@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/dist/react.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;
@@ -504,6 +557,37 @@ function collectFieldPatches(props) {
504
557
  }
505
558
  return out;
506
559
  }
560
+ function unwrapFieldsBag(item) {
561
+ if (!item || typeof item !== "object" || Array.isArray(item)) return {};
562
+ const out = {};
563
+ for (const [key, raw] of Object.entries(item)) {
564
+ if (isFieldEnvelope(raw)) {
565
+ out[key] = raw.value;
566
+ continue;
567
+ }
568
+ if (raw && typeof raw === "object" && !Array.isArray(raw) && !isPortableImageShape(raw) && !isEntryRefItem(raw) && !raw.$$typeof) {
569
+ out[key] = unwrapFieldsBag(raw);
570
+ continue;
571
+ }
572
+ out[key] = raw;
573
+ }
574
+ return out;
575
+ }
576
+ function resolveCollectionItems(field, overlay) {
577
+ const name = typeof field?.name === "string" ? field.name : "";
578
+ const raw = overlay !== void 0 ? overlay : field?.value;
579
+ const list = Array.isArray(raw) ? raw : isFieldEnvelope(raw) && Array.isArray(raw.value) ? raw.value : [];
580
+ if (list.length === 0) return [];
581
+ if (isRepeaterArray(list) || list.every((item) => isBrandedFields(item))) {
582
+ return envelopeRepeaterItems(list, name);
583
+ }
584
+ return envelopeRepeaterItems(
585
+ list.map(
586
+ (item) => item && typeof item === "object" && !Array.isArray(item) ? item : {}
587
+ ),
588
+ name
589
+ );
590
+ }
507
591
  function resolveEditableBinding(field, value, name) {
508
592
  if (isFieldEnvelope(field)) {
509
593
  return { name: field.name, value: field.value, requiresName: false };
@@ -3617,6 +3701,16 @@ var ComposerFieldStore = class {
3617
3701
  if (set.size === 0) this.listeners.delete(name);
3618
3702
  };
3619
3703
  }
3704
+ keys() {
3705
+ return [...this.values.keys()];
3706
+ }
3707
+ delete(name) {
3708
+ if (!name || !this.values.has(name)) return;
3709
+ this.values.delete(name);
3710
+ const set = this.listeners.get(name);
3711
+ if (!set) return;
3712
+ for (const fn of set) fn();
3713
+ }
3620
3714
  };
3621
3715
  var ComposerStoreContext = createContext(null);
