@px-ui/core 1.22.0 → 1.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/components/block-checkbox-group.js +72 -0
  2. package/dist/components/block-radio-group.js +79 -0
  3. package/dist/components/input-group.js +37 -24
  4. package/dist/components/input.js +46 -0
  5. package/dist/components/radio-group.js +85 -0
  6. package/dist/components/switch.js +39 -0
  7. package/dist/components/tabs.js +108 -0
  8. package/dist/components/textarea.js +41 -0
  9. package/dist/components/tooltip.js +5 -5
  10. package/dist/hooks/use-async-options.js +17 -13
  11. package/dist/index.d.ts +21 -11
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +48 -21
  14. package/dist/node_modules/.pnpm/@base-ui-components_react@1.0.0-beta.4_@types_react@19.2.0_react-dom@19.2.0_react@19.2.0/node_modules/@base-ui-components/react/esm/checkbox-group/CheckboxGroup.js +82 -0
  15. package/dist/node_modules/.pnpm/@base-ui-components_react@1.0.0-beta.4_@types_react@19.2.0_react-dom@19.2.0_react@19.2.0/node_modules/@base-ui-components/react/esm/checkbox-group/useCheckboxGroupParent.js +42 -0
  16. package/dist/node_modules/.pnpm/@base-ui-components_react@1.0.0-beta.4_@types_react@19.2.0_react-dom@19.2.0_react@19.2.0/node_modules/@base-ui-components/react/esm/radio/indicator/RadioIndicator.js +37 -0
  17. package/dist/node_modules/.pnpm/@base-ui-components_react@1.0.0-beta.4_@types_react@19.2.0_react-dom@19.2.0_react@19.2.0/node_modules/@base-ui-components/react/esm/radio/root/RadioRootContext.js +11 -4
  18. package/dist/node_modules/.pnpm/@base-ui-components_react@1.0.0-beta.4_@types_react@19.2.0_react-dom@19.2.0_react@19.2.0/node_modules/@base-ui-components/react/esm/switch/root/SwitchRoot.js +144 -0
  19. package/dist/node_modules/.pnpm/@base-ui-components_react@1.0.0-beta.4_@types_react@19.2.0_react-dom@19.2.0_react@19.2.0/node_modules/@base-ui-components/react/esm/switch/root/SwitchRootContext.js +13 -0
  20. package/dist/node_modules/.pnpm/@base-ui-components_react@1.0.0-beta.4_@types_react@19.2.0_react-dom@19.2.0_react@19.2.0/node_modules/@base-ui-components/react/esm/switch/root/SwitchRootDataAttributes.js +6 -0
  21. package/dist/node_modules/.pnpm/@base-ui-components_react@1.0.0-beta.4_@types_react@19.2.0_react-dom@19.2.0_react@19.2.0/node_modules/@base-ui-components/react/esm/switch/stateAttributesMapping.js +15 -0
  22. package/dist/node_modules/.pnpm/@base-ui-components_react@1.0.0-beta.4_@types_react@19.2.0_react-dom@19.2.0_react@19.2.0/node_modules/@base-ui-components/react/esm/switch/thumb/SwitchThumb.js +27 -0
  23. package/dist/node_modules/.pnpm/@base-ui-components_react@1.0.0-beta.4_@types_react@19.2.0_react-dom@19.2.0_react@19.2.0/node_modules/@base-ui-components/react/esm/tabs/indicator/TabsIndicator.js +107 -0
  24. package/dist/node_modules/.pnpm/@base-ui-components_react@1.0.0-beta.4_@types_react@19.2.0_react-dom@19.2.0_react@19.2.0/node_modules/@base-ui-components/react/esm/tabs/indicator/TabsIndicatorCssVars.js +6 -0
  25. package/dist/node_modules/.pnpm/@base-ui-components_react@1.0.0-beta.4_@types_react@19.2.0_react-dom@19.2.0_react@19.2.0/node_modules/@base-ui-components/react/esm/tabs/indicator/prehydrationScript.min.js +4 -0
  26. package/dist/node_modules/.pnpm/@base-ui-components_react@1.0.0-beta.4_@types_react@19.2.0_react-dom@19.2.0_react@19.2.0/node_modules/@base-ui-components/react/esm/tabs/list/TabsList.js +130 -0
  27. package/dist/node_modules/.pnpm/@base-ui-components_react@1.0.0-beta.4_@types_react@19.2.0_react-dom@19.2.0_react@19.2.0/node_modules/@base-ui-components/react/esm/tabs/list/TabsListContext.js +13 -0
  28. package/dist/node_modules/.pnpm/@base-ui-components_react@1.0.0-beta.4_@types_react@19.2.0_react-dom@19.2.0_react@19.2.0/node_modules/@base-ui-components/react/esm/tabs/panel/TabsPanel.js +53 -0
  29. package/dist/node_modules/.pnpm/@base-ui-components_react@1.0.0-beta.4_@types_react@19.2.0_react-dom@19.2.0_react@19.2.0/node_modules/@base-ui-components/react/esm/tabs/panel/TabsPanelDataAttributes.js +6 -0
  30. package/dist/node_modules/.pnpm/@base-ui-components_react@1.0.0-beta.4_@types_react@19.2.0_react-dom@19.2.0_react@19.2.0/node_modules/@base-ui-components/react/esm/tabs/root/TabsRoot.js +76 -0
  31. package/dist/node_modules/.pnpm/@base-ui-components_react@1.0.0-beta.4_@types_react@19.2.0_react-dom@19.2.0_react@19.2.0/node_modules/@base-ui-components/react/esm/tabs/root/TabsRootContext.js +13 -0
  32. package/dist/node_modules/.pnpm/@base-ui-components_react@1.0.0-beta.4_@types_react@19.2.0_react-dom@19.2.0_react@19.2.0/node_modules/@base-ui-components/react/esm/tabs/root/TabsRootDataAttributes.js +6 -0
  33. package/dist/node_modules/.pnpm/@base-ui-components_react@1.0.0-beta.4_@types_react@19.2.0_react-dom@19.2.0_react@19.2.0/node_modules/@base-ui-components/react/esm/tabs/root/stateAttributesMapping.js +9 -0
  34. package/dist/node_modules/.pnpm/@base-ui-components_react@1.0.0-beta.4_@types_react@19.2.0_react-dom@19.2.0_react@19.2.0/node_modules/@base-ui-components/react/esm/tabs/tab/TabsTab.js +108 -0
  35. package/dist/node_modules/.pnpm/@base-ui-components_react@1.0.0-beta.4_@types_react@19.2.0_react-dom@19.2.0_react@19.2.0/node_modules/@base-ui-components/react/esm/utils/createBaseUIEventDetails.js +9 -9
  36. package/dist/node_modules/.pnpm/@base-ui-components_utils@0.1.2_@types_react@19.2.0_react-dom@19.2.0_react@19.2.0/node_modules/@base-ui-components/utils/esm/generateId.js +7 -0
  37. package/dist/node_modules/.pnpm/@base-ui-components_utils@0.1.2_@types_react@19.2.0_react-dom@19.2.0_react@19.2.0/node_modules/@base-ui-components/utils/esm/useForcedRerendering.js +10 -0
  38. package/package.json +98 -6
