@uniformdev/mesh-sdk-react 19.23.1-alpha.12 → 19.23.1-alpha.13

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
@@ -2921,7 +2921,7 @@ function useMeshLocation(expectedLocation) {
2921
2921
 
2922
2922
  // src/components/Variables/InputVariables.tsx
2923
2923
  init_emotion_jsx_shim();
2924
- import { Caption as Caption2, ErrorMessage, InfoMessage, WarningMessage } from "@uniformdev/design-system";
2924
+ import { Caption, ErrorMessage, InfoMessage, WarningMessage } from "@uniformdev/design-system";
2925
2925
  import * as React11 from "react";
2926
2926
  import { useMemo as useMemo8 } from "react";
2927
2927
  import { v4 as v43 } from "uuid";
@@ -3107,17 +3107,43 @@ import { CLEAR_EDITOR_COMMAND } from "lexical";
3107
3107
 
3108
3108
  // src/components/Variables/composer/VariablesPlugin.tsx
3109
3109
  init_emotion_jsx_shim();
3110
- import { css as css21 } from "@emotion/react";
3110
+ import { css as css22 } from "@emotion/react";
3111
3111
  import { useLexicalComposerContext as useLexicalComposerContext2 } from "@lexical/react/LexicalComposerContext";
3112
3112
  import {
3113
3113
  LexicalTypeaheadMenuPlugin,
3114
3114
  MenuOption
3115
3115
  } from "@lexical/react/LexicalTypeaheadMenuPlugin";
3116
- import { Caption, MenuGroup, MenuItem as MenuItem2, MenuItemSeparator } from "@uniformdev/design-system";
3116
+ import { MenuGroup, MenuItem as MenuItem2, MenuItemSeparator } from "@uniformdev/design-system";
3117
3117
  import { $insertNodes, $nodesOfType, COMMAND_PRIORITY_NORMAL, createCommand } from "lexical";
3118
3118
  import { useCallback, useEffect as useEffect7, useMemo as useMemo6, useState as useState8 } from "react";
3119
3119
  import { createPortal } from "react-dom";
3120
3120
 
3121
+ // src/components/Variables/styles/InsertVariableMenu.styles.ts
3122
+ init_emotion_jsx_shim();
3123
+ import { css as css20 } from "@emotion/react";
3124
+ var menuBtn2 = css20`
3125
+ background: none;
3126
+ border: none;
3127
+ color: var(--gray-500);
3128
+ padding: 0;
3129
+ `;
3130
+ var menuItemTextGroup = css20`
3131
+ align-items: flex-start;
3132
+ display: flex;
3133
+ flex-direction: column;
3134
+ gap: 0;
3135
+ line-height: 1em;
3136
+ `;
3137
+ var smallText = css20`
3138
+ font-size: var(--fs-xs);
3139
+ color: var(--gray-500);
3140
+ `;
3141
+ var variablesTipText = css20`
3142
+ ${smallText}
3143
+ color: var(--gray-500);
3144
+ padding: 0 var(--spacing-sm);
3145
+ `;
3146
+
3121
3147
  // src/components/Variables/useOnVariableUpdated.ts
3122
3148
  init_emotion_jsx_shim();
3123
3149
  import { useEffect as useEffect6 } from "react";
@@ -3136,13 +3162,13 @@ import { z } from "zod";
3136
3162
 
3137
3163
  // src/components/Variables/styles/VariableEditor.styles.ts
3138
3164
  init_emotion_jsx_shim();
3139
- import { css as css20 } from "@emotion/react";
3140
- var variablesFormContainer = css20`
3165
+ import { css as css21 } from "@emotion/react";
3166
+ var variablesFormContainer = css21`
3141
3167
  > * {
3142
3168
  margin: var(--spacing-base) 0 0;
3143
3169
  }
3144
3170
  `;
3145
- var variablesFormBtnGroup = css20`
3171
+ var variablesFormBtnGroup = css21`
3146
3172
  display: flex;
3147
3173
  gap: var(--spacing-sm);
3148
3174
  `;
@@ -3282,7 +3308,8 @@ function VariablesProvider({
3282
3308
  variables: value,
3283
3309
  isEditing: typeof editing !== "undefined",
3284
3310
  events,
3285
- canDispatch: true
3311
+ canDispatch: true,
3312
+ readOnly
3286
3313
  };
3287
3314
  return /* @__PURE__ */ jsxs17(VariablesContext.Provider, { value: contextValue, children: [
3288
3315
  children,
@@ -3523,6 +3550,7 @@ function VariablesPlugin({
3523
3550
  const [editor] = useLexicalComposerContext2();
3524
3551
  const { variables, dispatch, isEditing, canDispatch, readOnly } = useVariables();
3525
3552
  const canEditVariable = canDispatch && enableEditingVariables && !readOnly;
3553
+ const canAddVariable = canDispatch && showAddVariableMenuOption && !readOnly;
3526
3554
  const [openedAdd, setOpenedAdd] = useState8(false);
3527
3555
  useOnVariableUpdated((varName) => {
3528
3556
  editor.update(() => {
@@ -3537,7 +3565,7 @@ function VariablesPlugin({
3537
3565
  const [queryString, setQueryString] = useState8(null);
3538
3566
  const { groupedVariables, menuOptions } = useMemo6(() => {
3539
3567
  const groupedVariables2 = variablesToGroupedList(variables);
3540
- if (showAddVariableMenuOption) {
3568
+ if (canAddVariable) {
3541
3569
  groupedVariables2.push({
3542
3570
  name: SOURCE_SEPARATOR,
3543
3571
  variables: [{ name: ADD_VARIABLE_OPTION, displayName: "Add\u2026", default: "" }]
@@ -3550,7 +3578,7 @@ function VariablesPlugin({
3550
3578
  })
3551
3579
  );
3552
3580
  return { menuOptions: menuOptions2, groupedVariables: groupedVariables2 };
3553
- }, [variables, showAddVariableMenuOption]);
3581
+ }, [variables, canAddVariable]);
3554
3582
  const { filteredGroupedVariables, filteredMenuOptions } = useMemo6(() => {
3555
3583
  if (!queryString) {
3556
3584
  return {
@@ -3657,12 +3685,14 @@ function VariablesPlugin({
3657
3685
  /* @__PURE__ */ jsx31(
3658
3686
  "div",
3659
3687
  {
3660
- css: css21`
3688
+ css: css22`
3661
3689
  box-shadow: var(--shadow-base);
3662
3690
  border-radius: var(--rounded-base);
3663
3691
  background: var(--gray-50);
3664
3692
  display: flex;
3665
3693
  flex-direction: column;
3694
+ // 1em = text height, spacing-sm for padding, to prevent menu overlapping text entry
3695
+ margin-top: calc(1em + var(--spacing-sm));
3666
3696
  min-width: 250px;
3667
3697
  padding: var(--spacing-sm);
3668
3698
  outline: none;
@@ -3677,24 +3707,26 @@ function VariablesPlugin({
3677
3707
  {
3678
3708
  title: group.name === SOURCE_SEPARATOR ? "" : (_a = group.name) != null ? _a : "",
3679
3709
  children: [
3680
- group.name === SOURCE_SEPARATOR ? /* @__PURE__ */ jsx31(MenuItemSeparator, {}) : null,
3710
+ group.name === SOURCE_SEPARATOR && currentCumulativeMenuIndex > 0 ? /* @__PURE__ */ jsx31(MenuItemSeparator, {}) : null,
3681
3711
  group.variables.map((variable) => {
3682
3712
  var _a2;
3683
3713
  currentCumulativeMenuIndex++;
3714
+ const myCumulativeIndex = currentCumulativeMenuIndex;
3684
3715
  return /* @__PURE__ */ jsxs18(
3685
3716
  MenuItem2,
3686
3717
  {
3687
- active: selectedIndex === currentCumulativeMenuIndex,
3718
+ active: selectedIndex === myCumulativeIndex,
3688
3719
  onClick: () => {
3689
- setHighlightedIndex(currentCumulativeMenuIndex);
3720
+ setHighlightedIndex(myCumulativeIndex);
3690
3721
  selectOptionAndCleanUp(new MenuOption(variable.name));
3691
3722
  },
3692
3723
  onMouseEnter: () => {
3693
- setHighlightedIndex(currentCumulativeMenuIndex);
3724
+ setHighlightedIndex(myCumulativeIndex);
3694
3725
  },
3726
+ css: menuItemTextGroup,
3695
3727
  children: [
3696
- /* @__PURE__ */ jsx31("div", { children: (_a2 = variable.displayName) != null ? _a2 : variable.name }),
3697
- variable.helpText ? /* @__PURE__ */ jsx31(Caption, { children: variable.helpText }) : null
3728
+ /* @__PURE__ */ jsx31("span", { children: (_a2 = variable.displayName) != null ? _a2 : variable.name }),
3729
+ variable.helpText ? /* @__PURE__ */ jsx31("small", { css: smallText, children: variable.helpText }) : null
3698
3730
  ]
3699
3731
  },
3700
3732
  variable.name
@@ -3719,40 +3751,11 @@ init_emotion_jsx_shim();
3719
3751
  import { Menu as Menu2, MenuGroup as MenuGroup2, MenuItem as MenuItem3, MenuItemSeparator as MenuItemSeparator2 } from "@uniformdev/design-system";
3720
3752
  import { useEffect as useEffect8, useRef as useRef8, useState as useState9 } from "react";
3721
3753
  import { CgUsbC } from "react-icons/cg";
3722
-
3723
- // src/components/Variables/styles/InsertVariableMenu.styles.ts
3724
- init_emotion_jsx_shim();
3725
- import { css as css22 } from "@emotion/react";
3726
- var menuBtn2 = css22`
3727
- background: none;
3728
- border: none;
3729
- color: var(--gray-500);
3730
- padding: 0;
3731
- `;
3732
- var menuItemTextGroup = css22`
3733
- align-items: flex-start;
3734
- display: flex;
3735
- flex-direction: column;
3736
- gap: 0;
3737
- line-height: 1em;
3738
- `;
3739
- var smallText = css22`
3740
- font-size: var(--fs-xs);
3741
- color: var(--gray-500);
3742
- `;
3743
- var variablesTipText = css22`
3744
- ${smallText}
3745
- color: var(--gray-500);
3746
- padding: 0 var(--spacing-sm);
3747
- `;
3748
-
3749
- // src/components/Variables/SelectVariableMenu.tsx
3750
3754
  import { Fragment as Fragment5, jsx as jsx32, jsxs as jsxs19 } from "@emotion/react/jsx-runtime";
3751
3755
  var SelectVariableMenu = ({
3752
3756
  onSelectVariable,
3753
3757
  onResetVariables,
3754
3758
  showAddVariableMenuOption = false,
3755
- forceVisible,
3756
3759
  buttonCss,
3757
3760
  buttonProps,
3758
3761
  tip
@@ -3774,7 +3777,6 @@ var SelectVariableMenu = ({
3774
3777
  Menu2,
3775
3778
  {
3776
3779
  placement: "bottom-start",
3777
- forceVisible,
3778
3780
  menuTrigger: /* @__PURE__ */ jsx32(
3779
3781
  "button",
3780
3782
  {
@@ -4072,7 +4074,7 @@ function InputVariables({
4072
4074
  infoMessage,
4073
4075
  "data-test-id": dataTestId
4074
4076
  }) {
4075
- const { variables, readOnly } = useVariables(true);
4077
+ const { variables } = useVariables(true);
4076
4078
  const [finalId] = React11.useState(id != null ? id : () => v43());
4077
4079
  const hasVariablesInValue = getReferencedVariables(value).length > 0;
4078
4080
  const [hadVariablesInValue, setHadVariablesInValue] = React11.useState(hasVariablesInValue);
@@ -4081,7 +4083,7 @@ function InputVariables({
4081
4083
  setHadVariablesInValue(true);
4082
4084
  }
4083
4085
  }, [hasVariablesInValue]);
4084
- const disableVariablesForReals = disableVariables || Object.keys(variables).length === 0 && !showAddVariableMenuOption || readOnly;
4086
+ const disableVariablesForReals = disableVariables || Object.keys(variables).length === 0 && !showAddVariableMenuOption;
4085
4087
  const disableInlineVariablesForReals = disableVariablesForReals || disableInlineMenu;
4086
4088
  const sharedMenuProps = useMemo8(
4087
4089
  () => ({
@@ -4102,7 +4104,7 @@ function InputVariables({
4102
4104
  "data-text-value": value
4103
4105
  }
4104
4106
  ) }),
4105
- caption ? /* @__PURE__ */ jsx36(Caption2, { children: caption }) : null,
4107
+ caption ? /* @__PURE__ */ jsx36(Caption, { children: caption }) : null,
4106
4108
  errorMessage ? /* @__PURE__ */ jsx36(ErrorMessage, { message: errorMessage }) : null,
4107
4109
  warningMessage ? /* @__PURE__ */ jsx36(WarningMessage, { message: warningMessage }) : null,
4108
4110
  infoMessage ? /* @__PURE__ */ jsx36(InfoMessage, { message: infoMessage }) : null
package/dist/index.js CHANGED
@@ -3262,17 +3262,43 @@ var import_lexical4 = require("lexical");
3262
3262
 
3263
3263
  // src/components/Variables/composer/VariablesPlugin.tsx
3264
3264
  init_emotion_jsx_shim();
3265
- var import_react34 = require("@emotion/react");
3265
+ var import_react35 = require("@emotion/react");
3266
3266
  var import_LexicalComposerContext2 = require("@lexical/react/LexicalComposerContext");
3267
3267
  var import_LexicalTypeaheadMenuPlugin = require("@lexical/react/LexicalTypeaheadMenuPlugin");
3268
3268
  var import_design_system16 = require("@uniformdev/design-system");
3269
3269
  var import_lexical3 = require("lexical");
3270
- var import_react35 = require("react");
3270
+ var import_react36 = require("react");
3271
3271
  var import_react_dom = require("react-dom");
3272
3272
 
3273
+ // src/components/Variables/styles/InsertVariableMenu.styles.ts
3274
+ init_emotion_jsx_shim();
3275
+ var import_react31 = require("@emotion/react");
3276
+ var menuBtn2 = import_react31.css`
3277
+ background: none;
3278
+ border: none;
3279
+ color: var(--gray-500);
3280
+ padding: 0;
3281
+ `;
3282
+ var menuItemTextGroup = import_react31.css`
3283
+ align-items: flex-start;
3284
+ display: flex;
3285
+ flex-direction: column;
3286
+ gap: 0;
3287
+ line-height: 1em;
3288
+ `;
3289
+ var smallText = import_react31.css`
3290
+ font-size: var(--fs-xs);
3291
+ color: var(--gray-500);
3292
+ `;
3293
+ var variablesTipText = import_react31.css`
3294
+ ${smallText}
3295
+ color: var(--gray-500);
3296
+ padding: 0 var(--spacing-sm);
3297
+ `;
3298
+
3273
3299
  // src/components/Variables/useOnVariableUpdated.ts
3274
3300
  init_emotion_jsx_shim();
3275
- var import_react32 = require("react");
3301
+ var import_react33 = require("react");
3276
3302
 
3277
3303
  // src/components/Variables/VariablesProvider.tsx
3278
3304
  init_emotion_jsx_shim();
@@ -3288,13 +3314,13 @@ var import_zod2 = require("zod");
3288
3314
 
3289
3315
  // src/components/Variables/styles/VariableEditor.styles.ts
3290
3316
  init_emotion_jsx_shim();
3291
- var import_react31 = require("@emotion/react");
3292
- var variablesFormContainer = import_react31.css`
3317
+ var import_react32 = require("@emotion/react");
3318
+ var variablesFormContainer = import_react32.css`
3293
3319
  > * {
3294
3320
  margin: var(--spacing-base) 0 0;
3295
3321
  }
3296
3322
  `;
3297
- var variablesFormBtnGroup = import_react31.css`
3323
+ var variablesFormBtnGroup = import_react32.css`
3298
3324
  display: flex;
3299
3325
  gap: var(--spacing-sm);
3300
3326
  `;
@@ -3434,7 +3460,8 @@ function VariablesProvider({
3434
3460
  variables: value,
3435
3461
  isEditing: typeof editing !== "undefined",
3436
3462
  events,
3437
- canDispatch: true
3463
+ canDispatch: true,
3464
+ readOnly
3438
3465
  };
3439
3466
  return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(VariablesContext.Provider, { value: contextValue, children: [
3440
3467
  children,
@@ -3483,7 +3510,7 @@ function flattenVariables(variables) {
3483
3510
  // src/components/Variables/useOnVariableUpdated.ts
3484
3511
  function useOnVariableUpdated(fn2, disabled) {
3485
3512
  const { variables, events } = useVariables();
3486
- (0, import_react32.useEffect)(() => {
3513
+ (0, import_react33.useEffect)(() => {
3487
3514
  if (disabled) {
3488
3515
  return;
3489
3516
  }
@@ -3538,7 +3565,7 @@ function variablesToGroupedList(variables) {
3538
3565
  init_emotion_jsx_shim();
3539
3566
  var import_design_system15 = require("@uniformdev/design-system");
3540
3567
  var import_lexical2 = require("lexical");
3541
- var import_react33 = require("react");
3568
+ var import_react34 = require("react");
3542
3569
  var import_jsx_runtime30 = require("@emotion/react/jsx-runtime");
3543
3570
  var VariableNode = class extends import_lexical2.DecoratorNode {
3544
3571
  constructor(reference, state, key) {
@@ -3598,7 +3625,7 @@ var VariableNode = class extends import_lexical2.DecoratorNode {
3598
3625
  */
3599
3626
  decorate(editor) {
3600
3627
  const { displayName, hasClickEvent, referenceIsValid } = this.__state;
3601
- const Wrapper = referenceIsValid ? import_react33.Fragment : UndefinedVariableReference;
3628
+ const Wrapper = referenceIsValid ? import_react34.Fragment : UndefinedVariableReference;
3602
3629
  return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
3603
3630
  import_design_system15.Chip,
3604
3631
  {
@@ -3675,21 +3702,22 @@ function VariablesPlugin({
3675
3702
  const [editor] = (0, import_LexicalComposerContext2.useLexicalComposerContext)();
3676
3703
  const { variables, dispatch, isEditing, canDispatch, readOnly } = useVariables();
3677
3704
  const canEditVariable = canDispatch && enableEditingVariables && !readOnly;
3678
- const [openedAdd, setOpenedAdd] = (0, import_react35.useState)(false);
3705
+ const canAddVariable = canDispatch && showAddVariableMenuOption && !readOnly;
3706
+ const [openedAdd, setOpenedAdd] = (0, import_react36.useState)(false);
3679
3707
  useOnVariableUpdated((varName) => {
3680
3708
  editor.update(() => {
3681
3709
  editor.dispatchCommand(INSERT_VARIABLE_COMMAND, { reference: varName });
3682
3710
  });
3683
3711
  }, !openedAdd);
3684
- (0, import_react35.useEffect)(() => {
3712
+ (0, import_react36.useEffect)(() => {
3685
3713
  if (openedAdd && !isEditing) {
3686
3714
  setOpenedAdd(false);
3687
3715
  }
3688
3716
  }, [isEditing, openedAdd]);
3689
- const [queryString, setQueryString] = (0, import_react35.useState)(null);
3690
- const { groupedVariables, menuOptions } = (0, import_react35.useMemo)(() => {
3717
+ const [queryString, setQueryString] = (0, import_react36.useState)(null);
3718
+ const { groupedVariables, menuOptions } = (0, import_react36.useMemo)(() => {
3691
3719
  const groupedVariables2 = variablesToGroupedList(variables);
3692
- if (showAddVariableMenuOption) {
3720
+ if (canAddVariable) {
3693
3721
  groupedVariables2.push({
3694
3722
  name: SOURCE_SEPARATOR,
3695
3723
  variables: [{ name: ADD_VARIABLE_OPTION, displayName: "Add\u2026", default: "" }]
@@ -3702,8 +3730,8 @@ function VariablesPlugin({
3702
3730
  })
3703
3731
  );
3704
3732
  return { menuOptions: menuOptions2, groupedVariables: groupedVariables2 };
3705
- }, [variables, showAddVariableMenuOption]);
3706
- const { filteredGroupedVariables, filteredMenuOptions } = (0, import_react35.useMemo)(() => {
3733
+ }, [variables, canAddVariable]);
3734
+ const { filteredGroupedVariables, filteredMenuOptions } = (0, import_react36.useMemo)(() => {
3707
3735
  if (!queryString) {
3708
3736
  return {
3709
3737
  filteredGroupedVariables: groupedVariables,
@@ -3723,7 +3751,7 @@ function VariablesPlugin({
3723
3751
  )
3724
3752
  };
3725
3753
  }, [queryString, groupedVariables, menuOptions]);
3726
- const onSelectOption = (0, import_react35.useCallback)(
3754
+ const onSelectOption = (0, import_react36.useCallback)(
3727
3755
  (selectedOption, nodeToReplace, closeMenu) => {
3728
3756
  if (selectedOption.key === ADD_VARIABLE_OPTION) {
3729
3757
  setOpenedAdd(true);
@@ -3750,7 +3778,7 @@ function VariablesPlugin({
3750
3778
  },
3751
3779
  [editor, queryString, variables, canEditVariable]
3752
3780
  );
3753
- (0, import_react35.useEffect)(() => {
3781
+ (0, import_react36.useEffect)(() => {
3754
3782
  editor.registerCommand(
3755
3783
  EDIT_VARIABLE_COMMAND,
3756
3784
  ({ reference }) => {
@@ -3778,7 +3806,7 @@ function VariablesPlugin({
3778
3806
  import_lexical3.COMMAND_PRIORITY_NORMAL
3779
3807
  );
3780
3808
  }, [editor, disableVariables, variables, canDispatch, dispatch, canEditVariable, readOnly]);
3781
- (0, import_react35.useEffect)(() => {
3809
+ (0, import_react36.useEffect)(() => {
3782
3810
  editor.update(() => {
3783
3811
  (0, import_lexical3.$nodesOfType)(VariableNode).forEach((variableNode) => {
3784
3812
  const targetVar = variables[variableNode.reference];
@@ -3809,12 +3837,14 @@ function VariablesPlugin({
3809
3837
  /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3810
3838
  "div",
3811
3839
  {
3812
- css: import_react34.css`
3840
+ css: import_react35.css`
3813
3841
  box-shadow: var(--shadow-base);
3814
3842
  border-radius: var(--rounded-base);
3815
3843
  background: var(--gray-50);
3816
3844
  display: flex;
3817
3845
  flex-direction: column;
3846
+ // 1em = text height, spacing-sm for padding, to prevent menu overlapping text entry
3847
+ margin-top: calc(1em + var(--spacing-sm));
3818
3848
  min-width: 250px;
3819
3849
  padding: var(--spacing-sm);
3820
3850
  outline: none;
@@ -3829,24 +3859,26 @@ function VariablesPlugin({
3829
3859
  {
3830
3860
  title: group.name === SOURCE_SEPARATOR ? "" : (_a = group.name) != null ? _a : "",
3831
3861
  children: [
3832
- group.name === SOURCE_SEPARATOR ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_design_system16.MenuItemSeparator, {}) : null,
3862
+ group.name === SOURCE_SEPARATOR && currentCumulativeMenuIndex > 0 ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_design_system16.MenuItemSeparator, {}) : null,
3833
3863
  group.variables.map((variable) => {
3834
3864
  var _a2;
3835
3865
  currentCumulativeMenuIndex++;
3866
+ const myCumulativeIndex = currentCumulativeMenuIndex;
3836
3867
  return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
3837
3868
  import_design_system16.MenuItem,
3838
3869
  {
3839
- active: selectedIndex === currentCumulativeMenuIndex,
3870
+ active: selectedIndex === myCumulativeIndex,
3840
3871
  onClick: () => {
3841
- setHighlightedIndex(currentCumulativeMenuIndex);
3872
+ setHighlightedIndex(myCumulativeIndex);
3842
3873
  selectOptionAndCleanUp(new import_LexicalTypeaheadMenuPlugin.MenuOption(variable.name));
3843
3874
  },
3844
3875
  onMouseEnter: () => {
3845
- setHighlightedIndex(currentCumulativeMenuIndex);
3876
+ setHighlightedIndex(myCumulativeIndex);
3846
3877
  },
3878
+ css: menuItemTextGroup,
3847
3879
  children: [
3848
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { children: (_a2 = variable.displayName) != null ? _a2 : variable.name }),
3849
- variable.helpText ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_design_system16.Caption, { children: variable.helpText }) : null
3880
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { children: (_a2 = variable.displayName) != null ? _a2 : variable.name }),
3881
+ variable.helpText ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("small", { css: smallText, children: variable.helpText }) : null
3850
3882
  ]
3851
3883
  },
3852
3884
  variable.name
@@ -3871,40 +3903,11 @@ init_emotion_jsx_shim();
3871
3903
  var import_design_system17 = require("@uniformdev/design-system");
3872
3904
  var import_react37 = require("react");
3873
3905
  var import_cg5 = require("react-icons/cg");
3874
-
3875
- // src/components/Variables/styles/InsertVariableMenu.styles.ts
3876
- init_emotion_jsx_shim();
3877
- var import_react36 = require("@emotion/react");
3878
- var menuBtn2 = import_react36.css`
3879
- background: none;
3880
- border: none;
3881
- color: var(--gray-500);
3882
- padding: 0;
3883
- `;
3884
- var menuItemTextGroup = import_react36.css`
3885
- align-items: flex-start;
3886
- display: flex;
3887
- flex-direction: column;
3888
- gap: 0;
3889
- line-height: 1em;
3890
- `;
3891
- var smallText = import_react36.css`
3892
- font-size: var(--fs-xs);
3893
- color: var(--gray-500);
3894
- `;
3895
- var variablesTipText = import_react36.css`
3896
- ${smallText}
3897
- color: var(--gray-500);
3898
- padding: 0 var(--spacing-sm);
3899
- `;
3900
-
3901
- // src/components/Variables/SelectVariableMenu.tsx
3902
3906
  var import_jsx_runtime32 = require("@emotion/react/jsx-runtime");
3903
3907
  var SelectVariableMenu = ({
3904
3908
  onSelectVariable,
3905
3909
  onResetVariables,
3906
3910
  showAddVariableMenuOption = false,
3907
- forceVisible,
3908
3911
  buttonCss,
3909
3912
  buttonProps,
3910
3913
  tip
@@ -3926,7 +3929,6 @@ var SelectVariableMenu = ({
3926
3929
  import_design_system17.Menu,
3927
3930
  {
3928
3931
  placement: "bottom-start",
3929
- forceVisible,
3930
3932
  menuTrigger: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
3931
3933
  "button",
3932
3934
  {
@@ -4221,7 +4223,7 @@ function InputVariables({
4221
4223
  infoMessage,
4222
4224
  "data-test-id": dataTestId
4223
4225
  }) {
4224
- const { variables, readOnly } = useVariables(true);
4226
+ const { variables } = useVariables(true);
4225
4227
  const [finalId] = React11.useState(id != null ? id : () => (0, import_uuid3.v4)());
4226
4228
  const hasVariablesInValue = getReferencedVariables(value).length > 0;
4227
4229
  const [hadVariablesInValue, setHadVariablesInValue] = React11.useState(hasVariablesInValue);
@@ -4230,7 +4232,7 @@ function InputVariables({
4230
4232
  setHadVariablesInValue(true);
4231
4233
  }
4232
4234
  }, [hasVariablesInValue]);
4233
- const disableVariablesForReals = disableVariables || Object.keys(variables).length === 0 && !showAddVariableMenuOption || readOnly;
4235
+ const disableVariablesForReals = disableVariables || Object.keys(variables).length === 0 && !showAddVariableMenuOption;
4234
4236
  const disableInlineVariablesForReals = disableVariablesForReals || disableInlineMenu;
4235
4237
  const sharedMenuProps = (0, import_react41.useMemo)(
4236
4238
  () => ({
package/dist/index.mjs CHANGED
@@ -2921,7 +2921,7 @@ function useMeshLocation(expectedLocation) {
2921
2921
 
2922
2922
  // src/components/Variables/InputVariables.tsx
2923
2923
  init_emotion_jsx_shim();
2924
- import { Caption as Caption2, ErrorMessage, InfoMessage, WarningMessage } from "@uniformdev/design-system";
2924
+ import { Caption, ErrorMessage, InfoMessage, WarningMessage } from "@uniformdev/design-system";
2925
2925
  import * as React11 from "react";
2926
2926
  import { useMemo as useMemo8 } from "react";
2927
2927
  import { v4 as v43 } from "uuid";
@@ -3107,17 +3107,43 @@ import { CLEAR_EDITOR_COMMAND } from "lexical";
3107
3107
 
3108
3108
  // src/components/Variables/composer/VariablesPlugin.tsx
3109
3109
  init_emotion_jsx_shim();
3110
- import { css as css21 } from "@emotion/react";
3110
+ import { css as css22 } from "@emotion/react";
3111
3111
  import { useLexicalComposerContext as useLexicalComposerContext2 } from "@lexical/react/LexicalComposerContext";
3112
3112
  import {
3113
3113
  LexicalTypeaheadMenuPlugin,
3114
3114
  MenuOption
3115
3115
  } from "@lexical/react/LexicalTypeaheadMenuPlugin";
3116
- import { Caption, MenuGroup, MenuItem as MenuItem2, MenuItemSeparator } from "@uniformdev/design-system";
3116
+ import { MenuGroup, MenuItem as MenuItem2, MenuItemSeparator } from "@uniformdev/design-system";
3117
3117
  import { $insertNodes, $nodesOfType, COMMAND_PRIORITY_NORMAL, createCommand } from "lexical";
3118
3118
  import { useCallback, useEffect as useEffect7, useMemo as useMemo6, useState as useState8 } from "react";
3119
3119
  import { createPortal } from "react-dom";
3120
3120
 
3121
+ // src/components/Variables/styles/InsertVariableMenu.styles.ts
3122
+ init_emotion_jsx_shim();
3123
+ import { css as css20 } from "@emotion/react";
3124
+ var menuBtn2 = css20`
3125
+ background: none;
3126
+ border: none;
3127
+ color: var(--gray-500);
3128
+ padding: 0;
3129
+ `;
3130
+ var menuItemTextGroup = css20`
3131
+ align-items: flex-start;
3132
+ display: flex;
3133
+ flex-direction: column;
3134
+ gap: 0;
3135
+ line-height: 1em;
3136
+ `;
3137
+ var smallText = css20`
3138
+ font-size: var(--fs-xs);
3139
+ color: var(--gray-500);
3140
+ `;
3141
+ var variablesTipText = css20`
3142
+ ${smallText}
3143
+ color: var(--gray-500);
3144
+ padding: 0 var(--spacing-sm);
3145
+ `;
3146
+
3121
3147
  // src/components/Variables/useOnVariableUpdated.ts
3122
3148
  init_emotion_jsx_shim();
3123
3149
  import { useEffect as useEffect6 } from "react";
@@ -3136,13 +3162,13 @@ import { z } from "zod";
3136
3162
 
3137
3163
  // src/components/Variables/styles/VariableEditor.styles.ts
3138
3164
  init_emotion_jsx_shim();
3139
- import { css as css20 } from "@emotion/react";
3140
- var variablesFormContainer = css20`
3165
+ import { css as css21 } from "@emotion/react";
3166
+ var variablesFormContainer = css21`
3141
3167
  > * {
3142
3168
  margin: var(--spacing-base) 0 0;
3143
3169
  }
3144
3170
  `;
3145
- var variablesFormBtnGroup = css20`
3171
+ var variablesFormBtnGroup = css21`
3146
3172
  display: flex;
3147
3173
  gap: var(--spacing-sm);
3148
3174
  `;
@@ -3282,7 +3308,8 @@ function VariablesProvider({
3282
3308
  variables: value,
3283
3309
  isEditing: typeof editing !== "undefined",
3284
3310
  events,
3285
- canDispatch: true
3311
+ canDispatch: true,
3312
+ readOnly
3286
3313
  };
3287
3314
  return /* @__PURE__ */ jsxs17(VariablesContext.Provider, { value: contextValue, children: [
3288
3315
  children,
@@ -3523,6 +3550,7 @@ function VariablesPlugin({
3523
3550
  const [editor] = useLexicalComposerContext2();
3524
3551
  const { variables, dispatch, isEditing, canDispatch, readOnly } = useVariables();
3525
3552
  const canEditVariable = canDispatch && enableEditingVariables && !readOnly;
3553
+ const canAddVariable = canDispatch && showAddVariableMenuOption && !readOnly;
3526
3554
  const [openedAdd, setOpenedAdd] = useState8(false);
3527
3555
  useOnVariableUpdated((varName) => {
3528
3556
  editor.update(() => {
@@ -3537,7 +3565,7 @@ function VariablesPlugin({
3537
3565
  const [queryString, setQueryString] = useState8(null);
3538
3566
  const { groupedVariables, menuOptions } = useMemo6(() => {
3539
3567
  const groupedVariables2 = variablesToGroupedList(variables);
3540
- if (showAddVariableMenuOption) {
3568
+ if (canAddVariable) {
3541
3569
  groupedVariables2.push({
3542
3570
  name: SOURCE_SEPARATOR,
3543
3571
  variables: [{ name: ADD_VARIABLE_OPTION, displayName: "Add\u2026", default: "" }]
@@ -3550,7 +3578,7 @@ function VariablesPlugin({
3550
3578
  })
3551
3579
  );
3552
3580
  return { menuOptions: menuOptions2, groupedVariables: groupedVariables2 };
3553
- }, [variables, showAddVariableMenuOption]);
3581
+ }, [variables, canAddVariable]);
3554
3582
  const { filteredGroupedVariables, filteredMenuOptions } = useMemo6(() => {
3555
3583
  if (!queryString) {
3556
3584
  return {
@@ -3657,12 +3685,14 @@ function VariablesPlugin({
3657
3685
  /* @__PURE__ */ jsx31(
3658
3686
  "div",
3659
3687
  {
3660
- css: css21`
3688
+ css: css22`
3661
3689
  box-shadow: var(--shadow-base);
3662
3690
  border-radius: var(--rounded-base);
3663
3691
  background: var(--gray-50);
3664
3692
  display: flex;
3665
3693
  flex-direction: column;
3694
+ // 1em = text height, spacing-sm for padding, to prevent menu overlapping text entry
3695
+ margin-top: calc(1em + var(--spacing-sm));
3666
3696
  min-width: 250px;
3667
3697
  padding: var(--spacing-sm);
3668
3698
  outline: none;
@@ -3677,24 +3707,26 @@ function VariablesPlugin({
3677
3707
  {
3678
3708
  title: group.name === SOURCE_SEPARATOR ? "" : (_a = group.name) != null ? _a : "",
3679
3709
  children: [
3680
- group.name === SOURCE_SEPARATOR ? /* @__PURE__ */ jsx31(MenuItemSeparator, {}) : null,
3710
+ group.name === SOURCE_SEPARATOR && currentCumulativeMenuIndex > 0 ? /* @__PURE__ */ jsx31(MenuItemSeparator, {}) : null,
3681
3711
  group.variables.map((variable) => {
3682
3712
  var _a2;
3683
3713
  currentCumulativeMenuIndex++;
3714
+ const myCumulativeIndex = currentCumulativeMenuIndex;
3684
3715
  return /* @__PURE__ */ jsxs18(
3685
3716
  MenuItem2,
3686
3717
  {
3687
- active: selectedIndex === currentCumulativeMenuIndex,
3718
+ active: selectedIndex === myCumulativeIndex,
3688
3719
  onClick: () => {
3689
- setHighlightedIndex(currentCumulativeMenuIndex);
3720
+ setHighlightedIndex(myCumulativeIndex);
3690
3721
  selectOptionAndCleanUp(new MenuOption(variable.name));
3691
3722
  },
3692
3723
  onMouseEnter: () => {
3693
- setHighlightedIndex(currentCumulativeMenuIndex);
3724
+ setHighlightedIndex(myCumulativeIndex);
3694
3725
  },
3726
+ css: menuItemTextGroup,
3695
3727
  children: [
3696
- /* @__PURE__ */ jsx31("div", { children: (_a2 = variable.displayName) != null ? _a2 : variable.name }),
3697
- variable.helpText ? /* @__PURE__ */ jsx31(Caption, { children: variable.helpText }) : null
3728
+ /* @__PURE__ */ jsx31("span", { children: (_a2 = variable.displayName) != null ? _a2 : variable.name }),
3729
+ variable.helpText ? /* @__PURE__ */ jsx31("small", { css: smallText, children: variable.helpText }) : null
3698
3730
  ]
3699
3731
  },
3700
3732
  variable.name
@@ -3719,40 +3751,11 @@ init_emotion_jsx_shim();
3719
3751
  import { Menu as Menu2, MenuGroup as MenuGroup2, MenuItem as MenuItem3, MenuItemSeparator as MenuItemSeparator2 } from "@uniformdev/design-system";
3720
3752
  import { useEffect as useEffect8, useRef as useRef8, useState as useState9 } from "react";
3721
3753
  import { CgUsbC } from "react-icons/cg";
3722
-
3723
- // src/components/Variables/styles/InsertVariableMenu.styles.ts
3724
- init_emotion_jsx_shim();
3725
- import { css as css22 } from "@emotion/react";
3726
- var menuBtn2 = css22`
3727
- background: none;
3728
- border: none;
3729
- color: var(--gray-500);
3730
- padding: 0;
3731
- `;
3732
- var menuItemTextGroup = css22`
3733
- align-items: flex-start;
3734
- display: flex;
3735
- flex-direction: column;
3736
- gap: 0;
3737
- line-height: 1em;
3738
- `;
3739
- var smallText = css22`
3740
- font-size: var(--fs-xs);
3741
- color: var(--gray-500);
3742
- `;
3743
- var variablesTipText = css22`
3744
- ${smallText}
3745
- color: var(--gray-500);
3746
- padding: 0 var(--spacing-sm);
3747
- `;
3748
-
3749
- // src/components/Variables/SelectVariableMenu.tsx
3750
3754
  import { Fragment as Fragment5, jsx as jsx32, jsxs as jsxs19 } from "@emotion/react/jsx-runtime";
3751
3755
  var SelectVariableMenu = ({
3752
3756
  onSelectVariable,
3753
3757
  onResetVariables,
3754
3758
  showAddVariableMenuOption = false,
3755
- forceVisible,
3756
3759
  buttonCss,
3757
3760
  buttonProps,
3758
3761
  tip
@@ -3774,7 +3777,6 @@ var SelectVariableMenu = ({
3774
3777
  Menu2,
3775
3778
  {
3776
3779
  placement: "bottom-start",
3777
- forceVisible,
3778
3780
  menuTrigger: /* @__PURE__ */ jsx32(
3779
3781
  "button",
3780
3782
  {
@@ -4072,7 +4074,7 @@ function InputVariables({
4072
4074
  infoMessage,
4073
4075
  "data-test-id": dataTestId
4074
4076
  }) {
4075
- const { variables, readOnly } = useVariables(true);
4077
+ const { variables } = useVariables(true);
4076
4078
  const [finalId] = React11.useState(id != null ? id : () => v43());
4077
4079
  const hasVariablesInValue = getReferencedVariables(value).length > 0;
4078
4080
  const [hadVariablesInValue, setHadVariablesInValue] = React11.useState(hasVariablesInValue);
@@ -4081,7 +4083,7 @@ function InputVariables({
4081
4083
  setHadVariablesInValue(true);
4082
4084
  }
4083
4085
  }, [hasVariablesInValue]);
4084
- const disableVariablesForReals = disableVariables || Object.keys(variables).length === 0 && !showAddVariableMenuOption || readOnly;
4086
+ const disableVariablesForReals = disableVariables || Object.keys(variables).length === 0 && !showAddVariableMenuOption;
4085
4087
  const disableInlineVariablesForReals = disableVariablesForReals || disableInlineMenu;
4086
4088
  const sharedMenuProps = useMemo8(
4087
4089
  () => ({
@@ -4102,7 +4104,7 @@ function InputVariables({
4102
4104
  "data-text-value": value
4103
4105
  }
4104
4106
  ) }),
4105
- caption ? /* @__PURE__ */ jsx36(Caption2, { children: caption }) : null,
4107
+ caption ? /* @__PURE__ */ jsx36(Caption, { children: caption }) : null,
4106
4108
  errorMessage ? /* @__PURE__ */ jsx36(ErrorMessage, { message: errorMessage }) : null,
4107
4109
  warningMessage ? /* @__PURE__ */ jsx36(WarningMessage, { message: warningMessage }) : null,
4108
4110
  infoMessage ? /* @__PURE__ */ jsx36(InfoMessage, { message: infoMessage }) : null
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/mesh-sdk-react",
3
- "version": "19.23.1-alpha.12+669adf812",
3
+ "version": "19.23.1-alpha.13+9373933c0",
4
4
  "description": "Uniform Mesh Framework SDK for React",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -45,8 +45,8 @@
45
45
  "dependencies": {
46
46
  "@hookform/resolvers": "^3.0.1",
47
47
  "@lexical/react": "^0.11.0",
48
- "@uniformdev/design-system": "19.23.1-alpha.12+669adf812",
49
- "@uniformdev/mesh-sdk": "19.23.1-alpha.12+669adf812",
48
+ "@uniformdev/design-system": "19.23.1-alpha.13+9373933c0",
49
+ "@uniformdev/mesh-sdk": "19.23.1-alpha.13+9373933c0",
50
50
  "lexical": "^0.11.0",
51
51
  "mitt": "^3.0.0",
52
52
  "react-beautiful-dnd": "13.1.1",
@@ -80,5 +80,5 @@
80
80
  "publishConfig": {
81
81
  "access": "public"
82
82
  },
83
- "gitHead": "669adf812df13a7856fb9bc5c4332c77e0697f3f"
83
+ "gitHead": "9373933c0734ad2de988ed99278b61623ddfa920"
84
84
  }