@tekkare/romulus 0.1.283 → 0.1.285

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/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.16.0"
6
6
  },
7
- "version": "0.1.282",
7
+ "version": "0.1.284",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "2.0.0"
@@ -50,25 +50,33 @@
50
50
  </div>
51
51
  </div>
52
52
 
53
- <div v-for="block in textBlocks" :key="block.key" class="oip_list gap-4">
54
- <p class="oip_label">{{ block.label }}</p>
55
- <p :id="`${blockId}-${block.key}`" class="am_text" :class="{ 'am_text--clamped': !expanded[block.key] }">
56
- <template v-for="(seg, si) in block.segments" :key="si"><mark v-if="seg.hit">{{ seg.text }}</mark><template v-else>{{ seg.text }}</template></template>
57
- </p>
58
- <button
59
- v-if="block.long"
60
- type="button"
61
- class="am_toggle"
62
- :aria-expanded="!!expanded[block.key]"
63
- :aria-controls="`${blockId}-${block.key}`"
64
- @click="expanded[block.key] = !expanded[block.key]"
65
- >
66
- {{
67
- expanded[block.key]
68
- ? t("oipDrugs.heart.associations.nationalAssembly.amendments.card.showLess")
69
- : t("oipDrugs.heart.associations.nationalAssembly.amendments.card.showMore")
70
- }}
71
- </button>
53
+ <!-- Dispositif et expose : un bloc a part, aere, pour ne pas se lire d'un trait. -->
54
+ <div v-if="textBlocks.length > 0" class="am_texts">
55
+ <div v-for="block in textBlocks" :key="block.key" class="oip_list gap-4">
56
+ <p class="oip_label">{{ block.label }}</p>
57
+ <p
58
+ :id="`${blockId}-${block.key}`"
59
+ :ref="(el) => watchOverflow(block.key, el as HTMLElement | null)"
60
+ class="am_text"
61
+ :class="{ 'am_text--clamped': !expanded[block.key] }"
62
+ >
63
+ <template v-for="(seg, si) in block.segments" :key="si"><mark v-if="seg.hit">{{ seg.text }}</mark><template v-else>{{ seg.text }}</template></template>
64
+ </p>
65
+ <button
66
+ v-if="overflowing[block.key]"
67
+ type="button"
68
+ class="am_toggle"
69
+ :aria-expanded="!!expanded[block.key]"
70
+ :aria-controls="`${blockId}-${block.key}`"
71
+ @click="expanded[block.key] = !expanded[block.key]"
72
+ >
73
+ {{
74
+ expanded[block.key]
75
+ ? t("oipDrugs.heart.associations.nationalAssembly.amendments.card.showLess")
76
+ : t("oipDrugs.heart.associations.nationalAssembly.amendments.card.showMore")
77
+ }}
78
+ </button>
79
+ </div>
72
80
  </div>
73
81
 
74
82
  <p v-if="amendment[AMENDMENT_FIELDS.irrecevability]" class="am_irrecevable">
@@ -76,6 +84,9 @@
76
84
  </p>
77
85
 
78
86
  <div v-if="amendment[AMENDMENT_FIELDS.url]" class="oip_row gap-8 wrap">
87
+ <RmButton variant="secondary" prefix-icon="FilePdf" @click="emit('read', amendment)">
88
+ {{ t("oipDrugs.heart.associations.nationalAssembly.amendments.card.pdf") }}
89
+ </RmButton>
79
90
  <RmButton
80
91
  v-if="amendmentDiscussed(amendment)"
81
92
  variant="secondary"
@@ -84,9 +95,6 @@
84
95
  >
85
96
  {{ t("oipDrugs.heart.associations.nationalAssembly.amendments.card.report") }}
86
97
  </RmButton>
87
- <RmButton variant="secondary" prefix-icon="FilePdf" @click="emit('read', amendment)">
88
- {{ t("oipDrugs.heart.associations.nationalAssembly.amendments.card.pdf") }}
89
- </RmButton>
90
98
  <RmButton
