@elliemae/ds-wizard 3.17.0-next.14 → 3.17.0-next.16
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/dist/cjs/WizardStep.js +2 -2
- package/dist/cjs/WizardStep.js.map +2 -2
- package/dist/cjs/useWizard.js +9 -2
- package/dist/cjs/useWizard.js.map +2 -2
- package/dist/esm/WizardStep.js +2 -2
- package/dist/esm/WizardStep.js.map +2 -2
- package/dist/esm/useWizard.js +9 -2
- package/dist/esm/useWizard.js.map +2 -2
- package/dist/types/WizardStep.d.ts +12 -18
- package/dist/types/useWizard.d.ts +9 -7
- package/package.json +5 -5
- package/dist/types/WizardSteps.d.ts +0 -43
package/dist/cjs/WizardStep.js
CHANGED
|
@@ -63,12 +63,12 @@ const WizardStep = ({
|
|
|
63
63
|
if (completed)
|
|
64
64
|
return iconCompleted;
|
|
65
65
|
return icon;
|
|
66
|
-
}, [active, completed]) || icon;
|
|
66
|
+
}, [active, completed, icon, iconActive, iconCompleted]) || icon;
|
|
67
67
|
const iconWithOptions = (0, import_react.useMemo)(
|
|
68
68
|
() => (0, import_react.isValidElement)(currentIcon) ? (0, import_react.cloneElement)(currentIcon, {
|
|
69
69
|
color: (0, import_ds_utilities.get)(currentIcon, ["props", "color"]) || ["brand-primary", completed ? 600 : 500]
|
|
70
70
|
}) : currentIcon || index + 1,
|
|
71
|
-
[currentIcon]
|
|
71
|
+
[completed, currentIcon, index]
|
|
72
72
|
);
|
|
73
73
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Item, { classProps: { active, completed }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Wrapper, { children: [
|
|
74
74
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(BulletWrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Bullet, { children: iconWithOptions }) }),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/WizardStep.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable indent */\nimport React, { cloneElement, useMemo, isValidElement } from 'react';\nimport { aggregatedClasses } from '@elliemae/ds-classnames';\nimport { get } from '@elliemae/ds-utilities';\nimport { describe, PropTypes } from '@elliemae/ds-props-helpers';\nimport { Checkmark } from '@elliemae/ds-icons';\nimport { indicatorItemBlockName } from './blockNames.js';\n\nconst Item = aggregatedClasses('div')(`${indicatorItemBlockName}`, null, ({ active, completed }) => ({\n active,\n completed,\n}));\nconst Wrapper = aggregatedClasses('div')(`${indicatorItemBlockName}-wrapper`);\nconst Label = aggregatedClasses('span')(indicatorItemBlockName, 'label');\nconst Bullet = aggregatedClasses('div')(indicatorItemBlockName, 'bullet');\nconst BulletWrapper = aggregatedClasses('div')(indicatorItemBlockName, 'bullet-wrapper');\n\nconst WizardStep = ({\n label = '',\n icon = null,\n iconCompleted = <Checkmark />,\n iconActive = null,\n active = false,\n completed = false,\n index = 0,\n}) => {\n const currentIcon =\n useMemo(() => {\n if (active) return iconActive;\n if (completed) return iconCompleted;\n return icon;\n }, [active, completed]) || icon;\n\n const iconWithOptions = useMemo(\n () =>\n isValidElement(currentIcon)\n ? cloneElement(currentIcon, {\n color: get(currentIcon, ['props', 'color']) || ['brand-primary', completed ? 600 : 500],\n })\n : currentIcon || index + 1,\n [currentIcon],\n );\n\n return (\n <Item classProps={{ active, completed }}>\n <Wrapper>\n <BulletWrapper>\n <Bullet>{iconWithOptions}</Bullet>\n </BulletWrapper>\n <Label>{label}</Label>\n </Wrapper>\n </Item>\n );\n};\n\nconst wizzardStepProps = {\n label: PropTypes.string.description('Step label'),\n icon: PropTypes.oneOfType([PropTypes.element, PropTypes.string]).description('Default icon or number'),\n iconCompleted: PropTypes.element.description('Icon when the step is completed').defaultValue(Checkmark),\n iconActive: PropTypes.element.description('Icon when the step is active'),\n active: PropTypes.bool.description('Whether the step is active or not').defaultValue(false),\n completed: PropTypes.bool.description('Whether the step is completed or not').defaultValue(false),\n index: PropTypes.number.description('Current item index'),\n};\n\nWizardStep.propTypes = wizzardStepProps;\nWizardStep.displayName = 'WizardStep';\nconst WizzardStepWithSchema = describe(WizardStep);\nWizzardStepWithSchema.propTypes = wizzardStepProps;\n\nexport { WizzardStepWithSchema };\nexport default WizardStep;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable indent */\nimport React, { cloneElement, useMemo, isValidElement } from 'react';\nimport { aggregatedClasses } from '@elliemae/ds-classnames';\nimport { get } from '@elliemae/ds-utilities';\nimport { describe, PropTypes } from '@elliemae/ds-props-helpers';\nimport { Checkmark } from '@elliemae/ds-icons';\nimport { indicatorItemBlockName } from './blockNames.js';\n\nconst Item = aggregatedClasses('div')(`${indicatorItemBlockName}`, null, ({ active, completed }) => ({\n active,\n completed,\n}));\nconst Wrapper = aggregatedClasses('div')(`${indicatorItemBlockName}-wrapper`);\nconst Label = aggregatedClasses('span')(indicatorItemBlockName, 'label');\nconst Bullet = aggregatedClasses('div')(indicatorItemBlockName, 'bullet');\nconst BulletWrapper = aggregatedClasses('div')(indicatorItemBlockName, 'bullet-wrapper');\n\ninterface WizardStepProps {\n label?: string;\n icon?: React.ReactNode;\n iconCompleted?: React.ReactNode;\n iconActive?: React.ReactNode;\n active?: boolean;\n completed?: boolean;\n index?: number;\n}\n\nconst WizardStep = ({\n label = '',\n icon = null,\n iconCompleted = <Checkmark />,\n iconActive = null,\n active = false,\n completed = false,\n index = 0,\n}: WizardStepProps) => {\n const currentIcon =\n useMemo(() => {\n if (active) return iconActive;\n if (completed) return iconCompleted;\n return icon;\n }, [active, completed, icon, iconActive, iconCompleted]) || icon;\n\n const iconWithOptions = useMemo(\n () =>\n isValidElement(currentIcon)\n ? cloneElement(currentIcon, {\n color: get(currentIcon, ['props', 'color']) || ['brand-primary', completed ? 600 : 500],\n })\n : currentIcon || index + 1,\n [completed, currentIcon, index],\n );\n\n return (\n <Item classProps={{ active, completed }}>\n <Wrapper>\n <BulletWrapper>\n <Bullet>{iconWithOptions}</Bullet>\n </BulletWrapper>\n <Label>{label}</Label>\n </Wrapper>\n </Item>\n );\n};\n\nconst wizzardStepProps = {\n label: PropTypes.string.description('Step label'),\n icon: PropTypes.oneOfType([PropTypes.element, PropTypes.string]).description('Default icon or number'),\n iconCompleted: PropTypes.element.description('Icon when the step is completed').defaultValue(Checkmark),\n iconActive: PropTypes.element.description('Icon when the step is active'),\n active: PropTypes.bool.description('Whether the step is active or not').defaultValue(false),\n completed: PropTypes.bool.description('Whether the step is completed or not').defaultValue(false),\n index: PropTypes.number.description('Current item index'),\n};\n\nWizardStep.propTypes = wizzardStepProps;\nWizardStep.displayName = 'WizardStep';\nconst WizzardStepWithSchema = describe(WizardStep);\nWizzardStepWithSchema.propTypes = wizzardStepProps;\n\nexport { WizzardStepWithSchema };\nexport default WizardStep;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;AD8BL;AA7BlB,mBAA6D;AAC7D,2BAAkC;AAClC,0BAAoB;AACpB,8BAAoC;AACpC,sBAA0B;AAC1B,wBAAuC;AAEvC,MAAM,WAAO,wCAAkB,KAAK,EAAE,GAAG,4CAA0B,MAAM,CAAC,EAAE,QAAQ,UAAU,OAAO;AAAA,EACnG;AAAA,EACA;AACF,EAAE;AACF,MAAM,cAAU,wCAAkB,KAAK,EAAE,GAAG,kDAAgC;AAC5E,MAAM,YAAQ,wCAAkB,MAAM,EAAE,0CAAwB,OAAO;AACvE,MAAM,aAAS,wCAAkB,KAAK,EAAE,0CAAwB,QAAQ;AACxE,MAAM,oBAAgB,wCAAkB,KAAK,EAAE,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EA,WAAW,YAAY;AACvB,WAAW,cAAc;AACzB,MAAM,4BAAwB,kCAAS,UAAU;AACjD,sBAAsB,YAAY;AAGlC,IAAO,qBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/useWizard.js
CHANGED
|
@@ -37,10 +37,17 @@ var import_ds_utilities = require("@elliemae/ds-utilities");
|
|
|
37
37
|
const checkCanNext = (prevIndex, array) => array.length > prevIndex + 1;
|
|
38
38
|
const checkCanPrevious = (prevIndex) => prevIndex - 1 >= 0;
|
|
39
39
|
const noop = (currentStep) => null;
|
|
40
|
-
function useWizard({
|
|
40
|
+
function useWizard({
|
|
41
|
+
steps: wizardSteps,
|
|
42
|
+
current,
|
|
43
|
+
onNext = noop,
|
|
44
|
+
onPrevious = noop,
|
|
45
|
+
initial = 0
|
|
46
|
+
}) {
|
|
41
47
|
const [currentStep, setCurrentStep] = (0, import_react.useState)(initial);
|
|
42
48
|
(0, import_react.useEffect)(() => {
|
|
43
|
-
|
|
49
|
+
if (typeof current !== "undefined")
|
|
50
|
+
setCurrentStep(current);
|
|
44
51
|
}, [current]);
|
|
45
52
|
const handleNext = (0, import_react.useCallback)(() => {
|
|
46
53
|
if (checkCanNext(currentStep, wizardSteps)) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/useWizard.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import { useEffect, useCallback, useState } from 'react';\nimport { get, useDerivedStateFromProps } from '@elliemae/ds-utilities';\n\nconst checkCanNext = (prevIndex: number, array: any[]): boolean => array.length > prevIndex + 1;\nconst checkCanPrevious = (prevIndex: number): boolean => prevIndex - 1 >= 0;\n\nconst noop = (currentStep:
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAiD;AACjD,0BAA8C;AAE9C,MAAM,eAAe,CAAC,WAAmB,UAA0B,MAAM,SAAS,YAAY;AAC9F,MAAM,mBAAmB,CAAC,cAA+B,YAAY,KAAK;AAE1E,MAAM,OAAO,CAAC,
|
|
4
|
+
"sourcesContent": ["import { useEffect, useCallback, useState } from 'react';\nimport { get, useDerivedStateFromProps } from '@elliemae/ds-utilities';\n\nconst checkCanNext = (prevIndex: number, array: any[]): boolean => array.length > prevIndex + 1;\nconst checkCanPrevious = (prevIndex: number): boolean => prevIndex - 1 >= 0;\n\nconst noop = (currentStep: number) => null;\n\ninterface WizardConfig {\n steps: any[];\n current?: number;\n onNext?: (currentStep: number) => void;\n onPrevious?: (currentStep: number) => void;\n initial?: number;\n}\n\nexport default function useWizard({\n steps: wizardSteps,\n current,\n onNext = noop,\n onPrevious = noop,\n initial = 0,\n}: WizardConfig) {\n const [currentStep, setCurrentStep] = useState(initial);\n\n useEffect(() => {\n if (typeof current !== 'undefined') setCurrentStep(current);\n }, [current]);\n\n const handleNext = useCallback(() => {\n if (checkCanNext(currentStep, wizardSteps)) {\n onNext(currentStep);\n setCurrentStep(currentStep + 1);\n }\n }, [currentStep, wizardSteps, onNext]);\n\n const handlePrevious = useCallback(() => {\n if (checkCanPrevious(currentStep)) {\n onPrevious(currentStep);\n setCurrentStep(currentStep - 1);\n }\n }, [currentStep, onPrevious]);\n\n return {\n current: currentStep,\n next: handleNext,\n previous: handlePrevious,\n canNext: checkCanNext(currentStep, wizardSteps),\n canPrevious: checkCanPrevious(currentStep),\n WizardCurrentContent: get(wizardSteps, [currentStep, 'content'], () => null),\n };\n}\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAiD;AACjD,0BAA8C;AAE9C,MAAM,eAAe,CAAC,WAAmB,UAA0B,MAAM,SAAS,YAAY;AAC9F,MAAM,mBAAmB,CAAC,cAA+B,YAAY,KAAK;AAE1E,MAAM,OAAO,CAAC,gBAAwB;AAUvB,SAAR,UAA2B;AAAA,EAChC,OAAO;AAAA,EACP;AAAA,EACA,SAAS;AAAA,EACT,aAAa;AAAA,EACb,UAAU;AACZ,GAAiB;AACf,QAAM,CAAC,aAAa,cAAc,QAAI,uBAAS,OAAO;AAEtD,8BAAU,MAAM;AACd,QAAI,OAAO,YAAY;AAAa,qBAAe,OAAO;AAAA,EAC5D,GAAG,CAAC,OAAO,CAAC;AAEZ,QAAM,iBAAa,0BAAY,MAAM;AACnC,QAAI,aAAa,aAAa,WAAW,GAAG;AAC1C,aAAO,WAAW;AAClB,qBAAe,cAAc,CAAC;AAAA,IAChC;AAAA,EACF,GAAG,CAAC,aAAa,aAAa,MAAM,CAAC;AAErC,QAAM,qBAAiB,0BAAY,MAAM;AACvC,QAAI,iBAAiB,WAAW,GAAG;AACjC,iBAAW,WAAW;AACtB,qBAAe,cAAc,CAAC;AAAA,IAChC;AAAA,EACF,GAAG,CAAC,aAAa,UAAU,CAAC;AAE5B,SAAO;AAAA,IACL,SAAS;AAAA,IACT,MAAM;AAAA,IACN,UAAU;AAAA,IACV,SAAS,aAAa,aAAa,WAAW;AAAA,IAC9C,aAAa,iBAAiB,WAAW;AAAA,IACzC,0BAAsB,yBAAI,aAAa,CAAC,aAAa,SAAS,GAAG,MAAM,IAAI;AAAA,EAC7E;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/WizardStep.js
CHANGED
|
@@ -29,12 +29,12 @@ const WizardStep = ({
|
|
|
29
29
|
if (completed)
|
|
30
30
|
return iconCompleted;
|
|
31
31
|
return icon;
|
|
32
|
-
}, [active, completed]) || icon;
|
|
32
|
+
}, [active, completed, icon, iconActive, iconCompleted]) || icon;
|
|
33
33
|
const iconWithOptions = useMemo(
|
|
34
34
|
() => isValidElement(currentIcon) ? cloneElement(currentIcon, {
|
|
35
35
|
color: get(currentIcon, ["props", "color"]) || ["brand-primary", completed ? 600 : 500]
|
|
36
36
|
}) : currentIcon || index + 1,
|
|
37
|
-
[currentIcon]
|
|
37
|
+
[completed, currentIcon, index]
|
|
38
38
|
);
|
|
39
39
|
return /* @__PURE__ */ jsx(Item, { classProps: { active, completed }, children: /* @__PURE__ */ jsxs(Wrapper, { children: [
|
|
40
40
|
/* @__PURE__ */ jsx(BulletWrapper, { children: /* @__PURE__ */ jsx(Bullet, { children: iconWithOptions }) }),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/WizardStep.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable indent */\nimport React, { cloneElement, useMemo, isValidElement } from 'react';\nimport { aggregatedClasses } from '@elliemae/ds-classnames';\nimport { get } from '@elliemae/ds-utilities';\nimport { describe, PropTypes } from '@elliemae/ds-props-helpers';\nimport { Checkmark } from '@elliemae/ds-icons';\nimport { indicatorItemBlockName } from './blockNames.js';\n\nconst Item = aggregatedClasses('div')(`${indicatorItemBlockName}`, null, ({ active, completed }) => ({\n active,\n completed,\n}));\nconst Wrapper = aggregatedClasses('div')(`${indicatorItemBlockName}-wrapper`);\nconst Label = aggregatedClasses('span')(indicatorItemBlockName, 'label');\nconst Bullet = aggregatedClasses('div')(indicatorItemBlockName, 'bullet');\nconst BulletWrapper = aggregatedClasses('div')(indicatorItemBlockName, 'bullet-wrapper');\n\nconst WizardStep = ({\n label = '',\n icon = null,\n iconCompleted = <Checkmark />,\n iconActive = null,\n active = false,\n completed = false,\n index = 0,\n}) => {\n const currentIcon =\n useMemo(() => {\n if (active) return iconActive;\n if (completed) return iconCompleted;\n return icon;\n }, [active, completed]) || icon;\n\n const iconWithOptions = useMemo(\n () =>\n isValidElement(currentIcon)\n ? cloneElement(currentIcon, {\n color: get(currentIcon, ['props', 'color']) || ['brand-primary', completed ? 600 : 500],\n })\n : currentIcon || index + 1,\n [currentIcon],\n );\n\n return (\n <Item classProps={{ active, completed }}>\n <Wrapper>\n <BulletWrapper>\n <Bullet>{iconWithOptions}</Bullet>\n </BulletWrapper>\n <Label>{label}</Label>\n </Wrapper>\n </Item>\n );\n};\n\nconst wizzardStepProps = {\n label: PropTypes.string.description('Step label'),\n icon: PropTypes.oneOfType([PropTypes.element, PropTypes.string]).description('Default icon or number'),\n iconCompleted: PropTypes.element.description('Icon when the step is completed').defaultValue(Checkmark),\n iconActive: PropTypes.element.description('Icon when the step is active'),\n active: PropTypes.bool.description('Whether the step is active or not').defaultValue(false),\n completed: PropTypes.bool.description('Whether the step is completed or not').defaultValue(false),\n index: PropTypes.number.description('Current item index'),\n};\n\nWizardStep.propTypes = wizzardStepProps;\nWizardStep.displayName = 'WizardStep';\nconst WizzardStepWithSchema = describe(WizardStep);\nWizzardStepWithSchema.propTypes = wizzardStepProps;\n\nexport { WizzardStepWithSchema };\nexport default WizardStep;\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable indent */\nimport React, { cloneElement, useMemo, isValidElement } from 'react';\nimport { aggregatedClasses } from '@elliemae/ds-classnames';\nimport { get } from '@elliemae/ds-utilities';\nimport { describe, PropTypes } from '@elliemae/ds-props-helpers';\nimport { Checkmark } from '@elliemae/ds-icons';\nimport { indicatorItemBlockName } from './blockNames.js';\n\nconst Item = aggregatedClasses('div')(`${indicatorItemBlockName}`, null, ({ active, completed }) => ({\n active,\n completed,\n}));\nconst Wrapper = aggregatedClasses('div')(`${indicatorItemBlockName}-wrapper`);\nconst Label = aggregatedClasses('span')(indicatorItemBlockName, 'label');\nconst Bullet = aggregatedClasses('div')(indicatorItemBlockName, 'bullet');\nconst BulletWrapper = aggregatedClasses('div')(indicatorItemBlockName, 'bullet-wrapper');\n\ninterface WizardStepProps {\n label?: string;\n icon?: React.ReactNode;\n iconCompleted?: React.ReactNode;\n iconActive?: React.ReactNode;\n active?: boolean;\n completed?: boolean;\n index?: number;\n}\n\nconst WizardStep = ({\n label = '',\n icon = null,\n iconCompleted = <Checkmark />,\n iconActive = null,\n active = false,\n completed = false,\n index = 0,\n}: WizardStepProps) => {\n const currentIcon =\n useMemo(() => {\n if (active) return iconActive;\n if (completed) return iconCompleted;\n return icon;\n }, [active, completed, icon, iconActive, iconCompleted]) || icon;\n\n const iconWithOptions = useMemo(\n () =>\n isValidElement(currentIcon)\n ? cloneElement(currentIcon, {\n color: get(currentIcon, ['props', 'color']) || ['brand-primary', completed ? 600 : 500],\n })\n : currentIcon || index + 1,\n [completed, currentIcon, index],\n );\n\n return (\n <Item classProps={{ active, completed }}>\n <Wrapper>\n <BulletWrapper>\n <Bullet>{iconWithOptions}</Bullet>\n </BulletWrapper>\n <Label>{label}</Label>\n </Wrapper>\n </Item>\n );\n};\n\nconst wizzardStepProps = {\n label: PropTypes.string.description('Step label'),\n icon: PropTypes.oneOfType([PropTypes.element, PropTypes.string]).description('Default icon or number'),\n iconCompleted: PropTypes.element.description('Icon when the step is completed').defaultValue(Checkmark),\n iconActive: PropTypes.element.description('Icon when the step is active'),\n active: PropTypes.bool.description('Whether the step is active or not').defaultValue(false),\n completed: PropTypes.bool.description('Whether the step is completed or not').defaultValue(false),\n index: PropTypes.number.description('Current item index'),\n};\n\nWizardStep.propTypes = wizzardStepProps;\nWizardStep.displayName = 'WizardStep';\nconst WizzardStepWithSchema = describe(WizardStep);\nWizzardStepWithSchema.propTypes = wizzardStepProps;\n\nexport { WizzardStepWithSchema };\nexport default WizardStep;\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;AC8BL,cAyBZ,YAzBY;AA7BlB,SAAgB,cAAc,SAAS,sBAAsB;AAC7D,SAAS,yBAAyB;AAClC,SAAS,WAAW;AACpB,SAAS,UAAU,iBAAiB;AACpC,SAAS,iBAAiB;AAC1B,SAAS,8BAA8B;AAEvC,MAAM,OAAO,kBAAkB,KAAK,EAAE,GAAG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Q,YAAY,iCAAiC,EAAE,aAAa,SAAS;AAAA,EACtG,YAAY,UAAU,QAAQ,YAAY,8BAA8B;AAAA,EACxE,QAAQ,UAAU,KAAK,YAAY,mCAAmC,EAAE,aAAa,KAAK;AAAA,EAC1F,WAAW,UAAU,KAAK,YAAY,sCAAsC,EAAE,aAAa,KAAK;AAAA,EAChG,OAAO,UAAU,OAAO,YAAY,oBAAoB;AAC1D;AAEA,WAAW,YAAY;AACvB,WAAW,cAAc;AACzB,MAAM,wBAAwB,SAAS,UAAU;AACjD,sBAAsB,YAAY;AAGlC,IAAO,qBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/useWizard.js
CHANGED
|
@@ -4,10 +4,17 @@ import { get } from "@elliemae/ds-utilities";
|
|
|
4
4
|
const checkCanNext = (prevIndex, array) => array.length > prevIndex + 1;
|
|
5
5
|
const checkCanPrevious = (prevIndex) => prevIndex - 1 >= 0;
|
|
6
6
|
const noop = (currentStep) => null;
|
|
7
|
-
function useWizard({
|
|
7
|
+
function useWizard({
|
|
8
|
+
steps: wizardSteps,
|
|
9
|
+
current,
|
|
10
|
+
onNext = noop,
|
|
11
|
+
onPrevious = noop,
|
|
12
|
+
initial = 0
|
|
13
|
+
}) {
|
|
8
14
|
const [currentStep, setCurrentStep] = useState(initial);
|
|
9
15
|
useEffect(() => {
|
|
10
|
-
|
|
16
|
+
if (typeof current !== "undefined")
|
|
17
|
+
setCurrentStep(current);
|
|
11
18
|
}, [current]);
|
|
12
19
|
const handleNext = useCallback(() => {
|
|
13
20
|
if (checkCanNext(currentStep, wizardSteps)) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/useWizard.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useEffect, useCallback, useState } from 'react';\nimport { get, useDerivedStateFromProps } from '@elliemae/ds-utilities';\n\nconst checkCanNext = (prevIndex: number, array: any[]): boolean => array.length > prevIndex + 1;\nconst checkCanPrevious = (prevIndex: number): boolean => prevIndex - 1 >= 0;\n\nconst noop = (currentStep:
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,WAAW,aAAa,gBAAgB;AACjD,SAAS,WAAqC;AAE9C,MAAM,eAAe,CAAC,WAAmB,UAA0B,MAAM,SAAS,YAAY;AAC9F,MAAM,mBAAmB,CAAC,cAA+B,YAAY,KAAK;AAE1E,MAAM,OAAO,CAAC,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useEffect, useCallback, useState } from 'react';\nimport { get, useDerivedStateFromProps } from '@elliemae/ds-utilities';\n\nconst checkCanNext = (prevIndex: number, array: any[]): boolean => array.length > prevIndex + 1;\nconst checkCanPrevious = (prevIndex: number): boolean => prevIndex - 1 >= 0;\n\nconst noop = (currentStep: number) => null;\n\ninterface WizardConfig {\n steps: any[];\n current?: number;\n onNext?: (currentStep: number) => void;\n onPrevious?: (currentStep: number) => void;\n initial?: number;\n}\n\nexport default function useWizard({\n steps: wizardSteps,\n current,\n onNext = noop,\n onPrevious = noop,\n initial = 0,\n}: WizardConfig) {\n const [currentStep, setCurrentStep] = useState(initial);\n\n useEffect(() => {\n if (typeof current !== 'undefined') setCurrentStep(current);\n }, [current]);\n\n const handleNext = useCallback(() => {\n if (checkCanNext(currentStep, wizardSteps)) {\n onNext(currentStep);\n setCurrentStep(currentStep + 1);\n }\n }, [currentStep, wizardSteps, onNext]);\n\n const handlePrevious = useCallback(() => {\n if (checkCanPrevious(currentStep)) {\n onPrevious(currentStep);\n setCurrentStep(currentStep - 1);\n }\n }, [currentStep, onPrevious]);\n\n return {\n current: currentStep,\n next: handleNext,\n previous: handlePrevious,\n canNext: checkCanNext(currentStep, wizardSteps),\n canPrevious: checkCanPrevious(currentStep),\n WizardCurrentContent: get(wizardSteps, [currentStep, 'content'], () => null),\n };\n}\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,WAAW,aAAa,gBAAgB;AACjD,SAAS,WAAqC;AAE9C,MAAM,eAAe,CAAC,WAAmB,UAA0B,MAAM,SAAS,YAAY;AAC9F,MAAM,mBAAmB,CAAC,cAA+B,YAAY,KAAK;AAE1E,MAAM,OAAO,CAAC,gBAAwB;AAUvB,SAAR,UAA2B;AAAA,EAChC,OAAO;AAAA,EACP;AAAA,EACA,SAAS;AAAA,EACT,aAAa;AAAA,EACb,UAAU;AACZ,GAAiB;AACf,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,OAAO;AAEtD,YAAU,MAAM;AACd,QAAI,OAAO,YAAY;AAAa,qBAAe,OAAO;AAAA,EAC5D,GAAG,CAAC,OAAO,CAAC;AAEZ,QAAM,aAAa,YAAY,MAAM;AACnC,QAAI,aAAa,aAAa,WAAW,GAAG;AAC1C,aAAO,WAAW;AAClB,qBAAe,cAAc,CAAC;AAAA,IAChC;AAAA,EACF,GAAG,CAAC,aAAa,aAAa,MAAM,CAAC;AAErC,QAAM,iBAAiB,YAAY,MAAM;AACvC,QAAI,iBAAiB,WAAW,GAAG;AACjC,iBAAW,WAAW;AACtB,qBAAe,cAAc,CAAC;AAAA,IAChC;AAAA,EACF,GAAG,CAAC,aAAa,UAAU,CAAC;AAE5B,SAAO;AAAA,IACL,SAAS;AAAA,IACT,MAAM;AAAA,IACN,UAAU;AAAA,IACV,SAAS,aAAa,aAAa,WAAW;AAAA,IAC9C,aAAa,iBAAiB,WAAW;AAAA,IACzC,sBAAsB,IAAI,aAAa,CAAC,aAAa,SAAS,GAAG,MAAM,IAAI;AAAA,EAC7E;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface WizardStepProps {
|
|
3
|
+
label?: string;
|
|
4
|
+
icon?: React.ReactNode;
|
|
5
|
+
iconCompleted?: React.ReactNode;
|
|
6
|
+
iconActive?: React.ReactNode;
|
|
7
|
+
active?: boolean;
|
|
8
|
+
completed?: boolean;
|
|
9
|
+
index?: number;
|
|
10
|
+
}
|
|
1
11
|
declare const WizardStep: {
|
|
2
|
-
({ label, icon, iconCompleted, iconActive, active, completed, index, }:
|
|
3
|
-
label?: string | undefined;
|
|
4
|
-
icon?: null | undefined;
|
|
5
|
-
iconCompleted?: import("react/jsx-runtime.js").JSX.Element | undefined;
|
|
6
|
-
iconActive?: null | undefined;
|
|
7
|
-
active?: boolean | undefined;
|
|
8
|
-
completed?: boolean | undefined;
|
|
9
|
-
index?: number | undefined;
|
|
10
|
-
}): import("react/jsx-runtime.js").JSX.Element;
|
|
12
|
+
({ label, icon, iconCompleted, iconActive, active, completed, index, }: WizardStepProps): import("react/jsx-runtime.js").JSX.Element;
|
|
11
13
|
propTypes: {
|
|
12
14
|
label: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").ReactDescT;
|
|
13
15
|
icon: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").ReactDescT;
|
|
@@ -19,14 +21,6 @@ declare const WizardStep: {
|
|
|
19
21
|
};
|
|
20
22
|
displayName: string;
|
|
21
23
|
};
|
|
22
|
-
declare const WizzardStepWithSchema: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").DocumentedReactComponent<
|
|
23
|
-
label?: string | undefined;
|
|
24
|
-
icon?: null | undefined;
|
|
25
|
-
iconCompleted?: import("react/jsx-runtime.js").JSX.Element | undefined;
|
|
26
|
-
iconActive?: null | undefined;
|
|
27
|
-
active?: boolean | undefined;
|
|
28
|
-
completed?: boolean | undefined;
|
|
29
|
-
index?: number | undefined;
|
|
30
|
-
}>;
|
|
24
|
+
declare const WizzardStepWithSchema: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").DocumentedReactComponent<WizardStepProps>;
|
|
31
25
|
export { WizzardStepWithSchema };
|
|
32
26
|
export default WizardStep;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
steps: any;
|
|
3
|
-
current
|
|
4
|
-
onNext?: (
|
|
5
|
-
onPrevious?: (
|
|
6
|
-
initial?: number
|
|
7
|
-
}
|
|
1
|
+
interface WizardConfig {
|
|
2
|
+
steps: any[];
|
|
3
|
+
current?: number;
|
|
4
|
+
onNext?: (currentStep: number) => void;
|
|
5
|
+
onPrevious?: (currentStep: number) => void;
|
|
6
|
+
initial?: number;
|
|
7
|
+
}
|
|
8
|
+
export default function useWizard({ steps: wizardSteps, current, onNext, onPrevious, initial, }: WizardConfig): {
|
|
8
9
|
current: number;
|
|
9
10
|
next: () => void;
|
|
10
11
|
previous: () => void;
|
|
@@ -12,3 +13,4 @@ export default function useWizard({ steps: wizardSteps, current, onNext, onPrevi
|
|
|
12
13
|
canPrevious: boolean;
|
|
13
14
|
WizardCurrentContent: any;
|
|
14
15
|
};
|
|
16
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-wizard",
|
|
3
|
-
"version": "3.17.0-next.
|
|
3
|
+
"version": "3.17.0-next.16",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Wizard",
|
|
6
6
|
"files": [
|
|
@@ -55,10 +55,10 @@
|
|
|
55
55
|
"indent": 4
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@elliemae/ds-classnames": "3.17.0-next.
|
|
59
|
-
"@elliemae/ds-icons": "3.17.0-next.
|
|
60
|
-
"@elliemae/ds-props-helpers": "3.17.0-next.
|
|
61
|
-
"@elliemae/ds-utilities": "3.17.0-next.
|
|
58
|
+
"@elliemae/ds-classnames": "3.17.0-next.16",
|
|
59
|
+
"@elliemae/ds-icons": "3.17.0-next.16",
|
|
60
|
+
"@elliemae/ds-props-helpers": "3.17.0-next.16",
|
|
61
|
+
"@elliemae/ds-utilities": "3.17.0-next.16"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"lodash": "^4.17.21",
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
declare const WizardSteps: {
|
|
2
|
-
({ current, steps, children, ...otherProps }: {
|
|
3
|
-
[x: string]: any;
|
|
4
|
-
current?: number | undefined;
|
|
5
|
-
steps: any;
|
|
6
|
-
children: any;
|
|
7
|
-
}): import("react/jsx-runtime.js").JSX.Element;
|
|
8
|
-
Item: {
|
|
9
|
-
({ label, icon, iconCompleted, iconActive, active, completed, index, }: {
|
|
10
|
-
label?: string | undefined;
|
|
11
|
-
icon?: null | undefined;
|
|
12
|
-
iconCompleted?: import("react/jsx-runtime.js").JSX.Element | undefined;
|
|
13
|
-
iconActive?: null | undefined;
|
|
14
|
-
active?: boolean | undefined;
|
|
15
|
-
completed?: boolean | undefined;
|
|
16
|
-
index?: number | undefined;
|
|
17
|
-
}): import("react/jsx-runtime.js").JSX.Element;
|
|
18
|
-
propTypes: {
|
|
19
|
-
label: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").ReactDescT;
|
|
20
|
-
icon: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").ReactDescT;
|
|
21
|
-
iconCompleted: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").ReactDescT;
|
|
22
|
-
iconActive: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").ReactDescT;
|
|
23
|
-
active: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").ReactDescT;
|
|
24
|
-
completed: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").ReactDescT;
|
|
25
|
-
index: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").ReactDescT;
|
|
26
|
-
};
|
|
27
|
-
displayName: string;
|
|
28
|
-
};
|
|
29
|
-
propTypes: {
|
|
30
|
-
current: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").ReactDescT;
|
|
31
|
-
steps: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").ReactDescT;
|
|
32
|
-
children: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").ReactDescT;
|
|
33
|
-
};
|
|
34
|
-
displayName: string;
|
|
35
|
-
};
|
|
36
|
-
declare const WizzardWithSchema: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").DocumentedReactComponent<{
|
|
37
|
-
[x: string]: any;
|
|
38
|
-
current?: number | undefined;
|
|
39
|
-
steps: any;
|
|
40
|
-
children: any;
|
|
41
|
-
}>;
|
|
42
|
-
export { WizzardWithSchema };
|
|
43
|
-
export default WizardSteps;
|