tera-system-ui 0.1.35 → 0.1.40

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.
Files changed (101) hide show
  1. package/dist/components/command/command.scss +2 -2
  2. package/dist/components/command/components/command-empty.svelte +16 -0
  3. package/dist/components/command/components/command-empty.svelte.d.ts +4 -0
  4. package/dist/components/command/components/command-group.svelte +31 -0
  5. package/dist/components/command/components/command-group.svelte.d.ts +7 -0
  6. package/dist/components/command/components/command-input.svelte +30 -0
  7. package/dist/components/command/components/command-input.svelte.d.ts +4 -0
  8. package/dist/components/command/components/command-item.svelte +20 -0
  9. package/dist/components/command/components/command-item.svelte.d.ts +4 -0
  10. package/dist/components/command/components/command-link-item.svelte +18 -0
  11. package/dist/components/command/components/command-link-item.svelte.d.ts +4 -0
  12. package/dist/components/command/components/command-list.svelte +16 -0
  13. package/dist/components/command/components/command-list.svelte.d.ts +4 -0
  14. package/dist/components/command/components/command-separator.svelte +15 -0
  15. package/dist/components/command/components/command-separator.svelte.d.ts +4 -0
  16. package/dist/components/command/components/command-shortcut.svelte +19 -0
  17. package/dist/components/command/components/command-shortcut.svelte.d.ts +5 -0
  18. package/dist/components/command/components/command.svelte +54 -0
  19. package/dist/components/command/components/command.svelte.d.ts +5 -0
  20. package/dist/components/command/index.d.ts +12 -12
  21. package/dist/components/command/index.js +13 -18
  22. package/dist/index.d.ts +0 -1
  23. package/dist/index.js +0 -1
  24. package/dist/tera-i18n/dev-tools/translator/gpt-translator-i18n-message.js +1 -3
  25. package/dist/tera-i18n/dev-tools/translator/prompt/i18n-message-translate-prompt-cv-maker.txt +17 -14
  26. package/dist/tera-i18n/projects/common/all-language-data.js +10 -1
  27. package/dist/tera-i18n/projects/cv-maker/messages/ar.json +13 -13
  28. package/dist/tera-i18n/projects/cv-maker/messages/bg.json +18 -18
  29. package/dist/tera-i18n/projects/cv-maker/messages/bn.json +21 -21
  30. package/dist/tera-i18n/projects/cv-maker/messages/ca.json +12 -12
  31. package/dist/tera-i18n/projects/cv-maker/messages/cs.json +11 -11
  32. package/dist/tera-i18n/projects/cv-maker/messages/da.json +10 -10
  33. package/dist/tera-i18n/projects/cv-maker/messages/de.json +11 -11
  34. package/dist/tera-i18n/projects/cv-maker/messages/el.json +14 -14
  35. package/dist/tera-i18n/projects/cv-maker/messages/en-CA.json +51 -0
  36. package/dist/tera-i18n/projects/cv-maker/messages/en-GB.json +51 -0
  37. package/dist/tera-i18n/projects/cv-maker/messages/en-IN.json +51 -0
  38. package/dist/tera-i18n/projects/cv-maker/messages/en-PK.json +51 -0
  39. package/dist/tera-i18n/projects/cv-maker/messages/en-US.json +51 -0
  40. package/dist/tera-i18n/projects/cv-maker/messages/en-ZA.json +51 -0
  41. package/dist/tera-i18n/projects/cv-maker/messages/es.json +8 -8
  42. package/dist/tera-i18n/projects/cv-maker/messages/fi.json +5 -5
  43. package/dist/tera-i18n/projects/cv-maker/messages/fr.json +13 -13
  44. package/dist/tera-i18n/projects/cv-maker/messages/he.json +13 -13
  45. package/dist/tera-i18n/projects/cv-maker/messages/hi.json +12 -12
  46. package/dist/tera-i18n/projects/cv-maker/messages/hu.json +16 -16
  47. package/dist/tera-i18n/projects/cv-maker/messages/id.json +9 -9
  48. package/dist/tera-i18n/projects/cv-maker/messages/it.json +13 -13
  49. package/dist/tera-i18n/projects/cv-maker/messages/ja.json +13 -13
  50. package/dist/tera-i18n/projects/cv-maker/messages/ko.json +15 -15
  51. package/dist/tera-i18n/projects/cv-maker/messages/lt.json +13 -13
  52. package/dist/tera-i18n/projects/cv-maker/messages/lv.json +12 -12
  53. package/dist/tera-i18n/projects/cv-maker/messages/ms-MY.json +51 -0
  54. package/dist/tera-i18n/projects/cv-maker/messages/ms.json +10 -10
  55. package/dist/tera-i18n/projects/cv-maker/messages/nl.json +5 -5
  56. package/dist/tera-i18n/projects/cv-maker/messages/no.json +8 -8
  57. package/dist/tera-i18n/projects/cv-maker/messages/pl.json +12 -12
  58. package/dist/tera-i18n/projects/cv-maker/messages/pt-BR.json +51 -0
  59. package/dist/tera-i18n/projects/cv-maker/messages/pt-PT.json +51 -0
  60. package/dist/tera-i18n/projects/cv-maker/messages/pt.json +7 -7
  61. package/dist/tera-i18n/projects/cv-maker/messages/ro.json +9 -9
  62. package/dist/tera-i18n/projects/cv-maker/messages/ru.json +13 -13
  63. package/dist/tera-i18n/projects/cv-maker/messages/sk.json +15 -15
  64. package/dist/tera-i18n/projects/cv-maker/messages/sl.json +15 -15
  65. package/dist/tera-i18n/projects/cv-maker/messages/sq.json +34 -34
  66. package/dist/tera-i18n/projects/cv-maker/messages/sr.json +16 -16
  67. package/dist/tera-i18n/projects/cv-maker/messages/sv.json +9 -9
  68. package/dist/tera-i18n/projects/cv-maker/messages/sw.json +15 -15
  69. package/dist/tera-i18n/projects/cv-maker/messages/ta.json +25 -25
  70. package/dist/tera-i18n/projects/cv-maker/messages/te.json +25 -25
  71. package/dist/tera-i18n/projects/cv-maker/messages/th.json +17 -17
  72. package/dist/tera-i18n/projects/cv-maker/messages/tl.json +16 -16
  73. package/dist/tera-i18n/projects/cv-maker/messages/tr.json +6 -6
  74. package/dist/tera-i18n/projects/cv-maker/messages/uk.json +15 -15
  75. package/dist/tera-i18n/projects/cv-maker/messages/vi.json +18 -18
  76. package/dist/tera-i18n/projects/cv-maker/messages/zh-CN.json +29 -29
  77. package/dist/tera-i18n/projects/cv-maker/messages/zh-TW.json +26 -26
  78. package/dist/tera-i18n/projects/cv-maker/project.inlang/settings.json +68 -59
  79. package/dist/tera-i18n/projects/cv-maker/supported-language.js +10 -1
  80. package/dist/utils/index.d.ts +10 -0
  81. package/package.json +1 -1
  82. package/dist/components/command/command.d.ts +0 -33
  83. package/dist/components/command/command.js +0 -512
  84. package/dist/components/command/components/Command.svelte +0 -120
  85. package/dist/components/command/components/Command.svelte.d.ts +0 -4
  86. package/dist/components/command/components/CommandEmpty.svelte +0 -30
  87. package/dist/components/command/components/CommandEmpty.svelte.d.ts +0 -4
  88. package/dist/components/command/components/CommandGroup.svelte +0 -110
  89. package/dist/components/command/components/CommandGroup.svelte.d.ts +0 -4
  90. package/dist/components/command/components/CommandInput.svelte +0 -92
  91. package/dist/components/command/components/CommandInput.svelte.d.ts +0 -8
  92. package/dist/components/command/components/CommandItem.svelte +0 -110
  93. package/dist/components/command/components/CommandItem.svelte.d.ts +0 -4
  94. package/dist/components/command/components/CommandList.svelte +0 -56
  95. package/dist/components/command/components/CommandList.svelte.d.ts +0 -6
  96. package/dist/components/command/components/CommandLoading.svelte +0 -29
  97. package/dist/components/command/components/CommandLoading.svelte.d.ts +0 -9
  98. package/dist/components/command/components/CommandSeparator.svelte +0 -21
  99. package/dist/components/command/components/CommandSeparator.svelte.d.ts +0 -4
  100. package/dist/components/command/types.d.ts +0 -227
  101. package/dist/components/command/types.js +0 -1
