@plexui/ui 0.28.1 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (230) hide show
  1. package/dist/es/components/Alert/Alert.js +2 -2
  2. package/dist/es/components/Alert/Alert.js.map +1 -1
  3. package/dist/es/components/Avatar/Avatar.js +3 -1
  4. package/dist/es/components/Avatar/Avatar.js.map +1 -1
  5. package/dist/es/components/Badge/index.js +1 -1
  6. package/dist/es/components/Badge/index.js.map +1 -1
  7. package/dist/es/components/Button/Button.js +4 -3
  8. package/dist/es/components/Button/Button.js.map +1 -1
  9. package/dist/es/components/Button/NavigationButton.js +10 -0
  10. package/dist/es/components/Button/NavigationButton.js.map +1 -0
  11. package/dist/es/components/Button/NavigationGlyph.js +19 -0
  12. package/dist/es/components/Button/NavigationGlyph.js.map +1 -0
  13. package/dist/es/components/Button/index.js +1 -0
  14. package/dist/es/components/Button/index.js.map +1 -1
  15. package/dist/es/components/Checkbox/Checkbox.js +2 -1
  16. package/dist/es/components/Checkbox/Checkbox.js.map +1 -1
  17. package/dist/es/components/ColorPicker/ColorPicker.js +227 -0
  18. package/dist/es/components/ColorPicker/ColorPicker.js.map +1 -0
  19. package/dist/es/components/ColorPicker/ColorWell.js +58 -0
  20. package/dist/es/components/ColorPicker/ColorWell.js.map +1 -0
  21. package/dist/es/components/ColorPicker/index.js +3 -0
  22. package/dist/es/components/ColorPicker/index.js.map +1 -0
  23. package/dist/es/components/ColorPicker/shared.js +132 -0
  24. package/dist/es/components/ColorPicker/shared.js.map +1 -0
  25. package/dist/es/components/ContextMenu/ContextMenu.js +164 -0
  26. package/dist/es/components/ContextMenu/ContextMenu.js.map +1 -0
  27. package/dist/es/components/ContextMenu/index.js +2 -0
  28. package/dist/es/components/ContextMenu/index.js.map +1 -0
  29. package/dist/es/components/ContextMenu/shared.js +56 -0
  30. package/dist/es/components/ContextMenu/shared.js.map +1 -0
  31. package/dist/es/components/DateInput/DateInput.js +4 -2
  32. package/dist/es/components/DateInput/DateInput.js.map +1 -1
  33. package/dist/es/components/DatePicker/Calendar.js +89 -55
  34. package/dist/es/components/DatePicker/Calendar.js.map +1 -1
  35. package/dist/es/components/DatePicker/CalendarNavigationIcon.js +13 -0
  36. package/dist/es/components/DatePicker/CalendarNavigationIcon.js.map +1 -0
  37. package/dist/es/components/DatePicker/DatePicker.js +9 -2
  38. package/dist/es/components/DatePicker/DatePicker.js.map +1 -1
  39. package/dist/es/components/DatePicker/useCalendarGutter.js +8 -0
  40. package/dist/es/components/DatePicker/useCalendarGutter.js.map +1 -0
  41. package/dist/es/components/DateRangePicker/Calendar.js +66 -49
  42. package/dist/es/components/DateRangePicker/Calendar.js.map +1 -1
  43. package/dist/es/components/DateRangePicker/DateRangePicker.js +6 -1
  44. package/dist/es/components/DateRangePicker/DateRangePicker.js.map +1 -1
  45. package/dist/es/components/DateRangePicker/Trigger.js +1 -1
  46. package/dist/es/components/DateRangePicker/Trigger.js.map +1 -1
  47. package/dist/es/components/Dialog/Dialog.js +136 -20
  48. package/dist/es/components/Dialog/Dialog.js.map +1 -1
  49. package/dist/es/components/Dialog/index.js.map +1 -1
  50. package/dist/es/components/Dialog/sheetDrag.js +77 -24
  51. package/dist/es/components/Dialog/sheetDrag.js.map +1 -1
  52. package/dist/es/components/Field/Field.js +51 -4
  53. package/dist/es/components/Field/Field.js.map +1 -1
  54. package/dist/es/components/FieldGroup/FieldGroup.js +4 -2
  55. package/dist/es/components/FieldGroup/FieldGroup.js.map +1 -1
  56. package/dist/es/components/FileUpload/FileUpload.js +43 -3
  57. package/dist/es/components/FileUpload/FileUpload.js.map +1 -1
  58. package/dist/es/components/FloatingLabelInput/FloatingLabelInput.js +18 -16
  59. package/dist/es/components/FloatingLabelInput/FloatingLabelInput.js.map +1 -1
  60. package/dist/es/components/FloatingLabelSelect/FloatingLabelSelect.js +11 -6
  61. package/dist/es/components/FloatingLabelSelect/FloatingLabelSelect.js.map +1 -1
  62. package/dist/es/components/Icon/index.js +2 -0
  63. package/dist/es/components/Icon/index.js.map +1 -1
  64. package/dist/es/components/Icon/svg/Disclosure.js +5 -0
  65. package/dist/es/components/Icon/svg/Disclosure.js.map +1 -0
  66. package/dist/es/components/Icon/svg/Eyedropper.js +6 -0
  67. package/dist/es/components/Icon/svg/Eyedropper.js.map +1 -0
  68. package/dist/es/components/Indicator/LoadingIndicator.js +1 -1
  69. package/dist/es/components/Indicator/LoadingIndicator.js.map +1 -1
  70. package/dist/es/components/Input/Input.js +3 -3
  71. package/dist/es/components/Input/Input.js.map +1 -1
  72. package/dist/es/components/InputGroup/InputGroup.js +3 -1
  73. package/dist/es/components/InputGroup/InputGroup.js.map +1 -1
  74. package/dist/es/components/MarkdownEditor/MarkdownEditor.js +95 -93
  75. package/dist/es/components/MarkdownEditor/MarkdownEditor.js.map +1 -1
  76. package/dist/es/components/Menu/Menu.js +306 -34
  77. package/dist/es/components/Menu/Menu.js.map +1 -1
  78. package/dist/es/components/OTPInput/OTPInput.js +4 -1
  79. package/dist/es/components/OTPInput/OTPInput.js.map +1 -1
  80. package/dist/es/components/Page/Page.js +147 -19
  81. package/dist/es/components/Page/Page.js.map +1 -1
  82. package/dist/es/components/Page/index.js.map +1 -1
  83. package/dist/es/components/PageControl/PageControl.js +146 -0
  84. package/dist/es/components/PageControl/PageControl.js.map +1 -0
  85. package/dist/es/components/PageControl/index.js +2 -0
  86. package/dist/es/components/PageControl/index.js.map +1 -0
  87. package/dist/es/components/Popover/Popover.js +75 -33
  88. package/dist/es/components/Popover/Popover.js.map +1 -1
  89. package/dist/es/components/Popover/deferredOutsidePress.js +90 -0
  90. package/dist/es/components/Popover/deferredOutsidePress.js.map +1 -0
  91. package/dist/es/components/Popover/usePopoverContext.js.map +1 -1
  92. package/dist/es/components/RadioGroup/RadioGroup.js +1 -1
  93. package/dist/es/components/RadioGroup/RadioGroup.js.map +1 -1
  94. package/dist/es/components/Select/Select.js +98 -32
  95. package/dist/es/components/Select/Select.js.map +1 -1
  96. package/dist/es/components/SelectControl/SelectControl.js +48 -29
  97. package/dist/es/components/SelectControl/SelectControl.js.map +1 -1
  98. package/dist/es/components/SelectControl/index.js +1 -1
  99. package/dist/es/components/SelectControl/index.js.map +1 -1
  100. package/dist/es/components/ShimmerText/ShimmerText.js +17 -7
  101. package/dist/es/components/ShimmerText/ShimmerText.js.map +1 -1
  102. package/dist/es/components/Sidebar/Sidebar.js +21 -8
  103. package/dist/es/components/Sidebar/Sidebar.js.map +1 -1
  104. package/dist/es/components/Slider/Slider.js +61 -15
  105. package/dist/es/components/Slider/Slider.js.map +1 -1
  106. package/dist/es/components/Sortable/Sortable.js +16 -6
  107. package/dist/es/components/Sortable/Sortable.js.map +1 -1
  108. package/dist/es/components/Stepper/Stepper.js +114 -0
  109. package/dist/es/components/Stepper/Stepper.js.map +1 -0
  110. package/dist/es/components/Stepper/index.js +2 -0
  111. package/dist/es/components/Stepper/index.js.map +1 -0
  112. package/dist/es/components/Switch/Switch.js +2 -2
  113. package/dist/es/components/Switch/Switch.js.map +1 -1
  114. package/dist/es/components/TabBar/TabBar.js +128 -0
  115. package/dist/es/components/TabBar/TabBar.js.map +1 -0
  116. package/dist/es/components/TabBar/index.js +2 -0
  117. package/dist/es/components/TabBar/index.js.map +1 -0
  118. package/dist/es/components/Tabs/Tabs.js +27 -11
  119. package/dist/es/components/Tabs/Tabs.js.map +1 -1
  120. package/dist/es/components/TagInput/TagInput.js +40 -4
  121. package/dist/es/components/TagInput/TagInput.js.map +1 -1
  122. package/dist/es/components/Textarea/Textarea.js +7 -1
  123. package/dist/es/components/Textarea/Textarea.js.map +1 -1
  124. package/dist/es/components/Toast/ToastRenderer.js +86 -0
  125. package/dist/es/components/Toast/ToastRenderer.js.map +1 -0
  126. package/dist/es/components/Toast/Toaster.js +31 -16
  127. package/dist/es/components/Toast/Toaster.js.map +1 -1
  128. package/dist/es/components/Toast/toastLifecycle.js +283 -0
  129. package/dist/es/components/Toast/toastLifecycle.js.map +1 -0
  130. package/dist/es/components/Toolbar/Toolbar.js +92 -0
  131. package/dist/es/components/Toolbar/Toolbar.js.map +1 -0
  132. package/dist/es/components/Toolbar/index.js +2 -0
  133. package/dist/es/components/Toolbar/index.js.map +1 -0
  134. package/dist/es/components/Tooltip/CopyTooltip.js +37 -11
  135. package/dist/es/components/Tooltip/CopyTooltip.js.map +1 -1
  136. package/dist/es/components/Tooltip/Tooltip.js +61 -9
  137. package/dist/es/components/Tooltip/Tooltip.js.map +1 -1
  138. package/dist/es/hooks/useFloatingBoundary.js +35 -0
  139. package/dist/es/hooks/useFloatingBoundary.js.map +1 -0
  140. package/dist/es/hooks/usePhoneSubmenu.js +22 -0
  141. package/dist/es/hooks/usePhoneSubmenu.js.map +1 -0
  142. package/dist/es/lib/copyToClipboard.js +16 -7
  143. package/dist/es/lib/copyToClipboard.js.map +1 -1
  144. package/dist/es/lib/fieldRow.js +7 -1
  145. package/dist/es/lib/fieldRow.js.map +1 -1
  146. package/dist/es/lib/floatingBoundary.js +90 -0
  147. package/dist/es/lib/floatingBoundary.js.map +1 -0
  148. package/dist/es/lib/focusRestore.js +56 -0
  149. package/dist/es/lib/focusRestore.js.map +1 -0
  150. package/dist/es/lib/helpers.js +0 -18
  151. package/dist/es/lib/helpers.js.map +1 -1
  152. package/dist/es/lib/inputMode.js +9 -0
  153. package/dist/es/lib/inputMode.js.map +1 -0
  154. package/dist/es/lib/menuInitialFocus.js +100 -0
  155. package/dist/es/lib/menuInitialFocus.js.map +1 -0
  156. package/dist/es/lib/menuSubmenuPlacement.js +264 -0
  157. package/dist/es/lib/menuSubmenuPlacement.js.map +1 -0
  158. package/dist/es/lib/menuTriggerCover.js +70 -0
  159. package/dist/es/lib/menuTriggerCover.js.map +1 -0
  160. package/dist/es/lib/observeTextareaWidth.js +49 -0
  161. package/dist/es/lib/observeTextareaWidth.js.map +1 -0
  162. package/dist/es/lib/scrollEdges.js +34 -0
  163. package/dist/es/lib/scrollEdges.js.map +1 -0
  164. package/dist/es/lib/selectPress.js +34 -0
  165. package/dist/es/lib/selectPress.js.map +1 -0
  166. package/dist/es/lib/sortable.js +74 -20
  167. package/dist/es/lib/sortable.js.map +1 -1
  168. package/dist/es/styles/mobile-materials.css +1 -0
  169. package/dist/es/styles/mobile-surfaces.css +1 -0
  170. package/dist/types/components/Button/Button.d.ts +2 -0
  171. package/dist/types/components/Button/NavigationButton.d.ts +8 -0
  172. package/dist/types/components/Button/NavigationGlyph.d.ts +7 -0
  173. package/dist/types/components/Button/index.d.ts +1 -0
  174. package/dist/types/components/ColorPicker/ColorPicker.d.ts +34 -0
  175. package/dist/types/components/ColorPicker/ColorWell.d.ts +32 -0
  176. package/dist/types/components/ColorPicker/index.d.ts +3 -0
  177. package/dist/types/components/ColorPicker/shared.d.ts +69 -0
  178. package/dist/types/components/ContextMenu/ContextMenu.d.ts +78 -0
  179. package/dist/types/components/ContextMenu/index.d.ts +1 -0
  180. package/dist/types/components/ContextMenu/shared.d.ts +50 -0
  181. package/dist/types/components/DatePicker/CalendarNavigationIcon.d.ts +5 -0
  182. package/dist/types/components/DatePicker/DatePicker.d.ts +7 -1
  183. package/dist/types/components/DatePicker/useCalendarGutter.d.ts +1 -0
  184. package/dist/types/components/DateRangePicker/DateRangePicker.d.ts +2 -0
  185. package/dist/types/components/Dialog/Dialog.d.ts +17 -6
  186. package/dist/types/components/Dialog/index.d.ts +1 -1
  187. package/dist/types/components/Field/Field.d.ts +12 -2
  188. package/dist/types/components/FieldGroup/FieldGroup.d.ts +11 -2
  189. package/dist/types/components/Icon/index.d.ts +2 -0
  190. package/dist/types/components/Icon/svg/Disclosure.d.ts +6 -0
  191. package/dist/types/components/Icon/svg/Eyedropper.d.ts +6 -0
  192. package/dist/types/components/Indicator/LoadingIndicator.d.ts +1 -1
  193. package/dist/types/components/Menu/Menu.d.ts +74 -9
  194. package/dist/types/components/Page/Page.d.ts +24 -9
  195. package/dist/types/components/Page/index.d.ts +1 -1
  196. package/dist/types/components/PageControl/PageControl.d.ts +52 -0
  197. package/dist/types/components/PageControl/index.d.ts +1 -0
  198. package/dist/types/components/Popover/Popover.d.ts +11 -6
  199. package/dist/types/components/Popover/deferredOutsidePress.d.ts +14 -0
  200. package/dist/types/components/Popover/usePopoverContext.d.ts +1 -0
  201. package/dist/types/components/Select/Select.d.ts +3 -3
  202. package/dist/types/components/SelectControl/SelectControl.d.ts +2 -2
  203. package/dist/types/components/SelectControl/index.d.ts +1 -1
  204. package/dist/types/components/Sortable/Sortable.d.ts +1 -1
  205. package/dist/types/components/Stepper/Stepper.d.ts +56 -0
  206. package/dist/types/components/Stepper/index.d.ts +1 -0
  207. package/dist/types/components/Switch/Switch.d.ts +3 -1
  208. package/dist/types/components/TabBar/TabBar.d.ts +74 -0
  209. package/dist/types/components/TabBar/index.d.ts +1 -0
  210. package/dist/types/components/Toast/ToastRenderer.d.ts +3 -0
  211. package/dist/types/components/Toast/Toaster.d.ts +4 -2
  212. package/dist/types/components/Toast/toastLifecycle.d.ts +90 -0
  213. package/dist/types/components/Toolbar/Toolbar.d.ts +93 -0
  214. package/dist/types/components/Toolbar/index.d.ts +1 -0
  215. package/dist/types/components/Tooltip/Tooltip.d.ts +2 -2
  216. package/dist/types/hooks/useFloatingBoundary.d.ts +24 -0
  217. package/dist/types/hooks/usePhoneSubmenu.d.ts +3 -0
  218. package/dist/types/lib/fieldRow.d.ts +6 -0
  219. package/dist/types/lib/floatingBoundary.d.ts +9 -0
  220. package/dist/types/lib/focusRestore.d.ts +5 -0
  221. package/dist/types/lib/helpers.d.ts +1 -5
  222. package/dist/types/lib/inputMode.d.ts +7 -0
  223. package/dist/types/lib/menuInitialFocus.d.ts +9 -0
  224. package/dist/types/lib/menuSubmenuPlacement.d.ts +57 -0
  225. package/dist/types/lib/menuTriggerCover.d.ts +23 -0
  226. package/dist/types/lib/observeTextareaWidth.d.ts +2 -0
  227. package/dist/types/lib/scrollEdges.d.ts +16 -0
  228. package/dist/types/lib/selectPress.d.ts +23 -0
  229. package/dist/types/lib/sortable.d.ts +1 -1
  230. package/package.json +6 -2
