@nascentdigital/funnel-editor 4.5.3 → 4.5.6

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.
Files changed (62) hide show
  1. package/dist/core/components/feedback/Note.d.ts +3 -1
  2. package/dist/core/components/feedback/Note.js +6 -3
  3. package/dist/core/components/fields/BooleanField.d.ts +3 -1
  4. package/dist/core/components/fields/BooleanField.js +2 -2
  5. package/dist/core/components/fields/DateField.d.ts +3 -1
  6. package/dist/core/components/fields/DateField.js +2 -2
  7. package/dist/core/components/fields/EnumField.d.ts +3 -1
  8. package/dist/core/components/fields/EnumField.js +4 -4
  9. package/dist/core/components/fields/FieldEditor.d.ts +3 -1
  10. package/dist/core/components/fields/FieldEditor.js +7 -7
  11. package/dist/core/components/fields/FieldHeader.d.ts +3 -1
  12. package/dist/core/components/fields/FieldHeader.js +18 -5
  13. package/dist/core/components/fields/FieldLayout.d.ts +3 -1
  14. package/dist/core/components/fields/FieldLayout.js +17 -4
  15. package/dist/core/components/fields/FieldSize.d.ts +1 -0
  16. package/dist/core/components/fields/FieldSize.js +2 -0
  17. package/dist/core/components/fields/FieldsPanel.js +5 -4
  18. package/dist/core/components/fields/RichTextEditor.d.ts +2 -3
  19. package/dist/core/components/fields/RichTextEditor.js +13 -10
  20. package/dist/core/components/fields/RichTextField.d.ts +1 -2
  21. package/dist/core/components/fields/RichTextField.js +4 -16
  22. package/dist/core/components/fields/TextField.d.ts +3 -2
  23. package/dist/core/components/fields/TextField.js +8 -7
  24. package/dist/core/components/fields/TimestampField.d.ts +3 -1
  25. package/dist/core/components/fields/TimestampField.js +2 -2
  26. package/dist/core/components/fields/index.d.ts +2 -0
  27. package/dist/core/components/fields/index.js +2 -0
  28. package/dist/core/components/fields/richtext/Theme.d.ts +1 -2
  29. package/dist/core/components/fields/richtext/Theme.js +2 -2
  30. package/dist/core/components/interaction/Button.js +3 -3
  31. package/dist/core/components/interaction/Combobox.d.ts +8 -1
  32. package/dist/core/components/interaction/Combobox.js +39 -12
  33. package/dist/core/components/interaction/IconButton.d.ts +2 -2
  34. package/dist/core/components/interaction/IconButton.js +2 -1
  35. package/dist/core/components/interaction/QuickEditor.d.ts +11 -0
  36. package/dist/core/components/interaction/QuickEditor.js +33 -0
  37. package/dist/core/components/interaction/QuickInput.js +1 -1
  38. package/dist/core/components/interaction/QuickPicker.js +5 -3
  39. package/dist/core/components/interaction/SegmentedButton.d.ts +3 -1
  40. package/dist/core/components/interaction/SegmentedButton.js +4 -1
  41. package/dist/core/components/interaction/SideSheet.js +1 -1
  42. package/dist/core/components/interaction/index.d.ts +1 -0
  43. package/dist/core/components/interaction/index.js +1 -0
  44. package/dist/core/components/visuals/Icon.d.ts +2 -2
  45. package/dist/core/components/visuals/Icon.js +5 -0
  46. package/dist/core/domain/BlockConfiguration.d.ts +15 -3
  47. package/dist/core/domain/BlockConfiguration.js +94 -27
  48. package/dist/page/components/config/BlockConfig.js +1 -1
  49. package/dist/page/components/config/BlockConfigEditor.js +26 -19
  50. package/dist/page/components/config/BlockPreview.d.ts +1 -1
  51. package/dist/page/components/config/BlockPreview.js +24 -18
  52. package/dist/page/components/config/ListPanelEditor.d.ts +4 -2
  53. package/dist/page/components/config/ListPanelEditor.js +78 -2
  54. package/dist/page/components/config/MessagePanelEditor.d.ts +4 -2
  55. package/dist/page/components/config/MessagePanelEditor.js +6 -2
  56. package/dist/page/components/config/VisualPanelEditor.d.ts +4 -2
  57. package/dist/page/components/config/VisualPanelEditor.js +65 -2
  58. package/dist/styles/index.css +303 -143
  59. package/dist/styles/tailwind.js +2 -0
  60. package/package.json +2 -2
  61. package/dist/page/components/config/ListLayoutPicker.d.ts +0 -6
  62. package/dist/page/components/config/ListLayoutPicker.js +0 -13
@@ -20,7 +20,7 @@ function BlockConfig({ className, block: blockOrSectionBlock }) {
20
20
  }
21
21
  // render
22
22
  const valid = config.every(field => field.valid);
23
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(core_1.StatusChip, { className: className, variant: valid ? 'success' : 'error', onClick: () => setConfiguration(block.getConfiguration()), children: "Configure" }), process.env.NEXT_PUBLIC_EDITOR_BLOCK_CONFIG === 'experimental'
23
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(core_1.StatusChip, { className: className, variant: valid ? 'success' : 'error', onClick: () => setConfiguration(blockOrSectionBlock.getConfiguration()), children: "Configure" }), process.env.NEXT_PUBLIC_EDITOR_BLOCK_CONFIG === 'experimental'
24
24
  ?
25
25
  (0, jsx_runtime_1.jsx)(BlockConfigEditor_1.BlockConfigEditor, { configuration: configuration, onClose: () => setConfiguration(undefined) })
26
26
  :
@@ -7,6 +7,7 @@ const react_1 = require("motion/react");
7
7
  const react_2 = require("react");
8
8
  const rxjs_1 = require("rxjs");
9
9
  const core_1 = require("../../../core");
10
+ const FieldHeader_1 = require("../../../core/components/fields/FieldHeader");
10
11
  const hooks_1 = require("../../hooks");