package/dist/index.d.ts CHANGED
@@ -1,18 +1,28 @@
1
- import * as Dialog from "./components/dialog";
2
- import * as Popover from "./components/popover";
3
- import * as Combobox from "./components/combobox";
4
- import * as Select from "./components/select";
5
- import * as Menu from "./components/menu";
1
+ export * as Dialog from './components/dialog';
2
+ export * as Popover from './components/popover';
3
+ export * as Combobox from './components/combobox';
4
+ export * as Select from './components/select';
5
+ export * as Menu from './components/menu';
6
+ export * as InputGroup from './components/input-group';
7
+ export * as SegmentedControl from './components/segmented-control';
8
+ export * as Tabs from './components/tabs';
9
+ export * as Tooltip from './components/tooltip';
10
+ export * as BlockCheckboxGroup from './components/block-checkbox-group';
11
+ export * as BlockRadioGroup from './components/block-radio-group';
6
12
  export * from './components/button';
7
13
  export * from './components/checkbox';
8
14
  export * from './components/label';
9
15
  export * from './components/text-input';
16
+ export * from './components/input';
17
+ export * from './components/textarea';
10
18
  export * from './components/avatar';
11
19
  export * from './components/avatar-group';
12
- export * from './components/segmented-control';
13
- export { Dialog };
14
- export { Popover };
15
- export { Combobox };
16
- export { Select };
17
- export { Menu };
20
+ export * from './components/spinner';
21
+ export * from './components/switch';
22
+ export * from './components/radio-group';
23
+ export * from './hooks/use-debounce';
24
+ export * from './hooks/use-async-options';
25
+ export * from './hooks/use-infinite-scroll';
26
+ export * from './hooks/use-intersection-observer';
27
+ export * from './utils';
18
28
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AAErB,OAAO,KAAK,MAAM,MAAM,qBAAqB,CAAC;AAC9C,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,QAAQ,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,MAAM,MAAM,qBAAqB,CAAC;AAC9C,OAAO,KAAK,IAAI,MAAM,mBAAmB,CAAC;AAE1C,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC;AAE/C,OAAO,EAAE,MAAM,EAAE,CAAC;AAClB,OAAO,EAAE,OAAO,EAAE,CAAC;AACnB,OAAO,EAAE,QAAQ,EAAE,CAAC;AACpB,OAAO,EAAE,MAAM,EAAE,CAAC;AAClB,OAAO,EAAE,IAAI,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AAGrB,OAAO,KAAK,MAAM,MAAM,qBAAqB,CAAC;AAC9C,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,QAAQ,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,MAAM,MAAM,qBAAqB,CAAC;AAC9C,OAAO,KAAK,IAAI,MAAM,mBAAmB,CAAC;AAC1C,OAAO,KAAK,UAAU,MAAM,0BAA0B,CAAC;AACvD,OAAO,KAAK,gBAAgB,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,IAAI,MAAM,mBAAmB,CAAC;AAC1C,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,kBAAkB,MAAM,mCAAmC,CAAC;AACxE,OAAO,KAAK,eAAe,MAAM,gCAAgC,CAAC;AAGlE,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AAGzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC;AAGlD,cAAc,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -1,30 +1,57 @@
1
1
  /* empty css */
