@box/blueprint-web 19.5.0 → 20.0.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 (208) hide show
  1. package/THIRD_PARTY_LICENSES +119 -0
  2. package/dist/lib-esm/accordion/accordion.js +14 -6
  3. package/dist/lib-esm/accordion/accordion.module.js +1 -1
  4. package/dist/lib-esm/accordion/types.d.ts +1 -1
  5. package/dist/lib-esm/blueprint-configuration-context/consts.d.ts +1 -1
  6. package/dist/lib-esm/blueprint-configuration-context/consts.js +1 -1
  7. package/dist/lib-esm/checkbox/checkbox-item.js +3 -3
  8. package/dist/lib-esm/checkbox/types.d.ts +1 -1
  9. package/dist/lib-esm/collapsible/collapsible-section.js +5 -5
  10. package/dist/lib-esm/collapsible/types.d.ts +1 -1
  11. package/dist/lib-esm/combobox-group/combobox-group-combobox.js +1 -1
  12. package/dist/lib-esm/components.css +400 -280
  13. package/dist/lib-esm/date-picker/date-picker.js +8 -7
  14. package/dist/lib-esm/guided-tooltip/guided-tooltip.js +7 -7
  15. package/dist/lib-esm/guided-tooltip/types.d.ts +1 -1
  16. package/dist/lib-esm/index.css +400 -280
  17. package/dist/lib-esm/modal/alert-modal.types.d.ts +1 -1
  18. package/dist/lib-esm/modal/modal-close.js +2 -2
  19. package/dist/lib-esm/modal/modal-content.d.ts +1 -1
  20. package/dist/lib-esm/modal/modal-content.js +4 -4
  21. package/dist/lib-esm/modal/modal-description.js +2 -2
  22. package/dist/lib-esm/modal/modal-title.js +2 -2
  23. package/dist/lib-esm/modal/modal-trigger.js +2 -2
  24. package/dist/lib-esm/modal/modal.d.ts +1 -1
  25. package/dist/lib-esm/modal/modal.js +1 -1
  26. package/dist/lib-esm/modal/types.d.ts +1 -1
  27. package/dist/lib-esm/navigation-menu/index.d.ts +4 -2
  28. package/dist/lib-esm/navigation-menu/navigation-menu-item.d.ts +1 -1
  29. package/dist/lib-esm/navigation-menu/navigation-menu-trigger.d.ts +3 -1
  30. package/dist/lib-esm/primitives/chips/chip.d.ts +1 -1
  31. package/dist/lib-esm/primitives/chips/chip.js +2 -2
  32. package/dist/lib-esm/primitives/chips/chips-group.js +2 -2
  33. package/dist/lib-esm/primitives/chips/filter-chip/filter-chip-button.d.ts +1 -1
  34. package/dist/lib-esm/primitives/chips/filter-chip/filter-chip.d.ts +1 -1
  35. package/dist/lib-esm/primitives/chips/filter-chip/filter-combo-chip.d.ts +2 -2
  36. package/dist/lib-esm/primitives/chips/filter-chip/filter-trigger-chip.d.ts +1 -1
  37. package/dist/lib-esm/primitives/chips/filter-chip/index.d.ts +5 -5
  38. package/dist/lib-esm/primitives/chips/types.d.ts +1 -1
  39. package/dist/lib-esm/primitives/context-menu/context-menu-item.d.ts +2 -2
  40. package/dist/lib-esm/primitives/context-menu/context-menu-item.js +2 -2
  41. package/dist/lib-esm/primitives/context-menu/context-menu-menu-content.d.ts +1 -1
  42. package/dist/lib-esm/primitives/context-menu/context-menu-menu-content.js +5 -5
  43. package/dist/lib-esm/primitives/context-menu/context-menu-menu-header.js +3 -10
  44. package/dist/lib-esm/primitives/context-menu/context-menu-menu-root.d.ts +1 -1
  45. package/dist/lib-esm/primitives/context-menu/context-menu-menu-root.js +1 -1
  46. package/dist/lib-esm/primitives/context-menu/context-menu-menu-trigger.d.ts +1 -1
  47. package/dist/lib-esm/primitives/context-menu/context-menu-menu-trigger.js +1 -1
  48. package/dist/lib-esm/primitives/context-menu/context-menu-sub-menu-content.d.ts +1 -1
  49. package/dist/lib-esm/primitives/context-menu/context-menu-sub-menu-content.js +5 -5
  50. package/dist/lib-esm/primitives/context-menu/context-menu-sub-menu-root.d.ts +1 -1
  51. package/dist/lib-esm/primitives/context-menu/context-menu-sub-menu-root.js +1 -1
  52. package/dist/lib-esm/primitives/context-menu/context-menu-sub-menu-trigger.d.ts +2 -2
  53. package/dist/lib-esm/primitives/context-menu/context-menu-sub-menu-trigger.js +1 -1
  54. package/dist/lib-esm/primitives/context-menu/index.d.ts +3 -3
  55. package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-checkbox-item.d.ts +2 -2
  56. package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-checkbox-item.js +3 -3
  57. package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-content.d.ts +1 -1
  58. package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-content.js +5 -5
  59. package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-group.d.ts +4 -2
  60. package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-group.js +2 -2
  61. package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-item.d.ts +2 -2
  62. package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-item.js +2 -2
  63. package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-radio-group.d.ts +2 -2
  64. package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-radio-group.js +2 -2
  65. package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-radio-select-item.d.ts +2 -2
  66. package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-radio-select-item.js +3 -3
  67. package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-root.d.ts +1 -1
  68. package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-root.js +2 -2
  69. package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-sub-header.d.ts +4 -2
  70. package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-sub-header.js +2 -2
  71. package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-sub-menu-content.d.ts +1 -1
  72. package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-sub-menu-content.js +5 -5
  73. package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-sub-menu-root.d.ts +1 -1
  74. package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-sub-menu-root.js +2 -2
  75. package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-sub-menu-trigger.d.ts +2 -2
  76. package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-sub-menu-trigger.js +2 -2
  77. package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-trigger.d.ts +4 -2
  78. package/dist/lib-esm/primitives/dropdown-menu/dropdown-menu-trigger.js +2 -2
  79. package/dist/lib-esm/primitives/dropdown-menu/index.d.ts +14 -8
  80. package/dist/lib-esm/primitives/notification/hooks/use-notification-layer.d.ts +15 -0
  81. package/dist/lib-esm/primitives/notification/hooks/use-notification-layer.js +49 -0
  82. package/dist/lib-esm/primitives/notification/notification-provider.js +2 -2
  83. package/dist/lib-esm/primitives/notification/notification.viewport-animated.js +12 -8
  84. package/dist/lib-esm/primitives/notification/notification.viewport.js +5 -1
  85. package/dist/lib-esm/primitives/notification/private-notification-element-animated.js +44 -6
  86. package/dist/lib-esm/primitives/notification/private-notification-element.js +34 -4
  87. package/dist/lib-esm/primitives/popover/index.d.ts +11 -5
  88. package/dist/lib-esm/primitives/popover/popover-anchor.d.ts +4 -2
  89. package/dist/lib-esm/primitives/popover/popover-anchor.js +2 -2
  90. package/dist/lib-esm/primitives/popover/popover-close.d.ts +4 -2
  91. package/dist/lib-esm/primitives/popover/popover-close.js +2 -2
  92. package/dist/lib-esm/primitives/popover/popover-content-container.d.ts +1 -1
  93. package/dist/lib-esm/primitives/popover/popover-content-container.js +3 -3
  94. package/dist/lib-esm/primitives/popover/popover-footer.d.ts +1 -1
  95. package/dist/lib-esm/primitives/popover/popover-main-content.d.ts +1 -1
  96. package/dist/lib-esm/primitives/popover/popover-root.d.ts +1 -1
  97. package/dist/lib-esm/primitives/popover/popover-root.js +2 -2
  98. package/dist/lib-esm/primitives/popover/popover-trigger.d.ts +4 -2
  99. package/dist/lib-esm/primitives/popover/popover-trigger.js +2 -2
  100. package/dist/lib-esm/radio-group/index.d.ts +1 -1
  101. package/dist/lib-esm/radio-group/radio-group.d.ts +1 -1
  102. package/dist/lib-esm/radio-group/radio-group.js +2 -2
  103. package/dist/lib-esm/radio-group/radio-item.js +3 -3
  104. package/dist/lib-esm/radio-group/types.d.ts +1 -1
  105. package/dist/lib-esm/select/select.js +12 -12
  106. package/dist/lib-esm/select/types.d.ts +1 -1
  107. package/dist/lib-esm/select/utils/use-select-exit-animation.d.ts +3 -3
  108. package/dist/lib-esm/select/utils/use-select-exit-animation.js +3 -3
  109. package/dist/lib-esm/side-panel/side-panel-close.js +2 -2
  110. package/dist/lib-esm/side-panel/side-panel-content.js +3 -3
  111. package/dist/lib-esm/side-panel/side-panel-header.js +2 -2
  112. package/dist/lib-esm/side-panel/side-panel-overlay.js +3 -3
  113. package/dist/lib-esm/side-panel/side-panel-trigger.js +2 -2
  114. package/dist/lib-esm/side-panel/side-panel.js +1 -1
  115. package/dist/lib-esm/side-panel/types.d.ts +1 -1
  116. package/dist/lib-esm/small-list-item/small-list.js +8 -0
  117. package/dist/lib-esm/switch/switch-item.js +3 -3
  118. package/dist/lib-esm/switch/types.d.ts +1 -1
  119. package/dist/lib-esm/toolbar/index.d.ts +2 -2
  120. package/dist/lib-esm/toolbar/toolbar-button.js +2 -2
  121. package/dist/lib-esm/toolbar/toolbar-input.js +2 -2
  122. package/dist/lib-esm/toolbar/toolbar-link.js +2 -2
  123. package/dist/lib-esm/toolbar/toolbar-root.js +3 -3
  124. package/dist/lib-esm/toolbar/toolbar-separator.d.ts +1 -1
  125. package/dist/lib-esm/toolbar/toolbar-separator.js +2 -2
  126. package/dist/lib-esm/toolbar/toolbar-text-toggle-item.js +2 -2
  127. package/dist/lib-esm/toolbar/toolbar-toggle-group.d.ts +1 -2
  128. package/dist/lib-esm/toolbar/toolbar-toggle-group.js +2 -2
  129. package/dist/lib-esm/toolbar/toolbar-toggle-item.js +2 -2
  130. package/dist/lib-esm/toolbar/types.d.ts +1 -1
  131. package/dist/lib-esm/tooltip/tooltip.d.ts +1 -1
  132. package/dist/lib-esm/tooltip/tooltip.js +6 -6
  133. package/dist/lib-esm/tooltip/types.d.ts +1 -1
  134. package/dist/lib-esm/util-components/base-grid-list-item/base-grid-list-item.module.js +1 -1
  135. package/dist/lib-esm/utils/TooltipWrapper.d.ts +1 -1
  136. package/dist/lib-esm/utils/radix-compat/accordion.d.ts +45 -0
  137. package/dist/lib-esm/utils/radix-compat/accordion.js +299 -0
  138. package/dist/lib-esm/utils/radix-compat/allow-auto-focus.d.ts +9 -0
  139. package/dist/lib-esm/utils/radix-compat/allow-auto-focus.js +16 -0
  140. package/dist/lib-esm/utils/radix-compat/bubble-input.d.ts +14 -0
  141. package/dist/lib-esm/utils/radix-compat/bubble-input.js +70 -0
  142. package/dist/lib-esm/utils/radix-compat/button-controls.d.ts +9 -0
  143. package/dist/lib-esm/utils/radix-compat/button-controls.js +6 -0
  144. package/dist/lib-esm/utils/radix-compat/checkbox.d.ts +18 -0
  145. package/dist/lib-esm/utils/radix-compat/checkbox.js +131 -0
  146. package/dist/lib-esm/utils/radix-compat/collapsible.d.ts +33 -0
  147. package/dist/lib-esm/utils/radix-compat/collapsible.js +133 -0
  148. package/dist/lib-esm/utils/radix-compat/collection.d.ts +21 -0
  149. package/dist/lib-esm/utils/radix-compat/collection.js +82 -0
  150. package/dist/lib-esm/utils/radix-compat/compose-refs.d.ts +8 -0
  151. package/dist/lib-esm/utils/radix-compat/compose-refs.js +44 -0
  152. package/dist/lib-esm/utils/radix-compat/content-size.d.ts +15 -0
  153. package/dist/lib-esm/utils/radix-compat/content-size.js +61 -0
  154. package/dist/lib-esm/utils/radix-compat/context-menu.d.ts +56 -0
  155. package/dist/lib-esm/utils/radix-compat/context-menu.js +191 -0
  156. package/dist/lib-esm/utils/radix-compat/dialog.d.ts +50 -0
  157. package/dist/lib-esm/utils/radix-compat/dialog.js +367 -0
  158. package/dist/lib-esm/utils/radix-compat/dismiss-marker.d.ts +5 -0
  159. package/dist/lib-esm/utils/radix-compat/dismiss-marker.js +12 -0
  160. package/dist/lib-esm/utils/radix-compat/dismissable.d.ts +34 -0
  161. package/dist/lib-esm/utils/radix-compat/dismissable.js +205 -0
  162. package/dist/lib-esm/utils/radix-compat/dropdown-menu.d.ts +57 -0
  163. package/dist/lib-esm/utils/radix-compat/dropdown-menu.js +187 -0
  164. package/dist/lib-esm/utils/radix-compat/focus-scope-component.d.ts +16 -0
  165. package/dist/lib-esm/utils/radix-compat/focus-scope-component.js +41 -0
  166. package/dist/lib-esm/utils/radix-compat/focus-scope.d.ts +37 -0
  167. package/dist/lib-esm/utils/radix-compat/focus-scope.js +288 -0
  168. package/dist/lib-esm/utils/radix-compat/hide-others.d.ts +6 -0
  169. package/dist/lib-esm/utils/radix-compat/hide-others.js +18 -0
  170. package/dist/lib-esm/utils/radix-compat/index.d.ts +14 -0
  171. package/dist/lib-esm/utils/radix-compat/layers.d.ts +25 -0
  172. package/dist/lib-esm/utils/radix-compat/layers.js +61 -0
  173. package/dist/lib-esm/utils/radix-compat/menu.d.ts +98 -0
  174. package/dist/lib-esm/utils/radix-compat/menu.js +1041 -0
  175. package/dist/lib-esm/utils/radix-compat/popover.d.ts +44 -0
  176. package/dist/lib-esm/utils/radix-compat/popover.js +386 -0
  177. package/dist/lib-esm/utils/radix-compat/popper.d.ts +60 -0
  178. package/dist/lib-esm/utils/radix-compat/popper.js +416 -0
  179. package/dist/lib-esm/utils/radix-compat/portal.d.ts +11 -0
  180. package/dist/lib-esm/utils/radix-compat/portal.js +20 -0
  181. package/dist/lib-esm/utils/radix-compat/presence.d.ts +20 -0
  182. package/dist/lib-esm/utils/radix-compat/presence.js +110 -0
  183. package/dist/lib-esm/utils/radix-compat/radio-group.d.ts +27 -0
  184. package/dist/lib-esm/utils/radix-compat/radio-group.js +189 -0
  185. package/dist/lib-esm/utils/radix-compat/roving-focus.d.ts +35 -0
  186. package/dist/lib-esm/utils/radix-compat/roving-focus.js +237 -0
  187. package/dist/lib-esm/utils/radix-compat/select.d.ts +82 -0
  188. package/dist/lib-esm/utils/radix-compat/select.js +901 -0
  189. package/dist/lib-esm/utils/radix-compat/slot.d.ts +31 -0
  190. package/dist/lib-esm/utils/radix-compat/slot.js +119 -0
  191. package/dist/lib-esm/utils/radix-compat/store-options.d.ts +8 -0
  192. package/dist/lib-esm/utils/radix-compat/store-options.js +10 -0
  193. package/dist/lib-esm/utils/radix-compat/switch.d.ts +16 -0
  194. package/dist/lib-esm/utils/radix-compat/switch.js +97 -0
  195. package/dist/lib-esm/utils/radix-compat/toggle-group.d.ts +41 -0
  196. package/dist/lib-esm/utils/radix-compat/toggle-group.js +195 -0
  197. package/dist/lib-esm/utils/radix-compat/toolbar.d.ts +32 -0
  198. package/dist/lib-esm/utils/radix-compat/toolbar.js +136 -0
  199. package/dist/lib-esm/utils/radix-compat/tooltip.d.ts +59 -0
  200. package/dist/lib-esm/utils/radix-compat/tooltip.js +636 -0
  201. package/dist/lib-esm/utils/radix-compat/typeahead.d.ts +22 -0
  202. package/dist/lib-esm/utils/radix-compat/typeahead.js +64 -0
  203. package/dist/lib-esm/utils/radix-compat/types.d.ts +53 -0
  204. package/dist/lib-esm/utils/radix-compat/viewport-height.d.ts +5 -0
  205. package/dist/lib-esm/utils/radix-compat/viewport-height.js +28 -0
  206. package/dist/lib-esm/utils/radix-compat/visually-hidden.d.ts +2 -0
  207. package/dist/lib-esm/utils/radix-compat/visually-hidden.js +24 -0
  208. package/package.json +8 -19
