tera-system-ui 0.0.18 → 0.0.20

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 (68) hide show
  1. package/dist/components/brand-logo/BrandLogo.svelte +31 -31
  2. package/dist/components/button/Button.svelte +49 -49
  3. package/dist/components/combobox/Combobox.svelte +8 -8
  4. package/dist/components/command/command.scss +72 -72
  5. package/dist/components/command/components/Command.svelte +120 -120
  6. package/dist/components/command/components/CommandEmpty.svelte +30 -30
  7. package/dist/components/command/components/CommandGroup.svelte +110 -110
  8. package/dist/components/command/components/CommandInput.svelte +92 -92
  9. package/dist/components/command/components/CommandItem.svelte +110 -110
  10. package/dist/components/command/components/CommandList.svelte +56 -56
  11. package/dist/components/command/components/CommandLoading.svelte +28 -28
  12. package/dist/components/command/components/CommandSeparator.svelte +21 -21
  13. package/dist/components/dialog/Dialog.astro +63 -0
  14. package/dist/components/dialog/Dialog.d.ts +10 -6
  15. package/dist/components/dialog/Dialog.svelte +109 -107
  16. package/dist/components/dialog/dialog.scss +115 -112
  17. package/dist/components/dialog/index.d.ts +1 -0
  18. package/dist/components/dialog/index.js +1 -0
  19. package/dist/components/header/Header.svelte +36 -36
  20. package/dist/components/header/header.scss +19 -19
  21. package/dist/components/icons/IconArrowBigRightFilled.svelte +10 -10
  22. package/dist/components/icons/IconBook.svelte +10 -10
  23. package/dist/components/icons/IconBookmarkPlus.svelte +10 -10
  24. package/dist/components/icons/IconCalculator.svelte +10 -10
  25. package/dist/components/icons/IconCheck.svelte +10 -10
  26. package/dist/components/icons/IconChevronDown.svelte +10 -10
  27. package/dist/components/icons/IconCopy.svelte +10 -10
  28. package/dist/components/icons/IconCopyCheckFilled.svelte +10 -10
  29. package/dist/components/icons/IconHamburger.svelte +10 -10
  30. package/dist/components/icons/IconLanguage.svelte +10 -10
  31. package/dist/components/icons/IconLoader2.svelte +10 -10
  32. package/dist/components/icons/IconMoon.svelte +10 -10
  33. package/dist/components/icons/IconPointFilled.svelte +10 -10
  34. package/dist/components/icons/IconSearch.svelte +10 -10
  35. package/dist/components/icons/IconSun.svelte +10 -10
  36. package/dist/components/icons/IconSwitchHorizontal.svelte +10 -10
  37. package/dist/components/icons/IconSwitchVertical.svelte +10 -10
  38. package/dist/components/icons/IconTransform.svelte +10 -10
  39. package/dist/components/icons/IconX.svelte +10 -10
  40. package/dist/components/input/Input.svelte +24 -24
  41. package/dist/components/language-picker-button/LanguagePickerButton.svelte +109 -109
  42. package/dist/components/light-dark-toggle/LightDarkToggle.svelte +36 -36
  43. package/dist/components/popover/Popover.svelte +136 -136
  44. package/dist/components/popover-responsive/PopoverResponsive.svelte +87 -87
  45. package/dist/components/side-navigation/SideNavigation.svelte +114 -114
  46. package/dist/components/side-navigation/SideNavigationItem.svelte +17 -17
  47. package/dist/components/side-navigation/SideNavigationLayout.svelte +19 -19
  48. package/dist/components/side-navigation/sidenav.scss +149 -149
  49. package/dist/components/tera-ui-context/TeraUiContext.d.ts +1 -0
  50. package/dist/components/tera-ui-context/TeraUiContext.svelte +28 -28
  51. package/dist/components/tera-ui-context/global-context-store.d.ts +3 -0
  52. package/dist/components/tera-ui-context/global-context-store.js +2 -0
  53. package/dist/components/tera-ui-context/global-context.js +11 -3
  54. package/dist/index.d.ts +1 -1
  55. package/dist/index.js +1 -1
  56. package/dist/paraglide/messages/de.js +1 -1
  57. package/dist/paraglide/messages/es.js +1 -1
  58. package/dist/paraglide/messages/it.js +1 -1
  59. package/dist/paraglide/messages/pt.js +1 -1
  60. package/dist/paraglide/messages/ru.js +1 -1
  61. package/dist/paraglide/messages/vi.js +1 -1
  62. package/dist/themes/scrollbar.scss +37 -37
  63. package/dist/themes/tera-ui-base.css +58 -22
  64. package/dist/themes/tw-preset.cjs +3 -0
  65. package/dist/themes/tw-preset.d.cts +4 -0
  66. package/package.json +96 -95
  67. package/scripts/add-component-template.js +120 -120
  68. package/scripts/generate-ts-index.js +136 -136
