@pisell/materials 1.0.471 → 1.0.473

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 (279) 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 +142 -142
  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 +15 -15
  11. package/es/components/dataSourceComponents/dataSourceForm/index.less +1 -1
  12. package/es/components/dataSourceComponents/dataSourceForm/provider/hooks/useJsonPrefixPath.d.ts +4 -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 +52 -4
  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/table/Actions/index.js +16 -7
  106. package/es/components/table/Gallery/index.d.ts +3 -3
  107. package/es/components/table/Gallery/index.js +25 -7
  108. package/es/components/table/Gallery/index.less +1 -0
  109. package/es/components/table/Header/index.d.ts +10 -3
  110. package/es/components/table/Header/index.js +37 -11
  111. package/es/components/table/Header/index.less +10 -2
  112. package/es/components/table/Table/utils.js +4 -0
  113. package/es/components/table/Tabs/index.d.ts +14 -0
  114. package/es/components/table/Tabs/index.js +37 -0
  115. package/es/components/table/hooks/useTriggerValuesChange.js +3 -0
  116. package/es/components/table/index.js +16 -3
  117. package/es/components/table/types.d.ts +14 -2
  118. package/es/components/typography/index.d.ts +2 -2
  119. package/es/components/typography/index.js +4 -3
  120. package/es/index.d.ts +4 -0
  121. package/es/index.js +5 -1
  122. package/es/locales/en-US.d.ts +7 -0
  123. package/es/locales/en-US.js +16 -1
  124. package/es/locales/zh-CN.d.ts +7 -0
  125. package/es/locales/zh-CN.js +16 -1
  126. package/es/locales/zh-TW.d.ts +7 -0
  127. package/es/locales/zh-TW.js +16 -1
  128. package/lib/components/dataSourceComponents/dataSourceForm/index.less +1 -1
  129. package/lib/components/dataSourceComponents/dataSourceForm/provider/hooks/useJsonPrefixPath.d.ts +4 -1
  130. package/lib/components/dataSourceComponents/dataSourceForm/serve.d.ts +1 -0
  131. package/lib/components/dataSourceComponents/dataSourceForm/serve.js +3 -2
  132. package/lib/components/dataSourceComponents/dataSourceForm/utils.d.ts +2 -2
  133. package/lib/components/dataSourceComponents/dataSourceForm/utils.js +58 -11
  134. package/lib/components/dataSourceComponents/dataSourceShow/dataSourceImage/index.d.ts +3 -0
  135. package/lib/components/dataSourceComponents/dataSourceShow/dataSourceImage/index.js +38 -0
  136. package/lib/components/dataSourceComponents/dataSourceShow/dataSourceQRCode/index.d.ts +3 -0
  137. package/lib/components/dataSourceComponents/dataSourceShow/dataSourceQRCode/index.js +38 -0
  138. package/lib/components/dataSourceComponents/dataSourceShow/dataSourceTypography/index.d.ts +10 -0
  139. package/lib/components/dataSourceComponents/dataSourceShow/dataSourceTypography/index.js +44 -0
  140. package/lib/components/dataSourceComponents/dataSourceShow/utils.d.ts +6 -0
  141. package/lib/components/dataSourceComponents/dataSourceShow/utils.js +95 -0
  142. package/lib/components/dataSourceComponents/dataSourceTable/BaseTable.js +29 -90
  143. package/lib/components/dataSourceComponents/dataSourceTable/filter/index.d.ts +25 -0
  144. package/lib/components/dataSourceComponents/dataSourceTable/filter/index.js +176 -0
  145. package/lib/components/dataSourceComponents/dataSourceTable/filter/utils.d.ts +8 -0
  146. package/lib/components/dataSourceComponents/dataSourceTable/filter/utils.js +176 -0
  147. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useDataSourceKey.d.ts +2 -2
  148. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useDataSourceKey.js +1 -1
  149. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useDesignMode.js +24 -37
  150. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useDrawerState.d.ts +20 -4
  151. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useDrawerState.js +53 -7
  152. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useFormat.d.ts +17 -1
  153. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useFormat.js +73 -3
  154. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +77 -0
  155. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.js +236 -0
  156. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableQuery.d.ts +20 -7
  157. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableQuery.js +38 -11
  158. package/lib/components/dataSourceComponents/dataSourceTable/index.d.ts +1 -0
  159. package/lib/components/dataSourceComponents/dataSourceTable/index.js +1 -0
  160. package/lib/components/dataSourceComponents/dataSourceTable/index.less +5 -0
  161. package/lib/components/dataSourceComponents/dataSourceTable/type.d.ts +57 -9
  162. package/lib/components/dataSourceComponents/dataSourceWrapper/BaseWrapper.d.ts +7 -0
  163. package/lib/components/dataSourceComponents/dataSourceWrapper/BaseWrapper.js +51 -0
  164. package/lib/components/dataSourceComponents/dataSourceWrapper/index.d.ts +2 -4
  165. package/lib/components/dataSourceComponents/dataSourceWrapper/index.js +14 -2
  166. package/lib/components/dataSourceComponents/fields/Checkbox/ReadPretty.js +3 -1
  167. package/lib/components/dataSourceComponents/fields/Checkbox/index.js +3 -1
  168. package/lib/components/dataSourceComponents/fields/DatePicker/index.js +5 -1
  169. package/lib/components/dataSourceComponents/fields/DateRangePicker/ReadPretty.d.ts +4 -0
  170. package/lib/components/dataSourceComponents/fields/DateRangePicker/ReadPretty.js +41 -0
  171. package/lib/components/dataSourceComponents/fields/DateRangePicker/WithMode.d.ts +4 -0
  172. package/lib/components/dataSourceComponents/fields/DateRangePicker/WithMode.js +42 -0
  173. package/lib/components/dataSourceComponents/fields/DateRangePicker/index.d.ts +4 -0
  174. package/lib/components/dataSourceComponents/fields/DateRangePicker/index.js +39 -0
  175. package/lib/components/dataSourceComponents/fields/DateRangePicker/index.less +14 -0
  176. package/lib/components/dataSourceComponents/fields/DateRangePicker/type.d.ts +4 -0
  177. package/lib/components/dataSourceComponents/fields/DateRangePicker/type.js +17 -0
  178. package/lib/components/dataSourceComponents/fields/Input/index.d.ts +6 -1
  179. package/lib/components/dataSourceComponents/fields/Input/index.js +4 -0
  180. package/lib/components/dataSourceComponents/fields/Input.Email/ReadPretty.d.ts +4 -0
  181. package/lib/components/dataSourceComponents/fields/Input.Email/ReadPretty.js +39 -0
  182. package/lib/components/dataSourceComponents/fields/Input.Email/WithMode.d.ts +4 -0
  183. package/lib/components/dataSourceComponents/fields/Input.Email/WithMode.js +57 -0
  184. package/lib/components/dataSourceComponents/fields/Input.Email/index.d.ts +3 -0
  185. package/lib/components/dataSourceComponents/fields/Input.Email/index.js +38 -0
  186. package/lib/components/dataSourceComponents/fields/Input.Email/type.d.ts +5 -0
  187. package/lib/components/dataSourceComponents/fields/Input.Email/type.js +17 -0
  188. package/lib/components/dataSourceComponents/fields/Input.Json/ReadPretty.js +2 -2
  189. package/lib/components/dataSourceComponents/fields/Input.Json/WithMode.d.ts +2 -2
  190. package/lib/components/dataSourceComponents/fields/Input.Json/WithMode.js +30 -2
  191. package/lib/components/dataSourceComponents/fields/Input.Json/index.d.ts +1 -1
  192. package/lib/components/dataSourceComponents/fields/Input.Phone/ReadPretty.d.ts +4 -0
  193. package/lib/components/dataSourceComponents/fields/Input.Phone/ReadPretty.js +39 -0
  194. package/lib/components/dataSourceComponents/fields/Input.Phone/WithMode.d.ts +4 -0
  195. package/lib/components/dataSourceComponents/fields/Input.Phone/WithMode.js +43 -0
  196. package/lib/components/dataSourceComponents/fields/Input.Phone/index.d.ts +3 -0
  197. package/lib/components/dataSourceComponents/fields/Input.Phone/index.js +38 -0
  198. package/lib/components/dataSourceComponents/fields/Input.Phone/type.d.ts +5 -0
  199. package/lib/components/dataSourceComponents/fields/Input.Phone/type.js +17 -0
  200. package/lib/components/dataSourceComponents/fields/InputNumber/index.js +5 -1
  201. package/lib/components/dataSourceComponents/fields/Select/index.d.ts +1 -1
  202. package/lib/components/dataSourceComponents/fields/index.d.ts +52 -4
  203. package/lib/components/dataSourceComponents/fields/index.js +6 -1
  204. package/lib/components/dataSourceComponents/fields/type.d.ts +18 -0
  205. package/lib/components/dataSourceComponents/fields/type.js +17 -0
  206. package/lib/components/dataSourceComponents/fields/utils.d.ts +3 -0
  207. package/lib/components/dataSourceComponents/fields/utils.js +134 -0
  208. package/lib/components/dataSourceComponents/hooks/useActions.js +14 -5
  209. package/lib/components/dataSourceComponents/hooks/useComponentId.d.ts +2 -0
  210. package/lib/components/dataSourceComponents/hooks/useComponentId.js +32 -0
  211. package/lib/components/dataSourceComponents/provider/dataSource/DataSourceContext.d.ts +19 -2
  212. package/lib/components/dataSourceComponents/provider/dataSource/DataSourceProvider.d.ts +1 -1
  213. package/lib/components/dataSourceComponents/provider/dataSource/DataSourceProvider.js +29 -16
  214. package/lib/components/dataSourceComponents/provider/variables/VariablesContext.d.ts +3 -2
  215. package/lib/components/dataSourceComponents/provider/variables/VariablesProvider.js +17 -8
  216. package/lib/components/dataSourceComponents/provider/variables/utils.d.ts +2 -0
  217. package/lib/components/dataSourceComponents/provider/variables/utils.js +15 -2
  218. package/lib/components/filter/components/Dropdown/index.d.ts +1 -0
  219. package/lib/components/filter/components/Dropdown/index.js +6 -2
  220. package/lib/components/filter/components/FilterButton/index.js +5 -3
  221. package/lib/components/filter/components/FilterButton/types.d.ts +2 -0
  222. package/lib/components/table/Actions/index.js +18 -9
  223. package/lib/components/table/Gallery/index.d.ts +3 -3
  224. package/lib/components/table/Gallery/index.js +17 -0
  225. package/lib/components/table/Gallery/index.less +1 -0
  226. package/lib/components/table/Header/index.d.ts +10 -3
  227. package/lib/components/table/Header/index.js +29 -4
  228. package/lib/components/table/Header/index.less +10 -2
  229. package/lib/components/table/Table/utils.js +4 -0
  230. package/lib/components/table/Tabs/index.d.ts +14 -0
  231. package/lib/components/table/Tabs/index.js +70 -0
  232. package/lib/components/table/hooks/useTriggerValuesChange.js +3 -0
  233. package/lib/components/table/index.js +17 -2
  234. package/lib/components/table/types.d.ts +14 -2
  235. package/lib/components/typography/index.d.ts +2 -2
  236. package/lib/components/typography/index.js +4 -3
  237. package/lib/index.d.ts +4 -0
  238. package/lib/index.js +12 -0
  239. package/lib/locales/en-US.d.ts +7 -0
  240. package/lib/locales/en-US.js +8 -1
  241. package/lib/locales/zh-CN.d.ts +7 -0
  242. package/lib/locales/zh-CN.js +8 -1
  243. package/lib/locales/zh-TW.d.ts +7 -0
  244. package/lib/locales/zh-TW.js +8 -1
  245. package/lowcode/_utils/defaultSchema.ts +452 -83
  246. package/lowcode/_utils/type.ts +5 -0
  247. package/lowcode/_utils/utils.ts +1 -0
  248. package/lowcode/button/meta.ts +1 -2
  249. package/lowcode/data-source-form/constants.ts +5 -0
  250. package/lowcode/data-source-form/meta.ts +259 -273
  251. package/lowcode/data-source-form/snippets.ts +9 -0
  252. package/lowcode/data-source-form/utils.ts +80 -15
  253. package/lowcode/data-source-image/meta.ts +74 -0
  254. package/lowcode/data-source-image/snippets.ts +14 -0
  255. package/lowcode/data-source-qrcode/meta.ts +158 -0
  256. package/lowcode/data-source-qrcode/snippets.ts +20 -0
  257. package/lowcode/data-source-table/meta.ts +4577 -2285
  258. package/lowcode/data-source-table/snippets.ts +10 -4
  259. package/lowcode/data-source-table/utils.tsx +254 -0
  260. package/lowcode/data-source-typography/meta.ts +54 -0
  261. package/lowcode/data-source-typography.text/meta.ts +212 -0
  262. package/lowcode/data-source-typography.text/snippets.ts +12 -0
  263. package/lowcode/data-source-wrapper/meta.ts +243 -0
  264. package/lowcode/data-source-wrapper/snippets.ts +11 -0
  265. package/lowcode/data-source-wrapper/utils.ts +45 -0
  266. package/lowcode/form-item-color-picker/snippets.ts +1 -0
  267. package/lowcode/form-item-input/meta.ts +2 -1
  268. package/lowcode/form-item-input/snippets.ts +2 -1
  269. package/lowcode/form-item-input.email/meta.ts +284 -0
  270. package/lowcode/form-item-input.email/snippets.ts +35 -0
  271. package/lowcode/form-item-input.phone/meta.ts +295 -0
  272. package/lowcode/form-item-input.phone/snippets.ts +16 -0
  273. package/lowcode/form-item-input.text-area/meta.ts +243 -32
  274. package/lowcode/form-item-input.text-area/snippets.ts +2 -1
  275. package/lowcode/form-item-input.url/meta.ts +44 -20
  276. package/lowcode/form-item-input.url/snippets.ts +5 -5
  277. package/lowcode/table/snippets.ts +6 -0
  278. package/lowcode/test/meta.ts +1 -2
  279. package/package.json +2 -2
