@cdx-ui/primitives 0.0.1-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (260) hide show
  1. package/README.md +17 -0
  2. package/lib/commonjs/button/context.js +11 -0
  3. package/lib/commonjs/button/context.js.map +1 -0
  4. package/lib/commonjs/button/createButtonGroup.js +80 -0
  5. package/lib/commonjs/button/createButtonGroup.js.map +1 -0
  6. package/lib/commonjs/button/createButtonIcon.js +18 -0
  7. package/lib/commonjs/button/createButtonIcon.js.map +1 -0
  8. package/lib/commonjs/button/createButtonRoot.js +81 -0
  9. package/lib/commonjs/button/createButtonRoot.js.map +1 -0
  10. package/lib/commonjs/button/createButtonSpinner.js +34 -0
  11. package/lib/commonjs/button/createButtonSpinner.js.map +1 -0
  12. package/lib/commonjs/button/createButtonText.js +38 -0
  13. package/lib/commonjs/button/createButtonText.js.map +1 -0
  14. package/lib/commonjs/button/index.js +31 -0
  15. package/lib/commonjs/button/index.js.map +1 -0
  16. package/lib/commonjs/button/types.js +6 -0
  17. package/lib/commonjs/button/types.js.map +1 -0
  18. package/lib/commonjs/index.js +52 -0
  19. package/lib/commonjs/index.js.map +1 -0
  20. package/lib/commonjs/input/context.js +11 -0
  21. package/lib/commonjs/input/context.js.map +1 -0
  22. package/lib/commonjs/input/createInputField.js +90 -0
  23. package/lib/commonjs/input/createInputField.js.map +1 -0
  24. package/lib/commonjs/input/createInputIcon.js +20 -0
  25. package/lib/commonjs/input/createInputIcon.js.map +1 -0
  26. package/lib/commonjs/input/createInputRoot.js +82 -0
  27. package/lib/commonjs/input/createInputRoot.js.map +1 -0
  28. package/lib/commonjs/input/createInputSlot.js +44 -0
  29. package/lib/commonjs/input/createInputSlot.js.map +1 -0
  30. package/lib/commonjs/input/index.js +28 -0
  31. package/lib/commonjs/input/index.js.map +1 -0
  32. package/lib/commonjs/input/types.js +6 -0
  33. package/lib/commonjs/input/types.js.map +1 -0
  34. package/lib/commonjs/overlay/OverlayContainer.js +67 -0
  35. package/lib/commonjs/overlay/OverlayContainer.js.map +1 -0
  36. package/lib/commonjs/overlay/index.js +40 -0
  37. package/lib/commonjs/overlay/index.js.map +1 -0
  38. package/lib/commonjs/overlay/useAnchorPosition.js +68 -0
  39. package/lib/commonjs/overlay/useAnchorPosition.js.map +1 -0
  40. package/lib/commonjs/overlay/useDismissOverlay.js +14 -0
  41. package/lib/commonjs/overlay/useDismissOverlay.js.map +1 -0
  42. package/lib/commonjs/overlay/useDismissOverlay.web.js +46 -0
  43. package/lib/commonjs/overlay/useDismissOverlay.web.js.map +1 -0
  44. package/lib/commonjs/overlay/useOverlayPosition.js +93 -0
  45. package/lib/commonjs/overlay/useOverlayPosition.js.map +1 -0
  46. package/lib/commonjs/package.json +1 -0
  47. package/lib/commonjs/select/context.js +63 -0
  48. package/lib/commonjs/select/context.js.map +1 -0
  49. package/lib/commonjs/select/createSelectContent.js +102 -0
  50. package/lib/commonjs/select/createSelectContent.js.map +1 -0
  51. package/lib/commonjs/select/createSelectIcon.js +41 -0
  52. package/lib/commonjs/select/createSelectIcon.js.map +1 -0
  53. package/lib/commonjs/select/createSelectItem.js +101 -0
  54. package/lib/commonjs/select/createSelectItem.js.map +1 -0
  55. package/lib/commonjs/select/createSelectItemLabel.js +41 -0
  56. package/lib/commonjs/select/createSelectItemLabel.js.map +1 -0
  57. package/lib/commonjs/select/createSelectRoot.js +99 -0
  58. package/lib/commonjs/select/createSelectRoot.js.map +1 -0
  59. package/lib/commonjs/select/createSelectTrigger.js +138 -0
  60. package/lib/commonjs/select/createSelectTrigger.js.map +1 -0
  61. package/lib/commonjs/select/createSelectValue.js +53 -0
  62. package/lib/commonjs/select/createSelectValue.js.map +1 -0
  63. package/lib/commonjs/select/index.js +38 -0
  64. package/lib/commonjs/select/index.js.map +1 -0
  65. package/lib/commonjs/select/types.js +6 -0
  66. package/lib/commonjs/select/types.js.map +1 -0
  67. package/lib/commonjs/select/useContentFocus.js +47 -0
  68. package/lib/commonjs/select/useContentFocus.js.map +1 -0
  69. package/lib/commonjs/select/useListboxNavigation.js +83 -0
  70. package/lib/commonjs/select/useListboxNavigation.js.map +1 -0
  71. package/lib/commonjs/uniwind.d.js +2 -0
  72. package/lib/commonjs/uniwind.d.js.map +1 -0
  73. package/lib/commonjs/utils/dataAttributes.js +32 -0
  74. package/lib/commonjs/utils/dataAttributes.js.map +1 -0
  75. package/lib/commonjs/utils/dataAttributes.web.js +31 -0
  76. package/lib/commonjs/utils/dataAttributes.web.js.map +1 -0
  77. package/lib/module/button/context.js +5 -0
  78. package/lib/module/button/context.js.map +1 -0
  79. package/lib/module/button/createButtonGroup.js +74 -0
  80. package/lib/module/button/createButtonGroup.js.map +1 -0
  81. package/lib/module/button/createButtonIcon.js +13 -0
  82. package/lib/module/button/createButtonIcon.js.map +1 -0
  83. package/lib/module/button/createButtonRoot.js +76 -0
  84. package/lib/module/button/createButtonRoot.js.map +1 -0
  85. package/lib/module/button/createButtonSpinner.js +29 -0
  86. package/lib/module/button/createButtonSpinner.js.map +1 -0
  87. package/lib/module/button/createButtonText.js +33 -0
  88. package/lib/module/button/createButtonText.js.map +1 -0
  89. package/lib/module/button/index.js +27 -0
  90. package/lib/module/button/index.js.map +1 -0
  91. package/lib/module/button/types.js +4 -0
  92. package/lib/module/button/types.js.map +1 -0
  93. package/lib/module/index.js +7 -0
  94. package/lib/module/index.js.map +1 -0
  95. package/lib/module/input/context.js +5 -0
  96. package/lib/module/input/context.js.map +1 -0
  97. package/lib/module/input/createInputField.js +85 -0
  98. package/lib/module/input/createInputField.js.map +1 -0
  99. package/lib/module/input/createInputIcon.js +15 -0
  100. package/lib/module/input/createInputIcon.js.map +1 -0
  101. package/lib/module/input/createInputRoot.js +76 -0
  102. package/lib/module/input/createInputRoot.js.map +1 -0
  103. package/lib/module/input/createInputSlot.js +39 -0
  104. package/lib/module/input/createInputSlot.js.map +1 -0
  105. package/lib/module/input/index.js +23 -0
  106. package/lib/module/input/index.js.map +1 -0
  107. package/lib/module/input/types.js +4 -0
  108. package/lib/module/input/types.js.map +1 -0
  109. package/lib/module/overlay/OverlayContainer.js +62 -0
  110. package/lib/module/overlay/OverlayContainer.js.map +1 -0
  111. package/lib/module/overlay/index.js +7 -0
  112. package/lib/module/overlay/index.js.map +1 -0
  113. package/lib/module/overlay/useAnchorPosition.js +64 -0
  114. package/lib/module/overlay/useAnchorPosition.js.map +1 -0
  115. package/lib/module/overlay/useDismissOverlay.js +10 -0
  116. package/lib/module/overlay/useDismissOverlay.js.map +1 -0
  117. package/lib/module/overlay/useDismissOverlay.web.js +43 -0
  118. package/lib/module/overlay/useDismissOverlay.web.js.map +1 -0
  119. package/lib/module/overlay/useOverlayPosition.js +88 -0
  120. package/lib/module/overlay/useOverlayPosition.js.map +1 -0
  121. package/lib/module/select/context.js +56 -0
  122. package/lib/module/select/context.js.map +1 -0
  123. package/lib/module/select/createSelectContent.js +97 -0
  124. package/lib/module/select/createSelectContent.js.map +1 -0
  125. package/lib/module/select/createSelectIcon.js +36 -0
  126. package/lib/module/select/createSelectIcon.js.map +1 -0
  127. package/lib/module/select/createSelectItem.js +96 -0
  128. package/lib/module/select/createSelectItem.js.map +1 -0
  129. package/lib/module/select/createSelectItemLabel.js +36 -0
  130. package/lib/module/select/createSelectItemLabel.js.map +1 -0
  131. package/lib/module/select/createSelectRoot.js +94 -0
  132. package/lib/module/select/createSelectRoot.js.map +1 -0
  133. package/lib/module/select/createSelectTrigger.js +133 -0
  134. package/lib/module/select/createSelectTrigger.js.map +1 -0
  135. package/lib/module/select/createSelectValue.js +48 -0
  136. package/lib/module/select/createSelectValue.js.map +1 -0
  137. package/lib/module/select/index.js +34 -0
  138. package/lib/module/select/index.js.map +1 -0
  139. package/lib/module/select/types.js +4 -0
  140. package/lib/module/select/types.js.map +1 -0
  141. package/lib/module/select/useContentFocus.js +44 -0
  142. package/lib/module/select/useContentFocus.js.map +1 -0
  143. package/lib/module/select/useListboxNavigation.js +80 -0
  144. package/lib/module/select/useListboxNavigation.js.map +1 -0
  145. package/lib/module/uniwind.d.js +2 -0
  146. package/lib/module/uniwind.d.js.map +1 -0
  147. package/lib/module/utils/dataAttributes.js +28 -0
  148. package/lib/module/utils/dataAttributes.js.map +1 -0
  149. package/lib/module/utils/dataAttributes.web.js +27 -0
  150. package/lib/module/utils/dataAttributes.web.js.map +1 -0
  151. package/lib/typescript/button/context.d.ts +6 -0
  152. package/lib/typescript/button/context.d.ts.map +1 -0
  153. package/lib/typescript/button/createButtonGroup.d.ts +4 -0
  154. package/lib/typescript/button/createButtonGroup.d.ts.map +1 -0
  155. package/lib/typescript/button/createButtonIcon.d.ts +2 -0
  156. package/lib/typescript/button/createButtonIcon.d.ts.map +1 -0
  157. package/lib/typescript/button/createButtonRoot.d.ts +6 -0
  158. package/lib/typescript/button/createButtonRoot.d.ts.map +1 -0
  159. package/lib/typescript/button/createButtonSpinner.d.ts +4 -0
  160. package/lib/typescript/button/createButtonSpinner.d.ts.map +1 -0
  161. package/lib/typescript/button/createButtonText.d.ts +4 -0
  162. package/lib/typescript/button/createButtonText.d.ts.map +1 -0
  163. package/lib/typescript/button/index.d.ts +11 -0
  164. package/lib/typescript/button/index.d.ts.map +1 -0
  165. package/lib/typescript/button/types.d.ts +65 -0
  166. package/lib/typescript/button/types.d.ts.map +1 -0
  167. package/lib/typescript/index.d.ts +5 -0
  168. package/lib/typescript/index.d.ts.map +1 -0
  169. package/lib/typescript/input/context.d.ts +6 -0
  170. package/lib/typescript/input/context.d.ts.map +1 -0
  171. package/lib/typescript/input/createInputField.d.ts +4 -0
  172. package/lib/typescript/input/createInputField.d.ts.map +1 -0
  173. package/lib/typescript/input/createInputIcon.d.ts +4 -0
  174. package/lib/typescript/input/createInputIcon.d.ts.map +1 -0
  175. package/lib/typescript/input/createInputRoot.d.ts +4 -0
  176. package/lib/typescript/input/createInputRoot.d.ts.map +1 -0
  177. package/lib/typescript/input/createInputSlot.d.ts +4 -0
  178. package/lib/typescript/input/createInputSlot.d.ts.map +1 -0
  179. package/lib/typescript/input/index.d.ts +9 -0
  180. package/lib/typescript/input/index.d.ts.map +1 -0
  181. package/lib/typescript/input/types.d.ts +91 -0
  182. package/lib/typescript/input/types.d.ts.map +1 -0
  183. package/lib/typescript/overlay/OverlayContainer.d.ts +23 -0
  184. package/lib/typescript/overlay/OverlayContainer.d.ts.map +1 -0
  185. package/lib/typescript/overlay/index.d.ts +6 -0
  186. package/lib/typescript/overlay/index.d.ts.map +1 -0
  187. package/lib/typescript/overlay/useAnchorPosition.d.ts +15 -0
  188. package/lib/typescript/overlay/useAnchorPosition.d.ts.map +1 -0
  189. package/lib/typescript/overlay/useDismissOverlay.d.ts +7 -0
  190. package/lib/typescript/overlay/useDismissOverlay.d.ts.map +1 -0
  191. package/lib/typescript/overlay/useDismissOverlay.web.d.ts +8 -0
  192. package/lib/typescript/overlay/useDismissOverlay.web.d.ts.map +1 -0
  193. package/lib/typescript/overlay/useOverlayPosition.d.ts +45 -0
  194. package/lib/typescript/overlay/useOverlayPosition.d.ts.map +1 -0
  195. package/lib/typescript/select/context.d.ts +17 -0
  196. package/lib/typescript/select/context.d.ts.map +1 -0
  197. package/lib/typescript/select/createSelectContent.d.ts +4 -0
  198. package/lib/typescript/select/createSelectContent.d.ts.map +1 -0
  199. package/lib/typescript/select/createSelectIcon.d.ts +2 -0
  200. package/lib/typescript/select/createSelectIcon.d.ts.map +1 -0
  201. package/lib/typescript/select/createSelectItem.d.ts +6 -0
  202. package/lib/typescript/select/createSelectItem.d.ts.map +1 -0
  203. package/lib/typescript/select/createSelectItemLabel.d.ts +4 -0
  204. package/lib/typescript/select/createSelectItemLabel.d.ts.map +1 -0
  205. package/lib/typescript/select/createSelectRoot.d.ts +4 -0
  206. package/lib/typescript/select/createSelectRoot.d.ts.map +1 -0
  207. package/lib/typescript/select/createSelectTrigger.d.ts +12 -0
  208. package/lib/typescript/select/createSelectTrigger.d.ts.map +1 -0
  209. package/lib/typescript/select/createSelectValue.d.ts +4 -0
  210. package/lib/typescript/select/createSelectValue.d.ts.map +1 -0
  211. package/lib/typescript/select/index.d.ts +13 -0
  212. package/lib/typescript/select/index.d.ts.map +1 -0
  213. package/lib/typescript/select/types.d.ts +96 -0
  214. package/lib/typescript/select/types.d.ts.map +1 -0
  215. package/lib/typescript/select/useContentFocus.d.ts +19 -0
  216. package/lib/typescript/select/useContentFocus.d.ts.map +1 -0
  217. package/lib/typescript/select/useListboxNavigation.d.ts +13 -0
  218. package/lib/typescript/select/useListboxNavigation.d.ts.map +1 -0
  219. package/lib/typescript/utils/dataAttributes.d.ts +14 -0
  220. package/lib/typescript/utils/dataAttributes.d.ts.map +1 -0
  221. package/lib/typescript/utils/dataAttributes.web.d.ts +16 -0
  222. package/lib/typescript/utils/dataAttributes.web.d.ts.map +1 -0
  223. package/package.json +78 -0
  224. package/src/button/context.tsx +4 -0
  225. package/src/button/createButtonGroup.tsx +88 -0
  226. package/src/button/createButtonIcon.tsx +8 -0
  227. package/src/button/createButtonRoot.tsx +101 -0
  228. package/src/button/createButtonSpinner.tsx +20 -0
  229. package/src/button/createButtonText.tsx +22 -0
  230. package/src/button/index.tsx +53 -0
  231. package/src/button/types.ts +85 -0
  232. package/src/index.ts +4 -0
  233. package/src/input/context.tsx +4 -0
  234. package/src/input/createInputField.tsx +104 -0
  235. package/src/input/createInputIcon.tsx +12 -0
  236. package/src/input/createInputRoot.tsx +92 -0
  237. package/src/input/createInputSlot.tsx +39 -0
  238. package/src/input/index.tsx +51 -0
  239. package/src/input/types.ts +113 -0
  240. package/src/overlay/OverlayContainer.tsx +77 -0
  241. package/src/overlay/index.ts +10 -0
  242. package/src/overlay/useAnchorPosition.ts +72 -0
  243. package/src/overlay/useDismissOverlay.ts +14 -0
  244. package/src/overlay/useDismissOverlay.web.ts +51 -0
  245. package/src/overlay/useOverlayPosition.ts +96 -0
  246. package/src/select/context.tsx +56 -0
  247. package/src/select/createSelectContent.tsx +115 -0
  248. package/src/select/createSelectIcon.tsx +27 -0
  249. package/src/select/createSelectItem.tsx +121 -0
  250. package/src/select/createSelectItemLabel.tsx +30 -0
  251. package/src/select/createSelectRoot.tsx +130 -0
  252. package/src/select/createSelectTrigger.tsx +192 -0
  253. package/src/select/createSelectValue.tsx +38 -0
  254. package/src/select/index.tsx +73 -0
  255. package/src/select/types.ts +131 -0
  256. package/src/select/useContentFocus.ts +54 -0
  257. package/src/select/useListboxNavigation.ts +85 -0
  258. package/src/uniwind.d.ts +3 -0
  259. package/src/utils/dataAttributes.ts +28 -0
  260. package/src/utils/dataAttributes.web.ts +26 -0
