@tekkare/romulus 0.1.351 → 0.1.353

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.350",
7
+ "version": "0.1.352",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "2.0.0"
@@ -409,5 +409,5 @@ defineExpose({
409
409
  </template>
410
410
 
411
411
  <style scoped>
412
- .rm-dashboard{display:flex;flex-direction:column;gap:16px}.rm-dashboard__bar{align-items:center;display:flex;flex-wrap:wrap;gap:12px;justify-content:space-between}.rm-dashboard__status{align-items:center;color:var(--text-secondary);display:inline-flex;font-size:.8125rem;gap:4px;margin:0;min-height:1.25rem}.rm-dashboard__actions{display:flex;gap:8px;margin-left:auto}.rm-dashboard__link{background:none;color:var(--color-primary);cursor:pointer;padding:0;text-decoration:underline}.rm-dashboard__templates{display:flex;flex-direction:column;gap:12px;padding:4px}.rm-dashboard__template-group{display:flex;flex-direction:column;gap:6px}.rm-dashboard__template-label{color:var(--text-muted);font-size:var(--font-11);font-weight:var(--weight-semibold);letter-spacing:.06em;margin:0 4px;text-transform:uppercase}.rm-dashboard__template{background:var(--bg-surface);border:1px solid var(--border-soft);border-radius:var(--radius-md);color:var(--text-primary);cursor:pointer;display:flex;flex-direction:column;gap:2px;padding:10px 12px;text-align:left;transition:border-color var(--duration-fast) var(--ease-out),box-shadow var(--duration-fast) var(--ease-out);width:100%}.rm-dashboard__template:hover:not(:disabled){border-color:var(--border-default);box-shadow:var(--shadow-xs)}.rm-dashboard__template:focus-visible{box-shadow:var(--shadow-focus);outline:none}.rm-dashboard__template:disabled{cursor:default;opacity:.6}.rm-dashboard__template-title{font-size:var(--font-13);font-weight:var(--weight-semibold);line-height:18px}.rm-dashboard__template-desc{color:var(--text-secondary);font-size:var(--font-12);line-height:16px}.rm-dashboard__template-note{color:var(--text-secondary);font-size:var(--font-12);margin:0 4px}.rm-dashboard__confirm-title{font-size:var(--font-15,15px);font-weight:var(--weight-bold);margin:0}.rm-dashboard__confirm-text{color:var(--text-secondary);font-size:var(--font-13);margin:0}.rm-dashboard__confirm-actions{display:flex;gap:8px;justify-content:flex-end}
412
+ .rm-dashboard{display:flex;flex-direction:column;gap:16px}.rm-dashboard__bar{align-items:center;display:flex;flex-wrap:wrap;gap:12px;justify-content:space-between;padding-top:12px}.rm-dashboard__status{align-items:center;color:var(--text-secondary);display:inline-flex;font-size:.8125rem;gap:4px;margin:0;min-height:1.25rem}.rm-dashboard__actions{display:flex;gap:8px;margin-left:auto}.rm-dashboard__link{background:none;color:var(--color-primary);cursor:pointer;padding:0;text-decoration:underline}.rm-dashboard__templates{display:flex;flex-direction:column;gap:12px;padding:4px}.rm-dashboard__template-group{display:flex;flex-direction:column;gap:6px}.rm-dashboard__template-label{color:var(--text-muted);font-size:var(--font-11);font-weight:var(--weight-semibold);letter-spacing:.06em;margin:0 4px;text-transform:uppercase}.rm-dashboard__template{background:var(--bg-surface);border:1px solid var(--border-soft);border-radius:var(--radius-md);color:var(--text-primary);cursor:pointer;display:flex;flex-direction:column;gap:2px;padding:10px 12px;text-align:left;transition:border-color var(--duration-fast) var(--ease-out),box-shadow var(--duration-fast) var(--ease-out);width:100%}.rm-dashboard__template:hover:not(:disabled){border-color:var(--border-default);box-shadow:var(--shadow-xs)}.rm-dashboard__template:focus-visible{box-shadow:var(--shadow-focus);outline:none}.rm-dashboard__template:disabled{cursor:default;opacity:.6}.rm-dashboard__template-title{font-size:var(--font-13);font-weight:var(--weight-semibold);line-height:18px}.rm-dashboard__template-desc{color:var(--text-secondary);font-size:var(--font-12);line-height:16px}.rm-dashboard__template-note{color:var(--text-secondary);font-size:var(--font-12);margin:0 4px}.rm-dashboard__confirm-title{font-size:var(--font-15,15px);font-weight:var(--weight-bold);margin:0}.rm-dashboard__confirm-text{color:var(--text-secondary);font-size:var(--font-13);margin:0}.rm-dashboard__confirm-actions{display:flex;gap:8px;justify-content:flex-end}
413
413
  </style>
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { computed, ref, toRef } from 'vue'
2
+ import { computed, ref, toRef, watch } from 'vue'
3
3
  import { useRmDialog } from '../composables/useRmDialog'
4
4
 
5
5
  export interface RmDrawerProps {
@@ -15,7 +15,7 @@ export interface RmDrawerProps {
15
15
  side?: 'right' | 'left'
16
16
  /** Show overlay behind the drawer */
17
17
  overlay?: boolean
18
- /** Offset from the edge (e.g. '280px' to keep a panel visible) */
18
+ /** Offset from the edge (e.g. '280px' to keep a panel visible). Absent, a right drawer sits beside the OIP right rail. */
19
19
  offset?: string
20
20
  /**
21
21
  * Nom accessible du tiroir. A renseigner des que l'en-tete est purement
@@ -46,7 +46,7 @@ const props = withDefaults(defineProps<RmDrawerProps>(), {
46
46
  size: 'lg',
47
47
  side: 'right',
48
48
  overlay: true,
49
- offset: '0px',
49
+ offset: undefined,
50
50
  label: undefined,
51
51
  labelledBy: undefined,
52
52
  closeLabel: 'Fermer',
@@ -76,6 +76,29 @@ const sizeMap: Record<string, string> = {
76
76
  const drawerWidth = computed(() => sizeMap[props.size] || props.size)
77
77
 
78
78
  const layer = computed(() => (props.zIndex === undefined ? undefined : { zIndex: props.zIndex }))
79
+
80
+ /**
81
+ * Un tiroir de droite sans `offset` se pose a gauche du rail de droite d'un
82
+ * shell OIP (`.rm-sb--right`), a sa hauteur : sinon le rail, au-dessus de
83
+ * tout, masquait le bord du tiroir et ses boutons de pied. Mesure a chaque
84
+ * ouverture (le rail glisse quand un panneau s'ouvre). Sans rail, le tiroir
85
+ * colle au bord comme avant.
86
+ */
87
+ const railFit = ref<{ offset: string, inset?: string } | null>(null)
88
+ function fitRail() {
89
+ if (typeof document === 'undefined' || props.side !== 'right' || props.offset !== undefined) {
90
+ railFit.value = null
91
+ return
92
+ }
93
+ const rail = document.querySelector('.rm-sb--right')?.getBoundingClientRect()
94
+ railFit.value = rail && rail.width
95
+ ? { offset: `${Math.max(0, Math.round(window.innerWidth - rail.left))}px`, inset: rail.top > 0 ? `${Math.round(rail.top)}px` : undefined }
96
+ : null
97
+ }
98
+ watch(() => props.modelValue, (open) => { if (open) fitRail() }, { immediate: true })
99
+
100
+ const sideOffset = computed(() => props.offset ?? railFit.value?.offset ?? '0px')
101
+ const edgeInset = computed(() => props.inset ?? railFit.value?.inset)
79
102
  </script>
80
103
 
81
104
  <template>
@@ -94,8 +117,8 @@ const layer = computed(() => (props.zIndex === undefined ? undefined : { zIndex:
94
117
  v-if="modelValue"
95
118
  ref="surface"
96
119
  class="rm-drawer"
97
- :class="[`rm-drawer--${side}`, { 'rm-drawer--inset': inset, 'rm-drawer--attached': inset && offset !== '0px' }]"
98
- :style="[{ width: drawerWidth, [side]: offset }, inset ? { top: inset, bottom: inset } : {}, layer]"
120
+ :class="[`rm-drawer--${side}`, { 'rm-drawer--inset': edgeInset, 'rm-drawer--attached': edgeInset && sideOffset !== '0px' }]"
121
+ :style="[{ width: drawerWidth, [side]: sideOffset }, edgeInset ? { top: edgeInset, bottom: edgeInset } : {}, layer]"
99
122
  role="dialog"
100
123
  aria-modal="true"
101
124
  :aria-label="labelledBy ? undefined : label"
@@ -35,13 +35,25 @@
35
35
  @create="onCreate"
36
36
  >
37
37
  <template v-if="button" #new="{ openForm }">
38
- <component :is="button" size="sm" @free="openForm" />
38
+ <!-- Branche sur le layer : les memes gestes que « Mes projets » (creation
39
+ libre dans la meme fenetre, nom et description, ou creation guidee). -->
40
+ <component :is="button" size="sm" @free="own ? (dialogOpen = true) : openForm()" />
39
41
  </template>
40
42
  </RmProjectPanel>
43
+
44
+ <RmProjectCreateDialog
45
+ v-if="own"
46
+ v-model="dialogOpen"
47
+ :loading="dialogSaving"
48
+ :error="dialogError"
49
+ :lang="locale === 'en' ? 'en' : 'fr'"
50
+ @create="createFromDialog"
51
+ />
41
52
  </template>
42
53
 
43
54
  <script setup lang="ts">
44
- import { resolveComponent, type Component } from "vue";
55
+ import type { Component } from "vue";
56
+ import ProjectNewButton from "../project/NewButton.vue";
45
57
  import type { RmProject } from "@tekkare/romulus/utils/projects";
46
58
  import { PROJECTS_PATH, PROJECTS_UPSELL, useProjectsAccess } from "#oip-projects";
47
59
 
@@ -98,7 +110,10 @@ const creating = ref(false);
98
110
  const wired = props.projects === undefined;
99
111
  const own = wired ? useProjects() : null;
100
112
  const allowed = useProjectsAccess();
101
- const newProjectButton = resolveComponent("ProjectNewButton");
113
+ // Importe, pas resolu par son nom : un composant du layer n'est pas enregistre
114
+ // globalement, `resolveComponent` rendait une chaine et le panneau retombait
115
+ // sur son seul formulaire du nom.
116
+ const newProjectButton = ProjectNewButton;
102
117
 
103
118
  const list = computed(() => (own ? own.rmProjects.value : props.projects ?? []));
104
119
  const active = computed(() => (own ? own.activeId.value : props.activeId));
@@ -124,6 +139,31 @@ async function onCreate(title: string) {
124
139
  }
125
140
  }
126
141
 
142
+ /**
143
+ * La creation libre du panneau, la meme que celle de « Mes projets » : nom et
144
+ * description, puis le projet devient l'actif et s'ouvre.
145
+ */
146
+ const dialogOpen = ref(false);
147
+ const dialogSaving = ref(false);
148
+ const dialogError = ref("");
149
+ async function createFromDialog(value: { title: string; description: string }) {
150
+ if (!own) return;
151
+ dialogSaving.value = true;
152
+ dialogError.value = "";
153
+ try {
154
+ const project = await own.create(value.title, value.description);
155
+ dialogOpen.value = false;
156
+ own.setActive(project.id);
157
+ emit("close");
158
+ own.open(project.id);
159
+ } catch (error: any) {
160
+ dialogError.value =
161
+ error?.data?.error || error?.data?.message || (locale.value === "en" ? "The project was not created" : "Le projet n'a pas été créé");
162
+ } finally {
163
+ dialogSaving.value = false;
164
+ }
165
+ }
166
+
127
167
  function activate(id: string) {
128
168
  if (own) own.setActive(id);
129
169
  else emit("activate", id);
@@ -18,8 +18,6 @@
18
18
  <RmDrawer
19
19
  :model-value="modelValue"
20
20
  size="xl"
21
- :offset="railOffset"
22
- :inset="railInset"
23
21
  :label="tr('Création guidée', 'Guided creation')"
24
22
  @update:model-value="requestClose"
25
23
  >
@@ -418,20 +416,6 @@ const KIND_META: Record<GuidedMatchKind, { label: { fr: string; en: string }; he
418
416
  /** Les blocs que l'app propose (`PROJECT_GUIDED_BLOCKS`), dans l'ordre du layer. */
419
417
  const blocks = computed<GuidedBlock[]>(() => GUIDED_BLOCKS.filter((block) => (PROJECT_GUIDED_BLOCKS ?? []).includes(block.key)));
420
418
 
421
- /**
422
- * Le tiroir se pose a gauche du rail de droite (z-index 402) plutot que
423
- * dessous : sinon le rail masque le bouton « Continuer ». Passer au-dessus
424
- * ferait passer le tiroir devant la confirmation de sortie (modale, 100).
425
- */
426
- const railOffset = ref("0px");
427
- /** Meme marge haute et basse que le rail : les deux panneaux s'alignent. */
428
- const railInset = ref<string | undefined>(undefined);
429
- function measureRail() {
430
- const rail = document.querySelector(".rm-sb--right")?.getBoundingClientRect();
431
- railOffset.value = rail ? `${Math.max(0, window.innerWidth - rail.left)}px` : "0px";
432
- railInset.value = rail && rail.top > 0 ? `${Math.round(rail.top)}px` : undefined;
433
- }
434
-
435
419
  const step = ref<Step>("subjects");
436
420
  const stepIndex = computed(() => STEPS.findIndex((entry) => entry.key === step.value));
437
421
 
@@ -937,7 +921,6 @@ watch(
937
921
  (open) => {
938
922
  if (!open) return;
939
923
  reset();
940
- measureRail();
941
924
  preloadGuidedSubjects();
942
925
  nextTick(() => searchInput.value?.focus());
943
926
  },
@@ -68,23 +68,35 @@ const DEFAULT_LAYOUT: Array<{ kind: string; viz: RmDashboardWidget["viz"]; w: nu
68
68
 
69
69
  /**
70
70
  * Pose les widgets ligne par ligne sur les 12 colonnes : un widget qui ne
71
- * tient plus sur la ligne passe a la suivante, sans trou laisse par ceux
72
- * qui n'ont rien a montrer.
71
+ * tient plus sur la ligne passe a la suivante. Une ligne incomplete (un
72
+ * voisin prevu n'avait rien a montrer) s'etire : ses widgets se partagent
73
+ * les colonnes restantes au prorata de leur largeur, et prennent tous la
74
+ * hauteur du plus haut. Pas de trou dans le tableau de depart.
73
75
  */
74
76
  function pack(entries: Array<{ kind: string; viz: RmDashboardWidget["viz"]; w: number; h: number }>): RmDashboardModel {
75
- const widgets: RmDashboardWidget[] = [];
76
- let x = 0;
77
- let y = 0;
78
- let rowHeight = 0;
77
+ const rows: Array<typeof entries> = [];
78
+ let width = 0;
79
79
  for (const entry of entries) {
80
- if (x + entry.w > 12) {
81
- x = 0;
82
- y += rowHeight;
83
- rowHeight = 0;
80
+ if (!rows.length || width + entry.w > 12) {
81
+ rows.push([]);
82
+ width = 0;
84
83
  }
85
- widgets.push({ id: rmNewWidgetId(), kind: entry.kind, viz: entry.viz, params: {}, layout: { x, y, w: entry.w, h: entry.h } });
86
- x += entry.w;
87
- rowHeight = Math.max(rowHeight, entry.h);
84
+ rows[rows.length - 1]!.push(entry);
85
+ width += entry.w;
86
+ }
87
+ const widgets: RmDashboardWidget[] = [];
88
+ let y = 0;
89
+ for (const row of rows) {
90
+ const total = row.reduce((sum, entry) => sum + entry.w, 0);
91
+ const height = Math.max(...row.map((entry) => entry.h));
92
+ let x = 0;
93
+ row.forEach((entry, index) => {
94
+ // Le dernier prend ce qui reste : les arrondis ne laissent jamais de colonne vide.
95
+ const w = index === row.length - 1 ? 12 - x : Math.max(1, Math.round((entry.w * 12) / total));
96
+ widgets.push({ id: rmNewWidgetId(), kind: entry.kind, viz: entry.viz, params: {}, layout: { x, y, w, h: height } });
97
+ x += w;
98
+ });
99
+ y += height;
88
100
  }
89
101
  return { version: 1, widgets };
90
102
  }
@@ -20,6 +20,7 @@ import type { RmDashboardModel, RmDashboardWidget, RmWidgetContext, RmWidgetKind
20
20
  import { rmAddableWidgets, rmNewWidgetId } from "@tekkare/romulus/utils/dashboard";
21
21
  import type { ProjectInboxItem, ProjectSuggestion } from "../types/projects";
22
22
  import type { GuidedBlockKey } from "../oip-guided/families";
23
+ import { oipProjectBrands } from "../oip-drugs/dashboardWidgets";
23
24
 
24
25
  type Lang = "fr" | "en";
25
26
  type Text = { fr: string; en: string };
@@ -118,11 +119,62 @@ export const PROJECT_WORDING: {
118
119
 
119
120
  /** Les rangees du cadrage de la vue d'ensemble. Aucune par defaut. */
120
121
  export function useProjectScopeRows(
121
- _project: Ref<{ scope?: unknown } | null>,
122
- _rows: Ref<RmProjectResource[]>,
123
- _lang: Ref<Lang>,
122
+ project: Ref<{ scope?: unknown } | null>,
123
+ rows: Ref<RmProjectResource[]>,
124
+ lang: Ref<Lang>,
124
125
  ): ComputedRef<RmProjectScopeRow[]> {
125
- return computed(() => []);
126
+ return computed(() => oipProjectScopeRows(project.value?.scope, rows.value, lang.value));
127
+ }
128
+
129
+ /**
130
+ * Le cadrage par defaut de la vue d'ensemble, lu dans le projet lui-meme :
131
+ * les sujets poses a la creation guidee (`scope` : maladies avec leur code,
132
+ * molecules, marques), puis ce que le projet range (les marques des fiches,
133
+ * les familles et leur nombre, les pays). Une app garde le sien en exportant
134
+ * `useProjectScopeRows`.
135
+ */
136
+ export function oipProjectScopeRows(scope: unknown, rows: RmProjectResource[], lang: Lang): RmProjectScopeRow[] {
137
+ const s = (scope ?? {}) as {
138
+ diseases?: Array<{ label?: string; code?: string; system?: string }>;
139
+ molecules?: Array<{ label?: string }>;
140
+ brands?: string[];
141
+ };
142
+ const uniq = (values: string[]) => [...new Set(values.map((value) => value.trim()).filter(Boolean))];
143
+ const diseases = uniq(
144
+ (s.diseases ?? []).map((disease) =>
145
+ disease.code ? `${disease.label} (${disease.system === "orpha" ? "ORPHA:" : ""}${disease.code})` : String(disease.label ?? ""),
146
+ ),
147
+ );
148
+ const molecules = uniq((s.molecules ?? []).map((molecule) => String(molecule.label ?? "")));
149
+ // Les marques choisies d'abord, puis celles des fiches rangees.
150
+ const brands = uniq([
151
+ ...(s.brands ?? []).map((brand) => String(brand).toUpperCase()),
152
+ ...oipProjectBrands(rows.map((row) => ({ type: row.type, source: (row.source ?? {}) as Record<string, any> }))),
153
+ ]);
154
+ const families = new Map<string, number>();
155
+ for (const row of rows) families.set(row.family, (families.get(row.family) ?? 0) + 1);
156
+ const countryName = (code: string) => {
157
+ try {
158
+ return new Intl.DisplayNames([lang], { type: "region" }).of(code.toUpperCase()) ?? code;
159
+ } catch {
160
+ return code;
161
+ }
162
+ };
163
+ const countries = uniq(rows.map((row) => row.country ?? "").filter(Boolean).map(countryName));
164
+ const out: RmProjectScopeRow[] = [];
165
+ if (diseases.length) out.push({ key: "diseases", label: T(lang, "Maladies", "Diseases"), icon: "Heartbeat", values: diseases });
166
+ if (molecules.length) out.push({ key: "molecules", label: T(lang, "Molécules", "Molecules"), icon: "Atom", values: molecules });
167
+ if (brands.length) out.push({ key: "brands", label: T(lang, "Marques", "Brands"), icon: "Pill", values: brands });
168
+ if (families.size) {
169
+ out.push({
170
+ key: "families",
171
+ label: T(lang, "Sources", "Sources"),
172
+ icon: "Stack",
173
+ values: [...families].sort((a, b) => b[1] - a[1]).map(([family, count]) => `${family} (${count})`),
174
+ });
175
+ }
176
+ if (countries.length) out.push({ key: "countries", label: T(lang, "Pays", "Countries"), icon: "GlobeHemisphereWest", values: countries });
177
+ return out;
126
178
  }
127
179
 
128
180
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tekkare/romulus",
3
- "version": "0.1.351",
3
+ "version": "0.1.353",
4
4
  "description": "Romulus Design System - Nuxt module by Tekkare",
5
5
  "license": "MIT",
6
6
  "type": "module",