@endora-commerce/page-builder-core 0.100.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/LICENSE +21 -0
- package/README.md +51 -0
- package/dist/block-name.d.ts +48 -0
- package/dist/block-name.d.ts.map +1 -0
- package/dist/block-name.js +79 -0
- package/dist/block-name.js.map +1 -0
- package/dist/block-tree.d.ts +44 -0
- package/dist/block-tree.d.ts.map +1 -0
- package/dist/block-tree.js +120 -0
- package/dist/block-tree.js.map +1 -0
- package/dist/client.d.ts +3 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +4 -0
- package/dist/client.js.map +1 -0
- package/dist/color-palette/context.d.ts +18 -0
- package/dist/color-palette/context.d.ts.map +1 -0
- package/dist/color-palette/context.js +11 -0
- package/dist/color-palette/context.js.map +1 -0
- package/dist/define-component.d.ts +47 -0
- package/dist/define-component.d.ts.map +1 -0
- package/dist/define-component.js +74 -0
- package/dist/define-component.js.map +1 -0
- package/dist/editor/editor-carousel-preview-ui.d.ts +7 -0
- package/dist/editor/editor-carousel-preview-ui.d.ts.map +1 -0
- package/dist/editor/editor-carousel-preview-ui.js +11 -0
- package/dist/editor/editor-carousel-preview-ui.js.map +1 -0
- package/dist/editor/editor-carousel-preview.d.ts +31 -0
- package/dist/editor/editor-carousel-preview.d.ts.map +1 -0
- package/dist/editor/editor-carousel-preview.js +109 -0
- package/dist/editor/editor-carousel-preview.js.map +1 -0
- package/dist/editor/enhance-component-config.d.ts +7 -0
- package/dist/editor/enhance-component-config.d.ts.map +1 -0
- package/dist/editor/enhance-component-config.js +55 -0
- package/dist/editor/enhance-component-config.js.map +1 -0
- package/dist/editor/field-tabs.d.ts +7 -0
- package/dist/editor/field-tabs.d.ts.map +1 -0
- package/dist/editor/field-tabs.js +29 -0
- package/dist/editor/field-tabs.js.map +1 -0
- package/dist/editor/fields-tab-panel.d.ts +9 -0
- package/dist/editor/fields-tab-panel.d.ts.map +1 -0
- package/dist/editor/fields-tab-panel.js +132 -0
- package/dist/editor/fields-tab-panel.js.map +1 -0
- package/dist/editor/format-outline-label.d.ts +2 -0
- package/dist/editor/format-outline-label.d.ts.map +1 -0
- package/dist/editor/format-outline-label.js +10 -0
- package/dist/editor/format-outline-label.js.map +1 -0
- package/dist/editor/outline-data.d.ts +13 -0
- package/dist/editor/outline-data.d.ts.map +1 -0
- package/dist/editor/outline-data.js +73 -0
- package/dist/editor/outline-data.js.map +1 -0
- package/dist/editor/outline-dnd.d.ts +15 -0
- package/dist/editor/outline-dnd.d.ts.map +1 -0
- package/dist/editor/outline-dnd.js +55 -0
- package/dist/editor/outline-dnd.js.map +1 -0
- package/dist/editor/page-builder-component-overlay.d.ts +13 -0
- package/dist/editor/page-builder-component-overlay.d.ts.map +1 -0
- package/dist/editor/page-builder-component-overlay.js +14 -0
- package/dist/editor/page-builder-component-overlay.js.map +1 -0
- package/dist/editor/page-builder-outline.d.ts +10 -0
- package/dist/editor/page-builder-outline.d.ts.map +1 -0
- package/dist/editor/page-builder-outline.js +133 -0
- package/dist/editor/page-builder-outline.js.map +1 -0
- package/dist/editor/page-builder-plugin.d.ts +6 -0
- package/dist/editor/page-builder-plugin.d.ts.map +1 -0
- package/dist/editor/page-builder-plugin.js +31 -0
- package/dist/editor/page-builder-plugin.js.map +1 -0
- package/dist/editor/preview-viewport-bridge.d.ts +9 -0
- package/dist/editor/preview-viewport-bridge.d.ts.map +1 -0
- package/dist/editor/preview-viewport-bridge.js +19 -0
- package/dist/editor/preview-viewport-bridge.js.map +1 -0
- package/dist/editor/preview-viewport-store.d.ts +4 -0
- package/dist/editor/preview-viewport-store.d.ts.map +1 -0
- package/dist/editor/preview-viewport-store.js +24 -0
- package/dist/editor/preview-viewport-store.js.map +1 -0
- package/dist/editor/puck-action-guards.d.ts +46 -0
- package/dist/editor/puck-action-guards.d.ts.map +1 -0
- package/dist/editor/puck-action-guards.js +232 -0
- package/dist/editor/puck-action-guards.js.map +1 -0
- package/dist/editor/puck-dnd-element.d.ts +3 -0
- package/dist/editor/puck-dnd-element.d.ts.map +1 -0
- package/dist/editor/puck-dnd-element.js +20 -0
- package/dist/editor/puck-dnd-element.js.map +1 -0
- package/dist/editor/settings-scope-context.d.ts +13 -0
- package/dist/editor/settings-scope-context.d.ts.map +1 -0
- package/dist/editor/settings-scope-context.js +30 -0
- package/dist/editor/settings-scope-context.js.map +1 -0
- package/dist/editor/settings-scope-store.d.ts +5 -0
- package/dist/editor/settings-scope-store.d.ts.map +1 -0
- package/dist/editor/settings-scope-store.js +22 -0
- package/dist/editor/settings-scope-store.js.map +1 -0
- package/dist/editor/settings-tab-store.d.ts +5 -0
- package/dist/editor/settings-tab-store.d.ts.map +1 -0
- package/dist/editor/settings-tab-store.js +22 -0
- package/dist/editor/settings-tab-store.js.map +1 -0
- package/dist/editor/use-component-scope.d.ts +4 -0
- package/dist/editor/use-component-scope.d.ts.map +1 -0
- package/dist/editor/use-component-scope.js +15 -0
- package/dist/editor/use-component-scope.js.map +1 -0
- package/dist/editor/use-page-builder-puck.d.ts +4 -0
- package/dist/editor/use-page-builder-puck.d.ts.map +1 -0
- package/dist/editor/use-page-builder-puck.js +4 -0
- package/dist/editor/use-page-builder-puck.js.map +1 -0
- package/dist/editor/use-preview-breakpoint-tier.d.ts +10 -0
- package/dist/editor/use-preview-breakpoint-tier.d.ts.map +1 -0
- package/dist/editor/use-preview-breakpoint-tier.js +40 -0
- package/dist/editor/use-preview-breakpoint-tier.js.map +1 -0
- package/dist/editor.d.ts +15 -0
- package/dist/editor.d.ts.map +1 -0
- package/dist/editor.js +16 -0
- package/dist/editor.js.map +1 -0
- package/dist/fields/background-field.d.ts +14 -0
- package/dist/fields/background-field.d.ts.map +1 -0
- package/dist/fields/background-field.js +38 -0
- package/dist/fields/background-field.js.map +1 -0
- package/dist/fields/border-field.d.ts +5 -0
- package/dist/fields/border-field.d.ts.map +1 -0
- package/dist/fields/border-field.js +85 -0
- package/dist/fields/border-field.js.map +1 -0
- package/dist/fields/color-field-utils.d.ts +16 -0
- package/dist/fields/color-field-utils.d.ts.map +1 -0
- package/dist/fields/color-field-utils.js +45 -0
- package/dist/fields/color-field-utils.js.map +1 -0
- package/dist/fields/color-field.d.ts +5 -0
- package/dist/fields/color-field.d.ts.map +1 -0
- package/dist/fields/color-field.js +74 -0
- package/dist/fields/color-field.js.map +1 -0
- package/dist/fields/color-input-debounce.d.ts +6 -0
- package/dist/fields/color-input-debounce.d.ts.map +1 -0
- package/dist/fields/color-input-debounce.js +24 -0
- package/dist/fields/color-input-debounce.js.map +1 -0
- package/dist/fields/editor-name-field.d.ts +3 -0
- package/dist/fields/editor-name-field.d.ts.map +1 -0
- package/dist/fields/editor-name-field.js +12 -0
- package/dist/fields/editor-name-field.js.map +1 -0
- package/dist/fields/hide-on-field.d.ts +4 -0
- package/dist/fields/hide-on-field.d.ts.map +1 -0
- package/dist/fields/hide-on-field.js +26 -0
- package/dist/fields/hide-on-field.js.map +1 -0
- package/dist/fields/native-color-input.d.ts +12 -0
- package/dist/fields/native-color-input.d.ts.map +1 -0
- package/dist/fields/native-color-input.js +51 -0
- package/dist/fields/native-color-input.js.map +1 -0
- package/dist/fields/puck-field-label.d.ts +8 -0
- package/dist/fields/puck-field-label.d.ts.map +1 -0
- package/dist/fields/puck-field-label.js +8 -0
- package/dist/fields/puck-field-label.js.map +1 -0
- package/dist/fields/responsive-field-types.d.ts +21 -0
- package/dist/fields/responsive-field-types.d.ts.map +1 -0
- package/dist/fields/responsive-field-types.js +97 -0
- package/dist/fields/responsive-field-types.js.map +1 -0
- package/dist/fields/scoped-field.d.ts +19 -0
- package/dist/fields/scoped-field.d.ts.map +1 -0
- package/dist/fields/scoped-field.js +67 -0
- package/dist/fields/scoped-field.js.map +1 -0
- package/dist/fields/spacing-field.d.ts +14 -0
- package/dist/fields/spacing-field.d.ts.map +1 -0
- package/dist/fields/spacing-field.js +71 -0
- package/dist/fields/spacing-field.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/migration/frozen-block-renames.d.ts +14 -0
- package/dist/migration/frozen-block-renames.d.ts.map +1 -0
- package/dist/migration/frozen-block-renames.js +132 -0
- package/dist/migration/frozen-block-renames.js.map +1 -0
- package/dist/migration/index.d.ts +4 -0
- package/dist/migration/index.d.ts.map +1 -0
- package/dist/migration/index.js +22 -0
- package/dist/migration/index.js.map +1 -0
- package/dist/migration/rename-block-names-sql.d.ts +28 -0
- package/dist/migration/rename-block-names-sql.d.ts.map +1 -0
- package/dist/migration/rename-block-names-sql.js +117 -0
- package/dist/migration/rename-block-names-sql.js.map +1 -0
- package/dist/palette.d.ts +47 -0
- package/dist/palette.d.ts.map +1 -0
- package/dist/palette.js +84 -0
- package/dist/palette.js.map +1 -0
- package/dist/render/responsive-styles.d.ts +19 -0
- package/dist/render/responsive-styles.d.ts.map +1 -0
- package/dist/render/responsive-styles.js +91 -0
- package/dist/render/responsive-styles.js.map +1 -0
- package/dist/types/background.d.ts +26 -0
- package/dist/types/background.d.ts.map +1 -0
- package/dist/types/background.js +76 -0
- package/dist/types/background.js.map +1 -0
- package/dist/types/box-styles.d.ts +67 -0
- package/dist/types/box-styles.d.ts.map +1 -0
- package/dist/types/box-styles.js +217 -0
- package/dist/types/box-styles.js.map +1 -0
- package/dist/types/editor-chrome.d.ts +15 -0
- package/dist/types/editor-chrome.d.ts.map +1 -0
- package/dist/types/editor-chrome.js +8 -0
- package/dist/types/editor-chrome.js.map +1 -0
- package/dist/types/hide-on.d.ts +6 -0
- package/dist/types/hide-on.d.ts.map +1 -0
- package/dist/types/hide-on.js +2 -0
- package/dist/types/hide-on.js.map +1 -0
- package/dist/types/responsive.d.ts +70 -0
- package/dist/types/responsive.d.ts.map +1 -0
- package/dist/types/responsive.js +91 -0
- package/dist/types/responsive.js.map +1 -0
- package/dist/visibility/with-hide-on.d.ts +12 -0
- package/dist/visibility/with-hide-on.d.ts.map +1 -0
- package/dist/visibility/with-hide-on.js +28 -0
- package/dist/visibility/with-hide-on.js.map +1 -0
- package/package.json +96 -0
- package/tailwind.css +14 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The DDL that creates the rewrite function, and the `drop` that retires it.
|
|
3
|
+
*
|
|
4
|
+
* `functionName` must be unique per migration: five migrations may share one
|
|
5
|
+
* pooled session, and a second `create function` over the same name would fail
|
|
6
|
+
* — so each migration names its own and drops it when it is done.
|
|
7
|
+
*
|
|
8
|
+
* The map is embedded as a **`jsonb` object literal** and the lookup is
|
|
9
|
+
* `map -> (value #>> '{}')`, a single hash probe per node rather than a join.
|
|
10
|
+
* `coalesce(…, v)` is the one branch `contracts/block-name-migration.md` §3.3
|
|
11
|
+
* describes: a name the map holds is replaced, anything else is left
|
|
12
|
+
* byte-identical — an already-namespaced name and an unrecognised one alike,
|
|
13
|
+
* because the map's domain is bare and its codomain is dotted.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createRenameFunctionSql(functionName: string, renames: Readonly<Record<string, string>>): string;
|
|
16
|
+
/** Retire the function created by {@link createRenameFunctionSql}. */
|
|
17
|
+
export declare function dropRenameFunctionSql(functionName: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Apply the function to one column.
|
|
20
|
+
*
|
|
21
|
+
* `where "<column>" is not null` and nothing finer: a `jsonb` document with no
|
|
22
|
+
* node in it is rewritten to a structurally identical document, so the update
|
|
23
|
+
* is a no-op in content and costs one rewritten row. Trying to narrow it with a
|
|
24
|
+
* `@>` containment test would need the node's shape, which is the thing the walk
|
|
25
|
+
* exists to find.
|
|
26
|
+
*/
|
|
27
|
+
export declare function applyRenameFunctionSql(functionName: string, table: string, column: string): string;
|
|
28
|
+
//# sourceMappingURL=rename-block-names-sql.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rename-block-names-sql.d.ts","sourceRoot":"","sources":["../../src/migration/rename-block-names-sql.ts"],"names":[],"mappings":"AAgCA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GACxC,MAAM,CAgCR;AAED,sEAAsE;AACtE,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAGlE;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,MAAM,CAKR"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// The rename migration's SQL — feature 096, T403.
|
|
2
|
+
//
|
|
3
|
+
// **One generator, five migrations** (`contracts/block-name-migration.md` §3.4).
|
|
4
|
+
// Each of the five table-owning modules writes its own migration over its own
|
|
5
|
+
// columns; what none of them writes is the rewrite itself, because five copies
|
|
6
|
+
// of a recursive `jsonb` walk are five chances to disagree about what a node is.
|
|
7
|
+
//
|
|
8
|
+
// ## The premise, verified before this file was written (T403a)
|
|
9
|
+
//
|
|
10
|
+
// `contracts/block-name-migration.md` §3.4 flagged the shape as unverified:
|
|
11
|
+
// every migration in this tree uses `this.addSql(...)` with literal SQL and
|
|
12
|
+
// **none creates a function**, so there was no precedent for `pg_temp`
|
|
13
|
+
// surviving MikroORM's statement batching. It was probed against real
|
|
14
|
+
// PostgreSQL before anything was built on it, on MikroORM 6.6.13: a
|
|
15
|
+
// `create function pg_temp.…` issued through `addSql` **is** visible to a later
|
|
16
|
+
// `addSql` in the same migration, the recursion works, and a slotted child two
|
|
17
|
+
// levels down is renamed. The fallback — a batched row walk in TypeScript — was
|
|
18
|
+
// therefore not needed and is not carried here.
|
|
19
|
+
//
|
|
20
|
+
// ## Why a function rather than an expression
|
|
21
|
+
//
|
|
22
|
+
// The rewrite is recursive: a Puck tree nests to arbitrary depth and places node
|
|
23
|
+
// arrays under arbitrary prop keys. SQL has no recursive expression, so the
|
|
24
|
+
// choice is a function or a row walk in TypeScript; the function runs inside the
|
|
25
|
+
// migration's own transaction, needs no ORM and uses memory independent of the
|
|
26
|
+
// data size.
|
|
27
|
+
//
|
|
28
|
+
// `pg_temp` and not a schema-qualified permanent function: the object lives for
|
|
29
|
+
// the session and disappears with it, so an upgrade leaves nothing behind for an
|
|
30
|
+
// operator to notice or clean up, and a failed migration's rollback removes it
|
|
31
|
+
// with everything else.
|
|
32
|
+
/**
|
|
33
|
+
* The DDL that creates the rewrite function, and the `drop` that retires it.
|
|
34
|
+
*
|
|
35
|
+
* `functionName` must be unique per migration: five migrations may share one
|
|
36
|
+
* pooled session, and a second `create function` over the same name would fail
|
|
37
|
+
* — so each migration names its own and drops it when it is done.
|
|
38
|
+
*
|
|
39
|
+
* The map is embedded as a **`jsonb` object literal** and the lookup is
|
|
40
|
+
* `map -> (value #>> '{}')`, a single hash probe per node rather than a join.
|
|
41
|
+
* `coalesce(…, v)` is the one branch `contracts/block-name-migration.md` §3.3
|
|
42
|
+
* describes: a name the map holds is replaced, anything else is left
|
|
43
|
+
* byte-identical — an already-namespaced name and an unrecognised one alike,
|
|
44
|
+
* because the map's domain is bare and its codomain is dotted.
|
|
45
|
+
*/
|
|
46
|
+
export function createRenameFunctionSql(functionName, renames) {
|
|
47
|
+
assertPgTempFunctionName(functionName);
|
|
48
|
+
const map = JSON.stringify(renames);
|
|
49
|
+
// Every value in the map is a block name — `^[a-z][a-z0-9_]*\.[A-Z][A-Za-z0-9]*$`
|
|
50
|
+
// — so it carries no quote, no backslash and no dollar sign, and the literal
|
|
51
|
+
// below cannot be terminated early. Asserted rather than assumed.
|
|
52
|
+
assertSqlSafeMap(renames);
|
|
53
|
+
return `
|
|
54
|
+
create function pg_temp.${functionName}(doc jsonb) returns jsonb as $fn096$
|
|
55
|
+
select case jsonb_typeof(doc)
|
|
56
|
+
when 'object' then (
|
|
57
|
+
select coalesce(
|
|
58
|
+
jsonb_object_agg(
|
|
59
|
+
e.k,
|
|
60
|
+
case
|
|
61
|
+
when e.k = 'type' and jsonb_typeof(e.v) = 'string'
|
|
62
|
+
then coalesce('${map}'::jsonb -> (e.v #>> '{}'), e.v)
|
|
63
|
+
else pg_temp.${functionName}(e.v)
|
|
64
|
+
end
|
|
65
|
+
),
|
|
66
|
+
'{}'::jsonb
|
|
67
|
+
)
|
|
68
|
+
from jsonb_each(doc) as e(k, v)
|
|
69
|
+
)
|
|
70
|
+
when 'array' then (
|
|
71
|
+
select coalesce(jsonb_agg(pg_temp.${functionName}(el)), '[]'::jsonb)
|
|
72
|
+
from jsonb_array_elements(doc) as el
|
|
73
|
+
)
|
|
74
|
+
else doc
|
|
75
|
+
end
|
|
76
|
+
$fn096$ language sql immutable;
|
|
77
|
+
`;
|
|
78
|
+
}
|
|
79
|
+
/** Retire the function created by {@link createRenameFunctionSql}. */
|
|
80
|
+
export function dropRenameFunctionSql(functionName) {
|
|
81
|
+
assertPgTempFunctionName(functionName);
|
|
82
|
+
return `drop function if exists pg_temp.${functionName}(jsonb);`;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Apply the function to one column.
|
|
86
|
+
*
|
|
87
|
+
* `where "<column>" is not null` and nothing finer: a `jsonb` document with no
|
|
88
|
+
* node in it is rewritten to a structurally identical document, so the update
|
|
89
|
+
* is a no-op in content and costs one rewritten row. Trying to narrow it with a
|
|
90
|
+
* `@>` containment test would need the node's shape, which is the thing the walk
|
|
91
|
+
* exists to find.
|
|
92
|
+
*/
|
|
93
|
+
export function applyRenameFunctionSql(functionName, table, column) {
|
|
94
|
+
assertPgTempFunctionName(functionName);
|
|
95
|
+
assertIdentifier(table);
|
|
96
|
+
assertIdentifier(column);
|
|
97
|
+
return `update "${table}" set "${column}" = pg_temp.${functionName}("${column}") where "${column}" is not null;`;
|
|
98
|
+
}
|
|
99
|
+
function assertPgTempFunctionName(name) {
|
|
100
|
+
if (!/^[a-z][a-z0-9_]*$/.test(name)) {
|
|
101
|
+
throw new Error(`[page-builder-core] "${name}" is not a usable pg_temp function name.`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function assertIdentifier(name) {
|
|
105
|
+
if (!/^[a-z][a-z0-9_]*$/.test(name)) {
|
|
106
|
+
throw new Error(`[page-builder-core] "${name}" is not a usable SQL identifier.`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function assertSqlSafeMap(renames) {
|
|
110
|
+
for (const [from, to] of Object.entries(renames)) {
|
|
111
|
+
if (!/^[A-Za-z0-9_.]+$/.test(from) || !/^[A-Za-z0-9_.]+$/.test(to)) {
|
|
112
|
+
throw new Error(`[page-builder-core] block name "${from}" -> "${to}" carries a character that cannot ` +
|
|
113
|
+
'be embedded in the rename function literal.');
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=rename-block-names-sql.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rename-block-names-sql.js","sourceRoot":"","sources":["../../src/migration/rename-block-names-sql.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,EAAE;AACF,iFAAiF;AACjF,8EAA8E;AAC9E,+EAA+E;AAC/E,iFAAiF;AACjF,EAAE;AACF,gEAAgE;AAChE,EAAE;AACF,4EAA4E;AAC5E,4EAA4E;AAC5E,uEAAuE;AACvE,sEAAsE;AACtE,oEAAoE;AACpE,gFAAgF;AAChF,+EAA+E;AAC/E,gFAAgF;AAChF,gDAAgD;AAChD,EAAE;AACF,8CAA8C;AAC9C,EAAE;AACF,iFAAiF;AACjF,4EAA4E;AAC5E,iFAAiF;AACjF,+EAA+E;AAC/E,aAAa;AACb,EAAE;AACF,gFAAgF;AAChF,iFAAiF;AACjF,+EAA+E;AAC/E,wBAAwB;AAExB;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,uBAAuB,CACrC,YAAoB,EACpB,OAAyC;IAEzC,wBAAwB,CAAC,YAAY,CAAC,CAAC;IACvC,MAAM,GAAG,GAAG,IAAI,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CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;YACnE,MAAM,IAAI,KAAK,CACb,mCAAmC,IAAI,SAAS,EAAE,oCAAoC;gBACpF,6CAA6C,CAChD,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Config } from '@measured/puck';
|
|
2
|
+
import type { PageBuilderContext } from './types/responsive.js';
|
|
3
|
+
/** A section as the descriptor serves it — already merged across present modules. */
|
|
4
|
+
export interface ServedPaletteSection {
|
|
5
|
+
readonly key: string;
|
|
6
|
+
readonly titleKey: string;
|
|
7
|
+
readonly contexts: readonly PageBuilderContext[];
|
|
8
|
+
readonly weight?: number | undefined;
|
|
9
|
+
readonly visible?: boolean | undefined;
|
|
10
|
+
/** The module whose declaration won the merge. Derived, never declared. */
|
|
11
|
+
readonly ownerModule?: string | undefined;
|
|
12
|
+
}
|
|
13
|
+
/** A block as the descriptor serves it — the fields this derivation reads. */
|
|
14
|
+
export interface ServedPaletteBlock {
|
|
15
|
+
readonly name: string;
|
|
16
|
+
readonly ownerModule: string;
|
|
17
|
+
readonly category?: string | undefined;
|
|
18
|
+
readonly contexts?: readonly PageBuilderContext[] | undefined;
|
|
19
|
+
readonly weight?: number | undefined;
|
|
20
|
+
}
|
|
21
|
+
export interface BuildPaletteOptions {
|
|
22
|
+
/**
|
|
23
|
+
* Resolve a section's title. `titleKey` is **module-relative**, so the caller
|
|
24
|
+
* supplies the scope binding — `useTranslationContext().t(ownerModule, key)`
|
|
25
|
+
* in the admin. Returning the key unchanged is a legitimate answer and is what
|
|
26
|
+
* an unresolved key renders as.
|
|
27
|
+
*/
|
|
28
|
+
readonly title: (section: ServedPaletteSection) => string;
|
|
29
|
+
/**
|
|
30
|
+
* Names the renderer map actually holds. A declared block with no renderer in
|
|
31
|
+
* this bundle is left out of the palette rather than offered and then
|
|
32
|
+
* exploding on insert; it still resolves to the missing-component placeholder
|
|
33
|
+
* when it is already in a document (FR-019).
|
|
34
|
+
*/
|
|
35
|
+
readonly renderable: ReadonlySet<string>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Build the Puck `categories` map for one context.
|
|
39
|
+
*
|
|
40
|
+
* Order is a function of the declarations alone — lowest `weight` first with an
|
|
41
|
+
* absent `weight` sorting after every declared one, ties by key (sections) or by
|
|
42
|
+
* name (blocks), both ascending — so the palette is stable under a
|
|
43
|
+
* re-composition or a reordering of `MODULES`, which is D-45 applied to a
|
|
44
|
+
* discovery surface.
|
|
45
|
+
*/
|
|
46
|
+
export declare function buildPaletteCategories(blocks: readonly ServedPaletteBlock[], sections: readonly ServedPaletteSection[], context: PageBuilderContext, options: BuildPaletteOptions): NonNullable<Config['categories']>;
|
|
47
|
+
//# sourceMappingURL=palette.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"palette.d.ts","sourceRoot":"","sources":["../src/palette.ts"],"names":[],"mappings":"AAkCA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,qFAAqF;AACrF,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,SAAS,kBAAkB,EAAE,CAAC;IACjD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACvC,2EAA2E;IAC3E,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3C;AAED,8EAA8E;AAC9E,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,kBAAkB,EAAE,GAAG,SAAS,CAAC;IAC9D,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC;AAED,MAAM,WAAW,mBAAmB;IAClC;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,oBAAoB,KAAK,MAAM,CAAC;IAC1D;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC1C;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,SAAS,kBAAkB,EAAE,EACrC,QAAQ,EAAE,SAAS,oBAAoB,EAAE,EACzC,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,mBAAmB,GAC3B,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CA6BnC"}
|
package/dist/palette.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// The derived palette — feature 096, T305/T310.
|
|
2
|
+
//
|
|
3
|
+
// **One layer answers "which sections does the palette for context X have, and
|
|
4
|
+
// what is in them"** (`contracts/block-definition.md` §4.1.1). The three
|
|
5
|
+
// hand-written `categories` maps that answered it before — one in
|
|
6
|
+
// `cms-components`, one in `email-components`, one in `invoices`' Puck config —
|
|
7
|
+
// are gone: a section is now declared by the module whose blocks occupy it, and
|
|
8
|
+
// contributing a block into a section costs no edit to a file the contributor
|
|
9
|
+
// does not own (FR-009). What arrives here is the *served* declarations, merged
|
|
10
|
+
// across the effectively present modules by the registry
|
|
11
|
+
// (`page-builder-registry.ts`), and what leaves is a Puck `categories` map.
|
|
12
|
+
//
|
|
13
|
+
// ## Admission, and why it is applied here and nowhere else
|
|
14
|
+
//
|
|
15
|
+
// `contexts` states what a block is **authored for**; which palette it
|
|
16
|
+
// **appears in** is derived. The one admission the platform grants is
|
|
17
|
+
// `email -> newsletter` — the newsletter palette *is* the e-mail palette, and no
|
|
18
|
+
// block in this repository declares `newsletter`. The relation has one
|
|
19
|
+
// implementation, `contextAdmits`, and this file imports it rather than spelling
|
|
20
|
+
// `contexts.includes(context)`, which is correct for `cms`, `email` and
|
|
21
|
+
// `invoice` and silently empties the fourth.
|
|
22
|
+
//
|
|
23
|
+
// **It applies to sections as well as to blocks, at the same fold.** That is not
|
|
24
|
+
// a symmetry for its own sake: a palette that admits the blocks and not the
|
|
25
|
+
// sections renders 28 entries in Puck's *Other* drawer — not empty, merely
|
|
26
|
+
// unsectioned, which is the state defect D-c exists to close.
|
|
27
|
+
//
|
|
28
|
+
// ## What is derived from the blocks rather than from the declarations
|
|
29
|
+
//
|
|
30
|
+
// A declared section with no visible member in this context is **not rendered**.
|
|
31
|
+
// That is reading 3's kept half (`contracts/block-definition.md` §1.1): the set
|
|
32
|
+
// of sections actually rendered follows the blocks, so a module declaring a
|
|
33
|
+
// section it then contributes nothing to adds no empty drawer.
|
|
34
|
+
import { contextAdmits } from './define-component.js';
|
|
35
|
+
/**
|
|
36
|
+
* Build the Puck `categories` map for one context.
|
|
37
|
+
*
|
|
38
|
+
* Order is a function of the declarations alone — lowest `weight` first with an
|
|
39
|
+
* absent `weight` sorting after every declared one, ties by key (sections) or by
|
|
40
|
+
* name (blocks), both ascending — so the palette is stable under a
|
|
41
|
+
* re-composition or a reordering of `MODULES`, which is D-45 applied to a
|
|
42
|
+
* discovery surface.
|
|
43
|
+
*/
|
|
44
|
+
export function buildPaletteCategories(blocks, sections, context, options) {
|
|
45
|
+
const admittedBlocks = blocks
|
|
46
|
+
.filter((block) => contextAdmits(block.contexts ?? ['cms'], context) && options.renderable.has(block.name))
|
|
47
|
+
.sort(compareByWeightThen((block) => block.name));
|
|
48
|
+
const membersByCategory = new Map();
|
|
49
|
+
for (const block of admittedBlocks) {
|
|
50
|
+
if (!block.category)
|
|
51
|
+
continue;
|
|
52
|
+
const bucket = membersByCategory.get(block.category);
|
|
53
|
+
if (bucket)
|
|
54
|
+
bucket.push(block.name);
|
|
55
|
+
else
|
|
56
|
+
membersByCategory.set(block.category, [block.name]);
|
|
57
|
+
}
|
|
58
|
+
const categories = {};
|
|
59
|
+
for (const section of [...sections]
|
|
60
|
+
.filter((section) => contextAdmits(section.contexts, context))
|
|
61
|
+
.sort(compareByWeightThen((section) => section.key))) {
|
|
62
|
+
const members = membersByCategory.get(section.key);
|
|
63
|
+
if (!members || members.length === 0)
|
|
64
|
+
continue;
|
|
65
|
+
categories[section.key] = {
|
|
66
|
+
title: options.title(section),
|
|
67
|
+
components: members,
|
|
68
|
+
...(section.visible !== undefined ? { visible: section.visible } : {}),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
return categories;
|
|
72
|
+
}
|
|
73
|
+
function compareByWeightThen(tiebreak) {
|
|
74
|
+
return (a, b) => {
|
|
75
|
+
const aw = a.weight ?? Number.POSITIVE_INFINITY;
|
|
76
|
+
const bw = b.weight ?? Number.POSITIVE_INFINITY;
|
|
77
|
+
if (aw !== bw)
|
|
78
|
+
return aw - bw;
|
|
79
|
+
const at = tiebreak(a);
|
|
80
|
+
const bt = tiebreak(b);
|
|
81
|
+
return at < bt ? -1 : at > bt ? 1 : 0;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=palette.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"palette.js","sourceRoot":"","sources":["../src/palette.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,EAAE;AACF,+EAA+E;AAC/E,yEAAyE;AACzE,kEAAkE;AAClE,gFAAgF;AAChF,gFAAgF;AAChF,8EAA8E;AAC9E,gFAAgF;AAChF,yDAAyD;AACzD,4EAA4E;AAC5E,EAAE;AACF,4DAA4D;AAC5D,EAAE;AACF,uEAAuE;AACvE,sEAAsE;AACtE,i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CAAC,CAAC;IACxC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
import { type PageBuilderBreakpoints, type ResponsiveProp, hideOnDataAttrs, type BreakpointTier } from '../types/responsive.js';
|
|
3
|
+
export type ResponsiveVisibility = ResponsiveProp<boolean>;
|
|
4
|
+
export declare const DEFAULT_VISIBILITY: ResponsiveVisibility;
|
|
5
|
+
export declare function resolveVisibility(visibility: ResponsiveVisibility | boolean | undefined, tier: BreakpointTier): boolean;
|
|
6
|
+
export declare function breakpointCssVars(breakpoints?: PageBuilderBreakpoints): CSSProperties;
|
|
7
|
+
export declare const RESPONSIVE_HIDE_ON_CLASS = "cmsc-pb-hide-on";
|
|
8
|
+
export { hideOnDataAttrs };
|
|
9
|
+
export declare function buildResponsiveNumberVars(name: string, value: number | ResponsiveProp<number> | undefined, fallback: number): CSSProperties;
|
|
10
|
+
/** Unitless responsive CSS custom properties (font-weight, line-height multipliers). */
|
|
11
|
+
export declare function buildResponsiveCSSValueVars(name: string, value: number | ResponsiveProp<number> | undefined, fallback: number): CSSProperties;
|
|
12
|
+
export declare function responsiveRowAlignClass(value: ResponsiveProp<string> | string | undefined, fallback: string): string;
|
|
13
|
+
export declare function resolveRowAlignClassForTier(value: ResponsiveProp<string> | string | undefined, tier: BreakpointTier, fallback: string): string;
|
|
14
|
+
export declare function textAlignDataAttrs(value: ResponsiveProp<string> | string | undefined, fallback: string): Record<string, string>;
|
|
15
|
+
export declare function resolveTextAlignForTier(value: ResponsiveProp<string> | string | undefined, tier: BreakpointTier, fallback: string): 'left' | 'center' | 'right';
|
|
16
|
+
export declare function responsiveTextAlignClass(_value: ResponsiveProp<string> | string | undefined, _fallback: string): string;
|
|
17
|
+
export declare function resolveTextAlignClassForTier(value: ResponsiveProp<string> | string | undefined, tier: BreakpointTier, fallback: string): string;
|
|
18
|
+
export declare function resolveResponsiveNumber(value: number | ResponsiveProp<number> | undefined, tier: BreakpointTier, fallback: number): number;
|
|
19
|
+
//# sourceMappingURL=responsive-styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responsive-styles.d.ts","sourceRoot":"","sources":["../../src/render/responsive-styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAEL,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EAGnB,eAAe,EACf,KAAK,cAAc,EACpB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,oBAAoB,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;AAE3D,eAAO,MAAM,kBAAkB,EAAE,oBAAqC,CAAC;AAEvE,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,oBAAoB,GAAG,OAAO,GAAG,SAAS,EACtD,IAAI,EAAE,cAAc,GACnB,OAAO,CAIT;AAED,wBAAgB,iBAAiB,CAAC,WAAW,GAAE,sBAA4C,GAAG,aAAa,CAK1G;AAED,eAAO,MAAM,wBAAwB,oBAAoB,CAAC;AAE1D,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC,GAAG,SAAS,EAClD,QAAQ,EAAE,MAAM,GACf,aAAa,CASf;AAED,wFAAwF;AACxF,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC,GAAG,SAAS,EAClD,QAAQ,EAAE,MAAM,GACf,aAAa,CASf;AAeD,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,cAAc,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,SAAS,EAClD,QAAQ,EAAE,MAAM,GACf,MAAM,CAQR;AAED,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,cAAc,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,SAAS,EAClD,IAAI,EAAE,cAAc,EACpB,QAAQ,EAAE,MAAM,GACf,MAAM,CAGR;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,cAAc,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,SAAS,EAClD,QAAQ,EAAE,MAAM,GACf,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CASxB;AAED,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,cAAc,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,SAAS,EAClD,IAAI,EAAE,cAAc,EACpB,QAAQ,EAAE,MAAM,GACf,MAAM,GAAG,QAAQ,GAAG,OAAO,CAI7B;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,SAAS,EACnD,SAAS,EAAE,MAAM,GAChB,MAAM,CAER;AAED,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,cAAc,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,SAAS,EAClD,IAAI,EAAE,cAAc,EACpB,QAAQ,EAAE,MAAM,GACf,MAAM,CAGR;AAED,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC,GAAG,SAAS,EAClD,IAAI,EAAE,cAAc,EACpB,QAAQ,EAAE,MAAM,GACf,MAAM,CAER"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { DEFAULT_BREAKPOINTS, normalizeResponsive, resolveResponsive, hideOnDataAttrs, } from '../types/responsive.js';
|
|
2
|
+
export const DEFAULT_VISIBILITY = { base: true };
|
|
3
|
+
export function resolveVisibility(visibility, tier) {
|
|
4
|
+
if (visibility === undefined)
|
|
5
|
+
return true;
|
|
6
|
+
if (typeof visibility === 'boolean')
|
|
7
|
+
return visibility;
|
|
8
|
+
return resolveResponsive(visibility, tier, true);
|
|
9
|
+
}
|
|
10
|
+
export function breakpointCssVars(breakpoints = DEFAULT_BREAKPOINTS) {
|
|
11
|
+
return {
|
|
12
|
+
'--cmsc-bp-tablet': `${breakpoints.tabletMin}px`,
|
|
13
|
+
'--cmsc-bp-desktop': `${breakpoints.desktopMin}px`,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export const RESPONSIVE_HIDE_ON_CLASS = 'cmsc-pb-hide-on';
|
|
17
|
+
export { hideOnDataAttrs };
|
|
18
|
+
export function buildResponsiveNumberVars(name, value, fallback) {
|
|
19
|
+
const responsive = normalizeResponsive(value, fallback);
|
|
20
|
+
const tablet = responsive.tablet ?? responsive.base;
|
|
21
|
+
const desktop = responsive.desktop ?? tablet;
|
|
22
|
+
return {
|
|
23
|
+
[`--pb-${name}`]: `${responsive.base}px`,
|
|
24
|
+
[`--pb-${name}-md`]: `${tablet}px`,
|
|
25
|
+
[`--pb-${name}-lg`]: `${desktop}px`,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/** Unitless responsive CSS custom properties (font-weight, line-height multipliers). */
|
|
29
|
+
export function buildResponsiveCSSValueVars(name, value, fallback) {
|
|
30
|
+
const responsive = normalizeResponsive(value, fallback);
|
|
31
|
+
const tablet = responsive.tablet ?? responsive.base;
|
|
32
|
+
const desktop = responsive.desktop ?? tablet;
|
|
33
|
+
return {
|
|
34
|
+
[`--pb-${name}`]: String(responsive.base),
|
|
35
|
+
[`--pb-${name}-md`]: String(tablet),
|
|
36
|
+
[`--pb-${name}-lg`]: String(desktop),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
const ROW_ALIGN_CLASS = {
|
|
40
|
+
stretch: 'cmsc:items-stretch',
|
|
41
|
+
start: 'cmsc:items-start',
|
|
42
|
+
center: 'cmsc:items-center',
|
|
43
|
+
end: 'cmsc:items-end',
|
|
44
|
+
};
|
|
45
|
+
const TEXT_ALIGN_CLASS = {
|
|
46
|
+
left: 'cmsc:text-left',
|
|
47
|
+
center: 'cmsc:text-center',
|
|
48
|
+
right: 'cmsc:text-right',
|
|
49
|
+
};
|
|
50
|
+
export function responsiveRowAlignClass(value, fallback) {
|
|
51
|
+
const mobile = resolveResponsive(value, 'mobile', fallback);
|
|
52
|
+
const tablet = resolveResponsive(value, 'tablet', fallback);
|
|
53
|
+
const desktop = resolveResponsive(value, 'desktop', fallback);
|
|
54
|
+
const classes = [ROW_ALIGN_CLASS[mobile] ?? ROW_ALIGN_CLASS.stretch, 'cmsc-pb-row-align'];
|
|
55
|
+
if (tablet !== mobile)
|
|
56
|
+
classes.push(`cmsc-pb-row-align-md-${tablet}`);
|
|
57
|
+
if (desktop !== tablet)
|
|
58
|
+
classes.push(`cmsc-pb-row-align-lg-${desktop}`);
|
|
59
|
+
return classes.join(' ');
|
|
60
|
+
}
|
|
61
|
+
export function resolveRowAlignClassForTier(value, tier, fallback) {
|
|
62
|
+
const resolved = resolveResponsive(value, tier, fallback);
|
|
63
|
+
return ROW_ALIGN_CLASS[resolved] ?? 'cmsc:items-stretch';
|
|
64
|
+
}
|
|
65
|
+
export function textAlignDataAttrs(value, fallback) {
|
|
66
|
+
const normalized = normalizeResponsive(value, fallback);
|
|
67
|
+
const tablet = normalized.tablet ?? normalized.base;
|
|
68
|
+
const desktop = normalized.desktop ?? normalized.tablet ?? normalized.base;
|
|
69
|
+
return {
|
|
70
|
+
'data-align': normalized.base,
|
|
71
|
+
'data-align-md': tablet,
|
|
72
|
+
'data-align-lg': desktop,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
export function resolveTextAlignForTier(value, tier, fallback) {
|
|
76
|
+
const resolved = resolveResponsive(value, tier, fallback);
|
|
77
|
+
if (resolved === 'center' || resolved === 'right')
|
|
78
|
+
return resolved;
|
|
79
|
+
return 'left';
|
|
80
|
+
}
|
|
81
|
+
export function responsiveTextAlignClass(_value, _fallback) {
|
|
82
|
+
return 'cmsc-pb-text-align';
|
|
83
|
+
}
|
|
84
|
+
export function resolveTextAlignClassForTier(value, tier, fallback) {
|
|
85
|
+
const resolved = resolveResponsive(value, tier, fallback);
|
|
86
|
+
return TEXT_ALIGN_CLASS[resolved] ?? 'cmsc:text-left';
|
|
87
|
+
}
|
|
88
|
+
export function resolveResponsiveNumber(value, tier, fallback) {
|
|
89
|
+
return resolveResponsive(value, tier, fallback);
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=responsive-styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responsive-styles.js","sourceRoot":"","sources":["../../src/render/responsive-styles.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EAGnB,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,GAEhB,MAAM,wBAAwB,CAAC;AAIhC,MAAM,CAAC,MAAM,kBAAkB,GAAyB,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AAEvE,MAAM,UAAU,iBAAiB,CAC/B,UAAsD,EACtD,IAAoB;IAEpB,IAAI,UAAU,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAC1C,IAAI,OAAO,UAAU,KAAK,SAAS;QAAE,OAAO,UAAU,CAAC;IACvD,OAAO,iBAAiB,CAAC,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,cAAsC,mBAAmB;IACzF,OAAO;QACL,kBAAkB,EAAE,GAAG,WAAW,CAAC,SAAS,IAAI;QAChD,mBAAmB,EAAE,GAAG,WAAW,CAAC,UAAU,IAAI;KAClC,CAAC;AACrB,CAAC;AAED,MAAM,CAAC,MAAM,wBAAwB,GAAG,iBAAiB,CAAC;AAE1D,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B,MAAM,UAAU,yBAAyB,CACvC,IAAY,EACZ,KAAkD,EAClD,QAAgB;IAEhB,MAAM,UAAU,GAAG,mBAAmB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACxD,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,IAAI,UAAU,CAAC,IAAI,CAAC;IACpD,MAA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,GAAG,iBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC1D,IAAI,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,OAAO;QAAE,OAAO,QAAQ,CAAC;IACnE,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,wBAAwB,CACtC,MAAmD,EACnD,SAAiB;IAEjB,OAAO,oBAAoB,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,4BAA4B,CAC1C,KAAkD,EAClD,IAAoB,EACpB,QAAgB;IAEhB,MAAM,QAAQ,GAAG,iBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC1D,OAAO,gBAAgB,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,uBAAuB,CACrC,KAAkD,EAClD,IAAoB,EACpB,QAAgB;IAEhB,OAAO,iBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type BackgroundKind = 'none' | 'solid' | 'gradient' | 'image' | 'video';
|
|
2
|
+
export type MediaSourceKind = 'url' | 'library';
|
|
3
|
+
export interface BackgroundValue {
|
|
4
|
+
kind: BackgroundKind;
|
|
5
|
+
color?: string;
|
|
6
|
+
gradientFrom?: string;
|
|
7
|
+
gradientTo?: string;
|
|
8
|
+
gradientAngle?: number;
|
|
9
|
+
imageSource?: MediaSourceKind;
|
|
10
|
+
imageUrl?: string;
|
|
11
|
+
imageAssetId?: string;
|
|
12
|
+
videoSource?: MediaSourceKind;
|
|
13
|
+
videoUrl?: string;
|
|
14
|
+
videoAssetId?: string;
|
|
15
|
+
}
|
|
16
|
+
export type BackgroundProp = string | BackgroundValue | undefined;
|
|
17
|
+
/** Rebases host-relative media URLs onto the API origin (never the page origin). */
|
|
18
|
+
export declare function absolutizeBackgroundMediaUrl(url: string, mediaBaseUrl?: string): string;
|
|
19
|
+
export declare function normalizeBackground(value: BackgroundProp): BackgroundValue;
|
|
20
|
+
export declare function backgroundToStyle(value: BackgroundProp, assets?: Record<string, {
|
|
21
|
+
url: string;
|
|
22
|
+
}>, mediaBaseUrl?: string): {
|
|
23
|
+
style: Record<string, string>;
|
|
24
|
+
videoUrl?: string;
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=background.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"background.d.ts","sourceRoot":"","sources":["../../src/types/background.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,OAAO,GAAG,OAAO,CAAC;AAC/E,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,SAAS,CAAC;AAEhD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,cAAc,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,eAAe,GAAG,SAAS,CAAC;AAElE,oFAAoF;AACpF,wBAAgB,4BAA4B,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAMvF;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,cAAc,GAAG,eAAe,CAU1E;AAED,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,cAAc,EACrB,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAM,EAC5C,YAAY,CAAC,EAAE,MAAM,GACpB;IACD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAuDA"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/** Rebases host-relative media URLs onto the API origin (never the page origin). */
|
|
2
|
+
export function absolutizeBackgroundMediaUrl(url, mediaBaseUrl) {
|
|
3
|
+
if (!url)
|
|
4
|
+
return '';
|
|
5
|
+
if (/^(https?:|data:|blob:)/i.test(url))
|
|
6
|
+
return url;
|
|
7
|
+
if (!url.startsWith('/'))
|
|
8
|
+
return url;
|
|
9
|
+
const base = mediaBaseUrl?.replace(/\/+$/, '');
|
|
10
|
+
return base ? `${base}${url}` : url;
|
|
11
|
+
}
|
|
12
|
+
export function normalizeBackground(value) {
|
|
13
|
+
if (value === undefined || value === null || value === '') {
|
|
14
|
+
return { kind: 'none' };
|
|
15
|
+
}
|
|
16
|
+
if (typeof value === 'string') {
|
|
17
|
+
if (value === 'transparent')
|
|
18
|
+
return { kind: 'none' };
|
|
19
|
+
return { kind: 'solid', color: value };
|
|
20
|
+
}
|
|
21
|
+
if (!value.kind)
|
|
22
|
+
return { kind: 'none' };
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
export function backgroundToStyle(value, assets = {}, mediaBaseUrl) {
|
|
26
|
+
const bg = normalizeBackground(value);
|
|
27
|
+
if (bg.kind === 'none')
|
|
28
|
+
return { style: {} };
|
|
29
|
+
if (bg.kind === 'solid') {
|
|
30
|
+
const color = bg.color && bg.color !== 'transparent' ? bg.color : undefined;
|
|
31
|
+
return color ? { style: { backgroundColor: color } } : { style: {} };
|
|
32
|
+
}
|
|
33
|
+
if (bg.kind === 'gradient') {
|
|
34
|
+
const from = bg.gradientFrom ?? '#ffffff';
|
|
35
|
+
const to = bg.gradientTo ?? '#000000';
|
|
36
|
+
const angle = bg.gradientAngle ?? 135;
|
|
37
|
+
return {
|
|
38
|
+
style: {
|
|
39
|
+
background: `linear-gradient(${angle}deg, ${from}, ${to})`,
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
if (bg.kind === 'image') {
|
|
44
|
+
const raw = bg.imageSource === 'library' && bg.imageAssetId
|
|
45
|
+
? assets[bg.imageAssetId]?.url ||
|
|
46
|
+
(bg.imageAssetId ? `/assets/file/${bg.imageAssetId}` : '')
|
|
47
|
+
: bg.imageUrl ?? '';
|
|
48
|
+
const url = absolutizeBackgroundMediaUrl(raw, mediaBaseUrl);
|
|
49
|
+
if (!url)
|
|
50
|
+
return { style: {} };
|
|
51
|
+
return {
|
|
52
|
+
style: {
|
|
53
|
+
backgroundImage: `url("${url.replace(/"/g, '\\"')}")`,
|
|
54
|
+
backgroundSize: 'cover',
|
|
55
|
+
backgroundPosition: 'center',
|
|
56
|
+
backgroundRepeat: 'no-repeat',
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
if (bg.kind === 'video') {
|
|
61
|
+
const raw = bg.videoSource === 'library' && bg.videoAssetId
|
|
62
|
+
? assets[bg.videoAssetId]?.url ||
|
|
63
|
+
(bg.videoAssetId ? `/assets/file/${bg.videoAssetId}` : '')
|
|
64
|
+
: bg.videoUrl ?? '';
|
|
65
|
+
const url = absolutizeBackgroundMediaUrl(raw, mediaBaseUrl);
|
|
66
|
+
return {
|
|
67
|
+
style: {
|
|
68
|
+
position: 'relative',
|
|
69
|
+
overflow: 'hidden',
|
|
70
|
+
},
|
|
71
|
+
...(url ? { videoUrl: url } : {}),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
return { style: {} };
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=background.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"background.js","sourceRoot":"","sources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AO;YACL,KAAK,EAAE;gBACL,eAAe,EAAE,QAAQ,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI;gBACrD,cAAc,EAAE,OAAO;gBACvB,kBAAkB,EAAE,QAAQ;gBAC5B,gBAAgB,EAAE,WAAW;aAC9B;SACF,CAAC;IACJ,CAAC;IAED,IAAI,EAAE,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QACxB,MAAM,GAAG,GACP,EAAE,CAAC,WAAW,KAAK,SAAS,IAAI,EAAE,CAAC,YAAY;YAC7C,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,YAAY,CAAC,EAAE,GAAG;gBAC5B,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,gBAAgB,EAAE,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5D,CAAC,CAAC,EAAE,CAAC,QAAQ,IAAI,EAAE,CAAC;QACxB,MAAM,GAAG,GAAG,4BAA4B,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;QAC5D,OAAO;YACL,KAAK,EAAE;gBACL,QAAQ,EAAE,UAAU;gBACpB,QAAQ,EAAE,QAAQ;aACnB;YACD,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAClC,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
import { type BreakpointTier, type ResponsiveProp } from './responsive.js';
|
|
3
|
+
export type SpacingValue = {
|
|
4
|
+
mode: 'uniform';
|
|
5
|
+
value: number;
|
|
6
|
+
} | {
|
|
7
|
+
mode: 'sides';
|
|
8
|
+
top: number;
|
|
9
|
+
right: number;
|
|
10
|
+
bottom: number;
|
|
11
|
+
left: number;
|
|
12
|
+
};
|
|
13
|
+
export type BorderStyle = 'none' | 'solid' | 'dashed' | 'dotted';
|
|
14
|
+
export type BorderSide = {
|
|
15
|
+
width: number;
|
|
16
|
+
style: BorderStyle;
|
|
17
|
+
color: string;
|
|
18
|
+
};
|
|
19
|
+
export type BorderValue = {
|
|
20
|
+
mode: 'none';
|
|
21
|
+
} | {
|
|
22
|
+
mode: 'uniform';
|
|
23
|
+
width: number;
|
|
24
|
+
style: BorderStyle;
|
|
25
|
+
color: string;
|
|
26
|
+
} | {
|
|
27
|
+
mode: 'sides';
|
|
28
|
+
top: BorderSide;
|
|
29
|
+
right: BorderSide;
|
|
30
|
+
bottom: BorderSide;
|
|
31
|
+
left: BorderSide;
|
|
32
|
+
};
|
|
33
|
+
export declare const DEFAULT_SPACING: SpacingValue;
|
|
34
|
+
export declare const DEFAULT_BORDER: BorderValue;
|
|
35
|
+
export declare function normalizeSpacing(value: SpacingValue | undefined): SpacingValue;
|
|
36
|
+
export declare function normalizeBorder(value: BorderValue | undefined): BorderValue;
|
|
37
|
+
export declare function spacingToCss(value: SpacingValue | undefined): string;
|
|
38
|
+
export declare function borderToCss(value: BorderValue | undefined): string | undefined;
|
|
39
|
+
export declare function borderSidesToCss(value: BorderValue | undefined): CSSProperties;
|
|
40
|
+
export declare function buildResponsiveSpacingVars(name: string, value: SpacingValue | ResponsiveProp<SpacingValue> | undefined, fallback?: SpacingValue): CSSProperties;
|
|
41
|
+
export declare function buildResponsiveBorderVars(value: BorderValue | ResponsiveProp<BorderValue> | undefined, fallback?: BorderValue): CSSProperties;
|
|
42
|
+
export declare function resolveSpacing(value: SpacingValue | ResponsiveProp<SpacingValue> | undefined, tier: BreakpointTier, fallback?: SpacingValue): SpacingValue;
|
|
43
|
+
export declare function resolveBorder(value: BorderValue | ResponsiveProp<BorderValue> | undefined, tier: BreakpointTier, fallback?: BorderValue): BorderValue;
|
|
44
|
+
export declare function spacingStyleForTier(value: SpacingValue | ResponsiveProp<SpacingValue> | undefined, tier: BreakpointTier, property: 'margin' | 'padding', fallback?: SpacingValue): CSSProperties;
|
|
45
|
+
export declare function borderStyleForTier(value: BorderValue | ResponsiveProp<BorderValue> | undefined, tier: BreakpointTier, fallback?: BorderValue): CSSProperties;
|
|
46
|
+
export declare function gridTemplateColumnsFromCount(count: number): string;
|
|
47
|
+
export declare function buildResponsiveColumnCountVars(value: number | ResponsiveProp<number> | undefined, fallback?: number): CSSProperties;
|
|
48
|
+
export declare function resolveColumnCount(value: number | ResponsiveProp<number> | undefined, tier: BreakpointTier, fallback?: number): number;
|
|
49
|
+
export type ContentWidth = 'full' | 'narrow' | 'wide';
|
|
50
|
+
export type RowContentMaxWidth = 'none' | 'narrow' | 'wide' | 'custom';
|
|
51
|
+
export type RowSectionLayout = 'in_flow' | 'full_width' | 'full_bleed';
|
|
52
|
+
export type ContentPosition = 'top' | 'middle' | 'bottom';
|
|
53
|
+
export type CornerRadius = 'none' | 'small' | 'medium' | 'large';
|
|
54
|
+
export type Shadow = 'none' | 'soft' | 'medium';
|
|
55
|
+
export type VerticalAlign = 'top' | 'middle' | 'bottom' | 'stretch';
|
|
56
|
+
export declare const CONTENT_WIDTH_MAX: Record<ContentWidth, string | undefined>;
|
|
57
|
+
export declare const ROW_CONTENT_MAX_WIDTH: Record<'narrow' | 'wide', string>;
|
|
58
|
+
export declare function clampColumnSpan(value: number): number;
|
|
59
|
+
export declare function resolveColumnSpan(value: number | ResponsiveProp<number> | undefined, tier: BreakpointTier, fallback?: number): number;
|
|
60
|
+
export declare function buildResponsiveSpanVars(value: number | ResponsiveProp<number> | undefined, fallback?: number): CSSProperties;
|
|
61
|
+
export declare const CORNER_RADIUS_PX: Record<CornerRadius, number>;
|
|
62
|
+
export declare const SHADOW_CSS: Record<Shadow, string>;
|
|
63
|
+
export declare function resolveContentPosition(position: ContentPosition | ResponsiveProp<ContentPosition> | undefined, tier: BreakpointTier): ContentPosition;
|
|
64
|
+
export declare function contentPositionToJustify(position: ContentPosition): string;
|
|
65
|
+
export declare function resolveVerticalAlign(value: VerticalAlign | ResponsiveProp<VerticalAlign> | undefined, tier: BreakpointTier): VerticalAlign;
|
|
66
|
+
export declare function verticalAlignToCss(value: VerticalAlign): string;
|
|
67
|
+
//# sourceMappingURL=box-styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"box-styles.d.ts","sourceRoot":"","sources":["../../src/types/box-styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,YAAY,GACpB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhF,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEjE,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,WAAW,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACrE;IACE,IAAI,EAAE,OAAO,CAAC;IACd,GAAG,EAAE,UAAU,CAAC;IAChB,KAAK,EAAE,UAAU,CAAC;IAClB,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,EAAE,UAAU,CAAC;CAClB,CAAC;A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