chiplet 0.4.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/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/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/menu/renderMenuItem.js +5 -1
- package/dist/component/menu/renderMenuItem.js.map +1 -1
- 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/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 +3 -0
- 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/index.js +2 -0
- 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/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/global.css.ts +0 -27
- package/src/theme/index.ts +4 -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
|
@@ -7,13 +7,26 @@ export function readAsDataURL(blob: Blob, signal?: AbortSignal | undefined) {
|
|
|
7
7
|
return new Promise<string>((resolve, reject) => {
|
|
8
8
|
const reader = new FileReader()
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
const onAbort = () => reader.abort()
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
const cleanup = () => signal?.removeEventListener('abort', onAbort)
|
|
13
13
|
|
|
14
|
-
reader.
|
|
14
|
+
reader.onabort = () => {
|
|
15
|
+
cleanup()
|
|
16
|
+
reject(AbortError())
|
|
17
|
+
}
|
|
15
18
|
|
|
16
|
-
|
|
19
|
+
reader.onerror = () => {
|
|
20
|
+
cleanup()
|
|
21
|
+
reject(reader.error)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
reader.onload = () => {
|
|
25
|
+
cleanup()
|
|
26
|
+
resolve(reader.result as string)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
signal?.addEventListener('abort', onAbort, { once: true })
|
|
17
30
|
|
|
18
31
|
reader.readAsDataURL(blob)
|
|
19
32
|
|
package/src/util/number/index.ts
CHANGED
package/src/util/random/index.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// 'generateDeterministicId' is deliberately not exported from this barrel:
|
|
2
|
+
// it imports '@vanilla-extract/css', which has side effects, so re-exporting
|
|
3
|
+
// it would pull them into every '#util' consumer. Import it by direct
|
|
4
|
+
// relative path instead.
|
|
1
5
|
export * from './generateDigest'
|
|
2
6
|
export * from './generateUniqueId'
|
|
3
7
|
export * from './toHex'
|
|
@@ -1,13 +1,24 @@
|
|
|
1
|
+
import { detachChild } from './detachChild'
|
|
1
2
|
import type { TreeNode } from './node'
|
|
2
3
|
|
|
3
4
|
export function attachChild<T extends TreeNode<unknown>>(parent: T, child: T) {
|
|
5
|
+
// Detach a child that is still attached to a tree first so re-attaching
|
|
6
|
+
// cannot leave stale or self-referential links behind.
|
|
7
|
+
if (child.parent != null) {
|
|
8
|
+
detachChild(child.parent, child)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// Reset the child's sibling links so a node previously attached elsewhere
|
|
12
|
+
// cannot keep stale links into its former tree.
|
|
13
|
+
child.previousSibling = parent.lastChild ?? null
|
|
14
|
+
child.nextSibling = null
|
|
15
|
+
|
|
4
16
|
if (parent.firstChild == null) {
|
|
5
17
|
parent.firstChild = child
|
|
6
18
|
}
|
|
7
19
|
|
|
8
20
|
if (parent.lastChild) {
|
|
9
21
|
parent.lastChild.nextSibling = child
|
|
10
|
-
child.previousSibling = parent.lastChild
|
|
11
22
|
}
|
|
12
23
|
|
|
13
24
|
parent.lastChild = child
|
|
@@ -17,5 +17,11 @@ export function detachChild<T extends TreeNode<unknown>>(parent: T, child: T) {
|
|
|
17
17
|
child.nextSibling.previousSibling = child.previousSibling ?? null
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
// Detach the child's own links so it cannot reach back into the tree it
|
|
21
|
+
// was removed from.
|
|
22
|
+
child.parent = null
|
|
23
|
+
child.previousSibling = null
|
|
24
|
+
child.nextSibling = null
|
|
25
|
+
|
|
20
26
|
return parent
|
|
21
27
|
}
|