@youcan/celeste 0.6.15 → 0.6.17
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/celeste.css +597 -198
- package/dist/cjs/chunks/combobox-anchor.js +31 -0
- package/dist/cjs/chunks/combobox-root.js +38 -0
- package/dist/cjs/chunks/index.js +17 -0
- package/dist/cjs/combobox-anchor.js +3 -0
- package/dist/cjs/combobox-empty.js +32 -0
- package/dist/cjs/combobox-group.js +42 -0
- package/dist/cjs/combobox-input.js +67 -0
- package/dist/cjs/combobox-item.js +109 -0
- package/dist/cjs/combobox-list.js +62 -0
- package/dist/cjs/combobox-root.js +3 -0
- package/dist/cjs/combobox-separator.js +32 -0
- package/dist/cjs/combobox-trigger.js +46 -0
- package/dist/cjs/combobox.js +190 -0
- package/dist/cjs/dropdown.js +10 -3
- package/dist/cjs/index.js +30 -0
- package/dist/cjs/text-input-icon.js +2 -2
- package/dist/components/combobox/combobox-anchor.d.ts +22 -0
- package/dist/components/combobox/combobox-empty.d.ts +22 -0
- package/dist/components/combobox/combobox-group.d.ts +23 -0
- package/dist/components/combobox/combobox-input.d.ts +17 -0
- package/dist/components/combobox/combobox-item.d.ts +31 -0
- package/dist/components/combobox/combobox-list.d.ts +36 -0
- package/dist/components/combobox/combobox-root.d.ts +29 -0
- package/dist/components/combobox/combobox-separator.d.ts +22 -0
- package/dist/components/combobox/combobox-trigger.d.ts +20 -0
- package/dist/components/combobox/combobox.d.ts +40 -0
- package/dist/components/combobox/index.d.ts +20 -0
- package/dist/components/dropdown/dropdown.d.ts +5 -1
- package/dist/components/dropdown-menu/dropdown-menu-sub-content.d.ts +4 -4
- package/dist/components/index.d.ts +1 -0
- package/dist/components/modal/modal-content.d.ts +2 -2
- package/dist/components/popover/popover-content.d.ts +2 -2
- package/dist/es/chunks/combobox-anchor.js +32 -0
- package/dist/es/chunks/combobox-root.js +39 -0
- package/dist/es/chunks/index.js +59 -42
- package/dist/es/combobox-anchor.js +4 -0
- package/dist/es/combobox-empty.js +33 -0
- package/dist/es/combobox-group.js +43 -0
- package/dist/es/combobox-input.js +68 -0
- package/dist/es/combobox-item.js +110 -0
- package/dist/es/combobox-list.js +63 -0
- package/dist/es/combobox-root.js +4 -0
- package/dist/es/combobox-separator.js +33 -0
- package/dist/es/combobox-trigger.js +47 -0
- package/dist/es/combobox.js +191 -0
- package/dist/es/command-group.js +1 -1
- package/dist/es/command-input.js +1 -1
- package/dist/es/command-separator.js +1 -1
- package/dist/es/dropdown-menu-group.js +1 -1
- package/dist/es/dropdown-menu-item.js +1 -1
- package/dist/es/dropdown-menu-label.js +1 -1
- package/dist/es/dropdown-menu-separator.js +1 -1
- package/dist/es/dropdown-menu-trigger.js +1 -1
- package/dist/es/dropdown-menu.js +1 -1
- package/dist/es/dropdown.js +11 -4
- package/dist/es/index.js +75 -45
- package/dist/es/label.js +1 -1
- package/dist/es/modal-content.js +1 -1
- package/dist/es/modal-header.js +1 -1
- package/dist/es/popover-content.js +1 -1
- package/dist/es/popover-trigger.js +1 -1
- package/dist/es/segmented-control-item.js +1 -1
- package/dist/es/segmented-control.js +1 -1
- package/dist/es/select-content.js +1 -1
- package/dist/es/select-item.js +1 -1
- package/dist/es/select-trigger.js +1 -1
- package/dist/es/select-value.js +1 -1
- package/dist/es/tab-menu-content.js +1 -1
- package/dist/es/tab-menu-item.js +1 -1
- package/dist/es/tab-menu-list.js +1 -1
- package/dist/es/text-input-icon.js +2 -2
- package/dist/es/tooltip.js +1 -1
- package/package.json +3 -3
- package/src/components/combobox/combobox-anchor.vue +25 -0
- package/src/components/combobox/combobox-empty.vue +30 -0
- package/src/components/combobox/combobox-group.vue +42 -0
- package/src/components/combobox/combobox-input.vue +64 -0
- package/src/components/combobox/combobox-item.vue +196 -0
- package/src/components/combobox/combobox-list.vue +100 -0
- package/src/components/combobox/combobox-root.vue +14 -0
- package/src/components/combobox/combobox-separator.vue +31 -0
- package/src/components/combobox/combobox-trigger.vue +249 -0
- package/src/components/combobox/combobox.vue +235 -0
- package/src/components/combobox/index.ts +29 -0
- package/src/components/combobox/stories/combobox.stories.ts +242 -0
- package/src/components/dropdown/dropdown.vue +33 -2
- package/src/components/index.ts +1 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/vue3-vite';
|
|
2
|
+
import { ref } from 'vue';
|
|
3
|
+
import Combobox from '../combobox.vue';
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof Combobox> = {
|
|
6
|
+
title: 'Components/Combobox',
|
|
7
|
+
component: Combobox,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export default meta;
|
|
11
|
+
|
|
12
|
+
type Story = StoryObj<typeof Combobox>;
|
|
13
|
+
|
|
14
|
+
const OPTIONS = [
|
|
15
|
+
{ value: { id: 1 }, label: 'Durward Reynolds', sublabel: 'Teacher' },
|
|
16
|
+
{ value: { id: 2 }, label: 'Kenton Towne', icon: 'i-celeste-globe-line' },
|
|
17
|
+
{ value: { id: 3 }, label: 'Therese Wunsch', sublabel: 'Engineer' },
|
|
18
|
+
{ value: { id: 4 }, label: 'Benedict Kessler', image: 'https://cdn3.pixelcut.app/7/20/uncrop_hero_bdf08a8ca6.jpg' },
|
|
19
|
+
{ value: { id: 5 }, label: 'Katelyn Rohan' },
|
|
20
|
+
{ value: { id: 6 }, label: 'Lily Marissa', icon: 'i-celeste-globe-line' },
|
|
21
|
+
{ value: { id: 7 }, label: 'Maya San Eleine', sublabel: 'Writer', icon: 'i-celeste-bookmark-fill' },
|
|
22
|
+
{ value: { id: 8 }, label: 'Rami Kent' },
|
|
23
|
+
{ value: { id: 9 }, label: 'Goerge Dan', icon: 'i-celeste-sticky-note-line' },
|
|
24
|
+
{ value: { id: 10 }, label: 'Remus Down' },
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
export const Default: Story = {
|
|
28
|
+
args: {
|
|
29
|
+
options: OPTIONS,
|
|
30
|
+
valueBy: 'id',
|
|
31
|
+
placeholder: 'Select a person',
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
render: args => ({
|
|
35
|
+
components: { Combobox },
|
|
36
|
+
setup() {
|
|
37
|
+
const selectedValue = ref();
|
|
38
|
+
|
|
39
|
+
return { args, selectedValue };
|
|
40
|
+
},
|
|
41
|
+
template: `
|
|
42
|
+
<div>
|
|
43
|
+
<Combobox v-bind="args" v-model="selectedValue" />
|
|
44
|
+
<div style="margin-top: 16px; padding: 12px; background: #f5f5f5; border-radius: 8px; font-family: monospace;">
|
|
45
|
+
<strong>Selected:</strong> {{ selectedValue ? selectedValue.label : 'None' }}
|
|
46
|
+
<br>
|
|
47
|
+
<strong>Value:</strong> {{ selectedValue ? JSON.stringify(selectedValue.value) : 'None' }}
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
`,
|
|
51
|
+
}),
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const Multiple: Story = {
|
|
55
|
+
args: {
|
|
56
|
+
options: OPTIONS,
|
|
57
|
+
valueBy: 'id',
|
|
58
|
+
placeholder: 'Select multiple people',
|
|
59
|
+
multiple: true,
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
render: args => ({
|
|
63
|
+
components: { Combobox },
|
|
64
|
+
setup() {
|
|
65
|
+
const selectedValues = ref([]);
|
|
66
|
+
|
|
67
|
+
return { args, selectedValues };
|
|
68
|
+
},
|
|
69
|
+
template: `
|
|
70
|
+
<div>
|
|
71
|
+
<Combobox v-bind="args" v-model="selectedValues" />
|
|
72
|
+
<div style="margin-top: 16px; padding: 12px; background: #f5f5f5; border-radius: 8px; font-family: monospace;">
|
|
73
|
+
<strong>Selected ({{ selectedValues.length }}):</strong>
|
|
74
|
+
<ul v-if="selectedValues.length > 0" style="margin: 4px 0; padding-left: 20px;">
|
|
75
|
+
<li v-for="item in selectedValues" :key="item.value.id">
|
|
76
|
+
{{ item.label }} (ID: {{ item.value.id }})
|
|
77
|
+
</li>
|
|
78
|
+
</ul>
|
|
79
|
+
<span v-else>None</span>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
`,
|
|
83
|
+
}),
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export const Searchable: Story = {
|
|
87
|
+
args: {
|
|
88
|
+
options: OPTIONS,
|
|
89
|
+
valueBy: 'id',
|
|
90
|
+
placeholder: 'Search and select',
|
|
91
|
+
searchable: true,
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
render: args => ({
|
|
95
|
+
components: { Combobox },
|
|
96
|
+
setup() {
|
|
97
|
+
const selectedValue = ref();
|
|
98
|
+
|
|
99
|
+
return { args, selectedValue };
|
|
100
|
+
},
|
|
101
|
+
template: `
|
|
102
|
+
<div>
|
|
103
|
+
<Combobox v-bind="args" v-model="selectedValue" />
|
|
104
|
+
<div style="margin-top: 16px; padding: 12px; background: #f5f5f5; border-radius: 8px; font-family: monospace;">
|
|
105
|
+
<strong>Selected:</strong> {{ selectedValue ? selectedValue.label : 'None' }}
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
`,
|
|
109
|
+
}),
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export const Inline: Story = {
|
|
113
|
+
args: {
|
|
114
|
+
options: OPTIONS,
|
|
115
|
+
valueBy: 'id',
|
|
116
|
+
type: 'inline',
|
|
117
|
+
placeholder: 'Inline style',
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
render: args => ({
|
|
121
|
+
components: { Combobox },
|
|
122
|
+
setup() {
|
|
123
|
+
const selectedValue = ref();
|
|
124
|
+
|
|
125
|
+
return { args, selectedValue };
|
|
126
|
+
},
|
|
127
|
+
template: `
|
|
128
|
+
<div>
|
|
129
|
+
<Combobox v-bind="args" v-model="selectedValue" />
|
|
130
|
+
<div style="margin-top: 16px; padding: 12px; background: #f5f5f5; border-radius: 8px; font-family: monospace;">
|
|
131
|
+
<strong>Selected:</strong> {{ selectedValue ? selectedValue.label : 'None' }}
|
|
132
|
+
</div>
|
|
133
|
+
</div>
|
|
134
|
+
`,
|
|
135
|
+
}),
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export const Compact: Story = {
|
|
139
|
+
args: {
|
|
140
|
+
options: OPTIONS,
|
|
141
|
+
valueBy: 'id',
|
|
142
|
+
type: 'compact',
|
|
143
|
+
placeholder: 'Compact style',
|
|
144
|
+
},
|
|
145
|
+
|
|
146
|
+
render: args => ({
|
|
147
|
+
components: { Combobox },
|
|
148
|
+
setup() {
|
|
149
|
+
const selectedValue = ref();
|
|
150
|
+
|
|
151
|
+
return { args, selectedValue };
|
|
152
|
+
},
|
|
153
|
+
template: `
|
|
154
|
+
<div>
|
|
155
|
+
<Combobox v-bind="args" v-model="selectedValue" />
|
|
156
|
+
<div style="margin-top: 16px; padding: 12px; background: #f5f5f5; border-radius: 8px; font-family: monospace;">
|
|
157
|
+
<strong>Selected:</strong> {{ selectedValue ? selectedValue.label : 'None' }}
|
|
158
|
+
</div>
|
|
159
|
+
</div>
|
|
160
|
+
`,
|
|
161
|
+
}),
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
export const CompactInput: Story = {
|
|
165
|
+
args: {
|
|
166
|
+
options: OPTIONS,
|
|
167
|
+
valueBy: 'id',
|
|
168
|
+
type: 'compact-input',
|
|
169
|
+
placeholder: 'Compact input style',
|
|
170
|
+
},
|
|
171
|
+
|
|
172
|
+
render: args => ({
|
|
173
|
+
components: { Combobox },
|
|
174
|
+
setup() {
|
|
175
|
+
const selectedValue = ref();
|
|
176
|
+
|
|
177
|
+
return { args, selectedValue };
|
|
178
|
+
},
|
|
179
|
+
template: `
|
|
180
|
+
<div>
|
|
181
|
+
<Combobox v-bind="args" v-model="selectedValue" />
|
|
182
|
+
<div style="margin-top: 16px; padding: 12px; background: #f5f5f5; border-radius: 8px; font-family: monospace;">
|
|
183
|
+
<strong>Selected:</strong> {{ selectedValue ? selectedValue.label : 'None' }}
|
|
184
|
+
</div>
|
|
185
|
+
</div>
|
|
186
|
+
`,
|
|
187
|
+
}),
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
export const WithBadge: Story = {
|
|
191
|
+
args: {
|
|
192
|
+
options: OPTIONS,
|
|
193
|
+
valueBy: 'id',
|
|
194
|
+
placeholder: 'Select with badge',
|
|
195
|
+
badgeProps: {
|
|
196
|
+
label: 'New',
|
|
197
|
+
variant: 'fill',
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
|
|
201
|
+
render: args => ({
|
|
202
|
+
components: { Combobox },
|
|
203
|
+
setup() {
|
|
204
|
+
const selectedValue = ref();
|
|
205
|
+
|
|
206
|
+
return { args, selectedValue };
|
|
207
|
+
},
|
|
208
|
+
template: `
|
|
209
|
+
<div>
|
|
210
|
+
<Combobox v-bind="args" v-model="selectedValue" />
|
|
211
|
+
<div style="margin-top: 16px; padding: 12px; background: #f5f5f5; border-radius: 8px; font-family: monospace;">
|
|
212
|
+
<strong>Selected:</strong> {{ selectedValue ? selectedValue.label : 'None' }}
|
|
213
|
+
</div>
|
|
214
|
+
</div>
|
|
215
|
+
`,
|
|
216
|
+
}),
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
export const Preselected: Story = {
|
|
220
|
+
args: {
|
|
221
|
+
options: OPTIONS,
|
|
222
|
+
valueBy: 'id',
|
|
223
|
+
placeholder: 'Preselected option',
|
|
224
|
+
},
|
|
225
|
+
|
|
226
|
+
render: args => ({
|
|
227
|
+
components: { Combobox },
|
|
228
|
+
setup() {
|
|
229
|
+
const selectedValue = ref(OPTIONS[2]);
|
|
230
|
+
|
|
231
|
+
return { args, selectedValue };
|
|
232
|
+
},
|
|
233
|
+
template: `
|
|
234
|
+
<div>
|
|
235
|
+
<Combobox v-bind="args" v-model="selectedValue" />
|
|
236
|
+
<div style="margin-top: 16px; padding: 12px; background: #f5f5f5; border-radius: 8px; font-family: monospace;">
|
|
237
|
+
<strong>Selected:</strong> {{ selectedValue ? selectedValue.label : 'None' }}
|
|
238
|
+
</div>
|
|
239
|
+
</div>
|
|
240
|
+
`,
|
|
241
|
+
}),
|
|
242
|
+
};
|
|
@@ -15,6 +15,8 @@ const props = withDefaults(defineProps<Dropdown>(), {
|
|
|
15
15
|
multiple: false,
|
|
16
16
|
searchable: false,
|
|
17
17
|
emptyLabel: 'No options available',
|
|
18
|
+
position: 'bottom',
|
|
19
|
+
align: 'start',
|
|
18
20
|
});
|
|
19
21
|
|
|
20
22
|
const model = defineModel<SelectedType | SelectedType[] | undefined>();
|
|
@@ -121,6 +123,8 @@ export interface Dropdown {
|
|
|
121
123
|
error?: boolean;
|
|
122
124
|
size?: 'xs' | 'sm' | 'md';
|
|
123
125
|
type?: 'normal' | 'compact' | 'inline' | 'compact-input';
|
|
126
|
+
position?: 'top' | 'bottom';
|
|
127
|
+
align?: 'start' | 'end' | 'center';
|
|
124
128
|
multiple?: boolean;
|
|
125
129
|
emptyLabel?: string;
|
|
126
130
|
searchable?: boolean;
|
|
@@ -209,7 +213,13 @@ export interface SelectedType {
|
|
|
209
213
|
v-if="!disabled"
|
|
210
214
|
force-mount
|
|
211
215
|
dismissable
|
|
216
|
+
:avoid-collisions="true"
|
|
212
217
|
class="celeste-dropdown-content"
|
|
218
|
+
:class="clsx(
|
|
219
|
+
'celeste-dropdown-content',
|
|
220
|
+
`celeste-dropdown-content-size-${position}`,
|
|
221
|
+
`celeste-dropdown-content-align-${align}`,
|
|
222
|
+
)"
|
|
213
223
|
>
|
|
214
224
|
<ComboboxViewport class="celeste-dropdown-items-viewport">
|
|
215
225
|
<div v-if="searchable" class="celeste-dropdown-search">
|
|
@@ -501,8 +511,6 @@ export interface SelectedType {
|
|
|
501
511
|
display: flex;
|
|
502
512
|
position: absolute;
|
|
503
513
|
z-index: 9999;
|
|
504
|
-
top: calc(var(--dropdown-width) + var(--spacing-4));
|
|
505
|
-
left: 0;
|
|
506
514
|
flex-direction: column;
|
|
507
515
|
width: var(--dropdown-width);
|
|
508
516
|
min-width: 300px;
|
|
@@ -528,6 +536,29 @@ export interface SelectedType {
|
|
|
528
536
|
}
|
|
529
537
|
}
|
|
530
538
|
|
|
539
|
+
.celeste-dropdown-content-size-top {
|
|
540
|
+
bottom: calc(var(--dropdown-width) + var(--spacing-4));
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
.celeste-dropdown-content-size-bottom {
|
|
544
|
+
top: calc(var(--dropdown-width) + var(--spacing-4));
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
.celeste-dropdown-content-align-start {
|
|
548
|
+
left: 0;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
.celeste-dropdown-content-align-end {
|
|
552
|
+
right: 0;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
:not(:has(.celeste-dropdown-anchor-trigger-type-normal)) {
|
|
556
|
+
.celeste-dropdown-content-align-center {
|
|
557
|
+
left: 50%;
|
|
558
|
+
transform: translateX(-50%);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
|
|
531
562
|
&:deep(.celeste-input-wrapper .celeste-input-prefix) {
|
|
532
563
|
@include icon-size;
|
|
533
564
|
|
package/src/components/index.ts
CHANGED