@postenbring/hedwig-react 3.0.5 → 4.0.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/alert/alert.d.ts +14 -0
- package/dist/alert/alert.d.ts.map +1 -1
- package/dist/alert/alert.js +43 -7
- package/dist/alert/alert.js.map +1 -1
- package/dist/alert/alert.mjs +2 -2
- package/dist/alert/index.js +43 -7
- package/dist/alert/index.js.map +1 -1
- package/dist/alert/index.mjs +2 -2
- package/dist/badge/badge.d.ts +12 -2
- package/dist/badge/badge.d.ts.map +1 -1
- package/dist/badge/badge.js +21 -4
- package/dist/badge/badge.js.map +1 -1
- package/dist/badge/badge.mjs +1 -1
- package/dist/badge/index.js +21 -4
- package/dist/badge/index.js.map +1 -1
- package/dist/badge/index.mjs +1 -1
- package/dist/box/box.d.ts +9 -2
- package/dist/box/box.d.ts.map +1 -1
- package/dist/box/box.js +31 -3
- package/dist/box/box.js.map +1 -1
- package/dist/box/box.mjs +1 -1
- package/dist/box/index.js +31 -3
- package/dist/box/index.js.map +1 -1
- package/dist/box/index.mjs +1 -1
- package/dist/card/card.d.ts +85 -7
- package/dist/card/card.d.ts.map +1 -1
- package/dist/card/card.js +30 -6
- package/dist/card/card.js.map +1 -1
- package/dist/card/card.mjs +1 -1
- package/dist/card/index.js +30 -6
- package/dist/card/index.js.map +1 -1
- package/dist/card/index.mjs +1 -1
- package/dist/{chunk-JOEPTRHW.mjs → chunk-BFM6UZGI.mjs} +31 -7
- package/dist/chunk-BFM6UZGI.mjs.map +1 -0
- package/dist/{chunk-3OGHJOJF.mjs → chunk-DEABU7DB.mjs} +32 -4
- package/dist/chunk-DEABU7DB.mjs.map +1 -0
- package/dist/{chunk-EQFY63YP.mjs → chunk-EDPWJWQO.mjs} +2 -2
- package/dist/chunk-F4VC5NPP.mjs +54 -0
- package/dist/chunk-F4VC5NPP.mjs.map +1 -0
- package/dist/{chunk-W7CPW23K.mjs → chunk-F7MLQ6JI.mjs} +4 -14
- package/dist/{chunk-W7CPW23K.mjs.map → chunk-F7MLQ6JI.mjs.map} +1 -1
- package/dist/{chunk-EGW3RCXD.mjs → chunk-I76U35YW.mjs} +2 -3
- package/dist/chunk-I76U35YW.mjs.map +1 -0
- package/dist/{chunk-BYFBK3J7.mjs → chunk-ILN2L5NX.mjs} +4 -4
- package/dist/chunk-ILN2L5NX.mjs.map +1 -0
- package/dist/{chunk-YZDURLEY.mjs → chunk-INDTHGWZ.mjs} +2 -2
- package/dist/{chunk-4P4GPVKZ.mjs → chunk-PZUJLRG4.mjs} +14 -6
- package/dist/chunk-PZUJLRG4.mjs.map +1 -0
- package/dist/{chunk-OHDHIRAW.mjs → chunk-QE2ZES72.mjs} +1 -1
- package/dist/chunk-QE2ZES72.mjs.map +1 -0
- package/dist/{chunk-I4NL4ESV.mjs → chunk-YNGU3V4J.mjs} +3 -2
- package/dist/chunk-YNGU3V4J.mjs.map +1 -0
- package/dist/footer/footer.d.ts.map +1 -1
- package/dist/footer/footer.js +2 -1
- package/dist/footer/footer.js.map +1 -1
- package/dist/footer/footer.mjs +1 -1
- package/dist/footer/index.js +2 -1
- package/dist/footer/index.js.map +1 -1
- package/dist/footer/index.mjs +1 -1
- package/dist/form/error-summary/error-summary.d.ts.map +1 -1
- package/dist/form/error-summary/error-summary.js +32 -14
- package/dist/form/error-summary/error-summary.js.map +1 -1
- package/dist/form/error-summary/error-summary.mjs +3 -3
- package/dist/form/error-summary/index.js +32 -14
- package/dist/form/error-summary/index.js.map +1 -1
- package/dist/form/error-summary/index.mjs +3 -3
- package/dist/form/index.js +32 -14
- package/dist/form/index.js.map +1 -1
- package/dist/form/index.mjs +3 -3
- package/dist/help-text/help-text.js +31 -3
- package/dist/help-text/help-text.js.map +1 -1
- package/dist/help-text/help-text.mjs +2 -2
- package/dist/help-text/index.js +31 -3
- package/dist/help-text/index.js.map +1 -1
- package/dist/help-text/index.mjs +2 -2
- package/dist/index.js +102 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -16
- package/dist/link/index.js.map +1 -1
- package/dist/link/index.mjs +1 -1
- package/dist/link/link.d.ts +1 -1
- package/dist/link/link.d.ts.map +1 -1
- package/dist/link/link.js.map +1 -1
- package/dist/link/link.mjs +1 -1
- package/dist/message/index.js +33 -5
- package/dist/message/index.js.map +1 -1
- package/dist/message/index.mjs +2 -2
- package/dist/message/message.d.ts +1 -0
- package/dist/message/message.d.ts.map +1 -1
- package/dist/message/message.js +33 -5
- package/dist/message/message.js.map +1 -1
- package/dist/message/message.mjs +2 -2
- package/dist/modal/index.js +31 -3
- package/dist/modal/index.js.map +1 -1
- package/dist/modal/index.mjs +2 -2
- package/dist/modal/modal.js +31 -3
- package/dist/modal/modal.js.map +1 -1
- package/dist/modal/modal.mjs +2 -2
- package/dist/styled-html/index.js +1 -2
- package/dist/styled-html/index.js.map +1 -1
- package/dist/styled-html/index.mjs +1 -1
- package/dist/styled-html/styled-html.d.ts +0 -4
- package/dist/styled-html/styled-html.d.ts.map +1 -1
- package/dist/styled-html/styled-html.js +1 -2
- package/dist/styled-html/styled-html.js.map +1 -1
- package/dist/styled-html/styled-html.mjs +1 -1
- package/package.json +2 -2
- package/src/alert/alert.stories.tsx +2 -2
- package/src/alert/alert.tsx +36 -4
- package/src/badge/badge.tsx +34 -4
- package/src/box/box.stories.tsx +7 -1
- package/src/box/box.tsx +47 -4
- package/src/card/card.tsx +139 -13
- package/src/footer/footer.tsx +2 -1
- package/src/form/error-summary/error-summary.tsx +1 -7
- package/src/link/link.tsx +1 -1
- package/src/message/message.tsx +2 -0
- package/src/styled-html/styled-html.stories.tsx +0 -7
- package/src/styled-html/styled-html.tsx +1 -7
- package/dist/chunk-3OGHJOJF.mjs.map +0 -1
- package/dist/chunk-4P4GPVKZ.mjs.map +0 -1
- package/dist/chunk-BYFBK3J7.mjs.map +0 -1
- package/dist/chunk-EGW3RCXD.mjs.map +0 -1
- package/dist/chunk-I4NL4ESV.mjs.map +0 -1
- package/dist/chunk-JOEPTRHW.mjs.map +0 -1
- package/dist/chunk-OHDHIRAW.mjs.map +0 -1
- package/dist/chunk-OXZOGFNV.mjs +0 -37
- package/dist/chunk-OXZOGFNV.mjs.map +0 -1
- /package/dist/{chunk-EQFY63YP.mjs.map → chunk-EDPWJWQO.mjs.map} +0 -0
- /package/dist/{chunk-YZDURLEY.mjs.map → chunk-INDTHGWZ.mjs.map} +0 -0
package/dist/box/box.js
CHANGED
|
@@ -57,23 +57,47 @@ var import_react = require("react");
|
|
|
57
57
|
var import_typed_classname = require("@postenbring/hedwig-css/typed-classname");
|
|
58
58
|
var import_react_slot = require("@radix-ui/react-slot");
|
|
59
59
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
60
|
+
function CloseIcon() {
|
|
61
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { "aria-hidden": true, xmlns: "http://www.w3.org/2000/svg", width: 32, height: 32, viewBox: "0 0 32 32", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
62
|
+
"path",
|
|
63
|
+
{
|
|
64
|
+
d: "M17.5469 16.3333L22.375 11.5521L23.3594 10.5677C23.5 10.4271 23.5 10.1927 23.3594 10.0052L22.3281 8.97394C22.1406 8.83331 21.9062 8.83331 21.7656 8.97394L16 14.7864L10.1875 8.97394C10.0469 8.83331 9.8125 8.83331 9.625 8.97394L8.59375 10.0052C8.45312 10.1927 8.45312 10.4271 8.59375 10.5677L14.4062 16.3333L8.59375 22.1458C8.45312 22.2864 8.45312 22.5208 8.59375 22.7083L9.625 23.7396C9.8125 23.8802 10.0469 23.8802 10.1875 23.7396L16 17.9271L20.7812 22.7552L21.7656 23.7396C21.9062 23.8802 22.1406 23.8802 22.3281 23.7396L23.3594 22.7083C23.5 22.5208 23.5 22.2864 23.3594 22.1458L17.5469 16.3333Z",
|
|
65
|
+
fill: "currentColor"
|
|
66
|
+
}
|
|
67
|
+
) });
|
|
68
|
+
}
|
|
60
69
|
var BoxCloseButton = (0, import_react.forwardRef)(
|
|
61
70
|
(_a, ref) => {
|
|
62
71
|
var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
|
|
63
72
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
64
73
|
"button",
|
|
65
|
-
__spreadValues({
|
|
74
|
+
__spreadProps(__spreadValues({
|
|
66
75
|
className: (0, import_typed_classname.clsx)("hds-box__close-button", className),
|
|
67
76
|
ref,
|
|
68
77
|
type: "button"
|
|
69
|
-
}, rest)
|
|
78
|
+
}, rest), {
|
|
79
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CloseIcon, {})
|
|
80
|
+
})
|
|
70
81
|
);
|
|
71
82
|
}
|
|
72
83
|
);
|
|
73
84
|
BoxCloseButton.displayName = "Box.CloseButton";
|
|
85
|
+
var convertVariantToColor = (variant) => {
|
|
86
|
+
switch (variant) {
|
|
87
|
+
case "lighter":
|
|
88
|
+
return "";
|
|
89
|
+
case "white":
|
|
90
|
+
return "";
|
|
91
|
+
case "warning":
|
|
92
|
+
return "warning";
|
|
93
|
+
default:
|
|
94
|
+
return "neutral";
|
|
95
|
+
}
|
|
96
|
+
};
|
|
74
97
|
var Box = (0, import_react.forwardRef)(
|
|
75
98
|
(_a, ref) => {
|
|
76
99
|
var _b = _a, {
|
|
100
|
+
"data-color": color = "",
|
|
77
101
|
asChild,
|
|
78
102
|
variant,
|
|
79
103
|
closeable = false,
|
|
@@ -83,6 +107,7 @@ var Box = (0, import_react.forwardRef)(
|
|
|
83
107
|
children,
|
|
84
108
|
className
|
|
85
109
|
} = _b, rest = __objRest(_b, [
|
|
110
|
+
"data-color",
|
|
86
111
|
"asChild",
|
|
87
112
|
"variant",
|
|
88
113
|
"closeable",
|
|
@@ -105,12 +130,15 @@ var Box = (0, import_react.forwardRef)(
|
|
|
105
130
|
}, []);
|
|
106
131
|
const closed = closedProp != null ? closedProp : closedState;
|
|
107
132
|
const Component = asChild ? import_react_slot.Slot : "div";
|
|
133
|
+
const resolvedColor = color && color !== "" ? color : convertVariantToColor(variant);
|
|
108
134
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
109
135
|
Component,
|
|
110
136
|
__spreadProps(__spreadValues({
|
|
137
|
+
"data-color": resolvedColor,
|
|
111
138
|
className: (0, import_typed_classname.clsx)(
|
|
112
139
|
"hds-box",
|
|
113
|
-
|
|
140
|
+
{ "hds-box--lighter": variant === "lighter" },
|
|
141
|
+
{ "hds-box--white": variant === "white" },
|
|
114
142
|
{ "hds-box--closed": closed },
|
|
115
143
|
className
|
|
116
144
|
),
|
package/dist/box/box.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/box/box.tsx"],"sourcesContent":["import { forwardRef, useCallback, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot, Slottable } from \"@radix-ui/react-slot\";\n\nexport type BoxCloseButtonProps = Omit<React.HTMLAttributes<HTMLButtonElement>, \"children\">;\nexport const BoxCloseButton = forwardRef<HTMLButtonElement, BoxCloseButtonProps>(\n ({ className, ...rest }, ref) => {\n return (\n <button\n className={clsx(\"hds-box__close-button\", className as undefined)}\n ref={ref}\n type=\"button\"\n {...rest}\n />\n );\n },\n);\nBoxCloseButton.displayName = \"Box.CloseButton\";\n\nexport interface BoxProps extends React.HTMLAttributes<HTMLDivElement> {\n children?: React.ReactNode;\n\n /**\n *
|
|
1
|
+
{"version":3,"sources":["../../src/box/box.tsx"],"sourcesContent":["import { forwardRef, useCallback, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot, Slottable } from \"@radix-ui/react-slot\";\n\nfunction CloseIcon() {\n return (\n <svg aria-hidden xmlns=\"http://www.w3.org/2000/svg\" width={32} height={32} viewBox=\"0 0 32 32\">\n <path\n d=\"M17.5469 16.3333L22.375 11.5521L23.3594 10.5677C23.5 10.4271 23.5 10.1927 23.3594 10.0052L22.3281 8.97394C22.1406 8.83331 21.9062 8.83331 21.7656 8.97394L16 14.7864L10.1875 8.97394C10.0469 8.83331 9.8125 8.83331 9.625 8.97394L8.59375 10.0052C8.45312 10.1927 8.45312 10.4271 8.59375 10.5677L14.4062 16.3333L8.59375 22.1458C8.45312 22.2864 8.45312 22.5208 8.59375 22.7083L9.625 23.7396C9.8125 23.8802 10.0469 23.8802 10.1875 23.7396L16 17.9271L20.7812 22.7552L21.7656 23.7396C21.9062 23.8802 22.1406 23.8802 22.3281 23.7396L23.3594 22.7083C23.5 22.5208 23.5 22.2864 23.3594 22.1458L17.5469 16.3333Z\"\n fill=\"currentColor\"\n />\n </svg>\n );\n}\n\nexport type BoxCloseButtonProps = Omit<React.HTMLAttributes<HTMLButtonElement>, \"children\">;\nexport const BoxCloseButton = forwardRef<HTMLButtonElement, BoxCloseButtonProps>(\n ({ className, ...rest }, ref) => {\n return (\n <button\n className={clsx(\"hds-box__close-button\", className as undefined)}\n ref={ref}\n type=\"button\"\n {...rest}\n >\n <CloseIcon />\n </button>\n );\n },\n);\nBoxCloseButton.displayName = \"Box.CloseButton\";\n\nexport interface BoxProps extends React.HTMLAttributes<HTMLDivElement> {\n children?: React.ReactNode;\n\n /**\n * Posten/Bring-spesific variant of the box. NB: warning variant is deprecated, use data-color=\"warning\" instead.\n *\n * @default \"light-grey\"\n */\n variant?:\n | \"light-grey\"\n | \"lighter\"\n | \"white\"\n /** @deprecated use data-color=\"warning\" instead */\n | \"warning\";\n\n /**\n * Color variant of the box\n *\n */\n\n \"data-color\"?: \"neutral\" | \"info\" | \"success\" | \"warning\" | \"error\";\n\n /**\n * If `true`, a close button will be shown.\n * Use when you want to control the close button using the BoxCloseButton component.\n *\n * @default false\n */\n closeable?: boolean;\n\n /**\n * Callback fired when the component requests to be closed.\n * If not set, the component will be closed without any user interaction.\n *\n * If set, and the handler returns non-true value, the component will not be closed.\n * Use this if you want to control the closing of the component, using the `closed` prop\n *\n * If set, and the handler returns the true, the component will be closed.\n * Use this with `window.confirm()` to ask the user to confirm closing the component.\n */\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents -- It's fine, I want to have the boolean in the type\n onClose?: () => boolean | unknown;\n\n /**\n * If `true`, the box will be closed and hidden from view\n */\n closed?: boolean;\n\n /**\n * Props applied to the close button element.\n */\n closeButtonProps?: BoxCloseButtonProps;\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\nconst convertVariantToColor = (variant: BoxProps[\"variant\"] | \"\") => {\n switch (variant) {\n case \"lighter\":\n return \"\";\n case \"white\":\n return \"\";\n case \"warning\":\n return \"warning\";\n default:\n return \"neutral\";\n }\n};\n\nexport const Box = forwardRef<HTMLDivElement, BoxProps>(\n (\n {\n \"data-color\": color = \"\",\n asChild,\n variant,\n closeable = false,\n onClose: onCloseProp,\n closed: closedProp,\n closeButtonProps,\n children,\n className,\n ...rest\n },\n ref,\n ) => {\n const [closedState, setClosedState] = useState(false);\n const onClose = useCallback(() => {\n if (onCloseProp) {\n const result = onCloseProp();\n if (result === true) {\n setClosedState(true);\n }\n } else {\n setClosedState(true);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps -- I know better\n }, []);\n const closed = closedProp ?? closedState;\n const Component = asChild ? Slot : \"div\";\n\n const resolvedColor = color && color !== \"\" ? color : convertVariantToColor(variant);\n\n return (\n <Component\n data-color={resolvedColor}\n className={clsx(\n \"hds-box\",\n { \"hds-box--lighter\": variant === \"lighter\" },\n { \"hds-box--white\": variant === \"white\" },\n { \"hds-box--closed\": closed },\n className as undefined,\n )}\n ref={ref}\n {...rest}\n >\n {closeable ? <BoxCloseButton onClick={onClose} {...closeButtonProps} /> : null}\n <Slottable>{children}</Slottable>\n </Component>\n );\n },\n) as BoxType;\nBox.displayName = \"Box\";\n\nBox.CloseButton = BoxCloseButton;\n\ntype BoxType = ReturnType<typeof forwardRef<HTMLDivElement, BoxProps>> & {\n CloseButton: typeof BoxCloseButton;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;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,YAAY;AAC3B,YAAI,WAAW,MAAM;AACnB,yBAAe,IAAI;AAAA,QACrB;AAAA,MACF,OAAO;AACL,uBAAe,IAAI;AAAA,MACrB;AAAA,IAEF,GAAG,CAAC,CAAC;AACL,UAAM,SAAS,kCAAc;AAC7B,UAAM,YAAY,UAAU,yBAAO;AAEnC,UAAM,gBAAgB,SAAS,UAAU,KAAK,QAAQ,sBAAsB,OAAO;AAEnF,WACE;AAAA,MAAC;AAAA;AAAA,QACC,cAAY;AAAA,QACZ,eAAW;AAAA,UACT;AAAA,UACA,EAAE,oBAAoB,YAAY,UAAU;AAAA,UAC5C,EAAE,kBAAkB,YAAY,QAAQ;AAAA,UACxC,EAAE,mBAAmB,OAAO;AAAA,UAC5B;AAAA,QACF;AAAA,QACA;AAAA,SACI,OAVL;AAAA,QAYE;AAAA,sBAAY,4CAAC,iCAAe,SAAS,WAAa,iBAAkB,IAAK;AAAA,UAC1E,4CAAC,+BAAW,UAAS;AAAA;AAAA;AAAA,IACvB;AAAA,EAEJ;AACF;AACA,IAAI,cAAc;AAElB,IAAI,cAAc;","names":[]}
|
package/dist/box/box.mjs
CHANGED
package/dist/box/index.js
CHANGED
|
@@ -59,23 +59,47 @@ var import_react = require("react");
|
|
|
59
59
|
var import_typed_classname = require("@postenbring/hedwig-css/typed-classname");
|
|
60
60
|
var import_react_slot = require("@radix-ui/react-slot");
|
|
61
61
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
62
|
+
function CloseIcon() {
|
|
63
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { "aria-hidden": true, xmlns: "http://www.w3.org/2000/svg", width: 32, height: 32, viewBox: "0 0 32 32", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
64
|
+
"path",
|
|
65
|
+
{
|
|
66
|
+
d: "M17.5469 16.3333L22.375 11.5521L23.3594 10.5677C23.5 10.4271 23.5 10.1927 23.3594 10.0052L22.3281 8.97394C22.1406 8.83331 21.9062 8.83331 21.7656 8.97394L16 14.7864L10.1875 8.97394C10.0469 8.83331 9.8125 8.83331 9.625 8.97394L8.59375 10.0052C8.45312 10.1927 8.45312 10.4271 8.59375 10.5677L14.4062 16.3333L8.59375 22.1458C8.45312 22.2864 8.45312 22.5208 8.59375 22.7083L9.625 23.7396C9.8125 23.8802 10.0469 23.8802 10.1875 23.7396L16 17.9271L20.7812 22.7552L21.7656 23.7396C21.9062 23.8802 22.1406 23.8802 22.3281 23.7396L23.3594 22.7083C23.5 22.5208 23.5 22.2864 23.3594 22.1458L17.5469 16.3333Z",
|
|
67
|
+
fill: "currentColor"
|
|
68
|
+
}
|
|
69
|
+
) });
|
|
70
|
+
}
|
|
62
71
|
var BoxCloseButton = (0, import_react.forwardRef)(
|
|
63
72
|
(_a, ref) => {
|
|
64
73
|
var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
|
|
65
74
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
66
75
|
"button",
|
|
67
|
-
__spreadValues({
|
|
76
|
+
__spreadProps(__spreadValues({
|
|
68
77
|
className: (0, import_typed_classname.clsx)("hds-box__close-button", className),
|
|
69
78
|
ref,
|
|
70
79
|
type: "button"
|
|
71
|
-
}, rest)
|
|
80
|
+
}, rest), {
|
|
81
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CloseIcon, {})
|
|
82
|
+
})
|
|
72
83
|
);
|
|
73
84
|
}
|
|
74
85
|
);
|
|
75
86
|
BoxCloseButton.displayName = "Box.CloseButton";
|
|
87
|
+
var convertVariantToColor = (variant) => {
|
|
88
|
+
switch (variant) {
|
|
89
|
+
case "lighter":
|
|
90
|
+
return "";
|
|
91
|
+
case "white":
|
|
92
|
+
return "";
|
|
93
|
+
case "warning":
|
|
94
|
+
return "warning";
|
|
95
|
+
default:
|
|
96
|
+
return "neutral";
|
|
97
|
+
}
|
|
98
|
+
};
|
|
76
99
|
var Box = (0, import_react.forwardRef)(
|
|
77
100
|
(_a, ref) => {
|
|
78
101
|
var _b = _a, {
|
|
102
|
+
"data-color": color = "",
|
|
79
103
|
asChild,
|
|
80
104
|
variant,
|
|
81
105
|
closeable = false,
|
|
@@ -85,6 +109,7 @@ var Box = (0, import_react.forwardRef)(
|
|
|
85
109
|
children,
|
|
86
110
|
className
|
|
87
111
|
} = _b, rest = __objRest(_b, [
|
|
112
|
+
"data-color",
|
|
88
113
|
"asChild",
|
|
89
114
|
"variant",
|
|
90
115
|
"closeable",
|
|
@@ -107,12 +132,15 @@ var Box = (0, import_react.forwardRef)(
|
|
|
107
132
|
}, []);
|
|
108
133
|
const closed = closedProp != null ? closedProp : closedState;
|
|
109
134
|
const Component = asChild ? import_react_slot.Slot : "div";
|
|
135
|
+
const resolvedColor = color && color !== "" ? color : convertVariantToColor(variant);
|
|
110
136
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
111
137
|
Component,
|
|
112
138
|
__spreadProps(__spreadValues({
|
|
139
|
+
"data-color": resolvedColor,
|
|
113
140
|
className: (0, import_typed_classname.clsx)(
|
|
114
141
|
"hds-box",
|
|
115
|
-
|
|
142
|
+
{ "hds-box--lighter": variant === "lighter" },
|
|
143
|
+
{ "hds-box--white": variant === "white" },
|
|
116
144
|
{ "hds-box--closed": closed },
|
|
117
145
|
className
|
|
118
146
|
),
|
package/dist/box/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/box/index.tsx","../../src/box/box.tsx"],"sourcesContent":["export { Box, BoxCloseButton } from \"./box\";\n\nexport type * from \"./box\";\n","import { forwardRef, useCallback, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot, Slottable } from \"@radix-ui/react-slot\";\n\nexport type BoxCloseButtonProps = Omit<React.HTMLAttributes<HTMLButtonElement>, \"children\">;\nexport const BoxCloseButton = forwardRef<HTMLButtonElement, BoxCloseButtonProps>(\n ({ className, ...rest }, ref) => {\n return (\n <button\n className={clsx(\"hds-box__close-button\", className as undefined)}\n ref={ref}\n type=\"button\"\n {...rest}\n />\n );\n },\n);\nBoxCloseButton.displayName = \"Box.CloseButton\";\n\nexport interface BoxProps extends React.HTMLAttributes<HTMLDivElement> {\n children?: React.ReactNode;\n\n /**\n *
|
|
1
|
+
{"version":3,"sources":["../../src/box/index.tsx","../../src/box/box.tsx"],"sourcesContent":["export { Box, BoxCloseButton } from \"./box\";\n\nexport type * from \"./box\";\n","import { forwardRef, useCallback, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot, Slottable } from \"@radix-ui/react-slot\";\n\nfunction CloseIcon() {\n return (\n <svg aria-hidden xmlns=\"http://www.w3.org/2000/svg\" width={32} height={32} viewBox=\"0 0 32 32\">\n <path\n d=\"M17.5469 16.3333L22.375 11.5521L23.3594 10.5677C23.5 10.4271 23.5 10.1927 23.3594 10.0052L22.3281 8.97394C22.1406 8.83331 21.9062 8.83331 21.7656 8.97394L16 14.7864L10.1875 8.97394C10.0469 8.83331 9.8125 8.83331 9.625 8.97394L8.59375 10.0052C8.45312 10.1927 8.45312 10.4271 8.59375 10.5677L14.4062 16.3333L8.59375 22.1458C8.45312 22.2864 8.45312 22.5208 8.59375 22.7083L9.625 23.7396C9.8125 23.8802 10.0469 23.8802 10.1875 23.7396L16 17.9271L20.7812 22.7552L21.7656 23.7396C21.9062 23.8802 22.1406 23.8802 22.3281 23.7396L23.3594 22.7083C23.5 22.5208 23.5 22.2864 23.3594 22.1458L17.5469 16.3333Z\"\n fill=\"currentColor\"\n />\n </svg>\n );\n}\n\nexport type BoxCloseButtonProps = Omit<React.HTMLAttributes<HTMLButtonElement>, \"children\">;\nexport const BoxCloseButton = forwardRef<HTMLButtonElement, BoxCloseButtonProps>(\n ({ className, ...rest }, ref) => {\n return (\n <button\n className={clsx(\"hds-box__close-button\", className as undefined)}\n ref={ref}\n type=\"button\"\n {...rest}\n >\n <CloseIcon />\n </button>\n );\n },\n);\nBoxCloseButton.displayName = \"Box.CloseButton\";\n\nexport interface BoxProps extends React.HTMLAttributes<HTMLDivElement> {\n children?: React.ReactNode;\n\n /**\n * Posten/Bring-spesific variant of the box. NB: warning variant is deprecated, use data-color=\"warning\" instead.\n *\n * @default \"light-grey\"\n */\n variant?:\n | \"light-grey\"\n | \"lighter\"\n | \"white\"\n /** @deprecated use data-color=\"warning\" instead */\n | \"warning\";\n\n /**\n * Color variant of the box\n *\n */\n\n \"data-color\"?: \"neutral\" | \"info\" | \"success\" | \"warning\" | \"error\";\n\n /**\n * If `true`, a close button will be shown.\n * Use when you want to control the close button using the BoxCloseButton component.\n *\n * @default false\n */\n closeable?: boolean;\n\n /**\n * Callback fired when the component requests to be closed.\n * If not set, the component will be closed without any user interaction.\n *\n * If set, and the handler returns non-true value, the component will not be closed.\n * Use this if you want to control the closing of the component, using the `closed` prop\n *\n * If set, and the handler returns the true, the component will be closed.\n * Use this with `window.confirm()` to ask the user to confirm closing the component.\n */\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents -- It's fine, I want to have the boolean in the type\n onClose?: () => boolean | unknown;\n\n /**\n * If `true`, the box will be closed and hidden from view\n */\n closed?: boolean;\n\n /**\n * Props applied to the close button element.\n */\n closeButtonProps?: BoxCloseButtonProps;\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\nconst convertVariantToColor = (variant: BoxProps[\"variant\"] | \"\") => {\n switch (variant) {\n case \"lighter\":\n return \"\";\n case \"white\":\n return \"\";\n case \"warning\":\n return \"warning\";\n default:\n return \"neutral\";\n }\n};\n\nexport const Box = forwardRef<HTMLDivElement, BoxProps>(\n (\n {\n \"data-color\": color = \"\",\n asChild,\n variant,\n closeable = false,\n onClose: onCloseProp,\n closed: closedProp,\n closeButtonProps,\n children,\n className,\n ...rest\n },\n ref,\n ) => {\n const [closedState, setClosedState] = useState(false);\n const onClose = useCallback(() => {\n if (onCloseProp) {\n const result = onCloseProp();\n if (result === true) {\n setClosedState(true);\n }\n } else {\n setClosedState(true);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps -- I know better\n }, []);\n const closed = closedProp ?? closedState;\n const Component = asChild ? Slot : \"div\";\n\n const resolvedColor = color && color !== \"\" ? color : convertVariantToColor(variant);\n\n return (\n <Component\n data-color={resolvedColor}\n className={clsx(\n \"hds-box\",\n { \"hds-box--lighter\": variant === \"lighter\" },\n { \"hds-box--white\": variant === \"white\" },\n { \"hds-box--closed\": closed },\n className as undefined,\n )}\n ref={ref}\n {...rest}\n >\n {closeable ? <BoxCloseButton onClick={onClose} {...closeButtonProps} /> : null}\n <Slottable>{children}</Slottable>\n </Component>\n );\n },\n) as BoxType;\nBox.displayName = \"Box\";\n\nBox.CloseButton = BoxCloseButton;\n\ntype BoxType = ReturnType<typeof forwardRef<HTMLDivElement, BoxProps>> & {\n CloseButton: typeof BoxCloseButton;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAkD;AAClD,6BAAqB;AACrB,wBAAgC;AAK1B;AAHN,SAAS,YAAY;AACnB,SACE,4CAAC,SAAI,eAAW,MAAC,OAAM,8BAA6B,OAAO,IAAI,QAAQ,IAAI,SAAQ,aACjF;AAAA,IAAC;AAAA;AAAA,MACC,GAAE;AAAA,MACF,MAAK;AAAA;AAAA,EACP,GACF;AAEJ;AAGO,IAAM,qBAAiB;AAAA,EAC5B,CAAC,IAAwB,QAAQ;AAAhC,iBAAE,YAjBL,IAiBG,IAAgB,iBAAhB,IAAgB,CAAd;AACD,WACE;AAAA,MAAC;AAAA;AAAA,QACC,eAAW,6BAAK,yBAAyB,SAAsB;AAAA,QAC/D;AAAA,QACA,MAAK;AAAA,SACD,OAJL;AAAA,QAMC,sDAAC,aAAU;AAAA;AAAA,IACb;AAAA,EAEJ;AACF;AACA,eAAe,cAAc;AA+D7B,IAAM,wBAAwB,CAAC,YAAsC;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cAAc;AAElB,IAAI,cAAc;","names":[]}
|
package/dist/box/index.mjs
CHANGED
package/dist/card/card.d.ts
CHANGED
|
@@ -60,7 +60,11 @@ export interface CardBaseProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
60
60
|
*/
|
|
61
61
|
asChild?: boolean;
|
|
62
62
|
}
|
|
63
|
-
|
|
63
|
+
/**
|
|
64
|
+
* @deprecated This interface is deprecated and will be removed in a future release.
|
|
65
|
+
* Use `CardSlimAndMiniatureProps` with props `data-color` and `theme` instead.
|
|
66
|
+
*/
|
|
67
|
+
export interface CardSlimAndMiniaturePropsDeprecated extends CardBaseProps {
|
|
64
68
|
/**
|
|
65
69
|
* Change the default rendered element for Card.
|
|
66
70
|
*/
|
|
@@ -71,18 +75,56 @@ export interface CardSlimAndMiniatureProps extends CardBaseProps {
|
|
|
71
75
|
* @default "slim"
|
|
72
76
|
*/
|
|
73
77
|
variant?: "slim" | "miniature";
|
|
78
|
+
"data-color"?: never;
|
|
79
|
+
theme?: never;
|
|
74
80
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
|
|
81
|
+
* @deprecated
|
|
82
|
+
* Use props `data-color` and `theme` instead.
|
|
83
|
+
* These colors will be removed in a future release.
|
|
84
|
+
*/
|
|
79
85
|
color?: "white" | "lighter-brand" | "light-grey-fill";
|
|
80
86
|
imagePosition?: never;
|
|
81
87
|
}
|
|
88
|
+
export interface CardSlimAndMiniatureProps extends CardBaseProps {
|
|
89
|
+
/**
|
|
90
|
+
* Change the default rendered element for Card.
|
|
91
|
+
*/
|
|
92
|
+
as?: "section" | "div" | "article" | "aside";
|
|
93
|
+
/**
|
|
94
|
+
* Allows for a horizontal variant for sizes above small.
|
|
95
|
+
*
|
|
96
|
+
* @default "slim"
|
|
97
|
+
*/
|
|
98
|
+
variant?: "slim" | "miniature";
|
|
99
|
+
/**
|
|
100
|
+
* Set theme for card
|
|
101
|
+
* @default "default"
|
|
102
|
+
*/
|
|
103
|
+
theme?: "default" | "tinted" | "base";
|
|
104
|
+
/**
|
|
105
|
+
* Set data-color for card.
|
|
106
|
+
*/
|
|
107
|
+
"data-color"?: "neutral" | "posten" | "bring";
|
|
108
|
+
imagePosition?: never;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* @deprecated Use Full-width card instead
|
|
112
|
+
*/
|
|
82
113
|
export interface CardFocusProps extends CardBaseProps {
|
|
114
|
+
/**
|
|
115
|
+
* Change the default rendered element for Card.
|
|
116
|
+
*/
|
|
83
117
|
as?: "section" | "div" | "article" | "aside";
|
|
118
|
+
/** @deprecated Use Full-width card instead */
|
|
84
119
|
variant: "focus";
|
|
120
|
+
/**
|
|
121
|
+
* @deprecated
|
|
122
|
+
* Use props `data-color` and `theme` instead.
|
|
123
|
+
* The color prop will be removed in a future release.
|
|
124
|
+
*/
|
|
85
125
|
color?: "darker" | "dark";
|
|
126
|
+
"data-color"?: never;
|
|
127
|
+
theme?: never;
|
|
86
128
|
/**
|
|
87
129
|
* fullwidth or focus cards can have images to the left or right of the text.
|
|
88
130
|
*
|
|
@@ -90,9 +132,23 @@ export interface CardFocusProps extends CardBaseProps {
|
|
|
90
132
|
* */
|
|
91
133
|
imagePosition?: "left" | "right";
|
|
92
134
|
}
|
|
93
|
-
|
|
135
|
+
/**
|
|
136
|
+
* @deprecated This interface is deprecated and will be removed in a future release.
|
|
137
|
+
* Use `CardSlimAndMiniatureProps` with props `data-color` and `theme` instead.
|
|
138
|
+
*/
|
|
139
|
+
export interface CardFullwidthPropsDeprecated extends CardBaseProps {
|
|
140
|
+
/**
|
|
141
|
+
* Change the default rendered element for Card.
|
|
142
|
+
*/
|
|
94
143
|
as?: "section" | "div" | "article" | "aside";
|
|
95
144
|
variant: "full-width";
|
|
145
|
+
"data-color"?: never;
|
|
146
|
+
theme?: never;
|
|
147
|
+
/**
|
|
148
|
+
* @deprecated
|
|
149
|
+
* Use `data-color` and `theme` instead.
|
|
150
|
+
* The color prop will be removed in a future release.
|
|
151
|
+
*/
|
|
96
152
|
color: "white" | "lighter-brand" | "light-grey-fill";
|
|
97
153
|
/**
|
|
98
154
|
* fullwidth or focus cards can have images to the left or right of the text.
|
|
@@ -101,7 +157,29 @@ export interface CardFullwidthProps extends CardBaseProps {
|
|
|
101
157
|
* */
|
|
102
158
|
imagePosition?: "left" | "right";
|
|
103
159
|
}
|
|
104
|
-
export
|
|
160
|
+
export interface CardFullwidthProps extends CardBaseProps {
|
|
161
|
+
/**
|
|
162
|
+
* Change the default rendered element for Card.
|
|
163
|
+
*/
|
|
164
|
+
as?: "section" | "div" | "article" | "aside";
|
|
165
|
+
variant: "full-width";
|
|
166
|
+
/**
|
|
167
|
+
* Set theme for card
|
|
168
|
+
* @default "default"
|
|
169
|
+
*/
|
|
170
|
+
theme?: "default" | "tinted" | "base";
|
|
171
|
+
/**
|
|
172
|
+
* Set data-color for card.
|
|
173
|
+
*/
|
|
174
|
+
"data-color"?: "neutral" | "posten" | "bring";
|
|
175
|
+
/**
|
|
176
|
+
* fullwidth or focus cards can have images to the left or right of the text.
|
|
177
|
+
*
|
|
178
|
+
* @default "left"
|
|
179
|
+
* */
|
|
180
|
+
imagePosition?: "left" | "right";
|
|
181
|
+
}
|
|
182
|
+
export type CardProps = CardSlimAndMiniatureProps | CardFocusProps | CardFullwidthProps | CardSlimAndMiniaturePropsDeprecated | CardFullwidthPropsDeprecated;
|
|
105
183
|
export declare const Card: CardType;
|
|
106
184
|
type CardType = ReturnType<typeof forwardRef<HTMLDivElement, CardProps>> & {
|
|
107
185
|
Media: typeof CardMedia;
|
package/dist/card/card.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card.d.ts","sourceRoot":"","sources":["../../src/card/card.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAInC,eAAO,MAAM,SAAS,0GASrB,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card.BodyActionArrow";
|
|
209
|
+
var convertDeprecatedColor = (color) => {
|
|
210
|
+
switch (color) {
|
|
211
|
+
case "lighter-brand":
|
|
212
|
+
return { theme: "default" };
|
|
213
|
+
case "light-grey-fill":
|
|
214
|
+
return { theme: "base", dataColor: "neutral" };
|
|
215
|
+
case "white":
|
|
216
|
+
return { theme: "default", dataColor: "neutral" };
|
|
217
|
+
case "dark":
|
|
218
|
+
return { theme: "base" };
|
|
219
|
+
case "darker":
|
|
220
|
+
return { theme: "tinted", dataColorScheme: "dark" };
|
|
221
|
+
default:
|
|
222
|
+
return {};
|
|
223
|
+
}
|
|
224
|
+
};
|
|
209
225
|
var Card = (0, import_react.forwardRef)(
|
|
210
226
|
(_a, ref) => {
|
|
211
227
|
var _b = _a, {
|
|
@@ -214,6 +230,8 @@ var Card = (0, import_react.forwardRef)(
|
|
|
214
230
|
className,
|
|
215
231
|
children,
|
|
216
232
|
variant = "slim",
|
|
233
|
+
"data-color": dataColorAttr,
|
|
234
|
+
theme = "default",
|
|
217
235
|
color,
|
|
218
236
|
imagePosition
|
|
219
237
|
} = _b, rest = __objRest(_b, [
|
|
@@ -222,24 +240,30 @@ var Card = (0, import_react.forwardRef)(
|
|
|
222
240
|
"className",
|
|
223
241
|
"children",
|
|
224
242
|
"variant",
|
|
243
|
+
"data-color",
|
|
244
|
+
"theme",
|
|
225
245
|
"color",
|
|
226
246
|
"imagePosition"
|
|
227
247
|
]);
|
|
228
248
|
const Component = asChild ? import_react_slot.Slot : Tag;
|
|
229
|
-
const
|
|
249
|
+
const {
|
|
250
|
+
theme: themeFromDeprecated,
|
|
251
|
+
dataColor: dataColorFromDeprecated,
|
|
252
|
+
dataColorScheme: dataColorSchemeFromDeprecated
|
|
253
|
+
} = convertDeprecatedColor(color != null ? color : variant === "focus" ? "darker" : void 0);
|
|
230
254
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
231
255
|
Component,
|
|
232
|
-
__spreadProps(__spreadValues({}, rest), {
|
|
256
|
+
__spreadProps(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, rest), dataColorAttr ? { "data-color": dataColorAttr } : {}), dataColorFromDeprecated ? { "data-color": dataColorFromDeprecated } : {}), dataColorSchemeFromDeprecated ? { "data-color-scheme": dataColorSchemeFromDeprecated } : {}), {
|
|
233
257
|
className: (0, import_typed_classname.clsx)(
|
|
234
258
|
"hds-card",
|
|
235
259
|
{ "hds-card--full-width": variant === "full-width" },
|
|
236
260
|
{ "hds-card--miniature": variant === "miniature" },
|
|
237
261
|
{ "hds-card--focus": variant === "focus" },
|
|
262
|
+
// @deprecated
|
|
238
263
|
{ "hds-card--slim": variant === "slim" },
|
|
239
|
-
{ "hds-card--
|
|
240
|
-
{ "hds-card--
|
|
241
|
-
{ "hds-card--
|
|
242
|
-
{ "hds-card--color-darker": effectiveColor === "darker" },
|
|
264
|
+
{ "hds-card--theme-default": (themeFromDeprecated != null ? themeFromDeprecated : theme) === "default" },
|
|
265
|
+
{ "hds-card--theme-tinted": (themeFromDeprecated != null ? themeFromDeprecated : theme) === "tinted" },
|
|
266
|
+
{ "hds-card--theme-base": (themeFromDeprecated != null ? themeFromDeprecated : theme) === "base" },
|
|
243
267
|
{ "hds-card--image-position-right": imagePosition === "right" },
|
|
244
268
|
className
|
|
245
269
|
),
|
package/dist/card/card.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/card/card.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { forwardRef } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot } from \"@radix-ui/react-slot\";\n\nexport const CardMedia = forwardRef<HTMLDivElement, CardBaseProps>(\n ({ asChild, className, children, ...rest }, ref) => {\n const Component = asChild ? Slot : \"div\";\n return (\n <Component {...rest} className={clsx(\"hds-card__media\", className as undefined)} ref={ref}>\n {children}\n </Component>\n );\n },\n);\nCardMedia.displayName = \"Card.Media\";\n\nexport interface CardImageMediaProps extends React.ImgHTMLAttributes<HTMLImageElement> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n /**\n * Define image scaling behavior when the image are varies in both width and height across different page breaks and sizes of the card.\n * \"crop\": Image always fills the available space.\n * If the aspect ratio doesn't match, then the top/bottom or left/right edges are cropped away.\n * \"scale\": No cropping, image scales to the maximum size available and centers.\n * If the aspect ratio doesn't match, then the background will show on the top/bottom or left/right sides of the image.\n *\n * @default \"crop\"\n */\n variant?: \"crop\" | \"scale\";\n}\nexport const CardMediaImg = forwardRef<HTMLImageElement, CardImageMediaProps>(\n ({ asChild, variant, className, ...rest }, ref) => {\n const Component = asChild ? Slot : \"img\";\n return (\n <Component\n {...rest}\n className={clsx(\n \"hds-card__media__img\",\n { \"hds-card__img__scale\": variant === \"scale\" },\n className as undefined,\n )}\n ref={ref}\n />\n );\n },\n);\nCardMediaImg.displayName = \"Card.MediaImg\";\n\nexport const CardBody = forwardRef<HTMLDivElement, CardBaseProps>(\n ({ asChild, className, children, ...rest }, ref) => {\n const Component = asChild ? Slot : \"div\";\n return (\n <Component {...rest} className={clsx(\"hds-card__body\", className as undefined)} ref={ref}>\n <div className={clsx(\"hds-card__centerbody\", className as undefined)}>{children}</div>\n </Component>\n );\n },\n);\nCardBody.displayName = \"Card.Body\";\n\nexport const CardBodyHeader = forwardRef<\n HTMLHeadingElement,\n CardBaseProps &\n (\n | {\n /**\n * Heading level of the card heading\n */\n as: \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\n asChild?: never;\n }\n | {\n asChild: true;\n as?: never;\n }\n )\n>(({ as: Tag, asChild, className, children, ...rest }, ref) => {\n const Component = asChild ? Slot : Tag;\n return (\n <Component\n {...rest}\n className={clsx(\"hds-card__body-header\", className as undefined)}\n ref={ref}\n >\n {children}\n </Component>\n );\n});\nCardBodyHeader.displayName = \"Card.BodyHeader\";\n\nexport const CardBodyHeaderOverline = forwardRef<HTMLDivElement, CardBaseProps>(\n ({ asChild, className, children, ...rest }, ref) => {\n const Component = asChild ? Slot : \"span\";\n return (\n <Component\n {...rest}\n className={clsx(\"hds-card__body-header-overline\", className as undefined)}\n ref={ref}\n >\n {children}\n </Component>\n );\n },\n);\nCardBodyHeaderOverline.displayName = \"Card.BodyHeaderOverline\";\n\nexport const CardBodyHeaderTitle = forwardRef<HTMLDivElement, CardBaseProps>(\n ({ asChild, className, children, ...rest }, ref) => {\n const Component = asChild ? Slot : \"div\";\n return (\n <Component\n {...rest}\n className={clsx(\"hds-card__body-header-title\", className as undefined)}\n ref={ref}\n >\n {children}\n </Component>\n );\n },\n);\nCardBodyHeaderTitle.displayName = \"Card.BodyHeaderTitle\";\n\nexport const CardBodyDescription = forwardRef<HTMLParagraphElement, CardBaseProps>(\n ({ asChild, className, children, ...rest }, ref) => {\n const Component = asChild ? Slot : \"p\";\n return (\n <Component\n {...rest}\n className={clsx(\"hds-card__body-description\", className as undefined)}\n ref={ref}\n >\n {children}\n </Component>\n );\n },\n);\nCardBodyDescription.displayName = \"Card.BodyDescription\";\n\nexport const CardBodyAction = forwardRef<HTMLDivElement, CardBaseProps>(\n ({ asChild, className, children, ...rest }, ref) => {\n const Component = asChild ? Slot : \"div\";\n return (\n <Component\n {...rest}\n className={clsx(\"hds-card__body-action\", className as undefined)}\n ref={ref}\n >\n {children}\n </Component>\n );\n },\n);\nCardBodyAction.displayName = \"Card.BodyAction\";\n\nexport const CardBodyActionRow = forwardRef<HTMLDivElement, CardBaseProps>(\n ({ asChild, className, children, ...rest }, ref) => {\n const Component = asChild ? Slot : \"div\";\n return (\n <Component\n {...rest}\n className={clsx(\"hds-card__body-action-row\", className as undefined)}\n ref={ref}\n >\n {children}\n </Component>\n );\n },\n);\nCardBodyActionRow.displayName = \"Card.BodyActionRow\";\n\ninterface CardBodyActionArrowProps extends React.HTMLAttributes<HTMLSpanElement> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n\n /**\n * Set direction of the arrow\n *\n * @default \"right\"\n */\n direction?: \"right\" | \"up-right\";\n}\nexport const CardBodyActionArrow = forwardRef<HTMLSpanElement, CardBodyActionArrowProps>(\n ({ asChild, className, direction, ...rest }, ref) => {\n const Component = asChild ? Slot : \"span\";\n return (\n <Component\n {...rest}\n className={clsx(\n \"hds-card__body-action-arrow\",\n { \"hds-card__body-action-arrow-up-right\": direction === \"up-right\" },\n className as undefined,\n )}\n ref={ref}\n />\n );\n },\n);\nCardBodyActionArrow.displayName = \"Card.BodyActionArrow\";\n\nexport interface CardBaseProps extends React.HTMLAttributes<HTMLDivElement> {\n children: ReactNode;\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\nexport interface CardSlimAndMiniatureProps extends CardBaseProps {\n /**\n * Change the default rendered element for Card.\n */\n as?: \"section\" | \"div\" | \"article\" | \"aside\";\n /**\n * Allows for a horizontal variant for sizes above small.\n *\n * @default \"slim\"\n */\n variant?: \"slim\" | \"miniature\";\n /**\n * The color of the card.\n *\n * @default \"lighter-brand\"\n * */\n color?: \"white\" | \"lighter-brand\" | \"light-grey-fill\";\n\n /* Only fullwidth or focus cards can have images to the left or right of the text: */\n imagePosition?: never;\n}\n\nexport interface CardFocusProps extends CardBaseProps {\n as?: \"section\" | \"div\" | \"article\" | \"aside\";\n variant: \"focus\";\n color?: \"darker\" | \"dark\";\n /**\n * fullwidth or focus cards can have images to the left or right of the text.\n *\n * @default \"left\"\n * */\n imagePosition?: \"left\" | \"right\";\n}\n\nexport interface CardFullwidthProps extends CardBaseProps {\n as?: \"section\" | \"div\" | \"article\" | \"aside\";\n variant: \"full-width\";\n color: \"white\" | \"lighter-brand\" | \"light-grey-fill\";\n /**\n * fullwidth or focus cards can have images to the left or right of the text.\n *\n * @default \"left\"\n * */\n imagePosition?: \"left\" | \"right\";\n}\n\nexport type CardProps = CardSlimAndMiniatureProps | CardFocusProps | CardFullwidthProps;\n\nexport const Card = forwardRef<HTMLDivElement, CardProps>(\n (\n {\n as: Tag = \"section\",\n asChild,\n className,\n children,\n variant = \"slim\",\n color,\n imagePosition,\n ...rest\n },\n ref,\n ) => {\n const Component = asChild ? Slot : Tag;\n const effectiveColor = variant === \"focus\" && !color ? \"darker\" : color;\n return (\n <Component\n {...rest}\n className={clsx(\n \"hds-card\",\n { \"hds-card--full-width\": variant === \"full-width\" },\n { \"hds-card--miniature\": variant === \"miniature\" },\n { \"hds-card--focus\": variant === \"focus\" },\n { \"hds-card--slim\": variant === \"slim\" },\n { \"hds-card--color-white\": effectiveColor === \"white\" },\n { \"hds-card--color-light-grey-fill\": effectiveColor === \"light-grey-fill\" },\n { \"hds-card--color-dark\": effectiveColor === \"dark\" },\n { \"hds-card--color-darker\": effectiveColor === \"darker\" },\n { \"hds-card--image-position-right\": imagePosition === \"right\" },\n className as undefined,\n )}\n ref={ref}\n >\n {variant === \"full-width\" || variant === \"focus\" ? (\n <div className={clsx(\"hds-card__layoutwrapper\", className as undefined)}>{children}</div>\n ) : (\n children\n )}\n </Component>\n );\n },\n) as CardType;\nCard.displayName = \"Card\";\n\nCard.Media = CardMedia;\nCard.MediaImg = CardMediaImg;\nCard.Body = CardBody;\nCard.BodyHeader = CardBodyHeader;\nCard.BodyHeaderOverline = CardBodyHeaderOverline;\nCard.BodyHeaderTitle = CardBodyHeaderTitle;\nCard.BodyDescription = CardBodyDescription;\nCard.BodyAction = CardBodyAction;\nCard.BodyActionRow = CardBodyActionRow;\nCard.BodyActionArrow = CardBodyActionArrow;\n\ntype CardType = ReturnType<typeof forwardRef<HTMLDivElement, CardProps>> & {\n Media: typeof CardMedia;\n MediaImg: typeof CardMediaImg;\n Body: typeof CardBody;\n BodyHeader: typeof CardBodyHeader;\n BodyHeaderOverline: typeof CardBodyHeaderOverline;\n BodyHeaderTitle: typeof CardBodyHeaderTitle;\n BodyDescription: typeof CardBodyDescription;\n BodyAction: typeof CardBodyAction;\n BodyActionRow: typeof CardBodyActionRow;\n Bod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U;AAAA,MACV;AAAA,MACA;AAAA,IApRN,IA6QI,IAQK,iBARL,IAQK;AAAA,MAPH;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAKF,UAAM,YAAY,UAAU,yBAAO;AACnC,UAAM,iBAAiB,YAAY,WAAW,CAAC,QAAQ,WAAW;AAClE,WACE;AAAA,MAAC;AAAA,uCACK,OADL;AAAA,QAEC,eAAW;AAAA,UACT;AAAA,UACA,EAAE,wBAAwB,YAAY,aAAa;AAAA,UACnD,EAAE,uBAAuB,YAAY,YAAY;AAAA,UACjD,EAAE,mBAAmB,YAAY,QAAQ;AAAA,UACzC,EAAE,kBAAkB,YAAY,OAAO;AAAA,UACvC,EAAE,yBAAyB,mBAAmB,QAAQ;AAAA,UACtD,EAAE,mCAAmC,mBAAmB,kBAAkB;AAAA,UAC1E,EAAE,wBAAwB,mBAAmB,OAAO;AAAA,UACpD,EAAE,0BAA0B,mBAAmB,SAAS;AAAA,UACxD,EAAE,kCAAkC,kBAAkB,QAAQ;AAAA,UAC9D;AAAA,QACF;AAAA,QACA;AAAA,QAEC,sBAAY,gBAAgB,YAAY,UACvC,4CAAC,SAAI,eAAW,6BAAK,2BAA2B,SAAsB,GAAI,UAAS,IAEnF;AAAA;AAAA,IAEJ;AAAA,EAEJ;AACF;AACA,KAAK,cAAc;AAEnB,KAAK,QAAQ;AACb,KAAK,WAAW;AAChB,KAAK,OAAO;AACZ,KAAK,aAAa;AAClB,KAAK,qBAAqB;AAC1B,KAAK,kBAAkB;AACvB,KAAK,kBAAkB;AACvB,KAAK,aAAa;AAClB,KAAK,gBAAgB;AACrB,KAAK,kBAAkB;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/card/card.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { forwardRef } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot } from \"@radix-ui/react-slot\";\n\nexport const CardMedia = forwardRef<HTMLDivElement, CardBaseProps>(\n ({ asChild, className, children, ...rest }, ref) => {\n const Component = asChild ? Slot : \"div\";\n return (\n <Component {...rest} className={clsx(\"hds-card__media\", className as undefined)} ref={ref}>\n {children}\n </Component>\n );\n },\n);\nCardMedia.displayName = \"Card.Media\";\n\nexport interface CardImageMediaProps extends React.ImgHTMLAttributes<HTMLImageElement> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n /**\n * Define image scaling behavior when the image are varies in both width and height across different page breaks and sizes of the card.\n * \"crop\": Image always fills the available space.\n * If the aspect ratio doesn't match, then the top/bottom or left/right edges are cropped away.\n * \"scale\": No cropping, image scales to the maximum size available and centers.\n * If the aspect ratio doesn't match, then the background will show on the top/bottom or left/right sides of the image.\n *\n * @default \"crop\"\n */\n variant?: \"crop\" | \"scale\";\n}\nexport const CardMediaImg = forwardRef<HTMLImageElement, CardImageMediaProps>(\n ({ asChild, variant, className, ...rest }, ref) => {\n const Component = asChild ? Slot : \"img\";\n return (\n <Component\n {...rest}\n className={clsx(\n \"hds-card__media__img\",\n { \"hds-card__img__scale\": variant === \"scale\" },\n className as undefined,\n )}\n ref={ref}\n />\n );\n },\n);\nCardMediaImg.displayName = \"Card.MediaImg\";\n\nexport const CardBody = forwardRef<HTMLDivElement, CardBaseProps>(\n ({ asChild, className, children, ...rest }, ref) => {\n const Component = asChild ? Slot : \"div\";\n return (\n <Component {...rest} className={clsx(\"hds-card__body\", className as undefined)} ref={ref}>\n <div className={clsx(\"hds-card__centerbody\", className as undefined)}>{children}</div>\n </Component>\n );\n },\n);\nCardBody.displayName = \"Card.Body\";\n\nexport const CardBodyHeader = forwardRef<\n HTMLHeadingElement,\n CardBaseProps &\n (\n | {\n /**\n * Heading level of the card heading\n */\n as: \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\n asChild?: never;\n }\n | {\n asChild: true;\n as?: never;\n }\n )\n>(({ as: Tag, asChild, className, children, ...rest }, ref) => {\n const Component = asChild ? Slot : Tag;\n return (\n <Component\n {...rest}\n className={clsx(\"hds-card__body-header\", className as undefined)}\n ref={ref}\n >\n {children}\n </Component>\n );\n});\nCardBodyHeader.displayName = \"Card.BodyHeader\";\n\nexport const CardBodyHeaderOverline = forwardRef<HTMLDivElement, CardBaseProps>(\n ({ asChild, className, children, ...rest }, ref) => {\n const Component = asChild ? Slot : \"span\";\n return (\n <Component\n {...rest}\n className={clsx(\"hds-card__body-header-overline\", className as undefined)}\n ref={ref}\n >\n {children}\n </Component>\n );\n },\n);\nCardBodyHeaderOverline.displayName = \"Card.BodyHeaderOverline\";\n\nexport const CardBodyHeaderTitle = forwardRef<HTMLDivElement, CardBaseProps>(\n ({ asChild, className, children, ...rest }, ref) => {\n const Component = asChild ? Slot : \"div\";\n return (\n <Component\n {...rest}\n className={clsx(\"hds-card__body-header-title\", className as undefined)}\n ref={ref}\n >\n {children}\n </Component>\n );\n },\n);\nCardBodyHeaderTitle.displayName = \"Card.BodyHeaderTitle\";\n\nexport const CardBodyDescription = forwardRef<HTMLParagraphElement, CardBaseProps>(\n ({ asChild, className, children, ...rest }, ref) => {\n const Component = asChild ? Slot : \"p\";\n return (\n <Component\n {...rest}\n className={clsx(\"hds-card__body-description\", className as undefined)}\n ref={ref}\n >\n {children}\n </Component>\n );\n },\n);\nCardBodyDescription.displayName = \"Card.BodyDescription\";\n\nexport const CardBodyAction = forwardRef<HTMLDivElement, CardBaseProps>(\n ({ asChild, className, children, ...rest }, ref) => {\n const Component = asChild ? Slot : \"div\";\n return (\n <Component\n {...rest}\n className={clsx(\"hds-card__body-action\", className as undefined)}\n ref={ref}\n >\n {children}\n </Component>\n );\n },\n);\nCardBodyAction.displayName = \"Card.BodyAction\";\n\nexport const CardBodyActionRow = forwardRef<HTMLDivElement, CardBaseProps>(\n ({ asChild, className, children, ...rest }, ref) => {\n const Component = asChild ? Slot : \"div\";\n return (\n <Component\n {...rest}\n className={clsx(\"hds-card__body-action-row\", className as undefined)}\n ref={ref}\n >\n {children}\n </Component>\n );\n },\n);\nCardBodyActionRow.displayName = \"Card.BodyActionRow\";\n\ninterface CardBodyActionArrowProps extends React.HTMLAttributes<HTMLSpanElement> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n\n /**\n * Set direction of the arrow\n *\n * @default \"right\"\n */\n direction?: \"right\" | \"up-right\";\n}\nexport const CardBodyActionArrow = forwardRef<HTMLSpanElement, CardBodyActionArrowProps>(\n ({ asChild, className, direction, ...rest }, ref) => {\n const Component = asChild ? Slot : \"span\";\n return (\n <Component\n {...rest}\n className={clsx(\n \"hds-card__body-action-arrow\",\n { \"hds-card__body-action-arrow-up-right\": direction === \"up-right\" },\n className as undefined,\n )}\n ref={ref}\n />\n );\n },\n);\nCardBodyActionArrow.displayName = \"Card.BodyActionArrow\";\n\nexport interface CardBaseProps extends React.HTMLAttributes<HTMLDivElement> {\n children: ReactNode;\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\n/**\n * @deprecated This interface is deprecated and will be removed in a future release.\n * Use `CardSlimAndMiniatureProps` with props `data-color` and `theme` instead.\n */\nexport interface CardSlimAndMiniaturePropsDeprecated extends CardBaseProps {\n /**\n * Change the default rendered element for Card.\n */\n as?: \"section\" | \"div\" | \"article\" | \"aside\";\n /**\n * Allows for a horizontal variant for sizes above small.\n *\n * @default \"slim\"\n */\n variant?: \"slim\" | \"miniature\";\n \"data-color\"?: never;\n theme?: never;\n /**\n * @deprecated\n * Use props `data-color` and `theme` instead.\n * These colors will be removed in a future release.\n */\n color?: \"white\" | \"lighter-brand\" | \"light-grey-fill\";\n\n /* Only fullwidth or focus cards can have images to the left or right of the text: */\n imagePosition?: never;\n}\n\nexport interface CardSlimAndMiniatureProps extends CardBaseProps {\n /**\n * Change the default rendered element for Card.\n */\n as?: \"section\" | \"div\" | \"article\" | \"aside\";\n /**\n * Allows for a horizontal variant for sizes above small.\n *\n * @default \"slim\"\n */\n variant?: \"slim\" | \"miniature\";\n /**\n * Set theme for card\n * @default \"default\"\n */\n theme?: \"default\" | \"tinted\" | \"base\";\n /**\n * Set data-color for card.\n */\n \"data-color\"?: \"neutral\" | \"posten\" | \"bring\";\n /* Only fullwidth or focus cards can have images to the left or right of the text: */\n imagePosition?: never;\n}\n\n/**\n * @deprecated Use Full-width card instead\n */\nexport interface CardFocusProps extends CardBaseProps {\n /**\n * Change the default rendered element for Card.\n */\n as?: \"section\" | \"div\" | \"article\" | \"aside\";\n /** @deprecated Use Full-width card instead */\n variant: \"focus\";\n /**\n * @deprecated\n * Use props `data-color` and `theme` instead.\n * The color prop will be removed in a future release.\n */\n color?: \"darker\" | \"dark\";\n \"data-color\"?: never;\n theme?: never;\n /**\n * fullwidth or focus cards can have images to the left or right of the text.\n *\n * @default \"left\"\n * */\n imagePosition?: \"left\" | \"right\";\n}\n\n/**\n * @deprecated This interface is deprecated and will be removed in a future release.\n * Use `CardSlimAndMiniatureProps` with props `data-color` and `theme` instead.\n */\nexport interface CardFullwidthPropsDeprecated extends CardBaseProps {\n /**\n * Change the default rendered element for Card.\n */\n as?: \"section\" | \"div\" | \"article\" | \"aside\";\n variant: \"full-width\";\n \"data-color\"?: never;\n theme?: never;\n /**\n * @deprecated\n * Use `data-color` and `theme` instead.\n * The color prop will be removed in a future release.\n */\n color: \"white\" | \"lighter-brand\" | \"light-grey-fill\";\n /**\n * fullwidth or focus cards can have images to the left or right of the text.\n *\n * @default \"left\"\n * */\n imagePosition?: \"left\" | \"right\";\n}\n\nexport interface CardFullwidthProps extends CardBaseProps {\n /**\n * Change the default rendered element for Card.\n */\n as?: \"section\" | \"div\" | \"article\" | \"aside\";\n variant: \"full-width\";\n /**\n * Set theme for card\n * @default \"default\"\n */\n theme?: \"default\" | \"tinted\" | \"base\";\n /**\n * Set data-color for card.\n */\n \"data-color\"?: \"neutral\" | \"posten\" | \"bring\";\n /**\n * fullwidth or focus cards can have images to the left or right of the text.\n *\n * @default \"left\"\n * */\n imagePosition?: \"left\" | \"right\";\n}\n\nexport type CardProps =\n | CardSlimAndMiniatureProps\n | CardFocusProps\n | CardFullwidthProps\n | CardSlimAndMiniaturePropsDeprecated\n | CardFullwidthPropsDeprecated;\n\n/**\n * Converts deprecated colors to current colors\n * @param color\n * @returns\n */\nconst convertDeprecatedColor = (\n color: string | undefined,\n): Partial<{\n theme: NonNullable<CardSlimAndMiniatureProps[\"theme\"]>;\n dataColor: NonNullable<CardSlimAndMiniatureProps[\"data-color\"]>;\n dataColorScheme: \"light\" | \"dark\";\n}> => {\n switch (color) {\n case \"lighter-brand\":\n return { theme: \"default\" };\n case \"light-grey-fill\":\n return { theme: \"base\", dataColor: \"neutral\" };\n case \"white\":\n return { theme: \"default\", dataColor: \"neutral\" };\n case \"dark\":\n return { theme: \"base\" };\n case \"darker\":\n return { theme: \"tinted\", dataColorScheme: \"dark\" };\n default:\n return {};\n }\n};\n\nexport const Card = forwardRef<HTMLDivElement, CardProps>(\n (\n {\n as: Tag = \"section\",\n asChild,\n className,\n children,\n variant = \"slim\",\n \"data-color\": dataColorAttr,\n theme = \"default\",\n color,\n imagePosition,\n ...rest\n },\n ref,\n ) => {\n const Component = asChild ? Slot : Tag;\n\n const {\n theme: themeFromDeprecated,\n dataColor: dataColorFromDeprecated,\n dataColorScheme: dataColorSchemeFromDeprecated,\n } = convertDeprecatedColor(color ?? (variant === \"focus\" ? \"darker\" : undefined));\n\n return (\n <Component\n {...rest}\n {...(dataColorAttr ? { \"data-color\": dataColorAttr } : {})}\n {...(dataColorFromDeprecated ? { \"data-color\": dataColorFromDeprecated } : {})}\n {...(dataColorSchemeFromDeprecated\n ? { \"data-color-scheme\": dataColorSchemeFromDeprecated }\n : {})}\n className={clsx(\n \"hds-card\",\n { \"hds-card--full-width\": variant === \"full-width\" },\n { \"hds-card--miniature\": variant === \"miniature\" },\n { \"hds-card--focus\": variant === \"focus\" }, // @deprecated\n { \"hds-card--slim\": variant === \"slim\" },\n { \"hds-card--theme-default\": (themeFromDeprecated ?? theme) === \"default\" },\n { \"hds-card--theme-tinted\": (themeFromDeprecated ?? theme) === \"tinted\" },\n { \"hds-card--theme-base\": (themeFromDeprecated ?? theme) === \"base\" },\n { \"hds-card--image-position-right\": imagePosition === \"right\" },\n className as undefined,\n )}\n ref={ref}\n >\n {variant === \"full-width\" || variant === \"focus\" ? (\n <div className={clsx(\"hds-card__layoutwrapper\", className as undefined)}>{children}</div>\n ) : (\n children\n )}\n </Component>\n );\n },\n) as CardType;\nCard.displayName = \"Card\";\n\nCard.Media = CardMedia;\nCard.MediaImg = CardMediaImg;\nCard.Body = CardBody;\nCard.BodyHeader = CardBodyHeader;\nCard.BodyHeaderOverline = CardBodyHeaderOverline;\nCard.BodyHeaderTitle = CardBodyHeaderTitle;\nCard.BodyDescription = CardBodyDescription;\nCard.BodyAction = CardBodyAction;\nCard.BodyActionRow = CardBodyActionRow;\nCard.BodyActionArrow = CardBodyActionArrow;\n\ntype CardType = ReturnType<typeof forwardRef<HTMLDivElement, CardProps>> & {\n Media: typeof CardMedia;\n MediaImg: typeof CardMediaImg;\n Body: typeof CardBody;\n BodyHeader: typeof CardBodyHeader;\n BodyHeaderOverline: typeof CardBodyHeaderOverline;\n BodyHeaderTitle: typeof CardBodyHeaderTitle;\n BodyDescription: typeof CardBodyDescription;\n BodyAction: typeof CardBodyAction;\n BodyActionRow: typeof CardBodyActionRow;\n BodyActionArrow: typeof CardBodyActionArrow;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA2B;AAC3B,6BAAqB;AACrB,wBAAqB;AAMf;AAJC,IAAM,gBAAY;AAAA,EACvB,CAAC,IAA2C,QAAQ;AAAnD,iBAAE,WAAS,WAAW,SANzB,IAMG,IAAmC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;AAC1B,KAAK,kBAAkB;AACvB,KAAK,kBAAkB;AACvB,KAAK,aAAa;AAClB,KAAK,gBAAgB;AACrB,KAAK,kBAAkB;","names":[]}
|
package/dist/card/card.mjs
CHANGED
package/dist/card/index.js
CHANGED
|
@@ -207,6 +207,22 @@ var CardBodyActionArrow = (0, import_react.forwardRef)(
|
|
|
207
207
|
}
|
|
208
208
|
);
|
|
209
209
|
CardBodyActionArrow.displayName = "Card.BodyActionArrow";
|
|
210
|
+
var convertDeprecatedColor = (color) => {
|
|
211
|
+
switch (color) {
|
|
212
|
+
case "lighter-brand":
|
|
213
|
+
return { theme: "default" };
|
|
214
|
+
case "light-grey-fill":
|
|
215
|
+
return { theme: "base", dataColor: "neutral" };
|
|
216
|
+
case "white":
|
|
217
|
+
return { theme: "default", dataColor: "neutral" };
|
|
218
|
+
case "dark":
|
|
219
|
+
return { theme: "base" };
|
|
220
|
+
case "darker":
|
|
221
|
+
return { theme: "tinted", dataColorScheme: "dark" };
|
|
222
|
+
default:
|
|
223
|
+
return {};
|
|
224
|
+
}
|
|
225
|
+
};
|
|
210
226
|
var Card = (0, import_react.forwardRef)(
|
|
211
227
|
(_a, ref) => {
|
|
212
228
|
var _b = _a, {
|
|
@@ -215,6 +231,8 @@ var Card = (0, import_react.forwardRef)(
|
|
|
215
231
|
className,
|
|
216
232
|
children,
|
|
217
233
|
variant = "slim",
|
|
234
|
+
"data-color": dataColorAttr,
|
|
235
|
+
theme = "default",
|
|
218
236
|
color,
|
|
219
237
|
imagePosition
|
|
220
238
|
} = _b, rest = __objRest(_b, [
|
|
@@ -223,24 +241,30 @@ var Card = (0, import_react.forwardRef)(
|
|
|
223
241
|
"className",
|
|
224
242
|
"children",
|
|
225
243
|
"variant",
|
|
244
|
+
"data-color",
|
|
245
|
+
"theme",
|
|
226
246
|
"color",
|
|
227
247
|
"imagePosition"
|
|
228
248
|
]);
|
|
229
249
|
const Component = asChild ? import_react_slot.Slot : Tag;
|
|
230
|
-
const
|
|
250
|
+
const {
|
|
251
|
+
theme: themeFromDeprecated,
|
|
252
|
+
dataColor: dataColorFromDeprecated,
|
|
253
|
+
dataColorScheme: dataColorSchemeFromDeprecated
|
|
254
|
+
} = convertDeprecatedColor(color != null ? color : variant === "focus" ? "darker" : void 0);
|
|
231
255
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
232
256
|
Component,
|
|
233
|
-
__spreadProps(__spreadValues({}, rest), {
|
|
257
|
+
__spreadProps(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, rest), dataColorAttr ? { "data-color": dataColorAttr } : {}), dataColorFromDeprecated ? { "data-color": dataColorFromDeprecated } : {}), dataColorSchemeFromDeprecated ? { "data-color-scheme": dataColorSchemeFromDeprecated } : {}), {
|
|
234
258
|
className: (0, import_typed_classname.clsx)(
|
|
235
259
|
"hds-card",
|
|
236
260
|
{ "hds-card--full-width": variant === "full-width" },
|
|
237
261
|
{ "hds-card--miniature": variant === "miniature" },
|
|
238
262
|
{ "hds-card--focus": variant === "focus" },
|
|
263
|
+
// @deprecated
|
|
239
264
|
{ "hds-card--slim": variant === "slim" },
|
|
240
|
-
{ "hds-card--
|
|
241
|
-
{ "hds-card--
|
|
242
|
-
{ "hds-card--
|
|
243
|
-
{ "hds-card--color-darker": effectiveColor === "darker" },
|
|
265
|
+
{ "hds-card--theme-default": (themeFromDeprecated != null ? themeFromDeprecated : theme) === "default" },
|
|
266
|
+
{ "hds-card--theme-tinted": (themeFromDeprecated != null ? themeFromDeprecated : theme) === "tinted" },
|
|
267
|
+
{ "hds-card--theme-base": (themeFromDeprecated != null ? themeFromDeprecated : theme) === "base" },
|
|
244
268
|
{ "hds-card--image-position-right": imagePosition === "right" },
|
|
245
269
|
className
|
|
246
270
|
),
|