@insymetri/styleguide 0.1.25 → 0.1.27
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.
- package/dist/IICombobox/IICombobox.svelte +18 -1
- package/dist/IICombobox/IICombobox.svelte.d.ts +1 -0
- package/dist/IIDateInput/IIDateInput.svelte +1 -1
- package/dist/IIDropdownInput/IIDropdownInput.svelte +17 -2
- package/dist/IIDropdownInput/IIDropdownInput.svelte.d.ts +1 -0
- package/package.json +1 -1
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
emptyContent?: Snippet
|
|
37
37
|
// Grouped items (alternative to flat items)
|
|
38
38
|
groups?: Group<T>[]
|
|
39
|
+
openOnFocus?: boolean
|
|
39
40
|
// CSS classes
|
|
40
41
|
class?: string
|
|
41
42
|
contentClass?: string
|
|
@@ -54,6 +55,7 @@
|
|
|
54
55
|
renderItem,
|
|
55
56
|
emptyContent,
|
|
56
57
|
groups,
|
|
58
|
+
openOnFocus = false,
|
|
57
59
|
class: className,
|
|
58
60
|
contentClass,
|
|
59
61
|
}: Props<T> = $props()
|
|
@@ -67,6 +69,13 @@
|
|
|
67
69
|
mobile: 'h-48 rounded-control text-default',
|
|
68
70
|
} as const
|
|
69
71
|
|
|
72
|
+
const itemDensityClasses = {
|
|
73
|
+
compact: 'py-4 text-tiny',
|
|
74
|
+
default: 'py-6 text-small',
|
|
75
|
+
comfortable: 'py-8 text-small',
|
|
76
|
+
mobile: 'py-10 text-default',
|
|
77
|
+
} as const
|
|
78
|
+
|
|
70
79
|
let inputValue = $state('')
|
|
71
80
|
let open = $state(false)
|
|
72
81
|
|
|
@@ -128,6 +137,10 @@
|
|
|
128
137
|
inputValue = e.currentTarget.value
|
|
129
138
|
}
|
|
130
139
|
|
|
140
|
+
function handleFocus() {
|
|
141
|
+
open = true
|
|
142
|
+
}
|
|
143
|
+
|
|
131
144
|
// Check if item looks like a SimpleItem for default rendering
|
|
132
145
|
function isSimpleItem(item: T): item is T & SimpleItem {
|
|
133
146
|
return typeof item === 'object' && item !== null && 'label' in item && 'value' in item
|
|
@@ -139,7 +152,10 @@
|
|
|
139
152
|
value={getItemValue(item)}
|
|
140
153
|
label={isSimpleItem(item) ? item.label : getItemValue(item)}
|
|
141
154
|
disabled={getItemDisabled?.(item) ?? false}
|
|
142
|
-
class=
|
|
155
|
+
class={cn(
|
|
156
|
+
'flex items-center gap-8 px-12 text-dropdown-item rounded-6 cursor-default transition-all duration-fast outline-none hover:bg-dropdown-item-hover data-[highlighted]:bg-dropdown-item-hover data-[selected]:bg-dropdown-item-selected data-[disabled]:opacity-50 data-[disabled]:cursor-not-allowed motion-reduce:transition-none',
|
|
157
|
+
itemDensityClasses[density.value]
|
|
158
|
+
)}
|
|
143
159
|
>
|
|
144
160
|
{#snippet children({selected})}
|
|
145
161
|
{#if renderItem}
|
|
@@ -172,6 +188,7 @@
|
|
|
172
188
|
{placeholder}
|
|
173
189
|
{disabled}
|
|
174
190
|
oninput={handleInput}
|
|
191
|
+
onfocus={openOnFocus ? handleFocus : undefined}
|
|
175
192
|
class={cn(
|
|
176
193
|
'w-full box-border py-5 px-12 text-input-text bg-input-bg border border-input-border transition-all duration-fast outline-none placeholder:text-input-placeholder hover:border-input-border-hover focus:border-input-border-hover disabled:opacity-50 disabled:cursor-not-allowed disabled:bg-input-bg-disabled motion-reduce:transition-none',
|
|
177
194
|
densityClasses[density.value]
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
<div class={cn('flex flex-col gap-4', className)}>
|
|
44
44
|
<DatePicker.Root bind:value {onValueChange} {disabled}>
|
|
45
45
|
{#if label}
|
|
46
|
-
<DatePicker.Label class="text-small-emphasis text-
|
|
46
|
+
<DatePicker.Label class="text-small-emphasis text-secondary">{label}</DatePicker.Label>
|
|
47
47
|
{/if}
|
|
48
48
|
<DatePicker.Input
|
|
49
49
|
class={cn(
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
items: Item[]
|
|
17
17
|
value?: string | undefined
|
|
18
18
|
placeholder?: string
|
|
19
|
+
label?: string
|
|
19
20
|
disabled?: boolean
|
|
20
21
|
onSelect?: (value: string) => void
|
|
21
22
|
matchTriggerWidth?: boolean
|
|
@@ -28,6 +29,7 @@
|
|
|
28
29
|
items,
|
|
29
30
|
value = $bindable(),
|
|
30
31
|
placeholder = 'Select...',
|
|
32
|
+
label,
|
|
31
33
|
disabled = false,
|
|
32
34
|
onSelect,
|
|
33
35
|
matchTriggerWidth = false,
|
|
@@ -45,6 +47,13 @@
|
|
|
45
47
|
mobile: 'h-48 rounded-control text-default',
|
|
46
48
|
} as const
|
|
47
49
|
|
|
50
|
+
const itemDensityClasses = {
|
|
51
|
+
compact: 'py-4 text-tiny',
|
|
52
|
+
default: 'py-6 text-small',
|
|
53
|
+
comfortable: 'py-8 text-small',
|
|
54
|
+
mobile: 'py-10 text-default',
|
|
55
|
+
} as const
|
|
56
|
+
|
|
48
57
|
let open = $state(false)
|
|
49
58
|
let triggerEl = $state<HTMLElement | null>(null)
|
|
50
59
|
let triggerWidth = $state<number | undefined>(undefined)
|
|
@@ -65,6 +74,10 @@
|
|
|
65
74
|
})
|
|
66
75
|
</script>
|
|
67
76
|
|
|
77
|
+
<div class="flex flex-col">
|
|
78
|
+
{#if label}
|
|
79
|
+
<span class="text-small-emphasis text-secondary mb-4">{label}</span>
|
|
80
|
+
{/if}
|
|
68
81
|
<DropdownMenu.Root bind:open>
|
|
69
82
|
<DropdownMenu.Trigger
|
|
70
83
|
bind:ref={triggerEl}
|
|
@@ -79,7 +92,7 @@
|
|
|
79
92
|
{#if renderSelected && selectedItem}
|
|
80
93
|
{@render renderSelected(selectedItem)}
|
|
81
94
|
{:else}
|
|
82
|
-
<span
|
|
95
|
+
<span>{selectedLabel}</span>
|
|
83
96
|
{/if}
|
|
84
97
|
<IIIcon iconName="caret-down" class="w-14 h-14 shrink-0" />
|
|
85
98
|
</DropdownMenu.Trigger>
|
|
@@ -98,7 +111,8 @@
|
|
|
98
111
|
<DropdownMenu.Item
|
|
99
112
|
disabled={item.disabled}
|
|
100
113
|
class={cn(
|
|
101
|
-
'flex items-center justify-between gap-12 px-12
|
|
114
|
+
'flex items-center justify-between gap-12 px-12 rounded-6 text-dropdown-item cursor-default outline-none data-[highlighted]:bg-dropdown-item-hover data-[disabled]:opacity-50 data-[disabled]:cursor-not-allowed',
|
|
115
|
+
itemDensityClasses[density.value],
|
|
102
116
|
value === item.value && 'text-dropdown-item-selected'
|
|
103
117
|
)}
|
|
104
118
|
onSelect={() => handleSelect(item)}
|
|
@@ -127,3 +141,4 @@
|
|
|
127
141
|
</DropdownMenu.Content>
|
|
128
142
|
</DropdownMenu.Portal>
|
|
129
143
|
</DropdownMenu.Root>
|
|
144
|
+
</div>
|