chiplet 0.3.0 → 0.5.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 (316) hide show
  1. package/README.md +2 -5
  2. package/dist/assets/positioning.css.ts.vanilla-BLJ90UCF.css +60 -0
  3. package/dist/component/button/Button.js +5 -5
  4. package/dist/component/button/Button.js.map +1 -1
  5. package/dist/component/button/IconButton.js +1 -1
  6. package/dist/component/button/IconButton.js.map +1 -1
  7. package/dist/component/button/Interactive.js +2 -17
  8. package/dist/component/button/Interactive.js.map +1 -1
  9. package/dist/component/button/LinkButton.js +7 -5
  10. package/dist/component/button/LinkButton.js.map +1 -1
  11. package/dist/component/button/index.js +1 -0
  12. package/dist/component/button/index.js.map +1 -1
  13. package/dist/component/button/style/{index.css.vanilla.js → index.css.js} +5 -5
  14. package/dist/component/button/style/index.css.js.map +1 -0
  15. package/dist/component/checkbox/Checkbox.js +9 -19
  16. package/dist/component/checkbox/Checkbox.js.map +1 -1
  17. package/dist/component/checkbox/CheckboxGroup.js +2 -17
  18. package/dist/component/checkbox/CheckboxGroup.js.map +1 -1
  19. package/dist/component/checkbox/Radio.js +7 -18
  20. package/dist/component/checkbox/Radio.js.map +1 -1
  21. package/dist/component/checkbox/RadioGroup.js +2 -17
  22. package/dist/component/checkbox/RadioGroup.js.map +1 -1
  23. package/dist/component/checkbox/Switch.js +2 -2
  24. package/dist/component/checkbox/Switch.js.map +1 -1
  25. package/dist/component/checkbox/icon/index.js +0 -29
  26. package/dist/component/checkbox/icon/index.js.map +1 -1
  27. package/dist/component/checkbox/style/{index.css.vanilla.js → index.css.js} +4 -5
  28. package/dist/component/checkbox/style/index.css.js.map +1 -0
  29. package/dist/component/header/Header.js +2 -2
  30. package/dist/component/header/Header.js.map +1 -1
  31. package/dist/component/header/style/index.css.js +7 -0
  32. package/dist/component/header/style/index.css.js.map +1 -0
  33. package/dist/component/index.js +21 -19
  34. package/dist/component/index.js.map +1 -1
  35. package/dist/component/input/Input.js +7 -18
  36. package/dist/component/input/Input.js.map +1 -1
  37. package/dist/component/input/SearchInput.js +7 -13
  38. package/dist/component/input/SearchInput.js.map +1 -1
  39. package/dist/component/input/style/{index.css.vanilla.js → index.css.js} +5 -5
  40. package/dist/component/input/style/index.css.js.map +1 -0
  41. package/dist/component/menu/Menu.js +2 -28
  42. package/dist/component/menu/Menu.js.map +1 -1
  43. package/dist/component/menu/MenuButton.js +1 -3
  44. package/dist/component/menu/MenuButton.js.map +1 -1
  45. package/dist/component/menu/MenuItem.js +2 -18
  46. package/dist/component/menu/MenuItem.js.map +1 -1
  47. package/dist/component/menu/MenuItemCheckbox.js +4 -31
  48. package/dist/component/menu/MenuItemCheckbox.js.map +1 -1
  49. package/dist/component/menu/MenuItemRadio.js +5 -32
  50. package/dist/component/menu/MenuItemRadio.js.map +1 -1
  51. package/dist/component/menu/renderMenuItem.js +6 -2
  52. package/dist/component/menu/renderMenuItem.js.map +1 -1
  53. package/dist/component/popover/Dialog.js +2 -17
  54. package/dist/component/popover/Dialog.js.map +1 -1
  55. package/dist/component/popover/DismissButton.js +2 -19
  56. package/dist/component/popover/DismissButton.js.map +1 -1
  57. package/dist/component/popover/Popover.js +2 -17
  58. package/dist/component/popover/Popover.js.map +1 -1
  59. package/dist/component/popover/ShadowRoot.js +34 -0
  60. package/dist/component/popover/ShadowRoot.js.map +1 -0
  61. package/dist/component/popover/Tooltip.js +4 -18
  62. package/dist/component/popover/Tooltip.js.map +1 -1
  63. package/dist/component/popover/index.js +1 -0
  64. package/dist/component/popover/index.js.map +1 -1
  65. package/dist/component/popover/style/{index.css.vanilla.js → index.css.js} +5 -5
  66. package/dist/component/popover/style/index.css.js.map +1 -0
  67. package/dist/component/progress/Spinner.js +1 -1
  68. package/dist/component/progress/style/{index.css.vanilla.js → index.css.js} +4 -5
  69. package/dist/component/progress/style/index.css.js.map +1 -0
  70. package/dist/component/select/AutoComplete.js +7 -30
  71. package/dist/component/select/AutoComplete.js.map +1 -1
  72. package/dist/component/select/Group.js +3 -18
  73. package/dist/component/select/Group.js.map +1 -1
  74. package/dist/component/select/Option.js +7 -22
  75. package/dist/component/select/Option.js.map +1 -1
  76. package/dist/component/select/Select.js +6 -29
  77. package/dist/component/select/Select.js.map +1 -1
  78. package/dist/component/select/Separator.js +1 -1
  79. package/dist/component/select/style/{index.css.vanilla.js → index.css.js} +5 -5
  80. package/dist/component/select/style/index.css.js.map +1 -0
  81. package/dist/component/style/article.css.js +6 -0
  82. package/dist/component/style/article.css.js.map +1 -0
  83. package/dist/component/style/index.js +1 -1
  84. package/dist/component/typography/Body1.js +1 -1
  85. package/dist/component/typography/Body2.js +1 -1
  86. package/dist/component/typography/Body3.js +1 -1
  87. package/dist/component/typography/Caption1.js +1 -1
  88. package/dist/component/typography/Caption2.js +1 -1
  89. package/dist/component/typography/Heading1.js +1 -1
  90. package/dist/component/typography/Heading2.js +1 -1
  91. package/dist/component/typography/Heading3.js +1 -1
  92. package/dist/component/typography/Heading4.js +1 -1
  93. package/dist/component/typography/style/{index.css.vanilla.js → index.css.js} +4 -5
  94. package/dist/component/typography/style/index.css.js.map +1 -0
  95. package/dist/hook/accessibility/keyboard/Keyboard.js +6 -18
  96. package/dist/hook/accessibility/keyboard/Keyboard.js.map +1 -1
  97. package/dist/hook/accessibility/keyboard/Roving.js +0 -15
  98. package/dist/hook/accessibility/keyboard/Roving.js.map +1 -1
  99. package/dist/hook/accessibility/keyboard/context/index.js.map +1 -1
  100. package/dist/hook/accessibility/keyboard/hook/useLastFocused.js +1 -4
  101. package/dist/hook/accessibility/keyboard/hook/useLastFocused.js.map +1 -1
  102. package/dist/hook/accessibility/keyboard/hook/useNavigate.js.map +1 -1
  103. package/dist/hook/accessibility/keyboard/resolve.js +1 -4
  104. package/dist/hook/accessibility/keyboard/resolve.js.map +1 -1
  105. package/dist/hook/accessibility/keyboard/sort.js +0 -3
  106. package/dist/hook/accessibility/keyboard/sort.js.map +1 -1
  107. package/dist/hook/accessibility/keyboard/tree.js +1 -4
  108. package/dist/hook/accessibility/keyboard/tree.js.map +1 -1
  109. package/dist/hook/accessibility/keyboard/useController.js +2 -15
  110. package/dist/hook/accessibility/keyboard/useController.js.map +1 -1
  111. package/dist/hook/accessibility/keyboard/useKeyboard.js +2 -16
  112. package/dist/hook/accessibility/keyboard/useKeyboard.js.map +1 -1
  113. package/dist/hook/document/useHighlight.js +1 -6
  114. package/dist/hook/document/useHighlight.js.map +1 -1
  115. package/dist/hook/form/context/index.js.map +1 -1
  116. package/dist/hook/form/useAutoComplete.js +2 -16
  117. package/dist/hook/form/useAutoComplete.js.map +1 -1
  118. package/dist/hook/form/useChange.js.map +1 -1
  119. package/dist/hook/form/useCheckbox.js +0 -16
  120. package/dist/hook/form/useCheckbox.js.map +1 -1
  121. package/dist/hook/form/useChecked.js +1 -14
  122. package/dist/hook/form/useChecked.js.map +1 -1
  123. package/dist/hook/form/useForm.js +1 -15
  124. package/dist/hook/form/useForm.js.map +1 -1
  125. package/dist/hook/form/useGroup.js +18 -30
  126. package/dist/hook/form/useGroup.js.map +1 -1
  127. package/dist/hook/form/useName.js.map +1 -1
  128. package/dist/hook/form/useOption.js +0 -16
  129. package/dist/hook/form/useOption.js.map +1 -1
  130. package/dist/hook/form/useRadio.js +0 -16
  131. package/dist/hook/form/useRadio.js.map +1 -1
  132. package/dist/hook/form/useSelect.js +0 -16
  133. package/dist/hook/form/useSelect.js.map +1 -1
  134. package/dist/hook/form/useValue.js +0 -15
  135. package/dist/hook/form/useValue.js.map +1 -1
  136. package/dist/hook/index.js +22 -21
  137. package/dist/hook/index.js.map +1 -1
  138. package/dist/hook/observable/useObservable.js +6 -1
  139. package/dist/hook/observable/useObservable.js.map +1 -1
  140. package/dist/hook/popover/context/index.js.map +1 -1
  141. package/dist/hook/popover/index.js +2 -1
  142. package/dist/hook/popover/index.js.map +1 -1
  143. package/dist/hook/popover/style/positioning.css.js +13 -0
  144. package/dist/hook/popover/style/positioning.css.js.map +1 -0
  145. package/dist/hook/popover/useAnchorPositioning.js +6 -88
  146. package/dist/hook/popover/useAnchorPositioning.js.map +1 -1
  147. package/dist/hook/popover/useDialog.js +1 -15
  148. package/dist/hook/popover/useDialog.js.map +1 -1
  149. package/dist/hook/popover/useLightDismiss.js +16 -4
  150. package/dist/hook/popover/useLightDismiss.js.map +1 -1
  151. package/dist/hook/popover/useOverlay.js +8 -20
  152. package/dist/hook/popover/useOverlay.js.map +1 -1
  153. package/dist/hook/popover/usePopover.js +12 -23
  154. package/dist/hook/popover/usePopover.js.map +1 -1
  155. package/dist/hook/popover/usePositioning.js +10 -16
  156. package/dist/hook/popover/usePositioning.js.map +1 -1
  157. package/dist/hook/popover/useReturnFocus.js.map +1 -1
  158. package/dist/hook/popover/useTooltip.js +4 -15
  159. package/dist/hook/popover/useTooltip.js.map +1 -1
  160. package/dist/hook/promise/usePromise.js +1 -1
  161. package/dist/hook/promise/usePromise.js.map +1 -1
  162. package/dist/hook/react/refValue.js +0 -3
  163. package/dist/hook/react/refValue.js.map +1 -1
  164. package/dist/hook/react/useActivate.js +4 -4
  165. package/dist/hook/react/useActivate.js.map +1 -1
  166. package/dist/hook/react/useConst.js +3 -2
  167. package/dist/hook/react/useConst.js.map +1 -1
  168. package/dist/hook/react/useInteractive.js +1 -4
  169. package/dist/hook/react/useInteractive.js.map +1 -1
  170. package/dist/hook/react/useRefCallback.js.map +1 -1
  171. package/dist/hook/react/useUniqueId.js +1 -4
  172. package/dist/hook/react/useUniqueId.js.map +1 -1
  173. package/dist/index.js +112 -109
  174. package/dist/index.js.map +1 -1
  175. package/dist/infra/index.js +1 -1
  176. package/dist/infra/logging/logger.js +13 -10
  177. package/dist/infra/logging/logger.js.map +1 -1
  178. package/dist/theme/defineTheme.js +0 -3
  179. package/dist/theme/defineTheme.js.map +1 -1
  180. package/dist/theme/{global.css.vanilla.js → global.css.js} +4 -4
  181. package/dist/theme/global.css.js.map +1 -0
  182. package/dist/theme/index.js +5 -3
  183. package/dist/theme/index.js.map +1 -1
  184. package/dist/theme/{theme.css.vanilla.js → theme.css.js} +3 -3
  185. package/dist/theme/theme.css.js.map +1 -0
  186. package/dist/theme/{token.css.vanilla.js → token.css.js} +2 -2
  187. package/dist/theme/token.css.js.map +1 -0
  188. package/dist/theme/useSystemColorScheme.js +16 -16
  189. package/dist/theme/useSystemColorScheme.js.map +1 -1
  190. package/dist/util/array/index.js +0 -1
  191. package/dist/util/array/index.js.map +1 -1
  192. package/dist/util/document/{accessibility.css.vanilla.js → accessibility.css.js} +1 -1
  193. package/dist/util/document/accessibility.css.js.map +1 -0
  194. package/dist/util/document/index.js +1 -1
  195. package/dist/util/file/readAsDataURL.js +15 -4
  196. package/dist/util/file/readAsDataURL.js.map +1 -1
  197. package/dist/util/index.js +28 -30
  198. package/dist/util/index.js.map +1 -1
  199. package/dist/util/linked-list/buildLinkedList.js.map +1 -1
  200. package/dist/util/lock/lock.js +0 -2
  201. package/dist/util/lock/lock.js.map +1 -1
  202. package/dist/util/random/index.js +0 -1
  203. package/dist/util/random/index.js.map +1 -1
  204. package/dist/util/tree/addTreeNode.js.map +1 -1
  205. package/dist/util/tree/attachChild.js +7 -1
  206. package/dist/util/tree/attachChild.js.map +1 -1
  207. package/dist/util/tree/buildTree.js.map +1 -1
  208. package/dist/util/tree/detachChild.js +3 -0
  209. package/dist/util/tree/detachChild.js.map +1 -1
  210. package/dist/util/tree/iterateChildren.js.map +1 -1
  211. package/dist/util/tree/iterateTree.js.map +1 -1
  212. package/package.json +49 -47
  213. package/src/component/button/Button.tsx +4 -5
  214. package/src/component/button/IconButton.tsx +1 -1
  215. package/src/component/button/LinkButton.tsx +14 -6
  216. package/src/component/button/index.ts +1 -0
  217. package/src/component/checkbox/Checkbox.tsx +8 -1
  218. package/src/component/checkbox/Radio.tsx +5 -1
  219. package/src/component/checkbox/Switch.tsx +1 -1
  220. package/src/component/checkbox/icon/index.ts +1 -1
  221. package/src/component/header/Header.tsx +1 -1
  222. package/src/component/input/Input.tsx +5 -1
  223. package/src/component/input/SearchInput.tsx +10 -9
  224. package/src/component/menu/Menu.tsx +1 -1
  225. package/src/component/menu/MenuItemCheckbox.tsx +1 -1
  226. package/src/component/menu/MenuItemRadio.tsx +1 -1
  227. package/src/component/menu/renderMenuItem.tsx +5 -1
  228. package/src/component/popover/ShadowRoot.tsx +42 -0
  229. package/src/component/popover/Tooltip.tsx +2 -2
  230. package/src/component/popover/index.ts +1 -0
  231. package/src/component/select/AutoComplete.tsx +3 -7
  232. package/src/component/select/Group.tsx +1 -1
  233. package/src/component/select/Option.tsx +1 -1
  234. package/src/component/select/Select.tsx +3 -7
  235. package/src/hook/accessibility/keyboard/Keyboard.tsx +1 -1
  236. package/src/hook/accessibility/keyboard/Roving.tsx +1 -1
  237. package/src/hook/accessibility/keyboard/context/index.ts +2 -2
  238. package/src/hook/accessibility/keyboard/hook/useLastFocused.ts +7 -1
  239. package/src/hook/accessibility/keyboard/hook/useNavigate.ts +1 -1
  240. package/src/hook/accessibility/keyboard/resolve.ts +1 -1
  241. package/src/hook/accessibility/keyboard/useController.ts +3 -2
  242. package/src/hook/accessibility/keyboard/useKeyboard.ts +3 -2
  243. package/src/hook/document/useHighlight.ts +5 -4
  244. package/src/hook/form/context/index.ts +1 -1
  245. package/src/hook/form/useAutoComplete.ts +14 -14
  246. package/src/hook/form/useChange.ts +1 -1
  247. package/src/hook/form/useCheckbox.ts +2 -2
  248. package/src/hook/form/useChecked.ts +3 -2
  249. package/src/hook/form/useForm.ts +1 -1
  250. package/src/hook/form/useGroup.ts +20 -21
  251. package/src/hook/form/useName.ts +1 -1
  252. package/src/hook/form/useOption.ts +2 -2
  253. package/src/hook/form/useRadio.ts +2 -2
  254. package/src/hook/form/useSelect.ts +15 -12
  255. package/src/hook/form/useValue.ts +3 -2
  256. package/src/hook/observable/useObservable.ts +14 -1
  257. package/src/hook/popover/context/index.ts +1 -1
  258. package/src/hook/popover/style/positioning.css.ts +112 -0
  259. package/src/hook/popover/useAnchorPositioning.ts +16 -105
  260. package/src/hook/popover/useDialog.ts +5 -4
  261. package/src/hook/popover/useLightDismiss.ts +27 -0
  262. package/src/hook/popover/useOverlay.ts +17 -8
  263. package/src/hook/popover/usePopover.ts +22 -24
  264. package/src/hook/popover/usePositioning.ts +17 -20
  265. package/src/hook/popover/useReturnFocus.ts +12 -3
  266. package/src/hook/popover/useTooltip.ts +10 -9
  267. package/src/hook/promise/usePromise.ts +4 -1
  268. package/src/hook/react/useActivate.ts +8 -1
  269. package/src/hook/react/useConst.ts +3 -3
  270. package/src/hook/react/useRefCallback.ts +3 -1
  271. package/src/infra/logging/logger.ts +43 -19
  272. package/src/theme/global.css.ts +1 -28
  273. package/src/theme/index.ts +4 -0
  274. package/src/theme/useSystemColorScheme.ts +22 -20
  275. package/src/util/array/index.ts +0 -1
  276. package/src/util/document/accessibility.css.ts +1 -1
  277. package/src/util/file/readAsDataURL.ts +17 -4
  278. package/src/util/linked-list/buildLinkedList.ts +1 -1
  279. package/src/util/number/index.ts +2 -0
  280. package/src/util/random/index.ts +4 -1
  281. package/src/util/tree/addTreeNode.ts +1 -1
  282. package/src/util/tree/attachChild.ts +13 -2
  283. package/src/util/tree/buildTree.ts +1 -1
  284. package/src/util/tree/detachChild.ts +7 -1
  285. package/src/util/tree/iterateChildren.ts +1 -1
  286. package/src/util/tree/iterateTree.ts +1 -1
  287. package/dist/component/button/style/index.css.vanilla.js.map +0 -1
  288. package/dist/component/checkbox/style/index.css.vanilla.js.map +0 -1
  289. package/dist/component/header/style/index.css.vanilla.js +0 -7
  290. package/dist/component/header/style/index.css.vanilla.js.map +0 -1
  291. package/dist/component/input/style/index.css.vanilla.js.map +0 -1
  292. package/dist/component/popover/style/index.css.vanilla.js.map +0 -1
  293. package/dist/component/progress/style/index.css.vanilla.js.map +0 -1
  294. package/dist/component/select/style/index.css.vanilla.js.map +0 -1
  295. package/dist/component/style/article.css.vanilla.js +0 -6
  296. package/dist/component/style/article.css.vanilla.js.map +0 -1
  297. package/dist/component/typography/style/index.css.vanilla.js.map +0 -1
  298. package/dist/theme/global.css.vanilla.js.map +0 -1
  299. package/dist/theme/theme.css.vanilla.js.map +0 -1
  300. package/dist/theme/token.css.vanilla.js.map +0 -1
  301. package/dist/util/array/fromAsync.js +0 -11
  302. package/dist/util/array/fromAsync.js.map +0 -1
  303. package/dist/util/document/accessibility.css.vanilla.js.map +0 -1
  304. package/src/util/array/fromAsync.ts +0 -11
  305. /package/dist/{article.css → assets/article.css.ts.vanilla-s_HEpsy3.css} +0 -0
  306. /package/dist/{global.css → assets/global.css.ts.vanilla-CTwjHiaM.css} +0 -0
  307. /package/dist/{index8.css → assets/index.css.ts.vanilla-9qGDrdgn.css} +0 -0
  308. /package/dist/{index6.css → assets/index.css.ts.vanilla-BsBngo8U.css} +0 -0
  309. /package/dist/{index2.css → assets/index.css.ts.vanilla-CVNLkHc9.css} +0 -0
  310. /package/dist/{index3.css → assets/index.css.ts.vanilla-C_RzxiYH.css} +0 -0
  311. /package/dist/{index5.css → assets/index.css.ts.vanilla-CvQQLJ-M.css} +0 -0
  312. /package/dist/{index.css → assets/index.css.ts.vanilla-DGmHFJbF.css} +0 -0
  313. /package/dist/{index4.css → assets/index.css.ts.vanilla-VHSAjLub.css} +0 -0
  314. /package/dist/{index7.css → assets/index.css.ts.vanilla-kgyRRvgH.css} +0 -0
  315. /package/dist/{theme.css → assets/theme.css.ts.vanilla-Bjn8sb_B.css} +0 -0
  316. /package/dist/{token.css → assets/token.css.ts.vanilla-B3LtFaO7.css} +0 -0
