@elliemae/ds-wizard 1.57.0-rc.1 → 1.57.0-rc.13
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/cjs/WizardStep.js +5 -6
- package/cjs/WizardStep.js.map +1 -1
- package/cjs/WizardSteps.js +2 -2
- package/cjs/index.js +2 -3
- package/cjs/index.js.map +1 -1
- package/cjs/useWizard.js +3 -5
- package/cjs/useWizard.js.map +1 -1
- package/esm/WizardStep.js +2 -2
- package/esm/WizardStep.js.map +1 -1
- package/esm/WizardSteps.js +2 -2
- package/esm/index.js +2 -3
- package/esm/index.js.map +1 -1
- package/esm/useWizard.js +1 -2
- package/esm/useWizard.js.map +1 -1
- package/package.json +5 -5
package/cjs/WizardStep.js
CHANGED
|
@@ -5,14 +5,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var reactDesc = require('react-desc');
|
|
7
7
|
var dsClassnames = require('@elliemae/ds-classnames');
|
|
8
|
-
var
|
|
9
|
-
var
|
|
8
|
+
var dsUtilities = require('@elliemae/ds-utilities');
|
|
9
|
+
var dsIcons = require('@elliemae/ds-icons');
|
|
10
10
|
var blockNames = require('./blockNames.js');
|
|
11
11
|
|
|
12
12
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
13
|
|
|
14
14
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
15
|
-
var Checkmark__default = /*#__PURE__*/_interopDefaultLegacy(Checkmark);
|
|
16
15
|
|
|
17
16
|
/* eslint-disable indent */
|
|
18
17
|
var Item = dsClassnames.aggregatedClasses('div')("".concat(blockNames.indicatorItemBlockName), null, function (_ref) {
|
|
@@ -34,7 +33,7 @@ function WizardStep(_ref2) {
|
|
|
34
33
|
_ref2$icon = _ref2.icon,
|
|
35
34
|
icon = _ref2$icon === void 0 ? null : _ref2$icon,
|
|
36
35
|
_ref2$iconCompleted = _ref2.iconCompleted,
|
|
37
|
-
iconCompleted = _ref2$iconCompleted === void 0 ? /*#__PURE__*/React__default['default'].createElement(
|
|
36
|
+
iconCompleted = _ref2$iconCompleted === void 0 ? /*#__PURE__*/React__default['default'].createElement(dsIcons.Checkmark, null) : _ref2$iconCompleted,
|
|
38
37
|
_ref2$iconActive = _ref2.iconActive,
|
|
39
38
|
iconActive = _ref2$iconActive === void 0 ? null : _ref2$iconActive,
|
|
40
39
|
_ref2$active = _ref2.active,
|
|
@@ -50,7 +49,7 @@ function WizardStep(_ref2) {
|
|
|
50
49
|
}, [active, completed]) || icon;
|
|
51
50
|
var iconWithOptions = React.useMemo(function () {
|
|
52
51
|
return /*#__PURE__*/React.isValidElement(currentIcon) ? /*#__PURE__*/React.cloneElement(currentIcon, {
|
|
53
|
-
color:
|
|
52
|
+
color: dsUtilities.get(currentIcon, ['props', 'color']) || ['brand-primary', completed ? 600 : 500]
|
|
54
53
|
}) : currentIcon || index + 1;
|
|
55
54
|
}, [currentIcon]);
|
|
56
55
|
return /*#__PURE__*/React__default['default'].createElement(Item, {
|
|
@@ -64,7 +63,7 @@ function WizardStep(_ref2) {
|
|
|
64
63
|
var wizzardStepProps = {
|
|
65
64
|
label: reactDesc.PropTypes.string.description('Step label'),
|
|
66
65
|
icon: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.element, reactDesc.PropTypes.string]).description('Default icon or number'),
|
|
67
|
-
iconCompleted: reactDesc.PropTypes.element.description('Icon when the step is completed').defaultValue(
|
|
66
|
+
iconCompleted: reactDesc.PropTypes.element.description('Icon when the step is completed').defaultValue(dsIcons.Checkmark),
|
|
68
67
|
iconActive: reactDesc.PropTypes.element.description('Icon when the step is active'),
|
|
69
68
|
active: reactDesc.PropTypes.bool.description('Whether the step is active or not').defaultValue(false),
|
|
70
69
|
completed: reactDesc.PropTypes.bool.description('Whether the step is completed or not').defaultValue(false),
|
package/cjs/WizardStep.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WizardStep.js","sources":["../../src/WizardStep.tsx"],"sourcesContent":["/* eslint-disable indent */\nimport React, { cloneElement, useMemo, isValidElement } from 'react';\nimport { describe, PropTypes } from 'react-desc';\nimport { aggregatedClasses } from '@elliemae/ds-classnames';\nimport { get } from '@elliemae/ds-utilities
|
|
1
|
+
{"version":3,"file":"WizardStep.js","sources":["../../src/WizardStep.tsx"],"sourcesContent":["/* eslint-disable indent */\nimport React, { cloneElement, useMemo, isValidElement } from 'react';\nimport { describe, PropTypes } from 'react-desc';\nimport { aggregatedClasses } from '@elliemae/ds-classnames';\nimport { get } from '@elliemae/ds-utilities';\nimport { Checkmark } from '@elliemae/ds-icons';\nimport { indicatorItemBlockName } from './blockNames';\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\nfunction 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;\n\nconst WizzardStepWithSchema = describe(WizardStep);\nWizzardStepWithSchema.propTypes = wizzardStepProps;\n\nexport { WizzardStepWithSchema };\nexport default WizardStep;\n"],"names":["Item","aggregatedClasses","indicatorItemBlockName","active","completed","Wrapper","Label","Bullet","BulletWrapper","WizardStep","label","icon","iconCompleted","React","Checkmark","iconActive","index","currentIcon","useMemo","iconWithOptions","isValidElement","cloneElement","color","get","wizzardStepProps","PropTypes","string","description","oneOfType","element","defaultValue","bool","number","propTypes","WizzardStepWithSchema","describe"],"mappings":";;;;;;;;;;;;;;;AAAA;AAQA,IAAMA,IAAI,GAAGC,8BAAiB,CAAC,KAAD,CAAjB,WAA4BC,iCAA5B,GAAsD,IAAtD,EAA4D;AAAA,MAAGC,MAAH,QAAGA,MAAH;AAAA,MAAWC,SAAX,QAAWA,SAAX;AAAA,SAA4B;AACnGD,IAAAA,MAAM,EAANA,MADmG;AAEnGC,IAAAA,SAAS,EAATA;AAFmG,GAA5B;AAAA,CAA5D,CAAb;AAIA,IAAMC,OAAO,GAAGJ,8BAAiB,CAAC,KAAD,CAAjB,WAA4BC,iCAA5B,cAAhB;AACA,IAAMI,KAAK,GAAGL,8BAAiB,CAAC,MAAD,CAAjB,CAA0BC,iCAA1B,EAAkD,OAAlD,CAAd;AACA,IAAMK,MAAM,GAAGN,8BAAiB,CAAC,KAAD,CAAjB,CAAyBC,iCAAzB,EAAiD,QAAjD,CAAf;AACA,IAAMM,aAAa,GAAGP,8BAAiB,CAAC,KAAD,CAAjB,CAAyBC,iCAAzB,EAAiD,gBAAjD,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F;AAUD;;AAED,IAAMc,gBAAgB,GAAG;AACvBd,EAAAA,KAAK,EAAEe,mBAAS,CAACC,MAAV,CAAiBC,WAAjB,CAA6B,YAA7B,CADgB;AAEvBhB,EAAAA,IAAI,EAAEc,mBAAS,CAACG,SAAV,CAAoB,CAACH,mBAAS,CAACI,OAAX,EAAoBJ,mBAAS,CAACC,MAA9B,CAApB,EAA2DC,WAA3D,CAAuE,wBAAvE,CAFiB;AAGvBf,EAAAA,aAAa,EAAEa,mBAAS,CAACI,OAAV,CAAkBF,WAAlB,CAA8B,iCAA9B,EAAiEG,YAAjE,CAA8EhB,iBAA9E,CAHQ;AAIvBC,EAAAA,UAAU,EAAEU,mBAAS,CAACI,OAAV,CAAkBF,WAAlB,CAA8B,8BAA9B,CAJW;AAKvBxB,EAAAA,MAAM,EAAEsB,mBAAS,CAACM,IAAV,CAAeJ,WAAf,CAA2B,mCAA3B,EAAgEG,YAAhE,CAA6E,KAA7E,CALe;AAMvB1B,EAAAA,SAAS,EAAEqB,mBAAS,CAACM,IAAV,CAAeJ,WAAf,CAA2B,sCAA3B,EAAmEG,YAAnE,CAAgF,KAAhF,CANY;AAOvBd,EAAAA,KAAK,EAAES,mBAAS,CAACO,MAAV,CAAiBL,WAAjB,CAA6B,oBAA7B;AAPgB,CAAzB;AAUAlB,UAAU,CAACwB,SAAX,GAAuBT,gBAAvB;IAEMU,qBAAqB,GAAGC,kBAAQ,CAAC1B,UAAD;AACtCyB,qBAAqB,CAACD,SAAtB,GAAkCT,gBAAlC;;;;;"}
|
package/cjs/WizardSteps.js
CHANGED
|
@@ -9,8 +9,8 @@ var reactDesc = require('react-desc');
|
|
|
9
9
|
var dsClassnames = require('@elliemae/ds-classnames');
|
|
10
10
|
var WizardStep = require('./WizardStep.js');
|
|
11
11
|
var blockNames = require('./blockNames.js');
|
|
12
|
-
require('@elliemae/ds-utilities
|
|
13
|
-
require('@elliemae/ds-icons
|
|
12
|
+
require('@elliemae/ds-utilities');
|
|
13
|
+
require('@elliemae/ds-icons');
|
|
14
14
|
|
|
15
15
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
16
16
|
|
package/cjs/index.js
CHANGED
|
@@ -11,10 +11,9 @@ require('react');
|
|
|
11
11
|
require('react-desc');
|
|
12
12
|
require('@elliemae/ds-classnames');
|
|
13
13
|
require('./blockNames.js');
|
|
14
|
-
require('@elliemae/ds-utilities
|
|
15
|
-
require('@elliemae/ds-icons
|
|
14
|
+
require('@elliemae/ds-utilities');
|
|
15
|
+
require('@elliemae/ds-icons');
|
|
16
16
|
require('@babel/runtime/helpers/slicedToArray');
|
|
17
|
-
require('@elliemae/ds-utilities/hooks/useDerivedStateFromProps');
|
|
18
17
|
|
|
19
18
|
|
|
20
19
|
|
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;"}
|
package/cjs/useWizard.js
CHANGED
|
@@ -2,13 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
4
4
|
var React = require('react');
|
|
5
|
-
var
|
|
6
|
-
var useDerivedStateFromProps = require('@elliemae/ds-utilities/hooks/useDerivedStateFromProps');
|
|
5
|
+
var dsUtilities = require('@elliemae/ds-utilities');
|
|
7
6
|
|
|
8
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
8
|
|
|
10
9
|
var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
|
|
11
|
-
var useDerivedStateFromProps__default = /*#__PURE__*/_interopDefaultLegacy(useDerivedStateFromProps);
|
|
12
10
|
|
|
13
11
|
var checkCanNext = function checkCanNext(prevIndex, array) {
|
|
14
12
|
return array.length > prevIndex + 1;
|
|
@@ -32,7 +30,7 @@ function useWizard(_ref) {
|
|
|
32
30
|
_ref$initial = _ref.initial,
|
|
33
31
|
initial = _ref$initial === void 0 ? 0 : _ref$initial;
|
|
34
32
|
|
|
35
|
-
var _useDerivedStateFromP =
|
|
33
|
+
var _useDerivedStateFromP = dsUtilities.useDerivedStateFromProps(current || initial),
|
|
36
34
|
_useDerivedStateFromP2 = _slicedToArray__default['default'](_useDerivedStateFromP, 2),
|
|
37
35
|
currentStep = _useDerivedStateFromP2[0],
|
|
38
36
|
setCurrentStep = _useDerivedStateFromP2[1];
|
|
@@ -55,7 +53,7 @@ function useWizard(_ref) {
|
|
|
55
53
|
previous: handlePrevious,
|
|
56
54
|
canNext: checkCanNext(currentStep, wizardSteps),
|
|
57
55
|
canPrevious: checkCanPrevious(currentStep),
|
|
58
|
-
WizardCurrentContent:
|
|
56
|
+
WizardCurrentContent: dsUtilities.get(wizardSteps, [currentStep, 'content'], function () {
|
|
59
57
|
return null;
|
|
60
58
|
})
|
|
61
59
|
};
|
package/cjs/useWizard.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWizard.js","sources":["../../src/useWizard.tsx"],"sourcesContent":["import { useCallback } from 'react';\nimport { get } from '@elliemae/ds-utilities
|
|
1
|
+
{"version":3,"file":"useWizard.js","sources":["../../src/useWizard.tsx"],"sourcesContent":["import { useCallback } from 'react';\nimport { get, useDerivedStateFromProps } from '@elliemae/ds-utilities';\n\nconst checkCanNext = (prevIndex, array) => array.length > prevIndex + 1;\nconst checkCanPrevious = prevIndex => prevIndex - 1 >= 0;\n\nconst noop = () => null;\n\nexport default function useWizard({\n steps: wizardSteps,\n current,\n onNext = noop,\n onPrevious = noop,\n initial = 0,\n}) {\n const [currentStep, setCurrentStep] = useDerivedStateFromProps(\n current || initial,\n );\n\n const handleNext = useCallback(() => {\n if (checkCanNext(currentStep, wizardSteps)) {\n onNext(currentStep);\n setCurrentStep(currentStep + 1);\n }\n });\n\n const handlePrevious = useCallback(() => {\n if (checkCanPrevious(currentStep)) {\n onPrevious(currentStep);\n setCurrentStep(currentStep - 1);\n }\n });\n\n return {\n current: currentStep,\n next: handleNext,\n previous: handlePrevious,\n canNext: checkCanNext(currentStep, wizardSteps),\n canPrevious: checkCanPrevious(currentStep),\n WizardCurrentContent: get(\n wizardSteps,\n [currentStep, 'content'],\n () => null,\n ),\n };\n}\n"],"names":["checkCanNext","prevIndex","array","length","checkCanPrevious","noop","useWizard","wizardSteps","steps","current","onNext","onPrevious","initial","useDerivedStateFromProps","currentStep","setCurrentStep","handleNext","useCallback","handlePrevious","next","previous","canNext","canPrevious","WizardCurrentContent","get"],"mappings":";;;;;;;;;;AAGA,IAAMA,YAAY,GAAG,SAAfA,YAAe,CAACC,SAAD,EAAYC,KAAZ;AAAA,SAAsBA,KAAK,CAACC,MAAN,GAAeF,SAAS,GAAG,CAAjD;AAAA,CAArB;;AACA,IAAMG,gBAAgB,GAAG,SAAnBA,gBAAmB,CAAAH,SAAS;AAAA,SAAIA,SAAS,GAAG,CAAZ,IAAiB,CAArB;AAAA,CAAlC;;AAEA,IAAMI,IAAI,GAAG,SAAPA,IAAO;AAAA,SAAM,IAAN;AAAA,CAAb;;AAEe,SAASC,SAAT,OAMZ;AAAA,MALMC,WAKN,QALDC,KAKC;AAAA,MAJDC,OAIC,QAJDA,OAIC;AAAA,yBAHDC,MAGC;AAAA,MAHDA,MAGC,4BAHQL,IAGR;AAAA,6BAFDM,UAEC;AAAA,MAFDA,UAEC,gCAFYN,IAEZ;AAAA,0BADDO,OACC;AAAA,MADDA,OACC,6BADS,CACT;;AACD,8BAAsCC,oCAAwB,CAC5DJ,OAAO,IAAIG,OADiD,CAA9D;AAAA;AAAA,MAAOE,WAAP;AAAA,MAAoBC,cAApB;;AAIA,MAAMC,UAAU,GAAGC,iBAAW,CAAC,YAAM;AACnC,QAAIjB,YAAY,CAACc,WAAD,EAAcP,WAAd,CAAhB,EAA4C;AAC1CG,MAAAA,MAAM,CAACI,WAAD,CAAN;AACAC,MAAAA,cAAc,CAACD,WAAW,GAAG,CAAf,CAAd;AACD;AACF,GAL6B,CAA9B;AAOA,MAAMI,cAAc,GAAGD,iBAAW,CAAC,YAAM;AACvC,QAAIb,gBAAgB,CAACU,WAAD,CAApB,EAAmC;AACjCH,MAAAA,UAAU,CAACG,WAAD,CAAV;AACAC,MAAAA,cAAc,CAACD,WAAW,GAAG,CAAf,CAAd;AACD;AACF,GALiC,CAAlC;AAOA,SAAO;AACLL,IAAAA,OAAO,EAAEK,WADJ;AAELK,IAAAA,IAAI,EAAEH,UAFD;AAGLI,IAAAA,QAAQ,EAAEF,cAHL;AAILG,IAAAA,OAAO,EAAErB,YAAY,CAACc,WAAD,EAAcP,WAAd,CAJhB;AAKLe,IAAAA,WAAW,EAAElB,gBAAgB,CAACU,WAAD,CALxB;AAMLS,IAAAA,oBAAoB,EAAEC,eAAG,CACvBjB,WADuB,EAEvB,CAACO,WAAD,EAAc,SAAd,CAFuB,EAGvB;AAAA,aAAM,IAAN;AAAA,KAHuB;AANpB,GAAP;AAYD;;;;"}
|
package/esm/WizardStep.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { useMemo, isValidElement, cloneElement } from 'react';
|
|
2
2
|
import { PropTypes, describe } from 'react-desc';
|
|
3
3
|
import { aggregatedClasses } from '@elliemae/ds-classnames';
|
|
4
|
-
import { get } from '@elliemae/ds-utilities
|
|
5
|
-
import Checkmark from '@elliemae/ds-icons
|
|
4
|
+
import { get } from '@elliemae/ds-utilities';
|
|
5
|
+
import { Checkmark } from '@elliemae/ds-icons';
|
|
6
6
|
import { indicatorItemBlockName } from './blockNames.js';
|
|
7
7
|
|
|
8
8
|
/* eslint-disable indent */
|
package/esm/WizardStep.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WizardStep.js","sources":["../../src/WizardStep.tsx"],"sourcesContent":["/* eslint-disable indent */\nimport React, { cloneElement, useMemo, isValidElement } from 'react';\nimport { describe, PropTypes } from 'react-desc';\nimport { aggregatedClasses } from '@elliemae/ds-classnames';\nimport { get } from '@elliemae/ds-utilities
|
|
1
|
+
{"version":3,"file":"WizardStep.js","sources":["../../src/WizardStep.tsx"],"sourcesContent":["/* eslint-disable indent */\nimport React, { cloneElement, useMemo, isValidElement } from 'react';\nimport { describe, PropTypes } from 'react-desc';\nimport { aggregatedClasses } from '@elliemae/ds-classnames';\nimport { get } from '@elliemae/ds-utilities';\nimport { Checkmark } from '@elliemae/ds-icons';\nimport { indicatorItemBlockName } from './blockNames';\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\nfunction 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;\n\nconst WizzardStepWithSchema = describe(WizardStep);\nWizzardStepWithSchema.propTypes = wizzardStepProps;\n\nexport { WizzardStepWithSchema };\nexport default WizardStep;\n"],"names":["Item","aggregatedClasses","indicatorItemBlockName","active","completed","Wrapper","Label","Bullet","BulletWrapper","WizardStep","label","icon","iconCompleted","iconActive","index","currentIcon","useMemo","iconWithOptions","isValidElement","cloneElement","color","get","wizzardStepProps","PropTypes","string","description","oneOfType","element","defaultValue","Checkmark","bool","number","propTypes","WizzardStepWithSchema","describe"],"mappings":";;;;;;;AAAA;AAQA,IAAMA,IAAI,GAAGC,iBAAiB,CAAC,KAAD,CAAjB,WAA4BC,sBAA5B,GAAsD,IAAtD,EAA4D;AAAA,MAAGC,MAAH,QAAGA,MAAH;AAAA,MAAWC,SAAX,QAAWA,SAAX;AAAA,SAA4B;AACnGD,IAAAA,MAAM,EAANA,MADmG;AAEnGC,IAAAA,SAAS,EAATA;AAFmG,GAA5B;AAAA,CAA5D,CAAb;AAIA,IAAMC,OAAO,GAAGJ,iBAAiB,CAAC,KAAD,CAAjB,WAA4BC,sBAA5B,cAAhB;AACA,IAAMI,KAAK,GAAGL,iBAAiB,CAAC,MAAD,CAAjB,CAA0BC,sBAA1B,EAAkD,OAAlD,CAAd;AACA,IAAMK,MAAM,GAAGN,iBAAiB,CAAC,KAAD,CAAjB,CAAyBC,sBAAzB,EAAiD,QAAjD,CAAf;AACA,IAAMM,aAAa,GAAGP,iBAAiB,CAAC,KAAD,CAAjB,CAAyBC,sBAAzB,EAAiD,gBAAjD,CAAtB;;AAEA,SAASO,UAAT,QAQG;AAAA,0BAPDC,KAOC;AAAA,MAPDA,KAOC,4BAPO,EAOP;AAAA,yBAND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A7B,CADgB;AAEvBd,EAAAA,IAAI,EAAEY,SAAS,CAACG,SAAV,CAAoB,CAACH,SAAS,CAACI,OAAX,EAAoBJ,SAAS,CAACC,MAA9B,CAApB,EAA2DC,WAA3D,CAAuE,wBAAvE,CAFiB;AAGvBb,EAAAA,aAAa,EAAEW,SAAS,CAACI,OAAV,CAAkBF,WAAlB,CAA8B,iCAA9B,EAAiEG,YAAjE,CAA8EC,SAA9E,CAHQ;AAIvBhB,EAAAA,UAAU,EAAEU,SAAS,CAACI,OAAV,CAAkBF,WAAlB,CAA8B,8BAA9B,CAJW;AAKvBtB,EAAAA,MAAM,EAAEoB,SAAS,CAACO,IAAV,CAAeL,WAAf,CAA2B,mCAA3B,EAAgEG,YAAhE,CAA6E,KAA7E,CALe;AAMvBxB,EAAAA,SAAS,EAAEmB,SAAS,CAACO,IAAV,CAAeL,WAAf,CAA2B,sCAA3B,EAAmEG,YAAnE,CAAgF,KAAhF,CANY;AAOvBd,EAAAA,KAAK,EAAES,SAAS,CAACQ,MAAV,CAAiBN,WAAjB,CAA6B,oBAA7B;AAPgB,CAAzB;AAUAhB,UAAU,CAACuB,SAAX,GAAuBV,gBAAvB;IAEMW,qBAAqB,GAAGC,QAAQ,CAACzB,UAAD;AACtCwB,qBAAqB,CAACD,SAAtB,GAAkCV,gBAAlC;;;;"}
|
package/esm/WizardSteps.js
CHANGED
|
@@ -5,8 +5,8 @@ import { PropTypes, describe } from 'react-desc';
|
|
|
5
5
|
import { aggregatedClasses } from '@elliemae/ds-classnames';
|
|
6
6
|
import WizardStep from './WizardStep.js';
|
|
7
7
|
import { indicatorBlockName } from './blockNames.js';
|
|
8
|
-
import '@elliemae/ds-utilities
|
|
9
|
-
import '@elliemae/ds-icons
|
|
8
|
+
import '@elliemae/ds-utilities';
|
|
9
|
+
import '@elliemae/ds-icons';
|
|
10
10
|
|
|
11
11
|
var _excluded = ["current", "steps", "children"];
|
|
12
12
|
var StepsWrapper = aggregatedClasses('div')(indicatorBlockName);
|
package/esm/index.js
CHANGED
|
@@ -7,8 +7,7 @@ import 'react';
|
|
|
7
7
|
import 'react-desc';
|
|
8
8
|
import '@elliemae/ds-classnames';
|
|
9
9
|
import './blockNames.js';
|
|
10
|
-
import '@elliemae/ds-utilities
|
|
11
|
-
import '@elliemae/ds-icons
|
|
10
|
+
import '@elliemae/ds-utilities';
|
|
11
|
+
import '@elliemae/ds-icons';
|
|
12
12
|
import '@babel/runtime/helpers/esm/slicedToArray';
|
|
13
|
-
import '@elliemae/ds-utilities/hooks/useDerivedStateFromProps';
|
|
14
13
|
//# sourceMappingURL=index.js.map
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
|
package/esm/useWizard.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _slicedToArray from '@babel/runtime/helpers/esm/slicedToArray';
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
|
-
import { get } from '@elliemae/ds-utilities
|
|
4
|
-
import useDerivedStateFromProps from '@elliemae/ds-utilities/hooks/useDerivedStateFromProps';
|
|
3
|
+
import { useDerivedStateFromProps, get } from '@elliemae/ds-utilities';
|
|
5
4
|
|
|
6
5
|
var checkCanNext = function checkCanNext(prevIndex, array) {
|
|
7
6
|
return array.length > prevIndex + 1;
|
package/esm/useWizard.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWizard.js","sources":["../../src/useWizard.tsx"],"sourcesContent":["import { useCallback } from 'react';\nimport { get } from '@elliemae/ds-utilities
|
|
1
|
+
{"version":3,"file":"useWizard.js","sources":["../../src/useWizard.tsx"],"sourcesContent":["import { useCallback } from 'react';\nimport { get, useDerivedStateFromProps } from '@elliemae/ds-utilities';\n\nconst checkCanNext = (prevIndex, array) => array.length > prevIndex + 1;\nconst checkCanPrevious = prevIndex => prevIndex - 1 >= 0;\n\nconst noop = () => null;\n\nexport default function useWizard({\n steps: wizardSteps,\n current,\n onNext = noop,\n onPrevious = noop,\n initial = 0,\n}) {\n const [currentStep, setCurrentStep] = useDerivedStateFromProps(\n current || initial,\n );\n\n const handleNext = useCallback(() => {\n if (checkCanNext(currentStep, wizardSteps)) {\n onNext(currentStep);\n setCurrentStep(currentStep + 1);\n }\n });\n\n const handlePrevious = useCallback(() => {\n if (checkCanPrevious(currentStep)) {\n onPrevious(currentStep);\n setCurrentStep(currentStep - 1);\n }\n });\n\n return {\n current: currentStep,\n next: handleNext,\n previous: handlePrevious,\n canNext: checkCanNext(currentStep, wizardSteps),\n canPrevious: checkCanPrevious(currentStep),\n WizardCurrentContent: get(\n wizardSteps,\n [currentStep, 'content'],\n () => null,\n ),\n };\n}\n"],"names":["checkCanNext","prevIndex","array","length","checkCanPrevious","noop","useWizard","wizardSteps","steps","current","onNext","onPrevious","initial","useDerivedStateFromProps","currentStep","setCurrentStep","handleNext","useCallback","handlePrevious","next","previous","canNext","canPrevious","WizardCurrentContent","get"],"mappings":";;;;AAGA,IAAMA,YAAY,GAAG,SAAfA,YAAe,CAACC,SAAD,EAAYC,KAAZ;AAAA,SAAsBA,KAAK,CAACC,MAAN,GAAeF,SAAS,GAAG,CAAjD;AAAA,CAArB;;AACA,IAAMG,gBAAgB,GAAG,SAAnBA,gBAAmB,CAAAH,SAAS;AAAA,SAAIA,SAAS,GAAG,CAAZ,IAAiB,CAArB;AAAA,CAAlC;;AAEA,IAAMI,IAAI,GAAG,SAAPA,IAAO;AAAA,SAAM,IAAN;AAAA,CAAb;;AAEe,SAASC,SAAT,OAMZ;AAAA,MALMC,WAKN,QALDC,KAKC;AAAA,MAJDC,OAIC,QAJDA,OAIC;AAAA,yBAHDC,MAGC;AAAA,MAHDA,MAGC,4BAHQL,IAGR;AAAA,6BAFDM,UAEC;AAAA,MAFDA,UAEC,gCAFYN,IAEZ;AAAA,0BADDO,OACC;AAAA,MADDA,OACC,6BADS,CACT;;AACD,8BAAsCC,wBAAwB,CAC5DJ,OAAO,IAAIG,OADiD,CAA9D;AAAA;AAAA,MAAOE,WAAP;AAAA,MAAoBC,cAApB;;AAIA,MAAMC,UAAU,GAAGC,WAAW,CAAC,YAAM;AACnC,QAAIjB,YAAY,CAACc,WAAD,EAAcP,WAAd,CAAhB,EAA4C;AAC1CG,MAAAA,MAAM,CAACI,WAAD,CAAN;AACAC,MAAAA,cAAc,CAACD,WAAW,GAAG,CAAf,CAAd;AACD;AACF,GAL6B,CAA9B;AAOA,MAAMI,cAAc,GAAGD,WAAW,CAAC,YAAM;AACvC,QAAIb,gBAAgB,CAACU,WAAD,CAApB,EAAmC;AACjCH,MAAAA,UAAU,CAACG,WAAD,CAAV;AACAC,MAAAA,cAAc,CAACD,WAAW,GAAG,CAAf,CAAd;AACD;AACF,GALiC,CAAlC;AAOA,SAAO;AACLL,IAAAA,OAAO,EAAEK,WADJ;AAELK,IAAAA,IAAI,EAAEH,UAFD;AAGLI,IAAAA,QAAQ,EAAEF,cAHL;AAILG,IAAAA,OAAO,EAAErB,YAAY,CAACc,WAAD,EAAcP,WAAd,CAJhB;AAKLe,IAAAA,WAAW,EAAElB,gBAAgB,CAACU,WAAD,CALxB;AAMLS,IAAAA,oBAAoB,EAAEC,GAAG,CACvBjB,WADuB,EAEvB,CAACO,WAAD,EAAc,SAAd,CAFuB,EAGvB;AAAA,aAAM,IAAN;AAAA,KAHuB;AANpB,GAAP;AAYD;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-wizard",
|
|
3
|
-
"version": "1.57.0-rc.
|
|
3
|
+
"version": "1.57.0-rc.13",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Ellie Mae - Dim Sum - Wizard",
|
|
6
6
|
"main": "cjs/index.js",
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
"build": "node ../../scripts/build/build.js"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@elliemae/ds-basic": "1.57.0-rc.
|
|
20
|
-
"@elliemae/ds-classnames": "1.57.0-rc.
|
|
21
|
-
"@elliemae/ds-icons": "1.57.0-rc.
|
|
22
|
-
"@elliemae/ds-utilities": "1.57.0-rc.
|
|
19
|
+
"@elliemae/ds-basic": "1.57.0-rc.13",
|
|
20
|
+
"@elliemae/ds-classnames": "1.57.0-rc.13",
|
|
21
|
+
"@elliemae/ds-icons": "1.57.0-rc.13",
|
|
22
|
+
"@elliemae/ds-utilities": "1.57.0-rc.13",
|
|
23
23
|
"prop-types": "~15.7.2",
|
|
24
24
|
"react-desc": "^4.1.2"
|
|
25
25
|
},
|