@smudi/designsystem 1.5.1 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/@smudi/components/stepper/index.d.ts +15 -0
  2. package/@smudi/components/stepper/index.d.ts.map +1 -0
  3. package/@smudi/components/stepper/index.js +17 -0
  4. package/@smudi/components/stepper/step/step-list.d.ts +7 -0
  5. package/@smudi/components/stepper/step/step-list.d.ts.map +1 -0
  6. package/@smudi/components/stepper/step/step-list.js +40 -0
  7. package/@smudi/components/stepper/step/step-list.module.css.js +7 -0
  8. package/@smudi/components/stepper/step/step.d.ts +22 -0
  9. package/@smudi/components/stepper/step/step.d.ts.map +1 -0
  10. package/@smudi/components/stepper/step/step.js +86 -0
  11. package/@smudi/components/stepper/step/step.module.css.js +10 -0
  12. package/@smudi/components/stepper/step-content/step-content-list.d.ts +2 -0
  13. package/@smudi/components/stepper/step-content/step-content-list.d.ts.map +1 -0
  14. package/@smudi/components/stepper/step-content/step-content-list.js +25 -0
  15. package/@smudi/components/stepper/step-content/step-content-list.module.css.js +7 -0
  16. package/@smudi/components/stepper/step-content/step-content.d.ts +13 -0
  17. package/@smudi/components/stepper/step-content/step-content.d.ts.map +1 -0
  18. package/@smudi/components/stepper/step-content/step-content.js +28 -0
  19. package/@smudi/components/stepper/step-content/step-content.module.css.js +7 -0
  20. package/@smudi/components/stepper/stepper-context.d.ts +49 -0
  21. package/@smudi/components/stepper/stepper-context.d.ts.map +1 -0
  22. package/@smudi/components/stepper/stepper-context.js +23 -0
  23. package/@smudi/components/stepper/stepper.d.ts +42 -0
  24. package/@smudi/components/stepper/stepper.d.ts.map +1 -0
  25. package/@smudi/components/stepper/stepper.js +62 -0
  26. package/@smudi/components/stepper/stepper.module.css.js +7 -0
  27. package/@smudi/components/stepper/use-stepper-state.d.ts +43 -0
  28. package/@smudi/components/stepper/use-stepper-state.d.ts.map +1 -0
  29. package/@smudi/components/stepper/use-stepper-state.js +17 -0
  30. package/@smudi/react.js +66 -62
  31. package/@smudi/smudi/react.d.ts +1 -0
  32. package/@smudi/smudi/react.d.ts.map +1 -1
  33. package/@smudi/styles.css +1 -1
  34. package/package.json +1 -1
