fix: 更新 CI 配置以限制推送到 main 分支,更新 README 链接,添加必填项星号插件
Some checks failed
/ surge (push) Failing after 16s
Some checks failed
/ surge (push) Failing after 16s
This commit is contained in:
2
.github/workflows/ci.yaml
vendored
2
.github/workflows/ci.yaml
vendored
@ -1,6 +1,8 @@
|
|||||||
# https://cn.vitejs.dev/guide/static-deploy
|
# https://cn.vitejs.dev/guide/static-deploy
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
surge:
|
surge:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Vue FormKit Example
|
# Vue FormKit Example
|
||||||
|
|
||||||
- https://github.com/mathsgod/formkit-element$0
|
- https://github.com/mathsgod/formkit-element
|
||||||
|
|
||||||
---
|
---
|
||||||
- https://themes.formkit.com/editor?theme=regenesis
|
- https://themes.formkit.com/editor?theme=regenesis
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import type { FormKitOptions } from '@formkit/core'
|
import type { FormKitExtendableSchemaRoot, FormKitNode, FormKitOptions } from '@formkit/core'
|
||||||
import { createI18nPlugin, zh } from '@formkit/i18n'
|
import { createI18nPlugin, zh } from '@formkit/i18n'
|
||||||
import { genesisIcons } from '@formkit/icons'
|
import { genesisIcons } from '@formkit/icons'
|
||||||
import { checkbox, createLibraryPlugin, form, group, range, submit, text } from '@formkit/inputs'
|
import { checkbox, createLibraryPlugin, form, group, range, submit, text } from '@formkit/inputs'
|
||||||
@ -15,7 +15,46 @@ const theme = undefined;
|
|||||||
const icons = genesisIcons;
|
const icons = genesisIcons;
|
||||||
const themePlugin = createThemePlugin(theme, icons/* , iconLoaderUrl, iconLoader */)
|
const themePlugin = createThemePlugin(theme, icons/* , iconLoaderUrl, iconLoader */)
|
||||||
|
|
||||||
|
|
||||||
|
const legends = ['checkbox_multi', 'radio_multi', 'repeater', 'transferlist'];
|
||||||
|
function addAsteriskPlugin(node: FormKitNode) {
|
||||||
|
if (['button', 'submit', 'hidden', 'group', 'list', 'meta'].includes(node.props.type)) return;
|
||||||
|
|
||||||
|
node.on('created', () => {
|
||||||
|
const legendOrLabel = legends.includes(`${node.props.type}${node.props.options ? '_multi' : ''}`) ? 'legend' : 'label';
|
||||||
|
|
||||||
|
console.group(node.props.label || node.props.submitLabel)
|
||||||
|
console.debug(`node :>> `, node);
|
||||||
|
console.debug(`node.props.definition :>> `, node.props.definition);
|
||||||
|
// if (typeof node.props.definition!.schema === 'function') {
|
||||||
|
// console.debug(`node.props.definition.schema.call :>> `, node.props.definition!.schema.call(node.props.definition, {}));
|
||||||
|
// }
|
||||||
|
console.debug(`legendOrLabel :>> `, legendOrLabel);
|
||||||
|
console.groupEnd()
|
||||||
|
|
||||||
|
if (node.props.definition?.schemaMemoKey) {
|
||||||
|
node.props.definition.schemaMemoKey += `${node.props.options ? '_multi' : ''}_add_asterisk`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const schemaFn = node.props.definition!.schema!;
|
||||||
|
node.props.definition!.schema = (sectionsSchema = {}) => {
|
||||||
|
sectionsSchema[legendOrLabel] = {
|
||||||
|
children: ['$label', {
|
||||||
|
$el: 'span',
|
||||||
|
if: '$state.required',
|
||||||
|
attrs: {
|
||||||
|
class: '$classes.asterisk',
|
||||||
|
},
|
||||||
|
children: ['*']
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
|
||||||
|
return typeof schemaFn === 'function' ? schemaFn(sectionsSchema) : schemaFn
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
plugins: [library, themePlugin, bindings, i18n, validation,],
|
plugins: [library, themePlugin, bindings, i18n, validation, addAsteriskPlugin],
|
||||||
config: { rootClasses },
|
config: { rootClasses },
|
||||||
} satisfies FormKitOptions
|
} satisfies FormKitOptions
|
@ -15,16 +15,18 @@ const castNumber = (node: FormKitNode) => {
|
|||||||
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
console.group('onMounted')
|
||||||
const nameNode = getNode('nameNodeId')
|
const nameNode = getNode('nameNodeId')
|
||||||
Object.assign(window, { nameNode })
|
Object.assign(window, { nameNode })
|
||||||
console.debug('[onMounted]', `nameNode :>> `, nameNode);
|
console.debug(`nameNode :>> `, nameNode);
|
||||||
|
|
||||||
const schemaGroupInput = nameNode!.root.at('schemaGroup.input')
|
const schemaGroupInput = nameNode!.root.at('schemaGroup.input')
|
||||||
console.debug('[onMounted]', `schemaGroupInput :>> `, schemaGroupInput);
|
console.debug(`schemaGroupInput :>> `, schemaGroupInput);
|
||||||
nameNode!.on('commit', ({ payload }) => {
|
nameNode!.on('commit', ({ payload }) => {
|
||||||
console.debug('[nameNode] [on commit]', `payload :>> `, payload);
|
console.debug('[nameNode] [on commit]', `payload :>> `, payload);
|
||||||
schemaGroupInput!.input(`姓名:${payload}`)
|
schemaGroupInput!.input(`姓名:${payload}`)
|
||||||
})
|
})
|
||||||
|
console.groupEnd()
|
||||||
})
|
})
|
||||||
|
|
||||||
const SCHEMA: FormKitSchemaDefinition = [
|
const SCHEMA: FormKitSchemaDefinition = [
|
||||||
@ -89,6 +91,7 @@ const SCHEMA: FormKitSchemaDefinition = [
|
|||||||
id="nameNodeId"
|
id="nameNodeId"
|
||||||
label="姓名"
|
label="姓名"
|
||||||
help="别人都叫你什么?"
|
help="别人都叫你什么?"
|
||||||
|
some-attr="some-attr-value"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<FormKit
|
<FormKit
|
||||||
|
Reference in New Issue
Block a user