@pisell/materials 1.0.472 → 1.0.474

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 (291) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/index.js +1 -1
  5. package/build/lowcode/meta.js +7 -7
  6. package/build/lowcode/preview.js +7 -7
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +18 -18
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +17 -17
  11. package/es/components/cardMetricItem/index.less +1 -0
  12. package/es/components/dataSourceComponents/dataSourceForm/index.less +1 -1
  13. package/es/components/dataSourceComponents/dataSourceForm/serve.d.ts +1 -0
  14. package/es/components/dataSourceComponents/dataSourceForm/serve.js +4 -3
  15. package/es/components/dataSourceComponents/dataSourceForm/utils.d.ts +2 -2
  16. package/es/components/dataSourceComponents/dataSourceForm/utils.js +41 -17
  17. package/es/components/dataSourceComponents/dataSourceShow/dataSourceImage/index.d.ts +3 -0
  18. package/es/components/dataSourceComponents/dataSourceShow/dataSourceImage/index.js +4 -0
  19. package/es/components/dataSourceComponents/dataSourceShow/dataSourceQRCode/index.d.ts +3 -0
  20. package/es/components/dataSourceComponents/dataSourceShow/dataSourceQRCode/index.js +4 -0
  21. package/es/components/dataSourceComponents/dataSourceShow/dataSourceTypography/index.d.ts +10 -0
  22. package/es/components/dataSourceComponents/dataSourceShow/dataSourceTypography/index.js +15 -0
  23. package/es/components/dataSourceComponents/dataSourceShow/utils.d.ts +6 -0
  24. package/es/components/dataSourceComponents/dataSourceShow/utils.js +82 -0
  25. package/es/components/dataSourceComponents/dataSourceTable/BaseTable.js +33 -139
  26. package/es/components/dataSourceComponents/dataSourceTable/filter/index.d.ts +25 -0
  27. package/es/components/dataSourceComponents/dataSourceTable/filter/index.js +162 -0
  28. package/es/components/dataSourceComponents/dataSourceTable/filter/utils.d.ts +8 -0
  29. package/es/components/dataSourceComponents/dataSourceTable/filter/utils.js +135 -0
  30. package/es/components/dataSourceComponents/dataSourceTable/hooks/useDataSourceKey.d.ts +2 -2
  31. package/es/components/dataSourceComponents/dataSourceTable/hooks/useDataSourceKey.js +1 -1
  32. package/es/components/dataSourceComponents/dataSourceTable/hooks/useDesignMode.js +35 -39
  33. package/es/components/dataSourceComponents/dataSourceTable/hooks/useDrawerState.d.ts +20 -4
  34. package/es/components/dataSourceComponents/dataSourceTable/hooks/useDrawerState.js +65 -11
  35. package/es/components/dataSourceComponents/dataSourceTable/hooks/useFormat.d.ts +17 -1
  36. package/es/components/dataSourceComponents/dataSourceTable/hooks/useFormat.js +105 -6
  37. package/es/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +77 -0
  38. package/es/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.js +245 -0
  39. package/es/components/dataSourceComponents/dataSourceTable/hooks/useTableQuery.d.ts +20 -7
  40. package/es/components/dataSourceComponents/dataSourceTable/hooks/useTableQuery.js +41 -12
  41. package/es/components/dataSourceComponents/dataSourceTable/index.d.ts +1 -0
  42. package/es/components/dataSourceComponents/dataSourceTable/index.js +1 -0
  43. package/es/components/dataSourceComponents/dataSourceTable/index.less +5 -0
  44. package/es/components/dataSourceComponents/dataSourceTable/type.d.ts +57 -9
  45. package/es/components/dataSourceComponents/dataSourceWrapper/BaseWrapper.d.ts +7 -0
  46. package/es/components/dataSourceComponents/dataSourceWrapper/BaseWrapper.js +23 -0
  47. package/es/components/dataSourceComponents/dataSourceWrapper/index.d.ts +2 -4
  48. package/es/components/dataSourceComponents/dataSourceWrapper/index.js +17 -2
  49. package/es/components/dataSourceComponents/fields/Checkbox/ReadPretty.js +7 -1
  50. package/es/components/dataSourceComponents/fields/Checkbox/index.js +3 -1
  51. package/es/components/dataSourceComponents/fields/DatePicker/index.js +5 -1
  52. package/es/components/dataSourceComponents/fields/DateRangePicker/ReadPretty.d.ts +4 -0
  53. package/es/components/dataSourceComponents/fields/DateRangePicker/ReadPretty.js +7 -0
  54. package/es/components/dataSourceComponents/fields/DateRangePicker/WithMode.d.ts +4 -0
  55. package/es/components/dataSourceComponents/fields/DateRangePicker/WithMode.js +5 -0
  56. package/es/components/dataSourceComponents/fields/DateRangePicker/index.d.ts +4 -0
  57. package/es/components/dataSourceComponents/fields/DateRangePicker/index.js +5 -0
  58. package/es/components/dataSourceComponents/fields/DateRangePicker/index.less +14 -0
  59. package/es/components/dataSourceComponents/fields/DateRangePicker/type.d.ts +4 -0
  60. package/es/components/dataSourceComponents/fields/DateRangePicker/type.js +1 -0
  61. package/es/components/dataSourceComponents/fields/Input/index.d.ts +6 -1
  62. package/es/components/dataSourceComponents/fields/Input/index.js +4 -0
  63. package/es/components/dataSourceComponents/fields/Input.Email/ReadPretty.d.ts +4 -0
  64. package/es/components/dataSourceComponents/fields/Input.Email/ReadPretty.js +5 -0
  65. package/es/components/dataSourceComponents/fields/Input.Email/WithMode.d.ts +4 -0
  66. package/es/components/dataSourceComponents/fields/Input.Email/WithMode.js +17 -0
  67. package/es/components/dataSourceComponents/fields/Input.Email/index.d.ts +3 -0
  68. package/es/components/dataSourceComponents/fields/Input.Email/index.js +4 -0
  69. package/es/components/dataSourceComponents/fields/Input.Email/type.d.ts +5 -0
  70. package/es/components/dataSourceComponents/fields/Input.Email/type.js +1 -0
  71. package/es/components/dataSourceComponents/fields/Input.Json/ReadPretty.js +2 -2
  72. package/es/components/dataSourceComponents/fields/Input.Json/WithMode.d.ts +2 -2
  73. package/es/components/dataSourceComponents/fields/Input.Json/WithMode.js +41 -1
  74. package/es/components/dataSourceComponents/fields/Input.Json/index.d.ts +1 -1
  75. package/es/components/dataSourceComponents/fields/Input.Phone/ReadPretty.d.ts +4 -0
  76. package/es/components/dataSourceComponents/fields/Input.Phone/ReadPretty.js +5 -0
  77. package/es/components/dataSourceComponents/fields/Input.Phone/WithMode.d.ts +4 -0
  78. package/es/components/dataSourceComponents/fields/Input.Phone/WithMode.js +12 -0
  79. package/es/components/dataSourceComponents/fields/Input.Phone/index.d.ts +3 -0
  80. package/es/components/dataSourceComponents/fields/Input.Phone/index.js +4 -0
  81. package/es/components/dataSourceComponents/fields/Input.Phone/type.d.ts +5 -0
  82. package/es/components/dataSourceComponents/fields/Input.Phone/type.js +1 -0
  83. package/es/components/dataSourceComponents/fields/InputNumber/index.js +5 -1
  84. package/es/components/dataSourceComponents/fields/Select/index.d.ts +1 -1
  85. package/es/components/dataSourceComponents/fields/index.d.ts +46 -5
  86. package/es/components/dataSourceComponents/fields/index.js +7 -2
  87. package/es/components/dataSourceComponents/fields/type.d.ts +18 -0
  88. package/es/components/dataSourceComponents/fields/type.js +1 -0
  89. package/es/components/dataSourceComponents/fields/utils.d.ts +3 -0
  90. package/es/components/dataSourceComponents/fields/utils.js +111 -0
  91. package/es/components/dataSourceComponents/hooks/useActions.js +22 -7
  92. package/es/components/dataSourceComponents/hooks/useComponentId.d.ts +2 -0
  93. package/es/components/dataSourceComponents/hooks/useComponentId.js +9 -0
  94. package/es/components/dataSourceComponents/provider/dataSource/DataSourceContext.d.ts +19 -2
  95. package/es/components/dataSourceComponents/provider/dataSource/DataSourceProvider.d.ts +1 -1
  96. package/es/components/dataSourceComponents/provider/dataSource/DataSourceProvider.js +37 -27
  97. package/es/components/dataSourceComponents/provider/variables/VariablesContext.d.ts +3 -2
  98. package/es/components/dataSourceComponents/provider/variables/VariablesProvider.js +19 -13
  99. package/es/components/dataSourceComponents/provider/variables/utils.d.ts +2 -0
  100. package/es/components/dataSourceComponents/provider/variables/utils.js +9 -0
  101. package/es/components/filter/components/Dropdown/index.d.ts +1 -0
  102. package/es/components/filter/components/Dropdown/index.js +6 -2
  103. package/es/components/filter/components/FilterButton/index.js +5 -3
  104. package/es/components/filter/components/FilterButton/types.d.ts +2 -0
  105. package/es/components/pisellAnchor/index.less +77 -77
  106. package/es/components/pisellStatisticList/index.less +1 -1
  107. package/es/components/pisellWalletPassCard/index.js +3 -1
  108. package/es/components/pisellWalletPassCard/index.less +23 -9
  109. package/es/components/table/Actions/index.js +16 -7
  110. package/es/components/table/Gallery/index.d.ts +3 -3
  111. package/es/components/table/Gallery/index.js +25 -7
  112. package/es/components/table/Gallery/index.less +1 -0
  113. package/es/components/table/Header/index.d.ts +10 -3
  114. package/es/components/table/Header/index.js +37 -11
  115. package/es/components/table/Header/index.less +10 -2
  116. package/es/components/table/Table/utils.js +4 -0
  117. package/es/components/table/Tabs/index.d.ts +14 -0
  118. package/es/components/table/Tabs/index.js +37 -0
  119. package/es/components/table/hooks/useTriggerValuesChange.js +3 -0
  120. package/es/components/table/index.js +16 -3
  121. package/es/components/table/types.d.ts +14 -2
  122. package/es/components/typography/index.d.ts +2 -2
  123. package/es/components/typography/index.js +4 -3
  124. package/es/components/walletCard/index.d.ts +6 -4
  125. package/es/components/walletCard/index.js +34 -15
  126. package/es/index.d.ts +4 -0
  127. package/es/index.js +5 -1
  128. package/es/locales/en-US.d.ts +7 -0
  129. package/es/locales/en-US.js +16 -1
  130. package/es/locales/zh-CN.d.ts +7 -0
  131. package/es/locales/zh-CN.js +16 -1
  132. package/es/locales/zh-TW.d.ts +7 -0
  133. package/es/locales/zh-TW.js +16 -1
  134. package/lib/components/cardMetricItem/index.less +1 -0
  135. package/lib/components/dataSourceComponents/dataSourceForm/index.less +1 -1
  136. package/lib/components/dataSourceComponents/dataSourceForm/serve.d.ts +1 -0
  137. package/lib/components/dataSourceComponents/dataSourceForm/serve.js +3 -2
  138. package/lib/components/dataSourceComponents/dataSourceForm/utils.d.ts +2 -2
  139. package/lib/components/dataSourceComponents/dataSourceForm/utils.js +58 -11
  140. package/lib/components/dataSourceComponents/dataSourceShow/dataSourceImage/index.d.ts +3 -0
  141. package/lib/components/dataSourceComponents/dataSourceShow/dataSourceImage/index.js +38 -0
  142. package/lib/components/dataSourceComponents/dataSourceShow/dataSourceQRCode/index.d.ts +3 -0
  143. package/lib/components/dataSourceComponents/dataSourceShow/dataSourceQRCode/index.js +38 -0
  144. package/lib/components/dataSourceComponents/dataSourceShow/dataSourceTypography/index.d.ts +10 -0
  145. package/lib/components/dataSourceComponents/dataSourceShow/dataSourceTypography/index.js +44 -0
  146. package/lib/components/dataSourceComponents/dataSourceShow/utils.d.ts +6 -0
  147. package/lib/components/dataSourceComponents/dataSourceShow/utils.js +95 -0
  148. package/lib/components/dataSourceComponents/dataSourceTable/BaseTable.js +29 -90
  149. package/lib/components/dataSourceComponents/dataSourceTable/filter/index.d.ts +25 -0
  150. package/lib/components/dataSourceComponents/dataSourceTable/filter/index.js +176 -0
  151. package/lib/components/dataSourceComponents/dataSourceTable/filter/utils.d.ts +8 -0
  152. package/lib/components/dataSourceComponents/dataSourceTable/filter/utils.js +176 -0
  153. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useDataSourceKey.d.ts +2 -2
  154. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useDataSourceKey.js +1 -1
  155. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useDesignMode.js +24 -37
  156. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useDrawerState.d.ts +20 -4
  157. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useDrawerState.js +53 -7
  158. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useFormat.d.ts +17 -1
  159. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useFormat.js +73 -3
  160. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +77 -0
  161. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.js +236 -0
  162. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableQuery.d.ts +20 -7
  163. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableQuery.js +38 -11
  164. package/lib/components/dataSourceComponents/dataSourceTable/index.d.ts +1 -0
  165. package/lib/components/dataSourceComponents/dataSourceTable/index.js +1 -0
  166. package/lib/components/dataSourceComponents/dataSourceTable/index.less +5 -0
  167. package/lib/components/dataSourceComponents/dataSourceTable/type.d.ts +57 -9
  168. package/lib/components/dataSourceComponents/dataSourceWrapper/BaseWrapper.d.ts +7 -0
  169. package/lib/components/dataSourceComponents/dataSourceWrapper/BaseWrapper.js +51 -0
  170. package/lib/components/dataSourceComponents/dataSourceWrapper/index.d.ts +2 -4
  171. package/lib/components/dataSourceComponents/dataSourceWrapper/index.js +14 -2
  172. package/lib/components/dataSourceComponents/fields/Checkbox/ReadPretty.js +3 -1
  173. package/lib/components/dataSourceComponents/fields/Checkbox/index.js +3 -1
  174. package/lib/components/dataSourceComponents/fields/DatePicker/index.js +5 -1
  175. package/lib/components/dataSourceComponents/fields/DateRangePicker/ReadPretty.d.ts +4 -0
  176. package/lib/components/dataSourceComponents/fields/DateRangePicker/ReadPretty.js +41 -0
  177. package/lib/components/dataSourceComponents/fields/DateRangePicker/WithMode.d.ts +4 -0
  178. package/lib/components/dataSourceComponents/fields/DateRangePicker/WithMode.js +42 -0
  179. package/lib/components/dataSourceComponents/fields/DateRangePicker/index.d.ts +4 -0
  180. package/lib/components/dataSourceComponents/fields/DateRangePicker/index.js +39 -0
  181. package/lib/components/dataSourceComponents/fields/DateRangePicker/index.less +14 -0
  182. package/lib/components/dataSourceComponents/fields/DateRangePicker/type.d.ts +4 -0
  183. package/lib/components/dataSourceComponents/fields/DateRangePicker/type.js +17 -0
  184. package/lib/components/dataSourceComponents/fields/Input/index.d.ts +6 -1
  185. package/lib/components/dataSourceComponents/fields/Input/index.js +4 -0
  186. package/lib/components/dataSourceComponents/fields/Input.Email/ReadPretty.d.ts +4 -0
  187. package/lib/components/dataSourceComponents/fields/Input.Email/ReadPretty.js +39 -0
  188. package/lib/components/dataSourceComponents/fields/Input.Email/WithMode.d.ts +4 -0
  189. package/lib/components/dataSourceComponents/fields/Input.Email/WithMode.js +57 -0
  190. package/lib/components/dataSourceComponents/fields/Input.Email/index.d.ts +3 -0
  191. package/lib/components/dataSourceComponents/fields/Input.Email/index.js +38 -0
  192. package/lib/components/dataSourceComponents/fields/Input.Email/type.d.ts +5 -0
  193. package/lib/components/dataSourceComponents/fields/Input.Email/type.js +17 -0
  194. package/lib/components/dataSourceComponents/fields/Input.Json/ReadPretty.js +2 -2
  195. package/lib/components/dataSourceComponents/fields/Input.Json/WithMode.d.ts +2 -2
  196. package/lib/components/dataSourceComponents/fields/Input.Json/WithMode.js +30 -2
  197. package/lib/components/dataSourceComponents/fields/Input.Json/index.d.ts +1 -1
  198. package/lib/components/dataSourceComponents/fields/Input.Phone/ReadPretty.d.ts +4 -0
  199. package/lib/components/dataSourceComponents/fields/Input.Phone/ReadPretty.js +39 -0
  200. package/lib/components/dataSourceComponents/fields/Input.Phone/WithMode.d.ts +4 -0
  201. package/lib/components/dataSourceComponents/fields/Input.Phone/WithMode.js +43 -0
  202. package/lib/components/dataSourceComponents/fields/Input.Phone/index.d.ts +3 -0
  203. package/lib/components/dataSourceComponents/fields/Input.Phone/index.js +38 -0
  204. package/lib/components/dataSourceComponents/fields/Input.Phone/type.d.ts +5 -0
  205. package/lib/components/dataSourceComponents/fields/Input.Phone/type.js +17 -0
  206. package/lib/components/dataSourceComponents/fields/InputNumber/index.js +5 -1
  207. package/lib/components/dataSourceComponents/fields/Select/index.d.ts +1 -1
  208. package/lib/components/dataSourceComponents/fields/index.d.ts +46 -5
  209. package/lib/components/dataSourceComponents/fields/index.js +6 -1
  210. package/lib/components/dataSourceComponents/fields/type.d.ts +18 -0
  211. package/lib/components/dataSourceComponents/fields/type.js +17 -0
  212. package/lib/components/dataSourceComponents/fields/utils.d.ts +3 -0
  213. package/lib/components/dataSourceComponents/fields/utils.js +134 -0
  214. package/lib/components/dataSourceComponents/hooks/useActions.js +14 -5
  215. package/lib/components/dataSourceComponents/hooks/useComponentId.d.ts +2 -0
  216. package/lib/components/dataSourceComponents/hooks/useComponentId.js +32 -0
  217. package/lib/components/dataSourceComponents/provider/dataSource/DataSourceContext.d.ts +19 -2
  218. package/lib/components/dataSourceComponents/provider/dataSource/DataSourceProvider.d.ts +1 -1
  219. package/lib/components/dataSourceComponents/provider/dataSource/DataSourceProvider.js +29 -16
  220. package/lib/components/dataSourceComponents/provider/variables/VariablesContext.d.ts +3 -2
  221. package/lib/components/dataSourceComponents/provider/variables/VariablesProvider.js +17 -8
  222. package/lib/components/dataSourceComponents/provider/variables/utils.d.ts +2 -0
  223. package/lib/components/dataSourceComponents/provider/variables/utils.js +15 -2
  224. package/lib/components/filter/components/Dropdown/index.d.ts +1 -0
  225. package/lib/components/filter/components/Dropdown/index.js +6 -2
  226. package/lib/components/filter/components/FilterButton/index.js +5 -3
  227. package/lib/components/filter/components/FilterButton/types.d.ts +2 -0
  228. package/lib/components/pisellAnchor/index.less +77 -77
  229. package/lib/components/pisellStatisticList/index.less +1 -1
  230. package/lib/components/pisellWalletPassCard/index.js +1 -1
  231. package/lib/components/pisellWalletPassCard/index.less +23 -9
  232. package/lib/components/table/Actions/index.js +18 -9
  233. package/lib/components/table/Gallery/index.d.ts +3 -3
  234. package/lib/components/table/Gallery/index.js +17 -0
  235. package/lib/components/table/Gallery/index.less +1 -0
  236. package/lib/components/table/Header/index.d.ts +10 -3
  237. package/lib/components/table/Header/index.js +29 -4
  238. package/lib/components/table/Header/index.less +10 -2
  239. package/lib/components/table/Table/utils.js +4 -0
  240. package/lib/components/table/Tabs/index.d.ts +14 -0
  241. package/lib/components/table/Tabs/index.js +70 -0
  242. package/lib/components/table/hooks/useTriggerValuesChange.js +3 -0
  243. package/lib/components/table/index.js +17 -2
  244. package/lib/components/table/types.d.ts +14 -2
  245. package/lib/components/typography/index.d.ts +2 -2
  246. package/lib/components/typography/index.js +4 -3
  247. package/lib/components/walletCard/index.d.ts +6 -4
  248. package/lib/components/walletCard/index.js +24 -13
  249. package/lib/index.d.ts +4 -0
  250. package/lib/index.js +12 -0
  251. package/lib/locales/en-US.d.ts +7 -0
  252. package/lib/locales/en-US.js +8 -1
  253. package/lib/locales/zh-CN.d.ts +7 -0
  254. package/lib/locales/zh-CN.js +8 -1
  255. package/lib/locales/zh-TW.d.ts +7 -0
  256. package/lib/locales/zh-TW.js +8 -1
  257. package/lowcode/_utils/defaultSchema.ts +452 -83
  258. package/lowcode/_utils/type.ts +5 -0
  259. package/lowcode/_utils/utils.ts +1 -0
  260. package/lowcode/button/meta.ts +1 -2
  261. package/lowcode/data-source-form/constants.ts +5 -0
  262. package/lowcode/data-source-form/meta.ts +259 -273
  263. package/lowcode/data-source-form/snippets.ts +9 -0
  264. package/lowcode/data-source-form/utils.ts +80 -15
  265. package/lowcode/data-source-image/meta.ts +74 -0
  266. package/lowcode/data-source-image/snippets.ts +14 -0
  267. package/lowcode/data-source-qrcode/meta.ts +158 -0
  268. package/lowcode/data-source-qrcode/snippets.ts +20 -0
  269. package/lowcode/data-source-table/meta.ts +4577 -2285
  270. package/lowcode/data-source-table/snippets.ts +10 -4
  271. package/lowcode/data-source-table/utils.tsx +254 -0
  272. package/lowcode/data-source-typography/meta.ts +54 -0
  273. package/lowcode/data-source-typography.text/meta.ts +212 -0
  274. package/lowcode/data-source-typography.text/snippets.ts +12 -0
  275. package/lowcode/data-source-wrapper/meta.ts +243 -0
  276. package/lowcode/data-source-wrapper/snippets.ts +11 -0
  277. package/lowcode/data-source-wrapper/utils.ts +45 -0
  278. package/lowcode/form-item-color-picker/snippets.ts +1 -0
  279. package/lowcode/form-item-input/meta.ts +2 -1
  280. package/lowcode/form-item-input/snippets.ts +2 -1
  281. package/lowcode/form-item-input.email/meta.ts +284 -0
  282. package/lowcode/form-item-input.email/snippets.ts +35 -0
  283. package/lowcode/form-item-input.phone/meta.ts +295 -0
  284. package/lowcode/form-item-input.phone/snippets.ts +16 -0
  285. package/lowcode/form-item-input.text-area/meta.ts +243 -32
  286. package/lowcode/form-item-input.text-area/snippets.ts +2 -1
  287. package/lowcode/form-item-input.url/meta.ts +44 -20
  288. package/lowcode/form-item-input.url/snippets.ts +5 -5
  289. package/lowcode/table/snippets.ts +6 -0
  290. package/lowcode/test/meta.ts +1 -2
  291. package/package.json +4 -4
