@uniformdev/mesh-sdk-react 19.23.0 → 19.23.1-alpha.13
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 +43 -15
- package/dist/index.esm.js +1145 -509
- package/dist/index.js +1206 -577
- package/dist/index.mjs +1145 -509
- package/package.json +8 -5
package/dist/index.esm.js
CHANGED
|
@@ -2921,34 +2921,224 @@ function useMeshLocation(expectedLocation) {
|
|
|
2921
2921
|
|
|
2922
2922
|
// src/components/Variables/InputVariables.tsx
|
|
2923
2923
|
init_emotion_jsx_shim();
|
|
2924
|
-
import { Caption, ErrorMessage, InfoMessage,
|
|
2924
|
+
import { Caption, ErrorMessage, InfoMessage, WarningMessage } from "@uniformdev/design-system";
|
|
2925
2925
|
import * as React11 from "react";
|
|
2926
|
-
import {
|
|
2926
|
+
import { useMemo as useMemo8 } from "react";
|
|
2927
|
+
import { v4 as v43 } from "uuid";
|
|
2927
2928
|
|
|
2928
|
-
// src/components/Variables/
|
|
2929
|
+
// src/components/Variables/composer/PasteTransformerPlugin.tsx
|
|
2929
2930
|
init_emotion_jsx_shim();
|
|
2930
|
-
import {
|
|
2931
|
-
import {
|
|
2932
|
-
import {
|
|
2931
|
+
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
2932
|
+
import { $getSelection, $isRangeSelection, COMMAND_PRIORITY_HIGH, PASTE_COMMAND } from "lexical";
|
|
2933
|
+
import { useEffect as useEffect5 } from "react";
|
|
2934
|
+
function PasteTransformerPlugin({ transformPaste }) {
|
|
2935
|
+
const [editor] = useLexicalComposerContext();
|
|
2936
|
+
useEffect5(() => {
|
|
2937
|
+
editor.registerCommand(
|
|
2938
|
+
PASTE_COMMAND,
|
|
2939
|
+
(event) => {
|
|
2940
|
+
var _a;
|
|
2941
|
+
const selection = $getSelection();
|
|
2942
|
+
const pastedText = (_a = event.clipboardData) == null ? void 0 : _a.getData("text/plain");
|
|
2943
|
+
if (pastedText && transformPaste && $isRangeSelection(selection)) {
|
|
2944
|
+
const result = transformPaste(pastedText);
|
|
2945
|
+
if (result !== void 0) {
|
|
2946
|
+
selection.insertText(result);
|
|
2947
|
+
return true;
|
|
2948
|
+
}
|
|
2949
|
+
}
|
|
2950
|
+
return false;
|
|
2951
|
+
},
|
|
2952
|
+
COMMAND_PRIORITY_HIGH
|
|
2953
|
+
);
|
|
2954
|
+
}, [editor, transformPaste]);
|
|
2955
|
+
return null;
|
|
2956
|
+
}
|
|
2933
2957
|
|
|
2934
|
-
// src/components/Variables/styles/
|
|
2958
|
+
// src/components/Variables/styles/InputVariables.styles.ts
|
|
2935
2959
|
init_emotion_jsx_shim();
|
|
2936
2960
|
import { css as css18 } from "@emotion/react";
|
|
2961
|
+
var menuContainer = css18`
|
|
2962
|
+
position: relative;
|
|
2963
|
+
`;
|
|
2937
2964
|
var menuBtn = css18`
|
|
2965
|
+
position: absolute;
|
|
2966
|
+
top: 50%;
|
|
2967
|
+
right: var(--spacing-sm);
|
|
2968
|
+
transform: translateY(-50%);
|
|
2969
|
+
`;
|
|
2970
|
+
var input = css18`
|
|
2971
|
+
appearance: none;
|
|
2972
|
+
background-color: var(--white);
|
|
2973
|
+
border: 1px solid var(--gray-400);
|
|
2974
|
+
border-radius: var(--rounded-md);
|
|
2975
|
+
color: var(--gray-700);
|
|
2976
|
+
padding-block: var(--spacing-sm);
|
|
2977
|
+
padding-left: var(--spacing-base);
|
|
2978
|
+
padding-right: var(--spacing-lg);
|
|
2979
|
+
line-height: 2.5;
|
|
2980
|
+
width: 100%;
|
|
2981
|
+
position: relative;
|
|
2982
|
+
transition: background var(--duration-fast) var(--timing-ease-out),
|
|
2983
|
+
border-color var(--duration-fast) var(--timing-ease-out),
|
|
2984
|
+
color var(--duration-fast) var(--timing-ease-out);
|
|
2985
|
+
|
|
2986
|
+
&:focus,
|
|
2987
|
+
&:focus-within {
|
|
2988
|
+
border-color: var(--brand-secondary-1);
|
|
2989
|
+
box-shadow: none;
|
|
2990
|
+
outline: none;
|
|
2991
|
+
}
|
|
2992
|
+
|
|
2993
|
+
&:disabled,
|
|
2994
|
+
&:disabled::placeholder {
|
|
2995
|
+
cursor: not-allowed;
|
|
2996
|
+
color: var(--gray-300);
|
|
2997
|
+
border-color: var(--gray-300);
|
|
2998
|
+
}
|
|
2999
|
+
|
|
3000
|
+
> p {
|
|
3001
|
+
margin: 0;
|
|
3002
|
+
}
|
|
3003
|
+
`;
|
|
3004
|
+
|
|
3005
|
+
// src/components/Variables/util/getReferencedVariables.ts
|
|
3006
|
+
init_emotion_jsx_shim();
|
|
3007
|
+
|
|
3008
|
+
// src/components/Variables/util/parseVariableExpression.ts
|
|
3009
|
+
init_emotion_jsx_shim();
|
|
3010
|
+
|
|
3011
|
+
// src/components/Variables/util/variableExpression.ts
|
|
3012
|
+
init_emotion_jsx_shim();
|
|
3013
|
+
var variablePrefix = "${";
|
|
3014
|
+
var variableSuffix = "}";
|
|
3015
|
+
|
|
3016
|
+
// src/components/Variables/util/parseVariableExpression.ts
|
|
3017
|
+
function parseVariableExpression(serialized, onToken) {
|
|
3018
|
+
let buf = [];
|
|
3019
|
+
let state = "text";
|
|
3020
|
+
for (let index = 0; index < serialized.length; index++) {
|
|
3021
|
+
const char = serialized[index];
|
|
3022
|
+
if (char === "$" && serialized.at(index + 1) === "{") {
|
|
3023
|
+
if (serialized.at(index - 1) === "\\") {
|
|
3024
|
+
buf.pop();
|
|
3025
|
+
buf.push(char);
|
|
3026
|
+
continue;
|
|
3027
|
+
}
|
|
3028
|
+
state = "variable";
|
|
3029
|
+
if (buf.length) {
|
|
3030
|
+
onToken(buf.join(""), "text");
|
|
3031
|
+
buf = [];
|
|
3032
|
+
}
|
|
3033
|
+
index++;
|
|
3034
|
+
continue;
|
|
3035
|
+
}
|
|
3036
|
+
if (char === "}" && state === "variable") {
|
|
3037
|
+
state = "text";
|
|
3038
|
+
if (buf.length) {
|
|
3039
|
+
onToken(buf.join(""), "variable");
|
|
3040
|
+
buf = [];
|
|
3041
|
+
}
|
|
3042
|
+
continue;
|
|
3043
|
+
}
|
|
3044
|
+
buf.push(char);
|
|
3045
|
+
}
|
|
3046
|
+
if (buf.length) {
|
|
3047
|
+
if (state === "variable") {
|
|
3048
|
+
state = "text";
|
|
3049
|
+
buf.unshift(variablePrefix);
|
|
3050
|
+
}
|
|
3051
|
+
onToken(buf.join(""), state);
|
|
3052
|
+
}
|
|
3053
|
+
}
|
|
3054
|
+
|
|
3055
|
+
// src/components/Variables/util/getReferencedVariables.ts
|
|
3056
|
+
function getReferencedVariables(value) {
|
|
3057
|
+
const result = [];
|
|
3058
|
+
parseVariableExpression(value, (token, type) => {
|
|
3059
|
+
if (type === "variable") {
|
|
3060
|
+
result.push(token);
|
|
3061
|
+
}
|
|
3062
|
+
});
|
|
3063
|
+
return result;
|
|
3064
|
+
}
|
|
3065
|
+
|
|
3066
|
+
// src/components/Variables/VariableField.tsx
|
|
3067
|
+
init_emotion_jsx_shim();
|
|
3068
|
+
|
|
3069
|
+
// src/components/Variables/styles/VariableField.styles.ts
|
|
3070
|
+
init_emotion_jsx_shim();
|
|
3071
|
+
import { css as css19 } from "@emotion/react";
|
|
3072
|
+
var labelText = css19`
|
|
3073
|
+
align-items: center;
|
|
3074
|
+
display: flex;
|
|
3075
|
+
gap: var(--spacing-xs);
|
|
3076
|
+
font-weight: var(--fw-regular);
|
|
3077
|
+
margin: 0 0 var(--spacing-xs);
|
|
3078
|
+
`;
|
|
3079
|
+
var variableBindButton = css19`
|
|
3080
|
+
align-items: center;
|
|
3081
|
+
border: none;
|
|
3082
|
+
border-radius: var(--rounded-base);
|
|
3083
|
+
background: none;
|
|
3084
|
+
display: flex;
|
|
3085
|
+
height: 1.2rem;
|
|
3086
|
+
padding: var(--spacing-2xs);
|
|
3087
|
+
transition: background var(--duration-fast) var(--timing-ease-out),
|
|
3088
|
+
color var(--duration-fast) var(--timing-ease-out);
|
|
3089
|
+
width: 1.2rem;
|
|
3090
|
+
|
|
3091
|
+
&:hover,
|
|
3092
|
+
&[aria-pressed='true']:not(:disabled) {
|
|
3093
|
+
background: var(--brand-secondary-3);
|
|
3094
|
+
color: var(--white);
|
|
3095
|
+
}
|
|
3096
|
+
|
|
3097
|
+
&[aria-disabled='true'] {
|
|
3098
|
+
background: none;
|
|
3099
|
+
color: currentColor;
|
|
3100
|
+
}
|
|
3101
|
+
`;
|
|
3102
|
+
|
|
3103
|
+
// src/components/Variables/VariablesComposerVariableMenu.tsx
|
|
3104
|
+
init_emotion_jsx_shim();
|
|
3105
|
+
import { useLexicalComposerContext as useLexicalComposerContext3 } from "@lexical/react/LexicalComposerContext";
|
|
3106
|
+
import { CLEAR_EDITOR_COMMAND } from "lexical";
|
|
3107
|
+
|
|
3108
|
+
// src/components/Variables/composer/VariablesPlugin.tsx
|
|
3109
|
+
init_emotion_jsx_shim();
|
|
3110
|
+
import { css as css22 } from "@emotion/react";
|
|
3111
|
+
import { useLexicalComposerContext as useLexicalComposerContext2 } from "@lexical/react/LexicalComposerContext";
|
|
3112
|
+
import {
|
|
3113
|
+
LexicalTypeaheadMenuPlugin,
|
|
3114
|
+
MenuOption
|
|
3115
|
+
} from "@lexical/react/LexicalTypeaheadMenuPlugin";
|
|
3116
|
+
import { MenuGroup, MenuItem as MenuItem2, MenuItemSeparator } from "@uniformdev/design-system";
|
|
3117
|
+
import { $insertNodes, $nodesOfType, COMMAND_PRIORITY_NORMAL, createCommand } from "lexical";
|
|
3118
|
+
import { useCallback, useEffect as useEffect7, useMemo as useMemo6, useState as useState8 } from "react";
|
|
3119
|
+
import { createPortal } from "react-dom";
|
|
3120
|
+
|
|
3121
|
+
// src/components/Variables/styles/InsertVariableMenu.styles.ts
|
|
3122
|
+
init_emotion_jsx_shim();
|
|
3123
|
+
import { css as css20 } from "@emotion/react";
|
|
3124
|
+
var menuBtn2 = css20`
|
|
2938
3125
|
background: none;
|
|
2939
3126
|
border: none;
|
|
2940
3127
|
color: var(--gray-500);
|
|
2941
3128
|
padding: 0;
|
|
2942
3129
|
`;
|
|
2943
|
-
var menuItemTextGroup =
|
|
3130
|
+
var menuItemTextGroup = css20`
|
|
2944
3131
|
align-items: flex-start;
|
|
2945
3132
|
display: flex;
|
|
2946
3133
|
flex-direction: column;
|
|
3134
|
+
gap: 0;
|
|
3135
|
+
line-height: 1em;
|
|
2947
3136
|
`;
|
|
2948
|
-
var smallText =
|
|
3137
|
+
var smallText = css20`
|
|
2949
3138
|
font-size: var(--fs-xs);
|
|
3139
|
+
color: var(--gray-500);
|
|
2950
3140
|
`;
|
|
2951
|
-
var variablesTipText =
|
|
3141
|
+
var variablesTipText = css20`
|
|
2952
3142
|
${smallText}
|
|
2953
3143
|
color: var(--gray-500);
|
|
2954
3144
|
padding: 0 var(--spacing-sm);
|
|
@@ -2956,7 +3146,7 @@ var variablesTipText = css18`
|
|
|
2956
3146
|
|
|
2957
3147
|
// src/components/Variables/useOnVariableUpdated.ts
|
|
2958
3148
|
init_emotion_jsx_shim();
|
|
2959
|
-
import { useEffect as
|
|
3149
|
+
import { useEffect as useEffect6 } from "react";
|
|
2960
3150
|
|
|
2961
3151
|
// src/components/Variables/VariablesProvider.tsx
|
|
2962
3152
|
init_emotion_jsx_shim();
|
|
@@ -2972,13 +3162,13 @@ import { z } from "zod";
|
|
|
2972
3162
|
|
|
2973
3163
|
// src/components/Variables/styles/VariableEditor.styles.ts
|
|
2974
3164
|
init_emotion_jsx_shim();
|
|
2975
|
-
import { css as
|
|
2976
|
-
var variablesFormContainer =
|
|
3165
|
+
import { css as css21 } from "@emotion/react";
|
|
3166
|
+
var variablesFormContainer = css21`
|
|
2977
3167
|
> * {
|
|
2978
3168
|
margin: var(--spacing-base) 0 0;
|
|
2979
3169
|
}
|
|
2980
3170
|
`;
|
|
2981
|
-
var variablesFormBtnGroup =
|
|
3171
|
+
var variablesFormBtnGroup = css21`
|
|
2982
3172
|
display: flex;
|
|
2983
3173
|
gap: var(--spacing-sm);
|
|
2984
3174
|
`;
|
|
@@ -3079,17 +3269,27 @@ function VariablesProvider({
|
|
|
3079
3269
|
value,
|
|
3080
3270
|
onChange,
|
|
3081
3271
|
editVariableComponent,
|
|
3272
|
+
readOnly,
|
|
3082
3273
|
children
|
|
3083
3274
|
}) {
|
|
3084
3275
|
const [editing, setEditing] = React10.useState();
|
|
3085
3276
|
const events = React10.useMemo(() => mitt(), []);
|
|
3277
|
+
if (!readOnly && !onChange) {
|
|
3278
|
+
throw new Error("onChange must be provided when readOnly is false");
|
|
3279
|
+
}
|
|
3086
3280
|
const Editor = editVariableComponent != null ? editVariableComponent : VariableEditor;
|
|
3087
3281
|
const contextValue = {
|
|
3088
3282
|
flatVariables: flattenVariables(value),
|
|
3089
3283
|
dispatch: (event) => {
|
|
3284
|
+
if (readOnly) {
|
|
3285
|
+
console.warn(
|
|
3286
|
+
`Received ignored mutation event in read-only variables context: ${JSON.stringify(event)}`
|
|
3287
|
+
);
|
|
3288
|
+
return;
|
|
3289
|
+
}
|
|
3090
3290
|
if (event.type === "set") {
|
|
3091
3291
|
const { name, ...varValue } = event.variable;
|
|
3092
|
-
onChange({ ...contextValue.variables, [event.variable.name]: varValue });
|
|
3292
|
+
onChange == null ? void 0 : onChange({ ...contextValue.variables, [event.variable.name]: varValue });
|
|
3093
3293
|
if (event.openEditor) {
|
|
3094
3294
|
setEditing(event.variable.name);
|
|
3095
3295
|
}
|
|
@@ -3098,9 +3298,9 @@ function VariablesProvider({
|
|
|
3098
3298
|
} else if (event.type === "remove") {
|
|
3099
3299
|
const newValue = { ...value };
|
|
3100
3300
|
delete newValue[event.variable];
|
|
3101
|
-
onChange(newValue);
|
|
3301
|
+
onChange == null ? void 0 : onChange(newValue);
|
|
3102
3302
|
} else if (event.type === "reorder") {
|
|
3103
|
-
onChange(event.result);
|
|
3303
|
+
onChange == null ? void 0 : onChange(event.result);
|
|
3104
3304
|
} else {
|
|
3105
3305
|
throw new Error(`Unknown event ${JSON.stringify(event)}`);
|
|
3106
3306
|
}
|
|
@@ -3108,7 +3308,8 @@ function VariablesProvider({
|
|
|
3108
3308
|
variables: value,
|
|
3109
3309
|
isEditing: typeof editing !== "undefined",
|
|
3110
3310
|
events,
|
|
3111
|
-
canDispatch: true
|
|
3311
|
+
canDispatch: true,
|
|
3312
|
+
readOnly
|
|
3112
3313
|
};
|
|
3113
3314
|
return /* @__PURE__ */ jsxs17(VariablesContext.Provider, { value: contextValue, children: [
|
|
3114
3315
|
children,
|
|
@@ -3118,7 +3319,7 @@ function VariablesProvider({
|
|
|
3118
3319
|
onSubmit: (val) => {
|
|
3119
3320
|
setEditing(void 0);
|
|
3120
3321
|
const { name, ...varValue } = val;
|
|
3121
|
-
onChange({ ...value, [name]: varValue });
|
|
3322
|
+
onChange == null ? void 0 : onChange({ ...value, [name]: varValue });
|
|
3122
3323
|
events.emit("update", name);
|
|
3123
3324
|
},
|
|
3124
3325
|
onCancel: () => setEditing(void 0),
|
|
@@ -3157,7 +3358,7 @@ function flattenVariables(variables) {
|
|
|
3157
3358
|
// src/components/Variables/useOnVariableUpdated.ts
|
|
3158
3359
|
function useOnVariableUpdated(fn2, disabled) {
|
|
3159
3360
|
const { variables, events } = useVariables();
|
|
3160
|
-
|
|
3361
|
+
useEffect6(() => {
|
|
3161
3362
|
if (disabled) {
|
|
3162
3363
|
return;
|
|
3163
3364
|
}
|
|
@@ -3166,6 +3367,9 @@ function useOnVariableUpdated(fn2, disabled) {
|
|
|
3166
3367
|
}, [disabled, events, fn2, variables]);
|
|
3167
3368
|
}
|
|
3168
3369
|
|
|
3370
|
+
// src/components/Variables/variablesToGroupedList.ts
|
|
3371
|
+
init_emotion_jsx_shim();
|
|
3372
|
+
|
|
3169
3373
|
// src/components/Variables/variablesToList.ts
|
|
3170
3374
|
init_emotion_jsx_shim();
|
|
3171
3375
|
function variablesToList(variables) {
|
|
@@ -3185,180 +3389,474 @@ function variablesToList(variables) {
|
|
|
3185
3389
|
}));
|
|
3186
3390
|
}
|
|
3187
3391
|
|
|
3392
|
+
// src/components/Variables/variablesToGroupedList.ts
|
|
3393
|
+
function variablesToGroupedList(variables) {
|
|
3394
|
+
const groups = {};
|
|
3395
|
+
Object.entries(variables || {}).forEach(([name, definition]) => {
|
|
3396
|
+
var _a;
|
|
3397
|
+
const group = (_a = definition.source) != null ? _a : "";
|
|
3398
|
+
if (!groups[group]) {
|
|
3399
|
+
groups[group] = {};
|
|
3400
|
+
}
|
|
3401
|
+
groups[group][name] = definition;
|
|
3402
|
+
});
|
|
3403
|
+
return Object.entries(groups).map(([group, variables2]) => ({
|
|
3404
|
+
name: group,
|
|
3405
|
+
variables: variablesToList(variables2)
|
|
3406
|
+
})).sort((a2, b2) => {
|
|
3407
|
+
var _a, _b;
|
|
3408
|
+
return ((_a = a2.name) != null ? _a : "").localeCompare((_b = b2.name) != null ? _b : "");
|
|
3409
|
+
});
|
|
3410
|
+
}
|
|
3411
|
+
|
|
3412
|
+
// src/components/Variables/composer/VariableNode.tsx
|
|
3413
|
+
init_emotion_jsx_shim();
|
|
3414
|
+
import { Chip } from "@uniformdev/design-system";
|
|
3415
|
+
import { DecoratorNode } from "lexical";
|
|
3416
|
+
import { Fragment as Fragment4 } from "react";
|
|
3417
|
+
import { jsx as jsx30 } from "@emotion/react/jsx-runtime";
|
|
3418
|
+
var VariableNode = class extends DecoratorNode {
|
|
3419
|
+
constructor(reference, state, key) {
|
|
3420
|
+
super(key);
|
|
3421
|
+
this.reference = reference;
|
|
3422
|
+
this.__state = state;
|
|
3423
|
+
}
|
|
3424
|
+
static getType() {
|
|
3425
|
+
return "variable";
|
|
3426
|
+
}
|
|
3427
|
+
static clone(node) {
|
|
3428
|
+
return new VariableNode(node.reference, { ...node.__state }, node.__key);
|
|
3429
|
+
}
|
|
3430
|
+
/** Imports the node from serialized JSON (i.e. the data provided to the editor's initial state) */
|
|
3431
|
+
static importJSON(serializedNode) {
|
|
3432
|
+
return $createVariableNode(serializedNode.reference, {
|
|
3433
|
+
displayName: serializedNode.reference,
|
|
3434
|
+
referenceIsValid: true,
|
|
3435
|
+
hasClickEvent: void 0
|
|
3436
|
+
});
|
|
3437
|
+
}
|
|
3438
|
+
/**
|
|
3439
|
+
* Updates the node's variables state so it knows its current validity, display name, etc
|
|
3440
|
+
* The plugin updates this whenever the variables prop changes.
|
|
3441
|
+
*/
|
|
3442
|
+
setState(state) {
|
|
3443
|
+
this.getWritable().__state = state;
|
|
3444
|
+
}
|
|
3445
|
+
/**
|
|
3446
|
+
* Serializes the node to JSON for editor initial state
|
|
3447
|
+
*/
|
|
3448
|
+
exportJSON() {
|
|
3449
|
+
return {
|
|
3450
|
+
reference: this.reference,
|
|
3451
|
+
type: VariableNode.getType(),
|
|
3452
|
+
version: 1
|
|
3453
|
+
};
|
|
3454
|
+
}
|
|
3455
|
+
/**
|
|
3456
|
+
* Copy variable to clipboard in a format we will read back if pasted
|
|
3457
|
+
* (albeit it won't get the fancy chip-node)
|
|
3458
|
+
*/
|
|
3459
|
+
getTextContent() {
|
|
3460
|
+
return `\${${this.reference}}`;
|
|
3461
|
+
}
|
|
3462
|
+
/** Creates the DOM wrapper that hosts the node */
|
|
3463
|
+
createDOM() {
|
|
3464
|
+
return document.createElement("span");
|
|
3465
|
+
}
|
|
3466
|
+
updateDOM() {
|
|
3467
|
+
return false;
|
|
3468
|
+
}
|
|
3469
|
+
/**
|
|
3470
|
+
* Render the variable node using React.
|
|
3471
|
+
* NOTE: this is effectively an island of React, and you may not call hooks,
|
|
3472
|
+
* rely on Context, etc in this renderer.
|
|
3473
|
+
*/
|
|
3474
|
+
decorate(editor) {
|
|
3475
|
+
const { displayName, hasClickEvent, referenceIsValid } = this.__state;
|
|
3476
|
+
const Wrapper = referenceIsValid ? Fragment4 : UndefinedVariableReference;
|
|
3477
|
+
return /* @__PURE__ */ jsx30(
|
|
3478
|
+
Chip,
|
|
3479
|
+
{
|
|
3480
|
+
text: /* @__PURE__ */ jsx30(Wrapper, { children: displayName || this.reference }),
|
|
3481
|
+
title: !referenceIsValid ? `${this.reference} is not defined.` : hasClickEvent ? "Click to edit" : void 0,
|
|
3482
|
+
onClick: () => {
|
|
3483
|
+
editor.dispatchCommand(EDIT_VARIABLE_COMMAND, {
|
|
3484
|
+
reference: this.reference
|
|
3485
|
+
});
|
|
3486
|
+
}
|
|
3487
|
+
}
|
|
3488
|
+
);
|
|
3489
|
+
}
|
|
3490
|
+
/** Enables keyboard navigation to hop over the node to previous text */
|
|
3491
|
+
isIsolated() {
|
|
3492
|
+
return true;
|
|
3493
|
+
}
|
|
3494
|
+
};
|
|
3495
|
+
function $createVariableNode(variableReference, state) {
|
|
3496
|
+
return new VariableNode(variableReference, state);
|
|
3497
|
+
}
|
|
3498
|
+
function UndefinedVariableReference({ children }) {
|
|
3499
|
+
return /* @__PURE__ */ jsx30(
|
|
3500
|
+
"span",
|
|
3501
|
+
{
|
|
3502
|
+
style: {
|
|
3503
|
+
textDecoration: "underline",
|
|
3504
|
+
textDecorationStyle: "wavy",
|
|
3505
|
+
textDecorationColor: "red"
|
|
3506
|
+
},
|
|
3507
|
+
children
|
|
3508
|
+
}
|
|
3509
|
+
);
|
|
3510
|
+
}
|
|
3511
|
+
|
|
3512
|
+
// src/components/Variables/composer/VariablesPlugin.tsx
|
|
3513
|
+
import { jsx as jsx31, jsxs as jsxs18 } from "@emotion/react/jsx-runtime";
|
|
3514
|
+
var EDIT_VARIABLE_COMMAND = createCommand("uniform:edit-variable");
|
|
3515
|
+
var INSERT_VARIABLE_COMMAND = createCommand("uniform:insert-variable");
|
|
3516
|
+
var PUNCTUATION = `\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'"~=<>_:;`;
|
|
3517
|
+
var NAME = "\\b[A-Z][^\\s" + PUNCTUATION + "]";
|
|
3518
|
+
var DocumentVariablesRegex = {
|
|
3519
|
+
NAME,
|
|
3520
|
+
PUNCTUATION
|
|
3521
|
+
};
|
|
3522
|
+
var PUNC = DocumentVariablesRegex.PUNCTUATION;
|
|
3523
|
+
var TRIGGERS = ["$"].join("");
|
|
3524
|
+
var VALID_CHARS = "[^" + TRIGGERS + PUNC + "\\s]";
|
|
3525
|
+
var VALID_JOINS = "(?:\\.[ |$]| |[" + PUNC + "]|)";
|
|
3526
|
+
var LENGTH_LIMIT = 75;
|
|
3527
|
+
var DollarSignVariablesRegex = new RegExp(
|
|
3528
|
+
"(^.*)([" + TRIGGERS + "]((?:" + VALID_CHARS + VALID_JOINS + "){0," + LENGTH_LIMIT + "}))$"
|
|
3529
|
+
);
|
|
3530
|
+
function getPossibleQueryMatch(text) {
|
|
3531
|
+
const match = DollarSignVariablesRegex.exec(text);
|
|
3532
|
+
if (match !== null) {
|
|
3533
|
+
const maybeLeadingWhitespace = match[1];
|
|
3534
|
+
const matchingString = match[3];
|
|
3535
|
+
return {
|
|
3536
|
+
leadOffset: match.index + maybeLeadingWhitespace.length,
|
|
3537
|
+
matchingString,
|
|
3538
|
+
replaceableString: match[2]
|
|
3539
|
+
};
|
|
3540
|
+
}
|
|
3541
|
+
return null;
|
|
3542
|
+
}
|
|
3543
|
+
var ADD_VARIABLE_OPTION = "$$add-variable$$";
|
|
3544
|
+
var SOURCE_SEPARATOR = "--";
|
|
3545
|
+
function VariablesPlugin({
|
|
3546
|
+
disableVariables,
|
|
3547
|
+
showAddVariableMenuOption,
|
|
3548
|
+
enableEditingVariables
|
|
3549
|
+
}) {
|
|
3550
|
+
const [editor] = useLexicalComposerContext2();
|
|
3551
|
+
const { variables, dispatch, isEditing, canDispatch, readOnly } = useVariables();
|
|
3552
|
+
const canEditVariable = canDispatch && enableEditingVariables && !readOnly;
|
|
3553
|
+
const canAddVariable = canDispatch && showAddVariableMenuOption && !readOnly;
|
|
3554
|
+
const [openedAdd, setOpenedAdd] = useState8(false);
|
|
3555
|
+
useOnVariableUpdated((varName) => {
|
|
3556
|
+
editor.update(() => {
|
|
3557
|
+
editor.dispatchCommand(INSERT_VARIABLE_COMMAND, { reference: varName });
|
|
3558
|
+
});
|
|
3559
|
+
}, !openedAdd);
|
|
3560
|
+
useEffect7(() => {
|
|
3561
|
+
if (openedAdd && !isEditing) {
|
|
3562
|
+
setOpenedAdd(false);
|
|
3563
|
+
}
|
|
3564
|
+
}, [isEditing, openedAdd]);
|
|
3565
|
+
const [queryString, setQueryString] = useState8(null);
|
|
3566
|
+
const { groupedVariables, menuOptions } = useMemo6(() => {
|
|
3567
|
+
const groupedVariables2 = variablesToGroupedList(variables);
|
|
3568
|
+
if (canAddVariable) {
|
|
3569
|
+
groupedVariables2.push({
|
|
3570
|
+
name: SOURCE_SEPARATOR,
|
|
3571
|
+
variables: [{ name: ADD_VARIABLE_OPTION, displayName: "Add\u2026", default: "" }]
|
|
3572
|
+
});
|
|
3573
|
+
}
|
|
3574
|
+
const menuOptions2 = [];
|
|
3575
|
+
groupedVariables2.forEach(
|
|
3576
|
+
(group) => group.variables.forEach((variable) => {
|
|
3577
|
+
menuOptions2.push(new MenuOption(variable.name));
|
|
3578
|
+
})
|
|
3579
|
+
);
|
|
3580
|
+
return { menuOptions: menuOptions2, groupedVariables: groupedVariables2 };
|
|
3581
|
+
}, [variables, canAddVariable]);
|
|
3582
|
+
const { filteredGroupedVariables, filteredMenuOptions } = useMemo6(() => {
|
|
3583
|
+
if (!queryString) {
|
|
3584
|
+
return {
|
|
3585
|
+
filteredGroupedVariables: groupedVariables,
|
|
3586
|
+
filteredMenuOptions: menuOptions
|
|
3587
|
+
};
|
|
3588
|
+
}
|
|
3589
|
+
const query = queryString.toLowerCase();
|
|
3590
|
+
return {
|
|
3591
|
+
filteredGroupedVariables: groupedVariables.map((group) => ({
|
|
3592
|
+
name: group.name,
|
|
3593
|
+
variables: group.variables.filter(
|
|
3594
|
+
(option) => option.name.toLowerCase().includes(query) || option.name === ADD_VARIABLE_OPTION
|
|
3595
|
+
)
|
|
3596
|
+
})).filter((group) => group.variables.length > 0),
|
|
3597
|
+
filteredMenuOptions: menuOptions.filter(
|
|
3598
|
+
(option) => option.key.includes(query) || option.key === ADD_VARIABLE_OPTION
|
|
3599
|
+
)
|
|
3600
|
+
};
|
|
3601
|
+
}, [queryString, groupedVariables, menuOptions]);
|
|
3602
|
+
const onSelectOption = useCallback(
|
|
3603
|
+
(selectedOption, nodeToReplace, closeMenu) => {
|
|
3604
|
+
if (selectedOption.key === ADD_VARIABLE_OPTION) {
|
|
3605
|
+
setOpenedAdd(true);
|
|
3606
|
+
editor.update(() => {
|
|
3607
|
+
nodeToReplace == null ? void 0 : nodeToReplace.remove();
|
|
3608
|
+
});
|
|
3609
|
+
editor.dispatchCommand(EDIT_VARIABLE_COMMAND, {
|
|
3610
|
+
reference: queryString != null ? queryString : ""
|
|
3611
|
+
});
|
|
3612
|
+
} else {
|
|
3613
|
+
editor.update(() => {
|
|
3614
|
+
var _a;
|
|
3615
|
+
const variableNode = $createVariableNode(selectedOption.key, {
|
|
3616
|
+
displayName: ((_a = variables[selectedOption.key]) == null ? void 0 : _a.displayName) || selectedOption.key,
|
|
3617
|
+
hasClickEvent: canEditVariable,
|
|
3618
|
+
referenceIsValid: Boolean(variables[selectedOption.key])
|
|
3619
|
+
});
|
|
3620
|
+
if (nodeToReplace) {
|
|
3621
|
+
nodeToReplace.replace(variableNode);
|
|
3622
|
+
}
|
|
3623
|
+
});
|
|
3624
|
+
}
|
|
3625
|
+
closeMenu();
|
|
3626
|
+
},
|
|
3627
|
+
[editor, queryString, variables, canEditVariable]
|
|
3628
|
+
);
|
|
3629
|
+
useEffect7(() => {
|
|
3630
|
+
editor.registerCommand(
|
|
3631
|
+
EDIT_VARIABLE_COMMAND,
|
|
3632
|
+
({ reference }) => {
|
|
3633
|
+
if (!disableVariables && canEditVariable) {
|
|
3634
|
+
dispatch({ type: "edit", variable: reference });
|
|
3635
|
+
}
|
|
3636
|
+
return true;
|
|
3637
|
+
},
|
|
3638
|
+
COMMAND_PRIORITY_NORMAL
|
|
3639
|
+
);
|
|
3640
|
+
editor.registerCommand(
|
|
3641
|
+
INSERT_VARIABLE_COMMAND,
|
|
3642
|
+
({ reference }) => {
|
|
3643
|
+
var _a;
|
|
3644
|
+
if (!disableVariables) {
|
|
3645
|
+
const variableNode = $createVariableNode(reference, {
|
|
3646
|
+
displayName: ((_a = variables[reference]) == null ? void 0 : _a.displayName) || reference,
|
|
3647
|
+
hasClickEvent: canEditVariable,
|
|
3648
|
+
referenceIsValid: Boolean(variables[reference])
|
|
3649
|
+
});
|
|
3650
|
+
$insertNodes([variableNode]);
|
|
3651
|
+
}
|
|
3652
|
+
return true;
|
|
3653
|
+
},
|
|
3654
|
+
COMMAND_PRIORITY_NORMAL
|
|
3655
|
+
);
|
|
3656
|
+
}, [editor, disableVariables, variables, canDispatch, dispatch, canEditVariable, readOnly]);
|
|
3657
|
+
useEffect7(() => {
|
|
3658
|
+
editor.update(() => {
|
|
3659
|
+
$nodesOfType(VariableNode).forEach((variableNode) => {
|
|
3660
|
+
const targetVar = variables[variableNode.reference];
|
|
3661
|
+
variableNode.setState({
|
|
3662
|
+
displayName: (targetVar == null ? void 0 : targetVar.displayName) || variableNode.reference,
|
|
3663
|
+
hasClickEvent: canEditVariable,
|
|
3664
|
+
referenceIsValid: Boolean(targetVar)
|
|
3665
|
+
});
|
|
3666
|
+
});
|
|
3667
|
+
});
|
|
3668
|
+
}, [editor, variables, canEditVariable]);
|
|
3669
|
+
if (disableVariables) {
|
|
3670
|
+
return null;
|
|
3671
|
+
}
|
|
3672
|
+
return /* @__PURE__ */ jsx31(
|
|
3673
|
+
LexicalTypeaheadMenuPlugin,
|
|
3674
|
+
{
|
|
3675
|
+
onQueryChange: setQueryString,
|
|
3676
|
+
onSelectOption,
|
|
3677
|
+
triggerFn: getPossibleQueryMatch,
|
|
3678
|
+
options: filteredMenuOptions,
|
|
3679
|
+
menuRenderFn: (anchorElementRef, { selectOptionAndCleanUp, setHighlightedIndex, selectedIndex }) => {
|
|
3680
|
+
if (!anchorElementRef.current || groupedVariables.length === 0 || openedAdd) {
|
|
3681
|
+
return null;
|
|
3682
|
+
}
|
|
3683
|
+
let currentCumulativeMenuIndex = -1;
|
|
3684
|
+
return createPortal(
|
|
3685
|
+
/* @__PURE__ */ jsx31(
|
|
3686
|
+
"div",
|
|
3687
|
+
{
|
|
3688
|
+
css: css22`
|
|
3689
|
+
box-shadow: var(--shadow-base);
|
|
3690
|
+
border-radius: var(--rounded-base);
|
|
3691
|
+
background: var(--gray-50);
|
|
3692
|
+
display: flex;
|
|
3693
|
+
flex-direction: column;
|
|
3694
|
+
// 1em = text height, spacing-sm for padding, to prevent menu overlapping text entry
|
|
3695
|
+
margin-top: calc(1em + var(--spacing-sm));
|
|
3696
|
+
min-width: 250px;
|
|
3697
|
+
padding: var(--spacing-sm);
|
|
3698
|
+
outline: none;
|
|
3699
|
+
overflow: hidden;
|
|
3700
|
+
position: relative;
|
|
3701
|
+
z-index: var(--z-50);
|
|
3702
|
+
`,
|
|
3703
|
+
children: /* @__PURE__ */ jsx31("div", { children: filteredGroupedVariables.map((group, index) => {
|
|
3704
|
+
var _a, _b;
|
|
3705
|
+
return /* @__PURE__ */ jsxs18(
|
|
3706
|
+
MenuGroup,
|
|
3707
|
+
{
|
|
3708
|
+
title: group.name === SOURCE_SEPARATOR ? "" : (_a = group.name) != null ? _a : "",
|
|
3709
|
+
children: [
|
|
3710
|
+
group.name === SOURCE_SEPARATOR && currentCumulativeMenuIndex > 0 ? /* @__PURE__ */ jsx31(MenuItemSeparator, {}) : null,
|
|
3711
|
+
group.variables.map((variable) => {
|
|
3712
|
+
var _a2;
|
|
3713
|
+
currentCumulativeMenuIndex++;
|
|
3714
|
+
const myCumulativeIndex = currentCumulativeMenuIndex;
|
|
3715
|
+
return /* @__PURE__ */ jsxs18(
|
|
3716
|
+
MenuItem2,
|
|
3717
|
+
{
|
|
3718
|
+
active: selectedIndex === myCumulativeIndex,
|
|
3719
|
+
onClick: () => {
|
|
3720
|
+
setHighlightedIndex(myCumulativeIndex);
|
|
3721
|
+
selectOptionAndCleanUp(new MenuOption(variable.name));
|
|
3722
|
+
},
|
|
3723
|
+
onMouseEnter: () => {
|
|
3724
|
+
setHighlightedIndex(myCumulativeIndex);
|
|
3725
|
+
},
|
|
3726
|
+
css: menuItemTextGroup,
|
|
3727
|
+
children: [
|
|
3728
|
+
/* @__PURE__ */ jsx31("span", { children: (_a2 = variable.displayName) != null ? _a2 : variable.name }),
|
|
3729
|
+
variable.helpText ? /* @__PURE__ */ jsx31("small", { css: smallText, children: variable.helpText }) : null
|
|
3730
|
+
]
|
|
3731
|
+
},
|
|
3732
|
+
variable.name
|
|
3733
|
+
);
|
|
3734
|
+
})
|
|
3735
|
+
]
|
|
3736
|
+
},
|
|
3737
|
+
(_b = group.name) != null ? _b : `none${index}`
|
|
3738
|
+
);
|
|
3739
|
+
}) })
|
|
3740
|
+
}
|
|
3741
|
+
),
|
|
3742
|
+
anchorElementRef.current
|
|
3743
|
+
);
|
|
3744
|
+
}
|
|
3745
|
+
}
|
|
3746
|
+
);
|
|
3747
|
+
}
|
|
3748
|
+
|
|
3188
3749
|
// src/components/Variables/SelectVariableMenu.tsx
|
|
3189
|
-
|
|
3750
|
+
init_emotion_jsx_shim();
|
|
3751
|
+
import { Menu as Menu2, MenuGroup as MenuGroup2, MenuItem as MenuItem3, MenuItemSeparator as MenuItemSeparator2 } from "@uniformdev/design-system";
|
|
3752
|
+
import { useEffect as useEffect8, useRef as useRef8, useState as useState9 } from "react";
|
|
3753
|
+
import { CgUsbC } from "react-icons/cg";
|
|
3754
|
+
import { Fragment as Fragment5, jsx as jsx32, jsxs as jsxs19 } from "@emotion/react/jsx-runtime";
|
|
3190
3755
|
var SelectVariableMenu = ({
|
|
3191
3756
|
onSelectVariable,
|
|
3192
3757
|
onResetVariables,
|
|
3193
3758
|
showAddVariableMenuOption = false,
|
|
3194
|
-
forceVisible,
|
|
3195
3759
|
buttonCss,
|
|
3196
3760
|
buttonProps,
|
|
3197
3761
|
tip
|
|
3198
3762
|
}) => {
|
|
3199
3763
|
const { variables, dispatch, isEditing, canDispatch } = useVariables();
|
|
3200
3764
|
const btnRef = useRef8(null);
|
|
3201
|
-
const [openedAdd, setOpenedAdd] =
|
|
3765
|
+
const [openedAdd, setOpenedAdd] = useState9(false);
|
|
3202
3766
|
useOnVariableUpdated((varName) => {
|
|
3203
3767
|
onSelectVariable == null ? void 0 : onSelectVariable({ name: varName, default: "" });
|
|
3204
3768
|
}, !openedAdd);
|
|
3205
|
-
|
|
3769
|
+
useEffect8(() => {
|
|
3206
3770
|
if (openedAdd && !isEditing) {
|
|
3207
3771
|
setOpenedAdd(false);
|
|
3208
3772
|
}
|
|
3209
3773
|
}, [isEditing, openedAdd]);
|
|
3210
|
-
const
|
|
3774
|
+
const variablesGroups = variablesToGroupedList(variables);
|
|
3211
3775
|
const menuHasVariableOptions = Object.entries(variables).length || showAddVariableMenuOption;
|
|
3212
|
-
return /* @__PURE__ */
|
|
3776
|
+
return /* @__PURE__ */ jsxs19(
|
|
3213
3777
|
Menu2,
|
|
3214
3778
|
{
|
|
3215
3779
|
placement: "bottom-start",
|
|
3216
|
-
|
|
3217
|
-
menuTrigger: /* @__PURE__ */ jsx30(
|
|
3780
|
+
menuTrigger: /* @__PURE__ */ jsx32(
|
|
3218
3781
|
"button",
|
|
3219
3782
|
{
|
|
3220
3783
|
title: "Insert variable",
|
|
3221
3784
|
...buttonProps,
|
|
3222
3785
|
ref: btnRef,
|
|
3223
|
-
css: [
|
|
3786
|
+
css: [menuBtn2, buttonCss],
|
|
3224
3787
|
type: "button",
|
|
3225
|
-
children: /* @__PURE__ */
|
|
3788
|
+
children: /* @__PURE__ */ jsx32(CgUsbC, { size: "1.4rem" })
|
|
3226
3789
|
}
|
|
3227
3790
|
),
|
|
3228
3791
|
menuLabel: "Insert variable",
|
|
3229
3792
|
children: [
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
return /* @__PURE__ */
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3793
|
+
variablesGroups.map((group) => {
|
|
3794
|
+
var _a;
|
|
3795
|
+
return /* @__PURE__ */ jsx32(MenuGroup2, { title: (_a = group.name) != null ? _a : "", children: group.variables.map((variable) => {
|
|
3796
|
+
const { name, helpText } = variable;
|
|
3797
|
+
return /* @__PURE__ */ jsxs19(
|
|
3798
|
+
MenuItem3,
|
|
3799
|
+
{
|
|
3800
|
+
id: name,
|
|
3801
|
+
css: menuItemTextGroup,
|
|
3802
|
+
onClick: () => onSelectVariable == null ? void 0 : onSelectVariable(variable),
|
|
3803
|
+
children: [
|
|
3804
|
+
/* @__PURE__ */ jsx32("span", { children: name }),
|
|
3805
|
+
helpText ? /* @__PURE__ */ jsx32("small", { css: smallText, children: helpText }) : null
|
|
3806
|
+
]
|
|
3807
|
+
},
|
|
3808
|
+
name
|
|
3809
|
+
);
|
|
3810
|
+
}) }, group.name);
|
|
3245
3811
|
}),
|
|
3246
|
-
showAddVariableMenuOption && canDispatch ? /* @__PURE__ */
|
|
3247
|
-
|
|
3248
|
-
/* @__PURE__ */
|
|
3249
|
-
|
|
3812
|
+
showAddVariableMenuOption && canDispatch ? /* @__PURE__ */ jsxs19(Fragment5, { children: [
|
|
3813
|
+
variablesGroups.length ? /* @__PURE__ */ jsx32(MenuItemSeparator2, {}) : null,
|
|
3814
|
+
/* @__PURE__ */ jsx32(
|
|
3815
|
+
MenuItem3,
|
|
3250
3816
|
{
|
|
3251
3817
|
onClick: () => {
|
|
3252
3818
|
setOpenedAdd(true);
|
|
3253
3819
|
dispatch({ type: "edit", variable: "" });
|
|
3254
3820
|
},
|
|
3255
|
-
children: "Add
|
|
3821
|
+
children: "Add\u2026"
|
|
3256
3822
|
}
|
|
3257
3823
|
)
|
|
3258
3824
|
] }) : null,
|
|
3259
|
-
menuHasVariableOptions && onResetVariables ? /* @__PURE__ */
|
|
3260
|
-
onResetVariables ? /* @__PURE__ */
|
|
3261
|
-
tip && (menuHasVariableOptions || onResetVariables) ? /* @__PURE__ */
|
|
3262
|
-
tip ? /* @__PURE__ */
|
|
3825
|
+
menuHasVariableOptions && onResetVariables ? /* @__PURE__ */ jsx32(MenuItemSeparator2, {}) : null,
|
|
3826
|
+
onResetVariables ? /* @__PURE__ */ jsx32(MenuItem3, { onClick: onResetVariables, css: { color: "var(--brand-secondary-5)" }, children: "Reset" }) : null,
|
|
3827
|
+
tip && (menuHasVariableOptions || onResetVariables) ? /* @__PURE__ */ jsx32(MenuItemSeparator2, {}) : null,
|
|
3828
|
+
tip ? /* @__PURE__ */ jsx32("i", { css: variablesTipText, children: tip }) : null
|
|
3263
3829
|
]
|
|
3264
3830
|
}
|
|
3265
3831
|
);
|
|
3266
3832
|
};
|
|
3267
3833
|
|
|
3268
|
-
// src/components/Variables/
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
const result = [];
|
|
3292
|
-
for (const match of value.matchAll(variableExpression)) {
|
|
3293
|
-
result.push(match[1]);
|
|
3294
|
-
}
|
|
3295
|
-
return result;
|
|
3296
|
-
}
|
|
3297
|
-
|
|
3298
|
-
// src/components/Variables/util/insertVariableIntoText.ts
|
|
3299
|
-
init_emotion_jsx_shim();
|
|
3300
|
-
function insertVariableIntoText({
|
|
3301
|
-
variableName: variableName2,
|
|
3302
|
-
value,
|
|
3303
|
-
selectionStart = null,
|
|
3304
|
-
selectionEnd = null
|
|
3305
|
-
}) {
|
|
3306
|
-
const variableExpression2 = `${variablePrefix}${variableName2}${variableSuffix}`;
|
|
3307
|
-
if (selectionStart !== null && selectionEnd !== null && selectionStart !== selectionEnd) {
|
|
3308
|
-
return `${value.substring(0, selectionStart)}${variableExpression2}${value.substring(selectionEnd)}`;
|
|
3309
|
-
}
|
|
3310
|
-
const hasCursorPosition = selectionStart !== null;
|
|
3311
|
-
let startOffset = 0;
|
|
3312
|
-
if (hasCursorPosition && value.substring(selectionStart - variablePrefix.length, selectionStart) === variablePrefix) {
|
|
3313
|
-
startOffset = variablePrefix.length;
|
|
3314
|
-
}
|
|
3315
|
-
if (hasCursorPosition) {
|
|
3316
|
-
return `${value.substring(0, selectionStart - startOffset)}${variableExpression2}${value.substring(
|
|
3317
|
-
selectionStart
|
|
3318
|
-
)}`;
|
|
3319
|
-
}
|
|
3320
|
-
return `${value}${variableExpression2}`;
|
|
3321
|
-
}
|
|
3322
|
-
|
|
3323
|
-
// src/components/Variables/VariableField.tsx
|
|
3324
|
-
init_emotion_jsx_shim();
|
|
3325
|
-
|
|
3326
|
-
// src/components/Variables/styles/VariableField.styles.ts
|
|
3327
|
-
init_emotion_jsx_shim();
|
|
3328
|
-
import { css as css21 } from "@emotion/react";
|
|
3329
|
-
var labelText = css21`
|
|
3330
|
-
align-items: center;
|
|
3331
|
-
display: flex;
|
|
3332
|
-
gap: var(--spacing-xs);
|
|
3333
|
-
font-weight: var(--fw-regular);
|
|
3334
|
-
margin: 0 0 var(--spacing-xs);
|
|
3335
|
-
`;
|
|
3336
|
-
var variableBindButton = css21`
|
|
3337
|
-
align-items: center;
|
|
3338
|
-
border: none;
|
|
3339
|
-
border-radius: var(--rounded-base);
|
|
3340
|
-
background: none;
|
|
3341
|
-
display: flex;
|
|
3342
|
-
height: 1.2rem;
|
|
3343
|
-
padding: var(--spacing-2xs);
|
|
3344
|
-
transition: background var(--duration-fast) var(--timing-ease-out),
|
|
3345
|
-
color var(--duration-fast) var(--timing-ease-out);
|
|
3346
|
-
width: 1.2rem;
|
|
3347
|
-
|
|
3348
|
-
&:hover,
|
|
3349
|
-
&[aria-pressed='true']:not(:disabled) {
|
|
3350
|
-
background: var(--brand-secondary-3);
|
|
3351
|
-
color: var(--white);
|
|
3352
|
-
}
|
|
3353
|
-
|
|
3354
|
-
&[aria-disabled='true'] {
|
|
3355
|
-
background: none;
|
|
3356
|
-
color: currentColor;
|
|
3357
|
-
}
|
|
3358
|
-
`;
|
|
3834
|
+
// src/components/Variables/VariablesComposerVariableMenu.tsx
|
|
3835
|
+
import { jsx as jsx33 } from "@emotion/react/jsx-runtime";
|
|
3836
|
+
var VariablesComposerVariableMenu = (props) => {
|
|
3837
|
+
const [editor] = useLexicalComposerContext3();
|
|
3838
|
+
const onSelectVariable = (selectedVariable) => {
|
|
3839
|
+
editor.dispatchCommand(INSERT_VARIABLE_COMMAND, {
|
|
3840
|
+
reference: selectedVariable.name
|
|
3841
|
+
});
|
|
3842
|
+
};
|
|
3843
|
+
const onResetVariable = () => {
|
|
3844
|
+
var _a;
|
|
3845
|
+
editor.dispatchCommand(CLEAR_EDITOR_COMMAND, void 0);
|
|
3846
|
+
(_a = props.onResetVariables) == null ? void 0 : _a.call(props);
|
|
3847
|
+
};
|
|
3848
|
+
return /* @__PURE__ */ jsx33(
|
|
3849
|
+
SelectVariableMenu,
|
|
3850
|
+
{
|
|
3851
|
+
...props,
|
|
3852
|
+
onSelectVariable,
|
|
3853
|
+
onResetVariables: props.onResetVariables ? onResetVariable : void 0
|
|
3854
|
+
}
|
|
3855
|
+
);
|
|
3856
|
+
};
|
|
3359
3857
|
|
|
3360
3858
|
// src/components/Variables/VariableField.tsx
|
|
3361
|
-
import { jsx as
|
|
3859
|
+
import { jsx as jsx34, jsxs as jsxs20 } from "@emotion/react/jsx-runtime";
|
|
3362
3860
|
function VariableField({
|
|
3363
3861
|
label,
|
|
3364
3862
|
selectVariableMenuOptions,
|
|
@@ -3369,25 +3867,194 @@ function VariableField({
|
|
|
3369
3867
|
}) {
|
|
3370
3868
|
const { variables } = useVariables(true);
|
|
3371
3869
|
const varCount = Object.keys(variables).length;
|
|
3372
|
-
const variableSelector = varCount > 0 &&
|
|
3373
|
-
|
|
3870
|
+
const variableSelector = varCount > 0 && !disableVariables ? /* @__PURE__ */ jsx34(
|
|
3871
|
+
VariablesComposerVariableMenu,
|
|
3374
3872
|
{
|
|
3375
3873
|
...selectVariableMenuOptions,
|
|
3376
3874
|
buttonCss: [variableBindButton, selectVariableMenuOptions == null ? void 0 : selectVariableMenuOptions.buttonCss],
|
|
3377
3875
|
buttonProps: isActive ? { "aria-pressed": "true" } : void 0
|
|
3378
3876
|
}
|
|
3379
3877
|
) : null;
|
|
3380
|
-
return /* @__PURE__ */
|
|
3381
|
-
/* @__PURE__ */
|
|
3878
|
+
return /* @__PURE__ */ jsxs20("div", { children: [
|
|
3879
|
+
/* @__PURE__ */ jsxs20("label", { htmlFor: id, css: labelText, children: [
|
|
3382
3880
|
variableSelector,
|
|
3383
|
-
/* @__PURE__ */
|
|
3881
|
+
/* @__PURE__ */ jsx34("span", { children: label })
|
|
3384
3882
|
] }),
|
|
3385
3883
|
children
|
|
3386
3884
|
] });
|
|
3387
3885
|
}
|
|
3388
3886
|
|
|
3887
|
+
// src/components/Variables/VariablesComposer.tsx
|
|
3888
|
+
init_emotion_jsx_shim();
|
|
3889
|
+
import { ClearEditorPlugin } from "@lexical/react/LexicalClearEditorPlugin";
|
|
3890
|
+
import { LexicalComposer } from "@lexical/react/LexicalComposer";
|
|
3891
|
+
import { ContentEditable } from "@lexical/react/LexicalContentEditable";
|
|
3892
|
+
import LexicalErrorBoundary from "@lexical/react/LexicalErrorBoundary";
|
|
3893
|
+
import { OnChangePlugin } from "@lexical/react/LexicalOnChangePlugin";
|
|
3894
|
+
import { PlainTextPlugin } from "@lexical/react/LexicalPlainTextPlugin";
|
|
3895
|
+
import {
|
|
3896
|
+
LineBreakNode as LineBreakNode2,
|
|
3897
|
+
TextNode as TextNode2
|
|
3898
|
+
} from "lexical";
|
|
3899
|
+
import { useMemo as useMemo7, useRef as useRef9, useState as useState10 } from "react";
|
|
3900
|
+
import { v4 as v42 } from "uuid";
|
|
3901
|
+
|
|
3902
|
+
// src/components/Variables/composer/DisablePlugin.tsx
|
|
3903
|
+
init_emotion_jsx_shim();
|
|
3904
|
+
import { useLexicalComposerContext as useLexicalComposerContext4 } from "@lexical/react/LexicalComposerContext";
|
|
3905
|
+
import { useEffect as useEffect9 } from "react";
|
|
3906
|
+
function DisablePlugin({ disabled }) {
|
|
3907
|
+
const [editor] = useLexicalComposerContext4();
|
|
3908
|
+
useEffect9(() => {
|
|
3909
|
+
editor.setEditable(!disabled);
|
|
3910
|
+
}, [editor, disabled]);
|
|
3911
|
+
return null;
|
|
3912
|
+
}
|
|
3913
|
+
|
|
3914
|
+
// src/components/Variables/composer/SingleLineTextPlugin.tsx
|
|
3915
|
+
init_emotion_jsx_shim();
|
|
3916
|
+
import { useLexicalComposerContext as useLexicalComposerContext5 } from "@lexical/react/LexicalComposerContext";
|
|
3917
|
+
import { LineBreakNode } from "lexical";
|
|
3918
|
+
import { useEffect as useEffect10 } from "react";
|
|
3919
|
+
function SingleLineTextPlugin() {
|
|
3920
|
+
const [editor] = useLexicalComposerContext5();
|
|
3921
|
+
useEffect10(() => {
|
|
3922
|
+
editor.registerNodeTransform(LineBreakNode, (node) => {
|
|
3923
|
+
node.remove();
|
|
3924
|
+
});
|
|
3925
|
+
}, [editor]);
|
|
3926
|
+
return null;
|
|
3927
|
+
}
|
|
3928
|
+
|
|
3929
|
+
// src/components/Variables/VariablesComposer.tsx
|
|
3930
|
+
import { Fragment as Fragment6, jsx as jsx35, jsxs as jsxs21 } from "@emotion/react/jsx-runtime";
|
|
3931
|
+
function VariablesComposer(props) {
|
|
3932
|
+
const { value, children, onChange, disabled, disableVariables, ...variablesPluginProps } = props;
|
|
3933
|
+
const [namespace] = useState10(v42());
|
|
3934
|
+
const [lastEmittedValue, setLastEmittedValue] = useState10(value);
|
|
3935
|
+
const editorConfig = useMemo7(
|
|
3936
|
+
() => ({
|
|
3937
|
+
namespace,
|
|
3938
|
+
onError(error) {
|
|
3939
|
+
throw error;
|
|
3940
|
+
},
|
|
3941
|
+
nodes: [VariableNode],
|
|
3942
|
+
editorState: deserializeEditorState(props.value)
|
|
3943
|
+
}),
|
|
3944
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3945
|
+
[namespace]
|
|
3946
|
+
);
|
|
3947
|
+
const editorState = useRef9();
|
|
3948
|
+
const updateTimeout = useRef9();
|
|
3949
|
+
if (typeof document === "undefined")
|
|
3950
|
+
return null;
|
|
3951
|
+
return /* @__PURE__ */ jsxs21(LexicalComposer, { initialConfig: editorConfig, children: [
|
|
3952
|
+
/* @__PURE__ */ jsx35(
|
|
3953
|
+
OnChangePlugin,
|
|
3954
|
+
{
|
|
3955
|
+
onChange: (state) => {
|
|
3956
|
+
editorState.current = state;
|
|
3957
|
+
if (updateTimeout.current) {
|
|
3958
|
+
clearTimeout(updateTimeout.current);
|
|
3959
|
+
}
|
|
3960
|
+
setTimeout(() => {
|
|
3961
|
+
if (editorState.current) {
|
|
3962
|
+
const valueToEmit = serializeEditorState(editorState.current);
|
|
3963
|
+
if (valueToEmit !== lastEmittedValue) {
|
|
3964
|
+
setLastEmittedValue(valueToEmit);
|
|
3965
|
+
onChange(valueToEmit);
|
|
3966
|
+
}
|
|
3967
|
+
}
|
|
3968
|
+
}, 400);
|
|
3969
|
+
}
|
|
3970
|
+
}
|
|
3971
|
+
),
|
|
3972
|
+
/* @__PURE__ */ jsx35(SingleLineTextPlugin, {}),
|
|
3973
|
+
/* @__PURE__ */ jsx35(ClearEditorPlugin, {}),
|
|
3974
|
+
/* @__PURE__ */ jsx35(VariablesPlugin, { ...variablesPluginProps }),
|
|
3975
|
+
/* @__PURE__ */ jsx35(DisablePlugin, { disabled }),
|
|
3976
|
+
/* @__PURE__ */ jsx35(Fragment6, { children })
|
|
3977
|
+
] });
|
|
3978
|
+
}
|
|
3979
|
+
function VariablesComposerInput(props) {
|
|
3980
|
+
return /* @__PURE__ */ jsx35("div", { children: /* @__PURE__ */ jsx35(
|
|
3981
|
+
PlainTextPlugin,
|
|
3982
|
+
{
|
|
3983
|
+
contentEditable: /* @__PURE__ */ jsx35(ContentEditable, { css: input, ...props }),
|
|
3984
|
+
placeholder: null,
|
|
3985
|
+
ErrorBoundary: LexicalErrorBoundary
|
|
3986
|
+
}
|
|
3987
|
+
) });
|
|
3988
|
+
}
|
|
3989
|
+
function deserializeEditorState(serialized) {
|
|
3990
|
+
const result = [];
|
|
3991
|
+
parseVariableExpression(serialized, (token, type) => {
|
|
3992
|
+
if (type === "text") {
|
|
3993
|
+
const node = {
|
|
3994
|
+
type: TextNode2.getType(),
|
|
3995
|
+
text: token,
|
|
3996
|
+
mode: "normal",
|
|
3997
|
+
version: 1,
|
|
3998
|
+
detail: 0,
|
|
3999
|
+
format: 0,
|
|
4000
|
+
style: ""
|
|
4001
|
+
};
|
|
4002
|
+
result.push(node);
|
|
4003
|
+
}
|
|
4004
|
+
if (type === "variable") {
|
|
4005
|
+
const node = {
|
|
4006
|
+
type: "variable",
|
|
4007
|
+
reference: token,
|
|
4008
|
+
version: 1
|
|
4009
|
+
};
|
|
4010
|
+
result.push(node);
|
|
4011
|
+
}
|
|
4012
|
+
});
|
|
4013
|
+
const rez = JSON.stringify({
|
|
4014
|
+
root: {
|
|
4015
|
+
children: [
|
|
4016
|
+
{
|
|
4017
|
+
children: result,
|
|
4018
|
+
direction: "ltr",
|
|
4019
|
+
format: "",
|
|
4020
|
+
indent: 0,
|
|
4021
|
+
type: "paragraph",
|
|
4022
|
+
version: 1
|
|
4023
|
+
}
|
|
4024
|
+
],
|
|
4025
|
+
direction: "ltr",
|
|
4026
|
+
format: "",
|
|
4027
|
+
indent: 0,
|
|
4028
|
+
type: "root",
|
|
4029
|
+
version: 1
|
|
4030
|
+
}
|
|
4031
|
+
});
|
|
4032
|
+
return rez;
|
|
4033
|
+
}
|
|
4034
|
+
function serializeEditorState(editorState) {
|
|
4035
|
+
const buf = [];
|
|
4036
|
+
serializeRecursive(editorState.toJSON().root, buf);
|
|
4037
|
+
return buf.join("");
|
|
4038
|
+
}
|
|
4039
|
+
function serializeRecursive(node, buffer) {
|
|
4040
|
+
if (node.type === TextNode2.getType()) {
|
|
4041
|
+
buffer.push(node.text);
|
|
4042
|
+
}
|
|
4043
|
+
if (node.type === VariableNode.getType()) {
|
|
4044
|
+
buffer.push(`\${${node.reference}}`);
|
|
4045
|
+
}
|
|
4046
|
+
if (node.type === LineBreakNode2.getType()) {
|
|
4047
|
+
buffer.push("\n");
|
|
4048
|
+
}
|
|
4049
|
+
if ("children" in node && node.children) {
|
|
4050
|
+
for (const child of node.children) {
|
|
4051
|
+
serializeRecursive(child, buffer);
|
|
4052
|
+
}
|
|
4053
|
+
}
|
|
4054
|
+
}
|
|
4055
|
+
|
|
3389
4056
|
// src/components/Variables/InputVariables.tsx
|
|
3390
|
-
import { Fragment as
|
|
4057
|
+
import { Fragment as Fragment7, jsx as jsx36, jsxs as jsxs22 } from "@emotion/react/jsx-runtime";
|
|
3391
4058
|
function InputVariables({
|
|
3392
4059
|
id,
|
|
3393
4060
|
"aria-label": ariaLabel,
|
|
@@ -3395,38 +4062,20 @@ function InputVariables({
|
|
|
3395
4062
|
value,
|
|
3396
4063
|
disableVariables,
|
|
3397
4064
|
disableReset,
|
|
4065
|
+
enableEditingVariables,
|
|
3398
4066
|
disableInlineMenu,
|
|
3399
4067
|
onChange,
|
|
3400
|
-
|
|
4068
|
+
transformPaste,
|
|
3401
4069
|
showAddVariableMenuOption,
|
|
3402
4070
|
inputWhenNoVariables,
|
|
3403
4071
|
caption,
|
|
3404
4072
|
errorMessage,
|
|
3405
4073
|
warningMessage,
|
|
3406
4074
|
infoMessage,
|
|
3407
|
-
|
|
4075
|
+
"data-test-id": dataTestId
|
|
3408
4076
|
}) {
|
|
3409
|
-
var _a, _b;
|
|
3410
4077
|
const { variables } = useVariables(true);
|
|
3411
|
-
const
|
|
3412
|
-
const [finalId] = React11.useState(id != null ? id : () => v42());
|
|
3413
|
-
const onPasteHandler = (e) => {
|
|
3414
|
-
var _a2, _b2, _c;
|
|
3415
|
-
if (!onPaste) {
|
|
3416
|
-
return;
|
|
3417
|
-
}
|
|
3418
|
-
const pastedValue = (_a2 = e.clipboardData) == null ? void 0 : _a2.getData("text/plain");
|
|
3419
|
-
if (!pastedValue || !e.currentTarget) {
|
|
3420
|
-
return;
|
|
3421
|
-
}
|
|
3422
|
-
const selectionStart = (_b2 = e.currentTarget.selectionStart) != null ? _b2 : 0;
|
|
3423
|
-
const selectionEnd = (_c = e.currentTarget.selectionEnd) != null ? _c : 0;
|
|
3424
|
-
const newValue = e.currentTarget.value.substring(0, selectionStart) + pastedValue + e.currentTarget.value.substring(selectionEnd);
|
|
3425
|
-
onPaste(newValue);
|
|
3426
|
-
e.preventDefault();
|
|
3427
|
-
};
|
|
3428
|
-
const currentCursor = (_b = (_a = inputRef.current) == null ? void 0 : _a.selectionStart) != null ? _b : value.length;
|
|
3429
|
-
const forceMenu = value.substring(currentCursor - 2, currentCursor) === variablePrefix;
|
|
4078
|
+
const [finalId] = React11.useState(id != null ? id : () => v43());
|
|
3430
4079
|
const hasVariablesInValue = getReferencedVariables(value).length > 0;
|
|
3431
4080
|
const [hadVariablesInValue, setHadVariablesInValue] = React11.useState(hasVariablesInValue);
|
|
3432
4081
|
React11.useEffect(() => {
|
|
@@ -3436,58 +4085,33 @@ function InputVariables({
|
|
|
3436
4085
|
}, [hasVariablesInValue]);
|
|
3437
4086
|
const disableVariablesForReals = disableVariables || Object.keys(variables).length === 0 && !showAddVariableMenuOption;
|
|
3438
4087
|
const disableInlineVariablesForReals = disableVariablesForReals || disableInlineMenu;
|
|
3439
|
-
const
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
const handleSetValue = (rawValue) => {
|
|
3452
|
-
onChange(rawValue);
|
|
3453
|
-
};
|
|
3454
|
-
const sharedMenuProps = {
|
|
3455
|
-
onSelectVariable: handleInsertVariable,
|
|
3456
|
-
showAddVariableMenuOption,
|
|
3457
|
-
onResetVariables: hadVariablesInValue && !disableReset ? () => {
|
|
3458
|
-
handleSetValue("");
|
|
3459
|
-
setHadVariablesInValue(false);
|
|
3460
|
-
} : void 0
|
|
3461
|
-
};
|
|
3462
|
-
const input = /* @__PURE__ */ jsxs20("div", { children: [
|
|
3463
|
-
inputWhenNoVariables && !hadVariablesInValue ? inputWhenNoVariables : /* @__PURE__ */ jsx32(
|
|
3464
|
-
InputVariablesShell,
|
|
4088
|
+
const sharedMenuProps = useMemo8(
|
|
4089
|
+
() => ({
|
|
4090
|
+
showAddVariableMenuOption,
|
|
4091
|
+
onResetVariables: disableReset ? void 0 : () => {
|
|
4092
|
+
setHadVariablesInValue(false);
|
|
4093
|
+
}
|
|
4094
|
+
}),
|
|
4095
|
+
[disableReset, showAddVariableMenuOption]
|
|
4096
|
+
);
|
|
4097
|
+
const input2 = /* @__PURE__ */ jsxs22("div", { children: [
|
|
4098
|
+
inputWhenNoVariables && !hadVariablesInValue ? inputWhenNoVariables : /* @__PURE__ */ jsx36(InputVariablesMenu, { ...sharedMenuProps, disabled: disableInlineVariablesForReals, children: /* @__PURE__ */ jsx36(
|
|
4099
|
+
VariablesComposerInput,
|
|
3465
4100
|
{
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
Input3,
|
|
3471
|
-
{
|
|
3472
|
-
id: finalId,
|
|
3473
|
-
ref: inputRef,
|
|
3474
|
-
label: ariaLabel,
|
|
3475
|
-
showLabel: false,
|
|
3476
|
-
value,
|
|
3477
|
-
onChange: (e) => handleSetValue(e.currentTarget.value),
|
|
3478
|
-
onPaste: onPasteHandler,
|
|
3479
|
-
...inputProps
|
|
3480
|
-
}
|
|
3481
|
-
)
|
|
4101
|
+
id: finalId,
|
|
4102
|
+
"aria-label": ariaLabel,
|
|
4103
|
+
"data-testid": dataTestId,
|
|
4104
|
+
"data-text-value": value
|
|
3482
4105
|
}
|
|
3483
|
-
),
|
|
3484
|
-
caption ? /* @__PURE__ */
|
|
3485
|
-
errorMessage ? /* @__PURE__ */
|
|
3486
|
-
warningMessage ? /* @__PURE__ */
|
|
3487
|
-
infoMessage ? /* @__PURE__ */
|
|
4106
|
+
) }),
|
|
4107
|
+
caption ? /* @__PURE__ */ jsx36(Caption, { children: caption }) : null,
|
|
4108
|
+
errorMessage ? /* @__PURE__ */ jsx36(ErrorMessage, { message: errorMessage }) : null,
|
|
4109
|
+
warningMessage ? /* @__PURE__ */ jsx36(WarningMessage, { message: warningMessage }) : null,
|
|
4110
|
+
infoMessage ? /* @__PURE__ */ jsx36(InfoMessage, { message: infoMessage }) : null
|
|
3488
4111
|
] });
|
|
4112
|
+
let body = input2;
|
|
3489
4113
|
if (label) {
|
|
3490
|
-
|
|
4114
|
+
body = /* @__PURE__ */ jsx36(
|
|
3491
4115
|
VariableField,
|
|
3492
4116
|
{
|
|
3493
4117
|
label,
|
|
@@ -3495,29 +4119,49 @@ function InputVariables({
|
|
|
3495
4119
|
id: finalId,
|
|
3496
4120
|
isActive: hadVariablesInValue,
|
|
3497
4121
|
disableVariables: disableVariablesForReals,
|
|
3498
|
-
children:
|
|
4122
|
+
children: input2
|
|
3499
4123
|
}
|
|
3500
4124
|
);
|
|
3501
4125
|
}
|
|
3502
|
-
return
|
|
4126
|
+
return /* @__PURE__ */ jsxs22(
|
|
4127
|
+
VariablesComposer,
|
|
4128
|
+
{
|
|
4129
|
+
onChange,
|
|
4130
|
+
value,
|
|
4131
|
+
disableVariables: disableVariablesForReals,
|
|
4132
|
+
showAddVariableMenuOption,
|
|
4133
|
+
enableEditingVariables,
|
|
4134
|
+
children: [
|
|
4135
|
+
/* @__PURE__ */ jsx36(PasteTransformerPlugin, { transformPaste }),
|
|
4136
|
+
body
|
|
4137
|
+
]
|
|
4138
|
+
}
|
|
4139
|
+
);
|
|
3503
4140
|
}
|
|
3504
|
-
function
|
|
4141
|
+
function InputVariablesMenu({
|
|
3505
4142
|
children,
|
|
3506
4143
|
disabled,
|
|
3507
4144
|
...props
|
|
3508
4145
|
}) {
|
|
3509
4146
|
if (disabled) {
|
|
3510
|
-
return /* @__PURE__ */
|
|
4147
|
+
return /* @__PURE__ */ jsx36(Fragment7, { children });
|
|
3511
4148
|
}
|
|
3512
|
-
return /* @__PURE__ */
|
|
4149
|
+
return /* @__PURE__ */ jsxs22("div", { css: menuContainer, children: [
|
|
3513
4150
|
children,
|
|
3514
|
-
/* @__PURE__ */
|
|
4151
|
+
/* @__PURE__ */ jsx36(
|
|
4152
|
+
VariablesComposerVariableMenu,
|
|
4153
|
+
{
|
|
4154
|
+
...props,
|
|
4155
|
+
tip: "Tip: access this list by typing $",
|
|
4156
|
+
buttonCss: menuBtn
|
|
4157
|
+
}
|
|
4158
|
+
)
|
|
3515
4159
|
] });
|
|
3516
4160
|
}
|
|
3517
4161
|
|
|
3518
4162
|
// src/components/Variables/VariablesList.tsx
|
|
3519
4163
|
init_emotion_jsx_shim();
|
|
3520
|
-
import { css as
|
|
4164
|
+
import { css as css24 } from "@emotion/react";
|
|
3521
4165
|
import {
|
|
3522
4166
|
AddListButton,
|
|
3523
4167
|
button,
|
|
@@ -3533,8 +4177,8 @@ import { DragDropContext as DragDropContext2, Draggable as Draggable2, Droppable
|
|
|
3533
4177
|
|
|
3534
4178
|
// src/components/Variables/styles/VariablesList.styles.ts
|
|
3535
4179
|
init_emotion_jsx_shim();
|
|
3536
|
-
import { css as
|
|
3537
|
-
var tableRow = (isDragging) =>
|
|
4180
|
+
import { css as css23 } from "@emotion/react";
|
|
4181
|
+
var tableRow = (isDragging) => css23`
|
|
3538
4182
|
position: relative;
|
|
3539
4183
|
${isDragging ? `
|
|
3540
4184
|
display: table;
|
|
@@ -3542,7 +4186,7 @@ var tableRow = (isDragging) => css22`
|
|
|
3542
4186
|
top: auto !important;
|
|
3543
4187
|
` : void 0}
|
|
3544
4188
|
`;
|
|
3545
|
-
var tableCellDragIcon =
|
|
4189
|
+
var tableCellDragIcon = css23`
|
|
3546
4190
|
&::after {
|
|
3547
4191
|
content: '';
|
|
3548
4192
|
display: block;
|
|
@@ -3560,7 +4204,7 @@ var tableCellDragIcon = css22`
|
|
|
3560
4204
|
opacity: 1;
|
|
3561
4205
|
}
|
|
3562
4206
|
`;
|
|
3563
|
-
var variableName =
|
|
4207
|
+
var variableName = css23`
|
|
3564
4208
|
border: none;
|
|
3565
4209
|
color: var(--brand-secondary-5);
|
|
3566
4210
|
font-weight: var(--fw-medium);
|
|
@@ -3571,7 +4215,7 @@ var variableName = css22`
|
|
|
3571
4215
|
white-space: nowrap;
|
|
3572
4216
|
max-width: 20ch;
|
|
3573
4217
|
`;
|
|
3574
|
-
var variableValue =
|
|
4218
|
+
var variableValue = css23`
|
|
3575
4219
|
overflow: hidden;
|
|
3576
4220
|
text-overflow: ellipsis;
|
|
3577
4221
|
white-space: nowrap;
|
|
@@ -3579,7 +4223,7 @@ var variableValue = css22`
|
|
|
3579
4223
|
`;
|
|
3580
4224
|
|
|
3581
4225
|
// src/components/Variables/VariablesList.tsx
|
|
3582
|
-
import { Fragment as
|
|
4226
|
+
import { Fragment as Fragment8, jsx as jsx37, jsxs as jsxs23 } from "@emotion/react/jsx-runtime";
|
|
3583
4227
|
function VariablesList() {
|
|
3584
4228
|
const { variables, dispatch } = useVariables();
|
|
3585
4229
|
const sorted = variablesToList(variables);
|
|
@@ -3600,23 +4244,23 @@ function VariablesList() {
|
|
|
3600
4244
|
return result;
|
|
3601
4245
|
}
|
|
3602
4246
|
};
|
|
3603
|
-
return /* @__PURE__ */
|
|
3604
|
-
/* @__PURE__ */
|
|
3605
|
-
/* @__PURE__ */
|
|
3606
|
-
/* @__PURE__ */
|
|
3607
|
-
/* @__PURE__ */
|
|
3608
|
-
/* @__PURE__ */
|
|
4247
|
+
return /* @__PURE__ */ jsxs23(Fragment8, { children: [
|
|
4248
|
+
/* @__PURE__ */ jsx37(DragDropContext2, { onDragEnd: (res) => onDragEnd(res), children: /* @__PURE__ */ jsx37(Droppable2, { droppableId: "variables-table", children: (provided) => /* @__PURE__ */ jsxs23(Table, { ...provided.droppableProps, ref: provided.innerRef, children: [
|
|
4249
|
+
/* @__PURE__ */ jsx37(TableHead, { children: /* @__PURE__ */ jsxs23(TableRow, { children: [
|
|
4250
|
+
/* @__PURE__ */ jsx37(TableCellHead, { children: "Name" }),
|
|
4251
|
+
/* @__PURE__ */ jsx37(TableCellHead, { children: "Default Value" }),
|
|
4252
|
+
/* @__PURE__ */ jsx37(TableCellHead, {})
|
|
3609
4253
|
] }) }),
|
|
3610
|
-
/* @__PURE__ */
|
|
4254
|
+
/* @__PURE__ */ jsxs23(TableBody, { children: [
|
|
3611
4255
|
sorted.map(({ name, displayName, default: defaultValue }, index) => {
|
|
3612
4256
|
const text = displayName != null ? displayName : name;
|
|
3613
|
-
return /* @__PURE__ */
|
|
4257
|
+
return /* @__PURE__ */ jsx37(
|
|
3614
4258
|
Draggable2,
|
|
3615
4259
|
{
|
|
3616
4260
|
draggableId: name,
|
|
3617
4261
|
index,
|
|
3618
4262
|
isDragDisabled: sorted.length === 1,
|
|
3619
|
-
children: (provided2, snapshot) => /* @__PURE__ */
|
|
4263
|
+
children: (provided2, snapshot) => /* @__PURE__ */ jsxs23(
|
|
3620
4264
|
TableRow,
|
|
3621
4265
|
{
|
|
3622
4266
|
ref: provided2.innerRef,
|
|
@@ -3626,7 +4270,7 @@ function VariablesList() {
|
|
|
3626
4270
|
css: tableRow(snapshot.isDragging),
|
|
3627
4271
|
"data-dragging": snapshot.isDragging,
|
|
3628
4272
|
children: [
|
|
3629
|
-
/* @__PURE__ */
|
|
4273
|
+
/* @__PURE__ */ jsx37(TableCellData, { css: sorted.length > 1 ? tableCellDragIcon : void 0, children: /* @__PURE__ */ jsx37(
|
|
3630
4274
|
"button",
|
|
3631
4275
|
{
|
|
3632
4276
|
css: variableName,
|
|
@@ -3639,21 +4283,21 @@ function VariablesList() {
|
|
|
3639
4283
|
children: text
|
|
3640
4284
|
}
|
|
3641
4285
|
) }),
|
|
3642
|
-
/* @__PURE__ */
|
|
3643
|
-
/* @__PURE__ */
|
|
4286
|
+
/* @__PURE__ */ jsx37(TableCellData, { children: /* @__PURE__ */ jsx37("span", { css: variableValue, title: defaultValue, children: defaultValue }) }),
|
|
4287
|
+
/* @__PURE__ */ jsx37(TableCellData, { align: "right", children: /* @__PURE__ */ jsx37(
|
|
3644
4288
|
"button",
|
|
3645
4289
|
{
|
|
3646
4290
|
type: "button",
|
|
3647
4291
|
title: `delete ${text}`,
|
|
3648
4292
|
css: [
|
|
3649
4293
|
button,
|
|
3650
|
-
|
|
4294
|
+
css24`
|
|
3651
4295
|
background: transparent;
|
|
3652
4296
|
`
|
|
3653
4297
|
],
|
|
3654
4298
|
"aria-controls": text,
|
|
3655
4299
|
onClick: () => dispatch({ type: "remove", variable: name }),
|
|
3656
|
-
children: /* @__PURE__ */
|
|
4300
|
+
children: /* @__PURE__ */ jsx37(Icon5, { icon: "trash", iconColor: "red" })
|
|
3657
4301
|
}
|
|
3658
4302
|
) })
|
|
3659
4303
|
]
|
|
@@ -3666,7 +4310,7 @@ function VariablesList() {
|
|
|
3666
4310
|
provided.placeholder
|
|
3667
4311
|
] })
|
|
3668
4312
|
] }) }) }),
|
|
3669
|
-
/* @__PURE__ */
|
|
4313
|
+
/* @__PURE__ */ jsx37(
|
|
3670
4314
|
AddListButton,
|
|
3671
4315
|
{
|
|
3672
4316
|
onButtonClick: () => dispatch({ type: "edit", variable: "" }),
|
|
@@ -3680,49 +4324,36 @@ function VariablesList() {
|
|
|
3680
4324
|
}
|
|
3681
4325
|
|
|
3682
4326
|
// src/components/DataResourceDynamicInputProvider.tsx
|
|
3683
|
-
import { Fragment as
|
|
4327
|
+
import { Fragment as Fragment9, jsx as jsx38 } from "@emotion/react/jsx-runtime";
|
|
3684
4328
|
function DataResourceDynamicInputProvider({
|
|
3685
4329
|
children,
|
|
3686
4330
|
dynamicInputs
|
|
3687
4331
|
}) {
|
|
3688
4332
|
if (dynamicInputs) {
|
|
3689
|
-
return /* @__PURE__ */
|
|
4333
|
+
return /* @__PURE__ */ jsx38(DataResourceDynamicInputProviderRenderer, { dynamicInputs, children });
|
|
3690
4334
|
}
|
|
3691
|
-
return /* @__PURE__ */
|
|
4335
|
+
return /* @__PURE__ */ jsx38(DataResourceDynamicInputProviderContextShim, { children });
|
|
3692
4336
|
}
|
|
3693
4337
|
function DataResourceDynamicInputProviderContextShim(props) {
|
|
3694
4338
|
const {
|
|
3695
4339
|
metadata: { dynamicInputs }
|
|
3696
4340
|
} = useMeshLocation("dataResource");
|
|
3697
|
-
return /* @__PURE__ */
|
|
4341
|
+
return /* @__PURE__ */ jsx38(DataResourceDynamicInputProviderRenderer, { ...props, dynamicInputs });
|
|
3698
4342
|
}
|
|
3699
4343
|
function DataResourceDynamicInputProviderRenderer({
|
|
3700
4344
|
children,
|
|
3701
4345
|
dynamicInputs
|
|
3702
4346
|
}) {
|
|
3703
|
-
return /* @__PURE__ */
|
|
3704
|
-
VariablesProvider,
|
|
3705
|
-
{
|
|
3706
|
-
value: convertDynamicInputsToVariables(dynamicInputs),
|
|
3707
|
-
onChange: () => {
|
|
3708
|
-
throw new Error("Cannot change dynamic inputs. Make sure that add variable is disabled.");
|
|
3709
|
-
},
|
|
3710
|
-
editVariableComponent: () => /* @__PURE__ */ jsx34("span", { children: "Cannot edit dynamic inputs." }),
|
|
3711
|
-
children
|
|
3712
|
-
}
|
|
3713
|
-
);
|
|
4347
|
+
return /* @__PURE__ */ jsx38(VariablesProvider, { value: convertDynamicInputsToVariables(dynamicInputs), readOnly: true, children });
|
|
3714
4348
|
}
|
|
3715
4349
|
function convertDynamicInputsToVariables(dynamicInputs) {
|
|
3716
4350
|
return Object.entries(dynamicInputs).reduce(
|
|
3717
|
-
(acc, [name,
|
|
4351
|
+
(acc, [name, input2]) => {
|
|
3718
4352
|
acc[name] = {
|
|
3719
|
-
type:
|
|
3720
|
-
default:
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
", from ",
|
|
3724
|
-
input.type === "path" ? "URL path" : "query string"
|
|
3725
|
-
] })
|
|
4353
|
+
type: input2.type,
|
|
4354
|
+
default: input2.value,
|
|
4355
|
+
source: `from ${input2.type === "path" ? "URL path" : "query string"}`,
|
|
4356
|
+
helpText: /* @__PURE__ */ jsx38(Fragment9, { children: input2.value || /* @__PURE__ */ jsx38("em", { children: "not provided" }) })
|
|
3726
4357
|
// type abuse! 💚
|
|
3727
4358
|
};
|
|
3728
4359
|
return acc;
|
|
@@ -3734,13 +4365,13 @@ function convertDynamicInputsToVariables(dynamicInputs) {
|
|
|
3734
4365
|
// src/components/DataResourceVariablesList.tsx
|
|
3735
4366
|
init_emotion_jsx_shim();
|
|
3736
4367
|
import { Callout as Callout4 } from "@uniformdev/design-system";
|
|
3737
|
-
import { jsx as
|
|
4368
|
+
import { jsx as jsx39 } from "@emotion/react/jsx-runtime";
|
|
3738
4369
|
function DataResourceVariablesList(props) {
|
|
3739
4370
|
const {
|
|
3740
4371
|
value,
|
|
3741
4372
|
metadata: { dataType, dynamicInputs }
|
|
3742
4373
|
} = useMeshLocation("dataResource");
|
|
3743
|
-
return /* @__PURE__ */
|
|
4374
|
+
return /* @__PURE__ */ jsx39(
|
|
3744
4375
|
DataResourceVariablesListExplicit,
|
|
3745
4376
|
{
|
|
3746
4377
|
...props,
|
|
@@ -3761,14 +4392,14 @@ function DataResourceVariablesListExplicit({
|
|
|
3761
4392
|
const variableDefinitions = variablesToList(dataType.variables);
|
|
3762
4393
|
if (variableDefinitions.length === 0) {
|
|
3763
4394
|
if (NoVariablesComponent) {
|
|
3764
|
-
return /* @__PURE__ */
|
|
4395
|
+
return /* @__PURE__ */ jsx39(NoVariablesComponent, {});
|
|
3765
4396
|
}
|
|
3766
|
-
return /* @__PURE__ */
|
|
4397
|
+
return /* @__PURE__ */ jsx39(Callout4, { type: "note", children: "No settings are required." });
|
|
3767
4398
|
}
|
|
3768
|
-
return /* @__PURE__ */
|
|
4399
|
+
return /* @__PURE__ */ jsx39(DataResourceDynamicInputProvider, { dynamicInputs, children: /* @__PURE__ */ jsx39("div", { children: variableDefinitions.map((variableDefinition) => {
|
|
3769
4400
|
var _a, _b, _c;
|
|
3770
4401
|
const VariableRenderer = variableDefinition.type ? (_a = typeRenderers == null ? void 0 : typeRenderers[variableDefinition.type]) != null ? _a : TextVariableRenderer : TextVariableRenderer;
|
|
3771
|
-
return /* @__PURE__ */
|
|
4402
|
+
return /* @__PURE__ */ jsx39("div", { children: /* @__PURE__ */ jsx39(
|
|
3772
4403
|
VariableRenderer,
|
|
3773
4404
|
{
|
|
3774
4405
|
definition: variableDefinition,
|
|
@@ -3791,7 +4422,7 @@ function DataResourceVariablesListExplicit({
|
|
|
3791
4422
|
}
|
|
3792
4423
|
function TextVariableRenderer({ definition, value, setValue }) {
|
|
3793
4424
|
var _a;
|
|
3794
|
-
return /* @__PURE__ */
|
|
4425
|
+
return /* @__PURE__ */ jsx39("div", { children: /* @__PURE__ */ jsx39(
|
|
3795
4426
|
InputVariables,
|
|
3796
4427
|
{
|
|
3797
4428
|
label: definition.displayName || definition.name,
|
|
@@ -3807,14 +4438,14 @@ init_emotion_jsx_shim();
|
|
|
3807
4438
|
|
|
3808
4439
|
// src/components/Request/RequestBody.tsx
|
|
3809
4440
|
init_emotion_jsx_shim();
|
|
3810
|
-
import { css as
|
|
4441
|
+
import { css as css26 } from "@emotion/react";
|
|
3811
4442
|
import { InputSelect as InputSelect4, JsonEditor } from "@uniformdev/design-system";
|
|
3812
|
-
import { useState as
|
|
4443
|
+
import { useState as useState12 } from "react";
|
|
3813
4444
|
|
|
3814
4445
|
// src/components/Request/RequestProvider.tsx
|
|
3815
4446
|
init_emotion_jsx_shim();
|
|
3816
4447
|
import * as React12 from "react";
|
|
3817
|
-
import { jsx as
|
|
4448
|
+
import { jsx as jsx40 } from "@emotion/react/jsx-runtime";
|
|
3818
4449
|
var RequestContext = React12.createContext(null);
|
|
3819
4450
|
function RequestProvider({ value, onChange, children }) {
|
|
3820
4451
|
const contextValue = React12.useMemo(() => {
|
|
@@ -3883,7 +4514,7 @@ function RequestProvider({ value, onChange, children }) {
|
|
|
3883
4514
|
request: value
|
|
3884
4515
|
};
|
|
3885
4516
|
}, [onChange, value]);
|
|
3886
|
-
return /* @__PURE__ */
|
|
4517
|
+
return /* @__PURE__ */ jsx40(RequestContext.Provider, { value: contextValue, children });
|
|
3887
4518
|
}
|
|
3888
4519
|
function useRequest() {
|
|
3889
4520
|
const context = React12.useContext(RequestContext);
|
|
@@ -3898,11 +4529,11 @@ init_emotion_jsx_shim();
|
|
|
3898
4529
|
|
|
3899
4530
|
// src/components/Request/styles/Request.styles.ts
|
|
3900
4531
|
init_emotion_jsx_shim();
|
|
3901
|
-
import { css as
|
|
3902
|
-
var innerContentStyles =
|
|
4532
|
+
import { css as css25 } from "@emotion/react";
|
|
4533
|
+
var innerContentStyles = css25`
|
|
3903
4534
|
background: var(--white);
|
|
3904
4535
|
`;
|
|
3905
|
-
var requestTypeContainer = (bgColor) =>
|
|
4536
|
+
var requestTypeContainer = (bgColor) => css25`
|
|
3906
4537
|
align-items: start;
|
|
3907
4538
|
background: ${bgColor};
|
|
3908
4539
|
display: grid;
|
|
@@ -3911,17 +4542,17 @@ var requestTypeContainer = (bgColor) => css24`
|
|
|
3911
4542
|
`;
|
|
3912
4543
|
|
|
3913
4544
|
// src/components/Request/RequestTypeContainer.tsx
|
|
3914
|
-
import { jsx as
|
|
4545
|
+
import { jsx as jsx41 } from "@emotion/react/jsx-runtime";
|
|
3915
4546
|
var RequestTypeContainer = ({
|
|
3916
4547
|
bgColor = "transparent",
|
|
3917
4548
|
children,
|
|
3918
4549
|
...props
|
|
3919
4550
|
}) => {
|
|
3920
|
-
return /* @__PURE__ */
|
|
4551
|
+
return /* @__PURE__ */ jsx41("div", { css: requestTypeContainer(bgColor), ...props, children });
|
|
3921
4552
|
};
|
|
3922
4553
|
|
|
3923
4554
|
// src/components/Request/RequestBody.tsx
|
|
3924
|
-
import { jsx as
|
|
4555
|
+
import { jsx as jsx42, jsxs as jsxs24 } from "@emotion/react/jsx-runtime";
|
|
3925
4556
|
var LANGUAGE_OPTIONS = [
|
|
3926
4557
|
{ label: "Text", value: "plaintext" },
|
|
3927
4558
|
{ label: "JSON", value: "json" },
|
|
@@ -3940,22 +4571,22 @@ var LANGUAGE_TO_CONTENT_TYPE = {
|
|
|
3940
4571
|
};
|
|
3941
4572
|
function RequestBody() {
|
|
3942
4573
|
const { request, dispatch } = useRequest();
|
|
3943
|
-
const [language, setLanguage] =
|
|
3944
|
-
return /* @__PURE__ */
|
|
4574
|
+
const [language, setLanguage] = useState12("json");
|
|
4575
|
+
return /* @__PURE__ */ jsxs24(
|
|
3945
4576
|
"div",
|
|
3946
4577
|
{
|
|
3947
|
-
css:
|
|
4578
|
+
css: css26`
|
|
3948
4579
|
background: var(--white);
|
|
3949
4580
|
`,
|
|
3950
4581
|
children: [
|
|
3951
|
-
/* @__PURE__ */
|
|
4582
|
+
/* @__PURE__ */ jsx42(
|
|
3952
4583
|
RequestTypeContainer,
|
|
3953
4584
|
{
|
|
3954
4585
|
bgColor: "var(--gray-100)",
|
|
3955
|
-
css:
|
|
4586
|
+
css: css26`
|
|
3956
4587
|
padding: var(--spacing-sm) var(--spacing-base);
|
|
3957
4588
|
`,
|
|
3958
|
-
children: /* @__PURE__ */
|
|
4589
|
+
children: /* @__PURE__ */ jsx42(
|
|
3959
4590
|
InputSelect4,
|
|
3960
4591
|
{
|
|
3961
4592
|
label: "Language",
|
|
@@ -3978,7 +4609,7 @@ function RequestBody() {
|
|
|
3978
4609
|
)
|
|
3979
4610
|
}
|
|
3980
4611
|
),
|
|
3981
|
-
/* @__PURE__ */
|
|
4612
|
+
/* @__PURE__ */ jsx42(
|
|
3982
4613
|
JsonEditor,
|
|
3983
4614
|
{
|
|
3984
4615
|
height: 200,
|
|
@@ -3998,7 +4629,7 @@ function RequestBody() {
|
|
|
3998
4629
|
// src/components/Request/RequestHeaders.tsx
|
|
3999
4630
|
init_emotion_jsx_shim();
|
|
4000
4631
|
import {
|
|
4001
|
-
Input as
|
|
4632
|
+
Input as Input3,
|
|
4002
4633
|
Table as Table2,
|
|
4003
4634
|
TableBody as TableBody2,
|
|
4004
4635
|
TableCellData as TableCellData2,
|
|
@@ -4007,7 +4638,7 @@ import {
|
|
|
4007
4638
|
TableRow as TableRow2,
|
|
4008
4639
|
WarningMessage as WarningMessage2
|
|
4009
4640
|
} from "@uniformdev/design-system";
|
|
4010
|
-
import { jsx as
|
|
4641
|
+
import { jsx as jsx43, jsxs as jsxs25 } from "@emotion/react/jsx-runtime";
|
|
4011
4642
|
function RequestHeaders({ disableVariables }) {
|
|
4012
4643
|
var _a, _b;
|
|
4013
4644
|
const { dispatch, request } = useRequest();
|
|
@@ -4023,29 +4654,29 @@ function RequestHeaders({ disableVariables }) {
|
|
|
4023
4654
|
index
|
|
4024
4655
|
});
|
|
4025
4656
|
};
|
|
4026
|
-
return /* @__PURE__ */
|
|
4027
|
-
/* @__PURE__ */
|
|
4028
|
-
/* @__PURE__ */
|
|
4029
|
-
/* @__PURE__ */
|
|
4657
|
+
return /* @__PURE__ */ jsx43("div", { css: innerContentStyles, children: /* @__PURE__ */ jsxs25(Table2, { children: [
|
|
4658
|
+
/* @__PURE__ */ jsx43(TableHead2, { children: /* @__PURE__ */ jsxs25(TableRow2, { children: [
|
|
4659
|
+
/* @__PURE__ */ jsx43(TableCellHead2, { children: "Name" }),
|
|
4660
|
+
/* @__PURE__ */ jsx43(TableCellHead2, { children: "Value" })
|
|
4030
4661
|
] }) }),
|
|
4031
|
-
/* @__PURE__ */
|
|
4662
|
+
/* @__PURE__ */ jsxs25(TableBody2, { children: [
|
|
4032
4663
|
(_b = (_a = request.baseRequest) == null ? void 0 : _a.headers) == null ? void 0 : _b.map((baseHeader) => {
|
|
4033
|
-
return /* @__PURE__ */
|
|
4034
|
-
/* @__PURE__ */
|
|
4664
|
+
return /* @__PURE__ */ jsxs25(TableRow2, { children: [
|
|
4665
|
+
/* @__PURE__ */ jsxs25(TableCellData2, { width: "50%", children: [
|
|
4035
4666
|
baseHeader.key,
|
|
4036
|
-
/* @__PURE__ */
|
|
4037
|
-
/* @__PURE__ */
|
|
4667
|
+
/* @__PURE__ */ jsx43("br", {}),
|
|
4668
|
+
/* @__PURE__ */ jsx43("i", { css: { color: "var(--gray-500)" }, children: /* @__PURE__ */ jsx43("small", { children: "from data source" }) })
|
|
4038
4669
|
] }),
|
|
4039
|
-
/* @__PURE__ */
|
|
4040
|
-
/* @__PURE__ */
|
|
4041
|
-
request.headers.find((p2) => p2.key === baseHeader.key) ? /* @__PURE__ */
|
|
4670
|
+
/* @__PURE__ */ jsxs25(TableCellData2, { width: "50%", children: [
|
|
4671
|
+
/* @__PURE__ */ jsx43("i", { css: { color: "var(--gray-500)" }, children: baseHeader.value }),
|
|
4672
|
+
request.headers.find((p2) => p2.key === baseHeader.key) ? /* @__PURE__ */ jsx43(WarningMessage2, { message: "overridden below" }) : null
|
|
4042
4673
|
] })
|
|
4043
4674
|
] }, baseHeader.key);
|
|
4044
4675
|
}),
|
|
4045
4676
|
deezHeaders.map((header, index) => {
|
|
4046
|
-
return /* @__PURE__ */
|
|
4047
|
-
/* @__PURE__ */
|
|
4048
|
-
|
|
4677
|
+
return /* @__PURE__ */ jsxs25(TableRow2, { children: [
|
|
4678
|
+
/* @__PURE__ */ jsx43(TableCellData2, { width: "50%", children: /* @__PURE__ */ jsx43(
|
|
4679
|
+
Input3,
|
|
4049
4680
|
{
|
|
4050
4681
|
label: header.key,
|
|
4051
4682
|
value: header.key,
|
|
@@ -4064,13 +4695,15 @@ function RequestHeaders({ disableVariables }) {
|
|
|
4064
4695
|
"data-test-id": "header-key"
|
|
4065
4696
|
}
|
|
4066
4697
|
) }),
|
|
4067
|
-
/* @__PURE__ */
|
|
4698
|
+
/* @__PURE__ */ jsx43(TableCellData2, { width: "50%", children: header.key ? /* @__PURE__ */ jsx43(
|
|
4068
4699
|
InputVariables,
|
|
4069
4700
|
{
|
|
4070
4701
|
value: header.value,
|
|
4071
4702
|
onChange: (value) => handleUpdateParamFromMenu({ key: header.key, value, index }),
|
|
4072
4703
|
disableVariables,
|
|
4073
4704
|
showAddVariableMenuOption: true,
|
|
4705
|
+
enableEditingVariables: true,
|
|
4706
|
+
disableReset: true,
|
|
4074
4707
|
"data-test-id": "header-value"
|
|
4075
4708
|
}
|
|
4076
4709
|
) : null })
|
|
@@ -4083,11 +4716,11 @@ function RequestHeaders({ disableVariables }) {
|
|
|
4083
4716
|
// src/components/Request/RequestMethodSelect.tsx
|
|
4084
4717
|
init_emotion_jsx_shim();
|
|
4085
4718
|
import { InputSelect as InputSelect5 } from "@uniformdev/design-system";
|
|
4086
|
-
import { jsx as
|
|
4719
|
+
import { jsx as jsx44 } from "@emotion/react/jsx-runtime";
|
|
4087
4720
|
function RequestMethodSelect(props) {
|
|
4088
4721
|
var _a;
|
|
4089
4722
|
const { request, dispatch } = useRequest();
|
|
4090
|
-
return /* @__PURE__ */
|
|
4723
|
+
return /* @__PURE__ */ jsx44(
|
|
4091
4724
|
InputSelect5,
|
|
4092
4725
|
{
|
|
4093
4726
|
...props,
|
|
@@ -4105,7 +4738,7 @@ function RequestMethodSelect(props) {
|
|
|
4105
4738
|
// src/components/Request/RequestParameters.tsx
|
|
4106
4739
|
init_emotion_jsx_shim();
|
|
4107
4740
|
import {
|
|
4108
|
-
Input as
|
|
4741
|
+
Input as Input4,
|
|
4109
4742
|
Table as Table3,
|
|
4110
4743
|
TableBody as TableBody3,
|
|
4111
4744
|
TableCellData as TableCellData3,
|
|
@@ -4114,7 +4747,7 @@ import {
|
|
|
4114
4747
|
TableRow as TableRow3,
|
|
4115
4748
|
WarningMessage as WarningMessage3
|
|
4116
4749
|
} from "@uniformdev/design-system";
|
|
4117
|
-
import { jsx as
|
|
4750
|
+
import { jsx as jsx45, jsxs as jsxs26 } from "@emotion/react/jsx-runtime";
|
|
4118
4751
|
function RequestParameters({ disableVariables }) {
|
|
4119
4752
|
var _a, _b;
|
|
4120
4753
|
const { dispatch, request } = useRequest();
|
|
@@ -4130,29 +4763,29 @@ function RequestParameters({ disableVariables }) {
|
|
|
4130
4763
|
index
|
|
4131
4764
|
});
|
|
4132
4765
|
};
|
|
4133
|
-
return /* @__PURE__ */
|
|
4134
|
-
/* @__PURE__ */
|
|
4135
|
-
/* @__PURE__ */
|
|
4136
|
-
/* @__PURE__ */
|
|
4766
|
+
return /* @__PURE__ */ jsx45("div", { css: innerContentStyles, children: /* @__PURE__ */ jsxs26(Table3, { children: [
|
|
4767
|
+
/* @__PURE__ */ jsx45(TableHead3, { children: /* @__PURE__ */ jsxs26(TableRow3, { children: [
|
|
4768
|
+
/* @__PURE__ */ jsx45(TableCellHead3, { children: "Name" }),
|
|
4769
|
+
/* @__PURE__ */ jsx45(TableCellHead3, { children: "Value" })
|
|
4137
4770
|
] }) }),
|
|
4138
|
-
/* @__PURE__ */
|
|
4771
|
+
/* @__PURE__ */ jsxs26(TableBody3, { children: [
|
|
4139
4772
|
(_b = (_a = request.baseRequest) == null ? void 0 : _a.parameters) == null ? void 0 : _b.map((baseParameter) => {
|
|
4140
|
-
return /* @__PURE__ */
|
|
4141
|
-
/* @__PURE__ */
|
|
4773
|
+
return /* @__PURE__ */ jsxs26(TableRow3, { children: [
|
|
4774
|
+
/* @__PURE__ */ jsxs26(TableCellData3, { width: "50%", children: [
|
|
4142
4775
|
baseParameter.key,
|
|
4143
|
-
/* @__PURE__ */
|
|
4144
|
-
/* @__PURE__ */
|
|
4776
|
+
/* @__PURE__ */ jsx45("br", {}),
|
|
4777
|
+
/* @__PURE__ */ jsx45("i", { css: { color: "var(--gray-500)" }, children: /* @__PURE__ */ jsx45("small", { children: "from data source" }) })
|
|
4145
4778
|
] }),
|
|
4146
|
-
/* @__PURE__ */
|
|
4147
|
-
/* @__PURE__ */
|
|
4148
|
-
request.parameters.find((p2) => p2.key === baseParameter.key) ? /* @__PURE__ */
|
|
4779
|
+
/* @__PURE__ */ jsxs26(TableCellData3, { width: "50%", children: [
|
|
4780
|
+
/* @__PURE__ */ jsx45("i", { css: { color: "var(--gray-500)" }, children: baseParameter.value }),
|
|
4781
|
+
request.parameters.find((p2) => p2.key === baseParameter.key) ? /* @__PURE__ */ jsx45(WarningMessage3, { message: "overridden below" }) : null
|
|
4149
4782
|
] })
|
|
4150
4783
|
] }, baseParameter.key);
|
|
4151
4784
|
}),
|
|
4152
4785
|
deezParameters.map((parameter, index) => {
|
|
4153
|
-
return /* @__PURE__ */
|
|
4154
|
-
/* @__PURE__ */
|
|
4155
|
-
|
|
4786
|
+
return /* @__PURE__ */ jsxs26(TableRow3, { children: [
|
|
4787
|
+
/* @__PURE__ */ jsx45(TableCellData3, { width: "50%", children: /* @__PURE__ */ jsx45(
|
|
4788
|
+
Input4,
|
|
4156
4789
|
{
|
|
4157
4790
|
label: parameter.key,
|
|
4158
4791
|
value: parameter.key,
|
|
@@ -4171,7 +4804,7 @@ function RequestParameters({ disableVariables }) {
|
|
|
4171
4804
|
"data-test-id": "parameter-key"
|
|
4172
4805
|
}
|
|
4173
4806
|
) }),
|
|
4174
|
-
/* @__PURE__ */
|
|
4807
|
+
/* @__PURE__ */ jsx45(TableCellData3, { width: "50%", children: parameter.key ? /* @__PURE__ */ jsx45(
|
|
4175
4808
|
InputVariables,
|
|
4176
4809
|
{
|
|
4177
4810
|
value: parameter.value,
|
|
@@ -4182,7 +4815,9 @@ function RequestParameters({ disableVariables }) {
|
|
|
4182
4815
|
}),
|
|
4183
4816
|
disableVariables,
|
|
4184
4817
|
"data-test-id": "parameter-value",
|
|
4185
|
-
showAddVariableMenuOption: true
|
|
4818
|
+
showAddVariableMenuOption: true,
|
|
4819
|
+
enableEditingVariables: true,
|
|
4820
|
+
disableReset: true
|
|
4186
4821
|
}
|
|
4187
4822
|
) : null })
|
|
4188
4823
|
] }, index);
|
|
@@ -4193,8 +4828,8 @@ function RequestParameters({ disableVariables }) {
|
|
|
4193
4828
|
|
|
4194
4829
|
// src/components/Request/RequestUrl.tsx
|
|
4195
4830
|
init_emotion_jsx_shim();
|
|
4196
|
-
import { css as
|
|
4197
|
-
import { useMemo as
|
|
4831
|
+
import { css as css27 } from "@emotion/react";
|
|
4832
|
+
import { useMemo as useMemo10 } from "react";
|
|
4198
4833
|
|
|
4199
4834
|
// src/components/Request/urlEncodeRequestParameter.ts
|
|
4200
4835
|
init_emotion_jsx_shim();
|
|
@@ -4216,35 +4851,35 @@ function decodeVariablesInUrlEncodedString(string, varValues) {
|
|
|
4216
4851
|
}
|
|
4217
4852
|
|
|
4218
4853
|
// src/components/Request/RequestUrl.tsx
|
|
4219
|
-
import { Fragment as
|
|
4854
|
+
import { Fragment as Fragment10, jsx as jsx46, jsxs as jsxs27 } from "@emotion/react/jsx-runtime";
|
|
4220
4855
|
function RequestUrl() {
|
|
4221
4856
|
var _a, _b;
|
|
4222
4857
|
const { variables } = useVariables();
|
|
4223
4858
|
const { request } = useRequest();
|
|
4224
|
-
const mergedParameters =
|
|
4859
|
+
const mergedParameters = useMemo10(() => {
|
|
4225
4860
|
var _a2;
|
|
4226
4861
|
if (!((_a2 = request.baseRequest) == null ? void 0 : _a2.parameters)) {
|
|
4227
4862
|
return request.parameters;
|
|
4228
4863
|
}
|
|
4229
4864
|
return request.baseRequest.parameters.filter((baseParam) => !request.parameters.find((p2) => p2.key === baseParam.key)).concat(request.parameters);
|
|
4230
4865
|
}, [(_a = request.baseRequest) == null ? void 0 : _a.parameters, request.parameters]);
|
|
4231
|
-
return /* @__PURE__ */
|
|
4866
|
+
return /* @__PURE__ */ jsxs27(
|
|
4232
4867
|
"small",
|
|
4233
4868
|
{
|
|
4234
|
-
css:
|
|
4869
|
+
css: css27`
|
|
4235
4870
|
display: inline-block;
|
|
4236
4871
|
margin-bottom: var(--spacing-xs);
|
|
4237
4872
|
word-break: break-word;
|
|
4238
4873
|
`,
|
|
4239
4874
|
children: [
|
|
4240
|
-
request.baseRequest ? /* @__PURE__ */
|
|
4241
|
-
/* @__PURE__ */
|
|
4875
|
+
request.baseRequest ? /* @__PURE__ */ jsx46("span", { children: (_b = request.baseRequest) == null ? void 0 : _b.baseUrl }) : null,
|
|
4876
|
+
/* @__PURE__ */ jsxs27("span", { css: { fontWeight: request.baseRequest ? "bold" : "inherit" }, children: [
|
|
4242
4877
|
urlEncodeRequestUrl(request.relativeUrl, variables),
|
|
4243
|
-
mergedParameters.length > 0 ? /* @__PURE__ */
|
|
4878
|
+
mergedParameters.length > 0 ? /* @__PURE__ */ jsxs27(Fragment10, { children: [
|
|
4244
4879
|
"?",
|
|
4245
4880
|
mergedParameters.map((param, index) => {
|
|
4246
4881
|
const encoded = urlEncodeRequestParameter(param, variables);
|
|
4247
|
-
return /* @__PURE__ */
|
|
4882
|
+
return /* @__PURE__ */ jsxs27("span", { children: [
|
|
4248
4883
|
index > 0 ? "&" : null,
|
|
4249
4884
|
encoded.key,
|
|
4250
4885
|
"=",
|
|
@@ -4261,9 +4896,9 @@ function RequestUrl() {
|
|
|
4261
4896
|
// src/components/Request/RequestUrlInput.tsx
|
|
4262
4897
|
init_emotion_jsx_shim();
|
|
4263
4898
|
|
|
4264
|
-
// src/components/Request/util/
|
|
4899
|
+
// src/components/Request/util/transformPastedUrl.ts
|
|
4265
4900
|
init_emotion_jsx_shim();
|
|
4266
|
-
function
|
|
4901
|
+
function transformPastedUrl(value, currentRequest, dispatch) {
|
|
4267
4902
|
var _a, _b, _c;
|
|
4268
4903
|
const indexOfQueryString = value.indexOf("?");
|
|
4269
4904
|
const hasQueryString = indexOfQueryString >= 0;
|
|
@@ -4271,7 +4906,6 @@ function handlePastedUrl(value, currentRequest, dispatch) {
|
|
|
4271
4906
|
if (((_a = currentRequest.baseRequest) == null ? void 0 : _a.baseUrl) && relativeUrl.startsWith((_b = currentRequest.baseRequest) == null ? void 0 : _b.baseUrl)) {
|
|
4272
4907
|
relativeUrl = relativeUrl.substring((_c = currentRequest.baseRequest) == null ? void 0 : _c.baseUrl.length);
|
|
4273
4908
|
}
|
|
4274
|
-
dispatch({ type: "setRelativeUrl", relativeUrl });
|
|
4275
4909
|
if (hasQueryString) {
|
|
4276
4910
|
for (let index = currentRequest.parameters.length - 1; index >= 0; index--) {
|
|
4277
4911
|
dispatch({ type: "removeParameter", index });
|
|
@@ -4284,25 +4918,25 @@ function handlePastedUrl(value, currentRequest, dispatch) {
|
|
|
4284
4918
|
} catch (e) {
|
|
4285
4919
|
}
|
|
4286
4920
|
}
|
|
4921
|
+
return relativeUrl;
|
|
4287
4922
|
}
|
|
4288
4923
|
|
|
4289
4924
|
// src/components/Request/RequestUrlInput.tsx
|
|
4290
|
-
import { jsx as
|
|
4925
|
+
import { jsx as jsx47 } from "@emotion/react/jsx-runtime";
|
|
4291
4926
|
function RequestUrlInput(props) {
|
|
4292
4927
|
const { request, dispatch } = useRequest();
|
|
4293
|
-
return /* @__PURE__ */
|
|
4928
|
+
return /* @__PURE__ */ jsx47(
|
|
4294
4929
|
InputVariables,
|
|
4295
4930
|
{
|
|
4296
4931
|
disableReset: true,
|
|
4297
4932
|
...props,
|
|
4298
4933
|
value: request.relativeUrl,
|
|
4299
|
-
|
|
4300
|
-
handlePastedUrl(value, request, dispatch);
|
|
4301
|
-
},
|
|
4934
|
+
transformPaste: (value) => transformPastedUrl(value, request, dispatch),
|
|
4302
4935
|
onChange: (value) => {
|
|
4303
4936
|
dispatch({ type: "setRelativeUrl", relativeUrl: value });
|
|
4304
4937
|
},
|
|
4305
4938
|
showAddVariableMenuOption: true,
|
|
4939
|
+
enableEditingVariables: true,
|
|
4306
4940
|
"data-test-id": "field-url"
|
|
4307
4941
|
}
|
|
4308
4942
|
);
|
|
@@ -4345,18 +4979,19 @@ function useRequestParameter(paramName) {
|
|
|
4345
4979
|
}
|
|
4346
4980
|
|
|
4347
4981
|
// src/components/DataSourceEditor.tsx
|
|
4348
|
-
import { jsx as
|
|
4982
|
+
import { jsx as jsx48 } from "@emotion/react/jsx-runtime";
|
|
4349
4983
|
function DataSourceEditor({ onChange, children, editVariableComponent }) {
|
|
4350
4984
|
var _a;
|
|
4351
4985
|
const { value } = useMeshLocation("dataSource");
|
|
4352
4986
|
const currentRequestValue = convertDataSourceToRequestData(value);
|
|
4353
|
-
return /* @__PURE__ */
|
|
4987
|
+
return /* @__PURE__ */ jsx48(
|
|
4354
4988
|
VariablesProvider,
|
|
4355
4989
|
{
|
|
4356
4990
|
value: (_a = value.variables) != null ? _a : {},
|
|
4357
4991
|
onChange: (newValue) => onChange((prev) => ({ newValue: { ...prev, variables: newValue } })),
|
|
4358
4992
|
editVariableComponent,
|
|
4359
|
-
|
|
4993
|
+
readOnly: true,
|
|
4994
|
+
children: /* @__PURE__ */ jsx48(
|
|
4360
4995
|
RequestProvider,
|
|
4361
4996
|
{
|
|
4362
4997
|
value: currentRequestValue,
|
|
@@ -4394,21 +5029,23 @@ function convertRequestDataToDataSource(dataSource, requestData) {
|
|
|
4394
5029
|
|
|
4395
5030
|
// src/components/DataTypeEditor.tsx
|
|
4396
5031
|
init_emotion_jsx_shim();
|
|
4397
|
-
import { jsx as
|
|
5032
|
+
import { jsx as jsx49 } from "@emotion/react/jsx-runtime";
|
|
4398
5033
|
function DataTypeEditor({ onChange, children, editVariableComponent }) {
|
|
4399
5034
|
var _a;
|
|
4400
5035
|
const {
|
|
4401
5036
|
value,
|
|
4402
|
-
metadata: { dataSource }
|
|
5037
|
+
metadata: { dataSource },
|
|
5038
|
+
isReadOnly
|
|
4403
5039
|
} = useMeshLocation("dataType");
|
|
4404
5040
|
const currentRequestValue = convertDataTypeToRequestData(value, dataSource);
|
|
4405
|
-
return /* @__PURE__ */
|
|
5041
|
+
return /* @__PURE__ */ jsx49(
|
|
4406
5042
|
VariablesProvider,
|
|
4407
5043
|
{
|
|
4408
5044
|
value: (_a = value.variables) != null ? _a : {},
|
|
4409
5045
|
onChange: (newValue) => onChange((prev) => ({ newValue: { ...prev, variables: newValue } })),
|
|
4410
5046
|
editVariableComponent,
|
|
4411
|
-
|
|
5047
|
+
readOnly: isReadOnly,
|
|
5048
|
+
children: /* @__PURE__ */ jsx49(
|
|
4412
5049
|
RequestProvider,
|
|
4413
5050
|
{
|
|
4414
5051
|
value: currentRequestValue,
|
|
@@ -4460,12 +5097,12 @@ import { LoadingIndicator as LoadingIndicator2, Theme as Theme2 } from "@uniform
|
|
|
4460
5097
|
// src/hooks/useInitializeUniformMeshSdk.ts
|
|
4461
5098
|
init_emotion_jsx_shim();
|
|
4462
5099
|
import { initializeUniformMeshSDK } from "@uniformdev/mesh-sdk";
|
|
4463
|
-
import { useEffect as
|
|
5100
|
+
import { useEffect as useEffect12, useRef as useRef10, useState as useState13 } from "react";
|
|
4464
5101
|
var useInitializeUniformMeshSdk = ({ autoResizingDisabled } = {}) => {
|
|
4465
|
-
const [error, setError] =
|
|
4466
|
-
const [sdk, setSdk] =
|
|
5102
|
+
const [error, setError] = useState13();
|
|
5103
|
+
const [sdk, setSdk] = useState13();
|
|
4467
5104
|
const initializationInProgress = useRef10(false);
|
|
4468
|
-
|
|
5105
|
+
useEffect12(
|
|
4469
5106
|
() => {
|
|
4470
5107
|
if (typeof window === "undefined" || sdk) {
|
|
4471
5108
|
return;
|
|
@@ -4498,7 +5135,7 @@ var useInitializeUniformMeshSdk = ({ autoResizingDisabled } = {}) => {
|
|
|
4498
5135
|
};
|
|
4499
5136
|
|
|
4500
5137
|
// src/components/MeshApp.tsx
|
|
4501
|
-
import { jsx as
|
|
5138
|
+
import { jsx as jsx50, jsxs as jsxs28 } from "@emotion/react/jsx-runtime";
|
|
4502
5139
|
var MeshApp = ({
|
|
4503
5140
|
children,
|
|
4504
5141
|
loadingComponent,
|
|
@@ -4507,37 +5144,37 @@ var MeshApp = ({
|
|
|
4507
5144
|
const { initializing, error, sdk } = useInitializeUniformMeshSdk();
|
|
4508
5145
|
if (initializing || !sdk) {
|
|
4509
5146
|
const LoadingComponent = loadingComponent;
|
|
4510
|
-
return LoadingComponent ? /* @__PURE__ */
|
|
5147
|
+
return LoadingComponent ? /* @__PURE__ */ jsx50(LoadingComponent, {}) : /* @__PURE__ */ jsx50(LoadingIndicator2, {});
|
|
4511
5148
|
}
|
|
4512
5149
|
if (error) {
|
|
4513
5150
|
const ErrorComponent = errorComponent;
|
|
4514
5151
|
if (ErrorComponent) {
|
|
4515
|
-
return /* @__PURE__ */
|
|
5152
|
+
return /* @__PURE__ */ jsx50(ErrorComponent, { error });
|
|
4516
5153
|
}
|
|
4517
5154
|
throw error;
|
|
4518
5155
|
}
|
|
4519
|
-
return /* @__PURE__ */
|
|
4520
|
-
/* @__PURE__ */
|
|
4521
|
-
/* @__PURE__ */
|
|
5156
|
+
return /* @__PURE__ */ jsxs28(UniformMeshSdkContext.Provider, { value: { sdk }, children: [
|
|
5157
|
+
/* @__PURE__ */ jsx50(Theme2, {}),
|
|
5158
|
+
/* @__PURE__ */ jsx50(UniformMeshLocationContextProvider, { children })
|
|
4522
5159
|
] });
|
|
4523
5160
|
};
|
|
4524
5161
|
|
|
4525
5162
|
// src/components/ObjectSearch/DataRefreshButton.tsx
|
|
4526
5163
|
init_emotion_jsx_shim();
|
|
4527
|
-
import { css as
|
|
5164
|
+
import { css as css28 } from "@emotion/react";
|
|
4528
5165
|
import { Button as Button3, LoadingIndicator as LoadingIndicator3 } from "@uniformdev/design-system";
|
|
4529
|
-
import { jsx as
|
|
5166
|
+
import { jsx as jsx51, jsxs as jsxs29 } from "@emotion/react/jsx-runtime";
|
|
4530
5167
|
var DataRefreshButton = ({
|
|
4531
5168
|
buttonText,
|
|
4532
5169
|
isLoading,
|
|
4533
5170
|
onRefreshData,
|
|
4534
5171
|
...props
|
|
4535
5172
|
}) => {
|
|
4536
|
-
return /* @__PURE__ */
|
|
4537
|
-
!isLoading ? null : /* @__PURE__ */
|
|
5173
|
+
return /* @__PURE__ */ jsxs29(Button3, { buttonType: "primaryInvert", onClick: onRefreshData, disabled: isLoading, ...props, children: [
|
|
5174
|
+
!isLoading ? null : /* @__PURE__ */ jsx51(
|
|
4538
5175
|
LoadingIndicator3,
|
|
4539
5176
|
{
|
|
4540
|
-
css:
|
|
5177
|
+
css: css28`
|
|
4541
5178
|
${isLoading ? "opacity: 0.2;" : void 0}
|
|
4542
5179
|
`
|
|
4543
5180
|
}
|
|
@@ -5715,13 +6352,13 @@ import { Container, IconsProvider, ScrollableList, VerticalRhythm } from "@unifo
|
|
|
5715
6352
|
init_emotion_jsx_shim();
|
|
5716
6353
|
import {
|
|
5717
6354
|
createContext as createContext5,
|
|
5718
|
-
useCallback,
|
|
6355
|
+
useCallback as useCallback2,
|
|
5719
6356
|
useContext as useContext7,
|
|
5720
6357
|
useDeferredValue,
|
|
5721
|
-
useMemo as
|
|
5722
|
-
useState as
|
|
6358
|
+
useMemo as useMemo11,
|
|
6359
|
+
useState as useState14
|
|
5723
6360
|
} from "react";
|
|
5724
|
-
import { jsx as
|
|
6361
|
+
import { jsx as jsx52 } from "@emotion/react/jsx-runtime";
|
|
5725
6362
|
var ObjectSearchContext = createContext5({
|
|
5726
6363
|
onSetQuery: () => {
|
|
5727
6364
|
},
|
|
@@ -5737,15 +6374,15 @@ var ObjectSearchContext = createContext5({
|
|
|
5737
6374
|
}
|
|
5738
6375
|
});
|
|
5739
6376
|
var ObjectSearchProvider = ({ currentlySelectedItems, children }) => {
|
|
5740
|
-
const [query, setQuery] =
|
|
6377
|
+
const [query, setQuery] = useState14({
|
|
5741
6378
|
contentType: "",
|
|
5742
6379
|
keyword: ""
|
|
5743
6380
|
});
|
|
5744
6381
|
const { flatVariables } = useVariables(true);
|
|
5745
6382
|
const querySearchDeferred = useDeferredValue(query);
|
|
5746
|
-
const [selectedItems, setSelectedItems] =
|
|
5747
|
-
const [list, setList] =
|
|
5748
|
-
const onSetQuery =
|
|
6383
|
+
const [selectedItems, setSelectedItems] = useState14(currentlySelectedItems != null ? currentlySelectedItems : []);
|
|
6384
|
+
const [list, setList] = useState14({});
|
|
6385
|
+
const onSetQuery = useCallback2(
|
|
5749
6386
|
(value2) => {
|
|
5750
6387
|
if (Array.isArray(value2.contentType) && value2.contentType.length > 0) {
|
|
5751
6388
|
return setQuery({
|
|
@@ -5757,7 +6394,7 @@ var ObjectSearchProvider = ({ currentlySelectedItems, children }) => {
|
|
|
5757
6394
|
},
|
|
5758
6395
|
[setQuery]
|
|
5759
6396
|
);
|
|
5760
|
-
const onSelectItem =
|
|
6397
|
+
const onSelectItem = useCallback2(
|
|
5761
6398
|
(selectedResult) => {
|
|
5762
6399
|
if (Array.isArray(selectedResult)) {
|
|
5763
6400
|
setSelectedItems(selectedResult);
|
|
@@ -5771,17 +6408,17 @@ var ObjectSearchProvider = ({ currentlySelectedItems, children }) => {
|
|
|
5771
6408
|
},
|
|
5772
6409
|
[setSelectedItems, selectedItems]
|
|
5773
6410
|
);
|
|
5774
|
-
const onRemoveAllSelectedItems =
|
|
6411
|
+
const onRemoveAllSelectedItems = useCallback2(() => {
|
|
5775
6412
|
setSelectedItems([]);
|
|
5776
6413
|
}, [setSelectedItems]);
|
|
5777
|
-
const onSetList =
|
|
6414
|
+
const onSetList = useCallback2(
|
|
5778
6415
|
(value2) => {
|
|
5779
6416
|
setList(value2);
|
|
5780
6417
|
},
|
|
5781
6418
|
[setList]
|
|
5782
6419
|
);
|
|
5783
|
-
const boundQuery =
|
|
5784
|
-
const value =
|
|
6420
|
+
const boundQuery = useMemo11(() => bindQuery(query, flatVariables), [query, flatVariables]);
|
|
6421
|
+
const value = useMemo11(
|
|
5785
6422
|
() => ({
|
|
5786
6423
|
boundQuery,
|
|
5787
6424
|
onSetQuery,
|
|
@@ -5803,7 +6440,7 @@ var ObjectSearchProvider = ({ currentlySelectedItems, children }) => {
|
|
|
5803
6440
|
onSetList
|
|
5804
6441
|
]
|
|
5805
6442
|
);
|
|
5806
|
-
return /* @__PURE__ */
|
|
6443
|
+
return /* @__PURE__ */ jsx52(ObjectSearchContext.Provider, { value, children });
|
|
5807
6444
|
};
|
|
5808
6445
|
function useObjectSearchContext() {
|
|
5809
6446
|
return useContext7(ObjectSearchContext);
|
|
@@ -5821,7 +6458,7 @@ function bindQuery(query, inputs) {
|
|
|
5821
6458
|
}
|
|
5822
6459
|
|
|
5823
6460
|
// src/components/ObjectSearch/ObjectSearchContainer.tsx
|
|
5824
|
-
import { jsx as
|
|
6461
|
+
import { jsx as jsx53, jsxs as jsxs30 } from "@emotion/react/jsx-runtime";
|
|
5825
6462
|
var ObjectSearchContainer = ({
|
|
5826
6463
|
label,
|
|
5827
6464
|
enableDynamicInputToResultId,
|
|
@@ -5832,9 +6469,9 @@ var ObjectSearchContainer = ({
|
|
|
5832
6469
|
var _a, _b;
|
|
5833
6470
|
const { onSelectItem, selectedListItems, list } = useObjectSearchContext();
|
|
5834
6471
|
const { flatVariables } = useVariables(true);
|
|
5835
|
-
const body = /* @__PURE__ */
|
|
6472
|
+
const body = /* @__PURE__ */ jsxs30(VerticalRhythm, { children: [
|
|
5836
6473
|
searchFilters,
|
|
5837
|
-
!resultList ? null : /* @__PURE__ */
|
|
6474
|
+
!resultList ? null : /* @__PURE__ */ jsx53(ScrollableList, { role: "list", children: resultList })
|
|
5838
6475
|
] });
|
|
5839
6476
|
const handleSelectedVariableChange = (selectedValue) => {
|
|
5840
6477
|
var _a2;
|
|
@@ -5863,8 +6500,8 @@ var ObjectSearchContainer = ({
|
|
|
5863
6500
|
}
|
|
5864
6501
|
]);
|
|
5865
6502
|
};
|
|
5866
|
-
return /* @__PURE__ */
|
|
5867
|
-
/* @__PURE__ */
|
|
6503
|
+
return /* @__PURE__ */ jsx53(IconsProvider, { children: /* @__PURE__ */ jsxs30(VerticalRhythm, { children: [
|
|
6504
|
+
/* @__PURE__ */ jsx53(Container, { backgroundColor: "gray-50", padding: "var(--spacing-base)", border: true, children: label ? /* @__PURE__ */ jsx53(
|
|
5868
6505
|
InputVariables,
|
|
5869
6506
|
{
|
|
5870
6507
|
label,
|
|
@@ -5881,12 +6518,12 @@ var ObjectSearchContainer = ({
|
|
|
5881
6518
|
// src/components/ObjectSearch/ObjectSearchFilter.tsx
|
|
5882
6519
|
init_emotion_jsx_shim();
|
|
5883
6520
|
import { InputKeywordSearch as InputKeywordSearch2, InputSelect as InputSelect6 } from "@uniformdev/design-system";
|
|
5884
|
-
import { useState as
|
|
6521
|
+
import { useState as useState15 } from "react";
|
|
5885
6522
|
|
|
5886
6523
|
// src/components/ObjectSearch/styles/ObjectSearchFilterContainer.styles.ts
|
|
5887
6524
|
init_emotion_jsx_shim();
|
|
5888
|
-
import { css as
|
|
5889
|
-
var ObjectSearchFilterContainerLabel =
|
|
6525
|
+
import { css as css29 } from "@emotion/react";
|
|
6526
|
+
var ObjectSearchFilterContainerLabel = css29`
|
|
5890
6527
|
align-items: center;
|
|
5891
6528
|
display: flex;
|
|
5892
6529
|
font-size: var(--fs-sm);
|
|
@@ -5894,21 +6531,21 @@ var ObjectSearchFilterContainerLabel = css28`
|
|
|
5894
6531
|
line-height: 1rem;
|
|
5895
6532
|
margin-bottom: var(--spacing-sm);
|
|
5896
6533
|
`;
|
|
5897
|
-
var ObjectSearchFilterContainer =
|
|
6534
|
+
var ObjectSearchFilterContainer = css29`
|
|
5898
6535
|
display: grid;
|
|
5899
6536
|
gap: var(--spacing-base);
|
|
5900
6537
|
`;
|
|
5901
|
-
var ObjectSearchFilterDropdownAndTextSearch =
|
|
6538
|
+
var ObjectSearchFilterDropdownAndTextSearch = css29`
|
|
5902
6539
|
grid-template-columns: 0.5fr 1fr;
|
|
5903
6540
|
`;
|
|
5904
|
-
var ObjectSearchFilterGrid = (gridColumns) =>
|
|
6541
|
+
var ObjectSearchFilterGrid = (gridColumns) => css29`
|
|
5905
6542
|
display: grid;
|
|
5906
6543
|
grid-template-columns: ${gridColumns};
|
|
5907
6544
|
gap: var(--spacing-base);
|
|
5908
6545
|
`;
|
|
5909
6546
|
|
|
5910
6547
|
// src/components/ObjectSearch/ObjectSearchFilter.tsx
|
|
5911
|
-
import { jsx as
|
|
6548
|
+
import { jsx as jsx54, jsxs as jsxs31 } from "@emotion/react/jsx-runtime";
|
|
5912
6549
|
var ObjectSearchFilter = ({
|
|
5913
6550
|
requireContentType,
|
|
5914
6551
|
typeSelectorAllTypesOptionText = "All content types",
|
|
@@ -5918,7 +6555,7 @@ var ObjectSearchFilter = ({
|
|
|
5918
6555
|
selectOptions
|
|
5919
6556
|
}) => {
|
|
5920
6557
|
const { query, onSetQuery } = useObjectSearchContext();
|
|
5921
|
-
const [searchState, setSearchState] =
|
|
6558
|
+
const [searchState, setSearchState] = useState15({
|
|
5922
6559
|
contentType: "",
|
|
5923
6560
|
keyword: ""
|
|
5924
6561
|
});
|
|
@@ -5928,8 +6565,8 @@ var ObjectSearchFilter = ({
|
|
|
5928
6565
|
});
|
|
5929
6566
|
onSetQuery({ ...query, ...value });
|
|
5930
6567
|
};
|
|
5931
|
-
return /* @__PURE__ */
|
|
5932
|
-
/* @__PURE__ */
|
|
6568
|
+
return /* @__PURE__ */ jsxs31("fieldset", { css: [ObjectSearchFilterContainer, ObjectSearchFilterDropdownAndTextSearch], children: [
|
|
6569
|
+
/* @__PURE__ */ jsx54(
|
|
5933
6570
|
InputSelect6,
|
|
5934
6571
|
{
|
|
5935
6572
|
label: selectLabel,
|
|
@@ -5945,7 +6582,7 @@ var ObjectSearchFilter = ({
|
|
|
5945
6582
|
value: query.contentType
|
|
5946
6583
|
}
|
|
5947
6584
|
),
|
|
5948
|
-
/* @__PURE__ */
|
|
6585
|
+
/* @__PURE__ */ jsx54(
|
|
5949
6586
|
InputKeywordSearch2,
|
|
5950
6587
|
{
|
|
5951
6588
|
inputFieldName: searchInputName,
|
|
@@ -5961,11 +6598,11 @@ var ObjectSearchFilter = ({
|
|
|
5961
6598
|
|
|
5962
6599
|
// src/components/ObjectSearch/ObjectSearchFilterContainer.tsx
|
|
5963
6600
|
init_emotion_jsx_shim();
|
|
5964
|
-
import { jsx as
|
|
6601
|
+
import { jsx as jsx55, jsxs as jsxs32 } from "@emotion/react/jsx-runtime";
|
|
5965
6602
|
var ObjectSearchFilterContainer2 = ({ label, children }) => {
|
|
5966
|
-
return /* @__PURE__ */
|
|
5967
|
-
label ? /* @__PURE__ */
|
|
5968
|
-
/* @__PURE__ */
|
|
6603
|
+
return /* @__PURE__ */ jsxs32("div", { children: [
|
|
6604
|
+
label ? /* @__PURE__ */ jsx55("span", { css: ObjectSearchFilterContainerLabel, children: label }) : null,
|
|
6605
|
+
/* @__PURE__ */ jsx55("div", { css: ObjectSearchFilterContainer, children })
|
|
5969
6606
|
] });
|
|
5970
6607
|
};
|
|
5971
6608
|
|
|
@@ -5975,9 +6612,9 @@ import { Popover } from "@uniformdev/design-system";
|
|
|
5975
6612
|
|
|
5976
6613
|
// src/components/ObjectSearch/styles/ObjectSearchListItem.styles.ts
|
|
5977
6614
|
init_emotion_jsx_shim();
|
|
5978
|
-
import { css as
|
|
6615
|
+
import { css as css30 } from "@emotion/react";
|
|
5979
6616
|
import { skeletonLoading } from "@uniformdev/design-system";
|
|
5980
|
-
var ObjectListItemContainer =
|
|
6617
|
+
var ObjectListItemContainer = css30`
|
|
5981
6618
|
align-items: center;
|
|
5982
6619
|
border: 1px solid var(--gray-300);
|
|
5983
6620
|
border-radius: var(--rounded-base);
|
|
@@ -5990,7 +6627,7 @@ var ObjectListItemContainer = css29`
|
|
|
5990
6627
|
display: none;
|
|
5991
6628
|
}
|
|
5992
6629
|
`;
|
|
5993
|
-
var ObjectListItemLoading =
|
|
6630
|
+
var ObjectListItemLoading = css30`
|
|
5994
6631
|
animation: ${skeletonLoading} 1s linear infinite alternate;
|
|
5995
6632
|
border-color: transparent;
|
|
5996
6633
|
min-height: 42px;
|
|
@@ -6014,37 +6651,37 @@ var ObjectListItemLoading = css29`
|
|
|
6014
6651
|
width: 1rem;
|
|
6015
6652
|
}
|
|
6016
6653
|
`;
|
|
6017
|
-
var ObjectListItemHeadingGroup =
|
|
6654
|
+
var ObjectListItemHeadingGroup = css30`
|
|
6018
6655
|
align-items: center;
|
|
6019
6656
|
display: grid;
|
|
6020
6657
|
`;
|
|
6021
|
-
var ObjectListItemTitle =
|
|
6658
|
+
var ObjectListItemTitle = css30`
|
|
6022
6659
|
color: var(--brand-secondary-1);
|
|
6023
6660
|
display: block;
|
|
6024
6661
|
font-size: var(--fs-sm);
|
|
6025
6662
|
`;
|
|
6026
|
-
var ObjectListItemSubtitle =
|
|
6663
|
+
var ObjectListItemSubtitle = css30`
|
|
6027
6664
|
color: var(--gray-500);
|
|
6028
6665
|
display: block;
|
|
6029
6666
|
font-size: var(--fs-xs);
|
|
6030
6667
|
line-height: 1;
|
|
6031
6668
|
`;
|
|
6032
|
-
var ObjectListItemInfoContainer =
|
|
6669
|
+
var ObjectListItemInfoContainer = css30`
|
|
6033
6670
|
align-items: center;
|
|
6034
6671
|
display: flex;
|
|
6035
6672
|
justify-content: center;
|
|
6036
6673
|
`;
|
|
6037
|
-
var ObjectListItemControlledContent =
|
|
6674
|
+
var ObjectListItemControlledContent = css30`
|
|
6038
6675
|
display: flex;
|
|
6039
6676
|
gap: var(--spacing-sm);
|
|
6040
6677
|
`;
|
|
6041
|
-
var ObjectListItemUnControlledContent =
|
|
6678
|
+
var ObjectListItemUnControlledContent = css30`
|
|
6042
6679
|
margin-top: var(--spacing-sm);
|
|
6043
6680
|
grid-column: 1 / -1;
|
|
6044
6681
|
`;
|
|
6045
6682
|
|
|
6046
6683
|
// src/components/ObjectSearch/ObjectSearchListItem.tsx
|
|
6047
|
-
import { jsx as
|
|
6684
|
+
import { jsx as jsx56, jsxs as jsxs33 } from "@emotion/react/jsx-runtime";
|
|
6048
6685
|
var ObjectSearchListItem = ({
|
|
6049
6686
|
id,
|
|
6050
6687
|
title,
|
|
@@ -6067,20 +6704,20 @@ var ObjectSearchListItem = ({
|
|
|
6067
6704
|
return onSelectItem([selectedItem]);
|
|
6068
6705
|
};
|
|
6069
6706
|
const hideWhenInSelectedList = selectedListItems.some((item) => item.id === id);
|
|
6070
|
-
return /* @__PURE__ */
|
|
6071
|
-
/* @__PURE__ */
|
|
6072
|
-
!image ? null : /* @__PURE__ */
|
|
6073
|
-
/* @__PURE__ */
|
|
6074
|
-
!contentType ? null : /* @__PURE__ */
|
|
6075
|
-
/* @__PURE__ */
|
|
6707
|
+
return /* @__PURE__ */ jsxs33("div", { role: "listitem", hidden: hideWhenInSelectedList, css: ObjectListItemContainer, children: [
|
|
6708
|
+
/* @__PURE__ */ jsxs33("div", { role: "button", onClick: handleSelectItem, css: ObjectListItemControlledContent, children: [
|
|
6709
|
+
!image ? null : /* @__PURE__ */ jsx56("img", { ...image, loading: (image == null ? void 0 : image.width) && image.height ? "lazy" : "eager" }),
|
|
6710
|
+
/* @__PURE__ */ jsxs33("div", { role: "heading", css: ObjectListItemHeadingGroup, children: [
|
|
6711
|
+
!contentType ? null : /* @__PURE__ */ jsx56("span", { css: ObjectListItemSubtitle, children: formatedContentType }),
|
|
6712
|
+
/* @__PURE__ */ jsx56("span", { css: ObjectListItemTitle, children: title })
|
|
6076
6713
|
] })
|
|
6077
6714
|
] }),
|
|
6078
|
-
!popoverData ? null : /* @__PURE__ */
|
|
6079
|
-
!children ? null : /* @__PURE__ */
|
|
6715
|
+
!popoverData ? null : /* @__PURE__ */ jsx56("div", { css: ObjectListItemInfoContainer, children: /* @__PURE__ */ jsx56(Popover, { baseId: title, ariaLabel: title, buttonText: `See ${title} details`, children: popoverData }) }),
|
|
6716
|
+
!children ? null : /* @__PURE__ */ jsx56("div", { css: ObjectListItemUnControlledContent, children })
|
|
6080
6717
|
] });
|
|
6081
6718
|
};
|
|
6082
6719
|
var ObjectSearchListItemLoadingSkeleton = () => {
|
|
6083
|
-
return /* @__PURE__ */
|
|
6720
|
+
return /* @__PURE__ */ jsx56("div", { role: "presentation", css: [ObjectListItemContainer, ObjectListItemLoading] });
|
|
6084
6721
|
};
|
|
6085
6722
|
|
|
6086
6723
|
// src/components/ObjectSearch/ObjectSearchResultItem.tsx
|
|
@@ -6093,9 +6730,9 @@ init_emotion_jsx_shim();
|
|
|
6093
6730
|
|
|
6094
6731
|
// src/components/ObjectSearch/styles/ObjectSearchResultItemButton.styles.ts
|
|
6095
6732
|
init_emotion_jsx_shim();
|
|
6096
|
-
import { css as
|
|
6733
|
+
import { css as css31 } from "@emotion/react";
|
|
6097
6734
|
import { button as button2 } from "@uniformdev/design-system";
|
|
6098
|
-
var ButtonStyles =
|
|
6735
|
+
var ButtonStyles = css31`
|
|
6099
6736
|
${button2}
|
|
6100
6737
|
background: transparent;
|
|
6101
6738
|
border: 1px solid var(--brand-secondary-1);
|
|
@@ -6122,20 +6759,20 @@ var ButtonStyles = css30`
|
|
|
6122
6759
|
text-decoration: none;
|
|
6123
6760
|
}
|
|
6124
6761
|
`;
|
|
6125
|
-
var ButtonIcon =
|
|
6762
|
+
var ButtonIcon = css31`
|
|
6126
6763
|
width: 1rem;
|
|
6127
6764
|
height: 1rem;
|
|
6128
6765
|
`;
|
|
6129
6766
|
|
|
6130
6767
|
// src/components/ObjectSearch/ObjectSearchResultItemButton.tsx
|
|
6131
|
-
import { jsx as
|
|
6768
|
+
import { jsx as jsx57, jsxs as jsxs34 } from "@emotion/react/jsx-runtime";
|
|
6132
6769
|
var ObjectSearchResultItemButton = ({
|
|
6133
6770
|
text,
|
|
6134
6771
|
icon,
|
|
6135
6772
|
...props
|
|
6136
6773
|
}) => {
|
|
6137
|
-
return /* @__PURE__ */
|
|
6138
|
-
!icon ? null : /* @__PURE__ */
|
|
6774
|
+
return /* @__PURE__ */ jsxs34("button", { type: "button", css: ButtonStyles, ...props, children: [
|
|
6775
|
+
!icon ? null : /* @__PURE__ */ jsx57(Image, { src: icon, css: ButtonIcon }),
|
|
6139
6776
|
text
|
|
6140
6777
|
] });
|
|
6141
6778
|
};
|
|
@@ -6144,16 +6781,16 @@ var LinkButton = ({
|
|
|
6144
6781
|
icon,
|
|
6145
6782
|
...props
|
|
6146
6783
|
}) => {
|
|
6147
|
-
return /* @__PURE__ */
|
|
6148
|
-
!icon ? null : /* @__PURE__ */
|
|
6784
|
+
return /* @__PURE__ */ jsxs34("a", { ...props, css: ButtonStyles, target: "_blank", rel: "noopener noreferrer", children: [
|
|
6785
|
+
!icon ? null : /* @__PURE__ */ jsx57(Image, { src: icon, css: ButtonIcon }),
|
|
6149
6786
|
text
|
|
6150
6787
|
] });
|
|
6151
6788
|
};
|
|
6152
6789
|
|
|
6153
6790
|
// src/components/ObjectSearch/styles/ObjectSearchResultItem.styles.ts
|
|
6154
6791
|
init_emotion_jsx_shim();
|
|
6155
|
-
import { css as
|
|
6156
|
-
var ObjectSearchResultItemContainer =
|
|
6792
|
+
import { css as css32 } from "@emotion/react";
|
|
6793
|
+
var ObjectSearchResultItemContainer = css32`
|
|
6157
6794
|
align-items: center;
|
|
6158
6795
|
border: 1px solid var(--gray-300);
|
|
6159
6796
|
border-radius: var(--rounded-base);
|
|
@@ -6169,7 +6806,7 @@ var ObjectSearchResultItemContainer = css31`
|
|
|
6169
6806
|
}
|
|
6170
6807
|
}
|
|
6171
6808
|
`;
|
|
6172
|
-
var ObjectSearchDragHandle =
|
|
6809
|
+
var ObjectSearchDragHandle = css32`
|
|
6173
6810
|
border-left: 2px dotted var(--gray-300);
|
|
6174
6811
|
border-right: 2px dotted var(--gray-300);
|
|
6175
6812
|
position: absolute;
|
|
@@ -6178,41 +6815,41 @@ var ObjectSearchDragHandle = css31`
|
|
|
6178
6815
|
transition: opacity var(--duration-fast) var(--timing-ease-out);
|
|
6179
6816
|
opacity: 0;
|
|
6180
6817
|
`;
|
|
6181
|
-
var ObjectSearchResultItemSubtitle =
|
|
6818
|
+
var ObjectSearchResultItemSubtitle = css32`
|
|
6182
6819
|
color: var(--gray-500);
|
|
6183
6820
|
display: block;
|
|
6184
6821
|
font-size: var(--fs-xs);
|
|
6185
6822
|
line-height: 1;
|
|
6186
6823
|
`;
|
|
6187
|
-
var ObjectSearchResultItemTitle =
|
|
6824
|
+
var ObjectSearchResultItemTitle = css32`
|
|
6188
6825
|
align-items: center;
|
|
6189
6826
|
color: var(--brand-secondary-1);
|
|
6190
6827
|
display: flex;
|
|
6191
6828
|
gap: var(--spacing-xs);
|
|
6192
6829
|
`;
|
|
6193
|
-
var ObjectSearchResultItemTimeStamp =
|
|
6830
|
+
var ObjectSearchResultItemTimeStamp = css32`
|
|
6194
6831
|
color: var(--gray-500);
|
|
6195
6832
|
font-size: var(--fs-xs);
|
|
6196
6833
|
`;
|
|
6197
|
-
var ObjectSearchAuthorStateGroup =
|
|
6834
|
+
var ObjectSearchAuthorStateGroup = css32`
|
|
6198
6835
|
align-items: center;
|
|
6199
6836
|
display: flex;
|
|
6200
6837
|
gap: var(--spacing-sm);
|
|
6201
6838
|
`;
|
|
6202
|
-
var ObjectSearchUpdateGroup =
|
|
6839
|
+
var ObjectSearchUpdateGroup = css32`
|
|
6203
6840
|
display: grid;
|
|
6204
6841
|
`;
|
|
6205
|
-
var ObjectSearchContentContainer =
|
|
6842
|
+
var ObjectSearchContentContainer = css32`
|
|
6206
6843
|
display: flex;
|
|
6207
6844
|
gap: var(--spacing-base);
|
|
6208
6845
|
`;
|
|
6209
|
-
var ObjectSearchImage =
|
|
6846
|
+
var ObjectSearchImage = css32`
|
|
6210
6847
|
width: 56px;
|
|
6211
6848
|
object-fit: contain;
|
|
6212
6849
|
`;
|
|
6213
6850
|
|
|
6214
6851
|
// src/components/ObjectSearch/ObjectSearchResultItem.tsx
|
|
6215
|
-
import { jsx as
|
|
6852
|
+
import { jsx as jsx58, jsxs as jsxs35 } from "@emotion/react/jsx-runtime";
|
|
6216
6853
|
var ObjectSearchResultItem = ({
|
|
6217
6854
|
id,
|
|
6218
6855
|
title,
|
|
@@ -6236,35 +6873,35 @@ var ObjectSearchResultItem = ({
|
|
|
6236
6873
|
onSelectItem({ id, title: id });
|
|
6237
6874
|
onRemove == null ? void 0 : onRemove();
|
|
6238
6875
|
};
|
|
6239
|
-
return /* @__PURE__ */
|
|
6240
|
-
disableDnD ? null : /* @__PURE__ */
|
|
6241
|
-
/* @__PURE__ */
|
|
6242
|
-
!imageUrl ? null : /* @__PURE__ */
|
|
6243
|
-
/* @__PURE__ */
|
|
6244
|
-
/* @__PURE__ */
|
|
6245
|
-
/* @__PURE__ */
|
|
6876
|
+
return /* @__PURE__ */ jsxs35("div", { css: ObjectSearchResultItemContainer, children: [
|
|
6877
|
+
disableDnD ? null : /* @__PURE__ */ jsx58("div", { role: "presentation", className: "drag-handle", css: ObjectSearchDragHandle }),
|
|
6878
|
+
/* @__PURE__ */ jsx58("div", { children: /* @__PURE__ */ jsxs35("div", { css: ObjectSearchContentContainer, children: [
|
|
6879
|
+
!imageUrl ? null : /* @__PURE__ */ jsx58("img", { src: imageUrl, alt: `Thumbnail for ${title}`, css: ObjectSearchImage }),
|
|
6880
|
+
/* @__PURE__ */ jsxs35("div", { children: [
|
|
6881
|
+
/* @__PURE__ */ jsx58("span", { css: ObjectSearchResultItemSubtitle, children: formatedContentType }),
|
|
6882
|
+
/* @__PURE__ */ jsxs35("span", { role: "heading", css: ObjectSearchResultItemTitle, children: [
|
|
6246
6883
|
title != null ? title : name,
|
|
6247
|
-
!popoverData ? null : /* @__PURE__ */
|
|
6884
|
+
!popoverData ? null : /* @__PURE__ */ jsx58(Popover2, { baseId: title, ariaLabel: title, buttonText: `See ${title} details`, children: popoverData })
|
|
6248
6885
|
] }),
|
|
6249
|
-
!createdAt && !publishStatus ? null : /* @__PURE__ */
|
|
6250
|
-
!(publishStatus == null ? void 0 : publishStatus.text) ? null : /* @__PURE__ */
|
|
6251
|
-
!createdAt && !publishedAt ? null : /* @__PURE__ */
|
|
6252
|
-
!createdAt ? null : /* @__PURE__ */
|
|
6253
|
-
/* @__PURE__ */
|
|
6886
|
+
!createdAt && !publishStatus ? null : /* @__PURE__ */ jsxs35("div", { css: ObjectSearchAuthorStateGroup, children: [
|
|
6887
|
+
!(publishStatus == null ? void 0 : publishStatus.text) ? null : /* @__PURE__ */ jsx58(Badge, { ...publishStatus, size: "sm", uppercaseText: true }),
|
|
6888
|
+
!createdAt && !publishedAt ? null : /* @__PURE__ */ jsxs35("div", { css: ObjectSearchUpdateGroup, children: [
|
|
6889
|
+
!createdAt ? null : /* @__PURE__ */ jsxs35("small", { css: ObjectSearchResultItemTimeStamp, children: [
|
|
6890
|
+
/* @__PURE__ */ jsx58("strong", { children: "Last updated: " }),
|
|
6254
6891
|
timeagoFormat(createdAt)
|
|
6255
6892
|
] }),
|
|
6256
|
-
!publishedAt ? null : /* @__PURE__ */
|
|
6257
|
-
/* @__PURE__ */
|
|
6893
|
+
!publishedAt ? null : /* @__PURE__ */ jsxs35("small", { css: ObjectSearchResultItemTimeStamp, children: [
|
|
6894
|
+
/* @__PURE__ */ jsx58("strong", { children: "Last published: " }),
|
|
6258
6895
|
timeagoFormat(publishedAt)
|
|
6259
6896
|
] })
|
|
6260
6897
|
] })
|
|
6261
6898
|
] }),
|
|
6262
|
-
/* @__PURE__ */
|
|
6899
|
+
/* @__PURE__ */ jsx58("div", { children })
|
|
6263
6900
|
] })
|
|
6264
6901
|
] }) }),
|
|
6265
|
-
!editLink && hideRemoveButton ? null : /* @__PURE__ */
|
|
6266
|
-
!editLink ? null : /* @__PURE__ */
|
|
6267
|
-
hideRemoveButton ? null : /* @__PURE__ */
|
|
6902
|
+
!editLink && hideRemoveButton ? null : /* @__PURE__ */ jsxs35("div", { css: ObjectSearchAuthorStateGroup, children: [
|
|
6903
|
+
!editLink ? null : /* @__PURE__ */ jsx58(LinkButton, { text: "Edit", href: editLink, icon: editLinkIcon }),
|
|
6904
|
+
hideRemoveButton ? null : /* @__PURE__ */ jsx58(Button4, { buttonType: "ghostDestructive", onClick: onRemoveItem, children: "Remove" })
|
|
6268
6905
|
] })
|
|
6269
6906
|
] });
|
|
6270
6907
|
};
|
|
@@ -6276,35 +6913,35 @@ import { DragDropContext as DragDropContext3, Draggable as Draggable3, Droppable
|
|
|
6276
6913
|
|
|
6277
6914
|
// src/components/ObjectSearch/styles/ObjectSearchResultList.styles.ts
|
|
6278
6915
|
init_emotion_jsx_shim();
|
|
6279
|
-
import { css as
|
|
6280
|
-
var ObjectSearchResultListContainer =
|
|
6916
|
+
import { css as css33 } from "@emotion/react";
|
|
6917
|
+
var ObjectSearchResultListContainer = css33`
|
|
6281
6918
|
align-items: center;
|
|
6282
6919
|
display: flex;
|
|
6283
6920
|
gap: var(--spacing-sm);
|
|
6284
6921
|
justify-content: space-between;
|
|
6285
6922
|
`;
|
|
6286
|
-
var ObjectSearchDragContainer =
|
|
6923
|
+
var ObjectSearchDragContainer = css33`
|
|
6287
6924
|
margin: 0 0 var(--spacing-sm);
|
|
6288
6925
|
`;
|
|
6289
|
-
var ObjectSearchResultListCounterContainer =
|
|
6926
|
+
var ObjectSearchResultListCounterContainer = css33`
|
|
6290
6927
|
align-items: center;
|
|
6291
6928
|
display: flex;
|
|
6292
6929
|
gap: var(--spacing-sm);
|
|
6293
6930
|
`;
|
|
6294
|
-
var ObjectSearchResultListTitle =
|
|
6931
|
+
var ObjectSearchResultListTitle = css33`
|
|
6295
6932
|
font-weight: var(--fw-bold);
|
|
6296
6933
|
line-height: 1;
|
|
6297
6934
|
`;
|
|
6298
6935
|
|
|
6299
6936
|
// src/components/ObjectSearch/ObjectSearchResultList.tsx
|
|
6300
|
-
import { Fragment as
|
|
6937
|
+
import { Fragment as Fragment11, jsx as jsx59, jsxs as jsxs36 } from "@emotion/react/jsx-runtime";
|
|
6301
6938
|
function ObjectSearchResultList({
|
|
6302
6939
|
resultLabelText = "Selected",
|
|
6303
6940
|
removeButtonText = "Remove all",
|
|
6304
6941
|
onRemoveAllSelected,
|
|
6305
6942
|
hideRemoveButton = false,
|
|
6306
6943
|
additionalButtons,
|
|
6307
|
-
renderResultComponent = (value) => /* @__PURE__ */
|
|
6944
|
+
renderResultComponent = (value) => /* @__PURE__ */ jsx59(ObjectSearchResultItem, { ...value, disableDnD }),
|
|
6308
6945
|
multiSelectId,
|
|
6309
6946
|
disableDnD = false,
|
|
6310
6947
|
whenNothingSelected = null
|
|
@@ -6324,16 +6961,16 @@ function ObjectSearchResultList({
|
|
|
6324
6961
|
return result;
|
|
6325
6962
|
}
|
|
6326
6963
|
};
|
|
6327
|
-
return /* @__PURE__ */
|
|
6328
|
-
/* @__PURE__ */
|
|
6329
|
-
/* @__PURE__ */
|
|
6330
|
-
/* @__PURE__ */
|
|
6964
|
+
return /* @__PURE__ */ jsxs36(Fragment11, { children: [
|
|
6965
|
+
/* @__PURE__ */ jsxs36("div", { role: "group", css: ObjectSearchResultListContainer, children: [
|
|
6966
|
+
/* @__PURE__ */ jsxs36("div", { role: "note", css: ObjectSearchResultListCounterContainer, children: [
|
|
6967
|
+
/* @__PURE__ */ jsx59("span", { css: ObjectSearchResultListTitle, children: resultLabelText }),
|
|
6331
6968
|
" ",
|
|
6332
|
-
!selectedListItems.length ? null : /* @__PURE__ */
|
|
6969
|
+
!selectedListItems.length ? null : /* @__PURE__ */ jsx59(Counter, { count: selectedListItems.length })
|
|
6333
6970
|
] }),
|
|
6334
|
-
/* @__PURE__ */
|
|
6971
|
+
/* @__PURE__ */ jsxs36("div", { css: ObjectSearchResultListCounterContainer, children: [
|
|
6335
6972
|
additionalButtons,
|
|
6336
|
-
hideRemoveButton ? null : /* @__PURE__ */
|
|
6973
|
+
hideRemoveButton ? null : /* @__PURE__ */ jsx59(
|
|
6337
6974
|
Button5,
|
|
6338
6975
|
{
|
|
6339
6976
|
buttonType: "ghostDestructive",
|
|
@@ -6345,10 +6982,10 @@ function ObjectSearchResultList({
|
|
|
6345
6982
|
)
|
|
6346
6983
|
] })
|
|
6347
6984
|
] }),
|
|
6348
|
-
!selectedListItems.length ? whenNothingSelected : /* @__PURE__ */
|
|
6985
|
+
!selectedListItems.length ? whenNothingSelected : /* @__PURE__ */ jsx59(DragDropContext3, { onDragEnd: (res) => onDragEnd(res), children: /* @__PURE__ */ jsx59(Droppable3, { droppableId: multiSelectId != null ? multiSelectId : "canvas-multi-select", children: (provided) => /* @__PURE__ */ jsxs36("div", { ...provided.droppableProps, ref: provided.innerRef, children: [
|
|
6349
6986
|
selectedListItems.map((item, i2) => {
|
|
6350
6987
|
const renderListItem = renderResultComponent(item);
|
|
6351
|
-
return /* @__PURE__ */
|
|
6988
|
+
return /* @__PURE__ */ jsx59(Draggable3, { draggableId: item.id, index: i2, isDragDisabled: disableDnD, children: (provided2, snapshot) => /* @__PURE__ */ jsx59(
|
|
6352
6989
|
"div",
|
|
6353
6990
|
{
|
|
6354
6991
|
css: ObjectSearchDragContainer,
|
|
@@ -6367,9 +7004,9 @@ function ObjectSearchResultList({
|
|
|
6367
7004
|
|
|
6368
7005
|
// src/components/ObjectSearch/QueryFilter.tsx
|
|
6369
7006
|
init_emotion_jsx_shim();
|
|
6370
|
-
import { Input as
|
|
6371
|
-
import { useEffect as
|
|
6372
|
-
import { jsx as
|
|
7007
|
+
import { Input as Input5, InputKeywordSearch as InputKeywordSearch3, InputSelect as InputSelect7, VerticalRhythm as VerticalRhythm2 } from "@uniformdev/design-system";
|
|
7008
|
+
import { useEffect as useEffect13, useState as useState16 } from "react";
|
|
7009
|
+
import { jsx as jsx60, jsxs as jsxs37 } from "@emotion/react/jsx-runtime";
|
|
6373
7010
|
var QueryFilter = ({
|
|
6374
7011
|
requireContentType,
|
|
6375
7012
|
queryFilterTitle = "Configure Query",
|
|
@@ -6400,7 +7037,7 @@ var QueryFilter = ({
|
|
|
6400
7037
|
}) => {
|
|
6401
7038
|
var _a, _b, _c, _d;
|
|
6402
7039
|
const { query, onSetQuery } = useObjectSearchContext();
|
|
6403
|
-
const [queryState, setQueryState] =
|
|
7040
|
+
const [queryState, setQueryState] = useState16({
|
|
6404
7041
|
contentType: "",
|
|
6405
7042
|
keyword: "",
|
|
6406
7043
|
count: countValue != null ? countValue : 5,
|
|
@@ -6411,13 +7048,13 @@ var QueryFilter = ({
|
|
|
6411
7048
|
setQueryState((prev) => ({ ...prev, ...value }));
|
|
6412
7049
|
onSetQuery({ ...query, ...value });
|
|
6413
7050
|
};
|
|
6414
|
-
|
|
7051
|
+
useEffect13(() => {
|
|
6415
7052
|
onSetQuery(queryState);
|
|
6416
7053
|
}, [onSetQuery, queryState]);
|
|
6417
|
-
return /* @__PURE__ */
|
|
6418
|
-
/* @__PURE__ */
|
|
6419
|
-
/* @__PURE__ */
|
|
6420
|
-
/* @__PURE__ */
|
|
7054
|
+
return /* @__PURE__ */ jsxs37("fieldset", { children: [
|
|
7055
|
+
/* @__PURE__ */ jsx60("span", { css: ObjectSearchFilterContainerLabel, children: queryFilterTitle }),
|
|
7056
|
+
/* @__PURE__ */ jsx60("div", { css: ObjectSearchFilterContainer, children: /* @__PURE__ */ jsxs37(VerticalRhythm2, { children: [
|
|
7057
|
+
/* @__PURE__ */ jsx60(
|
|
6421
7058
|
InputVariables,
|
|
6422
7059
|
{
|
|
6423
7060
|
label: searchInputLabel,
|
|
@@ -6425,7 +7062,7 @@ var QueryFilter = ({
|
|
|
6425
7062
|
onChange: (newQuery) => handleFilterChange({ keyword: newQuery }),
|
|
6426
7063
|
disableInlineMenu: true,
|
|
6427
7064
|
id: "qf_searchText",
|
|
6428
|
-
inputWhenNoVariables: /* @__PURE__ */
|
|
7065
|
+
inputWhenNoVariables: /* @__PURE__ */ jsx60(
|
|
6429
7066
|
InputKeywordSearch3,
|
|
6430
7067
|
{
|
|
6431
7068
|
id: "qf_searchText",
|
|
@@ -6439,8 +7076,8 @@ var QueryFilter = ({
|
|
|
6439
7076
|
)
|
|
6440
7077
|
}
|
|
6441
7078
|
),
|
|
6442
|
-
/* @__PURE__ */
|
|
6443
|
-
/* @__PURE__ */
|
|
7079
|
+
/* @__PURE__ */ jsxs37("div", { css: ObjectSearchFilterGrid("1fr 100px"), children: [
|
|
7080
|
+
/* @__PURE__ */ jsx60(
|
|
6444
7081
|
InputVariables,
|
|
6445
7082
|
{
|
|
6446
7083
|
label: contentTypeLabel,
|
|
@@ -6448,7 +7085,7 @@ var QueryFilter = ({
|
|
|
6448
7085
|
value: (_d = queryState.contentType) != null ? _d : "",
|
|
6449
7086
|
onChange: (newType) => handleFilterChange({ contentType: newType }),
|
|
6450
7087
|
disableInlineMenu: true,
|
|
6451
|
-
inputWhenNoVariables: /* @__PURE__ */
|
|
7088
|
+
inputWhenNoVariables: /* @__PURE__ */ jsx60(
|
|
6452
7089
|
InputSelect7,
|
|
6453
7090
|
{
|
|
6454
7091
|
id: "qf_contentType",
|
|
@@ -6467,7 +7104,7 @@ var QueryFilter = ({
|
|
|
6467
7104
|
)
|
|
6468
7105
|
}
|
|
6469
7106
|
),
|
|
6470
|
-
/* @__PURE__ */
|
|
7107
|
+
/* @__PURE__ */ jsx60(
|
|
6471
7108
|
InputVariables,
|
|
6472
7109
|
{
|
|
6473
7110
|
label: countLabel,
|
|
@@ -6475,8 +7112,8 @@ var QueryFilter = ({
|
|
|
6475
7112
|
value: queryState.count.toString(10),
|
|
6476
7113
|
onChange: (newCount) => handleFilterChange({ count: newCount }),
|
|
6477
7114
|
disableInlineMenu: true,
|
|
6478
|
-
inputWhenNoVariables: /* @__PURE__ */
|
|
6479
|
-
|
|
7115
|
+
inputWhenNoVariables: /* @__PURE__ */ jsx60(
|
|
7116
|
+
Input5,
|
|
6480
7117
|
{
|
|
6481
7118
|
id: "qf_count",
|
|
6482
7119
|
label: countLabel,
|
|
@@ -6490,8 +7127,8 @@ var QueryFilter = ({
|
|
|
6490
7127
|
}
|
|
6491
7128
|
)
|
|
6492
7129
|
] }),
|
|
6493
|
-
/* @__PURE__ */
|
|
6494
|
-
/* @__PURE__ */
|
|
7130
|
+
/* @__PURE__ */ jsxs37("div", { css: ObjectSearchFilterGrid("2fr 1fr"), children: [
|
|
7131
|
+
/* @__PURE__ */ jsx60(
|
|
6495
7132
|
InputVariables,
|
|
6496
7133
|
{
|
|
6497
7134
|
id: "qf_sortBy",
|
|
@@ -6499,7 +7136,7 @@ var QueryFilter = ({
|
|
|
6499
7136
|
value: queryState.sortBy,
|
|
6500
7137
|
onChange: (newSortBy) => handleFilterChange({ sortBy: newSortBy }),
|
|
6501
7138
|
disableInlineMenu: true,
|
|
6502
|
-
inputWhenNoVariables: /* @__PURE__ */
|
|
7139
|
+
inputWhenNoVariables: /* @__PURE__ */ jsx60(
|
|
6503
7140
|
InputSelect7,
|
|
6504
7141
|
{
|
|
6505
7142
|
label: sortLabel,
|
|
@@ -6521,7 +7158,7 @@ var QueryFilter = ({
|
|
|
6521
7158
|
)
|
|
6522
7159
|
}
|
|
6523
7160
|
),
|
|
6524
|
-
/* @__PURE__ */
|
|
7161
|
+
/* @__PURE__ */ jsx60(
|
|
6525
7162
|
InputVariables,
|
|
6526
7163
|
{
|
|
6527
7164
|
label: sortOrderLabel,
|
|
@@ -6529,7 +7166,7 @@ var QueryFilter = ({
|
|
|
6529
7166
|
value: queryState.sortOrder,
|
|
6530
7167
|
onChange: (newSort) => handleFilterChange({ sortOrder: newSort }),
|
|
6531
7168
|
disableInlineMenu: true,
|
|
6532
|
-
inputWhenNoVariables: /* @__PURE__ */
|
|
7169
|
+
inputWhenNoVariables: /* @__PURE__ */ jsx60(
|
|
6533
7170
|
InputSelect7,
|
|
6534
7171
|
{
|
|
6535
7172
|
label: sortOrderLabel,
|
|
@@ -6572,7 +7209,7 @@ import {
|
|
|
6572
7209
|
Button as Button6,
|
|
6573
7210
|
Callout as Callout5,
|
|
6574
7211
|
Heading,
|
|
6575
|
-
Input as
|
|
7212
|
+
Input as Input6,
|
|
6576
7213
|
InputComboBox,
|
|
6577
7214
|
InputKeywordSearch as InputKeywordSearch4,
|
|
6578
7215
|
InputSelect as InputSelect8,
|
|
@@ -6581,7 +7218,7 @@ import {
|
|
|
6581
7218
|
LoadingIndicator as LoadingIndicator4,
|
|
6582
7219
|
LoadingOverlay as LoadingOverlay2,
|
|
6583
7220
|
Menu as Menu3,
|
|
6584
|
-
MenuItem as
|
|
7221
|
+
MenuItem as MenuItem4,
|
|
6585
7222
|
ParameterGroup,
|
|
6586
7223
|
ParameterImage,
|
|
6587
7224
|
ParameterImageInner,
|
|
@@ -6619,7 +7256,7 @@ export {
|
|
|
6619
7256
|
EntrySearch,
|
|
6620
7257
|
Heading,
|
|
6621
7258
|
icons_exports as Icons,
|
|
6622
|
-
|
|
7259
|
+
Input6 as Input,
|
|
6623
7260
|
InputComboBox,
|
|
6624
7261
|
InputKeywordSearch4 as InputKeywordSearch,
|
|
6625
7262
|
InputSelect8 as InputSelect,
|
|
@@ -6630,7 +7267,7 @@ export {
|
|
|
6630
7267
|
LoadingIndicator4 as LoadingIndicator,
|
|
6631
7268
|
LoadingOverlay2 as LoadingOverlay,
|
|
6632
7269
|
Menu3 as Menu,
|
|
6633
|
-
|
|
7270
|
+
MenuItem4 as MenuItem,
|
|
6634
7271
|
MeshApp,
|
|
6635
7272
|
ObjectSearchContainer,
|
|
6636
7273
|
ObjectSearchFilter,
|
|
@@ -6758,7 +7395,6 @@ export {
|
|
|
6758
7395
|
useRequestParameter,
|
|
6759
7396
|
useUniformMeshSdk,
|
|
6760
7397
|
useVariables,
|
|
6761
|
-
variableExpression,
|
|
6762
7398
|
variablePrefix,
|
|
6763
7399
|
variableSuffix,
|
|
6764
7400
|
variablesToList
|