@mgamadeus/ddd-design-studio 0.10.0 → 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` |
@@ -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-46OBH55W.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";
@@ -2274,12 +2275,14 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2274
2275
  const overview = overviewData?.designStudioOverview;
2275
2276
  const projectSummary = overview?.projects?.elements?.find((project) => project.projectKey === projectKey);
2276
2277
  const canvasSummary = projectSummary?.canvases?.elements?.find((item) => item.canvasKey === canvasKey);
2277
- 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]);
2278
2281
  const {
2279
2282
  data: themesData,
2280
2283
  isLoading: isLoadingThemes,
2281
2284
  isError: isThemesError
2282
- } = api.useThemesQuery({}, { skip: !hasThemes });
2285
+ } = api.useThemesQuery(themesQueryArgument, { skip: !hasThemes });
2283
2286
  const themes = useMemo2(() => themesData?.designThemes.elements ?? [], [themesData]);
2284
2287
  const isDefaultLook = chosenThemeId === null && chosenMode === null;
2285
2288
  const isLookResolved = isDefaultLook || (overviewData !== void 0 || isOverviewError) && (!hasThemes || themesData !== void 0 || isThemesError);
@@ -2323,6 +2326,9 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2323
2326
  if (canvas && (canvas.referenceTheme ?? null) !== loadedReferenceTheme) {
2324
2327
  setLoadedReferenceTheme(canvas.referenceTheme ?? null);
2325
2328
  }
2329
+ if (canvas && Boolean(canvas.hasThemes) !== loadedCanvasHasThemes) {
2330
+ setLoadedCanvasHasThemes(Boolean(canvas.hasThemes));
2331
+ }
2326
2332
  const shownLook = useMemo2(() => splitThemeReference(canvas?.themeReference), [canvas?.themeReference]);
2327
2333
  const sections = useMemo2(() => canvas?.sections?.elements ?? [], [canvas]);
2328
2334
  const statuses = useMemo2(() => canvas?.statuses ?? overview?.statuses ?? [], [canvas?.statuses, overview?.statuses]);