@dnax/ui 0.0.15 → 0.0.16
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 +44 -6
- package/package.json +1 -1
- package/styles/main.css +10 -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 =>
|
|
@@ -378,8 +416,8 @@ watch(open, (v) => {
|
|
|
378
416
|
<div
|
|
379
417
|
ref="sheetRef"
|
|
380
418
|
class="q-autocomplete__sheet"
|
|
381
|
-
:class="`q-autocomplete__sheet--${mode}
|
|
382
|
-
:style="sheetStyle"
|
|
419
|
+
:class="[`q-autocomplete__sheet--${mode}`, modeOptions?.class]"
|
|
420
|
+
:style="[sheetStyle, modeOptions?.style]"
|
|
383
421
|
role="dialog"
|
|
384
422
|
aria-modal="true"
|
|
385
423
|
:aria-label="sheetTitle"
|
|
@@ -401,7 +439,7 @@ watch(open, (v) => {
|
|
|
401
439
|
ref="panelInput"
|
|
402
440
|
class="q-autocomplete__search-input"
|
|
403
441
|
:value="query"
|
|
404
|
-
:placeholder="
|
|
442
|
+
:placeholder="panelSearchPlaceholder"
|
|
405
443
|
role="combobox"
|
|
406
444
|
:aria-expanded="open ? 'true' : 'false'"
|
|
407
445
|
aria-autocomplete="list"
|
package/package.json
CHANGED
package/styles/main.css
CHANGED
|
@@ -3456,6 +3456,16 @@ html.dark body {
|
|
|
3456
3456
|
padding-bottom: constant(safe-area-inset-bottom);
|
|
3457
3457
|
padding-bottom: env(safe-area-inset-bottom);
|
|
3458
3458
|
}
|
|
3459
|
+
|
|
3460
|
+
/* écran < md (768px, convention Tailwind/shadcn) : le sheet prend 100% de la
|
|
3461
|
+
largeur par défaut — tant qu'aucun width n'est fourni (un width inline
|
|
3462
|
+
via sheetOptions/modalOptions ou la prop width prime sur cette règle) */
|
|
3463
|
+
@media (max-width: 767px) {
|
|
3464
|
+
.q-autocomplete__sheet--sheet {
|
|
3465
|
+
width: 100%;
|
|
3466
|
+
max-width: 100%;
|
|
3467
|
+
}
|
|
3468
|
+
}
|
|
3459
3469
|
.q-autocomplete__sheet-header {
|
|
3460
3470
|
display: flex;
|
|
3461
3471
|
align-items: center;
|