91
99
  variant="tertiary"
92
100
  ghost
@@ -100,7 +108,7 @@
100
108
  </template>
101
109
 
102
110
  <script lang="ts" setup>
103
- import { useId } from "vue";
111
+ import { nextTick, onBeforeUnmount, useId, watch } from "vue";
104
112
  import { AMENDMENT_FIELDS, amendmentDiscussed } from "../../../../oip-drugs/utils/associationFields";
105
113
  import { highlightSegments } from "../../../../oip-drugs/utils/esHighlight";
106
114
  import { drugsAssociationPath } from "../../../../oip-drugs/kinds";
@@ -201,9 +209,6 @@ const associations = computed<string[]>(() => {
201
209
  .sort((a, b) => a.localeCompare(b, "fr"));
202
210
  });
203
211
 
204
- /** Au-dela, le texte se replie sur quatre lignes. */
205
- const LONG_TEXT = 320;
206
-
207
212
  /** Dispositif puis expose, surlignes quand le moteur l'a fait. */
208
213
  const textBlocks = computed(() =>
209
214
  (
@@ -218,7 +223,6 @@ const textBlocks = computed(() =>
218
223
  return {
219
224
  key,
220
225
  label: t(`oipDrugs.heart.associations.nationalAssembly.amendments.card.${key}`),
221
- long: plain.length > LONG_TEXT,
222
226
  segments: highlighted ? highlightSegments(highlighted) : [{ text: plain, hit: false }],
223
227
  plain,
224
228
  };
@@ -228,6 +232,35 @@ const textBlocks = computed(() =>
228
232
 
229
233
  const expanded = reactive<Record<string, boolean>>({});
230
234
 
235
+ /**
236
+ * « Afficher tout » ne vaut que si le texte deborde vraiment ses quatre
237
+ * lignes. Un seuil en caracteres se trompe selon la largeur de la carte :
238
+ * on mesure le paragraphe replie, et on garde la reponse une fois deplie
239
+ * pour pouvoir le replier.
240
+ */
241
+ const overflowing = reactive<Record<string, boolean>>({});
242
+ const observed = new Map<string, HTMLElement>();
243
+ function measure() {
244
+ for (const [key, el] of observed) {
245
+ if (!expanded[key]) overflowing[key] = el.scrollHeight > el.clientHeight + 1;
246
+ }
247
+ }
248
+ const resizeObserver = import.meta.client ? new ResizeObserver(measure) : null;
249
+ // Un nouveau surlignage peut changer le texte sans changer la hauteur repliee.
250
+ watch(textBlocks, () => nextTick(measure));
251
+
252
+ function watchOverflow(key: string, el: HTMLElement | null) {
253
+ const previous = observed.get(key);
254
+ if (previous === el) return;
255
+ if (previous) resizeObserver?.unobserve(previous);
256
+ if (el) {
257
+ observed.set(key, el);
258
+ resizeObserver?.observe(el);
259
+ } else observed.delete(key);
260
+ }
261
+
262
+ onBeforeUnmount(() => resizeObserver?.disconnect());
263
+
231
264
  function openLink(url: string) {
232
265
  if (url) window.open(url, "_blank");
233
266
  }
@@ -260,6 +293,13 @@ function openLink(url: string) {
260
293
  outline-offset: 2px;
261
294
  }
262
295
 
296
+ .am_texts {
297
+ display: flex;
298
+ flex-direction: column;
299
+ gap: var(--space-24);
300
+ margin-block: var(--space-8);
301
+ }
302
+
263
303
  .am_text {
264
304
  margin: 0;
265
305
  color: var(--text-primary);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tekkare/romulus",
3
- "version": "0.1.283",
3
+ "version": "0.1.285",
4
4
  "description": "Romulus Design System - Nuxt module by Tekkare",
5
5
  "license": "MIT",
6
6
  "type": "module",