3622
3716
  function matchesNode(eventNodeId, layoutNodeId) {
@@ -3637,6 +3731,13 @@ function ComposerProvider({
3637
3731
  if (!fieldName || typeof fieldName !== "string") return;
3638
3732
  if (!matchesNode(nodeId, layoutNodeId)) return;
3639
3733
  store.set(fieldName, value);
3734
+ if (value && typeof value === "object") {
3735
+ for (const patch of collectFieldPatches(
3736
+ toFieldEnvelopes({ [fieldName]: value })
3737
+ )) {
3738
+ store.set(patch.name, patch.value);
3739
+ }
3740
+ }
3640
3741
  };
3641
3742
  const applyProps = (nextProps, nodeId) => {
3642
3743
  if (!nextProps || typeof nextProps !== "object" || Array.isArray(nextProps)) {
@@ -3691,6 +3792,9 @@ function useComposerFieldValue(name, fallback) {
3691
3792
  const overlay = useSyncExternalStore(subscribe, getSnapshot, () => void 0);
3692
3793
  return overlay !== void 0 ? overlay : fallback;
3693
3794
  }
3795
+ function useComposerStore() {
3796
+ return useContext(ComposerStoreContext);
3797
+ }
3694
3798
  function MaybeComposerProvider({
3695
3799
  enabled,
3696
3800
  layoutNodeId,
@@ -4354,6 +4458,21 @@ function AmplifyPageContent({
4354
4458
  }
4355
4459
  );
4356
4460
  }
4461
+
4462
+ // src/composer-edit-mode.ts
4463
+ function isComposerEditMode() {
4464
+ if (typeof window === "undefined") return false;
4465
+ return isComposerPreview() && window.__AMPLIFYUP_EVENT_SELECTION__ !== true;
4466
+ }
4467
+ function subscribeComposerEdit(onStoreChange) {
4468
+ if (typeof window === "undefined") return () => {
4469
+ };
4470
+ window.addEventListener("amplifyup:composer-edit", onStoreChange);
4471
+ return () => window.removeEventListener("amplifyup:composer-edit", onStoreChange);
4472
+ }
4473
+ function getComposerEditModeServer() {
4474
+ return false;
4475
+ }
4357
4476
  var ComponentContext = createContext(null);
4358
4477
  function ComponentContextProvider({
4359
4478
  children,
@@ -4455,10 +4574,6 @@ function Slot({
4455
4574
  }
4456
4575
  );
4457
4576
  }
4458
- function isComposerEditMode() {
4459
- if (typeof window === "undefined") return false;
4460
- return isComposerPreview() && window.__AMPLIFYUP_EVENT_SELECTION__ !== true;
4461
- }
4462
4577
  function isLikelyNonTextFieldName(name) {
4463
4578
  const n = name.toLowerCase();
4464
4579
  return n.includes("href") || n.includes("url") || n.includes("src") || n.includes("image") || n.includes("icon") || n.includes("overlay") || n.includes("color");
@@ -4493,17 +4608,11 @@ function canInlineEditRichText(name, value) {
4493
4608
  }
4494
4609
  return true;
4495
4610
  }
4496
- function subscribeComposerEdit(onStoreChange) {
4497
- if (typeof window === "undefined") return () => {
4498
- };
4499
- window.addEventListener("amplifyup:composer-edit", onStoreChange);
4500
- return () => window.removeEventListener("amplifyup:composer-edit", onStoreChange);
4501
- }
4502
4611
  function useComposerEditMode() {
4503
4612
  return useSyncExternalStore(
4504
4613
  subscribeComposerEdit,
4505
4614
  isComposerEditMode,
4506
- () => false
4615
+ getComposerEditModeServer
4507
4616
  );
4508
4617
  }
4509
4618
  function useBoundField(field, value, name, component) {
@@ -4571,23 +4680,20 @@ function ComposerInlineField({
4571
4680
  name,
4572
4681
  value,
4573
4682
  className,
4574
- render,
4575
4683
  layoutNodeId,
4576
4684
  componentId,
4577
4685
  rich = false
4578
4686
  }) {
4579
- const [editing, setEditing] = useState(false);
4580
4687
  const [focused, setFocused] = useState(false);
4581
4688
  const elRef = useRef(null);
4582
4689
  const storedEmpty = isComposerEmptyText(value);
4583
4690
  const text = storedEmpty ? "" : formatFieldValue(value);
4584
4691
  const hint = COMPOSER_EMPTY_FIELD_HINT;
4585
4692
  const idleDisplay = storedEmpty ? hint : text;
4586
- const showRendered = !!render && !editing && !storedEmpty;
4587
- const showHint = storedEmpty && !focused && !showRendered;
4693
+ const showHint = storedEmpty && !focused;
4588
4694
  useEffect(() => {
4589
4695
  const el = elRef.current;
4590
- if (!el || showRendered) return;
4696
+ if (!el) return;
4591
4697
  if (document.activeElement === el) return;
4592
4698
  if (el.querySelector(
4593
4699
  "input, button, select, textarea, form, svg, iframe, img"
@@ -4596,24 +4702,10 @@ function ComposerInlineField({
4596
4702
  }
4597
4703
  const next = idleDisplay || "";
4598
4704
  if (el.textContent !== next) el.textContent = next;
4599
- }, [idleDisplay, showRendered]);
4600
- useEffect(() => {
4601
- if (!editing || !elRef.current) return;
4602
- const el = elRef.current;
4603
- if (storedEmpty) {
4604
- el.textContent = "";
4605
- el.focus();
4606
- placeCaret(el, true);
4607
- return;
4608
- }
4609
- el.textContent = idleDisplay || "";
4610
- el.focus();
4611
- placeCaret(el, false);
4612
- }, [editing, storedEmpty, idleDisplay]);
4705
+ }, [idleDisplay]);
4613
4706
  const finishEdit = () => {
4614
4707
  const raw = (elRef.current?.innerText ?? "").replace(/\u00a0/g, " ").replace(/\n+$/g, "");
4615
4708
  const next = raw.trim() === "" ? "" : raw;
4616
- setEditing(false);
4617
4709
  setFocused(false);
4618
4710
  if (storedEmpty && next === "") {
4619
4711
  if (elRef.current) elRef.current.textContent = hint;
@@ -4647,7 +4739,7 @@ function ComposerInlineField({
4647
4739
  "data-amplifyup-field-type": rich ? "richtext" : "text",
4648
4740
  "data-amplifyup-node-id": layoutNodeId || void 0,
4649
4741
  "data-amplifyup-empty-hint": showHint ? "true" : void 0,
4650
- contentEditable: !rich && !showRendered,
4742
+ contentEditable: !rich,
4651
4743
  suppressContentEditableWarning: true,
4652
4744
  role: "textbox",
4653
4745
  tabIndex: 0,
@@ -4662,9 +4754,6 @@ function ComposerInlineField({
4662
4754
  openRichEditor(event);
4663
4755
  return;
4664
4756
  }
4665
- if (render) {
4666
- setEditing(true);
4667
- }
4668
4757
  },
4669
4758
  onFocus: () => {
4670
4759
  if (!isComposerEditMode()) return;
@@ -4678,7 +4767,6 @@ function ComposerInlineField({
4678
4767
  el.textContent = "";
4679
4768
  placeCaret(el, true);
4680
4769
  }
4681
- if (render) setEditing(true);
4682
4770
  },
4683
4771
  onBlur: rich ? void 0 : finishEdit,
4684
4772
  onKeyDown: (event) => {
@@ -4690,7 +4778,6 @@ function ComposerInlineField({
4690
4778
  if (event.key === "Escape") {
4691
4779
  event.preventDefault();
4692
4780
  if (elRef.current) elRef.current.textContent = idleDisplay || "";
4693
- setEditing(false);
4694
4781
  setFocused(false);
4695
4782
  event.currentTarget.blur();
4696
4783
  }
@@ -4704,8 +4791,7 @@ function ComposerInlineField({
4704
4791
  // Do not force `inline` — that overrides Tailwind `block` and parks
4705
4792
  // an empty-field hint on the same line as a sibling that has a value.
4706
4793
  opacity: showHint ? 0.5 : void 0
4707
- },
4708
- children: showRendered ? render(value) : null
4794
+ }
4709
4795
  }
4710
4796
  );
4711
4797
  }
@@ -4784,35 +4870,8 @@ function warnProjectionProps(component, hasField, hasValue, name) {
4784
4870
  function hasOwnProp(props, key) {
4785
4871
  return Object.prototype.hasOwnProperty.call(props, key);
4786
4872
  }
4787
- function isLinkListItem(value) {
4788
- return !!value && typeof value === "object" && !Array.isArray(value);
4789
- }
4790
- function renderLinkList(items, className) {
4791
- const links = items.filter(isLinkListItem).filter((item) => {
4792
- const label = typeof item.label === "string" ? item.label.trim() : "";
4793
- const href = typeof item.href === "string" ? item.href.trim() : "";
4794
- return !!(label || href);
4795
- });
4796
- if (links.length === 0) return null;
4797
- return /* @__PURE__ */ jsx("span", { className, style: { display: "contents" }, children: links.map((item, index) => {
4798
- const label = typeof item.label === "string" && item.label.trim() ? item.label : typeof item.href === "string" ? item.href : "Link";
4799
- const href = typeof item.href === "string" && item.href.trim() ? item.href : "#";
4800
- const style = typeof item.style === "string" ? item.style.trim() : "";
4801
- return /* @__PURE__ */ jsx(
4802
- "a",
4803
- {
4804
- href,
4805
- target: item.openInNewTab ? "_blank" : void 0,
4806
- rel: item.openInNewTab ? "noreferrer" : void 0,
4807
- "data-amplifyup-action-style": style || void 0,
4808
- children: label
4809
- },
4810
- typeof item._key === "string" && item._key ? item._key : `${href}-${index}`
4811
- );
4812
- }) });
4813
- }
4814
4873
  function Field(props) {
4815
- const { field, value, name, className, render } = props;
4874
+ const { field, value, name, className } = props;
4816
4875
  const context = useContext(ComponentContext);
4817
4876
  const composerEdit = useComposerEditMode();
4818
4877
  const hasField = isFieldEnvelope(field);
@@ -4822,6 +4881,9 @@ function Field(props) {
4822
4881
  if (!hasField && !hasValue && !name) {
4823
4882
  return null;
4824
4883
  }
4884
+ if (Array.isArray(fieldValue)) {
4885
+ return null;
4886
+ }
4825
4887
  const empty = isComposerEmptyText(fieldValue);
4826
4888
  if (composerEdit && editName && context && canInlineEdit(editName, fieldValue)) {
4827
4889
  return /* @__PURE__ */ jsx(
@@ -4830,7 +4892,6 @@ function Field(props) {
4830
4892
  name: editName,
4831
4893
  value: fieldValue,
4832
4894
  className,
4833
- render: empty ? void 0 : render,
4834
4895
  layoutNodeId: context.layoutNodeId,
4835
4896
  componentId: context.componentId,
4836
4897
  rich: looksLikeRichCanvasField(editName)
@@ -4838,17 +4899,190 @@ function Field(props) {
4838
4899
  );
4839
4900
  }
4840
4901
  if (empty) return null;
4841
- if (render) {
4842
- return /* @__PURE__ */ jsx("span", { className, style: { display: "contents" }, children: render(fieldValue) });
4843
- }
4844
- if (Array.isArray(fieldValue)) {
4845
- const list = renderLinkList(fieldValue, className);
4846
- if (list) return list;
4847
- }
4848
4902
  const text = formatFieldValue(fieldValue);
4849
4903
  if (!text) return null;
4850
4904
  return /* @__PURE__ */ jsx("span", { className, children: text });
4851
4905
  }
4906
+ var COMPOSER_EMPTY_COLLECTION_HINT = "Click here to add an item";
4907
+ function CollectionChromeButton({
4908
+ label,
4909
+ onClick
4910
+ }) {
4911
+ return /* @__PURE__ */ jsx(
4912
+ "button",
4913
+ {
4914
+ type: "button",
4915
+ onMouseDown: (event) => event.stopPropagation(),
4916
+ onClick: (event) => {
4917
+ event.preventDefault();
4918
+ event.stopPropagation();
4919
+ onClick();
4920
+ },
4921
+ style: {
4922
+ fontSize: 11,
4923
+ lineHeight: 1.2,
4924
+ padding: "4px 8px",
4925
+ border: "1px solid color-mix(in srgb, currentColor 28%, transparent)",
4926
+ borderRadius: 6,
4927
+ background: "transparent",
4928
+ cursor: "pointer",
4929
+ color: "inherit"
4930
+ },
4931
+ children: label
4932
+ }
4933
+ );
4934
+ }
4935
+ function Collection({
4936
+ field,
4937
+ children,
4938
+ className
4939
+ }) {
4940
+ const context = useContext(ComponentContext);
4941
+ const store = useComposerStore();
4942
+ const composerEdit = useComposerEditMode();
4943
+ const name = isFieldEnvelope(field) ? field.name : "";
4944
+ const overlay = useComposerFieldValue(name, void 0);
4945
+ const items = resolveCollectionItems(field, overlay);
4946
+ const writeItems = (nextPlain) => {
4947
+ if (name && store) {
4948
+ const prefixed = name ? store.keys().filter((key) => key === name || key.startsWith(`${name}.`)) : [];
4949
+ for (const key of prefixed) store.delete(key);
4950
+ store.set(name, nextPlain);
4951
+ for (const patch of collectFieldPatches(
4952
+ toFieldEnvelopes({ [name]: nextPlain })
4953
+ )) {
4954
+ store.set(patch.name, patch.value);
4955
+ }
4956
+ }
4957
+ commitComposerField(
4958
+ context?.layoutNodeId,
4959
+ context?.componentId,
4960
+ name,
4961
+ nextPlain
4962
+ );
4963
+ };
4964
+ const plainItems = () => items.map((item, index) => {
4965
+ const base = unwrapFieldsBag(item);
4966
+ if (!store || !name) return base;
4967
+ const out = { ...base };
4968
+ for (const key of Object.keys(out)) {
4969
+ const overlayValue = store.get(`${name}.${index}.${key}`);
4970
+ if (overlayValue !== void 0) out[key] = overlayValue;
4971
+ }
4972
+ return out;
4973
+ });
4974
+ const addItem = () => writeItems([...plainItems(), {}]);
4975
+ const removeItem = (index) => writeItems(plainItems().filter((_, i) => i !== index));
4976
+ const moveItem = (index, delta) => {
4977
+ const next = plainItems();
4978
+ const target = index + delta;
4979
+ if (target < 0 || target >= next.length) return;
4980
+ const swap = next[index];
4981
+ next[index] = next[target];
4982
+ next[target] = swap;
4983
+ writeItems(next);
4984
+ };
4985
+ if (!composerEdit) {
4986
+ if (items.length === 0) return null;
4987
+ return /* @__PURE__ */ jsx("span", { className, style: { display: "contents" }, children: items.map((item, index) => /* @__PURE__ */ jsx(React2.Fragment, { children: children(item, index) }, item && typeof item === "object" ? `${name}.${index}` : index)) });
4988
+ }
4989
+ if (items.length === 0) {
4990
+ return /* @__PURE__ */ jsx(
4991
+ "span",
4992
+ {
4993
+ className,
4994
+ "data-amplifyup-collection": name || void 0,
4995
+ "data-amplifyup-collection-empty": "true",
4996
+ "data-amplifyup-node-id": context?.layoutNodeId || void 0,
4997
+ role: "button",
4998
+ tabIndex: 0,
4999
+ onMouseDown: (event) => event.stopPropagation(),
5000
+ onClick: (event) => {
5001
+ event.preventDefault();
5002
+ event.stopPropagation();
5003
+ addItem();
5004
+ },
5005
+ onKeyDown: (event) => {
5006
+ if (event.key === "Enter" || event.key === " ") {
5007
+ event.preventDefault();
5008
+ addItem();
5009
+ }
5010
+ },
5011
+ style: {
5012
+ display: "block",
5013
+ cursor: "pointer",
5014
+ outline: "1px dashed color-mix(in srgb, currentColor 40%, transparent)",
5015
+ outlineOffset: 2,
5016
+ minHeight: "3em",
5017
+ opacity: 0.5
5018
+ },
5019
+ children: /* @__PURE__ */ jsx(EmptySlotHint, { label: COMPOSER_EMPTY_COLLECTION_HINT, compact: true })
5020
+ }
5021
+ );
5022
+ }
5023
+ return /* @__PURE__ */ jsxs(
5024
+ "span",
5025
+ {
5026
+ className,
5027
+ "data-amplifyup-collection": name || void 0,
5028
+ "data-amplifyup-node-id": context?.layoutNodeId || void 0,
5029
+ style: { display: "flex", flexDirection: "column", gap: 8 },
5030
+ children: [
5031
+ items.map((item, index) => /* @__PURE__ */ jsxs(
5032
+ "span",
5033
+ {
5034
+ "data-amplifyup-collection-item": `${name}.${index}`,
5035
+ style: {
5036
+ display: "block",
5037
+ outline: "1px dashed color-mix(in srgb, currentColor 28%, transparent)",
5038
+ outlineOffset: 2,
5039
+ padding: 8
5040
+ },
5041
+ children: [
5042
+ /* @__PURE__ */ jsxs(
5043
+ "span",
5044
+ {
5045
+ style: {
5046
+ display: "flex",
5047
+ gap: 6,
5048
+ justifyContent: "flex-end",
5049
+ marginBottom: 8
5050
+ },
5051
+ children: [
5052
+ /* @__PURE__ */ jsx(
5053
+ CollectionChromeButton,
5054
+ {
5055
+ label: "Move up",
5056
+ onClick: () => moveItem(index, -1)
5057
+ }
5058
+ ),
5059
+ /* @__PURE__ */ jsx(
5060
+ CollectionChromeButton,
5061
+ {
5062
+ label: "Move down",
5063
+ onClick: () => moveItem(index, 1)
5064
+ }
5065
+ ),
5066
+ /* @__PURE__ */ jsx(
5067
+ CollectionChromeButton,
5068
+ {
5069
+ label: "Remove",
5070
+ onClick: () => removeItem(index)
5071
+ }
5072
+ )
5073
+ ]
5074
+ }
5075
+ ),
5076
+ children(item, index)
5077
+ ]
5078
+ },
5079
+ `${name}.${index}`
5080
+ )),
5081
+ /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(CollectionChromeButton, { label: "Add item", onClick: addItem }) })
5082
+ ]
5083
+ }
5084
+ );
5085
+ }
4852
5086
  function markdownToHtml(markdown) {
4853
5087
  try {
4854
5088
  const result = marked.parse(markdown, { async: false });
@@ -5237,6 +5471,6 @@ function useAmplifyUp() {
5237
5471
  return context;
5238
5472
  }
5239
5473
 
5240
- export { AmplifyPageContent, AmplifyRenderer, AmplifyUpProvider, ComponentContextProvider, ComposerProvider, Field, Image, MaybeComposerProvider, QueryContentError, RichText, SelectVariantsError, Slot, isBrandedFields, isComposerPreview, isFieldEnvelope, isPreviewRequest, isWorkingContentRequest, nextPageSpec, queryContent, searchSpec, selectVariants, toFieldEnvelopes, useAmplifyUp };
5474
+ export { AmplifyPageContent, AmplifyRenderer, AmplifyUpProvider, Collection, ComponentContextProvider, ComposerProvider, Field, Image, MaybeComposerProvider, QueryContentError, RichText, SelectVariantsError, Slot, isBrandedFields, isComposerPreview, isFieldEnvelope, isPreviewRequest, isWorkingContentRequest, nextPageSpec, queryContent, searchSpec, selectVariants, toFieldEnvelopes, useAmplifyUp };
5241
5475
  //# sourceMappingURL=react.mjs.map
5242
5476
  //# sourceMappingURL=react.mjs.map