@cdx-ui/components 0.0.1-beta.65 → 0.0.1-beta.66

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 (242) hide show
  1. package/lib/commonjs/components/AlertDialog/index.js +12 -10
  2. package/lib/commonjs/components/AlertDialog/index.js.map +1 -1
  3. package/lib/commonjs/components/Avatar/index.js +125 -25
  4. package/lib/commonjs/components/Avatar/index.js.map +1 -1
  5. package/lib/commonjs/components/Button/index.js +127 -28
  6. package/lib/commonjs/components/Button/index.js.map +1 -1
  7. package/lib/commonjs/components/Button/styles.js +9 -3
  8. package/lib/commonjs/components/Button/styles.js.map +1 -1
  9. package/lib/commonjs/components/CLAUDE.md +115 -11
  10. package/lib/commonjs/components/Checkbox/index.js +69 -22
  11. package/lib/commonjs/components/Checkbox/index.js.map +1 -1
  12. package/lib/commonjs/components/Checkbox/styles.js +1 -1
  13. package/lib/commonjs/components/Checkbox/styles.js.map +1 -1
  14. package/lib/commonjs/components/Chip/index.js +44 -36
  15. package/lib/commonjs/components/Chip/index.js.map +1 -1
  16. package/lib/commonjs/components/Chip/styles.js +6 -35
  17. package/lib/commonjs/components/Chip/styles.js.map +1 -1
  18. package/lib/commonjs/components/Dialog/index.js +92 -72
  19. package/lib/commonjs/components/Dialog/index.js.map +1 -1
  20. package/lib/commonjs/components/Field/index.js +70 -26
  21. package/lib/commonjs/components/Field/index.js.map +1 -1
  22. package/lib/commonjs/components/Form/index.js +5 -12
  23. package/lib/commonjs/components/Form/index.js.map +1 -1
  24. package/lib/commonjs/components/IconButton/index.js +5 -33
  25. package/lib/commonjs/components/IconButton/index.js.map +1 -1
  26. package/lib/commonjs/components/Input/index.js +50 -20
  27. package/lib/commonjs/components/Input/index.js.map +1 -1
  28. package/lib/commonjs/components/Link/index.js +14 -7
  29. package/lib/commonjs/components/Link/index.js.map +1 -1
  30. package/lib/commonjs/components/ListItem/index.js +129 -54
  31. package/lib/commonjs/components/ListItem/index.js.map +1 -1
  32. package/lib/commonjs/components/OtpInput/index.js +94 -28
  33. package/lib/commonjs/components/OtpInput/index.js.map +1 -1
  34. package/lib/commonjs/components/ProgressBar/index.js +8 -13
  35. package/lib/commonjs/components/ProgressBar/index.js.map +1 -1
  36. package/lib/commonjs/components/Radio/index.js +51 -53
  37. package/lib/commonjs/components/Radio/index.js.map +1 -1
  38. package/lib/commonjs/components/Select/index.js +112 -46
  39. package/lib/commonjs/components/Select/index.js.map +1 -1
  40. package/lib/commonjs/components/Select/styles.js +2 -2
  41. package/lib/commonjs/components/Select/styles.js.map +1 -1
  42. package/lib/commonjs/components/Switch/BaseSwitch.js +23 -13
  43. package/lib/commonjs/components/Switch/BaseSwitch.js.map +1 -1
  44. package/lib/commonjs/components/Switch/BaseSwitch.web.js +25 -21
  45. package/lib/commonjs/components/Switch/BaseSwitch.web.js.map +1 -1
  46. package/lib/commonjs/components/Switch/index.js +34 -3
  47. package/lib/commonjs/components/Switch/index.js.map +1 -1
  48. package/lib/commonjs/components/Tile/index.js +150 -77
  49. package/lib/commonjs/components/Tile/index.js.map +1 -1
  50. package/lib/commonjs/figma/Chip.figma.js +2 -2
  51. package/lib/commonjs/figma/Chip.figma.js.map +1 -1
  52. package/lib/commonjs/utils/positionToDataIcon.js +41 -0
  53. package/lib/commonjs/utils/positionToDataIcon.js.map +1 -0
  54. package/lib/module/components/AlertDialog/index.js +13 -11
  55. package/lib/module/components/AlertDialog/index.js.map +1 -1
  56. package/lib/module/components/Avatar/index.js +128 -28
  57. package/lib/module/components/Avatar/index.js.map +1 -1
  58. package/lib/module/components/Button/index.js +130 -32
  59. package/lib/module/components/Button/index.js.map +1 -1
  60. package/lib/module/components/Button/styles.js +8 -2
  61. package/lib/module/components/Button/styles.js.map +1 -1
  62. package/lib/module/components/CLAUDE.md +115 -11
  63. package/lib/module/components/Checkbox/index.js +72 -25
  64. package/lib/module/components/Checkbox/index.js.map +1 -1
  65. package/lib/module/components/Checkbox/styles.js +1 -1
  66. package/lib/module/components/Checkbox/styles.js.map +1 -1
  67. package/lib/module/components/Chip/index.js +47 -39
  68. package/lib/module/components/Chip/index.js.map +1 -1
  69. package/lib/module/components/Chip/styles.js +6 -35
  70. package/lib/module/components/Chip/styles.js.map +1 -1
  71. package/lib/module/components/Dialog/index.js +96 -76
  72. package/lib/module/components/Dialog/index.js.map +1 -1
  73. package/lib/module/components/Field/index.js +74 -31
  74. package/lib/module/components/Field/index.js.map +1 -1
  75. package/lib/module/components/Form/index.js +7 -14
  76. package/lib/module/components/Form/index.js.map +1 -1
  77. package/lib/module/components/IconButton/index.js +6 -34
  78. package/lib/module/components/IconButton/index.js.map +1 -1
  79. package/lib/module/components/Input/index.js +53 -23
  80. package/lib/module/components/Input/index.js.map +1 -1
  81. package/lib/module/components/Link/index.js +16 -8
  82. package/lib/module/components/Link/index.js.map +1 -1
  83. package/lib/module/components/ListItem/index.js +134 -59
  84. package/lib/module/components/ListItem/index.js.map +1 -1
  85. package/lib/module/components/OtpInput/index.js +94 -28
  86. package/lib/module/components/OtpInput/index.js.map +1 -1
  87. package/lib/module/components/ProgressBar/index.js +9 -14
  88. package/lib/module/components/ProgressBar/index.js.map +1 -1
  89. package/lib/module/components/Radio/index.js +54 -57
  90. package/lib/module/components/Radio/index.js.map +1 -1
  91. package/lib/module/components/Select/index.js +118 -52
  92. package/lib/module/components/Select/index.js.map +1 -1
  93. package/lib/module/components/Select/styles.js +2 -2
  94. package/lib/module/components/Select/styles.js.map +1 -1
  95. package/lib/module/components/Switch/BaseSwitch.js +24 -14
  96. package/lib/module/components/Switch/BaseSwitch.js.map +1 -1
  97. package/lib/module/components/Switch/BaseSwitch.web.js +26 -22
  98. package/lib/module/components/Switch/BaseSwitch.web.js.map +1 -1
  99. package/lib/module/components/Switch/index.js +35 -4
  100. package/lib/module/components/Switch/index.js.map +1 -1
  101. package/lib/module/components/Tile/index.js +155 -83
  102. package/lib/module/components/Tile/index.js.map +1 -1
  103. package/lib/module/figma/Chip.figma.js +2 -2
  104. package/lib/module/figma/Chip.figma.js.map +1 -1
  105. package/lib/module/utils/positionToDataIcon.js +38 -0
  106. package/lib/module/utils/positionToDataIcon.js.map +1 -0
  107. package/lib/typescript/components/AlertDialog/index.d.ts.map +1 -1
  108. package/lib/typescript/components/Avatar/index.d.ts +6 -2
  109. package/lib/typescript/components/Avatar/index.d.ts.map +1 -1
  110. package/lib/typescript/components/Button/index.d.ts +31 -8
  111. package/lib/typescript/components/Button/index.d.ts.map +1 -1
  112. package/lib/typescript/components/Button/styles.d.ts +2 -1
  113. package/lib/typescript/components/Button/styles.d.ts.map +1 -1
  114. package/lib/typescript/components/Checkbox/index.d.ts +3 -1
  115. package/lib/typescript/components/Checkbox/index.d.ts.map +1 -1
  116. package/lib/typescript/components/Chip/index.d.ts +19 -9
  117. package/lib/typescript/components/Chip/index.d.ts.map +1 -1
  118. package/lib/typescript/components/Chip/styles.d.ts +0 -1
  119. package/lib/typescript/components/Chip/styles.d.ts.map +1 -1
  120. package/lib/typescript/components/Dialog/index.d.ts +12 -6
  121. package/lib/typescript/components/Dialog/index.d.ts.map +1 -1
  122. package/lib/typescript/components/Dialog/styles.d.ts +1 -1
  123. package/lib/typescript/components/Field/index.d.ts +14 -7
  124. package/lib/typescript/components/Field/index.d.ts.map +1 -1
  125. package/lib/typescript/components/Form/index.d.ts +4 -4
  126. package/lib/typescript/components/Form/index.d.ts.map +1 -1
  127. package/lib/typescript/components/IconButton/index.d.ts.map +1 -1
  128. package/lib/typescript/components/Input/index.d.ts +11 -3
  129. package/lib/typescript/components/Input/index.d.ts.map +1 -1
  130. package/lib/typescript/components/Link/index.d.ts +2 -0
  131. package/lib/typescript/components/Link/index.d.ts.map +1 -1
  132. package/lib/typescript/components/ListItem/index.d.ts +28 -6
  133. package/lib/typescript/components/ListItem/index.d.ts.map +1 -1
  134. package/lib/typescript/components/OtpInput/index.d.ts +1 -1
  135. package/lib/typescript/components/OtpInput/index.d.ts.map +1 -1
  136. package/lib/typescript/components/ProgressBar/index.d.ts +4 -4
  137. package/lib/typescript/components/ProgressBar/index.d.ts.map +1 -1
  138. package/lib/typescript/components/Radio/index.d.ts +4 -0
  139. package/lib/typescript/components/Radio/index.d.ts.map +1 -1
  140. package/lib/typescript/components/Select/index.d.ts +35 -2
  141. package/lib/typescript/components/Select/index.d.ts.map +1 -1
  142. package/lib/typescript/components/Select/styles.d.ts.map +1 -1
  143. package/lib/typescript/components/Switch/BaseSwitch.d.ts +12 -5
  144. package/lib/typescript/components/Switch/BaseSwitch.d.ts.map +1 -1
  145. package/lib/typescript/components/Switch/BaseSwitch.web.d.ts +11 -5
  146. package/lib/typescript/components/Switch/BaseSwitch.web.d.ts.map +1 -1
  147. package/lib/typescript/components/Switch/index.d.ts +5 -1
  148. package/lib/typescript/components/Switch/index.d.ts.map +1 -1
  149. package/lib/typescript/components/Tile/index.d.ts +8 -2
  150. package/lib/typescript/components/Tile/index.d.ts.map +1 -1
  151. package/lib/typescript/utils/positionToDataIcon.d.ts +29 -0
  152. package/lib/typescript/utils/positionToDataIcon.d.ts.map +1 -0
  153. package/package.json +5 -5
  154. package/src/components/AlertDialog/index.tsx +13 -14
  155. package/src/components/Avatar/index.tsx +134 -44
  156. package/src/components/Button/index.tsx +216 -44
  157. package/src/components/Button/styles.ts +50 -38
  158. package/src/components/CLAUDE.md +115 -11
  159. package/src/components/Checkbox/index.tsx +93 -32
  160. package/src/components/Checkbox/styles.ts +1 -1
  161. package/src/components/Chip/index.tsx +88 -61
  162. package/src/components/Chip/styles.ts +6 -18
  163. package/src/components/Dialog/index.tsx +139 -99
  164. package/src/components/Field/index.tsx +113 -49
  165. package/src/components/Form/index.tsx +18 -14
  166. package/src/components/IconButton/index.tsx +7 -31
  167. package/src/components/Input/index.tsx +75 -32
  168. package/src/components/Link/index.tsx +38 -12
  169. package/src/components/ListItem/index.tsx +158 -73
  170. package/src/components/OtpInput/index.tsx +126 -43
  171. package/src/components/ProgressBar/index.tsx +11 -16
  172. package/src/components/Radio/index.tsx +76 -54
  173. package/src/components/Select/index.tsx +174 -59
  174. package/src/components/Select/styles.ts +1 -2
  175. package/src/components/Switch/BaseSwitch.tsx +38 -16
  176. package/src/components/Switch/BaseSwitch.web.tsx +28 -35
  177. package/src/components/Switch/index.tsx +51 -4
  178. package/src/components/Tile/index.tsx +145 -94
  179. package/src/utils/positionToDataIcon.ts +34 -0
  180. package/lib/commonjs/components/Field/FieldLabel.js +0 -33
  181. package/lib/commonjs/components/Field/FieldLabel.js.map +0 -1
  182. package/lib/commonjs/components/Field/FieldLabel.web.js +0 -22
  183. package/lib/commonjs/components/Field/FieldLabel.web.js.map +0 -1
  184. package/lib/commonjs/components/Form/FormRoot.js +0 -25
  185. package/lib/commonjs/components/Form/FormRoot.js.map +0 -1
  186. package/lib/commonjs/components/Form/FormRoot.web.js +0 -17
  187. package/lib/commonjs/components/Form/FormRoot.web.js.map +0 -1
  188. package/lib/commonjs/components/Input/BaseInput.android.js +0 -20
  189. package/lib/commonjs/components/Input/BaseInput.android.js.map +0 -1
  190. package/lib/commonjs/components/Input/BaseInput.js +0 -13
  191. package/lib/commonjs/components/Input/BaseInput.js.map +0 -1
  192. package/lib/commonjs/components/Input/BaseInput.web.js +0 -50
  193. package/lib/commonjs/components/Input/BaseInput.web.js.map +0 -1
  194. package/lib/commonjs/components/Select/SelectTriggerHost.js +0 -10
  195. package/lib/commonjs/components/Select/SelectTriggerHost.js.map +0 -1
  196. package/lib/commonjs/components/Select/SelectTriggerHost.web.js +0 -102
  197. package/lib/commonjs/components/Select/SelectTriggerHost.web.js.map +0 -1
  198. package/lib/module/components/Field/FieldLabel.js +0 -29
  199. package/lib/module/components/Field/FieldLabel.js.map +0 -1
  200. package/lib/module/components/Field/FieldLabel.web.js +0 -17
  201. package/lib/module/components/Field/FieldLabel.web.js.map +0 -1
  202. package/lib/module/components/Form/FormRoot.js +0 -21
  203. package/lib/module/components/Form/FormRoot.js.map +0 -1
  204. package/lib/module/components/Form/FormRoot.web.js +0 -12
  205. package/lib/module/components/Form/FormRoot.web.js.map +0 -1
  206. package/lib/module/components/Input/BaseInput.android.js +0 -16
  207. package/lib/module/components/Input/BaseInput.android.js.map +0 -1
  208. package/lib/module/components/Input/BaseInput.js +0 -4
  209. package/lib/module/components/Input/BaseInput.js.map +0 -1
  210. package/lib/module/components/Input/BaseInput.web.js +0 -45
  211. package/lib/module/components/Input/BaseInput.web.js.map +0 -1
  212. package/lib/module/components/Select/SelectTriggerHost.js +0 -7
  213. package/lib/module/components/Select/SelectTriggerHost.js.map +0 -1
  214. package/lib/module/components/Select/SelectTriggerHost.web.js +0 -97
  215. package/lib/module/components/Select/SelectTriggerHost.web.js.map +0 -1
  216. package/lib/typescript/components/Field/FieldLabel.d.ts +0 -18
  217. package/lib/typescript/components/Field/FieldLabel.d.ts.map +0 -1
  218. package/lib/typescript/components/Field/FieldLabel.web.d.ts +0 -16
  219. package/lib/typescript/components/Field/FieldLabel.web.d.ts.map +0 -1
  220. package/lib/typescript/components/Form/FormRoot.d.ts +0 -14
  221. package/lib/typescript/components/Form/FormRoot.d.ts.map +0 -1
  222. package/lib/typescript/components/Form/FormRoot.web.d.ts +0 -10
  223. package/lib/typescript/components/Form/FormRoot.web.d.ts.map +0 -1
  224. package/lib/typescript/components/Input/BaseInput.android.d.ts +0 -3
  225. package/lib/typescript/components/Input/BaseInput.android.d.ts.map +0 -1
  226. package/lib/typescript/components/Input/BaseInput.d.ts +0 -2
  227. package/lib/typescript/components/Input/BaseInput.d.ts.map +0 -1
  228. package/lib/typescript/components/Input/BaseInput.web.d.ts +0 -3
  229. package/lib/typescript/components/Input/BaseInput.web.d.ts.map +0 -1
  230. package/lib/typescript/components/Select/SelectTriggerHost.d.ts +0 -3
  231. package/lib/typescript/components/Select/SelectTriggerHost.d.ts.map +0 -1
  232. package/lib/typescript/components/Select/SelectTriggerHost.web.d.ts +0 -16
  233. package/lib/typescript/components/Select/SelectTriggerHost.web.d.ts.map +0 -1
  234. package/src/components/Field/FieldLabel.tsx +0 -33
  235. package/src/components/Field/FieldLabel.web.tsx +0 -25
  236. package/src/components/Form/FormRoot.tsx +0 -20
  237. package/src/components/Form/FormRoot.web.tsx +0 -12
  238. package/src/components/Input/BaseInput.android.tsx +0 -13
  239. package/src/components/Input/BaseInput.tsx +0 -1
  240. package/src/components/Input/BaseInput.web.tsx +0 -41
  241. package/src/components/Select/SelectTriggerHost.tsx +0 -4
  242. package/src/components/Select/SelectTriggerHost.web.tsx +0 -143
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.positionToDataIcon = positionToDataIcon;
7
+ var _primitives = require("@cdx-ui/primitives");
8
+ /**
9
+ * Position hint accepted by icon/spinner-bearing styled slots
10
+ * (`Button.Icon`, `Button.Spinner`, `Chip.Icon`, etc.). Maps to a logical
11
+ * `data-icon` attribute that CVA targets for leading/trailing padding.
12
+ *
13
+ * `'leading'` → `data-icon="inline-start"`
14
+ * `'trailing'` → `data-icon="inline-end"`
15
+ */
16
+
17
+ /**
18
+ * Returns the data-attribute spread props for the requested position, or
19
+ * `undefined` when no position is set (so the attribute is omitted entirely
20
+ * and baseline spacing applies).
21
+ *
22
+ * Spread the result onto the rendered element:
23
+ *
24
+ * ```tsx
25
+ * <Icon {...positionToDataIcon(position)} />
26
+ * ```
27
+ *
28
+ * Spacing rules live in CVA variant strings, targeting the attribute via
29
+ * logical-property utilities so RTL flips automatically:
30
+ *
31
+ * ```ts
32
+ * cva(['data-[icon=inline-start]:me-1.5 data-[icon=inline-end]:ms-1.5'], { ... });
33
+ * ```
34
+ */
35
+ function positionToDataIcon(position) {
36
+ if (!position) return undefined;
37
+ return (0, _primitives.dataAttributes)({
38
+ icon: position === 'leading' ? 'inline-start' : 'inline-end'
39
+ });
40
+ }
41
+ //# sourceMappingURL=positionToDataIcon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_primitives","require","positionToDataIcon","position","undefined","dataAttributes","icon"],"sourceRoot":"../../../src","sources":["utils/positionToDataIcon.ts"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,kBAAkBA,CAACC,QAA2B,EAAE;EAC9D,IAAI,CAACA,QAAQ,EAAE,OAAOC,SAAS;EAC/B,OAAO,IAAAC,0BAAc,EAAC;IAAEC,IAAI,EAAEH,QAAQ,KAAK,SAAS,GAAG,cAAc,GAAG;EAAa,CAAC,CAAC;AACzF","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  import React, { forwardRef } from 'react';
4
- import { useDialog } from '@cdx-ui/primitives';
4
+ import { Slot, useDialog } from '@cdx-ui/primitives';
5
5
  import { composeEventHandlers } from '@cdx-ui/utils';