@@ -0,0 +1,95 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/components/dataSourceComponents/dataSourceShow/utils.tsx
30
+ var utils_exports = {};
31
+ __export(utils_exports, {
32
+ default: () => utils_default
33
+ });
34
+ module.exports = __toCommonJS(utils_exports);
35
+ var import_react = __toESM(require("react"));
36
+ var import_utils = require("@pisell/utils");
37
+ var import_ahooks = require("ahooks");
38
+ var import_utils2 = require("../provider/variables/utils");
39
+ var import_useVariables = __toESM(require("../hooks/useVariables"));
40
+ var parseValueToVariableKey = (value) => {
41
+ if ((0, import_utils.isArr)(value) && value.length === 1 && (0, import_utils.isString)(value[0])) {
42
+ const key = (0, import_utils2.getVariableKey)(value[0]);
43
+ return key ? key.split(".")[0] : null;
44
+ }
45
+ if ((0, import_utils.isString)(value)) {
46
+ const key = (0, import_utils2.getVariableKey)(value);
47
+ return key ? key.split(".")[0] : null;
48
+ }
49
+ return null;
50
+ };
51
+ var withParseVariables = (Component, keys) => {
52
+ return (props) => {
53
+ const [variables, setVariables] = (0, import_react.useState)({});
54
+ const { parseVariable, subscribeVariables } = (0, import_useVariables.default)();
55
+ const valuesRef = (0, import_react.useRef)(/* @__PURE__ */ new Set());
56
+ const handleVariableChange = (0, import_ahooks.useMemoizedFn)(
57
+ (allVariables, updateVariables) => {
58
+ const changedKey = Object.keys(updateVariables)[0];
59
+ if (valuesRef.current.has(changedKey)) {
60
+ setVariables((prev) => ({ ...prev, ...allVariables }));
61
+ }
62
+ }
63
+ );
64
+ (0, import_react.useEffect)(() => {
65
+ const values = /* @__PURE__ */ new Set();
66
+ keys.forEach((key) => {
67
+ const variableKey = parseValueToVariableKey(props[key]);
68
+ if (variableKey) {
69
+ values.add(variableKey);
70
+ }
71
+ });
72
+ valuesRef.current = values;
73
+ }, [props, keys]);
74
+ (0, import_react.useEffect)(() => {
75
+ const unsubscribe = subscribeVariables == null ? void 0 : subscribeVariables(handleVariableChange);
76
+ return () => {
77
+ unsubscribe == null ? void 0 : unsubscribe();
78
+ };
79
+ }, []);
80
+ const parsedProps = (0, import_react.useMemo)(() => {
81
+ const result = { ...props };
82
+ keys.forEach((key) => {
83
+ const value = props[key];
84
+ if ((0, import_utils.isArr)(value) && value.length === 1 && (0, import_utils.isString)(value[0])) {
85
+ result[key] = parseVariable == null ? void 0 : parseVariable(value[0], variables);
86
+ } else if ((0, import_utils.isString)(value)) {
87
+ result[key] = parseVariable == null ? void 0 : parseVariable(value, variables);
88
+ }
89
+ });
90
+ return result;
91
+ }, [props, variables, keys]);
92
+ return /* @__PURE__ */ import_react.default.createElement(Component, { ...parsedProps });
93
+ };
94
+ };
95
+ var utils_default = withParseVariables;
@@ -33,58 +33,47 @@ __export(BaseTable_exports, {
33
33
  });