@@ -2,8 +2,8 @@ import type { ChangeCallback } from '#hook'
2
2
  import { isEnterKey } from '#util'
3
3
  import clsx from 'clsx'
4
4
  import { useCallback } from 'react'
5
- import { Input, type InputProps } from '.'
6
5
  import { Search24Regular } from '../icon'
6
+ import { Input, type InputProps } from './Input'
7
7
  import { InputBeforeStyle, SearchInputBeforeStyle } from './style/index.css'
8
8
 
9
9
  export interface SearchInputProps extends InputProps {
@@ -12,7 +12,7 @@ export interface SearchInputProps extends InputProps {
12
12
  }
13
13
 
14
14
  export function SearchInput(props: SearchInputProps) {
15
- const { onSearch, ...attrs } = props
15
+ const { onSearch, onKeyDown, ...attrs } = props
16
16
 
17
17
  attrs.role ||= 'searchbox'
18
18
 
@@ -24,20 +24,21 @@ export function SearchInput(props: SearchInputProps) {
24
24
  )
25
25
  }
26
26
 
27
- const { onKeyDown } = attrs
28
-
29
- attrs.onKeyDown = useCallback<NonNullable<typeof onKeyDown>>(
30
- // eslint-disable-next-line react-hooks/preserve-manual-memoization
27
+ const handleKeyDown = useCallback<NonNullable<typeof onKeyDown>>(
31
28
  (ev) => {
32
29
  onKeyDown?.(ev)
33
30
 
34
- if (!ev.defaultPrevented && isEnterKey(ev)) {
31
+ // Ignore the 'Enter' key that confirms an in-progress IME composition.
32
+ if (
33
+ !ev.defaultPrevented &&
34
+ isEnterKey(ev) &&
35
+ !ev.nativeEvent.isComposing
36
+ ) {
35
37
  onSearch?.(ev, ev.currentTarget.value)
36
38
  }
37
39
  },
38
- // eslint-disable-next-line react-hooks/preserve-manual-memoization
39
40
  [onKeyDown, onSearch]
40
41
  )
41
42
 
42
- return <Input {...attrs} />
43
+ return <Input {...attrs} onKeyDown={handleKeyDown} />
43
44
  }
@@ -1,6 +1,6 @@
1
- import { type PopoverProps, Popover } from '#component'
2
1
  import { useForm } from '#hook'
3
2
  import clsx from 'clsx'
3
+ import { Popover, type PopoverProps } from '../popover/Popover'
4
4
  import { ListStyle } from '../select/style/index.css'
5
5
 
6
6
  export function Menu(props: PopoverProps<'ul'>) {
@@ -1,5 +1,5 @@
1
- import { Checkmark24Regular } from '#component'
2
1
  import { useChange, useCheckbox, useInteractive, useKeyboard } from '#hook'
2
+ import { Checkmark24Regular } from '../icon'
3
3
  import { ItemIconStyle } from '../select/style/index.css'
4
4
  import { renderMenuItem, type MenuItemProps } from './renderMenuItem'
5
5
 
@@ -1,4 +1,3 @@
1
- import { Checkmark24Regular } from '#component'
2
1
  import {
3
2
  useChange,
4
3
  useClose,
@@ -6,6 +5,7 @@ import {
6
5
  useKeyboard,
7
6
  useRadio,
8
7
  } from '#hook'
8
+ import { Checkmark24Regular } from '../icon'
9
9
  import { ItemIconStyle } from '../select/style/index.css'
10
10
  import { renderMenuItem, type MenuItemProps } from './renderMenuItem'
11
11
 
@@ -30,7 +30,11 @@ export function renderMenuItem(props: MenuItemProps) {
30
30
  <li
31
31
  {...slot?.root}
32
32
  {...attrs}
33
- className={clsx(ItemStyle({ danger }), attrs.className)}
33
+ className={clsx(
34
+ ItemStyle({ danger }),
35
+ slot?.root?.className,
36
+ attrs.className
37
+ )}
34
38
  >
35
39
  <div
36
40
  {...slot?.before}
@@ -0,0 +1,42 @@
1
+ import { useIsomorphicLayoutEffect, useRefObject } from '#hook'
2
+ import { useRef } from 'react'
3
+ import { type Root, createRoot } from 'react-dom/client'
4
+
5
+ export interface ShadowRootProps extends React.ComponentProps<'div'> {
6
+ delegatesFocus?: boolean | undefined
7
+ }
8
+
9
+ export function ShadowRoot(props: ShadowRootProps) {
10
+ const { children, delegatesFocus = false, ref, ...attrs } = props
11
+ const hostRef = useRefObject<HTMLDivElement>(ref)
12
+ const nestedRootRef = useRef<Root | null>(null)
13
+
14
+ useIsomorphicLayoutEffect(() => {
15
+ const host = hostRef.current
16
+
17
+ /* istanbul ignore next */
18
+ if (host === null) {
19
+ return
20
+ }
21
+
22
+ const shadowRoot =
23
+ host.shadowRoot ??
24
+ host.attachShadow({
25
+ mode: 'open',
26
+ delegatesFocus,
27
+ })
28
+ const nestedRoot = nestedRootRef.current ?? createRoot(shadowRoot)
29
+
30
+ nestedRootRef.current = nestedRoot
31
+
32
+ return () => {
33
+ nestedRoot.render(null)
34
+ }
35
+ }, [delegatesFocus, hostRef])
36
+
37
+ useIsomorphicLayoutEffect(() => {
38
+ nestedRootRef.current?.render(children)
39
+ })
40
+
41
+ return <div {...attrs} ref={hostRef} />
42
+ }
@@ -1,5 +1,5 @@
1
1
  import {
2
- positionAxis,
2
+ positionAxisMap,
3
3
  useTooltip,
4
4
  type Overlay,
5
5
  type TooltipOptions,
@@ -38,7 +38,7 @@ export function Tooltip(props: TooltipProps) {
38
38
  <div
39
39
  {...tooltip.arrow.props}
40
40
  className={clsx(
41
- TooltipArrowStyle({ axis: positionAxis(tooltip.position) }),
41
+ TooltipArrowStyle({ axis: positionAxisMap[tooltip.position] }),
42
42
  tooltip.arrow.props.className
43
43
  )}
44
44
  />
@@ -2,4 +2,5 @@ export * from './Dialog'
2
2
  export * from './DismissButton'
3
3
  export * from './Popover'
4
4
  export * from './Portal'
5
+ export * from './ShadowRoot'
5
6
  export * from './Tooltip'
@@ -1,15 +1,11 @@
1
1
  'use client'
2
- import {
3
- ChevronDown24Regular,
4
- Input,
5
- Popover,
6
- type InputProps,
7
- type PopoverProps,
8
- } from '#component'
9
2
  import { FormContext, useAutoComplete, type AutoCompleteOptions } from '#hook'
10
3
  import { HighlightName } from '#theme'
11
4
  import clsx from 'clsx'
12
5
  import { useLayoutEffect, type JSX } from 'react'
6
+ import { ChevronDown24Regular } from '../icon'
7
+ import { Input, type InputProps } from '../input/Input'
8
+ import { Popover, type PopoverProps } from '../popover/Popover'
13
9
  import { InputAfterStyle } from '../input/style/index.css'
14
10
  import { Option } from './Option'
15
11
  import { ListStyle } from './style/index.css'
@@ -35,7 +35,7 @@ export function Group(props: GroupProps) {
35
35
  <li
36
36
  {...slot?.root}
37
37
  {...attrs}
38
- className={clsx(GroupStyle, attrs.className)}
38
+ className={clsx(GroupStyle, slot?.root?.className, attrs.className)}
39
39
  role='group'
40
40
  aria-labelledby={label != null ? labelProps.id : undefined}
41
41
  >
@@ -61,7 +61,7 @@ export function Option<T extends OptionValue>(props: OptionProps<T>) {
61
61
  <li
62
62
  {...slot?.root}
63
63
  {...attrs}
64
- className={clsx(ItemStyle(), attrs.className)}
64
+ className={clsx(ItemStyle(), slot?.root?.className, attrs.className)}
65
65
  role='option'
66
66
  value={value}
67
67
  aria-selected={selected}
@@ -1,10 +1,3 @@
1
- import {
2
- Button,
3
- ChevronDown24Regular,
4
- Popover,
5
- type ButtonProps,
6
- type PopoverProps,
7
- } from '#component'
8
1
  import {
9
2
  FormContext,
10
3
  useSelect,
@@ -13,6 +6,9 @@ import {
13
6
  } from '#hook'
14
7
  import clsx from 'clsx'
15
8
  import type { JSX } from 'react'
9
+ import { Popover, type PopoverProps } from '../popover/Popover'
10
+ import { Button, type ButtonProps } from '../button/Button'
11
+ import { ChevronDown24Regular } from '../icon'
16
12
  import { ButtonAfterStyle } from '../button/style/index.css'
17
13
  import { ListStyle } from '../select/style/index.css'
18
14
  import { Option } from './Option'
@@ -1,7 +1,7 @@
1
1
  'use client'
2
- import { useActivate, type ActivateCallback } from '#hook'
3
2
  import { useImperativeHandle, useMemo } from 'react'
4
3
  import invariant from 'tiny-invariant'
4
+ import { useActivate, type ActivateCallback } from '../../react/useActivate'
5
5
  import { KeyboardContext } from './context'
6
6
  import {
7
7
  useLastFocused,
@@ -1,5 +1,5 @@
1
1
  import type { HTMLElementType, JSX } from 'react'
2
- import { useKeyboard } from '.'
2
+ import { useKeyboard } from './useKeyboard'
3
3
 
4
4
  type Props<T extends HTMLElementType> = JSX.IntrinsicElements[T] & {
5
5
  elementType?: T
@@ -1,7 +1,7 @@
1
1
  'use client'
2
2
  import { createContext } from 'react'
3
- import type { Keyboard } from '..'
4
- import type { PoolAdd, PoolRemove } from '../hook'
3
+ import type { Keyboard } from '../Keyboard'
4
+ import type { PoolAdd, PoolRemove } from '../hook/usePool'
5
5
 
6
6
  export interface KeyboardContext extends Keyboard {
7
7
  lastActive: Element | null
@@ -1,6 +1,6 @@
1
1
  import { isARIAChecked, isARIASelected } from '#util'
2
2
  import { useLayoutEffect, useMemo, useRef } from 'react'
3
- import type { NavigationType } from '..'
3
+ import type { NavigationType } from '../Keyboard'
4
4
  import type { Tree } from '../tree'
5
5
 
6
6
  export function useLastFocused(
@@ -8,6 +8,12 @@ export function useLastFocused(
8
8
  tree: Tree,
9
9
  active: Element | null
10
10
  ) {
11
+ // The memoized context binding is deliberately reassigned: when 'active'
12
+ // is removed from the tree (or missing) the memo yields null or
13
+ // undefined, and the '??=' fallback below restores the last captured
14
+ // context from the ref. Reassigning the binding keeps the ref fallback
15
+ // out of the memo dependencies, which would otherwise propagate ref
16
+ // reads into every downstream memo.
11
17
  // eslint-disable-next-line react-hooks/preserve-manual-memoization
12
18
  let ctx = useMemo(
13
19
  () => (active ? tree.map.get(active)?.context : null),
@@ -1,5 +1,5 @@
1
1
  import { useCallback, useLayoutEffect, useRef } from 'react'
2
- import type { NavigationDirection, NavigationType } from '..'
2
+ import type { NavigationDirection, NavigationType } from '../Keyboard'
3
3
  import { resolve, type Parse } from '../resolve'
4
4
  import type { Tree } from '../tree'
5
5
  import type { MoveFocus } from './useMoveFocus'
@@ -10,7 +10,7 @@ import {
10
10
  } from '#util'
11
11
  import type { Pool } from './hook/usePool'
12
12
  import { Tree } from './tree'
13
- import type { NavigationDirection, NavigationType } from '.'
13
+ import type { NavigationDirection, NavigationType } from './Keyboard'
14
14
 
15
15
  const PAGE_SIZE = 10
16
16
 
@@ -1,5 +1,4 @@
1
1
  'use client'
2
- import { positionMap, type Overlay, type Position } from '#hook'
3
2
  import {
4
3
  isArrowDownKey,
5
4
  isArrowLeftKey,
@@ -8,7 +7,9 @@ import {
8
7
  } from '#util'
9
8
  import { getAlignment, getOppositePlacement, getSide } from '@floating-ui/utils'
10
9
  import { useCallback, useLayoutEffect, useRef } from 'react'
11
- import type { Keyboard, NavigationDirection } from '.'
10
+ import type { Overlay } from '../../popover/useOverlay'
11
+ import { positionMap, type Position } from '../../popover/style/positioning.css'
12
+ import type { Keyboard, NavigationDirection } from './Keyboard'
12
13
 
13
14
  interface Props extends React.AriaAttributes {
14
15
  disabled?: boolean | undefined
@@ -1,7 +1,8 @@
1
- import { useRefCallback, useUniqueId } from '#hook'
2
- import type { GlobalAttributes } from '#hook/react/element.d'
3
1
  import { VirtualActive, VirtualFocus } from '#util'
4
2
  import { use, useCallback } from 'react'
3
+ import type { GlobalAttributes } from '../../react/element.d'
4
+ import { useRefCallback } from '../../react/useRefCallback'
5
+ import { useUniqueId } from '../../react/useUniqueId'
5
6
  import { KeyboardContext } from './context'
6
7
 
7
8
  interface Props extends GlobalAttributes, React.RefAttributes<Element> {
@@ -1,6 +1,7 @@
1
1
  'use client'
2
2
  import { useCallback, useLayoutEffect, useState } from 'react'
3
- import { refValue, useRegExp, type RefValue } from '../react'
3
+ import { refValue, type RefValue } from '../react/refValue'
4
+ import { useRegExp } from '../react/useRegExp'
4
5
 
5
6
  export function useHighlight(
6
7
  pattern: string | undefined,
@@ -37,9 +38,9 @@ export function useHighlight(
37
38
 
38
39
  traverse(el)
39
40
 
40
- if (highlight.size > 0) {
41
- setHighlight(highlight)
42
- }
41
+ // Report an empty result as 'undefined' so a stale 'Highlight' with
42
+ // detached ranges is not kept around when the matches disappear.
43
+ setHighlight(highlight.size > 0 ? highlight : undefined)
43
44
  },
44
45
  [RE]
45
46
  )
@@ -1,6 +1,6 @@
1
1
  'use client'
2
- import type { ChangeCallback } from '#hook'
3
2
  import { createContext, type SetStateAction } from 'react'
3
+ import type { ChangeCallback } from '../useDefault'
4
4
 
5
5
  export interface FormContext<T> {
6
6
  name?: string | undefined
@@ -1,17 +1,4 @@
1
1
  'use client'
2
- import type {
3
- ChangeCallback,
4
- KeyboardOptions,
5
- KeyboardProps,
6
- NavigationDirection,
7
- OptionalChangeCallback,
8
- Overlay,
9
- PopoverOptions,
10
- PositioningOptions,
11
- ToggleCallback,
12
- } from '#hook'
13
- import { useHighlight, useRefObject, useRegExp } from '#hook'
14
- import type { GlobalAttributes } from '#hook/react/element.d'
15
2
  import { uniq } from 'lodash-es'
16
3
  import {
17
4
  useCallback,
@@ -21,7 +8,20 @@ import {
21
8
  useRef,
22
9
  useState,
23
10
  } from 'react'
24
- import { useGroup } from '.'
11
+ import type {
12
+ KeyboardOptions,
13
+ KeyboardProps,
14
+ NavigationDirection,
15
+ } from '../accessibility/keyboard/Keyboard'
16
+ import { useHighlight } from '../document/useHighlight'
17
+ import type { Overlay, ToggleCallback } from '../popover/useOverlay'
18
+ import type { PopoverOptions } from '../popover/usePopover'
19
+ import type { PositioningOptions } from '../popover/usePositioning'
20
+ import type { GlobalAttributes } from '../react/element.d'
21
+ import { useRefObject } from '../react/useRefObject'
22
+ import { useRegExp } from '../react/useRegExp'
23
+ import type { ChangeCallback, OptionalChangeCallback } from './useDefault'
24
+ import { useGroup } from './useGroup'
25
25
 
26
26
  type Option<T> = { value: T; label: string }
27
27
 
@@ -1,5 +1,5 @@
1
- import type { ChangeCallback } from '#hook'
2
1
  import { useCallback } from 'react'
2
+ import type { ChangeCallback } from './useDefault'
3
3
 
4
4
  interface Props {
5
5
  disabled?: boolean | undefined
@@ -1,5 +1,5 @@
1
- import type { ChangeCallback } from '#hook'
2
- import { useChecked } from '.'
1
+ import type { ChangeCallback } from './useDefault'
2
+ import { useChecked } from './useChecked'
3
3
 
4
4
  interface Props {
5
5
  name?: string | undefined
@@ -1,9 +1,10 @@
1
1
  'use client'
2
- import { useConst, type ChangeCallback } from '#hook'
3
2
  import { uniq, without } from 'lodash-es'
4
3
  import { useCallback, useLayoutEffect, useRef } from 'react'
5
4
  import invariant from 'tiny-invariant'
6
- import { useName } from '.'
5
+ import { useConst } from '../react/useConst'
6
+ import type { ChangeCallback } from './useDefault'
7
+ import { useName } from './useName'
7
8
 
8
9
  type Value<T, M extends boolean> = M extends true ? readonly T[] : T
9
10
 
@@ -1,5 +1,5 @@
1
1
  import { createElement, useMemo, type PropsWithChildren } from 'react'
2
- import { useDefault, type ChangeCallback } from '.'
2
+ import { useDefault, type ChangeCallback } from './useDefault'
3
3
  import { FormContext } from './context'
4
4
 
5
5
  interface Props<T extends object> extends PropsWithChildren {
@@ -1,5 +1,4 @@
1
1
  'use client'
2
- import { useConst, useUniqueId } from '#hook'
3
2
  import {
4
3
  createElement,
5
4
  use,
@@ -11,7 +10,9 @@ import {
11
10
  type SyntheticEvent,
12
11
  } from 'react'
13
12
  import invariant from 'tiny-invariant'
14
- import { useDefault, type ChangeCallback } from '.'
13
+ import { useConst } from '../react/useConst'
14
+ import { useUniqueId } from '../react/useUniqueId'
15
+ import { useDefault, type ChangeCallback } from './useDefault'
15
16
  import { FormContext } from './context'
16
17
 
17
18
  interface Props<T, E extends SyntheticEvent> extends PropsWithChildren {
@@ -56,16 +57,6 @@ export function useGroup<T, P extends Props<T, SyntheticEvent>>(props: P) {
56
57
  value: _value,
57
58
  })
58
59
 
59
- // eslint-disable-next-line react-hooks/immutability
60
- props = {
61
- ...props,
62
- name,
63
- defaultValue: undefined,
64
- value,
65
- multiple,
66
- disabled,
67
- }
68
-
69
60
  const [_state, _setState] = useDefault({
70
61
  defaultValue: {},
71
62
  value: context?.value,
@@ -129,20 +120,28 @@ export function useGroup<T, P extends Props<T, SyntheticEvent>>(props: P) {
129
120
  [name, setState]
130
121
  )
131
122
 
132
- props = {
133
- ...props,
134
- onChange: handleChange,
135
- }
136
-
137
123
  const _context = useMemo<NonNullable<typeof context>>(
138
124
  () => ({ name, value: state, multiple, disabled, onChange: setState }),
139
125
  [disabled, multiple, name, setState, state]
140
126
  )
141
127
 
142
- props = {
128
+ const groupProps: P = {
143
129
  ...props,
144
- // eslint-disable-next-line react-hooks/refs
145
- children: createElement(FormContext, { value: _context }, props.children),
130
+ name,
131
+ defaultValue: undefined,
132
+ value,
133
+ multiple,
134
+ disabled,
135
+ onChange: handleChange,
136
+ children: createElement(
137
+ FormContext,
138
+ // The context value bundles 'setState', which reads the latest state
139
+ // from a ref inside event callbacks. The rule conservatively flags any
140
+ // ref-reading function passed through a provider during render.
141
+ // eslint-disable-next-line react-hooks/refs
142
+ { value: _context },
143
+ props.children
144
+ ),
146
145
  }
147
146
 
148
147
  return {
@@ -151,7 +150,7 @@ export function useGroup<T, P extends Props<T, SyntheticEvent>>(props: P) {
151
150
  multiple,
152
151
  disabled,
153
152
  onChange: handleChange,
154
- props,
153
+ props: groupProps,
155
154
  context: _context,
156
155
  }
157
156
  }
@@ -1,5 +1,5 @@
1
- import type { ChangeCallback } from '#hook'
2
1
  import { use, useCallback } from 'react'
2
+ import type { ChangeCallback } from './useDefault'
3
3
  import { FormContext } from './context'
4
4
 
5
5
  interface Props<T> {
@@ -1,5 +1,5 @@
1
- import type { ChangeCallback } from '#hook'
2
- import { useChecked } from '.'
1
+ import type { ChangeCallback } from './useDefault'
2
+ import { useChecked } from './useChecked'
3
3
 
4
4
  export type OptionValue = string | number
5
5
 
@@ -1,5 +1,5 @@
1
- import type { ChangeCallback } from '#hook'
2
- import { useChecked } from '.'
1
+ import type { ChangeCallback } from './useDefault'
2
+ import { useChecked } from './useChecked'
3
3
 
4
4
  interface Props {
5
5
  name?: string | undefined
@@ -1,15 +1,18 @@
1
- import {
2
- useRefCallback,
3
- type ChangeCallback,
4
- type KeyboardOptions,
5
- type NavigationDirection,
6
- type Overlay,
7
- type OverlayAnchorProps,
8
- type PopoverOptions,
9
- type PositioningOptions,
10
- type ToggleCallback,
11
- } from '#hook'
12
- import { normalizeValue, useGroup } from '.'
1
+ import type {
2
+ KeyboardOptions,
3
+ NavigationDirection,
4
+ } from '../accessibility/keyboard/Keyboard'
5
+ import type {
6
+ Overlay,
7
+ OverlayAnchorProps,
8
+ ToggleCallback,
9
+ } from '../popover/useOverlay'
10
+ import type { PopoverOptions } from '../popover/usePopover'
11
+ import type { PositioningOptions } from '../popover/usePositioning'
12
+ import { useRefCallback } from '../react/useRefCallback'
13
+ import type { ChangeCallback } from './useDefault'
14
+ import { normalizeValue } from './useChecked'
15
+ import { useGroup } from './useGroup'
13
16
 
14
17
  type Option<T> = { value: T; label: string }
15
18
 
@@ -1,6 +1,7 @@
1
- import { useConst, type ChangeCallback } from '#hook'
2
1
  import invariant from 'tiny-invariant'
3
- import { useName } from '.'
2
+ import { useConst } from '../react/useConst'
3
+ import type { ChangeCallback } from './useDefault'
4
+ import { useName } from './useName'
4
5
 
5
6
  interface Props<T> {
6
7
  name?: string | undefined
@@ -1,7 +1,7 @@
1
1
  'use client'
2
2
  import 'symbol-observable'
3
3
 
4
- import { useCallback, useRef, useSyncExternalStore } from 'react'
4
+ import { useCallback, useEffect, useRef, useSyncExternalStore } from 'react'
5
5
  import type { ObservableInput } from 'rxjs'
6
6
  import { from } from 'rxjs'
7
7
 
@@ -20,10 +20,23 @@ export function useObservable<T>(
20
20
  initialValue?: T | undefined
21
21
  ) {
22
22
  const valueRef = useRef(initialValue)
23
+ const initialValueRef = useRef(initialValue)
24
+
25
+ // Track the latest 'initialValue' in a ref so the subscribe callback below
26
+ // depends only on 'observable'; a new initial value identity must not
27
+ // resubscribe and reset the emitted value.
28
+ useEffect(() => {
29
+ initialValueRef.current = initialValue
30
+ })
23
31
 
24
32
  return useSyncExternalStore(
25
33
  useCallback(
26
34
  (onStoreChange) => {
35
+ // A new 'observable' must not keep reporting the previous source's
36
+ // last emission; fall back to the latest 'initialValue' until it
37
+ // emits.
38
+ valueRef.current = initialValueRef.current
39
+
27
40
  const subscription = from(observable).subscribe((value) => {
28
41
  valueRef.current = value
29
42
  onStoreChange()
@@ -1,5 +1,5 @@
1
1
  import { createContext } from 'react'
2
- import type { Overlay } from '..'
2
+ import type { Overlay } from '../useOverlay'
3
3
 
4
4
  export const OverlayContext = createContext<Overlay | null>(null)
5
5