@@ -1,7 +1,99 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
5
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
6
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
7
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
8
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
9
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
10
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
12
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
1
13
  import { useMemoizedFn } from 'ahooks';
14
+ import { formFieldFilterFuncMap } from "../../fields/utils";
15
+ import { isArr } from '@pisell/utils';
16
+ // 转换过滤条件
17
+ var formatFilter = function formatFilter(filterValue, fields) {
18
+ var conditions = [];
19
+ if (!filterValue || !(fields !== null && fields !== void 0 && fields.length)) {
20
+ return JSON.stringify({});
21
+ }
22
+
23
+ // 处理关键字搜索
24
+ if (filterValue._keywords) {
25
+ var keywordFields = fields.filter(function (item) {
26
+ return ['string', 'number', 'text'].includes(item.type);
27
+ }).map(function (item) {
28
+ return _defineProperty({}, item.name, {
29
+ $includes: filterValue._keywords
30
+ });
31
+ });
32
+ if (keywordFields.length > 0) {
33
+ conditions.push({
34
+ $or: keywordFields
35
+ });
36
+ }
37
+ }
38
+ var fieldsMap = fields.reduce(function (acc, field) {
39
+ if (field.name) {
40
+ acc[field.name] = field;
41
+ }
42
+ return acc;
43
+ }, {});
44
+
45
+ // 处理其他过滤条件
46
+ var normalConditions = [];
47
+ Object.entries(filterValue).forEach(function (_ref2) {
48
+ var _field$uiSchema;
49
+ var _ref3 = _slicedToArray(_ref2, 2),
50
+ key = _ref3[0],
51
+ value = _ref3[1];
52
+ if (key === '_keywords' || value === undefined || value === null || value === '' || isArr(value) && value.length === 0) {
53
+ return;
54
+ }
55
+ var field = fieldsMap[key];
56
+ if (!(field !== null && field !== void 0 && (_field$uiSchema = field.uiSchema) !== null && _field$uiSchema !== void 0 && _field$uiSchema['x-component'])) {
57
+ return;
58
+ }
59
+ var filterFunc = formFieldFilterFuncMap[field.uiSchema['x-component']];
60
+ if (!filterFunc) {
61
+ return;
62
+ }
63
+ var condition = filterFunc(value, field);
64
+ if (condition) {
65
+ normalConditions.push(_defineProperty({}, key, condition));
66
+ }
67
+ });
68
+ if (normalConditions.length > 0) {
69
+ conditions.push({
70
+ $and: normalConditions
71
+ });
72
+ }
73
+ var filterCondition = conditions.length ? {
74
+ $and: conditions
75
+ } : {};
76
+ return JSON.stringify(filterCondition);
77
+ };
78
+
79
+ // 转换排序条件
80
+ var formatSort = function formatSort(sortValue) {
81
+ if (!sortValue) return undefined;
82
+ var _sortValue$split = sortValue.split(':'),
83
+ _sortValue$split2 = _slicedToArray(_sortValue$split, 2),
84
+ field = _sortValue$split2[0],
85
+ order = _sortValue$split2[1];
86
+ var prefix = order === 'desc' ? '-' : '';
87
+ return ["".concat(prefix).concat(field)];
88
+ };
89
+ var customApiFormatFilter = function customApiFormatFilter(filter) {
90
+ return _objectSpread({}, filter);
91
+ };
92
+
2
93
  // 数据格式化
