@ogcio/design-system-react 1.17.2 → 1.18.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.
@@ -1,22 +1,4 @@
1
- import { FC, PropsWithChildren } from 'react';
2
- import { ButtonAppearance, ButtonSize } from '../button/types.js';
3
- type ButtonGroupItemProps = PropsWithChildren<{
4
- value: string;
5
- role?: string;
6
- 'aria-checked'?: boolean;
7
- 'aria-label'?: string;
8
- }>;
1
+ import { FC } from 'react';
2
+ import { ButtonGroupItemProps, ButtonGroupProps } from './types.js';
9
3
  export declare const ButtonGroupItem: FC<ButtonGroupItemProps>;
10
- type ButtonGroupProps = PropsWithChildren<{
11
- name: string;
12
- size?: ButtonSize;
13
- appearance?: ButtonAppearance;
14
- onChange?: (value: string) => void;
15
- defaultValue?: string;
16
- value?: string;
17
- role?: string;
18
- 'aria-labelledby'?: string;
19
- 'aria-describedby'?: string;
20
- }>;
21
4
  export declare const ButtonGroup: FC<ButtonGroupProps>;
22
- export {};
@@ -1,92 +1,98 @@
1
1
  "use client";
2
- import { jsx as f } from "react/jsx-runtime";
3
- import { createContext as x, useState as B, useEffect as G, useContext as V } from "react";
4
- import { Button as k } from "../button/button.js";
5
- import { useDomId as S } from "../hooks/use-dom-id.js";
6
- const I = x(
2
+ import { jsx as y } from "react/jsx-runtime";
3
+ import { createContext as G, useState as V, useEffect as k, useContext as S } from "react";
4
+ import { Button as w } from "../button/button.js";
5
+ import { cn as E } from "../cn.js";
6
+ import { useDomId as $ } from "../hooks/use-dom-id.js";
7
+ const x = G(
7
8
  void 0
8
- ), v = ({
9
+ ), P = ({
9
10
  value: r,
10
11
  children: d,
11
12
  role: s,
12
13
  "aria-checked": e,
13
- "aria-label": a
14
+ "aria-label": a,
15
+ ...t
14
16
  }) => {
15
- const t = V(I);
16
- if (!t)
17
+ const c = S(x);
18
+ if (!c)
17
19
  throw new Error("ButtonGroupItem must be used within a ButtonGroup");
18
20
  const {
19
21
  selectedValue: n,
20
22
  setSelectedValue: l,
21
23
  size: u,
22
24
  onChange: o,
23
- groupId: p,
24
- appearance: i
25
- } = t, c = n === r, m = () => {
25
+ groupId: m,
26
+ appearance: p
27
+ } = c, i = n === r, b = () => {
26
28
  l(r), o == null || o(r);
27
- }, b = `${p}-${r}`;
28
- return /* @__PURE__ */ f(
29
- k,
29
+ }, f = `${m}-${r}`;
30
+ return /* @__PURE__ */ y(
31
+ w,
30
32
  {
31
- variant: c ? "primary" : "secondary",
33
+ variant: i ? "primary" : "secondary",
32
34
  size: u,
33
- appearance: i,
34
- onClick: m,
35
- id: b,
35
+ appearance: p,
36
+ onClick: b,
37
+ id: f,
36
38
  role: s || "radio",
37
- "aria-checked": e === void 0 ? c : e,
39
+ "aria-checked": e === void 0 ? i : e,
38
40
  "aria-label": a,
39
41
  type: "button",
42
+ ...t,
40
43
  children: d
41
44
  }
42
45
  );
43
- }, z = ({
46
+ }, q = ({
44
47
  name: r,
45
48
  size: d = "medium",
46
49
  appearance: s = "dark",
47
50
  onChange: e,
48
51
  defaultValue: a,
49
52
  value: t,
50
- children: n,
51
- role: l,
52
- "aria-labelledby": u,
53
- "aria-describedby": o
53
+ children: c,
54
+ role: n,
55
+ "aria-labelledby": l,
56
+ "aria-describedby": u,
57
+ className: o,
58
+ ...m
54
59
  }) => {
55
- const [p, i] = B(
60
+ const [p, i] = V(
56
61
  a
57
- ), c = t === void 0 ? p : t;
58
- G(() => {
62
+ ), b = t === void 0 ? p : t;
63
+ k(() => {
59
64
  t !== void 0 && i(t);
60
65
  }, [t]);
61
- const m = (y) => {
62
- t === void 0 && i(y), e == null || e(y);
63
- }, b = S();
64
- return /* @__PURE__ */ f(
65
- I.Provider,
66
+ const f = (I) => {
67
+ t === void 0 && i(I), e == null || e(I);
68
+ }, B = $();
69
+ return /* @__PURE__ */ y(
70
+ x.Provider,
66
71
  {
67
72
  value: {
68
- selectedValue: c,
69
- setSelectedValue: m,
73
+ selectedValue: b,
74
+ setSelectedValue: f,
70
75
  name: r,
71
76
  size: d,
72
77
  onChange: e,
73
- groupId: b,
74
- appearance: s
78
+ groupId: B,
79
+ appearance: s,
80
+ ...m
75
81
  },
76
- children: /* @__PURE__ */ f(
82
+ children: /* @__PURE__ */ y(
77
83
  "div",
78
84
  {
79
- className: "gi-btn-group",
80
- role: l || "radiogroup",
81
- "aria-labelledby": u,
82
- "aria-describedby": o,
83
- children: n
85
+ className: E("gi-btn-group", o),
86
+ role: n || "radiogroup",
87
+ "aria-labelledby": l,
88
+ "aria-describedby": u,
89
+ children: c
84
90
  }
85
91
  )
86
92
  }
87
93
  );
88
94
  };
89
95
  export {
90
- z as ButtonGroup,
91
- v as ButtonGroupItem
96
+ q as ButtonGroup,
97
+ P as ButtonGroupItem
92
98
  };
@@ -0,0 +1,29 @@
1
+ import { PropsWithChildren } from 'react';
2
+ import { ButtonAppearance, ButtonSize } from '../button/types.js';
3
+ export type ButtonGroupProps = PropsWithChildren<{
4
+ name: string;
5
+ size?: ButtonSize;
6
+ appearance?: ButtonAppearance;
7
+ onChange?: (value: string) => void;
8
+ defaultValue?: string;
9
+ value?: string;
10
+ role?: string;
11
+ 'aria-labelledby'?: string;
12
+ 'aria-describedby'?: string;
13
+ className?: string;
14
+ }>;
15
+ export type ButtonGroupItemProps = PropsWithChildren<{
16
+ value: string;
17
+ role?: string;
18
+ 'aria-checked'?: boolean;
19
+ 'aria-label'?: string;
20
+ }>;
21
+ export type ButtonGroupContextType = {
22
+ selectedValue?: string;
23
+ setSelectedValue: (value: string) => void;
24
+ name: string;
25
+ size: ButtonSize;
26
+ appearance?: ButtonAppearance;
27
+ onChange?: (value: string) => void;
28
+ groupId: string;
29
+ };
@@ -0,0 +1 @@
1
+
package/dist/index.d.ts CHANGED
@@ -7,6 +7,7 @@ export { Blockquote, type BlockquoteProps } from './blockquote/blockquote.js';
7
7
  export { BreadcrumbCurrentLink, BreadcrumbEllipsis, BreadcrumbLink, Breadcrumbs, } from './breadcrumbs/breadcrumbs.js';
8
8
  export { type BreadcrumbLinkProps, type BreadcrumbProps, } from './breadcrumbs/types.js';
9
9
  export { ButtonGroup, ButtonGroupItem } from './button-group/button-group.js';
10
+ export * from './button-group/types.js';
10
11
  export { Button } from './button/button.js';
11
12
  export { type ButtonProps } from './button/types.js';
12
13
  export { CardAction, CardContainer, CardDescription, CardHeader, CardMedia, CardSubtitle, CardTag, CardTitle, } from './card/card-next.js';
@@ -1,23 +1,26 @@
1
1
  "use client";
2
- import { jsxs as u, jsx as d } from "react/jsx-runtime";
3
- import k from "react";
4
- import { ButtonGroup as y, ButtonGroupItem as N } from "../button-group/button-group.js";
5
- import { FormField as x, FormFieldLabel as f, FormFieldHint as j } from "../forms/form-field/form-field.js";
6
- const _ = ({
7
- name: p,
8
- size: $ = "medium",
9
- value: s,
10
- label: F,
11
- hint: i,
12
- leftLabel: a,
13
- rightLabel: r,
14
- onChange: c,
15
- type: I
2
+ import { jsxs as a, jsx as s, Fragment as F } from "react/jsx-runtime";
3
+ import { useId as G } from "react";
4
+ import { ButtonGroup as j, ButtonGroupItem as w } from "../button-group/button-group.js";
5
+ import { cn as o } from "../cn.js";
6
+ import { FormField as O, FormFieldLabel as V, FormFieldHint as E } from "../forms/form-field/form-field.js";
7
+ import { useBreakpoint as H, Breakpoint as $ } from "../hooks/use-breakpoint.js";
8
+ const K = ({
9
+ name: B,
10
+ size: x = "medium",
11
+ orientation: t = "horizontal",
12
+ wrapInMobile: I = !0,
13
+ value: m,
14
+ label: N,
15
+ hint: d,
16
+ leftLabel: i,
17
+ rightLabel: c,
18
+ onChange: v,
19
+ type: f
16
20
  }) => {
17
- var m, t;
18
- const o = k.useId(), v = `${o}-label`, b = i ? `${o}-hint` : void 0;
21
+ const h = G(), b = `${h}-label`, n = d ? `${h}-hint` : void 0, { breakpoint: p } = H(), g = p === $.ExtraSmall || p === $.Small;
19
22
  let l = [];
20
- switch (I) {
23
+ switch (f) {
21
24
  case "1-5": {
22
25
  l = [
23
26
  { value: "1", label: "1" },
@@ -57,48 +60,88 @@ const _ = ({
57
60
  break;
58
61
  }
59
62
  }
60
- return /* @__PURE__ */ u(x, { className: "gi-w-full", children: [
61
- /* @__PURE__ */ d(f, { id: v, children: F }),
62
- i && /* @__PURE__ */ d(j, { id: b, children: i }),
63
- /* @__PURE__ */ u(
63
+ const u = t === "vertical" || g && !I, y = () => u ? "gi-score-select-button-group-vertical" : "gi-score-select-button-group-horizontal", z = () => {
64
+ var e, r;
65
+ return i && c && l.length > 2 && t === "horizontal" && !u && /* @__PURE__ */ a(
64
66
  "div",
65
67
  {
66
- className: "gi-score-select-button-group",
67
- role: "group",
68
- "aria-labelledby": v,
69
- "aria-describedby": b,
68
+ className: o("gi-score-select-labels-responsive"),
69
+ "aria-hidden": "true",
70
70
  children: [
71
- a && r && l.length > 2 && /* @__PURE__ */ u("div", { className: "gi-score-select-labels-responsive", "aria-hidden": "true", children: [
72
- /* @__PURE__ */ u("div", { children: [
73
- (m = l[0]) == null ? void 0 : m.label,
74
- " – ",
75
- a
76
- ] }),
77
- /* @__PURE__ */ u("div", { children: [
78
- (t = l.at(-1)) == null ? void 0 : t.label,
79
- " – ",
80
- r
81
- ] })
71
+ /* @__PURE__ */ a("div", { children: [
72
+ (e = l[0]) == null ? void 0 : e.label,
73
+ " ",
74
+ i
75
+ ] }),
76
+ /* @__PURE__ */ a("div", { children: [
77
+ (r = l.at(-1)) == null ? void 0 : r.label,
78
+ " ",
79
+ c
80
+ ] })
81
+ ]
82
+ }
83
+ );
84
+ }, S = () => {
85
+ var e, r;
86
+ return (i || c) && /* @__PURE__ */ s(
87
+ "div",
88
+ {
89
+ className: o("gi-score-select-labels", {
90
+ "gi-score-select-labels-vertical": u
91
+ }),
92
+ "aria-hidden": "true",
93
+ children: t === "horizontal" && g ? /* @__PURE__ */ a(F, { children: [
94
+ /* @__PURE__ */ a("div", { children: [
95
+ (e = l[0]) == null ? void 0 : e.label,
96
+ " – ",
97
+ i
82
98
  ] }),
83
- /* @__PURE__ */ d(
84
- y,
99
+ /* @__PURE__ */ a("div", { children: [
100
+ (r = l.at(-1)) == null ? void 0 : r.label,
101
+ " – ",
102
+ c
103
+ ] })
104
+ ] }) : /* @__PURE__ */ a(F, { children: [
105
+ /* @__PURE__ */ s("div", { children: i }),
106
+ /* @__PURE__ */ s("div", { children: c })
107
+ ] })
108
+ }
109
+ );
110
+ };
111
+ return /* @__PURE__ */ a(O, { className: "gi-w-full", children: [
112
+ /* @__PURE__ */ s(V, { id: b, children: N }),
113
+ d && /* @__PURE__ */ s(E, { id: n, children: d }),
114
+ /* @__PURE__ */ a(
115
+ "div",
116
+ {
117
+ className: o("gi-score-select-button-group", y()),
118
+ role: "group",
119
+ "aria-labelledby": b,
120
+ "aria-describedby": n,
121
+ children: [
122
+ z(),
123
+ /* @__PURE__ */ s(
124
+ j,
85
125
  {
86
- name: p,
87
- size: $,
88
- defaultValue: s,
89
- onChange: (e) => c == null ? void 0 : c(e),
126
+ name: B,
127
+ size: x,
128
+ defaultValue: m,
129
+ onChange: (e) => v == null ? void 0 : v(e),
90
130
  role: "radiogroup",
91
- "aria-labelledby": v,
92
- "aria-describedby": b,
131
+ "aria-labelledby": b,
132
+ "aria-describedby": n,
133
+ className: o({
134
+ "gi-flex-col gi-items-start": u
135
+ }),
93
136
  children: l.map((e) => {
94
- var n, h;
95
- return /* @__PURE__ */ d(
96
- N,
137
+ var r, k;
138
+ return /* @__PURE__ */ s(
139
+ w,
97
140
  {
98
141
  value: e.value,
99
142
  role: "radio",
100
- "aria-checked": s === e.value,
101
- "aria-label": `${e.label}${a && e.value === ((n = l[0]) == null ? void 0 : n.value) ? ` - ${a}` : ""}${r && e.value === ((h = l.at(-1)) == null ? void 0 : h.value) ? ` - ${r}` : ""}`,
143
+ "aria-checked": m === e.value,
144
+ "aria-label": `${e.label}${i && e.value === ((r = l[0]) == null ? void 0 : r.value) ? ` - ${i}` : ""}${c && e.value === ((k = l.at(-1)) == null ? void 0 : k.value) ? ` - ${c}` : ""}`,
102
145
  children: e.label
103
146
  },
104
147
  e.value
@@ -106,15 +149,12 @@ const _ = ({
106
149
  })
107
150
  }
108
151
  ),
109
- (a || r) && /* @__PURE__ */ u("div", { className: "gi-score-select-labels", "aria-hidden": "true", children: [
110
- /* @__PURE__ */ d("div", { children: a }),
111
- /* @__PURE__ */ d("div", { children: r })
112
- ] })
152
+ S()
113
153
  ]
114
154
  }
115
155
  )
116
156
  ] });
117
157
  };
118
158
  export {
119
- _ as ScoreSelect
159
+ K as ScoreSelect
120
160
  };
@@ -9,6 +9,10 @@ export type ScoreSelectProps = {
9
9
  leftLabel?: string;
10
10
  rightLabel?: string;
11
11
  type: ScoreSelectType;
12
+ orientation?: 'vertical' | 'horizontal';
13
+ startLabel?: string;
14
+ endLabel?: string;
15
+ wrapInMobile?: boolean;
12
16
  onChange?: (value: string) => void;
13
17
  };
14
18
  export {};