@silver-formily/element-plus 3.0.0 → 3.0.2

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 (140) 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 +1 -1
  6. package/esm/__builtins__/shared/loading.mjs.map +1 -1
  7. package/esm/__builtins__/shared/simple-version-compare.mjs.map +1 -1
  8. package/esm/__builtins__/shared/transform-component.mjs.map +1 -1
  9. package/esm/__builtins__/shared/use-enter-submit.mjs +57 -16
  10. package/esm/__builtins__/shared/use-enter-submit.mjs.map +1 -1
  11. package/esm/__builtins__/shared/utils.mjs.map +1 -1
  12. package/esm/array-base/index.mjs +45 -42
  13. package/esm/array-base/index.mjs.map +1 -1
  14. package/esm/array-base/symbols.mjs.map +1 -1
  15. package/esm/array-base/utils.mjs +36 -31
  16. package/esm/array-base/utils.mjs.map +1 -1
  17. package/esm/array-cards/index.mjs +34 -32
  18. package/esm/array-cards/index.mjs.map +1 -1
  19. package/esm/array-collapse/index.mjs +29 -28
  20. package/esm/array-collapse/index.mjs.map +1 -1
  21. package/esm/array-collapse/utils.mjs +8 -2
  22. package/esm/array-collapse/utils.mjs.map +1 -1
  23. package/esm/array-items/index.mjs +34 -31
  24. package/esm/array-items/index.mjs.map +1 -1
  25. package/esm/array-list-tabs/index.mjs +51 -50
  26. package/esm/array-list-tabs/index.mjs.map +1 -1
  27. package/esm/array-list-tabs/utils.mjs +11 -5
  28. package/esm/array-list-tabs/utils.mjs.map +1 -1
  29. package/esm/array-table/index.mjs +47 -46
  30. package/esm/array-table/index.mjs.map +1 -1
  31. package/esm/array-table/utils.mjs +18 -12
  32. package/esm/array-table/utils.mjs.map +1 -1
  33. package/esm/array-tabs/index.mjs +27 -27
  34. package/esm/array-tabs/index.mjs.map +1 -1
  35. package/esm/autocomplete/index.mjs +21 -18
  36. package/esm/autocomplete/index.mjs.map +1 -1
  37. package/esm/cascader/index.mjs +18 -15
  38. package/esm/cascader/index.mjs.map +1 -1
  39. package/esm/checkbox/index.mjs +19 -16
  40. package/esm/checkbox/index.mjs.map +1 -1
  41. package/esm/color-picker/index.mjs +9 -6
  42. package/esm/color-picker/index.mjs.map +1 -1
  43. package/esm/color-picker-panel/index.mjs +9 -6
  44. package/esm/color-picker-panel/index.mjs.map +1 -1
  45. package/esm/date-picker/index.mjs +14 -11
  46. package/esm/date-picker/index.mjs.map +1 -1
  47. package/esm/date-picker/utils.mjs.map +1 -1
  48. package/esm/date-picker-panel/index.mjs +14 -11
  49. package/esm/date-picker-panel/index.mjs.map +1 -1
  50. package/esm/editable/index.mjs +34 -32
  51. package/esm/editable/index.mjs.map +1 -1
  52. package/esm/form/form.mjs +6 -6
  53. package/esm/form/form.mjs.map +1 -1
  54. package/esm/form-button-group/index.mjs +17 -14
  55. package/esm/form-button-group/index.mjs.map +1 -1
  56. package/esm/form-button-group/utils.mjs +8 -2
  57. package/esm/form-button-group/utils.mjs.map +1 -1
  58. package/esm/form-collapse/index.mjs +20 -18
  59. package/esm/form-collapse/index.mjs.map +1 -1
  60. package/esm/form-collapse/utils.mjs.map +1 -1
  61. package/esm/form-dialog/index.d.ts +1 -1
  62. package/esm/form-dialog/index.mjs +22 -22
  63. package/esm/form-dialog/index.mjs.map +1 -1
  64. package/esm/form-dialog/types.d.ts +13 -5
  65. package/esm/form-drawer/index.d.ts +1 -1
  66. package/esm/form-drawer/index.mjs +21 -21
  67. package/esm/form-drawer/index.mjs.map +1 -1
  68. package/esm/form-drawer/types.d.ts +13 -5
  69. package/esm/form-grid/hooks.mjs.map +1 -1
  70. package/esm/form-grid/index.mjs +20 -18
  71. package/esm/form-grid/index.mjs.map +1 -1
  72. package/esm/form-item/index.mjs +54 -53
  73. package/esm/form-item/index.mjs.map +1 -1
  74. package/esm/form-item/utils.mjs.map +1 -1
  75. package/esm/form-layout/form-layout.mjs +13 -10
  76. package/esm/form-layout/form-layout.mjs.map +1 -1
  77. package/esm/form-layout/utils.mjs.map +1 -1
  78. package/esm/form-step/index.mjs +29 -27
  79. package/esm/form-step/index.mjs.map +1 -1
  80. package/esm/form-step/utils.mjs.map +1 -1
  81. package/esm/form-tab/hooks.mjs.map +1 -1
  82. package/esm/form-tab/index.mjs +22 -21
  83. package/esm/form-tab/index.mjs.map +1 -1
  84. package/esm/form-tab/utils.mjs.map +1 -1
  85. package/esm/index.mjs +72 -72
  86. package/esm/input/index.mjs +25 -22
  87. package/esm/input/index.mjs.map +1 -1
  88. package/esm/input-number/index.mjs +11 -8
  89. package/esm/input-number/index.mjs.map +1 -1
  90. package/esm/input-tag/index.mjs +16 -13
  91. package/esm/input-tag/index.mjs.map +1 -1
  92. package/esm/mention/index.mjs +20 -17
  93. package/esm/mention/index.mjs.map +1 -1
  94. package/esm/pagination/components/jumper.mjs.map +1 -1
  95. package/esm/pagination/components/next.mjs.map +1 -1
  96. package/esm/pagination/components/pager.mjs.map +1 -1
  97. package/esm/pagination/components/prev.mjs.map +1 -1
  98. package/esm/pagination/components/total.mjs.map +1 -1
  99. package/esm/pagination/pagination.mjs.map +1 -1
  100. package/esm/password/index.mjs.map +1 -1
  101. package/esm/preview-text/index.mjs +30 -27
  102. package/esm/preview-text/index.mjs.map +1 -1
  103. package/esm/preview-text/utils.mjs.map +1 -1
  104. package/esm/query-form/default-components.mjs.map +1 -1
  105. package/esm/query-form/hooks.mjs.map +1 -1
  106. package/esm/query-form/index.mjs +142 -140
  107. package/esm/query-form/index.mjs.map +1 -1
  108. package/esm/query-form-item/index.mjs +17 -15
  109. package/esm/query-form-item/index.mjs.map +1 -1
  110. package/esm/radio/index.mjs +28 -25
  111. package/esm/radio/index.mjs.map +1 -1
  112. package/esm/rate/index.mjs +13 -10
  113. package/esm/rate/index.mjs.map +1 -1
  114. package/esm/reset/index.mjs.map +1 -1
  115. package/esm/segmented/index.mjs +15 -12
  116. package/esm/segmented/index.mjs.map +1 -1
  117. package/esm/select/index.mjs +22 -19
  118. package/esm/select/index.mjs.map +1 -1
  119. package/esm/select-table/index.mjs +15 -12
  120. package/esm/select-table/index.mjs.map +1 -1
  121. package/esm/shared/overlay-elements.mjs.map +1 -1
  122. package/esm/slider/index.mjs +13 -10
  123. package/esm/slider/index.mjs.map +1 -1
  124. package/esm/submit/index.mjs.map +1 -1
  125. package/esm/switch/index.mjs.map +1 -1
  126. package/esm/time-picker/index.mjs +9 -6
  127. package/esm/time-picker/index.mjs.map +1 -1
  128. package/esm/time-select/index.d.ts +8 -8
  129. package/esm/time-select/index.mjs +9 -6
  130. package/esm/time-select/index.mjs.map +1 -1
  131. package/esm/transfer/index.mjs.map +1 -1
  132. package/esm/tree/index.mjs +31 -28
  133. package/esm/tree/index.mjs.map +1 -1
  134. package/esm/tree/utils.mjs.map +1 -1
  135. package/esm/tree-select/index.mjs +17 -14
  136. package/esm/tree-select/index.mjs.map +1 -1
  137. package/esm/upload/index.mjs +36 -37
  138. package/esm/upload/index.mjs.map +1 -1
  139. package/esm/vendor/sizes.mjs.map +1 -1
  140. package/package.json +12 -11
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../src/select-table/select-table.vue","../../src/select-table/index.ts"],"sourcesContent":["<script setup lang=\"ts\">\r\nimport type { TableInstance } from 'element-plus'\r\nimport type { ISelectTableProps } from './types'\r\nimport { isEqual, isFn, isValid } from '@formily/shared'\r\nimport { useField } from '@silver-formily/vue'\r\nimport {\r\n ElLink,\r\n ElRadio,\r\n ElRadioGroup,\r\n ElTable,\r\n ElTableColumn,\r\n useAttrs,\r\n version,\r\n vLoading,\r\n} from 'element-plus'\r\nimport { differenceWith, remove, uniq, uniqWith, xor } from 'lodash-es'\r\nimport { computed, nextTick, ref, watch } from 'vue'\r\nimport { lt, stylePrefix } from '../__builtins__'\r\n\r\ndefineOptions({\r\n name: 'FSelectTable',\r\n inheritAttrs: false,\r\n})\r\n\r\nconst props = withDefaults(defineProps<ISelectTableProps>(), {\r\n columns: () => [],\r\n mode: 'multiple',\r\n dataSource: () => [],\r\n optionAsValue: false,\r\n valueType: 'all',\r\n loading: false,\r\n clickRowToSelect: true,\r\n showAlertToolbar: true,\r\n ignoreSelectable: true,\r\n})\r\n\r\nconst emit = defineEmits(['update:modelValue'])\r\n\r\nconst elTableProps = useAttrs()\r\nconst field = useField()\r\n\r\nfunction compatibleRadioValue(key: string) {\r\n return lt(version, '2.6.0') ? { label: key } : { value: key }\r\n}\r\n\r\nconst elTableRef = ref<TableInstance>()\r\nconst rowKey = props.rowKey\r\nfunction getInitialSelectedList() {\r\n if (props.mode === 'multiple') {\r\n return props.modelValue?.map((item) => {\r\n if (!props.optionAsValue) {\r\n return {\r\n [rowKey]: item,\r\n }\r\n }\r\n return item\r\n }) ?? []\r\n }\r\n else {\r\n return props.optionAsValue ? [props.modelValue] : [{ [rowKey]: props.modelValue }]\r\n }\r\n}\r\nconst initialSelectedList = getInitialSelectedList()\r\nconst selectedFlatDataSource = ref(initialSelectedList)\r\n// 为了获取移除的项而缓存的当前页面的前一次选择。由于element-plus没有获取移除项的方法,需要通过这种方式移除field中移除的项\r\nlet prevSelection = []\r\n\r\nconst radioSelectedKey = ref()\r\n\r\nconst currentSelectLength = computed(() => {\r\n if (props.mode === 'multiple') {\r\n return Array.isArray(props.modelValue) ? props.modelValue.length : 0\r\n }\r\n else {\r\n return isValid(radioSelectedKey.value) ? 1 : 0\r\n }\r\n})\r\n\r\nwatch(\r\n () => props.dataSource,\r\n async () => {\r\n const selectedKeys = uniq(\r\n selectedFlatDataSource.value.map(item => item[rowKey]),\r\n )\r\n await nextTick()\r\n for (const item of props.dataSource) {\r\n if (selectedKeys.includes(item[rowKey])) {\r\n if (props.mode === 'multiple') {\r\n elTableRef.value?.toggleRowSelection(item, true, props.ignoreSelectable)\r\n }\r\n else {\r\n elTableRef.value?.setCurrentRow(item)\r\n onRadioClick(item)\r\n }\r\n }\r\n await nextTick()\r\n prevSelection = elTableRef.value?.getSelectionRows()\r\n }\r\n },\r\n { immediate: true },\r\n)\r\n\r\nwatch(\r\n () => [props.modelValue, props.loading],\r\n async ([value, loading]) => {\r\n if (loading) {\r\n return\r\n }\r\n if (props.mode === 'single') {\r\n radioSelectedKey.value = props.optionAsValue ? value[rowKey] : value\r\n }\r\n else {\r\n await nextTick()\r\n const currentDisplayDataKeys = elTableRef.value\r\n ?.getSelectionRows()\r\n .map(item => item[rowKey])\r\n const valueKeys = props.optionAsValue\r\n ? value?.map(item => item[rowKey])\r\n : value ?? []\r\n selectedFlatDataSource.value = selectedFlatDataSource.value.filter(\r\n item => valueKeys.includes(item[rowKey]),\r\n )\r\n if (isEqual(valueKeys, currentDisplayDataKeys)) {\r\n return\r\n }\r\n const diffItems = xor(valueKeys, currentDisplayDataKeys)\r\n for (const tableItem of props.dataSource) {\r\n if (diffItems.includes(tableItem[rowKey])) {\r\n const shouldSelect = valueKeys.includes(tableItem[rowKey])\r\n elTableRef.value.toggleRowSelection(tableItem, shouldSelect, props.ignoreSelectable)\r\n }\r\n }\r\n }\r\n },\r\n {\r\n immediate: true,\r\n },\r\n)\r\n\r\nfunction onSelect(newSelection: Record<string, any>[]) {\r\n /* istanbul ignore if -- @preserve */\r\n if (!rowKey) {\r\n throw new Error('rowKey is required')\r\n }\r\n\r\n const removedItemList\r\n = prevSelection.length > newSelection.length\r\n ? differenceWith(\r\n prevSelection,\r\n newSelection,\r\n (itemPrev, itemNext) => {\r\n return itemPrev[rowKey] === itemNext[rowKey]\r\n },\r\n )\r\n : []\r\n prevSelection = [...newSelection]\r\n selectedFlatDataSource.value = uniqWith(\r\n [...selectedFlatDataSource.value, ...newSelection],\r\n (itemPrev, itemNext) => {\r\n return itemPrev[rowKey] === itemNext[rowKey]\r\n },\r\n )\r\n if (removedItemList.length > 0) {\r\n const removedKeys = uniq(removedItemList.map(item => item[rowKey]))\r\n remove(selectedFlatDataSource.value, item =>\r\n removedKeys.includes(item[rowKey]))\r\n }\r\n\r\n if (props.optionAsValue) {\r\n emit('update:modelValue', selectedFlatDataSource.value)\r\n }\r\n else {\r\n const selectedKeys = selectedFlatDataSource.value.map(\r\n item => item[rowKey],\r\n )\r\n emit('update:modelValue', selectedKeys)\r\n }\r\n}\r\n\r\nfunction onRadioClick(item) {\r\n radioSelectedKey.value = item[rowKey]\r\n if (props.optionAsValue) {\r\n emit('update:modelValue', item)\r\n }\r\n else {\r\n emit('update:modelValue', item[rowKey])\r\n }\r\n}\r\n\r\nfunction onRowClick(row: Record<string, any>, _, event: Event) {\r\n if (!props.clickRowToSelect)\r\n return\r\n\r\n if (props.mode === 'multiple') {\r\n const checkboxDOM = (event.target as Element)\r\n .closest('tr')\r\n .querySelector('input[type=\"checkbox\"]')\r\n if (checkboxDOM instanceof HTMLElement) {\r\n checkboxDOM.click()\r\n }\r\n }\r\n else {\r\n const radioDOM = (event.target as Element)\r\n .closest('tr')\r\n .querySelector('input[type=\"radio\"]')\r\n if (radioDOM instanceof HTMLElement) {\r\n radioDOM.click()\r\n }\r\n }\r\n}\r\n\r\nfunction onClearSelectionClick() {\r\n if (props.mode === 'multiple') {\r\n emit('update:modelValue', [])\r\n selectedFlatDataSource.value = []\r\n }\r\n else {\r\n radioSelectedKey.value = null\r\n emit('update:modelValue', null)\r\n }\r\n}\r\n\r\nfunction selectable(row: Record<string, any>, index: number) {\r\n if (props.selectable && isFn(props.selectable)) {\r\n return props.selectable(row, index, field.value)\r\n }\r\n return true\r\n}\r\n</script>\r\n\r\n<template>\r\n <div :class=\"`${stylePrefix}-select-table`\">\r\n <div\r\n v-if=\"currentSelectLength > 0 && props.showAlertToolbar\"\r\n :class=\"`${stylePrefix}-select-table-alert-container`\"\r\n >\r\n <span>已选择 {{ currentSelectLength }} 项</span>\r\n <ElLink\r\n type=\"primary\"\r\n :underline=\"lt(version, '2.9.9') ? false : 'never'\"\r\n style=\"margin-left: 8px;\"\r\n @click=\"onClearSelectionClick\"\r\n >\r\n 取消选择\r\n </ElLink>\r\n </div>\r\n <ElTable\r\n ref=\"elTableRef\"\r\n v-loading=\"props.loading\"\r\n v-bind=\"elTableProps\"\r\n :row-key=\"rowKey\"\r\n :row-class-name=\"props.clickRowToSelect ? `--click-row-select` : ''\"\r\n :data=\"props.dataSource\"\r\n :highlight-current-row=\"props.mode === 'single'\"\r\n @select=\"onSelect\"\r\n @select-all=\"onSelect\"\r\n @row-click=\"onRowClick\"\r\n >\r\n <ElTableColumn\r\n v-if=\"props.mode === 'multiple'\"\r\n type=\"selection\"\r\n :selectable=\"selectable\"\r\n />\r\n <ElTableColumn\r\n v-else\r\n width=\"46\"\r\n >\r\n <template #default=\"{ row }\">\r\n <ElRadioGroup v-model=\"radioSelectedKey\" style=\"width: 100%;\">\r\n <ElRadio\r\n v-bind=\"compatibleRadioValue(row[rowKey])\"\r\n @change=\"() => onRadioClick(row)\"\r\n >\r\n &nbsp;\r\n </ElRadio>\r\n </ElRadioGroup>\r\n </template>\r\n </ElTableColumn>\r\n <template v-if=\"props.columns.length === 0\">\r\n <slot />\r\n </template>\r\n <template v-else>\r\n <ElTableColumn\r\n v-for=\"colItem of props.columns\"\r\n v-bind=\"colItem\"\r\n :key=\"colItem.prop || colItem.type\"\r\n />\r\n </template>\r\n </ElTable>\r\n </div>\r\n</template>\r\n","import { connect, mapProps } from '@silver-formily/vue'\r\nimport InnerSelectTable from './select-table.vue'\r\nimport './style.scss'\r\n\r\nconst SelectTable = connect<typeof InnerSelectTable>(\n InnerSelectTable,\n mapProps({ dataSource: 'dataSource', loading: 'loading' }),\r\n)\r\n\r\nexport { SelectTable }\r\n\r\nexport default SelectTable\r\n"],"names":["props","__props","emit","__emit","elTableProps","useAttrs","field","useField","compatibleRadioValue","key","lt","version","elTableRef","ref","rowKey","getInitialSelectedList","item","initialSelectedList","selectedFlatDataSource","prevSelection","radioSelectedKey","currentSelectLength","computed","isValid","watch","selectedKeys","uniq","nextTick","onRadioClick","value","loading","currentDisplayDataKeys","valueKeys","isEqual","diffItems","xor","tableItem","shouldSelect","onSelect","newSelection","removedItemList","differenceWith","itemPrev","itemNext","uniqWith","removedKeys","remove","onRowClick","row","_","event","checkboxDOM","radioDOM","onClearSelectionClick","selectable","index","isFn","_createElementBlock","_unref","stylePrefix","_createElementVNode","_toDisplayString","_createVNode","ElLink","_cache","_withDirectives","_openBlock","_createBlock","_mergeProps","ElTableColumn","_withCtx","ElRadioGroup","$event","_renderSlot","_ctx","_Fragment","_renderList","colItem","vLoading","SelectTable","connect","InnerSelectTable","mapProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,UAAMA,IAAQC,GAYRC,IAAOC,GAEPC,IAAeC,GAAA,GACfC,IAAQC,EAAA;AAEd,aAASC,EAAqBC,GAAa;AACzC,aAAOC,EAAGC,GAAS,OAAO,IAAI,EAAE,OAAOF,EAAA,IAAQ,EAAE,OAAOA,EAAA;AAAA,IAC1D;AAEA,UAAMG,IAAaC,EAAA,GACbC,IAASd,EAAM;AACrB,aAASe,IAAyB;AAChC,aAAIf,EAAM,SAAS,aACVA,EAAM,YAAY,IAAI,CAACgB,MACvBhB,EAAM,gBAKJgB,IAJE;AAAA,QACL,CAACF,CAAM,GAAGE;AAAA,MAAA,CAIf,KAAK,CAAA,IAGChB,EAAM,gBAAgB,CAACA,EAAM,UAAU,IAAI,CAAC,EAAE,CAACc,CAAM,GAAGd,EAAM,YAAY;AAAA,IAErF;AACA,UAAMiB,IAAsBF,EAAA,GACtBG,IAAyBL,EAAII,CAAmB;AAEtD,QAAIE,IAAgB,CAAA;AAEpB,UAAMC,IAAmBP,EAAA,GAEnBQ,IAAsBC,EAAS,MAC/BtB,EAAM,SAAS,aACV,MAAM,QAAQA,EAAM,UAAU,IAAIA,EAAM,WAAW,SAAS,IAG5DuB,GAAQH,EAAiB,KAAK,IAAI,IAAI,CAEhD;AAED,IAAAI;AAAA,MACE,MAAMxB,EAAM;AAAA,MACZ,YAAY;AACV,cAAMyB,IAAeC;AAAA,UACnBR,EAAuB,MAAM,IA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O;AAAA,MAAA;;;ICpPxB+E,KAAcC;AAAA,EAClBC;AAAAA,EACAC,EAAS,EAAE,YAAY,cAAc,SAAS,WAAW;AAC3D;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../src/select-table/select-table.vue","../../src/select-table/index.ts"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { TableInstance } from 'element-plus'\nimport type { ISelectTableProps } from './types'\nimport { isEqual, isFn, isValid } from '@formily/shared'\nimport { useField } from '@silver-formily/vue'\nimport {\n ElLink,\n ElRadio,\n ElRadioGroup,\n ElTable,\n ElTableColumn,\n useAttrs,\n version,\n vLoading,\n} from 'element-plus'\nimport { differenceWith, remove, uniq, uniqWith, xor } from 'lodash-es'\nimport { computed, nextTick, ref, watch } from 'vue'\nimport { lt, stylePrefix } from '../__builtins__'\n\ndefineOptions({\n name: 'FSelectTable',\n inheritAttrs: false,\n})\n\nconst props = withDefaults(defineProps<ISelectTableProps>(), {\n columns: () => [],\n mode: 'multiple',\n dataSource: () => [],\n optionAsValue: false,\n valueType: 'all',\n loading: false,\n clickRowToSelect: true,\n showAlertToolbar: true,\n ignoreSelectable: true,\n})\n\nconst emit = defineEmits(['update:modelValue'])\n\nconst elTableProps = useAttrs()\nconst field = useField()\n\nfunction compatibleRadioValue(key: string) {\n return lt(version, '2.6.0') ? { label: key } : { value: key }\n}\n\nconst elTableRef = ref<TableInstance>()\nconst rowKey = props.rowKey\nfunction getInitialSelectedList() {\n if (props.mode === 'multiple') {\n return props.modelValue?.map((item) => {\n if (!props.optionAsValue) {\n return {\n [rowKey]: item,\n }\n }\n return item\n }) ?? []\n }\n else {\n return props.optionAsValue ? [props.modelValue] : [{ [rowKey]: props.modelValue }]\n }\n}\nconst initialSelectedList = getInitialSelectedList()\nconst selectedFlatDataSource = ref(initialSelectedList)\n// 为了获取移除的项而缓存的当前页面的前一次选择。由于element-plus没有获取移除项的方法,需要通过这种方式移除field中移除的项\nlet prevSelection = []\n\nconst radioSelectedKey = ref()\n\nconst currentSelectLength = computed(() => {\n if (props.mode === 'multiple') {\n return Array.isArray(props.modelValue) ? props.modelValue.length : 0\n }\n else {\n return isValid(radioSelectedKey.value) ? 1 : 0\n }\n})\n\nwatch(\n () => props.dataSource,\n async () => {\n const selectedKeys = uniq(\n selectedFlatDataSource.value.map(item => item[rowKey]),\n )\n await nextTick()\n for (const item of props.dataSource) {\n if (selectedKeys.includes(item[rowKey])) {\n if (props.mode === 'multiple') {\n elTableRef.value?.toggleRowSelection(item, true, props.ignoreSelectable)\n }\n else {\n elTableRef.value?.setCurrentRow(item)\n onRadioClick(item)\n }\n }\n await nextTick()\n prevSelection = elTableRef.value?.getSelectionRows()\n }\n },\n { immediate: true },\n)\n\nwatch(\n () => [props.modelValue, props.loading],\n async ([value, loading]) => {\n if (loading) {\n return\n }\n if (props.mode === 'single') {\n radioSelectedKey.value = props.optionAsValue ? value[rowKey] : value\n }\n else {\n await nextTick()\n const currentDisplayDataKeys = elTableRef.value\n ?.getSelectionRows()\n .map(item => item[rowKey])\n const valueKeys = props.optionAsValue\n ? value?.map(item => item[rowKey])\n : value ?? []\n selectedFlatDataSource.value = selectedFlatDataSource.value.filter(\n item => valueKeys.includes(item[rowKey]),\n )\n if (isEqual(valueKeys, currentDisplayDataKeys)) {\n return\n }\n const diffItems = xor(valueKeys, currentDisplayDataKeys)\n for (const tableItem of props.dataSource) {\n if (diffItems.includes(tableItem[rowKey])) {\n const shouldSelect = valueKeys.includes(tableItem[rowKey])\n elTableRef.value.toggleRowSelection(tableItem, shouldSelect, props.ignoreSelectable)\n }\n }\n }\n },\n {\n immediate: true,\n },\n)\n\nfunction onSelect(newSelection: Record<string, any>[]) {\n /* istanbul ignore if -- @preserve */\n if (!rowKey) {\n throw new Error('rowKey is required')\n }\n\n const removedItemList\n = prevSelection.length > newSelection.length\n ? differenceWith(\n prevSelection,\n newSelection,\n (itemPrev, itemNext) => {\n return itemPrev[rowKey] === itemNext[rowKey]\n },\n )\n : []\n prevSelection = [...newSelection]\n selectedFlatDataSource.value = uniqWith(\n [...selectedFlatDataSource.value, ...newSelection],\n (itemPrev, itemNext) => {\n return itemPrev[rowKey] === itemNext[rowKey]\n },\n )\n if (removedItemList.length > 0) {\n const removedKeys = uniq(removedItemList.map(item => item[rowKey]))\n remove(selectedFlatDataSource.value, item =>\n removedKeys.includes(item[rowKey]))\n }\n\n if (props.optionAsValue) {\n emit('update:modelValue', selectedFlatDataSource.value)\n }\n else {\n const selectedKeys = selectedFlatDataSource.value.map(\n item => item[rowKey],\n )\n emit('update:modelValue', selectedKeys)\n }\n}\n\nfunction onRadioClick(item) {\n radioSelectedKey.value = item[rowKey]\n if (props.optionAsValue) {\n emit('update:modelValue', item)\n }\n else {\n emit('update:modelValue', item[rowKey])\n }\n}\n\nfunction onRowClick(row: Record<string, any>, _, event: Event) {\n if (!props.clickRowToSelect)\n return\n\n if (props.mode === 'multiple') {\n const checkboxDOM = (event.target as Element)\n .closest('tr')\n .querySelector('input[type=\"checkbox\"]')\n if (checkboxDOM instanceof HTMLElement) {\n checkboxDOM.click()\n }\n }\n else {\n const radioDOM = (event.target as Element)\n .closest('tr')\n .querySelector('input[type=\"radio\"]')\n if (radioDOM instanceof HTMLElement) {\n radioDOM.click()\n }\n }\n}\n\nfunction onClearSelectionClick() {\n if (props.mode === 'multiple') {\n emit('update:modelValue', [])\n selectedFlatDataSource.value = []\n }\n else {\n radioSelectedKey.value = null\n emit('update:modelValue', null)\n }\n}\n\nfunction selectable(row: Record<string, any>, index: number) {\n if (props.selectable && isFn(props.selectable)) {\n return props.selectable(row, index, field.value)\n }\n return true\n}\n</script>\n\n<template>\n <div :class=\"`${stylePrefix}-select-table`\">\n <div\n v-if=\"currentSelectLength > 0 && props.showAlertToolbar\"\n :class=\"`${stylePrefix}-select-table-alert-container`\"\n >\n <span>已选择 {{ currentSelectLength }} 项</span>\n <ElLink\n type=\"primary\"\n :underline=\"lt(version, '2.9.9') ? false : 'never'\"\n style=\"margin-left: 8px;\"\n @click=\"onClearSelectionClick\"\n >\n 取消选择\n </ElLink>\n </div>\n <ElTable\n ref=\"elTableRef\"\n v-loading=\"props.loading\"\n v-bind=\"elTableProps\"\n :row-key=\"rowKey\"\n :row-class-name=\"props.clickRowToSelect ? `--click-row-select` : ''\"\n :data=\"props.dataSource\"\n :highlight-current-row=\"props.mode === 'single'\"\n @select=\"onSelect\"\n @select-all=\"onSelect\"\n @row-click=\"onRowClick\"\n >\n <ElTableColumn\n v-if=\"props.mode === 'multiple'\"\n type=\"selection\"\n :selectable=\"selectable\"\n />\n <ElTableColumn\n v-else\n width=\"46\"\n >\n <template #default=\"{ row }\">\n <ElRadioGroup v-model=\"radioSelectedKey\" style=\"width: 100%;\">\n <ElRadio\n v-bind=\"compatibleRadioValue(row[rowKey])\"\n @change=\"() => onRadioClick(row)\"\n >\n &nbsp;\n </ElRadio>\n </ElRadioGroup>\n </template>\n </ElTableColumn>\n <template v-if=\"props.columns.length === 0\">\n <slot />\n </template>\n <template v-else>\n <ElTableColumn\n v-for=\"colItem of props.columns\"\n v-bind=\"colItem\"\n :key=\"colItem.prop || colItem.type\"\n />\n </template>\n </ElTable>\n </div>\n</template>\n","import { connect, mapProps } from '@silver-formily/vue'\r\nimport InnerSelectTable from './select-table.vue'\r\nimport './style.scss'\r\n\r\nconst SelectTable = connect<typeof InnerSelectTable>(\n InnerSelectTable,\n mapProps({ dataSource: 'dataSource', loading: 'loading' }),\r\n)\r\n\r\nexport { SelectTable }\r\n\r\nexport default SelectTable\r\n"],"names":["props","__props","emit","__emit","elTableProps","useAttrs","field","useField","compatibleRadioValue","key","lt","version","elTableRef","ref","rowKey","getInitialSelectedList","item","initialSelectedList","selectedFlatDataSource","prevSelection","radioSelectedKey","currentSelectLength","computed","isValid","watch","selectedKeys","uniq","nextTick","onRadioClick","value","loading","currentDisplayDataKeys","valueKeys","isEqual","diffItems","xor","tableItem","shouldSelect","onSelect","newSelection","removedItemList","differenceWith","itemPrev","itemNext","uniqWith","removedKeys","remove","onRowClick","row","_","event","checkboxDOM","radioDOM","onClearSelectionClick","selectable","index","isFn","_createElementBlock","_unref","stylePrefix","_createElementVNode","_toDisplayString","_createVNode","ElLink","_cache","_withDirectives","_openBlock","_createBlock","_mergeProps","ElTableColumn","_withCtx","ElRadioGroup","$event","_renderSlot","_ctx","_Fragment","_renderList","colItem","vLoading","SelectTable","connect","InnerSelectTable","mapProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,UAAMA,IAAQC,GAYRC,IAAOC,GAEPC,IAAeC,GAAA,GACfC,IAAQC,EAAA;AAEd,aAASC,EAAqBC,GAAa;AACzC,aAAOC,EAAGC,GAAS,OAAO,IAAI,EAAE,OAAOF,EAAA,IAAQ,EAAE,OAAOA,EAAA;AAAA,IAC1D;AAEA,UAAMG,IAAaC,EAAA,GACbC,IAASd,EAAM;AACrB,aAASe,IAAyB;AAChC,aAAIf,EAAM,SAAS,aACVA,EAAM,YAAY,IAAI,CAACgB,MACvBhB,EAAM,gBAKJgB,IAJE;AAAA,QACL,CAACF,CAAM,GAAGE;AAAA,MAAA,CAIf,KAAK,CAAA,IAGChB,EAAM,gBAAgB,CAACA,EAAM,UAAU,IAAI,CAAC,EAAE,CAACc,CAAM,GAAGd,EAAM,YAAY;AAAA,IAErF;AACA,UAAMiB,IAAsBF,EAAA,GACtBG,IAAyBL,EAAII,CAAmB;AAEtD,QAAIE,IAAgB,CAAA;AAEpB,UAAMC,IAAmBP,EAAA,GAEnBQ,IAAsBC,EAAS,MAC/BtB,EAAM,SAAS,aACV,MAAM,QAAQA,EAAM,UAAU,IAAIA,EAAM,WAAW,SAAS,IAG5DuB,GAAQH,EAAiB,KAAK,IAAI,IAAI,CAEhD;AAED,IAAAI;AAAA,MACE,MAAMxB,EAAM;AAAA,MACZ,YAAY;AACV,cAAMyB,IAAeC;AAAA,UACnBR,EAAuB,MAAM,IAAI,CAAAF,MAAQA,EAAKF,CAAM,CAAC;AAAA,QAAA;AAEvD,cAAMa,EAAA;AACN,mBAAWX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Ac,SAAS,WAAW;AAC3D;"}
@@ -1 +1 @@
1
- {"version":3,"file":"overlay-elements.mjs","sources":["../../src/shared/overlay-elements.ts"],"sourcesContent":["import type { ComponentPublicInstance } from 'vue'\r\n\r\nexport type DialogLikeInstance = ComponentPublicInstance<{ dialogContentRef?: ComponentPublicInstance | null }> | null\r\n\r\ntype OverlayLikeInstance = ComponentPublicInstance & {\r\n exposed?: Record<string, any>\r\n $refs?: Record<string, any>\r\n dialogContentRef?: ComponentPublicInstance | null\r\n}\r\n\r\nfunction toHTMLElement(target: unknown): HTMLElement | null {\r\n if (target instanceof HTMLElement)\r\n return target\r\n\r\n const element = (target as { $el?: unknown } | null | undefined)?.$el\r\n return element instanceof HTMLElement ? element : null\r\n}\r\n\r\nexport function resolveDialogElement(instance: DialogLikeInstance): HTMLElement | null {\r\n const vm = instance as OverlayLikeInstance | null\r\n return toHTMLElement(vm?.dialogContentRef)\r\n ?? toHTMLElement(vm?.exposed?.dialogContentRef)\r\n ?? toHTMLElement(vm)\r\n}\r\n\r\nexport function resolveDrawerElement(instance: ComponentPublicInstance | null): HTMLElement | null {\r\n const vm = instance as OverlayLikeInstance | null\r\n return toHTMLElement(vm?.exposed?.drawerRef)\r\n ?? toHTMLElement(vm?.$refs?.drawerRef)\r\n ?? toHTMLElement(vm)\r\n}\r\n"],"names":["toHTMLElement","target","element","resolveDialogElement","instance","vm","resolveDrawerElement"],"mappings":"AAUA,SAASA,EAAcC,GAAqC;AAC1D,MAAIA,aAAkB;AACpB,WAAOA;AAET,QAAMC,IAAWD,GAAiD;AAClE,SAAOC,aAAmB,cAAcA,IAAU;AACpD;AAEO,SAASC,EAAqBC,GAAkD;AACrF,QAAMC,IAAKD;AACX,SAAOJ,EAAcK,GAAI,gBAAgB,KACpCL,EAAcK,GAAI,SAAS,gBAAgB,KAC3CL,EAAcK,CAAE;AACvB;AAEO,SAASC,EAAqBF,GAA8D;AACjG,QAAMC,IAAKD;AACX,SAAOJ,EAAcK,GAAI,SAAS,SAAS,KACtCL,EAAcK,GAAI,OAAO,SAAS,KAClCL,EAAcK,CAAE;AACvB;"}
1
+ {"version":3,"file":"overlay-elements.mjs","sources":["../../src/shared/overlay-elements.ts"],"sourcesContent":["import type { ComponentPublicInstance } from 'vue'\n\nexport type DialogLikeInstance = ComponentPublicInstance<{ dialogContentRef?: ComponentPublicInstance | null }> | null\n\ntype OverlayLikeInstance = ComponentPublicInstance & {\n exposed?: Record<string, any>\n $refs?: Record<string, any>\n dialogContentRef?: ComponentPublicInstance | null\n}\n\nfunction toHTMLElement(target: unknown): HTMLElement | null {\n if (target instanceof HTMLElement)\n return target\n\n const element = (target as { $el?: unknown } | null | undefined)?.$el\n return element instanceof HTMLElement ? element : null\n}\n\nexport function resolveDialogElement(instance: DialogLikeInstance): HTMLElement | null {\n const vm = instance as OverlayLikeInstance | null\n return toHTMLElement(vm?.dialogContentRef)\n ?? toHTMLElement(vm?.exposed?.dialogContentRef)\n ?? toHTMLElement(vm)\n}\n\nexport function resolveDrawerElement(instance: ComponentPublicInstance | null): HTMLElement | null {\n const vm = instance as OverlayLikeInstance | null\n return toHTMLElement(vm?.exposed?.drawerRef)\n ?? toHTMLElement(vm?.$refs?.drawerRef)\n ?? toHTMLElement(vm)\n}\n"],"names":["toHTMLElement","target","element","resolveDialogElement","instance","vm","resolveDrawerElement"],"mappings":"AAUA,SAASA,EAAcC,GAAqC;AAC1D,MAAIA,aAAkB;AACpB,WAAOA;AAET,QAAMC,IAAWD,GAAiD;AAClE,SAAOC,aAAmB,cAAcA,IAAU;AACpD;AAEO,SAASC,EAAqBC,GAAkD;AACrF,QAAMC,IAAKD;AACX,SAAOJ,EAAcK,GAAI,gBAAgB,KACpCL,EAAcK,GAAI,SAAS,gBAAgB,KAC3CL,EAAcK,CAAE;AACvB;AAEO,SAASC,EAAqBF,GAA8D;AACjG,QAAMC,IAAKD;AACX,SAAOJ,EAAcK,GAAI,SAAS,SAAS,KACtCL,EAAcK,GAAI,OAAO,SAAS,KAClCL,EAAcK,CAAE;AACvB;"}
@@ -1,14 +1,17 @@
1
- import { connect as r, mapProps as e } from "@silver-formily/vue";
2
- import { ElSlider as o } from "element-plus";
3
- import { PreviewText as t } from "../preview-text/index.mjs";
4
- import { mapReadPretty as m } from "../__builtins__/shared/transform-component.mjs";
5
- const l = r(
6
- o,
7
- e({ readOnly: "readonly", disabled: !0 }),
8
- m(t.Input)
1
+ import { connect as r, mapProps as o } from "@silver-formily/vue";
2
+ import { ElSlider as t } from "element-plus";
3
+ import "@silver-formily/reactive-vue";
4
+ import "@vueuse/core";
5
+ import "vue";
6
+ import { mapReadPretty as e } from "../__builtins__/shared/transform-component.mjs";
7
+ import { PreviewText as m } from "../preview-text/index.mjs";
8
+ const s = r(
9
+ t,
10
+ o({ readOnly: "readonly", disabled: !0 }),
11
+ e(m.Input)
9
12
  );
10
13
  export {
11
- l as Slider,
12
- l as default
14
+ s as Slider,
15
+ s as default
13
16
  };
14
17
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../src/slider/index.ts"],"sourcesContent":["import { connect, mapProps } from '@silver-formily/vue'\r\nimport { ElSlider } from 'element-plus'\r\nimport { mapReadPretty } from '../__builtins__'\r\nimport { PreviewText } from '../preview-text'\r\n\r\nexport type SliderProps = typeof ElSlider\r\n\r\nexport const Slider = connect<typeof ElSlider>(\r\n ElSlider,\r\n mapProps({ readOnly: 'readonly', disabled: true }),\r\n mapReadPretty(PreviewText.Input),\r\n)\r\n\r\nexport default Slider\r\n"],"names":["Slider","connect","ElSlider","mapProps","mapReadPretty","PreviewText"],"mappings":";;;;AAOO,MAAMA,IAASC;AAAA,EACpBC;AAAA,EACAC,EAAS,EAAE,UAAU,YAAY,UAAU,IAAM;AAAA,EACjDC,EAAcC,EAAY,KAAK;AACjC;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../src/slider/index.ts"],"sourcesContent":["import { connect, mapProps } from '@silver-formily/vue'\nimport { ElSlider } from 'element-plus'\nimport { mapReadPretty } from '../__builtins__'\nimport { PreviewText } from '../preview-text'\n\nexport type SliderProps = typeof ElSlider\n\nexport const Slider = connect<typeof ElSlider>(\n ElSlider,\n mapProps({ readOnly: 'readonly', disabled: true }),\n mapReadPretty(PreviewText.Input),\n)\n\nexport default Slider\n"],"names":["Slider","connect","ElSlider","mapProps","mapReadPretty","PreviewText"],"mappings":";;;;;;;AAOO,MAAMA,IAASC;AAAA,EACpBC;AAAA,EACAC,EAAS,EAAE,UAAU,YAAY,UAAU,IAAM;AAAA,EACjDC,EAAcC,EAAY,KAAK;AACjC;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../src/submit/submit.vue","../../src/submit/index.ts"],"sourcesContent":["<script lang=\"ts\" setup>\r\nimport type { IFormFeedback } from '@formily/core'\r\nimport type { PropType } from 'vue'\r\nimport { useParentForm } from '@silver-formily/vue'\r\nimport { ElButton } from 'element-plus'\r\n\r\ndefineOptions({\r\n name: 'FSubmit',\r\n inheritAttrs: false,\r\n})\r\n\r\nconst props = defineProps({\r\n onClick: Function as PropType<(e: MouseEvent) => any>,\r\n onSubmit: Function as PropType<(values: any) => Promise<any>>,\r\n onSubmitSuccess: Function as PropType<(payload: any) => void>,\r\n onSubmitFailed: Function as PropType<(feedbacks: IFormFeedback[]) => void>,\r\n submit: Boolean,\r\n loading: Boolean,\r\n})\r\n\r\nconst formRef = useParentForm()\r\n\r\nfunction handleClick(e: MouseEvent) {\r\n if (props.onClick?.(e) === false)\r\n return\r\n if (props.onSubmit) {\r\n const form = formRef?.value\r\n form?.submit(props.onSubmit)\r\n .then(props.onSubmitSuccess)\r\n .catch(props.onSubmitFailed ?? console.error)\r\n }\r\n}\r\n</script>\r\n\r\n<template>\r\n <ElButton\r\n :native-type=\"props.submit ? 'button' : 'submit'\"\r\n type=\"primary\"\r\n v-bind=\"$attrs\"\r\n :loading=\"formRef?.submitting ?? props.loading\"\r\n @click=\"handleClick\"\r\n >\r\n <template #default>\r\n <slot />\r\n </template>\r\n </ElButton>\r\n</template>\r\n","import { observer } from '@silver-formily/reactive-vue'\r\nimport FSubmit from './submit.vue'\r\n\r\nexport const Submit = observer(FSubmit)\r\n\r\nexport default Submit\r\n"],"names":["props","__props","formRef","useParentForm","handleClick","e","_openBlock","_createBlock","_unref","_mergeProps","$attrs","_renderSlot","_ctx","Submit","observer","FSubmit"],"mappings":";;;;;;;;;;;;;;;;;AAWA,UAAMA,IAAQC,GASRC,IAAUC,EAAA;AAEhB,aAASC,EAAYC,GAAe;AAClC,MAAIL,EAAM,UAAUK,CAAC,MAAM,MAEvBL,EAAM,YACKE,GAAS,OAChB,OAAOF,EAAM,QAAQ,EACxB,KAAKA,EAAM,eAAe,EAC1B,MAAMA,EAAM,kBAAkB,QAAQ,KAAK;AAAA,IAElD;sBAIEM,KAAAC,EAUWC,MAVXC,EAUW;AAAA,MATR,eAAaT,EAAM,SAAM,WAAA;AAAA,MAC1B,MAAK;AAAA,IAAA,GACGU,EAAAA,QAAM;AAAA,MACb,SAASF,EAAAN,CAAA,GAAS,cAAcF,EAAM;AAAA,MACtC,SAAOI;AAAA,IAAA;MAEG,WACT,MAAQ;AAAA,QAARO,EAAQC,EAAA,QAAA,SAAA;AAAA,MAAA;;;;ICxCDC,IAASC,EAASC,CAAO;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../src/submit/submit.vue","../../src/submit/index.ts"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { IFormFeedback } from '@formily/core'\nimport type { PropType } from 'vue'\nimport { useParentForm } from '@silver-formily/vue'\nimport { ElButton } from 'element-plus'\n\ndefineOptions({\n name: 'FSubmit',\n inheritAttrs: false,\n})\n\nconst props = defineProps({\n onClick: Function as PropType<(e: MouseEvent) => any>,\n onSubmit: Function as PropType<(values: any) => Promise<any>>,\n onSubmitSuccess: Function as PropType<(payload: any) => void>,\n onSubmitFailed: Function as PropType<(feedbacks: IFormFeedback[]) => void>,\n submit: Boolean,\n loading: Boolean,\n})\n\nconst formRef = useParentForm()\n\nfunction handleClick(e: MouseEvent) {\n if (props.onClick?.(e) === false)\n return\n if (props.onSubmit) {\n const form = formRef?.value\n form?.submit(props.onSubmit)\n .then(props.onSubmitSuccess)\n .catch(props.onSubmitFailed ?? console.error)\n }\n}\n</script>\n\n<template>\n <ElButton\n :native-type=\"props.submit ? 'button' : 'submit'\"\n type=\"primary\"\n v-bind=\"$attrs\"\n :loading=\"formRef?.submitting ?? props.loading\"\n @click=\"handleClick\"\n >\n <template #default>\n <slot />\n </template>\n </ElButton>\n</template>\n","import { observer } from '@silver-formily/reactive-vue'\nimport FSubmit from './submit.vue'\n\nexport const Submit = observer(FSubmit)\n\nexport default Submit\n"],"names":["props","__props","formRef","useParentForm","handleClick","e","_openBlock","_createBlock","_unref","_mergeProps","$attrs","_renderSlot","_ctx","Submit","observer","FSubmit"],"mappings":";;;;;;;;;;;;;;;;;AAWA,UAAMA,IAAQC,GASRC,IAAUC,EAAA;AAEhB,aAASC,EAAYC,GAAe;AAClC,MAAIL,EAAM,UAAUK,CAAC,MAAM,MAEvBL,EAAM,YACKE,GAAS,OAChB,OAAOF,EAAM,QAAQ,EACxB,KAAKA,EAAM,eAAe,EAC1B,MAAMA,EAAM,kBAAkB,QAAQ,KAAK;AAAA,IAElD;sBAIEM,KAAAC,EAUWC,MAVXC,EAUW;AAAA,MATR,eAAaT,EAAM,SAAM,WAAA;AAAA,MAC1B,MAAK;AAAA,IAAA,GACGU,EAAAA,QAAM;AAAA,MACb,SAASF,EAAAN,CAAA,GAAS,cAAcF,EAAM;AAAA,MACtC,SAAOI;AAAA,IAAA;MAEG,WACT,MAAQ;AAAA,QAARO,EAAQC,EAAA,QAAA,SAAA;AAAA,MAAA;;;;ICxCDC,IAASC,EAASC,CAAO;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../src/switch/index.ts"],"sourcesContent":["import { connect, mapProps } from '@silver-formily/vue'\r\nimport { ElSwitch } from 'element-plus'\r\n\r\nexport type SwitchProps = typeof ElSwitch\r\n\r\nexport const Switch = connect<typeof ElSwitch>(\r\n ElSwitch,\r\n mapProps({\r\n readOnly: 'readonly',\r\n }),\r\n)\r\n\r\nexport default Switch\r\n"],"names":["Switch","connect","ElSwitch","mapProps"],"mappings":";;AAKO,MAAMA,IAASC;AAAA,EACpBC;AAAA,EACAC,EAAS;AAAA,IACP,UAAU;AAAA,EAAA,CACX;AACH;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../src/switch/index.ts"],"sourcesContent":["import { connect, mapProps } from '@silver-formily/vue'\nimport { ElSwitch } from 'element-plus'\n\nexport type SwitchProps = typeof ElSwitch\n\nexport const Switch = connect<typeof ElSwitch>(\n ElSwitch,\n mapProps({\n readOnly: 'readonly',\n }),\n)\n\nexport default Switch\n"],"names":["Switch","connect","ElSwitch","mapProps"],"mappings":";;AAKO,MAAMA,IAASC;AAAA,EACpBC;AAAA,EACAC,EAAS;AAAA,IACP,UAAU;AAAA,EAAA,CACX;AACH;"}
@@ -1,14 +1,17 @@
1
1
  import { connect as r, mapProps as e } from "@silver-formily/vue";
