@silver-formily/element-plus 3.0.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en-US.md +32 -32
- package/README.md +32 -32
- package/esm/__builtins__/configs/index.mjs.map +1 -1
- package/esm/__builtins__/index.mjs +18 -18
- package/esm/__builtins__/shared/loading.mjs.map +1 -1
- package/esm/__builtins__/shared/simple-version-compare.mjs.map +1 -1
- package/esm/__builtins__/shared/transform-component.mjs.map +1 -1
- package/esm/__builtins__/shared/use-enter-submit.mjs.map +1 -1
- package/esm/__builtins__/shared/utils.mjs.map +1 -1
- package/esm/array-base/index.mjs +63 -59
- package/esm/array-base/index.mjs.map +1 -1
- package/esm/array-base/symbols.mjs.map +1 -1
- package/esm/array-base/utils.mjs +37 -31
- package/esm/array-base/utils.mjs.map +1 -1
- package/esm/array-cards/index.mjs +36 -33
- package/esm/array-cards/index.mjs.map +1 -1
- package/esm/array-collapse/index.mjs +39 -37
- package/esm/array-collapse/index.mjs.map +1 -1
- package/esm/array-collapse/utils.mjs +9 -2
- package/esm/array-collapse/utils.mjs.map +1 -1
- package/esm/array-items/index.mjs +38 -34
- package/esm/array-items/index.mjs.map +1 -1
- package/esm/array-list-tabs/index.mjs +38 -36
- package/esm/array-list-tabs/index.mjs.map +1 -1
- package/esm/array-list-tabs/utils.mjs +12 -5
- package/esm/array-list-tabs/utils.mjs.map +1 -1
- package/esm/array-table/index.mjs +62 -60
- package/esm/array-table/index.mjs.map +1 -1
- package/esm/array-table/utils.mjs +18 -11
- package/esm/array-table/utils.mjs.map +1 -1
- package/esm/array-tabs/index.mjs +28 -25
- package/esm/array-tabs/index.mjs.map +1 -1
- package/esm/autocomplete/index.mjs +22 -18
- package/esm/autocomplete/index.mjs.map +1 -1
- package/esm/cascader/index.mjs +22 -18
- package/esm/cascader/index.mjs.map +1 -1
- package/esm/checkbox/index.mjs +20 -16
- package/esm/checkbox/index.mjs.map +1 -1
- package/esm/color-picker/index.mjs +9 -6
- package/esm/color-picker/index.mjs.map +1 -1
- package/esm/color-picker-panel/index.mjs +9 -6
- package/esm/color-picker-panel/index.mjs.map +1 -1
- package/esm/date-picker/index.mjs +14 -11
- package/esm/date-picker/index.mjs.map +1 -1
- package/esm/date-picker/utils.mjs.map +1 -1
- package/esm/date-picker-panel/index.mjs +14 -11
- package/esm/date-picker-panel/index.mjs.map +1 -1
- package/esm/editable/index.mjs +33 -30
- package/esm/editable/index.mjs.map +1 -1
- package/esm/form/form.mjs +6 -6
- package/esm/form/form.mjs.map +1 -1
- package/esm/form-button-group/index.mjs +18 -14
- package/esm/form-button-group/index.mjs.map +1 -1
- package/esm/form-button-group/utils.mjs +9 -2
- package/esm/form-button-group/utils.mjs.map +1 -1
- package/esm/form-collapse/index.mjs +21 -18
- package/esm/form-collapse/index.mjs.map +1 -1
- package/esm/form-collapse/utils.mjs.map +1 -1
- package/esm/form-dialog/index.d.ts +1 -1
- package/esm/form-dialog/index.mjs +22 -22
- package/esm/form-dialog/index.mjs.map +1 -1
- package/esm/form-dialog/types.d.ts +13 -5
- package/esm/form-drawer/index.d.ts +1 -1
- package/esm/form-drawer/index.mjs +21 -21
- package/esm/form-drawer/index.mjs.map +1 -1
- package/esm/form-drawer/types.d.ts +13 -5
- package/esm/form-grid/hooks.mjs.map +1 -1
- package/esm/form-grid/index.mjs +21 -18
- package/esm/form-grid/index.mjs.map +1 -1
- package/esm/form-item/index.mjs +55 -53
- package/esm/form-item/index.mjs.map +1 -1
- package/esm/form-item/utils.mjs.map +1 -1
- package/esm/form-layout/form-layout.mjs +14 -10
- package/esm/form-layout/form-layout.mjs.map +1 -1
- package/esm/form-layout/utils.mjs.map +1 -1
- package/esm/form-step/index.mjs +30 -27
- package/esm/form-step/index.mjs.map +1 -1
- package/esm/form-step/utils.mjs.map +1 -1
- package/esm/form-tab/hooks.mjs.map +1 -1
- package/esm/form-tab/index.mjs +25 -23
- package/esm/form-tab/index.mjs.map +1 -1
- package/esm/form-tab/utils.mjs.map +1 -1
- package/esm/index.mjs +72 -72
- package/esm/input/index.mjs +30 -26
- package/esm/input/index.mjs.map +1 -1
- package/esm/input-number/index.mjs +11 -8
- package/esm/input-number/index.mjs.map +1 -1
- package/esm/input-tag/index.mjs +20 -16
- package/esm/input-tag/index.mjs.map +1 -1
- package/esm/mention/index.mjs +24 -20
- package/esm/mention/index.mjs.map +1 -1
- package/esm/pagination/components/jumper.mjs.map +1 -1
- package/esm/pagination/components/next.mjs.map +1 -1
- package/esm/pagination/components/pager.mjs.map +1 -1
- package/esm/pagination/components/prev.mjs.map +1 -1
- package/esm/pagination/components/total.mjs.map +1 -1
- package/esm/pagination/pagination.mjs.map +1 -1
- package/esm/password/index.mjs.map +1 -1
- package/esm/preview-text/index.mjs +31 -27
- package/esm/preview-text/index.mjs.map +1 -1
- package/esm/preview-text/utils.mjs.map +1 -1
- package/esm/query-form/default-components.mjs.map +1 -1
- package/esm/query-form/hooks.mjs.map +1 -1
- package/esm/query-form/index.mjs +51 -48
- package/esm/query-form/index.mjs.map +1 -1
- package/esm/query-form-item/index.mjs +37 -34
- package/esm/query-form-item/index.mjs.map +1 -1
- package/esm/radio/index.mjs +29 -25
- package/esm/radio/index.mjs.map +1 -1
- package/esm/rate/index.mjs +13 -10
- package/esm/rate/index.mjs.map +1 -1
- package/esm/reset/index.mjs.map +1 -1
- package/esm/segmented/index.mjs +16 -12
- package/esm/segmented/index.mjs.map +1 -1
- package/esm/select/index.mjs +26 -22
- package/esm/select/index.mjs.map +1 -1
- package/esm/select-table/index.mjs +16 -12
- package/esm/select-table/index.mjs.map +1 -1
- package/esm/shared/overlay-elements.mjs.map +1 -1
- package/esm/slider/index.mjs +13 -10
- package/esm/slider/index.mjs.map +1 -1
- package/esm/submit/index.mjs.map +1 -1
- package/esm/switch/index.mjs.map +1 -1
- package/esm/time-picker/index.mjs +9 -6
- package/esm/time-picker/index.mjs.map +1 -1
- package/esm/time-select/index.mjs +9 -6
- package/esm/time-select/index.mjs.map +1 -1
- package/esm/transfer/index.mjs.map +1 -1
- package/esm/tree/index.mjs +33 -29
- package/esm/tree/index.mjs.map +1 -1
- package/esm/tree/utils.mjs.map +1 -1
- package/esm/tree-select/index.mjs +18 -14
- package/esm/tree-select/index.mjs.map +1 -1
- package/esm/upload/index.mjs +10 -7
- package/esm/upload/index.mjs.map +1 -1
- package/esm/vendor/sizes.mjs.map +1 -1
- package/package.json +6 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/editable/editable-popover.vue","../../src/editable/editable.vue","../../src/editable/index.ts"],"sourcesContent":["<script lang=\"ts\" setup>\r\nimport type { Field } from '@formily/core'\r\nimport type { IFormItemProps } from '../form-item/types'\r\nimport { Edit } from '@element-plus/icons-vue'\r\nimport { reaction } from '@formily/reactive'\r\nimport { isValid } from '@formily/shared'\r\nimport { useField } from '@silver-formily/vue'\r\nimport { ElPopover, ElText, ClickOutside as vClickOutside } from 'element-plus'\r\nimport { ref } from 'vue'\r\nimport { stylePrefix } from '../__builtins__/configs'\r\nimport { FormBaseItem } from '../form-item'\r\n\r\ndefineOptions({\r\n name: 'FEditablePopover',\r\n inheritAttrs: false,\r\n})\r\n\r\nconst props = withDefaults(defineProps<IFormItemProps>(), {\r\n feedbackLayout: 'popover',\r\n size: 'default',\r\n})\r\n\r\nconst fieldRef = useField<Field>()\r\nconst prefixCls = `${stylePrefix}-editable`\r\nconst contentRef = ref<HTMLElement>()\r\nconst visible = ref(false)\r\n\r\nif (isValid(fieldRef.value.data)) {\r\n /* istanbul ignore else -- @preserve */\r\n if (!isValid(fieldRef.value.data.readPretty)) {\r\n fieldRef.value.data.readPretty = true\r\n }\r\n}\r\nelse {\r\n fieldRef.value.data = {}\r\n fieldRef.value.data.readPretty = true\r\n}\r\n\r\nfunction onClickOutside(e) {\r\n const popoverDOM = contentRef.value.parentElement\r\n /* istanbul ignore else -- @preserve */\r\n if (!popoverDOM.contains(e.target)) {\r\n visible.value = false\r\n }\r\n}\r\nfunction onClick() {\r\n visible.value = true\r\n}\r\n\r\nreaction(\r\n () => fieldRef.value.form.queryFeedbacks({\r\n type: 'error',\r\n address: `${fieldRef.value.address.entire}.*`,\r\n }),\r\n (errorList) => {\r\n if (errorList.length > 0) {\r\n visible.value = true\r\n }\r\n },\r\n)\r\n</script>\r\n\r\n<template>\r\n <div :class=\"prefixCls\">\r\n <ElPopover\r\n v-bind=\"$attrs\"\r\n :visible=\"visible\"\r\n :title=\"$attrs.title || fieldRef.title\" trigger=\"click\" width=\"auto\"\r\n >\r\n <template #default>\r\n <div ref=\"contentRef\" :class=\"`${prefixCls}-popover-wrapper`\">\r\n <slot />\r\n </div>\r\n </template>\r\n <template #reference>\r\n <FormBaseItem v-click-outside=\"onClickOutside\" v-bind=\"props\" :class=\"`${prefixCls}-trigger`\">\r\n <div :class=\"`${prefixCls}-content`\" @click=\"onClick\">\r\n <ElText>\r\n {{ fieldRef.title }}\r\n </ElText>\r\n <Edit :class=\"`${prefixCls}-edit-btn`\" />\r\n </div>\r\n </FormBaseItem>\r\n </template>\r\n </ElPopover>\r\n </div>\r\n</template>\r\n","<script lang=\"ts\" setup>\r\nimport type { Field } from '@formily/core'\r\nimport type { IFormItemProps } from '../form-item/types'\r\nimport { Close, Edit } from '@element-plus/icons-vue'\r\nimport { isPlainObj, isValid } from '@formily/shared'\r\nimport { useField } from '@silver-formily/vue'\r\nimport { ClickOutside as vClickOutside } from 'element-plus'\r\nimport { omit } from 'lodash-es'\r\nimport { computed, nextTick, ref } from 'vue'\r\nimport { stylePrefix } from '../__builtins__/configs'\r\nimport { FormBaseItem } from '../form-item'\r\n\r\ndefineOptions({\r\n name: 'FEditable',\r\n})\r\n\r\nconst props = withDefaults(defineProps<IFormItemProps & { editProps?: IFormItemProps }>(), {\r\n feedbackLayout: 'popover',\r\n size: 'default',\r\n})\r\n\r\nconst fieldRef = useField<Field>()\r\nconst innerRef = ref<HTMLElement>(null)\r\nconst prefixCls = `${stylePrefix}-editable`\r\nconst formItemRef = ref<InstanceType<typeof FormBaseItem>>(null)\r\n\r\nconst commonProps = computed(() => omit(props, 'editProps'))\r\nconst editProps = computed(() => {\r\n if (isPlainObj(props.editProps)) {\r\n return { ...omit(props, 'editProps'), ...props.editProps }\r\n }\r\n return omit(props, 'editProps')\r\n})\r\n\r\nfunction handleEnsureReadPretty() {\r\n if (!isValid(fieldRef.value.data)) {\r\n fieldRef.value.data = {}\r\n }\r\n}\r\n\r\nhandleEnsureReadPretty()\r\nfieldRef.value.data.readPretty = true\r\n\r\nasync function onClick() {\r\n if (fieldRef.value.disabled)\r\n return\r\n handleEnsureReadPretty()\r\n fieldRef.value.data.readPretty = false\r\n await nextTick()\r\n formItemRef.value.feedbackTooltipRef.updatePopper()\r\n innerRef.value?.querySelector('input')?.focus()\r\n}\r\n\r\nfunction onClickOutside() {\r\n if (fieldRef.value.data?.readPretty === true)\r\n return\r\n handleEnsureReadPretty()\r\n // 使用下拉菜单等触发的事件完成应有的操作\r\n setTimeout(async () => {\r\n fieldRef.value.data.readPretty = true\r\n await nextTick()\r\n formItemRef.value?.feedbackTooltipRef.updatePopper()\r\n }, 0)\r\n}\r\n</script>\r\n\r\n<template>\r\n <div ref=\"innerRef\" :class=\"[prefixCls, fieldRef.disabled && 'is-disabled']\">\r\n <div v-click-outside=\"onClickOutside\" :class=\"`${prefixCls}-content`\">\r\n <FormBaseItem ref=\"formItemRef\" v-bind=\"fieldRef.data?.readPretty === false ? editProps : commonProps\" @click=\"onClick\">\r\n <div>\r\n <slot />\r\n </div>\r\n </FormBaseItem>\r\n <template v-if=\"!fieldRef.disabled\">\r\n <template v-if=\"fieldRef.data?.readPretty === true\">\r\n <FormBaseItem :size=\"props.size\" :feedback-layout=\"props.feedbackLayout\">\r\n <Edit :class=\"`${prefixCls}-edit-btn`\" @click=\"onClick\" />\r\n </FormBaseItem>\r\n </template>\r\n <template v-else>\r\n <FormBaseItem :size=\"props.size\" :feedback-layout=\"props.feedbackLayout\">\r\n <Close :class=\"`${prefixCls}-close-btn`\" @click=\"onClickOutside\" />\r\n </FormBaseItem>\r\n </template>\r\n </template>\r\n </div>\r\n </div>\r\n</template>\r\n","import type { ElPopover } from 'element-plus'\r\nimport type { IFormItemProps } from '../form-item/types'\r\nimport { connect, mapProps } from '@silver-formily/vue'\r\nimport { composeExport } from '../__builtins__/shared'\r\nimport { fieldFeedbackMapper } from '../form-item'\r\nimport FEditablePopover from './editable-popover.vue'\r\nimport FEditable from './editable.vue'\r\nimport './style.scss'\r\n\r\nexport type EditableProps = IFormItemProps\r\nexport type EditablePopoverProps = typeof ElPopover\r\n\r\nconst EditableInner = connect<typeof FEditable>(FEditable, mapProps(\r\n {\r\n required: true,\r\n description: 'extra',\r\n },\r\n fieldFeedbackMapper,\r\n))\r\n\r\nconst EditablePopover = connect<typeof FEditablePopover>(FEditablePopover, mapProps(\r\n {\r\n required: true,\r\n description: 'extra',\r\n },\r\n fieldFeedbackMapper,\r\n))\r\n\r\nexport const Editable = composeExport(EditableInner, {\r\n Popover: EditablePopover,\r\n})\r\n\r\nexport default Editable\r\n"],"names":["props","__props","fieldRef","useField","prefixCls","stylePrefix","contentRef","ref","visible","isValid","onClickOutside","e","onClick","reaction","errorList","_createElementBlock","_createVNode","_unref","ElPopover","_mergeProps","_ctx","$attrs","_createElementVNode","_renderSlot","_createBlock","FormBaseItem","ElText","_createTextVNode","_toDisplayString","Edit","innerRef","formItemRef","commonProps","computed","omit","editProps","isPlainObj","handleEnsureReadPretty","nextTick","_normalizeClass","_Fragment","Close","EditableInner","connect","FEditable","mapProps","fieldFeedbackMapper","EditablePopover","FEditablePopover","Editable","composeExport"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,UAAMA,IAAQC,GAKRC,IAAWC,EAAA,GACXC,IAAY,GAAGC,CAAW,aAC1BC,IAAaC,EAAA,GACbC,IAAUD,EAAI,EAAK;AAEzB,IAAIE,EAAQP,EAAS,MAAM,IAAI,IAExBO,EAAQ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;AAAA,EAEfC;AACF,CAAC,GAEYG,KAAWC,EAAcR,GAAe;AAAA,EACnD,SAASK;AACX,CAAC;"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/editable/editable-popover.vue","../../src/editable/editable.vue","../../src/editable/index.ts"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { Field } from '@formily/core'\nimport type { IFormItemProps } from '../form-item/types'\nimport { Edit } from '@element-plus/icons-vue'\nimport { reaction } from '@formily/reactive'\nimport { isValid } from '@formily/shared'\nimport { useField } from '@silver-formily/vue'\nimport { ElPopover, ElText, ClickOutside as vClickOutside } from 'element-plus'\nimport { ref } from 'vue'\nimport { stylePrefix } from '../__builtins__/configs'\nimport { FormBaseItem } from '../form-item'\n\ndefineOptions({\n name: 'FEditablePopover',\n inheritAttrs: false,\n})\n\nconst props = withDefaults(defineProps<IFormItemProps>(), {\n feedbackLayout: 'popover',\n size: 'default',\n})\n\nconst fieldRef = useField<Field>()\nconst prefixCls = `${stylePrefix}-editable`\nconst contentRef = ref<HTMLElement>()\nconst visible = ref(false)\n\nif (isValid(fieldRef.value.data)) {\n /* istanbul ignore else -- @preserve */\n if (!isValid(fieldRef.value.data.readPretty)) {\n fieldRef.value.data.readPretty = true\n }\n}\nelse {\n fieldRef.value.data = {}\n fieldRef.value.data.readPretty = true\n}\n\nfunction onClickOutside(e) {\n const popoverDOM = contentRef.value.parentElement\n /* istanbul ignore else -- @preserve */\n if (!popoverDOM.contains(e.target)) {\n visible.value = false\n }\n}\nfunction onClick() {\n visible.value = true\n}\n\nreaction(\n () => fieldRef.value.form.queryFeedbacks({\n type: 'error',\n address: `${fieldRef.value.address.entire}.*`,\n }),\n (errorList) => {\n if (errorList.length > 0) {\n visible.value = true\n }\n },\n)\n</script>\n\n<template>\n <div :class=\"prefixCls\">\n <ElPopover\n v-bind=\"$attrs\"\n :visible=\"visible\"\n :title=\"$attrs.title || fieldRef.title\" trigger=\"click\" width=\"auto\"\n >\n <template #default>\n <div ref=\"contentRef\" :class=\"`${prefixCls}-popover-wrapper`\">\n <slot />\n </div>\n </template>\n <template #reference>\n <FormBaseItem v-click-outside=\"onClickOutside\" v-bind=\"props\" :class=\"`${prefixCls}-trigger`\">\n <div :class=\"`${prefixCls}-content`\" @click=\"onClick\">\n <ElText>\n {{ fieldRef.title }}\n </ElText>\n <Edit :class=\"`${prefixCls}-edit-btn`\" />\n </div>\n </FormBaseItem>\n </template>\n </ElPopover>\n </div>\n</template>\n","<script lang=\"ts\" setup>\nimport type { Field } from '@formily/core'\nimport type { IFormItemProps } from '../form-item/types'\nimport { Close, Edit } from '@element-plus/icons-vue'\nimport { isPlainObj, isValid } from '@formily/shared'\nimport { useField } from '@silver-formily/vue'\nimport { ClickOutside as vClickOutside } from 'element-plus'\nimport { omit } from 'lodash-es'\nimport { computed, nextTick, ref } from 'vue'\nimport { stylePrefix } from '../__builtins__/configs'\nimport { FormBaseItem } from '../form-item'\n\ndefineOptions({\n name: 'FEditable',\n})\n\nconst props = withDefaults(defineProps<IFormItemProps & { editProps?: IFormItemProps }>(), {\n feedbackLayout: 'popover',\n size: 'default',\n})\n\nconst fieldRef = useField<Field>()\nconst innerRef = ref<HTMLElement>(null)\nconst prefixCls = `${stylePrefix}-editable`\nconst formItemRef = ref<InstanceType<typeof FormBaseItem>>(null)\n\nconst commonProps = computed(() => omit(props, 'editProps'))\nconst editProps = computed(() => {\n if (isPlainObj(props.editProps)) {\n return { ...omit(props, 'editProps'), ...props.editProps }\n }\n return omit(props, 'editProps')\n})\n\nfunction handleEnsureReadPretty() {\n if (!isValid(fieldRef.value.data)) {\n fieldRef.value.data = {}\n }\n}\n\nhandleEnsureReadPretty()\nfieldRef.value.data.readPretty = true\n\nasync function onClick() {\n if (fieldRef.value.disabled)\n return\n handleEnsureReadPretty()\n fieldRef.value.data.readPretty = false\n await nextTick()\n formItemRef.value.feedbackTooltipRef.updatePopper()\n innerRef.value?.querySelector('input')?.focus()\n}\n\nfunction onClickOutside() {\n if (fieldRef.value.data?.readPretty === true)\n return\n handleEnsureReadPretty()\n // 使用下拉菜单等触发的事件完成应有的操作\n setTimeout(async () => {\n fieldRef.value.data.readPretty = true\n await nextTick()\n formItemRef.value?.feedbackTooltipRef.updatePopper()\n }, 0)\n}\n</script>\n\n<template>\n <div ref=\"innerRef\" :class=\"[prefixCls, fieldRef.disabled && 'is-disabled']\">\n <div v-click-outside=\"onClickOutside\" :class=\"`${prefixCls}-content`\">\n <FormBaseItem ref=\"formItemRef\" v-bind=\"fieldRef.data?.readPretty === false ? editProps : commonProps\" @click=\"onClick\">\n <div>\n <slot />\n </div>\n </FormBaseItem>\n <template v-if=\"!fieldRef.disabled\">\n <template v-if=\"fieldRef.data?.readPretty === true\">\n <FormBaseItem :size=\"props.size\" :feedback-layout=\"props.feedbackLayout\">\n <Edit :class=\"`${prefixCls}-edit-btn`\" @click=\"onClick\" />\n </FormBaseItem>\n </template>\n <template v-else>\n <FormBaseItem :size=\"props.size\" :feedback-layout=\"props.feedbackLayout\">\n <Close :class=\"`${prefixCls}-close-btn`\" @click=\"onClickOutside\" />\n </FormBaseItem>\n </template>\n </template>\n </div>\n </div>\n</template>\n","import type { ElPopover } from 'element-plus'\nimport type { IFormItemProps } from '../form-item/types'\nimport { connect, mapProps } from '@silver-formily/vue'\nimport { composeExport } from '../__builtins__/shared'\nimport { fieldFeedbackMapper } from '../form-item'\nimport FEditablePopover from './editable-popover.vue'\nimport FEditable from './editable.vue'\nimport './style.scss'\n\nexport type EditableProps = IFormItemProps\nexport type EditablePopoverProps = typeof ElPopover\n\nconst EditableInner = connect<typeof FEditable>(FEditable, mapProps(\n {\n required: true,\n description: 'extra',\n },\n fieldFeedbackMapper,\n))\n\nconst EditablePopover = connect<typeof FEditablePopover>(FEditablePopover, mapProps(\n {\n required: true,\n description: 'extra',\n },\n fieldFeedbackMapper,\n))\n\nexport const Editable = composeExport(EditableInner, {\n Popover: EditablePopover,\n})\n\nexport default Editable\n"],"names":["props","__props","fieldRef","useField","prefixCls","stylePrefix","contentRef","ref","visible","isValid","onClickOutside","e","onClick","reaction","errorList","_createElementBlock","_createVNode","_unref","ElPopover","_mergeProps","_ctx","$attrs","_createElementVNode","_renderSlot","_createBlock","FormBaseItem","ElText","_createTextVNode","_toDisplayString","Edit","innerRef","formItemRef","commonProps","computed","omit","editProps","isPlainObj","handleEnsureReadPretty","nextTick","_normalizeClass","_Fragment","Close","EditableInner","connect","FEditable","mapProps","fieldFeedbackMapper","EditablePopover","FEditablePopover","Editable","composeExport"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,UAAMA,IAAQC,GAKRC,IAAWC,EAAA,GACXC,IAAY,GAAGC,CAAW,aAC1BC,IAAaC,EAAA,GACbC,IAAUD,EAAI,EAAK;AAEzB,IAAIE,EAAQP,EAAS,MAAM,IAAI,IAExBO,EAAQP,EAAS,MAAM,KAAK,UAAU,MACzCA,EAAS,MAAM,KAAK,aAAa,OAInCA,EAAS,MAAM,OAAO,CAAA,GACtBA,EAAS,MAAM,KAAK,aAAa;AAGnC,aAASQ,EAAeC,GAAG;AAGzB,MAFmBL,EAAW,MAAM,cAEpB,SAASK,EAAE,MAAM,MAC/BH,EAAQ,QAAQ;AAAA,IAEpB;AACA,aAASI,IAAU;AACjB,MAAAJ,EAAQ,QAAQ;AAAA,IAClB;AAEA,WAAAK;AAAA,MACE,MAAMX,EAAS,MAAM,KAAK,eAAe;AAAA,QACvC,MAAM;AAAA,QACN,SAAS,GAAGA,EAAS,MAAM,QAAQ,MAAM;AAAA,MAAA,CAC1C;AAAA,MACD,CAACY,MAAc;AACb,QAAIA,EAAU,SAAS,MACrBN,EAAQ,QAAQ;AAAA,MAEpB;AAAA,IAAA,mBAKAO,EAsBM,OAAA;AAAA,MAtBA,SAAOX,CAAS;AAAA,IAAA;MACpBY,EAoBYC,EAAAC,CAAA,GApBZC,EAoBYC,EAAA,QAnBI;AAAA,QACb,SAASZ,EAAA;AAAA,QACT,OAAOa,EAAAA,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AAnD,YAAUzB,CAAS,WAAA;AAAA,gBAAc,SAAAQ;AAAA,cAAA;;;sDAI1CY,EAEeP,EAAAQ,CAAA,GAAA;AAAA;YAFA,MAAMzB,EAAM;AAAA,YAAO,mBAAiBA,EAAM;AAAA,UAAA;uBACvD,MAAmE;AAAA,cAAnEgB,EAAmEC,EAAAwB,CAAA,GAAA;AAAA,gBAA3D,YAAUrC,CAAS,YAAA;AAAA,gBAAe,SAAOM;AAAA,cAAA;;;;;;eAdnCA,CAAc;AAAA,MAAA;;;ICxDlCgC,IAAgBC,EAA0BC,GAAWC;AAAA,EACzD;AAAA,IACE,UAAU;AAAA,IACV,aAAa;AAAA,EAAA;AAAA,EAEfC;AACF,CAAC,GAEKC,IAAkBJ,EAAiCK,GAAkBH;AAAA,EACzE;AAAA,IACE,UAAU;AAAA,IACV,aAAa;AAAA,EAAA;AAAA,EAEfC;AACF,CAAC,GAEYG,KAAWC,EAAcR,GAAe;AAAA,EACnD,SAASK;AACX,CAAC;"}
|
package/esm/form/form.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineComponent as h, openBlock as f, createBlock as p, unref as t, withCtx as i, createVNode as n, mergeProps as d, renderSlot as s, withModifiers as S, createCommentVNode as F } from "vue";
|
|
2
2
|
import { useForm as v, FormProvider as w } from "@silver-formily/vue";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { _ as c } from "../form-layout/form-layout.mjs";
|
|
4
|
+
import { PreviewText as b } from "../preview-text/index.mjs";
|
|
5
5
|
const $ = /* @__PURE__ */ h({
|
|
6
6
|
name: "FForm",
|
|
7
7
|
inheritAttrs: !1,
|
|
@@ -30,11 +30,11 @@ const $ = /* @__PURE__ */ h({
|
|
|
30
30
|
form: o.form
|
|
31
31
|
}, {
|
|
32
32
|
default: i(() => [
|
|
33
|
-
n(t(
|
|
33
|
+
n(t(b), {
|
|
34
34
|
placeholder: o.previewTextPlaceholder
|
|
35
35
|
}, {
|
|
36
36
|
default: i(() => [
|
|
37
|
-
n(t(
|
|
37
|
+
n(t(c), d(m.$attrs, {
|
|
38
38
|
onSubmit: r[0] || (r[0] = (e) => a(e, l.form))
|
|
39
39
|
}), {
|
|
40
40
|
default: i(() => [
|
|
@@ -47,12 +47,12 @@ const $ = /* @__PURE__ */ h({
|
|
|
47
47
|
}, 8, ["placeholder"])
|
|
48
48
|
]),
|
|
49
49
|
_: 3
|
|
50
|
-
}, 8, ["form"])) : t(u) ? (f(), p(t(
|
|
50
|
+
}, 8, ["form"])) : t(u) ? (f(), p(t(b), {
|
|
51
51
|
key: 1,
|
|
52
52
|
placeholder: o.previewTextPlaceholder
|
|
53
53
|
}, {
|
|
54
54
|
default: i(() => [
|
|
55
|
-
n(t(
|
|
55
|
+
n(t(c), d(m.$attrs, {
|
|
56
56
|
onSubmit: r[1] || (r[1] = S((e) => a(e, t(u)), ["prevent", "stop"]))
|
|
57
57
|
}), {
|
|
58
58
|
default: i(() => [
|
package/esm/form/form.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form.mjs","sources":["../../src/form/form.vue"],"sourcesContent":["<script lang=\"ts\" setup>\
|
|
1
|
+
{"version":3,"file":"form.mjs","sources":["../../src/form/form.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { Form as FormType, IFormFeedback } from '@formily/core'\nimport type { PropType } from 'vue'\nimport { FormProvider, useForm } from '@silver-formily/vue'\nimport { FormLayout } from '../form-layout'\nimport { PreviewText } from '../preview-text'\n\ndefineOptions({\n name: 'FForm',\n inheritAttrs: false,\n})\n\nconst props = defineProps({\n form: {\n type: Object as PropType<FormType>,\n },\n previewTextPlaceholder: {\n type: String,\n },\n onAutoSubmit: {\n type: Function as PropType<(values: FormType['values']) => Promise<any>>,\n },\n onAutoSubmitFailed: {\n type: Function as PropType<(error: IFormFeedback[]) => void>,\n },\n})\n\nconst top = useForm()\n\nfunction handleSubmit(e: Event, form: FormType) {\n form\n .submit(values => props.onAutoSubmit?.(values))\n .catch(error => props.onAutoSubmitFailed?.(error))\n}\n</script>\n\n<template>\n <FormProvider v-if=\"props.form\" :form=\"props.form\">\n <PreviewText :placeholder=\"props.previewTextPlaceholder\">\n <FormLayout v-bind=\"$attrs\" @submit=\"(e) => handleSubmit(e, form)\">\n <slot />\n </FormLayout>\n </PreviewText>\n </FormProvider>\n <template v-else-if=\"top\">\n <PreviewText :placeholder=\"props.previewTextPlaceholder\">\n <FormLayout\n v-bind=\"$attrs\"\n @submit.prevent.stop=\"(e) => handleSubmit(e, top)\"\n >\n <slot />\n </FormLayout>\n </PreviewText>\n </template>\n</template>\n"],"names":["props","__props","top","useForm","handleSubmit","e","form","values","error","_createBlock","_unref","FormProvider","_createVNode","PreviewText","FormLayout","_mergeProps","_ctx","_renderSlot"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAYA,UAAMA,IAAQC,GAeRC,IAAMC,EAAA;AAEZ,aAASC,EAAaC,GAAUC,GAAgB;AAC9C,MAAAA,EACG,OAAO,CAAAC,MAAUP,EAAM,eAAeO,CAAM,CAAC,EAC7C,MAAM,CAAAC,MAASR,EAAM,qBAAqBQ,CAAK,CAAC;AAAA,IACrD;qBAIsBR,EAAM,aAA1BS,EAMeC,EAAAC,CAAA,GAAA;AAAA;MANkB,MAAMX,EAAM;AAAA,IAAA;iBAC3C,MAIc;AAAA,QAJdY,EAIcF,EAAAG,CAAA,GAAA;AAAA,UAJA,aAAab,EAAM;AAAA,QAAA;qBAC/B,MAEa;AAAA,YAFbY,EAEaF,EAAAI,CAAA,GAFbC,EAEaC,EAAA,QAFa;AAAA,cAAG,2BAAS,MAAMZ,EAAa,GAAGH,EAAA,IAAI;AAAA,YAAA;yBAC9D,MAAQ;AAAA,gBAARgB,EAAQD,EAAA,QAAA,SAAA;AAAA,cAAA;;;;;;;;uBAION,EAAAR,CAAA,UACnBO,EAOcC,EAAAG,CAAA,GAAA;AAAA;MAPA,aAAab,EAAM;AAAA,IAAA;iBAC/B,MAKa;AAAA,QALbY,EAKaF,EAAAI,CAAA,GALbC,EAKaC,EAAA,QAJG;AAAA,UACb,6BAAsB,MAAMZ,EAAa,GAAGM,EAAAR,CAAA,CAAG,GAAA,CAAA,WAAA,MAAA,CAAA;AAAA,QAAA;qBAEhD,MAAQ;AAAA,YAARe,EAAQD,EAAA,QAAA,SAAA;AAAA,UAAA;;;;;;;;"}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
1
|
+
import { useAttrs as y, ElAffix as g, ElSpace as m } from "element-plus";
|
|
2
|
+
import "@formily/reactive";
|
|
3
|
+
import "@vueuse/core";
|
|
4
|
+
import { defineComponent as p, computed as _, openBlock as s, createBlock as n, unref as e, mergeProps as a, withCtx as l, renderSlot as u, createVNode as $, normalizeStyle as v } from "vue";
|
|
5
|
+
import "@formily/core";
|
|
6
|
+
import "@silver-formily/reactive-vue";
|
|
7
|
+
import { useForm as h } from "@silver-formily/vue";
|
|
8
|
+
import { composeExport as F } from "../__builtins__/shared/utils.mjs";
|
|
9
|
+
import { useFormLayoutId as k } from "../form-layout/utils.mjs";
|
|
5
10
|
import { prefixCls as r } from "./utils.mjs";
|
|
6
|
-
import { FormItem as
|
|
7
|
-
import { composeExport as x } from "../__builtins__/shared/utils.mjs";
|
|
11
|
+
import { FormItem as x } from "../form-item/index.mjs";
|
|
8
12
|
import '../styles/form-button-group/index.css';const B = /* @__PURE__ */ p({
|
|
9
13
|
__name: "form-button-group-sticky",
|
|
10
14
|
setup(f) {
|
|
11
|
-
const t =
|
|
12
|
-
return (d, z) => (
|
|
15
|
+
const t = y(), o = h(), i = k(), c = _(() => t.value.target ? t.value.target : i.value ? `#${i.value}` : o.value?.id ? `#formily-${o.value.id}` : void 0);
|
|
16
|
+
return (d, z) => (s(), n(e(g), a({
|
|
13
17
|
class: `${e(r)}__sticky`
|
|
14
18
|
}, e(t), {
|
|
15
19
|
position: e(t).position ?? "bottom",
|
|
@@ -45,7 +49,7 @@ import '../styles/form-button-group/index.css';const B = /* @__PURE__ */ p({
|
|
|
45
49
|
},
|
|
46
50
|
setup(f) {
|
|
47
51
|
const t = f;
|
|
48
|
-
return (o,
|
|
52
|
+
return (o, i) => t.alignFormItem ? (s(), n(e(x), a({
|
|
49
53
|
key: 0,
|
|
50
54
|
label: " "
|
|
51
55
|
}, o.$attrs, {
|
|
@@ -55,9 +59,9 @@ import '../styles/form-button-group/index.css';const B = /* @__PURE__ */ p({
|
|
|
55
59
|
}
|
|
56
60
|
}), {
|
|
57
61
|
default: l(() => [
|
|
58
|
-
|
|
62
|
+
$(e(m), {
|
|
59
63
|
size: t.gutter,
|
|
60
|
-
style:
|
|
64
|
+
style: v(t.align === "left" ? void 0 : {
|
|
61
65
|
justifyContent: t.align === "right" ? "flex-end" : "center",
|
|
62
66
|
display: "flex",
|
|
63
67
|
width: "100%"
|
|
@@ -70,7 +74,7 @@ import '../styles/form-button-group/index.css';const B = /* @__PURE__ */ p({
|
|
|
70
74
|
}, 8, ["size", "style"])
|
|
71
75
|
]),
|
|
72
76
|
_: 3
|
|
73
|
-
}, 16, ["class"])) : (
|
|
77
|
+
}, 16, ["class"])) : (s(), n(e(m), a({ key: 1 }, o.$attrs, {
|
|
74
78
|
class: [e(r), t.inline && `${e(r)}--inline`],
|
|
75
79
|
style: {
|
|
76
80
|
justifyContent: t.align === "left" ? "flex-start" : t.align === "right" ? "flex-end" : "center",
|
|
@@ -84,10 +88,10 @@ import '../styles/form-button-group/index.css';const B = /* @__PURE__ */ p({
|
|
|
84
88
|
_: 3
|
|
85
89
|
}, 16, ["class", "style", "size"]));
|
|
86
90
|
}
|
|
87
|
-
}),
|
|
91
|
+
}), R = F(b, {
|
|
88
92
|
Sticky: B
|
|
89
93
|
});
|
|
90
94
|
export {
|
|
91
|
-
|
|
95
|
+
R as FormButtonGroup
|
|
92
96
|
};
|
|
93
97
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/form-button-group/form-button-group-sticky.vue","../../src/form-button-group/form-button-group.vue","../../src/form-button-group/index.ts"],"sourcesContent":["<script setup lang=\"ts\">\
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/form-button-group/form-button-group-sticky.vue","../../src/form-button-group/form-button-group.vue","../../src/form-button-group/index.ts"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { AffixProps } from 'element-plus'\nimport type { ComputedRef } from 'vue'\nimport { useForm } from '@silver-formily/vue'\nimport { ElAffix, useAttrs } from 'element-plus'\nimport { computed } from 'vue'\nimport { useFormLayoutId } from '../form-layout/utils'\nimport { prefixCls } from './utils'\n\nconst attrs = useAttrs() as ComputedRef<Partial<AffixProps>>\nconst formRef = useForm()\nconst formLayoutId = useFormLayoutId()\n\nconst target = computed(() => {\n if (attrs.value.target) {\n return attrs.value.target\n }\n if (formLayoutId.value) {\n return `#${formLayoutId.value}`\n }\n /* istanbul ignore next -- @preserve */\n return formRef.value?.id ? `#formily-${formRef.value.id}` : undefined\n})\n</script>\n\n<template>\n <ElAffix\n :class=\"`${prefixCls}__sticky`\"\n v-bind=\"attrs\"\n :position=\"attrs.position ?? 'bottom'\"\n :target=\"target\"\n >\n <slot />\n </ElAffix>\n</template>\n","<script lang=\"ts\" setup>\nimport { ElSpace } from 'element-plus'\nimport FormItem from '../form-item/index'\nimport { prefixCls } from './utils'\n\ndefineOptions({\n name: 'FFormButtonGroup',\n inheritAttrs: false,\n})\n\nconst props = defineProps({\n align: {\n type: String,\n default: 'left',\n },\n inline: {\n type: Boolean,\n default: false,\n },\n gutter: {\n type: Number,\n default: 8,\n },\n alignFormItem: {\n type: Boolean,\n default: false,\n },\n})\n</script>\n\n<template>\n <FormItem\n v-if=\"props.alignFormItem\"\n label=\" \"\n v-bind=\"$attrs\"\n :class=\"[prefixCls, props.inline && `${prefixCls}--inline`]\"\n :style=\"{\n width: '100%',\n }\"\n >\n <ElSpace\n :size=\"props.gutter\"\n :style=\"props.align === 'left'\n ? undefined\n : {\n justifyContent: props.align === 'right' ? 'flex-end' : 'center',\n display: 'flex',\n width: '100%',\n }\"\n >\n <slot />\n </ElSpace>\n </FormItem>\n <ElSpace\n v-else\n v-bind=\"$attrs\"\n :class=\"[prefixCls, props.inline && `${prefixCls}--inline`]\"\n :style=\"{\n justifyContent: props.align === 'left'\n ? 'flex-start'\n : (props.align === 'right'\n ? 'flex-end'\n : 'center'),\n display: 'flex',\n }\"\n :size=\"props.gutter\"\n >\n <slot />\n </ElSpace>\n</template>\n","import { composeExport } from '../__builtins__/shared'\nimport FormButtonGroupSticky from './form-button-group-sticky.vue'\nimport FormButtonGroupInner from './form-button-group.vue'\nimport './style.scss'\n\nexport const FormButtonGroup = composeExport(FormButtonGroupInner, {\n Sticky: FormButtonGroupSticky,\n})\n"],"names":["attrs","useAttrs","formRef","useForm","formLayoutId","useFormLayoutId","target","computed","_openBlock","_createBlock","_unref","_mergeProps","prefixCls","_renderSlot","_ctx","props","__props","$attrs","_createVNode","ElSpace","_normalizeStyle","FormButtonGroup","composeExport","FormButtonGroupInner","FormButtonGroupSticky"],"mappings":";;;;;;;;;;;;;;AASA,UAAMA,IAAQC,EAAA,GACRC,IAAUC,EAAA,GACVC,IAAeC,EAAA,GAEfC,IAASC,EAAS,MAClBP,EAAM,MAAM,SACPA,EAAM,MAAM,SAEjBI,EAAa,QACR,IAAIA,EAAa,KAAK,KAGxBF,EAAQ,OAAO,KAAK,YAAYA,EAAQ,MAAM,EAAE,KAAK,MAC7D;sBAICM,KAAAC,EAOUC,MAPVC,EAOU;AAAA,MANP,UAAUD,EAAAE,CAAA,CAAS;AAAA,IAAA,GACZF,EAAAV,CAAA,GAAK;AAAA,MACZ,UAAUU,EAAAV,CAAA,EAAM,YAAQ;AAAA,MACxB,QAAQM,EAAA;AAAA,IAAA;iBAET,MAAQ;AAAA,QAARO,EAAQC,EAAA,QAAA,SAAA;AAAA,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;ACtBZ,UAAMC,IAAQC;qBAsBJD,EAAM,iBADdP,EAAA,GAAAC,EAqBWC,MArBXC,EAqBW;AAAA;MAnBT,OAAM;AAAA,IAAA,GACEM,EAAAA,QAAM;AAAA,MACb,QAAQP,EAAAE,CAAA,GAAWG,EAAM,aAAaL,EAAAE,CAAA,CAAS,UAAA;AAAA,MAC/C,OAAO;AAAA;;IAEP;iBAED,MAWU;AAAA,QAXVM,EAWUR,EAAAS,CAAA,GAAA;AAAA,UAVP,MAAMJ,EAAM;AAAA,UACZ,OAAKK,EAAEL,EAAM,UAAK,SAAsB;YAAgD,gBAAAA,EAAM,UAAK,UAAA,aAAA;AAAA;;;;qBAQpG,MAAQ;AAAA,YAARF,EAAQC,EAAA,QAAA,SAAA;AAAA,UAAA;;;;;+BAGZL,EAeUC,EAAAS,CAAA,GAfVR,EAeU,EAAA,KAAA,EAAA,GAbAM,EAAAA,QAAM;AAAA,MACb,QAAQP,EAAAE,CAAA,GAAWG,EAAM,aAAaL,EAAAE,CAAA,CAAS,UAAA;AAAA,MAC/C,OAAK;AAAA,QAA0B,gBAAAG,EAAM,UAAK,wBAA8CA,EAAM,UAAK;;;MAQnG,MAAMA,EAAM;AAAA,IAAA;iBAEb,MAAQ;AAAA,QAARF,EAAQC,EAAA,QAAA,SAAA;AAAA,MAAA;;;;IC9DCO,IAAkBC,EAAcC,GAAsB;AAAA,EACjE,QAAQC;AACV,CAAC;"}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { stylePrefix as o } from "../__builtins__/configs/index.mjs";
|
|
2
|
-
|
|
2
|
+
import "element-plus";
|
|
3
|
+
import "@formily/reactive";
|
|
4
|
+
import "@vueuse/core";
|
|
5
|
+
import "vue";
|
|
6
|
+
import "@formily/core";
|
|
7
|
+
import "@silver-formily/reactive-vue";
|
|
8
|
+
import "@silver-formily/vue";
|
|
9
|
+
const x = `${o}-form-button-group`;
|
|
3
10
|
export {
|
|
4
|
-
|
|
11
|
+
x as prefixCls
|
|
5
12
|
};
|
|
6
13
|
//# sourceMappingURL=utils.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","sources":["../../src/form-button-group/utils.ts"],"sourcesContent":["import { stylePrefix } from '../__builtins__'\
|
|
1
|
+
{"version":3,"file":"utils.mjs","sources":["../../src/form-button-group/utils.ts"],"sourcesContent":["import { stylePrefix } from '../__builtins__'\n\nexport const prefixCls = `${stylePrefix}-form-button-group`\n"],"names":["prefixCls","stylePrefix"],"mappings":";;;;;;;;AAEO,MAAMA,IAAY,GAAGC,CAAW;"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { defineComponent as K, computed as V, openBlock as o, createBlock as s, unref as e, mergeProps as k, withCtx as c, createElementBlock as u, Fragment as m, renderList as N, normalizeClass as P, resolveDynamicComponent as F, toDisplayString as _, createTextVNode as $, createVNode as D, h as R } from "vue";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
2
|
+
import { ElCollapse as h, ElCollapseItem as j, ElBadge as q } from "element-plus";
|
|
3
|
+
import "@formily/reactive";
|
|
4
|
+
import "@vueuse/core";
|
|
5
|
+
import "@formily/core";
|
|
6
|
+
import { formilyComputed as g } from "@silver-formily/reactive-vue";
|
|
7
|
+
import { useField as w, useFieldSchema as z, RecursionField as L } from "@silver-formily/vue";
|
|
8
|
+
import { useCleanAttrs as O, composeExport as T } from "../__builtins__/shared/utils.mjs";
|
|
9
|
+
import { isFn as E } from "@formily/shared";
|
|
10
|
+
import { stylePrefix as U } from "../__builtins__/configs/index.mjs";
|
|
11
|
+
import { usePanels as G, createFormCollapse as A } from "./utils.mjs";
|
|
9
12
|
import '../styles/form-collapse/index.css';const H = { key: 1 }, J = /* @__PURE__ */ K({
|
|
10
13
|
inheritAttrs: !1,
|
|
11
14
|
__name: "form-collapse",
|
|
@@ -16,17 +19,17 @@ import '../styles/form-collapse/index.css';const H = { key: 1 }, J = /* @__PURE_
|
|
|
16
19
|
}
|
|
17
20
|
},
|
|
18
21
|
setup(C) {
|
|
19
|
-
const r = C, x = `${
|
|
22
|
+
const r = C, x = `${U}-form-collapse`, { props: b } = O(["modelValue", "onUpdate:modelValue"]), i = w(), B = z(), f = g(() => G(i.value, B.value)), d = V(
|
|
20
23
|
() => r.formCollapse ?? A()
|
|
21
24
|
);
|
|
22
25
|
function I(a) {
|
|
23
26
|
return r.activeKey ? r.activeKey : d.value?.activeKeys ? d.value?.activeKeys : a.map((l) => l.name);
|
|
24
27
|
}
|
|
25
|
-
const n =
|
|
28
|
+
const n = g(() => f.value.map((a) => i.value.form.queryFeedbacks({
|
|
26
29
|
type: "error",
|
|
27
30
|
address: `${i.value.address.concat(a.name)}.*`
|
|
28
31
|
}).length));
|
|
29
|
-
return (a, l) => (o(), s(e(
|
|
32
|
+
return (a, l) => (o(), s(e(h), k({
|
|
30
33
|
class: x,
|
|
31
34
|
"model-value": I(e(f))
|
|
32
35
|
}, e(b), {
|
|
@@ -35,28 +38,28 @@ import '../styles/form-collapse/index.css';const H = { key: 1 }, J = /* @__PURE_
|
|
|
35
38
|
})
|
|
36
39
|
}), {
|
|
37
40
|
default: c(() => [
|
|
38
|
-
(o(!0), u(m, null, N(e(f), ({ props: y, schema: t, name: v }, p) => (o(), s(e(
|
|
41
|
+
(o(!0), u(m, null, N(e(f), ({ props: y, schema: t, name: v }, p) => (o(), s(e(j), k({
|
|
39
42
|
key: v,
|
|
40
43
|
ref_for: !0
|
|
41
44
|
}, y, { name: v }), {
|
|
42
45
|
default: c(() => [
|
|
43
|
-
D(e(
|
|
46
|
+
D(e(L), {
|
|
44
47
|
schema: t,
|
|
45
48
|
name: v
|
|
46
49
|
}, null, 8, ["schema", "name"])
|
|
47
50
|
]),
|
|
48
51
|
title: c(() => [
|
|
49
|
-
e(n)[p] !== 0 ? (o(), s(e(
|
|
52
|
+
e(n)[p] !== 0 ? (o(), s(e(q), {
|
|
50
53
|
key: 0,
|
|
51
54
|
class: P(`${x}-errors-badge`),
|
|
52
55
|
value: e(n)[p]
|
|
53
56
|
}, {
|
|
54
57
|
default: c(() => [
|
|
55
|
-
t["x-content"]?.title ? (o(), s(F(() => e(
|
|
58
|
+
t["x-content"]?.title ? (o(), s(F(() => e(E)(t["x-content"]?.title) ? t["x-content"]?.title(e(n)[p]) : t["x-content"]?.title), { key: 0 })) : (o(), u("span", H, _(t["x-component-props"]?.title), 1))
|
|
56
59
|
]),
|
|
57
60
|
_: 2
|
|
58
61
|
}, 1032, ["class", "value"])) : (o(), u(m, { key: 1 }, [
|
|
59
|
-
t["x-content"]?.title ? (o(), s(F(() => e(
|
|
62
|
+
t["x-content"]?.title ? (o(), s(F(() => e(E)(t["x-content"]?.title) ? t["x-content"]?.title(e(n)[p]) : t["x-content"]?.title), { key: 0 })) : (o(), u(m, { key: 1 }, [
|
|
60
63
|
$(_(t["x-component-props"]?.title), 1)
|
|
61
64
|
], 64))
|
|
62
65
|
], 64))
|
|
@@ -73,13 +76,13 @@ import '../styles/form-collapse/index.css';const H = { key: 1 }, J = /* @__PURE_
|
|
|
73
76
|
setup(C, { slots: r }) {
|
|
74
77
|
return () => R(m, r.default?.());
|
|
75
78
|
}
|
|
76
|
-
}),
|
|
79
|
+
}), se = T(J, {
|
|
77
80
|
Item: M,
|
|
78
81
|
createFormCollapse: A
|
|
79
82
|
});
|
|
80
83
|
export {
|
|
81
|
-
|
|
84
|
+
se as FormCollapse,
|
|
82
85
|
M as FormCollapseItem,
|
|
83
|
-
|
|
86
|
+
se as default
|
|
84
87
|
};
|
|
85
88
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/form-collapse/form-collapse.vue","../../src/form-collapse/index.ts"],"sourcesContent":["<script lang=\"ts\" setup>\
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/form-collapse/form-collapse.vue","../../src/form-collapse/index.ts"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { PropType } from 'vue'\nimport type { IFormCollapse } from './utils'\nimport { isFn } from '@formily/shared'\nimport { formilyComputed } from '@silver-formily/reactive-vue'\nimport { RecursionField, useField, useFieldSchema } from '@silver-formily/vue'\nimport { ElBadge, ElCollapse, ElCollapseItem } from 'element-plus'\nimport { computed } from 'vue'\nimport { stylePrefix, useCleanAttrs } from '../__builtins__'\nimport { createFormCollapse, usePanels } from './utils'\n\ndefineOptions({\n inheritAttrs: false,\n})\n\nconst props = defineProps({\n formCollapse: { type: Object as PropType<IFormCollapse> },\n activeKey: {\n type: [String, Number],\n },\n})\nconst prefixCls = `${stylePrefix}-form-collapse`\nconst { props: collapseAttrs } = useCleanAttrs(['modelValue', 'onUpdate:modelValue'])\n\nconst field = useField()\nconst schema = useFieldSchema()\nconst panels = formilyComputed(() => usePanels(field.value, schema.value))\nconst formCollapseRef = computed(\n () => props.formCollapse ?? createFormCollapse(),\n)\n\nfunction takeActiveKeys(panelList) {\n if (props.activeKey)\n return props.activeKey\n if (formCollapseRef.value?.activeKeys)\n return formCollapseRef.value?.activeKeys\n return panelList.map(item => item.name)\n}\n\nconst panelErrorCounts = formilyComputed(() => {\n return panels.value.map((item) => {\n const panelErrors = field.value.form.queryFeedbacks({\n type: 'error',\n address: `${field.value.address.concat(item.name)}.*`,\n })\n return panelErrors.length\n })\n})\n</script>\n\n<template>\n <ElCollapse\n :class=\"prefixCls\"\n :model-value=\"takeActiveKeys(panels)\"\n v-bind=\"collapseAttrs\"\n @change=\"(key) => {\n formCollapseRef.setActiveKeys(key)\n }\"\n >\n <template v-for=\"({ props: itemProps, schema: itemSchema, name }, index) of panels\" :key=\"name\">\n <ElCollapseItem v-bind=\"itemProps\" :name=\"name\">\n <template #default>\n <RecursionField :schema=\"itemSchema\" :name=\"name\" />\n </template>\n <template #title>\n <ElBadge\n v-if=\"panelErrorCounts[index] !== 0\"\n :class=\"`${prefixCls}-errors-badge`\"\n :value=\"panelErrorCounts[index]\"\n >\n <component\n :is=\"() => isFn(itemSchema['x-content']?.title)\n ? itemSchema['x-content']?.title(panelErrorCounts[index])\n : itemSchema['x-content']?.title\"\n v-if=\"itemSchema['x-content']?.title\"\n />\n <span v-else>{{ itemSchema['x-component-props']?.title }}</span>\n </ElBadge>\n <template v-else>\n <component\n :is=\"() => isFn(itemSchema['x-content']?.title)\n ? itemSchema['x-content']?.title(panelErrorCounts[index])\n : itemSchema['x-content']?.title\"\n v-if=\"itemSchema['x-content']?.title\"\n />\n <template v-else>\n {{ itemSchema['x-component-props']?.title }}\n </template>\n </template>\n </template>\n </ElCollapseItem>\n </template>\n </ElCollapse>\n</template>\n","import { defineComponent, Fragment, h } from 'vue'\nimport { composeExport } from '../__builtins__'\nimport FormCollapse from './form-collapse.vue'\nimport { createFormCollapse } from './utils'\nimport './style.scss'\n\nexport const FormCollapseItem = defineComponent({\n name: 'FFormCollapseItem',\n inheritAttrs: false,\n setup(_props, { slots }) {\n return () => h(Fragment, slots.default?.())\n },\n})\n\nconst composeFormCollapse = composeExport(FormCollapse, {\n Item: FormCollapseItem,\n createFormCollapse,\n})\n\nexport { composeFormCollapse as FormCollapse }\nexport default composeFormCollapse\n"],"names":["props","__props","prefixCls","stylePrefix","collapseAttrs","useCleanAttrs","field","useField","schema","useFieldSchema","panels","formilyComputed","usePanels","formCollapseRef","computed","createFormCollapse","takeActiveKeys","panelList","item","panelErrorCounts","_openBlock","_createBlock","_unref","_mergeProps","key","_createElementBlock","_Fragment","_renderList","itemProps","itemSchema","name","index","_createVNode","RecursionField","ElBadge","_resolveDynamicComponent","isFn","_hoisted_1","_toDisplayString","_createTextVNode","FormCollapseItem","defineComponent","_props","slots","h","Fragment","composeFormCollapse","composeExport","FormCollapse"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAeA,UAAMA,IAAQC,GAMRC,IAAY,GAAGC,CAAW,kBAC1B,EAAE,OAAOC,EAAA,IAAkBC,EAAc,CAAC,cA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;AAAA;cAVP,YAAUhC,CAAS,eAAA;AAAA,cACnB,OAAOoB,EAAAH,CAAA,EAAiBY,CAAK;AAAA,YAAA;yBAE9B,MAKE;AAAA,gBADMF,gBAAyB,SAJjCT,KAAAC,EAKEc,EAAA,MAJWb,EAAAc,CAAA,EAAKP,gBAAyB,KAAK,IAAoBA,EAAU,WAAA,GAAe,MAAMP,EAAAH,CAAA,EAAiBY,CAAK,CAAA,IAAqBF,gBAAyB,KAAK,GAAA,EAAA,KAAA,EAAA,CAAA,WAK5KJ,EAAgE,QAAAY,GAAAC,EAAhDT,EAAU,mBAAA,GAAuB,KAAK,GAAA,CAAA;AAAA,cAAA;;kDAExDJ,EAUWC,GAAA,EAAA,KAAA,KAAA;AAAA,cALDG,gBAAyB,SAJjCT,KAAAC,EAKEc,EAAA,MAJWb,EAAAc,CAAA,EAAKP,gBAAyB,KAAK,IAAoBA,EAAU,WAAA,GAAe,MAAMP,EAAAH,CAAA,EAAiBY,CAAK,CAAA,IAAqBF,gBAAyB,KAAK,GAAA,EAAA,KAAA,GAAA,WAK5KJ,EAEWC,GAAA,EAAA,KAAA,KAAA;AAAA,gBADNa,EAAAD,EAAAT,wBAAiC,KAAK,GAAA,CAAA;AAAA,cAAA;;;;;;;;;IChF1CW,IAAmBC,EAAgB;AAAA,EAC9C,MAAM;AAAA,EACN,cAAc;AAAA,EACd,MAAMC,GAAQ,EAAE,OAAAC,KAAS;AACvB,WAAO,MAAMC,EAAEC,GAAUF,EAAM,WAAW;AAAA,EAC5C;AACF,CAAC,GAEKG,KAAsBC,EAAcC,GAAc;AAAA,EACtD,MAAMR;AAAA,EACN,oBAAAzB;AACF,CAAC;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","sources":["../../src/form-collapse/utils.ts"],"sourcesContent":["import type { GeneralField } from '@formily/core'\
|
|
1
|
+
{"version":3,"file":"utils.mjs","sources":["../../src/form-collapse/utils.ts"],"sourcesContent":["import type { GeneralField } from '@formily/core'\nimport type { Schema, SchemaKey } from '@formily/json-schema'\nimport { model } from '@formily/reactive'\nimport { toArr } from '@formily/shared'\n\ntype ActiveKeys = string | number | Array<string | number>\n\ntype ActiveKey = string | number\n\ntype Panels = { name: SchemaKey, props: any, schema: Schema }[]\n\nexport interface IFormCollapse {\n activeKeys: ActiveKeys\n hasActiveKey: (key: ActiveKey) => boolean\n setActiveKeys: (key: ActiveKeys) => void\n addActiveKey: (key: ActiveKey) => void\n removeActiveKey: (key: ActiveKey) => void\n toggleActiveKey: (key: ActiveKey) => void\n}\n\nexport interface IFormCollapseProps {\n formCollapse?: IFormCollapse\n activeKey?: ActiveKey\n}\n\nexport function usePanels(collapseField: GeneralField, schema: Schema) {\n const schemaList = schema.mapProperties((schema, name) => ({\n name,\n props: {\n ...schema?.['x-component-props'],\n key: schema?.['x-component-props']?.key || name,\n },\n schema,\n }))\n\n const panels: Panels = schemaList.filter((item) => {\n const field = collapseField.query(collapseField.address.concat(item.name)).take()\n const isHidden = field?.display === 'none' || field?.display === 'hidden'\n if (isHidden)\n return false\n return item?.schema?.['x-component']?.includes('FormCollapse.Item') ?? false\n })\n\n return panels\n}\n\nexport function createFormCollapse(defaultActiveKeys?: ActiveKeys) {\n const formCollapse = model({\n activeKeys: defaultActiveKeys,\n setActiveKeys(keys: ActiveKeys) {\n /* istanbul ignore if -- @preserve */\n if (keys === formCollapse.activeKeys)\n return\n formCollapse.activeKeys = keys\n },\n hasActiveKey(key: ActiveKey) {\n if (Array.isArray(formCollapse.activeKeys)) {\n if (formCollapse.activeKeys.includes(key)) {\n return true\n }\n }\n else if (formCollapse.activeKeys === key) {\n return true\n }\n return false\n },\n addActiveKey(key: ActiveKey) {\n /* istanbul ignore if -- @preserve */\n if (formCollapse.hasActiveKey(key))\n return\n formCollapse.activeKeys = toArr(formCollapse.activeKeys).concat(key)\n },\n removeActiveKey(key: ActiveKey) {\n formCollapse.activeKeys = Array.isArray(formCollapse.activeKeys)\n ? formCollapse.activeKeys.filter(\n item => item !== key,\n )\n : ''\n },\n toggleActiveKey(key: ActiveKey) {\n if (formCollapse.hasActiveKey(key)) {\n formCollapse.removeActiveKey(key)\n }\n else {\n formCollapse.addActiveKey(key)\n }\n },\n })\n return formCollapse\n}\n"],"names":["usePanels","collapseField","schema","name","item","field","createFormCollapse","defaultActiveKeys","formCollapse","model","keys","key","toArr"],"mappings":";;AAyBO,SAASA,EAAUC,GAA6BC,GAAgB;AAkBrE,SAjBmBA,EAAO,cAAc,CAACA,GAAQC,OAAU;AAAA,IACzD,MAAAA;AAAA,IACA,OAAO;AAAA,MACL,GAAGD,IAAS,mBAAmB;AAAA,MAC/B,KAAKA,IAAS,mBAAmB,GAAG,OAAOC;AAAA,IAAA;AAAA,IAE7C,QAAAD;AAAAA,EAAA,EACA,EAEgC,OAAO,CAACE,MAAS;AACjD,UAAMC,IAAQJ,EAAc,MAAMA,EAAc,QAAQ,OAAOG,EAAK,IAAI,CAAC,EAAE,KAAA;AAE3E,WADiBC,GAAO,YAAY,UAAUA,GAAO,YAAY,WAExD,KACFD,GAAM,SAAS,aAAa,GAAG,SAAS,mBAAmB,KAAK;AAAA,EACzE,CAAC;AAGH;AAEO,SAASE,EAAmBC,GAAgC;AACjE,QAAMC,IAAeC,EAAM;AAAA,IACzB,YAAYF;AAAA,IACZ,cAAcG,GAAkB;AAE9B,MAAIA,MAASF,EAAa,eAE1BA,EAAa,aAAaE;AAAA,IAC5B;AAAA,IACA,aAAaC,GAAgB;AAC3B,UAAI,MAAM,QAAQH,EAAa,UAAU;AACvC,YAAIA,EAAa,WAAW,SAASG,CAAG;AACtC,iBAAO;AAAA,iBAGFH,EAAa,eAAeG;AACnC,eAAO;AAET,aAAO;AAAA,IACT;AAAA,IACA,aAAaA,GAAgB;AAE3B,MAAIH,EAAa,aAAaG,CAAG,MAEjCH,EAAa,aAAaI,EAAMJ,EAAa,UAAU,EAAE,OAAOG,CAAG;AAAA,IACrE;AAAA,IACA,gBAAgBA,GAAgB;AAC9B,MAAAH,EAAa,aAAa,MAAM,QAAQA,EAAa,UAAU,IAC3DA,EAAa,WAAW;AAAA,QACtB,OAAQJ,MAASO;AAAA,MAAA,IAEnB;AAAA,IACN;AAAA,IACA,gBAAgBA,GAAgB;AAC9B,MAAIH,EAAa,aAAaG,CAAG,IAC/BH,EAAa,gBAAgBG,CAAG,IAGhCH,EAAa,aAAaG,CAAG;AAAA,IAEjC;AAAA,EAAA,CACD;AACD,SAAOH;AACT;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Component } from 'vue';
|
|
2
2
|
import { FormDialogSlotContent, IFormDialog, IFormDialogProps } from './types';
|
|
3
|
-
export declare function FormDialog<T extends object = any>(title: IFormDialogProps | string, content?: Component | FormDialogSlotContent, dynamicMiddlewareNames?:
|
|
3
|
+
export declare function FormDialog<T extends object = any, const DynamicMiddlewareNames extends readonly string[] = []>(title: IFormDialogProps | string, content?: Component | FormDialogSlotContent, dynamicMiddlewareNames?: DynamicMiddlewareNames): IFormDialog<T, DynamicMiddlewareNames[number]>;
|
|
4
4
|
export default FormDialog;
|
|
@@ -3,15 +3,15 @@ import { toJS as q } from "@formily/reactive";
|
|
|
3
3
|
import { isFn as p, isArr as y, isStr as E, pascalCase as S, applyMiddleware as g, isValid as z } from "@formily/shared";
|
|
4
4
|
import { observer as N } from "@silver-formily/reactive-vue";
|
|
5
5
|
import { defineComponent as O, useSlots as R, ref as B, computed as $, openBlock as k, createBlock as A, unref as i, mergeProps as C, createSlots as I, withCtx as c, createElementVNode as J, normalizeClass as U, renderSlot as w, createElementBlock as G, Fragment as H, createVNode as b, createTextVNode as h, toDisplayString as j, normalizeProps as K, guardReactiveProps as L, h as x, createApp as Q } from "vue";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
6
|
+
import { ElDialog as W, ElButton as D, ElConfigProvider as X } from "element-plus";
|
|
7
|
+
import { useDebonceSubmitting as Y, loading as M, getTransitionDuration as Z } from "../__builtins__/shared/loading.mjs";
|
|
8
|
+
import { FormProvider as _ } from "@silver-formily/vue";
|
|
9
|
+
import { isVueOptions as ee } from "../__builtins__/shared/utils.mjs";
|
|
10
|
+
import { stylePrefix as oe } from "../__builtins__/configs/index.mjs";
|
|
11
|
+
import { loadElConfigProvider as re } from "../__builtins__/shared/load-config-provider.mjs";
|
|
12
|
+
import { useEnterSubmit as te } from "../__builtins__/shared/use-enter-submit.mjs";
|
|
13
|
+
import { resolveDialogElement as ne } from "../shared/overlay-elements.mjs";
|
|
14
|
+
import { o as ie, c as F } from "../vendor/lodash.mjs";
|
|
15
15
|
const le = /* @__PURE__ */ O({
|
|
16
16
|
name: "FormDialogContent",
|
|
17
17
|
__name: "dialog-content",
|
|
@@ -38,19 +38,19 @@ const le = /* @__PURE__ */ O({
|
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
setup(r) {
|
|
41
|
-
const t = r, f = R(), e = `${
|
|
41
|
+
const t = r, f = R(), e = `${oe}-form-dialog`, u = re(), m = ie(t.dialogProps, [
|
|
42
42
|
"modelValue",
|
|
43
43
|
"onUpdate:modelValue",
|
|
44
44
|
"beforeClose",
|
|
45
45
|
"enterSubmit"
|
|
46
|
-
]), { internalSubmitting: d } =
|
|
47
|
-
return
|
|
46
|
+
]), { internalSubmitting: d } = Y(t.form), s = B(null), o = $(() => t.dialogProps.enterSubmit !== !1);
|
|
47
|
+
return te({
|
|
48
48
|
visible: $(() => t.visible),
|
|
49
49
|
resolve: () => t.resolve(),
|
|
50
50
|
submitting: d,
|
|
51
|
-
getContainer: () =>
|
|
51
|
+
getContainer: () => ne(s.value),
|
|
52
52
|
enabled: o
|
|
53
|
-
}), (n, l) => (k(), A(i(
|
|
53
|
+
}), (n, l) => (k(), A(i(W), C({
|
|
54
54
|
ref_key: "dialogRef",
|
|
55
55
|
ref: s,
|
|
56
56
|
class: e,
|
|
@@ -62,11 +62,11 @@ const le = /* @__PURE__ */ O({
|
|
|
62
62
|
}
|
|
63
63
|
}), I({
|
|
64
64
|
default: c(() => [
|
|
65
|
-
b(i(
|
|
65
|
+
b(i(_), {
|
|
66
66
|
form: t.form
|
|
67
67
|
}, {
|
|
68
68
|
default: c(() => [
|
|
69
|
-
b(i(
|
|
69
|
+
b(i(X), K(L(i(u))), {
|
|
70
70
|
default: c(() => [
|
|
71
71
|
w(n.$slots, "default", {
|
|
72
72
|
resolve: r.resolve,
|
|
@@ -141,7 +141,7 @@ function Ee(r, t, f) {
|
|
|
141
141
|
for (const o of f) {
|
|
142
142
|
if (!E(o))
|
|
143
143
|
return;
|
|
144
|
-
const n =
|
|
144
|
+
const n = F(o);
|
|
145
145
|
if (["open", "cancel", "confirm"].includes(n))
|
|
146
146
|
throw new Error(`for${S(n)} is presved`);
|
|
147
147
|
e[`${n}Middlewares`] = [];
|
|
@@ -149,7 +149,7 @@ function Ee(r, t, f) {
|
|
|
149
149
|
document.body.append(e.root);
|
|
150
150
|
const u = E(r) ? { title: r } : r;
|
|
151
151
|
function m(o, n, l) {
|
|
152
|
-
const a =
|
|
152
|
+
const a = ee(t) ? { default: () => x(t) } : t;
|
|
153
153
|
if (!e.instance) {
|
|
154
154
|
const v = N({
|
|
155
155
|
setup(se, { expose: T }) {
|
|
@@ -170,7 +170,7 @@ function Ee(r, t, f) {
|
|
|
170
170
|
e.instance.visible = o;
|
|
171
171
|
}
|
|
172
172
|
function d() {
|
|
173
|
-
const o =
|
|
173
|
+
const o = Z();
|
|
174
174
|
setTimeout(() => {
|
|
175
175
|
e.app?.unmount?.(), e.app = null, e.instance = null, e.root?.remove(), e.root = void 0;
|
|
176
176
|
}, o);
|
|
@@ -180,14 +180,14 @@ function Ee(r, t, f) {
|
|
|
180
180
|
forConfirm: (o) => (p(o) && e.confirmMiddlewares.push(o), s),
|
|
181
181
|
forCancel: (o) => (p(o) && e.cancelMiddlewares.push(o), s),
|
|
182
182
|
open: (o) => (e.promise || (e.promise = new Promise((n, l) => {
|
|
183
|
-
|
|
183
|
+
M(u.loadingText, () => g(o, e.openMiddlewares)).then((a) => {
|
|
184
184
|
e.form = e.form || V(a), m(!0, (v) => {
|
|
185
185
|
e.form.submit(async () => {
|
|
186
186
|
await (z(v) ? g(e.form, e[`${v}Middlewares`]) : g(e.form, e.confirmMiddlewares)), n(q(e.form.values)), s.close(), d();
|
|
187
187
|
}).catch(() => {
|
|
188
188
|
});
|
|
189
189
|
}, async () => {
|
|
190
|
-
await
|
|
190
|
+
await M(u.loadingText, () => g(e.form, e.cancelMiddlewares)), s.close(), d(), l(new Error("cancel"));
|
|
191
191
|
});
|
|
192
192
|
}).catch(
|
|
193
193
|
/* istanbul ignore next -- @preserve */
|
|
@@ -200,7 +200,7 @@ function Ee(r, t, f) {
|
|
|
200
200
|
};
|
|
201
201
|
if (y(f))
|
|
202
202
|
for (const o of f) {
|
|
203
|
-
const n =
|
|
203
|
+
const n = F(o);
|
|
204
204
|
s[`for${S(n)}`] = (l) => (p(l) && e[`${n}Middlewares`].push(l), s);
|
|
205
205
|
}
|
|
206
206
|
return s;
|