@ogcio/design-system-react 1.19.0 → 1.21.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.
Files changed (76) hide show
  1. package/dist/card/card-legacy.d.ts +1 -1
  2. package/dist/card/card-legacy.js +12 -12
  3. package/dist/card/card-next.d.ts +2 -3
  4. package/dist/card/card-next.js +226 -61
  5. package/dist/card/card.js +17 -16
  6. package/dist/card/types.d.ts +20 -30
  7. package/dist/forms/form-field/form-field.js +58 -60
  8. package/dist/header/components/header-menu.d.ts +1 -2
  9. package/dist/header/header-legacy.d.ts +2 -0
  10. package/dist/header/header-legacy.js +223 -0
  11. package/dist/header/header-next/components/header-logo.d.ts +2 -0
  12. package/dist/header/header-next/components/header-logo.js +19 -0
  13. package/dist/header/header-next/components/header-title.d.ts +2 -0
  14. package/dist/header/header-next/components/header-title.js +29 -0
  15. package/dist/header/header-next/components/menu/components/header-menu-item-button.d.ts +2 -0
  16. package/dist/header/header-next/components/menu/components/header-menu-item-button.js +42 -0
  17. package/dist/header/header-next/components/menu/components/header-menu-item-link.d.ts +8 -0
  18. package/dist/header/header-next/components/menu/components/header-menu-item-link.js +72 -0
  19. package/dist/header/header-next/components/menu/components/header-menu-item-separator.d.ts +3 -0
  20. package/dist/header/header-next/components/menu/components/header-menu-item-separator.js +34 -0
  21. package/dist/header/header-next/components/menu/components/header-menu-item-slot.d.ts +5 -0
  22. package/dist/header/header-next/components/menu/components/header-menu-item-slot.js +42 -0
  23. package/dist/header/header-next/components/menu/header-menu-context.d.ts +7 -0
  24. package/dist/header/header-next/components/menu/header-menu-context.js +23 -0
  25. package/dist/header/header-next/components/menu/header-primary-menu.d.ts +3 -0
  26. package/dist/header/header-next/components/menu/header-primary-menu.js +63 -0
  27. package/dist/header/header-next/components/menu/header-secondary-menu.d.ts +3 -0
  28. package/dist/header/header-next/components/menu/header-secondary-menu.js +52 -0
  29. package/dist/header/header-next/header-context.d.ts +13 -0
  30. package/dist/header/header-next/header-context.js +31 -0
  31. package/dist/header/header-next/header-next.d.ts +7 -0
  32. package/dist/header/header-next/header-next.js +75 -0
  33. package/dist/header/header-next/index.d.ts +11 -0
  34. package/dist/header/header-next/index.js +27 -0
  35. package/dist/header/header.d.ts +2 -2
  36. package/dist/header/header.js +17 -219
  37. package/dist/header/types.d.ts +84 -4
  38. package/dist/header/variants.d.ts +2 -2
  39. package/dist/header/variants.js +1 -1
  40. package/dist/hooks/use-toggle-map.d.ts +15 -0
  41. package/dist/hooks/use-toggle-map.js +45 -0
  42. package/dist/icon/icons.d.ts +2 -2
  43. package/dist/icon/icons.js +2 -0
  44. package/dist/index.d.ts +3 -2
  45. package/dist/index.js +210 -178
  46. package/dist/input-checkbox/input-checkbox.d.ts +1 -1
  47. package/dist/input-checkbox/input-checkbox.js +65 -48
  48. package/dist/input-radio/input-radio.d.ts +1 -1
  49. package/dist/input-radio/input-radio.js +50 -44
  50. package/dist/input-radio/types.d.ts +0 -1
  51. package/dist/input-radio/types.js +0 -1
  52. package/dist/list-item/list-item.d.ts +3 -2
  53. package/dist/list-item/list-item.js +15 -6
  54. package/dist/modal/types.d.ts +5 -3
  55. package/dist/radio/types.d.ts +0 -1
  56. package/dist/styles.css +2 -2
  57. package/dist/summary-list/index.d.ts +6 -0
  58. package/dist/summary-list/index.js +12 -0
  59. package/dist/summary-list/summary-list-action.d.ts +5 -0
  60. package/dist/summary-list/summary-list-action.js +18 -0
  61. package/dist/summary-list/summary-list-context.d.ts +2 -0
  62. package/dist/summary-list/summary-list-context.js +20 -0
  63. package/dist/summary-list/summary-list-header.d.ts +5 -0
  64. package/dist/summary-list/summary-list-header.js +68 -0
  65. package/dist/summary-list/summary-list-row.d.ts +6 -0
  66. package/dist/summary-list/summary-list-row.js +63 -0
  67. package/dist/summary-list/summary-list-value.d.ts +5 -0
  68. package/dist/summary-list/summary-list-value.js +17 -0
  69. package/dist/summary-list/summary-list.d.ts +2 -11
  70. package/dist/summary-list/summary-list.js +37 -43
  71. package/dist/summary-list/types.d.ts +15 -11
  72. package/dist/utilities.d.ts +3 -0
  73. package/dist/utilities.js +17 -7
  74. package/dist/utils/utilities.d.ts +3 -0
  75. package/dist/utils/utilities.js +34 -25
  76. package/package.json +4 -4