2
2
  import * as r from "./components/dialog.js";
3
3
  import * as t from "./components/popover.js";
4
- import * as e from "./components/combobox.js";
5
- import * as p from "./components/select.js";
4
+ import * as p from "./components/combobox.js";
5
+ import * as e from "./components/select.js";
6
6
  import * as m from "./components/menu.js";
7
- import { Button as f, buttonVariants as s } from "./components/button.js";
8
- import { Checkbox as b } from "./components/checkbox.js";
9
- import { Label as n } from "./components/label.js";
10
- import { TextInput as v } from "./components/text-input.js";
11
- import { Avatar as A, AvatarImpl as I } from "./components/avatar.js";
12
- import { AvatarGroup as C } from "./components/avatar-group.js";
13
- import { Item as h, Root as k } from "./components/segmented-control.js";
7
+ import * as a from "./components/input-group.js";
8
+ import * as s from "./components/segmented-control.js";
9
+ import * as x from "./components/tabs.js";
10
+ import * as i from "./components/tooltip.js";
11
+ import * as f from "./components/block-checkbox-group.js";
12
+ import * as n from "./components/block-radio-group.js";
13
+ import { Button as c, buttonVariants as l } from "./components/button.js";
14
+ import { Checkbox as G } from "./components/checkbox.js";
15
+ import { Label as v } from "./components/label.js";
16
+ import { TextInput as I } from "./components/text-input.js";
17
+ import { Input as h } from "./components/input.js";
18
+ import { Textarea as R } from "./components/textarea.js";
19
+ import { Avatar as T, AvatarImpl as B } from "./components/avatar.js";
20
+ import { AvatarGroup as L } from "./components/avatar-group.js";
21
+ import { Spinner as y } from "./components/spinner.js";
22
+ import { Switch as M } from "./components/switch.js";
23
+ import { RadioGroup as V, RadioGroupItem as j } from "./components/radio-group.js";
24
+ import { defineLoadOptions as z, useAsyncOptions as E } from "./hooks/use-async-options.js";
25
+ import { useIntersectionObserver as H } from "./hooks/use-intersection-observer.js";
26
+ import { cn as K } from "./utils/classnames.js";
14
27
  export {
15
- A as Avatar,
16
- C as AvatarGroup,
17
- I as AvatarImpl,
18
- f as Button,
19
- b as Checkbox,
20
- e as Combobox,
28
+ T as Avatar,
29
+ L as AvatarGroup,
30
+ B as AvatarImpl,
31
+ f as BlockCheckboxGroup,
32
+ n as BlockRadioGroup,
33
+ c as Button,
34
+ G as Checkbox,
35
+ p as Combobox,
21
36
  r as Dialog,
22
- h as Item,
23
- n as Label,
37
+ h as Input,
38
+ a as InputGroup,
39
+ v as Label,
24
40
  m as Menu,
25
41
  t as Popover,
26
- k as Root,
27
- p as Select,
28
- v as TextInput,
29
- s as buttonVariants
42
+ V as RadioGroup,
43
+ j as RadioGroupItem,
44
+ s as SegmentedControl,
45
+ e as Select,
46
+ y as Spinner,
47
+ M as Switch,
48
+ x as Tabs,
49
+ I as TextInput,
50
+ R as Textarea,
51
+ i as Tooltip,
52
+ l as buttonVariants,
53
+ K as cn,
54
+ z as defineLoadOptions,
55
+ E as useAsyncOptions,
56
+ H as useIntersectionObserver
30
57
  };
