@refraktor/core 0.0.3 → 0.0.4

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 (284) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/build/components/button/button.styles.js +5 -5
  3. package/build/components/chip/chip-group/chip-group.d.ts +4 -0
  4. package/build/components/chip/chip-group/chip-group.d.ts.map +1 -0
  5. package/build/components/chip/chip-group/chip-group.js +43 -0
  6. package/build/components/chip/chip-group/index.d.ts +2 -0
  7. package/build/components/chip/chip-group/index.d.ts.map +1 -0
  8. package/build/components/chip/chip-group/index.js +1 -0
  9. package/build/components/chip/chip.context.d.ts +15 -0
  10. package/build/components/chip/chip.context.d.ts.map +1 -0
  11. package/build/components/chip/chip.context.js +2 -0
  12. package/build/components/chip/chip.d.ts +4 -0
  13. package/build/components/chip/chip.d.ts.map +1 -0
  14. package/build/components/chip/chip.js +85 -0
  15. package/build/components/chip/chip.styles.d.ts +5 -0
  16. package/build/components/chip/chip.styles.d.ts.map +1 -0
  17. package/build/components/chip/chip.styles.js +19 -0
  18. package/build/components/chip/chip.test.d.ts +2 -0
  19. package/build/components/chip/chip.test.d.ts.map +1 -0
  20. package/build/components/chip/chip.test.js +107 -0
  21. package/build/components/chip/chip.types.d.ts +95 -0
  22. package/build/components/chip/chip.types.d.ts.map +1 -0
  23. package/build/components/chip/chip.types.js +1 -0
  24. package/build/components/chip/index.d.ts +4 -0
  25. package/build/components/chip/index.d.ts.map +1 -0
  26. package/build/components/chip/index.js +2 -0
  27. package/build/components/combobox/combobox-dropdown/combobox-dropdown.d.ts +4 -0
  28. package/build/components/combobox/combobox-dropdown/combobox-dropdown.d.ts.map +1 -0
  29. package/build/components/combobox/combobox-dropdown/combobox-dropdown.js +21 -0
  30. package/build/components/combobox/combobox-dropdown/index.d.ts +2 -0
  31. package/build/components/combobox/combobox-dropdown/index.d.ts.map +1 -0
  32. package/build/components/combobox/combobox-dropdown/index.js +1 -0
  33. package/build/components/combobox/combobox-group/combobox-group.d.ts +4 -0
  34. package/build/components/combobox/combobox-group/combobox-group.d.ts.map +1 -0
  35. package/build/components/combobox/combobox-group/combobox-group.js +15 -0
  36. package/build/components/combobox/combobox-group/index.d.ts +2 -0
  37. package/build/components/combobox/combobox-group/index.d.ts.map +1 -0
  38. package/build/components/combobox/combobox-group/index.js +1 -0
  39. package/build/components/combobox/combobox-input/combobox-input.d.ts +4 -0
  40. package/build/components/combobox/combobox-input/combobox-input.d.ts.map +1 -0
  41. package/build/components/combobox/combobox-input/combobox-input.js +101 -0
  42. package/build/components/combobox/combobox-input/index.d.ts +2 -0
  43. package/build/components/combobox/combobox-input/index.d.ts.map +1 -0
  44. package/build/components/combobox/combobox-input/index.js +1 -0
  45. package/build/components/combobox/combobox-option/combobox-option.d.ts +4 -0
  46. package/build/components/combobox/combobox-option/combobox-option.d.ts.map +1 -0
  47. package/build/components/combobox/combobox-option/combobox-option.js +86 -0
  48. package/build/components/combobox/combobox-option/index.d.ts +2 -0
  49. package/build/components/combobox/combobox-option/index.d.ts.map +1 -0
  50. package/build/components/combobox/combobox-option/index.js +1 -0
  51. package/build/components/combobox/combobox-root/combobox-root.d.ts +4 -0
  52. package/build/components/combobox/combobox-root/combobox-root.d.ts.map +1 -0
  53. package/build/components/combobox/combobox-root/combobox-root.js +282 -0
  54. package/build/components/combobox/combobox-root/index.d.ts +2 -0
  55. package/build/components/combobox/combobox-root/index.d.ts.map +1 -0
  56. package/build/components/combobox/combobox-root/index.js +1 -0
  57. package/build/components/combobox/combobox.context.d.ts +73 -0
  58. package/build/components/combobox/combobox.context.d.ts.map +1 -0
  59. package/build/components/combobox/combobox.context.js +50 -0
  60. package/build/components/combobox/combobox.d.ts +4 -0
  61. package/build/components/combobox/combobox.d.ts.map +1 -0
  62. package/build/components/combobox/combobox.js +31 -0
  63. package/build/components/combobox/combobox.test.d.ts +2 -0
  64. package/build/components/combobox/combobox.test.d.ts.map +1 -0
  65. package/build/components/combobox/combobox.test.js +104 -0
  66. package/build/components/combobox/combobox.types.d.ts +205 -0
  67. package/build/components/combobox/combobox.types.d.ts.map +1 -0
  68. package/build/components/combobox/combobox.types.js +1 -0
  69. package/build/components/combobox/index.d.ts +8 -0
  70. package/build/components/combobox/index.d.ts.map +1 -0
  71. package/build/components/combobox/index.js +6 -0
  72. package/build/components/combobox/use-combobox.d.ts +32 -0
  73. package/build/components/combobox/use-combobox.d.ts.map +1 -0
  74. package/build/components/combobox/use-combobox.js +80 -0
  75. package/build/components/drawer/drawer-body/drawer-body.d.ts +4 -0
  76. package/build/components/drawer/drawer-body/drawer-body.d.ts.map +1 -0
  77. package/build/components/drawer/drawer-body/drawer-body.js +11 -0
  78. package/build/components/drawer/drawer-body/index.d.ts +2 -0
  79. package/build/components/drawer/drawer-body/index.d.ts.map +1 -0
  80. package/build/components/drawer/drawer-body/index.js +1 -0
  81. package/build/components/drawer/drawer-content/drawer-content.d.ts.map +1 -1
  82. package/build/components/drawer/drawer-content/drawer-content.js +9 -6
  83. package/build/components/drawer/drawer-overlay/drawer-overlay.d.ts.map +1 -1
  84. package/build/components/drawer/drawer-overlay/drawer-overlay.js +4 -4
  85. package/build/components/drawer/drawer-root/drawer-root.d.ts.map +1 -1
  86. package/build/components/drawer/drawer-root/drawer-root.js +8 -9
  87. package/build/components/drawer/drawer.context.d.ts +2 -1
  88. package/build/components/drawer/drawer.context.d.ts.map +1 -1
  89. package/build/components/drawer/drawer.d.ts.map +1 -1
  90. package/build/components/drawer/drawer.js +5 -3
  91. package/build/components/drawer/drawer.test.js +55 -16
  92. package/build/components/drawer/drawer.types.d.ts +29 -3
  93. package/build/components/drawer/drawer.types.d.ts.map +1 -1
  94. package/build/components/drawer/index.d.ts +2 -1
  95. package/build/components/drawer/index.d.ts.map +1 -1
  96. package/build/components/drawer/index.js +1 -0
  97. package/build/components/drawer/use-drawer.d.ts +8 -1
  98. package/build/components/drawer/use-drawer.d.ts.map +1 -1
  99. package/build/components/drawer/use-drawer.js +25 -38
  100. package/build/components/file-input/file-input.d.ts +4 -0
  101. package/build/components/file-input/file-input.d.ts.map +1 -0
  102. package/build/components/file-input/file-input.js +88 -0
  103. package/build/components/file-input/file-input.test.d.ts +2 -0
  104. package/build/components/file-input/file-input.test.d.ts.map +1 -0
  105. package/build/components/file-input/file-input.test.js +74 -0
  106. package/build/components/file-input/file-input.types.d.ts +46 -0
  107. package/build/components/file-input/file-input.types.d.ts.map +1 -0
  108. package/build/components/file-input/file-input.types.js +1 -0
  109. package/build/components/file-input/file-input.utils.d.ts +11 -0
  110. package/build/components/file-input/file-input.utils.d.ts.map +1 -0
  111. package/build/components/file-input/file-input.utils.js +67 -0
  112. package/build/components/file-input/file-input.utils.test.d.ts +2 -0
  113. package/build/components/file-input/file-input.utils.test.d.ts.map +1 -0
  114. package/build/components/file-input/file-input.utils.test.js +27 -0
  115. package/build/components/file-input/index.d.ts +3 -0
  116. package/build/components/file-input/index.d.ts.map +1 -0
  117. package/build/components/file-input/index.js +2 -0
  118. package/build/components/for/for.d.ts +8 -0
  119. package/build/components/for/for.d.ts.map +1 -0
  120. package/build/components/for/for.js +32 -0
  121. package/build/components/for/for.test.d.ts +2 -0
  122. package/build/components/for/for.test.d.ts.map +1 -0
  123. package/build/components/for/for.test.js +31 -0
  124. package/build/components/for/for.types.d.ts +33 -0
  125. package/build/components/for/for.types.d.ts.map +1 -0
  126. package/build/components/for/for.types.js +1 -0
  127. package/build/components/for/index.d.ts +3 -0
  128. package/build/components/for/index.d.ts.map +1 -0
  129. package/build/components/for/index.js +1 -0
  130. package/build/components/index.d.ts +6 -0
  131. package/build/components/index.d.ts.map +1 -1
  132. package/build/components/index.js +6 -0
  133. package/build/components/modal/index.d.ts +2 -1
  134. package/build/components/modal/index.d.ts.map +1 -1
  135. package/build/components/modal/index.js +1 -0
  136. package/build/components/modal/modal-body/index.d.ts +2 -0
  137. package/build/components/modal/modal-body/index.d.ts.map +1 -0
  138. package/build/components/modal/modal-body/index.js +1 -0
  139. package/build/components/modal/modal-body/modal-body.d.ts +4 -0
  140. package/build/components/modal/modal-body/modal-body.d.ts.map +1 -0
  141. package/build/components/modal/modal-body/modal-body.js +11 -0
  142. package/build/components/modal/modal-content/modal-content.d.ts.map +1 -1
  143. package/build/components/modal/modal-content/modal-content.js +13 -5
  144. package/build/components/modal/modal-header/modal-header.js +2 -2
  145. package/build/components/modal/modal-overlay/modal-overlay.d.ts.map +1 -1
  146. package/build/components/modal/modal-overlay/modal-overlay.js +4 -4
  147. package/build/components/modal/modal-root/modal-root.d.ts.map +1 -1
  148. package/build/components/modal/modal-root/modal-root.js +12 -9
  149. package/build/components/modal/modal.context.d.ts +5 -2
  150. package/build/components/modal/modal.context.d.ts.map +1 -1
  151. package/build/components/modal/modal.d.ts.map +1 -1
  152. package/build/components/modal/modal.js +5 -3
  153. package/build/components/modal/modal.test.js +78 -13
  154. package/build/components/modal/modal.types.d.ts +34 -5
  155. package/build/components/modal/modal.types.d.ts.map +1 -1
  156. package/build/components/modal/use-modal.d.ts +8 -1
  157. package/build/components/modal/use-modal.d.ts.map +1 -1
  158. package/build/components/modal/use-modal.js +25 -38
  159. package/build/components/password-input/index.d.ts +3 -0
  160. package/build/components/password-input/index.d.ts.map +1 -0
  161. package/build/components/password-input/index.js +2 -0
  162. package/build/components/password-input/password-input.d.ts +4 -0
  163. package/build/components/password-input/password-input.d.ts.map +1 -0
  164. package/build/components/password-input/password-input.js +32 -0
  165. package/build/components/password-input/password-input.test.d.ts +2 -0
  166. package/build/components/password-input/password-input.test.d.ts.map +1 -0
  167. package/build/components/password-input/password-input.test.js +47 -0
  168. package/build/components/password-input/password-input.types.d.ts +24 -0
  169. package/build/components/password-input/password-input.types.d.ts.map +1 -0
  170. package/build/components/password-input/password-input.types.js +1 -0
  171. package/build/components/pin-input/index.d.ts +3 -0
  172. package/build/components/pin-input/index.d.ts.map +1 -0
  173. package/build/components/pin-input/index.js +2 -0
  174. package/build/components/pin-input/pin-input.d.ts +4 -0
  175. package/build/components/pin-input/pin-input.d.ts.map +1 -0
  176. package/build/components/pin-input/pin-input.js +245 -0
  177. package/build/components/pin-input/pin-input.test.d.ts +2 -0
  178. package/build/components/pin-input/pin-input.test.d.ts.map +1 -0
  179. package/build/components/pin-input/pin-input.test.js +87 -0
  180. package/build/components/pin-input/pin-input.types.d.ts +44 -0
  181. package/build/components/pin-input/pin-input.types.d.ts.map +1 -0
  182. package/build/components/pin-input/pin-input.types.js +1 -0
  183. package/build/components/scroll-area/index.d.ts +3 -0
  184. package/build/components/scroll-area/index.d.ts.map +1 -0
  185. package/build/components/scroll-area/index.js +1 -0
  186. package/build/components/scroll-area/scroll-area.d.ts +4 -0
  187. package/build/components/scroll-area/scroll-area.d.ts.map +1 -0
  188. package/build/components/scroll-area/scroll-area.js +30 -0
  189. package/build/components/scroll-area/scroll-area.test.d.ts +2 -0
  190. package/build/components/scroll-area/scroll-area.test.d.ts.map +1 -0
  191. package/build/components/scroll-area/scroll-area.test.js +39 -0
  192. package/build/components/scroll-area/scroll-area.types.d.ts +25 -0
  193. package/build/components/scroll-area/scroll-area.types.d.ts.map +1 -0
  194. package/build/components/scroll-area/scroll-area.types.js +1 -0
  195. package/build/components/segmented-control/segmented-control.d.ts.map +1 -1
  196. package/build/components/segmented-control/segmented-control.js +3 -3
  197. package/build/components/segmented-control/segmented-control.styles.js +13 -13
  198. package/build/components/segmented-control/segmented-control.test.js +11 -0
  199. package/build/components/segmented-control/segmented-control.types.d.ts +2 -0
  200. package/build/components/segmented-control/segmented-control.types.d.ts.map +1 -1
  201. package/build/icons/eye-off.d.ts +4 -0
  202. package/build/icons/eye-off.d.ts.map +1 -0
  203. package/build/icons/eye-off.js +5 -0
  204. package/build/icons/eye.d.ts +4 -0
  205. package/build/icons/eye.d.ts.map +1 -0
  206. package/build/icons/eye.js +5 -0
  207. package/build/icons/index.d.ts +2 -0
  208. package/build/icons/index.d.ts.map +1 -1
  209. package/build/icons/index.js +2 -0
  210. package/build/style.css +1 -1
  211. package/package.json +2 -2
  212. package/src/components/button/button.styles.ts +5 -5
  213. package/src/components/chip/chip-group/chip-group.tsx +107 -0
  214. package/src/components/chip/chip-group/index.ts +1 -0
  215. package/src/components/chip/chip.context.ts +15 -0
  216. package/src/components/chip/chip.styles.ts +36 -0
  217. package/src/components/chip/chip.test.tsx +197 -0
  218. package/src/components/chip/chip.tsx +208 -0
  219. package/src/components/chip/chip.types.ts +134 -0
  220. package/src/components/chip/index.ts +10 -0
  221. package/src/components/drawer/drawer-body/drawer-body.tsx +29 -0
  222. package/src/components/drawer/drawer-body/index.ts +1 -0
  223. package/src/components/drawer/drawer-content/drawer-content.tsx +63 -26
  224. package/src/components/drawer/drawer-overlay/drawer-overlay.tsx +6 -5
  225. package/src/components/drawer/drawer-root/drawer-root.tsx +17 -18
  226. package/src/components/drawer/drawer.context.ts +2 -1
  227. package/src/components/drawer/drawer.test.tsx +144 -36
  228. package/src/components/drawer/drawer.tsx +31 -3
  229. package/src/components/drawer/drawer.types.ts +37 -3
  230. package/src/components/drawer/index.ts +2 -0
  231. package/src/components/drawer/use-drawer.ts +44 -51
  232. package/src/components/file-input/file-input.test.tsx +134 -0
  233. package/src/components/file-input/file-input.tsx +224 -0
  234. package/src/components/file-input/file-input.types.ts +78 -0
  235. package/src/components/file-input/file-input.utils.test.ts +36 -0
  236. package/src/components/file-input/file-input.utils.ts +130 -0
  237. package/src/components/file-input/index.ts +2 -0
  238. package/src/components/for/for.test.tsx +66 -0
  239. package/src/components/for/for.tsx +53 -0
  240. package/src/components/for/for.types.ts +40 -0
  241. package/src/components/for/index.ts +2 -0
  242. package/src/components/index.ts +6 -0
  243. package/src/components/menu/menu-dropdown/menu-dropdown.tsx +220 -220
  244. package/src/components/menu/menu-sub-dropdown/menu-sub-dropdown.tsx +221 -221
  245. package/src/components/modal/index.ts +4 -1
  246. package/src/components/modal/modal-body/index.ts +1 -0
  247. package/src/components/modal/modal-body/modal-body.tsx +29 -0
  248. package/src/components/modal/modal-content/modal-content.tsx +71 -24
  249. package/src/components/modal/modal-header/modal-header.tsx +2 -2
  250. package/src/components/modal/modal-overlay/modal-overlay.tsx +46 -45
  251. package/src/components/modal/modal-root/modal-root.tsx +22 -17
  252. package/src/components/modal/modal.context.ts +5 -2
  253. package/src/components/modal/modal.test.tsx +234 -64
  254. package/src/components/modal/modal.tsx +36 -4
  255. package/src/components/modal/modal.types.ts +49 -8
  256. package/src/components/modal/use-modal.ts +44 -51
  257. package/src/components/password-input/index.ts +2 -0
  258. package/src/components/password-input/password-input.test.tsx +72 -0
  259. package/src/components/password-input/password-input.tsx +85 -0
  260. package/src/components/password-input/password-input.types.ts +30 -0
  261. package/src/components/pin-input/index.ts +2 -0
  262. package/src/components/pin-input/pin-input.test.tsx +149 -0
  263. package/src/components/pin-input/pin-input.tsx +473 -0
  264. package/src/components/pin-input/pin-input.types.ts +78 -0
  265. package/src/components/scroll-area/index.ts +6 -0
  266. package/src/components/scroll-area/scroll-area.test.tsx +72 -0
  267. package/src/components/scroll-area/scroll-area.tsx +70 -0
  268. package/src/components/scroll-area/scroll-area.types.ts +37 -0
  269. package/src/components/segmented-control/segmented-control.styles.ts +13 -13
  270. package/src/components/segmented-control/segmented-control.test.tsx +18 -0
  271. package/src/components/segmented-control/segmented-control.tsx +11 -1
  272. package/src/components/segmented-control/segmented-control.types.ts +3 -0
  273. package/src/components/select/select-dropdown/select-dropdown.tsx +299 -299
  274. package/src/components/select/select-root/select-root.tsx +333 -333
  275. package/src/components/select/select-trigger/select-trigger.tsx +123 -123
  276. package/src/components/select/select.context.ts +140 -140
  277. package/src/components/select/select.test.tsx +190 -190
  278. package/src/components/select/select.types.ts +272 -272
  279. package/src/components/select/use-select.ts +170 -170
  280. package/src/icons/eye-off.tsx +30 -0
  281. package/src/icons/eye.tsx +24 -0
  282. package/src/icons/index.ts +2 -0
  283. package/src/style.css +14 -8
  284. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"password-input.types.d.ts","sourceRoot":"","sources":["../../../src/components/password-input/password-input.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC;IAChE,mEAAmE;IACnE,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAE/B,gCAAgC;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,+BAA+B;IAC/B,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB,8CAA8C;IAC9C,kBAAkB,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAEhD,yEAAyE;IACzE,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B,wEAAwE;IACxE,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,2BAA4B,SAAQ,cAAc;IAC/D,KAAK,EAAE,kBAAkB,CAAC;IAC1B,GAAG,EAAE,gBAAgB,CAAC;IACtB,QAAQ,EAAE;QACN,SAAS,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,kBAAkB,CAAC,CAAC,CAAC;KAC3E,CAAC;CACL"}