@@ -1 +1 @@
1
- {"version":3,"file":"Sortable.js","sourceRoot":"","sources":["../../../../src/components/Sortable/Sortable.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,mBAAmB,EAA0C,MAAM,oBAAoB,CAAA;AAC3H,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAEtC,OAAO,CAAC,MAAM,wDAAwD,CAAA;AAqDtE,MAAM,iBAAiB,GAAG,CAAC,KAAgB,EAAE,EAAE,CAAC,KAAK,CAAC,cAAc,EAAE,CAAA;AAEtE,8HAA8H;AAC9H,MAAM,UAAU,QAAQ,CAAI,EAC1B,KAAK,EACL,QAAQ,EACR,MAAM,GAAG,MAAM,EACf,EAAE,EAAE,GAAG,GAAG,KAAK,EACf,QAAQ,GAAG,KAAK,EAChB,OAAO,EACP,KAAK,EACL,IAAI,EACJ,MAAM,EACN,MAAM,EACN,SAAS,EACT,QAAQ,EACR,aAAa,EACb,SAAS,EACT,GAAG,IAAI,EACU;IACjB,MAAM,MAAM,GAAG,cAAc,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;IAExE,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,EAAU,EAAE,EAAE;QAC1C,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC,OAAO,CAAA;QACnF,SAAS,CAAC,GAAG,EAAE;YACb,MAAM,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,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AAA;IAED,OAAO,CACL,KAAC,GAAG,OACE,IAAI,EACR,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE,SAAS,CAAC,mBACxB,EAAE,iBACH,MAAM,mBACJ,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,kBAC1B,OAAO,EAAE,QAAQ,EAAE,gBACrB,KAAK,eACN,IAAI,EACf,aAAa,EAAE,iBAAiB,EAChC,SAAS,EAAE,aAAa,EACxB,WAAW,EAAE,iBAAiB,YAE7B,QAAQ,GACL,CACP,CAAA;AACH,CAAC;AAUD,gFAAgF;AAChF,SAAS,cAAc,CAAC,EAAE,YAAY,EAAE,SAAS,GAAG,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAuB;IAChH,OAAO,CACL,oBAAY,IAAI,EAAE,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,SAAS,CAAC,0BAAuB,EAAE,gBAAa,SAAS,YAChH,QAAQ,IAAI,KAAC,YAAY,0BAAe,GAClC,CACV,CAAA;AACH,CAAC;AAkBD,+FAA+F;AAC/F,SAAS,cAAc,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,GAAG,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,EAAuB;IAC/F,OAAO,KAAC,GAAG,OAAK,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,SAAS,CAAC,0BAAwB,KAAK,eAAa,IAAI,GAAI,CAAA;AAC9G,CAAC;AAED,QAAQ,CAAC,MAAM,GAAG,cAAc,CAAA;AAChC,QAAQ,CAAC,MAAM,GAAG,cAAc,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport type { ComponentProps, DragEvent, ElementType, KeyboardEvent, PointerEvent, ReactNode } from \"react\"\nimport { flushSync } from \"react-dom\"\n\nimport { useLatestValue } from \"../../hooks/useLatestValue\"\nimport { moveItem, sortableKeyDown, sortablePointerDown, type SortableLayout, type SortableMove } from \"../../lib/sortable\"\nimport { GripVertical } from \"../Icon\"\n\nimport s from \"@plexui/styles/components/Sortable/Sortable.module.css\"\n\nexport type SortableProps<T> = {\n /**\n * The list, in the order of the children\n */\n value: readonly T[]\n /**\n * Called with the new order after a drop\n */\n onChange?: (value: T[]) => void\n /**\n * `list` for rows one under another, `grid` for items that stand side by side\n * @default list\n */\n layout?: SortableLayout\n /**\n * Element to render, such as `TableBody` for table rows\n * @default div\n */\n as?: ElementType\n /**\n * Turns dragging off\n * @default false\n */\n disabled?: boolean\n /**\n * Shows the grips of `Sortable.Handle`. A hidden grip still takes the keyboard, and the item drags from anywhere but a control.\n * @default true in a table, otherwise false\n */\n handles?: boolean\n /**\n * Lists of one group trade items, and a `Sortable.Target` of that group takes them. Give each list a `name`.\n */\n group?: string\n /**\n * Names the list in `onMove`\n */\n name?: string\n /**\n * An item moved, inside this list or out of it. Out of it the app updates both lists: `onChange` is for a move inside one.\n */\n onMove?: (move: SortableMove<T>) => void\n /**\n * A drag rests on a `Sortable.Target` of the group: open what it stands for or go there\n */\n onHold?: (name: string) => void\n /**\n * The items, one direct child per entry of `value`, keyed by the entry and not by its index\n */\n children?: ReactNode\n} & Omit<ComponentProps<\"div\">, \"children\" | \"onChange\">\n\nconst preventNativeDrag = (event: DragEvent) => event.preventDefault()\n\n/** Reorders its direct children by dragging, from anywhere but a control, or by a `Sortable.Handle` where grips are shown. */\nexport function Sortable<T>({\n value,\n onChange,\n layout = \"list\",\n as: Tag = \"div\",\n disabled = false,\n handles,\n group,\n name,\n onMove,\n onHold,\n className,\n children,\n onPointerDown,\n onKeyDown,\n ...rest\n}: SortableProps<T>) {\n const latest = useLatestValue({ value, onChange, onMove, onHold, name })\n\n const commit = (from: number, to: number) => {\n const { value: items, onChange: change, onMove: move, name: list } = latest.current\n flushSync(() => {\n change?.(moveItem(items, from, to))\n move?.({ item: items[from], from: list as string, fromIndex: from, to: list as string, toIndex: to })\n })\n }\n\n const link = {\n move: (fromIndex: number, to: string, toIndex?: number) => {\n const { value: items, onMove: move, name: from } = latest.current\n flushSync(() => move?.({ item: items[fromIndex], from: from as string, fromIndex, to, toIndex }))\n },\n hold: (target: string) => latest.current.onHold?.(target),\n }\n\n const handlePointerDown = (event: PointerEvent<HTMLDivElement>) => {\n onPointerDown?.(event)\n if (!disabled) sortablePointerDown(event.nativeEvent, event.currentTarget, layout, commit, link)\n }\n\n const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n onKeyDown?.(event)\n if (!disabled) void sortableKeyDown(event.nativeEvent, event.currentTarget, commit, link)\n }\n\n return (\n <Tag\n {...rest}\n className={clsx(s.Sortable, className)}\n data-sortable=\"\"\n data-layout={layout}\n data-disabled={disabled ? \"\" : undefined}\n data-handles={handles?.toString()}\n data-group={group}\n data-name={name}\n onPointerDown={handlePointerDown}\n onKeyDown={handleKeyDown}\n onDragStart={preventNativeDrag}\n >\n {children}\n </Tag>\n )\n}\n\nexport type SortableHandleProps = {\n /**\n * Name of the handle for assistive technology\n * @default Reorder\n */\n \"aria-label\"?: string\n} & ComponentProps<\"button\">\n\n/** The grip of an item. Arrow keys move the item while the handle has focus. */\nfunction SortableHandle({ \"aria-label\": ariaLabel = \"Reorder\", className, children, ...rest }: SortableHandleProps) {\n return (\n <button {...rest} type=\"button\" className={clsx(s.Handle, className)} data-sortable-handle=\"\" aria-label={ariaLabel}>\n {children ?? <GripVertical aria-hidden />}\n </button>\n )\n}\n\nexport type SortableTargetProps = {\n /**\n * The `group` of the lists whose items it takes\n */\n group: string\n /**\n * Names the target in `onMove` and `onHold` on the list\n */\n name: string\n /**\n * Element to render\n * @default div\n */\n as?: ElementType\n} & ComponentProps<\"div\">\n\n/** A place outside the lists that takes an item whole: a folder, a category in a side list. */\nfunction SortableTarget({ group, name, as: Tag = \"div\", className, ...rest }: SortableTargetProps) {\n return <Tag {...rest} className={clsx(s.Target, className)} data-sortable-target={group} data-name={name} />\n}\n\nSortable.Handle = SortableHandle\nSortable.Target = SortableTarget\n"]}
1
+ {"version":3,"file":"Sortable.js","sourceRoot":"","sources":["../../../../src/components/Sortable/Sortable.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,SAAS,EAAE,MAAM,EAAgH,MAAM,OAAO,CAAA;AACvJ,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,mBAAmB,EAA0C,MAAM,oBAAoB,CAAA;AAC3H,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAEjD,OAAO,CAAC,MAAM,wDAAwD,CAAA;AAqDtE,MAAM,iBAAiB,GAAG,CAAC,KAAgB,EAAE,EAAE,CAAC,KAAK,CAAC,cAAc,EAAE,CAAA;AAEtE,8HAA8H;AAC9H,MAAM,UAAU,QAAQ,CAAI,EAC1B,KAAK,EACL,QAAQ,EACR,MAAM,GAAG,MAAM,EACf,EAAE,EAAE,GAAG,GAAG,KAAK,EACf,QAAQ,GAAG,KAAK,EAChB,OAAO,EACP,KAAK,EACL,IAAI,EACJ,MAAM,EACN,MAAM,EACN,SAAS,EACT,QAAQ,EACR,aAAa,EACb,SAAS,EACT,GAAG,IAAI,EACU;IACjB,MAAM,MAAM,GAAG,cAAc,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;IACxE,MAAM,UAAU,GAAG,MAAM,CAAyC,SAAS,CAAC,CAAA;IAC5E,SAAS,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;IACjD,SAAS,CAAC,GAAG,EAAE;QAC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C,0BAAuB,EAAE,gBAAa,SAAS,YAChH,QAAQ,IAAI,8BAAE,KAAC,YAAY,IAAC,SAAS,EAAE,CAAC,CAAC,WAAW,wBAAgB,EAAA,KAAC,SAAS,IAAC,SAAS,EAAE,CAAC,CAAC,SAAS,wBAAgB,IAAG,GAClH,CACV,CAAA;AACH,CAAC;AAkBD,+FAA+F;AAC/F,SAAS,cAAc,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,GAAG,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,EAAuB;IAC/F,OAAO,KAAC,GAAG,OAAK,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,SAAS,CAAC,0BAAwB,KAAK,eAAa,IAAI,GAAI,CAAA;AAC9G,CAAC;AAED,QAAQ,CAAC,MAAM,GAAG,cAAc,CAAA;AAChC,QAAQ,CAAC,MAAM,GAAG,cAAc,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { useEffect, useRef, type ComponentProps, type DragEvent, type ElementType, type KeyboardEvent, type PointerEvent, type ReactNode } from \"react\"\nimport { flushSync } from \"react-dom\"\n\nimport { useLatestValue } from \"../../hooks/useLatestValue\"\nimport { moveItem, sortableKeyDown, sortablePointerDown, type SortableLayout, type SortableMove } from \"../../lib/sortable\"\nimport { GripVertical, Hamburger } from \"../Icon\"\n\nimport s from \"@plexui/styles/components/Sortable/Sortable.module.css\"\n\nexport type SortableProps<T> = {\n /**\n * The list, in the order of the children\n */\n value: readonly T[]\n /**\n * Called with the new order after a drop\n */\n onChange?: (value: T[]) => void\n /**\n * `list` for rows one under another, `grid` for items that stand side by side\n * @default list\n */\n layout?: SortableLayout\n /**\n * Element to render, such as `TableBody` for table rows\n * @default div\n */\n as?: ElementType\n /**\n * Turns dragging off\n * @default false\n */\n disabled?: boolean\n /**\n * Shows the grips of `Sortable.Handle`. A hidden grip still takes the keyboard, and the item drags from anywhere but a control.\n * @default true in a table, otherwise false\n */\n handles?: boolean\n /**\n * Lists of one group trade items, and a `Sortable.Target` of that group takes them. Give each list a `name`.\n */\n group?: string\n /**\n * Names the list in `onMove`\n */\n name?: string\n /**\n * An item moved, inside this list or out of it. Out of it the app updates both lists: `onChange` is for a move inside one.\n */\n onMove?: (move: SortableMove<T>) => void\n /**\n * A drag rests on a `Sortable.Target` of the group: open what it stands for or go there\n */\n onHold?: (name: string) => void\n /**\n * The items, one direct child per entry of `value`, keyed by the entry and not by its index\n */\n children?: ReactNode\n} & Omit<ComponentProps<\"div\">, \"children\" | \"onChange\">\n\nconst preventNativeDrag = (event: DragEvent) => event.preventDefault()\n\n/** Reorders its direct children by dragging, from anywhere but a control, or by a `Sortable.Handle` where grips are shown. */\nexport function Sortable<T>({\n value,\n onChange,\n layout = \"list\",\n as: Tag = \"div\",\n disabled = false,\n handles,\n group,\n name,\n onMove,\n onHold,\n className,\n children,\n onPointerDown,\n onKeyDown,\n ...rest\n}: SortableProps<T>) {\n const latest = useLatestValue({ value, onChange, onMove, onHold, name })\n const cancelDrag = useRef<ReturnType<typeof sortablePointerDown>>(undefined)\n useEffect(() => () => cancelDrag.current?.(), [])\n useEffect(() => {\n if (disabled) {\n cancelDrag.current?.()\n cancelDrag.current = undefined\n }\n }, [disabled])\n\n const commit = (from: number, to: number) => {\n const { value: items, onChange: change, onMove: move, name: list } = latest.current\n flushSync(() => {\n change?.(moveItem(items, from, to))\n move?.({ item: items[from], from: list as string, fromIndex: from, to: list as string, toIndex: to })\n })\n }\n\n const link = {\n move: (fromIndex: number, to: string, toIndex?: number) => {\n const { value: items, onMove: move, name: from } = latest.current\n flushSync(() => move?.({ item: items[fromIndex], from: from as string, fromIndex, to, toIndex }))\n },\n hold: (target: string) => latest.current.onHold?.(target),\n }\n\n const handlePointerDown = (event: PointerEvent<HTMLDivElement>) => {\n onPointerDown?.(event)\n if (!disabled && !event.defaultPrevented) {\n cancelDrag.current = sortablePointerDown(event.nativeEvent, event.currentTarget, layout, commit, link) ?? cancelDrag.current\n }\n }\n\n const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n onKeyDown?.(event)\n if (!disabled && !event.defaultPrevented) void sortableKeyDown(event.nativeEvent, event.currentTarget, commit, link)\n }\n\n return (\n <Tag\n {...rest}\n className={clsx(s.Sortable, className)}\n data-sortable=\"\"\n data-layout={layout}\n data-disabled={disabled ? \"\" : undefined}\n data-handles={handles?.toString()}\n data-group={group}\n data-name={name}\n onPointerDown={handlePointerDown}\n onKeyDown={handleKeyDown}\n onDragStart={preventNativeDrag}\n >\n {children}\n </Tag>\n )\n}\n\nexport type SortableHandleProps = {\n /**\n * Name of the handle for assistive technology\n * @default Reorder\n */\n \"aria-label\"?: string\n} & ComponentProps<\"button\">\n\n/** The grip of an item. Arrow keys move the item while the handle has focus. */\nfunction SortableHandle({ \"aria-label\": ariaLabel = \"Reorder\", className, children, ...rest }: SortableHandleProps) {\n return (\n <button {...rest} type=\"button\" className={clsx(s.Handle, className)} data-sortable-handle=\"\" aria-label={ariaLabel}>\n {children ?? <><GripVertical className={s.DesktopGrip} aria-hidden /><Hamburger className={s.PhoneGrip} aria-hidden /></>}\n </button>\n )\n}\n\nexport type SortableTargetProps = {\n /**\n * The `group` of the lists whose items it takes\n */\n group: string\n /**\n * Names the target in `onMove` and `onHold` on the list\n */\n name: string\n /**\n * Element to render\n * @default div\n */\n as?: ElementType\n} & ComponentProps<\"div\">\n\n/** A place outside the lists that takes an item whole: a folder, a category in a side list. */\nfunction SortableTarget({ group, name, as: Tag = \"div\", className, ...rest }: SortableTargetProps) {\n return <Tag {...rest} className={clsx(s.Target, className)} data-sortable-target={group} data-name={name} />\n}\n\nSortable.Handle = SortableHandle\nSortable.Target = SortableTarget\n"]}
@@ -0,0 +1,114 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import clsx from "clsx";
4
+ import { useCallback, useEffect, useRef, useState, } from "react";
5
+ import s from "@plexui/styles/components/Stepper/Stepper.module.css";
6
+ import { useLatestValue } from "../../hooks/useLatestValue.js";
7
+ import { Minus, Plus } from "../Icon/index.js";
8
+ /** Delay before a held segment starts repeating, and the time between repeats, in ms. */
9
+ const REPEAT_DELAY = 400;
10
+ const REPEAT_INTERVAL = 100;
11
+ const decimals = (n) => {
12
+ const [, fraction = ""] = String(n).split(".");
13
+ return fraction.length;
14
+ };
15
+ /** The value one step away, clamped to the range or wrapped, without floating point drift. */
16
+ export const stepValue = (current, direction, { min, max, step, wrap }) => {
17
+ const precision = Math.max(decimals(step), decimals(min), decimals(current));
18
+ const next = Number((current + direction * step).toFixed(precision));
19
+ if (next > max)
20
+ return wrap ? min : max;
21
+ if (next < min)
22
+ return wrap ? max : min;
23
+ return next;
24
+ };
25
+ /**
26
+ * Two segments that decrease and increase a number, as the iOS 26 stepper does. It shows no value of its own:
27
+ * name it with `aria-label` or `aria-labelledby` and show the value beside it. Keyboard focus lands on the
28
+ * stepper, a spin button: Up and Down step, Page Up and Page Down step ten times, Home and End go to the range ends.
29
+ */
30
+ export function Stepper({ id, value: valueProp, defaultValue, onChange, min = 0, max = 100, step = 1, wrap = false, autoRepeat = true, disabled = false, pill = true, decrementLabel = "Decrease", incrementLabel = "Increase", name, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, onFocus, onBlur, className, }) {
31
+ const [internalValue, setInternalValue] = useState(() => defaultValue ?? min);
32
+ const value = valueProp ?? internalValue;
33
+ // Timers and key handlers read the value through this ref; an uncontrolled step advances it at once.
34
+ const valueRef = useLatestValue(value);
35
+ const onChangeRef = useLatestValue(onChange);
36
+ const optionsRef = useLatestValue({ min, max, step, wrap, disabled, controlled: valueProp !== undefined });
37
+ const timer = useRef(undefined);
38
+ const [pressed, setPressed] = useState(null);
39
+ const commit = useCallback((next) => {
40
+ if (next === valueRef.current)
41
+ return false;
42
+ // A controlled value changes only when the owner passes it back, as in Vue.
43
+ if (!optionsRef.current.controlled) {
44
+ valueRef.current = next;
45
+ setInternalValue(next);
46
+ }
47
+ onChangeRef.current?.(next);
48
+ return true;
49
+ }, [valueRef, optionsRef, onChangeRef]);
50
+ const stepBy = useCallback((direction, times = 1) => {
51
+ let next = valueRef.current;
52
+ for (let i = 0; i < times; i++)
53
+ next = stepValue(next, direction, optionsRef.current);
54
+ return commit(next);
55
+ }, [commit, valueRef, optionsRef]);
56
+ const stopRepeat = useCallback(() => {
57
+ clearTimeout(timer.current);
58
+ timer.current = undefined;
59
+ setPressed(null);
60
+ }, []);
61
+ useEffect(() => stopRepeat, [stopRepeat]);
62
+ const atMin = !wrap && value <= min;
63
+ const atMax = !wrap && value >= max;
64
+ const startPress = (segment, event) => {
65
+ if (event.button !== 0 || disabled)
66
+ return;
67
+ if (segment === "decrement" ? atMin : atMax)
68
+ return;
69
+ event.currentTarget.setPointerCapture?.(event.pointerId);
70
+ setPressed(segment);
71
+ const direction = segment === "decrement" ? -1 : 1;
72
+ stepBy(direction);
73
+ if (!autoRepeat)
74
+ return;
75
+ const repeat = () => {
76
+ if (optionsRef.current.disabled || !stepBy(direction))
77
+ return stopRepeat();
78
+ timer.current = setTimeout(repeat, REPEAT_INTERVAL);
79
+ };
80
+ timer.current = setTimeout(repeat, REPEAT_DELAY);
81
+ };
82
+ // A pointer steps on press, so only a click without one (assistive technology, `element.click()`) steps here.
83
+ const handleClick = (segment, event) => {
84
+ if (event.detail !== 0 || disabled)
85
+ return;
86
+ stepBy(segment === "decrement" ? -1 : 1);
87
+ };
88
+ const handleKeyDown = (event) => {
89
+ if (disabled || event.altKey || event.ctrlKey || event.metaKey)
90
+ return;
91
+ const keys = {
92
+ ArrowUp: () => stepBy(1),
93
+ ArrowDown: () => stepBy(-1),
94
+ PageUp: () => stepBy(1, 10),
95
+ PageDown: () => stepBy(-1, 10),
96
+ Home: () => commit(min),
97
+ End: () => commit(max),
98
+ };
99
+ const action = keys[event.key];
100
+ if (!action)
101
+ return;
102
+ event.preventDefault();
103
+ action();
104
+ };
105
+ const segment = (kind) => {
106
+ const atEnd = kind === "decrement" ? atMin : atMax;
107
+ const Icon = kind === "decrement" ? Minus : Plus;
108
+ return (_jsx("button", { type: "button", tabIndex: -1, "aria-label": kind === "decrement" ? decrementLabel : incrementLabel, "aria-disabled": atEnd || undefined, disabled: disabled, className: s.Segment, "data-segment": kind, "data-disabled": atEnd || disabled ? "" : undefined, "data-pressed": pressed === kind && !disabled ? "" : undefined,
109
+ // Keeps the focus where it is, as a native stepper takes none.
110
+ onMouseDown: (event) => event.preventDefault(), onPointerDown: (event) => startPress(kind, event), onPointerUp: stopRepeat, onPointerCancel: stopRepeat, onLostPointerCapture: stopRepeat, onClick: (event) => handleClick(kind, event), children: _jsx(Icon, { className: s.Icon }) }));
111
+ };
112
+ return (_jsxs("div", { id: id, role: "spinbutton", tabIndex: disabled ? -1 : 0, "aria-valuenow": value, "aria-valuemin": min, "aria-valuemax": max, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-disabled": disabled || undefined, className: clsx(s.Stepper, className), "data-disabled": disabled ? "" : undefined, "data-pill": pill ? "" : undefined, onKeyDown: handleKeyDown, onFocus: onFocus, onBlur: onBlur, children: [segment("decrement"), _jsx("span", { className: s.Separator, "aria-hidden": "true" }), segment("increment"), name !== undefined && _jsx("input", { type: "hidden", name: name, value: value, disabled: disabled })] }));
113
+ }
114
+ //# sourceMappingURL=Stepper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Stepper.js","sourceRoot":"","sources":["../../../../src/components/Stepper/Stepper.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAKL,WAAW,EACX,SAAS,EACT,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAA;AACd,OAAO,CAAC,MAAM,sDAAsD,CAAA;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,KAAK,E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,CAAC,IAAI,EAAE,KAAK,CAAC,YAE5C,KAAC,IAAI,IAAC,SAAS,EAAE,CAAC,CAAC,IAAI,GAAI,GACpB,CACV,CAAA;IACH,CAAC,CAAA;IAED,OAAO,CACL,eACE,EAAE,EAAE,EAAE,EACN,IAAI,EAAC,YAAY,EACjB,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,mBACZ,KAAK,mBACL,GAAG,mBACH,GAAG,gBACN,SAAS,qBACJ,cAAc,sBACb,eAAe,mBAClB,QAAQ,IAAI,SAAS,EACpC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE,SAAS,CAAC,mBACtB,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,eAC7B,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,EAChC,SAAS,EAAE,aAAa,EACxB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,aAEb,OAAO,CAAC,WAAW,CAAC,EACrB,eAAM,SAAS,EAAE,CAAC,CAAC,SAAS,iBAAc,MAAM,GAAG,EAClD,OAAO,CAAC,WAAW,CAAC,EACpB,IAAI,KAAK,SAAS,IAAI,gBAAO,IAAI,EAAC,QAAQ,EAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,GAAI,IACxF,CACP,CAAA;AACH,CAAC","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport {\n type FocusEventHandler,\n type KeyboardEvent,\n type MouseEvent,\n type PointerEvent,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from \"react\"\nimport s from \"@plexui/styles/components/Stepper/Stepper.module.css\"\nimport { useLatestValue } from \"../../hooks/useLatestValue\"\nimport { Minus, Plus } from \"../Icon\"\n\nexport type StepperProps = {\n /** The `id` of the stepper. */\n id?: string\n /** The controlled value. Use with `onChange`. */\n value?: number\n /** The value when it is initially rendered. Use when you do not need to control the value. @default min */\n defaultValue?: number\n /** Called with the next value after a step. */\n onChange?: (value: number) => void\n /** The lowest value. @default 0 */\n min?: number\n /** The highest value. @default 100 */\n max?: number\n /** The amount each step adds or removes. @default 1 */\n step?: number\n /** A step past `max` continues from `min`, and one below `min` from `max`. @default false */\n wrap?: boolean\n /** Holding a segment keeps stepping, as a native stepper does. @default true */\n autoRepeat?: boolean\n /** When `true`, prevents the user from interacting with the stepper. */\n disabled?: boolean\n /** Fully rounded ends. @default true */\n pill?: boolean\n /** Accessible name of the decrement segment. @default \"Decrease\" */\n decrementLabel?: string\n /** Accessible name of the increment segment. @default \"Increase\" */\n incrementLabel?: string\n /** The name of the stepper. Submits its value with the owning form. */\n name?: string\n /** Accessible name of the value the stepper changes, when no visible label names it. */\n \"aria-label\"?: string\n /** The `id` of the visible label of the value the stepper changes. */\n \"aria-labelledby\"?: string\n /** The `id` of an element that describes the stepper, such as the text that shows its value. */\n \"aria-describedby\"?: string\n /** Event handler called when the stepper gains focus. */\n onFocus?: FocusEventHandler<HTMLDivElement>\n /** Event handler called when the stepper loses focus. */\n onBlur?: FocusEventHandler<HTMLDivElement>\n /** CSS classes applied to the stepper */\n className?: string\n}\n\n/** Delay before a held segment starts repeating, and the time between repeats, in ms. */\nconst REPEAT_DELAY = 400\nconst REPEAT_INTERVAL = 100\n\nconst decimals = (n: number) => {\n const [, fraction = \"\"] = String(n).split(\".\")\n return fraction.length\n}\n\n/** The value one step away, clamped to the range or wrapped, without floating point drift. */\nexport const stepValue = (current: number, direction: 1 | -1, { min, max, step, wrap }: { min: number; max: number; step: number; wrap: boolean }) => {\n const precision = Math.max(decimals(step), decimals(min), decimals(current))\n const next = Number((current + direction * step).toFixed(precision))\n if (next > max) return wrap ? min : max\n if (next < min) return wrap ? max : min\n return next\n}\n\n/**\n * Two segments that decrease and increase a number, as the iOS 26 stepper does. It shows no value of its own:\n * name it with `aria-label` or `aria-labelledby` and show the value beside it. Keyboard focus lands on the\n * stepper, a spin button: Up and Down step, Page Up and Page Down step ten times, Home and End go to the range ends.\n */\nexport function Stepper({\n id,\n value: valueProp,\n defaultValue,\n onChange,\n min = 0,\n max = 100,\n step = 1,\n wrap = false,\n autoRepeat = true,\n disabled = false,\n pill = true,\n decrementLabel = \"Decrease\",\n incrementLabel = \"Increase\",\n name,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n onFocus,\n onBlur,\n className,\n}: StepperProps) {\n const [internalValue, setInternalValue] = useState(() => defaultValue ?? min)\n const value = valueProp ?? internalValue\n // Timers and key handlers read the value through this ref; an uncontrolled step advances it at once.\n const valueRef = useLatestValue(value)\n const onChangeRef = useLatestValue(onChange)\n const optionsRef = useLatestValue({ min, max, step, wrap, disabled, controlled: valueProp !== undefined })\n const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)\n const [pressed, setPressed] = useState<\"decrement\" | \"increment\" | null>(null)\n\n const commit = useCallback((next: number) => {\n if (next === valueRef.current) return false\n // A controlled value changes only when the owner passes it back, as in Vue.\n if (!optionsRef.current.controlled) {\n valueRef.current = next\n setInternalValue(next)\n }\n onChangeRef.current?.(next)\n return true\n }, [valueRef, optionsRef, onChangeRef])\n\n const stepBy = useCallback((direction: 1 | -1, times = 1) => {\n let next = valueRef.current\n for (let i = 0; i < times; i++) next = stepValue(next, direction, optionsRef.current)\n return commit(next)\n }, [commit, valueRef, optionsRef])\n\n const stopRepeat = useCallback(() => {\n clearTimeout(timer.current)\n timer.current = undefined\n setPressed(null)\n }, [])\n\n useEffect(() => stopRepeat, [stopRepeat])\n\n const atMin = !wrap && value <= min\n const atMax = !wrap && value >= max\n\n const startPress = (segment: \"decrement\" | \"increment\", event: PointerEvent<HTMLButtonElement>) => {\n if (event.button !== 0 || disabled) return\n if (segment === \"decrement\" ? atMin : atMax) return\n event.currentTarget.setPointerCapture?.(event.pointerId)\n setPressed(segment)\n const direction = segment === \"decrement\" ? -1 : 1\n stepBy(direction)\n if (!autoRepeat) return\n const repeat = () => {\n if (optionsRef.current.disabled || !stepBy(direction)) return stopRepeat()\n timer.current = setTimeout(repeat, REPEAT_INTERVAL)\n }\n timer.current = setTimeout(repeat, REPEAT_DELAY)\n }\n\n // A pointer steps on press, so only a click without one (assistive technology, `element.click()`) steps here.\n const handleClick = (segment: \"decrement\" | \"increment\", event: MouseEvent<HTMLButtonElement>) => {\n if (event.detail !== 0 || disabled) return\n stepBy(segment === \"decrement\" ? -1 : 1)\n }\n\n const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n if (disabled || event.altKey || event.ctrlKey || event.metaKey) return\n const keys: Record<string, () => void> = {\n ArrowUp: () => stepBy(1),\n ArrowDown: () => stepBy(-1),\n PageUp: () => stepBy(1, 10),\n PageDown: () => stepBy(-1, 10),\n Home: () => commit(min),\n End: () => commit(max),\n }\n const action = keys[event.key]\n if (!action) return\n event.preventDefault()\n action()\n }\n\n const segment = (kind: \"decrement\" | \"increment\") => {\n const atEnd = kind === \"decrement\" ? atMin : atMax\n const Icon = kind === \"decrement\" ? Minus : Plus\n return (\n <button\n type=\"button\"\n tabIndex={-1}\n aria-label={kind === \"decrement\" ? decrementLabel : incrementLabel}\n aria-disabled={atEnd || undefined}\n disabled={disabled}\n className={s.Segment}\n data-segment={kind}\n data-disabled={atEnd || disabled ? \"\" : undefined}\n data-pressed={pressed === kind && !disabled ? \"\" : undefined}\n // Keeps the focus where it is, as a native stepper takes none.\n onMouseDown={(event) => event.preventDefault()}\n onPointerDown={(event) => startPress(kind, event)}\n onPointerUp={stopRepeat}\n onPointerCancel={stopRepeat}\n onLostPointerCapture={stopRepeat}\n onClick={(event) => handleClick(kind, event)}\n >\n <Icon className={s.Icon} />\n </button>\n )\n }\n\n return (\n <div\n id={id}\n role=\"spinbutton\"\n tabIndex={disabled ? -1 : 0}\n aria-valuenow={value}\n aria-valuemin={min}\n aria-valuemax={max}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={ariaDescribedBy}\n aria-disabled={disabled || undefined}\n className={clsx(s.Stepper, className)}\n data-disabled={disabled ? \"\" : undefined}\n data-pill={pill ? \"\" : undefined}\n onKeyDown={handleKeyDown}\n onFocus={onFocus}\n onBlur={onBlur}\n >\n {segment(\"decrement\")}\n <span className={s.Separator} aria-hidden=\"true\" />\n {segment(\"increment\")}\n {name !== undefined && <input type=\"hidden\" name={name} value={value} disabled={disabled} />}\n </div>\n )\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export { Stepper } from "./Stepper.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Stepper/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAqB,MAAM,WAAW,CAAA","sourcesContent":["export { Stepper, type StepperProps } from \"./Stepper\"\n"]}
@@ -4,7 +4,7 @@ import clsx from "clsx";
4
4
  import { Switch as RadixSwitch } from "radix-ui";
5
5
  import { useId } from "react";
6
6
  import s from "@plexui/styles/components/Switch/Switch.module.css";
7
- export const Switch = ({ className, label, description, id: propsId, disabled, labelPosition = "end", ...restProps }) => {
7
+ export const Switch = ({ className, label, description, id: propsId, disabled, color = "primary", labelPosition = "end", ...restProps }) => {
8
8
  const reactId = useId();
9
9
  const id = propsId ?? reactId;
10
10
  // The description only renders next to a label; it comes before any ids
@@ -12,6 +12,6 @@ export const Switch = ({ className, label, description, id: propsId, disabled, l
12
12
  const descriptionId = label && description ? `${id}-label-description` : undefined;
13
13
  const ariaDescribedBy = [descriptionId, restProps["aria-describedby"]].filter(Boolean).join(" ") ||
14
14
  undefined;
15
- return (_jsxs("div", { className: clsx(s.Container, className), "data-disabled": disabled ? "" : undefined, "data-has-label": label ? "" : undefined, "data-label-position": labelPosition, children: [_jsx(RadixSwitch.Root, { id: id, className: s.Track, disabled: disabled, ...restProps, "aria-describedby": ariaDescribedBy, children: _jsx(RadixSwitch.Thumb, { className: s.Thumb }) }), label && (description ? (_jsxs("div", { className: s.LabelGroup, children: [_jsx("label", { htmlFor: id, className: s.Label, children: label }), _jsx("span", { id: descriptionId, className: s.Description, children: description })] })) : (_jsx("label", { htmlFor: id, className: s.Label, children: label })))] }));
15
+ return (_jsxs("div", { className: clsx(s.Container, className), "data-color": color, "data-disabled": disabled ? "" : undefined, "data-has-label": label ? "" : undefined, "data-label-position": labelPosition, children: [_jsx(RadixSwitch.Root, { id: id, className: s.Track, disabled: disabled, ...restProps, "aria-describedby": ariaDescribedBy, children: _jsx(RadixSwitch.Thumb, { className: s.Thumb }) }), label && (description ? (_jsxs("div", { className: s.LabelGroup, children: [_jsx("label", { htmlFor: id, className: s.Label, children: label }), _jsx("span", { id: descriptionId, className: s.Description, children: description })] })) : (_jsx("label", { htmlFor: id, className: s.Label, children: label })))] }));
16
16
  };
17
17
  //# sourceMappingURL=Switch.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Switch.js","sourceRoot":"","sources":["../../../../src/components/Switch/Switch.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,UAAU,CAAA;AAChD,OAAO,EAA0C,KAAK,EAAE,MAAM,OAAO,CAAA;AACrE,OAAO,CAAC,MAAM,oDAAoD,CAAA;AAoClE,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,EACrB,SAAS,EACT,KAAK,EACL,WAAW,EACX,EAAE,EAAE,OAAO,EACX,QAAQ,EACR,aAAa,GAAG,KAAK,EACrB,GAAG,SAAS,EACA,EAAE,EAAE;IAChB,MAAM,OAAO,GAAG,KAAK,EAAE,CAAA;IACvB,MAAM,EAAE,GAAG,OAAO,IAAI,OAAO,CAAA;IAC7B,wEAAwE;IACxE,mCAAmC;IACnC,MAAM,aAAa,GAAG,KAAK,IAAI,WAAW,CAAC,CAAC,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC,CAAC,SAAS,CAAA;IAClF,MAAM,eAAe,GACnB,CAAC,aAAa,EAAG,SAA6C,CAAC,kBAAkB,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QAC7G,SAAS,CAAA;IAEX,OAAO,CACL,eACE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,mBACxB,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,oBACxB,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,yBACjB,aAAa,aAElC,KAAC,WAAW,CAAC,IAAI,IACf,EAAE,EAAE,EAAE,EACN,SAAS,EAAE,CAAC,CAAC,KAAK,EAClB,QAAQ,EAAE,QAAQ,KACd,SAAS,sBACK,eAAe,YAEjC,KAAC,WAAW,CAAC,KAAK,IAAC,SAAS,EAAE,CAAC,CAAC,KAAK,GAAI,GACxB,EAElB,KAAK,IAAI,CACR,WAAW,CAAC,CAAC,CAAC,CACZ,eAAK,SAAS,EAAE,CAAC,CAAC,UAAU,aAC1B,gBAAO,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,KAAK,YACnC,KAAK,GACA,EACR,eAAM,EAAE,EAAE,aAAa,EAAE,SAAS,EAAE,CAAC,CAAC,WAAW,YAC9C,WAAW,GACP,IACH,CACP,CAAC,CAAC,CAAC,CACF,gBAAO,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,KAAK,YACnC,KAAK,GACA,CACT,CACF,IACG,CACP,CAAA;AACH,CAAC,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { Switch as RadixSwitch } from \"radix-ui\"\nimport { type FocusEventHandler, type ReactNode, useId } from \"react\"\nimport s from \"@plexui/styles/components/Switch/Switch.module.css\"\n\nexport type SwitchProps = {\n /** The `id` of the switch. */\n id?: string\n /** The state of the switch when it is initially rendered. Use when you do not need to control its state. */\n defaultChecked?: boolean\n /** The controlled state of the switch. Must be used in conjunction with `onCheckedChange`. */\n checked?: boolean\n /** Optional accessible label rendered next to the switch. */\n label?: ReactNode\n /** Optional description rendered below the label. Linked via `aria-describedby`. */\n description?: ReactNode\n /** Event handler called when the state of the switch changes. */\n onCheckedChange?: (nextState: boolean) => void\n /** Event handler called when the checkbox looses focus. */\n onBlur?: FocusEventHandler<HTMLButtonElement>\n /** Event handler called when the checkbox gains focus. */\n onFocus?: FocusEventHandler<HTMLButtonElement>\n /** When `true`, prevents the user from interacting with the switch. */\n disabled?: boolean\n /** When `true`, indicates that the user must check the switch before the owning form can be submitted. */\n required?: boolean\n /** The name of the switch. Submitted with its owning form as part of a name/value pair. */\n name?: string\n /** The value given as data when submitted with a `name`. */\n value?: string\n /** CSS classes applied to wrapper node */\n className?: string\n /**\n * The position of the label relative to the switch.\n * @default end\n */\n labelPosition?: \"start\" | \"end\"\n}\n\nexport const Switch = ({\n className,\n label,\n description,\n id: propsId,\n disabled,\n labelPosition = \"end\",\n ...restProps\n}: SwitchProps) => {\n const reactId = useId()\n const id = propsId ?? reactId\n // The description only renders next to a label; it comes before any ids\n // the caller (a Field, say) passes\n const descriptionId = label && description ? `${id}-label-description` : undefined\n const ariaDescribedBy =\n [descriptionId, (restProps as { \"aria-describedby\"?: string })[\"aria-describedby\"]].filter(Boolean).join(\" \") ||\n undefined\n\n return (\n <div\n className={clsx(s.Container, className)}\n data-disabled={disabled ? \"\" : undefined}\n data-has-label={label ? \"\" : undefined}\n data-label-position={labelPosition}\n >\n <RadixSwitch.Root\n id={id}\n className={s.Track}\n disabled={disabled}\n {...restProps}\n aria-describedby={ariaDescribedBy}\n >\n <RadixSwitch.Thumb className={s.Thumb} />\n </RadixSwitch.Root>\n\n {label && (\n description ? (\n <div className={s.LabelGroup}>\n <label htmlFor={id} className={s.Label}>\n {label}\n </label>\n <span id={descriptionId} className={s.Description}>\n {description}\n </span>\n </div>\n ) : (\n <label htmlFor={id} className={s.Label}>\n {label}\n </label>\n )\n )}\n </div>\n )\n}\n"]}
1
+ {"version":3,"file":"Switch.js","sourceRoot":"","sources":["../../../../src/components/Switch/Switch.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,UAAU,CAAA;AAChD,OAAO,EAA0C,KAAK,EAAE,MAAM,OAAO,CAAA;AACrE,OAAO,CAAC,MAAM,oDAAoD,CAAA;AAsClE,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,EACrB,SAAS,EACT,KAAK,EACL,WAAW,EACX,EAAE,EAAE,OAAO,EACX,QAAQ,EACR,KAAK,GAAG,SAAS,EACjB,aAAa,GAAG,KAAK,EACrB,GAAG,SAAS,EACA,EAAE,EAAE;IAChB,MAAM,OAAO,GAAG,KAAK,EAAE,CAAA;IACvB,MAAM,EAAE,GAAG,OAAO,IAAI,OAAO,CAAA;IAC7B,wEAAwE;IACxE,mCAAmC;IACnC,MAAM,aAAa,GAAG,KAAK,IAAI,WAAW,CAAC,CAAC,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC,CAAC,SAAS,CAAA;IAClF,MAAM,eAAe,GACnB,CAAC,aAAa,EAAG,SAA6C,CAAC,kBAAkB,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QAC7G,SAAS,CAAA;IAEX,OAAO,CACL,eACE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,gBAC3B,KAAK,mBACF,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,oBACxB,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,yBACjB,aAAa,aAElC,KAAC,WAAW,CAAC,IAAI,IACf,EAAE,EAAE,EAAE,EACN,SAAS,EAAE,CAAC,CAAC,KAAK,EAClB,QAAQ,EAAE,QAAQ,KACd,SAAS,sBACK,eAAe,YAEjC,KAAC,WAAW,CAAC,KAAK,IAAC,SAAS,EAAE,CAAC,CAAC,KAAK,GAAI,GACxB,EAElB,KAAK,IAAI,CACR,WAAW,CAAC,CAAC,CAAC,CACZ,eAAK,SAAS,EAAE,CAAC,CAAC,UAAU,aAC1B,gBAAO,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,KAAK,YACnC,KAAK,GACA,EACR,eAAM,EAAE,EAAE,aAAa,EAAE,SAAS,EAAE,CAAC,CAAC,WAAW,YAC9C,WAAW,GACP,IACH,CACP,CAAC,CAAC,CAAC,CACF,gBAAO,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,KAAK,YACnC,KAAK,GACA,CACT,CACF,IACG,CACP,CAAA;AACH,CAAC,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { Switch as RadixSwitch } from \"radix-ui\"\nimport { type FocusEventHandler, type ReactNode, useId } from \"react\"\nimport s from \"@plexui/styles/components/Switch/Switch.module.css\"\n\nexport type SwitchProps = {\n /** The `id` of the switch. */\n id?: string\n /** The state of the switch when it is initially rendered. Use when you do not need to control its state. */\n defaultChecked?: boolean\n /** The controlled state of the switch. Must be used in conjunction with `onCheckedChange`. */\n checked?: boolean\n /** Checked track color. The accent option uses the platform toggle green. @default primary */\n color?: \"primary\" | \"accent\"\n /** Optional accessible label rendered next to the switch. */\n label?: ReactNode\n /** Optional description rendered below the label. Linked via `aria-describedby`. */\n description?: ReactNode\n /** Event handler called when the state of the switch changes. */\n onCheckedChange?: (nextState: boolean) => void\n /** Event handler called when the checkbox looses focus. */\n onBlur?: FocusEventHandler<HTMLButtonElement>\n /** Event handler called when the checkbox gains focus. */\n onFocus?: FocusEventHandler<HTMLButtonElement>\n /** When `true`, prevents the user from interacting with the switch. */\n disabled?: boolean\n /** When `true`, indicates that the user must check the switch before the owning form can be submitted. */\n required?: boolean\n /** The name of the switch. Submitted with its owning form as part of a name/value pair. */\n name?: string\n /** The value given as data when submitted with a `name`. */\n value?: string\n /** CSS classes applied to wrapper node */\n className?: string\n /**\n * The position of the label relative to the switch.\n * @default end\n */\n labelPosition?: \"start\" | \"end\"\n}\n\nexport const Switch = ({\n className,\n label,\n description,\n id: propsId,\n disabled,\n color = \"primary\",\n labelPosition = \"end\",\n ...restProps\n}: SwitchProps) => {\n const reactId = useId()\n const id = propsId ?? reactId\n // The description only renders next to a label; it comes before any ids\n // the caller (a Field, say) passes\n const descriptionId = label && description ? `${id}-label-description` : undefined\n const ariaDescribedBy =\n [descriptionId, (restProps as { \"aria-describedby\"?: string })[\"aria-describedby\"]].filter(Boolean).join(\" \") ||\n undefined\n\n return (\n <div\n className={clsx(s.Container, className)}\n data-color={color}\n data-disabled={disabled ? \"\" : undefined}\n data-has-label={label ? \"\" : undefined}\n data-label-position={labelPosition}\n >\n <RadixSwitch.Root\n id={id}\n className={s.Track}\n disabled={disabled}\n {...restProps}\n aria-describedby={ariaDescribedBy}\n >\n <RadixSwitch.Thumb className={s.Thumb} />\n </RadixSwitch.Root>\n\n {label && (\n description ? (\n <div className={s.LabelGroup}>\n <label htmlFor={id} className={s.Label}>\n {label}\n </label>\n <span id={descriptionId} className={s.Description}>\n {description}\n </span>\n </div>\n ) : (\n <label htmlFor={id} className={s.Label}>\n {label}\n </label>\n )\n )}\n </div>\n )\n}\n"]}
@@ -0,0 +1,128 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import clsx from "clsx";
4
+ import { createContext, useCallback, useContext, useEffect, useLayoutEffect, useRef, useState, } from "react";
5
+ import s from "@plexui/styles/components/TabBar/TabBar.module.css";
6
+ import { useLatestValue } from "../../hooks/useLatestValue.js";
7
+ import { Search as SearchIcon } from "../Icon/index.js";
8
+ import { ToolbarHostContext } from "../Toolbar/Toolbar.js";
9
+ /** A scroll of at least this many pixels in one direction minimizes or expands the bar. */
10
+ const MINIMIZE_AFTER = 8;
11
+ const TabBarContext = createContext(null);
12
+ function useTabBarContext(part) {
13
+ const context = useContext(TabBarContext);
14
+ if (!context)
15
+ throw new Error(`${part} must be used within TabBar`);
16
+ return context;
17
+ }
18
+ /**
19
+ * The tab bar of a phone screen after the iOS 26 kit Tab Bar - iPhone (507:24689): two to five tabs, each a
20
+ * symbol over a label, in a floating glass capsule at the bottom, the selected tab on a pill, and an optional
21
+ * search tab in a circle of its own. It minimizes to the selected tab while the content scrolls down. A desktop
22
+ * layout navigates with a Sidebar or Tabs, so the bar never renders from 768px up.
23
+ */
24
+ function TabBarRoot({ value: valueProp, defaultValue, onValueChange, search, minimizeBehavior = "never", minimized: minimizedProp, defaultMinimized = false, onMinimizedChange, background = "soft", "aria-label": ariaLabel = "Tabs", children, className, ref, }) {
25
+ const host = useContext(ToolbarHostContext);
26
+ const [internalValue, setInternalValue] = useState(defaultValue);
27
+ const value = valueProp ?? internalValue;
28
+ const [internalMinimized, setInternalMinimized] = useState(defaultMinimized);
29
+ const minimized = minimizedProp ?? internalMinimized;
30
+ const onValueChangeRef = useLatestValue(onValueChange);
31
+ const onMinimizedChangeRef = useLatestValue(onMinimizedChange);
32
+ const minimizedRef = useLatestValue(minimized);
33
+ const controlledMinimized = minimizedProp !== undefined;
34
+ const select = useCallback((next) => {
35
+ if (valueProp === undefined)
36
+ setInternalValue(next);
37
+ onValueChangeRef.current?.(next);
38
+ }, [valueProp, onValueChangeRef]);
39
+ const setMinimized = useCallback((next) => {
40
+ if (next === minimizedRef.current)
41
+ return;
42
+ // A controlled state changes only when the owner passes it back.
43
+ if (!controlledMinimized) {
44
+ minimizedRef.current = next;
45
+ setInternalMinimized(next);
46
+ }
47
+ onMinimizedChangeRef.current?.(next);
48
+ }, [controlledMinimized, minimizedRef, onMinimizedChangeRef]);
49
+ const expand = useCallback(() => setMinimized(false), [setMinimized]);
50
+ // The bar follows the Page content: down by MINIMIZE_AFTER minimizes it, up by as much (or the top) expands it.
51
+ const subscribeScroll = host?.subscribeScroll;
52
+ useEffect(() => {
53
+ if (minimizeBehavior !== "onScrollDown" || !subscribeScroll)
54
+ return;
55
+ let anchor = 0;
56
+ return subscribeScroll((scrollTop) => {
57
+ if (scrollTop <= 0) {
58
+ anchor = 0;
59
+ return setMinimized(false);
60
+ }
61
+ const delta = scrollTop - anchor;
62
+ if (minimizedRef.current ? delta < 0 : delta > 0) {
63
+ if (Math.abs(delta) >= MINIMIZE_AFTER) {
64
+ anchor = scrollTop;
65
+ setMinimized(!minimizedRef.current);
66
+ }
67
+ return;
68
+ }
69
+ anchor = scrollTop;
70
+ });
71
+ }, [minimizeBehavior, subscribeScroll, setMinimized, minimizedRef]);
72
+ const element = useRef(null);
73
+ const setRef = useCallback((node) => {
74
+ element.current = node;
75
+ if (typeof ref === "function")
76
+ return ref(node);
77
+ if (ref)
78
+ ref.current = node;
79
+ }, [ref]);
80
+ // Like a bottom Toolbar, the bar reserves its height on the Page; a desktop layout hides it.
81
+ const setHeight = host?.setHeight;
82
+ useLayoutEffect(() => {
83
+ const bar = element.current;
84
+ if (!bar || !setHeight)
85
+ return;
86
+ const update = () => setHeight("bottom", bar.offsetHeight || undefined);
87
+ update();
88
+ const observer = typeof ResizeObserver !== "undefined" ? new ResizeObserver(update) : undefined;
89
+ observer?.observe(bar, { box: "border-box" });
90
+ return () => { observer?.disconnect(); setHeight("bottom", undefined); };
91
+ }, [setHeight]);
92
+ const context = { value, minimized, select, expand };
93
+ return (_jsx("nav", { ref: setRef, "aria-label": ariaLabel, className: clsx(s.TabBar, className), "data-host": host?.kind, "data-background": background, "data-content-below": host?.contentBelow ? "" : undefined, "data-minimized": minimized ? "" : undefined, "data-search": search ? "" : undefined, children: _jsxs(TabBarContext.Provider, { value: context, children: [_jsx("div", { className: s.Tabs, children: children }), search && (_jsx(TabBarItem, { className: s.Search, value: search.value, label: search.label ?? "Search", icon: _jsx(SearchIcon, {}), hideLabel: true }))] }) }));
94
+ }
95
+ TabBarRoot.displayName = "TabBar";
96
+ function TabBarItem({ value, label, icon, href, disabled = false, onClick, className, hideLabel = false }) {
97
+ const context = useTabBarContext("TabBar.Item");
98
+ const selected = context.value === value;
99
+ // A minimized bar shows the selected tab only; pressing it brings the other tabs back.
100
+ const collapsed = context.minimized && selected && !hideLabel;
101
+ const handleClick = (event) => {
102
+ onClick?.(event);
103
+ if (event.defaultPrevented || disabled)
104
+ return;
105
+ if (collapsed) {
106
+ event.preventDefault();
107
+ return context.expand();
108
+ }
109
+ context.select(value);
110
+ };
111
+ const content = (_jsxs(_Fragment, { children: [_jsx("span", { className: s.Icon, "aria-hidden": "true", children: icon }), !hideLabel && _jsx("span", { className: s.Label, children: label })] }));
112
+ const props = {
113
+ "className": clsx(s.Item, className),
114
+ "aria-current": selected ? "page" : undefined,
115
+ "aria-label": hideLabel ? label : undefined,
116
+ "aria-expanded": collapsed ? false : undefined,
117
+ "data-selected": selected ? "" : undefined,
118
+ "data-disabled": disabled ? "" : undefined,
119
+ "data-value": value,
120
+ "onClick": handleClick,
121
+ };
122
+ if (href !== undefined && !disabled)
123
+ return _jsx("a", { href: href, ...props, children: content });
124
+ return _jsx("button", { type: "button", disabled: disabled, ...props, children: content });
125
+ }
126
+ TabBarItem.displayName = "TabBar.Item";
127
+ export const TabBar = Object.assign(TabBarRoot, { Item: TabBarItem });
128
+ //# sourceMappingURL=TabBar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TabBar.js","sourceRoot":"","sources":["../../../../src/components/TabBar/TabBar.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EACL,aAAa,EACb,WAAW,EACX,UAAU,EACV,SAAS,EACT,eAAe,EACf,MAAM,EACN,QAAQ,GAIT,MAAM,OAAO,CAAA;AACd,OAAO,CAAC,MAAM,oDAAoD,CAAA;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;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AC,CAAC,CAAC,SAAS;QAC1C,YAAY,EAAE,KAAK;QACnB,SAAS,EAAE,WAAW;KACvB,CAAA;IACD,IAAI,IAAI,KAAK,SAAS,IAAI,CAAC,QAAQ;QAAE,OAAO,YAAG,IAAI,EAAE,IAAI,KAAM,KAAK,YAAG,OAAO,GAAK,CAAA;IACnF,OAAO,iBAAQ,IAAI,EAAC,QAAQ,EAAC,QAAQ,EAAE,QAAQ,KAAM,KAAK,YAAG,OAAO,GAAU,CAAA;AAChF,CAAC;AACD,UAAU,CAAC,WAAW,GAAG,aAAa,CAAA;AAEtC,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n type MouseEvent,\n type ReactNode,\n type Ref,\n} from \"react\"\nimport s from \"@plexui/styles/components/TabBar/TabBar.module.css\"\nimport { useLatestValue } from \"../../hooks/useLatestValue\"\nimport { Search as SearchIcon } from \"../Icon\"\nimport { ToolbarHostContext, type BarBackground } from \"../Toolbar/Toolbar\"\n\n/** A scroll of at least this many pixels in one direction minimizes or expands the bar. */\nconst MINIMIZE_AFTER = 8\n\ntype TabBarContextValue = {\n value: string | undefined\n minimized: boolean\n select: (value: string) => void\n expand: () => void\n}\n\nconst TabBarContext = createContext<TabBarContextValue | null>(null)\n\nfunction useTabBarContext(part: string) {\n const context = useContext(TabBarContext)\n if (!context) throw new Error(`${part} must be used within TabBar`)\n return context\n}\n\nexport type TabBarSearch = {\n /** The value of the search tab. */\n value: string\n /** Accessible name of the search tab. @default \"Search\" */\n label?: string\n}\n\nexport type TabBarProps = {\n /** The controlled value of the selected tab. Use with `onValueChange`. */\n value?: string\n /** The selected tab when it is initially rendered. */\n defaultValue?: string\n /** Called with the value of the tab a person selects. */\n onValueChange?: (value: string) => void\n /** A search tab in a glass circle of its own at the trailing end, as the iOS 26 separate search tab. */\n search?: TabBarSearch\n /**\n * `onScrollDown` minimizes the bar to the selected tab while the content of the `Page` scrolls down and\n * expands it when the content scrolls back up; a tap on the minimized tab expands it too. @default \"never\"\n */\n minimizeBehavior?: \"never\" | \"onScrollDown\"\n /** Controlled minimized state. Use with `onMinimizedChange`. */\n minimized?: boolean\n /** The minimized state when it is initially rendered. @default false */\n defaultMinimized?: boolean\n /** Called when the bar minimizes or expands. */\n onMinimizedChange?: (minimized: boolean) => void\n /** How the bar meets the content scrolled under it; see `BarBackground`. @default \"soft\" */\n background?: BarBackground\n /** Accessible name of the navigation. @default \"Tabs\" */\n \"aria-label\"?: string\n /** `TabBar.Item` elements. */\n children?: ReactNode\n /** CSS classes applied to the bar */\n className?: string\n ref?: Ref<HTMLElement>\n}\n\n/**\n * The tab bar of a phone screen after the iOS 26 kit Tab Bar - iPhone (507:24689): two to five tabs, each a\n * symbol over a label, in a floating glass capsule at the bottom, the selected tab on a pill, and an optional\n * search tab in a circle of its own. It minimizes to the selected tab while the content scrolls down. A desktop\n * layout navigates with a Sidebar or Tabs, so the bar never renders from 768px up.\n */\nfunction TabBarRoot({\n value: valueProp,\n defaultValue,\n onValueChange,\n search,\n minimizeBehavior = \"never\",\n minimized: minimizedProp,\n defaultMinimized = false,\n onMinimizedChange,\n background = \"soft\",\n \"aria-label\": ariaLabel = \"Tabs\",\n children,\n className,\n ref,\n}: TabBarProps) {\n const host = useContext(ToolbarHostContext)\n const [internalValue, setInternalValue] = useState(defaultValue)\n const value = valueProp ?? internalValue\n const [internalMinimized, setInternalMinimized] = useState(defaultMinimized)\n const minimized = minimizedProp ?? internalMinimized\n const onValueChangeRef = useLatestValue(onValueChange)\n const onMinimizedChangeRef = useLatestValue(onMinimizedChange)\n const minimizedRef = useLatestValue(minimized)\n const controlledMinimized = minimizedProp !== undefined\n\n const select = useCallback((next: string) => {\n if (valueProp === undefined) setInternalValue(next)\n onValueChangeRef.current?.(next)\n }, [valueProp, onValueChangeRef])\n\n const setMinimized = useCallback((next: boolean) => {\n if (next === minimizedRef.current) return\n // A controlled state changes only when the owner passes it back.\n if (!controlledMinimized) {\n minimizedRef.current = next\n setInternalMinimized(next)\n }\n onMinimizedChangeRef.current?.(next)\n }, [controlledMinimized, minimizedRef, onMinimizedChangeRef])\n\n const expand = useCallback(() => setMinimized(false), [setMinimized])\n\n // The bar follows the Page content: down by MINIMIZE_AFTER minimizes it, up by as much (or the top) expands it.\n const subscribeScroll = host?.subscribeScroll\n useEffect(() => {\n if (minimizeBehavior !== \"onScrollDown\" || !subscribeScroll) return\n let anchor = 0\n return subscribeScroll((scrollTop) => {\n if (scrollTop <= 0) {\n anchor = 0\n return setMinimized(false)\n }\n const delta = scrollTop - anchor\n if (minimizedRef.current ? delta < 0 : delta > 0) {\n if (Math.abs(delta) >= MINIMIZE_AFTER) {\n anchor = scrollTop\n setMinimized(!minimizedRef.current)\n }\n return\n }\n anchor = scrollTop\n })\n }, [minimizeBehavior, subscribeScroll, setMinimized, minimizedRef])\n\n const element = useRef<HTMLElement | null>(null)\n const setRef = useCallback((node: HTMLElement | null) => {\n element.current = node\n if (typeof ref === \"function\") return ref(node)\n if (ref) ref.current = node\n }, [ref])\n\n // Like a bottom Toolbar, the bar reserves its height on the Page; a desktop layout hides it.\n const setHeight = host?.setHeight\n useLayoutEffect(() => {\n const bar = element.current\n if (!bar || !setHeight) return\n const update = () => setHeight(\"bottom\", bar.offsetHeight || undefined)\n update()\n const observer = typeof ResizeObserver !== \"undefined\" ? new ResizeObserver(update) : undefined\n observer?.observe(bar, { box: \"border-box\" })\n return () => { observer?.disconnect(); setHeight(\"bottom\", undefined) }\n }, [setHeight])\n\n const context = { value, minimized, select, expand }\n\n return (\n <nav\n ref={setRef}\n aria-label={ariaLabel}\n className={clsx(s.TabBar, className)}\n data-host={host?.kind}\n data-background={background}\n data-content-below={host?.contentBelow ? \"\" : undefined}\n data-minimized={minimized ? \"\" : undefined}\n data-search={search ? \"\" : undefined}\n >\n <TabBarContext.Provider value={context}>\n <div className={s.Tabs}>{children}</div>\n {search && (\n <TabBarItem className={s.Search} value={search.value} label={search.label ?? \"Search\"} icon={<SearchIcon />} hideLabel />\n )}\n </TabBarContext.Provider>\n </nav>\n )\n}\nTabBarRoot.displayName = \"TabBar\"\n\nexport type TabBarItemProps = {\n /** The value of the tab. */\n value: string\n /** The label under the symbol, and the accessible name of the tab. */\n label: string\n /** The symbol, a PlexUI icon. */\n icon: ReactNode\n /** Makes the tab a link to this URL. */\n href?: string\n /** When `true`, the tab cannot be selected. */\n disabled?: boolean\n /** Called when the tab is pressed, before it is selected. */\n onClick?: (event: MouseEvent<HTMLElement>) => void\n /** CSS classes applied to the tab */\n className?: string\n /** @internal The search tab shows its symbol only. */\n hideLabel?: boolean\n}\n\nfunction TabBarItem({ value, label, icon, href, disabled = false, onClick, className, hideLabel = false }: TabBarItemProps) {\n const context = useTabBarContext(\"TabBar.Item\")\n const selected = context.value === value\n // A minimized bar shows the selected tab only; pressing it brings the other tabs back.\n const collapsed = context.minimized && selected && !hideLabel\n const handleClick = (event: MouseEvent<HTMLElement>) => {\n onClick?.(event)\n if (event.defaultPrevented || disabled) return\n if (collapsed) {\n event.preventDefault()\n return context.expand()\n }\n context.select(value)\n }\n const content = (\n <>\n <span className={s.Icon} aria-hidden=\"true\">{icon}</span>\n {!hideLabel && <span className={s.Label}>{label}</span>}\n </>\n )\n const props = {\n \"className\": clsx(s.Item, className),\n \"aria-current\": selected ? (\"page\" as const) : undefined,\n \"aria-label\": hideLabel ? label : undefined,\n \"aria-expanded\": collapsed ? false : undefined,\n \"data-selected\": selected ? \"\" : undefined,\n \"data-disabled\": disabled ? \"\" : undefined,\n \"data-value\": value,\n \"onClick\": handleClick,\n }\n if (href !== undefined && !disabled) return <a href={href} {...props}>{content}</a>\n return <button type=\"button\" disabled={disabled} {...props}>{content}</button>\n}\nTabBarItem.displayName = \"TabBar.Item\"\n\nexport const TabBar = Object.assign(TabBarRoot, { Item: TabBarItem })\n"]}
@@ -0,0 +1,2 @@
1
+ export { TabBar } from "./TabBar.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/TabBar/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAA6D,MAAM,UAAU,CAAA","sourcesContent":["export { TabBar, type TabBarItemProps, type TabBarProps, type TabBarSearch } from \"./TabBar\"\n"]}
@@ -2,15 +2,17 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import clsx from "clsx";
4
4
  import { ToggleGroup } from "radix-ui";
5
- import { Children, cloneElement, Fragment, isValidElement, useCallback, useEffect, useLayoutEffect, useRef, useState, } from "react";
5
+ import { Children, cloneElement, createContext, Fragment, isValidElement, useCallback, useContext, useEffect, useLayoutEffect, useRef, useState, } from "react";
6
6
  import { useResizeObserver } from "usehooks-ts";
7
- import { handlePressableMouseEnter, waitForAnimationFrame } from "../../lib/helpers.js";
7
+ import { handlePressableMouseEnter, prefersReducedMotion, waitForAnimationFrame } from "../../lib/helpers.js";
8
8
  import {} from "../../types.js";
9
- import { ChevronDownMd } from "../Icon/index.js";
9
+ import { CheckMd, ChevronDownMd } from "../Icon/index.js";
10
10
  import { LoadingIndicator } from "../Indicator/index.js";
11
11
  import { Menu } from "../Menu/index.js";
12
- import { fitCount, visibleTabCount } from "./overflow.js";
12
+ import { visibleTabCount } from "./overflow.js";
13
13
  import s from "@plexui/styles/components/Tabs/Tabs.module.css";
14
+ /** Vertical tabs are a list on a phone, where the selected row shows a checkmark */
15
+ const TabsVerticalContext = createContext(false);
14
16
  export const Tabs = ({ overflow = "scroll", overflowLabel = "More", ...props }) => {
15
17
  if (overflow === "menu" && !props.block && props.orientation !== "vertical") {
16
18
  return _jsx(OverflowTabs, { ...props, overflowLabel: overflowLabel });
@@ -53,7 +55,9 @@ const TabsRoot = ({ value, onChange, children, variant = "segmented", orientatio
53
55
  const bottom = top + targetHeight;
54
56
  if (top < scrollTop + buffer || bottom > scrollTop + rootHeight - buffer) {
55
57
  if (attemptScroll) {
56
- activeNode.scrollIntoView({ block: "center", inline: "nearest", behavior: "smooth" });
58
+ // Scroll the control only: scrollIntoView also scrolls the page to it (a switch to Phone
59
+ // re-rendered a control far down the page and slid the page to it, owner 08.11)
60
+ root.scrollTo({ top: top - (rootHeight - targetHeight) / 2, behavior: prefersReducedMotion() ? "auto" : "smooth" });
57
61
  }
58
62
  }
59
63
  }
@@ -80,7 +84,9 @@ const TabsRoot = ({ value, onChange, children, variant = "segmented", orientatio
80
84
  if (left < scrollLeft + buffer || right > scrollLeft + rootWidth - buffer) {
81
85
  // Cheap trick to avoid unintentional scroll on mount - transition is set after mounting
82
86
  if (attemptScroll) {
83
- activeNode.scrollIntoView({ block: "nearest", inline: "center", behavior: "smooth" });
87
+ // Scroll the control only: scrollIntoView also scrolls the page to it (a switch to Phone
88
+ // re-rendered a control far down the page and slid the page to it, owner 08.11)
89
+ root.scrollTo({ left: left - (rootWidth - targetWidth) / 2, behavior: prefersReducedMotion() ? "auto" : "smooth" });
84
90
  }
85
91
  }
86
92
  }
@@ -120,8 +126,8 @@ const TabsRoot = ({ value, onChange, children, variant = "segmented", orientatio
120
126
  return () => observer.disconnect();
121
127
  }, [applyThumbSizing]);
122
128
  const transitionProperty = isVertical
123
- ? "height 200ms var(--cubic-enter), transform 200ms var(--cubic-enter)"
124
- : "width 200ms var(--cubic-enter), transform 200ms var(--cubic-enter)";
129
+ ? "height var(--tabs-thumb-transition-duration, 200ms) var(--cubic-enter), transform var(--tabs-thumb-transition-duration, 200ms) var(--cubic-enter)"
130
+ : "width var(--tabs-thumb-transition-duration, 200ms) var(--cubic-enter), transform var(--tabs-thumb-transition-duration, 200ms) var(--cubic-enter)";
125
131
  useLayoutEffect(() => {
126
132
  const root = rootRef.current;
127
133
  const thumb = thumbRef.current;
@@ -165,7 +171,7 @@ const TabsRoot = ({ value, onChange, children, variant = "segmented", orientatio
165
171
  const isPill = variant === "segmented" && pill;
166
172
  // Only apply flush for underline variant
167
173
  const isFlush = variant === "underline" && flush;
168
- return (_jsxs(ToggleGroup.Root, { ref: rootRef, className: clsx(s.Tabs, className), type: "single", value: value, loop: false, onValueChange: handleValueChange, onClick: onClick, "data-variant": variant, "data-orientation": orientation, "data-block": block ? "" : undefined, "data-pill": isPill ? "" : undefined, "data-flush": isFlush ? "" : undefined, "data-size": size, "data-gutter-size": gutterSize, ...restProps, children: [_jsx("div", { className: s.TabsThumb, ref: thumbRef }), children] }));
174
+ return (_jsxs(ToggleGroup.Root, { ref: rootRef, className: clsx(s.Tabs, className), type: "single", value: value, loop: false, onValueChange: handleValueChange, onClick: onClick, "data-variant": variant, "data-orientation": orientation, "data-block": block ? "" : undefined, "data-pill": isPill ? "" : undefined, "data-flush": isFlush ? "" : undefined, "data-size": size, "data-gutter-size": gutterSize, ...restProps, children: [_jsx("div", { className: s.TabsThumb, ref: thumbRef }), _jsx(TabsVerticalContext.Provider, { value: isVertical, children: children })] }));
169
175
  };
170
176
  // Type guard for badge object form
171
177
  const isBadgeObject = (badge) => {
@@ -174,7 +180,8 @@ const isBadgeObject = (badge) => {
174
180
  const Tab = ({ children, icon, badge, ...restProps }) => {
175
181
  // Normalize badge prop
176
182
  const badgeProps = badge != null ? (isBadgeObject(badge) ? badge : { content: badge }) : null;
177
- return (_jsx(ToggleGroup.Item, { className: s.Tab, ...restProps, onPointerEnter: handlePressableMouseEnter, children: _jsxs("span", { className: s.TabContent, children: [icon, children && _jsx("span", { children: children }), badgeProps && (_jsx("span", { className: s.TabBadge, "data-color": badgeProps.color ?? "secondary", "data-variant": badgeProps.variant ?? "soft", "data-pill": badgeProps.pill ? "" : undefined, children: badgeProps.loading ? _jsx(LoadingIndicator, {}) : badgeProps.content }))] }) }));
183
+ const vertical = useContext(TabsVerticalContext);
184
+ return (_jsxs(ToggleGroup.Item, { className: s.Tab, ...restProps, onPointerEnter: handlePressableMouseEnter, children: [_jsxs("span", { className: s.TabContent, children: [icon, children && _jsx("span", { className: s.TabLabel, children: children }), badgeProps && (_jsx("span", { className: s.TabBadge, "data-color": badgeProps.color ?? "secondary", "data-variant": badgeProps.variant ?? "soft", "data-pill": badgeProps.pill ? "" : undefined, children: badgeProps.loading ? _jsx(LoadingIndicator, {}) : badgeProps.content }))] }), vertical && _jsx(CheckMd, { className: s.TabCheckmark, "aria-hidden": "true" })] }));
178
185
  };
179
186
  // =============================================
180
187
  // overflow="menu"
@@ -209,7 +216,11 @@ const tabsSignature = (items) => items
209
216
  * by it. The menu's value does not reach the tab; its handlers and
210
217
  * `aria-haspopup` / `aria-expanded` do.
211
218
  */
212
- const MoreTab = ({ "data-state": _menuState, ...restProps }) => (_jsx(Tab, { ...restProps }));
219
+ const MoreTab = (props) => {
220
+ const restProps = { ...props };
221
+ delete restProps["data-state"];
222
+ return _jsx(Tab, { ...restProps });
223
+ };
213
224
  const OverflowTabs = ({ children, value, onChange, overflowLabel, ...restProps }) => {
214
225
  const items = tabElements(children);
215
226
  // The strip's own props size the tabs and the menu button too
@@ -255,6 +266,9 @@ const OverflowTabs = ({ children, value, onChange, overflowLabel, ...restProps }
255
266
  // A hidden strip has no width to decide by: show every tab, and measure
256
267
  // when it appears (the observer sees the width change)
257
268
  if (available <= 0) {
269
+ // Resolve the zero-width measuring pass before paint; the resize observer
270
+ // restarts measurement when this hidden strip becomes visible.
271
+ // eslint-disable-next-line react-hooks/set-state-in-effect
258
272
  setVisibleCount(items.length);
259
273
  return;
260
274
  }
@@ -263,6 +277,8 @@ const OverflowTabs = ({ children, value, onChange, overflowLabel, ...restProps }
263
277
  const chevronWidth = chevron?.getBoundingClientRect().width ?? 0;
264
278
  const labelGap = chevron?.parentElement ? Number.parseFloat(getComputedStyle(chevron.parentElement).columnGap) || 0 : 0;
265
279
  const activeWidth = activeIndex < 0 ? 0 : (widths[activeIndex] ?? 0) + chevronWidth + labelGap;
280
+ // This result depends on committed DOM widths. Apply it before first paint
281
+ // so the temporary full strip never flashes before overflowing tabs move.
266
282
  setVisibleCount(visibleTabCount(widths, moreWidth, activeWidth, activeIndex, gap, available));
267
283
  }, [visibleCount, items.length, activeIndex]);
268
284
  // The width to fit is the container's, not the strip's: the strip shrinks