@refraktor/core 0.0.4 → 0.0.5

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 (334) hide show
  1. package/build/components/progress-circle/progress-circle.d.ts.map +1 -1
  2. package/build/components/progress-circle/progress-circle.js +6 -6
  3. package/build/components/progress-circle/progress-circle.styles.d.ts +2 -7
  4. package/build/components/progress-circle/progress-circle.styles.d.ts.map +1 -1
  5. package/build/components/progress-circle/progress-circle.styles.js +2 -23
  6. package/build/components/progress-circle/progress-circle.types.d.ts +4 -3
  7. package/build/components/progress-circle/progress-circle.types.d.ts.map +1 -1
  8. package/build/components/slider/slider.d.ts.map +1 -1
  9. package/build/components/slider/slider.js +69 -20
  10. package/build/components/tooltip/tooltip.js +1 -1
  11. package/build/style.css +2 -2
  12. package/package.json +30 -3
  13. package/.turbo/turbo-build.log +0 -4
  14. package/refraktor-core-0.0.1-alpha.0.tgz +0 -0
  15. package/src/components/accordion/accordion-control/accordion-control.tsx +0 -156
  16. package/src/components/accordion/accordion-control/index.ts +0 -1
  17. package/src/components/accordion/accordion-item/accordion-item.tsx +0 -40
  18. package/src/components/accordion/accordion-item/index.ts +0 -1
  19. package/src/components/accordion/accordion-panel/accordion-panel.tsx +0 -58
  20. package/src/components/accordion/accordion-panel/index.ts +0 -1
  21. package/src/components/accordion/accordion.context.ts +0 -93
  22. package/src/components/accordion/accordion.styles.ts +0 -60
  23. package/src/components/accordion/accordion.test.tsx +0 -174
  24. package/src/components/accordion/accordion.tsx +0 -203
  25. package/src/components/accordion/accordion.types.ts +0 -126
  26. package/src/components/accordion/index.ts +0 -17
  27. package/src/components/avatar/avatar-group/avatar-group.tsx +0 -73
  28. package/src/components/avatar/avatar-group/index.ts +0 -1
  29. package/src/components/avatar/avatar.styles.ts +0 -11
  30. package/src/components/avatar/avatar.tsx +0 -142
  31. package/src/components/avatar/avatar.types.ts +0 -86
  32. package/src/components/avatar/index.ts +0 -8
  33. package/src/components/badge/badge.styles.ts +0 -21
  34. package/src/components/badge/badge.tsx +0 -62
  35. package/src/components/badge/badge.types.ts +0 -40
  36. package/src/components/badge/index.ts +0 -2
  37. package/src/components/breadcrumbs/breadcrumbs.styles.ts +0 -55
  38. package/src/components/breadcrumbs/breadcrumbs.test.tsx +0 -136
  39. package/src/components/breadcrumbs/breadcrumbs.tsx +0 -199
  40. package/src/components/breadcrumbs/breadcrumbs.types.ts +0 -78
  41. package/src/components/breadcrumbs/breadcrumbs.utils.ts +0 -70
  42. package/src/components/breadcrumbs/index.ts +0 -6
  43. package/src/components/button/button.styles.ts +0 -28
  44. package/src/components/button/button.test.tsx +0 -57
  45. package/src/components/button/button.tsx +0 -110
  46. package/src/components/button/button.types.ts +0 -69
  47. package/src/components/button/index.ts +0 -2
  48. package/src/components/checkbox/checkbox-group/checkbox-group.tsx +0 -93
  49. package/src/components/checkbox/checkbox-group/index.ts +0 -1
  50. package/src/components/checkbox/checkbox.context.ts +0 -14
  51. package/src/components/checkbox/checkbox.styles.ts +0 -49
  52. package/src/components/checkbox/checkbox.test.tsx +0 -80
  53. package/src/components/checkbox/checkbox.tsx +0 -192
  54. package/src/components/checkbox/checkbox.types.ts +0 -125
  55. package/src/components/checkbox/index.ts +0 -10
  56. package/src/components/chip/chip-group/chip-group.tsx +0 -107
  57. package/src/components/chip/chip-group/index.ts +0 -1
  58. package/src/components/chip/chip.context.ts +0 -15
  59. package/src/components/chip/chip.styles.ts +0 -36
  60. package/src/components/chip/chip.test.tsx +0 -197
  61. package/src/components/chip/chip.tsx +0 -208
  62. package/src/components/chip/chip.types.ts +0 -134
  63. package/src/components/chip/index.ts +0 -10
  64. package/src/components/color-swatch/color-swatch.styles.ts +0 -11
  65. package/src/components/color-swatch/color-swatch.test.tsx +0 -80
  66. package/src/components/color-swatch/color-swatch.tsx +0 -84
  67. package/src/components/color-swatch/color-swatch.types.ts +0 -46
  68. package/src/components/color-swatch/index.ts +0 -2
  69. package/src/components/drawer/drawer-body/drawer-body.tsx +0 -29
  70. package/src/components/drawer/drawer-body/index.ts +0 -1
  71. package/src/components/drawer/drawer-close/drawer-close.tsx +0 -43
  72. package/src/components/drawer/drawer-close/index.ts +0 -1
  73. package/src/components/drawer/drawer-content/drawer-content.tsx +0 -135
  74. package/src/components/drawer/drawer-content/index.ts +0 -1
  75. package/src/components/drawer/drawer-header/drawer-header.tsx +0 -40
  76. package/src/components/drawer/drawer-header/index.ts +0 -1
  77. package/src/components/drawer/drawer-overlay/drawer-overlay.tsx +0 -87
  78. package/src/components/drawer/drawer-overlay/index.ts +0 -1
  79. package/src/components/drawer/drawer-root/drawer-root.tsx +0 -93
  80. package/src/components/drawer/drawer-root/index.ts +0 -1
  81. package/src/components/drawer/drawer.context.ts +0 -26
  82. package/src/components/drawer/drawer.styles.ts +0 -32
  83. package/src/components/drawer/drawer.test.tsx +0 -274
  84. package/src/components/drawer/drawer.tsx +0 -58
  85. package/src/components/drawer/drawer.types.ts +0 -192
  86. package/src/components/drawer/index.ts +0 -18
  87. package/src/components/drawer/use-drawer.ts +0 -94
  88. package/src/components/file-input/file-input.test.tsx +0 -134
  89. package/src/components/file-input/file-input.tsx +0 -224
  90. package/src/components/file-input/file-input.types.ts +0 -78
  91. package/src/components/file-input/file-input.utils.test.ts +0 -36
  92. package/src/components/file-input/file-input.utils.ts +0 -130
  93. package/src/components/file-input/index.ts +0 -2
  94. package/src/components/for/for.test.tsx +0 -66
  95. package/src/components/for/for.tsx +0 -53
  96. package/src/components/for/for.types.ts +0 -40
  97. package/src/components/for/index.ts +0 -2
  98. package/src/components/index.ts +0 -35
  99. package/src/components/input/index.ts +0 -2
  100. package/src/components/input/input-description/index.ts +0 -2
  101. package/src/components/input/input-description/input-description.tsx +0 -36
  102. package/src/components/input/input-error/index.ts +0 -2
  103. package/src/components/input/input-error/input-error.tsx +0 -36
  104. package/src/components/input/input-field/index.ts +0 -1
  105. package/src/components/input/input-field/input-field.styles.ts +0 -23
  106. package/src/components/input/input-field/input-field.tsx +0 -94
  107. package/src/components/input/input-label/index.ts +0 -2
  108. package/src/components/input/input-label/input-label.tsx +0 -47
  109. package/src/components/input/input-wrapper/index.ts +0 -2
  110. package/src/components/input/input-wrapper/input-wrapper.tsx +0 -43
  111. package/src/components/input/input.tsx +0 -71
  112. package/src/components/input/input.types.ts +0 -111
  113. package/src/components/loader/index.ts +0 -2
  114. package/src/components/loader/loader.tsx +0 -89
  115. package/src/components/loader/loader.types.ts +0 -33
  116. package/src/components/menu/index.ts +0 -24
  117. package/src/components/menu/menu-dropdown/index.ts +0 -1
  118. package/src/components/menu/menu-dropdown/menu-dropdown.tsx +0 -220
  119. package/src/components/menu/menu-item/index.ts +0 -1
  120. package/src/components/menu/menu-item/menu-item.tsx +0 -126
  121. package/src/components/menu/menu-label/index.ts +0 -1
  122. package/src/components/menu/menu-label/menu-label.tsx +0 -30
  123. package/src/components/menu/menu-separator/index.ts +0 -1
  124. package/src/components/menu/menu-separator/menu-separator.tsx +0 -28
  125. package/src/components/menu/menu-sub/index.ts +0 -1
  126. package/src/components/menu/menu-sub/menu-sub.tsx +0 -117
  127. package/src/components/menu/menu-sub-dropdown/index.ts +0 -1
  128. package/src/components/menu/menu-sub-dropdown/menu-sub-dropdown.tsx +0 -221
  129. package/src/components/menu/menu-sub-trigger/index.ts +0 -1
  130. package/src/components/menu/menu-sub-trigger/menu-sub-trigger.tsx +0 -164
  131. package/src/components/menu/menu-trigger/index.ts +0 -1
  132. package/src/components/menu/menu-trigger/menu-trigger.tsx +0 -98
  133. package/src/components/menu/menu.context.ts +0 -162
  134. package/src/components/menu/menu.test.tsx +0 -136
  135. package/src/components/menu/menu.tsx +0 -133
  136. package/src/components/menu/menu.types.ts +0 -291
  137. package/src/components/menu/use-menu.ts +0 -204
  138. package/src/components/modal/index.ts +0 -18
  139. package/src/components/modal/modal-body/index.ts +0 -1
  140. package/src/components/modal/modal-body/modal-body.tsx +0 -29
  141. package/src/components/modal/modal-close/index.ts +0 -1
  142. package/src/components/modal/modal-close/modal-close.tsx +0 -43
  143. package/src/components/modal/modal-content/index.ts +0 -1
  144. package/src/components/modal/modal-content/modal-content.tsx +0 -119
  145. package/src/components/modal/modal-header/index.ts +0 -1
  146. package/src/components/modal/modal-header/modal-header.tsx +0 -40
  147. package/src/components/modal/modal-overlay/index.ts +0 -1
  148. package/src/components/modal/modal-overlay/modal-overlay.tsx +0 -87
  149. package/src/components/modal/modal-root/index.ts +0 -1
  150. package/src/components/modal/modal-root/modal-root.tsx +0 -93
  151. package/src/components/modal/modal.context.ts +0 -26
  152. package/src/components/modal/modal.test.tsx +0 -316
  153. package/src/components/modal/modal.tsx +0 -58
  154. package/src/components/modal/modal.types.ts +0 -189
  155. package/src/components/modal/use-modal.ts +0 -94
  156. package/src/components/number-input/index.ts +0 -2
  157. package/src/components/number-input/number-input.styles.ts +0 -37
  158. package/src/components/number-input/number-input.test.tsx +0 -22
  159. package/src/components/number-input/number-input.tsx +0 -381
  160. package/src/components/number-input/number-input.types.ts +0 -58
  161. package/src/components/pagination/index.ts +0 -7
  162. package/src/components/pagination/pagination.styles.ts +0 -84
  163. package/src/components/pagination/pagination.test.tsx +0 -117
  164. package/src/components/pagination/pagination.tsx +0 -371
  165. package/src/components/pagination/pagination.types.ts +0 -95
  166. package/src/components/pagination/pagination.utils.ts +0 -88
  167. package/src/components/password-input/index.ts +0 -2
  168. package/src/components/password-input/password-input.test.tsx +0 -72
  169. package/src/components/password-input/password-input.tsx +0 -85
  170. package/src/components/password-input/password-input.types.ts +0 -30
  171. package/src/components/pin-input/index.ts +0 -2
  172. package/src/components/pin-input/pin-input.test.tsx +0 -149
  173. package/src/components/pin-input/pin-input.tsx +0 -473
  174. package/src/components/pin-input/pin-input.types.ts +0 -78
  175. package/src/components/popover/index.ts +0 -12
  176. package/src/components/popover/popover-dropdown/index.ts +0 -1
  177. package/src/components/popover/popover-dropdown/popover-dropdown.tsx +0 -94
  178. package/src/components/popover/popover-trigger/index.ts +0 -1
  179. package/src/components/popover/popover-trigger/popover-trigger.tsx +0 -49
  180. package/src/components/popover/popover.context.ts +0 -20
  181. package/src/components/popover/popover.tsx +0 -113
  182. package/src/components/popover/popover.types.ts +0 -137
  183. package/src/components/popover/use-popover.ts +0 -219
  184. package/src/components/portal/index.ts +0 -2
  185. package/src/components/portal/portal.test.tsx +0 -39
  186. package/src/components/portal/portal.tsx +0 -104
  187. package/src/components/portal/portal.types.ts +0 -31
  188. package/src/components/progress/index.ts +0 -2
  189. package/src/components/progress/progress.styles.ts +0 -25
  190. package/src/components/progress/progress.test.tsx +0 -107
  191. package/src/components/progress/progress.tsx +0 -93
  192. package/src/components/progress/progress.types.ts +0 -52
  193. package/src/components/progress-circle/index.ts +0 -5
  194. package/src/components/progress-circle/progress-circle.styles.ts +0 -31
  195. package/src/components/progress-circle/progress-circle.test.tsx +0 -140
  196. package/src/components/progress-circle/progress-circle.tsx +0 -124
  197. package/src/components/progress-circle/progress-circle.types.ts +0 -52
  198. package/src/components/radio/index.ts +0 -10
  199. package/src/components/radio/radio-group/index.ts +0 -1
  200. package/src/components/radio/radio-group/radio-group.tsx +0 -89
  201. package/src/components/radio/radio.context.ts +0 -14
  202. package/src/components/radio/radio.styles.ts +0 -49
  203. package/src/components/radio/radio.test.tsx +0 -75
  204. package/src/components/radio/radio.tsx +0 -173
  205. package/src/components/radio/radio.types.ts +0 -126
  206. package/src/components/scroll-area/index.ts +0 -6
  207. package/src/components/scroll-area/scroll-area.test.tsx +0 -72
  208. package/src/components/scroll-area/scroll-area.tsx +0 -70
  209. package/src/components/scroll-area/scroll-area.types.ts +0 -37
  210. package/src/components/segmented-control/index.ts +0 -6
  211. package/src/components/segmented-control/segmented-control.styles.ts +0 -37
  212. package/src/components/segmented-control/segmented-control.test.tsx +0 -170
  213. package/src/components/segmented-control/segmented-control.tsx +0 -255
  214. package/src/components/segmented-control/segmented-control.types.ts +0 -78
  215. package/src/components/select/index.ts +0 -20
  216. package/src/components/select/select-dropdown/index.ts +0 -1
  217. package/src/components/select/select-dropdown/select-dropdown.tsx +0 -299
  218. package/src/components/select/select-group/index.ts +0 -1
  219. package/src/components/select/select-group/select-group.tsx +0 -47
  220. package/src/components/select/select-item/index.ts +0 -1
  221. package/src/components/select/select-item/select-item.tsx +0 -157
  222. package/src/components/select/select-root/index.ts +0 -1
  223. package/src/components/select/select-root/select-root.tsx +0 -333
  224. package/src/components/select/select-trigger/index.ts +0 -1
  225. package/src/components/select/select-trigger/select-trigger.tsx +0 -123
  226. package/src/components/select/select.context.ts +0 -140
  227. package/src/components/select/select.test.tsx +0 -190
  228. package/src/components/select/select.tsx +0 -82
  229. package/src/components/select/select.types.ts +0 -272
  230. package/src/components/select/use-select.ts +0 -170
  231. package/src/components/slider/index.ts +0 -7
  232. package/src/components/slider/slider.styles.ts +0 -37
  233. package/src/components/slider/slider.tsx +0 -275
  234. package/src/components/slider/slider.types.ts +0 -82
  235. package/src/components/switch/index.ts +0 -2
  236. package/src/components/switch/switch.styles.ts +0 -31
  237. package/src/components/switch/switch.tsx +0 -132
  238. package/src/components/switch/switch.types.ts +0 -62
  239. package/src/components/table/index.ts +0 -24
  240. package/src/components/table/table-body/index.ts +0 -1
  241. package/src/components/table/table-body/table-body.tsx +0 -37
  242. package/src/components/table/table-caption/index.ts +0 -1
  243. package/src/components/table/table-caption/table-caption.tsx +0 -32
  244. package/src/components/table/table-cell/index.ts +0 -1
  245. package/src/components/table/table-cell/table-cell.tsx +0 -33
  246. package/src/components/table/table-head/index.ts +0 -1
  247. package/src/components/table/table-head/table-head.tsx +0 -29
  248. package/src/components/table/table-header-cell/index.ts +0 -1
  249. package/src/components/table/table-header-cell/table-header-cell.tsx +0 -33
  250. package/src/components/table/table-row/index.ts +0 -1
  251. package/src/components/table/table-row/table-row.tsx +0 -30
  252. package/src/components/table/table.context.ts +0 -18
  253. package/src/components/table/table.styles.ts +0 -62
  254. package/src/components/table/table.test.tsx +0 -145
  255. package/src/components/table/table.tsx +0 -91
  256. package/src/components/table/table.types.ts +0 -145
  257. package/src/components/tabs/index.ts +0 -18
  258. package/src/components/tabs/tabs-list/index.ts +0 -1
  259. package/src/components/tabs/tabs-list/tabs-list.tsx +0 -42
  260. package/src/components/tabs/tabs-panel/index.ts +0 -1
  261. package/src/components/tabs/tabs-panel/tabs-panel.tsx +0 -58
  262. package/src/components/tabs/tabs-tab/index.ts +0 -1
  263. package/src/components/tabs/tabs-tab/tabs-tab.tsx +0 -210
  264. package/src/components/tabs/tabs.context.ts +0 -88
  265. package/src/components/tabs/tabs.styles.ts +0 -92
  266. package/src/components/tabs/tabs.test.tsx +0 -167
  267. package/src/components/tabs/tabs.tsx +0 -137
  268. package/src/components/tabs/tabs.types.ts +0 -128
  269. package/src/components/textarea/index.ts +0 -2
  270. package/src/components/textarea/textarea-field/index.ts +0 -1
  271. package/src/components/textarea/textarea-field/textarea-field.styles.ts +0 -34
  272. package/src/components/textarea/textarea-field/textarea-field.tsx +0 -96
  273. package/src/components/textarea/textarea.tsx +0 -64
  274. package/src/components/textarea/textarea.types.ts +0 -80
  275. package/src/components/timeline/index.ts +0 -11
  276. package/src/components/timeline/timeline-item/index.ts +0 -1
  277. package/src/components/timeline/timeline-item/timeline-item.tsx +0 -158
  278. package/src/components/timeline/timeline.context.ts +0 -21
  279. package/src/components/timeline/timeline.styles.ts +0 -135
  280. package/src/components/timeline/timeline.test.tsx +0 -150
  281. package/src/components/timeline/timeline.tsx +0 -124
  282. package/src/components/timeline/timeline.types.ts +0 -91
  283. package/src/components/tooltip/index.ts +0 -8
  284. package/src/components/tooltip/tooltip.tsx +0 -164
  285. package/src/components/tooltip/tooltip.types.ts +0 -104
  286. package/src/components/tooltip/use-tooltip.ts +0 -200
  287. package/src/components/transition/index.ts +0 -11
  288. package/src/components/transition/transition.test.tsx +0 -126
  289. package/src/components/transition/transition.tsx +0 -441
  290. package/src/components/transition/transition.types.ts +0 -97
  291. package/src/components/transition/transitions.ts +0 -140
  292. package/src/icons/check.tsx +0 -25
  293. package/src/icons/chevron.tsx +0 -46
  294. package/src/icons/eye-off.tsx +0 -30
  295. package/src/icons/eye.tsx +0 -24
  296. package/src/icons/index.ts +0 -7
  297. package/src/icons/minus.tsx +0 -24
  298. package/src/icons/types.ts +0 -9
  299. package/src/icons/user.tsx +0 -18
  300. package/src/icons/x.tsx +0 -35
  301. package/src/index.ts +0 -5
  302. package/src/style.css +0 -334
  303. package/src/theme/ThemeProvider/ThemeProvider.tsx +0 -111
  304. package/src/theme/ThemeProvider/context.ts +0 -7
  305. package/src/theme/ThemeProvider/generateVariables.test.ts +0 -49
  306. package/src/theme/ThemeProvider/generateVariables.ts +0 -124
  307. package/src/theme/ThemeProvider/index.ts +0 -3
  308. package/src/theme/ThemeProvider/types.ts +0 -37
  309. package/src/theme/createTheme/createTheme.ts +0 -41
  310. package/src/theme/createTheme/index.ts +0 -7
  311. package/src/theme/createTheme/types.ts +0 -62
  312. package/src/theme/defaults/colors.ts +0 -203
  313. package/src/theme/defaults/settings.ts +0 -8
  314. package/src/theme/index.ts +0 -4
  315. package/src/theme/types.ts +0 -31
  316. package/src/theme/utils/get-radius.ts +0 -23
  317. package/src/theme/utils/get-shade.ts +0 -16
  318. package/src/theme/utils/index.ts +0 -3
  319. package/src/theme/utils/use-theme.ts +0 -27
  320. package/src/utils/configs/create-config.ts +0 -15
  321. package/src/utils/configs/index.ts +0 -3
  322. package/src/utils/configs/use-class-names.ts +0 -41
  323. package/src/utils/configs/use-props.ts +0 -55
  324. package/src/utils/cx/index.ts +0 -6
  325. package/src/utils/factory/factory.ts +0 -23
  326. package/src/utils/factory/index.ts +0 -14
  327. package/src/utils/factory/types.ts +0 -92
  328. package/src/utils/index.ts +0 -3
  329. package/src/vitest/index.ts +0 -1
  330. package/src/vitest/setup.tsx +0 -20
  331. package/src/vitest/utils.tsx +0 -59
  332. package/tsconfig.json +0 -13
  333. package/tsconfig.tsbuildinfo +0 -1
  334. package/vitest.config.js +0 -19
