@uniformdev/mesh-sdk-react 19.47.1-alpha.3 → 19.48.1-alpha.0

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.esm.js CHANGED
@@ -2909,7 +2909,7 @@ function ControlledValuePlugin({
2909
2909
  import { useLexicalComposerContext as useLexicalComposerContext3 } from "@lexical/react/LexicalComposerContext";
2910
2910
  import { useLexicalNodeSelection } from "@lexical/react/useLexicalNodeSelection";
2911
2911
  import { $moveCharacter, $shouldOverrideDefaultCharacterSelection } from "@lexical/selection";
2912
- import { mergeRegister } from "@lexical/utils";
2912
+ import { mergeRegister as mergeRegister2 } from "@lexical/utils";
2913
2913
  import { createVariableReference as createVariableReference2 } from "@uniformdev/canvas";
2914
2914
  import { LoadingIndicator as LoadingIndicator2 } from "@uniformdev/design-system";
2915
2915
  import {
@@ -2999,18 +2999,20 @@ import {
2999
2999
  LexicalTypeaheadMenuPlugin,
3000
3000
  MenuOption
3001
3001
  } from "@lexical/react/LexicalTypeaheadMenuPlugin";
3002
+ import { mergeRegister } from "@lexical/utils";
3002
3003
  import { AiFillPlusCircle } from "@react-icons/all-files/ai/AiFillPlusCircle";
3003
3004
  import { createVariableReference } from "@uniformdev/canvas";
3004
- import { HorizontalRhythm, MenuGroup, MenuItem as MenuItem2, MenuItemSeparator } from "@uniformdev/design-system";
3005
+ import { HorizontalRhythm as HorizontalRhythm2, MenuGroup, MenuItem as MenuItem2, MenuItemSeparator } from "@uniformdev/design-system";
3005
3006
  import { dequal as dequal2 } from "dequal/lite";
3006
3007
  import {
3008
+ $createTextNode,
3007
3009
  $getNodeByKey,
3008
3010
  $insertNodes,
3009
3011
  $nodesOfType as $nodesOfType2,
3010
3012
  COMMAND_PRIORITY_NORMAL,
3011
3013
  createCommand
3012
3014
  } from "lexical";
3013
- import { useCallback, useEffect as useEffect7, useMemo as useMemo8, useRef as useRef9, useState as useState8 } from "react";
3015
+ import { useCallback, useEffect as useEffect7, useMemo as useMemo8, useRef as useRef10, useState as useState9 } from "react";
3014
3016
  import { createPortal } from "react-dom";
3015
3017
 
3016
3018
  // src/components/Variables/toolbox/SelectVariableMenu.styles.ts
@@ -3042,8 +3044,8 @@ var variablesTipText = css18`
3042
3044
  padding: 0 var(--spacing-sm);
3043
3045
  `;
3044
3046
 
3045
- // src/components/Variables/useOnVariableUpdated.ts
3046
- import { useEffect as useEffect6 } from "react";
3047
+ // src/components/Variables/useVariableEditor.ts
3048
+ import { useEffect as useEffect6, useState as useState8 } from "react";
3047
3049
 
3048
3050
  // src/components/Variables/VariablesProvider.tsx
3049
3051
  import mitt from "mitt";
@@ -3051,7 +3053,8 @@ import { createContext as createContext3, useContext as useContext5, useMemo as
3051
3053
 
3052
3054
  // src/components/Variables/VariableEditor.tsx
3053
3055
  import { zodResolver } from "@hookform/resolvers/zod";
3054
- import { Button as Button2, Callout as Callout3, Input as Input2, useShortcut } from "@uniformdev/design-system";
3056
+ import { Button as Button2, Callout as Callout3, HorizontalRhythm, Input as Input2, useShortcut } from "@uniformdev/design-system";
3057
+ import { useLayoutEffect, useRef as useRef9 } from "react";
3055
3058
  import { useForm } from "react-hook-form";
3056
3059
  import { z } from "zod";
3057
3060
 
@@ -3062,10 +3065,6 @@ var variablesFormContainer = css19`
3062
3065
  margin: var(--spacing-base) 0 0;
3063
3066
  }
3064
3067
  `;
3065
- var variablesFormBtnGroup = css19`
3066
- display: flex;
3067
- gap: var(--spacing-sm);
3068
- `;
3069
3068
 
3070
3069
  // src/components/Variables/VariableEditor.tsx
3071
3070
  import { jsx as jsx30, jsxs as jsxs16 } from "@emotion/react/jsx-runtime";
@@ -3077,7 +3076,12 @@ var schema = z.object({
3077
3076
  order: z.number().optional(),
3078
3077
  type: z.string().optional()
3079
3078
  });
3080
- function VariableEditor({ variable, onSubmit, onCancel, disableMeshTip }) {
3079
+ function VariableEditor({
3080
+ variable,
3081
+ onSubmit,
3082
+ onCancel,
3083
+ disableMeshTip
3084
+ }) {
3081
3085
  var _a, _b, _c, _d, _e, _f, _g;
3082
3086
  const { variables } = useVariables();
3083
3087
  const currentVariable = variables[variable];
@@ -3099,7 +3103,7 @@ function VariableEditor({ variable, onSubmit, onCancel, disableMeshTip }) {
3099
3103
  type: values.type || void 0,
3100
3104
  displayName: values.displayName || void 0
3101
3105
  };
3102
- return onSubmit(finalValue);
3106
+ return onSubmit(finalValue, null);
3103
3107
  });
3104
3108
  useShortcut({
3105
3109
  shortcut: "enter",
@@ -3108,6 +3112,13 @@ function VariableEditor({ variable, onSubmit, onCancel, disableMeshTip }) {
3108
3112
  },
3109
3113
  activeWhenEditing: true
3110
3114
  });
3115
+ const nameRef = useRef9(null);
3116
+ const { ref, ...nameRegister } = register("name");
3117
+ useLayoutEffect(() => {
3118
+ if (nameRef.current && !nameRef.current.value) {
3119
+ nameRef.current.focus();
3120
+ }
3121
+ }, []);
3111
3122
  return (
3112
3123
  // NOTE: this is intentionally NOT a <form> because it's regularly used in a nested modal and that can make it bubble
3113
3124
  // up a submit to its 'parent form' which is not what we want.
@@ -3115,12 +3126,15 @@ function VariableEditor({ variable, onSubmit, onCancel, disableMeshTip }) {
3115
3126
  /* @__PURE__ */ jsx30(
3116
3127
  Input2,
3117
3128
  {
3118
- ...register("name"),
3129
+ ...nameRegister,
3119
3130
  label: "Name",
3120
3131
  disabled: variable !== "",
3121
3132
  caption: "This cannot change once created.",
3122
3133
  errorMessage: (_e = formState.errors.name) == null ? void 0 : _e.message,
3123
- "data-af": "1"
3134
+ ref: (e) => {
3135
+ ref(e);
3136
+ nameRef.current = e;
3137
+ }
3124
3138
  }
3125
3139
  ),
3126
3140
  /* @__PURE__ */ jsx30(
@@ -3142,14 +3156,22 @@ function VariableEditor({ variable, onSubmit, onCancel, disableMeshTip }) {
3142
3156
  errorMessage: (_g = formState.errors.default) == null ? void 0 : _g.message
3143
3157
  }
3144
3158
  ),
3145
- /* @__PURE__ */ jsxs16("div", { css: variablesFormBtnGroup, children: [
3159
+ /* @__PURE__ */ jsx30(HorizontalRhythm, { justify: "space-between", children: /* @__PURE__ */ jsxs16(HorizontalRhythm, { gap: "sm", children: [
3146
3160
  /* @__PURE__ */ jsx30(Button2, { type: "button", onClick: submitHandler, children: "OK" }),
3147
- /* @__PURE__ */ jsx30(Button2, { type: "button", buttonType: "ghost", onClick: onCancel, children: "Cancel" })
3148
- ] }),
3161
+ /* @__PURE__ */ jsx30(Button2, { type: "button", buttonType: "ghost", onClick: () => onCancel({ disconnect: false }), children: "cancel" })
3162
+ ] }) }),
3149
3163
  disableMeshTip ? null : /* @__PURE__ */ jsxs16(Callout3, { type: "tip", title: "Customized User Interfaces", children: [
3150
3164
  "Developers can create customized user interfaces for variable editing by building a Uniform mesh integration. Get started quickly with our",
3151
3165
  " ",
3152
- /* @__PURE__ */ jsx30("a", { href: "https://docs.uniform.app", target: "_blank", rel: "noopener noreferrer", children: "Mesh SDK" }),
3166
+ /* @__PURE__ */ jsx30(
3167
+ "a",
3168
+ {
3169
+ href: "https://docs.uniform.app/docs/integrations/mesh-integrations/custom-integrations",
3170
+ target: "_blank",
3171
+ rel: "noopener noreferrer",
3172
+ children: "Mesh SDK"
3173
+ }
3174
+ ),
3153
3175
  "."
3154
3176
  ] })
3155
3177
  ] })
@@ -3170,7 +3192,10 @@ function VariablesProvider({
3170
3192
  }) {
3171
3193
  const [editing, setEditing] = useState7();
3172
3194
  const [editingContext, setEditingContext] = useState7();
3173
- const events = useMemo7(() => mitt(), []);
3195
+ const events = useMemo7(
3196
+ () => mitt(),
3197
+ []
3198
+ );
3174
3199
  if (!readOnly && !onChange) {
3175
3200
  throw new Error("onChange must be provided when readOnly is false");
3176
3201
  }
@@ -3229,15 +3254,23 @@ function VariablesProvider({
3229
3254
  Editor,
3230
3255
  {
3231
3256
  context: editingContext,
3232
- onSubmit: (val) => {
3257
+ onSubmit: (val, editorCompletedContext) => {
3233
3258
  contextValue.dispatch({ type: "cancelEdit" });
3234
3259
  const { name, ...varValue } = val;
3235
3260
  const latestValue = { ...value, [name]: varValue };
3236
3261
  onChange == null ? void 0 : onChange(latestValue);
3237
- events.emit("update", { name, latestValue });
3262
+ events.emit("editCompleted", {
3263
+ canceled: false,
3264
+ selectedVariable: val,
3265
+ editorCompletedContext
3266
+ });
3238
3267
  },
3239
- onCancel: () => {
3268
+ onCancel: (editorCancelledContext) => {
3240
3269
  contextValue.dispatch({ type: "cancelEdit" });
3270
+ events.emit("editCompleted", {
3271
+ canceled: true,
3272
+ editorCancelledContext
3273
+ });
3241
3274
  },
3242
3275
  variable: editing
3243
3276
  }
@@ -3273,16 +3306,57 @@ function flattenVariables(variables) {
3273
3306
  return flatVariables;
3274
3307
  }
3275
3308
 
3276
- // src/components/Variables/useOnVariableUpdated.ts
3277
- function useOnVariableUpdated(fn, disabled) {
3278
- const { variables, events, canDispatch } = useVariables(true);
3309
+ // src/components/Variables/useVariableEditor.ts
3310
+ function useVariableEditor() {
3311
+ const { variables, events, canDispatch, dispatch, isEditing } = useVariables(true);
3312
+ const [isEditingBinding, setIsEditingBinding] = useState8();
3279
3313
  useEffect6(() => {
3280
- if (disabled || !canDispatch) {
3314
+ if (!canDispatch || !isEditingBinding) {
3281
3315
  return;
3282
3316
  }
3283
- events.on("update", fn);
3284
- return () => events.off("update", fn);
3285
- }, [canDispatch, disabled, events, fn, variables]);
3317
+ const fn = (e) => {
3318
+ isEditingBinding.resolve(e);
3319
+ setIsEditingBinding(void 0);
3320
+ };
3321
+ events.on("editCompleted", fn);
3322
+ return () => events.off("editCompleted", fn);
3323
+ }, [canDispatch, events, isEditingBinding, variables]);
3324
+ useEffect6(() => {
3325
+ if (!isEditing) {
3326
+ setIsEditingBinding(void 0);
3327
+ }
3328
+ }, [isEditing]);
3329
+ return {
3330
+ async editVariable(variable, context) {
3331
+ if (!canDispatch) {
3332
+ throw new Error("Cannot edit variable. VariablesProvider is not mounted.");
3333
+ }
3334
+ if (isEditingBinding) {
3335
+ throw new Error("Cannot edit variable. Another variable is already being edited.");
3336
+ }
3337
+ return new Promise((resolve) => {
3338
+ setIsEditingBinding({
3339
+ resolve,
3340
+ variable
3341
+ });
3342
+ dispatch({ type: "edit", variable, context });
3343
+ });
3344
+ }
3345
+ };
3346
+ }
3347
+
3348
+ // src/components/Variables/util/variableDefaultTextValue.ts
3349
+ function variableDefaultTextValue(defaultValue) {
3350
+ if (defaultValue === void 0 || defaultValue === null) {
3351
+ return "";
3352
+ }
3353
+ if (typeof defaultValue === "string") {
3354
+ return defaultValue;
3355
+ }
3356
+ if (defaultValue.toString) {
3357
+ return defaultValue.toString();
3358
+ }
3359
+ return "unknown";
3286
3360
  }
3287
3361
 
3288
3362
  // src/components/Variables/variablesToList.ts
@@ -3335,6 +3409,9 @@ function variablesToGroupedList(variables, filterFn, context) {
3335
3409
  import { Fragment as Fragment6, jsx as jsx32, jsxs as jsxs18 } from "@emotion/react/jsx-runtime";
3336
3410
  var OPEN_INSERT_VARIABLE_COMMAND = createCommand("uniform:open-insert-variable");
3337
3411
  var EDIT_VARIABLE_COMMAND = createCommand("uniform:edit-variable");
3412
+ var DISCONNECT_VARIABLE_COMMAND = createCommand(
3413
+ "uniform:disconnect-variable"
3414
+ );
3338
3415
  var INSERT_VARIABLE_COMMAND = createCommand("uniform:insert-variable");
3339
3416
  var TRIGGER = "\\$\\$";
3340
3417
  var LENGTH_LIMIT = 20;
@@ -3438,7 +3515,7 @@ function VariablesPlugin({
3438
3515
  }) {
3439
3516
  const [editor] = useLexicalComposerContext2();
3440
3517
  const { variables, dispatch, isEditing, canDispatch, readOnly, knownUndefinedValues, isLoading } = useVariables(true);
3441
- const variablesRef = useRef9({ variables, knownUndefinedValues, isLoading });
3518
+ const variablesRef = useRef10({ variables, knownUndefinedValues, isLoading });
3442
3519
  variablesRef.current = { variables, knownUndefinedValues, isLoading };
3443
3520
  const canEditVariable = useCallback(
3444
3521
  (name, variable) => (
@@ -3447,28 +3524,8 @@ function VariablesPlugin({
3447
3524
  ),
3448
3525
  [canDispatch, enableEditingVariables, readOnly]
3449
3526
  );
3450
- const [editingKey, setEditingKey] = useState8(null);
3451
- useOnVariableUpdated(({ name, latestValue }) => {
3452
- editor.update(() => {
3453
- var _a;
3454
- if (editingKey === null) {
3455
- return;
3456
- }
3457
- const targetKey = editingKey === ADD_VARIABLE_OPTION ? void 0 : editingKey;
3458
- editor.dispatchCommand(INSERT_VARIABLE_COMMAND, {
3459
- reference: name,
3460
- initialDisplayName: (_a = latestValue[name]) == null ? void 0 : _a.displayName,
3461
- targetKey,
3462
- overwriteExistingValue: replaceValueOnVariableInsert
3463
- });
3464
- });
3465
- }, editingKey === null);
3466
- useEffect7(() => {
3467
- if (editingKey !== null && !isEditing) {
3468
- setEditingKey(null);
3469
- }
3470
- }, [editingKey, isEditing]);
3471
- const [queryString, setQueryString] = useState8(null);
3527
+ const { editVariable } = useVariableEditor();
3528
+ const [queryString, setQueryString] = useState9(null);
3472
3529
  const { groupedVariables, menuOptions, onSelect } = useVariablesMenu({
3473
3530
  showAddVariableMenuOption,
3474
3531
  filterVariable,
@@ -3496,9 +3553,6 @@ function VariablesPlugin({
3496
3553
  }, [queryString, groupedVariables, menuOptions]);
3497
3554
  const onSelectOption = useCallback(
3498
3555
  (selectedOption, nodeToReplace, closeMenu) => {
3499
- if (selectedOption.key === ADD_VARIABLE_OPTION) {
3500
- setEditingKey(void 0);
3501
- }
3502
3556
  onSelect({
3503
3557
  queryString: queryString != null ? queryString : void 0,
3504
3558
  value: selectedOption.key,
@@ -3511,57 +3565,126 @@ function VariablesPlugin({
3511
3565
  [editor, onSelect, queryString, replaceValueOnVariableInsert]
3512
3566
  );
3513
3567
  useEffect7(() => {
3514
- editor.registerCommand(
3515
- EDIT_VARIABLE_COMMAND,
3516
- ({ reference, sourceKey }) => {
3517
- if (!disableVariables && canEditVariable(reference, variablesRef.current.variables[reference])) {
3518
- dispatch({ type: "edit", variable: reference, context: getEditorContext == null ? void 0 : getEditorContext() });
3519
- setEditingKey(sourceKey);
3520
- }
3521
- return true;
3522
- },
3523
- COMMAND_PRIORITY_NORMAL
3524
- );
3525
- editor.registerCommand(
3526
- OPEN_INSERT_VARIABLE_COMMAND,
3527
- () => {
3528
- if (!disableVariables) {
3529
- dispatch({ type: "edit", variable: "", context: getEditorContext == null ? void 0 : getEditorContext() });
3530
- setEditingKey(ADD_VARIABLE_OPTION);
3531
- }
3532
- return true;
3533
- },
3534
- COMMAND_PRIORITY_NORMAL
3535
- );
3536
- editor.registerCommand(
3537
- INSERT_VARIABLE_COMMAND,
3538
- ({ reference, initialDisplayName, targetKey, overwriteExistingValue }) => {
3539
- var _a, _b;
3540
- if (!disableVariables) {
3541
- const targetVariable = variablesRef.current.variables[reference];
3542
- if (overwriteExistingValue) {
3543
- setVariablesEditorValue(editor, createVariableReference(reference));
3544
- return true;
3568
+ return mergeRegister(
3569
+ editor.registerCommand(
3570
+ EDIT_VARIABLE_COMMAND,
3571
+ ({ reference, sourceKey }) => {
3572
+ const currentValue = variablesRef.current.variables[reference];
3573
+ if (!disableVariables && canEditVariable(reference, currentValue)) {
3574
+ editVariable(reference, getEditorContext == null ? void 0 : getEditorContext()).then((result) => {
3575
+ var _a;
3576
+ if (result.canceled) {
3577
+ if (((_a = result.editorCancelledContext) == null ? void 0 : _a.disconnect) && sourceKey) {
3578
+ editor.dispatchCommand(DISCONNECT_VARIABLE_COMMAND, { sourceKey });
3579
+ return;
3580
+ }
3581
+ return;
3582
+ }
3583
+ editor.dispatchCommand(INSERT_VARIABLE_COMMAND, {
3584
+ variable: result.selectedVariable.name,
3585
+ initialDisplayName: result.selectedVariable.displayName,
3586
+ targetKey: sourceKey,
3587
+ overwriteExistingValue: replaceValueOnVariableInsert
3588
+ });
3589
+ });
3545
3590
  }
3546
- const variableNode = $createVariableNode(reference, {
3547
- displayName: initialDisplayName != null ? initialDisplayName : (targetVariable == null ? void 0 : targetVariable.displayName) || reference,
3548
- hasClickEvent: canEditVariable(reference, targetVariable),
3549
- referenceIsValid: true,
3550
- tooltip: (_a = targetVariable == null ? void 0 : targetVariable.tooltip) != null ? _a : targetVariable == null ? void 0 : targetVariable.helpText,
3551
- isFresh: true,
3552
- isLoading: false
3591
+ return true;
3592
+ },
3593
+ COMMAND_PRIORITY_NORMAL
3594
+ ),
3595
+ // disconnects a variable node from its variable value and leaves the variable's default value
3596
+ // as a string literal in its place. Note that single-valued binding UIs override this so that it
3597
+ // acts as a reset to default component as well as a binding disconnect.
3598
+ editor.registerCommand(
3599
+ DISCONNECT_VARIABLE_COMMAND,
3600
+ ({ sourceKey }) => {
3601
+ editor.update(() => {
3602
+ var _a;
3603
+ const currentNode = $getNodeByKey(sourceKey);
3604
+ if (!$isVariableNode(currentNode)) {
3605
+ throw new Error("Cannot disconnect a non-variable node");
3606
+ }
3607
+ const currentVariableDefinition = variablesRef.current.variables[currentNode.reference];
3608
+ const variableTextNode = $createTextNode(
3609
+ variableDefaultTextValue(
3610
+ (_a = currentVariableDefinition == null ? void 0 : currentVariableDefinition.default) != null ? _a : currentNode.getState().displayName
3611
+ )
3612
+ );
3613
+ const variableNode = $getNodeByKey(sourceKey);
3614
+ if (!variableNode) {
3615
+ console.error("Disconnected from unknown node.");
3616
+ return true;
3617
+ }
3618
+ variableNode.replace(variableTextNode);
3619
+ variableTextNode.select();
3553
3620
  });
3554
- if (targetKey) {
3555
- (_b = $getNodeByKey(targetKey)) == null ? void 0 : _b.replace(variableNode);
3556
- } else {
3557
- $insertNodes([variableNode]);
3621
+ return true;
3622
+ },
3623
+ COMMAND_PRIORITY_NORMAL
3624
+ ),
3625
+ editor.registerCommand(
3626
+ OPEN_INSERT_VARIABLE_COMMAND,
3627
+ () => {
3628
+ if (!disableVariables) {
3629
+ editVariable("", getEditorContext == null ? void 0 : getEditorContext()).then((result) => {
3630
+ if (result.canceled) {
3631
+ return;
3632
+ }
3633
+ editor.dispatchCommand(INSERT_VARIABLE_COMMAND, {
3634
+ variable: result.selectedVariable.name,
3635
+ initialDisplayName: result.selectedVariable.displayName,
3636
+ targetKey: void 0,
3637
+ overwriteExistingValue: replaceValueOnVariableInsert
3638
+ });
3639
+ });
3558
3640
  }
3559
- }
3560
- return true;
3561
- },
3562
- COMMAND_PRIORITY_NORMAL
3641
+ return true;
3642
+ },
3643
+ COMMAND_PRIORITY_NORMAL
3644
+ ),
3645
+ // register the insert variable command, used to handle inserting
3646
+ // a variable reference from non-autocomplete menus at the current selection,
3647
+ // or replacing an existing variable node with a new variable reference (when targetKey is set to a node ID)
3648
+ editor.registerCommand(
3649
+ INSERT_VARIABLE_COMMAND,
3650
+ ({ variable: reference, initialDisplayName, targetKey, overwriteExistingValue }) => {
3651
+ var _a, _b;
3652
+ if (!disableVariables) {
3653
+ const targetVariable = variablesRef.current.variables[reference];
3654
+ if (overwriteExistingValue) {
3655
+ setVariablesEditorValue(editor, createVariableReference(reference));
3656
+ return true;
3657
+ }
3658
+ const variableNode = $createVariableNode(reference, {
3659
+ displayName: initialDisplayName != null ? initialDisplayName : (targetVariable == null ? void 0 : targetVariable.displayName) || reference,
3660
+ hasClickEvent: canEditVariable(reference, targetVariable),
3661
+ referenceIsValid: true,
3662
+ tooltip: (_a = targetVariable == null ? void 0 : targetVariable.tooltip) != null ? _a : targetVariable == null ? void 0 : targetVariable.helpText,
3663
+ isFresh: true,
3664
+ isLoading: false
3665
+ });
3666
+ if (targetKey) {
3667
+ (_b = $getNodeByKey(targetKey)) == null ? void 0 : _b.replace(variableNode);
3668
+ } else {
3669
+ $insertNodes([variableNode]);
3670
+ }
3671
+ }
3672
+ return true;
3673
+ },
3674
+ COMMAND_PRIORITY_NORMAL
3675
+ )
3563
3676
  );
3564
- }, [editor, disableVariables, canDispatch, dispatch, canEditVariable, readOnly, getEditorContext]);
3677
+ }, [
3678
+ editor,
3679
+ disableVariables,
3680
+ canDispatch,
3681
+ dispatch,
3682
+ canEditVariable,
3683
+ readOnly,
3684
+ getEditorContext,
3685
+ editVariable,
3686
+ replaceValueOnVariableInsert
3687
+ ]);
3565
3688
  const updateExistingNodeIfChanged = useCallback(
3566
3689
  (variableNode) => {
3567
3690
  var _a, _b, _c;
@@ -3609,7 +3732,7 @@ function VariablesPlugin({
3609
3732
  triggerFn: getPossibleQueryMatch,
3610
3733
  options: filteredMenuOptions,
3611
3734
  menuRenderFn: (anchorElementRef, { selectOptionAndCleanUp, setHighlightedIndex, selectedIndex }) => {
3612
- if (!anchorElementRef.current || groupedVariables.length === 0 || editingKey !== null) {
3735
+ if (!anchorElementRef.current || groupedVariables.length === 0 || isEditing) {
3613
3736
  return null;
3614
3737
  }
3615
3738
  let currentCumulativeMenuIndex = -1;
@@ -3651,7 +3774,7 @@ function VariablesPlugin({
3651
3774
  setHighlightedIndex(myCumulativeIndex);
3652
3775
  },
3653
3776
  css: menuItemTextGroup,
3654
- children: variable.name === ADD_VARIABLE_OPTION ? /* @__PURE__ */ jsxs18(HorizontalRhythm, { gap: "sm", align: "center", children: [
3777
+ children: variable.name === ADD_VARIABLE_OPTION ? /* @__PURE__ */ jsxs18(HorizontalRhythm2, { gap: "sm", align: "center", children: [
3655
3778
  /* @__PURE__ */ jsx32(AiFillPlusCircle, { fill: "var(--gray-500)" }),
3656
3779
  " ",
3657
3780
  /* @__PURE__ */ jsx32("span", { children: variable.displayName })
@@ -3772,7 +3895,7 @@ function VariableNodeComponent({
3772
3895
  [isSelected, nodeKey]
3773
3896
  );
3774
3897
  useEffect8(() => {
3775
- return mergeRegister(
3898
+ return mergeRegister2(
3776
3899
  editor.registerCommand(KEY_DELETE_COMMAND, onDelete, COMMAND_PRIORITY_LOW),
3777
3900
  editor.registerCommand(KEY_BACKSPACE_COMMAND, onDelete, COMMAND_PRIORITY_LOW),
3778
3901
  // HACK: see https://github.com/facebook/lexical/issues/4214
@@ -3878,27 +4001,30 @@ function EditorRefPlugin({
3878
4001
 
3879
4002
  // src/components/Variables/composer/PasteTransformerPlugin.tsx
3880
4003
  import { useLexicalComposerContext as useLexicalComposerContext5 } from "@lexical/react/LexicalComposerContext";
4004
+ import { mergeRegister as mergeRegister3 } from "@lexical/utils";
3881
4005
  import { $getSelection as $getSelection2, $isRangeSelection as $isRangeSelection2, COMMAND_PRIORITY_HIGH, PASTE_COMMAND } from "lexical";
3882
4006
  import { useEffect as useEffect9 } from "react";
3883
4007
  function PasteTransformerPlugin({ transformPaste }) {
3884
4008
  const [editor] = useLexicalComposerContext5();
3885
4009
  useEffect9(() => {
3886
- editor.registerCommand(
3887
- PASTE_COMMAND,
3888
- (event) => {
3889
- var _a;
3890
- const selection = $getSelection2();
3891
- const pastedText = (_a = event.clipboardData) == null ? void 0 : _a.getData("text/plain");
3892
- if (pastedText && transformPaste && $isRangeSelection2(selection)) {
3893
- const result = transformPaste(pastedText);
3894
- if (result !== void 0) {
3895
- selection.insertText(result);
3896
- return true;
4010
+ return mergeRegister3(
4011
+ editor.registerCommand(
4012
+ PASTE_COMMAND,
4013
+ (event) => {
4014
+ var _a;
4015
+ const selection = $getSelection2();
4016
+ const pastedText = (_a = event.clipboardData) == null ? void 0 : _a.getData("text/plain");
4017
+ if (pastedText && transformPaste && $isRangeSelection2(selection)) {
4018
+ const result = transformPaste(pastedText);
4019
+ if (result !== void 0) {
4020
+ selection.insertText(result);
4021
+ return true;
4022
+ }
3897
4023
  }
3898
- }
3899
- return false;
3900
- },
3901
- COMMAND_PRIORITY_HIGH
4024
+ return false;
4025
+ },
4026
+ COMMAND_PRIORITY_HIGH
4027
+ )
3902
4028
  );
3903
4029
  }, [editor, transformPaste]);
3904
4030
  return null;
@@ -4022,7 +4148,8 @@ function useInputVariablesState({
4022
4148
  sharedMenuProps,
4023
4149
  disableVariablesForReals,
4024
4150
  hasVariablesInValue,
4025
- hadVariablesInValue: hadVariablesInValueForReals
4151
+ hadVariablesInValue: hadVariablesInValueForReals,
4152
+ setHadVariablesInValue
4026
4153
  };
4027
4154
  }
4028
4155
 
@@ -4066,8 +4193,8 @@ import { CLEAR_EDITOR_COMMAND } from "lexical";
4066
4193
  // src/components/Variables/toolbox/SelectVariableMenu.tsx
4067
4194
  import { BsFillPlusCircleFill } from "@react-icons/all-files/bs/BsFillPlusCircleFill";
4068
4195
  import { CgUsbC } from "@react-icons/all-files/cg/CgUsbC";
4069
- import { HorizontalRhythm as HorizontalRhythm2, Menu as Menu2, MenuGroup as MenuGroup2, MenuItem as MenuItem3, MenuItemSeparator as MenuItemSeparator2 } from "@uniformdev/design-system";
4070
- import { useEffect as useEffect11, useRef as useRef10, useState as useState10 } from "react";
4196
+ import { HorizontalRhythm as HorizontalRhythm3, Menu as Menu2, MenuGroup as MenuGroup2, MenuItem as MenuItem3, MenuItemSeparator as MenuItemSeparator2 } from "@uniformdev/design-system";
4197
+ import { useRef as useRef11 } from "react";
4071
4198
  import { Fragment as Fragment7, jsx as jsx34, jsxs as jsxs19 } from "@emotion/react/jsx-runtime";
4072
4199
  function SelectVariableMenu({
4073
4200
  onSelectVariable,
@@ -4080,17 +4207,9 @@ function SelectVariableMenu({
4080
4207
  menuTooltip = "Insert variable",
4081
4208
  filterVariable
4082
4209
  }) {
4083
- const { variables, dispatch, isEditing, canDispatch, readOnly } = useVariables(true);
4084
- const btnRef = useRef10(null);
4085
- const [openedAdd, setOpenedAdd] = useState10(false);
4086
- useOnVariableUpdated(({ name, latestValue }) => {
4087
- onSelectVariable == null ? void 0 : onSelectVariable({ ...latestValue[name], name });
4088
- }, !openedAdd);
4089
- useEffect11(() => {
4090
- if (openedAdd && !isEditing) {
4091
- setOpenedAdd(false);
4092
- }
4093
- }, [isEditing, openedAdd]);
4210
+ const { variables, canDispatch, readOnly } = useVariables(true);
4211
+ const btnRef = useRef11(null);
4212
+ const { editVariable } = useVariableEditor();
4094
4213
  const variablesGroups = variablesToGroupedList(variables, filterVariable, getEditorContext == null ? void 0 : getEditorContext());
4095
4214
  const showAddVariableMenuOptionForReals = showAddVariableMenuOption && canDispatch && !readOnly;
4096
4215
  const menuHasVariableOptions = variablesGroups.length > 0;
@@ -4119,12 +4238,15 @@ function SelectVariableMenu({
4119
4238
  showAddVariableMenuOptionForReals ? /* @__PURE__ */ jsx34(
4120
4239
  MenuItem3,
4121
4240
  {
4122
- onClick: () => {
4123
- setOpenedAdd(true);
4124
- dispatch({ type: "edit", variable: "", context: getEditorContext == null ? void 0 : getEditorContext() });
4241
+ onClick: async () => {
4242
+ const result = await editVariable("", getEditorContext == null ? void 0 : getEditorContext());
4243
+ if (result.canceled) {
4244
+ return;
4245
+ }
4246
+ onSelectVariable == null ? void 0 : onSelectVariable(result.selectedVariable);
4125
4247
  },
4126
4248
  "data-testid": "add-variable-button",
4127
- children: /* @__PURE__ */ jsxs19(HorizontalRhythm2, { gap: "sm", align: "center", children: [
4249
+ children: /* @__PURE__ */ jsxs19(HorizontalRhythm3, { gap: "sm", align: "center", children: [
4128
4250
  /* @__PURE__ */ jsx34(BsFillPlusCircleFill, { fill: "var(--gray-500)", size: "1.25em" }),
4129
4251
  /* @__PURE__ */ jsx34("span", { children: typeof showAddVariableMenuOption === "string" ? showAddVariableMenuOption : /* @__PURE__ */ jsx34(Fragment7, { children: "Add\u2026" }) })
4130
4252
  ] })
@@ -4165,7 +4287,7 @@ function VariablesComposerVariableMenu(props) {
4165
4287
  const [editor] = useLexicalComposerContext6();
4166
4288
  const onSelectVariable = (selectedVariable) => {
4167
4289
  editor.dispatchCommand(INSERT_VARIABLE_COMMAND, {
4168
- reference: selectedVariable.name,
4290
+ variable: selectedVariable.name,
4169
4291
  initialDisplayName: selectedVariable.displayName,
4170
4292
  targetKey: void 0,
4171
4293
  overwriteExistingValue: props.replaceValueOnVariableInsert
@@ -4220,14 +4342,14 @@ import { AutoFocusPlugin } from "@lexical/react/LexicalAutoFocusPlugin";
4220
4342
  import { ClearEditorPlugin } from "@lexical/react/LexicalClearEditorPlugin";
4221
4343
  import { LexicalComposer } from "@lexical/react/LexicalComposer";
4222
4344
  import { OnChangePlugin } from "@lexical/react/LexicalOnChangePlugin";
4223
- import { useMemo as useMemo10, useRef as useRef11, useState as useState11 } from "react";
4345
+ import { useMemo as useMemo10, useRef as useRef12, useState as useState11 } from "react";
4224
4346
 
4225
4347
  // src/components/Variables/composer/DisablePlugin.tsx
4226
4348
  import { useLexicalComposerContext as useLexicalComposerContext7 } from "@lexical/react/LexicalComposerContext";
4227
- import { useEffect as useEffect12 } from "react";
4349
+ import { useEffect as useEffect11 } from "react";
4228
4350
  function DisablePlugin({ disabled }) {
4229
4351
  const [editor] = useLexicalComposerContext7();
4230
- useEffect12(() => {
4352
+ useEffect11(() => {
4231
4353
  editor.setEditable(!disabled);
4232
4354
  }, [editor, disabled]);
4233
4355
  return null;
@@ -4236,10 +4358,10 @@ function DisablePlugin({ disabled }) {
4236
4358
  // src/components/Variables/composer/SingleLineTextPlugin.tsx
4237
4359
  import { useLexicalComposerContext as useLexicalComposerContext8 } from "@lexical/react/LexicalComposerContext";
4238
4360
  import { LineBreakNode } from "lexical";
4239
- import { useEffect as useEffect13 } from "react";
4361
+ import { useEffect as useEffect12 } from "react";
4240
4362
  function SingleLineTextPlugin() {
4241
4363
  const [editor] = useLexicalComposerContext8();
4242
- useEffect13(() => {
4364
+ useEffect12(() => {
4243
4365
  editor.registerNodeTransform(LineBreakNode, (node) => {
4244
4366
  node.remove();
4245
4367
  });
@@ -4305,8 +4427,8 @@ function VariablesComposer(props) {
4305
4427
  // eslint-disable-next-line react-hooks/exhaustive-deps
4306
4428
  []
4307
4429
  );
4308
- const editorState = useRef11();
4309
- const updateTimeout = useRef11();
4430
+ const editorState = useRef12();
4431
+ const updateTimeout = useRef12();
4310
4432
  if (typeof document === "undefined")
4311
4433
  return null;
4312
4434
  return /* @__PURE__ */ jsxs21(LexicalComposer, { initialConfig: editorConfig, children: [
@@ -4350,7 +4472,7 @@ import { ContentEditable } from "@lexical/react/LexicalContentEditable";
4350
4472
  import LexicalErrorBoundary from "@lexical/react/LexicalErrorBoundary";
4351
4473
  import { HistoryPlugin } from "@lexical/react/LexicalHistoryPlugin";
4352
4474
  import { PlainTextPlugin } from "@lexical/react/LexicalPlainTextPlugin";
4353
- import { objectKlassEquals } from "@lexical/utils";
4475
+ import { mergeRegister as mergeRegister4, objectKlassEquals } from "@lexical/utils";
4354
4476
  import {
4355
4477
  $getSelection as $getSelection3,
4356
4478
  $isNodeSelection as $isNodeSelection2,
@@ -4360,7 +4482,7 @@ import {
4360
4482
  CUT_COMMAND,
4361
4483
  PASTE_COMMAND as PASTE_COMMAND2
4362
4484
  } from "lexical";
4363
- import { useEffect as useEffect14 } from "react";
4485
+ import { useEffect as useEffect13 } from "react";
4364
4486
  import { jsx as jsx38, jsxs as jsxs22 } from "@emotion/react/jsx-runtime";
4365
4487
  function VariablesComposerInput({ css: css37, ...contentEditableProps }) {
4366
4488
  return /* @__PURE__ */ jsxs22("div", { children: [
@@ -4378,67 +4500,75 @@ function VariablesComposerInput({ css: css37, ...contentEditableProps }) {
4378
4500
  }
4379
4501
  function RichishCopyAndPastePlugin() {
4380
4502
  const [editor] = useLexicalComposerContext9();
4381
- useEffect14(() => {
4382
- editor.registerCommand(
4383
- COPY_COMMAND,
4384
- (event) => {
4385
- copyToClipboard(editor, objectKlassEquals(event, ClipboardEvent) ? event : null);
4386
- return true;
4387
- },
4388
- COMMAND_PRIORITY_HIGH2
4389
- );
4390
- editor.registerCommand(
4391
- CUT_COMMAND,
4392
- (event) => {
4393
- copyToClipboard(editor, objectKlassEquals(event, ClipboardEvent) ? event : null);
4394
- editor.update(() => {
4503
+ useEffect13(() => {
4504
+ return mergeRegister4(
4505
+ editor.registerCommand(
4506
+ COPY_COMMAND,
4507
+ (event) => {
4508
+ copyToClipboard(
4509
+ editor,
4510
+ objectKlassEquals(event, ClipboardEvent) ? event : null
4511
+ );
4512
+ return true;
4513
+ },
4514
+ COMMAND_PRIORITY_HIGH2
4515
+ ),
4516
+ editor.registerCommand(
4517
+ CUT_COMMAND,
4518
+ (event) => {
4519
+ copyToClipboard(
4520
+ editor,
4521
+ objectKlassEquals(event, ClipboardEvent) ? event : null
4522
+ );
4523
+ editor.update(() => {
4524
+ const selection = $getSelection3();
4525
+ if ($isRangeSelection3(selection)) {
4526
+ selection.removeText();
4527
+ } else if ($isNodeSelection2(selection)) {
4528
+ selection.getNodes().forEach((node) => node.remove());
4529
+ }
4530
+ });
4531
+ return true;
4532
+ },
4533
+ COMMAND_PRIORITY_HIGH2
4534
+ ),
4535
+ editor.registerCommand(
4536
+ PASTE_COMMAND2,
4537
+ (event) => {
4395
4538
  const selection = $getSelection3();
4396
4539
  if ($isRangeSelection3(selection)) {
4397
- selection.removeText();
4398
- } else if ($isNodeSelection2(selection)) {
4399
- selection.getNodes().forEach((node) => node.remove());
4400
- }
4401
- });
4402
- return true;
4403
- },
4404
- COMMAND_PRIORITY_HIGH2
4405
- );
4406
- editor.registerCommand(
4407
- PASTE_COMMAND2,
4408
- (event) => {
4409
- const selection = $getSelection3();
4410
- if ($isRangeSelection3(selection)) {
4411
- event.preventDefault();
4412
- editor.update(
4413
- () => {
4414
- const selection2 = $getSelection3();
4415
- const clipboardData = event instanceof InputEvent || event instanceof KeyboardEvent ? null : event.clipboardData;
4416
- if (clipboardData != null && $isRangeSelection3(selection2)) {
4417
- const lexicalString = clipboardData.getData("application/x-lexical-editor");
4418
- if (lexicalString) {
4419
- try {
4420
- const payload = JSON.parse(lexicalString);
4421
- if (Array.isArray(payload.nodes)) {
4422
- const nodes = $generateNodesFromSerializedNodes(payload.nodes);
4423
- return $insertGeneratedNodes(editor, nodes, selection2);
4540
+ event.preventDefault();
4541
+ editor.update(
4542
+ () => {
4543
+ const selection2 = $getSelection3();
4544
+ const clipboardData = event instanceof InputEvent || event instanceof KeyboardEvent ? null : event.clipboardData;
4545
+ if (clipboardData != null && $isRangeSelection3(selection2)) {
4546
+ const lexicalString = clipboardData.getData("application/x-lexical-editor");
4547
+ if (lexicalString) {
4548
+ try {
4549
+ const payload = JSON.parse(lexicalString);
4550
+ if (Array.isArray(payload.nodes)) {
4551
+ const nodes = $generateNodesFromSerializedNodes(payload.nodes);
4552
+ return $insertGeneratedNodes(editor, nodes, selection2);
4553
+ }
4554
+ } catch (e) {
4424
4555
  }
4425
- } catch (e) {
4556
+ }
4557
+ const text = clipboardData.getData("text/plain") || clipboardData.getData("text/uri-list");
4558
+ if (text != null) {
4559
+ selection2.insertRawText(text);
4426
4560
  }
4427
4561
  }
4428
- const text = clipboardData.getData("text/plain") || clipboardData.getData("text/uri-list");
4429
- if (text != null) {
4430
- selection2.insertRawText(text);
4431
- }
4562
+ },
4563
+ {
4564
+ tag: "paste"
4432
4565
  }
4433
- },
4434
- {
4435
- tag: "paste"
4436
- }
4437
- );
4438
- }
4439
- return true;
4440
- },
4441
- COMMAND_PRIORITY_HIGH2
4566
+ );
4567
+ }
4568
+ return true;
4569
+ },
4570
+ COMMAND_PRIORITY_HIGH2
4571
+ )
4442
4572
  );
4443
4573
  }, [editor]);
4444
4574
  return null;
@@ -4575,7 +4705,7 @@ function InputVariablesOverlayMenu({
4575
4705
  // src/components/Variables/ParameterConnectionIndicator.tsx
4576
4706
  import { CgUsbC as CgUsbC2 } from "@react-icons/all-files/cg/CgUsbC";
4577
4707
  import { bindVariablesToObject } from "@uniformdev/canvas";
4578
- import { HorizontalRhythm as HorizontalRhythm3, Menu as Menu3 } from "@uniformdev/design-system";
4708
+ import { HorizontalRhythm as HorizontalRhythm4, Menu as Menu3 } from "@uniformdev/design-system";
4579
4709
  import { useMemo as useMemo11 } from "react";
4580
4710
 
4581
4711
  // src/components/Variables/styles/ParameterVariables.styles.ts
@@ -4685,7 +4815,7 @@ function ParameterConnectionIndicator({
4685
4815
  });
4686
4816
  return result;
4687
4817
  }, [value]);
4688
- return /* @__PURE__ */ jsxs24(HorizontalRhythm3, { align: "center", gap: "xs", css: { width: "100%" }, children: [
4818
+ return /* @__PURE__ */ jsxs24(HorizontalRhythm4, { align: "center", gap: "xs", css: { width: "100%" }, children: [
4689
4819
  /* @__PURE__ */ jsx40("div", { css: { flex: 1 }, children }),
4690
4820
  disabled ? null : /* @__PURE__ */ jsx40(
4691
4821
  Menu3,
@@ -4710,7 +4840,47 @@ function ParameterConnectionIndicator({
4710
4840
  }
4711
4841
 
4712
4842
  // src/components/Variables/ParameterOrSingleVariable.tsx
4713
- import { HorizontalRhythm as HorizontalRhythm4 } from "@uniformdev/design-system";
4843
+ import { HorizontalRhythm as HorizontalRhythm5 } from "@uniformdev/design-system";
4844
+ import { useCallback as useCallback3 } from "react";
4845
+
4846
+ // src/components/Variables/composer/OnDisconnectPlugin.tsx
4847
+ import { useLexicalComposerContext as useLexicalComposerContext10 } from "@lexical/react/LexicalComposerContext";
4848
+ import { mergeRegister as mergeRegister5 } from "@lexical/utils";
4849
+ import { $getNodeByKey as $getNodeByKey3, COMMAND_PRIORITY_HIGH as COMMAND_PRIORITY_HIGH3 } from "lexical";
4850
+ import { useEffect as useEffect14, useRef as useRef13 } from "react";
4851
+ function OnDisconnectPlugin({
4852
+ onDisconnect
4853
+ }) {
4854
+ const [editor] = useLexicalComposerContext10();
4855
+ const { variables } = useVariables(true);
4856
+ const variablesRef = useRef13(variables);
4857
+ variablesRef.current = variables;
4858
+ useEffect14(() => {
4859
+ return mergeRegister5(
4860
+ editor.registerCommand(
4861
+ DISCONNECT_VARIABLE_COMMAND,
4862
+ ({ sourceKey }) => {
4863
+ editor.update(() => {
4864
+ const currentNode = $getNodeByKey3(sourceKey);
4865
+ if (!$isVariableNode(currentNode)) {
4866
+ return;
4867
+ }
4868
+ const currentVariableDefinition = variablesRef.current[currentNode.reference];
4869
+ if (!currentVariableDefinition) {
4870
+ return;
4871
+ }
4872
+ onDisconnect({ name: currentNode.reference, ...currentVariableDefinition });
4873
+ });
4874
+ return false;
4875
+ },
4876
+ COMMAND_PRIORITY_HIGH3
4877
+ )
4878
+ );
4879
+ }, [editor, onDisconnect]);
4880
+ return null;
4881
+ }
4882
+
4883
+ // src/components/Variables/ParameterOrSingleVariable.tsx
4714
4884
  import { jsx as jsx41, jsxs as jsxs25 } from "@emotion/react/jsx-runtime";
4715
4885
  function ParameterOrSingleVariable(props) {
4716
4886
  const {
@@ -4720,9 +4890,25 @@ function ParameterOrSingleVariable(props) {
4720
4890
  enableEditingVariables,
4721
4891
  disabled,
4722
4892
  editorRef,
4723
- filterVariable
4893
+ filterVariable,
4894
+ onDisconnect
4724
4895
  } = props;
4725
- const { disableVariablesForReals, hadVariablesInValue, sharedMenuProps, hasVariablesInValue } = useInputVariablesState(props);
4896
+ const {
4897
+ disableVariablesForReals,
4898
+ hadVariablesInValue,
4899
+ sharedMenuProps,
4900
+ hasVariablesInValue,
4901
+ setHadVariablesInValue
4902
+ } = useInputVariablesState(props);
4903
+ const handleDisconnect = useCallback3(
4904
+ (variable) => {
4905
+ setHadVariablesInValue(false);
4906
+ if (onDisconnect) {
4907
+ onDisconnect(variable);
4908
+ }
4909
+ },
4910
+ [onDisconnect, setHadVariablesInValue]
4911
+ );
4726
4912
  return (
4727
4913
  // we use a "fauxical" lexical here to render the vars the same as other editors do,
4728
4914
  // and also to enable us to dispatch the same editor commands as other editors do
@@ -4737,9 +4923,10 @@ function ParameterOrSingleVariable(props) {
4737
4923
  replaceValueOnVariableInsert: true,
4738
4924
  disabled: true,
4739
4925
  children: [
4926
+ /* @__PURE__ */ jsx41(OnDisconnectPlugin, { onDisconnect: handleDisconnect }),
4740
4927
  editorRef ? /* @__PURE__ */ jsx41(EditorRefPlugin, { editorRef }) : null,
4741
4928
  /* @__PURE__ */ jsx41(ControlledValuePlugin, { enabled: true, value }),
4742
- /* @__PURE__ */ jsxs25(HorizontalRhythm4, { align: "center", gap: "xs", css: { width: "100%" }, children: [
4929
+ /* @__PURE__ */ jsxs25(HorizontalRhythm5, { align: "center", gap: "xs", css: { width: "100%" }, children: [
4743
4930
  /* @__PURE__ */ jsx41("div", { css: { flex: 1 }, children: inputWhenNoVariables && !hadVariablesInValue ? inputWhenNoVariables : /* @__PURE__ */ jsx41(
4744
4931
  VariablesComposerInput,
4745
4932
  {
@@ -4767,7 +4954,7 @@ function ParameterOrSingleVariable(props) {
4767
4954
 
4768
4955
  // src/components/Variables/ParameterVariables.tsx
4769
4956
  import { css as css24 } from "@emotion/react";
4770
- import { HorizontalRhythm as HorizontalRhythm5 } from "@uniformdev/design-system";
4957
+ import { HorizontalRhythm as HorizontalRhythm6 } from "@uniformdev/design-system";
4771
4958
  import { jsx as jsx42, jsxs as jsxs26 } from "@emotion/react/jsx-runtime";
4772
4959
  function ParameterVariables(props) {
4773
4960
  const {
@@ -4805,7 +4992,7 @@ function ParameterVariables(props) {
4805
4992
  editorRef ? /* @__PURE__ */ jsx42(EditorRefPlugin, { editorRef }) : null,
4806
4993
  /* @__PURE__ */ jsx42(ControlledValuePlugin, { value, enabled: useInputWhenNoVariables }),
4807
4994
  /* @__PURE__ */ jsxs26(
4808
- HorizontalRhythm5,
4995
+ HorizontalRhythm6,
4809
4996
  {
4810
4997
  align: "center",
4811
4998
  gap: "xs",
@@ -4859,20 +5046,6 @@ ${prettifyBindExpression(bindExpression)}`
4859
5046
  };
4860
5047
  }
4861
5048
 
4862
- // src/components/Variables/util/variableDefaultTextValue.ts
4863
- function variableDefaultTextValue(defaultValue) {
4864
- if (defaultValue === void 0 || defaultValue === null) {
4865
- return "";
4866
- }
4867
- if (typeof defaultValue === "string") {
4868
- return defaultValue;
4869
- }
4870
- if (defaultValue.toString) {
4871
- return defaultValue.toString();
4872
- }
4873
- return "unknown";
4874
- }
4875
-
4876
5049
  // src/components/Variables/VariablesList.tsx
4877
5050
  import { css as css26 } from "@emotion/react";
4878
5051
  import {
@@ -5835,11 +6008,11 @@ import { LoadingIndicator as LoadingIndicator3, Theme as Theme2 } from "@uniform
5835
6008
 
5836
6009
  // src/hooks/useInitializeUniformMeshSdk.ts
5837
6010
  import { initializeUniformMeshSDK } from "@uniformdev/mesh-sdk";
5838
- import { useEffect as useEffect15, useRef as useRef12, useState as useState14 } from "react";
6011
+ import { useEffect as useEffect15, useRef as useRef14, useState as useState14 } from "react";
5839
6012
  var useInitializeUniformMeshSdk = ({ autoResizingDisabled } = {}) => {
5840
6013
  const [error, setError] = useState14();
5841
6014
  const [sdk, setSdk] = useState14();
5842
- const initializationInProgress = useRef12(false);
6015
+ const initializationInProgress = useRef14(false);
5843
6016
  useEffect15(
5844
6017
  () => {
5845
6018
  if (typeof window === "undefined" || sdk) {
@@ -5929,7 +6102,7 @@ import { Container, IconsProvider, ScrollableList, VerticalRhythm as VerticalRhy
5929
6102
  import { bindVariablesToObject as bindVariablesToObject2 } from "@uniformdev/canvas";
5930
6103
  import {
5931
6104
  createContext as createContext5,
5932
- useCallback as useCallback3,
6105
+ useCallback as useCallback4,
5933
6106
  useContext as useContext7,
5934
6107
  useDeferredValue,
5935
6108
  useMemo as useMemo14,
@@ -5959,7 +6132,7 @@ var ObjectSearchProvider = ({ currentlySelectedItems, children }) => {
5959
6132
  const querySearchDeferred = useDeferredValue(query);
5960
6133
  const [selectedItems, setSelectedItems] = useState15(currentlySelectedItems != null ? currentlySelectedItems : []);
5961
6134
  const [list, setList] = useState15({});
5962
- const onSetQuery = useCallback3(
6135
+ const onSetQuery = useCallback4(
5963
6136
  (value2) => {
5964
6137
  if (Array.isArray(value2.contentType) && value2.contentType.length > 0) {
5965
6138
  return setQuery({
@@ -5971,7 +6144,7 @@ var ObjectSearchProvider = ({ currentlySelectedItems, children }) => {
5971
6144
  },
5972
6145
  [setQuery]
5973
6146
  );
5974
- const onSelectItem = useCallback3(
6147
+ const onSelectItem = useCallback4(
5975
6148
  (selectedResult) => {
5976
6149
  if (Array.isArray(selectedResult)) {
5977
6150
  setSelectedItems(selectedResult);
@@ -5985,10 +6158,10 @@ var ObjectSearchProvider = ({ currentlySelectedItems, children }) => {
5985
6158
  },
5986
6159
  [setSelectedItems, selectedItems]
5987
6160
  );
5988
- const onRemoveAllSelectedItems = useCallback3(() => {
6161
+ const onRemoveAllSelectedItems = useCallback4(() => {
5989
6162
  setSelectedItems([]);
5990
6163
  }, [setSelectedItems]);
5991
- const onSetList = useCallback3(
6164
+ const onSetList = useCallback4(
5992
6165
  (value2) => {
5993
6166
  setList(value2);
5994
6167
  },
@@ -6804,7 +6977,7 @@ var QueryFilter = ({
6804
6977
  };
6805
6978
 
6806
6979
  // src/components/ParamTypeDynamicDataProvider.tsx
6807
- import { useEffect as useEffect17, useMemo as useMemo15, useRef as useRef13 } from "react";
6980
+ import { useEffect as useEffect17, useMemo as useMemo15, useRef as useRef15 } from "react";
6808
6981
  import { jsx as jsx67 } from "@emotion/react/jsx-runtime";
6809
6982
  function ParamTypeDynamicDataProvider(props) {
6810
6983
  const { children } = props;
@@ -6826,7 +6999,7 @@ var JsonMeshVariableEditor = ({
6826
6999
  variable,
6827
7000
  context
6828
7001
  }) => {
6829
- const sillyRef = useRef13(false);
7002
+ const sillyRef = useRef15(false);
6830
7003
  const { editConnectedData } = useMeshLocation("paramType");
6831
7004
  useEffect17(() => {
6832
7005
  if (sillyRef.current) {
@@ -6846,10 +7019,10 @@ var JsonMeshVariableEditor = ({
6846
7019
  existingConnectedData: variable
6847
7020
  });
6848
7021
  if (result.canceled) {
6849
- onCancel();
7022
+ onCancel(result.editorCancelledContext);
6850
7023
  return;
6851
7024
  }
6852
- onSubmit(result.connectedData);
7025
+ onSubmit(result.connectedData, null);
6853
7026
  };
6854
7027
  effect();
6855
7028
  }, [context == null ? void 0 : context.connectsTo, editConnectedData, onCancel, onSubmit, variable]);
@@ -6909,6 +7082,7 @@ export {
6909
7082
  Button6 as Button,
6910
7083
  Callout5 as Callout,
6911
7084
  ControlledValuePlugin,
7085
+ DISCONNECT_VARIABLE_COMMAND,
6912
7086
  DamSelectedItem,
6913
7087
  DataRefreshButton,
6914
7088
  DataResourceDynamicInputProvider,
@@ -7069,7 +7243,6 @@ export {
7069
7243
  useDynamicInputsAsVariables,
7070
7244
  useMeshLocation,
7071
7245
  useObjectSearchContext,
7072
- useOnVariableUpdated,
7073
7246
  useParameterShell,
7074
7247
  useProductQueryContext,
7075
7248
  useProductSearchContext,
@@ -7077,6 +7250,7 @@ export {
7077
7250
  useRequestHeader,
7078
7251
  useRequestParameter,
7079
7252
  useUniformMeshSdk,
7253
+ useVariableEditor,
7080
7254
  useVariables,
7081
7255
  useVariablesMenu,
7082
7256
  variableDefaultTextValue,