@@ -0,0 +1,3 @@
1
+ export { default as PinInput } from "./pin-input";
2
+ export * from "./pin-input.types";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/pin-input/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,aAAa,CAAC;AAClD,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { default as PinInput } from "./pin-input";
2
+ export * from "./pin-input.types";
@@ -0,0 +1,4 @@
1
+ import { PinInputFactoryPayload } from "./pin-input.types";
2
+ declare const PinInput: import("../..").RefraktorComponent<PinInputFactoryPayload>;
3
+ export default PinInput;
4
+ //# sourceMappingURL=pin-input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pin-input.d.ts","sourceRoot":"","sources":["../../../src/components/pin-input/pin-input.tsx"],"names":[],"mappings":"AAYA,OAAO,EAGH,sBAAsB,EAGzB,MAAM,mBAAmB,CAAC;AAyG3B,QAAA,MAAM,QAAQ,4DAuVZ,CAAC;AAMH,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,245 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useId, useUncontrolled } from "@refraktor/utils";
3
+ import { useCallback, useMemo, useRef } from "react";
4
+ import { useTheme } from "../../theme";
5
+ import { createClassNamesConfig, createComponentConfig, factory, useClassNames, useProps } from "../../utils";
6
+ import { getVariant } from "../input/input-field/input-field.styles";
7
+ import { InputWrapper } from "../input/input-wrapper";
8
+ const CHARACTER_SET_PATTERNS = {
9
+ numeric: /^[0-9]$/,
10
+ alphabetic: /^[A-Za-z]$/,
11
+ alphanumeric: /^[A-Za-z0-9]$/,
12
+ all: /^.$/
13
+ };
14
+ const CELL_SIZES = {
15
+ xs: "h-7 w-7 text-[10px]",
16
+ sm: "h-8 w-8 text-xs",
17
+ md: "h-10 w-10 text-sm",
18
+ lg: "h-12 w-12 text-base",
19
+ xl: "h-14 w-14 text-lg"
20
+ };
21
+ const defaultProps = {
22
+ length: 6,
23
+ variant: "default",
24
+ size: "md",
25
+ radius: "default",
26
+ mask: false,
27
+ characterSet: "numeric",
28
+ transform: "none",
29
+ ariaLabelPrefix: "Character",
30
+ autoComplete: "one-time-code"
31
+ };
32
+ function normalizeLength(value) {
33
+ const length = Number.isFinite(value) ? Math.trunc(value) : 6;
34
+ return Math.max(1, length);
35
+ }
36
+ function transformCharacter(char, transform) {
37
+ if (transform === "uppercase") {
38
+ return char.toUpperCase();
39
+ }
40
+ if (transform === "lowercase") {
41
+ return char.toLowerCase();
42
+ }
43
+ return char;
44
+ }
45
+ function isAllowedCharacter(char, characterSet, characterPattern) {
46
+ const pattern = characterPattern ?? CHARACTER_SET_PATTERNS[characterSet];
47
+ pattern.lastIndex = 0;
48
+ return pattern.test(char);
49
+ }
50
+ function toSanitizedChars(value, options) {
51
+ const result = [];
52
+ for (const rawChar of value) {
53
+ const transformedChar = transformCharacter(rawChar, options.transform);
54
+ if (transformedChar &&
55
+ isAllowedCharacter(transformedChar, options.characterSet, options.characterPattern)) {
56
+ result.push(transformedChar);
57
+ }
58
+ }
59
+ return result;
60
+ }
61
+ function toCellArray(value, length, options) {
62
+ const chars = toSanitizedChars(value, options).slice(0, length);
63
+ return Array.from({ length }, (_, index) => chars[index] ?? "");
64
+ }
65
+ function normalizeCells(cells, length) {
66
+ return Array.from({ length }, (_, index) => cells?.[index] ?? "");
67
+ }
68
+ const PinInput = factory((_props, ref) => {
69
+ const { cx, getRadius } = useTheme();
70
+ const { id, label, description, error, required, withAsterisk, length, value, defaultValue, onChange, onComplete, mask, characterSet, characterPattern, transform, ariaLabelPrefix, name, variant, size, radius, disabled, className, classNames, inputMode, autoComplete, placeholder, ...props } = useProps("PinInput", defaultProps, _props);
71
+ const classes = useClassNames("PinInput", classNames);
72
+ const _id = useId(id);
73
+ const resolvedLength = normalizeLength(length);
74
+ const sanitizingOptions = useMemo(() => ({
75
+ characterSet,
76
+ characterPattern,
77
+ transform
78
+ }), [characterSet, characterPattern, transform]);
79
+ const emptyCells = useMemo(() => Array.from({ length: resolvedLength }, () => ""), [resolvedLength]);
80
+ const [_valueCells, setValueCells] = useUncontrolled({
81
+ value: value === undefined
82
+ ? undefined
83
+ : toCellArray(String(value), resolvedLength, sanitizingOptions),
84
+ defaultValue: defaultValue === undefined
85
+ ? undefined
86
+ : toCellArray(String(defaultValue), resolvedLength, sanitizingOptions),
87
+ finalValue: emptyCells,
88
+ onChange: (nextCells) => onChange?.(nextCells.join(""))
89
+ });
90
+ const chars = useMemo(() => normalizeCells(_valueCells, resolvedLength), [_valueCells, resolvedLength]);
91
+ const charsRef = useRef(chars);
92
+ charsRef.current = chars;
93
+ const completedValueRef = useRef(null);
94
+ const inputRefs = useRef([]);
95
+ const hasWrapper = label || description || error;
96
+ const describedBy = error
97
+ ? `${_id}-error`
98
+ : description
99
+ ? `${_id}-description`
100
+ : undefined;
101
+ const resolvedInputMode = inputMode ?? (characterSet === "numeric" ? "numeric" : "text");
102
+ const emitValue = useCallback((nextChars) => {
103
+ setValueCells(nextChars);
104
+ const nextValue = nextChars.join("");
105
+ if (!nextChars.includes("")) {
106
+ if (completedValueRef.current !== nextValue) {
107
+ onComplete?.(nextValue);
108
+ completedValueRef.current = nextValue;
109
+ }
110
+ }
111
+ else {
112
+ completedValueRef.current = null;
113
+ }
114
+ }, [onComplete, setValueCells]);
115
+ const focusCell = useCallback((index) => {
116
+ if (index < 0 || index >= resolvedLength) {
117
+ return;
118
+ }
119
+ setTimeout(() => {
120
+ const input = inputRefs.current[index];
121
+ if (!input) {
122
+ return;
123
+ }
124
+ input.focus();
125
+ input.select();
126
+ }, 0);
127
+ }, [resolvedLength]);
128
+ const fillFromIndex = useCallback((index, incoming) => {
129
+ const next = [...charsRef.current];
130
+ let writeIndex = index;
131
+ for (const char of incoming) {
132
+ if (writeIndex >= resolvedLength) {
133
+ break;
134
+ }
135
+ next[writeIndex] = char;
136
+ writeIndex += 1;
137
+ }
138
+ emitValue(next);
139
+ if (writeIndex < resolvedLength) {
140
+ focusCell(writeIndex);
141
+ return;
142
+ }
143
+ focusCell(resolvedLength - 1);
144
+ }, [emitValue, focusCell, resolvedLength]);
145
+ const handleCellChange = useCallback((index, event) => {
146
+ if (disabled) {
147
+ return;
148
+ }
149
+ const incoming = toSanitizedChars(event.currentTarget.value, sanitizingOptions);
150
+ if (incoming.length === 0) {
151
+ if (event.currentTarget.value !== "") {
152
+ return;
153
+ }
154
+ const next = [...charsRef.current];
155
+ next[index] = "";
156
+ emitValue(next);
157
+ return;
158
+ }
159
+ if (incoming.length === 1) {
160
+ const next = [...charsRef.current];
161
+ next[index] = incoming[0];
162
+ emitValue(next);
163
+ if (index < resolvedLength - 1) {
164
+ focusCell(index + 1);
165
+ }
166
+ return;
167
+ }
168
+ fillFromIndex(index, incoming);
169
+ }, [
170
+ disabled,
171
+ sanitizingOptions,
172
+ emitValue,
173
+ resolvedLength,
174
+ focusCell,
175
+ fillFromIndex
176
+ ]);
177
+ const handlePaste = useCallback((index, event) => {
178
+ event.preventDefault();
179
+ if (disabled) {
180
+ return;
181
+ }
182
+ const incoming = toSanitizedChars(event.clipboardData.getData("text"), sanitizingOptions);
183
+ if (incoming.length === 0) {
184
+ return;
185
+ }
186
+ fillFromIndex(index, incoming);
187
+ }, [disabled, sanitizingOptions, fillFromIndex]);
188
+ const handleKeyDown = useCallback((index, event) => {
189
+ if (disabled) {
190
+ return;
191
+ }
192
+ if (event.key === "ArrowLeft") {
193
+ event.preventDefault();
194
+ focusCell(index - 1);
195
+ return;
196
+ }
197
+ if (event.key === "ArrowRight") {
198
+ event.preventDefault();
199
+ focusCell(index + 1);
200
+ return;
201
+ }
202
+ if (event.key === "Home") {
203
+ event.preventDefault();
204
+ focusCell(0);
205
+ return;
206
+ }
207
+ if (event.key === "End") {
208
+ event.preventDefault();
209
+ focusCell(resolvedLength - 1);
210
+ return;
211
+ }
212
+ if (event.key === "Backspace") {
213
+ event.preventDefault();
214
+ const next = [...charsRef.current];
215
+ if (next[index]) {
216
+ next[index] = "";
217
+ emitValue(next);
218
+ return;
219
+ }
220
+ if (index > 0) {
221
+ next[index - 1] = "";
222
+ emitValue(next);
223
+ focusCell(index - 1);
224
+ }
225
+ return;
226
+ }
227
+ if (event.key === "Delete") {
228
+ event.preventDefault();
229
+ const next = [...charsRef.current];
230
+ next[index] = "";
231
+ emitValue(next);
232
+ }
233
+ }, [disabled, emitValue, focusCell, resolvedLength]);
234
+ const field = (_jsxs("div", { ref: ref, className: cx("flex w-full items-center gap-2", className, classes.root), children: [chars.map((char, index) => (_jsx("input", { ...props, id: `${_id}-${index}`, ref: (node) => {
235
+ inputRefs.current[index] = node;
236
+ }, type: mask ? "password" : "text", inputMode: resolvedInputMode, autoComplete: index === 0 ? autoComplete : "off", maxLength: resolvedLength, value: char, disabled: disabled, required: required && index === 0, placeholder: placeholder, "aria-invalid": error ? true : undefined, "aria-describedby": describedBy, "aria-label": `${ariaLabelPrefix} ${index + 1} of ${resolvedLength}`, className: cx("flex-none text-center font-medium tabular-nums outline-none transition-colors", "focus:border-[var(--refraktor-primary)]", getVariant(variant), getRadius(radius), CELL_SIZES[size], error && "border-[var(--refraktor-colors-red-6)]", disabled && "cursor-not-allowed opacity-50", classes.cell), onChange: (event) => handleCellChange(index, event), onKeyDown: (event) => handleKeyDown(index, event), onPaste: (event) => handlePaste(index, event), onFocus: (event) => event.currentTarget.select() }, `${_id}-cell-${index}`))), name && _jsx("input", { type: "hidden", name: name, value: chars.join("") })] }));
237
+ if (!hasWrapper) {
238
+ return field;
239
+ }
240
+ return (_jsx(InputWrapper, { label: label, description: description, error: error, required: required, withAsterisk: withAsterisk, inputId: `${_id}-0`, children: field }));
241
+ });
242
+ PinInput.displayName = "@refraktor/core/PinInput";
243
+ PinInput.configure = createComponentConfig();
244
+ PinInput.classNames = createClassNamesConfig();
245
+ export default PinInput;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=pin-input.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pin-input.test.d.ts","sourceRoot":"","sources":["../../../src/components/pin-input/pin-input.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,87 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { describe, expect, it, vi } from "vitest";
4
+ import { render, screen, userEvent } from "../../vitest";
5
+ import PinInput from "./pin-input";
6
+ const getCells = (length) => Array.from({ length }, (_, index) => screen.getByLabelText(`Character ${index + 1} of ${length}`));
7
+ describe("@refraktor/core/PinInput", () => {
8
+ it("supports input wrapper props", async () => {
9
+ await render(_jsx(PinInput, { label: "Verification code", description: "Enter the code from your authenticator app", error: "Code is required" }));
10
+ const firstCell = screen.getByLabelText("Verification code");
11
+ expect(firstCell).toHaveAttribute("aria-invalid", "true");
12
+ expect(screen.getByText("Enter the code from your authenticator app")).toBeInTheDocument();
13
+ expect(screen.getByText("Code is required")).toBeInTheDocument();
14
+ });
15
+ it("auto-advances focus and fires onComplete", async () => {
16
+ const user = userEvent.setup();
17
+ const onComplete = vi.fn();
18
+ await render(_jsx(PinInput, { length: 4, onComplete: onComplete }));
19
+ const cells = getCells(4);
20
+ await user.type(cells[0], "1");
21
+ expect(cells[1]).toHaveFocus();
22
+ await user.type(cells[1], "2");
23
+ await user.type(cells[2], "3");
24
+ await user.type(cells[3], "4");
25
+ expect(onComplete).toHaveBeenCalledTimes(1);
26
+ expect(onComplete).toHaveBeenCalledWith("1234");
27
+ });
28
+ it("handles backspace navigation", async () => {
29
+ const user = userEvent.setup();
30
+ await render(_jsx(PinInput, { length: 4 }));
31
+ const cells = getCells(4);
32
+ await user.type(cells[0], "1");
33
+ await user.type(cells[1], "2");
34
+ expect(cells[2]).toHaveFocus();
35
+ await user.keyboard("{Backspace}");
36
+ expect(cells[1]).toHaveFocus();
37
+ expect(cells[1]).toHaveValue("");
38
+ });
39
+ it("handles paste across cells", async () => {
40
+ const user = userEvent.setup();
41
+ await render(_jsx(PinInput, { length: 6, characterSet: "alphanumeric" }));
42
+ const cells = getCells(6);
43
+ cells[0].focus();
44
+ await user.paste("A1B2C3");
45
+ expect(cells.map((cell) => cell.value)).toEqual([
46
+ "A",
47
+ "1",
48
+ "B",
49
+ "2",
50
+ "C",
51
+ "3"
52
+ ]);
53
+ });
54
+ it("supports alphanumeric and custom filtering props", async () => {
55
+ const user = userEvent.setup();
56
+ await render(_jsx(PinInput, { length: 4, characterPattern: /[A-F0-9]/, transform: "uppercase" }));
57
+ const cells = getCells(4);
58
+ await user.type(cells[0], "a");
59
+ await user.type(cells[1], "g");
60
+ await user.type(cells[1], "9");
61
+ expect(cells[0]).toHaveValue("A");
62
+ expect(cells[1]).toHaveValue("9");
63
+ });
64
+ it("supports controlled usage", async () => {
65
+ const user = userEvent.setup();
66
+ function Demo() {
67
+ const [value, setValue] = useState("");
68
+ return _jsx(PinInput, { length: 4, value: value, onChange: setValue });
69
+ }
70
+ await render(_jsx(Demo, {}));
71
+ const cells = getCells(4);
72
+ await user.type(cells[0], "1");
73
+ await user.type(cells[1], "2");
74
+ expect(cells[0]).toHaveValue("1");
75
+ expect(cells[1]).toHaveValue("2");
76
+ });
77
+ it("supports masking and hidden form value", async () => {
78
+ await render(_jsx(PinInput, { length: 4, defaultValue: "A1B2", characterSet: "alphanumeric", mask: true, name: "otp" }));
79
+ const cells = getCells(4);
80
+ for (const cell of cells) {
81
+ expect(cell).toHaveAttribute("type", "password");
82
+ }
83
+ const hidden = document.querySelector('input[type="hidden"][name="otp"]');
84
+ expect(hidden).not.toBeNull();
85
+ expect(hidden?.value).toBe("A1B2");
86
+ });
87
+ });
@@ -0,0 +1,44 @@
1
+ import { createClassNamesConfig, createComponentConfig, FactoryPayload } from "../../utils";
2
+ import { InputProps } from "../input";
3
+ export type PinInputCharacterSet = "numeric" | "alphabetic" | "alphanumeric" | "all";
4
+ export type PinInputTransform = "none" | "uppercase" | "lowercase";
5
+ export type PinInputClassNames = {
6
+ root?: string;
7
+ cell?: string;
8
+ };
9
+ export interface _PinInputProps {
10
+ /** OTP length @default `6` */
11
+ length?: number;
12
+ /** Value (controlled) */
13
+ value?: string;
14
+ /** Default value (uncontrolled) */
15
+ defaultValue?: string;
16
+ /** Callback called whenever the code value changes */
17
+ onChange?: (value: string) => void;
18
+ /** Callback called when all cells are filled */
19
+ onComplete?: (value: string) => void;
20
+ /** Masks entered characters @default `false` */
21
+ mask?: boolean;
22
+ /** Character set filter @default `numeric` */
23
+ characterSet?: PinInputCharacterSet;
24
+ /** Optional custom character pattern (overrides characterSet) */
25
+ characterPattern?: RegExp;
26
+ /** Character transform @default `none` */
27
+ transform?: PinInputTransform;
28
+ /** Accessible label prefix for each cell @default `Character` */
29
+ ariaLabelPrefix?: string;
30
+ /** Hidden input name for form submission */
31
+ name?: string;
32
+ /** Used for styling different parts of the component */
33
+ classNames?: PinInputClassNames;
34
+ }
35
+ export type PinInputProps = _PinInputProps & Omit<InputProps, "type" | "value" | "defaultValue" | "onChange" | "leftSection" | "rightSection" | "maxLength">;
36
+ export interface PinInputFactoryPayload extends FactoryPayload {
37
+ props: PinInputProps;
38
+ ref: HTMLDivElement;
39
+ compound: {
40
+ configure: ReturnType<typeof createComponentConfig<PinInputProps>>;
41
+ classNames: ReturnType<typeof createClassNamesConfig<PinInputClassNames>>;
42
+ };
43
+ }
44
+ //# sourceMappingURL=pin-input.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pin-input.types.d.ts","sourceRoot":"","sources":["../../../src/components/pin-input/pin-input.types.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,sBAAsB,EACtB,qBAAqB,EACrB,cAAc,EACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,MAAM,MAAM,oBAAoB,GAC1B,SAAS,GACT,YAAY,GACZ,cAAc,GACd,KAAK,CAAC;AAEZ,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,WAAW,GAAG,WAAW,CAAC;AAEnE,MAAM,MAAM,kBAAkB,GAAG;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,WAAW,cAAc;IAC3B,8BAA8B;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,yBAAyB;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,mCAAmC;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,sDAAsD;IACtD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAEnC,gDAAgD;IAChD,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAErC,gDAAgD;IAChD,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf,8CAA8C;IAC9C,YAAY,CAAC,EAAE,oBAAoB,CAAC;IAEpC,iEAAiE;IACjE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,0CAA0C;IAC1C,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAE9B,iEAAiE;IACjE,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,4CAA4C;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,wDAAwD;IACxD,UAAU,CAAC,EAAE,kBAAkB,CAAC;CACnC;AAED,MAAM,MAAM,aAAa,GAAG,cAAc,GACtC,IAAI,CACA,UAAU,EACR,MAAM,GACN,OAAO,GACP,cAAc,GACd,UAAU,GACV,aAAa,GACb,cAAc,GACd,WAAW,CAChB,CAAC;AAEN,MAAM,WAAW,sBAAuB,SAAQ,cAAc;IAC1D,KAAK,EAAE,aAAa,CAAC;IACrB,GAAG,EAAE,cAAc,CAAC;IACpB,QAAQ,EAAE;QACN,SAAS,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,aAAa,CAAC,CAAC,CAAC;QACnE,UAAU,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC,kBAAkB,CAAC,CAAC,CAAC;KAC7E,CAAC;CACL"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ export { default as ScrollArea } from "./scroll-area";
2
+ export type { ScrollAreaProps, ScrollAreaClassNames, ScrollAreaOrientation } from "./scroll-area.types";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/scroll-area/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC;AACtD,YAAY,EACR,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACxB,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1 @@
1
+ export { default as ScrollArea } from "./scroll-area";
@@ -0,0 +1,4 @@
1
+ import type { ScrollAreaFactoryPayload } from "./scroll-area.types";
2
+ declare const ScrollArea: import("../..").RefraktorComponent<ScrollAreaFactoryPayload>;
3
+ export default ScrollArea;
4
+ //# sourceMappingURL=scroll-area.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scroll-area.d.ts","sourceRoot":"","sources":["../../../src/components/scroll-area/scroll-area.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAER,wBAAwB,EAG3B,MAAM,qBAAqB,CAAC;AAoB7B,QAAA,MAAM,UAAU,8DA8Bd,CAAC;AAMH,eAAe,UAAU,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createClassNamesConfig, createComponentConfig, factory, useClassNames, useProps } from "../../utils";
3
+ import { useTheme } from "../../theme";
4
+ const defaultProps = {
5
+ orientation: "vertical",
6
+ scrollbarSize: 6
7
+ };
8
+ function getOrientationStyles(orientation) {
9
+ if (orientation === "horizontal") {
10
+ return "overflow-x-auto overflow-y-hidden";
11
+ }
12
+ if (orientation === "both") {
13
+ return "overflow-auto";
14
+ }
15
+ return "overflow-y-auto overflow-x-hidden";
16
+ }
17
+ const ScrollArea = factory((_props, ref) => {
18
+ const { cx } = useTheme();
19
+ const { orientation, scrollbarSize, className, classNames, style, ...props } = useProps("ScrollArea", defaultProps, _props);
20
+ const classes = useClassNames("ScrollArea", classNames);
21
+ const resolvedStyle = {
22
+ ...(style ?? {}),
23
+ "--refraktor-scrollbar-size": `${scrollbarSize}px`
24
+ };
25
+ return (_jsx("div", { ref: ref, className: cx("refraktor-scrollbar", getOrientationStyles(orientation), classes.root, className), style: resolvedStyle, ...props }));
26
+ });
27
+ ScrollArea.displayName = "@refraktor/core/ScrollArea";
28
+ ScrollArea.configure = createComponentConfig();
29
+ ScrollArea.classNames = createClassNamesConfig();
30
+ export default ScrollArea;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=scroll-area.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scroll-area.test.d.ts","sourceRoot":"","sources":["../../../src/components/scroll-area/scroll-area.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,39 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createRef } from "react";
3
+ import { describe, expect, it } from "vitest";
4
+ import { render, screen } from "../../vitest";
5
+ import ScrollArea from "./scroll-area";
6
+ describe("@refraktor/core/ScrollArea", () => {
7
+ it("renders children with default vertical scroll behavior", async () => {
8
+ await render(_jsx(ScrollArea, { "data-testid": "scroll-area", children: _jsx("div", { children: "Content" }) }));
9
+ const scrollArea = screen.getByTestId("scroll-area");
10
+ expect(scrollArea).toHaveClass("refraktor-scrollbar");
11
+ expect(scrollArea).toHaveClass("overflow-y-auto");
12
+ expect(scrollArea).toHaveClass("overflow-x-hidden");
13
+ expect(scrollArea).toHaveTextContent("Content");
14
+ });
15
+ it("supports horizontal and bidirectional orientation", async () => {
16
+ const { rerender } = await render(_jsx(ScrollArea, { "data-testid": "scroll-area", orientation: "horizontal" }));
17
+ expect(screen.getByTestId("scroll-area")).toHaveClass("overflow-x-auto");
18
+ expect(screen.getByTestId("scroll-area")).toHaveClass("overflow-y-hidden");
19
+ rerender(_jsx(ScrollArea, { "data-testid": "scroll-area", orientation: "both" }));
20
+ expect(screen.getByTestId("scroll-area")).toHaveClass("overflow-auto");
21
+ });
22
+ it("applies scrollbar size css variable", async () => {
23
+ await render(_jsx(ScrollArea, { "data-testid": "scroll-area", scrollbarSize: 10 }));
24
+ const scrollArea = screen.getByTestId("scroll-area");
25
+ expect(scrollArea.style.getPropertyValue("--refraktor-scrollbar-size")).toBe("10px");
26
+ });
27
+ it("supports root and slot class names", async () => {
28
+ await render(_jsx(ScrollArea, { "data-testid": "scroll-area", className: "custom-root", classNames: { root: "slot-root" } }));
29
+ const scrollArea = screen.getByTestId("scroll-area");
30
+ expect(scrollArea).toHaveClass("custom-root");
31
+ expect(scrollArea).toHaveClass("slot-root");
32
+ });
33
+ it("forwards ref to root element", async () => {
34
+ const ref = createRef();
35
+ await render(_jsx(ScrollArea, { ref: ref }));
36
+ expect(ref.current).toBeInstanceOf(HTMLDivElement);
37
+ expect(ref.current?.tagName).toBe("DIV");
38
+ });
39
+ });
@@ -0,0 +1,25 @@
1
+ import { ComponentPropsWithoutRef } from "react";
2
+ import { createClassNamesConfig, createComponentConfig, FactoryPayload } from "../../utils";
3
+ export type ScrollAreaOrientation = "vertical" | "horizontal" | "both";
4
+ export type ScrollAreaClassNames = {
5
+ root?: string;
6
+ };
7
+ export interface ScrollAreaProps extends ComponentPropsWithoutRef<"div"> {
8
+ /** Scroll direction behavior @default `vertical` */
9
+ orientation?: ScrollAreaOrientation;
10
+ /** Scrollbar thickness in pixels @default `6` */
11
+ scrollbarSize?: number;
12
+ /** Used for editing root class name */
13
+ className?: string;
14
+ /** Used for styling different parts of the component */
15
+ classNames?: ScrollAreaClassNames;
16
+ }
17
+ export interface ScrollAreaFactoryPayload extends FactoryPayload {
18
+ props: ScrollAreaProps;
19
+ ref: HTMLDivElement;
20
+ compound: {
21
+ configure: ReturnType<typeof createComponentConfig<ScrollAreaProps>>;
22
+ classNames: ReturnType<typeof createClassNamesConfig<ScrollAreaClassNames>>;
23
+ };
24
+ }
25
+ //# sourceMappingURL=scroll-area.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scroll-area.types.d.ts","sourceRoot":"","sources":["../../../src/components/scroll-area/scroll-area.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EACH,sBAAsB,EACtB,qBAAqB,EACrB,cAAc,EACjB,MAAM,aAAa,CAAC;AAErB,MAAM,MAAM,qBAAqB,GAAG,UAAU,GAAG,YAAY,GAAG,MAAM,CAAC;AAEvE,MAAM,MAAM,oBAAoB,GAAG;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,WAAW,eAAgB,SAAQ,wBAAwB,CAAC,KAAK,CAAC;IACpE,oDAAoD;IACpD,WAAW,CAAC,EAAE,qBAAqB,CAAC;IAEpC,iDAAiD;IACjD,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,uCAAuC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,wDAAwD;IACxD,UAAU,CAAC,EAAE,oBAAoB,CAAC;CACrC;AAED,MAAM,WAAW,wBAAyB,SAAQ,cAAc;IAC5D,KAAK,EAAE,eAAe,CAAC;IACvB,GAAG,EAAE,cAAc,CAAC;IACpB,QAAQ,EAAE;QACN,SAAS,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,eAAe,CAAC,CAAC,CAAC;QACrE,UAAU,EAAE,UAAU,CAClB,OAAO,sBAAsB,CAAC,oBAAoB,CAAC,CACtD,CAAC;KACL,CAAC;CACL"}
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +1 @@
1
- {"version":3,"file":"segmented-control.d.ts","sourceRoot":"","sources":["../../../src/components/segmented-control/segmented-control.tsx"],"names":[],"mappings":"AAWA,OAAO,EAEH,8BAA8B,EAEjC,MAAM,2BAA2B,CAAC;AASnC,QAAA,MAAM,gBAAgB,oEAqNrB,CAAC;AAOF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"segmented-control.d.ts","sourceRoot":"","sources":["../../../src/components/segmented-control/segmented-control.tsx"],"names":[],"mappings":"AAWA,OAAO,EAEH,8BAA8B,EAEjC,MAAM,2BAA2B,CAAC;AASnC,QAAA,MAAM,gBAAgB,oEA+NrB,CAAC;AAOF,eAAe,gBAAgB,CAAC"}
@@ -97,13 +97,13 @@ const SegmentedControl = factory((_props, ref) => {
97
97
  return (_jsxs("div", { ref: ref, id: _id, role: "radiogroup", "data-disabled": disabled, "aria-disabled": disabled, className: cx("relative inline-flex items-stretch border border-[var(--refraktor-border)]", "bg-[var(--refraktor-bg-subtle)]", "data-[disabled=true]:opacity-50", fullWidth && "w-full", sizeStyles.root, getRadius(radius), classes.root, className), ...props, children: [data.map((item, index) => {
98
98
  const isActive = item.value === selectedValue;
99
99
  const isControlDisabled = !!(disabled || item.disabled);
100
- return (_jsx("button", { ref: (node) => {
100
+ return (_jsxs("button", { ref: (node) => {
101
101
  controlRefs.current[index] = node;
102
102
  }, type: "button", role: "radio", id: `${_id}-control-${index}`, "aria-checked": isActive, "aria-disabled": isControlDisabled, "data-active": isActive, "data-disabled": isControlDisabled, disabled: isControlDisabled, tabIndex: isControlDisabled || tabStopIndex !== index
103
103
  ? -1
104
- : 0, className: cx("relative inline-flex items-center justify-center whitespace-nowrap select-none outline-none transition-colors", "focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--refraktor-primary)]", "data-[disabled=true]:opacity-50 data-[disabled=true]:pointer-events-none data-[disabled=true]:cursor-not-allowed", fullWidth && "flex-1", sizeStyles.control, sizeStyles.label, getRadius(radius), isActive
104
+ : 0, className: cx("relative inline-flex items-center justify-center whitespace-nowrap select-none outline-none transition-colors cursor-pointer", "focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--refraktor-primary)]", "data-[disabled=true]:opacity-50 data-[disabled=true]:pointer-events-none data-[disabled=true]:cursor-not-allowed", item.icon && "gap-1.5", fullWidth && "flex-1", sizeStyles.control, sizeStyles.label, getRadius(radius), isActive
105
105
  ? "bg-[var(--refraktor-primary)] text-[var(--refraktor-primary-text)]"
106
- : "text-[var(--refraktor-text-secondary)] hover:bg-[var(--refraktor-bg-hover)] hover:text-[var(--refraktor-text)]", classes.control), onClick: () => selectByIndex(index), onKeyDown: (event) => handleKeyDown(event, index, isControlDisabled), children: _jsx("span", { className: cx("leading-none", classes.label), children: item.label }) }, item.value));
106
+ : "text-[var(--refraktor-text-secondary)] hover:bg-[var(--refraktor-bg-hover)] hover:text-[var(--refraktor-text)]", classes.control), onClick: () => selectByIndex(index), onKeyDown: (event) => handleKeyDown(event, index, isControlDisabled), children: [item.icon && (_jsx("span", { "aria-hidden": "true", className: "inline-flex shrink-0 leading-none", children: item.icon })), _jsx("span", { className: cx("leading-none", classes.label), children: item.label })] }, item.value));
107
107
  }), name && (_jsx("input", { type: "hidden", name: name, value: selectedValue }))] }));
108
108
  });
109
109
  SegmentedControl.displayName = "@refraktor/core/SegmentedControl";
@@ -1,28 +1,28 @@
1
1
  const sizes = {
2
2
  xs: {
3
3
  root: "p-0.5 gap-0.5",
4
- control: "h-6 px-2 min-w-7",
5
- label: "text-[10px]"
4
+ control: "h-4 px-2 min-w-6",
5
+ label: "text-[8px]"
6
6
  },
7
7
  sm: {
8
8
  root: "p-0.5 gap-0.5",
9
- control: "h-7 px-2.5 min-w-8",
10
- label: "text-xs"
9
+ control: "h-5 px-2.5 min-w-7",
10
+ label: "text-[10px]"
11
11
  },
12
12
  md: {
13
- root: "p-1 gap-1",
14
- control: "h-8 px-3 min-w-9",
15
- label: "text-sm"
13
+ root: "p-0.5 gap-0.5",
14
+ control: "h-7 px-3 min-w-8",
15
+ label: "text-xs"
16
16
  },
17
17
  lg: {
18
- root: "p-1 gap-1",
19
- control: "h-9 px-3.5 min-w-10",
20
- label: "text-base"
18
+ root: "p-0.5 gap-0.5",
19
+ control: "h-9 px-3.5 min-w-9",
20
+ label: "text-sm"
21
21
  },
22
22
  xl: {
23
- root: "p-1.5 gap-1.5",
24
- control: "h-10 px-4 min-w-11",
25
- label: "text-lg"
23
+ root: "p-0.5 gap-0.5",
24
+ control: "h-11 px-4 min-w-10",
25
+ label: "text-base"
26
26
  }
27
27
  };
28
28
  export const getSize = (size = "md") => sizes[size];