@spaced-out/ui-design-system 0.1.32 → 0.1.34
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/.cspell/custom-words.txt +1 -0
- package/.github/workflows/publish_to_npm.yml +1 -1
- package/CHANGELOG.md +19 -0
- package/lib/components/Badge/Badge.js +3 -3
- package/lib/components/Badge/Badge.js.flow +3 -3
- package/lib/components/Badge/Badge.module.css +6 -0
- package/lib/components/Dialog/index.js +11 -31
- package/lib/components/Dialog/index.js.flow +1 -13
- package/lib/components/FileUpload/FileBlock/FileBlock.js +111 -0
- package/lib/components/FileUpload/FileBlock/FileBlock.js.flow +139 -0
- package/lib/components/FileUpload/FileBlock/index.js +16 -0
- package/lib/components/FileUpload/FileBlock/index.js.flow +3 -0
- package/lib/components/FileUpload/FileUpload.js +5 -98
- package/lib/components/FileUpload/FileUpload.js.flow +5 -107
- package/lib/components/FileUpload/FileUpload.module.css +1 -1
- package/lib/components/FileUpload/index.js +11 -0
- package/lib/components/FileUpload/index.js.flow +1 -0
- package/lib/components/Stepper/Step/Step.js +63 -0
- package/lib/components/Stepper/Step/Step.js.flow +101 -0
- package/lib/components/Stepper/Step/StepContent.js +30 -0
- package/lib/components/Stepper/Step/StepContent.js.flow +40 -0
- package/lib/components/{CodeBlock/CodeBlock.js → Stepper/Step/StepLabel.js} +18 -11
- package/lib/components/Stepper/Step/StepLabel.js.flow +40 -0
- package/lib/components/Stepper/Step/index.js +38 -0
- package/lib/components/Stepper/Step/index.js.flow +5 -0
- package/lib/components/Stepper/Stepper.js +48 -0
- package/lib/components/Stepper/Stepper.js.flow +64 -0
- package/lib/components/Stepper/Stepper.module.css +110 -0
- package/lib/components/Stepper/index.js +27 -0
- package/lib/components/Stepper/index.js.flow +4 -0
- package/lib/components/index.js +11 -11
- package/lib/components/index.js.flow +1 -1
- package/package.json +1 -2
- package/lib/components/CodeBlock/CodeBlock.js.flow +0 -20
- package/lib/components/CodeBlock/index.js +0 -12
- package/lib/components/CodeBlock/index.js.flow +0 -3
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
} from '../../hooks/useFileUpload';
|
|
9
9
|
import classify from '../../utils/classify';
|
|
10
10
|
import {UnstyledButton} from '../Button';
|
|
11
|
-
import {ClickableIcon, CloseIcon, Icon} from '../Icon';
|
|
12
|
-
import {LinearLoader} from '../LinearLoader';
|
|
13
11
|
import {Truncate} from '../Truncate';
|
|
14
12
|
|
|
13
|
+
import {FileBlock} from './FileBlock';
|
|
14
|
+
|
|
15
15
|
import css from './FileUpload.module.css';
|
|
16
16
|
|
|
17
17
|
|
|
@@ -88,12 +88,6 @@ export type FileUploadProps = {
|
|
|
88
88
|
onFileRefreshClick?: (file: FileObject) => void,
|
|
89
89
|
};
|
|
90
90
|
|
|
91
|
-
export type FileBlockProps = {
|
|
92
|
-
file: FileObject,
|
|
93
|
-
onFileRefreshClick?: (file: FileObject) => void,
|
|
94
|
-
handleFileClear?: (id: string) => mixed,
|
|
95
|
-
};
|
|
96
|
-
|
|
97
91
|
const FileUploadBase = (props: FileUploadProps, ref) => {
|
|
98
92
|
const {
|
|
99
93
|
classNames,
|
|
@@ -184,10 +178,10 @@ const FileUploadBase = (props: FileUploadProps, ref) => {
|
|
|
184
178
|
|
|
185
179
|
{files.length > 0 && (
|
|
186
180
|
<div className={css.files}>
|
|
187
|
-
{files.map((
|
|
188
|
-
<React.Fragment key={
|
|
181
|
+
{files.map((fileObject: FileObject) => (
|
|
182
|
+
<React.Fragment key={fileObject.id}>
|
|
189
183
|
<FileBlock
|
|
190
|
-
|
|
184
|
+
fileObject={fileObject}
|
|
191
185
|
onFileRefreshClick={onFileRefreshClick}
|
|
192
186
|
handleFileClear={handleFileClear}
|
|
193
187
|
/>
|
|
@@ -199,102 +193,6 @@ const FileUploadBase = (props: FileUploadProps, ref) => {
|
|
|
199
193
|
);
|
|
200
194
|
};
|
|
201
195
|
|
|
202
|
-
const FileBlock = ({
|
|
203
|
-
file,
|
|
204
|
-
onFileRefreshClick,
|
|
205
|
-
handleFileClear,
|
|
206
|
-
}: FileBlockProps): React.Node => (
|
|
207
|
-
<>
|
|
208
|
-
<div className={css.file}>
|
|
209
|
-
<div className={css.fileInfo}>
|
|
210
|
-
<div className={css.fileNameBlock}>
|
|
211
|
-
<div className={css.icon}>
|
|
212
|
-
<FileStatusIcon file={file} />
|
|
213
|
-
</div>
|
|
214
|
-
<div className={css.fileName}>
|
|
215
|
-
<Truncate>{file.file.name}</Truncate>
|
|
216
|
-
</div>
|
|
217
|
-
</div>
|
|
218
|
-
|
|
219
|
-
{file.success && !!file.successMessage && (
|
|
220
|
-
<div className={css.fileSuccess}>
|
|
221
|
-
<Truncate>{file.successMessage}</Truncate>
|
|
222
|
-
</div>
|
|
223
|
-
)}
|
|
224
|
-
|
|
225
|
-
{file.reject && !!file.rejectReason && (
|
|
226
|
-
<div className={css.fileError}>
|
|
227
|
-
<Truncate>{file.rejectReason}</Truncate>
|
|
228
|
-
</div>
|
|
229
|
-
)}
|
|
230
|
-
|
|
231
|
-
{!!file.progress && (
|
|
232
|
-
<div className={css.progress}>
|
|
233
|
-
<LinearLoader
|
|
234
|
-
size="small"
|
|
235
|
-
value={file.progress === 'indeterminate' ? 0 : file.progress}
|
|
236
|
-
indeterminate={file.progress === 'indeterminate'}
|
|
237
|
-
></LinearLoader>
|
|
238
|
-
</div>
|
|
239
|
-
)}
|
|
240
|
-
</div>
|
|
241
|
-
<div className={css.rightSection}>
|
|
242
|
-
{file.showReUpload && (
|
|
243
|
-
<div className={css.rightBlock}>
|
|
244
|
-
<ClickableIcon
|
|
245
|
-
name="refresh"
|
|
246
|
-
size="small"
|
|
247
|
-
onClick={() => onFileRefreshClick?.(file)}
|
|
248
|
-
/>
|
|
249
|
-
</div>
|
|
250
|
-
)}
|
|
251
|
-
|
|
252
|
-
<div className={css.rightBlock}>
|
|
253
|
-
<CloseIcon size="small" onClick={() => handleFileClear?.(file.id)} />
|
|
254
|
-
</div>
|
|
255
|
-
</div>
|
|
256
|
-
</div>
|
|
257
|
-
</>
|
|
258
|
-
);
|
|
259
|
-
|
|
260
|
-
// This function returns the status of a file
|
|
261
|
-
const getFileStatus = (file: FileObject) => {
|
|
262
|
-
if (file.progress) {
|
|
263
|
-
return 'progress';
|
|
264
|
-
}
|
|
265
|
-
if (file.success) {
|
|
266
|
-
return 'success';
|
|
267
|
-
}
|
|
268
|
-
if (file.reject) {
|
|
269
|
-
return 'error';
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
return 'default';
|
|
273
|
-
};
|
|
274
|
-
|
|
275
|
-
// This component renders the status icon for a file
|
|
276
|
-
const FileStatusIcon = ({file}: {file: FileObject}) => {
|
|
277
|
-
const status = getFileStatus(file);
|
|
278
|
-
switch (status) {
|
|
279
|
-
case 'progress':
|
|
280
|
-
return <Icon size="small" name="loader" color="tertiary" />;
|
|
281
|
-
case 'success':
|
|
282
|
-
return <Icon size="small" name="check" color="success" />;
|
|
283
|
-
case 'error':
|
|
284
|
-
return (
|
|
285
|
-
<Icon
|
|
286
|
-
size="small"
|
|
287
|
-
name="circle-exclamation"
|
|
288
|
-
color="danger"
|
|
289
|
-
type="solid"
|
|
290
|
-
/>
|
|
291
|
-
);
|
|
292
|
-
|
|
293
|
-
default:
|
|
294
|
-
return <Icon size="small" name="check" color="success" />;
|
|
295
|
-
}
|
|
296
|
-
};
|
|
297
|
-
|
|
298
196
|
export const FileUpload: React.AbstractComponent<
|
|
299
197
|
FileUploadProps,
|
|
300
198
|
FileUploadRef,
|
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
var _FileBlock = require("./FileBlock");
|
|
7
|
+
Object.keys(_FileBlock).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _FileBlock[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _FileBlock[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
6
17
|
var _FileUpload = require("./FileUpload");
|
|
7
18
|
Object.keys(_FileUpload).forEach(function (key) {
|
|
8
19
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Step = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _classify = _interopRequireDefault(require("../../../utils/classify"));
|
|
9
|
+
var _Icon = require("../../Icon");
|
|
10
|
+
var _StepperModule = _interopRequireDefault(require("../Stepper.module.css"));
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
14
|
+
|
|
15
|
+
const Step = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
16
|
+
let {
|
|
17
|
+
active,
|
|
18
|
+
children,
|
|
19
|
+
completed = false,
|
|
20
|
+
disabled = false,
|
|
21
|
+
expanded = false,
|
|
22
|
+
index = 0,
|
|
23
|
+
last,
|
|
24
|
+
classNames,
|
|
25
|
+
onClick,
|
|
26
|
+
allowClick
|
|
27
|
+
} = _ref;
|
|
28
|
+
const childrenArray = React.Children.toArray(children).filter(Boolean);
|
|
29
|
+
const stepContent = childrenArray.map(stepContent => /*#__PURE__*/React.cloneElement(stepContent, {
|
|
30
|
+
...stepContent.props,
|
|
31
|
+
active,
|
|
32
|
+
completed,
|
|
33
|
+
disabled
|
|
34
|
+
}));
|
|
35
|
+
const handleClick = e => allowClick && onClick?.(index, e);
|
|
36
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
37
|
+
ref: ref,
|
|
38
|
+
className: (0, _classify.default)(_StepperModule.default.stepWrapper, {
|
|
39
|
+
[_StepperModule.default.active]: active,
|
|
40
|
+
[_StepperModule.default.completed]: completed,
|
|
41
|
+
[_StepperModule.default.expanded]: expanded,
|
|
42
|
+
[_StepperModule.default.last]: last,
|
|
43
|
+
[_StepperModule.default.disabled]: disabled,
|
|
44
|
+
[_StepperModule.default.clickable]: allowClick
|
|
45
|
+
}, classNames?.wrapper),
|
|
46
|
+
onClick: handleClick
|
|
47
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
48
|
+
className: (0, _classify.default)(_StepperModule.default.stepWrapperCounter, {
|
|
49
|
+
[_StepperModule.default.selected]: active,
|
|
50
|
+
[_StepperModule.default.completed]: completed,
|
|
51
|
+
[_StepperModule.default.expanded]: expanded,
|
|
52
|
+
[_StepperModule.default.last]: last,
|
|
53
|
+
[_StepperModule.default.disabled]: disabled
|
|
54
|
+
}, classNames?.stepCounter)
|
|
55
|
+
}, completed && !active ? /*#__PURE__*/React.createElement(_Icon.Icon, {
|
|
56
|
+
name: "check",
|
|
57
|
+
color: "inversePrimary",
|
|
58
|
+
size: "small"
|
|
59
|
+
}) : /*#__PURE__*/React.createElement(React.Fragment, null, (index + 1).toString())), /*#__PURE__*/React.createElement("div", {
|
|
60
|
+
className: (0, _classify.default)(_StepperModule.default.stepContent, classNames?.content)
|
|
61
|
+
}, stepContent));
|
|
62
|
+
});
|
|
63
|
+
exports.Step = Step;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// @flow strict
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
import classify from '../../../utils/classify';
|
|
6
|
+
import {Icon} from '../../Icon';
|
|
7
|
+
|
|
8
|
+
import css from '../Stepper.module.css';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
type ClassNames = $ReadOnly<{
|
|
12
|
+
wrapper?: string,
|
|
13
|
+
stepCounter?: string,
|
|
14
|
+
content?: string,
|
|
15
|
+
}>;
|
|
16
|
+
|
|
17
|
+
export type StepProps = {
|
|
18
|
+
active?: boolean,
|
|
19
|
+
children: React.Node,
|
|
20
|
+
completed?: boolean,
|
|
21
|
+
disabled?: boolean,
|
|
22
|
+
expanded?: boolean,
|
|
23
|
+
index: number,
|
|
24
|
+
last?: boolean,
|
|
25
|
+
classNames?: ClassNames,
|
|
26
|
+
allowClick?: boolean,
|
|
27
|
+
onClick?: (idx: number, e?: ?SyntheticEvent<HTMLElement>) => mixed,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const Step: React$AbstractComponent<StepProps, HTMLDivElement> =
|
|
31
|
+
React.forwardRef<StepProps, HTMLDivElement>(
|
|
32
|
+
(
|
|
33
|
+
{
|
|
34
|
+
active,
|
|
35
|
+
children,
|
|
36
|
+
completed = false,
|
|
37
|
+
disabled = false,
|
|
38
|
+
expanded = false,
|
|
39
|
+
index = 0,
|
|
40
|
+
last,
|
|
41
|
+
classNames,
|
|
42
|
+
onClick,
|
|
43
|
+
allowClick,
|
|
44
|
+
}: StepProps,
|
|
45
|
+
ref,
|
|
46
|
+
): React.Node => {
|
|
47
|
+
const childrenArray = React.Children.toArray(children).filter(Boolean);
|
|
48
|
+
const stepContent = childrenArray.map((stepContent) =>
|
|
49
|
+
React.cloneElement(stepContent, {
|
|
50
|
+
...stepContent.props,
|
|
51
|
+
active,
|
|
52
|
+
completed,
|
|
53
|
+
disabled,
|
|
54
|
+
}),
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
const handleClick = (e) => allowClick && onClick?.(index, e);
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<div
|
|
61
|
+
ref={ref}
|
|
62
|
+
className={classify(
|
|
63
|
+
css.stepWrapper,
|
|
64
|
+
{
|
|
65
|
+
[css.active]: active,
|
|
66
|
+
[css.completed]: completed,
|
|
67
|
+
[css.expanded]: expanded,
|
|
68
|
+
[css.last]: last,
|
|
69
|
+
[css.disabled]: disabled,
|
|
70
|
+
[css.clickable]: allowClick,
|
|
71
|
+
},
|
|
72
|
+
classNames?.wrapper,
|
|
73
|
+
)}
|
|
74
|
+
onClick={handleClick}
|
|
75
|
+
>
|
|
76
|
+
<div
|
|
77
|
+
className={classify(
|
|
78
|
+
css.stepWrapperCounter,
|
|
79
|
+
{
|
|
80
|
+
[css.selected]: active,
|
|
81
|
+
[css.completed]: completed,
|
|
82
|
+
[css.expanded]: expanded,
|
|
83
|
+
[css.last]: last,
|
|
84
|
+
[css.disabled]: disabled,
|
|
85
|
+
},
|
|
86
|
+
classNames?.stepCounter,
|
|
87
|
+
)}
|
|
88
|
+
>
|
|
89
|
+
{completed && !active ? (
|
|
90
|
+
<Icon name="check" color="inversePrimary" size="small" />
|
|
91
|
+
) : (
|
|
92
|
+
<React.Fragment>{(index + 1).toString()}</React.Fragment>
|
|
93
|
+
)}
|
|
94
|
+
</div>
|
|
95
|
+
<div className={classify(css.stepContent, classNames?.content)}>
|
|
96
|
+
{stepContent}
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
);
|
|
100
|
+
},
|
|
101
|
+
);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.StepContent = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _classify = require("../../../utils/classify");
|
|
9
|
+
var _StepperModule = _interopRequireDefault(require("../Stepper.module.css"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
13
|
+
|
|
14
|
+
const StepContent = _ref => {
|
|
15
|
+
let {
|
|
16
|
+
children,
|
|
17
|
+
classNames,
|
|
18
|
+
active,
|
|
19
|
+
completed = false,
|
|
20
|
+
disabled = false
|
|
21
|
+
} = _ref;
|
|
22
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
23
|
+
className: (0, _classify.classify)(_StepperModule.default.stepContentWrapper, {
|
|
24
|
+
[_StepperModule.default.active]: active,
|
|
25
|
+
[_StepperModule.default.completed]: completed,
|
|
26
|
+
[_StepperModule.default.disabled]: disabled
|
|
27
|
+
}, classNames?.wrapper)
|
|
28
|
+
}, children);
|
|
29
|
+
};
|
|
30
|
+
exports.StepContent = StepContent;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// @flow strict
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
import {classify} from '../../../utils/classify';
|
|
6
|
+
|
|
7
|
+
import css from '../Stepper.module.css';
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
type ClassNames = $ReadOnly<{wrapper?: string}>;
|
|
11
|
+
|
|
12
|
+
export type StepContentProps = {
|
|
13
|
+
children: React.Node,
|
|
14
|
+
active?: boolean,
|
|
15
|
+
completed?: boolean,
|
|
16
|
+
disabled?: boolean,
|
|
17
|
+
classNames?: ClassNames,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const StepContent = ({
|
|
21
|
+
children,
|
|
22
|
+
classNames,
|
|
23
|
+
active,
|
|
24
|
+
completed = false,
|
|
25
|
+
disabled = false,
|
|
26
|
+
}: StepContentProps): React.Node => (
|
|
27
|
+
<div
|
|
28
|
+
className={classify(
|
|
29
|
+
css.stepContentWrapper,
|
|
30
|
+
{
|
|
31
|
+
[css.active]: active,
|
|
32
|
+
[css.completed]: completed,
|
|
33
|
+
[css.disabled]: disabled,
|
|
34
|
+
},
|
|
35
|
+
classNames?.wrapper,
|
|
36
|
+
)}
|
|
37
|
+
>
|
|
38
|
+
{children}
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
@@ -3,21 +3,28 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.StepLabel = void 0;
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
|
-
var
|
|
8
|
+
var _classify = require("../../../utils/classify");
|
|
9
|
+
var _StepperModule = _interopRequireDefault(require("../Stepper.module.css"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
11
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
10
12
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
+
|
|
14
|
+
const StepLabel = _ref => {
|
|
13
15
|
let {
|
|
14
16
|
children,
|
|
15
|
-
|
|
17
|
+
classNames,
|
|
18
|
+
active,
|
|
19
|
+
completed = false,
|
|
20
|
+
disabled = false
|
|
16
21
|
} = _ref;
|
|
17
|
-
return /*#__PURE__*/React.createElement(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
23
|
+
className: (0, _classify.classify)(_StepperModule.default.stepLabelWrapper, {
|
|
24
|
+
[_StepperModule.default.active]: active,
|
|
25
|
+
[_StepperModule.default.completed]: completed,
|
|
26
|
+
[_StepperModule.default.disabled]: disabled
|
|
27
|
+
}, classNames?.wrapper)
|
|
28
|
+
}, children);
|
|
22
29
|
};
|
|
23
|
-
exports.
|
|
30
|
+
exports.StepLabel = StepLabel;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// @flow strict
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
import {classify} from '../../../utils/classify';
|
|
6
|
+
|
|
7
|
+
import css from '../Stepper.module.css';
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
type ClassNames = $ReadOnly<{wrapper?: string}>;
|
|
11
|
+
|
|
12
|
+
export type StepLabelProps = {
|
|
13
|
+
children: React.Node,
|
|
14
|
+
active?: boolean,
|
|
15
|
+
completed?: boolean,
|
|
16
|
+
disabled?: boolean,
|
|
17
|
+
classNames?: ClassNames,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const StepLabel = ({
|
|
21
|
+
children,
|
|
22
|
+
classNames,
|
|
23
|
+
active,
|
|
24
|
+
completed = false,
|
|
25
|
+
disabled = false,
|
|
26
|
+
}: StepLabelProps): React.Node => (
|
|
27
|
+
<div
|
|
28
|
+
className={classify(
|
|
29
|
+
css.stepLabelWrapper,
|
|
30
|
+
{
|
|
31
|
+
[css.active]: active,
|
|
32
|
+
[css.completed]: completed,
|
|
33
|
+
[css.disabled]: disabled,
|
|
34
|
+
},
|
|
35
|
+
classNames?.wrapper,
|
|
36
|
+
)}
|
|
37
|
+
>
|
|
38
|
+
{children}
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _Step = require("./Step");
|
|
7
|
+
Object.keys(_Step).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _Step[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _Step[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _StepContent = require("./StepContent");
|
|
18
|
+
Object.keys(_StepContent).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _StepContent[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _StepContent[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _StepLabel = require("./StepLabel");
|
|
29
|
+
Object.keys(_StepLabel).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _StepLabel[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _StepLabel[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Stepper = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _classify = require("../../utils/classify");
|
|
9
|
+
var _StepperModule = _interopRequireDefault(require("./Stepper.module.css"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
13
|
+
|
|
14
|
+
const Stepper = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
15
|
+
let {
|
|
16
|
+
activeStep = 0,
|
|
17
|
+
children,
|
|
18
|
+
orientation = 'horizontal',
|
|
19
|
+
classNames,
|
|
20
|
+
disabled = false
|
|
21
|
+
} = _ref;
|
|
22
|
+
const childrenArray = React.Children.toArray(children).filter(Boolean);
|
|
23
|
+
const steps = childrenArray.map((step, index) => {
|
|
24
|
+
let isLastStepCompleted = false;
|
|
25
|
+
const {
|
|
26
|
+
disabled: disabledChild,
|
|
27
|
+
onClick
|
|
28
|
+
} = step.props;
|
|
29
|
+
if (index === 0) {
|
|
30
|
+
isLastStepCompleted = true;
|
|
31
|
+
} else {
|
|
32
|
+
isLastStepCompleted = childrenArray[index - 1]?.props?.completed;
|
|
33
|
+
}
|
|
34
|
+
return /*#__PURE__*/React.cloneElement(step, {
|
|
35
|
+
...step.props,
|
|
36
|
+
index,
|
|
37
|
+
last: index + 1 === childrenArray.length,
|
|
38
|
+
active: index === activeStep,
|
|
39
|
+
allowClick: onClick && index !== activeStep && isLastStepCompleted,
|
|
40
|
+
disabled: disabledChild || disabled
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
44
|
+
className: (0, _classify.classify)(_StepperModule.default.stepperWrapper, _StepperModule.default[orientation], classNames?.wrapper),
|
|
45
|
+
ref: ref
|
|
46
|
+
}, steps);
|
|
47
|
+
});
|
|
48
|
+
exports.Stepper = Stepper;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// @flow strict
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
import {classify} from '../../utils/classify';
|
|
6
|
+
|
|
7
|
+
import css from './Stepper.module.css';
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
type ClassNames = $ReadOnly<{wrapper?: string}>;
|
|
11
|
+
|
|
12
|
+
export type StepperProps = {
|
|
13
|
+
classNames?: ClassNames,
|
|
14
|
+
activeStep?: number,
|
|
15
|
+
children: React.Node,
|
|
16
|
+
orientation?: 'horizontal' | 'vertical',
|
|
17
|
+
disabled?: boolean,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const Stepper: React$AbstractComponent<StepperProps, HTMLDivElement> =
|
|
21
|
+
React.forwardRef<StepperProps, HTMLDivElement>(
|
|
22
|
+
(
|
|
23
|
+
{
|
|
24
|
+
activeStep = 0,
|
|
25
|
+
children,
|
|
26
|
+
orientation = 'horizontal',
|
|
27
|
+
classNames,
|
|
28
|
+
disabled = false,
|
|
29
|
+
}: StepperProps,
|
|
30
|
+
ref,
|
|
31
|
+
) => {
|
|
32
|
+
const childrenArray = React.Children.toArray(children).filter(Boolean);
|
|
33
|
+
const steps = childrenArray.map((step, index) => {
|
|
34
|
+
let isLastStepCompleted = false;
|
|
35
|
+
const {disabled: disabledChild, onClick} = step.props;
|
|
36
|
+
if (index === 0) {
|
|
37
|
+
isLastStepCompleted = true;
|
|
38
|
+
} else {
|
|
39
|
+
isLastStepCompleted = childrenArray[index - 1]?.props?.completed;
|
|
40
|
+
}
|
|
41
|
+
return React.cloneElement(step, {
|
|
42
|
+
...step.props,
|
|
43
|
+
index,
|
|
44
|
+
last: index + 1 === childrenArray.length,
|
|
45
|
+
active: index === activeStep,
|
|
46
|
+
allowClick: onClick && index !== activeStep && isLastStepCompleted,
|
|
47
|
+
disabled: disabledChild || disabled,
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<div
|
|
53
|
+
className={classify(
|
|
54
|
+
css.stepperWrapper,
|
|
55
|
+
css[orientation],
|
|
56
|
+
classNames?.wrapper,
|
|
57
|
+
)}
|
|
58
|
+
ref={ref}
|
|
59
|
+
>
|
|
60
|
+
{steps}
|
|
61
|
+
</div>
|
|
62
|
+
);
|
|
63
|
+
},
|
|
64
|
+
);
|