@elliemae/ds-wizard 2.2.0 → 2.3.0-alpha.3

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/useWizard.js CHANGED
@@ -1,31 +1,55 @@
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
-
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");
7
35
  const checkCanNext = (prevIndex, array) => array.length > prevIndex + 1;
8
-
9
- const checkCanPrevious = prevIndex => prevIndex - 1 >= 0;
10
-
36
+ const checkCanPrevious = (prevIndex) => prevIndex - 1 >= 0;
11
37
  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(() => {
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)(() => {
23
47
  if (checkCanNext(currentStep, wizardSteps)) {
24
48
  onNext(currentStep);
25
49
  setCurrentStep(currentStep + 1);
26
50
  }
27
51
  });
28
- const handlePrevious = React.useCallback(() => {
52
+ const handlePrevious = (0, import_react.useCallback)(() => {
29
53
  if (checkCanPrevious(currentStep)) {
30
54
  onPrevious(currentStep);
31
55
  setCurrentStep(currentStep - 1);
@@ -37,8 +61,8 @@ function useWizard(_ref) {
37
61
  previous: handlePrevious,
38
62
  canNext: checkCanNext(currentStep, wizardSteps),
39
63
  canPrevious: checkCanPrevious(currentStep),
40
- WizardCurrentContent: dsUtilities.get(wizardSteps, [currentStep, 'content'], () => null)
64
+ WizardCurrentContent: (0, import_ds_utilities.get)(wizardSteps, [currentStep, "content"], () => null)
41
65
  };
42
66
  }
43
-
44
- module.exports = useWizard;
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
+ }
package/esm/WizardStep.js CHANGED
@@ -1,63 +1,56 @@
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;
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
+ }) {
35
25
  const currentIcon = useMemo(() => {
36
- if (active) return iconActive;
37
- if (completed) return iconCompleted;
26
+ if (active)
27
+ return iconActive;
28
+ if (completed)
29
+ return iconCompleted;
38
30
  return icon;
39
31
  }, [active, completed]) || icon;
40
- const iconWithOptions = useMemo(() => /*#__PURE__*/isValidElement(currentIcon) ? /*#__PURE__*/cloneElement(currentIcon, {
41
- color: get(currentIcon, ['props', 'color']) || ['brand-primary', completed ? 600 : 500]
32
+ const iconWithOptions = useMemo(() => isValidElement(currentIcon) ? cloneElement(currentIcon, {
33
+ color: get(currentIcon, ["props", "color"]) || ["brand-primary", completed ? 600 : 500]
42
34
  }) : 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)));
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)));
49
38
  }
50
-
51
39
  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')
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")
59
47
  };
48
+ WizardStep.propTypes = wizzardStepProps;
60
49
  const WizzardStepWithSchema = describe(WizardStep);
61
50
  WizzardStepWithSchema.propTypes = wizzardStepProps;
62
-
63
- export { WizzardStepWithSchema, WizardStep as default };
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
+ }
@@ -1,55 +1,39 @@
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
-
1
+ import * as React from "react";
2
+ import React2, { cloneElement, useMemo } from "react";
3
+ import { describe, PropTypes } from "react-desc";
4
+ import { aggregatedClasses } from "@elliemae/ds-classnames";
5
+ import WizardStep from "./WizardStep";
6
+ import { indicatorBlockName } from "./blockNames";
7
+ const StepsWrapper = aggregatedClasses("div")(indicatorBlockName);
8
+ function WizardSteps({ current = 0, steps, children, ...otherProps }) {
32
9
  const items = useMemo(() => {
33
10
  const mergeStepProps = (step, index) => ({
34
11
  index,
35
12
  active: current === index,
36
13
  completed: index < current
37
14
  });
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)));
15
+ return steps ? steps.map((step, index) => /* @__PURE__ */ React2.createElement(WizardStep, {
16
+ key: index,
17
+ ...step,
18
+ ...mergeStepProps(step, index)
19
+ })) : React2.Children.map(children, (item, index) => cloneElement(item, mergeStepProps(item, index)));
40
20
  }, [current, children]);
41
- return /*#__PURE__*/jsx(StepsWrapper, _objectSpread(_objectSpread({}, otherProps), {}, {
42
- children: items
43
- }));
21
+ return /* @__PURE__ */ React2.createElement(StepsWrapper, {
22
+ ...otherProps
23
+ }, items);
44
24
  }
45
-
46
25
  WizardSteps.Item = WizardStep;
47
26
  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')
27
+ current: PropTypes.number.description("Current active state index").defaultValue(0),
28
+ steps: PropTypes.arrayOf(PropTypes.shape({})).description("Array of steps objects").defaultValue([]).isRequired,
29
+ children: PropTypes.arrayOf(PropTypes.instanceOf(WizardStep)).description("List of WizardStep components")
51
30
  };
