@immich/ui 0.57.1 → 0.57.2
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,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import Text from '../../internal/Text.svelte';
|
|
2
3
|
import type { FontWeight, HeadingColor, HeadingSize, HeadingTag, TextVariant } from '../../types.js';
|
|
3
4
|
import { cleanClass } from '../../utilities/internal.js';
|
|
4
|
-
import Text from '../../internal/Text.svelte';
|
|
5
5
|
import type { Snippet } from 'svelte';
|
|
6
6
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
7
7
|
import { tv } from 'tailwind-variants';
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
base: 'leading-none tracking-tight',
|
|
27
27
|
variants: {
|
|
28
28
|
size: {
|
|
29
|
-
tiny: 'text-base',
|
|
30
|
-
small: 'text-lg',
|
|
31
|
-
medium: 'text-xl',
|
|
32
|
-
large: 'text-3xl',
|
|
33
|
-
giant: 'text-5xl',
|
|
34
|
-
title: 'text-
|
|
29
|
+
tiny: 'text-sm md:text-base',
|
|
30
|
+
small: 'text-lg md:text-xl',
|
|
31
|
+
medium: 'text-xl md:text-2xl',
|
|
32
|
+
large: 'text-3xl md:text-4xl',
|
|
33
|
+
giant: 'text-4xl md:text-5xl',
|
|
34
|
+
title: 'text-5xl md:text-6xl',
|
|
35
35
|
},
|
|
36
36
|
},
|
|
37
37
|
});
|
|
@@ -49,11 +49,15 @@
|
|
|
49
49
|
true: 'focus-within:ring-danger dark:focus-within:ring-danger dark:ring-danger-300 ring-danger-300 ring-1',
|
|
50
50
|
false: '',
|
|
51
51
|
},
|
|
52
|
+
disabled: {
|
|
53
|
+
true: 'bg-light-300 dark:bg-gray-900',
|
|
54
|
+
false: '',
|
|
55
|
+
},
|
|
52
56
|
},
|
|
53
57
|
});
|
|
54
58
|
|
|
55
59
|
const inputStyles = tv({
|
|
56
|
-
base: cleanClass(styleVariants.inputCommon, 'flex-1 py-2.5'),
|
|
60
|
+
base: cleanClass(styleVariants.inputCommon, 'w-full flex-1 py-2.5'),
|
|
57
61
|
variants: {
|
|
58
62
|
textSize: styleVariants.textSize,
|
|
59
63
|
leadingPadding: {
|
|
@@ -89,7 +93,7 @@
|
|
|
89
93
|
const descriptionId = $derived(description ? `description-${id}` : undefined);
|
|
90
94
|
</script>
|
|
91
95
|
|
|
92
|
-
<div class="flex w-full flex-col gap-1"
|
|
96
|
+
<div class="flex w-full flex-col gap-1">
|
|
93
97
|
{#if label}
|
|
94
98
|
<Label id={labelId} for={inputId} {label} requiredIndicator={required === 'indicator'} {...labelProps} {size} />
|
|
95
99
|
{/if}
|
|
@@ -99,8 +103,10 @@
|
|
|
99
103
|
{/if}
|
|
100
104
|
|
|
101
105
|
<div
|
|
106
|
+
bind:this={containerRef}
|
|
102
107
|
class={cleanClass(
|
|
103
108
|
containerStyles({
|
|
109
|
+
disabled,
|
|
104
110
|
shape,
|
|
105
111
|
roundedSize: shape === 'semi-round' ? size : undefined,
|
|
106
112
|
invalid,
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { getFieldContext } from '../common/context.svelte.js';
|
|
3
|
-
import Field from '../components/Field/Field.svelte';
|
|
4
3
|
import Icon from '../components/Icon/Icon.svelte';
|
|
5
4
|
import IconButton from '../components/IconButton/IconButton.svelte';
|
|
6
5
|
import Input from '../components/Input/Input.svelte';
|
|
7
|
-
import Label from '../components/Label/Label.svelte';
|
|
8
6
|
import { zIndex } from '../constants.js';
|
|
9
7
|
import type { SelectCommonProps, SelectItem } from '../types.js';
|
|
10
|
-
import { cleanClass
|
|
11
|
-
import { mdiArrowDown, mdiArrowUp, mdiCheck,
|
|
8
|
+
import { cleanClass } from '../utilities/internal.js';
|
|
9
|
+
import { mdiArrowDown, mdiArrowUp, mdiCheck, mdiChevronDown } from '@mdi/js';
|
|
12
10
|
import { Select } from 'bits-ui';
|
|
11
|
+
import { tv } from 'tailwind-variants';
|
|
13
12
|
|
|
14
13
|
type T = SelectItem;
|
|
15
14
|
|
|
@@ -46,16 +45,22 @@
|
|
|
46
45
|
const options = $derived(asOptions(data));
|
|
47
46
|
|
|
48
47
|
const context = getFieldContext();
|
|
49
|
-
const {
|
|
48
|
+
const { invalid, disabled, ...labelProps } = $derived(context());
|
|
50
49
|
const size = $derived(initialSize ?? labelProps.size ?? 'small');
|
|
51
50
|
|
|
52
|
-
const id = generateId();
|
|
53
|
-
const inputId = `input-${id}`;
|
|
54
|
-
const labelId = `label-${id}`;
|
|
55
|
-
|
|
56
51
|
const selectedLabel = $derived(asLabel(values));
|
|
57
52
|
|
|
58
|
-
|
|
53
|
+
const triggerStyles = tv({
|
|
54
|
+
base: 'w-full gap-1 rounded-lg py-0 text-start focus-visible:outline-none',
|
|
55
|
+
variants: {
|
|
56
|
+
invalid: {
|
|
57
|
+
true: 'border-danger border',
|
|
58
|
+
false: '',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
let inputRef = $state<HTMLInputElement | null>(null);
|
|
59
64
|
let contentRef = $state<HTMLElement | null>(null);
|
|
60
65
|
let ref = $state<HTMLElement | null>(null);
|
|
61
66
|
|
|
@@ -79,48 +84,37 @@
|
|
|
79
84
|
</script>
|
|
80
85
|
|
|
81
86
|
<div class={cleanClass('flex flex-col gap-1', className)} bind:this={ref}>
|
|
82
|
-
{#if label}
|
|
83
|
-
<Label id={labelId} for={inputId} {label} requiredIndicator={required === 'indicator'} {...labelProps} {size} />
|
|
84
|
-
{/if}
|
|
85
|
-
|
|
86
87
|
<Select.Root type={multiple ? 'multiple' : 'single'} bind:value={internalValue as never} {onValueChange}>
|
|
87
|
-
<Select.Trigger
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
class="m-1"
|
|
111
|
-
icon={mdiUnfoldMoreHorizontal}
|
|
112
|
-
{disabled}
|
|
113
|
-
aria-label="Expand"
|
|
114
|
-
/>
|
|
115
|
-
{/snippet}
|
|
116
|
-
</Input>
|
|
117
|
-
</Field>
|
|
88
|
+
<Select.Trigger {disabled} class={cleanClass(triggerStyles({ invalid: false }))} aria-label={placeholder}>
|
|
89
|
+
<Input
|
|
90
|
+
bind:containerRef={inputRef}
|
|
91
|
+
{size}
|
|
92
|
+
{shape}
|
|
93
|
+
{placeholder}
|
|
94
|
+
value={selectedLabel}
|
|
95
|
+
readonly
|
|
96
|
+
class={cleanClass('text-start', invalid && 'border-danger')}
|
|
97
|
+
>
|
|
98
|
+
{#snippet trailingIcon()}
|
|
99
|
+
<IconButton
|
|
100
|
+
variant="ghost"
|
|
101
|
+
shape="round"
|
|
102
|
+
color="secondary"
|
|
103
|
+
size="tiny"
|
|
104
|
+
class="m-1"
|
|
105
|
+
icon={mdiChevronDown}
|
|
106
|
+
{disabled}
|
|
107
|
+
aria-label="Expand"
|
|
108
|
+
/>
|
|
109
|
+
{/snippet}
|
|
110
|
+
</Input>
|
|
118
111
|
</Select.Trigger>
|
|
119
112
|
<Select.Portal>
|
|
120
113
|
<Select.Content
|
|
121
114
|
bind:ref={contentRef}
|
|
122
|
-
class="bg-
|
|
123
|
-
|
|
115
|
+
class="text-dark dark:bg-primary-100 bg-light-100 max-h-96 rounded-xl border py-3 outline-none select-none {zIndex.SelectDropdown}"
|
|
116
|
+
customAnchor={inputRef}
|
|
117
|
+
sideOffset={4}
|
|
124
118
|
>
|
|
125
119
|
<Select.ScrollUpButton class="flex w-full items-center justify-center">
|
|
126
120
|
<Icon icon={mdiArrowUp} />
|
|
@@ -129,7 +123,7 @@
|
|
|
129
123
|
{#each options as { value, label, disabled }, i (i + value)}
|
|
130
124
|
<Select.Item
|
|
131
125
|
class={cleanClass(
|
|
132
|
-
'hover:bg-
|
|
126
|
+
'hover:bg-light-200 hover:dark:bg-primary-200 data-selected:bg-light-200 dark:data-selected:bg-primary-200 flex h-10 w-full items-center px-5 py-3 text-sm duration-75 outline-none select-none data-disabled:opacity-50',
|
|
133
127
|
disabled ? 'cursor-not-allowed' : 'cursor-pointer',
|
|
134
128
|
)}
|
|
135
129
|
{value}
|