@bonprix-ds/react-step-navi 1.0.3 → 1.0.4

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/dist/index.d.ts CHANGED
@@ -1,22 +1,16 @@
1
- import { FC } from 'react';
1
+ import { default as default_2 } from 'react';
2
2
  import { ReactElement } from 'react';
3
3
 
4
- declare interface Props {
5
- /** The name of the step. */
6
- children: string;
7
- /** The href attribute for the step link. */
8
- href?: string;
9
- }
10
-
11
- declare interface PropsInternal extends Props {
12
- active?: boolean;
13
- completed?: boolean;
14
- disabled?: boolean;
15
- }
4
+ declare type StepElement = ReactElement<StepNaviStepProps & StepNaviStepInternalProps, typeof StepNaviStep>;
16
5
 
17
- declare type StepElement = ReactElement<PropsInternal, typeof StepNaviStep>;
18
-
19
- declare const StepNavi: FC<StepNaviProps> & Subcomponents;
6
+ declare const StepNavi: {
7
+ ({ completedSteps, activeStep, children, ariaLabel }: StepNaviProps): default_2.JSX.Element;
8
+ displayName: string;
9
+ Step: {
10
+ ({ children, href, active, completed, disabled }: StepNaviStepProps & StepNaviStepInternalProps): default_2.JSX.Element;
11
+ displayName: string;
12
+ };
13
+ };
20
14
  export default StepNavi;
21
15
 
22
16
  export declare interface StepNaviProps {
@@ -30,10 +24,26 @@ export declare interface StepNaviProps {
30
24
  ariaLabel?: string;
31
25
  }
32
26
 
33
- declare const StepNaviStep: FC<Props>;
27
+ declare const StepNaviStep: {
28
+ ({ children, href, active, completed, disabled }: StepNaviStepProps & StepNaviStepInternalProps): default_2.JSX.Element;
29
+ displayName: string;
30
+ };
31
+
32
+ /**
33
+ * `StepNavi` derives these for each of its steps and passes them in. They are not meant to be set
34
+ * from the outside, so they are tagged `@internal` and left out of the generated API table.
35
+ */
36
+ declare interface StepNaviStepInternalProps {
37
+ /* Excluded from this release type: active */
38
+ /* Excluded from this release type: completed */
39
+ /* Excluded from this release type: disabled */
40
+ }
34
41
 
35
- declare interface Subcomponents {
36
- Step: typeof StepNaviStep;
42
+ declare interface StepNaviStepProps {
43
+ /** The name of the step. */
44
+ children: string;
45
+ /** The href attribute for the step link. */
46
+ href?: string;
37
47
  }
38
48
 
39
49
  export { }
package/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
- "use client";
2
1
  import { Children as e, cloneElement as t } from "react";
3
2
  import n from "@bonprix-ds/react-icon";
4
3
  import { tv as r } from "tailwind-variants";
@@ -46,7 +45,11 @@ var o = r({
46
45
  })
47
46
  ]
48
47
  });
49
- }, c = (e, t, n) => e > n + 1 ? (console.error("activeStep must not be greater than completedSteps + 1"), n + 1) : e > t ? (console.error("activeStep must not be greater than the amount of steps. activeStep is set to last available step"), t) : e, l = ({ completedSteps: n = 0, activeStep: r = n + 1, children: a, ariaLabel: o }) => {
48
+ };
49
+ s.displayName = "StepNavi.Step";
50
+ //#endregion
51
+ //#region src/StepNavi.tsx
52
+ var c = (e, t, n) => e > n + 1 ? (console.error("activeStep must not be greater than completedSteps + 1"), n + 1) : e > t ? (console.error("activeStep must not be greater than the amount of steps. activeStep is set to last available step"), t) : e, l = ({ completedSteps: n = 0, activeStep: r = n + 1, children: a, ariaLabel: o }) => {
50
53
  let s = e.toArray(a), l = c(r, s.length, n);
51
54
  return /* @__PURE__ */ i("nav", {
52
55
  "aria-label": o,
@@ -69,7 +72,7 @@ var o = r({
69
72
  })
70
73
  });
71
74
  };
