@uniformdev/mesh-sdk-react 19.36.1-alpha.4 → 19.36.1-alpha.61

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,15 +1,18 @@
1
1
  import * as _emotion_react_types_jsx_namespace from '@emotion/react/types/jsx-namespace';
2
2
  import * as React$1 from 'react';
3
- import React__default, { SVGProps, PropsWithChildren, ComponentType, HTMLAttributes, ReactNode, AnchorHTMLAttributes } from 'react';
3
+ import React__default, { SVGProps, ReactNode, MutableRefObject, ComponentType, PropsWithChildren, HTMLAttributes, AnchorHTMLAttributes } from 'react';
4
4
  import { TDate } from 'timeago.js';
5
5
  import * as _emotion_react from '@emotion/react';
6
6
  import * as _uniformdev_mesh_sdk from '@uniformdev/mesh-sdk';
7
- import { DynamicInput, MeshLocation, SetValueOptions, DynamicInputs, DataSourceLocationValue, DataTypeLocationValue } from '@uniformdev/mesh-sdk';
7
+ import { DynamicInput, MeshLocation, SetValueOptions, DynamicInputs, DataSourceLocationValue, DataTypeLocationValue, BindableTypes } from '@uniformdev/mesh-sdk';
8
8
  export * from '@uniformdev/mesh-sdk';
9
9
  import { DataVariableDefinition, DataResourceVariables, DataType } from '@uniformdev/canvas';
10
10
  import { Emitter } from 'mitt';
11
11
  import { BadgeThemeProps, InputSelectProps } from '@uniformdev/design-system';
12
12
  export { AddListButton, AddListButtonProps, Button, ButtonProps, Callout, CalloutProps, DrawerContent, Heading, HeadingProps, Input, InputComboBox, InputComboBoxProps, InputKeywordSearch, InputProps, InputSelect, InputToggle, InputToggleProps, Label, LabelProps, LoadingIndicator, LoadingOverlay, Menu, MenuItem, MenuItemProps, MenuProps, ParameterGroup, ParameterGroupProps, ParameterImage, ParameterImageInner, ParameterImageProps, ParameterInput, ParameterInputInner, ParameterInputProps, ParameterLabel, ParameterLabelProps, ParameterMenuButton, ParameterMenuButtonProps, ParameterSelect, ParameterSelectInner, ParameterSelectProps, ParameterShell, ParameterShellContext, ParameterShellProps, ParameterTextarea, ParameterTextareaInner, ParameterTextareaProps, ParameterToggle, ParameterToggleInner, ParameterToggleProps, ScrollableList, ScrollableListItem, ScrollableListItemProps, ScrollableListProps, Switch, SwitchProps, Textarea, TextareaProps, Theme, ThemeProps, useParameterShell } from '@uniformdev/design-system';
13
+ import * as lexical from 'lexical';
14
+ import { SerializedEditorState, SerializedLexicalNode, Spread, DecoratorNode, NodeKey, LexicalEditor, LexicalNode, EditorState } from 'lexical';
15
+ import { MenuOption } from '@lexical/react/LexicalTypeaheadMenuPlugin';
13
16
 
14
17
  declare const SvgCaution: (props: SVGProps<SVGSVGElement>) => _emotion_react_types_jsx_namespace.EmotionJSX.Element;
15
18
 
@@ -369,16 +372,18 @@ declare const damSelectItemImage: _emotion_react.SerializedStyles;
369
372
 
370
373
  type MinimalDynamicInput = Omit<DynamicInput, 'source'>;
371
374
  type MinimalDynamicInputs = Record<string, MinimalDynamicInput>;
372
- type DataResourceDynamicInputProviderProps = PropsWithChildren<{
375
+ type DataResourceDynamicInputProviderProps = {
373
376
  /** Explicitly provide dynamic input values. If not set, Mesh location will be used */
374
377
  dynamicInputs?: MinimalDynamicInputs;
375
- }>;
378
+ /** Child components of the provider. Variables-using components, such as InputVariables, can be used here. */
379
+ children: ReactNode;
380
+ };
376
381
  /**
377
382
  * Wrapper for data resource locations. Provides read-only access to dynamic inputs as if they were variables,
378
383
  * using variables-aware components (i.e. InputVariables). This simplifies building dynamic-input-aware editors,
379
384
  * where a data resource variable could be a static value or bound to a dynamic input from the route (project map).
380
385
  */
381
- declare function DataResourceDynamicInputProvider({ children, dynamicInputs, }: DataResourceDynamicInputProviderProps): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
386
+ declare function DataResourceDynamicInputProvider(props: DataResourceDynamicInputProviderProps): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
382
387
 
