@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,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
+ /// <reference types="react" />
2
+ import { InventoryPageProps } from "./types.js";
3
+
4
+ //#region src/plus/inventory/InventoryLocationManagement.d.ts
5
+ declare function InventoryLocationManagement(props: InventoryPageProps): 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
+ /// <reference types="react" />
2
+ import { InventoryPageProps } from "./types.js";
3
+
4
+ //#region src/plus/inventory/InventoryUnitManagement.d.ts
5
+ declare function InventoryUnitManagement(props: InventoryPageProps): JSX.Element;
6
+ //#endregion
7
+ export { InventoryUnitManagement };
@@ -0,0 +1,144 @@
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 { InventoryProvider, useInventory } from "./context.js";
4
+ import { useInventoryList, useInventoryMutation } from "./hooks.js";
5
+ import { InventoryHeader, InventoryTable, RequestError, SearchInput, StatusSelect, StatusTag } from "./components.js";
6
+ import RecordDialog from "./RecordDialog.js";
7
+ import React, { useMemo, useState } from "react";
8
+ import { Button, Space } from "antd";
9
+ import { useDebounce } from "ahooks";
10
+ import { PlusOutlined, ReloadOutlined } from "@ant-design/icons";
11
+ //#region src/plus/inventory/InventoryUnitManagement.tsx
12
+ function UnitPage({ className, style }) {
13
+ const { api, t, name, confirm, success } = useInventory();
14
+ const [search, setSearch] = useState("");
15
+ const keyword = useDebounce(search, { wait: 300 });
16
+ const [status, setStatus] = useState();
17
+ const [target, setTarget] = useState();
18
+ const mutation = useInventoryMutation();
19
+ const list = useInventoryList("item-unit", {
20
+ search: keyword || void 0,
21
+ status
22
+ });
23
+ const remove = (record) => void mutation.run(_asyncToGenerator(function* () {
24
+ if (!(yield confirm("deleteTitle", /* @__PURE__ */ React.createElement(React.Fragment, null, name(record), /* @__PURE__ */ React.createElement("p", null, t("deleteHint")))))) return;
25
+ try {
26
+ yield api.remove("item-unit", record.id);
27
+ success("deleted");
28
+ } finally {
29
+ list.reload();
30
+ }
31
+ }));
32
+ const columns = useMemo(() => [
33
+ {
34
+ title: t("name"),
35
+ key: "name",
36
+ dataIndex: "name",
37
+ width: 260,
38
+ render: (_, record) => /* @__PURE__ */ React.createElement(Button, {
39
+ type: "link",
40
+ onClick: () => setTarget({
41
+ resource: "item-unit",
42
+ id: record.id,
43
+ mode: "view"
44
+ })
45
+ }, name(record))
46
+ },
47
+ {
48
+ title: t("status"),
49
+ key: "status",
50
+ dataIndex: "status",
51
+ render: (value) => /* @__PURE__ */ React.createElement(StatusTag, { status: value })
52
+ },
53
+ {
54
+ title: t("sort"),
55
+ key: "sort",
56
+ dataIndex: "sort"
57
+ },
58
+ {
59
+ title: t("updated"),
60
+ key: "updated_at",
61
+ dataIndex: "updated_at",
62
+ render: (value) => value || "—"
63
+ },
64
+ {
65
+ title: t("actions"),
66
+ key: "actions",
67
+ dataIndex: "actions",
68
+ fixed: "right",
69
+ width: 220,
70
+ render: (_, record) => /* @__PURE__ */ React.createElement(Space, { size: 0 }, /* @__PURE__ */ React.createElement(Button, {
71
+ type: "link",
72
+ disabled: mutation.busy,
73
+ onClick: () => setTarget({
74
+ resource: "item-unit",
75
+ id: record.id,
76
+ mode: "view"
77
+ })
78
+ }, t("view")), /* @__PURE__ */ React.createElement(Button, {
79
+ type: "link",
80
+ disabled: mutation.busy,
81
+ onClick: () => setTarget({
82
+ resource: "item-unit",
83
+ id: record.id,
84
+ mode: "edit"
85
+ })
86
+ }, t("edit")), /* @__PURE__ */ React.createElement(Button, {
87
+ type: "link",
88
+ danger: true,
89
+ disabled: mutation.busy,
90
+ onClick: () => remove(record)
91
+ }, t("remove")))
92
+ }
93
+ ], [
94
+ t,
95
+ name,
96
+ mutation.busy,
97
+ api,
98
+ confirm
99
+ ]);
100
+ return /* @__PURE__ */ React.createElement("div", {
101
+ className: `inventory-page ${className || ""}`,
102
+ style
103
+ }, /* @__PURE__ */ React.createElement(InventoryHeader, {
104
+ title: t("units"),
105
+ description: t("unitHint")
106
+ }, /* @__PURE__ */ React.createElement(Button, {
107
+ type: "primary",
108
+ icon: /* @__PURE__ */ React.createElement(PlusOutlined, null),
109
+ disabled: mutation.busy,
110
+ onClick: () => setTarget({
111
+ resource: "item-unit",
112
+ mode: "create"
113
+ })
114
+ }, t("add"), " ", t("unit"))), /* @__PURE__ */ React.createElement("div", { className: "inventory-toolbar" }, /* @__PURE__ */ React.createElement(SearchInput, {
115
+ value: search,
116
+ onChange: setSearch
117
+ }), /* @__PURE__ */ React.createElement(StatusSelect, {
118
+ value: status,
119
+ onChange: setStatus
120
+ }), /* @__PURE__ */ React.createElement(Button, {
121
+ icon: /* @__PURE__ */ React.createElement(ReloadOutlined, null),
122
+ onClick: list.reload,
123
+ disabled: mutation.busy
124
+ }, t("refresh"))), /* @__PURE__ */ React.createElement(RequestError, {
125
+ error: list.error,
126
+ retry: list.reload
127
+ }), /* @__PURE__ */ React.createElement(InventoryTable, _objectSpread2(_objectSpread2({}, list), {}, {
128
+ loading: list.loading || mutation.busy,
129
+ columns,
130
+ tableKey: "units"
131
+ })), target && /* @__PURE__ */ React.createElement(RecordDialog, {
132
+ target,
133
+ onClose: () => setTarget(void 0),
134
+ onSaved: () => {
135
+ setTarget(void 0);
136
+ list.reload();
137
+ }
138
+ }));
139
+ }
140
+ function InventoryUnitManagement(props) {
141
+ return /* @__PURE__ */ React.createElement(InventoryProvider, { id: props.__id }, /* @__PURE__ */ React.createElement(UnitPage, props));
142
+ }
143
+ //#endregion
144
+ export { InventoryUnitManagement as default };