3
- var useFormat = function useFormat(_ref) {
4
- var dataSourceKey = _ref.dataSourceKey;
94
+ var useFormat = function useFormat(_ref4) {
95
+ var dataSourceKey = _ref4.dataSourceKey,
96
+ fields = _ref4.fields;
5
97
  // list接口请求 结果格式化
6
98
  var formatListResult = useMemoizedFn(function (res) {
7
99
  if (dataSourceKey === 'pisell2-api' && 'list' in res) {
@@ -25,11 +117,18 @@ var useFormat = function useFormat(_ref) {
25
117
 
26
118
  // list接口请求 参数格式化
27
119
  var formatListParams = useMemoizedFn(function (params) {
120
+ // 如果dataSourceKey为空 则为标准数据源
121
+ if (!dataSourceKey) {
122
+ return _objectSpread(_objectSpread({}, params), {}, {
123
+ filter: formatFilter(params.filter, fields),
124
+ sort: formatSort(params.sort)
125
+ });
126
+ }
28
127
  if (dataSourceKey === 'pisell2-api') {
29
- return {
30
- page: params.page,
31
- size: params.pageSize
32
- };
128
+ return _objectSpread({
129
+ page: (params === null || params === void 0 ? void 0 : params.page) || 1,
130
+ size: (params === null || params === void 0 ? void 0 : params.pageSize) || 10
131
+ }, customApiFormatFilter(params.filter || {}));
33
132
  }
34
133
  return params;
35
134
  });
@@ -0,0 +1,77 @@
1
+ import React from 'react';
2
+ import { DataSourceTableProps } from '../type';
3
+ import { OperationItem } from '../type';
4
+ interface UseTablePropsProps {
5
+ data: any;
6
+ originProps: DataSourceTableProps;
7
+ openDrawer: (type: OperationItem) => void;
8
+ closeDrawer: () => void;
9
+ refreshData: () => void;
10
+ handleFilterChange: (changedFields: any, allFields: any) => void;
11
+ }
12
+ /**
13
+ * 处理table的props
14
+ * 转换title
15
+ * @param props
16
+ * @returns
17
+ */
18
+ declare const useTableProps: (props: UseTablePropsProps) => {
19
+ title: number | boolean | React.JSX.Element | Iterable<React.ReactNode> | (() => React.ReactNode) | null | undefined;
20
+ pagination: {
21
+ total: number;
22
+ current: number;
23
+ pageSize: number;
24
+ size: string;
25
+ showSizeChanger: boolean;
26
+ };
27
+ columns: import("./useColumns").Column[];
28
+ subTitle: number | boolean | React.JSX.Element | Iterable<React.ReactNode> | (() => React.ReactNode) | null | undefined;
29
+ buttons: any[] | null;
30
+ filter: React.JSX.Element | null;
31
+ onRow: (record: any) => any;
32
+ titleButtons?: {
33
+ show: boolean;
34
+ maxCount: number;
35
+ items: OperationItem[];
36
+ } | undefined;
37
+ operation?: {
38
+ show: boolean;
39
+ title: string;
40
+ width: number;
41
+ align: "center" | "left" | "right";
42
+ fixed: false | "left" | "right";
43
+ type: "button" | "link";
44
+ items: OperationItem[];
45
+ } | undefined;
46
+ operationContent?: {
47
+ [key: string]: React.ReactNode;
48
+ } | undefined;
49
+ dataSource: import("../../provider/dataSource/DataSourceContext").DataSourceType;
50
+ search?: {
51
+ show: boolean;
52
+ placeholder: string;
53
+ } | undefined;
54
+ __designMode: string;
55
+ componentId: string;
56
+ clickToDetail?: {
57
+ show: boolean;
58
+ useCustomAction: boolean;
59
+ actionType: string;
60
+ openMode: "modal" | "drawer";
61
+ openContentSize: "small" | "middle" | "large";
62
+ openTitle: string;
63
+ key: string;
64
+ } | undefined;
65
+ filterBy?: Record<string, any> | undefined;
66
+ sortBy: string;
67
+ tabs?: {
68
+ show: boolean;
69
+ type: string;
70
+ items: {
71
+ name: string;
72
+ filterBy: Record<string, any>;
73
+ sortBy: string;
74
+ }[];
75
+ } | undefined;
76
+ };
77
+ export default useTableProps;
@@ -0,0 +1,245 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
5
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
7
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
8
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
9
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
10
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
11
+ import React, { useMemo } from 'react';
12
+ import { Button, Space, message, Modal } from 'antd';
13
+ import { isString } from '@pisell/utils';
14
+ import Filter from "../filter";
15
+ import usePagination from "./usePagination";
16
+ import useColumns from "./useColumns";
17
+ import useVariables from "../../hooks/useVariables";
18
+ import useComponentId from "../../hooks/useComponentId";
19
+ import useDataSource from "../../hooks/useDataSource";
20
+ import { useMemoizedFn } from 'ahooks';
21
+ /**
22
+ * 处理table的props
23
+ * 转换title
24
+ * @param props
25
+ * @returns
26
+ */
27
+ var useTableProps = function useTableProps(props) {
28
+ var _originProps$dataSour;
29
+ var originProps = props.originProps,
30
+ openDrawer = props.openDrawer,
31
+ closeDrawer = props.closeDrawer,
32
+ refreshData = props.refreshData,
33
+ handleFilterChange = props.handleFilterChange;
34
+ var propsTitle = originProps.title,
35
+ propsSubTitle = originProps.subTitle,
36
+ titleButtons = originProps.titleButtons,
37
+ operation = originProps.operation,
38
+ propsFilter = originProps.filter,
39
+ search = originProps.search,
40
+ clickToDetail = originProps.clickToDetail,
41
+ propsOnRow = originProps.onRow,
42
+ filterBy = originProps.filterBy;
43
+ var _ref = operation || {},
44
+ items = _ref.items,
45
+ show = _ref.show,
46
+ operationTitle = _ref.title,
47
+ width = _ref.width,
48
+ align = _ref.align,
49
+ fixed = _ref.fixed,
50
+ type = _ref.type;
51
+ var componentId = useComponentId(originProps);
52
+ var _useDataSource = useDataSource(),
53
+ list = _useDataSource.list,
54
+ destroy = _useDataSource.destroy;
55
+ var data = list.data;
56
+ var pagination = usePagination({
57
+ data: data
58
+ });
59
+ var _useVariables = useVariables(),
60
+ registerValueVariable = _useVariables.registerValueVariable;
61
+
62
+ // 表格标题 如果是字符串则包裹className 否则直接返回
63
+ var title = useMemo(function () {
64
+ if (isString(propsTitle)) {
65
+ return /*#__PURE__*/React.createElement("span", {
66
+ className: "data-source-table-title"
67
+ }, propsTitle);
68
+ }
69
+ return propsTitle;
70
+ }, [propsTitle]);
71
+
72
+ // 表格副标题 如果是字符串则包裹className 否则直接返回
73
+ var subTitle = useMemo(function () {
74
+ if (isString(propsSubTitle)) {
75
+ return /*#__PURE__*/React.createElement("span", {
76
+ className: "data-source-table-sub-title"
77
+ }, propsSubTitle);
78
+ }
79
+ return propsSubTitle;
80
+ }, [propsSubTitle]);
81
+
82
+ // 打开抽屉
83
+ var handleOpenDrawer = useMemoizedFn(function (record, item) {
84
+ registerValueVariable === null || registerValueVariable === void 0 ? void 0 : registerValueVariable(componentId, {
85
+ currentRecord: record
86
+ });
87
+ openDrawer(item);
88
+ });
89
+
90
+ // 删除记录
91
+ var handleDelete = useMemoizedFn( /*#__PURE__*/function () {
92
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(record) {
93
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
94
+ while (1) switch (_context2.prev = _context2.next) {
95
+ case 0:
96
+ try {
97
+ registerValueVariable === null || registerValueVariable === void 0 ? void 0 : registerValueVariable(componentId, {
98
+ currentRecord: record
99
+ });
100
+ setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
101
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
102
+ while (1) switch (_context.prev = _context.next) {
103
+ case 0:
104
+ _context.next = 2;
105
+ return destroy === null || destroy === void 0 ? void 0 : destroy.run(record.id);
106
+ case 2:
107
+ refreshData();
108
+ case 3:
109
+ case "end":
110
+ return _context.stop();
111
+ }
112
+ }, _callee);
113
+ })));
114
+ } catch (error) {
115
+ console.error(error);
116
+ message.error('删除失败,请重试');
117
+ }
118
+ case 1:
119
+ case "end":
120
+ return _context2.stop();
121
+ }
122
+ }, _callee2);
123
+ }));
124
+ return function (_x) {
125
+ return _ref2.apply(this, arguments);
126
+ };
127
+ }());
128
+
129
+ // 操作列
130
+ var actionsColumns = useMemo(function () {
131
+ if (!show) {
132
+ return [];
133
+ }
134
+ return [{
135
+ title: operationTitle,
136
+ key: 'actions',
137
+ align: align,
138
+ width: width,
139
+ fixed: fixed,
140
+ items: items,
141
+ type: type,
142
+ render: function render(_, record) {
143
+ return /*#__PURE__*/React.createElement(Space, null, items === null || items === void 0 ? void 0 : items.map(function (item) {
144
+ var label = item.label,
145
+ actionType = item.actionType;
146
+ var handleClick = function handleClick() {
147
+ if (actionType === 'delete') {
148
+ Modal.confirm({
149
+ title: '确认删除',
150
+ content: '确定要删除该条记录吗?',
151
+ okText: '确定',
152
+ cancelText: '取消',
153
+ onOk: function onOk() {
154
+ handleDelete(record);
155
+ }
156
+ });
157
+ return;
158
+ } else {
159
+ handleOpenDrawer(record, item);
160
+ }
161
+ };
162
+ return /*#__PURE__*/React.createElement(Button, {
163
+ onClick: handleClick,
164
+ type: type === 'link' ? 'link' : 'default',
165
+ style: type === 'link' ? {
166
+ padding: '0'
167
+ } : {}
168
+ }, label);
169
+ }));
170
+ }
171
+ }];
172
+ }, [operationTitle, show, width, align, fixed, type, items]);
173
+ var columns = useColumns({
174
+ columns: originProps.columns,
175
+ fields: (_originProps$dataSour = originProps.dataSource) === null || _originProps$dataSour === void 0 ? void 0 : _originProps$dataSour.fields,
176
+ // 操作列
177
+ actionsColumns: actionsColumns
178
+ });
179
+ var buttons = useMemo(function () {
180
+ var _titleButtons$items;
181
+ if (!(titleButtons !== null && titleButtons !== void 0 && titleButtons.show)) {
182
+ return null;
183
+ }
184
+ return titleButtons === null || titleButtons === void 0 ? void 0 : (_titleButtons$items = titleButtons.items) === null || _titleButtons$items === void 0 ? void 0 : _titleButtons$items.map(function (button) {
185
+ var actionType = button.actionType,
186
+ buttonProps = button.buttonProps;
187
+ return _objectSpread(_objectSpread(_objectSpread({}, button), buttonProps), {}, {
188
+ onClick: function onClick() {
189
+ if (actionType === 'add') {
190
+ handleOpenDrawer(null, button);
191
+ }
192
+ }
193
+ });
194
+ });
195
+ }, [titleButtons]);
196
+ var filter = useMemo(function () {
197
+ if (!(propsFilter !== null && propsFilter !== void 0 && propsFilter.show) && !(search !== null && search !== void 0 && search.show)) {
198
+ return null;
199
+ }
200
+ return /*#__PURE__*/React.createElement(Filter, _extends({}, propsFilter, {
201
+ componentId: componentId,
202
+ search: search,
203
+ handleValuesChange: handleFilterChange,
204
+ filterBy: filterBy
205
+ }));
206
+ }, [propsFilter, search]);
207
+ var onRow = useMemoizedFn(function (record) {
208
+ if (!(clickToDetail !== null && clickToDetail !== void 0 && clickToDetail.show)) {
209
+ return propsOnRow;
210
+ }
211
+ return _objectSpread(_objectSpread({}, propsOnRow), {}, {
212
+ onClick: function onClick(event) {
213
+ var _propsOnRow$onClick;
214
+ var detail;
215
+ if (clickToDetail !== null && clickToDetail !== void 0 && clickToDetail.useCustomAction) {
216
+ detail = {
217
+ openMode: clickToDetail === null || clickToDetail === void 0 ? void 0 : clickToDetail.openMode,
218
+ openContentSize: clickToDetail === null || clickToDetail === void 0 ? void 0 : clickToDetail.openContentSize,
219
+ openTitle: clickToDetail === null || clickToDetail === void 0 ? void 0 : clickToDetail.openTitle,
220
+ actionType: clickToDetail === null || clickToDetail === void 0 ? void 0 : clickToDetail.actionType,
221
+ key: clickToDetail === null || clickToDetail === void 0 ? void 0 : clickToDetail.actionType
222
+ };
223
+ } else {
224
+ detail = items === null || items === void 0 ? void 0 : items.find(function (item) {
225
+ return item.key === (clickToDetail === null || clickToDetail === void 0 ? void 0 : clickToDetail.key);
226
+ });
227
+ }
228
+ if (detail) {
229
+ handleOpenDrawer(record, detail);
230
+ }
231
+ propsOnRow === null || propsOnRow === void 0 ? void 0 : (_propsOnRow$onClick = propsOnRow.onClick) === null || _propsOnRow$onClick === void 0 ? void 0 : _propsOnRow$onClick.call(propsOnRow, record, event);
232
+ }
233
+ });
234
+ });
235
+ return _objectSpread(_objectSpread({}, originProps), {}, {
236
+ title: title,
237
+ pagination: pagination,
238
+ columns: columns,
239
+ subTitle: subTitle,
240
+ buttons: buttons,
241
+ filter: filter,
242
+ onRow: onRow
243
+ });
244
+ };
245
+ export default useTableProps;
@@ -1,19 +1,32 @@
1
1
  /// <reference types="react" />