2
2
  import { ElTimePicker as m } from "element-plus";
3
- import { PreviewText as o } from "../preview-text/index.mjs";
4
- import { mapReadPretty as i } from "../__builtins__/shared/transform-component.mjs";
5
- const P = r(
3
+ import "@silver-formily/reactive-vue";
4
+ import "@vueuse/core";
5
+ import "vue";
6
+ import { mapReadPretty as o } from "../__builtins__/shared/transform-component.mjs";
7
+ import { PreviewText as i } from "../preview-text/index.mjs";
8
+ const d = r(
6
9
  m,
7
10
  e({ readOnly: "readonly" }),
8
- i(o.TimePicker)
11
+ o(i.TimePicker)
9
12
  );
10
13
  export {
11
- P as TimePicker,
12
- P as default
14
+ d as TimePicker,
15
+ d as default
13
16
  };
14
17
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../src/time-picker/index.ts"],"sourcesContent":["import { connect, mapProps } from '@silver-formily/vue'\r\nimport { ElTimePicker } from 'element-plus'\r\nimport { mapReadPretty } from '../__builtins__'\r\nimport { PreviewText } from '../preview-text'\r\n\r\nexport type TimePickerProps = typeof ElTimePicker\r\n\r\nexport const TimePicker = connect<typeof ElTimePicker>(\r\n ElTimePicker,\r\n mapProps({ readOnly: 'readonly' }),\r\n mapReadPretty(PreviewText.TimePicker),\r\n)\r\n\r\nexport default TimePicker\r\n"],"names":["TimePicker","connect","ElTimePicker","mapProps","mapReadPretty","PreviewText"],"mappings":";;;;AAOO,MAAMA,IAAaC;AAAA,EACxBC;AAAA,EACAC,EAAS,EAAE,UAAU,YAAY;AAAA,EACjCC,EAAcC,EAAY,UAAU;AACtC;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../src/time-picker/index.ts"],"sourcesContent":["import { connect, mapProps } from '@silver-formily/vue'\nimport { ElTimePicker } from 'element-plus'\nimport { mapReadPretty } from '../__builtins__'\nimport { PreviewText } from '../preview-text'\n\nexport type TimePickerProps = typeof ElTimePicker\n\nexport const TimePicker = connect<typeof ElTimePicker>(\n ElTimePicker,\n mapProps({ readOnly: 'readonly' }),\n mapReadPretty(PreviewText.TimePicker),\n)\n\nexport default TimePicker\n"],"names":["TimePicker","connect","ElTimePicker","mapProps","mapReadPretty","PreviewText"],"mappings":";;;;;;;AAOO,MAAMA,IAAaC;AAAA,EACxBC;AAAA,EACAC,EAAS,EAAE,UAAU,YAAY;AAAA,EACjCC,EAAcC,EAAY,UAAU;AACtC;"}
@@ -12,6 +12,10 @@ export declare const TimeSelect: import('element-plus/es/utils/index.mjs').SFCWi
12
12
  name: {
13
13
  type: import('vue').PropType<string>;
14
14
  };
15
+ effect: {
16
+ type: import('vue').PropType<import('element-plus').PopperEffect>;
17
+ default: string;
18
+ };
15
19
  format: {
16
20
  type: import('vue').PropType<string>;
17
21
  default: string;
@@ -24,10 +28,6 @@ export declare const TimeSelect: import('element-plus/es/utils/index.mjs').SFCWi
24
28
  type: import('vue').PropType<boolean>;
25
29
  default: undefined;
26
30
  };
27
- effect: {
28
- type: import('vue').PropType<import('element-plus').PopperEffect>;
29
- default: string;
30
- };
31
31
  placeholder: {
32
32
  type: import('vue').PropType<string>;
33
33
  };
@@ -98,6 +98,10 @@ export declare const TimeSelect: import('element-plus/es/utils/index.mjs').SFCWi
98
98
  name: {
99
99
  type: import('vue').PropType<string>;
100
100
  };
101
+ effect: {
102
+ type: import('vue').PropType<import('element-plus').PopperEffect>;
103
+ default: string;
104
+ };
101
105
  format: {
102
106
  type: import('vue').PropType<string>;
103
107
  default: string;
@@ -110,10 +114,6 @@ export declare const TimeSelect: import('element-plus/es/utils/index.mjs').SFCWi
110
114
  type: import('vue').PropType<boolean>;
111
115
  default: undefined;
112
116
  };
113
- effect: {
114
- type: import('vue').PropType<import('element-plus').PopperEffect>;
115
- default: string;
116
- };
117
117
  placeholder: {
118
118
  type: import('vue').PropType<string>;
119
119
  };
@@ -1,14 +1,17 @@
1
1
  import { connect as e, mapProps as t } from "@silver-formily/vue";
2
2
  import { ElTimeSelect as m } from "element-plus";
3
- import { PreviewText as o } from "../preview-text/index.mjs";
4
- import { mapReadPretty as r } from "../__builtins__/shared/transform-component.mjs";
5
- const l = e(
3
+ import "@silver-formily/reactive-vue";
4
+ import "@vueuse/core";
5
+ import "vue";
6
+ import { mapReadPretty as o } from "../__builtins__/shared/transform-component.mjs";
7
+ import { PreviewText as r } from "../preview-text/index.mjs";
8
+ const s = e(
6
9
  m,
7
10
  t({ disabled: "disabled", editable: "editable" }),
8
- r(o.Input)
11
+ o(r.Input)
9
12
  );
10
13
  export {
11
- l as TimeSelect,
12
- l as default
14
+ s as TimeSelect,
15
+ s as default
13
16
  };
14
17
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../src/time-select/index.ts"],"sourcesContent":["import { connect, mapProps } from '@silver-formily/vue'\r\nimport { ElTimeSelect } from 'element-plus'\r\nimport { mapReadPretty } from '../__builtins__'\r\nimport { PreviewText } from '../preview-text'\r\n\r\nexport const TimeSelect = connect<typeof ElTimeSelect>(\n ElTimeSelect,\n mapProps({ disabled: 'disabled', editable: 'editable' }),\r\n mapReadPretty(PreviewText.Input),\r\n)\r\n\r\nexport default TimeSelect\r\n"],"names":["TimeSelect","connect","ElTimeSelect","mapProps","mapReadPretty","PreviewText"],"mappings":";;;;AAKO,MAAMA,IAAaC;AAAA,EACxBC;AAAA,EACAC,EAAS,EAAE,UAAU,YAAY,UAAU,YAAY;AAAA,EACvDC,EAAcC,EAAY,KAAK;AACjC;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../src/time-select/index.ts"],"sourcesContent":["import { connect, mapProps } from '@silver-formily/vue'\r\nimport { ElTimeSelect } from 'element-plus'\r\nimport { mapReadPretty } from '../__builtins__'\r\nimport { PreviewText } from '../preview-text'\r\n\r\nexport const TimeSelect = connect<typeof ElTimeSelect>(\n ElTimeSelect,\n mapProps({ disabled: 'disabled', editable: 'editable' }),\r\n mapReadPretty(PreviewText.Input),\r\n)\r\n\r\nexport default TimeSelect\r\n"],"names":["TimeSelect","connect","ElTimeSelect","mapProps","mapReadPretty","PreviewText"],"mappings":";;;;;;;AAKO,MAAMA,IAAaC;AAAA,EACxBC;AAAA,EACAC,EAAS,EAAE,UAAU,YAAY,UAAU,YAAY;AAAA,EACvDC,EAAcC,EAAY,KAAK;AACjC;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../src/transfer/index.ts"],"sourcesContent":["import { connect, mapProps } from '@silver-formily/vue'\r\nimport { ElTransfer } from 'element-plus'\r\n\r\nexport type TransferProps = typeof ElTransfer\r\n\r\nexport const Transfer = connect<typeof ElTransfer>(\r\n ElTransfer,\r\n mapProps({ dataSource: 'data' }),\r\n)\r\n\r\nexport default Transfer\r\n"],"names":["Transfer","connect","ElTransfer","mapProps"],"mappings":";;AAKO,MAAMA,IAAWC;AAAA,EACtBC;AAAA,EACAC,EAAS,EAAE,YAAY,OAAA,CAAQ;AACjC;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../src/transfer/index.ts"],"sourcesContent":["import { connect, mapProps } from '@silver-formily/vue'\nimport { ElTransfer } from 'element-plus'\n\nexport type TransferProps = typeof ElTransfer\n\nexport const Transfer = connect<typeof ElTransfer>(\n ElTransfer,\n mapProps({ dataSource: 'data' }),\n)\n\nexport default Transfer\n"],"names":["Transfer","connect","ElTransfer","mapProps"],"mappings":";;AAKO,MAAMA,IAAWC;AAAA,EACtBC;AAAA,EACAC,EAAS,EAAE,YAAY,OAAA,CAAQ;AACjC;"}
@@ -1,12 +1,15 @@
1
1
  import { useField as _, connect as A, mapProps as D } from "@silver-formily/vue";
2
- import { PreviewText as H } from "../preview-text/index.mjs";
3
- import { defineComponent as P, useSlots as R, ref as h, computed as y, watch as v, nextTick as k, openBlock as g, createBlock as C, unref as a, withCtx as T, withDirectives as w, mergeProps as F, createSlots as B, renderList as E, renderSlot as L, normalizeProps as j, guardReactiveProps as z } from "vue";
4
- import { isFn as I } from "@formily/shared";
5
- import { ElScrollbar as N, ElTree as O, vLoading as $ } from "element-plus";
6
- import { addDisabledToNodes as q, flattenTree as G, getInputKeys as J, getOutputData as M } from "./utils.mjs";
7
- import { useCleanAttrs as Q } from "../__builtins__/shared/utils.mjs";
8
- import { mapReadPretty as U } from "../__builtins__/shared/transform-component.mjs";
9
- const W = /* @__PURE__ */ P({
2
+ import { ElScrollbar as H, ElTree as P, vLoading as R } from "element-plus";
3
+ import "@silver-formily/reactive-vue";
4
+ import "@vueuse/core";
5
+ import { defineComponent as w, useSlots as F, ref as h, computed as y, watch as v, nextTick as k, openBlock as g, createBlock as C, unref as a, withCtx as T, withDirectives as B, mergeProps as E, createSlots as L, renderList as j, renderSlot as z, normalizeProps as I, guardReactiveProps as N } from "vue";
6
+ import { mapReadPretty as O } from "../__builtins__/shared/transform-component.mjs";
7
+ import { PreviewText as $ } from "../preview-text/index.mjs";
8
+ import { isFn as q } from "@formily/shared";
9
+ import "@formily/core";
10
+ import { useCleanAttrs as G } from "../__builtins__/shared/utils.mjs";
11
+ import { addDisabledToNodes as J, flattenTree as M, getInputKeys as Q, getOutputData as U } from "./utils.mjs";
12
+ const W = /* @__PURE__ */ w({
10
13
  name: "Tree",
11
14
  inheritAttrs: !1,
12
15
  __name: "tree",
@@ -28,13 +31,13 @@ const W = /* @__PURE__ */ P({
28
31
  },
29
32
  emits: ["update:modelValue"],
30
33
  setup(K, { emit: V }) {
31
- const e = K, s = V, b = R(), { props: l } = Q(), o = h(), d = h([]), n = y(() => q(e.data ?? [], l.value.disabled, e.props)), c = y(() => G(n.value ?? [], [], e.props.children));
32
- async function u() {
34
+ const e = K, s = V, b = F(), { props: l } = G(), o = h(), d = h([]), n = y(() => J(e.data ?? [], l.value.disabled, e.props)), p = y(() => M(n.value ?? [], [], e.props.children));
35
+ async function c() {
33
36
  await k();
34
37
  const t = o.value.getCheckedKeys(), f = o.value.getHalfCheckedKeys() || [];
35
38
  d.value = t;
36
- const { value: m, nodes: r } = M(t, f, {
37
- flatData: c.value,
39
+ const { value: m, nodes: r } = U(t, f, {
40
+ flatData: p.value,
38
41
  nodeKey: e.nodeKey,
39
42
  propsConfig: e.props,
40
43
  data: e.data ?? [],
@@ -42,13 +45,13 @@ const W = /* @__PURE__ */ P({
42
45
  includeHalfChecked: e.includeHalfChecked,
43
46
  checkStrictly: l.value.checkStrictly
44
47
  });
45
- e.optionAsValue ? I(e.optionFormatter) ? s("update:modelValue", r.map((i, x, S) => e.optionFormatter(i, x, S))) : s("update:modelValue", r) : s("update:modelValue", m);
48
+ e.optionAsValue ? q(e.optionFormatter) ? s("update:modelValue", r.map((i, x, S) => e.optionFormatter(i, x, S))) : s("update:modelValue", r) : s("update:modelValue", m);
46
49
  }
47
50
  v(() => e.modelValue, (t) => {
48
- t !== void 0 && (d.value = J(t, {
51
+ t !== void 0 && (d.value = Q(t, {
49
52
  optionAsValue: e.optionAsValue,
50
53
  nodeKey: e.nodeKey,
51
- flatData: c.value,
54
+ flatData: p.value,
52
55
  propsConfig: e.props,
53
56
  data: e.data ?? [],
54
57
  valueType: e.valueType,
@@ -57,17 +60,17 @@ const W = /* @__PURE__ */ P({
57
60
  o.value && o.value.setCheckedKeys(d.value);
58
61
  }));
59
62
  }, { immediate: !0 }), v(() => [e.valueType, e.optionAsValue, e.includeHalfChecked], () => {
60
- u();
63
+ c();
61
64
  }, { immediate: !1 });
62
- const p = _();
63
- return p.value?.inject({
65
+ const u = _();
66
+ return u.value?.inject({
64
67
  getTreeRef: () => o
65
- }), (t, f) => (g(), C(a(N), {
68
+ }), (t, f) => (g(), C(a(H), {
66
69
  height: e.height,
67
70
  "max-height": e.maxHeight
68
71
  }, {
69
72
  default: T(() => [
70
- w((g(), C(a(O), F({
73
+ B((g(), C(a(P), E({
71
74
  ref_key: "treeRef",
72
75
  ref: o,
73
76
  data: n.value,
@@ -75,27 +78,27 @@ const W = /* @__PURE__ */ P({
75
78
  "node-key": e.nodeKey,
76
79
  "default-checked-keys": d.value,
77
80
  "show-checkbox": !0
78
- }, a(l), { onCheck: u }), B({ _: 2 }, [
79
- E(a(b), (m, r) => ({
81
+ }, a(l), { onCheck: c }), L({ _: 2 }, [
82
+ j(a(b), (m, r) => ({
80
83
  name: r,
81
84
  fn: T((i) => [
82
- L(t.$slots, r, j(z({ field: a(p), ...i })))
85
+ z(t.$slots, r, I(N({ field: a(u), ...i })))
83
86
  ])
84
87
  }))
85
88
  ]), 1040, ["data", "props", "node-key", "default-checked-keys"])), [
86
- [a($), a(l).loading]
89
+ [a(R), a(l).loading]
87
90
  ])
88
91
  ]),
89
92
  _: 3
90
93
  }, 8, ["height", "max-height"]));
91
94
  }
92
- }), re = A(
95
+ }), ie = A(
93
96
  W,
94
97
  D({ dataSource: "data", loading: "loading", disabled: !0 }),
95
- U(H.Tree)
98
+ O($.Tree)
96
99
  );
97
100
  export {
98
- re as Tree,
99
- re as default
101
+ ie as Tree,
102
+ ie as default
100
103
  };
101
104
  //# sourceMappingURL=index.mjs.map
@@ -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,EAAM,QAAQ,CAAA,GAAIM,EAAM,MAAM,UAAUN,EAAM,KAAK,CAC9E,GAEKc,IAAWF,EAAS,MAAMG,EAAYJ,EAAc,SAAS,CAAA,GAAI,IAAIX,EAAM,MAAM,QAAQ,CAAC;AAEhG,mBAAegB,IAAc;AAC3B,YAAMC,EAAA;AACN,YAAMC,IAAOV,EAAQ,MAAM,eAAA,GACrBW,IAAkBX,EAAQ,MAAM,mBAAA,KAAwB,CAAA;AAC9D,MAAAE,EAAY,QAAQQ;AAEpB,YAAM,EAAE,OAAAE,GAAO,OAAAC,EAAA,IAAUC,EAAcJ,GAAMC,GAAiB;AAAA,QAC5D,UAAUL,EAAS;AAAA,QACnB,SAASd,EAAM;AAAA,QACf,aAAaA,EAAM;AAAA,QACnB,MAAMA,EAAM,QAAQ,CAAA;AAAA,QACpB,WAAWA,EAAM;AAAA,QACjB,oBAAoBA,EAAM;AAAA,QAC1B,eAAeM,EAAM,MAAM;AAAA,MAAA,CAC5B;AAED,MAAIN,EAAM,gBACRuB,EAAKvB,EAAM,e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A3B,CAAA,GAAK,EACZ,SAAOU,GAAW,GAAAsB,EAAA,EAAA,GAAA,KAAA;AAAA,YAEWL,EAAA7B,CAAA,GAAK,CAAjBmC,GAAGC;;YACnB,IAAAC,EAAA,CAD4CC,MAAQ;AAAA,cACpDC,EAA+DC,EAAA,QAAlDJ,GAAIK,EAAAC,EAAA,EAAA,OAAmBb,EAAAH,CAAA,MAAaY,EAAA,CAAQ,CAAA,CAAA;AAAA,YAAA;;;UAVhD,CAAAT,EAAAc,CAAA,GAAAd,EAAA3B,CAAA,EAAM,OAAO;AAAA,QAAA;;;;;ICpGxB0C,KAAOC;AAAA,EACXC;AAAAA,EACAC,EAAS,EAAE,YAAY,QAAQ,SAAS,WAAW,UAAU,IAAM;AAAA,EACnEC,EAAcC,EAAY,IAAI;AAChC;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../src/tree/tree.vue","../../src/tree/index.ts"],"sourcesContent":["<script setup lang=\"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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,EAAM,QAAQ,CAAA,GAAIM,EAAM,MAAM,UAAUN,EAAM,KAAK,CAC9E,GAEKc,IAAWF,EAAS,MAAMG,EAAYJ,EAAc,SAAS,CAAA,GAAI,IAAIX,EAAM,MAAM,QAAQ,CAAC;AAEhG,mBAAegB,IAAc;AAC3B,YAAMC,EAAA;AACN,YAAMC,IAAOV,EAAQ,MAAM,eAAA,GACrBW,IAAkBX,EAAQ,MAAM,mBAAA,KAAwB,CAAA;AAC9D,MAAAE,EAAY,QAAQQ;AAEpB,YAAM,EAAE,OAAAE,GAAO,OAAAC,EAAA,IAAUC,EAAcJ,GAAMC,GAAiB;AAAA,QAC5D,UAAUL,EAAS;AAAA,QACnB,SAASd,EAAM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AA,GAAAJ,EAcSC,MAdTI,EAcS;AAAA,mBAbH;AAAA,UAAJ,KAAI7B;AAAA,UAEH,MAAMG,EAAA;AAAA,UACN,OAAOX,EAAM;AAAA,UACb,YAAUA,EAAM;AAAA,UAChB,wBAAsBU,EAAA;AAAA,UACtB,iBAAe;AAAA,QAAA,GACRuB,EAAA3B,CAAA,GAAK,EACZ,SAAOU,GAAW,GAAAsB,EAAA,EAAA,GAAA,KAAA;AAAA,YAEWL,EAAA7B,CAAA,GAAK,CAAjBmC,GAAGC;;YACnB,IAAAC,EAAA,CAD4CC,MAAQ;AAAA,cACpDC,EAA+DC,EAAA,QAAlDJ,GAAIK,EAAAC,EAAA,EAAA,OAAmBb,EAAAH,CAAA,MAAaY,EAAA,CAAQ,CAAA,CAAA;AAAA,YAAA;;;UAVhD,CAAAT,EAAAc,CAAA,GAAAd,EAAA3B,CAAA,EAAM,OAAO;AAAA,QAAA;;;;;ICpGxB0C,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,Q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AW;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","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,IAZ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A;AAEX;AAKO,SAASI,EACdC,GACAnC,GASO;AACP,QAAM,EAAE,eAAAoC,GAAe,SAAA/B,GAAS,UAAAc,GAAU,aAAAvB,GAAa,MAAA4B,GAAM,WAAAC,GAAW,eAAAE,MAAkB3B;AAG1F,MAAI,CAACmC,KAAc,CAAC,MAAM,QAAQA,CAAU;AAC1C,WAAO,CAAA;AAET,QAAME,IAAaD,IAAgBD,EAAW,IAAI,CAACG,MAAcA,EAAKjC,CAAO,CAAC,IAAI8B;AAElF,MAAIR;AACF,WAAOU;AAGT,UAAQZ,GAAA;AAAA,IACN,KAAK,UAAU;AACb,YAAMc,IAAU,CAAC,GAAGF,CAAU;AAE9B,iBAAWjB,KAAOiB,GAAY;AAC5B,cAAM5C,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,18 +1,21 @@
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 "@silver-formily/reactive-vue";
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 { useCleanAttrs as C } from "../__builtins__/shared/utils.mjs";
10
+ const w = /* @__PURE__ */ f({
8
11
  name: "FSelectTree",
9
12
  inheritAttrs: !1,
10
13
  __name: "tree-select",
11
14
  setup(A) {
12
- const n = d(), { props: l } = x(), r = u(), t = c();
15
+ const n = d(), { props: l } = C(), r = u(), t = c();
13
16
  return t.value?.inject({
14
17
  getTreeSelectRef: () => r
15
- }), (s, B) => (S(), _(e(k), g({
18
+ }), (s, B) => (S(), _(e(m), g({
16
19
  ref_key: "treeSelectRef",
17
20
  ref: r,
18
21
  loading: e(t).value?.loading
@@ -25,13 +28,13 @@ const w = /* @__PURE__ */ m({
25
28
  }))
26
29
  ]), 1040, ["loading"]));
27
30
  }
28
- }), b = i(
31
+ }), G = i(
29
32
  w,
30
- f({ readOnly: "readonly", dataSource: "data" }),
31
- C(p.Select)
33
+ p({ readOnly: "readonly", dataSource: "data" }),
34
+ k(x.Select)
32
35
  );
33
36
  export {
34
- b as TreeSelect,
35
- b as default
37
+ G as TreeSelect,
38
+ G as default
36
39
  };
37
40
  //# 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;"}