@@ -0,0 +1,82 @@
1
+ import * as l from "react";
2
+ import { useControlled as j } from "../../../../../../@base-ui-components_utils@0.1.2_@types_react@19.2.0_react-dom@19.2.0_react@19.2.0/node_modules/@base-ui-components/utils/esm/useControlled.js";
3
+ import { useEventCallback as x } from "../../../../../../@base-ui-components_utils@0.1.2_@types_react@19.2.0_react-dom@19.2.0_react@19.2.0/node_modules/@base-ui-components/utils/esm/useEventCallback.js";
4
+ import { useBaseUiId as y } from "../utils/useBaseUiId.js";
5
+ import { useRenderElement as A } from "../utils/useRenderElement.js";
6
+ import { CheckboxGroupContext as F } from "./CheckboxGroupContext.js";
7
+ import { useFieldRootContext as w } from "../field/root/FieldRootContext.js";
8
+ import { fieldValidityMapping as B } from "../field/utils/constants.js";
9
+ import { useField as I } from "../field/useField.js";
10
+ import { useFieldControlValidation as O } from "../field/control/useFieldControlValidation.js";
11
+ import { PARENT_CHECKBOX as U } from "../checkbox/root/CheckboxRoot.js";
12
+ import { useCheckboxGroupParent as _ } from "./useCheckboxGroupParent.js";
13
+ import { j as D } from "../../../../../../../../_virtual/jsx-runtime.js";
14
+ const H = /* @__PURE__ */ l.forwardRef(function(d, V) {
15
+ const {
16
+ allValues: a,
17
+ className: S,
18
+ defaultValue: i,
19
+ disabled: R = !1,
20
+ id: h,
21
+ onValueChange: o,
22
+ render: T,
23
+ value: u,
24
+ ...k
25
+ } = d, {
26
+ disabled: v,
27
+ labelId: E,
28
+ name: m,
29
+ state: p
30
+ } = w(), t = v || R, s = O(), [r, G] = j({
31
+ controlled: u,
32
+ default: i,
33
+ name: "CheckboxGroup",
34
+ state: "value"
35
+ }), c = x((e, C) => {
36
+ o == null || o(e, C), !C.isCanceled && G(e);
37
+ }), f = _({
38
+ allValues: a,
39
+ value: u,
40
+ onValueChange: o
41
+ }), N = y(h), n = l.useRef(null), b = x((e) => {
42
+ n.current == null && e != null && !e.hasAttribute(U) && (n.current = e);
43
+ });
44
+ I({
45
+ enabled: !!m,
46
+ id: N,
47
+ commitValidation: s.commitValidation,
48
+ value: r,
49
+ controlRef: n,
50
+ name: m,
51
+ getValue: () => r
52
+ });
53
+ const P = l.useMemo(() => ({
54
+ ...p,
55
+ disabled: t
56
+ }), [p, t]), g = l.useMemo(() => ({
57
+ allValues: a,
58
+ value: r,
59
+ defaultValue: i,
60
+ setValue: c,
61
+ parent: f,
62
+ disabled: t,
63
+ fieldControlValidation: s,
64
+ registerControlRef: b
65
+ }), [a, r, i, c, f, t, s, b]), M = A("div", d, {
66
+ state: P,
67
+ ref: V,
68
+ props: [{
69
+ role: "group",
70
+ "aria-labelledby": E
71
+ }, k],
72
+ stateAttributesMapping: B
73
+ });
74
+ return /* @__PURE__ */ D.jsx(F.Provider, {
75
+ value: g,
76
+ children: M
77
+ });
78
+ });
79
+ process.env.NODE_ENV !== "production" && (H.displayName = "CheckboxGroup");
80
+ export {
81
+ H as CheckboxGroup
82
+ };
@@ -0,0 +1,42 @@
1
+ import * as a from "react";
2
+ import { useEventCallback as b } from "../../../../../../@base-ui-components_utils@0.1.2_@types_react@19.2.0_react-dom@19.2.0_react@19.2.0/node_modules/@base-ui-components/utils/esm/useEventCallback.js";
3
+ import { useBaseUiId as R } from "../utils/useBaseUiId.js";
4
+ const x = [];
5
+ function M(O) {
6
+ const {
7
+ allValues: r = x,
8
+ value: e = x,
9
+ onValueChange: P
10
+ } = O, p = a.useRef(e), i = a.useRef(/* @__PURE__ */ new Map()), [f, h] = a.useState("mixed"), l = R(), C = e.length === r.length, d = e.length !== r.length && e.length > 0, n = b(P), m = a.useCallback(() => ({
11
+ id: l,
12
+ indeterminate: d,
13
+ checked: C,
14
+ "aria-controls": r.map((t) => `${l}-${t}`).join(" "),
15
+ onCheckedChange(t, s) {
16
+ const c = p.current, o = r.filter((u) => i.current.get(u) && c.includes(u)), g = r.filter((u) => !i.current.get(u) || i.current.get(u) && c.includes(u));
17
+ if (c.length === g.length || c.length === 0) {
18
+ e.length === g.length ? n(o, s) : n(g, s);
19
+ return;
20
+ }
21
+ f === "mixed" ? (n(g, s), h("on")) : f === "on" ? (n(o, s), h("off")) : f === "off" && (n(c, s), h("mixed"));
22
+ }
23
+ }), [r, C, l, d, n, f, e.length]), k = a.useCallback((t) => ({
24
+ name: t,
25
+ id: `${l}-${t}`,
26
+ checked: e.includes(t),
27
+ onCheckedChange(s, c) {
28
+ const o = e.slice();
29
+ s ? o.push(t) : o.splice(o.indexOf(t), 1), p.current = o, n(o, c), h("mixed");
30
+ }
31
+ }), [l, n, e]);
32
+ return a.useMemo(() => ({
33
+ id: l,
34
+ indeterminate: d,
35
+ getParentProps: m,
36
+ getChildProps: k,
37
+ disabledStatesRef: i
38
+ }), [l, d, m, k]);
39
+ }
40
+ export {
41
+ M as useCheckboxGroupParent
42
+ };
@@ -0,0 +1,37 @@
1
+ import * as o from "react";
2
+ import { useRenderElement as u } from "../../utils/useRenderElement.js";
3
+ import { useRadioRootContext as l } from "../root/RadioRootContext.js";
4
+ import { stateAttributesMapping as R } from "../utils/stateAttributesMapping.js";
5
+ import { useOpenChangeComplete as C } from "../../utils/useOpenChangeComplete.js";
6
+ import { useTransitionStatus as M } from "../../utils/useTransitionStatus.js";
7
+ const N = /* @__PURE__ */ o.forwardRef(function(n, i) {
8
+ const {
9
+ render: E,
10
+ className: I,
11
+ keepMounted: d = !1,
12
+ ...c
13
+ } = n, t = l(), e = t.checked, {
14
+ transitionStatus: r,
15
+ setMounted: m
16
+ } = M(e), p = o.useMemo(() => ({
17
+ ...t,
18
+ transitionStatus: r
19
+ }), [t, r]), s = o.useRef(null), a = d || e, f = u("span", n, {
20
+ enabled: a,
21
+ ref: [i, s],
22
+ state: p,
23
+ props: c,
24
+ stateAttributesMapping: R
25
+ });
26
+ return C({
27
+ open: e,
28
+ ref: s,
29
+ onComplete() {
30
+ e || m(!1);
31
+ }
32
+ }), a ? f : null;
33
+ });
34
+ process.env.NODE_ENV !== "production" && (N.displayName = "RadioIndicator");
35
+ export {
36
+ N as RadioIndicator
37
+ };
@@ -1,6 +1,13 @@
1
- import * as o from "react";
2
- const t = /* @__PURE__ */ o.createContext(void 0);
3
- process.env.NODE_ENV !== "production" && (t.displayName = "RadioRootContext");
1
+ import * as t from "react";
2
+ const e = /* @__PURE__ */ t.createContext(void 0);
3
+ process.env.NODE_ENV !== "production" && (e.displayName = "RadioRootContext");
4
+ function n() {
5
+ const o = t.useContext(e);
6
+ if (o === void 0)
7
+ throw new Error("Base UI: RadioRootContext is missing. Radio parts must be placed within <Radio.Root>.");
8
+ return o;
9
+ }
4
10
  export {
5
- t as RadioRootContext
11
+ e as RadioRootContext,
12
+ n as useRadioRootContext
6
13
  };
