@pisell/private-materials 6.3.220 → 6.3.222

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 (125) 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/render/default/view.css +1 -1
  6. package/build/lowcode/render/default/view.js +13 -13
  7. package/build/lowcode/view.css +1 -1
  8. package/build/lowcode/view.js +13 -13
  9. package/es/components/kioskSkuDetail/index.js +7 -7
  10. package/es/components/pay/toC/PaymentMethods/MWCreditCard/tds2.js +53 -26
  11. package/es/components/scanOrder/components/Content/index.js +14 -2
  12. package/es/components/scanOrder/components/ExitConfirmModal/index.js +84 -0
  13. package/es/components/scanOrder/components/ExitConfirmModal/index.less +182 -0
  14. package/es/components/scanOrder/locales.js +20 -0
  15. package/es/index.d.ts +9 -1
  16. package/es/index.js +6 -2
  17. package/es/plus/inventory/BindingModal.js +94 -0
  18. package/es/plus/inventory/InventoryItemManagement.d.ts +7 -0
  19. package/es/plus/inventory/InventoryItemManagement.js +204 -0
  20. package/es/plus/inventory/InventoryLocationManagement.d.ts +7 -0
  21. package/es/plus/inventory/InventoryLocationManagement.js +296 -0
  22. package/es/plus/inventory/InventoryUnitManagement.d.ts +7 -0
  23. package/es/plus/inventory/InventoryUnitManagement.js +144 -0
  24. package/es/plus/inventory/ItemDrawer.js +266 -0
  25. package/es/plus/inventory/RecordDialog.js +141 -0
  26. package/es/plus/inventory/StockList.js +132 -0
  27. package/es/plus/inventory/api.js +66 -0
  28. package/es/plus/inventory/components.js +172 -0
  29. package/es/plus/inventory/context.js +118 -0
  30. package/es/plus/inventory/forms.js +46 -0
  31. package/es/plus/inventory/hooks.js +235 -0
  32. package/es/plus/inventory/index.less +559 -0
  33. package/es/plus/inventory/locales.js +277 -0
  34. package/es/plus/inventory/types.d.ts +10 -0
  35. package/es/plus/inventory/utils.js +24 -0
  36. package/es/plus/panpacificTask/JobCard.js +22 -0
  37. package/es/plus/panpacificTask/JobDrawer.js +366 -0
  38. package/es/plus/panpacificTask/JobForm.js +312 -0
  39. package/es/plus/panpacificTask/JobStatus.js +29 -0
  40. package/es/plus/panpacificTask/PanpacificTask.d.ts +7 -0
  41. package/es/plus/panpacificTask/PanpacificTask.js +552 -0
  42. package/es/plus/panpacificTask/PhotoPreview.js +37 -0
  43. package/es/plus/panpacificTask/README.md +114 -0
  44. package/es/plus/panpacificTask/attachments.js +64 -0
  45. package/es/plus/panpacificTask/index.d.ts +2 -0
  46. package/es/plus/panpacificTask/index.less +539 -0
  47. package/es/plus/panpacificTask/locales.js +586 -0
  48. package/es/plus/panpacificTask/model.js +260 -0
  49. package/es/plus/panpacificTask/saveJob.js +68 -0
  50. package/es/plus/panpacificTask/serve.js +243 -0
  51. package/es/plus/panpacificTask/tenant.js +16 -0
  52. package/es/plus/panpacificTask/types.d.ts +19 -0
  53. package/es/plus/pisellReservation/data/bookingToReservationTables.js +1 -1
  54. package/es/plus/pisellReservation/floorMap/floorPlanApi.js +1 -1
  55. package/es/plus/pisellReservation/floorMap/reservationMock.js +1 -1
  56. package/es/plus/pisellSupersetDashboard/README.md +291 -0
  57. package/es/plus/pisellSupersetDashboard/index.d.ts +15 -0
  58. package/es/plus/pisellSupersetDashboard/index.js +187 -0
  59. package/es/plus/pisellSupersetDashboard/index.less +83 -0
  60. package/es/plus/pisellSupersetDashboard/locales.js +36 -0
  61. package/es/plus/pisellSupersetDashboard/serve.js +51 -0
  62. package/es/plus/pisellSupersetDashboard/types.d.ts +17 -0
  63. package/es/plus/skuOptionsSelection/store/createStore.js +2 -2
  64. package/es/private-materials/lowcode/authmodal/meta.d.ts +1 -0
  65. package/es/pro/Login2.0/AuthModal.d.ts +1 -1
  66. package/es/pro/Login2.0/index.d.ts +1 -2
  67. package/es/pro/Login2.0/shared/types.d.ts +1 -1
  68. package/lib/components/kioskSkuDetail/index.js +7 -7
  69. package/lib/components/pay/toC/PaymentMethods/MWCreditCard/tds2.js +53 -26
  70. package/lib/components/scanOrder/components/Content/index.js +14 -2
  71. package/lib/components/scanOrder/components/ExitConfirmModal/index.js +86 -0
  72. package/lib/components/scanOrder/components/ExitConfirmModal/index.less +182 -0
  73. package/lib/components/scanOrder/locales.js +20 -0
  74. package/lib/index.d.ts +9 -1
  75. package/lib/index.js +136 -126
  76. package/lib/plus/inventory/BindingModal.js +96 -0
  77. package/lib/plus/inventory/InventoryItemManagement.d.ts +7 -0
  78. package/lib/plus/inventory/InventoryItemManagement.js +206 -0
  79. package/lib/plus/inventory/InventoryLocationManagement.d.ts +7 -0
  80. package/lib/plus/inventory/InventoryLocationManagement.js +298 -0
  81. package/lib/plus/inventory/InventoryUnitManagement.d.ts +7 -0
  82. package/lib/plus/inventory/InventoryUnitManagement.js +146 -0
  83. package/lib/plus/inventory/ItemDrawer.js +268 -0
  84. package/lib/plus/inventory/RecordDialog.js +143 -0
  85. package/lib/plus/inventory/StockList.js +134 -0
  86. package/lib/plus/inventory/api.js +66 -0
  87. package/lib/plus/inventory/components.js +181 -0
  88. package/lib/plus/inventory/context.js +121 -0
  89. package/lib/plus/inventory/forms.js +50 -0
  90. package/lib/plus/inventory/hooks.js +240 -0
  91. package/lib/plus/inventory/index.less +559 -0
  92. package/lib/plus/inventory/locales.js +277 -0
  93. package/lib/plus/inventory/types.d.ts +10 -0
  94. package/lib/plus/inventory/utils.js +30 -0
  95. package/lib/plus/panpacificTask/JobCard.js +24 -0
  96. package/lib/plus/panpacificTask/JobDrawer.js +368 -0
  97. package/lib/plus/panpacificTask/JobForm.js +314 -0
  98. package/lib/plus/panpacificTask/JobStatus.js +33 -0
  99. package/lib/plus/panpacificTask/PanpacificTask.d.ts +7 -0
  100. package/lib/plus/panpacificTask/PanpacificTask.js +555 -0
  101. package/lib/plus/panpacificTask/PhotoPreview.js +39 -0
  102. package/lib/plus/panpacificTask/README.md +114 -0
  103. package/lib/plus/panpacificTask/attachments.js +66 -0
  104. package/lib/plus/panpacificTask/index.d.ts +2 -0
  105. package/lib/plus/panpacificTask/index.less +539 -0
  106. package/lib/plus/panpacificTask/locales.js +586 -0
  107. package/lib/plus/panpacificTask/model.js +289 -0
  108. package/lib/plus/panpacificTask/saveJob.js +68 -0
  109. package/lib/plus/panpacificTask/serve.js +260 -0
  110. package/lib/plus/panpacificTask/tenant.js +17 -0
  111. package/lib/plus/panpacificTask/types.d.ts +19 -0
  112. package/lib/plus/pisellSupersetDashboard/README.md +291 -0
  113. package/lib/plus/pisellSupersetDashboard/index.d.ts +15 -0
  114. package/lib/plus/pisellSupersetDashboard/index.js +189 -0
  115. package/lib/plus/pisellSupersetDashboard/index.less +83 -0
  116. package/lib/plus/pisellSupersetDashboard/locales.js +36 -0
  117. package/lib/plus/pisellSupersetDashboard/serve.js +52 -0
  118. package/lib/plus/pisellSupersetDashboard/types.d.ts +17 -0
  119. package/lowcode/inventory-item-management/meta.ts +20 -0
  120. package/lowcode/inventory-location-management/meta.ts +20 -0
  121. package/lowcode/inventory-unit-management/meta.ts +20 -0
  122. package/lowcode/panpacific-task/meta.ts +51 -0
  123. package/lowcode/pisell-superset-dashboard/meta.ts +75 -0
  124. package/package.json +4 -2
  125. package/es/plus/pisellReservation/index.js +0 -17
