@elliemae/ds-wizard 2.2.0-alpha.2 → 2.2.0-beta.0

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,55 +1,31 @@
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 = __toESM(require("react"));
34
- var import_ds_utilities = __toESM(require("@elliemae/ds-utilities"));
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
+
35
7
  const checkCanNext = (prevIndex, array) => array.length > prevIndex + 1;
36
- const checkCanPrevious = (prevIndex) => prevIndex - 1 >= 0;
8
+
9
+ const checkCanPrevious = prevIndex => prevIndex - 1 >= 0;
10
+
37
11
  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)(() => {
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(() => {
47
23
  if (checkCanNext(currentStep, wizardSteps)) {
48
24
  onNext(currentStep);
49
25
  setCurrentStep(currentStep + 1);
50
26
  }
51
27
  });
52
- const handlePrevious = (0, import_react.useCallback)(() => {
28
+ const handlePrevious = React.useCallback(() => {
53
29
  if (checkCanPrevious(currentStep)) {
54
30
  onPrevious(currentStep);
55
31
  setCurrentStep(currentStep - 1);
@@ -61,8 +37,8 @@ function useWizard({
61
37
  previous: handlePrevious,
62
38
  canNext: checkCanNext(currentStep, wizardSteps),
63
39
  canPrevious: checkCanPrevious(currentStep),
64
- WizardCurrentContent: (0, import_ds_utilities.get)(wizardSteps, [currentStep, "content"], () => null)
40
+ WizardCurrentContent: dsUtilities.get(wizardSteps, [currentStep, 'content'], () => null)
65
41
  };
66
42
  }
67
- module.exports = __toCommonJS(useWizard_exports);
68
- //# sourceMappingURL=useWizard.js.map
43
+
44
+ module.exports = useWizard;
@@ -0,0 +1,13 @@
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 };
package/esm/WizardStep.js CHANGED
@@ -1,56 +1,63 @@
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
- }) {
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;
25
35
  const currentIcon = useMemo(() => {
26
- if (active)
27
- return iconActive;
28
- if (completed)
29
- return iconCompleted;
36
+ if (active) return iconActive;
37
+ if (completed) return iconCompleted;
30
38
  return icon;
31
39
  }, [active, completed]) || icon;
32
- const iconWithOptions = useMemo(() => isValidElement(currentIcon) ? cloneElement(currentIcon, {
33
- color: get(currentIcon, ["props", "color"]) || ["brand-primary", completed ? 600 : 500]
40
+ const iconWithOptions = useMemo(() => /*#__PURE__*/isValidElement(currentIcon) ? /*#__PURE__*/cloneElement(currentIcon, {
41
+ color: get(currentIcon, ['props', 'color']) || ['brand-primary', completed ? 600 : 500]
34
42
  }) : 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)));
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)));
38
49
  }
50
+
39
51
  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")
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')
47
59
  };
48
- WizardStep.propTypes = wizzardStepProps;
49
60
  const WizzardStepWithSchema = describe(WizardStep);
50
61
  WizzardStepWithSchema.propTypes = wizzardStepProps;
51
- var WizardStep_default = WizardStep;
52
- export {
53
- WizzardStepWithSchema,
54
- WizardStep_default as default
55
- };
56
- //# sourceMappingURL=WizardStep.js.map
62
+
63
+ export { WizzardStepWithSchema, WizardStep as default };
@@ -1,39 +1,55 @@
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 }) {
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
+
9
32
  const items = useMemo(() => {
10
33
  const mergeStepProps = (step, index) => ({
11
34
  index,
12
35
  active: current === index,
13
36
  completed: index < current
14
37
  });
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)));
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)));
20
40
  }, [current, children]);
21
- return /* @__PURE__ */ React2.createElement(StepsWrapper, {
22
- ...otherProps
23
- }, items);
41
+ return /*#__PURE__*/jsx(StepsWrapper, _objectSpread(_objectSpread({}, otherProps), {}, {
42
+ children: items
43
+ }));
24
44
  }