11
12
  const BlockPreview_1 = require("./BlockPreview");
12
13
  // editor
@@ -60,43 +61,49 @@ function BlockConfigEditor({ configuration, onClose }) {
60
61
  }
61
62
  };
62
63
  // render
63
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(core_1.SideSheet, { size: "xs", title: "Block Configuration", backdrop: "glass", open: !!configuration, onSave: onSave, onClose: onClose, disableDismiss: modified, disableSave: !modified || !valid, customActions: (0, jsx_runtime_1.jsx)(core_1.Button, { variant: "secondary", size: "sm", disabled: configuration === null || configuration === void 0 ? void 0 : configuration.isConfigInDefault, onClick: () => configuration === null || configuration === void 0 ? void 0 : configuration.reset(), children: "Reset to Default" }), children: (0, jsx_runtime_1.jsxs)("div", { className: "h-full flex flex-col gap-l9 p-l8", children: [(0, jsx_runtime_1.jsxs)("section", { className: "flex items-center gap-l4", children: [(0, jsx_runtime_1.jsx)("span", { className: "label-sm text-content-primary flex-1", children: "Layout" }), ((_a = configuration === null || configuration === void 0 ? void 0 : configuration.slotOptions) !== null && _a !== void 0 ? _a : []).length > 1 &&
64
- (0, jsx_runtime_1.jsx)(core_1.Button, { variant: "secondary", size: "sm", iconLeft: "ArrowLeftRight", onClick: () => configuration === null || configuration === void 0 ? void 0 : configuration.gotToNextSlot(), children: "Rearrange" }), (0, jsx_runtime_1.jsx)(core_1.Button, { variant: "secondary", size: "sm", iconLeft: "LayoutTemplate", onClick: onChangePanelLayout, children: "Change" })] }), blocksFields.length > 0 &&
65
- (0, jsx_runtime_1.jsx)("section", { className: "grid grid-cols-2 auto-rows-auto items-start gap-l6", children: (0, jsx_runtime_1.jsx)(core_1.FieldErrorController, { children: blocksFields.map(field => (0, jsx_runtime_1.jsx)(core_1.FieldEditor, { className: "col-span-2", field: field, variant: "wide" }, field.id)) }) }), (0, jsx_runtime_1.jsx)(core_1.Tabs, { items: blockViews, selectedItem: blockView, onSelect: setBlockView }), (0, jsx_runtime_1.jsx)("section", { className: "stacked p-l6 bg-surface1 rounded-md", children: (0, jsx_runtime_1.jsx)(react_1.AnimatePresence, { children: (0, jsx_runtime_1.jsx)(core_1.Animate, { effect: "fade", present: true, children: (0, jsx_runtime_1.jsx)(BlockPreview_1.BlockPreview, { variant: blockView, configuration: configuration }) }, blockView) }) }), settingsFields.length > 0 &&
66
- (0, jsx_runtime_1.jsx)("section", { className: "grid grid-cols-2 auto-rows-auto items-start gap-l6", children: (0, jsx_runtime_1.jsx)(core_1.FieldErrorController, { children: settingsFields.map(field => (0, jsx_runtime_1.jsx)(core_1.FieldEditor, { className: "col-span-2", field: field, variant: "wide" }, field.id)) }) })] }) }), (0, jsx_runtime_1.jsx)(core_1.QuickPicker, { ref: panelLayoutPickerRef, variant: "card", title: "Pick Block Layout", description: "Select an available layout for this block.", renderItem: (item) => renderPanelLayoutItem(item) })] }));
64
+ const { options: slotOptions = [], currentIndex: slotIndex = 0 } = (_a = configuration === null || configuration === void 0 ? void 0 : configuration.slotState) !== null && _a !== void 0 ? _a : {};
65
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(core_1.SideSheet, { title: "Block Configuration", size: "xs", backdrop: "glass", open: !!configuration, onSave: onSave, onClose: onClose, disableDismiss: modified, disableSave: !modified || !valid, customActions: (0, jsx_runtime_1.jsx)(core_1.Button, { variant: "secondary", size: "sm", disabled: configuration === null || configuration === void 0 ? void 0 : configuration.isConfigInDefault, onClick: () => configuration === null || configuration === void 0 ? void 0 : configuration.reset(), children: "Reset to Default" }), children: (0, jsx_runtime_1.jsxs)("div", { className: "h-full flex flex-col gap-l6", children: [(0, jsx_runtime_1.jsxs)("section", { className: "grid grid-cols-2 gap-x-l5 gap-y-l4", children: [blocksFields.length > 0 &&
66
+ (0, jsx_runtime_1.jsx)(core_1.FieldErrorController, { children: blocksFields.map(field => (0, jsx_runtime_1.jsx)(core_1.FieldEditor, { className: "col-span-full", field: field, size: "xs" }, field.id)) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-l2", children: [(0, jsx_runtime_1.jsx)(FieldHeader_1.FieldHeader, { label: "Layout", size: "xs" }), (0, jsx_runtime_1.jsx)(core_1.Button, { variant: "secondary", size: "xs", iconLeft: "LayoutTemplate", onClick: onChangePanelLayout, children: "Change" })] }), slotOptions.length > 1 &&
67
+ (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-l2", children: [(0, jsx_runtime_1.jsx)(FieldHeader_1.FieldHeader, { label: "Arrangement", size: "xs" }), slotOptions.length === 2
68
+ ?
69
+ (0, jsx_runtime_1.jsx)(core_1.Button, { variant: "secondary", size: "xs", iconLeft: "ArrowLeftRight", onClick: () => configuration === null || configuration === void 0 ? void 0 : configuration.gotToNextSlot(), children: "Swap" })
70
+ :
71
+ (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-l4", children: [(0, jsx_runtime_1.jsx)(core_1.Button, { variant: "secondary", size: "xs", onClick: () => configuration === null || configuration === void 0 ? void 0 : configuration.gotToPreviousSlot(), children: (0, jsx_runtime_1.jsx)(core_1.Icon, { variant: "ArrowLeft", size: { size: 16, strokeWidth: 1, absoluteStrokeWidth: true } }) }), (0, jsx_runtime_1.jsxs)("span", { className: "label-xs", children: [slotIndex + 1, " of ", slotOptions.length] }), (0, jsx_runtime_1.jsx)(core_1.Button, { variant: "secondary", size: "xs", onClick: () => configuration === null || configuration === void 0 ? void 0 : configuration.gotToNextSlot(), children: (0, jsx_runtime_1.jsx)(core_1.Icon, { variant: "ArrowRight", size: { size: 16, strokeWidth: 1, absoluteStrokeWidth: true } }) })] })] })] }), (0, jsx_runtime_1.jsx)(core_1.Tabs, { items: blockViews, selectedItem: blockView, onSelect: setBlockView }), (0, jsx_runtime_1.jsx)(react_1.motion.section, { className: "p-l6 bg-surface-placeholder-raised rounded-md", layout: true, children: configuration &&
72
+ (0, jsx_runtime_1.jsx)(BlockPreview_1.BlockPreview, { variant: blockView, configuration: configuration }) }), settingsFields.length > 0 &&
73
+ (0, jsx_runtime_1.jsx)("section", { className: "grid grid-cols-2 auto-rows-auto items-start gap-l6", children: (0, jsx_runtime_1.jsx)(core_1.FieldErrorController, { children: settingsFields.map(field => (0, jsx_runtime_1.jsx)(core_1.FieldEditor, { className: "col-span-2", field: field, size: "xs" }, field.id)) }) })] }) }), (0, jsx_runtime_1.jsx)(core_1.QuickPicker, { ref: panelLayoutPickerRef, variant: "card", title: "Pick Block Layout", description: "Select an available layout for this block.", renderItem: (item) => renderPanelLayoutItem(item) })] }));
67
74
  }