34
34
  module.exports = __toCommonJS(BaseTable_exports);
35
35
  var import_react = __toESM(require("react"));
36
- var import_antd = require("antd");
36
+ var import_ahooks = require("ahooks");
37
37
  var import_table = __toESM(require("../../table"));
38
38
  var import_useVariables = __toESM(require("../hooks/useVariables"));
39
- var import_useColumns = __toESM(require("./hooks/useColumns"));
40
- var import_usePagination = __toESM(require("./hooks/usePagination"));
41
39
  var import_ActionsProvider = __toESM(require("../provider/actions/ActionsProvider"));
42
40
  var import_useDrawerState = __toESM(require("./hooks/useDrawerState"));
43
41
  var import_useDesignMode = __toESM(require("./hooks/useDesignMode"));
42
+ var import_useComponentId = __toESM(require("../hooks/useComponentId"));
44
43
  var import_useTableQuery = __toESM(require("./hooks/useTableQuery"));
45
- var import_locales = require("../../../locales");
46
44
  var import_useDataSource = __toESM(require("../hooks/useDataSource"));
47
45
  var import_TableSettingProvider = __toESM(require("./provider/tableSetting/TableSettingProvider"));
48
46
  var import_useDataSourceKey = __toESM(require("./hooks/useDataSourceKey"));
