chiplet 0.3.0-dev.4 → 0.4.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 (300) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +42 -13
  3. package/dist/assets/positioning.css.ts.vanilla-BVOg9Lwj.css +60 -0
  4. package/dist/component/button/Button.js +5 -5
  5. package/dist/component/button/Button.js.map +1 -1
  6. package/dist/component/button/IconButton.js +1 -1
  7. package/dist/component/button/IconButton.js.map +1 -1
  8. package/dist/component/button/Interactive.js +2 -17
  9. package/dist/component/button/Interactive.js.map +1 -1
  10. package/dist/component/button/LinkButton.js +7 -5
  11. package/dist/component/button/LinkButton.js.map +1 -1
  12. package/dist/component/button/style/{index.css.vanilla.js → index.css.js} +5 -5
  13. package/dist/component/button/style/index.css.js.map +1 -0
  14. package/dist/component/checkbox/Checkbox.js +4 -18
  15. package/dist/component/checkbox/Checkbox.js.map +1 -1
  16. package/dist/component/checkbox/CheckboxGroup.js +2 -17
  17. package/dist/component/checkbox/CheckboxGroup.js.map +1 -1
  18. package/dist/component/checkbox/Radio.js +2 -17
  19. package/dist/component/checkbox/Radio.js.map +1 -1
  20. package/dist/component/checkbox/RadioGroup.js +2 -17
  21. package/dist/component/checkbox/RadioGroup.js.map +1 -1
  22. package/dist/component/checkbox/Switch.js +1 -1
  23. package/dist/component/checkbox/icon/CheckboxChecked.svg.js.map +1 -1
  24. package/dist/component/checkbox/icon/CheckboxIndeterminate.svg.js.map +1 -1
  25. package/dist/component/checkbox/icon/CheckboxUnchecked.svg.js.map +1 -1
  26. package/dist/component/checkbox/icon/RadioChecked.svg.js.map +1 -1
  27. package/dist/component/checkbox/icon/RadioUnchecked.svg.js.map +1 -1
  28. package/dist/component/checkbox/icon/index.js +0 -29
  29. package/dist/component/checkbox/icon/index.js.map +1 -1
  30. package/dist/component/checkbox/style/{index.css.vanilla.js → index.css.js} +4 -5
  31. package/dist/component/checkbox/style/index.css.js.map +1 -0
  32. package/dist/component/header/Header.js +1 -1
  33. package/dist/component/header/style/index.css.js +7 -0
  34. package/dist/component/header/style/index.css.js.map +1 -0
  35. package/dist/component/icon/set/Checkmark24Filled.svg.js.map +1 -1
  36. package/dist/component/icon/set/Checkmark24Regular.svg.js.map +1 -1
  37. package/dist/component/icon/set/ChevronDown24Filled.svg.js.map +1 -1
  38. package/dist/component/icon/set/ChevronDown24Regular.svg.js.map +1 -1
  39. package/dist/component/icon/set/Dismiss24Filled.svg.js.map +1 -1
  40. package/dist/component/icon/set/Dismiss24Regular.svg.js.map +1 -1
  41. package/dist/component/icon/set/Search24Filled.svg.js.map +1 -1
  42. package/dist/component/icon/set/Search24Regular.svg.js.map +1 -1
  43. package/dist/component/index.js +20 -19
  44. package/dist/component/index.js.map +1 -1
  45. package/dist/component/input/Input.js +2 -17
  46. package/dist/component/input/Input.js.map +1 -1
  47. package/dist/component/input/SearchInput.js +4 -5
  48. package/dist/component/input/SearchInput.js.map +1 -1
  49. package/dist/component/input/style/{index.css.vanilla.js → index.css.js} +5 -5
  50. package/dist/component/input/style/index.css.js.map +1 -0
  51. package/dist/component/menu/Menu.js +2 -28
  52. package/dist/component/menu/Menu.js.map +1 -1
  53. package/dist/component/menu/MenuButton.js +1 -3
  54. package/dist/component/menu/MenuButton.js.map +1 -1
  55. package/dist/component/menu/MenuItem.js +2 -18
  56. package/dist/component/menu/MenuItem.js.map +1 -1
  57. package/dist/component/menu/MenuItemCheckbox.js +4 -31
  58. package/dist/component/menu/MenuItemCheckbox.js.map +1 -1
  59. package/dist/component/menu/MenuItemRadio.js +5 -32
  60. package/dist/component/menu/MenuItemRadio.js.map +1 -1
  61. package/dist/component/menu/renderMenuItem.js +1 -1
  62. package/dist/component/popover/Dialog.js +2 -17
  63. package/dist/component/popover/Dialog.js.map +1 -1
  64. package/dist/component/popover/DismissButton.js +2 -19
  65. package/dist/component/popover/DismissButton.js.map +1 -1
  66. package/dist/component/popover/Popover.js +2 -17
  67. package/dist/component/popover/Popover.js.map +1 -1
  68. package/dist/component/popover/ShadowRoot.js +34 -0
  69. package/dist/component/popover/ShadowRoot.js.map +1 -0
  70. package/dist/component/popover/Tooltip.js +4 -18
  71. package/dist/component/popover/Tooltip.js.map +1 -1
  72. package/dist/component/popover/index.js +1 -0
  73. package/dist/component/popover/index.js.map +1 -1
  74. package/dist/component/popover/style/{index.css.vanilla.js → index.css.js} +5 -5
  75. package/dist/component/popover/style/index.css.js.map +1 -0
  76. package/dist/component/progress/Spinner.js +1 -1
  77. package/dist/component/progress/style/{index.css.vanilla.js → index.css.js} +4 -5
  78. package/dist/component/progress/style/index.css.js.map +1 -0
  79. package/dist/component/select/AutoComplete.js +7 -30
  80. package/dist/component/select/AutoComplete.js.map +1 -1
  81. package/dist/component/select/Group.js +2 -17
  82. package/dist/component/select/Group.js.map +1 -1
  83. package/dist/component/select/Option.js +6 -21
  84. package/dist/component/select/Option.js.map +1 -1
  85. package/dist/component/select/Select.js +6 -29
  86. package/dist/component/select/Select.js.map +1 -1
  87. package/dist/component/select/Separator.js +1 -1
  88. package/dist/component/select/style/{index.css.vanilla.js → index.css.js} +5 -5
  89. package/dist/component/select/style/index.css.js.map +1 -0
  90. package/dist/component/style/article.css.js +6 -0
  91. package/dist/component/style/article.css.js.map +1 -0
  92. package/dist/component/style/index.js +1 -1
  93. package/dist/component/typography/Body1.js +1 -1
  94. package/dist/component/typography/Body2.js +1 -1
  95. package/dist/component/typography/Body3.js +1 -1
  96. package/dist/component/typography/Caption1.js +1 -1
  97. package/dist/component/typography/Caption2.js +1 -1
  98. package/dist/component/typography/Heading1.js +1 -1
  99. package/dist/component/typography/Heading2.js +1 -1
  100. package/dist/component/typography/Heading3.js +1 -1
  101. package/dist/component/typography/Heading4.js +1 -1
  102. package/dist/component/typography/style/{index.css.vanilla.js → index.css.js} +4 -5
  103. package/dist/component/typography/style/index.css.js.map +1 -0
  104. package/dist/hook/accessibility/keyboard/Keyboard.js +6 -18
  105. package/dist/hook/accessibility/keyboard/Keyboard.js.map +1 -1
  106. package/dist/hook/accessibility/keyboard/Roving.js +0 -15
  107. package/dist/hook/accessibility/keyboard/Roving.js.map +1 -1
  108. package/dist/hook/accessibility/keyboard/context/index.js.map +1 -1
  109. package/dist/hook/accessibility/keyboard/hook/useLastFocused.js +1 -4
  110. package/dist/hook/accessibility/keyboard/hook/useLastFocused.js.map +1 -1
  111. package/dist/hook/accessibility/keyboard/hook/useNavigate.js.map +1 -1
  112. package/dist/hook/accessibility/keyboard/resolve.js +1 -4
  113. package/dist/hook/accessibility/keyboard/resolve.js.map +1 -1
  114. package/dist/hook/accessibility/keyboard/sort.js +0 -3
  115. package/dist/hook/accessibility/keyboard/sort.js.map +1 -1
  116. package/dist/hook/accessibility/keyboard/tree.js +1 -4
  117. package/dist/hook/accessibility/keyboard/tree.js.map +1 -1
  118. package/dist/hook/accessibility/keyboard/useController.js +2 -15
  119. package/dist/hook/accessibility/keyboard/useController.js.map +1 -1
  120. package/dist/hook/accessibility/keyboard/useKeyboard.js +2 -16
  121. package/dist/hook/accessibility/keyboard/useKeyboard.js.map +1 -1
  122. package/dist/hook/document/useHighlight.js +1 -4
  123. package/dist/hook/document/useHighlight.js.map +1 -1
  124. package/dist/hook/form/context/index.js.map +1 -1
  125. package/dist/hook/form/useAutoComplete.js +2 -16
  126. package/dist/hook/form/useAutoComplete.js.map +1 -1
  127. package/dist/hook/form/useChange.js.map +1 -1
  128. package/dist/hook/form/useCheckbox.js +0 -16
  129. package/dist/hook/form/useCheckbox.js.map +1 -1
  130. package/dist/hook/form/useChecked.js +1 -14
  131. package/dist/hook/form/useChecked.js.map +1 -1
  132. package/dist/hook/form/useForm.js +1 -15
  133. package/dist/hook/form/useForm.js.map +1 -1
  134. package/dist/hook/form/useGroup.js +2 -14
  135. package/dist/hook/form/useGroup.js.map +1 -1
  136. package/dist/hook/form/useName.js.map +1 -1
  137. package/dist/hook/form/useOption.js +0 -16
  138. package/dist/hook/form/useOption.js.map +1 -1
  139. package/dist/hook/form/useRadio.js +0 -16
  140. package/dist/hook/form/useRadio.js.map +1 -1
  141. package/dist/hook/form/useSelect.js +0 -16
  142. package/dist/hook/form/useSelect.js.map +1 -1
  143. package/dist/hook/form/useValue.js +0 -15
  144. package/dist/hook/form/useValue.js.map +1 -1
  145. package/dist/hook/index.js +22 -21
  146. package/dist/hook/index.js.map +1 -1
  147. package/dist/hook/popover/context/index.js.map +1 -1
  148. package/dist/hook/popover/index.js +2 -1
  149. package/dist/hook/popover/index.js.map +1 -1
  150. package/dist/hook/popover/style/positioning.css.js +13 -0
  151. package/dist/hook/popover/style/positioning.css.js.map +1 -0
  152. package/dist/hook/popover/useAnchorPositioning.js +6 -88
  153. package/dist/hook/popover/useAnchorPositioning.js.map +1 -1
  154. package/dist/hook/popover/useDialog.js +1 -15
  155. package/dist/hook/popover/useDialog.js.map +1 -1
  156. package/dist/hook/popover/useLightDismiss.js +1 -4
  157. package/dist/hook/popover/useLightDismiss.js.map +1 -1
  158. package/dist/hook/popover/useOverlay.js +0 -15
  159. package/dist/hook/popover/useOverlay.js.map +1 -1
  160. package/dist/hook/popover/usePopover.js +1 -12
  161. package/dist/hook/popover/usePopover.js.map +1 -1
  162. package/dist/hook/popover/usePositioning.js +4 -5
  163. package/dist/hook/popover/usePositioning.js.map +1 -1
  164. package/dist/hook/popover/useTooltip.js +1 -13
  165. package/dist/hook/popover/useTooltip.js.map +1 -1
  166. package/dist/hook/react/refValue.js +0 -3
  167. package/dist/hook/react/refValue.js.map +1 -1
  168. package/dist/hook/react/useActivate.js +1 -4
  169. package/dist/hook/react/useActivate.js.map +1 -1
  170. package/dist/hook/react/useConst.js.map +1 -1
  171. package/dist/hook/react/useInteractive.js +1 -4
  172. package/dist/hook/react/useInteractive.js.map +1 -1
  173. package/dist/hook/react/useRefCallback.js.map +1 -1
  174. package/dist/hook/react/useUniqueId.js +1 -4
  175. package/dist/hook/react/useUniqueId.js.map +1 -1
  176. package/dist/index.js +109 -109
  177. package/dist/infra/index.js +1 -1
  178. package/dist/infra/logging/logger.js +7 -8
  179. package/dist/infra/logging/logger.js.map +1 -1
  180. package/dist/theme/ColorScheme.js.map +1 -1
  181. package/dist/theme/defineTheme.js +0 -3
  182. package/dist/theme/defineTheme.js.map +1 -1
  183. package/dist/theme/{global.css.vanilla.js → global.css.js} +4 -4
  184. package/dist/theme/global.css.js.map +1 -0
  185. package/dist/theme/index.js +3 -3
  186. package/dist/theme/{theme.css.vanilla.js → theme.css.js} +3 -3
  187. package/dist/theme/theme.css.js.map +1 -0
  188. package/dist/theme/{token.css.vanilla.js → token.css.js} +2 -2
  189. package/dist/theme/token.css.js.map +1 -0
  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/index.js +28 -30
  196. package/dist/util/index.js.map +1 -1
  197. package/dist/util/linked-list/buildLinkedList.js.map +1 -1
  198. package/dist/util/lock/lock.js +0 -2
  199. package/dist/util/lock/lock.js.map +1 -1
  200. package/dist/util/random/index.js +0 -1
  201. package/dist/util/random/index.js.map +1 -1
  202. package/dist/util/tree/addTreeNode.js.map +1 -1
  203. package/dist/util/tree/attachChild.js.map +1 -1
  204. package/dist/util/tree/buildTree.js.map +1 -1
  205. package/dist/util/tree/detachChild.js.map +1 -1
  206. package/dist/util/tree/iterateChildren.js.map +1 -1
  207. package/dist/util/tree/iterateTree.js.map +1 -1
  208. package/package.json +99 -97
  209. package/src/component/button/Button.tsx +5 -10
  210. package/src/component/button/IconButton.tsx +1 -1
  211. package/src/component/button/LinkButton.tsx +12 -6
  212. package/src/component/checkbox/Checkbox.tsx +2 -2
  213. package/src/component/checkbox/Radio.tsx +1 -2
  214. package/src/component/checkbox/RadioGroup.tsx +1 -2
  215. package/src/component/checkbox/icon/index.ts +1 -1
  216. package/src/component/icon/README.md +17 -3
  217. package/src/component/input/Input.tsx +1 -2
  218. package/src/component/input/SearchInput.tsx +4 -3
  219. package/src/component/menu/Menu.tsx +1 -1
  220. package/src/component/menu/MenuItemCheckbox.tsx +1 -1
  221. package/src/component/menu/MenuItemRadio.tsx +1 -1
  222. package/src/component/popover/ShadowRoot.tsx +42 -0
  223. package/src/component/popover/Tooltip.tsx +3 -5
  224. package/src/component/popover/index.ts +1 -0
  225. package/src/component/select/AutoComplete.tsx +3 -7
  226. package/src/component/select/Option.tsx +1 -2
  227. package/src/component/select/Select.tsx +3 -7
  228. package/src/hook/accessibility/keyboard/Keyboard.tsx +1 -1
  229. package/src/hook/accessibility/keyboard/Roving.tsx +1 -1
  230. package/src/hook/accessibility/keyboard/context/index.ts +1 -1
  231. package/src/hook/accessibility/keyboard/hook/useLastFocused.ts +2 -1
  232. package/src/hook/accessibility/keyboard/hook/useNavigate.ts +1 -1
  233. package/src/hook/accessibility/keyboard/resolve.ts +1 -1
  234. package/src/hook/accessibility/keyboard/useController.ts +3 -2
  235. package/src/hook/accessibility/keyboard/useKeyboard.ts +3 -2
  236. package/src/hook/form/context/index.ts +1 -1
  237. package/src/hook/form/useAutoComplete.ts +14 -14
  238. package/src/hook/form/useChange.ts +1 -1
  239. package/src/hook/form/useCheckbox.ts +2 -2
  240. package/src/hook/form/useChecked.ts +3 -2
  241. package/src/hook/form/useForm.ts +1 -1
  242. package/src/hook/form/useGroup.ts +5 -3
  243. package/src/hook/form/useName.ts +1 -1
  244. package/src/hook/form/useOption.ts +2 -2
  245. package/src/hook/form/useRadio.ts +2 -2
  246. package/src/hook/form/useSelect.ts +15 -12
  247. package/src/hook/form/useValue.ts +3 -2
  248. package/src/hook/popover/context/index.ts +1 -1
  249. package/src/hook/popover/style/positioning.css.ts +112 -0
  250. package/src/hook/popover/useAnchorPositioning.ts +15 -104
  251. package/src/hook/popover/useDialog.ts +5 -4
  252. package/src/hook/popover/useOverlay.ts +2 -2
  253. package/src/hook/popover/usePopover.ts +12 -11
  254. package/src/hook/popover/usePositioning.ts +12 -6
  255. package/src/hook/popover/useTooltip.ts +7 -6
  256. package/src/hook/react/useConst.ts +2 -1
  257. package/src/hook/react/useRefCallback.ts +1 -1
  258. package/src/infra/logging/logger.ts +32 -18
  259. package/src/theme/ColorScheme.tsx +1 -5
  260. package/src/theme/global.css.ts +1 -1
  261. package/src/util/array/index.ts +0 -1
  262. package/src/util/document/accessibility.css.ts +1 -1
  263. package/src/util/linked-list/buildLinkedList.ts +1 -1
  264. package/src/util/random/index.ts +0 -1
  265. package/src/util/tree/addTreeNode.ts +1 -1
  266. package/src/util/tree/attachChild.ts +1 -1
  267. package/src/util/tree/buildTree.ts +1 -1
  268. package/src/util/tree/detachChild.ts +1 -1
  269. package/src/util/tree/iterateChildren.ts +1 -1
  270. package/src/util/tree/iterateTree.ts +1 -1
  271. package/dist/component/button/style/index.css.vanilla.js.map +0 -1
  272. package/dist/component/checkbox/style/index.css.vanilla.js.map +0 -1
  273. package/dist/component/header/style/index.css.vanilla.js +0 -7
  274. package/dist/component/header/style/index.css.vanilla.js.map +0 -1
  275. package/dist/component/input/style/index.css.vanilla.js.map +0 -1
  276. package/dist/component/popover/style/index.css.vanilla.js.map +0 -1
  277. package/dist/component/progress/style/index.css.vanilla.js.map +0 -1
  278. package/dist/component/select/style/index.css.vanilla.js.map +0 -1
  279. package/dist/component/style/article.css.vanilla.js +0 -6
  280. package/dist/component/style/article.css.vanilla.js.map +0 -1
  281. package/dist/component/typography/style/index.css.vanilla.js.map +0 -1
  282. package/dist/theme/global.css.vanilla.js.map +0 -1
  283. package/dist/theme/theme.css.vanilla.js.map +0 -1
  284. package/dist/theme/token.css.vanilla.js.map +0 -1
  285. package/dist/util/array/fromAsync.js +0 -11
  286. package/dist/util/array/fromAsync.js.map +0 -1
  287. package/dist/util/document/accessibility.css.vanilla.js.map +0 -1
  288. package/src/util/array/fromAsync.ts +0 -11
  289. /package/dist/{component/style/article.css → assets/article.css.ts.vanilla-s_HEpsy3.css} +0 -0
  290. /package/dist/{theme/global.css → assets/global.css.ts.vanilla-CTwjHiaM.css} +0 -0
  291. /package/dist/{component/button/style/index.css → assets/index.css.ts.vanilla-9qGDrdgn.css} +0 -0
  292. /package/dist/{component/checkbox/style/index.css → assets/index.css.ts.vanilla-BsBngo8U.css} +0 -0
  293. /package/dist/{component/select/index2.css → assets/index.css.ts.vanilla-CVNLkHc9.css} +0 -0
  294. /package/dist/{component/select/style/index.css → assets/index.css.ts.vanilla-C_RzxiYH.css} +0 -0
  295. /package/dist/{component/popover/style/index.css → assets/index.css.ts.vanilla-CvQQLJ-M.css} +0 -0
  296. /package/dist/{component/select/index.css → assets/index.css.ts.vanilla-DGmHFJbF.css} +0 -0
  297. /package/dist/{component/progress/style/index.css → assets/index.css.ts.vanilla-VHSAjLub.css} +0 -0
  298. /package/dist/{component/input/style/index.css → assets/index.css.ts.vanilla-kgyRRvgH.css} +0 -0
  299. /package/dist/{theme/theme.css → assets/theme.css.ts.vanilla-Bjn8sb_B.css} +0 -0
  300. /package/dist/{theme/token.css → assets/token.css.ts.vanilla-B3LtFaO7.css} +0 -0
