@svadmin/ui 0.74.0 → 0.75.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.
@@ -575,15 +575,15 @@
575
575
  {#key renderedRoute + (renderedParams['resource'] ?? '') + (renderedParams['id'] ?? '') + (renderedParams['variant'] ?? '') + (renderedParams['columns'] ?? '')}
576
576
  <div class="svadmin-page-enter">
577
577
  {#if renderedRoute === '/public-profile'}
578
- <LazyPage loader={loadPublicProfilePage} props={{ variant: 'default', initialTab: 'projects' }} />
578
+ <LazyPage loader={loadPublicProfilePage} props={{ variant: 'default', initialTab: 'projects' } as const} />
579
579
  {:else if renderedRoute === '/public-profile/projects/:columns'}
580
- <LazyPage loader={loadPublicProfilePage} props={{ variant: 'default', initialTab: 'projects', columns: renderedParams['columns']?.includes('3') ? 3 : 2 }} />
580
+ <LazyPage loader={loadPublicProfilePage} props={{ variant: 'default', initialTab: 'projects', columns: renderedParams['columns']?.includes('3') ? 3 : 2 } as const} />
581
581
  {:else if renderedRoute === '/public-profile/activity'}
582
- <LazyPage loader={loadPublicProfilePage} props={{ variant: 'default', initialTab: 'activity' }} />
582
+ <LazyPage loader={loadPublicProfilePage} props={{ variant: 'default', initialTab: 'activity' } as const} />
583
583
  {:else if renderedRoute === '/public-profile/teams'}
584
- <LazyPage loader={loadPublicProfilePage} props={{ variant: 'default', initialTab: 'teams' }} />
584
+ <LazyPage loader={loadPublicProfilePage} props={{ variant: 'default', initialTab: 'teams' } as const} />
585
585
  {:else if renderedRoute === '/public-profile/profiles/:variant'}
586
- <LazyPage loader={loadPublicProfilePage} props={{ variant: (renderedParams['variant'] === 'company' || renderedParams['variant'] === 'gamer' || renderedParams['variant'] === 'default' ? renderedParams['variant'] : 'default') as 'company' | 'gamer' | 'default', showSections: true }} />
586
+ <LazyPage loader={loadPublicProfilePage} props={{ variant: (renderedParams['variant'] === 'company' || renderedParams['variant'] === 'gamer' || renderedParams['variant'] === 'default' ? renderedParams['variant'] : 'default') as 'company' | 'gamer' | 'default', showSections: true } as const} />
587
587
  {:else if renderedRoute === '/account/get-started' || renderedRoute === '/account/home/get-started'}
588
588
  <LazyPage loader={loadGetStartedPage} props={{}} />
589
589
  {:else if renderedRoute === '/account/home/user-profile'}
@@ -4,7 +4,7 @@
4
4
 
5
5
  export type DatePickerProps = Omit<ComponentProps<typeof DateTimeInput>, 'mode'>;
6
6
 
7
- let props: DatePickerProps = $props();
7
+ let { value = $bindable(null), ...props }: DatePickerProps = $props();
8
8
  </script>
9
9
 
10
- <DateTimeInput {...props} mode="date" />
10
+ <DateTimeInput {...props} bind:value mode="date" />
@@ -1,6 +1,6 @@
1
1
  import type { ComponentProps } from 'svelte';
2
2
  import DateTimeInput from './DateTimeInput.svelte';
3
3
  export type DatePickerProps = Omit<ComponentProps<typeof DateTimeInput>, 'mode'>;
4
- declare const DatePicker: import("svelte").Component<DatePickerProps, {}, "">;
4
+ declare const DatePicker: import("svelte").Component<DatePickerProps, {}, "value">;
5
5
  type DatePicker = ReturnType<typeof DatePicker>;
6
6
  export default DatePicker;
@@ -4,7 +4,7 @@
4
4
 
5
5
  export type DateRangePickerProps = Omit<ComponentProps<typeof DateRangeInput>, 'mode'>;
6
6
 
7
- let props: DateRangePickerProps = $props();
7
+ let { value = $bindable({ start: null, end: null }), ...props }: DateRangePickerProps = $props();
8
8
  </script>
9
9
 
10
- <DateRangeInput {...props} mode="date" />
10
+ <DateRangeInput {...props} bind:value mode="date" />
@@ -1,6 +1,6 @@
1
1
  import type { ComponentProps } from 'svelte';
2
2
  import DateRangeInput from './DateRangeInput.svelte';
3
3
  export type DateRangePickerProps = Omit<ComponentProps<typeof DateRangeInput>, 'mode'>;
4
- declare const DateRangePicker: import("svelte").Component<DateRangePickerProps, {}, "">;
4
+ declare const DateRangePicker: import("svelte").Component<DateRangePickerProps, {}, "value">;
5
5
  type DateRangePicker = ReturnType<typeof DateRangePicker>;
6
6
  export default DateRangePicker;
@@ -11,24 +11,24 @@
11
11
  interface Props {
12
12
  value?: string | null;
13
13
  mode?: DateTimeInputMode;
14
- min?: string;
15
- max?: string;
16
- minInstant?: string;
17
- maxInstant?: string;
18
- step?: number;
19
- disabledDate?: (date: string) => boolean;
20
- id?: string;
21
- name?: string;
22
- disabled?: boolean;
23
- required?: boolean;
24
- invalid?: boolean;
25
- describedby?: string;
26
- ariaLabel?: string;
27
- class?: string;
28
- onchange?: (value: string | null) => void;
29
- timeZone?: string;
30
- valueMode?: DateTimeValueMode;
31
- disambiguation?: DateTimeDisambiguation;
14
+ min?: string | undefined;
15
+ max?: string | undefined;
16
+ minInstant?: string | undefined;
17
+ maxInstant?: string | undefined;
18
+ step?: number | undefined;
19
+ disabledDate?: ((date: string) => boolean) | undefined;
20
+ id?: string | undefined;
21
+ name?: string | undefined;
22
+ disabled?: boolean | undefined;
23
+ required?: boolean | undefined;
24
+ invalid?: boolean | undefined;
25
+ describedby?: string | undefined;
26
+ ariaLabel?: string | undefined;
27
+ class?: string | undefined;
28
+ onchange?: ((value: string | null) => void) | undefined;
29
+ timeZone?: string | undefined;
30
+ valueMode?: DateTimeValueMode | undefined;
31
+ disambiguation?: DateTimeDisambiguation | undefined;
32
32
  }
33
33
 
34
34
  let {
@@ -3,24 +3,24 @@ export type DateTimeInputMode = 'date' | 'time' | 'datetime';
3
3
  interface Props {
4
4
  value?: string | null;
5
5
  mode?: DateTimeInputMode;
6
- min?: string;
7
- max?: string;
8
- minInstant?: string;
9
- maxInstant?: string;
10
- step?: number;
11
- disabledDate?: (date: string) => boolean;
12
- id?: string;
13
- name?: string;
14
- disabled?: boolean;
15
- required?: boolean;
16
- invalid?: boolean;
17
- describedby?: string;
18
- ariaLabel?: string;
19
- class?: string;
20
- onchange?: (value: string | null) => void;
21
- timeZone?: string;
22
- valueMode?: DateTimeValueMode;
23
- disambiguation?: DateTimeDisambiguation;
6
+ min?: string | undefined;
7
+ max?: string | undefined;
8
+ minInstant?: string | undefined;
9
+ maxInstant?: string | undefined;
10
+ step?: number | undefined;
11
+ disabledDate?: ((date: string) => boolean) | undefined;
12
+ id?: string | undefined;
13
+ name?: string | undefined;
14
+ disabled?: boolean | undefined;
15
+ required?: boolean | undefined;
16
+ invalid?: boolean | undefined;
17
+ describedby?: string | undefined;
18
+ ariaLabel?: string | undefined;
19
+ class?: string | undefined;
20
+ onchange?: ((value: string | null) => void) | undefined;
21
+ timeZone?: string | undefined;
22
+ valueMode?: DateTimeValueMode | undefined;
23
+ disambiguation?: DateTimeDisambiguation | undefined;
24
24
  }
25
25
  declare const DateTimeInput: import("svelte").Component<Props, {}, "value">;
26
26
  type DateTimeInput = ReturnType<typeof DateTimeInput>;
@@ -4,7 +4,7 @@
4
4
 
5
5
  export type DateTimePickerProps = Omit<ComponentProps<typeof DateTimeInput>, 'mode'>;
6
6
 
7
- let props: DateTimePickerProps = $props();
7
+ let { value = $bindable(null), ...props }: DateTimePickerProps = $props();
8
8
  </script>
9
9
 
10
- <DateTimeInput {...props} mode="datetime" />
10
+ <DateTimeInput {...props} bind:value mode="datetime" />
@@ -1,6 +1,6 @@
1
1
  import type { ComponentProps } from 'svelte';
2
2
  import DateTimeInput from './DateTimeInput.svelte';
3
3
  export type DateTimePickerProps = Omit<ComponentProps<typeof DateTimeInput>, 'mode'>;
4
- declare const DateTimePicker: import("svelte").Component<DateTimePickerProps, {}, "">;
4
+ declare const DateTimePicker: import("svelte").Component<DateTimePickerProps, {}, "value">;
5
5
  type DateTimePicker = ReturnType<typeof DateTimePicker>;
6
6
  export default DateTimePicker;
@@ -38,6 +38,7 @@
38
38
  import { cn } from '../utils.js';
39
39
  import { numericInputValue } from '../numeric-input.js';
40
40
 
41
+ type FieldOption = NonNullable<FieldDefinition['options']>[number];
41
42
  const i18n = useTranslation();
42
43
 
43
44
  let { field, value, onchange, disabled, invalid = false, errorId, density = 'comfortable', children } = $props<{
@@ -59,7 +60,6 @@
59
60
  const boolVal = $derived((value as boolean) ?? false);
60
61
  const tagsVal = $derived((value as string[]) ?? []);
61
62
  const multiVal = $derived((value as (string | number)[]) ?? []);
62
- type FieldOption = NonNullable<FieldDefinition['options']>[number];
63
63
  const selectToken = $derived.by(() => {
64
64
  const index = field.options?.findIndex((option: FieldOption) => option.value === value) ?? -1;
65
65
  return index < 0 ? '' : `option:${index}`;
@@ -1,11 +1,11 @@
1
1
  <script module lang="ts">
2
2
  import type { Component } from 'svelte';
3
3
 
4
+ export type LazyPageRenderable = Component<never>;
4
5
  export type LazyPageModule = {
5
- default: Component<never>;
6
+ default: LazyPageRenderable;
6
7
  };
7
8
 
8
- export type LazyPageRenderable = Component<Record<string, unknown>>;
9
9
  export type LazyPageLoader = () => Promise<LazyPageModule>;
10
10
 
11
11
  const pagePromises = new WeakMap<object, Promise<unknown>>();
@@ -38,7 +38,7 @@
38
38
  <span class="svadmin-u-fc7473ca09eb svadmin-u-bfa603190748">Loading...</span>
39
39
  </div>
40
40
  {:then pageModule}
41
- {@const Page = pageModule.default as unknown as LazyPageRenderable}
41
+ {@const Page = pageModule.default as unknown as Component<Record<string, unknown>>}
42
42
  <Page {...props} />
43
43
  {:catch}
44
44
  <div class="svadmin-u-60fbb7713999 svadmin-u-8a7a926578c8 svadmin-u-3960ffc248d9 svadmin-u-86843cf1e227" role="alert">
@@ -1,8 +1,8 @@
1
1
  import type { Component } from 'svelte';
2
+ export type LazyPageRenderable = Component<never>;
2
3
  export type LazyPageModule = {
3
- default: Component<never>;
4
+ default: LazyPageRenderable;
4
5
  };
5
- export type LazyPageRenderable = Component<Record<string, unknown>>;
6
6
  export type LazyPageLoader = () => Promise<LazyPageModule>;
7
7
  export declare function loadLazyPage(loader: LazyPageLoader): Promise<LazyPageModule>;
8
8
  type $$ComponentProps = {
@@ -1,10 +1,10 @@
1
1
  <script lang="ts">
2
- /* eslint-disable @typescript-eslint/no-explicit-any */
3
2
  import { Input } from './ui/input/index.js';
4
3
  import TooltipButton from './TooltipButton.svelte';
5
4
  import { Label } from './ui/label/index.js';
6
5
  import { Lock, Eye, EyeOff } from '@lucide/svelte';
7
6
  import { useTranslation } from '@svadmin/core/i18n';
7
+ import type { FullAutoFill } from 'svelte/elements';
8
8
 
9
9
  const i18n = useTranslation();
10
10
 
@@ -13,7 +13,7 @@
13
13
  label: string;
14
14
  value: string;
15
15
  placeholder?: string;
16
- autocomplete?: string;
16
+ autocomplete?: FullAutoFill;
17
17
  showStrength?: boolean;
18
18
  disabled?: boolean;
19
19
  class?: string;
@@ -67,7 +67,7 @@
67
67
  {placeholder}
68
68
  bind:value
69
69
  class="svadmin-u-9e83b2412bc9 svadmin-u-1b1df78e4d0a"
70
- autocomplete={autocomplete as any}
70
+ {autocomplete}
71
71
  {disabled}
72
72
  />
73
73
  <TooltipButton
@@ -1,9 +1,10 @@
1
+ import type { FullAutoFill } from 'svelte/elements';
1
2
  interface Props {
2
3
  id: string;
3
4
  label: string;
4
5
  value: string;
5
6
  placeholder?: string;
6
- autocomplete?: string;
7
+ autocomplete?: FullAutoFill;
7
8
  showStrength?: boolean;
8
9
  disabled?: boolean;
9
10
  class?: string;
@@ -78,8 +78,12 @@
78
78
  emptyLanesText = 'No grouped records yet.',
79
79
  highlightsLabel = 'Focus queue',
80
80
  workspaceStyle = 'operations',
81
- tableProps = {},
81
+ tableProps: rawTableProps = {},
82
82
  }: Props = $props();
83
+ const tableProps = $derived({
84
+ ...rawTableProps,
85
+ ...(rendering === undefined ? {} : { rendering }),
86
+ });
83
87
  const navigation = useNavigation();
84
88
  const context = captureAdminContext();
85
89
  const resource = $derived(context.getResource(resourceName));
@@ -4,7 +4,7 @@
4
4
 
5
5
  export type TimePickerProps = Omit<ComponentProps<typeof DateTimeInput>, 'mode'>;
6
6
 
7
- let props: TimePickerProps = $props();
7
+ let { value = $bindable(null), ...props }: TimePickerProps = $props();
8
8
  </script>
9
9
 
10
- <DateTimeInput {...props} mode="time" />
10
+ <DateTimeInput {...props} bind:value mode="time" />
@@ -1,6 +1,6 @@
1
1
  import type { ComponentProps } from 'svelte';
2
2
  import DateTimeInput from './DateTimeInput.svelte';
3
3
  export type TimePickerProps = Omit<ComponentProps<typeof DateTimeInput>, 'mode'>;
4
- declare const TimePicker: import("svelte").Component<TimePickerProps, {}, "">;
4
+ declare const TimePicker: import("svelte").Component<TimePickerProps, {}, "value">;
5
5
  type TimePicker = ReturnType<typeof TimePicker>;
6
6
  export default TimePicker;
@@ -1,5 +1,4 @@
1
1
  <script lang="ts">
2
- /* eslint-disable @typescript-eslint/no-explicit-any */
3
2
  import * as Tooltip from './ui/tooltip/index.js';
4
3
  import { Button } from './ui/button/index.js';
5
4
  import type { Snippet } from 'svelte';
@@ -43,8 +42,8 @@
43
42
  onclick?.(event);
44
43
  }
45
44
 
46
- function mergeButtonProps(primitiveProps: Record<string, any>) {
47
- const merged: Record<string, any> = { ...primitiveProps, ...restProps };
45
+ function mergeButtonProps(primitiveProps: Record<string, unknown>) {
46
+ const merged: Record<string, unknown> = { ...primitiveProps, ...restProps };
48
47
  for (const [key, userHandler] of Object.entries(restProps)) {
49
48
  const primitiveHandler = primitiveProps[key];
50
49
  if (!key.startsWith('on') || typeof userHandler !== 'function' || typeof primitiveHandler !== 'function') continue;
@@ -61,7 +60,7 @@
61
60
  <Tooltip.Trigger aria-describedby={restProps['aria-describedby']}>
62
61
  {#snippet child({ props })}
63
62
  {@const primitiveOnclick = props['onclick'] as ((event: MouseEvent) => void) | undefined}
64
- {@const buttonProps = { ...mergeButtonProps(props), href, target, rel, variant, size, type, class: className, 'aria-label': restProps['aria-label'] ?? tooltip, 'aria-describedby': props['aria-describedby'], onclick: (event: MouseEvent) => handleClick(event, primitiveOnclick), disabled, tabindex } as any}
63
+ {@const buttonProps = { ...mergeButtonProps(props), href, target, rel, variant, size, type, class: className, 'aria-label': typeof restProps['aria-label'] === 'string' ? restProps['aria-label'] : tooltip, 'aria-describedby': typeof props['aria-describedby'] === 'string' ? props['aria-describedby'] : undefined, onclick: (event: MouseEvent) => handleClick(event, primitiveOnclick), disabled, tabindex }}
65
64
  <Button {...buttonProps}>
66
65
  {@render children()}
67
66
  </Button>
@@ -12,6 +12,15 @@
12
12
  interface DomPurifyLike {
13
13
  sanitize(source: string | Node, config?: Record<string, unknown>): string;
14
14
  }
15
+ interface DomPurifyModule {
16
+ default?: DomPurifyLike;
17
+ sanitize?: DomPurifyLike["sanitize"];
18
+ }
19
+
20
+ function isDomPurifyModule(value: unknown): value is DomPurifyModule {
21
+ return typeof value === 'object' && value !== null;
22
+ }
23
+
15
24
  let DOMPurify: DomPurifyLike | null = $state(null);
16
25
 
17
26
  onMount(() => {
@@ -19,12 +28,12 @@
19
28
  import("isomorphic-dompurify")
20
29
  .then((pkg) => {
21
30
  if (!cancelled) {
22
- const mod = pkg as unknown as { default?: DomPurifyLike; sanitize?: DomPurifyLike["sanitize"] };
31
+ if (!isDomPurifyModule(pkg)) return;
23
32
  const loaded: DomPurifyLike | undefined =
24
- mod.default && typeof mod.default.sanitize === "function"
25
- ? mod.default
26
- : typeof mod.sanitize === "function"
27
- ? (mod as DomPurifyLike)
33
+ pkg.default && typeof pkg.default.sanitize === "function"
34
+ ? pkg.default
35
+ : typeof pkg.sanitize === "function"
36
+ ? { sanitize: pkg.sanitize }
28
37
  : undefined;
29
38
  if (loaded) {
30
39
  DOMPurify = loaded;
@@ -29,7 +29,7 @@
29
29
  <h2 id="fields-heading">Fields and selection / 字段与选择</h2>
30
30
  <div class="svadmin-design-system-showcase__grid">
31
31
  <Input aria-label="Default input" placeholder="Default" />
32
- <Input aria-label="Compact input" size="compact" placeholder="Compact" />
32
+ <Input aria-label="Compact input" data-size="compact" placeholder="Compact" />
33
33
  <Select aria-label="Status" size="compact" placeholder="Choose a status" />
34
34
  <label class="svadmin-design-system-showcase__checkbox">
35
35
  <Checkbox aria-label="Enabled" size="compact" />
@@ -1,5 +1,4 @@
1
1
  <script lang="ts">
2
- /* eslint-disable @typescript-eslint/no-explicit-any */
3
2
  import { cn, type WithElementRef } from "../../../utils.js";
4
3
  import type { HTMLButtonAttributes } from "svelte/elements";
5
4
  import { getContext } from "svelte";
@@ -19,7 +18,7 @@
19
18
  function handleClick(e: MouseEvent) {
20
19
  e.stopPropagation();
21
20
  toggle?.();
22
- restProps.onclick?.(e as any);
21
+ restProps.onclick?.(e as Parameters<NonNullable<typeof restProps.onclick>>[0]);
23
22
  }
24
23
  </script>
25
24
 
@@ -1,4 +1,5 @@
1
1
  import type { Component } from 'svelte';
2
+ type EditorProps = Record<string, unknown>;
2
3
  /**
3
4
  * Register a global Rich Text Editor component.
4
5
  * This decouples @svadmin/ui from @svadmin/editor, making the editor completely optional.
@@ -11,5 +12,6 @@ import type { Component } from 'svelte';
11
12
  * setRichTextEditor(Editor);
12
13
  * ```
13
14
  */
14
- export declare function setRichTextEditor(editorComponent: Component<any>): void;
15
- export declare function getRichTextEditor(): Component<any> | undefined;
15
+ export declare function setRichTextEditor(editorComponent: Component<EditorProps>): void;
16
+ export declare function getRichTextEditor(): Component<EditorProps> | undefined;
17
+ export {};