asma-ui-core 3.129.0 → 3.130.1

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,31 +1,34 @@
1
1
  import { cn as u } from "../../../helpers/cn.js";
2
- import { ChevronDownIcon as P } from "../../icons/chevron-down-icon/ChevronDownIcon.js";
3
- import { StyledButton as x } from "../button/StyledButton.js";
4
- import { StyledRadio as $ } from "../radio-button/base-ui/StyledRadio.js";
5
- import { HelperRow as H } from "../../../helpers/HelperRow.js";
6
- import { useHelperSlot as q } from "../../../helpers/useHelperSlot.js";
7
- import { StyledInputField as D } from "../input-field/StyledInputField.js";
8
- import { getPickerText as L } from "../full-screen-picker/pickerCopy.js";
9
- import { StyledSelectAutocomplete as F } from "../select-autocomplete/StyledSelectAutocomplete.js";
2
+ import { ChevronDownIcon as L } from "../../icons/chevron-down-icon/ChevronDownIcon.js";
3
+ import { CloseIcon as F } from "../../icons/close-icon/CloseIcon.js";
4
+ import { StyledButton as q } from "../button/StyledButton.js";
5
+ import { StyledRadio as T } from "../radio-button/base-ui/StyledRadio.js";
6
+ import { HelperRow as M } from "../../../helpers/HelperRow.js";
7
+ import { useHelperSlot as V } from "../../../helpers/useHelperSlot.js";
8
+ import { StyledInputField as K } from "../input-field/StyledInputField.js";
9
+ import { getPickerText as X } from "../full-screen-picker/pickerCopy.js";
10
+ import { StyledSelectAutocomplete as B } from "../select-autocomplete/StyledSelectAutocomplete.js";
10
11
  import a from "./StyledEmojiChoice.module.js";
11
- import { useId as j, useRef as M, useState as T } from "react";
12
+ import { useId as w, useRef as E, useState as x } from "react";
12
13
  import { jsx as l, jsxs as f } from "react/jsx-runtime";
