@pisell/private-materials 6.5.4 → 6.5.6
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 +1 -1
- package/build/lowcode/preview.js +160 -146
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +9 -9
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +9 -9
- package/es/components/booking/addons/model.d.ts +1 -10
- package/es/components/booking/components/actionButtons/index.js +37 -42
- package/es/components/booking/components/actionButtons/index.less +0 -28
- package/es/components/booking/components/footer/amount.d.ts +3 -3
- package/es/components/booking/components/footer/amount.js +51 -31
- package/es/components/booking/components/footer/index.js +177 -68
- package/es/components/booking/components/footer/utils.js +62 -33
- package/es/components/booking/forms/model.d.ts +1 -10
- package/es/components/booking/info/model.d.ts +1 -10
- package/es/components/booking/info/model.js +5 -0
- package/es/components/booking/info/service/addService/index.js +2 -1
- package/es/components/booking/info/service/addService/utils.d.ts +1 -1
- package/es/components/booking/info/service2/utils.d.ts +1 -1
- package/es/components/booking/info2/index.js +42 -2
- package/es/components/booking/info2/service/addService/index.js +2 -1
- package/es/components/booking/info2/service/addService/utils.d.ts +1 -1
- package/es/components/booking/info2/service/editService/index.js +12 -4
- package/es/components/booking/model.d.ts +1 -9
- package/es/components/booking/notes/model.d.ts +1 -10
- package/es/components/booking/payments/model.d.ts +1 -10
- package/es/components/booking/utils.js +10 -5
- package/es/components/checkout/PaymentModal.d.ts +2 -0
- package/es/components/checkout/PaymentModal.js +462 -263
- package/es/components/checkout/components/AdditionalModule/index.less +1 -1
- package/es/components/checkout/components/AmountSummary/index.js +176 -65
- package/es/components/checkout/components/AmountSummary/index.less +13 -0
- package/es/components/checkout/components/CashPaymentModule/index.d.ts +5 -3
- package/es/components/checkout/components/CashPaymentModule/index.js +110 -132
- package/es/components/checkout/components/CashPaymentModule/index.less +200 -176
- package/es/components/checkout/components/PaymentDetailModal/index.js +2 -2
- package/es/components/checkout/components/PaymentOptionsModule/PaymentMethodItem.d.ts +29 -0
- package/es/components/checkout/components/PaymentOptionsModule/PaymentMethodItem.js +214 -0
- package/es/components/checkout/components/PaymentOptionsModule/index.d.ts +2 -4
- package/es/components/checkout/components/PaymentOptionsModule/index.js +12 -114
- package/es/components/checkout/components/PaymentOptionsModule/index.less +23 -0
- package/es/components/checkout/components/PaymentResultToast/index.js +38 -8
- package/es/components/checkout/components/PaymentResultToast/types.d.ts +2 -0
- package/es/components/checkout/components/SavePayLaterHandler/index.js +1 -1
- package/es/components/checkout/components/SearchAndClientModule/index.js +40 -39
- package/es/components/checkout/components/WalletPassModule/index.js +4 -3
- package/es/components/checkout/components/WalletPassModule/utils.js +10 -4
- package/es/components/checkout/hooks/useWalletPass.js +11 -4
- package/es/components/checkout/index.less +1 -1
- package/es/components/checkout/locales.d.ts +36 -0
- package/es/components/checkout/locales.js +43 -4
- package/es/components/checkout/types.d.ts +1 -0
- package/es/components/eftposPay/amount.d.ts +1 -1
- package/es/components/eftposPay/device.d.ts +1 -1
- package/es/components/eftposPay/hooks.d.ts +1 -1
- package/es/components/eftposPay/store/index.d.ts +3 -3
- package/es/components/pay/toC/model.d.ts +1 -9
- package/es/components/schedules/model.d.ts +1 -9
- package/es/components/shoppingCart/components/Cart/Product.js +143 -71
- package/es/components/shoppingCart/components/Cart/index.js +1 -1
- package/es/components/shoppingCart/components/Cart/index.less +31 -0
- package/es/components/shoppingCart/locales.d.ts +3 -0
- package/es/components/shoppingCart/locales.js +12 -3
- package/es/components/ticketBooking/components/addServiceVariant/addService.d.ts +0 -1
- package/es/components/ticketBooking/components/addServiceVariant/addService.js +9 -12
- package/es/components/ticketBooking/components/addServiceVariant/index.d.ts +0 -1
- package/es/components/ticketBooking/components/menuBar/index.js +3 -1
- package/es/components/ticketBooking/components/menuBar/index.less +7 -0
- package/es/components/ticketBooking/components/ticketBooking/index.d.ts +0 -1
- package/es/components/ticketBooking/hooks/pisellos/useCustomer.js +7 -7
- package/es/components/ticketBooking/index.d.ts +0 -1
- package/es/components/ticketBooking/utils/index.d.ts +1 -1
- package/es/components/ticketBooking/utils/index.js +2 -1
- package/es/components/wallet/Detail/model.d.ts +1 -13
- package/es/components/wallet/DiscountCard/model.d.ts +1 -14
- package/es/components/wallet/PointCard/model.d.ts +1 -13
- package/es/components/wallet/RechargeableCard/model.d.ts +1 -29
- package/es/components/wallet/Voucher/model.d.ts +1 -13
- package/es/components/wallet/model.d.ts +1 -9
- package/es/pro/pisellPriceKeyboardPopover/PisellPriceKeyboardPopover.js +1 -1
- package/es/pro/pisellSimplePriceKeyboardPopover/PisellPriceKeyboardPopover.d.ts +5 -0
- package/es/pro/pisellSimplePriceKeyboardPopover/PisellPriceKeyboardPopover.js +148 -0
- package/es/pro/pisellSimplePriceKeyboardPopover/PisellPriceKeyboardPopover.less +23 -0
- package/es/pro/pisellSimplePriceKeyboardPopover/index.d.ts +2 -0
- package/es/pro/pisellSimplePriceKeyboardPopover/index.js +1 -0
- package/es/pro/pisellSimplePriceKeyboardPopover/types.d.ts +33 -0
- package/es/pro/pisellSimplePriceKeyboardPopover/types.js +1 -0
- package/es/pro/priceKeyboard/components/cashKeyboard/CashKeyboardIntact.d.ts +5 -0
- package/es/pro/priceKeyboard/components/cashKeyboard/CashKeyboardIntact.js +331 -0
- package/es/pro/priceKeyboard/components/cashKeyboard/CashKeyboardSimple.d.ts +13 -0
- package/es/pro/priceKeyboard/components/cashKeyboard/CashKeyboardSimple.js +349 -0
- package/es/pro/priceKeyboard/components/cashKeyboard/index.d.ts +12 -0
- package/es/pro/priceKeyboard/components/cashKeyboard/index.js +49 -0
- package/es/pro/priceKeyboard/components/cashKeyboard/index.less +103 -0
- package/es/pro/priceKeyboard/components/cashKeyboard/locales.d.ts +39 -0
- package/es/pro/priceKeyboard/components/cashKeyboard/locales.js +41 -0
- package/es/pro/priceKeyboard/components/cashKeyboard/types.d.ts +97 -0
- package/es/pro/priceKeyboard/components/cashKeyboard/types.js +1 -0
- package/es/pro/priceKeyboard/components/discountKeyboard/index.d.ts +22 -0
- package/es/pro/priceKeyboard/components/discountKeyboard/index.js +465 -0
- package/es/pro/priceKeyboard/components/discountKeyboard/index.less +47 -0
- package/es/pro/priceKeyboard/components/discountKeyboard/locales.d.ts +42 -0
- package/es/pro/priceKeyboard/components/discountKeyboard/locales.js +44 -0
- package/es/pro/priceKeyboard/components/discountKeyboard/types.d.ts +17 -0
- package/es/pro/priceKeyboard/components/discountKeyboard/types.js +1 -0
- package/es/pro/priceKeyboard/components/paymentKeyboard/index.d.ts +12 -0
- package/es/pro/priceKeyboard/components/paymentKeyboard/index.js +444 -0
- package/es/pro/priceKeyboard/components/paymentKeyboard/index.less +64 -0
- package/es/pro/priceKeyboard/components/paymentKeyboard/locales.d.ts +45 -0
- package/es/pro/priceKeyboard/components/paymentKeyboard/locales.js +47 -0
- package/es/pro/priceKeyboard/components/paymentKeyboard/types.d.ts +39 -0
- package/es/pro/priceKeyboard/components/paymentKeyboard/types.js +1 -0
- package/es/pro/priceKeyboard/components/shortcuts/index.d.ts +17 -0
- package/es/pro/priceKeyboard/components/shortcuts/index.js +47 -0
- package/es/pro/priceKeyboard/components/shortcuts/index.less +39 -0
- package/es/pro/priceKeyboard/hooks/keyActions.d.ts +28 -0
- package/es/pro/priceKeyboard/hooks/keyActions.js +252 -0
- package/es/pro/priceKeyboard/hooks/rightItems.d.ts +28 -0
- package/es/pro/priceKeyboard/hooks/rightItems.js +50 -0
- package/es/pro/priceKeyboard/index.d.ts +3 -0
- package/es/pro/priceKeyboard/index.js +3 -0
- package/es/pro/priceKeyboard/index.less +215 -0
- package/es/pro/priceKeyboard/utils.d.ts +31 -0
- package/es/pro/priceKeyboard/utils.js +51 -0
- package/es/pro/skuDetailModal/index.js +19 -16
- package/lib/components/booking/addons/model.d.ts +1 -10
- package/lib/components/booking/components/actionButtons/index.js +31 -28
- package/lib/components/booking/components/actionButtons/index.less +0 -28
- package/lib/components/booking/components/footer/amount.d.ts +3 -3
- package/lib/components/booking/components/footer/amount.js +49 -34
- package/lib/components/booking/components/footer/index.js +114 -40
- package/lib/components/booking/components/footer/utils.js +35 -7
- package/lib/components/booking/forms/model.d.ts +1 -10
- package/lib/components/booking/info/model.d.ts +1 -10
- package/lib/components/booking/info/model.js +3 -0
- package/lib/components/booking/info/service/addService/index.js +2 -1
- package/lib/components/booking/info/service/addService/utils.d.ts +1 -1
- package/lib/components/booking/info/service2/utils.d.ts +1 -1
- package/lib/components/booking/info2/index.js +18 -1
- package/lib/components/booking/info2/service/addService/index.js +2 -1
- package/lib/components/booking/info2/service/addService/utils.d.ts +1 -1
- package/lib/components/booking/info2/service/editService/index.js +12 -4
- package/lib/components/booking/model.d.ts +1 -9
- package/lib/components/booking/notes/model.d.ts +1 -10
- package/lib/components/booking/payments/model.d.ts +1 -10
- package/lib/components/booking/utils.js +10 -5
- package/lib/components/checkout/PaymentModal.d.ts +2 -0
- package/lib/components/checkout/PaymentModal.js +208 -91
- package/lib/components/checkout/components/AdditionalModule/index.less +1 -1
- package/lib/components/checkout/components/AmountSummary/index.js +120 -50
- package/lib/components/checkout/components/AmountSummary/index.less +13 -0
- package/lib/components/checkout/components/CashPaymentModule/index.d.ts +5 -3
- package/lib/components/checkout/components/CashPaymentModule/index.js +101 -134
- package/lib/components/checkout/components/CashPaymentModule/index.less +200 -176
- package/lib/components/checkout/components/PaymentDetailModal/index.js +2 -2
- package/lib/components/checkout/components/PaymentOptionsModule/PaymentMethodItem.d.ts +29 -0
- package/lib/components/checkout/components/PaymentOptionsModule/PaymentMethodItem.js +163 -0
- package/lib/components/checkout/components/PaymentOptionsModule/index.d.ts +2 -4
- package/lib/components/checkout/components/PaymentOptionsModule/index.js +11 -123
- package/lib/components/checkout/components/PaymentOptionsModule/index.less +23 -0
- package/lib/components/checkout/components/PaymentResultToast/index.js +26 -1
- package/lib/components/checkout/components/PaymentResultToast/types.d.ts +2 -0
- package/lib/components/checkout/components/SavePayLaterHandler/index.js +1 -1
- package/lib/components/checkout/components/SearchAndClientModule/index.js +3 -29
- package/lib/components/checkout/components/WalletPassModule/index.js +4 -3
- package/lib/components/checkout/components/WalletPassModule/utils.js +8 -4
- package/lib/components/checkout/hooks/useWalletPass.js +11 -6
- package/lib/components/checkout/index.less +1 -1
- package/lib/components/checkout/locales.d.ts +36 -0
- package/lib/components/checkout/locales.js +43 -4
- package/lib/components/checkout/types.d.ts +1 -0
- package/lib/components/eftposPay/amount.d.ts +1 -1
- package/lib/components/eftposPay/device.d.ts +1 -1
- package/lib/components/eftposPay/hooks.d.ts +1 -1
- package/lib/components/eftposPay/store/index.d.ts +3 -3
- package/lib/components/pay/toC/model.d.ts +1 -9
- package/lib/components/schedules/model.d.ts +1 -9
- package/lib/components/shoppingCart/components/Cart/Product.js +111 -51
- package/lib/components/shoppingCart/components/Cart/index.js +1 -1
- package/lib/components/shoppingCart/components/Cart/index.less +31 -0
- package/lib/components/shoppingCart/locales.d.ts +3 -0
- package/lib/components/shoppingCart/locales.js +6 -3
- package/lib/components/ticketBooking/components/addServiceVariant/addService.d.ts +0 -1
- package/lib/components/ticketBooking/components/addServiceVariant/addService.js +1 -4
- package/lib/components/ticketBooking/components/addServiceVariant/index.d.ts +0 -1
- package/lib/components/ticketBooking/components/menuBar/index.js +1 -1
- package/lib/components/ticketBooking/components/menuBar/index.less +7 -0
- package/lib/components/ticketBooking/components/ticketBooking/index.d.ts +0 -1
- package/lib/components/ticketBooking/hooks/pisellos/useCustomer.js +7 -7
- package/lib/components/ticketBooking/index.d.ts +0 -1
- package/lib/components/ticketBooking/utils/index.d.ts +1 -1
- package/lib/components/ticketBooking/utils/index.js +2 -1
- package/lib/components/wallet/Detail/model.d.ts +1 -13
- package/lib/components/wallet/DiscountCard/model.d.ts +1 -14
- package/lib/components/wallet/PointCard/model.d.ts +1 -13
- package/lib/components/wallet/RechargeableCard/model.d.ts +1 -29
- package/lib/components/wallet/Voucher/model.d.ts +1 -13
- package/lib/components/wallet/model.d.ts +1 -9
- package/lib/pro/pisellPriceKeyboardPopover/PisellPriceKeyboardPopover.js +2 -2
- package/lib/pro/pisellSimplePriceKeyboardPopover/PisellPriceKeyboardPopover.d.ts +5 -0
- package/lib/pro/pisellSimplePriceKeyboardPopover/PisellPriceKeyboardPopover.js +144 -0
- package/lib/pro/pisellSimplePriceKeyboardPopover/PisellPriceKeyboardPopover.less +23 -0
- package/lib/pro/pisellSimplePriceKeyboardPopover/index.d.ts +2 -0
- package/lib/pro/pisellSimplePriceKeyboardPopover/index.js +35 -0
- package/lib/pro/pisellSimplePriceKeyboardPopover/types.d.ts +33 -0
- package/lib/pro/pisellSimplePriceKeyboardPopover/types.js +17 -0
- package/lib/pro/priceKeyboard/components/cashKeyboard/CashKeyboardIntact.d.ts +5 -0
- package/lib/pro/priceKeyboard/components/cashKeyboard/CashKeyboardIntact.js +360 -0
- package/lib/pro/priceKeyboard/components/cashKeyboard/CashKeyboardSimple.d.ts +13 -0
- package/lib/pro/priceKeyboard/components/cashKeyboard/CashKeyboardSimple.js +399 -0
- package/lib/pro/priceKeyboard/components/cashKeyboard/index.d.ts +12 -0
- package/lib/pro/priceKeyboard/components/cashKeyboard/index.js +76 -0
- package/lib/pro/priceKeyboard/components/cashKeyboard/index.less +103 -0
- package/lib/pro/priceKeyboard/components/cashKeyboard/locales.d.ts +39 -0
- package/lib/pro/priceKeyboard/components/cashKeyboard/locales.js +65 -0
- package/lib/pro/priceKeyboard/components/cashKeyboard/types.d.ts +97 -0
- package/lib/pro/priceKeyboard/components/cashKeyboard/types.js +17 -0
- package/lib/pro/priceKeyboard/components/discountKeyboard/index.d.ts +22 -0
- package/lib/pro/priceKeyboard/components/discountKeyboard/index.js +504 -0
- package/lib/pro/priceKeyboard/components/discountKeyboard/index.less +47 -0
- package/lib/pro/priceKeyboard/components/discountKeyboard/locales.d.ts +42 -0
- package/lib/pro/priceKeyboard/components/discountKeyboard/locales.js +68 -0
- package/lib/pro/priceKeyboard/components/discountKeyboard/types.d.ts +17 -0
- package/lib/pro/priceKeyboard/components/discountKeyboard/types.js +17 -0
- package/lib/pro/priceKeyboard/components/paymentKeyboard/index.d.ts +12 -0
- package/lib/pro/priceKeyboard/components/paymentKeyboard/index.js +488 -0
- package/lib/pro/priceKeyboard/components/paymentKeyboard/index.less +64 -0
- package/lib/pro/priceKeyboard/components/paymentKeyboard/locales.d.ts +45 -0
- package/lib/pro/priceKeyboard/components/paymentKeyboard/locales.js +71 -0
- package/lib/pro/priceKeyboard/components/paymentKeyboard/types.d.ts +39 -0
- package/lib/pro/priceKeyboard/components/paymentKeyboard/types.js +17 -0
- package/lib/pro/priceKeyboard/components/shortcuts/index.d.ts +17 -0
- package/lib/pro/priceKeyboard/components/shortcuts/index.js +79 -0
- package/lib/pro/priceKeyboard/components/shortcuts/index.less +39 -0
- package/lib/pro/priceKeyboard/hooks/keyActions.d.ts +28 -0
- package/lib/pro/priceKeyboard/hooks/keyActions.js +176 -0
- package/lib/pro/priceKeyboard/hooks/rightItems.d.ts +28 -0
- package/lib/pro/priceKeyboard/hooks/rightItems.js +81 -0
- package/lib/pro/priceKeyboard/index.d.ts +3 -0
- package/lib/pro/priceKeyboard/index.js +45 -0
- package/lib/pro/priceKeyboard/index.less +215 -0
- package/lib/pro/priceKeyboard/utils.d.ts +31 -0
- package/lib/pro/priceKeyboard/utils.js +75 -0
- package/lib/pro/skuDetailModal/index.js +18 -22
- package/package.json +12 -12
@@ -0,0 +1,97 @@
|
|
1
|
+
/// <reference types="react" />
|
2
|
+
export interface RightItemsStyleProps {
|
3
|
+
buttonBackgroundColor?: string;
|
4
|
+
textColor?: string;
|
5
|
+
resetButtonBackgroundColor?: string;
|
6
|
+
resetButtonTextColor?: string;
|
7
|
+
isDoneButtonFollowTheme?: boolean;
|
8
|
+
doneButtonBackgroundColor?: string;
|
9
|
+
doneButtonTextColor?: string;
|
10
|
+
}
|
11
|
+
export declare type ItemValue = string | number;
|
12
|
+
export interface Item {
|
13
|
+
value: ItemValue;
|
14
|
+
label: React.ReactNode;
|
15
|
+
disabled: boolean;
|
16
|
+
type: 'text' | 'primary';
|
17
|
+
style?: React.CSSProperties;
|
18
|
+
size?: number;
|
19
|
+
}
|
20
|
+
export interface KeyboardProps {
|
21
|
+
className?: string;
|
22
|
+
style?: React.CSSProperties;
|
23
|
+
onChange?: (value?: ItemValue) => void;
|
24
|
+
items?: Item[];
|
25
|
+
rightItems?: Item[];
|
26
|
+
keydown?: boolean;
|
27
|
+
}
|
28
|
+
export interface TitleAreaConfig {
|
29
|
+
visible?: boolean;
|
30
|
+
title?: {
|
31
|
+
visible?: boolean;
|
32
|
+
text?: string;
|
33
|
+
fontSize?: string | number;
|
34
|
+
color?: string;
|
35
|
+
fontWeight?: string | number;
|
36
|
+
};
|
37
|
+
subtitle?: {
|
38
|
+
visible?: boolean;
|
39
|
+
text?: string;
|
40
|
+
fontSize?: string | number;
|
41
|
+
color?: string;
|
42
|
+
fontWeight?: string | number;
|
43
|
+
};
|
44
|
+
alignment?: 'left' | 'right' | 'center' | 'space-between';
|
45
|
+
spacing?: string | number;
|
46
|
+
}
|
47
|
+
export interface DisplayFieldConfig {
|
48
|
+
cashReceived?: {
|
49
|
+
visible?: boolean;
|
50
|
+
};
|
51
|
+
balanceDue?: {
|
52
|
+
visible?: boolean;
|
53
|
+
};
|
54
|
+
changeDue?: {
|
55
|
+
visible?: boolean;
|
56
|
+
};
|
57
|
+
gridRatio?: number[];
|
58
|
+
}
|
59
|
+
export interface CashKeyboardBaseProps {
|
60
|
+
amountSymbol?: string;
|
61
|
+
value?: string;
|
62
|
+
/** 默认值,非受控模式 */
|
63
|
+
defaultValue?: string;
|
64
|
+
/** 原始值,多用于重置, 当前对应 Balance Due */
|
65
|
+
originalValue?: string;
|
66
|
+
placeholder?: string;
|
67
|
+
max?: number;
|
68
|
+
min?: number;
|
69
|
+
disabled?: boolean;
|
70
|
+
doneText?: string;
|
71
|
+
resetText?: string;
|
72
|
+
presets?: any;
|
73
|
+
hiddenChangeDue?: boolean;
|
74
|
+
onChange?: (val: string) => void;
|
75
|
+
onEnter?: (val: string) => void;
|
76
|
+
onReset?: () => void;
|
77
|
+
onPay?: () => void;
|
78
|
+
rightItemsStyle?: RightItemsStyleProps;
|
79
|
+
titleArea?: TitleAreaConfig;
|
80
|
+
displayField?: DisplayFieldConfig;
|
81
|
+
keyboardProps?: KeyboardProps;
|
82
|
+
style?: React.CSSProperties;
|
83
|
+
selectType?: 'light' | 'dark';
|
84
|
+
backgroundColor?: string;
|
85
|
+
containerBackgroundColor?: string;
|
86
|
+
buttonBackgroundColor?: string;
|
87
|
+
textColor?: string;
|
88
|
+
resetButtonBackgroundColor?: string;
|
89
|
+
resetButtonTextColor?: string;
|
90
|
+
isDoneButtonFollowTheme?: boolean;
|
91
|
+
doneButtonBackgroundColor?: string;
|
92
|
+
doneButtonTextColor?: string;
|
93
|
+
keyboardBackgroundColor?: string;
|
94
|
+
keyboardButtonBackgroundColor?: string;
|
95
|
+
keyboardButtonTextColor?: string;
|
96
|
+
keyboardButtonHoverColor?: string;
|
97
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { DiscountKeyboardBaseProps } from './types';
|
3
|
+
import './index.less';
|
4
|
+
export interface DiscountKeyboardProps extends DiscountKeyboardBaseProps {
|
5
|
+
containerProps?: {
|
6
|
+
renderType: 'modal' | 'popover';
|
7
|
+
open?: boolean;
|
8
|
+
[key: string]: any;
|
9
|
+
};
|
10
|
+
children?: React.ReactNode;
|
11
|
+
}
|
12
|
+
declare const DiscountKeyboard: {
|
13
|
+
(props: DiscountKeyboardProps): JSX.Element | null;
|
14
|
+
InputNumber: (props: DiscountKeyboardInputNumberProps) => JSX.Element;
|
15
|
+
};
|
16
|
+
interface DiscountKeyboardInputNumberProps {
|
17
|
+
value?: number;
|
18
|
+
onChange?: (val: number) => void;
|
19
|
+
keyboardProps?: DiscountKeyboardProps;
|
20
|
+
[key: string]: any;
|
21
|
+
}
|
22
|
+
export default DiscountKeyboard;
|
@@ -0,0 +1,465 @@
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
2
|
+
var _excluded = ["containerProps", "children"],
|
3
|
+
_excluded2 = ["renderType", "open"],
|
4
|
+
_excluded3 = ["originalValue", "value", "onChange", "keyboardProps"];
|
5
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
6
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
7
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
8
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
9
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
10
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
11
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
12
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
13
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
14
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
15
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
16
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
17
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
18
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
19
|
+
import React, { useEffect, useMemo, useState, useId, useCallback } from 'react';
|
20
|
+
import { Popover, Segmented, InputNumber } from 'antd';
|
21
|
+
import Decimal from 'decimal.js';
|
22
|
+
//@ts-ignore
|
23
|
+
import { locales } from '@pisell/utils';
|
24
|
+
import { PisellText, Keyboard, VirtualInput, PisellModal } from '@pisell/materials';
|
25
|
+
import { useControllableValue } from 'ahooks';
|
26
|
+
import useRightItems from "../../hooks/rightItems";
|
27
|
+
import useKeyActions from "../../hooks/keyActions";
|
28
|
+
import { setKeyboardTheme } from "../../utils";
|
29
|
+
import useEngineContext from "../../../../hooks/useEngineContext";
|
30
|
+
import localeTexts from "./locales";
|
31
|
+
import "./index.less";
|
32
|
+
var TIP_COLORS = {
|
33
|
+
positive: '#CA8504',
|
34
|
+
negative: '#1570EF',
|
35
|
+
overflow: '#D92D20'
|
36
|
+
};
|
37
|
+
|
38
|
+
/**
|
39
|
+
* originalValue: 当前订单原始值
|
40
|
+
* defaultValue: 折扣后金额
|
41
|
+
* onEnter: 折扣金额回调
|
42
|
+
*/
|
43
|
+
var DiscountKeyboardBase = function DiscountKeyboardBase(props) {
|
44
|
+
var _context$appHelper$ut, _context$appHelper$ut2, _context$appHelper$ut3, _context$appHelper$ut4;
|
45
|
+
var defaultValue = props.defaultValue,
|
46
|
+
originalValue = props.originalValue,
|
47
|
+
_props$selectType = props.selectType,
|
48
|
+
selectType = _props$selectType === void 0 ? 'light' : _props$selectType,
|
49
|
+
resetText = props.resetText,
|
50
|
+
doneText = props.doneText,
|
51
|
+
onEnter = props.onEnter,
|
52
|
+
onReset = props.onReset,
|
53
|
+
_props$enableExceedMa = props.enableExceedMaxAmount,
|
54
|
+
enableExceedMaxAmount = _props$enableExceedMa === void 0 ? false : _props$enableExceedMa;
|
55
|
+
var context = useEngineContext();
|
56
|
+
var _useState = useState(true),
|
57
|
+
_useState2 = _slicedToArray(_useState, 2),
|
58
|
+
isFirstInput = _useState2[0],
|
59
|
+
setIsFirstInput = _useState2[1];
|
60
|
+
locales.init(localeTexts, ((_context$appHelper$ut = context.appHelper.utils) === null || _context$appHelper$ut === void 0 || (_context$appHelper$ut2 = _context$appHelper$ut.getApp) === null || _context$appHelper$ut2 === void 0 || (_context$appHelper$ut2 = _context$appHelper$ut2.call(_context$appHelper$ut)) === null || _context$appHelper$ut2 === void 0 || (_context$appHelper$ut2 = _context$appHelper$ut2.locales) === null || _context$appHelper$ut2 === void 0 || (_context$appHelper$ut3 = _context$appHelper$ut2.getLocale) === null || _context$appHelper$ut3 === void 0 ? void 0 : _context$appHelper$ut3.call(_context$appHelper$ut2)) || ((_context$appHelper$ut4 = context.appHelper.utils) === null || _context$appHelper$ut4 === void 0 || (_context$appHelper$ut4 = _context$appHelper$ut4.storage) === null || _context$appHelper$ut4 === void 0 ? void 0 : _context$appHelper$ut4.get('umi_locale')) || 'en');
|
61
|
+
var getData = context.appHelper.utils.getData;
|
62
|
+
var amountSymbol = props.amountSymbol || (getData === null || getData === void 0 ? void 0 : getData('shop_symbol')) || '$';
|
63
|
+
var uniqueId = useId();
|
64
|
+
var uniqueKeyboardId = "virtual-keyboard-".concat(uniqueId.replace(/:/g, '-'));
|
65
|
+
// 一口价或者折扣
|
66
|
+
var _useState3 = useState('priceOverride'),
|
67
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
68
|
+
updateMode = _useState4[0],
|
69
|
+
setUpdateMode = _useState4[1];
|
70
|
+
// 折扣模式分为 金额 和 百分比
|
71
|
+
var _useState5 = useState('amount'),
|
72
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
73
|
+
discountMode = _useState6[0],
|
74
|
+
setDiscountMode = _useState6[1];
|
75
|
+
var _useState7 = useState(defaultValue ? String(defaultValue) : ''),
|
76
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
77
|
+
internalValue = _useState8[0],
|
78
|
+
setInternalValue = _useState8[1];
|
79
|
+
var _useState9 = useState(''),
|
80
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
81
|
+
discountValue = _useState10[0],
|
82
|
+
setDiscountValue = _useState10[1];
|
83
|
+
useEffect(function () {
|
84
|
+
document.body.id = 'body';
|
85
|
+
}, []);
|
86
|
+
|
87
|
+
// 设置主题
|
88
|
+
useEffect(function () {
|
89
|
+
setKeyboardTheme(selectType);
|
90
|
+
}, [selectType]);
|
91
|
+
var _onReset = useCallback(function () {
|
92
|
+
if (updateMode === 'priceOverride') {
|
93
|
+
// 重置为最初价格
|
94
|
+
setInternalValue(originalValue ? String(originalValue) : '');
|
95
|
+
setIsFirstInput(true);
|
96
|
+
} else {
|
97
|
+
setDiscountValue('');
|
98
|
+
}
|
99
|
+
onReset === null || onReset === void 0 || onReset();
|
100
|
+
}, [originalValue, onReset, updateMode]);
|
101
|
+
var _handleChange = useCallback(function (val) {
|
102
|
+
if (updateMode === 'priceOverride') {
|
103
|
+
setIsFirstInput(false);
|
104
|
+
setInternalValue(val);
|
105
|
+
} else {
|
106
|
+
setDiscountValue(val);
|
107
|
+
}
|
108
|
+
}, [updateMode]);
|
109
|
+
|
110
|
+
// 计算折扣金额和符号
|
111
|
+
var discountAmount = useMemo(function () {
|
112
|
+
var originalPrice = new Decimal(originalValue || 0);
|
113
|
+
var discountAmount = new Decimal(0);
|
114
|
+
if (updateMode === 'priceOverride') {
|
115
|
+
discountAmount = originalPrice.minus(new Decimal(internalValue || 0));
|
116
|
+
} else {
|
117
|
+
// discount 模式
|
118
|
+
if (discountMode === 'amount') {
|
119
|
+
discountAmount = new Decimal(discountValue || 0);
|
120
|
+
} else {
|
121
|
+
// percentage 模式
|
122
|
+
var percentage = new Decimal(discountValue || 0);
|
123
|
+
discountAmount = originalPrice.times(percentage.dividedBy(100));
|
124
|
+
}
|
125
|
+
}
|
126
|
+
return discountAmount.toNumber();
|
127
|
+
}, [updateMode, discountMode, internalValue, discountValue, originalValue]);
|
128
|
+
var isDiscountOverflow = useMemo(function () {
|
129
|
+
var _original = new Decimal(originalValue || 0);
|
130
|
+
if (updateMode === 'priceOverride') {
|
131
|
+
return new Decimal(internalValue || 0).greaterThan(_original);
|
132
|
+
}
|
133
|
+
if (discountMode === 'amount') {
|
134
|
+
return new Decimal(discountValue || 0).greaterThan(_original);
|
135
|
+
}
|
136
|
+
return false;
|
137
|
+
}, [updateMode, discountMode, internalValue, discountValue, originalValue]);
|
138
|
+
var payableAmount = useMemo(function () {
|
139
|
+
return new Decimal(originalValue || 0).minus(discountAmount).toNumber();
|
140
|
+
}, [originalValue, discountAmount]);
|
141
|
+
var handleEnter = function handleEnter() {
|
142
|
+
// 改价模式下,且允许超出原价,那么直接返回
|
143
|
+
if (updateMode === 'priceOverride' && enableExceedMaxAmount) {
|
144
|
+
onEnter === null || onEnter === void 0 || onEnter(String(discountAmount));
|
145
|
+
return;
|
146
|
+
}
|
147
|
+
// 折扣模式、或一口价有限额,则进行折扣值的校验
|
148
|
+
if (isDiscountOverflow) {
|
149
|
+
return;
|
150
|
+
}
|
151
|
+
onEnter === null || onEnter === void 0 || onEnter(String(discountAmount));
|
152
|
+
};
|
153
|
+
var _max = useMemo(function () {
|
154
|
+
return updateMode === 'discount' && discountMode === 'percentage' ? 100 : undefined;
|
155
|
+
}, [updateMode, discountMode]);
|
156
|
+
var _useKeyActions = useKeyActions({
|
157
|
+
onEnter: handleEnter,
|
158
|
+
onReset: _onReset,
|
159
|
+
onChange: _handleChange,
|
160
|
+
value: updateMode === 'priceOverride' ? internalValue : discountValue,
|
161
|
+
max: _max,
|
162
|
+
mode: isFirstInput && updateMode === 'priceOverride' ? 'replace' : 'append',
|
163
|
+
scale: 2
|
164
|
+
}),
|
165
|
+
handleChange = _useKeyActions.handleChange;
|
166
|
+
var rightItems = useRightItems({
|
167
|
+
rightItemsStyle: {
|
168
|
+
doneButtonStyle: {
|
169
|
+
boxShadow: '0px 0px 1px #898A8D',
|
170
|
+
cursor: updateMode !== 'priceOverride' && isDiscountOverflow ? 'not-allowed' : undefined,
|
171
|
+
backgroundColor: updateMode !== 'priceOverride' && isDiscountOverflow ? '#D0D5DD' : undefined
|
172
|
+
}
|
173
|
+
},
|
174
|
+
doneText: doneText || locales.getText('discount-keyboard-done'),
|
175
|
+
resetText: resetText || locales.getText('discount-keyboard-reset')
|
176
|
+
});
|
177
|
+
var formattedVal = useMemo(function () {
|
178
|
+
if (updateMode === 'priceOverride') {
|
179
|
+
return internalValue ? "".concat(amountSymbol).concat(internalValue) : '';
|
180
|
+
}
|
181
|
+
if (discountMode === 'amount') {
|
182
|
+
return discountValue ? "".concat(amountSymbol).concat(discountValue) : '';
|
183
|
+
} else {
|
184
|
+
return discountValue ? "".concat(discountValue, "%") : '';
|
185
|
+
}
|
186
|
+
}, [updateMode, discountMode, internalValue, discountValue, amountSymbol]);
|
187
|
+
var placeholder = useMemo(function () {
|
188
|
+
if (updateMode === 'priceOverride') {
|
189
|
+
return "".concat(amountSymbol, "0");
|
190
|
+
} else {
|
191
|
+
if (discountMode === 'amount') {
|
192
|
+
return '0';
|
193
|
+
}
|
194
|
+
return '%';
|
195
|
+
}
|
196
|
+
}, [amountSymbol, updateMode, discountMode]);
|
197
|
+
var renderBottomContent = function renderBottomContent() {
|
198
|
+
// 没改价,则为空
|
199
|
+
if (new Decimal(discountAmount).equals(0)) {
|
200
|
+
return /*#__PURE__*/React.createElement("div", null, "\xA0");
|
201
|
+
}
|
202
|
+
if (updateMode === 'priceOverride' || discountMode === 'percentage') {
|
203
|
+
var color;
|
204
|
+
var sign = '';
|
205
|
+
// 折扣为正值, 展示为负
|
206
|
+
if (new Decimal(discountAmount).greaterThan(0)) {
|
207
|
+
color = TIP_COLORS.negative;
|
208
|
+
sign = '-';
|
209
|
+
} else {
|
210
|
+
sign = '+';
|
211
|
+
color = TIP_COLORS.positive;
|
212
|
+
}
|
213
|
+
var style = {
|
214
|
+
color: color
|
215
|
+
};
|
216
|
+
return /*#__PURE__*/React.createElement("div", {
|
217
|
+
style: style,
|
218
|
+
className: "ellipsis"
|
219
|
+
}, /*#__PURE__*/React.createElement("span", null, sign, /*#__PURE__*/React.createElement(PisellText.Amount, {
|
220
|
+
hideDecimalForWholeNumbers: false,
|
221
|
+
precision: 2,
|
222
|
+
value: Math.abs(discountAmount)
|
223
|
+
})));
|
224
|
+
}
|
225
|
+
return /*#__PURE__*/React.createElement("div", {
|
226
|
+
style: {
|
227
|
+
color: isDiscountOverflow ? TIP_COLORS.overflow : ''
|
228
|
+
},
|
229
|
+
className: "ellipsis"
|
230
|
+
}, locales.getText('discount-keyboard-max-discount'), ":", ' ', /*#__PURE__*/React.createElement(PisellText.Amount, {
|
231
|
+
hideDecimalForWholeNumbers: false,
|
232
|
+
precision: 2,
|
233
|
+
value: originalValue
|
234
|
+
}));
|
235
|
+
};
|
236
|
+
var customDisplay = function customDisplay() {
|
237
|
+
var _color = updateMode === 'discount' && discountMode === 'amount' && isDiscountOverflow ? TIP_COLORS.overflow : undefined;
|
238
|
+
return /*#__PURE__*/React.createElement("div", {
|
239
|
+
style: {
|
240
|
+
display: 'flex',
|
241
|
+
gap: 8
|
242
|
+
}
|
243
|
+
}, /*#__PURE__*/React.createElement(VirtualInput, {
|
244
|
+
focused: true,
|
245
|
+
value: formattedVal,
|
246
|
+
wrapperStyle: {
|
247
|
+
padding: '12px 20px',
|
248
|
+
borderRadius: '8px',
|
249
|
+
backgroundColor: 'white',
|
250
|
+
boxShadow: '0px 1px 2px rgba(16, 24, 40, 0.06)',
|
251
|
+
flex: '2',
|
252
|
+
overflow: 'hidden'
|
253
|
+
},
|
254
|
+
style: {
|
255
|
+
color: _color
|
256
|
+
},
|
257
|
+
placeholder: placeholder,
|
258
|
+
bottomContent: renderBottomContent()
|
259
|
+
}), /*#__PURE__*/React.createElement("div", {
|
260
|
+
style: {
|
261
|
+
flex: '1',
|
262
|
+
display: 'flex',
|
263
|
+
flexDirection: 'column',
|
264
|
+
borderRadius: '8px',
|
265
|
+
backgroundColor: '#ffffff',
|
266
|
+
padding: 8,
|
267
|
+
boxShadow: '0px 1px 2px rgba(16, 24, 40, 0.06)',
|
268
|
+
overflow: 'hidden'
|
269
|
+
}
|
270
|
+
}, /*#__PURE__*/React.createElement("div", {
|
271
|
+
style: {
|
272
|
+
flex: 1
|
273
|
+
}
|
274
|
+
}, /*#__PURE__*/React.createElement("div", {
|
275
|
+
style: {
|
276
|
+
color: '#667085',
|
277
|
+
fontSize: 12,
|
278
|
+
fontWeight: 500,
|
279
|
+
wordWrap: 'break-word'
|
280
|
+
}
|
281
|
+
}, locales.getText('discount-keyboard-total')), /*#__PURE__*/React.createElement("div", {
|
282
|
+
style: {
|
283
|
+
color: '#475467',
|
284
|
+
fontSize: 14,
|
285
|
+
fontWeight: 700,
|
286
|
+
wordWrap: 'break-word'
|
287
|
+
}
|
288
|
+
}, /*#__PURE__*/React.createElement(PisellText.Amount, {
|
289
|
+
value: originalValue
|
290
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
291
|
+
style: {
|
292
|
+
flex: 1
|
293
|
+
}
|
294
|
+
}, /*#__PURE__*/React.createElement("div", {
|
295
|
+
style: {
|
296
|
+
color: '#667085',
|
297
|
+
fontSize: 12,
|
298
|
+
fontWeight: 500,
|
299
|
+
wordWrap: 'break-word'
|
300
|
+
}
|
301
|
+
}, locales.getText('discount-keyboard-payable')), /*#__PURE__*/React.createElement("div", {
|
302
|
+
style: {
|
303
|
+
color: '#475467',
|
304
|
+
fontSize: 14,
|
305
|
+
fontWeight: 700,
|
306
|
+
wordWrap: 'break-word'
|
307
|
+
}
|
308
|
+
}, /*#__PURE__*/React.createElement(PisellText.Amount, {
|
309
|
+
value: payableAmount
|
310
|
+
})))));
|
311
|
+
};
|
312
|
+
return /*#__PURE__*/React.createElement("div", {
|
313
|
+
className: "pisell-pro-price-keyboard-discount"
|
314
|
+
}, /*#__PURE__*/React.createElement(Segmented, {
|
315
|
+
size: "large",
|
316
|
+
style: {
|
317
|
+
padding: 6
|
318
|
+
},
|
319
|
+
options: [{
|
320
|
+
label: locales.getText('discount-keyboard-price-override'),
|
321
|
+
value: 'priceOverride'
|
322
|
+
}, {
|
323
|
+
label: locales.getText('discount-keyboard-discount'),
|
324
|
+
value: 'discount'
|
325
|
+
}],
|
326
|
+
value: updateMode,
|
327
|
+
onChange: function onChange(val) {
|
328
|
+
return setUpdateMode(val);
|
329
|
+
},
|
330
|
+
block: true
|
331
|
+
}), updateMode === 'discount' && /*#__PURE__*/React.createElement(Segmented, {
|
332
|
+
size: "large",
|
333
|
+
style: {
|
334
|
+
padding: 6
|
335
|
+
},
|
336
|
+
options: [{
|
337
|
+
label: locales.getText('discount-keyboard-amount') + " (".concat(amountSymbol, ")"),
|
338
|
+
value: 'amount'
|
339
|
+
}, {
|
340
|
+
label: locales.getText('discount-keyboard-percentage') + ' (%)',
|
341
|
+
value: 'percentage'
|
342
|
+
}],
|
343
|
+
value: discountMode,
|
344
|
+
onChange: function onChange(val) {
|
345
|
+
setDiscountMode(val);
|
346
|
+
setDiscountValue('');
|
347
|
+
},
|
348
|
+
block: true
|
349
|
+
}), /*#__PURE__*/React.createElement("div", {
|
350
|
+
className: "pisell-pro-price-keyboard-content"
|
351
|
+
}, customDisplay(), /*#__PURE__*/React.createElement(Keyboard, {
|
352
|
+
rightItems: rightItems,
|
353
|
+
onChange: handleChange,
|
354
|
+
id: uniqueKeyboardId
|
355
|
+
})));
|
356
|
+
};
|
357
|
+
var DiscountKeyboard = function DiscountKeyboard(props) {
|
358
|
+
var containerProps = props.containerProps,
|
359
|
+
children = props.children,
|
360
|
+
keyboardProps = _objectWithoutProperties(props, _excluded);
|
361
|
+
if (!containerProps) {
|
362
|
+
return /*#__PURE__*/React.createElement(DiscountKeyboardBase, keyboardProps);
|
363
|
+
}
|
364
|
+
var _ref = containerProps || {},
|
365
|
+
renderType = _ref.renderType,
|
366
|
+
open = _ref.open,
|
367
|
+
restProps = _objectWithoutProperties(_ref, _excluded2);
|
368
|
+
|
369
|
+
// 暂时只支持受控模式
|
370
|
+
if (renderType === 'popover') {
|
371
|
+
return /*#__PURE__*/React.createElement(Popover, _extends({
|
372
|
+
key: "".concat(open),
|
373
|
+
open: open,
|
374
|
+
trigger: "click",
|
375
|
+
className: "pisell-discount-keyboard-popover"
|
376
|
+
}, restProps, {
|
377
|
+
content: /*#__PURE__*/React.createElement(DiscountKeyboardBase, keyboardProps)
|
378
|
+
}), children);
|
379
|
+
}
|
380
|
+
|
381
|
+
// 暂时只支持受控模式
|
382
|
+
if (renderType === 'modal') {
|
383
|
+
return open ? /*#__PURE__*/React.createElement(PisellModal, _extends({
|
384
|
+
platform: 'pc',
|
385
|
+
open: true,
|
386
|
+
width: "unset",
|
387
|
+
header: null,
|
388
|
+
footer: false,
|
389
|
+
mask: false,
|
390
|
+
maskClosable: true,
|
391
|
+
bodyStyle: {
|
392
|
+
padding: '0px',
|
393
|
+
backgroundColor: 'transparent'
|
394
|
+
},
|
395
|
+
closeIcon: null,
|
396
|
+
className: "pisell-discount-keyboard-modal",
|
397
|
+
destroyOnHidden: true
|
398
|
+
}, restProps), /*#__PURE__*/React.createElement(DiscountKeyboardBase, keyboardProps)) : null;
|
399
|
+
}
|
400
|
+
return /*#__PURE__*/React.createElement(DiscountKeyboardBase, keyboardProps);
|
401
|
+
};
|
402
|
+
// 基于 DiscountKeyboard 的输入框组件
|
403
|
+
var DiscountKeyboardInputNumber = function DiscountKeyboardInputNumber(props) {
|
404
|
+
var _keyboardProps$contai;
|
405
|
+
var originalValue = props.originalValue,
|
406
|
+
value = props.value,
|
407
|
+
onChange = props.onChange,
|
408
|
+
keyboardProps = props.keyboardProps,
|
409
|
+
rest = _objectWithoutProperties(props, _excluded3);
|
410
|
+
var _useControllableValue = useControllableValue(props),
|
411
|
+
_useControllableValue2 = _slicedToArray(_useControllableValue, 2),
|
412
|
+
internalValue = _useControllableValue2[0],
|
413
|
+
setInternalValue = _useControllableValue2[1];
|
414
|
+
var _useState11 = useState(false),
|
415
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
416
|
+
isOpen = _useState12[0],
|
417
|
+
setIsOpen = _useState12[1];
|
418
|
+
var renderType = (keyboardProps === null || keyboardProps === void 0 || (_keyboardProps$contai = keyboardProps.containerProps) === null || _keyboardProps$contai === void 0 ? void 0 : _keyboardProps$contai.renderType) || 'popover';
|
419
|
+
if (renderType === 'modal') {
|
420
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(InputNumber, _extends({
|
421
|
+
value: value,
|
422
|
+
readOnly: true
|
423
|
+
}, rest, {
|
424
|
+
onClick: function onClick() {
|
425
|
+
return setIsOpen(true);
|
426
|
+
}
|
427
|
+
})), /*#__PURE__*/React.createElement(DiscountKeyboard, _extends({}, keyboardProps || {}, {
|
428
|
+
containerProps: _objectSpread(_objectSpread({}, keyboardProps === null || keyboardProps === void 0 ? void 0 : keyboardProps.containerProps), {}, {
|
429
|
+
open: isOpen,
|
430
|
+
onCancel: function onCancel() {
|
431
|
+
return setIsOpen(false);
|
432
|
+
},
|
433
|
+
renderType: 'modal'
|
434
|
+
}),
|
435
|
+
enableExceedMaxAmount: true,
|
436
|
+
defaultValue: internalValue,
|
437
|
+
onEnter: function onEnter(val) {
|
438
|
+
setInternalValue(new Decimal(originalValue).minus(Number(val)).toNumber());
|
439
|
+
setIsOpen(false);
|
440
|
+
},
|
441
|
+
originalValue: originalValue
|
442
|
+
})));
|
443
|
+
}
|
444
|
+
return /*#__PURE__*/React.createElement(DiscountKeyboard, _extends({}, keyboardProps || {}, {
|
445
|
+
containerProps: _objectSpread(_objectSpread({}, keyboardProps === null || keyboardProps === void 0 ? void 0 : keyboardProps.containerProps), {}, {
|
446
|
+
open: isOpen,
|
447
|
+
onOpenChange: function onOpenChange(val) {
|
448
|
+
return setIsOpen(val);
|
449
|
+
},
|
450
|
+
renderType: 'popover'
|
451
|
+
}),
|
452
|
+
enableExceedMaxAmount: true,
|
453
|
+
defaultValue: internalValue,
|
454
|
+
onEnter: function onEnter(val) {
|
455
|
+
setInternalValue(new Decimal(originalValue).minus(Number(val)).toNumber());
|
456
|
+
setIsOpen(false);
|
457
|
+
},
|
458
|
+
originalValue: originalValue
|
459
|
+
}), /*#__PURE__*/React.createElement(InputNumber, _extends({
|
460
|
+
value: value,
|
461
|
+
readOnly: true
|
462
|
+
}, rest)));
|
463
|
+
};
|
464
|
+
DiscountKeyboard.InputNumber = DiscountKeyboardInputNumber;
|
465
|
+
export default DiscountKeyboard;
|
@@ -0,0 +1,47 @@
|
|
1
|
+
.pisell-pro-price-keyboard-discount {
|
2
|
+
width: 360px;
|
3
|
+
border-radius: 10px;
|
4
|
+
padding: 10px;
|
5
|
+
display: flex;
|
6
|
+
flex-direction: column;
|
7
|
+
gap: 10px;
|
8
|
+
background-color: var(--pisell-pro-price-keyboard-bg-color, #ffffff);
|
9
|
+
|
10
|
+
.ellipsis {
|
11
|
+
overflow: hidden;
|
12
|
+
text-overflow: ellipsis;
|
13
|
+
white-space: nowrap;
|
14
|
+
}
|
15
|
+
|
16
|
+
// 复写Segmented样式
|
17
|
+
.pisell-lowcode-segmented {
|
18
|
+
background-color: var(
|
19
|
+
--pisell-pro-price-keyboard-bg-color-gray-200,
|
20
|
+
#eaecf0
|
21
|
+
);
|
22
|
+
color: var(--pisell-pro-price-keyboard-text-gray-500, #667085);
|
23
|
+
}
|
24
|
+
|
25
|
+
.pisell-pro-price-keyboard-content {
|
26
|
+
width: 100%;
|
27
|
+
padding: 10px;
|
28
|
+
border-radius: 10px;
|
29
|
+
display: flex;
|
30
|
+
flex-direction: column;
|
31
|
+
gap: 8px;
|
32
|
+
background-color: var(
|
33
|
+
--pisell-pro-price-keyboard-bg-color-gray-300,
|
34
|
+
#d0d5dd
|
35
|
+
);
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
.pisell-discount-keyboard-modal {
|
40
|
+
.pisell-lowcode-modal-content {
|
41
|
+
background-color: transparent;
|
42
|
+
}
|
43
|
+
|
44
|
+
.pisell-lowcode-modal-close {
|
45
|
+
display: none;
|
46
|
+
}
|
47
|
+
}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
declare const _default: {
|
2
|
+
en: {
|
3
|
+
'discount-keyboard-price-override': string;
|
4
|
+
'discount-keyboard-discount': string;
|
5
|
+
'discount-keyboard-amount': string;
|
6
|
+
'discount-keyboard-percentage': string;
|
7
|
+
'discount-keyboard-max-discount': string;
|
8
|
+
'discount-keyboard-discount-amount': string;
|
9
|
+
'discount-keyboard-total': string;
|
10
|
+
'discount-keyboard-payable': string;
|
11
|
+
'discount-keyboard-reset': string;
|
12
|
+
'discount-keyboard-done': string;
|
13
|
+
'discount-keyboard-pay': string;
|
14
|
+
};
|
15
|
+
'zh-CN': {
|
16
|
+
'discount-keyboard-price-override': string;
|
17
|
+
'discount-keyboard-discount': string;
|
18
|
+
'discount-keyboard-amount': string;
|
19
|
+
'discount-keyboard-percentage': string;
|
20
|
+
'discount-keyboard-max-discount': string;
|
21
|
+
'discount-keyboard-discount-amount': string;
|
22
|
+
'discount-keyboard-total': string;
|
23
|
+
'discount-keyboard-payable': string;
|
24
|
+
'discount-keyboard-reset': string;
|
25
|
+
'discount-keyboard-done': string;
|
26
|
+
'discount-keyboard-pay': string;
|
27
|
+
};
|
28
|
+
'zh-HK': {
|
29
|
+
'discount-keyboard-price-override': string;
|
30
|
+
'discount-keyboard-discount': string;
|
31
|
+
'discount-keyboard-amount': string;
|
32
|
+
'discount-keyboard-percentage': string;
|
33
|
+
'discount-keyboard-max-discount': string;
|
34
|
+
'discount-keyboard-discount-amount': string;
|
35
|
+
'discount-keyboard-total': string;
|
36
|
+
'discount-keyboard-payable': string;
|
37
|
+
'discount-keyboard-reset': string;
|
38
|
+
'discount-keyboard-done': string;
|
39
|
+
'discount-keyboard-pay': string;
|
40
|
+
};
|
41
|
+
};
|
42
|
+
export default _default;
|