@elementor/editor-variables 3.35.0-362 → 3.35.0-364

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/index.d.mts CHANGED
@@ -71,7 +71,9 @@ declare const service: {
71
71
  id: any;
72
72
  variable: any;
73
73
  }>;
74
- update: (id: string, { label, value }: Omit<Variable, "type">) => Promise<{
74
+ update: (id: string, { label, value, type }: Omit<Variable, "type"> & {
75
+ type?: Variable["type"];
76
+ }) => Promise<{
75
77
  id: any;
76
78
  variable: any;
77
79
  }>;
@@ -79,7 +81,7 @@ declare const service: {
79
81
  id: any;
80
82
  variable: any;
81
83
  }>;
82
- restore: (id: string, label?: string, value?: string) => Promise<{
84
+ restore: (id: string, label?: string, value?: string, type?: string) => Promise<{
83
85
  id: any;
84
86
  variable: any;
85
87
  }>;
package/dist/index.d.ts CHANGED
@@ -71,7 +71,9 @@ declare const service: {
71
71
  id: any;
72
72
  variable: any;
73
73
  }>;
74
- update: (id: string, { label, value }: Omit<Variable, "type">) => Promise<{
74
+ update: (id: string, { label, value, type }: Omit<Variable, "type"> & {
75
+ type?: Variable["type"];
76
+ }) => Promise<{
75
77
  id: any;
76
78
  variable: any;
77
79
  }>;
@@ -79,7 +81,7 @@ declare const service: {
79
81
  id: any;
80
82
  variable: any;
81
83
  }>;
82
- restore: (id: string, label?: string, value?: string) => Promise<{
84
+ restore: (id: string, label?: string, value?: string, type?: string) => Promise<{
83
85
  id: any;
84
86
  variable: any;
85
87
  }>;
package/dist/index.js CHANGED
@@ -228,17 +228,18 @@ var apiClient = {
228
228
  value
229
229
  });
230
230
  },
231
- update: (id2, label, value) => {
231
+ update: (id2, label, value, type) => {
232
232
  return (0, import_http_client.httpService)().put(BASE_PATH + "/update", {
233
233
  id: id2,
234
234
  label,
235
- value
235
+ value,
236
+ type
236
237
  });
237
238
  },
238
239
  delete: (id2) => {
239
240
  return (0, import_http_client.httpService)().post(BASE_PATH + "/delete", { id: id2 });
240
241
  },
241
- restore: (id2, label, value) => {
242
+ restore: (id2, label, value, type) => {
242
243
  const payload = { id: id2 };
243
244
  if (label) {
244
245
  payload.label = label;
@@ -246,6 +247,9 @@ var apiClient = {
246
247
  if (value) {
247
248
  payload.value = value;
248
249
  }
250
+ if (type) {
251
+ payload.type = type;
252
+ }
249
253
  return (0, import_http_client.httpService)().post(BASE_PATH + "/restore", payload);
250
254
  },
251
255
  batch: (payload) => {
@@ -511,8 +515,8 @@ var service = {
511
515
  };
512
516
  });
513
517
  },
514
- update: (id2, { label, value }) => {
515
- return apiClient.update(id2, label, value).then((response) => {
518
+ update: (id2, { label, value, type }) => {
519
+ return apiClient.update(id2, label, value, type).then((response) => {
516
520
  const { success, data: payload } = response.data;
517
521
  if (!success) {
518
522
  const errorMessage = payload?.message || (0, import_i18n2.__)("Unexpected response from server", "elementor");
@@ -554,8 +558,8 @@ var service = {
554
558
  };
555
559
  });
556
560
  },
557
- restore: (id2, label, value) => {
558
- return apiClient.restore(id2, label, value).then((response) => {
561
+ restore: (id2, label, value, type) => {
562
+ return apiClient.restore(id2, label, value, type).then((response) => {
559
563
  const { success, data: payload } = response.data;
560
564
  if (!success) {
561
565
  throw new Error("Unexpected response from server");
@@ -968,14 +972,14 @@ var extractId = ({ id: id2 }) => id2;
968
972
  var createVariable = (newVariable) => {
969
973
  return service.create(newVariable).then(extractId);
970
974
  };
971
- var updateVariable = (updateId, { value, label }) => {
972
- return service.update(updateId, { value, label }).then(extractId);
975
+ var updateVariable = (updateId, { value, label, type }) => {
976
+ return service.update(updateId, { value, label, type }).then(extractId);
973
977
  };
974
978
  var deleteVariable = (deleteId) => {
975
979
  return service.delete(deleteId).then(extractId);
976
980
  };
977
- var restoreVariable = (restoreId, label, value) => {
978
- return service.restore(restoreId, label, value).then(extractId);
981
+ var restoreVariable = (restoreId, label, value, type) => {
982
+ return service.restore(restoreId, label, value, type).then(extractId);
979
983
  };
980
984
 
981
985
  // src/components/variables-manager/hooks/use-variables-manager-state.ts
@@ -2253,7 +2257,7 @@ var EditConfirmationDialog = ({
2253
2257
  var SIZE3 = "tiny";
2254
2258
  var DELETE_LABEL = (0, import_i18n12.__)("Delete variable", "elementor");
2255
2259
  var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
2256
- const { icon: VariableIcon, valueField: ValueField, variableType } = useVariableType();
2260
+ const { icon: VariableIcon, valueField: ValueField, variableType, propTypeUtil } = useVariableType();
2257
2261
  const { setVariableValue: notifyBoundPropChange, variableId } = useVariableBoundProp();
2258
2262
  const { propType } = (0, import_editor_controls5.useBoundProp)();
2259
2263
  const [isMessageSuppressed, suppressMessage] = (0, import_editor_current_user2.useSuppressedMessage)(EDIT_CONFIRMATION_DIALOG_ID);
@@ -2263,6 +2267,7 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
2263
2267
  const [valueFieldError, setValueFieldError] = (0, import_react15.useState)("");
2264
2268
  const { labelFieldError, setLabelFieldError } = useLabelError();
2265
2269
  const variable = useVariable(editId);
2270
+ const [propTypeKey, setPropTypeKey] = (0, import_react15.useState)(variable?.type ?? propTypeUtil.key);
2266
2271
  if (!variable) {
2267
2272
  throw new Error(`Global ${variableType} variable not found`);
2268
2273
  }
@@ -2290,10 +2295,9 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
2290
2295
  }
2291
2296
  };
2292
2297
  const handleSaveVariable = () => {
2293
- updateVariable(editId, {
2294
- value,
2295
- label
2296
- }).then(() => {
2298
+ const typeChanged = propTypeKey !== variable.type;
2299
+ const updatePayload = typeChanged ? { value, label, type: propTypeKey } : { value, label };
2300
+ updateVariable(editId, updatePayload).then(() => {
2297
2301
  maybeTriggerBoundPropChange();
2298
2302
  onSubmit?.();
2299
2303
  }).catch((error) => {
@@ -2397,6 +2401,7 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
2397
2401
  ValueField,
2398
2402
  {
2399
2403
  propTypeKey: variable.type,
2404
+ onPropTypeKeyChange: (key) => setPropTypeKey(key),
2400
2405
  value,
2401
2406
  onChange: (newValue) => {
2402
2407
  setValue(newValue);
@@ -2858,7 +2863,7 @@ var import_ui23 = require("@elementor/ui");
2858
2863
  var import_i18n16 = require("@wordpress/i18n");
2859
2864
  var SIZE7 = "tiny";
2860
2865
  var VariableRestore = ({ variableId, onClose, onSubmit }) => {
2861
- const { icon: VariableIcon, valueField: ValueField, variableType } = useVariableType();
2866
+ const { icon: VariableIcon, valueField: ValueField, variableType, propTypeUtil } = useVariableType();
2862
2867
  const { setVariableValue: notifyBoundPropChange } = useVariableBoundProp();
2863
2868
  const { propType } = (0, import_editor_controls7.useBoundProp)();
2864
2869
  const variable = useVariable(variableId);
@@ -2869,12 +2874,15 @@ var VariableRestore = ({ variableId, onClose, onSubmit }) => {
2869
2874
  const [valueFieldError, setValueFieldError] = (0, import_react19.useState)("");
2870
2875
  const [label, setLabel] = (0, import_react19.useState)(variable.label);
2871
2876
  const [value, setValue] = (0, import_react19.useState)(variable.value);
2877
+ const [propTypeKey, setPropTypeKey] = (0, import_react19.useState)(variable?.type ?? propTypeUtil.key);
2872
2878
  const { labelFieldError, setLabelFieldError } = useLabelError({
2873
2879
  value: variable.label,
2874
2880
  message: ERROR_MESSAGES.DUPLICATED_LABEL
2875
2881
  });
2876
2882
  const handleRestore = () => {
2877
- restoreVariable(variableId, label, value).then(() => {
2883
+ const typeChanged = propTypeKey !== variable.type;
2884
+ const restorePromise = typeChanged ? restoreVariable(variableId, label, value, propTypeKey) : restoreVariable(variableId, label, value);
2885
+ restorePromise.then(() => {
2878
2886
  notifyBoundPropChange(variableId);
2879
2887
  onSubmit?.();
2880
2888
  }).catch((error) => {
@@ -2942,6 +2950,8 @@ var VariableRestore = ({ variableId, onClose, onSubmit }) => {
2942
2950
  ), ValueField && /* @__PURE__ */ React23.createElement(FormField, { errorMsg: valueFieldError, label: (0, import_i18n16.__)("Value", "elementor") }, /* @__PURE__ */ React23.createElement(import_ui23.Typography, { variant: "h5" }, /* @__PURE__ */ React23.createElement(
2943
2951
  ValueField,
2944
2952
  {
2953
+ propTypeKey,
2954
+ onPropTypeKeyChange: (key) => setPropTypeKey(key),
2945
2955
  value,
2946
2956
  onChange: (newValue) => {
2947
2957
  setValue(newValue);
@@ -3355,6 +3365,10 @@ var initCreateVariableTool = () => {
3355
3365
  name: "create-global-variable",
3356
3366
  schema: InputSchema,
3357
3367
  outputSchema: OutputSchema,
3368
+ modelPreferences: {
3369
+ intelligencePriority: 0.7,
3370
+ speedPriority: 0.7
3371
+ },
3358
3372
  description: `Create a new global variable
3359
3373
  ## When to use this tool:
3360
3374
  - When a user requests to create a new global variable in the Elementor editor.
@@ -3415,6 +3429,10 @@ var initDeleteVariableTool = () => {
3415
3429
  outputSchema: {
3416
3430
  status: import_schema4.z.enum(["ok", "error"]).describe("The status of the operation")
3417
3431
  },
3432
+ modelPreferences: {
3433
+ intelligencePriority: 0.7,
3434
+ speedPriority: 0.8
3435
+ },
3418
3436
  description: `Delete an existing global variable
3419
3437
 
3420
3438
  ## When to use this tool:
@@ -3470,6 +3488,10 @@ var initUpdateVariableTool = () => {
3470
3488
  message: import_schema5.z.string().optional().describe("Optional message providing additional information about the operation")
3471
3489
  },
3472
3490
  name: "update-global-variable",
3491
+ modelPreferences: {
3492
+ intelligencePriority: 0.75,
3493
+ speedPriority: 0.7
3494
+ },
3473
3495
  description: `Update an existing global variable
3474
3496
 
3475
3497
  ## When to use this tool: