origam 2.42.0 → 2.43.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/CHANGELOG.md +23 -0
- package/dist/src/components/NumberField/OrigamNumberField.vue +14 -10
- package/dist/src/components/Table/OrigamTable.vue +1 -1
- package/dist/src/directives/Contrast/contrast.directive.cjs +47 -14
- package/dist/src/directives/Contrast/contrast.directive.js +42 -9
- package/dist/src/interfaces/NumberField/number-field.interface.d.ts +8 -0
- package/dist/src/interfaces/Table/table.interface.d.ts +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -18,6 +18,29 @@ This project follows [Semantic Versioning](https://semver.org).
|
|
|
18
18
|
|
|
19
19
|
## [Unreleased]
|
|
20
20
|
|
|
21
|
+
## [2.43.0] - 2026-11-22
|
|
22
|
+
|
|
23
|
+
### Changed — complexité de `v-contrast` (#1398)
|
|
24
|
+
|
|
25
|
+
- `resolvePaintedBackground` passait à 16 de complexité cognitive (seuil Sonar 15) après #1427 et #1131. Refactor pur : l'abstention (`mustAbstain`) et la composition des couches (`compositeLayers`) sont extraites, comportement identique. Complexité 16 → 10.
|
|
26
|
+
|
|
27
|
+
### Fixed — `OrigamNumberField` : plus de retrait vide avec `hideControls`, plus d'écriture du modèle au montage, bornage désactivable (#1327)
|
|
28
|
+
|
|
29
|
+
- Cause : le gabarit `#prependInner` était toujours passé à `OrigamField`, même vide ; `useAdjacentInner` le comptait comme présent et `.origam-field__prepend-inner` réservait ~27 px à gauche du texte.
|
|
30
|
+
- Correctif : le gabarit n'est passé que si les contrôles sont affichés ou si l'appelant fournit son propre slot `prependInner`.
|
|
31
|
+
- Le montage ne borne plus la valeur : aucune écriture du modèle sans interaction (`27` avec `min=2000` reste `27`, la validation le signale).
|
|
32
|
+
- Nouvelle prop `clamp` (défaut `true`) : `false` désactive le bornage à la sortie du champ et à l'écriture, pour refuser une valeur hors bornes avec un message. Rupture assumée : le bornage au montage disparaît.
|
|
33
|
+
|
|
34
|
+
### Fixed — `OrigamTable` : `update:hover` est déclaré (#1155)
|
|
35
|
+
|
|
36
|
+
- Cause : `ITableEmits` était vide alors que `useStateFlag(props, {state: 'hover'})` émet `update:hover` ; le descripteur `emits` compilé était donc `undefined`, Vue restait silencieux et un handler `onUpdate:hover` du consommateur retombait dans `$attrs`, donc sur la racine.
|
|
37
|
+
- Correctif : `ITableEmits extends IHoverEmits`, comme `ICardEmits` / `ISheetEmits`. Story `Events - update:hover` et ligne de doc ajoutées ; cas ajouté à `relay-emits-declaration.spec.ts`.
|
|
38
|
+
|
|
39
|
+
### Fixed — `v-contrast` : un fond `oklab()` / `oklch()` n'est plus sauté (#1131)
|
|
40
|
+
|
|
41
|
+
- Cause : pendant une transition (`1e-05s` sous `prefers-reduced-motion: reduce`) et à l'hydratation, Chromium rapporte `background-color` en `oklab(…)`. `rgbaParts` ne lisait que `rgb(`, la couche était ignorée, le fond de page mesuré, et `#000` / `#fff` forcé en `!important`.
|
|
42
|
+
- `oklab()` / `oklch()` sont désormais convertis en sRGB ; une couleur de fond non convertible fait **s'abstenir** la directive au lieu de mesurer la couche du dessous.
|
|
43
|
+
|
|
21
44
|
## [2.42.0] - 2026-11-22
|
|
22
45
|
|
|
23
46
|
### Fixed — `OrigamBtn` en chargement circulaire : le libellé reste visible (#1086)
|
|
@@ -112,7 +112,10 @@
|
|
|
112
112
|
<slot name="loader"/>
|
|
113
113
|
</template>
|
|
114
114
|
|
|
115
|
-
<template
|
|
115
|
+
<template
|
|
116
|
+
v-if="!hideControls || slots.prependInner"
|
|
117
|
+
#prependInner
|
|
118
|
+
>
|
|
116
119
|
<div
|
|
117
120
|
v-if="!hideControls"
|
|
118
121
|
class="origam-number-field__control"
|
|
@@ -282,7 +285,7 @@
|
|
|
282
285
|
</template>
|
|
283
286
|
|
|
284
287
|
<script lang="ts" setup>
|
|
285
|
-
import { computed, getCurrentInstance, nextTick,
|
|
288
|
+
import { computed, getCurrentInstance, nextTick, ref, shallowRef, StyleValue, useSlots, watch, watchEffect } from "vue";
|
|
286
289
|
import OrigamBtn from "../Btn/OrigamBtn.vue";
|
|
287
290
|
import OrigamDivider from "../Divider/OrigamDivider.vue";
|
|
288
291
|
import OrigamInput from "../Input/OrigamInput.vue";
|
|
@@ -389,6 +392,11 @@ const props = defineProps({
|
|
|
389
392
|
type: Boolean,
|
|
390
393
|
required: false
|
|
391
394
|
},
|
|
395
|
+
clamp: {
|
|
396
|
+
type: Boolean,
|
|
397
|
+
required: false,
|
|
398
|
+
default: true
|
|
399
|
+
},
|
|
392
400
|
compact: {
|
|
393
401
|
type: Boolean,
|
|
394
402
|
required: false,
|
|
@@ -1178,7 +1186,7 @@ const controlsDisabled = computed(() => !!(props.disabled || props.readonly));
|
|
|
1178
1186
|
/*********************************************************
|
|
1179
1187
|
* Value
|
|
1180
1188
|
********************************************************/
|
|
1181
|
-
const model = useVModel(props, "modelValue", null, (val) => val ?? null, (val) => val == null ? val ?? null : clamp(Number(val), props.min, props.max));
|
|
1189
|
+
const model = useVModel(props, "modelValue", null, (val) => val ?? null, (val) => val == null ? val ?? null : props.clamp ? clamp(Number(val), props.min, props.max) : Number(val));
|
|
1182
1190
|
/*********************************************************
|
|
1183
1191
|
* effectiveValidationValue (#696)
|
|
1184
1192
|
*
|
|
@@ -1299,7 +1307,7 @@ const inputText = computed({
|
|
|
1299
1307
|
if (val === null || val === "") {
|
|
1300
1308
|
model.value = null;
|
|
1301
1309
|
_inputText.value = null;
|
|
1302
|
-
} else if (!isNaN(Number(val)) && Number(val) <= props.max && Number(val) >= props.min) {
|
|
1310
|
+
} else if (!isNaN(Number(val)) && (!props.clamp || Number(val) <= props.max && Number(val) >= props.min)) {
|
|
1303
1311
|
model.value = Number(val);
|
|
1304
1312
|
_inputText.value = val;
|
|
1305
1313
|
}
|
|
@@ -1323,9 +1331,6 @@ const canDecrease = computed(() => {
|
|
|
1323
1331
|
return (model.value ?? 0) - props.step >= props.min;
|
|
1324
1332
|
});
|
|
1325
1333
|
watch(() => props.precision, () => formatInputValue());
|
|
1326
|
-
onMounted(() => {
|
|
1327
|
-
clampModel();
|
|
1328
|
-
});
|
|
1329
1334
|
/*********************************************************
|
|
1330
1335
|
* Spinbutton role (non-compact input)
|
|
1331
1336
|
*
|
|
@@ -1471,7 +1476,7 @@ const handleClear = (e) => {
|
|
|
1471
1476
|
emits("click:clear", e);
|
|
1472
1477
|
};
|
|
1473
1478
|
const clampModel = () => {
|
|
1474
|
-
if (controlsDisabled.value) return;
|
|
1479
|
+
if (controlsDisabled.value || !props.clamp) return;
|
|
1475
1480
|
const actualText = _inputText.value ?? origamTextFieldRef.value?.value ?? null;
|
|
1476
1481
|
if (actualText && !isNaN(Number(actualText))) {
|
|
1477
1482
|
const clamped = clamp(Number(actualText), props.min, props.max);
|
|
@@ -1569,8 +1574,7 @@ const compactInputText = computed({
|
|
|
1569
1574
|
if (val === "") {
|
|
1570
1575
|
model.value = null;
|
|
1571
1576
|
} else if (!isNaN(Number(val))) {
|
|
1572
|
-
|
|
1573
|
-
model.value = clamped;
|
|
1577
|
+
model.value = props.clamp ? clamp(Number(val), props.min, props.max) : Number(val);
|
|
1574
1578
|
}
|
|
1575
1579
|
}
|
|
1576
1580
|
});
|
|
@@ -34,6 +34,33 @@ function srgbToRgb(color) {
|
|
|
34
34
|
const a = m[4] !== void 0 ? parseFloat(m[4]) : 1;
|
|
35
35
|
return a < 1 ? `rgba(${r}, ${g}, ${b}, ${a})` : `rgb(${r}, ${g}, ${b})`;
|
|
36
36
|
}
|
|
37
|
+
function oklabToRgb(color) {
|
|
38
|
+
const m = /^\s*(oklab|oklch)\(\s*([^\s/)]+)\s+([^\s/)]+)\s+([^\s/)]+)(?:\s*\/\s*([^\s)]+))?\s*\)\s*$/i.exec(color);
|
|
39
|
+
if (!m) return null;
|
|
40
|
+
const num = (v, pct) => /^-?[\d.]+(?:e-?\d+)?%$/i.test(v) ? parseFloat(v) / 100 * pct : /^-?[\d.]+(?:e-?\d+)?(?:deg)?$/i.test(v) ? parseFloat(v) : NaN;
|
|
41
|
+
const L = num(m[2], 1);
|
|
42
|
+
let a = num(m[3], m[1].toLowerCase() === "oklab" ? 0.4 : 0.4);
|
|
43
|
+
let b = num(m[4], 0.4);
|
|
44
|
+
const alpha = m[5] === void 0 ? 1 : num(m[5], 1);
|
|
45
|
+
if ([L, a, b, alpha].some(Number.isNaN)) return null;
|
|
46
|
+
if (m[1].toLowerCase() === "oklch") {
|
|
47
|
+
const h = b * Math.PI / 180;
|
|
48
|
+
b = a * Math.sin(h);
|
|
49
|
+
a = a * Math.cos(h);
|
|
50
|
+
}
|
|
51
|
+
const l = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3;
|
|
52
|
+
const mm = (L - 0.1055613458 * a - 0.0638541728 * b) ** 3;
|
|
53
|
+
const s = (L - 0.0894841775 * a - 1.291485548 * b) ** 3;
|
|
54
|
+
const enc = c => {
|
|
55
|
+
const v = Math.min(1, Math.max(0, c));
|
|
56
|
+
return Math.round((v <= 31308e-7 ? 12.92 * v : 1.055 * v ** (1 / 2.4) - 0.055) * 255);
|
|
57
|
+
};
|
|
58
|
+
const r = enc(4.0767416621 * l - 3.3077115913 * mm + 0.2309699292 * s);
|
|
59
|
+
const g = enc(-1.2684380046 * l + 2.6097574011 * mm - 0.3413193965 * s);
|
|
60
|
+
const bl = enc(-0.0041960863 * l - 0.7034186147 * mm + 1.707614701 * s);
|
|
61
|
+
const al = Math.min(1, Math.max(0, alpha));
|
|
62
|
+
return al < 1 ? `rgba(${r}, ${g}, ${bl}, ${al})` : `rgb(${r}, ${g}, ${bl})`;
|
|
63
|
+
}
|
|
37
64
|
function hexToRgb(hex) {
|
|
38
65
|
const m = /^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(hex);
|
|
39
66
|
if (!m) return null;
|
|
@@ -49,7 +76,7 @@ function hexToRgb(hex) {
|
|
|
49
76
|
}
|
|
50
77
|
function toRgb(color) {
|
|
51
78
|
if (!color) return null;
|
|
52
|
-
const direct = srgbToRgb(color);
|
|
79
|
+
const direct = srgbToRgb(color) ?? oklabToRgb(color);
|
|
53
80
|
if (direct) return direct;
|
|
54
81
|
if (/^rgba?\(/i.test(color)) return color;
|
|
55
82
|
if (typeof document === "undefined") return color;
|
|
@@ -86,31 +113,37 @@ function over(top, bottom) {
|
|
|
86
113
|
a: 1
|
|
87
114
|
};
|
|
88
115
|
}
|
|
116
|
+
function mustAbstain(style, parts) {
|
|
117
|
+
if (style.backgroundImage && style.backgroundImage !== "none") return true;
|
|
118
|
+
return !parts && !!style.backgroundColor && style.backgroundColor !== "transparent";
|
|
119
|
+
}
|
|
120
|
+
function compositeLayers(layers) {
|
|
121
|
+
const deepest = layers[layers.length - 1];
|
|
122
|
+
let acc = deepest.a >= 1 ? layers.pop() : {
|
|
123
|
+
r: 255,
|
|
124
|
+
g: 255,
|
|
125
|
+
b: 255,
|
|
126
|
+
a: 1
|
|
127
|
+
};
|
|
128
|
+
for (let i = layers.length - 1; i >= 0; i -= 1) {
|
|
129
|
+
acc = over(layers[i], acc);
|
|
130
|
+
}
|
|
131
|
+
return `rgb(${Math.round(acc.r)}, ${Math.round(acc.g)}, ${Math.round(acc.b)})`;
|
|
132
|
+
}
|
|
89
133
|
function resolvePaintedBackground(el) {
|
|
90
134
|
const layers = [];
|
|
91
135
|
let node = el;
|
|
92
136
|
while (node) {
|
|
93
137
|
const style = getComputedStyle(node);
|
|
94
|
-
if (style.backgroundImage && style.backgroundImage !== "none") return null;
|
|
95
138
|
const parts = rgbaParts(toRgb(style.backgroundColor));
|
|
139
|
+
if (mustAbstain(style, parts)) return null;
|
|
96
140
|
if (parts && parts.a > 0) {
|
|
97
141
|
layers.push(parts);
|
|
98
142
|
if (parts.a >= 1) break;
|
|
99
143
|
}
|
|
100
144
|
node = node.parentElement;
|
|
101
145
|
}
|
|
102
|
-
|
|
103
|
-
const deepest = layers[layers.length - 1];
|
|
104
|
-
let acc = deepest.a >= 1 ? layers.pop() : {
|
|
105
|
-
r: 255,
|
|
106
|
-
g: 255,
|
|
107
|
-
b: 255,
|
|
108
|
-
a: 1
|
|
109
|
-
};
|
|
110
|
-
for (let i = layers.length - 1; i >= 0; i -= 1) {
|
|
111
|
-
acc = over(layers[i], acc);
|
|
112
|
-
}
|
|
113
|
-
return `rgb(${Math.round(acc.r)}, ${Math.round(acc.g)}, ${Math.round(acc.b)})`;
|
|
146
|
+
return layers.length ? compositeLayers(layers) : null;
|
|
114
147
|
}
|
|
115
148
|
function channelsOf(rgb) {
|
|
116
149
|
if (!rgb) return null;
|
|
@@ -22,6 +22,33 @@ function srgbToRgb(color) {
|
|
|
22
22
|
const a = m[4] !== void 0 ? parseFloat(m[4]) : 1;
|
|
23
23
|
return a < 1 ? `rgba(${r}, ${g}, ${b}, ${a})` : `rgb(${r}, ${g}, ${b})`;
|
|
24
24
|
}
|
|
25
|
+
function oklabToRgb(color) {
|
|
26
|
+
const m = /^\s*(oklab|oklch)\(\s*([^\s/)]+)\s+([^\s/)]+)\s+([^\s/)]+)(?:\s*\/\s*([^\s)]+))?\s*\)\s*$/i.exec(color);
|
|
27
|
+
if (!m) return null;
|
|
28
|
+
const num = (v, pct) => /^-?[\d.]+(?:e-?\d+)?%$/i.test(v) ? parseFloat(v) / 100 * pct : /^-?[\d.]+(?:e-?\d+)?(?:deg)?$/i.test(v) ? parseFloat(v) : NaN;
|
|
29
|
+
const L = num(m[2], 1);
|
|
30
|
+
let a = num(m[3], m[1].toLowerCase() === "oklab" ? 0.4 : 0.4);
|
|
31
|
+
let b = num(m[4], 0.4);
|
|
32
|
+
const alpha = m[5] === void 0 ? 1 : num(m[5], 1);
|
|
33
|
+
if ([L, a, b, alpha].some(Number.isNaN)) return null;
|
|
34
|
+
if (m[1].toLowerCase() === "oklch") {
|
|
35
|
+
const h = b * Math.PI / 180;
|
|
36
|
+
b = a * Math.sin(h);
|
|
37
|
+
a = a * Math.cos(h);
|
|
38
|
+
}
|
|
39
|
+
const l = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3;
|
|
40
|
+
const mm = (L - 0.1055613458 * a - 0.0638541728 * b) ** 3;
|
|
41
|
+
const s = (L - 0.0894841775 * a - 1.291485548 * b) ** 3;
|
|
42
|
+
const enc = (c) => {
|
|
43
|
+
const v = Math.min(1, Math.max(0, c));
|
|
44
|
+
return Math.round((v <= 31308e-7 ? 12.92 * v : 1.055 * v ** (1 / 2.4) - 0.055) * 255);
|
|
45
|
+
};
|
|
46
|
+
const r = enc(4.0767416621 * l - 3.3077115913 * mm + 0.2309699292 * s);
|
|
47
|
+
const g = enc(-1.2684380046 * l + 2.6097574011 * mm - 0.3413193965 * s);
|
|
48
|
+
const bl = enc(-0.0041960863 * l - 0.7034186147 * mm + 1.707614701 * s);
|
|
49
|
+
const al = Math.min(1, Math.max(0, alpha));
|
|
50
|
+
return al < 1 ? `rgba(${r}, ${g}, ${bl}, ${al})` : `rgb(${r}, ${g}, ${bl})`;
|
|
51
|
+
}
|
|
25
52
|
function hexToRgb(hex) {
|
|
26
53
|
const m = /^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(hex);
|
|
27
54
|
if (!m) return null;
|
|
@@ -37,7 +64,7 @@ function hexToRgb(hex) {
|
|
|
37
64
|
}
|
|
38
65
|
function toRgb(color) {
|
|
39
66
|
if (!color) return null;
|
|
40
|
-
const direct = srgbToRgb(color);
|
|
67
|
+
const direct = srgbToRgb(color) ?? oklabToRgb(color);
|
|
41
68
|
if (direct) return direct;
|
|
42
69
|
if (/^rgba?\(/i.test(color)) return color;
|
|
43
70
|
if (typeof document === "undefined") return color;
|
|
@@ -69,26 +96,32 @@ function over(top, bottom) {
|
|
|
69
96
|
a: 1
|
|
70
97
|
};
|
|
71
98
|
}
|
|
99
|
+
function mustAbstain(style, parts) {
|
|
100
|
+
if (style.backgroundImage && style.backgroundImage !== "none") return true;
|
|
101
|
+
return !parts && !!style.backgroundColor && style.backgroundColor !== "transparent";
|
|
102
|
+
}
|
|
103
|
+
function compositeLayers(layers) {
|
|
104
|
+
const deepest = layers[layers.length - 1];
|
|
105
|
+
let acc = deepest.a >= 1 ? layers.pop() : { r: 255, g: 255, b: 255, a: 1 };
|
|
106
|
+
for (let i = layers.length - 1; i >= 0; i -= 1) {
|
|
107
|
+
acc = over(layers[i], acc);
|
|
108
|
+
}
|
|
109
|
+
return `rgb(${Math.round(acc.r)}, ${Math.round(acc.g)}, ${Math.round(acc.b)})`;
|
|
110
|
+
}
|
|
72
111
|
function resolvePaintedBackground(el) {
|
|
73
112
|
const layers = [];
|
|
74
113
|
let node = el;
|
|
75
114
|
while (node) {
|
|
76
115
|
const style = getComputedStyle(node);
|
|
77
|
-
if (style.backgroundImage && style.backgroundImage !== "none") return null;
|
|
78
116
|
const parts = rgbaParts(toRgb(style.backgroundColor));
|
|
117
|
+
if (mustAbstain(style, parts)) return null;
|
|
79
118
|
if (parts && parts.a > 0) {
|
|
80
119
|
layers.push(parts);
|
|
81
120
|
if (parts.a >= 1) break;
|
|
82
121
|
}
|
|
83
122
|
node = node.parentElement;
|
|
84
123
|
}
|
|
85
|
-
|
|
86
|
-
const deepest = layers[layers.length - 1];
|
|
87
|
-
let acc = deepest.a >= 1 ? layers.pop() : { r: 255, g: 255, b: 255, a: 1 };
|
|
88
|
-
for (let i = layers.length - 1; i >= 0; i -= 1) {
|
|
89
|
-
acc = over(layers[i], acc);
|
|
90
|
-
}
|
|
91
|
-
return `rgb(${Math.round(acc.r)}, ${Math.round(acc.g)}, ${Math.round(acc.b)})`;
|
|
124
|
+
return layers.length ? compositeLayers(layers) : null;
|
|
92
125
|
}
|
|
93
126
|
function channelsOf(rgb) {
|
|
94
127
|
if (!rgb) return null;
|
|
@@ -23,6 +23,14 @@ export interface INumberFieldProps extends IFieldProps, IInputProps, IInputVaria
|
|
|
23
23
|
holdRepeat?: number;
|
|
24
24
|
split?: boolean;
|
|
25
25
|
hideControls?: boolean;
|
|
26
|
+
/*********************************************************
|
|
27
|
+
* clamp
|
|
28
|
+
*
|
|
29
|
+
* @description
|
|
30
|
+
* Bounds the value to `min`/`max` on blur and on write (default `true`).
|
|
31
|
+
* `false` keeps an out-of-range value so validation can reject it.
|
|
32
|
+
********************************************************/
|
|
33
|
+
clamp?: boolean;
|
|
26
34
|
compact?: boolean;
|
|
27
35
|
/*********************************************************
|
|
28
36
|
* decrementAriaLabel / incrementAriaLabel
|
|
@@ -3,7 +3,7 @@ import type { ICommonsComponentProps, ITagProps } from '../Commons/commons.inter
|
|
|
3
3
|
import type { IDensityProps } from '../Commons/density.interface';
|
|
4
4
|
import type { IDimensionProps } from '../Commons/dimension.interface';
|
|
5
5
|
import type { IElevationProps } from '../Commons/elevation.interface';
|
|
6
|
-
import type { IHoverProps } from '../Commons/hover.interface';
|
|
6
|
+
import type { IHoverEmits, IHoverProps } from '../Commons/hover.interface';
|
|
7
7
|
import type { IMarginProps } from '../Commons/margin.interface';
|
|
8
8
|
import type { IPaddingProps } from '../Commons/padding.interface';
|
|
9
9
|
import type { IRoundedProps } from '../Commons/rounded.interface';
|
|
@@ -15,7 +15,7 @@ export interface ITableProps extends ICommonsComponentProps, IBorderProps, IRoun
|
|
|
15
15
|
captionVisible?: boolean;
|
|
16
16
|
ariaRowcount?: number;
|
|
17
17
|
}
|
|
18
|
-
export interface ITableEmits {
|
|
18
|
+
export interface ITableEmits extends IHoverEmits {
|
|
19
19
|
}
|
|
20
20
|
/** Slot signatures for `<OrigamTable>`. */
|
|
21
21
|
export interface ITableSlots {
|