@pisell/private-materials 6.3.53 → 6.3.54

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 (146) 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 +2 -2
  6. package/build/lowcode/preview.js +146 -157
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +11 -16
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +11 -16
  11. package/es/components/booking/components/TabProduct/index.d.ts +1 -0
  12. package/es/components/booking/components/formItemChildrenWrap/index.d.ts +1 -0
  13. package/es/components/booking/forms/table/index.d.ts +1 -0
  14. package/es/components/booking/info/clientVariant/hooks/useIsLowSpeedNetwork.d.ts +1 -0
  15. package/es/components/booking/info/service/like/index.d.ts +1 -0
  16. package/es/components/eftpos/deviceList/index.d.ts +1 -0
  17. package/es/components/eftpos/form/index.d.ts +1 -0
  18. package/es/components/eftpos/group/index.d.ts +1 -0
  19. package/es/components/eftpos/hooks.d.ts +1 -0
  20. package/es/components/eftpos/icon/apiKey.d.ts +1 -0
  21. package/es/components/eftpos/icon/device.d.ts +1 -0
  22. package/es/components/eftpos/receipt/index.d.ts +1 -0
  23. package/es/components/eftposPay/component/alert/warn.d.ts +1 -0
  24. package/es/components/eftposPay/component/header/titlebar.d.ts +1 -0
  25. package/es/components/eftposPay/component/step/index.d.ts +1 -0
  26. package/es/components/eftposPay/component/step/step.d.ts +1 -0
  27. package/es/components/eftposPay/tyro/hooks.d.ts +1 -0
  28. package/es/components/eventBooking/components/Provider/Cart/Deposit/index.d.ts +1 -0
  29. package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateStatus/index.d.ts +1 -0
  30. package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/Item/DayItem/index.d.ts +1 -0
  31. package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/Item/index.d.ts +1 -0
  32. package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/Status/index.d.ts +1 -0
  33. package/es/components/index.d.ts +2 -1
  34. package/es/components/index.js +2 -1
  35. package/es/components/pay/toC/PaymentMethods/StripePay/Stripe/StripeSDK/index.d.ts +1 -0
  36. package/es/components/pay/toC/PaymentMethods/StripePay/Stripe/index.d.ts +1 -0
  37. package/es/components/productExtension/fields/Actor/index.d.ts +1 -0
  38. package/es/components/productExtension/fields/Forms/index.d.ts +1 -0
  39. package/es/components/schedules/calendar/calendarItem.d.ts +1 -0
  40. package/es/components/schedules/products/ProductDetailDrawer/ProductDetail/index.d.ts +1 -0
  41. package/es/components/schedules/products/ProductDetailDrawer/ProductDetailByDate/index.d.ts +1 -0
  42. package/es/components/schedules/resources/relationProduct/index.d.ts +1 -0
  43. package/es/components/schedules/utils.d.ts +1 -1
  44. package/es/components/shoppingCart/components/Empty/index.d.ts +1 -0
  45. package/es/components/shoppingCart/components/Render/index.d.ts +1 -0
  46. package/es/components/systemSettings/registry/components/GroupModal.d.ts +4 -0
  47. package/es/components/systemSettings/registry/components/GroupModal.js +160 -0
  48. package/es/components/systemSettings/registry/components/ItemModal.d.ts +4 -0
  49. package/es/components/systemSettings/registry/components/ItemModal.js +547 -0
  50. package/es/components/systemSettings/registry/components/ModuleList.d.ts +4 -0
  51. package/es/components/systemSettings/registry/components/ModuleList.js +54 -0
  52. package/es/components/systemSettings/registry/components/SectionList.d.ts +4 -0
  53. package/es/components/systemSettings/registry/components/SectionList.js +174 -0
  54. package/es/components/systemSettings/registry/components/SettingsTable.d.ts +4 -0
  55. package/es/components/systemSettings/registry/components/SettingsTable.js +765 -0
  56. package/es/components/systemSettings/registry/components/index.d.ts +4 -0
  57. package/es/components/systemSettings/registry/components/index.js +4 -0
  58. package/es/components/systemSettings/registry/index.d.ts +5 -0
  59. package/es/components/systemSettings/registry/index.js +1059 -0
  60. package/es/components/systemSettings/registry/index.less +410 -0
  61. package/es/components/systemSettings/registry/locales.d.ts +272 -0
  62. package/es/components/systemSettings/registry/locales.js +300 -0
  63. package/es/components/systemSettings/registry/services.d.ts +77 -0
  64. package/es/components/systemSettings/registry/services.js +472 -0
  65. package/es/components/systemSettings/registry/types.d.ts +126 -0
  66. package/es/components/systemSettings/registry/types.js +1 -0
  67. package/es/components/systemSettings/registry/utils/typeValidation.d.ts +16 -0
  68. package/es/components/systemSettings/registry/utils/typeValidation.js +284 -0
  69. package/es/components/systemSettings/registry/utils/validators.d.ts +8 -0
  70. package/es/components/systemSettings/registry/utils/validators.js +44 -0
  71. package/es/index.d.ts +1 -0
  72. package/es/index.js +1 -0
  73. package/es/plus/clientName/index.d.ts +1 -0
  74. package/es/pro/Login2.0/AuthModal.js +12 -4
  75. package/es/pro/Login2.0/index.less +3 -3
  76. package/es/pro/pisellPaymentList/example.d.ts +1 -0
  77. package/es/utils/index.d.ts +1 -1
  78. package/lib/components/booking/components/TabProduct/index.d.ts +1 -0
  79. package/lib/components/booking/components/formItemChildrenWrap/index.d.ts +1 -0
  80. package/lib/components/booking/forms/table/index.d.ts +1 -0
  81. package/lib/components/booking/info/clientVariant/hooks/useIsLowSpeedNetwork.d.ts +1 -0
  82. package/lib/components/booking/info/service/like/index.d.ts +1 -0
  83. package/lib/components/eftpos/deviceList/index.d.ts +1 -0
  84. package/lib/components/eftpos/form/index.d.ts +1 -0
  85. package/lib/components/eftpos/group/index.d.ts +1 -0
  86. package/lib/components/eftpos/hooks.d.ts +1 -0
  87. package/lib/components/eftpos/icon/apiKey.d.ts +1 -0
  88. package/lib/components/eftpos/icon/device.d.ts +1 -0
  89. package/lib/components/eftpos/receipt/index.d.ts +1 -0
  90. package/lib/components/eftposPay/component/alert/warn.d.ts +1 -0
  91. package/lib/components/eftposPay/component/header/titlebar.d.ts +1 -0
  92. package/lib/components/eftposPay/component/step/index.d.ts +1 -0
  93. package/lib/components/eftposPay/component/step/step.d.ts +1 -0
  94. package/lib/components/eftposPay/tyro/hooks.d.ts +1 -0
  95. package/lib/components/eventBooking/components/Provider/Cart/Deposit/index.d.ts +1 -0
  96. package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateStatus/index.d.ts +1 -0
  97. package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/Item/DayItem/index.d.ts +1 -0
  98. package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/Item/index.d.ts +1 -0
  99. package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/Status/index.d.ts +1 -0
  100. package/lib/components/index.d.ts +2 -1
  101. package/lib/components/index.js +3 -0
  102. package/lib/components/pay/toC/PaymentMethods/StripePay/Stripe/StripeSDK/index.d.ts +1 -0
  103. package/lib/components/pay/toC/PaymentMethods/StripePay/Stripe/index.d.ts +1 -0
  104. package/lib/components/productExtension/fields/Actor/index.d.ts +1 -0
  105. package/lib/components/productExtension/fields/Forms/index.d.ts +1 -0
  106. package/lib/components/schedules/calendar/calendarItem.d.ts +1 -0
  107. package/lib/components/schedules/products/ProductDetailDrawer/ProductDetail/index.d.ts +1 -0
  108. package/lib/components/schedules/products/ProductDetailDrawer/ProductDetailByDate/index.d.ts +1 -0
  109. package/lib/components/schedules/resources/relationProduct/index.d.ts +1 -0
  110. package/lib/components/schedules/utils.d.ts +1 -1
  111. package/lib/components/shoppingCart/components/Empty/index.d.ts +1 -0
  112. package/lib/components/shoppingCart/components/Render/index.d.ts +1 -0
  113. package/lib/components/systemSettings/registry/components/GroupModal.d.ts +4 -0
  114. package/lib/components/systemSettings/registry/components/GroupModal.js +177 -0
  115. package/lib/components/systemSettings/registry/components/ItemModal.d.ts +4 -0
  116. package/lib/components/systemSettings/registry/components/ItemModal.js +508 -0
  117. package/lib/components/systemSettings/registry/components/ModuleList.d.ts +4 -0
  118. package/lib/components/systemSettings/registry/components/ModuleList.js +71 -0
  119. package/lib/components/systemSettings/registry/components/SectionList.d.ts +4 -0
  120. package/lib/components/systemSettings/registry/components/SectionList.js +181 -0
  121. package/lib/components/systemSettings/registry/components/SettingsTable.d.ts +4 -0
  122. package/lib/components/systemSettings/registry/components/SettingsTable.js +575 -0
  123. package/lib/components/systemSettings/registry/components/index.d.ts +4 -0
  124. package/lib/components/systemSettings/registry/components/index.js +48 -0
  125. package/lib/components/systemSettings/registry/index.d.ts +5 -0
  126. package/lib/components/systemSettings/registry/index.js +529 -0
  127. package/lib/components/systemSettings/registry/index.less +410 -0
  128. package/lib/components/systemSettings/registry/locales.d.ts +272 -0
  129. package/lib/components/systemSettings/registry/locales.js +324 -0
  130. package/lib/components/systemSettings/registry/services.d.ts +77 -0
  131. package/lib/components/systemSettings/registry/services.js +290 -0
  132. package/lib/components/systemSettings/registry/types.d.ts +126 -0
  133. package/lib/components/systemSettings/registry/types.js +17 -0
  134. package/lib/components/systemSettings/registry/utils/typeValidation.d.ts +16 -0
  135. package/lib/components/systemSettings/registry/utils/typeValidation.js +228 -0
  136. package/lib/components/systemSettings/registry/utils/validators.d.ts +8 -0
  137. package/lib/components/systemSettings/registry/utils/validators.js +54 -0
  138. package/lib/index.d.ts +1 -0
  139. package/lib/index.js +3 -0
  140. package/lib/plus/clientName/index.d.ts +1 -0
  141. package/lib/pro/Login2.0/AuthModal.js +15 -7
  142. package/lib/pro/Login2.0/index.less +3 -3
  143. package/lib/pro/pisellPaymentList/example.d.ts +1 -0
  144. package/lib/utils/index.d.ts +1 -1
  145. package/lowcode/settings-registry/meta.ts +29 -0
  146. package/package.json +2 -2
