@uniformdev/mesh-sdk-react 18.35.1-alpha.12 → 18.35.1-alpha.17

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 CHANGED
@@ -5,10 +5,10 @@ import { TDate } from 'timeago.js';
5
5
  import * as _emotion_react from '@emotion/react';
6
6
  import { DataVariableDefinition, DataResourceVariables } from '@uniformdev/canvas';
7
7
  import * as _uniformdev_mesh_sdk from '@uniformdev/mesh-sdk';
8
- import { MeshLocation, SetValueOptions, DataSourceLocationValue, DataTypeLocationValue } from '@uniformdev/mesh-sdk';
8
+ import { MeshLocation, SetValueOptions, DataSourceLocationValue, DataTypeLocationValue, UniformMeshSDK, MeshLocationCore } from '@uniformdev/mesh-sdk';
9
9
  export * from '@uniformdev/mesh-sdk';
10
10
  import { BadgeThemeProps, InputSelectProps } from '@uniformdev/design-system';
11
- export { AddListButton, AddListButtonProps, Button, ButtonProps, Callout, CalloutProps, 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';
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, 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';
12
12
 
13
13
  declare const SvgCaution: (props: SVGProps<SVGSVGElement>) => _emotion_react_types_jsx_namespace.EmotionJSX.Element;
14
14
 
@@ -182,6 +182,10 @@ type ProductSearchResult = EntrySearchResult & {
182
182
  id: string;
183
183
  name: string;
184
184
  }>;
185
+ /** @deprecated Use `editLink` instead. */
186
+ url?: string;
187
+ /** @deprecated Use `title` instead. */
188
+ name?: string;
185
189
  };