2
- declare const useTableQuery: () => {
2
+ import { DataSourceTableProps } from '../type';
3
+ declare type Params = {
4
+ pagination?: {
5
+ page: number;
6
+ size: number;
7
+ };
8
+ order_by?: string;
9
+ tabs?: {
10
+ name: string;
11
+ filterBy: Record<string, any>;
12
+ sortBy: string;
13
+ };
14
+ };
15
+ declare const useTableQuery: (props: DataSourceTableProps) => {
3
16
  queryPageConfig: {
4
17
  page: number;
5
18
  pageSize: number;
19
+ filter: Record<string, any>;
20
+ sort: string;
6
21
  };
7
22
  setQueryPageConfig: import("react").Dispatch<import("react").SetStateAction<{
8
23
  page: number;
9
24
  pageSize: number;
25
+ filter: Record<string, any>;
26
+ sort: string;
10
27
  }>>;
11
- handleValuesChange: (params: {
12
- pagination: {
13
- page: number;
14
- size: number;
15
- };
16
- }) => void;
28
+ handleValuesChange: (params: Params, allParams: Params) => void;
17
29
  refreshData: () => void;
30
+ handleFilterChange: (changedFields: any, allFields: any) => void;
18
31
  };
19
32
  export default useTableQuery;
@@ -12,27 +12,55 @@ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefine
12
12
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
13
  import { useState } from 'react';
14
14
  import { useMemoizedFn } from 'ahooks';
15
- var useTableQuery = function useTableQuery() {
15
+ var useTableQuery = function useTableQuery(props) {
16
+ var _tabs$items, _tabs$items$, _tabs$items2, _tabs$items2$;
17
+ var filterBy = props.filterBy,
18
+ sortBy = props.sortBy,
19
+ tabs = props.tabs;
20
+
16
21
  // 分页配置
17
22
  var _useState = useState({
18
23
  page: 1,
19
- pageSize: 10
24
+ pageSize: 10,
25
+ filter: (tabs === null || tabs === void 0 ? void 0 : (_tabs$items = tabs.items) === null || _tabs$items === void 0 ? void 0 : (_tabs$items$ = _tabs$items[0]) === null || _tabs$items$ === void 0 ? void 0 : _tabs$items$.filterBy) || filterBy || {},
26
+ sort: (tabs === null || tabs === void 0 ? void 0 : (_tabs$items2 = tabs.items) === null || _tabs$items2 === void 0 ? void 0 : (_tabs$items2$ = _tabs$items2[0]) === null || _tabs$items2$ === void 0 ? void 0 : _tabs$items2$.sortBy) || sortBy
20
27
  }),
21
28
  _useState2 = _slicedToArray(_useState, 2),
22
29
  queryPageConfig = _useState2[0],
23
30
  setQueryPageConfig = _useState2[1];
24
31
 
25
32
  // 分页变化
26
- var handleValuesChange = useMemoizedFn(function (params) {
27
- var _params$pagination = params.pagination,
28
- page = _params$pagination.page,
29
- size = _params$pagination.size;
30
- if (page !== queryPageConfig.page || size !== queryPageConfig.pageSize) {
31
- setQueryPageConfig({
32
- page: size !== queryPageConfig.pageSize ? 1 : page,
33
- pageSize: size
33
+ var handleValuesChange = useMemoizedFn(function (params, allParams) {
34
+ var _ref = params.pagination || {},
35
+ page = _ref.page,
36
+ size = _ref.size;
37
+ setQueryPageConfig(function (prev) {
38
+ var sort = prev.sort || sortBy;
39
+ var filter = prev.filter;
40
+ if ("tabs" in params) {
41
+ var _params$tabs, _params$tabs2;
42
+ sort = ((_params$tabs = params.tabs) === null || _params$tabs === void 0 ? void 0 : _params$tabs.sortBy) || sortBy || "";
43
+ filter = ((_params$tabs2 = params.tabs) === null || _params$tabs2 === void 0 ? void 0 : _params$tabs2.filterBy) || {};
44
+ }
45
+ if ("order_by" in params) {
46
+ var _allParams$tabs;
47
+ sort = params.order_by || ((_allParams$tabs = allParams.tabs) === null || _allParams$tabs === void 0 ? void 0 : _allParams$tabs.sortBy) || sortBy;
48
+ }
49
+ return _objectSpread(_objectSpread({}, prev), {}, {
50
+ page: size !== prev.pageSize ? 1 : page !== null && page !== void 0 ? page : prev.page,
51
+ pageSize: size !== null && size !== void 0 ? size : prev.pageSize,
52
+ sort: sort,
53
+ filter: filter
34
54
  });
35
- }
55
+ });
56
+ });
57
+ var handleFilterChange = useMemoizedFn(function (changedFields, allFields) {
58
+ setQueryPageConfig(function (prev) {
59
+ return _objectSpread(_objectSpread({}, prev), {}, {
60
+ page: 1,
61
+ filter: _objectSpread(_objectSpread({}, allFields), filterBy || {})
62
+ });
63
+ });
36
64
  });
37
65
  var refreshData = useMemoizedFn(function () {
38
66
  setQueryPageConfig(function (prev) {
@@ -45,7 +73,8 @@ var useTableQuery = function useTableQuery() {
45
73
  queryPageConfig: queryPageConfig,
46
74
  setQueryPageConfig: setQueryPageConfig,
47
75
  handleValuesChange: handleValuesChange,
48
- refreshData: refreshData
76
+ refreshData: refreshData,
77
+ handleFilterChange: handleFilterChange
49
78
  };
50
79
  };
51
80
  export default useTableQuery;
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import "./index.less";
2
3
  import { DataSourceTableProps } from './type';
3
4
  declare const DataSourceTable: (props: DataSourceTableProps) => React.JSX.Element;
4
5
  export default DataSourceTable;
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import BaseTable from "./BaseTable";
3
3
  import DataSourceProvider from "../provider/dataSource/DataSourceProvider";
4
+ import "./index.less";
4
5
  var DataSourceTable = function DataSourceTable(props) {
5
6
  var dataSource = props.dataSource;
6
7
  return /*#__PURE__*/React.createElement(DataSourceProvider, {
@@ -0,0 +1,5 @@
1
+ .data-source-table-title {
2
+ color: #101828;
3
+ font-weight: 600;
4
+ font-size: 20px;
5
+ }