chiplet 0.4.0 → 0.6.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/dist/assets/{global.css.ts.vanilla-CTwjHiaM.css → global.css.ts.vanilla-C6UQbnfq.css} +8 -2
- package/dist/assets/{positioning.css.ts.vanilla-BVOg9Lwj.css → positioning.css.ts.vanilla-BLJ90UCF.css} +12 -12
- package/dist/component/button/LinkButton.js +1 -1
- 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.js +2 -2
- package/dist/component/checkbox/Checkbox.js +5 -1
- package/dist/component/checkbox/Checkbox.js.map +1 -1
- package/dist/component/checkbox/Radio.js +5 -1
- package/dist/component/checkbox/Radio.js.map +1 -1
- package/dist/component/checkbox/Switch.js +1 -1
- package/dist/component/checkbox/Switch.js.map +1 -1
- package/dist/component/header/Header.js +1 -1
- package/dist/component/header/Header.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 +5 -1
- package/dist/component/input/Input.js.map +1 -1
- package/dist/component/input/SearchInput.js +4 -7
- package/dist/component/input/SearchInput.js.map +1 -1
- package/dist/component/input/style/index.css.js +2 -2
- package/dist/component/menu/renderMenuItem.js +5 -1
- package/dist/component/menu/renderMenuItem.js.map +1 -1
- package/dist/component/popover/Portal.js +8 -1
- package/dist/component/popover/Portal.js.map +1 -1
- package/dist/component/popover/style/index.css.js +4 -4
- package/dist/component/select/Group.js +1 -1
- package/dist/component/select/Group.js.map +1 -1
- package/dist/component/select/Option.js +1 -1
- package/dist/component/select/Option.js.map +1 -1
- package/dist/component/select/style/index.css.js +2 -2
- package/dist/hook/accessibility/keyboard/context/index.js.map +1 -1
- package/dist/hook/accessibility/keyboard/hook/useLastFocused.js.map +1 -1
- package/dist/hook/document/useHighlight.js +2 -4
- package/dist/hook/document/useHighlight.js.map +1 -1
- package/dist/hook/form/useGroup.js +17 -16
- package/dist/hook/form/useGroup.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/style/positioning.css.js +1 -1
- package/dist/hook/popover/useAnchorPositioning.js +1 -1
- package/dist/hook/popover/useAnchorPositioning.js.map +1 -1
- package/dist/hook/popover/useLightDismiss.js +15 -0
- package/dist/hook/popover/useLightDismiss.js.map +1 -1
- package/dist/hook/popover/useOverlay.js +8 -5
- package/dist/hook/popover/useOverlay.js.map +1 -1
- package/dist/hook/popover/usePopover.js +11 -11
- package/dist/hook/popover/usePopover.js.map +1 -1
- package/dist/hook/popover/usePositioning.js +7 -12
- 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 -2
- 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/useActivate.js +3 -0
- 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/useRefCallback.js.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/infra/logging/logger.js +6 -2
- package/dist/infra/logging/logger.js.map +1 -1
- package/dist/theme/ThemeContext.js +8 -0
- package/dist/theme/ThemeContext.js.map +1 -0
- package/dist/theme/ThemeProvider.js +19 -0
- package/dist/theme/ThemeProvider.js.map +1 -0
- package/dist/theme/global.css.js +6 -4
- package/dist/theme/global.css.js.map +1 -1
- package/dist/theme/index.js +5 -1
- package/dist/theme/index.js.map +1 -1
- package/dist/theme/useSystemColorScheme.js +16 -16
- package/dist/theme/useSystemColorScheme.js.map +1 -1
- package/dist/util/file/readAsDataURL.js +15 -4
- package/dist/util/file/readAsDataURL.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/detachChild.js +3 -0
- package/dist/util/tree/detachChild.js.map +1 -1
- package/package.json +17 -17
- package/src/component/button/LinkButton.tsx +3 -1
- package/src/component/button/index.ts +1 -0
- package/src/component/checkbox/Checkbox.tsx +7 -1
- package/src/component/checkbox/Radio.tsx +5 -1
- package/src/component/checkbox/Switch.tsx +1 -1
- package/src/component/header/Header.tsx +1 -1
- package/src/component/input/Input.tsx +5 -1
- package/src/component/input/SearchInput.tsx +9 -8
- package/src/component/menu/renderMenuItem.tsx +5 -1
- package/src/component/popover/Portal.tsx +20 -1
- package/src/component/select/Group.tsx +1 -1
- package/src/component/select/Option.tsx +1 -1
- package/src/hook/accessibility/keyboard/context/index.ts +1 -1
- package/src/hook/accessibility/keyboard/hook/useLastFocused.ts +6 -0
- package/src/hook/document/useHighlight.ts +5 -4
- package/src/hook/form/useGroup.ts +17 -19
- package/src/hook/observable/useObservable.ts +14 -1
- package/src/hook/popover/style/positioning.css.ts +1 -1
- package/src/hook/popover/useAnchorPositioning.ts +1 -1
- package/src/hook/popover/useLightDismiss.ts +27 -0
- package/src/hook/popover/useOverlay.ts +15 -6
- package/src/hook/popover/usePopover.ts +11 -13
- package/src/hook/popover/usePositioning.ts +7 -15
- package/src/hook/popover/useReturnFocus.ts +12 -3
- package/src/hook/popover/useTooltip.ts +4 -3
- package/src/hook/promise/usePromise.ts +4 -1
- package/src/hook/react/useActivate.ts +8 -1
- package/src/hook/react/useConst.ts +3 -4
- package/src/hook/react/useRefCallback.ts +2 -0
- package/src/infra/logging/logger.ts +12 -2
- package/src/theme/ThemeContext.ts +15 -0
- package/src/theme/ThemeProvider.tsx +26 -0
- package/src/theme/global.css.ts +14 -28
- package/src/theme/index.ts +8 -0
- package/src/theme/useSystemColorScheme.ts +22 -20
- package/src/util/file/readAsDataURL.ts +17 -4
- package/src/util/number/index.ts +2 -0
- package/src/util/random/index.ts +4 -0
- package/src/util/tree/attachChild.ts +12 -1
- package/src/util/tree/detachChild.ts +6 -0
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
import { detachChild } from './detachChild.js';
|
|
3
|
+
|
|
2
4
|
function attachChild(parent, child) {
|
|
5
|
+
if (child.parent != null) {
|
|
6
|
+
detachChild(child.parent, child);
|
|
7
|
+
}
|
|
8
|
+
child.previousSibling = parent.lastChild ?? null;
|
|
9
|
+
child.nextSibling = null;
|
|
3
10
|
if (parent.firstChild == null) {
|
|
4
11
|
parent.firstChild = child;
|
|
5
12
|
}
|
|
6
13
|
if (parent.lastChild) {
|
|
7
14
|
parent.lastChild.nextSibling = child;
|
|
8
|
-
child.previousSibling = parent.lastChild;
|
|
9
15
|
}
|
|
10
16
|
parent.lastChild = child;
|
|
11
17
|
child.parent = parent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachChild.js","sources":["../../../src/util/tree/attachChild.ts"],"sourcesContent":["import type { TreeNode } from './node'\n\nexport function attachChild<T extends TreeNode<unknown>>(parent: T, child: T) {\n if (parent.firstChild == null) {\n parent.firstChild = child\n }\n\n if (parent.lastChild) {\n parent.lastChild.nextSibling = child\n
|
|
1
|
+
{"version":3,"file":"attachChild.js","sources":["../../../src/util/tree/attachChild.ts"],"sourcesContent":["import { detachChild } from './detachChild'\nimport type { TreeNode } from './node'\n\nexport function attachChild<T extends TreeNode<unknown>>(parent: T, child: T) {\n // Detach a child that is still attached to a tree first so re-attaching\n // cannot leave stale or self-referential links behind.\n if (child.parent != null) {\n detachChild(child.parent, child)\n }\n\n // Reset the child's sibling links so a node previously attached elsewhere\n // cannot keep stale links into its former tree.\n child.previousSibling = parent.lastChild ?? null\n child.nextSibling = null\n\n if (parent.firstChild == null) {\n parent.firstChild = child\n }\n\n if (parent.lastChild) {\n parent.lastChild.nextSibling = child\n }\n\n parent.lastChild = child\n child.parent = parent\n\n return parent\n}\n"],"names":[],"mappings":";;;AAGO,CAAA,CAAA,CAAA,CAAA,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AA,CAAA,CAAA,CAAA,EAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAW;AACpB,CAAA,CAAA,CAAA,CAAA,MAAA,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAU,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAc,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CACjC;AAEA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAY,CAAA,CAAA,CAAA,CAAA,CAAA;AACnB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAEf,CAAA,CAAA,OAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACT;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detachChild.js","sources":["../../../src/util/tree/detachChild.ts"],"sourcesContent":["import type { TreeNode } from './node'\n\nexport function detachChild<T extends TreeNode<unknown>>(parent: T, child: T) {\n if (parent.firstChild === child) {\n parent.firstChild = child.nextSibling ?? null\n }\n\n if (parent.lastChild === child) {\n parent.lastChild = child.previousSibling ?? null\n }\n\n if (child.previousSibling) {\n child.previousSibling.nextSibling = child.nextSibling ?? null\n }\n\n if (child.nextSibling) {\n child.nextSibling.previousSibling = child.previousSibling ?? null\n }\n\n return parent\n}\n"],"names":[],"mappings":";AAEO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAyC,CAAA,CAAA,CAAA,CAAA,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AAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAc,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAe,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CAC3D;AAEA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAI,CAAA,CAAA,CAAA,CAAA,EAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAa;AACrB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAY,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAkB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAmB,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CAC/D;
|
|
1
|
+
{"version":3,"file":"detachChild.js","sources":["../../../src/util/tree/detachChild.ts"],"sourcesContent":["import type { TreeNode } from './node'\n\nexport function detachChild<T extends TreeNode<unknown>>(parent: T, child: T) {\n if (parent.firstChild === child) {\n parent.firstChild = child.nextSibling ?? null\n }\n\n if (parent.lastChild === child) {\n parent.lastChild = child.previousSibling ?? null\n }\n\n if (child.previousSibling) {\n child.previousSibling.nextSibling = child.nextSibling ?? null\n }\n\n if (child.nextSibling) {\n child.nextSibling.previousSibling = child.previousSibling ?? null\n }\n\n // Detach the child's own links so it cannot reach back into the tree it\n // was removed from.\n child.parent = null\n child.previousSibling = null\n child.nextSibling = null\n\n return parent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A,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAkB,CAAA,CAAA,CAAA,CAAA;AACxB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAc,CAAA,CAAA,CAAA,CAAA;AAEpB,CAAA,CAAA,OAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACT;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chiplet",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "React component, hook, and utility library.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -75,8 +75,8 @@
|
|
|
75
75
|
"@commitlint/cli": "^21.2.4",
|
|
76
76
|
"@commitlint/config-conventional": "^21.2.4",
|
|
77
77
|
"@commitlint/types": "^21.2.3",
|
|
78
|
-
"@csstools/postcss-light-dark-function": "^3.0.
|
|
79
|
-
"@csstools/postcss-relative-color-syntax": "^4.0.
|
|
78
|
+
"@csstools/postcss-light-dark-function": "^3.0.9",
|
|
79
|
+
"@csstools/postcss-relative-color-syntax": "^4.0.17",
|
|
80
80
|
"@eslint/js": "^10.0.1",
|
|
81
81
|
"@rollup/plugin-babel": "^7.1.0",
|
|
82
82
|
"@rollup/plugin-commonjs": "^29.0.3",
|
|
@@ -89,9 +89,9 @@
|
|
|
89
89
|
"@storybook/react-vite": "^10.6.7",
|
|
90
90
|
"@svgr/rollup": "^8.1.0",
|
|
91
91
|
"@tailwindcss/postcss": "^4.3.5",
|
|
92
|
-
"@testing-library/jest-dom": "^
|
|
92
|
+
"@testing-library/jest-dom": "^8.0.0",
|
|
93
93
|
"@testing-library/react": "^16.3.3",
|
|
94
|
-
"@testing-library/user-event": "^14.6.
|
|
94
|
+
"@testing-library/user-event": "^14.6.13",
|
|
95
95
|
"@types/lodash-es": "^4.17.12",
|
|
96
96
|
"@types/node": "^24.12.2",
|
|
97
97
|
"@types/react": "^19.3.0",
|
|
@@ -101,12 +101,12 @@
|
|
|
101
101
|
"@vanilla-extract/vite-plugin": "^5.2.6",
|
|
102
102
|
"@vitejs/plugin-legacy": "^8.2.4",
|
|
103
103
|
"@vitejs/plugin-react": "^6.3.0",
|
|
104
|
-
"@vitest/browser-playwright": "^5.1.
|
|
105
|
-
"@vitest/coverage-istanbul": "^5.1.
|
|
104
|
+
"@vitest/browser-playwright": "^5.1.1",
|
|
105
|
+
"@vitest/coverage-istanbul": "^5.1.1",
|
|
106
106
|
"babel-plugin-react-compiler": "^1.0.0",
|
|
107
107
|
"clsx": "^2.1.1",
|
|
108
108
|
"colorjs.io": "^0.7.1",
|
|
109
|
-
"csstype": "^3.2.
|
|
109
|
+
"csstype": "^3.2.4",
|
|
110
110
|
"eslint": "^10.15.0",
|
|
111
111
|
"eslint-plugin-import-x": "^4.18.1",
|
|
112
112
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
@@ -120,17 +120,17 @@
|
|
|
120
120
|
"lint-staged": "^17.6.1",
|
|
121
121
|
"playwright": "^1.65.1",
|
|
122
122
|
"postcss": "^8.5.33",
|
|
123
|
-
"postcss-html": "^2.0.
|
|
123
|
+
"postcss-html": "^2.0.1",
|
|
124
124
|
"postcss-scss": "^4.0.9",
|
|
125
125
|
"postcss-styled-syntax": "^0.7.4",
|
|
126
126
|
"prettier": "^3.10.1",
|
|
127
127
|
"prettier-plugin-tailwindcss": "^0.8.1",
|
|
128
128
|
"react": "^19.3.1",
|
|
129
129
|
"react-dom": "^19.3.1",
|
|
130
|
-
"reelout": "^0.
|
|
130
|
+
"reelout": "^0.6.1",
|
|
131
131
|
"remark-gfm": "^4.0.1",
|
|
132
132
|
"rimraf": "^6.1.4",
|
|
133
|
-
"rollup": "^4.68.
|
|
133
|
+
"rollup": "^4.68.7",
|
|
134
134
|
"rollup-plugin-esbuild": "^6.2.1",
|
|
135
135
|
"rollup-plugin-node-externals": "^9.0.1",
|
|
136
136
|
"rollup-plugin-visualizer": "^7.1.3",
|
|
@@ -138,17 +138,17 @@
|
|
|
138
138
|
"sort-package-json": "^4.1.0",
|
|
139
139
|
"storybook": "^10.6.7",
|
|
140
140
|
"stylelint": "^18.0.0",
|
|
141
|
-
"stylelint-config-recess-order": "^7.10.
|
|
141
|
+
"stylelint-config-recess-order": "^7.10.1",
|
|
142
142
|
"stylelint-config-standard": "^41.0.0",
|
|
143
|
-
"stylelint-plugin-logical-css": "^2.1.
|
|
143
|
+
"stylelint-plugin-logical-css": "^2.1.1",
|
|
144
144
|
"tailwindcss": "^4.3.5",
|
|
145
145
|
"ts-node": "^10.9.2",
|
|
146
146
|
"tslib": "^2.9.1",
|
|
147
|
-
"type-fest": "^
|
|
148
|
-
"typescript": "^6.0.
|
|
149
|
-
"typescript-eslint": "^8.
|
|
147
|
+
"type-fest": "^6.0.3",
|
|
148
|
+
"typescript": "^6.0.3",
|
|
149
|
+
"typescript-eslint": "^8.73.0",
|
|
150
150
|
"vite": "^8.3.8",
|
|
151
|
-
"vitest": "^5.1.
|
|
151
|
+
"vitest": "^5.1.1"
|
|
152
152
|
},
|
|
153
153
|
"peerDependencies": {
|
|
154
154
|
"@vanilla-extract/css": "^1.21.3",
|
|
@@ -36,7 +36,9 @@ export function LinkButton(props: LinkButtonProps) {
|
|
|
36
36
|
return (
|
|
37
37
|
<a
|
|
38
38
|
{...attrs}
|
|
39
|
-
|
|
39
|
+
// A disabled link must not navigate: 'aria-disabled' alone does not
|
|
40
|
+
// prevent activation of an anchor with an 'href'.
|
|
41
|
+
href={disabled ? undefined : href}
|
|
40
42
|
className={clsx(
|
|
41
43
|
ButtonStyle({ color, variant, size, shape, block }),
|
|
42
44
|
LinkButtonStyle,
|
|
@@ -49,6 +49,8 @@ export function Checkbox(props: CheckboxProps) {
|
|
|
49
49
|
if (ref.current) {
|
|
50
50
|
// When a checkbox has both `indeterminate` and `checked` set to true,
|
|
51
51
|
// only the `indeterminate` state will be activated in Chromium browser.
|
|
52
|
+
// Writing the 'indeterminate' IDL attribute mutates the value returned
|
|
53
|
+
// by the 'current' getter, which the compiler cannot prove mutable.
|
|
52
54
|
// eslint-disable-next-line react-compiler/react-compiler
|
|
53
55
|
ref.current.indeterminate = !ref.current.checked && !!indeterminate
|
|
54
56
|
}
|
|
@@ -57,7 +59,11 @@ export function Checkbox(props: CheckboxProps) {
|
|
|
57
59
|
return (
|
|
58
60
|
<div
|
|
59
61
|
{...slot?.root}
|
|
60
|
-
className={clsx(
|
|
62
|
+
className={clsx(
|
|
63
|
+
CheckboxStyle({ size }),
|
|
64
|
+
slot?.root?.className,
|
|
65
|
+
className
|
|
66
|
+
)}
|
|
61
67
|
style={style}
|
|
62
68
|
>
|
|
63
69
|
<input
|
|
@@ -37,7 +37,11 @@ export function Radio(props: RadioProps) {
|
|
|
37
37
|
return (
|
|
38
38
|
<div
|
|
39
39
|
{...slot?.root}
|
|
40
|
-
className={clsx(
|
|
40
|
+
className={clsx(
|
|
41
|
+
CheckboxStyle({ size }),
|
|
42
|
+
slot?.root?.className,
|
|
43
|
+
className
|
|
44
|
+
)}
|
|
41
45
|
style={style}
|
|
42
46
|
>
|
|
43
47
|
<input
|
|
@@ -20,7 +20,7 @@ export function Header(props: HeaderProps) {
|
|
|
20
20
|
<header
|
|
21
21
|
{...slot?.root}
|
|
22
22
|
{...attrs}
|
|
23
|
-
className={clsx(HeaderStyle, attrs.className)}
|
|
23
|
+
className={clsx(HeaderStyle, slot?.root?.className, attrs.className)}
|
|
24
24
|
>
|
|
25
25
|
<nav {...slot?.nav} className={clsx(NavStyle, slot?.nav?.className)}>
|
|
26
26
|
{props.renderNav()}
|
|
@@ -44,7 +44,11 @@ export function Input(props: InputProps) {
|
|
|
44
44
|
return (
|
|
45
45
|
<div
|
|
46
46
|
{...slot?.root}
|
|
47
|
-
className={clsx(
|
|
47
|
+
className={clsx(
|
|
48
|
+
InputStyle({ variant, size }),
|
|
49
|
+
slot?.root?.className,
|
|
50
|
+
className
|
|
51
|
+
)}
|
|
48
52
|
style={style}
|
|
49
53
|
>
|
|
50
54
|
{before}
|
|
@@ -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
|
}
|
|
@@ -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}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ThemeContext } from '#theme'
|
|
2
|
+
import { use } from 'react'
|
|
1
3
|
import { createPortal } from 'react-dom'
|
|
2
4
|
|
|
3
5
|
export interface PortalProps extends React.PropsWithChildren {
|
|
@@ -7,6 +9,14 @@ export interface PortalProps extends React.PropsWithChildren {
|
|
|
7
9
|
export function Portal(props: PortalProps) {
|
|
8
10
|
let { container } = props
|
|
9
11
|
|
|
12
|
+
// Portaled content leaves the themed root, so re-establish the active
|
|
13
|
+
// 'ThemeContext' scope around it here rather than in
|
|
14
|
+
// 'usePopover'/'useTooltip'/'useDialog': those hooks only produce props
|
|
15
|
+
// for the positioned element, and merging the scope classes onto that
|
|
16
|
+
// element would compete with the overlay's own surface styles in the
|
|
17
|
+
// cascade.
|
|
18
|
+
const scope = use(ThemeContext)
|
|
19
|
+
|
|
10
20
|
if (!container && typeof document !== 'undefined') {
|
|
11
21
|
container = document.body
|
|
12
22
|
}
|
|
@@ -15,5 +25,14 @@ export function Portal(props: PortalProps) {
|
|
|
15
25
|
return null
|
|
16
26
|
}
|
|
17
27
|
|
|
18
|
-
return createPortal(
|
|
28
|
+
return createPortal(
|
|
29
|
+
scope === null ? (
|
|
30
|
+
props.children
|
|
31
|
+
) : (
|
|
32
|
+
<div className={scope.className} style={{ display: 'contents' }}>
|
|
33
|
+
{props.children}
|
|
34
|
+
</div>
|
|
35
|
+
),
|
|
36
|
+
container
|
|
37
|
+
)
|
|
19
38
|
}
|
|
@@ -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,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { createContext } from 'react'
|
|
3
3
|
import type { Keyboard } from '../Keyboard'
|
|
4
|
-
import type { PoolAdd, PoolRemove } from '../hook'
|
|
4
|
+
import type { PoolAdd, PoolRemove } from '../hook/usePool'
|
|
5
5
|
|
|
6
6
|
export interface KeyboardContext extends Keyboard {
|
|
7
7
|
lastActive: Element | null
|
|
@@ -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,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
|
)
|
|
@@ -57,16 +57,6 @@ export function useGroup<T, P extends Props<T, SyntheticEvent>>(props: P) {
|
|
|
57
57
|
value: _value,
|
|
58
58
|
})
|
|
59
59
|
|
|
60
|
-
// eslint-disable-next-line react-hooks/immutability, react-compiler/react-compiler
|
|
61
|
-
props = {
|
|
62
|
-
...props,
|
|
63
|
-
name,
|
|
64
|
-
defaultValue: undefined,
|
|
65
|
-
value,
|
|
66
|
-
multiple,
|
|
67
|
-
disabled,
|
|
68
|
-
}
|
|
69
|
-
|
|
70
60
|
const [_state, _setState] = useDefault({
|
|
71
61
|
defaultValue: {},
|
|
72
62
|
value: context?.value,
|
|
@@ -130,20 +120,28 @@ export function useGroup<T, P extends Props<T, SyntheticEvent>>(props: P) {
|
|
|
130
120
|
[name, setState]
|
|
131
121
|
)
|
|
132
122
|
|
|
133
|
-
props = {
|
|
134
|
-
...props,
|
|
135
|
-
onChange: handleChange,
|
|
136
|
-
}
|
|
137
|
-
|
|
138
123
|
const _context = useMemo<NonNullable<typeof context>>(
|
|
139
124
|
() => ({ name, value: state, multiple, disabled, onChange: setState }),
|
|
140
125
|
[disabled, multiple, name, setState, state]
|
|
141
126
|
)
|
|
142
127
|
|
|
143
|
-
|
|
128
|
+
const groupProps: P = {
|
|
144
129
|
...props,
|
|
145
|
-
|
|
146
|
-
|
|
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
|
+
),
|
|
147
145
|
}
|
|
148
146
|
|
|
149
147
|
return {
|
|
@@ -152,7 +150,7 @@ export function useGroup<T, P extends Props<T, SyntheticEvent>>(props: P) {
|
|
|
152
150
|
multiple,
|
|
153
151
|
disabled,
|
|
154
152
|
onChange: handleChange,
|
|
155
|
-
props,
|
|
153
|
+
props: groupProps,
|
|
156
154
|
context: _context,
|
|
157
155
|
}
|
|
158
156
|
}
|
|
@@ -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()
|
|
@@ -103,9 +103,9 @@ export const positionTryOptionMap: Record<Position, string> = fromEntries(
|
|
|
103
103
|
|
|
104
104
|
for (const [position, area] of entries(positionAreaMap)) {
|
|
105
105
|
globalStyle(`@position-try ${positionTryOptionMap[position]}`, {
|
|
106
|
-
positionArea: area,
|
|
107
106
|
inset: 'auto',
|
|
108
107
|
[positionInsetMap[position]]: `var(${PositionOffset})`,
|
|
108
|
+
positionArea: area,
|
|
109
109
|
// TODO: extend 'positionTryOptionMap', add '@starting-style' entry
|
|
110
110
|
// animation, and try to reuse 'PopoverStyle'
|
|
111
111
|
})
|
|
@@ -28,6 +28,33 @@ export function useLightDismiss<
|
|
|
28
28
|
ref.current.source = source
|
|
29
29
|
})
|
|
30
30
|
|
|
31
|
+
{
|
|
32
|
+
const { onKeyDown } = anchorProps
|
|
33
|
+
|
|
34
|
+
anchorProps = {
|
|
35
|
+
...anchorProps,
|
|
36
|
+
onKeyDown: useCallback<NonNullable<typeof onKeyDown>>(
|
|
37
|
+
(ev) => {
|
|
38
|
+
onKeyDown?.(ev)
|
|
39
|
+
|
|
40
|
+
// A pending open or close claims the escape key to abort
|
|
41
|
+
// itself by reverting to the committed state. A committed
|
|
42
|
+
// open or an idle overlay toggles to a no-op and defers to
|
|
43
|
+
// the document listener below, which closes the topmost
|
|
44
|
+
// overlay instead.
|
|
45
|
+
if (
|
|
46
|
+
!ev.defaultPrevented &&
|
|
47
|
+
isEscapeKey(ev) &&
|
|
48
|
+
ref.current.overlay.toggle(ev, ref.current.overlay.open, 'escape')
|
|
49
|
+
) {
|
|
50
|
+
ev.preventDefault()
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
[onKeyDown]
|
|
54
|
+
),
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
31
58
|
{
|
|
32
59
|
const { onClickCapture } = positionedProps
|
|
33
60
|
|
|
@@ -9,6 +9,7 @@ export interface OverlayAnchorProps
|
|
|
9
9
|
onFocus?: React.FocusEventHandler<Element> | undefined
|
|
10
10
|
onBlur?: React.FocusEventHandler<Element> | undefined
|
|
11
11
|
onClick?: React.MouseEventHandler<Element> | undefined
|
|
12
|
+
onKeyDown?: React.KeyboardEventHandler<Element> | undefined
|
|
12
13
|
onPointerEnter?: React.PointerEventHandler<Element> | undefined
|
|
13
14
|
onPointerLeave?: React.PointerEventHandler<Element> | undefined
|
|
14
15
|
}
|
|
@@ -33,7 +34,7 @@ export interface Overlay<T extends HTMLElement = HTMLElement> {
|
|
|
33
34
|
ev: Event | React.SyntheticEvent,
|
|
34
35
|
open?: boolean,
|
|
35
36
|
hint?: string
|
|
36
|
-
) =>
|
|
37
|
+
) => boolean
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
export function useOverlay<T extends HTMLElement>(options: OverlayOptions<T>) {
|
|
@@ -55,13 +56,21 @@ export function useOverlay<T extends HTMLElement>(options: OverlayOptions<T>) {
|
|
|
55
56
|
(ev, open, hint) => {
|
|
56
57
|
open ??= !ref.current
|
|
57
58
|
|
|
58
|
-
if (ref.current
|
|
59
|
-
|
|
59
|
+
if (ref.current === open) {
|
|
60
|
+
return false
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
setOpen(ev, open, hint)
|
|
60
64
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
// A vetoed change (`onToggle` preventing the event) never commits in
|
|
66
|
+
// `useDefault`, so the uncommitted mirror in `ref` must not advance.
|
|
67
|
+
if (ev.defaultPrevented) {
|
|
68
|
+
return false
|
|
64
69
|
}
|
|
70
|
+
|
|
71
|
+
ref.current = open
|
|
72
|
+
|
|
73
|
+
return true
|
|
65
74
|
},
|
|
66
75
|
[setOpen]
|
|
67
76
|
)
|
|
@@ -149,6 +149,12 @@ export function usePopover<T extends React.HTMLElementType = 'div'>(
|
|
|
149
149
|
ref: anchorRef,
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
+
keyboardProps = {
|
|
153
|
+
...keyboardProps,
|
|
154
|
+
ref: setKeyboardRef,
|
|
155
|
+
children,
|
|
156
|
+
}
|
|
157
|
+
|
|
152
158
|
positionedProps = {
|
|
153
159
|
...positionedProps,
|
|
154
160
|
role: positionedProps.role || 'dialog',
|
|
@@ -160,21 +166,13 @@ export function usePopover<T extends React.HTMLElementType = 'div'>(
|
|
|
160
166
|
...positionedProps.style,
|
|
161
167
|
},
|
|
162
168
|
ref: positionedRef,
|
|
169
|
+
children: createElement(
|
|
170
|
+
OverlayContext,
|
|
171
|
+
{ value: overlay },
|
|
172
|
+
createElement(Keyboard, keyboardProps)
|
|
173
|
+
),
|
|
163
174
|
}
|
|
164
175
|
|
|
165
|
-
keyboardProps = {
|
|
166
|
-
...keyboardProps,
|
|
167
|
-
ref: setKeyboardRef,
|
|
168
|
-
children,
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// eslint-disable-next-line react-hooks/refs
|
|
172
|
-
positionedProps.children = createElement(
|
|
173
|
-
OverlayContext,
|
|
174
|
-
{ value: overlay },
|
|
175
|
-
createElement(Keyboard, keyboardProps)
|
|
176
|
-
)
|
|
177
|
-
|
|
178
176
|
return {
|
|
179
177
|
overlay,
|
|
180
178
|
position: positioning.position,
|