@casinogate/ui 1.3.7 → 1.5.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.
- package/README.md +4 -9
- package/dist/assets/css/root.css +428 -21
- package/dist/assets/css/theme.css +38 -0
- package/dist/components/badge/badge.stories.svelte +81 -0
- package/dist/components/badge/badge.stories.svelte.d.ts +19 -0
- package/dist/components/badge/badge.svelte +30 -0
- package/dist/components/badge/badge.svelte.d.ts +4 -0
- package/dist/components/badge/exports.d.ts +1 -0
- package/dist/components/badge/exports.js +1 -0
- package/dist/components/badge/index.d.ts +2 -0
- package/dist/components/badge/index.js +1 -0
- package/dist/components/badge/styles.d.ts +99 -0
- package/dist/components/badge/styles.js +126 -0
- package/dist/components/badge/types.d.ts +8 -0
- package/dist/components/badge/types.js +1 -0
- package/dist/components/breadcrumb/breadcrumb.stories.svelte +60 -0
- package/dist/components/breadcrumb/breadcrumb.stories.svelte.d.ts +19 -0
- package/dist/components/breadcrumb/breadcrumb.svelte +32 -0
- package/dist/components/breadcrumb/breadcrumb.svelte.d.ts +4 -0
- package/dist/components/breadcrumb/components/breadcrumb.item.svelte +16 -0
- package/dist/components/breadcrumb/components/breadcrumb.item.svelte.d.ts +4 -0
- package/dist/components/breadcrumb/components/breadcrumb.link.svelte +29 -0
- package/dist/components/breadcrumb/components/breadcrumb.link.svelte.d.ts +4 -0
- package/dist/components/breadcrumb/components/breadcrumb.list.svelte +16 -0
- package/dist/components/breadcrumb/components/breadcrumb.list.svelte.d.ts +4 -0
- package/dist/components/breadcrumb/components/breadcrumb.page.svelte +19 -0
- package/dist/components/breadcrumb/components/breadcrumb.page.svelte.d.ts +4 -0
- package/dist/components/breadcrumb/components/breadcrumb.root.svelte +22 -0
- package/dist/components/breadcrumb/components/breadcrumb.root.svelte.d.ts +4 -0
- package/dist/components/breadcrumb/components/breadcrumb.separator.svelte +24 -0
- package/dist/components/breadcrumb/components/breadcrumb.separator.svelte.d.ts +4 -0
- package/dist/components/breadcrumb/exports-primitive.d.ts +6 -0
- package/dist/components/breadcrumb/exports-primitive.js +6 -0
- package/dist/components/breadcrumb/exports.d.ts +1 -0
- package/dist/components/breadcrumb/exports.js +1 -0
- package/dist/components/breadcrumb/index.d.ts +3 -0
- package/dist/components/breadcrumb/index.js +2 -0
- package/dist/components/breadcrumb/styles.d.ts +62 -0
- package/dist/components/breadcrumb/styles.js +18 -0
- package/dist/components/breadcrumb/types.d.ts +19 -0
- package/dist/components/breadcrumb/types.js +1 -0
- package/dist/components/collapsible/components/collapsaible.svelte.d.ts +11 -0
- package/dist/components/collapsible/components/collapsaible.svelte.js +16 -0
- package/dist/components/collapsible/components/collapsaible.trigger.svelte +17 -5
- package/dist/components/collapsible/types.d.ts +5 -2
- package/dist/components/icons/caret-down.svelte +3 -3
- package/dist/components/icons/caret-up.svelte +3 -3
- package/dist/components/icons/check.svelte +3 -3
- package/dist/components/icons/checkmark.svelte +12 -0
- package/dist/components/icons/checkmark.svelte.d.ts +3 -0
- package/dist/components/icons/chevron-down.svelte +3 -3
- package/dist/components/icons/chevron-left.svelte +3 -3
- package/dist/components/icons/chevron-right.svelte +3 -3
- package/dist/components/icons/chevron-small-down.svelte +3 -3
- package/dist/components/icons/chevron-small-left.svelte +3 -3
- package/dist/components/icons/chevron-small-right.svelte +3 -3
- package/dist/components/icons/chevron-small-up.svelte +3 -3
- package/dist/components/icons/chevron-up.svelte +3 -3
- package/dist/components/icons/dots.svelte +5 -5
- package/dist/components/icons/error.svelte +3 -3
- package/dist/components/icons/exports.d.ts +2 -0
- package/dist/components/icons/exports.js +2 -0
- package/dist/components/icons/eye-crossed.svelte +3 -3
- package/dist/components/icons/eye.svelte +3 -3
- package/dist/components/icons/info.svelte +3 -3
- package/dist/components/icons/minus.svelte +3 -3
- package/dist/components/icons/sidebar-toggle.svelte +4 -4
- package/dist/components/icons/slash.svelte +9 -0
- package/dist/components/icons/slash.svelte.d.ts +3 -0
- package/dist/components/icons/sort.svelte +4 -4
- package/dist/components/icons/spinner.svelte +3 -3
- package/dist/components/icons/success.svelte +3 -3
- package/dist/components/icons/warning.svelte +3 -3
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +2 -0
- package/dist/components/navigation/components/navigation.content.svelte +2 -2
- package/dist/components/navigation/components/navigation.root.svelte +3 -1
- package/dist/components/navigation/components/navigation.root.svelte.d.ts +1 -1
- package/dist/components/navigation/components/navigation.sub-content.svelte +12 -5
- package/dist/components/navigation/components/navigation.svelte.d.ts +8 -2
- package/dist/components/navigation/components/navigation.svelte.js +8 -4
- package/dist/components/navigation/components/navigation.trigger.svelte +83 -25
- package/dist/components/navigation/exports.d.ts +1 -1
- package/dist/components/navigation/exports.js +1 -1
- package/dist/components/navigation/index.d.ts +2 -2
- package/dist/components/navigation/index.js +1 -1
- package/dist/components/navigation/navigation.stories.svelte +34 -20
- package/dist/components/navigation/navigation.stories.svelte.d.ts +1 -0
- package/dist/components/navigation/navigation.svelte +35 -2
- package/dist/components/navigation/navigation.svelte.d.ts +3 -17
- package/dist/components/navigation/styles.d.ts +3 -3
- package/dist/components/navigation/styles.js +5 -4
- package/dist/components/navigation/types.d.ts +35 -4
- package/dist/components/popover/styles.d.ts +3 -3
- package/dist/components/popover/styles.js +1 -1
- package/dist/components/select/components/select.content.svelte +31 -0
- package/dist/components/select/components/select.content.svelte.d.ts +3 -25
- package/dist/components/select/components/select.group-heading.svelte +19 -0
- package/dist/components/select/components/select.group-heading.svelte.d.ts +4 -0
- package/dist/components/select/components/select.group.svelte +8 -0
- package/dist/components/select/components/select.group.svelte.d.ts +4 -0
- package/dist/components/select/components/select.item.svelte +38 -0
- package/dist/components/select/components/select.item.svelte.d.ts +3 -25
- package/dist/components/select/components/select.portal.svelte +10 -0
- package/dist/components/select/components/select.portal.svelte.d.ts +3 -0
- package/dist/components/select/components/select.trigger.svelte +28 -27
- package/dist/components/select/components/select.viewport.svelte +24 -0
- package/dist/components/select/components/select.viewport.svelte.d.ts +3 -25
- package/dist/components/select/exports-primitive.d.ts +6 -0
- package/dist/components/select/exports-primitive.js +6 -0
- package/dist/components/select/exports.d.ts +1 -0
- package/dist/components/select/exports.js +1 -0
- package/dist/components/select/index.d.ts +2 -1
- package/dist/components/select/index.js +1 -0
- package/dist/components/select/select.stories.svelte +178 -15
- package/dist/components/select/select.stories.svelte.d.ts +3 -17
- package/dist/components/select/select.svelte +141 -0
- package/dist/components/select/select.svelte.d.ts +4 -0
- package/dist/components/select/styles.d.ts +15 -3
- package/dist/components/select/styles.js +24 -8
- package/dist/components/select/types.d.ts +42 -4
- package/dist/components/textarea/exports.d.ts +1 -0
- package/dist/components/textarea/exports.js +1 -0
- package/dist/components/textarea/index.d.ts +2 -0
- package/dist/components/textarea/index.js +1 -0
- package/dist/components/textarea/styles.d.ts +54 -0
- package/dist/components/textarea/styles.js +39 -0
- package/dist/components/textarea/textarea.stories.svelte +36 -0
- package/dist/components/textarea/textarea.stories.svelte.d.ts +19 -0
- package/dist/components/textarea/textarea.svelte +22 -0
- package/dist/components/textarea/textarea.svelte.d.ts +4 -0
- package/dist/components/textarea/types.d.ts +6 -0
- package/dist/components/textarea/types.js +1 -0
- package/dist/internal/types/html-attributes.d.ts +2 -1
- package/dist/internal/utils/tailwindcss.js +16 -0
- package/package.json +2 -1
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
-
import { Icon } from '../icons/index.js';
|
|
3
2
|
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
4
3
|
import type { Parameters } from '@storybook/sveltekit';
|
|
5
4
|
import type { ComponentProps } from 'svelte';
|
|
6
|
-
import { SelectPrimitive } from './index.js';
|
|
5
|
+
import { Select, SelectPrimitive } from './index.js';
|
|
7
6
|
|
|
8
7
|
const parameters: Parameters = {
|
|
9
8
|
controls: {
|
|
@@ -24,30 +23,194 @@
|
|
|
24
23
|
variant: 'primary',
|
|
25
24
|
rounded: 'sm',
|
|
26
25
|
w: 'full',
|
|
27
|
-
type: 'single',
|
|
28
|
-
};
|
|
26
|
+
// type: 'single',
|
|
27
|
+
} as Args;
|
|
29
28
|
</script>
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
{
|
|
30
|
+
<script lang="ts">
|
|
31
|
+
const items = [
|
|
32
|
+
{
|
|
33
|
+
value: '1',
|
|
34
|
+
label: 'Item 1',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
value: '2',
|
|
38
|
+
label: 'Item 2',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
value: '3',
|
|
42
|
+
label: 'Item 3',
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
const groupedItems = [
|
|
47
|
+
{
|
|
48
|
+
value: '1',
|
|
49
|
+
label: 'Item 1',
|
|
50
|
+
group: 'Group 1',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
value: '2',
|
|
54
|
+
label: 'Item 2',
|
|
55
|
+
group: 'Group 1',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
value: '3',
|
|
59
|
+
label: 'Item 3',
|
|
60
|
+
group: 'Group 1',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
value: '4',
|
|
64
|
+
label: 'Item 4',
|
|
65
|
+
group: 'Group 2',
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
value: '5',
|
|
69
|
+
label: 'Item 5',
|
|
70
|
+
group: 'Group 2',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
value: '6',
|
|
74
|
+
label: 'Item 6',
|
|
75
|
+
group: 'Group 2',
|
|
76
|
+
},
|
|
77
|
+
];
|
|
78
|
+
|
|
79
|
+
let basic = $state<string>('');
|
|
80
|
+
let grouped = $state<string>('');
|
|
34
81
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
82
|
+
const selectedLabel = $derived(basic ? items.find((item) => item.value === basic)?.label : 'Select');
|
|
83
|
+
const selectedGroupedLabel = $derived(
|
|
84
|
+
grouped ? groupedItems.find((group) => group.value === grouped)?.label : 'Select'
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
const organizedGroups = $derived(
|
|
88
|
+
groupedItems.reduce(
|
|
89
|
+
(acc, item) => {
|
|
90
|
+
const groupName = item.group;
|
|
91
|
+
const existingGroup = acc.find((g) => g.label === groupName);
|
|
92
|
+
|
|
93
|
+
if (existingGroup) {
|
|
94
|
+
existingGroup.items.push(item);
|
|
95
|
+
} else {
|
|
96
|
+
acc.push({
|
|
97
|
+
label: groupName,
|
|
98
|
+
items: [item],
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return acc;
|
|
103
|
+
},
|
|
104
|
+
[] as Array<{ label: string; items: typeof groupedItems }>
|
|
105
|
+
)
|
|
106
|
+
);
|
|
107
|
+
</script>
|
|
38
108
|
|
|
39
109
|
<Story name="Basic" {args} {parameters}>
|
|
40
110
|
{#snippet template(args: Args)}
|
|
41
|
-
<SelectPrimitive.Root {...args}>
|
|
42
|
-
<SelectPrimitive.Trigger>
|
|
111
|
+
<SelectPrimitive.Root {...args} type="single" bind:value={basic}>
|
|
112
|
+
<SelectPrimitive.Trigger>
|
|
113
|
+
{selectedLabel}
|
|
114
|
+
</SelectPrimitive.Trigger>
|
|
115
|
+
<SelectPrimitive.Portal>
|
|
116
|
+
<SelectPrimitive.Content>
|
|
117
|
+
<SelectPrimitive.Viewport>
|
|
118
|
+
{#each items as item}
|
|
119
|
+
<SelectPrimitive.Item value={item.value} label={item.label} />
|
|
120
|
+
{/each}
|
|
121
|
+
</SelectPrimitive.Viewport>
|
|
122
|
+
</SelectPrimitive.Content>
|
|
123
|
+
</SelectPrimitive.Portal>
|
|
43
124
|
</SelectPrimitive.Root>
|
|
44
125
|
{/snippet}
|
|
45
126
|
</Story>
|
|
46
127
|
|
|
47
|
-
<Story name="
|
|
128
|
+
<Story name="Grouped" {args} {parameters}>
|
|
48
129
|
{#snippet template(args: Args)}
|
|
49
|
-
<SelectPrimitive.Root {...args}>
|
|
50
|
-
<SelectPrimitive.Trigger
|
|
130
|
+
<SelectPrimitive.Root {...args} type="single" bind:value={grouped}>
|
|
131
|
+
<SelectPrimitive.Trigger>{selectedGroupedLabel}</SelectPrimitive.Trigger>
|
|
132
|
+
|
|
133
|
+
<SelectPrimitive.Portal>
|
|
134
|
+
<SelectPrimitive.Content>
|
|
135
|
+
<SelectPrimitive.Viewport>
|
|
136
|
+
<SelectPrimitive.Group>
|
|
137
|
+
{#each organizedGroups as group}
|
|
138
|
+
<SelectPrimitive.GroupHeading>{group.label}</SelectPrimitive.GroupHeading>
|
|
139
|
+
{#each group.items as item}
|
|
140
|
+
<SelectPrimitive.Item value={item.value} label={item.label} />
|
|
141
|
+
{/each}
|
|
142
|
+
{/each}
|
|
143
|
+
</SelectPrimitive.Group>
|
|
144
|
+
</SelectPrimitive.Viewport>
|
|
145
|
+
</SelectPrimitive.Content>
|
|
146
|
+
</SelectPrimitive.Portal>
|
|
51
147
|
</SelectPrimitive.Root>
|
|
52
148
|
{/snippet}
|
|
53
149
|
</Story>
|
|
150
|
+
|
|
151
|
+
<Story name="Preset" {args} {parameters}>
|
|
152
|
+
{#snippet template(args: Args)}
|
|
153
|
+
<div class="cgui:flex cgui:flex-col cgui:gap-4">
|
|
154
|
+
<Select.Root {...args} type="single" data={['Item 1', 'Item 2', 'Item 3']} placeholder="Select Item" />
|
|
155
|
+
|
|
156
|
+
<Select.Root
|
|
157
|
+
{...args}
|
|
158
|
+
type="single"
|
|
159
|
+
data={[
|
|
160
|
+
{ label: 'Item 1', value: '1' },
|
|
161
|
+
{ label: 'Item 2', value: '2' },
|
|
162
|
+
{ label: 'Item 3', value: '3' },
|
|
163
|
+
]}
|
|
164
|
+
placeholder="Select Item"
|
|
165
|
+
/>
|
|
166
|
+
|
|
167
|
+
<Select.Root
|
|
168
|
+
{...args}
|
|
169
|
+
type="single"
|
|
170
|
+
data={[
|
|
171
|
+
{
|
|
172
|
+
group: 'Group 1',
|
|
173
|
+
items: [
|
|
174
|
+
{ label: 'Item 1', value: '1' },
|
|
175
|
+
{ label: 'Item 2', value: '2' },
|
|
176
|
+
{ label: 'Item 3', value: '3' },
|
|
177
|
+
],
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
group: 'Group 2',
|
|
181
|
+
items: [
|
|
182
|
+
{ label: 'Item 4', value: '4' },
|
|
183
|
+
{ label: 'Item 5', value: '5' },
|
|
184
|
+
{ label: 'Item 6', value: '6' },
|
|
185
|
+
],
|
|
186
|
+
},
|
|
187
|
+
]}
|
|
188
|
+
placeholder="Select Item"
|
|
189
|
+
/>
|
|
190
|
+
|
|
191
|
+
<Select.Root
|
|
192
|
+
{...args}
|
|
193
|
+
type="multiple"
|
|
194
|
+
data={[
|
|
195
|
+
{
|
|
196
|
+
group: 'Group 1',
|
|
197
|
+
items: [
|
|
198
|
+
{ label: 'Item 1', value: '1' },
|
|
199
|
+
{ label: 'Item 2', value: '2' },
|
|
200
|
+
{ label: 'Item 3', value: '3' },
|
|
201
|
+
],
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
group: 'Group 2',
|
|
205
|
+
items: [
|
|
206
|
+
{ label: 'Item 4', value: '4' },
|
|
207
|
+
{ label: 'Item 5', value: '5' },
|
|
208
|
+
{ label: 'Item 6', value: '6' },
|
|
209
|
+
],
|
|
210
|
+
},
|
|
211
|
+
]}
|
|
212
|
+
placeholder="Select Item"
|
|
213
|
+
/>
|
|
214
|
+
</div>
|
|
215
|
+
{/snippet}
|
|
216
|
+
</Story>
|
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} & Exports;
|
|
5
|
-
(internal: unknown, props: {
|
|
6
|
-
$$events?: Events;
|
|
7
|
-
$$slots?: Slots;
|
|
8
|
-
}): Exports & {
|
|
9
|
-
$set?: any;
|
|
10
|
-
$on?: any;
|
|
11
|
-
};
|
|
12
|
-
z_$$bindings?: Bindings;
|
|
13
|
-
}
|
|
14
|
-
declare const Select: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
-
[evt: string]: CustomEvent<any>;
|
|
16
|
-
}, {}, {}, string>;
|
|
17
|
-
type Select = InstanceType<typeof Select>;
|
|
1
|
+
import { Select } from './index.js';
|
|
2
|
+
declare const Select: import("svelte").Component<Record<string, never>, {}, "">;
|
|
3
|
+
type Select = ReturnType<typeof Select>;
|
|
18
4
|
export default Select;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { SelectItem, SelectItemData, SelectItemGroup, SelectProps } from './types.js';
|
|
3
|
+
|
|
4
|
+
import Content from './components/select.content.svelte';
|
|
5
|
+
import GroupHeading from './components/select.group-heading.svelte';
|
|
6
|
+
import Group from './components/select.group.svelte';
|
|
7
|
+
import Item from './components/select.item.svelte';
|
|
8
|
+
import Portal from './components/select.portal.svelte';
|
|
9
|
+
import Root from './components/select.root.svelte';
|
|
10
|
+
import Trigger from './components/select.trigger.svelte';
|
|
11
|
+
import Viewport from './components/select.viewport.svelte';
|
|
12
|
+
|
|
13
|
+
let {
|
|
14
|
+
value = $bindable(''),
|
|
15
|
+
open = $bindable(false),
|
|
16
|
+
|
|
17
|
+
empty = 'No results found',
|
|
18
|
+
|
|
19
|
+
data,
|
|
20
|
+
item,
|
|
21
|
+
trigger,
|
|
22
|
+
side,
|
|
23
|
+
sideOffset,
|
|
24
|
+
align,
|
|
25
|
+
alignOffset,
|
|
26
|
+
avoidCollisions,
|
|
27
|
+
collisionPadding,
|
|
28
|
+
customAnchor,
|
|
29
|
+
|
|
30
|
+
placeholder: placeholderProp,
|
|
31
|
+
|
|
32
|
+
...restProps
|
|
33
|
+
}: SelectProps = $props();
|
|
34
|
+
|
|
35
|
+
const getLabelFromValue = (searchValue: string): string | null => {
|
|
36
|
+
for (const item of data) {
|
|
37
|
+
if (typeof item === 'string') {
|
|
38
|
+
if (item === searchValue) return item;
|
|
39
|
+
} else if ('group' in item) {
|
|
40
|
+
for (const groupItem of item.items) {
|
|
41
|
+
if (typeof groupItem === 'string') {
|
|
42
|
+
if (groupItem === searchValue) return groupItem;
|
|
43
|
+
} else if (groupItem.value === searchValue) {
|
|
44
|
+
return groupItem.label;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
} else if (item.value === searchValue) {
|
|
48
|
+
return item.label;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const placeholder = $derived.by(() => {
|
|
55
|
+
if (typeof value === 'string' && value.trim() !== '') {
|
|
56
|
+
const label = getLabelFromValue(value);
|
|
57
|
+
return label ?? value;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (Array.isArray(value) && value.length > 0) {
|
|
61
|
+
const labels = value.map((v) => getLabelFromValue(v) ?? v);
|
|
62
|
+
return labels.join(', ');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (placeholderProp) return placeholderProp;
|
|
66
|
+
|
|
67
|
+
return '';
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const getItemKey = (item: SelectItemData) => {
|
|
71
|
+
if (typeof item === 'string') return item;
|
|
72
|
+
if ('group' in item) return item.group;
|
|
73
|
+
return item.value;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const hasResults = $derived.by(() => {
|
|
77
|
+
return data.length > 0;
|
|
78
|
+
});
|
|
79
|
+
</script>
|
|
80
|
+
|
|
81
|
+
{#snippet itemsString(item: string)}
|
|
82
|
+
<Item value={item} label={item} />
|
|
83
|
+
{/snippet}
|
|
84
|
+
|
|
85
|
+
{#snippet itemBasic(item: SelectItem)}
|
|
86
|
+
<Item value={item.value} label={item.label} />
|
|
87
|
+
{/snippet}
|
|
88
|
+
|
|
89
|
+
{#snippet itemGroup(group: SelectItemGroup)}
|
|
90
|
+
<Group>
|
|
91
|
+
<GroupHeading>
|
|
92
|
+
{group.group}
|
|
93
|
+
</GroupHeading>
|
|
94
|
+
|
|
95
|
+
{#each group.items as item (getItemKey(item))}
|
|
96
|
+
{#if typeof item === 'string'}
|
|
97
|
+
{@render itemsString(item)}
|
|
98
|
+
{:else}
|
|
99
|
+
{@render itemBasic(item)}
|
|
100
|
+
{/if}
|
|
101
|
+
{/each}
|
|
102
|
+
</Group>
|
|
103
|
+
{/snippet}
|
|
104
|
+
|
|
105
|
+
<Root bind:value={value as never} bind:open {...restProps}>
|
|
106
|
+
{#if trigger}
|
|
107
|
+
<Trigger>
|
|
108
|
+
{#snippet child({ props })}
|
|
109
|
+
{@render trigger?.({ props, label: placeholder })}
|
|
110
|
+
{/snippet}
|
|
111
|
+
</Trigger>
|
|
112
|
+
{:else}
|
|
113
|
+
<Trigger>
|
|
114
|
+
{placeholder}
|
|
115
|
+
</Trigger>
|
|
116
|
+
{/if}
|
|
117
|
+
|
|
118
|
+
<Portal>
|
|
119
|
+
<Content>
|
|
120
|
+
<Viewport>
|
|
121
|
+
{#if hasResults}
|
|
122
|
+
{#each data as item (getItemKey(item))}
|
|
123
|
+
{#if typeof item === 'string'}
|
|
124
|
+
{@render itemsString(item)}
|
|
125
|
+
{:else if 'group' in item}
|
|
126
|
+
{@render itemGroup(item)}
|
|
127
|
+
{:else}
|
|
128
|
+
{@render itemBasic(item)}
|
|
129
|
+
{/if}
|
|
130
|
+
{/each}
|
|
131
|
+
{:else if typeof empty === 'string'}
|
|
132
|
+
<div class="cgui:p-4 cgui:text-center cgui:text-body-2 cgui:text-fg-darkest">
|
|
133
|
+
{empty}
|
|
134
|
+
</div>
|
|
135
|
+
{:else}
|
|
136
|
+
{@render empty?.()}
|
|
137
|
+
{/if}
|
|
138
|
+
</Viewport>
|
|
139
|
+
</Content>
|
|
140
|
+
</Portal>
|
|
141
|
+
</Root>
|
|
@@ -46,8 +46,12 @@ export declare const selectVariants: import("tailwind-variants").TVReturnType<{
|
|
|
46
46
|
};
|
|
47
47
|
};
|
|
48
48
|
}, {
|
|
49
|
+
content: string[];
|
|
50
|
+
item: string[];
|
|
51
|
+
viewport: string[];
|
|
52
|
+
group: never[];
|
|
53
|
+
label: string[];
|
|
49
54
|
trigger: string[];
|
|
50
|
-
chevron: string[];
|
|
51
55
|
}, undefined, {
|
|
52
56
|
variant: {
|
|
53
57
|
primary: {
|
|
@@ -93,8 +97,12 @@ export declare const selectVariants: import("tailwind-variants").TVReturnType<{
|
|
|
93
97
|
};
|
|
94
98
|
};
|
|
95
99
|
}, {
|
|
100
|
+
content: string[];
|
|
101
|
+
item: string[];
|
|
102
|
+
viewport: string[];
|
|
103
|
+
group: never[];
|
|
104
|
+
label: string[];
|
|
96
105
|
trigger: string[];
|
|
97
|
-
chevron: string[];
|
|
98
106
|
}, import("tailwind-variants").TVReturnType<{
|
|
99
107
|
variant: {
|
|
100
108
|
primary: {
|
|
@@ -140,8 +148,12 @@ export declare const selectVariants: import("tailwind-variants").TVReturnType<{
|
|
|
140
148
|
};
|
|
141
149
|
};
|
|
142
150
|
}, {
|
|
151
|
+
content: string[];
|
|
152
|
+
item: string[];
|
|
153
|
+
viewport: string[];
|
|
154
|
+
group: never[];
|
|
155
|
+
label: string[];
|
|
143
156
|
trigger: string[];
|
|
144
|
-
chevron: string[];
|
|
145
157
|
}, undefined, unknown, unknown, undefined>>;
|
|
146
158
|
export type SelectVariantsProps = VariantProps<typeof selectVariants>;
|
|
147
159
|
type SelectStylesContextValues = ReadableBox<ReturnType<typeof selectVariants>>;
|
|
@@ -3,16 +3,32 @@ import { Context } from 'runed';
|
|
|
3
3
|
import { keyWithPrefix } from './../../internal/utils/common.js';
|
|
4
4
|
export const selectVariants = tv({
|
|
5
5
|
slots: {
|
|
6
|
-
|
|
7
|
-
'cgui:relative cgui:
|
|
8
|
-
'cgui:
|
|
6
|
+
content: [
|
|
7
|
+
'cgui:relative cgui:overflow-y-auto cgui:overflow-x-hidden',
|
|
8
|
+
'cgui:shadow-select cgui:bg-surface-white',
|
|
9
|
+
'cgui:rounded-sm',
|
|
10
|
+
'cgui:z-(--cg-ui-z-index-select)',
|
|
11
|
+
'cgui:max-h-(--bits-select-content-available-height) cgui:origin-(--bits-select-content-transform-origin)',
|
|
12
|
+
'cgui:data-[state=open]:animate-in cgui:data-[state=closed]:animate-out cgui:data-[state=closed]:fade-out-0 cgui:data-[state=open]:fade-in-0 cgui:data-[state=closed]:zoom-out-95 cgui:data-[state=open]:zoom-in-95 cgui:data-[side=bottom]:slide-in-from-top-2 cgui:data-[side=left]:slide-in-from-right-2 cgui:data-[side=right]:slide-in-from-left-2 cgui:data-[side=top]:slide-in-from-bottom-2 cgui:data-[side=bottom]:translate-y-1 cgui:data-[side=left]:-translate-x-1 cgui:data-[side=right]:translate-x-1 cgui:data-[side=top]:-translate-y-1',
|
|
13
|
+
],
|
|
14
|
+
item: [
|
|
15
|
+
'cgui:relative cgui:w-full',
|
|
16
|
+
'cgui:flex cgui:items-center cgui:justify-between cgui:gap-2',
|
|
17
|
+
'cgui:outline-hidden cgui:cursor-default cgui:select-none',
|
|
18
|
+
'cgui:p-2',
|
|
19
|
+
'cgui:text-body cgui:text-fg-dark',
|
|
20
|
+
'cgui:data-[disabled]:pointer-events-none cgui:data-[disabled]:opacity-50',
|
|
21
|
+
'cgui:[&_svg]:shrink-0 cgui:[&_svg]:pointer-events-none',
|
|
9
22
|
],
|
|
10
|
-
|
|
11
|
-
'cgui:
|
|
23
|
+
viewport: [
|
|
24
|
+
'cgui:h-(--bits-select-anchor-height) cgui:min-w-(--bits-select-anchor-width) cgui:w-full cgui:scroll-my-1 cgui:p-1',
|
|
25
|
+
],
|
|
26
|
+
group: [],
|
|
27
|
+
label: ['cgui:text-fg-semilight cgui:px-2 cgui:py-1.5 cgui:text-caption'],
|
|
28
|
+
trigger: [
|
|
29
|
+
'cgui:group/select-trigger',
|
|
30
|
+
'cgui:relative cgui:flex cgui:items-center cgui:justify-between cgui:flex-wrap',
|
|
12
31
|
'cgui:transition-all cgui:duration-250 cgui:ease-in-out',
|
|
13
|
-
'cgui:text-icon-regular',
|
|
14
|
-
'cgui:data-[slot=start-chevron]:left-0 cgui:data-[slot=end-chevron]:right-0',
|
|
15
|
-
'cgui:data-[slot=start-chevron]:translate-x-1/2 cgui:data-[slot=end-chevron]:-translate-x-1/2',
|
|
16
32
|
],
|
|
17
33
|
},
|
|
18
34
|
variants: {
|
|
@@ -1,9 +1,47 @@
|
|
|
1
|
-
import { type SelectRootProps as SelectRootPropsPrimitive, type SelectTriggerProps as SelectTriggerPropsPrimitive } from 'bits-ui';
|
|
1
|
+
import { type SelectContentProps as SelectContentPropsPrimitive, type SelectGroupHeadingProps as SelectGroupHeadingPropsPrimitive, type SelectGroupProps as SelectGroupPropsPrimitive, type SelectItemProps as SelectItemPropsPrimitive, type SelectPortalProps as SelectPortalPropsPrimitive, type SelectRootProps as SelectRootPropsPrimitive, type SelectTriggerProps as SelectTriggerPropsPrimitive, type SelectViewportProps as SelectViewportPropsPrimitive } from 'bits-ui';
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
3
|
import type { WithoutChild } from 'svelte-toolbelt';
|
|
4
4
|
import { type SelectVariantsProps } from './styles.js';
|
|
5
5
|
export type SelectRootProps = SelectRootPropsPrimitive & SelectVariantsProps;
|
|
6
|
-
export type SelectTriggerProps =
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
export type SelectTriggerProps = SelectTriggerPropsPrimitive & {
|
|
7
|
+
hasChevron?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type SelectContentProps = WithoutChild<SelectContentPropsPrimitive>;
|
|
10
|
+
export type SelectViewportProps = SelectViewportPropsPrimitive;
|
|
11
|
+
export type SelectItemProps = WithoutChild<SelectItemPropsPrimitive>;
|
|
12
|
+
export type SelectGroupProps = SelectGroupPropsPrimitive;
|
|
13
|
+
export type SelectGroupHeadingProps = SelectGroupHeadingPropsPrimitive;
|
|
14
|
+
export type SelectPortalProps = SelectPortalPropsPrimitive;
|
|
15
|
+
export type SelectBaseItem = {
|
|
16
|
+
value: string;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
};
|
|
19
|
+
export type SelectItem = SelectBaseItem & {
|
|
20
|
+
label: string;
|
|
21
|
+
};
|
|
22
|
+
export type SelectItemGroup<T = SelectItem | string> = {
|
|
23
|
+
group: string;
|
|
24
|
+
items: T[];
|
|
25
|
+
};
|
|
26
|
+
export type SelectItemData = string | SelectItemGroup | SelectItem;
|
|
27
|
+
export type SelectData = string[] | SelectItemGroup[] | SelectItem[];
|
|
28
|
+
export type SelectProps = SelectRootProps & {
|
|
29
|
+
data: SelectData;
|
|
30
|
+
placeholder?: string;
|
|
31
|
+
item?: Snippet<[{
|
|
32
|
+
item: SelectItemData;
|
|
33
|
+
props: Record<string, unknown>;
|
|
34
|
+
}]>;
|
|
35
|
+
trigger?: Snippet<[{
|
|
36
|
+
props: Record<string, unknown>;
|
|
37
|
+
label: string;
|
|
38
|
+
}]>;
|
|
39
|
+
empty?: Snippet | string;
|
|
40
|
+
side?: SelectContentProps['side'];
|
|
41
|
+
sideOffset?: SelectContentProps['sideOffset'];
|
|
42
|
+
align?: SelectContentProps['align'];
|
|
43
|
+
alignOffset?: SelectContentProps['alignOffset'];
|
|
44
|
+
avoidCollisions?: SelectContentProps['avoidCollisions'];
|
|
45
|
+
collisionPadding?: SelectContentProps['collisionPadding'];
|
|
46
|
+
customAnchor?: SelectContentProps['customAnchor'];
|
|
9
47
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Root } from './textarea.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Root } from './textarea.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as Textarea from './exports.js';
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { VariantProps } from 'tailwind-variants';
|
|
2
|
+
export declare const textareaVariants: import("tailwind-variants").TVReturnType<{
|
|
3
|
+
variant: {
|
|
4
|
+
primary: string[];
|
|
5
|
+
clear: never[];
|
|
6
|
+
};
|
|
7
|
+
resizable: {
|
|
8
|
+
true: string[];
|
|
9
|
+
false: string[];
|
|
10
|
+
};
|
|
11
|
+
rounded: {
|
|
12
|
+
sm: string[];
|
|
13
|
+
md: string[];
|
|
14
|
+
lg: string[];
|
|
15
|
+
xl: string[];
|
|
16
|
+
full: string[];
|
|
17
|
+
none: never[];
|
|
18
|
+
};
|
|
19
|
+
}, undefined, string[], {
|
|
20
|
+
variant: {
|
|
21
|
+
primary: string[];
|
|
22
|
+
clear: never[];
|
|
23
|
+
};
|
|
24
|
+
resizable: {
|
|
25
|
+
true: string[];
|
|
26
|
+
false: string[];
|
|
27
|
+
};
|
|
28
|
+
rounded: {
|
|
29
|
+
sm: string[];
|
|
30
|
+
md: string[];
|
|
31
|
+
lg: string[];
|
|
32
|
+
xl: string[];
|
|
33
|
+
full: string[];
|
|
34
|
+
none: never[];
|
|
35
|
+
};
|
|
36
|
+
}, undefined, import("tailwind-variants").TVReturnType<{
|
|
37
|
+
variant: {
|
|
38
|
+
primary: string[];
|
|
39
|
+
clear: never[];
|
|
40
|
+
};
|
|
41
|
+
resizable: {
|
|
42
|
+
true: string[];
|
|
43
|
+
false: string[];
|
|
44
|
+
};
|
|
45
|
+
rounded: {
|
|
46
|
+
sm: string[];
|
|
47
|
+
md: string[];
|
|
48
|
+
lg: string[];
|
|
49
|
+
xl: string[];
|
|
50
|
+
full: string[];
|
|
51
|
+
none: never[];
|
|
52
|
+
};
|
|
53
|
+
}, undefined, string[], unknown, unknown, undefined>>;
|
|
54
|
+
export type TextareaVariantsProps = VariantProps<typeof textareaVariants>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { tv } from '../../internal/utils/tailwindcss.js';
|
|
2
|
+
export const textareaVariants = tv({
|
|
3
|
+
base: [
|
|
4
|
+
'cgui:w-full cgui:overflow-x-hidden',
|
|
5
|
+
'cgui:scrollbar-thin cgui:scrollbar-track-surface-lightest cgui:scrollbar-thumb-rounded-md cgui:scrollbar-track-rounded-md',
|
|
6
|
+
'cgui:scrollbar-thumb-surface-regular/40 cgui:scrollbar-hover:scrollbar-thumb-surface-regular/60',
|
|
7
|
+
'cgui:outline-none cgui:text-body',
|
|
8
|
+
'cgui:transition-[opacity] cgui:duration-250 cgui:ease-in-out',
|
|
9
|
+
'cgui:disabled:opacity-50 cgui:disabled:cursor-not-allowed',
|
|
10
|
+
],
|
|
11
|
+
variants: {
|
|
12
|
+
variant: {
|
|
13
|
+
primary: [
|
|
14
|
+
'cgui:border cgui:border-stroke-default',
|
|
15
|
+
'cgui:bg-surface-lightest cgui:placeholder:text-fg-regular cgui:shadow-none',
|
|
16
|
+
'cgui:focus:ring-stroke-default cgui:focus-visible:border-stroke-focus',
|
|
17
|
+
'cgui:aria-invalid:ring-stroke-error cgui:aria-invalid:border-stroke-error',
|
|
18
|
+
],
|
|
19
|
+
clear: [],
|
|
20
|
+
},
|
|
21
|
+
resizable: {
|
|
22
|
+
true: ['cgui:resize-y'],
|
|
23
|
+
false: ['cgui:resize-none'],
|
|
24
|
+
},
|
|
25
|
+
rounded: {
|
|
26
|
+
sm: ['cgui:rounded-sm'],
|
|
27
|
+
md: ['cgui:rounded-md'],
|
|
28
|
+
lg: ['cgui:rounded-lg'],
|
|
29
|
+
xl: ['cgui:rounded-xl'],
|
|
30
|
+
full: ['cgui:rounded-full'],
|
|
31
|
+
none: [],
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
defaultVariants: {
|
|
35
|
+
rounded: 'sm',
|
|
36
|
+
resizable: true,
|
|
37
|
+
variant: 'primary',
|
|
38
|
+
},
|
|
39
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import type { Parameters } from '@storybook/sveltekit';
|
|
4
|
+
import type { ComponentProps } from 'svelte';
|
|
5
|
+
import { Textarea } from './index.js';
|
|
6
|
+
|
|
7
|
+
const parameters: Parameters = {
|
|
8
|
+
controls: {
|
|
9
|
+
include: ['placeholder', 'disabled', 'rounded', 'resizable', 'variant', 'rows'],
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const { Story } = defineMeta({
|
|
14
|
+
title: 'UI Kit/Textarea',
|
|
15
|
+
component: Textarea.Root,
|
|
16
|
+
tags: ['autodocs'],
|
|
17
|
+
parameters,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
type Args = ComponentProps<typeof Textarea.Root>;
|
|
21
|
+
|
|
22
|
+
const args: Args = {
|
|
23
|
+
placeholder: 'Textarea',
|
|
24
|
+
disabled: false,
|
|
25
|
+
rounded: 'sm',
|
|
26
|
+
variant: 'primary',
|
|
27
|
+
rows: 3,
|
|
28
|
+
resizable: false,
|
|
29
|
+
};
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<Story name="Basic" {args} {parameters}>
|
|
33
|
+
{#snippet template(args: Args)}
|
|
34
|
+
<Textarea.Root {...args} />
|
|
35
|
+
{/snippet}
|
|
36
|
+
</Story>
|