49
- var DRAWER_TITLES = {
50
- detail: (0, import_locales.getText)("pisell-data-source-table-detail"),
51
- edit: (0, import_locales.getText)("pisell-data-source-table-edit"),
52
- add: (0, import_locales.getText)("pisell-data-source-table-add")
53
- };
47
+ var import_useTableProps = __toESM(require("./hooks/useTableProps"));
54
48
  var BaseTable = (props) => {
55
49
  const {
56
50
  columns: propsColumns,
57
51
  dataSource,
58
- detailContent,
59
- editContent,
60
- showDetailButton,
61
- showEditButton,
62
- showDeleteButton,
63
- showAddButton,
64
- addContent,
65
- __designMode,
66
- componentId,
52
+ operationContent,
67
53
  ...others
68
54
  } = props;
55
+ const componentId = (0, import_useComponentId.default)(props);
69
56
  const { registerValueVariable } = (0, import_useVariables.default)();
70
- const { list, destroy } = (0, import_useDataSource.default)();
57
+ const { list } = (0, import_useDataSource.default)();
71
58
  const { data } = list;
72
59
  const { dataSourceKey, dataSourceKeyRef } = (0, import_useDataSourceKey.default)();
73
60
  const {
74
61
  drawerVisible,
75
62
  setDrawerVisible,
76
- drawerType,
77
63
  openDrawer,
78
- closeDrawer
79
- } = (0, import_useDrawerState.default)();
80
- const { queryPageConfig, handleValuesChange, refreshData } = (0, import_useTableQuery.default)();
64
+ closeDrawer,
65
+ containerProps,
66
+ Container,
67
+ drawerContent
68
+ } = (0, import_useDrawerState.default)(operationContent);
69
+ const { queryPageConfig, handleValuesChange, refreshData, handleFilterChange } = (0, import_useTableQuery.default)(props);
81
70
  (0, import_useDesignMode.default)(props, {
82
71
  registerValueVariable,
83
72
  openDrawer,
84
73
  closeDrawer,
85
74
  data: data == null ? void 0 : data.data
86
75
  });
