chiplet 0.3.0 → 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 (279) hide show
  1. package/README.md +2 -5
  2. package/dist/assets/positioning.css.ts.vanilla-BVOg9Lwj.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/style/{index.css.vanilla.js → index.css.js} +5 -5
  12. package/dist/component/button/style/index.css.js.map +1 -0
  13. package/dist/component/checkbox/Checkbox.js +4 -18
  14. package/dist/component/checkbox/Checkbox.js.map +1 -1
  15. package/dist/component/checkbox/CheckboxGroup.js +2 -17
  16. package/dist/component/checkbox/CheckboxGroup.js.map +1 -1
  17. package/dist/component/checkbox/Radio.js +2 -17
  18. package/dist/component/checkbox/Radio.js.map +1 -1
  19. package/dist/component/checkbox/RadioGroup.js +2 -17
  20. package/dist/component/checkbox/RadioGroup.js.map +1 -1
  21. package/dist/component/checkbox/Switch.js +1 -1
  22. package/dist/component/checkbox/icon/index.js +0 -29
  23. package/dist/component/checkbox/icon/index.js.map +1 -1
  24. package/dist/component/checkbox/style/{index.css.vanilla.js → index.css.js} +4 -5
  25. package/dist/component/checkbox/style/index.css.js.map +1 -0
  26. package/dist/component/header/Header.js +1 -1
  27. package/dist/component/header/style/index.css.js +7 -0
  28. package/dist/component/header/style/index.css.js.map +1 -0
  29. package/dist/component/index.js +20 -19
  30. package/dist/component/index.js.map +1 -1
  31. package/dist/component/input/Input.js +2 -17
  32. package/dist/component/input/Input.js.map +1 -1
  33. package/dist/component/input/SearchInput.js +3 -6
  34. package/dist/component/input/SearchInput.js.map +1 -1
  35. package/dist/component/input/style/{index.css.vanilla.js → index.css.js} +5 -5
  36. package/dist/component/input/style/index.css.js.map +1 -0
  37. package/dist/component/menu/Menu.js +2 -28
  38. package/dist/component/menu/Menu.js.map +1 -1
  39. package/dist/component/menu/MenuButton.js +1 -3
  40. package/dist/component/menu/MenuButton.js.map +1 -1
  41. package/dist/component/menu/MenuItem.js +2 -18
  42. package/dist/component/menu/MenuItem.js.map +1 -1
  43. package/dist/component/menu/MenuItemCheckbox.js +4 -31
  44. package/dist/component/menu/MenuItemCheckbox.js.map +1 -1
  45. package/dist/component/menu/MenuItemRadio.js +5 -32
  46. package/dist/component/menu/MenuItemRadio.js.map +1 -1
  47. package/dist/component/menu/renderMenuItem.js +1 -1
  48. package/dist/component/popover/Dialog.js +2 -17
  49. package/dist/component/popover/Dialog.js.map +1 -1
  50. package/dist/component/popover/DismissButton.js +2 -19
  51. package/dist/component/popover/DismissButton.js.map +1 -1
  52. package/dist/component/popover/Popover.js +2 -17
  53. package/dist/component/popover/Popover.js.map +1 -1
  54. package/dist/component/popover/ShadowRoot.js +34 -0
  55. package/dist/component/popover/ShadowRoot.js.map +1 -0
  56. package/dist/component/popover/Tooltip.js +4 -18
  57. package/dist/component/popover/Tooltip.js.map +1 -1
  58. package/dist/component/popover/index.js +1 -0
  59. package/dist/component/popover/index.js.map +1 -1
  60. package/dist/component/popover/style/{index.css.vanilla.js → index.css.js} +5 -5
  61. package/dist/component/popover/style/index.css.js.map +1 -0
  62. package/dist/component/progress/Spinner.js +1 -1
  63. package/dist/component/progress/style/{index.css.vanilla.js → index.css.js} +4 -5
  64. package/dist/component/progress/style/index.css.js.map +1 -0
  65. package/dist/component/select/AutoComplete.js +7 -30
  66. package/dist/component/select/AutoComplete.js.map +1 -1
  67. package/dist/component/select/Group.js +2 -17
  68. package/dist/component/select/Group.js.map +1 -1
  69. package/dist/component/select/Option.js +6 -21
  70. package/dist/component/select/Option.js.map +1 -1
  71. package/dist/component/select/Select.js +6 -29
  72. package/dist/component/select/Select.js.map +1 -1
  73. package/dist/component/select/Separator.js +1 -1
  74. package/dist/component/select/style/{index.css.vanilla.js → index.css.js} +5 -5
  75. package/dist/component/select/style/index.css.js.map +1 -0
  76. package/dist/component/style/article.css.js +6 -0
  77. package/dist/component/style/article.css.js.map +1 -0
  78. package/dist/component/style/index.js +1 -1
  79. package/dist/component/typography/Body1.js +1 -1
  80. package/dist/component/typography/Body2.js +1 -1
  81. package/dist/component/typography/Body3.js +1 -1
  82. package/dist/component/typography/Caption1.js +1 -1
  83. package/dist/component/typography/Caption2.js +1 -1
  84. package/dist/component/typography/Heading1.js +1 -1
  85. package/dist/component/typography/Heading2.js +1 -1
  86. package/dist/component/typography/Heading3.js +1 -1
  87. package/dist/component/typography/Heading4.js +1 -1
  88. package/dist/component/typography/style/{index.css.vanilla.js → index.css.js} +4 -5
  89. package/dist/component/typography/style/index.css.js.map +1 -0
  90. package/dist/hook/accessibility/keyboard/Keyboard.js +6 -18
  91. package/dist/hook/accessibility/keyboard/Keyboard.js.map +1 -1
  92. package/dist/hook/accessibility/keyboard/Roving.js +0 -15
  93. package/dist/hook/accessibility/keyboard/Roving.js.map +1 -1
  94. package/dist/hook/accessibility/keyboard/context/index.js.map +1 -1
  95. package/dist/hook/accessibility/keyboard/hook/useLastFocused.js +1 -4
  96. package/dist/hook/accessibility/keyboard/hook/useLastFocused.js.map +1 -1
  97. package/dist/hook/accessibility/keyboard/hook/useNavigate.js.map +1 -1
  98. package/dist/hook/accessibility/keyboard/resolve.js +1 -4
  99. package/dist/hook/accessibility/keyboard/resolve.js.map +1 -1
  100. package/dist/hook/accessibility/keyboard/sort.js +0 -3
  101. package/dist/hook/accessibility/keyboard/sort.js.map +1 -1
  102. package/dist/hook/accessibility/keyboard/tree.js +1 -4
  103. package/dist/hook/accessibility/keyboard/tree.js.map +1 -1
  104. package/dist/hook/accessibility/keyboard/useController.js +2 -15
  105. package/dist/hook/accessibility/keyboard/useController.js.map +1 -1
  106. package/dist/hook/accessibility/keyboard/useKeyboard.js +2 -16
  107. package/dist/hook/accessibility/keyboard/useKeyboard.js.map +1 -1
  108. package/dist/hook/document/useHighlight.js +1 -4
  109. package/dist/hook/document/useHighlight.js.map +1 -1
  110. package/dist/hook/form/context/index.js.map +1 -1
  111. package/dist/hook/form/useAutoComplete.js +2 -16
  112. package/dist/hook/form/useAutoComplete.js.map +1 -1
  113. package/dist/hook/form/useChange.js.map +1 -1
  114. package/dist/hook/form/useCheckbox.js +0 -16
  115. package/dist/hook/form/useCheckbox.js.map +1 -1
  116. package/dist/hook/form/useChecked.js +1 -14
  117. package/dist/hook/form/useChecked.js.map +1 -1
  118. package/dist/hook/form/useForm.js +1 -15
  119. package/dist/hook/form/useForm.js.map +1 -1
  120. package/dist/hook/form/useGroup.js +1 -14
  121. package/dist/hook/form/useGroup.js.map +1 -1
  122. package/dist/hook/form/useName.js.map +1 -1
  123. package/dist/hook/form/useOption.js +0 -16
  124. package/dist/hook/form/useOption.js.map +1 -1
  125. package/dist/hook/form/useRadio.js +0 -16
  126. package/dist/hook/form/useRadio.js.map +1 -1
  127. package/dist/hook/form/useSelect.js +0 -16
  128. package/dist/hook/form/useSelect.js.map +1 -1
  129. package/dist/hook/form/useValue.js +0 -15
  130. package/dist/hook/form/useValue.js.map +1 -1
  131. package/dist/hook/index.js +22 -21
  132. package/dist/hook/index.js.map +1 -1
  133. package/dist/hook/popover/context/index.js.map +1 -1
  134. package/dist/hook/popover/index.js +2 -1
  135. package/dist/hook/popover/index.js.map +1 -1
  136. package/dist/hook/popover/style/positioning.css.js +13 -0
  137. package/dist/hook/popover/style/positioning.css.js.map +1 -0
  138. package/dist/hook/popover/useAnchorPositioning.js +6 -88
  139. package/dist/hook/popover/useAnchorPositioning.js.map +1 -1
  140. package/dist/hook/popover/useDialog.js +1 -15
  141. package/dist/hook/popover/useDialog.js.map +1 -1
  142. package/dist/hook/popover/useLightDismiss.js +1 -4
  143. package/dist/hook/popover/useLightDismiss.js.map +1 -1
  144. package/dist/hook/popover/useOverlay.js +0 -15
  145. package/dist/hook/popover/useOverlay.js.map +1 -1
  146. package/dist/hook/popover/usePopover.js +1 -12
  147. package/dist/hook/popover/usePopover.js.map +1 -1
  148. package/dist/hook/popover/usePositioning.js +4 -5
  149. package/dist/hook/popover/usePositioning.js.map +1 -1
  150. package/dist/hook/popover/useTooltip.js +0 -13
  151. package/dist/hook/popover/useTooltip.js.map +1 -1
  152. package/dist/hook/react/refValue.js +0 -3
  153. package/dist/hook/react/refValue.js.map +1 -1
  154. package/dist/hook/react/useActivate.js +1 -4
  155. package/dist/hook/react/useActivate.js.map +1 -1
  156. package/dist/hook/react/useConst.js.map +1 -1
  157. package/dist/hook/react/useInteractive.js +1 -4
  158. package/dist/hook/react/useInteractive.js.map +1 -1
  159. package/dist/hook/react/useRefCallback.js.map +1 -1
  160. package/dist/hook/react/useUniqueId.js +1 -4
  161. package/dist/hook/react/useUniqueId.js.map +1 -1
  162. package/dist/index.js +109 -109
  163. package/dist/infra/index.js +1 -1
  164. package/dist/infra/logging/logger.js +7 -8
  165. package/dist/infra/logging/logger.js.map +1 -1
  166. package/dist/theme/defineTheme.js +0 -3
  167. package/dist/theme/defineTheme.js.map +1 -1
  168. package/dist/theme/{global.css.vanilla.js → global.css.js} +4 -4
  169. package/dist/theme/global.css.js.map +1 -0
  170. package/dist/theme/index.js +3 -3
  171. package/dist/theme/{theme.css.vanilla.js → theme.css.js} +3 -3
  172. package/dist/theme/theme.css.js.map +1 -0
  173. package/dist/theme/{token.css.vanilla.js → token.css.js} +2 -2
  174. package/dist/theme/token.css.js.map +1 -0
  175. package/dist/util/array/index.js +0 -1
  176. package/dist/util/array/index.js.map +1 -1
  177. package/dist/util/document/{accessibility.css.vanilla.js → accessibility.css.js} +1 -1
  178. package/dist/util/document/accessibility.css.js.map +1 -0
  179. package/dist/util/document/index.js +1 -1
  180. package/dist/util/index.js +28 -30
  181. package/dist/util/index.js.map +1 -1
  182. package/dist/util/linked-list/buildLinkedList.js.map +1 -1
  183. package/dist/util/lock/lock.js +0 -2
  184. package/dist/util/lock/lock.js.map +1 -1
  185. package/dist/util/random/index.js +0 -1
  186. package/dist/util/random/index.js.map +1 -1
  187. package/dist/util/tree/addTreeNode.js.map +1 -1
  188. package/dist/util/tree/attachChild.js.map +1 -1
  189. package/dist/util/tree/buildTree.js.map +1 -1
  190. package/dist/util/tree/detachChild.js.map +1 -1
  191. package/dist/util/tree/iterateChildren.js.map +1 -1
  192. package/dist/util/tree/iterateTree.js.map +1 -1
  193. package/package.json +34 -32
  194. package/src/component/button/Button.tsx +4 -5
  195. package/src/component/button/IconButton.tsx +1 -1
  196. package/src/component/button/LinkButton.tsx +12 -6
  197. package/src/component/checkbox/Checkbox.tsx +1 -0
  198. package/src/component/checkbox/icon/index.ts +1 -1
  199. package/src/component/input/SearchInput.tsx +1 -1
  200. package/src/component/menu/Menu.tsx +1 -1
  201. package/src/component/menu/MenuItemCheckbox.tsx +1 -1
  202. package/src/component/menu/MenuItemRadio.tsx +1 -1
  203. package/src/component/popover/ShadowRoot.tsx +42 -0
  204. package/src/component/popover/Tooltip.tsx +2 -2
  205. package/src/component/popover/index.ts +1 -0
  206. package/src/component/select/AutoComplete.tsx +3 -7
  207. package/src/component/select/Select.tsx +3 -7
  208. package/src/hook/accessibility/keyboard/Keyboard.tsx +1 -1
  209. package/src/hook/accessibility/keyboard/Roving.tsx +1 -1
  210. package/src/hook/accessibility/keyboard/context/index.ts +1 -1
  211. package/src/hook/accessibility/keyboard/hook/useLastFocused.ts +1 -1
  212. package/src/hook/accessibility/keyboard/hook/useNavigate.ts +1 -1
  213. package/src/hook/accessibility/keyboard/resolve.ts +1 -1
  214. package/src/hook/accessibility/keyboard/useController.ts +3 -2
  215. package/src/hook/accessibility/keyboard/useKeyboard.ts +3 -2
  216. package/src/hook/form/context/index.ts +1 -1
  217. package/src/hook/form/useAutoComplete.ts +14 -14
  218. package/src/hook/form/useChange.ts +1 -1
  219. package/src/hook/form/useCheckbox.ts +2 -2
  220. package/src/hook/form/useChecked.ts +3 -2
  221. package/src/hook/form/useForm.ts +1 -1
  222. package/src/hook/form/useGroup.ts +4 -3
  223. package/src/hook/form/useName.ts +1 -1
  224. package/src/hook/form/useOption.ts +2 -2
  225. package/src/hook/form/useRadio.ts +2 -2
  226. package/src/hook/form/useSelect.ts +15 -12
  227. package/src/hook/form/useValue.ts +3 -2
  228. package/src/hook/popover/context/index.ts +1 -1
  229. package/src/hook/popover/style/positioning.css.ts +112 -0
  230. package/src/hook/popover/useAnchorPositioning.ts +15 -104
  231. package/src/hook/popover/useDialog.ts +5 -4
  232. package/src/hook/popover/useOverlay.ts +2 -2
  233. package/src/hook/popover/usePopover.ts +11 -11
  234. package/src/hook/popover/usePositioning.ts +10 -5
  235. package/src/hook/popover/useTooltip.ts +6 -6
  236. package/src/hook/react/useConst.ts +1 -0
  237. package/src/hook/react/useRefCallback.ts +1 -1
  238. package/src/infra/logging/logger.ts +32 -18
  239. package/src/theme/global.css.ts +1 -1
  240. package/src/util/array/index.ts +0 -1
  241. package/src/util/document/accessibility.css.ts +1 -1
  242. package/src/util/linked-list/buildLinkedList.ts +1 -1
  243. package/src/util/random/index.ts +0 -1
  244. package/src/util/tree/addTreeNode.ts +1 -1
  245. package/src/util/tree/attachChild.ts +1 -1
  246. package/src/util/tree/buildTree.ts +1 -1
  247. package/src/util/tree/detachChild.ts +1 -1
  248. package/src/util/tree/iterateChildren.ts +1 -1
  249. package/src/util/tree/iterateTree.ts +1 -1
  250. package/dist/component/button/style/index.css.vanilla.js.map +0 -1
  251. package/dist/component/checkbox/style/index.css.vanilla.js.map +0 -1
  252. package/dist/component/header/style/index.css.vanilla.js +0 -7
  253. package/dist/component/header/style/index.css.vanilla.js.map +0 -1
  254. package/dist/component/input/style/index.css.vanilla.js.map +0 -1
  255. package/dist/component/popover/style/index.css.vanilla.js.map +0 -1
  256. package/dist/component/progress/style/index.css.vanilla.js.map +0 -1
  257. package/dist/component/select/style/index.css.vanilla.js.map +0 -1
  258. package/dist/component/style/article.css.vanilla.js +0 -6
  259. package/dist/component/style/article.css.vanilla.js.map +0 -1
  260. package/dist/component/typography/style/index.css.vanilla.js.map +0 -1
  261. package/dist/theme/global.css.vanilla.js.map +0 -1
  262. package/dist/theme/theme.css.vanilla.js.map +0 -1
  263. package/dist/theme/token.css.vanilla.js.map +0 -1
  264. package/dist/util/array/fromAsync.js +0 -11
  265. package/dist/util/array/fromAsync.js.map +0 -1
  266. package/dist/util/document/accessibility.css.vanilla.js.map +0 -1
  267. package/src/util/array/fromAsync.ts +0 -11
  268. /package/dist/{article.css → assets/article.css.ts.vanilla-s_HEpsy3.css} +0 -0
  269. /package/dist/{global.css → assets/global.css.ts.vanilla-CTwjHiaM.css} +0 -0
  270. /package/dist/{index8.css → assets/index.css.ts.vanilla-9qGDrdgn.css} +0 -0
  271. /package/dist/{index6.css → assets/index.css.ts.vanilla-BsBngo8U.css} +0 -0
  272. /package/dist/{index2.css → assets/index.css.ts.vanilla-CVNLkHc9.css} +0 -0
  273. /package/dist/{index3.css → assets/index.css.ts.vanilla-C_RzxiYH.css} +0 -0
  274. /package/dist/{index5.css → assets/index.css.ts.vanilla-CvQQLJ-M.css} +0 -0
  275. /package/dist/{index.css → assets/index.css.ts.vanilla-DGmHFJbF.css} +0 -0
  276. /package/dist/{index4.css → assets/index.css.ts.vanilla-VHSAjLub.css} +0 -0
  277. /package/dist/{index7.css → assets/index.css.ts.vanilla-kgyRRvgH.css} +0 -0
  278. /package/dist/{theme.css → assets/theme.css.ts.vanilla-Bjn8sb_B.css} +0 -0
  279. /package/dist/{token.css → assets/token.css.ts.vanilla-B3LtFaO7.css} +0 -0
