lithesome 0.20.2 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -43
- package/dist/components/accordion/Accordion.svelte +33 -33
- package/dist/components/accordion/AccordionButton.svelte +20 -20
- package/dist/components/accordion/AccordionContent.svelte +20 -20
- package/dist/components/accordion/AccordionHeading.svelte +26 -26
- package/dist/components/accordion/AccordionItem.svelte +28 -28
- package/dist/components/checkbox/CheckboxButton.svelte +56 -56
- package/dist/components/checkbox/CheckboxGroup.svelte +35 -35
- package/dist/components/checkbox/CheckboxLabel.svelte +24 -24
- package/dist/components/dropzone/Dropzone.svelte +48 -0
- package/dist/components/dropzone/Dropzone.svelte.d.ts +10 -0
- package/dist/components/dropzone/DropzoneInput.svelte +24 -0
- package/dist/components/dropzone/DropzoneInput.svelte.d.ts +10 -0
- package/dist/components/dropzone/index.d.ts +2 -0
- package/dist/components/dropzone/index.js +2 -0
- package/dist/components/dropzone/state.svelte.d.ts +32 -11
- package/dist/components/dropzone/state.svelte.js +148 -24
- package/dist/components/hovercard/Hovercard.svelte +38 -33
- package/dist/components/hovercard/HovercardArrow.svelte +23 -23
- package/dist/components/hovercard/HovercardContent.svelte +23 -23
- package/dist/components/hovercard/HovercardTrigger.svelte +23 -23
- package/dist/components/menu/Menu.svelte +36 -35
- package/dist/components/menu/MenuArrow.svelte +17 -17
- package/dist/components/menu/MenuContent.svelte +23 -23
- package/dist/components/menu/MenuItem.svelte +28 -28
- package/dist/components/menu/MenuSub.svelte +38 -38
- package/dist/components/menu/MenuSubContent.svelte +23 -23
- package/dist/components/menu/MenuSubTrigger.svelte +23 -23
- package/dist/components/menu/MenuTrigger.svelte +23 -23
- package/dist/components/modal/Modal.svelte +32 -32
- package/dist/components/modal/ModalBackdrop.svelte +24 -24
- package/dist/components/modal/ModalContent.svelte +24 -24
- package/dist/components/modal/ModalDescription.svelte +24 -24
- package/dist/components/modal/ModalTitle.svelte +24 -24
- package/dist/components/modal/ModalTrigger.svelte +24 -24
- package/dist/components/pin/Pin.svelte +41 -44
- package/dist/components/pin/PinInput.svelte +17 -17
- package/dist/components/pin/state.svelte.js +4 -0
- package/dist/components/radiogroup/RadioGroup.svelte +35 -35
- package/dist/components/radiogroup/RadioGroupItem.svelte +28 -28
- package/dist/components/select/Select.svelte +47 -47
- package/dist/components/select/SelectArrow.svelte +23 -23
- package/dist/components/select/SelectContent.svelte +23 -23
- package/dist/components/select/SelectOption.svelte +29 -29
- package/dist/components/select/SelectTrigger.svelte +23 -23
- package/dist/components/select/SelectValue.svelte +25 -25
- package/dist/components/slider/Slider.svelte +45 -45
- package/dist/components/slider/SliderRange.svelte +17 -17
- package/dist/components/slider/SliderThumb.svelte +17 -17
- package/dist/components/slider/SliderValue.svelte +17 -17
- package/dist/components/tabs/Tabs.svelte +31 -31
- package/dist/components/tabs/TabsButton.svelte +30 -30
- package/dist/components/tabs/TabsContent.svelte +25 -25
- package/dist/components/tabs/TabsList.svelte +23 -23
- package/dist/components/tags/Tags.svelte +37 -37
- package/dist/components/tags/TagsDelete.svelte +26 -26
- package/dist/components/tags/TagsInput.svelte +17 -17
- package/dist/components/tags/TagsItem.svelte +26 -26
- package/dist/components/tooltip/Tooltip.svelte +38 -38
- package/dist/components/tooltip/TooltipArrow.svelte +23 -23
- package/dist/components/tooltip/TooltipContent.svelte +23 -23
- package/dist/components/tooltip/TooltipTrigger.svelte +23 -23
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/internals/components/Element.svelte +77 -77
- package/dist/internals/types.d.ts +5 -6
- package/dist/types/components/dropzone.d.ts +32 -2
- package/package.json +75 -75
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DropzoneInputProps } from '../../types/index.js';
|
|
2
|
+
declare const DropzoneInput: import("svelte").Component<DropzoneInputProps<{
|
|
3
|
+
id: string;
|
|
4
|
+
"data-dropzone-input": string;
|
|
5
|
+
type: string;
|
|
6
|
+
multiple: boolean;
|
|
7
|
+
accept: string;
|
|
8
|
+
}, any>, {}, "ref">;
|
|
9
|
+
type DropzoneInput = ReturnType<typeof DropzoneInput>;
|
|
10
|
+
export default DropzoneInput;
|
|
@@ -1,21 +1,42 @@
|
|
|
1
|
+
import { SvelteMap } from 'svelte/reactivity';
|
|
1
2
|
import type { GetInternalProps } from '../../internals/types.js';
|
|
2
|
-
import type { DropzoneProps } from '../../types/index.js';
|
|
3
|
+
import type { DropzoneInputProps, DropzoneProps } from '../../types/index.js';
|
|
3
4
|
type RootProps = GetInternalProps<DropzoneProps>;
|
|
4
5
|
declare class DropzoneRoot {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
$disabled: RootProps['disabled'];
|
|
6
|
+
$$: RootProps;
|
|
7
|
+
errorsFound: boolean;
|
|
8
|
+
dragging: boolean;
|
|
9
|
+
dragCount: number;
|
|
10
|
+
sharedIds: SvelteMap<"input", string>;
|
|
11
11
|
constructor(props: RootProps);
|
|
12
|
+
checkFileType: (file: File) => boolean;
|
|
13
|
+
handleFiles: (filelist: FileList) => void;
|
|
14
|
+
validate: () => void;
|
|
12
15
|
props: {
|
|
13
|
-
id:
|
|
14
|
-
val: string;
|
|
15
|
-
};
|
|
16
|
+
id: string;
|
|
16
17
|
"data-dropzone-root": string;
|
|
17
18
|
};
|
|
18
|
-
state: {
|
|
19
|
+
state: {
|
|
20
|
+
dragging: boolean;
|
|
21
|
+
errors: boolean;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
type InputProps = GetInternalProps<DropzoneInputProps>;
|
|
25
|
+
declare class DropzoneInput {
|
|
26
|
+
$$: InputProps;
|
|
27
|
+
_root: DropzoneRoot;
|
|
28
|
+
constructor(root: DropzoneRoot, props: InputProps);
|
|
29
|
+
props: {
|
|
30
|
+
id: string;
|
|
31
|
+
"data-dropzone-input": string;
|
|
32
|
+
type: string;
|
|
33
|
+
multiple: boolean;
|
|
34
|
+
accept: string;
|
|
35
|
+
};
|
|
36
|
+
styles: {
|
|
37
|
+
display: string;
|
|
38
|
+
};
|
|
19
39
|
}
|
|
20
40
|
export declare const createDropzoneRootContext: (props: RootProps) => DropzoneRoot;
|
|
41
|
+
export declare const useDropzoneInput: (props: InputProps) => DropzoneInput;
|
|
21
42
|
export {};
|
|
@@ -1,33 +1,154 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { SvelteMap } from 'svelte/reactivity';
|
|
2
|
+
import { attach, buildContext } from '../../internals/index.js';
|
|
3
|
+
import { addEvents, createAttributes } from '../../internals/utils.svelte.js';
|
|
4
|
+
const { attrs } = createAttributes('dropzone', ['root', 'input']);
|
|
3
5
|
class DropzoneRoot {
|
|
4
|
-
|
|
5
|
-
$
|
|
6
|
-
$
|
|
7
|
-
$
|
|
8
|
-
|
|
9
|
-
$disabled;
|
|
6
|
+
$$;
|
|
7
|
+
errorsFound = $state(false);
|
|
8
|
+
dragging = $state(false);
|
|
9
|
+
dragCount = $state(0);
|
|
10
|
+
sharedIds = new SvelteMap();
|
|
10
11
|
constructor(props) {
|
|
11
|
-
this
|
|
12
|
-
this.$files = props.files;
|
|
13
|
-
this.$multiple = props.multiple;
|
|
14
|
-
this.$maxSize = props.maxSize;
|
|
15
|
-
this.$accept = props.accept;
|
|
16
|
-
this.$disabled = props.disabled;
|
|
12
|
+
this.$$ = props;
|
|
17
13
|
}
|
|
14
|
+
checkFileType = (file) => {
|
|
15
|
+
const fileExtension = file.name.split('.').pop()?.toLowerCase();
|
|
16
|
+
const acceptedTypes = this.$$.accept.val.split(',').map((el) => el.trim());
|
|
17
|
+
// Check if extension and mime type match the accept list.
|
|
18
|
+
return acceptedTypes.some((type) => {
|
|
19
|
+
if (type.startsWith('.') && fileExtension) {
|
|
20
|
+
return type.includes(fileExtension);
|
|
21
|
+
}
|
|
22
|
+
else if (type.endsWith('/*')) {
|
|
23
|
+
return file.type.startsWith(`${type.split('/')[0]}/`);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
return file.type === type;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
handleFiles = (filelist) => {
|
|
31
|
+
const files = Array.from(filelist);
|
|
32
|
+
const length = this.$$.multiple.val ? files.length : 1;
|
|
33
|
+
this.$$.onChange?.(this.$$.files.val);
|
|
34
|
+
for (let i = 0; i < length; i++) {
|
|
35
|
+
const file = files[i];
|
|
36
|
+
if (this.$$.maxSize.val > 0 && file.size > this.$$.maxSize.val) {
|
|
37
|
+
this.$$.onError?.({
|
|
38
|
+
type: 'maxSize',
|
|
39
|
+
file,
|
|
40
|
+
limit: this.$$.maxSize.val
|
|
41
|
+
});
|
|
42
|
+
this.errorsFound = true;
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (this.$$.accept.val && !this.checkFileType(file)) {
|
|
46
|
+
this.$$.onError?.({
|
|
47
|
+
type: 'invalidType',
|
|
48
|
+
file,
|
|
49
|
+
accept: this.$$.accept.val,
|
|
50
|
+
recieved: file.type
|
|
51
|
+
});
|
|
52
|
+
this.errorsFound = true;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (this.$$.validate && !this.$$.validate?.(file, this.$$.files.val)) {
|
|
56
|
+
this.$$.onError?.({
|
|
57
|
+
type: 'custom',
|
|
58
|
+
file
|
|
59
|
+
});
|
|
60
|
+
this.errorsFound = true;
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (this.$$.multiple.val) {
|
|
64
|
+
this.$$.files.val.push(file);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
this.$$.files.val[0] = file;
|
|
68
|
+
}
|
|
69
|
+
this.$$.onSuccess?.({
|
|
70
|
+
type: 'success',
|
|
71
|
+
file
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
validate = () => { };
|
|
18
76
|
props = $derived.by(() => ({
|
|
19
|
-
id: this
|
|
20
|
-
[attrs.root]: ''
|
|
77
|
+
id: this.$$.id.val,
|
|
78
|
+
[attrs.root]: '',
|
|
79
|
+
...attach((node) => {
|
|
80
|
+
return addEvents(node, {
|
|
81
|
+
dragenter: (e) => {
|
|
82
|
+
e.preventDefault();
|
|
83
|
+
if (this.$$.disabled.val)
|
|
84
|
+
return;
|
|
85
|
+
this.dragging = true;
|
|
86
|
+
this.dragCount++;
|
|
87
|
+
},
|
|
88
|
+
dragleave: (e) => {
|
|
89
|
+
e.preventDefault();
|
|
90
|
+
if (this.$$.disabled.val)
|
|
91
|
+
return;
|
|
92
|
+
this.dragCount--;
|
|
93
|
+
if (this.dragCount === 0)
|
|
94
|
+
this.dragging = false;
|
|
95
|
+
},
|
|
96
|
+
dragover: (e) => {
|
|
97
|
+
e.preventDefault();
|
|
98
|
+
},
|
|
99
|
+
drop: (e) => {
|
|
100
|
+
e.preventDefault();
|
|
101
|
+
if (this.$$.disabled.val)
|
|
102
|
+
return;
|
|
103
|
+
this.errorsFound = false;
|
|
104
|
+
if (e.dataTransfer?.files) {
|
|
105
|
+
this.handleFiles(e.dataTransfer.files);
|
|
106
|
+
this.dragging = false;
|
|
107
|
+
this.dragCount = 0;
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
click: () => {
|
|
111
|
+
if (this.$$.disabled.val)
|
|
112
|
+
return;
|
|
113
|
+
const input = document.querySelector(`#${this.sharedIds.get('input')}`);
|
|
114
|
+
input?.click();
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
})
|
|
21
118
|
}));
|
|
22
|
-
state = $derived.by(() => ({
|
|
119
|
+
state = $derived.by(() => ({
|
|
120
|
+
dragging: this.dragging,
|
|
121
|
+
errors: this.errorsFound
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
class DropzoneInput {
|
|
125
|
+
$$;
|
|
126
|
+
_root;
|
|
127
|
+
constructor(root, props) {
|
|
128
|
+
this._root = root;
|
|
129
|
+
this.$$ = props;
|
|
130
|
+
this._root.sharedIds.set('input', this.$$.id.val);
|
|
131
|
+
}
|
|
132
|
+
props = $derived.by(() => ({
|
|
133
|
+
id: this.$$.id.val,
|
|
134
|
+
[attrs.input]: '',
|
|
135
|
+
type: 'file',
|
|
136
|
+
multiple: this._root.$$.multiple.val,
|
|
137
|
+
accept: this._root.$$.accept.val,
|
|
138
|
+
...attach((node) => addEvents(node, {
|
|
139
|
+
change: (e) => {
|
|
140
|
+
const files = e.target.files;
|
|
141
|
+
if (files) {
|
|
142
|
+
this._root.errorsFound = false;
|
|
143
|
+
this._root.handleFiles(files);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}))
|
|
147
|
+
}));
|
|
148
|
+
styles = {
|
|
149
|
+
display: 'none'
|
|
150
|
+
};
|
|
23
151
|
}
|
|
24
|
-
// type InputProps = GetInternalProps<DropzoneInputProps>;
|
|
25
|
-
// class DropzoneInput {
|
|
26
|
-
// $id: InputProps['id'];
|
|
27
|
-
// _root: DropzoneRoot;
|
|
28
|
-
// constructor(root:DropzoneRoot, props: InputProps) {
|
|
29
|
-
// }
|
|
30
|
-
// }
|
|
31
152
|
//
|
|
32
153
|
// ~BUILDERS
|
|
33
154
|
//
|
|
@@ -35,3 +156,6 @@ const rootCtx = buildContext(DropzoneRoot);
|
|
|
35
156
|
export const createDropzoneRootContext = (props) => {
|
|
36
157
|
return rootCtx.create(props);
|
|
37
158
|
};
|
|
159
|
+
export const useDropzoneInput = (props) => {
|
|
160
|
+
return rootCtx.register(DropzoneInput, props);
|
|
161
|
+
};
|
|
@@ -1,33 +1,38 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { stateValue } from '../../internals/context.svelte.js';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
() =>
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { stateValue } from '../../internals/context.svelte.js';
|
|
3
|
+
import { parseId } from '../../internals/utils.svelte.js';
|
|
4
|
+
import { createHovercardRootContext } from './state.svelte.js';
|
|
5
|
+
|
|
6
|
+
import type { HovercardProps } from '../../types/index.js';
|
|
7
|
+
|
|
8
|
+
const uid = $props.id();
|
|
9
|
+
|
|
10
|
+
let {
|
|
11
|
+
id = parseId(uid),
|
|
12
|
+
children,
|
|
13
|
+
visible = $bindable(false),
|
|
14
|
+
delay = 700,
|
|
15
|
+
disabled = $bindable(false),
|
|
16
|
+
portalTarget = 'body',
|
|
17
|
+
floatingConfig = {}
|
|
18
|
+
}: HovercardProps<typeof ctx.state> = $props();
|
|
19
|
+
|
|
20
|
+
let ctx = createHovercardRootContext({
|
|
21
|
+
id: stateValue(() => id),
|
|
22
|
+
visible: stateValue(
|
|
23
|
+
() => visible,
|
|
24
|
+
(v) => {
|
|
25
|
+
visible = v;
|
|
26
|
+
}
|
|
27
|
+
),
|
|
28
|
+
disabled: stateValue(
|
|
29
|
+
() => disabled,
|
|
30
|
+
(v) => (disabled = v)
|
|
31
|
+
),
|
|
32
|
+
delay: stateValue(() => delay),
|
|
33
|
+
portalTarget: stateValue(() => portalTarget),
|
|
34
|
+
floatingConfig: stateValue(() => floatingConfig)
|
|
35
|
+
});
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
{@render children?.(ctx.state)}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { Element, parseId, stateValue } from '../../internals/index.js';
|
|
3
|
-
import { useHovercardArrow } from './state.svelte.js';
|
|
4
|
-
|
|
5
|
-
import type { HovercardArrowProps } from '../../types/index.js';
|
|
6
|
-
|
|
7
|
-
const uid = $props.id();
|
|
8
|
-
|
|
9
|
-
let {
|
|
10
|
-
id = parseId(uid),
|
|
11
|
-
children,
|
|
12
|
-
custom,
|
|
13
|
-
ref = $bindable(),
|
|
14
|
-
...props
|
|
15
|
-
}: HovercardArrowProps<typeof ctx.props> = $props();
|
|
16
|
-
|
|
17
|
-
let ctx = useHovercardArrow({
|
|
18
|
-
id: stateValue(() => id),
|
|
19
|
-
ref: stateValue(() => ref!)
|
|
20
|
-
});
|
|
21
|
-
</script>
|
|
22
|
-
|
|
23
|
-
<Element bind:ref {children} {custom} {ctx} as="button" {...props} />
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Element, parseId, stateValue } from '../../internals/index.js';
|
|
3
|
+
import { useHovercardArrow } from './state.svelte.js';
|
|
4
|
+
|
|
5
|
+
import type { HovercardArrowProps } from '../../types/index.js';
|
|
6
|
+
|
|
7
|
+
const uid = $props.id();
|
|
8
|
+
|
|
9
|
+
let {
|
|
10
|
+
id = parseId(uid),
|
|
11
|
+
children,
|
|
12
|
+
custom,
|
|
13
|
+
ref = $bindable(),
|
|
14
|
+
...props
|
|
15
|
+
}: HovercardArrowProps<typeof ctx.props> = $props();
|
|
16
|
+
|
|
17
|
+
let ctx = useHovercardArrow({
|
|
18
|
+
id: stateValue(() => id),
|
|
19
|
+
ref: stateValue(() => ref!)
|
|
20
|
+
});
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<Element bind:ref {children} {custom} {ctx} as="button" {...props} />
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { Element, parseId, stateValue } from '../../internals/index.js';
|
|
3
|
-
import { useHovercardContent } from './state.svelte.js';
|
|
4
|
-
|
|
5
|
-
import type { HovercardContentProps } from '../../types/index.js';
|
|
6
|
-
|
|
7
|
-
const uid = $props.id();
|
|
8
|
-
|
|
9
|
-
let {
|
|
10
|
-
id = parseId(uid),
|
|
11
|
-
children,
|
|
12
|
-
custom,
|
|
13
|
-
ref = $bindable(),
|
|
14
|
-
...props
|
|
15
|
-
}: HovercardContentProps<typeof ctx.props, typeof ctx.state> = $props();
|
|
16
|
-
|
|
17
|
-
let ctx = useHovercardContent({
|
|
18
|
-
id: stateValue(() => id),
|
|
19
|
-
ref: stateValue(() => ref!)
|
|
20
|
-
});
|
|
21
|
-
</script>
|
|
22
|
-
|
|
23
|
-
<Element bind:ref {children} {custom} visible={ctx._root.$$.visible.val} {ctx} {...props} />
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Element, parseId, stateValue } from '../../internals/index.js';
|
|
3
|
+
import { useHovercardContent } from './state.svelte.js';
|
|
4
|
+
|
|
5
|
+
import type { HovercardContentProps } from '../../types/index.js';
|
|
6
|
+
|
|
7
|
+
const uid = $props.id();
|
|
8
|
+
|
|
9
|
+
let {
|
|
10
|
+
id = parseId(uid),
|
|
11
|
+
children,
|
|
12
|
+
custom,
|
|
13
|
+
ref = $bindable(),
|
|
14
|
+
...props
|
|
15
|
+
}: HovercardContentProps<typeof ctx.props, typeof ctx.state> = $props();
|
|
16
|
+
|
|
17
|
+
let ctx = useHovercardContent({
|
|
18
|
+
id: stateValue(() => id),
|
|
19
|
+
ref: stateValue(() => ref!)
|
|
20
|
+
});
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<Element bind:ref {children} {custom} visible={ctx._root.$$.visible.val} {ctx} {...props} />
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { Element, parseId, stateValue } from '../../internals/index.js';
|
|
3
|
-
import { useHovercardTrigger } from './state.svelte.js';
|
|
4
|
-
|
|
5
|
-
import type { HovercardTriggerProps } from '../../types/index.js';
|
|
6
|
-
|
|
7
|
-
const uid = $props.id();
|
|
8
|
-
|
|
9
|
-
let {
|
|
10
|
-
id = parseId(uid),
|
|
11
|
-
children,
|
|
12
|
-
custom,
|
|
13
|
-
ref = $bindable(),
|
|
14
|
-
...props
|
|
15
|
-
}: HovercardTriggerProps<typeof ctx.props> = $props();
|
|
16
|
-
|
|
17
|
-
let ctx = useHovercardTrigger({
|
|
18
|
-
id: stateValue(() => id),
|
|
19
|
-
ref: stateValue(() => ref!)
|
|
20
|
-
});
|
|
21
|
-
</script>
|
|
22
|
-
|
|
23
|
-
<Element bind:ref {children} {custom} {ctx} as="button" {...props} />
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Element, parseId, stateValue } from '../../internals/index.js';
|
|
3
|
+
import { useHovercardTrigger } from './state.svelte.js';
|
|
4
|
+
|
|
5
|
+
import type { HovercardTriggerProps } from '../../types/index.js';
|
|
6
|
+
|
|
7
|
+
const uid = $props.id();
|
|
8
|
+
|
|
9
|
+
let {
|
|
10
|
+
id = parseId(uid),
|
|
11
|
+
children,
|
|
12
|
+
custom,
|
|
13
|
+
ref = $bindable(),
|
|
14
|
+
...props
|
|
15
|
+
}: HovercardTriggerProps<typeof ctx.props> = $props();
|
|
16
|
+
|
|
17
|
+
let ctx = useHovercardTrigger({
|
|
18
|
+
id: stateValue(() => id),
|
|
19
|
+
ref: stateValue(() => ref!)
|
|
20
|
+
});
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<Element bind:ref {children} {custom} {ctx} as="button" {...props} />
|
|
@@ -1,35 +1,36 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { stateValue } from '../../internals/context.svelte.js';
|
|
3
|
-
import { parseId } from '../../internals/utils.svelte.js';
|
|
4
|
-
import { createMenuRootContext } from './state.svelte.js';
|
|
5
|
-
|
|
6
|
-
import type { MenuProps } from '../../types/index.js';
|
|
7
|
-
|
|
8
|
-
const uid = $props.id();
|
|
9
|
-
|
|
10
|
-
let {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { stateValue } from '../../internals/context.svelte.js';
|
|
3
|
+
import { parseId } from '../../internals/utils.svelte.js';
|
|
4
|
+
import { createMenuRootContext } from './state.svelte.js';
|
|
5
|
+
|
|
6
|
+
import type { MenuProps } from '../../types/index.js';
|
|
7
|
+
|
|
8
|
+
const uid = $props.id();
|
|
9
|
+
|
|
10
|
+
let {
|
|
11
|
+
id = parseId(uid),
|
|
12
|
+
children,
|
|
13
|
+
visible = $bindable(false),
|
|
14
|
+
disabled = $bindable(false),
|
|
15
|
+
portalTarget = 'body',
|
|
16
|
+
floatingConfig = {}
|
|
17
|
+
}: MenuProps<typeof ctx.state> = $props();
|
|
18
|
+
|
|
19
|
+
let ctx = createMenuRootContext({
|
|
20
|
+
id: stateValue(() => id),
|
|
21
|
+
visible: stateValue(
|
|
22
|
+
() => visible,
|
|
23
|
+
(v) => {
|
|
24
|
+
visible = v;
|
|
25
|
+
}
|
|
26
|
+
),
|
|
27
|
+
disabled: stateValue(
|
|
28
|
+
() => disabled,
|
|
29
|
+
(v) => (disabled = v)
|
|
30
|
+
),
|
|
31
|
+
portalTarget: stateValue(() => portalTarget),
|
|
32
|
+
floatingConfig: stateValue(() => floatingConfig)
|
|
33
|
+
});
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
{@render children?.(ctx.state)}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { Element, parseId, stateValue } from '../../internals/index.js';
|
|
3
|
-
import { useMenuArrow } from './state.svelte.js';
|
|
4
|
-
|
|
5
|
-
import type { MenuArrowProps } from '../../types/index.js';
|
|
6
|
-
|
|
7
|
-
const uid = $props.id();
|
|
8
|
-
|
|
9
|
-
let { id = parseId(uid), children, custom, ref = $bindable(), ...props }: MenuArrowProps<typeof ctx.props> = $props();
|
|
10
|
-
|
|
11
|
-
let ctx = useMenuArrow({
|
|
12
|
-
id: stateValue(() => id),
|
|
13
|
-
ref: stateValue(() => ref!)
|
|
14
|
-
});
|
|
15
|
-
</script>
|
|
16
|
-
|
|
17
|
-
<Element bind:ref {children} {custom} {ctx} as="button" {...props} />
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Element, parseId, stateValue } from '../../internals/index.js';
|
|
3
|
+
import { useMenuArrow } from './state.svelte.js';
|
|
4
|
+
|
|
5
|
+
import type { MenuArrowProps } from '../../types/index.js';
|
|
6
|
+
|
|
7
|
+
const uid = $props.id();
|
|
8
|
+
|
|
9
|
+
let { id = parseId(uid), children, custom, ref = $bindable(), ...props }: MenuArrowProps<typeof ctx.props> = $props();
|
|
10
|
+
|
|
11
|
+
let ctx = useMenuArrow({
|
|
12
|
+
id: stateValue(() => id),
|
|
13
|
+
ref: stateValue(() => ref!)
|
|
14
|
+
});
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<Element bind:ref {children} {custom} {ctx} as="button" {...props} />
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { Element, parseId, stateValue } from '../../internals/index.js';
|
|
3
|
-
import { useMenuContent } from './state.svelte.js';
|
|
4
|
-
|
|
5
|
-
import type { MenuContentProps } from '../../types/index.js';
|
|
6
|
-
|
|
7
|
-
const uid = $props.id();
|
|
8
|
-
|
|
9
|
-
let {
|
|
10
|
-
id = parseId(uid),
|
|
11
|
-
children,
|
|
12
|
-
custom,
|
|
13
|
-
ref = $bindable(),
|
|
14
|
-
...props
|
|
15
|
-
}: MenuContentProps<typeof ctx.props, typeof ctx.state> = $props();
|
|
16
|
-
|
|
17
|
-
let ctx = useMenuContent({
|
|
18
|
-
id: stateValue(() => id),
|
|
19
|
-
ref: stateValue(() => ref!)
|
|
20
|
-
});
|
|
21
|
-
</script>
|
|
22
|
-
|
|
23
|
-
<Element bind:ref {children} {custom} visible={ctx._root.$$.visible.val} {ctx} {...props} />
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Element, parseId, stateValue } from '../../internals/index.js';
|
|
3
|
+
import { useMenuContent } from './state.svelte.js';
|
|
4
|
+
|
|
5
|
+
import type { MenuContentProps } from '../../types/index.js';
|
|
6
|
+
|
|
7
|
+
const uid = $props.id();
|
|
8
|
+
|
|
9
|
+
let {
|
|
10
|
+
id = parseId(uid),
|
|
11
|
+
children,
|
|
12
|
+
custom,
|
|
13
|
+
ref = $bindable(),
|
|
14
|
+
...props
|
|
15
|
+
}: MenuContentProps<typeof ctx.props, typeof ctx.state> = $props();
|
|
16
|
+
|
|
17
|
+
let ctx = useMenuContent({
|
|
18
|
+
id: stateValue(() => id),
|
|
19
|
+
ref: stateValue(() => ref!)
|
|
20
|
+
});
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<Element bind:ref {children} {custom} visible={ctx._root.$$.visible.val} {ctx} {...props} />
|