@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.
Files changed (137) hide show
  1. package/README.en-US.md +32 -32
  2. package/README.md +32 -32
  3. package/esm/__builtins__/configs/index.mjs.map +1 -1
  4. package/esm/__builtins__/index.mjs +18 -18
  5. package/esm/__builtins__/shared/loading.mjs.map +1 -1
  6. package/esm/__builtins__/shared/simple-version-compare.mjs.map +1 -1
  7. package/esm/__builtins__/shared/transform-component.mjs.map +1 -1
  8. package/esm/__builtins__/shared/use-enter-submit.mjs.map +1 -1
  9. package/esm/__builtins__/shared/utils.mjs.map +1 -1
  10. package/esm/array-base/index.mjs +63 -59
  11. package/esm/array-base/index.mjs.map +1 -1
  12. package/esm/array-base/symbols.mjs.map +1 -1
  13. package/esm/array-base/utils.mjs +37 -31
  14. package/esm/array-base/utils.mjs.map +1 -1
  15. package/esm/array-cards/index.mjs +36 -33
  16. package/esm/array-cards/index.mjs.map +1 -1
  17. package/esm/array-collapse/index.mjs +39 -37
  18. package/esm/array-collapse/index.mjs.map +1 -1
  19. package/esm/array-collapse/utils.mjs +9 -2
  20. package/esm/array-collapse/utils.mjs.map +1 -1
  21. package/esm/array-items/index.mjs +38 -34
  22. package/esm/array-items/index.mjs.map +1 -1
  23. package/esm/array-list-tabs/index.mjs +38 -36
  24. package/esm/array-list-tabs/index.mjs.map +1 -1
  25. package/esm/array-list-tabs/utils.mjs +12 -5
  26. package/esm/array-list-tabs/utils.mjs.map +1 -1
  27. package/esm/array-table/index.mjs +62 -60
  28. package/esm/array-table/index.mjs.map +1 -1
  29. package/esm/array-table/utils.mjs +18 -11
  30. package/esm/array-table/utils.mjs.map +1 -1
  31. package/esm/array-tabs/index.mjs +28 -25
  32. package/esm/array-tabs/index.mjs.map +1 -1
  33. package/esm/autocomplete/index.mjs +22 -18
  34. package/esm/autocomplete/index.mjs.map +1 -1
  35. package/esm/cascader/index.mjs +22 -18
  36. package/esm/cascader/index.mjs.map +1 -1
  37. package/esm/checkbox/index.mjs +20 -16
  38. package/esm/checkbox/index.mjs.map +1 -1
  39. package/esm/color-picker/index.mjs +9 -6
  40. package/esm/color-picker/index.mjs.map +1 -1
  41. package/esm/color-picker-panel/index.mjs +9 -6
  42. package/esm/color-picker-panel/index.mjs.map +1 -1
  43. package/esm/date-picker/index.mjs +14 -11
  44. package/esm/date-picker/index.mjs.map +1 -1
  45. package/esm/date-picker/utils.mjs.map +1 -1
  46. package/esm/date-picker-panel/index.mjs +14 -11
  47. package/esm/date-picker-panel/index.mjs.map +1 -1
  48. package/esm/editable/index.mjs +33 -30
  49. package/esm/editable/index.mjs.map +1 -1
  50. package/esm/form/form.mjs +6 -6
  51. package/esm/form/form.mjs.map +1 -1
  52. package/esm/form-button-group/index.mjs +18 -14
  53. package/esm/form-button-group/index.mjs.map +1 -1
  54. package/esm/form-button-group/utils.mjs +9 -2
  55. package/esm/form-button-group/utils.mjs.map +1 -1
  56. package/esm/form-collapse/index.mjs +21 -18
  57. package/esm/form-collapse/index.mjs.map +1 -1
  58. package/esm/form-collapse/utils.mjs.map +1 -1
  59. package/esm/form-dialog/index.d.ts +1 -1
  60. package/esm/form-dialog/index.mjs +22 -22
  61. package/esm/form-dialog/index.mjs.map +1 -1
  62. package/esm/form-dialog/types.d.ts +13 -5
  63. package/esm/form-drawer/index.d.ts +1 -1
  64. package/esm/form-drawer/index.mjs +21 -21
  65. package/esm/form-drawer/index.mjs.map +1 -1
  66. package/esm/form-drawer/types.d.ts +13 -5
  67. package/esm/form-grid/hooks.mjs.map +1 -1
  68. package/esm/form-grid/index.mjs +21 -18
  69. package/esm/form-grid/index.mjs.map +1 -1
  70. package/esm/form-item/index.mjs +55 -53
  71. package/esm/form-item/index.mjs.map +1 -1
  72. package/esm/form-item/utils.mjs.map +1 -1
  73. package/esm/form-layout/form-layout.mjs +14 -10
  74. package/esm/form-layout/form-layout.mjs.map +1 -1
  75. package/esm/form-layout/utils.mjs.map +1 -1
  76. package/esm/form-step/index.mjs +30 -27
  77. package/esm/form-step/index.mjs.map +1 -1
  78. package/esm/form-step/utils.mjs.map +1 -1
  79. package/esm/form-tab/hooks.mjs.map +1 -1
  80. package/esm/form-tab/index.mjs +25 -23
  81. package/esm/form-tab/index.mjs.map +1 -1
  82. package/esm/form-tab/utils.mjs.map +1 -1
  83. package/esm/index.mjs +72 -72
  84. package/esm/input/index.mjs +30 -26
  85. package/esm/input/index.mjs.map +1 -1
  86. package/esm/input-number/index.mjs +11 -8
  87. package/esm/input-number/index.mjs.map +1 -1
  88. package/esm/input-tag/index.mjs +20 -16
  89. package/esm/input-tag/index.mjs.map +1 -1
  90. package/esm/mention/index.mjs +24 -20
  91. package/esm/mention/index.mjs.map +1 -1
  92. package/esm/pagination/components/jumper.mjs.map +1 -1
  93. package/esm/pagination/components/next.mjs.map +1 -1
  94. package/esm/pagination/components/pager.mjs.map +1 -1
  95. package/esm/pagination/components/prev.mjs.map +1 -1
  96. package/esm/pagination/components/total.mjs.map +1 -1
  97. package/esm/pagination/pagination.mjs.map +1 -1
  98. package/esm/password/index.mjs.map +1 -1
  99. package/esm/preview-text/index.mjs +31 -27
  100. package/esm/preview-text/index.mjs.map +1 -1
  101. package/esm/preview-text/utils.mjs.map +1 -1
  102. package/esm/query-form/default-components.mjs.map +1 -1
  103. package/esm/query-form/hooks.mjs.map +1 -1
  104. package/esm/query-form/index.mjs +51 -48
  105. package/esm/query-form/index.mjs.map +1 -1
  106. package/esm/query-form-item/index.mjs +37 -34
  107. package/esm/query-form-item/index.mjs.map +1 -1
  108. package/esm/radio/index.mjs +29 -25
  109. package/esm/radio/index.mjs.map +1 -1
  110. package/esm/rate/index.mjs +13 -10
  111. package/esm/rate/index.mjs.map +1 -1
  112. package/esm/reset/index.mjs.map +1 -1
  113. package/esm/segmented/index.mjs +16 -12
  114. package/esm/segmented/index.mjs.map +1 -1
  115. package/esm/select/index.mjs +26 -22
  116. package/esm/select/index.mjs.map +1 -1
  117. package/esm/select-table/index.mjs +16 -12
  118. package/esm/select-table/index.mjs.map +1 -1
  119. package/esm/shared/overlay-elements.mjs.map +1 -1
  120. package/esm/slider/index.mjs +13 -10
  121. package/esm/slider/index.mjs.map +1 -1
  122. package/esm/submit/index.mjs.map +1 -1
  123. package/esm/switch/index.mjs.map +1 -1
  124. package/esm/time-picker/index.mjs +9 -6
  125. package/esm/time-picker/index.mjs.map +1 -1
  126. package/esm/time-select/index.mjs +9 -6
  127. package/esm/time-select/index.mjs.map +1 -1
  128. package/esm/transfer/index.mjs.map +1 -1
  129. package/esm/tree/index.mjs +33 -29
  130. package/esm/tree/index.mjs.map +1 -1
  131. package/esm/tree/utils.mjs.map +1 -1
  132. package/esm/tree-select/index.mjs +18 -14
  133. package/esm/tree-select/index.mjs.map +1 -1
  134. package/esm/upload/index.mjs +10 -7
  135. package/esm/upload/index.mjs.map +1 -1
  136. package/esm/vendor/sizes.mjs.map +1 -1
  137. package/package.json +6 -5
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../src/tree/tree.vue","../../src/tree/index.ts"],"sourcesContent":["<script setup lang=\"ts\">\r\nimport type { Field } from '@formily/core'\r\nimport type { TreeValueTypeProps } from './types'\r\nimport { isFn } from '@formily/shared'\r\nimport { useField } from '@silver-formily/vue'\r\nimport { ElScrollbar, ElTree, vLoading } from 'element-plus'\r\nimport { computed, nextTick, ref, useSlots, watch } from 'vue'\r\nimport { useCleanAttrs } from '../__builtins__'\r\nimport { addDisabledToNodes, flattenTree, getInputKeys, getOutputData } from './utils'\r\n\r\ndefineOptions({\r\n name: 'Tree',\r\n inheritAttrs: false,\r\n})\r\n\r\nconst props = withDefaults(defineProps<TreeValueTypeProps>(), {\r\n valueType: 'all',\r\n optionAsValue: false,\r\n includeHalfChecked: false,\r\n props: {\r\n children: 'children',\r\n label: 'label',\r\n disabled: 'disabled',\r\n },\r\n})\r\n\r\nconst emit = defineEmits<{\r\n 'update:modelValue': [value: any]\r\n}>()\r\n\r\nconst slots = useSlots()\r\n\r\nconst { props: attrs } = useCleanAttrs()\r\nconst treeRef = ref<InstanceType<typeof ElTree>>()\r\nconst checkedKeys = ref<any[]>([])\r\n\r\nconst processedData = computed(() => {\r\n return addDisabledToNodes(props.data ?? [], attrs.value.disabled, props.props)\r\n})\r\n\r\nconst flatData = computed(() => flattenTree(processedData.value ?? [], [], props.props.children))\r\n\r\nasync function handleCheck() {\r\n await nextTick()\r\n const keys = treeRef.value.getCheckedKeys()\r\n const halfCheckedKeys = treeRef.value.getHalfCheckedKeys() || []\r\n checkedKeys.value = keys\r\n\r\n const { value, nodes } = getOutputData(keys, halfCheckedKeys, {\r\n flatData: flatData.value,\r\n nodeKey: props.nodeKey,\r\n propsConfig: props.props,\r\n data: props.data ?? [],\r\n valueType: props.valueType,\r\n includeHalfChecked: props.includeHalfChecked,\r\n checkStrictly: attrs.value.checkStrictly,\r\n })\r\n\r\n if (props.optionAsValue) {\r\n isFn(props.optionFormatter)\r\n ? emit('update:modelValue', nodes.map((element, index, array) => {\r\n return props.optionFormatter(element, index, array)\r\n }))\r\n : emit('update:modelValue', nodes)\r\n }\r\n else {\r\n emit('update:modelValue', value)\r\n }\r\n}\r\n\r\nwatch(() => props.modelValue, (newValue) => {\r\n if (newValue !== undefined) {\r\n checkedKeys.value = getInputKeys(newValue, {\r\n optionAsValue: props.optionAsValue,\r\n nodeKey: props.nodeKey,\r\n flatData: flatData.value,\r\n propsConfig: props.props,\r\n data: props.data ?? [],\r\n valueType: props.valueType,\r\n checkStrictly: attrs.value.checkStrictly,\r\n })\r\n nextTick(() => {\r\n if (treeRef.value) {\r\n treeRef.value.setCheckedKeys(checkedKeys.value)\r\n }\r\n })\r\n }\r\n}, { immediate: true })\r\n\r\nwatch(() => [props.valueType, props.optionAsValue, props.includeHalfChecked], () => {\r\n handleCheck()\r\n}, { immediate: false })\r\n\r\nconst fieldRef = useField<Field>()\r\nfieldRef.value?.inject({\r\n getTreeRef: () => {\r\n return treeRef\r\n },\r\n})\r\n</script>\r\n\r\n<template>\r\n <ElScrollbar :height=\"props.height\" :max-height=\"props.maxHeight\">\r\n <ElTree\r\n ref=\"treeRef\"\r\n v-loading=\"attrs.loading\"\r\n :data=\"processedData\"\r\n :props=\"props.props\"\r\n :node-key=\"props.nodeKey\"\r\n :default-checked-keys=\"checkedKeys\"\r\n :show-checkbox=\"true\"\r\n v-bind=\"attrs\"\r\n @check=\"handleCheck\"\r\n >\r\n <template v-for=\"(_, name) of slots\" #[name]=\"slotData\">\r\n <slot :name=\"name\" v-bind=\"{ field: fieldRef, ...slotData }\" />\r\n </template>\r\n </ElTree>\r\n </ElScrollbar>\r\n</template>\r\n","import { connect, mapProps } from '@silver-formily/vue'\r\nimport { mapReadPretty } from '../__builtins__'\r\nimport { PreviewText } from '../preview-text'\r\nimport InnerTree from './tree.vue'\r\n\r\nconst Tree = connect<typeof InnerTree>(\r\n InnerTree,\r\n mapProps({ dataSource: 'data', loading: 'loading', disabled: true }),\r\n mapReadPretty(PreviewText.Tree),\r\n)\r\n\r\nexport { Tree }\r\n\r\nexport default Tree\r\n"],"names":["props","__props","emit","__emit","slots","useSlots","attrs","useCleanAttrs","treeRef","ref","checkedKeys","processedData","computed","addDisabledToNodes","flatData","flattenTree","handleCheck","nextTick","keys","halfCheckedKeys","value","nodes","getOutputData","isFn","element","index","array","watch","newValue","getInputKeys","fieldRef","useField","_createBlock","_unref","ElScrollbar","_withDirectives","_openBlock","_mergeProps","_createSlots","_","name","_withCtx","slotData","_renderSlot","_ctx","_normalizeProps","_guardReactiveProps","vLoading","Tree","connect","InnerTree","mapProps","mapReadPretty","PreviewText"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,UAAMA,IAAQC,GAWRC,IAAOC,GAIPC,IAAQC,EAAA,GAER,EAAE,OAAOC,EAAA,IAAUC,EAAA,GACnBC,IAAUC,EAAA,GACVC,IAAcD,EAAW,EAAE,GAE3BE,IAAgBC,EAAS,MACtBC,EAAmBb,EA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ts\">\nimport type { Field } from '@formily/core'\nimport type { TreeValueTypeProps } from './types'\nimport { isFn } from '@formily/shared'\nimport { useField } from '@silver-formily/vue'\nimport { ElScrollbar, ElTree, vLoading } from 'element-plus'\nimport { computed, nextTick, ref, useSlots, watch } from 'vue'\nimport { useCleanAttrs } from '../__builtins__'\nimport { addDisabledToNodes, flattenTree, getInputKeys, getOutputData } from './utils'\n\ndefineOptions({\n name: 'Tree',\n inheritAttrs: false,\n})\n\nconst props = withDefaults(defineProps<TreeValueTypeProps>(), {\n valueType: 'all',\n optionAsValue: false,\n includeHalfChecked: false,\n props: {\n children: 'children',\n label: 'label',\n disabled: 'disabled',\n },\n})\n\nconst emit = defineEmits<{\n 'update:modelValue': [value: any]\n}>()\n\nconst slots = useSlots()\n\nconst { props: attrs } = useCleanAttrs()\nconst treeRef = ref<InstanceType<typeof ElTree>>()\nconst checkedKeys = ref<any[]>([])\n\nconst processedData = computed(() => {\n return addDisabledToNodes(props.data ?? [], attrs.value.disabled, props.props)\n})\n\nconst flatData = computed(() => flattenTree(processedData.value ?? [], [], props.props.children))\n\nasync function handleCheck() {\n await nextTick()\n const keys = treeRef.value.getCheckedKeys()\n const halfCheckedKeys = treeRef.value.getHalfCheckedKeys() || []\n checkedKeys.value = keys\n\n const { value, nodes } = getOutputData(keys, halfCheckedKeys, {\n flatData: flatData.value,\n nodeKey: props.nodeKey,\n propsConfig: props.props,\n data: props.data ?? [],\n valueType: props.valueType,\n includeHalfChecked: props.includeHalfChecked,\n checkStrictly: attrs.value.checkStrictly,\n })\n\n if (props.optionAsValue) {\n isFn(props.optionFormatter)\n ? emit('update:modelValue', nodes.map((element, index, array) => {\n return props.optionFormatter(element, index, array)\n }))\n : emit('update:modelValue', nodes)\n }\n else {\n emit('update:modelValue', value)\n }\n}\n\nwatch(() => props.modelValue, (newValue) => {\n if (newValue !== undefined) {\n checkedKeys.value = getInputKeys(newValue, {\n optionAsValue: props.optionAsValue,\n nodeKey: props.nodeKey,\n flatData: flatData.value,\n propsConfig: props.props,\n data: props.data ?? [],\n valueType: props.valueType,\n checkStrictly: attrs.value.checkStrictly,\n })\n nextTick(() => {\n if (treeRef.value) {\n treeRef.value.setCheckedKeys(checkedKeys.value)\n }\n })\n }\n}, { immediate: true })\n\nwatch(() => [props.valueType, props.optionAsValue, props.includeHalfChecked], () => {\n handleCheck()\n}, { immediate: false })\n\nconst fieldRef = useField<Field>()\nfieldRef.value?.inject({\n getTreeRef: () => {\n return treeRef\n },\n})\n</script>\n\n<template>\n <ElScrollbar :height=\"props.height\" :max-height=\"props.maxHeight\">\n <ElTree\n ref=\"treeRef\"\n v-loading=\"attrs.loading\"\n :data=\"processedData\"\n :props=\"props.props\"\n :node-key=\"props.nodeKey\"\n :default-checked-keys=\"checkedKeys\"\n :show-checkbox=\"true\"\n v-bind=\"attrs\"\n @check=\"handleCheck\"\n >\n <template v-for=\"(_, name) of slots\" #[name]=\"slotData\">\n <slot :name=\"name\" v-bind=\"{ field: fieldRef, ...slotData }\" />\n </template>\n </ElTree>\n </ElScrollbar>\n</template>\n","import { connect, mapProps } from '@silver-formily/vue'\nimport { mapReadPretty } from '../__builtins__'\nimport { PreviewText } from '../preview-text'\nimport InnerTree from './tree.vue'\n\nconst Tree = connect<typeof InnerTree>(\n InnerTree,\n mapProps({ dataSource: 'data', loading: 'loading', disabled: true }),\n mapReadPretty(PreviewText.Tree),\n)\n\nexport { Tree }\n\nexport default Tree\n"],"names":["props","__props","emit","__emit","slots","useSlots","attrs","useCleanAttrs","treeRef","ref","checkedKeys","processedData","computed","addDisabledToNodes","flatData","flattenTree","handleCheck","nextTick","keys","halfCheckedKeys","value","nodes","getOutputData","isFn","element","index","array","watch","newValue","getInputKeys","fieldRef","useField","_createBlock","_unref","ElScrollbar","_withDirectives","_openBlock","_mergeProps","_createSlots","_","name","_withCtx","slotData","_renderSlot","_ctx","_normalizeProps","_guardReactiveProps","vLoading","Tree","connect","InnerTree","mapProps","mapReadPretty","PreviewText"],"mappings":";;;;;;;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xB0C,KAAOC;AAAA,EACXC;AAAAA,EACAC,EAAS,EAAE,YAAY,QAAQ,SAAS,WAAW,UAAU,IAAM;AAAA,EACnEC,EAAcC,EAAY,IAAI;AAChC;"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.mjs","sources":["../../src/tree/utils.ts"],"sourcesContent":["import type { TreeNodeData } from 'element-plus'\r\n\r\nexport function flattenTree(nodes: TreeNodeData[], result: TreeNodeData[] = [], childrenKey = 'children'): TreeNodeData[] {\r\n for (const node of nodes) {\r\n result.push(node)\r\n if (node[childrenKey] && node[childrenKey].length > 0) {\r\n flattenTree(node[childrenKey], result, childrenKey)\r\n }\r\n }\r\n return result\r\n}\r\n\r\nexport function addDisabledToNodes(nodes: TreeNodeData[], disabled: boolean, propsConfig: any): TreeNodeData[] {\r\n if (!disabled) {\r\n return nodes\r\n }\r\n\r\n return nodes.map((node) => {\r\n const newNode = { ...node }\r\n newNode[propsConfig.disabled!] = true\r\n\r\n if (node[propsConfig.children!] && node[propsConfig.children!].length > 0) {\r\n newNode[propsConfig.children!] = addDisabledToNodes(node[propsConfig.children!], disabled, propsConfig)\r\n }\r\n\r\n return newNode\r\n })\r\n}\r\n\r\nexport function traverseTree(\r\n nodes: TreeNodeData[],\r\n callback: (node: TreeNodeData) => void,\r\n options: {\r\n leafOnly?: boolean\r\n childrenKey?: string\r\n } = {},\r\n) {\r\n const { leafOnly = false, childrenKey = 'children' } = options\r\n\r\n for (const node of nodes) {\r\n const children = node[childrenKey] || []\r\n const isLeaf = children.length === 0\r\n\r\n if (!leafOnly || isLeaf) {\r\n callback(node)\r\n }\r\n if (children.length > 0) {\r\n traverseTree(children, callback, options)\r\n }\r\n }\r\n}\r\n\r\nexport function getChildrenKeys(node: TreeNodeData, nodeKey: string, propsConfig: any): any[] {\r\n const children = node[propsConfig.children!] || []\r\n if (children.length === 0)\r\n return []\r\n\r\n const keys: any[] = []\r\n traverseTree(children, (child) => {\r\n keys.push(child[nodeKey])\r\n }, { childrenKey: propsConfig.children })\r\n\r\n return keys\r\n}\r\n\r\nexport function extractKeysFromPath(pathNodes: TreeNodeData[], nodeKey: string, propsConfig: any): any[] {\r\n const keys: any[] = []\r\n traverseTree(pathNodes, (node) => {\r\n keys.push(node[nodeKey])\r\n }, { leafOnly: true, childrenKey: propsConfig.children })\r\n\r\n return keys\r\n}\r\n\r\nexport function getSelectedPath(nodes: TreeNodeData[], selectedKeys: any[], nodeKey: string, propsConfig: any): TreeNodeData[] {\r\n const result: TreeNodeData[] = []\r\n\r\n for (const node of nodes) {\r\n const children = node[propsConfig.children!] || []\r\n const hasSelectedChild = children.length > 0\r\n ? getSelectedPath(children, selectedKeys, nodeKey, propsConfig).length > 0\r\n : false\r\n\r\n if (selectedKeys.includes(node[nodeKey]) || hasSelectedChild) {\r\n const newNode = { ...node }\r\n if (hasSelectedChild && children.length > 0) {\r\n newNode[propsConfig.children!] = getSelectedPath(children, selectedKeys, nodeKey, propsConfig)\r\n }\r\n result.push(newNode)\r\n }\r\n }\r\n\r\n return result\r\n}\r\n\r\n/**\r\n * 查找节点的所有父节点路径\r\n */\r\nexport function findParents(nodes: TreeNodeData[], targetKey: any, nodeKey: string, propsConfig: any, parents: any[] = []): any[] {\r\n for (const node of nodes) {\r\n const currentPath = [...parents, node[nodeKey]]\r\n\r\n if (node[nodeKey] === targetKey) {\r\n return currentPath\r\n }\r\n\r\n const children = node[propsConfig.children!] || []\r\n if (children.length > 0) {\r\n const found = findParents(children, targetKey, nodeKey, propsConfig, currentPath)\r\n if (found.length > 0) {\r\n return found\r\n }\r\n }\r\n }\r\n /* istanbul ignore next -- @preserve */\r\n return []\r\n}\r\n\r\n/**\r\n * 过滤叶子节点\r\n */\r\nexport function filterLeafNodes(keys: any[], flatData: TreeNodeData[], nodeKey: string, propsConfig: any): any[] {\r\n return keys.filter((key) => {\r\n const node = flatData.find(n => n[nodeKey] === key)\r\n if (!node)\r\n return false\r\n const children = node[propsConfig.children!] || []\r\n return children.length === 0\r\n })\r\n}\r\n\r\n/**\r\n * 获取输出数据\r\n */\r\nexport function getOutputData(\r\n keys: any[],\r\n halfCheckedKeys: any[] = [],\r\n options: {\r\n flatData: TreeNodeData[]\r\n nodeKey: string\r\n propsConfig: any\r\n data: TreeNodeData[]\r\n valueType: string\r\n includeHalfChecked: boolean\r\n checkStrictly: boolean\r\n },\r\n) {\r\n const { flatData, nodeKey, propsConfig, data, valueType, includeHalfChecked, checkStrictly } = options\r\n\r\n const selectedNodes = flatData.filter(node =>\r\n keys.includes(node[nodeKey]),\r\n )\r\n\r\n let outputKeys = [...keys]\r\n let outputNodes = [...selectedNodes]\r\n\r\n if (checkStrictly) {\r\n return {\r\n value: outputKeys,\r\n nodes: outputNodes,\r\n }\r\n }\r\n\r\n switch (valueType) {\r\n case 'parent': {\r\n const allChildKeys: any[] = []\r\n for (const node of selectedNodes) {\r\n allChildKeys.push(...getChildrenKeys(node, nodeKey, propsConfig))\r\n }\r\n outputKeys = keys.filter(key => !allChildKeys.includes(key))\r\n outputNodes = selectedNodes.filter(node =>\r\n outputKeys.includes(node[nodeKey]),\r\n )\r\n break\r\n }\r\n\r\n case 'child': {\r\n for (const node of selectedNodes) {\r\n const childKeys = getChildrenKeys(node, nodeKey, propsConfig)\r\n const hasSelectedChild = childKeys.some(key => keys.includes(key))\r\n if (hasSelectedChild) {\r\n outputKeys = outputKeys.filter(key => key !== node[nodeKey])\r\n outputNodes = outputNodes.filter(n =>\r\n n[nodeKey] !== node[nodeKey],\r\n )\r\n }\r\n }\r\n break\r\n }\r\n\r\n case 'path': {\r\n const selectedPath = getSelectedPath(data, keys, nodeKey, propsConfig)\r\n return {\r\n value: selectedPath,\r\n nodes: selectedPath,\r\n }\r\n }\r\n\r\n default: { // 'all'\r\n if (includeHalfChecked && halfCheckedKeys.length > 0) {\r\n const halfCheckedNodes = flatData.filter(node =>\r\n halfCheckedKeys.includes(node[nodeKey]),\r\n )\r\n outputKeys = [...outputKeys, ...halfCheckedKeys]\r\n outputNodes = [...outputNodes, ...halfCheckedNodes]\r\n }\r\n break\r\n }\r\n }\r\n\r\n return {\r\n value: outputKeys,\r\n nodes: outputNodes,\r\n }\r\n}\r\n\r\n/**\r\n * 根据valueType将输入值转换为checkedKeys\r\n */\r\nexport function getInputKeys(\r\n inputValue: any,\r\n options: {\r\n optionAsValue: boolean\r\n nodeKey: string\r\n flatData: TreeNodeData[]\r\n propsConfig: any\r\n data: TreeNodeData[]\r\n valueType: string\r\n checkStrictly: boolean\r\n },\r\n): any[] {\r\n const { optionAsValue, nodeKey, flatData, propsConfig, data, valueType, checkStrictly } = options\r\n\r\n /* istanbul ignore if -- @preserve */\r\n if (!inputValue || !Array.isArray(inputValue))\r\n return []\r\n\r\n const valueArray = optionAsValue ? inputValue.map((item: any) => item[nodeKey]) : inputValue\r\n\r\n if (checkStrictly) {\r\n return valueArray\r\n }\r\n\r\n switch (valueType) {\r\n case 'parent': {\r\n const allKeys = [...valueArray]\r\n\r\n for (const key of valueArray) {\r\n const node = flatData.find(n => n[nodeKey] === key)\r\n if (node) {\r\n const childKeys = getChildrenKeys(node, nodeKey, propsConfig)\r\n allKeys.push(...childKeys)\r\n }\r\n }\r\n return filterLeafNodes(allKeys, flatData, nodeKey, propsConfig)\r\n }\r\n\r\n case 'child': {\r\n const allKeys = [...valueArray]\r\n for (const key of valueArray) {\r\n const parentPath = findParents(data, key, nodeKey, propsConfig)\r\n allKeys.push(...parentPath)\r\n }\r\n return filterLeafNodes(allKeys, flatData, nodeKey, propsConfig)\r\n }\r\n\r\n case 'path': {\r\n return extractKeysFromPath(valueArray, nodeKey, propsConfig)\r\n }\r\n\r\n default: { // 'all'\r\n return filterLeafNodes(valueArray, flatData, nodeKey, propsConfig)\r\n }\r\n }\r\n}\r\n"],"names":["flattenTree","nodes","result","childrenKey","node","addDisabledToNodes","disabled","propsConfig","newNode","traverseTree","callback","options","leafOnly","children","isLeaf","getChildrenKeys","nodeKey","keys","child","extractKeysFromPath","pathNodes","getSelectedPath","selectedKeys","hasSelectedChild","findParents","targetKey","parents","currentPath","found","filterLeafNodes","flatData","key","n","getOutputData","halfCheckedKeys","data","valueType","includeHalfChecked","checkStrictly","selectedNodes","outputKeys","outputNodes","allChildKeys","selectedPath","halfCheckedNodes","getInputKeys","inputValue","optionAsValue","valueArray","item","allKeys","childKeys","parentPath"],"mappings":"AAEO,SAASA,EAAYC,GAAuBC,IAAyB,CAAA,GAAIC,IAAc,YAA4B;AACxH,aAAWC,KAAQH;AACjB,IAAAC,EAAO,KAAKE,CAAI,GACZA,EAAKD,CAAW,KAAKC,EAAKD,CAAW,EAAE,SAAS,KAClDH,EAAYI,EAAKD,CAAW,GAAGD,GAAQC,CAAW;AAGtD,SAAOD;AACT;AAEO,SAASG,EAAmBJ,GAAuBK,GAAmBC,GAAkC;AAC7G,SAAKD,IAIEL,EAAM,IAAI,CAACG,MAAS;AACzB,UAAMI,IAAU,EAAE,GAAGJ,EAAA;AACrB,WAAAI,EAAQD,EAAY,QAAS,IAAI,IAE7BH,EAAKG,EAAY,QAAS,KAAKH,EAAKG,EAAY,QAAS,EAAE,SAAS,MACtEC,EAAQD,EAAY,QAAS,IAAIF,EAAmBD,EAAKG,EAAY,QAAS,GAAGD,GAAUC,CAAW,IAGjGC;AAAA,EACT,CAAC,IAZQP;AAaX;AAEO,SAASQ,EACdR,GACAS,GACAC,IAGI,CAAA,GACJ;AACA,QAAM,EAAE,UAAAC,IAAW,IAAO,aAAAT,IAAc,eAAeQ;AAEvD,aAAWP,KAAQH,GAAO;AACxB,UAAMY,IAAWT,EAAKD,CAAW,KAAK,CAAA,GAChCW,IAASD,EAAS,WAAW;AAEnC,KAAI,CAACD,KAAYE,MACfJ,EAASN,CAAI,GAEXS,EAAS,SAAS,KACpBJ,EAAaI,GAAUH,GAAUC,CAAO;AAAA,EAE5C;AACF;AAEO,SAASI,EAAgBX,GAAoBY,GAAiBT,GAAyB;AAC5F,QAAMM,IAAWT,EAAKG,EAAY,QAAS,KAAK,CAAA;AAChD,MAAIM,EAAS,WA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AAM5C,IAAO0B,EAAS,KAAK,OAAKE,EAAEhB,CAAO,MAAMe,CAAG;AAClD,YAAI3B,GAAM;AACR,gBAAM+C,IAAYpC,EAAgBX,GAAMY,GAAST,CAAW;AAC5D,UAAA2C,EAAQ,KAAK,GAAGC,CAAS;AAAA,QAC3B;AAAA,MACF;AACA,aAAOtB,EAAgBqB,GAASpB,GAAUd,GAAST,CAAW;AAAA,IAChE;AAAA,IAEA,KAAK,SAAS;AACZ,YAAM2C,IAAU,CAAC,GAAGF,CAAU;AAC9B,iBAAWjB,KAAOiB,GAAY;AAC5B,cAAMI,IAAa5B,EAAYW,GAAMJ,GAAKf,GAAST,CAAW;AAC9D,QAAA2C,EAAQ,KAAK,GAAGE,CAAU;AAAA,MAC5B;AACA,aAAOvB,EAAgBqB,GAASpB,GAAUd,GAAST,CAAW;AAAA,IAChE;AAAA,IAEA,KAAK;AACH,aAAOY,EAAoB6B,GAAYhC,GAAST,CAAW;AAAA,IAG7D;AACE,aAAOsB,EAAgBmB,GAAYlB,GAAUd,GAAST,CAAW;AAAA,EACnE;AAEJ;"}
1
+ {"version":3,"file":"utils.mjs","sources":["../../src/tree/utils.ts"],"sourcesContent":["import type { TreeNodeData } from 'element-plus'\n\nexport function flattenTree(nodes: TreeNodeData[], result: TreeNodeData[] = [], childrenKey = 'children'): TreeNodeData[] {\n for (const node of nodes) {\n result.push(node)\n if (node[childrenKey] && node[childrenKey].length > 0) {\n flattenTree(node[childrenKey], result, childrenKey)\n }\n }\n return result\n}\n\nexport function addDisabledToNodes(nodes: TreeNodeData[], disabled: boolean, propsConfig: any): TreeNodeData[] {\n if (!disabled) {\n return nodes\n }\n\n return nodes.map((node) => {\n const newNode = { ...node }\n newNode[propsConfig.disabled!] = true\n\n if (node[propsConfig.children!] && node[propsConfig.children!].length > 0) {\n newNode[propsConfig.children!] = addDisabledToNodes(node[propsConfig.children!], disabled, propsConfig)\n }\n\n return newNode\n })\n}\n\nexport function traverseTree(\n nodes: TreeNodeData[],\n callback: (node: TreeNodeData) => void,\n options: {\n leafOnly?: boolean\n childrenKey?: string\n } = {},\n) {\n const { leafOnly = false, childrenKey = 'children' } = options\n\n for (const node of nodes) {\n const children = node[childrenKey] || []\n const isLeaf = children.length === 0\n\n if (!leafOnly || isLeaf) {\n callback(node)\n }\n if (children.length > 0) {\n traverseTree(children, callback, options)\n }\n }\n}\n\nexport function getChildrenKeys(node: TreeNodeData, nodeKey: string, propsConfig: any): any[] {\n const children = node[propsConfig.children!] || []\n if (children.length === 0)\n return []\n\n const keys: any[] = []\n traverseTree(children, (child) => {\n keys.push(child[nodeKey])\n }, { childrenKey: propsConfig.children })\n\n return keys\n}\n\nexport function extractKeysFromPath(pathNodes: TreeNodeData[], nodeKey: string, propsConfig: any): any[] {\n const keys: any[] = []\n traverseTree(pathNodes, (node) => {\n keys.push(node[nodeKey])\n }, { leafOnly: true, childrenKey: propsConfig.children })\n\n return keys\n}\n\nexport function getSelectedPath(nodes: TreeNodeData[], selectedKeys: any[], nodeKey: string, propsConfig: any): TreeNodeData[] {\n const result: TreeNodeData[] = []\n\n for (const node of nodes) {\n const children = node[propsConfig.children!] || []\n const hasSelectedChild = children.length > 0\n ? getSelectedPath(children, selectedKeys, nodeKey, propsConfig).length > 0\n : false\n\n if (selectedKeys.includes(node[nodeKey]) || hasSelectedChild) {\n const newNode = { ...node }\n if (hasSelectedChild && children.length > 0) {\n newNode[propsConfig.children!] = getSelectedPath(children, selectedKeys, nodeKey, propsConfig)\n }\n result.push(newNode)\n }\n }\n\n return result\n}\n\n/**\n * 查找节点的所有父节点路径\n */\nexport function findParents(nodes: TreeNodeData[], targetKey: any, nodeKey: string, propsConfig: any, parents: any[] = []): any[] {\n for (const node of nodes) {\n const currentPath = [...parents, node[nodeKey]]\n\n if (node[nodeKey] === targetKey) {\n return currentPath\n }\n\n const children = node[propsConfig.children!] || []\n if (children.length > 0) {\n const found = findParents(children, targetKey, nodeKey, propsConfig, currentPath)\n if (found.length > 0) {\n return found\n }\n }\n }\n /* istanbul ignore next -- @preserve */\n return []\n}\n\n/**\n * 过滤叶子节点\n */\nexport function filterLeafNodes(keys: any[], flatData: TreeNodeData[], nodeKey: string, propsConfig: any): any[] {\n return keys.filter((key) => {\n const node = flatData.find(n => n[nodeKey] === key)\n if (!node)\n return false\n const children = node[propsConfig.children!] || []\n return children.length === 0\n })\n}\n\n/**\n * 获取输出数据\n */\nexport function getOutputData(\n keys: any[],\n halfCheckedKeys: any[] = [],\n options: {\n flatData: TreeNodeData[]\n nodeKey: string\n propsConfig: any\n data: TreeNodeData[]\n valueType: string\n includeHalfChecked: boolean\n checkStrictly: boolean\n },\n) {\n const { flatData, nodeKey, propsConfig, data, valueType, includeHalfChecked, checkStrictly } = options\n\n const selectedNodes = flatData.filter(node =>\n keys.includes(node[nodeKey]),\n )\n\n let outputKeys = [...keys]\n let outputNodes = [...selectedNodes]\n\n if (checkStrictly) {\n return {\n value: outputKeys,\n nodes: outputNodes,\n }\n }\n\n switch (valueType) {\n case 'parent': {\n const allChildKeys: any[] = []\n for (const node of selectedNodes) {\n allChildKeys.push(...getChildrenKeys(node, nodeKey, propsConfig))\n }\n outputKeys = keys.filter(key => !allChildKeys.includes(key))\n outputNodes = selectedNodes.filter(node =>\n outputKeys.includes(node[nodeKey]),\n )\n break\n }\n\n case 'child': {\n for (const node of selectedNodes) {\n const childKeys = getChildrenKeys(node, nodeKey, propsConfig)\n const hasSelectedChild = childKeys.some(key => keys.includes(key))\n if (hasSelectedChild) {\n outputKeys = outputKeys.filter(key => key !== node[nodeKey])\n outputNodes = outputNodes.filter(n =>\n n[nodeKey] !== node[nodeKey],\n )\n }\n }\n break\n }\n\n case 'path': {\n const selectedPath = getSelectedPath(data, keys, nodeKey, propsConfig)\n return {\n value: selectedPath,\n nodes: selectedPath,\n }\n }\n\n default: { // 'all'\n if (includeHalfChecked && halfCheckedKeys.length > 0) {\n const halfCheckedNodes = flatData.filter(node =>\n halfCheckedKeys.includes(node[nodeKey]),\n )\n outputKeys = [...outputKeys, ...halfCheckedKeys]\n outputNodes = [...outputNodes, ...halfCheckedNodes]\n }\n break\n }\n }\n\n return {\n value: outputKeys,\n nodes: outputNodes,\n }\n}\n\n/**\n * 根据valueType将输入值转换为checkedKeys\n */\nexport function getInputKeys(\n inputValue: any,\n options: {\n optionAsValue: boolean\n nodeKey: string\n flatData: TreeNodeData[]\n propsConfig: any\n data: TreeNodeData[]\n valueType: string\n checkStrictly: boolean\n },\n): any[] {\n const { optionAsValue, nodeKey, flatData, propsConfig, data, valueType, checkStrictly } = options\n\n /* istanbul ignore if -- @preserve */\n if (!inputValue || !Array.isArray(inputValue))\n return []\n\n const valueArray = optionAsValue ? inputValue.map((item: any) => item[nodeKey]) : inputValue\n\n if (checkStrictly) {\n return valueArray\n }\n\n switch (valueType) {\n case 'parent': {\n const allKeys = [...valueArray]\n\n for (const key of valueArray) {\n const node = flatData.find(n => n[nodeKey] === key)\n if (node) {\n const childKeys = getChildrenKeys(node, nodeKey, propsConfig)\n allKeys.push(...childKeys)\n }\n }\n return filterLeafNodes(allKeys, flatData, nodeKey, propsConfig)\n }\n\n case 'child': {\n const allKeys = [...valueArray]\n for (const key of valueArray) {\n const parentPath = findParents(data, key, nodeKey, propsConfig)\n allKeys.push(...parentPath)\n }\n return filterLeafNodes(allKeys, flatData, nodeKey, propsConfig)\n }\n\n case 'path': {\n return extractKeysFromPath(valueArray, nodeKey, propsConfig)\n }\n\n default: { // 'all'\n return filterLeafNodes(valueArray, flatData, nodeKey, propsConfig)\n }\n }\n}\n"],"names":["flattenTree","nodes","result","childrenKey","node","addDisabledToNodes","disabled","propsConfig","newNode","traverseTree","callback","options","leafOnly","children","isLeaf","getChildrenKeys","nodeKey","keys","child","extractKeysFromPath","pathNodes","getSelectedPath","selectedKeys","hasSelectedChild","findParents","targetKey","parents","currentPath","found","filterLeafNodes","flatData","key","n","getOutputData","halfCheckedKeys","data","valueType","includeHalfChecked","checkStrictly","selectedNodes","outputKeys","outputNodes","allChildKeys","selectedPath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CAAW;AAC5D,UAAA2C,EAAQ,KAAK,GAAGC,CAAS;AAAA,QAC3B;AAAA,MACF;AACA,aAAOtB,EAAgBqB,GAASpB,GAAUd,GAAST,CAAW;AAAA,IAChE;AAAA,IAEA,KAAK,SAAS;AACZ,YAAM2C,IAAU,CAAC,GAAGF,CAAU;AAC9B,iBAAWjB,KAAOiB,GAAY;AAC5B,cAAMI,IAAa5B,EAAYW,GAAMJ,GAAKf,GAAST,CAAW;AAC9D,QAAA2C,EAAQ,KAAK,GAAGE,CAAU;AAAA,MAC5B;AACA,aAAOvB,EAAgBqB,GAASpB,GAAUd,GAAST,CAAW;AAAA,IAChE;AAAA,IAEA,KAAK;AACH,aAAOY,EAAoB6B,GAAYhC,GAAST,CAAW;AAAA,IAG7D;AACE,aAAOsB,EAAgBmB,GAAYlB,GAAUd,GAAST,CAAW;AAAA,EACnE;AAEJ;"}
@@ -1,18 +1,22 @@
1
- import { useField as c, connect as i, mapProps as f } from "@silver-formily/vue";
2
- import { PreviewText as p } from "../preview-text/index.mjs";
3
- import { defineComponent as m, useSlots as d, ref as u, openBlock as S, createBlock as _, unref as e, mergeProps as g, createSlots as P, renderList as R, withCtx as T, renderSlot as v, normalizeProps as y, guardReactiveProps as h } from "vue";
4
- import { ElTreeSelect as k } from "element-plus";
5
- import { useCleanAttrs as x } from "../__builtins__/shared/utils.mjs";
6
- import { mapReadPretty as C } from "../__builtins__/shared/transform-component.mjs";
7
- const w = /* @__PURE__ */ m({
1
+ import { useField as c, connect as i, mapProps as p } from "@silver-formily/vue";
2
+ import { ElTreeSelect as m } from "element-plus";
3
+ import "@formily/reactive";
4
+ import "@vueuse/core";
5
+ import { defineComponent as f, useSlots as d, ref as u, openBlock as S, createBlock as _, unref as e, mergeProps as g, createSlots as P, renderList as R, withCtx as T, renderSlot as v, normalizeProps as y, guardReactiveProps as h } from "vue";
6
+ import { mapReadPretty as k } from "../__builtins__/shared/transform-component.mjs";
7
+ import { PreviewText as x } from "../preview-text/index.mjs";
8
+ import "@formily/core";
9
+ import "@silver-formily/reactive-vue";
10
+ import { useCleanAttrs as C } from "../__builtins__/shared/utils.mjs";
11
+ const w = /* @__PURE__ */ f({
8
12
  name: "FSelectTree",
9
13
  inheritAttrs: !1,
10
14
  __name: "tree-select",
11
15
  setup(A) {
12
- const n = d(), { props: l } = x(), r = u(), t = c();
16
+ const n = d(), { props: l } = C(), r = u(), t = c();
13
17
  return t.value?.inject({
14
18
  getTreeSelectRef: () => r
15
- }), (s, B) => (S(), _(e(k), g({
19
+ }), (s, B) => (S(), _(e(m), g({
16
20
  ref_key: "treeSelectRef",
17
21
  ref: r,
18
22
  loading: e(t).value?.loading
@@ -25,13 +29,13 @@ const w = /* @__PURE__ */ m({
25
29
  }))
26
30
  ]), 1040, ["loading"]));
27
31
  }
28
- }), b = i(
32
+ }), H = i(
29
33
  w,
30
- f({ readOnly: "readonly", dataSource: "data" }),
31
- C(p.Select)
34
+ p({ readOnly: "readonly", dataSource: "data" }),
35
+ k(x.Select)
32
36
  );
33
37
  export {
34
- b as TreeSelect,
35
- b as default
38
+ H as TreeSelect,
39
+ H as default
36
40
  };
37
41
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../src/tree-select/tree-select.vue","../../src/tree-select/index.ts"],"sourcesContent":["<script setup lang=\"ts\">\r\nimport type { Field } from '@formily/core'\r\nimport { useField } from '@silver-formily/vue'\r\nimport { ElTreeSelect } from 'element-plus'\r\nimport { ref, useSlots } from 'vue'\r\nimport { useCleanAttrs } from '../__builtins__'\r\n\r\ndefineOptions({\r\n name: 'FSelectTree',\r\n inheritAttrs: false,\r\n})\r\n\r\nconst slots = useSlots()\r\n\r\nconst { props: attrs } = useCleanAttrs()\r\n\r\nconst treeSelectRef = ref()\r\n\r\nconst fieldRef = useField<Field>()\r\n\r\nfieldRef.value?.inject({\r\n getTreeSelectRef: () => {\r\n return treeSelectRef\r\n },\r\n})\r\n</script>\r\n\r\n<template>\r\n <ElTreeSelect\r\n ref=\"treeSelectRef\"\r\n :loading=\"fieldRef.value?.loading\"\r\n v-bind=\"attrs\"\r\n >\r\n <template v-for=\"(_, name) of slots\" #[name]=\"slotData\">\r\n <slot :name=\"name\" v-bind=\"{ field: fieldRef, ...slotData }\" />\r\n </template>\r\n </ElTreeSelect>\r\n</template>\r\n","import { connect, mapProps } from '@silver-formily/vue'\r\nimport { mapReadPretty } from '../__builtins__'\r\nimport { PreviewText } from '../preview-text'\r\nimport FTreeSelect from './tree-select.vue'\r\n\r\nexport const TreeSelect = connect<typeof FTreeSelect>(\n FTreeSelect,\n mapProps({ readOnly: 'readonly', dataSource: 'data' }),\r\n mapReadPretty(PreviewText.Select),\r\n)\r\n\r\nexport default TreeSelect\r\n"],"names":["slots","useSlots","attrs","useCleanAttrs","treeSelectRef","ref","fieldRef","useField","_openBlock","_createBlock","_unref","_mergeProps","_createSlots","_","name","_withCtx","slotData","_renderSlot","_ctx","_normalizeProps","_guardReactiveProps","TreeSelect","connect","FTreeSelect","mapProps","mapReadPretty","PreviewText"],"mappings":";;;;;;;;;;;AAYA,UAAMA,IAAQC,EAAA,GAER,EAAE,OAAOC,EAAA,IAAUC,EAAA,GAEnBC,IAAgBC,EAAA,GAEhBC,IAAWC,EAAA;AAEjB,WAAAD,EAAS,OAAO,OAAO;AAAA,MACrB,kBAAkB,MACTF;AAAA,IACT,CACD,cAICI,KAAAC,EAQeC,MARfC,EAQe;AAAA,eAPT;AAAA,MAAJ,KAAIP;AAAA,MACH,SAASM,EAAAJ,CAAA,EAAS,OAAO;AAAA,IAAA,GAClBI,EAAAR,CAAA,CAAK,GAAAU,EAAA,EAAA,GAAA,KAAA;AAAA,QAEiBF,EAAAV,CAAA,GAAK,CAAjBa,GAAGC;;QACnB,IAAAC,EAAA,CAD4CC,MAAQ;AAAA,UACpDC,EAA+DC,EAAA,QAAlDJ,GAAIK,EAAAC,EAAA,EAAA,OAAmBV,EAAAJ,CAAA,MAAaU,EAAA,CAAQ,CAAA,CAAA;AAAA,QAAA;;;;IC7BlDK,IAAaC;AAAA,EACxBC;AAAAA,EACAC,EAAS,EAAE,UAAU,YAAY,YAAY,QAAQ;AAAA,EACrDC,EAAcC,EAAY,MAAM;AAClC;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../src/tree-select/tree-select.vue","../../src/tree-select/index.ts"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { Field } from '@formily/core'\nimport { useField } from '@silver-formily/vue'\nimport { ElTreeSelect } from 'element-plus'\nimport { ref, useSlots } from 'vue'\nimport { useCleanAttrs } from '../__builtins__'\n\ndefineOptions({\n name: 'FSelectTree',\n inheritAttrs: false,\n})\n\nconst slots = useSlots()\n\nconst { props: attrs } = useCleanAttrs()\n\nconst treeSelectRef = ref()\n\nconst fieldRef = useField<Field>()\n\nfieldRef.value?.inject({\n getTreeSelectRef: () => {\n return treeSelectRef\n },\n})\n</script>\n\n<template>\n <ElTreeSelect\n ref=\"treeSelectRef\"\n :loading=\"fieldRef.value?.loading\"\n v-bind=\"attrs\"\n >\n <template v-for=\"(_, name) of slots\" #[name]=\"slotData\">\n <slot :name=\"name\" v-bind=\"{ field: fieldRef, ...slotData }\" />\n </template>\n </ElTreeSelect>\n</template>\n","import { connect, mapProps } from '@silver-formily/vue'\r\nimport { mapReadPretty } from '../__builtins__'\r\nimport { PreviewText } from '../preview-text'\r\nimport FTreeSelect from './tree-select.vue'\r\n\r\nexport const TreeSelect = connect<typeof FTreeSelect>(\n FTreeSelect,\n mapProps({ readOnly: 'readonly', dataSource: 'data' }),\r\n mapReadPretty(PreviewText.Select),\r\n)\r\n\r\nexport default TreeSelect\r\n"],"names":["slots","useSlots","attrs","useCleanAttrs","treeSelectRef","ref","fieldRef","useField","_openBlock","_createBlock","_unref","_mergeProps","_createSlots","_","name","_withCtx","slotData","_renderSlot","_ctx","_normalizeProps","_guardReactiveProps","TreeSelect","connect","FTreeSelect","mapProps","mapReadPretty","PreviewText"],"mappings":";;;;;;;;;;;;;;;AAYA,UAAMA,IAAQC,EAAA,GAER,EAAE,OAAOC,EAAA,IAAUC,EAAA,GAEnBC,IAAgBC,EAAA,GAEhBC,IAAWC,EAAA;AAEjB,WAAAD,EAAS,OAAO,OAAO;AAAA,MACrB,kBAAkB,MACTF;AAAA,IACT,CACD,cAICI,KAAAC,EAQeC,MARfC,EAQe;AAAA,eAPT;AAAA,MAAJ,KAAIP;AAAA,MACH,SAASM,EAAAJ,CAAA,EAAS,OAAO;AAAA,IAAA,GAClBI,EAAAR,CAAA,CAAK,GAAAU,EAAA,EAAA,GAAA,KAAA;AAAA,QAEiBF,EAAAV,CAAA,GAAK,CAAjBa,GAAGC;;QACnB,IAAAC,EAAA,CAD4CC,MAAQ;AAAA,UACpDC,EAA+DC,EAAA,QAAlDJ,GAAIK,EAAAC,EAAA,EAAA,OAAmBV,EAAAJ,CAAA,MAAaU,EAAA,CAAQ,CAAA,CAAA;AAAA,QAAA;;;;IC7BlDK,IAAaC;AAAA,EACxBC;AAAAA,EACAC,EAAS,EAAE,UAAU,YAAY,YAAY,QAAQ;AAAA,EACrDC,EAAcC,EAAY,MAAM;AAClC;"}
@@ -4,8 +4,11 @@ import { UploadFilled as H, Plus as J, Upload as K } from "@element-plus/icons-v
4
4
  import { reaction as M } from "@formily/reactive";
5
5
  import { isFn as c } from "@formily/shared";
6
6
  import { ElUpload as Q, ElIcon as W, ElButton as X, ElImageViewer as Y, genFileId as Z } from "element-plus";
7
- import { o as ee } from "../vendor/lodash.mjs";
8
- import { hasSlotContent as te } from "../__builtins__/shared/utils.mjs";
7
+ import "@vueuse/core";
8
+ import "@formily/core";
9
+ import "@silver-formily/reactive-vue";
10
+ import { hasSlotContent as ee } from "../__builtins__/shared/utils.mjs";
11
+ import { o as te } from "../vendor/lodash.mjs";
9
12
  const oe = { class: "el-upload__text" }, re = { style: { "margin-left": "6px" } }, ne = /* @__PURE__ */ O({
10
13
  name: "FUpload",
11
14
  inheritAttrs: !1,
@@ -34,7 +37,7 @@ const oe = { class: "el-upload__text" }, re = { style: { "margin-left": "6px" }
34
37
  },
35
38
  emits: ["update:modelValue"],
36
39
  setup(u, { emit: S }) {
37
- const i = u, V = S, d = f(), o = z(), R = w(() => ee(o, [
40
+ const i = u, V = S, d = f(), o = z(), R = w(() => te(o, [
38
41
  "onChange",
39
42
  "onRemove",
40
43
  "onExceed",
@@ -100,7 +103,7 @@ const oe = { class: "el-upload__text" }, re = { style: { "margin-left": "6px" }
100
103
  onPreview: B
101
104
  }), q({
102
105
  default: s(() => [
103
- r(te)(e.$slots?.default) ? m(e.$slots, "default", { key: 0 }) : (a(), v(y, { key: 1 }, [
106
+ r(ee)(e.$slots?.default) ? m(e.$slots, "default", { key: 0 }) : (a(), v(y, { key: 1 }, [
104
107
  r(o).drag ? (a(), v(y, { key: 0 }, [
105
108
  p(r(W), { style: { "font-size": "60px", margin: "40px 0 16px" } }, {
106
109
  default: s(() => [
@@ -162,12 +165,12 @@ const oe = { class: "el-upload__text" }, re = { style: { "margin-left": "6px" }
162
165
  }), null, 16, ["url-list", "initial-index"])) : G("", !0)
163
166
  ], 64));
164
167
  }
165
- }), me = N(
168
+ }), ve = N(
166
169
  ne,
167
170
  j({ readOnly: "readonly", dataSource: "fileList" })
168
171
  );
169
172
  export {
170
- me as Upload,
171
- me as default
173
+ ve as Upload,
174
+ ve as default
172
175
  };
173
176
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../src/upload/upload.vue","../../src/upload/index.ts"],"sourcesContent":["<script lang=\"ts\" setup>\r\nimport type { Field } from '@formily/core'\r\nimport type { ImageViewerInstance, ImageViewerProps, UploadFile, UploadInstance, UploadProps, UploadRawFile } from 'element-plus'\r\nimport type { PropType } from 'vue'\r\nimport {\r\n Plus as PlusIcon,\r\n UploadFilled as UploadFilledIcon,\r\n Upload as UploadIcon,\r\n} from '@element-plus/icons-vue'\r\nimport { reaction } from '@formily/reactive'\r\nimport { isFn } from '@formily/shared'\r\nimport { useField } from '@silver-formily/vue'\r\nimport { ElButton, ElIcon, ElImageViewer, ElUpload, genFileId } from 'element-plus'\r\nimport { omit } from 'lodash-es'\r\nimport { computed, onBeforeUnmount, ref, useAttrs } from 'vue'\r\nimport { hasSlotContent } from '../__builtins__'\r\n\r\ndefineOptions({\r\n name: 'FUpload',\r\n inheritAttrs: false,\r\n})\r\n\r\nconst props = defineProps({\r\n textContent: {\r\n type: String,\r\n default: '',\r\n },\r\n errorAdaptor: {\r\n type: Function as PropType<(error?: Error) => string>,\r\n default: (error?: Error) => error?.message,\r\n },\r\n formatValue: {\r\n type: Function as PropType<(fileList?: UploadFile[]) => any>,\r\n default: item => item,\r\n },\r\n fileList: {\r\n type: Array as PropType<UploadFile[]>,\r\n default: () => [],\r\n },\r\n imageViewerProps: {\r\n type: Object as PropType<ImageViewerProps>,\r\n default: () => ({ teleported: true, showProgress: true }),\r\n },\r\n})\r\n\r\nconst emit = defineEmits(['update:modelValue'])\r\n\r\nconst uploadRef = ref<UploadInstance>()\r\nconst attrs = useAttrs() as UploadProps\r\nconst innerAttrs = computed(() => {\r\n return omit(attrs, [\r\n 'onChange',\r\n 'onRemove',\r\n 'onExceed',\r\n 'onError',\r\n 'onPreview',\r\n 'fileList',\r\n 'onUpdate:fileList',\r\n ])\r\n})\r\nconst fieldRef = useField<Field>()\r\nfieldRef.value?.inject({\r\n getElUploadRef: () => {\r\n return uploadRef\r\n },\r\n})\r\n\r\nconst imgPreviewRef = ref<ImageViewerInstance>()\r\nconst activeImageIndex = ref(0)\r\nconst isShowImgViewer = ref(false)\r\nconst imgPreviewList = computed(() => {\r\n return props.fileList.map(item => item.url)\r\n})\r\n\r\nfunction setFeedBack(error?: Error) {\r\n const message = props.errorAdaptor(error)\r\n fieldRef.value?.setFeedback({\r\n type: 'error',\r\n code: 'UploadError',\r\n messages: message ? [message] : [],\r\n })\r\n}\r\n\r\nfunction handleChange(file: UploadFile, fileList: UploadFile[]) {\r\n fieldRef.value?.setDataSource([...fileList])\r\n setFeedBack()\r\n}\r\n\r\nfunction handleRemove(file: UploadFile, fileList: UploadFile[]) {\r\n if (isFn(attrs.onRemove)) {\r\n attrs.onRemove(file, fileList)\r\n }\r\n fieldRef.value.setDataSource([...fileList])\r\n setFeedBack()\r\n}\r\n\r\nfunction handleExceed(files: File[], uploadFIles) {\r\n if (isFn(attrs.onExceed)) {\r\n attrs.onExceed(files, uploadFIles)\r\n }\r\n if (attrs.limit !== 1)\r\n return\r\n uploadRef.value!.clearFiles()\r\n const file = files[0] as UploadRawFile\r\n file.uid = genFileId()\r\n uploadRef.value!.handleStart(file)\r\n if (attrs.autoUpload ?? true) {\r\n uploadRef.value!.submit()\r\n }\r\n}\r\n\r\nfunction handleError(error: Error, file: UploadFile, fileList: UploadFile[]) {\r\n if (isFn(attrs.onError)) {\r\n (attrs.onError)(error, file, fileList)\r\n }\r\n}\r\n\r\nfunction onPreviewClick(uploadFile: UploadFile) {\r\n if (isFn(attrs.onPreview)) {\r\n (attrs.onPreview)(uploadFile)\r\n return\r\n }\r\n if (!uploadFile.url && !attrs.accept?.includes('image'))\r\n return\r\n const clickIndex = props.fileList.findIndex((element: UploadFile) => element.uid === uploadFile.uid)\r\n activeImageIndex.value = clickIndex\r\n isShowImgViewer.value = true\r\n}\r\n\r\nconst dispose = reaction(() => {\r\n return fieldRef.value?.dataSource ?? []\r\n}, () => {\r\n const emitValue = props.formatValue(fieldRef.value.dataSource as UploadFile[])\r\n emit('update:modelValue', emitValue)\r\n})\r\nonBeforeUnmount(() => {\r\n dispose()\r\n})\r\n</script>\r\n\r\n<template>\r\n <ElUpload\r\n ref=\"uploadRef\"\r\n v-bind=\"innerAttrs\"\r\n :file-list=\"$props.fileList\"\r\n @change=\"handleChange\"\r\n @remove=\"handleRemove\"\r\n @exceed=\"handleExceed\"\r\n @error=\"handleError\"\r\n @preview=\"onPreviewClick\"\r\n >\r\n <slot v-if=\"hasSlotContent($slots?.default)\" />\r\n <template v-else>\r\n <template v-if=\"attrs.drag\">\r\n <ElIcon style=\"font-size: 60px; margin: 40px 0 16px;\">\r\n <UploadFilledIcon color=\"gray\" />\r\n </ElIcon>\r\n <div class=\"el-upload__text\">\r\n {{ props.textContent }}\r\n </div>\r\n </template>\r\n <template v-else-if=\"attrs.listType === 'picture-card'\">\r\n <PlusIcon style=\"width: 28px; height: 28px; color: gray\" />\r\n </template>\r\n <template v-else>\r\n <ElButton>\r\n <UploadIcon width=\"16px\" height=\"16px\" />\r\n <span style=\"margin-left: 6px\">\r\n {{ props.textContent }}\r\n </span>\r\n </ElButton>\r\n </template>\r\n </template>\r\n <template v-if=\"$slots.file\" #file=\"{ file, index }\">\r\n <slot name=\"file\" :file=\"file\" :index=\"index\" />\r\n </template>\r\n <template v-if=\"$slots.tip\" #tip>\r\n <slot name=\"tip\" />\r\n </template>\r\n <template v-if=\"$slots.trigger\" #trigger>\r\n <slot name=\"trigger\" />\r\n </template>\r\n </ElUpload>\r\n <ElImageViewer\r\n v-if=\"isShowImgViewer\"\r\n ref=\"imgPreviewRef\"\r\n :url-list=\"imgPreviewList\"\r\n :initial-index=\"activeImageIndex\"\r\n v-bind=\"props.imageViewerProps\"\r\n @close=\"isShowImgViewer = false\"\r\n />\r\n</template>\r\n","import { connect, mapProps } from '@silver-formily/vue'\r\nimport FUpload from './upload.vue'\r\n\r\nexport const Upload = connect<typeof FUpload>(\n FUpload,\n mapProps({ readOnly: 'readonly', dataSource: 'fileList' }),\r\n)\r\n\r\nexport default Upload\r\n"],"names":["props","__props","emit","__emit","uploadRef","ref","attrs","useAttrs","innerAttrs","computed","omit","fieldRef","useField","imgPreviewRef","activeImageIndex","isShowImgViewer","imgPreviewList","item","setFeedBack","error","message","handleChange","file","fileList","handleRemove","isFn","handleExceed","files","uploadFIles","genFileId","handleError","onPreviewClick","uploadFile","clickIndex","element","dispose","reaction","emitValue","onBeforeUnmount","_createVNode","_unref","_mergeProps","$props","hasSlotContent","$slots","_renderSlot","_ctx","_createElementBlock","_Fragment","ElIcon","UploadFilledIcon","_createElementVNode","_hoisted_1","_toDisplayString","_createBlock","PlusIcon","ElButton","UploadIcon","_hoisted_2","index","_openBlock","Upload","connect","FUpload","mapProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,UAAMA,IAAQC,GAuBRC,IAAOC,GAEPC,IAAYC,EAAA,GACZC,IAAQC,EAAA,GACRC,IAAaC,EAAS,MACnBC,GAAKJ,GAAO;AAAA,MACjB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,CACD,CACF,GACKK,IAAWC,EAAA;AACjB,IAAAD,EAAS,OAAO,OAAO;AAAA,MACrB,gBAAgB,MACPP;AAAA,IACT,CACD;AAED,UAAMS,IAAgBR,EAAA,GAChBS,IAAmBT,EAAI,CAAC,GACxBU,IAAkBV,EAAI,EAAK,GAC3BW,IAAiBP,EAAS,MACvBT,EAAM,SAAS,IAAI,CAAAiB,MAAQA,EAAK,GAAG,CAC3C;AAED,aAASC,EAAYC,GAAe;AAClC,YAAMC,IAAUpB,EAAM,aAAamB,CAAK;AACxC,MAAAR,EAAS,OAAO,YAAY;AAAA,QAC1B,MAAM;AAAA,QACN,MAAM;AAAA,QACN,UAAUS,IAAU,CAACA,CAAO,IAAI,CAAA;AAAA,MAAC,CAClC;AAAA,IACH;AAEA,aAASC,EAAaC,GAAkBC,GAAwB;AAC9D,MAAAZ,EAAS,OAAO,cAAc,CAAC,GAAGY,CAAQ,CAAC,GAC3CL,EAAA;AAAA,IACF;AAEA,aAASM,EAAaF,GAAkBC,GAAwB;AAC9D,MAAIE,EAAKnB,EAAM,QAAQ,KACrBA,EAAM,SAASgB,GAAMC,CAAQ,GAE/BZ,EAAS,MAAM,cAAc,CAAC,GAAGY,CAAQ,CAAC,GAC1CL,EAAA;AAAA,IACF;AAEA,aAASQ,EAAaC,GAAeC,GAAa;AAIhD,UAHIH,EAAKnB,EAAM,QAAQ,KACrBA,EAAM,SAASqB,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MAInB/B,EAAA,SADR6C,EAAA,GAAAN,EAOEd,MAPFC,EAOE;AAAA;iBALI;AAAA,QAAJ,KAAI5B;AAAA,QACH,YAAUG,EAAA;AAAA,QACV,iBAAeF,EAAA;AAAA,MAAA,GACRd,EAAM,kBAAgB;AAAA,QAC7B,gCAAOe,EAAA,QAAe;AAAA,MAAA;;;IC1Ld8C,KAASC;AAAA,EACpBC;AAAAA,EACAC,EAAS,EAAE,UAAU,YAAY,YAAY,YAAY;AAC3D;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../src/upload/upload.vue","../../src/upload/index.ts"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { Field } from '@formily/core'\nimport type { ImageViewerInstance, ImageViewerProps, UploadFile, UploadInstance, UploadProps, UploadRawFile } from 'element-plus'\nimport type { PropType } from 'vue'\nimport {\n Plus as PlusIcon,\n UploadFilled as UploadFilledIcon,\n Upload as UploadIcon,\n} from '@element-plus/icons-vue'\nimport { reaction } from '@formily/reactive'\nimport { isFn } from '@formily/shared'\nimport { useField } from '@silver-formily/vue'\nimport { ElButton, ElIcon, ElImageViewer, ElUpload, genFileId } from 'element-plus'\nimport { omit } from 'lodash-es'\nimport { computed, onBeforeUnmount, ref, useAttrs } from 'vue'\nimport { hasSlotContent } from '../__builtins__'\n\ndefineOptions({\n name: 'FUpload',\n inheritAttrs: false,\n})\n\nconst props = defineProps({\n textContent: {\n type: String,\n default: '',\n },\n errorAdaptor: {\n type: Function as PropType<(error?: Error) => string>,\n default: (error?: Error) => error?.message,\n },\n formatValue: {\n type: Function as PropType<(fileList?: UploadFile[]) => any>,\n default: item => item,\n },\n fileList: {\n type: Array as PropType<UploadFile[]>,\n default: () => [],\n },\n imageViewerProps: {\n type: Object as PropType<ImageViewerProps>,\n default: () => ({ teleported: true, showProgress: true }),\n },\n})\n\nconst emit = defineEmits(['update:modelValue'])\n\nconst uploadRef = ref<UploadInstance>()\nconst attrs = useAttrs() as UploadProps\nconst innerAttrs = computed(() => {\n return omit(attrs, [\n 'onChange',\n 'onRemove',\n 'onExceed',\n 'onError',\n 'onPreview',\n 'fileList',\n 'onUpdate:fileList',\n ])\n})\nconst fieldRef = useField<Field>()\nfieldRef.value?.inject({\n getElUploadRef: () => {\n return uploadRef\n },\n})\n\nconst imgPreviewRef = ref<ImageViewerInstance>()\nconst activeImageIndex = ref(0)\nconst isShowImgViewer = ref(false)\nconst imgPreviewList = computed(() => {\n return props.fileList.map(item => item.url)\n})\n\nfunction setFeedBack(error?: Error) {\n const message = props.errorAdaptor(error)\n fieldRef.value?.setFeedback({\n type: 'error',\n code: 'UploadError',\n messages: message ? [message] : [],\n })\n}\n\nfunction handleChange(file: UploadFile, fileList: UploadFile[]) {\n fieldRef.value?.setDataSource([...fileList])\n setFeedBack()\n}\n\nfunction handleRemove(file: UploadFile, fileList: UploadFile[]) {\n if (isFn(attrs.onRemove)) {\n attrs.onRemove(file, fileList)\n }\n fieldRef.value.setDataSource([...fileList])\n setFeedBack()\n}\n\nfunction handleExceed(files: File[], uploadFIles) {\n if (isFn(attrs.onExceed)) {\n attrs.onExceed(files, uploadFIles)\n }\n if (attrs.limit !== 1)\n return\n uploadRef.value!.clearFiles()\n const file = files[0] as UploadRawFile\n file.uid = genFileId()\n uploadRef.value!.handleStart(file)\n if (attrs.autoUpload ?? true) {\n uploadRef.value!.submit()\n }\n}\n\nfunction handleError(error: Error, file: UploadFile, fileList: UploadFile[]) {\n if (isFn(attrs.onError)) {\n (attrs.onError)(error, file, fileList)\n }\n}\n\nfunction onPreviewClick(uploadFile: UploadFile) {\n if (isFn(attrs.onPreview)) {\n (attrs.onPreview)(uploadFile)\n return\n }\n if (!uploadFile.url && !attrs.accept?.includes('image'))\n return\n const clickIndex = props.fileList.findIndex((element: UploadFile) => element.uid === uploadFile.uid)\n activeImageIndex.value = clickIndex\n isShowImgViewer.value = true\n}\n\nconst dispose = reaction(() => {\n return fieldRef.value?.dataSource ?? []\n}, () => {\n const emitValue = props.formatValue(fieldRef.value.dataSource as UploadFile[])\n emit('update:modelValue', emitValue)\n})\nonBeforeUnmount(() => {\n dispose()\n})\n</script>\n\n<template>\n <ElUpload\n ref=\"uploadRef\"\n v-bind=\"innerAttrs\"\n :file-list=\"$props.fileList\"\n @change=\"handleChange\"\n @remove=\"handleRemove\"\n @exceed=\"handleExceed\"\n @error=\"handleError\"\n @preview=\"onPreviewClick\"\n >\n <slot v-if=\"hasSlotContent($slots?.default)\" />\n <template v-else>\n <template v-if=\"attrs.drag\">\n <ElIcon style=\"font-size: 60px; margin: 40px 0 16px;\">\n <UploadFilledIcon color=\"gray\" />\n </ElIcon>\n <div class=\"el-upload__text\">\n {{ props.textContent }}\n </div>\n </template>\n <template v-else-if=\"attrs.listType === 'picture-card'\">\n <PlusIcon style=\"width: 28px; height: 28px; color: gray\" />\n </template>\n <template v-else>\n <ElButton>\n <UploadIcon width=\"16px\" height=\"16px\" />\n <span style=\"margin-left: 6px\">\n {{ props.textContent }}\n </span>\n </ElButton>\n </template>\n </template>\n <template v-if=\"$slots.file\" #file=\"{ file, index }\">\n <slot name=\"file\" :file=\"file\" :index=\"index\" />\n </template>\n <template v-if=\"$slots.tip\" #tip>\n <slot name=\"tip\" />\n </template>\n <template v-if=\"$slots.trigger\" #trigger>\n <slot name=\"trigger\" />\n </template>\n </ElUpload>\n <ElImageViewer\n v-if=\"isShowImgViewer\"\n ref=\"imgPreviewRef\"\n :url-list=\"imgPreviewList\"\n :initial-index=\"activeImageIndex\"\n v-bind=\"props.imageViewerProps\"\n @close=\"isShowImgViewer = false\"\n />\n</template>\n","import { connect, mapProps } from '@silver-formily/vue'\r\nimport FUpload from './upload.vue'\r\n\r\nexport const Upload = connect<typeof FUpload>(\n FUpload,\n mapProps({ readOnly: 'readonly', dataSource: 'fileList' }),\r\n)\r\n\r\nexport default Upload\r\n"],"names":["props","__props","emit","__emit","uploadRef","ref","attrs","useAttrs","innerAttrs","computed","omit","fieldRef","useField","imgPreviewRef","activeImageIndex","isShowImgViewer","imgPreviewList","item","setFeedBack","error","message","handleChange","file","fileList","handleRemove","isFn","handleExceed","files","uploadFIles","genFileId","handleError","onPreviewClick","uploadFile","clickIndex","element","dispose","reaction","emitValue","onBeforeUnmount","_createVNode","_unref","_mergeProps","$props","hasSlotContent","$slots","_renderSlot","_ctx","_createElementBlock","_Fragment","ElIcon","UploadFilledIcon","_createElementVNode","_hoisted_1","_toDisplayString","_createBlock","PlusIcon","ElButton","UploadIcon","_hoisted_2","index","_openBlock","Upload","connect","FUpload","mapProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,UAAMA,IAAQC,GAuBRC,IAAOC,GAEPC,IAAYC,EAAA,GACZC,IAAQC,EAAA,GACRC,IAAaC,EAAS,MACnBC,GAAKJ,GAAO;AAAA,MACjB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,CACD,CACF,GACKK,IAAWC,EAAA;AACjB,IAAAD,EAAS,OAAO,OAAO;AAAA,MACrB,gBAAgB,MACPP;AAAA,IACT,CACD;AAED,UAAMS,IAAgBR,EAAA,GAChBS,IAAmBT,EAAI,CAAC,GACxBU,IAAkBV,EAAI,EAAK,GAC3BW,IAAiBP,EAAS,MACvBT,EAAM,SAAS,IAAI,CAAAiB,MAAQA,EAAK,GAAG,CAC3C;AAED,aAASC,EAAYC,GAAe;AAClC,YAAMC,IAAUpB,EAAM,aAAamB,CAAK;AACxC,MAAAR,EAAS,OAAO,YAAY;AAAA,QAC1B,MAAM;AAAA,QACN,MAAM;AAAA,QACN,UAAUS,IAAU,CAACA,CAAO,IAAI,CAAA;AAAA,MAAC,CAClC;AAAA,IACH;AAEA,aAASC,EAAaC,GAAkBC,GAAwB;AAC9D,MAAAZ,EAAS,OAAO,cAAc,CAAC,GAAGY,CAAQ,CAAC,GAC3CL,EAAA;AAAA,IACF;AAEA,aAASM,EAAaF,GAAkBC,GAAwB;AAC9D,MAAIE,EAAKnB,EAAM,Q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;QAElBf,EAAAA,OAAO;gBAAM;AAAA,gBAC3B,MAAmB;AAAA,YAAnBC,EAAmBC,EAAA,QAAA,KAAA;AAAA,UAAA;;;QAELF,EAAAA,OAAO;gBAAU;AAAA,gBAC/B,MAAuB;AAAA,YAAvBC,EAAuBC,EAAA,QAAA,SAAA;AAAA,UAAA;;;;MAInB/B,EAAA,SADR6C,EAAA,GAAAN,EAOEd,MAPFC,EAOE;AAAA;iBALI;AAAA,QAAJ,KAAI5B;AAAA,QACH,YAAUG,EAAA;AAAA,QACV,iBAAeF,EAAA;AAAA,MAAA,GACRd,EAAM,kBAAgB;AAAA,QAC7B,gCAAOe,EAAA,QAAe;AAAA,MAAA;;;IC1Ld8C,KAASC;AAAA,EACpBC;AAAAA,EACAC,EAAS,EAAE,UAAU,YAAY,YAAY,YAAY;AAC3D;"}
@@ -1 +1 @@
1
- {"version":3,"file":"sizes.mjs","sources":["../../../../node_modules/.pnpm/element-plus@2.13.2_vue@3.5.28_typescript@5.9.2_/node_modules/element-plus/es/utils/typescript.mjs","../../src/pagination/components/sizes.ts"],"sourcesContent":["const mutable = (val) => val;\n\nexport { mutable };\n//# sourceMappingURL=typescript.mjs.map\n","import type { ExtractPropTypes } from 'vue'\r\nimport type Sizes from './sizes.vue'\r\nimport { componentSizes } from 'element-plus'\r\nimport { buildProps, definePropType, mutable } from 'element-plus/es/utils/index'\r\n\r\nexport const paginationSizesProps = buildProps({\r\n pageSize: {\r\n type: Number,\r\n required: true,\r\n },\r\n pageSizes: {\r\n type: definePropType<number[]>(Array),\r\n default: () => mutable([10, 20, 30, 40, 50, 100] as const),\r\n },\r\n popperClass: {\r\n type: String,\r\n },\r\n disabled: Boolean,\r\n teleported: Boolean,\r\n size: {\r\n type: String,\r\n values: componentSizes,\r\n },\r\n appendSizeTo: String,\r\n} as const)\r\n\r\nexport type PaginationSizesProps = ExtractPropTypes<typeof paginationSizesProps>\r\n\r\nexport type SizesInstance = InstanceType<typeof Sizes> & unknown\r\n"],"names":["mutable","val","paginationSizesProps","buildProps","definePropType","componentSizes"],"mappings":";;AAAK,MAACA,IAAU,CAACC,MAAQA,GCKZC,IAAuBC,EAAW;AAAA,EAC7C,UAAU;AAAA,IACR,MAAM;AAAA,IACN,UAAU;AAAA,EAAA;AAAA,EAEZ,WAAW;AAAA,IACT,MAAMC,EAAyB,KAAK;AAAA,IACpC,SAAS,MAAMJ,EAAQ,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,GAAG,CAAU;AAAA,EAAA;AAAA,EAE3D,aAAa;AAAA,IACX,MAAM;AAAA,EAAA;AAAA,EAER,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,QAAQK;AAAA,EAAA;AAAA,EAEV,cAAc;AAChB,CAAU;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"sizes.mjs","sources":["../../../../node_modules/.pnpm/element-plus@2.13.2_vue@3.5.28_typescript@5.9.2_/node_modules/element-plus/es/utils/typescript.mjs","../../src/pagination/components/sizes.ts"],"sourcesContent":["const mutable = (val) => val;\n\nexport { mutable };\n//# sourceMappingURL=typescript.mjs.map\n","import type { ExtractPropTypes } from 'vue'\nimport type Sizes from './sizes.vue'\nimport { componentSizes } from 'element-plus'\nimport { buildProps, definePropType, mutable } from 'element-plus/es/utils/index'\n\nexport const paginationSizesProps = buildProps({\n pageSize: {\n type: Number,\n required: true,\n },\n pageSizes: {\n type: definePropType<number[]>(Array),\n default: () => mutable([10, 20, 30, 40, 50, 100] as const),\n },\n popperClass: {\n type: String,\n },\n disabled: Boolean,\n teleported: Boolean,\n size: {\n type: String,\n values: componentSizes,\n },\n appendSizeTo: String,\n} as const)\n\nexport type PaginationSizesProps = ExtractPropTypes<typeof paginationSizesProps>\n\nexport type SizesInstance = InstanceType<typeof Sizes> & unknown\n"],"names":["mutable","val","paginationSizesProps","buildProps","definePropType","componentSizes"],"mappings":";;AAAK,MAACA,IAAU,CAACC,MAAQA,GCKZC,IAAuBC,EAAW;AAAA,EAC7C,UAAU;AAAA,IACR,MAAM;AAAA,IACN,UAAU;AAAA,EAAA;AAAA,EAEZ,WAAW;AAAA,IACT,MAAMC,EAAyB,KAAK;AAAA,IACpC,SAAS,MAAMJ,EAAQ,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,GAAG,CAAU;AAAA,EAAA;AAAA,EAE3D,aAAa;AAAA,IACX,MAAM;AAAA,EAAA;AAAA,EAER,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,QAAQK;AAAA,EAAA;AAAA,EAEV,cAAc;AAChB,CAAU;","x_google_ignoreList":[0]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@silver-formily/element-plus",
3
3
  "type": "module",
4
- "version": "3.0.0",
4
+ "version": "3.0.1",
5
5
  "description": "Formily 的 Element Plus 封装",
6
6
  "author": "hezhengxu",
7
7
  "license": "MIT",
@@ -40,7 +40,7 @@
40
40
  "@formily/json-schema": "^2.0.8",
41
41
  "@formily/reactive": "^2.0.8",
42
42
  "@formily/shared": "^2.0.8",
43
- "@silver-formily/grid": "^1.0.0",
43
+ "@silver-formily/grid": "^1.0.1",
44
44
  "@silver-formily/reactive-vue": "^1",
45
45
  "@silver-formily/vue": "^2.3.1",
46
46
  "@vueuse/core": "*",
@@ -69,10 +69,10 @@
69
69
  "vite-plugin-lib-inject-css": "^2.2.2",
70
70
  "vitest": "^4.0.16",
71
71
  "vitest-browser-vue": "^2.0.2",
72
- "@silver-formily/grid": "1.0.0",
73
- "@silver-formily/reactive-vue": "1.0.0",
72
+ "@silver-formily/grid": "1.0.1",
74
73
  "@silver-formily/typescript-config": "0.0.0",
75
- "@silver-formily/vue": "2.3.1"
74
+ "@silver-formily/vue": "2.3.1",
75
+ "@silver-formily/reactive-vue": "1.0.0"
76
76
  },
77
77
  "scripts": {
78
78
  "build": "vite build",
@@ -82,6 +82,7 @@
82
82
  "test:coverage": "vitest run --coverage --browser.headless",
83
83
  "lint": "eslint .",
84
84
  "format": "eslint . --fix",
85
+ "check-types": "vue-tsc --noEmit --project tsconfig.check.json",
85
86
  "docs:dev": "pnpm --filter element-plus-docs dev",
86
87
  "docs:build": "pnpm turbo run docs:build --filter=element-plus-docs",
87
88
  "docs:preview": "pnpm --filter element-plus-docs preview"