@@ -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,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,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,
@@ -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'
@@ -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
@@ -96,7 +101,7 @@ export function usePositioning(
96
101
  const { signal } = (controller = new AbortController())
97
102
 
98
103
  try {
99
- 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
100
105
  const placement = resolve(positionMap[options.position], isRTL)
101
106
  const fallbackPlacements = options.fallback.map((position) =>
102
107
  resolve(positionMap[position], isRTL)
@@ -1,5 +1,4 @@
1
1
  'use client'
2
- import { useRefObject, useUniqueId } from '#hook'
3
2
  import {
4
3
  cloneElement,
5
4
  useCallback,
@@ -7,16 +6,17 @@ import {
7
6
  useLayoutEffect,
8
7
  useRef,
9
8
  } from 'react'
9
+ import { useRefObject } from '../react/useRefObject'
10
+ import { useUniqueId } from '../react/useUniqueId'
11
+ import { useLightDismiss } from './useLightDismiss'
10
12
  import {
11
- useLightDismiss,
12
13
  useOverlay,
13
- usePositioning,
14
- useReturnFocus,
15
14
  type Overlay,
16
15
  type OverlayAnchorProps,
17
- type PositioningOptions,
18
16
  type ToggleCallback,
19
- } from '.'
17
+ } from './useOverlay'
18
+ import { usePositioning, type PositioningOptions } from './usePositioning'
19
+ import { useReturnFocus } from './useReturnFocus'
20
20
 
21
21
  type TooltipTag = 'div'
22
22
 
@@ -1,6 +1,7 @@
1
1
  import { useMemo } from 'react'
2
2
 
3
3
  export function useConst<T>(initialize: () => T): T {
4
+ // eslint-disable-next-line react-compiler/react-compiler
4
5
  // eslint-disable-next-line react-hooks/exhaustive-deps, react-hooks/use-memo
5
6
  return useMemo(initialize, [])
6
7
  }
@@ -13,7 +13,7 @@ export function useRefCallback<T>(ref: Ref<T> | undefined) {
13
13
  if (typeof ref === 'function') {
14
14
  destroy = ref(current)
15
15
  } else if (ref) {
16
- // eslint-disable-next-line react-hooks/immutability
16
+ // eslint-disable-next-line react-hooks/immutability, react-compiler/react-compiler
17
17
  ref.current = current
18
18
  }
19
19