45
+
25
46
  WizardSteps.Item = WizardStep;
26
47
  const wizzardProps = {
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")
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')
30
51
  };
31
- WizardSteps.propTypes = wizzardProps;
32
52
  const WizzardWithSchema = describe(WizardSteps);
33
53
  WizzardWithSchema.propTypes = wizzardProps;
34
- var WizardSteps_default = WizardSteps;
35
- export {
36
- WizzardWithSchema,
37
- WizardSteps_default as default
38
- };
39
- //# sourceMappingURL=WizardSteps.js.map
54
+
55
+ export { WizzardWithSchema, WizardSteps as default };
package/esm/blockNames.js CHANGED
@@ -1,10 +1,5 @@
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
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 CHANGED
@@ -1,12 +1,3 @@
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
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,28 +1,28 @@
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
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 };
@@ -0,0 +1,52 @@
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import 'react';
3
+ import { useWizard, WizardStepsIndicator } from '@elliemae/ds-wizard';
4
+ import DSButton from '@elliemae/ds-button';
5
+ import { steps } from './steps.js';
6
+ import { jsxs, Fragment } from 'react/jsx-runtime';
7
+
8
+ const Overview = () => {
9
+ const {
10
+ WizardCurrentContent,
11
+ current,
12
+ next,
13
+ previous,
14
+ canNext,
15
+ canPrevious
16
+ } = useWizard({
17
+ steps
18
+ });
19
+ return /*#__PURE__*/jsxs(Fragment, {
20
+ children: [/*#__PURE__*/_jsx(WizardStepsIndicator, {
21
+ current: current,
22
+ steps: steps
23
+ }), /*#__PURE__*/_jsx("div", {
24
+ style: {
25
+ margin: '10px 0',
26
+ padding: 10,
27
+ border: '1px solid #ddd'
28
+ }
29
+ }, void 0, /*#__PURE__*/_jsx(WizardCurrentContent, {
30
+ data: {
31
+ someExtraData: 'step information'
32
+ }
33
+ })), /*#__PURE__*/_jsx("div", {
34
+ style: {
35
+ display: 'flex',
36
+ width: 180,
37
+ justifyContent: 'space-between'
38
+ }
39
+ }, void 0, /*#__PURE__*/_jsx(DSButton, {
40
+ buttonType: "secondary",
41
+ disabled: !canPrevious,
42
+ labelText: "Previous",
43
+ onClick: previous
44
+ }), /*#__PURE__*/_jsx(DSButton, {
45
+ disabled: !canNext,
46
+ labelText: "Next",
47
+ onClick: next
48
+ }))]
49
+ });
50
+ };
51
+
52
+ export { Overview };
package/esm/useWizard.js CHANGED
@@ -1,16 +1,21 @@
1
- import * as React from "react";
2
- import { useCallback } from "react";
3
- import { get, useDerivedStateFromProps } from "@elliemae/ds-utilities";
1
+ import 'core-js/modules/web.dom-collections.iterator.js';
2
+ import { useCallback } from 'react';
3
+ import { useDerivedStateFromProps, get } from '@elliemae/ds-utilities';
4
+
4
5
  const checkCanNext = (prevIndex, array) => array.length > prevIndex + 1;
5
- const checkCanPrevious = (prevIndex) => prevIndex - 1 >= 0;
6
+
7
+ const checkCanPrevious = prevIndex => prevIndex - 1 >= 0;
8
+
6
9
  const noop = () => null;
