@dnax/ui 0.0.15 → 0.0.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/components/QAutocomplete.vue +50 -6
- package/package.json +1 -1
- package/styles/main.css +22 -0
|
@@ -47,6 +47,25 @@ interface Props {
|
|
|
47
47
|
height?: string
|
|
48
48
|
/** Titre du panneau (défaut : label → placeholder) */
|
|
49
49
|
title?: string
|
|
50
|
+
/** Options spécifiques au mode sheet (width, height, title, style, class, searchPlaceholder) */
|
|
51
|
+
sheetOptions?: QAutocompleteModeOptions
|
|
52
|
+
/** Options spécifiques au mode modal */
|
|
53
|
+
modalOptions?: QAutocompleteModeOptions
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface QAutocompleteModeOptions {
|
|
57
|
+
/** Largeur du panneau (remplace width) */
|
|
58
|
+
width?: string
|
|
59
|
+
/** Hauteur de la liste scrollable (remplace height) */
|
|
60
|
+
height?: string
|
|
61
|
+
/** Titre du panneau (remplace title) */
|
|
62
|
+
title?: string
|
|
63
|
+
/** Style appliqué au panneau */
|
|
64
|
+
style?: Record<string, string>
|
|
65
|
+
/** Classes ajoutées au panneau */
|
|
66
|
+
class?: string
|
|
67
|
+
/** Placeholder du champ de recherche du panneau */
|
|
68
|
+
searchPlaceholder?: string
|
|
50
69
|
}
|
|
51
70
|
|
|
52
71
|
const props = withDefaults(defineProps<Props>(), {
|
|
@@ -98,23 +117,42 @@ const activeIndex = ref(0)
|
|
|
98
117
|
// — Mode panneau (modal / sheet) —
|
|
99
118
|
const panelMode = computed(() => props.mode !== "inline")
|
|
100
119
|
|
|
120
|
+
// Options du mode courant (sheet/modal) — surchargent les props directes
|
|
121
|
+
const modeOptions = computed<QAutocompleteModeOptions | undefined>(() => {
|
|
122
|
+
if (props.mode === "sheet") return props.sheetOptions
|
|
123
|
+
if (props.mode === "modal") return props.modalOptions
|
|
124
|
+
return undefined
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
const panelWidth = computed(() => modeOptions.value?.width ?? props.width)
|
|
128
|
+
const panelHeight = computed(() => modeOptions.value?.height ?? props.height)
|
|
129
|
+
const panelSearchPlaceholder = computed(
|
|
130
|
+
() => modeOptions.value?.searchPlaceholder ?? props.placeholder ?? "Search…",
|
|
131
|
+
)
|
|
132
|
+
|
|
101
133
|
// « Retour » navigateur → ferme le panneau au lieu de naviguer
|
|
102
134
|
const panelOpen = computed(() => panelMode.value && open.value)
|
|
103
135
|
useOverlayBack(panelOpen, () => closePopup(), "QAutocomplete")
|
|
104
136
|
|
|
105
137
|
const sheetStyle = computed<Record<string, string>>(() => {
|
|
106
138
|
const style: Record<string, string> = {}
|
|
107
|
-
if (props.mode !== "inline" &&
|
|
139
|
+
if (props.mode !== "inline" && panelWidth.value) {
|
|
140
|
+
// width ET maxWidth : sinon le max-width CSS (640px) plafonne le panneau
|
|
141
|
+
style.width = panelWidth.value
|
|
142
|
+
style.maxWidth = panelWidth.value
|
|
143
|
+
}
|
|
108
144
|
return style
|
|
109
145
|
})
|
|
110
146
|
|
|
111
147
|
const sheetListStyle = computed<Record<string, string>>(() => {
|
|
112
148
|
const style: Record<string, string> = {}
|
|
113
|
-
if (
|
|
149
|
+
if (panelHeight.value) style.height = panelHeight.value
|
|
114
150
|
return style
|
|
115
151
|
})
|
|
116
152
|
|
|
117
|
-
const sheetTitle = computed(
|
|
153
|
+
const sheetTitle = computed(
|
|
154
|
+
() => modeOptions.value?.title ?? props.title ?? props.label ?? props.placeholder ?? "Select",
|
|
155
|
+
)
|
|
118
156
|
|
|
119
157
|
// — Valeurs des options —
|
|
120
158
|
const getValue = (opt: any): any =>
|
|
@@ -322,6 +360,12 @@ watch(open, (v) => {
|
|
|
322
360
|
>
|
|
323
361
|
<Icon :icon="icons.x" aria-hidden="true" />
|
|
324
362
|
</button>
|
|
363
|
+
<Icon
|
|
364
|
+
:icon="icons.chevronDown"
|
|
365
|
+
class="q-autocomplete__arrow"
|
|
366
|
+
:class="{ 'q-autocomplete__arrow--rotated': open }"
|
|
367
|
+
aria-hidden="true"
|
|
368
|
+
/>
|
|
325
369
|
</div>
|
|
326
370
|
<div v-if="error" class="q-field__bottom">
|
|
327
371
|
<div class="q-field__error">
|
|
@@ -378,8 +422,8 @@ watch(open, (v) => {
|
|
|
378
422
|
<div
|
|
379
423
|
ref="sheetRef"
|
|
380
424
|
class="q-autocomplete__sheet"
|
|
381
|
-
:class="`q-autocomplete__sheet--${mode}
|
|
382
|
-
:style="sheetStyle"
|
|
425
|
+
:class="[`q-autocomplete__sheet--${mode}`, modeOptions?.class]"
|
|
426
|
+
:style="[sheetStyle, modeOptions?.style]"
|
|
383
427
|
role="dialog"
|
|
384
428
|
aria-modal="true"
|
|
385
429
|
:aria-label="sheetTitle"
|
|
@@ -401,7 +445,7 @@ watch(open, (v) => {
|
|
|
401
445
|
ref="panelInput"
|
|
402
446
|
class="q-autocomplete__search-input"
|
|
403
447
|
:value="query"
|
|
404
|
-
:placeholder="
|
|
448
|
+
:placeholder="panelSearchPlaceholder"
|
|
405
449
|
role="combobox"
|
|
406
450
|
:aria-expanded="open ? 'true' : 'false'"
|
|
407
451
|
aria-autocomplete="list"
|
package/package.json
CHANGED
package/styles/main.css
CHANGED
|
@@ -3366,6 +3366,18 @@ html.dark body {
|
|
|
3366
3366
|
flex-shrink: 0;
|
|
3367
3367
|
}
|
|
3368
3368
|
|
|
3369
|
+
.q-autocomplete__arrow {
|
|
3370
|
+
width: 18px;
|
|
3371
|
+
height: 18px;
|
|
3372
|
+
flex-shrink: 0;
|
|
3373
|
+
color: rgb(0 0 0 / 0.6);
|
|
3374
|
+
transition: transform 0.2s ease;
|
|
3375
|
+
}
|
|
3376
|
+
|
|
3377
|
+
.q-autocomplete__arrow--rotated {
|
|
3378
|
+
transform: rotate(180deg);
|
|
3379
|
+
}
|
|
3380
|
+
|
|
3369
3381
|
.q-autocomplete__popup {
|
|
3370
3382
|
position: absolute;
|
|
3371
3383
|
top: calc(100% + 4px);
|
|
@@ -3456,6 +3468,16 @@ html.dark body {
|
|
|
3456
3468
|
padding-bottom: constant(safe-area-inset-bottom);
|
|
3457
3469
|
padding-bottom: env(safe-area-inset-bottom);
|
|
3458
3470
|
}
|
|
3471
|
+
|
|
3472
|
+
/* écran < md (768px, convention Tailwind/shadcn) : le sheet prend 100% de la
|
|
3473
|
+
largeur par défaut — tant qu'aucun width n'est fourni (un width inline
|
|
3474
|
+
via sheetOptions/modalOptions ou la prop width prime sur cette règle) */
|
|
3475
|
+
@media (max-width: 767px) {
|
|
3476
|
+
.q-autocomplete__sheet--sheet {
|
|
3477
|
+
width: 100%;
|
|
3478
|
+
max-width: 100%;
|
|
3479
|
+
}
|
|
3480
|
+
}
|
|
3459
3481
|
.q-autocomplete__sheet-header {
|
|
3460
3482
|
display: flex;
|
|
3461
3483
|
align-items: center;
|