186
190
  interface ProductSearchResults {
187
191
  total: number;
@@ -385,6 +389,8 @@ declare function useMeshLocation<TLocationType extends MeshLocation['type'], TLo
385
389
  type: TLocationType;
386
390
  }> | Extract<_uniformdev_mesh_sdk.DataTypeLocation, {
387
391
  type: TLocationType;
392
+ }> | Extract<_uniformdev_mesh_sdk.DataTypeInstanceLocation, {
393
+ type: TLocationType;
388
394
  }> | Extract<_uniformdev_mesh_sdk.DataResourceLocation, {
389
395
  type: TLocationType;
390
396
  }> | Extract<_uniformdev_mesh_sdk.ParamTypeLocation<TLocationValue, unknown, TLocationSetValue, unknown>, {
@@ -398,6 +404,8 @@ declare function useMeshLocation<TLocationType extends MeshLocation['type'], TLo
398
404
  type: TLocationType;
399
405
  }> | Extract<_uniformdev_mesh_sdk.DataTypeLocation, {
400
406
  type: TLocationType;
407
+ }> | Extract<_uniformdev_mesh_sdk.DataTypeInstanceLocation, {
408
+ type: TLocationType;
401
409
  }> | Extract<_uniformdev_mesh_sdk.DataResourceLocation, {
402
410
  type: TLocationType;
403
411
  }> | Extract<_uniformdev_mesh_sdk.ParamTypeLocation<TLocationValue, unknown, TLocationSetValue, unknown>, {
@@ -410,6 +418,8 @@ declare function useMeshLocation<TLocationType extends MeshLocation['type'], TLo
410
418
  type: TLocationType;
411
419
  }> | Extract<_uniformdev_mesh_sdk.DataTypeLocation, {
412
420
  type: TLocationType;
421
+ }> | Extract<_uniformdev_mesh_sdk.DataTypeInstanceLocation, {
422
+ type: TLocationType;
413
423
  }> | Extract<_uniformdev_mesh_sdk.DataResourceLocation, {
414
424
  type: TLocationType;
415
425
  }> | Extract<_uniformdev_mesh_sdk.ParamTypeLocation<TLocationValue, unknown, TLocationSetValue, unknown>, {
@@ -1011,6 +1021,56 @@ declare function useRequestParameter(paramName: string): {
1011
1021
  update: (value: string) => void;
1012
1022
  };
1013
1023
 
1024
+ /** @deprecated */
1025
+ interface UniformMeshLocationContextValue<TLocationValue = unknown, TLocationSetValue = TLocationValue> {
1026
+ location: MeshLocation<TLocationValue, TLocationSetValue>;
1027
+ }
1028
+ /** @deprecated not intended for public usage */
1029
+ declare const UniformMeshLocationContext: React__default.Context<UniformMeshLocationContextValue<unknown, unknown> | undefined>;
1030
+ /** @deprecated not intended for public usage. Use <MeshApp /> instead. */
1031
+ declare const UniformMeshLocationContextProvider: React__default.FC<React__default.PropsWithChildren<unknown>>;
1032
+ /**
1033
+ * Provides access to the current UniformMeshLocationContext value.
1034
+ * @deprecated Not intended for public use. Use `useUniformMeshLocation` instead.
1035
+ */
1036
+ declare const useUniformMeshLocationContext: <TLocationValue = unknown, TLocationSetValue = TLocationValue>() => UniformMeshLocationContextValue<TLocationValue, TLocationSetValue>;
1037
+
1038
+ interface UniformMeshSdkContextValue {
1039
+ sdk: UniformMeshSDK;
1040
+ }
1041
+ /** @deprecated not intended for public usage */
1042
+ declare const UniformMeshSdkContext: React__default.Context<UniformMeshSdkContextValue | undefined>;
1043
+ /** @deprecated not intended for public usage; use <MeshApp /> instead */
1044
+ declare const UniformMeshSdkContextProvider: React__default.FC<React__default.PropsWithChildren<unknown>>;
1045
+ /**
1046
+ * Provides access to the current (initialized) Uniform Mesh SDK context value.
1047
+ * @deprecated Not intended for public use. Use `useUniformMeshLocation` or `useUniformMeshSdk` instead.
1048
+ */
1049
+ declare const useUniformMeshSdkContext: () => UniformMeshSdkContextValue;
1050
+
1051
+ interface UseUniformMeshSdkOptions {
1052
+ autoResizingDisabled?: boolean;
1053
+ }
1054
+ /**
1055
+ * Provides a React-hook wrapper around Uniform Mesh SDK initialization.
1056
+ * NOTE: initialization is an async operation and should be handled as such.
1057
+ *
1058
+ * @deprecated prefer <MeshApp /> to initialize and provide in a single component
1059
+ */
1060
+ declare const useInitializeUniformMeshSdk: ({ autoResizingDisabled }?: UseUniformMeshSdkOptions) => {
1061
+ initializing: boolean;
1062
+ error: Error | undefined;
1063
+ sdk: UniformMeshSDK | undefined;
1064
+ };
1065
+
1066
+ /**
1067
+ * Provides convenient access to the current Uniform Mesh location via React hook.
1068
+ * Intended to be used within <MeshApp />.
1069
+ *
1070
+ * @deprecated prefer useMeshLocation which has much more accurate type safety
1071
+ */
1072
+ declare function useUniformMeshLocation<TLocationValue = unknown, TLocationMetadata = never, TLocationSetValue = TLocationValue>(): MeshLocationCore<TLocationValue, TLocationMetadata, TLocationSetValue>;
1073
+
1014
1074
  /**
1015
1075
  * Provides convenient access to the current Uniform Mesh SDK instance via React hook.
1016
1076
  * Intended to be used within <MeshApp />.
@@ -1026,4 +1086,4 @@ declare function useUniformMeshSdk(): _uniformdev_mesh_sdk.UniformMeshSDK;
1026
1086
  */
1027
1087
  declare function createLocationValidator<TSetValue>(setValue: SetLocationValueDispatch<TSetValue>, validate: (newValue: TSetValue, currentResult: SetValueOptions | undefined) => SetValueOptions): SetLocationValueDispatch<TSetValue>;
1028
1088
 
1029
- export { BaseRequestData, Brand, DamItem, DamSelectedItem, DamSelectedItemProps, DataRefreshButton, DataRefreshButtonProps, 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, ItemListProps, LinkButton, MeshApp, MeshAppProps, 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, 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, variablesToList };
1089
+ export { BaseRequestData, Brand, DamItem, DamSelectedItem, DamSelectedItemProps, DataRefreshButton, DataRefreshButtonProps, 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, ItemListProps, LinkButton, MeshApp, MeshAppProps, 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, 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, useObjectSearchContext, useProductQueryContext, useProductSearchContext, useRequest, useRequestHeader, useRequestParameter, useUniformMeshLocation, useUniformMeshLocationContext, useUniformMeshSdk, useUniformMeshSdkContext, useVariables, variablesToList };
package/dist/index.esm.js CHANGED
@@ -893,7 +893,7 @@ var ProductPreviewList = ({
893
893
  scrollbarStyles
894
894
  ],
895
895
  children: products == null ? void 0 : products.map((product, index) => {
896
- var _a;
896
+ var _a, _b;
897
897
  const [category] = (product == null ? void 0 : product.categories) || [];
898
898
  const categoryName = typeof category === "undefined" || !categories ? void 0 : (_a = categories.find((c) => c.id === category.id)) == null ? void 0 : _a.name;
899
899
  return /* @__PURE__ */ jsx18("li", { css: productPreviewListItem, children: /* @__PURE__ */ jsxs7(
@@ -906,13 +906,13 @@ var ProductPreviewList = ({
906
906
  "img",
907
907
  {
908
908
  src: product.thumbnailUrl,
909
- alt: typeof product.title === "string" ? product.title : `Product ${index}`,
909
+ alt: typeof product.title === "string" ? product.title : product.name || `Product ${index}`,
910
910
  css: productPreviewListImage,
911
911
  "data-test-id": "product-image"
912
912
  }
913
913
  ) : /* @__PURE__ */ jsx18("div", { css: productPreviewListImageDefault }),
914
914
  /* @__PURE__ */ jsxs7("h4", { css: productPreviewListTitle, "data-test-id": "product-name", children: [
915
- product.title,
915
+ product.title || product.name,
916
916
  categoryName && /* @__PURE__ */ jsx18("span", { css: productPreviewListCategoryText, children: categoryName })
917
917
  ] }),
918
918
  product && /* @__PURE__ */ jsxs7(Fragment2, { children: [
@@ -925,12 +925,12 @@ var ProductPreviewList = ({
925
925
  "Price: ",
926
926
  product.price
927
927
  ] }) : null,
928
- product.editLink ? /* @__PURE__ */ jsxs7(
928
+ product.editLink || product.url ? /* @__PURE__ */ jsxs7(
929
929
  "a",
930
930
  {
931
931
  css: productPreviewListLinkBtn,
932
- href: product.editLink,
933
- title: `Go to ${product.title}`,
932
+ href: (_b = product.editLink) != null ? _b : product.url,
933
+ title: `Go to ${product.title || product.name}`,
934
934
  target: "_blank",
935
935
  rel: "noopener noreferrer",
936
936
  "data-test-id": "edit-product-button",
@@ -2655,6 +2655,18 @@ import { Theme } from "@uniformdev/design-system";
2655
2655
  import { createContext, useContext as useContext3 } from "react";
2656
2656
  import { jsx as jsx26, jsxs as jsxs15 } from "@emotion/react/jsx-runtime";
2657
2657
  var UniformMeshSdkContext = createContext(void 0);
2658
+ var UniformMeshSdkContextProvider = ({ children }) => {
2659
+ let value = void 0;
2660
+ if (typeof window !== "undefined" && typeof window.UniformMeshSDK !== "undefined") {
2661
+ value = {
2662
+ sdk: window.UniformMeshSDK
2663
+ };
2664
+ }
2665
+ return /* @__PURE__ */ jsxs15(UniformMeshSdkContext.Provider, { value, children: [
2666
+ /* @__PURE__ */ jsx26(Theme, {}),
2667
+ /* @__PURE__ */ jsx26(UniformMeshLocationContextProvider, { children })
2668
+ ] });
2669
+ };
2658
2670
  var useUniformMeshSdkContext = () => {
2659
2671
  const context = useContext3(UniformMeshSdkContext);
2660
2672
  if (!context) {
@@ -2671,7 +2683,9 @@ function useUniformMeshSdk() {
2671
2683
 
2672
2684
  // src/components/UniformMeshLocationContext.tsx
2673
2685
  import { jsx as jsx27 } from "@emotion/react/jsx-runtime";
2674
- var UniformMeshLocationContext = createContext2(void 0);
2686
+ var UniformMeshLocationContext = createContext2(
2687
+ void 0
2688
+ );
2675
2689
  var UniformMeshLocationContextProvider = ({
2676
2690
  children
2677
2691
  }) => {
@@ -2702,9 +2716,20 @@ var useUniformMeshLocationContext = () => {
2702
2716
  };
2703
2717
 
2704
2718
  // src/hooks/useMeshLocation.ts
2719
+ var legacyWarned = false;
2705
2720
  function useMeshLocation(expectedLocation) {
2706
2721
  const { location } = useUniformMeshLocationContext();
2707
- if (expectedLocation && location.type !== expectedLocation) {
2722
+ let effectiveExpected = expectedLocation;
2723
+ if (expectedLocation === "dataTypeInstance") {
2724
+ effectiveExpected = "dataResource";
2725
+ if (!legacyWarned) {
2726
+ console.warn(
2727
+ "`dataTypeInstance` mesh location is deprecated, please switch to `dataResource` instead."
2728
+ );
2729
+ legacyWarned = true;
2730
+ }
2731
+ }
2732
+ if (effectiveExpected && location.type !== effectiveExpected) {
2708
2733
  throw new Error(`Expected location type ${expectedLocation} but got ${location.type}`);
2709
2734
  }
2710
2735
  const backdoorLocation = useRef7(location);
@@ -3191,7 +3216,7 @@ function DataResourceVariablesList({
3191
3216
  const {
3192
3217
  value,
3193
3218
  metadata: { dataType }
3194
- } = useMeshLocation("dataResource");
3219
+ } = useMeshLocation("dataTypeInstance");
3195
3220
  const variableDefinitions = variablesToList(dataType.variables);
3196
3221
  if (variableDefinitions.length === 0) {
3197
3222
  if (NoVariablesComponent) {
@@ -4662,6 +4687,12 @@ var QueryFilter = ({
4662
4687
  ] });
4663
4688
  };
4664
4689
 
4690
+ // src/hooks/useUniformMeshLocation.ts
4691
+ function useUniformMeshLocation() {
4692
+ const { location } = useUniformMeshLocationContext();
4693
+ return location;
4694
+ }
4695
+
4665
4696
  // src/hooks/index.ts
4666
4697
  import { ParameterShellContext, useParameterShell } from "@uniformdev/design-system";
4667
4698
 
@@ -4684,6 +4715,7 @@ import {
4684
4715
  InputKeywordSearch as InputKeywordSearch4,
4685
4716
  InputSelect as InputSelect8,
4686
4717
  InputToggle,
4718
+ InputKeywordSearch as InputKeywordSearch5,
4687
4719
  Label,
4688
4720
  LoadingIndicator as LoadingIndicator4,
4689
4721
  LoadingOverlay as LoadingOverlay2,
@@ -4730,6 +4762,7 @@ export {
4730
4762
  InputSelect8 as InputSelect,
4731
4763
  InputToggle,
4732
4764
  InputVariables,
4765
+ InputKeywordSearch5 as KeywordSearchInput,
4733
4766
  Label,
4734
4767
  LinkButton,
4735
4768
  LoadingIndicator4 as LoadingIndicator,
@@ -4785,6 +4818,10 @@ export {
4785
4818
  TextVariableRenderer,
4786
4819
  Textarea,
4787
4820
  Theme3 as Theme,
4821
+ UniformMeshLocationContext,
4822
+ UniformMeshLocationContextProvider,
4823
+ UniformMeshSdkContext,
4824
+ UniformMeshSdkContextProvider,
4788
4825
  VariableEditor,
4789
4826
  VariablesList,
4790
4827
  VariablesProvider,
@@ -4853,6 +4890,7 @@ export {
4853
4890
  selectedItemTitle,
4854
4891
  urlEncodeRequestParameter,
4855
4892
  urlEncodeRequestUrl,
4893
+ useInitializeUniformMeshSdk,
4856
4894
  useMeshLocation,
4857
4895
  useObjectSearchContext,
4858
4896
  useParameterShell,
@@ -4861,7 +4899,10 @@ export {
4861
4899
  useRequest,
4862
4900
  useRequestHeader,
4863
4901
  useRequestParameter,
4902
+ useUniformMeshLocation,
4903
+ useUniformMeshLocationContext,
4864
4904
  useUniformMeshSdk,
4905
+ useUniformMeshSdkContext,
4865
4906
  useVariables,
4866
4907
  variablesToList
4867
4908
  };
package/dist/index.js CHANGED
@@ -50,6 +50,7 @@ __export(src_exports, {
50
50
  InputSelect: () => import_design_system34.InputSelect,
51
51
  InputToggle: () => import_design_system34.InputToggle,
52
52
  InputVariables: () => InputVariables,
53
+ KeywordSearchInput: () => import_design_system34.InputKeywordSearch,
53
54
  Label: () => import_design_system34.Label,
54
55
  LinkButton: () => LinkButton,
55
56
  LoadingIndicator: () => import_design_system34.LoadingIndicator,
@@ -105,6 +106,10 @@ __export(src_exports, {
105
106
  TextVariableRenderer: () => TextVariableRenderer,
106
107
  Textarea: () => import_design_system34.Textarea,
107
108
  Theme: () => import_design_system34.Theme,
109
+ UniformMeshLocationContext: () => UniformMeshLocationContext,
110
+ UniformMeshLocationContextProvider: () => UniformMeshLocationContextProvider,
111
+ UniformMeshSdkContext: () => UniformMeshSdkContext,
112
+ UniformMeshSdkContextProvider: () => UniformMeshSdkContextProvider,
108
113
  VariableEditor: () => VariableEditor,
109
114
  VariablesList: () => VariablesList,
110
115
  VariablesProvider: () => VariablesProvider,
@@ -173,6 +178,7 @@ __export(src_exports, {
173
178
  selectedItemTitle: () => selectedItemTitle,
174
179
  urlEncodeRequestParameter: () => urlEncodeRequestParameter,
175
180
  urlEncodeRequestUrl: () => urlEncodeRequestUrl,
181
+ useInitializeUniformMeshSdk: () => useInitializeUniformMeshSdk,
176
182
  useMeshLocation: () => useMeshLocation,
177
183
  useObjectSearchContext: () => useObjectSearchContext,
178
184
  useParameterShell: () => import_design_system33.useParameterShell,
@@ -181,7 +187,10 @@ __export(src_exports, {
181
187
  useRequest: () => useRequest,
182
188
  useRequestHeader: () => useRequestHeader,
183
189
  useRequestParameter: () => useRequestParameter,
190
+ useUniformMeshLocation: () => useUniformMeshLocation,
191
+ useUniformMeshLocationContext: () => useUniformMeshLocationContext,
184
192
  useUniformMeshSdk: () => useUniformMeshSdk,
193
+ useUniformMeshSdkContext: () => useUniformMeshSdkContext,
185
194
  useVariables: () => useVariables,
186
195
  variablesToList: () => variablesToList
187
196
  });
@@ -1076,7 +1085,7 @@ var ProductPreviewList = ({
1076
1085
  import_design_system3.scrollbarStyles
1077
1086
  ],
1078
1087
  children: products == null ? void 0 : products.map((product, index) => {
1079
- var _a;
1088
+ var _a, _b;
1080
1089
  const [category] = (product == null ? void 0 : product.categories) || [];
1081
1090
  const categoryName = typeof category === "undefined" || !categories ? void 0 : (_a = categories.find((c) => c.id === category.id)) == null ? void 0 : _a.name;
1082
1091
  return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("li", { css: productPreviewListItem, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
@@ -1089,13 +1098,13 @@ var ProductPreviewList = ({
1089
1098
  "img",
1090
1099
  {
1091
1100
  src: product.thumbnailUrl,
1092
- alt: typeof product.title === "string" ? product.title : `Product ${index}`,
1101
+ alt: typeof product.title === "string" ? product.title : product.name || `Product ${index}`,
1093
1102
  css: productPreviewListImage,
1094
1103
  "data-test-id": "product-image"
1095
1104
  }
1096
1105
  ) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { css: productPreviewListImageDefault }),
1097
1106
  /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("h4", { css: productPreviewListTitle, "data-test-id": "product-name", children: [
1098
- product.title,
1107
+ product.title || product.name,
1099
1108
  categoryName && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { css: productPreviewListCategoryText, children: categoryName })
1100
1109
  ] }),
1101
1110
  product && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
@@ -1108,12 +1117,12 @@ var ProductPreviewList = ({
1108
1117
  "Price: ",
1109
1118
  product.price
1110
1119
  ] }) : null,
1111
- product.editLink ? /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
1120
+ product.editLink || product.url ? /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
1112
1121
  "a",
1113
1122
  {
1114
1123
  css: productPreviewListLinkBtn,
1115
- href: product.editLink,
1116
- title: `Go to ${product.title}`,
1124
+ href: (_b = product.editLink) != null ? _b : product.url,
1125
+ title: `Go to ${product.title || product.name}`,
1117
1126
  target: "_blank",
1118
1127
  rel: "noopener noreferrer",
1119
1128
  "data-test-id": "edit-product-button",
@@ -2828,6 +2837,18 @@ var import_design_system13 = require("@uniformdev/design-system");
2828
2837
  var import_react25 = require("react");
2829
2838
  var import_jsx_runtime26 = require("@emotion/react/jsx-runtime");
2830
2839
  var UniformMeshSdkContext = (0, import_react25.createContext)(void 0);
2840
+ var UniformMeshSdkContextProvider = ({ children }) => {
2841
+ let value = void 0;
2842
+ if (typeof window !== "undefined" && typeof window.UniformMeshSDK !== "undefined") {
2843
+ value = {
2844
+ sdk: window.UniformMeshSDK
2845
+ };
2846
+ }
2847
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(UniformMeshSdkContext.Provider, { value, children: [
2848
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_design_system13.Theme, {}),
2849
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(UniformMeshLocationContextProvider, { children })
2850
+ ] });
2851
+ };
2831
2852
  var useUniformMeshSdkContext = () => {
2832
2853
  const context = (0, import_react25.useContext)(UniformMeshSdkContext);
2833
2854
  if (!context) {
@@ -2844,7 +2865,9 @@ function useUniformMeshSdk() {
2844
2865
 
2845
2866
  // src/components/UniformMeshLocationContext.tsx
2846
2867
  var import_jsx_runtime27 = require("@emotion/react/jsx-runtime");
2847
- var UniformMeshLocationContext = (0, import_react26.createContext)(void 0);
2868
+ var UniformMeshLocationContext = (0, import_react26.createContext)(
2869
+ void 0
2870
+ );
2848
2871
  var UniformMeshLocationContextProvider = ({
2849
2872
  children
2850
2873
  }) => {
@@ -2875,9 +2898,20 @@ var useUniformMeshLocationContext = () => {
2875
2898
  };
2876
2899
 
2877
2900
  // src/hooks/useMeshLocation.ts
2901
+ var legacyWarned = false;
2878
2902
  function useMeshLocation(expectedLocation) {
2879
2903
  const { location } = useUniformMeshLocationContext();
2880
- if (expectedLocation && location.type !== expectedLocation) {
2904
+ let effectiveExpected = expectedLocation;
2905
+ if (expectedLocation === "dataTypeInstance") {
2906
+ effectiveExpected = "dataResource";
2907
+ if (!legacyWarned) {
2908
+ console.warn(
2909
+ "`dataTypeInstance` mesh location is deprecated, please switch to `dataResource` instead."
2910
+ );
2911
+ legacyWarned = true;
2912
+ }
2913
+ }
2914
+ if (effectiveExpected && location.type !== effectiveExpected) {
2881
2915
  throw new Error(`Expected location type ${expectedLocation} but got ${location.type}`);
2882
2916
  }
2883
2917
  const backdoorLocation = (0, import_react27.useRef)(location);
@@ -3354,7 +3388,7 @@ function DataResourceVariablesList({
3354
3388
  const {
3355
3389
  value,
3356
3390
  metadata: { dataType }
3357
- } = useMeshLocation("dataResource");
3391
+ } = useMeshLocation("dataTypeInstance");
3358
3392
  const variableDefinitions = variablesToList(dataType.variables);
3359
3393
  if (variableDefinitions.length === 0) {
3360
3394
  if (NoVariablesComponent) {
@@ -4807,6 +4841,12 @@ var QueryFilter = ({
4807
4841
  ] });
4808
4842
  };
4809
4843
 
4844
+ // src/hooks/useUniformMeshLocation.ts
4845
+ function useUniformMeshLocation() {
4846
+ const { location } = useUniformMeshLocationContext();
4847
+ return location;
4848
+ }
4849
+
4810
4850
  // src/hooks/index.ts
4811
4851
  var import_design_system33 = require("@uniformdev/design-system");
4812
4852
 
@@ -4842,6 +4882,7 @@ __reExport(src_exports, require("@uniformdev/mesh-sdk"), module.exports);
4842
4882
  InputSelect,
4843
4883
  InputToggle,
4844
4884
  InputVariables,
4885
+ KeywordSearchInput,
4845
4886
  Label,
4846
4887
  LinkButton,
4847
4888
  LoadingIndicator,
@@ -4897,6 +4938,10 @@ __reExport(src_exports, require("@uniformdev/mesh-sdk"), module.exports);
4897
4938
  TextVariableRenderer,
4898
4939
  Textarea,
4899
4940
  Theme,
4941
+ UniformMeshLocationContext,
4942
+ UniformMeshLocationContextProvider,
4943
+ UniformMeshSdkContext,
4944
+ UniformMeshSdkContextProvider,
4900
4945
  VariableEditor,
4901
4946
  VariablesList,
4902
4947
  VariablesProvider,
@@ -4965,6 +5010,7 @@ __reExport(src_exports, require("@uniformdev/mesh-sdk"), module.exports);
4965
5010
  selectedItemTitle,
4966
5011
  urlEncodeRequestParameter,
4967
5012
  urlEncodeRequestUrl,
5013
+ useInitializeUniformMeshSdk,
4968
5014
  useMeshLocation,
4969
5015
  useObjectSearchContext,
4970
5016
  useParameterShell,
@@ -4973,7 +5019,10 @@ __reExport(src_exports, require("@uniformdev/mesh-sdk"), module.exports);
4973
5019
  useRequest,
4974
5020
  useRequestHeader,
4975
5021
  useRequestParameter,
5022
+ useUniformMeshLocation,
5023
+ useUniformMeshLocationContext,
4976
5024
  useUniformMeshSdk,
5025
+ useUniformMeshSdkContext,
4977
5026
  useVariables,
4978
5027
  variablesToList
4979
5028
  });
package/dist/index.mjs CHANGED
@@ -893,7 +893,7 @@ var ProductPreviewList = ({
893
893
  scrollbarStyles
894
894
  ],
895
895
  children: products == null ? void 0 : products.map((product, index) => {
896
- var _a;
896
+ var _a, _b;
897
897
  const [category] = (product == null ? void 0 : product.categories) || [];
898
898
  const categoryName = typeof category === "undefined" || !categories ? void 0 : (_a = categories.find((c) => c.id === category.id)) == null ? void 0 : _a.name;
899
899
  return /* @__PURE__ */ jsx18("li", { css: productPreviewListItem, children: /* @__PURE__ */ jsxs7(
@@ -906,13 +906,13 @@ var ProductPreviewList = ({
906
906
  "img",
907
907
  {
908
908
  src: product.thumbnailUrl,
909
- alt: typeof product.title === "string" ? product.title : `Product ${index}`,
909
+ alt: typeof product.title === "string" ? product.title : product.name || `Product ${index}`,
910
910
  css: productPreviewListImage,
911
911
  "data-test-id": "product-image"
912
912
  }
913
913
  ) : /* @__PURE__ */ jsx18("div", { css: productPreviewListImageDefault }),
914
914
  /* @__PURE__ */ jsxs7("h4", { css: productPreviewListTitle, "data-test-id": "product-name", children: [
915
- product.title,
915
+ product.title || product.name,
916
916
  categoryName && /* @__PURE__ */ jsx18("span", { css: productPreviewListCategoryText, children: categoryName })
917
917
  ] }),
918
918
  product && /* @__PURE__ */ jsxs7(Fragment2, { children: [
@@ -925,12 +925,12 @@ var ProductPreviewList = ({
925
925
  "Price: ",
926
926
  product.price
927
927
  ] }) : null,
928
- product.editLink ? /* @__PURE__ */ jsxs7(
928
+ product.editLink || product.url ? /* @__PURE__ */ jsxs7(
929
929
  "a",
930
930
  {
931
931
  css: productPreviewListLinkBtn,
932
- href: product.editLink,
933
- title: `Go to ${product.title}`,
932
+ href: (_b = product.editLink) != null ? _b : product.url,
933
+ title: `Go to ${product.title || product.name}`,
934
934
  target: "_blank",
935
935
  rel: "noopener noreferrer",
936
936
  "data-test-id": "edit-product-button",
@@ -2655,6 +2655,18 @@ import { Theme } from "@uniformdev/design-system";
2655
2655
  import { createContext, useContext as useContext3 } from "react";
2656
2656
  import { jsx as jsx26, jsxs as jsxs15 } from "@emotion/react/jsx-runtime";
2657
2657
  var UniformMeshSdkContext = createContext(void 0);
2658
+ var UniformMeshSdkContextProvider = ({ children }) => {
2659
+ let value = void 0;
2660
+ if (typeof window !== "undefined" && typeof window.UniformMeshSDK !== "undefined") {
2661
+ value = {
2662
+ sdk: window.UniformMeshSDK
2663
+ };
2664
+ }
2665
+ return /* @__PURE__ */ jsxs15(UniformMeshSdkContext.Provider, { value, children: [
2666
+ /* @__PURE__ */ jsx26(Theme, {}),
2667
+ /* @__PURE__ */ jsx26(UniformMeshLocationContextProvider, { children })
2668
+ ] });
2669
+ };
2658
2670
  var useUniformMeshSdkContext = () => {
2659
2671
  const context = useContext3(UniformMeshSdkContext);
2660
2672
  if (!context) {
@@ -2671,7 +2683,9 @@ function useUniformMeshSdk() {
2671
2683
 
2672
2684
  // src/components/UniformMeshLocationContext.tsx
2673
2685
  import { jsx as jsx27 } from "@emotion/react/jsx-runtime";
2674
- var UniformMeshLocationContext = createContext2(void 0);
2686
+ var UniformMeshLocationContext = createContext2(
2687
+ void 0
2688
+ );
2675
2689
  var UniformMeshLocationContextProvider = ({
2676
2690
  children
2677
2691
  }) => {
@@ -2702,9 +2716,20 @@ var useUniformMeshLocationContext = () => {
2702
2716
  };
2703
2717
 
2704
2718
  // src/hooks/useMeshLocation.ts
2719
+ var legacyWarned = false;
2705
2720
  function useMeshLocation(expectedLocation) {
2706
2721
  const { location } = useUniformMeshLocationContext();
2707
- if (expectedLocation && location.type !== expectedLocation) {
2722
+ let effectiveExpected = expectedLocation;
2723
+ if (expectedLocation === "dataTypeInstance") {
2724
+ effectiveExpected = "dataResource";
2725
+ if (!legacyWarned) {
2726
+ console.warn(
2727
+ "`dataTypeInstance` mesh location is deprecated, please switch to `dataResource` instead."
2728
+ );
2729
+ legacyWarned = true;
2730
+ }
2731
+ }
2732
+ if (effectiveExpected && location.type !== effectiveExpected) {
2708
2733
  throw new Error(`Expected location type ${expectedLocation} but got ${location.type}`);
2709
2734
  }
2710
2735
  const backdoorLocation = useRef7(location);
@@ -3191,7 +3216,7 @@ function DataResourceVariablesList({
3191
3216
  const {
3192
3217
  value,
3193
3218
  metadata: { dataType }
3194
- } = useMeshLocation("dataResource");
3219
+ } = useMeshLocation("dataTypeInstance");
3195
3220
  const variableDefinitions = variablesToList(dataType.variables);
3196
3221
  if (variableDefinitions.length === 0) {
3197
3222
  if (NoVariablesComponent) {
@@ -4662,6 +4687,12 @@ var QueryFilter = ({
4662
4687
  ] });
4663
4688
  };
4664
4689
 
4690
+ // src/hooks/useUniformMeshLocation.ts
4691
+ function useUniformMeshLocation() {
4692
+ const { location } = useUniformMeshLocationContext();
4693
+ return location;
4694
+ }
4695
+
4665
4696
  // src/hooks/index.ts
4666
4697
  import { ParameterShellContext, useParameterShell } from "@uniformdev/design-system";
4667
4698
 
@@ -4684,6 +4715,7 @@ import {
4684
4715
  InputKeywordSearch as InputKeywordSearch4,
4685
4716
  InputSelect as InputSelect8,
4686
4717
  InputToggle,
4718
+ InputKeywordSearch as InputKeywordSearch5,
4687
4719
  Label,
4688
4720
  LoadingIndicator as LoadingIndicator4,
4689
4721
  LoadingOverlay as LoadingOverlay2,
@@ -4730,6 +4762,7 @@ export {
4730
4762
  InputSelect8 as InputSelect,
4731
4763
  InputToggle,
4732
4764
  InputVariables,
4765
+ InputKeywordSearch5 as KeywordSearchInput,
4733
4766
  Label,
4734
4767
  LinkButton,
4735
4768
  LoadingIndicator4 as LoadingIndicator,
@@ -4785,6 +4818,10 @@ export {
4785
4818
  TextVariableRenderer,
4786
4819
  Textarea,
4787
4820
  Theme3 as Theme,
4821
+ UniformMeshLocationContext,
4822
+ UniformMeshLocationContextProvider,
4823
+ UniformMeshSdkContext,
4824
+ UniformMeshSdkContextProvider,
4788
4825
  VariableEditor,
4789
4826
  VariablesList,
4790
4827
  VariablesProvider,
@@ -4853,6 +4890,7 @@ export {
4853
4890
  selectedItemTitle,
4854
4891
  urlEncodeRequestParameter,
4855
4892
  urlEncodeRequestUrl,
4893
+ useInitializeUniformMeshSdk,
4856
4894
  useMeshLocation,
4857
4895
  useObjectSearchContext,
4858
4896
  useParameterShell,
@@ -4861,7 +4899,10 @@ export {
4861
4899
  useRequest,
4862
4900
  useRequestHeader,
4863
4901
  useRequestParameter,
4902
+ useUniformMeshLocation,
4903
+ useUniformMeshLocationContext,
4864
4904
  useUniformMeshSdk,
4905
+ useUniformMeshSdkContext,
4865
4906
  useVariables,
4866
4907
  variablesToList
4867
4908
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/mesh-sdk-react",
3
- "version": "18.35.1-alpha.12+d5e86f567",
3
+ "version": "18.35.1-alpha.17+c528ec3cb",
4
4
  "description": "Uniform Mesh Framework SDK for React",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -43,8 +43,8 @@
43
43
  "document": "api-extractor run --local"
44
44
  },
45
45
  "dependencies": {
46
- "@uniformdev/design-system": "18.35.1-alpha.12+d5e86f567",
47
- "@uniformdev/mesh-sdk": "18.35.1-alpha.12+d5e86f567",
46
+ "@uniformdev/design-system": "18.35.1-alpha.17+c528ec3cb",
47
+ "@uniformdev/mesh-sdk": "18.35.1-alpha.17+c528ec3cb",
48
48
  "formik": "^2.2.9",
49
49
  "react-beautiful-dnd": "13.1.1",
50
50
  "react-icons": "4.8.0",
@@ -73,5 +73,5 @@
73
73
  "publishConfig": {
74
74
  "access": "public"
75
75
  },
76
- "gitHead": "d5e86f5673575aecfcf517e684922871315f279b"
76
+ "gitHead": "c528ec3cbb765bfd058357968a9be5ae0926362c"
77
77
  }