@pisell/private-materials 6.6.59 → 6.6.61
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.
- package/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/index.js +1 -1
- package/build/lowcode/meta.js +2 -2
- package/build/lowcode/preview.js +8 -8
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +11 -11
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +11 -11
- package/es/components/booking/components/footer/utils.js +79 -75
- package/es/components/eftposPay/hooks.d.ts +1 -1
- package/es/components/eftposPay/store/index.d.ts +2 -2
- package/es/components/index.d.ts +2 -1
- package/es/components/index.js +2 -1
- package/es/components/pisellCashCounting/PisellCashCounting.d.ts +5 -0
- package/es/components/pisellCashCounting/PisellCashCounting.js +121 -0
- package/es/components/pisellCashCounting/PisellCashCounting.less +263 -0
- package/es/components/pisellCashCounting/components/CashCountingModal/index.d.ts +20 -0
- package/es/components/pisellCashCounting/components/CashCountingModal/index.js +250 -0
- package/es/components/pisellCashCounting/components/CashCountingModal/index.less +279 -0
- package/es/components/pisellCashCounting/hooks.d.ts +21 -0
- package/es/components/pisellCashCounting/hooks.js +193 -0
- package/es/components/pisellCashCounting/index.d.ts +2 -0
- package/es/components/pisellCashCounting/index.js +1 -0
- package/es/components/pisellCashCounting/locales.d.ts +118 -0
- package/es/components/pisellCashCounting/locales.js +117 -0
- package/es/components/pisellCashCounting/types.d.ts +85 -0
- package/es/components/pisellCashCounting/types.js +1 -0
- package/es/components/pisellCashCounting/utils.d.ts +10 -0
- package/es/components/pisellCashCounting/utils.js +40 -0
- package/es/hooks/useResponsive.d.ts +8 -0
- package/es/hooks/useResponsive.js +43 -0
- package/es/hooks/useThemeTokens.d.ts +7 -0
- package/es/hooks/useThemeTokens.js +20 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -1
- package/es/pro/NumericStepper/index.d.ts +75 -0
- package/es/pro/NumericStepper/index.js +301 -0
- package/es/pro/NumericStepper/index.less +364 -0
- package/es/pro/keyboards/index.d.ts +2 -0
- package/es/pro/keyboards/index.js +1 -0
- package/es/pro/keyboards/locales.d.ts +38 -0
- package/es/pro/keyboards/locales.js +57 -0
- package/es/pro/keyboards/numberKeyboard/index.d.ts +16 -0
- package/es/pro/keyboards/numberKeyboard/index.js +523 -0
- package/es/pro/keyboards/numberKeyboard/index.less +59 -0
- package/es/pro/keyboards/numberKeyboard/types.d.ts +63 -0
- package/es/pro/keyboards/numberKeyboard/types.js +1 -0
- package/es/pro/pisellPriceKeyboardModal/PisellPriceKeyboardModal.js +3 -1
- package/es/pro/pisellPriceKeyboardModal/types.d.ts +2 -0
- package/lib/components/booking/components/footer/utils.js +6 -3
- package/lib/components/eftposPay/hooks.d.ts +1 -1
- package/lib/components/eftposPay/store/index.d.ts +2 -2
- package/lib/components/index.d.ts +2 -1
- package/lib/components/index.js +3 -0
- package/lib/components/pisellCashCounting/PisellCashCounting.d.ts +5 -0
- package/lib/components/pisellCashCounting/PisellCashCounting.js +168 -0
- package/lib/components/pisellCashCounting/PisellCashCounting.less +263 -0
- package/lib/components/pisellCashCounting/components/CashCountingModal/index.d.ts +20 -0
- package/lib/components/pisellCashCounting/components/CashCountingModal/index.js +171 -0
- package/lib/components/pisellCashCounting/components/CashCountingModal/index.less +279 -0
- package/lib/components/pisellCashCounting/hooks.d.ts +21 -0
- package/lib/components/pisellCashCounting/hooks.js +189 -0
- package/lib/components/pisellCashCounting/index.d.ts +2 -0
- package/lib/components/pisellCashCounting/index.js +35 -0
- package/lib/components/pisellCashCounting/locales.d.ts +118 -0
- package/lib/components/pisellCashCounting/locales.js +141 -0
- package/lib/components/pisellCashCounting/types.d.ts +85 -0
- package/lib/components/pisellCashCounting/types.js +17 -0
- package/lib/components/pisellCashCounting/utils.d.ts +10 -0
- package/lib/components/pisellCashCounting/utils.js +59 -0
- package/lib/hooks/useResponsive.d.ts +8 -0
- package/lib/hooks/useResponsive.js +48 -0
- package/lib/hooks/useThemeTokens.d.ts +7 -0
- package/lib/hooks/useThemeTokens.js +40 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -0
- package/lib/pro/NumericStepper/index.d.ts +75 -0
- package/lib/pro/NumericStepper/index.js +338 -0
- package/lib/pro/NumericStepper/index.less +364 -0
- package/lib/pro/keyboards/index.d.ts +2 -0
- package/lib/pro/keyboards/index.js +39 -0
- package/lib/pro/keyboards/locales.d.ts +38 -0
- package/lib/pro/keyboards/locales.js +61 -0
- package/lib/pro/keyboards/numberKeyboard/index.d.ts +16 -0
- package/lib/pro/keyboards/numberKeyboard/index.js +400 -0
- package/lib/pro/keyboards/numberKeyboard/index.less +59 -0
- package/lib/pro/keyboards/numberKeyboard/types.d.ts +63 -0
- package/lib/pro/keyboards/numberKeyboard/types.js +17 -0
- package/lib/pro/pisellPriceKeyboardModal/PisellPriceKeyboardModal.js +3 -1
- package/lib/pro/pisellPriceKeyboardModal/types.d.ts +2 -0
- package/lowcode/pisell-cash-counting/meta.ts +167 -0
- package/lowcode/pisell-cash-counting/snippets.ts +13 -0
- package/package.json +4 -4
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/components/pisellCashCounting/components/CashCountingModal/index.tsx
|
|
30
|
+
var CashCountingModal_exports = {};
|
|
31
|
+
__export(CashCountingModal_exports, {
|
|
32
|
+
default: () => CashCountingModal_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(CashCountingModal_exports);
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
var import_materials = require("@pisell/materials");
|
|
37
|
+
var import_NumericStepper = __toESM(require("../../../../pro/NumericStepper"));
|
|
38
|
+
var import_utils = require("@pisell/utils");
|
|
39
|
+
var import_icons = require("@ant-design/icons");
|
|
40
|
+
var import_utils2 = require("../../utils");
|
|
41
|
+
var import_useEngineContext = __toESM(require("../../../../hooks/useEngineContext"));
|
|
42
|
+
var import_useResponsive = require("../../../../hooks/useResponsive");
|
|
43
|
+
var import_index = require("./index.less");
|
|
44
|
+
var PREFIX = "pisell-private-cash-counting-modal";
|
|
45
|
+
var formatAmount = (value, symbol, precision) => {
|
|
46
|
+
const formatter = new Intl.NumberFormat(void 0, {
|
|
47
|
+
minimumFractionDigits: precision,
|
|
48
|
+
maximumFractionDigits: precision
|
|
49
|
+
});
|
|
50
|
+
return `${symbol}${formatter.format(value)}`;
|
|
51
|
+
};
|
|
52
|
+
var CashCountingModal = (0, import_react.forwardRef)(
|
|
53
|
+
(props, ref) => {
|
|
54
|
+
var _a;
|
|
55
|
+
const {
|
|
56
|
+
currencyCode,
|
|
57
|
+
currencyDenominations,
|
|
58
|
+
decimalPlaces,
|
|
59
|
+
symbol,
|
|
60
|
+
modalWidth,
|
|
61
|
+
onCancel,
|
|
62
|
+
onConfirm
|
|
63
|
+
} = props;
|
|
64
|
+
const context = (0, import_useEngineContext.default)();
|
|
65
|
+
const { isTerminal } = ((_a = context.appHelper) == null ? void 0 : _a.utils) || {};
|
|
66
|
+
const [open, setOpen] = (0, import_react.useState)(false);
|
|
67
|
+
const [draftQuantities, setDraftQuantities] = (0, import_react.useState)({});
|
|
68
|
+
const isIpad = (0, import_useResponsive.useResponsive)(1200);
|
|
69
|
+
const isMobile = (0, import_useResponsive.useResponsive)(450);
|
|
70
|
+
(0, import_react.useImperativeHandle)(ref, () => ({
|
|
71
|
+
open: ({ initialQuantities }) => {
|
|
72
|
+
setDraftQuantities(initialQuantities);
|
|
73
|
+
setOpen(true);
|
|
74
|
+
},
|
|
75
|
+
close: () => setOpen(false)
|
|
76
|
+
}));
|
|
77
|
+
const groupedDenominations = (0, import_react.useMemo)(() => {
|
|
78
|
+
return currencyDenominations.reduce(
|
|
79
|
+
(acc, item) => {
|
|
80
|
+
acc[item.denomination_type].push(item);
|
|
81
|
+
return acc;
|
|
82
|
+
},
|
|
83
|
+
{ bill: [], coin: [] }
|
|
84
|
+
);
|
|
85
|
+
}, [currencyDenominations]);
|
|
86
|
+
const calculatedDetails = (0, import_react.useMemo)(() => {
|
|
87
|
+
return currencyDenominations.map((d) => {
|
|
88
|
+
const qty = draftQuantities[(0, import_utils2.getDenominationId)(d)] ?? 0;
|
|
89
|
+
return { denomination: d, quantity: qty, amount: (0, import_utils2.normalizeAmount)(d.denomination_value * qty, decimalPlaces) };
|
|
90
|
+
});
|
|
91
|
+
}, [currencyDenominations, draftQuantities, decimalPlaces, import_utils2.getDenominationId, import_utils2.normalizeAmount]);
|
|
92
|
+
const billSubtotal = (0, import_react.useMemo)(
|
|
93
|
+
() => calculatedDetails.filter((i) => i.denomination.denomination_type === "bill").reduce((s, i) => s + i.amount, 0),
|
|
94
|
+
[calculatedDetails]
|
|
95
|
+
);
|
|
96
|
+
const coinSubtotal = (0, import_react.useMemo)(
|
|
97
|
+
() => calculatedDetails.filter((i) => i.denomination.denomination_type === "coin").reduce((s, i) => s + i.amount, 0),
|
|
98
|
+
[calculatedDetails]
|
|
99
|
+
);
|
|
100
|
+
const totalAmount = (0, import_react.useMemo)(() => billSubtotal + coinSubtotal, [billSubtotal, coinSubtotal]);
|
|
101
|
+
const handleClose = () => {
|
|
102
|
+
setOpen(false);
|
|
103
|
+
if (typeof onCancel === "function") {
|
|
104
|
+
onCancel();
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
const handleClear = () => {
|
|
108
|
+
const reset = {};
|
|
109
|
+
currencyDenominations.forEach((d) => reset[(0, import_utils2.getDenominationId)(d)] = 0);
|
|
110
|
+
setDraftQuantities(reset);
|
|
111
|
+
};
|
|
112
|
+
const handleConfirm = () => {
|
|
113
|
+
const payload = {
|
|
114
|
+
amount: totalAmount,
|
|
115
|
+
currencyCode,
|
|
116
|
+
decimalPlaces,
|
|
117
|
+
billSubtotal,
|
|
118
|
+
coinSubtotal,
|
|
119
|
+
details: calculatedDetails,
|
|
120
|
+
quantities: draftQuantities
|
|
121
|
+
};
|
|
122
|
+
if (typeof onConfirm === "function") {
|
|
123
|
+
onConfirm(payload);
|
|
124
|
+
}
|
|
125
|
+
setOpen(false);
|
|
126
|
+
};
|
|
127
|
+
const renderSection = (type, title, subtotal) => {
|
|
128
|
+
const items = groupedDenominations[type];
|
|
129
|
+
if (!items.length) return null;
|
|
130
|
+
return /* @__PURE__ */ import_react.default.createElement("div", { className: `${PREFIX}__section` }, /* @__PURE__ */ import_react.default.createElement("div", { className: `${PREFIX}__section-header` }, /* @__PURE__ */ import_react.default.createElement("div", { className: `${PREFIX}__section-title` }, /* @__PURE__ */ import_react.default.createElement("span", { className: `${PREFIX}__dot ${PREFIX}__dot--${type}` }), /* @__PURE__ */ import_react.default.createElement("span", null, title)), /* @__PURE__ */ import_react.default.createElement("div", { className: `${PREFIX}__section-subtotal` }, /* @__PURE__ */ import_react.default.createElement("span", null, import_utils.locales.getText("pisell-cash-counting.subtotal")), /* @__PURE__ */ import_react.default.createElement("strong", null, formatAmount(subtotal, symbol, decimalPlaces)))), /* @__PURE__ */ import_react.default.createElement("div", { className: `${PREFIX}__denomination-list` }, items.map((item) => {
|
|
131
|
+
const id = (0, import_utils2.getDenominationId)(item);
|
|
132
|
+
const qty = draftQuantities[id] ?? 0;
|
|
133
|
+
const amt = (0, import_utils2.normalizeAmount)(item.denomination_value * qty, decimalPlaces);
|
|
134
|
+
return /* @__PURE__ */ import_react.default.createElement("div", { className: `${PREFIX}__denomination-row`, key: id }, /* @__PURE__ */ import_react.default.createElement("div", { className: `${PREFIX}__denomination-left` }, /* @__PURE__ */ import_react.default.createElement("div", { className: `${PREFIX}__denomination-label ${PREFIX}__denomination-label--${type}` }, item.denomination_label), /* @__PURE__ */ import_react.default.createElement("div", { className: `${PREFIX}__stepper-wrap` }, /* @__PURE__ */ import_react.default.createElement(
|
|
135
|
+
import_NumericStepper.default,
|
|
136
|
+
{
|
|
137
|
+
className: `${PREFIX}__stepper`,
|
|
138
|
+
min: 0,
|
|
139
|
+
max: 9999,
|
|
140
|
+
value: qty,
|
|
141
|
+
plusOnlyAtZero: false,
|
|
142
|
+
shape: "square",
|
|
143
|
+
onChange: (val) => setDraftQuantities((prev) => ({ ...prev, [id]: val }))
|
|
144
|
+
}
|
|
145
|
+
))), /* @__PURE__ */ import_react.default.createElement("div", { className: `${PREFIX}__row-amount` }, formatAmount(amt, symbol, decimalPlaces)));
|
|
146
|
+
})));
|
|
147
|
+
};
|
|
148
|
+
const renderHeader = (0, import_react.useCallback)(() => {
|
|
149
|
+
return /* @__PURE__ */ import_react.default.createElement("div", { className: `${PREFIX}__modal-header` }, /* @__PURE__ */ import_react.default.createElement(import_materials.Iconfont, { type: "pisell2-cash", className: `${PREFIX}__modal-header-icon` }), /* @__PURE__ */ import_react.default.createElement("div", { className: `${PREFIX}__modal-header-title` }, import_utils.locales.getText("pisell-cash-counting.countCash")), /* @__PURE__ */ import_react.default.createElement(import_materials.Tag, { color: "blue", style: { border: "none" } }, currencyCode));
|
|
150
|
+
}, [currencyCode]);
|
|
151
|
+
const renderFooter = (0, import_react.useCallback)(() => {
|
|
152
|
+
return /* @__PURE__ */ import_react.default.createElement("div", { className: `${PREFIX}__footer` }, /* @__PURE__ */ import_react.default.createElement("div", { className: `${PREFIX}__summary` }, /* @__PURE__ */ import_react.default.createElement("div", { className: `${PREFIX}__summary-row` }, /* @__PURE__ */ import_react.default.createElement("span", null, import_utils.locales.getText("pisell-cash-counting.billsSubtotal")), /* @__PURE__ */ import_react.default.createElement("strong", null, formatAmount(billSubtotal, symbol, decimalPlaces))), /* @__PURE__ */ import_react.default.createElement("div", { className: `${PREFIX}__summary-row` }, /* @__PURE__ */ import_react.default.createElement("span", null, import_utils.locales.getText("pisell-cash-counting.coinsSubtotal")), /* @__PURE__ */ import_react.default.createElement("strong", null, formatAmount(coinSubtotal, symbol, decimalPlaces))), /* @__PURE__ */ import_react.default.createElement("div", { className: `${PREFIX}__total-row` }, /* @__PURE__ */ import_react.default.createElement("span", null, import_utils.locales.getText("pisell-cash-counting.total")), /* @__PURE__ */ import_react.default.createElement("strong", null, formatAmount(totalAmount, symbol, decimalPlaces)))), /* @__PURE__ */ import_react.default.createElement("div", { className: `${PREFIX}__actions` }, /* @__PURE__ */ import_react.default.createElement(import_materials.Button, { type: "text", size: "large", onClick: handleClear }, import_utils.locales.getText("pisell-cash-counting.clearAll")), /* @__PURE__ */ import_react.default.createElement(import_materials.Button, { size: "large", onClick: handleClose }, import_utils.locales.getText("pisell-cash-counting.cancel")), /* @__PURE__ */ import_react.default.createElement(import_materials.Button, { type: "primary", size: "large", disabled: !currencyDenominations.length, onClick: handleConfirm }, import_utils.locales.getText("pisell-cash-counting.confirm"))));
|
|
153
|
+
}, [coinSubtotal, billSubtotal, totalAmount, currencyDenominations, handleClear, handleClose, handleConfirm]);
|
|
154
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
155
|
+
import_materials.PisellModal,
|
|
156
|
+
{
|
|
157
|
+
destroyOnClose: true,
|
|
158
|
+
maskClosable: false,
|
|
159
|
+
footer: renderFooter(),
|
|
160
|
+
open,
|
|
161
|
+
title: renderHeader(),
|
|
162
|
+
className: `${PREFIX}__modal-wrap`,
|
|
163
|
+
bodyStyle: { padding: 0 },
|
|
164
|
+
width: modalWidth ? modalWidth : (isTerminal == null ? void 0 : isTerminal()) ? "80%" : "880px",
|
|
165
|
+
onCancel: handleClose
|
|
166
|
+
},
|
|
167
|
+
/* @__PURE__ */ import_react.default.createElement("div", { className: `${PREFIX}__modal` }, /* @__PURE__ */ import_react.default.createElement("div", { className: `${PREFIX}__modal-intro` }, /* @__PURE__ */ import_react.default.createElement(import_icons.ExclamationCircleOutlined, { style: { fontSize: 18, color: "#F2A63A" } }), import_utils.locales.getText("pisell-cash-counting.subtitle")), /* @__PURE__ */ import_react.default.createElement("div", { className: `${PREFIX}__scroll ${isIpad || isMobile ? `${PREFIX}__scroll-column` : ""} ${isMobile ? `${PREFIX}__scroll-mobile` : ""}` }, currencyDenominations.length === 0 ? /* @__PURE__ */ import_react.default.createElement("div", { className: `${PREFIX}__empty` }, import_utils.locales.getText("pisell-cash-counting.empty")) : /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, renderSection("bill", import_utils.locales.getText("pisell-cash-counting.bills"), billSubtotal), renderSection("coin", import_utils.locales.getText("pisell-cash-counting.coins"), coinSubtotal))))
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
);
|
|
171
|
+
var CashCountingModal_default = CashCountingModal;
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
.pisell-private-cash-counting-modal {
|
|
2
|
+
&__modal-wrap {
|
|
3
|
+
.pisell-lowcode-modal-footer {
|
|
4
|
+
background: rgb(249, 250, 251);
|
|
5
|
+
padding: 12px 16px !important;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
&__modal {
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
&__modal-header {
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
gap: 10px;
|
|
18
|
+
|
|
19
|
+
&__modal-header-icon {
|
|
20
|
+
font-size: 20px;
|
|
21
|
+
color: #667085;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&__modal-intro {
|
|
26
|
+
padding: 10px 16px;
|
|
27
|
+
background: #FFF2C2;
|
|
28
|
+
color: #995522;
|
|
29
|
+
border-radius: 6px;
|
|
30
|
+
display: flex;
|
|
31
|
+
gap: 8px;
|
|
32
|
+
font-weight: 600;
|
|
33
|
+
font-size: 14px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&__subtitle {
|
|
37
|
+
color: #667085;
|
|
38
|
+
font-size: 14px;
|
|
39
|
+
line-height: 20px;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
&__currency {
|
|
43
|
+
display: inline-flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
min-height: 28px;
|
|
46
|
+
margin-top: 12px;
|
|
47
|
+
padding: 4px 10px;
|
|
48
|
+
border-radius: 999px;
|
|
49
|
+
background: #f2f4f7;
|
|
50
|
+
color: #344054;
|
|
51
|
+
font-size: 13px;
|
|
52
|
+
font-weight: 600;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
&__scroll {
|
|
56
|
+
flex: 1;
|
|
57
|
+
overflow-y: auto;
|
|
58
|
+
display: flex;
|
|
59
|
+
flex-direction: row;
|
|
60
|
+
gap: 16px;
|
|
61
|
+
padding: 0;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
&__empty {
|
|
65
|
+
display: flex;
|
|
66
|
+
align-items: center;
|
|
67
|
+
justify-content: center;
|
|
68
|
+
min-height: 220px;
|
|
69
|
+
color: #98a2b3;
|
|
70
|
+
font-size: 14px;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
&__section {
|
|
74
|
+
padding: 16px;
|
|
75
|
+
flex: 1;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
&__section+&__section {
|
|
79
|
+
|
|
80
|
+
border-top: none;
|
|
81
|
+
padding-bottom: 16px;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&__section-header {
|
|
85
|
+
display: flex;
|
|
86
|
+
align-items: center;
|
|
87
|
+
justify-content: space-between;
|
|
88
|
+
gap: 16px;
|
|
89
|
+
margin-bottom: 16px;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
&__section-title {
|
|
93
|
+
display: flex;
|
|
94
|
+
align-items: center;
|
|
95
|
+
gap: 8px;
|
|
96
|
+
color: #667085;
|
|
97
|
+
font-size: 14px;
|
|
98
|
+
font-weight: 700;
|
|
99
|
+
letter-spacing: 0.04em;
|
|
100
|
+
text-transform: uppercase;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
&__dot {
|
|
104
|
+
width: 8px;
|
|
105
|
+
height: 8px;
|
|
106
|
+
border-radius: 50%;
|
|
107
|
+
background: #635bff;
|
|
108
|
+
|
|
109
|
+
&--coin {
|
|
110
|
+
background: #f59e0b;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
&__section-subtotal {
|
|
115
|
+
display: flex;
|
|
116
|
+
align-items: center;
|
|
117
|
+
gap: 10px;
|
|
118
|
+
color: #667085;
|
|
119
|
+
font-size: 14px;
|
|
120
|
+
|
|
121
|
+
strong {
|
|
122
|
+
color: #101828;
|
|
123
|
+
font-size: 15px;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
&__denomination-list {
|
|
128
|
+
display: flex;
|
|
129
|
+
flex-direction: column;
|
|
130
|
+
gap: 16px;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
&__denomination-row {
|
|
134
|
+
// display: grid;
|
|
135
|
+
// grid-template-columns: 94px minmax(220px, 1fr) minmax(94px, 1fr);
|
|
136
|
+
align-items: center;
|
|
137
|
+
gap: 16px;
|
|
138
|
+
display: flex;
|
|
139
|
+
justify-content: space-between;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
&__denomination-label {
|
|
143
|
+
display: inline-flex;
|
|
144
|
+
align-items: center;
|
|
145
|
+
justify-content: center;
|
|
146
|
+
min-width: 94px;
|
|
147
|
+
height: 32px;
|
|
148
|
+
padding: 0 12px;
|
|
149
|
+
border-radius: 6px;
|
|
150
|
+
background: #dbeafe;
|
|
151
|
+
color: #175cd3;
|
|
152
|
+
font-size: 14px;
|
|
153
|
+
font-weight: 700;
|
|
154
|
+
|
|
155
|
+
&--coin {
|
|
156
|
+
background: #fef3c7;
|
|
157
|
+
color: #92400e;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
&__denomination-left {
|
|
162
|
+
display: flex;
|
|
163
|
+
align-items: center;
|
|
164
|
+
gap: 16px;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
&__stepper {
|
|
168
|
+
&.numeric-stepper {
|
|
169
|
+
gap: 8px;
|
|
170
|
+
grid-template-columns: auto auto auto;
|
|
171
|
+
justify-content: flex-start;
|
|
172
|
+
width: auto;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.numeric-stepper-button {
|
|
176
|
+
width: 40px;
|
|
177
|
+
height: 32px;
|
|
178
|
+
border-radius: 6px;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.numeric-stepper-display {
|
|
182
|
+
width: 70px;
|
|
183
|
+
height: 32px;
|
|
184
|
+
max-width: 70px;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
&__row-amount {
|
|
189
|
+
justify-self: end;
|
|
190
|
+
color: #98a2b3;
|
|
191
|
+
font-size: 15px;
|
|
192
|
+
font-weight: 700;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
&__footer {
|
|
196
|
+
width: 100%;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
&__summary {
|
|
200
|
+
padding-bottom: 4px;
|
|
201
|
+
border-bottom: 1px dashed #d0d5dd;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
&__summary-row,
|
|
205
|
+
&__total-row {
|
|
206
|
+
display: flex;
|
|
207
|
+
align-items: center;
|
|
208
|
+
justify-content: space-between;
|
|
209
|
+
gap: 16px;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
&__summary-row {
|
|
213
|
+
color: #667085;
|
|
214
|
+
font-size: 15px;
|
|
215
|
+
|
|
216
|
+
+.pisell-private-cash-counting__summary-row {
|
|
217
|
+
margin-top: 10px;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
strong {
|
|
221
|
+
color: #101828;
|
|
222
|
+
font-size: 16px;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
&__total-row {
|
|
227
|
+
margin-top: 4px;
|
|
228
|
+
color: #101828;
|
|
229
|
+
font-size: 18px;
|
|
230
|
+
font-weight: 700;
|
|
231
|
+
|
|
232
|
+
strong {
|
|
233
|
+
font-size: 34px;
|
|
234
|
+
line-height: 40px;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
&__actions {
|
|
239
|
+
display: grid;
|
|
240
|
+
grid-template-columns: 1fr 1fr 1fr;
|
|
241
|
+
gap: 12px;
|
|
242
|
+
margin-top: 12px;
|
|
243
|
+
|
|
244
|
+
.pisell-lowcode-btn {
|
|
245
|
+
margin: 0;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
&__scroll-column {
|
|
250
|
+
padding: 0 0 10px;
|
|
251
|
+
flex-direction: column;
|
|
252
|
+
gap: 0;
|
|
253
|
+
|
|
254
|
+
.numeric-stepper-button {
|
|
255
|
+
width: 66px!important;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.numeric-stepper-display {
|
|
259
|
+
width: 100px!important;
|
|
260
|
+
max-width: 100px!important;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
&__scroll-mobile {
|
|
265
|
+
.numeric-stepper-button {
|
|
266
|
+
width: 32px!important;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.numeric-stepper-display {
|
|
270
|
+
width: 60px!important;
|
|
271
|
+
max-width: 60px!important;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
&__scroll-column &__section+&__section {
|
|
276
|
+
border-top: 1px solid #f2f4f7;
|
|
277
|
+
padding-bottom: 0;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CashCountingConfirmPayload, PisellCashCountingProps } from './types';
|
|
2
|
+
import type { PisellCashCountingModalRef } from './components/CashCountingModal/index';
|
|
3
|
+
export declare function usePisellCashCounting({ value, defaultValue, currencyCode, currencySymbol, amountPrecision, denominations, disabled, countDisabled, onChange, onCountConfirm, onCountCancel, }: PisellCashCountingProps): {
|
|
4
|
+
modalRef: import("react").RefObject<PisellCashCountingModalRef>;
|
|
5
|
+
triggerRef: import("react").RefObject<HTMLDivElement>;
|
|
6
|
+
keyboardOpen: boolean;
|
|
7
|
+
setKeyboardOpen: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
8
|
+
currencyDenominations: import("./types").CurrencyDenominationConfig[];
|
|
9
|
+
decimalPlaces: number;
|
|
10
|
+
symbol: any;
|
|
11
|
+
currencyCode: any;
|
|
12
|
+
currentValue: string;
|
|
13
|
+
handleAmountChange: (nextValue: string | number) => void;
|
|
14
|
+
handleKeyboardClose: () => void;
|
|
15
|
+
openCountModal: () => void;
|
|
16
|
+
handleCountCancel: () => void;
|
|
17
|
+
handleCountConfirm: (payload: CashCountingConfirmPayload) => void;
|
|
18
|
+
manualCountMismatchOpen: boolean;
|
|
19
|
+
confirmUseCountedTotal: () => void;
|
|
20
|
+
confirmKeepManualAmount: () => void;
|
|
21
|
+
};
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/components/pisellCashCounting/hooks.ts
|
|
30
|
+
var hooks_exports = {};
|
|
31
|
+
__export(hooks_exports, {
|
|
32
|
+
usePisellCashCounting: () => usePisellCashCounting
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(hooks_exports);
|
|
35
|
+
var import_react = require("react");
|
|
36
|
+
var import_antd = require("antd");
|
|
37
|
+
var import_utils = require("@pisell/utils");
|
|
38
|
+
var import_utils2 = require("./utils");
|
|
39
|
+
var import_useEngineContext = __toESM(require("../../hooks/useEngineContext"));
|
|
40
|
+
function usePisellCashCounting({
|
|
41
|
+
value,
|
|
42
|
+
defaultValue = "",
|
|
43
|
+
currencyCode,
|
|
44
|
+
currencySymbol,
|
|
45
|
+
amountPrecision,
|
|
46
|
+
denominations = [],
|
|
47
|
+
disabled = false,
|
|
48
|
+
countDisabled = false,
|
|
49
|
+
onChange,
|
|
50
|
+
onCountConfirm,
|
|
51
|
+
onCountCancel
|
|
52
|
+
}) {
|
|
53
|
+
var _a, _b, _c, _d;
|
|
54
|
+
const context = (0, import_useEngineContext.default)();
|
|
55
|
+
const { store } = ((_a = context.appHelper) == null ? void 0 : _a.utils) || {};
|
|
56
|
+
const modalRef = (0, import_react.useRef)(null);
|
|
57
|
+
const triggerRef = (0, import_react.useRef)(null);
|
|
58
|
+
const [keyboardOpen, setKeyboardOpen] = (0, import_react.useState)(false);
|
|
59
|
+
const [internalValue, setInternalValue] = (0, import_react.useState)(defaultValue);
|
|
60
|
+
const [confirmedQuantities, setConfirmedQuantities] = (0, import_react.useState)({});
|
|
61
|
+
const countedResultRef = (0, import_react.useRef)(null);
|
|
62
|
+
const manualInputValueRef = (0, import_react.useRef)(null);
|
|
63
|
+
const [manualCountMismatchOpen, setManualCountMismatchOpen] = (0, import_react.useState)(false);
|
|
64
|
+
const globalConfig = (0, import_react.useMemo)(() => {
|
|
65
|
+
var _a2, _b2;
|
|
66
|
+
const global = ((_b2 = (_a2 = store == null ? void 0 : store.getState) == null ? void 0 : _a2.call(store)) == null ? void 0 : _b2.global) || {};
|
|
67
|
+
return {
|
|
68
|
+
symbol: (global == null ? void 0 : global.symbol) || "$",
|
|
69
|
+
currency_code: (global == null ? void 0 : global.currency_code) || "AUD"
|
|
70
|
+
};
|
|
71
|
+
}, [(_c = (_b = store == null ? void 0 : store.getState) == null ? void 0 : _b.call(store)) == null ? void 0 : _c.global]);
|
|
72
|
+
const _currencyCode = (0, import_react.useMemo)(() => {
|
|
73
|
+
return currencyCode || (globalConfig == null ? void 0 : globalConfig.currency_code);
|
|
74
|
+
}, [currencyCode, globalConfig == null ? void 0 : globalConfig.currency_code]);
|
|
75
|
+
const currencyDenominations = (0, import_react.useMemo)(() => {
|
|
76
|
+
return (0, import_utils2.getEffectiveDenominationsForCurrency)(denominations, _currencyCode);
|
|
77
|
+
}, [_currencyCode, denominations]);
|
|
78
|
+
const decimalPlaces = (0, import_react.useMemo)(() => {
|
|
79
|
+
var _a2;
|
|
80
|
+
if (typeof amountPrecision === "number") {
|
|
81
|
+
return amountPrecision;
|
|
82
|
+
}
|
|
83
|
+
return ((_a2 = currencyDenominations[0]) == null ? void 0 : _a2.decimal_places) ?? 2;
|
|
84
|
+
}, [amountPrecision, (_d = currencyDenominations[0]) == null ? void 0 : _d.decimal_places]);
|
|
85
|
+
const symbolValue = (0, import_react.useMemo)(() => {
|
|
86
|
+
if (currencySymbol) {
|
|
87
|
+
return currencySymbol;
|
|
88
|
+
}
|
|
89
|
+
return globalConfig == null ? void 0 : globalConfig.symbol;
|
|
90
|
+
}, [currencySymbol, globalConfig == null ? void 0 : globalConfig.symbol]);
|
|
91
|
+
const currentValue = (0, import_react.useMemo)(
|
|
92
|
+
() => String(value ?? internalValue),
|
|
93
|
+
[value, internalValue]
|
|
94
|
+
);
|
|
95
|
+
const updateAmount = (0, import_react.useCallback)(
|
|
96
|
+
(nextValue, source) => {
|
|
97
|
+
if (value === void 0) {
|
|
98
|
+
setInternalValue(nextValue);
|
|
99
|
+
}
|
|
100
|
+
if (typeof onChange === "function") {
|
|
101
|
+
onChange(nextValue, { source });
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
[decimalPlaces, onChange, value]
|
|
105
|
+
);
|
|
106
|
+
const handleAmountChange = (0, import_react.useCallback)(
|
|
107
|
+
(nextValue) => {
|
|
108
|
+
manualInputValueRef.current = nextValue;
|
|
109
|
+
updateAmount(String(nextValue), "manual");
|
|
110
|
+
},
|
|
111
|
+
[updateAmount]
|
|
112
|
+
);
|
|
113
|
+
const handleKeyboardClose = (0, import_react.useCallback)(
|
|
114
|
+
() => {
|
|
115
|
+
var _a2;
|
|
116
|
+
setKeyboardOpen(false);
|
|
117
|
+
if (((_a2 = countedResultRef.current) == null ? void 0 : _a2.amount) && Number(countedResultRef.current.amount) !== Number(manualInputValueRef.current)) {
|
|
118
|
+
setManualCountMismatchOpen(true);
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
[setManualCountMismatchOpen]
|
|
122
|
+
);
|
|
123
|
+
const confirmUseCountedTotal = (0, import_react.useCallback)(() => {
|
|
124
|
+
var _a2;
|
|
125
|
+
updateAmount(((_a2 = countedResultRef.current) == null ? void 0 : _a2.amount) ?? "", "count");
|
|
126
|
+
setManualCountMismatchOpen(false);
|
|
127
|
+
}, [updateAmount]);
|
|
128
|
+
const confirmKeepManualAmount = (0, import_react.useCallback)(() => {
|
|
129
|
+
countedResultRef.current = null;
|
|
130
|
+
setConfirmedQuantities({});
|
|
131
|
+
updateAmount(manualInputValueRef.current ?? "", "manual");
|
|
132
|
+
setManualCountMismatchOpen(false);
|
|
133
|
+
}, [updateAmount]);
|
|
134
|
+
const openCountModal = (0, import_react.useCallback)(() => {
|
|
135
|
+
var _a2;
|
|
136
|
+
if (disabled || countDisabled) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
if (currencyDenominations.length === 0) {
|
|
140
|
+
import_antd.message.warning(
|
|
141
|
+
import_utils.locales.getText("pisell-cash-counting.no-country-config")
|
|
142
|
+
);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const initialQuantities = {
|
|
146
|
+
...(0, import_utils2.buildEmptyQuantities)(currencyDenominations),
|
|
147
|
+
...confirmedQuantities
|
|
148
|
+
};
|
|
149
|
+
setKeyboardOpen(false);
|
|
150
|
+
(_a2 = modalRef.current) == null ? void 0 : _a2.open({ initialQuantities });
|
|
151
|
+
}, [confirmedQuantities, countDisabled, currencyDenominations, disabled]);
|
|
152
|
+
const handleCountCancel = (0, import_react.useCallback)(() => {
|
|
153
|
+
onCountCancel == null ? void 0 : onCountCancel();
|
|
154
|
+
}, [onCountCancel]);
|
|
155
|
+
const handleCountConfirm = (0, import_react.useCallback)(
|
|
156
|
+
(payload) => {
|
|
157
|
+
countedResultRef.current = payload;
|
|
158
|
+
setConfirmedQuantities(payload.quantities);
|
|
159
|
+
updateAmount(payload.amount, "count");
|
|
160
|
+
if (typeof onCountConfirm === "function") {
|
|
161
|
+
onCountConfirm(payload);
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
[onCountConfirm, updateAmount]
|
|
165
|
+
);
|
|
166
|
+
return {
|
|
167
|
+
modalRef,
|
|
168
|
+
triggerRef,
|
|
169
|
+
keyboardOpen,
|
|
170
|
+
setKeyboardOpen,
|
|
171
|
+
currencyDenominations,
|
|
172
|
+
decimalPlaces,
|
|
173
|
+
symbol: symbolValue,
|
|
174
|
+
currencyCode: _currencyCode,
|
|
175
|
+
currentValue,
|
|
176
|
+
handleAmountChange,
|
|
177
|
+
handleKeyboardClose,
|
|
178
|
+
openCountModal,
|
|
179
|
+
handleCountCancel,
|
|
180
|
+
handleCountConfirm,
|
|
181
|
+
manualCountMismatchOpen,
|
|
182
|
+
confirmUseCountedTotal,
|
|
183
|
+
confirmKeepManualAmount
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
187
|
+
0 && (module.exports = {
|
|
188
|
+
usePisellCashCounting
|
|
189
|
+
});
|