@pixldocs/canvas-renderer 0.5.3 → 0.5.5
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/index.cjs +42 -45
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +42 -45
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -8,7 +8,6 @@ const react = require("react");
|
|
|
8
8
|
const reactDom = require("react-dom");
|
|
9
9
|
const zustand = require("zustand");
|
|
10
10
|
const fabric = require("fabric");
|
|
11
|
-
const supabaseJs = require("@supabase/supabase-js");
|
|
12
11
|
const client = require("react-dom/client");
|
|
13
12
|
const jspdf = require("jspdf");
|
|
14
13
|
const svg2pdf_js = require("svg2pdf.js");
|
|
@@ -8784,50 +8783,6 @@ function applyThemeToConfig(config, themeOverrides) {
|
|
|
8784
8783
|
}
|
|
8785
8784
|
return cloned;
|
|
8786
8785
|
}
|
|
8787
|
-
const SUPABASE_URL = void 0;
|
|
8788
|
-
const SUPABASE_PUBLISHABLE_KEY = void 0;
|
|
8789
|
-
supabaseJs.createClient(SUPABASE_URL, SUPABASE_PUBLISHABLE_KEY, {
|
|
8790
|
-
auth: {
|
|
8791
|
-
storage: localStorage,
|
|
8792
|
-
persistSession: true,
|
|
8793
|
-
autoRefreshToken: true
|
|
8794
|
-
}
|
|
8795
|
-
});
|
|
8796
|
-
function repeatablePageToSection(page) {
|
|
8797
|
-
return {
|
|
8798
|
-
id: page.id,
|
|
8799
|
-
label: page.label,
|
|
8800
|
-
description: page.description,
|
|
8801
|
-
// Place pages after sections by default; explicit order preserved.
|
|
8802
|
-
order: typeof page.order === "number" ? page.order + 1e4 : 1e4,
|
|
8803
|
-
fields: page.fields,
|
|
8804
|
-
repeatable: true,
|
|
8805
|
-
minEntries: page.minEntries,
|
|
8806
|
-
maxEntries: page.maxEntries,
|
|
8807
|
-
templateKeyPrefix: page.templateKeyPrefix,
|
|
8808
|
-
children: page.children
|
|
8809
|
-
};
|
|
8810
|
-
}
|
|
8811
|
-
function getRenderableFormSections(schema) {
|
|
8812
|
-
if (!schema) return [];
|
|
8813
|
-
const base = schema.sections ?? [];
|
|
8814
|
-
const pages = schema.repeatablePages ?? [];
|
|
8815
|
-
if (!pages.length) return base;
|
|
8816
|
-
return [...base, ...pages.map(repeatablePageToSection)];
|
|
8817
|
-
}
|
|
8818
|
-
function buildRepeatablePagesInputForApply(schema, sectionState) {
|
|
8819
|
-
var _a;
|
|
8820
|
-
if (!((_a = schema == null ? void 0 : schema.repeatablePages) == null ? void 0 : _a.length)) return [];
|
|
8821
|
-
return schema.repeatablePages.map((p) => {
|
|
8822
|
-
const entries = sectionState == null ? void 0 : sectionState[p.id];
|
|
8823
|
-
const minEntries = p.minEntries != null ? Math.max(0, p.minEntries) : 1;
|
|
8824
|
-
let entryCount;
|
|
8825
|
-
if (Array.isArray(entries)) {
|
|
8826
|
-
entryCount = minEntries === 0 ? entries.length : Math.max(1, entries.length);
|
|
8827
|
-
}
|
|
8828
|
-
return { pageId: p.id, templateKeyPrefix: p.templateKeyPrefix, entryCount };
|
|
8829
|
-
});
|
|
8830
|
-
}
|
|
8831
8786
|
function mapFormDefFieldType(t) {
|
|
8832
8787
|
if (["text", "email", "tel", "textarea", "date", "url", "number", "toggle", "color", "image"].includes(t)) return t;
|
|
8833
8788
|
if (t === "currency") return "number";
|
|
@@ -10349,6 +10304,48 @@ function applyContentBoundsPagination(config) {
|
|
|
10349
10304
|
if (!mutated) return config;
|
|
10350
10305
|
return { ...config, pages: resultPages };
|
|
10351
10306
|
}
|
|
10307
|
+
function repeatablePageToSection(page) {
|
|
10308
|
+
return {
|
|
10309
|
+
id: page.id,
|
|
10310
|
+
label: page.label,
|
|
10311
|
+
description: page.description,
|
|
10312
|
+
order: typeof page.order === "number" ? page.order + 1e4 : 1e4,
|
|
10313
|
+
fields: page.fields,
|
|
10314
|
+
repeatable: true,
|
|
10315
|
+
minEntries: page.minEntries,
|
|
10316
|
+
maxEntries: page.maxEntries,
|
|
10317
|
+
templateKeyPrefix: page.templateKeyPrefix,
|
|
10318
|
+
children: page.children
|
|
10319
|
+
};
|
|
10320
|
+
}
|
|
10321
|
+
function getRenderableFormSections(schema) {
|
|
10322
|
+
if (!schema) return [];
|
|
10323
|
+
const base = schema.sections ?? [];
|
|
10324
|
+
const pages = schema.repeatablePages ?? [];
|
|
10325
|
+
if (!pages.length) return base;
|
|
10326
|
+
return [...base, ...pages.map(repeatablePageToSection)];
|
|
10327
|
+
}
|
|
10328
|
+
function buildRepeatablePagesInputForApply(schema, sectionState) {
|
|
10329
|
+
var _a;
|
|
10330
|
+
if (!((_a = schema == null ? void 0 : schema.repeatablePages) == null ? void 0 : _a.length)) return [];
|
|
10331
|
+
const normalizeTemplateKeyPrefix = (prefix) => {
|
|
10332
|
+
if (!prefix || typeof prefix !== "string") return "";
|
|
10333
|
+
return prefix.replace(/^field_/, "");
|
|
10334
|
+
};
|
|
10335
|
+
return schema.repeatablePages.map((page) => {
|
|
10336
|
+
const entries = sectionState == null ? void 0 : sectionState[page.id];
|
|
10337
|
+
const minEntries = page.minEntries != null ? Math.max(0, page.minEntries) : 1;
|
|
10338
|
+
let entryCount;
|
|
10339
|
+
if (Array.isArray(entries)) {
|
|
10340
|
+
entryCount = minEntries === 0 ? entries.length : Math.max(1, entries.length);
|
|
10341
|
+
}
|
|
10342
|
+
return {
|
|
10343
|
+
pageId: page.id,
|
|
10344
|
+
templateKeyPrefix: normalizeTemplateKeyPrefix(page.templateKeyPrefix),
|
|
10345
|
+
entryCount
|
|
10346
|
+
};
|
|
10347
|
+
});
|
|
10348
|
+
}
|
|
10352
10349
|
async function fetchRow(supabaseUrl, anonKey, table, id) {
|
|
10353
10350
|
const url = `${supabaseUrl}/rest/v1/${table}?id=eq.${id}&select=*`;
|
|
10354
10351
|
const res = await fetch(url, {
|