72
- l.displayName = "StepNavi", l.Step = s, l.Step.displayName = "StepNavi.Step";
75
+ l.displayName = "StepNavi", l.Step = s;
73
76
  //#endregion
74
77
  export { l as default };
75
78
 
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/StepNaviStep.tsx","../src/StepNavi.tsx"],"sourcesContent":["// inspired by https://a11y-guidelines.orange.com/en/articles/disable-elements/#disable-a-link\nimport Icon from \"@bonprix-ds/react-icon\";\nimport React, { FC } from \"react\";\nimport { tv } from \"tailwind-variants\";\n\nconst generateClasses = tv({\n slots: {\n container: \"preflight w-full flex flex-col gap-1.5 items-center l:items-start xl:items-start group focus:outline-none\",\n icon: \"h-5 w-5 fill-clr-fg-success invisible\",\n bar: \"w-full h-1 bg-clr-bg-disabled\",\n labelSlot: [\n \"typography-input-helper-text text-center text-clr-primary l:text-left xl:text-left px-1 break-all\",\n \"border border-transparent rounded-sm group-focus:border-clr-primary\",\n ],\n },\n variants: {\n active: {\n true: {\n bar: \"bg-clr-primary\",\n },\n },\n completed: {\n true: { icon: \"visible\" },\n },\n disabled: {\n true: {\n labelSlot: \"text-clr-disabled\",\n },\n false: {\n bar: \"group-hover:bg-clr-primary\",\n },\n },\n },\n});\n\nexport interface PropsInternal extends Props {\n active?: boolean;\n completed?: boolean;\n disabled?: boolean;\n}\n\ninterface Props {\n /** The name of the step. */\n children: string;\n /** The href attribute for the step link. */\n href?: string;\n}\n\nconst StepNaviStep: FC<Props> = ({ children, href, active, completed, disabled }: PropsInternal) => {\n const { container, icon, bar, labelSlot } = generateClasses({ active, completed, disabled });\n return (\n <a\n href={disabled ? undefined : href}\n className={container()}\n aria-current={active ? \"step\" : \"false\"}\n aria-disabled={disabled ? \"true\" : \"false\"}\n data-bpds-completed={completed}\n >\n <Icon variant=\"check-bold\" className={icon()} />\n <div className={bar()}></div>\n <div className={labelSlot()}>\n {children}\n {completed && <span className=\"sr-only\"> erfüllter schritt</span>}\n </div>\n </a>\n );\n};\n\nexport default StepNaviStep;\n","\"use client\";\n\nimport React, { Children, cloneElement, FC, ReactElement } from \"react\";\n\nimport StepNaviStep, { PropsInternal as StepNaviStepInternalProps } from \"./StepNaviStep\";\n\ninterface Subcomponents {\n Step: typeof StepNaviStep;\n}\n\ntype StepElement = ReactElement<StepNaviStepInternalProps, typeof StepNaviStep>;\n\nexport interface Props {\n /** StepNavi.Step subcomponents should be placed here. */\n children: StepElement | StepElement[];\n /** Amount of completed steps. */\n completedSteps?: number;\n /** Currently active step. Not index based, so starts with 1. */\n activeStep?: number;\n /** Accessible label for the navigation. */\n ariaLabel?: string;\n}\n\nconst checkActiveStep = (activeStep: number, stepsQuantity: number, completedSteps: number) => {\n if (activeStep > completedSteps + 1) {\n console.error(\"activeStep must not be greater than completedSteps + 1\");\n return completedSteps + 1;\n }\n\n if (activeStep > stepsQuantity) {\n console.error(\"activeStep must not be greater than the amount of steps. activeStep is set to last available step\");\n return stepsQuantity;\n }\n\n return activeStep;\n};\n\nconst StepNavi: FC<Props> & Subcomponents = ({ completedSteps = 0, activeStep = completedSteps + 1, children, ariaLabel }) => {\n const steps = Children.toArray(children) as StepElement[];\n const checkedActiveStep = checkActiveStep(activeStep, steps.length, completedSteps);\n\n return (\n <nav aria-label={ariaLabel} data-bpds=\"step-navi\" data-bpds-completed-steps={completedSteps} data-bpds-active-step={checkedActiveStep}>\n <ol className=\"preflight m-0 flex list-none flex-row gap-1 p-0\">\n {steps.map((step, index) => {\n const stepNumber = index + 1;\n\n return (\n <li className=\"flex-1\" key={step.key ?? stepNumber}>\n {cloneElement(step, {\n active: checkedActiveStep === stepNumber,\n completed: completedSteps >= stepNumber,\n disabled: stepNumber > completedSteps + 1,\n })}\n </li>\n );\n })}\n </ol>\n </nav>\n );\n};\n\nStepNavi.displayName = \"StepNavi\";\n\nStepNavi.Step = StepNaviStep;\nStepNavi.Step.displayName = \"StepNavi.Step\";\n\nexport default StepNavi;\n"],"mappings":";;;;;;AAKA,IAAM,IAAkB,EAAG;CACzB,OAAO;EACL,WAAW;EACX,MAAM;EACN,KAAK;EACL,WAAW,CACT,qGACA,qEACF;CACF;CACA,UAAU;EACR,QAAQ,EACN,MAAM,EACJ,KAAK,iBACP,EACF;EACA,WAAW,EACT,MAAM,EAAE,MAAM,UAAU,EAC1B;EACA,UAAU;GACR,MAAM,EACJ,WAAW,oBACb;GACA,OAAO,EACL,KAAK,6BACP;EACF;CACF;AACF,CAAC,GAeK,KAA2B,EAAE,aAAU,SAAM,WAAQ,cAAW,kBAA8B;CAClG,IAAM,EAAE,cAAW,SAAM,QAAK,iBAAc,EAAgB;EAA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src/StepNavi.tsx"],"sourcesContent":["// inspired by https://a11y-guidelines.orange.com/en/articles/disable-elements/#disable-a-link\nimport Icon from \"@bonprix-ds/react-icon\";\nimport React from \"react\";\nimport { tv } from \"tailwind-variants\";\n\nconst generateClasses = tv({\n slots: {\n container: \"preflight w-full flex flex-col gap-1.5 items-center l:items-start xl:items-start group focus:outline-none\",\n icon: \"h-5 w-5 fill-clr-fg-success invisible\",\n bar: \"w-full h-1 bg-clr-bg-disabled\",\n labelSlot: [\n \"typography-input-helper-text text-center text-clr-primary l:text-left xl:text-left px-1 break-all\",\n \"border border-transparent rounded-sm group-focus:border-clr-primary\",\n ],\n },\n variants: {\n active: {\n true: {\n bar: \"bg-clr-primary\",\n },\n },\n completed: {\n true: { icon: \"visible\" },\n },\n disabled: {\n true: {\n labelSlot: \"text-clr-disabled\",\n },\n false: {\n bar: \"group-hover:bg-clr-primary\",\n },\n },\n },\n});\n\nexport interface StepNaviStepProps {\n /** The name of the step. */\n children: string;\n /** The href attribute for the step link. */\n href?: string;\n}\n\n/**\n * `StepNavi` derives these for each of its steps and passes them in. They are not meant to be set\n * from the outside, so they are tagged `@internal` and left out of the generated API table.\n */\nexport interface StepNaviStepInternalProps {\n /** @internal */\n active?: boolean;\n /** @internal */\n completed?: boolean;\n /** @internal */\n disabled?: boolean;\n}\n\nconst StepNaviStep = ({ children, href, active, completed, disabled }: StepNaviStepProps & StepNaviStepInternalProps) => {\n const { container, icon, bar, labelSlot } = generateClasses({ active, completed, disabled });\n return (\n <a\n href={disabled ? undefined : href}\n className={container()}\n aria-current={active ? \"step\" : \"false\"}\n aria-disabled={disabled ? \"true\" : \"false\"}\n data-bpds-completed={completed}\n >\n <Icon variant=\"check-bold\" className={icon()} />\n <div className={bar()}></div>\n <div className={labelSlot()}>\n {children}\n {completed && <span className=\"sr-only\"> erfüllter schritt</span>}\n </div>\n </a>\n );\n};\n\nStepNaviStep.displayName = \"StepNavi.Step\";\n\nexport default StepNaviStep;\n","import React, { Children, cloneElement, ReactElement } from \"react\";\n\nimport StepNaviStep, { StepNaviStepInternalProps, StepNaviStepProps } from \"./StepNaviStep\";\n\ntype StepElement = ReactElement<StepNaviStepProps & StepNaviStepInternalProps, typeof StepNaviStep>;\n\nexport interface Props {\n /** StepNavi.Step subcomponents should be placed here. */\n children: StepElement | StepElement[];\n /** Amount of completed steps. */\n completedSteps?: number;\n /** Currently active step. Not index based, so starts with 1. */\n activeStep?: number;\n /** Accessible label for the navigation. */\n ariaLabel?: string;\n}\n\nconst checkActiveStep = (activeStep: number, stepsQuantity: number, completedSteps: number) => {\n if (activeStep > completedSteps + 1) {\n console.error(\"activeStep must not be greater than completedSteps + 1\");\n return completedSteps + 1;\n }\n\n if (activeStep > stepsQuantity) {\n console.error(\"activeStep must not be greater than the amount of steps. activeStep is set to last available step\");\n return stepsQuantity;\n }\n\n return activeStep;\n};\n\nconst StepNavi = ({ completedSteps = 0, activeStep = completedSteps + 1, children, ariaLabel }: Props) => {\n const steps = Children.toArray(children) as StepElement[];\n const checkedActiveStep = checkActiveStep(activeStep, steps.length, completedSteps);\n\n return (\n <nav aria-label={ariaLabel} data-bpds=\"step-navi\" data-bpds-completed-steps={completedSteps} data-bpds-active-step={checkedActiveStep}>\n <ol className=\"preflight m-0 flex list-none flex-row gap-1 p-0\">\n {steps.map((step, index) => {\n const stepNumber = index + 1;\n\n return (\n <li className=\"flex-1\" key={step.key ?? stepNumber}>\n {cloneElement(step, {\n active: checkedActiveStep === stepNumber,\n completed: completedSteps >= stepNumber,\n disabled: stepNumber > completedSteps + 1,\n })}\n </li>\n );\n })}\n </ol>\n </nav>\n );\n};\n\nStepNavi.displayName = \"StepNavi\";\n\nStepNavi.Step = StepNaviStep;\n\nexport default StepNavi;\n"],"mappings":";;;;;AAKA,IAAM,IAAkB,EAAG;CACzB,OAAO;EACL,WAAW;EACX,MAAM;EACN,KAAK;EACL,WAAW,CACT,qGACA,qEACF;CACF;CACA,UAAU;EACR,QAAQ,EACN,MAAM,EACJ,KAA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UAAA,EAAa,GAAM;MAClB,QAAQ,MAAsB;MAC9B,WAAW,KAAkB;MAC7B,UAAU,IAAa,IAAiB;KAC1C,CAAC;IACC,GANwB,EAAK,OAAO,CAMpC;GAER,CAAC;EACC,CAAA;CACD,CAAA;AAET;AAEA,EAAS,cAAc,YAEvB,EAAS,OAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonprix-ds/react-step-navi",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "StepNavi component, implemented in React, for the Bonprix Design System.",
5
5
  "type": "module",
6
6
  "publishConfig": {