@bacon-pos/ui 0.11.0 → 0.15.1
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/lib/commonjs/components/CodeInput/CodeInput.js +28 -9
- package/lib/commonjs/components/CodeInput/CodeInput.js.map +1 -1
- package/lib/commonjs/components/CodeInput/CodeInput.stories.js +28 -1
- package/lib/commonjs/components/CodeInput/CodeInput.stories.js.map +1 -1
- package/lib/commonjs/components/CodeInput/CodeInput.test.js +16 -0
- package/lib/commonjs/components/CodeInput/CodeInput.test.js.map +1 -1
- package/lib/commonjs/components/Dialog/Dialog.js +116 -71
- package/lib/commonjs/components/Dialog/Dialog.js.map +1 -1
- package/lib/commonjs/components/Dialog/StepDialog.js +111 -0
- package/lib/commonjs/components/Dialog/StepDialog.js.map +1 -0
- package/lib/commonjs/components/Dialog/StepDialog.stories.js +157 -0
- package/lib/commonjs/components/Dialog/StepDialog.stories.js.map +1 -0
- package/lib/commonjs/components/Dialog/StepDialog.test.js +118 -0
- package/lib/commonjs/components/Dialog/StepDialog.test.js.map +1 -0
- package/lib/commonjs/components/Dialog/index.js +7 -0
- package/lib/commonjs/components/Dialog/index.js.map +1 -1
- package/lib/commonjs/components/Icon/icons.generated.js +9 -1
- package/lib/commonjs/components/Icon/icons.generated.js.map +1 -1
- package/lib/commonjs/components/List/List.js +45 -0
- package/lib/commonjs/components/List/List.js.map +1 -0
- package/lib/commonjs/components/List/List.stories.js +215 -0
- package/lib/commonjs/components/List/List.stories.js.map +1 -0
- package/lib/commonjs/components/List/List.test.js +94 -0
- package/lib/commonjs/components/List/List.test.js.map +1 -0
- package/lib/commonjs/components/List/ListItem.js +210 -0
- package/lib/commonjs/components/List/ListItem.js.map +1 -0
- package/lib/commonjs/components/List/index.js +20 -0
- package/lib/commonjs/components/List/index.js.map +1 -0
- package/lib/commonjs/components/Menu/Menu.js +11 -3
- package/lib/commonjs/components/Menu/Menu.js.map +1 -1
- package/lib/commonjs/components/ProgressBar/ProgressBar.js +4 -3
- package/lib/commonjs/components/ProgressBar/ProgressBar.js.map +1 -1
- package/lib/commonjs/components/Sidebar/Sidebar.js +20 -3
- package/lib/commonjs/components/Sidebar/Sidebar.js.map +1 -1
- package/lib/commonjs/components/Sidebar/Sidebar.stories.js +17 -1
- package/lib/commonjs/components/Sidebar/Sidebar.stories.js.map +1 -1
- package/lib/commonjs/components/Table/Table.js +69 -6
- package/lib/commonjs/components/Table/Table.js.map +1 -1
- package/lib/commonjs/components/Table/Table.stories.js +118 -1
- package/lib/commonjs/components/Table/Table.stories.js.map +1 -1
- package/lib/commonjs/components/Table/Table.test.js +58 -0
- package/lib/commonjs/components/Table/Table.test.js.map +1 -1
- package/lib/commonjs/components/_internal/ModalHostContext.js +21 -0
- package/lib/commonjs/components/_internal/ModalHostContext.js.map +1 -0
- package/lib/commonjs/components/index.js +26 -15
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/module/components/CodeInput/CodeInput.js +28 -9
- package/lib/module/components/CodeInput/CodeInput.js.map +1 -1
- package/lib/module/components/CodeInput/CodeInput.stories.js +27 -0
- package/lib/module/components/CodeInput/CodeInput.stories.js.map +1 -1
- package/lib/module/components/CodeInput/CodeInput.test.js +16 -0
- package/lib/module/components/CodeInput/CodeInput.test.js.map +1 -1
- package/lib/module/components/Dialog/Dialog.js +116 -71
- package/lib/module/components/Dialog/Dialog.js.map +1 -1
- package/lib/module/components/Dialog/StepDialog.js +107 -0
- package/lib/module/components/Dialog/StepDialog.js.map +1 -0
- package/lib/module/components/Dialog/StepDialog.stories.js +153 -0
- package/lib/module/components/Dialog/StepDialog.stories.js.map +1 -0
- package/lib/module/components/Dialog/StepDialog.test.js +117 -0
- package/lib/module/components/Dialog/StepDialog.test.js.map +1 -0
- package/lib/module/components/Dialog/index.js +1 -0
- package/lib/module/components/Dialog/index.js.map +1 -1
- package/lib/module/components/Icon/icons.generated.js +9 -1
- package/lib/module/components/Icon/icons.generated.js.map +1 -1
- package/lib/module/components/List/List.js +41 -0
- package/lib/module/components/List/List.js.map +1 -0
- package/lib/module/components/List/List.stories.js +211 -0
- package/lib/module/components/List/List.stories.js.map +1 -0
- package/lib/module/components/List/List.test.js +94 -0
- package/lib/module/components/List/List.test.js.map +1 -0
- package/lib/module/components/List/ListItem.js +206 -0
- package/lib/module/components/List/ListItem.js.map +1 -0
- package/lib/module/components/List/index.js +5 -0
- package/lib/module/components/List/index.js.map +1 -0
- package/lib/module/components/Menu/Menu.js +12 -4
- package/lib/module/components/Menu/Menu.js.map +1 -1
- package/lib/module/components/ProgressBar/ProgressBar.js +4 -3
- package/lib/module/components/ProgressBar/ProgressBar.js.map +1 -1
- package/lib/module/components/Sidebar/Sidebar.js +20 -3
- package/lib/module/components/Sidebar/Sidebar.js.map +1 -1
- package/lib/module/components/Sidebar/Sidebar.stories.js +16 -0
- package/lib/module/components/Sidebar/Sidebar.stories.js.map +1 -1
- package/lib/module/components/Table/Table.js +70 -7
- package/lib/module/components/Table/Table.js.map +1 -1
- package/lib/module/components/Table/Table.stories.js +117 -0
- package/lib/module/components/Table/Table.stories.js.map +1 -1
- package/lib/module/components/Table/Table.test.js +58 -0
- package/lib/module/components/Table/Table.test.js.map +1 -1
- package/lib/module/components/_internal/ModalHostContext.js +17 -0
- package/lib/module/components/_internal/ModalHostContext.js.map +1 -0
- package/lib/module/components/index.js +1 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/typescript/commonjs/components/CodeInput/CodeInput.d.ts +5 -1
- package/lib/typescript/commonjs/components/CodeInput/CodeInput.d.ts.map +1 -1
- package/lib/typescript/commonjs/components/Dialog/Dialog.d.ts +13 -1
- package/lib/typescript/commonjs/components/Dialog/Dialog.d.ts.map +1 -1
- package/lib/typescript/commonjs/components/Dialog/StepDialog.d.ts +63 -0
- package/lib/typescript/commonjs/components/Dialog/StepDialog.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/Dialog/index.d.ts +1 -0
- package/lib/typescript/commonjs/components/Dialog/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/components/Icon/icons.generated.d.ts +8 -0
- package/lib/typescript/commonjs/components/Icon/icons.generated.d.ts.map +1 -1
- package/lib/typescript/commonjs/components/List/List.d.ts +22 -0
- package/lib/typescript/commonjs/components/List/List.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/List/ListItem.d.ts +61 -0
- package/lib/typescript/commonjs/components/List/ListItem.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/List/index.d.ts +5 -0
- package/lib/typescript/commonjs/components/List/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/Menu/Menu.d.ts +4 -2
- package/lib/typescript/commonjs/components/Menu/Menu.d.ts.map +1 -1
- package/lib/typescript/commonjs/components/ProgressBar/ProgressBar.d.ts +3 -1
- package/lib/typescript/commonjs/components/ProgressBar/ProgressBar.d.ts.map +1 -1
- package/lib/typescript/commonjs/components/Sidebar/Sidebar.d.ts.map +1 -1
- package/lib/typescript/commonjs/components/Table/Table.d.ts +25 -3
- package/lib/typescript/commonjs/components/Table/Table.d.ts.map +1 -1
- package/lib/typescript/commonjs/components/_internal/ModalHostContext.d.ts +11 -0
- package/lib/typescript/commonjs/components/_internal/ModalHostContext.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/index.d.ts +1 -0
- package/lib/typescript/commonjs/components/index.d.ts.map +1 -1
- package/lib/typescript/module/components/CodeInput/CodeInput.d.ts +5 -1
- package/lib/typescript/module/components/CodeInput/CodeInput.d.ts.map +1 -1
- package/lib/typescript/module/components/Dialog/Dialog.d.ts +13 -1
- package/lib/typescript/module/components/Dialog/Dialog.d.ts.map +1 -1
- package/lib/typescript/module/components/Dialog/StepDialog.d.ts +63 -0
- package/lib/typescript/module/components/Dialog/StepDialog.d.ts.map +1 -0
- package/lib/typescript/module/components/Dialog/index.d.ts +1 -0
- package/lib/typescript/module/components/Dialog/index.d.ts.map +1 -1
- package/lib/typescript/module/components/Icon/icons.generated.d.ts +8 -0
- package/lib/typescript/module/components/Icon/icons.generated.d.ts.map +1 -1
- package/lib/typescript/module/components/List/List.d.ts +22 -0
- package/lib/typescript/module/components/List/List.d.ts.map +1 -0
- package/lib/typescript/module/components/List/ListItem.d.ts +61 -0
- package/lib/typescript/module/components/List/ListItem.d.ts.map +1 -0
- package/lib/typescript/module/components/List/index.d.ts +5 -0
- package/lib/typescript/module/components/List/index.d.ts.map +1 -0
- package/lib/typescript/module/components/Menu/Menu.d.ts +4 -2
- package/lib/typescript/module/components/Menu/Menu.d.ts.map +1 -1
- package/lib/typescript/module/components/ProgressBar/ProgressBar.d.ts +3 -1
- package/lib/typescript/module/components/ProgressBar/ProgressBar.d.ts.map +1 -1
- package/lib/typescript/module/components/Sidebar/Sidebar.d.ts.map +1 -1
- package/lib/typescript/module/components/Table/Table.d.ts +25 -3
- package/lib/typescript/module/components/Table/Table.d.ts.map +1 -1
- package/lib/typescript/module/components/_internal/ModalHostContext.d.ts +11 -0
- package/lib/typescript/module/components/_internal/ModalHostContext.d.ts.map +1 -0
- package/lib/typescript/module/components/index.d.ts +1 -0
- package/lib/typescript/module/components/index.d.ts.map +1 -1
- package/package.json +16 -14
- package/src/components/CodeInput/CodeInput.tsx +46 -14
- package/src/components/Dialog/Dialog.tsx +92 -31
- package/src/components/Dialog/StepDialog.tsx +173 -0
- package/src/components/Dialog/index.ts +1 -0
- package/src/components/Icon/icons.generated.ts +9 -1
- package/src/components/List/List.tsx +45 -0
- package/src/components/List/ListItem.tsx +214 -0
- package/src/components/List/index.ts +4 -0
- package/src/components/Menu/Menu.tsx +15 -6
- package/src/components/ProgressBar/ProgressBar.tsx +6 -3
- package/src/components/Sidebar/Sidebar.tsx +18 -10
- package/src/components/Table/Table.tsx +93 -8
- package/src/components/_internal/ModalHostContext.tsx +15 -0
- package/src/components/index.ts +1 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.StepDialog = StepDialog;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _ProgressBar = require("../ProgressBar/ProgressBar.js");
|
|
9
|
+
var _Dialog = require("./Dialog.js");
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
const clamp = (n, min, max) => n < min ? min : n > max ? max : n;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* StepDialog — a multi-step (wizard) flow built on `Dialog`. Give it an array of
|
|
15
|
+
* `steps`; it tracks the current one, renders a round back button in the header
|
|
16
|
+
* from step 2 onward, a thin progress bar in the footer, and a
|
|
17
|
+
* secondary (Back / Cancel) + primary (Continue / Finish) button pair. A step's
|
|
18
|
+
* `onNext` can return `false` (sync or async) to block advancing after failed
|
|
19
|
+
* validation. Controlled via `step`/`onStepChange` or fully uncontrolled.
|
|
20
|
+
* Forwards all other `Dialog` props (width, fullscreen, scrollMode, …).
|
|
21
|
+
*/
|
|
22
|
+
function StepDialog({
|
|
23
|
+
steps,
|
|
24
|
+
step,
|
|
25
|
+
defaultStep = 0,
|
|
26
|
+
onStepChange,
|
|
27
|
+
onFinish,
|
|
28
|
+
finishLabel = 'Finish',
|
|
29
|
+
backLabel = 'Back',
|
|
30
|
+
cancelLabel = 'Cancel',
|
|
31
|
+
showHeaderBack = true,
|
|
32
|
+
showFooterBack = true,
|
|
33
|
+
showProgress = true,
|
|
34
|
+
progressWidth = '62%',
|
|
35
|
+
visible,
|
|
36
|
+
onClose,
|
|
37
|
+
...dialogProps
|
|
38
|
+
}) {
|
|
39
|
+
const total = steps.length;
|
|
40
|
+
const [uncontrolled, setUncontrolled] = (0, _react.useState)(defaultStep);
|
|
41
|
+
const isControlled = step !== undefined;
|
|
42
|
+
const index = clamp(isControlled ? step : uncontrolled, 0, Math.max(0, total - 1));
|
|
43
|
+
|
|
44
|
+
// Reset an uncontrolled flow to its first step whenever it is closed.
|
|
45
|
+
(0, _react.useEffect)(() => {
|
|
46
|
+
if (!visible && !isControlled) setUncontrolled(defaultStep);
|
|
47
|
+
}, [visible, isControlled, defaultStep]);
|
|
48
|
+
const setIndex = next => {
|
|
49
|
+
const clamped = clamp(next, 0, total - 1);
|
|
50
|
+
if (!isControlled) setUncontrolled(clamped);
|
|
51
|
+
onStepChange?.(clamped);
|
|
52
|
+
};
|
|
53
|
+
const current = steps[index];
|
|
54
|
+
if (!current) return null;
|
|
55
|
+
const isFirst = index === 0;
|
|
56
|
+
const isLast = index === total - 1;
|
|
57
|
+
const goBack = () => {
|
|
58
|
+
if (!isFirst) setIndex(index - 1);
|
|
59
|
+
};
|
|
60
|
+
const advance = () => {
|
|
61
|
+
if (isLast) onFinish?.();else setIndex(index + 1);
|
|
62
|
+
};
|
|
63
|
+
const goNext = () => {
|
|
64
|
+
const result = current.onNext?.();
|
|
65
|
+
// Await only a real promise, so sync steps advance synchronously.
|
|
66
|
+
if (result && typeof result.then === 'function') {
|
|
67
|
+
void result.then(r => {
|
|
68
|
+
if (r !== false) advance();
|
|
69
|
+
});
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (result === false) return;
|
|
73
|
+
advance();
|
|
74
|
+
};
|
|
75
|
+
const footerAccessory = showProgress ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_ProgressBar.ProgressBar, {
|
|
76
|
+
progress: (index + 1) / total,
|
|
77
|
+
showSupporting: false,
|
|
78
|
+
bordered: false,
|
|
79
|
+
height: 6,
|
|
80
|
+
style: {
|
|
81
|
+
width: progressWidth,
|
|
82
|
+
alignSelf: 'center'
|
|
83
|
+
},
|
|
84
|
+
accessibilityLabel: `Step ${index + 1} of ${total}`
|
|
85
|
+
}) : undefined;
|
|
86
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Dialog.Dialog, {
|
|
87
|
+
...dialogProps,
|
|
88
|
+
visible: visible,
|
|
89
|
+
onClose: onClose,
|
|
90
|
+
title: current.title,
|
|
91
|
+
subtitle: current.subtitle,
|
|
92
|
+
onBack: !isFirst && showHeaderBack ? goBack : undefined,
|
|
93
|
+
backAccessibilityLabel: backLabel,
|
|
94
|
+
footerAccessory: footerAccessory,
|
|
95
|
+
cancel: showFooterBack ? isFirst ? {
|
|
96
|
+
label: cancelLabel,
|
|
97
|
+
onPress: onClose
|
|
98
|
+
} : {
|
|
99
|
+
label: backLabel,
|
|
100
|
+
onPress: goBack
|
|
101
|
+
} : undefined,
|
|
102
|
+
actions: [{
|
|
103
|
+
label: current.nextLabel ?? (isLast ? finishLabel : 'Continue'),
|
|
104
|
+
onPress: goNext,
|
|
105
|
+
disabled: current.nextDisabled,
|
|
106
|
+
loading: current.nextLoading
|
|
107
|
+
}],
|
|
108
|
+
children: current.content
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=StepDialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_ProgressBar","_Dialog","_jsxRuntime","clamp","n","min","max","StepDialog","steps","step","defaultStep","onStepChange","onFinish","finishLabel","backLabel","cancelLabel","showHeaderBack","showFooterBack","showProgress","progressWidth","visible","onClose","dialogProps","total","length","uncontrolled","setUncontrolled","useState","isControlled","undefined","index","Math","useEffect","setIndex","next","clamped","current","isFirst","isLast","goBack","advance","goNext","result","onNext","then","r","footerAccessory","jsx","ProgressBar","progress","showSupporting","bordered","height","style","width","alignSelf","accessibilityLabel","Dialog","title","subtitle","onBack","backAccessibilityLabel","cancel","label","onPress","actions","nextLabel","disabled","nextDisabled","loading","nextLoading","children","content"],"sourceRoot":"..\\..\\..\\..\\src","sources":["components/Dialog/StepDialog.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAAoD,IAAAG,WAAA,GAAAH,OAAA;AA0DpD,MAAMI,KAAK,GAAGA,CAACC,CAAS,EAAEC,GAAW,EAAEC,GAAW,KAAMF,CAAC,GAAGC,GAAG,GAAGA,GAAG,GA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AAA3B,WAAA,CAAA6C,GAAA,EAAC9C,OAAA,CAAAwD,MAAM;IAAA,GACDnC,WAAW;IACfF,OAAO,EAAEA,OAAQ;IACjBC,OAAO,EAAEA,OAAQ;IACjBqC,KAAK,EAAEtB,OAAO,CAACsB,KAAM;IACrBC,QAAQ,EAAEvB,OAAO,CAACuB,QAAS;IAC3BC,MAAM,EAAE,CAACvB,OAAO,IAAIrB,cAAc,GAAGuB,MAAM,GAAGV,SAAU;IACxDgC,sBAAsB,EAAE/C,SAAU;IAClCgC,eAAe,EAAEA,eAAgB;IACjCgB,MAAM,EACJ7C,cAAc,GACVoB,OAAO,GACL;MAAE0B,KAAK,EAAEhD,WAAW;MAAEiD,OAAO,EAAE3C;IAAQ,CAAC,GACxC;MAAE0C,KAAK,EAAEjD,SAAS;MAAEkD,OAAO,EAAEzB;IAAO,CAAC,GACvCV,SACL;IACDoC,OAAO,EAAE,CACP;MACEF,KAAK,EAAE3B,OAAO,CAAC8B,SAAS,KAAK5B,MAAM,GAAGzB,WAAW,GAAG,UAAU,CAAC;MAC/DmD,OAAO,EAAEvB,MAAM;MACf0B,QAAQ,EAAE/B,OAAO,CAACgC,YAAY;MAC9BC,OAAO,EAAEjC,OAAO,CAACkC;IACnB,CAAC,CACD;IAAAC,QAAA,EAEDnC,OAAO,CAACoC;EAAO,CACV,CAAC;AAEb","ignoreList":[]}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.Fullscreen = exports.Basic = exports.AsyncValidation = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _StepDialog = require("./StepDialog.js");
|
|
10
|
+
var _Button = require("../Button/Button.js");
|
|
11
|
+
var _Input = require("../Input/Input.js");
|
|
12
|
+
var _Radio = require("../Radio/Radio.js");
|
|
13
|
+
var _Text = require("../Text/Text.js");
|
|
14
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
+
const meta = {
|
|
16
|
+
title: 'Components/StepDialog',
|
|
17
|
+
component: _StepDialog.StepDialog
|
|
18
|
+
};
|
|
19
|
+
var _default = exports.default = meta;
|
|
20
|
+
function Frame({
|
|
21
|
+
render
|
|
22
|
+
}) {
|
|
23
|
+
const [open, setOpen] = (0, _react.useState)(false);
|
|
24
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
25
|
+
style: {
|
|
26
|
+
padding: 24
|
|
27
|
+
},
|
|
28
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.Button, {
|
|
29
|
+
label: "Start flow",
|
|
30
|
+
onPress: () => setOpen(true)
|
|
31
|
+
}), render(open, () => setOpen(false))]
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Three-step flow: pick an option, fill details, confirm. */
|
|
36
|
+
const Basic = exports.Basic = {
|
|
37
|
+
render: () => /*#__PURE__*/(0, _jsxRuntime.jsx)(Frame, {
|
|
38
|
+
render: (open, close) => {
|
|
39
|
+
const [plan, setPlan] = (0, _react.useState)('standard');
|
|
40
|
+
const [name, setName] = (0, _react.useState)('');
|
|
41
|
+
const steps = [{
|
|
42
|
+
title: 'Choose a plan',
|
|
43
|
+
subtitle: 'Pick the option that fits your venue.',
|
|
44
|
+
content: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
45
|
+
style: {
|
|
46
|
+
gap: 12
|
|
47
|
+
},
|
|
48
|
+
children: ['standard', 'pro', 'enterprise'].map(p => /*#__PURE__*/(0, _jsxRuntime.jsx)(_Radio.Radio, {
|
|
49
|
+
selected: plan === p,
|
|
50
|
+
onChange: () => setPlan(p),
|
|
51
|
+
label: p[0].toUpperCase() + p.slice(1)
|
|
52
|
+
}, p))
|
|
53
|
+
})
|
|
54
|
+
}, {
|
|
55
|
+
title: 'Your details',
|
|
56
|
+
subtitle: 'Tell us who this is for.',
|
|
57
|
+
content: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Input.Input, {
|
|
58
|
+
label: "Full name",
|
|
59
|
+
placeholder: "Jane Doe",
|
|
60
|
+
value: name,
|
|
61
|
+
onChangeText: setName
|
|
62
|
+
}),
|
|
63
|
+
nextDisabled: name.trim().length === 0
|
|
64
|
+
}, {
|
|
65
|
+
title: 'All set',
|
|
66
|
+
subtitle: 'Review and confirm.',
|
|
67
|
+
content: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.Text, {
|
|
68
|
+
variant: "bodyMedium",
|
|
69
|
+
color: "secondary",
|
|
70
|
+
children: `Plan: ${plan}\nName: ${name || '—'}`
|
|
71
|
+
})
|
|
72
|
+
}];
|
|
73
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_StepDialog.StepDialog, {
|
|
74
|
+
visible: open,
|
|
75
|
+
onClose: close,
|
|
76
|
+
steps: steps,
|
|
77
|
+
onFinish: close
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/** Async validation on `onNext` — the primary button spins and can block advancing. */
|
|
84
|
+
const AsyncValidation = exports.AsyncValidation = {
|
|
85
|
+
render: () => /*#__PURE__*/(0, _jsxRuntime.jsx)(Frame, {
|
|
86
|
+
render: (open, close) => {
|
|
87
|
+
const [code, setCode] = (0, _react.useState)('');
|
|
88
|
+
const [loading, setLoading] = (0, _react.useState)(false);
|
|
89
|
+
const steps = [{
|
|
90
|
+
title: 'Enter access code',
|
|
91
|
+
subtitle: 'Try "1234" to pass.',
|
|
92
|
+
content: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Input.Input, {
|
|
93
|
+
label: "Code",
|
|
94
|
+
placeholder: "\u2022\u2022\u2022\u2022",
|
|
95
|
+
value: code,
|
|
96
|
+
onChangeText: setCode
|
|
97
|
+
}),
|
|
98
|
+
nextLabel: 'Verify',
|
|
99
|
+
nextLoading: loading,
|
|
100
|
+
onNext: async () => {
|
|
101
|
+
setLoading(true);
|
|
102
|
+
await new Promise(r => setTimeout(r, 700));
|
|
103
|
+
setLoading(false);
|
|
104
|
+
return code === '1234'; // false → stays on step
|
|
105
|
+
}
|
|
106
|
+
}, {
|
|
107
|
+
title: 'Verified',
|
|
108
|
+
content: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.Text, {
|
|
109
|
+
variant: "bodyMedium",
|
|
110
|
+
color: "secondary",
|
|
111
|
+
children: "You are in."
|
|
112
|
+
})
|
|
113
|
+
}];
|
|
114
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_StepDialog.StepDialog, {
|
|
115
|
+
visible: open,
|
|
116
|
+
onClose: close,
|
|
117
|
+
steps: steps,
|
|
118
|
+
onFinish: close
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/** Fullscreen flow for small devices. */
|
|
125
|
+
const Fullscreen = exports.Fullscreen = {
|
|
126
|
+
render: () => /*#__PURE__*/(0, _jsxRuntime.jsx)(Frame, {
|
|
127
|
+
render: (open, close) => {
|
|
128
|
+
const steps = [{
|
|
129
|
+
title: 'Step one',
|
|
130
|
+
content: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.Text, {
|
|
131
|
+
color: "secondary",
|
|
132
|
+
children: "First screen."
|
|
133
|
+
})
|
|
134
|
+
}, {
|
|
135
|
+
title: 'Step two',
|
|
136
|
+
content: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.Text, {
|
|
137
|
+
color: "secondary",
|
|
138
|
+
children: "Second screen."
|
|
139
|
+
})
|
|
140
|
+
}, {
|
|
141
|
+
title: 'Step three',
|
|
142
|
+
content: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.Text, {
|
|
143
|
+
color: "secondary",
|
|
144
|
+
children: "Last screen."
|
|
145
|
+
})
|
|
146
|
+
}];
|
|
147
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_StepDialog.StepDialog, {
|
|
148
|
+
visible: open,
|
|
149
|
+
onClose: close,
|
|
150
|
+
steps: steps,
|
|
151
|
+
onFinish: close,
|
|
152
|
+
fullscreen: true
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
})
|
|
156
|
+
};
|
|
157
|
+
//# sourceMappingURL=StepDialog.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_StepDialog","_Button","_Input","_Radio","_Text","_jsxRuntime","meta","title","component","StepDialog","_default","exports","default","Frame","render","open","setOpen","useState","jsxs","View","style","padding","children","jsx","Button","label","onPress","Basic","close","plan","setPlan","name","setName","steps","subtitle","content","gap","map","p","Radio","selected","onChange","toUpperCase","slice","Input","placeholder","value","onChangeText","nextDisabled","trim","length","Text","variant","color","visible","onClose","onFinish","AsyncValidation","code","setCode","loading","setLoading","nextLabel","nextLoading","onNext","Promise","r","setTimeout","Fullscreen","fullscreen"],"sourceRoot":"..\\..\\..\\..\\src","sources":["components/Dialog/StepDialog.stories.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AAAoC,IAAAO,WAAA,GAAAP,OAAA;AAEpC,MAAMQ,IAAI,GAAG;EACXC,KAAK,EAAE,uBAAuB;EAC9BC,SAAS,EAAEC;AACb,CAAmC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAErBN,IAAI;AAGnB,SAASO,KAAKA,CAAC;EAAEC;AAA0E,CAAC,EAAE;EAC5F,MAAM,CAACC,IAAI,EAAEC,OAAO,CAAC,GAAG,IAAAC,eAAQ,EAAC,KA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AAK;IACJC,MAAM,EAAEA,CAACC,IAAI,EAAEa,KAAK,KAAK;MACvB,MAAMK,KAAuB,GAAG,CAC9B;QAAE1B,KAAK,EAAE,UAAU;QAAE4B,OAAO,eAAE,IAAA9B,WAAA,CAAAkB,GAAA,EAACnB,KAAA,CAAA+C,IAAI;UAACE,KAAK,EAAC,WAAW;UAAA/B,QAAA,EAAC;QAAa,CAAM;MAAE,CAAC,EAC5E;QAAEf,KAAK,EAAE,UAAU;QAAE4B,OAAO,eAAE,IAAA9B,WAAA,CAAAkB,GAAA,EAACnB,KAAA,CAAA+C,IAAI;UAACE,KAAK,EAAC,WAAW;UAAA/B,QAAA,EAAC;QAAc,CAAM;MAAE,CAAC,EAC7E;QAAEf,KAAK,EAAE,YAAY;QAAE4B,OAAO,eAAE,IAAA9B,WAAA,CAAAkB,GAAA,EAACnB,KAAA,CAAA+C,IAAI;UAACE,KAAK,EAAC,WAAW;UAAA/B,QAAA,EAAC;QAAY,CAAM;MAAE,CAAC,CAC9E;MACD,oBAAO,IAAAjB,WAAA,CAAAkB,GAAA,EAACvB,WAAA,CAAAS,UAAU;QAAC6C,OAAO,EAAEvC,IAAK;QAACwC,OAAO,EAAE3B,KAAM;QAACK,KAAK,EAAEA,KAAM;QAACuB,QAAQ,EAAE5B,KAAM;QAACyC,UAAU;MAAA,CAAE,CAAC;IAChG;EAAE,CACH;AAEL,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _react = _interopRequireDefault(require("react"));
|
|
4
|
+
var _reactNative = require("@testing-library/react-native");
|
|
5
|
+
var _StepDialog = require("./StepDialog.js");
|
|
6
|
+
var _Text = require("../Text/Text.js");
|
|
7
|
+
var _index = require("../../theme/index.js");
|
|
8
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
function renderWithTheme(ui) {
|
|
11
|
+
return (0, _reactNative.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_index.ThemeProvider, {
|
|
12
|
+
children: ui
|
|
13
|
+
}));
|
|
14
|
+
}
|
|
15
|
+
const STEPS = [{
|
|
16
|
+
title: 'Step one',
|
|
17
|
+
content: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.Text, {
|
|
18
|
+
children: "Body one"
|
|
19
|
+
})
|
|
20
|
+
}, {
|
|
21
|
+
title: 'Step two',
|
|
22
|
+
content: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.Text, {
|
|
23
|
+
children: "Body two"
|
|
24
|
+
})
|
|
25
|
+
}, {
|
|
26
|
+
title: 'Step three',
|
|
27
|
+
content: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.Text, {
|
|
28
|
+
children: "Body three"
|
|
29
|
+
})
|
|
30
|
+
}];
|
|
31
|
+
describe('StepDialog', () => {
|
|
32
|
+
it('renders the first step with no header back button', () => {
|
|
33
|
+
renderWithTheme(/*#__PURE__*/(0, _jsxRuntime.jsx)(_StepDialog.StepDialog, {
|
|
34
|
+
visible: true,
|
|
35
|
+
onClose: () => {},
|
|
36
|
+
steps: STEPS
|
|
37
|
+
}));
|
|
38
|
+
expect(_reactNative.screen.getByText('Step one')).toBeTruthy();
|
|
39
|
+
expect(_reactNative.screen.getByText('Body one')).toBeTruthy();
|
|
40
|
+
expect(_reactNative.screen.queryByLabelText('Back')).toBeNull();
|
|
41
|
+
});
|
|
42
|
+
it('advances on Continue and shows the header back button from step 2', () => {
|
|
43
|
+
renderWithTheme(/*#__PURE__*/(0, _jsxRuntime.jsx)(_StepDialog.StepDialog, {
|
|
44
|
+
visible: true,
|
|
45
|
+
onClose: () => {},
|
|
46
|
+
steps: STEPS
|
|
47
|
+
}));
|
|
48
|
+
_reactNative.fireEvent.press(_reactNative.screen.getByText('Continue'));
|
|
49
|
+
expect(_reactNative.screen.getByText('Step two')).toBeTruthy();
|
|
50
|
+
expect(_reactNative.screen.getByLabelText('Back')).toBeTruthy();
|
|
51
|
+
});
|
|
52
|
+
it('goes back via the header button', () => {
|
|
53
|
+
renderWithTheme(/*#__PURE__*/(0, _jsxRuntime.jsx)(_StepDialog.StepDialog, {
|
|
54
|
+
visible: true,
|
|
55
|
+
onClose: () => {},
|
|
56
|
+
steps: STEPS
|
|
57
|
+
}));
|
|
58
|
+
_reactNative.fireEvent.press(_reactNative.screen.getByText('Continue'));
|
|
59
|
+
_reactNative.fireEvent.press(_reactNative.screen.getByLabelText('Back'));
|
|
60
|
+
expect(_reactNative.screen.getByText('Step one')).toBeTruthy();
|
|
61
|
+
});
|
|
62
|
+
it('shows Finish on the last step and calls onFinish', () => {
|
|
63
|
+
const onFinish = jest.fn();
|
|
64
|
+
renderWithTheme(/*#__PURE__*/(0, _jsxRuntime.jsx)(_StepDialog.StepDialog, {
|
|
65
|
+
visible: true,
|
|
66
|
+
onClose: () => {},
|
|
67
|
+
steps: STEPS,
|
|
68
|
+
onFinish: onFinish
|
|
69
|
+
}));
|
|
70
|
+
_reactNative.fireEvent.press(_reactNative.screen.getByText('Continue'));
|
|
71
|
+
_reactNative.fireEvent.press(_reactNative.screen.getByText('Continue'));
|
|
72
|
+
expect(_reactNative.screen.getByText('Finish')).toBeTruthy();
|
|
73
|
+
_reactNative.fireEvent.press(_reactNative.screen.getByText('Finish'));
|
|
74
|
+
expect(onFinish).toHaveBeenCalledTimes(1);
|
|
75
|
+
});
|
|
76
|
+
it('first step footer secondary is Cancel → onClose', () => {
|
|
77
|
+
const onClose = jest.fn();
|
|
78
|
+
renderWithTheme(/*#__PURE__*/(0, _jsxRuntime.jsx)(_StepDialog.StepDialog, {
|
|
79
|
+
visible: true,
|
|
80
|
+
onClose: onClose,
|
|
81
|
+
steps: STEPS
|
|
82
|
+
}));
|
|
83
|
+
_reactNative.fireEvent.press(_reactNative.screen.getByText('Cancel'));
|
|
84
|
+
expect(onClose).toHaveBeenCalledTimes(1);
|
|
85
|
+
});
|
|
86
|
+
it('blocks advancing when onNext resolves false', async () => {
|
|
87
|
+
const steps = [{
|
|
88
|
+
title: 'Gate',
|
|
89
|
+
content: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.Text, {
|
|
90
|
+
children: "Gate body"
|
|
91
|
+
}),
|
|
92
|
+
onNext: async () => false
|
|
93
|
+
}, {
|
|
94
|
+
title: 'After',
|
|
95
|
+
content: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.Text, {
|
|
96
|
+
children: "After body"
|
|
97
|
+
})
|
|
98
|
+
}];
|
|
99
|
+
renderWithTheme(/*#__PURE__*/(0, _jsxRuntime.jsx)(_StepDialog.StepDialog, {
|
|
100
|
+
visible: true,
|
|
101
|
+
onClose: () => {},
|
|
102
|
+
steps: steps
|
|
103
|
+
}));
|
|
104
|
+
_reactNative.fireEvent.press(_reactNative.screen.getByText('Continue'));
|
|
105
|
+
await (0, _reactNative.waitFor)(() => expect(_reactNative.screen.getByText('Gate')).toBeTruthy());
|
|
106
|
+
expect(_reactNative.screen.queryByText('After')).toBeNull();
|
|
107
|
+
});
|
|
108
|
+
it('respects a controlled step index', () => {
|
|
109
|
+
renderWithTheme(/*#__PURE__*/(0, _jsxRuntime.jsx)(_StepDialog.StepDialog, {
|
|
110
|
+
visible: true,
|
|
111
|
+
onClose: () => {},
|
|
112
|
+
steps: STEPS,
|
|
113
|
+
step: 1
|
|
114
|
+
}));
|
|
115
|
+
expect(_reactNative.screen.getByText('Step two')).toBeTruthy();
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
//# sourceMappingURL=StepDialog.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_StepDialog","_Text","_index","_jsxRuntime","e","__esModule","default","renderWithTheme","ui","render","jsx","ThemeProvider","children","STEPS","title","content","Text","describe","it","StepDialog","visible","onClose","steps","expect","screen","getByText","toBeTruthy","queryByLabelText","toBeNull","fireEvent","press","getByLabelText","onFinish","jest","fn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ACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -9,5 +9,12 @@ Object.defineProperty(exports, "Dialog", {
|
|
|
9
9
|
return _Dialog.Dialog;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
+
Object.defineProperty(exports, "StepDialog", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _StepDialog.StepDialog;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
12
18
|
var _Dialog = require("./Dialog.js");
|
|
19
|
+
var _StepDialog = require("./StepDialog.js");
|
|
13
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_Dialog","require"],"sourceRoot":"..\\..\\..\\..\\src","sources":["components/Dialog/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_Dialog","require","_StepDialog"],"sourceRoot":"..\\..\\..\\..\\src","sources":["components/Dialog/index.ts"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAMA,IAAAC,WAAA,GAAAD,OAAA","ignoreList":[]}
|