@@ -1,371 +0,0 @@
1
- import { clamp, useId, useUncontrolled } from "@refraktor/utils";
2
- import { useMemo } from "react";
3
- import { ChevronIcon } from "../../icons";
4
- import { useTheme } from "../../theme";
5
- import {
6
- createClassNamesConfig,
7
- createComponentConfig,
8
- factory,
9
- useClassNames,
10
- useProps
11
- } from "../../utils";
12
- import { getSize, getVariant } from "./pagination.styles";
13
- import {
14
- PaginationAriaLabelType,
15
- PaginationClassNames,
16
- PaginationFactoryPayload,
17
- PaginationProps
18
- } from "./pagination.types";
19
- import { buildPaginationRange } from "./pagination.utils";
20
-
21
- const defaultProps = {
22
- siblings: 1,
23
- boundaries: 1,
24
- withControls: true,
25
- withEdges: false,
26
- hideWithOnePage: false,
27
- disabled: false,
28
- size: "md",
29
- radius: "default",
30
- variant: "default"
31
- } satisfies Partial<PaginationProps>;
32
-
33
- const getSafeNumber = (value: number, fallback: number, minimum = 0) => {
34
- if (!Number.isFinite(value)) {
35
- return fallback;
36
- }
37
-
38
- return Math.max(minimum, Math.trunc(value));
39
- };
40
-
41
- const getDefaultAriaLabel = (
42
- type: PaginationAriaLabelType,
43
- page: number,
44
- selected: boolean
45
- ) => {
46
- if (type === "page") {
47
- return selected ? `Page ${page}, current page` : `Go to page ${page}`;
48
- }
49
-
50
- if (type === "first") {
51
- return "Go to first page";
52
- }
53
-
54
- if (type === "previous") {
55
- return "Go to previous page";
56
- }
57
-
58
- if (type === "next") {
59
- return "Go to next page";
60
- }
61
-
62
- return "Go to last page";
63
- };
64
-
65
- const Pagination = factory<PaginationFactoryPayload>((_props, ref) => {
66
- const { cx, getRadius } = useTheme();
67
- const {
68
- id,
69
- total,
70
- value,
71
- defaultValue,
72
- onChange,
73
- siblings,
74
- boundaries,
75
- withControls,
76
- withEdges,
77
- hideWithOnePage,
78
- disabled,
79
- size,
80
- radius,
81
- variant,
82
- getItemAriaLabel,
83
- className,
84
- classNames,
85
- ...props
86
- } = useProps("Pagination", defaultProps, _props);
87
- const classes = useClassNames("Pagination", classNames);
88
- const _id = useId(id);
89
-
90
- const totalPages = getSafeNumber(total, 0, 0);
91
- const safeSiblings = getSafeNumber(siblings, 1, 0);
92
- const safeBoundaries = getSafeNumber(boundaries, 1, 0);
93
-
94
- const [currentPage, setCurrentPage] = useUncontrolled<number>({
95
- value,
96
- defaultValue,
97
- finalValue: 1,
98
- onChange
99
- });
100
-
101
- const activePage =
102
- totalPages > 0
103
- ? clamp(getSafeNumber(currentPage, 1, 1), 1, totalPages)
104
- : 1;
105
-
106
- const items = useMemo(
107
- () =>
108
- buildPaginationRange({
109
- total: totalPages,
110
- page: activePage,
111
- siblings: safeSiblings,
112
- boundaries: safeBoundaries
113
- }),
114
- [totalPages, activePage, safeSiblings, safeBoundaries]
115
- );
116
-
117
- if (totalPages === 0) {
118
- return null;
119
- }
120
-
121
- if (hideWithOnePage && totalPages === 1) {
122
- return null;
123
- }
124
-
125
- const sizeStyles = getSize(size);
126
- const variantStyles = getVariant(variant);
127
-
128
- const resolveAriaLabel = (
129
- type: PaginationAriaLabelType,
130
- page: number,
131
- selected = false
132
- ) => {
133
- if (getItemAriaLabel) {
134
- return getItemAriaLabel(type, page, selected);
135
- }
136
-
137
- return getDefaultAriaLabel(type, page, selected);
138
- };
139
-
140
- const canGoPrevious = !disabled && activePage > 1;
141
- const canGoNext = !disabled && activePage < totalPages;
142
-
143
- const handlePageChange = (nextPage: number) => {
144
- if (disabled || totalPages === 0) {
145
- return;
146
- }
147
-
148
- const normalizedPage = clamp(nextPage, 1, totalPages);
149
-
150
- if (normalizedPage === activePage) {
151
- return;
152
- }
153
-
154
- setCurrentPage(normalizedPage);
155
- };
156
-
157
- const getControlClassName = (
158
- state: { disabled: boolean },
159
- className?: string
160
- ) =>
161
- cx(
162
- "inline-flex items-center justify-center select-none outline-none transition-colors",
163
- "focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--refraktor-primary)]",
164
- "data-[disabled=true]:opacity-50 data-[disabled=true]:pointer-events-none data-[disabled=true]:cursor-not-allowed",
165
- sizeStyles.item,
166
- getRadius(radius),
167
- variantStyles.base,
168
- variantStyles.inactive,
169
- classes.control,
170
- className,
171
- !state.disabled && "cursor-pointer"
172
- );
173
-
174
- const getPageClassName = (state: { active: boolean }) =>
175
- cx(
176
- "inline-flex items-center justify-center select-none outline-none transition-colors",
177
- "focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--refraktor-primary)]",
178
- "data-[disabled=true]:opacity-50 data-[disabled=true]:pointer-events-none data-[disabled=true]:cursor-not-allowed",
179
- sizeStyles.item,
180
- getRadius(radius),
181
- variantStyles.base,
182
- state.active ? variantStyles.active : variantStyles.inactive,
183
- classes.page,
184
- !disabled && "cursor-pointer"
185
- );
186
-
187
- return (
188
- <nav
189
- {...props}
190
- ref={ref}
191
- id={_id}
192
- role="navigation"
193
- aria-label="Pagination"
194
- className={cx("w-full", classes.root, className)}
195
- >
196
- <ul
197
- className={cx(
198
- "inline-flex items-center",
199
- sizeStyles.list,
200
- classes.list
201
- )}
202
- >
203
- {withControls && withEdges && (
204
- <li className={cx(classes.item)}>
205
- <button
206
- type="button"
207
- aria-label={resolveAriaLabel("first", 1, false)}
208
- aria-disabled={!canGoPrevious}
209
- data-disabled={!canGoPrevious}
210
- disabled={!canGoPrevious}
211
- className={getControlClassName(
212
- { disabled: !canGoPrevious },
213
- classes.first
214
- )}
215
- onClick={() => handlePageChange(1)}
216
- >
217
- <span className="inline-flex items-center -space-x-2">
218
- <ChevronIcon
219
- direction="left"
220
- size={sizeStyles.iconSize}
221
- />
222
- <ChevronIcon
223
- direction="left"
224
- size={sizeStyles.iconSize}
225
- />
226
- </span>
227
- </button>
228
- </li>
229
- )}
230
-
231
- {withControls && (
232
- <li className={cx(classes.item)}>
233
- <button
234
- type="button"
235
- aria-label={resolveAriaLabel(
236
- "previous",
237
- Math.max(1, activePage - 1),
238
- false
239
- )}
240
- aria-disabled={!canGoPrevious}
241
- data-disabled={!canGoPrevious}
242
- disabled={!canGoPrevious}
243
- className={getControlClassName(
244
- { disabled: !canGoPrevious },
245
- classes.previous
246
- )}
247
- onClick={() => handlePageChange(activePage - 1)}
248
- >
249
- <ChevronIcon
250
- direction="left"
251
- size={sizeStyles.iconSize}
252
- />
253
- </button>
254
- </li>
255
- )}
256
-
257
- {items.map((item, index) => {
258
- if (typeof item !== "number") {
259
- return (
260
- <li
261
- key={`${item}-${index}`}
262
- className={cx(classes.item)}
263
- >
264
- <span
265
- aria-hidden="true"
266
- className={cx(
267
- "inline-flex items-center justify-center select-none text-[var(--refraktor-text-tertiary)]",
268
- sizeStyles.dots,
269
- classes.dots
270
- )}
271
- >
272
- ...
273
- </span>
274
- </li>
275
- );
276
- }
277
-
278
- const isActive = item === activePage;
279
-
280
- return (
281
- <li key={item} className={cx(classes.item)}>
282
- <button
283
- type="button"
284
- aria-label={resolveAriaLabel(
285
- "page",
286
- item,
287
- isActive
288
- )}
289
- aria-current={isActive ? "page" : undefined}
290
- aria-disabled={disabled}
291
- data-active={isActive}
292
- data-disabled={disabled}
293
- disabled={disabled}
294
- className={getPageClassName({
295
- active: isActive
296
- })}
297
- onClick={() => handlePageChange(item)}
298
- >
299
- {item}
300
- </button>
301
- </li>
302
- );
303
- })}
304
-
305
- {withControls && (
306
- <li className={cx(classes.item)}>
307
- <button
308
- type="button"
309
- aria-label={resolveAriaLabel(
310
- "next",
311
- Math.min(totalPages, activePage + 1),
312
- false
313
- )}
314
- aria-disabled={!canGoNext}
315
- data-disabled={!canGoNext}
316
- disabled={!canGoNext}
317
- className={getControlClassName(
318
- { disabled: !canGoNext },
319
- classes.next
320
- )}
321
- onClick={() => handlePageChange(activePage + 1)}
322
- >
323
- <ChevronIcon
324
- direction="right"
325
- size={sizeStyles.iconSize}
326
- />
327
- </button>
328
- </li>
329
- )}
330
-
331
- {withControls && withEdges && (
332
- <li className={cx(classes.item)}>
333
- <button
334
- type="button"
335
- aria-label={resolveAriaLabel(
336
- "last",
337
- totalPages,
338
- false
339
- )}
340
- aria-disabled={!canGoNext}
341
- data-disabled={!canGoNext}
342
- disabled={!canGoNext}
343
- className={getControlClassName(
344
- { disabled: !canGoNext },
345
- classes.last
346
- )}
347
- onClick={() => handlePageChange(totalPages)}
348
- >
349
- <span className="inline-flex items-center -space-x-2">
350
- <ChevronIcon
351
- direction="right"
352
- size={sizeStyles.iconSize}
353
- />
354
- <ChevronIcon
355
- direction="right"
356
- size={sizeStyles.iconSize}
357
- />
358
- </span>
359
- </button>
360
- </li>
361
- )}
362
- </ul>
363
- </nav>
364
- );
365
- });
366
-
367
- Pagination.displayName = "@refraktor/core/Pagination";
368
- Pagination.configure = createComponentConfig<PaginationProps>();
369
- Pagination.classNames = createClassNamesConfig<PaginationClassNames>();
370
-
371
- export default Pagination;
@@ -1,95 +0,0 @@
1
- import { ComponentPropsWithoutRef } from "react";
2
- import { RefraktorRadius, RefraktorSize } from "../../theme";
3
- import {
4
- createClassNamesConfig,
5
- createComponentConfig,
6
- FactoryPayload
7
- } from "../../utils";
8
-
9
- export type PaginationVariant = "default" | "filled" | "outline" | "ghost";
10
-
11
- export type PaginationAriaLabelType =
12
- | "page"
13
- | "first"
14
- | "previous"
15
- | "next"
16
- | "last";
17
-
18
- export type PaginationClassNames = {
19
- root?: string;
20
- list?: string;
21
- item?: string;
22
- page?: string;
23
- control?: string;
24
- dots?: string;
25
- first?: string;
26
- previous?: string;
27
- next?: string;
28
- last?: string;
29
- };
30
-
31
- export interface PaginationProps
32
- extends Omit<ComponentPropsWithoutRef<"nav">, "children" | "onChange"> {
33
- /** Total amount of pages */
34
- total: number;
35
-
36
- /** Active page (controlled) */
37
- value?: number;
38
-
39
- /** Initial active page (uncontrolled) */
40
- defaultValue?: number;
41
-
42
- /** Callback called when page changes */
43
- onChange?: (value: number) => void;
44
-
45
- /** Number of sibling pages around active page @default `1` */
46
- siblings?: number;
47
-
48
- /** Number of always-visible pages at the edges @default `1` */
49
- boundaries?: number;
50
-
51
- /** Whether to show previous/next controls @default `true` */
52
- withControls?: boolean;
53
-
54
- /** Whether to show first/last controls @default `false` */
55
- withEdges?: boolean;
56
-
57
- /** Hide component when total is 1 @default `false` */
58
- hideWithOnePage?: boolean;
59
-
60
- /** Whether all controls are disabled @default `false` */
61
- disabled?: boolean;
62
-
63
- /** The size of the pagination @default `md` */
64
- size?: RefraktorSize;
65
-
66
- /** The radius of page buttons @default `default` */
67
- radius?: RefraktorRadius;
68
-
69
- /** Visual style variant @default `default` */
70
- variant?: PaginationVariant;
71
-
72
- /** Used for custom aria labels */
73
- getItemAriaLabel?: (
74
- type: PaginationAriaLabelType,
75
- page: number,
76
- selected: boolean
77
- ) => string;
78
-
79
- /** Used for editing root class name */
80
- className?: string;
81
-
82
- /** Used for styling different parts of the component */
83
- classNames?: PaginationClassNames;
84
- }
85
-
86
- export interface PaginationFactoryPayload extends FactoryPayload {
87
- props: PaginationProps;
88
- ref: HTMLElement;
89
- compound: {
90
- configure: ReturnType<typeof createComponentConfig<PaginationProps>>;
91
- classNames: ReturnType<
92
- typeof createClassNamesConfig<PaginationClassNames>
93
- >;
94
- };
95
- }
@@ -1,88 +0,0 @@
1
- import { clamp } from "@refraktor/utils";
2
-
3
- export type PaginationRangeItem = number | "dots-left" | "dots-right";
4
-
5
- export type PaginationRangeOptions = {
6
- total: number;
7
- page: number;
8
- siblings: number;
9
- boundaries: number;
10
- };
11
-
12
- function range(start: number, end: number) {
13
- if (end < start) {
14
- return [];
15
- }
16
-
17
- const length = end - start + 1;
18
-
19
- return Array.from({ length }, (_, index) => start + index);
20
- }
21
-
22
- function toSafeInteger(value: number, fallback: number, minimum = 0) {
23
- if (!Number.isFinite(value)) {
24
- return fallback;
25
- }
26
-
27
- return Math.max(minimum, Math.trunc(value));
28
- }
29
-
30
- export function buildPaginationRange(
31
- options: PaginationRangeOptions
32
- ): PaginationRangeItem[] {
33
- const total = toSafeInteger(options.total, 0, 0);
34
-
35
- if (total <= 0) {
36
- return [];
37
- }
38
-
39
- const page = clamp(toSafeInteger(options.page, 1, 1), 1, total);
40
- const siblings = toSafeInteger(options.siblings, 1, 0);
41
- const boundaries = Math.min(
42
- toSafeInteger(options.boundaries, 1, 0),
43
- Math.floor(total / 2)
44
- );
45
-
46
- const totalVisibleNumbers = boundaries * 2 + siblings * 2 + 3;
47
-
48
- if (totalVisibleNumbers >= total) {
49
- return range(1, total);
50
- }
51
-
52
- const leftSiblingIndex = Math.max(page - siblings, boundaries + 2);
53
- const rightSiblingIndex = Math.min(page + siblings, total - boundaries - 1);
54
-
55
- const shouldShowLeftDots = leftSiblingIndex > boundaries + 2;
56
- const shouldShowRightDots = rightSiblingIndex < total - boundaries - 1;
57
-
58
- const leftBoundary = range(1, boundaries);
59
- const rightBoundary = range(total - boundaries + 1, total);
60
-
61
- if (!shouldShowLeftDots && shouldShowRightDots) {
62
- const leftItemsCount = boundaries + siblings * 2 + 2;
63
- const leftRange = range(1, leftItemsCount);
64
-
65
- return [...leftRange, "dots-right", ...rightBoundary];
66
- }
67
-
68
- if (shouldShowLeftDots && !shouldShowRightDots) {
69
- const rightItemsCount = boundaries + siblings * 2 + 2;
70
- const rightRange = range(total - rightItemsCount + 1, total);
71
-
72
- return [...leftBoundary, "dots-left", ...rightRange];
73
- }
74
-
75
- if (shouldShowLeftDots && shouldShowRightDots) {
76
- const middleRange = range(leftSiblingIndex, rightSiblingIndex);
77
-
78
- return [
79
- ...leftBoundary,
80
- "dots-left",
81
- ...middleRange,
82
- "dots-right",
83
- ...rightBoundary
84
- ];
85
- }
86
-
87
- return range(1, total);
88
- }
@@ -1,2 +0,0 @@
1
- export { default as PasswordInput } from "./password-input";
2
- export * from "./password-input.types";
@@ -1,72 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { render, screen, userEvent } from "../../vitest";
3
- import PasswordInput from "./password-input";
4
-
5
- describe("@refraktor/core/PasswordInput", () => {
6
- it("supports input wrapper props", async () => {
7
- await render(
8
- <PasswordInput
9
- label="Password"
10
- description="Use at least 8 characters"
11
- error="Password is required"
12
- />
13
- );
14
-
15
- const input = screen.getByLabelText("Password");
16
-
17
- expect(input).toHaveAttribute("type", "password");
18
- expect(input).toHaveAttribute("aria-invalid", "true");
19
- expect(screen.getByText("Use at least 8 characters")).toBeInTheDocument();
20
- expect(screen.getByText("Password is required")).toBeInTheDocument();
21
- });
22
-
23
- it("toggles password visibility", async () => {
24
- const user = userEvent.setup();
25
-
26
- await render(<PasswordInput label="Password" />);
27
-
28
- const input = screen.getByLabelText("Password");
29
- const showButton = screen.getByRole("button", {
30
- name: "Show password"
31
- });
32
-
33
- expect(input).toHaveAttribute("type", "password");
34
- await user.click(showButton);
35
- expect(input).toHaveAttribute("type", "text");
36
-
37
- const hideButton = screen.getByRole("button", {
38
- name: "Hide password"
39
- });
40
-
41
- await user.click(hideButton);
42
- expect(input).toHaveAttribute("type", "password");
43
- });
44
-
45
- it("respects disabled state", async () => {
46
- const user = userEvent.setup();
47
-
48
- await render(<PasswordInput label="Password" disabled />);
49
-
50
- const input = screen.getByLabelText("Password");
51
- const toggle = screen.getByRole("button", {
52
- name: "Show password"
53
- });
54
-
55
- expect(toggle).toBeDisabled();
56
- await user.click(toggle);
57
- expect(input).toHaveAttribute("type", "password");
58
- });
59
-
60
- it("allows disabling visibility toggle", async () => {
61
- await render(
62
- <PasswordInput label="Password" withVisibilityToggle={false} />
63
- );
64
-
65
- const input = screen.getByLabelText("Password");
66
-
67
- expect(input).toHaveAttribute("type", "password");
68
- expect(
69
- screen.queryByRole("button", { name: "Show password" })
70
- ).not.toBeInTheDocument();
71
- });
72
- });