socle-ui 0.0.0-stage → 0.4.2
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/CHANGELOG.md +167 -0
- package/LICENSE +21 -0
- package/README.md +255 -2
- package/SocleDatePicker.vue +659 -0
- package/SocleDialog.vue +250 -0
- package/SocleField.vue +72 -0
- package/SocleInput.vue +164 -0
- package/SoclePopover.vue +171 -0
- package/SocleSelect.vue +331 -0
- package/SocleTableHead.vue +336 -0
- package/SocleTabs.vue +226 -0
- package/classes.ts +18 -0
- package/index.ts +13 -0
- package/package.json +51 -4
- package/socle.css +356 -0
- package/table.ts +120 -0
- package/tailwind.css +190 -0
package/SocleTabs.vue
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
SocleTabs.vue
|
|
3
|
+
Onglets accessibles (motif WAI-ARIA « Tabs ») : role="tablist" / "tab" / "tabpanel",
|
|
4
|
+
tabindex itinérant, navigation aux flèches, Début / Fin.
|
|
5
|
+
Prérequis : Vue >= 3.5 (useId, generics), Tailwind CSS v4.
|
|
6
|
+
|
|
7
|
+
<SocleTabs
|
|
8
|
+
v-model="tab"
|
|
9
|
+
aria-label="Fiche client"
|
|
10
|
+
:tabs="[
|
|
11
|
+
{ value: 'general', label: 'Général' },
|
|
12
|
+
{ value: 'orders', label: 'Commandes' },
|
|
13
|
+
{ value: 'archive', label: 'Archives', disabled: true },
|
|
14
|
+
]"
|
|
15
|
+
>
|
|
16
|
+
<template #general>…</template>
|
|
17
|
+
<template #orders>…</template>
|
|
18
|
+
</SocleTabs>
|
|
19
|
+
|
|
20
|
+
- Panneaux masqués par `hidden="until-found"` : la recherche du navigateur (Ctrl+F) trouve aussi
|
|
21
|
+
le texte des onglets masqués, et l'événement `beforematch` sélectionne l'onglet concerné.
|
|
22
|
+
- Contenu d'un panneau : slot nommé d'après la `value` de l'onglet, sinon slot par défaut ({ tab }).
|
|
23
|
+
- activation : `auto` (l'onglet est sélectionné dès qu'il reçoit le focus) ou `manual`
|
|
24
|
+
(les flèches déplacent le focus, Entrée / Espace sélectionnent).
|
|
25
|
+
- lazy : un panneau n'est rendu qu'à sa première sélection (puis conservé).
|
|
26
|
+
|
|
27
|
+
-->
|
|
28
|
+
<script setup lang="ts" generic="T extends string | number">
|
|
29
|
+
import { computed, reactive, useId, watch } from 'vue'
|
|
30
|
+
|
|
31
|
+
export interface TabItem<V> {
|
|
32
|
+
value: V
|
|
33
|
+
label: string
|
|
34
|
+
disabled?: boolean
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type TabsOrientation = 'horizontal' | 'vertical'
|
|
38
|
+
export type TabsActivation = 'auto' | 'manual'
|
|
39
|
+
|
|
40
|
+
const props = withDefaults(
|
|
41
|
+
defineProps<{
|
|
42
|
+
tabs: TabItem<T>[]
|
|
43
|
+
/** Disposition : onglets au-dessus (horizontal) ou à gauche (vertical) des panneaux. */
|
|
44
|
+
orientation?: TabsOrientation
|
|
45
|
+
/** auto : le focus sélectionne l'onglet ; manual : Entrée / Espace pour sélectionner. */
|
|
46
|
+
activation?: TabsActivation
|
|
47
|
+
/** Ne rend un panneau qu'à sa première sélection (le contenu est ensuite conservé). */
|
|
48
|
+
lazy?: boolean
|
|
49
|
+
/** Nom accessible de la liste d'onglets. */
|
|
50
|
+
ariaLabel?: string
|
|
51
|
+
/** Id d'un élément visible qui nomme la liste d'onglets (prioritaire sur ariaLabel). */
|
|
52
|
+
ariaLabelledby?: string
|
|
53
|
+
}>(),
|
|
54
|
+
{ orientation: 'horizontal', activation: 'auto', lazy: false },
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
const model = defineModel<T | null>({ default: null })
|
|
58
|
+
|
|
59
|
+
type SlotProps = { tab: TabItem<T>; selected: boolean }
|
|
60
|
+
|
|
61
|
+
defineSlots<
|
|
62
|
+
{
|
|
63
|
+
/** Rendu personnalisé du libellé d'un onglet. */
|
|
64
|
+
tab?(props: SlotProps): unknown
|
|
65
|
+
/** Contenu d'un panneau qui n'a pas de slot nommé d'après sa valeur. */
|
|
66
|
+
default?(props: SlotProps): unknown
|
|
67
|
+
} & {
|
|
68
|
+
/** Contenu du panneau dont la `value` est le nom du slot. */
|
|
69
|
+
[value: string]: ((props: SlotProps) => unknown) | undefined
|
|
70
|
+
}
|
|
71
|
+
>()
|
|
72
|
+
|
|
73
|
+
/* ---------- Identifiants ---------- */
|
|
74
|
+
const uid = useId()
|
|
75
|
+
const tabId = (i: number) => `${uid}-tab-${i}`
|
|
76
|
+
const panelId = (i: number) => `${uid}-panel-${i}`
|
|
77
|
+
|
|
78
|
+
/* ---------- Sélection ---------- */
|
|
79
|
+
const firstEnabled = () => props.tabs.findIndex((t) => !t.disabled)
|
|
80
|
+
|
|
81
|
+
const selectedIndex = computed(() => {
|
|
82
|
+
const i = props.tabs.findIndex((t) => t.value === model.value)
|
|
83
|
+
return i >= 0 && !props.tabs[i]!.disabled ? i : firstEnabled()
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
// v-model vide, inconnu ou désactivé : on le remet sur l'onglet réellement affiché.
|
|
87
|
+
watch(
|
|
88
|
+
selectedIndex,
|
|
89
|
+
(i) => {
|
|
90
|
+
const tab = props.tabs[i]
|
|
91
|
+
if (tab && tab.value !== model.value) model.value = tab.value
|
|
92
|
+
},
|
|
93
|
+
{ immediate: true },
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
/** Panneaux déjà affichés (mode lazy). */
|
|
97
|
+
const visited = reactive(new Set()) as Set<T>
|
|
98
|
+
watch(
|
|
99
|
+
() => props.tabs[selectedIndex.value]?.value,
|
|
100
|
+
(v) => {
|
|
101
|
+
if (v !== undefined) visited.add(v)
|
|
102
|
+
},
|
|
103
|
+
{ immediate: true },
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
function select(i: number) {
|
|
107
|
+
const tab = props.tabs[i]
|
|
108
|
+
if (tab && !tab.disabled) model.value = tab.value
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/* ---------- Clavier ---------- */
|
|
112
|
+
|
|
113
|
+
/** Prochain onglet actif dans la direction donnée, en bouclant ; -1 si aucun. */
|
|
114
|
+
function nextEnabled(from: number, dir: 1 | -1): number {
|
|
115
|
+
const n = props.tabs.length
|
|
116
|
+
for (let k = 1; k <= n; k++) {
|
|
117
|
+
const i = (((from + dir * k) % n) + n) % n
|
|
118
|
+
if (!props.tabs[i]!.disabled) return i
|
|
119
|
+
}
|
|
120
|
+
return -1
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function focusTab(i: number) {
|
|
124
|
+
if (i < 0) return
|
|
125
|
+
document.getElementById(tabId(i))?.focus()
|
|
126
|
+
if (props.activation === 'auto') select(i)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function onKeydown(e: KeyboardEvent, i: number) {
|
|
130
|
+
const vertical = props.orientation === 'vertical'
|
|
131
|
+
const rtl = getComputedStyle(e.currentTarget as Element).direction === 'rtl'
|
|
132
|
+
const prevKey = vertical ? 'ArrowUp' : rtl ? 'ArrowRight' : 'ArrowLeft'
|
|
133
|
+
const nextKey = vertical ? 'ArrowDown' : rtl ? 'ArrowLeft' : 'ArrowRight'
|
|
134
|
+
|
|
135
|
+
let target: number
|
|
136
|
+
switch (e.key) {
|
|
137
|
+
case prevKey:
|
|
138
|
+
target = nextEnabled(i, -1)
|
|
139
|
+
break
|
|
140
|
+
case nextKey:
|
|
141
|
+
target = nextEnabled(i, 1)
|
|
142
|
+
break
|
|
143
|
+
case 'Home':
|
|
144
|
+
target = nextEnabled(-1, 1)
|
|
145
|
+
break
|
|
146
|
+
case 'End':
|
|
147
|
+
target = nextEnabled(props.tabs.length, -1)
|
|
148
|
+
break
|
|
149
|
+
default:
|
|
150
|
+
return // Entrée / Espace : clic natif du bouton
|
|
151
|
+
}
|
|
152
|
+
e.preventDefault()
|
|
153
|
+
focusTab(target)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/* ---------- Classes (exclusives : pas de conflit d'ordre CSS Tailwind) ---------- */
|
|
157
|
+
const vertical = computed(() => props.orientation === 'vertical')
|
|
158
|
+
|
|
159
|
+
function tabClass(i: number) {
|
|
160
|
+
return [
|
|
161
|
+
vertical.value ? '-me-px rounded-s-socle-sm border-e-2 text-start' : 'rounded-t-socle-sm border-b-2',
|
|
162
|
+
i === selectedIndex.value
|
|
163
|
+
? 'border-socle-accent text-socle-accent-text'
|
|
164
|
+
: 'border-transparent text-socle-text-muted enabled:hover:border-socle-border enabled:hover:text-socle-text',
|
|
165
|
+
]
|
|
166
|
+
}
|
|
167
|
+
</script>
|
|
168
|
+
|
|
169
|
+
<template>
|
|
170
|
+
<div :class="vertical ? 'flex' : ''">
|
|
171
|
+
<div
|
|
172
|
+
role="tablist"
|
|
173
|
+
:aria-label="ariaLabelledby ? undefined : ariaLabel"
|
|
174
|
+
:aria-labelledby="ariaLabelledby"
|
|
175
|
+
:aria-orientation="vertical ? 'vertical' : undefined"
|
|
176
|
+
:class="
|
|
177
|
+
vertical
|
|
178
|
+
? 'flex shrink-0 flex-col border-e border-socle-border-subtle'
|
|
179
|
+
: 'flex overflow-x-auto shadow-[inset_0_-1px_0_var(--socle-color-border-subtle)]'
|
|
180
|
+
"
|
|
181
|
+
>
|
|
182
|
+
<button
|
|
183
|
+
v-for="(t, i) in tabs"
|
|
184
|
+
:id="tabId(i)"
|
|
185
|
+
:key="t.value"
|
|
186
|
+
type="button"
|
|
187
|
+
role="tab"
|
|
188
|
+
:aria-selected="i === selectedIndex"
|
|
189
|
+
:aria-controls="panelId(i)"
|
|
190
|
+
:tabindex="i === selectedIndex ? 0 : -1"
|
|
191
|
+
:disabled="t.disabled"
|
|
192
|
+
class="cursor-pointer whitespace-nowrap px-3 py-2 text-sm font-medium outline-none transition-colors focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-socle-accent/40 disabled:cursor-not-allowed disabled:opacity-40"
|
|
193
|
+
:class="tabClass(i)"
|
|
194
|
+
@click="select(i)"
|
|
195
|
+
@keydown="onKeydown($event, i)"
|
|
196
|
+
>
|
|
197
|
+
<slot name="tab" :tab="t" :selected="i === selectedIndex">{{ t.label }}</slot>
|
|
198
|
+
</button>
|
|
199
|
+
</div>
|
|
200
|
+
|
|
201
|
+
<div :class="vertical ? 'min-w-0 flex-1' : ''">
|
|
202
|
+
<!--
|
|
203
|
+
Panneau masqué : hidden="until-found" (repli : hidden simple pour un onglet désactivé,
|
|
204
|
+
que la recherche ne doit pas révéler). Aucune marge ni bordure sur le panneau lui-même :
|
|
205
|
+
masqué, il garde sa boîte (content-visibility: hidden) ; l'espacement est sur le contenu.
|
|
206
|
+
-->
|
|
207
|
+
<div
|
|
208
|
+
v-for="(t, i) in tabs"
|
|
209
|
+
:id="panelId(i)"
|
|
210
|
+
:key="t.value"
|
|
211
|
+
role="tabpanel"
|
|
212
|
+
:aria-labelledby="tabId(i)"
|
|
213
|
+
tabindex="0"
|
|
214
|
+
:hidden="i === selectedIndex ? false : t.disabled ? true : 'until-found'"
|
|
215
|
+
class="rounded-socle-sm outline-none focus-visible:ring-2 focus-visible:ring-socle-accent/40"
|
|
216
|
+
@beforematch="select(i)"
|
|
217
|
+
>
|
|
218
|
+
<div v-if="!lazy || visited.has(t.value)" :class="vertical ? 'ps-6' : 'pt-4'">
|
|
219
|
+
<slot :name="String(t.value)" :tab="t" :selected="i === selectedIndex">
|
|
220
|
+
<slot :tab="t" :selected="i === selectedIndex" />
|
|
221
|
+
</slot>
|
|
222
|
+
</div>
|
|
223
|
+
</div>
|
|
224
|
+
</div>
|
|
225
|
+
</div>
|
|
226
|
+
</template>
|
package/classes.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
classes.ts — classes Tailwind communes aux composants Socle.
|
|
3
|
+
|
|
4
|
+
Remplacé par l'utilitaire `socle-field-box`, défini dans tailwind.css.
|
|
5
|
+
Conservé pour ne pas casser les imports existants : sera retiré dans une prochaine version.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** @deprecated Sans effet : l'utilitaire `socle-field-box` détecte lui-même le mode de focus. */
|
|
9
|
+
export type FocusMode = 'within' | 'visible'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Écrire directement la classe `socle-field-box` (définie dans `socle-ui/tailwind.css`).
|
|
13
|
+
* Les options sont ignorées : l'utilitaire lit l'état dans le DOM. L'erreur demande
|
|
14
|
+
* `aria-invalid="true"`, la désactivation `disabled`, sur le cadre ou sur un enfant direct.
|
|
15
|
+
*/
|
|
16
|
+
export function fieldBoxClass(_options?: { focus?: FocusMode; error?: string | boolean; disabled?: boolean }) {
|
|
17
|
+
return 'socle-field-box'
|
|
18
|
+
}
|
package/index.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { default as SocleDatePicker } from './SocleDatePicker.vue'
|
|
2
|
+
export { default as SocleDialog } from './SocleDialog.vue'
|
|
3
|
+
export { default as SocleField } from './SocleField.vue'
|
|
4
|
+
export { default as SocleInput } from './SocleInput.vue'
|
|
5
|
+
export { default as SoclePopover } from './SoclePopover.vue'
|
|
6
|
+
export { default as SocleSelect } from './SocleSelect.vue'
|
|
7
|
+
export { default as SocleTableHead } from './SocleTableHead.vue'
|
|
8
|
+
export { default as SocleTabs } from './SocleTabs.vue'
|
|
9
|
+
export type { PopoverAlign, PopoverPlacement } from './SoclePopover.vue'
|
|
10
|
+
export type { SelectOption } from './SocleSelect.vue'
|
|
11
|
+
export type { TabItem, TabsActivation, TabsOrientation } from './SocleTabs.vue'
|
|
12
|
+
export { sortRows } from './table'
|
|
13
|
+
export type { ColumnType, SortDirection, TableColumn, TableSort } from './table'
|
package/package.json
CHANGED
|
@@ -1,6 +1,53 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "socle-ui",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.4.2",
|
|
4
|
+
"description": "Composants Vue 3 accessibles, bâtis sur les éléments natifs du navigateur (<dialog>, popover, CSS Anchor Positioning).",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Marc DUREN",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/marcduren/socle-ui.git"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/marcduren/socle-ui#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/marcduren/socle-ui/issues"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "./index.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": "./index.ts",
|
|
19
|
+
"./*.vue": "./*.vue",
|
|
20
|
+
"./socle.css": "./socle.css",
|
|
21
|
+
"./tailwind.css": "./tailwind.css",
|
|
22
|
+
"./classes": "./classes.ts",
|
|
23
|
+
"./table": "./table.ts"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"index.ts",
|
|
27
|
+
"classes.ts",
|
|
28
|
+
"table.ts",
|
|
29
|
+
"*.vue",
|
|
30
|
+
"socle.css",
|
|
31
|
+
"tailwind.css",
|
|
32
|
+
"CHANGELOG.md"
|
|
33
|
+
],
|
|
34
|
+
"sideEffects": [
|
|
35
|
+
"*.vue",
|
|
36
|
+
"*.css"
|
|
37
|
+
],
|
|
38
|
+
"keywords": [
|
|
39
|
+
"vue",
|
|
40
|
+
"components",
|
|
41
|
+
"tailwindcss",
|
|
42
|
+
"accessibility",
|
|
43
|
+
"dialog",
|
|
44
|
+
"popover",
|
|
45
|
+
"tabs",
|
|
46
|
+
"table",
|
|
47
|
+
"anchor-positioning"
|
|
48
|
+
],
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"tailwindcss": "^4.0.0",
|
|
51
|
+
"vue": "^3.5.0"
|
|
52
|
+
}
|
|
53
|
+
}
|
package/socle.css
ADDED
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
/*
|
|
2
|
+
socle.css — styles communs des composants Socle.
|
|
3
|
+
Ce qui ne s'exprime pas en utilitaires Tailwind : animations d'ouverture / fermeture,
|
|
4
|
+
::backdrop, CSS Anchor Positioning.
|
|
5
|
+
Styles globaux : toutes les classes sont préfixées par `socle-`.
|
|
6
|
+
Importé par chaque composant (le bundler ne l'inclut qu'une fois).
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/* ===================== SocleDialog ===================== */
|
|
10
|
+
|
|
11
|
+
/*
|
|
12
|
+
Animation d'ouverture / fermeture. `translate` (déplacement) et `scale` (animation)
|
|
13
|
+
sont deux propriétés indépendantes : glisser la boîte n'est jamais ralenti par une transition.
|
|
14
|
+
display / overlay en allow-discrete permettent aussi la transition de sortie.
|
|
15
|
+
*/
|
|
16
|
+
.socle-dialog {
|
|
17
|
+
opacity: 0;
|
|
18
|
+
scale: 0.97;
|
|
19
|
+
transition:
|
|
20
|
+
opacity 150ms ease,
|
|
21
|
+
scale 150ms ease,
|
|
22
|
+
display 150ms allow-discrete,
|
|
23
|
+
overlay 150ms allow-discrete;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.socle-dialog[open] {
|
|
27
|
+
opacity: 1;
|
|
28
|
+
scale: 1;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@starting-style {
|
|
32
|
+
.socle-dialog[open] {
|
|
33
|
+
opacity: 0;
|
|
34
|
+
scale: 0.97;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.socle-dialog::backdrop {
|
|
39
|
+
background: var(--socle-color-backdrop, rgb(15 23 42 / 0.4));
|
|
40
|
+
opacity: 0;
|
|
41
|
+
transition:
|
|
42
|
+
opacity 150ms ease,
|
|
43
|
+
display 150ms allow-discrete,
|
|
44
|
+
overlay 150ms allow-discrete;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.socle-dialog[open]::backdrop {
|
|
48
|
+
opacity: 1;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@starting-style {
|
|
52
|
+
.socle-dialog[open]::backdrop {
|
|
53
|
+
opacity: 0;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@media (prefers-reduced-motion: reduce) {
|
|
58
|
+
.socle-dialog,
|
|
59
|
+
.socle-dialog::backdrop {
|
|
60
|
+
transition: none;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/* Bloque le défilement de la page tant qu'une boîte modale est ouverte */
|
|
65
|
+
html:has(.socle-dialog:modal) {
|
|
66
|
+
overflow: hidden;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* ===================== SocleSelect ===================== */
|
|
70
|
+
|
|
71
|
+
/*
|
|
72
|
+
Cœur de l'ancrage : tout le positionnement est déclaratif.
|
|
73
|
+
--socle-anchor (posée sur le conteneur) est héritée par le bouton ET par la liste.
|
|
74
|
+
*/
|
|
75
|
+
.socle-select-trigger {
|
|
76
|
+
anchor-name: var(--socle-anchor);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.socle-select-listbox {
|
|
80
|
+
/* Neutralise les styles par défaut de [popover] (inset: 0; margin: auto) */
|
|
81
|
+
inset: auto;
|
|
82
|
+
margin: 0;
|
|
83
|
+
margin-block: 0.25rem;
|
|
84
|
+
|
|
85
|
+
position-anchor: var(--socle-anchor);
|
|
86
|
+
/* Sous le bouton, bord de début aligné (s'étend vers la fin de ligne) */
|
|
87
|
+
position-area: block-end span-inline-end;
|
|
88
|
+
/* Même largeur que le bouton */
|
|
89
|
+
width: anchor-size(width);
|
|
90
|
+
|
|
91
|
+
/* Pas assez de place en bas ? Le navigateur retourne la liste au-dessus,
|
|
92
|
+
en choisissant le côté qui offre le plus de hauteur. */
|
|
93
|
+
position-try-order: most-height;
|
|
94
|
+
position-try-fallbacks: flip-block;
|
|
95
|
+
/* Masque la liste si le bouton sort de la zone visible (scroll d'un parent) */
|
|
96
|
+
position-visibility: anchors-visible;
|
|
97
|
+
|
|
98
|
+
/* 100% = hauteur de la zone disponible définie par position-area */
|
|
99
|
+
max-height: min(18rem, 100%);
|
|
100
|
+
|
|
101
|
+
/* Animation d'ouverture ; `display` et `overlay` en allow-discrete
|
|
102
|
+
permettent aussi la transition de sortie. */
|
|
103
|
+
opacity: 0;
|
|
104
|
+
translate: 0 -0.25rem;
|
|
105
|
+
transition:
|
|
106
|
+
opacity 120ms ease,
|
|
107
|
+
translate 120ms ease,
|
|
108
|
+
display 120ms allow-discrete,
|
|
109
|
+
overlay 120ms allow-discrete;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.socle-select-listbox:popover-open {
|
|
113
|
+
opacity: 1;
|
|
114
|
+
translate: 0 0;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@starting-style {
|
|
118
|
+
.socle-select-listbox:popover-open {
|
|
119
|
+
opacity: 0;
|
|
120
|
+
translate: 0 -0.25rem;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
@media (prefers-reduced-motion: reduce) {
|
|
125
|
+
.socle-select-listbox {
|
|
126
|
+
transition: none;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/* ===================== SocleDatePicker ===================== */
|
|
131
|
+
|
|
132
|
+
/*
|
|
133
|
+
Ancrage : --socle-anchor (posée sur le conteneur) est héritée par le bouton ET par le popover.
|
|
134
|
+
*/
|
|
135
|
+
.socle-datepicker-trigger {
|
|
136
|
+
anchor-name: var(--socle-anchor);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.socle-datepicker-popover {
|
|
140
|
+
/* Neutralise les styles par défaut de [popover] (inset: 0; margin: auto) */
|
|
141
|
+
inset: auto;
|
|
142
|
+
margin: 0;
|
|
143
|
+
margin-block: 0.25rem;
|
|
144
|
+
|
|
145
|
+
position-anchor: var(--socle-anchor);
|
|
146
|
+
/* Sous le bouton, bord de début aligné (s'étend vers la fin de ligne) */
|
|
147
|
+
position-area: block-end span-inline-end;
|
|
148
|
+
|
|
149
|
+
/* Taille fixe du calendrier (7 colonnes de 2.25rem + padding) */
|
|
150
|
+
width: 19.5rem;
|
|
151
|
+
max-width: calc(100vw - 1rem);
|
|
152
|
+
|
|
153
|
+
/* Pas de place en bas → au-dessus ; pas de place à droite → aligné à droite du bouton. */
|
|
154
|
+
position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline;
|
|
155
|
+
/* Masque le calendrier si le bouton sort de la zone visible (scroll d'un parent) */
|
|
156
|
+
position-visibility: anchors-visible;
|
|
157
|
+
|
|
158
|
+
/* Animation d'ouverture ; display/overlay en allow-discrete permettent aussi la sortie. */
|
|
159
|
+
opacity: 0;
|
|
160
|
+
translate: 0 -0.25rem;
|
|
161
|
+
transition:
|
|
162
|
+
opacity 120ms ease,
|
|
163
|
+
translate 120ms ease,
|
|
164
|
+
display 120ms allow-discrete,
|
|
165
|
+
overlay 120ms allow-discrete;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.socle-datepicker-popover:popover-open {
|
|
169
|
+
opacity: 1;
|
|
170
|
+
translate: 0 0;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
@starting-style {
|
|
174
|
+
.socle-datepicker-popover:popover-open {
|
|
175
|
+
opacity: 0;
|
|
176
|
+
translate: 0 -0.25rem;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
@media (prefers-reduced-motion: reduce) {
|
|
181
|
+
.socle-datepicker-popover {
|
|
182
|
+
transition: none;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/* ===================== SocleTableHead ===================== */
|
|
187
|
+
|
|
188
|
+
/* Pendant un redimensionnement : curseur partout et pas de sélection de texte. */
|
|
189
|
+
html.socle-table-resizing,
|
|
190
|
+
html.socle-table-resizing * {
|
|
191
|
+
cursor: col-resize !important;
|
|
192
|
+
user-select: none !important;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/* ===================== SoclePopover ===================== */
|
|
196
|
+
|
|
197
|
+
/*
|
|
198
|
+
Ancrage : le bouton porte `anchor-name` (via les props du slot), le panneau reçoit
|
|
199
|
+
--socle-anchor. Le placement est déclaratif (data-placement / data-align) :
|
|
200
|
+
`position-area` place le panneau, `position-try-fallbacks` le retourne si la place manque.
|
|
201
|
+
Centrage : `span-all` + `anchor-center` plutôt que `center`, dont la zone n'a que la taille
|
|
202
|
+
du bouton : un panneau plus large y « déborderait » toujours et ne serait jamais retourné.
|
|
203
|
+
|
|
204
|
+
Personnalisation (variables CSS, à poser sur le panneau via `class` ou `style`) :
|
|
205
|
+
--socle-popover-offset écart entre le bouton et le panneau
|
|
206
|
+
--socle-popover-padding marge intérieure du contenu (défaut 0.75rem)
|
|
207
|
+
--socle-popover-max-width largeur maximale (défaut min(24rem, 100vw - 1rem))
|
|
208
|
+
--socle-popover-arrow-size côté du carré qui forme la flèche (défaut 0.75rem)
|
|
209
|
+
*/
|
|
210
|
+
.socle-popover {
|
|
211
|
+
--_offset: var(--socle-popover-offset, 0.375rem);
|
|
212
|
+
--_arrow: var(--socle-popover-arrow-size, 0.75rem);
|
|
213
|
+
/* Distance entre le bord du panneau et la pointe de la flèche quand align = start / end */
|
|
214
|
+
--_arrow-inset: 1.25rem;
|
|
215
|
+
|
|
216
|
+
/* Neutralise les styles par défaut de [popover] (inset: 0; margin: auto; padding; overflow) */
|
|
217
|
+
inset: auto;
|
|
218
|
+
margin: 0;
|
|
219
|
+
padding: 0;
|
|
220
|
+
overflow: visible;
|
|
221
|
+
|
|
222
|
+
position-anchor: var(--socle-anchor);
|
|
223
|
+
/* Masque le panneau si le bouton sort de la zone visible (scroll d'un parent) */
|
|
224
|
+
position-visibility: anchors-visible;
|
|
225
|
+
|
|
226
|
+
max-width: var(--socle-popover-max-width, min(24rem, 100vw - 1rem));
|
|
227
|
+
|
|
228
|
+
/* La flèche (descendante) interroge le panneau : a-t-il été retourné ? */
|
|
229
|
+
container-type: anchored;
|
|
230
|
+
|
|
231
|
+
/* Animation d'ouverture ; display/overlay en allow-discrete permettent aussi la sortie. */
|
|
232
|
+
opacity: 0;
|
|
233
|
+
scale: 0.96;
|
|
234
|
+
transition:
|
|
235
|
+
opacity 120ms ease,
|
|
236
|
+
scale 120ms ease,
|
|
237
|
+
display 120ms allow-discrete,
|
|
238
|
+
overlay 120ms allow-discrete;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.socle-popover:popover-open {
|
|
242
|
+
display: flex;
|
|
243
|
+
flex-direction: column;
|
|
244
|
+
opacity: 1;
|
|
245
|
+
scale: 1;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
@starting-style {
|
|
249
|
+
.socle-popover:popover-open {
|
|
250
|
+
opacity: 0;
|
|
251
|
+
scale: 0.96;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
@media (prefers-reduced-motion: reduce) {
|
|
256
|
+
.socle-popover {
|
|
257
|
+
transition: none;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/* --- Placement : au-dessus / en dessous --- */
|
|
262
|
+
.socle-popover:is([data-placement="bottom"], [data-placement="top"]) {
|
|
263
|
+
margin-block: var(--_offset);
|
|
264
|
+
/* Pas de max-height ici : un panneau qui déborde déclenche le retournement ;
|
|
265
|
+
plafonné, il rapetisserait au lieu de se retourner. */
|
|
266
|
+
position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.socle-popover[data-placement="bottom"] { --_y: 0%; }
|
|
270
|
+
.socle-popover[data-placement="top"] { --_y: 100%; }
|
|
271
|
+
|
|
272
|
+
.socle-popover[data-placement="bottom"][data-align="start"] { position-area: bottom span-right; }
|
|
273
|
+
.socle-popover[data-placement="bottom"][data-align="center"] { position-area: bottom span-all; justify-self: anchor-center; }
|
|
274
|
+
.socle-popover[data-placement="bottom"][data-align="end"] { position-area: bottom span-left; }
|
|
275
|
+
.socle-popover[data-placement="top"][data-align="start"] { position-area: top span-right; }
|
|
276
|
+
.socle-popover[data-placement="top"][data-align="center"] { position-area: top span-all; justify-self: anchor-center; }
|
|
277
|
+
.socle-popover[data-placement="top"][data-align="end"] { position-area: top span-left; }
|
|
278
|
+
|
|
279
|
+
.socle-popover:is([data-placement="bottom"], [data-placement="top"])[data-align="start"] { --_x: var(--_arrow-inset); }
|
|
280
|
+
.socle-popover:is([data-placement="bottom"], [data-placement="top"])[data-align="center"] { --_x: 50%; }
|
|
281
|
+
.socle-popover:is([data-placement="bottom"], [data-placement="top"])[data-align="end"] { --_x: calc(100% - var(--_arrow-inset)); }
|
|
282
|
+
|
|
283
|
+
/* --- Placement : à gauche / à droite --- */
|
|
284
|
+
.socle-popover:is([data-placement="left"], [data-placement="right"]) {
|
|
285
|
+
margin-inline: var(--_offset);
|
|
286
|
+
position-try-fallbacks: flip-inline, flip-block, flip-inline flip-block;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.socle-popover[data-placement="right"] { --_x: 0%; }
|
|
290
|
+
.socle-popover[data-placement="left"] { --_x: 100%; }
|
|
291
|
+
|
|
292
|
+
.socle-popover[data-placement="right"][data-align="start"] { position-area: right span-bottom; }
|
|
293
|
+
.socle-popover[data-placement="right"][data-align="center"] { position-area: right span-all; align-self: anchor-center; }
|
|
294
|
+
.socle-popover[data-placement="right"][data-align="end"] { position-area: right span-top; }
|
|
295
|
+
.socle-popover[data-placement="left"][data-align="start"] { position-area: left span-bottom; }
|
|
296
|
+
.socle-popover[data-placement="left"][data-align="center"] { position-area: left span-all; align-self: anchor-center; }
|
|
297
|
+
.socle-popover[data-placement="left"][data-align="end"] { position-area: left span-top; }
|
|
298
|
+
|
|
299
|
+
.socle-popover:is([data-placement="left"], [data-placement="right"])[data-align="start"] { --_y: var(--_arrow-inset); }
|
|
300
|
+
.socle-popover:is([data-placement="left"], [data-placement="right"])[data-align="center"] { --_y: 50%; }
|
|
301
|
+
.socle-popover:is([data-placement="left"], [data-placement="right"])[data-align="end"] { --_y: calc(100% - var(--_arrow-inset)); }
|
|
302
|
+
|
|
303
|
+
/* --- Contenu --- */
|
|
304
|
+
/* Positionné au-dessus de la flèche (z-index -1) et du même fond : il masque la moitié
|
|
305
|
+
intérieure de la flèche, seule la pointe dépasse du panneau. */
|
|
306
|
+
.socle-popover-body {
|
|
307
|
+
position: relative;
|
|
308
|
+
z-index: 0;
|
|
309
|
+
min-height: 0;
|
|
310
|
+
overflow: auto;
|
|
311
|
+
padding: var(--socle-popover-padding, 0.75rem);
|
|
312
|
+
background: inherit;
|
|
313
|
+
border-radius: inherit;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/* --- Flèche --- */
|
|
317
|
+
/*
|
|
318
|
+
Un carré tourné de 45°, centré sur le bord du panneau tourné vers le bouton.
|
|
319
|
+
Position = (--_x, --_y) ; quand le navigateur applique un repli, les requêtes
|
|
320
|
+
`@container anchored(fallback: …)` (voir SoclePopover.vue) passent --_fx / --_fy à 1,
|
|
321
|
+
ce qui donne la position symétrique : p → 100% − p.
|
|
322
|
+
Sans requêtes de conteneur ancré, impossible de savoir si le panneau a été retourné :
|
|
323
|
+
la flèche reste masquée.
|
|
324
|
+
*/
|
|
325
|
+
.socle-popover-arrow {
|
|
326
|
+
display: none;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
@supports (container-type: anchored) {
|
|
330
|
+
.socle-popover[data-arrow] {
|
|
331
|
+
--_offset: var(--socle-popover-offset, 0.75rem);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
.socle-popover-arrow {
|
|
335
|
+
--_fx: 0;
|
|
336
|
+
--_fy: 0;
|
|
337
|
+
display: block;
|
|
338
|
+
position: absolute;
|
|
339
|
+
z-index: -1;
|
|
340
|
+
left: calc(var(--_fx) * 100% + (1 - 2 * var(--_fx)) * var(--_x));
|
|
341
|
+
top: calc(var(--_fy) * 100% + (1 - 2 * var(--_fy)) * var(--_y));
|
|
342
|
+
width: var(--_arrow);
|
|
343
|
+
height: var(--_arrow);
|
|
344
|
+
margin: calc(var(--_arrow) / -2);
|
|
345
|
+
rotate: 45deg;
|
|
346
|
+
background: inherit;
|
|
347
|
+
border-width: inherit;
|
|
348
|
+
border-style: inherit;
|
|
349
|
+
border-color: inherit;
|
|
350
|
+
border-radius: 0.125rem;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/* Les requêtes `@container anchored(fallback: …)` qui passent --_fx / --_fy à 1 sont
|
|
354
|
+
injectées par SoclePopover.vue : les minifieurs CSS (Lightning CSS, utilisé par Vite)
|
|
355
|
+
ne savent pas encore les lire et feraient échouer le build. */
|
|
356
|
+
}
|