@uniformdev/mesh-sdk-react 20.73.0 → 20.74.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -2347,7 +2347,7 @@ import { AutoFocusPlugin } from "@lexical/react/LexicalAutoFocusPlugin";
2347
2347
  import { ClearEditorPlugin } from "@lexical/react/LexicalClearEditorPlugin";
2348
2348
  import { LexicalComposer } from "@lexical/react/LexicalComposer";
2349
2349
  import { OnChangePlugin } from "@lexical/react/LexicalOnChangePlugin";
2350
- import { useMemo as useMemo9, useRef as useRef5, useState as useState6 } from "react";
2350
+ import { useEffect as useEffect10, useMemo as useMemo9, useRef as useRef5, useState as useState6 } from "react";
2351
2351
 
2352
2352
  // src/components/Variables/composer/DisablePlugin.tsx
2353
2353
  import { useLexicalComposerContext as useLexicalComposerContext7 } from "@lexical/react/LexicalComposerContext";
@@ -2374,6 +2374,13 @@ function SingleLineTextPlugin() {
2374
2374
  return null;
2375
2375
  }
2376
2376
 
2377
+ // src/components/Variables/toolbox/useVariablesComposerFlushPending.ts
2378
+ import { createContext as createContext5, useContext as useContext5 } from "react";
2379
+ var VariablesComposerFlushPendingContext = createContext5(false);
2380
+ function useVariablesComposerFlushPending() {
2381
+ return useContext5(VariablesComposerFlushPendingContext);
2382
+ }
2383
+
2377
2384
  // src/components/Variables/toolbox/VariablesComposer.tsx
2378
2385
  import { Fragment as Fragment5, jsx as jsx26, jsxs as jsxs10 } from "@emotion/react/jsx-runtime";
