@ogcio/design-system-react 1.17.0 → 1.17.2

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,240 +1,252 @@
1
1
  "use client";
2
- import { jsx as i, jsxs as g, Fragment as A } from "react/jsx-runtime";
3
- import { isValidElement as x, cloneElement as v, useState as I, useRef as D, Children as S, useEffect as w } from "react";
4
- import { createPortal as V } from "react-dom";
5
- import { Button as B } from "../button/button.js";
2
+ import { jsx as i, jsxs as f, Fragment as P } from "react/jsx-runtime";
3
+ import { isValidElement as x, cloneElement as N, useState as B, useRef as U, useMemo as W, Children as z, useId as G, useEffect as w } from "react";
4
+ import { createPortal as J } from "react-dom";
5
+ import { Button as D } from "../button/button.js";
6
6
  import { cn as u } from "../cn.js";
7
- import { Heading as _ } from "../heading/heading.js";
8
- import { useAriaHider as $ } from "../hooks/use-aria-hider.js";
9
- import { useFocusTrap as K } from "../hooks/use-focus-trap.js";
10
- import { Icon as O } from "../icon/icon.js";
11
- import { IconButton as W } from "../icon-button/icon-button.js";
12
- const f = (e, t, o) => {
13
- var r;
14
- if (!x(o))
7
+ import { Heading as Q } from "../heading/heading.js";
8
+ import { useAriaHider as X } from "../hooks/use-aria-hider.js";
9
+ import { useFocusTrap as Y } from "../hooks/use-focus-trap.js";
10
+ import { Icon as Z } from "../icon/icon.js";
11
+ import { IconButton as O } from "../icon-button/icon-button.js";
12
+ import { splitAriaProps as R } from "../utils/utilities.js";
13
+ const T = (r, t, e) => {
14
+ var o;
15
+ if (!x(e))
15
16
  return !1;
16
- const a = o.type;
17
- return a === e || // @ts-expect-error The TS error says there is no _owner but there is
18
- ((r = o == null ? void 0 : o._owner) == null ? void 0 : r.name) === t || a.componentType === t;
19
- }, j = {
17
+ const a = e.type;
18
+ return a === r || // @ts-expect-error The TS error says there is no _owner but there is
19
+ ((o = e == null ? void 0 : e._owner) == null ? void 0 : o.name) === t || a.componentType === t;
20
+ }, E = {
20
21
  flat: 0,
21
22
  secondary: 1,
22
23
  primary: 2
23
- }, q = ({
24
- label: e,
24
+ }, tt = ({
25
+ label: r,
25
26
  size: t = "small",
26
- ...o
27
+ ...e
27
28
  }) => {
28
29
  let a = "sm";
29
- return (t === "large" || t === "medium") && (a = "md"), e ? /* @__PURE__ */ i(
30
- B,
30
+ return (t === "large" || t === "medium") && (a = "md"), r ? /* @__PURE__ */ i(
31
+ D,
31
32
  {
32
- onClick: o.onClick,
33
+ onClick: e.onClick,
33
34
  variant: "flat",
34
35
  size: t,
35
36
  appearance: "dark",
36
37
  className: "gi-modal-icon",
37
- "aria-label": e,
38
- ...o,
39
- children: /* @__PURE__ */ g(A, { children: [
40
- e,
41
- /* @__PURE__ */ i(O, { icon: "close", size: a })
38
+ "aria-label": r,
39
+ ...e,
40
+ children: /* @__PURE__ */ f(P, { children: [
41
+ r,
42
+ /* @__PURE__ */ i(Z, { icon: "close", size: a })
42
43
  ] })
43
44
  }
44
45
  ) : /* @__PURE__ */ i(
45
- W,
46
+ O,
46
47
  {
47
48
  className: "gi-modal-icon",
48
49
  icon: {
49
50
  icon: "close"
50
51
  },
51
52
  "aria-label": "Close modal",
52
- onClick: o.onClick,
53
+ onClick: e.onClick,
53
54
  variant: "flat",
54
55
  size: t,
55
56
  appearance: "dark",
56
- ...o
57
+ ...e
57
58
  }
58
59
  );
59
- }, z = ({
60
- closeButtonLabel: e,
60
+ }, et = ({
61
+ closeButtonLabel: r,
61
62
  modalTitle: t,
62
- closeOnClick: o,
63
+ closeOnClick: e,
63
64
  onClose: a,
64
- closeButtonSize: r
65
- }) => /* @__PURE__ */ g(
65
+ closeButtonSize: o
66
+ }) => /* @__PURE__ */ f(
66
67
  "div",
67
68
  {
68
69
  className: u({
69
- "gi-py-4 xs:gi-py-6": !e,
70
- "gi-py-2 xs:gi-py-4": !!e
70
+ "gi-py-4 xs:gi-py-6": !r,
71
+ "gi-py-2 xs:gi-py-4": !!r
71
72
  }),
72
73
  children: [
73
74
  t,
74
- o && /* @__PURE__ */ i(
75
- q,
75
+ e && /* @__PURE__ */ i(
76
+ tt,
76
77
  {
77
78
  onClick: a,
78
- label: e,
79
- size: r
79
+ label: r,
80
+ size: o
80
81
  }
81
82
  )
82
83
  ]
83
84
  }
84
- ), G = ({
85
- position: e = "center",
85
+ ), rt = ({
86
+ position: r = "center",
86
87
  size: t = "lg",
87
- closeOnClick: o = !0,
88
+ closeOnClick: e = !0,
88
89
  closeOnOverlayClick: a = !0,
89
- isOpen: r,
90
- onClose: m,
90
+ isOpen: o,
91
+ onClose: d,
91
92
  closeButtonLabel: y,
92
- className: d,
93
+ className: c,
93
94
  children: p,
94
95
  closeButtonSize: n,
95
96
  closeOnEscape: s,
96
- dataTestId: c,
97
- ...C
97
+ dataTestId: m,
98
+ ...v
98
99
  }) => {
99
- const k = D(null);
100
- $(k.current, r);
101
- const h = S.toArray(p), F = h.find(
102
- (l) => f(M, "ModalTitle", l)
103
- ), b = h.find(
104
- (l) => f(T, "ModalFooter", l)
105
- ), E = F ? v(F, {
106
- as: t === "sm" ? "h5" : "h4"
107
- }) : null, P = b ? v(b, {
100
+ var A;
101
+ const M = U(null);
102
+ X(M.current, o);
103
+ const [H, S] = W(
104
+ () => R(v),
105
+ [v]
106
+ ), k = z.toArray(p), g = k.find(
107
+ (l) => T(b, "ModalTitle", l)
108
+ ), C = k.find(
109
+ (l) => T(F, "ModalFooter", l)
110
+ ), $ = G(), L = ((A = g == null ? void 0 : g.props) == null ? void 0 : A.id) || `gi-modal-title-${$}`, V = g ? N(g, {
111
+ as: t === "sm" ? "h5" : "h4",
112
+ id: L
113
+ }) : null, _ = C ? N(C, {
108
114
  dataModalSize: t
109
- }) : null, H = h.filter(
110
- (l) => !f(M, "ModalTitle", l) && !f(T, "ModalFooter", l)
115
+ }) : null, q = k.filter(
116
+ (l) => !T(b, "ModalTitle", l) && !T(F, "ModalFooter", l)
111
117
  );
112
- return w(() => {
113
- if (!r || !s)
118
+ w(() => {
119
+ if (!o || !s)
114
120
  return;
115
- const l = (N) => {
116
- N.key === "Escape" && (N.stopPropagation(), m());
121
+ const l = (h) => {
122
+ h.key === "Escape" && (h.stopPropagation(), d());
117
123
  };
118
124
  return document.addEventListener("keydown", l), () => {
119
125
  document.removeEventListener("keydown", l);
120
126
  };
121
- }, [r, s, m]), /* @__PURE__ */ i(J, { modalRef: k, isOpen: r, children: /* @__PURE__ */ i(
127
+ }, [o, s, d]), w(() => {
128
+ if (!o || !e || !a)
129
+ return;
130
+ const l = (h) => {
131
+ var j;
132
+ const I = (j = M.current) == null ? void 0 : j.querySelector(
133
+ ".gi-modal-container-control"
134
+ );
135
+ I && (I.contains(h.target) || d());
136
+ };
137
+ return document.addEventListener("pointerdown", l, !0), () => document.removeEventListener("pointerdown", l, !0);
138
+ }, [o, e, a, d]);
139
+ const K = /* @__PURE__ */ i(
122
140
  "div",
123
141
  {
124
- ...C,
125
- ref: k,
142
+ ...S,
143
+ ref: M,
126
144
  className: u("gi-modal", {
127
- "gi-modal-open": r,
128
- "gi-modal-close": !r
145
+ "gi-modal-open": o,
146
+ "gi-modal-close": !o
129
147
  }),
130
- "data-testid": c || "modal",
131
- onClick: (l) => {
132
- l.currentTarget === l.target && o && a && m();
133
- },
148
+ "data-testid": m || "modal",
134
149
  tabIndex: -1,
135
- children: /* @__PURE__ */ g(
150
+ children: /* @__PURE__ */ f(
136
151
  "div",
137
152
  {
138
153
  "data-testid": "modal-container",
139
154
  role: "dialog",
140
155
  "aria-modal": "true",
141
156
  "aria-label": "dialog",
157
+ ...H,
142
158
  "data-size": t,
143
- "data-position": e,
159
+ "data-position": r,
144
160
  className: u(
145
161
  "gi-modal-container-control",
146
162
  {
147
- "gi-modal-container": !d,
148
- "gi-modal-container-center": e === "center",
149
- "gi-modal-container-left": e === "left",
150
- "gi-modal-container-right": e === "right",
151
- "gi-modal-container-bottom": e === "bottom"
163
+ "gi-modal-container": !c,
164
+ "gi-modal-container-center": r === "center",
165
+ "gi-modal-container-left": r === "left",
166
+ "gi-modal-container-right": r === "right",
167
+ "gi-modal-container-bottom": r === "bottom"
152
168
  },
153
- d
169
+ c
154
170
  ),
155
171
  children: [
156
172
  /* @__PURE__ */ i(
157
- z,
173
+ et,
158
174
  {
159
175
  closeButtonLabel: y,
160
- modalTitle: E,
161
- closeOnClick: o,
162
- onClose: m,
176
+ modalTitle: V,
177
+ closeOnClick: e,
178
+ onClose: d,
163
179
  closeButtonSize: n
164
180
  }
165
181
  ),
166
- /* @__PURE__ */ g("div", { className: u({ "gi-pb-6": !b }), children: [
167
- H,
168
- P
182
+ /* @__PURE__ */ f("div", { className: u({ "gi-pb-6": !C }), children: [
183
+ q,
184
+ _
169
185
  ] })
170
186
  ]
171
187
  }
172
188
  )
173
189
  }
174
- ) });
175
- }, M = ({ children: e, as: t = "h4", ...o }) => /* @__PURE__ */ i("div", { className: "gi-flex-1", id: o.id, "aria-label": e == null ? void 0 : e.toString(), children: /* @__PURE__ */ i(_, { as: t, ...o, children: e }) });
176
- Object.defineProperty(M, "componentType", {
190
+ );
191
+ return /* @__PURE__ */ i(ot, { modalRef: M, isOpen: o, children: K });
192
+ }, b = ({ children: r, as: t = "h4", ...e }) => /* @__PURE__ */ i("div", { className: "gi-flex-1", id: e.id, "aria-label": r == null ? void 0 : r.toString(), children: /* @__PURE__ */ i(Q, { as: t, ...e, children: r }) });
193
+ Object.defineProperty(b, "componentType", {
177
194
  value: "ModalTitle",
178
195
  writable: !1,
179
196
  enumerable: !1
180
197
  });
181
- M.displayName = "ModalTitle";
182
- const rt = ({
183
- children: e,
184
- className: t
198
+ b.displayName = "ModalTitle";
199
+ const ft = ({
200
+ children: r,
201
+ className: t,
202
+ includeModalClass: e = !0
185
203
  }) => /* @__PURE__ */ i(
186
204
  "div",
187
205
  {
188
- id: "gi-modal-body",
189
206
  "aria-label": "Modal content",
190
207
  role: "document",
191
208
  tabIndex: 0,
192
- className: u(
193
- {
194
- "gi-modal-body": !t
195
- },
196
- t
197
- ),
198
- children: e
209
+ className: u(e && "gi-modal-body", t),
210
+ children: r
199
211
  }
200
- ), T = ({
201
- className: e,
212
+ ), F = ({
213
+ className: r,
202
214
  children: t,
203
- orientation: o,
215
+ orientation: e,
204
216
  dataModalSize: a,
205
- stacked: r
217
+ stacked: o
206
218
  }) => {
207
- const d = (Array.isArray(t) ? t : [t]).filter((n) => {
208
- var s, c;
209
- return x(n) && (n.type === B || ((s = n.type) == null ? void 0 : s.displayName) === "Button" || ((c = n.props) == null ? void 0 : c["data-button"]));
219
+ const c = (Array.isArray(t) ? t : [t]).filter((n) => {
220
+ var s, m;
221
+ return x(n) && (n.type === D || ((s = n.type) == null ? void 0 : s.displayName) === "Button" || ((m = n.props) == null ? void 0 : m["data-button"]));
210
222
  }).sort((n, s) => {
211
- const c = n.props.variant ?? "primary", C = s.props.variant ?? "primary";
212
- return (j[c] || 0) - (j[C] || 0);
223
+ const m = n.props.variant ?? "primary", v = s.props.variant ?? "primary";
224
+ return (E[m] || 0) - (E[v] || 0);
213
225
  }), p = u({
214
- "gi-justify-center sm:gi-justify-start": !o && a !== "sm" && !r,
215
- "gi-justify-center": o === "vertical" || a === "sm" || r,
216
- "gi-justify-start": o === "horizontal"
226
+ "gi-justify-center sm:gi-justify-start": !e && a !== "sm" && !o,
227
+ "gi-justify-center": e === "vertical" || a === "sm" || o,
228
+ "gi-justify-start": e === "horizontal"
217
229
  });
218
230
  return /* @__PURE__ */ i(
219
231
  "div",
220
232
  {
221
- className: u(e, {
222
- "gi-pt-6": d.length === 0,
223
- "gi-modal-footer": d.length,
224
- "gi-modal-footer-stacked": r
233
+ className: u(r, {
234
+ "gi-pt-6": c.length === 0,
235
+ "gi-modal-footer": c.length,
236
+ "gi-modal-footer-stacked": o
225
237
  }),
226
- children: d.length > 0 && /* @__PURE__ */ i(
238
+ children: c.length > 0 && /* @__PURE__ */ i(
227
239
  "div",
228
240
  {
229
- "data-orientation": o || "unset",
241
+ "data-orientation": e || "unset",
230
242
  "data-modal-size": a,
231
- children: d.map(
243
+ children: c.map(
232
244
  (n, s) => {
233
- var c;
234
- return v(n, {
245
+ var m;
246
+ return N(n, {
235
247
  key: n.key || n.props.id || n.props.dataTestid || `modal-footer-button-${s}`,
236
248
  id: n.props.id || `modal-footer-button-${s}`,
237
- className: u((c = n == null ? void 0 : n.props) == null ? void 0 : c.className, p)
249
+ className: u((m = n == null ? void 0 : n.props) == null ? void 0 : m.className, p)
238
250
  });
239
251
  }
240
252
  ) || null
@@ -243,53 +255,53 @@ const rt = ({
243
255
  }
244
256
  );
245
257
  };
246
- Object.defineProperty(T, "componentType", {
258
+ Object.defineProperty(F, "componentType", {
247
259
  value: "ModalFooter",
248
260
  writable: !1,
249
261
  enumerable: !1
250
262
  });
251
- T.displayName = "ModalFooter";
252
- const J = ({
253
- children: e,
263
+ F.displayName = "ModalFooter";
264
+ const ot = ({
265
+ children: r,
254
266
  modalRef: t,
255
- isOpen: o
267
+ isOpen: e
256
268
  }) => {
257
- const [a, r] = I(!1);
269
+ const [a, o] = B(!1);
258
270
  return w(() => {
259
- r(!0);
260
- }, []), K(t == null ? void 0 : t.current, o && a, {
271
+ o(!0);
272
+ }, []), Y(t == null ? void 0 : t.current, e && a, {
261
273
  initialFocus: (t == null ? void 0 : t.current) ?? !0,
262
274
  fallbackFocus: () => t == null ? void 0 : t.current
263
- }), a ? V(e, document.body) : null;
264
- }, at = ({
265
- children: e,
275
+ }), a ? J(r, document.body) : null;
276
+ }, yt = ({
277
+ children: r,
266
278
  triggerButton: t,
267
- startsOpen: o,
279
+ startsOpen: e,
268
280
  ...a
269
281
  }) => {
270
- const [r, m] = I(!!o), y = () => m(!0), d = () => m(!1), p = v(t, {
282
+ const [o, d] = B(!!e), y = () => d(!0), c = () => d(!1), p = N(t, {
271
283
  "data-testid": "modal-trigger-button-container",
272
284
  "aria-haspopup": "dialog",
273
285
  onClick: y
274
286
  });
275
- return /* @__PURE__ */ g(A, { children: [
287
+ return /* @__PURE__ */ f(P, { children: [
276
288
  p,
277
289
  /* @__PURE__ */ i(
278
- G,
290
+ rt,
279
291
  {
280
- onClose: d,
292
+ onClose: c,
281
293
  position: "center",
282
- isOpen: r,
294
+ isOpen: o,
283
295
  ...a,
284
- children: e
296
+ children: r
285
297
  }
286
298
  )
287
299
  ] });
288
300
  };
289
301
  export {
290
- at as Modal,
291
- rt as ModalBody,
292
- T as ModalFooter,
293
- M as ModalTitle,
294
- G as ModalWrapper
302
+ yt as Modal,
303
+ ft as ModalBody,
304
+ F as ModalFooter,
305
+ b as ModalTitle,
306
+ rt as ModalWrapper
295
307
  };
@@ -3,5 +3,6 @@ export type ProgressBarProps = {
3
3
  value?: number;
4
4
  isIndeterminate?: boolean;
5
5
  label?: string;
6
- };
7
- export declare function ProgressBar({ value, max, isIndeterminate, label, }: ProgressBarProps): import("react/jsx-runtime").JSX.Element;
6
+ dataTestid?: string;
7
+ } & React.HTMLAttributes<HTMLDivElement>;
8
+ export declare function ProgressBar({ value, max, isIndeterminate, label, className, dataTestid, ...props }: ProgressBarProps): import("react/jsx-runtime").JSX.Element;
@@ -1,14 +1,17 @@
1
- import { jsxs as l, jsx as a } from "react/jsx-runtime";
2
- import { cn as t } from "../cn.js";
3
- import { translate as g } from "../i18n/utility.js";
4
- function d({
1
+ import { jsxs as c, jsx as a } from "react/jsx-runtime";
2
+ import { cn as o } from "../cn.js";
3
+ import { translate as p } from "../i18n/utility.js";
4
+ function u({
5
5
  value: s = 0,
6
6
  max: e = 100,
7
7
  isIndeterminate: r,
8
- label: o
8
+ label: i,
9
+ className: l,
10
+ dataTestid: t,
11
+ ...n
9
12
  }) {
10
- const i = s * 100 / e;
11
- return /* @__PURE__ */ l("div", { className: "gi-progress-bar-container", children: [
13
+ const g = s * 100 / e;
14
+ return /* @__PURE__ */ c("div", { className: "gi-progress-bar-container", children: [
12
15
  /* @__PURE__ */ a(
13
16
  "div",
14
17
  {
@@ -16,25 +19,26 @@ function d({
16
19
  "aria-valuenow": r ? void 0 : s,
17
20
  "aria-valuemin": 0,
18
21
  "aria-valuemax": e,
19
- "aria-label": g("progressBar.progressBar", {
22
+ "aria-label": p("progressBar.progressBar", {
20
23
  defaultValue: "Progress bar"
21
24
  }),
22
- "data-testid": "progress-bar",
23
- className: "gi-progress-bar",
25
+ className: o("gi-progress-bar", l),
26
+ "data-testid": t,
27
+ ...n,
24
28
  children: /* @__PURE__ */ a(
25
29
  "div",
26
30
  {
27
- className: t({
31
+ className: o({
28
32
  "gi-progress-bar-indeterminate": r
29
33
  }),
30
- style: r ? {} : { width: `${i}%` }
34
+ style: r ? {} : { width: `${g}%` }
31
35
  }
32
36
  )
33
37
  }
34
38
  ),
35
- o && /* @__PURE__ */ a("span", { children: o })
39
+ i && /* @__PURE__ */ a("span", { children: i })
36
40
  ] });
37
41
  }
38
42
  export {
39
- d as ProgressBar
43
+ u as ProgressBar
40
44
  };
@@ -1,7 +1,9 @@
1
1
  import { FC } from 'react';
2
- import { InnerStepProps, ProgressStepperProps, StepItemProps } from './types.js';
3
- export declare const Step: ({ isCurrentStep, isCompleted, isLastStep, isDisabled, stepNumber, orientation, children, indicator, verticalSlot, defaultOpen, dataTestId, ariaLabel, verticalGap, }: InnerStepProps & {
2
+ import { InnerStepProps, ProgressStepperProps, StepItemProps, StepFillLevelType } from './types.js';
3
+ export declare const Step: ({ isCurrentStep, isCompleted, isLastStep, isDisabled, stepNumber, orientation, children, indicator, verticalSlot, defaultOpen, dataTestId, ariaLabel, verticalGap, fill, useFill, }: InnerStepProps & {
4
4
  isDisabled?: boolean;
5
+ fill?: StepFillLevelType;
6
+ useFill?: boolean;
5
7
  }) => import("react/jsx-runtime").JSX.Element;
6
8
  export declare const StepItem: FC<StepItemProps>;
7
- export declare const ProgressStepper: ({ children, currentStepIndex, orientation, indicator, completeAll, stepStates, dataTestId, className, verticalGap, }: ProgressStepperProps) => import("react/jsx-runtime").JSX.Element;
9
+ export declare const ProgressStepper: ({ children, currentStepIndex, orientation, indicator, completeAll, stepStates, className, verticalGap, ...props }: ProgressStepperProps) => import("react/jsx-runtime").JSX.Element;