@elliemae/ds-wizard 2.3.1-rc.2 → 3.0.0-alpha.2

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.
@@ -0,0 +1,85 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __reExport = (target, module2, copyDefault, desc) => {
13
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
14
+ for (let key of __getOwnPropNames(module2))
15
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
16
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
17
+ }
18
+ return target;
19
+ };
20
+ var __toESM = (module2, isNodeMode) => {
21
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
22
+ };
23
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
24
+ return (module2, temp) => {
25
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
26
+ };
27
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
28
+ var WizardStep_exports = {};
29
+ __export(WizardStep_exports, {
30
+ WizzardStepWithSchema: () => WizzardStepWithSchema,
31
+ default: () => WizardStep_default
32
+ });
33
+ var React = __toESM(require("react"));
34
+ var import_react = __toESM(require("react"));
35
+ var import_react_desc = require("react-desc");
36
+ var import_ds_classnames = require("@elliemae/ds-classnames");
37
+ var import_ds_utilities = require("@elliemae/ds-utilities");
38
+ var import_ds_icons = require("@elliemae/ds-icons");
39
+ var import_blockNames = require("./blockNames");
40
+ const Item = (0, import_ds_classnames.aggregatedClasses)("div")(`${import_blockNames.indicatorItemBlockName}`, null, ({ active, completed }) => ({
41
+ active,
42
+ completed
43
+ }));
44
+ const Wrapper = (0, import_ds_classnames.aggregatedClasses)("div")(`${import_blockNames.indicatorItemBlockName}-wrapper`);
45
+ const Label = (0, import_ds_classnames.aggregatedClasses)("span")(import_blockNames.indicatorItemBlockName, "label");
46
+ const Bullet = (0, import_ds_classnames.aggregatedClasses)("div")(import_blockNames.indicatorItemBlockName, "bullet");
47
+ const BulletWrapper = (0, import_ds_classnames.aggregatedClasses)("div")(import_blockNames.indicatorItemBlockName, "bullet-wrapper");
48
+ function WizardStep({
49
+ label = "",
50
+ icon = null,
51
+ iconCompleted = /* @__PURE__ */ import_react.default.createElement(import_ds_icons.Checkmark, null),
52
+ iconActive = null,
53
+ active = false,
54
+ completed = false,
55
+ index = 0
56
+ }) {
57
+ const currentIcon = (0, import_react.useMemo)(() => {
58
+ if (active)
59
+ return iconActive;
60
+ if (completed)
61
+ return iconCompleted;
62
+ return icon;
63
+ }, [active, completed]) || icon;
64
+ const iconWithOptions = (0, import_react.useMemo)(() => (0, import_react.isValidElement)(currentIcon) ? (0, import_react.cloneElement)(currentIcon, {
65
+ color: (0, import_ds_utilities.get)(currentIcon, ["props", "color"]) || ["brand-primary", completed ? 600 : 500]
66
+ }) : currentIcon || index + 1, [currentIcon]);
67
+ return /* @__PURE__ */ import_react.default.createElement(Item, {
68
+ classProps: { active, completed }
69
+ }, /* @__PURE__ */ import_react.default.createElement(Wrapper, null, /* @__PURE__ */ import_react.default.createElement(BulletWrapper, null, /* @__PURE__ */ import_react.default.createElement(Bullet, null, iconWithOptions)), /* @__PURE__ */ import_react.default.createElement(Label, null, label)));
70
+ }
71
+ const wizzardStepProps = {
72
+ label: import_react_desc.PropTypes.string.description("Step label"),
73
+ icon: import_react_desc.PropTypes.oneOfType([import_react_desc.PropTypes.element, import_react_desc.PropTypes.string]).description("Default icon or number"),
74
+ iconCompleted: import_react_desc.PropTypes.element.description("Icon when the step is completed").defaultValue(import_ds_icons.Checkmark),
75
+ iconActive: import_react_desc.PropTypes.element.description("Icon when the step is active"),
76
+ active: import_react_desc.PropTypes.bool.description("Whether the step is active or not").defaultValue(false),
77
+ completed: import_react_desc.PropTypes.bool.description("Whether the step is completed or not").defaultValue(false),
78
+ index: import_react_desc.PropTypes.number.description("Current item index")
79
+ };
80
+ WizardStep.propTypes = wizzardStepProps;
81
+ const WizzardStepWithSchema = (0, import_react_desc.describe)(WizardStep);
82
+ WizzardStepWithSchema.propTypes = wizzardStepProps;
83
+ var WizardStep_default = WizardStep;
84
+ module.exports = __toCommonJS(WizardStep_exports);
85
+ //# sourceMappingURL=WizardStep.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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 { 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", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAA6D;AAC7D,wBAAoC;AACpC,2BAAkC;AAClC,0BAAoB;AACpB,sBAA0B;AAC1B,wBAAuC;AAEvC,MAAM,OAAO,4CAAkB,OAAO,GAAG,4CAA0B,MAAM,CAAC,EAAE,QAAQ,gBAAiB;AAAA,EACnG;AAAA,EACA;AAAA;AAEF,MAAM,UAAU,4CAAkB,OAAO,GAAG;AAC5C,MAAM,QAAQ,4CAAkB,QAAQ,0CAAwB;AAChE,MAAM,SAAS,4CAAkB,OAAO,0CAAwB;AAChE,MAAM,gBAAgB,4CAAkB,OAAO,0CAAwB;AAEvE,oBAAoB;AAAA,EAClB,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,gBAAgB,mDAAC,2BAAD;AAAA,EAChB,aAAa;AAAA,EACb,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,QAAQ;AAAA,GACP;AACD,QAAM,cACJ,0BAAQ,MAAM;AACZ,QAAI;AAAQ,aAAO;AACnB,QAAI;AAAW,aAAO;AACtB,WAAO;AAAA,KACN,CAAC,QAAQ,eAAe;AAE7B,QAAM,kBAAkB,0BACtB,MACE,iCAAe,eACX,+BAAa,aAAa;AAAA,IACxB,OAAO,6BAAI,aAAa,CAAC,SAAS,aAAa,CAAC,iBAAiB,YAAY,MAAM;AAAA,OAErF,eAAe,QAAQ,GAC7B,CAAC;AAGH,SACE,mDAAC,MAAD;AAAA,IAAM,YAAY,EAAE,QAAQ;AAAA,KAC1B,mDAAC,SAAD,MACE,mDAAC,eAAD,MACE,mDAAC,QAAD,MAAS,mBAEX,mDAAC,OAAD,MAAQ;AAAA;AAMhB,MAAM,mBAAmB;AAAA,EACvB,OAAO,4BAAU,OAAO,YAAY;AAAA,EACpC,MAAM,4BAAU,UAAU,CAAC,4BAAU,SAAS,4BAAU,SAAS,YAAY;AAAA,EAC7E,eAAe,4BAAU,QAAQ,YAAY,mCAAmC,aAAa;AAAA,EAC7F,YAAY,4BAAU,QAAQ,YAAY;AAAA,EAC1C,QAAQ,4BAAU,KAAK,YAAY,qCAAqC,aAAa;AAAA,EACrF,WAAW,4BAAU,KAAK,YAAY,wCAAwC,aAAa;AAAA,EAC3F,OAAO,4BAAU,OAAO,YAAY;AAAA;AAGtC,WAAW,YAAY;AAEvB,MAAM,wBAAwB,gCAAS;AACvC,sBAAsB,YAAY;AAGlC,IAAO,qBAAQ;",
6
+ "names": []
7
+ }
@@ -0,0 +1,91 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __spreadValues = (a, b) => {
11
+ for (var prop in b || (b = {}))
12
+ if (__hasOwnProp.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ if (__getOwnPropSymbols)
15
+ for (var prop of __getOwnPropSymbols(b)) {
16
+ if (__propIsEnum.call(b, prop))
17
+ __defNormalProp(a, prop, b[prop]);
18
+ }
19
+ return a;
20
+ };
21
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
22
+ var __objRest = (source, exclude) => {
23
+ var target = {};
24
+ for (var prop in source)
25
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
26
+ target[prop] = source[prop];
27
+ if (source != null && __getOwnPropSymbols)
28
+ for (var prop of __getOwnPropSymbols(source)) {
29
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
30
+ target[prop] = source[prop];
31
+ }
32
+ return target;
33
+ };
34
+ var __export = (target, all) => {
35
+ for (var name in all)
36
+ __defProp(target, name, { get: all[name], enumerable: true });
37
+ };
38
+ var __reExport = (target, module2, copyDefault, desc) => {
39
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
40
+ for (let key of __getOwnPropNames(module2))
41
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
42
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
43
+ }
44
+ return target;
45
+ };
46
+ var __toESM = (module2, isNodeMode) => {
47
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
48
+ };
49
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
50
+ return (module2, temp) => {
51
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
52
+ };
53
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
54
+ var WizardSteps_exports = {};
55
+ __export(WizardSteps_exports, {
56
+ WizzardWithSchema: () => WizzardWithSchema,
57
+ default: () => WizardSteps_default
58
+ });
59
+ var React = __toESM(require("react"));
60
+ var import_react = __toESM(require("react"));
61
+ var import_react_desc = require("react-desc");
62
+ var import_ds_classnames = require("@elliemae/ds-classnames");
63
+ var import_WizardStep = __toESM(require("./WizardStep"));
64
+ var import_blockNames = require("./blockNames");
65
+ const StepsWrapper = (0, import_ds_classnames.aggregatedClasses)("div")(import_blockNames.indicatorBlockName);
66
+ function WizardSteps(_a) {
67
+ var _b = _a, { current = 0, steps, children } = _b, otherProps = __objRest(_b, ["current", "steps", "children"]);
68
+ const items = (0, import_react.useMemo)(() => {
69
+ const mergeStepProps = (step, index) => ({
70
+ index,
71
+ active: current === index,
72
+ completed: index < current
73
+ });
74
+ return steps ? steps.map((step, index) => /* @__PURE__ */ import_react.default.createElement(import_WizardStep.default, __spreadValues(__spreadValues({
75
+ key: index
76
+ }, step), mergeStepProps(step, index)))) : import_react.default.Children.map(children, (item, index) => (0, import_react.cloneElement)(item, mergeStepProps(item, index)));
77
+ }, [current, children]);
78
+ return /* @__PURE__ */ import_react.default.createElement(StepsWrapper, __spreadValues({}, otherProps), items);
79
+ }
80
+ WizardSteps.Item = import_WizardStep.default;
81
+ const wizzardProps = {
82
+ current: import_react_desc.PropTypes.number.description("Current active state index").defaultValue(0),
83
+ steps: import_react_desc.PropTypes.arrayOf(import_react_desc.PropTypes.shape({})).description("Array of steps objects").defaultValue([]).isRequired,
84
+ children: import_react_desc.PropTypes.arrayOf(import_react_desc.PropTypes.instanceOf(import_WizardStep.default)).description("List of WizardStep components")
85
+ };
86
+ WizardSteps.propTypes = wizzardProps;
87
+ const WizzardWithSchema = (0, import_react_desc.describe)(WizardSteps);
88
+ WizzardWithSchema.propTypes = wizzardProps;
89
+ var WizardSteps_default = WizardSteps;
90
+ module.exports = __toCommonJS(WizardSteps_exports);
91
+ //# sourceMappingURL=WizardSteps.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/WizardSteps.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["/* eslint-disable indent */\n/* eslint-disable react/no-array-index-key */\nimport React, { cloneElement, useMemo } from 'react';\nimport { describe, PropTypes } from 'react-desc';\nimport { aggregatedClasses } from '@elliemae/ds-classnames';\nimport WizardStep from './WizardStep';\nimport { indicatorBlockName } from './blockNames';\n\nconst StepsWrapper = aggregatedClasses('div')(indicatorBlockName);\n\nfunction WizardSteps({ current = 0, steps, children, ...otherProps }) {\n const items = useMemo(() => {\n const mergeStepProps = (step, index) => ({\n index,\n active: current === index,\n completed: index < current,\n });\n\n return steps\n ? steps.map((step, index) => (\n <WizardStep key={index} {...step} {...mergeStepProps(step, index)} />\n ))\n : React.Children.map(children, (item, index) =>\n cloneElement(item, mergeStepProps(item, index)),\n );\n }, [current, children]);\n\n return <StepsWrapper {...otherProps}>{items}</StepsWrapper>;\n}\n\nWizardSteps.Item = WizardStep;\n\nconst wizzardProps = {\n current: PropTypes.number\n .description('Current active state index')\n .defaultValue(0),\n steps: PropTypes.arrayOf(PropTypes.shape({}))\n .description('Array of steps objects')\n .defaultValue([]).isRequired,\n children: PropTypes.arrayOf(PropTypes.instanceOf(WizardStep)).description(\n 'List of WizardStep components',\n ),\n};\n\nWizardSteps.propTypes = wizzardProps;\n\nconst WizzardWithSchema = describe(WizardSteps);\nWizzardWithSchema.propTypes = wizzardProps;\n\nexport { WizzardWithSchema };\nexport default WizardSteps;\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,mBAA6C;AAC7C,wBAAoC;AACpC,2BAAkC;AAClC,wBAAuB;AACvB,wBAAmC;AAEnC,MAAM,eAAe,4CAAkB,OAAO;AAE9C,qBAAqB,IAAiD;AAAjD,eAAE,YAAU,GAAG,OAAO,aAAtB,IAAmC,uBAAnC,IAAmC,CAAjC,WAAa,SAAO;AACzC,QAAM,QAAQ,0BAAQ,MAAM;AAC1B,UAAM,iBAAiB,CAAC,MAAM,UAAW;AAAA,MACvC;AAAA,MACA,QAAQ,YAAY;AAAA,MACpB,WAAW,QAAQ;AAAA;AAGrB,WAAO,QACH,MAAM,IAAI,CAAC,MAAM,UACf,mDAAC,2BAAD;AAAA,MAAY,KAAK;AAAA,OAAW,OAAU,eAAe,MAAM,YAE7D,qBAAM,SAAS,IAAI,UAAU,CAAC,MAAM,UAClC,+BAAa,MAAM,eAAe,MAAM;AAAA,KAE7C,CAAC,SAAS;AAEb,SAAO,mDAAC,cAAD,mBAAkB,aAAa;AAAA;AAGxC,YAAY,OAAO;AAEnB,MAAM,eAAe;AAAA,EACnB,SAAS,4BAAU,OAChB,YAAY,8BACZ,aAAa;AAAA,EAChB,OAAO,4BAAU,QAAQ,4BAAU,MAAM,KACtC,YAAY,0BACZ,aAAa,IAAI;AAAA,EACpB,UAAU,4BAAU,QAAQ,4BAAU,WAAW,4BAAa,YAC5D;AAAA;AAIJ,YAAY,YAAY;AAExB,MAAM,oBAAoB,gCAAS;AACnC,kBAAkB,YAAY;AAG9B,IAAO,sBAAQ;",
6
+ "names": []
7
+ }
@@ -0,0 +1,39 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __reExport = (target, module2, copyDefault, desc) => {
13
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
14
+ for (let key of __getOwnPropNames(module2))
15
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
16
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
17
+ }
18
+ return target;
19
+ };
20
+ var __toESM = (module2, isNodeMode) => {
21
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
22
+ };
23
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
24
+ return (module2, temp) => {
25
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
26
+ };
27
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
28
+ var blockNames_exports = {};
29
+ __export(blockNames_exports, {
30
+ indicatorBlockName: () => indicatorBlockName,
31
+ indicatorItemBlockName: () => indicatorItemBlockName,
32
+ wizardBlockName: () => wizardBlockName
33
+ });
34
+ var React = __toESM(require("react"));
35
+ const wizardBlockName = "wizard";
36
+ const indicatorBlockName = `${wizardBlockName}-steps-indicator`;
37
+ const indicatorItemBlockName = `${indicatorBlockName}-step`;
38
+ module.exports = __toCommonJS(blockNames_exports);
39
+ //# sourceMappingURL=blockNames.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/blockNames.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["export const wizardBlockName = 'wizard';\nexport const indicatorBlockName = `${wizardBlockName}-steps-indicator`;\nexport const indicatorItemBlockName = `${indicatorBlockName}-step`;\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAhB,MAAM,kBAAkB;AACxB,MAAM,qBAAqB,GAAG;AAC9B,MAAM,yBAAyB,GAAG;",
6
+ "names": []
7
+ }
@@ -0,0 +1,41 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __reExport = (target, module2, copyDefault, desc) => {
13
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
14
+ for (let key of __getOwnPropNames(module2))
15
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
16
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
17
+ }
18
+ return target;
19
+ };
20
+ var __toESM = (module2, isNodeMode) => {
21
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
22
+ };
23
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
24
+ return (module2, temp) => {
25
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
26
+ };
27
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
28
+ var src_exports = {};
29
+ __export(src_exports, {
30
+ WizardStep: () => import_WizardStep.default,
31
+ WizardStepsIndicator: () => import_WizardSteps.default,
32
+ WizzardStepWithSchema: () => import_WizardStep.WizzardStepWithSchema,
33
+ WizzardWithSchema: () => import_WizardSteps.WizzardWithSchema,
34
+ useWizard: () => import_useWizard.default
35
+ });
36
+ var React = __toESM(require("react"));
37
+ var import_WizardSteps = __toESM(require("./WizardSteps"));
38
+ var import_WizardStep = __toESM(require("./WizardStep"));
39
+ var import_useWizard = __toESM(require("./useWizard"));
40
+ module.exports = __toCommonJS(src_exports);
41
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["import WizardStepsIndicator, { WizzardWithSchema } from './WizardSteps';\nimport WizardStep, { WizzardStepWithSchema } from './WizardStep';\nimport useWizard from './useWizard';\n\nexport {\n useWizard,\n WizardStepsIndicator,\n WizardStep,\n WizzardWithSchema,\n WizzardStepWithSchema,\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,yBAAwD;AACxD,wBAAkD;AAClD,uBAAsB;",
6
+ "names": []
7
+ }
@@ -0,0 +1,68 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __reExport = (target, module2, copyDefault, desc) => {
13
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
14
+ for (let key of __getOwnPropNames(module2))
15
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
16
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
17
+ }
18
+ return target;
19
+ };
20
+ var __toESM = (module2, isNodeMode) => {
21
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
22
+ };
23
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
24
+ return (module2, temp) => {
25
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
26
+ };
27
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
28
+ var useWizard_exports = {};
29
+ __export(useWizard_exports, {
30
+ default: () => useWizard
31
+ });
32
+ var React = __toESM(require("react"));
33
+ var import_react = require("react");
34
+ var import_ds_utilities = require("@elliemae/ds-utilities");
35
+ const checkCanNext = (prevIndex, array) => array.length > prevIndex + 1;
36
+ const checkCanPrevious = (prevIndex) => prevIndex - 1 >= 0;
37
+ const noop = () => null;
38
+ function useWizard({
39
+ steps: wizardSteps,
40
+ current,
41
+ onNext = noop,
42
+ onPrevious = noop,
43
+ initial = 0
44
+ }) {
45
+ const [currentStep, setCurrentStep] = (0, import_ds_utilities.useDerivedStateFromProps)(current || initial);
46
+ const handleNext = (0, import_react.useCallback)(() => {
47
+ if (checkCanNext(currentStep, wizardSteps)) {
48
+ onNext(currentStep);
49
+ setCurrentStep(currentStep + 1);
50
+ }
51
+ });
52
+ const handlePrevious = (0, import_react.useCallback)(() => {
53
+ if (checkCanPrevious(currentStep)) {
54
+ onPrevious(currentStep);
55
+ setCurrentStep(currentStep - 1);
56
+ }
57
+ });
58
+ return {
59
+ current: currentStep,
60
+ next: handleNext,
61
+ previous: handlePrevious,
62
+ canNext: checkCanNext(currentStep, wizardSteps),
63
+ canPrevious: checkCanPrevious(currentStep),
64
+ WizardCurrentContent: (0, import_ds_utilities.get)(wizardSteps, [currentStep, "content"], () => null)
65
+ };
66
+ }
67
+ module.exports = __toCommonJS(useWizard_exports);
68
+ //# sourceMappingURL=useWizard.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/useWizard.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
+ "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", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA4B;AAC5B,0BAA8C;AAE9C,MAAM,eAAe,CAAC,WAAW,UAAU,MAAM,SAAS,YAAY;AACtE,MAAM,mBAAmB,eAAa,YAAY,KAAK;AAEvD,MAAM,OAAO,MAAM;AAEJ,mBAAmB;AAAA,EAChC,OAAO;AAAA,EACP;AAAA,EACA,SAAS;AAAA,EACT,aAAa;AAAA,EACb,UAAU;AAAA,GACT;AACD,QAAM,CAAC,aAAa,kBAAkB,kDACpC,WAAW;AAGb,QAAM,aAAa,8BAAY,MAAM;AACnC,QAAI,aAAa,aAAa,cAAc;AAC1C,aAAO;AACP,qBAAe,cAAc;AAAA;AAAA;AAIjC,QAAM,iBAAiB,8BAAY,MAAM;AACvC,QAAI,iBAAiB,cAAc;AACjC,iBAAW;AACX,qBAAe,cAAc;AAAA;AAAA;AAIjC,SAAO;AAAA,IACL,SAAS;AAAA,IACT,MAAM;AAAA,IACN,UAAU;AAAA,IACV,SAAS,aAAa,aAAa;AAAA,IACnC,aAAa,iBAAiB;AAAA,IAC9B,sBAAsB,6BACpB,aACA,CAAC,aAAa,YACd,MAAM;AAAA;AAAA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,56 @@
1
+ import * as React from "react";
2
+ import React2, { cloneElement, useMemo, isValidElement } from "react";
3
+ import { describe, PropTypes } from "react-desc";
4
+ import { aggregatedClasses } from "@elliemae/ds-classnames";
5
+ import { get } from "@elliemae/ds-utilities";
6
+ import { Checkmark } from "@elliemae/ds-icons";
7
+ import { indicatorItemBlockName } from "./blockNames";
8
+ const Item = aggregatedClasses("div")(`${indicatorItemBlockName}`, null, ({ active, completed }) => ({
9
+ active,
10
+ completed
11
+ }));
12
+ const Wrapper = aggregatedClasses("div")(`${indicatorItemBlockName}-wrapper`);
13
+ const Label = aggregatedClasses("span")(indicatorItemBlockName, "label");
14
+ const Bullet = aggregatedClasses("div")(indicatorItemBlockName, "bullet");
15
+ const BulletWrapper = aggregatedClasses("div")(indicatorItemBlockName, "bullet-wrapper");
16
+ function WizardStep({
17
+ label = "",
18
+ icon = null,
19
+ iconCompleted = /* @__PURE__ */ React2.createElement(Checkmark, null),
20
+ iconActive = null,
21
+ active = false,
22
+ completed = false,
23
+ index = 0
24
+ }) {
25
+ const currentIcon = useMemo(() => {
26
+ if (active)
27
+ return iconActive;
28
+ if (completed)
29
+ return iconCompleted;
30
+ return icon;
31
+ }, [active, completed]) || icon;
32
+ const iconWithOptions = useMemo(() => isValidElement(currentIcon) ? cloneElement(currentIcon, {
33
+ color: get(currentIcon, ["props", "color"]) || ["brand-primary", completed ? 600 : 500]
34
+ }) : currentIcon || index + 1, [currentIcon]);
35
+ return /* @__PURE__ */ React2.createElement(Item, {
36
+ classProps: { active, completed }
37
+ }, /* @__PURE__ */ React2.createElement(Wrapper, null, /* @__PURE__ */ React2.createElement(BulletWrapper, null, /* @__PURE__ */ React2.createElement(Bullet, null, iconWithOptions)), /* @__PURE__ */ React2.createElement(Label, null, label)));
38
+ }
39
+ const wizzardStepProps = {
40
+ label: PropTypes.string.description("Step label"),
41
+ icon: PropTypes.oneOfType([PropTypes.element, PropTypes.string]).description("Default icon or number"),
42
+ iconCompleted: PropTypes.element.description("Icon when the step is completed").defaultValue(Checkmark),
43
+ iconActive: PropTypes.element.description("Icon when the step is active"),
44
+ active: PropTypes.bool.description("Whether the step is active or not").defaultValue(false),
45
+ completed: PropTypes.bool.description("Whether the step is completed or not").defaultValue(false),
46
+ index: PropTypes.number.description("Current item index")
47
+ };
48
+ WizardStep.propTypes = wizzardStepProps;
49
+ const WizzardStepWithSchema = describe(WizardStep);
50
+ WizzardStepWithSchema.propTypes = wizzardStepProps;
51
+ var WizardStep_default = WizardStep;
52
+ export {
53
+ WizzardStepWithSchema,
54
+ WizardStep_default as default
55
+ };
56
+ //# sourceMappingURL=WizardStep.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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 { 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"],
5
+ "mappings": "AAAA;ACCA;AACA;AACA;AACA;AACA;AACA;AAEA,MAAM,OAAO,kBAAkB,OAAO,GAAG,0BAA0B,MAAM,CAAC,EAAE,QAAQ,gBAAiB;AAAA,EACnG;AAAA,EACA;AAAA;AAEF,MAAM,UAAU,kBAAkB,OAAO,GAAG;AAC5C,MAAM,QAAQ,kBAAkB,QAAQ,wBAAwB;AAChE,MAAM,SAAS,kBAAkB,OAAO,wBAAwB;AAChE,MAAM,gBAAgB,kBAAkB,OAAO,wBAAwB;AAEvE,oBAAoB;AAAA,EAClB,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,gBAAgB,qCAAC,WAAD;AAAA,EAChB,aAAa;AAAA,EACb,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,QAAQ;AAAA,GACP;AACD,QAAM,cACJ,QAAQ,MAAM;AACZ,QAAI;AAAQ,aAAO;AACnB,QAAI;AAAW,aAAO;AACtB,WAAO;AAAA,KACN,CAAC,QAAQ,eAAe;AAE7B,QAAM,kBAAkB,QACtB,MACE,eAAe,eACX,aAAa,aAAa;AAAA,IACxB,OAAO,IAAI,aAAa,CAAC,SAAS,aAAa,CAAC,iBAAiB,YAAY,MAAM;AAAA,OAErF,eAAe,QAAQ,GAC7B,CAAC;AAGH,SACE,qCAAC,MAAD;AAAA,IAAM,YAAY,EAAE,QAAQ;AAAA,KAC1B,qCAAC,SAAD,MACE,qCAAC,eAAD,MACE,qCAAC,QAAD,MAAS,mBAEX,qCAAC,OAAD,MAAQ;AAAA;AAMhB,MAAM,mBAAmB;AAAA,EACvB,OAAO,UAAU,OAAO,YAAY;AAAA,EACpC,MAAM,UAAU,UAAU,CAAC,UAAU,SAAS,UAAU,SAAS,YAAY;AAAA,EAC7E,eAAe,UAAU,QAAQ,YAAY,mCAAmC,aAAa;AAAA,EAC7F,YAAY,UAAU,QAAQ,YAAY;AAAA,EAC1C,QAAQ,UAAU,KAAK,YAAY,qCAAqC,aAAa;AAAA,EACrF,WAAW,UAAU,KAAK,YAAY,wCAAwC,aAAa;AAAA,EAC3F,OAAO,UAAU,OAAO,YAAY;AAAA;AAGtC,WAAW,YAAY;AAEvB,MAAM,wBAAwB,SAAS;AACvC,sBAAsB,YAAY;AAGlC,IAAO,qBAAQ;",
6
+ "names": []
7
+ }
@@ -0,0 +1,64 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ var __objRest = (source, exclude) => {
18
+ var target = {};
19
+ for (var prop in source)
20
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
21
+ target[prop] = source[prop];
22
+ if (source != null && __getOwnPropSymbols)
23
+ for (var prop of __getOwnPropSymbols(source)) {
24
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
25
+ target[prop] = source[prop];
26
+ }
27
+ return target;
28
+ };
29
+ import * as React from "react";
30
+ import React2, { cloneElement, useMemo } from "react";
31
+ import { describe, PropTypes } from "react-desc";
32
+ import { aggregatedClasses } from "@elliemae/ds-classnames";
33
+ import WizardStep from "./WizardStep";
34
+ import { indicatorBlockName } from "./blockNames";
35
+ const StepsWrapper = aggregatedClasses("div")(indicatorBlockName);
36
+ function WizardSteps(_a) {
37
+ var _b = _a, { current = 0, steps, children } = _b, otherProps = __objRest(_b, ["current", "steps", "children"]);
38
+ const items = useMemo(() => {
39
+ const mergeStepProps = (step, index) => ({
40
+ index,
41
+ active: current === index,
42
+ completed: index < current
43
+ });
44
+ return steps ? steps.map((step, index) => /* @__PURE__ */ React2.createElement(WizardStep, __spreadValues(__spreadValues({
45
+ key: index
46
+ }, step), mergeStepProps(step, index)))) : React2.Children.map(children, (item, index) => cloneElement(item, mergeStepProps(item, index)));
47
+ }, [current, children]);
48
+ return /* @__PURE__ */ React2.createElement(StepsWrapper, __spreadValues({}, otherProps), items);
49
+ }
50
+ WizardSteps.Item = WizardStep;
51
+ const wizzardProps = {
52
+ current: PropTypes.number.description("Current active state index").defaultValue(0),
53
+ steps: PropTypes.arrayOf(PropTypes.shape({})).description("Array of steps objects").defaultValue([]).isRequired,
54
+ children: PropTypes.arrayOf(PropTypes.instanceOf(WizardStep)).description("List of WizardStep components")
55
+ };
56
+ WizardSteps.propTypes = wizzardProps;
57
+ const WizzardWithSchema = describe(WizardSteps);
58
+ WizzardWithSchema.propTypes = wizzardProps;
59
+ var WizardSteps_default = WizardSteps;
60
+ export {
61
+ WizzardWithSchema,
62
+ WizardSteps_default as default
63
+ };
64
+ //# sourceMappingURL=WizardSteps.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/WizardSteps.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable indent */\n/* eslint-disable react/no-array-index-key */\nimport React, { cloneElement, useMemo } from 'react';\nimport { describe, PropTypes } from 'react-desc';\nimport { aggregatedClasses } from '@elliemae/ds-classnames';\nimport WizardStep from './WizardStep';\nimport { indicatorBlockName } from './blockNames';\n\nconst StepsWrapper = aggregatedClasses('div')(indicatorBlockName);\n\nfunction WizardSteps({ current = 0, steps, children, ...otherProps }) {\n const items = useMemo(() => {\n const mergeStepProps = (step, index) => ({\n index,\n active: current === index,\n completed: index < current,\n });\n\n return steps\n ? steps.map((step, index) => (\n <WizardStep key={index} {...step} {...mergeStepProps(step, index)} />\n ))\n : React.Children.map(children, (item, index) =>\n cloneElement(item, mergeStepProps(item, index)),\n );\n }, [current, children]);\n\n return <StepsWrapper {...otherProps}>{items}</StepsWrapper>;\n}\n\nWizardSteps.Item = WizardStep;\n\nconst wizzardProps = {\n current: PropTypes.number\n .description('Current active state index')\n .defaultValue(0),\n steps: PropTypes.arrayOf(PropTypes.shape({}))\n .description('Array of steps objects')\n .defaultValue([]).isRequired,\n children: PropTypes.arrayOf(PropTypes.instanceOf(WizardStep)).description(\n 'List of WizardStep components',\n ),\n};\n\nWizardSteps.propTypes = wizzardProps;\n\nconst WizzardWithSchema = describe(WizardSteps);\nWizzardWithSchema.propTypes = wizzardProps;\n\nexport { WizzardWithSchema };\nexport default WizardSteps;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;ACEA;AACA;AACA;AACA;AACA;AAEA,MAAM,eAAe,kBAAkB,OAAO;AAE9C,qBAAqB,IAAiD;AAAjD,eAAE,YAAU,GAAG,OAAO,aAAtB,IAAmC,uBAAnC,IAAmC,CAAjC,WAAa,SAAO;AACzC,QAAM,QAAQ,QAAQ,MAAM;AAC1B,UAAM,iBAAiB,CAAC,MAAM,UAAW;AAAA,MACvC;AAAA,MACA,QAAQ,YAAY;AAAA,MACpB,WAAW,QAAQ;AAAA;AAGrB,WAAO,QACH,MAAM,IAAI,CAAC,MAAM,UACf,qCAAC,YAAD;AAAA,MAAY,KAAK;AAAA,OAAW,OAAU,eAAe,MAAM,YAE7D,OAAM,SAAS,IAAI,UAAU,CAAC,MAAM,UAClC,aAAa,MAAM,eAAe,MAAM;AAAA,KAE7C,CAAC,SAAS;AAEb,SAAO,qCAAC,cAAD,mBAAkB,aAAa;AAAA;AAGxC,YAAY,OAAO;AAEnB,MAAM,eAAe;AAAA,EACnB,SAAS,UAAU,OAChB,YAAY,8BACZ,aAAa;AAAA,EAChB,OAAO,UAAU,QAAQ,UAAU,MAAM,KACtC,YAAY,0BACZ,aAAa,IAAI;AAAA,EACpB,UAAU,UAAU,QAAQ,UAAU,WAAW,aAAa,YAC5D;AAAA;AAIJ,YAAY,YAAY;AAExB,MAAM,oBAAoB,SAAS;AACnC,kBAAkB,YAAY;AAG9B,IAAO,sBAAQ;",
6
+ "names": []
7
+ }
@@ -0,0 +1,10 @@
1
+ import * as React from "react";
2
+ const wizardBlockName = "wizard";
3
+ const indicatorBlockName = `${wizardBlockName}-steps-indicator`;
4
+ const indicatorItemBlockName = `${indicatorBlockName}-step`;
5
+ export {
6
+ indicatorBlockName,
7
+ indicatorItemBlockName,
8
+ wizardBlockName
9
+ };
10
+ //# sourceMappingURL=blockNames.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/blockNames.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export const wizardBlockName = 'wizard';\nexport const indicatorBlockName = `${wizardBlockName}-steps-indicator`;\nexport const indicatorItemBlockName = `${indicatorBlockName}-step`;\n"],
5
+ "mappings": "AAAA;ACAO,MAAM,kBAAkB;AACxB,MAAM,qBAAqB,GAAG;AAC9B,MAAM,yBAAyB,GAAG;",
6
+ "names": []
7
+ }
@@ -0,0 +1,12 @@
1
+ import * as React from "react";
2
+ import WizardStepsIndicator, { WizzardWithSchema } from "./WizardSteps";
3
+ import WizardStep, { WizzardStepWithSchema } from "./WizardStep";
4
+ import useWizard from "./useWizard";
5
+ export {
6
+ WizardStep,
7
+ WizardStepsIndicator,
8
+ WizzardStepWithSchema,
9
+ WizzardWithSchema,
10
+ useWizard
11
+ };
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/index.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import WizardStepsIndicator, { WizzardWithSchema } from './WizardSteps';\nimport WizardStep, { WizzardStepWithSchema } from './WizardStep';\nimport useWizard from './useWizard';\n\nexport {\n useWizard,\n WizardStepsIndicator,\n WizardStep,\n WizzardWithSchema,\n WizzardStepWithSchema,\n};\n"],
5
+ "mappings": "AAAA;ACAA;AACA;AACA;",
6
+ "names": []
7
+ }
@@ -1,21 +1,16 @@
1
- import 'core-js/modules/web.dom-collections.iterator.js';
2
- import { useCallback } from 'react';
3
- import { useDerivedStateFromProps, get } from '@elliemae/ds-utilities';
4
-
1
+ import * as React from "react";
2
+ import { useCallback } from "react";
3
+ import { get, useDerivedStateFromProps } from "@elliemae/ds-utilities";
5
4
  const checkCanNext = (prevIndex, array) => array.length > prevIndex + 1;