87
- (0, import_react.useEffect)(() => {
76
+ (0, import_ahooks.useUpdateEffect)(() => {
88
77
  refreshData();
89
78
  }, [dataSourceKey]);
90
79
  (0, import_react.useEffect)(() => {
@@ -94,84 +83,33 @@ var BaseTable = (props) => {
94
83
  list == null ? void 0 : list.mutate([]);
95
84
  }
96
85
  }, [queryPageConfig]);
97
- const handleOpenDrawer = (record, type) => {
86
+ (0, import_react.useEffect)(() => {
98
87
  registerValueVariable == null ? void 0 : registerValueVariable(componentId, {
99
- currentRecord: record
88
+ currentDataSource: dataSource
100
89
  });
101
- openDrawer(type);
102
- };
90
+ }, [dataSource]);
103
91
  const handleCloseDrawer = () => {
104
92
  closeDrawer();
105
93
  registerValueVariable == null ? void 0 : registerValueVariable(componentId, {
106
94
  currentRecord: null
107
95
  });
108
96
  };
109
- const handleDelete = async (record) => {
110
- try {
111
- registerValueVariable == null ? void 0 : registerValueVariable(componentId, {
112
- currentRecord: record
113
- });
114
- setTimeout(async () => {
115
- await (destroy == null ? void 0 : destroy.run(record.id));
116
- refreshData();
117
- });
118
- } catch (error) {
119
- console.error(error);
120
- import_antd.message.error("删除失败,请重试");
121
- }
122
- };
123
- const actionsColumns = (0, import_react.useMemo)(() => {
124
- return [
125
- {
126
- title: "操作",
127
- key: "actions",
128
- showDetailButton,
129
- showEditButton,
130
- showDeleteButton,
131
- render: (_, record) => {
132
- return /* @__PURE__ */ import_react.default.createElement(import_antd.Space, null, showDetailButton && /* @__PURE__ */ import_react.default.createElement(
133
- import_antd.Button,
134
- {
135
- onClick: () => handleOpenDrawer(record, "detail"),
136
- type: "link"
137
- },
138
- (0, import_locales.getText)("pisell-data-source-table-detail")
139
- ), showEditButton && /* @__PURE__ */ import_react.default.createElement(
140
- import_antd.Button,
141
- {
142
- onClick: () => handleOpenDrawer(record, "edit"),
143
- type: "link"
144
- },
145
- (0, import_locales.getText)("pisell-data-source-table-edit")
146
- ), showDeleteButton && /* @__PURE__ */ import_react.default.createElement(import_antd.Button, { onClick: () => handleDelete(record), type: "link", danger: true }, (0, import_locales.getText)("pisell-data-source-table-delete")));
147
- }
148
- }
149
- ];
150
- }, [showDetailButton, showEditButton, showDeleteButton]);
151
- const columns = (0, import_useColumns.default)({
152
- columns: propsColumns,
153
- fields: dataSource == null ? void 0 : dataSource.fields,
154
- // 操作列
155
- actionsColumns
97
+ const transformProps = (0, import_useTableProps.default)({
98
+ data,
99
+ originProps: props,
100
+ openDrawer,
101
+ closeDrawer,
102
+ refreshData,
103
+ handleFilterChange
156
104
  });
157
- const pagination = (0, import_usePagination.default)({ data });
158
- const drawerContent = (0, import_react.useMemo)(() => {
159
- const contentMap = {
160
- detail: detailContent,
161
- edit: editContent,
162
- add: addContent
163
- };
164
- return contentMap[drawerType];
165
- }, [drawerType, detailContent, editContent, addContent]);
166
- return /* @__PURE__ */ import_react.default.createElement(import_TableSettingProvider.default, null, showAddButton && /* @__PURE__ */ import_react.default.createElement("div", { style: { marginBottom: 16 } }, /* @__PURE__ */ import_react.default.createElement(import_antd.Button, { type: "primary", onClick: () => handleOpenDrawer(null, "add") }, (0, import_locales.getText)("pisell-data-source-table-add"))), /* @__PURE__ */ import_react.default.createElement(
105
+ return /* @__PURE__ */ import_react.default.createElement(import_TableSettingProvider.default, null, /* @__PURE__ */ import_react.default.createElement(
167
106
  import_table.default,
168
107
  {
169
108
  ...others,
170
- columns,
109
+ ...transformProps,
171
110
  dataSource: (data == null ? void 0 : data.data) || [],
172
111
  loading: list == null ? void 0 : list.loading,
173
- onValuesChange: handleValuesChange,
174
- pagination
112
+ onValuesChange: handleValuesChange
175
113
  }
176
114
  ), /* @__PURE__ */ import_react.default.createElement(
177
115
  import_ActionsProvider.default,
@@ -181,11 +119,12 @@ var BaseTable = (props) => {
181
119
  refreshTableData: refreshData
182
120
  },
183
121
  /* @__PURE__ */ import_react.default.createElement(
184
- import_antd.Drawer,
122
+ Container,
185
123
  {
186
- title: DRAWER_TITLES[drawerType],
124
+ ...containerProps,
187
125
  open: drawerVisible,
188
126
  onClose: handleCloseDrawer,
127
+ onCancel: handleCloseDrawer,
189
128
  destroyOnClose: true
190
129
  },
191
130
  drawerContent
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ interface BaseFilterItem {
3
+ name?: string;
4
+ value: string;
5
+ label?: string;
6
+ type?: string;
7
+ isHidden: boolean;
8
+ isCustom?: boolean;
9
+ }
10
+ interface FilterProps {
11
+ componentId: string;
12
+ filterBy: Record<string, any>;
13
+ quickFilterMaxLength?: number;
14
+ sortButtonShow?: boolean;
15
+ mode?: 'simple' | 'complex';
16
+ items: BaseFilterItem[];
17
+ handleValuesChange: (changedFields: any, allFields: any) => void;
18
+ search: {
19
+ show: boolean;
20
+ placeholder: string;
21
+ key: string;
22
+ };
23
+ }
24
+ declare const Filter: (props: FilterProps) => React.JSX.Element;
25
+ export default Filter;
@@ -0,0 +1,176 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/components/dataSourceComponents/dataSourceTable/filter/index.tsx
30
+ var filter_exports = {};
31
+ __export(filter_exports, {
32
+ default: () => filter_default
33
+ });
34
+ module.exports = __toCommonJS(filter_exports);
35
+ var import_react = __toESM(require("react"));
36
+ var import_antd = require("antd");
37
+ var import_ahooks = require("ahooks");
38
+ var import_icons = require("@ant-design/icons");
39
+ var import_Input = __toESM(require("../../fields/Input"));
40
+ var import_useDataSource = __toESM(require("../../hooks/useDataSource"));
41
+ var import_FilterButton = __toESM(require("../../../filter/components/FilterButton"));
42
+ var import_utils = require("./utils");
43
+ var defaultArr = [];
44
+ var Filter = (props) => {
45
+ const {
46
+ componentId,
47
+ items = defaultArr,
48
+ mode = "simple",
49
+ quickFilterMaxLength = 3,
50
+ sortButtonShow = false,
51
+ handleValuesChange,
52
+ search,
53
+ filterBy
54
+ } = props;
55
+ const [form] = import_antd.Form.useForm();
56
+ const { dataSource } = (0, import_useDataSource.default)();
57
+ const [list, setList] = (0, import_react.useState)(() => {
58
+ const storedOrder = (0, import_utils.getStoredFilterOrder)(componentId);
59
+ return storedOrder || {
60
+ quickFilter: [],
61
+ otherFilter: []
62
+ };
63
+ });
64
+ const filterList = (0, import_react.useMemo)(() => {
65
+ return items.filter((item) => !(item == null ? void 0 : item.isHidden));
66
+ }, [items]);
67
+ const filterDom = (0, import_react.useMemo)(() => {
68
+ return (0, import_utils.genFilterItems)(list.quickFilter, dataSource);
69
+ }, [list.quickFilter]);
70
+ (0, import_react.useEffect)(() => {
71
+ const storedOrder = (0, import_utils.getStoredFilterOrder)(componentId);
72
+ if (!storedOrder) {
73
+ const newList = {
74
+ quickFilter: filterList.slice(0, quickFilterMaxLength),
75
+ otherFilter: filterList.slice(quickFilterMaxLength)
76
+ };
77
+ setList(newList);
78
+ (0, import_utils.saveFilterOrder)(componentId, newList);
79
+ return;
80
+ }
81
+ const orderedItems = {
82
+ quickFilter: [],
83
+ otherFilter: []
84
+ };
85
+ const itemMap = new Map(filterList.map((item) => [item.name, item]));
86
+ storedOrder.quickFilter.forEach((stored) => {
87
+ const item = itemMap.get(stored.name);
88
+ if (item) {
89
+ orderedItems.quickFilter.push(item);
90
+ itemMap.delete(stored.name);
91
+ }
92
+ });
93
+ storedOrder.otherFilter.forEach((stored) => {
94
+ const item = itemMap.get(stored.name);
95
+ if (item) {
96
+ orderedItems.otherFilter.push(item);
97
+ itemMap.delete(stored.name);
98
+ }
99
+ });
100
+ const remainingItems = Array.from(itemMap.values());
101
+ remainingItems.forEach((item) => {
102
+ if (orderedItems.quickFilter.length < quickFilterMaxLength) {
103
+ orderedItems.quickFilter.push(item);
104
+ } else {
105
+ orderedItems.otherFilter.push(item);
106
+ }
107
+ });
108
+ if (quickFilterMaxLength && orderedItems.quickFilter.length > quickFilterMaxLength) {
109
+ const overflow = orderedItems.quickFilter.splice(quickFilterMaxLength);
110
+ orderedItems.otherFilter.unshift(...overflow);
111
+ }
112
+ setList(orderedItems);
113
+ (0, import_utils.saveFilterOrder)(componentId, orderedItems);
114
+ }, [filterList, quickFilterMaxLength, componentId]);
115
+ const onChange = (newVal) => {
116
+ setList(newVal);
117
+ (0, import_utils.saveFilterOrder)(componentId, newVal);
118
+ };
119
+ const renderItem = (0, import_ahooks.useMemoizedFn)((item, otherProps) => {
120
+ const getField = (0, import_utils.genGetField)(dataSource);
121
+ const field = getField(item.name);
122
+ const cptDom = (0, import_utils.field2Cpt)(field, item, {
123
+ labelCol: { span: 24 },
124
+ style: (style) => {
125
+ return {
126
+ ...style || {},
127
+ width: "100%"
128
+ };
129
+ },
130
+ ...otherProps
131
+ });
132
+ return cptDom;
133
+ });
134
+ const onValuesChange = (0, import_ahooks.useDebounceFn)(
135
+ (changedFields, allFields) => {
136
+ handleValuesChange(changedFields, allFields);
137
+ },
138
+ { wait: 300 }
139
+ ).run;
140
+ const searchDom = (0, import_react.useMemo)(() => {
141
+ return (search == null ? void 0 : search.show) ? /* @__PURE__ */ import_react.default.createElement(
142
+ import_Input.default,
143
+ {
144
+ name: search.key || "_keywords",
145
+ placeholder: search.placeholder,
146
+ renderMode: "edit",
147
+ prefix: /* @__PURE__ */ import_react.default.createElement(import_icons.SearchOutlined, null),
148
+ style: { width: 200 }
149
+ }
150
+ ) : null;
151
+ }, [search]);
152
+ return /* @__PURE__ */ import_react.default.createElement(
153
+ import_antd.Form,
154
+ {
155
+ labelCol: { span: 0 },
156
+ form,
157
+ size: "large",
158
+ layout: "inline",
159
+ className: "filter-form-wrapper",
160
+ onValuesChange
161
+ },
162
+ searchDom,
163
+ filterDom,
164
+ /* @__PURE__ */ import_react.default.createElement(
165
+ import_FilterButton.default,
166
+ {
167
+ value: list,
168
+ quickFilterMaxLength,
169
+ formFiltersPrefix: "",
170
+ onChange,
171
+ renderItem
172
+ }
173
+ )
174
+ );
175
+ };
176
+ var filter_default = Filter;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { FilterItemProps } from '../../../filter/types';
3
+ import { DataSourceType, Field } from '../../provider/dataSource/DataSourceContext';
4
+ export declare const genGetField: (dataSource?: DataSourceType) => (key: string) => Field;
5
+ export declare const field2Cpt: (field: Field, item: any, otherProps?: any) => React.JSX.Element | null;
6
+ export declare const genFilterItems: (list: FilterItemProps[], dataSource?: DataSourceType) => (React.JSX.Element | null)[];
7
+ export declare const getStoredFilterOrder: (componentId: string) => any;
8
+ export declare const saveFilterOrder: (componentId: string, order: any) => void;
@@ -0,0 +1,176 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/components/dataSourceComponents/dataSourceTable/filter/utils.tsx
30
+ var utils_exports = {};
31
+ __export(utils_exports, {
32
+ field2Cpt: () => field2Cpt,
33
+ genFilterItems: () => genFilterItems,
34
+ genGetField: () => genGetField,
35
+ getStoredFilterOrder: () => getStoredFilterOrder,
36
+ saveFilterOrder: () => saveFilterOrder
37
+ });
38
+ module.exports = __toCommonJS(utils_exports);
39
+ var import_react = __toESM(require("react"));
40
+ var import_utils = require("@pisell/utils");
41
+ var import_fields = require("../../fields");
42
+ var genGetField = (dataSource) => {
43
+ const { fields = [] } = dataSource || {};
44
+ const fieldMap = fields.reduce((acc, field) => {
45
+ acc[field.name] = field;
46
+ return acc;
47
+ }, {});
48
+ return (key) => {
49
+ return fieldMap[key];
50
+ };
51
+ };
52
+ var fieldType2FilterMap = {
53
+ Checkbox: "Select",
54
+ ColorPicker: "Input",
55
+ DatePicker: "DateRangePicker",
56
+ Input: "Input",
57
+ Radio: "Select",
58
+ Select: "Select",
59
+ Percent: "Percent",
60
+ InputNumber: "Input",
61
+ "Input.JSON": "Input",
62
+ "Input.URL": "Input",
63
+ "Input.Password": "Input",
64
+ "Radio.Group": "Select",
65
+ "Checkbox.Group": "Select"
66
+ };
67
+ var getCptProps = (field, cptType, item) => {
68
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
69
+ let props = ((_a = field == null ? void 0 : field.uiSchema) == null ? void 0 : _a["x-component-props"]) || {};
70
+ props.style = {
71
+ ...(props == null ? void 0 : props.style) || {},
72
+ width: "200px"
73
+ };
74
+ props.placeholder = item.label;
75
+ props.allowClear = true;
76
+ if (cptType === "Select") {
77
+ props.mode = "multiple";
78
+ }
79
+ if (["Select", "Radio.Group", "Checkbox.Group"].includes(
80
+ (_b = field == null ? void 0 : field.uiSchema) == null ? void 0 : _b["x-component"]
81
+ ) && (((_d = (_c = field == null ? void 0 : field.uiSchema) == null ? void 0 : _c.enum) == null ? void 0 : _d.length) || 0) > 0) {
82
+ if (["Radio.Group", "Checkbox.Group"].includes(
83
+ (_e = field == null ? void 0 : field.uiSchema) == null ? void 0 : _e["x-component"]
84
+ )) {
85
+ props.direction = "horizontal";
86
+ }
87
+ props.options = (_f = field == null ? void 0 : field.uiSchema) == null ? void 0 : _f.enum;
88
+ }
89
+ if (((_g = field == null ? void 0 : field.uiSchema) == null ? void 0 : _g["x-component"]) === "ColorPicker") {
90
+ props.defaultValue = (_h = field == null ? void 0 : field.uiSchema) == null ? void 0 : _h.default;
91
+ }
92
+ if (cptType === "DateRangePicker") {
93
+ props.style = {
94
+ ...(props == null ? void 0 : props.style) || {},
95
+ width: "240px"
96
+ };
97
+ }
98
+ if (((_i = field == null ? void 0 : field.uiSchema) == null ? void 0 : _i["x-component"]) === "Checkbox" && cptType === "Select") {
99
+ props.mode = void 0;
100
+ props.allowClear = true;
101
+ props.options = [
102
+ {
103
+ label: "是",
104
+ value: true
105
+ },
106
+ {
107
+ label: "否",
108
+ value: false
109
+ }
110
+ ];
111
+ }
112
+ return props;
113
+ };
114
+ var field2Cpt = (field, item, otherProps) => {
115
+ const { isCustom, type: configType } = item;
116
+ const { uiSchema } = field || {};
117
+ const { "x-component": xComponent } = uiSchema || {};
118
+ let cptType = fieldType2FilterMap[xComponent];
119
+ if (isCustom) {
120
+ cptType = configType;
121
+ }
122
+ const Cpt = import_fields.formFieldMap[cptType];
123
+ if (!Cpt) {
124
+ return null;
125
+ }
126
+ const props = getCptProps(field, cptType, item);
127
+ const style = (0, import_utils.isFunction)(otherProps == null ? void 0 : otherProps.style) ? otherProps == null ? void 0 : otherProps.style(props.style) : (otherProps == null ? void 0 : otherProps.style) ? { ...props.style, ...otherProps == null ? void 0 : otherProps.style } : props.style;
128
+ return /* @__PURE__ */ import_react.default.createElement(
129
+ Cpt,
130
+ {
131
+ ...props,
132
+ label: item.label,
133
+ name: item.name || item.value,
134
+ ...otherProps,
135
+ style
136
+ }
137
+ );
138
+ };
139
+ var genFilterItems = (list, dataSource) => {
140
+ return list.map((item) => {
141
+ if (!item) {
142
+ return null;
143
+ }
144
+ const { name } = item;
145
+ const getField = genGetField(dataSource);
146
+ const field = getField(name);
147
+ const cptDom = field2Cpt(field, item);
148
+ return cptDom;
149
+ });
150
+ };
151
+ var FILTER_STORAGE_KEY = "filter-setting-";
152
+ var getStorageKey = (componentId) => `${FILTER_STORAGE_KEY}${componentId}`;
153
+ var getStoredFilterOrder = (componentId) => {
154
+ try {
155
+ const stored = localStorage.getItem(getStorageKey(componentId));
156
+ return stored ? JSON.parse(stored) : null;
157
+ } catch (e) {
158
+ console.error("Failed to parse stored filter order:", e);
159
+ return null;
160
+ }
161
+ };
162
+ var saveFilterOrder = (componentId, order) => {
163
+ try {
164
+ localStorage.setItem(getStorageKey(componentId), JSON.stringify(order));
165
+ } catch (e) {
166
+ console.error("Failed to save filter order:", e);
167
+ }
168
+ };
169
+ // Annotate the CommonJS export names for ESM import in node:
170
+ 0 && (module.exports = {
171
+ field2Cpt,
172
+ genFilterItems,
173
+ genGetField,
174
+ getStoredFilterOrder,
175
+ saveFilterOrder
176
+ });
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  declare const useDataSourceKey: () => {
3
- dataSourceKey: string;
4
- dataSourceKeyRef: import("react").MutableRefObject<string>;
3
+ dataSourceKey: string | undefined;
4
+ dataSourceKeyRef: import("react").MutableRefObject<string | undefined>;
5
5
  };
6
6
  export default useDataSourceKey;