@immich/ui 0.58.3 → 0.58.4

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.
@@ -1,16 +1,16 @@
1
1
  <script lang="ts" generics="T extends string">
2
2
  import InternalSelect from '../../internal/Select.svelte';
3
- import type { MultiSelectProps, SelectItem } from '../../types.js';
3
+ import type { MultiSelectProps, SelectOption } from '../../types.js';
4
4
 
5
- let { onChange, onItemChange, values = $bindable([]), ...restProps }: MultiSelectProps<T> = $props();
5
+ let { onChange, onSelect, values = $bindable([]), ...restProps }: MultiSelectProps<T> = $props();
6
6
 
7
7
  const handleChange = (values: T[]) => {
8
8
  onChange?.(values);
9
9
  };
10
10
 
11
- const handleItemChange = (items: SelectItem<T>[]) => {
12
- onItemChange?.(items);
11
+ const handleSelect = (items: SelectOption<T>[]) => {
12
+ onSelect?.(items);
13
13
  };
14
14
  </script>
15
15
 
16
- <InternalSelect multiple bind:values onItemChange={handleItemChange} onChange={handleChange} {...restProps} />
16
+ <InternalSelect multiple bind:values onSelect={handleSelect} onChange={handleChange} {...restProps} />
@@ -1,19 +1,19 @@
1
1
  <script lang="ts" generics="T extends string">
2
2
  import InternalSelect from '../../internal/Select.svelte';
3
- import type { SelectItem, SelectProps } from '../../types.js';
3
+ import type { SelectOption, SelectProps } from '../../types.js';
4
4
 
5
- let { onChange, onItemChange, value = $bindable(), ...restProps }: SelectProps<T> = $props();
5
+ let { onChange, onSelect, value = $bindable(), ...restProps }: SelectProps<T> = $props();
6
6
 
7
- let values = $derived(value ? [value] : []);
7
+ let values = $derived(value === null || value === undefined ? [] : [value]);
8
8
 
9
9
  const handleChange = (values: T[]) => {
10
10
  value = values[0];
11
11
  onChange?.(value);
12
12
  };
13
13
 
14
- const handleItemChange = (items: SelectItem<T>[]) => {
15
- onItemChange?.(items[0]);
14
+ const handleSelect = (items: SelectOption<T>[]) => {
15
+ onSelect?.(items[0]);
16
16
  };
17
17
  </script>
18
18
 
19
- <InternalSelect bind:values onChange={handleChange} onItemChange={handleItemChange} {...restProps} />
19
+ <InternalSelect bind:values onChange={handleChange} onSelect={handleSelect} {...restProps} />
@@ -4,7 +4,7 @@
4
4
  import IconButton from '../components/IconButton/IconButton.svelte';
5
5
  import Input from '../components/Input/Input.svelte';
6
6
  import { zIndex } from '../constants.js';
7
- import type { SelectCommonProps, SelectItem } from '../types.js';
7
+ import type { SelectCommonProps, SelectOption } from '../types.js';
8
8
  import { cleanClass } from '../utilities/internal.js';
9
9
  import { mdiArrowDown, mdiArrowUp, mdiCheck, mdiChevronDown } from '@mdi/js';
10
10
  import { Select } from 'bits-ui';
@@ -13,28 +13,28 @@
13
13
  type Props = {
14
14
  multiple?: boolean;
15
15
  values: T[];
16
- asLabel?: (items: SelectItem<T>[]) => string;
16
+ asLabel?: (items: SelectOption<T>[]) => string;
17
17
  onChange?: (values: T[]) => void;
18
- onItemChange?: (items: SelectItem<T>[]) => void;
18
+ onSelect?: (items: SelectOption<T>[]) => void;
19
19
  } & SelectCommonProps<T>;
20
20
 
21
21
  let {
22
- data,
22
+ options: optionsOrItems,
23
23
  shape,
24
24
  size: initialSize,
25
25
  multiple = false,
26
26
  values = $bindable([]),
27
27
  onChange,
28
- onItemChange,
29
- asLabel = (options: SelectItem<T>[]) => options.map(({ label }) => label).join(', '),
28
+ onSelect: onItemChange,
29
+ asLabel = (options: SelectOption<T>[]) => options.map(({ label }) => label).join(', '),
30
30
  placeholder,
31
31
  class: className,
32
32
  }: Props = $props();
33
33
 
34
- const asOptions = (items: string[] | SelectItem<T>[]) => {
34
+ const asOptions = (items: string[] | SelectOption<T>[]) => {
35
35
  return items.map((item) => {
36
36
  if (typeof item === 'string') {
37
- return { value: item, label: item } as SelectItem<T>;
37
+ return { value: item, label: item } as SelectOption<T>;
38
38
  }
39
39
 
40
40
  const label = item.label ?? item.value;
@@ -45,11 +45,11 @@
45
45
  const context = getFieldContext();
46
46
  const { invalid, disabled, ...labelProps } = $derived(context());
47
47
  const size = $derived(initialSize ?? labelProps.size ?? 'small');
48
- const options = $derived(asOptions(data));
48
+ const options = $derived(asOptions(optionsOrItems));
49
49
 
50
50
  const findOption = (value: string) => options.find((option) => option.value === value);
51
51
  const valuesToOptions = (values: T[]) =>
52
- values.map(findOption).filter((item): item is SelectItem<T> => Boolean(item));
52
+ values.map(findOption).filter((item): item is SelectOption<T> => Boolean(item));
53
53
 
54
54
  const selectedLabel = $derived(asLabel(valuesToOptions(values)));
55
55
 
@@ -75,7 +75,9 @@
75
75
 
76
76
  const onValueChange = (newValues: string[] | string) => {
77
77
  values = (Array.isArray(newValues) ? newValues : [newValues]) as T[];
78
- const items = values.map((value) => findOption(value)).filter((item): item is SelectItem<T> => item !== undefined);
78
+ const items = values
79
+ .map((value) => findOption(value))
80
+ .filter((item): item is SelectOption<T> => item !== undefined);
79
81
 
80
82
  onChange?.(values);
81
83
  onItemChange?.(items);
@@ -1,12 +1,12 @@
1
- import type { SelectCommonProps, SelectItem } from '../types.js';
1
+ import type { SelectCommonProps, SelectOption } from '../types.js';
2
2
  import { Select } from 'bits-ui';
3
3
  declare function $$render<T extends string>(): {
4
4
  props: {
5
5
  multiple?: boolean;
6
6
  values: T[];
7
- asLabel?: (items: SelectItem<T>[]) => string;
7
+ asLabel?: (items: SelectOption<T>[]) => string;
8
8
  onChange?: (values: T[]) => void;
9
- onItemChange?: (items: SelectItem<T>[]) => void;
9
+ onSelect?: (items: SelectOption<T>[]) => void;
10
10
  } & SelectCommonProps<T>;
11
11
  exports: {};
12
12
  bindings: "values";
package/dist/types.d.ts CHANGED
@@ -152,13 +152,13 @@ export type TextareaProps = {
152
152
  shape?: Shape;
153
153
  grow?: boolean;
154
154
  } & HTMLTextareaAttributes;
155
- export type SelectItem<T extends string = string> = {
155
+ export type SelectOption<T extends string = string> = {
156
156
  label?: string;
157
157
  value: T;
158
158
  disabled?: boolean;
159
159
  };
160
160
  export type SelectCommonProps<T extends string> = {
161
- data: string[] | SelectItem<T>[];
161
+ options: string[] | SelectOption<T>[];
162
162
  size?: Size;
163
163
  shape?: Shape;
164
164
  placeholder?: string;
@@ -167,12 +167,12 @@ export type SelectCommonProps<T extends string> = {
167
167
  export type SelectProps<T extends string> = SelectCommonProps<T> & {
168
168
  value?: T;
169
169
  onChange?: (value: T) => void;
170
- onItemChange?: (item: SelectItem<T>) => void;
170
+ onSelect?: (options: SelectOption<T>) => void;
171
171
  };
172
172
  export type MultiSelectProps<T extends string> = SelectCommonProps<T> & {
173
173
  values?: T[];
174
174
  onChange?: (values: T[]) => void;
175
- onItemChange?: (items: SelectItem<T>[]) => void;
175
+ onSelect?: (options: SelectOption<T>[]) => void;
176
176
  };
177
177
  export type ToastId = {
178
178
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@immich/ui",
3
- "version": "0.58.3",
3
+ "version": "0.58.4",
4
4
  "license": "GNU Affero General Public License version 3",
5
5
  "repository": {
6
6
  "type": "git",