@pisell/private-materials 3.4.156 → 3.4.157

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 (157) 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/meta.js +1 -1
  5. package/build/lowcode/preview.css +1 -1
  6. package/build/lowcode/preview.js +1 -1
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +12 -12
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +12 -12
  11. package/es/components/appointmentBooking/deposit/index.d.ts +1 -2
  12. package/es/components/appointmentBooking/index.d.ts +1 -2
  13. package/es/components/booking/dashboard/index.d.ts +1 -1
  14. package/es/components/booking/deposit/index.d.ts +1 -3
  15. package/es/components/booking/info/addServiceVariant/index.d.ts +1 -3
  16. package/es/components/booking/info/index.d.ts +1 -2
  17. package/es/components/booking/materiels/contacts/index.d.ts +1 -2
  18. package/es/components/booking/materiels/duration/index.d.ts +1 -2
  19. package/es/components/booking/materiels/startTime/index.d.ts +1 -2
  20. package/es/components/ecocup/cupList/index.d.ts +1 -2
  21. package/es/components/ecocup/cupProject/index.d.ts +2 -2
  22. package/es/components/ecocup/customerList/index.d.ts +2 -2
  23. package/es/components/eftpos/index.d.ts +1 -2
  24. package/es/components/eftposPay/index.d.ts +1 -2
  25. package/es/components/eventBooking/index.d.ts +1 -2
  26. package/es/components/kioskSkuDetail/index.d.ts +1 -1
  27. package/es/components/login/index.d.ts +1 -2
  28. package/es/components/pisellSelectCustomerModal/index.d.ts +1 -2
  29. package/es/components/productExtension/index.d.ts +1 -2
  30. package/es/components/ruleSetting/index.d.ts +1 -2
  31. package/es/components/scanOrder/index.d.ts +2 -2
  32. package/es/components/shoppingCart/index.d.ts +1 -2
  33. package/es/components/subTotal/index.d.ts +1 -1
  34. package/es/components/taxSelect/index.d.ts +1 -2
  35. package/es/components/ticketBooking/index.d.ts +1 -2
  36. package/es/components/venueBooking/index.d.ts +2 -2
  37. package/es/components/walletList/index.d.ts +1 -2
  38. package/es/index.d.ts +5 -1
  39. package/es/index.js +4 -2
  40. package/es/plus/inventory/BindingModal.js +94 -0
  41. package/es/plus/inventory/InventoryItemManagement.d.ts +7 -0
  42. package/es/plus/inventory/InventoryItemManagement.js +204 -0
  43. package/es/plus/inventory/InventoryLocationManagement.d.ts +7 -0
  44. package/es/plus/inventory/InventoryLocationManagement.js +296 -0
  45. package/es/plus/inventory/InventoryUnitManagement.d.ts +7 -0
  46. package/es/plus/inventory/InventoryUnitManagement.js +144 -0
  47. package/es/plus/inventory/ItemDrawer.js +266 -0
  48. package/es/plus/inventory/RecordDialog.js +141 -0
  49. package/es/plus/inventory/StockList.js +132 -0
  50. package/es/plus/inventory/api.js +66 -0
  51. package/es/plus/inventory/components.js +172 -0
  52. package/es/plus/inventory/context.js +118 -0
  53. package/es/plus/inventory/forms.js +46 -0
  54. package/es/plus/inventory/hooks.js +235 -0
  55. package/es/plus/inventory/index.less +559 -0
  56. package/es/plus/inventory/locales.js +277 -0
  57. package/es/plus/inventory/types.d.ts +10 -0
  58. package/es/plus/inventory/utils.js +24 -0
  59. package/es/plus/orderList/index.d.ts +1 -1
  60. package/es/plus/panpacificTask/PanpacificTask.d.ts +2 -2
  61. package/es/plus/pisellAdyenDashboard/index.d.ts +1 -1
  62. package/es/plus/pisellProResourcePickerModal/PisellFloorMapPaletteViewAllModal.d.ts +1 -1
  63. package/es/plus/pisellProResourcePickerModal/PisellProResourcePickerModal.d.ts +2 -2
  64. package/es/plus/pisellReservation/components/SelectFloorMapResourceDialog.d.ts +1 -1
  65. package/es/plus/pisellReservation/data/bookingToReservationTables.js +1 -1
  66. package/es/plus/pisellReservation/floorMap/floorPlanApi.js +1 -1
  67. package/es/plus/pisellReservation/floorMap/reservationMock.js +1 -1
  68. package/es/plus/pisellReservation/floorRoomCard/FloorRoomCardFromData.d.ts +1 -1
  69. package/es/plus/pisellReservation/floorRoomCard/ReservationFloorRoomCard.d.ts +1 -1
  70. package/es/plus/pisellSalesManagement/index.d.ts +1 -1
  71. package/es/plus/pisellTopology/PisellTopology.d.ts +2 -2
  72. package/es/plus/pisellTopology/TopologyDeviceCard.d.ts +1 -1
  73. package/es/plus/saasCreateOrganization/index.d.ts +1 -2
  74. package/es/plus/saleDetail/index.d.ts +2 -2
  75. package/es/plus/skuOptionsSelection/store/createStore.js +2 -2
  76. package/es/plus/walletPassGallery/components/passDetail/index.d.ts +1 -2
  77. package/es/plus/walletPassGallery/index.d.ts +1 -2
  78. package/es/pro/Login2.0/AuthModal.d.ts +1 -1
  79. package/es/pro/Login2.0/index.d.ts +1 -2
  80. package/es/pro/Login2.0/shared/types.d.ts +1 -1
  81. package/es/pro/Selector/Item.d.ts +1 -1
  82. package/lib/components/appointmentBooking/deposit/index.d.ts +2 -2
  83. package/lib/components/appointmentBooking/index.d.ts +2 -2
  84. package/lib/components/booking/dashboard/index.d.ts +1 -1
  85. package/lib/components/booking/deposit/index.d.ts +2 -3
  86. package/lib/components/booking/info/addServiceVariant/index.d.ts +2 -3
  87. package/lib/components/booking/info/index.d.ts +2 -2
  88. package/lib/components/booking/materiels/contacts/index.d.ts +2 -2
  89. package/lib/components/booking/materiels/duration/index.d.ts +2 -2
  90. package/lib/components/booking/materiels/resources/index.d.ts +1 -1
  91. package/lib/components/booking/materiels/startTime/index.d.ts +2 -2
  92. package/lib/components/ecocup/cupList/index.d.ts +2 -2
  93. package/lib/components/ecocup/cupProject/index.d.ts +2 -2
  94. package/lib/components/ecocup/customerList/index.d.ts +2 -2
  95. package/lib/components/eftpos/index.d.ts +2 -2
  96. package/lib/components/eftposPay/index.d.ts +2 -2
  97. package/lib/components/eventBooking/index.d.ts +2 -2
  98. package/lib/components/kioskSkuDetail/index.d.ts +1 -1
  99. package/lib/components/login/index.d.ts +2 -2
  100. package/lib/components/pisellCashCounting/types.d.ts +1 -1
  101. package/lib/components/pisellSelectCustomerModal/index.d.ts +2 -2
  102. package/lib/components/productExtension/index.d.ts +2 -2
  103. package/lib/components/ruleSetting/index.d.ts +2 -2
  104. package/lib/components/scanOrder/index.d.ts +2 -2
  105. package/lib/components/shoppingCart/index.d.ts +2 -2
  106. package/lib/components/subTotal/index.d.ts +1 -1
  107. package/lib/components/taxSelect/index.d.ts +2 -2
  108. package/lib/components/ticketBooking/index.d.ts +2 -2
  109. package/lib/components/venueBooking/index.d.ts +2 -2
  110. package/lib/components/walletList/index.d.ts +2 -2
  111. package/lib/index.d.ts +5 -1
  112. package/lib/index.js +6 -0
  113. package/lib/plus/clinetSearch/index.d.ts +1 -1
  114. package/lib/plus/inventory/BindingModal.js +96 -0
  115. package/lib/plus/inventory/InventoryItemManagement.d.ts +7 -0
  116. package/lib/plus/inventory/InventoryItemManagement.js +206 -0
  117. package/lib/plus/inventory/InventoryLocationManagement.d.ts +7 -0
  118. package/lib/plus/inventory/InventoryLocationManagement.js +298 -0
  119. package/lib/plus/inventory/InventoryUnitManagement.d.ts +7 -0
  120. package/lib/plus/inventory/InventoryUnitManagement.js +146 -0
  121. package/lib/plus/inventory/ItemDrawer.js +268 -0
  122. package/lib/plus/inventory/RecordDialog.js +143 -0
  123. package/lib/plus/inventory/StockList.js +134 -0
  124. package/lib/plus/inventory/api.js +66 -0
  125. package/lib/plus/inventory/components.js +181 -0
  126. package/lib/plus/inventory/context.js +121 -0
  127. package/lib/plus/inventory/forms.js +50 -0
  128. package/lib/plus/inventory/hooks.js +240 -0
  129. package/lib/plus/inventory/index.less +559 -0
  130. package/lib/plus/inventory/locales.js +277 -0
  131. package/lib/plus/inventory/types.d.ts +10 -0
  132. package/lib/plus/inventory/utils.js +30 -0
  133. package/lib/plus/orderList/index.d.ts +1 -1
  134. package/lib/plus/panpacificTask/PanpacificTask.d.ts +2 -2
  135. package/lib/plus/pisellAdyenDashboard/index.d.ts +1 -1
  136. package/lib/plus/pisellProResourcePickerModal/PisellFloorMapPaletteViewAllModal.d.ts +1 -1
  137. package/lib/plus/pisellProResourcePickerModal/PisellProResourcePickerModal.d.ts +2 -2
  138. package/lib/plus/pisellReservation/components/SelectFloorMapResourceDialog.d.ts +1 -1
  139. package/lib/plus/pisellReservation/floorRoomCard/FloorRoomCardFromData.d.ts +1 -1
  140. package/lib/plus/pisellReservation/floorRoomCard/ReservationFloorRoomCard.d.ts +1 -1
  141. package/lib/plus/pisellSalesManagement/index.d.ts +1 -1
  142. package/lib/plus/pisellTopology/PisellTopology.d.ts +2 -2
  143. package/lib/plus/pisellTopology/TopologyDeviceCard.d.ts +1 -1
  144. package/lib/plus/saasCreateOrganization/index.d.ts +2 -2
  145. package/lib/plus/saleDetail/index.d.ts +2 -2
  146. package/lib/plus/walletPassGallery/components/passDetail/index.d.ts +2 -2
  147. package/lib/plus/walletPassGallery/index.d.ts +2 -2
  148. package/lib/pro/Selector/Item.d.ts +1 -1
  149. package/lowcode/inventory-item-management/meta.ts +20 -0
  150. package/lowcode/inventory-location-management/meta.ts +20 -0
  151. package/lowcode/inventory-unit-management/meta.ts +20 -0
  152. package/package.json +3 -3
  153. package/es/plus/pisellReservation/floorRoomCard/views/RoomCardHeaderView.d.ts +0 -1
  154. package/es/plus/pisellReservation/index.js +0 -17
  155. package/lib/plus/pisellReservation/floorRoomCard/mapFloorRoomCardViewProps.d.ts +0 -1
  156. package/lib/plus/pisellReservation/floorRoomCard/views/RoomCardHeaderView.d.ts +0 -1
  157. /package/es/{plus/pisellReservation/floorRoomCard/mapFloorRoomCardViewProps.d.ts → private-materials/lowcode/authmodal/meta.d.ts} +0 -0