383
388
  /**
384
389
  * Provides convenient access to the current Uniform Mesh location via React hook.
@@ -441,6 +446,195 @@ type DispatchResult<TSetValue> = {
441
446
  newValue: TSetValue;
442
447
  };
443
448
 
449
+ /**
450
+ * Updates the Lexical editor state automatically when a controlled value changes, effectively
451
+ * turning the Lexical editor into a controlled component.
452
+ *
453
+ * DO NOT USE THIS when actually editing with Lexical as it will cause performance problems.
454
+ * This is intended to be used:
455
+ * * To simplify a read-only "preview" editor, where the user can't edit the value
456
+ * * To sync an external state with the Lexical editor state under certain conditions (i.e. composer mounted, but editor hidden)
457
+ */
458
+ declare function ControlledValuePlugin({ enabled, value, extraDependencies, }: {
459
+ /** Whether to enable the controlled value plugin. Defaults to false. The value is only controlled when set to true. */
460
+ enabled: boolean;
461
+ value: string | undefined | SerializedEditorState<SerializedLexicalNode>;
462
+ extraDependencies?: unknown[];
463
+ }): JSX.Element | null;
464
+
465
+ type SerializedVariableNode = Spread<{
466
+ reference: string;
467
+ type: 'variable';
468
+ version: 1;
469
+ }, SerializedLexicalNode>;
470
+ type VariableNodeState = {
471
+ /** Display name to show on the variable */
472
+ displayName: string;
473
+ /**
474
+ * Whether the variable reference is currently pointing to a known variable in the variables context
475
+ * Note that this is ignored if `isFresh` is true, which is set for the result of edits or insertions
476
+ * made after the editor has mounted (which we know are good and don't validate to prevent flicker or false errors)
477
+ */
478
+ referenceIsValid: boolean;
479
+ /**
480
+ * Whether the variable node has been inserted or edited during this editing session
481
+ * Fresh nodes are always considered "valid" because they are the result of a user action
482
+ */
483
+ isFresh: boolean;
484
+ /** Whether clicking the node has an effect (dispatching an edit event) */
485
+ hasClickEvent: boolean | undefined;
486
+ /** Tooltip of the node on hove */
487
+ tooltip: string | undefined;
488
+ };
489
+ /** Renders a variable reference node within a Lexical editor */
490
+ declare class VariableNode extends DecoratorNode<JSX.Element> {
491
+ reference: Readonly<string>;
492
+ private __state;
493
+ static getType(): string;
494
+ static clone(node: VariableNode): VariableNode;
495
+ /** Imports the node from serialized JSON (i.e. the data provided to the editor's initial state) */
496
+ static importJSON(serializedNode: SerializedVariableNode): VariableNode;
497
+ constructor(reference: Readonly<string>, state: VariableNodeState, key?: NodeKey);
498
+ /** Gets the node's current state */
499
+ getState(): VariableNodeState;
500
+ /**
501
+ * Updates the node's variables state so it knows its current validity, display name, etc
502
+ * The plugin updates this whenever the variables prop changes.
503
+ */
504
+ setState(state: VariableNodeState): void;
505
+ /**
506
+ * Serializes the node to JSON for editor initial state
507
+ */
508
+ exportJSON(): {
509
+ reference: string;
510
+ type: string;
511
+ version: number;
512
+ };
513
+ /**
514
+ * Copy variable to clipboard in a format we will read back if pasted
515
+ * (albeit it won't get the fancy chip-node)
516
+ */
517
+ getTextContent(): string;
518
+ /** Creates the DOM wrapper that hosts the node */
519
+ createDOM(): HTMLSpanElement;
520
+ updateDOM(): boolean;
521
+ /**
522
+ * Render the variable node using React.
523
+ * NOTE: this is effectively an island of React, and you may not call hooks,
524
+ * rely on Context, etc in this renderer.
525
+ */
526
+ decorate(editor: LexicalEditor): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
527
+ /** Enables keyboard navigation to hop over the node to previous text */
528
+ isIsolated(): boolean;
529
+ }
530
+ declare function $createVariableNode(variableReference: string, state: VariableNodeState): VariableNode;
531
+ declare function $isVariableNode(node: LexicalNode | null | undefined): node is VariableNode;
532
+
533
+ type MeshDataVariableDefinition = Omit<DataVariableDefinition, 'default'> & {
534
+ /** When used in code, variables may have non-string defaults */
535
+ default: unknown;
536
+ /**
537
+ * If true the variable will not be shown in variables listings and menus, but can still be resolved
538
+ * Useful for variables that are defined by their presence in a value, and disappear when deleted from the value,
539
+ * like bindings.
540
+ */
541
+ ephemeral?: boolean;
542
+ /**
543
+ * Prevents editing the variable if set to true. If the variable context is set to read only,
544
+ * this is ignored and is always effectively true.
545
+ */
546
+ readOnly?: boolean;
547
+ /**
548
+ * Tooltip for the variable when rendered in content UI.
549
+ * If not passed, defaults to helpText.
550
+ */
551
+ tooltip?: string;
552
+ };
553
+ type DataVariableDefinitionWithName = {
554
+ name: string;
555
+ } & MeshDataVariableDefinition;
556
+ /**
557
+ * Converts variable definitions stored in a map into a flat list,
558
+ * respecting their `order` property if set, and sorting by display name otherwise.
559
+ */
560
+ declare function variablesToList(variables: Record<string, MeshDataVariableDefinition> | undefined): Array<DataVariableDefinitionWithName>;
561
+
562
+ type VariableSourceGroup = {
563
+ name: string | undefined;
564
+ variables: Array<DataVariableDefinitionWithName>;
565
+ };
566
+ /**
567
+ * Groups variable definitions by their `source` property, and sorts the groups using `variablesToList`.
568
+ * Returns a flat list of groups and variables. Groups are sorted alphabetically.
569
+ */
570
+ declare function variablesToGroupedList(variables: Record<string, MeshDataVariableDefinition> | undefined): Array<VariableSourceGroup>;
571
+
572
+ type EditVariableCommandArguments = {
573
+ /** Lexical node key that is being edited */
574
+ sourceKey: string | undefined;
575
+ /** The variable reference to edit */
576
+ reference: string;
577
+ };
578
+ type InsertVariableCommandArguments = {
579
+ reference: string;
580
+ /**
581
+ * Optionally pass in display name if you have it
582
+ * avoids a flash of the reference name
583
+ */
584
+ initialDisplayName?: string;
585
+ /**
586
+ * If specified, the lexical node with this key is overwritten by the insert.
587
+ * If unspecified, the current selection is overwritten, or inserted to if a single location.
588
+ */
589
+ targetKey: string | undefined;
590
+ /**
591
+ * If true, the existing value of the editor should be replaced with this variable
592
+ * Used when inserting a variable during an input state transition.
593
+ */
594
+ overwriteExistingValue?: boolean;
595
+ };
596
+ /**
597
+ * Opens the variable editor and when a result is selected, inserts it at the current cursor location
598
+ * NOTE: differs from INSERT_VARIABLE_COMMAND because this opens a variable picker, and that command inserts a known variable reference with no picker.
599
+ */
600
+ declare const OPEN_INSERT_VARIABLE_COMMAND: lexical.LexicalCommand<unknown>;
601
+ /** Opens the variable editor for an existing variable node */
602
+ declare const EDIT_VARIABLE_COMMAND: lexical.LexicalCommand<EditVariableCommandArguments>;
603
+ /** Inserts a new variable node at the current selection, or replacing a specific node key */
604
+ declare const INSERT_VARIABLE_COMMAND: lexical.LexicalCommand<InsertVariableCommandArguments>;
605
+ type VariablesPluginProps<TEditorContext = unknown> = {
606
+ /** Disables adding variable references via autocomplete. Any existing variables will be rendered as variables. */
607
+ disableVariables?: boolean;
608
+ /** Enables 'add variable' option in autocomplete */
609
+ showAddVariableMenuOption?: boolean | string;
610
+ /** Enables clicking a variable reference to edit the variable */
611
+ enableEditingVariables?: boolean;
612
+ /** Computes the editor context when a variable is added or edited from this composer */
613
+ getEditorContext?: () => TEditorContext;
614
+ /** If true, the whole value of the editor is replaced when a variable is inserted */
615
+ replaceValueOnVariableInsert: boolean;
616
+ };
617
+ type UseVariablesMenuInput = Pick<VariablesPluginProps, 'showAddVariableMenuOption' | 'enableEditingVariables'>;
618
+ type OnVariableSelectInput = {
619
+ value: string;
620
+ queryString?: string;
621
+ nodeToReplace?: LexicalNode;
622
+ editor: LexicalEditor;
623
+ overwriteExistingValue: boolean;
624
+ };
625
+ type UseVariablesMenu = (input: UseVariablesMenuInput) => {
626
+ groupedVariables: VariableSourceGroup[];
627
+ menuOptions: MenuOption[];
628
+ onSelect: (input: OnVariableSelectInput) => void;
629
+ };
630
+ /** Hook to use the lexical variables typeahead/dropdown menu */
631
+ declare const useVariablesMenu: UseVariablesMenu;
632
+ /**
633
+ * Enables variables auto-complete and reference management to a Lexical editor.
634
+ * Must also activate the VariableNode node to make this work.
635
+ */
636
+ declare function VariablesPlugin<TEditorContext = unknown>({ disableVariables, showAddVariableMenuOption, enableEditingVariables, getEditorContext, replaceValueOnVariableInsert, }: VariablesPluginProps<TEditorContext>): JSX.Element | null;
637
+
444
638
  type PasteTransformerPluginProps = {
445
639
  /**
446
640
  * Transforms pasted contents before inserting them.
@@ -449,23 +643,48 @@ type PasteTransformerPluginProps = {
449
643
  transformPaste?: (pastedText: string) => string | undefined;
450
644
  };
451
645
 
452
- type InputToken = {
453
- name: string;
454
- value: string;
646
+ type UseInputVariablesStateProps<TEditorContext = unknown> = {
647
+ /** Unique ID for the value being edited. */
648
+ id?: string;
649
+ /**
650
+ * Sets the value of the input
651
+ * NOTE: this is NOT reactive after mount
652
+ */
653
+ value: string | undefined;
654
+ /** Callback to receive changes to the value of the variables input */
655
+ onChange: (newValue: string | undefined) => void;
656
+ /**
657
+ * The value to set the field to when it's "reset" from a variables-input to a custom component.
658
+ * Defaults to undefined.
659
+ */
660
+ valueToResetTo?: string | undefined;
661
+ /** Disables using variables in the input */
662
+ disableVariables?: boolean;
663
+ /**
664
+ * Enables adding variables from the menu. If a string is passed,
665
+ * the option is enabled and the string is used as the menu label.
666
+ */
667
+ showAddVariableMenuOption?: boolean | string;
668
+ /**
669
+ * When no variables are referenced in the value, and this prop is provided,
670
+ * the variables-injection input will be replaced with this component.
671
+ *
672
+ * NOTE: When this prop is provided, the and a variable is inserted, any existing value
673
+ * in the input will be replaced with the variable reference. Once in variables-mode, additional
674
+ * insertions are inserted at the current selection (or end) of the variables value.
675
+ */
676
+ inputWhenNoVariables?: JSX.Element;
677
+ /** Computes the editor context when a variable is added or edited from this composer */
678
+ getEditorContext?: () => TEditorContext;
455
679
  };
