sheer-ui 0.4.0 → 0.4.3
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/package.json +1 -1
- package/src/lib/components/accordion/components/accordion-item.svelte +3 -3
- package/src/lib/components/accordion/components/accordion.svelte +29 -13
- package/src/lib/components/accordion/types.ts +3 -3
- package/src/lib/components/avatar/avatar.svelte.ts +34 -37
- package/src/lib/components/avatar/components/avatar-fallback.svelte +9 -6
- package/src/lib/components/avatar/components/avatar-image.svelte +18 -9
- package/src/lib/components/avatar/components/avatar.svelte +20 -16
- package/src/lib/components/checkbox/checkbox.svelte.ts +45 -55
- package/src/lib/components/checkbox/components/checkbox-group-label.svelte +9 -6
- package/src/lib/components/checkbox/components/checkbox-group.svelte +25 -14
- package/src/lib/components/checkbox/components/checkbox.svelte +39 -21
- package/src/lib/components/combobox/components/combobox.svelte +2 -2
- package/src/lib/components/combobox/select/components/select.svelte +2 -2
- package/src/lib/components/context-menu/components/context-menu-trigger.svelte +1 -1
- package/src/lib/components/date-field/date-field.svelte.ts +2 -3
- package/src/lib/components/dialog/components/dialog-close.svelte +13 -8
- package/src/lib/components/dialog/components/dialog-content-headless.svelte +14 -11
- package/src/lib/components/dialog/components/dialog-description.svelte +9 -6
- package/src/lib/components/dialog/components/dialog-overlay.svelte +10 -7
- package/src/lib/components/dialog/components/dialog-title.svelte +12 -7
- package/src/lib/components/dialog/components/dialog-trigger.svelte +12 -7
- package/src/lib/components/dialog/components/dialog.svelte +10 -4
- package/src/lib/components/dialog/components/modal-surface.svelte +11 -8
- package/src/lib/components/dialog/dialog.svelte.ts +73 -61
- package/src/lib/components/drawer/drawer.svelte +8 -3
- package/src/lib/components/link-preview/components/link-preview-content.svelte +15 -8
- package/src/lib/components/link-preview/components/link-preview-trigger.svelte +9 -6
- package/src/lib/components/link-preview/components/link-preview.svelte +19 -11
- package/src/lib/components/link-preview/link-preview.svelte.ts +42 -43
- package/src/lib/components/menu/components/menu-checkbox-group.svelte +6 -4
- package/src/lib/components/menu/components/menu-checkbox-item.svelte +11 -7
- package/src/lib/components/menu/menu.svelte.ts +29 -19
- package/src/lib/components/menubar/menubar.svelte.ts +7 -6
- package/src/lib/components/meter/components/meter.svelte +18 -9
- package/src/lib/components/meter/meter.svelte.ts +15 -18
- package/src/lib/components/navigation-menu/components/navigation-menu-content.svelte +1 -1
- package/src/lib/components/navigation-menu/components/navigation-menu-indicator.svelte +2 -2
- package/src/lib/components/navigation-menu/components/navigation-menu-trigger.svelte +1 -1
- package/src/lib/components/navigation-menu/navigation-menu.svelte.ts +57 -60
- package/src/lib/components/pagination/components/pagination-next-button.svelte +12 -7
- package/src/lib/components/pagination/components/pagination-page.svelte +15 -8
- package/src/lib/components/pagination/components/pagination-prev-button.svelte +12 -7
- package/src/lib/components/pagination/components/pagination.svelte +31 -18
- package/src/lib/components/pagination/pagination.svelte.ts +48 -64
- package/src/lib/components/pin-input/pin-input.svelte.ts +7 -8
- package/src/lib/components/pin-input/usePasswordManager.svelte.ts +2 -2
- package/src/lib/components/popover/components/popover-close.svelte +9 -6
- package/src/lib/components/popover/components/popover-content.svelte +12 -7
- package/src/lib/components/popover/components/popover-trigger.svelte +21 -10
- package/src/lib/components/popover/components/popover.svelte +9 -8
- package/src/lib/components/popover/popover.svelte.ts +68 -74
- package/src/lib/components/progress/components/progress.svelte +18 -9
- package/src/lib/components/progress/progress.svelte.ts +14 -17
- package/src/lib/components/scroll-area/scroll-area.svelte.ts +9 -10
- package/src/lib/components/separator/components/separator.svelte +15 -8
- package/src/lib/components/separator/separator.svelte.ts +12 -15
- package/src/lib/components/sidebar/sidebar-mobile-surface.svelte +8 -4
- package/src/lib/components/slider/components/slider.svelte +2 -1
- package/src/lib/components/tabs/components/tabs-content.svelte +12 -7
- package/src/lib/components/tabs/components/tabs-list.svelte +9 -6
- package/src/lib/components/tabs/components/tabs-trigger.svelte +15 -8
- package/src/lib/components/tabs/components/tabs.svelte +28 -17
- package/src/lib/components/tabs/tabs.svelte.ts +51 -67
- package/src/lib/components/time-field/time-field.svelte.ts +2 -2
- package/src/lib/components/toggle/components/toggle.svelte +19 -14
- package/src/lib/components/toggle/toggle.svelte.ts +15 -20
- package/src/lib/components/toggle-group/components/toggle-group-item.svelte +15 -8
- package/src/lib/components/toggle-group/components/toggle-group.svelte +28 -16
- package/src/lib/components/toggle-group/toggle-group.svelte.ts +33 -35
- package/src/lib/components/toolbar/components/toolbar-group-item.svelte +15 -8
- package/src/lib/components/toolbar/components/toolbar-group.svelte +19 -14
- package/src/lib/components/toolbar/toolbar.svelte.ts +28 -30
- package/src/lib/components/tooltip/components/tooltip-content.svelte +15 -8
- package/src/lib/components/tooltip/components/tooltip-provider.svelte +18 -7
- package/src/lib/components/tooltip/components/tooltip-trigger.svelte +21 -10
- package/src/lib/components/tooltip/components/tooltip.svelte +34 -21
- package/src/lib/components/tooltip/tooltip.svelte.ts +101 -125
- package/src/lib/internal/dismissible-layer/use-dismissable-layer.svelte.ts +3 -4
- package/src/lib/internal/escape-layer/use-escape-layer.svelte.ts +13 -29
- package/src/lib/internal/floating-layer/use-floating-layer.svelte.ts +26 -30
- package/src/lib/internal/group-value.svelte.ts +11 -10
- package/src/lib/internal/native-popover.svelte.ts +6 -6
- package/src/lib/internal/{roving-focus-group.ts → roving-focus-group.svelte.ts} +17 -19
- package/src/lib/internal/roving-focus-item.svelte.ts +12 -17
- package/src/lib/internal/selection.svelte.ts +55 -41
- package/src/lib/internal/{state-machine.ts → state-machine.svelte.ts} +6 -8
- package/src/lib/internal/timeout-fn.svelte.ts +6 -4
- package/src/lib/internal/tools/box.svelte.ts +5 -114
- package/src/lib/internal/tools/index.ts +1 -11
- package/src/lib/internal/tools/types.ts +0 -3
- package/src/lib/internal/typeahead.svelte.ts +9 -13
- package/src/lib/internal/types.ts +6 -0
- package/src/lib/internal/vaul/use-drawer-content.svelte.ts +2 -2
- package/src/lib/internal/vaul/use-drawer-root.svelte.ts +12 -7
- package/src/lib/components/accordion/accordion.svelte.ts +0 -43
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
import { createContext } from 'svelte';
|
|
2
|
-
import {
|
|
2
|
+
import { attachRef } from '../../internal/tools/index.js';
|
|
3
3
|
import { createBitsAttrs, boolToEmptyStrOrUndef } from '../../internal/attrs.js';
|
|
4
4
|
import type { Orientation } from '../../internal/index.js';
|
|
5
|
-
import type { RefAttachment
|
|
6
|
-
import { RovingFocusGroup } from '../../internal/roving-focus-group.js';
|
|
7
|
-
import {
|
|
8
|
-
type SelectionGroup,
|
|
9
|
-
type SelectionItemOpts,
|
|
10
|
-
type SelectionType,
|
|
11
|
-
SelectionItemState,
|
|
12
|
-
SelectionValue,
|
|
13
|
-
} from '../../internal/selection.svelte.js';
|
|
5
|
+
import type { RefAttachment } from '../../internal/types.js';
|
|
6
|
+
import { RovingFocusGroup } from '../../internal/roving-focus-group.svelte.js';
|
|
7
|
+
import { type SelectionGroup, type SelectionItemOpts, SelectionItemState, SelectionValue } from '../../internal/selection.svelte.js';
|
|
14
8
|
|
|
15
9
|
export const toggleGroupAttrs = createBitsAttrs({
|
|
16
10
|
component: 'toggle-group',
|
|
@@ -19,17 +13,15 @@ export const toggleGroupAttrs = createBitsAttrs({
|
|
|
19
13
|
|
|
20
14
|
const [getToggleGroupRoot, setToggleGroupRoot] = createContext<ToggleGroupRootState>();
|
|
21
15
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
type: SelectionType;
|
|
32
|
-
value: WritableBox<string | string[]>;
|
|
16
|
+
/** The root component's props as accessors over its `$props()`; `ref` writes back to its bindable. */
|
|
17
|
+
interface ToggleGroupRootStateOpts {
|
|
18
|
+
readonly id: string;
|
|
19
|
+
readonly disabled: boolean;
|
|
20
|
+
readonly rovingFocus: boolean;
|
|
21
|
+
readonly loop: boolean;
|
|
22
|
+
readonly orientation: Orientation;
|
|
23
|
+
ref: HTMLElement | null;
|
|
24
|
+
selection: SelectionValue;
|
|
33
25
|
}
|
|
34
26
|
|
|
35
27
|
export class ToggleGroupRootState implements SelectionGroup {
|
|
@@ -38,36 +30,42 @@ export class ToggleGroupRootState implements SelectionGroup {
|
|
|
38
30
|
}
|
|
39
31
|
readonly opts: ToggleGroupRootStateOpts;
|
|
40
32
|
readonly selection: SelectionValue;
|
|
41
|
-
readonly disabled: ReadableBox<boolean>;
|
|
42
|
-
readonly orientation: ReadableBox<Orientation>;
|
|
43
|
-
readonly rovingFocus: ReadableBox<boolean>;
|
|
44
33
|
readonly rovingFocusGroup: RovingFocusGroup;
|
|
45
34
|
readonly selectionTakesTabStop = true;
|
|
46
35
|
readonly attachment: RefAttachment;
|
|
47
36
|
|
|
48
37
|
constructor(opts: ToggleGroupRootStateOpts) {
|
|
49
38
|
this.opts = opts;
|
|
50
|
-
this.selection =
|
|
51
|
-
this.
|
|
52
|
-
this.orientation = opts.orientation;
|
|
53
|
-
this.rovingFocus = opts.rovingFocus;
|
|
54
|
-
this.attachment = attachRef(opts.ref);
|
|
39
|
+
this.selection = opts.selection;
|
|
40
|
+
this.attachment = attachRef<HTMLElement>((v) => (opts.ref = v));
|
|
55
41
|
this.rovingFocusGroup = new RovingFocusGroup({
|
|
56
42
|
candidateAttr: toggleGroupAttrs.item,
|
|
57
|
-
rootNode: opts.ref,
|
|
58
|
-
loop: opts.loop,
|
|
59
|
-
orientation: opts.orientation,
|
|
43
|
+
rootNode: () => opts.ref,
|
|
44
|
+
loop: () => opts.loop,
|
|
45
|
+
orientation: () => opts.orientation,
|
|
60
46
|
});
|
|
61
47
|
}
|
|
62
48
|
|
|
49
|
+
get disabled() {
|
|
50
|
+
return this.opts.disabled;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
get orientation() {
|
|
54
|
+
return this.opts.orientation;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
get rovingFocus() {
|
|
58
|
+
return this.opts.rovingFocus;
|
|
59
|
+
}
|
|
60
|
+
|
|
63
61
|
readonly props = $derived.by(
|
|
64
62
|
() =>
|
|
65
63
|
({
|
|
66
|
-
id: this.opts.id
|
|
64
|
+
id: this.opts.id,
|
|
67
65
|
[toggleGroupAttrs.root]: '',
|
|
68
66
|
role: 'group',
|
|
69
|
-
'data-orientation': this.opts.orientation
|
|
70
|
-
'data-disabled': boolToEmptyStrOrUndef(this.opts.disabled
|
|
67
|
+
'data-orientation': this.opts.orientation,
|
|
68
|
+
'data-disabled': boolToEmptyStrOrUndef(this.opts.disabled),
|
|
71
69
|
...this.attachment,
|
|
72
70
|
}) as const,
|
|
73
71
|
);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { boxWith } from '../../../internal/tools/index.js';
|
|
3
2
|
import { mergeProps } from '../../../internal/merge-props.js';
|
|
4
3
|
import type { ToolbarGroupItemProps } from '../types.js';
|
|
5
4
|
import { createToolbarGroupItem } from '../toolbar.svelte.js';
|
|
@@ -25,13 +24,21 @@
|
|
|
25
24
|
} = $props();
|
|
26
25
|
|
|
27
26
|
const groupItemState = createToolbarGroupItem({
|
|
28
|
-
id
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
)
|
|
27
|
+
get id() {
|
|
28
|
+
return id;
|
|
29
|
+
},
|
|
30
|
+
get value() {
|
|
31
|
+
return value;
|
|
32
|
+
},
|
|
33
|
+
get disabled() {
|
|
34
|
+
return disabled ?? false;
|
|
35
|
+
},
|
|
36
|
+
get ref() {
|
|
37
|
+
return ref;
|
|
38
|
+
},
|
|
39
|
+
set ref(v) {
|
|
40
|
+
ref = v;
|
|
41
|
+
},
|
|
35
42
|
});
|
|
36
43
|
|
|
37
44
|
const mergedProps = $derived(
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { emptySelection } from '../../../internal/selection.svelte.js';
|
|
2
|
+
import { repairBindable } from '../../../internal/tools/index.js';
|
|
3
|
+
import { SelectionValue, emptySelection } from '../../../internal/selection.svelte.js';
|
|
5
4
|
import { mergeProps } from '../../../internal/merge-props.js';
|
|
6
5
|
import type { ToolbarGroupProps } from '../types.js';
|
|
7
6
|
import { ToolbarGroupState } from '../toolbar.svelte.js';
|
|
@@ -21,10 +20,10 @@
|
|
|
21
20
|
...restProps
|
|
22
21
|
}: ToolbarGroupProps = $props();
|
|
23
22
|
|
|
24
|
-
// Mode is
|
|
25
|
-
|
|
23
|
+
// Mode is fixed at mount: `value` keeps the shape it was declared with.
|
|
24
|
+
// svelte-ignore state_referenced_locally
|
|
25
|
+
const valueType = type;
|
|
26
26
|
|
|
27
|
-
// The group owns a mode-specific controlled value.
|
|
28
27
|
repairBindable(
|
|
29
28
|
() => value,
|
|
30
29
|
() => {
|
|
@@ -33,10 +32,20 @@
|
|
|
33
32
|
);
|
|
34
33
|
|
|
35
34
|
const groupState = ToolbarGroupState.create({
|
|
36
|
-
id
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
get id() {
|
|
36
|
+
return id;
|
|
37
|
+
},
|
|
38
|
+
get disabled() {
|
|
39
|
+
return disabled;
|
|
40
|
+
},
|
|
41
|
+
get ref() {
|
|
42
|
+
return ref;
|
|
43
|
+
},
|
|
44
|
+
set ref(v) {
|
|
45
|
+
ref = v;
|
|
46
|
+
},
|
|
47
|
+
selection: new SelectionValue(
|
|
48
|
+
valueType,
|
|
40
49
|
() => value ?? emptySelection(valueType),
|
|
41
50
|
(v) => {
|
|
42
51
|
value = v;
|
|
@@ -44,10 +53,6 @@
|
|
|
44
53
|
onValueChange(v as any);
|
|
45
54
|
},
|
|
46
55
|
),
|
|
47
|
-
ref: boxWith(
|
|
48
|
-
() => ref,
|
|
49
|
-
(v) => (ref = v),
|
|
50
|
-
),
|
|
51
56
|
});
|
|
52
57
|
|
|
53
58
|
const mergedProps = $derived(mergeProps({ 'data-slot': 'toolbar-group', class: 'flex items-center gap-1' }, restProps, groupState.props));
|
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
import { createContext } from 'svelte';
|
|
2
|
-
import { type ReadableBox, type ReadableBoxedValues,
|
|
2
|
+
import { type ReadableBox, type ReadableBoxedValues, attachRef } from '../../internal/tools/index.js';
|
|
3
3
|
import { createBitsAttrs, boolToEmptyStrOrUndef, boolToTrueOrUndef } from '../../internal/attrs.js';
|
|
4
4
|
import type { Orientation } from '../../internal/index.js';
|
|
5
5
|
import type { BitsKeyboardEvent, RefAttachment, WithRefOpts } from '../../internal/types.js';
|
|
6
|
-
import { RovingFocusGroup } from '../../internal/roving-focus-group.js';
|
|
6
|
+
import { RovingFocusGroup } from '../../internal/roving-focus-group.svelte.js';
|
|
7
7
|
import { RovingFocusItem } from '../../internal/roving-focus-item.svelte.js';
|
|
8
|
-
import {
|
|
9
|
-
type SelectionGroup,
|
|
10
|
-
type SelectionItemOpts,
|
|
11
|
-
type SelectionType,
|
|
12
|
-
SelectionItemState,
|
|
13
|
-
SelectionValue,
|
|
14
|
-
} from '../../internal/selection.svelte.js';
|
|
8
|
+
import { type SelectionGroup, type SelectionItemOpts, SelectionItemState, SelectionValue } from '../../internal/selection.svelte.js';
|
|
15
9
|
|
|
16
10
|
export const toolbarAttrs = createBitsAttrs({
|
|
17
11
|
component: 'toolbar',
|
|
@@ -41,9 +35,9 @@ export class ToolbarRootState {
|
|
|
41
35
|
this.attachment = attachRef(this.opts.ref);
|
|
42
36
|
|
|
43
37
|
this.rovingFocusGroup = new RovingFocusGroup({
|
|
44
|
-
orientation: this.opts.orientation,
|
|
45
|
-
loop: this.opts.loop,
|
|
46
|
-
rootNode: this.opts.ref,
|
|
38
|
+
orientation: () => this.opts.orientation.current,
|
|
39
|
+
loop: () => this.opts.loop.current,
|
|
40
|
+
rootNode: () => this.opts.ref.current,
|
|
47
41
|
candidateAttr: toolbarAttrs.item,
|
|
48
42
|
});
|
|
49
43
|
}
|
|
@@ -60,14 +54,12 @@ export class ToolbarRootState {
|
|
|
60
54
|
);
|
|
61
55
|
}
|
|
62
56
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
type: SelectionType;
|
|
70
|
-
value: WritableBox<string | string[]>;
|
|
57
|
+
/** The group component's props as accessors over its `$props()`; `ref` writes back to its bindable. */
|
|
58
|
+
interface ToolbarGroupStateOpts {
|
|
59
|
+
readonly id: string;
|
|
60
|
+
readonly disabled: boolean;
|
|
61
|
+
ref: HTMLElement | null;
|
|
62
|
+
selection: SelectionValue;
|
|
71
63
|
}
|
|
72
64
|
|
|
73
65
|
/** A selection group inside the toolbar: its items rove with the toolbar's other items. */
|
|
@@ -78,8 +70,6 @@ export class ToolbarGroupState implements SelectionGroup {
|
|
|
78
70
|
readonly opts: ToolbarGroupStateOpts;
|
|
79
71
|
readonly root: ToolbarRootState;
|
|
80
72
|
readonly selection: SelectionValue;
|
|
81
|
-
readonly disabled: ReadableBox<boolean>;
|
|
82
|
-
readonly orientation: ReadableBox<Orientation>;
|
|
83
73
|
readonly rovingFocusGroup: RovingFocusGroup;
|
|
84
74
|
readonly selectionTakesTabStop = false;
|
|
85
75
|
readonly extraItemAttrs = { [toolbarAttrs['group-item']]: '' } as const;
|
|
@@ -88,21 +78,27 @@ export class ToolbarGroupState implements SelectionGroup {
|
|
|
88
78
|
constructor(opts: ToolbarGroupStateOpts, root: ToolbarRootState) {
|
|
89
79
|
this.opts = opts;
|
|
90
80
|
this.root = root;
|
|
91
|
-
this.selection =
|
|
92
|
-
this.disabled = opts.disabled;
|
|
93
|
-
this.orientation = root.opts.orientation;
|
|
81
|
+
this.selection = opts.selection;
|
|
94
82
|
this.rovingFocusGroup = root.rovingFocusGroup;
|
|
95
|
-
this.attachment = attachRef(
|
|
83
|
+
this.attachment = attachRef<HTMLElement>((v) => (opts.ref = v));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
get disabled() {
|
|
87
|
+
return this.opts.disabled;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
get orientation() {
|
|
91
|
+
return this.root.opts.orientation.current;
|
|
96
92
|
}
|
|
97
93
|
|
|
98
94
|
readonly props = $derived.by(
|
|
99
95
|
() =>
|
|
100
96
|
({
|
|
101
|
-
id: this.opts.id
|
|
97
|
+
id: this.opts.id,
|
|
102
98
|
[toolbarAttrs.group]: '',
|
|
103
99
|
role: 'group',
|
|
104
100
|
'data-orientation': this.root.opts.orientation.current,
|
|
105
|
-
'data-disabled': boolToEmptyStrOrUndef(this.opts.disabled
|
|
101
|
+
'data-disabled': boolToEmptyStrOrUndef(this.opts.disabled),
|
|
106
102
|
...this.attachment,
|
|
107
103
|
}) as const,
|
|
108
104
|
);
|
|
@@ -127,7 +123,8 @@ export class ToolbarLinkState {
|
|
|
127
123
|
this.root = root;
|
|
128
124
|
this.rovingItem = new RovingFocusItem({
|
|
129
125
|
group: this.root.rovingFocusGroup,
|
|
130
|
-
ref: this.opts.ref,
|
|
126
|
+
ref: () => this.opts.ref.current,
|
|
127
|
+
setRef: (v) => (this.opts.ref.current = v),
|
|
131
128
|
});
|
|
132
129
|
|
|
133
130
|
this.onkeydown = this.onkeydown.bind(this);
|
|
@@ -179,7 +176,8 @@ export class ToolbarButtonState {
|
|
|
179
176
|
this.root = root;
|
|
180
177
|
this.rovingItem = new RovingFocusItem({
|
|
181
178
|
group: this.root.rovingFocusGroup,
|
|
182
|
-
ref: this.opts.ref,
|
|
179
|
+
ref: () => this.opts.ref.current,
|
|
180
|
+
setRef: (v) => (this.opts.ref.current = v),
|
|
183
181
|
});
|
|
184
182
|
|
|
185
183
|
this.onkeydown = this.onkeydown.bind(this);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { join } from 'overrule';
|
|
3
3
|
import type { ClassValue } from 'svelte/elements';
|
|
4
|
-
import { boxWith } from '../../../internal/tools/index.js';
|
|
5
4
|
import { mergeProps } from '../../../internal/merge-props.js';
|
|
6
5
|
import type { TooltipContentProps } from '../types.js';
|
|
7
6
|
import { TooltipContentState } from '../tooltip.svelte.js';
|
|
@@ -28,13 +27,21 @@
|
|
|
28
27
|
}: TooltipContentProps & { arrowClasses?: ClassValue; portalProps?: unknown } = $props();
|
|
29
28
|
|
|
30
29
|
const contentState = TooltipContentState.create({
|
|
31
|
-
id
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
get id() {
|
|
31
|
+
return id;
|
|
32
|
+
},
|
|
33
|
+
get ref() {
|
|
34
|
+
return ref;
|
|
35
|
+
},
|
|
36
|
+
set ref(v) {
|
|
37
|
+
ref = v;
|
|
38
|
+
},
|
|
39
|
+
get onInteractOutside() {
|
|
40
|
+
return onInteractOutside;
|
|
41
|
+
},
|
|
42
|
+
get onEscapeKeydown() {
|
|
43
|
+
return onEscapeKeydown;
|
|
44
|
+
},
|
|
38
45
|
});
|
|
39
46
|
|
|
40
47
|
const lifecycleProps = useNativePopoverLifecycle(contentState);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { boxWith } from '../../../internal/tools/index.js';
|
|
3
2
|
import type { TooltipProviderProps } from '../types.js';
|
|
4
3
|
import { TooltipProviderState } from '../tooltip.svelte.js';
|
|
5
4
|
|
|
@@ -14,12 +13,24 @@
|
|
|
14
13
|
}: TooltipProviderProps = $props();
|
|
15
14
|
|
|
16
15
|
TooltipProviderState.create({
|
|
17
|
-
delayDuration
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
get delayDuration() {
|
|
17
|
+
return delayDuration;
|
|
18
|
+
},
|
|
19
|
+
get disableCloseOnTriggerClick() {
|
|
20
|
+
return disableCloseOnTriggerClick;
|
|
21
|
+
},
|
|
22
|
+
get disableHoverableContent() {
|
|
23
|
+
return disableHoverableContent;
|
|
24
|
+
},
|
|
25
|
+
get disabled() {
|
|
26
|
+
return disabled;
|
|
27
|
+
},
|
|
28
|
+
get ignoreNonKeyboardFocus() {
|
|
29
|
+
return ignoreNonKeyboardFocus;
|
|
30
|
+
},
|
|
31
|
+
get skipDelayDuration() {
|
|
32
|
+
return skipDelayDuration;
|
|
33
|
+
},
|
|
23
34
|
});
|
|
24
35
|
</script>
|
|
25
36
|
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
</script>
|
|
4
4
|
|
|
5
5
|
<script lang="ts" generics="T = never">
|
|
6
|
-
import { boxWith } from '../../../internal/tools/index.js';
|
|
7
6
|
import { mergeProps } from '../../../internal/merge-props.js';
|
|
8
7
|
import type { TooltipTriggerProps } from '../types.js';
|
|
9
8
|
import { TooltipTriggerState } from '../tooltip.svelte.js';
|
|
@@ -25,15 +24,27 @@
|
|
|
25
24
|
}: TooltipTriggerProps<T> = $props();
|
|
26
25
|
|
|
27
26
|
const triggerState = TooltipTriggerState.create({
|
|
28
|
-
id
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
get id() {
|
|
28
|
+
return id;
|
|
29
|
+
},
|
|
30
|
+
get disabled() {
|
|
31
|
+
return disabled ?? false;
|
|
32
|
+
},
|
|
33
|
+
get tabindex() {
|
|
34
|
+
return tabindex ?? 0;
|
|
35
|
+
},
|
|
36
|
+
get payload() {
|
|
37
|
+
return payload;
|
|
38
|
+
},
|
|
39
|
+
get tether() {
|
|
40
|
+
return tether;
|
|
41
|
+
},
|
|
42
|
+
get ref() {
|
|
43
|
+
return ref;
|
|
44
|
+
},
|
|
45
|
+
set ref(v) {
|
|
46
|
+
ref = v;
|
|
47
|
+
},
|
|
37
48
|
});
|
|
38
49
|
|
|
39
50
|
const mergedProps = $derived(mergeProps({ 'data-slot': 'tooltip-trigger' }, restProps, triggerState.props, { type }));
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
</script>
|
|
4
4
|
|
|
5
5
|
<script lang="ts" generics="T = never">
|
|
6
|
-
import { boxWith } from '../../../internal/tools/index.js';
|
|
7
6
|
import { OpenCell } from '../../../internal/open-cell.svelte.js';
|
|
8
7
|
import type { TooltipRootProps } from '../types.js';
|
|
9
8
|
import { TooltipRootState } from '../tooltip.svelte.js';
|
|
@@ -22,34 +21,48 @@
|
|
|
22
21
|
children,
|
|
23
22
|
}: TooltipRootProps<T> = $props();
|
|
24
23
|
|
|
25
|
-
// Cell over the source prop; the engine keeps its boxed-open interface (vendored,
|
|
26
|
-
// ADR 0006) — the box is a bridge over the cell, so the cell owns `open`.
|
|
27
24
|
// svelte-ignore state_referenced_locally
|
|
28
25
|
const cell = givenCell ?? new OpenCell(() => open);
|
|
29
26
|
|
|
30
27
|
const rootState = TooltipRootState.create({
|
|
31
|
-
open
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
28
|
+
get open() {
|
|
29
|
+
return cell.open;
|
|
30
|
+
},
|
|
31
|
+
set open(v) {
|
|
32
|
+
cell.open = v;
|
|
33
|
+
},
|
|
34
|
+
get triggerId() {
|
|
35
|
+
return triggerId;
|
|
36
|
+
},
|
|
37
|
+
set triggerId(v) {
|
|
38
|
+
triggerId = v;
|
|
39
|
+
},
|
|
40
|
+
get delayDuration() {
|
|
41
|
+
return delayDuration;
|
|
42
|
+
},
|
|
43
|
+
get disableCloseOnTriggerClick() {
|
|
44
|
+
return disableCloseOnTriggerClick;
|
|
45
|
+
},
|
|
46
|
+
get disableHoverableContent() {
|
|
47
|
+
return disableHoverableContent;
|
|
48
|
+
},
|
|
49
|
+
get ignoreNonKeyboardFocus() {
|
|
50
|
+
return ignoreNonKeyboardFocus;
|
|
51
|
+
},
|
|
52
|
+
get disabled() {
|
|
53
|
+
return disabled;
|
|
54
|
+
},
|
|
55
|
+
get onOpenChangeComplete() {
|
|
56
|
+
return onOpenChangeComplete;
|
|
57
|
+
},
|
|
58
|
+
get tether() {
|
|
59
|
+
return tether;
|
|
60
|
+
},
|
|
48
61
|
});
|
|
49
62
|
</script>
|
|
50
63
|
|
|
51
64
|
{@render children?.({
|
|
52
|
-
open: rootState.opts.open
|
|
65
|
+
open: rootState.opts.open,
|
|
53
66
|
triggerId: rootState.activeTriggerId,
|
|
54
67
|
payload: rootState.activePayload as [T] extends [never] ? null : T | null,
|
|
55
68
|
})}
|