@brunoalz/smartgesti-site-editor 1.10.2 → 1.11.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"BlockPropertyEditor.d.ts","sourceRoot":"","sources":["../../../src/editor/PropertyEditor/BlockPropertyEditor.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,KAAK,EAAE,YAAY,EAAsE,MAAM,cAAc,CAAC;AAKvH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAkDzD,UAAU,wBAAwB;IAChC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IACjD,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,wEAAwE;IACxE,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED;;;GAGG;AACH,eAAO,MAAM,mBAAmB,gEAiJ9B,CAAC"}
1
+ {"version":3,"file":"BlockPropertyEditor.d.ts","sourceRoot":"","sources":["../../../src/editor/PropertyEditor/BlockPropertyEditor.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,KAAK,EAAE,YAAY,EAAsE,MAAM,cAAc,CAAC;AAKvH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAkDzD,UAAU,wBAAwB;IAChC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IACjD,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,wEAAwE;IACxE,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED;;;GAGG;AACH,eAAO,MAAM,mBAAmB,gEA6J9B,CAAC"}
@@ -1,12 +1,12 @@
1
- import { jsx as p, jsxs as T } from "react/jsx-runtime";
2
- import { memo as b, useMemo as d, useCallback as w } from "react";
3
- import { VariationSelector as S } from "./VariationSelector.js";
4
- import { BlockHeader as M } from "./BlockHeader.js";
5
- import { CollapsiblePropertyGroup as O } from "./CollapsiblePropertyGroup.js";
1
+ import { jsx as d, jsxs as T } from "react/jsx-runtime";
2
+ import { memo as S, useMemo as f, useCallback as b } from "react";
3
+ import { VariationSelector as M } from "./VariationSelector.js";
4
+ import { BlockHeader as O } from "./BlockHeader.js";
5
+ import { CollapsiblePropertyGroup as E } from "./CollapsiblePropertyGroup.js";
6
6
  import { evaluateShowWhen as j } from "../../engine/shared/showWhen.js";
7
- import { componentRegistry as E } from "../../engine/registry/registry.js";
8
- import { pluginRegistry as k } from "../../engine/plugins/pluginRegistry.js";
9
- const H = {
7
+ import { componentRegistry as k } from "../../engine/registry/registry.js";
8
+ import { pluginRegistry as H } from "../../engine/plugins/pluginRegistry.js";
9
+ const R = {
10
10
  // Buttons (primary)
11
11
  primaryButtonColor: "primary",
12
12
  buttonColor: "primary",
@@ -32,83 +32,92 @@ const H = {
32
32
  // Background (generic)
33
33
  bg: "bg"
34
34
  };
35
- function R(f, e) {
36
- const r = H[f];
35
+ function W(x, e) {
36
+ const r = R[x];
37
37
  if (!r) return;
38
- const s = e[r];
39
- return typeof s == "string" ? s : void 0;
38
+ const a = e[r];
39
+ return typeof a == "string" ? a : void 0;
40
40
  }
41
- const q = b(function({
41
+ const z = S(function({
42
42
  block: e,
43
43
  document: r,
44
- currentPageId: s,
45
- onUpdate: l,
46
- uploadConfig: v,
47
- focusedGroup: B
44
+ currentPageId: a,
45
+ onUpdate: c,
46
+ uploadConfig: B,
47
+ focusedGroup: F
48
48
  }) {
49
- const i = d(() => e ? E.get(e.type) : null, [e]), x = d(
50
- () => ({ document: r, currentPageId: s }),
51
- [r, s]
52
- ), h = d(() => {
49
+ const n = f(() => e ? k.get(e.type) : null, [e]), h = f(
50
+ () => ({ document: r, currentPageId: a }),
51
+ [r, a]
52
+ ), C = f(() => {
53
53
  if (!e || !r) return /* @__PURE__ */ new Set();
54
- const t = k.getEditorRestrictions(r, e.type);
54
+ const t = H.getEditorRestrictions(r, e.type);
55
55
  return t?.lockedFields ? new Set(t.lockedFields) : /* @__PURE__ */ new Set();
56
- }, [e, r]), C = d(() => {
57
- if (!e || !i?.inspectorMeta) return {};
58
- const t = e.props, o = i.defaultProps || {}, c = {};
59
- for (const [a, n] of Object.entries(
60
- i.inspectorMeta
56
+ }, [e, r]), g = f(() => {
57
+ if (!e || !n?.inspectorMeta) return {};
58
+ const t = e.props, i = n.defaultProps || {}, u = {}, v = (s, o) => {
59
+ if (!o.includes(".")) return s[o];
60
+ const p = o.split(".");
61
+ let l = s;
62
+ for (const m of p) {
63
+ if (l == null) return;
64
+ l = l[m];
65
+ }
66
+ return l;
67
+ };
68
+ for (const [s, o] of Object.entries(
69
+ n.inspectorMeta
61
70
  )) {
62
- if (n.showWhen && !j(n.showWhen, t, o, x))
71
+ if (o.showWhen && !j(o.showWhen, t, i, h))
63
72
  continue;
64
- const m = n.group || "Geral";
65
- c[m] || (c[m] = []);
66
- const u = t[a], g = n.inputType === "color" || n.inputType === "color-advanced";
67
- let y = u === void 0 || g && u === "" ? o[a] : u;
68
- y === void 0 && g && r?.theme?.colors && (y = R(
69
- a,
73
+ const p = o.group || "Geral";
74
+ u[p] || (u[p] = []);
75
+ const l = v(t, s), m = o.inputType === "color" || o.inputType === "color-advanced";
76
+ let y = l === void 0 || m && l === "" ? v(i, s) : l;
77
+ y === void 0 && m && r?.theme?.colors && (y = W(
78
+ s,
70
79
  r.theme.colors
71
80
  ));
72
- const P = h.has(a) ? { ...n, readOnly: !0 } : n;
73
- c[m].push({
74
- propName: a,
75
- meta: P,
81
+ const w = C.has(s) ? { ...o, readOnly: !0 } : o;
82
+ u[p].push({
83
+ propName: s,
84
+ meta: w,
76
85
  value: y
77
86
  });
78
87
  }
79
- return c;
80
- }, [e, i, r, x, h]), F = w((t, o) => {
81
- l(t === "logo" && (o === void 0 || o === "") ? { [t]: o, logoHeight: 70 } : { [t]: o });
82
- }, [l]);
83
- return e ? i ? /* @__PURE__ */ T("div", { className: "p-3 space-y-4", children: [
84
- /* @__PURE__ */ p(
85
- M,
88
+ return u;
89
+ }, [e, n, r, h, C]), P = b((t, i) => {
90
+ c(t === "logo" && (i === void 0 || i === "") ? { [t]: i, logoHeight: 70 } : { [t]: i });
91
+ }, [c]);
92
+ return e ? n ? /* @__PURE__ */ T("div", { className: "p-3 space-y-4", children: [
93
+ /* @__PURE__ */ d(
94
+ O,
86
95
  {
87
96
  type: e.type,
88
- name: i.name,
89
- description: i.description
97
+ name: n.name,
98
+ description: n.description
90
99
  }
91
100
  ),
92
- i.variations && /* @__PURE__ */ p(S, { block: e, onUpdate: l }),
93
- Object.keys(C).length === 0 ? /* @__PURE__ */ p("div", { className: "text-center text-gray-500 dark:text-gray-400 text-xs py-4", children: "Nenhuma propriedade configurável" }) : Object.entries(C).map(([t, o]) => /* @__PURE__ */ p(
94
- O,
101
+ n.variations && /* @__PURE__ */ d(M, { block: e, onUpdate: c }),
102
+ Object.keys(g).length === 0 ? /* @__PURE__ */ d("div", { className: "text-center text-gray-500 dark:text-gray-400 text-xs py-4", children: "Nenhuma propriedade configurável" }) : Object.entries(g).map(([t, i]) => /* @__PURE__ */ d(
103
+ E,
95
104
  {
96
105
  groupName: t,
97
- props: o,
98
- onPropChange: F,
99
- onMultiUpdate: l,
106
+ props: i,
107
+ onPropChange: P,
108
+ onMultiUpdate: c,
100
109
  allProps: e?.props,
101
- uploadConfig: v,
102
- isFocused: t === B
110
+ uploadConfig: B,
111
+ isFocused: t === F
103
112
  },
104
113
  t
105
114
  ))
106
115
  ] }) : /* @__PURE__ */ T("div", { className: "p-4 text-center text-red-500 text-sm", children: [
107
116
  "Tipo de bloco desconhecido: ",
108
117
  e.type
109
- ] }) : /* @__PURE__ */ p("div", { className: "p-4 text-center text-gray-500 dark:text-gray-400 text-sm", children: "Selecione um bloco para editar" });
118
+ ] }) : /* @__PURE__ */ d("div", { className: "p-4 text-center text-gray-500 dark:text-gray-400 text-sm", children: "Selecione um bloco para editar" });
110
119
  });
111
120
  export {
112
- q as BlockPropertyEditor
121
+ z as BlockPropertyEditor
113
122
  };
114
123
  //# sourceMappingURL=BlockPropertyEditor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BlockPropertyEditor.js","sources":["../../../src/editor/PropertyEditor/BlockPropertyEditor.tsx"],"sourcesContent":["/**\n * Block Property Editor - Refatorado\n * Editor dinâmico de propriedades baseado em inspectorMeta\n */\n\nimport { memo, useMemo, useCallback } from \"react\";\nimport { Block, SiteDocument, componentRegistry, InspectorMeta, evaluateShowWhen, pluginRegistry } from \"../../engine\";\nimport type { ShowWhenContext } from \"../../engine\";\nimport { VariationSelector } from \"./VariationSelector\";\nimport { BlockHeader } from \"./BlockHeader\";\nimport { CollapsiblePropertyGroup } from \"./CollapsiblePropertyGroup\";\nimport type { UploadConfig } from \"../LandingPageEditor\";\n\n// ============================================================================\n// Theme Color Fallback Map\n// Maps color property names → theme color token keys.\n// Used when block.props[colorProp] and defaultProps[colorProp] are both undefined,\n// so the editor shows the actual theme color instead of #000000.\n// ============================================================================\n\nconst THEME_COLOR_FALLBACKS: Record<string, string> = {\n // Buttons (primary)\n primaryButtonColor: \"primary\",\n buttonColor: \"primary\",\n primaryButtonTextColor: \"primaryText\",\n buttonTextColor: \"primaryText\",\n // Buttons (secondary)\n secondaryButtonColor: \"secondary\",\n secondaryButtonTextColor: \"primaryText\",\n // Badge\n badgeColor: \"accent\",\n badgeTextColor: \"primaryText\",\n // Links\n linkColor: \"linkColor\",\n linkHoverColor: \"primary\",\n // Border\n borderColor: \"border\",\n // Generic text\n color: \"text\",\n // Title/description\n titleColor: \"text\",\n subtitleColor: \"mutedText\",\n descriptionColor: \"mutedText\",\n // Background (generic)\n bg: \"bg\",\n};\n\n/**\n * Resolve theme color fallback for a color property.\n * Returns the theme color value if a mapping exists, undefined otherwise.\n */\nfunction resolveThemeColorFallback(\n propName: string,\n themeColors: Record<string, unknown>,\n): string | undefined {\n const themeKey = THEME_COLOR_FALLBACKS[propName];\n if (!themeKey) return undefined;\n const color = themeColors[themeKey];\n return typeof color === \"string\" ? color : undefined;\n}\n\ninterface BlockPropertyEditorProps {\n block: Block | null;\n document?: SiteDocument;\n currentPageId?: string;\n onUpdate: (updates: Record<string, any>) => void;\n uploadConfig?: UploadConfig;\n /** When set, the matching property group opens and scrolls into view */\n focusedGroup?: string | null;\n}\n\n/**\n * Componente principal do editor de propriedades\n * Memoizado para performance\n */\nexport const BlockPropertyEditor = memo(function BlockPropertyEditor({\n block,\n document,\n currentPageId,\n onUpdate,\n uploadConfig,\n focusedGroup,\n}: BlockPropertyEditorProps) {\n // Obter definição do bloco do registry\n const blockDefinition = useMemo(() => {\n if (!block) return null;\n return componentRegistry.get(block.type);\n }, [block]);\n\n // Contexto para cross-block showWhen\n const showWhenContext = useMemo<ShowWhenContext>(\n () => ({ document, currentPageId }),\n [document, currentPageId],\n );\n\n // Obter restrições de edição do plugin (se houver)\n const lockedFields = useMemo(() => {\n if (!block || !document) return new Set<string>();\n const restriction = pluginRegistry.getEditorRestrictions(document, block.type);\n if (!restriction?.lockedFields) return new Set<string>();\n return new Set(restriction.lockedFields);\n }, [block, document]);\n\n // Agrupar propriedades por grupo\n const groupedProps = useMemo(() => {\n if (!block || !blockDefinition?.inspectorMeta) return {};\n\n const props = block.props as Record<string, any>;\n const defaultProps = (blockDefinition.defaultProps || {}) as Record<string, any>;\n const groups: Record<\n string,\n Array<{ propName: string; meta: InspectorMeta; value: any }>\n > = {};\n\n for (const [propName, meta] of Object.entries(\n blockDefinition.inspectorMeta,\n )) {\n // Visibilidade condicional via showWhen\n if (meta.showWhen) {\n if (!evaluateShowWhen(meta.showWhen, props, defaultProps, showWhenContext)) {\n continue;\n }\n }\n\n const group = meta.group || \"Geral\";\n if (!groups[group]) {\n groups[group] = [];\n }\n\n // Usar valor atual ou fallback para defaultProps, e depois theme colors\n const currentValue = props[propName];\n // Para campos de cor, também fazer fallback se o valor for string vazia\n const isColorInput = meta.inputType === \"color\" || meta.inputType === \"color-advanced\";\n const shouldUseFallback = currentValue === undefined || (isColorInput && currentValue === \"\");\n let value = shouldUseFallback ? defaultProps[propName] : currentValue;\n\n // Para color inputs sem valor definido, tentar fallback para cor do theme\n if (value === undefined && isColorInput && document?.theme?.colors) {\n value = resolveThemeColorFallback(\n propName,\n document.theme.colors as unknown as Record<string, unknown>,\n );\n }\n\n // Aplicar readOnly de plugin restrictions\n const effectiveMeta = lockedFields.has(propName)\n ? { ...meta, readOnly: true }\n : meta;\n\n groups[group].push({\n propName,\n meta: effectiveMeta,\n value,\n });\n }\n\n return groups;\n }, [block, blockDefinition, document, showWhenContext, lockedFields]);\n\n // IMPORTANTE: todos os hooks devem ser chamados ANTES de qualquer early return\n const handlePropChange = useCallback((propName: string, value: any) => {\n // Se remover o logo (definir como undefined), resetar logoHeight para padrão\n if (propName === \"logo\" && (value === undefined || value === \"\")) {\n onUpdate({ [propName]: value, logoHeight: 70 });\n } else {\n onUpdate({ [propName]: value });\n }\n }, [onUpdate]);\n\n if (!block) {\n return (\n <div className=\"p-4 text-center text-gray-500 dark:text-gray-400 text-sm\">\n Selecione um bloco para editar\n </div>\n );\n }\n\n if (!blockDefinition) {\n return (\n <div className=\"p-4 text-center text-red-500 text-sm\">\n Tipo de bloco desconhecido: {block.type}\n </div>\n );\n }\n\n return (\n <div className=\"p-3 space-y-4\">\n {/* Header com ícone centralizado */}\n <BlockHeader\n type={block.type}\n name={blockDefinition.name}\n description={blockDefinition.description}\n />\n\n {/* Seletor de variações (Hero/Navbar) */}\n {blockDefinition.variations && (\n <VariationSelector block={block} onUpdate={onUpdate} />\n )}\n\n {/* Propriedades agrupadas com collapse */}\n {Object.keys(groupedProps).length === 0 ? (\n <div className=\"text-center text-gray-500 dark:text-gray-400 text-xs py-4\">\n Nenhuma propriedade configurável\n </div>\n ) : (\n Object.entries(groupedProps).map(([groupName, props]) => (\n <CollapsiblePropertyGroup\n key={groupName}\n groupName={groupName}\n props={props}\n onPropChange={handlePropChange}\n onMultiUpdate={onUpdate}\n allProps={block?.props as Record<string, any>}\n uploadConfig={uploadConfig}\n isFocused={groupName === focusedGroup}\n />\n ))\n )}\n </div>\n );\n});\n"],"names":["THEME_COLOR_FALLBACKS","resolveThemeColorFallback","propName","themeColors","themeKey","color","BlockPropertyEditor","memo","block","document","currentPageId","onUpdate","uploadConfig","focusedGroup","blockDefinition","useMemo","componentRegistry","showWhenContext","lockedFields","restriction","pluginRegistry","groupedProps","props","defaultProps","groups","meta","evaluateShowWhen","group","currentValue","isColorInput","value","effectiveMeta","handlePropChange","useCallback","jsxs","jsx","BlockHeader","VariationSelector","groupName","CollapsiblePropertyGroup"],"mappings":";;;;;;;;AAoBA,MAAMA,IAAgD;AAAA;AAAA,EAEpD,oBAAoB;AAAA,EACpB,aAAa;AAAA,EACb,wBAAwB;AAAA,EACxB,iBAAiB;AAAA;AAAA,EAEjB,sBAAsB;AAAA,EACtB,0BAA0B;AAAA;AAAA,EAE1B,YAAY;AAAA,EACZ,gBAAgB;AAAA;AAAA,EAEhB,WAAW;AAAA,EACX,gBAAgB;AAAA;AAAA,EAEhB,aAAa;AAAA;AAAA,EAEb,OAAO;AAAA;AAAA,EAEP,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,kBAAkB;AAAA;AAAA,EAElB,IAAI;AACN;AAMA,SAASC,EACPC,GACAC,GACoB;AACpB,QAAMC,IAAWJ,EAAsBE,CAAQ;AAC/C,MAAI,CAACE,EAAU;AACf,QAAMC,IAAQF,EAAYC,CAAQ;AAClC,SAAO,OA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AAA,QACjB,cAAAI;AAAA,QACA,WAAW0B,MAAczB;AAAA,MAAA;AAAA,MAPpByB;AAAA,IAAA,CASR;AAAA,EAAA,GAEL,IAvCE,gBAAAJ,EAAC,OAAA,EAAI,WAAU,wCAAuC,UAAA;AAAA,IAAA;AAAA,IACvB1B,EAAM;AAAA,EAAA,GACrC,IAVA,gBAAA2B,EAAC,OAAA,EAAI,WAAU,4DAA2D,UAAA,kCAE1E;AA+CN,CAAC;"}
1
+ {"version":3,"file":"BlockPropertyEditor.js","sources":["../../../src/editor/PropertyEditor/BlockPropertyEditor.tsx"],"sourcesContent":["/**\n * Block Property Editor - Refatorado\n * Editor dinâmico de propriedades baseado em inspectorMeta\n */\n\nimport { memo, useMemo, useCallback } from \"react\";\nimport { Block, SiteDocument, componentRegistry, InspectorMeta, evaluateShowWhen, pluginRegistry } from \"../../engine\";\nimport type { ShowWhenContext } from \"../../engine\";\nimport { VariationSelector } from \"./VariationSelector\";\nimport { BlockHeader } from \"./BlockHeader\";\nimport { CollapsiblePropertyGroup } from \"./CollapsiblePropertyGroup\";\nimport type { UploadConfig } from \"../LandingPageEditor\";\n\n// ============================================================================\n// Theme Color Fallback Map\n// Maps color property names → theme color token keys.\n// Used when block.props[colorProp] and defaultProps[colorProp] are both undefined,\n// so the editor shows the actual theme color instead of #000000.\n// ============================================================================\n\nconst THEME_COLOR_FALLBACKS: Record<string, string> = {\n // Buttons (primary)\n primaryButtonColor: \"primary\",\n buttonColor: \"primary\",\n primaryButtonTextColor: \"primaryText\",\n buttonTextColor: \"primaryText\",\n // Buttons (secondary)\n secondaryButtonColor: \"secondary\",\n secondaryButtonTextColor: \"primaryText\",\n // Badge\n badgeColor: \"accent\",\n badgeTextColor: \"primaryText\",\n // Links\n linkColor: \"linkColor\",\n linkHoverColor: \"primary\",\n // Border\n borderColor: \"border\",\n // Generic text\n color: \"text\",\n // Title/description\n titleColor: \"text\",\n subtitleColor: \"mutedText\",\n descriptionColor: \"mutedText\",\n // Background (generic)\n bg: \"bg\",\n};\n\n/**\n * Resolve theme color fallback for a color property.\n * Returns the theme color value if a mapping exists, undefined otherwise.\n */\nfunction resolveThemeColorFallback(\n propName: string,\n themeColors: Record<string, unknown>,\n): string | undefined {\n const themeKey = THEME_COLOR_FALLBACKS[propName];\n if (!themeKey) return undefined;\n const color = themeColors[themeKey];\n return typeof color === \"string\" ? color : undefined;\n}\n\ninterface BlockPropertyEditorProps {\n block: Block | null;\n document?: SiteDocument;\n currentPageId?: string;\n onUpdate: (updates: Record<string, any>) => void;\n uploadConfig?: UploadConfig;\n /** When set, the matching property group opens and scrolls into view */\n focusedGroup?: string | null;\n}\n\n/**\n * Componente principal do editor de propriedades\n * Memoizado para performance\n */\nexport const BlockPropertyEditor = memo(function BlockPropertyEditor({\n block,\n document,\n currentPageId,\n onUpdate,\n uploadConfig,\n focusedGroup,\n}: BlockPropertyEditorProps) {\n // Obter definição do bloco do registry\n const blockDefinition = useMemo(() => {\n if (!block) return null;\n return componentRegistry.get(block.type);\n }, [block]);\n\n // Contexto para cross-block showWhen\n const showWhenContext = useMemo<ShowWhenContext>(\n () => ({ document, currentPageId }),\n [document, currentPageId],\n );\n\n // Obter restrições de edição do plugin (se houver)\n const lockedFields = useMemo(() => {\n if (!block || !document) return new Set<string>();\n const restriction = pluginRegistry.getEditorRestrictions(document, block.type);\n if (!restriction?.lockedFields) return new Set<string>();\n return new Set(restriction.lockedFields);\n }, [block, document]);\n\n // Agrupar propriedades por grupo\n const groupedProps = useMemo(() => {\n if (!block || !blockDefinition?.inspectorMeta) return {};\n\n const props = block.props as Record<string, any>;\n const defaultProps = (blockDefinition.defaultProps || {}) as Record<string, any>;\n const groups: Record<\n string,\n Array<{ propName: string; meta: InspectorMeta; value: any }>\n > = {};\n\n // Helper para ler props com dot-notation (ex: \"lightbox.showArrows\" -> props.lightbox.showArrows)\n const getNestedValue = (obj: Record<string, any>, path: string): any => {\n if (!path.includes('.')) return obj[path];\n const parts = path.split('.');\n let current: any = obj;\n for (const part of parts) {\n if (current == null) return undefined;\n current = current[part];\n }\n return current;\n };\n\n for (const [propName, meta] of Object.entries(\n blockDefinition.inspectorMeta,\n )) {\n // Visibilidade condicional via showWhen\n if (meta.showWhen) {\n if (!evaluateShowWhen(meta.showWhen, props, defaultProps, showWhenContext)) {\n continue;\n }\n }\n\n const group = meta.group || \"Geral\";\n if (!groups[group]) {\n groups[group] = [];\n }\n\n // Usar valor atual ou fallback para defaultProps, e depois theme colors\n const currentValue = getNestedValue(props, propName);\n // Para campos de cor, também fazer fallback se o valor for string vazia\n const isColorInput = meta.inputType === \"color\" || meta.inputType === \"color-advanced\";\n const shouldUseFallback = currentValue === undefined || (isColorInput && currentValue === \"\");\n let value = shouldUseFallback ? getNestedValue(defaultProps, propName) : currentValue;\n\n // Para color inputs sem valor definido, tentar fallback para cor do theme\n if (value === undefined && isColorInput && document?.theme?.colors) {\n value = resolveThemeColorFallback(\n propName,\n document.theme.colors as unknown as Record<string, unknown>,\n );\n }\n\n // Aplicar readOnly de plugin restrictions\n const effectiveMeta = lockedFields.has(propName)\n ? { ...meta, readOnly: true }\n : meta;\n\n groups[group].push({\n propName,\n meta: effectiveMeta,\n value,\n });\n }\n\n return groups;\n }, [block, blockDefinition, document, showWhenContext, lockedFields]);\n\n // IMPORTANTE: todos os hooks devem ser chamados ANTES de qualquer early return\n const handlePropChange = useCallback((propName: string, value: any) => {\n // Se remover o logo (definir como undefined), resetar logoHeight para padrão\n if (propName === \"logo\" && (value === undefined || value === \"\")) {\n onUpdate({ [propName]: value, logoHeight: 70 });\n } else {\n onUpdate({ [propName]: value });\n }\n }, [onUpdate]);\n\n if (!block) {\n return (\n <div className=\"p-4 text-center text-gray-500 dark:text-gray-400 text-sm\">\n Selecione um bloco para editar\n </div>\n );\n }\n\n if (!blockDefinition) {\n return (\n <div className=\"p-4 text-center text-red-500 text-sm\">\n Tipo de bloco desconhecido: {block.type}\n </div>\n );\n }\n\n return (\n <div className=\"p-3 space-y-4\">\n {/* Header com ícone centralizado */}\n <BlockHeader\n type={block.type}\n name={blockDefinition.name}\n description={blockDefinition.description}\n />\n\n {/* Seletor de variações (Hero/Navbar) */}\n {blockDefinition.variations && (\n <VariationSelector block={block} onUpdate={onUpdate} />\n )}\n\n {/* Propriedades agrupadas com collapse */}\n {Object.keys(groupedProps).length === 0 ? (\n <div className=\"text-center text-gray-500 dark:text-gray-400 text-xs py-4\">\n Nenhuma propriedade configurável\n </div>\n ) : (\n Object.entries(groupedProps).map(([groupName, props]) => (\n <CollapsiblePropertyGroup\n key={groupName}\n groupName={groupName}\n props={props}\n onPropChange={handlePropChange}\n onMultiUpdate={onUpdate}\n allProps={block?.props as Record<string, any>}\n uploadConfig={uploadConfig}\n isFocused={groupName === focusedGroup}\n />\n ))\n )}\n </div>\n );\n});\n"],"names":["THEME_COLOR_FALLBACKS","resolveThemeColorFallback","propName","themeColors","themeKey","color","BlockPropertyEditor","memo","block","document","currentPageId","onUpdate","uploadConfig","focusedGroup","blockDefinition","useMemo","componentRegistry","showWhenContext","lockedFields","restriction","pluginRegistry","groupedProps","props","defaultProps","groups","getNestedValue","obj","path","parts","current","part","meta","evaluateShowWhen","group","currentValue","isColorInput","value","effectiveMeta","handlePropChange","useCallback","jsxs","jsx","BlockHeader","VariationSelector","groupName","CollapsiblePropertyGroup"],"mappings":";;;;;;;;AAoBA,MAAMA,IAAgD;AAAA;AAAA,EAEpD,oBAAoB;AAAA,EACpB,aAAa;AAAA,EACb,wBAAwB;AAAA,EACxB,iBAAiB;AAAA;AAAA,EAEjB,sBAAsB;AAAA,EACtB,0BAA0B;AAAA;AAAA,EAE1B,YAAY;AAAA,EACZ,gBAAgB;AAAA;AAAA,EAEhB,WAAW;AAAA,EACX,gBAAgB;AAAA;AAAA,EAEhB,aAAa;AAAA;AAAA,EAEb,OAAO;AAAA;AAAA,EAEP,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,kBAAkB;AAAA;AAAA,EAElB,IAAI;AACN;AAMA,SAASC,EACPC,GACAC,GAC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,EAAgB;AAAA,MAAA;AAAA,IAAA;AAAA,IAI9BA,EAAgB,cACf,gBAAA2B,EAACE,GAAA,EAAkB,OAAAnC,GAAc,UAAAG,GAAoB;AAAA,IAItD,OAAO,KAAKU,CAAY,EAAE,WAAW,IACpC,gBAAAoB,EAAC,SAAI,WAAU,6DAA4D,8CAE3E,IAEA,OAAO,QAAQpB,CAAY,EAAE,IAAI,CAAC,CAACuB,GAAWtB,CAAK,MACjD,gBAAAmB;AAAA,MAACI;AAAA,MAAA;AAAA,QAEC,WAAAD;AAAA,QACA,OAAAtB;AAAA,QACA,cAAcgB;AAAA,QACd,eAAe3B;AAAA,QACf,UAAUH,GAAO;AAAA,QACjB,cAAAI;AAAA,QACA,WAAWgC,MAAc/B;AAAA,MAAA;AAAA,MAPpB+B;AAAA,IAAA,CASR;AAAA,EAAA,GAEL,IAvCE,gBAAAJ,EAAC,OAAA,EAAI,WAAU,wCAAuC,UAAA;AAAA,IAAA;AAAA,IACvBhC,EAAM;AAAA,EAAA,GACrC,IAVA,gBAAAiC,EAAC,OAAA,EAAI,WAAU,4DAA2D,UAAA,kCAE1E;AA+CN,CAAC;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ImageGalleryExporter.d.ts","sourceRoot":"","sources":["../../../../../src/engine/export/exporters/sections/ImageGalleryExporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAgC,MAAM,8BAA8B,CAAC;AACxF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAgqC/D,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,MAAM,CAkDjH"}
1
+ {"version":3,"file":"ImageGalleryExporter.d.ts","sourceRoot":"","sources":["../../../../../src/engine/export/exporters/sections/ImageGalleryExporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAgC,MAAM,8BAA8B,CAAC;AACxF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAo/C/D,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,MAAM,CAoDjH"}