6
-
7
- const checkCanPrevious = prevIndex => prevIndex - 1 >= 0;
8
-
5
+ const checkCanPrevious = (prevIndex) => prevIndex - 1 >= 0;
9
6
  const noop = () => null;
10
-
11
- function useWizard(_ref) {
12
- let {
13
- steps: wizardSteps,
14
- current,
15
- onNext = noop,
16
- onPrevious = noop,
17
- initial = 0
18
- } = _ref;
7
+ function useWizard({
8
+ steps: wizardSteps,
9
+ current,
10
+ onNext = noop,
11
+ onPrevious = noop,
12
+ initial = 0
13
+ }) {
19
14
  const [currentStep, setCurrentStep] = useDerivedStateFromProps(current || initial);
20
15
  const handleNext = useCallback(() => {
21
16
  if (checkCanNext(currentStep, wizardSteps)) {
@@ -35,8 +30,10 @@ function useWizard(_ref) {
35
30
  previous: handlePrevious,
36
31
  canNext: checkCanNext(currentStep, wizardSteps),
37
32
  canPrevious: checkCanPrevious(currentStep),
38
- WizardCurrentContent: get(wizardSteps, [currentStep, 'content'], () => null)
33
+ WizardCurrentContent: get(wizardSteps, [currentStep, "content"], () => null)
39
34
  };
40
35
  }
41
-
42
- export { useWizard as default };
36
+ export {
37
+ useWizard as default
38
+ };
39
+ //# sourceMappingURL=useWizard.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/useWizard.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
5
+ "mappings": "AAAA;ACAA;AACA;AAEA,MAAM,eAAe,CAAC,WAAW,UAAU,MAAM,SAAS,YAAY;AACtE,MAAM,mBAAmB,eAAa,YAAY,KAAK;AAEvD,MAAM,OAAO,MAAM;AAEJ,mBAAmB;AAAA,EAChC,OAAO;AAAA,EACP;AAAA,EACA,SAAS;AAAA,EACT,aAAa;AAAA,EACb,UAAU;AAAA,GACT;AACD,QAAM,CAAC,aAAa,kBAAkB,yBACpC,WAAW;AAGb,QAAM,aAAa,YAAY,MAAM;AACnC,QAAI,aAAa,aAAa,cAAc;AAC1C,aAAO;AACP,qBAAe,cAAc;AAAA;AAAA;AAIjC,QAAM,iBAAiB,YAAY,MAAM;AACvC,QAAI,iBAAiB,cAAc;AACjC,iBAAW;AACX,qBAAe,cAAc;AAAA;AAAA;AAIjC,SAAO;AAAA,IACL,SAAS;AAAA,IACT,MAAM;AAAA,IACN,UAAU;AAAA,IACV,SAAS,aAAa,aAAa;AAAA,IACnC,aAAa,iBAAiB;AAAA,IAC9B,sBAAsB,IACpB,aACA,CAAC,aAAa,YACd,MAAM;AAAA;AAAA;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,31 +1,38 @@
1
1
  {
2
2
  "name": "@elliemae/ds-wizard",
3
- "version": "2.3.1-rc.2",
3
+ "version": "3.0.0-alpha.2",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Wizard",
6
- "module": "./esm/index.js",
7
- "main": "./cjs/index.js",
8
- "types": "./types/index.d.ts",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "module": "./dist/esm/index.js",
10
+ "main": "./dist/cjs/index.js",
11
+ "types": "./dist/types/index.d.ts",
9
12
  "exports": {
10
13
  ".": {
11
- "import": "./esm/index.js",
12
- "require": "./cjs/index.js"
14
+ "import": "./dist/esm/index.js",
15
+ "require": "./dist/cjs/index.js"
13
16
  },
14
17
  "./WizardSteps": {
15
- "import": "./esm/WizardSteps.js",
16
- "require": "./cjs/WizardSteps.js"
18
+ "import": "./dist/esm/WizardSteps.js",
19
+ "require": "./dist/cjs/WizardSteps.js"
17
20
  },
18
21
  "./WizardStep": {
19
- "import": "./esm/WizardStep.js",
20
- "require": "./cjs/WizardStep.js"
22
+ "import": "./dist/esm/WizardStep.js",
23
+ "require": "./dist/cjs/WizardStep.js"
21
24
  },
22
25
  "./useWizard": {
23
- "import": "./esm/useWizard.js",
24
- "require": "./cjs/useWizard.js"
26
+ "import": "./dist/esm/useWizard.js",
27
+ "require": "./dist/cjs/useWizard.js"
28
+ },
29
+ "./stories/steps": {
30
+ "import": "./dist/esm/stories/steps.js",
31
+ "require": "./dist/cjs/stories/steps.js"
25
32
  },
26
33
  "./blockNames": {
27
- "import": "./esm/blockNames.js",
28
- "require": "./cjs/blockNames.js"
34
+ "import": "./dist/esm/blockNames.js",
35
+ "require": "./dist/cjs/blockNames.js"
29
36
  }
30
37
  },
31
38
  "sideEffects": [
@@ -37,21 +44,22 @@
37
44
  "url": "https://git.elliemae.io/platform-ui/dimsum.git"
38
45
  },
39
46
  "engines": {
40
- "npm": ">=7",
41
- "node": ">=14"
47
+ "pnpm": ">=6",
48
+ "node": ">=16"
42
49
  },
43
50
  "author": "ICE MT",
44
- "scripts": {
45
- "dev": "cross-env NODE_ENV=development && node ../../scripts/build/build.js -w",
46
- "prebuild": "exit 0",
47
- "predev": "exit 0",
48
- "build": "node ../../scripts/build/build.js"
51
+ "jestSonar": {
52
+ "sonar56x": true,
53
+ "reportPath": "reports",
54
+ "reportFile": "tests.xml",
55
+ "indent": 4
49
56
  },
50
57
  "dependencies": {
51
- "@elliemae/ds-classnames": "2.3.1-rc.2",
52
- "@elliemae/ds-icons": "2.3.1-rc.2",
53
- "@elliemae/ds-utilities": "2.3.1-rc.2",
54
- "@elliemae/ds-wizard": "2.3.1-rc.2",
58
+ "@elliemae/ds-button": "3.0.0-alpha.2",
59
+ "@elliemae/ds-classnames": "3.0.0-alpha.2",
60
+ "@elliemae/ds-icons": "3.0.0-alpha.2",
61
+ "@elliemae/ds-utilities": "3.0.0-alpha.2",
62
+ "@elliemae/ds-wizard": "3.0.0-alpha.2",
55
63
  "prop-types": "~15.7.2",
56
64
  "react-desc": "~4.1.3"
57
65
  },
@@ -62,7 +70,13 @@
62
70
  },
63
71
  "publishConfig": {
64
72
  "access": "public",
65
- "directory": "dist",
66
- "generateSubmodules": true
73
+ "typeSafety": false
74
+ },
75
+ "scripts": {
76
+ "dev": "cross-env NODE_ENV=development node ../../scripts/build/build.mjs --watch",
77
+ "test": "node ../../scripts/testing/test.mjs",
78
+ "lint": "node ../../scripts/lint.mjs",
79
+ "dts": "node ../../scripts/dts.mjs",
80
+ "build": "cross-env NODE_ENV=production node ../../scripts/build/build.mjs"
67
81
  }
68
82
  }
package/cjs/WizardStep.js DELETED
@@ -1,72 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var _jsx = require('@babel/runtime/helpers/jsx');
6
- var React = require('react');
7
- var reactDesc = require('react-desc');
8
- var dsClassnames = require('@elliemae/ds-classnames');
9
- var dsUtilities = require('@elliemae/ds-utilities');
10
- var dsIcons = require('@elliemae/ds-icons');
11
- var blockNames = require('./blockNames.js');
12
-
13
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
14
-
15
- var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
16
-
17
- var _Checkmark;
18
- const Item = dsClassnames.aggregatedClasses('div')("".concat(blockNames.indicatorItemBlockName), null, _ref => {
19
- let {
20
- active,
21
- completed
22
- } = _ref;
23
- return {
24
- active,
25
- completed
26
- };
27
- });
28
- const Wrapper = dsClassnames.aggregatedClasses('div')("".concat(blockNames.indicatorItemBlockName, "-wrapper"));
29
- const Label = dsClassnames.aggregatedClasses('span')(blockNames.indicatorItemBlockName, 'label');
30
- const Bullet = dsClassnames.aggregatedClasses('div')(blockNames.indicatorItemBlockName, 'bullet');
31
- const BulletWrapper = dsClassnames.aggregatedClasses('div')(blockNames.indicatorItemBlockName, 'bullet-wrapper');
32
-
33
- function WizardStep(_ref2) {
34
- let {
35
- label = '',
36
- icon = null,
37
- iconCompleted = _Checkmark || (_Checkmark = /*#__PURE__*/_jsx__default["default"](dsIcons.Checkmark, {})),
38
- iconActive = null,
39
- active = false,
40
- completed = false,
41
- index = 0
42
- } = _ref2;
43
- const currentIcon = React.useMemo(() => {
44
- if (active) return iconActive;
45
- if (completed) return iconCompleted;
46
- return icon;
47
- }, [active, completed]) || icon;
48
- const iconWithOptions = React.useMemo(() => /*#__PURE__*/React.isValidElement(currentIcon) ? /*#__PURE__*/React.cloneElement(currentIcon, {
49
- color: dsUtilities.get(currentIcon, ['props', 'color']) || ['brand-primary', completed ? 600 : 500]
50
- }) : currentIcon || index + 1, [currentIcon]);
51
- return /*#__PURE__*/_jsx__default["default"](Item, {
52
- classProps: {
53
- active,
54
- completed
55
- }
56
- }, void 0, /*#__PURE__*/_jsx__default["default"](Wrapper, {}, void 0, /*#__PURE__*/_jsx__default["default"](BulletWrapper, {}, void 0, /*#__PURE__*/_jsx__default["default"](Bullet, {}, void 0, iconWithOptions)), /*#__PURE__*/_jsx__default["default"](Label, {}, void 0, label)));
57
- }
58
-
59
- const wizzardStepProps = {
60
- label: reactDesc.PropTypes.string.description('Step label'),
61
- icon: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.element, reactDesc.PropTypes.string]).description('Default icon or number'),
62
- iconCompleted: reactDesc.PropTypes.element.description('Icon when the step is completed').defaultValue(dsIcons.Checkmark),
63
- iconActive: reactDesc.PropTypes.element.description('Icon when the step is active'),
64
- active: reactDesc.PropTypes.bool.description('Whether the step is active or not').defaultValue(false),
65
- completed: reactDesc.PropTypes.bool.description('Whether the step is completed or not').defaultValue(false),
66
- index: reactDesc.PropTypes.number.description('Current item index')
67
- };
68
- const WizzardStepWithSchema = reactDesc.describe(WizardStep);
69
- WizzardStepWithSchema.propTypes = wizzardStepProps;
70
-
71
- exports.WizzardStepWithSchema = WizzardStepWithSchema;
72
- exports["default"] = WizardStep;
@@ -1,66 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var _defineProperty = require('@babel/runtime/helpers/defineProperty');
6
- var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
7
- require('core-js/modules/esnext.async-iterator.map.js');
8
- require('core-js/modules/esnext.iterator.map.js');
9
- require('core-js/modules/esnext.async-iterator.filter.js');
10
- require('core-js/modules/esnext.iterator.constructor.js');
11
- require('core-js/modules/esnext.iterator.filter.js');
12
- require('core-js/modules/esnext.async-iterator.for-each.js');
13
- require('core-js/modules/esnext.iterator.for-each.js');
14
- var React = require('react');
15
- var reactDesc = require('react-desc');
16
- var dsClassnames = require('@elliemae/ds-classnames');
17
- var WizardStep = require('./WizardStep.js');
18
- var blockNames = require('./blockNames.js');
19
- var jsxRuntime = require('react/jsx-runtime');
20
-
21
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
22
-
23
- var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
24
- var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
25
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
26
-
27
- const _excluded = ["current", "steps", "children"];
28
-
29
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
30
-
31
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
32
- const StepsWrapper = dsClassnames.aggregatedClasses('div')(blockNames.indicatorBlockName);
33
-
34
- function WizardSteps(_ref) {
35
- let {
36
- current = 0,
37
- steps,
38
- children
39
- } = _ref,
40
- otherProps = _objectWithoutProperties__default["default"](_ref, _excluded);
41
-
42
- const items = React.useMemo(() => {
43
- const mergeStepProps = (step, index) => ({
44
- index,
45
- active: current === index,
46
- completed: index < current
47
- });
48
-
49
- return steps ? steps.map((step, index) => /*#__PURE__*/jsxRuntime.jsx(WizardStep["default"], _objectSpread(_objectSpread({}, step), mergeStepProps(step, index)), index)) : React__default["default"].Children.map(children, (item, index) => /*#__PURE__*/React.cloneElement(item, mergeStepProps(item, index)));
50
- }, [current, children]);
51
- return /*#__PURE__*/jsxRuntime.jsx(StepsWrapper, _objectSpread(_objectSpread({}, otherProps), {}, {
52
- children: items
53
- }));
54
- }
55
-
56
- WizardSteps.Item = WizardStep["default"];
57
- const wizzardProps = {
58
- current: reactDesc.PropTypes.number.description('Current active state index').defaultValue(0),
59
- steps: reactDesc.PropTypes.arrayOf(reactDesc.PropTypes.shape({})).description('Array of steps objects').defaultValue([]).isRequired,
60
- children: reactDesc.PropTypes.arrayOf(reactDesc.PropTypes.instanceOf(WizardStep["default"])).description('List of WizardStep components')
61
- };
62
- const WizzardWithSchema = reactDesc.describe(WizardSteps);
63
- WizzardWithSchema.propTypes = wizzardProps;
64
-
65
- exports.WizzardWithSchema = WizzardWithSchema;
66
- exports["default"] = WizardSteps;
package/cjs/blockNames.js DELETED
@@ -1,11 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const wizardBlockName = 'wizard';
6
- const indicatorBlockName = "".concat(wizardBlockName, "-steps-indicator");
7
- const indicatorItemBlockName = "".concat(indicatorBlockName, "-step");
8
-
9
- exports.indicatorBlockName = indicatorBlockName;
10
- exports.indicatorItemBlockName = indicatorItemBlockName;
11
- exports.wizardBlockName = wizardBlockName;
package/cjs/index.js DELETED
@@ -1,15 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var WizardSteps = require('./WizardSteps.js');
6
- var WizardStep = require('./WizardStep.js');
7
- var useWizard = require('./useWizard.js');
8
-
9
-
10
-
11
- exports.WizardStepsIndicator = WizardSteps["default"];
12
- exports.WizzardWithSchema = WizardSteps.WizzardWithSchema;
13
- exports.WizardStep = WizardStep["default"];
14
- exports.WizzardStepWithSchema = WizardStep.WizzardStepWithSchema;
15
- exports.useWizard = useWizard;
package/cjs/useWizard.js DELETED
@@ -1,44 +0,0 @@
1
- 'use strict';
2
-
3
- require('core-js/modules/web.dom-collections.iterator.js');
4
- var React = require('react');
5
- var dsUtilities = require('@elliemae/ds-utilities');
6
-
7
- const checkCanNext = (prevIndex, array) => array.length > prevIndex + 1;
8
-
9
- const checkCanPrevious = prevIndex => prevIndex - 1 >= 0;
10
-
11
- const noop = () => null;
12
-
13
- function useWizard(_ref) {
14
- let {
15
- steps: wizardSteps,
16
- current,
17
- onNext = noop,
18
- onPrevious = noop,
19
- initial = 0
20
- } = _ref;
21
- const [currentStep, setCurrentStep] = dsUtilities.useDerivedStateFromProps(current || initial);
22
- const handleNext = React.useCallback(() => {
23
- if (checkCanNext(currentStep, wizardSteps)) {
24
- onNext(currentStep);
25
- setCurrentStep(currentStep + 1);
26
- }
27
- });
28
- const handlePrevious = React.useCallback(() => {
29
- if (checkCanPrevious(currentStep)) {
30
- onPrevious(currentStep);
31
- setCurrentStep(currentStep - 1);
32
- }
33
- });
34
- return {
35
- current: currentStep,
36
- next: handleNext,
37
- previous: handlePrevious,
38
- canNext: checkCanNext(currentStep, wizardSteps),
39
- canPrevious: checkCanPrevious(currentStep),
40
- WizardCurrentContent: dsUtilities.get(wizardSteps, [currentStep, 'content'], () => null)
41
- };
42
- }
43
-
44
- module.exports = useWizard;
package/esm/WizardStep.js DELETED
@@ -1,63 +0,0 @@
1
- import _jsx from '@babel/runtime/helpers/esm/jsx';
2
- import { useMemo, isValidElement, cloneElement } from 'react';
3
- import { PropTypes, describe } from 'react-desc';
4
- import { aggregatedClasses } from '@elliemae/ds-classnames';
5
- import { get } from '@elliemae/ds-utilities';
6
- import { Checkmark } from '@elliemae/ds-icons';
7
- import { indicatorItemBlockName } from './blockNames.js';
8
-
9
- var _Checkmark;
10
- const Item = aggregatedClasses('div')("".concat(indicatorItemBlockName), null, _ref => {
11
- let {
12
- active,
13
- completed
14
- } = _ref;
15
- return {
16
- active,
17
- completed
18
- };
19
- });
20
- const Wrapper = aggregatedClasses('div')("".concat(indicatorItemBlockName, "-wrapper"));
21
- const Label = aggregatedClasses('span')(indicatorItemBlockName, 'label');
22
- const Bullet = aggregatedClasses('div')(indicatorItemBlockName, 'bullet');
23
- const BulletWrapper = aggregatedClasses('div')(indicatorItemBlockName, 'bullet-wrapper');
24
-
25
- function WizardStep(_ref2) {
26
- let {
27
- label = '',
28
- icon = null,
29
- iconCompleted = _Checkmark || (_Checkmark = /*#__PURE__*/_jsx(Checkmark, {})),
30
- iconActive = null,
31
- active = false,
32
- completed = false,
33
- index = 0
34
- } = _ref2;
35
- const currentIcon = useMemo(() => {
36
- if (active) return iconActive;
37
- if (completed) return iconCompleted;
38
- return icon;
39
- }, [active, completed]) || icon;
40
- const iconWithOptions = useMemo(() => /*#__PURE__*/isValidElement(currentIcon) ? /*#__PURE__*/cloneElement(currentIcon, {
41
- color: get(currentIcon, ['props', 'color']) || ['brand-primary', completed ? 600 : 500]
42
- }) : currentIcon || index + 1, [currentIcon]);
43
- return /*#__PURE__*/_jsx(Item, {
44
- classProps: {
45
- active,
46
- completed
47
- }
48
- }, void 0, /*#__PURE__*/_jsx(Wrapper, {}, void 0, /*#__PURE__*/_jsx(BulletWrapper, {}, void 0, /*#__PURE__*/_jsx(Bullet, {}, void 0, iconWithOptions)), /*#__PURE__*/_jsx(Label, {}, void 0, label)));
49
- }
50
-
51
- const wizzardStepProps = {
52
- label: PropTypes.string.description('Step label'),
53
- icon: PropTypes.oneOfType([PropTypes.element, PropTypes.string]).description('Default icon or number'),
54
- iconCompleted: PropTypes.element.description('Icon when the step is completed').defaultValue(Checkmark),
55
- iconActive: PropTypes.element.description('Icon when the step is active'),
56
- active: PropTypes.bool.description('Whether the step is active or not').defaultValue(false),
57
- completed: PropTypes.bool.description('Whether the step is completed or not').defaultValue(false),
58
- index: PropTypes.number.description('Current item index')
59
- };
60
- const WizzardStepWithSchema = describe(WizardStep);
61
- WizzardStepWithSchema.propTypes = wizzardStepProps;
62
-
63
- export { WizzardStepWithSchema, WizardStep as default };
@@ -1,55 +0,0 @@
1
- import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
2
- import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
3
- import 'core-js/modules/esnext.async-iterator.map.js';
4
- import 'core-js/modules/esnext.iterator.map.js';
5
- import 'core-js/modules/esnext.async-iterator.filter.js';
6
- import 'core-js/modules/esnext.iterator.constructor.js';
7
- import 'core-js/modules/esnext.iterator.filter.js';
8
- import 'core-js/modules/esnext.async-iterator.for-each.js';
9
- import 'core-js/modules/esnext.iterator.for-each.js';
10
- import React, { useMemo, cloneElement } from 'react';
11
- import { PropTypes, describe } from 'react-desc';
12
- import { aggregatedClasses } from '@elliemae/ds-classnames';
13
- import WizardStep from './WizardStep.js';
14
- import { indicatorBlockName } from './blockNames.js';
15
- import { jsx } from 'react/jsx-runtime';
16
-
17
- const _excluded = ["current", "steps", "children"];
18
-
19
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
20
-
21
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
22
- const StepsWrapper = aggregatedClasses('div')(indicatorBlockName);
23
-
24
- function WizardSteps(_ref) {
25
- let {
26
- current = 0,
27
- steps,
28
- children
29
- } = _ref,
30
- otherProps = _objectWithoutProperties(_ref, _excluded);
31
-
32
- const items = useMemo(() => {
33
- const mergeStepProps = (step, index) => ({
34
- index,
35
- active: current === index,
36
- completed: index < current
37
- });
38
-
39
- return steps ? steps.map((step, index) => /*#__PURE__*/jsx(WizardStep, _objectSpread(_objectSpread({}, step), mergeStepProps(step, index)), index)) : React.Children.map(children, (item, index) => /*#__PURE__*/cloneElement(item, mergeStepProps(item, index)));
40
- }, [current, children]);
41
- return /*#__PURE__*/jsx(StepsWrapper, _objectSpread(_objectSpread({}, otherProps), {}, {
42
- children: items
43
- }));
44
- }
45
-
46
- WizardSteps.Item = WizardStep;
47
- const wizzardProps = {
48
- current: PropTypes.number.description('Current active state index').defaultValue(0),
49
- steps: PropTypes.arrayOf(PropTypes.shape({})).description('Array of steps objects').defaultValue([]).isRequired,
50
- children: PropTypes.arrayOf(PropTypes.instanceOf(WizardStep)).description('List of WizardStep components')
51
- };
52
- const WizzardWithSchema = describe(WizardSteps);
53
- WizzardWithSchema.propTypes = wizzardProps;
54
-
55
- export { WizzardWithSchema, WizardSteps as default };
package/esm/blockNames.js DELETED
@@ -1,5 +0,0 @@
1
- const wizardBlockName = 'wizard';
2
- const indicatorBlockName = "".concat(wizardBlockName, "-steps-indicator");
3
- const indicatorItemBlockName = "".concat(indicatorBlockName, "-step");
4
-
5
- export { indicatorBlockName, indicatorItemBlockName, wizardBlockName };
package/esm/index.js DELETED
@@ -1,3 +0,0 @@
1
- export { default as WizardStepsIndicator, WizzardWithSchema } from './WizardSteps.js';
2
- export { default as WizardStep, WizzardStepWithSchema } from './WizardStep.js';
3
- export { default as useWizard } from './useWizard.js';
@@ -1,10 +0,0 @@
1
- declare namespace _default {
2
- export const title: string;
3
- export { WizardStepsIndicator as component };
4
- export namespace parameters {
5
- export { WizzardWithSchema as propsSchemas };
6
- }
7
- }
8
- export default _default;
9
- import { WizardStepsIndicator } from "@elliemae/ds-wizard";
10
- import { WizzardWithSchema } from "@elliemae/ds-wizard";
@@ -1,55 +0,0 @@
1
- /// <reference path="../../../../shared/typings/react-desc.d.ts" />
2
- /// <reference types="react" />
3
- declare function WizardStep({ label, icon, iconCompleted, iconActive, active, completed, index, }: {
4
- label?: string | undefined;
5
- icon?: null | undefined;
6
- iconCompleted?: JSX.Element | undefined;
7
- iconActive?: null | undefined;
8
- active?: boolean | undefined;
9
- completed?: boolean | undefined;
10
- index?: number | undefined;
11
- }): JSX.Element;
12
- declare namespace WizardStep {
13
- var propTypes: {
14
- label: {
15
- defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
16
- deprecated: import("react-desc").PropTypesDescValidator;
17
- };
18
- isRequired: import("react-desc").PropTypesDescValue;
19
- };
20
- icon: {
21
- defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
22
- deprecated: import("react-desc").PropTypesDescValidator;
23
- };
24
- isRequired: import("react-desc").PropTypesDescValue;
25
- };
26
- iconCompleted: {
27
- deprecated: import("react-desc").PropTypesDescValidator;
28
- };
29
- iconActive: {
30
- defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
31
- deprecated: import("react-desc").PropTypesDescValidator;
32
- };
33
- isRequired: import("react-desc").PropTypesDescValue;
34
- };
35
- active: {
36
- deprecated: import("react-desc").PropTypesDescValidator;
37
- };
38
- completed: {
39
- deprecated: import("react-desc").PropTypesDescValidator;
40
- };
41
- index: {
42
- defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
43
- deprecated: import("react-desc").PropTypesDescValidator;
44
- };
45
- isRequired: import("react-desc").PropTypesDescValue;
46
- };
47
- };
48
- }
49
- declare const WizzardStepWithSchema: {
50
- (props?: unknown): JSX.Element;
51
- propTypes: unknown;
52
- toTypescript: () => import("react-desc").TypescriptSchema;
53
- };
54
- export { WizzardStepWithSchema };
55
- export default WizardStep;
@@ -1,31 +0,0 @@
1
- /// <reference path="../../../../shared/typings/react-desc.d.ts" />
2
- /// <reference types="react" />
3
- import WizardStep from './WizardStep';
4
- declare function WizardSteps({ current, steps, children, ...otherProps }: {
5
- [x: string]: any;
6
- current?: number | undefined;
7
- steps: any;
8
- children: any;
9
- }): JSX.Element;
10
- declare namespace WizardSteps {
11
- var Item: typeof WizardStep;
12
- var propTypes: {
13
- current: {
14
- deprecated: import("react-desc").PropTypesDescValidator;
15
- };
16
- steps: any;
17
- children: {
18
- defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
19
- deprecated: import("react-desc").PropTypesDescValidator;
20
- };
21
- isRequired: import("react-desc").PropTypesDescValue;
22
- };
23
- };
24
- }
25
- declare const WizzardWithSchema: {
26
- (props?: unknown): JSX.Element;
27
- propTypes: unknown;
28
- toTypescript: () => import("react-desc").TypescriptSchema;
29
- };
30
- export { WizzardWithSchema };
31
- export default WizardSteps;
@@ -1,3 +0,0 @@
1
- export declare const wizardBlockName = "wizard";
2
- export declare const indicatorBlockName: string;
3
- export declare const indicatorItemBlockName: string;
package/types/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import WizardStepsIndicator, { WizzardWithSchema } from './WizardSteps';
2
- import WizardStep, { WizzardStepWithSchema } from './WizardStep';
3
- import useWizard from './useWizard';
4
- export { useWizard, WizardStepsIndicator, WizardStep, WizzardWithSchema, WizzardStepWithSchema, };
@@ -1,14 +0,0 @@
1
- export default function useWizard({ steps: wizardSteps, current, onNext, onPrevious, initial, }: {
2
- steps: any;
3
- current: any;
4
- onNext?: (() => null) | undefined;
5
- onPrevious?: (() => null) | undefined;
6
- initial?: number | undefined;
7
- }): {
8
- current: any;
9
- next: () => void;
10
- previous: () => void;
11
- canNext: boolean;
12
- canPrevious: boolean;
13
- WizardCurrentContent: any;
14
- };