@@ -1,110 +0,0 @@
1
- <script lang="ts">
2
- import {generateId} from '../../../internal/index.js';
3
- import {derived} from 'svelte/store';
4
- import {createGroup, getCtx, getState, VALUE_ATTR} from '../command.js';
5
- import type {GroupProps} from '../types.js';
6
- import {onMount} from 'svelte';
7
-
8
- type $$Props = GroupProps;
9
-
10
- let {
11
- children,
12
- heading,
13
- value = '',
14
- alwaysRender = false,
15
- ...restProps
16
- }: $$Props = $props()
17
-
18
- const {id} = createGroup(alwaysRender);
19
-
20
- const context = getCtx();
21
- const commandState = getState();
22
- const headingId = generateId();
23
-
24
- const render = derived(commandState, ($state) => {
25
- if (alwaysRender) return true;
26
- if (context.filter() === false) return true;
27
- if (!$commandState.search) return true;
28
- return $commandState.filtered.groups.has(id);
29
- });
30
-
31
-
32
- onMount(() => {
33
- const unsubGroup = context.group(id);
34
- return unsubGroup;
35
- });
36
-
37
-
38
- function containerAction(node: HTMLElement) {
39
-
40
- if (value) {
41
- context.value(id, value);
42
- node.setAttribute(VALUE_ATTR, value);
43
- return;
44
- }
45
-
46
- if (heading) {
47
- value = heading.trim().toLowerCase();
48
- } else if (node.textContent) {
49
- value = node.textContent.trim().toLowerCase();
50
- }
51
-
52
- context.value(id, value);
53
- node.setAttribute(VALUE_ATTR, value);
54
- }
55
-
56
- let containerAttrs = $state()
57
-
58
- $effect(() => {
59
- containerAttrs = {
60
- 'data-cmdk-group': '',
61
- role: 'presentation',
62
- hidden: $render ? undefined : true,
63
- 'data-value': value
64
- }
65
- })
66
-
67
-
68
- const headingAttrs = {
69
- 'data-cmdk-group-heading': '',
70
- 'aria-hidden': true,
71
- id: headingId
72
- };
73
-
74
- let groupAttrs = $state()
75
- $effect(() => {
76
- groupAttrs = {
77
- 'data-cmdk-group-items': '',
78
- role: 'group',
79
- 'aria-labelledby': heading ? headingId : undefined
80
- };
81
- })
82
-
83
- let container = $state()
84
- $effect(() => {
85
- container = {
86
- action: containerAction,
87
- attrs: containerAttrs
88
- };
89
- })
90
-
91
-
92
- let group = $state()
93
- $effect(() => {
94
- group = {
95
- attrs: groupAttrs
96
- };
97
- })
98
- </script>
99
-
100
- <div use:containerAction {...containerAttrs} {...restProps}>
101
- {#if heading}
102
- <div {...headingAttrs}>
103
- {heading}
104
- </div>
105
- {/if}
106
- <div {...groupAttrs}>
107
- <!-- <slot {container} {group} heading={{ attrs: headingAttrs }}/>-->
108
- {@render children?.()}
109
- </div>
110
- </div>
@@ -1,4 +0,0 @@
1
- import type { GroupProps } from '../types.js';
2
- declare const CommandGroup: import("svelte").Component<GroupProps, {}, "">;
3
- type CommandGroup = ReturnType<typeof CommandGroup>;
4
- export default CommandGroup;
@@ -1,92 +0,0 @@
1
- <script lang="ts">
2
- import {derived, get} from 'svelte/store';
3
- import {getCtx, getState, ITEM_SELECTOR, VALUE_ATTR} from '../command.js';
4
- import {isBrowser} from '../../../internal/index';
5
- import type {InputEvents, InputProps} from '../types.js';
6
- import {sleep} from '../../../internal/helpers/sleep.js';
7
- import {styles} from "../../input/Input";
8
- import {IconSearch} from "../../icons";
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
- });
44
- }
45
- }
46
-
47
- let attrs = $state<Record<string, unknown>>()
48
-
49
- $effect(() => {
50
- attrs = {
51
- type: 'text',
52
- 'data-cmdk-input': '',
53
- autocomplete: 'off',
54
- autocorrect: 'off',
55
- spellcheck: false,
56
- 'aria-autocomplete': 'list',
57
- role: 'combobox',
58
- 'aria-expanded': true,
59
- 'aria-controls': ids.list,
60
- 'aria-labelledby': ids.label,
61
- 'aria-activedescendant': $selectedItemId ?? undefined,
62
- id: ids.input
63
- };
64
- })
65
-
66
- $effect(() => {
67
- return () => {
68
- value = ''
69
- }
70
- })
71
- </script>
72
-
73
- <div class="relative">
74
- <input
75
- class={styles({
76
- variant: 'borderless',
77
- size: 'lg',
78
- class: className + ' pl-9 border-b border-b-neutral-token-5 rounded-none text-sm',
79
- })}
80
- bind:this={el}
81
- {...attrs}
82
- bind:value={value}
83
- use:action
84
- {...restProps}
85
- onkeydown={() => {}}
86
- oninput={() => {handleValueUpdate(value)}}
87
- onfocus={() => {}}
88
- onblur={() => {}}
89
- onchange={() => {}}
90
- />
91
- <IconSearch class="absolute top-1/2 left-2 -translate-y-1/2 size-icon-xs opacity-60"/>
92
- </div>
@@ -1,8 +0,0 @@
1
- import type { InputProps } from '../types.js';
2
- type $$Props = InputProps;
3
- type $$ComponentProps = $$Props & {
4
- el?: HTMLElement;
5
- };
6
- declare const CommandInput: import("svelte").Component<$$ComponentProps, {}, "value">;
7
- type CommandInput = ReturnType<typeof CommandInput>;
8
- export default CommandInput;
@@ -1,110 +0,0 @@
1
- <script lang="ts">
2
- import {addEventListener, executeCallbacks, generateId, isUndefined} from '../../../internal/index.js';
3
- import {getCtx, getGroup, getState, VALUE_ATTR} from '../command.js';
4
- import type {ItemProps} from '../types.js';
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,4 +0,0 @@
1
- import type { ItemProps } from '../types.js';
2
- declare const CommandItem: import("svelte").Component<ItemProps, {}, "">;
3
- type CommandItem = ReturnType<typeof CommandItem>;
4
- export default CommandItem;
@@ -1,56 +0,0 @@
1
- <script lang="ts">
2
- import {isHTMLElement} from '../../../internal/index.js';
3
- import {getCtx, getState} from '../command.js';
4
- import type {ListProps} from '../types.js';
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,6 +0,0 @@
1
- declare const CommandList: import("svelte").Component<{
2
- children: any;
3
- el: any;
4
- } & Record<string, any>, {}, "">;
5
- type CommandList = ReturnType<typeof CommandList>;
6
- export default CommandList;
@@ -1,29 +0,0 @@
1
- <script lang="ts">
2
- import type { LoadingProps } from '../types.js';
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
- </div>
@@ -1,9 +0,0 @@
1
- import type { LoadingProps } from '../types.js';
2
- import type { Snippet } from "svelte";
3
- type $$Props = LoadingProps;
4
- type $$ComponentProps = $$Props & {
5
- childrenWithProps: Snippet<[any]>;
6
- };
7
- declare const CommandLoading: import("svelte").Component<$$ComponentProps, {}, "">;
8
- type CommandLoading = ReturnType<typeof CommandLoading>;
9
- export default CommandLoading;
@@ -1,21 +0,0 @@
1
- <script lang="ts">
2
- import { derived } from 'svelte/store';
3
- import { getState } from '../command.js';
4
- import type { SeparatorProps } from '../types.js';
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,4 +0,0 @@
1
- import type { SeparatorProps } from '../types.js';
2
- declare const CommandSeparator: import("svelte").Component<SeparatorProps, {}, "">;
3
- type CommandSeparator = ReturnType<typeof CommandSeparator>;
4
- export default CommandSeparator;
@@ -1,227 +0,0 @@
1
- import type { Expand, HTMLDivAttributes } from '../../internal/index.js';
2
- import type { HTMLInputAttributes } from 'svelte/elements';
3
- import type { Writable } from 'svelte/store';
4
- import type { Snippet } from "svelte";
5
- export type LoadingProps = {
6
- /** Estimated loading progress */
7
- progress?: number;
8
- /**
9
- * Whether to delegate rendering to a custom element.
10
- *
11
- * The contents within the `Loading` component should be marked
12
- * as `aria-hidden` to prevent screen readers from reading the
13
- * contents while loading.
14
- */
15
- asChild?: boolean;
16
- } & HTMLDivAttributes;
17
- export type EmptyProps = {
18
- /**
19
- * Whether to delegate rendering to a custom element.
20
- *
21
- * Only receives `attrs`, no `action`.
22
- */
23
- asChild?: boolean;
24
- } & HTMLDivAttributes;
25
- export type SeparatorProps = {
26
- /**
27
- * Whether this separator is always rendered, regardless
28
- * of the filter.
29
- */
30
- alwaysRender?: boolean;
31
- /**
32
- * Whether to delegate rendering to a custom element.
33
- */
34
- asChild?: boolean;
35
- } & HTMLDivAttributes;
36
- type BaseCommandProps = {
37
- /**
38
- * Controlled state store for the command menu.
39
- * Initialize state using the `createState` function.
40
- */
41
- state?: Writable<State>;
42
- /**
43
- * An accessible label for the command menu.
44
- * Not visible & only used for screen readers.
45
- */
46
- label?: string;
47
- /**
48
- * Optionally set to `false` to turn off the automatic filtering
49
- * and sorting. If `false`, you must conditionally render valid
50
- * items yourself.
51
- */
52
- shouldFilter?: boolean;
53
- /**
54
- * A custom filter function for whether each command item should
55
- * match the query. It should return a number between `0` and `1`,
56
- * with `1` being a perfect match, and `0` being no match, resulting
57
- * in the item being hidden entirely.
58
- *
59
- * By default, it will use the `command-score` package to score.
60
- */
61
- filter?: (value: string, search: string) => number;
62
- /**
63
- * Optionally provide or bind to the selected command menu item.
64
- */
65
- value?: string;
66
- /**
67
- * A function that is called when the selected command menu item
68
- * changes. It receives the new value as an argument.
69
- */
70
- onValueChange?: (value: string) => void;
71
- /**
72
- * Optionally set to `true` to enable looping through the items
73
- * when the user reaches the end of the list using the keyboard.
74
- */
75
- loop?: boolean;
76
- childrenWithProps?: Snippet<[any]>;
77
- };
78
- export type CommandProps = Expand<BaseCommandProps & {
79
- /**
80
- * Optionally provide custom ids for the command menu
81
- * elements. These ids should be unique and are only
82
- * necessary in very specific cases. Use with caution.
83
- */
84
- ids?: Partial<CommandIds>;
85
- }> & HTMLDivAttributes & {
86
- onKeydown?: (e: KeyboardEvent) => void;
87
- onRequestCloseCommand?: () => void;
88
- asChild?: boolean;
89
- };
90
- export type ListProps = {
91
- /**
92
- * The list element
93
- */
94
- el?: HTMLElement;
95
- /**
96
- * Whether to delegate rendering to a custom element.
97
- *
98
- * Provides 2 slot props: `container` & `list`.
99
- * Container only has an `attrs` property, while `list` has
100
- * `attrs` & `action` to be applied to the respective elements.
101
- *
102
- * The `list` wraps the `sizer`, and the `sizer` wraps the `items`, and
103
- * is responsible for measuring the height of the items and setting the
104
- * CSS variable to the height of the items.
105
- */
106
- asChild?: boolean;
107
- } & HTMLDivAttributes;
108
- export type InputProps = {
109
- /**
110
- * The input element
111
- */
112
- el?: HTMLInputElement;
113
- /**
114
- * Whether to delegate rendering to a custom element.
115
- */
116
- asChild?: boolean;
117
- } & HTMLInputAttributes;
118
- export type GroupProps = {
119
- /**
120
- * Optional heading to render for the group
121
- */
122
- heading?: string;
123
- /**
124
- * If heading isn't provided, you must provide a unique
125
- * value for the group.
126
- */
127
- value?: string;
128
- /**
129
- * Whether or not this group is always rendered,
130
- * regardless of filtering.
131
- */
132
- alwaysRender?: boolean;
133
- /**
134
- * Whether to delegate rendering to custom elements.
135
- *
136
- * Provides 3 slot props: `container`, `heading`, and `group`.
137
- * Container has `attrs` & `action`, while `heading` & `group`
138
- * only have `attrs` to be applied to the respective elements.
139
- */
140
- asChild?: boolean;
141
- } & HTMLDivAttributes;
142
- export type ItemProps = {
143
- /**
144
- * Whether this item is disabled.
145
- */
146
- disabled?: boolean;
147
- /**
148
- * A function called when this item is selected, either
149
- * via click or keyboard selection.
150
- */
151
- onSelect?: (value: string) => void;
152
- /**
153
- * A unique value for this item.
154
- * If not provided, it will be inferred from the rendered
155
- * `textContent`. If your `textContent` is dynamic, you must
156
- * provide a stable unique `value`.
157
- */
158
- value?: string;
159
- /**
160
- * Whether or not this item is always rendered,
161
- * regardless of filtering.
162
- */
163
- alwaysRender?: boolean;
164
- /**
165
- * Whether to delegate rendering to a custom element.
166
- * Will pass the `attrs` & `action` to be applied to the custom element.
167
- */
168
- asChild?: boolean;
169
- /**
170
- * Optionally override the default `id` generated for this item.
171
- * NOTE: This must be unique across all items and is only necessary
172
- * in very specific cases.
173
- */
174
- id?: string;
175
- childrenWithProps?: Snippet<[{
176
- action: (node: HTMLElement) => {
177
- destroy(): void;
178
- };
179
- attrs: any;
180
- }]>;
181
- } & HTMLDivAttributes;
182
- export type InputEvents = {
183
- keydown: KeyboardEvent;
184
- blur: FocusEvent;
185
- input: Event;
186
- focus: FocusEvent;
187
- change: Event;
188
- };
189
- export type CommandOptionStores = {
190
- [K in keyof Omit<Required<BaseCommandProps>, 'value'>]: Writable<CommandProps[K]>;
191
- };
192
- export type State = {
193
- /** The value of the search query */
194
- search: string;
195
- /** The value of the selected command menu item */
196
- value: string;
197
- /** The filtered items */
198
- filtered: {
199
- /** The count of all visible items. */
200
- count: number;
201
- /** Map from visible item id to its search store. */
202
- items: Map<string, number>;
203
- /** Set of groups with at least one visible item. */
204
- groups: Set<string>;
205
- };
206
- };
207
- export type CommandIds = Record<'root' | 'label' | 'input' | 'list', string>;
208
- export type Context = {
209
- value: (id: string, value: string) => void;
210
- item: (id: string, groupId: string | undefined) => () => void;
211
- group: (id: string) => () => void;
212
- filter: () => boolean;
213
- label: string;
214
- commandEl: Writable<HTMLElement | null>;
215
- ids: CommandIds;
216
- updateState: UpdateState;
217
- };
218
- type UpdateState = <K extends keyof State>(key: K, value: State[K], preventScroll?: boolean) => void;
219
- export type ConextStore = Writable<Context>;
220
- export type StateStore = Writable<State> & {
221
- updateState: UpdateState;
222
- };
223
- export type Group = {
224
- id: string;
225
- alwaysRender: boolean;
226
- };
227
- export {};
@@ -1 +0,0 @@
1
- export {};