origam 2.44.0 → 2.44.1
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 +31 -0
- package/dist/src/components/Audio/OrigamAudio.vue +1 -1
- package/dist/src/components/Chart/OrigamChartRadar.vue +1 -1
- package/dist/src/components/DatePicker/OrigamDatePickerControls.vue +1 -1
- package/dist/src/components/Drawer/OrigamDrawer.vue +65 -3
- package/dist/src/components/ExpansionPanel/OrigamExpansionPanel.vue +6 -4
- package/dist/src/components/ExpansionPanel/OrigamExpansionPanelContent.vue +1 -1
- package/dist/src/components/ExpansionPanel/OrigamExpansionPanelHeader.vue +1 -1
- package/dist/src/components/List/OrigamListChildren.vue +1 -1
- package/dist/src/components/Video/OrigamVideo.vue +1 -1
- package/dist/src/composables/Commons/style.composable.cjs +3 -2
- package/dist/src/composables/Commons/style.composable.js +3 -2
- package/dist/src/consts/Commons/style.const.cjs +9 -0
- package/dist/src/consts/Commons/style.const.d.ts +26 -0
- package/dist/src/consts/Commons/style.const.js +3 -0
- package/dist/src/consts/index.cjs +11 -0
- package/dist/src/consts/index.d.ts +1 -0
- package/dist/src/consts/index.js +1 -0
- package/dist/src/interfaces/ExpansionPanel/expansion-panel.interface.d.ts +1 -0
- package/dist/src/themes/origam.theme.cjs +0 -2
- package/dist/src/themes/origam.theme.js +2 -2
- package/dist/src/utils/Commons/style.util.cjs +30 -0
- package/dist/src/utils/Commons/style.util.d.ts +18 -0
- package/dist/src/utils/Commons/style.util.js +23 -0
- package/dist/src/utils/index.cjs +11 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/index.js +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -18,6 +18,37 @@ This project follows [Semantic Versioning](https://semver.org).
|
|
|
18
18
|
|
|
19
19
|
## [Unreleased]
|
|
20
20
|
|
|
21
|
+
## [2.44.1] - 2026-11-25
|
|
22
|
+
|
|
23
|
+
### Security — `useStyle` : une valeur de style ne peut plus sortir de sa déclaration (#1113)
|
|
24
|
+
|
|
25
|
+
- Cause : `toDeclarations` (`style.composable.ts`) concaténait `clé: valeur` tel quel dans le texte du `<style>` injecté en `<head>`. Une valeur libre (`color`, `bgColor`, dimension, prop `style`…) contenant `red; } body { … } .x {` fermait la règle `#id { … }` et injectait des règles arbitraires dans la page (mesuré sous jsdom : 3 règles parsées au lieu d'une). Les 147 composants qui appellent `useStyle` étaient concernés.
|
|
26
|
+
- Correctif : validation à la source unique, `toDeclarations`, via `toSafeCssDeclaration` / `toSafeCssDeclarations` (`utils/Commons/style.util.ts`). Une déclaration est écartée si son nom n'est pas un nom de propriété (`--custom` ou `[-]ident`) ou si sa valeur, chaînes entre guillemets et corps de `url(…)` masqués, contient `;` `{` `}` `<` `>` `@` `\`, un retour ligne, un commentaire, un guillemet non fermé ou `expression(`. Une chaîne `style` est découpée sur ses `;` hors chaînes / `url(…)` et chaque déclaration est validée séparément : les déclarations saines voisines restent émises. Restent acceptés : longueurs, `var(--origam-…, fallback)`, `calc()`, `clamp()`, `color-mix()`, `rgb()` / `oklch()` / `#hex`, `!important`, `font-family` entre guillemets, `url(…)` y compris `data:` (même pouvoir qu'un attribut `style` en ligne).
|
|
27
|
+
- Test : `style-injection.spec.ts` — 21 échecs sur le code parent, 49/49 après ; suite TU complète verte.
|
|
28
|
+
|
|
29
|
+
### Fixed — thème de base `origam` : plus de `variant` sur `origam-chip`, prop que Chip ne déclare pas (#1475)
|
|
30
|
+
- Cause : `origamLightTheme` / `origamDarkTheme` posaient `variant: 'outlined'` sur `origam-chip`. Le résolveur de thème (ADR-005) ignore une prop non déclarée et émet un avertissement dev : config morte, et un `console.warn` à chaque chargement chez tout consommateur.
|
|
31
|
+
- Correctif : clé retirée des deux thèmes. Rendu inchangé (la clé n'était jamais appliquée).
|
|
32
|
+
- Test : `theme-components-declared-props-1475.spec.ts` vérifie, sur le descripteur de props compilé, que tout le bloc `components` du thème de base ne nomme que des props déclarées — rouge sur le parent (`origam-chip.variant`), vert après.
|
|
33
|
+
|
|
34
|
+
### Fixed — avertissements `useUnsupportedProp` émis à tort (#1476)
|
|
35
|
+
|
|
36
|
+
- Cause : même défaut que #1157 — un prédicat `!== undefined` (ou `=== true` sur une prop à défaut `true`) est vrai dès le montage, car Vue convertit une prop booléenne absente en `false` et `withDefaults` fixe une valeur. L'avertissement « has no effect » partait à chaque montage, sans que le consommateur ait rien passé.
|
|
37
|
+
- Correctif : chaque prédicat compare à la valeur par défaut réelle. `OrigamVideo` `showCenterControls` (défaut `true`) ; `OrigamAudio` `waveformColor` (défaut `'currentColor'`) ; `OrigamDatePickerControls` `active`, `OrigamListChildren` `returnObject`, `OrigamChartRadar` `showTooltip` (booléens). Les 18 autres composants appelants ont été mesurés : aucun défaut.
|
|
38
|
+
- Test : `packages/tests/TU/components/Commons/unsupported-prop-predicates.spec.ts` — 7 cas rouges sur le parent, verts ; contrôle positif (prop morte réellement passée => 1 avertissement) pour chaque appel.
|
|
39
|
+
|
|
40
|
+
### Fixed — `OrigamExpansionPanel` : titre rendu côté serveur et ids stables à l'hydratation (#1469)
|
|
41
|
+
|
|
42
|
+
- Cause : les props du header / du content venaient de template refs (`ref.value?.filterProps`), `undefined` côté serveur : ni titre ni props relayées dans le HTML servi. Les ids `expansion-panel-header-N` / `-content-N` dérivaient du compteur de module de `useGroupItem` (valeur différente serveur / client, écart d'hydratation).
|
|
43
|
+
- Correctif : `filterPropsOf(OrigamExpansionPanelHeader|Content, …)` (définition statique, comme `OrigamTextareaField`) ; le panel fournit `uid: getUid()` (`useId`) et header / content en dérivent leurs ids. Sans changement d'API publique. Le corps reste lazy par conception : `eager` pour le mettre dans le HTML serveur. Le titre et l'id stable sont toujours rendus côté serveur ; le contenu n'est dans le HTML serveur (masqué) qu'avec `eager`, sinon il est monté à la première ouverture.
|
|
44
|
+
- Test : `OrigamExpansionPanel.ssr-1469.spec.ts` (`renderToString`) — rouge sur le commit parent, vert après.
|
|
45
|
+
|
|
46
|
+
### Fixed — `OrigamDrawer` : un tiroir `temporary` avec voile est maintenant modal (#1454)
|
|
47
|
+
|
|
48
|
+
- Cause : le tiroir `temporary` bloquait la page par son voile mais n'exposait ni `aria-modal`, ni piège à focus, ni fermeture sur Échap (la doc l'annonçait pourtant).
|
|
49
|
+
- Correctif : quand `temporary` et `scrim`, le tiroir porte `role="dialog"` + `aria-modal="true"`, prend le focus à l'ouverture, referme Tab / Maj+Tab sur lui-même, se ferme sur Échap s'il est au sommet de `useStack` (même pile que la famille Overlay), et rend le focus à l'élément précédent. `:ref="rootEl"` devient `ref="rootEl"` (la ref n'était pas peuplée). Sans API nouvelle ; `:scrim="false"` reste non modal.
|
|
50
|
+
- Test : `drawer-temporary-a11y-1454.spec.ts` — rouge sur le commit parent (`aria-modal` absent), vert après.
|
|
51
|
+
|
|
21
52
|
## [2.44.0] - 2026-11-25
|
|
22
53
|
|
|
23
54
|
### Fixed — `OrigamField` : les labels ne reprennent plus l'`id` de l'input (#1149)
|
|
@@ -1618,7 +1618,7 @@ const { colorClasses, colorStyles } = useColorEffect(props);
|
|
|
1618
1618
|
* cablees a un comportement invente. Elles avertissent une fois, en
|
|
1619
1619
|
* dev, avec la raison exacte. Meme traitement que la famille Chart.
|
|
1620
1620
|
********************************************************/
|
|
1621
|
-
useUnsupportedProp("OrigamAudio", "waveformColor", "the waveform paints from `currentColor`; this prop reaches no declaration.", () => props.waveformColor !==
|
|
1621
|
+
useUnsupportedProp("OrigamAudio", "waveformColor", "the waveform paints from `currentColor`; this prop reaches no declaration.", () => props.waveformColor !== "currentColor");
|
|
1622
1622
|
const hasColorProp = computed(() => !!props.color);
|
|
1623
1623
|
const hasBgColorProp = computed(() => !!props.bgColor);
|
|
1624
1624
|
const scrubberColorStyle = computed(() => {
|
|
@@ -570,7 +570,7 @@ const { headerTypographyStyles } = useChartHeaderTypography(props);
|
|
|
570
570
|
* comportement fictif : elles avertissent une fois, en dev, avec la
|
|
571
571
|
* raison exacte. Meme traitement que `OrigamChartGauge`.
|
|
572
572
|
********************************************************/
|
|
573
|
-
useUnsupportedProp("OrigamChartRadar", "showTooltip", "no tooltip component is rendered by the radar — `ChartTooltip` appears nowhere in its template.", () => props.showTooltip
|
|
573
|
+
useUnsupportedProp("OrigamChartRadar", "showTooltip", "no tooltip component is rendered by the radar — `ChartTooltip` appears nowhere in its template.", () => props.showTooltip === true);
|
|
574
574
|
const chartAnimationStyle = useChartAnimationStyle(props);
|
|
575
575
|
const { resizeRef: svgRef, width: svgWidth, height: svgHeight } = useChartSize(CHART_SIZE_FALLBACK.radar, { aspectRatio: CHART_ASPECT_RATIO.radial });
|
|
576
576
|
const { onKeydown: onChartKeydown } = useChartRoving(svgRef);
|
|
@@ -170,7 +170,7 @@ const props = defineProps({
|
|
|
170
170
|
* (`viewMode` n'en fait plus partie : il pilote `aria-expanded` et le
|
|
171
171
|
* pivot du chevron des deux boutons mois / annee.)
|
|
172
172
|
********************************************************/
|
|
173
|
-
useUnsupportedProp("OrigamDatePickerControls", "active", "the controls row reflects the picker view state of its parent; it has no active state of its own.", () => props.active
|
|
173
|
+
useUnsupportedProp("OrigamDatePickerControls", "active", "the controls row reflects the picker view state of its parent; it has no active state of its own.", () => props.active === true);
|
|
174
174
|
const emits = defineEmits([
|
|
175
175
|
"click:year",
|
|
176
176
|
"click:month",
|
|
@@ -9,8 +9,11 @@
|
|
|
9
9
|
:is="tag"
|
|
10
10
|
v-if="isActive"
|
|
11
11
|
:id="id"
|
|
12
|
-
|
|
12
|
+
ref="rootEl"
|
|
13
13
|
:aria-label="drawerAriaLabel"
|
|
14
|
+
:aria-modal="isModal ? 'true' : undefined"
|
|
15
|
+
:role="isModal ? 'dialog' : undefined"
|
|
16
|
+
:tabindex="isModal ? -1 : undefined"
|
|
14
17
|
:class="drawerClasses"
|
|
15
18
|
:style="drawerStyles"
|
|
16
19
|
v-bind="{...scopeId, ...$attrs}"
|
|
@@ -55,7 +58,7 @@
|
|
|
55
58
|
</template>
|
|
56
59
|
|
|
57
60
|
<script lang="ts" setup>
|
|
58
|
-
import { computed, ComputedRef, isRef, nextTick, onBeforeMount, onServerPrefetch, Ref, ref, shallowRef, StyleValue, toRef, useSlots, watch } from "vue";
|
|
61
|
+
import { computed, ComputedRef, isRef, nextTick, onBeforeMount, onBeforeUnmount, onServerPrefetch, Ref, ref, shallowRef, StyleValue, toRef, useSlots, watch } from "vue";
|
|
59
62
|
import OrigamOverlayScrim from "../Overlay/OrigamOverlayScrim.vue";
|
|
60
63
|
import OrigamTransition from "../Transition/OrigamTransition.vue";
|
|
61
64
|
import { useBackgroundColor } from "../../composables/Commons/backgroundColor.composable";
|
|
@@ -66,6 +69,7 @@ import { useProps } from "../../composables/Commons/props.composable";
|
|
|
66
69
|
import { useRouter } from "../../composables/Commons/router.composable";
|
|
67
70
|
import { useScopeId } from "../../composables/Commons/scopeId.composable";
|
|
68
71
|
import { useSsrBoot } from "../../composables/Commons/ssrBoot.composable";
|
|
72
|
+
import { useStack } from "../../composables/Commons/stack.composable";
|
|
69
73
|
import { useStateEffect } from "../../composables/Commons/stateEffect.composable";
|
|
70
74
|
import { useStateFlag } from "../../composables/Commons/stateFlag.composable";
|
|
71
75
|
import { useSticky } from "../../composables/Commons/sticky.composable";
|
|
@@ -75,8 +79,10 @@ import { useHydration } from "../../composables/Commons/hydration.composable";
|
|
|
75
79
|
import { useToggleScope } from "../../composables/Commons/toggleScope.composable";
|
|
76
80
|
import { useTouch } from "../../composables/Commons/touch.composable";
|
|
77
81
|
import { useVModel } from "../../composables/Commons/vModel.composable";
|
|
82
|
+
import { IN_BROWSER } from "../../consts/Commons/commons.const";
|
|
78
83
|
import { INLINE } from "../../enums/Commons/anchor.enum";
|
|
79
|
-
import {
|
|
84
|
+
import { KEYBOARD_VALUES } from "../../enums/Commons/hotkey.enum";
|
|
85
|
+
import { focusableChildren, int } from "../../utils/Commons/commons.util";
|
|
80
86
|
/*********************************************************
|
|
81
87
|
* inheritAttrs — #916 / #853
|
|
82
88
|
*
|
|
@@ -794,6 +800,62 @@ onBeforeMount(initActive);
|
|
|
794
800
|
********************************************************/
|
|
795
801
|
onServerPrefetch(initActive);
|
|
796
802
|
/*********************************************************
|
|
803
|
+
* Modal behaviour — #1454
|
|
804
|
+
*
|
|
805
|
+
* @description
|
|
806
|
+
* A `temporary` drawer with a scrim blocks the page behind it, so it is
|
|
807
|
+
* modal: `role="dialog"` + `aria-modal`, focus trapped inside, Escape
|
|
808
|
+
* closes it (top of the global stack only, same `useStack` as the
|
|
809
|
+
* Overlay family), and focus returns to whatever held it before opening.
|
|
810
|
+
********************************************************/
|
|
811
|
+
const isModal = computed(() => isActive.value && isTemporary.value && !!props.scrim);
|
|
812
|
+
const { globalTop } = useStack(isModal, shallowRef(1e3), shallowRef(false));
|
|
813
|
+
let returnFocusEl = null;
|
|
814
|
+
/*********************************************************
|
|
815
|
+
* Tab wrap
|
|
816
|
+
*
|
|
817
|
+
* @description
|
|
818
|
+
* Leaving the last focusable moves focus out of the document (no
|
|
819
|
+
* `focusin` fires), so only a keydown guard can trap it.
|
|
820
|
+
********************************************************/
|
|
821
|
+
const handleModalKeydown = (e) => {
|
|
822
|
+
if (!globalTop.value) return;
|
|
823
|
+
if (e.key === KEYBOARD_VALUES.ESC) {
|
|
824
|
+
isActive.value = false;
|
|
825
|
+
return;
|
|
826
|
+
}
|
|
827
|
+
const el = rootEl.value;
|
|
828
|
+
if (e.key !== KEYBOARD_VALUES.TAB || !el) return;
|
|
829
|
+
const focusable = focusableChildren(el);
|
|
830
|
+
const first = focusable[0] ?? el;
|
|
831
|
+
const last = focusable.at(-1) ?? el;
|
|
832
|
+
const outside = !el.contains(document.activeElement) || document.activeElement === el;
|
|
833
|
+
if (e.shiftKey && (document.activeElement === first || outside)) {
|
|
834
|
+
e.preventDefault();
|
|
835
|
+
last.focus();
|
|
836
|
+
} else if (!e.shiftKey && (document.activeElement === last || outside && !focusable.length)) {
|
|
837
|
+
e.preventDefault();
|
|
838
|
+
first.focus();
|
|
839
|
+
}
|
|
840
|
+
};
|
|
841
|
+
if (IN_BROWSER) {
|
|
842
|
+
watch(isModal, async (val) => {
|
|
843
|
+
if (val) {
|
|
844
|
+
returnFocusEl = document.activeElement;
|
|
845
|
+
window.addEventListener("keydown", handleModalKeydown);
|
|
846
|
+
await nextTick();
|
|
847
|
+
rootEl.value?.focus({ preventScroll: true });
|
|
848
|
+
} else {
|
|
849
|
+
window.removeEventListener("keydown", handleModalKeydown);
|
|
850
|
+
returnFocusEl?.focus({ preventScroll: true });
|
|
851
|
+
returnFocusEl = null;
|
|
852
|
+
}
|
|
853
|
+
}, { immediate: true });
|
|
854
|
+
onBeforeUnmount(() => {
|
|
855
|
+
window.removeEventListener("keydown", handleModalKeydown);
|
|
856
|
+
});
|
|
857
|
+
}
|
|
858
|
+
/*********************************************************
|
|
797
859
|
* Drag
|
|
798
860
|
*
|
|
799
861
|
* @description
|
|
@@ -114,10 +114,11 @@ import { useBothColor } from "../../composables/Commons/bothColor.composable";
|
|
|
114
114
|
import { useDensity } from "../../composables/Commons/density.composable";
|
|
115
115
|
import { useGroupItem } from "../../composables/Commons/groupItem.composable";
|
|
116
116
|
import { useLoader } from "../../composables/Commons/loader.composable";
|
|
117
|
-
import { useProps } from "../../composables/Commons/props.composable";
|
|
117
|
+
import { filterPropsOf, useProps } from "../../composables/Commons/props.composable";
|
|
118
118
|
import { useStateEffect } from "../../composables/Commons/stateEffect.composable";
|
|
119
119
|
import { useStateFlag } from "../../composables/Commons/stateFlag.composable";
|
|
120
120
|
import { useStyle } from "../../composables/Commons/style.composable";
|
|
121
|
+
import { getUid } from "../../utils/Commons/getCurrentInstance.util";
|
|
121
122
|
import vContrast from "../../directives/Contrast/contrast.directive";
|
|
122
123
|
import { ORIGAM_EXPANSION_PANEL_KEY } from "../../consts/ExpansionPanel/expansion-panel.const";
|
|
123
124
|
import { LOADER_KIND } from "../../enums/Commons/loader.enum";
|
|
@@ -785,7 +786,8 @@ if (groupItem !== null) {
|
|
|
785
786
|
provide(ORIGAM_EXPANSION_PANEL_KEY, {
|
|
786
787
|
...groupItem,
|
|
787
788
|
headerId,
|
|
788
|
-
contentId
|
|
789
|
+
contentId,
|
|
790
|
+
uid: getUid()
|
|
789
791
|
});
|
|
790
792
|
}
|
|
791
793
|
/*********************************************************
|
|
@@ -832,7 +834,7 @@ const hasHeader = computed(() => {
|
|
|
832
834
|
* Forwarded props
|
|
833
835
|
********************************************************/
|
|
834
836
|
const expansionPanelHeaderProps = computed(() => {
|
|
835
|
-
return
|
|
837
|
+
return filterPropsOf(OrigamExpansionPanelHeader, props, [
|
|
836
838
|
"class",
|
|
837
839
|
"id",
|
|
838
840
|
"style",
|
|
@@ -840,7 +842,7 @@ const expansionPanelHeaderProps = computed(() => {
|
|
|
840
842
|
]);
|
|
841
843
|
});
|
|
842
844
|
const expansionPanelContentProps = computed(() => {
|
|
843
|
-
return
|
|
845
|
+
return filterPropsOf(OrigamExpansionPanelContent, props, [
|
|
844
846
|
"class",
|
|
845
847
|
"id",
|
|
846
848
|
"style",
|
|
@@ -606,7 +606,7 @@ if (!expansionPanel) throw new Error("[Origam] expansion-panel-content needs to
|
|
|
606
606
|
* `aria-controls` at the REAL id instead of guessing the
|
|
607
607
|
* generated-fallback naming scheme (#519, #520).
|
|
608
608
|
********************************************************/
|
|
609
|
-
const contentDomId = computed(() => props.id || `expansion-panel-content-${expansionPanel.
|
|
609
|
+
const contentDomId = computed(() => props.id || `expansion-panel-content-${expansionPanel.uid}`);
|
|
610
610
|
watchEffect(() => {
|
|
611
611
|
expansionPanel.contentId.value = contentDomId.value;
|
|
612
612
|
});
|
|
@@ -703,7 +703,7 @@ const slots = useSlots();
|
|
|
703
703
|
* `aria-labelledby` at the REAL id instead of guessing the
|
|
704
704
|
* generated-fallback naming scheme (#519, #520).
|
|
705
705
|
********************************************************/
|
|
706
|
-
const headerDomId = computed(() => props.id || `expansion-panel-header-${expansionPanel.
|
|
706
|
+
const headerDomId = computed(() => props.id || `expansion-panel-header-${expansionPanel.uid}`);
|
|
707
707
|
watchEffect(() => {
|
|
708
708
|
expansionPanel.headerId.value = headerDomId.value;
|
|
709
709
|
});
|
|
@@ -123,7 +123,7 @@ const listItems = computed(() => {
|
|
|
123
123
|
* cablees a un comportement invente. Elles avertissent une fois, en
|
|
124
124
|
* dev, avec la raison exacte. Meme traitement que la famille Chart.
|
|
125
125
|
********************************************************/
|
|
126
|
-
useUnsupportedProp("OrigamListChildren", "returnObject", "this renderer emits nothing — selection payload shape is decided by `<origam-list>` upstream.", () => props.returnObject
|
|
126
|
+
useUnsupportedProp("OrigamListChildren", "returnObject", "this renderer emits nothing — selection payload shape is decided by `<origam-list>` upstream.", () => props.returnObject === true);
|
|
127
127
|
/*********************************************************
|
|
128
128
|
* Slots
|
|
129
129
|
********************************************************/
|
|
@@ -1446,7 +1446,7 @@ const { colorClasses, colorStyles } = useColorEffect(props);
|
|
|
1446
1446
|
* cablees a un comportement invente. Elles avertissent une fois, en
|
|
1447
1447
|
* dev, avec la raison exacte. Meme traitement que la famille Chart.
|
|
1448
1448
|
********************************************************/
|
|
1449
|
-
useUnsupportedProp("OrigamVideo", "showCenterControls", "no centre overlay is rendered; the controls live in the bottom bar only.", () => props.showCenterControls
|
|
1449
|
+
useUnsupportedProp("OrigamVideo", "showCenterControls", "no centre overlay is rendered; the controls live in the bottom bar only.", () => props.showCenterControls !== true);
|
|
1450
1450
|
const hasColorProp = computed(() => !!props.color);
|
|
1451
1451
|
const hasBgColorProp = computed(() => !!props.bgColor);
|
|
1452
1452
|
/*********************************************************
|
|
@@ -8,17 +8,18 @@ var _vue = require("vue");
|
|
|
8
8
|
var _ssrStyle = require("../../consts/Commons/ssr-style.const.cjs");
|
|
9
9
|
var _dom = require("../../utils/Commons/dom.util.cjs");
|
|
10
10
|
var _getCurrentInstance = require("../../utils/Commons/getCurrentInstance.util.cjs");
|
|
11
|
+
var _style = require("../../utils/Commons/style.util.cjs");
|
|
11
12
|
var _styleTag = require("./styleTag.composable.cjs");
|
|
12
13
|
function toKebabCase(key) {
|
|
13
14
|
return key.startsWith("--") ? key : key.replace(/[A-Z]/g, letter => `-${letter.toLowerCase()}`);
|
|
14
15
|
}
|
|
15
16
|
function toDeclarations(value) {
|
|
16
17
|
if (value == null || typeof value === "boolean" || typeof value === "number") return [];
|
|
17
|
-
if (typeof value === "string") return
|
|
18
|
+
if (typeof value === "string") return (0, _style.toSafeCssDeclarations)(value);
|
|
18
19
|
if (Array.isArray(value)) return value.flatMap(toDeclarations);
|
|
19
20
|
if (typeof value === "object") {
|
|
20
21
|
const bag = value;
|
|
21
|
-
return Object.keys(bag).filter(key => typeof bag[key] !== "undefined").map(key =>
|
|
22
|
+
return Object.keys(bag).filter(key => typeof bag[key] !== "undefined").map(key => (0, _style.toSafeCssDeclaration)(toKebabCase(key), String(bag[key]))).filter(declaration => declaration !== null);
|
|
22
23
|
}
|
|
23
24
|
return [];
|
|
24
25
|
}
|
|
@@ -2,17 +2,18 @@ import { computed, getCurrentInstance, inject, onMounted, toValue } from "vue";
|
|
|
2
2
|
import { ORIGAM_SSR_STYLES_KEY, SSR_STYLE_TAG_PREFIX } from "../../consts/Commons/ssr-style.const.js";
|
|
3
3
|
import { escapeCssIdent } from "../../utils/Commons/dom.util.js";
|
|
4
4
|
import { getCurrentInstanceName, getUid } from "../../utils/Commons/getCurrentInstance.util.js";
|
|
5
|
+
import { toSafeCssDeclaration, toSafeCssDeclarations } from "../../utils/Commons/style.util.js";
|
|
5
6
|
import { useStyleTag } from "./styleTag.composable.js";
|
|
6
7
|
function toKebabCase(key) {
|
|
7
8
|
return key.startsWith("--") ? key : key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
|
|
8
9
|
}
|
|
9
10
|
function toDeclarations(value) {
|
|
10
11
|
if (value == null || typeof value === "boolean" || typeof value === "number") return [];
|
|
11
|
-
if (typeof value === "string") return value
|
|
12
|
+
if (typeof value === "string") return toSafeCssDeclarations(value);
|
|
12
13
|
if (Array.isArray(value)) return value.flatMap(toDeclarations);
|
|
13
14
|
if (typeof value === "object") {
|
|
14
15
|
const bag = value;
|
|
15
|
-
return Object.keys(bag).filter((key) => typeof bag[key] !== "undefined").map((key) =>
|
|
16
|
+
return Object.keys(bag).filter((key) => typeof bag[key] !== "undefined").map((key) => toSafeCssDeclaration(toKebabCase(key), String(bag[key]))).filter((declaration) => declaration !== null);
|
|
16
17
|
}
|
|
17
18
|
return [];
|
|
18
19
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CSS_UNSAFE_VALUE_REGEX = exports.CSS_PROPERTY_NAME_REGEX = exports.CSS_LITERAL_REGEX = void 0;
|
|
7
|
+
const CSS_LITERAL_REGEX = exports.CSS_LITERAL_REGEX = /"(?:[^"\\\n\r\f]|\\.)*"|'(?:[^'\\\n\r\f]|\\.)*'|url\(\s*[^\s"'()\\]*\s*\)/gi;
|
|
8
|
+
const CSS_UNSAFE_VALUE_REGEX = exports.CSS_UNSAFE_VALUE_REGEX = /[;{}<>@\\\n\r\f"']|\/\*|\*\/|expression\s*\(/i;
|
|
9
|
+
const CSS_PROPERTY_NAME_REGEX = exports.CSS_PROPERTY_NAME_REGEX = /^(?:--[\w-]+|-?[a-z][a-z0-9-]*)$/i;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*********************************************************
|
|
2
|
+
* CSS_LITERAL_REGEX / CSS_UNSAFE_VALUE_REGEX / CSS_PROPERTY_NAME_REGEX (#1113)
|
|
3
|
+
*
|
|
4
|
+
* @description
|
|
5
|
+
* `useStyle()` serialises style values into the TEXT of a stylesheet, so a
|
|
6
|
+
* value is only safe when it cannot leave its declaration.
|
|
7
|
+
*
|
|
8
|
+
* @description
|
|
9
|
+
* `CSS_LITERAL_REGEX` matches the two places where `;`, `{`, `}` are plain
|
|
10
|
+
* content to the CSS tokenizer: a balanced quoted string and an unquoted
|
|
11
|
+
* `url(…)` body (`url(data:image/png;base64,…)`). They are masked before the
|
|
12
|
+
* unsafe test, so a `font-family: "A;B"` or a data URL keeps passing.
|
|
13
|
+
*
|
|
14
|
+
* @description
|
|
15
|
+
* `CSS_UNSAFE_VALUE_REGEX`, run on the MASKED value: a declaration or block
|
|
16
|
+
* boundary (`;` `{` `}`), markup (`<` `>`), an at-rule (`@`), an escape (`\`,
|
|
17
|
+
* which can spell `}` as `\7d`), a line break, a comment, a quote left
|
|
18
|
+
* unbalanced by the mask, or IE's `expression(`.
|
|
19
|
+
*
|
|
20
|
+
* @description
|
|
21
|
+
* `CSS_PROPERTY_NAME_REGEX`: a custom property (`--origam-btn---bg`) or a
|
|
22
|
+
* plain / vendor-prefixed property name, nothing else.
|
|
23
|
+
********************************************************/
|
|
24
|
+
export declare const CSS_LITERAL_REGEX: RegExp;
|
|
25
|
+
export declare const CSS_UNSAFE_VALUE_REGEX: RegExp;
|
|
26
|
+
export declare const CSS_PROPERTY_NAME_REGEX: RegExp;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export const CSS_LITERAL_REGEX = /"(?:[^"\\\n\r\f]|\\.)*"|'(?:[^'\\\n\r\f]|\\.)*'|url\(\s*[^\s"'()\\]*\s*\)/gi;
|
|
2
|
+
export const CSS_UNSAFE_VALUE_REGEX = /[;{}<>@\\\n\r\f"']|\/\*|\*\/|expression\s*\(/i;
|
|
3
|
+
export const CSS_PROPERTY_NAME_REGEX = /^(?:--[\w-]+|-?[a-z][a-z0-9-]*)$/i;
|
|
@@ -80,6 +80,17 @@ Object.keys(_ssrStyle).forEach(function (key) {
|
|
|
80
80
|
}
|
|
81
81
|
});
|
|
82
82
|
});
|
|
83
|
+
var _style = require("./Commons/style.const.cjs");
|
|
84
|
+
Object.keys(_style).forEach(function (key) {
|
|
85
|
+
if (key === "default" || key === "__esModule") return;
|
|
86
|
+
if (key in exports && exports[key] === _style[key]) return;
|
|
87
|
+
Object.defineProperty(exports, key, {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
get: function () {
|
|
90
|
+
return _style[key];
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
83
94
|
var _density = require("./Commons/density.const.cjs");
|
|
84
95
|
Object.keys(_density).forEach(function (key) {
|
|
85
96
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -5,6 +5,7 @@ export * from './Commons/commons.const';
|
|
|
5
5
|
export * from './Commons/date.const';
|
|
6
6
|
export * from './Commons/defaults.const';
|
|
7
7
|
export * from './Commons/ssr-style.const';
|
|
8
|
+
export * from './Commons/style.const';
|
|
8
9
|
export * from './Commons/density.const';
|
|
9
10
|
export * from './Commons/dimension.const';
|
|
10
11
|
export * from './Commons/layout.const';
|
package/dist/src/consts/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export * from "./Commons/commons.const.js";
|
|
|
5
5
|
export * from "./Commons/date.const.js";
|
|
6
6
|
export * from "./Commons/defaults.const.js";
|
|
7
7
|
export * from "./Commons/ssr-style.const.js";
|
|
8
|
+
export * from "./Commons/style.const.js";
|
|
8
9
|
export * from "./Commons/density.const.js";
|
|
9
10
|
export * from "./Commons/dimension.const.js";
|
|
10
11
|
export * from "./Commons/layout.const.js";
|
|
@@ -39,6 +39,7 @@ export interface IExpansionPanelProps extends ITagProps, ICommonsComponentProps,
|
|
|
39
39
|
export interface IExpansionPanelGroupItemProvide extends IGroupItemProvide {
|
|
40
40
|
headerId: Ref<string | undefined>;
|
|
41
41
|
contentId: Ref<string | undefined>;
|
|
42
|
+
uid: string;
|
|
42
43
|
}
|
|
43
44
|
/** Emits fired by `<OrigamExpansionPanel>` — group membership lifecycle. */
|
|
44
45
|
export interface IExpansionPanelEmits extends IGroupEmits {
|
|
@@ -268,7 +268,6 @@ const origamLightTheme = exports.origamLightTheme = {
|
|
|
268
268
|
},
|
|
269
269
|
"origam-chip": {
|
|
270
270
|
size: "small",
|
|
271
|
-
variant: "outlined",
|
|
272
271
|
color: "primary",
|
|
273
272
|
pill: true,
|
|
274
273
|
border: true,
|
|
@@ -682,7 +681,6 @@ const origamDarkTheme = exports.origamDarkTheme = {
|
|
|
682
681
|
},
|
|
683
682
|
"origam-chip": {
|
|
684
683
|
size: "small",
|
|
685
|
-
variant: "outlined",
|
|
686
684
|
color: "primary",
|
|
687
685
|
pill: true,
|
|
688
686
|
border: true,
|
|
@@ -172,7 +172,7 @@ export const origamLightTheme = {
|
|
|
172
172
|
"origam-btn-toggle": { variant: "text", size: "small" },
|
|
173
173
|
"origam-card": { tag: "div", density: "default", rounded: "lg", border: true },
|
|
174
174
|
"origam-checkbox": { density: "default" },
|
|
175
|
-
"origam-chip": { size: "small",
|
|
175
|
+
"origam-chip": { size: "small", color: "primary", pill: true, border: true, borderColor: "var(--origam-color__action--primary---bg)" },
|
|
176
176
|
"origam-clipboard": { tag: "span" },
|
|
177
177
|
"origam-code": { tag: "figure", rounded: "lg" },
|
|
178
178
|
"origam-color-picker-field": { density: "default", border: true, rounded: true },
|
|
@@ -342,7 +342,7 @@ export const origamDarkTheme = {
|
|
|
342
342
|
"origam-btn-toggle": { variant: "text", size: "small" },
|
|
343
343
|
"origam-card": { tag: "div", density: "default", rounded: "lg", border: true },
|
|
344
344
|
"origam-checkbox": { density: "default" },
|
|
345
|
-
"origam-chip": { size: "small",
|
|
345
|
+
"origam-chip": { size: "small", color: "primary", pill: true, border: true, borderColor: "var(--origam-color__action--primary---bg)" },
|
|
346
346
|
"origam-clipboard": { tag: "span" },
|
|
347
347
|
"origam-code": { tag: "figure", rounded: "lg" },
|
|
348
348
|
"origam-color-picker-field": { density: "default", border: true, rounded: true },
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.toSafeCssDeclaration = toSafeCssDeclaration;
|
|
7
|
+
exports.toSafeCssDeclarations = toSafeCssDeclarations;
|
|
8
|
+
var _style = require("../../consts/Commons/style.const.cjs");
|
|
9
|
+
function maskCssLiterals(value) {
|
|
10
|
+
return value.replace(_style.CSS_LITERAL_REGEX, literal => "_".repeat(literal.length));
|
|
11
|
+
}
|
|
12
|
+
function toSafeCssDeclaration(name, value) {
|
|
13
|
+
const safe = _style.CSS_PROPERTY_NAME_REGEX.test(name) && !_style.CSS_UNSAFE_VALUE_REGEX.test(maskCssLiterals(value));
|
|
14
|
+
return safe ? `${name}: ${value}` : null;
|
|
15
|
+
}
|
|
16
|
+
function toSafeCssDeclarations(style) {
|
|
17
|
+
const masked = maskCssLiterals(style);
|
|
18
|
+
const declarations = [];
|
|
19
|
+
let start = 0;
|
|
20
|
+
for (let end = 0; end <= masked.length; end++) {
|
|
21
|
+
if (end < masked.length && masked[end] !== ";") continue;
|
|
22
|
+
const colon = masked.indexOf(":", start);
|
|
23
|
+
if (colon !== -1 && colon < end) {
|
|
24
|
+
const declaration = toSafeCssDeclaration(style.slice(start, colon).trim(), style.slice(colon + 1, end).trim());
|
|
25
|
+
if (declaration) declarations.push(declaration);
|
|
26
|
+
}
|
|
27
|
+
start = end + 1;
|
|
28
|
+
}
|
|
29
|
+
return declarations;
|
|
30
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*********************************************************
|
|
2
|
+
* toSafeCssDeclaration (#1113)
|
|
3
|
+
*
|
|
4
|
+
* @description
|
|
5
|
+
* Returns `name: value` when both parts stay inside one declaration, `null`
|
|
6
|
+
* otherwise. The value is checked on its masked form, so `;` `{` `}` inside a
|
|
7
|
+
* quoted string or a `url(…)` body remain allowed.
|
|
8
|
+
********************************************************/
|
|
9
|
+
export declare function toSafeCssDeclaration(name: string, value: string): string | null;
|
|
10
|
+
/*********************************************************
|
|
11
|
+
* toSafeCssDeclarations (#1113)
|
|
12
|
+
*
|
|
13
|
+
* @description
|
|
14
|
+
* Splits an inline style STRING (`color: red; padding: 4px`) on the `;` that
|
|
15
|
+
* end a declaration — never on one inside a string or a `url(…)` body — and
|
|
16
|
+
* keeps only the declarations `toSafeCssDeclaration` accepts.
|
|
17
|
+
********************************************************/
|
|
18
|
+
export declare function toSafeCssDeclarations(style: string): string[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CSS_LITERAL_REGEX, CSS_PROPERTY_NAME_REGEX, CSS_UNSAFE_VALUE_REGEX } from "../../consts/Commons/style.const.js";
|
|
2
|
+
function maskCssLiterals(value) {
|
|
3
|
+
return value.replace(CSS_LITERAL_REGEX, (literal) => "_".repeat(literal.length));
|
|
4
|
+
}
|
|
5
|
+
export function toSafeCssDeclaration(name, value) {
|
|
6
|
+
const safe = CSS_PROPERTY_NAME_REGEX.test(name) && !CSS_UNSAFE_VALUE_REGEX.test(maskCssLiterals(value));
|
|
7
|
+
return safe ? `${name}: ${value}` : null;
|
|
8
|
+
}
|
|
9
|
+
export function toSafeCssDeclarations(style) {
|
|
10
|
+
const masked = maskCssLiterals(style);
|
|
11
|
+
const declarations = [];
|
|
12
|
+
let start = 0;
|
|
13
|
+
for (let end = 0; end <= masked.length; end++) {
|
|
14
|
+
if (end < masked.length && masked[end] !== ";") continue;
|
|
15
|
+
const colon = masked.indexOf(":", start);
|
|
16
|
+
if (colon !== -1 && colon < end) {
|
|
17
|
+
const declaration = toSafeCssDeclaration(style.slice(start, colon).trim(), style.slice(colon + 1, end).trim());
|
|
18
|
+
if (declaration) declarations.push(declaration);
|
|
19
|
+
}
|
|
20
|
+
start = end + 1;
|
|
21
|
+
}
|
|
22
|
+
return declarations;
|
|
23
|
+
}
|
package/dist/src/utils/index.cjs
CHANGED
|
@@ -168,6 +168,17 @@ Object.keys(_ssrStyles).forEach(function (key) {
|
|
|
168
168
|
}
|
|
169
169
|
});
|
|
170
170
|
});
|
|
171
|
+
var _style = require("./Commons/style.util.cjs");
|
|
172
|
+
Object.keys(_style).forEach(function (key) {
|
|
173
|
+
if (key === "default" || key === "__esModule") return;
|
|
174
|
+
if (key in exports && exports[key] === _style[key]) return;
|
|
175
|
+
Object.defineProperty(exports, key, {
|
|
176
|
+
enumerable: true,
|
|
177
|
+
get: function () {
|
|
178
|
+
return _style[key];
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
});
|
|
171
182
|
var _layout = require("./Commons/layout.util.cjs");
|
|
172
183
|
Object.keys(_layout).forEach(function (key) {
|
|
173
184
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -13,6 +13,7 @@ export * from './Commons/date.util';
|
|
|
13
13
|
export * from './Commons/elevation.util';
|
|
14
14
|
export * from './Commons/getCurrentInstance.util';
|
|
15
15
|
export * from './Commons/ssr-styles.util';
|
|
16
|
+
export * from './Commons/style.util';
|
|
16
17
|
export * from './Commons/layout.util';
|
|
17
18
|
export * from './Commons/locale.util';
|
|
18
19
|
export * from './Commons/nuxt-icons.util';
|
package/dist/src/utils/index.js
CHANGED
|
@@ -13,6 +13,7 @@ export * from "./Commons/date.util.js";
|
|
|
13
13
|
export * from "./Commons/elevation.util.js";
|
|
14
14
|
export * from "./Commons/getCurrentInstance.util.js";
|
|
15
15
|
export * from "./Commons/ssr-styles.util.js";
|
|
16
|
+
export * from "./Commons/style.util.js";
|
|
16
17
|
export * from "./Commons/layout.util.js";
|
|
17
18
|
export * from "./Commons/locale.util.js";
|
|
18
19
|
export * from "./Commons/nuxt-icons.util.js";
|