31
+ WizardSteps.propTypes = wizzardProps;
52
32
  const WizzardWithSchema = describe(WizardSteps);
53
33
  WizzardWithSchema.propTypes = wizzardProps;
54
-
55
- export { WizzardWithSchema, WizardSteps as default };
34
+ var WizardSteps_default = WizardSteps;
35
+ export {
36
+ WizzardWithSchema,
37
+ WizardSteps_default as default
38
+ };
39
+ //# 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,EAAE,UAAU,GAAG,OAAO,aAAa,cAAc;AACpE,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,SAAW;AAAA,SAAU,eAAe,MAAM;AAAA,UAE7D,OAAM,SAAS,IAAI,UAAU,CAAC,MAAM,UAClC,aAAa,MAAM,eAAe,MAAM;AAAA,KAE7C,CAAC,SAAS;AAEb,SAAO,qCAAC,cAAD;AAAA,OAAkB;AAAA,KAAa;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
+ }
package/esm/blockNames.js CHANGED
@@ -1,5 +1,10 @@
1
- const wizardBlockName = 'wizard';
2
- const indicatorBlockName = "".concat(wizardBlockName, "-steps-indicator");
3
- const indicatorItemBlockName = "".concat(indicatorBlockName, "-step");
4
-
5
- export { indicatorBlockName, indicatorItemBlockName, wizardBlockName };
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
+ }
package/esm/index.js CHANGED
@@ -1,3 +1,12 @@
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
+ 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,28 +1,28 @@
1
- import _jsx from '@babel/runtime/helpers/esm/jsx';
2
- import 'react';
3
-
4
- var _div, _div2, _div3, _div4;
5
-
6
- const Step1Content = () => _div || (_div = /*#__PURE__*/_jsx("div", {}, void 0, "Step 1 Content"));
7
-
8
- const Step2Content = () => _div2 || (_div2 = /*#__PURE__*/_jsx("div", {}, void 0, "Step 2 Content"));
9
-
10
- const Step3Content = () => _div3 || (_div3 = /*#__PURE__*/_jsx("div", {}, void 0, "Step 3 Content"));
11
-
12
- const Step4Content = () => _div4 || (_div4 = /*#__PURE__*/_jsx("div", {}, void 0, "Step 4 Content"));
13
-
14
- const steps = [{
15
- label: 'Step 1',
16
- content: Step1Content
17
- }, {
18
- label: 'Step Lorem Ipsum',
19
- content: Step2Content
20
- }, {
21
- label: 'Step Lorem',
22
- content: Step3Content
23
- }, {
24
- label: 'Step Lorem 4',
25
- content: Step4Content
26
- }];
27
-
28
- export { steps };
1
+ import * as React from "react";
2
+ import React2 from "react";
3
+ const Step1Content = () => /* @__PURE__ */ React2.createElement("div", null, "Step 1 Content");
4
+ const Step2Content = () => /* @__PURE__ */ React2.createElement("div", null, "Step 2 Content");
5
+ const Step3Content = () => /* @__PURE__ */ React2.createElement("div", null, "Step 3 Content");
6
+ const Step4Content = () => /* @__PURE__ */ React2.createElement("div", null, "Step 4 Content");
7
+ const steps = [
8
+ {
9
+ label: "Step 1",
10
+ content: Step1Content
11
+ },
12
+ {
13
+ label: "Step Lorem Ipsum",
14
+ content: Step2Content
15
+ },
16
+ {
17
+ label: "Step Lorem",
18
+ content: Step3Content
19
+ },
20
+ {
21
+ label: "Step Lorem 4",
22
+ content: Step4Content
23
+ }
24
+ ];
25
+ export {
26
+ steps
27
+ };
28
+ //# sourceMappingURL=steps.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/stories/steps.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\n\nconst Step1Content = () => <div>Step 1 Content</div>;\nconst Step2Content = () => <div>Step 2 Content</div>;\nconst Step3Content = () => <div>Step 3 Content</div>;\nconst Step4Content = () => <div>Step 4 Content</div>;\n\nexport const steps = [\n {\n label: 'Step 1',\n content: Step1Content,\n },\n {\n label: 'Step Lorem Ipsum',\n content: Step2Content,\n },\n {\n label: 'Step Lorem',\n content: Step3Content,\n },\n {\n label: 'Step Lorem 4',\n content: Step4Content,\n },\n];\n"],
5
+ "mappings": "AAAA;ACAA;AAEA,MAAM,eAAe,MAAM,qCAAC,OAAD,MAAK;AAChC,MAAM,eAAe,MAAM,qCAAC,OAAD,MAAK;AAChC,MAAM,eAAe,MAAM,qCAAC,OAAD,MAAK;AAChC,MAAM,eAAe,MAAM,qCAAC,OAAD,MAAK;AAEzB,MAAM,QAAQ;AAAA,EACnB;AAAA,IACE,OAAO;AAAA,IACP,SAAS;AAAA;AAAA,EAEX;AAAA,IACE,OAAO;AAAA,IACP,SAAS;AAAA;AAAA,EAEX;AAAA,IACE,OAAO;AAAA,IACP,SAAS;AAAA;AAAA,EAEX;AAAA,IACE,OAAO;AAAA,IACP,SAAS;AAAA;AAAA;",
6
+ "names": []
7
+ }
package/esm/useWizard.js CHANGED
@@ -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,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-wizard",
3
- "version": "2.2.0",
3
+ "version": "2.3.0-alpha.3",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Wizard",
6
6
  "module": "./esm/index.js",