7
- function useWizard({
8
- steps: wizardSteps,
9
- current,
10
- onNext = noop,
11
- onPrevious = noop,
12
- initial = 0
13
- }) {
10
+
11
+ function useWizard(_ref) {
12
+ let {
13
+ steps: wizardSteps,
14
+ current,
15
+ onNext = noop,
16
+ onPrevious = noop,
17
+ initial = 0
18
+ } = _ref;
14
19
  const [currentStep, setCurrentStep] = useDerivedStateFromProps(current || initial);
15
20
  const handleNext = useCallback(() => {
16
21
  if (checkCanNext(currentStep, wizardSteps)) {
@@ -30,10 +35,8 @@ function useWizard({
30
35
  previous: handlePrevious,
31
36
  canNext: checkCanNext(currentStep, wizardSteps),
32
37
  canPrevious: checkCanPrevious(currentStep),
33
- WizardCurrentContent: get(wizardSteps, [currentStep, "content"], () => null)
38
+ WizardCurrentContent: get(wizardSteps, [currentStep, 'content'], () => null)
34
39
  };
35
40
  }
36
- export {
37
- useWizard as default
38
- };
39
- //# sourceMappingURL=useWizard.js.map
41
+
42
+ export { useWizard as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-wizard",
3
- "version": "2.2.0-alpha.2",
3
+ "version": "2.2.0-beta.0",
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-alpha.2",
56
- "@elliemae/ds-classnames": "2.2.0-alpha.2",
57
- "@elliemae/ds-icons": "2.2.0-alpha.2",
58
- "@elliemae/ds-utilities": "2.2.0-alpha.2",
59
- "@elliemae/ds-wizard": "2.2.0-alpha.2",
55
+ "@elliemae/ds-button": "2.2.0-beta.0",
56
+ "@elliemae/ds-classnames": "2.2.0-beta.0",
57
+ "@elliemae/ds-icons": "2.2.0-beta.0",
58
+ "@elliemae/ds-utilities": "2.2.0-beta.0",
59
+ "@elliemae/ds-wizard": "2.2.0-beta.0",
60
60
  "prop-types": "~15.7.2",
61
61
  "react-desc": "~4.1.3"
62
62
  },
@@ -47,15 +47,7 @@ declare namespace WizardStep {
47
47
  };
48
48
  }
49
49
  declare const WizzardStepWithSchema: {
50
- (props?: {
51
- label?: string | undefined;
52
- icon?: null | undefined;
53
- iconCompleted?: JSX.Element | undefined;
54
- iconActive?: null | undefined;
55
- active?: boolean | undefined;
56
- completed?: boolean | undefined;
57
- index?: number | undefined;
58
- } | undefined): JSX.Element;
50
+ (props?: unknown): JSX.Element;
59
51
  propTypes: unknown;
60
52
  toTypescript: () => import("react-desc").TypescriptSchema;
61
53
  };
@@ -23,12 +23,7 @@ declare namespace WizardSteps {
23
23
  };
24
24
  }
25
25
  declare const WizzardWithSchema: {
26
- (props?: {
27
- [x: string]: any;
28
- current?: number | undefined;
29
- steps: any;
30
- children: any;
31
- } | undefined): JSX.Element;
26
+ (props?: unknown): JSX.Element;
32
27
  propTypes: unknown;
33
28
  toTypescript: () => import("react-desc").TypescriptSchema;
34
29
  };
@@ -1,7 +0,0 @@
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
- }
@@ -1,7 +0,0 @@
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,EAAE,UAAU,GAAG,OAAO,aAAa,cAAc;AACpE,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,SAAW;AAAA,SAAU,eAAe,MAAM;AAAA,UAE7D,qBAAM,SAAS,IAAI,UAAU,CAAC,MAAM,UAClC,+BAAa,MAAM,eAAe,MAAM;AAAA,KAE7C,CAAC,SAAS;AAEb,SAAO,mDAAC,cAAD;AAAA,OAAkB;AAAA,KAAa;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
- }
@@ -1,7 +0,0 @@
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
- }
package/cjs/index.js.map DELETED
@@ -1,7 +0,0 @@
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
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/stories/steps.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["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", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAkB;AAElB,MAAM,eAAe,MAAM,mDAAC,OAAD,MAAK;AAChC,MAAM,eAAe,MAAM,mDAAC,OAAD,MAAK;AAChC,MAAM,eAAe,MAAM,mDAAC,OAAD,MAAK;AAChC,MAAM,eAAe,MAAM,mDAAC,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
- }
@@ -1,7 +0,0 @@
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
- }