@@ -0,0 +1,31 @@
1
+ import { type HTMLAttributes, type ReactElement, type ReactNode, type Ref } from 'react';
2
+ type AnyProps = Record<string, unknown>;
3
+ export interface SlotProps extends HTMLAttributes<HTMLElement> {
4
+ children?: ReactNode;
5
+ /** Any prop of the child element, e.g. `disabled` on a button. */
6
+ [prop: string]: unknown;
7
+ }
8
+ /**
9
+ * Merges the slot props into its only child, like the Radix `Slot` behind `asChild`:
10
+ * the child's props win, event handlers run child first, class names are joined and styles are merged.
11
+ */
12
+ export declare function mergeSlotProps(slotProps: AnyProps, childProps: AnyProps): AnyProps;
13
+ /**
14
+ * Reads the ref of a React element without triggering React 19's `element.ref` deprecation warning.
15
+ */
16
+ export declare function getElementRef(element: ReactElement): Ref<unknown> | undefined;
17
+ export declare const Slot: import("react").ForwardRefExoticComponent<Omit<SlotProps, "ref"> & import("react").RefAttributes<HTMLElement>>;
18
+ type RenderProps = HTMLAttributes<HTMLElement> & {
19
+ ref?: Ref<HTMLElement>;
20
+ };
21
+ /**
22
+ * Supports `asChild` on content rendered by an Ariakit component, as its `render` and `children` props. The `render`
23
+ * function merges the Ariakit element props, except `omitProps`, into the only child element with the `Slot` rules,
24
+ * so that element becomes the content root; its own children go through `renderChildren`. Without `asChild`,
25
+ * `renderChildren` renders the children as usual.
26
+ */
27
+ export declare function getAsChildRender(asChild: boolean | undefined, children: ReactNode, renderChildren: (content: ReactNode) => ReactNode, omitProps?: string[]): {
28
+ render?: (props: RenderProps) => ReactElement;
29
+ children: ReactNode;
30
+ };
31
+ export {};
@@ -0,0 +1,119 @@
1
+ import { forwardRef, isValidElement, cloneElement, Children } from 'react';
2
+ import { composeRefs } from './compose-refs.js';
3
+
4
+ /**
5
+ * Merges the slot props into its only child, like the Radix `Slot` behind `asChild`:
6
+ * the child's props win, event handlers run child first, class names are joined and styles are merged.
7
+ */
8
+ function mergeSlotProps(slotProps, childProps) {
9
+ const overrideProps = {
10
+ ...childProps
11
+ };
12
+ Object.keys(childProps).forEach(propName => {
13
+ const slotPropValue = slotProps[propName];
14
+ const childPropValue = childProps[propName];
15
+ if (/^on[A-Z]/.test(propName)) {
16
+ if (typeof slotPropValue === 'function' && typeof childPropValue === 'function') {
17
+ overrideProps[propName] = (...args) => {
18
+ childPropValue(...args);
19
+ slotPropValue(...args);
20
+ };
21
+ } else if (slotPropValue) {
22
+ overrideProps[propName] = slotPropValue;
23
+ }
24
+ } else if (propName === 'style') {
25
+ overrideProps[propName] = {
26
+ ...slotPropValue,
27
+ ...childPropValue
28
+ };
29
+ } else if (propName === 'className') {
30
+ overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(' ');
31
+ }
32
+ });
33
+ return {
34
+ ...slotProps,
35
+ ...overrideProps
36
+ };
37
+ }
38
+ /**
39
+ * Reads the ref of a React element without triggering React 19's `element.ref` deprecation warning.
40
+ */
41
+ function getElementRef(element) {
42
+ const props = element.props;
43
+ let getter = Object.getOwnPropertyDescriptor(props, 'ref')?.get;
44
+ let mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning;
45
+ if (mayWarn) {
46
+ return element.ref;
47
+ }
48
+ getter = Object.getOwnPropertyDescriptor(element, 'ref')?.get;
49
+ mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning;
50
+ if (mayWarn) {
51
+ return props.ref;
52
+ }
53
+ return props.ref || element.ref;
54
+ }
55
+ const Slot = /*#__PURE__*/forwardRef(({
56
+ children,
57
+ ...slotProps
58
+ }, forwardedRef) => {
59
+ if (/*#__PURE__*/isValidElement(children)) {
60
+ const childRef = getElementRef(children);
61
+ return /*#__PURE__*/cloneElement(children, {
62
+ ...mergeSlotProps(slotProps, children.props),
63
+ ref: forwardedRef ? composeRefs(forwardedRef, childRef) : childRef
64
+ });
65
+ }
66
+ return Children.count(children) > 1 ? Children.only(null) : null;
67
+ });
68
+ Slot.displayName = 'Slot';
69
+ const composedRefsCache = new WeakMap();
70
+ /**
71
+ * Composes two refs into the same callback ref on every render. Ariakit registers its element through its ref, so a
72
+ * new callback ref on each render would re-register it and render again without end.
73
+ */
74
+ function getStableComposedRef(first, second) {
75
+ if (!first || !second) {
76
+ return first ?? second;
77
+ }
78
+ let refsCache = composedRefsCache.get(first);
79
+ if (!refsCache) {
80
+ refsCache = new WeakMap();
81
+ composedRefsCache.set(first, refsCache);
82
+ }
83
+ let composedRef = refsCache.get(second);
84
+ if (!composedRef) {
85
+ composedRef = composeRefs(first, second);
86
+ refsCache.set(second, composedRef);
87
+ }
88
+ return composedRef;
89
+ }
90
+ /**
91
+ * Supports `asChild` on content rendered by an Ariakit component, as its `render` and `children` props. The `render`
92
+ * function merges the Ariakit element props, except `omitProps`, into the only child element with the `Slot` rules,
93
+ * so that element becomes the content root; its own children go through `renderChildren`. Without `asChild`,
94
+ * `renderChildren` renders the children as usual.
95
+ */
96
+ function getAsChildRender(asChild, children, renderChildren, omitProps = []) {
97
+ if (!asChild || ! /*#__PURE__*/isValidElement(children)) {
98
+ return {
99
+ children: renderChildren(children)
100
+ };
101
+ }
102
+ return {
103
+ render: ({
104
+ children: contentChildren,
105
+ ref,
106
+ ...renderProps
107
+ }) => {
108
+ const slotProps = Object.fromEntries(Object.entries(renderProps).filter(([propName]) => !omitProps.includes(propName)));
109
+ return /*#__PURE__*/cloneElement(children, {
110
+ ...mergeSlotProps(slotProps, children.props),
111
+ children: contentChildren,
112
+ ref: getStableComposedRef(ref, getElementRef(children))
113
+ });
114
+ },
115
+ children: renderChildren(children.props.children)
116
+ };
117
+ }
118
+
119
+ export { Slot, getAsChildRender, getElementRef, mergeSlotProps };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Options for the Ariakit stores of the compat overlays. `Presence` keeps closing content mounted for its exit
3
+ * animation, so Ariakit must not track the animation itself: it makes animating closed content inert, which takes
4
+ * focus away from it while Radix kept it focusable until it unmounted.
5
+ */
6
+ export declare const overlayStoreOptions: {
7
+ readonly animated: false;
8
+ };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Options for the Ariakit stores of the compat overlays. `Presence` keeps closing content mounted for its exit
3
+ * animation, so Ariakit must not track the animation itself: it makes animating closed content inert, which takes
4
+ * focus away from it while Radix kept it focusable until it unmounted.
5
+ */
6
+ const overlayStoreOptions = {
7
+ animated: false
8
+ };
9
+
10
+ export { overlayStoreOptions };
@@ -0,0 +1,16 @@
1
+ import { type PrimitiveProps } from './types';
2
+ export interface SwitchProps extends Omit<PrimitiveProps<'button'>, 'checked' | 'defaultChecked'> {
3
+ checked?: boolean;
4
+ defaultChecked?: boolean;
5
+ required?: boolean;
6
+ onCheckedChange?(checked: boolean): void;
7
+ }
8
+ /**
9
+ * Switch rendered as a `<button role="switch">` with the Radix API and DOM, on top of the Ariakit `Checkbox`.
10
+ * Like a native button, both Enter and Space toggle it.
11
+ */
12
+ export declare const Root: import("react").ForwardRefExoticComponent<SwitchProps & import("react").RefAttributes<HTMLButtonElement>>;
13
+ export type SwitchThumbProps = PrimitiveProps<'span'>;
14
+ export declare const Thumb: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
15
+ asChild?: boolean;
16
+ } & import("react").RefAttributes<HTMLSpanElement>>;
@@ -0,0 +1,97 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { forwardRef, useState, useRef, useContext, createContext } from 'react';
3
+ import { composeEventHandlers } from '../composeEventHandlers.js';
4
+ import { useControllableState } from '../useControllableState.js';
5
+ import { BubbleInput } from './bubble-input.js';
6
+ import { ButtonCheckbox } from './button-controls.js';
7
+ import { useComposedRefs } from './compose-refs.js';
8
+ import { Slot } from './slot.js';
9
+
10
+ const getState = checked => checked ? 'checked' : 'unchecked';
11
+ const SwitchContext = /*#__PURE__*/createContext({
12
+ checked: false
13
+ });
14
+ /**
15
+ * Switch rendered as a `<button role="switch">` with the Radix API and DOM, on top of the Ariakit `Checkbox`.
16
+ * Like a native button, both Enter and Space toggle it.
17
+ */
18
+ const Root = /*#__PURE__*/forwardRef((props, forwardedRef) => {
19
+ const {
20
+ name,
21
+ checked: checkedProp,
22
+ defaultChecked,
23
+ required,
24
+ disabled,
25
+ value = 'on',
26
+ onCheckedChange,
27
+ asChild,
28
+ ...switchProps
29
+ } = props;
30
+ const [button, setButton] = useState(null);
31
+ const composedRefs = useComposedRefs(forwardedRef, setButton);
32
+ const hasConsumerStoppedPropagationRef = useRef(false);
33
+ const isFormControl = button ? Boolean(button.closest('form')) : true;
34
+ const [checked = false, setChecked] = useControllableState({
35
+ prop: checkedProp,
36
+ defaultProp: defaultChecked,
37
+ onChange: onCheckedChange
38
+ });
39
+ return jsxs(SwitchContext.Provider, {
40
+ value: {
41
+ checked,
42
+ disabled
43
+ },
44
+ children: [jsx(ButtonCheckbox, {
45
+ "aria-checked": checked,
46
+ "aria-required": required,
47
+ checked: checked,
48
+ "data-disabled": disabled ? '' : undefined,
49
+ "data-state": getState(checked),
50
+ role: "switch",
51
+ ...switchProps,
52
+ ref: composedRefs,
53
+ onClick: composeEventHandlers(props.onClick, event => {
54
+ setChecked(prevChecked => !prevChecked);
55
+ if (isFormControl) {
56
+ hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
57
+ if (!hasConsumerStoppedPropagationRef.current) {
58
+ event.stopPropagation();
59
+ }
60
+ }
61
+ }),
62
+ // Ariakit would also make a disabled switch `aria-disabled` and ignore pointer events, unlike Radix.
63
+ render: asChild ? jsx(Slot, {
64
+ disabled: disabled
65
+ }) : jsx("button", {
66
+ disabled: disabled,
67
+ type: "button",
68
+ value: value
69
+ })
70
+ }), isFormControl && jsx(BubbleInput, {
71
+ bubbles: !hasConsumerStoppedPropagationRef.current,
72
+ checked: checked,
73
+ control: button,
74
+ disabled: disabled,
75
+ name: name,
76
+ required: required,
77
+ value: value
78
+ })]
79
+ });
80
+ });
81
+ Root.displayName = 'Switch';
82
+ const Thumb = /*#__PURE__*/forwardRef(({
83
+ asChild,
84
+ ...thumbProps
85
+ }, forwardedRef) => {
86
+ const context = useContext(SwitchContext);
87
+ const Comp = asChild ? Slot : 'span';
88
+ return jsx(Comp, {
89
+ "data-disabled": context.disabled ? '' : undefined,
90
+ "data-state": getState(context.checked),
91
+ ...thumbProps,
92
+ ref: forwardedRef
93
+ });
94
+ });
95
+ Thumb.displayName = 'SwitchThumb';
96
+
97
+ export { Root, Thumb };
@@ -0,0 +1,41 @@
1
+ import { type Direction, type Orientation, type PrimitiveProps } from './types';
2
+ export interface ToggleGroupImplProps extends PrimitiveProps<'div'> {
3
+ disabled?: boolean;
4
+ rovingFocus?: boolean;
5
+ loop?: boolean;
6
+ orientation?: Orientation;
7
+ dir?: Direction;
8
+ }
9
+ export interface ToggleGroupImplSingleProps extends ToggleGroupImplProps {
10
+ value?: string;
11
+ defaultValue?: string;
12
+ onValueChange?(value: string): void;
13
+ }
14
+ export interface ToggleGroupImplMultipleProps extends ToggleGroupImplProps {
15
+ value?: string[];
16
+ defaultValue?: string[];
17
+ onValueChange?(value: string[]): void;
18
+ }
19
+ export interface ToggleGroupSingleProps extends ToggleGroupImplSingleProps {
20
+ type: 'single';
21
+ }
22
+ export interface ToggleGroupMultipleProps extends ToggleGroupImplMultipleProps {
23
+ type: 'multiple';
24
+ }
25
+ export type ToggleGroupProps = ToggleGroupSingleProps | ToggleGroupMultipleProps;
26
+ /**
27
+ * Toggle group with the Radix API and DOM (`role="group"`, `data-state="on|off"`, `aria-pressed` or
28
+ * `role="radio"` items) and the Radix roving focus model.
29
+ */
30
+ export declare const Root: import("react").ForwardRefExoticComponent<ToggleGroupProps & import("react").RefAttributes<HTMLDivElement>>;
31
+ export interface ToggleProps extends PrimitiveProps<'button'> {
32
+ pressed?: boolean;
33
+ defaultPressed?: boolean;
34
+ onPressedChange?(pressed: boolean): void;
35
+ }
36
+ /** A two-state button (Radix `Toggle`) rendered by the Ariakit `Button`. */
37
+ export declare const Toggle: import("react").ForwardRefExoticComponent<ToggleProps & import("react").RefAttributes<HTMLButtonElement>>;
38
+ export interface ToggleGroupItemProps extends Omit<ToggleProps, 'defaultPressed' | 'onPressedChange' | 'pressed'> {
39
+ value: string;
40
+ }
41
+ export declare const Item: import("react").ForwardRefExoticComponent<ToggleGroupItemProps & import("react").RefAttributes<HTMLButtonElement>>;
@@ -0,0 +1,195 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { Button } from '@ariakit/react';
3
+ import { forwardRef, useContext, useCallback, createContext } from 'react';
4
+ import { composeEventHandlers } from '../composeEventHandlers.js';
5
+ import { useControllableState } from '../useControllableState.js';
6
+ import { RovingFocusGroupItem, RovingFocusGroup } from './roving-focus.js';
7
+ import { Slot } from './slot.js';
8
+
9
+ const ToggleGroupValueContext = /*#__PURE__*/createContext(null);
10
+ const ToggleGroupContext = /*#__PURE__*/createContext(null);
11
+ const ToggleGroupImpl = /*#__PURE__*/forwardRef((props, forwardedRef) => {
12
+ const {
13
+ disabled = false,
14
+ rovingFocus = true,
15
+ orientation,
16
+ dir,
17
+ loop = true,
18
+ asChild,
19
+ ...toggleGroupProps
20
+ } = props;
21
+ const direction = dir ?? 'ltr';
22
+ const Comp = asChild ? Slot : 'div';
23
+ const commonProps = {
24
+ role: 'group',
25
+ dir: direction,
26
+ ...toggleGroupProps
27
+ };
28
+ return jsx(ToggleGroupContext.Provider, {
29
+ value: {
30
+ rovingFocus,
31
+ disabled
32
+ },
33
+ children: rovingFocus ? jsx(RovingFocusGroup, {
34
+ asChild: true,
35
+ dir: direction,
36
+ loop: loop,
37
+ orientation: orientation,
38
+ children: jsx(Comp, {
39
+ ...commonProps,
40
+ ref: forwardedRef
41
+ })
42
+ }) : jsx(Comp, {
43
+ ...commonProps,
44
+ ref: forwardedRef
45
+ })
46
+ });
47
+ });
48
+ const ToggleGroupSingle = /*#__PURE__*/forwardRef((props, forwardedRef) => {
49
+ const {
50
+ value: valueProp,
51
+ defaultValue,
52
+ onValueChange = () => undefined,
53
+ type: _type,
54
+ ...singleProps
55
+ } = props;
56
+ const [value, setValue] = useControllableState({
57
+ prop: valueProp,
58
+ defaultProp: defaultValue,
59
+ onChange: onValueChange
60
+ });
61
+ return jsx(ToggleGroupValueContext.Provider, {
62
+ value: {
63
+ type: 'single',
64
+ value: value ? [value] : [],
65
+ onItemActivate: setValue,
66
+ onItemDeactivate: useCallback(() => setValue(''), [setValue])
67
+ },
68
+ children: jsx(ToggleGroupImpl, {
69
+ ...singleProps,
70
+ ref: forwardedRef
71
+ })
72
+ });
73
+ });
74
+ const ToggleGroupMultiple = /*#__PURE__*/forwardRef((props, forwardedRef) => {
75
+ const {
76
+ value: valueProp,
77
+ defaultValue,
78
+ onValueChange = () => undefined,
79
+ type: _type,
80
+ ...multipleProps
81
+ } = props;
82
+ const [value = [], setValue] = useControllableState({
83
+ prop: valueProp,
84
+ defaultProp: defaultValue,
85
+ onChange: onValueChange
86
+ });
87
+ const onItemActivate = useCallback(itemValue => setValue((prevValue = []) => [...prevValue, itemValue]), [setValue]);
88
+ const onItemDeactivate = useCallback(itemValue => setValue((prevValue = []) => prevValue.filter(item => item !== itemValue)), [setValue]);
89
+ return jsx(ToggleGroupValueContext.Provider, {
90
+ value: {
91
+ type: 'multiple',
92
+ value,
93
+ onItemActivate,
94
+ onItemDeactivate
95
+ },
96
+ children: jsx(ToggleGroupImpl, {
97
+ ...multipleProps,
98
+ ref: forwardedRef
99
+ })
100
+ });
101
+ });
102
+ /**
103
+ * Toggle group with the Radix API and DOM (`role="group"`, `data-state="on|off"`, `aria-pressed` or
104
+ * `role="radio"` items) and the Radix roving focus model.
105
+ */
106
+ const Root = /*#__PURE__*/forwardRef((props, forwardedRef) => props.type === 'multiple' ? jsx(ToggleGroupMultiple, {
107
+ ...props,
108
+ ref: forwardedRef
109
+ }) : jsx(ToggleGroupSingle, {
110
+ ...props,
111
+ ref: forwardedRef
112
+ }));
113
+ Root.displayName = 'ToggleGroup';
114
+ /** A two-state button (Radix `Toggle`) rendered by the Ariakit `Button`. */
115
+ const Toggle = /*#__PURE__*/forwardRef((props, forwardedRef) => {
116
+ const {
117
+ pressed: pressedProp,
118
+ defaultPressed = false,
119
+ onPressedChange,
120
+ asChild,
121
+ disabled,
122
+ ...buttonProps
123
+ } = props;
124
+ const [pressed = false, setPressed] = useControllableState({
125
+ prop: pressedProp,
126
+ defaultProp: defaultPressed,
127
+ onChange: onPressedChange
128
+ });
129
+ return jsx(Button, {
130
+ "aria-pressed": pressed,
131
+ "data-disabled": disabled ? '' : undefined,
132
+ "data-state": pressed ? 'on' : 'off',
133
+ ...buttonProps,
134
+ ref: forwardedRef,
135
+ onClick: composeEventHandlers(props.onClick, () => {
136
+ if (!disabled) {
137
+ setPressed(!pressed);
138
+ }
139
+ }),
140
+ // Ariakit would also make a disabled button `aria-disabled` and ignore pointer events, unlike Radix.
141
+ render: asChild ? jsx(Slot, {
142
+ disabled: disabled
143
+ }) : jsx("button", {
144
+ disabled: disabled,
145
+ type: "button"
146
+ })
147
+ });
148
+ });
149
+ Toggle.displayName = 'Toggle';
150
+ const Item = /*#__PURE__*/forwardRef((props, forwardedRef) => {
151
+ const valueContext = useContext(ToggleGroupValueContext);
152
+ const context = useContext(ToggleGroupContext);
153
+ if (!valueContext || !context) {
154
+ throw new Error('ToggleGroup.Item must be used within ToggleGroup');
155
+ }
156
+ const {
157
+ value,
158
+ ...itemProps
159
+ } = props;
160
+ const pressed = valueContext.value.includes(value);
161
+ const disabled = context.disabled || props.disabled;
162
+ const typeProps = valueContext.type === 'single' ? {
163
+ role: 'radio',
164
+ 'aria-checked': pressed,
165
+ 'aria-pressed': undefined
166
+ } : {};
167
+ const {
168
+ onItemActivate,
169
+ onItemDeactivate
170
+ } = valueContext;
171
+ const handlePressedChange = useCallback(nextPressed => {
172
+ if (nextPressed) {
173
+ onItemActivate(value);
174
+ } else {
175
+ onItemDeactivate(value);
176
+ }
177
+ }, [onItemActivate, onItemDeactivate, value]);
178
+ const toggle = jsx(Toggle, {
179
+ ...typeProps,
180
+ ...itemProps,
181
+ ref: forwardedRef,
182
+ disabled: disabled,
183
+ pressed: pressed,
184
+ onPressedChange: handlePressedChange
185
+ });
186
+ return context.rovingFocus ? jsx(RovingFocusGroupItem, {
187
+ active: pressed,
188
+ asChild: true,
189
+ focusable: !disabled,
190
+ children: toggle
191
+ }) : toggle;
192
+ });
193
+ Item.displayName = 'ToggleGroupItem';
194
+
195
+ export { Item, Root, Toggle };
@@ -0,0 +1,32 @@
1
+ import * as ToggleGroupPrimitive from './toggle-group';
2
+ import { type Direction, type Orientation, type PrimitiveProps } from './types';
3
+ export interface ToolbarProps extends PrimitiveProps<'div'> {
4
+ orientation?: Orientation;
5
+ loop?: boolean;
6
+ dir?: Direction;
7
+ }
8
+ /**
9
+ * Toolbar with the Radix API, DOM and roving focus model: the toolbar is the tab stop, arrow keys move
10
+ * between items and loop, Home/PageUp and End/PageDown go to the first and last item.
11
+ */
12
+ export declare const Root: import("react").ForwardRefExoticComponent<ToolbarProps & import("react").RefAttributes<HTMLDivElement>>;
13
+ export interface ToolbarSeparatorProps extends PrimitiveProps<'div'> {
14
+ decorative?: boolean;
15
+ orientation?: Orientation;
16
+ }
17
+ export declare const Separator: import("react").ForwardRefExoticComponent<ToolbarSeparatorProps & import("react").RefAttributes<HTMLDivElement>>;
18
+ export type ToolbarButtonProps = PrimitiveProps<'button'>;
19
+ export declare const Button: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
20
+ asChild?: boolean;
21
+ } & import("react").RefAttributes<HTMLButtonElement>>;
22
+ export type ToolbarLinkProps = PrimitiveProps<'a'>;
23
+ export declare const Link: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "ref"> & {
24
+ asChild?: boolean;
25
+ } & import("react").RefAttributes<HTMLAnchorElement>>;
26
+ export type ToggleGroupProps = ToggleGroupPrimitive.ToggleGroupProps;
27
+ export type ToolbarToggleGroupSingleProps = ToggleGroupPrimitive.ToggleGroupSingleProps;
28
+ export type ToolbarToggleGroupMultipleProps = ToggleGroupPrimitive.ToggleGroupMultipleProps;
29
+ export type ToolbarToggleGroupProps = ToggleGroupProps;
30
+ export declare const ToggleGroup: import("react").ForwardRefExoticComponent<ToggleGroupPrimitive.ToggleGroupProps & import("react").RefAttributes<HTMLDivElement>>;
31
+ export type ToolbarToggleItemProps = ToggleGroupPrimitive.ToggleGroupItemProps;
32
+ export declare const ToggleItem: import("react").ForwardRefExoticComponent<ToggleGroupPrimitive.ToggleGroupItemProps & import("react").RefAttributes<HTMLButtonElement>>;