@@ -0,0 +1,268 @@
1
+ const require_runtime = require("../../_virtual/_rolldown/runtime.js");
2
+ const require_asyncToGenerator = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
3
+ const require_utils = require("./utils.js");
4
+ const require_context = require("./context.js");
5
+ const require_hooks = require("./hooks.js");
6
+ const require_components = require("./components.js");
7
+ const require_forms = require("./forms.js");
8
+ const require_StockList = require("./StockList.js");
9
+ let react = require("react");
10
+ react = require_runtime.__toESM(react);
11
+ let antd = require("antd");
12
+ let _ant_design_icons = require("@ant-design/icons");
13
+ //#region src/plus/inventory/ItemDrawer.tsx
14
+ function DetailRow({ label, children }) {
15
+ return /* @__PURE__ */ react.default.createElement("div", { className: "inventory-drawer__info-row" }, /* @__PURE__ */ react.default.createElement("dt", null, label), /* @__PURE__ */ react.default.createElement("dd", null, children));
16
+ }
17
+ function ItemDrawer({ target, onClose, onChanged }) {
18
+ const { api, t, name, success, scopeId } = require_context.useInventory();
19
+ const [itemId, setItemId] = (0, react.useState)(target.id);
20
+ const [mode, setMode] = (0, react.useState)(target.mode);
21
+ const [tab, setTab] = (0, react.useState)("basic");
22
+ const [bindingsVisited, setBindingsVisited] = (0, react.useState)(false);
23
+ const [form] = antd.Form.useForm();
24
+ const dirty = require_hooks.useUnsavedChanges();
25
+ const mutation = require_hooks.useInventoryMutation();
26
+ const query = require_hooks.useInventoryQuery(() => api.detail("item", itemId, ["unit"]), `item-${itemId}`, !!itemId);
27
+ const units = require_hooks.useInventoryQuery(() => api.units(), "drawer-units");
28
+ const record = query.data;
29
+ const readonly = mode === "view";
30
+ const unavailable = !!itemId && !query.loading && !query.error && record === null;
31
+ const disabled = readonly || mutation.busy || query.loading || !!query.error || unavailable;
32
+ (0, react.useEffect)(() => {
33
+ if (itemId && !record) return;
34
+ form.setFieldsValue(record ? {
35
+ name: record.name,
36
+ unit_id: record.unit_id || null,
37
+ sku: record.sku,
38
+ barcode: record.barcode,
39
+ cover: record.cover,
40
+ note: record.note,
41
+ stock_mode: record.stock_mode,
42
+ status: record.status
43
+ } : {
44
+ name: { original: "" },
45
+ unit_id: null,
46
+ sku: null,
47
+ barcode: null,
48
+ cover: null,
49
+ note: null,
50
+ stock_mode: "tracked",
51
+ status: "active"
52
+ });
53
+ dirty.setDirty(false);
54
+ }, [
55
+ record,
56
+ itemId,
57
+ form
58
+ ]);
59
+ const close = function() {
60
+ var _ref = require_asyncToGenerator._asyncToGenerator(function* () {
61
+ if (!mutation.busy && (yield dirty.canLeave())) onClose();
62
+ });
63
+ return function close() {
64
+ return _ref.apply(this, arguments);
65
+ };
66
+ }();
67
+ const cancelEdit = function() {
68
+ var _ref2 = require_asyncToGenerator._asyncToGenerator(function* () {
69
+ if (!(yield dirty.canLeave())) return;
70
+ if (!itemId) {
71
+ onClose();
72
+ return;
73
+ }
74
+ dirty.setDirty(false);
75
+ setMode("view");
76
+ query.reload();
77
+ });
78
+ return function cancelEdit() {
79
+ return _ref2.apply(this, arguments);
80
+ };
81
+ }();
82
+ const save = () => mutation.run(require_asyncToGenerator._asyncToGenerator(function* () {
83
+ let values;
84
+ try {
85
+ values = yield form.validateFields();
86
+ } catch (_unused) {
87
+ return;
88
+ }
89
+ setItemId((yield api.save("item", itemId, {
90
+ name: values.name,
91
+ unit_id: values.unit_id || null,
92
+ sku: require_utils.optionalText(values.sku),
93
+ barcode: require_utils.optionalText(values.barcode),
94
+ cover: require_utils.optionalText(values.cover),
95
+ note: require_utils.optionalText(values.note),
96
+ stock_mode: values.stock_mode,
97
+ status: values.status
98
+ })).id);
99
+ setMode("view");
100
+ dirty.setDirty(false);
101
+ query.reload();
102
+ success("success");
103
+ onChanged();
104
+ }));
105
+ const unitOptions = (units.data || []).map((unit) => ({
106
+ value: unit.id,
107
+ label: `${name(unit)}${unit.status === "inactive" ? ` (${t("inactive")})` : ""}`
108
+ }));
109
+ if ((record === null || record === void 0 ? void 0 : record.unit_id) && !unitOptions.some((option) => option.value === record.unit_id)) unitOptions.push({
110
+ value: record.unit_id,
111
+ label: record.unit ? name(record.unit) : `${t("missing")} (#${record.unit_id})`
112
+ });
113
+ const basic = /* @__PURE__ */ react.default.createElement(antd.Form, {
114
+ form,
115
+ layout: "vertical",
116
+ disabled,
117
+ onValuesChange: () => dirty.setDirty(true)
118
+ }, /* @__PURE__ */ react.default.createElement(antd.Card, {
119
+ className: "inventory-drawer__card",
120
+ title: t("basic")
121
+ }, /* @__PURE__ */ react.default.createElement(require_forms.NameField, { disabled }), /* @__PURE__ */ react.default.createElement("div", { className: "inventory-form-columns" }, /* @__PURE__ */ react.default.createElement(antd.Form.Item, {
122
+ name: "sku",
123
+ label: t("sku")
124
+ }, /* @__PURE__ */ react.default.createElement(antd.Input, { maxLength: 128 })), /* @__PURE__ */ react.default.createElement(antd.Form.Item, {
125
+ name: "barcode",
126
+ label: t("barcode")
127
+ }, /* @__PURE__ */ react.default.createElement(antd.Input, { maxLength: 128 })), /* @__PURE__ */ react.default.createElement(antd.Form.Item, {
128
+ name: "unit_id",
129
+ label: t("unit")
130
+ }, /* @__PURE__ */ react.default.createElement(antd.Select, {
131
+ showSearch: true,
132
+ allowClear: true,
133
+ optionFilterProp: "label",
134
+ placeholder: t("noUnit"),
135
+ options: unitOptions,
136
+ loading: units.loading,
137
+ onDropdownVisibleChange: (open) => {
138
+ if (open) units.reload();
139
+ }
140
+ })), /* @__PURE__ */ react.default.createElement(antd.Form.Item, {
141
+ name: "stock_mode",
142
+ label: t("stockMode"),
143
+ rules: [{
144
+ required: true,
145
+ message: t("required")
146
+ }]
147
+ }, /* @__PURE__ */ react.default.createElement(antd.Select, { options: ["tracked", "unlimited"].map((value) => ({
148
+ value,
149
+ label: t(value)
150
+ })) }))), /* @__PURE__ */ react.default.createElement(require_components.RequestError, {
151
+ error: units.error,
152
+ retry: units.reload
153
+ }), /* @__PURE__ */ react.default.createElement(antd.Form.Item, {
154
+ name: "cover",
155
+ label: t("cover"),
156
+ rules: [{ validator: (_, value) => {
157
+ if (!(value === null || value === void 0 ? void 0 : value.trim())) return Promise.resolve();
158
+ try {
159
+ const url = new URL(value.trim());
160
+ if (["https:", "http:"].includes(url.protocol) && value.trim().length <= 255) return Promise.resolve();
161
+ } catch (_unused2) {}
162
+ return Promise.reject(new Error(t("invalidUrl")));
163
+ } }]
164
+ }, /* @__PURE__ */ react.default.createElement(antd.Input, { maxLength: 255 })), /* @__PURE__ */ react.default.createElement(antd.Form.Item, {
165
+ name: "note",
166
+ label: t("note")
167
+ }, /* @__PURE__ */ react.default.createElement(antd.Input.TextArea, {
168
+ maxLength: 500,
169
+ rows: 3,
170
+ showCount: true
171
+ })), /* @__PURE__ */ react.default.createElement(require_forms.StatusField, null)));
172
+ const details = record && /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement(antd.Card, {
173
+ className: "inventory-drawer__card",
174
+ title: t("basic")
175
+ }, /* @__PURE__ */ react.default.createElement("dl", { className: "inventory-drawer__info-list" }, /* @__PURE__ */ react.default.createElement(DetailRow, { label: t("name") }, name(record)), /* @__PURE__ */ react.default.createElement(DetailRow, { label: t("sku") }, record.sku || "—"), /* @__PURE__ */ react.default.createElement(DetailRow, { label: t("barcode") }, record.barcode || "—"), /* @__PURE__ */ react.default.createElement(DetailRow, { label: t("unit") }, record.unit ? name(record.unit) : record.unit_id ? `${t("missing")} (#${record.unit_id})` : t("noUnit")), /* @__PURE__ */ react.default.createElement(DetailRow, { label: t("cover") }, record.cover || "—"), /* @__PURE__ */ react.default.createElement(DetailRow, { label: t("note") }, record.note || "—"))), /* @__PURE__ */ react.default.createElement(antd.Card, {
176
+ className: "inventory-drawer__card",
177
+ title: t("status")
178
+ }, /* @__PURE__ */ react.default.createElement("dl", { className: "inventory-drawer__info-list" }, /* @__PURE__ */ react.default.createElement(DetailRow, { label: t("status") }, /* @__PURE__ */ react.default.createElement(require_components.StatusTag, { status: record.status })), /* @__PURE__ */ react.default.createElement(DetailRow, { label: t("stockMode") }, t(record.stock_mode)))), /* @__PURE__ */ react.default.createElement(antd.Card, {
179
+ className: "inventory-drawer__card",
180
+ title: t("stockSummary")
181
+ }, /* @__PURE__ */ react.default.createElement("div", { className: "inventory-metrics" }, /* @__PURE__ */ react.default.createElement("div", null, /* @__PURE__ */ react.default.createElement("span", null, t("totalQuantity")), /* @__PURE__ */ react.default.createElement("strong", null, require_utils.inventoryQuantity(record.stock_quantity))), /* @__PURE__ */ react.default.createElement("div", null, /* @__PURE__ */ react.default.createElement("span", null, t("totalAvailable")), /* @__PURE__ */ react.default.createElement("strong", null, require_utils.inventoryQuantity(record.stock_available_quantity))))));
182
+ const title = mode === "create" ? `${t("add")} ${t("item")}` : record ? name(record) : `${t("item")} #${itemId}`;
183
+ const bindingDisabled = !itemId || !readonly || query.loading || unavailable || !!query.error;
184
+ const bindingHint = !itemId ? t("saveFirst") : !readonly ? t("editBasicFirst") : void 0;
185
+ return /* @__PURE__ */ react.default.createElement(antd.Drawer, {
186
+ open: true,
187
+ width: "min(720px, 100vw)",
188
+ onClose: () => void close(),
189
+ maskClosable: false,
190
+ closable: false,
191
+ destroyOnClose: true,
192
+ className: "inventory-drawer",
193
+ rootClassName: "inventory-drawer-root",
194
+ "aria-labelledby": `${scopeId}-item-drawer-title`,
195
+ styles: { body: {
196
+ padding: 0,
197
+ overflow: "hidden"
198
+ } }
199
+ }, /* @__PURE__ */ react.default.createElement("div", { className: "inventory-drawer__root" }, /* @__PURE__ */ react.default.createElement("nav", {
200
+ className: "inventory-drawer__sidebar",
201
+ "aria-label": t("item")
202
+ }, /* @__PURE__ */ react.default.createElement("button", {
203
+ type: "button",
204
+ className: `inventory-drawer__sidebar-item ${tab === "basic" ? "is-active" : ""}`,
205
+ "aria-current": tab === "basic" ? "page" : void 0,
206
+ onClick: () => setTab("basic")
207
+ }, /* @__PURE__ */ react.default.createElement(_ant_design_icons.InfoCircleOutlined, null), /* @__PURE__ */ react.default.createElement("span", null, t("basic"))), /* @__PURE__ */ react.default.createElement(antd.Tooltip, {
208
+ title: bindingHint,
209
+ placement: "right"
210
+ }, /* @__PURE__ */ react.default.createElement("span", { className: "inventory-drawer__sidebar-slot" }, /* @__PURE__ */ react.default.createElement("button", {
211
+ type: "button",
212
+ className: `inventory-drawer__sidebar-item ${tab === "bindings" ? "is-active" : ""}`,
213
+ "aria-current": tab === "bindings" ? "page" : void 0,
214
+ disabled: bindingDisabled,
215
+ onClick: () => {
216
+ setBindingsVisited(true);
217
+ setTab("bindings");
218
+ }
219
+ }, /* @__PURE__ */ react.default.createElement(_ant_design_icons.LinkOutlined, null), /* @__PURE__ */ react.default.createElement("span", null, t("bindings")))))), /* @__PURE__ */ react.default.createElement("div", { className: "inventory-drawer__main" }, /* @__PURE__ */ react.default.createElement("header", { className: "inventory-drawer__header" }, /* @__PURE__ */ react.default.createElement("div", { className: "inventory-drawer__icon" }, (record === null || record === void 0 ? void 0 : record.cover) && /* @__PURE__ */ react.default.createElement("img", {
220
+ src: record.cover,
221
+ alt: ""
222
+ }), !(record === null || record === void 0 ? void 0 : record.cover) && /* @__PURE__ */ react.default.createElement(_ant_design_icons.AppstoreOutlined, null)), /* @__PURE__ */ react.default.createElement("div", { className: "inventory-drawer__heading" }, /* @__PURE__ */ react.default.createElement("h2", { id: `${scopeId}-item-drawer-title` }, title), /* @__PURE__ */ react.default.createElement("div", { className: "inventory-drawer__subtitle" }, (record === null || record === void 0 ? void 0 : record.sku) || t("item"))), /* @__PURE__ */ react.default.createElement(antd.Button, {
223
+ type: "text",
224
+ icon: /* @__PURE__ */ react.default.createElement(_ant_design_icons.CloseOutlined, null),
225
+ "aria-label": t("close"),
226
+ disabled: mutation.busy,
227
+ onClick: () => void close()
228
+ })), /* @__PURE__ */ react.default.createElement("div", { className: "inventory-drawer__content" }, /* @__PURE__ */ react.default.createElement(require_components.RequestError, {
229
+ error: query.error,
230
+ retry: query.reload
231
+ }), unavailable && /* @__PURE__ */ react.default.createElement(antd.Alert, {
232
+ type: "warning",
233
+ message: t("missing"),
234
+ showIcon: true
235
+ }), /* @__PURE__ */ react.default.createElement(antd.Spin, { spinning: query.loading }, /* @__PURE__ */ react.default.createElement("section", {
236
+ hidden: tab !== "basic",
237
+ "aria-label": t("basic")
238
+ }, readonly && details, /* @__PURE__ */ react.default.createElement("div", { hidden: readonly }, basic)), /* @__PURE__ */ react.default.createElement("section", {
239
+ hidden: tab !== "bindings",
240
+ "aria-label": t("bindings")
241
+ }, bindingsVisited && itemId && !unavailable && !query.error && /* @__PURE__ */ react.default.createElement(antd.Card, {
242
+ className: "inventory-drawer__card",
243
+ title: t("bindings")
244
+ }, /* @__PURE__ */ react.default.createElement(require_StockList.default, {
245
+ key: itemId,
246
+ owner: "item",
247
+ id: itemId,
248
+ onChanged: () => {
249
+ query.reload();
250
+ onChanged();
251
+ }
252
+ }))))), /* @__PURE__ */ react.default.createElement("footer", { className: "inventory-drawer__footer" }, /* @__PURE__ */ react.default.createElement(antd.Button, {
253
+ disabled: mutation.busy,
254
+ onClick: () => void (readonly ? close() : cancelEdit())
255
+ }, t(readonly ? "close" : "cancel")), /* @__PURE__ */ react.default.createElement(antd.Button, {
256
+ type: "primary",
257
+ loading: mutation.busy,
258
+ disabled: query.loading || !!query.error || unavailable || readonly && !record,
259
+ onClick: () => {
260
+ if (readonly) {
261
+ setMode("edit");
262
+ setTab("basic");
263
+ } else save();
264
+ }
265
+ }, t(readonly ? "edit" : "save"))))));
266
+ }
267
+ //#endregion
268
+ exports.default = ItemDrawer;
@@ -0,0 +1,143 @@
1
+ const require_runtime = require("../../_virtual/_rolldown/runtime.js");
2
+ const require_asyncToGenerator = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
3
+ const require_utils = require("./utils.js");
4
+ const require_context = require("./context.js");
5
+ const require_hooks = require("./hooks.js");
6
+ const require_components = require("./components.js");
7
+ const require_forms = require("./forms.js");
8
+ const require_StockList = require("./StockList.js");
9
+ let react = require("react");
10
+ react = require_runtime.__toESM(react);
11
+ let antd = require("antd");
12
+ let _pisell_materials = require("@pisell/materials");
13
+ //#region src/plus/inventory/RecordDialog.tsx
14
+ function RecordDialog({ target, onClose, onSaved }) {
15
+ var _shelf, _ref, _location;
16
+ const { api, t, success } = require_context.useInventory();
17
+ const [form] = antd.Form.useForm();
18
+ const [mode, setMode] = (0, react.useState)(target.mode);
19
+ const dirty = require_hooks.useUnsavedChanges();
20
+ const mutation = require_hooks.useInventoryMutation();
21
+ const query = require_hooks.useInventoryQuery(() => api.detail(target.resource, target.id, target.resource === "shelf" ? ["location"] : target.resource === "space" ? ["shelf.location"] : void 0), `${target.resource}-${target.id}`, !!target.id);
22
+ const readonly = mode === "view";
23
+ const locationId = antd.Form.useWatch("location_id", form);
24
+ const record = query.data;
25
+ const currentShelf = (_shelf = record === null || record === void 0 ? void 0 : record.shelf) !== null && _shelf !== void 0 ? _shelf : target.shelf;
26
+ const currentLocation = (_ref = (_location = record === null || record === void 0 ? void 0 : record.location) !== null && _location !== void 0 ? _location : currentShelf === null || currentShelf === void 0 ? void 0 : currentShelf.location) !== null && _ref !== void 0 ? _ref : target.location;
27
+ (0, react.useEffect)(() => {
28
+ var _record$sort, _target$location$id, _target$location, _target$shelf, _target$shelf2;
29
+ if (target.id && !record) return;
30
+ form.setFieldsValue(record ? {
31
+ name: record.name,
32
+ status: record.status,
33
+ sort: (_record$sort = record.sort) !== null && _record$sort !== void 0 ? _record$sort : 0,
34
+ location_id: target.resource === "shelf" ? record.location_id : currentShelf === null || currentShelf === void 0 ? void 0 : currentShelf.location_id,
35
+ shelf_id: target.resource === "space" ? record.shelf_id : void 0
36
+ } : {
37
+ name: { original: "" },
38
+ status: "active",
39
+ sort: 0,
40
+ location_id: (_target$location$id = (_target$location = target.location) === null || _target$location === void 0 ? void 0 : _target$location.id) !== null && _target$location$id !== void 0 ? _target$location$id : (_target$shelf = target.shelf) === null || _target$shelf === void 0 ? void 0 : _target$shelf.location_id,
41
+ shelf_id: (_target$shelf2 = target.shelf) === null || _target$shelf2 === void 0 ? void 0 : _target$shelf2.id
42
+ });
43
+ dirty.setDirty(false);
44
+ }, [
45
+ record,
46
+ target.id,
47
+ form
48
+ ]);
49
+ const close = function() {
50
+ var _ref2 = require_asyncToGenerator._asyncToGenerator(function* () {
51
+ if (!mutation.busy && (yield dirty.canLeave())) onClose();
52
+ });
53
+ return function close() {
54
+ return _ref2.apply(this, arguments);
55
+ };
56
+ }();
57
+ const submit = () => mutation.run(require_asyncToGenerator._asyncToGenerator(function* () {
58
+ let values;
59
+ try {
60
+ values = yield form.validateFields();
61
+ } catch (_unused) {
62
+ return;
63
+ }
64
+ const payload = {
65
+ name: values.name,
66
+ status: values.status,
67
+ sort: values.sort
68
+ };
69
+ if (target.resource === "shelf") payload.location_id = values.location_id;
70
+ if (target.resource === "space") payload.shelf_id = values.shelf_id;
71
+ const saved = yield api.save(target.resource, target.id, payload);
72
+ dirty.setDirty(false);
73
+ success("success");
74
+ onSaved(saved);
75
+ }));
76
+ const label = t(target.resource === "item-unit" ? "unit" : target.resource);
77
+ const unavailable = !!target.id && !query.loading && !query.error && record === null;
78
+ const disabled = readonly || mutation.busy || query.loading || !!query.error || unavailable;
79
+ return /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellModal, {
80
+ open: true,
81
+ title: `${t(mode === "create" ? "add" : mode === "edit" ? "edit" : "view")} · ${label}`,
82
+ size: target.resource === "space" && readonly ? "large" : "middle",
83
+ onCancel: () => void close(),
84
+ closable: !mutation.busy,
85
+ maskClosable: false,
86
+ cancelText: t(readonly ? "close" : "cancel"),
87
+ cancelButtonProps: { disabled: mutation.busy },
88
+ okText: t(readonly ? "edit" : "save"),
89
+ okVisible: !unavailable && !query.error,
90
+ okButtonProps: { disabled: query.loading },
91
+ confirmLoading: mutation.busy,
92
+ onOk: () => {
93
+ if (readonly) setMode("edit");
94
+ else submit();
95
+ }
96
+ }, /* @__PURE__ */ react.default.createElement("div", { className: "inventory-modal-body" }, /* @__PURE__ */ react.default.createElement(require_components.RequestError, {
97
+ error: query.error,
98
+ retry: query.reload
99
+ }), unavailable && /* @__PURE__ */ react.default.createElement(antd.Alert, {
100
+ type: "warning",
101
+ showIcon: true,
102
+ message: t("missing")
103
+ }), /* @__PURE__ */ react.default.createElement(antd.Spin, { spinning: query.loading }, /* @__PURE__ */ react.default.createElement(antd.Form, {
104
+ form,
105
+ layout: "vertical",
106
+ disabled,
107
+ onValuesChange: () => dirty.setDirty(true)
108
+ }, /* @__PURE__ */ react.default.createElement(require_forms.NameField, { disabled }), target.resource !== "item-unit" && target.resource !== "location" && /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement(antd.Form.Item, {
109
+ name: "location_id",
110
+ label: t("location"),
111
+ rules: [{
112
+ required: true,
113
+ message: t("required")
114
+ }]
115
+ }, /* @__PURE__ */ react.default.createElement(require_components.PagedInventorySelect, {
116
+ resource: "location",
117
+ disabled,
118
+ selected: currentLocation,
119
+ placeholder: t("chooseLocation"),
120
+ onChange: () => {
121
+ if (target.resource === "space") form.setFieldValue("shelf_id", void 0);
122
+ }
123
+ })), target.resource === "space" && /* @__PURE__ */ react.default.createElement(antd.Form.Item, {
124
+ name: "shelf_id",
125
+ label: t("shelf"),
126
+ rules: [{
127
+ required: true,
128
+ message: t("required")
129
+ }]
130
+ }, /* @__PURE__ */ react.default.createElement(require_components.PagedInventorySelect, {
131
+ key: `shelf-${locationId}`,
132
+ resource: "shelf",
133
+ disabled: disabled || !locationId,
134
+ filters: { location_id: locationId },
135
+ selected: currentShelf,
136
+ placeholder: t("chooseShelf")
137
+ }))), /* @__PURE__ */ react.default.createElement("div", { className: "inventory-form-columns" }, /* @__PURE__ */ react.default.createElement(require_forms.StatusField, null), /* @__PURE__ */ react.default.createElement(require_forms.SortField, null))), /* @__PURE__ */ react.default.createElement("p", { className: "inventory-muted" }, t("statusHint")), !readonly && (target.resource === "shelf" || target.resource === "space") && /* @__PURE__ */ react.default.createElement("p", { className: "inventory-muted" }, t("parentHint")), readonly && target.resource === "space" && record && /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement("div", { className: "inventory-section-heading" }, /* @__PURE__ */ react.default.createElement("h3", null, t("referencedStock")), /* @__PURE__ */ react.default.createElement("span", null, t("totalQuantity"), ":", " ", require_utils.inventoryQuantity(record.stock_quantity))), /* @__PURE__ */ react.default.createElement(require_StockList.default, {
138
+ owner: "space",
139
+ id: record.id
140
+ })))));
141
+ }
142
+ //#endregion
143
+ exports.default = RecordDialog;
@@ -0,0 +1,134 @@
1
+ const require_runtime = require("../../_virtual/_rolldown/runtime.js");
2
+ const require_objectSpread2 = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
3
+ const require_asyncToGenerator = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
4
+ const require_utils = require("./utils.js");
5
+ const require_context = require("./context.js");
6
+ const require_hooks = require("./hooks.js");
7
+ const require_components = require("./components.js");
8
+ const require_BindingModal = require("./BindingModal.js");
9
+ let react = require("react");
10
+ react = require_runtime.__toESM(react);
11
+ let antd = require("antd");
12
+ //#region src/plus/inventory/StockList.tsx
13
+ function StockList({ owner, id, onChanged }) {
14
+ const { api, t, name, confirm, success } = require_context.useInventory();
15
+ const [binding, setBinding] = (0, react.useState)(false);
16
+ const mutation = require_hooks.useInventoryMutation();
17
+ const list = require_hooks.useInventoryList("stock", {
18
+ [owner === "item" ? "item_id" : "space_id"]: id,
19
+ with: owner === "item" ? ["space.shelf.location"] : ["item.unit"]
20
+ });
21
+ const unbind = (stock) => void mutation.run(require_asyncToGenerator._asyncToGenerator(function* () {
22
+ if (!require_utils.canUnbind(stock)) return;
23
+ if (!(yield confirm("unbindTitle", t("unbindHint")))) return;
24
+ try {
25
+ yield api.unbind(stock.id);
26
+ success("unbound");
27
+ } finally {
28
+ list.reload();
29
+ onChanged === null || onChanged === void 0 || onChanged();
30
+ }
31
+ }));
32
+ const columns = (0, react.useMemo)(() => {
33
+ return [
34
+ ...owner === "item" ? [{
35
+ title: t("path"),
36
+ key: "path",
37
+ dataIndex: "space_id",
38
+ width: 320,
39
+ render: (_, stock) => {
40
+ var _space$shelf, _space$shelf2, _space$shelf3;
41
+ const space = stock.space;
42
+ return /* @__PURE__ */ react.default.createElement("div", { className: "inventory-path" }, /* @__PURE__ */ react.default.createElement("span", null, space ? `${name((_space$shelf = space.shelf) === null || _space$shelf === void 0 ? void 0 : _space$shelf.location)} / ${name(space.shelf)} / ${name(space)}` : `${t("missing")} (#${stock.space_id})`), /* @__PURE__ */ react.default.createElement(antd.Space, {
43
+ size: 4,
44
+ wrap: true
45
+ }, (space === null || space === void 0 || (_space$shelf2 = space.shelf) === null || _space$shelf2 === void 0 || (_space$shelf2 = _space$shelf2.location) === null || _space$shelf2 === void 0 ? void 0 : _space$shelf2.status) === "inactive" && /* @__PURE__ */ react.default.createElement("span", null, t("location"), ": ", /* @__PURE__ */ react.default.createElement(require_components.StatusTag, { status: "inactive" })), (space === null || space === void 0 || (_space$shelf3 = space.shelf) === null || _space$shelf3 === void 0 ? void 0 : _space$shelf3.status) === "inactive" && /* @__PURE__ */ react.default.createElement("span", null, t("shelf"), ": ", /* @__PURE__ */ react.default.createElement(require_components.StatusTag, { status: "inactive" })), (space === null || space === void 0 ? void 0 : space.status) === "inactive" && /* @__PURE__ */ react.default.createElement("span", null, t("space"), ": ", /* @__PURE__ */ react.default.createElement(require_components.StatusTag, { status: "inactive" }))));
46
+ }
47
+ }] : [{
48
+ title: t("item"),
49
+ key: "item",
50
+ dataIndex: "item_id",
51
+ width: 230,
52
+ render: (_, stock) => {
53
+ var _stock$item, _stock$item2;
54
+ return /* @__PURE__ */ react.default.createElement(antd.Space, {
55
+ direction: "vertical",
56
+ size: 0
57
+ }, /* @__PURE__ */ react.default.createElement("span", null, stock.item ? name(stock.item) : `${t("missing")} (#${stock.item_id})`), /* @__PURE__ */ react.default.createElement("span", { className: "inventory-muted" }, ((_stock$item = stock.item) === null || _stock$item === void 0 ? void 0 : _stock$item.sku) || "—", " ", /* @__PURE__ */ react.default.createElement(require_components.StatusTag, { status: (_stock$item2 = stock.item) === null || _stock$item2 === void 0 ? void 0 : _stock$item2.status })));
58
+ }
59
+ }, {
60
+ title: t("unit"),
61
+ key: "unit",
62
+ dataIndex: "unit",
63
+ render: (_, stock) => {
64
+ var _stock$item3;
65
+ return ((_stock$item3 = stock.item) === null || _stock$item3 === void 0 ? void 0 : _stock$item3.unit) ? name(stock.item.unit) : "—";
66
+ }
67
+ }],
68
+ {
69
+ title: t("quantity"),
70
+ key: "quantity",
71
+ dataIndex: "quantity",
72
+ align: "right",
73
+ render: require_utils.inventoryQuantity
74
+ },
75
+ {
76
+ title: t("available"),
77
+ key: "available_quantity",
78
+ dataIndex: "available_quantity",
79
+ align: "right",
80
+ render: require_utils.inventoryQuantity
81
+ },
82
+ ...owner === "item" ? [{
83
+ title: t("actions"),
84
+ key: "actions",
85
+ dataIndex: "actions",
86
+ render: (_, stock) => /* @__PURE__ */ react.default.createElement(antd.Tooltip, { title: !require_utils.canUnbind(stock) ? t("unbindBlocked") : void 0 }, /* @__PURE__ */ react.default.createElement("span", null, /* @__PURE__ */ react.default.createElement(antd.Button, {
87
+ type: "link",
88
+ danger: true,
89
+ disabled: !require_utils.canUnbind(stock) || mutation.busy || list.loading,
90
+ onClick: () => unbind(stock)
91
+ }, t("unbind"))))
92
+ }] : []
93
+ ];
94
+ }, [
95
+ owner,
96
+ t,
97
+ name,
98
+ mutation.busy,
99
+ list.loading,
100
+ confirm,
101
+ api,
102
+ onChanged
103
+ ]);
104
+ return /* @__PURE__ */ react.default.createElement("section", { className: "inventory-stock-list" }, /* @__PURE__ */ react.default.createElement(antd.Alert, {
105
+ type: "info",
106
+ showIcon: true,
107
+ className: "inventory-notice",
108
+ message: t("stockReadOnly")
109
+ }), /* @__PURE__ */ react.default.createElement("div", { className: "inventory-toolbar inventory-toolbar-end" }, /* @__PURE__ */ react.default.createElement(antd.Button, {
110
+ onClick: list.reload,
111
+ disabled: mutation.busy
112
+ }, t("refresh")), owner === "item" && /* @__PURE__ */ react.default.createElement(antd.Button, {
113
+ type: "primary",
114
+ onClick: () => setBinding(true),
115
+ disabled: mutation.busy
116
+ }, t("bind"))), /* @__PURE__ */ react.default.createElement(require_components.RequestError, {
117
+ error: list.error,
118
+ retry: list.reload
119
+ }), /* @__PURE__ */ react.default.createElement(require_components.InventoryTable, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, list), {}, {
120
+ columns,
121
+ loading: list.loading || mutation.busy,
122
+ tableKey: `${owner}-${id}-stocks`
123
+ })), binding && /* @__PURE__ */ react.default.createElement(require_BindingModal.default, {
124
+ itemId: id,
125
+ onClose: () => setBinding(false),
126
+ onBound: () => {
127
+ setBinding(false);
128
+ list.reload();
129
+ onChanged === null || onChanged === void 0 || onChanged();
130
+ }
131
+ }));
132
+ }
133
+ //#endregion
134
+ exports.default = StockList;
@@ -0,0 +1,66 @@
1
+ const require_asyncToGenerator = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
2
+ //#region src/plus/inventory/api.ts
3
+ var InventoryRequestError = class extends Error {
4
+ constructor(message, code) {
5
+ super(message);
6
+ this.code = code;
7
+ this.name = "InventoryRequestError";
8
+ }
9
+ };
10
+ const CONFIG = {
11
+ isPisell2: true,
12
+ fullResult: true,
13
+ customToast: () => void 0
14
+ };
15
+ const PREFIX = "/tenant/inventory";
16
+ function createInventoryApi(client) {
17
+ function call(_x, _x2, _x3) {
18
+ return _call.apply(this, arguments);
19
+ }
20
+ function _call() {
21
+ _call = require_asyncToGenerator._asyncToGenerator(function* (method, path, params) {
22
+ if (!(client === null || client === void 0 ? void 0 : client[method])) throw new InventoryRequestError("noRequest");
23
+ const result = yield method === "remove" ? client.remove(`${PREFIX}/${path}`, CONFIG) : client[method](`${PREFIX}/${path}`, params, CONFIG);
24
+ if (!result || result.status !== true || result.code !== 200) throw new InventoryRequestError((result === null || result === void 0 ? void 0 : result.message) || "failed", result === null || result === void 0 ? void 0 : result.code);
25
+ return result.data;
26
+ });
27
+ return _call.apply(this, arguments);
28
+ }
29
+ function list(_x4, _x5) {
30
+ return _list.apply(this, arguments);
31
+ }
32
+ function _list() {
33
+ _list = require_asyncToGenerator._asyncToGenerator(function* (resource, params) {
34
+ const data = yield call("get", resource, params);
35
+ if (!data || !Array.isArray(data.list) || typeof data.count !== "number") throw new InventoryRequestError("invalidResponse");
36
+ return data;
37
+ });
38
+ return _list.apply(this, arguments);
39
+ }
40
+ return {
41
+ list,
42
+ units() {
43
+ return require_asyncToGenerator._asyncToGenerator(function* (params = {}) {
44
+ const data = yield call("get", "item-unit", params);
45
+ if (data !== null && !Array.isArray(data)) throw new InventoryRequestError("invalidResponse");
46
+ return data !== null && data !== void 0 ? data : [];
47
+ }).apply(this, arguments);
48
+ },
49
+ detail: (resource, id, withRelations) => call("get", `${resource}/${id}`, withRelations ? { with: withRelations } : {}),
50
+ save(resource, id, payload) {
51
+ return require_asyncToGenerator._asyncToGenerator(function* () {
52
+ const data = yield call(id ? "put" : "post", id ? `${resource}/${id}` : resource, payload);
53
+ if (!data || !Number.isInteger(data.id) || data.id <= 0) throw new InventoryRequestError("invalidResponse");
54
+ return data;
55
+ })();
56
+ },
57
+ remove: (resource, id) => call("remove", `${resource}/${id}`),
58
+ bind: (itemId, spaceId) => call("post", "stock", {
59
+ item_id: itemId,
60
+ space_id: spaceId
61
+ }),
62
+ unbind: (stockId) => call("remove", `stock/${stockId}`)
63
+ };
64
+ }
65
+ //#endregion
66
+ exports.createInventoryApi = createInventoryApi;