@uniformdev/mesh-sdk-react 18.2.2 → 18.3.1-alpha.22
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 +41 -5
- package/dist/index.esm.js +62 -15
- package/dist/index.js +92 -43
- package/dist/index.mjs +62 -15
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -531,12 +531,12 @@ type DataSourceEditorProps = PropsWithChildren<{
|
|
|
531
531
|
* by `createLocationValidator`.
|
|
532
532
|
*/
|
|
533
533
|
onChange: SetLocationValueDispatch<DataSourceLocationValue>;
|
|
534
|
-
}
|
|
534
|
+
} & Pick<VariablesProviderProps, 'editVariableComponent'>>;
|
|
535
535
|
/**
|
|
536
536
|
* Wrapper for editing a data source using Uniform Mesh SDK components that rely on `useRequest()`
|
|
537
537
|
* or `useVariables()`, or custom components that use the same hooks.
|
|
538
538
|
*/
|
|
539
|
-
declare function DataSourceEditor({ onChange, children }: DataSourceEditorProps): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
|
|
539
|
+
declare function DataSourceEditor({ onChange, children, editVariableComponent }: DataSourceEditorProps): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
|
|
540
540
|
|
|
541
541
|
type DataTypeEditorProps = PropsWithChildren<{
|
|
542
542
|
/**
|
|
@@ -545,12 +545,12 @@ type DataTypeEditorProps = PropsWithChildren<{
|
|
|
545
545
|
* by `createLocationValidator`.
|
|
546
546
|
*/
|
|
547
547
|
onChange: SetLocationValueDispatch<DataTypeLocationValue>;
|
|
548
|
-
}
|
|
548
|
+
} & Pick<VariablesProviderProps, 'editVariableComponent'>>;
|
|
549
549
|
/**
|
|
550
550
|
* Wrapper for editing a data type using Uniform Mesh SDK components that rely on `useRequest()`
|
|
551
551
|
* or `useVariables()`, or custom components that use the same hooks.
|
|
552
552
|
*/
|
|
553
|
-
declare function DataTypeEditor({ onChange, children }: DataTypeEditorProps): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
|
|
553
|
+
declare function DataTypeEditor({ onChange, children, editVariableComponent }: DataTypeEditorProps): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
|
|
554
554
|
|
|
555
555
|
type MeshAppProps = {
|
|
556
556
|
loadingComponent?: React__default.ComponentType;
|
|
@@ -560,13 +560,17 @@ type MeshAppProps = {
|
|
|
560
560
|
};
|
|
561
561
|
declare const MeshApp: React__default.FC<React__default.PropsWithChildren<MeshAppProps>>;
|
|
562
562
|
|
|
563
|
+
/** Editor component to let you write a request body for POST requests */
|
|
563
564
|
declare function RequestBody(): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
|
|
564
565
|
|
|
566
|
+
/** Editor component to manage HTTP headers on a request */
|
|
565
567
|
declare function RequestHeaders({ disableVariables }: Pick<InputVariablesProps, 'disableVariables'>): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
|
|
566
568
|
|
|
569
|
+
/** Dropdown to pick a HTTP method for a request */
|
|
567
570
|
declare function RequestMethodSelect(props: Omit<InputSelectProps, 'value' | 'onChange' | 'options'>): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
|
|
568
571
|
|
|
569
572
|
type RequestParametersProps = Pick<InputVariablesProps, 'disableVariables'>;
|
|
573
|
+
/** Component to manage query parameters on a request */
|
|
570
574
|
declare function RequestParameters({ disableVariables }: Pick<InputVariablesProps, 'disableVariables'>): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
|
|
571
575
|
|
|
572
576
|
type RequestParameter = {
|
|
@@ -619,6 +623,7 @@ type RequestContext = {
|
|
|
619
623
|
dispatch: (event: RequestAction) => void;
|
|
620
624
|
request: Readonly<RequestData>;
|
|
621
625
|
};
|
|
626
|
+
/** Provides a mutable HTTP request object context. Components such as RequestBody and RequestUrl use this context to render. */
|
|
622
627
|
declare function RequestProvider({ value, onChange, children }: RequestProviderProps): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
|
|
623
628
|
declare function useRequest(): RequestContext;
|
|
624
629
|
|
|
@@ -637,13 +642,44 @@ type RequestTypeContainerProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
|
637
642
|
* </div> */
|
|
638
643
|
declare const RequestTypeContainer: ({ bgColor, children, ...props }: RequestTypeContainerProps) => _emotion_react_types_jsx_namespace.EmotionJSX.Element;
|
|
639
644
|
|
|
645
|
+
/**
|
|
646
|
+
* Displays the current full URL of the request, including the base URL if one is set
|
|
647
|
+
*/
|
|
640
648
|
declare function RequestUrl(): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
|
|
641
649
|
|
|
650
|
+
/**
|
|
651
|
+
* Editor to modify the current URL of the request
|
|
652
|
+
* Note: entering query string parameters automatically converts them and syncs the request state with them
|
|
653
|
+
*/
|
|
642
654
|
declare function RequestUrlInput(props: Omit<InputVariablesProps, 'value' | 'onChange'>): _emotion_react_types_jsx_namespace.EmotionJSX.Element;
|
|
643
655
|
|
|
644
656
|
declare function urlEncodeRequestUrl(url: string, varValues?: Record<string, DataVariableDefinition>): string;
|
|
645
657
|
declare function urlEncodeRequestParameter(parameter: RequestParameter, varValues?: Record<string, DataVariableDefinition>): RequestParameter;
|
|
646
658
|
|
|
659
|
+
/**
|
|
660
|
+
* Hook to make it simple to read and write a specific request header by name,
|
|
661
|
+
* instead of supporting multiple values in an array like native dispatch.
|
|
662
|
+
*
|
|
663
|
+
* NOTE: if multiple values are added for the named header, this hook will bind to the FIRST
|
|
664
|
+
* instance of the header and leave the other values alone.
|
|
665
|
+
*/
|
|
666
|
+
declare function useRequestHeader(headerName: string): {
|
|
667
|
+
value: string;
|
|
668
|
+
update: (value: string) => void;
|
|
669
|
+
};
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* Hook to make it simple to read and write a specific request query string parameter by name,
|
|
673
|
+
* instead of supporting multiple values in an array like native dispatch.
|
|
674
|
+
*
|
|
675
|
+
* NOTE: if multiple values are added for the named parameter, this hook will bind to the FIRST
|
|
676
|
+
* instance of the parameter and leave the other values alone.
|
|
677
|
+
*/
|
|
678
|
+
declare function useRequestParameter(paramName: string): {
|
|
679
|
+
value: string;
|
|
680
|
+
update: (value: string) => void;
|
|
681
|
+
};
|
|
682
|
+
|
|
647
683
|
/** @deprecated */
|
|
648
684
|
interface UniformMeshLocationContextValue<TLocationValue = unknown, TLocationSetValue = TLocationValue> {
|
|
649
685
|
location: MeshLocation<TLocationValue, TLocationSetValue>;
|
|
@@ -709,4 +745,4 @@ declare function useUniformMeshSdk(): _uniformdev_mesh_sdk.UniformMeshSDK;
|
|
|
709
745
|
*/
|
|
710
746
|
declare function createLocationValidator<TSetValue>(setValue: SetLocationValueDispatch<TSetValue>, validate: (newValue: TSetValue, currentResult: SetValueOptions | undefined) => SetValueOptions): SetLocationValueDispatch<TSetValue>;
|
|
711
747
|
|
|
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 };
|
|
748
|
+
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, useRequestHeader, useRequestParameter, useUniformMeshLocation, useUniformMeshLocationContext, useUniformMeshSdk, useUniformMeshSdkContext, useVariables, variablesToList };
|
package/dist/index.esm.js
CHANGED
|
@@ -2688,8 +2688,11 @@ function DefaultDamItemRenderer({ item }) {
|
|
|
2688
2688
|
// src/components/DataResourceVariablesList.tsx
|
|
2689
2689
|
import { Callout as Callout3, Input as Input3 } from "@uniformdev/design-system";
|
|
2690
2690
|
|
|
2691
|
+
// src/hooks/useMeshLocation.ts
|
|
2692
|
+
import { useMemo as useMemo4, useRef as useRef7 } from "react";
|
|
2693
|
+
|
|
2691
2694
|
// src/components/UniformMeshLocationContext.tsx
|
|
2692
|
-
import { createContext as createContext2, useContext as useContext4,
|
|
2695
|
+
import { createContext as createContext2, useContext as useContext4, useMemo as useMemo3, useState as useState6 } from "react";
|
|
2693
2696
|
|
|
2694
2697
|
// src/components/UniformMeshSdkContext.tsx
|
|
2695
2698
|
import { Theme } from "@uniformdev/design-system";
|
|
@@ -2735,7 +2738,7 @@ var UniformMeshLocationContextProvider = ({
|
|
|
2735
2738
|
const valueChangeListener = (event) => {
|
|
2736
2739
|
setLocation((old) => ({ ...old, value: event.newValue }));
|
|
2737
2740
|
};
|
|
2738
|
-
|
|
2741
|
+
useMemo3(() => {
|
|
2739
2742
|
sdk.events.on("onValueChanged", valueChangeListener);
|
|
2740
2743
|
return () => {
|
|
2741
2744
|
sdk.events.off("onValueChanged", valueChangeListener);
|
|
@@ -2768,12 +2771,18 @@ function useMeshLocation(expectedLocation) {
|
|
|
2768
2771
|
if (effectiveExpected && location.type !== effectiveExpected) {
|
|
2769
2772
|
throw new Error(`Expected location type ${expectedLocation} but got ${location.type}`);
|
|
2770
2773
|
}
|
|
2774
|
+
const backdoorLocation = useRef7(location);
|
|
2775
|
+
backdoorLocation.current = location;
|
|
2776
|
+
const stabilizedSetValueProxy = useMemo4(
|
|
2777
|
+
() => (dispatch) => {
|
|
2778
|
+
const { newValue, options } = dispatch(backdoorLocation.current.value);
|
|
2779
|
+
backdoorLocation.current.setValue(newValue, options);
|
|
2780
|
+
},
|
|
2781
|
+
[]
|
|
2782
|
+
);
|
|
2771
2783
|
const proxyLocation = {
|
|
2772
2784
|
...location,
|
|
2773
|
-
setValue:
|
|
2774
|
-
const { newValue, options } = dispatch(location.value);
|
|
2775
|
-
location.setValue(newValue, options);
|
|
2776
|
-
}
|
|
2785
|
+
setValue: stabilizedSetValueProxy
|
|
2777
2786
|
};
|
|
2778
2787
|
return proxyLocation;
|
|
2779
2788
|
}
|
|
@@ -3345,8 +3354,8 @@ function VariableEditor({ variable, onSubmit, onCancel }) {
|
|
|
3345
3354
|
),
|
|
3346
3355
|
/* @__PURE__ */ jsx28(Input2, { ...getFieldProps("default"), label: "Default Value", autoComplete: "off" }),
|
|
3347
3356
|
/* @__PURE__ */ jsxs16("div", { css: variablesFormBtnGroup, children: [
|
|
3348
|
-
/* @__PURE__ */ jsx28(Button2, { type: "submit", children: "
|
|
3349
|
-
/* @__PURE__ */ jsx28(Button2, { type: "button", buttonType: "ghost", onClick: onCancel, children: "
|
|
3357
|
+
/* @__PURE__ */ jsx28(Button2, { type: "submit", children: "OK" }),
|
|
3358
|
+
/* @__PURE__ */ jsx28(Button2, { type: "button", buttonType: "ghost", onClick: onCancel, children: "Cancel" })
|
|
3350
3359
|
] })
|
|
3351
3360
|
] });
|
|
3352
3361
|
}
|
|
@@ -4121,7 +4130,7 @@ function RequestParameters({ disableVariables }) {
|
|
|
4121
4130
|
|
|
4122
4131
|
// src/components/Request/RequestUrl.tsx
|
|
4123
4132
|
import { css as css23 } from "@emotion/react";
|
|
4124
|
-
import { useMemo as
|
|
4133
|
+
import { useMemo as useMemo6 } from "react";
|
|
4125
4134
|
|
|
4126
4135
|
// src/components/Request/urlEncodeRequestParameter.ts
|
|
4127
4136
|
function urlEncodeRequestUrl(url, varValues) {
|
|
@@ -4147,7 +4156,7 @@ function RequestUrl() {
|
|
|
4147
4156
|
var _a, _b;
|
|
4148
4157
|
const { variables } = useVariables();
|
|
4149
4158
|
const { request } = useRequest();
|
|
4150
|
-
const mergedParameters =
|
|
4159
|
+
const mergedParameters = useMemo6(() => {
|
|
4151
4160
|
var _a2;
|
|
4152
4161
|
if (!((_a2 = request.baseRequest) == null ? void 0 : _a2.parameters)) {
|
|
4153
4162
|
return request.parameters;
|
|
@@ -4221,9 +4230,43 @@ function RequestUrlInput(props) {
|
|
|
4221
4230
|
);
|
|
4222
4231
|
}
|
|
4223
4232
|
|
|
4233
|
+
// src/components/Request/useRequestHeader.ts
|
|
4234
|
+
function useRequestHeader(headerName) {
|
|
4235
|
+
var _a, _b;
|
|
4236
|
+
const { request, dispatch } = useRequest();
|
|
4237
|
+
const headerIndex = request.headers.findIndex((f) => f.key === headerName);
|
|
4238
|
+
return {
|
|
4239
|
+
value: (_b = (_a = request.headers[headerIndex]) == null ? void 0 : _a.value) != null ? _b : "",
|
|
4240
|
+
update: (value) => {
|
|
4241
|
+
dispatch({
|
|
4242
|
+
type: "updateHeader",
|
|
4243
|
+
header: { key: headerName, value },
|
|
4244
|
+
index: headerIndex >= 0 ? headerIndex : void 0
|
|
4245
|
+
});
|
|
4246
|
+
}
|
|
4247
|
+
};
|
|
4248
|
+
}
|
|
4249
|
+
|
|
4250
|
+
// src/components/Request/useRequestParameter.ts
|
|
4251
|
+
function useRequestParameter(paramName) {
|
|
4252
|
+
var _a, _b;
|
|
4253
|
+
const { request, dispatch } = useRequest();
|
|
4254
|
+
const paramIndex = request.parameters.findIndex((f) => f.key === paramName);
|
|
4255
|
+
return {
|
|
4256
|
+
value: (_b = (_a = request.parameters[paramIndex]) == null ? void 0 : _a.value) != null ? _b : "",
|
|
4257
|
+
update: (value) => {
|
|
4258
|
+
dispatch({
|
|
4259
|
+
type: "updateParameter",
|
|
4260
|
+
parameter: { key: paramName, value },
|
|
4261
|
+
index: paramIndex >= 0 ? paramIndex : void 0
|
|
4262
|
+
});
|
|
4263
|
+
}
|
|
4264
|
+
};
|
|
4265
|
+
}
|
|
4266
|
+
|
|
4224
4267
|
// src/components/DataSourceEditor.tsx
|
|
4225
4268
|
import { jsx as jsx41 } from "@emotion/react/jsx-runtime";
|
|
4226
|
-
function DataSourceEditor({ onChange, children }) {
|
|
4269
|
+
function DataSourceEditor({ onChange, children, editVariableComponent }) {
|
|
4227
4270
|
var _a;
|
|
4228
4271
|
const { value } = useMeshLocation("dataSource");
|
|
4229
4272
|
const currentRequestValue = convertDataSourceToRequestData(value);
|
|
@@ -4232,6 +4275,7 @@ function DataSourceEditor({ onChange, children }) {
|
|
|
4232
4275
|
{
|
|
4233
4276
|
value: (_a = value.variables) != null ? _a : {},
|
|
4234
4277
|
onChange: (newValue) => onChange((prev) => ({ newValue: { ...prev, variables: newValue } })),
|
|
4278
|
+
editVariableComponent,
|
|
4235
4279
|
children: /* @__PURE__ */ jsx41(
|
|
4236
4280
|
RequestProvider,
|
|
4237
4281
|
{
|
|
@@ -4270,7 +4314,7 @@ function convertRequestDataToDataSource(dataSource, requestData) {
|
|
|
4270
4314
|
|
|
4271
4315
|
// src/components/DataTypeEditor.tsx
|
|
4272
4316
|
import { jsx as jsx42 } from "@emotion/react/jsx-runtime";
|
|
4273
|
-
function DataTypeEditor({ onChange, children }) {
|
|
4317
|
+
function DataTypeEditor({ onChange, children, editVariableComponent }) {
|
|
4274
4318
|
var _a;
|
|
4275
4319
|
const {
|
|
4276
4320
|
value,
|
|
@@ -4282,6 +4326,7 @@ function DataTypeEditor({ onChange, children }) {
|
|
|
4282
4326
|
{
|
|
4283
4327
|
value: (_a = value.variables) != null ? _a : {},
|
|
4284
4328
|
onChange: (newValue) => onChange((prev) => ({ newValue: { ...prev, variables: newValue } })),
|
|
4329
|
+
editVariableComponent,
|
|
4285
4330
|
children: /* @__PURE__ */ jsx42(
|
|
4286
4331
|
RequestProvider,
|
|
4287
4332
|
{
|
|
@@ -4332,12 +4377,12 @@ import { LoadingIndicator as LoadingIndicator2, Theme as Theme2 } from "@uniform
|
|
|
4332
4377
|
|
|
4333
4378
|
// src/hooks/useInitializeUniformMeshSdk.ts
|
|
4334
4379
|
import { initializeUniformMeshSDK } from "@uniformdev/mesh-sdk";
|
|
4335
|
-
import { useEffect as
|
|
4380
|
+
import { useEffect as useEffect7, useRef as useRef9, useState as useState9 } from "react";
|
|
4336
4381
|
var useInitializeUniformMeshSdk = ({ autoResizingDisabled } = {}) => {
|
|
4337
4382
|
const [error, setError] = useState9();
|
|
4338
4383
|
const [sdk, setSdk] = useState9();
|
|
4339
|
-
const initializationInProgress =
|
|
4340
|
-
|
|
4384
|
+
const initializationInProgress = useRef9(false);
|
|
4385
|
+
useEffect7(
|
|
4341
4386
|
() => {
|
|
4342
4387
|
if (typeof window === "undefined" || sdk) {
|
|
4343
4388
|
return;
|
|
@@ -4553,6 +4598,8 @@ export {
|
|
|
4553
4598
|
useProductQueryContext,
|
|
4554
4599
|
useProductSearchContext,
|
|
4555
4600
|
useRequest,
|
|
4601
|
+
useRequestHeader,
|
|
4602
|
+
useRequestParameter,
|
|
4556
4603
|
useUniformMeshLocation,
|
|
4557
4604
|
useUniformMeshLocationContext,
|
|
4558
4605
|
useUniformMeshSdk,
|
package/dist/index.js
CHANGED
|
@@ -152,6 +152,8 @@ __export(src_exports, {
|
|
|
152
152
|
useProductQueryContext: () => useProductQueryContext,
|
|
153
153
|
useProductSearchContext: () => useProductSearchContext,
|
|
154
154
|
useRequest: () => useRequest,
|
|
155
|
+
useRequestHeader: () => useRequestHeader,
|
|
156
|
+
useRequestParameter: () => useRequestParameter,
|
|
155
157
|
useUniformMeshLocation: () => useUniformMeshLocation,
|
|
156
158
|
useUniformMeshLocationContext: () => useUniformMeshLocationContext,
|
|
157
159
|
useUniformMeshSdk: () => useUniformMeshSdk,
|
|
@@ -2835,6 +2837,9 @@ function DefaultDamItemRenderer({ item }) {
|
|
|
2835
2837
|
// src/components/DataResourceVariablesList.tsx
|
|
2836
2838
|
var import_design_system15 = require("@uniformdev/design-system");
|
|
2837
2839
|
|
|
2840
|
+
// src/hooks/useMeshLocation.ts
|
|
2841
|
+
var import_react27 = require("react");
|
|
2842
|
+
|
|
2838
2843
|
// src/components/UniformMeshLocationContext.tsx
|
|
2839
2844
|
var import_react26 = require("react");
|
|
2840
2845
|
|
|
@@ -2882,7 +2887,7 @@ var UniformMeshLocationContextProvider = ({
|
|
|
2882
2887
|
const valueChangeListener = (event) => {
|
|
2883
2888
|
setLocation((old) => ({ ...old, value: event.newValue }));
|
|
2884
2889
|
};
|
|
2885
|
-
(0, import_react26.
|
|
2890
|
+
(0, import_react26.useMemo)(() => {
|
|
2886
2891
|
sdk.events.on("onValueChanged", valueChangeListener);
|
|
2887
2892
|
return () => {
|
|
2888
2893
|
sdk.events.off("onValueChanged", valueChangeListener);
|
|
@@ -2915,33 +2920,39 @@ function useMeshLocation(expectedLocation) {
|
|
|
2915
2920
|
if (effectiveExpected && location.type !== effectiveExpected) {
|
|
2916
2921
|
throw new Error(`Expected location type ${expectedLocation} but got ${location.type}`);
|
|
2917
2922
|
}
|
|
2923
|
+
const backdoorLocation = (0, import_react27.useRef)(location);
|
|
2924
|
+
backdoorLocation.current = location;
|
|
2925
|
+
const stabilizedSetValueProxy = (0, import_react27.useMemo)(
|
|
2926
|
+
() => (dispatch) => {
|
|
2927
|
+
const { newValue, options } = dispatch(backdoorLocation.current.value);
|
|
2928
|
+
backdoorLocation.current.setValue(newValue, options);
|
|
2929
|
+
},
|
|
2930
|
+
[]
|
|
2931
|
+
);
|
|
2918
2932
|
const proxyLocation = {
|
|
2919
2933
|
...location,
|
|
2920
|
-
setValue:
|
|
2921
|
-
const { newValue, options } = dispatch(location.value);
|
|
2922
|
-
location.setValue(newValue, options);
|
|
2923
|
-
}
|
|
2934
|
+
setValue: stabilizedSetValueProxy
|
|
2924
2935
|
};
|
|
2925
2936
|
return proxyLocation;
|
|
2926
2937
|
}
|
|
2927
2938
|
|
|
2928
2939
|
// src/components/Variables/InputVariables.tsx
|
|
2929
|
-
var
|
|
2930
|
-
var
|
|
2940
|
+
var import_react29 = require("@emotion/react");
|
|
2941
|
+
var import_react30 = __toESM(require("@yaireo/tagify/dist/react.tagify"));
|
|
2931
2942
|
var React11 = __toESM(require("react"));
|
|
2932
2943
|
|
|
2933
2944
|
// src/components/Variables/InputVariables.styles.ts
|
|
2934
|
-
var
|
|
2935
|
-
var variablesFormContainer =
|
|
2945
|
+
var import_react28 = require("@emotion/react");
|
|
2946
|
+
var variablesFormContainer = import_react28.css`
|
|
2936
2947
|
> * {
|
|
2937
2948
|
margin: var(--spacing-base) 0 0;
|
|
2938
2949
|
}
|
|
2939
2950
|
`;
|
|
2940
|
-
var variablesFormBtnGroup =
|
|
2951
|
+
var variablesFormBtnGroup = import_react28.css`
|
|
2941
2952
|
display: flex;
|
|
2942
2953
|
gap: var(--spacing-sm);
|
|
2943
2954
|
`;
|
|
2944
|
-
var tagifyStyles =
|
|
2955
|
+
var tagifyStyles = import_react28.css`
|
|
2945
2956
|
:root {
|
|
2946
2957
|
--tagify-dd-color-primary: rgb(53, 149, 246);
|
|
2947
2958
|
--tagify-dd-bg-color: var(--white);
|
|
@@ -3492,8 +3503,8 @@ function VariableEditor({ variable, onSubmit, onCancel }) {
|
|
|
3492
3503
|
),
|
|
3493
3504
|
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_design_system13.Input, { ...getFieldProps("default"), label: "Default Value", autoComplete: "off" }),
|
|
3494
3505
|
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { css: variablesFormBtnGroup, children: [
|
|
3495
|
-
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_design_system13.Button, { type: "submit", children: "
|
|
3496
|
-
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_design_system13.Button, { type: "button", buttonType: "ghost", onClick: onCancel, children: "
|
|
3506
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_design_system13.Button, { type: "submit", children: "OK" }),
|
|
3507
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_design_system13.Button, { type: "button", buttonType: "ghost", onClick: onCancel, children: "Cancel" })
|
|
3497
3508
|
] })
|
|
3498
3509
|
] });
|
|
3499
3510
|
}
|
|
@@ -3613,9 +3624,9 @@ function InputVariables({
|
|
|
3613
3624
|
}
|
|
3614
3625
|
}, []);
|
|
3615
3626
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(import_jsx_runtime30.Fragment, { children: [
|
|
3616
|
-
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
3627
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_react29.Global, { styles: tagifyStyles }),
|
|
3617
3628
|
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
3618
|
-
|
|
3629
|
+
import_react30.default,
|
|
3619
3630
|
{
|
|
3620
3631
|
tagifyRef,
|
|
3621
3632
|
"aria-label": ariaLabel,
|
|
@@ -3663,13 +3674,13 @@ function InputVariables({
|
|
|
3663
3674
|
}
|
|
3664
3675
|
|
|
3665
3676
|
// src/components/Variables/VariablesList.tsx
|
|
3666
|
-
var
|
|
3677
|
+
var import_react32 = require("@emotion/react");
|
|
3667
3678
|
var import_design_system14 = require("@uniformdev/design-system");
|
|
3668
3679
|
var import_react_beautiful_dnd2 = require("react-beautiful-dnd");
|
|
3669
3680
|
|
|
3670
3681
|
// src/components/Variables/styles/VariablesList.styles.ts
|
|
3671
|
-
var
|
|
3672
|
-
var tableRow = (isDragging) =>
|
|
3682
|
+
var import_react31 = require("@emotion/react");
|
|
3683
|
+
var tableRow = (isDragging) => import_react31.css`
|
|
3673
3684
|
position: relative;
|
|
3674
3685
|
${isDragging ? `
|
|
3675
3686
|
display: table;
|
|
@@ -3677,7 +3688,7 @@ var tableRow = (isDragging) => import_react30.css`
|
|
|
3677
3688
|
top: auto !important;
|
|
3678
3689
|
` : void 0}
|
|
3679
3690
|
`;
|
|
3680
|
-
var tableCellDragIcon =
|
|
3691
|
+
var tableCellDragIcon = import_react31.css`
|
|
3681
3692
|
&::after {
|
|
3682
3693
|
content: '';
|
|
3683
3694
|
display: block;
|
|
@@ -3695,7 +3706,7 @@ var tableCellDragIcon = import_react30.css`
|
|
|
3695
3706
|
opacity: 1;
|
|
3696
3707
|
}
|
|
3697
3708
|
`;
|
|
3698
|
-
var variableName =
|
|
3709
|
+
var variableName = import_react31.css`
|
|
3699
3710
|
border: none;
|
|
3700
3711
|
color: var(--brand-secondary-5);
|
|
3701
3712
|
font-weight: var(--fw-medium);
|
|
@@ -3706,7 +3717,7 @@ var variableName = import_react30.css`
|
|
|
3706
3717
|
white-space: nowrap;
|
|
3707
3718
|
max-width: 20ch;
|
|
3708
3719
|
`;
|
|
3709
|
-
var variableValue =
|
|
3720
|
+
var variableValue = import_react31.css`
|
|
3710
3721
|
overflow: hidden;
|
|
3711
3722
|
text-overflow: ellipsis;
|
|
3712
3723
|
white-space: nowrap;
|
|
@@ -3800,7 +3811,7 @@ function VariablesList() {
|
|
|
3800
3811
|
title: `delete ${text}`,
|
|
3801
3812
|
css: [
|
|
3802
3813
|
import_design_system14.button,
|
|
3803
|
-
|
|
3814
|
+
import_react32.css`
|
|
3804
3815
|
background: transparent;
|
|
3805
3816
|
`
|
|
3806
3817
|
],
|
|
@@ -3895,10 +3906,10 @@ function TextVariableRenderer({ definition, value, setValue }) {
|
|
|
3895
3906
|
}
|
|
3896
3907
|
|
|
3897
3908
|
// src/components/Request/RequestBody.tsx
|
|
3898
|
-
var
|
|
3899
|
-
var
|
|
3909
|
+
var import_react34 = require("@emotion/react");
|
|
3910
|
+
var import_react35 = __toESM(require("@monaco-editor/react"));
|
|
3900
3911
|
var import_design_system16 = require("@uniformdev/design-system");
|
|
3901
|
-
var
|
|
3912
|
+
var import_react36 = require("react");
|
|
3902
3913
|
|
|
3903
3914
|
// src/components/Request/RequestProvider.tsx
|
|
3904
3915
|
var React12 = __toESM(require("react"));
|
|
@@ -3982,11 +3993,11 @@ function useRequest() {
|
|
|
3982
3993
|
}
|
|
3983
3994
|
|
|
3984
3995
|
// src/components/Request/styles/Request.styles.ts
|
|
3985
|
-
var
|
|
3986
|
-
var innerContentStyles =
|
|
3996
|
+
var import_react33 = require("@emotion/react");
|
|
3997
|
+
var innerContentStyles = import_react33.css`
|
|
3987
3998
|
background: var(--white);
|
|
3988
3999
|
`;
|
|
3989
|
-
var requestTypeContainer = (bgColor) =>
|
|
4000
|
+
var requestTypeContainer = (bgColor) => import_react33.css`
|
|
3990
4001
|
align-items: start;
|
|
3991
4002
|
background: ${bgColor};
|
|
3992
4003
|
display: grid;
|
|
@@ -4024,11 +4035,11 @@ var LANGUAGE_TO_CONTENT_TYPE = {
|
|
|
4024
4035
|
};
|
|
4025
4036
|
function RequestBody() {
|
|
4026
4037
|
const { request, dispatch } = useRequest();
|
|
4027
|
-
const [language, setLanguage] = (0,
|
|
4038
|
+
const [language, setLanguage] = (0, import_react36.useState)("json");
|
|
4028
4039
|
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
|
|
4029
4040
|
"div",
|
|
4030
4041
|
{
|
|
4031
|
-
css:
|
|
4042
|
+
css: import_react34.css`
|
|
4032
4043
|
background: var(--white);
|
|
4033
4044
|
`,
|
|
4034
4045
|
children: [
|
|
@@ -4036,7 +4047,7 @@ function RequestBody() {
|
|
|
4036
4047
|
RequestTypeContainer,
|
|
4037
4048
|
{
|
|
4038
4049
|
bgColor: "var(--gray-100)",
|
|
4039
|
-
css:
|
|
4050
|
+
css: import_react34.css`
|
|
4040
4051
|
padding: var(--spacing-sm) var(--spacing-base);
|
|
4041
4052
|
`,
|
|
4042
4053
|
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
@@ -4063,7 +4074,7 @@ function RequestBody() {
|
|
|
4063
4074
|
}
|
|
4064
4075
|
),
|
|
4065
4076
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
4066
|
-
|
|
4077
|
+
import_react35.default,
|
|
4067
4078
|
{
|
|
4068
4079
|
height: 200,
|
|
4069
4080
|
value: request.body,
|
|
@@ -4239,8 +4250,8 @@ function RequestParameters({ disableVariables }) {
|
|
|
4239
4250
|
}
|
|
4240
4251
|
|
|
4241
4252
|
// src/components/Request/RequestUrl.tsx
|
|
4242
|
-
var
|
|
4243
|
-
var
|
|
4253
|
+
var import_react37 = require("@emotion/react");
|
|
4254
|
+
var import_react38 = require("react");
|
|
4244
4255
|
|
|
4245
4256
|
// src/components/Request/urlEncodeRequestParameter.ts
|
|
4246
4257
|
function urlEncodeRequestUrl(url, varValues) {
|
|
@@ -4266,7 +4277,7 @@ function RequestUrl() {
|
|
|
4266
4277
|
var _a, _b;
|
|
4267
4278
|
const { variables } = useVariables();
|
|
4268
4279
|
const { request } = useRequest();
|
|
4269
|
-
const mergedParameters = (0,
|
|
4280
|
+
const mergedParameters = (0, import_react38.useMemo)(() => {
|
|
4270
4281
|
var _a2;
|
|
4271
4282
|
if (!((_a2 = request.baseRequest) == null ? void 0 : _a2.parameters)) {
|
|
4272
4283
|
return request.parameters;
|
|
@@ -4276,7 +4287,7 @@ function RequestUrl() {
|
|
|
4276
4287
|
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
|
|
4277
4288
|
"small",
|
|
4278
4289
|
{
|
|
4279
|
-
css:
|
|
4290
|
+
css: import_react37.css`
|
|
4280
4291
|
display: inline-block;
|
|
4281
4292
|
margin-bottom: var(--spacing-xs);
|
|
4282
4293
|
word-break: break-word;
|
|
@@ -4340,9 +4351,43 @@ function RequestUrlInput(props) {
|
|
|
4340
4351
|
);
|
|
4341
4352
|
}
|
|
4342
4353
|
|
|
4354
|
+
// src/components/Request/useRequestHeader.ts
|
|
4355
|
+
function useRequestHeader(headerName) {
|
|
4356
|
+
var _a, _b;
|
|
4357
|
+
const { request, dispatch } = useRequest();
|
|
4358
|
+
const headerIndex = request.headers.findIndex((f) => f.key === headerName);
|
|
4359
|
+
return {
|
|
4360
|
+
value: (_b = (_a = request.headers[headerIndex]) == null ? void 0 : _a.value) != null ? _b : "",
|
|
4361
|
+
update: (value) => {
|
|
4362
|
+
dispatch({
|
|
4363
|
+
type: "updateHeader",
|
|
4364
|
+
header: { key: headerName, value },
|
|
4365
|
+
index: headerIndex >= 0 ? headerIndex : void 0
|
|
4366
|
+
});
|
|
4367
|
+
}
|
|
4368
|
+
};
|
|
4369
|
+
}
|
|
4370
|
+
|
|
4371
|
+
// src/components/Request/useRequestParameter.ts
|
|
4372
|
+
function useRequestParameter(paramName) {
|
|
4373
|
+
var _a, _b;
|
|
4374
|
+
const { request, dispatch } = useRequest();
|
|
4375
|
+
const paramIndex = request.parameters.findIndex((f) => f.key === paramName);
|
|
4376
|
+
return {
|
|
4377
|
+
value: (_b = (_a = request.parameters[paramIndex]) == null ? void 0 : _a.value) != null ? _b : "",
|
|
4378
|
+
update: (value) => {
|
|
4379
|
+
dispatch({
|
|
4380
|
+
type: "updateParameter",
|
|
4381
|
+
parameter: { key: paramName, value },
|
|
4382
|
+
index: paramIndex >= 0 ? paramIndex : void 0
|
|
4383
|
+
});
|
|
4384
|
+
}
|
|
4385
|
+
};
|
|
4386
|
+
}
|
|
4387
|
+
|
|
4343
4388
|
// src/components/DataSourceEditor.tsx
|
|
4344
4389
|
var import_jsx_runtime41 = require("@emotion/react/jsx-runtime");
|
|
4345
|
-
function DataSourceEditor({ onChange, children }) {
|
|
4390
|
+
function DataSourceEditor({ onChange, children, editVariableComponent }) {
|
|
4346
4391
|
var _a;
|
|
4347
4392
|
const { value } = useMeshLocation("dataSource");
|
|
4348
4393
|
const currentRequestValue = convertDataSourceToRequestData(value);
|
|
@@ -4351,6 +4396,7 @@ function DataSourceEditor({ onChange, children }) {
|
|
|
4351
4396
|
{
|
|
4352
4397
|
value: (_a = value.variables) != null ? _a : {},
|
|
4353
4398
|
onChange: (newValue) => onChange((prev) => ({ newValue: { ...prev, variables: newValue } })),
|
|
4399
|
+
editVariableComponent,
|
|
4354
4400
|
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
4355
4401
|
RequestProvider,
|
|
4356
4402
|
{
|
|
@@ -4389,7 +4435,7 @@ function convertRequestDataToDataSource(dataSource, requestData) {
|
|
|
4389
4435
|
|
|
4390
4436
|
// src/components/DataTypeEditor.tsx
|
|
4391
4437
|
var import_jsx_runtime42 = require("@emotion/react/jsx-runtime");
|
|
4392
|
-
function DataTypeEditor({ onChange, children }) {
|
|
4438
|
+
function DataTypeEditor({ onChange, children, editVariableComponent }) {
|
|
4393
4439
|
var _a;
|
|
4394
4440
|
const {
|
|
4395
4441
|
value,
|
|
@@ -4401,6 +4447,7 @@ function DataTypeEditor({ onChange, children }) {
|
|
|
4401
4447
|
{
|
|
4402
4448
|
value: (_a = value.variables) != null ? _a : {},
|
|
4403
4449
|
onChange: (newValue) => onChange((prev) => ({ newValue: { ...prev, variables: newValue } })),
|
|
4450
|
+
editVariableComponent,
|
|
4404
4451
|
children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
4405
4452
|
RequestProvider,
|
|
4406
4453
|
{
|
|
@@ -4451,12 +4498,12 @@ var import_design_system20 = require("@uniformdev/design-system");
|
|
|
4451
4498
|
|
|
4452
4499
|
// src/hooks/useInitializeUniformMeshSdk.ts
|
|
4453
4500
|
var import_mesh_sdk = require("@uniformdev/mesh-sdk");
|
|
4454
|
-
var
|
|
4501
|
+
var import_react39 = require("react");
|
|
4455
4502
|
var useInitializeUniformMeshSdk = ({ autoResizingDisabled } = {}) => {
|
|
4456
|
-
const [error, setError] = (0,
|
|
4457
|
-
const [sdk, setSdk] = (0,
|
|
4458
|
-
const initializationInProgress = (0,
|
|
4459
|
-
(0,
|
|
4503
|
+
const [error, setError] = (0, import_react39.useState)();
|
|
4504
|
+
const [sdk, setSdk] = (0, import_react39.useState)();
|
|
4505
|
+
const initializationInProgress = (0, import_react39.useRef)(false);
|
|
4506
|
+
(0, import_react39.useEffect)(
|
|
4460
4507
|
() => {
|
|
4461
4508
|
if (typeof window === "undefined" || sdk) {
|
|
4462
4509
|
return;
|
|
@@ -4652,6 +4699,8 @@ __reExport(src_exports, require("@uniformdev/mesh-sdk"), module.exports);
|
|
|
4652
4699
|
useProductQueryContext,
|
|
4653
4700
|
useProductSearchContext,
|
|
4654
4701
|
useRequest,
|
|
4702
|
+
useRequestHeader,
|
|
4703
|
+
useRequestParameter,
|
|
4655
4704
|
useUniformMeshLocation,
|
|
4656
4705
|
useUniformMeshLocationContext,
|
|
4657
4706
|
useUniformMeshSdk,
|
package/dist/index.mjs
CHANGED
|
@@ -2688,8 +2688,11 @@ function DefaultDamItemRenderer({ item }) {
|
|
|
2688
2688
|
// src/components/DataResourceVariablesList.tsx
|
|
2689
2689
|
import { Callout as Callout3, Input as Input3 } from "@uniformdev/design-system";
|
|
2690
2690
|
|
|
2691
|
+
// src/hooks/useMeshLocation.ts
|
|
2692
|
+
import { useMemo as useMemo4, useRef as useRef7 } from "react";
|
|
2693
|
+
|
|
2691
2694
|
// src/components/UniformMeshLocationContext.tsx
|
|
2692
|
-
import { createContext as createContext2, useContext as useContext4,
|
|
2695
|
+
import { createContext as createContext2, useContext as useContext4, useMemo as useMemo3, useState as useState6 } from "react";
|
|
2693
2696
|
|
|
2694
2697
|
// src/components/UniformMeshSdkContext.tsx
|
|
2695
2698
|
import { Theme } from "@uniformdev/design-system";
|
|
@@ -2735,7 +2738,7 @@ var UniformMeshLocationContextProvider = ({
|
|
|
2735
2738
|
const valueChangeListener = (event) => {
|
|
2736
2739
|
setLocation((old) => ({ ...old, value: event.newValue }));
|
|
2737
2740
|
};
|
|
2738
|
-
|
|
2741
|
+
useMemo3(() => {
|
|
2739
2742
|
sdk.events.on("onValueChanged", valueChangeListener);
|
|
2740
2743
|
return () => {
|
|
2741
2744
|
sdk.events.off("onValueChanged", valueChangeListener);
|
|
@@ -2768,12 +2771,18 @@ function useMeshLocation(expectedLocation) {
|
|
|
2768
2771
|
if (effectiveExpected && location.type !== effectiveExpected) {
|
|
2769
2772
|
throw new Error(`Expected location type ${expectedLocation} but got ${location.type}`);
|
|
2770
2773
|
}
|
|
2774
|
+
const backdoorLocation = useRef7(location);
|
|
2775
|
+
backdoorLocation.current = location;
|
|
2776
|
+
const stabilizedSetValueProxy = useMemo4(
|
|
2777
|
+
() => (dispatch) => {
|
|
2778
|
+
const { newValue, options } = dispatch(backdoorLocation.current.value);
|
|
2779
|
+
backdoorLocation.current.setValue(newValue, options);
|
|
2780
|
+
},
|
|
2781
|
+
[]
|
|
2782
|
+
);
|
|
2771
2783
|
const proxyLocation = {
|
|
2772
2784
|
...location,
|
|
2773
|
-
setValue:
|
|
2774
|
-
const { newValue, options } = dispatch(location.value);
|
|
2775
|
-
location.setValue(newValue, options);
|
|
2776
|
-
}
|
|
2785
|
+
setValue: stabilizedSetValueProxy
|
|
2777
2786
|
};
|
|
2778
2787
|
return proxyLocation;
|
|
2779
2788
|
}
|
|
@@ -3345,8 +3354,8 @@ function VariableEditor({ variable, onSubmit, onCancel }) {
|
|
|
3345
3354
|
),
|
|
3346
3355
|
/* @__PURE__ */ jsx28(Input2, { ...getFieldProps("default"), label: "Default Value", autoComplete: "off" }),
|
|
3347
3356
|
/* @__PURE__ */ jsxs16("div", { css: variablesFormBtnGroup, children: [
|
|
3348
|
-
/* @__PURE__ */ jsx28(Button2, { type: "submit", children: "
|
|
3349
|
-
/* @__PURE__ */ jsx28(Button2, { type: "button", buttonType: "ghost", onClick: onCancel, children: "
|
|
3357
|
+
/* @__PURE__ */ jsx28(Button2, { type: "submit", children: "OK" }),
|
|
3358
|
+
/* @__PURE__ */ jsx28(Button2, { type: "button", buttonType: "ghost", onClick: onCancel, children: "Cancel" })
|
|
3350
3359
|
] })
|
|
3351
3360
|
] });
|
|
3352
3361
|
}
|
|
@@ -4121,7 +4130,7 @@ function RequestParameters({ disableVariables }) {
|
|
|
4121
4130
|
|
|
4122
4131
|
// src/components/Request/RequestUrl.tsx
|
|
4123
4132
|
import { css as css23 } from "@emotion/react";
|
|
4124
|
-
import { useMemo as
|
|
4133
|
+
import { useMemo as useMemo6 } from "react";
|
|
4125
4134
|
|
|
4126
4135
|
// src/components/Request/urlEncodeRequestParameter.ts
|
|
4127
4136
|
function urlEncodeRequestUrl(url, varValues) {
|
|
@@ -4147,7 +4156,7 @@ function RequestUrl() {
|
|
|
4147
4156
|
var _a, _b;
|
|
4148
4157
|
const { variables } = useVariables();
|
|
4149
4158
|
const { request } = useRequest();
|
|
4150
|
-
const mergedParameters =
|
|
4159
|
+
const mergedParameters = useMemo6(() => {
|
|
4151
4160
|
var _a2;
|
|
4152
4161
|
if (!((_a2 = request.baseRequest) == null ? void 0 : _a2.parameters)) {
|
|
4153
4162
|
return request.parameters;
|
|
@@ -4221,9 +4230,43 @@ function RequestUrlInput(props) {
|
|
|
4221
4230
|
);
|
|
4222
4231
|
}
|
|
4223
4232
|
|
|
4233
|
+
// src/components/Request/useRequestHeader.ts
|
|
4234
|
+
function useRequestHeader(headerName) {
|
|
4235
|
+
var _a, _b;
|
|
4236
|
+
const { request, dispatch } = useRequest();
|
|
4237
|
+
const headerIndex = request.headers.findIndex((f) => f.key === headerName);
|
|
4238
|
+
return {
|
|
4239
|
+
value: (_b = (_a = request.headers[headerIndex]) == null ? void 0 : _a.value) != null ? _b : "",
|
|
4240
|
+
update: (value) => {
|
|
4241
|
+
dispatch({
|
|
4242
|
+
type: "updateHeader",
|
|
4243
|
+
header: { key: headerName, value },
|
|
4244
|
+
index: headerIndex >= 0 ? headerIndex : void 0
|
|
4245
|
+
});
|
|
4246
|
+
}
|
|
4247
|
+
};
|
|
4248
|
+
}
|
|
4249
|
+
|
|
4250
|
+
// src/components/Request/useRequestParameter.ts
|
|
4251
|
+
function useRequestParameter(paramName) {
|
|
4252
|
+
var _a, _b;
|
|
4253
|
+
const { request, dispatch } = useRequest();
|
|
4254
|
+
const paramIndex = request.parameters.findIndex((f) => f.key === paramName);
|
|
4255
|
+
return {
|
|
4256
|
+
value: (_b = (_a = request.parameters[paramIndex]) == null ? void 0 : _a.value) != null ? _b : "",
|
|
4257
|
+
update: (value) => {
|
|
4258
|
+
dispatch({
|
|
4259
|
+
type: "updateParameter",
|
|
4260
|
+
parameter: { key: paramName, value },
|
|
4261
|
+
index: paramIndex >= 0 ? paramIndex : void 0
|
|
4262
|
+
});
|
|
4263
|
+
}
|
|
4264
|
+
};
|
|
4265
|
+
}
|
|
4266
|
+
|
|
4224
4267
|
// src/components/DataSourceEditor.tsx
|
|
4225
4268
|
import { jsx as jsx41 } from "@emotion/react/jsx-runtime";
|
|
4226
|
-
function DataSourceEditor({ onChange, children }) {
|
|
4269
|
+
function DataSourceEditor({ onChange, children, editVariableComponent }) {
|
|
4227
4270
|
var _a;
|
|
4228
4271
|
const { value } = useMeshLocation("dataSource");
|
|
4229
4272
|
const currentRequestValue = convertDataSourceToRequestData(value);
|
|
@@ -4232,6 +4275,7 @@ function DataSourceEditor({ onChange, children }) {
|
|
|
4232
4275
|
{
|
|
4233
4276
|
value: (_a = value.variables) != null ? _a : {},
|
|
4234
4277
|
onChange: (newValue) => onChange((prev) => ({ newValue: { ...prev, variables: newValue } })),
|
|
4278
|
+
editVariableComponent,
|
|
4235
4279
|
children: /* @__PURE__ */ jsx41(
|
|
4236
4280
|
RequestProvider,
|
|
4237
4281
|
{
|
|
@@ -4270,7 +4314,7 @@ function convertRequestDataToDataSource(dataSource, requestData) {
|
|
|
4270
4314
|
|
|
4271
4315
|
// src/components/DataTypeEditor.tsx
|
|
4272
4316
|
import { jsx as jsx42 } from "@emotion/react/jsx-runtime";
|
|
4273
|
-
function DataTypeEditor({ onChange, children }) {
|
|
4317
|
+
function DataTypeEditor({ onChange, children, editVariableComponent }) {
|
|
4274
4318
|
var _a;
|
|
4275
4319
|
const {
|
|
4276
4320
|
value,
|
|
@@ -4282,6 +4326,7 @@ function DataTypeEditor({ onChange, children }) {
|
|
|
4282
4326
|
{
|
|
4283
4327
|
value: (_a = value.variables) != null ? _a : {},
|
|
4284
4328
|
onChange: (newValue) => onChange((prev) => ({ newValue: { ...prev, variables: newValue } })),
|
|
4329
|
+
editVariableComponent,
|
|
4285
4330
|
children: /* @__PURE__ */ jsx42(
|
|
4286
4331
|
RequestProvider,
|
|
4287
4332
|
{
|
|
@@ -4332,12 +4377,12 @@ import { LoadingIndicator as LoadingIndicator2, Theme as Theme2 } from "@uniform
|
|
|
4332
4377
|
|
|
4333
4378
|
// src/hooks/useInitializeUniformMeshSdk.ts
|
|
4334
4379
|
import { initializeUniformMeshSDK } from "@uniformdev/mesh-sdk";
|
|
4335
|
-
import { useEffect as
|
|
4380
|
+
import { useEffect as useEffect7, useRef as useRef9, useState as useState9 } from "react";
|
|
4336
4381
|
var useInitializeUniformMeshSdk = ({ autoResizingDisabled } = {}) => {
|
|
4337
4382
|
const [error, setError] = useState9();
|
|
4338
4383
|
const [sdk, setSdk] = useState9();
|
|
4339
|
-
const initializationInProgress =
|
|
4340
|
-
|
|
4384
|
+
const initializationInProgress = useRef9(false);
|
|
4385
|
+
useEffect7(
|
|
4341
4386
|
() => {
|
|
4342
4387
|
if (typeof window === "undefined" || sdk) {
|
|
4343
4388
|
return;
|
|
@@ -4553,6 +4598,8 @@ export {
|
|
|
4553
4598
|
useProductQueryContext,
|
|
4554
4599
|
useProductSearchContext,
|
|
4555
4600
|
useRequest,
|
|
4601
|
+
useRequestHeader,
|
|
4602
|
+
useRequestParameter,
|
|
4556
4603
|
useUniformMeshLocation,
|
|
4557
4604
|
useUniformMeshLocationContext,
|
|
4558
4605
|
useUniformMeshSdk,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/mesh-sdk-react",
|
|
3
|
-
"version": "18.
|
|
3
|
+
"version": "18.3.1-alpha.22+61a3fbd5a",
|
|
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
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@monaco-editor/react": "4.4.6",
|
|
46
|
-
"@uniformdev/design-system": "18.
|
|
47
|
-
"@uniformdev/mesh-sdk": "18.
|
|
46
|
+
"@uniformdev/design-system": "18.3.1-alpha.22+61a3fbd5a",
|
|
47
|
+
"@uniformdev/mesh-sdk": "18.3.1-alpha.22+61a3fbd5a",
|
|
48
48
|
"@yaireo/tagify": "4.16.4",
|
|
49
49
|
"formik": "^2.2.9",
|
|
50
50
|
"monaco-editor": "0.34.1",
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
"publishConfig": {
|
|
77
77
|
"access": "public"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "61a3fbd5aadff46369076445db0ede53fc229d34"
|
|
80
80
|
}
|