@@ -0,0 +1,529 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/components/systemSettings/registry/index.tsx
30
+ var registry_exports = {};
31
+ __export(registry_exports, {
32
+ default: () => registry_default
33
+ });
34
+ module.exports = __toCommonJS(registry_exports);
35
+ var import_react = __toESM(require("react"));
36
+ var import_antd = require("antd");
37
+ var import_materials = require("@pisell/materials");
38
+ var import_icons = require("@ant-design/icons");
39
+ var import_utils = require("@pisell/utils");
40
+ var import_useEngineContext = __toESM(require("../../../hooks/useEngineContext"));
41
+ var import_components = require("./components");
42
+ var import_services = require("./services");
43
+ var import_typeValidation = require("./utils/typeValidation");
44
+ var import_locales = __toESM(require("./locales"));
45
+ var import_index = require("./index.less");
46
+ var Registry = ({
47
+ className,
48
+ style,
49
+ sections = [],
50
+ selectedSectionId,
51
+ onSectionSelect,
52
+ onDataChange
53
+ }) => {
54
+ var _a, _b;
55
+ const context = (0, import_useEngineContext.default)();
56
+ const { request } = context.appHelper.utils;
57
+ const [localSections, setLocalSections] = (0, import_react.useState)(sections);
58
+ const [currentSectionId, setCurrentSectionId] = (0, import_react.useState)(
59
+ selectedSectionId || (sections.length > 0 ? sections[0].id : 0)
60
+ );
61
+ const [loading, setLoading] = (0, import_react.useState)(false);
62
+ const [hasMore, setHasMore] = (0, import_react.useState)(true);
63
+ const [currentPage, setCurrentPage] = (0, import_react.useState)(1);
64
+ const [pageSize] = (0, import_react.useState)(20);
65
+ const [isInitialLoad, setIsInitialLoad] = (0, import_react.useState)(true);
66
+ const [groupList, setGroupList] = (0, import_react.useState)([]);
67
+ const [groupLoading, setGroupLoading] = (0, import_react.useState)(false);
68
+ const onDataChangeRef = (0, import_react.useRef)(onDataChange);
69
+ const lastLoadedSectionCodeRef = (0, import_react.useRef)("");
70
+ onDataChangeRef.current = onDataChange;
71
+ const [groupModalOpen, setGroupModalOpen] = (0, import_react.useState)(false);
72
+ const [itemModalOpen, setItemModalOpen] = (0, import_react.useState)(false);
73
+ const [modalType, setModalType] = (0, import_react.useState)("add");
74
+ const [editingGroup, setEditingGroup] = (0, import_react.useState)();
75
+ const [editingItem, setEditingItem] = (0, import_react.useState)();
76
+ const [targetGroupId, setTargetGroupId] = (0, import_react.useState)(0);
77
+ const handleCreateGroup = async (params) => {
78
+ try {
79
+ const response = await (0, import_services.createGroup)(request, params);
80
+ if (currentSectionId) {
81
+ const currentSection2 = localSections.find((s) => s.id === currentSectionId);
82
+ if (currentSection2) {
83
+ await loadGroupData(currentSection2.code, true);
84
+ }
85
+ }
86
+ import_antd.message.success(import_utils.locales.getText("registry.message.save.success"));
87
+ return response;
88
+ } catch (error) {
89
+ import_antd.message.error(import_utils.locales.getText("registry.message.create.group.error"));
90
+ throw error;
91
+ }
92
+ };
93
+ const handleUpdateGroup = async (params) => {
94
+ try {
95
+ const response = await (0, import_services.updateGroup)(request, params);
96
+ if (currentSectionId) {
97
+ const currentSection2 = localSections.find((s) => s.id === currentSectionId);
98
+ if (currentSection2) {
99
+ await loadGroupData(currentSection2.code, true);
100
+ }
101
+ }
102
+ import_antd.message.success(import_utils.locales.getText("registry.message.save.success"));
103
+ return response;
104
+ } catch (error) {
105
+ throw error;
106
+ }
107
+ };
108
+ const handleDeleteGroup = async (params) => {
109
+ try {
110
+ const response = await (0, import_services.deleteGroup)(request, params);
111
+ if (currentSectionId) {
112
+ const currentSection2 = localSections.find((s) => s.id === currentSectionId);
113
+ if (currentSection2) {
114
+ await loadGroupData(currentSection2.code, true);
115
+ }
116
+ }
117
+ import_antd.message.success(import_utils.locales.getText("registry.message.delete.success"));
118
+ return response;
119
+ } catch (error) {
120
+ throw error;
121
+ }
122
+ };
123
+ const handleCreateItem = async (params) => {
124
+ try {
125
+ const response = await (0, import_services.createItem)(request, params);
126
+ if (currentSectionId) {
127
+ const currentSection2 = localSections.find((s) => s.id === currentSectionId);
128
+ if (currentSection2) {
129
+ await loadGroupData(currentSection2.code, true);
130
+ }
131
+ }
132
+ import_antd.message.success(import_utils.locales.getText("registry.message.save.success"));
133
+ return response;
134
+ } catch (error) {
135
+ throw error;
136
+ }
137
+ };
138
+ const handleUpdateItem = async (params) => {
139
+ try {
140
+ const response = await (0, import_services.updateItem)(request, params);
141
+ if (currentSectionId) {
142
+ const currentSection2 = localSections.find((s) => s.id === currentSectionId);
143
+ if (currentSection2) {
144
+ await loadGroupData(currentSection2.code, true);
145
+ }
146
+ }
147
+ import_antd.message.success(import_utils.locales.getText("registry.message.save.success"));
148
+ return response;
149
+ } catch (error) {
150
+ throw error;
151
+ }
152
+ };
153
+ const handleDeleteItem = async (params) => {
154
+ try {
155
+ const response = await (0, import_services.deleteItem)(request, params);
156
+ if (currentSectionId) {
157
+ const currentSection2 = localSections.find((s) => s.id === currentSectionId);
158
+ if (currentSection2) {
159
+ await loadGroupData(currentSection2.code, true);
160
+ }
161
+ }
162
+ import_antd.message.success(import_utils.locales.getText("registry.message.delete.success"));
163
+ return response;
164
+ } catch (error) {
165
+ console.error("Failed to delete item:", error);
166
+ throw error;
167
+ }
168
+ };
169
+ const handleGroupReorder = async (groupIds) => {
170
+ try {
171
+ const currentSection2 = localSections.find((s) => s.id === currentSectionId);
172
+ if (!currentSection2) {
173
+ throw new Error("Current section not found");
174
+ }
175
+ await (0, import_services.sortGroups)(request, {
176
+ section_code: currentSection2.code,
177
+ group_ids: groupIds
178
+ });
179
+ const reorderedGroups = groupIds.map((id) => {
180
+ const group = groupList.find((g) => g.id === id);
181
+ return group ? { ...group } : null;
182
+ }).filter(Boolean);
183
+ setGroupList(reorderedGroups);
184
+ import_antd.message.success(import_utils.locales.getText("registry.message.reorder.success"));
185
+ } catch (error) {
186
+ console.error("Failed to reorder groups:", error);
187
+ const currentSection2 = localSections.find((s) => s.id === currentSectionId);
188
+ if (currentSection2) {
189
+ await loadGroupData(currentSection2.code, true);
190
+ }
191
+ }
192
+ };
193
+ const handleItemMove = async (itemId, targetGroupId2, newOrder) => {
194
+ try {
195
+ const targetGroup = groupList.find((g) => g.id === targetGroupId2);
196
+ if (!targetGroup) {
197
+ throw new Error("Target group not found");
198
+ }
199
+ const targetGroupItems = [...targetGroup.items];
200
+ const existingIndex = targetGroupItems.findIndex((item) => item.id === itemId);
201
+ if (existingIndex !== -1) {
202
+ const [movedItem] = targetGroupItems.splice(existingIndex, 1);
203
+ targetGroupItems.splice(newOrder, 0, movedItem);
204
+ } else {
205
+ const allItems = groupList.reduce((acc, g) => [...acc, ...g.items], []);
206
+ const movedItem = allItems.find((item) => item.id === itemId);
207
+ if (movedItem) {
208
+ targetGroupItems.splice(newOrder, 0, movedItem);
209
+ }
210
+ }
211
+ const sortedItemIds = targetGroupItems.map((item) => item.id);
212
+ await (0, import_services.sortItems)(request, {
213
+ id: itemId,
214
+ group_id: targetGroupId2.toString(),
215
+ item_ids: sortedItemIds
216
+ });
217
+ const currentSection2 = localSections.find((s) => s.id === currentSectionId);
218
+ if (currentSection2) {
219
+ await loadGroupData(currentSection2.code, true);
220
+ }
221
+ import_antd.message.success(import_utils.locales.getText("registry.message.move.success"));
222
+ } catch (error) {
223
+ console.error("Failed to move item:", error);
224
+ const currentSection2 = localSections.find((s) => s.id === currentSectionId);
225
+ if (currentSection2) {
226
+ await loadGroupData(currentSection2.code, true);
227
+ }
228
+ }
229
+ };
230
+ const loadGroupData = (0, import_react.useCallback)(async (sectionCode, forceRefresh = false) => {
231
+ if (groupLoading || !forceRefresh && lastLoadedSectionCodeRef.current === sectionCode) {
232
+ return;
233
+ }
234
+ lastLoadedSectionCodeRef.current = sectionCode;
235
+ setGroupLoading(true);
236
+ try {
237
+ const response = await (0, import_services.getGroupList)(request, {
238
+ page: 1,
239
+ pageSize: 100,
240
+ // 获取所有组数据
241
+ filter: { section_code: sectionCode }
242
+ });
243
+ const newGroups = response.data || [];
244
+ setGroupList(newGroups);
245
+ } catch (error) {
246
+ console.error("Failed to load group data:", error);
247
+ setGroupList([]);
248
+ } finally {
249
+ setGroupLoading(false);
250
+ }
251
+ }, []);
252
+ const loadSectionData = (0, import_react.useCallback)(async (page, isLoadMore = false) => {
253
+ var _a2;
254
+ if (loading) return;
255
+ setLoading(true);
256
+ try {
257
+ const response = await (0, import_services.getSectionList)(request, {
258
+ page,
259
+ pageSize,
260
+ filter: {}
261
+ });
262
+ const newSections = response.data || [];
263
+ if (isLoadMore) {
264
+ setLocalSections((prev) => [...prev, ...newSections]);
265
+ } else {
266
+ setLocalSections(newSections);
267
+ if (newSections.length > 0 && (!currentSectionId || currentSectionId === 0)) {
268
+ setCurrentSectionId(newSections[0].id);
269
+ }
270
+ }
271
+ const { totalPage } = response.meta;
272
+ setHasMore(page < totalPage);
273
+ if (isLoadMore) {
274
+ setLocalSections((prev) => {
275
+ var _a3;
276
+ const updatedSections = [...prev, ...newSections];
277
+ (_a3 = onDataChangeRef.current) == null ? void 0 : _a3.call(onDataChangeRef, updatedSections);
278
+ return updatedSections;
279
+ });
280
+ } else {
281
+ (_a2 = onDataChangeRef.current) == null ? void 0 : _a2.call(onDataChangeRef, newSections);
282
+ }
283
+ } catch (error) {
284
+ console.error("Failed to load section data:", error);
285
+ } finally {
286
+ setLoading(false);
287
+ }
288
+ }, [loading, pageSize, currentSectionId]);
289
+ const handleLoadMore = (0, import_react.useCallback)(() => {
290
+ if (!hasMore || loading) return;
291
+ const nextPage = currentPage + 1;
292
+ setCurrentPage(nextPage);
293
+ loadSectionData(nextPage, true);
294
+ }, [hasMore, loading, currentPage]);
295
+ (0, import_react.useEffect)(() => {
296
+ var _a2, _b2;
297
+ const currentLocale = ((_b2 = (_a2 = context == null ? void 0 : context.engine) == null ? void 0 : _a2.props) == null ? void 0 : _b2.locale) || localStorage.getItem("umi_locale") || "zh-CN";
298
+ import_utils.locales.init(import_locales.default, currentLocale);
299
+ }, [(_b = (_a = context == null ? void 0 : context.engine) == null ? void 0 : _a.props) == null ? void 0 : _b.locale]);
300
+ (0, import_react.useEffect)(() => {
301
+ if (isInitialLoad) {
302
+ setIsInitialLoad(false);
303
+ loadSectionData(1, false);
304
+ }
305
+ }, [isInitialLoad]);
306
+ (0, import_react.useEffect)(() => {
307
+ if (!isInitialLoad && sections && sections.length > 0) {
308
+ setLocalSections(sections);
309
+ }
310
+ }, [sections, isInitialLoad]);
311
+ (0, import_react.useEffect)(() => {
312
+ if (selectedSectionId) {
313
+ setCurrentSectionId(selectedSectionId);
314
+ }
315
+ }, [selectedSectionId]);
316
+ (0, import_react.useEffect)(() => {
317
+ if (currentSectionId && localSections.length > 0) {
318
+ const selectedSection = localSections.find((section) => section.id === currentSectionId);
319
+ if (selectedSection) {
320
+ lastLoadedSectionCodeRef.current = "";
321
+ loadGroupData(selectedSection.code);
322
+ }
323
+ }
324
+ }, [currentSectionId, localSections]);
325
+ const handleSectionSelect = (sectionId) => {
326
+ setCurrentSectionId(sectionId);
327
+ onSectionSelect == null ? void 0 : onSectionSelect(sectionId);
328
+ };
329
+ const handleDataChange = (updatedSection) => {
330
+ const newSections = localSections.map(
331
+ (section) => section.id === updatedSection.id ? updatedSection : section
332
+ );
333
+ setLocalSections(newSections);
334
+ onDataChange == null ? void 0 : onDataChange(newSections);
335
+ };
336
+ const currentSection = localSections.find((section) => section.id === currentSectionId);
337
+ const isCodeExists = (code, excludeId) => {
338
+ if (!currentSection || !currentSection.groups) return false;
339
+ return currentSection.groups.some((group) => group.code === code && group.id !== excludeId);
340
+ };
341
+ const isKeyExists = (key, excludeId) => {
342
+ if (!currentSection || !currentSection.groups) return false;
343
+ return currentSection.groups.some(
344
+ (group) => group.items && group.items.some((item) => item.key === key && item.id !== excludeId)
345
+ );
346
+ };
347
+ const handleAddGroup = () => {
348
+ setModalType("add");
349
+ setEditingGroup(void 0);
350
+ setGroupModalOpen(true);
351
+ };
352
+ const handleEditGroup = (group) => {
353
+ setModalType("edit");
354
+ setEditingGroup(group);
355
+ console.log("group", group);
356
+ setGroupModalOpen(true);
357
+ };
358
+ const handleAddItem = (groupId) => {
359
+ setModalType("add");
360
+ setEditingItem(void 0);
361
+ setTargetGroupId(groupId);
362
+ setItemModalOpen(true);
363
+ };
364
+ const handleEditItem = (item) => {
365
+ setModalType("edit");
366
+ setEditingItem(item);
367
+ setTargetGroupId(item.groupId || item.group_id || 0);
368
+ setItemModalOpen(true);
369
+ };
370
+ const handleGroupSubmit = async (formData) => {
371
+ if (!currentSection) return;
372
+ if (isCodeExists(formData.code, editingGroup == null ? void 0 : editingGroup.id)) {
373
+ return;
374
+ }
375
+ try {
376
+ if (modalType === "add") {
377
+ const maxSort = groupList.length > 0 ? Math.max(...groupList.map((group) => group.sort || 0)) : 0;
378
+ const newSort = maxSort + 1;
379
+ await handleCreateGroup({
380
+ section_code: currentSection.code,
381
+ code: formData.code,
382
+ title: formData.title,
383
+ sort: newSort
384
+ });
385
+ } else {
386
+ if (!(editingGroup == null ? void 0 : editingGroup.id)) {
387
+ console.error("No editing group ID found");
388
+ return;
389
+ }
390
+ await handleUpdateGroup({
391
+ id: editingGroup.id,
392
+ code: formData.code,
393
+ title: formData.title
394
+ });
395
+ }
396
+ setGroupModalOpen(false);
397
+ } catch (error) {
398
+ console.error("Failed to submit group form:", error);
399
+ }
400
+ };
401
+ const handleItemSubmit = async (formData) => {
402
+ if (!currentSection) return;
403
+ if (isKeyExists(formData.key, editingItem == null ? void 0 : editingItem.id)) {
404
+ return;
405
+ }
406
+ let processedDefaultValue = formData.default;
407
+ if (formData.default !== void 0 && formData.default !== null && formData.default !== "") {
408
+ const validation = (0, import_typeValidation.validateDefaultValue)(formData.fieldType, formData.default);
409
+ if (!validation.isValid) {
410
+ import_antd.message.error(`默认值验证失败: ${validation.error}`);
411
+ return;
412
+ }
413
+ processedDefaultValue = (0, import_typeValidation.parseDefaultValue)(formData.fieldType, formData.default);
414
+ } else {
415
+ processedDefaultValue = null;
416
+ }
417
+ try {
418
+ if (modalType === "add") {
419
+ const targetGroup = groupList.find((group) => group.id === targetGroupId);
420
+ const maxSort = targetGroup && targetGroup.items && targetGroup.items.length > 0 ? Math.max(...targetGroup.items.map((item) => item.sort || 0)) : 0;
421
+ const newSort = maxSort + 1;
422
+ await handleCreateItem({
423
+ section_code: currentSection.code,
424
+ group_id: targetGroupId,
425
+ code: formData.key,
426
+ title: formData.name,
427
+ description: formData.description,
428
+ type: formData.fieldType,
429
+ interface: formData.interfaceType,
430
+ default: processedDefaultValue,
431
+ scopes: formData.scopes,
432
+ schema: formData.uiSchema ? (() => {
433
+ try {
434
+ return JSON.parse(formData.uiSchema);
435
+ } catch (e) {
436
+ console.warn("Invalid JSON in uiSchema:", e);
437
+ return formData.uiSchema;
438
+ }
439
+ })() : void 0,
440
+ sort: newSort
441
+ });
442
+ } else {
443
+ if (!(editingItem == null ? void 0 : editingItem.id)) {
444
+ console.error("No editing item ID found");
445
+ return;
446
+ }
447
+ await handleUpdateItem({
448
+ id: editingItem.id,
449
+ section_code: currentSection.code,
450
+ group_id: targetGroupId,
451
+ code: formData.key,
452
+ title: formData.name,
453
+ description: formData.description,
454
+ type: formData.fieldType,
455
+ interface: formData.interfaceType,
456
+ default: processedDefaultValue,
457
+ scopes: formData.scopes,
458
+ schema: formData.uiSchema ? (() => {
459
+ try {
460
+ return JSON.parse(formData.uiSchema);
461
+ } catch (e) {
462
+ console.warn("Invalid JSON in uiSchema:", e);
463
+ return formData.uiSchema;
464
+ }
465
+ })() : void 0,
466
+ sort: editingItem.sort
467
+ });
468
+ }
469
+ setItemModalOpen(false);
470
+ } catch (error) {
471
+ console.error("Failed to submit item form:", error);
472
+ }
473
+ };
474
+ return /* @__PURE__ */ import_react.default.createElement("div", { className: `pisell-settings-registry ${className || ""}`, style }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-settings-registry-sidebar" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-settings-registry-sidebar-header" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-settings-registry-sidebar-title" }, import_utils.locales.getText("registry.sections.title"))), /* @__PURE__ */ import_react.default.createElement(
475
+ import_components.SectionList,
476
+ {
477
+ sections: localSections,
478
+ selectedSectionId: currentSectionId,
479
+ onSectionSelect: handleSectionSelect,
480
+ loading,
481
+ hasMore,
482
+ onLoadMore: handleLoadMore
483
+ }
484
+ )), /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-settings-registry-content" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-settings-registry-content-header" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-settings-registry-content-title" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-settings-registry-content-main-title" }, import_utils.locales.getText("registry.title"))), /* @__PURE__ */ import_react.default.createElement(
485
+ import_materials.Button,
486
+ {
487
+ type: "primary",
488
+ icon: /* @__PURE__ */ import_react.default.createElement(import_icons.PlusOutlined, null),
489
+ onClick: handleAddGroup,
490
+ disabled: !currentSection
491
+ },
492
+ import_utils.locales.getText("registry.action.add.group")
493
+ )), /* @__PURE__ */ import_react.default.createElement(
494
+ import_components.SettingsTable,
495
+ {
496
+ section: currentSection,
497
+ groupList,
498
+ groupLoading,
499
+ onDataChange: handleDataChange,
500
+ onEditGroup: handleEditGroup,
501
+ onDeleteGroup: (groupId) => handleDeleteGroup({ id: groupId }),
502
+ onAddItem: handleAddItem,
503
+ onEditItem: handleEditItem,
504
+ onDeleteItem: (itemId) => handleDeleteItem({ id: itemId }),
505
+ onGroupReorder: handleGroupReorder,
506
+ onItemMove: handleItemMove
507
+ }
508
+ )), /* @__PURE__ */ import_react.default.createElement(
509
+ import_components.GroupModal,
510
+ {
511
+ open: groupModalOpen,
512
+ type: modalType,
513
+ data: editingGroup,
514
+ onOk: handleGroupSubmit,
515
+ onCancel: () => setGroupModalOpen(false)
516
+ }
517
+ ), /* @__PURE__ */ import_react.default.createElement(
518
+ import_components.ItemModal,
519
+ {
520
+ open: itemModalOpen,
521
+ type: modalType,
522
+ data: editingItem,
523
+ section: currentSection,
524
+ onOk: handleItemSubmit,
525
+ onCancel: () => setItemModalOpen(false)
526
+ }
527
+ ));
528
+ };
529
+ var registry_default = Registry;