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.
- package/README.md +2 -5
- package/dist/assets/positioning.css.ts.vanilla-BVOg9Lwj.css +60 -0
- package/dist/component/button/Button.js +5 -5
- package/dist/component/button/Button.js.map +1 -1
- package/dist/component/button/IconButton.js +1 -1
- package/dist/component/button/IconButton.js.map +1 -1
- package/dist/component/button/Interactive.js +2 -17
- package/dist/component/button/Interactive.js.map +1 -1
- package/dist/component/button/LinkButton.js +7 -5
- package/dist/component/button/LinkButton.js.map +1 -1
- package/dist/component/button/style/{index.css.vanilla.js → index.css.js} +5 -5
- package/dist/component/button/style/index.css.js.map +1 -0
- package/dist/component/checkbox/Checkbox.js +4 -18
- package/dist/component/checkbox/Checkbox.js.map +1 -1
- package/dist/component/checkbox/CheckboxGroup.js +2 -17
- package/dist/component/checkbox/CheckboxGroup.js.map +1 -1
- package/dist/component/checkbox/Radio.js +2 -17
- package/dist/component/checkbox/Radio.js.map +1 -1
- package/dist/component/checkbox/RadioGroup.js +2 -17
- package/dist/component/checkbox/RadioGroup.js.map +1 -1
- package/dist/component/checkbox/Switch.js +1 -1
- package/dist/component/checkbox/icon/index.js +0 -29
- package/dist/component/checkbox/icon/index.js.map +1 -1
- package/dist/component/checkbox/style/{index.css.vanilla.js → index.css.js} +4 -5
- package/dist/component/checkbox/style/index.css.js.map +1 -0
- package/dist/component/header/Header.js +1 -1
- package/dist/component/header/style/index.css.js +7 -0
- package/dist/component/header/style/index.css.js.map +1 -0
- package/dist/component/index.js +20 -19
- package/dist/component/index.js.map +1 -1
- package/dist/component/input/Input.js +2 -17
- package/dist/component/input/Input.js.map +1 -1
- package/dist/component/input/SearchInput.js +3 -6
- package/dist/component/input/SearchInput.js.map +1 -1
- package/dist/component/input/style/{index.css.vanilla.js → index.css.js} +5 -5
- package/dist/component/input/style/index.css.js.map +1 -0
- package/dist/component/menu/Menu.js +2 -28
- package/dist/component/menu/Menu.js.map +1 -1
- package/dist/component/menu/MenuButton.js +1 -3
- package/dist/component/menu/MenuButton.js.map +1 -1
- package/dist/component/menu/MenuItem.js +2 -18
- package/dist/component/menu/MenuItem.js.map +1 -1
- package/dist/component/menu/MenuItemCheckbox.js +4 -31
- package/dist/component/menu/MenuItemCheckbox.js.map +1 -1
- package/dist/component/menu/MenuItemRadio.js +5 -32
- package/dist/component/menu/MenuItemRadio.js.map +1 -1
- package/dist/component/menu/renderMenuItem.js +1 -1
- package/dist/component/popover/Dialog.js +2 -17
- package/dist/component/popover/Dialog.js.map +1 -1
- package/dist/component/popover/DismissButton.js +2 -19
- package/dist/component/popover/DismissButton.js.map +1 -1
- package/dist/component/popover/Popover.js +2 -17
- package/dist/component/popover/Popover.js.map +1 -1
- package/dist/component/popover/ShadowRoot.js +34 -0
- package/dist/component/popover/ShadowRoot.js.map +1 -0
- package/dist/component/popover/Tooltip.js +4 -18
- package/dist/component/popover/Tooltip.js.map +1 -1
- package/dist/component/popover/index.js +1 -0
- package/dist/component/popover/index.js.map +1 -1
- package/dist/component/popover/style/{index.css.vanilla.js → index.css.js} +5 -5
- package/dist/component/popover/style/index.css.js.map +1 -0
- package/dist/component/progress/Spinner.js +1 -1
- package/dist/component/progress/style/{index.css.vanilla.js → index.css.js} +4 -5
- package/dist/component/progress/style/index.css.js.map +1 -0
- package/dist/component/select/AutoComplete.js +7 -30
- package/dist/component/select/AutoComplete.js.map +1 -1
- package/dist/component/select/Group.js +2 -17
- package/dist/component/select/Group.js.map +1 -1
- package/dist/component/select/Option.js +6 -21
- package/dist/component/select/Option.js.map +1 -1
- package/dist/component/select/Select.js +6 -29
- package/dist/component/select/Select.js.map +1 -1
- package/dist/component/select/Separator.js +1 -1
- package/dist/component/select/style/{index.css.vanilla.js → index.css.js} +5 -5
- package/dist/component/select/style/index.css.js.map +1 -0
- package/dist/component/style/article.css.js +6 -0
- package/dist/component/style/article.css.js.map +1 -0
- package/dist/component/style/index.js +1 -1
- package/dist/component/typography/Body1.js +1 -1
- package/dist/component/typography/Body2.js +1 -1
- package/dist/component/typography/Body3.js +1 -1
- package/dist/component/typography/Caption1.js +1 -1
- package/dist/component/typography/Caption2.js +1 -1
- package/dist/component/typography/Heading1.js +1 -1
- package/dist/component/typography/Heading2.js +1 -1
- package/dist/component/typography/Heading3.js +1 -1
- package/dist/component/typography/Heading4.js +1 -1
- package/dist/component/typography/style/{index.css.vanilla.js → index.css.js} +4 -5
- package/dist/component/typography/style/index.css.js.map +1 -0
- package/dist/hook/accessibility/keyboard/Keyboard.js +6 -18
- package/dist/hook/accessibility/keyboard/Keyboard.js.map +1 -1
- package/dist/hook/accessibility/keyboard/Roving.js +0 -15
- package/dist/hook/accessibility/keyboard/Roving.js.map +1 -1
- package/dist/hook/accessibility/keyboard/context/index.js.map +1 -1
- package/dist/hook/accessibility/keyboard/hook/useLastFocused.js +1 -4
- package/dist/hook/accessibility/keyboard/hook/useLastFocused.js.map +1 -1
- package/dist/hook/accessibility/keyboard/hook/useNavigate.js.map +1 -1
- package/dist/hook/accessibility/keyboard/resolve.js +1 -4
- package/dist/hook/accessibility/keyboard/resolve.js.map +1 -1
- package/dist/hook/accessibility/keyboard/sort.js +0 -3
- package/dist/hook/accessibility/keyboard/sort.js.map +1 -1
- package/dist/hook/accessibility/keyboard/tree.js +1 -4
- package/dist/hook/accessibility/keyboard/tree.js.map +1 -1
- package/dist/hook/accessibility/keyboard/useController.js +2 -15
- package/dist/hook/accessibility/keyboard/useController.js.map +1 -1
- package/dist/hook/accessibility/keyboard/useKeyboard.js +2 -16
- package/dist/hook/accessibility/keyboard/useKeyboard.js.map +1 -1
- package/dist/hook/document/useHighlight.js +1 -4
- package/dist/hook/document/useHighlight.js.map +1 -1
- package/dist/hook/form/context/index.js.map +1 -1
- package/dist/hook/form/useAutoComplete.js +2 -16
- package/dist/hook/form/useAutoComplete.js.map +1 -1
- package/dist/hook/form/useChange.js.map +1 -1
- package/dist/hook/form/useCheckbox.js +0 -16
- package/dist/hook/form/useCheckbox.js.map +1 -1
- package/dist/hook/form/useChecked.js +1 -14
- package/dist/hook/form/useChecked.js.map +1 -1
- package/dist/hook/form/useForm.js +1 -15
- package/dist/hook/form/useForm.js.map +1 -1
- package/dist/hook/form/useGroup.js +1 -14
- package/dist/hook/form/useGroup.js.map +1 -1
- package/dist/hook/form/useName.js.map +1 -1
- package/dist/hook/form/useOption.js +0 -16
- package/dist/hook/form/useOption.js.map +1 -1
- package/dist/hook/form/useRadio.js +0 -16
- package/dist/hook/form/useRadio.js.map +1 -1
- package/dist/hook/form/useSelect.js +0 -16
- package/dist/hook/form/useSelect.js.map +1 -1
- package/dist/hook/form/useValue.js +0 -15
- package/dist/hook/form/useValue.js.map +1 -1
- package/dist/hook/index.js +22 -21
- package/dist/hook/index.js.map +1 -1
- package/dist/hook/popover/context/index.js.map +1 -1
- package/dist/hook/popover/index.js +2 -1
- package/dist/hook/popover/index.js.map +1 -1
- package/dist/hook/popover/style/positioning.css.js +13 -0
- package/dist/hook/popover/style/positioning.css.js.map +1 -0
- package/dist/hook/popover/useAnchorPositioning.js +6 -88
- package/dist/hook/popover/useAnchorPositioning.js.map +1 -1
- package/dist/hook/popover/useDialog.js +1 -15
- package/dist/hook/popover/useDialog.js.map +1 -1
- package/dist/hook/popover/useLightDismiss.js +1 -4
- package/dist/hook/popover/useLightDismiss.js.map +1 -1
- package/dist/hook/popover/useOverlay.js +0 -15
- package/dist/hook/popover/useOverlay.js.map +1 -1
- package/dist/hook/popover/usePopover.js +1 -12
- package/dist/hook/popover/usePopover.js.map +1 -1
- package/dist/hook/popover/usePositioning.js +4 -5
- package/dist/hook/popover/usePositioning.js.map +1 -1
- package/dist/hook/popover/useTooltip.js +0 -13
- package/dist/hook/popover/useTooltip.js.map +1 -1
- package/dist/hook/react/refValue.js +0 -3
- package/dist/hook/react/refValue.js.map +1 -1
- package/dist/hook/react/useActivate.js +1 -4
- package/dist/hook/react/useActivate.js.map +1 -1
- package/dist/hook/react/useConst.js.map +1 -1
- package/dist/hook/react/useInteractive.js +1 -4
- package/dist/hook/react/useInteractive.js.map +1 -1
- package/dist/hook/react/useRefCallback.js.map +1 -1
- package/dist/hook/react/useUniqueId.js +1 -4
- package/dist/hook/react/useUniqueId.js.map +1 -1
- package/dist/index.js +109 -109
- package/dist/infra/index.js +1 -1
- package/dist/infra/logging/logger.js +7 -8
- package/dist/infra/logging/logger.js.map +1 -1
- package/dist/theme/defineTheme.js +0 -3
- package/dist/theme/defineTheme.js.map +1 -1
- package/dist/theme/{global.css.vanilla.js → global.css.js} +4 -4
- package/dist/theme/global.css.js.map +1 -0
- package/dist/theme/index.js +3 -3
- package/dist/theme/{theme.css.vanilla.js → theme.css.js} +3 -3
- package/dist/theme/theme.css.js.map +1 -0
- package/dist/theme/{token.css.vanilla.js → token.css.js} +2 -2
- package/dist/theme/token.css.js.map +1 -0
- package/dist/util/array/index.js +0 -1
- package/dist/util/array/index.js.map +1 -1
- package/dist/util/document/{accessibility.css.vanilla.js → accessibility.css.js} +1 -1
- package/dist/util/document/accessibility.css.js.map +1 -0
- package/dist/util/document/index.js +1 -1
- package/dist/util/index.js +28 -30
- package/dist/util/index.js.map +1 -1
- package/dist/util/linked-list/buildLinkedList.js.map +1 -1
- package/dist/util/lock/lock.js +0 -2
- package/dist/util/lock/lock.js.map +1 -1
- package/dist/util/random/index.js +0 -1
- package/dist/util/random/index.js.map +1 -1
- package/dist/util/tree/addTreeNode.js.map +1 -1
- package/dist/util/tree/attachChild.js.map +1 -1
- package/dist/util/tree/buildTree.js.map +1 -1
- package/dist/util/tree/detachChild.js.map +1 -1
- package/dist/util/tree/iterateChildren.js.map +1 -1
- package/dist/util/tree/iterateTree.js.map +1 -1
- package/package.json +34 -32
- package/src/component/button/Button.tsx +4 -5
- package/src/component/button/IconButton.tsx +1 -1
- package/src/component/button/LinkButton.tsx +12 -6
- package/src/component/checkbox/Checkbox.tsx +1 -0
- package/src/component/checkbox/icon/index.ts +1 -1
- package/src/component/input/SearchInput.tsx +1 -1
- package/src/component/menu/Menu.tsx +1 -1
- package/src/component/menu/MenuItemCheckbox.tsx +1 -1
- package/src/component/menu/MenuItemRadio.tsx +1 -1
- package/src/component/popover/ShadowRoot.tsx +42 -0
- package/src/component/popover/Tooltip.tsx +2 -2
- package/src/component/popover/index.ts +1 -0
- package/src/component/select/AutoComplete.tsx +3 -7
- package/src/component/select/Select.tsx +3 -7
- package/src/hook/accessibility/keyboard/Keyboard.tsx +1 -1
- package/src/hook/accessibility/keyboard/Roving.tsx +1 -1
- package/src/hook/accessibility/keyboard/context/index.ts +1 -1
- package/src/hook/accessibility/keyboard/hook/useLastFocused.ts +1 -1
- package/src/hook/accessibility/keyboard/hook/useNavigate.ts +1 -1
- package/src/hook/accessibility/keyboard/resolve.ts +1 -1
- package/src/hook/accessibility/keyboard/useController.ts +3 -2
- package/src/hook/accessibility/keyboard/useKeyboard.ts +3 -2
- package/src/hook/form/context/index.ts +1 -1
- package/src/hook/form/useAutoComplete.ts +14 -14
- package/src/hook/form/useChange.ts +1 -1
- package/src/hook/form/useCheckbox.ts +2 -2
- package/src/hook/form/useChecked.ts +3 -2
- package/src/hook/form/useForm.ts +1 -1
- package/src/hook/form/useGroup.ts +4 -3
- package/src/hook/form/useName.ts +1 -1
- package/src/hook/form/useOption.ts +2 -2
- package/src/hook/form/useRadio.ts +2 -2
- package/src/hook/form/useSelect.ts +15 -12
- package/src/hook/form/useValue.ts +3 -2
- package/src/hook/popover/context/index.ts +1 -1
- package/src/hook/popover/style/positioning.css.ts +112 -0
- package/src/hook/popover/useAnchorPositioning.ts +15 -104
- package/src/hook/popover/useDialog.ts +5 -4
- package/src/hook/popover/useOverlay.ts +2 -2
- package/src/hook/popover/usePopover.ts +11 -11
- package/src/hook/popover/usePositioning.ts +10 -5
- package/src/hook/popover/useTooltip.ts +6 -6
- package/src/hook/react/useConst.ts +1 -0
- package/src/hook/react/useRefCallback.ts +1 -1
- package/src/infra/logging/logger.ts +32 -18
- package/src/theme/global.css.ts +1 -1
- package/src/util/array/index.ts +0 -1
- package/src/util/document/accessibility.css.ts +1 -1
- package/src/util/linked-list/buildLinkedList.ts +1 -1
- package/src/util/random/index.ts +0 -1
- package/src/util/tree/addTreeNode.ts +1 -1
- package/src/util/tree/attachChild.ts +1 -1
- package/src/util/tree/buildTree.ts +1 -1
- package/src/util/tree/detachChild.ts +1 -1
- package/src/util/tree/iterateChildren.ts +1 -1
- package/src/util/tree/iterateTree.ts +1 -1
- package/dist/component/button/style/index.css.vanilla.js.map +0 -1
- package/dist/component/checkbox/style/index.css.vanilla.js.map +0 -1
- package/dist/component/header/style/index.css.vanilla.js +0 -7
- package/dist/component/header/style/index.css.vanilla.js.map +0 -1
- package/dist/component/input/style/index.css.vanilla.js.map +0 -1
- package/dist/component/popover/style/index.css.vanilla.js.map +0 -1
- package/dist/component/progress/style/index.css.vanilla.js.map +0 -1
- package/dist/component/select/style/index.css.vanilla.js.map +0 -1
- package/dist/component/style/article.css.vanilla.js +0 -6
- package/dist/component/style/article.css.vanilla.js.map +0 -1
- package/dist/component/typography/style/index.css.vanilla.js.map +0 -1
- package/dist/theme/global.css.vanilla.js.map +0 -1
- package/dist/theme/theme.css.vanilla.js.map +0 -1
- package/dist/theme/token.css.vanilla.js.map +0 -1
- package/dist/util/array/fromAsync.js +0 -11
- package/dist/util/array/fromAsync.js.map +0 -1
- package/dist/util/document/accessibility.css.vanilla.js.map +0 -1
- package/src/util/array/fromAsync.ts +0 -11
- /package/dist/{article.css → assets/article.css.ts.vanilla-s_HEpsy3.css} +0 -0
- /package/dist/{global.css → assets/global.css.ts.vanilla-CTwjHiaM.css} +0 -0
- /package/dist/{index8.css → assets/index.css.ts.vanilla-9qGDrdgn.css} +0 -0
- /package/dist/{index6.css → assets/index.css.ts.vanilla-BsBngo8U.css} +0 -0
- /package/dist/{index2.css → assets/index.css.ts.vanilla-CVNLkHc9.css} +0 -0
- /package/dist/{index3.css → assets/index.css.ts.vanilla-C_RzxiYH.css} +0 -0
- /package/dist/{index5.css → assets/index.css.ts.vanilla-CvQQLJ-M.css} +0 -0
- /package/dist/{index.css → assets/index.css.ts.vanilla-DGmHFJbF.css} +0 -0
- /package/dist/{index4.css → assets/index.css.ts.vanilla-VHSAjLub.css} +0 -0
- /package/dist/{index7.css → assets/index.css.ts.vanilla-kgyRRvgH.css} +0 -0
- /package/dist/{theme.css → assets/theme.css.ts.vanilla-Bjn8sb_B.css} +0 -0
- /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 {
|
|
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,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 {
|
|
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,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 {
|
|
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
|
|
package/src/hook/form/useForm.ts
CHANGED
|
@@ -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 {
|
|
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,
|
package/src/hook/form/useName.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
} from '
|
|
12
|
-
import {
|
|
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 {
|
|
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
|
|
@@ -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) =>
|
|
50
|
+
.map((position) => positionTryOptionMap[position])
|
|
45
51
|
.join(', '),
|
|
46
52
|
margin: '0',
|
|
47
|
-
inset: 'auto',
|
|
48
|
-
|
|
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 &&
|
|
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 './
|
|
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
|
-
|
|
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/
|
|
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
|
|
|
@@ -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
|
|