tera-system-ui 0.0.24 → 0.0.25
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/components/avatar/Avatar.svelte +43 -43
- package/dist/components/brand-logo/BrandLogo.svelte +31 -31
- package/dist/components/button/Button.svelte +49 -49
- package/dist/components/combobox/Combobox.svelte +8 -8
- package/dist/components/command/command.scss +72 -72
- package/dist/components/command/components/Command.svelte +120 -120
- package/dist/components/command/components/Command.svelte.d.ts +1 -1
- package/dist/components/command/components/CommandEmpty.svelte +30 -30
- package/dist/components/command/components/CommandEmpty.svelte.d.ts +1 -1
- package/dist/components/command/components/CommandGroup.svelte +110 -110
- package/dist/components/command/components/CommandGroup.svelte.d.ts +1 -1
- package/dist/components/command/components/CommandInput.svelte +92 -92
- package/dist/components/command/components/CommandInput.svelte.d.ts +1 -1
- package/dist/components/command/components/CommandItem.svelte +110 -110
- package/dist/components/command/components/CommandItem.svelte.d.ts +1 -1
- package/dist/components/command/components/CommandList.svelte +56 -56
- package/dist/components/command/components/CommandLoading.svelte +28 -28
- package/dist/components/command/components/CommandLoading.svelte.d.ts +1 -1
- package/dist/components/command/components/CommandSeparator.svelte +21 -21
- package/dist/components/command/components/CommandSeparator.svelte.d.ts +1 -1
- package/dist/components/dialog/Dialog.astro +64 -64
- package/dist/components/dialog/Dialog.svelte +109 -109
- package/dist/components/dialog/dialog.scss +115 -115
- package/dist/components/dropdown-menu/components/DropdownMenu.svelte +33 -33
- package/dist/components/dropdown-menu/components/DropdownMenuGroup.svelte +11 -11
- package/dist/components/dropdown-menu/components/DropdownMenuHeader.svelte +11 -11
- package/dist/components/dropdown-menu/components/DropdownMenuItem.svelte +30 -30
- package/dist/components/dropdown-menu/components/DropdownMenuSeparator.svelte +10 -10
- package/dist/components/header/Header.svelte +36 -36
- package/dist/components/header/header.scss +19 -19
- package/dist/components/icons/IconArrowBigRightFilled.svelte +10 -10
- package/dist/components/icons/IconBook.svelte +10 -10
- package/dist/components/icons/IconBookmarkPlus.svelte +10 -10
- package/dist/components/icons/IconCalculator.svelte +10 -10
- package/dist/components/icons/IconCheck.svelte +10 -10
- package/dist/components/icons/IconChevronDown.svelte +10 -10
- package/dist/components/icons/IconCopy.svelte +10 -10
- package/dist/components/icons/IconCopyCheckFilled.svelte +10 -10
- package/dist/components/icons/IconHamburger.svelte +10 -10
- package/dist/components/icons/IconLanguage.svelte +10 -10
- package/dist/components/icons/IconLoader2.svelte +10 -10
- package/dist/components/icons/IconLogout.svelte +10 -10
- package/dist/components/icons/IconMoon.svelte +10 -10
- package/dist/components/icons/IconPointFilled.svelte +10 -10
- package/dist/components/icons/IconSearch.svelte +10 -10
- package/dist/components/icons/IconSettings.svelte +10 -10
- package/dist/components/icons/IconSun.svelte +10 -10
- package/dist/components/icons/IconSwitchHorizontal.svelte +10 -10
- package/dist/components/icons/IconSwitchVertical.svelte +10 -10
- package/dist/components/icons/IconTransform.svelte +10 -10
- package/dist/components/icons/IconX.svelte +10 -10
- package/dist/components/input/Input.svelte +24 -24
- package/dist/components/language-picker-button/LanguagePickerButton.svelte +109 -109
- package/dist/components/light-dark-toggle/LightDarkToggle.svelte +36 -36
- package/dist/components/popover/Popover.svelte +159 -159
- package/dist/components/popover-responsive/PopoverResponsive.svelte +87 -87
- package/dist/components/side-navigation/SideNavigation.svelte +114 -114
- package/dist/components/side-navigation/SideNavigationItem.svelte +17 -17
- package/dist/components/side-navigation/SideNavigationLayout.svelte +19 -19
- package/dist/components/side-navigation/sidenav.scss +149 -149
- package/dist/components/slider/Slider.svelte +181 -181
- package/dist/components/star-rating/StarRating.d.ts +10 -0
- package/dist/components/star-rating/StarRating.js +7 -0
- package/dist/components/star-rating/StarRating.svelte +88 -0
- package/dist/components/star-rating/StarRating.svelte.d.ts +3 -0
- package/dist/components/star-rating/index.d.ts +1 -0
- package/dist/components/star-rating/index.js +1 -0
- package/dist/components/tabs/components/Tabs.svelte +47 -47
- package/dist/components/tabs/components/TabsContent.svelte +34 -34
- package/dist/components/tabs/components/TabsItem.svelte +29 -29
- package/dist/components/tabs/components/TabsList.svelte +41 -41
- package/dist/components/tera-ui-context/TeraUiContext.svelte +28 -28
- package/dist/components/text-area/TextArea.svelte +88 -88
- package/dist/components/user-avatar-with-menu/UserAvatarWithMenu.svelte +67 -67
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/themes/scrollbar.scss +37 -37
- package/dist/themes/tera-ui-base.css +208 -208
- package/dist/themes/tw-preset.cjs +153 -153
- package/package.json +98 -98
- package/scripts/add-component-template.js +120 -120
- package/scripts/generate-ts-index.js +138 -138
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {derived, get} from 'svelte/store';
|
|
3
|
-
import {getCtx, getState, ITEM_SELECTOR, VALUE_ATTR} from '../command
|
|
4
|
-
import {isBrowser} from '../../../internal
|
|
5
|
-
import type {InputEvents, InputProps} from '../types
|
|
6
|
-
import {sleep} from '../../../internal/helpers/sleep
|
|
7
|
-
import {styles} from "../../input/Input";
|
|
8
|
-
import {IconSearch} from "../../..";
|
|
9
|
-
|
|
10
|
-
type $$Props = InputProps;
|
|
11
|
-
type $$Events = InputEvents;
|
|
12
|
-
|
|
13
|
-
const {ids, commandEl} = getCtx();
|
|
14
|
-
const commandState = getState();
|
|
15
|
-
|
|
16
|
-
const valueStore = derived(commandState, ($commandState) => $commandState.value);
|
|
17
|
-
|
|
18
|
-
let {
|
|
19
|
-
autofocus = undefined,
|
|
20
|
-
value = $bindable(),
|
|
21
|
-
el,
|
|
22
|
-
class: className,
|
|
23
|
-
...restProps
|
|
24
|
-
}: $$Props & {
|
|
25
|
-
el?: HTMLElement,
|
|
26
|
-
} = $props()
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const selectedItemId = derived([valueStore, commandEl], ([$value, $commandEl]) => {
|
|
30
|
-
if (!isBrowser) return undefined;
|
|
31
|
-
const item = $commandEl?.querySelector(`${ITEM_SELECTOR}[${VALUE_ATTR}="${$value}"]`);
|
|
32
|
-
return item?.getAttribute('id');
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
function handleValueUpdate(v: string) {
|
|
36
|
-
commandState.updateState('search', v);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function action(node: HTMLInputElement) {
|
|
40
|
-
if (autofocus) {
|
|
41
|
-
sleep(200).then(() => {
|
|
42
|
-
node.focus()
|
|
43
|
-
console.log('CommandInput autofocus')
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
let attrs = $state<Record<string, unknown>>()
|
|
49
|
-
|
|
50
|
-
$effect(() => {
|
|
51
|
-
attrs = {
|
|
52
|
-
type: 'text',
|
|
53
|
-
'data-cmdk-input': '',
|
|
54
|
-
autocomplete: 'off',
|
|
55
|
-
autocorrect: 'off',
|
|
56
|
-
spellcheck: false,
|
|
57
|
-
'aria-autocomplete': 'list',
|
|
58
|
-
role: 'combobox',
|
|
59
|
-
'aria-expanded': true,
|
|
60
|
-
'aria-controls': ids.list,
|
|
61
|
-
'aria-labelledby': ids.label,
|
|
62
|
-
'aria-activedescendant': $selectedItemId ?? undefined,
|
|
63
|
-
id: ids.input
|
|
64
|
-
};
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
$effect(() => {
|
|
68
|
-
return () => {
|
|
69
|
-
value = ''
|
|
70
|
-
}
|
|
71
|
-
})
|
|
72
|
-
</script>
|
|
73
|
-
|
|
74
|
-
<div class="relative">
|
|
75
|
-
<input
|
|
76
|
-
class={styles({
|
|
77
|
-
variant: 'borderless',
|
|
78
|
-
size: 'lg',
|
|
79
|
-
class: className + ' pl-9 border-b border-b-neutral-token-5 rounded-none text-sm',
|
|
80
|
-
})}
|
|
81
|
-
bind:this={el}
|
|
82
|
-
{...attrs}
|
|
83
|
-
bind:value={value}
|
|
84
|
-
use:action
|
|
85
|
-
{...restProps}
|
|
86
|
-
onkeydown={() => {}}
|
|
87
|
-
oninput={() => {handleValueUpdate(value)}}
|
|
88
|
-
onfocus={() => {}}
|
|
89
|
-
onblur={() => {}}
|
|
90
|
-
onchange={() => {}}
|
|
91
|
-
/>
|
|
92
|
-
<IconSearch class="absolute top-1/2 left-2 -translate-y-1/2 size-icon-xs opacity-60"/>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {derived, get} from 'svelte/store';
|
|
3
|
+
import {getCtx, getState, ITEM_SELECTOR, VALUE_ATTR} from '../command';
|
|
4
|
+
import {isBrowser} from '../../../internal';
|
|
5
|
+
import type {InputEvents, InputProps} from '../types';
|
|
6
|
+
import {sleep} from '../../../internal/helpers/sleep';
|
|
7
|
+
import {styles} from "../../input/Input";
|
|
8
|
+
import {IconSearch} from "../../..";
|
|
9
|
+
|
|
10
|
+
type $$Props = InputProps;
|
|
11
|
+
type $$Events = InputEvents;
|
|
12
|
+
|
|
13
|
+
const {ids, commandEl} = getCtx();
|
|
14
|
+
const commandState = getState();
|
|
15
|
+
|
|
16
|
+
const valueStore = derived(commandState, ($commandState) => $commandState.value);
|
|
17
|
+
|
|
18
|
+
let {
|
|
19
|
+
autofocus = undefined,
|
|
20
|
+
value = $bindable(),
|
|
21
|
+
el,
|
|
22
|
+
class: className,
|
|
23
|
+
...restProps
|
|
24
|
+
}: $$Props & {
|
|
25
|
+
el?: HTMLElement,
|
|
26
|
+
} = $props()
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
const selectedItemId = derived([valueStore, commandEl], ([$value, $commandEl]) => {
|
|
30
|
+
if (!isBrowser) return undefined;
|
|
31
|
+
const item = $commandEl?.querySelector(`${ITEM_SELECTOR}[${VALUE_ATTR}="${$value}"]`);
|
|
32
|
+
return item?.getAttribute('id');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
function handleValueUpdate(v: string) {
|
|
36
|
+
commandState.updateState('search', v);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function action(node: HTMLInputElement) {
|
|
40
|
+
if (autofocus) {
|
|
41
|
+
sleep(200).then(() => {
|
|
42
|
+
node.focus()
|
|
43
|
+
console.log('CommandInput autofocus')
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
let attrs = $state<Record<string, unknown>>()
|
|
49
|
+
|
|
50
|
+
$effect(() => {
|
|
51
|
+
attrs = {
|
|
52
|
+
type: 'text',
|
|
53
|
+
'data-cmdk-input': '',
|
|
54
|
+
autocomplete: 'off',
|
|
55
|
+
autocorrect: 'off',
|
|
56
|
+
spellcheck: false,
|
|
57
|
+
'aria-autocomplete': 'list',
|
|
58
|
+
role: 'combobox',
|
|
59
|
+
'aria-expanded': true,
|
|
60
|
+
'aria-controls': ids.list,
|
|
61
|
+
'aria-labelledby': ids.label,
|
|
62
|
+
'aria-activedescendant': $selectedItemId ?? undefined,
|
|
63
|
+
id: ids.input
|
|
64
|
+
};
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
$effect(() => {
|
|
68
|
+
return () => {
|
|
69
|
+
value = ''
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
</script>
|
|
73
|
+
|
|
74
|
+
<div class="relative">
|
|
75
|
+
<input
|
|
76
|
+
class={styles({
|
|
77
|
+
variant: 'borderless',
|
|
78
|
+
size: 'lg',
|
|
79
|
+
class: className + ' pl-9 border-b border-b-neutral-token-5 rounded-none text-sm',
|
|
80
|
+
})}
|
|
81
|
+
bind:this={el}
|
|
82
|
+
{...attrs}
|
|
83
|
+
bind:value={value}
|
|
84
|
+
use:action
|
|
85
|
+
{...restProps}
|
|
86
|
+
onkeydown={() => {}}
|
|
87
|
+
oninput={() => {handleValueUpdate(value)}}
|
|
88
|
+
onfocus={() => {}}
|
|
89
|
+
onblur={() => {}}
|
|
90
|
+
onchange={() => {}}
|
|
91
|
+
/>
|
|
92
|
+
<IconSearch class="absolute top-1/2 left-2 -translate-y-1/2 size-icon-xs opacity-60"/>
|
|
93
93
|
</div>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
declare const CommandInput: import("svelte").Component<{
|
|
2
2
|
el?: HTMLInputElement;
|
|
3
3
|
asChild?: boolean;
|
|
4
|
-
} & import("svelte/elements
|
|
4
|
+
} & import("svelte/elements").HTMLInputAttributes & {
|
|
5
5
|
el?: HTMLElement;
|
|
6
6
|
}, {}, "value">;
|
|
7
7
|
export default CommandInput;
|
|
@@ -1,110 +1,110 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {addEventListener, executeCallbacks, generateId, isUndefined} from '../../../internal
|
|
3
|
-
import {getCtx, getGroup, getState, VALUE_ATTR} from '../command
|
|
4
|
-
import type {ItemProps} from '../types
|
|
5
|
-
import {derived} from 'svelte/store';
|
|
6
|
-
import {onMount} from "svelte";
|
|
7
|
-
|
|
8
|
-
type $$Props = ItemProps
|
|
9
|
-
let {
|
|
10
|
-
children,
|
|
11
|
-
childrenWithProps,
|
|
12
|
-
id = generateId(),
|
|
13
|
-
alwaysRender = false,
|
|
14
|
-
onSelect,
|
|
15
|
-
value = '',
|
|
16
|
-
disabled = false,
|
|
17
|
-
...restProps
|
|
18
|
-
}: $$Props = $props()
|
|
19
|
-
|
|
20
|
-
const groupContext = getGroup();
|
|
21
|
-
const context = getCtx();
|
|
22
|
-
const commandState = getState();
|
|
23
|
-
|
|
24
|
-
const trueAlwaysRender = alwaysRender ?? groupContext?.alwaysRender;
|
|
25
|
-
|
|
26
|
-
const render = derived(commandState, ($state) => {
|
|
27
|
-
if (trueAlwaysRender || context.filter() === false || !$commandState.search) return true;
|
|
28
|
-
const currentScore = $commandState.filtered.items.get(id);
|
|
29
|
-
if (isUndefined(currentScore)) return false;
|
|
30
|
-
return currentScore > 0;
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const selected = derived(commandState, ($state) => $commandState.value === value);
|
|
34
|
-
|
|
35
|
-
let isFirstRender = $state(true);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
let attrs = derived(selected, ($selected) => (
|
|
39
|
-
{
|
|
40
|
-
'aria-disabled': disabled ? true : undefined,
|
|
41
|
-
'data-disabled': disabled ? true : undefined,
|
|
42
|
-
'aria-selected': $selected ? true : undefined,
|
|
43
|
-
'data-selected': $selected ? true : undefined,
|
|
44
|
-
'data-cmdk-item': '',
|
|
45
|
-
'data-value': value,
|
|
46
|
-
role: 'option',
|
|
47
|
-
id
|
|
48
|
-
}
|
|
49
|
-
));
|
|
50
|
-
|
|
51
|
-
onMount(() => {
|
|
52
|
-
isFirstRender = false;
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
onMount(() => {
|
|
57
|
-
let unsub
|
|
58
|
-
unsub = context.item(id, groupContext?.id);
|
|
59
|
-
return unsub;
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
function action(node: HTMLElement) {
|
|
64
|
-
if (!value && node.textContent) {
|
|
65
|
-
value = node.textContent.trim().toLowerCase();
|
|
66
|
-
}
|
|
67
|
-
context.value(id, value);
|
|
68
|
-
node.setAttribute(VALUE_ATTR, value);
|
|
69
|
-
|
|
70
|
-
const unsubEvents = executeCallbacks(
|
|
71
|
-
addEventListener(node, 'pointerenter', () => {
|
|
72
|
-
if (disabled) return;
|
|
73
|
-
select();
|
|
74
|
-
}),
|
|
75
|
-
addEventListener(node, 'click', () => {
|
|
76
|
-
if (disabled) return;
|
|
77
|
-
handleItemClick();
|
|
78
|
-
})
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
return {
|
|
82
|
-
destroy() {
|
|
83
|
-
unsubEvents();
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function handleItemClick() {
|
|
89
|
-
select();
|
|
90
|
-
onSelect?.(value);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function select() {
|
|
94
|
-
commandState.updateState('value', value, true);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
</script>
|
|
98
|
-
|
|
99
|
-
{#if $render || isFirstRender}
|
|
100
|
-
<div {...$attrs} use:action {...restProps}>
|
|
101
|
-
<!--{@render childrenWithProps?.(-->
|
|
102
|
-
<!-- {-->
|
|
103
|
-
<!-- attrs: attrs,-->
|
|
104
|
-
<!-- action: action-->
|
|
105
|
-
<!-- }-->
|
|
106
|
-
<!--)-->
|
|
107
|
-
<!--}-->
|
|
108
|
-
{@render children?.()}
|
|
109
|
-
</div>
|
|
110
|
-
{/if}
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {addEventListener, executeCallbacks, generateId, isUndefined} from '../../../internal';
|
|
3
|
+
import {getCtx, getGroup, getState, VALUE_ATTR} from '../command';
|
|
4
|
+
import type {ItemProps} from '../types';
|
|
5
|
+
import {derived} from 'svelte/store';
|
|
6
|
+
import {onMount} from "svelte";
|
|
7
|
+
|
|
8
|
+
type $$Props = ItemProps
|
|
9
|
+
let {
|
|
10
|
+
children,
|
|
11
|
+
childrenWithProps,
|
|
12
|
+
id = generateId(),
|
|
13
|
+
alwaysRender = false,
|
|
14
|
+
onSelect,
|
|
15
|
+
value = '',
|
|
16
|
+
disabled = false,
|
|
17
|
+
...restProps
|
|
18
|
+
}: $$Props = $props()
|
|
19
|
+
|
|
20
|
+
const groupContext = getGroup();
|
|
21
|
+
const context = getCtx();
|
|
22
|
+
const commandState = getState();
|
|
23
|
+
|
|
24
|
+
const trueAlwaysRender = alwaysRender ?? groupContext?.alwaysRender;
|
|
25
|
+
|
|
26
|
+
const render = derived(commandState, ($state) => {
|
|
27
|
+
if (trueAlwaysRender || context.filter() === false || !$commandState.search) return true;
|
|
28
|
+
const currentScore = $commandState.filtered.items.get(id);
|
|
29
|
+
if (isUndefined(currentScore)) return false;
|
|
30
|
+
return currentScore > 0;
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const selected = derived(commandState, ($state) => $commandState.value === value);
|
|
34
|
+
|
|
35
|
+
let isFirstRender = $state(true);
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
let attrs = derived(selected, ($selected) => (
|
|
39
|
+
{
|
|
40
|
+
'aria-disabled': disabled ? true : undefined,
|
|
41
|
+
'data-disabled': disabled ? true : undefined,
|
|
42
|
+
'aria-selected': $selected ? true : undefined,
|
|
43
|
+
'data-selected': $selected ? true : undefined,
|
|
44
|
+
'data-cmdk-item': '',
|
|
45
|
+
'data-value': value,
|
|
46
|
+
role: 'option',
|
|
47
|
+
id
|
|
48
|
+
}
|
|
49
|
+
));
|
|
50
|
+
|
|
51
|
+
onMount(() => {
|
|
52
|
+
isFirstRender = false;
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
onMount(() => {
|
|
57
|
+
let unsub
|
|
58
|
+
unsub = context.item(id, groupContext?.id);
|
|
59
|
+
return unsub;
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
function action(node: HTMLElement) {
|
|
64
|
+
if (!value && node.textContent) {
|
|
65
|
+
value = node.textContent.trim().toLowerCase();
|
|
66
|
+
}
|
|
67
|
+
context.value(id, value);
|
|
68
|
+
node.setAttribute(VALUE_ATTR, value);
|
|
69
|
+
|
|
70
|
+
const unsubEvents = executeCallbacks(
|
|
71
|
+
addEventListener(node, 'pointerenter', () => {
|
|
72
|
+
if (disabled) return;
|
|
73
|
+
select();
|
|
74
|
+
}),
|
|
75
|
+
addEventListener(node, 'click', () => {
|
|
76
|
+
if (disabled) return;
|
|
77
|
+
handleItemClick();
|
|
78
|
+
})
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
destroy() {
|
|
83
|
+
unsubEvents();
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function handleItemClick() {
|
|
89
|
+
select();
|
|
90
|
+
onSelect?.(value);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function select() {
|
|
94
|
+
commandState.updateState('value', value, true);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
</script>
|
|
98
|
+
|
|
99
|
+
{#if $render || isFirstRender}
|
|
100
|
+
<div {...$attrs} use:action {...restProps}>
|
|
101
|
+
<!--{@render childrenWithProps?.(-->
|
|
102
|
+
<!-- {-->
|
|
103
|
+
<!-- attrs: attrs,-->
|
|
104
|
+
<!-- action: action-->
|
|
105
|
+
<!-- }-->
|
|
106
|
+
<!--)-->
|
|
107
|
+
<!--}-->
|
|
108
|
+
{@render children?.()}
|
|
109
|
+
</div>
|
|
110
|
+
{/if}
|
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {isHTMLElement} from '../../../internal
|
|
3
|
-
import {getCtx, getState} from '../command
|
|
4
|
-
import type {ListProps} from '../types
|
|
5
|
-
|
|
6
|
-
const {ids} = getCtx();
|
|
7
|
-
const commandState = getState();
|
|
8
|
-
|
|
9
|
-
type $$Props = ListProps;
|
|
10
|
-
|
|
11
|
-
let {children, el, ...restProps} = $props()
|
|
12
|
-
|
|
13
|
-
function sizerAction(node: HTMLElement) {
|
|
14
|
-
let animationFrame: number;
|
|
15
|
-
const listEl = node.closest('[data-cmdk-list]');
|
|
16
|
-
if (!isHTMLElement(listEl)) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const observer = new ResizeObserver(() => {
|
|
21
|
-
animationFrame = requestAnimationFrame(() => {
|
|
22
|
-
const height = node.offsetHeight;
|
|
23
|
-
listEl.style.setProperty('--cmdk-list-height', height.toFixed(1) + 'px');
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
observer.observe(node);
|
|
28
|
-
return {
|
|
29
|
-
destroy() {
|
|
30
|
-
cancelAnimationFrame(animationFrame);
|
|
31
|
-
observer.unobserve(node);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const listAttrs = {
|
|
37
|
-
'data-cmdk-list': '',
|
|
38
|
-
role: 'listbox',
|
|
39
|
-
'aria-label': 'Suggestions',
|
|
40
|
-
id: ids.list,
|
|
41
|
-
'aria-labelledby': ids.input
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const sizerAttrs = {
|
|
45
|
-
'data-cmdk-list-sizer': ''
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
</script>
|
|
49
|
-
|
|
50
|
-
<div {...listAttrs} bind:this={el} {...restProps}>
|
|
51
|
-
<div {...sizerAttrs} use:sizerAction>
|
|
52
|
-
{#key $commandState.search === ''}
|
|
53
|
-
{@render children()}
|
|
54
|
-
{/key}
|
|
55
|
-
</div>
|
|
56
|
-
</div>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {isHTMLElement} from '../../../internal';
|
|
3
|
+
import {getCtx, getState} from '../command';
|
|
4
|
+
import type {ListProps} from '../types';
|
|
5
|
+
|
|
6
|
+
const {ids} = getCtx();
|
|
7
|
+
const commandState = getState();
|
|
8
|
+
|
|
9
|
+
type $$Props = ListProps;
|
|
10
|
+
|
|
11
|
+
let {children, el, ...restProps} = $props()
|
|
12
|
+
|
|
13
|
+
function sizerAction(node: HTMLElement) {
|
|
14
|
+
let animationFrame: number;
|
|
15
|
+
const listEl = node.closest('[data-cmdk-list]');
|
|
16
|
+
if (!isHTMLElement(listEl)) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const observer = new ResizeObserver(() => {
|
|
21
|
+
animationFrame = requestAnimationFrame(() => {
|
|
22
|
+
const height = node.offsetHeight;
|
|
23
|
+
listEl.style.setProperty('--cmdk-list-height', height.toFixed(1) + 'px');
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
observer.observe(node);
|
|
28
|
+
return {
|
|
29
|
+
destroy() {
|
|
30
|
+
cancelAnimationFrame(animationFrame);
|
|
31
|
+
observer.unobserve(node);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const listAttrs = {
|
|
37
|
+
'data-cmdk-list': '',
|
|
38
|
+
role: 'listbox',
|
|
39
|
+
'aria-label': 'Suggestions',
|
|
40
|
+
id: ids.list,
|
|
41
|
+
'aria-labelledby': ids.input
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const sizerAttrs = {
|
|
45
|
+
'data-cmdk-list-sizer': ''
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<div {...listAttrs} bind:this={el} {...restProps}>
|
|
51
|
+
<div {...sizerAttrs} use:sizerAction>
|
|
52
|
+
{#key $commandState.search === ''}
|
|
53
|
+
{@render children()}
|
|
54
|
+
{/key}
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { LoadingProps } from '../types
|
|
3
|
-
import type {Snippet} from "svelte";
|
|
4
|
-
|
|
5
|
-
type $$Props = LoadingProps;
|
|
6
|
-
|
|
7
|
-
let {childrenWithProps, progress, ...restProps} : $$Props & {
|
|
8
|
-
childrenWithProps: Snippet<[any]>
|
|
9
|
-
} = $props()
|
|
10
|
-
|
|
11
|
-
let attrs = $state<any>()
|
|
12
|
-
|
|
13
|
-
$effect(() => {
|
|
14
|
-
attrs = {
|
|
15
|
-
'data-cmdk-loading': '',
|
|
16
|
-
role: 'progressbar',
|
|
17
|
-
'aria-valuenow': progress,
|
|
18
|
-
'aria-valuemin': 0,
|
|
19
|
-
'aria-valuemax': 100,
|
|
20
|
-
'aria-label': 'Loading...'
|
|
21
|
-
};
|
|
22
|
-
})
|
|
23
|
-
</script>
|
|
24
|
-
|
|
25
|
-
<div {...attrs} {...restProps}>
|
|
26
|
-
<div aria-hidden>
|
|
27
|
-
{@render childrenWithProps(attrs)}
|
|
28
|
-
</div>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { LoadingProps } from '../types';
|
|
3
|
+
import type {Snippet} from "svelte";
|
|
4
|
+
|
|
5
|
+
type $$Props = LoadingProps;
|
|
6
|
+
|
|
7
|
+
let {childrenWithProps, progress, ...restProps} : $$Props & {
|
|
8
|
+
childrenWithProps: Snippet<[any]>
|
|
9
|
+
} = $props()
|
|
10
|
+
|
|
11
|
+
let attrs = $state<any>()
|
|
12
|
+
|
|
13
|
+
$effect(() => {
|
|
14
|
+
attrs = {
|
|
15
|
+
'data-cmdk-loading': '',
|
|
16
|
+
role: 'progressbar',
|
|
17
|
+
'aria-valuenow': progress,
|
|
18
|
+
'aria-valuemin': 0,
|
|
19
|
+
'aria-valuemax': 100,
|
|
20
|
+
'aria-label': 'Loading...'
|
|
21
|
+
};
|
|
22
|
+
})
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<div {...attrs} {...restProps}>
|
|
26
|
+
<div aria-hidden>
|
|
27
|
+
{@render childrenWithProps(attrs)}
|
|
28
|
+
</div>
|
|
29
29
|
</div>
|
|
@@ -2,7 +2,7 @@ import type { Snippet } from "svelte";
|
|
|
2
2
|
declare const CommandLoading: import("svelte").Component<{
|
|
3
3
|
progress?: number;
|
|
4
4
|
asChild?: boolean;
|
|
5
|
-
} & import("../../../internal
|
|
5
|
+
} & import("../../../internal").HTMLDivAttributes & {
|
|
6
6
|
childrenWithProps: Snippet<[any]>;
|
|
7
7
|
}, {}, "">;
|
|
8
8
|
export default CommandLoading;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { derived } from 'svelte/store';
|
|
3
|
-
import { getState } from '../command
|
|
4
|
-
import type { SeparatorProps } from '../types
|
|
5
|
-
|
|
6
|
-
type $$Props = SeparatorProps;
|
|
7
|
-
|
|
8
|
-
let {alwaysRender,...restProps} :$$Props= $props()
|
|
9
|
-
|
|
10
|
-
const commandState = getState();
|
|
11
|
-
const render = derived(commandState, ($state) => !$commandState.search);
|
|
12
|
-
|
|
13
|
-
const attrs = {
|
|
14
|
-
'data-cmdk-separator': '',
|
|
15
|
-
role: 'separator'
|
|
16
|
-
};
|
|
17
|
-
</script>
|
|
18
|
-
|
|
19
|
-
{#if $render || alwaysRender}
|
|
20
|
-
<div {...attrs} {...restProps}></div>
|
|
21
|
-
{/if}
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { derived } from 'svelte/store';
|
|
3
|
+
import { getState } from '../command';
|
|
4
|
+
import type { SeparatorProps } from '../types';
|
|
5
|
+
|
|
6
|
+
type $$Props = SeparatorProps;
|
|
7
|
+
|
|
8
|
+
let {alwaysRender,...restProps} :$$Props= $props()
|
|
9
|
+
|
|
10
|
+
const commandState = getState();
|
|
11
|
+
const render = derived(commandState, ($state) => !$commandState.search);
|
|
12
|
+
|
|
13
|
+
const attrs = {
|
|
14
|
+
'data-cmdk-separator': '',
|
|
15
|
+
role: 'separator'
|
|
16
|
+
};
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
{#if $render || alwaysRender}
|
|
20
|
+
<div {...attrs} {...restProps}></div>
|
|
21
|
+
{/if}
|