@@ -0,0 +1,15 @@
1
+ import { StepContentProps } from './step-content/step-content';
2
+ import { StepProps } from './step/step';
3
+ import { StepperProps } from './stepper';
4
+ export declare const Stepper: (<TValue extends string = string>(props: StepperProps<TValue>) => React.ReactElement) & {
5
+ displayName: string;
6
+ Step: <E extends React.ElementType = "button">(props: StepProps<E> & {
7
+ ref?: React.Ref<HTMLElement>;
8
+ }) => React.ReactElement;
9
+ StepList: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.OlHTMLAttributes<HTMLOListElement>, HTMLOListElement>, "ref"> & React.RefAttributes<HTMLOListElement>>;
10
+ Content: React.ForwardRefExoticComponent<Omit<StepContentProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
11
+ ContentList: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
12
+ };
13
+ export { useStepperState, type StepMountStrategy, type StepperState, type UseStepperStateOptions, } from './use-stepper-state';
14
+ export type { StepContentProps, StepProps, StepperProps };
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/stepper/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAQ,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EAA0B,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAEtE,eAAO,MAAM,OAAO;;;WAgBg9H,CAAC;;;;;CAVn+H,CAAC;AAEH,OAAO,EACL,eAAe,EACf,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,sBAAsB,GAC5B,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import { StepContent as t } from "./step-content/step-content.js";
3
+ import { StepContentList as e } from "./step-content/step-content-list.js";
4
+ import { Step as p } from "./step/step.js";
5
+ import { StepList as o } from "./step/step-list.js";
6
+ import { Stepper as r } from "./stepper.js";
7
+ import "react";
8
+ const a = Object.assign(r, {
9
+ displayName: "Stepper",
10
+ Step: p,
11
+ StepList: o,
12
+ Content: t,
13
+ ContentList: e
14
+ });
15
+ export {
16
+ a as Stepper
17
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Ordered list of steps. Provides roving-focus keyboard navigation: arrow keys
3
+ * (axis depends on orientation) plus Home/End move focus between step triggers;
4
+ * activating a focused step (Enter/Space, native <button>) commits it.
5
+ */
6
+ export declare const StepList: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.OlHTMLAttributes<HTMLOListElement>, HTMLOListElement>, "ref"> & React.RefAttributes<HTMLOListElement>>;
7
+ //# sourceMappingURL=step-list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step-list.d.ts","sourceRoot":"","sources":["../../../../components/stepper/step/step-list.tsx"],"names":[],"mappings":"AAiBA;;;;GAIG;AACH,eAAO,MAAM,QAAQ,2KAyDnB,CAAC"}
@@ -0,0 +1,40 @@
1
+ "use client";
2
+ import { jsx as a } from "react/jsx-runtime";
3
+ import { forwardRef as y, Children as w, isValidElement as A } from "react";
4
+ import { useStepper as h, StepOrderContext as E, STEP_TRIGGER_ATTR as S } from "../stepper-context.js";
5
+ import v from "./step-list.module.css.js";
6
+ import { classNames as x } from "../../utils/class-names.js";
7
+ const H = y(function({ children: i, className: f, onKeyDown: c, ...m }, u) {
8
+ const { orientation: n } = h();
9
+ function d(e) {
10
+ if (c?.(e), e.defaultPrevented) return;
11
+ const l = n === "vertical" ? "ArrowDown" : "ArrowRight", g = n === "vertical" ? "ArrowUp" : "ArrowLeft", { key: t } = e;
12
+ if (t !== l && t !== g && t !== "Home" && t !== "End")
13
+ return;
14
+ const r = Array.from(
15
+ e.currentTarget.querySelectorAll(
16
+ `[${S}]`
17
+ )
18
+ );
19
+ if (r.length === 0) return;
20
+ e.preventDefault();
21
+ const s = r.indexOf(document.activeElement);
22
+ let o;
23
+ t === "Home" ? o = 0 : t === "End" ? o = r.length - 1 : o = ((s === -1 ? 0 : s) + (t === l ? 1 : -1) + r.length) % r.length, r[o]?.focus();
24
+ }
25
+ const p = w.toArray(i).filter(A).map((e) => e.props.value).filter((e) => typeof e == "string");
26
+ return /* @__PURE__ */ a(
27
+ "ol",
28
+ {
29
+ ...m,
30
+ ref: u,
31
+ "data-orientation": n,
32
+ onKeyDown: d,
33
+ className: x(v["smudi-list"], f),
34
+ children: /* @__PURE__ */ a(E.Provider, { value: p, children: i })
35
+ }
36
+ );
37
+ });
38
+ export {
39
+ H as StepList
40
+ };
@@ -0,0 +1,7 @@
1
+ "use client";
2
+ const s = {
3
+ "smudi-list": "_smudi-list_x8prp_2"
4
+ };
5
+ export {
6
+ s as default
7
+ };
@@ -0,0 +1,22 @@
1
+ import { ComponentPropsWithoutRef, ElementType, PropsWithChildren, ReactElement, ReactNode, Ref } from 'react';
2
+ type StepOwnProps = PropsWithChildren & {
3
+ /** Unique value identifying this step; must match a `<StepContent value>`. */
4
+ value: string;
5
+ /** Custom indicator content, replacing the default status icon. */
6
+ icon?: ReactNode;
7
+ status?: "completed" | "error" | "warning";
8
+ /** Class applied to the step container (`<li>`), not the trigger. */
9
+ className?: string;
10
+ };
11
+ /**
12
+ * `as` lets a navigable step render as something other than a `<button>` —
13
+ * e.g. a router's `<Link>`. Extra props (`to`, `href`, …) flow to that element.
14
+ */
15
+ export type StepProps<E extends ElementType = "button"> = StepOwnProps & {
16
+ as?: E;
17
+ } & Omit<ComponentPropsWithoutRef<E>, keyof StepOwnProps | "as">;
18
+ export declare const Step: <E extends ElementType = "button">(props: StepProps<E> & {
19
+ ref?: Ref<HTMLElement>;
20
+ }) => ReactElement;
21
+ export {};
22
+ //# sourceMappingURL=step.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../../../components/stepper/step/step.tsx"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,WAAW,EAKhB,iBAAiB,EACjB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,GAAG,EACT,MAAM,OAAO,CAAC;AAUf,KAAK,YAAY,GAAG,iBAAiB,GAAG;IACtC,8EAA8E;IAC9E,KAAK,EAAE,MAAM,CAAC;IACd,mEAAmE;IACnE,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,GAAG,SAAS,CAAC;IAC3C,qEAAqE;IACrE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,WAAW,GAAG,QAAQ,IAAI,YAAY,GAAG;IACvE,EAAE,CAAC,EAAE,CAAC,CAAC;CACR,GAAG,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE,MAAM,YAAY,GAAG,IAAI,CAAC,CAAC;AAoHjE,eAAO,MAAM,IAAI,EAAe,CAAC,CAAC,SAAS,WAAW,GAAG,QAAQ,EAC/D,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAA;CAAE,KAC7C,YAAY,CAAC"}
@@ -0,0 +1,86 @@
1
+ "use client";
2
+ import { jsx as n, jsxs as a } from "react/jsx-runtime";
3
+ import { ExclamationmarkTriangleIcon as j, XMarkIcon as w, CheckmarkIcon as G } from "@navikt/aksel-icons";
4
+ import { forwardRef as L } from "react";
5
+ import { useStepper as P, useStepOrder as M, stepId as U, STEP_TRIGGER_ATTR as V } from "../stepper-context.js";
6
+ import r from "./step.module.css.js";
7
+ import { classNames as X } from "../../utils/class-names.js";
8
+ const q = {
9
+ completed: /* @__PURE__ */ n(G, {}),
10
+ error: /* @__PURE__ */ n(w, {}),
11
+ warning: /* @__PURE__ */ n(j, {})
12
+ };
13
+ function z({
14
+ value: e,
15
+ children: g,
16
+ status: t,
17
+ icon: h,
18
+ as: I,
19
+ className: N,
20
+ onClick: S,
21
+ ...k
22
+ }, x) {
23
+ const {
24
+ value: d,
25
+ onChange: T,
26
+ baseId: v,
27
+ orientation: y,
28
+ statusLabels: C,
29
+ variant: l,
30
+ lockedLabel: O
31
+ } = P(), s = M(), i = d === e, m = l !== "readonly", o = s.indexOf(d), p = l === "linear" && o !== -1 && s.indexOf(e) > o, c = m && !p, u = m && p, b = c ? I ?? "button" : "span", R = i || o === -1 && s[0] === e ? 0 : -1, A = c ? {
32
+ // Roving tabindex: only the current step is tabbable; arrow keys
33
+ // move focus between steps (handled by StepList).
34
+ [V]: "",
35
+ tabIndex: R,
36
+ onClick: E
37
+ } : {};
38
+ function E(_) {
39
+ T?.(e), S?.(_);
40
+ }
41
+ return /* @__PURE__ */ n(
42
+ "li",
43
+ {
44
+ "data-orientation": y,
45
+ "data-status": t,
46
+ "data-selected": i || void 0,
47
+ "data-navigable": c || void 0,
48
+ className: X(r["smudi-step"], N),
49
+ children: /* @__PURE__ */ a(
50
+ b,
51
+ {
52
+ ...k,
53
+ ref: x,
54
+ id: U(v, e),
55
+ className: r["smudi-trigger"],
56
+ "aria-current": i ? "step" : void 0,
57
+ "aria-disabled": u ? !0 : void 0,
58
+ ...A,
59
+ ...b === "button" ? { type: "button" } : {},
60
+ children: [
61
+ /* @__PURE__ */ n("span", { className: r["smudi-step-indicator"], "aria-hidden": "true", children: h ?? q[t] }),
62
+ /* @__PURE__ */ a("span", { className: r["smudi-step-label"], children: [
63
+ g,
64
+ t && /* @__PURE__ */ a("span", { className: "ds-sr-only", children: [
65
+ "- ",
66
+ C[t]
67
+ ] }),
68
+ u && /* @__PURE__ */ a("span", { className: "ds-sr-only", children: [
69
+ " - ",
70
+ O
71
+ ] })
72
+ ] })
73
+ ]
74
+ }
75
+ )
76
+ }
77
+ );
78
+ }
79
+ const f = L(
80
+ z
81
+ );
82
+ f.displayName = "Step";
83
+ const Q = f;
84
+ export {
85
+ Q as Step
86
+ };
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ const s = {
3
+ "smudi-step": "_smudi-step_1spum_9",
4
+ "smudi-trigger": "_smudi-trigger_1spum_22",
5
+ "smudi-step-label": "_smudi-step-label_1spum_45",
6
+ "smudi-step-indicator": "_smudi-step-indicator_1spum_97"
7
+ };
8
+ export {
9
+ s as default
10
+ };
@@ -0,0 +1,2 @@
1
+ export declare const StepContentList: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
2
+ //# sourceMappingURL=step-content-list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step-content-list.d.ts","sourceRoot":"","sources":["../../../../components/stepper/step-content/step-content-list.tsx"],"names":[],"mappings":"AAOA,eAAO,MAAM,eAAe,mKAgB3B,CAAC"}
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ import { jsx as n } from "react/jsx-runtime";
3
+ import { forwardRef as s } from "react";
4
+ import { useStepper as m } from "../stepper-context.js";
5
+ import a from "./step-content-list.module.css.js";
6
+ import { classNames as p } from "../../utils/class-names.js";
7
+ const v = s(
8
+ function({ children: t, className: o, ...e }, i) {
9
+ const { orientation: r } = m();
10
+ return /* @__PURE__ */ n(
11
+ "div",
12
+ {
13
+ ref: i,
14
+ "aria-live": "polite",
15
+ "data-orientation": r,
16
+ className: p(a["smudi-content-list"], o),
17
+ ...e,
18
+ children: t
19
+ }
20
+ );
21
+ }
22
+ );
23
+ export {
24
+ v as StepContentList
25
+ };
@@ -0,0 +1,7 @@
1
+ "use client";
2
+ const t = {
3
+ "smudi-content-list": "_smudi-content-list_1sb0r_2"
4
+ };
5
+ export {
6
+ t as default
7
+ };
@@ -0,0 +1,13 @@
1
+ import { ComponentProps } from 'react';
2
+ export type StepContentProps = ComponentProps<"div"> & {
3
+ /** Value identifying this panel; must match the `<Step value>` it belongs to. */
4
+ value: string;
5
+ };
6
+ /**
7
+ * A step's content panel. Renders whenever it's mounted and hides itself when
8
+ * it isn't the active step. Mounting is the consumer's concern — render every
9
+ * panel (all stay mounted) or gate them with `useStepperState`'s `shouldRender`
10
+ * to opt into `lazy`/`active` behaviour.
11
+ */
12
+ export declare const StepContent: React.ForwardRefExoticComponent<Omit<StepContentProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
13
+ //# sourceMappingURL=step-content.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step-content.d.ts","sourceRoot":"","sources":["../../../../components/stepper/step-content/step-content.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAc,MAAM,OAAO,CAAC;AAKxD,MAAM,MAAM,gBAAgB,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG;IACrD,iFAAiF;IACjF,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,sGAoBvB,CAAC"}
@@ -0,0 +1,28 @@
1
+ "use client";
2
+ import { jsx as m } from "react/jsx-runtime";
3
+ import { forwardRef as a } from "react";
4
+ import { useStepper as d, stepId as c, panelId as l } from "../stepper-context.js";
5
+ import f from "./step-content.module.css.js";
6
+ import { classNames as u } from "../../utils/class-names.js";
7
+ const C = a(
8
+ function({ value: e, children: o, className: r, ...s }, n) {
9
+ const { value: i, baseId: t } = d(), p = i === e;
10
+ return /* @__PURE__ */ m(
11
+ "div",
12
+ {
13
+ ...s,
14
+ ref: n,
15
+ id: l(t, e),
16
+ role: "group",
17
+ "aria-labelledby": c(t, e),
18
+ tabIndex: -1,
19
+ hidden: !p,
20
+ className: u(f["smudi-step-content"], r),
21
+ children: o
22
+ }
23
+ );
24
+ }
25
+ );
26
+ export {
27
+ C as StepContent
28
+ };
@@ -0,0 +1,7 @@
1
+ "use client";
2
+ const t = {
3
+ "smudi-step-content": "_smudi-step-content_1y93a_2"
4
+ };
5
+ export {
6
+ t as default
7
+ };
@@ -0,0 +1,49 @@
1
+ export type StepperOrientation = "horizontal" | "vertical";
2
+ /**
3
+ * Stepper variant:
4
+ * - `linear`: steps ahead of the current one are locked; the user can click
5
+ * back to earlier steps, but forward progress is programmatic.
6
+ * - `non-linear`: navigable, any step can be selected.
7
+ * - `readonly`: not navigable — a display-only progress indicator.
8
+ */
9
+ export type StepperVariant = "linear" | "non-linear" | "readonly";
10
+ /** Screen-reader-only text appended to a step for each status. Localizable. */
11
+ export interface StepperStatusLabels {
12
+ completed: string;
13
+ error: string;
14
+ warning: string;
15
+ }
16
+ export interface StepperContextValue {
17
+ /** The value of the currently active step. */
18
+ value: string;
19
+ /** Called with a step's value when the user activates an interactive step. */
20
+ onChange?: (value: string) => void;
21
+ /** Base id used to link each step to its content panel for assistive tech. */
22
+ baseId: string;
23
+ /** Layout direction of the step list. */
24
+ orientation: StepperOrientation;
25
+ /** Assistive-tech status text, resolved (defaults merged) by `<Stepper>`. */
26
+ statusLabels: StepperStatusLabels;
27
+ /** Variant controlling navigability and linear locking. */
28
+ variant: StepperVariant;
29
+ /** Screen-reader hint appended to steps locked by linear mode. */
30
+ lockedLabel: string;
31
+ }
32
+ export declare const StepperContext: React.Context<StepperContextValue | null>;
33
+ export declare function useStepper(): StepperContextValue;
34
+ /**
35
+ * Ordered list of step values in render order, published by `<StepList>` so a
36
+ * step can tell whether it comes before/after the current one (linear mode).
37
+ */
38
+ export declare const StepOrderContext: React.Context<readonly string[]>;
39
+ export declare function useStepOrder(): readonly string[];
40
+ /** Stable id for a step trigger — used as the panel's `aria-labelledby`. */
41
+ export declare const stepId: (baseId: string, value: string) => string;
42
+ /** Stable id for a step's content panel — used as the step's `aria-controls`. */
43
+ export declare const panelId: (baseId: string, value: string) => string;
44
+ /**
45
+ * Marker attribute set by a focusable `<Step>` trigger and queried by
46
+ * `<StepList>` to move roving focus. Shared so the name can't drift.
47
+ */
48
+ export declare const STEP_TRIGGER_ATTR = "data-step-trigger";
49
+ //# sourceMappingURL=stepper-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stepper-context.d.ts","sourceRoot":"","sources":["../../../components/stepper/stepper-context.tsx"],"names":[],"mappings":"AAEA,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG,UAAU,CAAC;AAE3D;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,YAAY,GAAG,UAAU,CAAC;AAElE,+EAA+E;AAC/E,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,8CAA8C;IAC9C,KAAK,EAAE,MAAM,CAAC;IACd,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,8EAA8E;IAC9E,MAAM,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,WAAW,EAAE,kBAAkB,CAAC;IAChC,6EAA6E;IAC7E,YAAY,EAAE,mBAAmB,CAAC;IAClC,2DAA2D;IAC3D,OAAO,EAAE,cAAc,CAAC;IACxB,kEAAkE;IAClE,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,cAAc,2CAAkD,CAAC;AAE9E,wBAAgB,UAAU,wBAMzB;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,kCAAuC,CAAC;AAErE,wBAAgB,YAAY,sBAE3B;AAED,4EAA4E;AAC5E,eAAO,MAAM,MAAM,GAAI,QAAQ,MAAM,EAAE,OAAO,MAAM,WACzB,CAAC;AAE5B,iFAAiF;AACjF,eAAO,MAAM,OAAO,GAAI,QAAQ,MAAM,EAAE,OAAO,MAAM,WACzB,CAAC;AAE7B;;;GAGG;AACH,eAAO,MAAM,iBAAiB,sBAAsB,CAAC"}
@@ -0,0 +1,23 @@
1
+ "use client";
2
+ import { createContext as n, useContext as r } from "react";
3
+ const o = n(null);
4
+ function u() {
5
+ const t = r(o);
6
+ if (!t)
7
+ throw new Error("useStepper must be used within a <Stepper>");
8
+ return t;
9
+ }
10
+ const p = n([]);
11
+ function c() {
12
+ return r(p);
13
+ }
14
+ const i = (t, e) => `${t}-step-${e}`, S = (t, e) => `${t}-panel-${e}`, a = "data-step-trigger";
15
+ export {
16
+ a as STEP_TRIGGER_ATTR,
17
+ p as StepOrderContext,
18
+ o as StepperContext,
19
+ S as panelId,
20
+ i as stepId,
21
+ c as useStepOrder,
22
+ u as useStepper
23
+ };
@@ -0,0 +1,42 @@
1
+ import { ComponentProps, ReactElement } from 'react';
2
+ import { StepperOrientation, StepperStatusLabels, StepperVariant } from './stepper-context';
3
+ export type StepperProps<TValue extends string = string> = Omit<ComponentProps<"div">, "onChange" | "defaultValue"> & {
4
+ /**
5
+ * The active step's value (controlled). Omit and use `defaultValue` for an
6
+ * uncontrolled stepper that manages its own state.
7
+ */
8
+ value?: TValue;
9
+ /**
10
+ * The `value` of the step that starts active in an uncontrolled stepper.
11
+ * Sets the initial step only — later navigation is managed internally.
12
+ * Ignored when `value` is provided (controlled). Omit both to start with no
13
+ * active step.
14
+ */
15
+ defaultValue?: TValue;
16
+ /**
17
+ * Called with a step's value when the user activates an interactive step.
18
+ */
19
+ onChange?: (value: TValue) => void;
20
+ /** Layout direction of the step list. Defaults to `'horizontal'`. */
21
+ orientation?: StepperOrientation;
22
+ /** Override the screen-reader status text (e.g. for localization). */
23
+ statusLabels?: Partial<StepperStatusLabels>;
24
+ /**
25
+ * Stepper variant. Defaults to `"linear"`.
26
+ * - `"linear"` (default): locks steps ahead of the current one — the user can
27
+ * click back to earlier steps, but advancing forward must be done
28
+ * programmatically (e.g. a "Next" button updating the active step).
29
+ * - `"non-linear"`: any step can be selected.
30
+ * - `"readonly"`: every step is inert (a display-only progress indicator);
31
+ * changing steps must be done fully programmatically.
32
+ */
33
+ variant?: StepperVariant;
34
+ /** Screen-reader hint for steps locked by linear mode. Defaults to "Locked". */
35
+ lockedLabel?: string;
36
+ };
37
+ /**
38
+ * forwardRef drops the generic, so re-assert it via a cast. `StepperProps`
39
+ * already carries `ref` (from the `<div>` props), so the ref flows through.
40
+ */
41
+ export declare const Stepper: <TValue extends string = string>(props: StepperProps<TValue>) => ReactElement;
42
+ //# sourceMappingURL=stepper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stepper.d.ts","sourceRoot":"","sources":["../../../components/stepper/stepper.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EAGnB,KAAK,YAAY,EAGlB,MAAM,OAAO,CAAC;AACf,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAC;AAU3B,MAAM,MAAM,YAAY,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM,IAAI,IAAI,CAC7D,cAAc,CAAC,KAAK,CAAC,EACrB,UAAU,GAAG,cAAc,CAC5B,GAAG;IACF;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,qEAAqE;IACrE,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC,sEAAsE;IACtE,YAAY,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC5C;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,gFAAgF;IAChF,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AA8DF;;;GAGG;AACH,eAAO,MAAM,OAAO,EAAkB,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM,EACnE,KAAK,EAAE,YAAY,CAAC,MAAM,CAAC,KACxB,YAAY,CAAC"}
@@ -0,0 +1,62 @@
1
+ "use client";
2
+ import { jsx as s } from "react/jsx-runtime";
3
+ import { forwardRef as b, useId as F, useState as N } from "react";
4
+ import { StepperContext as T } from "./stepper-context.js";
5
+ import U from "./stepper.module.css.js";
6
+ import { classNames as w } from "../utils/class-names.js";
7
+ const x = {
8
+ completed: "Fullført",
9
+ error: "Feil",
10
+ warning: "Advarsel"
11
+ };
12
+ function y({
13
+ id: e,
14
+ value: t,
15
+ defaultValue: a,
16
+ onChange: p,
17
+ orientation: o = "horizontal",
18
+ statusLabels: i,
19
+ variant: c = "linear",
20
+ lockedLabel: d = "Låst",
21
+ children: m,
22
+ className: u,
23
+ ...f
24
+ }, S) {
25
+ const v = F(), h = e ?? v, I = { ...x, ...i }, [L, g] = N(
26
+ a
27
+ ), r = t !== void 0, A = (r ? t : L) ?? "";
28
+ function C(n) {
29
+ r || g(n), p?.(n);
30
+ }
31
+ return /* @__PURE__ */ s(
32
+ "div",
33
+ {
34
+ id: e,
35
+ ref: S,
36
+ "data-orientation": o,
37
+ className: w(U["smudi-stepper"], u),
38
+ ...f,
39
+ children: /* @__PURE__ */ s(
40
+ T.Provider,
41
+ {
42
+ value: {
43
+ value: A,
44
+ onChange: C,
45
+ baseId: h,
46
+ orientation: o,
47
+ statusLabels: I,
48
+ variant: c,
49
+ lockedLabel: d
50
+ },
51
+ children: m
52
+ }
53
+ )
54
+ }
55
+ );
56
+ }
57
+ const l = b(y);
58
+ l.displayName = "Stepper";
59
+ const D = l;
60
+ export {
61
+ D as Stepper
62
+ };
@@ -0,0 +1,7 @@
1
+ "use client";
2
+ const e = {
3
+ "smudi-stepper": "_smudi-stepper_417iy_2"
4
+ };
5
+ export {
6
+ e as default
7
+ };
@@ -0,0 +1,43 @@
1
+ /**
2
+ * How step panels are mounted. This is opt-in via `useStepperState` — when the
3
+ * hook isn't used, every `<Stepper.Content>` you render stays mounted, which is
4
+ * equivalent to `"all"`. The Stepper component itself has no mount strategy.
5
+ * - `active`: only the active panel is rendered (others unmount on leave).
6
+ * - `lazy`: a panel renders on first visit, then stays rendered (hidden).
7
+ * - `all`: every panel renders (inactive ones hidden).
8
+ */
9
+ export type StepMountStrategy = "active" | "lazy" | "all";
10
+ export interface UseStepperStateOptions<TValue extends string> {
11
+ /** The step that starts active. Only seeds the initial value — later changes
12
+ * go through `setValue`. */
13
+ defaultValue: TValue;
14
+ /** Mounting behaviour. Defaults to `"all"` (render every panel). */
15
+ mountStrategy?: StepMountStrategy;
16
+ }
17
+ export interface StepperState<TValue extends string> {
18
+ /** The active step's value — pass to `<Stepper value>`. */
19
+ value: TValue;
20
+ /** Sets the active step. Wire to `<Stepper onChange>` and/or call it directly
21
+ * to move the stepper programmatically. */
22
+ setValue: (value: TValue) => void;
23
+ /** Whether the panel for `value` should be rendered right now. */
24
+ shouldRender: (value: TValue) => boolean;
25
+ }
26
+ /**
27
+ * Owns a stepper's active-step state and, optionally, decides which content
28
+ * panels are mounted. Gate `<Stepper.Content>` with the returned `shouldRender`:
29
+ *
30
+ * ```tsx
31
+ * const stepper = useStepperState({ defaultValue: "one", mountStrategy: "lazy" });
32
+ * <Stepper value={stepper.value} onChange={stepper.setValue}>
33
+ * {steps.map((s) => stepper.shouldRender(s.value) && (
34
+ * <Stepper.Content key={s.value} value={s.value}>…</Stepper.Content>
35
+ * ))}
36
+ * </Stepper>
37
+ * ```
38
+ *
39
+ * The hook lives in the parent, so its "visited" memory survives panels
40
+ * unmounting — which is what makes `"lazy"` reliable.
41
+ */
42
+ export declare function useStepperState<TValue extends string>({ defaultValue, mountStrategy, }: UseStepperStateOptions<TValue>): StepperState<TValue>;
43
+ //# sourceMappingURL=use-stepper-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-stepper-state.d.ts","sourceRoot":"","sources":["../../../components/stepper/use-stepper-state.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,CAAC;AAE1D,MAAM,WAAW,sBAAsB,CAAC,MAAM,SAAS,MAAM;IAC3D;iCAC6B;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,oEAAoE;IACpE,aAAa,CAAC,EAAE,iBAAiB,CAAC;CACnC;AAED,MAAM,WAAW,YAAY,CAAC,MAAM,SAAS,MAAM;IACjD,2DAA2D;IAC3D,KAAK,EAAE,MAAM,CAAC;IACd;gDAC4C;IAC5C,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,kEAAkE;IAClE,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;CAC1C;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAAC,MAAM,SAAS,MAAM,EAAE,EACrD,YAAY,EACZ,aAAqB,GACtB,EAAE,sBAAsB,CAAC,MAAM,CAAC,GAAG,YAAY,CAAC,MAAM,CAAC,CAiBvD"}
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import { useState as u, useRef as a, useCallback as o } from "react";
3
+ function d({
4
+ defaultValue: t,
5
+ mountStrategy: s = "all"
6
+ }) {
7
+ const [e, r] = u(t), l = a(/* @__PURE__ */ new Set([t]));
8
+ l.current.add(e);
9
+ const c = o(
10
+ (n) => s === "all" || n === e || s === "lazy" && l.current.has(n),
11
+ [s, e]
12
+ );
13
+ return { value: e, setValue: r, shouldRender: c };
14
+ }
15
+ export {
16
+ d as useStepperState
17
+ };