@@ -1,110 +1,110 @@
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
+ <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,56 +1,56 @@
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
+ <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,29 +1,29 @@
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>
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
29
  </div>
@@ -1,21 +1,21 @@
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
+ <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}
@@ -0,0 +1,63 @@
1
+ ---
2
+ import {type DialogPropsAstro, styles} from "./Dialog";
3
+ import IconX from "../icons/IconX.svelte";
4
+ import {Button} from "../button";
5
+ import './dialog.scss'
6
+
7
+ const {
8
+ closeOnClickOutside = true,
9
+ closeButton = true,
10
+ size = 'sm',
11
+ class: className,
12
+ position = 'center',
13
+ padding,
14
+ focusTriggerAfterClose,
15
+ ...props
16
+ }: DialogPropsAstro = Astro.props
17
+
18
+ const {base, dialog: dialogStyle, dialogContainer, header: headerStyle, body, footer: footerStyle} = styles({
19
+ size,
20
+ padding
21
+ })
22
+
23
+ const hasHeaderSlot = !!Astro.slots["header"];
24
+ const hasFooterSlot = !!Astro.slots["footer"];
25
+ ---
26
+
27
+ <dialog class={dialogStyle() + ` ${className}`}
28
+ data-position={position}
29
+ onmousedown={closeOnClickOutside ? 'event.target==this && this.close()' : ''}
30
+ size={size}
31
+ {...props}
32
+ >
33
+ <button class=""></button>
34
+
35
+ {closeButton &&
36
+ <form method="dialog">
37
+ <Button class="absolute right-1 top-1 [&>svg]:opacity-45 [&>svg]:hover:opacity-90 z-10"
38
+ icon={true}
39
+ client:idle
40
+ variant="ghost"
41
+ size="sm">
42
+ <IconX/>
43
+ </Button>
44
+ </form>
45
+ }
46
+
47
+ <div class={"dialog-box " + dialogContainer()}>
48
+ {hasHeaderSlot &&
49
+ <header class={headerStyle()}>
50
+ <slot name="header"/>
51
+ </header>
52
+ }
53
+
54
+ <main class={body()}>
55
+ <slot/>
56
+ </main>
57
+ {hasFooterSlot &&
58
+ <footer class={footerStyle()}>
59
+ <slot name="footer"/>
60
+ </footer>
61
+ }
62
+ </div>
63
+ </dialog>
@@ -190,18 +190,22 @@ export declare const styles: import("tailwind-variants").TVReturnType<{
190
190
  };
191
191
  }>, unknown, unknown, undefined>>;
192
192
  type DialogVariants = VariantProps<typeof styles>;
193
- export interface DialogProps extends DialogVariants {
194
- children?: any;
193
+ type DialogPropsCommon = {
195
194
  class?: string;
196
195
  id?: string;
197
- open?: boolean;
198
196
  closeOnClickOutside?: boolean;
199
197
  closeButton?: boolean;
198
+ position?: 'top' | 'center';
199
+ focusTriggerAfterClose?: boolean;
200
+ padding?: 'none' | undefined;
201
+ };
202
+ export type DialogProps = DialogVariants & DialogPropsCommon & {
203
+ children?: any;
200
204
  header?: any;
201
205
  footer?: any;
202
- position?: 'top' | 'center';
206
+ open?: boolean;
203
207
  staticRender?: boolean;
204
208
  triggerRef?: HTMLElement;
205
- focusTriggerAfterClose?: boolean;
206
- }
209
+ };
210
+ export type DialogPropsAstro = DialogVariants & DialogPropsCommon & {};
207
211
  export {};