@jbpark/live-editor 3.0.0 → 3.0.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.
@@ -1065,7 +1065,16 @@ const editJsxAttribute = (opening, propertyName, value) => {
1065
1065
  content: `=${content}`
1066
1066
  }];
1067
1067
  };
1068
- const buildAttributeValue = (value, type) => {
1068
+ const holdsStructuralExpression = (value) => import_lib$2.isJSXExpressionContainer(value) && (import_lib$2.isArrayExpression(value.expression) || import_lib$2.isObjectExpression(value.expression));
1069
+ const structuralSource = (value) => {
1070
+ try {
1071
+ const expression = (0, import_lib$1.parseExpression)(value.trim(), { plugins: ["jsx", "typescript"] });
1072
+ return import_lib$2.isArrayExpression(expression) || import_lib$2.isObjectExpression(expression) ? expression : null;
1073
+ } catch {
1074
+ return null;
1075
+ }
1076
+ };
1077
+ const buildAttributeValue = (value, type, current) => {
1069
1078
  if (type === "array" || type === "object") {
1070
1079
  if (typeof value === "string") try {
1071
1080
  return import_lib$2.jsxExpressionContainer((0, import_lib$1.parseExpression)(value.trim(), { plugins: ["jsx", "typescript"] }));
@@ -1075,14 +1084,20 @@ const buildAttributeValue = (value, type) => {
1075
1084
  const expr = valueToExpression(value);
1076
1085
  return expr ? import_lib$2.jsxExpressionContainer(expr) : import_lib$2.stringLiteral("");
1077
1086
  }
1078
- if (typeof value === "string") return import_lib$2.stringLiteral(value);
1087
+ if (typeof value === "string") {
1088
+ if (holdsStructuralExpression(current) && !(type && STRING_VALUED_TYPES.has(type))) {
1089
+ const structural = structuralSource(value);
1090
+ if (structural) return import_lib$2.jsxExpressionContainer(structural);
1091
+ }
1092
+ return import_lib$2.stringLiteral(value);
1093
+ }
1079
1094
  const expr = valueToExpression(value);
1080
1095
  return expr ? import_lib$2.jsxExpressionContainer(expr) : import_lib$2.stringLiteral(String(value));
1081
1096
  };
1082
1097
  const editAttribute = (opening, propertyName, value, type) => {
1083
1098
  const attribute = findAttribute(opening, propertyName);
1084
1099
  if (!attribute || attribute.start == null || attribute.end == null) return null;
1085
- const content = generateCode(import_lib$2.jsxAttribute(attribute.name, buildAttributeValue(value, type)));
1100
+ const content = generateCode(import_lib$2.jsxAttribute(attribute.name, buildAttributeValue(value, type, attribute.value)));
1086
1101
  return [{
1087
1102
  start: attribute.start,
1088
1103
  end: attribute.end,
@@ -1273,4 +1288,4 @@ const validateBindingValue = (binding, value) => {
1273
1288
  //#endregion
1274
1289
  export { parseValue as A, parseBindingExpression as C, extractObjectProperties as D, extractNodeValue as E, generateCode as M, flattenEditableValue as O, parseBinding as S, createNodeFromValue as T, moveSelectedIndices as _, extract as a, getCurrentValue as b, moveArrayItem as c, removeArrayItems as d, updateArrayItemProperty as f, replaceIds as g, fillIds as h, clearExtractCache as i, setEditableValue as j, parseArrayExpression as k, moveArrayItems as l, clone as m, bulkUpdate as n, appendArrayItem as o, updateArrayItemValue as p, update as r, duplicateArrayItems as s, validateBindingValue as t, parseItems as u, removeIndices as v, arrayExpressionToCode as w, getStructuredValue as x, findEditableChildren as y };
1275
1290
 
1276
- //# sourceMappingURL=ast-DRg6HV4H.js.map
1291
+ //# sourceMappingURL=ast-D6R-dsk0.js.map