chiplet 0.3.0-dev.3 → 0.3.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/LICENSE +1 -1
- package/README.md +46 -13
- package/dist/article.css +143 -0
- package/dist/component/button/Button.js.map +1 -1
- package/dist/component/button/Interactive.js +1 -0
- package/dist/component/button/Interactive.js.map +1 -1
- package/dist/component/button/style/index.css.vanilla.js +5 -5
- package/dist/component/button/style/index.css.vanilla.js.map +1 -1
- package/dist/component/checkbox/Checkbox.js +1 -1
- package/dist/component/checkbox/Checkbox.js.map +1 -1
- package/dist/component/checkbox/CheckboxGroup.js +1 -0
- package/dist/component/checkbox/CheckboxGroup.js.map +1 -1
- package/dist/component/checkbox/Radio.js +1 -0
- package/dist/component/checkbox/Radio.js.map +1 -1
- package/dist/component/checkbox/RadioGroup.js +1 -0
- package/dist/component/checkbox/RadioGroup.js.map +1 -1
- package/dist/component/checkbox/icon/CheckboxChecked.svg.js.map +1 -1
- package/dist/component/checkbox/icon/CheckboxIndeterminate.svg.js.map +1 -1
- package/dist/component/checkbox/icon/CheckboxUnchecked.svg.js.map +1 -1
- package/dist/component/checkbox/icon/RadioChecked.svg.js.map +1 -1
- package/dist/component/checkbox/icon/RadioUnchecked.svg.js.map +1 -1
- package/dist/component/checkbox/icon/index.js +7 -5
- package/dist/component/checkbox/icon/index.js.map +1 -1
- package/dist/component/checkbox/style/index.css.vanilla.js +14 -14
- package/dist/component/checkbox/style/index.css.vanilla.js.map +1 -1
- package/dist/component/header/style/index.css.vanilla.js +1 -1
- package/dist/component/header/style/index.css.vanilla.js.map +1 -1
- package/dist/component/icon/set/Checkmark24Filled.svg.js.map +1 -1
- package/dist/component/icon/set/Checkmark24Regular.svg.js.map +1 -1
- package/dist/component/icon/set/ChevronDown24Filled.svg.js.map +1 -1
- package/dist/component/icon/set/ChevronDown24Regular.svg.js.map +1 -1
- package/dist/component/icon/set/Dismiss24Filled.svg.js.map +1 -1
- package/dist/component/icon/set/Dismiss24Regular.svg.js.map +1 -1
- package/dist/component/icon/set/Search24Filled.svg.js.map +1 -1
- package/dist/component/icon/set/Search24Regular.svg.js.map +1 -1
- package/dist/component/index.js +1 -0
- package/dist/component/index.js.map +1 -1
- package/dist/component/input/Input.js +1 -0
- package/dist/component/input/Input.js.map +1 -1
- package/dist/component/input/SearchInput.js +4 -1
- package/dist/component/input/SearchInput.js.map +1 -1
- package/dist/component/input/style/index.css.vanilla.js +8 -8
- package/dist/component/input/style/index.css.vanilla.js.map +1 -1
- package/dist/component/menu/Menu.js +7 -5
- package/dist/component/menu/Menu.js.map +1 -1
- package/dist/component/menu/MenuItem.js +1 -0
- package/dist/component/menu/MenuItem.js.map +1 -1
- package/dist/component/menu/MenuItemCheckbox.js +7 -5
- package/dist/component/menu/MenuItemCheckbox.js.map +1 -1
- package/dist/component/menu/MenuItemRadio.js +7 -5
- package/dist/component/menu/MenuItemRadio.js.map +1 -1
- package/dist/component/popover/Dialog.js +1 -0
- package/dist/component/popover/Dialog.js.map +1 -1
- package/dist/component/popover/DismissButton.js +1 -0
- package/dist/component/popover/DismissButton.js.map +1 -1
- package/dist/component/popover/Popover.js +1 -0
- package/dist/component/popover/Popover.js.map +1 -1
- package/dist/component/popover/Tooltip.js +1 -0
- package/dist/component/popover/Tooltip.js.map +1 -1
- package/dist/component/popover/style/index.css.vanilla.js +8 -8
- package/dist/component/popover/style/index.css.vanilla.js.map +1 -1
- package/dist/component/progress/style/index.css.vanilla.js +4 -4
- package/dist/component/progress/style/index.css.vanilla.js.map +1 -1
- package/dist/component/select/AutoComplete.js +7 -5
- package/dist/component/select/AutoComplete.js.map +1 -1
- package/dist/component/select/Group.js +13 -4
- package/dist/component/select/Group.js.map +1 -1
- package/dist/component/select/Option.js +1 -0
- package/dist/component/select/Option.js.map +1 -1
- package/dist/component/select/Select.js +7 -5
- package/dist/component/select/Select.js.map +1 -1
- package/dist/component/select/style/index.css.vanilla.js +16 -15
- package/dist/component/select/style/index.css.vanilla.js.map +1 -1
- package/dist/component/style/article.css.vanilla.js +6 -0
- package/dist/component/style/article.css.vanilla.js.map +1 -0
- package/dist/component/style/index.js +3 -0
- package/dist/component/style/index.js.map +1 -0
- package/dist/component/typography/style/index.css.vanilla.js +4 -4
- package/dist/component/typography/style/index.css.vanilla.js.map +1 -1
- package/dist/{theme/global.css → global.css} +7 -7
- package/dist/hook/accessibility/keyboard/Keyboard.js +7 -2
- package/dist/hook/accessibility/keyboard/Keyboard.js.map +1 -1
- package/dist/hook/accessibility/keyboard/Roving.js +1 -0
- package/dist/hook/accessibility/keyboard/Roving.js.map +1 -1
- package/dist/hook/accessibility/keyboard/hook/useLastFocused.js +1 -0
- package/dist/hook/accessibility/keyboard/hook/useLastFocused.js.map +1 -1
- package/dist/hook/accessibility/keyboard/hook/useMoveFocus.js.map +1 -1
- package/dist/hook/accessibility/keyboard/hook/useNavigate.js +2 -4
- package/dist/hook/accessibility/keyboard/hook/useNavigate.js.map +1 -1
- package/dist/hook/accessibility/keyboard/resolve.js +1 -0
- package/dist/hook/accessibility/keyboard/resolve.js.map +1 -1
- package/dist/hook/accessibility/keyboard/sort.js +1 -1
- package/dist/hook/accessibility/keyboard/sort.js.map +1 -1
- package/dist/hook/accessibility/keyboard/tree.js +1 -0
- package/dist/hook/accessibility/keyboard/tree.js.map +1 -1
- package/dist/hook/accessibility/keyboard/useController.js +1 -0
- package/dist/hook/accessibility/keyboard/useController.js.map +1 -1
- package/dist/hook/accessibility/keyboard/useKeyboard.js +1 -0
- package/dist/hook/accessibility/keyboard/useKeyboard.js.map +1 -1
- package/dist/hook/document/useHighlight.js +1 -1
- package/dist/hook/document/useHighlight.js.map +1 -1
- package/dist/hook/form/useAutoComplete.js +1 -3
- package/dist/hook/form/useAutoComplete.js.map +1 -1
- package/dist/hook/form/useCheckbox.js +1 -0
- package/dist/hook/form/useCheckbox.js.map +1 -1
- package/dist/hook/form/useChecked.js +1 -0
- package/dist/hook/form/useChecked.js.map +1 -1
- package/dist/hook/form/useDefault.js +2 -0
- package/dist/hook/form/useDefault.js.map +1 -1
- package/dist/hook/form/useForm.js +2 -1
- package/dist/hook/form/useForm.js.map +1 -1
- package/dist/hook/form/useGroup.js +2 -0
- package/dist/hook/form/useGroup.js.map +1 -1
- package/dist/hook/form/useOption.js +1 -0
- package/dist/hook/form/useOption.js.map +1 -1
- package/dist/hook/form/useRadio.js +1 -0
- package/dist/hook/form/useRadio.js.map +1 -1
- package/dist/hook/form/useSelect.js +1 -0
- package/dist/hook/form/useSelect.js.map +1 -1
- package/dist/hook/form/useValue.js +1 -0
- package/dist/hook/form/useValue.js.map +1 -1
- package/dist/hook/popover/useAnchorPositioning.js +1 -0
- package/dist/hook/popover/useAnchorPositioning.js.map +1 -1
- package/dist/hook/popover/useDialog.js +1 -0
- package/dist/hook/popover/useDialog.js.map +1 -1
- package/dist/hook/popover/useLightDismiss.js +1 -1
- package/dist/hook/popover/useLightDismiss.js.map +1 -1
- package/dist/hook/popover/useOverlay.js +1 -0
- package/dist/hook/popover/useOverlay.js.map +1 -1
- package/dist/hook/popover/usePopover.js +6 -2
- package/dist/hook/popover/usePopover.js.map +1 -1
- package/dist/hook/popover/usePositioning.js +1 -0
- package/dist/hook/popover/usePositioning.js.map +1 -1
- package/dist/hook/popover/useTooltip.js +3 -1
- package/dist/hook/popover/useTooltip.js.map +1 -1
- package/dist/hook/react/refValue.js +1 -0
- package/dist/hook/react/refValue.js.map +1 -1
- package/dist/hook/react/useActivate.js +1 -1
- 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 -0
- package/dist/hook/react/useInteractive.js.map +1 -1
- package/dist/hook/react/useUniqueId.js +3 -2
- package/dist/hook/react/useUniqueId.js.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/index3.css +138 -0
- package/dist/index5.css +167 -0
- package/dist/{component/checkbox/style/index.css → index6.css} +79 -71
- package/dist/{component/input/style/index.css → index7.css} +29 -30
- package/dist/{component/button/style/index.css → index8.css} +37 -37
- package/dist/infra/logging/logger.js +10 -12
- package/dist/infra/logging/logger.js.map +1 -1
- package/dist/theme/ColorScheme.js.map +1 -1
- package/dist/theme/defineTheme.js +1 -0
- package/dist/theme/defineTheme.js.map +1 -1
- package/dist/theme/global.css.vanilla.js +11 -11
- package/dist/theme/global.css.vanilla.js.map +1 -1
- package/dist/theme/theme.css.vanilla.js +3 -3
- package/dist/theme/theme.css.vanilla.js.map +1 -1
- package/dist/theme/token.css.vanilla.js +1 -1
- package/dist/theme/token.css.vanilla.js.map +1 -1
- package/dist/{theme/theme.css → theme.css} +23 -27
- package/dist/util/document/accessibility.css.vanilla.js +4 -4
- package/dist/util/document/accessibility.css.vanilla.js.map +1 -1
- package/dist/util/index.js +4 -1
- package/dist/util/index.js.map +1 -1
- package/dist/util/random/generateDeterministicId.js +12 -0
- package/dist/util/random/generateDeterministicId.js.map +1 -0
- package/dist/util/random/generateDigest.js +12 -0
- package/dist/util/random/generateDigest.js.map +1 -0
- package/dist/util/random/generateUniqueId.js +9 -0
- package/dist/util/random/generateUniqueId.js.map +1 -0
- package/dist/util/random/index.js +4 -1
- package/dist/util/random/index.js.map +1 -1
- package/dist/util/random/toHex.js +10 -0
- package/dist/util/random/toHex.js.map +1 -0
- package/package.json +102 -105
- package/src/component/button/Button.tsx +1 -5
- package/src/component/button/style/index.css.ts +1 -1
- package/src/component/checkbox/Checkbox.tsx +2 -3
- package/src/component/checkbox/Radio.tsx +1 -2
- package/src/component/checkbox/RadioGroup.tsx +1 -2
- package/src/component/checkbox/style/index.css.ts +34 -25
- package/src/component/icon/README.md +17 -3
- package/src/component/index.ts +1 -0
- package/src/component/input/Input.tsx +1 -2
- package/src/component/input/SearchInput.tsx +4 -3
- package/src/component/input/style/index.css.ts +42 -41
- package/src/component/popover/Tooltip.tsx +1 -3
- package/src/component/popover/style/index.css.ts +100 -103
- package/src/component/select/Group.tsx +11 -3
- package/src/component/select/Option.tsx +1 -2
- package/src/component/select/style/index.css.ts +59 -53
- package/src/component/style/article.css.ts +189 -0
- package/src/component/style/index.ts +1 -0
- package/src/hook/accessibility/keyboard/Keyboard.tsx +6 -1
- package/src/hook/accessibility/keyboard/hook/useLastFocused.ts +1 -0
- package/src/hook/accessibility/keyboard/hook/useMoveFocus.ts +2 -0
- package/src/hook/accessibility/keyboard/hook/useNavigate.ts +5 -5
- package/src/hook/accessibility/keyboard/sort.ts +1 -1
- package/src/hook/document/useHighlight.ts +1 -27
- package/src/hook/form/useAutoComplete.ts +3 -3
- package/src/hook/form/useDefault.ts +2 -0
- package/src/hook/form/useForm.ts +2 -2
- package/src/hook/form/useGroup.ts +2 -1
- package/src/hook/popover/useLightDismiss.ts +1 -1
- package/src/hook/popover/usePopover.ts +7 -12
- package/src/hook/popover/usePositioning.ts +2 -1
- package/src/hook/popover/useTooltip.ts +3 -1
- package/src/hook/react/useActivate.ts +1 -1
- package/src/hook/react/useConst.ts +1 -1
- package/src/hook/react/useUniqueId.ts +2 -2
- package/src/infra/logging/logger.ts +26 -13
- package/src/theme/ColorScheme.tsx +1 -5
- package/src/theme/global.css.ts +2 -2
- package/src/theme/theme.css.ts +1 -5
- package/src/util/document/accessibility.css.ts +3 -3
- package/src/util/random/generateDeterministicId.ts +10 -0
- package/src/util/random/generateDigest.ts +11 -0
- package/src/util/random/{createUniqueId.ts → generateUniqueId.ts} +4 -6
- package/src/util/random/index.ts +4 -1
- package/src/util/random/toHex.ts +6 -0
- package/dist/component/popover/style/index.css +0 -175
- package/dist/component/select/style/index.css +0 -135
- package/dist/util/random/createUniqueId.js +0 -8
- package/dist/util/random/createUniqueId.js.map +0 -1
- package/src/component/style/font/font.css +0 -23
- package/src/component/style/font/proxima-nova-bold.woff +0 -0
- package/src/component/style/font/proxima-nova-light.woff +0 -0
- package/src/component/style/font/proxima-nova-regular.woff +0 -0
- package/src/component/style/font/proxima-nova-semibold.woff +0 -0
- package/src/component/style/press.module.css +0 -204
- /package/dist/{component/select/index.css → index.css} +0 -0
- /package/dist/{component/select/index2.css → index2.css} +0 -0
- /package/dist/{component/progress/style/index.css → index4.css} +0 -0
- /package/dist/{theme/token.css → token.css} +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useUniqueId } from '#hook'
|
|
2
2
|
import clsx from 'clsx'
|
|
3
3
|
import {
|
|
4
|
+
GroupHeaderStyle,
|
|
4
5
|
GroupLabelStyle,
|
|
5
6
|
GroupNestedListStyle,
|
|
6
7
|
GroupStyle,
|
|
@@ -17,6 +18,7 @@ export interface GroupProps
|
|
|
17
18
|
label?: string | undefined
|
|
18
19
|
slot?: {
|
|
19
20
|
root?: React.ComponentProps<'li'> | undefined
|
|
21
|
+
header?: React.ComponentProps<'div'> | undefined
|
|
20
22
|
label?: React.ComponentProps<'div'> | undefined
|
|
21
23
|
nested?: React.ComponentProps<'ul'> | undefined
|
|
22
24
|
}
|
|
@@ -39,11 +41,17 @@ export function Group(props: GroupProps) {
|
|
|
39
41
|
>
|
|
40
42
|
{label != null && (
|
|
41
43
|
<div
|
|
42
|
-
{...
|
|
43
|
-
className={clsx(
|
|
44
|
+
{...slot?.header}
|
|
45
|
+
className={clsx(GroupHeaderStyle, slot?.header?.className)}
|
|
44
46
|
role='none'
|
|
45
47
|
>
|
|
46
|
-
|
|
48
|
+
<div
|
|
49
|
+
{...labelProps}
|
|
50
|
+
className={clsx(GroupLabelStyle, labelProps.className)}
|
|
51
|
+
role='none'
|
|
52
|
+
>
|
|
53
|
+
{label}
|
|
54
|
+
</div>
|
|
47
55
|
</div>
|
|
48
56
|
)}
|
|
49
57
|
|
|
@@ -24,8 +24,7 @@ export interface OptionProps<T extends OptionValue> extends Omit<
|
|
|
24
24
|
multiple?: never
|
|
25
25
|
disabled?: boolean | undefined
|
|
26
26
|
onChange?:
|
|
27
|
-
|
|
28
|
-
| undefined
|
|
27
|
+
ChangeCallback<React.MouseEvent<HTMLLIElement>, boolean> | undefined
|
|
29
28
|
slot?: {
|
|
30
29
|
root?: React.ComponentProps<'li'> | undefined
|
|
31
30
|
icon?: React.ComponentProps<'svg'> | undefined
|
|
@@ -2,6 +2,8 @@ import {
|
|
|
2
2
|
ActiveSelector,
|
|
3
3
|
DisabledSelector,
|
|
4
4
|
HighlightName,
|
|
5
|
+
radiusVar,
|
|
6
|
+
SquircleStyle,
|
|
5
7
|
theme,
|
|
6
8
|
TRANSPARENT,
|
|
7
9
|
} from '#theme'
|
|
@@ -10,7 +12,6 @@ import { recipe } from '@vanilla-extract/recipes'
|
|
|
10
12
|
|
|
11
13
|
const gap = createVar()
|
|
12
14
|
const width = createVar()
|
|
13
|
-
const height = createVar()
|
|
14
15
|
const padding = createVar()
|
|
15
16
|
const paddingBlock = createVar()
|
|
16
17
|
const paddingInline = createVar()
|
|
@@ -18,8 +19,6 @@ const margin = createVar()
|
|
|
18
19
|
const marginBlock = createVar()
|
|
19
20
|
const marginInline = createVar()
|
|
20
21
|
const font = createVar()
|
|
21
|
-
const fontSize = createVar()
|
|
22
|
-
const lineHeight = createVar()
|
|
23
22
|
const icon = createVar()
|
|
24
23
|
const color = createVar()
|
|
25
24
|
const colorChecked = createVar()
|
|
@@ -32,10 +31,10 @@ const backgroundActive = createVar()
|
|
|
32
31
|
const backgroundDisabled = createVar()
|
|
33
32
|
const border = createVar()
|
|
34
33
|
const borderSize = createVar()
|
|
35
|
-
const radius = createVar()
|
|
36
34
|
|
|
37
35
|
const gridTemplate = "'a b c' / auto 1fr auto"
|
|
38
36
|
const gridColumn = 'span 3'
|
|
37
|
+
const paddingBlockValue = `calc((${theme.item.height} - 1lh) / 2)`
|
|
39
38
|
|
|
40
39
|
export const ListStyle = style({
|
|
41
40
|
vars: {
|
|
@@ -52,6 +51,8 @@ export const ListStyle = style({
|
|
|
52
51
|
padding,
|
|
53
52
|
margin: '0',
|
|
54
53
|
overflow: 'auto',
|
|
54
|
+
scrollSnapType: 'both mandatory',
|
|
55
|
+
scrollPadding: padding,
|
|
55
56
|
selectors: {
|
|
56
57
|
[`&::highlight(${HighlightName})`]: {
|
|
57
58
|
textDecorationLine: 'underline',
|
|
@@ -60,59 +61,57 @@ export const ListStyle = style({
|
|
|
60
61
|
})
|
|
61
62
|
|
|
62
63
|
export const ItemStyle = recipe({
|
|
63
|
-
base:
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
[height]: theme.item.height,
|
|
67
|
-
[padding]: `${paddingBlock} ${paddingInline}`,
|
|
68
|
-
[paddingBlock]: `calc((${height} - ${lineHeight}) / 2)`,
|
|
69
|
-
[paddingInline]: theme.item.padding,
|
|
70
|
-
[fontSize]: theme.item.fontSize,
|
|
71
|
-
[lineHeight]: theme.item.lineHeight,
|
|
72
|
-
[icon]: theme.item.icon,
|
|
73
|
-
[color]: 'inherit',
|
|
74
|
-
[colorDisabled]: theme.disabled.color,
|
|
75
|
-
[cursor]: 'pointer',
|
|
76
|
-
[cursorDisabled]: 'not-allowed',
|
|
77
|
-
[background]: 'none',
|
|
78
|
-
[backgroundHover]: theme.hover.background,
|
|
79
|
-
[backgroundActive]: theme.active.background,
|
|
80
|
-
[backgroundDisabled]: 'none',
|
|
81
|
-
[radius]: theme.item.radius,
|
|
82
|
-
},
|
|
83
|
-
display: 'grid',
|
|
84
|
-
gridTemplateRows: 'subgrid',
|
|
85
|
-
gridTemplateColumns: 'subgrid',
|
|
86
|
-
gridColumn,
|
|
87
|
-
gap,
|
|
88
|
-
placeItems: 'start',
|
|
89
|
-
padding,
|
|
90
|
-
fontSize,
|
|
91
|
-
lineHeight,
|
|
92
|
-
color,
|
|
93
|
-
cursor,
|
|
94
|
-
background,
|
|
95
|
-
borderRadius: radius,
|
|
96
|
-
':hover': {
|
|
64
|
+
base: [
|
|
65
|
+
SquircleStyle,
|
|
66
|
+
{
|
|
97
67
|
vars: {
|
|
98
|
-
[
|
|
68
|
+
[gap]: theme.item.gap,
|
|
69
|
+
[padding]: `${paddingBlock} ${paddingInline}`,
|
|
70
|
+
[paddingBlock]: paddingBlockValue,
|
|
71
|
+
[paddingInline]: theme.item.padding,
|
|
72
|
+
[icon]: theme.item.icon,
|
|
73
|
+
[color]: 'inherit',
|
|
74
|
+
[colorDisabled]: theme.disabled.color,
|
|
75
|
+
[cursor]: 'pointer',
|
|
76
|
+
[cursorDisabled]: 'not-allowed',
|
|
77
|
+
[background]: 'none',
|
|
78
|
+
[backgroundHover]: theme.hover.background,
|
|
79
|
+
[backgroundActive]: theme.active.background,
|
|
80
|
+
[backgroundDisabled]: 'none',
|
|
81
|
+
[radiusVar]: theme.item.radius,
|
|
99
82
|
},
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
83
|
+
display: 'grid',
|
|
84
|
+
gridTemplateRows: 'subgrid',
|
|
85
|
+
gridTemplateColumns: 'subgrid',
|
|
86
|
+
gridColumn,
|
|
87
|
+
gap,
|
|
88
|
+
placeItems: 'start',
|
|
89
|
+
padding,
|
|
90
|
+
color,
|
|
91
|
+
cursor,
|
|
92
|
+
scrollSnapAlign: 'center',
|
|
93
|
+
background,
|
|
94
|
+
':hover': {
|
|
103
95
|
vars: {
|
|
104
|
-
[background]:
|
|
96
|
+
[background]: backgroundHover,
|
|
105
97
|
},
|
|
106
98
|
},
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
99
|
+
selectors: {
|
|
100
|
+
[`&${ActiveSelector}`]: {
|
|
101
|
+
vars: {
|
|
102
|
+
[background]: backgroundActive,
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
[`&${DisabledSelector}`]: {
|
|
106
|
+
vars: {
|
|
107
|
+
[color]: colorDisabled,
|
|
108
|
+
[cursor]: cursorDisabled,
|
|
109
|
+
[background]: backgroundDisabled,
|
|
110
|
+
},
|
|
112
111
|
},
|
|
113
112
|
},
|
|
114
113
|
},
|
|
115
|
-
|
|
114
|
+
],
|
|
116
115
|
variants: {
|
|
117
116
|
danger: {
|
|
118
117
|
true: {
|
|
@@ -148,7 +147,7 @@ export const ItemAfterStyle = style({
|
|
|
148
147
|
|
|
149
148
|
export const ItemIconStyle = style({
|
|
150
149
|
vars: {
|
|
151
|
-
[marginBlock]: `calc((
|
|
150
|
+
[marginBlock]: `calc((1lh - ${icon}) / 2)`,
|
|
152
151
|
[color]: TRANSPARENT,
|
|
153
152
|
[colorChecked]: 'inherit',
|
|
154
153
|
},
|
|
@@ -168,7 +167,7 @@ export const ItemIconStyle = style({
|
|
|
168
167
|
export const SeparatorStyle = style({
|
|
169
168
|
vars: {
|
|
170
169
|
[margin]: `${marginBlock} ${marginInline}`,
|
|
171
|
-
[marginBlock]:
|
|
170
|
+
[marginBlock]: paddingBlockValue,
|
|
172
171
|
[marginInline]: '0',
|
|
173
172
|
[color]: theme.separator.color,
|
|
174
173
|
[border]: `${borderSize} solid`,
|
|
@@ -189,18 +188,25 @@ export const GroupStyle = style({
|
|
|
189
188
|
gap: 'inherit',
|
|
190
189
|
})
|
|
191
190
|
|
|
192
|
-
export const
|
|
191
|
+
export const GroupHeaderStyle = style({
|
|
193
192
|
vars: {
|
|
194
193
|
[padding]: `${paddingBlock} ${paddingInline}`,
|
|
195
|
-
[paddingBlock]:
|
|
194
|
+
[paddingBlock]: paddingBlockValue,
|
|
196
195
|
[paddingInline]: theme.item.padding,
|
|
197
196
|
[font]: theme.group.font,
|
|
198
197
|
[color]: theme.group.color,
|
|
199
198
|
},
|
|
200
199
|
position: 'sticky',
|
|
201
200
|
insetBlockStart: '0',
|
|
201
|
+
display: 'grid',
|
|
202
|
+
gridTemplateColumns: 'subgrid',
|
|
202
203
|
gridColumn,
|
|
204
|
+
gap: 'inherit',
|
|
203
205
|
padding,
|
|
206
|
+
})
|
|
207
|
+
|
|
208
|
+
export const GroupLabelStyle = style({
|
|
209
|
+
gridColumn,
|
|
204
210
|
font,
|
|
205
211
|
color,
|
|
206
212
|
})
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { createVar, globalStyle, style } from '@vanilla-extract/css'
|
|
2
|
+
|
|
3
|
+
const gap = createVar()
|
|
4
|
+
const width = createVar()
|
|
5
|
+
const color = createVar()
|
|
6
|
+
const background = createVar()
|
|
7
|
+
|
|
8
|
+
export const ArticleStyle = style({
|
|
9
|
+
vars: {
|
|
10
|
+
[width]: '48rem',
|
|
11
|
+
[color]: 'light-dark(#131313, #fff)',
|
|
12
|
+
[background]: 'light-dark(#fff, #131313)',
|
|
13
|
+
},
|
|
14
|
+
maxInlineSize: width,
|
|
15
|
+
paddingInline: '1.5rem',
|
|
16
|
+
margin: 'auto',
|
|
17
|
+
fontFamily: `'Proxima Nova', 'Myriad Set Pro', 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif`,
|
|
18
|
+
fontSize: '0.875rem',
|
|
19
|
+
lineHeight: '1.25rem',
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
globalStyle(`${ArticleStyle} h1, ${ArticleStyle} section`, {
|
|
23
|
+
color,
|
|
24
|
+
background,
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
globalStyle(
|
|
28
|
+
['h1', 'h2', 'h3', 'p', 'ul', 'ol', 'pre', 'hr', 'section']
|
|
29
|
+
.map((selector) => `${ArticleStyle} ${selector}`)
|
|
30
|
+
.join(', '),
|
|
31
|
+
{
|
|
32
|
+
maxInlineSize: width,
|
|
33
|
+
margin: 'auto',
|
|
34
|
+
}
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
globalStyle(`${ArticleStyle} h1`, {
|
|
38
|
+
padding: '2.5rem 2rem',
|
|
39
|
+
fontFamily: `'Proxima Nova', 'Segoe UI Light', Quicksand, 'Myriad Set Pro', 'Lucida Grande', sans-serif`,
|
|
40
|
+
fontSize: '2rem',
|
|
41
|
+
lineHeight: '3rem',
|
|
42
|
+
textAlign: 'center',
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
globalStyle(`${ArticleStyle} h2`, {
|
|
46
|
+
padding: '1rem 1.5rem 0.75rem 1.25rem',
|
|
47
|
+
fontSize: '1.125rem',
|
|
48
|
+
lineHeight: '1.75rem',
|
|
49
|
+
borderInlineStart: '0.25rem solid #aaf',
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
globalStyle(`${ArticleStyle} h3`, {
|
|
53
|
+
position: 'relative',
|
|
54
|
+
marginBlock: '1.25rem',
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
globalStyle(`${ArticleStyle} h3::before`, {
|
|
58
|
+
position: 'absolute',
|
|
59
|
+
insetBlock: '0.1875rem 0.375rem',
|
|
60
|
+
insetInlineStart: '-1.5rem',
|
|
61
|
+
content: '',
|
|
62
|
+
borderInlineStart: '0.25rem solid #999',
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
globalStyle(`${ArticleStyle} p, ${ArticleStyle} li`, {
|
|
66
|
+
marginBlock: '1.25rem',
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
globalStyle(`${ArticleStyle} ul`, {
|
|
70
|
+
paddingInlineStart: '1em',
|
|
71
|
+
listStyle: 'circle',
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
globalStyle(`${ArticleStyle} ol`, {
|
|
75
|
+
paddingInlineStart: '1em',
|
|
76
|
+
listStyle: 'auto',
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
globalStyle(`${ArticleStyle} a`, {
|
|
80
|
+
color: '#08c',
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
globalStyle(`${ArticleStyle} a:hover`, {
|
|
84
|
+
color: '#15c',
|
|
85
|
+
textDecoration: 'underline',
|
|
86
|
+
textDecorationColor: '#58e',
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
globalStyle(`${ArticleStyle} a:focus-visible`, {
|
|
90
|
+
outline: '1px dotted rgb(0 0 0 / 75%)',
|
|
91
|
+
outlineOffset: '2px',
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
globalStyle(`${ArticleStyle} a[download]`, {
|
|
95
|
+
vars: {
|
|
96
|
+
[color]: 'light-dark(#fff, #fff)',
|
|
97
|
+
[background]: 'light-dark(#acc, #222)',
|
|
98
|
+
},
|
|
99
|
+
display: 'inline-block',
|
|
100
|
+
blockSize: '1.75rem',
|
|
101
|
+
padding: '0 0.5rem',
|
|
102
|
+
fontSize: '0.875rem',
|
|
103
|
+
lineHeight: '1.75rem',
|
|
104
|
+
color,
|
|
105
|
+
background,
|
|
106
|
+
borderRadius: '0.125rem',
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
globalStyle(`${ArticleStyle} :has(> a[download]:only-child)`, {
|
|
110
|
+
paddingInline: '1.5rem',
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
globalStyle(`${ArticleStyle} a[download]:hover`, {
|
|
114
|
+
color: '#fff',
|
|
115
|
+
textDecoration: 'none',
|
|
116
|
+
background: '#8aa',
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
globalStyle(`${ArticleStyle} a[download]:focus-visible`, {
|
|
120
|
+
outline: '2px solid rgb(102 136 136 / 40%)',
|
|
121
|
+
outlineOffset: '1px',
|
|
122
|
+
background: '#688',
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
globalStyle(`${ArticleStyle} code`, {
|
|
126
|
+
display: 'inline-block',
|
|
127
|
+
padding: '0.125rem',
|
|
128
|
+
fontFamily: `Monaco, 'Andale Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace`,
|
|
129
|
+
fontSize: '0.875rem',
|
|
130
|
+
lineHeight: '1rem',
|
|
131
|
+
verticalAlign: 'top',
|
|
132
|
+
color: '#333',
|
|
133
|
+
whiteSpace: 'pre',
|
|
134
|
+
background: '#e5e5e5',
|
|
135
|
+
borderRadius: '0.125rem',
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
globalStyle(`${ArticleStyle} code::selection`, {
|
|
139
|
+
background: '#bbb',
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
globalStyle(`${ArticleStyle} section`, {
|
|
143
|
+
padding: '0.25rem 1.5rem',
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
globalStyle(`${ArticleStyle} footer`, {
|
|
147
|
+
vars: {
|
|
148
|
+
[gap]: '1.25rem',
|
|
149
|
+
[color]: '#aaf',
|
|
150
|
+
},
|
|
151
|
+
display: 'flex',
|
|
152
|
+
gap,
|
|
153
|
+
placeContent: 'center',
|
|
154
|
+
placeItems: 'center',
|
|
155
|
+
marginBlock: '2.5rem',
|
|
156
|
+
overflow: 'clip',
|
|
157
|
+
color,
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
globalStyle(`${ArticleStyle} footer::selection`, {
|
|
161
|
+
color: '#88d',
|
|
162
|
+
background: '#ccc',
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
globalStyle(`${ArticleStyle} footer strong, ${ArticleStyle} footer time`, {
|
|
166
|
+
position: 'relative',
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
globalStyle(
|
|
170
|
+
`${ArticleStyle} footer strong::before, ${ArticleStyle} footer time::after`,
|
|
171
|
+
{
|
|
172
|
+
position: 'absolute',
|
|
173
|
+
insetBlockStart: '0.5625rem',
|
|
174
|
+
inlineSize: width,
|
|
175
|
+
blockSize: '0.125rem',
|
|
176
|
+
content: '',
|
|
177
|
+
background: color,
|
|
178
|
+
}
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
globalStyle(`${ArticleStyle} footer strong::before`, {
|
|
182
|
+
insetInlineEnd: '100%',
|
|
183
|
+
marginInlineEnd: gap,
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
globalStyle(`${ArticleStyle} footer time::after`, {
|
|
187
|
+
insetInlineStart: '100%',
|
|
188
|
+
marginInlineStart: gap,
|
|
189
|
+
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './article.css'
|
|
@@ -5,6 +5,7 @@ import invariant from 'tiny-invariant'
|
|
|
5
5
|
import { KeyboardContext } from './context'
|
|
6
6
|
import {
|
|
7
7
|
useLastFocused,
|
|
8
|
+
useMoveFocus,
|
|
8
9
|
useNavigate,
|
|
9
10
|
usePool,
|
|
10
11
|
type Navigate,
|
|
@@ -62,10 +63,14 @@ export function Keyboard(props: KeyboardProps) {
|
|
|
62
63
|
|
|
63
64
|
const [isActivated, activate, reset] = useActivate(onActivate)
|
|
64
65
|
|
|
65
|
-
const [active, isFocusVisible,
|
|
66
|
+
const [active, isFocusVisible, moveFocus] = useMoveFocus(tree)
|
|
67
|
+
|
|
68
|
+
const navigate = useNavigate(
|
|
66
69
|
type,
|
|
67
70
|
direction,
|
|
68
71
|
tree,
|
|
72
|
+
active,
|
|
73
|
+
moveFocus,
|
|
69
74
|
(...args) => {
|
|
70
75
|
const target = props.parse?.(...args)
|
|
71
76
|
|
|
@@ -8,6 +8,8 @@ import {
|
|
|
8
8
|
import { preferVirtualFocus } from '../resolve'
|
|
9
9
|
import type { Tree } from '../tree'
|
|
10
10
|
|
|
11
|
+
export type MoveFocus = ReturnType<typeof useMoveFocus>[2]
|
|
12
|
+
|
|
11
13
|
export function useMoveFocus(tree: Tree) {
|
|
12
14
|
const [active, setActive] = useState<Element | null>(null)
|
|
13
15
|
const [isFocusVisible, setIsFocusVisible] = useState(false)
|
|
@@ -2,7 +2,7 @@ import { useCallback, useLayoutEffect, useRef } from 'react'
|
|
|
2
2
|
import type { NavigationDirection, NavigationType } from '..'
|
|
3
3
|
import { resolve, type Parse } from '../resolve'
|
|
4
4
|
import type { Tree } from '../tree'
|
|
5
|
-
import {
|
|
5
|
+
import type { MoveFocus } from './useMoveFocus'
|
|
6
6
|
|
|
7
7
|
export type NavigateCallback = (
|
|
8
8
|
ev: KeyboardEvent | React.KeyboardEvent,
|
|
@@ -10,17 +10,17 @@ export type NavigateCallback = (
|
|
|
10
10
|
from: Tree.Node | null
|
|
11
11
|
) => void
|
|
12
12
|
|
|
13
|
-
export type Navigate = ReturnType<typeof useNavigate>
|
|
13
|
+
export type Navigate = ReturnType<typeof useNavigate>
|
|
14
14
|
|
|
15
15
|
export function useNavigate(
|
|
16
16
|
type: NavigationType,
|
|
17
17
|
direction: NavigationDirection,
|
|
18
18
|
tree: Tree,
|
|
19
|
+
active: Tree.Node | null,
|
|
20
|
+
moveFocus: MoveFocus,
|
|
19
21
|
parse: Parse,
|
|
20
22
|
onNavigate?: NavigateCallback
|
|
21
23
|
) {
|
|
22
|
-
const [active, isFocusVisible, moveFocus] = useMoveFocus(tree)
|
|
23
|
-
|
|
24
24
|
const ref = useRef({
|
|
25
25
|
tree,
|
|
26
26
|
active,
|
|
@@ -87,5 +87,5 @@ export function useNavigate(
|
|
|
87
87
|
}
|
|
88
88
|
})
|
|
89
89
|
|
|
90
|
-
return
|
|
90
|
+
return navigate
|
|
91
91
|
}
|
|
@@ -3,7 +3,7 @@ import { mergeSort } from '#util'
|
|
|
3
3
|
|
|
4
4
|
export function sort<T extends TreeNode<Element>>(arr: readonly T[]) {
|
|
5
5
|
return mergeSort(arr, ({ value: a }, { value: b }) => {
|
|
6
|
-
/* istanbul ignore next
|
|
6
|
+
/* istanbul ignore next */
|
|
7
7
|
if (a === b) {
|
|
8
8
|
return 0
|
|
9
9
|
}
|
|
@@ -45,7 +45,7 @@ export function useHighlight(
|
|
|
45
45
|
)
|
|
46
46
|
|
|
47
47
|
useLayoutEffect(() => {
|
|
48
|
-
/* istanbul ignore next
|
|
48
|
+
/* istanbul ignore next */
|
|
49
49
|
if (typeof Highlight !== 'function') return
|
|
50
50
|
|
|
51
51
|
const el = refValue(ref)
|
|
@@ -76,29 +76,3 @@ export function useHighlight(
|
|
|
76
76
|
|
|
77
77
|
return highlight
|
|
78
78
|
}
|
|
79
|
-
|
|
80
|
-
declare global {
|
|
81
|
-
/**
|
|
82
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/Highlight
|
|
83
|
-
*/
|
|
84
|
-
interface Highlight {
|
|
85
|
-
readonly size: number
|
|
86
|
-
add(range: Range): this
|
|
87
|
-
clear(): void
|
|
88
|
-
delete(range: Range): boolean
|
|
89
|
-
entries(): IterableIterator<[Range, Range]>
|
|
90
|
-
has(range: Range): boolean
|
|
91
|
-
keys(): IterableIterator<Range>
|
|
92
|
-
values(): IterableIterator<Range>
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/HighlightRegistry
|
|
97
|
-
*/
|
|
98
|
-
interface HighlightRegistry {
|
|
99
|
-
readonly size: number
|
|
100
|
-
delete(name: string): boolean
|
|
101
|
-
set(name: string, highlight: Highlight): this
|
|
102
|
-
values(): IterableIterator<Highlight>
|
|
103
|
-
}
|
|
104
|
-
}
|
|
@@ -194,7 +194,7 @@ export function useAutoComplete<
|
|
|
194
194
|
(ev) => {
|
|
195
195
|
onBlur?.(ev)
|
|
196
196
|
|
|
197
|
-
/* istanbul ignore else
|
|
197
|
+
/* istanbul ignore else */
|
|
198
198
|
if (!ev.defaultPrevented) {
|
|
199
199
|
setState({
|
|
200
200
|
query: undefined,
|
|
@@ -228,7 +228,7 @@ export function useAutoComplete<
|
|
|
228
228
|
|
|
229
229
|
const value = args[0].context.value
|
|
230
230
|
|
|
231
|
-
/* istanbul ignore next
|
|
231
|
+
/* istanbul ignore next */
|
|
232
232
|
if (typeof value !== 'string') return
|
|
233
233
|
|
|
234
234
|
const label = options?.find((option) => option.value === value)?.label
|
|
@@ -269,7 +269,7 @@ export function useAutoComplete<
|
|
|
269
269
|
|
|
270
270
|
if (query != null) return query
|
|
271
271
|
|
|
272
|
-
/* istanbul ignore next
|
|
272
|
+
/* istanbul ignore next */
|
|
273
273
|
if (multiple) return ''
|
|
274
274
|
|
|
275
275
|
if (value === undefined) return ''
|
|
@@ -90,6 +90,7 @@ export function useDefault<E extends Partial<Event>, T, U extends T>(
|
|
|
90
90
|
const isControlled = useConst(() => props.value !== undefined)
|
|
91
91
|
|
|
92
92
|
invariant(
|
|
93
|
+
/* istanbul ignore next */
|
|
93
94
|
process.env.NODE_ENV === 'production' ||
|
|
94
95
|
isControlled === (props.value !== undefined),
|
|
95
96
|
isControlled
|
|
@@ -119,6 +120,7 @@ export function useDefault<E extends Partial<Event>, T, U extends T>(
|
|
|
119
120
|
|
|
120
121
|
const onChange = useCallback<ChangeCallback<E, V>>((ev, value, hint) => {
|
|
121
122
|
invariant(
|
|
123
|
+
/* istanbul ignore next */
|
|
122
124
|
process.env.NODE_ENV === 'production' || ref.current.isMounted,
|
|
123
125
|
'Cannot call `onChange` within the `useLayoutEffect` hook of a child component, as the parent component has not been mounted yet.'
|
|
124
126
|
)
|
package/src/hook/form/useForm.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createElement, useMemo, type PropsWithChildren } from 'react'
|
|
2
|
-
import { FormContext } from './context'
|
|
3
2
|
import { useDefault, type ChangeCallback } from '.'
|
|
3
|
+
import { FormContext } from './context'
|
|
4
4
|
|
|
5
5
|
interface Props<T extends object> extends PropsWithChildren {
|
|
6
6
|
defaultValue?: T | undefined
|
|
@@ -21,7 +21,7 @@ export function useForm<P extends Props<{}>>(props: P) {
|
|
|
21
21
|
)
|
|
22
22
|
|
|
23
23
|
let { children } = props
|
|
24
|
-
children = createElement(FormContext, { value: context },
|
|
24
|
+
children = createElement(FormContext, { value: context }, children)
|
|
25
25
|
|
|
26
26
|
props = {
|
|
27
27
|
...props,
|
|
@@ -11,8 +11,8 @@ import {
|
|
|
11
11
|
type SyntheticEvent,
|
|
12
12
|
} from 'react'
|
|
13
13
|
import invariant from 'tiny-invariant'
|
|
14
|
-
import { FormContext } from './context'
|
|
15
14
|
import { useDefault, type ChangeCallback } from '.'
|
|
15
|
+
import { FormContext } from './context'
|
|
16
16
|
|
|
17
17
|
interface Props<T, E extends SyntheticEvent> extends PropsWithChildren {
|
|
18
18
|
name?: string | undefined
|
|
@@ -141,6 +141,7 @@ export function useGroup<T, P extends Props<T, SyntheticEvent>>(props: P) {
|
|
|
141
141
|
|
|
142
142
|
props = {
|
|
143
143
|
...props,
|
|
144
|
+
// eslint-disable-next-line react-hooks/refs
|
|
144
145
|
children: createElement(FormContext, { value: _context }, props.children),
|
|
145
146
|
}
|
|
146
147
|
|
|
@@ -58,7 +58,7 @@ export function usePopover<T extends React.HTMLElementType = 'div'>(
|
|
|
58
58
|
|
|
59
59
|
let anchorProps: OverlayAnchorProps = { ...anchor?.props }
|
|
60
60
|
let positionedProps: React.JSX.IntrinsicElements[T] = { ...props }
|
|
61
|
-
let keyboardProps: KeyboardProps
|
|
61
|
+
let keyboardProps: KeyboardProps
|
|
62
62
|
|
|
63
63
|
{
|
|
64
64
|
const _id = useUniqueId('popover-')
|
|
@@ -103,7 +103,11 @@ export function usePopover<T extends React.HTMLElementType = 'div'>(
|
|
|
103
103
|
const { anchor, positioned }: Overlay<HTMLElement> = overlay
|
|
104
104
|
|
|
105
105
|
if (positioned && overlay.open && !positioned.matches(':popover-open')) {
|
|
106
|
-
|
|
106
|
+
const _source = source || anchor
|
|
107
|
+
|
|
108
|
+
positioned.showPopover(
|
|
109
|
+
_source instanceof HTMLElement ? { source: _source } : undefined
|
|
110
|
+
)
|
|
107
111
|
}
|
|
108
112
|
})
|
|
109
113
|
|
|
@@ -164,6 +168,7 @@ export function usePopover<T extends React.HTMLElementType = 'div'>(
|
|
|
164
168
|
children,
|
|
165
169
|
}
|
|
166
170
|
|
|
171
|
+
// eslint-disable-next-line react-hooks/refs
|
|
167
172
|
positionedProps.children = createElement(
|
|
168
173
|
OverlayContext,
|
|
169
174
|
{ value: overlay },
|
|
@@ -178,13 +183,3 @@ export function usePopover<T extends React.HTMLElementType = 'div'>(
|
|
|
178
183
|
keyboard: { props: keyboardProps },
|
|
179
184
|
}
|
|
180
185
|
}
|
|
181
|
-
|
|
182
|
-
declare global {
|
|
183
|
-
interface ShowPopoverOptions {
|
|
184
|
-
source?: Element | undefined
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
interface HTMLElement {
|
|
188
|
-
showPopover(options?: ShowPopoverOptions): void
|
|
189
|
-
}
|
|
190
|
-
}
|