6
6
  import { Button } from '../Button';
7
7
  import { Dialog } from '../Dialog';
@@ -37,11 +37,12 @@ const AlertDialogAction = /*#__PURE__*/forwardRef(({
37
37
  className,
38
38
  ...props
39
39
  }, ref) => {
40
- if (asChild && /*#__PURE__*/React.isValidElement(children)) {
41
- return /*#__PURE__*/React.cloneElement(children, {
42
- ref,
43
- className,
44
- ...props
40
+ if (asChild) {
41
+ return /*#__PURE__*/_jsx(Slot, {
42
+ ref: ref,
43
+ className: className,
44
+ ...props,
45
+ children: children
45
46
  });
46
47
  }
47
48
  return /*#__PURE__*/_jsx(Button, {
@@ -72,12 +73,13 @@ const AlertDialogCancel = /*#__PURE__*/forwardRef(({
72
73
  onOpenChange
73
74
  } = useDialog();
74
75
  const handlePress = composeEventHandlers(onPress, () => onOpenChange(false));
75
- if (asChild && /*#__PURE__*/React.isValidElement(children)) {
76
- return /*#__PURE__*/React.cloneElement(children, {
77
- ref,
76
+ if (asChild) {
77
+ return /*#__PURE__*/_jsx(Slot, {
78
+ ref: ref,
78
79
  onPress: handlePress,
79
- className,
80
- ...props
80
+ className: className,
81
+ ...props,
82
+ children: children
81
83
  });
82
84
  }
83
85
  return /*#__PURE__*/_jsx(Button, {
@@ -1 +1 @@
1
- {"version":3,"names":["React","forwardRef","useDialog","composeEventHandlers","Button","Dialog","jsx","_jsx","AlertDialogRoot","closeOnBackdropPress","closeOnEscKey","role","children","props","ref","displayName","AlertDialogAction","asChild","color","className","isValidElement","cloneElement","variant","Label","AlertDialogCancel","onPress","onOpenChange","handlePress","AlertDialog","Object","assign","Trigger","Popup","Header","Title","Description","Content","Text","Footer","Close","Action","Cancel"],"sourceRoot":"../../../../src","sources":["components/AlertDialog/index.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AAEzC,SAASC,SAAS,QAAQ,oBAAoB;AAC9C,SAASC,oBAAoB,QAAQ,eAAe;AACpD,SAASC,MAAM,QAA0B,WAAW;AACpD,SAASC,MAAM,QAA8B,WAAW;;AAExD;AACA;AACA;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAIA,MAAMC,eAAe,gBAAGP,UAAU,CAChC,CACE;EACEQ,oBAAoB,GAAG,KAAK;EAC5BC,aAAa,GAAG,KAAK;EACrBC,IAAI,GAAG,aAAa;EACpBC,QAAQ;EACR,GAAGC;AACL,CAAC,EACDC,GAAG,kBAEHP,IAAA,CAACF,MAAM;EACLS,GAAG,EAAEA,GAAI;EACTL,oBAAoB,EAAEA,oBAAqB;EAC3CC,aAAa,EAAEA,aAAc;EAC7BC,IAAI,EAAEA,IAAK;EAAA,GACPE,KAAK;EAAAD,QAAA,EAERA;AAAQ,CACH,CAEZ,CAAC;AACDJ,eAAe,CAACO,WAAW,GAAG,aAAa;;AAE3C;AACA;AACA;;AAMA,MAAMC,iBAAiB,gBAAGf,UAAU,CAClC,CAAC;EAAEgB,OAAO,GAAG,KAAK;EAAEL,QAAQ;EAAEM,KAAK,GAAG,QAAQ;EAAEC,SAAS;EAAE,GAAGN;AAAM,CAAC,EAAEC,GAAG,KAAK;E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AA,CAACH,MAAM,CAACmB,KAAK;MAAAX,QAAA,EAAEA;IAAQ,CAAe;EAAC,CACjC,CAAC;AAEb,CACF,CAAC;AACDY,iBAAiB,CAACT,WAAW,GAAG,oBAAoB;;AAEpD;AACA;AACA;;AAgBA,OAAO,MAAMa,WAAW,GAAGC,MAAM,CAACC,MAAM,CAACtB,eAAe,EAAE;EACxDuB,OAAO,EAAE1B,MAAM,CAAC0B,OAAO;EACvBC,KAAK,EAAE3B,MAAM,CAAC2B,KAAK;EACnBC,MAAM,EAAE5B,MAAM,CAAC4B,MAAM;EACrBC,KAAK,EAAE7B,MAAM,CAAC6B,KAAK;EACnBC,WAAW,EAAE9B,MAAM,CAAC8B,WAAW;EAC/BC,OAAO,EAAE/B,MAAM,CAAC+B,OAAO;EACvBC,IAAI,EAAEhC,MAAM,CAACgC,IAAI;EACjBC,MAAM,EAAEjC,MAAM,CAACiC,MAAM;EACrBC,KAAK,EAAElC,MAAM,CAACkC,KAAK;EACnBC,MAAM,EAAExB,iBAAiB;EACzByB,MAAM,EAAEjB;AACV,CAAC,CAAiC","ignoreList":[]}
1
+ {"version":3,"names":["React","forwardRef","Slot","useDialog","composeEventHandlers","Button","Dialog","jsx","_jsx","AlertDialogRoot","closeOnBackdropPress","closeOnEscKey","role","children","props","ref","displayName","AlertDialogAction","asChild","color","className","variant","Label","AlertDialogCancel","onPress","onOpenChange","handlePress","AlertDialog","Object","assign","Trigger","Popup","Header","Title","Description","Content","Text","Footer","Close","Action","Cancel"],"sourceRoot":"../../../../src","sources":["components/AlertDialog/index.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AAEzC,SAASC,IAAI,EAAEC,SAAS,QAAQ,oBAAoB;AACpD,SAASC,oBAAoB,QAAQ,eAAe;AACpD,SAASC,MAAM,QAA0B,WAAW;AACpD,SAASC,MAAM,QAA8B,WAAW;;AAExD;AACA;AACA;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAIA,MAAMC,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@@ -1,22 +1,34 @@
1
1
  "use strict";
2
2
 
3
- import { forwardRef } from 'react';
3
+ import { forwardRef, useEffect, useMemo } from 'react';
4
4
  import { Image, Text, View } from 'react-native';
5
- import { createAvatar } from '@cdx-ui/primitives';
6
- import { cn, useStyleContext, withStyleContext } from '@cdx-ui/utils';
5
+ import { AvatarRoot as AvatarRootPrimitive, Slot, dataAttributes, mergeDataAttributes, useAvatarContext } from '@cdx-ui/primitives';
6
+ import { cn, ParentContext, useParentContext, useStyleContext } from '@cdx-ui/utils';
7
7
  import { Icon as IconComponent } from '../Icon';
8
8
  import { avatarBadgeVariants, avatarIconVariants, avatarTextVariants, avatarImageVariants, avatarRootVariants } from './styles';
9
9
  import { jsx as _jsx } from "react/jsx-runtime";
10
10
  const SCOPE = 'AVATAR';
11
- const Root = withStyleContext(View, SCOPE);
12
11
  const useAvatarStyleContext = () => useStyleContext(SCOPE);
13
- const AvatarPrimitive = createAvatar({
14
- Root,
15
- Image,
16
- Text,
17
- Icon: IconComponent,
18
- Badge: View
19
- });
12
+
13
+ // =============================================================================
14
+ // UTILITIES
15
+ // =============================================================================
16
+
17
+ function getInitials(name) {
18
+ const trimmed = name.trim();
19
+ const words = trimmed.split(/\s+/);
20
+ if (words.length === 1 && trimmed.length <= 2) {
21
+ return trimmed.toUpperCase();
22
+ }
23
+ let result = '';
24
+ for (const word of words) {
25
+ if (word.length > 0) {
26
+ result += word.charAt(0);
27
+ }
28
+ if (result.length >= 2) break;
29
+ }
30
+ return result.toUpperCase();
31
+ }
20
32
 
21
33
  // =============================================================================
22
34
  // AVATAR ROOT
@@ -32,15 +44,25 @@ const AvatarRoot = /*#__PURE__*/forwardRef(({
32
44
  const computedClassName = cn(avatarRootVariants({
33
45
  size
34
46
  }), className);
35
- return /*#__PURE__*/_jsx(AvatarPrimitive, {
36
- ref: ref,
37
- className: computedClassName,
38
- style: style,
39
- context: {
47
+ const parent = useParentContext();
48
+ const ctx = useMemo(() => ({
49
+ ...parent,
50
+ [SCOPE]: {
40
51
  size
41
- },
42
- ...props,
43
- children: children
52
+ }
53
+ }), [parent, size]);
54
+ return /*#__PURE__*/_jsx(ParentContext.Provider, {
55
+ value: ctx,
56
+ children: /*#__PURE__*/_jsx(AvatarRootPrimitive, {
57
+ ref: ref,
58
+ className: computedClassName,
59
+ style: style,
60
+ ...props,
61
+ ...mergeDataAttributes(props, dataAttributes({
62
+ slot: 'avatar'
63
+ })),
64
+ children: children
65
+ })
44
66
  });
45
67
  });
46
68
  AvatarRoot.displayName = 'Avatar';
@@ -50,16 +72,53 @@ AvatarRoot.displayName = 'Avatar';
50
72
  // =============================================================================
51
73
 
52
74
  const AvatarImage = /*#__PURE__*/forwardRef(({
75
+ asChild,
53
76
  className,
54
77
  style,
78
+ src,
79
+ source,
80
+ onLoad,
81
+ onError,
55
82
  ...props
56
83
  }, ref) => {
84
+ const {
85
+ imageError,
86
+ setImageLoaded,
87
+ setImageError
88
+ } = useAvatarContext();
57
89
  const computedClassName = cn(avatarImageVariants(), className);
58
- return /*#__PURE__*/_jsx(AvatarPrimitive.Image, {
90
+ const resolvedSource = useMemo(() => src ? {
91
+ uri: src
92
+ } : source, [src, source]);
93
+ useEffect(() => {
94
+ if (!resolvedSource) {
95
+ setImageError(true);
96
+ } else {
97
+ setImageError(false);
98
+ setImageLoaded(false);
99
+ }
100
+ }, [resolvedSource, setImageError, setImageLoaded]);
101
+ if (!resolvedSource || imageError) {
102
+ return null;
103
+ }
104
+ const Comp = asChild ? Slot : Image;
105
+ return /*#__PURE__*/_jsx(Comp, {
59
106
  ref: ref,
107
+ source: resolvedSource,
60
108
  className: computedClassName,
61
109
  style: style,
62
- ...props
110
+ onLoad: e => {
111
+ setImageLoaded(true);
112
+ if (onLoad) onLoad(e);
113
+ },
114
+ onError: e => {
115
+ setImageError(true);
116
+ if (onError) onError(e);
117
+ },
118
+ ...props,
119
+ ...mergeDataAttributes(props, dataAttributes({
120
+ slot: 'avatar-image'
121
+ }))
63
122
  });
64
123
  });
65
124
  AvatarImage.displayName = 'Avatar.Image';
@@ -69,6 +128,7 @@ AvatarImage.displayName = 'Avatar.Image';
69
128
  // =============================================================================
70
129
 
71
130
  const AvatarText = /*#__PURE__*/forwardRef(({
131
+ asChild,
72
132
  className,
73
133
  children,
74
134
  style,
@@ -77,15 +137,27 @@ const AvatarText = /*#__PURE__*/forwardRef(({
77
137
  const {
78
138
  size
79
139
  } = useAvatarStyleContext();
140
+ const {
141
+ imageLoaded,
142
+ imageError
143
+ } = useAvatarContext();
144
+ const visible = !imageLoaded || imageError;
80
145
  const computedClassName = cn(avatarTextVariants({
81
146
  size
82
147
  }), className);
83
- return /*#__PURE__*/_jsx(AvatarPrimitive.Text, {
148
+ const text = typeof children === 'string' ? getInitials(children) : children;
149
+ const Comp = asChild ? Slot : Text;
150
+ return /*#__PURE__*/_jsx(Comp, {
84
151
  ref: ref,
85
152
  className: computedClassName,
86
- style: style,
153
+ style: [style, !visible && {
154
+ opacity: 0
155
+ }],
87
156
  ...props,
88
- children: children
157
+ ...mergeDataAttributes(props, dataAttributes({
158
+ slot: 'avatar-text'
159
+ })),
160
+ children: text
89
161
  });
90
162
  });
91
163
  AvatarText.displayName = 'Avatar.Text';
@@ -95,6 +167,7 @@ AvatarText.displayName = 'Avatar.Text';
95
167
  // =============================================================================
96
168
 
97
169
  const AvatarIcon = ({
170
+ asChild,
98
171
  className,
99
172
  style,
100
173
  ...props
@@ -102,13 +175,35 @@ const AvatarIcon = ({
102
175
  const {
103
176
  size
104
177
  } = useAvatarStyleContext();
178
+ const {
179
+ imageLoaded,
180
+ imageError
181
+ } = useAvatarContext();
182
+ const visible = !imageLoaded || imageError;
105
183
  const computedClassName = cn(avatarIconVariants({
106
184
  size
107
185
  }), className);
108
- return /*#__PURE__*/_jsx(AvatarPrimitive.Icon, {
186
+ if (asChild) {
187
+ return /*#__PURE__*/_jsx(Slot, {
188
+ className: computedClassName,
189
+ style: [style, !visible && {
190
+ opacity: 0
191
+ }],
192
+ ...props,
193
+ ...mergeDataAttributes(props, dataAttributes({
194
+ slot: 'avatar-icon'
195
+ }))
196
+ });
197
+ }
198
+ return /*#__PURE__*/_jsx(IconComponent, {
109
199
  className: computedClassName,
110
- style: style,
111
- ...props
200
+ style: [style, !visible && {
201
+ opacity: 0
202
+ }],
203
+ ...props,
204
+ ...mergeDataAttributes(props, dataAttributes({
205
+ slot: 'avatar-icon'
206
+ }))
112
207
  });
113
208
  };
114
209
  AvatarIcon.displayName = 'Avatar.Icon';
@@ -118,6 +213,7 @@ AvatarIcon.displayName = 'Avatar.Icon';
118
213
  // =============================================================================
119
214
 
120
215
  const AvatarBadge = /*#__PURE__*/forwardRef(({
216
+ asChild,
121
217
  className,
122
218
  children,
123
219
  style,
@@ -129,11 +225,15 @@ const AvatarBadge = /*#__PURE__*/forwardRef(({
129
225
  const computedClassName = cn(avatarBadgeVariants({
130
226
  size
131
227
  }), className);
132
- return /*#__PURE__*/_jsx(AvatarPrimitive.Badge, {
228
+ const Comp = asChild ? Slot : View;
229
+ return /*#__PURE__*/_jsx(Comp, {
133
230
  ref: ref,
134
231
  className: computedClassName,
135
232
  style: style,
136
233
  ...props,
234
+ ...mergeDataAttributes(props, dataAttributes({
235
+ slot: 'avatar-badge'
236
+ })),
137
237
  children: children
138
238
  });
139
239
  });
@@ -1 +1 @@
1
- {"version":3,"names":["forwardRef","Image","Text","View","createAvatar","cn","useStyleContext","withStyleContext","Icon","IconComponent","avatarBadgeVariants","avatarIconVariants","avatarTextVariants","avatarImageVariants","avatarRootVariants","jsx","_jsx","SCOPE","Root","useAvatarStyleContext","AvatarPrimitive","Badge","AvatarRoot","size","className","children","style","props","ref","computedClassName","context","displayName","AvatarImage","AvatarText","AvatarIcon","AvatarBadge","Avatar","Object","assign"],"sourceRoot":"../../../../src","sources":["components/Avatar/index.tsx"],"mappings":";;AAAA,SAASA,UAAU,QAAwB,OAAO;AAClD,SAASC,KAAK,EAAEC,IAAI,EAAEC,IAAI,QAAyD,cAAc;AACjG,SAASC,YAAY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KAAM;IAAA,GAAKC;EAAK,CAAG,CAAC;AACxF,CAAC;AAEDO,UAAU,CAACH,WAAW,GAAG,aAAa;;AAEtC;AACA;AACA;;AAOA,MAAMI,WAAW,gBAAGnC,UAAU,CAC5B,CAAC;EAAEwB,SAAS;EAAEC,QAAQ;EAAEC,KAAK;EAAE,GAAGC;AAAM,CAAC,EAAEC,GAAG,KAAK;EACjD,MAAM;IAAEL;EAAK,CAAC,GAAGJ,qBAAqB,CAAC,CAAC;EACxC,MAAMU,iBAAiB,GAAGxB,EAAE,CAACK,mBAAmB,CAAC;IAAEa;EAAK,CAAC,CAAC,EAAEC,SAAS,CAAC;EAEtE,oBACER,IAAA,CAACI,eAAe,CAACC,KAAK;IACpBO,GAAG,EAAEA,GAAa;IAClBJ,SAAS,EAAEK,iBAAkB;IAC7BH,KAAK,EAAEA,KAAM;IAAA,GACTC,KAAK;IAAAF,QAAA,EAERA;EAAQ,CACY,CAAC;AAE5B,CACF,CAAC;AAEDU,WAAW,CAACJ,WAAW,GAAG,cAAc;;AAExC;AACA;AACA;;AASA,OAAO,MAAMK,MAAM,GAAGC,MAAM,CAACC,MAAM,CAAChB,UAAU,EAAE;EAC9CrB,KAAK,EAAE+B,WAAW;EAClB9B,IAAI,EAAE+B,UAAU;EAChBzB,IAAI,EAAE0B,UAAU;EAChBb,KAAK,EAAEc;AACT,CAAC,CAA4B","ignoreList":[]}
1
+ {"version":3,"names":["forwardRef","useEffect","useMemo","Image","Text","View","AvatarRoot","AvatarRootPrimitive","Slot","dataAttributes","mergeDataAttributes","useAvatarContext","cn","ParentContext","useParentContext","useStyleContext","Icon","IconComponent","avatarBadgeVariants","avatarIconVariants","avatarTextVariants","avatarImageVariants","avatarRootVariants","jsx","_jsx","SCOPE","useAvatarStyleContext","getInitials","name","trimmed","trim","words","split","length","toUpperCase","result","word","charAt","size","className","children","style","props","ref","computedClassName","parent","ctx","Provider","value","slot","displayName","AvatarImage","asChild","src","source","onLoad","onError","imageError","setImageLoaded","setImageError","resolvedSource","uri","Comp","e","AvatarText","imageLoaded","visible","text","opacity","AvatarIcon","AvatarBadge","Avatar","Object","assign","Badge"],"sourceRoot":"../../../../src","sources":["components/Avatar/index.tsx"],"mappings":";;AAAA,SAASA,UAAU,EAAEC,SAAS,EAAEC,OAAO,QAAwB,OAAO;AACtE,SAASC,KAAK,EAAEC,IAAI,EAAEC,IAAI,QAAyD,cAAc;AACjG,SACEC,UAAU,IAAIC,mBAAmB,EACjCC,IAAI,EACJC,cAAc,EACdC,mBAAmB,EACnBC,gBAAgB,QAGX,oBAAoB;AAC3B,SAASC,EAAE,EAAEC,aAAa,EAAEC,gBAAgB,EAAEC,eAAe,QAAQ,eAAe;AACpF,SAASC,IAAI,IAAIC,aAAa,QAAwB,SAAS;AAC/D,SAEEC,mBAAmB,EACnBC,kBAAkB,EAClBC,kBAAkB,EAClBC,mBAAmB,EACnBC,kBAAkB,QACb,UAAU;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAElB,MAAMC,KAAK,GAAG,QAAQ;AAEtB,MAAMC,qBAAqB,GAAGA,CAAA,KAAMX,eAAe,CAACU,KAAK,CAAuB;;AAEhF;AACA;AACA;;AAEA,SAASE,WAAWA,CAACC,IAAY,EAAU;EACzC,MAAMC,OAAO,GAAGD,IAAI,CAACE,IAAI,CAAC,CAAC;EAC3B,MAAMC,KAAK,GAAGF,OAAO,CAACG,KAAK,CAAC,KAAK,CAAC;EAElC,IAAID,KAAK,CAACE,MAAM,KAAK,CAAC,IAAIJ,OAAO,CAACI,MAAM,IAAI,CAAC,EAAE;IAC7C,OAAOJ,OAAO,CAACK,WAAW,CAAC,CAAC;EAC9B;EAEA,IAAIC,MAAM,GAAG,EAAE;EACf,KAAK,MAAMC,IAAI,IAAIL,KAAK,EAAE;IACxB,IAAIK,IAAI,CAACH,MAAM,GAAG,CAAC,EAAE;MACnBE,MAAM,IAAIC,IAAI,CAACC,MAAM,CAAC,CAAC,CAAC;IAC1B;IACA,IAAIF,MAAM,CAACF,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AAMuB,IAAI,GAAGV,OAAO,GAAG5C,IAAI,GAAGH,IAAI;EAElC,oBACEmB,IAAA,CAACsC,IAAI;IACHnB,GAAG,EAAEA,GAAI;IACTJ,SAAS,EAAEK,iBAAkB;IAC7BH,KAAK,EAAEA,KAAM;IAAA,GACTC,KAAK;IAAA,GACLhC,mBAAmB,CAACgC,KAAK,EAAEjC,cAAc,CAAC;MAAEwC,IAAI,EAAE;IAAe,CAAC,CAAC,CAAC;IAAAT,QAAA,EAEvEA;EAAQ,CACL,CAAC;AAEX,CACF,CAAC;AAED8B,WAAW,CAACpB,WAAW,GAAG,cAAc;;AAExC;AACA;AACA;;AASA,OAAO,MAAMqB,MAAM,GAAGC,MAAM,CAACC,MAAM,CAACnE,UAAU,EAAE;EAC9CH,KAAK,EAAEgD,WAAW;EAClB/C,IAAI,EAAE4D,UAAU;EAChBhD,IAAI,EAAEqD,UAAU;EAChBK,KAAK,EAAEJ;AACT,CAAC,CAA4B","ignoreList":[]}
@@ -1,22 +1,15 @@
1
1
  "use strict";
2
2
 
3
- import { forwardRef, useEffect } from 'react';
4
- import { ActivityIndicator, Pressable, Text, View } from 'react-native';
5
- import { createButton } from '@cdx-ui/primitives';
6
- import { cn, useStyleContext, withStyleContext } from '@cdx-ui/utils';
3
+ import React, { forwardRef, useEffect, useMemo } from 'react';
4
+ import { ActivityIndicator, Text, View } from 'react-native';
5
+ import { ButtonRoot as ButtonRootPrimitive, Slot, dataAttributes, mergeDataAttributes } from '@cdx-ui/primitives';
6
+ import { cn, flattenChildren, ParentContext, useParentContext, useStyleContext } from '@cdx-ui/utils';
7
7
  import { Icon } from '../Icon';
8
- import { buttonGroupVariants, buttonIconVariants, buttonRootVariants, buttonSpinnerVariants, buttonTextVariants } from './styles';
8
+ import { positionToDataIcon } from '../../utils/positionToDataIcon';
9
+ import { buttonGroupVariants, buttonIconVariants, buttonRootVariants, buttonSpinnerColorVariants, buttonSpinnerVariants, buttonTextVariants } from './styles';
9
10
  import { jsx as _jsx } from "react/jsx-runtime";
10
11
  const SCOPE = 'BUTTON';
11
- const Root = withStyleContext(Pressable, SCOPE);
12
12
  const useButtonStyleContext = () => useStyleContext(SCOPE);
13
- const ButtonPrimitive = createButton({
14
- Root,
15
- Text,
16
- Group: View,
17
- Spinner: ActivityIndicator,
18
- Icon: View
19
- });
20
13
 
21
14
  // =============================================================================
22
15
  // STYLED ROOT COMPONENT
@@ -49,27 +42,38 @@ const ButtonRoot = /*#__PURE__*/forwardRef(({
49
42
  size,
50
43
  fullWidth
51
44
  }), className);
52
- return /*#__PURE__*/_jsx(ButtonPrimitive, {
53
- ref: ref,
54
- className: computedClassName,
55
- style: style,
56
- context: {
45
+ const parent = useParentContext();
46
+ const ctx = useMemo(() => ({
47
+ ...parent,
48
+ [SCOPE]: {
57
49
  variant,
58
50
  color,
59
51
  size,
60
52
  fullWidth
61
- },
62
- ...props,
63
- children: children
53
+ }
54
+ }), [parent, variant, color, size, fullWidth]);
55
+ return /*#__PURE__*/_jsx(ParentContext.Provider, {
56
+ value: ctx,
57
+ children: /*#__PURE__*/_jsx(ButtonRootPrimitive, {
58
+ ref: ref,
59
+ className: computedClassName,
60
+ style: style,
61
+ ...props,
62
+ ...mergeDataAttributes(props, dataAttributes({
63
+ slot: 'button'
64
+ })),
65
+ children: children
66
+ })
64
67
  });
65
68
  });
66
69
  ButtonRoot.displayName = 'Button';
67
70
 
68
71
  // =============================================================================
69
- // STYLED TEXT COMPONENT
72
+ // STYLED LABEL COMPONENT
70
73
  // =============================================================================
71
74
 
72
75
  const ButtonLabel = /*#__PURE__*/forwardRef(({
76
+ asChild,
73
77
  className,
74
78
  children,
75
79
  style,
@@ -85,46 +89,110 @@ const ButtonLabel = /*#__PURE__*/forwardRef(({
85
89
  color,
86
90
  size
87
91
  }), className);
88
- return /*#__PURE__*/_jsx(ButtonPrimitive.Text, {
92
+ const Comp = asChild ? Slot : Text;
93
+ return /*#__PURE__*/_jsx(Comp, {
89
94
  ref: ref,
90
95
  className: computedClassName,
91
96
  style: style,
92
97
  ...props,
98
+ ...mergeDataAttributes(props, dataAttributes({
99
+ slot: 'button-label'
100
+ })),
93
101
  children: children
94
102
  });
95
103
  });
96
104
  ButtonLabel.displayName = 'Button.Label';
97
105
 
106
+ // =============================================================================
107
+ // STYLED GROUP COMPONENT
108
+ // =============================================================================
109
+
98
110
  // TODO: Use ButtonGroupVariantProps
99
111
 
100
112
  const ButtonGroup = /*#__PURE__*/forwardRef(({
113
+ asChild,
101
114
  className,
102
115
  children,
103
116
  style,
104
117
  flexDirection = 'row',
105
118
  isAttached,
119
+ isDisabled,
120
+ isReversed,
121
+ reversed,
106
122
  ...props
107
123
  }, ref) => {
124
+ const direction = flexDirection.includes('reverse') ? flexDirection === 'column-reverse' ? 'column' : 'row' : flexDirection;
125
+ let childrenArray = React.Children.toArray(flattenChildren(children));
126
+ childrenArray = isReversed || reversed ? [...childrenArray].reverse() : childrenArray;
127
+ const computedChildren = childrenArray.map((child, index) => {
128
+ if (typeof child === 'string' || typeof child === 'number') {
129
+ return child;
130
+ }
131
+ const attachedStyles = {};
132
+ if (index === 0) {
133
+ if (direction === 'column') {
134
+ attachedStyles.borderBottomLeftRadius = 0;
135
+ attachedStyles.borderBottomRightRadius = 0;
136
+ } else {
137
+ attachedStyles.borderTopRightRadius = 0;
138
+ attachedStyles.borderBottomRightRadius = 0;
139
+ }
140
+ } else if (index === childrenArray.length - 1) {
141
+ if (direction === 'column') {
142
+ attachedStyles.borderTopLeftRadius = 0;
143
+ attachedStyles.borderTopRightRadius = 0;
144
+ } else {
145
+ attachedStyles.borderTopLeftRadius = 0;
146
+ attachedStyles.borderBottomLeftRadius = 0;
147
+ }
148
+ } else {
149
+ attachedStyles.borderRadius = 0;
150
+ }
151
+ const childProps = {
152
+ isDisabled,
153
+ ...child.props,
154
+ style: {
155
+ ...(isAttached ? attachedStyles : {}),
156
+ ...child.props.style
157
+ }
158
+ };
159
+ return /*#__PURE__*/_jsx(React.Fragment, {
160
+ children: /*#__PURE__*/React.cloneElement(child, childProps)
161
+ }, child.key ?? `spaced-child-${index.toString()}`);
162
+ });
108
163
  const groupClassName = cn(buttonGroupVariants({
109
164
  flexDirection,
110
165
  isAttached: !!isAttached
111
166
  }), className);
112
- return /*#__PURE__*/_jsx(ButtonPrimitive.Group, {
167
+ const Comp = asChild ? Slot : View;
168
+ const gapProp = isAttached ? {
169
+ gap: 0
170
+ } : {};
171
+ return /*#__PURE__*/_jsx(Comp, {
113
172
  ref: ref,
114
173
  className: groupClassName,
115
174
  style: [{
116
175
  flexDirection
117
- }, style],
118
- isAttached: isAttached,
176
+ }, style, gapProp],
119
177
  ...props,
120
- children: children
178
+ ...mergeDataAttributes(props, dataAttributes({
179
+ slot: 'button-group'
180
+ })),
181
+ children: computedChildren
121
182
  });
122
183
  });
123
184
  ButtonGroup.displayName = 'Button.Group';
185
+
186
+ // =============================================================================
187
+ // STYLED ICON COMPONENT
188
+ // =============================================================================
189
+
124
190
  const ButtonIcon = ({
191
+ asChild,
125
192
  className,
126
193
  style,
127
194
  as,
195
+ position,
128
196
  ...props
129
197
  }) => {
130
198
  const {
@@ -137,34 +205,64 @@ const ButtonIcon = ({
137
205
  color,
138
206
  size
139
207
  }), className);
208
+ if (asChild) {
209
+ return /*#__PURE__*/_jsx(Slot, {
210
+ className: computedClassName,
211
+ style: style,
212
+ ...props,
213
+ ...mergeDataAttributes(props, dataAttributes({
214
+ slot: 'button-icon'
215
+ }), positionToDataIcon(position))
216
+ });
217
+ }
218
+ if (!as) {
219
+ return null;
220
+ }
140
221
  return /*#__PURE__*/_jsx(Icon, {
141
222
  as: as,
142
223
  className: computedClassName,
143
224
  style: style,
144
- ...props
225
+ ...props,
226
+ ...mergeDataAttributes(props, dataAttributes({
227
+ slot: 'button-icon'
228
+ }), positionToDataIcon(position))
145
229
  });
146
230
  };
147
231
  ButtonIcon.displayName = 'Button.Icon';
232
+
233
+ // =============================================================================
234
+ // STYLED SPINNER COMPONENT
235
+ // =============================================================================
236
+
148
237
  const ButtonSpinner = /*#__PURE__*/forwardRef(({
238
+ asChild,
149
239
  className,
150
240
  colorClassName,
151
241
  style,
242
+ position,
243
+ accessibilityLabel = 'Loading',
152
244
  ...props
153
245
  }, ref) => {
154
246
  const {
155
247
  variant,
156
248
  color
157
249
  } = useButtonStyleContext();
158
- const computedColorClassName = cn(buttonSpinnerVariants({
250
+ const computedClassName = cn(buttonSpinnerVariants(), className);
251
+ const computedColorClassName = cn(buttonSpinnerColorVariants({
159
252
  variant,
160
253
  color
161
254
  }), colorClassName);
162
- return /*#__PURE__*/_jsx(ButtonPrimitive.Spinner, {
255
+ const Comp = asChild ? Slot : ActivityIndicator;
256
+ return /*#__PURE__*/_jsx(Comp, {
163
257
  ref: ref,
164
- className: className,
258
+ className: computedClassName,
165
259
  colorClassName: computedColorClassName,
166
260
  style: style,
167
- ...props
261
+ accessibilityLabel: accessibilityLabel,
262
+ ...props,
263
+ ...mergeDataAttributes(props, dataAttributes({
264
+ slot: 'button-spinner'
265
+ }), positionToDataIcon(position))
168
266
  });
169
267
  });
170
268
  ButtonSpinner.displayName = 'Button.Spinner';