chiplet 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -5
- package/dist/assets/positioning.css.ts.vanilla-BLJ90UCF.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/index.js +1 -0
- package/dist/component/button/index.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 +9 -19
- 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 +7 -18
- 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 +2 -2
- package/dist/component/checkbox/Switch.js.map +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 +2 -2
- package/dist/component/header/Header.js.map +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 +21 -19
- package/dist/component/index.js.map +1 -1
- package/dist/component/input/Input.js +7 -18
- package/dist/component/input/Input.js.map +1 -1
- package/dist/component/input/SearchInput.js +7 -13
- 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 +6 -2
- package/dist/component/menu/renderMenuItem.js.map +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 +3 -18
- package/dist/component/select/Group.js.map +1 -1
- package/dist/component/select/Option.js +7 -22
- 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 -6
- 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 +18 -30
- 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/observable/useObservable.js +6 -1
- package/dist/hook/observable/useObservable.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 +16 -4
- package/dist/hook/popover/useLightDismiss.js.map +1 -1
- package/dist/hook/popover/useOverlay.js +8 -20
- package/dist/hook/popover/useOverlay.js.map +1 -1
- package/dist/hook/popover/usePopover.js +12 -23
- package/dist/hook/popover/usePopover.js.map +1 -1
- package/dist/hook/popover/usePositioning.js +10 -16
- package/dist/hook/popover/usePositioning.js.map +1 -1
- package/dist/hook/popover/useReturnFocus.js.map +1 -1
- package/dist/hook/popover/useTooltip.js +4 -15
- package/dist/hook/popover/useTooltip.js.map +1 -1
- package/dist/hook/promise/usePromise.js +1 -1
- package/dist/hook/promise/usePromise.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 +4 -4
- package/dist/hook/react/useActivate.js.map +1 -1
- package/dist/hook/react/useConst.js +3 -2
- 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 +112 -109
- package/dist/index.js.map +1 -1
- package/dist/infra/index.js +1 -1
- package/dist/infra/logging/logger.js +13 -10
- 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 +5 -3
- package/dist/theme/index.js.map +1 -1
- 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/theme/useSystemColorScheme.js +16 -16
- package/dist/theme/useSystemColorScheme.js.map +1 -1
- 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/file/readAsDataURL.js +15 -4
- package/dist/util/file/readAsDataURL.js.map +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 +7 -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 +3 -0
- 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 +49 -47
- package/src/component/button/Button.tsx +4 -5
- package/src/component/button/IconButton.tsx +1 -1
- package/src/component/button/LinkButton.tsx +14 -6
- package/src/component/button/index.ts +1 -0
- package/src/component/checkbox/Checkbox.tsx +8 -1
- package/src/component/checkbox/Radio.tsx +5 -1
- package/src/component/checkbox/Switch.tsx +1 -1
- package/src/component/checkbox/icon/index.ts +1 -1
- package/src/component/header/Header.tsx +1 -1
- package/src/component/input/Input.tsx +5 -1
- package/src/component/input/SearchInput.tsx +10 -9
- 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/menu/renderMenuItem.tsx +5 -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/Group.tsx +1 -1
- package/src/component/select/Option.tsx +1 -1
- 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 +2 -2
- package/src/hook/accessibility/keyboard/hook/useLastFocused.ts +7 -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/document/useHighlight.ts +5 -4
- 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 +20 -21
- 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/observable/useObservable.ts +14 -1
- 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 +16 -105
- package/src/hook/popover/useDialog.ts +5 -4
- package/src/hook/popover/useLightDismiss.ts +27 -0
- package/src/hook/popover/useOverlay.ts +17 -8
- package/src/hook/popover/usePopover.ts +22 -24
- package/src/hook/popover/usePositioning.ts +17 -20
- package/src/hook/popover/useReturnFocus.ts +12 -3
- package/src/hook/popover/useTooltip.ts +10 -9
- package/src/hook/promise/usePromise.ts +4 -1
- package/src/hook/react/useActivate.ts +8 -1
- package/src/hook/react/useConst.ts +3 -3
- package/src/hook/react/useRefCallback.ts +3 -1
- package/src/infra/logging/logger.ts +43 -19
- package/src/theme/global.css.ts +1 -28
- package/src/theme/index.ts +4 -0
- package/src/theme/useSystemColorScheme.ts +22 -20
- package/src/util/array/index.ts +0 -1
- package/src/util/document/accessibility.css.ts +1 -1
- package/src/util/file/readAsDataURL.ts +17 -4
- package/src/util/linked-list/buildLinkedList.ts +1 -1
- package/src/util/number/index.ts +2 -0
- package/src/util/random/index.ts +4 -1
- package/src/util/tree/addTreeNode.ts +1 -1
- package/src/util/tree/attachChild.ts +13 -2
- package/src/util/tree/buildTree.ts +1 -1
- package/src/util/tree/detachChild.ts +7 -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
|
@@ -2,8 +2,8 @@ import type { ChangeCallback } from '#hook'
|
|
|
2
2
|
import { isEnterKey } from '#util'
|
|
3
3
|
import clsx from 'clsx'
|
|
4
4
|
import { useCallback } from 'react'
|
|
5
|
-
import { Input, type InputProps } from '.'
|
|
6
5
|
import { Search24Regular } from '../icon'
|
|
6
|
+
import { Input, type InputProps } from './Input'
|
|
7
7
|
import { InputBeforeStyle, SearchInputBeforeStyle } from './style/index.css'
|
|
8
8
|
|
|
9
9
|
export interface SearchInputProps extends InputProps {
|
|
@@ -12,7 +12,7 @@ export interface SearchInputProps extends InputProps {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export function SearchInput(props: SearchInputProps) {
|
|
15
|
-
const { onSearch, ...attrs } = props
|
|
15
|
+
const { onSearch, onKeyDown, ...attrs } = props
|
|
16
16
|
|
|
17
17
|
attrs.role ||= 'searchbox'
|
|
18
18
|
|
|
@@ -24,20 +24,21 @@ export function SearchInput(props: SearchInputProps) {
|
|
|
24
24
|
)
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
attrs.onKeyDown = useCallback<NonNullable<typeof onKeyDown>>(
|
|
30
|
-
// eslint-disable-next-line react-hooks/preserve-manual-memoization
|
|
27
|
+
const handleKeyDown = useCallback<NonNullable<typeof onKeyDown>>(
|
|
31
28
|
(ev) => {
|
|
32
29
|
onKeyDown?.(ev)
|
|
33
30
|
|
|
34
|
-
|
|
31
|
+
// Ignore the 'Enter' key that confirms an in-progress IME composition.
|
|
32
|
+
if (
|
|
33
|
+
!ev.defaultPrevented &&
|
|
34
|
+
isEnterKey(ev) &&
|
|
35
|
+
!ev.nativeEvent.isComposing
|
|
36
|
+
) {
|
|
35
37
|
onSearch?.(ev, ev.currentTarget.value)
|
|
36
38
|
}
|
|
37
39
|
},
|
|
38
|
-
// eslint-disable-next-line react-hooks/preserve-manual-memoization
|
|
39
40
|
[onKeyDown, onSearch]
|
|
40
41
|
)
|
|
41
42
|
|
|
42
|
-
return <Input {...attrs} />
|
|
43
|
+
return <Input {...attrs} onKeyDown={handleKeyDown} />
|
|
43
44
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type PopoverProps, Popover } from '#component'
|
|
2
1
|
import { useForm } from '#hook'
|
|
3
2
|
import clsx from 'clsx'
|
|
3
|
+
import { Popover, type PopoverProps } from '../popover/Popover'
|
|
4
4
|
import { ListStyle } from '../select/style/index.css'
|
|
5
5
|
|
|
6
6
|
export function Menu(props: PopoverProps<'ul'>) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Checkmark24Regular } from '#component'
|
|
2
1
|
import { useChange, useCheckbox, useInteractive, useKeyboard } from '#hook'
|
|
2
|
+
import { Checkmark24Regular } from '../icon'
|
|
3
3
|
import { ItemIconStyle } from '../select/style/index.css'
|
|
4
4
|
import { renderMenuItem, type MenuItemProps } from './renderMenuItem'
|
|
5
5
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Checkmark24Regular } from '#component'
|
|
2
1
|
import {
|
|
3
2
|
useChange,
|
|
4
3
|
useClose,
|
|
@@ -6,6 +5,7 @@ import {
|
|
|
6
5
|
useKeyboard,
|
|
7
6
|
useRadio,
|
|
8
7
|
} from '#hook'
|
|
8
|
+
import { Checkmark24Regular } from '../icon'
|
|
9
9
|
import { ItemIconStyle } from '../select/style/index.css'
|
|
10
10
|
import { renderMenuItem, type MenuItemProps } from './renderMenuItem'
|
|
11
11
|
|
|
@@ -30,7 +30,11 @@ export function renderMenuItem(props: MenuItemProps) {
|
|
|
30
30
|
<li
|
|
31
31
|
{...slot?.root}
|
|
32
32
|
{...attrs}
|
|
33
|
-
className={clsx(
|
|
33
|
+
className={clsx(
|
|
34
|
+
ItemStyle({ danger }),
|
|
35
|
+
slot?.root?.className,
|
|
36
|
+
attrs.className
|
|
37
|
+
)}
|
|
34
38
|
>
|
|
35
39
|
<div
|
|
36
40
|
{...slot?.before}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useIsomorphicLayoutEffect, useRefObject } from '#hook'
|
|
2
|
+
import { useRef } from 'react'
|
|
3
|
+
import { type Root, createRoot } from 'react-dom/client'
|
|
4
|
+
|
|
5
|
+
export interface ShadowRootProps extends React.ComponentProps<'div'> {
|
|
6
|
+
delegatesFocus?: boolean | undefined
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function ShadowRoot(props: ShadowRootProps) {
|
|
10
|
+
const { children, delegatesFocus = false, ref, ...attrs } = props
|
|
11
|
+
const hostRef = useRefObject<HTMLDivElement>(ref)
|
|
12
|
+
const nestedRootRef = useRef<Root | null>(null)
|
|
13
|
+
|
|
14
|
+
useIsomorphicLayoutEffect(() => {
|
|
15
|
+
const host = hostRef.current
|
|
16
|
+
|
|
17
|
+
/* istanbul ignore next */
|
|
18
|
+
if (host === null) {
|
|
19
|
+
return
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const shadowRoot =
|
|
23
|
+
host.shadowRoot ??
|
|
24
|
+
host.attachShadow({
|
|
25
|
+
mode: 'open',
|
|
26
|
+
delegatesFocus,
|
|
27
|
+
})
|
|
28
|
+
const nestedRoot = nestedRootRef.current ?? createRoot(shadowRoot)
|
|
29
|
+
|
|
30
|
+
nestedRootRef.current = nestedRoot
|
|
31
|
+
|
|
32
|
+
return () => {
|
|
33
|
+
nestedRoot.render(null)
|
|
34
|
+
}
|
|
35
|
+
}, [delegatesFocus, hostRef])
|
|
36
|
+
|
|
37
|
+
useIsomorphicLayoutEffect(() => {
|
|
38
|
+
nestedRootRef.current?.render(children)
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
return <div {...attrs} ref={hostRef} />
|
|
42
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
positionAxisMap,
|
|
3
3
|
useTooltip,
|
|
4
4
|
type Overlay,
|
|
5
5
|
type TooltipOptions,
|
|
@@ -38,7 +38,7 @@ export function Tooltip(props: TooltipProps) {
|
|
|
38
38
|
<div
|
|
39
39
|
{...tooltip.arrow.props}
|
|
40
40
|
className={clsx(
|
|
41
|
-
TooltipArrowStyle({ axis:
|
|
41
|
+
TooltipArrowStyle({ axis: positionAxisMap[tooltip.position] }),
|
|
42
42
|
tooltip.arrow.props.className
|
|
43
43
|
)}
|
|
44
44
|
/>
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import {
|
|
3
|
-
ChevronDown24Regular,
|
|
4
|
-
Input,
|
|
5
|
-
Popover,
|
|
6
|
-
type InputProps,
|
|
7
|
-
type PopoverProps,
|
|
8
|
-
} from '#component'
|
|
9
2
|
import { FormContext, useAutoComplete, type AutoCompleteOptions } from '#hook'
|
|
10
3
|
import { HighlightName } from '#theme'
|
|
11
4
|
import clsx from 'clsx'
|
|
12
5
|
import { useLayoutEffect, type JSX } from 'react'
|
|
6
|
+
import { ChevronDown24Regular } from '../icon'
|
|
7
|
+
import { Input, type InputProps } from '../input/Input'
|
|
8
|
+
import { Popover, type PopoverProps } from '../popover/Popover'
|
|
13
9
|
import { InputAfterStyle } from '../input/style/index.css'
|
|
14
10
|
import { Option } from './Option'
|
|
15
11
|
import { ListStyle } from './style/index.css'
|
|
@@ -35,7 +35,7 @@ export function Group(props: GroupProps) {
|
|
|
35
35
|
<li
|
|
36
36
|
{...slot?.root}
|
|
37
37
|
{...attrs}
|
|
38
|
-
className={clsx(GroupStyle, attrs.className)}
|
|
38
|
+
className={clsx(GroupStyle, slot?.root?.className, attrs.className)}
|
|
39
39
|
role='group'
|
|
40
40
|
aria-labelledby={label != null ? labelProps.id : undefined}
|
|
41
41
|
>
|
|
@@ -61,7 +61,7 @@ export function Option<T extends OptionValue>(props: OptionProps<T>) {
|
|
|
61
61
|
<li
|
|
62
62
|
{...slot?.root}
|
|
63
63
|
{...attrs}
|
|
64
|
-
className={clsx(ItemStyle(), attrs.className)}
|
|
64
|
+
className={clsx(ItemStyle(), slot?.root?.className, attrs.className)}
|
|
65
65
|
role='option'
|
|
66
66
|
value={value}
|
|
67
67
|
aria-selected={selected}
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Button,
|
|
3
|
-
ChevronDown24Regular,
|
|
4
|
-
Popover,
|
|
5
|
-
type ButtonProps,
|
|
6
|
-
type PopoverProps,
|
|
7
|
-
} from '#component'
|
|
8
1
|
import {
|
|
9
2
|
FormContext,
|
|
10
3
|
useSelect,
|
|
@@ -13,6 +6,9 @@ import {
|
|
|
13
6
|
} from '#hook'
|
|
14
7
|
import clsx from 'clsx'
|
|
15
8
|
import type { JSX } from 'react'
|
|
9
|
+
import { Popover, type PopoverProps } from '../popover/Popover'
|
|
10
|
+
import { Button, type ButtonProps } from '../button/Button'
|
|
11
|
+
import { ChevronDown24Regular } from '../icon'
|
|
16
12
|
import { ButtonAfterStyle } from '../button/style/index.css'
|
|
17
13
|
import { ListStyle } from '../select/style/index.css'
|
|
18
14
|
import { Option } from './Option'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import { useActivate, type ActivateCallback } from '#hook'
|
|
3
2
|
import { useImperativeHandle, useMemo } from 'react'
|
|
4
3
|
import invariant from 'tiny-invariant'
|
|
4
|
+
import { useActivate, type ActivateCallback } from '../../react/useActivate'
|
|
5
5
|
import { KeyboardContext } from './context'
|
|
6
6
|
import {
|
|
7
7
|
useLastFocused,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { createContext } from 'react'
|
|
3
|
-
import type { Keyboard } from '
|
|
4
|
-
import type { PoolAdd, PoolRemove } from '../hook'
|
|
3
|
+
import type { Keyboard } from '../Keyboard'
|
|
4
|
+
import type { PoolAdd, PoolRemove } from '../hook/usePool'
|
|
5
5
|
|
|
6
6
|
export interface KeyboardContext extends Keyboard {
|
|
7
7
|
lastActive: Element | null
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isARIAChecked, isARIASelected } from '#util'
|
|
2
2
|
import { useLayoutEffect, useMemo, useRef } from 'react'
|
|
3
|
-
import type { NavigationType } from '
|
|
3
|
+
import type { NavigationType } from '../Keyboard'
|
|
4
4
|
import type { Tree } from '../tree'
|
|
5
5
|
|
|
6
6
|
export function useLastFocused(
|
|
@@ -8,6 +8,12 @@ export function useLastFocused(
|
|
|
8
8
|
tree: Tree,
|
|
9
9
|
active: Element | null
|
|
10
10
|
) {
|
|
11
|
+
// The memoized context binding is deliberately reassigned: when 'active'
|
|
12
|
+
// is removed from the tree (or missing) the memo yields null or
|
|
13
|
+
// undefined, and the '??=' fallback below restores the last captured
|
|
14
|
+
// context from the ref. Reassigning the binding keeps the ref fallback
|
|
15
|
+
// out of the memo dependencies, which would otherwise propagate ref
|
|
16
|
+
// reads into every downstream memo.
|
|
11
17
|
// eslint-disable-next-line react-hooks/preserve-manual-memoization
|
|
12
18
|
let ctx = useMemo(
|
|
13
19
|
() => (active ? tree.map.get(active)?.context : null),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback, useLayoutEffect, useRef } from 'react'
|
|
2
|
-
import type { NavigationDirection, NavigationType } from '
|
|
2
|
+
import type { NavigationDirection, NavigationType } from '../Keyboard'
|
|
3
3
|
import { resolve, type Parse } from '../resolve'
|
|
4
4
|
import type { Tree } from '../tree'
|
|
5
5
|
import type { MoveFocus } from './useMoveFocus'
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from '#util'
|
|
11
11
|
import type { Pool } from './hook/usePool'
|
|
12
12
|
import { Tree } from './tree'
|
|
13
|
-
import type { NavigationDirection, NavigationType } from '
|
|
13
|
+
import type { NavigationDirection, NavigationType } from './Keyboard'
|
|
14
14
|
|
|
15
15
|
const PAGE_SIZE = 10
|
|
16
16
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import { positionMap, type Overlay, type Position } from '#hook'
|
|
3
2
|
import {
|
|
4
3
|
isArrowDownKey,
|
|
5
4
|
isArrowLeftKey,
|
|
@@ -8,7 +7,9 @@ import {
|
|
|
8
7
|
} from '#util'
|
|
9
8
|
import { getAlignment, getOppositePlacement, getSide } from '@floating-ui/utils'
|
|
10
9
|
import { useCallback, useLayoutEffect, useRef } from 'react'
|
|
11
|
-
import type {
|
|
10
|
+
import type { Overlay } from '../../popover/useOverlay'
|
|
11
|
+
import { positionMap, type Position } from '../../popover/style/positioning.css'
|
|
12
|
+
import type { Keyboard, NavigationDirection } from './Keyboard'
|
|
12
13
|
|
|
13
14
|
interface Props extends React.AriaAttributes {
|
|
14
15
|
disabled?: boolean | undefined
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { useRefCallback, useUniqueId } from '#hook'
|
|
2
|
-
import type { GlobalAttributes } from '#hook/react/element.d'
|
|
3
1
|
import { VirtualActive, VirtualFocus } from '#util'
|
|
4
2
|
import { use, useCallback } from 'react'
|
|
3
|
+
import type { GlobalAttributes } from '../../react/element.d'
|
|
4
|
+
import { useRefCallback } from '../../react/useRefCallback'
|
|
5
|
+
import { useUniqueId } from '../../react/useUniqueId'
|
|
5
6
|
import { KeyboardContext } from './context'
|
|
6
7
|
|
|
7
8
|
interface Props extends GlobalAttributes, React.RefAttributes<Element> {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { useCallback, useLayoutEffect, useState } from 'react'
|
|
3
|
-
import { refValue,
|
|
3
|
+
import { refValue, type RefValue } from '../react/refValue'
|
|
4
|
+
import { useRegExp } from '../react/useRegExp'
|
|
4
5
|
|
|
5
6
|
export function useHighlight(
|
|
6
7
|
pattern: string | undefined,
|
|
@@ -37,9 +38,9 @@ export function useHighlight(
|
|
|
37
38
|
|
|
38
39
|
traverse(el)
|
|
39
40
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
// Report an empty result as 'undefined' so a stale 'Highlight' with
|
|
42
|
+
// detached ranges is not kept around when the matches disappear.
|
|
43
|
+
setHighlight(highlight.size > 0 ? highlight : undefined)
|
|
43
44
|
},
|
|
44
45
|
[RE]
|
|
45
46
|
)
|
|
@@ -1,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,16 +57,6 @@ export function useGroup<T, P extends Props<T, SyntheticEvent>>(props: P) {
|
|
|
56
57
|
value: _value,
|
|
57
58
|
})
|
|
58
59
|
|
|
59
|
-
// eslint-disable-next-line react-hooks/immutability
|
|
60
|
-
props = {
|
|
61
|
-
...props,
|
|
62
|
-
name,
|
|
63
|
-
defaultValue: undefined,
|
|
64
|
-
value,
|
|
65
|
-
multiple,
|
|
66
|
-
disabled,
|
|
67
|
-
}
|
|
68
|
-
|
|
69
60
|
const [_state, _setState] = useDefault({
|
|
70
61
|
defaultValue: {},
|
|
71
62
|
value: context?.value,
|
|
@@ -129,20 +120,28 @@ export function useGroup<T, P extends Props<T, SyntheticEvent>>(props: P) {
|
|
|
129
120
|
[name, setState]
|
|
130
121
|
)
|
|
131
122
|
|
|
132
|
-
props = {
|
|
133
|
-
...props,
|
|
134
|
-
onChange: handleChange,
|
|
135
|
-
}
|
|
136
|
-
|
|
137
123
|
const _context = useMemo<NonNullable<typeof context>>(
|
|
138
124
|
() => ({ name, value: state, multiple, disabled, onChange: setState }),
|
|
139
125
|
[disabled, multiple, name, setState, state]
|
|
140
126
|
)
|
|
141
127
|
|
|
142
|
-
|
|
128
|
+
const groupProps: P = {
|
|
143
129
|
...props,
|
|
144
|
-
|
|
145
|
-
|
|
130
|
+
name,
|
|
131
|
+
defaultValue: undefined,
|
|
132
|
+
value,
|
|
133
|
+
multiple,
|
|
134
|
+
disabled,
|
|
135
|
+
onChange: handleChange,
|
|
136
|
+
children: createElement(
|
|
137
|
+
FormContext,
|
|
138
|
+
// The context value bundles 'setState', which reads the latest state
|
|
139
|
+
// from a ref inside event callbacks. The rule conservatively flags any
|
|
140
|
+
// ref-reading function passed through a provider during render.
|
|
141
|
+
// eslint-disable-next-line react-hooks/refs
|
|
142
|
+
{ value: _context },
|
|
143
|
+
props.children
|
|
144
|
+
),
|
|
146
145
|
}
|
|
147
146
|
|
|
148
147
|
return {
|
|
@@ -151,7 +150,7 @@ export function useGroup<T, P extends Props<T, SyntheticEvent>>(props: P) {
|
|
|
151
150
|
multiple,
|
|
152
151
|
disabled,
|
|
153
152
|
onChange: handleChange,
|
|
154
|
-
props,
|
|
153
|
+
props: groupProps,
|
|
155
154
|
context: _context,
|
|
156
155
|
}
|
|
157
156
|
}
|
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
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import 'symbol-observable'
|
|
3
3
|
|
|
4
|
-
import { useCallback, useRef, useSyncExternalStore } from 'react'
|
|
4
|
+
import { useCallback, useEffect, useRef, useSyncExternalStore } from 'react'
|
|
5
5
|
import type { ObservableInput } from 'rxjs'
|
|
6
6
|
import { from } from 'rxjs'
|
|
7
7
|
|
|
@@ -20,10 +20,23 @@ export function useObservable<T>(
|
|
|
20
20
|
initialValue?: T | undefined
|
|
21
21
|
) {
|
|
22
22
|
const valueRef = useRef(initialValue)
|
|
23
|
+
const initialValueRef = useRef(initialValue)
|
|
24
|
+
|
|
25
|
+
// Track the latest 'initialValue' in a ref so the subscribe callback below
|
|
26
|
+
// depends only on 'observable'; a new initial value identity must not
|
|
27
|
+
// resubscribe and reset the emitted value.
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
initialValueRef.current = initialValue
|
|
30
|
+
})
|
|
23
31
|
|
|
24
32
|
return useSyncExternalStore(
|
|
25
33
|
useCallback(
|
|
26
34
|
(onStoreChange) => {
|
|
35
|
+
// A new 'observable' must not keep reporting the previous source's
|
|
36
|
+
// last emission; fall back to the latest 'initialValue' until it
|
|
37
|
+
// emits.
|
|
38
|
+
valueRef.current = initialValueRef.current
|
|
39
|
+
|
|
27
40
|
const subscription = from(observable).subscribe((value) => {
|
|
28
41
|
valueRef.current = value
|
|
29
42
|
onStoreChange()
|