@mgamadeus/ddd-design-studio 0.9.3 → 0.11.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/README.md CHANGED
@@ -82,10 +82,14 @@ const designStudioApi = createDesignStudioApi({ baseApi, apiPrefix: '/api/admin/
82
82
  `createDesignStudioApi` calls `baseApi.enhanceEndpoints({ addTagTypes: ['DesignStudio'] }).injectEndpoints(…)` once and
83
83
  returns the hooks. One cache tag: every query provides it, every mutation invalidates it.
84
84
 
85
+ The canvas screen asks `useThemesQuery` for the shown canvas and shows the theme switcher when the overview's
86
+ `hasThemes` (the provider's) or the canvas view's `hasThemes` (`DesignStudioCanvasView.hasThemes`) (also true for theme files of the canvas' design system)
87
+ is true (`hasCanvasThemes()` in `canvas/designTheme.ts`).
88
+
85
89
  | Hook | Request (below `apiPrefix`) |
86
90
  |---|---|
87
91
  | `useOverviewQuery` | `GET /overview` |
88
- | `useThemesQuery` | `GET /themes` |
92
+ | `useThemesQuery` | `GET /themes`; argument `DesignStudioThemesArg` `{ search?, projectKey?, canvasKey? }`: with both keys the themes of that canvas (the provider's, then the theme files of its design system) |
89
93
  | `useCanvasQuery` | `GET /canvases/{projectKey}/{canvasKey}` |
90
94
  | `useCanvasRevisionQuery` | `GET /canvases/{projectKey}/{canvasKey}/revision` |
91
95
  | `useCanvasCommentsQuery` | `GET /canvases/{projectKey}/{canvasKey}/comments` |
@@ -102,7 +106,12 @@ returns the hooks. One cache tag: every query provides it, every mutation invali
102
106
  | `useKeepCommentMutation` | `POST /comments/{designStudioCommentId}/keep` |
103
107
 
104
108
  Request bodies are passed as `body`; the canvas, revision, comments and render-request operations take the optional
105
- `theme` query parameter (`<themeId>[:<mode>]`).
109
+ `theme` query parameter (`<themeId>[:<mode>]`). The revision must be asked for in the look the canvas is shown in (the
110
+ canvas screen passes the same argument to both): it changes with that theme's style. A new thread sends the shown
111
+ look as body `theme`, so the thread keeps the state it was written on (board version, `dependenciesHash`,
112
+ `themeReference`, `themeHash`); the canvas view carries `themeHash`, each board `dependenciesHash`, and a thread shows
113
+ "Board changed since", "Assets or theme changed since" and a link to the commented version
114
+ (`compareThreadState()` / `buildCommentedVersionUrl()` in `src/canvas/threadState.ts`).
106
115
 
107
116
  ## Environment (`DesignStudioEnvironment`)
108
117
 
@@ -170,6 +179,11 @@ Inside the package, components read it with `useDesignStudio()` or the narrower
170
179
  | `exportSvgDiffering(percent)` | `Differs from the raster picture in 5.3 % of the pixels.` |
171
180
  | `exportSvgLostEffects` | `Raster \| SVG \| differing pixels in red. Glass (backdrop-filter), blend modes and some filters are lost in SVG.` |
172
181
  | `exportSvgDownload` | `Download SVG` |
182
+ | `threadDependenciesChangedSince` | `Assets or theme changed since` (badge of a thread) |
183
+ | `threadDependenciesChangedSinceTitle` | `An image or script the board loads, or the style of the theme it is shown in, changed after this thread was written` |
184
+ | `showCommentedVersion` | `Show the commented version` (link of a thread whose board, assets or theme changed) |
185
+ | `statusDependenciesChangedSince` | `assets changed since` (next to the status chips) |
186
+ | `statusDependenciesChangedSinceTitle` | `An image or script the board loads changed after this status was set` |
173
187
 
174
188
  ```ts
175
189
  const ENVIRONMENT: DesignStudioEnvironment = {
@@ -18,6 +18,7 @@ import {
18
18
  findBoardForCode,
19
19
  frameCanvasHeight,
20
20
  framesOf,
21
+ hasCanvasThemes,
21
22
  initialViewportForBoard,
22
23
  isPinInViewport,
23
24
  isResponsiveBoard,
@@ -33,7 +34,7 @@ import {
33
34
  viewportOfComment,
34
35
  viewportWithWidth,
35
36
  wasContentUrlLoaded
36
- } from "../chunk-WFH4CMA6.js";
37
+ } from "../chunk-PCXDVGGG.js";
37
38
 
38
39
  // src/canvas/DesignStudioCanvasScreen.tsx
39
40
  import { normalizeDddError as normalizeDddError3 } from "@mgamadeus/ddd-web/api";
@@ -797,6 +798,7 @@ var BoardStatusChips = ({
797
798
  onStatusChanged
798
799
  }) => {
799
800
  const { api, notify, statuses: statusDefinitions } = useDesignStudio();
801
+ const texts = useDesignStudioTexts();
800
802
  const [patchStatus, { isLoading }] = api.useSetBoardStatusMutation();
801
803
  return /* @__PURE__ */ jsxs3("fieldset", { className: "m-0 flex flex-wrap items-center gap-1.5 border-0 p-0", "aria-label": "Board status", children: [
802
804
  statuses.map((status) => {
@@ -834,7 +836,8 @@ var BoardStatusChips = ({
834
836
  status
835
837
  );
836
838
  }),
837
- board.hasChangedSinceStatus && /* @__PURE__ */ jsx3("span", { className: "text-xs text-muted-foreground", title: "The board file changed after this status was set", children: "changed since" })
839
+ board.hasChangedSinceStatus && /* @__PURE__ */ jsx3("span", { className: "text-xs text-muted-foreground", title: "The board file changed after this status was set", children: "changed since" }),
840
+ board.hasDependenciesChangedSinceStatus && /* @__PURE__ */ jsx3("span", { className: "text-xs text-muted-foreground", title: texts.statusDependenciesChangedSinceTitle, children: texts.statusDependenciesChangedSince })
838
841
  ] });
839
842
  };
840
843
 
@@ -952,6 +955,7 @@ var BoardFocusView = ({
952
955
  onCopyReference,
953
956
  onCopyThreadReference,
954
957
  themeReference = null,
958
+ themeHash,
955
959
  themeLabel = "",
956
960
  isRendererEnabled = false
957
961
  }) => {
@@ -1367,7 +1371,9 @@ var BoardFocusView = ({
1367
1371
  onShowResolvedChange: setShowResolved,
1368
1372
  pinHint: "\u201CAdd pin\u201D marks a spot on the board",
1369
1373
  onCopyThreadReference,
1370
- onSelectViewport: isResponsive ? onViewportChange : void 0
1374
+ onSelectViewport: isResponsive ? onViewportChange : void 0,
1375
+ themeReference,
1376
+ themeHash
1371
1377
  }
1372
1378
  ) })
1373
1379
  ] })
@@ -2122,7 +2128,9 @@ var SelectedBoardPanel = ({
2122
2128
  onOpen,
2123
2129
  onCopyLink,
2124
2130
  onStatusChanged,
2125
- onCopyThreadReference
2131
+ onCopyThreadReference,
2132
+ themeReference,
2133
+ themeHash
2126
2134
  }) => {
2127
2135
  const { Button } = useDesignStudioComponents();
2128
2136
  const texts = useDesignStudioTexts();
@@ -2177,7 +2185,9 @@ var SelectedBoardPanel = ({
2177
2185
  showResolved,
2178
2186
  onShowResolvedChange: setShowResolved,
2179
2187
  pinHint: "open the focus view to pin it to a spot",
2180
- onCopyThreadReference
2188
+ onCopyThreadReference,
2189
+ themeReference,
2190
+ themeHash
2181
2191
  }
2182
2192
  )
2183
2193
  ] });
@@ -2265,12 +2275,14 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2265
2275
  const overview = overviewData?.designStudioOverview;
2266
2276
  const projectSummary = overview?.projects?.elements?.find((project) => project.projectKey === projectKey);
2267
2277
  const canvasSummary = projectSummary?.canvases?.elements?.find((item) => item.canvasKey === canvasKey);
2268
- const hasThemes = Boolean(overview?.hasThemes);
2278
+ const [loadedCanvasHasThemes, setLoadedCanvasHasThemes] = useState8(false);
2279
+ const hasThemes = hasCanvasThemes(overview?.hasThemes, loadedCanvasHasThemes);
2280
+ const themesQueryArgument = useMemo2(() => ({ projectKey, canvasKey }), [projectKey, canvasKey]);
2269
2281
  const {
2270
2282
  data: themesData,
2271
2283
  isLoading: isLoadingThemes,
2272
2284
  isError: isThemesError
2273
- } = api.useThemesQuery({}, { skip: !hasThemes });
2285
+ } = api.useThemesQuery(themesQueryArgument, { skip: !hasThemes });
2274
2286
  const themes = useMemo2(() => themesData?.designThemes.elements ?? [], [themesData]);
2275
2287
  const isDefaultLook = chosenThemeId === null && chosenMode === null;
2276
2288
  const isLookResolved = isDefaultLook || (overviewData !== void 0 || isOverviewError) && (!hasThemes || themesData !== void 0 || isThemesError);
@@ -2314,6 +2326,9 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2314
2326
  if (canvas && (canvas.referenceTheme ?? null) !== loadedReferenceTheme) {
2315
2327
  setLoadedReferenceTheme(canvas.referenceTheme ?? null);
2316
2328
  }
2329
+ if (canvas && Boolean(canvas.hasThemes) !== loadedCanvasHasThemes) {
2330
+ setLoadedCanvasHasThemes(Boolean(canvas.hasThemes));
2331
+ }
2317
2332
  const shownLook = useMemo2(() => splitThemeReference(canvas?.themeReference), [canvas?.themeReference]);
2318
2333
  const sections = useMemo2(() => canvas?.sections?.elements ?? [], [canvas]);
2319
2334
  const statuses = useMemo2(() => canvas?.statuses ?? overview?.statuses ?? [], [canvas?.statuses, overview?.statuses]);
@@ -3092,7 +3107,9 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
3092
3107
  onOpen: () => selectedBoardId && openBoardFromCanvas(selectedBoardId),
3093
3108
  onCopyLink: selectedBoard.code ? () => void copyBoardLink(selectedBoard) : void 0,
3094
3109
  onStatusChanged: (status) => selectedBoardId && setBoardStatus(selectedBoardId, status),
3095
- onCopyThreadReference: copyThreadReference
3110
+ onCopyThreadReference: copyThreadReference,
3111
+ themeReference: canvas?.themeReference ?? null,
3112
+ themeHash: canvas?.themeHash ?? null
3096
3113
  },
3097
3114
  selectedBoard.boardKey ?? ""
3098
3115
  ) : /* @__PURE__ */ jsxs8("div", { className: "space-y-4", children: [
@@ -3147,6 +3164,7 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
3147
3164
  onCopyReference: ({ region, note }) => focusedBoardId && void copyReferences([buildReferenceFor(focusedBoardId, { region, note, viewport: focusViewport })]),
3148
3165
  onCopyThreadReference: copyThreadReference,
3149
3166
  themeReference: canvas?.themeReference ?? null,
3167
+ themeHash: canvas?.themeHash ?? null,
3150
3168
  themeLabel: shownThemeLabel,
3151
3169
  isRendererEnabled
3152
3170
  }