@brycks/core-front 0.3.6 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/data/List/List.cjs +1 -1
- package/dist/components/data/List/List.cjs.map +1 -1
- package/dist/components/data/List/List.js +68 -148
- package/dist/components/data/List/List.js.map +1 -1
- package/dist/components/data/Table/Table.cjs +1 -1
- package/dist/components/data/Table/Table.cjs.map +1 -1
- package/dist/components/data/Table/Table.js +148 -217
- package/dist/components/data/Table/Table.js.map +1 -1
- package/dist/components/data/TreeView/TreeView.cjs +1 -1
- package/dist/components/data/TreeView/TreeView.cjs.map +1 -1
- package/dist/components/data/TreeView/TreeView.js +141 -182
- package/dist/components/data/TreeView/TreeView.js.map +1 -1
- package/dist/components/data.cjs +1 -1
- package/dist/components/data.js +23 -21
- package/dist/components/feedback/Banner/Banner.cjs +2 -0
- package/dist/components/feedback/Banner/Banner.cjs.map +1 -0
- package/dist/components/feedback/Banner/Banner.js +77 -0
- package/dist/components/feedback/Banner/Banner.js.map +1 -0
- package/dist/components/feedback/ConfirmDialog/ConfirmDialog.cjs +2 -0
- package/dist/components/feedback/ConfirmDialog/ConfirmDialog.cjs.map +1 -0
- package/dist/components/feedback/ConfirmDialog/ConfirmDialog.js +68 -0
- package/dist/components/feedback/ConfirmDialog/ConfirmDialog.js.map +1 -0
- package/dist/components/feedback/Drawer/Drawer.cjs +1 -22
- package/dist/components/feedback/Drawer/Drawer.cjs.map +1 -1
- package/dist/components/feedback/Drawer/Drawer.js +84 -184
- package/dist/components/feedback/Drawer/Drawer.js.map +1 -1
- package/dist/components/feedback/Modal/Modal.cjs +1 -1
- package/dist/components/feedback/Modal/Modal.cjs.map +1 -1
- package/dist/components/feedback/Modal/Modal.js +73 -150
- package/dist/components/feedback/Modal/Modal.js.map +1 -1
- package/dist/components/feedback/Popover/Popover.cjs +2 -2
- package/dist/components/feedback/Popover/Popover.cjs.map +1 -1
- package/dist/components/feedback/Popover/Popover.js +43 -44
- package/dist/components/feedback/Popover/Popover.js.map +1 -1
- package/dist/components/feedback/Toast/Toast.cjs +1 -10
- package/dist/components/feedback/Toast/Toast.cjs.map +1 -1
- package/dist/components/feedback/Toast/Toast.js +94 -187
- package/dist/components/feedback/Toast/Toast.js.map +1 -1
- package/dist/components/feedback.cjs +1 -1
- package/dist/components/feedback.js +17 -13
- package/dist/components/feedback.js.map +1 -1
- package/dist/components/form/Checkbox/Checkbox.cjs +1 -1
- package/dist/components/form/Checkbox/Checkbox.js +11 -11
- package/dist/components/form/Combobox/Combobox.cjs +1 -6
- package/dist/components/form/Combobox/Combobox.cjs.map +1 -1
- package/dist/components/form/Combobox/Combobox.js +190 -266
- package/dist/components/form/Combobox/Combobox.js.map +1 -1
- package/dist/components/form/Input/Input.cjs +1 -1
- package/dist/components/form/Input/Input.cjs.map +1 -1
- package/dist/components/form/Input/Input.js +38 -133
- package/dist/components/form/Input/Input.js.map +1 -1
- package/dist/components/form/SearchInput/SearchInput.cjs +2 -0
- package/dist/components/form/SearchInput/SearchInput.cjs.map +1 -0
- package/dist/components/form/SearchInput/SearchInput.js +68 -0
- package/dist/components/form/SearchInput/SearchInput.js.map +1 -0
- package/dist/components/form/Select/Select.cjs +1 -1
- package/dist/components/form/Select/Select.cjs.map +1 -1
- package/dist/components/form/Select/Select.js +36 -82
- package/dist/components/form/Select/Select.js.map +1 -1
- package/dist/components/form/TagInput/TagInput.cjs +1 -1
- package/dist/components/form/TagInput/TagInput.js +8 -8
- package/dist/components/form/Textarea/Textarea.cjs +1 -1
- package/dist/components/form/Textarea/Textarea.cjs.map +1 -1
- package/dist/components/form/Textarea/Textarea.js +61 -95
- package/dist/components/form/Textarea/Textarea.js.map +1 -1
- package/dist/components/form.cjs +1 -1
- package/dist/components/form.js +15 -13
- package/dist/components/form.js.map +1 -1
- package/dist/components/layout/Card/Card.cjs +1 -1
- package/dist/components/layout/Card/Card.cjs.map +1 -1
- package/dist/components/layout/Card/Card.js +7 -5
- package/dist/components/layout/Card/Card.js.map +1 -1
- package/dist/components/navigation/ContextMenu/ContextMenu.cjs +1 -1
- package/dist/components/navigation/ContextMenu/ContextMenu.js +9 -9
- package/dist/components/navigation/Menu/Menu.cjs +1 -1
- package/dist/components/navigation/Menu/Menu.cjs.map +1 -1
- package/dist/components/navigation/Menu/Menu.js +70 -135
- package/dist/components/navigation/Menu/Menu.js.map +1 -1
- package/dist/components/navigation/Pagination/Pagination.cjs +1 -1
- package/dist/components/navigation/Pagination/Pagination.cjs.map +1 -1
- package/dist/components/navigation/Pagination/Pagination.js +87 -157
- package/dist/components/navigation/Pagination/Pagination.js.map +1 -1
- package/dist/components/navigation/SegmentedControl/SegmentedControl.cjs +2 -0
- package/dist/components/navigation/SegmentedControl/SegmentedControl.cjs.map +1 -0
- package/dist/components/navigation/SegmentedControl/SegmentedControl.js +90 -0
- package/dist/components/navigation/SegmentedControl/SegmentedControl.js.map +1 -0
- package/dist/components/navigation.cjs +1 -1
- package/dist/components/navigation.js +25 -23
- package/dist/components/navigation.js.map +1 -1
- package/dist/components/utility/Avatar/Avatar.cjs +1 -1
- package/dist/components/utility/Avatar/Avatar.cjs.map +1 -1
- package/dist/components/utility/Avatar/Avatar.js +18 -18
- package/dist/components/utility/Avatar/Avatar.js.map +1 -1
- package/dist/components/utility/Badge/Badge.cjs +1 -1
- package/dist/components/utility/Badge/Badge.cjs.map +1 -1
- package/dist/components/utility/Badge/Badge.js +31 -23
- package/dist/components/utility/Badge/Badge.js.map +1 -1
- package/dist/components/utility/Kbd/Kbd.cjs +2 -0
- package/dist/components/utility/Kbd/Kbd.cjs.map +1 -0
- package/dist/components/utility/Kbd/Kbd.js +20 -0
- package/dist/components/utility/Kbd/Kbd.js.map +1 -0
- package/dist/components/utility/Logo/Logo.cjs +1 -1
- package/dist/components/utility/Logo/Logo.cjs.map +1 -1
- package/dist/components/utility/Logo/Logo.js +19 -19
- package/dist/components/utility/Logo/Logo.js.map +1 -1
- package/dist/components/utility.cjs +1 -1
- package/dist/components/utility.js +9 -7
- package/dist/components/utility.js.map +1 -1
- package/dist/data.d.ts +34 -1
- package/dist/feedback.d.ts +67 -2
- package/dist/form.d.ts +31 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +184 -3
- package/dist/index.js +177 -165
- package/dist/index.js.map +1 -1
- package/dist/navigation.d.ts +39 -0
- package/dist/styles.css +1 -1
- package/dist/utility.d.ts +19 -0
- package/package.json +1 -1
package/dist/components/data.js
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
|
-
import { Table as
|
|
2
|
-
import { List as
|
|
3
|
-
import { InfoItem as
|
|
4
|
-
import { TreeView as
|
|
5
|
-
import { VariableHeightVirtualList as
|
|
1
|
+
import { Table as a, TableBody as o, TableCaption as r, TableCell as l, TableEmpty as i, TableFoot as b, TableHead as T, TableHeader as m, TableRow as f, TableSkeleton as p } from "./data/Table/Table.js";
|
|
2
|
+
import { List as L, ListDivider as d, ListHeader as x, ListItem as n } from "./data/List/List.js";
|
|
3
|
+
import { InfoItem as I, InfoList as V } from "./data/InfoItem/InfoItem.js";
|
|
4
|
+
import { TreeView as w } from "./data/TreeView/TreeView.js";
|
|
5
|
+
import { VariableHeightVirtualList as C, VirtualList as g } from "./data/VirtualList/VirtualList.js";
|
|
6
6
|
export {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
b as
|
|
19
|
-
T as
|
|
7
|
+
I as InfoItem,
|
|
8
|
+
V as InfoList,
|
|
9
|
+
L as List,
|
|
10
|
+
d as ListDivider,
|
|
11
|
+
x as ListHeader,
|
|
12
|
+
n as ListItem,
|
|
13
|
+
a as Table,
|
|
14
|
+
o as TableBody,
|
|
15
|
+
r as TableCaption,
|
|
16
|
+
l as TableCell,
|
|
17
|
+
i as TableEmpty,
|
|
18
|
+
b as TableFoot,
|
|
19
|
+
T as TableHead,
|
|
20
|
+
m as TableHeader,
|
|
20
21
|
f as TableRow,
|
|
21
|
-
|
|
22
|
-
w as
|
|
23
|
-
C as
|
|
22
|
+
p as TableSkeleton,
|
|
23
|
+
w as TreeView,
|
|
24
|
+
C as VariableHeightVirtualList,
|
|
25
|
+
g as VirtualList
|
|
24
26
|
};
|
|
25
27
|
//# sourceMappingURL=data.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),p=require("react"),L=require("../../../utils/styles.cjs"),f={info:r.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none","aria-hidden":"true",children:[r.jsx("circle",{cx:"9",cy:"9",r:"7.5",stroke:"currentColor",strokeWidth:"1.5"}),r.jsx("path",{d:"M9 8V12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),r.jsx("circle",{cx:"9",cy:"5.5",r:"0.75",fill:"currentColor"})]}),success:r.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none","aria-hidden":"true",children:[r.jsx("circle",{cx:"9",cy:"9",r:"7.5",stroke:"currentColor",strokeWidth:"1.5"}),r.jsx("path",{d:"M6 9L8 11L12 7",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),warning:r.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none","aria-hidden":"true",children:[r.jsx("path",{d:"M9 2L16.5 15H1.5L9 2Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),r.jsx("path",{d:"M9 7V10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),r.jsx("circle",{cx:"9",cy:"12.5",r:"0.75",fill:"currentColor"})]}),error:r.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none","aria-hidden":"true",children:[r.jsx("circle",{cx:"9",cy:"9",r:"7.5",stroke:"currentColor",strokeWidth:"1.5"}),r.jsx("path",{d:"M6.5 6.5L11.5 11.5M11.5 6.5L6.5 11.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})},g=new Set(["warning","error"]),a=p.forwardRef(function({intent:e="info",title:s,icon:l,showIcon:d=!0,action:n,isDismissible:t,onDismiss:h,dismissLabel:u="Dismiss",role:x,className:k,style:j,testId:b,children:o,...v},y){const i=x??(g.has(e)?"alert":"status"),c=l??(e==="neutral"?null:f[e]);return r.jsxs("div",{ref:y,role:i,"aria-live":i==="alert"?"assertive":"polite",className:L.cx("brycks-banner",`brycks-banner--${e}`,k),style:j,"data-testid":b,...v,children:[d&&c&&r.jsx("span",{className:"brycks-banner__icon",children:c}),r.jsxs("div",{className:"brycks-banner__content",children:[s&&r.jsx("div",{className:"brycks-banner__title",children:s}),o&&r.jsx("div",{className:"brycks-banner__description",children:o})]}),(n||t)&&r.jsxs("div",{className:"brycks-banner__actions",children:[n,t&&r.jsx("button",{type:"button",className:"brycks-banner__dismiss",onClick:h,"aria-label":u,children:r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",children:r.jsx("path",{d:"M3 3L11 11M11 3L3 11",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})]})});a.displayName="Banner";exports.Banner=a;
|
|
2
|
+
//# sourceMappingURL=Banner.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Banner.cjs","sources":["../../../../src/components/feedback/Banner/Banner.tsx"],"sourcesContent":["/**\n * Banner Component\n *\n * App-level announcement bar for status, alerts, and notices.\n * Horizontal, full-width layout designed to sit at the top of a page or app shell.\n *\n * Unlike Alert (a contained, in-flow message), Banner spans the full width and\n * picks its ARIA role from the intent: critical intents (warning/error) announce\n * assertively as `alert`, informational intents (info/success/neutral) as `status`.\n *\n * All color styles are handled via CSS classes for easy customization.\n */\n\nimport React, {\n forwardRef,\n type ReactNode,\n type HTMLAttributes,\n} from 'react'\nimport { cx } from '../../../utils/styles'\n\nexport type BannerIntent = 'info' | 'success' | 'warning' | 'error' | 'neutral'\n\nexport interface BannerProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {\n /** Visual intent/status */\n intent?: BannerIntent\n /** Banner title (stronger weight, sits above the description) */\n title?: ReactNode\n /** Custom icon (overrides the default per-intent icon) */\n icon?: ReactNode\n /** Whether to show the leading icon */\n showIcon?: boolean\n /** Action element (button, link) shown on the trailing edge */\n action?: ReactNode\n /** Whether the banner can be dismissed */\n isDismissible?: boolean\n /** Callback when dismissed */\n onDismiss?: () => void\n /** Accessible label of the dismiss button */\n dismissLabel?: string\n /**\n * ARIA live-region role. Defaults to `alert` for warning/error and\n * `status` for info/success/neutral. Override when the default is wrong.\n */\n role?: 'alert' | 'status'\n /** Custom class name */\n className?: string\n /** Test ID */\n testId?: string\n /** Banner content (description) */\n children?: ReactNode\n}\n\nconst defaultIcons: Record<Exclude<BannerIntent, 'neutral'>, React.JSX.Element> = {\n info: (\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 18 18\" fill=\"none\" aria-hidden=\"true\">\n <circle cx=\"9\" cy=\"9\" r=\"7.5\" stroke=\"currentColor\" strokeWidth=\"1.5\" />\n <path d=\"M9 8V12\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" />\n <circle cx=\"9\" cy=\"5.5\" r=\"0.75\" fill=\"currentColor\" />\n </svg>\n ),\n success: (\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 18 18\" fill=\"none\" aria-hidden=\"true\">\n <circle cx=\"9\" cy=\"9\" r=\"7.5\" stroke=\"currentColor\" strokeWidth=\"1.5\" />\n <path d=\"M6 9L8 11L12 7\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n ),\n warning: (\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 18 18\" fill=\"none\" aria-hidden=\"true\">\n <path d=\"M9 2L16.5 15H1.5L9 2Z\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinejoin=\"round\" />\n <path d=\"M9 7V10\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" />\n <circle cx=\"9\" cy=\"12.5\" r=\"0.75\" fill=\"currentColor\" />\n </svg>\n ),\n error: (\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 18 18\" fill=\"none\" aria-hidden=\"true\">\n <circle cx=\"9\" cy=\"9\" r=\"7.5\" stroke=\"currentColor\" strokeWidth=\"1.5\" />\n <path d=\"M6.5 6.5L11.5 11.5M11.5 6.5L6.5 11.5\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" />\n </svg>\n ),\n}\n\nconst criticalIntents: ReadonlySet<BannerIntent> = new Set<BannerIntent>(['warning', 'error'])\n\nexport const Banner = forwardRef<HTMLDivElement, BannerProps>(function Banner(\n {\n intent = 'info',\n title,\n icon,\n showIcon = true,\n action,\n isDismissible,\n onDismiss,\n dismissLabel = 'Dismiss',\n role,\n className,\n style,\n testId,\n children,\n ...props\n },\n ref\n) {\n const resolvedRole = role ?? (criticalIntents.has(intent) ? 'alert' : 'status')\n const resolvedIcon = icon ?? (intent === 'neutral' ? null : defaultIcons[intent])\n\n return (\n <div\n ref={ref}\n role={resolvedRole}\n aria-live={resolvedRole === 'alert' ? 'assertive' : 'polite'}\n className={cx('brycks-banner', `brycks-banner--${intent}`, className)}\n style={style}\n data-testid={testId}\n {...props}\n >\n {showIcon && resolvedIcon && (\n <span className=\"brycks-banner__icon\">{resolvedIcon}</span>\n )}\n\n <div className=\"brycks-banner__content\">\n {title && <div className=\"brycks-banner__title\">{title}</div>}\n {children && <div className=\"brycks-banner__description\">{children}</div>}\n </div>\n\n {(action || isDismissible) && (\n <div className=\"brycks-banner__actions\">\n {action}\n {isDismissible && (\n <button\n type=\"button\"\n className=\"brycks-banner__dismiss\"\n onClick={onDismiss}\n aria-label={dismissLabel}\n >\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 14 14\" fill=\"none\" aria-hidden=\"true\">\n <path d=\"M3 3L11 11M11 3L3 11\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" />\n </svg>\n </button>\n )}\n </div>\n )}\n </div>\n )\n})\n\nBanner.displayName = 'Banner'\n"],"names":["defaultIcons","jsxs","jsx","criticalIntents","Banner","forwardRef","intent","title","icon","showIcon","action","isDismissible","onDismiss","dismissLabel","role","className","style","testId","children","props","ref","resolvedRole","resolvedIcon","cx"],"mappings":"+KAoDMA,EAA4E,CAChF,KACEC,EAAAA,KAAC,MAAA,CAAI,MAAM,KAAK,OAAO,KAAK,QAAQ,YAAY,KAAK,OAAO,cAAY,OACtE,SAAA,CAAAC,EAAAA,IAAC,SAAA,CAAO,GAAG,IAAI,GAAG,IAAI,EAAE,MAAM,OAAO,eAAe,YAAY,KAAA,CAAM,EACtEA,EAAAA,IAAC,QAAK,EAAE,UAAU,OAAO,eAAe,YAAY,MAAM,cAAc,OAAA,CAAQ,EAChFA,EAAAA,IAAC,UAAO,GAAG,IAAI,GAAG,MAAM,EAAE,OAAO,KAAK,cAAA,CAAe,CAAA,EACvD,EAEF,QACED,EAAAA,KAAC,MAAA,CAAI,MAAM,KAAK,OAAO,KAAK,QAAQ,YAAY,KAAK,OAAO,cAAY,OACtE,SAAA,CAAAC,EAAAA,IAAC,SAAA,CAAO,GAAG,IAAI,GAAG,IAAI,EAAE,MAAM,OAAO,eAAe,YAAY,KAAA,CAAM,EACtEA,EAAAA,IAAC,OAAA,CAAK,EAAE,iBAAiB,OAAO,eAAe,YAAY,MAAM,cAAc,QAAQ,eAAe,OAAA,CAAQ,CAAA,EAChH,EAEF,QACED,EAAAA,KAAC,MAAA,CAAI,MAAM,KAAK,OAAO,KAAK,QAAQ,YAAY,KAAK,OAAO,cAAY,OACtE,SAAA,CAAAC,EAAAA,IAAC,OAAA,CAAK,EAAE,wBAAwB,OAAO,eAAe,YAAY,MAAM,eAAe,OAAA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AAAM,GAASL,EAAAA,IAAC,MAAA,CAAI,UAAU,uBAAwB,SAAAK,EAAM,EACtDW,GAAYhB,EAAAA,IAAC,MAAA,CAAI,UAAU,6BAA8B,SAAAgB,CAAA,CAAS,CAAA,EACrE,GAEER,GAAUC,IACVV,EAAAA,KAAC,MAAA,CAAI,UAAU,yBACZ,SAAA,CAAAS,EACAC,GACCT,EAAAA,IAAC,SAAA,CACC,KAAK,SACL,UAAU,yBACV,QAASU,EACT,aAAYC,EAEZ,SAAAX,EAAAA,IAAC,OAAI,MAAM,KAAK,OAAO,KAAK,QAAQ,YAAY,KAAK,OAAO,cAAY,OACtE,SAAAA,EAAAA,IAAC,OAAA,CAAK,EAAE,uBAAuB,OAAO,eAAe,YAAY,MAAM,cAAc,OAAA,CAAQ,CAAA,CAC/F,CAAA,CAAA,CACF,CAAA,CAEJ,CAAA,CAAA,CAAA,CAIR,CAAC,EAEDE,EAAO,YAAc"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { jsxs as e, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as y } from "react";
|
|
3
|
+
import { cx as L } from "../../../utils/styles.js";
|
|
4
|
+
const w = {
|
|
5
|
+
info: /* @__PURE__ */ e("svg", { width: "18", height: "18", viewBox: "0 0 18 18", fill: "none", "aria-hidden": "true", children: [
|
|
6
|
+
/* @__PURE__ */ r("circle", { cx: "9", cy: "9", r: "7.5", stroke: "currentColor", strokeWidth: "1.5" }),
|
|
7
|
+
/* @__PURE__ */ r("path", { d: "M9 8V12", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }),
|
|
8
|
+
/* @__PURE__ */ r("circle", { cx: "9", cy: "5.5", r: "0.75", fill: "currentColor" })
|
|
9
|
+
] }),
|
|
10
|
+
success: /* @__PURE__ */ e("svg", { width: "18", height: "18", viewBox: "0 0 18 18", fill: "none", "aria-hidden": "true", children: [
|
|
11
|
+
/* @__PURE__ */ r("circle", { cx: "9", cy: "9", r: "7.5", stroke: "currentColor", strokeWidth: "1.5" }),
|
|
12
|
+
/* @__PURE__ */ r("path", { d: "M6 9L8 11L12 7", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
13
|
+
] }),
|
|
14
|
+
warning: /* @__PURE__ */ e("svg", { width: "18", height: "18", viewBox: "0 0 18 18", fill: "none", "aria-hidden": "true", children: [
|
|
15
|
+
/* @__PURE__ */ r("path", { d: "M9 2L16.5 15H1.5L9 2Z", stroke: "currentColor", strokeWidth: "1.5", strokeLinejoin: "round" }),
|
|
16
|
+
/* @__PURE__ */ r("path", { d: "M9 7V10", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }),
|
|
17
|
+
/* @__PURE__ */ r("circle", { cx: "9", cy: "12.5", r: "0.75", fill: "currentColor" })
|
|
18
|
+
] }),
|
|
19
|
+
error: /* @__PURE__ */ e("svg", { width: "18", height: "18", viewBox: "0 0 18 18", fill: "none", "aria-hidden": "true", children: [
|
|
20
|
+
/* @__PURE__ */ r("circle", { cx: "9", cy: "9", r: "7.5", stroke: "currentColor", strokeWidth: "1.5" }),
|
|
21
|
+
/* @__PURE__ */ r("path", { d: "M6.5 6.5L11.5 11.5M11.5 6.5L6.5 11.5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })
|
|
22
|
+
] })
|
|
23
|
+
}, x = /* @__PURE__ */ new Set(["warning", "error"]), g = y(function({
|
|
24
|
+
intent: n = "info",
|
|
25
|
+
title: o,
|
|
26
|
+
icon: l,
|
|
27
|
+
showIcon: d = !0,
|
|
28
|
+
action: t,
|
|
29
|
+
isDismissible: i,
|
|
30
|
+
onDismiss: h,
|
|
31
|
+
dismissLabel: k = "Dismiss",
|
|
32
|
+
role: u,
|
|
33
|
+
className: p,
|
|
34
|
+
style: v,
|
|
35
|
+
testId: b,
|
|
36
|
+
children: s,
|
|
37
|
+
...f
|
|
38
|
+
}, m) {
|
|
39
|
+
const c = u ?? (x.has(n) ? "alert" : "status"), a = l ?? (n === "neutral" ? null : w[n]);
|
|
40
|
+
return /* @__PURE__ */ e(
|
|
41
|
+
"div",
|
|
42
|
+
{
|
|
43
|
+
ref: m,
|
|
44
|
+
role: c,
|
|
45
|
+
"aria-live": c === "alert" ? "assertive" : "polite",
|
|
46
|
+
className: L("brycks-banner", `brycks-banner--${n}`, p),
|
|
47
|
+
style: v,
|
|
48
|
+
"data-testid": b,
|
|
49
|
+
...f,
|
|
50
|
+
children: [
|
|
51
|
+
d && a && /* @__PURE__ */ r("span", { className: "brycks-banner__icon", children: a }),
|
|
52
|
+
/* @__PURE__ */ e("div", { className: "brycks-banner__content", children: [
|
|
53
|
+
o && /* @__PURE__ */ r("div", { className: "brycks-banner__title", children: o }),
|
|
54
|
+
s && /* @__PURE__ */ r("div", { className: "brycks-banner__description", children: s })
|
|
55
|
+
] }),
|
|
56
|
+
(t || i) && /* @__PURE__ */ e("div", { className: "brycks-banner__actions", children: [
|
|
57
|
+
t,
|
|
58
|
+
i && /* @__PURE__ */ r(
|
|
59
|
+
"button",
|
|
60
|
+
{
|
|
61
|
+
type: "button",
|
|
62
|
+
className: "brycks-banner__dismiss",
|
|
63
|
+
onClick: h,
|
|
64
|
+
"aria-label": k,
|
|
65
|
+
children: /* @__PURE__ */ r("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ r("path", { d: "M3 3L11 11M11 3L3 11", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }) })
|
|
66
|
+
}
|
|
67
|
+
)
|
|
68
|
+
] })
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
});
|
|
73
|
+
g.displayName = "Banner";
|
|
74
|
+
export {
|
|
75
|
+
g as Banner
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=Banner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Banner.js","sources":["../../../../src/components/feedback/Banner/Banner.tsx"],"sourcesContent":["/**\n * Banner Component\n *\n * App-level announcement bar for status, alerts, and notices.\n * Horizontal, full-width layout designed to sit at the top of a page or app shell.\n *\n * Unlike Alert (a contained, in-flow message), Banner spans the full width and\n * picks its ARIA role from the intent: critical intents (warning/error) announce\n * assertively as `alert`, informational intents (info/success/neutral) as `status`.\n *\n * All color styles are handled via CSS classes for easy customization.\n */\n\nimport React, {\n forwardRef,\n type ReactNode,\n type HTMLAttributes,\n} from 'react'\nimport { cx } from '../../../utils/styles'\n\nexport type BannerIntent = 'info' | 'success' | 'warning' | 'error' | 'neutral'\n\nexport interface BannerProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {\n /** Visual intent/status */\n intent?: BannerIntent\n /** Banner title (stronger weight, sits above the description) */\n title?: ReactNode\n /** Custom icon (overrides the default per-intent icon) */\n icon?: ReactNode\n /** Whether to show the leading icon */\n showIcon?: boolean\n /** Action element (button, link) shown on the trailing edge */\n action?: ReactNode\n /** Whether the banner can be dismissed */\n isDismissible?: boolean\n /** Callback when dismissed */\n onDismiss?: () => void\n /** Accessible label of the dismiss button */\n dismissLabel?: string\n /**\n * ARIA live-region role. Defaults to `alert` for warning/error and\n * `status` for info/success/neutral. Override when the default is wrong.\n */\n role?: 'alert' | 'status'\n /** Custom class name */\n className?: string\n /** Test ID */\n testId?: string\n /** Banner content (description) */\n children?: ReactNode\n}\n\nconst defaultIcons: Record<Exclude<BannerIntent, 'neutral'>, React.JSX.Element> = {\n info: (\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 18 18\" fill=\"none\" aria-hidden=\"true\">\n <circle cx=\"9\" cy=\"9\" r=\"7.5\" stroke=\"currentColor\" strokeWidth=\"1.5\" />\n <path d=\"M9 8V12\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" />\n <circle cx=\"9\" cy=\"5.5\" r=\"0.75\" fill=\"currentColor\" />\n </svg>\n ),\n success: (\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 18 18\" fill=\"none\" aria-hidden=\"true\">\n <circle cx=\"9\" cy=\"9\" r=\"7.5\" stroke=\"currentColor\" strokeWidth=\"1.5\" />\n <path d=\"M6 9L8 11L12 7\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n ),\n warning: (\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 18 18\" fill=\"none\" aria-hidden=\"true\">\n <path d=\"M9 2L16.5 15H1.5L9 2Z\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinejoin=\"round\" />\n <path d=\"M9 7V10\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" />\n <circle cx=\"9\" cy=\"12.5\" r=\"0.75\" fill=\"currentColor\" />\n </svg>\n ),\n error: (\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 18 18\" fill=\"none\" aria-hidden=\"true\">\n <circle cx=\"9\" cy=\"9\" r=\"7.5\" stroke=\"currentColor\" strokeWidth=\"1.5\" />\n <path d=\"M6.5 6.5L11.5 11.5M11.5 6.5L6.5 11.5\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" />\n </svg>\n ),\n}\n\nconst criticalIntents: ReadonlySet<BannerIntent> = new Set<BannerIntent>(['warning', 'error'])\n\nexport const Banner = forwardRef<HTMLDivElement, BannerProps>(function Banner(\n {\n intent = 'info',\n title,\n icon,\n showIcon = true,\n action,\n isDismissible,\n onDismiss,\n dismissLabel = 'Dismiss',\n role,\n className,\n style,\n testId,\n children,\n ...props\n },\n ref\n) {\n const resolvedRole = role ?? (criticalIntents.has(intent) ? 'alert' : 'status')\n const resolvedIcon = icon ?? (intent === 'neutral' ? null : defaultIcons[intent])\n\n return (\n <div\n ref={ref}\n role={resolvedRole}\n aria-live={resolvedRole === 'alert' ? 'assertive' : 'polite'}\n className={cx('brycks-banner', `brycks-banner--${intent}`, className)}\n style={style}\n data-testid={testId}\n {...props}\n >\n {showIcon && resolvedIcon && (\n <span className=\"brycks-banner__icon\">{resolvedIcon}</span>\n )}\n\n <div className=\"brycks-banner__content\">\n {title && <div className=\"brycks-banner__title\">{title}</div>}\n {children && <div className=\"brycks-banner__description\">{children}</div>}\n </div>\n\n {(action || isDismissible) && (\n <div className=\"brycks-banner__actions\">\n {action}\n {isDismissible && (\n <button\n type=\"button\"\n className=\"brycks-banner__dismiss\"\n onClick={onDismiss}\n aria-label={dismissLabel}\n >\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 14 14\" fill=\"none\" aria-hidden=\"true\">\n <path d=\"M3 3L11 11M11 3L3 11\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" />\n </svg>\n </button>\n )}\n </div>\n )}\n </div>\n )\n})\n\nBanner.displayName = 'Banner'\n"],"names":["defaultIcons","jsxs","jsx","criticalIntents","Banner","forwardRef","intent","title","icon","showIcon","action","isDismissible","onDismiss","dismissLabel","role","className","style","testId","children","props","ref","resolvedRole","resolvedIcon","cx"],"mappings":";;;AAoDA,MAAMA,IAA4E;AAAA,EAChF,MACE,gBAAAC,EAAC,OAAA,EAAI,OAAM,MAAK,QAAO,MAAK,SAAQ,aAAY,MAAK,QAAO,eAAY,QACtE,UAAA;AAAA,IAAA,gBAAAC,EAAC,UAAA,EAAO,IAAG,KAAI,IAAG,KAAI,GAAE,OAAM,QAAO,gBAAe,aAAY,MAAA,CAAM;AAAA,IACtE,gBAAAA,EAAC,UAAK,GAAE,WAAU,QAAO,gBAAe,aAAY,OAAM,eAAc,QAAA,CAAQ;AAAA,IAChF,gBAAAA,EAAC,YAAO,IAAG,KAAI,IAAG,OAAM,GAAE,QAAO,MAAK,eAAA,CAAe;AAAA,EAAA,GACvD;AAAA,EAEF,SACE,gBAAAD,EAAC,OAAA,EAAI,OAAM,MAAK,QAAO,MAAK,SAAQ,aAAY,MAAK,QAAO,eAAY,QACtE,UAAA;AAAA,IAAA,gBAAAC,EAAC,UAAA,EAAO,IAAG,KAAI,IAAG,KAAI,GAAE,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AEDE,EAAO,cAAc;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),p=require("react"),b=require("../Modal/Modal.cjs"),n=require("../../primitives/Button/Button.cjs"),x={margin:0,fontSize:"var(--brycks-fs-body-base)",lineHeight:1.5,color:"var(--brycks-foreground-default)"},h={display:"flex",justifyContent:"flex-end",gap:"var(--brycks-spacing-2, 8px)",marginTop:"var(--brycks-spacing-6, 24px)"},l=p.forwardRef(function({isOpen:t,onClose:i,onConfirm:a,title:c,message:o,confirmLabel:f="Confirm",cancelLabel:d="Cancel",closeLabel:u="Close",variant:y="default",isLoading:e=!1,testId:m,children:C},g){const s=()=>{e||i()};return r.jsxs(b.Modal,{ref:g,isOpen:t,onClose:s,title:c,size:"sm",closeLabel:u,closeOnOverlayClick:!e,closeOnEscape:!e,testId:m,children:[o&&r.jsx("p",{style:x,children:o}),C,r.jsxs("div",{style:h,className:"brycks-confirm-dialog__footer",children:[r.jsx(n.Button,{size:"sm",variant:"ghost",onClick:s,isDisabled:e,children:d}),r.jsx(n.Button,{size:"sm",intent:y==="danger"?"error":"primary",onClick:a,isLoading:e,children:f})]})]})});l.displayName="ConfirmDialog";exports.ConfirmDialog=l;
|
|
2
|
+
//# sourceMappingURL=ConfirmDialog.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfirmDialog.cjs","sources":["../../../../src/components/feedback/ConfirmDialog/ConfirmDialog.tsx"],"sourcesContent":["/**\n * ConfirmDialog Component\n *\n * A small confirmation dialog built on top of Modal. Asks the user to confirm\n * or cancel an action, with an optional destructive (`danger`) styling and a\n * loading state for async confirmations.\n *\n * The component is i18n-agnostic: button labels default to English and should be\n * passed in by the consuming app when localization is needed.\n */\n\nimport {\n forwardRef,\n type ReactNode,\n type CSSProperties,\n} from 'react'\nimport { Modal } from '../Modal'\nimport { Button } from '../../primitives/Button'\n\nexport type ConfirmDialogVariant = 'default' | 'danger'\n\nexport interface ConfirmDialogProps {\n /** Whether the dialog is open */\n isOpen: boolean\n /** Callback when the dialog should close (cancel / overlay / escape) */\n onClose: () => void\n /** Callback when the user confirms */\n onConfirm: () => void\n /** Dialog title */\n title: ReactNode\n /** Body message (use `children` for richer content) */\n message?: ReactNode\n /** Label of the confirm button */\n confirmLabel?: string\n /** Label of the cancel button */\n cancelLabel?: string\n /** Accessible label of the modal close button */\n closeLabel?: string\n /** Visual variant — `danger` for destructive actions */\n variant?: ConfirmDialogVariant\n /** Whether the confirm action is in progress (disables cancel, spins confirm) */\n isLoading?: boolean\n /** Test ID */\n testId?: string\n /** Richer body content (rendered below `message`) */\n children?: ReactNode\n}\n\nconst messageStyle: CSSProperties = {\n margin: 0,\n fontSize: 'var(--brycks-fs-body-base)',\n lineHeight: 1.5,\n color: 'var(--brycks-foreground-default)',\n}\n\nconst footerStyle: CSSProperties = {\n display: 'flex',\n justifyContent: 'flex-end',\n gap: 'var(--brycks-spacing-2, 8px)',\n marginTop: 'var(--brycks-spacing-6, 24px)',\n}\n\nexport const ConfirmDialog = forwardRef<HTMLDivElement, ConfirmDialogProps>(function ConfirmDialog(\n {\n isOpen,\n onClose,\n onConfirm,\n title,\n message,\n confirmLabel = 'Confirm',\n cancelLabel = 'Cancel',\n closeLabel = 'Close',\n variant = 'default',\n isLoading = false,\n testId,\n children,\n },\n ref\n) {\n // Block close while the async confirm is running.\n const handleClose = () => {\n if (!isLoading) onClose()\n }\n\n return (\n <Modal\n ref={ref}\n isOpen={isOpen}\n onClose={handleClose}\n title={title}\n size=\"sm\"\n closeLabel={closeLabel}\n closeOnOverlayClick={!isLoading}\n closeOnEscape={!isLoading}\n testId={testId}\n >\n {message && <p style={messageStyle}>{message}</p>}\n {children}\n <div style={footerStyle} className=\"brycks-confirm-dialog__footer\">\n <Button size=\"sm\" variant=\"ghost\" onClick={handleClose} isDisabled={isLoading}>\n {cancelLabel}\n </Button>\n <Button\n size=\"sm\"\n intent={variant === 'danger' ? 'error' : 'primary'}\n onClick={onConfirm}\n isLoading={isLoading}\n >\n {confirmLabel}\n </Button>\n </div>\n </Modal>\n )\n})\n\nConfirmDialog.displayName = 'ConfirmDialog'\n"],"names":["messageStyle","footerStyle","ConfirmDialog","forwardRef","isOpen","onClose","onConfirm","title","message","confirmLabel","cancelLabel","closeLabel","variant","isLoading","testId","children","ref","handleClose","jsxs","Modal","jsx","Button"],"mappings":"wNAgDMA,EAA8B,CAClC,OAAQ,EACR,SAAU,6BACV,WAAY,IACZ,MAAO,kCACT,EAEMC,EAA6B,CACjC,QAAS,OACT,eAAgB,WAChB,IAAK,+BACL,UAAW,+BACb,EAEaC,EAAgBC,EAAAA,WAA+C,SAC1E,CACE,OAAAC,EACA,QAAAC,EACA,UAAAC,EACA,MAAAC,EACA,QAAAC,EACA,aAAAC,EAAe,UACf,YAAAC,EAAc,SACd,WAAAC,EAAa,QACb,QAAAC,EAAU,UACV,UAAAC,EAAY,GACZ,OAAAC,EACA,SAAAC,CACF,EACAC,EACA,CAEA,MAAMC,EAAc,IAAM,CACnBJ,GAAWR,EAAA,CAClB,EAEA,OACEa,EAAAA,KAACC,EAAAA,MAAA,CACC,IAAAH,EACA,OAAAZ,EACA,QAASa,EACT,MAAAV,EACA,KAAK,KACL,WAAAI,EACA,oBAAqB,CAACE,EACtB,cAAe,CAACA,EAChB,OAAAC,EAEC,SAAA,CAAAN,GAAWY,EAAAA,IAAC,IAAA,CAAE,MAAOpB,EAAe,SAAAQ,EAAQ,EAC5CO,EACDG,EAAAA,KAAC,MAAA,CAAI,MAAOjB,EAAa,UAAU,gCACjC,SAAA,CAAAmB,EAAAA,IAACC,EAAAA,OAAA,CAAO,KAAK,KAAK,QAAQ,QAAQ,QAASJ,EAAa,WAAYJ,EACjE,SAAAH,CAAA,CACH,EACAU,EAAAA,IAACC,EAAAA,OAAA,CACC,KAAK,KACL,OAAQT,IAAY,SAAW,QAAU,UACzC,QAASN,EACT,UAAAO,EAEC,SAAAJ,CAAA,CAAA,CACH,CAAA,CACF,CAAA,CAAA,CAAA,CAGN,CAAC,EAEDP,EAAc,YAAc"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { jsxs as n, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as b } from "react";
|
|
3
|
+
import { Modal as h } from "../Modal/Modal.js";
|
|
4
|
+
import { Button as s } from "../../primitives/Button/Button.js";
|
|
5
|
+
const k = {
|
|
6
|
+
margin: 0,
|
|
7
|
+
fontSize: "var(--brycks-fs-body-base)",
|
|
8
|
+
lineHeight: 1.5,
|
|
9
|
+
color: "var(--brycks-foreground-default)"
|
|
10
|
+
}, u = {
|
|
11
|
+
display: "flex",
|
|
12
|
+
justifyContent: "flex-end",
|
|
13
|
+
gap: "var(--brycks-spacing-2, 8px)",
|
|
14
|
+
marginTop: "var(--brycks-spacing-6, 24px)"
|
|
15
|
+
}, v = b(function({
|
|
16
|
+
isOpen: i,
|
|
17
|
+
onClose: t,
|
|
18
|
+
onConfirm: a,
|
|
19
|
+
title: c,
|
|
20
|
+
message: o,
|
|
21
|
+
confirmLabel: f = "Confirm",
|
|
22
|
+
cancelLabel: m = "Cancel",
|
|
23
|
+
closeLabel: p = "Close",
|
|
24
|
+
variant: d = "default",
|
|
25
|
+
isLoading: r = !1,
|
|
26
|
+
testId: y,
|
|
27
|
+
children: C
|
|
28
|
+
}, g) {
|
|
29
|
+
const l = () => {
|
|
30
|
+
r || t();
|
|
31
|
+
};
|
|
32
|
+
return /* @__PURE__ */ n(
|
|
33
|
+
h,
|
|
34
|
+
{
|
|
35
|
+
ref: g,
|
|
36
|
+
isOpen: i,
|
|
37
|
+
onClose: l,
|
|
38
|
+
title: c,
|
|
39
|
+
size: "sm",
|
|
40
|
+
closeLabel: p,
|
|
41
|
+
closeOnOverlayClick: !r,
|
|
42
|
+
closeOnEscape: !r,
|
|
43
|
+
testId: y,
|
|
44
|
+
children: [
|
|
45
|
+
o && /* @__PURE__ */ e("p", { style: k, children: o }),
|
|
46
|
+
C,
|
|
47
|
+
/* @__PURE__ */ n("div", { style: u, className: "brycks-confirm-dialog__footer", children: [
|
|
48
|
+
/* @__PURE__ */ e(s, { size: "sm", variant: "ghost", onClick: l, isDisabled: r, children: m }),
|
|
49
|
+
/* @__PURE__ */ e(
|
|
50
|
+
s,
|
|
51
|
+
{
|
|
52
|
+
size: "sm",
|
|
53
|
+
intent: d === "danger" ? "error" : "primary",
|
|
54
|
+
onClick: a,
|
|
55
|
+
isLoading: r,
|
|
56
|
+
children: f
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
] })
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
});
|
|
64
|
+
v.displayName = "ConfirmDialog";
|
|
65
|
+
export {
|
|
66
|
+
v as ConfirmDialog
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=ConfirmDialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfirmDialog.js","sources":["../../../../src/components/feedback/ConfirmDialog/ConfirmDialog.tsx"],"sourcesContent":["/**\n * ConfirmDialog Component\n *\n * A small confirmation dialog built on top of Modal. Asks the user to confirm\n * or cancel an action, with an optional destructive (`danger`) styling and a\n * loading state for async confirmations.\n *\n * The component is i18n-agnostic: button labels default to English and should be\n * passed in by the consuming app when localization is needed.\n */\n\nimport {\n forwardRef,\n type ReactNode,\n type CSSProperties,\n} from 'react'\nimport { Modal } from '../Modal'\nimport { Button } from '../../primitives/Button'\n\nexport type ConfirmDialogVariant = 'default' | 'danger'\n\nexport interface ConfirmDialogProps {\n /** Whether the dialog is open */\n isOpen: boolean\n /** Callback when the dialog should close (cancel / overlay / escape) */\n onClose: () => void\n /** Callback when the user confirms */\n onConfirm: () => void\n /** Dialog title */\n title: ReactNode\n /** Body message (use `children` for richer content) */\n message?: ReactNode\n /** Label of the confirm button */\n confirmLabel?: string\n /** Label of the cancel button */\n cancelLabel?: string\n /** Accessible label of the modal close button */\n closeLabel?: string\n /** Visual variant — `danger` for destructive actions */\n variant?: ConfirmDialogVariant\n /** Whether the confirm action is in progress (disables cancel, spins confirm) */\n isLoading?: boolean\n /** Test ID */\n testId?: string\n /** Richer body content (rendered below `message`) */\n children?: ReactNode\n}\n\nconst messageStyle: CSSProperties = {\n margin: 0,\n fontSize: 'var(--brycks-fs-body-base)',\n lineHeight: 1.5,\n color: 'var(--brycks-foreground-default)',\n}\n\nconst footerStyle: CSSProperties = {\n display: 'flex',\n justifyContent: 'flex-end',\n gap: 'var(--brycks-spacing-2, 8px)',\n marginTop: 'var(--brycks-spacing-6, 24px)',\n}\n\nexport const ConfirmDialog = forwardRef<HTMLDivElement, ConfirmDialogProps>(function ConfirmDialog(\n {\n isOpen,\n onClose,\n onConfirm,\n title,\n message,\n confirmLabel = 'Confirm',\n cancelLabel = 'Cancel',\n closeLabel = 'Close',\n variant = 'default',\n isLoading = false,\n testId,\n children,\n },\n ref\n) {\n // Block close while the async confirm is running.\n const handleClose = () => {\n if (!isLoading) onClose()\n }\n\n return (\n <Modal\n ref={ref}\n isOpen={isOpen}\n onClose={handleClose}\n title={title}\n size=\"sm\"\n closeLabel={closeLabel}\n closeOnOverlayClick={!isLoading}\n closeOnEscape={!isLoading}\n testId={testId}\n >\n {message && <p style={messageStyle}>{message}</p>}\n {children}\n <div style={footerStyle} className=\"brycks-confirm-dialog__footer\">\n <Button size=\"sm\" variant=\"ghost\" onClick={handleClose} isDisabled={isLoading}>\n {cancelLabel}\n </Button>\n <Button\n size=\"sm\"\n intent={variant === 'danger' ? 'error' : 'primary'}\n onClick={onConfirm}\n isLoading={isLoading}\n >\n {confirmLabel}\n </Button>\n </div>\n </Modal>\n )\n})\n\nConfirmDialog.displayName = 'ConfirmDialog'\n"],"names":["messageStyle","footerStyle","ConfirmDialog","forwardRef","isOpen","onClose","onConfirm","title","message","confirmLabel","cancelLabel","closeLabel","variant","isLoading","testId","children","ref","handleClose","jsxs","Modal","jsx","Button"],"m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AAA,UAAA;AAAA,QACH,EAAA,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN,CAAC;AAEDP,EAAc,cAAc;"}
|
|
@@ -1,23 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),t=require("react"),
|
|
2
|
-
@keyframes brycks-drawer-overlay-in {
|
|
3
|
-
from { opacity: 0; }
|
|
4
|
-
to { opacity: 1; }
|
|
5
|
-
}
|
|
6
|
-
@keyframes brycks-drawer-left-in {
|
|
7
|
-
from { transform: translateX(-100%); }
|
|
8
|
-
to { transform: translateX(0); }
|
|
9
|
-
}
|
|
10
|
-
@keyframes brycks-drawer-right-in {
|
|
11
|
-
from { transform: translateX(100%); }
|
|
12
|
-
to { transform: translateX(0); }
|
|
13
|
-
}
|
|
14
|
-
@keyframes brycks-drawer-top-in {
|
|
15
|
-
from { transform: translateY(-100%); }
|
|
16
|
-
to { transform: translateY(0); }
|
|
17
|
-
}
|
|
18
|
-
@keyframes brycks-drawer-bottom-in {
|
|
19
|
-
from { transform: translateY(100%); }
|
|
20
|
-
to { transform: translateY(0); }
|
|
21
|
-
}
|
|
22
|
-
`}),r.jsx("div",{className:"brycks-drawer-overlay",style:z,onClick:T,children:r.jsxs("div",{ref:e=>{d.current=e,typeof l=="function"?l(e):l&&(l.current=e)},role:"dialog","aria-modal":"true","aria-labelledby":c?m:void 0,className:W.cx("brycks-drawer",`brycks-drawer--${o}`,`brycks-drawer--${u}`,E),style:M,tabIndex:-1,"data-testid":C,...I,children:[(c||b)&&r.jsxs("div",{className:"brycks-drawer-header",style:N,children:[c&&r.jsx("h2",{id:m,style:L,children:c}),b&&r.jsx("button",{type:"button",className:"brycks-drawer-close",style:P,onClick:n,"aria-label":j,onMouseEnter:e=>{e.currentTarget.style.backgroundColor="var(--brycks-background-muted)",e.currentTarget.style.color="var(--brycks-foreground-default)"},onMouseLeave:e=>{e.currentTarget.style.backgroundColor="transparent",e.currentTarget.style.color="var(--brycks-foreground-muted)"},children:r.jsx(B,{})})]}),r.jsx("div",{className:"brycks-drawer-content",style:X,children:R})]})})]});return K.createPortal(Y,document.body)});p.displayName="Drawer";exports.Drawer=p;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),t=require("react"),M=require("react-dom"),k=require("../../../utils/styles.cjs"),S=require("../../../hooks/useId.cjs");function T(){return r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:r.jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}const x=t.forwardRef(function({isOpen:a,onClose:n,placement:E="right",size:j="md",title:s,closeOnOverlayClick:l=!0,closeOnEscape:i=!0,showCloseButton:f=!0,closeLabel:g="Close drawer",showOverlay:D=!0,className:R,style:p,children:N,testId:q,...I},d){const o=t.useRef(null),b=S.useId("drawer-title"),y=t.useRef(null),m=t.useRef(n);t.useEffect(()=>{m.current=n},[n]),t.useEffect(()=>{if(!a)return;y.current=document.activeElement;const e=o.current;e&&e.focus()},[a]),t.useEffect(()=>{if(!a)return;const e=o.current,w=c=>{if(c.key==="Escape"&&i){m.current();return}if(c.key==="Tab"&&e){const u=e.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [contenteditable="true"], [tabindex]:not([tabindex="-1"])'),v=u[0],h=u[u.length-1];c.shiftKey&&document.activeElement===v?(c.preventDefault(),h?.focus()):!c.shiftKey&&document.activeElement===h&&(c.preventDefault(),v?.focus())}};return document.addEventListener("keydown",w),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",w),document.body.style.overflow="",y.current?.focus()}},[a,i]);const K=t.useCallback(e=>{e.target===e.currentTarget&&l&&n()},[l,n]);if(!a)return null;const L=r.jsx("div",{className:k.cx("brycks-drawer-overlay",!D&&"brycks-drawer-overlay--transparent"),onClick:K,children:r.jsxs("div",{ref:e=>{o.current=e,typeof d=="function"?d(e):d&&(d.current=e)},role:"dialog","aria-modal":"true","aria-labelledby":s?b:void 0,className:k.cx("brycks-drawer",`brycks-drawer--${E}`,`brycks-drawer--${j}`,R),style:p,tabIndex:-1,"data-testid":q,...I,children:[(s||f)&&r.jsxs("div",{className:"brycks-drawer-header",children:[s&&r.jsx("h2",{id:b,className:"brycks-drawer-title",children:s}),f&&r.jsx("button",{type:"button",className:"brycks-drawer-close",onClick:n,"aria-label":g,children:r.jsx(T,{})})]}),r.jsx("div",{className:"brycks-drawer-content",children:N})]})});return M.createPortal(L,document.body)});x.displayName="Drawer";exports.Drawer=x;
|
|
23
2
|
//# sourceMappingURL=Drawer.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.cjs","sources":["../../../../src/components/feedback/Drawer/Drawer.tsx"],"sourcesContent":["/**\n * Drawer Component\n *\n * A slide-out panel that can appear from any edge of the screen.\n * Supports focus trapping and keyboard navigation.\n */\n\nimport {\n forwardRef,\n useEffect,\n useRef,\n useCallback,\n type CSSProperties,\n type ReactNode,\n type HTMLAttributes,\n} from 'react'\nimport { createPortal } from 'react-dom'\nimport { cx } from '../../../utils/styles'\nimport { useId } from '../../../hooks/useId'\n\nexport type DrawerPlacement = 'left' | 'right' | 'top' | 'bottom'\nexport type DrawerSize = 'sm' | 'md' | 'lg' | 'xl' | 'full'\n\nexport interface DrawerProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {\n /** Whether the drawer is open */\n isOpen: boolean\n /** Callback when drawer should close */\n onClose: () => void\n /** Drawer placement */\n placement?: DrawerPlacement\n /** Drawer size */\n size?: DrawerSize\n /** Drawer title */\n title?: ReactNode\n /** Whether to close on overlay click */\n closeOnOverlayClick?: boolean\n /** Whether to close on escape key */\n closeOnEscape?: boolean\n /** Whether to show close button */\n showCloseButton?: boolean\n /** Accessible label of the close button */\n closeLabel?: string\n /** Whether to show overlay */\n showOverlay?: boolean\n /** Custom class name */\n className?: string\n /** Test ID */\n testId?: string\n}\n\nconst sizeMap: Record<DrawerSize, string> = {\n sm: '320px',\n md: '400px',\n lg: '560px',\n xl: '720px',\n full: '100%',\n}\n\nfunction CloseIcon() {\n return (\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" aria-hidden=\"true\">\n <path d=\"M4 4l8 8M12 4l-8 8\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" />\n </svg>\n )\n}\n\nexport const Drawer = forwardRef<HTMLDivElement, DrawerProps>(function Drawer(\n {\n isOpen,\n onClose,\n placement = 'right',\n size = 'md',\n title,\n closeOnOverlayClick = true,\n closeOnEscape = true,\n showCloseButton = true,\n closeLabel = 'Close drawer',\n showOverlay = true,\n className,\n style,\n children,\n testId,\n ...props\n },\n ref\n) {\n const drawerRef = useRef<HTMLDivElement>(null)\n const titleId = useId('drawer-title')\n const previousActiveElement = useRef<HTMLElement | null>(null)\n\n // Store onClose in a ref to avoid re-running effects when it changes\n const onCloseRef = useRef(onClose)\n useEffect(() => {\n onCloseRef.current = onClose\n }, [onClose])\n\n // Focus drawer when it opens (only once)\n useEffect(() => {\n if (!isOpen) return\n\n previousActiveElement.current = document.activeElement as HTMLElement\n const drawer = drawerRef.current\n if (drawer) {\n drawer.focus()\n }\n }, [isOpen])\n\n // Keyboard handling and body scroll lock\n useEffect(() => {\n if (!isOpen) return\n\n const drawer = drawerRef.current\n\n const handleKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'Escape' && closeOnEscape) {\n onCloseRef.current()\n return\n }\n\n if (e.key === 'Tab' && drawer) {\n const focusableElements = drawer.querySelectorAll<HTMLElement>(\n 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [contenteditable=\"true\"], [tabindex]:not([tabindex=\"-1\"])'\n )\n const firstElement = focusableElements[0]\n const lastElement = focusableElements[focusableElements.length - 1]\n\n if (e.shiftKey && document.activeElement === firstElement) {\n e.preventDefault()\n lastElement?.focus()\n } else if (!e.shiftKey && document.activeElement === lastElement) {\n e.preventDefault()\n firstElement?.focus()\n }\n }\n }\n\n document.addEventListener('keydown', handleKeyDown)\n document.body.style.overflow = 'hidden'\n\n return () => {\n document.removeEventListener('keydown', handleKeyDown)\n document.body.style.overflow = ''\n previousActiveElement.current?.focus()\n }\n }, [isOpen, closeOnEscape])\n\n const handleOverlayClick = useCallback(\n (e: React.MouseEvent) => {\n if (e.target === e.currentTarget && closeOnOverlayClick) {\n onClose()\n }\n },\n [closeOnOverlayClick, onClose]\n )\n\n if (!isOpen) return null\n\n const isHorizontal = placement === 'left' || placement === 'right'\n const drawerSize = sizeMap[size]\n\n const overlayStyle: CSSProperties = {\n position: 'fixed',\n inset: 0,\n zIndex: 'var(--brycks-z-drawer)' as unknown as number,\n display: 'flex',\n backgroundColor: showOverlay ? 'var(--brycks-background-overlay)' : 'transparent',\n animation: 'brycks-drawer-overlay-in 200ms ease-out',\n }\n\n const getPositionStyles = (): CSSProperties => {\n const base: CSSProperties = {\n position: 'absolute',\n backgroundColor: 'var(--brycks-background-elevated)',\n boxShadow: 'var(--brycks-shadow-2xl)',\n display: 'flex',\n flexDirection: 'column',\n overflow: 'hidden',\n }\n\n if (isHorizontal) {\n return {\n ...base,\n top: 0,\n bottom: 0,\n [placement]: 0,\n width: drawerSize,\n maxWidth: '100vw',\n }\n }\n\n return {\n ...base,\n left: 0,\n right: 0,\n [placement]: 0,\n height: drawerSize,\n maxHeight: '100vh',\n }\n }\n\n const drawerStyle: CSSProperties = {\n ...getPositionStyles(),\n animation: `brycks-drawer-${placement}-in 250ms cubic-bezier(0.32, 0.72, 0, 1)`,\n outline: 'none',\n ...style,\n }\n\n const headerStyle: CSSProperties = {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n padding: '16px 20px',\n borderBottom: '1px solid var(--brycks-border-muted)',\n flexShrink: 0,\n }\n\n const titleStyle: CSSProperties = {\n fontSize: 18,\n fontWeight: 600,\n color: 'var(--brycks-foreground-default)',\n margin: 0,\n }\n\n const closeButtonStyle: CSSProperties = {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n width: 32,\n height: 32,\n borderRadius: 'var(--brycks-radius-md)',\n color: 'var(--brycks-foreground-muted)',\n transition: 'all 150ms ease-out',\n }\n\n const contentStyle: CSSProperties = {\n flex: 1,\n overflow: 'auto',\n padding: 20,\n }\n\n const drawerContent = (\n <>\n <style>\n {`\n @keyframes brycks-drawer-overlay-in {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n @keyframes brycks-drawer-left-in {\n from { transform: translateX(-100%); }\n to { transform: translateX(0); }\n }\n @keyframes brycks-drawer-right-in {\n from { transform: translateX(100%); }\n to { transform: translateX(0); }\n }\n @keyframes brycks-drawer-top-in {\n from { transform: translateY(-100%); }\n to { transform: translateY(0); }\n }\n @keyframes brycks-drawer-bottom-in {\n from { transform: translateY(100%); }\n to { transform: translateY(0); }\n }\n `}\n </style>\n <div\n className=\"brycks-drawer-overlay\"\n style={overlayStyle}\n onClick={handleOverlayClick}\n >\n <div\n ref={(node) => {\n (drawerRef as React.MutableRefObject<HTMLDivElement | null>).current = node\n if (typeof ref === 'function') ref(node)\n else if (ref) ref.current = node\n }}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby={title ? titleId : undefined}\n className={cx('brycks-drawer', `brycks-drawer--${placement}`, `brycks-drawer--${size}`, className)}\n style={drawerStyle}\n tabIndex={-1}\n data-testid={testId}\n {...props}\n >\n {(title || showCloseButton) && (\n <div className=\"brycks-drawer-header\" style={headerStyle}>\n {title && <h2 id={titleId} style={titleStyle}>{title}</h2>}\n {showCloseButton && (\n <button\n type=\"button\"\n className=\"brycks-drawer-close\"\n style={closeButtonStyle}\n onClick={onClose}\n aria-label={closeLabel}\n onMouseEnter={(e) => {\n e.currentTarget.style.backgroundColor = 'var(--brycks-background-muted)'\n e.currentTarget.style.color = 'var(--brycks-foreground-default)'\n }}\n onMouseLeave={(e) => {\n e.currentTarget.style.backgroundColor = 'transparent'\n e.currentTarget.style.color = 'var(--brycks-foreground-muted)'\n }}\n >\n <CloseIcon />\n </button>\n )}\n </div>\n )}\n <div className=\"brycks-drawer-content\" style={contentStyle}>\n {children}\n </div>\n </div>\n </div>\n </>\n )\n\n return createPortal(drawerContent, document.body)\n})\n\nDrawer.displayName = 'Drawer'\n"],"names":["sizeMap","CloseIcon","jsx","Drawer","forwardRef","isOpen","onClose","placement","size","title","closeOnOverlayClick","closeOnEscape","showCloseButton","closeLabel","showOverlay","className","style","children","testId","props","ref","drawerRef","useRef","titleId","useId","previousActiveElement","onCloseRef","useEffect","drawer","handleKeyDown","e","focusableElements","firstElement","lastElement","handleOverlayClick","useCallback","isHorizontal","drawerSize","overlayStyle","drawerStyle","base","headerStyle","titleStyle","closeButtonStyle","contentStyle","drawerContent","jsxs","Fragment","node","cx","createPortal"],"mappings":"4OAkDMA,EAAsC,CAC1C,GAAI,QACJ,GAAI,QACJ,GAAI,QACJ,GAAI,QACJ,KAAM,MACR,EAEA,SAASC,GAAY,CACnB,OACEC,MAAC,OAAI,MAAM,KAAK,OAAO,KAAK,QAAQ,YAAY,KAAK,OAAO,cAAY,OACtE,SAAAA,EAAAA,IAAC,OAAA,CAAK,EAAE,qBAAqB,OAAO,eAAe,YAAY,MAAM,cAAc,OAAA,CAAQ,CAAA,CAC7F,CAEJ,CAEO,MAAMC,EAASC,EAAAA,WAAwC,SAC5D,CACE,OAAAC,EACA,QAAAC,EACA,UAAAC,EAAY,QACZ,KAAAC,EAAO,KACP,MAAAC,EACA,oBAAAC,EAAsB,GACtB,cAAAC,EAAgB,GAChB,gBAAAC,EAAkB,GAClB,WAAAC,EAAa,eACb,YAAAC,EAAc,GACd,UAAAC,EACA,MAAAC,EACA,SAAAC,EACA,OAAAC,EACA,GAAGC,CACL,EACAC,EACA,CACA,MAAMC,EAAYC,EAAAA,OAAuB,IAAI,EACvCC,EAAUC,EAAAA,MAAM,cAAc,EAC9BC,EAAwBH,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,GAAQ,WAAYA,EAAI4B,CAAI,EAC9B5B,MAAS,QAAU4B,EAC9B,EACA,KAAK,SACL,aAAW,OACX,kBAAiBvC,EAAQc,EAAU,OACnC,UAAW0B,EAAAA,GAAG,gBAAiB,kBAAkB1C,CAAS,GAAI,kBAAkBC,CAAI,GAAIO,CAAS,EACjG,MAAOwB,EACP,SAAU,GACV,cAAarB,EACZ,GAAGC,EAEF,SAAA,EAAAV,GAASG,IACTkC,EAAAA,KAAC,MAAA,CAAI,UAAU,uBAAuB,MAAOL,EAC1C,SAAA,CAAAhC,SAAU,KAAA,CAAG,GAAIc,EAAS,MAAOmB,EAAa,SAAAjC,EAAM,EACpDG,GACCV,EAAAA,IAAC,SAAA,CACC,KAAK,SACL,UAAU,sBACV,MAAOyC,EACP,QAASrC,EACT,aAAYO,EACZ,aAAe,GAAM,CACnB,EAAE,cAAc,MAAM,gBAAkB,iCACxC,EAAE,cAAc,MAAM,MAAQ,kCAChC,EACA,aAAe,GAAM,CACnB,EAAE,cAAc,MAAM,gBAAkB,cACxC,EAAE,cAAc,MAAM,MAAQ,gCAChC,EAEA,eAACZ,EAAA,CAAA,CAAU,CAAA,CAAA,CACb,EAEJ,QAED,MAAA,CAAI,UAAU,wBAAwB,MAAO2C,EAC3C,SAAA3B,CAAA,CACH,CAAA,CAAA,CAAA,CACF,CAAA,CACF,EACF,EAGF,OAAOiC,eAAaL,EAAe,SAAS,IAAI,CAClD,CAAC,EAED1C,EAAO,YAAc"}
|
|
1
|
+
{"version":3,"file":"Drawer.cjs","sources":["../../../../src/components/feedback/Drawer/Drawer.tsx"],"sourcesContent":["/**\n * Drawer Component\n *\n * A slide-out panel that can appear from any edge of the screen.\n * Supports focus trapping and keyboard navigation.\n */\n\nimport {\n forwardRef,\n useEffect,\n useRef,\n useCallback,\n type ReactNode,\n type HTMLAttributes,\n} from 'react'\nimport { createPortal } from 'react-dom'\nimport { cx } from '../../../utils/styles'\nimport { useId } from '../../../hooks/useId'\n\nexport type DrawerPlacement = 'left' | 'right' | 'top' | 'bottom'\nexport type DrawerSize = 'sm' | 'md' | 'lg' | 'xl' | 'full'\n\nexport interface DrawerProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {\n /** Whether the drawer is open */\n isOpen: boolean\n /** Callback when drawer should close */\n onClose: () => void\n /** Drawer placement */\n placement?: DrawerPlacement\n /** Drawer size */\n size?: DrawerSize\n /** Drawer title */\n title?: ReactNode\n /** Whether to close on overlay click */\n closeOnOverlayClick?: boolean\n /** Whether to close on escape key */\n closeOnEscape?: boolean\n /** Whether to show close button */\n showCloseButton?: boolean\n /** Accessible label of the close button */\n closeLabel?: string\n /** Whether to show overlay */\n showOverlay?: boolean\n /** Custom class name */\n className?: string\n /** Test ID */\n testId?: string\n}\n\nfunction CloseIcon() {\n return (\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" aria-hidden=\"true\">\n <path d=\"M4 4l8 8M12 4l-8 8\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" />\n </svg>\n )\n}\n\nexport const Drawer = forwardRef<HTMLDivElement, DrawerProps>(function Drawer(\n {\n isOpen,\n onClose,\n placement = 'right',\n size = 'md',\n title,\n closeOnOverlayClick = true,\n closeOnEscape = true,\n showCloseButton = true,\n closeLabel = 'Close drawer',\n showOverlay = true,\n className,\n style,\n children,\n testId,\n ...props\n },\n ref\n) {\n const drawerRef = useRef<HTMLDivElement>(null)\n const titleId = useId('drawer-title')\n const previousActiveElement = useRef<HTMLElement | null>(null)\n\n // Store onClose in a ref to avoid re-running effects when it changes\n const onCloseRef = useRef(onClose)\n useEffect(() => {\n onCloseRef.current = onClose\n }, [onClose])\n\n // Focus drawer when it opens (only once)\n useEffect(() => {\n if (!isOpen) return\n\n previousActiveElement.current = document.activeElement as HTMLElement\n const drawer = drawerRef.current\n if (drawer) {\n drawer.focus()\n }\n }, [isOpen])\n\n // Keyboard handling and body scroll lock\n useEffect(() => {\n if (!isOpen) return\n\n const drawer = drawerRef.current\n\n const handleKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'Escape' && closeOnEscape) {\n onCloseRef.current()\n return\n }\n\n if (e.key === 'Tab' && drawer) {\n const focusableElements = drawer.querySelectorAll<HTMLElement>(\n 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [contenteditable=\"true\"], [tabindex]:not([tabindex=\"-1\"])'\n )\n const firstElement = focusableElements[0]\n const lastElement = focusableElements[focusableElements.length - 1]\n\n if (e.shiftKey && document.activeElement === firstElement) {\n e.preventDefault()\n lastElement?.focus()\n } else if (!e.shiftKey && document.activeElement === lastElement) {\n e.preventDefault()\n firstElement?.focus()\n }\n }\n }\n\n document.addEventListener('keydown', handleKeyDown)\n document.body.style.overflow = 'hidden'\n\n return () => {\n document.removeEventListener('keydown', handleKeyDown)\n document.body.style.overflow = ''\n previousActiveElement.current?.focus()\n }\n }, [isOpen, closeOnEscape])\n\n const handleOverlayClick = useCallback(\n (e: React.MouseEvent) => {\n if (e.target === e.currentTarget && closeOnOverlayClick) {\n onClose()\n }\n },\n [closeOnOverlayClick, onClose]\n )\n\n if (!isOpen) return null\n\n const drawerContent = (\n <div\n className={cx('brycks-drawer-overlay', !showOverlay && 'brycks-drawer-overlay--transparent')}\n onClick={handleOverlayClick}\n >\n <div\n ref={(node) => {\n (drawerRef as React.MutableRefObject<HTMLDivElement | null>).current = node\n if (typeof ref === 'function') ref(node)\n else if (ref) ref.current = node\n }}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby={title ? titleId : undefined}\n className={cx('brycks-drawer', `brycks-drawer--${placement}`, `brycks-drawer--${size}`, className)}\n style={style}\n tabIndex={-1}\n data-testid={testId}\n {...props}\n >\n {(title || showCloseButton) && (\n <div className=\"brycks-drawer-header\">\n {title && <h2 id={titleId} className=\"brycks-drawer-title\">{title}</h2>}\n {showCloseButton && (\n <button\n type=\"button\"\n className=\"brycks-drawer-close\"\n onClick={onClose}\n aria-label={closeLabel}\n >\n <CloseIcon />\n </button>\n )}\n </div>\n )}\n <div className=\"brycks-drawer-content\">\n {children}\n </div>\n </div>\n </div>\n )\n\n return createPortal(drawerContent, document.body)\n})\n\nDrawer.displayName = 'Drawer'\n"],"names":["CloseIcon","jsx","Drawer","forwardRef","isOpen","onClose","placement","size","title","closeOnOverlayClick","closeOnEscape","showCloseButton","closeLabel","showOverlay","className","style","children","testId","props","ref","drawerRef","useRef","titleId","useId","previousActiveElement","onCloseRef","useEffect","drawer","handleKeyDown","e","focusableElements","firstElement","lastElement","handleOverlayClick","useCallback","drawerContent","cx","jsxs","node","createPortal"],"mappings":"4OAiDA,SAASA,GAAY,CACnB,OACEC,MAAC,OAAI,MAAM,KAAK,OAAO,KAAK,QAAQ,YAAY,KAAK,OAAO,cAAY,OACtE,SAAAA,EAAAA,IAAC,OAAA,CAAK,EAAE,qBAAqB,OAAO,eAAe,YAAY,MAAM,cAAc,OAAA,CAAQ,CAAA,CAC7F,CAEJ,CAEO,MAAMC,EAASC,EAAAA,WAAwC,SAC5D,CACE,OAAAC,EACA,QAAAC,EACA,UAAAC,EAAY,QACZ,KAAAC,EAAO,KACP,MAAAC,EACA,oBAAAC,EAAsB,GACtB,cAAAC,EAAgB,GAChB,gBAAAC,EAAkB,GAClB,WAAAC,EAAa,eACb,YAAAC,EAAc,GACd,UAAAC,EACA,MAAAC,EACA,SAAAC,EACA,OAAAC,EACA,GAAGC,CACL,EACAC,EACA,CACA,MAAMC,EAAYC,EAAAA,OAAuB,IAAI,EACvCC,EAAUC,EAAAA,MAAM,cAAc,EAC9BC,EAAwBH,EAAAA,OAA2B,IAAI,EAGvDI,EAAaJ,EAAAA,OAAOhB,CAAO,EACjCqB,EAAAA,UAAU,IAAM,CACdD,EAAW,QAAUpB,CACvB,EAAG,CAACA,CAAO,CAAC,EAGZqB,EAAAA,UAAU,IAAM,CACd,GAAI,CAACtB,EAAQ,OAEboB,EAAsB,QAAU,SAAS,cACzC,MAAMG,EAASP,EAAU,QACrBO,GACF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