456
- type InputVariablesProps = {
680
+
681
+ type InputVariablesProps<TEditorContext = unknown> = {
457
682
  /** Sets a HTML ID for the variables input and label */
458
683
  id?: string;
459
684
  /** Enables a label for the input */
460
685
  label?: string;
461
686
  /** sets the input aria-label value. */
462
687
  'aria-label'?: string;
463
- /** sets the value of the input */
464
- value: string;
465
- /** sets the passed down function call */
466
- onChange: (newValue: string) => void;
467
- /** Disables using variables in the input */
468
- disableVariables?: boolean;
469
688
  /**
470
689
  * Turns off the 'Reset' menu option that is added when:
471
690
  * - inputWhenNoVariables is passed in
@@ -473,20 +692,18 @@ type InputVariablesProps = {
473
692
  *
474
693
  * The reset button returns the editor to the inputWithNoVariables state
475
694
  *
476
- * @deprecated not usually necessary to set this, it's automatic
695
+ * @deprecated this is ignored if passed, computation is now automatic
477
696
  */
478
697
  disableReset?: boolean;
479
- /** Enables adding variables from the menu */
480
- showAddVariableMenuOption?: boolean;
698
+ /** Enables mutliple lines in the input (\n in the value) */
699
+ multiLine?: boolean;
481
700
  /** Disables the inline variable selection menu when rendering a variables input */
482
701
  disableInlineMenu?: boolean;
483
- /** Enables clicking a variable reference to edit the variable */
484
- enableEditingVariables?: boolean;
485
702
  /**
486
- * When no variables are referenced in the value, and this prop is provided,
487
- * the variables-injection input will be replaced with this component.
703
+ * Enables clicking a variable reference to edit the variable
704
+ * Note: automatically disabled if `disabled` or `disableVariables` is set
488
705
  */
489
- inputWhenNoVariables?: JSX.Element;
706
+ enableEditingVariables?: boolean;
490
707
  /** (optional) sets and shows the the error message value */
491
708
  errorMessage?: string;
492
709
  /** (optional) sets and shows the the warning message value */
@@ -495,37 +712,97 @@ type InputVariablesProps = {
495
712
  infoMessage?: string;
496
713
  /** (optional) sets caption text value */
497
714
  caption?: string;
715
+ /** Disables editing the value of the input, editing variables, and adding variables */
716
+ disabled?: boolean;
498
717
  /** Sets the test ID of the input */
499
718
  'data-test-id'?: string;
500
- } & PasteTransformerPluginProps;
501
- declare function InputVariables({ id, 'aria-label': ariaLabel, label, value, disableVariables, disableReset, enableEditingVariables, disableInlineMenu, onChange, transformPaste, showAddVariableMenuOption, inputWhenNoVariables, caption, errorMessage, warningMessage, infoMessage, 'data-test-id': dataTestId, }: InputVariablesProps): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
719
+ /** If set the editor will auto-focus on mount */
720
+ autoFocus?: boolean;
721
+ /**
722
+ * Optional ref to get a handle to the variables editor.
723
+ * This can be useful for situations such as:
724
+ * * Once initially set, `value` prop is no longer reactive and the editor owns its state. The ref can be used to set the editor state after load.
725
+ * * Performing other custom mutations to the variables editor, such as inserting text from a button click.
726
+ */
727
+ editorRef?: MutableRefObject<LexicalEditor | null>;
728
+ } & PasteTransformerPluginProps & UseInputVariablesStateProps<TEditorContext>;
729
+ /**
730
+ * An input box that enables insertion of 'variables', provided by VariablesProvider,
731
+ * into its value.
732
+ */
733
+ declare function InputVariables<TEditorContext = unknown>(props: InputVariablesProps<TEditorContext>): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
502
734
 
503
- /** Expected prefix for variable expressions */
504
- declare const variablePrefix = "${";
505
- /** Expected suffix for variable expressions */
506
- declare const variableSuffix = "}";
735
+ type ParameterConnectionIndicatorProps = {
736
+ disabled?: boolean;
737
+ value: unknown;
738
+ children: ReactNode;
739
+ menuOptions: ReactNode;
740
+ };
741
+ /**
742
+ * An input box that enables insertion of 'variables', provided by VariablesProvider,
743
+ * into its value. Designed specifically for use in the Canvas Parameter Editor.
744
+ */
745
+ declare function ParameterConnectionIndicator({ children, value, menuOptions, disabled, }: ParameterConnectionIndicatorProps): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
507
746
 
508
- type DataVariableDefinitionWithName = {
509
- name: string;
510
- } & DataVariableDefinition;
747
+ type ParameterOrSingleVariableProps<TEditorContext = unknown> = {
748
+ disabled?: boolean;
749
+ inputWhenNoVariables: JSX.Element;
750
+ enableEditingVariables?: boolean;
751
+ /**
752
+ * Optional ref to get a handle to the variables editor.
753
+ * This can be useful for situations such as performing custom mutations to the variables editor,
754
+ * such as imperatively inserting a new variable using OPEN_INSERT_VARIABLE_COMMAND.
755
+ */
756
+ editorRef?: MutableRefObject<LexicalEditor | null>;
757
+ } & Omit<UseInputVariablesStateProps<TEditorContext>, 'inputWhenNoVariables'>;
511
758
  /**
512
- * Converts variable definitions stored in a map into a flat list,
513
- * respecting their `order` property if set, and sorting by display name otherwise.
759
+ * A parameter which can be one of a custom parameter editor (`inputWhenNoVariables`),
760
+ * or one single variable value (not multiple). Use for parameters which can only have one variable value,
761
+ * possibly because they bind to objects or arrays.
762
+ * Designed visually for use in the Canvas Parameter Editor.
763
+ */
764
+ declare function ParameterOrSingleVariable<TEditorContext = unknown>(props: ParameterOrSingleVariableProps<TEditorContext>): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
765
+
766
+ type ParameterVariablesProps<TEditorContext = unknown> = {
767
+ /** sets the input aria-label value. */
768
+ 'aria-label'?: string;
769
+ /** Sets the test ID of the input */
770
+ 'data-test-id'?: string;
771
+ /**
772
+ * Enables mutliple lines in the input (\n in the value).
773
+ * If a number is passed, the height of the editor is set to that number of lines and overflow scrolls.
774
+ * If a boolean true is passed, the editor auto-sizes to the content.
775
+ */
776
+ multiLine?: boolean | number;
777
+ /** Disables editing the value of the input, editing variables, and adding variables */
778
+ disabled?: boolean;
779
+ /**
780
+ * Optional ref to get a handle to the variables editor.
781
+ * This can be useful for situations such as:
782
+ * * Once initially set, `value` prop is no longer reactive and the editor owns its state. The ref can be used to set the editor state after load.
783
+ * * Performing other custom mutations to the variables editor, such as inserting text from a button click.
784
+ */
785
+ editorRef?: MutableRefObject<LexicalEditor | null>;
786
+ /** If set the editor will auto-focus on mount */
787
+ autoFocus?: boolean;
788
+ } & UseInputVariablesStateProps<TEditorContext>;
789
+ /**
790
+ * An input box that enables insertion of 'variables', provided by VariablesProvider,
791
+ * into its value. Designed visually for use in the Canvas Parameter Editor.
514
792
  */
515
- declare function variablesToList(variables: Record<string, DataVariableDefinition> | undefined): Array<DataVariableDefinitionWithName>;
793
+ declare function ParameterVariables<TEditorContext = unknown>(props: ParameterVariablesProps<TEditorContext>): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
516
794
 
517
- type VariableEditorProps = {
795
+ type VariableEditorProps<TEditorContext = unknown> = {
518
796
  variable: string;
519
797
  onSubmit: (values: DataVariableDefinitionWithName) => void | Promise<void>;
520
798
  /** Disables the tip about Mesh integrations. Intended for use when this is placed on a custom Mesh integration to edit variables. */
521
799
  disableMeshTip?: boolean;
522
800
  onCancel: () => void;
801
+ context: TEditorContext | undefined;
523
802
  };
524
- declare function VariableEditor({ variable, onSubmit, onCancel, disableMeshTip }: VariableEditorProps): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
803
+ declare function VariableEditor({ variable, onSubmit, onCancel, disableMeshTip }: VariableEditorProps<any>): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
525
804
 
526
- declare function VariablesList(): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
527
-
528
- type VariablesProviderProps = React$1.PropsWithChildren<{
805
+ type VariablesProviderProps<TEditVariableContext = unknown> = React$1.PropsWithChildren<{
529
806
  /**
530
807
  * Signals that components in this variables context are not intended to allow mutation
531
808
  * of the variable values (i.e. editing, adding, or deleting variable definitions).
@@ -534,18 +811,20 @@ type VariablesProviderProps = React$1.PropsWithChildren<{
534
811
  */
535
812
  readOnly?: boolean;
536
813
  /** Variable values to load into the context */
537
- value: Record<string, DataVariableDefinition>;
814
+ value: Record<string, MeshDataVariableDefinition>;
538
815
  /** Function to handle mutations to the variable values (optional when readOnly is true) */
539
- onChange?: (newValue: Record<string, DataVariableDefinition>) => void;
816
+ onChange?: (newValue: Record<string, MeshDataVariableDefinition>) => void;
540
817
  /**
541
818
  * Provide a component to handle editing a variable definition (e.g. a modal wrapper)
542
819
  * If not passed, the editor will be rendered inline, with potentially strange results.
543
820
  */
544
- editVariableComponent?: React$1.ComponentType<VariableEditorProps>;
821
+ editVariableComponent?: React$1.ComponentType<VariableEditorProps<TEditVariableContext>>;
545
822
  }>;
546
- type VariablesAction = {
823
+ type VariablesAction<TEditVariableContext> = {
547
824
  type: 'edit';
548
825
  variable: string;
826
+ /** Context that will be passed in a prop to the variables context editing component */
827
+ context?: TEditVariableContext;
549
828
  } | {
550
829
  type: 'remove';
551
830
  variable: string;
@@ -553,14 +832,22 @@ type VariablesAction = {
553
832
  type: 'set';
554
833
  variable: DataVariableDefinitionWithName;
555
834
  openEditor?: boolean;
835
+ /** Context that will be passed in a prop to the variables context editing component. Only has an effect when openEditor = true */
836
+ context?: TEditVariableContext;
556
837
  } | {
557
838
  type: 'reorder';
558
839
  result: Record<string, DataVariableDefinitionWithName>;
840
+ } | {
841
+ type: 'cancelEdit';
842
+ };
843
+ type VariablesUpdateEvent = {
844
+ name: string;
845
+ latestValue: Record<string, MeshDataVariableDefinition>;
559
846
  };
560
847
  type VariablesEvents = {
561
- update: string;
848
+ update: VariablesUpdateEvent;
562
849
  };
563
- type VariablesContext = {
850
+ type VariablesContext<TEditVariableContext> = {
564
851
  /**
565
852
  * Signals that components in this variables context are not intended to allow mutation
566
853
  * of the variable values (i.e. editing, adding, or deleting variable definitions).
@@ -569,9 +856,9 @@ type VariablesContext = {
569
856
  */
570
857
  readOnly?: boolean;
571
858
  /** Dispatch update events to the variables */
572
- dispatch: (event: VariablesAction) => void;
859
+ dispatch: (event: VariablesAction<TEditVariableContext>) => void;
573
860
  /** The current variables value */
574
- variables: Readonly<Record<string, DataVariableDefinition>>;
861
+ variables: Readonly<Record<string, MeshDataVariableDefinition>>;
575
862
  /** Whether the context is editing a variable value currently */
576
863
  isEditing: boolean;
577
864
  /** Add event handles (don't forget to unhook) */
@@ -582,10 +869,54 @@ type VariablesContext = {
582
869
  * A flattened version of `variables` that is a plain key-value object.
583
870
  * Used when binding the variables to a value.
584
871
  */
585
- flatVariables: Readonly<Record<string, string>>;
872
+ flatVariables: Readonly<Record<string, unknown>>;
586
873
  };
587
- declare function VariablesProvider({ value, onChange, editVariableComponent, readOnly, children, }: VariablesProviderProps): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
588
- declare function useVariables(returnEmptyWithoutProvider?: boolean): VariablesContext;
874
+ declare function VariablesProvider<TEditComponentContext = never>({ value, onChange, editVariableComponent, readOnly, children, }: VariablesProviderProps<TEditComponentContext>): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
875
+ declare function useVariables<TEditComponentContext = unknown>(returnEmptyWithoutProvider?: boolean): VariablesContext<TEditComponentContext>;
876
+
877
+ declare function useOnVariableUpdated(fn: (event: VariablesUpdateEvent) => void, disabled?: boolean): void;
878
+
879
+ /** Converts a connected data map entry to a VariablesProvider-format variable */
880
+ declare function convertConnectedDataToVariable(bindExpression: string, value: unknown): MeshDataVariableDefinition;
881
+
882
+ /**
883
+ * Returns true if the string expression has variable references in it
884
+ */
885
+ declare function hasReferencedVariables(value: string): boolean;
886
+
887
+ declare function prettifyBindExpression(bindExpression: string): string;
888
+
889
+ /**
890
+ * Serializes a Lexical variables-editor state (as a Lexical AST) to a Uniform-variable-reference formatted string
891
+ * Note: if no content is in the editor state, undefined will be returned.
892
+ */
893
+ declare function serializeVariablesEditorState(editorState: EditorState): string | undefined;
894
+
895
+ /**
896
+ * Programmatically sets the current value of a variables editor after it has already initialized
897
+ * and become an uncontrolled component. Passing the `editorRef` prop to the component will give
898
+ * a reference to `editor`, or use `ControlledValuePlugin` to manage this automatically.
899
+ *
900
+ * If newValue is undefined, the editor will be set to an empty state.
901
+ * If newValue is a string, it will be treated as a variable-reference-containing string, and parsed to a Lexical AST
902
+ * If newValue is a serialized Lexical AST, it will be used as-is. If the AST is invalid, the editor will be set to an empty state.
903
+ */
904
+ declare function setVariablesEditorValue(editor: LexicalEditor, newValue: string | undefined | SerializedEditorState<SerializedLexicalNode>): void;
905
+
906
+ declare function variableDefaultTextValue(defaultValue: unknown): string;
907
+
908
+ /**
909
+ * Expected prefix for variable expressions
910
+ * @deprecated
911
+ */
912
+ declare const variablePrefix = "${";
913
+ /**
914
+ * Expected suffix for variable expressions
915
+ * @deprecated
916
+ */
917
+ declare const variableSuffix = "}";
918
+
919
+ declare function VariablesList(): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
589
920
 
590
921
  type DataResourceVariablesListProps = {
591
922
  /**
@@ -1025,6 +1356,25 @@ type QueryFilterProps<TSelectOptions extends QuertFilterSelectionOptionProps = Q
1025
1356
  */
1026
1357
  declare const QueryFilter: ({ requireContentType, queryFilterTitle, contentTypeLabel, typeSelectorAllTypesOptionText, contentTypeOptions, searchInputName, searchInputPlaceholderText, searchInputLabel, countLabel, countValue, sortLabel, sortOptions, sortOrderLabel, sortOrderOptions, children, }: QueryFilterProps) => _emotion_react_types_jsx_namespace.EmotionJSX.Element;
1027
1358
 
1359
+ type ParamTypeDynamicDataProviderProps = {
1360
+ /** Child components of the provider. Variables-using components, such as ParameterVariables, can be used here. */
1361
+ children: ReactNode;
1362
+ };
1363
+ /** Context to tell the binding UI what types are allowed for the current binding expression */
1364
+ type ParameterConnectOptions = {
1365
+ /**
1366
+ * Which JSON primitive types can be connected to this parameter.
1367
+ * Note that if the only value of the parameter is a complex dynamic token connection (object or array), then the connected data will be the literal value, not a string.
1368
+ */
1369
+ connectsTo: BindableTypes[];
1370
+ };
1371
+ /**
1372
+ * Wrapper for data resource locations. Provides read-only access to dynamic inputs as if they were variables,
1373
+ * using variables-aware components (i.e. InputVariables). This simplifies building dynamic-input-aware editors,
1374
+ * where a data resource variable could be a static value or bound to a dynamic input from the route (project map).
1375
+ */
1376
+ declare function ParamTypeDynamicDataProvider(props: ParamTypeDynamicDataProviderProps): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
1377
+
1028
1378
  /** Editor component to let you write a request body for POST requests */
1029
1379
  declare function RequestBody(): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
1030
1380
 
@@ -1116,10 +1466,10 @@ declare function RequestUrl(): _emotion_react_types_jsx_namespace.EmotionJSX.Ele
1116
1466
  * Editor to modify the current URL of the request
1117
1467
  * Note: entering query string parameters automatically converts them and syncs the request state with them
1118
1468
  */
1119
- declare function RequestUrlInput(props: Omit<InputVariablesProps, 'value' | 'onChange'>): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
1469
+ declare function RequestUrlInput(props: Omit<InputVariablesProps, 'value' | 'onChange'> & Pick<InputVariablesProps, 'showAddVariableMenuOption' | 'enableEditingVariables'>): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
1120
1470
 
1121
- declare function urlEncodeRequestUrl(url: string, varValues?: Record<string, DataVariableDefinition>): string;
1122
- declare function urlEncodeRequestParameter(parameter: RequestParameter, varValues?: Record<string, DataVariableDefinition>): RequestParameter;
1471
+ declare function urlEncodeRequestUrl(url: string, varValues?: Record<string, MeshDataVariableDefinition>): string;
1472
+ declare function urlEncodeRequestParameter(parameter: RequestParameter, varValues?: Record<string, MeshDataVariableDefinition>): RequestParameter;
1123
1473
 
1124
1474
  /**
1125
1475
  * Hook to make it simple to read and write a specific request header by name,
@@ -1145,6 +1495,12 @@ declare function useRequestParameter(paramName: string): {
1145
1495
  update: (value: string) => void;
1146
1496
  };
1147
1497
 
1498
+ /** Converts connected data map into VariablesProvider-format variables */
1499
+ declare function useConnectedDataAsVariables(connectedData: Record<string, unknown> | undefined): Record<string, MeshDataVariableDefinition>;
1500
+
1501
+ /** Converts dynamic inputs into VariablesProvider-format variables */
1502
+ declare function useDynamicInputsAsVariables(dynamicInputs: MinimalDynamicInputs): Record<string, MeshDataVariableDefinition>;
1503
+
1148
1504
  /**
1149
1505
  * Provides convenient access to the current Uniform Mesh SDK instance via React hook.
1150
1506
  * Intended to be used within <MeshApp />.
@@ -1160,4 +1516,4 @@ declare function useUniformMeshSdk(): _uniformdev_mesh_sdk.UniformMeshSDK;
1160
1516
  */
1161
1517
  declare function createLocationValidator<TSetValue>(setValue: SetLocationValueDispatch<TSetValue>, validate: (newValue: TSetValue, currentResult: SetValueOptions | undefined) => SetValueOptions): SetLocationValueDispatch<TSetValue>;
1162
1518
 
1163
- export { BaseRequestData, Brand, DamItem, DamSelectedItem, DamSelectedItemProps, DataRefreshButton, DataRefreshButtonProps, DataResourceDynamicInputProvider, DataResourceDynamicInputProviderProps, DataResourceVariableRendererProps, DataResourceVariablesList, DataResourceVariablesListExplicit, DataResourceVariablesListProps, DataSourceEditor, DataSourceEditorProps, DataTypeEditor, DataTypeEditorProps, DataVariableDefinitionWithName, DefaultSearchRow, DefaultSelectedItem, DispatchResult, EntrySearch, EntrySearchContentType, EntrySearchProps, EntrySearchQueryOptions, EntrySearchResult, EntrySearchRowProps, EntrySearchSelectedItemProps, GetProductOptions, GetProductsOptions, index as Icons, InputToken, InputVariables, InputVariablesProps, ItemListProps, LinkButton, MeshApp, MeshAppProps, MinimalDynamicInput, MinimalDynamicInputs, NoResultsProps, ObjectSearchContainer, ObjectSearchContainerProps, ObjectSearchContextProps, ObjectSearchFilter, ObjectSearchFilterContainer, ObjectSearchFilterContainerProps, ObjectSearchFilterProps, ObjectSearchListItem, ObjectSearchListItemLoadingSkeleton, ObjectSearchListItemProps, ObjectSearchProvider, ObjectSearchProviderProps, ObjectSearchResultItem, ObjectSearchResultItemButton, ObjectSearchResultItemButtonProps, ObjectSearchResultItemProps, ObjectSearchResultList, ObjectSearchResultListProps, ProductCategory, ProductDynamicSelectorValue, ProductPreviewList, ProductQuery, ProductQueryCategory, ProductQueryContext, ProductQueryContextValue, ProductQueryProps, ProductSearch, ProductSearchContext, ProductSearchContextValue, ProductSearchProps, ProductSearchResult, ProductSearchResults, ProductSearchRow, ProductSelectedItem, QueryFilter, QueryFilterProps, QueryFilterSearchProps, RequestAction, RequestBody, RequestContext, RequestData, RequestHeaders, RequestMethodSelect, RequestParameter, RequestParameters, RequestParametersProps, RequestProvider, RequestProviderProps, RequestTypeContainer, RequestTypeContainerProps, RequestUrl, RequestUrlInput, ResolvableLoadingValue, SearchQueryProps, SelectedItemProps, SelectionField, SelectionFieldValue, SetLocationValueDispatch, SetLocationValueFunction, TextVariableRenderer, VariableEditor, VariableEditorProps, VariablesAction, VariablesContext, VariablesEvents, VariablesList, VariablesProvider, VariablesProviderProps, badgeIcon, createLocationValidator, damSelectItemImage, damSelectedItemContainer, damSelectedItemCopy, damSelectedItemDetails, damSelectedItemIcon, damSelectedItemInfoBtn, damSelectedItemInner, damSelectedItemLinkBtn, damSelectedItemLinkContainer, damSelectedItemMediaContainer, damSelectedItemPopover, damSelectedItemPopoverLabel, damSelectedItemSmallText, damSelectedItemTitle, draggableContainer, draggableIcon, draggableIconOffset, draggableIconWrapper, entrySearchBtn, entrySearchConfig, entrySearchConfigHidden, entrySearchLoadMoreBtn, entrySearchResultList, entrySearchSelectIcon, entrySearchSelectImg, entrySearchSelectInput, entrySearchSelectOption, entrySearchWrapper, productSearchRowActiveIcon, productSearchRowCategory, productSearchRowContainer, productSearchRowContent, productSearchRowContentActive, productSearchRowDetails, productSearchRowTitle, productSelectedItemContainer, productSelectedItemContent, productSelectedItemDetails, productSelectedItemIcon, productSelectedItemImage, productSelectedItemLinkContainer, productedSelectedItemLinkBtn, productedSelectedItemSmallText, searchRowBtn, searchRowContainer, searchRowContainerActive, searchRowContainerWithPopover, searchRowPopover, searchRowText, searchRowTextSmall, selectItemLinkBtn, selectItemLinkContainer, selectItemPopover, selectItemPopoverLabel, selectItemSmallText, selectedItemContainer, selectedItemCopy, selectedItemDetails, selectedItemIcon, selectedItemInner, selectedItemTitle, urlEncodeRequestParameter, urlEncodeRequestUrl, useMeshLocation, useObjectSearchContext, useProductQueryContext, useProductSearchContext, useRequest, useRequestHeader, useRequestParameter, useUniformMeshSdk, useVariables, variablePrefix, variableSuffix, variablesToList };
1519
+ export { $createVariableNode, $isVariableNode, BaseRequestData, Brand, ControlledValuePlugin, DamItem, DamSelectedItem, DamSelectedItemProps, DataRefreshButton, DataRefreshButtonProps, DataResourceDynamicInputProvider, DataResourceDynamicInputProviderProps, DataResourceVariableRendererProps, DataResourceVariablesList, DataResourceVariablesListExplicit, DataResourceVariablesListProps, DataSourceEditor, DataSourceEditorProps, DataTypeEditor, DataTypeEditorProps, DataVariableDefinitionWithName, DefaultSearchRow, DefaultSelectedItem, DispatchResult, EDIT_VARIABLE_COMMAND, EditVariableCommandArguments, EntrySearch, EntrySearchContentType, EntrySearchProps, EntrySearchQueryOptions, EntrySearchResult, EntrySearchRowProps, EntrySearchSelectedItemProps, GetProductOptions, GetProductsOptions, INSERT_VARIABLE_COMMAND, index as Icons, InputVariables, InputVariablesProps, InsertVariableCommandArguments, ItemListProps, LinkButton, MeshApp, MeshAppProps, MeshDataVariableDefinition, MinimalDynamicInput, MinimalDynamicInputs, NoResultsProps, OPEN_INSERT_VARIABLE_COMMAND, ObjectSearchContainer, ObjectSearchContainerProps, ObjectSearchContextProps, ObjectSearchFilter, ObjectSearchFilterContainer, ObjectSearchFilterContainerProps, ObjectSearchFilterProps, ObjectSearchListItem, ObjectSearchListItemLoadingSkeleton, ObjectSearchListItemProps, ObjectSearchProvider, ObjectSearchProviderProps, ObjectSearchResultItem, ObjectSearchResultItemButton, ObjectSearchResultItemButtonProps, ObjectSearchResultItemProps, ObjectSearchResultList, ObjectSearchResultListProps, ParamTypeDynamicDataProvider, ParamTypeDynamicDataProviderProps, ParameterConnectOptions, ParameterConnectionIndicator, ParameterConnectionIndicatorProps, ParameterOrSingleVariable, ParameterOrSingleVariableProps, ParameterVariables, ParameterVariablesProps, ProductCategory, ProductDynamicSelectorValue, ProductPreviewList, ProductQuery, ProductQueryCategory, ProductQueryContext, ProductQueryContextValue, ProductQueryProps, ProductSearch, ProductSearchContext, ProductSearchContextValue, ProductSearchProps, ProductSearchResult, ProductSearchResults, ProductSearchRow, ProductSelectedItem, QueryFilter, QueryFilterProps, QueryFilterSearchProps, RequestAction, RequestBody, RequestContext, RequestData, RequestHeaders, RequestMethodSelect, RequestParameter, RequestParameters, RequestParametersProps, RequestProvider, RequestProviderProps, RequestTypeContainer, RequestTypeContainerProps, RequestUrl, RequestUrlInput, ResolvableLoadingValue, SearchQueryProps, SelectedItemProps, SelectionField, SelectionFieldValue, SerializedVariableNode, SetLocationValueDispatch, SetLocationValueFunction, TextVariableRenderer, UseVariablesMenu, UseVariablesMenuInput, VariableEditor, VariableEditorProps, VariableNode, VariableNodeState, VariableSourceGroup, VariablesAction, VariablesContext, VariablesEvents, VariablesList, VariablesPlugin, VariablesPluginProps, VariablesProvider, VariablesProviderProps, VariablesUpdateEvent, badgeIcon, convertConnectedDataToVariable, createLocationValidator, damSelectItemImage, damSelectedItemContainer, damSelectedItemCopy, damSelectedItemDetails, damSelectedItemIcon, damSelectedItemInfoBtn, damSelectedItemInner, damSelectedItemLinkBtn, damSelectedItemLinkContainer, damSelectedItemMediaContainer, damSelectedItemPopover, damSelectedItemPopoverLabel, damSelectedItemSmallText, damSelectedItemTitle, draggableContainer, draggableIcon, draggableIconOffset, draggableIconWrapper, entrySearchBtn, entrySearchConfig, entrySearchConfigHidden, entrySearchLoadMoreBtn, entrySearchResultList, entrySearchSelectIcon, entrySearchSelectImg, entrySearchSelectInput, entrySearchSelectOption, entrySearchWrapper, hasReferencedVariables, prettifyBindExpression, productSearchRowActiveIcon, productSearchRowCategory, productSearchRowContainer, productSearchRowContent, productSearchRowContentActive, productSearchRowDetails, productSearchRowTitle, productSelectedItemContainer, productSelectedItemContent, productSelectedItemDetails, productSelectedItemIcon, productSelectedItemImage, productSelectedItemLinkContainer, productedSelectedItemLinkBtn, productedSelectedItemSmallText, searchRowBtn, searchRowContainer, searchRowContainerActive, searchRowContainerWithPopover, searchRowPopover, searchRowText, searchRowTextSmall, selectItemLinkBtn, selectItemLinkContainer, selectItemPopover, selectItemPopoverLabel, selectItemSmallText, selectedItemContainer, selectedItemCopy, selectedItemDetails, selectedItemIcon, selectedItemInner, selectedItemTitle, serializeVariablesEditorState, setVariablesEditorValue, urlEncodeRequestParameter, urlEncodeRequestUrl, useConnectedDataAsVariables, useDynamicInputsAsVariables, useMeshLocation, useObjectSearchContext, useOnVariableUpdated, useProductQueryContext, useProductSearchContext, useRequest, useRequestHeader, useRequestParameter, useUniformMeshSdk, useVariables, useVariablesMenu, variableDefaultTextValue, variablePrefix, variableSuffix, variablesToGroupedList, variablesToList };