@@ -0,0 +1,45 @@
1
+ import { type ViewStyle } from 'react-native';
2
+ import type { AnchorLayout } from './useAnchorPosition';
3
+ export interface EdgeInsets {
4
+ top: number;
5
+ right: number;
6
+ bottom: number;
7
+ left: number;
8
+ }
9
+ /**
10
+ * Provides safe-area insets to overlay positioning hooks. Wrap your app
11
+ * root with this provider and pass values from `useSafeAreaInsets()` to
12
+ * enable safe-area-aware overlay placement.
13
+ *
14
+ * @example
15
+ * ```tsx
16
+ * import { useSafeAreaInsets } from 'react-native-safe-area-context';
17
+ * import { OverlayInsetsProvider } from '@cdx-ui/primitives';
18
+ *
19
+ * function App() {
20
+ * const insets = useSafeAreaInsets();
21
+ * return (
22
+ * <OverlayInsetsProvider value={insets}>
23
+ * {children}
24
+ * </OverlayInsetsProvider>
25
+ * );
26
+ * }
27
+ * ```
28
+ */
29
+ export declare const OverlayInsetsContext: import("react").Context<EdgeInsets>;
30
+ export declare const OverlayInsetsProvider: import("react").Provider<EdgeInsets>;
31
+ export interface OverlayPosition {
32
+ style: ViewStyle;
33
+ maxHeight: number;
34
+ placement: 'top' | 'bottom';
35
+ }
36
+ /**
37
+ * Computes viewport-aware overlay positioning relative to an anchor element.
38
+ * Automatically flips placement from bottom to top when insufficient space
39
+ * exists below the anchor. Constrains `maxHeight` to available space so
40
+ * content never extends beyond the screen edge.
41
+ *
42
+ * Respects safe-area insets provided via `OverlayInsetsProvider`.
43
+ */
44
+ export declare function useOverlayPosition(anchorLayout: AnchorLayout | null): OverlayPosition | null;
45
+ //# sourceMappingURL=useOverlayPosition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOverlayPosition.d.ts","sourceRoot":"","sources":["../../../src/overlay/useOverlayPosition.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAID;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,oBAAoB,qCAA4C,CAAC;AAC9E,eAAO,MAAM,qBAAqB,sCAAgC,CAAC;AAQnE,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,SAAS,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,KAAK,GAAG,QAAQ,CAAC;CAC7B;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI,GAAG,eAAe,GAAG,IAAI,CAuC5F"}
@@ -0,0 +1,17 @@
1
+ import type { InteractionState, SelectContextValue, SelectItemInteractionState } from './types';
2
+ export declare const SelectContext: import("react").Context<SelectContextValue>;
3
+ export declare const useSelectContext: () => SelectContextValue;
4
+ /**
5
+ * Propagates the trigger's interaction state (hover, focus, active, etc.) to
6
+ * child components like SelectValue and SelectIcon so they can apply matching
7
+ * data-attribute styles.
8
+ */
9
+ export declare const SelectTriggerContext: import("react").Context<InteractionState>;
10
+ export declare const useSelectTriggerContext: () => InteractionState;
11
+ /**
12
+ * Propagates the item's interaction and selection state (hover, focus, active,
13
+ * highlighted, checked, etc.) to child components like SelectItemLabel.
14
+ */
15
+ export declare const SelectItemContext: import("react").Context<SelectItemInteractionState>;
16
+ export declare const useSelectItemContext: () => SelectItemInteractionState;
17
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/select/context.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAqBhG,eAAO,MAAM,aAAa,6CAAyD,CAAC;AAEpF,eAAO,MAAM,gBAAgB,0BAAkC,CAAC;AAEhE;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,2CAM/B,CAAC;AAEH,eAAO,MAAM,uBAAuB,wBAAyC,CAAC;AAE9E;;;GAGG;AACH,eAAO,MAAM,iBAAiB,qDAQ5B,CAAC;AAEH,eAAO,MAAM,oBAAoB,kCAAsC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type React from 'react';
2
+ import type { ISelectContentProps } from './types';
3
+ export declare const createSelectContent: <T>(BaseContent: React.ComponentType<T>) => React.ForwardRefExoticComponent<ISelectContentProps & React.RefAttributes<unknown>>;
4
+ //# sourceMappingURL=createSelectContent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createSelectContent.d.ts","sourceRoot":"","sources":["../../../src/select/createSelectContent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAa/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAInD,eAAO,MAAM,mBAAmB,GAAI,CAAC,EAAG,aAAa,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,wFAiGxE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const createSelectIcon: <T>(BaseIcon: React.ComponentType<T>) => import("react").ForwardRefExoticComponent<Omit<any, "ref"> & import("react").RefAttributes<unknown>>;
2
+ //# sourceMappingURL=createSelectIcon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createSelectIcon.d.ts","sourceRoot":"","sources":["../../../src/select/createSelectIcon.tsx"],"names":[],"mappings":"AAIA,eAAO,MAAM,gBAAgB,GAAI,CAAC,EAAG,UAAU,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,yGAsBjE,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type React from 'react';
2
+ import type { ISelectItemProps } from './types';
3
+ export declare const createSelectItem: <T>(BaseItem: React.ComponentType<T>) => React.ForwardRefExoticComponent<Omit<ISelectItemProps, "children"> & {
4
+ children?: React.ReactNode;
5
+ } & React.RefAttributes<unknown>>;
6
+ //# sourceMappingURL=createSelectItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createSelectItem.d.ts","sourceRoot":"","sources":["../../../src/select/createSelectItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,eAAO,MAAM,gBAAgB,GAAI,CAAC,EAAG,UAAU,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;eAaV,KAAK,CAAC,SAAS;iCAkGvE,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type React from 'react';
2
+ import type { ISelectItemLabelProps } from './types';
3
+ export declare const createSelectItemLabel: <T>(BaseItemLabel: React.ComponentType<T>) => React.ForwardRefExoticComponent<ISelectItemLabelProps & React.RefAttributes<unknown>>;
4
+ //# sourceMappingURL=createSelectItemLabel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createSelectItemLabel.d.ts","sourceRoot":"","sources":["../../../src/select/createSelectItemLabel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAErD,eAAO,MAAM,qBAAqB,GAAI,CAAC,EAAG,eAAe,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,0FAuB3E,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type React from 'react';
2
+ import type { ISelectProps } from './types';
3
+ export declare const createSelectRoot: <T>(BaseRoot: React.ComponentType<T>) => React.ForwardRefExoticComponent<ISelectProps & React.RefAttributes<unknown>>;
4
+ //# sourceMappingURL=createSelectRoot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createSelectRoot.d.ts","sourceRoot":"","sources":["../../../src/select/createSelectRoot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,eAAO,MAAM,gBAAgB,GAAI,CAAC,EAAG,UAAU,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,iFA0HlE,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type React from 'react';
2
+ import type { ISelectTriggerProps } from './types';
3
+ export declare const createSelectTrigger: <T>(BaseTrigger: React.ComponentType<T>) => React.ForwardRefExoticComponent<Omit<ISelectTriggerProps, "children"> & {
4
+ children?: (({ hovered, pressed, focused, focusVisible, disabled, }: {
5
+ hovered?: boolean;
6
+ pressed?: boolean;
7
+ focused?: boolean;
8
+ focusVisible?: boolean;
9
+ disabled?: boolean;
10
+ }) => React.ReactNode) | React.ReactNode;
11
+ } & React.RefAttributes<unknown>>;
12
+ //# sourceMappingURL=createSelectTrigger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createSelectTrigger.d.ts","sourceRoot":"","sources":["../../../src/select/createSelectTrigger.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAQ/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnD,eAAO,MAAM,mBAAmB,GAAI,CAAC,EAAG,aAAa,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;eAa/D,CAAC,CAAC,EACA,OAAO,EACP,OAAO,EACP,OAAO,EACP,YAAY,EACZ,QAAQ,GACT,EAAE;QACD,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB,KAAK,KAAK,CAAC,SAAS,CAAC,GACtB,KAAK,CAAC,SAAS;iCA2JxB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type React from 'react';
2
+ import type { ISelectValueProps } from './types';
3
+ export declare const createSelectValue: <T>(BaseValue: React.ComponentType<T>) => React.ForwardRefExoticComponent<ISelectValueProps & React.RefAttributes<unknown>>;
4
+ //# sourceMappingURL=createSelectValue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createSelectValue.d.ts","sourceRoot":"","sources":["../../../src/select/createSelectValue.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAIjD,eAAO,MAAM,iBAAiB,GAAI,CAAC,EAAG,WAAW,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,sFA6BnE,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type React from 'react';
2
+ import type { ISelectComponentType } from './types';
3
+ export type { ISelectContentProps, ISelectItemLabelProps, ISelectItemProps, ISelectProps, ISelectTriggerProps, ISelectValueProps, } from './types';
4
+ export declare function createSelect<RootProps, TriggerProps, ValueProps, IconProps, ContentProps, ItemProps, ItemLabelProps, TriggerRef = unknown, ValueRef = unknown>(BaseComponents: {
5
+ Root: React.ComponentType<RootProps>;
6
+ Trigger: React.ComponentType<TriggerProps>;
7
+ Value: React.ComponentType<ValueProps>;
8
+ Icon: React.ComponentType<IconProps>;
9
+ Content: React.ComponentType<ContentProps>;
10
+ Item: React.ComponentType<ItemProps>;
11
+ ItemLabel: React.ComponentType<ItemLabelProps>;
12
+ }): ISelectComponentType<RootProps, TriggerProps, ValueProps, IconProps, ContentProps, ItemProps, ItemLabelProps, TriggerRef, ValueRef>;
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/select/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAQ/B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD,YAAY,EACV,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,SAAS,CAAC;AAEjB,wBAAgB,YAAY,CAC1B,SAAS,EACT,YAAY,EACZ,UAAU,EACV,SAAS,EACT,YAAY,EACZ,SAAS,EACT,cAAc,EACd,UAAU,GAAG,OAAO,EACpB,QAAQ,GAAG,OAAO,EAClB,cAAc,EAAE;IAChB,IAAI,EAAE,KAAK,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IACrC,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;IAC3C,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IACvC,IAAI,EAAE,KAAK,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IACrC,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;IAC3C,IAAI,EAAE,KAAK,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IACrC,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;CAChD,GAwBO,oBAAoB,CACxB,SAAS,EACT,YAAY,EACZ,UAAU,EACV,SAAS,EACT,YAAY,EACZ,SAAS,EACT,cAAc,EACd,UAAU,EACV,QAAQ,CACT,CACF"}
@@ -0,0 +1,96 @@
1
+ import type { PropsWithoutRef, ReactNode, RefAttributes, RefObject } from 'react';
2
+ import type { PressableProps, ViewProps } from 'react-native';
3
+ import type { EntryOrExitLayoutType } from 'react-native-reanimated';
4
+ export interface InteractionState {
5
+ hover: boolean;
6
+ focus: boolean;
7
+ active: boolean;
8
+ disabled: boolean;
9
+ focusVisible: boolean;
10
+ }
11
+ export interface SelectItemInteractionState extends InteractionState {
12
+ highlighted: boolean;
13
+ checked: boolean;
14
+ }
15
+ export interface ISelectProps {
16
+ items: SelectItemData[];
17
+ value?: string;
18
+ defaultValue?: string;
19
+ onValueChange?: (value: string) => void;
20
+ open?: boolean;
21
+ defaultOpen?: boolean;
22
+ onOpenChange?: (open: boolean) => void;
23
+ disabled?: boolean;
24
+ isRequired?: boolean;
25
+ isInvalid?: boolean;
26
+ isReadOnly?: boolean;
27
+ native?: boolean;
28
+ accessibilityLabel?: string;
29
+ children?: ReactNode;
30
+ }
31
+ export interface ISelectTriggerProps extends PressableProps {
32
+ isHovered?: boolean;
33
+ isActive?: boolean;
34
+ isFocused?: boolean;
35
+ isFocusVisible?: boolean;
36
+ isDisabled?: boolean;
37
+ }
38
+ export interface ISelectValueProps {
39
+ placeholder?: string;
40
+ children?: ReactNode;
41
+ }
42
+ export interface ISelectContentProps extends ViewProps {
43
+ enteringAnimation?: EntryOrExitLayoutType;
44
+ exitingAnimation?: EntryOrExitLayoutType;
45
+ children?: ReactNode;
46
+ }
47
+ export interface ISelectItemProps extends PressableProps {
48
+ value: string;
49
+ disabled?: boolean;
50
+ isHovered?: boolean;
51
+ isActive?: boolean;
52
+ isFocused?: boolean;
53
+ isFocusVisible?: boolean;
54
+ isDisabled?: boolean;
55
+ }
56
+ export interface ISelectItemLabelProps {
57
+ children?: ReactNode;
58
+ }
59
+ export interface SelectItemData {
60
+ value: string;
61
+ label: string;
62
+ disabled?: boolean;
63
+ }
64
+ export interface SelectItemCollectionContextValue {
65
+ registerItem: (item: SelectItemData) => void;
66
+ unregisterItem: (value: string) => void;
67
+ getItems: () => SelectItemData[];
68
+ }
69
+ export interface SelectContextValue {
70
+ open: boolean;
71
+ items: SelectItemData[];
72
+ setOpen: (open: boolean) => void;
73
+ value: string | undefined;
74
+ onValueChange: (value: string) => void;
75
+ disabled: boolean;
76
+ required: boolean;
77
+ invalid: boolean;
78
+ readOnly: boolean;
79
+ native: boolean;
80
+ triggerRef: RefObject<any>;
81
+ contentId: string;
82
+ triggerId: string;
83
+ /** Currently highlighted value during keyboard navigation */
84
+ activeValue: string | undefined;
85
+ setActiveValue: (value: string | undefined) => void;
86
+ accessibilityLabel: string | undefined;
87
+ }
88
+ export type ISelectComponentType<RootProps, TriggerProps, ValueProps, IconProps, ContentProps, ItemProps, ItemLabelProps, TriggerRef = unknown, ValueRef = unknown> = React.ForwardRefExoticComponent<PropsWithoutRef<RootProps & ISelectProps> & RefAttributes<unknown>> & {
89
+ Trigger: React.ForwardRefExoticComponent<PropsWithoutRef<TriggerProps & ISelectTriggerProps> & RefAttributes<TriggerRef>>;
90
+ Value: React.ForwardRefExoticComponent<PropsWithoutRef<ValueProps & ISelectValueProps> & RefAttributes<ValueRef>>;
91
+ Icon: React.ForwardRefExoticComponent<PropsWithoutRef<IconProps> & RefAttributes<unknown>>;
92
+ Content: React.ForwardRefExoticComponent<PropsWithoutRef<ContentProps & ISelectContentProps> & RefAttributes<unknown>>;
93
+ Item: React.ForwardRefExoticComponent<PropsWithoutRef<ItemProps & ISelectItemProps> & RefAttributes<unknown>>;
94
+ ItemLabel: React.ForwardRefExoticComponent<PropsWithoutRef<ItemLabelProps & ISelectItemLabelProps> & RefAttributes<unknown>>;
95
+ };
96
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/select/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClF,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,KAAK,EAAE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KAAK,CAAC,yBAAyB,CACxC,eAAe,CAAC,cAAc,GAAG,qBAAqB,CAAC,GAAG,aAAa,CAAC,OAAO,CAAC,CACjF,CAAC;CACH,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { RefObject } from 'react';
2
+ import type { SelectItemData } from './types';
3
+ export interface UseContentFocusOptions {
4
+ open: boolean;
5
+ triggerRef: RefObject<any>;
6
+ items: SelectItemData[];
7
+ value: string | undefined;
8
+ setActiveValue: (value: string | undefined) => void;
9
+ }
10
+ /**
11
+ * Manages focus lifecycle for overlay content:
12
+ * - Restores focus to the trigger when the overlay closes (web)
13
+ * - Initializes `activeValue` to the current value or first enabled item
14
+ *
15
+ * Initial focus on open is handled via a ref callback in createSelectContent
16
+ * to avoid timing issues with deferred portal rendering.
17
+ */
18
+ export declare function useContentFocus({ open, triggerRef, items, value, setActiveValue, }: UseContentFocusOptions): void;
19
+ //# sourceMappingURL=useContentFocus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useContentFocus.d.ts","sourceRoot":"","sources":["../../../src/select/useContentFocus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAI9C,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,OAAO,CAAC;IACd,UAAU,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC;IAC3B,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;CACrD;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,EAC9B,IAAI,EACJ,UAAU,EACV,KAAK,EACL,KAAK,EACL,cAAc,GACf,EAAE,sBAAsB,QAwBxB"}
@@ -0,0 +1,13 @@
1
+ import type { SelectItemData } from './types';
2
+ export interface UseListboxNavigationOptions {
3
+ items: SelectItemData[];
4
+ activeValue: string | undefined;
5
+ setActiveValue: (value: string | undefined) => void;
6
+ onSelect: (value: string) => void;
7
+ onDismiss: () => void;
8
+ }
9
+ export declare function useListboxNavigation({ items, activeValue, setActiveValue, onSelect, onDismiss, }: UseListboxNavigationOptions): {
10
+ handleKeyDown: (e: any) => void;
11
+ getEnabledItems: () => SelectItemData[];
12
+ };
13
+ //# sourceMappingURL=useListboxNavigation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useListboxNavigation.d.ts","sourceRoot":"","sources":["../../../src/select/useListboxNavigation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAI9C,MAAM,WAAW,2BAA2B;IAC1C,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IACpD,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,SAAS,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,wBAAgB,oBAAoB,CAAC,EACnC,KAAK,EACL,WAAW,EACX,cAAc,EACd,QAAQ,EACR,SAAS,GACV,EAAE,2BAA2B;uBAUtB,GAAG;;EAuDV"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Produces platform-specific props for data attributes.
3
+ *
4
+ * Native: individual `data-*` props consumed by Uniwind.
5
+ * Web (.web.ts): a `dataSet` object consumed by React Native Web.
6
+ *
7
+ * Boolean values serialize to `"true"` / `"false"` strings.
8
+ * String values pass through as-is.
9
+ * Undefined values are omitted.
10
+ */
11
+ type DataAttributeValue = boolean | string | undefined;
12
+ export declare function dataAttributes(attrs: Record<string, DataAttributeValue>): Record<string, string>;
13
+ export {};
14
+ //# sourceMappingURL=dataAttributes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dataAttributes.d.ts","sourceRoot":"","sources":["../../../src/utils/dataAttributes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,KAAK,kBAAkB,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;AAMvD,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAUhG"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Produces platform-specific props for data attributes.
3
+ *
4
+ * Web: a `dataSet` object consumed by React Native Web, which translates
5
+ * camelCase keys to `data-kebab-case` DOM attributes automatically.
6
+ * Native (.ts): individual `data-*` props consumed by Uniwind.
7
+ *
8
+ * Values pass through to `dataSet` as-is (RNW handles serialization).
9
+ * Undefined values are omitted.
10
+ */
11
+ type DataAttributeValue = boolean | string | undefined;
12
+ export declare function dataAttributes(attrs: Record<string, DataAttributeValue>): {
13
+ dataSet: Record<string, boolean | string>;
14
+ };
15
+ export {};
16
+ //# sourceMappingURL=dataAttributes.web.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dataAttributes.web.d.ts","sourceRoot":"","sources":["../../../src/utils/dataAttributes.web.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,KAAK,kBAAkB,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;AAEvD,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,GAAG;IACzE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,CAAC;CAC3C,CAUA"}
package/package.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "@cdx-ui/primitives",
3
+ "version": "0.0.1-alpha.1",
4
+ "main": "lib/commonjs/index.js",
5
+ "module": "lib/module/index.js",
6
+ "react-native": "src/index.ts",
7
+ "types": "lib/typescript/index.d.ts",
8
+ "source": "src/index.ts",
9
+ "exports": {
10
+ ".": {
11
+ "react-native": "./src/index.ts",
12
+ "source": "./src/index.ts",
13
+ "types": "./lib/typescript/index.d.ts",
14
+ "import": "./lib/module/index.js",
15
+ "require": "./lib/commonjs/index.js",
16
+ "default": "./lib/module/index.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "lib",
21
+ "src"
22
+ ],
23
+ "react-native-builder-bob": {
24
+ "source": "src",
25
+ "output": "lib",
26
+ "targets": [
27
+ "commonjs",
28
+ "module",
29
+ "typescript"
30
+ ]
31
+ },
32
+ "peerDependencies": {
33
+ "react": ">=18.0.0",
34
+ "react-native": ">=0.74.0",
35
+ "react-native-web": ">=0.19.0",
36
+ "react-dom": ">=18.0.0"
37
+ },
38
+ "peerDependenciesMeta": {
39
+ "react-native": {
40
+ "optional": true
41
+ },
42
+ "react-native-web": {
43
+ "optional": true
44
+ },
45
+ "react-dom": {
46
+ "optional": true
47
+ }
48
+ },
49
+ "dependencies": {
50
+ "@react-native-aria/focus": "^0.2.9",
51
+ "@react-native-aria/interactions": "^0.2.16",
52
+ "@cdx-ui/utils": "0.0.1-alpha.1"
53
+ },
54
+ "devDependencies": {
55
+ "@types/react": "*",
56
+ "@types/react-dom": "*",
57
+ "react": "*",
58
+ "react-dom": "*",
59
+ "react-native": "*",
60
+ "react-native-builder-bob": "*",
61
+ "react-native-web": "*",
62
+ "typescript": "*"
63
+ },
64
+ "nx": {
65
+ "tags": [
66
+ "type:lib",
67
+ "scope:primitives"
68
+ ]
69
+ },
70
+ "sideEffects": false,
71
+ "publishConfig": {
72
+ "access": "public"
73
+ },
74
+ "scripts": {
75
+ "build": "bob build",
76
+ "lint": "eslint src/"
77
+ }
78
+ }
@@ -0,0 +1,4 @@
1
+ import { createContext } from '@cdx-ui/utils';
2
+ import type { InteractionState } from './types';
3
+
4
+ export const [ButtonProvider, useButtonContext] = createContext<InteractionState>('ButtonContext');
@@ -0,0 +1,88 @@
1
+ import React, { forwardRef } from 'react';
2
+ import { flattenChildren } from '@cdx-ui/utils';
3
+ import type { IButtonGroupProps } from './types';
4
+
5
+ export const createButtonGroup = <T,>(BaseButtonGroup: React.ComponentType<T>) =>
6
+ forwardRef(
7
+ (
8
+ {
9
+ flexDirection = 'row',
10
+ isAttached,
11
+ isDisabled,
12
+ children,
13
+ isReversed,
14
+ reversed,
15
+ ...props
16
+ }: IButtonGroupProps,
17
+ ref?: React.Ref<T>,
18
+ ) => {
19
+ const direction = flexDirection.includes('reverse')
20
+ ? flexDirection === 'column-reverse'
21
+ ? 'column'
22
+ : 'row'
23
+ : flexDirection;
24
+ let computedChildren: React.ReactNode | undefined;
25
+ let childrenArray = React.Children.toArray(flattenChildren(children));
26
+ childrenArray = isReversed || reversed ? [...childrenArray].reverse() : childrenArray;
27
+
28
+ if (childrenArray) {
29
+ computedChildren = childrenArray.map((child: any, index: number) => {
30
+ if (typeof child === 'string' || typeof child === 'number') {
31
+ return child;
32
+ }
33
+
34
+ const attachedStyles: any = {};
35
+
36
+ if (index === 0) {
37
+ if (direction === 'column') {
38
+ attachedStyles.borderBottomLeftRadius = 0;
39
+ attachedStyles.borderBottomRightRadius = 0;
40
+ } else {
41
+ attachedStyles.borderTopRightRadius = 0;
42
+ attachedStyles.borderBottomRightRadius = 0;
43
+ }
44
+ } else if (index === childrenArray.length - 1) {
45
+ if (direction === 'column') {
46
+ attachedStyles.borderTopLeftRadius = 0;
47
+ attachedStyles.borderTopRightRadius = 0;
48
+ } else {
49
+ attachedStyles.borderTopLeftRadius = 0;
50
+ attachedStyles.borderBottomLeftRadius = 0;
51
+ }
52
+ } else {
53
+ attachedStyles.borderRadius = 0;
54
+ }
55
+
56
+ const childProps = {
57
+ isDisabled,
58
+ ...child.props,
59
+ style: {
60
+ ...(isAttached ? attachedStyles : {}),
61
+ ...child.props.style,
62
+ },
63
+ };
64
+
65
+ const clonedChild = React.cloneElement(child, {
66
+ ...childProps,
67
+ });
68
+
69
+ return (
70
+ <React.Fragment key={child.key ?? `spaced-child-${index.toString()}`}>
71
+ {clonedChild}
72
+ </React.Fragment>
73
+ );
74
+ });
75
+ }
76
+
77
+ const gapProp = isAttached ? { gap: 0 } : {};
78
+
79
+ if (computedChildren) {
80
+ return (
81
+ <BaseButtonGroup {...({ flexDirection, ...props, ref, ...gapProp } as T)}>
82
+ {computedChildren}
83
+ </BaseButtonGroup>
84
+ );
85
+ }
86
+ return null;
87
+ },
88
+ );
@@ -0,0 +1,8 @@
1
+ import { forwardRef } from 'react';
2
+
3
+ // TODO: Does this need data-attributes?
4
+
5
+ export const createButtonIcon = <T,>(BaseButtonIcon: React.ComponentType<T>) =>
6
+ forwardRef((props: any, ref?: React.Ref<T>) => {
7
+ return <BaseButtonIcon {...props} ref={ref} />;
8
+ });
@@ -0,0 +1,101 @@
1
+ import type React from 'react';
2
+ import { forwardRef, useMemo } from 'react';
3
+ import { composeEventHandlers } from '@cdx-ui/utils';
4
+ import { useFocus, useFocusRing } from '@react-native-aria/focus';
5
+ import { useHover, usePress } from '@react-native-aria/interactions';
6
+ import { dataAttributes } from '../utils/dataAttributes';
7
+ import { ButtonProvider } from './context';
8
+ import type { IButtonProps, InteractionState } from './types';
9
+
10
+ export const createButtonRoot = <T,>(BaseButton: React.ComponentType<T>) =>
11
+ forwardRef(
12
+ (
13
+ {
14
+ children,
15
+ isDisabled,
16
+ isHovered: isHoveredProp,
17
+ isActive: isActiveProp,
18
+ isFocused: isFocusedProp,
19
+ isFocusVisible: isFocusVisibleProp,
20
+ ...props
21
+ }: Omit<IButtonProps, 'children'> & {
22
+ children?: ((state: InteractionState) => React.ReactNode) | React.ReactNode;
23
+ },
24
+ ref?: React.Ref<T>,
25
+ ) => {
26
+ const { isFocused, focusProps } = useFocus();
27
+ const { isFocusVisible, focusProps: focusRingProps } = useFocusRing() as {
28
+ isFocusVisible: boolean;
29
+ focusProps: typeof focusProps;
30
+ };
31
+ const { pressProps: pressableProps, isPressed: isActive } = usePress({
32
+ isDisabled,
33
+ });
34
+ const { isHovered, hoverProps } = useHover();
35
+ const contextValue = useMemo(() => {
36
+ return {
37
+ hover: isHoveredProp || isHovered,
38
+ focus: isFocusedProp || isFocused,
39
+ active: isActiveProp || isActive,
40
+ disabled: isDisabled,
41
+ focusVisible: isFocusVisibleProp || isFocusVisible,
42
+ };
43
+ }, [
44
+ isHovered,
45
+ isHoveredProp,
46
+ isFocused,
47
+ isFocusedProp,
48
+ isActive,
49
+ isActiveProp,
50
+ isDisabled,
51
+ isFocusVisible,
52
+ isFocusVisibleProp,
53
+ ]);
54
+
55
+ return (
56
+ <ButtonProvider value={contextValue}>
57
+ <BaseButton
58
+ ref={ref}
59
+ role={props?.role || 'button'}
60
+ {...dataAttributes({
61
+ hover: isHoveredProp || isHovered,
62
+ focus: isFocusedProp || isFocused,
63
+ active: isActiveProp || isActive,
64
+ disabled: isDisabled,
65
+ focusVisible: isFocusVisibleProp || isFocusVisible,
66
+ })}
67
+ disabled={isDisabled}
68
+ {...(props as T)}
69
+ onPressIn={composeEventHandlers(props?.onPressIn, pressableProps.onPressIn)}
70
+ onPressOut={composeEventHandlers(props?.onPressOut, pressableProps.onPressOut)}
71
+ onHoverIn={composeEventHandlers(props?.onHoverIn, hoverProps.onHoverIn)}
72
+ onHoverOut={composeEventHandlers(props?.onHoverOut, hoverProps.onHoverOut)}
73
+ onFocus={composeEventHandlers(
74
+ composeEventHandlers(
75
+ props?.onFocus as (...args: unknown[]) => unknown,
76
+ focusProps.onFocus,
77
+ ),
78
+ focusRingProps.onFocus,
79
+ )}
80
+ onBlur={composeEventHandlers(
81
+ composeEventHandlers(
82
+ props?.onBlur as (...args: unknown[]) => unknown,
83
+ focusProps.onBlur,
84
+ ),
85
+ focusRingProps.onBlur,
86
+ )}
87
+ >
88
+ {typeof children === 'function'
89
+ ? children({
90
+ hover: isHoveredProp || isHovered,
91
+ focus: isFocusedProp || isFocused,
92
+ active: isActiveProp || isActive,
93
+ disabled: isDisabled,
94
+ focusVisible: isFocusVisibleProp || isFocusVisible,
95
+ })
96
+ : children}
97
+ </BaseButton>
98
+ </ButtonProvider>
99
+ );
100
+ },
101
+ );