@bekk-basen/neutral-ui-do-not-use 0.0.0-dev.85c9640 → 0.0.0-dev.9fa1b12

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/index.js CHANGED
@@ -1,33 +1,38 @@
1
- import { jsx as x, jsxs as he, Fragment as on } from "react/jsx-runtime";
2
- import { Button as rn } from "@base-ui/react/button";
3
- import { cva as Be } from "class-variance-authority";
4
- import { clsx as X } from "clsx";
5
- import { Checkbox as We } from "@base-ui/react/checkbox";
6
- import { Check as Gn } from "lucide-react";
7
- import * as s from "react";
8
- import { createElement as ze, useState as jn } from "react";
9
- const Hn = "bnui-base-wpVVq", Wn = "bnui-primary-OKCHe", zn = "bnui-secondary-dazFR", qn = "bnui-lg-WgiKr", Yn = "bnui-sm-0Kb5B", Zn = "bnui-iconOnly-LsvO8", Jn = "bnui-content-q0g4H", Xn = "bnui-pending-xP-rH", Qn = "bnui-spinner-jLkEm", B = {
10
- base: Hn,
11
- primary: Wn,
12
- secondary: zn,
13
- lg: qn,
14
- sm: Yn,
15
- iconOnly: Zn,
16
- content: Jn,
17
- pending: Xn,
18
- spinner: Qn
19
- }, et = Be(B.base, {
1
+ import { jsx as e, jsxs as m, Fragment as G } from "react/jsx-runtime";
2
+ import { Button as R } from "@base-ui/react/button";
3
+ import { cva as w } from "class-variance-authority";
4
+ import { clsx as l } from "clsx";
5
+ import { Checkbox as L } from "@base-ui/react/checkbox";
6
+ import { Field as v } from "@base-ui/react/field";
7
+ import { Check as D, X as H, ChevronDown as q, UserRound as j } from "lucide-react";
8
+ import { createContext as M, use as X, useMemo as P, useState as Z } from "react";
9
+ import { CheckboxGroup as K } from "@base-ui/react/checkbox-group";
10
+ import { Combobox as d } from "@base-ui/react/combobox";
11
+ import { Select as b } from "@base-ui/react/select";
12
+ import { Form as Q } from "@base-ui/react/form";
13
+ import { Avatar as I } from "@base-ui/react/avatar";
14
+ const W = "bnui-base-wpVVq", U = "bnui-primary-OKCHe", J = "bnui-secondary-dazFR", Y = "bnui-lg-WgiKr", _ = "bnui-sm-0Kb5B", ee = "bnui-iconOnly-LsvO8", oe = "bnui-content-q0g4H", ne = "bnui-pending-xP-rH", te = "bnui-spinner-jLkEm", f = {
15
+ base: W,
16
+ primary: U,
17
+ secondary: J,
18
+ lg: Y,
19
+ sm: _,
20
+ iconOnly: ee,
21
+ content: oe,
22
+ pending: ne,
23
+ spinner: te
24
+ }, re = w(f.base, {
20
25
  variants: {
21
26
  variant: {
22
- primary: B.primary,
23
- secondary: B.secondary
27
+ primary: f.primary,
28
+ secondary: f.secondary
24
29
  },
25
30
  size: {
26
- lg: B.lg,
27
- sm: B.sm
31
+ lg: f.lg,
32
+ sm: f.sm
28
33
  },
29
34
  iconOnly: {
30
- true: B.iconOnly,
35
+ true: f.iconOnly,
31
36
  false: ""
32
37
  }
33
38
  },
@@ -37,45 +42,45 @@ const Hn = "bnui-base-wpVVq", Wn = "bnui-primary-OKCHe", zn = "bnui-secondary-da
37
42
  iconOnly: !1
38
43
  }
39
44
  });
40
- function Vo({
41
- className: e,
45
+ function mo({
46
+ className: o,
42
47
  variant: n,
43
- size: t,
44
- iconOnly: r,
45
- isPending: o,
46
- disabled: i,
47
- children: a,
48
- ...d
48
+ size: r,
49
+ iconOnly: a,
50
+ isPending: i,
51
+ disabled: s,
52
+ children: p,
53
+ ...g
49
54
  }) {
50
- return /* @__PURE__ */ x(
51
- rn,
55
+ return /* @__PURE__ */ e(
56
+ R,
52
57
  {
53
58
  "data-slot": "button",
54
- disabled: o || i,
55
- "aria-busy": o,
56
- className: X(
57
- et({ variant: n, size: t, iconOnly: r }),
58
- o && B.pending,
59
- e
59
+ disabled: i || s,
60
+ "aria-busy": i,
61
+ className: l(
62
+ re({ variant: n, size: r, iconOnly: a }),
63
+ i && f.pending,
64
+ o
60
65
  ),
61
- ...d,
62
- children: o ? /* @__PURE__ */ he(on, { children: [
63
- /* @__PURE__ */ x("span", { className: B.content, children: a }),
64
- /* @__PURE__ */ x("span", { className: B.spinner, "aria-hidden": "true" })
65
- ] }) : a
66
+ ...g,
67
+ children: i ? /* @__PURE__ */ m(G, { children: [
68
+ /* @__PURE__ */ e("span", { className: f.content, children: p }),
69
+ /* @__PURE__ */ e("span", { className: f.spinner, "aria-hidden": "true" })
70
+ ] }) : p
66
71
  }
67
72
  );
68
73
  }
69
- const nt = "bnui-headline-6c9bn", tt = "bnui-button-lekqm", ot = "bnui-body-2BdnA", rt = "bnui-description-6roeu", g = {
70
- headline: nt,
74
+ const z = M(!1), ie = "bnui-headline-6c9bn", ae = "bnui-button-lekqm", se = "bnui-body-2BdnA", ce = "bnui-description-6roeu", t = {
75
+ headline: ie,
71
76
  "headline-sm": "bnui-headline-sm-eesRr",
72
77
  "headline-xs": "bnui-headline-xs-bBHXL",
73
- button: tt,
78
+ button: ae,
74
79
  "body-bold": "bnui-body-bold-0cir6",
75
- body: ot,
80
+ body: se,
76
81
  "body-sm-bold": "bnui-body-sm-bold-9SPZK",
77
82
  "body-sm": "bnui-body-sm-MOXMI",
78
- description: rt,
83
+ description: ce,
79
84
  "color-default": "bnui-color-default-38dch",
80
85
  "color-white": "bnui-color-white-d9q0c",
81
86
  "color-background": "bnui-color-background-Flq4G",
@@ -87,31 +92,31 @@ const nt = "bnui-headline-6c9bn", tt = "bnui-button-lekqm", ot = "bnui-body-2Bdn
87
92
  "color-success": "bnui-color-success-ThRnA",
88
93
  "color-info": "bnui-color-info-PtkS-",
89
94
  "color-interactive": "bnui-color-interactive-b9cqS"
90
- }, it = Be("", {
95
+ }, le = w("", {
91
96
  variants: {
92
97
  variant: {
93
- headline: g.headline,
94
- "headline-sm": g["headline-sm"],
95
- "headline-xs": g["headline-xs"],
96
- button: g.button,
97
- "body-bold": g["body-bold"],
98
- body: g.body,
99
- "body-sm-bold": g["body-sm-bold"],
100
- "body-sm": g["body-sm"],
101
- description: g.description
98
+ headline: t.headline,
99
+ "headline-sm": t["headline-sm"],
100
+ "headline-xs": t["headline-xs"],
101
+ button: t.button,
102
+ "body-bold": t["body-bold"],
103
+ body: t.body,
104
+ "body-sm-bold": t["body-sm-bold"],
105
+ "body-sm": t["body-sm"],
106
+ description: t.description
102
107
  },
103
108
  color: {
104
- default: g["color-default"],
105
- white: g["color-white"],
106
- background: g["color-background"],
107
- surface: g["color-surface"],
108
- "divider-dark": g["color-divider-dark"],
109
- informative: g["color-informative"],
110
- error: g["color-error"],
111
- warning: g["color-warning"],
112
- success: g["color-success"],
113
- info: g["color-info"],
114
- interactive: g["color-interactive"],
109
+ default: t["color-default"],
110
+ white: t["color-white"],
111
+ background: t["color-background"],
112
+ surface: t["color-surface"],
113
+ "divider-dark": t["color-divider-dark"],
114
+ informative: t["color-informative"],
115
+ error: t["color-error"],
116
+ warning: t["color-warning"],
117
+ success: t["color-success"],
118
+ info: t["color-info"],
119
+ interactive: t["color-interactive"],
115
120
  inherit: ""
116
121
  }
117
122
  },
@@ -119,7 +124,7 @@ const nt = "bnui-headline-6c9bn", tt = "bnui-button-lekqm", ot = "bnui-body-2Bdn
119
124
  variant: "body",
120
125
  color: "default"
121
126
  }
122
- }), st = {
127
+ }), de = {
123
128
  headline: "h1",
124
129
  "headline-sm": "h2",
125
130
  "headline-xs": "h3",
@@ -130,1204 +135,450 @@ const nt = "bnui-headline-6c9bn", tt = "bnui-button-lekqm", ot = "bnui-body-2Bdn
130
135
  description: "p",
131
136
  button: "span"
132
137
  };
133
- function at({
134
- variant: e = "body",
138
+ function V({
139
+ variant: o = "body",
135
140
  color: n,
136
- as: t,
137
- className: r,
138
- ...o
141
+ as: r,
142
+ className: a,
143
+ ...i
139
144
  }) {
140
- const i = t ?? st[e];
141
- return /* @__PURE__ */ x(
142
- i,
145
+ const s = r ?? de[o];
146
+ return /* @__PURE__ */ e(
147
+ s,
143
148
  {
144
149
  "data-slot": "text",
145
- className: X(it({ variant: e, color: n, className: r })),
146
- ...o
150
+ className: l(le({ variant: o, color: n, className: a })),
151
+ ...i
147
152
  }
148
153
  );
149
154
  }
150
- const ct = "bnui-checkbox-mTFTt", lt = "bnui-label-JOyrO", ut = "bnui-indicator-VOiAE", dt = "bnui-check-6pYVz", ue = {
151
- checkbox: ct,
152
- label: lt,
153
- indicator: ut,
154
- check: dt
155
+ const ue = "bnui-checkbox-mTFTt", be = "bnui-label-JOyrO", me = "bnui-indicator-VOiAE", pe = "bnui-check-6pYVz", he = "bnui-item-qNsgX", N = {
156
+ checkbox: ue,
157
+ label: be,
158
+ indicator: me,
159
+ check: pe,
160
+ item: he
155
161
  };
156
- function Io({ className: e, label: n, ...t }) {
157
- const r = /* @__PURE__ */ x(
158
- We.Root,
162
+ function po({ className: o, label: n, ...r }) {
163
+ const a = X(z), i = /* @__PURE__ */ e(
164
+ L.Root,
159
165
  {
160
166
  "data-slot": "checkbox",
161
- className: X(ue.checkbox, e),
162
- ...t,
163
- children: /* @__PURE__ */ x(
164
- We.Indicator,
167
+ className: l(N.checkbox, o),
168
+ ...r,
169
+ children: /* @__PURE__ */ e(
170
+ L.Indicator,
165
171
  {
166
172
  "data-slot": "checkbox-indicator",
167
- className: ue.indicator,
168
- children: /* @__PURE__ */ x(Gn, { className: ue.check })
173
+ className: N.indicator,
174
+ children: /* @__PURE__ */ e(D, { className: N.check })
169
175
  }
170
176
  )
171
177
  }
172
178
  );
173
- return n === void 0 ? r : /* @__PURE__ */ he("label", { className: ue.label, children: [
174
- r,
175
- /* @__PURE__ */ x(at, { variant: "body", as: "span", children: n })
179
+ if (n === void 0) return i;
180
+ const s = /* @__PURE__ */ m(G, { children: [
181
+ i,
182
+ /* @__PURE__ */ e(V, { variant: "body", as: "span", children: n })
176
183
  ] });
184
+ return a ? /* @__PURE__ */ e(v.Item, { className: N.item, children: /* @__PURE__ */ e(v.Label, { className: N.label, children: s }) }) : /* @__PURE__ */ e("label", { className: N.label, children: s });
177
185
  }
178
- let Re;
179
- process.env.NODE_ENV !== "production" && (Re = /* @__PURE__ */ new Set());
180
- function pe(...e) {
181
- if (process.env.NODE_ENV !== "production") {
182
- const n = e.join(" ");
183
- Re.has(n) || (Re.add(n), console.error(`Base UI: ${n}`));
184
- }
185
- }
186
- function sn({
187
- controlled: e,
188
- default: n,
189
- name: t,
190
- state: r = "value"
186
+ const fe = "bnui-group-76ZZz", ge = "bnui-column-ev6Qg", ye = "bnui-row-K6-hO", T = {
187
+ group: fe,
188
+ column: ge,
189
+ row: ye
190
+ };
191
+ function ho({
192
+ className: o,
193
+ orientation: n = "row",
194
+ ...r
191
195
  }) {
192
- const {
193
- current: o
194
- } = s.useRef(e !== void 0), [i, a] = s.useState(n), d = o ? e : i;
195
- if (process.env.NODE_ENV !== "production") {
196
- s.useEffect(() => {
197
- o !== (e !== void 0) && pe([`A component is changing the ${o ? "" : "un"}controlled ${r} state of ${t} to be ${o ? "un" : ""}controlled.`, "Elements should not switch from uncontrolled to controlled (or vice versa).", `Decide between using a controlled or uncontrolled ${t} element for the lifetime of the component.`, "The nature of the state is determined during the first render. It's considered controlled if the value is not `undefined`.", "More info: https://fb.me/react-controlled-components"].join(`
198
- `));
199
- }, [r, t, e]);
200
- const {
201
- current: u
202
- } = s.useRef(n);
203
- s.useEffect(() => {
204
- !o && qe(u) !== qe(n) && pe([`A component is changing the default ${r} state of an uncontrolled ${t} after being initialized. To suppress this warning opt to use a controlled ${t}.`].join(`
205
- `));
206
- }, [n]);
207
- }
208
- const f = s.useCallback((u) => {
209
- o || a(u);
210
- }, []);
211
- return [d, f];
212
- }
213
- function qe(e) {
214
- let n = 0;
215
- const t = /* @__PURE__ */ new WeakMap();
216
- try {
217
- return JSON.stringify(e, function(i, a) {
218
- if (!(i === "_owner" && this != null && typeof this == "object" && "$$typeof" in this)) {
219
- if (typeof a == "bigint")
220
- return `__bigint__:${a}`;
221
- if (a !== null && typeof a == "object") {
222
- const d = t.get(a);
223
- if (d !== void 0)
224
- return `__object__:${d}`;
225
- t.set(a, n), n += 1;
226
- }
227
- return a;
228
- }
229
- }) ?? `__top__:${typeof e}`;
230
- } catch {
231
- return "__unserializable__";
232
- }
233
- }
234
- const Ye = {};
235
- function ge(e, n) {
236
- const t = s.useRef(Ye);
237
- return t.current === Ye && (t.current = e(n)), t;
238
- }
239
- const Ie = s[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0, -3)], ft = (
240
- // React 17 doesn't have useInsertionEffect.
241
- Ie && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
242
- Ie !== s.useLayoutEffect ? Ie : (e) => e()
243
- );
244
- function re(e) {
245
- const n = ge(pt).current;
246
- return n.next = e, ft(n.effect), n.trampoline;
247
- }
248
- function pt() {
249
- const e = {
250
- next: void 0,
251
- callback: bt,
252
- trampoline: (...n) => e.callback?.(...n),
253
- effect: () => {
254
- e.callback = e.next;
196
+ return /* @__PURE__ */ e(
197
+ K,
198
+ {
199
+ "data-slot": "checkbox-group",
200
+ className: l(
201
+ T.group,
202
+ n === "column" ? T.column : T.row,
203
+ o
204
+ ),
205
+ ...r
255
206
  }
256
- };
257
- return e;
258
- }
259
- function bt() {
260
- if (process.env.NODE_ENV !== "production")
261
- throw (
262
- /* minify-error-disabled */
263
- new Error("Base UI: Cannot call an event handler while rendering.")
264
- );
207
+ );
265
208
  }
266
- function I() {
209
+ const ve = "bnui-textarea-6uYeG", ke = {
210
+ textarea: ve
211
+ }, Ne = w(ke.textarea);
212
+ function fo({ className: o, ...n }) {
213
+ return /* @__PURE__ */ e(
214
+ v.Control,
215
+ {
216
+ "data-slot": "textarea",
217
+ render: /* @__PURE__ */ e("textarea", {}),
218
+ className: l(Ne(), o),
219
+ ...n
220
+ }
221
+ );
267
222
  }
268
- const Ze = Object.freeze([]), D = Object.freeze({}), Pe = {
269
- ...s
223
+ const xe = "bnui-inputGroup-csN7g", $e = "bnui-trigger-OmLpc", Oe = "bnui-clear-7uf1z", Fe = "bnui-input-7-Mc5", Ce = "bnui-icon-krESh", Se = "bnui-positioner-Q2F1m", we = "bnui-popup-1NCxE", Ve = "bnui-list-7LeQ6", Ie = "bnui-item-yAkmq", Te = "bnui-empty-V8bpF", u = {
224
+ inputGroup: xe,
225
+ trigger: $e,
226
+ clear: Oe,
227
+ input: Fe,
228
+ icon: Ce,
229
+ positioner: Se,
230
+ popup: we,
231
+ list: Ve,
232
+ item: Ie,
233
+ empty: Te
270
234
  };
271
- let Je = 0;
272
- function mt(e, n = "mui") {
273
- const [t, r] = s.useState(e), o = e || t;
274
- return s.useEffect(() => {
275
- t == null && (Je += 1, r(`${n}-${Je}`));
276
- }, [t, n]), o;
277
- }
278
- const Xe = Pe.useId;
279
- function ht(e, n) {
280
- if (Xe !== void 0) {
281
- const t = Xe();
282
- return e ?? `${n}-${t}`;
283
- }
284
- return mt(e, n);
285
- }
286
- function oe(e) {
287
- return ht(e, "base-ui");
288
- }
289
- function gt(e, n) {
290
- return function(r, ...o) {
291
- const i = new URL(e);
292
- return i.searchParams.set("code", r.toString()), o.forEach((a) => i.searchParams.append("args[]", a)), `${n} error #${r}; visit ${i} for the full message.`;
293
- };
294
- }
295
- const ye = gt("https://base-ui.com/production-error", "Base UI");
296
- function Te(e, n, t, r) {
297
- const o = ge(an).current;
298
- return Et(o, e, n, t, r) && cn(o, [e, n, t, r]), o.callback;
299
- }
300
- function yt(e) {
301
- const n = ge(an).current;
302
- return Ct(n, e) && cn(n, e), n.callback;
303
- }
304
- function an() {
305
- return {
306
- callback: null,
307
- cleanup: null,
308
- refs: []
235
+ function go({
236
+ items: o,
237
+ placeholder: n,
238
+ clearable: r = !0,
239
+ className: a,
240
+ disabled: i,
241
+ inputRef: s,
242
+ onFocus: p,
243
+ onBlur: g,
244
+ "aria-label": y,
245
+ "aria-labelledby": k,
246
+ ...O
247
+ }) {
248
+ const F = P(() => o.map((c) => c.value), [o]), C = P(() => {
249
+ const c = /* @__PURE__ */ new Map();
250
+ for (const h of o) c.set(h.value, h.label);
251
+ return c;
252
+ }, [o]), S = {
253
+ ...y !== void 0 && { "aria-label": y },
254
+ ...k !== void 0 && { "aria-labelledby": k }
309
255
  };
310
- }
311
- function Et(e, n, t, r, o) {
312
- return e.refs[0] !== n || e.refs[1] !== t || e.refs[2] !== r || e.refs[3] !== o;
313
- }
314
- function Ct(e, n) {
315
- return e.refs.length !== n.length || e.refs.some((t, r) => t !== n[r]);
316
- }
317
- function cn(e, n) {
318
- if (e.refs = n, n.every((t) => t == null)) {
319
- e.callback = null;
320
- return;
321
- }
322
- e.callback = (t) => {
323
- if (e.cleanup && (e.cleanup(), e.cleanup = null), t != null) {
324
- const r = Array(n.length).fill(null);
325
- for (let o = 0; o < n.length; o += 1) {
326
- const i = n[o];
327
- if (i != null)
328
- switch (typeof i) {
329
- case "function": {
330
- const a = i(t);
331
- typeof a == "function" && (r[o] = a);
332
- break;
333
- }
334
- case "object": {
335
- i.current = t;
336
- break;
337
- }
256
+ return /* @__PURE__ */ m(
257
+ d.Root,
258
+ {
259
+ autoHighlight: !0,
260
+ items: F,
261
+ disabled: i,
262
+ itemToStringLabel: (c) => C.get(c) ?? c,
263
+ ...O,
264
+ children: [
265
+ /* @__PURE__ */ m(
266
+ d.InputGroup,
267
+ {
268
+ className: l(u.inputGroup, a),
269
+ children: [
270
+ /* @__PURE__ */ e(
271
+ d.Input,
272
+ {
273
+ ref: s,
274
+ onFocus: p,
275
+ onBlur: g,
276
+ placeholder: n,
277
+ ...S,
278
+ className: u.input
279
+ }
280
+ ),
281
+ r && /* @__PURE__ */ e(
282
+ d.Clear,
283
+ {
284
+ "aria-label": "Fjern valgt verdi",
285
+ className: u.clear,
286
+ children: /* @__PURE__ */ e(H, { "aria-hidden": !0, className: u.icon, strokeWidth: 2 })
287
+ }
288
+ ),
289
+ /* @__PURE__ */ e(
290
+ d.Trigger,
291
+ {
292
+ "aria-label": "Vis alternativer",
293
+ className: u.trigger,
294
+ children: /* @__PURE__ */ e(
295
+ d.Icon,
296
+ {
297
+ render: /* @__PURE__ */ e(
298
+ q,
299
+ {
300
+ "aria-hidden": !0,
301
+ className: u.icon,
302
+ strokeWidth: 2
303
+ }
304
+ )
305
+ }
306
+ )
307
+ }
308
+ )
309
+ ]
338
310
  }
339
- }
340
- e.cleanup = () => {
341
- for (let o = 0; o < n.length; o += 1) {
342
- const i = n[o];
343
- if (i != null)
344
- switch (typeof i) {
345
- case "function": {
346
- const a = r[o];
347
- typeof a == "function" ? a() : i(null);
348
- break;
349
- }
350
- case "object": {
351
- i.current = null;
352
- break;
353
- }
354
- }
355
- }
356
- };
357
- }
358
- };
359
- }
360
- const vt = parseInt(s.version, 10);
361
- function kt(e) {
362
- return vt >= e;
363
- }
364
- function Qe(e) {
365
- if (!/* @__PURE__ */ s.isValidElement(e))
366
- return null;
367
- const n = e, t = n.props;
368
- return (kt(19) ? t?.ref : n.ref) ?? null;
369
- }
370
- function Se(e, n) {
371
- if (e && !n)
372
- return e;
373
- if (!e && n)
374
- return n;
375
- if (e || n)
376
- return {
377
- ...e,
378
- ...n
379
- };
380
- }
381
- let _e;
382
- process.env.NODE_ENV !== "production" && (_e = /* @__PURE__ */ new Set());
383
- function xt(...e) {
384
- if (process.env.NODE_ENV !== "production") {
385
- const n = e.join(" ");
386
- _e.has(n) || (_e.add(n), console.warn(`Base UI: ${n}`));
387
- }
388
- }
389
- function wt(e, n) {
390
- const t = {};
391
- for (const r in e) {
392
- const o = e[r];
393
- if (n?.hasOwnProperty(r)) {
394
- const i = n[r](o);
395
- i != null && Object.assign(t, i);
396
- continue;
311
+ ),
312
+ /* @__PURE__ */ e(d.Portal, { children: /* @__PURE__ */ e(
313
+ d.Positioner,
314
+ {
315
+ side: "bottom",
316
+ sideOffset: -2,
317
+ className: u.positioner,
318
+ children: /* @__PURE__ */ m(d.Popup, { className: u.popup, children: [
319
+ /* @__PURE__ */ e(d.Empty, { className: u.empty, children: "Ingen treff" }),
320
+ /* @__PURE__ */ e(d.List, { className: u.list, children: (c) => /* @__PURE__ */ e(
321
+ d.Item,
322
+ {
323
+ value: c,
324
+ className: u.item,
325
+ children: C.get(c)
326
+ },
327
+ c
328
+ ) })
329
+ ] })
330
+ }
331
+ ) })
332
+ ]
397
333
  }
398
- o === !0 ? t[`data-${r.toLowerCase()}`] = "" : o && (t[`data-${r.toLowerCase()}`] = o.toString());
399
- }
400
- return t;
401
- }
402
- function Nt(e, n) {
403
- return typeof e == "function" ? e(n) : e;
404
- }
405
- function Vt(e, n) {
406
- return typeof e == "function" ? e(n) : e;
407
- }
408
- const De = {};
409
- function Ee(e, n, t, r, o) {
410
- if (!t && !r && !e)
411
- return be(n);
412
- let i = be(e);
413
- return n && (i = fe(i, n)), t && (i = fe(i, t)), r && (i = fe(i, r)), i;
414
- }
415
- function It(e) {
416
- if (e.length === 0)
417
- return De;
418
- if (e.length === 1)
419
- return be(e[0]);
420
- let n = be(e[0]);
421
- for (let t = 1; t < e.length; t += 1)
422
- n = fe(n, e[t]);
423
- return n;
424
- }
425
- function be(e) {
426
- return $e(e) ? {
427
- ...un(e, De)
428
- } : Ot(e);
429
- }
430
- function fe(e, n) {
431
- return $e(n) ? un(n, e) : Rt(e, n);
334
+ );
432
335
  }
433
- function Ot(e) {
434
- const n = {
435
- ...e
336
+ const Ae = "bnui-trigger-38Xpm", Ee = "bnui-chevron-FhAbo", Ge = "bnui-positioner-kU88Q", Le = "bnui-popup-eNosq", Pe = "bnui-list-rnBdZ", Re = "bnui-item-czzad", x = {
337
+ trigger: Ae,
338
+ chevron: Ee,
339
+ positioner: Ge,
340
+ popup: Le,
341
+ list: Pe,
342
+ item: Re
343
+ };
344
+ function yo({
345
+ items: o,
346
+ placeholder: n,
347
+ className: r,
348
+ disabled: a,
349
+ "aria-label": i,
350
+ "aria-labelledby": s,
351
+ ...p
352
+ }) {
353
+ const g = {
354
+ ...i !== void 0 && { "aria-label": i },
355
+ ...s !== void 0 && { "aria-labelledby": s }
436
356
  };
437
- for (const t in n) {
438
- const r = n[t];
439
- ln(t, r) && (n[t] = dn(r));
440
- }
441
- return n;
442
- }
443
- function Rt(e, n) {
444
- if (!n)
445
- return e;
446
- for (const t in n) {
447
- const r = n[t];
448
- switch (t) {
449
- case "style": {
450
- e[t] = Se(e.style, r);
451
- break;
357
+ return /* @__PURE__ */ m(b.Root, { disabled: a, items: o, ...p, children: [
358
+ /* @__PURE__ */ m(
359
+ b.Trigger,
360
+ {
361
+ "data-slot": "select-trigger",
362
+ ...g,
363
+ className: l(x.trigger, r),
364
+ children: [
365
+ /* @__PURE__ */ e(b.Value, { placeholder: n }),
366
+ /* @__PURE__ */ e(
367
+ b.Icon,
368
+ {
369
+ render: /* @__PURE__ */ e(
370
+ q,
371
+ {
372
+ "aria-hidden": !0,
373
+ className: x.chevron,
374
+ strokeWidth: 2
375
+ }
376
+ )
377
+ }
378
+ )
379
+ ]
452
380
  }
453
- case "className": {
454
- e[t] = fn(e.className, r);
455
- break;
381
+ ),
382
+ /* @__PURE__ */ e(b.Portal, { children: /* @__PURE__ */ e(
383
+ b.Positioner,
384
+ {
385
+ alignItemWithTrigger: !1,
386
+ side: "bottom",
387
+ sideOffset: -2,
388
+ className: x.positioner,
389
+ children: /* @__PURE__ */ e(b.Popup, { className: x.popup, children: /* @__PURE__ */ e(b.List, { className: x.list, children: o.map(({ value: y, label: k }) => /* @__PURE__ */ e(
390
+ b.Item,
391
+ {
392
+ value: y,
393
+ className: x.item,
394
+ children: /* @__PURE__ */ e(b.ItemText, { children: k })
395
+ },
396
+ y
397
+ )) }) })
456
398
  }
457
- default:
458
- ln(t, r) ? e[t] = Pt(e[t], r) : e[t] = r;
459
- }
460
- }
461
- return e;
462
- }
463
- function ln(e, n) {
464
- const t = e.charCodeAt(0), r = e.charCodeAt(1), o = e.charCodeAt(2);
465
- return t === 111 && r === 110 && o >= 65 && o <= 90 && (typeof n == "function" || typeof n > "u");
466
- }
467
- function $e(e) {
468
- return typeof e == "function";
469
- }
470
- function un(e, n) {
471
- return $e(e) ? e(n) : e ?? De;
472
- }
473
- function Pt(e, n) {
474
- return n ? e ? (...t) => {
475
- const r = t[0];
476
- if (pn(r)) {
477
- const i = r;
478
- me(i);
479
- const a = n(...t);
480
- return i.baseUIHandlerPrevented || e?.(...t), a;
481
- }
482
- const o = n(...t);
483
- return e?.(...t), o;
484
- } : dn(n) : e;
485
- }
486
- function dn(e) {
487
- return e && ((...n) => {
488
- const t = n[0];
489
- return pn(t) && me(t), e(...n);
490
- });
491
- }
492
- function me(e) {
493
- return e.preventBaseUIHandler = () => {
494
- e.baseUIHandlerPrevented = !0;
495
- }, e;
496
- }
497
- function fn(e, n) {
498
- return n ? e ? n + " " + e : n : e;
499
- }
500
- function pn(e) {
501
- return e != null && typeof e == "object" && "nativeEvent" in e;
502
- }
503
- function bn(e, n, t = {}) {
504
- const r = n.render, o = Tt(n, t);
505
- if (t.enabled === !1)
506
- return null;
507
- const i = t.state ?? D;
508
- return $t(e, r, o, i);
509
- }
510
- function Tt(e, n = {}) {
511
- const {
512
- className: t,
513
- style: r,
514
- render: o
515
- } = e, {
516
- state: i = D,
517
- ref: a,
518
- props: d,
519
- stateAttributesMapping: f,
520
- enabled: u = !0
521
- } = n, p = u ? Nt(t, i) : void 0, h = u ? Vt(r, i) : void 0, N = u ? wt(i, f) : D, m = u && d ? St(d) : void 0, c = u ? Se(N, m) ?? {} : D;
522
- return typeof document < "u" && (u ? Array.isArray(a) ? c.ref = yt([c.ref, Qe(o), ...a]) : c.ref = Te(c.ref, Qe(o), a) : Te(null, null)), u ? (p !== void 0 && (c.className = fn(c.className, p)), h !== void 0 && (c.style = Se(c.style, h)), c) : D;
523
- }
524
- function St(e) {
525
- return Array.isArray(e) ? It(e) : Ee(void 0, e);
526
- }
527
- const _t = /* @__PURE__ */ Symbol.for("react.lazy"), Bt = /^[A-Z][A-Za-z0-9$]*$/, Dt = /[a-z]/;
528
- function $t(e, n, t, r) {
529
- if (n) {
530
- if (typeof n == "function")
531
- return process.env.NODE_ENV !== "production" && Mt(n), n(t, r);
532
- const o = Ee(t, n.props);
533
- o.ref = t.ref;
534
- let i = n;
535
- if (i?.$$typeof === _t && (i = s.Children.toArray(n)[0]), process.env.NODE_ENV !== "production" && !/* @__PURE__ */ s.isValidElement(i))
536
- throw new Error(["Base UI: The `render` prop was provided an invalid React element as `React.isValidElement(render)` is `false`.", "A valid React element must be provided to the `render` prop because it is cloned with props to replace the default element.", "https://base-ui.com/r/invalid-render-prop"].join(`
537
- `));
538
- return /* @__PURE__ */ s.cloneElement(i, o);
539
- }
540
- if (e && typeof e == "string")
541
- return At(e, t);
542
- throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: Render element or function are not defined." : ye(8));
543
- }
544
- function Mt(e) {
545
- const n = e.name;
546
- n.length !== 0 && Bt.test(n) && Dt.test(n) && xt(`The \`render\` prop received a function named \`${n}\` that starts with an uppercase letter.`, "This usually means a React component was passed directly as `render={Component}`.", "Base UI calls `render` as a plain function, which can break the Rules of Hooks during reconciliation.", "If this is an intentional render callback, rename it to start with a lowercase letter.", "Use `render={<Component />}` or `render={(props) => <Component {...props} />}` instead.", "https://base-ui.com/r/invalid-render-prop");
547
- }
548
- function At(e, n) {
549
- return e === "button" ? /* @__PURE__ */ ze("button", {
550
- type: "button",
551
- ...n,
552
- key: n.key
553
- }) : e === "img" ? /* @__PURE__ */ ze("img", {
554
- alt: "",
555
- ...n,
556
- key: n.key
557
- }) : /* @__PURE__ */ s.createElement(e, n);
558
- }
559
- const Me = /* @__PURE__ */ s.createContext(void 0);
560
- process.env.NODE_ENV !== "production" && (Me.displayName = "CheckboxGroupContext");
561
- function Lt(e = !0) {
562
- const n = s.useContext(Me);
563
- if (n === void 0 && !e)
564
- throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: CheckboxGroupContext is missing. CheckboxGroup parts must be placed within <CheckboxGroup>." : ye(3));
565
- return n;
566
- }
567
- let en = /* @__PURE__ */ (function(e) {
568
- return e.disabled = "data-disabled", e.valid = "data-valid", e.invalid = "data-invalid", e.touched = "data-touched", e.dirty = "data-dirty", e.filled = "data-filled", e.focused = "data-focused", e;
569
- })({});
570
- const Ut = {
571
- badInput: !1,
572
- customError: !1,
573
- patternMismatch: !1,
574
- rangeOverflow: !1,
575
- rangeUnderflow: !1,
576
- stepMismatch: !1,
577
- tooLong: !1,
578
- tooShort: !1,
579
- typeMismatch: !1,
580
- valid: null,
581
- valueMissing: !1
582
- }, te = {
583
- valid: null,
584
- touched: !1,
585
- dirty: !1,
586
- filled: !1,
587
- focused: !1
588
- }, Ft = {
589
- disabled: !1,
590
- ...te
591
- }, mn = {
592
- valid(e) {
593
- return e === null ? null : e ? {
594
- [en.valid]: ""
595
- } : {
596
- [en.invalid]: ""
597
- };
598
- }
599
- }, hn = /* @__PURE__ */ s.createContext({
600
- invalid: void 0,
601
- name: void 0,
602
- validityData: {
603
- state: Ut,
604
- errors: [],
605
- error: "",
606
- value: "",
607
- initialValue: null
608
- },
609
- setValidityData: I,
610
- disabled: void 0,
611
- touched: te.touched,
612
- setTouched: I,
613
- dirty: te.dirty,
614
- setDirty: I,
615
- filled: te.filled,
616
- setFilled: I,
617
- focused: te.focused,
618
- setFocused: I,
619
- validate: () => null,
620
- validationMode: "onSubmit",
621
- validationDebounceTime: 0,
622
- shouldValidateOnChange: () => !1,
623
- state: Ft,
624
- markedDirtyRef: {
625
- current: !1
626
- },
627
- registerFieldControl: I,
628
- validation: {
629
- getValidationProps: (e = D) => e,
630
- getInputValidationProps: (e = D) => e,
631
- inputRef: {
632
- current: null
633
- },
634
- commit: async () => {
635
- }
636
- }
637
- });
638
- process.env.NODE_ENV !== "production" && (hn.displayName = "FieldRootContext");
639
- function Ae(e = !0) {
640
- const n = s.useContext(hn);
641
- if (n.setValidityData === I && !e)
642
- throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: FieldRootContext is missing. Field parts must be placed within <Field.Root>." : ye(28));
643
- return n;
644
- }
645
- const Kt = () => {
646
- }, H = typeof document < "u" ? s.useLayoutEffect : Kt;
647
- function gn(e, n) {
648
- const {
649
- enabled: t = !0,
650
- getValue: r,
651
- id: o,
652
- value: i
653
- } = n, {
654
- registerFieldControl: a
655
- } = Ae(), d = s.useRef(null);
656
- d.current || (d.current = /* @__PURE__ */ Symbol()), H(() => {
657
- const f = d.current;
658
- if (!(!f || !t))
659
- return a(f, {
660
- controlRef: e,
661
- getValue: r,
662
- id: o,
663
- value: i
664
- }), () => {
665
- a(f, void 0);
666
- };
667
- }, [e, t, r, o, a, i]);
668
- }
669
- const yn = /* @__PURE__ */ s.createContext({
670
- controlId: void 0,
671
- registerControlId: I,
672
- labelId: void 0,
673
- setLabelId: I,
674
- messageIds: [],
675
- setMessageIds: I,
676
- getDescriptionProps: (e) => e
677
- });
678
- process.env.NODE_ENV !== "production" && (yn.displayName = "LabelableContext");
679
- function En() {
680
- return s.useContext(yn);
399
+ ) })
400
+ ] });
681
401
  }
682
- const Cn = {
683
- clipPath: "inset(50%)",
684
- overflow: "hidden",
685
- whiteSpace: "nowrap",
686
- border: 0,
687
- padding: 0,
688
- width: 1,
689
- height: 1,
690
- margin: -1
691
- }, Gt = {
692
- ...Cn,
693
- position: "fixed",
694
- top: 0,
695
- left: 0
696
- }, jt = {
697
- ...Cn,
698
- position: "absolute"
402
+ const qe = "bnui-container-GujCE", ze = "bnui-error-9Pli1", Be = "bnui-errorDot-mVjXf", E = {
403
+ container: qe,
404
+ error: ze,
405
+ errorDot: Be
699
406
  };
700
- let nn = /* @__PURE__ */ (function(e) {
701
- return e.checked = "data-checked", e.unchecked = "data-unchecked", e.indeterminate = "data-indeterminate", e.disabled = "data-disabled", e.readonly = "data-readonly", e.required = "data-required", e.valid = "data-valid", e.invalid = "data-invalid", e.touched = "data-touched", e.dirty = "data-dirty", e.filled = "data-filled", e.focused = "data-focused", e;
702
- })({});
703
- function Ht(e) {
704
- return s.useMemo(() => ({
705
- checked(n) {
706
- return e.indeterminate ? {} : n ? {
707
- [nn.checked]: ""
708
- } : {
709
- [nn.unchecked]: ""
710
- };
711
- },
712
- ...mn
713
- }), [e.indeterminate]);
714
- }
715
- function Wt() {
716
- return typeof window < "u";
717
- }
718
- function zt(e) {
719
- var n;
720
- return (e == null || (n = e.ownerDocument) == null ? void 0 : n.defaultView) || window;
721
- }
722
- function qt(e) {
723
- return Wt() ? e instanceof HTMLElement || e instanceof zt(e).HTMLElement : !1;
724
- }
725
- const vn = /* @__PURE__ */ s.createContext(void 0);
726
- process.env.NODE_ENV !== "production" && (vn.displayName = "CompositeRootContext");
727
- function Yt(e = !1) {
728
- const n = s.useContext(vn);
729
- if (n === void 0 && !e)
730
- throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: CompositeRootContext is missing. Composite parts must be placed within <Composite.Root>." : ye(16));
731
- return n;
732
- }
733
- function Zt(e) {
734
- const {
735
- focusableWhenDisabled: n,
736
- disabled: t,
737
- composite: r = !1,
738
- tabIndex: o = 0,
739
- isNativeButton: i
740
- } = e, a = r && n !== !1, d = r && n === !1;
741
- return {
742
- props: s.useMemo(() => {
743
- const u = {
744
- // allow Tabbing away from focusableWhenDisabled elements
745
- onKeyDown(p) {
746
- t && n && p.key !== "Tab" && p.preventDefault();
747
- }
748
- };
749
- return r || (u.tabIndex = o, !i && t && (u.tabIndex = n ? o : -1)), (i && (n || a) || !i && t) && (u["aria-disabled"] = t), i && (!n || d) && (u.disabled = t), u;
750
- }, [r, t, n, a, d, i, o])
751
- };
752
- }
753
- function Jt(e = {}) {
754
- const {
755
- disabled: n = !1,
756
- focusableWhenDisabled: t,
757
- tabIndex: r = 0,
758
- native: o = !0,
759
- composite: i
760
- } = e, a = s.useRef(null), d = Yt(!0), f = i ?? d !== void 0, {
761
- props: u
762
- } = Zt({
763
- focusableWhenDisabled: t,
764
- disabled: n,
765
- composite: f,
766
- tabIndex: r,
767
- isNativeButton: o
768
- });
769
- process.env.NODE_ENV !== "production" && s.useEffect(() => {
770
- if (!a.current)
771
- return;
772
- const m = de(a.current);
773
- if (o) {
774
- if (!m) {
775
- const c = Pe.captureOwnerStack?.() || "";
776
- pe(`A component that acts as a button expected a native <button> because the \`nativeButton\` prop is true. Rendering a non-<button> removes native button semantics, which can impact forms and accessibility. Use a real <button> in the \`render\` prop, or set \`nativeButton\` to \`false\`.${c}`);
777
- }
778
- } else if (m) {
779
- const c = Pe.captureOwnerStack?.() || "";
780
- pe(`A component that acts as a button expected a non-<button> because the \`nativeButton\` prop is false. Rendering a <button> keeps native behavior while Base UI applies non-native attributes and handlers, which can add unintended extra attributes (such as \`role\` or \`aria-disabled\`). Use a non-<button> in the \`render\` prop, or set \`nativeButton\` to \`true\`.${c}`);
407
+ function vo({ className: o, ...n }) {
408
+ return /* @__PURE__ */ e(z, { value: !0, children: /* @__PURE__ */ e(
409
+ v.Root,
410
+ {
411
+ "data-slot": "field",
412
+ className: l(E.container, o),
413
+ ...n
781
414
  }
782
- }, [o]);
783
- const p = s.useCallback(() => {
784
- const m = a.current;
785
- de(m) && f && n && u.disabled === void 0 && m.disabled && (m.disabled = !1);
786
- }, [n, u.disabled, f]);
787
- H(p, [p]);
788
- const h = s.useCallback((m = {}) => {
789
- const {
790
- onClick: c,
791
- onMouseDown: b,
792
- onKeyUp: E,
793
- onKeyDown: C,
794
- onPointerDown: O,
795
- ...T
796
- } = m;
797
- return Ee({
798
- type: o ? "button" : void 0,
799
- onClick(l) {
800
- if (n) {
801
- l.preventDefault();
802
- return;
803
- }
804
- c?.(l);
805
- },
806
- onMouseDown(l) {
807
- n || b?.(l);
808
- },
809
- onKeyDown(l) {
810
- if (n || (me(l), C?.(l), l.baseUIHandlerPrevented))
811
- return;
812
- const W = l.target === l.currentTarget, $ = l.currentTarget, M = de($), A = !o && Xt($), R = W && (o ? M : !A), L = l.key === "Enter", S = l.key === " ", U = $.getAttribute("role"), z = U?.startsWith("menuitem") || U === "option" || U === "gridcell";
813
- if (W && f && S) {
814
- if (l.defaultPrevented && z)
815
- return;
816
- l.preventDefault(), A || o && M ? ($.click(), l.preventBaseUIHandler()) : R && (c?.(l), l.preventBaseUIHandler());
817
- return;
818
- }
819
- R && (!o && (S || L) && l.preventDefault(), !o && L && c?.(l));
820
- },
821
- onKeyUp(l) {
822
- if (!n) {
823
- if (me(l), E?.(l), l.target === l.currentTarget && o && f && de(l.currentTarget) && l.key === " ") {
824
- l.preventDefault();
825
- return;
826
- }
827
- l.baseUIHandlerPrevented || l.target === l.currentTarget && !o && !f && l.key === " " && c?.(l);
828
- }
829
- },
830
- onPointerDown(l) {
831
- if (n) {
832
- l.preventDefault();
833
- return;
834
- }
835
- O?.(l);
836
- }
837
- }, o ? void 0 : {
838
- role: "button"
839
- }, u, T);
840
- }, [n, u, f, o]), N = re((m) => {
841
- a.current = m, p();
842
- });
843
- return {
844
- getButtonProps: h,
845
- buttonRef: N
846
- };
415
+ ) });
847
416
  }
848
- function de(e) {
849
- return qt(e) && e.tagName === "BUTTON";
850
- }
851
- function Xt(e) {
852
- return !!(e?.tagName === "A" && e?.href);
853
- }
854
- const kn = /* @__PURE__ */ s.createContext({
855
- disabled: !1
856
- });
857
- process.env.NODE_ENV !== "production" && (kn.displayName = "FieldItemContext");
858
- function Qt() {
859
- return s.useContext(kn);
860
- }
861
- const xn = /* @__PURE__ */ s.createContext({
862
- formRef: {
863
- current: {
864
- fields: /* @__PURE__ */ new Map()
417
+ function ko({
418
+ children: o,
419
+ nativeLabel: n = !0,
420
+ ...r
421
+ }) {
422
+ return /* @__PURE__ */ e(
423
+ v.Label,
424
+ {
425
+ "data-slot": "field-label",
426
+ nativeLabel: n,
427
+ render: /* @__PURE__ */ e(V, { variant: "body-sm", as: n ? "label" : "span", children: o }),
428
+ ...r
865
429
  }
866
- },
867
- errors: {},
868
- clearErrors: I,
869
- validationMode: "onSubmit",
870
- submitAttemptedRef: {
871
- current: !1
872
- }
873
- });
874
- process.env.NODE_ENV !== "production" && (xn.displayName = "FormContext");
875
- function wn() {
876
- return s.useContext(xn);
877
- }
878
- function eo(e, n, t, r = !0, o) {
879
- const [i, a] = s.useState(), d = oe(o ? `${o}-label` : void 0), f = e ?? n ?? i;
880
- return H(() => {
881
- const u = e || n || !r ? void 0 : no(t.current, d);
882
- i !== u && a(u);
883
- }), f;
884
- }
885
- function no(e, n) {
886
- const t = to(e);
887
- if (t)
888
- return !t.id && n && (t.id = n), t.id || void 0;
889
- }
890
- function to(e) {
891
- if (!e)
892
- return;
893
- const n = e.parentElement;
894
- if (n && n.tagName === "LABEL")
895
- return n;
896
- const t = e.id;
897
- if (t) {
898
- const o = e.nextElementSibling;
899
- if (o && o.htmlFor === t)
900
- return o;
901
- }
902
- const r = e.labels;
903
- return r && r[0];
904
- }
905
- const Nn = /* @__PURE__ */ s.createContext(void 0);
906
- process.env.NODE_ENV !== "production" && (Nn.displayName = "CheckboxRootContext");
907
- const oo = "none";
908
- function ro(e, n, t, r) {
909
- let o = !1, i = !1;
910
- const a = D;
911
- return {
912
- reason: e,
913
- event: n ?? new Event("base-ui"),
914
- cancel() {
915
- o = !0;
916
- },
917
- allowPropagation() {
918
- i = !0;
919
- },
920
- get isCanceled() {
921
- return o;
922
- },
923
- get isPropagationAllowed() {
924
- return i;
925
- },
926
- trigger: t,
927
- ...a
928
- };
929
- }
930
- function Vn(e, n) {
931
- const t = s.useRef(e), r = re(n);
932
- H(() => {
933
- t.current !== e && r(t.current);
934
- }, [e, r]), H(() => {
935
- t.current = e;
936
- }, [e]);
430
+ );
937
431
  }
938
- const In = "data-parent", io = /* @__PURE__ */ s.forwardRef(function(n, t) {
939
- const {
940
- checked: r,
941
- className: o,
942
- defaultChecked: i = !1,
943
- "aria-labelledby": a,
944
- disabled: d = !1,
945
- form: f,
946
- id: u,
947
- indeterminate: p = !1,
948
- inputRef: h,
949
- name: N,
950
- onCheckedChange: m,
951
- parent: c = !1,
952
- readOnly: b = !1,
953
- render: E,
954
- required: C = !1,
955
- uncheckedValue: O,
956
- value: T,
957
- nativeButton: k = !1,
958
- style: l,
959
- ...W
960
- } = n, {
961
- clearErrors: $
962
- } = wn(), {
963
- disabled: M,
964
- name: A,
965
- setDirty: R,
966
- setFilled: L,
967
- setFocused: S,
968
- setTouched: U,
969
- state: z,
970
- validationMode: Q,
971
- validityData: ie,
972
- shouldValidateOnChange: F,
973
- validation: Ce
974
- } = Ae(), ve = Qt(), {
975
- labelId: ke,
976
- controlId: P,
977
- registerControlId: _,
978
- getDescriptionProps: Le
979
- } = En(), v = Lt(), ee = v?.parent, ne = ee && v.allValues, K = M || ve.disabled || v?.disabled || d, q = A ?? N, w = T ?? q, Ue = oe(), Rn = oe();
980
- let G = P;
981
- ne ? G = c ? Rn : `${ee.id}-${w}` : u && (G = u);
982
- let xe = {};
983
- ne && (c ? xe = v.parent.getParentProps() : w && (xe = v.parent.getChildProps(w)));
984
- const Pn = re(m), {
985
- checked: Fe = r,
986
- indeterminate: se = p,
987
- onCheckedChange: Tn,
988
- ...Sn
989
- } = xe, Y = v?.value, Ke = v?.setValue, Ge = v?.defaultValue, we = s.useRef(null), ae = ge(() => /* @__PURE__ */ Symbol("checkbox-control")), Ne = s.useRef(!1), {
990
- getButtonProps: _n,
991
- buttonRef: Bn
992
- } = Jt({
993
- disabled: K,
994
- native: k
995
- }), j = v?.validation ?? Ce, [V, Dn] = sn({
996
- controlled: w && Y && !c ? Y.includes(w) : Fe,
997
- default: w && Ge && !c ? Ge.includes(w) : i,
998
- name: "Checkbox",
999
- state: "checked"
1000
- });
1001
- H(() => {
1002
- _ !== I && (Ne.current = !0, _(ae.current, G));
1003
- }, [G, v, _, c, ae]), s.useEffect(() => {
1004
- const y = ae.current;
1005
- return () => {
1006
- !Ne.current || _ === I || (Ne.current = !1, _(y, void 0));
1007
- };
1008
- }, [_, ae]), gn(we, {
1009
- enabled: !v,
1010
- id: Ue,
1011
- value: V
1012
- });
1013
- const Z = s.useRef(null), $n = Te(h, Z, j.inputRef), Mn = eo(a, ke, Z, !k, G ?? void 0);
1014
- H(() => {
1015
- Z.current && (Z.current.indeterminate = se, V && L(!0));
1016
- }, [V, se, L]), Vn(V, () => {
1017
- v && !c || ($(q), L(V), R(V !== ie.initialValue), F() ? j.commit(V) : j.commit(V, !0));
1018
- });
1019
- const An = Ee(
432
+ function No({ children: o, ...n }) {
433
+ return /* @__PURE__ */ e(
434
+ v.Description,
1020
435
  {
1021
- checked: V,
1022
- disabled: K,
1023
- form: f,
1024
- // parent checkboxes unset `name` to be excluded from form submission
1025
- name: c ? void 0 : q,
1026
- // Set `id` to stop Chrome warning about an unassociated input.
1027
- // When using a native button, the `id` is applied to the button instead.
1028
- id: k ? void 0 : G ?? void 0,
1029
- required: C,
1030
- ref: $n,
1031
- style: q ? jt : Gt,
1032
- tabIndex: -1,
1033
- type: "checkbox",
1034
- "aria-hidden": !0,
1035
- onChange(y) {
1036
- if (y.nativeEvent.defaultPrevented)
1037
- return;
1038
- if (b) {
1039
- y.preventDefault();
1040
- return;
1041
- }
1042
- const ce = y.currentTarget.checked, le = ro(oo, y.nativeEvent);
1043
- if (Tn?.(ce, le), Pn(ce, le), !le.isCanceled && (Dn(ce), w && Y && Ke && !c && !ne)) {
1044
- const Fn = ce ? [...Y, w] : Y.filter((Kn) => Kn !== w);
1045
- Ke(Fn, le);
1046
- }
1047
- },
1048
- onFocus() {
1049
- we.current?.focus();
1050
- }
1051
- },
1052
- // React <19 sets an empty value if `undefined` is passed explicitly
1053
- // To avoid this, we only set the value if it's defined
1054
- T !== void 0 ? {
1055
- value: (v ? V && T : T) || ""
1056
- } : D,
1057
- Le,
1058
- v ? j.getValidationProps : j.getInputValidationProps
1059
- ), je = ne ? !!Fe : V, He = ne && se || p;
1060
- s.useEffect(() => {
1061
- if (!ee || !w)
1062
- return;
1063
- const y = ee.disabledStatesRef.current;
1064
- return y.set(w, K), () => {
1065
- y.delete(w);
1066
- };
1067
- }, [ee, K, w]);
1068
- const Ve = s.useMemo(() => ({
1069
- ...z,
1070
- checked: je,
1071
- disabled: K,
1072
- readOnly: b,
1073
- required: C,
1074
- indeterminate: He
1075
- }), [z, je, K, b, C, He]), Ln = Ht(Ve), Un = bn("span", n, {
1076
- state: Ve,
1077
- ref: [Bn, we, t, v?.registerControlRef],
1078
- props: [{
1079
- id: k ? G ?? void 0 : Ue,
1080
- role: "checkbox",
1081
- "aria-checked": se ? "mixed" : V,
1082
- "aria-readonly": b || void 0,
1083
- "aria-required": C || void 0,
1084
- "aria-labelledby": Mn,
1085
- [In]: c ? "" : void 0,
1086
- onFocus() {
1087
- S(!0);
1088
- },
1089
- onBlur() {
1090
- const y = Z.current;
1091
- y && (U(!0), S(!1), Q === "onBlur" && j.commit(v ? Y : y.checked));
1092
- },
1093
- onClick(y) {
1094
- b || K || (y.preventDefault(), Z.current?.dispatchEvent(new PointerEvent("click", {
1095
- bubbles: !0,
1096
- shiftKey: y.shiftKey,
1097
- ctrlKey: y.ctrlKey,
1098
- altKey: y.altKey,
1099
- metaKey: y.metaKey
1100
- })));
1101
- }
1102
- }, Le, j.getValidationProps, W, Sn, _n],
1103
- stateAttributesMapping: Ln
1104
- });
1105
- return /* @__PURE__ */ he(Nn.Provider, {
1106
- value: Ve,
1107
- children: [Un, !V && !v && q && !c && O !== void 0 && /* @__PURE__ */ x("input", {
1108
- type: "hidden",
1109
- form: f,
1110
- name: q,
1111
- value: O
1112
- }), /* @__PURE__ */ x("input", {
1113
- ...An,
1114
- suppressHydrationWarning: !0
1115
- })]
1116
- });
1117
- });
1118
- process.env.NODE_ENV !== "production" && (io.displayName = "CheckboxRoot");
1119
- const tn = [];
1120
- function so(e) {
1121
- const {
1122
- allValues: n = tn,
1123
- value: t = tn,
1124
- onValueChange: r
1125
- } = e, o = s.useRef(t), i = s.useRef(/* @__PURE__ */ new Map()), [a, d] = s.useState("mixed"), f = oe(), u = t.length === n.length, p = t.length !== n.length && t.length > 0, h = re(r), N = s.useCallback(() => ({
1126
- id: f,
1127
- indeterminate: p,
1128
- checked: u,
1129
- // TODO: custom `id` on child checkboxes breaks this
1130
- // https://github.com/mui/base-ui/issues/2691
1131
- "aria-controls": n.map((c) => `${f}-${c}`).join(" "),
1132
- onCheckedChange(c, b) {
1133
- const E = o.current, C = n.filter((k) => i.current.get(k) && E.includes(k)), O = n.filter((k) => !i.current.get(k) || i.current.get(k) && E.includes(k));
1134
- if (E.length === O.length || E.length === 0) {
1135
- t.length === O.length ? h(C, b) : h(O, b);
1136
- return;
1137
- }
1138
- a === "mixed" ? (h(O, b), d("on")) : a === "on" ? (h(C, b), d("off")) : a === "off" && (h(E, b), d("mixed"));
1139
- }
1140
- }), [n, u, f, p, h, a, t.length]), m = s.useCallback((c) => ({
1141
- checked: t.includes(c),
1142
- onCheckedChange(b, E) {
1143
- const C = t.slice();
1144
- b ? C.push(c) : C.splice(C.indexOf(c), 1), o.current = C, h(C, E), d("mixed");
436
+ "data-slot": "field-description",
437
+ render: /* @__PURE__ */ e(V, { variant: "description", color: "informative", children: o }),
438
+ ...n
1145
439
  }
1146
- }), [h, t]);
1147
- return s.useMemo(() => ({
1148
- id: f,
1149
- indeterminate: p,
1150
- getParentProps: N,
1151
- getChildProps: m,
1152
- disabledStatesRef: i
1153
- }), [f, p, N, m]);
440
+ );
1154
441
  }
1155
- function ao(e, n, t = (r, o) => r === o) {
1156
- return e.length === n.length && e.every((r, o) => t(r, n[o]));
442
+ function xo({ children: o, className: n, ...r }) {
443
+ return /* @__PURE__ */ e(
444
+ v.Error,
445
+ {
446
+ "data-slot": "field-error",
447
+ className: l(E.error, n),
448
+ render: ({ children: a, ...i }) => /* @__PURE__ */ m("div", { ...i, children: [
449
+ /* @__PURE__ */ e("span", { "aria-hidden": !0, className: E.errorDot }),
450
+ /* @__PURE__ */ e(V, { variant: "description", as: "div", children: o ?? a })
451
+ ] }),
452
+ ...r
453
+ }
454
+ );
1157
455
  }
1158
- const On = /* @__PURE__ */ s.forwardRef(function(n, t) {
1159
- const {
1160
- allValues: r,
1161
- className: o,
1162
- defaultValue: i,
1163
- disabled: a = !1,
1164
- id: d,
1165
- onValueChange: f,
1166
- render: u,
1167
- value: p,
1168
- style: h,
1169
- ...N
1170
- } = n, {
1171
- disabled: m,
1172
- name: c,
1173
- state: b,
1174
- validation: E,
1175
- setFilled: C,
1176
- setDirty: O,
1177
- shouldValidateOnChange: T,
1178
- validityData: k
1179
- } = Ae(), {
1180
- labelId: l,
1181
- getDescriptionProps: W
1182
- } = En(), {
1183
- clearErrors: $
1184
- } = wn(), M = m || a, A = s.useMemo(() => {
1185
- if (p === void 0)
1186
- return i ?? [];
1187
- }, [p, i]), [R, L] = sn({
1188
- controlled: p,
1189
- default: A,
1190
- name: "CheckboxGroup",
1191
- state: "value"
1192
- }), S = re((P, _) => {
1193
- f?.(P, _), !_.isCanceled && L(P);
1194
- }), U = so({
1195
- allValues: r,
1196
- value: R,
1197
- onValueChange: S
1198
- }), z = oe(d), Q = s.useRef(null), ie = s.useCallback((P) => {
1199
- Q.current == null && P != null && !P.hasAttribute(In) && (Q.current = P);
1200
- }, []);
1201
- gn(Q, {
1202
- enabled: !!c,
1203
- id: z,
1204
- value: R
1205
- });
1206
- const F = R ?? Ze;
1207
- Vn(F, () => {
1208
- c && $(c);
1209
- const P = Array.isArray(k.initialValue) ? k.initialValue : Ze;
1210
- C(F.length > 0), O(!ao(F, P)), T() ? E.commit(F) : E.commit(F, !0);
1211
- });
1212
- const Ce = {
1213
- ...b,
1214
- disabled: M
1215
- }, ve = s.useMemo(() => ({
1216
- allValues: r,
1217
- value: R,
1218
- defaultValue: A,
1219
- setValue: S,
1220
- parent: U,
1221
- disabled: M,
1222
- validation: E,
1223
- registerControlRef: ie
1224
- }), [r, R, A, S, U, M, E, ie]), ke = bn("div", n, {
1225
- state: Ce,
1226
- ref: t,
1227
- props: [{
1228
- role: "group",
1229
- "aria-labelledby": l
1230
- }, W, N],
1231
- stateAttributesMapping: mn
1232
- });
1233
- return /* @__PURE__ */ x(Me.Provider, {
1234
- value: ve,
1235
- children: ke
1236
- });
1237
- });
1238
- process.env.NODE_ENV !== "production" && (On.displayName = "CheckboxGroup");
1239
- const co = "bnui-group-76ZZz", lo = "bnui-column-ev6Qg", uo = "bnui-row-K6-hO", Oe = {
1240
- group: co,
1241
- column: lo,
1242
- row: uo
456
+ const De = "bnui-form-9QnXK", He = {
457
+ form: De
1243
458
  };
1244
- function Oo({
1245
- className: e,
1246
- orientation: n = "row",
1247
- ...t
1248
- }) {
1249
- return /* @__PURE__ */ x(
1250
- On,
459
+ function $o({ className: o, ...n }) {
460
+ return /* @__PURE__ */ e(
461
+ Q,
1251
462
  {
1252
- "data-slot": "checkbox-group",
1253
- className: X(
1254
- Oe.group,
1255
- n === "column" ? Oe.column : Oe.row,
1256
- e
1257
- ),
1258
- ...t
463
+ "data-slot": "form",
464
+ className: l(He.form, o),
465
+ ...n
1259
466
  }
1260
467
  );
1261
468
  }
1262
- const fo = "bnui-root-oLVBN", po = "bnui-hasSelectedSecondOption-LfH49", bo = "bnui-filled-L-AUH", mo = "bnui-stroked-wRb92", ho = "bnui-option-Hou7J", go = "bnui-selectedOption-twuTF", J = {
1263
- root: fo,
1264
- hasSelectedSecondOption: po,
1265
- filled: bo,
1266
- stroked: mo,
1267
- option: ho,
1268
- selectedOption: go
469
+ const je = "bnui-root-oLVBN", Me = "bnui-hasSelectedSecondOption-LfH49", Xe = "bnui-filled-L-AUH", Ze = "bnui-stroked-wRb92", Ke = "bnui-option-Hou7J", Qe = "bnui-selectedOption-twuTF", $ = {
470
+ root: je,
471
+ hasSelectedSecondOption: Me,
472
+ filled: Xe,
473
+ stroked: Ze,
474
+ option: Ke,
475
+ selectedOption: Qe
1269
476
  };
1270
- function Ro({
1271
- options: e,
477
+ function Oo({
478
+ options: o,
1272
479
  title: n,
1273
- variant: t = "filled",
1274
- value: r,
1275
- defaultValue: o,
1276
- onValueChange: i,
1277
- name: a,
1278
- className: d
480
+ variant: r = "filled",
481
+ value: a,
482
+ defaultValue: i,
483
+ onValueChange: s,
484
+ name: p,
485
+ className: g
1279
486
  }) {
1280
- const [f, u] = jn(
1281
- o ?? e[0].value
1282
- ), p = r ?? f, h = e[0].value === p ? 0 : 1, N = e[h], m = e[h === 0 ? 1 : 0];
487
+ const [y, k] = Z(
488
+ i ?? o[0].value
489
+ ), O = a ?? y, F = o[0].value === O ? 0 : 1, C = o[F], S = o[F === 0 ? 1 : 0];
1283
490
  function c() {
1284
- const b = m.value;
1285
- r === void 0 && u(b), i?.(b);
491
+ const h = S.value;
492
+ a === void 0 && k(h), s?.(h);
1286
493
  }
1287
- return /* @__PURE__ */ he(on, { children: [
1288
- a && /* @__PURE__ */ x("input", { type: "hidden", name: a, value: p }),
1289
- /* @__PURE__ */ x(
1290
- rn,
494
+ return /* @__PURE__ */ m(G, { children: [
495
+ p && /* @__PURE__ */ e("input", { type: "hidden", name: p, value: O }),
496
+ /* @__PURE__ */ e(
497
+ R,
1291
498
  {
1292
499
  onClick: c,
1293
- "aria-label": `Bytt ${n} mellom ${N.label} og ${m.label}, valgt: ${N.label}`,
1294
- className: X(
1295
- yo({ variant: t }),
1296
- h === 1 && J.hasSelectedSecondOption,
1297
- d
500
+ "aria-label": `Bytt ${n} mellom ${C.label} og ${S.label}, valgt: ${C.label}`,
501
+ className: l(
502
+ We({ variant: r }),
503
+ F === 1 && $.hasSelectedSecondOption,
504
+ g
1298
505
  ),
1299
- children: e.map((b) => {
1300
- const E = b.value === p;
1301
- return /* @__PURE__ */ x(
506
+ children: o.map((h) => {
507
+ const B = h.value === O;
508
+ return /* @__PURE__ */ e(
1302
509
  "span",
1303
510
  {
1304
511
  "aria-hidden": "true",
1305
- className: X(J.option, E && J.selectedOption),
1306
- children: b.icon
512
+ className: l($.option, B && $.selectedOption),
513
+ children: h.icon
1307
514
  },
1308
- b.value
515
+ h.value
1309
516
  );
1310
517
  })
1311
518
  }
1312
519
  )
1313
520
  ] });
1314
521
  }
1315
- const yo = Be(J.root, {
522
+ const We = w($.root, {
1316
523
  variants: {
1317
524
  variant: {
1318
- filled: J.filled,
1319
- stroked: J.stroked
525
+ filled: $.filled,
526
+ stroked: $.stroked
1320
527
  }
1321
528
  },
1322
529
  defaultVariants: {
1323
530
  variant: "filled"
1324
531
  }
1325
- });
532
+ }), Ue = "bnui-base-ZhllN", Je = "bnui-image-Ngo7A", Ye = "bnui-fallback-Tf3oZ", A = {
533
+ base: Ue,
534
+ image: Je,
535
+ fallback: Ye
536
+ };
537
+ function Fo({ src: o, alt: n, className: r, ...a }) {
538
+ return /* @__PURE__ */ m(
539
+ I.Root,
540
+ {
541
+ "data-slot": "avatar",
542
+ className: l(A.base, r),
543
+ ...a,
544
+ children: [
545
+ o !== void 0 && /* @__PURE__ */ e(
546
+ I.Image,
547
+ {
548
+ "data-slot": "avatar-image",
549
+ src: o,
550
+ alt: n,
551
+ loading: "lazy",
552
+ className: A.image
553
+ }
554
+ ),
555
+ /* @__PURE__ */ e(
556
+ I.Fallback,
557
+ {
558
+ "data-slot": "avatar-fallback",
559
+ className: A.fallback,
560
+ children: /* @__PURE__ */ e(j, {})
561
+ }
562
+ )
563
+ ]
564
+ }
565
+ );
566
+ }
1326
567
  export {
1327
- Vo as Button,
1328
- Io as Checkbox,
1329
- Oo as CheckboxGroup,
1330
- Ro as IconsToggle,
1331
- et as buttonVariants
568
+ Fo as Avatar,
569
+ mo as Button,
570
+ po as Checkbox,
571
+ ho as CheckboxGroup,
572
+ go as Combobox,
573
+ vo as Field,
574
+ No as FieldDescription,
575
+ xo as FieldError,
576
+ ko as FieldLabel,
577
+ $o as Form,
578
+ Oo as IconsToggle,
579
+ yo as Select,
580
+ fo as Textarea,
581
+ re as buttonVariants,
582
+ Ne as textareaVariants
1332
583
  };
1333
584
  //# sourceMappingURL=index.js.map