@j2-health/design-system 0.6.2 → 0.6.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/dist/index.cjs CHANGED
@@ -52,6 +52,7 @@ const require_Spinner = require("./src/components/spinner/Spinner.cjs");
52
52
  const require_StatusPill = require("./src/components/statusPill/StatusPill.cjs");
53
53
  const require_useSteps = require("./src/components/steps/useSteps.cjs");
54
54
  const require_Steps = require("./src/components/steps/Steps.cjs");
55
+ const require_StepDrawer = require("./src/components/stepDrawer/StepDrawer.cjs");
55
56
  const require_SwatchStrip = require("./src/components/swatchStrip/SwatchStrip.cjs");
56
57
  const require_Switch = require("./src/components/switch/Switch.cjs");
57
58
  const require_Table = require("./src/components/table/Table.cjs");
@@ -111,6 +112,7 @@ exports.SelectAll = require_SelectAll.SelectAll;
111
112
  exports.Skeleton = require_Skeleton.Skeleton;
112
113
  exports.Spinner = require_Spinner.Spinner;
113
114
  exports.StatusPill = require_StatusPill.StatusPill;
115
+ exports.StepDrawer = require_StepDrawer.StepDrawer;
114
116
  exports.Steps = require_Steps.Steps;
115
117
  exports.SummarizedSelect = require_SummarizedSelect.SummarizedSelect;
116
118
  exports.Swatch = require_Swatch.Swatch;
@@ -137,5 +139,6 @@ exports.operatorOptionsFor = require_useFilterField.operatorOptionsFor;
137
139
  exports.tailwindPreset = require_tailwind.tailwindPreset;
138
140
  exports.useMessage = require_useMessage.useMessage;
139
141
  exports.useNotification = require_useNotification.useNotification;
142
+ exports.useStepDrawerSlots = require_StepDrawer.useStepDrawerSlots;
140
143
  exports.useSteps = require_useSteps.useSteps;
141
144
  exports.withDesignSystemPaginationOverrides = require_Pagination.withDesignSystemPaginationOverrides;
package/dist/index.d.ts CHANGED
@@ -37,6 +37,7 @@ export * from './src/components/select/index.js';
37
37
  export * from './src/components/skeleton/index.js';
38
38
  export * from './src/components/spinner/index.js';
39
39
  export * from './src/components/statusPill/index.js';
40
+ export * from './src/components/stepDrawer/index.js';
40
41
  export * from './src/components/steps/index.js';
41
42
  export * from './src/components/swatch/index.js';
42
43
  export * from './src/components/swatchStrip/index.js';
package/dist/index.js CHANGED
@@ -51,6 +51,7 @@ import { Spinner } from "./src/components/spinner/Spinner.js";
51
51
  import { StatusPill } from "./src/components/statusPill/StatusPill.js";
52
52
  import { useSteps } from "./src/components/steps/useSteps.js";
53
53
  import { Steps } from "./src/components/steps/Steps.js";
54
+ import { StepDrawer, useStepDrawerSlots } from "./src/components/stepDrawer/StepDrawer.js";
54
55
  import { SwatchStrip } from "./src/components/swatchStrip/SwatchStrip.js";
55
56
  import { Switch } from "./src/components/switch/Switch.js";
56
57
  import { Table } from "./src/components/table/Table.js";
@@ -60,4 +61,4 @@ import { VennDiagram } from "./src/components/vennDiagram/VennDiagram.js";
60
61
  import { UserProfile } from "./src/components/legacyNavMenu/UserProfile.js";
61
62
  import { LegacyNavMenu } from "./src/components/legacyNavMenu/LegacyNavMenu.js";
62
63
  import { icons } from "./index2.js";
63
- export { Alert, AntdInput, AntdSearchInput, AntdSelect, AppConfigProvider, BarChart, BareButton, Breadcrumb, BulkActionBar, Button, Card, ChangeChip, Checkbox, CheckboxTree, Collapse, Drawer, Dropdown, EmptyState, FiltersForm, Form, HighchartsReact, Input, InputNumber, LegacyNavMenu, ListPopover, ListRow, ManageColumnsPanel, Menu, Modal, MultiValueTextOperatorOptions, NavMenu, NotificationModal, Pagination, Popover, Progress, Radio, RadioGroup, Rate, Select, SelectAll, Skeleton, Spinner, StatusPill, Steps, SummarizedSelect, Swatch, SwatchStrip, Switch, Table, Tabs, Tag, ThresholdBar, Tooltip, UserProfile, VennDiagram, appTheme, icons, isMultiValueTextOperator, mergeProps, normalizeMultiValues, operatorOptionsFor, tailwindPreset, useMessage, useNotification, useSteps, withDesignSystemPaginationOverrides };
64
+ export { Alert, AntdInput, AntdSearchInput, AntdSelect, AppConfigProvider, BarChart, BareButton, Breadcrumb, BulkActionBar, Button, Card, ChangeChip, Checkbox, CheckboxTree, Collapse, Drawer, Dropdown, EmptyState, FiltersForm, Form, HighchartsReact, Input, InputNumber, LegacyNavMenu, ListPopover, ListRow, ManageColumnsPanel, Menu, Modal, MultiValueTextOperatorOptions, NavMenu, NotificationModal, Pagination, Popover, Progress, Radio, RadioGroup, Rate, Select, SelectAll, Skeleton, Spinner, StatusPill, StepDrawer, Steps, SummarizedSelect, Swatch, SwatchStrip, Switch, Table, Tabs, Tag, ThresholdBar, Tooltip, UserProfile, VennDiagram, appTheme, icons, isMultiValueTextOperator, mergeProps, normalizeMultiValues, operatorOptionsFor, tailwindPreset, useMessage, useNotification, useStepDrawerSlots, useSteps, withDesignSystemPaginationOverrides };
package/dist/index2.js CHANGED
@@ -51,6 +51,7 @@ import { Spinner } from "./src/components/spinner/Spinner.js";
51
51
  import { StatusPill } from "./src/components/statusPill/StatusPill.js";
52
52
  import { useSteps } from "./src/components/steps/useSteps.js";
53
53
  import { Steps } from "./src/components/steps/Steps.js";
54
+ import { StepDrawer, useStepDrawerSlots } from "./src/components/stepDrawer/StepDrawer.js";
54
55
  import { SwatchStrip } from "./src/components/swatchStrip/SwatchStrip.js";
55
56
  import { Switch } from "./src/components/switch/Switch.js";
56
57
  import { Table } from "./src/components/table/Table.js";
@@ -60,4 +61,4 @@ import { VennDiagram } from "./src/components/vennDiagram/VennDiagram.js";
60
61
  import { UserProfile } from "./src/components/legacyNavMenu/UserProfile.js";
61
62
  import { LegacyNavMenu } from "./src/components/legacyNavMenu/LegacyNavMenu.js";
62
63
  import * as icons from "@phosphor-icons/react";
