@amplifyup/sdk 0.1.62 → 0.1.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +401 -12
- package/dist/{AmplifyRenderer-BQ8-H2H4.d.ts → AmplifyRenderer-Bwob7ICJ.d.ts} +23 -4
- package/dist/{AmplifyRenderer-W7eqltSj.d.mts → AmplifyRenderer-TawbUIKZ.d.mts} +23 -4
- package/dist/AmplifyRenderer.d.mts +1 -1
- package/dist/AmplifyRenderer.d.ts +1 -1
- package/dist/AmplifyRenderer.js +70 -0
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +70 -0
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -0
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +45 -11
- package/dist/react.d.ts +45 -11
- package/dist/react.js +310 -75
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +310 -76
- package/dist/react.mjs.map +1 -1
- package/dist/server.js +37 -0
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +37 -0
- package/dist/server.mjs.map +1 -1
- package/package.json +1 -1
package/dist/AmplifyRenderer.mjs
CHANGED
|
@@ -428,6 +428,21 @@ function isPortableImageShape(value) {
|
|
|
428
428
|
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
429
429
|
return "url" in value;
|
|
430
430
|
}
|
|
431
|
+
function isEntryRefItem(value) {
|
|
432
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
433
|
+
const rec = value;
|
|
434
|
+
return typeof rec.id === "string" && rec.id.trim().length > 0 || typeof rec._id === "string" && rec._id.trim().length > 0 || typeof rec.docId === "string" && rec.docId.trim().length > 0;
|
|
435
|
+
}
|
|
436
|
+
function isRepeaterArray(value) {
|
|
437
|
+
if (!Array.isArray(value) || value.length === 0) return false;
|
|
438
|
+
const sample = value.find((item) => item != null);
|
|
439
|
+
if (sample === void 0) return false;
|
|
440
|
+
if (typeof sample !== "object" || Array.isArray(sample)) return false;
|
|
441
|
+
if (isPortableImageShape(sample)) return false;
|
|
442
|
+
if (isEntryRefItem(sample)) return false;
|
|
443
|
+
if (sample.$$typeof) return false;
|
|
444
|
+
return true;
|
|
445
|
+
}
|
|
431
446
|
function joinPath(prefix, key) {
|
|
432
447
|
return prefix ? `${prefix}.${key}` : key;
|
|
433
448
|
}
|
|
@@ -444,9 +459,21 @@ function toFieldEnvelopes(source, prefix = "") {
|
|
|
444
459
|
for (const [key, raw] of Object.entries(input)) {
|
|
445
460
|
const path = joinPath(prefix, key);
|
|
446
461
|
if (isFieldEnvelope(raw)) {
|
|
462
|
+
const inner = raw.value;
|
|
463
|
+
if (isRepeaterArray(inner)) {
|
|
464
|
+
out[key] = {
|
|
465
|
+
value: envelopeRepeaterItems(inner, raw.name || path),
|
|
466
|
+
name: raw.name || path
|
|
467
|
+
};
|
|
468
|
+
continue;
|
|
469
|
+
}
|
|
447
470
|
out[key] = { value: raw.value ?? null, name: raw.name || path };
|
|
448
471
|
continue;
|
|
449
472
|
}
|
|
473
|
+
if (isRepeaterArray(raw)) {
|
|
474
|
+
out[key] = { value: envelopeRepeaterItems(raw, path), name: path };
|
|
475
|
+
continue;
|
|
476
|
+
}
|
|
450
477
|
if (raw && typeof raw === "object" && !Array.isArray(raw) && !isPortableImageShape(raw) && !raw.$$typeof) {
|
|
451
478
|
out[key] = toFieldEnvelopes(raw, path);
|
|
452
479
|
continue;
|
|
@@ -455,6 +482,16 @@ function toFieldEnvelopes(source, prefix = "") {
|
|
|
455
482
|
}
|
|
456
483
|
return brandFields(out);
|
|
457
484
|
}
|
|
485
|
+
function envelopeRepeaterItems(items, prefix) {
|
|
486
|
+
return items.map((item, i) => {
|
|
487
|
+
const path = joinPath(prefix, String(i));
|
|
488
|
+
if (isBrandedFields(item)) return item;
|
|
489
|
+
if (item && typeof item === "object" && !Array.isArray(item)) {
|
|
490
|
+
return toFieldEnvelopes(item, path);
|
|
491
|
+
}
|
|
492
|
+
return toFieldEnvelopes({}, path);
|
|
493
|
+
});
|
|
494
|
+
}
|
|
458
495
|
function attachFieldEnvelopes(props) {
|
|
459
496
|
const raw = props && typeof props === "object" ? { ...props } : {};
|
|
460
497
|
if (isBrandedFields(raw.fields)) return raw;
|
|
@@ -481,6 +518,14 @@ function envelopePageConfig(page) {
|
|
|
481
518
|
}
|
|
482
519
|
function collectFieldPatches(props) {
|
|
483
520
|
const out = [];
|
|
521
|
+
const walkRepeater = (items, prefix) => {
|
|
522
|
+
items.forEach((item, i) => {
|
|
523
|
+
const itemPath = joinPath(prefix, String(i));
|
|
524
|
+
if (isBrandedFields(item) || item && typeof item === "object" && !Array.isArray(item) && !isFieldEnvelope(item)) {
|
|
525
|
+
walk(item, itemPath);
|
|
526
|
+
}
|
|
527
|
+
});
|
|
528
|
+
};
|
|
484
529
|
const walk = (obj, prefix) => {
|
|
485
530
|
for (const [key, raw] of Object.entries(obj)) {
|
|
486
531
|
if (key === "fields" && raw && typeof raw === "object" && !Array.isArray(raw) && !isFieldEnvelope(raw)) {
|
|
@@ -489,9 +534,17 @@ function collectFieldPatches(props) {
|
|
|
489
534
|
}
|
|
490
535
|
const path = joinPath(prefix, key);
|
|
491
536
|
if (isFieldEnvelope(raw)) {
|
|
537
|
+
if (isRepeaterArray(raw.value)) {
|
|
538
|
+
walkRepeater(raw.value, raw.name || path);
|
|
539
|
+
continue;
|
|
540
|
+
}
|
|
492
541
|
out.push({ name: raw.name || path, value: raw.value });
|
|
493
542
|
continue;
|
|
494
543
|
}
|
|
544
|
+
if (isRepeaterArray(raw)) {
|
|
545
|
+
walkRepeater(raw, path);
|
|
546
|
+
continue;
|
|
547
|
+
}
|
|
495
548
|
if (raw && typeof raw === "object" && !Array.isArray(raw) && !isPortableImageShape(raw) && !raw.$$typeof) {
|
|
496
549
|
walk(raw, path);
|
|
497
550
|
continue;
|
|
@@ -3232,6 +3285,16 @@ var ComposerFieldStore = class {
|
|
|
3232
3285
|
if (set.size === 0) this.listeners.delete(name);
|
|
3233
3286
|
};
|
|
3234
3287
|
}
|
|
3288
|
+
keys() {
|
|
3289
|
+
return [...this.values.keys()];
|
|
3290
|
+
}
|
|
3291
|
+
delete(name) {
|
|
3292
|
+
if (!name || !this.values.has(name)) return;
|
|
3293
|
+
this.values.delete(name);
|
|
3294
|
+
const set = this.listeners.get(name);
|
|
3295
|
+
if (!set) return;
|
|
3296
|
+
for (const fn of set) fn();
|
|
3297
|
+
}
|
|
3235
3298
|
};
|
|
3236
3299
|
var ComposerStoreContext = createContext(null);
|
|
3237
3300
|
function matchesNode(eventNodeId, layoutNodeId) {
|
|
@@ -3252,6 +3315,13 @@ function ComposerProvider({
|
|
|
3252
3315
|
if (!fieldName || typeof fieldName !== "string") return;
|
|
3253
3316
|
if (!matchesNode(nodeId, layoutNodeId)) return;
|
|
3254
3317
|
store.set(fieldName, value);
|
|
3318
|
+
if (value && typeof value === "object") {
|
|
3319
|
+
for (const patch of collectFieldPatches(
|
|
3320
|
+
toFieldEnvelopes({ [fieldName]: value })
|
|
3321
|
+
)) {
|
|
3322
|
+
store.set(patch.name, patch.value);
|
|
3323
|
+
}
|
|
3324
|
+
}
|
|
3255
3325
|
};
|
|
3256
3326
|
const applyProps = (nextProps, nodeId) => {
|
|
3257
3327
|
if (!nextProps || typeof nextProps !== "object" || Array.isArray(nextProps)) {
|