@@ -0,0 +1,144 @@
1
+ import * as a from "react";
2
+ import { useControlled as W } from "../../../../../../../@base-ui-components_utils@0.1.2_@types_react@19.2.0_react-dom@19.2.0_react@19.2.0/node_modules/@base-ui-components/utils/esm/useControlled.js";
3
+ import { useEventCallback as X } from "../../../../../../../@base-ui-components_utils@0.1.2_@types_react@19.2.0_react-dom@19.2.0_react@19.2.0/node_modules/@base-ui-components/utils/esm/useEventCallback.js";
4
+ import { useMergedRefs as Y } from "../../../../../../../@base-ui-components_utils@0.1.2_@types_react@19.2.0_react-dom@19.2.0_react@19.2.0/node_modules/@base-ui-components/utils/esm/useMergedRefs.js";
5
+ import { useIsoLayoutEffect as D } from "../../../../../../../@base-ui-components_utils@0.1.2_@types_react@19.2.0_react-dom@19.2.0_react@19.2.0/node_modules/@base-ui-components/utils/esm/useIsoLayoutEffect.js";
6
+ import { visuallyHidden as Z } from "../../../../../../../@base-ui-components_utils@0.1.2_@types_react@19.2.0_react-dom@19.2.0_react@19.2.0/node_modules/@base-ui-components/utils/esm/visuallyHidden.js";
7
+ import { useRenderElement as ee } from "../../utils/useRenderElement.js";
8
+ import { useBaseUiId as te } from "../../utils/useBaseUiId.js";
9
+ import { SwitchRootContext as oe } from "./SwitchRootContext.js";
10
+ import { stateAttributesMapping as ne } from "../stateAttributesMapping.js";
11
+ import { useField as re } from "../../field/useField.js";
12
+ import { useFieldRootContext as ie } from "../../field/root/FieldRootContext.js";
13
+ import { useFieldControlValidation as se } from "../../field/control/useFieldControlValidation.js";
14
+ import { useFormContext as ae } from "../../form/FormContext.js";
15
+ import { createChangeEventDetails as le } from "../../utils/createBaseUIEventDetails.js";
16
+ import { j as k } from "../../../../../../../../../_virtual/jsx-runtime.js";
17
+ import { useButton as de } from "../../use-button/useButton.js";
18
+ import { mergeProps as ue } from "../../merge-props/mergeProps.js";
19
+ const ce = /* @__PURE__ */ a.forwardRef(function(b, M) {
20
+ const {
21
+ checked: j,
22
+ className: me,
23
+ defaultChecked: N,
24
+ id: h,
25
+ inputRef: O,
26
+ name: R,
27
+ nativeButton: q = !0,
28
+ onCheckedChange: A,
29
+ readOnly: l = !1,
30
+ required: u = !1,
31
+ disabled: H = !1,
32
+ render: pe,
33
+ ...L
34
+ } = b, {
35
+ clearErrors: P
36
+ } = ae(), {
37
+ state: x,
38
+ labelId: g,
39
+ setControlId: c,
40
+ setTouched: y,
41
+ setDirty: E,
42
+ validityData: V,
43
+ setFilled: f,
44
+ setFocused: v,
45
+ validationMode: m,
46
+ disabled: T,
47
+ name: U
48
+ } = ie(), r = T || H, d = U ?? R, {
49
+ getValidationProps: _,
50
+ getInputValidationProps: w,
51
+ inputRef: $,
52
+ commitValidation: s
53
+ } = se(), p = X(A), t = a.useRef(null), I = Y(t, O, $), C = a.useRef(null), i = te(h);
54
+ D(() => {
55
+ const e = C.current;
56
+ if (e)
57
+ return e.closest("label") != null ? c(h ?? null) : c(i), () => {
58
+ c(void 0);
59
+ };
60
+ }, [i, h, c]);
61
+ const [o, B] = W({
62
+ controlled: j,
63
+ default: !!N,
64
+ name: "Switch",
65
+ state: "checked"
66
+ });
67
+ re({
68
+ id: i,
69
+ commitValidation: s,
70
+ value: o,
71
+ controlRef: C,
72
+ name: d,
73
+ getValue: () => o
74
+ }), D(() => {
75
+ t.current && f(t.current.checked);
76
+ }, [t, f]);
77
+ const {
78
+ getButtonProps: z,
79
+ buttonRef: G
80
+ } = de({
81
+ disabled: r,
82
+ native: q
83
+ }), J = a.useMemo(() => ({
84
+ id: i,
85
+ role: "switch",
86
+ disabled: r,
87
+ "aria-checked": o,
88
+ "aria-readonly": l || void 0,
89
+ "aria-labelledby": g,
90
+ onFocus() {
91
+ v(!0);
92
+ },
93
+ onBlur() {
94
+ const e = t.current;
95
+ e && (y(!0), v(!1), m === "onBlur" && s(e.checked));
96
+ },
97
+ onClick(e) {
98
+ var n;
99
+ e.defaultPrevented || l || (n = t == null ? void 0 : t.current) == null || n.click();
100
+ }
101
+ }), [i, r, o, l, g, v, y, s, m, t]), K = a.useMemo(() => ue({
102
+ checked: o,
103
+ disabled: r,
104
+ id: d ? void 0 : `${i}-input`,
105
+ name: d,
106
+ required: u,
107
+ style: Z,
108
+ tabIndex: -1,
109
+ type: "checkbox",
110
+ "aria-hidden": !0,
111
+ ref: I,
112
+ onChange(e) {
113
+ if (e.nativeEvent.defaultPrevented)
114
+ return;
115
+ const n = e.target.checked, S = le("none", e.nativeEvent);
116
+ p == null || p(n, S), !S.isCanceled && (P(d), E(n !== V.initialValue), f(n), B(n), m === "onChange" ? s(n) : s(n, !0));
117
+ }
118
+ }, w), [o, P, s, r, w, I, i, d, p, u, B, E, f, m, V.initialValue]), F = a.useMemo(() => ({
119
+ ...x,
120
+ checked: o,
121
+ disabled: r,
122
+ readOnly: l,
123
+ required: u
124
+ }), [x, o, r, l, u]), Q = ee("button", b, {
125
+ state: F,
126
+ ref: [M, C, G],
127
+ props: [J, _, L, z],
128
+ stateAttributesMapping: ne
129
+ });
130
+ return /* @__PURE__ */ k.jsxs(oe.Provider, {
131
+ value: F,
132
+ children: [Q, !o && R && /* @__PURE__ */ k.jsx("input", {
133
+ type: "hidden",
134
+ name: R,
135
+ value: "off"
136
+ }), /* @__PURE__ */ k.jsx("input", {
137
+ ...K
138
+ })]
139
+ });
140
+ });
141
+ process.env.NODE_ENV !== "production" && (ce.displayName = "SwitchRoot");
142
+ export {
143
+ ce as SwitchRoot
144
+ };
@@ -0,0 +1,13 @@
1
+ import * as o from "react";
2
+ const e = /* @__PURE__ */ o.createContext(void 0);
3
+ process.env.NODE_ENV !== "production" && (e.displayName = "SwitchRootContext");
4
+ function n() {
5
+ const t = o.useContext(e);
6
+ if (t === void 0)
7
+ throw new Error("Base UI: SwitchRootContext is missing. Switch parts must be placed within <Switch.Root>.");
8
+ return t;
9
+ }
10
+ export {
11
+ e as SwitchRootContext,
12
+ n as useSwitchRootContext
13
+ };
@@ -0,0 +1,6 @@
1
+ let e = /* @__PURE__ */ function(d) {
2
+ return d.checked = "data-checked", d.unchecked = "data-unchecked", d.disabled = "data-disabled", d.readonly = "data-readonly", d.required = "data-required", d.valid = "data-valid", d.invalid = "data-invalid", d.touched = "data-touched", d.dirty = "data-dirty", d.filled = "data-filled", d.focused = "data-focused", d;
3
+ }({});
4
+ export {
5
+ e as SwitchRootDataAttributes
6
+ };
@@ -0,0 +1,15 @@
1
+ import { fieldValidityMapping as i } from "../field/utils/constants.js";
2
+ import { SwitchRootDataAttributes as t } from "./root/SwitchRootDataAttributes.js";
3
+ const o = {
4
+ ...i,
5
+ checked(e) {
6
+ return e ? {
7
+ [t.checked]: ""
8
+ } : {
9
+ [t.unchecked]: ""
10
+ };
11
+ }
12
+ };
13
+ export {
14
+ o as stateAttributesMapping
15
+ };
@@ -0,0 +1,27 @@
1
+ import * as n from "react";
2
+ import { useSwitchRootContext as m } from "../root/SwitchRootContext.js";
3
+ import { useRenderElement as a } from "../../utils/useRenderElement.js";
4
+ import { useFieldRootContext as c } from "../../field/root/FieldRootContext.js";
5
+ import { stateAttributesMapping as p } from "../stateAttributesMapping.js";
6
+ const f = /* @__PURE__ */ n.forwardRef(function(t, e) {
7
+ const {
8
+ render: d,
9
+ className: h,
10
+ ...o
11
+ } = t, {
12
+ state: r
13
+ } = c(), s = m(), i = {
14
+ ...r,
15
+ ...s
16
+ };
17
+ return a("span", t, {
18
+ state: i,
19
+ ref: e,
20
+ stateAttributesMapping: p,
21
+ props: o
22
+ });
23
+ });
24
+ process.env.NODE_ENV !== "production" && (f.displayName = "SwitchThumb");
25
+ export {
26
+ f as SwitchThumb
27
+ };
@@ -0,0 +1,107 @@
1
+ import * as t from "react";
2
+ import { generateId as C } from "../../../../../../../@base-ui-components_utils@0.1.2_@types_react@19.2.0_react-dom@19.2.0_react@19.2.0/node_modules/@base-ui-components/utils/esm/generateId.js";
3
+ import { useForcedRerendering as N } from "../../../../../../../@base-ui-components_utils@0.1.2_@types_react@19.2.0_react-dom@19.2.0_react@19.2.0/node_modules/@base-ui-components/utils/esm/useForcedRerendering.js";
4
+ import { useOnMount as V } from "../../../../../../../@base-ui-components_utils@0.1.2_@types_react@19.2.0_react-dom@19.2.0_react@19.2.0/node_modules/@base-ui-components/utils/esm/useOnMount.js";
5
+ import { useRenderElement as A } from "../../utils/useRenderElement.js";
6
+ import { useDirection as D } from "../../direction-provider/DirectionContext.js";
7
+ import { useTabsRootContext as M } from "../root/TabsRootContext.js";
8
+ import { tabsStateAttributesMapping as _ } from "../root/stateAttributesMapping.js";
9
+ import { useTabsListContext as F } from "../list/TabsListContext.js";
10
+ import { script as P } from "./prehydrationScript.min.js";
11
+ import { TabsIndicatorCssVars as i } from "./TabsIndicatorCssVars.js";
12
+ import { j as L } from "../../../../../../../../../_virtual/jsx-runtime.js";
13
+ const k = {
14
+ ..._,
15
+ selectedTabPosition: () => null,
16
+ selectedTabSize: () => null
17
+ }, q = /* @__PURE__ */ t.forwardRef(function(p, R) {
18
+ const {
19
+ className: J,
20
+ render: K,
21
+ renderBeforeHydration: m = !1,
22
+ ...y
23
+ } = p, {
24
+ getTabElementBySelectedValue: I,
25
+ orientation: b,
26
+ tabActivationDirection: T,
27
+ value: d
28
+ } = M(), {
29
+ tabsListRef: a
30
+ } = F(), [S] = t.useState(() => C("tab")), [h, H] = t.useState(!1), {
31
+ value: E
32
+ } = M(), $ = D();
33
+ V(() => H(!0));
34
+ const g = N();
35
+ t.useEffect(() => {
36
+ if (d != null && a.current != null && typeof ResizeObserver < "u") {
37
+ const e = new ResizeObserver(() => {
38
+ g();
39
+ });
40
+ return e.observe(a.current), () => {
41
+ e.disconnect();
42
+ };
43
+ }
44
+ }, [d, a, g]);
45
+ let c = 0, l = 0, u = 0, f = 0, r = 0, o = 0, n = !1;
46
+ if (d != null && a.current != null) {
47
+ const e = I(d), s = a.current;
48
+ if (n = !0, e != null) {
49
+ c = e.offsetLeft - s.clientLeft, u = e.offsetTop - s.clientTop;
50
+ const {
51
+ width: w,
52
+ height: B
53
+ } = e.getBoundingClientRect();
54
+ r = Math.floor(w), o = Math.floor(B), l = $ === "ltr" ? s.scrollWidth - e.offsetLeft - r - s.clientLeft : e.offsetLeft - s.clientLeft, f = s.scrollHeight - e.offsetTop - o - s.clientTop;
55
+ }
56
+ }
57
+ const v = t.useMemo(() => n ? {
58
+ left: c,
59
+ right: l,
60
+ top: u,
61
+ bottom: f
62
+ } : null, [c, l, u, f, n]), x = t.useMemo(() => n ? {
63
+ width: r,
64
+ height: o
65
+ } : null, [r, o, n]), z = t.useMemo(() => {
66
+ if (n)
67
+ return {
68
+ [i.activeTabLeft]: `${c}px`,
69
+ [i.activeTabRight]: `${l}px`,
70
+ [i.activeTabTop]: `${u}px`,
71
+ [i.activeTabBottom]: `${f}px`,
72
+ [i.activeTabWidth]: `${r}px`,
73
+ [i.activeTabHeight]: `${o}px`
74
+ };
75
+ }, [c, l, u, f, r, o, n]), O = n && r > 0 && o > 0, W = t.useMemo(() => ({
76
+ orientation: b,
77
+ selectedTabPosition: v,
78
+ selectedTabSize: x,
79
+ tabActivationDirection: T
80
+ }), [b, v, x, T]), j = A("span", p, {
81
+ state: W,
82
+ ref: R,
83
+ props: [{
84
+ role: "presentation",
85
+ style: z,
86
+ hidden: !O
87
+ // do not display the indicator before the layout is settled
88
+ }, y, {
89
+ "data-instance-id": h && m ? void 0 : S,
90
+ suppressHydrationWarning: !0
91
+ }],
92
+ stateAttributesMapping: k
93
+ });
94
+ return E == null ? null : /* @__PURE__ */ L.jsxs(t.Fragment, {
95
+ children: [j, !h && m && /* @__PURE__ */ L.jsx("script", {
96
+ // eslint-disable-next-line react/no-danger
97
+ dangerouslySetInnerHTML: {
98
+ __html: P
99
+ },
100
+ suppressHydrationWarning: !0
101
+ })]
102
+ });
103
+ });
104
+ process.env.NODE_ENV !== "production" && (q.displayName = "TabsIndicator");
105
+ export {
106
+ q as TabsIndicator
107
+ };
@@ -0,0 +1,6 @@
1
+ let e = /* @__PURE__ */ function(t) {
2
+ return t.activeTabLeft = "--active-tab-left", t.activeTabRight = "--active-tab-right", t.activeTabTop = "--active-tab-top", t.activeTabBottom = "--active-tab-bottom", t.activeTabWidth = "--active-tab-width", t.activeTabHeight = "--active-tab-height", t;
3
+ }({});
4
+ export {
5
+ e as TabsIndicatorCssVars
6
+ };
@@ -0,0 +1,4 @@
1
+ const t = '!function(){const t=document.currentScript.previousElementSibling;if(!t)return;const e=t.closest(\'[role="tablist"]\');if(!e)return;const o=e.querySelector("[data-selected]");if(!o)return;if(0===o.offsetWidth||0===e.offsetWidth)return;const i=getComputedStyle(e).direction,f=o.offsetLeft-e.clientLeft,{width:n,height:r}=o.getBoundingClientRect(),l=Math.floor(n),c=Math.floor(r),s="ltr"===i?e.scrollWidth-o.offsetLeft-l-e.clientLeft:o.offsetLeft-e.clientLeft,h=o.offsetTop-e.clientTop,d=e.scrollHeight-o.offsetTop-c-e.clientTop;function u(e,o){t.style.setProperty(`--active-tab-${e}`,`${o}px`)}u("left",f),u("right",s),u("top",h),u("bottom",d),u("width",l),u("height",c),l>0&&c>0&&t.removeAttribute("hidden")}();';
2
+ export {
3
+ t as script
4
+ };