63
- export { Alert, AntdInput, AntdSearchInput, AntdSelect, AppConfigProvider, BarChart, BareButton, Breadcrumb, BulkActionBar, Button, Card, ChangeChip, Checkbox, CheckboxTree, Collapse, Drawer, Dropdown, EmptyState, FiltersForm, Form, HighchartsReact, Input, InputNumber, LegacyNavMenu, ListPopover, ListRow, ManageColumnsPanel, Menu, Modal, MultiValueTextOperatorOptions, NavMenu, NotificationModal, Pagination, Popover, Progress, Radio, RadioGroup, Rate, Select, SelectAll, Skeleton, Spinner, StatusPill, Steps, SummarizedSelect, Swatch, SwatchStrip, Switch, Table, Tabs, Tag, ThresholdBar, Tooltip, UserProfile, VennDiagram, appTheme, icons, isMultiValueTextOperator, mergeProps, normalizeMultiValues, operatorOptionsFor, tailwindPreset, useMessage, useNotification, useSteps, withDesignSystemPaginationOverrides };
64
+ export { Alert, AntdInput, AntdSearchInput, AntdSelect, AppConfigProvider, BarChart, BareButton, Breadcrumb, BulkActionBar, Button, Card, ChangeChip, Checkbox, CheckboxTree, Collapse, Drawer, Dropdown, EmptyState, FiltersForm, Form, HighchartsReact, Input, InputNumber, LegacyNavMenu, ListPopover, ListRow, ManageColumnsPanel, Menu, Modal, MultiValueTextOperatorOptions, NavMenu, NotificationModal, Pagination, Popover, Progress, Radio, RadioGroup, Rate, Select, SelectAll, Skeleton, Spinner, StatusPill, StepDrawer, Steps, SummarizedSelect, Swatch, SwatchStrip, Switch, Table, Tabs, Tag, ThresholdBar, Tooltip, UserProfile, VennDiagram, appTheme, icons, isMultiValueTextOperator, mergeProps, normalizeMultiValues, operatorOptionsFor, tailwindPreset, useMessage, useNotification, useStepDrawerSlots, useSteps, withDesignSystemPaginationOverrides };
@@ -0,0 +1,89 @@
1
+ const require_Button = require("../button/Button.cjs");
2
+ const require_Drawer = require("../drawer/Drawer.cjs");
3
+ const require_Steps = require("../steps/Steps.cjs");
4
+ let react = require("react");
5
+ let react_jsx_runtime = require("react/jsx-runtime");
6
+ //#region src/components/stepDrawer/StepDrawer.tsx
7
+ var SlotContext = (0, react.createContext)({
8
+ primary: null,
9
+ extra: null
10
+ });
11
+ /**
12
+ * The footer's primary-action slot and the header's extra slot, for steps that
13
+ * build their own buttons from state the drawer's parent cannot reach. Portal
14
+ * into them with `createPortal`. A flow whose buttons are available where the
15
+ * drawer is rendered passes `primaryAction` / `extraContent` instead.
16
+ *
17
+ * Use one or the other on a given step. The header slot only exists while
18
+ * `extraContent` is empty, but the footer slot is always there, so a step that
19
+ * portals its primary action needs the flow to pass no `primaryAction`.
20
+ */
21
+ var useStepDrawerSlots = () => (0, react.useContext)(SlotContext);
22
+ /**
23
+ * A full-page multi-step drawer: bottom placement, a numbered step bar that
24
+ * shows progress but cannot be clicked, and a right-aligned footer. Navigation
25
+ * is footer-only. There is no Cancel button: leaving goes through `onClose`,
26
+ * from the close control or Esc.
27
+ *
28
+ * The flow owns everything that gates a step. There is deliberately no
29
+ * `canProceed` prop: whether the primary action is disabled, or clickable and
30
+ * revealing errors, is up to the node passed as `primaryAction`.
31
+ */
32
+ function StepDrawer({ open, onClose, title, labels, current, onBack, primaryAction, extraContent, bodyClassName = "h-full overflow-y-auto", destroyOnHidden, afterOpenChange, children }) {
33
+ const [primarySlot, setPrimarySlot] = (0, react.useState)(null);
34
+ const [extraSlot, setExtraSlot] = (0, react.useState)(null);
35
+ const slots = (0, react.useMemo)(() => ({
36
+ primary: primarySlot,
37
+ extra: extraSlot
38
+ }), [primarySlot, extraSlot]);
39
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Drawer.Drawer, {
40
+ open,
41
+ onClose,
42
+ title,
43
+ placement: "bottom",
44
+ fillPage: true,
45
+ destroyOnHidden,
46
+ afterOpenChange,
47
+ extraContent: extraContent || /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { ref: setExtraSlot }),
48
+ footer: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
49
+ className: "flex w-full justify-end gap-2",
50
+ children: [
51
+ onBack && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Button.Button, {
52
+ size: "large",
53
+ onClick: onBack,
54
+ children: "Go back"
55
+ }),
56
+ primaryAction,
57
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
58
+ ref: setPrimarySlot,
59
+ className: "contents"
60
+ })
61
+ ]
62
+ }),
63
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SlotContext.Provider, {
64
+ value: slots,
65
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
66
+ className: bodyClassName,
67
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
68
+ className: "flex w-full justify-center py-8",
69
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
70
+ className: "w-2/3 max-w-4xl",
71
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Steps.Steps, {
72
+ items: labels.map((label, index) => ({
73
+ title: index + 1,
74
+ description: label
75
+ })),
76
+ dot: true,
77
+ current
78
+ })
79
+ })
80
+ }), children]
81
+ })
82
+ })
83
+ });
84
+ }
85
+ //#endregion
86
+ exports.StepDrawer = StepDrawer;
87
+ exports.useStepDrawerSlots = useStepDrawerSlots;
88
+
89
+ //# sourceMappingURL=StepDrawer.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StepDrawer.cjs","names":["createContext","useContext","useState","useMemo","Drawer","Button","Steps"],"sources":["../../../../src/components/stepDrawer/StepDrawer.tsx"],"sourcesContent":["import {\n createContext,\n useContext,\n useMemo,\n useState,\n type ReactNode,\n} from 'react'\nimport { Button } from '../button'\nimport { Drawer } from '../drawer'\nimport { Steps } from '../steps'\n\ntype StepDrawerSlots = {\n primary: HTMLElement | null\n extra: HTMLElement | null\n}\n\nconst SlotContext = createContext<StepDrawerSlots>({\n primary: null,\n extra: null,\n})\n\n/**\n * The footer's primary-action slot and the header's extra slot, for steps that\n * build their own buttons from state the drawer's parent cannot reach. Portal\n * into them with `createPortal`. A flow whose buttons are available where the\n * drawer is rendered passes `primaryAction` / `extraContent` instead.\n *\n * Use one or the other on a given step. The header slot only exists while\n * `extraContent` is empty, but the footer slot is always there, so a step that\n * portals its primary action needs the flow to pass no `primaryAction`.\n */\nexport const useStepDrawerSlots = () => useContext(SlotContext)\n\nexport type StepDrawerProps = {\n open: boolean\n onClose: () => void\n title: ReactNode\n /** One label per step, shown under its number in the step bar. */\n labels: string[]\n /** Zero-based index of the step on screen. The drawer never changes it. */\n current: number\n /**\n * Renders a Go back button in the footer. Omit it on a step with nowhere to\n * return to, which is usually the first. A flow whose first step does have\n * somewhere to return to passes a handler there too.\n */\n onBack?: () => void\n /** The footer's main button, such as Next or Submit. */\n primaryAction?: ReactNode\n /**\n * Content in the header, left of the close control. While it is empty\n * (any falsy value, such as the `false` from `cond && <X />`) the header\n * holds the extra slot instead.\n */\n extraContent?: ReactNode\n /**\n * Classes for the body around the step bar and content. Replaces the\n * default `h-full overflow-y-auto`, so a step that scrolls its own content\n * can pass `h-full` alone.\n */\n bodyClassName?: string\n destroyOnHidden?: boolean\n /**\n * Fires once the open or close animation has finished. A flow that resets\n * state on close wants this rather than `open`, which flips while the panel\n * is still on screen.\n */\n afterOpenChange?: (open: boolean) => void\n children: ReactNode\n}\n\n/**\n * A full-page multi-step drawer: bottom placement, a numbered step bar that\n * shows progress but cannot be clicked, and a right-aligned footer. Navigation\n * is footer-only. There is no Cancel button: leaving goes through `onClose`,\n * from the close control or Esc.\n *\n * The flow owns everything that gates a step. There is deliberately no\n * `canProceed` prop: whether the primary action is disabled, or clickable and\n * revealing errors, is up to the node passed as `primaryAction`.\n */\nexport function StepDrawer({\n open,\n onClose,\n title,\n labels,\n current,\n onBack,\n primaryAction,\n extraContent,\n bodyClassName = 'h-full overflow-y-auto',\n destroyOnHidden,\n afterOpenChange,\n children,\n}: StepDrawerProps) {\n const [primarySlot, setPrimarySlot] = useState<HTMLDivElement | null>(null)\n const [extraSlot, setExtraSlot] = useState<HTMLDivElement | null>(null)\n const slots = useMemo(\n () => ({ primary: primarySlot, extra: extraSlot }),\n [primarySlot, extraSlot]\n )\n\n return (\n <Drawer\n open={open}\n onClose={onClose}\n title={title}\n placement=\"bottom\"\n fillPage\n destroyOnHidden={destroyOnHidden}\n afterOpenChange={afterOpenChange}\n // Unlike the footer slot below, this one is either/or: the header sits in\n // an antd `Space`, which gives every child its own gap, so an unused slot\n // would push the close control across.\n extraContent={extraContent || <div ref={setExtraSlot} />}\n footer={\n <div className=\"flex w-full justify-end gap-2\">\n {/* The group is right-anchored, so a missing Go back leaves the\n primary action where it was rather than shifting it. */}\n {onBack && (\n <Button size=\"large\" onClick={onBack}>\n Go back\n </Button>\n )}\n {primaryAction}\n {/* `contents` keeps the empty slot out of the flex row, so a flow can\n pass `primaryAction` on some steps and portal into the slot on\n others without the unused one opening a gap. */}\n <div ref={setPrimarySlot} className=\"contents\" />\n </div>\n }\n >\n <SlotContext.Provider value={slots}>\n <div className={bodyClassName}>\n <div className=\"flex w-full justify-center py-8\">\n <div className=\"w-2/3 max-w-4xl\">\n {/* `current` without `setCurrent` renders the bar read-only. */}\n <Steps\n items={labels.map((label, index) => ({\n title: index + 1,\n description: label,\n }))}\n dot\n current={current}\n />\n </div>\n </div>\n {children}\n </div>\n </SlotContext.Provider>\n </Drawer>\n )\n}\n"],"mappings":";;;;;;AAgBA,IAAM,eAAA,GAAcA,MAAAA,cAAAA,CAA+B;CACjD,SAAS;CACT,OAAO;AACT,CAAC;;;;;;;;;;;AAYD,IAAa,4BAAA,GAA2BC,MAAAA,WAAAA,CAAW,WAAW;;;;;;;;;;;AAkD9D,SAAgB,WAAW,EACzB,MACA,SACA,OACA,QACA,SACA,QACA,eACA,cACA,gBAAgB,0BAChB,iBACA,iBACA,YACkB;CAClB,MAAM,CAAC,aAAa,mBAAA,GAAkBC,MAAAA,SAAAA,CAAgC,IAAI;CAC1E,MAAM,CAAC,WAAW,iBAAA,GAAgBA,MAAAA,SAAAA,CAAgC,IAAI;CACtE,MAAM,SAAA,GAAQC,MAAAA,QAAAA,QACL;EAAE,SAAS;EAAa,OAAO;CAAU,IAChD,CAAC,aAAa,SAAS,CACzB;CAEA,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,eAAAA,QAAD;EACQ;EACG;EACF;EACP,WAAU;EACV,UAAA;EACiB;EACA;EAIjB,cAAc,gBAAgB,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD,EAAK,KAAK,aAAe,CAAA;EACvD,QACE,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;GAAK,WAAU;GAAf,UAAA;IAGG,UACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,eAAAA,QAAD;KAAQ,MAAK;KAAQ,SAAS;KAAQ,UAAA;IAE9B,CAAA;IAET;IAID,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;KAAK,KAAK;KAAgB,WAAU;IAAY,CAAA;GAC7C;;EAGP,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,YAAY,UAAb;GAAsB,OAAO;GAC3B,UAAA,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;IAAK,WAAW;IAAhB,UAAA,CACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;KAAK,WAAU;KACb,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;MAAK,WAAU;MAEb,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,cAAAA,OAAD;OACE,OAAO,OAAO,KAAK,OAAO,WAAW;QACnC,OAAO,QAAQ;QACf,aAAa;OACf,EAAE;OACF,KAAA;OACS;MACV,CAAA;KACE,CAAA;IACF,CAAA,GACJ,QACE;;EACe,CAAA;CAChB,CAAA;AAEZ"}
@@ -0,0 +1,65 @@
1
+ import { ReactNode } from 'react';
2
+ type StepDrawerSlots = {
3
+ primary: HTMLElement | null;
4
+ extra: HTMLElement | null;
5
+ };
6
+ /**
7
+ * The footer's primary-action slot and the header's extra slot, for steps that
8
+ * build their own buttons from state the drawer's parent cannot reach. Portal
9
+ * into them with `createPortal`. A flow whose buttons are available where the
10
+ * drawer is rendered passes `primaryAction` / `extraContent` instead.
11
+ *
12
+ * Use one or the other on a given step. The header slot only exists while
13
+ * `extraContent` is empty, but the footer slot is always there, so a step that
14
+ * portals its primary action needs the flow to pass no `primaryAction`.
15
+ */
16
+ export declare const useStepDrawerSlots: () => StepDrawerSlots;
17
+ export type StepDrawerProps = {
18
+ open: boolean;
19
+ onClose: () => void;
20
+ title: ReactNode;
21
+ /** One label per step, shown under its number in the step bar. */
22
+ labels: string[];
23
+ /** Zero-based index of the step on screen. The drawer never changes it. */
24
+ current: number;
25
+ /**
26
+ * Renders a Go back button in the footer. Omit it on a step with nowhere to
27
+ * return to, which is usually the first. A flow whose first step does have
28
+ * somewhere to return to passes a handler there too.
29
+ */
30
+ onBack?: () => void;
31
+ /** The footer's main button, such as Next or Submit. */
32
+ primaryAction?: ReactNode;
33
+ /**
34
+ * Content in the header, left of the close control. While it is empty
35
+ * (any falsy value, such as the `false` from `cond && <X />`) the header
36
+ * holds the extra slot instead.
37
+ */
38
+ extraContent?: ReactNode;
39
+ /**
40
+ * Classes for the body around the step bar and content. Replaces the
41
+ * default `h-full overflow-y-auto`, so a step that scrolls its own content
42
+ * can pass `h-full` alone.
43
+ */
44
+ bodyClassName?: string;
45
+ destroyOnHidden?: boolean;
46
+ /**
47
+ * Fires once the open or close animation has finished. A flow that resets
48
+ * state on close wants this rather than `open`, which flips while the panel
49
+ * is still on screen.
50
+ */
51
+ afterOpenChange?: (open: boolean) => void;
52
+ children: ReactNode;
53
+ };
54
+ /**
55
+ * A full-page multi-step drawer: bottom placement, a numbered step bar that
56
+ * shows progress but cannot be clicked, and a right-aligned footer. Navigation
57
+ * is footer-only. There is no Cancel button: leaving goes through `onClose`,
58
+ * from the close control or Esc.
59
+ *
60
+ * The flow owns everything that gates a step. There is deliberately no
61
+ * `canProceed` prop: whether the primary action is disabled, or clickable and
62
+ * revealing errors, is up to the node passed as `primaryAction`.
63
+ */
64
+ export declare function StepDrawer({ open, onClose, title, labels, current, onBack, primaryAction, extraContent, bodyClassName, destroyOnHidden, afterOpenChange, children, }: StepDrawerProps): import('react').JSX.Element;
65
+ export {};
@@ -0,0 +1,88 @@
1
+ import { Button } from "../button/Button.js";
2
+ import { Drawer } from "../drawer/Drawer.js";
3
+ import { Steps } from "../steps/Steps.js";
4
+ import { createContext, useContext, useMemo, useState } from "react";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ //#region src/components/stepDrawer/StepDrawer.tsx
7
+ var SlotContext = createContext({
8
+ primary: null,
9
+ extra: null
10
+ });
11
+ /**
12
+ * The footer's primary-action slot and the header's extra slot, for steps that
13
+ * build their own buttons from state the drawer's parent cannot reach. Portal
14
+ * into them with `createPortal`. A flow whose buttons are available where the
15
+ * drawer is rendered passes `primaryAction` / `extraContent` instead.
16
+ *
17
+ * Use one or the other on a given step. The header slot only exists while
18
+ * `extraContent` is empty, but the footer slot is always there, so a step that
19
+ * portals its primary action needs the flow to pass no `primaryAction`.
20
+ */
21
+ var useStepDrawerSlots = () => useContext(SlotContext);
22
+ /**
23
+ * A full-page multi-step drawer: bottom placement, a numbered step bar that
24
+ * shows progress but cannot be clicked, and a right-aligned footer. Navigation
25
+ * is footer-only. There is no Cancel button: leaving goes through `onClose`,
26
+ * from the close control or Esc.
27
+ *
28
+ * The flow owns everything that gates a step. There is deliberately no
29
+ * `canProceed` prop: whether the primary action is disabled, or clickable and
30
+ * revealing errors, is up to the node passed as `primaryAction`.
31
+ */
32
+ function StepDrawer({ open, onClose, title, labels, current, onBack, primaryAction, extraContent, bodyClassName = "h-full overflow-y-auto", destroyOnHidden, afterOpenChange, children }) {
33
+ const [primarySlot, setPrimarySlot] = useState(null);
34
+ const [extraSlot, setExtraSlot] = useState(null);
35
+ const slots = useMemo(() => ({
36
+ primary: primarySlot,
37
+ extra: extraSlot
38
+ }), [primarySlot, extraSlot]);
39
+ return /* @__PURE__ */ jsx(Drawer, {
40
+ open,
41
+ onClose,
42
+ title,
43
+ placement: "bottom",
44
+ fillPage: true,
45
+ destroyOnHidden,
46
+ afterOpenChange,
47
+ extraContent: extraContent || /* @__PURE__ */ jsx("div", { ref: setExtraSlot }),
48
+ footer: /* @__PURE__ */ jsxs("div", {
49
+ className: "flex w-full justify-end gap-2",
50
+ children: [
51
+ onBack && /* @__PURE__ */ jsx(Button, {
52
+ size: "large",
53
+ onClick: onBack,
54
+ children: "Go back"
55
+ }),
56
+ primaryAction,
57
+ /* @__PURE__ */ jsx("div", {
58
+ ref: setPrimarySlot,
59
+ className: "contents"
60
+ })
61
+ ]
62
+ }),
63
+ children: /* @__PURE__ */ jsx(SlotContext.Provider, {
64
+ value: slots,
65
+ children: /* @__PURE__ */ jsxs("div", {
66
+ className: bodyClassName,
67
+ children: [/* @__PURE__ */ jsx("div", {
68
+ className: "flex w-full justify-center py-8",
69
+ children: /* @__PURE__ */ jsx("div", {
70
+ className: "w-2/3 max-w-4xl",
71
+ children: /* @__PURE__ */ jsx(Steps, {
72
+ items: labels.map((label, index) => ({
73
+ title: index + 1,
74
+ description: label
75
+ })),
76
+ dot: true,
77
+ current
78
+ })
79
+ })
80
+ }), children]
81
+ })
82
+ })
83
+ });
84
+ }
85
+ //#endregion
86
+ export { StepDrawer, useStepDrawerSlots };
87
+
88
+ //# sourceMappingURL=StepDrawer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StepDrawer.js","names":[],"sources":["../../../../src/components/stepDrawer/StepDrawer.tsx"],"sourcesContent":["import {\n createContext,\n useContext,\n useMemo,\n useState,\n type ReactNode,\n} from 'react'\nimport { Button } from '../button'\nimport { Drawer } from '../drawer'\nimport { Steps } from '../steps'\n\ntype StepDrawerSlots = {\n primary: HTMLElement | null\n extra: HTMLElement | null\n}\n\nconst SlotContext = createContext<StepDrawerSlots>({\n primary: null,\n extra: null,\n})\n\n/**\n * The footer's primary-action slot and the header's extra slot, for steps that\n * build their own buttons from state the drawer's parent cannot reach. Portal\n * into them with `createPortal`. A flow whose buttons are available where the\n * drawer is rendered passes `primaryAction` / `extraContent` instead.\n *\n * Use one or the other on a given step. The header slot only exists while\n * `extraContent` is empty, but the footer slot is always there, so a step that\n * portals its primary action needs the flow to pass no `primaryAction`.\n */\nexport const useStepDrawerSlots = () => useContext(SlotContext)\n\nexport type StepDrawerProps = {\n open: boolean\n onClose: () => void\n title: ReactNode\n /** One label per step, shown under its number in the step bar. */\n labels: string[]\n /** Zero-based index of the step on screen. The drawer never changes it. */\n current: number\n /**\n * Renders a Go back button in the footer. Omit it on a step with nowhere to\n * return to, which is usually the first. A flow whose first step does have\n * somewhere to return to passes a handler there too.\n */\n onBack?: () => void\n /** The footer's main button, such as Next or Submit. */\n primaryAction?: ReactNode\n /**\n * Content in the header, left of the close control. While it is empty\n * (any falsy value, such as the `false` from `cond && <X />`) the header\n * holds the extra slot instead.\n */\n extraContent?: ReactNode\n /**\n * Classes for the body around the step bar and content. Replaces the\n * default `h-full overflow-y-auto`, so a step that scrolls its own content\n * can pass `h-full` alone.\n */\n bodyClassName?: string\n destroyOnHidden?: boolean\n /**\n * Fires once the open or close animation has finished. A flow that resets\n * state on close wants this rather than `open`, which flips while the panel\n * is still on screen.\n */\n afterOpenChange?: (open: boolean) => void\n children: ReactNode\n}\n\n/**\n * A full-page multi-step drawer: bottom placement, a numbered step bar that\n * shows progress but cannot be clicked, and a right-aligned footer. Navigation\n * is footer-only. There is no Cancel button: leaving goes through `onClose`,\n * from the close control or Esc.\n *\n * The flow owns everything that gates a step. There is deliberately no\n * `canProceed` prop: whether the primary action is disabled, or clickable and\n * revealing errors, is up to the node passed as `primaryAction`.\n */\nexport function StepDrawer({\n open,\n onClose,\n title,\n labels,\n current,\n onBack,\n primaryAction,\n extraContent,\n bodyClassName = 'h-full overflow-y-auto',\n destroyOnHidden,\n afterOpenChange,\n children,\n}: StepDrawerProps) {\n const [primarySlot, setPrimarySlot] = useState<HTMLDivElement | null>(null)\n const [extraSlot, setExtraSlot] = useState<HTMLDivElement | null>(null)\n const slots = useMemo(\n () => ({ primary: primarySlot, extra: extraSlot }),\n [primarySlot, extraSlot]\n )\n\n return (\n <Drawer\n open={open}\n onClose={onClose}\n title={title}\n placement=\"bottom\"\n fillPage\n destroyOnHidden={destroyOnHidden}\n afterOpenChange={afterOpenChange}\n // Unlike the footer slot below, this one is either/or: the header sits in\n // an antd `Space`, which gives every child its own gap, so an unused slot\n // would push the close control across.\n extraContent={extraContent || <div ref={setExtraSlot} />}\n footer={\n <div className=\"flex w-full justify-end gap-2\">\n {/* The group is right-anchored, so a missing Go back leaves the\n primary action where it was rather than shifting it. */}\n {onBack && (\n <Button size=\"large\" onClick={onBack}>\n Go back\n </Button>\n )}\n {primaryAction}\n {/* `contents` keeps the empty slot out of the flex row, so a flow can\n pass `primaryAction` on some steps and portal into the slot on\n others without the unused one opening a gap. */}\n <div ref={setPrimarySlot} className=\"contents\" />\n </div>\n }\n >\n <SlotContext.Provider value={slots}>\n <div className={bodyClassName}>\n <div className=\"flex w-full justify-center py-8\">\n <div className=\"w-2/3 max-w-4xl\">\n {/* `current` without `setCurrent` renders the bar read-only. */}\n <Steps\n items={labels.map((label, index) => ({\n title: index + 1,\n description: label,\n }))}\n dot\n current={current}\n />\n </div>\n </div>\n {children}\n </div>\n </SlotContext.Provider>\n </Drawer>\n )\n}\n"],"mappings":";;;;;;AAgBA,IAAM,cAAc,cAA+B;CACjD,SAAS;CACT,OAAO;AACT,CAAC;;;;;;;;;;;AAYD,IAAa,2BAA2B,WAAW,WAAW;;;;;;;;;;;AAkD9D,SAAgB,WAAW,EACzB,MACA,SACA,OACA,QACA,SACA,QACA,eACA,cACA,gBAAgB,0BAChB,iBACA,iBACA,YACkB;CAClB,MAAM,CAAC,aAAa,kBAAkB,SAAgC,IAAI;CAC1E,MAAM,CAAC,WAAW,gBAAgB,SAAgC,IAAI;CACtE,MAAM,QAAQ,eACL;EAAE,SAAS;EAAa,OAAO;CAAU,IAChD,CAAC,aAAa,SAAS,CACzB;CAEA,OACE,oBAAC,QAAD;EACQ;EACG;EACF;EACP,WAAU;EACV,UAAA;EACiB;EACA;EAIjB,cAAc,gBAAgB,oBAAC,OAAD,EAAK,KAAK,aAAe,CAAA;EACvD,QACE,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA;IAGG,UACC,oBAAC,QAAD;KAAQ,MAAK;KAAQ,SAAS;KAAQ,UAAA;IAE9B,CAAA;IAET;IAID,oBAAC,OAAD;KAAK,KAAK;KAAgB,WAAU;IAAY,CAAA;GAC7C;;EAGP,UAAA,oBAAC,YAAY,UAAb;GAAsB,OAAO;GAC3B,UAAA,qBAAC,OAAD;IAAK,WAAW;IAAhB,UAAA,CACE,oBAAC,OAAD;KAAK,WAAU;KACb,UAAA,oBAAC,OAAD;MAAK,WAAU;MAEb,UAAA,oBAAC,OAAD;OACE,OAAO,OAAO,KAAK,OAAO,WAAW;QACnC,OAAO,QAAQ;QACf,aAAa;OACf,EAAE;OACF,KAAA;OACS;MACV,CAAA;KACE,CAAA;IACF,CAAA,GACJ,QACE;;EACe,CAAA;CAChB,CAAA;AAEZ"}
@@ -0,0 +1 @@
1
+ export { StepDrawer, useStepDrawerSlots, type StepDrawerProps, } from './StepDrawer.js';
@@ -8,22 +8,23 @@ let react_jsx_runtime = require("react/jsx-runtime");
8
8
  let classnames = require("classnames");