@@ -1,5 +1,5 @@
1
1
  import { CardProps } from './types.js';
2
2
  export declare const CardLegacy: {
3
- ({ type, title, inset, subTitle, media, content, action, href, tag, dataTestid, titleAsChild, children, }: CardProps): import("react/jsx-runtime").JSX.Element;
3
+ ({ type, title, inset, subTitle, media, content, action, href, tag, titleAsChild, children, ...props }: CardProps): import("react/jsx-runtime").JSX.Element;
4
4
  displayName: string;
5
5
  };
@@ -1,21 +1,21 @@
1
1
  import { jsxs as i, jsx as e } from "react/jsx-runtime";
2
- import { Button as b } from "../button/button.js";
2
+ import { Button as k } from "../button/button.js";
3
3
  import { translate as c } from "../i18n/utility.js";
4
4
  import { Link as u } from "../link/link.js";
5
- import { CardNext as k, CardMedia as T, CardContainer as L, CardHeader as V, CardTitle as $, CardSubtitle as j, CardTag as A, CardDescription as B, CardAction as H } from "./card-next.js";
5
+ import { CardNext as b, CardMedia as L, CardContainer as T, CardHeader as V, CardTitle as $, CardSubtitle as j, CardTag as A, CardDescription as B, CardAction as H } from "./card-next.js";
6
6
  const N = ({
7
7
  type: C = "vertical",
8
8
  title: d,
9
- inset: t = "none",
10
- subTitle: p,
9
+ inset: p = "none",
10
+ subTitle: t,
11
11
  media: o,
12
12
  content: m,
13
13
  action: h,
14
14
  href: n,
15
15
  tag: l,
16
- dataTestid: s,
17
16
  titleAsChild: a,
18
- children: y
17
+ children: s,
18
+ ...y
19
19
  }) => {
20
20
  const f = () => !d || !n && !a ? d || "" : /* @__PURE__ */ e(
21
21
  u,
@@ -26,7 +26,7 @@ const N = ({
26
26
  title: d,
27
27
  defaultValue: `Card link: ${d}`
28
28
  }),
29
- children: a ? y : d
29
+ children: a ? s : d
30
30
  }
31
31
  ), x = (r) => r.type === "link" ? /* @__PURE__ */ e(
32
32
  u,
@@ -39,7 +39,7 @@ const N = ({
39
39
  children: r.children
40
40
  }
41
41
  ) : /* @__PURE__ */ e(
42
- b,
42
+ k,
43
43
  {
44
44
  ...r,
45
45
  "aria-label": c("card.actionButton", {
@@ -49,12 +49,12 @@ const N = ({
49
49
  children: r.children
50
50
  }
51
51
  );
52
- return /* @__PURE__ */ i(k, { inset: t, type: C, dataTestid: s, children: [
53
- o && /* @__PURE__ */ e(T, { media: o, href: n }),
54
- /* @__PURE__ */ i(L, { inset: t, children: [
52
+ return /* @__PURE__ */ i(b, { inset: p, type: C, ...y, children: [
53
+ o && /* @__PURE__ */ e(L, { media: o, href: n }),
54
+ /* @__PURE__ */ i(T, { children: [
55
55
  /* @__PURE__ */ i(V, { children: [
56
56
  /* @__PURE__ */ e($, { children: f() }),
57
- /* @__PURE__ */ e(j, { children: p }),
57
+ t && /* @__PURE__ */ e(j, { children: t }),
58
58
  l && /* @__PURE__ */ e(A, { text: l.text, type: l.type })
59
59
  ] }),
60
60
  /* @__PURE__ */ e(B, { children: m }),
@@ -1,13 +1,12 @@
1
1
  import { Context, FC } from 'react';
2
- import { TagProps } from '../tag/tag.js';
3
- import { CardDescriptionProps, CardContainerProps, CardActionProps, CardHeaderProps, CardMediaProps, CardNextProps, CardSubtitleProps, CardTitleProps } from './types.js';
2
+ import { CardDescriptionProps, CardContainerProps, CardActionProps, CardHeaderProps, CardMediaProps, CardNextProps, CardSubtitleProps, CardTitleProps, CardTagProps } from './types.js';
4
3
  export declare function useRequiredContext(context: Context<boolean>, componentName: string, parentName: string): true;
5
4
  export declare const CardNext: FC<CardNextProps>;
6
5
  export declare const CardMedia: FC<CardMediaProps>;
7
6
  export declare const CardContainer: FC<CardContainerProps>;
8
7
  export declare const CardTitle: FC<CardTitleProps>;
9
8
  export declare const CardSubtitle: FC<CardSubtitleProps>;
10
- export declare const CardTag: FC<TagProps>;
9
+ export declare const CardTag: FC<CardTagProps>;
11
10
  export declare const CardHeader: FC<CardHeaderProps>;
12
11
  export declare const CardDescription: FC<CardDescriptionProps>;
13
12
  export declare const CardAction: FC<CardActionProps>;
@@ -1,85 +1,250 @@
1
1
  "use client";
2
2
  import "@ogcio/design-system-react/browser-check";
3
- import { jsx as r, jsxs as g } from "react/jsx-runtime";
4
- import { createContext as l, Children as m, isValidElement as f, useContext as p, useMemo as v } from "react";
5
- import { Icon as N } from "../icon/icon.js";
6
- import { Paragraph as h } from "../paragraph/paragraph.js";
7
- import { Tag as x } from "../tag/tag.js";
8
- const u = l(!1), o = l(!1), c = l(!1);
9
- function i(e, a, n) {
10
- if (!p(e))
11
- throw new Error(`${a} must be used inside <${n}>`);
3
+ import { jsx as r, jsxs as A } from "react/jsx-runtime";
4
+ import { createContext as y, useId as M, useContext as N, Children as P, isValidElement as B, useState as S, useMemo as q, useEffect as F, cloneElement as O } from "react";
5
+ import { cn as d } from "../cn.js";
6
+ import { useBreakpoint as G, Breakpoint as z } from "../hooks/use-breakpoint.js";
7
+ import { Icon as J } from "../icon/icon.js";
8
+ import { Paragraph as K } from "../paragraph/paragraph.js";
9
+ import { Tag as Q } from "../tag/tag.js";
10
+ import { isSpecialComponent as U, getSpecialComponentType as L } from "../utils/utilities.js";
11
+ const $ = (e) => e.ariaLabel ?? e.label ?? e.title ?? e.alt ?? "", E = y(!1), I = y(!1), w = y(!1), x = y(null);
12
+ function u(e, t, a) {
13
+ if (!N(e))
14
+ throw new Error(`${t} must be used inside <${a}>`);
12
15
  return !0;
13
16
  }
14
- const j = ({
15
- children: e,
16
- inset: a,
17
- type: n = "vertical",
18
- dataTestid: t
17
+ const W = (e, t) => e === "full" ? { padding: t } : {}, X = (e, t, a) => {
18
+ if (e === "body")
19
+ return a === "horizontal" ? { paddingBlock: t, paddingRight: t } : { paddingInline: t, paddingBottom: t };
20
+ }, se = ({
21
+ inset: e = "none",
22
+ insetSpace: t = 16,
23
+ type: a = "vertical",
24
+ background: i = "white",
25
+ className: o,
26
+ role: n,
27
+ children: l,
28
+ ...g
19
29
  }) => {
20
- const s = v(() => {
21
- const d = `gi-card-inset-${a || "none"}`;
22
- return `gi-card gi-card-${n} ${d} gi-not-prose`;
23
- }, [n, a]);
24
- return /* @__PURE__ */ r(u.Provider, { value: !0, children: /* @__PURE__ */ r("div", { className: s, "data-testid": t, children: e }) });
25
- }, E = ({ media: e, href: a }) => {
26
- if (i(u, "CardMedia", "Card"), !e)
30
+ var D, H;
31
+ const { breakpoint: C } = G(), b = C === z.ExtraSmall || C === z.Small, [m, p] = S(a), [s, v] = S(), [f, k] = S([]), R = q(
32
+ () => ({
33
+ setLabelId: (c) => v(c),
34
+ addDescId: (c) => k(
35
+ (T) => T.includes(c) ? T : [...T, c]
36
+ ),
37
+ labelId: s,
38
+ descIds: f
39
+ }),
40
+ [s, f]
41
+ ), j = P.toArray(l), h = j.find(
42
+ (c) => L(c) === "CardContainer"
43
+ ), V = j.find(
44
+ (c) => L(c) === "CardMedia"
45
+ );
46
+ return F(() => {
47
+ if (b || a === "vertical") {
48
+ p("vertical");
49
+ return;
50
+ }
51
+ p("horizontal");
52
+ }, [b]), /* @__PURE__ */ r(E.Provider, { value: !0, children: /* @__PURE__ */ r(x.Provider, { value: R, children: /* @__PURE__ */ A(
53
+ "div",
54
+ {
55
+ className: d(
56
+ "gi-card gi-not-prose",
57
+ {
58
+ "gi-card-vertical": m === "vertical",
59
+ "gi-card-horizontal": m === "horizontal",
60
+ "gi-bg-white": i === "white",
61
+ "gi-bg-color-surface-system-neutral-layer1": i === "grey"
62
+ },
63
+ o
64
+ ),
65
+ style: W(e, t),
66
+ role: n ?? "article",
67
+ "aria-labelledby": s,
68
+ "aria-describedby": f != null && f.length ? f.join(" ") : void 0,
69
+ ...g,
70
+ children: [
71
+ V,
72
+ h ? O(h, {
73
+ className: d((D = h.props) == null ? void 0 : D.className),
74
+ style: {
75
+ ...(H = h.props) == null ? void 0 : H.style,
76
+ ...X(e, t, m)
77
+ }
78
+ }) : null
79
+ ]
80
+ }
81
+ ) }) });
82
+ }, Y = ({ media: e, href: t }) => {
83
+ if (u(E, "CardMedia", "Card"), !e)
27
84
  return null;
28
85
  switch (e.type) {
29
86
  case "image": {
30
- const { src: n, alt: t, aspectRatio: s } = e.config;
31
- return /* @__PURE__ */ r("div", { className: "gi-card-image", children: /* @__PURE__ */ r("a", { href: a, children: /* @__PURE__ */ r(
87
+ const { src: a, alt: i, aspectRatio: o } = e.config ?? {}, n = $(e.config);
88
+ return /* @__PURE__ */ r("div", { className: "gi-card-image", children: /* @__PURE__ */ r("a", { href: t, "aria-label": n, title: n, children: /* @__PURE__ */ r(
32
89
  "img",
33
90
  {
34
- src: n,
35
- alt: t,
36
- style: s ? { aspectRatio: s } : void 0,
37
- className: s ? "gi-w-full" : void 0
91
+ src: a,
92
+ alt: i ?? "",
93
+ style: o ? { aspectRatio: o } : void 0,
94
+ className: o ? "gi-w-full" : void 0
38
95
  }
39
96
  ) }) });
40
97
  }
41
- case "icon":
42
- return /* @__PURE__ */ r("div", { className: "gi-card-icon", "aria-hidden": "true", children: /* @__PURE__ */ r("a", { href: a, children: /* @__PURE__ */ r(N, { ...e.config }) }) });
43
- case "iframe":
44
- return /* @__PURE__ */ r("div", { className: "gi-card-iframe", children: /* @__PURE__ */ r("iframe", { ...e.config }) });
98
+ case "icon": {
99
+ const a = $(e.config);
100
+ return /* @__PURE__ */ r("div", { className: "gi-card-icon", children: /* @__PURE__ */ r("a", { href: t, "aria-label": a, title: a, children: /* @__PURE__ */ r(J, { ...e.config, "aria-hidden": "true" }) }) });
101
+ }
102
+ case "iframe": {
103
+ const { title: a } = e.config ?? "Embedded content";
104
+ return /* @__PURE__ */ r("div", { className: "gi-card-iframe", children: /* @__PURE__ */ r("iframe", { ...e.config, title: a }) });
105
+ }
45
106
  default:
46
107
  return null;
47
108
  }
48
- }, M = ({
109
+ };
110
+ Object.defineProperty(Y, "componentType", {
111
+ value: "CardMedia",
112
+ writable: !1,
113
+ enumerable: !1
114
+ });
115
+ const Z = ({
116
+ children: e,
117
+ className: t,
118
+ ...a
119
+ }) => (u(E, "CardContainer", "Card"), /* @__PURE__ */ r(w.Provider, { value: !0, children: /* @__PURE__ */ r("div", { className: d("gi-card-content", t), ...a, children: e }) }));
120
+ Object.defineProperty(Z, "componentType", {
121
+ value: "CardContainer",
122
+ writable: !1,
123
+ enumerable: !1
124
+ });
125
+ const ce = ({
49
126
  children: e,
50
- inset: a = "none"
51
- }) => (i(u, "CardContainer", "Card"), /* @__PURE__ */ r(c.Provider, { value: !0, children: /* @__PURE__ */ r("div", { className: `gi-card-content gi-card-inset-${a || "none"}`, children: e }) })), A = ({ children: e }) => (i(o, "CardTitle", "CardHeader"), e ? /* @__PURE__ */ r("div", { className: "gi-card-title", children: e }) : null), D = ({ children: e }) => (i(o, "CardSubtitle", "CardHeader"), e ? /* @__PURE__ */ r("div", { className: "gi-card-subheading", children: e }) : null), T = ({ text: e, type: a }) => (i(o, "CardTag", "CardHeader"), /* @__PURE__ */ r("div", { className: "gi-card-tag", children: /* @__PURE__ */ r(x, { text: e, type: a }) }));
52
- Object.defineProperty(T, "componentType", {
127
+ className: t,
128
+ truncate: a,
129
+ id: i,
130
+ ["aria-level"]: o = 2,
131
+ ...n
132
+ }) => {
133
+ u(I, "CardTitle", "CardHeader");
134
+ const l = typeof e == "string", g = (s) => {
135
+ var v;
136
+ return a && B(s) ? O(s, {
137
+ className: d((v = s.props) == null ? void 0 : v.className, "gi-card-truncate-text")
138
+ }) : s;
139
+ }, C = a && !l ? P.map(e, g) : e, b = M(), m = i ?? `card-title-${b}`, p = N(x);
140
+ return p && p.setLabelId(m), /* @__PURE__ */ r(
141
+ "div",
142
+ {
143
+ className: d(
144
+ "gi-card-title",
145
+ {
146
+ "gi-card-truncate-text": !!a && l
147
+ },
148
+ t
149
+ ),
150
+ id: m,
151
+ role: "heading",
152
+ "aria-level": o,
153
+ title: l && a ? e.toString() : void 0,
154
+ ...n,
155
+ children: C
156
+ }
157
+ );
158
+ }, ue = ({
159
+ children: e,
160
+ className: t,
161
+ truncate: a,
162
+ id: i,
163
+ ...o
164
+ }) => {
165
+ u(I, "CardSubtitle", "CardHeader");
166
+ const n = typeof e == "string" && a ? e : void 0, l = M(), g = i ?? `card-subtitle-${l}`, C = N(x);
167
+ return C && C.addDescId(g), /* @__PURE__ */ r(
168
+ "div",
169
+ {
170
+ className: d(
171
+ "gi-card-subheading",
172
+ {
173
+ "gi-card-truncate-text": a
174
+ },
175
+ t
176
+ ),
177
+ id: g,
178
+ title: n,
179
+ ...o,
180
+ children: e
181
+ }
182
+ );
183
+ }, _ = ({
184
+ text: e,
185
+ type: t,
186
+ className: a,
187
+ ...i
188
+ }) => (u(I, "CardTag", "CardHeader"), /* @__PURE__ */ r(
189
+ "div",
190
+ {
191
+ role: "note",
192
+ "aria-label": typeof e == "string" ? e : void 0,
193
+ className: d("gi-card-tag", a),
194
+ ...i,
195
+ children: /* @__PURE__ */ r(Q, { text: e, type: t })
196
+ }
197
+ ));
198
+ Object.defineProperty(_, "componentType", {
53
199
  value: "CardTag",
54
200
  writable: !1,
55
201
  enumerable: !1
56
202
  });
57
- const R = ({ children: e }) => {
58
- i(c, "CardHeader", "CardContainer");
59
- const a = [], n = [];
60
- return m.forEach(e, (t) => {
61
- var d, C;
62
- if (!f(t))
63
- return;
64
- (((d = t == null ? void 0 : t.type) == null ? void 0 : d.componentType) || ((C = t.props) == null ? void 0 : C.__type)) === "CardTag" ? n.push(t) : a.push(t);
65
- }), /* @__PURE__ */ r(o.Provider, { value: !0, children: /* @__PURE__ */ g("div", { className: "gi-card-header", children: [
66
- /* @__PURE__ */ r("div", { className: "gi-card-heading", children: a }),
67
- n
203
+ const Ce = ({
204
+ children: e,
205
+ className: t,
206
+ ...a
207
+ }) => {
208
+ u(w, "CardHeader", "CardContainer");
209
+ const i = [], o = [];
210
+ return P.forEach(e, (n) => {
211
+ B(n) && (U(n, ["CardTag"]) ? o.push(n) : i.push(n));
212
+ }), /* @__PURE__ */ r(I.Provider, { value: !0, children: /* @__PURE__ */ A("div", { className: d("gi-card-header", t), role: "group", ...a, children: [
213
+ /* @__PURE__ */ r("div", { className: "gi-card-heading", children: i }),
214
+ o
68
215
  ] }) });
69
- }, S = ({
70
- children: e
71
- }) => (i(c, "CardDescription", "CardContainer"), e ? /* @__PURE__ */ r("div", { className: "gi-card-paragraph", children: /* @__PURE__ */ r(h, { size: "sm", children: e }) }) : null), _ = ({
72
- children: e
73
- }) => (i(c, "CardAction", "CardContainer"), /* @__PURE__ */ r("div", { className: "gi-card-action", children: e }));
216
+ }, ge = ({
217
+ children: e,
218
+ className: t,
219
+ id: a,
220
+ ...i
221
+ }) => {
222
+ if (u(w, "CardDescription", "CardContainer"), !e)
223
+ return null;
224
+ const o = M(), n = a ?? `card-desc-${o}`, l = N(x);
225
+ return l && l.addDescId(n), /* @__PURE__ */ r("div", { className: d("gi-card-paragraph", t), id: n, ...i, children: /* @__PURE__ */ r(K, { size: "sm", children: e }) });
226
+ }, me = ({
227
+ children: e,
228
+ className: t,
229
+ ...a
230
+ }) => (u(w, "CardAction", "CardContainer"), /* @__PURE__ */ r(
231
+ "div",
232
+ {
233
+ className: d("gi-card-action", t),
234
+ role: "group",
235
+ ...a,
236
+ children: e
237
+ }
238
+ ));
74
239
  export {
75
- _ as CardAction,
76
- M as CardContainer,
77
- S as CardDescription,
78
- R as CardHeader,
79
- E as CardMedia,
80
- j as CardNext,
81
- D as CardSubtitle,
82
- T as CardTag,
83
- A as CardTitle,
84
- i as useRequiredContext
240
+ me as CardAction,
241
+ Z as CardContainer,
242
+ ge as CardDescription,
243
+ Ce as CardHeader,
244
+ Y as CardMedia,
245
+ se as CardNext,
246
+ ue as CardSubtitle,
247
+ _ as CardTag,
248
+ ce as CardTitle,
249
+ u as useRequiredContext
85
250
  };
package/dist/card/card.js CHANGED
@@ -1,7 +1,9 @@
1
- import { jsx as t } from "react/jsx-runtime";
2
- import { CardLegacy as a } from "./card-legacy.js";
3
- import { CardNext as n } from "./card-next.js";
4
- const r = [
1
+ "use client";
2
+ import "@ogcio/design-system-react/browser-check";
3
+ import { jsx as r } from "react/jsx-runtime";
4
+ import { CardLegacy as m } from "./card-legacy.js";
5
+ import { CardNext as g } from "./card-next.js";
6
+ const n = [
5
7
  "title",
6
8
  "subTitle",
7
9
  "href",
@@ -10,17 +12,16 @@ const r = [
10
12
  "content",
11
13
  "action",
12
14
  "titleAsChild"
13
- ], l = (e) => r.some((i) => i in e) ? (console.warn(
14
- "[Card] Using legacy props. Please migrate to the new composable API."
15
- ), /* @__PURE__ */ t(a, { ...e })) : /* @__PURE__ */ t(
16
- n,
17
- {
18
- inset: e.inset,
19
- type: e.type,
20
- dataTestid: e.dataTestid,
21
- children: e.children
22
- }
23
- );
15
+ ], u = (e) => {
16
+ if (n.some((t) => t in e))
17
+ return console.warn(
18
+ "[Card] Using legacy props. Please migrate to the new composable API."
19
+ ), /* @__PURE__ */ r(m, { ...e });
20
+ const { inset: o, background: s, type: c, children: i, ...a } = e, d = new Set(n), l = Object.fromEntries(
21
+ Object.entries(a).filter(([t]) => !d.has(t))
22
+ );
23
+ return /* @__PURE__ */ r(g, { inset: o, type: c, background: s, ...l, children: i });
24
+ };
24
25
  export {
25
- l as Card
26
+ u as Card
26
27
  };
@@ -1,15 +1,10 @@
1
- import { ReactElement } from 'react';
2
- import { Button } from '../button/button.js';
1
+ import { ComponentPropsWithoutRef, ReactElement } from 'react';
3
2
  import { ButtonProps } from '../button/types.js';
4
3
  import { IconProps } from '../icon/icon.js';
5
- import { Link, LinkProps } from '../link/link.js';
4
+ import { LinkProps } from '../link/link.js';
6
5
  import { TagProps } from '../tag/tag.js';
7
- import { CardAction, CardContainer, CardDescription, CardMedia, CardHeader, CardTitle, CardSubtitle, CardTag } from './card-next.js';
6
+ import { CardContainer, CardMedia } from './card-next.js';
8
7
  type CardNextChild = ReactElement<typeof CardMedia> | ReactElement<typeof CardContainer> | ReactElement | undefined | null;
9
- type CardContainerChild = ReactElement<typeof CardHeader> | ReactElement<typeof CardDescription> | ReactElement<typeof CardAction> | undefined;
10
- type CardHeaderChild = ReactElement<typeof CardTitle> | ReactElement<typeof CardSubtitle> | ReactElement<typeof CardTag> | undefined;
11
- type CardActionChild = ReactElement<typeof Button> | ReactElement<typeof Link>;
12
- type CardTitleChild = ReactElement<typeof Link> | string;
13
8
  type InsetProps = 'body' | 'full' | 'none';
14
9
  type TypeProps = 'vertical' | 'horizontal';
15
10
  export type Action = (ButtonProps & {
@@ -38,11 +33,11 @@ export type MediaContent = {
38
33
  type: 'iframe';
39
34
  config: IframePropTypes;
40
35
  };
41
- export type CardProps = {
36
+ export type CardProps = ComponentPropsWithoutRef<'div'> & {
42
37
  type?: TypeProps;
43
38
  inset?: InsetProps;
39
+ background?: 'grey' | 'white';
44
40
  children?: CardNextChild | CardNextChild[] | null;
45
- dataTestid?: string;
46
41
  /** @deprecated Use <CardTitle> instead */
47
42
  title?: string;
48
43
  /** @deprecated Use <CardTitle subtitle=""> instead */
@@ -60,33 +55,28 @@ export type CardProps = {
60
55
  /** @deprecated Use <CardTitle> */
61
56
  titleAsChild?: boolean;
62
57
  };
63
- export type CardContainerProps = {
64
- children: CardContainerChild | CardContainerChild[];
65
- inset?: InsetProps;
66
- };
67
- export type CardDescriptionProps = {
58
+ export type CardContainerProps = ComponentPropsWithoutRef<'div'>;
59
+ export type CardDescriptionProps = ComponentPropsWithoutRef<'div'> & {
68
60
  children?: string;
69
61
  };
70
- export type CardActionProps = {
71
- children: CardActionChild | CardActionChild[];
72
- };
73
- export type CardNextProps = {
74
- children: CardNextChild | CardNextChild[];
62
+ export type CardActionProps = ComponentPropsWithoutRef<'div'>;
63
+ export type CardNextProps = ComponentPropsWithoutRef<'div'> & {
75
64
  inset?: InsetProps;
65
+ insetSpace?: number;
76
66
  type?: TypeProps;
77
- dataTestid?: string;
67
+ background?: 'grey' | 'white';
78
68
  };
79
- export type CardHeaderProps = {
80
- children: CardHeaderChild | CardHeaderChild[];
69
+ export type CardHeaderProps = ComponentPropsWithoutRef<'div'>;
70
+ export type CardTitleProps = ComponentPropsWithoutRef<'div'> & {
71
+ truncate?: boolean;
81
72
  };
82
- export type CardTitleProps = {
83
- children: CardTitleChild;
73
+ export type CardSubtitleProps = ComponentPropsWithoutRef<'div'> & {
74
+ children: string;
75
+ truncate?: boolean;
84
76
  };
85
- export type CardSubtitleProps = {
86
- children?: string;
87
- };
88
- export type CardMediaProps = {
77
+ export type CardMediaProps = Omit<ComponentPropsWithoutRef<'div'> & {
89
78
  media: MediaContent;
90
79
  href?: string;
91
- };
80
+ }, 'children'>;
81
+ export type CardTagProps = Omit<ComponentPropsWithoutRef<'div'> & TagProps, 'children'>;
92
82
  export {};