@uniformdev/mesh-sdk-react 17.6.1-alpha.60 → 17.7.1-alpha.140
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.ts +172 -67
- package/dist/index.esm.js +154 -154
- package/dist/index.js +156 -156
- package/dist/index.mjs +154 -154
- package/package.json +9 -9
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import * as _emotion_react_types_jsx_namespace from '@emotion/react/types/jsx-namespace';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import React__default, { SVGProps } from 'react';
|
|
3
|
+
import React__default, { SVGProps, ComponentType, PropsWithChildren } from 'react';
|
|
4
4
|
import { TDate } from 'timeago.js';
|
|
5
5
|
import * as _emotion_react from '@emotion/react';
|
|
6
|
-
import {
|
|
7
|
-
export { AddListButton, AddListButtonProps, Button, ButtonProps, Callout, CalloutProps, Heading, HeadingProps, Input, InputComboBox, InputComboBoxProps, InputKeywordSearch, InputProps, InputSelect, InputToggle, InputToggleProps, InputKeywordSearch as KeywordSearchInput, Label, LabelProps, LoadingIndicator, LoadingOverlay, Menu, MenuItem, MenuItemProps, MenuProps, ScrollableList, ScrollableListItem, ScrollableListItemProps, ScrollableListProps, Switch, SwitchProps, Textarea, TextareaProps, Theme, ThemeProps } from '@uniformdev/design-system';
|
|
8
|
-
import { DataVariableDefinition } from '@uniformdev/canvas';
|
|
6
|
+
import { DataVariableDefinition, DataResourceVariables } from '@uniformdev/canvas';
|
|
9
7
|
import * as _uniformdev_mesh_sdk from '@uniformdev/mesh-sdk';
|
|
10
|
-
import { MeshLocation, UniformMeshSDK, MeshLocationCore } from '@uniformdev/mesh-sdk';
|
|
8
|
+
import { MeshLocation, SetValueOptions, DataSourceLocationValue, DataTypeLocationValue, UniformMeshSDK, MeshLocationCore } from '@uniformdev/mesh-sdk';
|
|
11
9
|
export * from '@uniformdev/mesh-sdk';
|
|
10
|
+
import { InputSelectProps } from '@uniformdev/design-system';
|
|
11
|
+
export { AddListButton, AddListButtonProps, Button, ButtonProps, Callout, CalloutProps, Heading, HeadingProps, Input, InputComboBox, InputComboBoxProps, InputKeywordSearch, InputProps, InputSelect, InputToggle, InputToggleProps, InputKeywordSearch as KeywordSearchInput, Label, LabelProps, LoadingIndicator, LoadingOverlay, Menu, MenuItem, MenuItemProps, MenuProps, ScrollableList, ScrollableListItem, ScrollableListItemProps, ScrollableListProps, Switch, SwitchProps, Textarea, TextareaProps, Theme, ThemeProps } from '@uniformdev/design-system';
|
|
12
12
|
|
|
13
13
|
declare const SvgCaution: (props: SVGProps<SVGSVGElement>) => _emotion_react_types_jsx_namespace.EmotionJSX.Element;
|
|
14
14
|
|
|
@@ -64,13 +64,13 @@ interface EntrySearchSelectedItemProps<TResult extends EntrySearchResult = Entry
|
|
|
64
64
|
}
|
|
65
65
|
declare const DefaultSelectedItem: React__default.FC<EntrySearchSelectedItemProps>;
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
type EntrySearchQueryOptions = {
|
|
68
68
|
count: number;
|
|
69
69
|
offset: number;
|
|
70
70
|
contentType?: string;
|
|
71
71
|
cursor?: string;
|
|
72
72
|
};
|
|
73
|
-
|
|
73
|
+
type EntrySearchProps<TResult extends EntrySearchResult = EntrySearchResult> = {
|
|
74
74
|
search: (text: string, options: EntrySearchQueryOptions) => void;
|
|
75
75
|
results: TResult[] | undefined;
|
|
76
76
|
totalResults?: number | undefined;
|
|
@@ -164,7 +164,7 @@ declare const draggableIcon: _emotion_react.SerializedStyles;
|
|
|
164
164
|
declare const draggableIconOffset: _emotion_react.SerializedStyles;
|
|
165
165
|
declare const badgeIcon: _emotion_react.SerializedStyles;
|
|
166
166
|
|
|
167
|
-
|
|
167
|
+
type GetProductsOptions = {
|
|
168
168
|
keyword?: string;
|
|
169
169
|
count?: number;
|
|
170
170
|
categories?: string[];
|
|
@@ -174,7 +174,7 @@ declare type GetProductsOptions = {
|
|
|
174
174
|
ids?: string[];
|
|
175
175
|
offset?: number;
|
|
176
176
|
};
|
|
177
|
-
|
|
177
|
+
type ProductSearchResult = EntrySearchResult & {
|
|
178
178
|
price?: number | string;
|
|
179
179
|
sku?: string;
|
|
180
180
|
thumbnailUrl?: string;
|
|
@@ -251,7 +251,7 @@ interface ProductQueryContextValue {
|
|
|
251
251
|
declare const ProductQueryContext: React__default.Context<ProductQueryContextValue | undefined>;
|
|
252
252
|
declare const useProductQueryContext: () => ProductQueryContextValue;
|
|
253
253
|
|
|
254
|
-
|
|
254
|
+
type ProductSearchProps<TResult extends ProductSearchResult = ProductSearchResult> = Pick<EntrySearchProps<TResult>, 'multiSelect' | 'multiSelectId' | 'logoIcon' | 'rowComponent' | 'selectedItemComponent' | 'helpComponent' | 'noResultsComponent' | 'onSort' | 'typeSelectorAllTypesOptionText' | 'typeSelectorLabel'> & {
|
|
255
255
|
selectedProducts: TResult[] | undefined;
|
|
256
256
|
setSelectedProducts: (products: TResult[] | undefined) => Promise<void>;
|
|
257
257
|
onGetCategories: () => Promise<ProductCategory[]>;
|
|
@@ -292,7 +292,7 @@ declare const ResolvableLoadingValue: ({ value, text, loading, }: {
|
|
|
292
292
|
loading: boolean;
|
|
293
293
|
}) => _emotion_react_types_jsx_namespace.EmotionJSX.Element;
|
|
294
294
|
|
|
295
|
-
|
|
295
|
+
type SelectionFieldValue = {
|
|
296
296
|
id: string;
|
|
297
297
|
name: string;
|
|
298
298
|
};
|
|
@@ -370,23 +370,80 @@ declare const damSelectedItemMediaContainer: _emotion_react.SerializedStyles;
|
|
|
370
370
|
declare const damSelectedItemInfoBtn: _emotion_react.SerializedStyles;
|
|
371
371
|
declare const damSelectItemImage: _emotion_react.SerializedStyles;
|
|
372
372
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
373
|
+
/**
|
|
374
|
+
* Provides convenient access to the current Uniform Mesh location via React hook.
|
|
375
|
+
* Intended to be used within <MeshApp />.
|
|
376
|
+
*
|
|
377
|
+
* There are three primary ways to invoke this hook:
|
|
378
|
+
* 1. Without any arguments, this hook will return the current location regardless of its type. The result will be a union of all possible locations you can discriminate between i.e. with an if statement on the `type`
|
|
379
|
+
* const location = useMeshLocation();
|
|
380
|
+
* if (location.type === 'paramType') { // location is now known to be a paramType }
|
|
381
|
+
* 2. With a string argument, this hook will assert that the current location is the expected one and return the correct typings for that location.
|
|
382
|
+
* const location = useMeshLocation('settings');
|
|
383
|
+
* 3. With an explicit generic to set the expected param type data or param type settings data. This is useful because (2) will return unknown as the value type for param types.
|
|
384
|
+
* const location = useMeshLocation<'paramType', MyParamTypeValueType>();
|
|
385
|
+
*
|
|
386
|
+
* You can also combine (2) and (3) to get both explicit value typing and assertion of the location.
|
|
387
|
+
*/
|
|
388
|
+
declare function useMeshLocation<TLocationType extends MeshLocation['type'], TLocationValue = unknown, TLocationSetValue = TLocationValue>(expectedLocation?: TLocationType): Omit<Extract<_uniformdev_mesh_sdk.DataSourceLocation, {
|
|
389
|
+
type: TLocationType;
|
|
390
|
+
}> | Extract<_uniformdev_mesh_sdk.DataTypeLocation, {
|
|
391
|
+
type: TLocationType;
|
|
392
|
+
}> | Extract<_uniformdev_mesh_sdk.DataTypeInstanceLocation, {
|
|
393
|
+
type: TLocationType;
|
|
394
|
+
}> | Extract<_uniformdev_mesh_sdk.DataResourceLocation, {
|
|
395
|
+
type: TLocationType;
|
|
396
|
+
}> | Extract<_uniformdev_mesh_sdk.ParamTypeLocation<TLocationValue, unknown, TLocationSetValue, unknown>, {
|
|
397
|
+
type: TLocationType;
|
|
398
|
+
}> | Extract<_uniformdev_mesh_sdk.ParamTypeConfigLocation<TLocationValue, unknown>, {
|
|
399
|
+
type: TLocationType;
|
|
400
|
+
}> | Extract<_uniformdev_mesh_sdk.SettingsLocation<TLocationValue>, {
|
|
401
|
+
type: TLocationType;
|
|
402
|
+
}>, "setValue"> & {
|
|
403
|
+
setValue: SetLocationValueDispatch<(Extract<_uniformdev_mesh_sdk.DataSourceLocation, {
|
|
404
|
+
type: TLocationType;
|
|
405
|
+
}> | Extract<_uniformdev_mesh_sdk.DataTypeLocation, {
|
|
406
|
+
type: TLocationType;
|
|
407
|
+
}> | Extract<_uniformdev_mesh_sdk.DataTypeInstanceLocation, {
|
|
408
|
+
type: TLocationType;
|
|
409
|
+
}> | Extract<_uniformdev_mesh_sdk.DataResourceLocation, {
|
|
410
|
+
type: TLocationType;
|
|
411
|
+
}> | Extract<_uniformdev_mesh_sdk.ParamTypeLocation<TLocationValue, unknown, TLocationSetValue, unknown>, {
|
|
412
|
+
type: TLocationType;
|
|
413
|
+
}> | Extract<_uniformdev_mesh_sdk.ParamTypeConfigLocation<TLocationValue, unknown>, {
|
|
414
|
+
type: TLocationType;
|
|
415
|
+
}> | Extract<_uniformdev_mesh_sdk.SettingsLocation<TLocationValue>, {
|
|
416
|
+
type: TLocationType;
|
|
417
|
+
}>)["value"], Parameters<(Extract<_uniformdev_mesh_sdk.DataSourceLocation, {
|
|
418
|
+
type: TLocationType;
|
|
419
|
+
}> | Extract<_uniformdev_mesh_sdk.DataTypeLocation, {
|
|
420
|
+
type: TLocationType;
|
|
421
|
+
}> | Extract<_uniformdev_mesh_sdk.DataTypeInstanceLocation, {
|
|
422
|
+
type: TLocationType;
|
|
423
|
+
}> | Extract<_uniformdev_mesh_sdk.DataResourceLocation, {
|
|
424
|
+
type: TLocationType;
|
|
425
|
+
}> | Extract<_uniformdev_mesh_sdk.ParamTypeLocation<TLocationValue, unknown, TLocationSetValue, unknown>, {
|
|
426
|
+
type: TLocationType;
|
|
427
|
+
}> | Extract<_uniformdev_mesh_sdk.ParamTypeConfigLocation<TLocationValue, unknown>, {
|
|
428
|
+
type: TLocationType;
|
|
429
|
+
}> | Extract<_uniformdev_mesh_sdk.SettingsLocation<TLocationValue>, {
|
|
430
|
+
type: TLocationType;
|
|
431
|
+
}>)["setValue"]>[0]>;
|
|
432
|
+
};
|
|
433
|
+
type SetLocationValueDispatch<TValue, TSetValue = TValue> = (dispatch: SetLocationValueFunction<TValue, TSetValue>) => Promise<void> | void;
|
|
434
|
+
type SetLocationValueFunction<TValue, TSetValue> = (previousValue: TValue) => DispatchResult<TSetValue>;
|
|
435
|
+
type DispatchResult<TSetValue> = {
|
|
436
|
+
options?: SetValueOptions;
|
|
437
|
+
newValue: TSetValue;
|
|
378
438
|
};
|
|
379
|
-
declare const MeshApp: React__default.FC<React__default.PropsWithChildren<MeshAppProps>>;
|
|
380
|
-
|
|
381
|
-
declare function RequestBody(): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
|
|
382
439
|
|
|
383
|
-
|
|
440
|
+
type InputToken = {
|
|
384
441
|
name: string;
|
|
385
442
|
value: string;
|
|
386
443
|
};
|
|
387
|
-
|
|
388
|
-
/** sets the input label value */
|
|
389
|
-
label
|
|
444
|
+
type InputVariablesProps = {
|
|
445
|
+
/** sets the input aria-label value. */
|
|
446
|
+
'aria-label'?: string;
|
|
390
447
|
/** sets the value of the input */
|
|
391
448
|
value: string;
|
|
392
449
|
/** sets the passed down function call */
|
|
@@ -395,14 +452,14 @@ declare type InputVariablesProps = {
|
|
|
395
452
|
onPaste?: (newValue: string) => void;
|
|
396
453
|
disableVariables?: boolean;
|
|
397
454
|
};
|
|
398
|
-
declare function InputVariables({ label, value, disableVariables, onChange, onPaste }: InputVariablesProps): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
|
|
455
|
+
declare function InputVariables({ 'aria-label': ariaLabel, value, disableVariables, onChange, onPaste, }: InputVariablesProps): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
|
|
399
456
|
|
|
400
|
-
|
|
457
|
+
type DataVariableDefinitionWithName = {
|
|
401
458
|
name: string;
|
|
402
459
|
} & DataVariableDefinition;
|
|
403
460
|
declare function variablesToList(variables: Record<string, DataVariableDefinition> | undefined): Array<DataVariableDefinitionWithName>;
|
|
404
461
|
|
|
405
|
-
|
|
462
|
+
type VariableEditorProps = {
|
|
406
463
|
variable: string;
|
|
407
464
|
onSubmit: (values: DataVariableDefinitionWithName) => void | Promise<void>;
|
|
408
465
|
onCancel: () => void;
|
|
@@ -411,12 +468,12 @@ declare function VariableEditor({ variable, onSubmit, onCancel }: VariableEditor
|
|
|
411
468
|
|
|
412
469
|
declare function VariablesList(): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
|
|
413
470
|
|
|
414
|
-
|
|
471
|
+
type VariablesProviderProps = React.PropsWithChildren<{
|
|
415
472
|
value: Record<string, DataVariableDefinition>;
|
|
416
473
|
onChange: (newValue: Record<string, DataVariableDefinition>) => void;
|
|
417
474
|
editVariableComponent?: React.ComponentType<VariableEditorProps>;
|
|
418
475
|
}>;
|
|
419
|
-
|
|
476
|
+
type VariablesAction = {
|
|
420
477
|
type: 'edit';
|
|
421
478
|
variable: string;
|
|
422
479
|
} | {
|
|
@@ -430,30 +487,98 @@ declare type VariablesAction = {
|
|
|
430
487
|
type: 'reorder';
|
|
431
488
|
result: Record<string, DataVariableDefinitionWithName>;
|
|
432
489
|
};
|
|
433
|
-
|
|
490
|
+
type VariablesContext = {
|
|
434
491
|
dispatch: (event: VariablesAction) => void;
|
|
435
492
|
variables: Readonly<Record<string, DataVariableDefinition>>;
|
|
436
493
|
};
|
|
437
494
|
declare function VariablesProvider({ value, onChange, editVariableComponent, children, }: VariablesProviderProps): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
|
|
438
495
|
declare function useVariables(): VariablesContext;
|
|
439
496
|
|
|
497
|
+
type DataResourceVariablesListProps = {
|
|
498
|
+
/**
|
|
499
|
+
* Overrides rendering of a variable based on the `type` property it has set on it.
|
|
500
|
+
* If this is not passed, all variables are rendered using TextVariableRenderer.
|
|
501
|
+
*/
|
|
502
|
+
typeRenderers?: Record<string, ComponentType<DataResourceVariableRendererProps> | undefined>;
|
|
503
|
+
/**
|
|
504
|
+
* Callback when the state changes in the data resource variables.
|
|
505
|
+
* Can be sent directly to `useMeshLocation`'s `setValue` or intercepted for validation
|
|
506
|
+
* by `createLocationValidator`.
|
|
507
|
+
*/
|
|
508
|
+
setVariables: SetLocationValueDispatch<DataResourceVariables>;
|
|
509
|
+
/**
|
|
510
|
+
* Component that is rendered if no variables are set on the data resource.
|
|
511
|
+
* Defaults to a callout stating that no settings are required.
|
|
512
|
+
*/
|
|
513
|
+
noVariables?: ComponentType;
|
|
514
|
+
};
|
|
515
|
+
declare function DataResourceVariablesList({ setVariables, noVariables: NoVariablesComponent, typeRenderers, }: DataResourceVariablesListProps): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
|
|
516
|
+
type DataResourceVariableRendererProps = {
|
|
517
|
+
/** Current value of the variable on the data resource */
|
|
518
|
+
value: string | undefined;
|
|
519
|
+
/** Updates the value of the variable on the data resource */
|
|
520
|
+
setValue: (newValue: string | undefined) => void;
|
|
521
|
+
/** The definition of the data variable */
|
|
522
|
+
definition: DataVariableDefinitionWithName;
|
|
523
|
+
};
|
|
524
|
+
/** Default data resource variable renderer, uses a text input */
|
|
525
|
+
declare function TextVariableRenderer({ definition, value, setValue }: DataResourceVariableRendererProps): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
|
|
526
|
+
|
|
527
|
+
type DataSourceEditorProps = PropsWithChildren<{
|
|
528
|
+
/**
|
|
529
|
+
* Callback when the state changes in the request or variables contexts.
|
|
530
|
+
* Can be sent directly to `useMeshLocation`'s `setValue` or intercepted for validation
|
|
531
|
+
* by `createLocationValidator`.
|
|
532
|
+
*/
|
|
533
|
+
onChange: SetLocationValueDispatch<DataSourceLocationValue>;
|
|
534
|
+
}>;
|
|
535
|
+
/**
|
|
536
|
+
* Wrapper for editing a data source using Uniform Mesh SDK components that rely on `useRequest()`
|
|
537
|
+
* or `useVariables()`, or custom components that use the same hooks.
|
|
538
|
+
*/
|
|
539
|
+
declare function DataSourceEditor({ onChange, children }: DataSourceEditorProps): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
|
|
540
|
+
|
|
541
|
+
type DataTypeEditorProps = PropsWithChildren<{
|
|
542
|
+
/**
|
|
543
|
+
* Callback when the state changes in the request or variables contexts.
|
|
544
|
+
* Can be sent directly to `useMeshLocation`'s `setValue` or intercepted for validation
|
|
545
|
+
* by `createLocationValidator`.
|
|
546
|
+
*/
|
|
547
|
+
onChange: SetLocationValueDispatch<DataTypeLocationValue>;
|
|
548
|
+
}>;
|
|
549
|
+
/**
|
|
550
|
+
* Wrapper for editing a data type using Uniform Mesh SDK components that rely on `useRequest()`
|
|
551
|
+
* or `useVariables()`, or custom components that use the same hooks.
|
|
552
|
+
*/
|
|
553
|
+
declare function DataTypeEditor({ onChange, children }: DataTypeEditorProps): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
|
|
554
|
+
|
|
555
|
+
type MeshAppProps = {
|
|
556
|
+
loadingComponent?: React__default.ComponentType;
|
|
557
|
+
errorComponent?: React__default.ComponentType<{
|
|
558
|
+
error: Error;
|
|
559
|
+
}>;
|
|
560
|
+
};
|
|
561
|
+
declare const MeshApp: React__default.FC<React__default.PropsWithChildren<MeshAppProps>>;
|
|
562
|
+
|
|
563
|
+
declare function RequestBody(): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
|
|
564
|
+
|
|
440
565
|
declare function RequestHeaders({ disableVariables }: Pick<InputVariablesProps, 'disableVariables'>): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
|
|
441
566
|
|
|
442
567
|
declare function RequestMethodSelect(props: Omit<InputSelectProps, 'value' | 'onChange' | 'options'>): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
|
|
443
568
|
|
|
444
|
-
|
|
569
|
+
type RequestParametersProps = Pick<InputVariablesProps, 'disableVariables'>;
|
|
445
570
|
declare function RequestParameters({ disableVariables }: Pick<InputVariablesProps, 'disableVariables'>): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
|
|
446
571
|
|
|
447
|
-
|
|
572
|
+
type RequestParameter = {
|
|
448
573
|
key: string;
|
|
449
574
|
value: string;
|
|
450
575
|
};
|
|
451
|
-
|
|
576
|
+
type BaseRequestData = {
|
|
452
577
|
baseUrl: string;
|
|
453
578
|
headers?: Array<RequestParameter>;
|
|
454
579
|
parameters?: Array<RequestParameter>;
|
|
455
580
|
};
|
|
456
|
-
|
|
581
|
+
type RequestData = {
|
|
457
582
|
relativeUrl: string;
|
|
458
583
|
headers: Array<RequestParameter>;
|
|
459
584
|
parameters: Array<RequestParameter>;
|
|
@@ -461,11 +586,11 @@ declare type RequestData = {
|
|
|
461
586
|
method?: string;
|
|
462
587
|
body?: string;
|
|
463
588
|
};
|
|
464
|
-
|
|
589
|
+
type RequestProviderProps = React.PropsWithChildren<{
|
|
465
590
|
value: RequestData;
|
|
466
591
|
onChange: (delegate: (oldValue: RequestData) => RequestData) => void;
|
|
467
592
|
}>;
|
|
468
|
-
|
|
593
|
+
type RequestAction = {
|
|
469
594
|
type: 'setRelativeUrl';
|
|
470
595
|
relativeUrl: string;
|
|
471
596
|
} | {
|
|
@@ -490,14 +615,14 @@ declare type RequestAction = {
|
|
|
490
615
|
body: string;
|
|
491
616
|
contentType: string;
|
|
492
617
|
};
|
|
493
|
-
|
|
618
|
+
type RequestContext = {
|
|
494
619
|
dispatch: (event: RequestAction) => void;
|
|
495
620
|
request: Readonly<RequestData>;
|
|
496
621
|
};
|
|
497
622
|
declare function RequestProvider({ value, onChange, children }: RequestProviderProps): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
|
|
498
623
|
declare function useRequest(): RequestContext;
|
|
499
624
|
|
|
500
|
-
|
|
625
|
+
type RequestTypeContainerProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
501
626
|
/**sets the background color of the container
|
|
502
627
|
* @default 'transparent'
|
|
503
628
|
*/
|
|
@@ -561,35 +686,6 @@ declare const useInitializeUniformMeshSdk: ({ autoResizingDisabled }?: UseUnifor
|
|
|
561
686
|
sdk: UniformMeshSDK | undefined;
|
|
562
687
|
};
|
|
563
688
|
|
|
564
|
-
/**
|
|
565
|
-
* Provides convenient access to the current Uniform Mesh location via React hook.
|
|
566
|
-
* Intended to be used within <MeshApp />.
|
|
567
|
-
*
|
|
568
|
-
* There are three primary ways to invoke this hook:
|
|
569
|
-
* 1. Without any arguments, this hook will return the current location regardless of its type. The result will be a union of all possible locations you can discriminate between i.e. with an if statement on the `type`
|
|
570
|
-
* const location = useMeshLocation();
|
|
571
|
-
* if (location.type === 'paramType') { // location is now known to be a paramType }
|
|
572
|
-
* 2. With a string argument, this hook will assert that the current location is the expected one and return the correct typings for that location.
|
|
573
|
-
* const location = useMeshLocation('settings');
|
|
574
|
-
* 3. With an explicit generic to set the expected param type data or param type settings data. This is useful because (2) will return unknown as the value type for param types.
|
|
575
|
-
* const location = useMeshLocation<'paramType', MyParamTypeValueType>();
|
|
576
|
-
*
|
|
577
|
-
* You can also combine (2) and (3) to get both explicit value typing and assertion of the location.
|
|
578
|
-
*/
|
|
579
|
-
declare function useMeshLocation<TLocationType extends MeshLocation['type'], TLocationValue = unknown, TLocationSetValue = TLocationValue>(expectedLocation?: TLocationType): Extract<_uniformdev_mesh_sdk.DataSourceLocation, {
|
|
580
|
-
type: TLocationType;
|
|
581
|
-
}> | Extract<_uniformdev_mesh_sdk.DataTypeLocation, {
|
|
582
|
-
type: TLocationType;
|
|
583
|
-
}> | Extract<_uniformdev_mesh_sdk.DataTypeInstanceLocation, {
|
|
584
|
-
type: TLocationType;
|
|
585
|
-
}> | Extract<_uniformdev_mesh_sdk.ParamTypeLocation<TLocationValue, unknown, TLocationSetValue, unknown>, {
|
|
586
|
-
type: TLocationType;
|
|
587
|
-
}> | Extract<_uniformdev_mesh_sdk.ParamTypeConfigLocation<TLocationValue, unknown>, {
|
|
588
|
-
type: TLocationType;
|
|
589
|
-
}> | Extract<_uniformdev_mesh_sdk.SettingsLocation<TLocationValue>, {
|
|
590
|
-
type: TLocationType;
|
|
591
|
-
}>;
|
|
592
|
-
|
|
593
689
|
/**
|
|
594
690
|
* Provides convenient access to the current Uniform Mesh location via React hook.
|
|
595
691
|
* Intended to be used within <MeshApp />.
|
|
@@ -604,4 +700,13 @@ declare function useUniformMeshLocation<TLocationValue = unknown, TLocationMetad
|
|
|
604
700
|
*/
|
|
605
701
|
declare function useUniformMeshSdk(): _uniformdev_mesh_sdk.UniformMeshSDK;
|
|
606
702
|
|
|
607
|
-
|
|
703
|
+
/**
|
|
704
|
+
* Creates a validation interceptor between useMeshLocation's setValue function and your code.
|
|
705
|
+
* You can use this utility to write cleaner validation logic for your Mesh Location UIs.
|
|
706
|
+
* @param setValue The location's raw setValue function
|
|
707
|
+
* @param validate A function to validate the new location's value.
|
|
708
|
+
* @returns An equivalent to the setValue function that intercepts sets, performs validation, and emits the result with the new value.
|
|
709
|
+
*/
|
|
710
|
+
declare function createLocationValidator<TSetValue>(setValue: SetLocationValueDispatch<TSetValue>, validate: (newValue: TSetValue, currentResult: SetValueOptions | undefined) => SetValueOptions): SetLocationValueDispatch<TSetValue>;
|
|
711
|
+
|
|
712
|
+
export { BaseRequestData, Brand, DamItem, DamSelectedItem, DamSelectedItemProps, DataResourceVariableRendererProps, DataResourceVariablesList, DataResourceVariablesListProps, DataSourceEditor, DataSourceEditorProps, DataTypeEditor, DataTypeEditorProps, DataVariableDefinitionWithName, DefaultSearchRow, DefaultSelectedItem, DispatchResult, EntrySearch, EntrySearchContentType, EntrySearchProps, EntrySearchQueryOptions, EntrySearchResult, EntrySearchRowProps, EntrySearchSelectedItemProps, GetProductOptions, GetProductsOptions, index as Icons, InputToken, InputVariables, InputVariablesProps, MeshApp, MeshAppProps, NoResultsProps, ProductCategory, ProductDynamicSelectorValue, ProductPreviewList, ProductQuery, ProductQueryCategory, ProductQueryContext, ProductQueryContextValue, ProductQueryProps, ProductSearch, ProductSearchContext, ProductSearchContextValue, ProductSearchProps, ProductSearchResult, ProductSearchResults, ProductSearchRow, ProductSelectedItem, RequestAction, RequestBody, RequestContext, RequestData, RequestHeaders, RequestMethodSelect, RequestParameter, RequestParameters, RequestParametersProps, RequestProvider, RequestProviderProps, RequestTypeContainer, RequestTypeContainerProps, RequestUrl, RequestUrlInput, ResolvableLoadingValue, SelectionField, SelectionFieldValue, SetLocationValueDispatch, SetLocationValueFunction, TextVariableRenderer, UniformMeshLocationContext, UniformMeshLocationContextProvider, UniformMeshLocationContextValue, UniformMeshSdkContext, UniformMeshSdkContextProvider, UniformMeshSdkContextValue, UseUniformMeshSdkOptions, VariableEditor, VariableEditorProps, VariablesAction, VariablesContext, 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, useInitializeUniformMeshSdk, useMeshLocation, useProductQueryContext, useProductSearchContext, useRequest, useUniformMeshLocation, useUniformMeshLocationContext, useUniformMeshSdk, useUniformMeshSdkContext, useVariables, variablesToList };
|