@knitui/components 0.5.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (495) hide show
  1. package/lib/commonjs/Accordion/Accordion.js +10 -6
  2. package/lib/commonjs/Accordion/Accordion.js.map +1 -1
  3. package/lib/commonjs/Alert/Alert.js +31 -11
  4. package/lib/commonjs/Alert/Alert.js.map +1 -1
  5. package/lib/commonjs/AngleSlider/AngleSlider.js +55 -17
  6. package/lib/commonjs/AngleSlider/AngleSlider.js.map +1 -1
  7. package/lib/commonjs/Autocomplete/Autocomplete.js +53 -33
  8. package/lib/commonjs/Autocomplete/Autocomplete.js.map +1 -1
  9. package/lib/commonjs/Badge/Badge.js +6 -9
  10. package/lib/commonjs/Badge/Badge.js.map +1 -1
  11. package/lib/commonjs/Button/Button.js +22 -6
  12. package/lib/commonjs/Button/Button.js.map +1 -1
  13. package/lib/commonjs/Card/Card.js +13 -4
  14. package/lib/commonjs/Card/Card.js.map +1 -1
  15. package/lib/commonjs/Checkbox/CheckIcon.js +10 -6
  16. package/lib/commonjs/Checkbox/CheckIcon.js.map +1 -1
  17. package/lib/commonjs/Checkbox/Checkbox.js +9 -2
  18. package/lib/commonjs/Checkbox/Checkbox.js.map +1 -1
  19. package/lib/commonjs/Chip/Chip.js +15 -16
  20. package/lib/commonjs/Chip/Chip.js.map +1 -1
  21. package/lib/commonjs/CloseButton/CloseButton.js +2 -2
  22. package/lib/commonjs/CloseButton/CloseButton.js.map +1 -1
  23. package/lib/commonjs/ColorInput/ColorInput.js +12 -4
  24. package/lib/commonjs/ColorInput/ColorInput.js.map +1 -1
  25. package/lib/commonjs/ColorPicker/ColorPicker.js +32 -24
  26. package/lib/commonjs/ColorPicker/ColorPicker.js.map +1 -1
  27. package/lib/commonjs/Combobox/Combobox.js +11 -6
  28. package/lib/commonjs/Combobox/Combobox.js.map +1 -1
  29. package/lib/commonjs/Combobox/OptionsDropdown.js +6 -2
  30. package/lib/commonjs/Combobox/OptionsDropdown.js.map +1 -1
  31. package/lib/commonjs/Group/Group.js +19 -11
  32. package/lib/commonjs/Group/Group.js.map +1 -1
  33. package/lib/commonjs/Highlight/Highlight.js +30 -10
  34. package/lib/commonjs/Highlight/Highlight.js.map +1 -1
  35. package/lib/commonjs/HoverCard/HoverCard.js +23 -10
  36. package/lib/commonjs/HoverCard/HoverCard.js.map +1 -1
  37. package/lib/commonjs/Indicator/Indicator.js +5 -1
  38. package/lib/commonjs/Indicator/Indicator.js.map +1 -1
  39. package/lib/commonjs/Input/Input.js +30 -12
  40. package/lib/commonjs/Input/Input.js.map +1 -1
  41. package/lib/commonjs/Input/shared.js +18 -8
  42. package/lib/commonjs/Input/shared.js.map +1 -1
  43. package/lib/commonjs/Loader/Loader.js +18 -10
  44. package/lib/commonjs/Loader/Loader.js.map +1 -1
  45. package/lib/commonjs/Menu/Menu.js +6 -7
  46. package/lib/commonjs/Menu/Menu.js.map +1 -1
  47. package/lib/commonjs/MultiSelect/MultiSelect.js +112 -47
  48. package/lib/commonjs/MultiSelect/MultiSelect.js.map +1 -1
  49. package/lib/commonjs/Notification/Notification.js +31 -11
  50. package/lib/commonjs/Notification/Notification.js.map +1 -1
  51. package/lib/commonjs/NumberFormatter/NumberFormatter.js +48 -11
  52. package/lib/commonjs/NumberFormatter/NumberFormatter.js.map +1 -1
  53. package/lib/commonjs/Paper/Paper.js +8 -8
  54. package/lib/commonjs/Paper/Paper.js.map +1 -1
  55. package/lib/commonjs/Pill/Pill.js +6 -8
  56. package/lib/commonjs/Pill/Pill.js.map +1 -1
  57. package/lib/commonjs/Progress/Progress.js +4 -1
  58. package/lib/commonjs/Progress/Progress.js.map +1 -1
  59. package/lib/commonjs/RollingNumber/RollingNumber.js +30 -13
  60. package/lib/commonjs/RollingNumber/RollingNumber.js.map +1 -1
  61. package/lib/commonjs/RollingNumber/rolling-number-utils.js +27 -5
  62. package/lib/commonjs/RollingNumber/rolling-number-utils.js.map +1 -1
  63. package/lib/commonjs/ScrollArea/ScrollArea.js +131 -41
  64. package/lib/commonjs/ScrollArea/ScrollArea.js.map +1 -1
  65. package/lib/commonjs/ScrollArea/ScrollArea.native.js +128 -40
  66. package/lib/commonjs/ScrollArea/ScrollArea.native.js.map +1 -1
  67. package/lib/commonjs/SegmentedControl/SegmentedControl.js +4 -1
  68. package/lib/commonjs/SegmentedControl/SegmentedControl.js.map +1 -1
  69. package/lib/commonjs/Select/Select.js +64 -35
  70. package/lib/commonjs/Select/Select.js.map +1 -1
  71. package/lib/commonjs/Skeleton/Skeleton.js +6 -2
  72. package/lib/commonjs/Skeleton/Skeleton.js.map +1 -1
  73. package/lib/commonjs/Slider/Slider.js +136 -83
  74. package/lib/commonjs/Slider/Slider.js.map +1 -1
  75. package/lib/commonjs/Spoiler/Spoiler.js +22 -2
  76. package/lib/commonjs/Spoiler/Spoiler.js.map +1 -1
  77. package/lib/commonjs/Stepper/Stepper.js +2 -2
  78. package/lib/commonjs/Stepper/Stepper.js.map +1 -1
  79. package/lib/commonjs/Switch/Switch.js +18 -7
  80. package/lib/commonjs/Switch/Switch.js.map +1 -1
  81. package/lib/commonjs/Table/Table.js +91 -28
  82. package/lib/commonjs/Table/Table.js.map +1 -1
  83. package/lib/commonjs/TableOfContents/TableOfContents.js +4 -1
  84. package/lib/commonjs/TableOfContents/TableOfContents.js.map +1 -1
  85. package/lib/commonjs/TagsInput/TagsInput.js +138 -55
  86. package/lib/commonjs/TagsInput/TagsInput.js.map +1 -1
  87. package/lib/commonjs/Tooltip/Tooltip.js +27 -5
  88. package/lib/commonjs/Tooltip/Tooltip.js.map +1 -1
  89. package/lib/commonjs/Tree/Tree.js +4 -1
  90. package/lib/commonjs/Tree/Tree.js.map +1 -1
  91. package/lib/commonjs/Tree/tree-data.js +58 -23
  92. package/lib/commonjs/Tree/tree-data.js.map +1 -1
  93. package/lib/commonjs/Tree/use-tree.js +33 -4
  94. package/lib/commonjs/Tree/use-tree.js.map +1 -1
  95. package/lib/commonjs/TreeSelect/TreeSelect.js +70 -30
  96. package/lib/commonjs/TreeSelect/TreeSelect.js.map +1 -1
  97. package/lib/commonjs/Typography/Typography.js +10 -10
  98. package/lib/commonjs/Typography/Typography.js.map +1 -1
  99. package/lib/commonjs/UnstyledButton/UnstyledButton.js +8 -3
  100. package/lib/commonjs/UnstyledButton/UnstyledButton.js.map +1 -1
  101. package/lib/commonjs/VirtualList/VirtualList.js +71 -13
  102. package/lib/commonjs/VirtualList/VirtualList.js.map +1 -1
  103. package/lib/commonjs/floating/platform.js +28 -1
  104. package/lib/commonjs/floating/platform.js.map +1 -1
  105. package/lib/commonjs/floating/use-position.js +33 -1
  106. package/lib/commonjs/floating/use-position.js.map +1 -1
  107. package/lib/commonjs/internal/ControlIconProvider.js +20 -15
  108. package/lib/commonjs/internal/ControlIconProvider.js.map +1 -1
  109. package/lib/commonjs/internal/color.js +8 -1
  110. package/lib/commonjs/internal/color.js.map +1 -1
  111. package/lib/commonjs/internal/gradient-shared.js +9 -5
  112. package/lib/commonjs/internal/gradient-shared.js.map +1 -1
  113. package/lib/commonjs/internal/gradient.js +21 -9
  114. package/lib/commonjs/internal/gradient.js.map +1 -1
  115. package/lib/commonjs/internal/gradient.native.js +36 -10
  116. package/lib/commonjs/internal/gradient.native.js.map +1 -1
  117. package/lib/commonjs/internal/render-text-child.js +30 -2
  118. package/lib/commonjs/internal/render-text-child.js.map +1 -1
  119. package/lib/commonjs/internal/style-props.js +17 -5
  120. package/lib/commonjs/internal/style-props.js.map +1 -1
  121. package/lib/commonjs/internal/theme-color-web.js +46 -0
  122. package/lib/commonjs/internal/theme-color-web.js.map +1 -0
  123. package/lib/commonjs/internal/use-icon-color.js +33 -0
  124. package/lib/commonjs/internal/use-icon-color.js.map +1 -0
  125. package/lib/commonjs/internal/use-icon-color.native.js +23 -0
  126. package/lib/commonjs/internal/use-icon-color.native.js.map +1 -0
  127. package/lib/commonjs/internal/use-looping-animation.js +7 -3
  128. package/lib/commonjs/internal/use-looping-animation.js.map +1 -1
  129. package/lib/commonjs/internal/use-looping-animation.native.js +9 -1
  130. package/lib/commonjs/internal/use-looping-animation.native.js.map +1 -1
  131. package/lib/commonjs/internal/use-looping-animation.shared.js +33 -0
  132. package/lib/commonjs/internal/use-looping-animation.shared.js.map +1 -1
  133. package/lib/commonjs/internal/use-slot-text-wrapper.js +36 -5
  134. package/lib/commonjs/internal/use-slot-text-wrapper.js.map +1 -1
  135. package/lib/module/Accordion/Accordion.js +9 -5
  136. package/lib/module/Accordion/Accordion.js.map +1 -1
  137. package/lib/module/Alert/Alert.js +31 -11
  138. package/lib/module/Alert/Alert.js.map +1 -1
  139. package/lib/module/AngleSlider/AngleSlider.js +55 -17
  140. package/lib/module/AngleSlider/AngleSlider.js.map +1 -1
  141. package/lib/module/Autocomplete/Autocomplete.js +54 -34
  142. package/lib/module/Autocomplete/Autocomplete.js.map +1 -1
  143. package/lib/module/Badge/Badge.js +6 -9
  144. package/lib/module/Badge/Badge.js.map +1 -1
  145. package/lib/module/Button/Button.js +23 -7
  146. package/lib/module/Button/Button.js.map +1 -1
  147. package/lib/module/Card/Card.js +13 -4
  148. package/lib/module/Card/Card.js.map +1 -1
  149. package/lib/module/Checkbox/CheckIcon.js +9 -5
  150. package/lib/module/Checkbox/CheckIcon.js.map +1 -1
  151. package/lib/module/Checkbox/Checkbox.js +9 -2
  152. package/lib/module/Checkbox/Checkbox.js.map +1 -1
  153. package/lib/module/Chip/Chip.js +15 -16
  154. package/lib/module/Chip/Chip.js.map +1 -1
  155. package/lib/module/CloseButton/CloseButton.js +1 -1
  156. package/lib/module/CloseButton/CloseButton.js.map +1 -1
  157. package/lib/module/ColorInput/ColorInput.js +12 -4
  158. package/lib/module/ColorInput/ColorInput.js.map +1 -1
  159. package/lib/module/ColorPicker/ColorPicker.js +32 -24
  160. package/lib/module/ColorPicker/ColorPicker.js.map +1 -1
  161. package/lib/module/Combobox/Combobox.js +11 -6
  162. package/lib/module/Combobox/Combobox.js.map +1 -1
  163. package/lib/module/Combobox/OptionsDropdown.js +6 -2
  164. package/lib/module/Combobox/OptionsDropdown.js.map +1 -1
  165. package/lib/module/Group/Group.js +19 -11
  166. package/lib/module/Group/Group.js.map +1 -1
  167. package/lib/module/Highlight/Highlight.js +30 -10
  168. package/lib/module/Highlight/Highlight.js.map +1 -1
  169. package/lib/module/HoverCard/HoverCard.js +23 -10
  170. package/lib/module/HoverCard/HoverCard.js.map +1 -1
  171. package/lib/module/Indicator/Indicator.js +5 -1
  172. package/lib/module/Indicator/Indicator.js.map +1 -1
  173. package/lib/module/Input/Input.js +32 -14
  174. package/lib/module/Input/Input.js.map +1 -1
  175. package/lib/module/Input/shared.js +19 -9
  176. package/lib/module/Input/shared.js.map +1 -1
  177. package/lib/module/Loader/Loader.js +18 -10
  178. package/lib/module/Loader/Loader.js.map +1 -1
  179. package/lib/module/Menu/Menu.js +6 -7
  180. package/lib/module/Menu/Menu.js.map +1 -1
  181. package/lib/module/MultiSelect/MultiSelect.js +113 -48
  182. package/lib/module/MultiSelect/MultiSelect.js.map +1 -1
  183. package/lib/module/Notification/Notification.js +31 -11
  184. package/lib/module/Notification/Notification.js.map +1 -1
  185. package/lib/module/NumberFormatter/NumberFormatter.js +48 -11
  186. package/lib/module/NumberFormatter/NumberFormatter.js.map +1 -1
  187. package/lib/module/Paper/Paper.js +7 -8
  188. package/lib/module/Paper/Paper.js.map +1 -1
  189. package/lib/module/Pill/Pill.js +6 -8
  190. package/lib/module/Pill/Pill.js.map +1 -1
  191. package/lib/module/Progress/Progress.js +4 -1
  192. package/lib/module/Progress/Progress.js.map +1 -1
  193. package/lib/module/RollingNumber/RollingNumber.js +30 -13
  194. package/lib/module/RollingNumber/RollingNumber.js.map +1 -1
  195. package/lib/module/RollingNumber/rolling-number-utils.js +27 -5
  196. package/lib/module/RollingNumber/rolling-number-utils.js.map +1 -1
  197. package/lib/module/ScrollArea/ScrollArea.js +133 -43
  198. package/lib/module/ScrollArea/ScrollArea.js.map +1 -1
  199. package/lib/module/ScrollArea/ScrollArea.native.js +128 -40
  200. package/lib/module/ScrollArea/ScrollArea.native.js.map +1 -1
  201. package/lib/module/SegmentedControl/SegmentedControl.js +4 -1
  202. package/lib/module/SegmentedControl/SegmentedControl.js.map +1 -1
  203. package/lib/module/Select/Select.js +65 -36
  204. package/lib/module/Select/Select.js.map +1 -1
  205. package/lib/module/Skeleton/Skeleton.js +6 -2
  206. package/lib/module/Skeleton/Skeleton.js.map +1 -1
  207. package/lib/module/Slider/Slider.js +137 -84
  208. package/lib/module/Slider/Slider.js.map +1 -1
  209. package/lib/module/Spoiler/Spoiler.js +23 -3
  210. package/lib/module/Spoiler/Spoiler.js.map +1 -1
  211. package/lib/module/Stepper/Stepper.js +1 -1
  212. package/lib/module/Stepper/Stepper.js.map +1 -1
  213. package/lib/module/Switch/Switch.js +18 -7
  214. package/lib/module/Switch/Switch.js.map +1 -1
  215. package/lib/module/Table/Table.js +91 -28
  216. package/lib/module/Table/Table.js.map +1 -1
  217. package/lib/module/TableOfContents/TableOfContents.js +5 -2
  218. package/lib/module/TableOfContents/TableOfContents.js.map +1 -1
  219. package/lib/module/TagsInput/TagsInput.js +140 -57
  220. package/lib/module/TagsInput/TagsInput.js.map +1 -1
  221. package/lib/module/Tooltip/Tooltip.js +27 -5
  222. package/lib/module/Tooltip/Tooltip.js.map +1 -1
  223. package/lib/module/Tree/Tree.js +4 -1
  224. package/lib/module/Tree/Tree.js.map +1 -1
  225. package/lib/module/Tree/tree-data.js +57 -23
  226. package/lib/module/Tree/tree-data.js.map +1 -1
  227. package/lib/module/Tree/use-tree.js +34 -5
  228. package/lib/module/Tree/use-tree.js.map +1 -1
  229. package/lib/module/TreeSelect/TreeSelect.js +72 -32
  230. package/lib/module/TreeSelect/TreeSelect.js.map +1 -1
  231. package/lib/module/Typography/Typography.js +9 -10
  232. package/lib/module/Typography/Typography.js.map +1 -1
  233. package/lib/module/UnstyledButton/UnstyledButton.js +9 -4
  234. package/lib/module/UnstyledButton/UnstyledButton.js.map +1 -1
  235. package/lib/module/VirtualList/VirtualList.js +71 -13
  236. package/lib/module/VirtualList/VirtualList.js.map +1 -1
  237. package/lib/module/floating/platform.js +28 -1
  238. package/lib/module/floating/platform.js.map +1 -1
  239. package/lib/module/floating/use-position.js +33 -1
  240. package/lib/module/floating/use-position.js.map +1 -1
  241. package/lib/module/internal/ControlIconProvider.js +18 -13
  242. package/lib/module/internal/ControlIconProvider.js.map +1 -1
  243. package/lib/module/internal/color.js +8 -1
  244. package/lib/module/internal/color.js.map +1 -1
  245. package/lib/module/internal/gradient-shared.js +9 -5
  246. package/lib/module/internal/gradient-shared.js.map +1 -1
  247. package/lib/module/internal/gradient.js +22 -9
  248. package/lib/module/internal/gradient.js.map +1 -1
  249. package/lib/module/internal/gradient.native.js +36 -10
  250. package/lib/module/internal/gradient.native.js.map +1 -1
  251. package/lib/module/internal/render-text-child.js +30 -2
  252. package/lib/module/internal/render-text-child.js.map +1 -1
  253. package/lib/module/internal/style-props.js +16 -4
  254. package/lib/module/internal/style-props.js.map +1 -1
  255. package/lib/module/internal/theme-color-web.js +42 -0
  256. package/lib/module/internal/theme-color-web.js.map +1 -0
  257. package/lib/module/internal/use-icon-color.js +29 -0
  258. package/lib/module/internal/use-icon-color.js.map +1 -0
  259. package/lib/module/internal/use-icon-color.native.js +19 -0
  260. package/lib/module/internal/use-icon-color.native.js.map +1 -0
  261. package/lib/module/internal/use-looping-animation.js +8 -4
  262. package/lib/module/internal/use-looping-animation.js.map +1 -1
  263. package/lib/module/internal/use-looping-animation.native.js +10 -2
  264. package/lib/module/internal/use-looping-animation.native.js.map +1 -1
  265. package/lib/module/internal/use-looping-animation.shared.js +31 -0
  266. package/lib/module/internal/use-looping-animation.shared.js.map +1 -1
  267. package/lib/module/internal/use-slot-text-wrapper.js +37 -5
  268. package/lib/module/internal/use-slot-text-wrapper.js.map +1 -1
  269. package/lib/typescript/Accordion/Accordion.d.ts +15 -15
  270. package/lib/typescript/Accordion/Accordion.d.ts.map +1 -1
  271. package/lib/typescript/ActionIcon/ActionIcon.d.ts +13 -13
  272. package/lib/typescript/Alert/Alert.d.ts +19 -19
  273. package/lib/typescript/Alert/Alert.d.ts.map +1 -1
  274. package/lib/typescript/Anchor/Anchor.d.ts +9 -9
  275. package/lib/typescript/AngleSlider/AngleSlider.d.ts +8 -8
  276. package/lib/typescript/AngleSlider/AngleSlider.d.ts.map +1 -1
  277. package/lib/typescript/Autocomplete/Autocomplete.d.ts +18 -44
  278. package/lib/typescript/Autocomplete/Autocomplete.d.ts.map +1 -1
  279. package/lib/typescript/Avatar/Avatar.d.ts +38 -38
  280. package/lib/typescript/Badge/Badge.d.ts +20 -20
  281. package/lib/typescript/Badge/Badge.d.ts.map +1 -1
  282. package/lib/typescript/Blockquote/Blockquote.d.ts +8 -8
  283. package/lib/typescript/Breadcrumbs/Breadcrumbs.d.ts +8 -8
  284. package/lib/typescript/Burger/Burger.d.ts +4 -4
  285. package/lib/typescript/Button/Button.d.ts +13 -13
  286. package/lib/typescript/Button/Button.d.ts.map +1 -1
  287. package/lib/typescript/Card/Card.d.ts.map +1 -1
  288. package/lib/typescript/Checkbox/CheckIcon.d.ts.map +1 -1
  289. package/lib/typescript/Checkbox/Checkbox.d.ts.map +1 -1
  290. package/lib/typescript/Chip/Chip.d.ts +15 -15
  291. package/lib/typescript/Chip/Chip.d.ts.map +1 -1
  292. package/lib/typescript/CloseButton/CloseButton.d.ts +7 -7
  293. package/lib/typescript/Code/Code.d.ts +6 -6
  294. package/lib/typescript/ColorInput/ColorInput.d.ts.map +1 -1
  295. package/lib/typescript/ColorPicker/ColorPicker.d.ts.map +1 -1
  296. package/lib/typescript/Combobox/Combobox.d.ts +9 -9
  297. package/lib/typescript/Combobox/Combobox.d.ts.map +1 -1
  298. package/lib/typescript/Combobox/OptionsDropdown.d.ts.map +1 -1
  299. package/lib/typescript/Combobox/index.d.ts +7 -7
  300. package/lib/typescript/Container/Container.d.ts +3 -3
  301. package/lib/typescript/Dialog/Dialog.d.ts +6 -6
  302. package/lib/typescript/Drawer/Drawer.d.ts +4 -4
  303. package/lib/typescript/Fieldset/Fieldset.d.ts +11 -11
  304. package/lib/typescript/Flex/Flex.d.ts +3 -3
  305. package/lib/typescript/Group/Group.d.ts +3 -3
  306. package/lib/typescript/Group/Group.d.ts.map +1 -1
  307. package/lib/typescript/Highlight/Highlight.d.ts +4 -4
  308. package/lib/typescript/Highlight/Highlight.d.ts.map +1 -1
  309. package/lib/typescript/HoverCard/HoverCard.d.ts +1 -1
  310. package/lib/typescript/HoverCard/HoverCard.d.ts.map +1 -1
  311. package/lib/typescript/Image/Image.d.ts +25 -25
  312. package/lib/typescript/Image/createImage.d.ts +36 -36
  313. package/lib/typescript/Indicator/Indicator.d.ts +4 -4
  314. package/lib/typescript/Indicator/Indicator.d.ts.map +1 -1
  315. package/lib/typescript/Input/Input.d.ts +61 -61
  316. package/lib/typescript/Input/Input.d.ts.map +1 -1
  317. package/lib/typescript/Input/Input.native.d.ts +79 -79
  318. package/lib/typescript/Input/shared.d.ts +66 -66
  319. package/lib/typescript/Input/shared.d.ts.map +1 -1
  320. package/lib/typescript/InputBase/InputBase.d.ts +4 -4
  321. package/lib/typescript/Kbd/Kbd.d.ts +23 -23
  322. package/lib/typescript/KeyboardAvoidingView/KeyboardAvoidingView.d.ts +1 -1
  323. package/lib/typescript/KeyboardAwareScrollView/KeyboardAwareScrollView.d.ts +1 -1
  324. package/lib/typescript/List/List.d.ts +14 -14
  325. package/lib/typescript/Loader/Loader.d.ts.map +1 -1
  326. package/lib/typescript/LoadingOverlay/LoadingOverlay.d.ts +2 -2
  327. package/lib/typescript/Mark/Mark.d.ts +23 -23
  328. package/lib/typescript/Marquee/Marquee.d.ts +4 -4
  329. package/lib/typescript/MaskInput/MaskInput.d.ts +4 -4
  330. package/lib/typescript/Menu/Menu.d.ts +28 -28
  331. package/lib/typescript/Menu/Menu.d.ts.map +1 -1
  332. package/lib/typescript/Modal/Modal.d.ts +10 -10
  333. package/lib/typescript/MultiSelect/MultiSelect.d.ts +17 -62
  334. package/lib/typescript/MultiSelect/MultiSelect.d.ts.map +1 -1
  335. package/lib/typescript/NavLink/NavLink.d.ts +19 -19
  336. package/lib/typescript/Notification/Notification.d.ts +12 -12
  337. package/lib/typescript/Notification/Notification.d.ts.map +1 -1
  338. package/lib/typescript/NumberFormatter/NumberFormatter.d.ts +6 -6
  339. package/lib/typescript/NumberFormatter/NumberFormatter.d.ts.map +1 -1
  340. package/lib/typescript/NumberInput/NumberInput.d.ts +15 -15
  341. package/lib/typescript/Overlay/Overlay.d.ts +3 -3
  342. package/lib/typescript/Paper/Paper.d.ts +8 -40
  343. package/lib/typescript/Paper/Paper.d.ts.map +1 -1
  344. package/lib/typescript/Paragraph/Paragraph.d.ts +6 -6
  345. package/lib/typescript/PasswordInput/PasswordInput.d.ts +19 -19
  346. package/lib/typescript/Pill/Pill.d.ts +19 -19
  347. package/lib/typescript/Pill/Pill.d.ts.map +1 -1
  348. package/lib/typescript/PinInput/PinInput.d.ts +66 -66
  349. package/lib/typescript/Popover/Popover.shared.d.ts +3 -3
  350. package/lib/typescript/Progress/Progress.d.ts +4 -4
  351. package/lib/typescript/Progress/Progress.d.ts.map +1 -1
  352. package/lib/typescript/Radio/Radio.d.ts +8 -8
  353. package/lib/typescript/Rating/Rating.d.ts +2 -2
  354. package/lib/typescript/RollingNumber/RollingNumber.d.ts +4 -4
  355. package/lib/typescript/RollingNumber/RollingNumber.d.ts.map +1 -1
  356. package/lib/typescript/RollingNumber/rolling-number-utils.d.ts.map +1 -1
  357. package/lib/typescript/ScrollArea/ScrollArea.d.ts.map +1 -1
  358. package/lib/typescript/ScrollArea/ScrollArea.native.d.ts.map +1 -1
  359. package/lib/typescript/SegmentedControl/SegmentedControl.d.ts +4 -4
  360. package/lib/typescript/SegmentedControl/SegmentedControl.d.ts.map +1 -1
  361. package/lib/typescript/Select/Select.d.ts +22 -51
  362. package/lib/typescript/Select/Select.d.ts.map +1 -1
  363. package/lib/typescript/Separator/Separator.d.ts +13 -13
  364. package/lib/typescript/Skeleton/Skeleton.d.ts +3 -3
  365. package/lib/typescript/Skeleton/Skeleton.d.ts.map +1 -1
  366. package/lib/typescript/Slider/Slider.d.ts +12 -12
  367. package/lib/typescript/Slider/Slider.d.ts.map +1 -1
  368. package/lib/typescript/Spoiler/Spoiler.d.ts +4 -4
  369. package/lib/typescript/Spoiler/Spoiler.d.ts.map +1 -1
  370. package/lib/typescript/Stepper/Stepper.d.ts +16 -16
  371. package/lib/typescript/Switch/Switch.d.ts +18 -7
  372. package/lib/typescript/Switch/Switch.d.ts.map +1 -1
  373. package/lib/typescript/Table/Table.d.ts +59 -53
  374. package/lib/typescript/Table/Table.d.ts.map +1 -1
  375. package/lib/typescript/TableOfContents/TableOfContents.d.ts +4 -4
  376. package/lib/typescript/TableOfContents/TableOfContents.d.ts.map +1 -1
  377. package/lib/typescript/Tabs/Tabs.d.ts +15 -15
  378. package/lib/typescript/TagsInput/TagsInput.d.ts +15 -49
  379. package/lib/typescript/TagsInput/TagsInput.d.ts.map +1 -1
  380. package/lib/typescript/Text/Text.d.ts +2 -2
  381. package/lib/typescript/TextInput/TextInput.d.ts +4 -4
  382. package/lib/typescript/Textarea/Textarea.d.ts +4 -4
  383. package/lib/typescript/ThemeIcon/ThemeIcon.d.ts +7 -7
  384. package/lib/typescript/Title/Title.d.ts +9 -9
  385. package/lib/typescript/Tooltip/Tooltip.d.ts +4 -4
  386. package/lib/typescript/Tooltip/Tooltip.d.ts.map +1 -1
  387. package/lib/typescript/Tree/Tree.d.ts +8 -8
  388. package/lib/typescript/Tree/Tree.d.ts.map +1 -1
  389. package/lib/typescript/Tree/tree-data.d.ts +7 -0
  390. package/lib/typescript/Tree/tree-data.d.ts.map +1 -1
  391. package/lib/typescript/Tree/use-tree.d.ts +5 -0
  392. package/lib/typescript/Tree/use-tree.d.ts.map +1 -1
  393. package/lib/typescript/TreeSelect/TreeSelect.d.ts +36 -62
  394. package/lib/typescript/TreeSelect/TreeSelect.d.ts.map +1 -1
  395. package/lib/typescript/Typography/Typography.d.ts +8 -8
  396. package/lib/typescript/Typography/Typography.d.ts.map +1 -1
  397. package/lib/typescript/UnstyledButton/UnstyledButton.d.ts.map +1 -1
  398. package/lib/typescript/VirtualList/VirtualList.d.ts.map +1 -1
  399. package/lib/typescript/VisuallyHidden/VisuallyHidden.d.ts +6 -6
  400. package/lib/typescript/floating/platform.d.ts +11 -0
  401. package/lib/typescript/floating/platform.d.ts.map +1 -1
  402. package/lib/typescript/floating/use-position.d.ts.map +1 -1
  403. package/lib/typescript/internal/ControlIconProvider.d.ts +1 -1
  404. package/lib/typescript/internal/ControlIconProvider.d.ts.map +1 -1
  405. package/lib/typescript/internal/InlineControl.d.ts +6 -6
  406. package/lib/typescript/internal/color.d.ts.map +1 -1
  407. package/lib/typescript/internal/gradient-shared.d.ts +7 -4
  408. package/lib/typescript/internal/gradient-shared.d.ts.map +1 -1
  409. package/lib/typescript/internal/gradient.d.ts +18 -0
  410. package/lib/typescript/internal/gradient.d.ts.map +1 -1
  411. package/lib/typescript/internal/gradient.native.d.ts.map +1 -1
  412. package/lib/typescript/internal/render-text-child.d.ts +11 -0
  413. package/lib/typescript/internal/render-text-child.d.ts.map +1 -1
  414. package/lib/typescript/internal/style-props.d.ts +17 -0
  415. package/lib/typescript/internal/style-props.d.ts.map +1 -1
  416. package/lib/typescript/internal/theme-color-web.d.ts +2 -0
  417. package/lib/typescript/internal/theme-color-web.d.ts.map +1 -0
  418. package/lib/typescript/internal/use-icon-color.d.ts +25 -0
  419. package/lib/typescript/internal/use-icon-color.d.ts.map +1 -0
  420. package/lib/typescript/internal/use-icon-color.native.d.ts +11 -0
  421. package/lib/typescript/internal/use-icon-color.native.d.ts.map +1 -0
  422. package/lib/typescript/internal/use-looping-animation.d.ts.map +1 -1
  423. package/lib/typescript/internal/use-looping-animation.native.d.ts.map +1 -1
  424. package/lib/typescript/internal/use-looping-animation.shared.d.ts +30 -3
  425. package/lib/typescript/internal/use-looping-animation.shared.d.ts.map +1 -1
  426. package/lib/typescript/internal/use-slot-text-wrapper.d.ts +0 -20
  427. package/lib/typescript/internal/use-slot-text-wrapper.d.ts.map +1 -1
  428. package/package.json +7 -7
  429. package/src/Accordion/Accordion.tsx +6 -2
  430. package/src/Alert/Alert.tsx +43 -22
  431. package/src/AngleSlider/AngleSlider.tsx +73 -21
  432. package/src/Autocomplete/Autocomplete.tsx +74 -55
  433. package/src/Badge/Badge.tsx +6 -8
  434. package/src/Button/Button.tsx +17 -3
  435. package/src/Card/Card.tsx +11 -3
  436. package/src/Checkbox/CheckIcon.tsx +9 -5
  437. package/src/Checkbox/Checkbox.tsx +8 -1
  438. package/src/Chip/Chip.tsx +15 -22
  439. package/src/CloseButton/CloseButton.tsx +1 -1
  440. package/src/ColorInput/ColorInput.tsx +15 -4
  441. package/src/ColorPicker/ColorPicker.tsx +38 -25
  442. package/src/Combobox/Combobox.tsx +10 -6
  443. package/src/Combobox/OptionsDropdown.tsx +6 -1
  444. package/src/Group/Group.tsx +21 -10
  445. package/src/Highlight/Highlight.tsx +42 -7
  446. package/src/HoverCard/HoverCard.tsx +48 -31
  447. package/src/Indicator/Indicator.tsx +4 -0
  448. package/src/Input/Input.tsx +31 -16
  449. package/src/Input/shared.tsx +20 -4
  450. package/src/Loader/Loader.tsx +14 -4
  451. package/src/Menu/Menu.tsx +6 -8
  452. package/src/MultiSelect/MultiSelect.tsx +140 -85
  453. package/src/Notification/Notification.tsx +43 -22
  454. package/src/NumberFormatter/NumberFormatter.tsx +66 -11
  455. package/src/Paper/Paper.tsx +8 -6
  456. package/src/Pill/Pill.tsx +6 -9
  457. package/src/Progress/Progress.tsx +3 -0
  458. package/src/RollingNumber/RollingNumber.tsx +43 -21
  459. package/src/RollingNumber/rolling-number-utils.ts +28 -5
  460. package/src/ScrollArea/ScrollArea.native.tsx +142 -49
  461. package/src/ScrollArea/ScrollArea.tsx +140 -47
  462. package/src/SegmentedControl/SegmentedControl.tsx +12 -1
  463. package/src/Select/Select.tsx +90 -67
  464. package/src/Skeleton/Skeleton.tsx +5 -1
  465. package/src/Slider/Slider.tsx +157 -61
  466. package/src/Spoiler/Spoiler.tsx +22 -10
  467. package/src/Stepper/Stepper.tsx +1 -1
  468. package/src/Switch/Switch.tsx +20 -9
  469. package/src/Table/Table.tsx +89 -33
  470. package/src/TableOfContents/TableOfContents.tsx +5 -1
  471. package/src/TagsInput/TagsInput.tsx +193 -141
  472. package/src/Tooltip/Tooltip.tsx +33 -7
  473. package/src/Tree/Tree.tsx +4 -1
  474. package/src/Tree/tree-data.ts +74 -26
  475. package/src/Tree/use-tree.ts +52 -7
  476. package/src/TreeSelect/TreeSelect.tsx +96 -64
  477. package/src/Typography/Typography.tsx +9 -8
  478. package/src/UnstyledButton/UnstyledButton.tsx +12 -5
  479. package/src/VirtualList/VirtualList.tsx +82 -18
  480. package/src/floating/platform.ts +29 -1
  481. package/src/floating/use-position.tsx +38 -1
  482. package/src/internal/ControlIconProvider.tsx +17 -12
  483. package/src/internal/color.ts +8 -1
  484. package/src/internal/gradient-shared.ts +9 -5
  485. package/src/internal/gradient.native.tsx +29 -5
  486. package/src/internal/gradient.tsx +22 -7
  487. package/src/internal/render-text-child.tsx +30 -2
  488. package/src/internal/style-props.ts +20 -4
  489. package/src/internal/theme-color-web.ts +40 -0
  490. package/src/internal/use-icon-color.native.ts +17 -0
  491. package/src/internal/use-icon-color.ts +26 -0
  492. package/src/internal/use-looping-animation.native.tsx +10 -2
  493. package/src/internal/use-looping-animation.shared.ts +38 -3
  494. package/src/internal/use-looping-animation.tsx +8 -4
  495. package/src/internal/use-slot-text-wrapper.tsx +39 -5