@@ -0,0 +1,94 @@
1
+ import { _asyncToGenerator } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
2
+ import { useInventory } from "./context.js";
3
+ import { useInventoryMutation } from "./hooks.js";
4
+ import { PagedInventorySelect } from "./components.js";
5
+ import React from "react";
6
+ import { Alert, Form } from "antd";
7
+ import { PisellModal } from "@pisell/materials";
8
+ //#region src/plus/inventory/BindingModal.tsx
9
+ function BindingModal({ itemId, onClose, onBound }) {
10
+ const { api, t, success } = useInventory();
11
+ const [form] = Form.useForm();
12
+ const locationId = Form.useWatch("location_id", form);
13
+ const shelfId = Form.useWatch("shelf_id", form);
14
+ const mutation = useInventoryMutation();
15
+ const submit = () => mutation.run(_asyncToGenerator(function* () {
16
+ let values;
17
+ try {
18
+ values = yield form.validateFields();
19
+ } catch (_unused) {
20
+ return;
21
+ }
22
+ yield api.bind(itemId, values.space_id);
23
+ success("bound");
24
+ onBound();
25
+ }));
26
+ return /* @__PURE__ */ React.createElement(PisellModal, {
27
+ open: true,
28
+ title: t("bind"),
29
+ size: "middle",
30
+ okText: t("bind"),
31
+ cancelText: t("cancel"),
32
+ confirmLoading: mutation.busy,
33
+ closable: !mutation.busy,
34
+ maskClosable: !mutation.busy,
35
+ cancelButtonProps: { disabled: mutation.busy },
36
+ onCancel: () => {
37
+ if (!mutation.busy) onClose();
38
+ },
39
+ onOk: () => void submit()
40
+ }, /* @__PURE__ */ React.createElement("div", { className: "inventory-modal-body" }, /* @__PURE__ */ React.createElement(Alert, {
41
+ className: "inventory-notice",
42
+ type: "info",
43
+ showIcon: true,
44
+ message: t("bindHint")
45
+ }), /* @__PURE__ */ React.createElement(Form, {
46
+ form,
47
+ layout: "vertical",
48
+ disabled: mutation.busy
49
+ }, /* @__PURE__ */ React.createElement(Form.Item, {
50
+ name: "location_id",
51
+ label: t("location"),
52
+ rules: [{
53
+ required: true,
54
+ message: t("required")
55
+ }]
56
+ }, /* @__PURE__ */ React.createElement(PagedInventorySelect, {
57
+ resource: "location",
58
+ placeholder: t("chooseLocation"),
59
+ disabled: mutation.busy,
60
+ onChange: () => form.setFieldsValue({
61
+ shelf_id: void 0,
62
+ space_id: void 0
63
+ })
64
+ })), /* @__PURE__ */ React.createElement(Form.Item, {
65
+ name: "shelf_id",
66
+ label: t("shelf"),
67
+ rules: [{
68
+ required: true,
69
+ message: t("required")
70
+ }]
71
+ }, /* @__PURE__ */ React.createElement(PagedInventorySelect, {
72
+ key: `shelf-${locationId}`,
73
+ resource: "shelf",
74
+ placeholder: t("chooseShelf"),
75
+ disabled: !locationId || mutation.busy,
76
+ filters: { location_id: locationId },
77
+ onChange: () => form.setFieldValue("space_id", void 0)
78
+ })), /* @__PURE__ */ React.createElement(Form.Item, {
79
+ name: "space_id",
80
+ label: t("space"),
81
+ rules: [{
82
+ required: true,
83
+ message: t("required")
84
+ }]
85
+ }, /* @__PURE__ */ React.createElement(PagedInventorySelect, {
86
+ key: `space-${shelfId}`,
87
+ resource: "space",
88
+ placeholder: t("chooseSpace"),
89
+ disabled: !shelfId || mutation.busy,
90
+ filters: { shelf_id: shelfId }
91
+ })))));
92
+ }
93
+ //#endregion
94
+ export { BindingModal as default };
@@ -0,0 +1,7 @@
1
+ import { InventoryPageProps } from "./types.js";
2
+ import React from "react";
3
+
4
+ //#region src/plus/inventory/InventoryItemManagement.d.ts
5
+ declare function InventoryItemManagement(props: InventoryPageProps): React.JSX.Element;
6
+ //#endregion
7
+ export { InventoryItemManagement };
@@ -0,0 +1,204 @@
1
+ import { _objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
2
+ import { _asyncToGenerator } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
3
+ import { inventoryQuantity } from "./utils.js";
4
+ import { InventoryProvider, useInventory } from "./context.js";
5
+ import { useInventoryList, useInventoryMutation, useInventoryQuery } from "./hooks.js";
6
+ import { InventoryHeader, InventoryTable, RequestError, SearchInput, StatusSelect, StatusTag } from "./components.js";
7
+ import ItemDrawer from "./ItemDrawer.js";
8
+ import React, { useMemo, useState } from "react";
9
+ import { Button, Select, Space, Tooltip } from "antd";
10
+ import { useDebounce } from "ahooks";
11
+ import { PlusOutlined, ReloadOutlined } from "@ant-design/icons";
12
+ //#region src/plus/inventory/InventoryItemManagement.tsx
13
+ function ItemPage({ className, style }) {
14
+ const { api, t, name, confirm, success } = useInventory();
15
+ const [search, setSearch] = useState("");
16
+ const keyword = useDebounce(search, { wait: 300 });
17
+ const [status, setStatus] = useState();
18
+ const [unit, setUnit] = useState();
19
+ const [stockMode, setStockMode] = useState();
20
+ const [target, setTarget] = useState();
21
+ const mutation = useInventoryMutation();
22
+ const units = useInventoryQuery(() => api.units(), "item-filter-units");
23
+ const list = useInventoryList("item", {
24
+ search: keyword || void 0,
25
+ status,
26
+ unit_id: unit,
27
+ stock_mode: stockMode,
28
+ with: ["unit"]
29
+ });
30
+ const remove = (record) => void mutation.run(_asyncToGenerator(function* () {
31
+ if (!(yield confirm("deleteTitle", /* @__PURE__ */ React.createElement(React.Fragment, null, name(record), /* @__PURE__ */ React.createElement("p", null, t("deleteHint")))))) return;
32
+ try {
33
+ yield api.remove("item", record.id);
34
+ success("deleted");
35
+ } finally {
36
+ list.reload();
37
+ }
38
+ }));
39
+ const columns = useMemo(() => [
40
+ {
41
+ title: t("item"),
42
+ key: "name",
43
+ dataIndex: "name",
44
+ width: 250,
45
+ render: (_, record) => /* @__PURE__ */ React.createElement("button", {
46
+ type: "button",
47
+ className: "inventory-item-link",
48
+ onClick: () => setTarget({
49
+ id: record.id,
50
+ mode: "view"
51
+ })
52
+ }, record.cover && /* @__PURE__ */ React.createElement("img", {
53
+ className: "inventory-cover inventory-cover-small",
54
+ src: record.cover,
55
+ alt: ""
56
+ }), /* @__PURE__ */ React.createElement("span", null, name(record)))
57
+ },
58
+ {
59
+ title: t("sku"),
60
+ key: "sku",
61
+ dataIndex: "sku",
62
+ render: (value) => value || "—"
63
+ },
64
+ {
65
+ title: t("barcode"),
66
+ key: "barcode",
67
+ dataIndex: "barcode",
68
+ render: (value) => value || "—"
69
+ },
70
+ {
71
+ title: t("unit"),
72
+ key: "unit",
73
+ dataIndex: "unit",
74
+ render: (_, record) => record.unit ? name(record.unit) : "—"
75
+ },
76
+ {
77
+ title: t("stockMode"),
78
+ key: "stock_mode",
79
+ dataIndex: "stock_mode",
80
+ render: (value) => t(value)
81
+ },
82
+ {
83
+ title: t("quantity"),
84
+ key: "stock_quantity",
85
+ dataIndex: "stock_quantity",
86
+ align: "right",
87
+ render: inventoryQuantity
88
+ },
89
+ {
90
+ title: t("available"),
91
+ key: "stock_available_quantity",
92
+ dataIndex: "stock_available_quantity",
93
+ align: "right",
94
+ render: inventoryQuantity
95
+ },
96
+ {
97
+ title: t("status"),
98
+ key: "status",
99
+ dataIndex: "status",
100
+ render: (value) => /* @__PURE__ */ React.createElement(StatusTag, { status: value })
101
+ },
102
+ {
103
+ title: t("actions"),
104
+ key: "actions",
105
+ dataIndex: "actions",
106
+ fixed: "right",
107
+ width: 210,
108
+ render: (_, record) => /* @__PURE__ */ React.createElement(Space, { size: 0 }, /* @__PURE__ */ React.createElement(Button, {
109
+ type: "link",
110
+ disabled: mutation.busy,
111
+ onClick: () => setTarget({
112
+ id: record.id,
113
+ mode: "view"
114
+ })
115
+ }, t("view")), /* @__PURE__ */ React.createElement(Button, {
116
+ type: "link",
117
+ disabled: mutation.busy,
118
+ onClick: () => setTarget({
119
+ id: record.id,
120
+ mode: "edit"
121
+ })
122
+ }, t("edit")), /* @__PURE__ */ React.createElement(Button, {
123
+ type: "link",
124
+ danger: true,
125
+ disabled: mutation.busy,
126
+ onClick: () => remove(record)
127
+ }, t("remove")))
128
+ }
129
+ ], [
130
+ t,
131
+ name,
132
+ mutation.busy,
133
+ confirm,
134
+ api
135
+ ]);
136
+ return /* @__PURE__ */ React.createElement("div", {
137
+ className: `inventory-page ${className || ""}`,
138
+ style
139
+ }, /* @__PURE__ */ React.createElement(InventoryHeader, {
140
+ title: t("items"),
141
+ description: t("itemHint")
142
+ }, /* @__PURE__ */ React.createElement(Button, {
143
+ type: "primary",
144
+ icon: /* @__PURE__ */ React.createElement(PlusOutlined, null),
145
+ disabled: mutation.busy,
146
+ onClick: () => setTarget({ mode: "create" })
147
+ }, t("add"), " ", t("item"))), /* @__PURE__ */ React.createElement("div", { className: "inventory-toolbar" }, /* @__PURE__ */ React.createElement(Tooltip, { title: t("searchHint") }, /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement(SearchInput, {
148
+ items: true,
149
+ value: search,
150
+ onChange: setSearch
151
+ }))), /* @__PURE__ */ React.createElement(Select, {
152
+ className: "inventory-filter",
153
+ showSearch: true,
154
+ allowClear: true,
155
+ optionFilterProp: "label",
156
+ placeholder: t("allUnits"),
157
+ loading: units.loading,
158
+ value: unit,
159
+ onChange: setUnit,
160
+ options: (units.data || []).map((record) => ({
161
+ value: record.id,
162
+ label: `${name(record)}${record.status === "inactive" ? ` (${t("inactive")})` : ""}`
163
+ }))
164
+ }), /* @__PURE__ */ React.createElement(Select, {
165
+ className: "inventory-filter",
166
+ allowClear: true,
167
+ placeholder: t("allStockModes"),
168
+ value: stockMode,
169
+ onChange: setStockMode,
170
+ options: ["tracked", "unlimited"].map((value) => ({
171
+ value,
172
+ label: t(value)
173
+ }))
174
+ }), /* @__PURE__ */ React.createElement(StatusSelect, {
175
+ value: status,
176
+ onChange: setStatus
177
+ }), /* @__PURE__ */ React.createElement(Button, {
178
+ icon: /* @__PURE__ */ React.createElement(ReloadOutlined, null),
179
+ disabled: mutation.busy,
180
+ onClick: () => {
181
+ list.reload();
182
+ units.reload();
183
+ }
184
+ }, t("refresh"))), /* @__PURE__ */ React.createElement(RequestError, {
185
+ error: list.error || units.error,
186
+ retry: () => {
187
+ list.reload();
188
+ units.reload();
189
+ }
190
+ }), /* @__PURE__ */ React.createElement(InventoryTable, _objectSpread2(_objectSpread2({}, list), {}, {
191
+ loading: list.loading || mutation.busy,
192
+ columns,
193
+ tableKey: "items"
194
+ })), target && /* @__PURE__ */ React.createElement(ItemDrawer, {
195
+ target,
196
+ onClose: () => setTarget(void 0),
197
+ onChanged: list.reload
198
+ }));
199
+ }
200
+ function InventoryItemManagement(props) {
201
+ return /* @__PURE__ */ React.createElement(InventoryProvider, { id: props.__id }, /* @__PURE__ */ React.createElement(ItemPage, props));
202
+ }
203
+ //#endregion
204
+ export { InventoryItemManagement as default };
@@ -0,0 +1,7 @@
1
+ import { InventoryPageProps } from "./types.js";
2
+ import React from "react";
3
+
4
+ //#region src/plus/inventory/InventoryLocationManagement.d.ts
5
+ declare function InventoryLocationManagement(props: InventoryPageProps): React.JSX.Element;
6
+ //#endregion
7
+ export { InventoryLocationManagement };
@@ -0,0 +1,296 @@
1
+ import { _objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
2
+ import { _asyncToGenerator } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
3
+ import { inventoryQuantity } from "./utils.js";
4
+ import { InventoryProvider, useInventory } from "./context.js";
5
+ import { useInventoryList, useInventoryMutation, useInventoryOptions, useInventoryQuery } from "./hooks.js";
6
+ import { InventoryHeader, InventoryNavLoading, InventoryTable, RequestError, SearchInput, StatusSelect, StatusTag } from "./components.js";
7
+ import RecordDialog from "./RecordDialog.js";
8
+ import React, { useEffect, useMemo, useState } from "react";
9
+ import { Breadcrumb, Button, Space, Tooltip } from "antd";
10
+ import { useDebounce } from "ahooks";
11
+ import { CaretRightOutlined, PlusOutlined, ReloadOutlined, RightOutlined } from "@ant-design/icons";
12
+ //#region src/plus/inventory/InventoryLocationManagement.tsx
13
+ function NavigationLocation({ record, expanded, onToggle, selection, onSelect, revision, selectedShelf }) {
14
+ const { t, name } = useInventory();
15
+ const shelves = useInventoryOptions("shelf", { location_id: record.id }, expanded, revision);
16
+ const rows = (selectedShelf === null || selectedShelf === void 0 ? void 0 : selectedShelf.location_id) === record.id && !shelves.rows.some((shelf) => shelf.id === selectedShelf.id) ? [selectedShelf, ...shelves.rows] : shelves.rows;
17
+ return /* @__PURE__ */ React.createElement("div", { className: "inventory-nav-location" }, /* @__PURE__ */ React.createElement("div", { className: `inventory-nav-row ${selection.kind === "location" && selection.id === record.id ? "is-selected" : ""}` }, /* @__PURE__ */ React.createElement(Button, {
18
+ type: "text",
19
+ "aria-expanded": expanded,
20
+ "aria-label": t(expanded ? "collapse" : "expand"),
21
+ icon: /* @__PURE__ */ React.createElement(CaretRightOutlined, {
22
+ rotate: expanded ? 90 : 0,
23
+ style: { fontSize: 12 }
24
+ }),
25
+ onClick: onToggle
26
+ }), /* @__PURE__ */ React.createElement("button", {
27
+ type: "button",
28
+ className: "inventory-nav-label",
29
+ onClick: () => onSelect({
30
+ kind: "location",
31
+ id: record.id
32
+ }),
33
+ title: name(record)
34
+ }, name(record), record.status === "inactive" && /* @__PURE__ */ React.createElement("span", {
35
+ className: "inventory-inactive-dot",
36
+ title: t("inactive")
37
+ }, " ", "· ", t("inactive")))), expanded && /* @__PURE__ */ React.createElement("div", { className: "inventory-nav-shelves" }, /* @__PURE__ */ React.createElement(RequestError, {
38
+ error: shelves.error,
39
+ retry: () => void shelves.reload()
40
+ }), rows.map((shelf) => /* @__PURE__ */ React.createElement("button", {
41
+ type: "button",
42
+ key: shelf.id,
43
+ className: `inventory-nav-row inventory-nav-shelf ${selection.kind === "shelf" && selection.id === shelf.id ? "is-selected" : ""}`,
44
+ onClick: () => onSelect({
45
+ kind: "shelf",
46
+ id: shelf.id
47
+ }),
48
+ title: name(shelf)
49
+ }, name(shelf), shelf.status === "inactive" && /* @__PURE__ */ React.createElement("span", { className: "inventory-inactive-dot" }, " ", "· ", t("inactive")))), shelves.loading && !shelves.hasMore && /* @__PURE__ */ React.createElement(InventoryNavLoading, null), !shelves.loading && !shelves.error && !rows.length && /* @__PURE__ */ React.createElement("span", { className: "inventory-nav-empty" }, t("empty")), shelves.hasMore && /* @__PURE__ */ React.createElement(Button, {
50
+ type: "text",
51
+ block: true,
52
+ loading: shelves.loading,
53
+ onClick: () => void shelves.loadMore()
54
+ }, t("loadMore"))));
55
+ }
56
+ function LocationPage({ className, style }) {
57
+ const { api, t, name, confirm, success, report } = useInventory();
58
+ const [selection, setSelection] = useState({ kind: "root" });
59
+ const [expanded, setExpanded] = useState(() => /* @__PURE__ */ new Set());
60
+ const [navigationRevision, setNavigationRevision] = useState(0);
61
+ const [target, setTarget] = useState();
62
+ const selectionKey = JSON.stringify(selection);
63
+ const [filter, setFilter] = useState({
64
+ key: selectionKey,
65
+ search: ""
66
+ });
67
+ const search = filter.key === selectionKey ? filter.search : "";
68
+ const status = filter.key === selectionKey ? filter.status : void 0;
69
+ const debouncedSearch = useDebounce(useMemo(() => ({
70
+ key: selectionKey,
71
+ search
72
+ }), [selectionKey, search]), { wait: 300 });
73
+ const keyword = debouncedSearch.key === selectionKey ? debouncedSearch.search : "";
74
+ const mutation = useInventoryMutation();
75
+ const locations = useInventoryOptions("location", {}, true, navigationRevision);
76
+ const selected = useInventoryQuery(() => selection.kind === "root" ? Promise.resolve(null) : api.detail(selection.kind, selection.id, selection.kind === "shelf" ? ["location"] : void 0), selectionKey, selection.kind !== "root");
77
+ const selectedShelf = selection.kind === "shelf" ? selected.data : void 0;
78
+ const selectedLocation = selection.kind === "location" ? selected.data : selectedShelf === null || selectedShelf === void 0 ? void 0 : selectedShelf.location;
79
+ const resource = selection.kind === "root" ? "location" : selection.kind === "location" ? "shelf" : "space";
80
+ const list = useInventoryList(resource, _objectSpread2({
81
+ search: keyword || void 0,
82
+ status
83
+ }, selection.kind === "location" ? { location_id: selection.id } : selection.kind === "shelf" ? { shelf_id: selection.id } : {}), selection.kind === "root" || !!selected.data);
84
+ useEffect(() => {
85
+ if (selection.kind !== "root" && selected.data === null) {
86
+ report(new Error(t("missing")));
87
+ setSelection({ kind: "root" });
88
+ }
89
+ }, [
90
+ selected.data,
91
+ selectionKey,
92
+ report,
93
+ t
94
+ ]);
95
+ useEffect(() => {
96
+ if (selectedShelf === null || selectedShelf === void 0 ? void 0 : selectedShelf.location_id) setExpanded((previous) => new Set([...previous, selectedShelf.location_id]));
97
+ }, [selectedShelf === null || selectedShelf === void 0 ? void 0 : selectedShelf.location_id]);
98
+ const refresh = () => {
99
+ list.reload();
100
+ selected.reload();
101
+ setNavigationRevision((value) => value + 1);
102
+ };
103
+ const open = (mode, kind = resource, id) => {
104
+ setTarget({
105
+ resource: kind,
106
+ mode,
107
+ id,
108
+ location: selectedLocation || void 0,
109
+ shelf: selectedShelf || void 0
110
+ });
111
+ };
112
+ const remove = (kind, record) => void mutation.run(_asyncToGenerator(function* () {
113
+ if (!(yield confirm("deleteTitle", /* @__PURE__ */ React.createElement(React.Fragment, null, name(record), /* @__PURE__ */ React.createElement("p", null, t("deleteHint")))))) return;
114
+ try {
115
+ yield api.remove(kind, record.id);
116
+ success("deleted");
117
+ if (selection.kind === kind && selection.id === record.id) setSelection({ kind: "root" });
118
+ } finally {
119
+ refresh();
120
+ }
121
+ }));
122
+ const columns = useMemo(() => [
123
+ {
124
+ title: t("name"),
125
+ key: "name",
126
+ dataIndex: "name",
127
+ width: 250,
128
+ render: (_, record) => /* @__PURE__ */ React.createElement(Button, {
129
+ type: "link",
130
+ onClick: () => {
131
+ if (resource === "space") open("view", resource, record.id);
132
+ else setSelection({
133
+ kind: resource,
134
+ id: record.id
135
+ });
136
+ }
137
+ }, name(record), resource !== "space" && /* @__PURE__ */ React.createElement(RightOutlined, null))
138
+ },
139
+ {
140
+ title: t("status"),
141
+ key: "status",
142
+ dataIndex: "status",
143
+ render: (value) => /* @__PURE__ */ React.createElement(StatusTag, { status: value })
144
+ },
145
+ {
146
+ title: t("sort"),
147
+ key: "sort",
148
+ dataIndex: "sort"
149
+ },
150
+ ...resource === "space" ? [{
151
+ title: t("totalQuantity"),
152
+ key: "stock_quantity",
153
+ dataIndex: "stock_quantity",
154
+ render: inventoryQuantity
155
+ }] : [],
156
+ {
157
+ title: t("updated"),
158
+ key: "updated_at",
159
+ dataIndex: "updated_at",
160
+ render: (value) => value || "—"
161
+ },
162
+ {
163
+ title: t("actions"),
164
+ key: "actions",
165
+ dataIndex: "actions",
166
+ width: 210,
167
+ fixed: "right",
168
+ render: (_, record) => /* @__PURE__ */ React.createElement(Space, { size: 0 }, /* @__PURE__ */ React.createElement(Button, {
169
+ type: "link",
170
+ disabled: mutation.busy,
171
+ onClick: () => open("view", resource, record.id)
172
+ }, t("view")), /* @__PURE__ */ React.createElement(Button, {
173
+ type: "link",
174
+ disabled: mutation.busy,
175
+ onClick: () => open("edit", resource, record.id)
176
+ }, t("edit")), /* @__PURE__ */ React.createElement(Button, {
177
+ type: "link",
178
+ danger: true,
179
+ disabled: mutation.busy,
180
+ onClick: () => remove(resource, record)
181
+ }, t("remove")))
182
+ }
183
+ ], [
184
+ t,
185
+ name,
186
+ resource,
187
+ mutation.busy,
188
+ selectedLocation,
189
+ selectedShelf,
190
+ selectionKey,
191
+ api,
192
+ confirm
193
+ ]);
194
+ const navigationLocations = selectedLocation && !locations.rows.some((record) => record.id === selectedLocation.id) ? [selectedLocation, ...locations.rows] : locations.rows;
195
+ const breadcrumbs = [{ title: /* @__PURE__ */ React.createElement("button", {
196
+ className: "inventory-text-button",
197
+ onClick: () => setSelection({ kind: "root" })
198
+ }, t("allLocations")) }];
199
+ if (selectedLocation) breadcrumbs.push({ title: /* @__PURE__ */ React.createElement("button", {
200
+ className: "inventory-text-button",
201
+ onClick: () => setSelection({
202
+ kind: "location",
203
+ id: selectedLocation.id
204
+ })
205
+ }, name(selectedLocation)) });
206
+ if (selectedShelf) breadcrumbs.push({ title: /* @__PURE__ */ React.createElement("span", null, name(selectedShelf)) });
207
+ return /* @__PURE__ */ React.createElement("div", {
208
+ className: `inventory-page ${className || ""}`,
209
+ style
210
+ }, /* @__PURE__ */ React.createElement(InventoryHeader, {
211
+ title: t("locations"),
212
+ description: t("hierarchyHint")
213
+ }, /* @__PURE__ */ React.createElement(Button, {
214
+ icon: /* @__PURE__ */ React.createElement(ReloadOutlined, null),
215
+ disabled: mutation.busy,
216
+ onClick: refresh
217
+ }, t("refresh"))), /* @__PURE__ */ React.createElement("div", { className: "inventory-location-layout" }, /* @__PURE__ */ React.createElement("nav", {
218
+ className: "inventory-navigation",
219
+ "aria-label": t("locations")
220
+ }, /* @__PURE__ */ React.createElement("button", {
221
+ type: "button",
222
+ className: `inventory-nav-row inventory-nav-root ${selection.kind === "root" ? "is-selected" : ""}`,
223
+ onClick: () => setSelection({ kind: "root" })
224
+ }, t("allLocations")), /* @__PURE__ */ React.createElement(RequestError, {
225
+ error: locations.error,
226
+ retry: () => void locations.reload()
227
+ }), navigationLocations.map((record) => /* @__PURE__ */ React.createElement(NavigationLocation, {
228
+ key: record.id,
229
+ record,
230
+ selection,
231
+ selectedShelf,
232
+ expanded: expanded.has(record.id),
233
+ revision: navigationRevision,
234
+ onSelect: setSelection,
235
+ onToggle: () => setExpanded((previous) => {
236
+ const next = new Set(previous);
237
+ if (next.has(record.id)) next.delete(record.id);
238
+ else next.add(record.id);
239
+ return next;
240
+ })
241
+ })), locations.loading && !locations.hasMore && /* @__PURE__ */ React.createElement(InventoryNavLoading, null), !locations.loading && !locations.error && !locations.rows.length && /* @__PURE__ */ React.createElement("span", { className: "inventory-nav-empty" }, t("empty")), locations.hasMore && /* @__PURE__ */ React.createElement(Button, {
242
+ type: "text",
243
+ block: true,
244
+ loading: locations.loading,
245
+ onClick: () => void locations.loadMore()
246
+ }, t("loadMore"))), /* @__PURE__ */ React.createElement("main", { className: "inventory-location-main" }, /* @__PURE__ */ React.createElement(Breadcrumb, { items: breadcrumbs }), /* @__PURE__ */ React.createElement(RequestError, {
247
+ error: selected.error,
248
+ retry: selected.reload
249
+ }), selected.data && /* @__PURE__ */ React.createElement("div", { className: "inventory-section-heading" }, /* @__PURE__ */ React.createElement(Space, null, /* @__PURE__ */ React.createElement("h3", null, name(selected.data)), /* @__PURE__ */ React.createElement(StatusTag, { status: selected.data.status })), /* @__PURE__ */ React.createElement(Space, null, /* @__PURE__ */ React.createElement(Tooltip, { title: t("edit") }, /* @__PURE__ */ React.createElement(Button, {
250
+ disabled: mutation.busy,
251
+ onClick: () => selection.kind !== "root" && open("edit", selection.kind, selection.id)
252
+ }, t("edit"))), /* @__PURE__ */ React.createElement(Button, {
253
+ danger: true,
254
+ disabled: mutation.busy,
255
+ onClick: () => selection.kind !== "root" && remove(selection.kind, selected.data)
256
+ }, t("remove")))), /* @__PURE__ */ React.createElement("div", { className: "inventory-toolbar" }, /* @__PURE__ */ React.createElement(SearchInput, {
257
+ value: search,
258
+ onChange: (value) => setFilter({
259
+ key: selectionKey,
260
+ search: value,
261
+ status
262
+ })
263
+ }), /* @__PURE__ */ React.createElement(StatusSelect, {
264
+ value: status,
265
+ onChange: (value) => setFilter({
266
+ key: selectionKey,
267
+ search,
268
+ status: value
269
+ })
270
+ }), /* @__PURE__ */ React.createElement(Button, {
271
+ type: "primary",
272
+ className: "inventory-toolbar-primary",
273
+ icon: /* @__PURE__ */ React.createElement(PlusOutlined, null),
274
+ disabled: mutation.busy || selected.loading || !!selected.error || selection.kind !== "root" && !selected.data,
275
+ onClick: () => open("create")
276
+ }, t("add"), " ", t(resource))), /* @__PURE__ */ React.createElement(RequestError, {
277
+ error: list.error,
278
+ retry: list.reload
279
+ }), /* @__PURE__ */ React.createElement(InventoryTable, _objectSpread2(_objectSpread2({}, list), {}, {
280
+ loading: list.loading || selected.loading || mutation.busy,
281
+ columns,
282
+ tableKey: `locations-${resource}`
283
+ })))), target && /* @__PURE__ */ React.createElement(RecordDialog, {
284
+ target,
285
+ onClose: () => setTarget(void 0),
286
+ onSaved: () => {
287
+ setTarget(void 0);
288
+ refresh();
289
+ }
290
+ }));
291
+ }
292
+ function InventoryLocationManagement(props) {
293
+ return /* @__PURE__ */ React.createElement(InventoryProvider, { id: props.__id }, /* @__PURE__ */ React.createElement(LocationPage, props));
294
+ }
295
+ //#endregion
296
+ export { InventoryLocationManagement as default };
@@ -0,0 +1,7 @@
1
+ import { InventoryPageProps } from "./types.js";
2
+ import React from "react";
3
+
4
+ //#region src/plus/inventory/InventoryUnitManagement.d.ts
5
+ declare function InventoryUnitManagement(props: InventoryPageProps): React.JSX.Element;
6
+ //#endregion
7
+ export { InventoryUnitManagement };