9
9
  classnames = require_runtime.__toESM(classnames, 1);
10
10
  //#region src/components/steps/Steps.tsx
11
- var Steps = ({ items, current, setCurrent, dot = false, direction, orientation, size, labelPlacement, titlePlacement, ...props }) => {
11
+ var Steps = ({ items, current, setCurrent, dot = false, direction, orientation, size, labelPlacement, titlePlacement, className, ...props }) => {
12
12
  const isVertical = (orientation ?? direction) === "vertical";
13
13
  const totalSteps = items?.length || 0;
14
+ const isReadOnly = current !== void 0 && setCurrent === void 0;
14
15
  const { current: currentStep, setCurrent: setCurrentStep } = require_useSteps.useSteps({
15
16
  current,
16
17
  setCurrent,
17
18
  totalSteps
18
19
  });
19
20
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Steps, {
20
- className: "j2Steps",
21
21
  ...props,
22
+ className: (0, classnames.default)("j2Steps", className),
22
23
  orientation: orientation ?? direction,
23
24
  titlePlacement: titlePlacement ?? labelPlacement,
24
25
  size: size === "default" ? "medium" : size,
25
26
  current: currentStep,
26
- onChange: (curr) => setCurrentStep(curr),
27
+ onChange: isReadOnly ? void 0 : (curr) => setCurrentStep(curr),
27
28
  ...dot && { type: "dot" },
28
29
  items: items?.map((item, index) => {
29
30
  const { description, ...restItem } = item;
@@ -1 +1 @@
1
- {"version":3,"file":"Steps.cjs","names":["useSteps","AntdSteps","cx","CheckIcon"],"sources":["../../../../src/components/steps/Steps.tsx"],"sourcesContent":["import { Steps as AntdSteps, StepsProps } from 'antd'\nimport './Steps.css'\nimport { CheckIcon } from '@phosphor-icons/react'\nimport cx from 'classnames'\nimport { useSteps } from './useSteps'\n\ntype AllProps = StepsProps & {\n items: NonNullable<StepsProps['items']>\n dot?: boolean\n current?: number\n setCurrent?: (current: number) => void\n}\n\ntype Props = Expand<AllProps>\n\nexport const Steps = ({\n items,\n current,\n setCurrent,\n dot = false,\n direction,\n orientation,\n size,\n labelPlacement,\n titlePlacement,\n ...props\n}: Props) => {\n const isVertical = (orientation ?? direction) === 'vertical'\n const totalSteps = items?.length || 0\n\n const { current: currentStep, setCurrent: setCurrentStep } = useSteps({\n current,\n setCurrent,\n totalSteps,\n })\n\n return (\n <AntdSteps\n className=\"j2Steps\"\n {...props}\n orientation={orientation ?? direction}\n titlePlacement={titlePlacement ?? labelPlacement}\n size={size === 'default' ? 'medium' : size}\n current={currentStep}\n onChange={(curr) => setCurrentStep(curr)}\n {...(dot && { type: 'dot' })}\n items={items?.map((item, index) => {\n const { description, ...restItem } = item\n return {\n ...restItem,\n content: item.content ?? description,\n icon:\n !dot && currentStep > index ? (\n <div\n className={cx(\n `check-${size === 'small' ? 'small' : 'medium'}`,\n isVertical ? `vertical-check-icon` : `check-icon`\n )}\n >\n <CheckIcon size={16} />\n </div>\n ) : (\n item.icon\n ),\n }\n })}\n />\n )\n}\n"],"mappings":";;;;;;;;;;AAeA,IAAa,SAAS,EACpB,OACA,SACA,YACA,MAAM,OACN,WACA,aACA,MACA,gBACA,gBACA,GAAG,YACQ;CACX,MAAM,cAAc,eAAe,eAAe;CAClD,MAAM,aAAa,OAAO,UAAU;CAEpC,MAAM,EAAE,SAAS,aAAa,YAAY,mBAAmBA,iBAAAA,SAAS;EACpE;EACA;EACA;CACF,CAAC;CAED,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,KAAAA,OAAD;EACE,WAAU;EACV,GAAI;EACJ,aAAa,eAAe;EAC5B,gBAAgB,kBAAkB;EAClC,MAAM,SAAS,YAAY,WAAW;EACtC,SAAS;EACT,WAAW,SAAS,eAAe,IAAI;EACvC,GAAK,OAAO,EAAE,MAAM,MAAM;EAC1B,OAAO,OAAO,KAAK,MAAM,UAAU;GACjC,MAAM,EAAE,aAAa,GAAG,aAAa;GACrC,OAAO;IACL,GAAG;IACH,SAAS,KAAK,WAAW;IACzB,MACE,CAAC,OAAO,cAAc,QACpB,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;KACE,YAAA,GAAWC,WAAAA,QAAAA,CACT,SAAS,SAAS,UAAU,UAAU,YACtC,aAAa,wBAAwB,YACvC;KAEA,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,sBAAAA,WAAD,EAAW,MAAM,GAAK,CAAA;IACnB,CAAA,IAEL,KAAK;GAEX;EACF,CAAC;CACF,CAAA;AAEL"}
1
+ {"version":3,"file":"Steps.cjs","names":["useSteps","AntdSteps","cx","CheckIcon"],"sources":["../../../../src/components/steps/Steps.tsx"],"sourcesContent":["import { Steps as AntdSteps, StepsProps } from 'antd'\nimport './Steps.css'\nimport { CheckIcon } from '@phosphor-icons/react'\nimport cx from 'classnames'\nimport { useSteps } from './useSteps'\n\ntype AllProps = StepsProps & {\n items: NonNullable<StepsProps['items']>\n dot?: boolean\n current?: number\n setCurrent?: (current: number) => void\n}\n\ntype Props = Expand<AllProps>\n\nexport const Steps = ({\n items,\n current,\n setCurrent,\n dot = false,\n direction,\n orientation,\n size,\n labelPlacement,\n titlePlacement,\n className,\n ...props\n}: Props) => {\n const isVertical = (orientation ?? direction) === 'vertical'\n const totalSteps = items?.length || 0\n // antd only makes a step clickable when `onChange` is set, so a controlled\n // bar with no setter renders read-only rather than inert-but-clickable.\n const isReadOnly = current !== undefined && setCurrent === undefined\n\n const { current: currentStep, setCurrent: setCurrentStep } = useSteps({\n current,\n setCurrent,\n totalSteps,\n })\n\n return (\n <AntdSteps\n {...props}\n className={cx('j2Steps', className)}\n orientation={orientation ?? direction}\n titlePlacement={titlePlacement ?? labelPlacement}\n size={size === 'default' ? 'medium' : size}\n current={currentStep}\n onChange={isReadOnly ? undefined : (curr) => setCurrentStep(curr)}\n {...(dot && { type: 'dot' })}\n items={items?.map((item, index) => {\n const { description, ...restItem } = item\n return {\n ...restItem,\n content: item.content ?? description,\n icon:\n !dot && currentStep > index ? (\n <div\n className={cx(\n `check-${size === 'small' ? 'small' : 'medium'}`,\n isVertical ? `vertical-check-icon` : `check-icon`\n )}\n >\n <CheckIcon size={16} />\n </div>\n ) : (\n item.icon\n ),\n }\n })}\n />\n )\n}\n"],"mappings":";;;;;;;;;;AAeA,IAAa,SAAS,EACpB,OACA,SACA,YACA,MAAM,OACN,WACA,aACA,MACA,gBACA,gBACA,WACA,GAAG,YACQ;CACX,MAAM,cAAc,eAAe,eAAe;CAClD,MAAM,aAAa,OAAO,UAAU;CAGpC,MAAM,aAAa,YAAY,KAAA,KAAa,eAAe,KAAA;CAE3D,MAAM,EAAE,SAAS,aAAa,YAAY,mBAAmBA,iBAAAA,SAAS;EACpE;EACA;EACA;CACF,CAAC;CAED,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,KAAAA,OAAD;EACE,GAAI;EACJ,YAAA,GAAWC,WAAAA,QAAAA,CAAG,WAAW,SAAS;EAClC,aAAa,eAAe;EAC5B,gBAAgB,kBAAkB;EAClC,MAAM,SAAS,YAAY,WAAW;EACtC,SAAS;EACT,UAAU,aAAa,KAAA,KAAa,SAAS,eAAe,IAAI;EAChE,GAAK,OAAO,EAAE,MAAM,MAAM;EAC1B,OAAO,OAAO,KAAK,MAAM,UAAU;GACjC,MAAM,EAAE,aAAa,GAAG,aAAa;GACrC,OAAO;IACL,GAAG;IACH,SAAS,KAAK,WAAW;IACzB,MACE,CAAC,OAAO,cAAc,QACpB,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;KACE,YAAA,GAAWA,WAAAA,QAAAA,CACT,SAAS,SAAS,UAAU,UAAU,YACtC,aAAa,wBAAwB,YACvC;KAEA,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,sBAAAA,WAAD,EAAW,MAAM,GAAK,CAAA;IACnB,CAAA,IAEL,KAAK;GAEX;EACF,CAAC;CACF,CAAA;AAEL"}
@@ -6,5 +6,5 @@ type AllProps = StepsProps & {
6
6
  setCurrent?: (current: number) => void;
7
7
  };
8
8
  type Props = Expand<AllProps>;
9
- export declare const Steps: ({ items, current, setCurrent, dot, direction, orientation, size, labelPlacement, titlePlacement, ...props }: Props) => import('react').JSX.Element;
9
+ export declare const Steps: ({ items, current, setCurrent, dot, direction, orientation, size, labelPlacement, titlePlacement, className, ...props }: Props) => import('react').JSX.Element;
10
10
  export {};
@@ -5,22 +5,23 @@ import { CheckIcon } from "@phosphor-icons/react";
5
5
  import { jsx } from "react/jsx-runtime";
6
6
  import cx from "classnames";
7
7
  //#region src/components/steps/Steps.tsx
8
- var Steps$1 = ({ items, current, setCurrent, dot = false, direction, orientation, size, labelPlacement, titlePlacement, ...props }) => {
8
+ var Steps$1 = ({ items, current, setCurrent, dot = false, direction, orientation, size, labelPlacement, titlePlacement, className, ...props }) => {
9
9
  const isVertical = (orientation ?? direction) === "vertical";
10
10
  const totalSteps = items?.length || 0;
11
+ const isReadOnly = current !== void 0 && setCurrent === void 0;
11
12
  const { current: currentStep, setCurrent: setCurrentStep } = useSteps({
12
13
  current,
13
14
  setCurrent,
14
15
  totalSteps
15
16
  });
16
17
  return /* @__PURE__ */ jsx(Steps, {
17
- className: "j2Steps",
18
18
  ...props,
19
+ className: cx("j2Steps", className),
19
20
  orientation: orientation ?? direction,
20
21
  titlePlacement: titlePlacement ?? labelPlacement,
21
22
  size: size === "default" ? "medium" : size,
22
23
  current: currentStep,
23
- onChange: (curr) => setCurrentStep(curr),
24
+ onChange: isReadOnly ? void 0 : (curr) => setCurrentStep(curr),
24
25
  ...dot && { type: "dot" },
25
26
  items: items?.map((item, index) => {
26
27
  const { description, ...restItem } = item;
@@ -1 +1 @@
1
- {"version":3,"file":"Steps.js","names":["Steps","AntdSteps"],"sources":["../../../../src/components/steps/Steps.tsx"],"sourcesContent":["import { Steps as AntdSteps, StepsProps } from 'antd'\nimport './Steps.css'\nimport { CheckIcon } from '@phosphor-icons/react'\nimport cx from 'classnames'\nimport { useSteps } from './useSteps'\n\ntype AllProps = StepsProps & {\n items: NonNullable<StepsProps['items']>\n dot?: boolean\n current?: number\n setCurrent?: (current: number) => void\n}\n\ntype Props = Expand<AllProps>\n\nexport const Steps = ({\n items,\n current,\n setCurrent,\n dot = false,\n direction,\n orientation,\n size,\n labelPlacement,\n titlePlacement,\n ...props\n}: Props) => {\n const isVertical = (orientation ?? direction) === 'vertical'\n const totalSteps = items?.length || 0\n\n const { current: currentStep, setCurrent: setCurrentStep } = useSteps({\n current,\n setCurrent,\n totalSteps,\n })\n\n return (\n <AntdSteps\n className=\"j2Steps\"\n {...props}\n orientation={orientation ?? direction}\n titlePlacement={titlePlacement ?? labelPlacement}\n size={size === 'default' ? 'medium' : size}\n current={currentStep}\n onChange={(curr) => setCurrentStep(curr)}\n {...(dot && { type: 'dot' })}\n items={items?.map((item, index) => {\n const { description, ...restItem } = item\n return {\n ...restItem,\n content: item.content ?? description,\n icon:\n !dot && currentStep > index ? (\n <div\n className={cx(\n `check-${size === 'small' ? 'small' : 'medium'}`,\n isVertical ? `vertical-check-icon` : `check-icon`\n )}\n >\n <CheckIcon size={16} />\n </div>\n ) : (\n item.icon\n ),\n }\n })}\n />\n )\n}\n"],"mappings":";;;;;;;AAeA,IAAaA,WAAS,EACpB,OACA,SACA,YACA,MAAM,OACN,WACA,aACA,MACA,gBACA,gBACA,GAAG,YACQ;CACX,MAAM,cAAc,eAAe,eAAe;CAClD,MAAM,aAAa,OAAO,UAAU;CAEpC,MAAM,EAAE,SAAS,aAAa,YAAY,mBAAmB,SAAS;EACpE;EACA;EACA;CACF,CAAC;CAED,OACE,oBAACC,OAAD;EACE,WAAU;EACV,GAAI;EACJ,aAAa,eAAe;EAC5B,gBAAgB,kBAAkB;EAClC,MAAM,SAAS,YAAY,WAAW;EACtC,SAAS;EACT,WAAW,SAAS,eAAe,IAAI;EACvC,GAAK,OAAO,EAAE,MAAM,MAAM;EAC1B,OAAO,OAAO,KAAK,MAAM,UAAU;GACjC,MAAM,EAAE,aAAa,GAAG,aAAa;GACrC,OAAO;IACL,GAAG;IACH,SAAS,KAAK,WAAW;IACzB,MACE,CAAC,OAAO,cAAc,QACpB,oBAAC,OAAD;KACE,WAAW,GACT,SAAS,SAAS,UAAU,UAAU,YACtC,aAAa,wBAAwB,YACvC;KAEA,UAAA,oBAAC,WAAD,EAAW,MAAM,GAAK,CAAA;IACnB,CAAA,IAEL,KAAK;GAEX;EACF,CAAC;CACF,CAAA;AAEL"}
1
+ {"version":3,"file":"Steps.js","names":["Steps","AntdSteps"],"sources":["../../../../src/components/steps/Steps.tsx"],"sourcesContent":["import { Steps as AntdSteps, StepsProps } from 'antd'\nimport './Steps.css'\nimport { CheckIcon } from '@phosphor-icons/react'\nimport cx from 'classnames'\nimport { useSteps } from './useSteps'\n\ntype AllProps = StepsProps & {\n items: NonNullable<StepsProps['items']>\n dot?: boolean\n current?: number\n setCurrent?: (current: number) => void\n}\n\ntype Props = Expand<AllProps>\n\nexport const Steps = ({\n items,\n current,\n setCurrent,\n dot = false,\n direction,\n orientation,\n size,\n labelPlacement,\n titlePlacement,\n className,\n ...props\n}: Props) => {\n const isVertical = (orientation ?? direction) === 'vertical'\n const totalSteps = items?.length || 0\n // antd only makes a step clickable when `onChange` is set, so a controlled\n // bar with no setter renders read-only rather than inert-but-clickable.\n const isReadOnly = current !== undefined && setCurrent === undefined\n\n const { current: currentStep, setCurrent: setCurrentStep } = useSteps({\n current,\n setCurrent,\n totalSteps,\n })\n\n return (\n <AntdSteps\n {...props}\n className={cx('j2Steps', className)}\n orientation={orientation ?? direction}\n titlePlacement={titlePlacement ?? labelPlacement}\n size={size === 'default' ? 'medium' : size}\n current={currentStep}\n onChange={isReadOnly ? undefined : (curr) => setCurrentStep(curr)}\n {...(dot && { type: 'dot' })}\n items={items?.map((item, index) => {\n const { description, ...restItem } = item\n return {\n ...restItem,\n content: item.content ?? description,\n icon:\n !dot && currentStep > index ? (\n <div\n className={cx(\n `check-${size === 'small' ? 'small' : 'medium'}`,\n isVertical ? `vertical-check-icon` : `check-icon`\n )}\n >\n <CheckIcon size={16} />\n </div>\n ) : (\n item.icon\n ),\n }\n })}\n />\n )\n}\n"],"mappings":";;;;;;;AAeA,IAAaA,WAAS,EACpB,OACA,SACA,YACA,MAAM,OACN,WACA,aACA,MACA,gBACA,gBACA,WACA,GAAG,YACQ;CACX,MAAM,cAAc,eAAe,eAAe;CAClD,MAAM,aAAa,OAAO,UAAU;CAGpC,MAAM,aAAa,YAAY,KAAA,KAAa,eAAe,KAAA;CAE3D,MAAM,EAAE,SAAS,aAAa,YAAY,mBAAmB,SAAS;EACpE;EACA;EACA;CACF,CAAC;CAED,OACE,oBAACC,OAAD;EACE,GAAI;EACJ,WAAW,GAAG,WAAW,SAAS;EAClC,aAAa,eAAe;EAC5B,gBAAgB,kBAAkB;EAClC,MAAM,SAAS,YAAY,WAAW;EACtC,SAAS;EACT,UAAU,aAAa,KAAA,KAAa,SAAS,eAAe,IAAI;EAChE,GAAK,OAAO,EAAE,MAAM,MAAM;EAC1B,OAAO,OAAO,KAAK,MAAM,UAAU;GACjC,MAAM,EAAE,aAAa,GAAG,aAAa;GACrC,OAAO;IACL,GAAG;IACH,SAAS,KAAK,WAAW;IACzB,MACE,CAAC,OAAO,cAAc,QACpB,oBAAC,OAAD;KACE,WAAW,GACT,SAAS,SAAS,UAAU,UAAU,YACtC,aAAa,wBAAwB,YACvC;KAEA,UAAA,oBAAC,WAAD,EAAW,MAAM,GAAK,CAAA;IACnB,CAAA,IAEL,KAAK;GAEX;EACF,CAAC;CACF,CAAA;AAEL"}
@@ -2,10 +2,10 @@ let react = require("react");
2
2
  //#region src/components/steps/useSteps.ts
3
3
  var useSteps = ({ current, setCurrent, totalSteps, initialStep = 0 }) => {
4
4
  const [internalCurrent, setInternalCurrent] = (0, react.useState)(initialStep);
5
- const isControlled = current !== void 0 && setCurrent !== void 0;
5
+ const isControlled = current !== void 0;
6
6
  const currentStep = isControlled ? current : internalCurrent;
7
7
  const handleSetCurrent = (0, react.useCallback)((newCurrent) => {
8
- if (isControlled) setCurrent(newCurrent);
8
+ if (isControlled) setCurrent?.(newCurrent);
9
9
  else setInternalCurrent(newCurrent);
10
10
  }, [isControlled, setCurrent]);
11
11
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"useSteps.cjs","names":["useState","useCallback"],"sources":["../../../../src/components/steps/useSteps.ts"],"sourcesContent":["import { useState, useCallback } from 'react'\n\ninterface UseStepsOptions {\n current?: number\n setCurrent?: (current: number) => void\n totalSteps: number\n initialStep?: number\n}\n\nexport const useSteps = ({\n current,\n setCurrent,\n totalSteps,\n initialStep = 0,\n}: UseStepsOptions) => {\n const [internalCurrent, setInternalCurrent] = useState(initialStep)\n\n const isControlled = current !== undefined && setCurrent !== undefined\n const currentStep = isControlled ? current : internalCurrent\n\n const handleSetCurrent = useCallback(\n (newCurrent: number) => {\n if (isControlled) {\n setCurrent!(newCurrent)\n } else {\n setInternalCurrent(newCurrent)\n }\n },\n [isControlled, setCurrent]\n )\n\n const next = useCallback(() => {\n if (currentStep < totalSteps - 1) {\n handleSetCurrent(currentStep + 1)\n }\n }, [currentStep, totalSteps, handleSetCurrent])\n\n const previous = useCallback(() => {\n if (currentStep > 0) {\n handleSetCurrent(currentStep - 1)\n }\n }, [currentStep, handleSetCurrent])\n\n const goToStep = useCallback(\n (step: number) => {\n if (step >= 0 && step < totalSteps) {\n handleSetCurrent(step)\n }\n },\n [totalSteps, handleSetCurrent]\n )\n\n const cancel = useCallback(() => {\n handleSetCurrent(initialStep)\n }, [handleSetCurrent, initialStep])\n\n return {\n next,\n previous,\n goToStep,\n cancel,\n current: currentStep,\n setCurrent: handleSetCurrent,\n canGoNext: currentStep < totalSteps - 1,\n canGoPrevious: currentStep > 0,\n }\n}\n"],"mappings":";;AASA,IAAa,YAAY,EACvB,SACA,YACA,YACA,cAAc,QACO;CACrB,MAAM,CAAC,iBAAiB,uBAAA,GAAsBA,MAAAA,SAAAA,CAAS,WAAW;CAElE,MAAM,eAAe,YAAY,KAAA,KAAa,eAAe,KAAA;CAC7D,MAAM,cAAc,eAAe,UAAU;CAE7C,MAAM,oBAAA,GAAmBC,MAAAA,YAAAA,EACtB,eAAuB;EACtB,IAAI,cACF,WAAY,UAAU;OAEtB,mBAAmB,UAAU;CAEjC,GACA,CAAC,cAAc,UAAU,CAC3B;CA2BA,OAAO;EACL,OAAA,GA1BWA,MAAAA,YAAAA,OAAkB;GAC7B,IAAI,cAAc,aAAa,GAC7B,iBAAiB,cAAc,CAAC;EAEpC,GAAG;GAAC;GAAa;GAAY;EAAgB,CAsB3C;EACA,WAAA,GArBeA,MAAAA,YAAAA,OAAkB;GACjC,IAAI,cAAc,GAChB,iBAAiB,cAAc,CAAC;EAEpC,GAAG,CAAC,aAAa,gBAAgB,CAiB/B;EACA,WAAA,GAhBeA,MAAAA,YAAAA,EACd,SAAiB;GAChB,IAAI,QAAQ,KAAK,OAAO,YACtB,iBAAiB,IAAI;EAEzB,GACA,CAAC,YAAY,gBAAgB,CAU7B;EACA,SAAA,GARaA,MAAAA,YAAAA,OAAkB;GAC/B,iBAAiB,WAAW;EAC9B,GAAG,CAAC,kBAAkB,WAAW,CAM/B;EACA,SAAS;EACT,YAAY;EACZ,WAAW,cAAc,aAAa;EACtC,eAAe,cAAc;CAC/B;AACF"}
1
+ {"version":3,"file":"useSteps.cjs","names":["useState","useCallback"],"sources":["../../../../src/components/steps/useSteps.ts"],"sourcesContent":["import { useState, useCallback } from 'react'\n\ninterface UseStepsOptions {\n current?: number\n setCurrent?: (current: number) => void\n totalSteps: number\n initialStep?: number\n}\n\nexport const useSteps = ({\n current,\n setCurrent,\n totalSteps,\n initialStep = 0,\n}: UseStepsOptions) => {\n const [internalCurrent, setInternalCurrent] = useState(initialStep)\n\n // `current` alone makes the steps controlled. Without `setCurrent` they are\n // read-only: navigation is a no-op and the parent moves `current` itself.\n const isControlled = current !== undefined\n const currentStep = isControlled ? current : internalCurrent\n\n const handleSetCurrent = useCallback(\n (newCurrent: number) => {\n if (isControlled) {\n setCurrent?.(newCurrent)\n } else {\n setInternalCurrent(newCurrent)\n }\n },\n [isControlled, setCurrent]\n )\n\n const next = useCallback(() => {\n if (currentStep < totalSteps - 1) {\n handleSetCurrent(currentStep + 1)\n }\n }, [currentStep, totalSteps, handleSetCurrent])\n\n const previous = useCallback(() => {\n if (currentStep > 0) {\n handleSetCurrent(currentStep - 1)\n }\n }, [currentStep, handleSetCurrent])\n\n const goToStep = useCallback(\n (step: number) => {\n if (step >= 0 && step < totalSteps) {\n handleSetCurrent(step)\n }\n },\n [totalSteps, handleSetCurrent]\n )\n\n const cancel = useCallback(() => {\n handleSetCurrent(initialStep)\n }, [handleSetCurrent, initialStep])\n\n return {\n next,\n previous,\n goToStep,\n cancel,\n current: currentStep,\n setCurrent: handleSetCurrent,\n canGoNext: currentStep < totalSteps - 1,\n canGoPrevious: currentStep > 0,\n }\n}\n"],"mappings":";;AASA,IAAa,YAAY,EACvB,SACA,YACA,YACA,cAAc,QACO;CACrB,MAAM,CAAC,iBAAiB,uBAAA,GAAsBA,MAAAA,SAAAA,CAAS,WAAW;CAIlE,MAAM,eAAe,YAAY,KAAA;CACjC,MAAM,cAAc,eAAe,UAAU;CAE7C,MAAM,oBAAA,GAAmBC,MAAAA,YAAAA,EACtB,eAAuB;EACtB,IAAI,cACF,aAAa,UAAU;OAEvB,mBAAmB,UAAU;CAEjC,GACA,CAAC,cAAc,UAAU,CAC3B;CA2BA,OAAO;EACL,OAAA,GA1BWA,MAAAA,YAAAA,OAAkB;GAC7B,IAAI,cAAc,aAAa,GAC7B,iBAAiB,cAAc,CAAC;EAEpC,GAAG;GAAC;GAAa;GAAY;EAAgB,CAsB3C;EACA,WAAA,GArBeA,MAAAA,YAAAA,OAAkB;GACjC,IAAI,cAAc,GAChB,iBAAiB,cAAc,CAAC;EAEpC,GAAG,CAAC,aAAa,gBAAgB,CAiB/B;EACA,WAAA,GAhBeA,MAAAA,YAAAA,EACd,SAAiB;GAChB,IAAI,QAAQ,KAAK,OAAO,YACtB,iBAAiB,IAAI;EAEzB,GACA,CAAC,YAAY,gBAAgB,CAU7B;EACA,SAAA,GARaA,MAAAA,YAAAA,OAAkB;GAC/B,iBAAiB,WAAW;EAC9B,GAAG,CAAC,kBAAkB,WAAW,CAM/B;EACA,SAAS;EACT,YAAY;EACZ,WAAW,cAAc,aAAa;EACtC,eAAe,cAAc;CAC/B;AACF"}
@@ -2,10 +2,10 @@ import { useCallback, useState } from "react";
2
2
  //#region src/components/steps/useSteps.ts
3
3
  var useSteps = ({ current, setCurrent, totalSteps, initialStep = 0 }) => {
4
4
  const [internalCurrent, setInternalCurrent] = useState(initialStep);
5
- const isControlled = current !== void 0 && setCurrent !== void 0;
5
+ const isControlled = current !== void 0;
6
6
  const currentStep = isControlled ? current : internalCurrent;
7
7
  const handleSetCurrent = useCallback((newCurrent) => {
8
- if (isControlled) setCurrent(newCurrent);
8
+ if (isControlled) setCurrent?.(newCurrent);
9
9
  else setInternalCurrent(newCurrent);
10
10
  }, [isControlled, setCurrent]);
11
11
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"useSteps.js","names":[],"sources":["../../../../src/components/steps/useSteps.ts"],"sourcesContent":["import { useState, useCallback } from 'react'\n\ninterface UseStepsOptions {\n current?: number\n setCurrent?: (current: number) => void\n totalSteps: number\n initialStep?: number\n}\n\nexport const useSteps = ({\n current,\n setCurrent,\n totalSteps,\n initialStep = 0,\n}: UseStepsOptions) => {\n const [internalCurrent, setInternalCurrent] = useState(initialStep)\n\n const isControlled = current !== undefined && setCurrent !== undefined\n const currentStep = isControlled ? current : internalCurrent\n\n const handleSetCurrent = useCallback(\n (newCurrent: number) => {\n if (isControlled) {\n setCurrent!(newCurrent)\n } else {\n setInternalCurrent(newCurrent)\n }\n },\n [isControlled, setCurrent]\n )\n\n const next = useCallback(() => {\n if (currentStep < totalSteps - 1) {\n handleSetCurrent(currentStep + 1)\n }\n }, [currentStep, totalSteps, handleSetCurrent])\n\n const previous = useCallback(() => {\n if (currentStep > 0) {\n handleSetCurrent(currentStep - 1)\n }\n }, [currentStep, handleSetCurrent])\n\n const goToStep = useCallback(\n (step: number) => {\n if (step >= 0 && step < totalSteps) {\n handleSetCurrent(step)\n }\n },\n [totalSteps, handleSetCurrent]\n )\n\n const cancel = useCallback(() => {\n handleSetCurrent(initialStep)\n }, [handleSetCurrent, initialStep])\n\n return {\n next,\n previous,\n goToStep,\n cancel,\n current: currentStep,\n setCurrent: handleSetCurrent,\n canGoNext: currentStep < totalSteps - 1,\n canGoPrevious: currentStep > 0,\n }\n}\n"],"mappings":";;AASA,IAAa,YAAY,EACvB,SACA,YACA,YACA,cAAc,QACO;CACrB,MAAM,CAAC,iBAAiB,sBAAsB,SAAS,WAAW;CAElE,MAAM,eAAe,YAAY,KAAA,KAAa,eAAe,KAAA;CAC7D,MAAM,cAAc,eAAe,UAAU;CAE7C,MAAM,mBAAmB,aACtB,eAAuB;EACtB,IAAI,cACF,WAAY,UAAU;OAEtB,mBAAmB,UAAU;CAEjC,GACA,CAAC,cAAc,UAAU,CAC3B;CA2BA,OAAO;EACL,MA1BW,kBAAkB;GAC7B,IAAI,cAAc,aAAa,GAC7B,iBAAiB,cAAc,CAAC;EAEpC,GAAG;GAAC;GAAa;GAAY;EAAgB,CAsB3C;EACA,UArBe,kBAAkB;GACjC,IAAI,cAAc,GAChB,iBAAiB,cAAc,CAAC;EAEpC,GAAG,CAAC,aAAa,gBAAgB,CAiB/B;EACA,UAhBe,aACd,SAAiB;GAChB,IAAI,QAAQ,KAAK,OAAO,YACtB,iBAAiB,IAAI;EAEzB,GACA,CAAC,YAAY,gBAAgB,CAU7B;EACA,QARa,kBAAkB;GAC/B,iBAAiB,WAAW;EAC9B,GAAG,CAAC,kBAAkB,WAAW,CAM/B;EACA,SAAS;EACT,YAAY;EACZ,WAAW,cAAc,aAAa;EACtC,eAAe,cAAc;CAC/B;AACF"}
1
+ {"version":3,"file":"useSteps.js","names":[],"sources":["../../../../src/components/steps/useSteps.ts"],"sourcesContent":["import { useState, useCallback } from 'react'\n\ninterface UseStepsOptions {\n current?: number\n setCurrent?: (current: number) => void\n totalSteps: number\n initialStep?: number\n}\n\nexport const useSteps = ({\n current,\n setCurrent,\n totalSteps,\n initialStep = 0,\n}: UseStepsOptions) => {\n const [internalCurrent, setInternalCurrent] = useState(initialStep)\n\n // `current` alone makes the steps controlled. Without `setCurrent` they are\n // read-only: navigation is a no-op and the parent moves `current` itself.\n const isControlled = current !== undefined\n const currentStep = isControlled ? current : internalCurrent\n\n const handleSetCurrent = useCallback(\n (newCurrent: number) => {\n if (isControlled) {\n setCurrent?.(newCurrent)\n } else {\n setInternalCurrent(newCurrent)\n }\n },\n [isControlled, setCurrent]\n )\n\n const next = useCallback(() => {\n if (currentStep < totalSteps - 1) {\n handleSetCurrent(currentStep + 1)\n }\n }, [currentStep, totalSteps, handleSetCurrent])\n\n const previous = useCallback(() => {\n if (currentStep > 0) {\n handleSetCurrent(currentStep - 1)\n }\n }, [currentStep, handleSetCurrent])\n\n const goToStep = useCallback(\n (step: number) => {\n if (step >= 0 && step < totalSteps) {\n handleSetCurrent(step)\n }\n },\n [totalSteps, handleSetCurrent]\n )\n\n const cancel = useCallback(() => {\n handleSetCurrent(initialStep)\n }, [handleSetCurrent, initialStep])\n\n return {\n next,\n previous,\n goToStep,\n cancel,\n current: currentStep,\n setCurrent: handleSetCurrent,\n canGoNext: currentStep < totalSteps - 1,\n canGoPrevious: currentStep > 0,\n }\n}\n"],"mappings":";;AASA,IAAa,YAAY,EACvB,SACA,YACA,YACA,cAAc,QACO;CACrB,MAAM,CAAC,iBAAiB,sBAAsB,SAAS,WAAW;CAIlE,MAAM,eAAe,YAAY,KAAA;CACjC,MAAM,cAAc,eAAe,UAAU;CAE7C,MAAM,mBAAmB,aACtB,eAAuB;EACtB,IAAI,cACF,aAAa,UAAU;OAEvB,mBAAmB,UAAU;CAEjC,GACA,CAAC,cAAc,UAAU,CAC3B;CA2BA,OAAO;EACL,MA1BW,kBAAkB;GAC7B,IAAI,cAAc,aAAa,GAC7B,iBAAiB,cAAc,CAAC;EAEpC,GAAG;GAAC;GAAa;GAAY;EAAgB,CAsB3C;EACA,UArBe,kBAAkB;GACjC,IAAI,cAAc,GAChB,iBAAiB,cAAc,CAAC;EAEpC,GAAG,CAAC,aAAa,gBAAgB,CAiB/B;EACA,UAhBe,aACd,SAAiB;GAChB,IAAI,QAAQ,KAAK,OAAO,YACtB,iBAAiB,IAAI;EAEzB,GACA,CAAC,YAAY,gBAAgB,CAU7B;EACA,QARa,kBAAkB;GAC/B,iBAAiB,WAAW;EAC9B,GAAG,CAAC,kBAAkB,WAAW,CAM/B;EACA,SAAS;EACT,YAAY;EACZ,WAAW,cAAc,aAAa;EACtC,eAAe,cAAc;CAC/B;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@j2-health/design-system",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "type": "module",
5
5
  "description": "J2 Health shared React component library",
6
6
  "repository": {
@@ -84,7 +84,7 @@
84
84
  "@tailwindcss/postcss": "^4.3.3",
85
85
  "@testing-library/jest-dom": "^7.0.1",
86
86
  "@testing-library/react": "^16.3.3",
87
- "@types/lodash": "^4.17.14",
87
+ "@types/lodash": "^4.17.26",
88
88
  "@types/react": "^19.2.18",
89
89
  "@types/react-dom": "^19.2.5",
90
90
  "@vitejs/plugin-react": "^6.1.2",
@@ -100,11 +100,11 @@
100
100
  "eslint-plugin-storybook": "^10.6.1",
101
101
  "formik": "^2.4.6",
102
102
  "globals": "^17.13.0",
103
- "happy-dom": "^20.14.5",
103
+ "happy-dom": "^20.14.6",
104
104
  "highcharts": "^13.1.1",
105
105
  "lodash": "^4.18.1",
106
106
  "postcss": "^8.5.29",
107
- "prettier": "^3.9.9",
107
+ "prettier": "^3.9.10",
108
108
  "react": "^19.2.8",
109
109
  "react-dom": "^19.2.8",
110
110
  "semver": "^7.8.5",
@@ -113,14 +113,14 @@
113
113
  "ts-node": "^10.9.2",
114
114
  "typescript": "^5.5.3",
115
115
  "typescript-eslint": "^8.71.1",
116
- "vite": "^8.3.3",
116
+ "vite": "^8.3.4",
117
117
  "vite-plugin-dts": "^5.1.2",
118
118
  "vite-plugin-svgr": "^5.2.0",
119
119
  "vitest": "^5.0.3",
120
120
  "yup": "^1.4.0"
121
121
  },
122
122
  "optionalDependencies": {
123
- "@rollup/rollup-linux-x64-gnu": "^4.64.0"
123
+ "@rollup/rollup-linux-x64-gnu": "^4.64.5"
124
124
  },
125
125
  "eslintConfig": {
126
126
  "extends": [