@@ -1,6 +1,7 @@
1
1
  import * as React from "react";
2
2
 
3
3
  import { type LayoutChangeEvent, styled } from "@knitui/core";
4
+ import { useCallbackRef } from "@knitui/hooks";
4
5
 
5
6
  import { Box, type BoxProps } from "../Box";
6
7
  import { slotStyles } from "../internal/styles";
@@ -44,6 +45,23 @@ export type {
44
45
  * model, so no exact `estimatedItemSize` is required (a closer seed just means
45
46
  * less first-scroll correction). Mirrors the familiar `FlatList` / `FlashList`
46
47
  * surface for the v1 subset: vertical, single-column lists.
48
+ *
49
+ * ## Keep the row props stable
50
+ *
51
+ * Each mounted row is a memoized cell, so scrolling only re-renders the rows that
52
+ * actually enter or leave the window — but ONLY if the props handed to those rows
53
+ * keep their identity. For the memo to pay off, `renderItem` (and, when supplied,
54
+ * `getItemType`, `ItemSeparatorComponent` and `styles.item`) must be referentially
55
+ * stable: hoist them, or wrap them in `useCallback` / `useMemo`. An inline
56
+ * `renderItem={({ item }) => …}` is a new function on every parent render and
57
+ * therefore re-runs for every mounted row — cheap for a handful of rows, the
58
+ * dominant scroll cost for a large window.
59
+ *
60
+ * They are deliberately NOT stabilised internally (e.g. via `useCallbackRef`),
61
+ * because a `renderItem` closing over component state must be able to produce new
62
+ * output when that state changes. Pass `extraData` when your rows depend on state
63
+ * a stable `renderItem` cannot see: it is compared by the row memo and re-renders
64
+ * every mounted row.
47
65
  */
48
66
  const VirtualListFrame = styled(Box, {
49
67
  name: "VirtualList",
@@ -70,6 +88,17 @@ const VirtualListItem = styled(Box, {
70
88
  /* Memoized row cell */
71
89
  /* -------------------------------------------------------------------------- */
72
90
 
91
+ /**
92
+ * Stable fallback for the optional `item` slot.
93
+ *
94
+ * `slots.get("item") ?? {}` allocated a FRESH object on every render, and that
95
+ * object is handed to the memoized {@link Row} as `itemProps` — so the common
96
+ * case (no `styles.item`) silently defeated the row memo and re-ran `renderItem`
97
+ * for every mounted row on every windowing render and every measurement-driven
98
+ * `bumpLayout`. One module-level constant keeps the reference identical forever.
99
+ */
100
+ const EMPTY_ITEM_PROPS: Partial<BoxProps> = {};
101
+
73
102
  interface RowProps<T> {
74
103
  item: T;
75
104
  index: number;
@@ -80,6 +109,13 @@ interface RowProps<T> {
80
109
  separator: React.ReactNode;
81
110
  onMeasure: (index: number, height: number, type: string | number) => void;
82
111
  itemProps: Partial<BoxProps>;
112
+ /**
113
+ * Not read by the row — carried purely so `React.memo` compares it. This is
114
+ * what makes the documented `extraData` escape hatch work now that the row's
115
+ * other props can all be referentially stable: change `extraData` and every
116
+ * mounted row re-runs `renderItem`, even though its `item` did not change.
117
+ */
118
+ extraData?: unknown;
83
119
  }
84
120
 
85
121
  /**
@@ -154,7 +190,9 @@ function VirtualListInner<T>(
154
190
  const slots = slotStyles<VirtualListStyles>(styles, VIRTUAL_LIST_SLOTS, "VirtualList");
155
191
  const scrollAreaSlot = slots.get("scrollArea");
156
192
  const contentSlot = slots.get("content");
157
- const itemSlot = slots.get("item") ?? {};
193
+ // Referentially stable when the caller passes no `styles.item` — see
194
+ // {@link EMPTY_ITEM_PROPS}; a fresh `{}` here would break every row's memo.
195
+ const itemSlot = slots.get("item") ?? EMPTY_ITEM_PROPS;
158
196
 
159
197
  const count = data.length;
160
198
 
@@ -185,12 +223,30 @@ function VirtualListInner<T>(
185
223
  const [layoutVersion, bumpLayout] = React.useReducer((v: number) => v + 1, 0);
186
224
  const [headerH, setHeaderH] = React.useState(0);
187
225
  const [footerH, setFooterH] = React.useState(0);
188
-
189
- const maybeEndReached = React.useCallback(() => {
226
+ // The chrome heights are ALSO mirrored into refs, written by the same layout
227
+ // handlers that set the state. The scroll path below reads the refs, never the
228
+ // state: `useCallbackRef` refreshes its closure in a passive effect, so a scroll
229
+ // sample landing between a chrome commit and that flush would otherwise window
230
+ // against the previous header height. Refs close that gap; the state copies exist
231
+ // only because rendering (row tops, spacer height) needs them.
232
+ const headerHRef = React.useRef(0);
233
+ const footerHRef = React.useRef(0);
234
+
235
+ // ── the scroll path: every callback below has a STABLE identity ──
236
+ // These land (via `handleScroll`) on `ScrollArea`'s `onScrollPositionChange`,
237
+ // which is a dependency of its `reportScroll`, which is a dependency of its
238
+ // `useAnimatedScrollHandler`. A new identity per render therefore rebuilt the
239
+ // Reanimated worklet scroll handler on every windowing render — i.e. repeatedly
240
+ // WHILE the user is flinging. `useCallbackRef` keeps one identity forever and
241
+ // still invokes the latest closure, so the freshest props/state are always read.
242
+ // All live values they touch are refs (`layoutRef`, `scrollTopRef`,
243
+ // `viewportHRef`, `rangeRef`, `endReachedFiredRef`, `headerHRef`, `footerHRef`);
244
+ // the rest are props, which the latest closure supplies.
245
+ const maybeEndReached = useCallbackRef(() => {
190
246
  if (!onEndReached) return;
191
247
  const vh = viewportHRef.current;
192
248
  if (vh <= 0) return;
193
- const total = getContentSize(layoutRef.current) + headerH + footerH;
249
+ const total = getContentSize(layoutRef.current) + headerHRef.current + footerHRef.current;
194
250
  const distanceFromEnd = total - (scrollTopRef.current + vh);
195
251
  if (distanceFromEnd <= onEndReachedThreshold * vh) {
196
252
  if (!endReachedFiredRef.current) {
@@ -200,16 +256,16 @@ function VirtualListInner<T>(
200
256
  } else {
201
257
  endReachedFiredRef.current = false;
202
258
  }
203
- }, [onEndReached, onEndReachedThreshold, headerH, footerH]);
259
+ });
204
260
 
205
261
  // Recompute the mounted range from the live scroll + viewport, and only commit
206
262
  // to React state when the range actually changes (one render per row-crossing,
207
263
  // not per scroll frame).
208
- const recomputeRange = React.useCallback(() => {
264
+ const recomputeRange = useCallbackRef(() => {
209
265
  const vh = viewportHRef.current;
210
266
  const next = findVisibleRange(
211
267
  layoutRef.current,
212
- scrollTopRef.current - headerH,
268
+ scrollTopRef.current - headerHRef.current,
213
269
  vh,
214
270
  drawDistance,
215
271
  );
@@ -219,16 +275,13 @@ function VirtualListInner<T>(
219
275
  setRange(next);
220
276
  onRenderedRangeChange?.(next);
221
277
  }
222
- }, [drawDistance, headerH, onRenderedRangeChange]);
278
+ });
223
279
 
224
- const handleScroll = React.useCallback(
225
- (pos: { x: number; y: number }) => {
226
- scrollTopRef.current = pos.y;
227
- recomputeRange();
228
- maybeEndReached();
229
- },
230
- [recomputeRange, maybeEndReached],
231
- );
280
+ const handleScroll = useCallbackRef((pos: { x: number; y: number }) => {
281
+ scrollTopRef.current = pos.y;
282
+ recomputeRange();
283
+ maybeEndReached();
284
+ });
232
285
 
233
286
  const handleFrameLayout = React.useCallback((e: LayoutChangeEvent) => {
234
287
  const h = e.nativeEvent.layout.height;
@@ -248,6 +301,10 @@ function VirtualListInner<T>(
248
301
 
249
302
  // After any commit that could move offsets (measurement, viewport, data, chrome),
250
303
  // re-window and re-check the end. Runs post-layout so measurements are settled.
304
+ // `recomputeRange` / `maybeEndReached` are stable, so this now fires only when one
305
+ // of the listed values actually changed instead of on every single render.
306
+ // `drawDistance` / `onEndReachedThreshold` are listed explicitly because they used
307
+ // to reach this list through those callbacks' identities.
251
308
  React.useEffect(() => {
252
309
  recomputeRange();
253
310
  maybeEndReached();
@@ -258,6 +315,8 @@ function VirtualListInner<T>(
258
315
  headerH,
259
316
  footerH,
260
317
  extraData,
318
+ drawDistance,
319
+ onEndReachedThreshold,
261
320
  recomputeRange,
262
321
  maybeEndReached,
263
322
  ]);
@@ -313,6 +372,7 @@ function VirtualListInner<T>(
313
372
  separator={ItemSeparatorComponent}
314
373
  onMeasure={handleMeasure}
315
374
  itemProps={itemSlot}
375
+ extraData={extraData}
316
376
  />,
317
377
  );
318
378
  }
@@ -342,7 +402,9 @@ function VirtualListInner<T>(
342
402
  right={0}
343
403
  onLayout={(e: LayoutChangeEvent) => {
344
404
  const h = e.nativeEvent.layout.height;
345
- setHeaderH((prev) => (Math.abs(prev - h) > 0.5 ? h : prev));
405
+ if (Math.abs(headerHRef.current - h) <= 0.5) return;
406
+ headerHRef.current = h;
407
+ setHeaderH(h);
346
408
  }}
347
409
  >
348
410
  {ListHeaderComponent}
@@ -357,7 +419,9 @@ function VirtualListInner<T>(
357
419
  right={0}
358
420
  onLayout={(e: LayoutChangeEvent) => {
359
421
  const h = e.nativeEvent.layout.height;
360
- setFooterH((prev) => (Math.abs(prev - h) > 0.5 ? h : prev));
422
+ if (Math.abs(footerHRef.current - h) <= 0.5) return;
423
+ footerHRef.current = h;
424
+ setFooterH(h);
361
425
  }}
362
426
  >
363
427
  {ListFooterComponent}
@@ -76,6 +76,17 @@ export function measure(
76
76
  * Reposition `onUpdate` whenever the layout could have changed: scroll (captured
77
77
  * so nested scroll containers count), window resize, and element resize. Calls
78
78
  * `onUpdate` once immediately so the first position is computed synchronously.
79
+ *
80
+ * Every trigger is **coalesced into one `requestAnimationFrame` per frame**. This is
81
+ * load-bearing for scroll performance, not a micro-optimisation: the capture-phase
82
+ * `scroll` listener fires for EVERY scrollable ancestor in the app, and a repositioning
83
+ * pass reads `getBoundingClientRect()` on the reference, the floating element and its
84
+ * offset parent — layout reads interleaved with the style writes of the previous pass,
85
+ * i.e. a forced synchronous reflow each time. Browsers can dispatch several scroll
86
+ * events (plus a `ResizeObserver` callback, plus a resize) within one frame, and each
87
+ * one used to run the full measure → `computePosition` → `setState` → restyle cycle.
88
+ * Painting at most once per frame is all the display can show anyway, and it collapses
89
+ * a burst of triggers into a single reflow.
79
90
  */
80
91
  export function autoUpdate(
81
92
  referenceNode: TamaguiElement | null,
@@ -84,7 +95,21 @@ export function autoUpdate(
84
95
  ): () => void {
85
96
  if (typeof window === "undefined") return () => {};
86
97
 
87
- const handler = () => onUpdate();
98
+ let frame: number | null = null;
99
+ const canSchedule = typeof requestAnimationFrame === "function";
100
+
101
+ const handler = () => {
102
+ if (!canSchedule) {
103
+ onUpdate();
104
+ return;
105
+ }
106
+ if (frame != null) return;
107
+ frame = requestAnimationFrame(() => {
108
+ frame = null;
109
+ onUpdate();
110
+ });
111
+ };
112
+
88
113
  window.addEventListener("scroll", handler, { capture: true, passive: true });
89
114
  window.addEventListener("resize", handler, { passive: true });
90
115
 
@@ -97,9 +122,12 @@ export function autoUpdate(
97
122
  if (floating) observer.observe(floating);
98
123
  }
99
124
 
125
+ // The FIRST position is computed synchronously (not through the frame above) so the
126
+ // overlay never paints one frame at its un-positioned origin.
100
127
  onUpdate();
101
128
 
102
129
  return () => {
130
+ if (frame != null && typeof cancelAnimationFrame === "function") cancelAnimationFrame(frame);
103
131
  window.removeEventListener("scroll", handler, { capture: true });
104
132
  window.removeEventListener("resize", handler);
105
133
  observer?.disconnect();
@@ -67,6 +67,43 @@ export type UsePositionReturn = {
67
67
  floatingStyles: { position: Strategy; top: number; left: number };
68
68
  };
69
69
 
70
+ /**
71
+ * Cheap structural comparison for the middleware-data bag, used to bail out of
72
+ * re-renders when nothing moved. This runs on EVERY repositioning pass — i.e. once
73
+ * per animation frame while the page scrolls with an overlay open — so it must not
74
+ * allocate: the previous implementation `JSON.stringify`d both bags on every pass
75
+ * (two full serializations per frame, per open overlay) just to compare a handful of
76
+ * numbers (`arrow.x/y`, `hide.*`, `offset.x/y`, the reference width). One level of
77
+ * nesting is enough for every middleware the engine ships.
78
+ */
79
+ const shallowEqual = (a: unknown, b: unknown): boolean => {
80
+ if (a === b) return true;
81
+ if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) return false;
82
+ const aKeys = Object.keys(a as object);
83
+ const bKeys = Object.keys(b as object);
84
+ if (aKeys.length !== bKeys.length) return false;
85
+ for (const key of aKeys) {
86
+ if (
87
+ (a as Record<string, unknown>)[key] !== (b as Record<string, unknown>)[key] &&
88
+ !Object.is((a as Record<string, unknown>)[key], (b as Record<string, unknown>)[key])
89
+ ) {
90
+ return false;
91
+ }
92
+ }
93
+ return true;
94
+ };
95
+
96
+ const middlewareDataEqual = (a: MiddlewareData, b: MiddlewareData): boolean => {
97
+ const aKeys = Object.keys(a);
98
+ const bKeys = Object.keys(b);
99
+ if (aKeys.length !== bKeys.length) return false;
100
+ for (const key of aKeys) {
101
+ if (!(key in b)) return false;
102
+ if (!shallowEqual(a[key], b[key])) return false;
103
+ }
104
+ return true;
105
+ };
106
+
70
107
  type PositionData = {
71
108
  x: number | null;
72
109
  y: number | null;
@@ -181,7 +218,7 @@ export function usePosition(props: UsePositionProps): UsePositionReturn {
181
218
  prev.y === y &&
182
219
  prev.placement === result.placement &&
183
220
  prev.strategy === cfg.strategy &&
184
- JSON.stringify(prev.middlewareData) === JSON.stringify(result.middlewareData)
221
+ middlewareDataEqual(prev.middlewareData, result.middlewareData)
185
222
  ) {
186
223
  return prev;
187
224
  }
@@ -1,11 +1,14 @@
1
- import * as React from "react";
1
+ import type * as React from "react";
2
2
 
3
- import { useTheme } from "@knitui/core";
4
- import { IconProvider } from "@knitui/icons";
3
+ // Deep import on purpose: the `@knitui/icons` root barrel re-exports all ~6.1k
4
+ // icon modules, and Metro does not tree-shake — importing it here would pull
5
+ // every glyph into every component that renders a control icon. See the
6
+ // `no-restricted-imports` guardrail in eslint.config.base.mjs.
7
+ import { IconProvider } from "@knitui/icons/context";
5
8
 
6
9
  import { controlIconSize } from "./control-icon-size";
7
10
  import type { SizeKey } from "./control-metrics";
8
- import { resolveThemeColor } from "./resolve-theme-color";
11
+ import { useIconColor } from "./use-icon-color";
9
12
  import { VARIANT_FOREGROUND_EMPHASIS } from "./variant-colors";
10
13
 
11
14
  type ForegroundVariant = keyof typeof VARIANT_FOREGROUND_EMPHASIS;
@@ -47,15 +50,17 @@ export function ControlIconProvider({
47
50
  stroke,
48
51
  children,
49
52
  }: ControlIconProviderProps) {
50
- const theme = useTheme();
51
53
  const token = color ?? VARIANT_FOREGROUND_EMPHASIS[variant]?.color ?? "$color12";
52
- const resolvedColor = resolveThemeColor(theme, token);
53
- const iconSize = controlIconSize(size);
54
+ // Theme-free on web, theme-subscribing on native — see `use-icon-color.ts`.
55
+ const resolvedColor = useIconColor(token);
54
56
 
55
- const value = React.useMemo(
56
- () => ({ size: iconSize, color: resolvedColor, stroke }),
57
- [iconSize, resolvedColor, stroke],
57
+ // Passed inline on purpose: `IconProvider` already memoises its context value
58
+ // on the PRIMITIVE `size`/`color`/`stroke` fields rather than on `value`'s
59
+ // identity, so a `useMemo` here would buy nothing and cost a deps array plus a
60
+ // retained object per control section.
61
+ return (
62
+ <IconProvider value={{ size: controlIconSize(size), color: resolvedColor, stroke }}>
63
+ {children}
64
+ </IconProvider>
58
65
  );
59
-
60
- return <IconProvider value={value}>{children}</IconProvider>;
61
66
  }
@@ -45,7 +45,14 @@ export function hsvaToRgbaObject({ h, s, v, a }: HsvaColor): RgbaColor {
45
45
  const l = _v * (1 - _s);
46
46
  const c = _v * (1 - (_h - hh) * _s);
47
47
  const d = _v * (1 - (1 - _h + hh) * _s);
48
- const module = hh % 6;
48
+ // Euclidean remainder, not `%`. An out-of-range hue reaches here unnormalised:
49
+ // `h` is a plain number on the public `HsvaColor` API, and `ColorPicker` feeds
50
+ // it straight through on every hue change. A negative one gave `hh = -1`, and
51
+ // `hh % 6 === -1` indexed off the FRONT of the three sector tuples below,
52
+ // producing `NaN` for every channel. (The *string* path can't get here —
53
+ // `VALIDATION_REGEXP.hsl` requires `\d+`, so `hsl(-60, …)` is rejected as
54
+ // invalid and resolves to black.)
55
+ const module = ((hh % 6) + 6) % 6;
49
56
 
50
57
  return {
51
58
  r: round([_v, c, l, l, d, _v][module] * 255),
@@ -16,6 +16,7 @@ import type * as React from "react";
16
16
  import type { useTheme } from "@knitui/core";
17
17
 
18
18
  import { resolveThemeColor } from "./resolve-theme-color";
19
+ import { themeColorToCssVar } from "./theme-color-web";
19
20
 
20
21
  /** A single gradient color stop. `offset` is a 0–100 percentage along the line. */
21
22
  export interface GradientStop {
@@ -90,13 +91,16 @@ export const normalizeStops = (gradient: GradientValue): Required<GradientStop>[
90
91
  type Theme = ReturnType<typeof useTheme>;
91
92
 
92
93
  /**
93
- * Build the web `linear-gradient(...)` string. Each stop color is resolved
94
- * through {@link resolveThemeColor}, so a `$colorN` token becomes `var(--colorN)`
95
- * and the gradient still tracks the active theme via CSS variables.
94
+ * Build the web `linear-gradient(...)` string. Each stop color is mapped to its
95
+ * CSS custom property by {@link themeColorToCssVar}, so a `$colorN` token becomes
96
+ * `var(--colorN)` and the gradient still tracks the active theme via CSS
97
+ * variables — WITHOUT reading the theme object, which is why the web
98
+ * `useGradient` needs no `useTheme()` (see `theme-color-web.ts`). Web-only; the
99
+ * native painter resolves stops to concrete colors via {@link resolveStops}.
96
100
  */
97
- export const gradientToCss = (theme: Theme, gradient: GradientValue): string => {
101
+ export const gradientToCss = (gradient: GradientValue): string => {
98
102
  const stops = normalizeStops(gradient)
99
- .map((stop) => `${resolveThemeColor(theme, stop.color)} ${stop.offset}%`)
103
+ .map((stop) => `${themeColorToCssVar(stop.color)} ${stop.offset}%`)
100
104
  .join(", ");
101
105
  return `linear-gradient(${gradientDeg(gradient)}deg, ${stops})`;
102
106
  };
@@ -8,6 +8,14 @@
8
8
  *
9
9
  * Stop colors are resolved to concrete values via `resolveStops` because
10
10
  * `react-native-svg` can't paint `$colorN` tokens. See `gradient-shared.ts`.
11
+ *
12
+ * The theme read + `useId` live INSIDE {@link GradientLayer}, which only mounts
13
+ * when a gradient actually exists. In the hook they ran on every render of every
14
+ * Button / ActionIcon / Badge / Avatar / CloseButton / ThemeIcon / Pill / Alert
15
+ * — a full `useThemeWithState` (useId + useRef + useReducer + a dep-less
16
+ * `useEffect` after every render) plus a regex `replace`, for a feature that is
17
+ * off unless `variant="gradient"`. `frameProps` is a static constant, so nothing
18
+ * the hook returns needs the theme.
11
19
  */
12
20
  import * as React from "react";
13
21
  import Svg, { Defs, LinearGradient, Rect, Stop } from "react-native-svg";
@@ -20,17 +28,30 @@ import { degToSvgCoords, gradientDeg, resolveStops } from "./gradient-shared";
20
28
 
21
29
  export type { GradientStop, GradientValue } from "./gradient-shared";
22
30
 
23
- export const useGradient = (gradient: GradientValue | undefined): GradientResult => {
31
+ /**
32
+ * The no-gradient result, shared and frozen so the (overwhelmingly common)
33
+ * off-path allocates nothing and keeps a stable `frameProps` identity across
34
+ * renders — a fresh `{}` per render would defeat downstream prop memoisation.
35
+ */
36
+ const EMPTY_GRADIENT: GradientResult = Object.freeze({
37
+ frameProps: Object.freeze({}),
38
+ layer: null,
39
+ });
40
+
41
+ /** Frame props when a gradient IS painted — static, so it can be a constant. */
42
+ const GRADIENT_FRAME_PROPS = Object.freeze({ overflow: "hidden" as const });
43
+
44
+ /** The SVG fill layer. Mounted only when a `gradient` exists, so the theme
45
+ * subscription + `useId` are paid only by components that actually paint one. */
46
+ function GradientLayer({ gradient }: { gradient: GradientValue }) {
24
47
  const theme = useTheme();
25
48
  // `useId` is colon-bearing; SVG ids must be colon-free to be valid `url(#…)` refs.
26
49
  const id = `knitui-grad-${React.useId().replace(/:/g, "")}`;
27
50
 
28
- if (!gradient) return { frameProps: {}, layer: null };
29
-
30
51
  const stops = resolveStops(theme, gradient);
31
52
  const { x1, y1, x2, y2 } = degToSvgCoords(gradientDeg(gradient));
32
53
 
33
- const layer = (
54
+ return (
34
55
  <Box position="absolute" top={0} left={0} right={0} bottom={0} pointerEvents="none">
35
56
  <Svg width="100%" height="100%">
36
57
  <Defs>
@@ -44,6 +65,9 @@ export const useGradient = (gradient: GradientValue | undefined): GradientResult
44
65
  </Svg>
45
66
  </Box>
46
67
  );
68
+ }
47
69
 
48
- return { frameProps: { overflow: "hidden" }, layer };
70
+ export const useGradient = (gradient: GradientValue | undefined): GradientResult => {
71
+ if (!gradient) return EMPTY_GRADIENT;
72
+ return { frameProps: GRADIENT_FRAME_PROPS, layer: <GradientLayer gradient={gradient} /> };
49
73
  };
@@ -4,19 +4,34 @@
4
4
  * `backgroundImage`, so there's no extra DOM: the hook just resolves the
5
5
  * `gradient` value to a `linear-gradient(...)` string spread onto the frame.
6
6
  *
7
- * Returns `{ frameProps: {}, layer: null }` when `gradient` is undefined (the
8
- * component isn't in `variant="gradient"`), so callers can wire it
7
+ * Returns the shared frozen {@link EMPTY_GRADIENT} when `gradient` is undefined
8
+ * (the component isn't in `variant="gradient"`), so callers can wire it
9
9
  * unconditionally. See `gradient-shared.ts` for the value type + math.
10
+ *
11
+ * Deliberately hook-FREE. It used to call `useTheme()` before the bail-out, so
12
+ * every Button / ActionIcon / Badge / Avatar / CloseButton / ThemeIcon / Pill /
13
+ * Alert paid a full `useThemeWithState` (useId + useRef + useReducer + a
14
+ * dep-less `useEffect` firing after every render, plus theme-subscriber
15
+ * bookkeeping) for a feature that is off unless `variant="gradient"`. On web the
16
+ * theme was never needed: token → `var(--token)` is a pure string transform
17
+ * (see `theme-color-web.ts`).
10
18
  */
11
- import { useTheme } from "@knitui/core";
12
-
13
19
  import type { GradientResult, GradientValue } from "./gradient-shared";
14
20
  import { gradientToCss } from "./gradient-shared";
15
21
 
16
22
  export type { GradientStop, GradientValue } from "./gradient-shared";
17
23
 
24
+ /**
25
+ * The no-gradient result, shared and frozen so the (overwhelmingly common)
26
+ * off-path allocates nothing and keeps a stable `frameProps` identity across
27
+ * renders — a fresh `{}` per render would defeat downstream prop memoisation.
28
+ */
29
+ const EMPTY_GRADIENT: GradientResult = Object.freeze({
30
+ frameProps: Object.freeze({}),
31
+ layer: null,
32
+ });
33
+
18
34
  export const useGradient = (gradient: GradientValue | undefined): GradientResult => {
19
- const theme = useTheme();
20
- if (!gradient) return { frameProps: {}, layer: null };
21
- return { frameProps: { backgroundImage: gradientToCss(theme, gradient) }, layer: null };
35
+ if (!gradient) return EMPTY_GRADIENT;
36
+ return { frameProps: { backgroundImage: gradientToCss(gradient) }, layer: null };
22
37
  };
@@ -29,19 +29,47 @@ const isTextNode = (child: React.ReactNode): child is string | number =>
29
29
  * `ListItemLabel`, the primitive `Text`, …) so each component keeps its styling.
30
30
  * Typed precisely — `Wrapper` only needs to accept `children`; styled components
31
31
  * (whose other props are all optional) satisfy this without a cast.
32
+ *
33
+ * ## Cost
34
+ *
35
+ * This runs at ~28 call sites on every render, so the single-child shapes are
36
+ * answered BEFORE `React.Children.toArray`. `toArray` flattens *and clones every
37
+ * element child* (re-escaping keys) — and cases (1)/(2) then throw that clone
38
+ * away, so for a `<Center>` / `<Modal.Body>` / `<Card>` holding elements it was
39
+ * pure waste every render, while for the common single-string case it allocated
40
+ * an array to learn what `typeof children === "string"` already says. Only the
41
+ * genuinely-multi-child shapes now reach `toArray`, and the case detection there
42
+ * is one pass rather than `some` + `every`.
32
43
  */
33
44
  export function renderTextChild(
34
45
  children: React.ReactNode,
35
46
  Wrapper: React.ComponentType<{ children: React.ReactNode }>,
36
47
  ): React.ReactNode {
48
+ // ---- Fast paths: the single-child shapes, decided without allocating. ----
49
+ const type = typeof children;
50
+ // (1) A lone string/number — by far the most common shape ("Save").
51
+ if (type === "string" || type === "number") return <Wrapper>{children}</Wrapper>;
52
+ // (2) Nothing renderable, or a single element (including a Fragment, which
53
+ // `toArray` does NOT flatten) → pass through untouched, exactly as the array
54
+ // path's "no text at all" branch did.
55
+ if (children == null || type === "boolean" || React.isValidElement(children)) return children;
56
+
57
+ // ---- Multi-child (arrays, iterables): flatten once, then classify. ----
37
58
  const array = React.Children.toArray(children);
38
59
 
60
+ let hasText = false;
61
+ let hasOther = false;
62
+ for (let i = 0; i < array.length; i++) {
63
+ if (isTextNode(array[i])) hasText = true;
64
+ else hasOther = true;
65
+ }
66
+
39
67
  // (2) No text at all → pass elements through untouched.
40
- if (!array.some(isTextNode)) return children;
68
+ if (!hasText) return children;
41
69
 
42
70
  // (1) Entirely text/number → wrap once, preserving the original `children`
43
71
  // (and any inline run) verbatim.
44
- if (array.every(isTextNode)) return <Wrapper>{children}</Wrapper>;
72
+ if (!hasOther) return <Wrapper>{children}</Wrapper>;
45
73
 
46
74
  // (3) Mixed → wrap each contiguous text run; keep elements as siblings.
47
75
  const out: React.ReactNode[] = [];
@@ -479,9 +479,17 @@ export const webCursorStyle = <T extends string>(cursor: T): { cursor: T } | und
479
479
  * doesn't submit an enclosing form), gated to web — a no-op `{}` on native, where
480
480
  * there's no button host and outline-based focus rings don't apply anyway. Spread
481
481
  * onto the frame: `<Frame {...webButton()} />`. Mirrors `webCursor`'s web-gating.
482
+ *
483
+ * `isWeb` is a BUILD-time constant, so the result is one of two invariant objects
484
+ * — {@link WEB_BUTTON_PROPS}. It used to be freshly allocated on every render of
485
+ * every button-like control; prefer spreading the constant directly. Frozen
486
+ * because it is shared: callers spread it (`{...WEB_BUTTON_PROPS}`), never mutate it.
482
487
  */
483
- export const webButton = (): { render?: "button"; type?: string } =>
484
- isWeb ? { render: "button", type: "button" } : {};
488
+ export const WEB_BUTTON_PROPS: { render?: "button"; type?: string } = Object.freeze(
489
+ isWeb ? { render: "button" as const, type: "button" } : {},
490
+ );
491
+
492
+ export const webButton = (): { render?: "button"; type?: string } => WEB_BUTTON_PROPS;
485
493
 
486
494
  /**
487
495
  * Web-only reset for the native `<button>` user-agent `text-align: center`.
@@ -496,9 +504,17 @@ export const webButton = (): { render?: "button"; type?: string } =>
496
504
  * still wins. Mirrors {@link webButton} / {@link webCursorStyle} web-gating; pair
497
505
  * the two on any pressable that renders a real `<button>` and hosts text content
498
506
  * (e.g. `UnstyledButton`), so web text matches native's start-aligned default.
507
+ *
508
+ * Also build-time invariant, so it is the module constant
509
+ * {@link WEB_BUTTON_TEXT_RESET} rather than a per-render object — a fresh object
510
+ * (and, worse, the fresh `[reset, style]` array around it) invalidates Tamagui's
511
+ * style cache on every render. Frozen: it is only ever read.
499
512
  */
500
- export const webButtonTextReset = (): { textAlign: "left" } | undefined =>
501
- isWeb ? { textAlign: "left" } : undefined;
513
+ export const WEB_BUTTON_TEXT_RESET: { textAlign: "left" } | undefined = isWeb
514
+ ? Object.freeze({ textAlign: "left" as const })
515
+ : undefined;
516
+
517
+ export const webButtonTextReset = (): { textAlign: "left" } | undefined => WEB_BUTTON_TEXT_RESET;
502
518
 
503
519
  /**
504
520
  * Mantine's `direction` (flex main-axis) cannot be a styled variant: Tamagui
@@ -0,0 +1,40 @@
1
+ import { createCSSVariable } from "@knitui/core";
2
+
3
+ /**
4
+ * WEB-ONLY, theme-free colour-token resolution.
5
+ *
6
+ * `resolveThemeColor(theme, color)` needs a theme object because on NATIVE a
7
+ * `$token` has to be read out of the active theme to get a concrete colour
8
+ * string. On WEB it does not: Tamagui's `variableToString` returns
9
+ * `variable.variable` — the token's CSS custom property — for every theme
10
+ * variable, and that property name is a pure function of the token key
11
+ * (`createCSSVariable("color5") === "var(--color5)"`). So the whole lookup
12
+ * collapses to a string transform with no theme access at all.
13
+ *
14
+ * That matters because `useTheme()` is not free: it runs `useThemeWithState`
15
+ * (useId + useRef + useReducer + a DEP-LESS `useEffect` that fires after every
16
+ * render) and registers the component as a theme change subscriber. Call sites
17
+ * that only ever needed the token→`var()` mapping (the gradient painter, the
18
+ * control-icon provider) were paying that on every render of every control,
19
+ * including when the feature was switched off.
20
+ *
21
+ * Divergence from the theme-based path, deliberate: a `$name` that is NOT a key
22
+ * of the active theme used to pass through verbatim (`"$nope"`), and now becomes
23
+ * `var(--nope)`. Both are broken CSS — an undefined custom property and a
24
+ * literal `$nope` are equally unpaintable — so no real value changes. Every
25
+ * `$token` the kit itself passes (`$color1`…`$color12`, `$white`, `$blueN`,
26
+ * `$redN`, `$accentN`, `$borderColor`, …) IS a theme key and resolves identically.
27
+ *
28
+ * Non-token values (`"#ff0000"`, `"rgb(…)"`, `"currentColor"`) pass through.
29
+ */
30
+ const cache = new Map<string, string>();
31
+
32
+ export const themeColorToCssVar = (color: string): string => {
33
+ // 36 === "$". A bare "$" has no token name, so it is not a token either.
34
+ if (color.charCodeAt(0) !== 36 || color.length < 2) return color;
35
+ const hit = cache.get(color);
36
+ if (hit !== undefined) return hit;
37
+ const resolved = createCSSVariable(color.slice(1));
38
+ cache.set(color, resolved);
39
+ return resolved;
40
+ };
@@ -0,0 +1,17 @@
1
+ import { useTheme } from "@knitui/core";
2
+
3
+ import { resolveThemeColor } from "./resolve-theme-color";
4
+
5
+ /**
6
+ * Resolve a control's icon colour token — NATIVE implementation (overrides the
7
+ * web `use-icon-color.ts`).
8
+ *
9
+ * `react-native-svg` cannot paint `$colorN`, so the concrete value genuinely has
10
+ * to be read out of the active theme, and the component genuinely has to be a
11
+ * theme subscriber so it repaints on a theme change. On web none of that is
12
+ * needed — see the web twin for why that split exists.
13
+ */
14
+ export const useIconColor = (token: string): string => {
15
+ const theme = useTheme();
16
+ return resolveThemeColor(theme, token);
17
+ };