@uniformdev/mesh-sdk-react 18.35.1-alpha.17 → 18.35.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 +24 -67
- package/dist/index.esm.js +257 -175
- package/dist/index.js +310 -236
- package/dist/index.mjs +257 -175
- package/package.json +10 -7
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;
|
|
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 :
|
|
909
|
+
alt: typeof product.title === "string" ? product.title : `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,
|
|
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
|
|
928
|
+
product.editLink ? /* @__PURE__ */ jsxs7(
|
|
929
929
|
"a",
|
|
930
930
|
{
|
|
931
931
|
css: productPreviewListLinkBtn,
|
|
932
|
-
href:
|
|
933
|
-
title: `Go to ${product.title
|
|
932
|
+
href: product.editLink,
|
|
933
|
+
title: `Go to ${product.title}`,
|
|
934
934
|
target: "_blank",
|
|
935
935
|
rel: "noopener noreferrer",
|
|
936
936
|
"data-test-id": "edit-product-button",
|
|
@@ -2642,7 +2642,7 @@ function DefaultDamItemRenderer({ item }) {
|
|
|
2642
2642
|
}
|
|
2643
2643
|
|
|
2644
2644
|
// src/components/DataResourceVariablesList.tsx
|
|
2645
|
-
import { Callout as
|
|
2645
|
+
import { Callout as Callout4, Input as Input4 } from "@uniformdev/design-system";
|
|
2646
2646
|
|
|
2647
2647
|
// src/hooks/useMeshLocation.ts
|
|
2648
2648
|
import { useMemo as useMemo4, useRef as useRef7 } from "react";
|
|
@@ -2655,18 +2655,6 @@ 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
|
-
};
|
|
2670
2658
|
var useUniformMeshSdkContext = () => {
|
|
2671
2659
|
const context = useContext3(UniformMeshSdkContext);
|
|
2672
2660
|
if (!context) {
|
|
@@ -2683,9 +2671,7 @@ function useUniformMeshSdk() {
|
|
|
2683
2671
|
|
|
2684
2672
|
// src/components/UniformMeshLocationContext.tsx
|
|
2685
2673
|
import { jsx as jsx27 } from "@emotion/react/jsx-runtime";
|
|
2686
|
-
var UniformMeshLocationContext = createContext2(
|
|
2687
|
-
void 0
|
|
2688
|
-
);
|
|
2674
|
+
var UniformMeshLocationContext = createContext2(void 0);
|
|
2689
2675
|
var UniformMeshLocationContextProvider = ({
|
|
2690
2676
|
children
|
|
2691
2677
|
}) => {
|
|
@@ -2716,20 +2702,9 @@ var useUniformMeshLocationContext = () => {
|
|
|
2716
2702
|
};
|
|
2717
2703
|
|
|
2718
2704
|
// src/hooks/useMeshLocation.ts
|
|
2719
|
-
var legacyWarned = false;
|
|
2720
2705
|
function useMeshLocation(expectedLocation) {
|
|
2721
2706
|
const { location } = useUniformMeshLocationContext();
|
|
2722
|
-
|
|
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) {
|
|
2707
|
+
if (expectedLocation && location.type !== expectedLocation) {
|
|
2733
2708
|
throw new Error(`Expected location type ${expectedLocation} but got ${location.type}`);
|
|
2734
2709
|
}
|
|
2735
2710
|
const backdoorLocation = useRef7(location);
|
|
@@ -2752,9 +2727,35 @@ function useMeshLocation(expectedLocation) {
|
|
|
2752
2727
|
import { Input as Input3 } from "@uniformdev/design-system";
|
|
2753
2728
|
import * as React11 from "react";
|
|
2754
2729
|
|
|
2730
|
+
// src/components/Variables/insertVariableIntoText.ts
|
|
2731
|
+
function insertVariableIntoText({
|
|
2732
|
+
variableName: variableName2,
|
|
2733
|
+
variablePrefix,
|
|
2734
|
+
variableSuffix = "",
|
|
2735
|
+
value,
|
|
2736
|
+
selectionStart = null,
|
|
2737
|
+
selectionEnd = null
|
|
2738
|
+
}) {
|
|
2739
|
+
const variableExpression = `${variablePrefix}${variableName2}${variableSuffix}`;
|
|
2740
|
+
if (selectionStart !== null && selectionEnd !== null && selectionStart !== selectionEnd) {
|
|
2741
|
+
return `${value.substring(0, selectionStart)}${variableExpression}${value.substring(selectionEnd)}`;
|
|
2742
|
+
}
|
|
2743
|
+
const hasCursorPosition = selectionStart !== null;
|
|
2744
|
+
let startOffset = 0;
|
|
2745
|
+
if (hasCursorPosition && value.substring(selectionStart - variablePrefix.length, selectionStart) === variablePrefix) {
|
|
2746
|
+
startOffset = variablePrefix.length;
|
|
2747
|
+
}
|
|
2748
|
+
if (hasCursorPosition) {
|
|
2749
|
+
return `${value.substring(0, selectionStart - startOffset)}${variableExpression}${value.substring(
|
|
2750
|
+
selectionStart
|
|
2751
|
+
)}`;
|
|
2752
|
+
}
|
|
2753
|
+
return `${value}${variableExpression}`;
|
|
2754
|
+
}
|
|
2755
|
+
|
|
2755
2756
|
// src/components/Variables/InsertVariableMenu.tsx
|
|
2756
2757
|
import { Icon as Icon5, Menu as Menu2, MenuItem as MenuItem2, MenuItemSeparator } from "@uniformdev/design-system";
|
|
2757
|
-
import { useEffect as
|
|
2758
|
+
import { useEffect as useEffect6, useRef as useRef8, useState as useState8 } from "react";
|
|
2758
2759
|
|
|
2759
2760
|
// src/components/Variables/styles/InsertVariableMenu.styles.ts
|
|
2760
2761
|
import { css as css18 } from "@emotion/react";
|
|
@@ -2784,12 +2785,18 @@ var variablesTipText = css18`
|
|
|
2784
2785
|
padding: 0 var(--spacing-sm);
|
|
2785
2786
|
`;
|
|
2786
2787
|
|
|
2788
|
+
// src/components/Variables/useOnVariableUpdated.ts
|
|
2789
|
+
import { useEffect as useEffect5 } from "react";
|
|
2790
|
+
|
|
2787
2791
|
// src/components/Variables/VariablesProvider.tsx
|
|
2792
|
+
import mitt from "mitt";
|
|
2788
2793
|
import * as React10 from "react";
|
|
2789
2794
|
|
|
2790
2795
|
// src/components/Variables/VariableEditor.tsx
|
|
2791
|
-
import {
|
|
2792
|
-
import {
|
|
2796
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
|
2797
|
+
import { Button as Button2, Callout as Callout3, Input as Input2, useShortcut } from "@uniformdev/design-system";
|
|
2798
|
+
import { useForm } from "react-hook-form";
|
|
2799
|
+
import { z } from "zod";
|
|
2793
2800
|
|
|
2794
2801
|
// src/components/Variables/InputVariables.styles.ts
|
|
2795
2802
|
import { css as css19 } from "@emotion/react";
|
|
@@ -2805,57 +2812,90 @@ var variablesFormBtnGroup = css19`
|
|
|
2805
2812
|
|
|
2806
2813
|
// src/components/Variables/VariableEditor.tsx
|
|
2807
2814
|
import { jsx as jsx28, jsxs as jsxs16 } from "@emotion/react/jsx-runtime";
|
|
2808
|
-
|
|
2809
|
-
|
|
2815
|
+
var schema = z.object({
|
|
2816
|
+
name: z.string().nonempty("Name can't be empty").regex(/^[^${}]+$/, "$, {, and } are reserved characters and cannot be used in a variable name"),
|
|
2817
|
+
default: z.string(),
|
|
2818
|
+
displayName: z.string().optional(),
|
|
2819
|
+
helpText: z.string().optional(),
|
|
2820
|
+
order: z.number().optional(),
|
|
2821
|
+
type: z.string().optional()
|
|
2822
|
+
});
|
|
2823
|
+
function VariableEditor({ variable, onSubmit, onCancel, disableMeshTip }) {
|
|
2824
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
2810
2825
|
const { variables } = useVariables();
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
{
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
),
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2826
|
+
const currentVariable = variables[variable];
|
|
2827
|
+
const { register, handleSubmit, formState } = useForm({
|
|
2828
|
+
defaultValues: {
|
|
2829
|
+
name: variable,
|
|
2830
|
+
default: (_a = currentVariable == null ? void 0 : currentVariable.default) != null ? _a : "",
|
|
2831
|
+
displayName: (_b = currentVariable == null ? void 0 : currentVariable.displayName) != null ? _b : "",
|
|
2832
|
+
helpText: (_c = currentVariable == null ? void 0 : currentVariable.helpText) != null ? _c : "",
|
|
2833
|
+
order: currentVariable == null ? void 0 : currentVariable.order,
|
|
2834
|
+
type: (_d = currentVariable == null ? void 0 : currentVariable.type) != null ? _d : ""
|
|
2835
|
+
},
|
|
2836
|
+
resolver: zodResolver(schema)
|
|
2837
|
+
});
|
|
2838
|
+
const submitHandler = handleSubmit((values) => {
|
|
2839
|
+
const finalValue = {
|
|
2840
|
+
...values,
|
|
2841
|
+
helpText: values.helpText || void 0,
|
|
2842
|
+
type: values.type || void 0,
|
|
2843
|
+
displayName: values.displayName || void 0
|
|
2844
|
+
};
|
|
2845
|
+
return onSubmit(finalValue);
|
|
2846
|
+
});
|
|
2847
|
+
useShortcut({
|
|
2848
|
+
shortcut: "enter",
|
|
2849
|
+
handler: () => {
|
|
2850
|
+
submitHandler();
|
|
2851
|
+
},
|
|
2852
|
+
activeWhenEditing: true
|
|
2853
|
+
});
|
|
2854
|
+
return (
|
|
2855
|
+
// NOTE: this is intentionally NOT a <form> because it's regularly used in a nested modal and that can make it bubble
|
|
2856
|
+
// up a submit to its 'parent form' which is not what we want.
|
|
2857
|
+
/* @__PURE__ */ jsxs16("div", { css: variablesFormContainer, children: [
|
|
2858
|
+
/* @__PURE__ */ jsx28(
|
|
2859
|
+
Input2,
|
|
2860
|
+
{
|
|
2861
|
+
...register("name"),
|
|
2862
|
+
label: "Name",
|
|
2863
|
+
disabled: variable !== "",
|
|
2864
|
+
caption: "This cannot change once created.",
|
|
2865
|
+
errorMessage: (_e = formState.errors.name) == null ? void 0 : _e.message,
|
|
2866
|
+
"data-af": "1"
|
|
2867
|
+
}
|
|
2868
|
+
),
|
|
2869
|
+
/* @__PURE__ */ jsx28(
|
|
2870
|
+
Input2,
|
|
2871
|
+
{
|
|
2872
|
+
...register("helpText"),
|
|
2873
|
+
label: "Help Text",
|
|
2874
|
+
caption: "Appears when entering a value for this variable.",
|
|
2875
|
+
autoComplete: "off",
|
|
2876
|
+
errorMessage: (_f = formState.errors.helpText) == null ? void 0 : _f.message
|
|
2877
|
+
}
|
|
2878
|
+
),
|
|
2879
|
+
/* @__PURE__ */ jsx28(
|
|
2880
|
+
Input2,
|
|
2881
|
+
{
|
|
2882
|
+
...register("default"),
|
|
2883
|
+
label: "Default Value",
|
|
2884
|
+
autoComplete: "off",
|
|
2885
|
+
errorMessage: (_g = formState.errors.default) == null ? void 0 : _g.message
|
|
2886
|
+
}
|
|
2887
|
+
),
|
|
2888
|
+
/* @__PURE__ */ jsxs16("div", { css: variablesFormBtnGroup, children: [
|
|
2889
|
+
/* @__PURE__ */ jsx28(Button2, { type: "button", onClick: submitHandler, children: "OK" }),
|
|
2890
|
+
/* @__PURE__ */ jsx28(Button2, { type: "button", buttonType: "ghost", onClick: onCancel, children: "Cancel" })
|
|
2891
|
+
] }),
|
|
2892
|
+
disableMeshTip ? null : /* @__PURE__ */ jsxs16(Callout3, { type: "tip", title: "Customized User Interfaces", children: [
|
|
2893
|
+
"Developers can create customized user interfaces for variable editing by building a Uniform mesh integration. Get started quickly with our",
|
|
2894
|
+
" ",
|
|
2895
|
+
/* @__PURE__ */ jsx28("a", { href: "https://docs.uniform.app", target: "_blank", rel: "noopener noreferrer", children: "Mesh SDK" }),
|
|
2896
|
+
"."
|
|
2897
|
+
] })
|
|
2898
|
+
] })
|
|
2859
2899
|
);
|
|
2860
2900
|
}
|
|
2861
2901
|
|
|
@@ -2869,6 +2909,7 @@ function VariablesProvider({
|
|
|
2869
2909
|
children
|
|
2870
2910
|
}) {
|
|
2871
2911
|
const [editing, setEditing] = React10.useState();
|
|
2912
|
+
const events = React10.useMemo(() => mitt(), []);
|
|
2872
2913
|
const Editor = editVariableComponent != null ? editVariableComponent : VariableEditor;
|
|
2873
2914
|
const contextValue = {
|
|
2874
2915
|
dispatch: (event) => {
|
|
@@ -2890,7 +2931,9 @@ function VariablesProvider({
|
|
|
2890
2931
|
throw new Error(`Unknown event ${JSON.stringify(event)}`);
|
|
2891
2932
|
}
|
|
2892
2933
|
},
|
|
2893
|
-
variables: value
|
|
2934
|
+
variables: value,
|
|
2935
|
+
isEditing: typeof editing !== "undefined",
|
|
2936
|
+
events
|
|
2894
2937
|
};
|
|
2895
2938
|
return /* @__PURE__ */ jsxs17(VariablesContext.Provider, { value: contextValue, children: [
|
|
2896
2939
|
children,
|
|
@@ -2901,6 +2944,7 @@ function VariablesProvider({
|
|
|
2901
2944
|
setEditing(void 0);
|
|
2902
2945
|
const { name, ...varValue } = val;
|
|
2903
2946
|
onChange({ ...value, [name]: varValue });
|
|
2947
|
+
events.emit("update", name);
|
|
2904
2948
|
},
|
|
2905
2949
|
onCancel: () => setEditing(void 0),
|
|
2906
2950
|
variable: editing
|
|
@@ -2916,51 +2960,106 @@ function useVariables() {
|
|
|
2916
2960
|
return context;
|
|
2917
2961
|
}
|
|
2918
2962
|
|
|
2963
|
+
// src/components/Variables/useOnVariableUpdated.ts
|
|
2964
|
+
function useOnVariableUpdated(fn, disabled) {
|
|
2965
|
+
const { variables, events } = useVariables();
|
|
2966
|
+
useEffect5(() => {
|
|
2967
|
+
if (disabled) {
|
|
2968
|
+
return;
|
|
2969
|
+
}
|
|
2970
|
+
events.on("update", fn);
|
|
2971
|
+
return () => events.off("update", fn);
|
|
2972
|
+
}, [disabled, events, fn, variables]);
|
|
2973
|
+
}
|
|
2974
|
+
|
|
2975
|
+
// src/components/Variables/variablesToList.ts
|
|
2976
|
+
function variablesToList(variables) {
|
|
2977
|
+
return Object.entries(variables || {}).sort(([aKey, a], [bKey, b]) => {
|
|
2978
|
+
var _a, _b;
|
|
2979
|
+
if (a.order && b.order) {
|
|
2980
|
+
return a.order - b.order;
|
|
2981
|
+
} else if (a.order) {
|
|
2982
|
+
return 1;
|
|
2983
|
+
} else if (b.order) {
|
|
2984
|
+
return -1;
|
|
2985
|
+
}
|
|
2986
|
+
return ((_a = a.displayName) != null ? _a : aKey).localeCompare((_b = b.displayName) != null ? _b : bKey);
|
|
2987
|
+
}).map(([name, definition]) => ({
|
|
2988
|
+
name,
|
|
2989
|
+
...definition
|
|
2990
|
+
}));
|
|
2991
|
+
}
|
|
2992
|
+
|
|
2919
2993
|
// src/components/Variables/InsertVariableMenu.tsx
|
|
2920
2994
|
import { Fragment as Fragment4, jsx as jsx30, jsxs as jsxs18 } from "@emotion/react/jsx-runtime";
|
|
2921
2995
|
var InsertVariableMenu = ({
|
|
2922
|
-
|
|
2996
|
+
onSelectVariable,
|
|
2923
2997
|
children,
|
|
2924
2998
|
textValue,
|
|
2925
2999
|
trigger = "${",
|
|
2926
|
-
showAddVariableMenuOption = false
|
|
3000
|
+
showAddVariableMenuOption = false,
|
|
3001
|
+
disabled = false,
|
|
3002
|
+
forceVisible
|
|
2927
3003
|
}) => {
|
|
2928
|
-
const { variables, dispatch } = useVariables();
|
|
3004
|
+
const { variables, dispatch, isEditing } = useVariables();
|
|
2929
3005
|
const btnRef = useRef8(null);
|
|
2930
|
-
const tip =
|
|
2931
|
-
|
|
3006
|
+
const tip = `Tip: access this list by typing ${trigger}`;
|
|
3007
|
+
useEffect6(() => {
|
|
2932
3008
|
if (textValue === trigger && btnRef.current && btnRef.current.getAttribute("aria-expanded") === "false") {
|
|
2933
3009
|
btnRef.current.click();
|
|
2934
3010
|
}
|
|
2935
3011
|
}, [textValue, btnRef, trigger]);
|
|
3012
|
+
const [openedAdd, setOpenedAdd] = useState8(false);
|
|
3013
|
+
useOnVariableUpdated((varName) => {
|
|
3014
|
+
onSelectVariable == null ? void 0 : onSelectVariable({ name: varName, default: "" });
|
|
3015
|
+
}, !openedAdd);
|
|
3016
|
+
useEffect6(() => {
|
|
3017
|
+
if (openedAdd && !isEditing) {
|
|
3018
|
+
setOpenedAdd(false);
|
|
3019
|
+
}
|
|
3020
|
+
}, [isEditing, openedAdd]);
|
|
3021
|
+
if (disabled) {
|
|
3022
|
+
return /* @__PURE__ */ jsx30(Fragment4, { children });
|
|
3023
|
+
}
|
|
3024
|
+
const variablesList = variablesToList(variables);
|
|
2936
3025
|
return /* @__PURE__ */ jsxs18("div", { css: menuContainer, children: [
|
|
2937
3026
|
children,
|
|
2938
3027
|
/* @__PURE__ */ jsxs18(
|
|
2939
3028
|
Menu2,
|
|
2940
3029
|
{
|
|
2941
3030
|
placement: "bottom-start",
|
|
3031
|
+
forceVisible,
|
|
2942
3032
|
menuTrigger: /* @__PURE__ */ jsx30("button", { ref: btnRef, css: menuBtn, type: "button", title: "Insert variable", children: /* @__PURE__ */ jsx30(Icon5, { icon: "usb-c", iconColor: "currentColor" }) }),
|
|
2943
3033
|
menuLabel: "Insert variable",
|
|
2944
3034
|
children: [
|
|
2945
|
-
|
|
2946
|
-
const { helpText } =
|
|
3035
|
+
variablesList.map((variable) => {
|
|
3036
|
+
const { name, helpText } = variable;
|
|
2947
3037
|
return /* @__PURE__ */ jsxs18(
|
|
2948
3038
|
MenuItem2,
|
|
2949
3039
|
{
|
|
2950
|
-
id:
|
|
3040
|
+
id: name,
|
|
2951
3041
|
css: menuItemTextGroup,
|
|
2952
|
-
onClick: () =>
|
|
3042
|
+
onClick: () => onSelectVariable == null ? void 0 : onSelectVariable(variable),
|
|
2953
3043
|
children: [
|
|
2954
|
-
/* @__PURE__ */ jsx30("span", { children:
|
|
3044
|
+
/* @__PURE__ */ jsx30("span", { children: name }),
|
|
2955
3045
|
helpText ? /* @__PURE__ */ jsx30("small", { css: smallText, children: helpText }) : null
|
|
2956
3046
|
]
|
|
2957
3047
|
},
|
|
2958
|
-
|
|
3048
|
+
name
|
|
2959
3049
|
);
|
|
2960
3050
|
}),
|
|
2961
3051
|
showAddVariableMenuOption ? /* @__PURE__ */ jsxs18(Fragment4, { children: [
|
|
2962
|
-
/* @__PURE__ */ jsx30(MenuItemSeparator, {}),
|
|
2963
|
-
/* @__PURE__ */ jsx30(
|
|
3052
|
+
variablesList.length ? /* @__PURE__ */ jsx30(MenuItemSeparator, {}) : null,
|
|
3053
|
+
/* @__PURE__ */ jsx30(
|
|
3054
|
+
MenuItem2,
|
|
3055
|
+
{
|
|
3056
|
+
onClick: () => {
|
|
3057
|
+
setOpenedAdd(true);
|
|
3058
|
+
dispatch({ type: "edit", variable: "" });
|
|
3059
|
+
},
|
|
3060
|
+
children: "Add Variable"
|
|
3061
|
+
}
|
|
3062
|
+
)
|
|
2964
3063
|
] }) : null,
|
|
2965
3064
|
Object.entries(variables).length || showAddVariableMenuOption ? /* @__PURE__ */ jsx30(MenuItemSeparator, {}) : null,
|
|
2966
3065
|
/* @__PURE__ */ jsx30("i", { css: variablesTipText, children: tip })
|
|
@@ -2975,13 +3074,15 @@ import { jsx as jsx31 } from "@emotion/react/jsx-runtime";
|
|
|
2975
3074
|
function InputVariables({
|
|
2976
3075
|
"aria-label": ariaLabel,
|
|
2977
3076
|
value,
|
|
2978
|
-
|
|
3077
|
+
disableVariables,
|
|
2979
3078
|
onChange,
|
|
2980
3079
|
onPaste,
|
|
2981
|
-
onVariableClick,
|
|
2982
3080
|
showAddVariableMenuOption,
|
|
3081
|
+
variablePrefix = "${",
|
|
3082
|
+
variableSuffix = "}",
|
|
2983
3083
|
...inputProps
|
|
2984
3084
|
}) {
|
|
3085
|
+
var _a, _b;
|
|
2985
3086
|
const { variables, dispatch } = useVariables();
|
|
2986
3087
|
const currentVariables = React11.useRef(variables);
|
|
2987
3088
|
const currentDispatch = React11.useRef(dispatch);
|
|
@@ -2996,21 +3097,40 @@ function InputVariables({
|
|
|
2996
3097
|
React11.useEffect(() => {
|
|
2997
3098
|
currentSetValue.current = onChange;
|
|
2998
3099
|
}, [onChange]);
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3100
|
+
const onPasteHandler = () => {
|
|
3101
|
+
setTimeout(() => {
|
|
3102
|
+
if (!inputRef.current) {
|
|
3103
|
+
return;
|
|
3104
|
+
}
|
|
3105
|
+
onPaste == null ? void 0 : onPaste(inputRef.current.value);
|
|
3106
|
+
});
|
|
3107
|
+
};
|
|
3108
|
+
const handleInsertVariable = (variable) => {
|
|
3109
|
+
var _a2, _b2;
|
|
3110
|
+
handleSetValue(
|
|
3111
|
+
insertVariableIntoText({
|
|
3112
|
+
variableName: variable.name,
|
|
3113
|
+
value,
|
|
3114
|
+
variablePrefix,
|
|
3115
|
+
variableSuffix,
|
|
3116
|
+
selectionEnd: (_a2 = inputRef.current) == null ? void 0 : _a2.selectionEnd,
|
|
3117
|
+
selectionStart: (_b2 = inputRef.current) == null ? void 0 : _b2.selectionStart
|
|
3118
|
+
})
|
|
3119
|
+
);
|
|
3120
|
+
};
|
|
3005
3121
|
const handleSetValue = (rawValue) => {
|
|
3006
3122
|
currentSetValue.current(rawValue);
|
|
3007
3123
|
};
|
|
3124
|
+
const currentCursor = (_b = (_a = inputRef.current) == null ? void 0 : _a.selectionStart) != null ? _b : value.length;
|
|
3125
|
+
const forceMenu = value.substring(currentCursor - 2, currentCursor) === "${";
|
|
3008
3126
|
return /* @__PURE__ */ jsx31(
|
|
3009
3127
|
InsertVariableMenu,
|
|
3010
3128
|
{
|
|
3011
3129
|
showAddVariableMenuOption,
|
|
3012
3130
|
textValue: value,
|
|
3013
|
-
|
|
3131
|
+
onSelectVariable: handleInsertVariable,
|
|
3132
|
+
disabled: disableVariables,
|
|
3133
|
+
forceVisible: forceMenu || void 0,
|
|
3014
3134
|
children: /* @__PURE__ */ jsx31(
|
|
3015
3135
|
Input3,
|
|
3016
3136
|
{
|
|
@@ -3019,6 +3139,7 @@ function InputVariables({
|
|
|
3019
3139
|
showLabel: false,
|
|
3020
3140
|
value,
|
|
3021
3141
|
onChange: (e) => handleSetValue(e.currentTarget.value),
|
|
3142
|
+
onPaste: onPasteHandler,
|
|
3022
3143
|
...inputProps
|
|
3023
3144
|
}
|
|
3024
3145
|
)
|
|
@@ -3087,24 +3208,6 @@ var variableValue = css20`
|
|
|
3087
3208
|
max-width: 20ch;
|
|
3088
3209
|
`;
|
|
3089
3210
|
|
|
3090
|
-
// src/components/Variables/variablesToList.ts
|
|
3091
|
-
function variablesToList(variables) {
|
|
3092
|
-
return Object.entries(variables || {}).sort(([aKey, a], [bKey, b]) => {
|
|
3093
|
-
var _a, _b;
|
|
3094
|
-
if (a.order && b.order) {
|
|
3095
|
-
return a.order - b.order;
|
|
3096
|
-
} else if (a.order) {
|
|
3097
|
-
return 1;
|
|
3098
|
-
} else if (b.order) {
|
|
3099
|
-
return -1;
|
|
3100
|
-
}
|
|
3101
|
-
return ((_a = a.displayName) != null ? _a : aKey).localeCompare((_b = b.displayName) != null ? _b : bKey);
|
|
3102
|
-
}).map(([name, definition]) => ({
|
|
3103
|
-
name,
|
|
3104
|
-
...definition
|
|
3105
|
-
}));
|
|
3106
|
-
}
|
|
3107
|
-
|
|
3108
3211
|
// src/components/Variables/VariablesList.tsx
|
|
3109
3212
|
import { Fragment as Fragment5, jsx as jsx32, jsxs as jsxs19 } from "@emotion/react/jsx-runtime";
|
|
3110
3213
|
function VariablesList() {
|
|
@@ -3216,13 +3319,13 @@ function DataResourceVariablesList({
|
|
|
3216
3319
|
const {
|
|
3217
3320
|
value,
|
|
3218
3321
|
metadata: { dataType }
|
|
3219
|
-
} = useMeshLocation("
|
|
3322
|
+
} = useMeshLocation("dataResource");
|
|
3220
3323
|
const variableDefinitions = variablesToList(dataType.variables);
|
|
3221
3324
|
if (variableDefinitions.length === 0) {
|
|
3222
3325
|
if (NoVariablesComponent) {
|
|
3223
3326
|
return /* @__PURE__ */ jsx33(NoVariablesComponent, {});
|
|
3224
3327
|
}
|
|
3225
|
-
return /* @__PURE__ */ jsx33(
|
|
3328
|
+
return /* @__PURE__ */ jsx33(Callout4, { type: "note", children: "No settings are required." });
|
|
3226
3329
|
}
|
|
3227
3330
|
return /* @__PURE__ */ jsx33("div", { children: variableDefinitions.map((variableDefinition) => {
|
|
3228
3331
|
var _a, _b, _c;
|
|
@@ -3271,7 +3374,7 @@ function TextVariableRenderer({ definition, value, setValue }) {
|
|
|
3271
3374
|
// src/components/Request/RequestBody.tsx
|
|
3272
3375
|
import { css as css23 } from "@emotion/react";
|
|
3273
3376
|
import { InputSelect as InputSelect4, JsonEditor } from "@uniformdev/design-system";
|
|
3274
|
-
import { useState as
|
|
3377
|
+
import { useState as useState9 } from "react";
|
|
3275
3378
|
|
|
3276
3379
|
// src/components/Request/RequestProvider.tsx
|
|
3277
3380
|
import * as React12 from "react";
|
|
@@ -3397,7 +3500,7 @@ var LANGUAGE_TO_CONTENT_TYPE = {
|
|
|
3397
3500
|
};
|
|
3398
3501
|
function RequestBody() {
|
|
3399
3502
|
const { request, dispatch } = useRequest();
|
|
3400
|
-
const [language, setLanguage] =
|
|
3503
|
+
const [language, setLanguage] = useState9("json");
|
|
3401
3504
|
return /* @__PURE__ */ jsxs21(
|
|
3402
3505
|
"div",
|
|
3403
3506
|
{
|
|
@@ -3525,7 +3628,8 @@ function RequestHeaders({ disableVariables }) {
|
|
|
3525
3628
|
{
|
|
3526
3629
|
value: header.value,
|
|
3527
3630
|
onChange: (value) => handleUpdateParamFromMenu({ key: header.key, value, index }),
|
|
3528
|
-
|
|
3631
|
+
disableVariables,
|
|
3632
|
+
showAddVariableMenuOption: true,
|
|
3529
3633
|
"data-test-id": "header-value"
|
|
3530
3634
|
}
|
|
3531
3635
|
) : null })
|
|
@@ -3633,12 +3737,9 @@ function RequestParameters({ disableVariables }) {
|
|
|
3633
3737
|
value: selectedVariable,
|
|
3634
3738
|
index
|
|
3635
3739
|
}),
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
index
|
|
3640
|
-
}),
|
|
3641
|
-
"data-test-id": "parameter-value"
|
|
3740
|
+
disableVariables,
|
|
3741
|
+
"data-test-id": "parameter-value",
|
|
3742
|
+
showAddVariableMenuOption: true
|
|
3642
3743
|
}
|
|
3643
3744
|
) : null })
|
|
3644
3745
|
] }, index);
|
|
@@ -3649,7 +3750,7 @@ function RequestParameters({ disableVariables }) {
|
|
|
3649
3750
|
|
|
3650
3751
|
// src/components/Request/RequestUrl.tsx
|
|
3651
3752
|
import { css as css24 } from "@emotion/react";
|
|
3652
|
-
import { useMemo as
|
|
3753
|
+
import { useMemo as useMemo7 } from "react";
|
|
3653
3754
|
|
|
3654
3755
|
// src/components/Request/urlEncodeRequestParameter.ts
|
|
3655
3756
|
function urlEncodeRequestUrl(url, varValues) {
|
|
@@ -3675,7 +3776,7 @@ function RequestUrl() {
|
|
|
3675
3776
|
var _a, _b;
|
|
3676
3777
|
const { variables } = useVariables();
|
|
3677
3778
|
const { request } = useRequest();
|
|
3678
|
-
const mergedParameters =
|
|
3779
|
+
const mergedParameters = useMemo7(() => {
|
|
3679
3780
|
var _a2;
|
|
3680
3781
|
if (!((_a2 = request.baseRequest) == null ? void 0 : _a2.parameters)) {
|
|
3681
3782
|
return request.parameters;
|
|
@@ -3745,9 +3846,6 @@ function RequestUrlInput(props) {
|
|
|
3745
3846
|
onChange: (value) => {
|
|
3746
3847
|
dispatch({ type: "setRelativeUrl", relativeUrl: value });
|
|
3747
3848
|
},
|
|
3748
|
-
onVariableClick: (selectedValue) => {
|
|
3749
|
-
dispatch({ type: "setRelativeUrl", relativeUrl: request.relativeUrl.concat(selectedValue) });
|
|
3750
|
-
},
|
|
3751
3849
|
showAddVariableMenuOption: true
|
|
3752
3850
|
}
|
|
3753
3851
|
);
|
|
@@ -3900,12 +3998,12 @@ import { LoadingIndicator as LoadingIndicator2, Theme as Theme2 } from "@uniform
|
|
|
3900
3998
|
|
|
3901
3999
|
// src/hooks/useInitializeUniformMeshSdk.ts
|
|
3902
4000
|
import { initializeUniformMeshSDK } from "@uniformdev/mesh-sdk";
|
|
3903
|
-
import { useEffect as
|
|
4001
|
+
import { useEffect as useEffect8, useRef as useRef10, useState as useState10 } from "react";
|
|
3904
4002
|
var useInitializeUniformMeshSdk = ({ autoResizingDisabled } = {}) => {
|
|
3905
|
-
const [error, setError] =
|
|
3906
|
-
const [sdk, setSdk] =
|
|
4003
|
+
const [error, setError] = useState10();
|
|
4004
|
+
const [sdk, setSdk] = useState10();
|
|
3907
4005
|
const initializationInProgress = useRef10(false);
|
|
3908
|
-
|
|
4006
|
+
useEffect8(
|
|
3909
4007
|
() => {
|
|
3910
4008
|
if (typeof window === "undefined" || sdk) {
|
|
3911
4009
|
return;
|
|
@@ -4004,10 +4102,10 @@ var ObjectSearchContainer = ({
|
|
|
4004
4102
|
|
|
4005
4103
|
// src/components/ObjectSearch/ObjectSearchFilter.tsx
|
|
4006
4104
|
import { InputKeywordSearch as InputKeywordSearch2, InputSelect as InputSelect6 } from "@uniformdev/design-system";
|
|
4007
|
-
import { useState as
|
|
4105
|
+
import { useState as useState12 } from "react";
|
|
4008
4106
|
|
|
4009
4107
|
// src/components/ObjectSearch/hooks/ObjectSearchContext.tsx
|
|
4010
|
-
import { createContext as createContext5, useCallback, useContext as useContext7, useDeferredValue, useState as
|
|
4108
|
+
import { createContext as createContext5, useCallback, useContext as useContext7, useDeferredValue, useState as useState11 } from "react";
|
|
4011
4109
|
import { jsx as jsx47 } from "@emotion/react/jsx-runtime";
|
|
4012
4110
|
var ObjectSearchContext = createContext5({
|
|
4013
4111
|
onSetQuery: () => {
|
|
@@ -4026,13 +4124,13 @@ var ObjectSearchContext = createContext5({
|
|
|
4026
4124
|
}
|
|
4027
4125
|
});
|
|
4028
4126
|
var ObjectSearchProvider = ({ currentlySelectedItems, children }) => {
|
|
4029
|
-
const [query, setQuery] =
|
|
4127
|
+
const [query, setQuery] = useState11({
|
|
4030
4128
|
contentType: "",
|
|
4031
4129
|
keyword: ""
|
|
4032
4130
|
});
|
|
4033
4131
|
const querySearchDeferred = useDeferredValue(query);
|
|
4034
|
-
const [selectedItems, setSelectedItems] =
|
|
4035
|
-
const [list, setList] =
|
|
4132
|
+
const [selectedItems, setSelectedItems] = useState11(currentlySelectedItems != null ? currentlySelectedItems : []);
|
|
4133
|
+
const [list, setList] = useState11({});
|
|
4036
4134
|
const onSetQuery = useCallback(
|
|
4037
4135
|
(value) => {
|
|
4038
4136
|
if (Array.isArray(value.contentType) && value.contentType.length > 0) {
|
|
@@ -4123,7 +4221,7 @@ var ObjectSearchFilter = ({
|
|
|
4123
4221
|
selectOptions
|
|
4124
4222
|
}) => {
|
|
4125
4223
|
const { query, onSetQuery } = useObjectSearchContext();
|
|
4126
|
-
const [searchState, setSearchState] =
|
|
4224
|
+
const [searchState, setSearchState] = useState12({
|
|
4127
4225
|
contentType: "",
|
|
4128
4226
|
keyword: ""
|
|
4129
4227
|
});
|
|
@@ -4561,7 +4659,7 @@ var ObjectSearchResultList = ({
|
|
|
4561
4659
|
|
|
4562
4660
|
// src/components/ObjectSearch/QueryFilter.tsx
|
|
4563
4661
|
import { Input as Input7, InputKeywordSearch as InputKeywordSearch3, InputSelect as InputSelect7 } from "@uniformdev/design-system";
|
|
4564
|
-
import { useEffect as
|
|
4662
|
+
import { useEffect as useEffect9, useState as useState13 } from "react";
|
|
4565
4663
|
import { jsx as jsx54, jsxs as jsxs34 } from "@emotion/react/jsx-runtime";
|
|
4566
4664
|
var QueryFilter = ({
|
|
4567
4665
|
requireContentType,
|
|
@@ -4592,7 +4690,7 @@ var QueryFilter = ({
|
|
|
4592
4690
|
}) => {
|
|
4593
4691
|
var _a, _b;
|
|
4594
4692
|
const { query, onSetQuery } = useObjectSearchContext();
|
|
4595
|
-
const [queryState, setQueryState] =
|
|
4693
|
+
const [queryState, setQueryState] = useState13({
|
|
4596
4694
|
contentType: "",
|
|
4597
4695
|
keyword: "",
|
|
4598
4696
|
count: countValue != null ? countValue : 5,
|
|
@@ -4603,7 +4701,7 @@ var QueryFilter = ({
|
|
|
4603
4701
|
setQueryState((prev) => ({ ...prev, ...value }));
|
|
4604
4702
|
onSetQuery({ ...query, ...value });
|
|
4605
4703
|
};
|
|
4606
|
-
|
|
4704
|
+
useEffect9(() => {
|
|
4607
4705
|
onSetQuery(queryState);
|
|
4608
4706
|
}, [onSetQuery, queryState]);
|
|
4609
4707
|
return /* @__PURE__ */ jsxs34("fieldset", { children: [
|
|
@@ -4687,12 +4785,6 @@ var QueryFilter = ({
|
|
|
4687
4785
|
] });
|
|
4688
4786
|
};
|
|
4689
4787
|
|
|
4690
|
-
// src/hooks/useUniformMeshLocation.ts
|
|
4691
|
-
function useUniformMeshLocation() {
|
|
4692
|
-
const { location } = useUniformMeshLocationContext();
|
|
4693
|
-
return location;
|
|
4694
|
-
}
|
|
4695
|
-
|
|
4696
4788
|
// src/hooks/index.ts
|
|
4697
4789
|
import { ParameterShellContext, useParameterShell } from "@uniformdev/design-system";
|
|
4698
4790
|
|
|
@@ -4708,14 +4800,13 @@ function createLocationValidator(setValue, validate) {
|
|
|
4708
4800
|
import {
|
|
4709
4801
|
AddListButton as AddListButton2,
|
|
4710
4802
|
Button as Button6,
|
|
4711
|
-
Callout as
|
|
4803
|
+
Callout as Callout5,
|
|
4712
4804
|
Heading,
|
|
4713
4805
|
Input as Input8,
|
|
4714
4806
|
InputComboBox,
|
|
4715
4807
|
InputKeywordSearch as InputKeywordSearch4,
|
|
4716
4808
|
InputSelect as InputSelect8,
|
|
4717
4809
|
InputToggle,
|
|
4718
|
-
InputKeywordSearch as InputKeywordSearch5,
|
|
4719
4810
|
Label,
|
|
4720
4811
|
LoadingIndicator as LoadingIndicator4,
|
|
4721
4812
|
LoadingOverlay as LoadingOverlay2,
|
|
@@ -4745,7 +4836,7 @@ export * from "@uniformdev/mesh-sdk";
|
|
|
4745
4836
|
export {
|
|
4746
4837
|
AddListButton2 as AddListButton,
|
|
4747
4838
|
Button6 as Button,
|
|
4748
|
-
|
|
4839
|
+
Callout5 as Callout,
|
|
4749
4840
|
DamSelectedItem,
|
|
4750
4841
|
DataRefreshButton,
|
|
4751
4842
|
DataResourceVariablesList,
|
|
@@ -4762,7 +4853,6 @@ export {
|
|
|
4762
4853
|
InputSelect8 as InputSelect,
|
|
4763
4854
|
InputToggle,
|
|
4764
4855
|
InputVariables,
|
|
4765
|
-
InputKeywordSearch5 as KeywordSearchInput,
|
|
4766
4856
|
Label,
|
|
4767
4857
|
LinkButton,
|
|
4768
4858
|
LoadingIndicator4 as LoadingIndicator,
|
|
@@ -4818,10 +4908,6 @@ export {
|
|
|
4818
4908
|
TextVariableRenderer,
|
|
4819
4909
|
Textarea,
|
|
4820
4910
|
Theme3 as Theme,
|
|
4821
|
-
UniformMeshLocationContext,
|
|
4822
|
-
UniformMeshLocationContextProvider,
|
|
4823
|
-
UniformMeshSdkContext,
|
|
4824
|
-
UniformMeshSdkContextProvider,
|
|
4825
4911
|
VariableEditor,
|
|
4826
4912
|
VariablesList,
|
|
4827
4913
|
VariablesProvider,
|
|
@@ -4890,7 +4976,6 @@ export {
|
|
|
4890
4976
|
selectedItemTitle,
|
|
4891
4977
|
urlEncodeRequestParameter,
|
|
4892
4978
|
urlEncodeRequestUrl,
|
|
4893
|
-
useInitializeUniformMeshSdk,
|
|
4894
4979
|
useMeshLocation,
|
|
4895
4980
|
useObjectSearchContext,
|
|
4896
4981
|
useParameterShell,
|
|
@@ -4899,10 +4984,7 @@ export {
|
|
|
4899
4984
|
useRequest,
|
|
4900
4985
|
useRequestHeader,
|
|
4901
4986
|
useRequestParameter,
|
|
4902
|
-
useUniformMeshLocation,
|
|
4903
|
-
useUniformMeshLocationContext,
|
|
4904
4987
|
useUniformMeshSdk,
|
|
4905
|
-
useUniformMeshSdkContext,
|
|
4906
4988
|
useVariables,
|
|
4907
4989
|
variablesToList
|
|
4908
4990
|
};
|