@@ -1,6 +1,6 @@
1
1
  'use client'
2
2
  import { createContext } from 'react'
3
- import type { Keyboard } from '..'
3
+ import type { Keyboard } from '../Keyboard'
4
4
  import type { PoolAdd, PoolRemove } from '../hook'
5
5
 
6
6
  export interface KeyboardContext extends Keyboard {
@@ -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,7 @@ export function useLastFocused(
8
8
  tree: Tree,
9
9
  active: Element | null
10
10
  ) {
11
+ // eslint-disable-next-line react-hooks/preserve-manual-memoization
11
12
  let ctx = useMemo(
12
13
  () => (active ? tree.map.get(active)?.context : null),
13
14
  [active, tree.map]
@@ -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,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,8 +10,10 @@ import {
11
10
  type SyntheticEvent,
12
11
  } from 'react'
13
12
  import invariant from 'tiny-invariant'
13
+ import { useConst } from '../react/useConst'
14
+ import { useUniqueId } from '../react/useUniqueId'
15
+ import { useDefault, type ChangeCallback } from './useDefault'
14
16
  import { FormContext } from './context'
15
- import { useDefault, type ChangeCallback } from '.'
16
17
 
17
18
  interface Props<T, E extends SyntheticEvent> extends PropsWithChildren {
18
19
  name?: string | undefined
@@ -56,7 +57,7 @@ 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
+ // eslint-disable-next-line react-hooks/immutability, react-compiler/react-compiler
60
61
  props = {
61
62
  ...props,
62
63
  name,
@@ -141,6 +142,7 @@ export function useGroup<T, P extends Props<T, SyntheticEvent>>(props: P) {
141
142
 
142
143
  props = {
143
144
  ...props,
145
+ // eslint-disable-next-line react-hooks/refs
144
146
  children: createElement(FormContext, { value: _context }, props.children),
145
147
  }
146
148
 
@@ -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,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
 
@@ -0,0 +1,112 @@
1
+ import { entries, fromEntries, keys } from '#util'
2
+ import type { Alignment, Placement } from '@floating-ui/utils'
3
+ import { globalStyle } from '@vanilla-extract/css'
4
+ import type { Simplify } from 'type-fest'
5
+ import { generateDeterministicId } from '../../../util/random/generateDeterministicId'
6
+
7
+ export type Side = 'above' | 'below' | 'before' | 'after'
8
+ export type Axis = 'block' | 'inline'
9
+ export type Position = Simplify<Side | `${Side}-${Alignment}`>
10
+
11
+ export const Position = [
12
+ 'above',
13
+ 'below',
14
+ 'before',
15
+ 'after',
16
+ 'above-start',
17
+ 'above-end',
18
+ 'below-start',
19
+ 'below-end',
20
+ 'before-start',
21
+ 'before-end',
22
+ 'after-start',
23
+ 'after-end',
24
+ ] as const
25
+
26
+ export const positionMap: Record<Position, Placement> = {
27
+ 'above': 'top',
28
+ 'below': 'bottom',
29
+ 'before': 'left',
30
+ 'after': 'right',
31
+ 'above-start': 'top-start',
32
+ 'above-end': 'top-end',
33
+ 'below-start': 'bottom-start',
34
+ 'below-end': 'bottom-end',
35
+ 'before-start': 'left-start',
36
+ 'before-end': 'left-end',
37
+ 'after-start': 'right-start',
38
+ 'after-end': 'right-end',
39
+ }
40
+
41
+ export const placementMap: Record<Placement, Position> = fromEntries(
42
+ entries(positionMap).map(([position, placement]) => [placement, position])
43
+ )
44
+
45
+ export const positionAxisMap: Record<Position, Axis> = {
46
+ 'above': 'block',
47
+ 'above-start': 'block',
48
+ 'above-end': 'block',
49
+ 'below': 'block',
50
+ 'below-start': 'block',
51
+ 'below-end': 'block',
52
+ 'before': 'inline',
53
+ 'before-start': 'inline',
54
+ 'before-end': 'inline',
55
+ 'after': 'inline',
56
+ 'after-start': 'inline',
57
+ 'after-end': 'inline',
58
+ }
59
+
60
+ /**
61
+ * https://developer.mozilla.org/en-US/docs/Web/CSS/position-area_value#logical_grid_keyword_defaults
62
+ */
63
+ export const positionAreaMap: Record<Position, string> = {
64
+ 'above': 'block-start',
65
+ 'below': 'block-end',
66
+ 'before': 'inline-start',
67
+ 'after': 'inline-end',
68
+ 'above-start': 'start span-end',
69
+ 'above-end': 'start span-start',
70
+ 'below-start': 'end span-end',
71
+ 'below-end': 'end span-start',
72
+ 'before-start': 'inline-start span-block-end',
73
+ 'before-end': 'inline-start span-block-start',
74
+ 'after-start': 'inline-end span-block-end',
75
+ 'after-end': 'inline-end span-block-start',
76
+ }
77
+
78
+ export const positionInsetMap: Record<Position, keyof React.CSSProperties> = {
79
+ 'above': 'insetBlockEnd',
80
+ 'above-start': 'insetBlockEnd',
81
+ 'above-end': 'insetBlockEnd',
82
+ 'below': 'insetBlockStart',
83
+ 'below-start': 'insetBlockStart',
84
+ 'below-end': 'insetBlockStart',
85
+ 'before': 'insetInlineEnd',
86
+ 'before-start': 'insetInlineEnd',
87
+ 'before-end': 'insetInlineEnd',
88
+ 'after': 'insetInlineStart',
89
+ 'after-start': 'insetInlineStart',
90
+ 'after-end': 'insetInlineStart',
91
+ }
92
+
93
+ export const PositionOffset = generateDeterministicId('--offset')
94
+
95
+ const PositionTryOptionName = generateDeterministicId('')
96
+
97
+ export const positionTryOptionMap: Record<Position, string> = fromEntries(
98
+ keys(positionMap).map((position) => [
99
+ position,
100
+ `--position-try-option-${position}-${PositionTryOptionName}`,
101
+ ])
102
+ )
103
+
104
+ for (const [position, area] of entries(positionAreaMap)) {
105
+ globalStyle(`@position-try ${positionTryOptionMap[position]}`, {
106
+ positionArea: area,
107
+ inset: 'auto',
108
+ [positionInsetMap[position]]: `var(${PositionOffset})`,
109
+ // TODO: extend 'positionTryOptionMap', add '@starting-style' entry
110
+ // animation, and try to reuse 'PopoverStyle'
111
+ })
112
+ }
@@ -1,15 +1,21 @@
1
- import { entries, fromEntries } from '#util'
2
1
  import {
3
2
  getAlignment,
4
3
  getExpandedPlacements,
5
4
  getOppositeAxisPlacements,
6
5
  getOppositePlacement,
7
- type Alignment,
8
- type Placement,
9
6
  } from '@floating-ui/utils'
10
7
  import { useMemo } from 'react'
11
- import type { Simplify } from 'type-fest'
12
8
  import { useUniqueId } from '../react'
9
+ import {
10
+ placementMap,
11
+ positionAreaMap,
12
+ positionAxisMap,
13
+ positionInsetMap,
14
+ positionMap,
15
+ PositionOffset,
16
+ positionTryOptionMap,
17
+ type Position,
18
+ } from './style/positioning.css'
13
19
  import type { Positioning, PositioningOptions } from './usePositioning'
14
20
 
15
21
  /**
@@ -36,22 +42,19 @@ export function useAnchorPositioning(options: PositioningOptions): Positioning {
36
42
  }
37
43
 
38
44
  positionedStyle = {
45
+ [PositionOffset]: `${offset}px`,
39
46
  position: strategy,
40
47
  positionAnchor: anchorName,
41
48
  positionArea: positionAreaMap[position],
42
- // TODO: https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/At-rules/@position-try
43
49
  positionTry: fallback
44
- .map((position) => positionAreaMap[position])
50
+ .map((position) => positionTryOptionMap[position])
45
51
  .join(', '),
46
52
  margin: '0',
47
- inset: 'auto', // https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/position-area#using_position-area_to_position_popovers
48
- // https://developer.mozilla.org/en-US/docs/Web/CSS/position-area#adjusted_default_behavior
49
- // When an anchor-positioned element is positioned using the position-area property,
50
- // any inset properties set, such as top or inset-inline-end, specify offsets from the position-area.
51
- [insetMap[position]]: `${offset}px`,
53
+ inset: 'auto',
54
+ [positionInsetMap[position]]: `var(${PositionOffset})`,
52
55
  }
53
56
 
54
- switch (options.align && positionAxis(position)) {
57
+ switch (options.align && positionAxisMap[position]) {
55
58
  case 'block':
56
59
  positionedStyle.minInlineSize = `min(100vi, 100%, anchor-size(self-inline))`
57
60
  break
@@ -71,83 +74,6 @@ export function useAnchorPositioning(options: PositioningOptions): Positioning {
71
74
  }
72
75
  }
73
76
 
74
- type Side = 'above' | 'below' | 'before' | 'after'
75
-
76
- export type Position = Simplify<Side | `${Side}-${Alignment}`>
77
-
78
- export const Position = [
79
- 'above',
80
- 'below',
81
- 'before',
82
- 'after',
83
- 'above-start',
84
- 'above-end',
85
- 'below-start',
86
- 'below-end',
87
- 'before-start',
88
- 'before-end',
89
- 'after-start',
90
- 'after-end',
91
- ] as const
92
-
93
- type Axis = 'block' | 'inline'
94
-
95
- function positionSide(position: Position): Side {
96
- return position.split('-')[0] as Side
97
- }
98
-
99
- export function positionAxis(position: Position): Axis {
100
- switch (positionSide(position)) {
101
- case 'above':
102
- case 'below':
103
- return 'block'
104
- case 'before':
105
- case 'after':
106
- return 'inline'
107
- }
108
- }
109
-
110
- export const positionMap: Record<Position, Placement> = {
111
- 'above': 'top',
112
- 'below': 'bottom',
113
- 'before': 'left',
114
- 'after': 'right',
115
- 'above-start': 'top-start',
116
- 'above-end': 'top-end',
117
- 'below-start': 'bottom-start',
118
- 'below-end': 'bottom-end',
119
- 'before-start': 'left-start',
120
- 'before-end': 'left-end',
121
- 'after-start': 'right-start',
122
- 'after-end': 'right-end',
123
- }
124
-
125
- export const placementMap: Record<Placement, Position> = fromEntries(
126
- entries(positionMap).map(([position, placement]) => [placement, position])
127
- )
128
-
129
- /**
130
- * TODO
131
- * - above => [flip-block, flip-start, flip-start flip-inline]
132
- * - above-start => [flip-inline, flip-block, flip-block flip-inline, flip-start, flip-start flip-block, flip-start flip-inline, flip-start flip-inline flip-block]
133
- *
134
- * https://developer.mozilla.org/en-US/docs/Web/CSS/position-area_value#logical_grid_keyword_defaults
135
- */
136
- export const positionAreaMap: Record<Position, string> = {
137
- 'above': 'block-start',
138
- 'below': 'block-end',
139
- 'before': 'inline-start',
140
- 'after': 'inline-end',
141
- 'above-start': 'start span-end',
142
- 'above-end': 'start span-start',
143
- 'below-start': 'end span-end',
144
- 'below-end': 'end span-start',
145
- 'before-start': 'inline-start span-block-end',
146
- 'before-end': 'inline-start span-block-start',
147
- 'after-start': 'inline-end span-block-end',
148
- 'after-end': 'inline-end span-block-start',
149
- }
150
-
151
77
  /**
152
78
  * https://floating-ui.com/docs/flip#fallbackplacements
153
79
  *
@@ -167,21 +93,6 @@ export function positionTry(position: Position, tryCrossAxis?: boolean) {
167
93
  ).map((placement) => placementMap[placement])
168
94
  }
169
95
 
170
- const insetMap: Record<Position, string> = {
171
- 'above': 'insetBlock', // TODO: when flipping to the before/after position, we should use the `inset-inline` property instead.
172
- 'below': 'insetBlock',
173
- 'before': 'insetInline',
174
- 'after': 'insetInline',
175
- 'above-start': 'insetBlock',
176
- 'above-end': 'insetBlock',
177
- 'below-start': 'insetBlock',
178
- 'below-end': 'insetBlock',
179
- 'before-start': 'insetInline',
180
- 'before-end': 'insetInline',
181
- 'after-start': 'insetInline',
182
- 'after-end': 'insetInline',
183
- }
184
-
185
96
  export function usePositioningOptions(options: PositioningOptions) {
186
97
  const { position = 'below' } = options
187
98
 
@@ -1,5 +1,4 @@
1
1
  'use client'
2
- import { useRefObject, useUniqueId } from '#hook'
3
2
  import {
4
3
  cloneElement,
5
4
  createElement,
@@ -7,16 +6,18 @@ import {
7
6
  useLayoutEffect,
8
7
  useRef,
9
8
  } from 'react'
9
+ import { useRefObject } from '../react/useRefObject'
10
+ import { useUniqueId } from '../react/useUniqueId'
10
11
  import { OverlayContext } from './context'
11
12
  import { useAnchor } from './useAnchor'
13
+ import { useLightDismiss } from './useLightDismiss'
12
14
  import {
13
- useLightDismiss,
14
15
  useOverlay,
15
- useReturnFocus,
16
16
  type Overlay,
17
17
  type OverlayAnchorProps,
18
18
  type ToggleCallback,
19
- } from '.'
19
+ } from './useOverlay'
20
+ import { useReturnFocus } from './useReturnFocus'
20
21
 
21
22
  type DialogTag = 'dialog'
22
23
 
@@ -1,7 +1,7 @@
1
1
  'use client'
2
- import { useDefault } from '#hook'
3
- import type { GlobalAttributes } from '#hook/react/element.d'
4
2
  import { useCallback, useLayoutEffect, useMemo, useRef } from 'react'
3
+ import { useDefault } from '../form/useDefault'
4
+ import type { GlobalAttributes } from '../react/element.d'
5
5
 
6
6
  export interface OverlayAnchorProps
7
7
  extends GlobalAttributes, React.AriaAttributes, React.RefAttributes<Element> {
@@ -1,15 +1,4 @@
1
1
  'use client'
2
- import {
3
- Keyboard,
4
- useController,
5
- useRefCallback,
6
- useRefObject,
7
- useUniqueId,
8
- type KeyboardOptions,
9
- type KeyboardProps,
10
- type NavigationDirection,
11
- } from '#hook'
12
- import type { HTMLElementRef } from '#hook/react/element.d'
13
2
  import {
14
3
  cloneElement,
15
4
  createElement,
@@ -17,6 +6,17 @@ import {
17
6
  useLayoutEffect,
18
7
  useRef,
19
8
  } from 'react'
9
+ import {
10
+ Keyboard,
11
+ type KeyboardOptions,
12
+ type KeyboardProps,
13
+ type NavigationDirection,
14
+ } from '../accessibility/keyboard/Keyboard'
15
+ import { useController } from '../accessibility/keyboard/useController'
16
+ import type { HTMLElementRef } from '../react/element.d'
17
+ import { useRefCallback } from '../react/useRefCallback'
18
+ import { useRefObject } from '../react/useRefObject'
19
+ import { useUniqueId } from '../react/useUniqueId'
20
20
  import { OverlayContext } from './context'
21
21
  import { useAnchor } from './useAnchor'
22
22
  import { useLightDismiss } from './useLightDismiss'
@@ -168,6 +168,7 @@ export function usePopover<T extends React.HTMLElementType = 'div'>(
168
168
  children,
169
169
  }
170
170
 
171
+ // eslint-disable-next-line react-hooks/refs
171
172
  positionedProps.children = createElement(
172
173
  OverlayContext,
173
174
  { value: overlay },
@@ -16,12 +16,17 @@ import { isEqual } from 'lodash-es'
16
16
  import { useEffect, useLayoutEffect, useRef, useState } from 'react'
17
17
  import { flushSync } from 'react-dom'
18
18
  import { refValue, type RefValue } from '../react'
19
- import type { Position } from './useAnchorPositioning'
20
- import {
19
+ import type { Position } from './style/positioning.css'
20
+ import { placementMap, positionMap } from './style/positioning.css'
21
+ import { usePositioningOptions } from './useAnchorPositioning'
22
+
23
+ export {
21
24
  placementMap,
25
+ Position,
26
+ positionAreaMap,
27
+ positionAxisMap,
22
28
  positionMap,
23
- usePositioningOptions,
24
- } from './useAnchorPositioning'
29
+ } from './style/positioning.css'
25
30
 
26
31
  export interface PositioningOptions {
27
32
  disabled?: boolean | undefined
@@ -64,8 +69,9 @@ export function usePositioning(
64
69
  {
65
70
  const ref = useRef(_options)
66
71
 
72
+ // eslint-disable-next-line react-hooks/refs
67
73
  if (isEqual(_options, ref.current)) {
68
- // eslint-disable-next-line react-hooks/immutability
74
+ // eslint-disable-next-line react-hooks/immutability, react-hooks/refs
69
75
  _options = ref.current
70
76
  }
71
77
 
@@ -95,7 +101,7 @@ export function usePositioning(
95
101
  const { signal } = (controller = new AbortController())
96
102
 
97
103
  try {
98
- const isRTL = await platform.isRTL(positionedEl) // https://github.com/floating-ui/floating-ui/blob/1b76112bd89dfe1822248e8d6a72c1e73dad8254/packages/core/src/computePosition.ts#L24
104
+ const isRTL = await platform.isRTL(positionedEl) // https://github.com/floating-ui/floating-ui/blob/c3042f1f37d96dfadff1d8894daa31e120d89ed4/packages/core/src/computePosition.ts#L35
99
105
  const placement = resolve(positionMap[options.position], isRTL)
100
106
  const fallbackPlacements = options.fallback.map((position) =>
101
107
  resolve(positionMap[position], isRTL)