@drawnagency/primitives 0.1.94 → 0.1.95
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/{chunk-UFOWXOG6.js → chunk-ABV7OZB3.js} +6 -0
- package/dist/{chunk-677NTHAZ.js → chunk-PTOLUMGV.js} +3 -0
- package/dist/{chunk-GDLH3LVH.js → chunk-QQBBYQYD.js} +3 -2
- package/dist/{chunk-XYFZ57AS.js → chunk-YUUUCDXN.js} +59 -5
- package/dist/components/brandguide/Colors.d.ts +2 -2
- package/dist/components/brandguide/Colors.d.ts.map +1 -1
- package/dist/components/brandguide/ColorsEditable.d.ts +2 -2
- package/dist/components/brandguide/ColorsEditable.d.ts.map +1 -1
- package/dist/components/editor/SectionWrapper.d.ts.map +1 -1
- package/dist/components/editor/SettingsForm.d.ts.map +1 -1
- package/dist/components/editor/index.js +4 -3
- package/dist/components/sections/Container/Container.d.ts +2 -2
- package/dist/components/sections/Container/Container.d.ts.map +1 -1
- package/dist/components/sections/register-schemas.js +2 -2
- package/dist/components/sections/register.js +2 -2
- package/dist/components/shared/HistoryChangesModal.d.ts +39 -0
- package/dist/components/shared/HistoryChangesModal.d.ts.map +1 -0
- package/dist/components/shared/HistoryPopover.d.ts +3 -1
- package/dist/components/shared/HistoryPopover.d.ts.map +1 -1
- package/dist/components/shared/Navigation.d.ts.map +1 -1
- package/dist/components/shared/Popover.d.ts +10 -1
- package/dist/components/shared/Popover.d.ts.map +1 -1
- package/dist/components/shell/EditorModal.d.ts +6 -1
- package/dist/components/shell/EditorModal.d.ts.map +1 -1
- package/dist/components/shell/EditorModalContext.d.ts +3 -2
- package/dist/components/shell/EditorModalContext.d.ts.map +1 -1
- package/dist/components/shell/EditorShell.d.ts.map +1 -1
- package/dist/hooks/useEditorPublish.d.ts +5 -1
- package/dist/hooks/useEditorPublish.d.ts.map +1 -1
- package/dist/index.js +8 -6
- package/dist/lib/events.d.ts +18 -0
- package/dist/lib/events.d.ts.map +1 -1
- package/dist/lib/history-buckets.d.ts +30 -0
- package/dist/lib/history-buckets.d.ts.map +1 -0
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +4 -2
- package/dist/lib/media-folders.d.ts +13 -0
- package/dist/lib/media-folders.d.ts.map +1 -1
- package/dist/lib/media-folders.js +172 -0
- package/dist/lib/registry.d.ts +7 -1
- package/dist/lib/registry.d.ts.map +1 -1
- package/dist/lib/theme-vars.d.ts +19 -4
- package/dist/lib/theme-vars.d.ts.map +1 -1
- package/package.json +5 -1
- package/src/components/brandguide/Colors.tsx +2 -1
- package/src/components/brandguide/ColorsEditable.tsx +2 -1
- package/src/components/editor/SectionWrapper.tsx +1 -0
- package/src/components/editor/SettingsForm.tsx +5 -2
- package/src/components/sections/Container/Container.tsx +5 -4
- package/src/components/shared/HistoryChangesModal.tsx +256 -0
- package/src/components/shared/HistoryPopover.tsx +255 -76
- package/src/components/shared/Navigation.tsx +30 -9
- package/src/components/shared/Popover.tsx +95 -2
- package/src/components/shell/EditorModal.tsx +26 -4
- package/src/components/shell/EditorModalContext.tsx +5 -4
- package/src/components/shell/EditorShell.tsx +51 -2
- package/src/components/shell/SiteSettingsModal.tsx +1 -1
- package/src/hooks/useEditorPublish.ts +15 -6
- package/src/lib/events.ts +11 -0
- package/src/lib/history-buckets.ts +190 -0
- package/src/lib/index.ts +1 -1
- package/src/lib/media-folders.ts +16 -0
- package/src/lib/registry.ts +9 -1
- package/src/lib/theme-vars.ts +25 -4
package/dist/lib/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
loadSiteContent,
|
|
11
11
|
loadStaticSiteContent,
|
|
12
12
|
mergeSiteContent,
|
|
13
|
+
onPrimaryVarValue,
|
|
13
14
|
primaryVarValue,
|
|
14
15
|
relativeLuminance,
|
|
15
16
|
resolveChatbotName,
|
|
@@ -17,7 +18,7 @@ import {
|
|
|
17
18
|
safeRedirect,
|
|
18
19
|
suggestAccessibleOn,
|
|
19
20
|
wcagLevel
|
|
20
|
-
} from "../chunk-
|
|
21
|
+
} from "../chunk-ABV7OZB3.js";
|
|
21
22
|
import {
|
|
22
23
|
curatedIcons,
|
|
23
24
|
getIcon
|
|
@@ -27,7 +28,7 @@ import {
|
|
|
27
28
|
darkModeEvent,
|
|
28
29
|
editModeEvent,
|
|
29
30
|
navChangeEvent
|
|
30
|
-
} from "../chunk-
|
|
31
|
+
} from "../chunk-PTOLUMGV.js";
|
|
31
32
|
import {
|
|
32
33
|
ensureSanitizer,
|
|
33
34
|
generateNavLinks,
|
|
@@ -91,6 +92,7 @@ export {
|
|
|
91
92
|
loadStaticSiteContent,
|
|
92
93
|
mergeSiteContent,
|
|
93
94
|
navChangeEvent,
|
|
95
|
+
onPrimaryVarValue,
|
|
94
96
|
primaryVarValue,
|
|
95
97
|
registerSchema,
|
|
96
98
|
registerSection,
|
|
@@ -43,6 +43,19 @@ export declare function itemFolderId(folders: Record<string, MediaFolder>, item:
|
|
|
43
43
|
export declare function recursiveItemCounts(folders: Record<string, MediaFolder>, items: MediaItem[]): Record<string, number>;
|
|
44
44
|
/** Pure heal: dangling folderIds dropped, orphan/cyclic folders re-rooted. */
|
|
45
45
|
export declare function healMediaManifest(manifest: MediaManifest): MediaManifest;
|
|
46
|
+
/**
|
|
47
|
+
* Rebase a local manifest onto a freshly-fetched remote one, so media another
|
|
48
|
+
* writer added is in our copy before the next save assembles from it. Without
|
|
49
|
+
* this a rebased session still writes its pre-conflict manifest, which silently
|
|
50
|
+
* drops their entries and orphans the files they committed.
|
|
51
|
+
*
|
|
52
|
+
* Images union, ours winning, so local alt/folder-move edits survive; a pending
|
|
53
|
+
* local deletion isn't removed from the manifest until save, so the union can't
|
|
54
|
+
* resurrect one. Folders stay ours verbatim — deleting a folder removes it from
|
|
55
|
+
* our map with no wire signal, so unioning would undo the delete. Mirrors the
|
|
56
|
+
* server-side merge in core's content-ops.
|
|
57
|
+
*/
|
|
58
|
+
export declare function rebaseMediaManifest(local: MediaManifest, remote: MediaManifest): MediaManifest;
|
|
46
59
|
/**
|
|
47
60
|
* Save-time manifest assembly: merge uploaded pending items, apply deletions,
|
|
48
61
|
* preserve every other manifest key (folders!), then heal.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media-folders.d.ts","sourceRoot":"","sources":["../../src/lib/media-folders.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE5E,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,cAAc,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,gBAAgB;IAC/B,2EAA2E;IAC3E,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACxC,6DAA6D;IAC7D,WAAW,EAAE;QAAE,IAAI,EAAE,IAAI,CAAC;QAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,EAAE,CAAC;CACxD;AAED,gFAAgF;AAChF,wBAAgB,cAAc,IAAI,MAAM,CAIvC;AAED,iEAAiE;AACjE,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAQxF;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAIjG;AAED,wEAAwE;AACxE,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,EAAE,CAItG;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE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CAAC,SAAS,EAAE,UAAU,CAAC,GAChC,MAAM,GAAG,IAAI,CAEf;AAED,kFAAkF;AAClF,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EACpC,KAAK,EAAE,SAAS,EAAE,GACjB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAYxB;AAED,8EAA8E;AAC9E,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,aAAa,GAAG,aAAa,CAexE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa,GAAG,aAAa,CAE9F;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,aAAa,EACvB,aAAa,EAAE,SAAS,EAAE,EAC1B,UAAU,EAAE,MAAM,EAAE,GACnB,aAAa,CAKf;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,EAAE,EAC7C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EACpC,eAAe,EAAE,MAAM,GAAG,IAAI,EAC9B,KAAK,GAAE,MAAM,MAAuB,GACnC,gBAAgB,CA2BlB"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import "../chunk-JSBRDJBE.js";
|
|
2
|
+
|
|
3
|
+
// src/lib/media-folders.ts
|
|
4
|
+
function createFolderId() {
|
|
5
|
+
const bytes = new Uint8Array(6);
|
|
6
|
+
crypto.getRandomValues(bytes);
|
|
7
|
+
return `f_${Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
8
|
+
}
|
|
9
|
+
function isCyclicFolder(folders, id) {
|
|
10
|
+
const max = Object.keys(folders).length;
|
|
11
|
+
let cursor = folders[id]?.parentId ?? null;
|
|
12
|
+
for (let steps = 0; cursor !== null && folders[cursor] && steps <= max; steps++) {
|
|
13
|
+
if (cursor === id) return true;
|
|
14
|
+
cursor = folders[cursor].parentId;
|
|
15
|
+
}
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
function effectiveParentId(folders, id) {
|
|
19
|
+
const parentId = folders[id]?.parentId ?? null;
|
|
20
|
+
if (parentId === null || !folders[parentId]) return null;
|
|
21
|
+
return isCyclicFolder(folders, id) ? null : parentId;
|
|
22
|
+
}
|
|
23
|
+
function childFolderIds(folders, parentId) {
|
|
24
|
+
return Object.keys(folders).filter((id) => effectiveParentId(folders, id) === parentId).sort((a, b) => folders[a].name.localeCompare(folders[b].name, void 0, { sensitivity: "base" }));
|
|
25
|
+
}
|
|
26
|
+
function buildFolderTree(folders) {
|
|
27
|
+
const build = (parentId) => childFolderIds(folders, parentId).map((id) => ({
|
|
28
|
+
id,
|
|
29
|
+
name: folders[id].name,
|
|
30
|
+
children: build(id)
|
|
31
|
+
}));
|
|
32
|
+
return build(null);
|
|
33
|
+
}
|
|
34
|
+
function folderPathNames(folders, id) {
|
|
35
|
+
const names = [];
|
|
36
|
+
let cursor = id;
|
|
37
|
+
while (cursor !== null && folders[cursor]) {
|
|
38
|
+
names.unshift(folders[cursor].name);
|
|
39
|
+
cursor = effectiveParentId(folders, cursor);
|
|
40
|
+
}
|
|
41
|
+
return names;
|
|
42
|
+
}
|
|
43
|
+
function folderPathIds(folders, id) {
|
|
44
|
+
const ids = [];
|
|
45
|
+
let cursor = id;
|
|
46
|
+
while (cursor !== null && folders[cursor]) {
|
|
47
|
+
ids.unshift(cursor);
|
|
48
|
+
cursor = effectiveParentId(folders, cursor);
|
|
49
|
+
}
|
|
50
|
+
return ids;
|
|
51
|
+
}
|
|
52
|
+
function descendantFolderIds(folders, id) {
|
|
53
|
+
const result = /* @__PURE__ */ new Set([id]);
|
|
54
|
+
const ids = Object.keys(folders);
|
|
55
|
+
let grew = true;
|
|
56
|
+
while (grew) {
|
|
57
|
+
grew = false;
|
|
58
|
+
for (const fid of ids) {
|
|
59
|
+
if (result.has(fid)) continue;
|
|
60
|
+
const parent = effectiveParentId(folders, fid);
|
|
61
|
+
if (parent !== null && result.has(parent)) {
|
|
62
|
+
result.add(fid);
|
|
63
|
+
grew = true;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
function canMoveFolder(folders, id, targetParentId) {
|
|
70
|
+
if (!folders[id]) return false;
|
|
71
|
+
if (targetParentId === null) return effectiveParentId(folders, id) !== null;
|
|
72
|
+
if (!folders[targetParentId]) return false;
|
|
73
|
+
if (descendantFolderIds(folders, id).has(targetParentId)) return false;
|
|
74
|
+
return effectiveParentId(folders, id) !== targetParentId;
|
|
75
|
+
}
|
|
76
|
+
function uniqueFolderName(folders, parentId, desired, excludeId) {
|
|
77
|
+
const base = desired.trim();
|
|
78
|
+
const siblings = new Set(
|
|
79
|
+
childFolderIds(folders, parentId).filter((id) => id !== excludeId).map((id) => folders[id].name.toLowerCase())
|
|
80
|
+
);
|
|
81
|
+
if (!siblings.has(base.toLowerCase())) return base;
|
|
82
|
+
for (let n = 2; ; n++) {
|
|
83
|
+
const candidate = `${base} (${n})`;
|
|
84
|
+
if (!siblings.has(candidate.toLowerCase())) return candidate;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function itemFolderId(folders, item) {
|
|
88
|
+
return item.folderId && folders[item.folderId] ? item.folderId : null;
|
|
89
|
+
}
|
|
90
|
+
function recursiveItemCounts(folders, items) {
|
|
91
|
+
const counts = {};
|
|
92
|
+
for (const item of items) {
|
|
93
|
+
let cursor = itemFolderId(folders, item);
|
|
94
|
+
const seen = /* @__PURE__ */ new Set();
|
|
95
|
+
while (cursor !== null && !seen.has(cursor)) {
|
|
96
|
+
seen.add(cursor);
|
|
97
|
+
counts[cursor] = (counts[cursor] ?? 0) + 1;
|
|
98
|
+
cursor = effectiveParentId(folders, cursor);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return counts;
|
|
102
|
+
}
|
|
103
|
+
function healMediaManifest(manifest) {
|
|
104
|
+
const folders = {};
|
|
105
|
+
for (const [id, f] of Object.entries(manifest.folders)) {
|
|
106
|
+
folders[id] = { ...f, parentId: effectiveParentId(manifest.folders, id) };
|
|
107
|
+
}
|
|
108
|
+
const images = {};
|
|
109
|
+
for (const [id, entry] of Object.entries(manifest.images)) {
|
|
110
|
+
if (entry.folderId && !folders[entry.folderId]) {
|
|
111
|
+
const { folderId: _dropped, ...rest } = entry;
|
|
112
|
+
images[id] = rest;
|
|
113
|
+
} else {
|
|
114
|
+
images[id] = entry;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return { ...manifest, images, folders };
|
|
118
|
+
}
|
|
119
|
+
function rebaseMediaManifest(local, remote) {
|
|
120
|
+
return { ...local, images: { ...remote.images, ...local.images } };
|
|
121
|
+
}
|
|
122
|
+
function assembleSavedManifest(manifest, uploadedItems, deletedIds) {
|
|
123
|
+
const images = { ...manifest.images };
|
|
124
|
+
for (const entry of uploadedItems) images[entry.id] = entry;
|
|
125
|
+
for (const id of deletedIds) delete images[id];
|
|
126
|
+
return healMediaManifest({ ...manifest, images });
|
|
127
|
+
}
|
|
128
|
+
function planFolderUpload(files, folders, currentFolderId, newId = createFolderId) {
|
|
129
|
+
const newFolders = {};
|
|
130
|
+
const byName = /* @__PURE__ */ new Map();
|
|
131
|
+
for (const [fid, f] of Object.entries(folders)) {
|
|
132
|
+
byName.set(`${effectiveParentId(folders, fid)}/${f.name.toLowerCase()}`, fid);
|
|
133
|
+
}
|
|
134
|
+
const ensureDir = (segments) => {
|
|
135
|
+
let parent = currentFolderId;
|
|
136
|
+
for (const segment of segments) {
|
|
137
|
+
const key = `${parent}/${segment.toLowerCase()}`;
|
|
138
|
+
let fid = byName.get(key);
|
|
139
|
+
if (!fid) {
|
|
140
|
+
fid = newId();
|
|
141
|
+
newFolders[fid] = { name: segment, parentId: parent };
|
|
142
|
+
byName.set(key, fid);
|
|
143
|
+
}
|
|
144
|
+
parent = fid;
|
|
145
|
+
}
|
|
146
|
+
return parent;
|
|
147
|
+
};
|
|
148
|
+
const fileTargets = files.map(({ file, relativePath }) => {
|
|
149
|
+
const segments = relativePath.split("/").filter(Boolean);
|
|
150
|
+
segments.pop();
|
|
151
|
+
return { file, folderId: ensureDir(segments) };
|
|
152
|
+
});
|
|
153
|
+
return { newFolders, fileTargets };
|
|
154
|
+
}
|
|
155
|
+
export {
|
|
156
|
+
assembleSavedManifest,
|
|
157
|
+
buildFolderTree,
|
|
158
|
+
canMoveFolder,
|
|
159
|
+
childFolderIds,
|
|
160
|
+
createFolderId,
|
|
161
|
+
descendantFolderIds,
|
|
162
|
+
effectiveParentId,
|
|
163
|
+
folderPathIds,
|
|
164
|
+
folderPathNames,
|
|
165
|
+
healMediaManifest,
|
|
166
|
+
isCyclicFolder,
|
|
167
|
+
itemFolderId,
|
|
168
|
+
planFolderUpload,
|
|
169
|
+
rebaseMediaManifest,
|
|
170
|
+
recursiveItemCounts,
|
|
171
|
+
uniqueFolderName
|
|
172
|
+
};
|
package/dist/lib/registry.d.ts
CHANGED
|
@@ -66,12 +66,18 @@ export type Thumbnail = {
|
|
|
66
66
|
value: string;
|
|
67
67
|
};
|
|
68
68
|
export type CustomSettingsFormProps = Record<string, any>;
|
|
69
|
+
export interface ModalOptions {
|
|
70
|
+
/** Content is a tab set — lock the modal height so tab switches don't resize it. */
|
|
71
|
+
tabbed?: boolean;
|
|
72
|
+
}
|
|
73
|
+
/** Signature of the editor's modal opener as threaded down to sections. */
|
|
74
|
+
export type OpenModal = (title: string, content: ReactNode, options?: ModalOptions) => void;
|
|
69
75
|
export interface SectionProps<T = unknown> {
|
|
70
76
|
content: T;
|
|
71
77
|
options?: Record<string, unknown>;
|
|
72
78
|
onChange?: (content: T) => void;
|
|
73
79
|
isEditMode: boolean;
|
|
74
|
-
openModal?:
|
|
80
|
+
openModal?: OpenModal;
|
|
75
81
|
/** Delete this whole section. Used e.g. when a colors section's last swatch
|
|
76
82
|
* is dragged into another section, leaving it empty. */
|
|
77
83
|
onDelete?: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/lib/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACtC,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AAI3E,MAAM,MAAM,gBAAgB,GACxB;IACE,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GACD;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,GACD;IACE,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CAChC,GACD;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,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,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;IACnD,aAAa,IAAI,IAAI,CAAC;CACvB;AAED,wBAAgB,cAAc,IAAI,eAAe,CA0ChD;AAYD,wBAAgB,eAAe,CAAC,GAAG,EAAE,iBAAiB,CAAC,GAAG,CAAC,GAAG,IAAI,CAEjE;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAElE;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAE9E;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAEjE;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAEtE;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAE3D;AAED,wBAAgB,cAAc,IAAI,iBAAiB,EAAE,CAEpD;AAED,wBAAgB,aAAa,IAAI,OAAO,EAAE,CAEzC;AAED,wBAAgB,aAAa,IAAI,IAAI,CAEpC"}
|
package/dist/lib/theme-vars.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { SiteConfig } from "../schemas/site-config";
|
|
2
2
|
/**
|
|
3
3
|
* Computes the CSS value for the brand `--color-primary` / `--color-primary-contrast`
|
|
4
|
-
* custom properties. When darkMode is "optional" AND a dark
|
|
5
|
-
* value is a CSS `light-dark(<light>, <dark>)` expression — the
|
|
6
|
-
* it per the element's `color-scheme` (the `.dark` class sets
|
|
7
|
-
* `:root` sets `color-scheme: light`). Otherwise it's the
|
|
4
|
+
* / `--color-on-primary` custom properties. When darkMode is "optional" AND a dark
|
|
5
|
+
* variant is set, the value is a CSS `light-dark(<light>, <dark>)` expression — the
|
|
6
|
+
* browser resolves it per the element's `color-scheme` (the `.dark` class sets
|
|
7
|
+
* `color-scheme: dark`; `:root` sets `color-scheme: light`). Otherwise it's the
|
|
8
|
+
* plain light hex.
|
|
8
9
|
*
|
|
9
10
|
* Single source of truth for every injection site: Layout.astro / LoginLayout.astro
|
|
10
11
|
* (SSR inline `<html style>`) and EditorShell (live setProperty + localStorage).
|
|
@@ -12,5 +13,19 @@ import type { SiteConfig } from "../schemas/site-config";
|
|
|
12
13
|
type ThemeColorConfig = Pick<SiteConfig, "primaryColor" | "primaryContrast" | "primaryColorDark" | "primaryContrastDark" | "darkMode">;
|
|
13
14
|
export declare function primaryVarValue(c?: Partial<ThemeColorConfig> | null): string;
|
|
14
15
|
export declare function accentVarValue(c?: Partial<ThemeColorConfig> | null): string;
|
|
16
|
+
/**
|
|
17
|
+
* Foreground ink for text drawn ON a `--color-primary`-filled surface (branded
|
|
18
|
+
* plates, primary cards). Derived from `primaryColor` with the same
|
|
19
|
+
* black/white WCAG pick the editor's accent "Suggest" button uses, so a
|
|
20
|
+
* primary-filled surface is legible on every brand without configuration.
|
|
21
|
+
*
|
|
22
|
+
* This exists because `--color-primary-contrast` cannot serve the role: it is
|
|
23
|
+
* the *accent* — brands legitimately repoint it at a decorative colour (Siete's
|
|
24
|
+
* gold on aubergine) that reads as a highlight but cannot carry body copy.
|
|
25
|
+
* Sections should consume `var(--color-on-primary)` for text on primary and
|
|
26
|
+
* keep `--color-primary-contrast` for accents, and derive softer inks by mixing
|
|
27
|
+
* the two brand tokens: `color-mix(in srgb, var(--color-on-primary) 70%, var(--color-primary))`.
|
|
28
|
+
*/
|
|
29
|
+
export declare function onPrimaryVarValue(c?: Partial<ThemeColorConfig> | null): string;
|
|
15
30
|
export {};
|
|
16
31
|
//# sourceMappingURL=theme-vars.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-vars.d.ts","sourceRoot":"","sources":["../../src/lib/theme-vars.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"theme-vars.d.ts","sourceRoot":"","sources":["../../src/lib/theme-vars.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGzD;;;;;;;;;;GAUG;AACH,KAAK,gBAAgB,GAAG,IAAI,CAC1B,UAAU,EACV,cAAc,GAAG,iBAAiB,GAAG,kBAAkB,GAAG,qBAAqB,GAAG,UAAU,CAC7F,CAAC;AASF,wBAAgB,eAAe,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,IAAI,GAAG,MAAM,CAE5E;AAED,wBAAgB,cAAc,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,IAAI,GAAG,MAAM,CAE3E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,IAAI,GAAG,MAAM,CAI9E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drawnagency/primitives",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.95",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./package.json": "./package.json",
|
|
@@ -60,6 +60,10 @@
|
|
|
60
60
|
"types": "./dist/lib/registry.d.ts",
|
|
61
61
|
"default": "./dist/lib/registry.js"
|
|
62
62
|
},
|
|
63
|
+
"./lib/media-folders": {
|
|
64
|
+
"types": "./dist/lib/media-folders.d.ts",
|
|
65
|
+
"default": "./dist/lib/media-folders.js"
|
|
66
|
+
},
|
|
63
67
|
"./lib/migrate-sections-transform": {
|
|
64
68
|
"types": "./dist/lib/migrate-sections-transform.d.ts",
|
|
65
69
|
"default": "./dist/lib/migrate-sections-transform.js"
|
|
@@ -3,6 +3,7 @@ import ColorsView from "./ColorsView";
|
|
|
3
3
|
import ColorsEditable from "./ColorsEditable";
|
|
4
4
|
import type { ColorItem } from "../sections/Colors/schema";
|
|
5
5
|
import type { SectionContent } from "../../schemas/sections";
|
|
6
|
+
import type { OpenModal } from "../../lib/registry";
|
|
6
7
|
|
|
7
8
|
interface Props {
|
|
8
9
|
colors: ColorItem[];
|
|
@@ -11,7 +12,7 @@ interface Props {
|
|
|
11
12
|
collapsing?: boolean;
|
|
12
13
|
showLabel?: boolean;
|
|
13
14
|
onChange?: (content: SectionContent) => void;
|
|
14
|
-
openModal?:
|
|
15
|
+
openModal?: OpenModal;
|
|
15
16
|
onDelete?: () => void;
|
|
16
17
|
}
|
|
17
18
|
|
|
@@ -8,6 +8,7 @@ import ColorSwatchSettings from "./ColorSwatchSettings";
|
|
|
8
8
|
import { getContrastClass, createColorItem } from "./colors-shared";
|
|
9
9
|
import type { ColorItem } from "../sections/Colors/schema";
|
|
10
10
|
import type { SectionContent } from "../../schemas/sections";
|
|
11
|
+
import type { OpenModal } from "../../lib/registry";
|
|
11
12
|
|
|
12
13
|
export function buildContent(
|
|
13
14
|
colors: ColorItem[],
|
|
@@ -32,7 +33,7 @@ export default function ColorsEditable({
|
|
|
32
33
|
collapsing?: boolean;
|
|
33
34
|
showLabel?: boolean;
|
|
34
35
|
onChange: (content: SectionContent) => void;
|
|
35
|
-
openModal:
|
|
36
|
+
openModal: OpenModal;
|
|
36
37
|
onDelete?: () => void;
|
|
37
38
|
}) {
|
|
38
39
|
const [expanded, setExpanded] = useState(!collapsing);
|
|
@@ -194,9 +194,12 @@ export function SettingsForm({ schema, values, onChange, tabs }: SettingsFormPro
|
|
|
194
194
|
|
|
195
195
|
const listed = new Set(tabs.flatMap((t) => t.fields));
|
|
196
196
|
const otherKeys = Object.keys(schema).filter((key) => !listed.has(key));
|
|
197
|
+
// min-h-0 + overflow-y-auto: the modal locks its height for tabbed content,
|
|
198
|
+
// so a long tab scrolls in place rather than growing the dialog.
|
|
199
|
+
const panel = "flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-px";
|
|
197
200
|
const tabItems = [
|
|
198
|
-
...tabs.map((t) => ({ id: t.label, label: t.label, content: <div className=
|
|
199
|
-
...(otherKeys.length > 0 ? [{ id: "__other__", label: "Other", content: <div className=
|
|
201
|
+
...tabs.map((t) => ({ id: t.label, label: t.label, content: <div className={panel}>{fields(t.fields)}</div> })),
|
|
202
|
+
...(otherKeys.length > 0 ? [{ id: "__other__", label: "Other", content: <div className={panel}>{fields(otherKeys)}</div> }] : []),
|
|
200
203
|
];
|
|
201
204
|
return <Tabs tabs={tabItems} fullBleedTabBar />;
|
|
202
205
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ComponentType, type ReactNode } from "react";
|
|
2
2
|
import type { Edge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
|
|
3
|
-
import { getSection } from "../../../lib/registry";
|
|
3
|
+
import { getSection, type OpenModal } from "../../../lib/registry";
|
|
4
4
|
import { cn } from "../../../lib/cn";
|
|
5
5
|
import { containerGridClass, colSpanClass, spacerHiddenClass, masonryColumnsClass } from "../../../lib/container-grid";
|
|
6
6
|
import { ChildBlockWrapper } from "../../editor/ChildBlockWrapper";
|
|
@@ -27,7 +27,7 @@ type ChildComponent = ComponentType<{
|
|
|
27
27
|
options: Record<string, unknown>;
|
|
28
28
|
isEditMode: boolean;
|
|
29
29
|
onChange?: (content: unknown) => void;
|
|
30
|
-
openModal?:
|
|
30
|
+
openModal?: OpenModal;
|
|
31
31
|
}>;
|
|
32
32
|
|
|
33
33
|
interface ContainerChildProps {
|
|
@@ -48,7 +48,7 @@ interface ContainerChildProps {
|
|
|
48
48
|
onColSpanChange: (span: number) => void;
|
|
49
49
|
onOpenSettings?: () => void;
|
|
50
50
|
onChildContentChange?: (content: unknown) => void;
|
|
51
|
-
openModal?:
|
|
51
|
+
openModal?: OpenModal;
|
|
52
52
|
/** Drag/drop hitbox edges: ["left","right"] in grid (row flow), ["top","bottom"] in masonry
|
|
53
53
|
* (CSS multi-column stacks items vertically). Defaults to ROW_EDGES. */
|
|
54
54
|
allowedEdges?: Edge[];
|
|
@@ -134,7 +134,7 @@ export interface ContainerProps {
|
|
|
134
134
|
content: { id?: string; content: ContainerContent };
|
|
135
135
|
isEditMode: boolean;
|
|
136
136
|
onChange?: (content: unknown) => void;
|
|
137
|
-
openModal?:
|
|
137
|
+
openModal?: OpenModal;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
/**
|
|
@@ -296,6 +296,7 @@ export function Container({ content, isEditMode, onChange, openModal }: Containe
|
|
|
296
296
|
onChange={applyResult}
|
|
297
297
|
tabs={def.settingsTabs}
|
|
298
298
|
/>,
|
|
299
|
+
{ tabbed: (def.settingsTabs?.length ?? 0) > 0 },
|
|
299
300
|
);
|
|
300
301
|
}
|
|
301
302
|
};
|