13
- var V = {
14
+ var G = {
14
15
  en: {
15
16
  noAnswer: "No answer",
16
17
  showAllOptions: (e) => `Show all options (${e})`,
17
18
  hideOptions: "Hide options",
18
19
  selected: "selected",
19
- option: (e) => `Option ${e}`
20
+ option: (e) => `Option ${e}`,
21
+ clearSelection: "Clear selection"
20
22
  },
21
23
  no: {
22
24
  noAnswer: "Ingen svar",
23
25
  showAllOptions: (e) => `Vis alle alternativ (${e})`,
24
26
  hideOptions: "Skjul alternativ",
25
27
  selected: "valgt",
26
- option: (e) => `Alternativ ${e}`
28
+ option: (e) => `Alternativ ${e}`,
29
+ clearSelection: "Fjern valget"
27
30
  }
28
- }, K = 5, C = (e, n, h) => e.label ? e.label : e.emoji ? e.emoji : h.option(n), R = ({ option: e, className: n }) => e.emoji ? /* @__PURE__ */ l("span", {
31
+ }, z = 5, R = (e, n, o) => e.label ? e.label : e.emoji ? e.emoji : o.option(n), H = ({ option: e, className: n }) => e.emoji ? /* @__PURE__ */ l("span", {
29
32
  "aria-hidden": "true",
30
33
  className: n,
31
34
  children: e.emoji
@@ -33,15 +36,15 @@ var V = {
33
36
  alt: "",
34
37
  src: e.emojiImageSrc,
35
38
  className: n
36
- }) : null, S = ({ option: e, position: n, text: h, radio: N }) => {
37
- const p = !!e.emoji || !!e.emojiImageSrc;
39
+ }) : null, $ = ({ option: e, position: n, text: o, radio: h }) => {
40
+ const m = !!e.emoji || !!e.emojiImageSrc;
38
41
  return /* @__PURE__ */ f("span", {
39
- className: u(a.content, !p && a.noEmoji),
42
+ className: u(a.content, !m && a.noEmoji),
40
43
  children: [/* @__PURE__ */ f("span", {
41
44
  className: a.lead,
42
- children: [N, p && /* @__PURE__ */ l("span", {
45
+ children: [h, m && /* @__PURE__ */ l("span", {
43
46
  className: a.emojiSlot,
44
- children: /* @__PURE__ */ l(R, {
47
+ children: /* @__PURE__ */ l(H, {
45
48
  option: e,
46
49
  className: a.emoji
47
50
  })
@@ -51,209 +54,240 @@ var V = {
51
54
  children: e.label
52
55
  }) : /* @__PURE__ */ l("span", {
53
56
  className: "sr-only",
54
- children: C(e, n, h)
57
+ children: R(e, n, o)
55
58
  })]
56
59
  });
57
- }, X = (e) => {
60
+ }, D = ({ dataTest: e, text: n, onClear: o, focusAfter: h }) => /* @__PURE__ */ l(q, {
61
+ dataTest: `${e}-clear`,
62
+ variant: "text",
63
+ type: "button",
64
+ className: a.clear,
65
+ startIcon: /* @__PURE__ */ l(F, {
66
+ width: 24,
67
+ height: 24
68
+ }),
69
+ onClick: () => {
70
+ o(), h()?.focus({ preventScroll: !0 });
71
+ },
72
+ children: n.clearSelection
73
+ }), J = (e) => {
58
74
  e.key === "Enter" && (e.preventDefault(), e.currentTarget.click());
59
- }, B = ({ dataTest: e, options: n, value: h, onValueChange: N, question: p, "aria-labelledby": y, name: m, error: o, helperText: b, className: O, text: w }) => {
60
- const v = j(), c = j(), { show: s, role: g } = q("StyledEmojiChoice", o, b);
75
+ }, Q = ({ dataTest: e, options: n, value: o, onValueChange: h, onClear: m, question: O, "aria-labelledby": c, name: p, error: N, helperText: y, className: g, text: b }) => {
76
+ const d = w(), s = w(), v = E(null), { show: S, role: A } = V("StyledEmojiChoice", N, y), I = n.some((r) => r.value === o);
61
77
  return /* @__PURE__ */ f("fieldset", {
78
+ ref: v,
79
+ tabIndex: -1,
62
80
  role: "group",
63
- "aria-labelledby": y,
64
- "aria-describedby": s ? c : void 0,
81
+ "aria-labelledby": c,
82
+ "aria-describedby": S ? s : void 0,
65
83
  "data-testid": e,
66
- className: u(a.group, O),
84
+ className: u(a.group, g),
67
85
  children: [
68
- !y && /* @__PURE__ */ l("legend", {
86
+ !c && /* @__PURE__ */ l("legend", {
69
87
  className: a.question,
70
- children: p
88
+ children: O
71
89
  }),
72
90
  /* @__PURE__ */ l("div", {
73
91
  className: a.options,
74
- children: n.map((d, t) => {
75
- const I = d.value === h;
92
+ children: n.map((r, j) => {
93
+ const C = r.value === o;
76
94
  return /* @__PURE__ */ f("label", {
77
- "data-testid": `${e}-option-${t}`,
78
- className: u(a.card, a.choice, !d.label && a.fit),
95
+ "data-testid": `${e}-option-${j}`,
96
+ className: u(a.card, a.choice, !r.label && a.fit),
79
97
  children: [/* @__PURE__ */ l("input", {
80
98
  type: "radio",
81
99
  className: "sr-only",
82
- name: m ?? v,
83
- value: d.value,
84
- checked: I,
85
- onChange: () => N?.(d.value, d),
86
- onKeyDown: X
100
+ name: p ?? d,
101
+ value: r.value,
102
+ checked: C,
103
+ onChange: () => h?.(r.value, r),
104
+ onKeyDown: J
87
105
  }), /* @__PURE__ */ l("span", {
88
106
  className: a.body,
89
- children: /* @__PURE__ */ l(S, {
90
- option: d,
91
- position: t + 1,
92
- text: w,
93
- radio: /* @__PURE__ */ l($, {
107
+ children: /* @__PURE__ */ l($, {
108
+ option: r,
109
+ position: j + 1,
110
+ text: b,
111
+ radio: /* @__PURE__ */ l(T, {
94
112
  decorative: !0,
95
- checked: I
113
+ checked: C
96
114
  })
97
115
  })
98
116
  })]
99
- }, `${t}-${d.value}`);
117
+ }, `${j}-${r.value}`);
100
118
  })
101
119
  }),
102
- s && /* @__PURE__ */ l(H, {
103
- id: c,
104
- role: g,
105
- error: o,
106
- message: b,
107
- className: u("m-0", o && "font-medium")
120
+ m && I && /* @__PURE__ */ l(D, {
121
+ dataTest: e,
122
+ text: b,
123
+ onClear: m,
124
+ focusAfter: () => v.current
125
+ }),
126
+ S && /* @__PURE__ */ l(M, {
127
+ id: s,
128
+ role: A,
129
+ error: N,
130
+ message: y,
131
+ className: u("m-0", N && "font-medium")
108
132
  })
109
133
  ]
110
134
  });
111
- }, G = ({ dataTest: e, options: n, value: h, onValueChange: N, question: p, "aria-labelledby": y, error: m, helperText: o, placeholder: b, locale: O, className: w, text: v }) => {
112
- const c = j(), [s, g] = T(null), d = M(!1), t = n.find((r) => r.value === h) ?? null, I = t ? C(t, n.indexOf(t) + 1, v) : "", _ = s === null && t !== null && (t.label !== "" || !t.emoji);
135
+ }, U = ({ dataTest: e, options: n, value: o, onValueChange: h, onClear: m, question: O, "aria-labelledby": c, error: p, helperText: N, placeholder: y, locale: g, className: b, text: d }) => {
136
+ const s = w(), v = E(null), [S, A] = x(null), I = E(!1), r = n.find((t) => t.value === o) ?? null, j = r ? R(r, n.indexOf(r) + 1, d) : "", C = S === null && r !== null && (r.label !== "" || !r.emoji);
113
137
  return /* @__PURE__ */ f("div", {
114
- className: u(a.dropdown, w),
115
- children: [!y && /* @__PURE__ */ l("span", {
116
- id: c,
117
- className: a.question,
118
- children: p
119
- }), /* @__PURE__ */ l(F, {
120
- dataTest: e,
121
- options: n,
122
- value: t,
123
- onChange: (r, i) => {
124
- i && N?.(i.value, i);
125
- },
126
- getOptionLabel: (r) => C(r, n.indexOf(r) + 1, v),
127
- getOptionKey: (r) => r.value,
128
- isOptionEqualToValue: (r, i) => r.value === i.value,
129
- inputValue: s ?? I,
130
- onInputChange: (r, i, A) => g(A === "input" ? i : null),
131
- onClose: () => g(null),
132
- disableClearable: !0,
133
- error: m,
134
- helperText: o,
135
- pickerTitle: p,
136
- locale: O,
137
- noOptionsText: L(O ?? "en").noMatches,
138
- maxListHeight: 322,
139
- slotProps: { popper: { className: a.menu } },
140
- renderOption: ({ key: r, className: i, ...A }, E, k) => /* @__PURE__ */ l("li", {
141
- ...A,
142
- className: u(a.menuOption, k.inPicker && a.pickerOption),
143
- children: /* @__PURE__ */ l("span", {
144
- className: u(a.card, a.body),
145
- children: /* @__PURE__ */ l(S, {
146
- option: E,
147
- position: n.indexOf(E) + 1,
148
- text: v,
149
- radio: /* @__PURE__ */ l($, {
150
- decorative: !0,
151
- checked: k.selected
138
+ ref: v,
139
+ className: u(a.dropdown, b),
140
+ children: [
141
+ !c && /* @__PURE__ */ l("span", {
142
+ id: s,
143
+ className: a.question,
144
+ children: O
145
+ }),
146
+ /* @__PURE__ */ l(B, {
147
+ dataTest: e,
148
+ options: n,
149
+ value: r,
150
+ onChange: (t, i) => {
151
+ i && h?.(i.value, i);
152
+ },
153
+ getOptionLabel: (t) => R(t, n.indexOf(t) + 1, d),
154
+ getOptionKey: (t) => t.value,
155
+ isOptionEqualToValue: (t, i) => t.value === i.value,
156
+ inputValue: S ?? j,
157
+ onInputChange: (t, i, k) => A(k === "input" ? i : null),
158
+ onClose: () => A(null),
159
+ disableClearable: !0,
160
+ error: p,
161
+ helperText: N,
162
+ pickerTitle: O,
163
+ locale: g,
164
+ noOptionsText: X(g ?? "en").noMatches,
165
+ maxListHeight: 322,
166
+ slotProps: { popper: { className: a.menu } },
167
+ renderOption: ({ key: t, className: i, ...k }, _, P) => /* @__PURE__ */ l("li", {
168
+ ...k,
169
+ className: u(a.menuOption, P.inPicker && a.pickerOption),
170
+ children: /* @__PURE__ */ l("span", {
171
+ className: u(a.card, a.body),
172
+ children: /* @__PURE__ */ l($, {
173
+ option: _,
174
+ position: n.indexOf(_) + 1,
175
+ text: d,
176
+ radio: /* @__PURE__ */ l(T, {
177
+ decorative: !0,
178
+ checked: P.selected
179
+ })
152
180
  })
153
181
  })
154
- })
155
- }, r),
156
- renderInput: (r) => /* @__PURE__ */ l(D, {
157
- ...r,
158
- dataTest: `${e}-input`,
159
- placeholder: b,
160
- onFocus: (i) => {
161
- r.onFocus?.(), i.currentTarget.select(), d.current = !0;
162
- },
163
- onClick: (i) => {
164
- d.current && i.target instanceof HTMLInputElement && i.target.select(), d.current = !1;
165
- },
166
- slotProps: {
167
- htmlInput: {
168
- ...r.slotProps.htmlInput,
169
- "aria-labelledby": y ?? c
182
+ }, t),
183
+ renderInput: (t) => /* @__PURE__ */ l(K, {
184
+ ...t,
185
+ dataTest: `${e}-input`,
186
+ placeholder: y,
187
+ onFocus: (i) => {
188
+ t.onFocus?.(), i.currentTarget.select(), I.current = !0;
189
+ },
190
+ onClick: (i) => {
191
+ I.current && i.target instanceof HTMLInputElement && i.target.select(), I.current = !1;
170
192
  },
171
- input: {
172
- ...r.slotProps.input,
173
- startAdornment: t && _ ? /* @__PURE__ */ l(R, {
174
- option: t,
175
- className: a.fieldEmoji
176
- }) : void 0
193
+ slotProps: {
194
+ htmlInput: {
195
+ ...t.slotProps.htmlInput,
196
+ "aria-labelledby": c ?? s
197
+ },
198
+ input: {
199
+ ...t.slotProps.input,
200
+ startAdornment: r && C ? /* @__PURE__ */ l(H, {
201
+ option: r,
202
+ className: a.fieldEmoji
203
+ }) : void 0
204
+ }
177
205
  }
178
- }
206
+ })
207
+ }),
208
+ m && r && /* @__PURE__ */ l(D, {
209
+ dataTest: e,
210
+ text: d,
211
+ onClear: m,
212
+ focusAfter: () => v.current?.querySelector("input")
179
213
  })
180
- })]
214
+ ]
181
215
  });
182
- }, z = ({ dataTest: e, options: n, value: h, question: N, "aria-labelledby": p, className: y, text: m }) => {
183
- const [o, b] = T(!1), O = j(), w = j(), v = j(), c = n.find((s) => s.value === h);
216
+ }, W = ({ dataTest: e, options: n, value: o, question: h, "aria-labelledby": m, className: O, text: c }) => {
217
+ const [p, N] = x(!1), y = w(), g = w(), b = w(), d = n.find((s) => s.value === o);
184
218
  return /* @__PURE__ */ f("dl", {
185
219
  "data-testid": e,
186
- className: u(a.readOnly, y),
220
+ className: u(a.readOnly, O),
187
221
  children: [/* @__PURE__ */ l("dt", {
188
- id: O,
189
- className: p ? "sr-only" : a.question,
190
- children: N
222
+ id: y,
223
+ className: m ? "sr-only" : a.question,
224
+ children: h
191
225
  }), /* @__PURE__ */ f("dd", {
192
226
  className: a.readOnlyAnswer,
193
227
  children: [/* @__PURE__ */ f("div", {
194
228
  className: a.readOnlyCard,
195
- children: [c ? /* @__PURE__ */ l(S, {
196
- option: c,
197
- position: n.indexOf(c) + 1,
198
- text: m
229
+ children: [d ? /* @__PURE__ */ l($, {
230
+ option: d,
231
+ position: n.indexOf(d) + 1,
232
+ text: c
199
233
  }) : /* @__PURE__ */ l("span", {
200
234
  className: a.noAnswer,
201
- children: m.noAnswer
202
- }), n.length > 0 && /* @__PURE__ */ l(x, {
235
+ children: c.noAnswer
236
+ }), n.length > 0 && /* @__PURE__ */ l(q, {
203
237
  dataTest: `${e}-show-all`,
204
238
  variant: "text",
205
239
  type: "button",
206
240
  className: a.showAll,
207
- "aria-expanded": o,
208
- "aria-controls": v,
209
- "aria-labelledby": `${w} ${O}`,
210
- endIcon: /* @__PURE__ */ l(P, {
241
+ "aria-expanded": p,
242
+ "aria-controls": b,
243
+ "aria-labelledby": `${g} ${y}`,
244
+ endIcon: /* @__PURE__ */ l(L, {
211
245
  width: 24,
212
246
  height: 24,
213
- className: u(o && "flip-180")
247
+ className: u(p && "flip-180")
214
248
  }),
215
- onClick: () => b(!o),
249
+ onClick: () => N(!p),
216
250
  children: /* @__PURE__ */ l("span", {
217
- id: w,
218
- children: o ? m.hideOptions : m.showAllOptions(n.length)
251
+ id: g,
252
+ children: p ? c.hideOptions : c.showAllOptions(n.length)
219
253
  })
220
254
  })]
221
255
  }), /* @__PURE__ */ l("ul", {
222
- id: v,
223
- hidden: !o,
256
+ id: b,
257
+ hidden: !p,
224
258
  className: a.options,
225
- children: n.map((s, g) => /* @__PURE__ */ f("li", {
259
+ children: n.map((s, v) => /* @__PURE__ */ f("li", {
226
260
  className: u(a.card, a.body, !s.label && a.fit),
227
- children: [/* @__PURE__ */ l(S, {
261
+ children: [/* @__PURE__ */ l($, {
228
262
  option: s,
229
- position: g + 1,
230
- text: m,
231
- radio: /* @__PURE__ */ l($, {
263
+ position: v + 1,
264
+ text: c,
265
+ radio: /* @__PURE__ */ l(T, {
232
266
  decorative: !0,
233
267
  readOnly: !0,
234
- checked: s === c
268
+ checked: s === d
235
269
  })
236
- }), s === c && /* @__PURE__ */ l("span", {
270
+ }), s === d && /* @__PURE__ */ l("span", {
237
271
  className: "sr-only",
238
- children: `, ${m.selected}`
272
+ children: `, ${c.selected}`
239
273
  })]
240
- }, `${g}-${s.value}`))
274
+ }, `${v}-${s.value}`))
241
275
  })]
242
276
  })]
243
277
  });
244
- }, te = (e) => {
245
- const n = V[e.locale ?? "en"];
246
- return e.readOnly ? /* @__PURE__ */ l(z, {
278
+ }, me = (e) => {
279
+ const n = G[e.locale ?? "en"];
280
+ return e.readOnly ? /* @__PURE__ */ l(W, {
247
281
  ...e,
248
282
  text: n
249
- }) : e.options.length > K ? /* @__PURE__ */ l(G, {
283
+ }) : e.options.length > z ? /* @__PURE__ */ l(U, {
250
284
  ...e,
251
285
  text: n
252
- }) : /* @__PURE__ */ l(B, {
286
+ }) : /* @__PURE__ */ l(Q, {
253
287
  ...e,
254
288
  text: n
255
289
  });
256
290
  };
257
291
  export {
258
- te as StyledEmojiChoice
292
+ me as StyledEmojiChoice
259
293
  };
@@ -1,27 +1,28 @@
1
- var _ = "_group_xgzbu_1", r = "_question_xgzbu_9", o = "_options_xgzbu_19", a = "_card_xgzbu_31", e = "_body_xgzbu_45", u = "_fit_xgzbu_52", n = "_choice_xgzbu_57", i = "_content_xgzbu_86", x = "_noEmoji_xgzbu_94", b = "_readOnlyCard_xgzbu_97", d = "_lead_xgzbu_101", g = "_emojiSlot_xgzbu_109", t = "_emoji_xgzbu_109", v = "_text_xgzbu_131", z = "_dropdown_xgzbu_139", l = "_fieldEmoji_xgzbu_144", p = "_menuOption_xgzbu_156", m = "_pickerOption_xgzbu_165", c = "_readOnly_xgzbu_97", s = "_readOnlyAnswer_xgzbu_200", O = "_noAnswer_xgzbu_220", j = "_showAll_xgzbu_224", y = {
1
+ var _ = "_group_1lqw7_1", r = "_question_1lqw7_12", l = "_options_1lqw7_22", o = "_card_1lqw7_34", a = "_body_1lqw7_48", e = "_fit_1lqw7_55", w = "_choice_1lqw7_60", n = "_content_1lqw7_89", i = "_noEmoji_1lqw7_97", q = "_readOnlyCard_1lqw7_100", d = "_lead_1lqw7_104", t = "_emojiSlot_1lqw7_112", v = "_emoji_1lqw7_112", c = "_text_1lqw7_134", p = "_dropdown_1lqw7_142", m = "_fieldEmoji_1lqw7_147", s = "_menuOption_1lqw7_159", O = "_pickerOption_1lqw7_168", j = "_readOnly_1lqw7_100", u = "_readOnlyAnswer_1lqw7_203", y = "_noAnswer_1lqw7_223", f = "_showAll_1lqw7_227", A = "_clear_1lqw7_232", h = {
2
2
  group: _,
3
3
  question: r,
4
- options: o,
5
- card: a,
6
- body: e,
7
- fit: u,
8
- choice: n,
9
- content: i,
10
- noEmoji: x,
11
- readOnlyCard: b,
4
+ options: l,
5
+ card: o,
6
+ body: a,
7
+ fit: e,
8
+ choice: w,
9
+ content: n,
10
+ noEmoji: i,
11
+ readOnlyCard: q,
12
12
  lead: d,
13
- emojiSlot: g,
14
- emoji: t,
15
- text: v,
16
- dropdown: z,
17
- fieldEmoji: l,
18
- menuOption: p,
19
- pickerOption: m,
20
- readOnly: c,
21
- readOnlyAnswer: s,
22
- noAnswer: O,
23
- showAll: j
13
+ emojiSlot: t,
14
+ emoji: v,
15
+ text: c,
16
+ dropdown: p,
17
+ fieldEmoji: m,
18
+ menuOption: s,
19
+ pickerOption: O,
20
+ readOnly: j,
21
+ readOnlyAnswer: u,
22
+ noAnswer: y,
23
+ showAll: f,
24
+ clear: A
24
25
  };
25
26
  export {
26
- y as default
27
+ h as default
27
28
  };