@pisell/private-materials 3.0.95 → 3.0.97
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 +8 -8
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +16 -9
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +15 -8
- package/es/components/booking/addons/index.d.ts +1 -1
- package/es/components/booking/addons/model.d.ts +1 -2
- package/es/components/booking/forms/forms.d.ts +1 -1
- package/es/components/booking/forms/index.d.ts +1 -1
- package/es/components/booking/forms/model.d.ts +1 -2
- package/es/components/booking/index.d.ts +1 -1
- package/es/components/booking/info/index.d.ts +1 -1
- package/es/components/booking/info/model.d.ts +1 -2
- package/es/components/booking/model.d.ts +1 -2
- package/es/components/booking/notes/index.d.ts +1 -1
- package/es/components/booking/notes/model.d.ts +1 -2
- package/es/components/booking/payments/index.d.ts +1 -1
- package/es/components/booking/payments/model.d.ts +1 -2
- package/es/components/eftpos/const.d.ts +38 -0
- package/es/components/eftpos/const.js +79 -0
- package/es/components/eftpos/device.d.ts +8 -0
- package/es/components/eftpos/device.js +30 -0
- package/es/components/eftpos/form/index.d.ts +16 -0
- package/es/components/eftpos/form/index.js +113 -0
- package/es/components/eftpos/index.d.ts +37 -0
- package/es/components/eftpos/index.js +274 -0
- package/es/components/eftpos/index.less +153 -0
- package/es/components/eftpos/locales.d.ts +75 -0
- package/es/components/eftpos/locales.js +98 -0
- package/es/components/eftpos/pos.d.ts +9 -0
- package/es/components/eftpos/pos.js +33 -0
- package/es/components/eftpos/surcharge/index.css +17 -0
- package/es/components/eftpos/surcharge/index.d.ts +8 -0
- package/es/components/eftpos/surcharge/index.js +111 -0
- package/es/components/eftpos/table.d.ts +17 -0
- package/es/components/eftpos/table.js +236 -0
- package/es/components/eftposPay/amount.d.ts +14 -0
- package/es/components/eftposPay/amount.js +253 -0
- package/es/components/eftposPay/component/alert/index.d.ts +6 -0
- package/es/components/eftposPay/component/alert/index.js +11 -0
- package/es/components/eftposPay/component/alert/index.less +29 -0
- package/es/components/eftposPay/component/alert/warn.d.ts +3 -0
- package/es/components/eftposPay/component/alert/warn.js +45 -0
- package/es/components/eftposPay/component/fail/failCustom.d.ts +4 -0
- package/es/components/eftposPay/component/fail/failCustom.js +95 -0
- package/es/components/eftposPay/component/fail/index.d.ts +4 -0
- package/es/components/eftposPay/component/fail/index.js +105 -0
- package/es/components/eftposPay/component/fail/network.d.ts +4 -0
- package/es/components/eftposPay/component/fail/network.js +48 -0
- package/es/components/eftposPay/component/fail/unknow.d.ts +4 -0
- package/es/components/eftposPay/component/fail/unknow.js +43 -0
- package/es/components/eftposPay/component/header/index.d.ts +9 -0
- package/es/components/eftposPay/component/header/index.js +66 -0
- package/es/components/eftposPay/component/header/index.less +44 -0
- package/es/components/eftposPay/component/header/titlebar.d.ts +13 -0
- package/es/components/eftposPay/component/header/titlebar.js +39 -0
- package/es/components/eftposPay/component/header/titlebar.less +17 -0
- package/es/components/eftposPay/component/manual/index.d.ts +5 -0
- package/es/components/eftposPay/component/manual/index.js +91 -0
- package/es/components/eftposPay/component/manual/index.less +96 -0
- package/es/components/eftposPay/component/signature/index.d.ts +4 -0
- package/es/components/eftposPay/component/signature/index.js +63 -0
- package/es/components/eftposPay/component/step/index.d.ts +12 -0
- package/es/components/eftposPay/component/step/index.js +31 -0
- package/es/components/eftposPay/component/step/step.d.ts +9 -0
- package/es/components/eftposPay/component/step/step.js +23 -0
- package/es/components/eftposPay/const.d.ts +131 -0
- package/es/components/eftposPay/const.js +48 -0
- package/es/components/eftposPay/device.d.ts +14 -0
- package/es/components/eftposPay/device.js +124 -0
- package/es/components/eftposPay/device.less +61 -0
- package/es/components/eftposPay/eftpos/config.d.ts +11 -0
- package/es/components/eftposPay/eftpos/config.js +178 -0
- package/es/components/eftposPay/eftpos/const.d.ts +10 -0
- package/es/components/eftposPay/eftpos/const.js +139 -0
- package/es/components/eftposPay/eftpos/index.d.ts +7 -0
- package/es/components/eftposPay/eftpos/index.js +35 -0
- package/es/components/eftposPay/helper.d.ts +3 -0
- package/es/components/eftposPay/helper.js +35 -0
- package/es/components/eftposPay/hooks.d.ts +4 -0
- package/es/components/eftposPay/hooks.js +153 -0
- package/es/components/eftposPay/index.d.ts +7 -0
- package/es/components/eftposPay/index.js +188 -0
- package/es/components/eftposPay/index.less +273 -0
- package/es/components/eftposPay/locales.d.ts +264 -0
- package/es/components/eftposPay/locales.js +384 -0
- package/es/components/eftposPay/manufacturer.d.ts +6 -0
- package/es/components/eftposPay/manufacturer.js +32 -0
- package/es/components/eftposPay/pay.d.ts +10 -0
- package/es/components/eftposPay/pay.js +108 -0
- package/es/components/eftposPay/payo/config.d.ts +11 -0
- package/es/components/eftposPay/payo/config.js +357 -0
- package/es/components/eftposPay/payo/const.d.ts +6 -0
- package/es/components/eftposPay/payo/const.js +93 -0
- package/es/components/eftposPay/payo/hooks.d.ts +5 -0
- package/es/components/eftposPay/payo/hooks.js +84 -0
- package/es/components/eftposPay/payo/index.d.ts +7 -0
- package/es/components/eftposPay/payo/index.js +35 -0
- package/es/components/eftposPay/store/index.d.ts +239 -0
- package/es/components/eftposPay/store/index.js +304 -0
- package/es/components/eftposPay/store/useThunkReducer.d.ts +9 -0
- package/es/components/eftposPay/store/useThunkReducer.js +31 -0
- package/es/components/eftposPay/windcave/action.d.ts +8 -0
- package/es/components/eftposPay/windcave/action.js +104 -0
- package/es/components/eftposPay/windcave/const.d.ts +104 -0
- package/es/components/eftposPay/windcave/const.js +253 -0
- package/es/components/eftposPay/windcave/helper.d.ts +9 -0
- package/es/components/eftposPay/windcave/helper.js +314 -0
- package/es/components/eftposPay/windcave/hook.d.ts +14 -0
- package/es/components/eftposPay/windcave/hook.js +144 -0
- package/es/components/eftposPay/windcave/index.d.ts +8 -0
- package/es/components/eftposPay/windcave/index.js +49 -0
- package/es/components/eftposPay/windcave/pos.d.ts +8 -0
- package/es/components/eftposPay/windcave/pos.js +180 -0
- package/es/components/eftposPay/windcave/pwd.d.ts +8 -0
- package/es/components/eftposPay/windcave/pwd.js +124 -0
- package/es/components/eftposPay/windcave/receipet.d.ts +6 -0
- package/es/components/eftposPay/windcave/receipet.js +67 -0
- package/es/components/eftposPay/windcave/receiptAction.d.ts +11 -0
- package/es/components/eftposPay/windcave/receiptAction.js +326 -0
- package/es/components/eftposPay/windcave/timer.d.ts +17 -0
- package/es/components/eftposPay/windcave/timer.js +181 -0
- package/es/components/eftposPay/windcave/wait.d.ts +12 -0
- package/es/components/eftposPay/windcave/wait.js +139 -0
- package/es/components/eftposPay/windcave/windcave.d.ts +6 -0
- package/es/components/eftposPay/windcave/windcave.js +283 -0
- package/es/components/schedules/index.d.ts +1 -1
- package/es/components/schedules/model.d.ts +1 -2
- package/es/hooks/usePrefix.d.ts +1 -0
- package/es/hooks/usePrefix.js +10 -0
- package/es/index.d.ts +2 -0
- package/es/index.js +3 -1
- package/lib/components/booking/addons/index.d.ts +1 -1
- package/lib/components/booking/addons/model.d.ts +1 -2
- package/lib/components/booking/forms/forms.d.ts +1 -1
- package/lib/components/booking/forms/index.d.ts +1 -1
- package/lib/components/booking/forms/model.d.ts +1 -2
- package/lib/components/booking/index.d.ts +1 -1
- package/lib/components/booking/info/index.d.ts +1 -1
- package/lib/components/booking/info/model.d.ts +1 -2
- package/lib/components/booking/model.d.ts +1 -2
- package/lib/components/booking/notes/index.d.ts +1 -1
- package/lib/components/booking/notes/model.d.ts +1 -2
- package/lib/components/booking/payments/index.d.ts +1 -1
- package/lib/components/booking/payments/model.d.ts +1 -2
- package/lib/components/eftpos/const.d.ts +38 -0
- package/lib/components/eftpos/const.js +108 -0
- package/lib/components/eftpos/device.d.ts +8 -0
- package/lib/components/eftpos/device.js +55 -0
- package/lib/components/eftpos/form/index.d.ts +16 -0
- package/lib/components/eftpos/form/index.js +124 -0
- package/lib/components/eftpos/index.d.ts +37 -0
- package/lib/components/eftpos/index.js +279 -0
- package/lib/components/eftpos/index.less +153 -0
- package/lib/components/eftpos/locales.d.ts +75 -0
- package/lib/components/eftpos/locales.js +116 -0
- package/lib/components/eftpos/pos.d.ts +9 -0
- package/lib/components/eftpos/pos.js +55 -0
- package/lib/components/eftpos/surcharge/index.css +17 -0
- package/lib/components/eftpos/surcharge/index.d.ts +8 -0
- package/lib/components/eftpos/surcharge/index.js +125 -0
- package/lib/components/eftpos/table.d.ts +17 -0
- package/lib/components/eftpos/table.js +235 -0
- package/lib/components/eftposPay/amount.d.ts +14 -0
- package/lib/components/eftposPay/amount.js +239 -0
- package/lib/components/eftposPay/component/alert/index.d.ts +6 -0
- package/lib/components/eftposPay/component/alert/index.js +38 -0
- package/lib/components/eftposPay/component/alert/index.less +29 -0
- package/lib/components/eftposPay/component/alert/warn.d.ts +3 -0
- package/lib/components/eftposPay/component/alert/warn.js +80 -0
- package/lib/components/eftposPay/component/fail/failCustom.d.ts +4 -0
- package/lib/components/eftposPay/component/fail/failCustom.js +117 -0
- package/lib/components/eftposPay/component/fail/index.d.ts +4 -0
- package/lib/components/eftposPay/component/fail/index.js +121 -0
- package/lib/components/eftposPay/component/fail/network.d.ts +4 -0
- package/lib/components/eftposPay/component/fail/network.js +65 -0
- package/lib/components/eftposPay/component/fail/unknow.d.ts +4 -0
- package/lib/components/eftposPay/component/fail/unknow.js +72 -0
- package/lib/components/eftposPay/component/header/index.d.ts +9 -0
- package/lib/components/eftposPay/component/header/index.js +92 -0
- package/lib/components/eftposPay/component/header/index.less +44 -0
- package/lib/components/eftposPay/component/header/titlebar.d.ts +13 -0
- package/lib/components/eftposPay/component/header/titlebar.js +55 -0
- package/lib/components/eftposPay/component/header/titlebar.less +17 -0
- package/lib/components/eftposPay/component/manual/index.d.ts +5 -0
- package/lib/components/eftposPay/component/manual/index.js +101 -0
- package/lib/components/eftposPay/component/manual/index.less +96 -0
- package/lib/components/eftposPay/component/signature/index.d.ts +4 -0
- package/lib/components/eftposPay/component/signature/index.js +80 -0
- package/lib/components/eftposPay/component/step/index.d.ts +12 -0
- package/lib/components/eftposPay/component/step/index.js +71 -0
- package/lib/components/eftposPay/component/step/step.d.ts +9 -0
- package/lib/components/eftposPay/component/step/step.js +59 -0
- package/lib/components/eftposPay/const.d.ts +131 -0
- package/lib/components/eftposPay/const.js +86 -0
- package/lib/components/eftposPay/device.d.ts +14 -0
- package/lib/components/eftposPay/device.js +127 -0
- package/lib/components/eftposPay/device.less +61 -0
- package/lib/components/eftposPay/eftpos/config.d.ts +11 -0
- package/lib/components/eftposPay/eftpos/config.js +199 -0
- package/lib/components/eftposPay/eftpos/const.d.ts +10 -0
- package/lib/components/eftposPay/eftpos/const.js +165 -0
- package/lib/components/eftposPay/eftpos/index.d.ts +7 -0
- package/lib/components/eftposPay/eftpos/index.js +66 -0
- package/lib/components/eftposPay/helper.d.ts +3 -0
- package/lib/components/eftposPay/helper.js +62 -0
- package/lib/components/eftposPay/hooks.d.ts +4 -0
- package/lib/components/eftposPay/hooks.js +237 -0
- package/lib/components/eftposPay/index.d.ts +7 -0
- package/lib/components/eftposPay/index.js +189 -0
- package/lib/components/eftposPay/index.less +273 -0
- package/lib/components/eftposPay/locales.d.ts +264 -0
- package/lib/components/eftposPay/locales.js +304 -0
- package/lib/components/eftposPay/manufacturer.d.ts +6 -0
- package/lib/components/eftposPay/manufacturer.js +77 -0
- package/lib/components/eftposPay/pay.d.ts +10 -0
- package/lib/components/eftposPay/pay.js +120 -0
- package/lib/components/eftposPay/payo/config.d.ts +11 -0
- package/lib/components/eftposPay/payo/config.js +377 -0
- package/lib/components/eftposPay/payo/const.d.ts +6 -0
- package/lib/components/eftposPay/payo/const.js +112 -0
- package/lib/components/eftposPay/payo/hooks.d.ts +5 -0
- package/lib/components/eftposPay/payo/hooks.js +80 -0
- package/lib/components/eftposPay/payo/index.d.ts +7 -0
- package/lib/components/eftposPay/payo/index.js +63 -0
- package/lib/components/eftposPay/store/index.d.ts +239 -0
- package/lib/components/eftposPay/store/index.js +371 -0
- package/lib/components/eftposPay/store/useThunkReducer.d.ts +9 -0
- package/lib/components/eftposPay/store/useThunkReducer.js +53 -0
- package/lib/components/eftposPay/windcave/action.d.ts +8 -0
- package/lib/components/eftposPay/windcave/action.js +143 -0
- package/lib/components/eftposPay/windcave/const.d.ts +104 -0
- package/lib/components/eftposPay/windcave/const.js +300 -0
- package/lib/components/eftposPay/windcave/helper.d.ts +9 -0
- package/lib/components/eftposPay/windcave/helper.js +378 -0
- package/lib/components/eftposPay/windcave/hook.d.ts +14 -0
- package/lib/components/eftposPay/windcave/hook.js +139 -0
- package/lib/components/eftposPay/windcave/index.d.ts +8 -0
- package/lib/components/eftposPay/windcave/index.js +78 -0
- package/lib/components/eftposPay/windcave/pos.d.ts +8 -0
- package/lib/components/eftposPay/windcave/pos.js +197 -0
- package/lib/components/eftposPay/windcave/pwd.d.ts +8 -0
- package/lib/components/eftposPay/windcave/pwd.js +143 -0
- package/lib/components/eftposPay/windcave/receipet.d.ts +6 -0
- package/lib/components/eftposPay/windcave/receipet.js +93 -0
- package/lib/components/eftposPay/windcave/receiptAction.d.ts +11 -0
- package/lib/components/eftposPay/windcave/receiptAction.js +386 -0
- package/lib/components/eftposPay/windcave/timer.d.ts +17 -0
- package/lib/components/eftposPay/windcave/timer.js +126 -0
- package/lib/components/eftposPay/windcave/wait.d.ts +12 -0
- package/lib/components/eftposPay/windcave/wait.js +163 -0
- package/lib/components/eftposPay/windcave/windcave.d.ts +6 -0
- package/lib/components/eftposPay/windcave/windcave.js +283 -0
- package/lib/components/schedules/index.d.ts +1 -1
- package/lib/components/schedules/model.d.ts +1 -2
- package/lib/hooks/usePrefix.d.ts +1 -0
- package/lib/hooks/usePrefix.js +44 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +6 -0
- package/lowcode/eftpos/meta.ts +187 -0
- package/lowcode/eftpos-pay/meta.ts +122 -0
- package/package.json +4 -3
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { DeviceStatusType, StatusType, ModeType } from '../const';
|
|
3
|
+
import { ThunkDispatch } from './useThunkReducer';
|
|
4
|
+
export declare enum EActionTypes {
|
|
5
|
+
UPDATE_INIT = "UPDATE_INIT",
|
|
6
|
+
UPDATE_CUSTOM = "UPDATE_CUSTOM",
|
|
7
|
+
UPDATE_KEY = "UPDATE_KEY",
|
|
8
|
+
UPDATE_STEP = "UPDATE_STEP",
|
|
9
|
+
UPDATE_STEP_KEY = "UPDATE_STEP_KEY",
|
|
10
|
+
UPDATE_DEVICE = "UPDATE_DEVICE",
|
|
11
|
+
UPDATE_NEXT_STEP = "UPDATE_NEXT_STEP",
|
|
12
|
+
UPDATE_STATUS = "UPDATE_STATUS",
|
|
13
|
+
UPDATE_TITLE = "UPDATE_TITLE",
|
|
14
|
+
UPDATE_LOADING = "UPDATE_LOADING",
|
|
15
|
+
UPDATE_COMPONENT = "UPDATE_COMPONENT",
|
|
16
|
+
UPDATE_STEPS = "UPDATE_STEPS",
|
|
17
|
+
UPDATE_WARN = "UPDATE_WARN",
|
|
18
|
+
UPDATE_STEP_CURRENT_ITEM_CUSTOM = "UPDATE_STEP_CURRENT_ITEM_CUSTOM",
|
|
19
|
+
UPDATE_STEP_ITEM_CUSTOM = "UPDATE_STEP_ITEM_CUSTOM",
|
|
20
|
+
UPDATE_STEP_ITEM = "UPDATE_STEP_ITEM",
|
|
21
|
+
BACKUP_PRODUCTION = "BACKUP_PRODUCTION",
|
|
22
|
+
BACKUP_FREE = "BACKUP_FREE"
|
|
23
|
+
}
|
|
24
|
+
export declare type State = {
|
|
25
|
+
mode: ModeType;
|
|
26
|
+
/** 厂商 */
|
|
27
|
+
eftpos: DeviceStatusType;
|
|
28
|
+
/** 用于重置页面特指 =》全部步骤 */
|
|
29
|
+
key: number;
|
|
30
|
+
/** 当前执行到哪一步了 */
|
|
31
|
+
step: number;
|
|
32
|
+
/** 标题 */
|
|
33
|
+
title: string;
|
|
34
|
+
/** step : 常规步骤页面 ,unset 自定义页面 */
|
|
35
|
+
type: 'step' | 'unset';
|
|
36
|
+
render: boolean;
|
|
37
|
+
/** 上面 unset 自定义页面,这里需要指定到具体页面 */
|
|
38
|
+
component: string;
|
|
39
|
+
lastComponent?: string;
|
|
40
|
+
/** 页面状态 */
|
|
41
|
+
status: StatusType;
|
|
42
|
+
/** 警告文案 */
|
|
43
|
+
warn: ReactNode;
|
|
44
|
+
steps: {
|
|
45
|
+
/** 用于重置当前步骤 */
|
|
46
|
+
key: number;
|
|
47
|
+
title?: ReactNode;
|
|
48
|
+
text?: ReactNode;
|
|
49
|
+
warn?: ReactNode;
|
|
50
|
+
tip?: ReactNode;
|
|
51
|
+
success?: ReactNode;
|
|
52
|
+
fail?: ReactNode;
|
|
53
|
+
loading?: ReactNode;
|
|
54
|
+
/** 步骤状态 */
|
|
55
|
+
status: StatusType;
|
|
56
|
+
custom?: {
|
|
57
|
+
/** 厂商自定义 */
|
|
58
|
+
[key: string]: unknown;
|
|
59
|
+
};
|
|
60
|
+
}[];
|
|
61
|
+
device?: {
|
|
62
|
+
[key: string]: unknown;
|
|
63
|
+
};
|
|
64
|
+
custom?: {
|
|
65
|
+
[key: string]: unknown;
|
|
66
|
+
};
|
|
67
|
+
manual?: {
|
|
68
|
+
title: string;
|
|
69
|
+
text: string;
|
|
70
|
+
};
|
|
71
|
+
backup?: Omit<State, 'backup'>;
|
|
72
|
+
};
|
|
73
|
+
export declare type Action = {
|
|
74
|
+
type: EActionTypes;
|
|
75
|
+
payload: Partial<State>;
|
|
76
|
+
};
|
|
77
|
+
export declare const updateKey: (key: number) => {
|
|
78
|
+
type: EActionTypes;
|
|
79
|
+
payload: {
|
|
80
|
+
key: number;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
export declare const updateDevice: (payload: {
|
|
84
|
+
device: State['device'];
|
|
85
|
+
}) => {
|
|
86
|
+
type: EActionTypes;
|
|
87
|
+
payload: {
|
|
88
|
+
device: State['device'];
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
export declare const updateStepKey: () => {
|
|
92
|
+
type: EActionTypes;
|
|
93
|
+
payload: {};
|
|
94
|
+
};
|
|
95
|
+
export declare const updateNextStep: (warn?: string) => {
|
|
96
|
+
type: EActionTypes;
|
|
97
|
+
payload: {
|
|
98
|
+
warn: string;
|
|
99
|
+
} | {
|
|
100
|
+
warn?: undefined;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
export declare const updateStep: (payload: {
|
|
104
|
+
step: number;
|
|
105
|
+
warn?: ReactNode;
|
|
106
|
+
}) => {
|
|
107
|
+
type: EActionTypes;
|
|
108
|
+
payload: {
|
|
109
|
+
step: number;
|
|
110
|
+
warn?: ReactNode;
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
export declare const updateCustom: (payload: {
|
|
114
|
+
[key: string]: unknown;
|
|
115
|
+
}) => {
|
|
116
|
+
type: EActionTypes;
|
|
117
|
+
payload: {
|
|
118
|
+
[key: string]: unknown;
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
export declare const updateStatus: (status: 'loading' | 'warn' | 'fail' | 'success' | 'question') => {
|
|
122
|
+
type: EActionTypes;
|
|
123
|
+
payload: {
|
|
124
|
+
status: "loading" | "success" | "warn" | "fail" | "question";
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
export declare const updateWarn: (warn: ReactNode) => {
|
|
128
|
+
type: EActionTypes;
|
|
129
|
+
payload: {
|
|
130
|
+
warn: React.ReactNode;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
export declare const updateComponent: (component: string, render?: boolean) => {
|
|
134
|
+
type: EActionTypes;
|
|
135
|
+
payload: {
|
|
136
|
+
readonly component: string;
|
|
137
|
+
readonly type: "unset";
|
|
138
|
+
readonly render: boolean;
|
|
139
|
+
} | {
|
|
140
|
+
readonly type: "step";
|
|
141
|
+
readonly render: boolean;
|
|
142
|
+
readonly component?: undefined;
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
export declare const updateSteps: (steps: State['steps']) => {
|
|
146
|
+
type: EActionTypes;
|
|
147
|
+
payload: {
|
|
148
|
+
steps: {
|
|
149
|
+
/** 用于重置当前步骤 */
|
|
150
|
+
key: number;
|
|
151
|
+
title?: ReactNode;
|
|
152
|
+
text?: ReactNode;
|
|
153
|
+
warn?: ReactNode;
|
|
154
|
+
tip?: ReactNode;
|
|
155
|
+
success?: ReactNode;
|
|
156
|
+
fail?: ReactNode;
|
|
157
|
+
loading?: ReactNode;
|
|
158
|
+
/** 步骤状态 */
|
|
159
|
+
status: StatusType;
|
|
160
|
+
custom?: {
|
|
161
|
+
[key: string]: unknown;
|
|
162
|
+
} | undefined;
|
|
163
|
+
}[];
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
export declare const updateState: (payload: Partial<State>) => {
|
|
167
|
+
type: EActionTypes;
|
|
168
|
+
payload: Partial<State>;
|
|
169
|
+
};
|
|
170
|
+
export declare const updateCurrentCustomStemItem: (payload: NonNullable<Partial<State['steps'][number]['custom']>>) => {
|
|
171
|
+
type: EActionTypes;
|
|
172
|
+
payload: Partial<{
|
|
173
|
+
[key: string]: unknown;
|
|
174
|
+
}>;
|
|
175
|
+
};
|
|
176
|
+
export declare const updateCustomStemItem: (payload: NonNullable<Partial<State['steps'][number]['custom']>>) => {
|
|
177
|
+
type: EActionTypes;
|
|
178
|
+
payload: Partial<{
|
|
179
|
+
[key: string]: unknown;
|
|
180
|
+
}>;
|
|
181
|
+
};
|
|
182
|
+
export declare const updateCurrentStemItem: (payload: any) => {
|
|
183
|
+
type: EActionTypes;
|
|
184
|
+
payload: any;
|
|
185
|
+
};
|
|
186
|
+
export declare const backUpProduction: (payload: Partial<State>) => {
|
|
187
|
+
type: EActionTypes;
|
|
188
|
+
payload: Partial<State>;
|
|
189
|
+
};
|
|
190
|
+
export declare const backUpFree: (payload: Partial<State>) => {
|
|
191
|
+
type: EActionTypes;
|
|
192
|
+
payload: {
|
|
193
|
+
mode?: "refund" | "pay" | "query" | undefined;
|
|
194
|
+
eftpos?: "payo" | "tyro" | "windcave" | "stripe" | "eftpos" | undefined;
|
|
195
|
+
key?: number | undefined;
|
|
196
|
+
step?: number | undefined;
|
|
197
|
+
title?: string | undefined;
|
|
198
|
+
type?: "unset" | "step" | undefined;
|
|
199
|
+
render?: boolean | undefined;
|
|
200
|
+
component?: string | undefined;
|
|
201
|
+
lastComponent?: string | undefined;
|
|
202
|
+
status?: "loading" | "success" | "warn" | "fail" | "pedding" | "resove" | "reject" | "question" | undefined;
|
|
203
|
+
warn?: ReactNode;
|
|
204
|
+
steps?: {
|
|
205
|
+
/** 用于重置当前步骤 */
|
|
206
|
+
key: number;
|
|
207
|
+
title?: ReactNode;
|
|
208
|
+
text?: ReactNode;
|
|
209
|
+
warn?: ReactNode;
|
|
210
|
+
tip?: ReactNode;
|
|
211
|
+
success?: ReactNode;
|
|
212
|
+
fail?: ReactNode;
|
|
213
|
+
loading?: ReactNode;
|
|
214
|
+
/** 步骤状态 */
|
|
215
|
+
status: StatusType;
|
|
216
|
+
custom?: {
|
|
217
|
+
[key: string]: unknown;
|
|
218
|
+
} | undefined;
|
|
219
|
+
}[] | undefined;
|
|
220
|
+
device?: {
|
|
221
|
+
[key: string]: unknown;
|
|
222
|
+
} | undefined;
|
|
223
|
+
custom?: {
|
|
224
|
+
[key: string]: unknown;
|
|
225
|
+
} | undefined;
|
|
226
|
+
manual?: {
|
|
227
|
+
title: string;
|
|
228
|
+
text: string;
|
|
229
|
+
} | undefined;
|
|
230
|
+
backup?: Omit<State, "backup"> | undefined;
|
|
231
|
+
};
|
|
232
|
+
};
|
|
233
|
+
export declare function reducers(state: State, action: Action): State;
|
|
234
|
+
export declare const Provider: ({ children, state: providerState, }: {
|
|
235
|
+
children: ReactNode;
|
|
236
|
+
state?: State | undefined;
|
|
237
|
+
}) => React.JSX.Element;
|
|
238
|
+
export declare function useContextData(): State;
|
|
239
|
+
export declare function useDispatch(): ThunkDispatch<State, Action>;
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
3
|
+
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."); }
|
|
4
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
5
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
6
|
+
function _objectDestructuringEmpty(obj) { if (obj == null) throw new TypeError("Cannot destructure " + obj); }
|
|
7
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
8
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
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); }
|
|
10
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
11
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
12
|
+
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; }
|
|
13
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
14
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15
|
+
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; }
|
|
16
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
17
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
18
|
+
/* eslint-disable no-case-declarations */
|
|
19
|
+
import React, { createContext, useContext } from 'react';
|
|
20
|
+
import { StatusEnum, ModeEnum, PayRouteEnum } from "../const";
|
|
21
|
+
import { cloneDeep } from "../helper";
|
|
22
|
+
import useThunkReducer from "./useThunkReducer";
|
|
23
|
+
export var EActionTypes;
|
|
24
|
+
(function (EActionTypes) {
|
|
25
|
+
EActionTypes["UPDATE_INIT"] = "UPDATE_INIT";
|
|
26
|
+
EActionTypes["UPDATE_CUSTOM"] = "UPDATE_CUSTOM";
|
|
27
|
+
EActionTypes["UPDATE_KEY"] = "UPDATE_KEY";
|
|
28
|
+
EActionTypes["UPDATE_STEP"] = "UPDATE_STEP";
|
|
29
|
+
EActionTypes["UPDATE_STEP_KEY"] = "UPDATE_STEP_KEY";
|
|
30
|
+
EActionTypes["UPDATE_DEVICE"] = "UPDATE_DEVICE";
|
|
31
|
+
EActionTypes["UPDATE_NEXT_STEP"] = "UPDATE_NEXT_STEP";
|
|
32
|
+
EActionTypes["UPDATE_STATUS"] = "UPDATE_STATUS";
|
|
33
|
+
EActionTypes["UPDATE_TITLE"] = "UPDATE_TITLE";
|
|
34
|
+
EActionTypes["UPDATE_LOADING"] = "UPDATE_LOADING";
|
|
35
|
+
EActionTypes["UPDATE_COMPONENT"] = "UPDATE_COMPONENT";
|
|
36
|
+
EActionTypes["UPDATE_STEPS"] = "UPDATE_STEPS";
|
|
37
|
+
EActionTypes["UPDATE_WARN"] = "UPDATE_WARN";
|
|
38
|
+
EActionTypes["UPDATE_STEP_CURRENT_ITEM_CUSTOM"] = "UPDATE_STEP_CURRENT_ITEM_CUSTOM";
|
|
39
|
+
EActionTypes["UPDATE_STEP_ITEM_CUSTOM"] = "UPDATE_STEP_ITEM_CUSTOM";
|
|
40
|
+
EActionTypes["UPDATE_STEP_ITEM"] = "UPDATE_STEP_ITEM";
|
|
41
|
+
EActionTypes["BACKUP_PRODUCTION"] = "BACKUP_PRODUCTION";
|
|
42
|
+
EActionTypes["BACKUP_FREE"] = "BACKUP_FREE";
|
|
43
|
+
})(EActionTypes || (EActionTypes = {}));
|
|
44
|
+
export var updateKey = function updateKey(key) {
|
|
45
|
+
return {
|
|
46
|
+
type: EActionTypes.UPDATE_KEY,
|
|
47
|
+
payload: {
|
|
48
|
+
key: key
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
export var updateDevice = function updateDevice(payload) {
|
|
53
|
+
return {
|
|
54
|
+
type: EActionTypes.UPDATE_DEVICE,
|
|
55
|
+
payload: payload
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
export var updateStepKey = function updateStepKey() {
|
|
59
|
+
return {
|
|
60
|
+
type: EActionTypes.UPDATE_STEP_KEY,
|
|
61
|
+
payload: {}
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
export var updateNextStep = function updateNextStep(warn) {
|
|
65
|
+
return {
|
|
66
|
+
type: EActionTypes.UPDATE_NEXT_STEP,
|
|
67
|
+
payload: warn ? {
|
|
68
|
+
warn: warn
|
|
69
|
+
} : {}
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
export var updateStep = function updateStep(payload) {
|
|
73
|
+
return {
|
|
74
|
+
type: EActionTypes.UPDATE_STEP,
|
|
75
|
+
payload: payload
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
export var updateCustom = function updateCustom(payload) {
|
|
79
|
+
return {
|
|
80
|
+
type: EActionTypes.UPDATE_CUSTOM,
|
|
81
|
+
payload: payload
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
export var updateStatus = function updateStatus(status) {
|
|
85
|
+
return {
|
|
86
|
+
type: EActionTypes.UPDATE_LOADING,
|
|
87
|
+
payload: {
|
|
88
|
+
status: status
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
export var updateWarn = function updateWarn(warn) {
|
|
93
|
+
return {
|
|
94
|
+
type: EActionTypes.UPDATE_WARN,
|
|
95
|
+
payload: {
|
|
96
|
+
warn: warn
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
export var updateComponent = function updateComponent(component, render) {
|
|
101
|
+
return {
|
|
102
|
+
type: EActionTypes.UPDATE_COMPONENT,
|
|
103
|
+
payload: component ? {
|
|
104
|
+
component: component,
|
|
105
|
+
type: 'unset',
|
|
106
|
+
render: typeof render === 'boolean' ? render : false
|
|
107
|
+
} : {
|
|
108
|
+
type: 'step',
|
|
109
|
+
render: typeof render === 'boolean' ? render : true
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
export var updateSteps = function updateSteps(steps) {
|
|
114
|
+
return {
|
|
115
|
+
type: EActionTypes.UPDATE_STEPS,
|
|
116
|
+
payload: {
|
|
117
|
+
steps: steps
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
export var updateState = function updateState(payload) {
|
|
122
|
+
return {
|
|
123
|
+
type: EActionTypes.UPDATE_INIT,
|
|
124
|
+
payload: payload
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
export var updateCurrentCustomStemItem = function updateCurrentCustomStemItem(payload) {
|
|
128
|
+
return {
|
|
129
|
+
type: EActionTypes.UPDATE_STEP_CURRENT_ITEM_CUSTOM,
|
|
130
|
+
payload: payload
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
export var updateCustomStemItem = function updateCustomStemItem(payload) {
|
|
134
|
+
return {
|
|
135
|
+
type: EActionTypes.UPDATE_STEP_ITEM_CUSTOM,
|
|
136
|
+
payload: payload
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
export var updateCurrentStemItem = function updateCurrentStemItem(payload) {
|
|
140
|
+
return {
|
|
141
|
+
type: EActionTypes.UPDATE_STEP_ITEM,
|
|
142
|
+
payload: payload
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
export var backUpProduction = function backUpProduction(payload) {
|
|
146
|
+
return {
|
|
147
|
+
type: EActionTypes.BACKUP_PRODUCTION,
|
|
148
|
+
payload: payload
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
export var backUpFree = function backUpFree(payload) {
|
|
152
|
+
return {
|
|
153
|
+
type: EActionTypes.BACKUP_FREE,
|
|
154
|
+
payload: _objectSpread({}, payload)
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
var initialState = {
|
|
158
|
+
mode: ModeEnum.Pay,
|
|
159
|
+
eftpos: '',
|
|
160
|
+
key: 0,
|
|
161
|
+
step: 0,
|
|
162
|
+
type: PayRouteEnum.Step,
|
|
163
|
+
title: 'Processing ...',
|
|
164
|
+
component: '',
|
|
165
|
+
status: StatusEnum.Loading,
|
|
166
|
+
steps: [],
|
|
167
|
+
warn: '',
|
|
168
|
+
render: true
|
|
169
|
+
};
|
|
170
|
+
var StateContext = /*#__PURE__*/createContext(undefined);
|
|
171
|
+
var DispatchContext = /*#__PURE__*/createContext(undefined);
|
|
172
|
+
export function reducers(state, action) {
|
|
173
|
+
switch (action.type) {
|
|
174
|
+
case EActionTypes.UPDATE_INIT:
|
|
175
|
+
return _objectSpread(_objectSpread({}, state), action.payload);
|
|
176
|
+
case EActionTypes.UPDATE_NEXT_STEP:
|
|
177
|
+
// eslint-disable-next-line no-case-declarations
|
|
178
|
+
var currentStep = state.step + 1;
|
|
179
|
+
if (state.step === state.steps.length - 1) {
|
|
180
|
+
state.steps[state.steps.length - 1].status = 'success';
|
|
181
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
182
|
+
status: 'success',
|
|
183
|
+
steps: _toConsumableArray(state.steps)
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
state.steps[state.step].status = 'success';
|
|
187
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
188
|
+
warn: action.payload.warn || '',
|
|
189
|
+
steps: _toConsumableArray(state.steps),
|
|
190
|
+
status: state.steps[currentStep].status,
|
|
191
|
+
step: currentStep
|
|
192
|
+
});
|
|
193
|
+
case EActionTypes.UPDATE_KEY:
|
|
194
|
+
return _objectSpread(_objectSpread({}, state), action.payload);
|
|
195
|
+
case EActionTypes.UPDATE_STEP:
|
|
196
|
+
if (state.type === 'unset') {
|
|
197
|
+
return state;
|
|
198
|
+
}
|
|
199
|
+
var _ref = action.payload,
|
|
200
|
+
step = _ref.step;
|
|
201
|
+
state.steps.forEach(function (s, index) {
|
|
202
|
+
if (index < step) {
|
|
203
|
+
s.status = 'success';
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
var current = step < state.steps.length - 1 ? step : state.steps.length - 1;
|
|
207
|
+
console.log('current ', current);
|
|
208
|
+
return _objectSpread(_objectSpread({}, state), {
|
|
209
|
+
step: current,
|
|
210
|
+
warn: action.payload.warn || '',
|
|
211
|
+
status: state.steps[current].status,
|
|
212
|
+
steps: _toConsumableArray(state.steps)
|
|
213
|
+
});
|
|
214
|
+
case EActionTypes.UPDATE_LOADING:
|
|
215
|
+
return _objectSpread(_objectSpread({}, state), action.payload);
|
|
216
|
+
case EActionTypes.UPDATE_COMPONENT:
|
|
217
|
+
return _objectSpread(_objectSpread(_objectSpread({}, state), action.payload), {}, {
|
|
218
|
+
lastComponent: state.component
|
|
219
|
+
});
|
|
220
|
+
case EActionTypes.UPDATE_STEPS:
|
|
221
|
+
return _objectSpread(_objectSpread({}, state), action.payload);
|
|
222
|
+
case EActionTypes.UPDATE_STEP_ITEM:
|
|
223
|
+
state.steps[state.step] = _objectSpread(_objectSpread({}, state.steps[state.step]), action.payload);
|
|
224
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
225
|
+
steps: _toConsumableArray(state.steps)
|
|
226
|
+
});
|
|
227
|
+
case EActionTypes.UPDATE_WARN:
|
|
228
|
+
return _objectSpread(_objectSpread({}, state), action.payload);
|
|
229
|
+
case EActionTypes.UPDATE_STEP_CURRENT_ITEM_CUSTOM:
|
|
230
|
+
if (state.steps[state.step].custom) {
|
|
231
|
+
state.steps[state.step].custom = _objectSpread(_objectSpread({}, state.steps[state.step].custom), action.payload);
|
|
232
|
+
} else {
|
|
233
|
+
state.steps[state.step].custom = _objectSpread({}, action.payload);
|
|
234
|
+
}
|
|
235
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
236
|
+
steps: _toConsumableArray(state.steps)
|
|
237
|
+
});
|
|
238
|
+
case EActionTypes.UPDATE_STEP_ITEM_CUSTOM:
|
|
239
|
+
var index = action.payload.step;
|
|
240
|
+
var custom = action.payload.custom;
|
|
241
|
+
if (state.steps[index].custom) {
|
|
242
|
+
state.steps[index].custom = _objectSpread(_objectSpread({}, state.steps[index].custom), custom);
|
|
243
|
+
} else {
|
|
244
|
+
state.steps[index].custom = _objectSpread({}, custom);
|
|
245
|
+
}
|
|
246
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
247
|
+
steps: _toConsumableArray(state.steps)
|
|
248
|
+
});
|
|
249
|
+
case EActionTypes.UPDATE_STEP_KEY:
|
|
250
|
+
state.steps[state.step].key = Date.now();
|
|
251
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
252
|
+
steps: _toConsumableArray(state.steps)
|
|
253
|
+
});
|
|
254
|
+
case EActionTypes.UPDATE_DEVICE:
|
|
255
|
+
return _objectSpread(_objectSpread({}, state), action.payload);
|
|
256
|
+
case EActionTypes.UPDATE_CUSTOM:
|
|
257
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
258
|
+
custom: state.custom ? _objectSpread(_objectSpread({}, state.custom), action.payload) : _objectSpread({}, action.payload)
|
|
259
|
+
// ,
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
case EActionTypes.BACKUP_PRODUCTION:
|
|
263
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
264
|
+
backup: cloneDeep(state)
|
|
265
|
+
});
|
|
266
|
+
case EActionTypes.BACKUP_FREE:
|
|
267
|
+
if (!state.backup) {
|
|
268
|
+
return state;
|
|
269
|
+
}
|
|
270
|
+
var s = Object.assign({}, (_objectDestructuringEmpty(state.backup), state.backup));
|
|
271
|
+
return _objectSpread(_objectSpread({}, s), action.payload);
|
|
272
|
+
default:
|
|
273
|
+
{
|
|
274
|
+
throw new Error("Unhandled action type: ".concat(action.type));
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
export var Provider = function Provider(_ref2) {
|
|
279
|
+
var children = _ref2.children,
|
|
280
|
+
providerState = _ref2.state;
|
|
281
|
+
var _useThunkReducer = useThunkReducer(reducers, providerState || initialState),
|
|
282
|
+
_useThunkReducer2 = _slicedToArray(_useThunkReducer, 2),
|
|
283
|
+
state = _useThunkReducer2[0],
|
|
284
|
+
dispatch = _useThunkReducer2[1];
|
|
285
|
+
return /*#__PURE__*/React.createElement(StateContext.Provider, {
|
|
286
|
+
value: state
|
|
287
|
+
}, /*#__PURE__*/React.createElement(DispatchContext.Provider, {
|
|
288
|
+
value: dispatch
|
|
289
|
+
}, children));
|
|
290
|
+
};
|
|
291
|
+
export function useContextData() {
|
|
292
|
+
var context = useContext(StateContext);
|
|
293
|
+
if (context === undefined) {
|
|
294
|
+
throw new Error('useState must be used within a Provider');
|
|
295
|
+
}
|
|
296
|
+
return context;
|
|
297
|
+
}
|
|
298
|
+
export function useDispatch() {
|
|
299
|
+
var context = useContext(DispatchContext);
|
|
300
|
+
if (context === undefined) {
|
|
301
|
+
throw new Error('useDispatch must be used within a Provider');
|
|
302
|
+
}
|
|
303
|
+
return context;
|
|
304
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Reducer } from 'react';
|
|
2
|
+
export default function useThunkReducer<State, Action extends {
|
|
3
|
+
[P in keyof Action]: Action[P];
|
|
4
|
+
}>(reducer: Reducer<State, Action>, initialArg: State, init?: (s: State) => State): [State, ThunkDispatch<State, Action>];
|
|
5
|
+
export interface ThunkDispatch<State, Action> {
|
|
6
|
+
<TReturnType>(ThunkAction: ThunkAction<TReturnType, State, Action>): TReturnType;
|
|
7
|
+
(action: Action): void;
|
|
8
|
+
}
|
|
9
|
+
export declare type ThunkAction<TReturnType, State, Action> = (dispatch: ThunkDispatch<State, Action>, getState: () => State) => TReturnType;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
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."); }
|
|
3
|
+
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); }
|
|
4
|
+
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; }
|
|
5
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import { useCallback, useRef, useState } from 'react';
|
|
8
|
+
export default function useThunkReducer(reducer, initialArg, init) {
|
|
9
|
+
var _useState = useState(init ? init(initialArg) : initialArg),
|
|
10
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
11
|
+
hookState = _useState2[0],
|
|
12
|
+
setHookState = _useState2[1];
|
|
13
|
+
var state = useRef(hookState);
|
|
14
|
+
var getState = useCallback(function () {
|
|
15
|
+
return state.current;
|
|
16
|
+
}, [state]);
|
|
17
|
+
var setState = useCallback(function (newState) {
|
|
18
|
+
state.current = newState;
|
|
19
|
+
setHookState(newState);
|
|
20
|
+
}, [state, setHookState]);
|
|
21
|
+
var reduce = useCallback(function (action) {
|
|
22
|
+
return reducer(getState(), action);
|
|
23
|
+
}, [reducer, getState]);
|
|
24
|
+
var dispatch = useCallback(function (action) {
|
|
25
|
+
if (typeof action === 'function') {
|
|
26
|
+
return action(dispatch, getState);
|
|
27
|
+
}
|
|
28
|
+
setState(reduce(action));
|
|
29
|
+
}, [getState, setState, reduce]);
|
|
30
|
+
return [hookState, dispatch];
|
|
31
|
+
}
|