68
75
  function renderPanelLayoutItem(item) {
69
76
  switch (item.id) {
70
77
  case 'solo':
71
- return ((0, jsx_runtime_1.jsx)("div", { className: "p-l6 size-full", children: (0, jsx_runtime_1.jsx)("div", { className: "size-full bg-surface2" }) }));
78
+ return ((0, jsx_runtime_1.jsx)("div", { className: "p-l4 size-full", children: (0, jsx_runtime_1.jsx)("div", { className: "size-full bg-surface-placeholder" }) }));
72
79
  case 'stack.v':
73
- return ((0, jsx_runtime_1.jsxs)("div", { className: "p-l6 flex flex-col gap-l2 h-full", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface2" }), (0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface2" })] }));
80
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "flex h-full flex-col p-l4 gap-l1", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface-placeholder rounded-[2px]" }), (0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface-placeholder rounded-[2px]" })] }));
74
81
  case 'stack.h':
75
- return ((0, jsx_runtime_1.jsxs)("div", { className: "p-l6 flex gap-l2 h-full", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface2" }), (0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface2" })] }));
82
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "flex h-full p-l4 gap-l1", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface-placeholder rounded-[2px]" }), (0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface-placeholder rounded-[2px]" })] }));
76
83
  case 'brick.v':
77
- return ((0, jsx_runtime_1.jsxs)("div", { className: "p-l6 flex flex-col gap-l2 h-full", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface2" }), (0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface2" }), (0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface2" })] }));
84
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "flex h-full flex-col p-l4 gap-l1", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface-placeholder rounded-[2px]" }), (0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface-placeholder rounded-[2px]" }), (0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface-placeholder rounded-[2px]" })] }));
78
85
  case 'brick.t':
79
- return ((0, jsx_runtime_1.jsxs)("div", { className: "p-l6 flex flex-col gap-l2 h-full", children: [(0, jsx_runtime_1.jsx)("div", { className: "h-[20px] w-full bg-surface2" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex gap-l2 flex-1", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface2" }), (0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface2" })] })] }));
86
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "flex h-full flex-col p-l4 gap-l1", children: [(0, jsx_runtime_1.jsx)("div", { className: "w-full h-[20px] bg-surface-placeholder rounded-[2px]" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-1 gap-l1", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface-placeholder rounded-[2px]r" }), (0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface-placeholder rounded-[2px]" })] })] }));
80
87
  case 'brick.r':
81
- return ((0, jsx_runtime_1.jsxs)("div", { className: "p-l6 flex gap-l2 h-full", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col flex-1 gap-l2 h-full", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface2" }), (0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface2" })] }), (0, jsx_runtime_1.jsx)("div", { className: "h-full w-[30px] bg-surface2" })] }));
88
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "flex h-full p-l4 gap-l1", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex h-full flex-1 flex-col gap-l1", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface-placeholder rounded-[2px]" }), (0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface-placeholder rounded-[2px]" })] }), (0, jsx_runtime_1.jsx)("div", { className: "h-full w-[30px] bg-surface-placeholder rounded-[2px]" })] }));
82
89
  case 'brick.b':
83
- return ((0, jsx_runtime_1.jsxs)("div", { className: "p-l6 flex flex-col gap-l2 h-full", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex gap-l2 flex-1", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface2" }), (0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface2" })] }), (0, jsx_runtime_1.jsx)("div", { className: "h-[20px] w-full bg-surface2" })] }));
90
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "flex h-full flex-col p-l4 gap-l1", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex flex-1 gap-l1", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface-placeholder rounded-[2px]" }), (0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface-placeholder rounded-[2px]" })] }), (0, jsx_runtime_1.jsx)("div", { className: "w-full h-[20px] bg-surface-placeholder rounded-[2px]" })] }));
84
91
  case 'brick.l':
85
- return ((0, jsx_runtime_1.jsxs)("div", { className: "p-l6 flex gap-l2 h-full", children: [(0, jsx_runtime_1.jsx)("div", { className: "h-full w-[30px] bg-surface2" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col flex-1 gap-l2 h-full", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface2" }), (0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface2" })] })] }));
92
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "flex h-full p-l4 gap-l1", children: [(0, jsx_runtime_1.jsx)("div", { className: "h-full w-[30px] bg-surface-placeholder rounded-[2px]" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex h-full flex-1 flex-col gap-l1", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface-placeholder rounded-[2px]" }), (0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface-placeholder rounded-[2px]" })] })] }));
86
93
  case 'nested':
87
- return ((0, jsx_runtime_1.jsx)("div", { className: "p-l6 size-full", children: (0, jsx_runtime_1.jsx)("div", { className: "px-l5 py-l3 flex h-full bg-surface2", children: (0, jsx_runtime_1.jsx)("div", { className: "bg-surface1" }) }) }));
94
+ return ((0, jsx_runtime_1.jsx)("div", { className: "p-l4 size-full", children: (0, jsx_runtime_1.jsx)("div", { className: "flex h-full px-l5 py-l2 bg-surface-placeholder rounded-[2px]", children: (0, jsx_runtime_1.jsx)("div", { className: "bg-surface-placeholder-raised rounded-[2px]" }) }) }));
88
95
  case 'nested.v':
89
- return ((0, jsx_runtime_1.jsx)("div", { className: "p-l6 w-full h-full", children: (0, jsx_runtime_1.jsxs)("div", { className: "px-l5 py-l3 flex flex-col gap-l2 h-full bg-surface2", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface1" }), (0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface1" })] }) }));
96
+ return ((0, jsx_runtime_1.jsx)("div", { className: "h-full w-full p-l4", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex h-full flex-col px-l4 py-l2 gap-l1 bg-surface-placeholder rounded-[2px]", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface-placeholder-raised rounded-[2px]" }), (0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface-placeholder-raised rounded-[2px]" })] }) }));
90
97
  case 'nested.h':
91
- return ((0, jsx_runtime_1.jsx)("div", { className: "p-l6 w-full h-full", children: (0, jsx_runtime_1.jsxs)("div", { className: "px-l5 py-l3 flex gap-l2 h-full bg-surface2", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface1" }), (0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface1" })] }) }));
98
+ return ((0, jsx_runtime_1.jsx)("div", { className: "h-full w-full p-l4", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex h-full px-l4 py-l3 gap-l1 bg-surface-placeholder rounded-[2px]", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface-placeholder-raised rounded-[2px]" }), (0, jsx_runtime_1.jsx)("div", { className: "flex-1 bg-surface-placeholder-raised rounded-[2px]" })] }) }));
92
99
  case 'nested.t':
93
- return ((0, jsx_runtime_1.jsxs)("div", { className: "p-l6 flex flex-col gap-l2 h-full", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex-1 p-l2 bg-surface2", children: (0, jsx_runtime_1.jsx)("div", { className: "h-full w-7/12 bg-surface1" }) }), (0, jsx_runtime_1.jsx)("div", { className: "flex-1 p-l2 bg-surface2" })] }));
100
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "flex h-full flex-col p-l4 gap-l1", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex-1 p-l2 bg-surface-placeholder rounded-[2px]", children: (0, jsx_runtime_1.jsx)("div", { className: "h-full w-7/12 bg-surface-placeholder-raised rounded-[2px]" }) }), (0, jsx_runtime_1.jsx)("div", { className: "flex-1 p-l2 bg-surface-placeholder rounded-[2px]" })] }));
94
101
  case 'nested.r':
95
- return ((0, jsx_runtime_1.jsxs)("div", { className: "p-l6 flex gap-l2 h-full", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex-1 p-l2 bg-surface2" }), (0, jsx_runtime_1.jsx)("div", { className: "flex-1 flex flex-col p-l2 bg-surface2", children: (0, jsx_runtime_1.jsx)("div", { className: "h-[60%] w-full bg-surface1" }) })] }));
102
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "flex h-full p-l4 gap-l1", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex-1 p-l2 bg-surface-placeholder rounded-[2px]" }), (0, jsx_runtime_1.jsx)("div", { className: "flex flex-1 flex-col p-l2 bg-surface-placeholder rounded-[2px]", children: (0, jsx_runtime_1.jsx)("div", { className: "w-full h-[60%] bg-surface-placeholder-raised rounded-[2px]" }) })] }));
96
103
  case 'nested.b':
97
- return ((0, jsx_runtime_1.jsxs)("div", { className: "p-l6 flex flex-col gap-l2 h-full", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex-1 p-l2 bg-surface2" }), (0, jsx_runtime_1.jsx)("div", { className: "flex-1 p-l2 bg-surface2", children: (0, jsx_runtime_1.jsx)("div", { className: "h-full w-7/12 bg-surface1" }) })] }));
104
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "flex h-full flex-col p-l4 gap-l1", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex-1 p-l2 bg-surface-placeholder rounded-[2px]" }), (0, jsx_runtime_1.jsx)("div", { className: "flex-1 p-l2 bg-surface-placeholder rounded-[2px]", children: (0, jsx_runtime_1.jsx)("div", { className: "h-full w-7/12 bg-surface-placeholder-raised rounded-[2px]" }) })] }));
98
105
  case 'nested.l':
99
- return ((0, jsx_runtime_1.jsxs)("div", { className: "p-l6 flex gap-l2 h-full", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex-1 flex flex-col p-l2 bg-surface2", children: (0, jsx_runtime_1.jsx)("div", { className: "h-[60%] w-full bg-surface1" }) }), (0, jsx_runtime_1.jsx)("div", { className: "flex-1 p-l2 bg-surface2" })] }));
106
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "flex h-full p-l4 gap-l1", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex flex-1 flex-col p-l2 bg-surface-placeholder rounded-[2px]", children: (0, jsx_runtime_1.jsx)("div", { className: "w-full h-[60%] bg-surface-placeholder-raised rounded-[2px]" }) }), (0, jsx_runtime_1.jsx)("div", { className: "flex-1 p-l2 bg-surface-placeholder rounded-[2px]" })] }));
100
107
  default:
101
108
  return ((0, jsx_runtime_1.jsx)("div", { children: item.id }));
102
109
  }
@@ -5,6 +5,6 @@ export declare namespace BlockPreview {
5
5
  type Props = {
6
6
  className?: string;
7
7
  variant: Variant;
8
- configuration?: BlockConfiguration;
8
+ configuration: BlockConfiguration;
9
9
  };
10
10
  }
@@ -20,43 +20,49 @@ const funnel_core_1 = require("@nascentdigital/funnel-core");
20
20
  const classnames_1 = __importDefault(require("classnames"));
21
21
  const react_1 = require("react");
22
22
  const core_1 = require("../../../core");
23
+ const ListPanelEditor_1 = require("./ListPanelEditor");
24
+ const MessagePanelEditor_1 = require("./MessagePanelEditor");
25
+ const VisualPanelEditor_1 = require("./VisualPanelEditor");
26
+ const react_2 = require("motion/react");
23
27
  // component
24
28
  function BlockPreview({ className, variant, configuration }) {
25
- // determine active panels
26
- const { layout } = configuration !== null && configuration !== void 0 ? configuration : {};
29
+ // bind props + state + refs
30
+ const { layout } = configuration;
31
+ const [editingPanel, setEditingPanel] = (0, react_1.useState)();
32
+ const previewRef = (0, react_1.useRef)(null);
27
33
  // sync configuration
28
34
  (0, core_1.useBlockConfiguration)(configuration);
29
35
  // helpers
30
36
  const onPanelClick = (panel) => {
31
- console.debug('[BlockPreview] opening panel editor', panel);
37
+ setEditingPanel(panel.type);
32
38
  };
33
39
  // render
34
40
  const tight = variant === 'mobile'
35
41
  ? layout === null || layout === void 0 ? void 0 : layout.tight.mobile
36
42
  : layout === null || layout === void 0 ? void 0 : layout.tight.desktop;
37
- return ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(className, 'w-full flex justify-center'), children: (0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)('bg-surface2 rounded-xs', {
38
- 'min-h-[100px]': !layout,
39
- 'w-[120px]': variant === 'desktop',
40
- 'w-[64px]': variant === 'mobile',
41
- 'pb-l4': tight === 'above',
42
- 'pt-l4': tight === 'below',
43
- 'py-l4': tight === 'none'
44
- }), children: renderLayout({ variant, layout, onPanelClick }) }) }));
43
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)(react_2.motion.div, { ref: previewRef, className: (0, classnames_1.default)(className, 'w-full flex justify-center'), layout: true, children: [(0, jsx_runtime_1.jsx)(react_2.motion.div, { className: (0, classnames_1.default)('bg-surface2 rounded-xs', {
44
+ 'min-h-[100px]': !layout,
45
+ 'w-[120px]': variant === 'desktop',
46
+ 'w-[64px]': variant === 'mobile',
47
+ 'pb-l4': tight === 'above',
48
+ 'pt-l4': tight === 'below',
49
+ 'py-l4': tight === 'none'
50
+ }), layoutRoot: true, layout: true, children: renderLayout({ variant, layout, onPanelClick }) }), (0, jsx_runtime_1.jsx)(MessagePanelEditor_1.MessagePanelEditor, { open: editingPanel === 'message', onClose: () => setEditingPanel(panel => panel === 'message' ? undefined : panel), anchor: previewRef.current, configuration: configuration }), (0, jsx_runtime_1.jsx)(ListPanelEditor_1.ListPanelEditor, { open: editingPanel === 'list', onClose: () => setEditingPanel(panel => panel === 'list' ? undefined : panel), anchor: previewRef.current, configuration: configuration }), (0, jsx_runtime_1.jsx)(VisualPanelEditor_1.VisualPanelEditor, { open: editingPanel === 'visual', onClose: () => setEditingPanel(panel => panel === 'visual' ? undefined : panel), anchor: previewRef.current, configuration: configuration })] }) }));
45
51
  }
46
52
  // helpers
47
53
  var Skeleton;
48
54
  (function (Skeleton) {
49
55
  function HeadlinePart({ className, size }) {
50
- return ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(className, 'bg-ix-primary rounded-xxs overflow-hidden', {
56
+ return ((0, jsx_runtime_1.jsx)(react_2.motion.div, { className: (0, classnames_1.default)(className, 'bg-ix-primary rounded-xxs overflow-hidden', {
51
57
  'h-6 ': size === 'sm',
52
58
  'h-8': size === 'md'
53
- }) }));
59
+ }), layout: true }));
54
60
  }
55
61
  Skeleton.HeadlinePart = HeadlinePart;
56
62
  function CaptionPart({ className, size }) {
57
- return ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(className, 'h-4 bg-draft/tint3 rounded-px overflow-hidden', {
63
+ return ((0, jsx_runtime_1.jsx)(react_2.motion.div, { className: (0, classnames_1.default)(className, 'h-4 bg-draft/tint3 rounded-px overflow-hidden', {
58
64
  '': size === 'sm'
59
- }) }));
65
+ }), layout: true }));
60
66
  }
61
67
  Skeleton.CaptionPart = CaptionPart;
62
68
  function MediaPart({ className, aspect }) {
@@ -95,7 +101,7 @@ function renderLayout({ className, variant, layout, onPanelClick }) {
95
101
  }
96
102
  // render root layout
97
103
  const { type, items } = layout.root;
98
- return ((0, jsx_runtime_1.jsx)("div", { className: getContainerClasses({ className, variant, siblingCount: 1, item: layout.root }), children: items.map((item, parentOffset) => (0, jsx_runtime_1.jsx)(react_1.Fragment, { children: renderItem({
104
+ return ((0, jsx_runtime_1.jsx)(react_2.motion.div, { className: getContainerClasses({ className, variant, siblingCount: 1, item: layout.root }), layout: true, children: items.map((item, parentOffset) => (0, jsx_runtime_1.jsx)(react_1.Fragment, { children: renderItem({
99
105
  className: (0, classnames_1.default)({
100
106
  'flex-1': type === 'row' && variant !== 'mobile'
101
107
  }),
@@ -119,7 +125,7 @@ function renderItem({ className, parent, parentNested, siblingCount, variant, it
119
125
  case 'row':
120
126
  case 'column':
121
127
  case 'stack':
122
- return ((0, jsx_runtime_1.jsx)("div", { className: getContainerClasses({ className, parent, siblingCount, variant, item }), children: item.items.map((item, parentOffset, items) => (0, jsx_runtime_1.jsx)(react_1.Fragment, { children: renderItem({
128
+ return ((0, jsx_runtime_1.jsx)(react_2.motion.div, { className: getContainerClasses({ className, parent, siblingCount, variant, item }), layout: true, children: item.items.map((item, parentOffset, items) => (0, jsx_runtime_1.jsx)(react_1.Fragment, { children: renderItem({
123
129
  className: (0, classnames_1.default)({
124
130
  'flex-1': itemType === 'row'
125
131
  }),
@@ -437,7 +443,7 @@ function getPanelClasses({ className, variant, parent, parentNested, item: { ali
437
443
  function EditablePanel(_a) {
438
444
  var { panelClassName, children } = _a, args = __rest(_a, ["panelClassName", "children"]);
439
445
  // render
440
- return ((0, jsx_runtime_1.jsx)("div", { className: getPanelWrapClasses(args), children: (0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(panelClassName, 'relative'), children: [children, (0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)('group absolute inset-0 z-overlay cursor-pointer interpolate', 'bg-surface1 border border-solid, border-ix-primary rounded-xxs overflow-hidden', 'opacity-none hover:opacity-full'), onClick: () => args.onPanelClick(args.item), children: (0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)('w-full h-full interpolate', 'flex flex-col justify-center items-center gap-l6', 'text-ix-primary group-hover:bg-ix-primary/tint1 group-active:bg-ix-primary/tint3'), children: (0, jsx_runtime_1.jsx)("span", { className: "label-xs label-strong", children: "Edit" }) }) })] }) }));
446
+ return ((0, jsx_runtime_1.jsx)(react_2.motion.div, { className: getPanelWrapClasses(args), layout: true, layoutId: args.item.key, children: (0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(panelClassName, 'relative'), children: [children, (0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)('group absolute inset-0 z-overlay cursor-pointer interpolate', 'bg-surface1 border border-solid, border-ix-primary rounded-xxs overflow-hidden', 'opacity-none hover:opacity-full'), onClick: () => args.onPanelClick(args.item), children: (0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)('w-full h-full interpolate', 'flex flex-col justify-center items-center gap-l6', 'text-ix-primary group-hover:bg-ix-primary/tint1 group-active:bg-ix-primary/tint3'), children: (0, jsx_runtime_1.jsx)("span", { className: "label-xs label-strong", children: "Edit" }) }) })] }) }, args.item.key));
441
447
  }
442
448
  // TODO: scrap this
443
449
  class ItemPosition {
@@ -1,6 +1,8 @@
1
- export declare function ListPanelEditor({ className }: ListPanelEditor.Props): import("react/jsx-runtime").JSX.Element;
1
+ import { BlockConfiguration, Popup } from '../../../core';
2
+ export declare function ListPanelEditor({ className, anchor, open, onClose, configuration }: ListPanelEditor.Props): import("react/jsx-runtime").JSX.Element;
2
3
  export declare namespace ListPanelEditor {
3
- type Props = {
4
+ type Props = Pick<Popup.Props, 'open' | 'onClose' | 'anchor'> & {
4
5
  className?: string;
6
+ configuration: BlockConfiguration;
5
7
  };
6
8
  }
@@ -1,13 +1,89 @@
1
1
  "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
2
13
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
15
  };
5
16
  Object.defineProperty(exports, "__esModule", { value: true });
6
17
  exports.ListPanelEditor = ListPanelEditor;
7
18
  const jsx_runtime_1 = require("react/jsx-runtime");
19
+ const funnel_core_1 = require("@nascentdigital/funnel-core");
8
20
  const classnames_1 = __importDefault(require("classnames"));
21
+ const react_1 = require("react");
22
+ const core_1 = require("../../../core");
9
23
  // component
10
- function ListPanelEditor({ className }) {
24
+ function ListPanelEditor({ className, anchor, open, onClose, configuration }) {
25
+ // bind props + refs
26
+ const _a = configuration.listFields, { layout: layoutField } = _a, listFields = __rest(_a, ["layout"]);
27
+ const layoutPickerRef = (0, react_1.useRef)(null);
28
+ // helpers
29
+ const onChangeLayout = async (e) => {
30
+ var _a;
31
+ // skip if there's no layout field (shouldn't happen)
32
+ const layoutSchema = layoutField === null || layoutField === void 0 ? void 0 : layoutField.schema;
33
+ if (!layoutField || !layoutSchema) {
34
+ return;
35
+ }
36
+ // pick new layout
37
+ const { value: layoutData } = layoutField;
38
+ const selectedLayout = await ((_a = layoutPickerRef.current) === null || _a === void 0 ? void 0 : _a.open({
39
+ anchor: e.currentTarget,
40
+ anchorOffset: 4,
41
+ placement: 'top',
42
+ items: Object.entries(layoutSchema.options).map(([layout, option]) => ({
43
+ id: layout,
44
+ label: option.name
45
+ })),
46
+ selectedItem: layoutData === null || layoutData === void 0 ? void 0 : layoutData.value
47
+ }));
48
+ // update if something was picked
49
+ if (selectedLayout) {
50
+ layoutField.value = funnel_core_1.Schema.EnumField.Value.toData(selectedLayout);
51
+ }
52
+ };
11
53
  // render
12
- return ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(className), children: "ListPanelEditor" }));
54
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(core_1.QuickEditor, { className: (0, classnames_1.default)(className), title: "List Configuration", tip: "Lorem ipsum.", anchor: anchor, placement: "left", anchorOffset: 4, viewportPadding: 4, open: open, onClose: onClose, size: "sm", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-l4", children: [(0, jsx_runtime_1.jsx)(core_1.Button, { variant: "secondary", size: "xs", iconLeft: "LayoutTemplate", onClick: onChangeLayout, children: "Change" }), Object.values(listFields)
55
+ .filter(funnel_core_1.Value.isDefined)
56
+ .map(field => (0, jsx_runtime_1.jsx)(core_1.FieldEditor, { field: field, size: "xs" }, field.id))] }) }), (0, jsx_runtime_1.jsx)(core_1.QuickPicker, { ref: layoutPickerRef, variant: "card", title: "Pick List Layout", description: "Select an available layout for this list.", renderItem: (item) => renderListLayoutItem(item) })] }));
57
+ }
58
+ function renderListLayoutItem(item) {
59
+ // panel
60
+ const panel = (className = 'w-full') => ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)('bg-surface-placeholder rounded-[3px]', className) }));
61
+ // get content
62
+ const panelClassName = 'w-full h-full';
63
+ const panelPaddedX = 'px-10';
64
+ const panelPaddedY = 'py-10';
65
+ const panelPadded = (0, classnames_1.default)(panelPaddedX, panelPaddedY);
66
+ let content;
67
+ switch (item.id) {
68
+ case 'grid':
69
+ content = ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(panelClassName, panelPadded, 'grid grid-cols-3 auto-cols-fr gap-x-l3 gap-y-l2 '), children: [panel(), panel(), panel(), panel(), panel()] }));
70
+ break;
71
+ case 'verticalStack':
72
+ content = ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(panelClassName, panelPadded, 'grid grid-cols-1 auto-rows-fr gap-y-l2 '), children: [panel(), panel(), panel()] }));
73
+ break;
74
+ case 'horizontalStack':
75
+ content = ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(panelClassName, panelPadded, 'grid grid-rows-1 auto-cols-fr grid-flow-col gap-x-l3 '), children: [panel(), panel(), panel()] }));
76
+ break;
77
+ case 'masonry':
78
+ content = ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(panelClassName, panelPaddedX, 'grid grid-cols-3 grid-flow-col gap-x-l3 pt-10'), children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-l2", children: [panel('h-l5'), panel('h-l6'), panel('h-l5')] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-l2", children: [panel('h-22'), panel('h-l6')] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-l2", children: [panel('h-l4'), panel('h-l7'), panel('h-l5')] })] }));
79
+ break;
80
+ case 'bento':
81
+ content = ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(panelClassName, panelPadded, 'grid auto-rows-auto auto-cols-auto gap-l3'), children: [panel('w-20 row-start-1 row-span-2 col-start-1'), panel('w-28 row-start-1 col-start-2'), panel('w-18 row-start-2 col-start-2')] }));
82
+ break;
83
+ default:
84
+ content = ((0, jsx_runtime_1.jsx)("div", { children: item.id }));
85
+ break;
86
+ }
87
+ // render item in frame
88
+ return ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)('w-full h-full flex justify-center items-center'), children: content }));
13
89
  }
@@ -1,6 +1,8 @@
1
- export declare function MessagePanelEditor({ className }: MessagePanelEditor.Props): import("react/jsx-runtime").JSX.Element;
1
+ import { BlockConfiguration, Popup } from '../../../core';
2
+ export declare function MessagePanelEditor({ className, anchor, open, onClose, configuration }: MessagePanelEditor.Props): import("react/jsx-runtime").JSX.Element;
2
3
  export declare namespace MessagePanelEditor {
3
- type Props = {
4
+ type Props = Pick<Popup.Props, 'open' | 'onClose' | 'anchor'> & {
4
5
  className?: string;
6
+ configuration: BlockConfiguration;
5
7
  };
6
8
  }
@@ -5,9 +5,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.MessagePanelEditor = MessagePanelEditor;
7
7
  const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const funnel_core_1 = require("@nascentdigital/funnel-core");
8
9
  const classnames_1 = __importDefault(require("classnames"));
10
+ const core_1 = require("../../../core");
9
11
  // component
10
- function MessagePanelEditor({ className }) {
12
+ function MessagePanelEditor({ className, anchor, open, onClose, configuration }) {
11
13
  // render
12
- return ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(className), children: "MessagePanelEditor" }));
14
+ return ((0, jsx_runtime_1.jsx)(core_1.QuickEditor, { className: (0, classnames_1.default)(className), title: "Message Configuration", tip: "Medium and Large are relative to this block's text area, not the page width.", anchor: anchor, placement: "left", anchorOffset: 4, viewportPadding: 4, open: open, onClose: onClose, size: "sm", children: (0, jsx_runtime_1.jsx)("div", { className: "flex flex-col gap-l4", children: Object.values(configuration.messageFields)
15
+ .filter(funnel_core_1.Value.isDefined)
16
+ .map(field => (0, jsx_runtime_1.jsx)(core_1.FieldEditor, { field: field, size: "xs" }, field.id)) }) }));
13
17
  }
@@ -1,6 +1,8 @@
1
- export declare function VisualPanelEditor({ className }: VisualPanelEditor.Props): import("react/jsx-runtime").JSX.Element;
1
+ import { BlockConfiguration, Popup } from '../../../core';
2
+ export declare function VisualPanelEditor({ className, anchor, open, onClose, configuration }: VisualPanelEditor.Props): import("react/jsx-runtime").JSX.Element;
2
3
  export declare namespace VisualPanelEditor {
3
- type Props = {
4
+ type Props = Pick<Popup.Props, 'open' | 'onClose' | 'anchor'> & {
4
5
  className?: string;
6
+ configuration: BlockConfiguration;
5
7
  };
6
8
  }
@@ -6,8 +6,71 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.VisualPanelEditor = VisualPanelEditor;
7
7
  const jsx_runtime_1 = require("react/jsx-runtime");
8
8
  const classnames_1 = __importDefault(require("classnames"));
9
+ const funnel_core_1 = require("@nascentdigital/funnel-core");
10
+ const core_1 = require("../../../core");
11
+ const FieldHeader_1 = require("../../../core/components/fields/FieldHeader");
12
+ const framer_motion_1 = require("framer-motion");
9
13
  // component
10
- function VisualPanelEditor({ className }) {
14
+ function VisualPanelEditor({ className, anchor, open, onClose, configuration }) {
15
+ var _a;
16
+ // get fields
17
+ const { visualFields: { aspect: aspectField, anchor: anchorField, width: widthField, horizontalAlign: horizontalAlignField } } = configuration;
18
+ const { value } = (_a = configuration.getFieldData('visual')) !== null && _a !== void 0 ? _a : {};
19
+ const visual = funnel_core_1.Schema.AssetField.LinkedValue.Visual.filter(value)
20
+ ? value
21
+ : undefined;
22
+ // sync config
23
+ (0, core_1.useBlockConfiguration)(configuration);
11
24
  // render
12
- return ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(className), children: "MessagePanelEditor" }));
25
+ return ((0, jsx_runtime_1.jsx)(core_1.QuickEditor, { className: (0, classnames_1.default)(className), title: "Visual Configuration", tip: "Cropping changes how the image appears on your site, not your original file.", anchor: anchor, placement: "left", anchorOffset: 4, viewportPadding: 4, open: open, onClose: onClose, size: "sm", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-l9", children: [(0, jsx_runtime_1.jsxs)("section", { className: "flex flex-col gap-l4", children: [aspectField &&
26
+ (0, jsx_runtime_1.jsx)(core_1.FieldEditor, { field: aspectField, size: "xs" }), anchorField
27
+ ? (0, jsx_runtime_1.jsx)(core_1.FieldEditor, { field: anchorField, size: "xs" })
28
+ :
29
+ (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(FieldHeader_1.FieldHeader, { label: "Anchor", size: "xs" }), (0, jsx_runtime_1.jsx)("p", { className: "label-xs text-content-secondary text-pretty", children: "Your current image size and aspect ratio don't require and anchor (there's no cropping)." })] })] }), visual && renderVisual({
30
+ configuration,
31
+ visual,
32
+ aspectField: aspectField,
33
+ anchorField: anchorField
34
+ })] }) }));
35
+ }
36
+ function renderVisual({ configuration, visual, aspectField, anchorField }) {
37
+ var _a, _b, _c;
38
+ // determine layout info
39
+ const { metadata, name, description } = visual;
40
+ const { dimensions: { width, height } } = metadata;
41
+ const isPortrait = width < height;
42
+ const aspect = (_b = (_a = aspectField === null || aspectField === void 0 ? void 0 : aspectField.value) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 'auto';
43
+ const anchor = (_c = anchorField === null || anchorField === void 0 ? void 0 : anchorField.value) === null || _c === void 0 ? void 0 : _c.value;
44
+ const anchorDirection = anchorField
45
+ ? anchorField.schema.isValidOption('left')
46
+ ? 'x'
47
+ : 'y'
48
+ : undefined;
49
+ // render
50
+ return ((0, jsx_runtime_1.jsx)("section", { className: (0, classnames_1.default)('w-full h-[210px]', 'flex flex-col justify-center items-center', 'bg-background rounded-xs'), children: (0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)('relative bg-destructive', {
51
+ 'h-full max-h-full w-auto': isPortrait,
52
+ 'w-full': !isPortrait
53
+ }), children: [funnel_core_1.Schema.AssetField.LinkedValue.Image.filter(visual)
54
+ ? renderImage({ configuration, visual })
55
+ : renderVideo({ configuration, visual }), aspect !== 'auto' && anchor && anchorDirection &&
56
+ (0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)('absolute inset-0 z-supersurface flex', {
57
+ 'flex-col': anchorDirection === 'y'
58
+ }), children: (0, jsx_runtime_1.jsxs)(framer_motion_1.AnimatePresence, { mode: "popLayout", children: [anchor !== 'left' && anchor !== 'top' &&
59
+ (0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { className: "flex-1 bg-content-button-contrast/backdrop", layout: true, variants: core_1.Animate.Variants.fade, initial: "initial", animate: "animate", exit: "exit" }, "crop.start"), (0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { className: (0, classnames_1.default)('shrink-0 outline outline-1 outline-ix-primary', {
60
+ 'h-full w-auto': anchorDirection === 'x',
61
+ 'w-full h-auto': anchorDirection === 'y',
62
+ 'aspect-square': aspect === 'square',
63
+ 'aspect-phone': aspect === 'phone',
64
+ 'aspect-tv': aspect === 'tv',
65
+ 'aspect-widescreen': aspect === 'widescreen',
66
+ 'aspect-cinema': aspect === 'cinema'
67
+ }), layout: true }, "visible"), anchor !== 'right' && anchor !== 'bottom' &&
68
+ (0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { className: "flex-1 bg-content-button-contrast/backdrop", layout: true, variants: core_1.Animate.Variants.fade, initial: "initial", animate: "animate", exit: "exit" }, "crop.end")] }) })] }) }));
69
+ }
70
+ function renderImage({ visual }) {
71
+ var _a;
72
+ return ((0, jsx_runtime_1.jsx)("img", { className: "max-w-full max-h-full", src: visual.url, alt: (_a = visual.description) !== null && _a !== void 0 ? _a : visual.name }));
73
+ }
74
+ function renderVideo({ visual }) {
75
+ return ((0, jsx_runtime_1.jsx)("video", { className: "max-w-full max-h-full", src: visual.url, autoPlay: true, muted: true, loop: true, playsInline: true }));
13
76
  }