2379
2386
  function VariablesComposer(props) {
@@ -2388,6 +2395,7 @@ function VariablesComposer(props) {
2388
2395
  ...variablesPluginProps
2389
2396
  } = props;
2390
2397
  const [lastEmittedValue, setLastEmittedValue] = useState6(value);
2398
+ const [flushPending, setFlushPending] = useState6(false);
2391
2399
  const editorConfig = useMemo9(
2392
2400
  () => ({
2393
2401
  namespace: "uniform",
@@ -2402,6 +2410,24 @@ function VariablesComposer(props) {
2402
2410
  );
2403
2411
  const editorState = useRef5(void 0);
2404
2412
  const updateTimeout = useRef5(void 0);
2413
+ const flushDepsRef = useRef5({ onChange, lastEmittedValue });
2414
+ flushDepsRef.current = { onChange, lastEmittedValue };
2415
+ useEffect10(
2416
+ () => () => {
2417
+ if (!updateTimeout.current) {
2418
+ return;
2419
+ }
2420
+ clearTimeout(updateTimeout.current);
2421
+ const { onChange: emit, lastEmittedValue: lastEmitted } = flushDepsRef.current;
2422
+ const valueToEmit = editorState.current ? serializeVariablesEditorState(editorState.current) : void 0;
2423
+ const shouldEmit = editorState.current != null && valueToEmit !== lastEmitted;
2424
+ if (!shouldEmit) {
2425
+ return;
2426
+ }
2427
+ queueMicrotask(() => emit(valueToEmit));
2428
+ },
2429
+ []
2430
+ );
2405
2431
  if (typeof document === "undefined") return null;
2406
2432
  return /* @__PURE__ */ jsxs10(LexicalComposer, { initialConfig: editorConfig, children: [
2407
2433
  /* @__PURE__ */ jsx26(
@@ -2413,6 +2439,7 @@ function VariablesComposer(props) {
2413
2439
  if (updateTimeout.current) {
2414
2440
  clearTimeout(updateTimeout.current);
2415
2441
  }
2442
+ setFlushPending(true);
2416
2443
  updateTimeout.current = window.setTimeout(() => {
2417
2444
  if (editorState.current) {
2418
2445
  const valueToEmit = serializeVariablesEditorState(editorState.current);
@@ -2421,6 +2448,8 @@ function VariablesComposer(props) {
2421
2448
  onChange(valueToEmit);
2422
2449
  }
2423
2450
  }
2451
+ setFlushPending(false);
2452
+ updateTimeout.current = void 0;
2424
2453
  }, 400);
2425
2454
  }
2426
2455
  }
@@ -2430,7 +2459,7 @@ function VariablesComposer(props) {
2430
2459
  /* @__PURE__ */ jsx26(VariablesPlugin, { ...variablesPluginProps }),
2431
2460
  /* @__PURE__ */ jsx26(DisablePlugin, { disabled }),
2432
2461
  /* @__PURE__ */ jsx26(Fragment5, { children: autoFocus ? /* @__PURE__ */ jsx26(AutoFocusPlugin, {}) : null }),
2433
- /* @__PURE__ */ jsx26(Fragment5, { children })
2462
+ /* @__PURE__ */ jsx26(VariablesComposerFlushPendingContext.Provider, { value: flushPending, children })
2434
2463
  ] });
2435
2464
  }
2436
2465
 
@@ -2455,18 +2484,27 @@ import {
2455
2484
  CUT_COMMAND,
2456
2485
  PASTE_COMMAND as PASTE_COMMAND2
2457
2486
  } from "lexical";
2458
- import { useEffect as useEffect10 } from "react";
2487
+ import { useEffect as useEffect11 } from "react";
2459
2488
  import { Fragment as Fragment6, jsx as jsx27, jsxs as jsxs11 } from "@emotion/react/jsx-runtime";
2460
2489
  function VariablesComposerInput({
2461
2490
  css: css24,
2462
2491
  placeholder,
2463
2492
  ...contentEditableProps
2464
2493
  }) {
2494
+ const flushPending = useVariablesComposerFlushPending();
2465
2495
  return /* @__PURE__ */ jsxs11("div", { children: [
2466
2496
  /* @__PURE__ */ jsx27(
2467
2497
  PlainTextPlugin,
2468
2498
  {
2469
- contentEditable: /* @__PURE__ */ jsx27(ContentEditable, { ...contentEditableProps, placeholder: null, "aria-placeholder": void 0 }),
2499
+ contentEditable: /* @__PURE__ */ jsx27(
2500
+ ContentEditable,
2501
+ {
2502
+ ...contentEditableProps,
2503
+ "data-flush-pending": flushPending,
2504
+ placeholder: null,
2505
+ "aria-placeholder": void 0
2506
+ }
2507
+ ),
2470
2508
  placeholder: placeholder ? /* @__PURE__ */ jsx27(Fragment6, { children: placeholder }) : null,
2471
2509
  ErrorBoundary: LexicalErrorBoundary
2472
2510
  }
@@ -2477,7 +2515,7 @@ function VariablesComposerInput({
2477
2515
  }
2478
2516
  function RichishCopyAndPastePlugin() {
2479
2517
  const [editor] = useLexicalComposerContext9();
2480
- useEffect10(() => {
2518
+ useEffect11(() => {
2481
2519
  return mergeRegister4(
2482
2520
  editor.registerCommand(
2483
2521
  COPY_COMMAND,
@@ -2794,7 +2832,7 @@ import { useCallback as useCallback4 } from "react";
2794
2832
  import { useLexicalComposerContext as useLexicalComposerContext10 } from "@lexical/react/LexicalComposerContext";
2795
2833
  import { mergeRegister as mergeRegister5 } from "@lexical/utils";
2796
2834
  import { $getNodeByKey as $getNodeByKey3, COMMAND_PRIORITY_HIGH as COMMAND_PRIORITY_HIGH3 } from "lexical";
2797
- import { useEffect as useEffect11, useRef as useRef6 } from "react";
2835
+ import { useEffect as useEffect12, useRef as useRef6 } from "react";
2798
2836
  function OnDisconnectPlugin({
2799
2837
  onDisconnect
2800
2838
  }) {
@@ -2802,7 +2840,7 @@ function OnDisconnectPlugin({
2802
2840
  const { variables } = useVariables(true);
2803
2841
  const variablesRef = useRef6(variables);
2804
2842
  variablesRef.current = variables;
2805
- useEffect11(() => {
2843
+ useEffect12(() => {
2806
2844
  return mergeRegister5(
2807
2845
  editor.registerCommand(
2808
2846
  DISCONNECT_VARIABLE_COMMAND,
@@ -3986,7 +4024,7 @@ function convertRequestDataToDataType(dataType, requestData) {
3986
4024
 
3987
4025
  // src/components/Delegation/DelegationGate.tsx
3988
4026
  import { Callout as Callout3, LoadingOverlay } from "@uniformdev/design-system";
3989
- import { useEffect as useEffect12 } from "react";
4027
+ import { useEffect as useEffect13 } from "react";
3990
4028
 
3991
4029
  // src/components/Delegation/styles/DelegationGate.style.ts
3992
4030
  import { css as css14 } from "@emotion/react";
@@ -4004,7 +4042,7 @@ function DefaultDelegationDisabled() {
4004
4042
  return /* @__PURE__ */ jsx46(Callout3, { type: "caution", title: "Feature unavailable", children: "This app requires permissions that are not currently enabled. Please contact your Uniform administrator to enable identity delegation for this integration." });
4005
4043
  }
4006
4044
  function DefaultDelegationError({ error }) {
4007
- useEffect12(() => {
4045
+ useEffect13(() => {
4008
4046
  console.error("Delegation connection failed", error);
4009
4047
  }, [error]);
4010
4048
  return /* @__PURE__ */ jsx46(Callout3, { type: "error", title: "Connection error", children: /* @__PURE__ */ jsx46("p", { children: "Failed to connect to Uniform. Try again, or contact your administrator if the problem persists." }) });
@@ -4039,7 +4077,7 @@ function DelegationGate({
4039
4077
  }
4040
4078
 
4041
4079
  // src/components/Delegation/DelegationProvider.tsx
4042
- import { useCallback as useCallback5, useEffect as useEffect13, useMemo as useMemo13, useRef as useRef7, useState as useState11 } from "react";
4080
+ import { useCallback as useCallback5, useEffect as useEffect14, useMemo as useMemo13, useRef as useRef7, useState as useState11 } from "react";
4043
4081
  import { jsx as jsx47 } from "@emotion/react/jsx-runtime";
4044
4082
  var DelegationDisabledError = class extends Error {
4045
4083
  constructor() {
@@ -4110,7 +4148,7 @@ function DelegationProvider({
4110
4148
  });
4111
4149
  return acquirePromiseRef.current;
4112
4150
  }, [sdk, onSessionToken, checkActive]);
4113
- useEffect13(() => {
4151
+ useEffect14(() => {
4114
4152
  mountedRef.current = true;
4115
4153
  void acquire().catch(() => {
4116
4154
  });
@@ -4137,7 +4175,7 @@ function DelegationProvider({
4137
4175
  } catch (e) {
4138
4176
  }
4139
4177
  }, [checkActive, acquire]);
4140
- useEffect13(() => {
4178
+ useEffect14(() => {
4141
4179
  if (!revalidateOnFocus) {
4142
4180
  return;
4143
4181
  }
@@ -4172,12 +4210,12 @@ import { IconsProvider, LoadingIndicator as LoadingIndicator2, Theme as Theme2 }
4172
4210
 
4173
4211
  // src/hooks/useInitializeUniformMeshSdk.ts
4174
4212
  import { initializeUniformMeshSDK } from "@uniformdev/mesh-sdk";
4175
- import { useEffect as useEffect14, useRef as useRef8, useState as useState12 } from "react";
4213
+ import { useEffect as useEffect15, useRef as useRef8, useState as useState12 } from "react";
4176
4214
  var useInitializeUniformMeshSdk = ({ autoResizingDisabled } = {}) => {
4177
4215
  const [error, setError] = useState12();
4178
4216
  const [sdk, setSdk] = useState12();
4179
4217
  const initializationInProgress = useRef8(false);
4180
- useEffect14(
4218
+ useEffect15(
4181
4219
  () => {
4182
4220
  if (typeof window === "undefined" || sdk) {
4183
4221
  return;
@@ -4265,15 +4303,15 @@ import { Callout as Callout4, Container, ScrollableList, VerticalRhythm as Verti
4265
4303
  // src/components/ObjectSearch/hooks/ObjectSearchContext.tsx
4266
4304
  import { bindVariablesToObject as bindVariablesToObject2 } from "@uniformdev/canvas";
4267
4305
  import {
4268
- createContext as createContext6,
4306
+ createContext as createContext7,
4269
4307
  useCallback as useCallback6,
4270
- useContext as useContext6,
4308
+ useContext as useContext7,
4271
4309
  useDeferredValue,
4272
4310
  useMemo as useMemo14,
4273
4311
  useState as useState13
4274
4312
  } from "react";
4275
4313
  import { jsx as jsx50 } from "@emotion/react/jsx-runtime";
4276
- var ObjectSearchContext = createContext6({
4314
+ var ObjectSearchContext = createContext7({
4277
4315
  onSetQuery: () => {
4278
4316
  },
4279
4317
  onSelectItem: () => {
@@ -4366,7 +4404,7 @@ var ObjectSearchProvider = ({
4366
4404
  return /* @__PURE__ */ jsx50(ObjectSearchContext.Provider, { value, children });
4367
4405
  };
4368
4406
  function useObjectSearchContext() {
4369
- return useContext6(ObjectSearchContext);
4407
+ return useContext7(ObjectSearchContext);
4370
4408
  }
4371
4409
  function bindQuery(query, inputs) {
4372
4410
  const { result, errors } = bindVariablesToObject2({
@@ -5074,7 +5112,7 @@ function ObjectSearchResultList({
5074
5112
 
5075
5113
  // src/components/ObjectSearch/QueryFilter.tsx
5076
5114
  import { DebouncedInputKeywordSearch as DebouncedInputKeywordSearch2, Input as Input4, InputSelect as InputSelect4, VerticalRhythm as VerticalRhythm4 } from "@uniformdev/design-system";
5077
- import { useEffect as useEffect15, useState as useState15 } from "react";
5115
+ import { useEffect as useEffect16, useState as useState15 } from "react";
5078
5116
  import { jsx as jsx59, jsxs as jsxs29 } from "@emotion/react/jsx-runtime";
5079
5117
  var QueryFilter = ({
5080
5118
  requireContentType,
@@ -5114,7 +5152,7 @@ var QueryFilter = ({
5114
5152
  setQueryState((prev) => ({ ...prev, ...value }));
5115
5153
  onSetQuery({ ...query, ...value });
5116
5154
  };
5117
- useEffect15(() => {
5155
+ useEffect16(() => {
5118
5156
  onSetQuery(queryState);
5119
5157
  }, []);
5120
5158
  return /* @__PURE__ */ jsxs29("fieldset", { children: [
@@ -5240,7 +5278,7 @@ var QueryFilter = ({
5240
5278
  };
5241
5279
 
5242
5280
  // src/components/ParamTypeDynamicDataProvider.tsx
5243
- import { useEffect as useEffect16, useMemo as useMemo16, useRef as useRef9 } from "react";
5281
+ import { useEffect as useEffect17, useMemo as useMemo16, useRef as useRef9 } from "react";
5244
5282
  import { jsx as jsx60 } from "@emotion/react/jsx-runtime";
5245
5283
  function ParamTypeDynamicDataProvider(props) {
5246
5284
  const { children } = props;
@@ -5264,7 +5302,7 @@ var JsonMeshVariableEditor = ({
5264
5302
  }) => {
5265
5303
  const sillyRef = useRef9(false);
5266
5304
  const { editConnectedData } = useMeshLocation("paramType");
5267
- useEffect16(() => {
5305
+ useEffect17(() => {
5268
5306
  if (sillyRef.current) {
5269
5307
  return;
5270
5308
  }
@@ -5764,7 +5802,7 @@ var DateEditor = ({
5764
5802
 
5765
5803
  // src/components/SearchAndFilter/editors/DateRangeEditor.tsx
5766
5804
  import { Input as Input6 } from "@uniformdev/design-system";
5767
- import { useEffect as useEffect17, useState as useState17 } from "react";
5805
+ import { useEffect as useEffect18, useState as useState17 } from "react";
5768
5806
  import { useDebounce as useDebounce3 } from "react-use";
5769
5807
 
5770
5808
  // src/components/SearchAndFilter/editors/shared/ErrorContainer.tsx
@@ -5814,7 +5852,7 @@ var DateRangeEditor = ({
5814
5852
  500,
5815
5853
  [minDateValue, maxDateValue]
5816
5854
  );
5817
- useEffect17(() => {
5855
+ useEffect18(() => {
5818
5856
  if (!minDateValue || !maxDateValue) {
5819
5857
  return;
5820
5858
  }
@@ -6028,7 +6066,7 @@ var NumberEditor = ({
6028
6066
 
6029
6067
  // src/components/SearchAndFilter/editors/NumberRangeEditor.tsx
6030
6068
  import { Input as Input8 } from "@uniformdev/design-system";
6031
- import { useEffect as useEffect18, useState as useState19 } from "react";
6069
+ import { useEffect as useEffect19, useState as useState19 } from "react";
6032
6070
  import { useDebounce as useDebounce5 } from "react-use";
6033
6071
  import { Fragment as Fragment13, jsx as jsx67, jsxs as jsxs31 } from "@emotion/react/jsx-runtime";
6034
6072
  var NumberRangeEditor = ({
@@ -6053,7 +6091,7 @@ var NumberRangeEditor = ({
6053
6091
  500,
6054
6092
  [minValue, maxValue]
6055
6093
  );
6056
- useEffect18(() => {
6094
+ useEffect19(() => {
6057
6095
  if (!maxValue && !minValue) {
6058
6096
  return;
6059
6097
  }
@@ -6624,18 +6662,18 @@ import { CgClose } from "@react-icons/all-files/cg/CgClose";
6624
6662
  import { hasReferencedVariables as hasReferencedVariables2 } from "@uniformdev/canvas";
6625
6663
  import { Icon as Icon3, InputKeywordSearch } from "@uniformdev/design-system";
6626
6664
  import { CLEAR_EDITOR_COMMAND as CLEAR_EDITOR_COMMAND2 } from "lexical";
6627
- import { useEffect as useEffect20, useRef as useRef10, useState as useState22 } from "react";
6665
+ import { useEffect as useEffect21, useRef as useRef10, useState as useState22 } from "react";
6628
6666
  import { useDebounce as useDebounce7 } from "react-use";
6629
6667
  import { v4 as v42 } from "uuid";
6630
6668
 
6631
6669
  // src/components/SearchAndFilter/hooks/useSearchAndFilter.tsx
6632
6670
  import { VerticalRhythm as VerticalRhythm5 } from "@uniformdev/design-system";
6633
6671
  import {
6634
- createContext as createContext7,
6672
+ createContext as createContext8,
6635
6673
  useCallback as useCallback7,
6636
- useContext as useContext7,
6674
+ useContext as useContext8,
6637
6675
  useDeferredValue as useDeferredValue2,
6638
- useEffect as useEffect19,
6676
+ useEffect as useEffect20,
6639
6677
  useMemo as useMemo22,
6640
6678
  useState as useState21
6641
6679
  } from "react";
@@ -6714,7 +6752,7 @@ var bindableFiltersMapper = {
6714
6752
 
6715
6753
  // src/components/SearchAndFilter/hooks/useSearchAndFilter.tsx
6716
6754
  import { jsx as jsx75 } from "@emotion/react/jsx-runtime";
6717
- var SearchAndFilterContext = createContext7({
6755
+ var SearchAndFilterContext = createContext8({
6718
6756
  searchTerm: "",
6719
6757
  setSearchTerm: () => {
6720
6758
  },
@@ -6796,7 +6834,7 @@ var SearchAndFilterProvider = ({
6796
6834
  return filters;
6797
6835
  }
6798
6836
  }, [filters]);
6799
- useEffect19(() => {
6837
+ useEffect20(() => {
6800
6838
  if (filterVisibility) {
6801
6839
  const handleEscKeyFilterClose = (e) => {
6802
6840
  if (e.key === "Escape") {
@@ -6834,7 +6872,7 @@ var SearchAndFilterProvider = ({
6834
6872
  );
6835
6873
  };
6836
6874
  var useSearchAndFilter = () => {
6837
- const value = useContext7(SearchAndFilterContext);
6875
+ const value = useContext8(SearchAndFilterContext);
6838
6876
  return { ...value };
6839
6877
  };
6840
6878
 
@@ -6865,7 +6903,7 @@ var FilterControls = ({
6865
6903
  300,
6866
6904
  [localSearchTerm]
6867
6905
  );
6868
- useEffect20(() => {
6906
+ useEffect21(() => {
6869
6907
  if (searchTerm === "") {
6870
6908
  setLocalSearchTerm("");
6871
6909
  setIdToResetInputVariables(`data-resource-search-term-input-${v42()}`);
@@ -7142,7 +7180,7 @@ import { Icon as Icon5 } from "@uniformdev/design-system";
7142
7180
 
7143
7181
  // src/components/SearchAndFilter/FilterMenu.tsx
7144
7182
  import { HorizontalRhythm as HorizontalRhythm8, VerticalRhythm as VerticalRhythm6 } from "@uniformdev/design-system";
7145
- import React8, { useEffect as useEffect21 } from "react";
7183
+ import React8, { useEffect as useEffect22 } from "react";
7146
7184
  import { jsx as jsx78, jsxs as jsxs35 } from "@emotion/react/jsx-runtime";
7147
7185
  var SearchAndFilterOptionsContainer2 = ({
7148
7186
  buttonRow,
@@ -7175,7 +7213,7 @@ var FilterMenu = ({
7175
7213
  }) => {
7176
7214
  const { filterVisibility, setFilterVisibility, handleResetFilters, filters } = useSearchAndFilter();
7177
7215
  const innerMenuRef = React8.useRef(null);
7178
- useEffect21(() => {
7216
+ useEffect22(() => {
7179
7217
  var _a;
7180
7218
  if (filterVisibility) {
7181
7219
  (_a = innerMenuRef.current) == null ? void 0 : _a.focus();
@@ -7524,10 +7562,10 @@ var SearchAndFilter = ({
7524
7562
 
7525
7563
  // src/components/SearchAndFilter/SearchOnlyFilter.tsx
7526
7564
  import { InputKeywordSearch as InputKeywordSearch2 } from "@uniformdev/design-system";
7527
- import { createContext as createContext8, useState as useState23 } from "react";
7565
+ import { createContext as createContext9, useState as useState23 } from "react";
7528
7566
  import { useDebounce as useDebounce8 } from "react-use";
7529
7567
  import { jsx as jsx82 } from "@emotion/react/jsx-runtime";
7530
- var SearchOnlyContext = createContext8({
7568
+ var SearchOnlyContext = createContext9({
7531
7569
  searchTerm: "",
7532
7570
  setSearchTerm: () => {
7533
7571
  }
@@ -7935,7 +7973,7 @@ function createLocationValidator(setValue, validate) {
7935
7973
 
7936
7974
  // src/utils/useContentDataResourceLocaleInfo.ts
7937
7975
  import { bindVariables as bindVariables2, createVariableReference as createVariableReference4, LOCALE_DYNAMIC_INPUT_NAME as LOCALE_DYNAMIC_INPUT_NAME2 } from "@uniformdev/canvas";
7938
- import { useEffect as useEffect22, useRef as useRef11 } from "react";
7976
+ import { useEffect as useEffect23, useRef as useRef11 } from "react";
7939
7977
  function useContentDataResourceLocaleInfo({
7940
7978
  locale,
7941
7979
  defaultLocale,
@@ -7948,7 +7986,7 @@ function useContentDataResourceLocaleInfo({
7948
7986
  const { flatVariables } = useVariables();
7949
7987
  const effectiveLocale = locale != null ? locale : dynamicInputs[LOCALE_DYNAMIC_INPUT_NAME2] ? createVariableReference4(LOCALE_DYNAMIC_INPUT_NAME2) : defaultLocale != null ? defaultLocale : "";
7950
7988
  const boundLocale = (_a = bindVariables2({ variables: flatVariables, value: effectiveLocale }).result) != null ? _a : effectiveLocale;
7951
- useEffect22(() => {
7989
+ useEffect23(() => {
7952
7990
  if (locale === void 0 && effectiveLocale && setLocaleRef.current) {
7953
7991
  setLocaleRef.current(effectiveLocale);
7954
7992
  }