@@ -52,11 +52,11 @@
52
52
  "build": "node ../../scripts/build/build.js"
53
53
  },
54
54
  "dependencies": {
55
- "@elliemae/ds-button": "2.2.0",
56
- "@elliemae/ds-classnames": "2.2.0",
57
- "@elliemae/ds-icons": "2.2.0",
58
- "@elliemae/ds-utilities": "2.2.0",
59
- "@elliemae/ds-wizard": "2.2.0",
55
+ "@elliemae/ds-button": "2.3.0-alpha.3",
56
+ "@elliemae/ds-classnames": "2.3.0-alpha.3",
57
+ "@elliemae/ds-icons": "2.3.0-alpha.3",
58
+ "@elliemae/ds-utilities": "2.3.0-alpha.3",
59
+ "@elliemae/ds-wizard": "2.3.0-alpha.3",
60
60
  "prop-types": "~15.7.2",
61
61
  "react-desc": "~4.1.3"
62
62
  },
@@ -1,18 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var dsWizard = require('@elliemae/ds-wizard');
6
- var wizzardOverview_stories = require('./stories/wizzard-overview.stories.js');
7
-
8
- /* eslint-disable import/no-unresolved */
9
- var DSWizard_stories = {
10
- title: 'Wizzard',
11
- component: dsWizard.WizardStepsIndicator,
12
- parameters: {
13
- propsSchemas: dsWizard.WizzardWithSchema
14
- }
15
- };
16
-
17
- exports.Overview = wizzardOverview_stories.Overview;
18
- exports["default"] = DSWizard_stories;
@@ -1,61 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var _jsx = require('@babel/runtime/helpers/jsx');
6
- require('react');
7
- var dsWizard = require('@elliemae/ds-wizard');
8
- var DSButton = require('@elliemae/ds-button');
9
- var steps = require('./steps.js');
10
- var jsxRuntime = require('react/jsx-runtime');
11
-
12
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
-
14
- var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
15
- var DSButton__default = /*#__PURE__*/_interopDefaultLegacy(DSButton);
16
-
17
- const Overview = () => {
18
- const {
19
- WizardCurrentContent,
20
- current,
21
- next,
22
- previous,
23
- canNext,
24
- canPrevious
25
- } = dsWizard.useWizard({
26
- steps: steps.steps
27
- });
28
- return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
29
- children: [/*#__PURE__*/_jsx__default["default"](dsWizard.WizardStepsIndicator, {
30
- current: current,
31
- steps: steps.steps
32
- }), /*#__PURE__*/_jsx__default["default"]("div", {
33
- style: {
34
- margin: '10px 0',
35
- padding: 10,
36
- border: '1px solid #ddd'
37
- }
38
- }, void 0, /*#__PURE__*/_jsx__default["default"](WizardCurrentContent, {
39
- data: {
40
- someExtraData: 'step information'
41
- }
42
- })), /*#__PURE__*/_jsx__default["default"]("div", {
43
- style: {
44
- display: 'flex',
45
- width: 180,
46
- justifyContent: 'space-between'
47
- }
48
- }, void 0, /*#__PURE__*/_jsx__default["default"](DSButton__default["default"], {
49
- buttonType: "secondary",
50
- disabled: !canPrevious,
51
- labelText: "Previous",
52
- onClick: previous
53
- }), /*#__PURE__*/_jsx__default["default"](DSButton__default["default"], {
54
- disabled: !canNext,
55
- labelText: "Next",
56
- onClick: next
57
- }))]
58
- });
59
- };
60
-
61
- exports.Overview = Overview;
@@ -1,13 +0,0 @@
1
- import { WizardStepsIndicator, WizzardWithSchema } from '@elliemae/ds-wizard';
2
- export { Overview } from './stories/wizzard-overview.stories.js';
3
-
4
- /* eslint-disable import/no-unresolved */
5
- var DSWizard_stories = {
6
- title: 'Wizzard',
7
- component: WizardStepsIndicator,
8
- parameters: {
9
- propsSchemas: WizzardWithSchema
10
- }
11
- };
12
-
13
- export { DSWizard_stories as default };