@spacego/fe-components 0.1.0 → 0.2.0

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 (205) hide show
  1. package/README.md +37 -37
  2. package/lib/_virtual/Resizable.js +4 -0
  3. package/lib/_virtual/ResizableBox.js +4 -0
  4. package/lib/_virtual/index.js +5 -0
  5. package/lib/_virtual/index2.js +4 -0
  6. package/lib/_virtual/index3.js +4 -0
  7. package/lib/_virtual/index4.js +4 -0
  8. package/lib/_virtual/propTypes.js +4 -0
  9. package/lib/_virtual/react-is.development.js +4 -0
  10. package/lib/_virtual/react-is.production.min.js +4 -0
  11. package/lib/_virtual/utils.js +4 -0
  12. package/lib/fe-auto-complete/index.js +6 -0
  13. package/lib/fe-button/index.js +27 -0
  14. package/lib/fe-cascader/index.js +19 -0
  15. package/lib/fe-checkbox/index.js +6 -0
  16. package/lib/fe-checkbox-group/index.js +6 -0
  17. package/lib/fe-date-picker/index.js +19 -0
  18. package/lib/fe-description-render/index.js +43 -0
  19. package/lib/fe-descriptions/index.js +6 -0
  20. package/lib/fe-empty/index.js +6 -0
  21. package/lib/fe-error-block/index.js +6 -0
  22. package/lib/fe-form/fe-form/index.js +133 -0
  23. package/lib/fe-form/fe-form-auto-complete/index.js +57 -0
  24. package/lib/fe-form/fe-form-btn-group/index.js +29 -0
  25. package/lib/fe-form/fe-form-cascader/index.js +25 -0
  26. package/lib/fe-form/fe-form-checkbox-group/index.js +21 -0
  27. package/lib/fe-form/fe-form-date-picker/index.js +75 -0
  28. package/lib/fe-form/fe-form-date-range-picker/index.js +99 -0
  29. package/lib/fe-form/fe-form-input/index.js +53 -0
  30. package/lib/fe-form/fe-form-input-input/index.js +63 -0
  31. package/lib/fe-form/fe-form-input-number/index.js +43 -0
  32. package/lib/fe-form/fe-form-item/index.js +46 -0
  33. package/lib/fe-form/fe-form-label/index.js +20 -0
  34. package/lib/fe-form/fe-form-radio/index.js +21 -0
  35. package/lib/fe-form/fe-form-render/index.js +33 -0
  36. package/lib/fe-form/fe-form-rich-text/index.js +25 -0
  37. package/lib/fe-form/fe-form-select/index.js +93 -0
  38. package/lib/fe-form/fe-form-switch/index.js +21 -0
  39. package/lib/fe-form/fe-form-text/index.js +20 -0
  40. package/lib/fe-form/fe-form-text-area/index.js +24 -0
  41. package/lib/fe-form/fe-form-time-picker/index.js +21 -0
  42. package/lib/fe-form/fe-form-upload/index.js +63 -0
  43. package/lib/fe-form/utils/index.js +28 -0
  44. package/lib/fe-input/index.js +32 -0
  45. package/lib/fe-input-number/index.js +19 -0
  46. package/lib/fe-layouts/auth-layout/index.js +35 -17
  47. package/lib/fe-layouts/basics-layout/index.js +2 -2
  48. package/lib/fe-layouts/layout.js +34 -16
  49. package/lib/fe-link/index.js +23 -0
  50. package/lib/fe-map/index.js +263 -0
  51. package/lib/fe-modal/index.js +85 -0
  52. package/lib/fe-pagination/index.js +6 -0
  53. package/lib/fe-panel/fe-panel-toolbar.js +40 -0
  54. package/lib/fe-panel/index.js +49 -0
  55. package/lib/fe-panel/use-panel-context.js +9 -0
  56. package/lib/fe-permission/index.js +12 -0
  57. package/lib/fe-permission-provider/index.js +29 -0
  58. package/lib/fe-radio/index.js +11 -0
  59. package/lib/fe-radio-group/index.js +6 -0
  60. package/lib/fe-rich-text/index.js +293 -0
  61. package/lib/fe-select/index.js +24 -0
  62. package/lib/fe-switch/index.js +6 -0
  63. package/lib/fe-table/fe-edit-table/index.js +39 -0
  64. package/lib/fe-table/fe-edit-table-cell/index.js +63 -0
  65. package/lib/fe-table/fe-head-title/index.js +9 -0
  66. package/lib/fe-table/fe-normal-table/index.js +192 -0
  67. package/lib/fe-table/fe-sub-table/index.js +74 -0
  68. package/lib/fe-table/fe-table/index.js +7 -0
  69. package/lib/fe-table/fe-table-alert/index.js +42 -0
  70. package/lib/fe-table/fe-table-link/index.js +87 -0
  71. package/lib/fe-table/fe-table-render/index.js +56 -0
  72. package/lib/fe-table/fe-table-setting/index.js +165 -0
  73. package/lib/fe-table/fe-table-toolbar/index.js +63 -0
  74. package/lib/fe-table/fe-table-utils/index.js +157 -0
  75. package/lib/fe-table/type/table.d.js +4 -0
  76. package/lib/fe-table/use-edit-table/index.js +151 -0
  77. package/lib/fe-table/use-pagination/index.js +59 -0
  78. package/lib/fe-table/use-sub-table/index.js +23 -0
  79. package/lib/fe-table/use-table/index.js +177 -0
  80. package/lib/fe-table/use-table-columns/index.js +53 -0
  81. package/lib/fe-table/use-table-form-context/index.js +14 -0
  82. package/lib/fe-table/use-table-selection/index.js +53 -0
  83. package/lib/fe-text-area/index.js +21 -0
  84. package/lib/fe-time-picker/index.js +19 -0
  85. package/lib/fe-upload/index.js +182 -0
  86. package/lib/fe-upload/upload.constant.js +91 -0
  87. package/lib/fe-upload-atomic/index.js +6 -0
  88. package/lib/fe-upload-crop/index.js +207 -0
  89. package/lib/hooks/{use-auth.hook.js → use-auth.hook/index.js} +3 -3
  90. package/lib/hooks/use-form/index.js +38 -0
  91. package/lib/hooks/use-permission.hook/index.js +9 -0
  92. package/lib/index.css +7 -1
  93. package/lib/index.js +161 -42
  94. package/lib/node_modules/.pnpm/@dnd-kit_accessibility@3.1.1_react@18.3.1/node_modules/@dnd-kit/accessibility/dist/accessibility.esm.js +56 -0
  95. package/lib/node_modules/.pnpm/@dnd-kit_core@6.3.1_nnrd3gsncyragczmpvfhocinkq/node_modules/@dnd-kit/core/dist/core.esm.js +2344 -0
  96. package/lib/node_modules/.pnpm/@dnd-kit_modifiers@9.0.0_55ztycxty3xzw7t4rzpvix55vq/node_modules/@dnd-kit/modifiers/dist/modifiers.esm.js +13 -0
  97. package/lib/node_modules/.pnpm/@dnd-kit_sortable@10.0.0_55ztycxty3xzw7t4rzpvix55vq/node_modules/@dnd-kit/sortable/dist/sortable.esm.js +439 -0
  98. package/lib/node_modules/.pnpm/@dnd-kit_utilities@3.2.2_react@18.3.1/node_modules/@dnd-kit/utilities/dist/utilities.esm.js +235 -0
  99. package/lib/node_modules/.pnpm/object-assign@4.1.1/node_modules/object-assign/index.js +54 -0
  100. package/lib/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/checkPropTypes.js +54 -0
  101. package/lib/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/factoryWithThrowingShims.js +52 -0
  102. package/lib/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/factoryWithTypeCheckers.js +329 -0
  103. package/lib/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.js +17 -0
  104. package/lib/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/lib/ReactPropTypesSecret.js +10 -0
  105. package/lib/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/lib/has.js +7 -0
  106. package/lib/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/cjs/react-is.development.js +95 -0
  107. package/lib/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/cjs/react-is.production.min.js +78 -0
  108. package/lib/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/index.js +10 -0
  109. package/lib/node_modules/.pnpm/react-resizable@3.1.3_nnrd3gsncyragczmpvfhocinkq/node_modules/react-resizable/build/Resizable.js +233 -0
  110. package/lib/node_modules/.pnpm/react-resizable@3.1.3_nnrd3gsncyragczmpvfhocinkq/node_modules/react-resizable/build/ResizableBox.js +164 -0
  111. package/lib/node_modules/.pnpm/react-resizable@3.1.3_nnrd3gsncyragczmpvfhocinkq/node_modules/react-resizable/build/propTypes.js +113 -0
  112. package/lib/node_modules/.pnpm/react-resizable@3.1.3_nnrd3gsncyragczmpvfhocinkq/node_modules/react-resizable/build/utils.js +56 -0
  113. package/lib/node_modules/.pnpm/react-resizable@3.1.3_nnrd3gsncyragczmpvfhocinkq/node_modules/react-resizable/index.js +12 -0
  114. package/lib/store/modules/layout-config.store.js +83 -65
  115. package/lib/store/modules/theme.store.js +36 -18
  116. package/lib/types/fe-auto-complete/index.d.ts +2 -0
  117. package/lib/types/fe-button/index.d.ts +16 -0
  118. package/lib/types/fe-cascader/index.d.ts +7 -0
  119. package/lib/types/fe-checkbox/index.d.ts +6 -0
  120. package/lib/types/fe-checkbox-group/index.d.ts +7 -0
  121. package/lib/types/fe-date-picker/index.d.ts +3 -0
  122. package/lib/types/fe-description-render/index.d.ts +31 -0
  123. package/lib/types/fe-descriptions/index.d.ts +2 -0
  124. package/lib/types/fe-empty/index.d.ts +2 -0
  125. package/lib/types/fe-error-block/index.d.ts +6 -0
  126. package/lib/types/fe-form/fe-form/index.d.ts +356 -0
  127. package/lib/types/fe-form/fe-form-auto-complete/index.d.ts +3 -0
  128. package/lib/types/fe-form/fe-form-btn-group/index.d.ts +3 -0
  129. package/lib/types/fe-form/fe-form-cascader/index.d.ts +3 -0
  130. package/lib/types/fe-form/fe-form-checkbox-group/index.d.ts +3 -0
  131. package/lib/types/fe-form/fe-form-date-picker/index.d.ts +3 -0
  132. package/lib/types/fe-form/fe-form-date-range-picker/index.d.ts +3 -0
  133. package/lib/types/fe-form/fe-form-input/index.d.ts +3 -0
  134. package/lib/types/fe-form/fe-form-input-input/index.d.ts +3 -0
  135. package/lib/types/fe-form/fe-form-input-number/index.d.ts +3 -0
  136. package/lib/types/fe-form/fe-form-item/index.d.ts +70 -0
  137. package/lib/types/fe-form/fe-form-label/index.d.ts +45 -0
  138. package/lib/types/fe-form/fe-form-radio/index.d.ts +3 -0
  139. package/lib/types/fe-form/fe-form-render/index.d.ts +3 -0
  140. package/lib/types/fe-form/fe-form-rich-text/index.d.ts +3 -0
  141. package/lib/types/fe-form/fe-form-select/index.d.ts +3 -0
  142. package/lib/types/fe-form/fe-form-switch/index.d.ts +3 -0
  143. package/lib/types/fe-form/fe-form-text/index.d.ts +3 -0
  144. package/lib/types/fe-form/fe-form-text-area/index.d.ts +3 -0
  145. package/lib/types/fe-form/fe-form-time-picker/index.d.ts +3 -0
  146. package/lib/types/fe-form/fe-form-upload/index.d.ts +3 -0
  147. package/lib/types/fe-form/index.d.ts +26 -0
  148. package/lib/types/fe-form/utils/index.d.ts +24 -0
  149. package/lib/types/fe-input/index.d.ts +12 -0
  150. package/lib/types/fe-input-number/index.d.ts +2 -0
  151. package/lib/types/fe-layouts/context/global-context.d.ts +240 -238
  152. package/lib/types/fe-link/index.d.ts +6 -0
  153. package/lib/types/fe-map/index.d.ts +73 -0
  154. package/lib/types/fe-modal/index.d.ts +20 -0
  155. package/lib/types/fe-pagination/index.d.ts +2 -0
  156. package/lib/types/fe-panel/fe-panel-toolbar.d.ts +3 -0
  157. package/lib/types/fe-panel/index.d.ts +61 -0
  158. package/lib/types/fe-panel/panel-toolbar.d.ts +4 -0
  159. package/lib/types/fe-panel/use-panel-context.d.ts +6 -0
  160. package/lib/types/fe-permission/index.d.ts +10 -0
  161. package/lib/types/fe-permission-provider/index.d.ts +8 -0
  162. package/lib/types/fe-radio/index.d.ts +2 -0
  163. package/lib/types/fe-radio-group/index.d.ts +2 -0
  164. package/lib/types/fe-rich-text/index.d.ts +167 -0
  165. package/lib/types/fe-select/index.d.ts +8 -0
  166. package/lib/types/fe-switch/index.d.ts +2 -0
  167. package/lib/types/fe-table/fe-edit-table/index.d.ts +3 -0
  168. package/lib/types/fe-table/fe-edit-table-cell/index.d.ts +16 -0
  169. package/lib/types/fe-table/fe-head-title/index.d.ts +6 -0
  170. package/lib/types/fe-table/fe-normal-table/index.d.ts +3 -0
  171. package/lib/types/fe-table/fe-sub-table/index.d.ts +3 -0
  172. package/lib/types/fe-table/fe-table/index.d.ts +3 -0
  173. package/lib/types/fe-table/fe-table-alert/index.d.ts +13 -0
  174. package/lib/types/fe-table/fe-table-link/index.d.ts +12 -0
  175. package/lib/types/fe-table/fe-table-render/index.d.ts +13 -0
  176. package/lib/types/fe-table/fe-table-setting/index.d.ts +22 -0
  177. package/lib/types/fe-table/fe-table-toolbar/index.d.ts +18 -0
  178. package/lib/types/fe-table/fe-table-utils/index.d.ts +193 -0
  179. package/lib/types/fe-table/index.d.ts +6 -0
  180. package/lib/types/fe-table/type/table-context.d.ts +60 -0
  181. package/lib/types/fe-table/type/table.d.ts +797 -0
  182. package/lib/types/fe-table/use-edit-table/index.d.ts +6 -0
  183. package/lib/types/fe-table/use-pagination/index.d.ts +3 -0
  184. package/lib/types/fe-table/use-sub-table/index.d.ts +8 -0
  185. package/lib/types/fe-table/use-table/index.d.ts +3 -0
  186. package/lib/types/fe-table/use-table-columns/index.d.ts +47 -0
  187. package/lib/types/fe-table/use-table-form-context/index.d.ts +10 -0
  188. package/lib/types/fe-table/use-table-selection/index.d.ts +46 -0
  189. package/lib/types/fe-text-area/index.d.ts +4 -0
  190. package/lib/types/fe-time-picker/index.d.ts +3 -0
  191. package/lib/types/fe-upload/index.d.ts +85 -0
  192. package/lib/types/fe-upload/upload.constant.d.ts +39 -0
  193. package/lib/types/fe-upload-atomic/index.d.ts +2 -0
  194. package/lib/types/fe-upload-crop/index.d.ts +10 -0
  195. package/lib/types/hooks/index.d.ts +1 -0
  196. package/lib/types/hooks/use-descriptions/index.d.ts +3 -0
  197. package/lib/types/hooks/use-form/index.d.ts +16 -0
  198. package/lib/types/hooks/use-permission.hook/index.d.ts +10 -0
  199. package/lib/types/index.d.ts +32 -0
  200. package/lib/types/typings/index.d.ts +98 -59
  201. package/lib/types/typings/shims-axios.d.ts +38 -38
  202. package/package.json +79 -68
  203. /package/lib/hooks/{use-nprogress.hook.js → use-nprogress.hook/index.js} +0 -0
  204. /package/lib/types/hooks/{use-auth.hook.d.ts → use-auth.hook/index.d.ts} +0 -0
  205. /package/lib/types/hooks/{use-nprogress.hook.d.ts → use-nprogress.hook/index.d.ts} +0 -0
