@elliemae/ds-wizard 2.3.0-alpha.9 → 2.3.0-next.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.
Files changed (48) hide show
  1. package/cjs/DSWizard.stories.js +18 -0
  2. package/cjs/WizardStep.js +72 -0
  3. package/cjs/WizardSteps.js +66 -0
  4. package/cjs/blockNames.js +11 -0
  5. package/cjs/index.js +15 -0
  6. package/cjs/stories/steps.js +36 -0
  7. package/cjs/stories/wizzard-overview.stories.js +61 -0
  8. package/cjs/useWizard.js +44 -0
  9. package/esm/DSWizard.stories.js +13 -0
  10. package/esm/WizardStep.js +63 -0
  11. package/esm/WizardSteps.js +55 -0
  12. package/esm/blockNames.js +5 -0
  13. package/esm/index.js +3 -0
  14. package/esm/stories/steps.js +28 -0
  15. package/esm/stories/wizzard-overview.stories.js +52 -0
  16. package/{dist/esm → esm}/useWizard.js +19 -16
  17. package/package.json +31 -33
  18. package/{dist/types → types}/DSWizard.stories.d.ts +2 -0
  19. package/{dist/types → types}/WizardStep.d.ts +0 -0
  20. package/{dist/types → types}/WizardSteps.d.ts +0 -0
  21. package/{dist/types → types}/blockNames.d.ts +0 -0
  22. package/{dist/types → types}/index.d.ts +0 -0
  23. package/{dist/types → types}/stories/steps.d.ts +0 -0
  24. package/{dist/types → types}/stories/wizzard-overview.stories.d.ts +0 -0
  25. package/{dist/types → types}/useWizard.d.ts +0 -0
  26. package/dist/cjs/WizardStep.js +0 -85
  27. package/dist/cjs/WizardStep.js.map +0 -7
  28. package/dist/cjs/WizardSteps.js +0 -68
  29. package/dist/cjs/WizardSteps.js.map +0 -7
  30. package/dist/cjs/blockNames.js +0 -39
  31. package/dist/cjs/blockNames.js.map +0 -7
  32. package/dist/cjs/index.js +0 -41
  33. package/dist/cjs/index.js.map +0 -7
  34. package/dist/cjs/stories/steps.js +0 -57
  35. package/dist/cjs/stories/steps.js.map +0 -7
  36. package/dist/cjs/useWizard.js +0 -68
  37. package/dist/cjs/useWizard.js.map +0 -7
  38. package/dist/esm/WizardStep.js +0 -56
  39. package/dist/esm/WizardStep.js.map +0 -7
  40. package/dist/esm/WizardSteps.js +0 -39
  41. package/dist/esm/WizardSteps.js.map +0 -7
  42. package/dist/esm/blockNames.js +0 -10
  43. package/dist/esm/blockNames.js.map +0 -7
  44. package/dist/esm/index.js +0 -12
  45. package/dist/esm/index.js.map +0 -7
  46. package/dist/esm/stories/steps.js +0 -28
  47. package/dist/esm/stories/steps.js.map +0 -7
  48. package/dist/esm/useWizard.js.map +0 -7
@@ -1,39 +0,0 @@
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 }) {
9
- const items = useMemo(() => {
10
- const mergeStepProps = (step, index) => ({
11
- index,
12
- active: current === index,
13
- completed: index < current
14
- });
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)));
20
- }, [current, children]);
21
- return /* @__PURE__ */ React2.createElement(StepsWrapper, {
22
- ...otherProps
23
- }, items);
24
- }
25
- WizardSteps.Item = WizardStep;
26
- 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")
30
- };
31
- WizardSteps.propTypes = wizzardProps;
32
- const WizzardWithSchema = describe(WizardSteps);
33
- WizzardWithSchema.propTypes = wizzardProps;
34
- var WizardSteps_default = WizardSteps;
35
- export {
36
- WizzardWithSchema,
37
- WizardSteps_default as default
38
- };
39
- //# sourceMappingURL=WizardSteps.js.map
@@ -1,7 +0,0 @@
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
- }
@@ -1,10 +0,0 @@
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,7 +0,0 @@
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/dist/esm/index.js DELETED
@@ -1,12 +0,0 @@
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,7 +0,0 @@
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 +0,0 @@
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,7 +0,0 @@
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
- }
@@ -1,7 +0,0 @@
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
- }