@pantheon-systems/puck-css 0.4.1 → 0.4.3
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/core/config.d.ts +3 -0
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +5 -6
- package/dist/core/config.js.map +1 -1
- package/dist/core/featureConfig.d.ts +2 -0
- package/dist/core/featureConfig.d.ts.map +1 -1
- package/dist/core/featureConfig.js +4 -0
- package/dist/core/featureConfig.js.map +1 -1
- package/dist/core/types.d.ts +58 -1
- package/dist/core/types.d.ts.map +1 -1
- package/dist/data/dal/index.d.ts +5 -1
- package/dist/data/dal/index.d.ts.map +1 -1
- package/dist/data/dal/index.js +22 -1
- package/dist/data/dal/index.js.map +1 -1
- package/dist/data/dal/init.d.ts.map +1 -1
- package/dist/data/dal/init.js +22 -14
- package/dist/data/dal/init.js.map +1 -1
- package/dist/data/dal/p1-store.d.ts +15 -1
- package/dist/data/dal/p1-store.d.ts.map +1 -1
- package/dist/data/dal/p1-store.js +51 -5
- package/dist/data/dal/p1-store.js.map +1 -1
- package/dist/data/dal/types.d.ts +13 -1
- package/dist/data/dal/types.d.ts.map +1 -1
- package/dist/data/page-store.d.ts +17 -2
- package/dist/data/page-store.d.ts.map +1 -1
- package/dist/data/page-store.js +47 -5
- package/dist/data/page-store.js.map +1 -1
- package/dist/editor/P1App.d.ts.map +1 -1
- package/dist/editor/P1App.js +1 -1
- package/dist/editor/P1App.js.map +1 -1
- package/dist/editor/P1PuckProvider.d.ts.map +1 -1
- package/dist/editor/P1PuckProvider.js +175 -66
- package/dist/editor/P1PuckProvider.js.map +1 -1
- package/dist/editor/plugin/P1Plugin.d.ts +22 -1
- package/dist/editor/plugin/P1Plugin.d.ts.map +1 -1
- package/dist/editor/plugin/P1Plugin.js +72 -21
- package/dist/editor/plugin/P1Plugin.js.map +1 -1
- package/dist/editor/plugin/createP1Overrides.d.ts.map +1 -1
- package/dist/editor/plugin/createP1Overrides.js +4 -1
- package/dist/editor/plugin/createP1Overrides.js.map +1 -1
- package/dist/editor/useDocuments.d.ts +4 -1
- package/dist/editor/useDocuments.d.ts.map +1 -1
- package/dist/editor/useDocuments.js +5 -2
- package/dist/editor/useDocuments.js.map +1 -1
- package/dist/editor/useP1Editor.d.ts +12 -0
- package/dist/editor/useP1Editor.d.ts.map +1 -1
- package/dist/editor/useP1Editor.js +40 -5
- package/dist/editor/useP1Editor.js.map +1 -1
- package/dist/editor/useP1Plugin.d.ts +5 -1
- package/dist/editor/useP1Plugin.d.ts.map +1 -1
- package/dist/editor/useP1Plugin.js +4 -0
- package/dist/editor/useP1Plugin.js.map +1 -1
- package/dist/editor/useRealtime.d.ts +9 -4
- package/dist/editor/useRealtime.d.ts.map +1 -1
- package/dist/editor/useRealtime.js +11 -6
- package/dist/editor/useRealtime.js.map +1 -1
- package/dist/features/content-type-templates/editor/useTemplateEditor.d.ts +20 -0
- package/dist/features/content-type-templates/editor/useTemplateEditor.d.ts.map +1 -0
- package/dist/features/content-type-templates/editor/useTemplateEditor.js +62 -0
- package/dist/features/content-type-templates/editor/useTemplateEditor.js.map +1 -0
- package/dist/features/content-type-templates/editor/useTemplatePermissions.d.ts +7 -0
- package/dist/features/content-type-templates/editor/useTemplatePermissions.d.ts.map +1 -0
- package/dist/features/content-type-templates/editor/useTemplatePermissions.js +12 -0
- package/dist/features/content-type-templates/editor/useTemplatePermissions.js.map +1 -0
- package/dist/features/content-type-templates/editor/useTemplateScaffold.d.ts +19 -0
- package/dist/features/content-type-templates/editor/useTemplateScaffold.d.ts.map +1 -0
- package/dist/features/content-type-templates/editor/useTemplateScaffold.js +37 -0
- package/dist/features/content-type-templates/editor/useTemplateScaffold.js.map +1 -0
- package/dist/features/content-type-templates/hooks/useTemplateList.d.ts +41 -0
- package/dist/features/content-type-templates/hooks/useTemplateList.d.ts.map +1 -0
- package/dist/features/content-type-templates/hooks/useTemplateList.js +72 -0
- package/dist/features/content-type-templates/hooks/useTemplateList.js.map +1 -0
- package/dist/features/content-type-templates/index.d.ts +18 -0
- package/dist/features/content-type-templates/index.d.ts.map +1 -0
- package/dist/features/content-type-templates/index.js +13 -0
- package/dist/features/content-type-templates/index.js.map +1 -0
- package/dist/features/content-type-templates/permissions/createPuckPermissions.d.ts +68 -0
- package/dist/features/content-type-templates/permissions/createPuckPermissions.d.ts.map +1 -0
- package/dist/features/content-type-templates/permissions/createPuckPermissions.js +90 -0
- package/dist/features/content-type-templates/permissions/createPuckPermissions.js.map +1 -0
- package/dist/features/content-type-templates/permissions/role-permissions.d.ts +49 -0
- package/dist/features/content-type-templates/permissions/role-permissions.d.ts.map +1 -0
- package/dist/features/content-type-templates/permissions/role-permissions.js +79 -0
- package/dist/features/content-type-templates/permissions/role-permissions.js.map +1 -0
- package/dist/features/content-type-templates/permissions/useContentRole.d.ts +37 -0
- package/dist/features/content-type-templates/permissions/useContentRole.d.ts.map +1 -0
- package/dist/features/content-type-templates/permissions/useContentRole.js +34 -0
- package/dist/features/content-type-templates/permissions/useContentRole.js.map +1 -0
- package/dist/features/content-type-templates/permissions/useResolveContentRole.d.ts +38 -0
- package/dist/features/content-type-templates/permissions/useResolveContentRole.d.ts.map +1 -0
- package/dist/features/content-type-templates/permissions/useResolveContentRole.js +83 -0
- package/dist/features/content-type-templates/permissions/useResolveContentRole.js.map +1 -0
- package/dist/features/content-type-templates/stores/index.d.ts +9 -0
- package/dist/features/content-type-templates/stores/index.d.ts.map +1 -0
- package/dist/features/content-type-templates/stores/index.js +8 -0
- package/dist/features/content-type-templates/stores/index.js.map +1 -0
- package/dist/features/content-type-templates/stores/template-store-api.d.ts +17 -0
- package/dist/features/content-type-templates/stores/template-store-api.d.ts.map +1 -0
- package/dist/features/content-type-templates/stores/template-store-api.js +56 -0
- package/dist/features/content-type-templates/stores/template-store-api.js.map +1 -0
- package/dist/features/content-type-templates/stores/template-store.d.ts +54 -0
- package/dist/features/content-type-templates/stores/template-store.d.ts.map +1 -0
- package/dist/features/content-type-templates/stores/template-store.js +80 -0
- package/dist/features/content-type-templates/stores/template-store.js.map +1 -0
- package/dist/features/content-type-templates/types.d.ts +114 -0
- package/dist/features/content-type-templates/types.d.ts.map +1 -0
- package/dist/features/content-type-templates/types.js +7 -0
- package/dist/features/content-type-templates/types.js.map +1 -0
- package/dist/features/content-type-templates/ui/ActionBarPinButton.d.ts +3 -0
- package/dist/features/content-type-templates/ui/ActionBarPinButton.d.ts.map +1 -0
- package/dist/features/content-type-templates/ui/ActionBarPinButton.js +77 -0
- package/dist/features/content-type-templates/ui/ActionBarPinButton.js.map +1 -0
- package/dist/features/content-type-templates/ui/TemplateManagerOverlay.d.ts +18 -0
- package/dist/features/content-type-templates/ui/TemplateManagerOverlay.d.ts.map +1 -0
- package/dist/features/content-type-templates/ui/TemplateManagerOverlay.js +167 -0
- package/dist/features/content-type-templates/ui/TemplateManagerOverlay.js.map +1 -0
- package/dist/features/content-type-templates/ui/TemplatePinPanel.d.ts +18 -0
- package/dist/features/content-type-templates/ui/TemplatePinPanel.d.ts.map +1 -0
- package/dist/features/content-type-templates/ui/TemplatePinPanel.js +11 -0
- package/dist/features/content-type-templates/ui/TemplatePinPanel.js.map +1 -0
- package/dist/features/content-type-templates/ui/TemplateSelector.d.ts +41 -0
- package/dist/features/content-type-templates/ui/TemplateSelector.d.ts.map +1 -0
- package/dist/features/content-type-templates/ui/TemplateSelector.js +32 -0
- package/dist/features/content-type-templates/ui/TemplateSelector.js.map +1 -0
- package/dist/features/content-type-templates/ui/dataToTemplate.d.ts +25 -0
- package/dist/features/content-type-templates/ui/dataToTemplate.d.ts.map +1 -0
- package/dist/features/content-type-templates/ui/dataToTemplate.js +37 -0
- package/dist/features/content-type-templates/ui/dataToTemplate.js.map +1 -0
- package/dist/features/content-type-templates/validation/structural-validation.d.ts +29 -0
- package/dist/features/content-type-templates/validation/structural-validation.d.ts.map +1 -0
- package/dist/features/content-type-templates/validation/structural-validation.js +69 -0
- package/dist/features/content-type-templates/validation/structural-validation.js.map +1 -0
- package/dist/index.d.ts +8 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/p1/editor/connect/connect-field-modal.d.ts.map +1 -1
- package/dist/p1/editor/connect/connect-field-modal.js +23 -1
- package/dist/p1/editor/connect/connect-field-modal.js.map +1 -1
- package/dist/p1/editor/connect/field-connect-plugin.d.ts.map +1 -1
- package/dist/p1/editor/connect/field-connect-plugin.js +2 -6
- package/dist/p1/editor/connect/field-connect-plugin.js.map +1 -1
- package/dist/p1/pages/conflict-resolution-panel.d.ts +17 -0
- package/dist/p1/pages/conflict-resolution-panel.d.ts.map +1 -0
- package/dist/p1/pages/conflict-resolution-panel.js +74 -0
- package/dist/p1/pages/conflict-resolution-panel.js.map +1 -0
- package/dist/p1/pages/content-type-template-list.d.ts +7 -0
- package/dist/p1/pages/content-type-template-list.d.ts.map +1 -0
- package/dist/p1/pages/content-type-template-list.js +108 -0
- package/dist/p1/pages/content-type-template-list.js.map +1 -0
- package/dist/p1/pages/create-content-type-form.d.ts +7 -0
- package/dist/p1/pages/create-content-type-form.d.ts.map +1 -0
- package/dist/p1/pages/create-content-type-form.js +102 -0
- package/dist/p1/pages/create-content-type-form.js.map +1 -0
- package/dist/p1/pages/create-page-form.d.ts +8 -1
- package/dist/p1/pages/create-page-form.d.ts.map +1 -1
- package/dist/p1/pages/create-page-form.js +67 -8
- package/dist/p1/pages/create-page-form.js.map +1 -1
- package/dist/p1/pages/create-template-form.d.ts +6 -1
- package/dist/p1/pages/create-template-form.d.ts.map +1 -1
- package/dist/p1/pages/create-template-form.js +61 -15
- package/dist/p1/pages/create-template-form.js.map +1 -1
- package/dist/p1/pages/hooks.d.ts +6 -1
- package/dist/p1/pages/hooks.d.ts.map +1 -1
- package/dist/p1/pages/hooks.js +13 -2
- package/dist/p1/pages/hooks.js.map +1 -1
- package/dist/p1/pages/index.d.ts +5 -0
- package/dist/p1/pages/index.d.ts.map +1 -1
- package/dist/p1/pages/index.js +5 -0
- package/dist/p1/pages/index.js.map +1 -1
- package/dist/p1/pages/migration-conflict-queue.d.ts +8 -0
- package/dist/p1/pages/migration-conflict-queue.d.ts.map +1 -0
- package/dist/p1/pages/migration-conflict-queue.js +62 -0
- package/dist/p1/pages/migration-conflict-queue.js.map +1 -0
- package/dist/p1/pages/migration-preview-panel.d.ts +12 -0
- package/dist/p1/pages/migration-preview-panel.d.ts.map +1 -0
- package/dist/p1/pages/migration-preview-panel.js +157 -0
- package/dist/p1/pages/migration-preview-panel.js.map +1 -0
- package/dist/p1/pages/migration-status-panel.d.ts +7 -0
- package/dist/p1/pages/migration-status-panel.d.ts.map +1 -0
- package/dist/p1/pages/migration-status-panel.js +198 -0
- package/dist/p1/pages/migration-status-panel.js.map +1 -0
- package/dist/p1/pages/structure-page.d.ts.map +1 -1
- package/dist/p1/pages/structure-page.js +75 -18
- package/dist/p1/pages/structure-page.js.map +1 -1
- package/dist/p1/pages/structure-tabs.d.ts +11 -0
- package/dist/p1/pages/structure-tabs.d.ts.map +1 -0
- package/dist/p1/pages/structure-tabs.js +45 -0
- package/dist/p1/pages/structure-tabs.js.map +1 -0
- package/dist/pds/components/P1EditorHeader.d.ts +8 -9
- package/dist/pds/components/P1EditorHeader.d.ts.map +1 -1
- package/dist/pds/components/P1EditorHeader.js +20 -52
- package/dist/pds/components/P1EditorHeader.js.map +1 -1
- package/dist/pds/components/P1EditorHeader.module.css +43 -17
- package/dist/pds/components/P1EditorSubheader.d.ts +10 -1
- package/dist/pds/components/P1EditorSubheader.d.ts.map +1 -1
- package/dist/pds/components/P1EditorSubheader.js +4 -3
- package/dist/pds/components/P1EditorSubheader.js.map +1 -1
- package/dist/pds/components/P1EditorSubheader.module.css +31 -2
- package/dist/pds/components/PageNavigator.d.ts +7 -2
- package/dist/pds/components/PageNavigator.d.ts.map +1 -1
- package/dist/pds/components/PageNavigator.js +28 -7
- package/dist/pds/components/PageNavigator.js.map +1 -1
- package/dist/pds/components/PageNavigator.module.css +70 -0
- package/dist/pds/components/PublishControl.d.ts +4 -1
- package/dist/pds/components/PublishControl.d.ts.map +1 -1
- package/dist/pds/components/PublishControl.js +27 -10
- package/dist/pds/components/PublishControl.js.map +1 -1
- package/dist/pds/components/WorkstreamSwitcher.d.ts.map +1 -1
- package/dist/pds/components/WorkstreamSwitcher.js +8 -3
- package/dist/pds/components/WorkstreamSwitcher.js.map +1 -1
- package/dist/pds/components/WorkstreamSwitcher.module.css +12 -2
- package/package.json +16 -16
- package/src/styles.css +364 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useResolveContentRole Hook
|
|
3
|
+
*
|
|
4
|
+
* Auto-detects the user's ContentRole by querying the CSS backend's
|
|
5
|
+
* auth/me endpoint with site context. Falls back to the provided
|
|
6
|
+
* default role if the backend doesn't return role info.
|
|
7
|
+
*
|
|
8
|
+
* CSS backend role mapping:
|
|
9
|
+
* - ADMIN → 'admin'
|
|
10
|
+
* - EDITOR → 'editor'
|
|
11
|
+
* - VIEWER → 'junior-editor' (read-only structural access)
|
|
12
|
+
* - NO_ACCESS → 'junior-editor' (most restrictive)
|
|
13
|
+
*/
|
|
14
|
+
import { useState, useEffect } from 'react';
|
|
15
|
+
function mapCssRoleToContentRole(cssRole) {
|
|
16
|
+
switch (cssRole) {
|
|
17
|
+
case 'ADMIN':
|
|
18
|
+
return 'admin';
|
|
19
|
+
case 'EDITOR':
|
|
20
|
+
return 'editor';
|
|
21
|
+
case 'VIEWER':
|
|
22
|
+
case 'NO_ACCESS':
|
|
23
|
+
default:
|
|
24
|
+
return 'junior-editor';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Hook to auto-resolve the user's ContentRole from the CSS backend.
|
|
29
|
+
*
|
|
30
|
+
* Calls GET /api/sites/{siteId}/auth/role (when available) to determine
|
|
31
|
+
* the user's effective role. Falls back to the provided fallbackRole
|
|
32
|
+
* if the endpoint is unavailable or returns an error.
|
|
33
|
+
*/
|
|
34
|
+
export function useResolveContentRole({ baseUrl, siteId, branchId, token, fallbackRole = 'junior-editor', }) {
|
|
35
|
+
const [role, setRole] = useState(fallbackRole);
|
|
36
|
+
const [loading, setLoading] = useState(true);
|
|
37
|
+
const [resolved, setResolved] = useState(false);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (!baseUrl || !siteId || !token) {
|
|
40
|
+
setRole(fallbackRole);
|
|
41
|
+
setLoading(false);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
let cancelled = false;
|
|
45
|
+
(async () => {
|
|
46
|
+
try {
|
|
47
|
+
const headers = {
|
|
48
|
+
Authorization: `Bearer ${token}`,
|
|
49
|
+
};
|
|
50
|
+
const res = await fetch(`${baseUrl}/api/sites/${encodeURIComponent(siteId)}/branches/${encodeURIComponent(branchId)}/auth/role`, { method: 'GET', headers });
|
|
51
|
+
if (cancelled)
|
|
52
|
+
return;
|
|
53
|
+
if (res.ok) {
|
|
54
|
+
const data = (await res.json());
|
|
55
|
+
if (data.roleName) {
|
|
56
|
+
setRole(mapCssRoleToContentRole(data.roleName));
|
|
57
|
+
setResolved(true);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
setRole(fallbackRole);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
setRole(fallbackRole);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
if (!cancelled)
|
|
69
|
+
setRole(fallbackRole);
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
if (!cancelled)
|
|
73
|
+
setLoading(false);
|
|
74
|
+
}
|
|
75
|
+
})();
|
|
76
|
+
return () => {
|
|
77
|
+
cancelled = true;
|
|
78
|
+
};
|
|
79
|
+
}, [baseUrl, siteId, branchId, token, fallbackRole]);
|
|
80
|
+
return { role, loading, resolved };
|
|
81
|
+
}
|
|
82
|
+
export { mapCssRoleToContentRole };
|
|
83
|
+
//# sourceMappingURL=useResolveContentRole.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useResolveContentRole.js","sourceRoot":"","sources":["../../../../src/features/content-type-templates/permissions/useResolveContentRole.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAK5C,SAAS,uBAAuB,CAAC,OAAoB;IACnD,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,OAAO;YACV,OAAO,OAAO,CAAC;QACjB,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAClB,KAAK,QAAQ,CAAC;QACd,KAAK,WAAW,CAAC;QACjB;YACE,OAAO,eAAe,CAAC;IAC3B,CAAC;AACH,CAAC;AAgBD;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,EACpC,OAAO,EACP,MAAM,EACN,QAAQ,EACR,KAAK,EACL,YAAY,GAAG,eAAe,GACD;IAC7B,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAc,YAAY,CAAC,CAAC;IAC5D,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEhD,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,OAAO,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;YAClC,OAAO,CAAC,YAAY,CAAC,CAAC;YACtB,UAAU,CAAC,KAAK,CAAC,CAAC;YAClB,OAAO;QACT,CAAC;QAED,IAAI,SAAS,GAAG,KAAK,CAAC;QAEtB,CAAC,KAAK,IAAI,EAAE;YACV,IAAI,CAAC;gBACH,MAAM,OAAO,GAA2B;oBACtC,aAAa,EAAE,UAAU,KAAK,EAAE;iBACjC,CAAC;gBACF,MAAM,GAAG,GAAG,MAAM,KAAK,CAC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
+
export type { TemplateStore } from './template-store.js';
|
|
7
|
+
export { createInMemoryTemplateStore } from './template-store.js';
|
|
8
|
+
export { createApiTemplateStore } from './template-store-api.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/content-type-templates/stores/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/features/content-type-templates/stores/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API-Backed Template Store
|
|
3
|
+
*
|
|
4
|
+
* Production template store implementation using the backend API.
|
|
5
|
+
*/
|
|
6
|
+
import type { P1Client } from '@pantheon-systems/css-client';
|
|
7
|
+
import type { TemplateStore } from './template-store.js';
|
|
8
|
+
/**
|
|
9
|
+
* Create a template store backed by the P1 API.
|
|
10
|
+
*
|
|
11
|
+
* @param client - P1Client instance
|
|
12
|
+
* @param siteId - Site ID
|
|
13
|
+
* @param branchId - Branch ID
|
|
14
|
+
* @returns TemplateStore instance
|
|
15
|
+
*/
|
|
16
|
+
export declare function createApiTemplateStore(client: P1Client, siteId: string, branchId: string): TemplateStore;
|
|
17
|
+
//# sourceMappingURL=template-store-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-store-api.d.ts","sourceRoot":"","sources":["../../../../src/features/content-type-templates/stores/template-store-api.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGzD;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,QAAQ,EAChB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,aAAa,CAoDf"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API-Backed Template Store
|
|
3
|
+
*
|
|
4
|
+
* Production template store implementation using the backend API.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Create a template store backed by the P1 API.
|
|
8
|
+
*
|
|
9
|
+
* @param client - P1Client instance
|
|
10
|
+
* @param siteId - Site ID
|
|
11
|
+
* @param branchId - Branch ID
|
|
12
|
+
* @returns TemplateStore instance
|
|
13
|
+
*/
|
|
14
|
+
export function createApiTemplateStore(client, siteId, branchId) {
|
|
15
|
+
return {
|
|
16
|
+
async create(params) {
|
|
17
|
+
const template = await client.templates.create(siteId, branchId, params);
|
|
18
|
+
return template;
|
|
19
|
+
},
|
|
20
|
+
async get(id) {
|
|
21
|
+
try {
|
|
22
|
+
const template = await client.templates.get(siteId, branchId, id);
|
|
23
|
+
return template;
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
// Return undefined for 404s
|
|
27
|
+
if (error && typeof error === 'object' && 'status' in error && error.status === 404) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
async list() {
|
|
34
|
+
return await client.templates.list(siteId, branchId);
|
|
35
|
+
},
|
|
36
|
+
async update(id, params) {
|
|
37
|
+
return await client.templates.update(siteId, branchId, id, params);
|
|
38
|
+
},
|
|
39
|
+
async delete(id) {
|
|
40
|
+
await client.templates.delete(siteId, branchId, id);
|
|
41
|
+
},
|
|
42
|
+
async getBinding(_documentId) {
|
|
43
|
+
return undefined;
|
|
44
|
+
},
|
|
45
|
+
async setBinding(_documentId, _templateId, _templateVersion) {
|
|
46
|
+
throw new Error('Template bindings are managed server-side via document metadata. Use the documents API to set template_id.');
|
|
47
|
+
},
|
|
48
|
+
async listBindings(_templateId) {
|
|
49
|
+
return [];
|
|
50
|
+
},
|
|
51
|
+
async removeBinding(_documentId) {
|
|
52
|
+
throw new Error('Template bindings are managed server-side via document metadata. Use the documents API to update template_id.');
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=template-store-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-store-api.js","sourceRoot":"","sources":["../../../../src/features/content-type-templates/stores/template-store-api.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CACpC,MAAgB,EAChB,MAAc,EACd,QAAgB;IAEhB,OAAO;QACL,KAAK,CAAC,MAAM,CAAC,MAA4B;YACvC,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;YACzE,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,KAAK,CAAC,GAAG,CAAC,EAAU;YAClB,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;gBAClE,OAAO,QAAQ,CAAC;YAClB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,4BAA4B;gBAC5B,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,QAAQ,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;oBACpF,OAAO,SAAS,CAAC;gBACnB,CAAC;gBACD,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;QAED,KAAK,CAAC,IAAI;YACR,OAAO,MAAM,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QACvD,CAAC;QAED,KAAK,CAAC,MAAM,CAAC,EAAU,EAAE,MAA4B;YACnD,OAAO,MAAM,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;QACrE,CAAC;QAED,KAAK,CAAC,MAAM,CAAC,EAAU;YACrB,MAAM,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;QACtD,CAAC;QAED,KAAK,CAAC,UAAU,CAAC,WAAmB;YAClC,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,KAAK,CAAC,UAAU,CACd,WAAmB,EACnB,WAAmB,EACnB,gBAAwB;YAExB,MAAM,IAAI,KAAK,CAAC,4GAA4G,CAAC,CAAC;QAChI,CAAC;QAED,KAAK,CAAC,YAAY,CAAC,WAAmB;YACpC,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,KAAK,CAAC,aAAa,CAAC,WAAmB;YACrC,MAAM,IAAI,KAAK,CAAC,+GAA+G,CAAC,CAAC;QACnI,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Template Store Interface
|
|
3
|
+
*
|
|
4
|
+
* Defines the contract for template storage and retrieval.
|
|
5
|
+
* Implementations can use localStorage, CSS documents, or backend API.
|
|
6
|
+
*/
|
|
7
|
+
import type { Template, TemplateBinding, CreateTemplateParams, UpdateTemplateParams } from '../types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Template store interface for CRUD operations and bindings.
|
|
10
|
+
*/
|
|
11
|
+
export interface TemplateStore {
|
|
12
|
+
/**
|
|
13
|
+
* Create a new template.
|
|
14
|
+
*/
|
|
15
|
+
create(params: CreateTemplateParams): Promise<Template>;
|
|
16
|
+
/**
|
|
17
|
+
* Get a template by ID.
|
|
18
|
+
*/
|
|
19
|
+
get(id: string): Promise<Template | undefined>;
|
|
20
|
+
/**
|
|
21
|
+
* List all templates.
|
|
22
|
+
*/
|
|
23
|
+
list(): Promise<Template[]>;
|
|
24
|
+
/**
|
|
25
|
+
* Update an existing template.
|
|
26
|
+
* Increments the version number.
|
|
27
|
+
*/
|
|
28
|
+
update(id: string, params: UpdateTemplateParams): Promise<Template>;
|
|
29
|
+
/**
|
|
30
|
+
* Delete a template.
|
|
31
|
+
*/
|
|
32
|
+
delete(id: string): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Get the template binding for a document.
|
|
35
|
+
*/
|
|
36
|
+
getBinding(documentId: string): Promise<TemplateBinding | undefined>;
|
|
37
|
+
/**
|
|
38
|
+
* Set a template binding for a document.
|
|
39
|
+
*/
|
|
40
|
+
setBinding(documentId: string, templateId: string, templateVersion: number): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* List all document bindings for a template.
|
|
43
|
+
*/
|
|
44
|
+
listBindings(templateId: string): Promise<TemplateBinding[]>;
|
|
45
|
+
/**
|
|
46
|
+
* Remove a template binding for a document.
|
|
47
|
+
*/
|
|
48
|
+
removeBinding(documentId: string): Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Create an in-memory template store for testing and development.
|
|
52
|
+
*/
|
|
53
|
+
export declare function createInMemoryTemplateStore(): TemplateStore;
|
|
54
|
+
//# sourceMappingURL=template-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-store.d.ts","sourceRoot":"","sources":["../../../../src/features/content-type-templates/stores/template-store.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,QAAQ,EACR,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,aAAa,CAAC;AAErB;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,MAAM,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAExD;;OAEG;IACH,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC;IAE/C;;OAEG;IACH,IAAI,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IAE5B;;;OAGG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEpE;;OAEG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAElC;;OAEG;IACH,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CAAC;IAErE;;OAEG;IACH,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3F;;OAEG;IACH,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IAE7D;;OAEG;IACH,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAClD;AASD;;GAEG;AACH,wBAAgB,2BAA2B,IAAI,aAAa,CA+E3D"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Template Store Interface
|
|
3
|
+
*
|
|
4
|
+
* Defines the contract for template storage and retrieval.
|
|
5
|
+
* Implementations can use localStorage, CSS documents, or backend API.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Generate a unique template ID.
|
|
9
|
+
*/
|
|
10
|
+
function generateId() {
|
|
11
|
+
return `tmpl_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Create an in-memory template store for testing and development.
|
|
15
|
+
*/
|
|
16
|
+
export function createInMemoryTemplateStore() {
|
|
17
|
+
const templates = new Map();
|
|
18
|
+
const bindings = new Map();
|
|
19
|
+
return {
|
|
20
|
+
async create(params) {
|
|
21
|
+
const now = new Date().toISOString();
|
|
22
|
+
const template = {
|
|
23
|
+
id: generateId(),
|
|
24
|
+
name: params.name,
|
|
25
|
+
label: params.label,
|
|
26
|
+
description: params.description,
|
|
27
|
+
defaultUrlPattern: params.defaultUrlPattern,
|
|
28
|
+
version: 1,
|
|
29
|
+
components: params.components,
|
|
30
|
+
createdAt: now,
|
|
31
|
+
updatedAt: now,
|
|
32
|
+
};
|
|
33
|
+
templates.set(template.id, template);
|
|
34
|
+
return template;
|
|
35
|
+
},
|
|
36
|
+
async get(id) {
|
|
37
|
+
return templates.get(id);
|
|
38
|
+
},
|
|
39
|
+
async list() {
|
|
40
|
+
return Array.from(templates.values());
|
|
41
|
+
},
|
|
42
|
+
async update(id, params) {
|
|
43
|
+
const existing = templates.get(id);
|
|
44
|
+
if (!existing) {
|
|
45
|
+
throw new Error('Template not found');
|
|
46
|
+
}
|
|
47
|
+
const updated = {
|
|
48
|
+
...existing,
|
|
49
|
+
label: params.label ?? existing.label,
|
|
50
|
+
description: params.description ?? existing.description,
|
|
51
|
+
defaultUrlPattern: params.defaultUrlPattern ?? existing.defaultUrlPattern,
|
|
52
|
+
components: params.components ?? existing.components,
|
|
53
|
+
version: existing.version + 1,
|
|
54
|
+
updatedAt: new Date().toISOString(),
|
|
55
|
+
};
|
|
56
|
+
templates.set(id, updated);
|
|
57
|
+
return updated;
|
|
58
|
+
},
|
|
59
|
+
async delete(id) {
|
|
60
|
+
templates.delete(id);
|
|
61
|
+
},
|
|
62
|
+
async getBinding(documentId) {
|
|
63
|
+
return bindings.get(documentId);
|
|
64
|
+
},
|
|
65
|
+
async setBinding(documentId, templateId, templateVersion) {
|
|
66
|
+
bindings.set(documentId, {
|
|
67
|
+
documentId,
|
|
68
|
+
templateId,
|
|
69
|
+
templateVersion,
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
async listBindings(templateId) {
|
|
73
|
+
return Array.from(bindings.values()).filter((b) => b.templateId === templateId);
|
|
74
|
+
},
|
|
75
|
+
async removeBinding(documentId) {
|
|
76
|
+
bindings.delete(documentId);
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=template-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-store.js","sourceRoot":"","sources":["../../../../src/features/content-type-templates/stores/template-store.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA4DH;;GAEG;AACH,SAAS,UAAU;IACjB,OAAO,QAAQ,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;AAC5E,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,2BAA2B;IACzC,MAAM,SAAS,GAAG,IAAI,GAAG,EAAoB,CAAC;IAC9C,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA2B,CAAC;IAEpD,OAAO;QACL,KAAK,CAAC,MAAM,CAAC,MAA4B;YACvC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;YACrC,MAAM,QAAQ,GAAa;gBACzB,EAAE,EAAE,UAAU,EAAE;gBAChB,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,WAAW,EAAE,MAAM,CAAC,WAAW;gBAC/B,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;gBAC3C,OAAO,EAAE,CAAC;gBACV,UAAU,EAAE,M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AK,CAAC,UAAU,CAAC,UAAkB;YACjC,OAAO,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAClC,CAAC;QAED,KAAK,CAAC,UAAU,CACd,UAAkB,EAClB,UAAkB,EAClB,eAAuB;YAEvB,QAAQ,CAAC,GAAG,CAAC,UAAU,EAAE;gBACvB,UAAU;gBACV,UAAU;gBACV,eAAe;aAChB,CAAC,CAAC;QACL,CAAC;QAED,KAAK,CAAC,YAAY,CAAC,UAAkB;YACnC,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,UAAU,CAAC,CAAC;QAClF,CAAC;QAED,KAAK,CAAC,aAAa,CAAC,UAAkB;YACpC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAC9B,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content Type Templates - Core Types
|
|
3
|
+
*
|
|
4
|
+
* TypeScript types and interfaces for the content type templates feature.
|
|
5
|
+
*/
|
|
6
|
+
import type { Data } from '@puckeditor/core';
|
|
7
|
+
/**
|
|
8
|
+
* User role for content editing.
|
|
9
|
+
*
|
|
10
|
+
* - admin: Full access - can create/edit templates, full structural control
|
|
11
|
+
* - editor: Pinned components locked (cannot move/delete), can add/remove non-pinned
|
|
12
|
+
* - junior-editor: View/edit props only, no structural changes
|
|
13
|
+
*/
|
|
14
|
+
export type ContentRole = 'admin' | 'editor' | 'junior-editor';
|
|
15
|
+
/**
|
|
16
|
+
* Template metadata stored in root.props._templateMeta.
|
|
17
|
+
*/
|
|
18
|
+
export interface TemplateMetadata {
|
|
19
|
+
/** Unique template name (kebab-case identifier) */
|
|
20
|
+
name: string;
|
|
21
|
+
/** Human-readable label */
|
|
22
|
+
label: string;
|
|
23
|
+
/** Optional description */
|
|
24
|
+
description?: string;
|
|
25
|
+
/** Optional default URL pattern for documents created from this template */
|
|
26
|
+
defaultUrlPattern?: string;
|
|
27
|
+
/** Template version number (incremented on each save) */
|
|
28
|
+
version: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A component in the template skeleton with pinned status.
|
|
32
|
+
*/
|
|
33
|
+
export interface TemplateComponent {
|
|
34
|
+
/** Component type (e.g., "HeadingBlock", "TextBlock") */
|
|
35
|
+
type: string;
|
|
36
|
+
/** Whether this component is pinned (locked position) */
|
|
37
|
+
pinned: boolean;
|
|
38
|
+
/** Default props for this component */
|
|
39
|
+
defaultProps: Record<string, unknown>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A complete template definition.
|
|
43
|
+
*/
|
|
44
|
+
export interface Template {
|
|
45
|
+
/** Unique template ID */
|
|
46
|
+
id: string;
|
|
47
|
+
/** Template name (kebab-case identifier) */
|
|
48
|
+
name: string;
|
|
49
|
+
/** Human-readable label */
|
|
50
|
+
label: string;
|
|
51
|
+
/** Optional description */
|
|
52
|
+
description?: string;
|
|
53
|
+
/** Optional default URL pattern */
|
|
54
|
+
defaultUrlPattern?: string;
|
|
55
|
+
/** Template version number */
|
|
56
|
+
version: number;
|
|
57
|
+
/** Whether this template is deprecated */
|
|
58
|
+
deprecated?: boolean;
|
|
59
|
+
/** Component skeleton */
|
|
60
|
+
components: TemplateComponent[];
|
|
61
|
+
/** Creation timestamp (not returned by all endpoints) */
|
|
62
|
+
createdAt?: string;
|
|
63
|
+
/** Last update timestamp */
|
|
64
|
+
updatedAt: string;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Document-to-template binding.
|
|
68
|
+
* Stored in documents table columns (template_id, template_version).
|
|
69
|
+
*/
|
|
70
|
+
export interface TemplateBinding {
|
|
71
|
+
/** Document ID */
|
|
72
|
+
documentId: string;
|
|
73
|
+
/** Template ID this document is bound to */
|
|
74
|
+
templateId: string;
|
|
75
|
+
/** Template version this document was created from or migrated to */
|
|
76
|
+
templateVersion: number;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Parameters for creating a template.
|
|
80
|
+
*/
|
|
81
|
+
export interface CreateTemplateParams {
|
|
82
|
+
/** Template name (kebab-case identifier) */
|
|
83
|
+
name: string;
|
|
84
|
+
/** Human-readable label */
|
|
85
|
+
label: string;
|
|
86
|
+
/** Optional description */
|
|
87
|
+
description?: string;
|
|
88
|
+
/** Optional default URL pattern */
|
|
89
|
+
defaultUrlPattern?: string;
|
|
90
|
+
/** Initial component skeleton */
|
|
91
|
+
components: TemplateComponent[];
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Parameters for updating a template.
|
|
95
|
+
*/
|
|
96
|
+
export interface UpdateTemplateParams {
|
|
97
|
+
/** Updated label */
|
|
98
|
+
label?: string;
|
|
99
|
+
/** Updated description */
|
|
100
|
+
description?: string;
|
|
101
|
+
/** Updated default URL pattern */
|
|
102
|
+
defaultUrlPattern?: string;
|
|
103
|
+
/** Updated component skeleton */
|
|
104
|
+
components?: TemplateComponent[];
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Template with full Puck data for editing.
|
|
108
|
+
* Used when editing a template document in the editor.
|
|
109
|
+
*/
|
|
110
|
+
export interface TemplateDocument extends Template {
|
|
111
|
+
/** Full Puck data structure */
|
|
112
|
+
data: Data;
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/features/content-type-templates/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE7C;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,QAAQ,GAAG,eAAe,CAAC;AAE/D;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,mDAAmD;IACnD,I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IAEb,2BAA2B;IAC3B,KAAK,EAAE,MAAM,CAAC;IAEd,2BAA2B;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,mCAAmC;IACnC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B,iCAAiC;IACjC,UAAU,EAAE,iBAAiB,EAAE,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,0BAA0B;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,kCAAkC;IAClC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B,iCAAiC;IACjC,UAAU,CAAC,EAAE,iBAAiB,EAAE,CAAC;CAClC;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAiB,SAAQ,QAAQ;IAChD,+BAA+B;IAC/B,IAAI,EAAE,IAAI,CAAC;CACZ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/features/content-type-templates/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionBarPinButton.d.ts","sourceRoot":"","sources":["../../../../src/features/content-type-templates/ui/ActionBarPinButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAgC,MAAM,OAAO,CAAC;AAiCrD,wBAAgB,kBAAkB,IAAI,KAAK,CAAC,YAAY,GAAG,IAAI,CAqF9D"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useState } from 'react';
|
|
3
|
+
import { ActionBar, createUsePuck, usePuck } from '@puckeditor/core';
|
|
4
|
+
import { Icon } from '@pantheon-systems/pds-toolkit-react';
|
|
5
|
+
import { useP1PuckOptional } from '../../../core/P1PuckContext.js';
|
|
6
|
+
const usePuckState = createUsePuck();
|
|
7
|
+
function resolveTemplate(css) {
|
|
8
|
+
if (css.currentTemplate)
|
|
9
|
+
return css.currentTemplate;
|
|
10
|
+
const path = css.currentDocument?.path;
|
|
11
|
+
if (!path)
|
|
12
|
+
return null;
|
|
13
|
+
const match = path.match(/^_registry\/templates\/(.+)$/);
|
|
14
|
+
if (!match)
|
|
15
|
+
return null;
|
|
16
|
+
return css.templates.find((t) => t.name === match[1]) ?? null;
|
|
17
|
+
}
|
|
18
|
+
export function ActionBarPinButton() {
|
|
19
|
+
const css = useP1PuckOptional();
|
|
20
|
+
const selectedItem = usePuckState((s) => s.selectedItem);
|
|
21
|
+
const content = usePuckState((s) => s.appState?.data?.content);
|
|
22
|
+
const rootProps = usePuckState((s) => s.appState?.data?.root?.props);
|
|
23
|
+
const { dispatch, refreshPermissions } = usePuck();
|
|
24
|
+
const [toggling, setToggling] = useState(false);
|
|
25
|
+
const template = css ? resolveTemplate(css) : null;
|
|
26
|
+
const pinMap = rootProps?._pinMap ?? {};
|
|
27
|
+
const handleTogglePin = useCallback(async () => {
|
|
28
|
+
if (!css || !template || !selectedItem || !content || toggling)
|
|
29
|
+
return;
|
|
30
|
+
setToggling(true);
|
|
31
|
+
const compId = selectedItem.props.id;
|
|
32
|
+
const newPinned = !pinMap[compId];
|
|
33
|
+
const updatedPinMap = { ...pinMap, [compId]: newPinned };
|
|
34
|
+
dispatch({
|
|
35
|
+
type: 'setData',
|
|
36
|
+
data: (prev) => ({
|
|
37
|
+
...prev,
|
|
38
|
+
root: {
|
|
39
|
+
...prev.root,
|
|
40
|
+
props: {
|
|
41
|
+
...prev.root.props,
|
|
42
|
+
_pinMap: updatedPinMap,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
}),
|
|
46
|
+
});
|
|
47
|
+
// Puck caches resolvePermissions results per component instance and only
|
|
48
|
+
// re-resolves when the component's own data changes. Since _pinMap lives
|
|
49
|
+
// in root props, toggling it doesn't invalidate per-component caches.
|
|
50
|
+
// Force a full re-resolution so the updated pinMap is respected immediately.
|
|
51
|
+
void refreshPermissions();
|
|
52
|
+
const updatedComponents = content.map((c) => {
|
|
53
|
+
const existing = template.components?.find((tc) => tc.type === c.type);
|
|
54
|
+
return {
|
|
55
|
+
type: c.type,
|
|
56
|
+
pinned: updatedPinMap[c.props.id] ?? false,
|
|
57
|
+
defaultProps: existing?.defaultProps ?? {},
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
try {
|
|
61
|
+
await css.client.templates.update(css.siteId, css.branchId, template.id, {
|
|
62
|
+
components: updatedComponents,
|
|
63
|
+
});
|
|
64
|
+
await css.refreshTemplates();
|
|
65
|
+
}
|
|
66
|
+
finally {
|
|
67
|
+
setToggling(false);
|
|
68
|
+
}
|
|
69
|
+
}, [css, template, selectedItem, content, pinMap, dispatch, refreshPermissions, toggling]);
|
|
70
|
+
if (!css || !template || !selectedItem || !content) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
const isAdmin = css.userRole === 'admin';
|
|
74
|
+
const isPinned = pinMap[selectedItem.props.id] ?? false;
|
|
75
|
+
return (_jsx(ActionBar.Action, { label: isPinned ? 'Unpin component' : 'Pin component', onClick: handleTogglePin, active: isPinned, disabled: toggling || !isAdmin, children: _jsx(Icon, { iconName: isPinned ? 'lock' : 'lockOpen', iconSize: "s", "aria-hidden": "true" }) }));
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=ActionBarPinButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionBarPinButton.js","sourceRoot":"","sources":["../../../../src/features/content-type-templates/ui/ActionBarPinButton.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM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emplateManagerOverlay
|
|
3
|
+
*
|
|
4
|
+
* Full-screen overlay for managing content type templates.
|
|
5
|
+
* Provides a list view of templates and a Puck-based editor for
|
|
6
|
+
* creating and editing templates.
|
|
7
|
+
*/
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import type { P1Client } from '@pantheon-systems/css-client';
|
|
10
|
+
export interface TemplateManagerOverlayProps {
|
|
11
|
+
client: P1Client;
|
|
12
|
+
siteId: string;
|
|
13
|
+
branchId: string;
|
|
14
|
+
puckConfig: unknown;
|
|
15
|
+
onClose: () => void;
|
|
16
|
+
}
|
|
17
|
+
export declare function TemplateManagerOverlay({ client, siteId, branchId, puckConfig, onClose, }: TemplateManagerOverlayProps): React.ReactElement;
|
|
18
|
+
//# sourceMappingURL=TemplateManagerOverlay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateManagerOverlay.d.ts","sourceRoot":"","sources":["../../../../src/features/content-type-templates/ui/TemplateManagerOverlay.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAA2C,MAAM,OAAO,CAAC;AAEhE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAQ7D,MAAM,WAAW,2BAA2B;IAC1C,MAAM,EAAE,QAAQ,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAUD,wBAAgB,sBAAsB,CAAC,EACrC,MAAM,EACN,MAAM,EACN,QAAQ,EACR,UAAU,EACV,OAAO,GACR,EAAE,2BAA2B,GAAG,KAAK,CAAC,YAAY,CAkSlD"}
|