@@ -0,0 +1,157 @@
1
+ import { QuestionCircleOutlined as g } from "@ant-design/icons";
2
+ import { isString as T } from "@spacego/turbo-utils";
3
+ import { Tooltip as I } from "antd";
4
+ import * as h from "react";
5
+ import y from "../fe-table-link/index.js";
6
+ import w from "../fe-table-render/index.js";
7
+ const W = (e, r) => (e === null || Array.isArray(e) && e.length === 0) && r > 1, v = (e, r, t, a = [], s) => !t || !t.length ? [] : y({
8
+ config: t.map((n) => ({
9
+ ...n,
10
+ record: e,
11
+ index: r
12
+ })).filter((n) => !n.hidden || !n.hidden(e, r)).filter((n) => !n.btnPermission || (a || []).includes(n.btnPermission ?? "")),
13
+ modal: s
14
+ }), u = (e) => e == null || e === "", C = (e) => e.render || ((r, t) => {
15
+ var d;
16
+ e.renderType = e.renderType ?? "default";
17
+ const a = () => {
18
+ if (e.defaultRenderParams && e.defaultRenderParams.filter) {
19
+ const l = e.defaultRenderParams.filter(
20
+ t[e.dataIndex],
21
+ ...Object.values(e.defaultRenderParams.dictfilterParams || {})
22
+ );
23
+ return u(l) ? "-" : l;
24
+ }
25
+ return u(t[e.dataIndex]) ? "-" : t[e.dataIndex];
26
+ }, s = () => {
27
+ var p;
28
+ let l = t[e.dataIndex];
29
+ return u(l) ? [] : (T(t[e.dataIndex]) || (l = String(t[e.dataIndex])), l.split(((p = e.tagRenderParams) == null ? void 0 : p.separator) ?? "|").filter((o) => !!o).map((o) => {
30
+ var b, R, c, P;
31
+ return (b = e.tagRenderParams) != null && b.filter && (c = (R = e.tagRenderParams) == null ? void 0 : R.dictfilterParams) != null && c.dictList ? e.tagRenderParams.filter(o, ...Object.values((P = e.tagRenderParams) == null ? void 0 : P.dictfilterParams)) : o;
32
+ }));
33
+ }, n = () => u(t[e.dataIndex]) ? "-" : t[e.dataIndex], i = (d = (/* @__PURE__ */ new Map([
34
+ ["default", a],
35
+ ["tag", s],
36
+ ["thousands", n]
37
+ ])).get(e.renderType)) == null ? void 0 : d();
38
+ return e.renderParams = e.renderParams ?? {
39
+ tooltip: !0,
40
+ maxLines: 2,
41
+ ellipsis: !0
42
+ }, w({
43
+ value: i,
44
+ width: e.width,
45
+ record: t,
46
+ column: e,
47
+ renderType: e.renderType,
48
+ renderParams: e.renderParams,
49
+ tagRenderParams: e.tagRenderParams,
50
+ thousandsParams: e.thousandsParams
51
+ });
52
+ }), B = (e, r = !0, t = 1, a = 10) => {
53
+ if (r && e.findIndex((s) => s.dataIndex === "index") === -1) {
54
+ const s = [...e];
55
+ return s.unshift({
56
+ title: "序号",
57
+ dataIndex: "index",
58
+ key: "index",
59
+ width: 60,
60
+ fixed: "left",
61
+ render: (n, f, i) => t === 1 && a === 10 ? i + 1 : (t - 1) * a + i + 1
62
+ }), s;
63
+ }
64
+ return e;
65
+ }, L = (e, r = [], t = [], a = {}, s) => {
66
+ const n = e.map((d) => ({
67
+ ...d,
68
+ render: C(d)
69
+ })), f = !!r && !!r.length, i = (r || []).filter((d) => !d.btnPermission || (t || []).includes(d.btnPermission ?? ""));
70
+ return f && i.length > 0 && n.findIndex((d) => d.dataIndex === "handle") === -1 && n.push({
71
+ title: "操作",
72
+ dataIndex: "handle",
73
+ key: "handle",
74
+ fixed: (a == null ? void 0 : a.fixed) || "right",
75
+ width: (a == null ? void 0 : a.width) || 160,
76
+ render: (d, l, p) => v(l, p, r, t, s)
77
+ }), n;
78
+ }, m = (e) => e.map((r) => {
79
+ const t = {
80
+ ...r,
81
+ ellipsis: r.ellipsis ?? !0,
82
+ align: r.align ?? "center",
83
+ ...r.ellipsis === !0 ? { ellipsis: { showTitle: !0 } } : {}
84
+ };
85
+ if (r.showHint && r.hintText) {
86
+ const a = r.title;
87
+ t.title = h.createElement(
88
+ "span",
89
+ { style: { display: "inline-flex", alignItems: "center", gap: "4px" } },
90
+ a,
91
+ h.createElement(
92
+ I,
93
+ { title: r.hintText },
94
+ h.createElement(g, { style: { color: "#999", cursor: "help" } })
95
+ )
96
+ );
97
+ }
98
+ return t;
99
+ }), E = (e, r = "id") => {
100
+ const t = {};
101
+ return Object.entries(e).forEach(([a, s]) => {
102
+ if (!a.includes("_")) return;
103
+ const n = a.lastIndexOf("_"), f = a.substring(0, n), i = a.substring(n + 1);
104
+ t[i] || (t[i] = { [r]: i }), t[i][f] = s;
105
+ }), t;
106
+ }, F = (e, r = "id") => String(e[r]), q = (e = [], r, t, a) => e.map((s) => s.validator && typeof s.validator == "function" ? {
107
+ ...s,
108
+ validator: (n, f, i) => {
109
+ const d = x(r, t, a);
110
+ return s.validator(n, f, i, d);
111
+ }
112
+ } : s), x = (e, r, t) => {
113
+ let a = {}, s = { ...e };
114
+ if (t) {
115
+ const n = t.getFieldsValue();
116
+ a = E(n, r);
117
+ const f = F(e, r), i = a[f];
118
+ i && (s = { ...e, ...i });
119
+ }
120
+ return {
121
+ currentRecord: s,
122
+ // 合并了最新表单数据的记录
123
+ allTableData: a,
124
+ form: t
125
+ };
126
+ }, O = (e = {}, r, t, a) => {
127
+ const s = {};
128
+ return Object.entries(e).forEach(([n, f]) => {
129
+ n.startsWith("on") && typeof f == "function" ? s[n] = (...i) => {
130
+ const d = x(r, t, a);
131
+ return f(...i, d);
132
+ } : s[n] = f;
133
+ }), s;
134
+ }, _ = (e) => e.endsWith("Attributes"), Q = (e, r, t, a) => {
135
+ if (!e) return e;
136
+ const s = x(r, t, a), n = typeof e == "function" ? e(s) : e;
137
+ if (!n) return n;
138
+ const f = { ...n };
139
+ return Object.keys(f).forEach((i) => {
140
+ const d = f[i];
141
+ _(i) && d && typeof d == "object" && !Array.isArray(d) && (f[i] = O(d, r, t, a));
142
+ }), f;
143
+ };
144
+ export {
145
+ B as addIndexColumn,
146
+ m as applyColumnStyles,
147
+ C as createCellRenderer,
148
+ x as createTableContext,
149
+ Q as enhanceFormPropsWithContext,
150
+ F as getRowIdFromRecord,
151
+ E as parseTableFormData,
152
+ O as processEventHandlers,
153
+ L as processTableColumns,
154
+ q as processTableRules,
155
+ v as renderActionButtons,
156
+ W as shouldRequestPreviousPage
157
+ };
@@ -0,0 +1,4 @@
1
+ const s = (e) => IUseTableRsp;
2
+ export {
3
+ s as useTable
4
+ };
@@ -0,0 +1,151 @@
1
+ import { debounce as X, cloneDeep as p } from "lodash-es";
2
+ import { useRef as D, useState as S, useEffect as Y } from "react";
3
+ const k = (u) => {
4
+ if (typeof queueMicrotask == "function") {
5
+ queueMicrotask(u);
6
+ return;
7
+ }
8
+ Promise.resolve().then(u);
9
+ }, P = ({
10
+ tableProps: u,
11
+ onTableChange: _,
12
+ editTable: d = !1
13
+ }) => {
14
+ const y = D(null), l = D({}), i = D([]), x = D({}), [, h] = S({}), [, w] = S([]), [C, N] = S([]), [$, b] = S(null), q = (e, t) => d ? !0 : e[t] === $, R = (e, t) => {
15
+ l.current = e, h(e), i.current = t, w(t);
16
+ }, A = (e, t) => e == null ? void 0 : e.reduce((r, n) => {
17
+ var c;
18
+ return (c = Object.entries(n)) == null || c.forEach(([o, s]) => {
19
+ o !== t && (r[`${o}_${n[t]}`] = s);
20
+ }), r;
21
+ }, {}), z = (e, t, r) => {
22
+ const n = {
23
+ [r]: t
24
+ };
25
+ return Object.entries(e).forEach(([c, o]) => {
26
+ if (c !== r) {
27
+ const [s, a] = c.split("_");
28
+ a === t && (n[s] = o);
29
+ }
30
+ }), n;
31
+ }, j = () => {
32
+ if (d) {
33
+ const e = p(u.dataSource), t = A(e, u.rowKey);
34
+ R(t, e);
35
+ } else {
36
+ const e = p(x.current);
37
+ R(e, [e]);
38
+ }
39
+ }, B = (e, t) => {
40
+ const r = e.split("_");
41
+ let n, c;
42
+ if (r.length >= 2) {
43
+ const o = r[r.length - 1];
44
+ i.current.some((a) => String(a[u.rowKey]) === String(o)) ? (n = r.slice(0, -1).join("_"), c = o) : (n = e, c = t);
45
+ } else
46
+ n = e, c = t;
47
+ return { fieldName: n, targetRowId: c };
48
+ }, v = (e, t) => {
49
+ const r = /* @__PURE__ */ new Map();
50
+ Object.entries(e).forEach(([n, c]) => {
51
+ const { fieldName: o, targetRowId: s } = B(n, t), a = `${o}_${s}`;
52
+ l.current[a] = c, r.has(s) || r.set(s, {}), r.get(s)[o] = c;
53
+ }), h({ ...l.current }), r.forEach((n, c) => {
54
+ const o = i.current.findIndex((s) => String(s[u.rowKey]) === String(c));
55
+ o !== -1 ? i.current[o] = {
56
+ ...i.current[o],
57
+ ...n
58
+ } : i.current.push({
59
+ [u.rowKey]: c,
60
+ ...n
61
+ });
62
+ }), w([...i.current]);
63
+ }, H = (e) => ({
64
+ validate: async (t) => {
65
+ var n;
66
+ const r = t ? `${t}_${e}` : void 0;
67
+ return (n = y.current) == null ? void 0 : n.validate(r);
68
+ },
69
+ onReload: j,
70
+ setFieldValue: (t, r) => {
71
+ k(() => {
72
+ v({ [t]: r }, e);
73
+ });
74
+ },
75
+ setFieldsValue: (t) => {
76
+ k(() => {
77
+ v(t, e);
78
+ });
79
+ }
80
+ }), M = ({ values: e, record: t }) => {
81
+ if (!t || Object.keys(t).length === 0) {
82
+ const E = Object.keys(l.current).reduce((g, K) => (g[K] = void 0, g), {});
83
+ return l.current = { ...E, ...e }, h(l.current), i.current = i.current.map((g) => {
84
+ const K = String(g[u.rowKey]), I = { ...g };
85
+ return Object.keys(E).forEach((O) => {
86
+ const f = O.split("_");
87
+ if (f.length >= 2 && f[f.length - 1] === K) {
88
+ const m = f.slice(0, -1).join("_");
89
+ I[m] = void 0;
90
+ }
91
+ }), Object.entries(e).forEach(([O, f]) => {
92
+ const m = O.split("_");
93
+ if (m.length >= 2 && m[m.length - 1] === K) {
94
+ const U = m.slice(0, -1).join("_");
95
+ I[U] = f;
96
+ }
97
+ }), I;
98
+ }), w([...i.current]), { key: "", value: void 0, newRecord: {}, rowValue: "" };
99
+ }
100
+ const n = Object.keys(e)[0], [c, o] = n.split("_"), s = e[n];
101
+ l.current = { ...l.current, ...t }, h(l.current);
102
+ const a = z(t, o, u.rowKey), F = i.current.findIndex((E) => String(E[u.rowKey]) === String(o));
103
+ return F !== -1 ? i.current[F] = { ...i.current[F], ...a } : i.current.push(a), w([...i.current]), { key: c, value: s, newRecord: a, rowValue: o };
104
+ }, J = ({ values: e, record: t }) => {
105
+ const { key: r, value: n, newRecord: c, rowValue: o } = M({ values: e, record: t });
106
+ _ == null || _({
107
+ key: r,
108
+ value: n,
109
+ record: c,
110
+ form: H(o)
111
+ });
112
+ }, W = () => i.current, G = async () => {
113
+ var e;
114
+ try {
115
+ return await ((e = y.current) == null ? void 0 : e.validate());
116
+ } catch (t) {
117
+ return N(Object.keys(t.values || {})), !1;
118
+ }
119
+ }, L = (e) => {
120
+ const t = p(e), r = u.rowKey, n = t[r];
121
+ Number(n) !== Number($) && b(n);
122
+ const c = Object.entries(e).reduce((o, [s, a]) => (s !== r && !s.includes("_") && (o[`${s}_${n}`] = a), o[s] = a, o), {});
123
+ R(c, [e]), x.current = p(c);
124
+ }, V = () => {
125
+ var e;
126
+ b(null), R({}, []), N([]), (e = y.current) == null || e.onReload();
127
+ };
128
+ Y(() => {
129
+ d && u.dataSource ? j() : d || V();
130
+ }, [d, JSON.stringify(u.dataSource), u.rowKey]);
131
+ const Q = X(J, 500, { leading: !0, trailing: !1 });
132
+ return {
133
+ formRef: y,
134
+ onTableValueChange: Q,
135
+ onInternalStateChange: M,
136
+ formData: l.current,
137
+ tableData: i.current,
138
+ errorKey: C,
139
+ editTable: d,
140
+ edit: !0,
141
+ onEditingChange: L,
142
+ onCancelChange: V,
143
+ onValidate: G,
144
+ isEditing: q,
145
+ onReload: j,
146
+ getTableData: W
147
+ };
148
+ };
149
+ export {
150
+ P as default
151
+ };
@@ -0,0 +1,59 @@
1
+ import { useRequest as D, useMemoizedFn as i } from "ahooks";
2
+ import { useMemo as F } from "react";
3
+ const T = (f, N = {}) => {
4
+ var u, P, l, d;
5
+ const { defaultPageSize: n = 10, defaultCurrent: C = 1, ...M } = N, a = D(f, {
6
+ defaultParams: [
7
+ {
8
+ pageNo: C,
9
+ pageSize: n
10
+ }
11
+ ],
12
+ refreshDepsAction: () => {
13
+ m(1);
14
+ },
15
+ ...M
16
+ }), p = a.params && a.params[0] ? a.params[0] : { pageNo: 1, pageSize: n }, s = ((u = a.data) == null ? void 0 : u.pageNo) || p.pageNo || 1, t = ((P = a.data) == null ? void 0 : P.pageSize) || p.pageSize || n, o = ((l = a.data) == null ? void 0 : l.totalCount) || 0, c = F(() => {
17
+ var e;
18
+ return ((e = a.data) == null ? void 0 : e.totalPage) || Math.ceil(o / t);
19
+ }, [t, o]), g = (e, z) => {
20
+ let r = e <= 0 ? 1 : e;
21
+ const h = z <= 0 ? 1 : z, S = Math.ceil(o / h);
22
+ r > S && (r = Math.max(1, S));
23
+ const [q = {}, ...A] = a.params || [];
24
+ a.run(
25
+ {
26
+ ...q,
27
+ pageNo: r,
28
+ pageSize: h
29
+ },
30
+ ...A
31
+ );
32
+ }, m = (e) => {
33
+ g(e, t);
34
+ }, x = (e) => {
35
+ g(s, e);
36
+ };
37
+ return {
38
+ ...a,
39
+ data: ((d = a.data) == null ? void 0 : d.records) || [],
40
+ pageInfo: {
41
+ pageNo: s,
42
+ pageSize: t,
43
+ totalCount: o,
44
+ totalPage: c
45
+ },
46
+ pagination: {
47
+ pageNo: s,
48
+ pageSize: t,
49
+ totalCount: o,
50
+ totalPage: c,
51
+ onChange: i(g),
52
+ changePageNo: i(m),
53
+ changePageSize: i(x)
54
+ }
55
+ };
56
+ };
57
+ export {
58
+ T as default
59
+ };
@@ -0,0 +1,23 @@
1
+ import { App as c } from "antd";
2
+ import { useMemo as d } from "react";
3
+ import { addIndexColumn as i, processTableColumns as p, applyColumnStyles as f } from "../fe-table-utils/index.js";
4
+ const A = (o) => {
5
+ const { columnsHandleConfig: s, btnPermissionList: e, showIndex: l, columns: u, expandableConfig: t, columnsHandleAttr: m } = o || {}, { modal: r } = c.useApp();
6
+ return {
7
+ subColumns: d(() => {
8
+ if (!o || !o.columns) return [];
9
+ let n = i([...o.columns], o.showIndex !== !1);
10
+ return n = p(
11
+ n,
12
+ s,
13
+ e,
14
+ m,
15
+ r
16
+ ), n = f(n), n;
17
+ }, [u, s, l, e]),
18
+ expandableConfig: t
19
+ };
20
+ };
21
+ export {
22
+ A as default
23
+ };
@@ -0,0 +1,177 @@
1
+ import { App as N } from "antd";
2
+ import { useRef as u, useEffect as c, useMemo as P } from "react";
3
+ import "react/jsx-runtime";
4
+ import "@ant-design/icons";
5
+ import "../../store/modules/layout-config.store.js";
6
+ import "../../store/modules/theme.store.js";
7
+ import "react-router-dom";
8
+ import "../../fe-layouts/context/context.js";
9
+ import "nprogress";
10
+ import { usePermission as L } from "../../hooks/use-permission.hook/index.js";
11
+ import "@spacego/turbo-utils";
12
+ /* empty css */
13
+ import "lodash-es";
14
+ import "../../fe-form/fe-form-date-range-picker/index.js";
15
+ import "../../fe-rich-text/index.js";
16
+ import "../../fe-text-area/index.js";
17
+ /* empty css */
18
+ /* empty css */
19
+ /* empty css */
20
+ import "@spacego/zustand";
21
+ import "react-icons/fa6";
22
+ import "react-icons/io5";
23
+ import "react-icons/lu";
24
+ import "react-icons/md";
25
+ /* empty css */
26
+ import "../../fe-layouts/basics-layout/index.js";
27
+ /* empty css */
28
+ /* empty css */
29
+ /* empty css */
30
+ import "react-draggable";
31
+ import "../../fe-panel/use-panel-context.js";
32
+ /* empty css */
33
+ import "../../_virtual/index.js";
34
+ import "../fe-edit-table-cell/index.js";
35
+ import B from "../use-pagination/index.js";
36
+ import "../fe-table-setting/index.js";
37
+ import { processTableColumns as I, addIndexColumn as O, applyColumnStyles as H, shouldRequestPreviousPage as S } from "../fe-table-utils/index.js";
38
+ import "ahooks";
39
+ import A from "../fe-head-title/index.js";
40
+ import $ from "../fe-table-toolbar/index.js";
41
+ const Te = (i) => {
42
+ var d, h, b;
43
+ const { btnPermissionList: y } = L(), e = {
44
+ ...i,
45
+ loadType: i.loadType ?? "page",
46
+ btnPermissionList: i.btnPermissionList ?? y,
47
+ rowKey: i.rowKey || "id",
48
+ showIndex: i.showIndex ?? !0
49
+ }, { modal: m } = N.useApp(), g = u(""), C = u(), s = u({}), f = async (o) => {
50
+ var w;
51
+ const r = o.pageNo || 1, n = o.pageSize || 10;
52
+ if (!e.fetchModel)
53
+ return {
54
+ pageNo: r,
55
+ pageSize: n,
56
+ totalCount: ((w = e.initDataSource) == null ? void 0 : w.length) || 0,
57
+ totalPage: 1,
58
+ records: e.initDataSource || []
59
+ };
60
+ const p = await e.fetchModel({
61
+ pageNo: r,
62
+ pageSize: n,
63
+ ...o,
64
+ ...s.current
65
+ });
66
+ return S(p.records, r) ? f({
67
+ pageSize: n,
68
+ ...o,
69
+ pageNo: r - 1,
70
+ ...s.current
71
+ }) : p;
72
+ }, {
73
+ data: a,
74
+ pageInfo: t,
75
+ pagination: T,
76
+ refresh: l,
77
+ run: R
78
+ } = B(f, {
79
+ defaultCurrent: ((d = e.pageOption) == null ? void 0 : d.pageNo) || 1,
80
+ defaultPageSize: ((h = e.pageOption) == null ? void 0 : h.pageSize) || 10,
81
+ manual: !0
82
+ });
83
+ c(() => {
84
+ a.length && !a.every((o) => !!o[e.rowKey]) && console.error(`数据缺少主键${e.rowKey}`);
85
+ }, [a, e.rowKey]);
86
+ const x = P(() => {
87
+ let o = [...e.columns];
88
+ return o = I(
89
+ o,
90
+ e.columnsHandleConfig,
91
+ e.btnPermissionList,
92
+ e.columnsHandleAttr,
93
+ m
94
+ ), o = O(
95
+ o,
96
+ e.showIndex,
97
+ t.pageNo,
98
+ t.pageSize
99
+ ), H(o);
100
+ }, [
101
+ e.columns,
102
+ e.columnsHandleConfig,
103
+ e.btnPermissionList,
104
+ e.showIndex,
105
+ t.pageNo,
106
+ t.pageSize
107
+ ]), K = () => {
108
+ var o;
109
+ if (e.toolBarRender)
110
+ return e.toolBarRender;
111
+ if ((o = e.toolBarConfig) != null && o.length)
112
+ return $({
113
+ config: e.toolBarConfig,
114
+ btnPermissionList: e.btnPermissionList,
115
+ modal: m
116
+ });
117
+ }, z = () => e.subTitle ? A({
118
+ title: e.headerTitle || "",
119
+ subTitle: e.subTitle
120
+ }) : e.headerTitle || "";
121
+ return c(() => {
122
+ s.current = i.searchOption || {};
123
+ }, [i.searchOption]), c(() => {
124
+ var o;
125
+ (o = e == null ? void 0 : e.rawKeyRef) != null && o.current && g.current !== e.rawKeyRef.current && (g.current = e.rawKeyRef.current, l());
126
+ }, [(b = e == null ? void 0 : e.rawKeyRef) == null ? void 0 : b.current, l]), {
127
+ tableProps: {
128
+ actionRef: C,
129
+ columns: x,
130
+ dataSource: a,
131
+ scroll: { x: e.scrollX || "1300px", y: e.scrollY || "500px" },
132
+ rowKey: e.rowKey,
133
+ tableLayout: "fixed",
134
+ headerTitle: z(),
135
+ toolBarRender: K,
136
+ pagination: e.pageVisible ? {
137
+ showQuickJumper: !0,
138
+ showSizeChanger: !0,
139
+ pageSize: t.pageSize,
140
+ current: t.pageNo,
141
+ total: t.totalCount,
142
+ showTotal: (o, r) => {
143
+ const [n, p] = r;
144
+ return `第 ${n}-${p} 条/总共 ${o} 条`;
145
+ },
146
+ onChange: (o, r) => {
147
+ T.onChange(o, r);
148
+ }
149
+ } : !1,
150
+ options: !1,
151
+ search: !1,
152
+ cardProps: !1,
153
+ subTableConfig: e.subTableConfig,
154
+ expandable: e.expandable,
155
+ rowSelection: e.rowSelection,
156
+ columnSetting: e.columnSetting
157
+ },
158
+ fetchPageOption: () => ({
159
+ pageNo: t.pageNo,
160
+ pageSize: t.pageSize,
161
+ totalCount: t.totalCount
162
+ }),
163
+ search: async (o) => {
164
+ const { pageNo: r, pageSize: n, ...p } = o || {};
165
+ s.current = { ...s.current, ...p || {} }, R({
166
+ pageNo: r || 1,
167
+ pageSize: n || t.pageSize,
168
+ ...s.current
169
+ });
170
+ },
171
+ refresh: l,
172
+ shouldRequestPreviousPage: S
173
+ };
174
+ };
175
+ export {
176
+ Te as default
177
+ };
@@ -0,0 +1,53 @@
1
+ import { useUpdateEffect as y, useAsyncEffect as p } from "ahooks";
2
+ import { useState as f, useMemo as g, useCallback as C } from "react";
3
+ const F = (h) => {
4
+ const { columns: n, columnSetting: s = !1, tableKey: i } = h, [l, c] = f(n == null ? void 0 : n.map((e) => ({ title: e.title, dataIndex: e.dataIndex }))), [d, u] = f([]), r = g(() => i ? `FE_TABLE_COLUMNS_CONFIG_${i.toUpperCase()}` : null, [i]), I = g(() => {
5
+ let e = l.length > 0 ? l : n;
6
+ return (e.length !== n.length || !e.every((t) => n.some((o) => o.dataIndex === t.dataIndex))) && (e = n, c(n)), e.filter((t) => t.dataIndex ? !d.includes(t.dataIndex) : !0);
7
+ }, [l, n, d]), x = C((e) => {
8
+ c(e);
9
+ }, []), O = C((e, t) => {
10
+ u((o) => {
11
+ let a = [];
12
+ return t ? a = o.filter((m) => m !== e) : a = o.includes(e) ? o : [...o, e], a;
13
+ });
14
+ }, []);
15
+ return y(() => {
16
+ if (r && s)
17
+ try {
18
+ const e = {
19
+ hiddenColumns: d,
20
+ columnOrder: l.map((t) => ({ title: t.title, dataIndex: t.dataIndex }))
21
+ };
22
+ localStorage.setItem(r, JSON.stringify(e));
23
+ } catch (e) {
24
+ console.warn("Failed to save table columns config to localStorage:", e);
25
+ }
26
+ }, [r, l, d, s]), p(async () => {
27
+ if (!(!r || !s))
28
+ try {
29
+ const e = localStorage.getItem(r);
30
+ if (e) {
31
+ const t = JSON.parse(e);
32
+ if (t.columnOrder) {
33
+ const o = t.columnOrder.map((a) => n.find((S) => S.dataIndex === a.dataIndex) || a).filter(Boolean);
34
+ c(o);
35
+ }
36
+ t.hiddenColumns && u(t.hiddenColumns);
37
+ }
38
+ } catch (e) {
39
+ console.warn("Failed to load table columns config from localStorage:", e);
40
+ }
41
+ }, [r, s]), {
42
+ processedColumns: I,
43
+ originalColumns: l.length > 0 ? l : n,
44
+ hiddenColumns: d,
45
+ onColumnsChange: x,
46
+ onColumnVisibilityChange: O,
47
+ columnSettingEnabled: s
48
+ };
49
+ };
50
+ export {
51
+ F as default,
52
+ F as useTableColumns
53
+ };
@@ -0,0 +1,14 @@
1
+ import { Form as c } from "antd";
2
+ import { enhanceFormPropsWithContext as m, processTableRules as a } from "../fe-table-utils/index.js";
3
+ const F = () => {
4
+ var t, s;
5
+ const e = ((s = (t = c).useFormInstance) == null ? void 0 : s.call(t)) || null;
6
+ return {
7
+ formInstance: e,
8
+ enhanceRules: (n, o, r) => a(n, o, r, e),
9
+ enhanceFormProps: (n, o, r) => m(n, o, r, e)
10
+ };
11
+ };
12
+ export {
13
+ F as useTableFormContext
14
+ };
@@ -0,0 +1,53 @@
1
+ import { useState as E, useCallback as u, useMemo as A, useEffect as I } from "react";
2
+ const T = (b) => {
3
+ const { rowSelection: e, dataSource: f = [], rowKey: a = "id" } = b, t = (e == null ? void 0 : e.selectedRowKeys) !== void 0, [v, K] = E([]), d = t ? (e == null ? void 0 : e.selectedRowKeys) || [] : v, h = u(
4
+ (s) => typeof a == "function" ? a(s) : s[a],
5
+ [a]
6
+ ), y = A(() => !d.length || !f.length ? [] : f.filter((s) => {
7
+ const l = h(s);
8
+ return d.includes(l);
9
+ }), [d, f, h]), _ = () => {
10
+ var s;
11
+ t ? (s = e == null ? void 0 : e.onChange) == null || s.call(e, [], [], { type: "none" }) : K([]);
12
+ }, g = u(
13
+ (s, l, c) => {
14
+ var n;
15
+ t || K(s), (n = e == null ? void 0 : e.onChange) == null || n.call(e, s, l, c);
16
+ },
17
+ [t, e]
18
+ ), C = u(
19
+ (s, l, c, n) => {
20
+ var m;
21
+ (m = e == null ? void 0 : e.onSelect) == null || m.call(e, s, l, y, n);
22
+ },
23
+ [e]
24
+ ), r = u(
25
+ (s, l, c) => {
26
+ var n;
27
+ (n = e == null ? void 0 : e.onSelectAll) == null || n.call(e, s, y, c);
28
+ },
29
+ [e]
30
+ ), x = A(() => {
31
+ if (e)
32
+ return {
33
+ ...e,
34
+ selectedRowKeys: d,
35
+ onChange: g,
36
+ onSelect: C,
37
+ onSelectAll: r
38
+ };
39
+ }, [e, d, g, C, r]);
40
+ return I(() => {
41
+ t && (e != null && e.selectedRowKeys);
42
+ }, [t, e == null ? void 0 : e.selectedRowKeys]), {
43
+ selectedRowKeys: d,
44
+ selectedRows: y,
45
+ rowSelection: x,
46
+ onCleanSelected: _,
47
+ isControlled: t
48
+ };
49
+ };
50
+ export {
51
+ T as default,
52
+ T as useTableSelection
53
+ };