@veritone-ce/design-system 2.4.17 → 2.4.18

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.
@@ -1,130 +0,0 @@
1
- 'use strict';
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, '__esModule', { value: true });
5
-
6
- var jsxRuntime = require('react/jsx-runtime');
7
- var React = require('react');
8
- var index = require('../Box/index.js');
9
- var index$1 = require('../Button/index.js');
10
- var index$2 = require('../Typography/index.js');
11
- require('@capsizecss/core');
12
- require('color2k');
13
- require('../styles/css-vars.js');
14
- var defaultTheme = require('../styles/defaultTheme.js');
15
- require('@mui/system');
16
- require('../styles/styled.js');
17
- var styles_module = require('./styles.module.scss.js');
18
-
19
- const Stepper = ({
20
- steps,
21
- onCancel,
22
- onFinish,
23
- backLabel = "Back",
24
- cancelLabel = "Cancel",
25
- nextLabel = "Next",
26
- finishLabel = "Finish"
27
- }) => {
28
- const [activeStep, setActiveStep] = React.useState(0);
29
- const [completed, setCompleted] = React.useState({});
30
- const totalSteps = () => {
31
- return steps.length;
32
- };
33
- const completedSteps = () => {
34
- return Object.keys(completed).length;
35
- };
36
- const isLastStep = () => {
37
- return activeStep === totalSteps() - 1;
38
- };
39
- const allStepsCompleted = () => {
40
- return completedSteps() === totalSteps();
41
- };
42
- const handleNext = () => {
43
- const newActiveStep = isLastStep() && !allStepsCompleted() ? (
44
- // It's the last step, but not all steps have been completed,
45
- // find the first step that has been completed
46
- steps.findIndex((step, i) => !(i in completed))
47
- ) : activeStep + 1;
48
- setActiveStep(newActiveStep);
49
- };
50
- const handleBack = () => {
51
- setActiveStep((prevActiveStep) => prevActiveStep - 1);
52
- };
53
- const handleChangeStep = (selectedStep) => () => {
54
- if (selectedStep < activeStep) {
55
- setActiveStep(selectedStep);
56
- } else if (steps[activeStep]?.validateStep()) {
57
- setActiveStep(selectedStep);
58
- }
59
- };
60
- const handleCompleteStep = () => {
61
- const newCompleted = completed;
62
- newCompleted[activeStep] = true;
63
- setCompleted(newCompleted);
64
- if (!isLastStep()) {
65
- handleNext();
66
- } else {
67
- handleFinishForm();
68
- }
69
- };
70
- const handleCancel = () => {
71
- setActiveStep(0);
72
- setCompleted({});
73
- onCancel();
74
- };
75
- const handleFinishForm = () => {
76
- onFinish();
77
- };
78
- return /* @__PURE__ */ jsxRuntime.jsxs(index.default, { className: styles_module.default.stepperWrapper, children: [
79
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_module.default.stepperContainer, children: steps.map((step, index) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles_module.default.step, children: [
80
- /* @__PURE__ */ jsxRuntime.jsx(
81
- index$1.default,
82
- {
83
- palette: defaultTheme.defaultThemeCssVariableUsages.palette.action.secondary,
84
- variant: activeStep === index ? "primary" : "secondary",
85
- onClick: handleChangeStep(index),
86
- className: styles_module.default.stepButton,
87
- children: index + 1
88
- }
89
- ),
90
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_module.default.stepLabel, onClick: handleChangeStep(index), children: /* @__PURE__ */ jsxRuntime.jsx(index$2.default, { variant: "paragraph2", color: "primary", children: step.label }) }),
91
- index !== steps.length - 1 && /* @__PURE__ */ jsxRuntime.jsx("hr", { className: styles_module.default.stepperLine })
92
- ] }, step.label)) }),
93
- steps.map((step, index) => {
94
- if (index === activeStep) {
95
- return /* @__PURE__ */ jsxRuntime.jsx("div", { children: index === activeStep && step.step }, index);
96
- }
97
- }),
98
- /* @__PURE__ */ jsxRuntime.jsxs(index.default, { className: styles_module.default.buttonRowBottom, children: [
99
- activeStep !== 0 && /* @__PURE__ */ jsxRuntime.jsx(
100
- index$1.default,
101
- {
102
- variant: "secondary",
103
- disabled: activeStep === 0,
104
- onClick: handleBack,
105
- children: backLabel
106
- }
107
- ),
108
- /* @__PURE__ */ jsxRuntime.jsx(index.default, { sx: { flex: "1 1 auto" } }),
109
- /* @__PURE__ */ jsxRuntime.jsx(
110
- index$1.default,
111
- {
112
- variant: "tertiary",
113
- onClick: handleCancel,
114
- style: { marginRight: "10px" },
115
- children: cancelLabel
116
- }
117
- ),
118
- /* @__PURE__ */ jsxRuntime.jsx(
119
- index$1.default,
120
- {
121
- disabled: !steps[activeStep]?.validateStep(),
122
- onClick: handleCompleteStep,
123
- children: isLastStep() ? finishLabel : nextLabel
124
- }
125
- )
126
- ] })
127
- ] });
128
- };
129
-
130
- exports.default = Stepper;
@@ -1,126 +0,0 @@
1
- 'use strict';
2
- import { jsxs, jsx } from 'react/jsx-runtime';
3
- import React__default from 'react';
4
- import Box from '../Box/index.js';
5
- import Button from '../Button/index.js';
6
- import Typography from '../Typography/index.js';
7
- import '@capsizecss/core';
8
- import 'color2k';
9
- import '../styles/css-vars.js';
10
- import { defaultThemeCssVariableUsages } from '../styles/defaultTheme.js';
11
- import '@mui/system';
12
- import '../styles/styled.js';
13
- import styles from './styles.module.scss.js';
14
-
15
- const Stepper = ({
16
- steps,
17
- onCancel,
18
- onFinish,
19
- backLabel = "Back",
20
- cancelLabel = "Cancel",
21
- nextLabel = "Next",
22
- finishLabel = "Finish"
23
- }) => {
24
- const [activeStep, setActiveStep] = React__default.useState(0);
25
- const [completed, setCompleted] = React__default.useState({});
26
- const totalSteps = () => {
27
- return steps.length;
28
- };
29
- const completedSteps = () => {
30
- return Object.keys(completed).length;
31
- };
32
- const isLastStep = () => {
33
- return activeStep === totalSteps() - 1;
34
- };
35
- const allStepsCompleted = () => {
36
- return completedSteps() === totalSteps();
37
- };
38
- const handleNext = () => {
39
- const newActiveStep = isLastStep() && !allStepsCompleted() ? (
40
- // It's the last step, but not all steps have been completed,
41
- // find the first step that has been completed
42
- steps.findIndex((step, i) => !(i in completed))
43
- ) : activeStep + 1;
44
- setActiveStep(newActiveStep);
45
- };
46
- const handleBack = () => {
47
- setActiveStep((prevActiveStep) => prevActiveStep - 1);
48
- };
49
- const handleChangeStep = (selectedStep) => () => {
50
- if (selectedStep < activeStep) {
51
- setActiveStep(selectedStep);
52
- } else if (steps[activeStep]?.validateStep()) {
53
- setActiveStep(selectedStep);
54
- }
55
- };
56
- const handleCompleteStep = () => {
57
- const newCompleted = completed;
58
- newCompleted[activeStep] = true;
59
- setCompleted(newCompleted);
60
- if (!isLastStep()) {
61
- handleNext();
62
- } else {
63
- handleFinishForm();
64
- }
65
- };
66
- const handleCancel = () => {
67
- setActiveStep(0);
68
- setCompleted({});
69
- onCancel();
70
- };
71
- const handleFinishForm = () => {
72
- onFinish();
73
- };
74
- return /* @__PURE__ */ jsxs(Box, { className: styles.stepperWrapper, children: [
75
- /* @__PURE__ */ jsx("div", { className: styles.stepperContainer, children: steps.map((step, index) => /* @__PURE__ */ jsxs("div", { className: styles.step, children: [
76
- /* @__PURE__ */ jsx(
77
- Button,
78
- {
79
- palette: defaultThemeCssVariableUsages.palette.action.secondary,
80
- variant: activeStep === index ? "primary" : "secondary",
81
- onClick: handleChangeStep(index),
82
- className: styles.stepButton,
83
- children: index + 1
84
- }
85
- ),
86
- /* @__PURE__ */ jsx("div", { className: styles.stepLabel, onClick: handleChangeStep(index), children: /* @__PURE__ */ jsx(Typography, { variant: "paragraph2", color: "primary", children: step.label }) }),
87
- index !== steps.length - 1 && /* @__PURE__ */ jsx("hr", { className: styles.stepperLine })
88
- ] }, step.label)) }),
89
- steps.map((step, index) => {
90
- if (index === activeStep) {
91
- return /* @__PURE__ */ jsx("div", { children: index === activeStep && step.step }, index);
92
- }
93
- }),
94
- /* @__PURE__ */ jsxs(Box, { className: styles.buttonRowBottom, children: [
95
- activeStep !== 0 && /* @__PURE__ */ jsx(
96
- Button,
97
- {
98
- variant: "secondary",
99
- disabled: activeStep === 0,
100
- onClick: handleBack,
101
- children: backLabel
102
- }
103
- ),
104
- /* @__PURE__ */ jsx(Box, { sx: { flex: "1 1 auto" } }),
105
- /* @__PURE__ */ jsx(
106
- Button,
107
- {
108
- variant: "tertiary",
109
- onClick: handleCancel,
110
- style: { marginRight: "10px" },
111
- children: cancelLabel
112
- }
113
- ),
114
- /* @__PURE__ */ jsx(
115
- Button,
116
- {
117
- disabled: !steps[activeStep]?.validateStep(),
118
- onClick: handleCompleteStep,
119
- children: isLastStep() ? finishLabel : nextLabel
120
- }
121
- )
122
- ] })
123
- ] });
124
- };
125
-
126
- export { Stepper as default };