@uniformdev/mesh-sdk-react 19.141.1-alpha.5 → 19.142.0
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.mts +509 -137
- package/dist/index.d.ts +509 -137
- package/dist/index.esm.js +2057 -607
- package/dist/index.js +2127 -655
- package/dist/index.mjs +2057 -607
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -2652,9 +2652,6 @@ function DefaultDamItemRenderer({ item }) {
|
|
|
2652
2652
|
] }) : null;
|
|
2653
2653
|
}
|
|
2654
2654
|
|
|
2655
|
-
// src/components/DataResourceDynamicInputProvider.tsx
|
|
2656
|
-
import { createContext as createContext4, useContext as useContext6 } from "react";
|
|
2657
|
-
|
|
2658
2655
|
// src/hooks/useConnectedDataAsVariables.tsx
|
|
2659
2656
|
import { useMemo as useMemo3 } from "react";
|
|
2660
2657
|
function useConnectedDataAsVariables(connectedData) {
|
|
@@ -2948,15 +2945,16 @@ import {
|
|
|
2948
2945
|
KEY_BACKSPACE_COMMAND,
|
|
2949
2946
|
KEY_DELETE_COMMAND
|
|
2950
2947
|
} from "lexical";
|
|
2951
|
-
import { useCallback as useCallback3, useEffect as
|
|
2948
|
+
import { useCallback as useCallback3, useEffect as useEffect9 } from "react";
|
|
2952
2949
|
|
|
2953
2950
|
// src/components/Variables/util/prettifyBindExpression.tsx
|
|
2954
2951
|
function prettifyBindExpression(bindExpression) {
|
|
2955
|
-
|
|
2952
|
+
const [, expression] = bindExpression.split(":");
|
|
2953
|
+
return expression;
|
|
2956
2954
|
}
|
|
2957
2955
|
|
|
2958
2956
|
// src/components/Variables/composer/VariableChip.tsx
|
|
2959
|
-
import { MultilineChip } from "@uniformdev/design-system";
|
|
2957
|
+
import { MultilineChip, Tooltip, VerticalRhythm } from "@uniformdev/design-system";
|
|
2960
2958
|
import { Fragment as Fragment5 } from "react";
|
|
2961
2959
|
import { jsx as jsx30 } from "@emotion/react/jsx-runtime";
|
|
2962
2960
|
function VariableChip({
|
|
@@ -2972,42 +2970,58 @@ function VariableChip({
|
|
|
2972
2970
|
}) {
|
|
2973
2971
|
const hasClickEvent = !!onClick;
|
|
2974
2972
|
const referenceIsValidFr = isFresh ? true : referenceIsValid;
|
|
2975
|
-
const Wrapper = referenceIsValidFr === "info" ? InfoVariableReference : referenceIsValidFr ? Fragment5 : UndefinedVariableReference;
|
|
2973
|
+
const Wrapper = referenceIsValidFr === "warning" ? WarningVariableReference : referenceIsValidFr === "info" ? InfoVariableReference : referenceIsValidFr ? Fragment5 : UndefinedVariableReference;
|
|
2976
2974
|
const extraTitle = !referenceIsValidFr ? `${reference} is not defined.` : hasClickEvent && clickToEdit ? "Click to edit" : void 0;
|
|
2975
|
+
const chippy = /* @__PURE__ */ jsx30(MultilineChip, { onClick, "aria-selected": selected ? true : void 0, "aria-disabled": disabled, children: /* @__PURE__ */ jsx30(Wrapper, { children: displayName || reference }) });
|
|
2976
|
+
if (tooltip) {
|
|
2977
|
+
const tip = tooltip ? `${tooltip}${extraTitle ? `
|
|
2978
|
+
|
|
2979
|
+
${extraTitle}` : ""}` : extraTitle != null ? extraTitle : "";
|
|
2980
|
+
const tipLines = tip.split("\n");
|
|
2981
|
+
return /* @__PURE__ */ jsx30(
|
|
2982
|
+
Tooltip,
|
|
2983
|
+
{
|
|
2984
|
+
title: /* @__PURE__ */ jsx30(VerticalRhythm, { gap: "sm", children: tipLines.map((t, index) => /* @__PURE__ */ jsx30("div", { children: t }, index)) }),
|
|
2985
|
+
children: /* @__PURE__ */ jsx30("span", { children: chippy })
|
|
2986
|
+
}
|
|
2987
|
+
);
|
|
2988
|
+
}
|
|
2989
|
+
return chippy;
|
|
2990
|
+
}
|
|
2991
|
+
function UndefinedVariableReference({ children }) {
|
|
2977
2992
|
return /* @__PURE__ */ jsx30(
|
|
2978
|
-
|
|
2993
|
+
"span",
|
|
2979
2994
|
{
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
children: /* @__PURE__ */ jsx30(Wrapper, { children: displayName || reference })
|
|
2995
|
+
style: {
|
|
2996
|
+
textDecoration: "underline",
|
|
2997
|
+
textDecorationStyle: "wavy",
|
|
2998
|
+
textDecorationColor: "var(--error)"
|
|
2999
|
+
},
|
|
3000
|
+
children
|
|
2987
3001
|
}
|
|
2988
3002
|
);
|
|
2989
3003
|
}
|
|
2990
|
-
function
|
|
3004
|
+
function InfoVariableReference({ children }) {
|
|
2991
3005
|
return /* @__PURE__ */ jsx30(
|
|
2992
3006
|
"span",
|
|
2993
3007
|
{
|
|
2994
3008
|
style: {
|
|
2995
3009
|
textDecoration: "underline",
|
|
2996
3010
|
textDecorationStyle: "wavy",
|
|
2997
|
-
textDecorationColor: "
|
|
3011
|
+
textDecorationColor: "var(--primary-action-default)"
|
|
2998
3012
|
},
|
|
2999
3013
|
children
|
|
3000
3014
|
}
|
|
3001
3015
|
);
|
|
3002
3016
|
}
|
|
3003
|
-
function
|
|
3017
|
+
function WarningVariableReference({ children }) {
|
|
3004
3018
|
return /* @__PURE__ */ jsx30(
|
|
3005
3019
|
"span",
|
|
3006
3020
|
{
|
|
3007
3021
|
style: {
|
|
3008
3022
|
textDecoration: "underline",
|
|
3009
3023
|
textDecorationStyle: "wavy",
|
|
3010
|
-
textDecorationColor: "
|
|
3024
|
+
textDecorationColor: "var(--alert)"
|
|
3011
3025
|
},
|
|
3012
3026
|
children
|
|
3013
3027
|
}
|
|
@@ -3037,7 +3051,7 @@ import {
|
|
|
3037
3051
|
COMMAND_PRIORITY_NORMAL,
|
|
3038
3052
|
createCommand
|
|
3039
3053
|
} from "lexical";
|
|
3040
|
-
import { useCallback as useCallback2, useEffect as
|
|
3054
|
+
import { useCallback as useCallback2, useEffect as useEffect8, useMemo as useMemo8, useRef as useRef10, useState as useState10 } from "react";
|
|
3041
3055
|
import { createPortal } from "react-dom";
|
|
3042
3056
|
|
|
3043
3057
|
// src/components/Variables/toolbox/SelectVariableMenu.styles.ts
|
|
@@ -3071,7 +3085,7 @@ var variablesTipText = css18`
|
|
|
3071
3085
|
|
|
3072
3086
|
// src/components/Variables/VariablesProvider.tsx
|
|
3073
3087
|
import mitt from "mitt";
|
|
3074
|
-
import { createContext as createContext3, useContext as useContext5, useMemo as useMemo7, useState as useState9 } from "react";
|
|
3088
|
+
import { createContext as createContext3, useContext as useContext5, useEffect as useEffect7, useMemo as useMemo7, useState as useState9 } from "react";
|
|
3075
3089
|
|
|
3076
3090
|
// src/components/Variables/util/useVariableEditTransaction.ts
|
|
3077
3091
|
import { useCallback, useEffect as useEffect6, useState as useState8 } from "react";
|
|
@@ -3268,7 +3282,8 @@ function VariablesProvider({
|
|
|
3268
3282
|
readOnly,
|
|
3269
3283
|
isLoading,
|
|
3270
3284
|
children,
|
|
3271
|
-
knownUndefinedValues = {}
|
|
3285
|
+
knownUndefinedValues = {},
|
|
3286
|
+
onChangeKnownUndefinedValue
|
|
3272
3287
|
}) {
|
|
3273
3288
|
const [editing, setEditing] = useState9();
|
|
3274
3289
|
const [editingContext, setEditingContext] = useState9();
|
|
@@ -3335,6 +3350,15 @@ function VariablesProvider({
|
|
|
3335
3350
|
isLoading: !!isLoading
|
|
3336
3351
|
};
|
|
3337
3352
|
}, [valueBasedContextValue, editVariableTxn, editing, events, knownUndefinedValues, isLoading]);
|
|
3353
|
+
useEffect7(() => {
|
|
3354
|
+
if (editing === void 0) {
|
|
3355
|
+
return;
|
|
3356
|
+
}
|
|
3357
|
+
const activeElement = document.activeElement;
|
|
3358
|
+
if (activeElement && "blur" in activeElement && typeof activeElement.blur === "function") {
|
|
3359
|
+
activeElement.blur();
|
|
3360
|
+
}
|
|
3361
|
+
}, [editing]);
|
|
3338
3362
|
return /* @__PURE__ */ jsxs17(VariablesContext.Provider, { value: contextValue, children: [
|
|
3339
3363
|
children,
|
|
3340
3364
|
typeof editing !== "undefined" ? /* @__PURE__ */ jsx32(
|
|
@@ -3343,9 +3367,19 @@ function VariablesProvider({
|
|
|
3343
3367
|
context: editingContext,
|
|
3344
3368
|
onSubmit: (val, editorCompletedContext) => {
|
|
3345
3369
|
contextValue.dispatch({ type: "cancelEdit" });
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3370
|
+
if ("resultType" in val) {
|
|
3371
|
+
if (!onChangeKnownUndefinedValue) {
|
|
3372
|
+
throw new Error(
|
|
3373
|
+
"onChangeKnownUndefinedValue must be provided to handle known-undefined-value results"
|
|
3374
|
+
);
|
|
3375
|
+
}
|
|
3376
|
+
const { name, ...kuv } = val;
|
|
3377
|
+
onChangeKnownUndefinedValue(val.name, kuv);
|
|
3378
|
+
} else {
|
|
3379
|
+
const { name, ...varValue } = val;
|
|
3380
|
+
const latestValue = { ...value, [name]: varValue };
|
|
3381
|
+
onChange == null ? void 0 : onChange(latestValue);
|
|
3382
|
+
}
|
|
3349
3383
|
events.emit("editCompleted", {
|
|
3350
3384
|
canceled: false,
|
|
3351
3385
|
selectedVariable: val,
|
|
@@ -3628,7 +3662,7 @@ function VariablesPlugin({
|
|
|
3628
3662
|
},
|
|
3629
3663
|
[editor, onSelect, queryString, replaceValueOnVariableInsert]
|
|
3630
3664
|
);
|
|
3631
|
-
|
|
3665
|
+
useEffect8(() => {
|
|
3632
3666
|
return mergeRegister(
|
|
3633
3667
|
editor.registerCommand(
|
|
3634
3668
|
EDIT_VARIABLE_COMMAND,
|
|
@@ -3760,21 +3794,21 @@ function VariablesPlugin({
|
|
|
3760
3794
|
]);
|
|
3761
3795
|
const updateExistingNodeIfChanged = useCallback2(
|
|
3762
3796
|
(variableNode) => {
|
|
3763
|
-
var _a, _b, _c;
|
|
3797
|
+
var _a, _b, _c, _d;
|
|
3764
3798
|
const targetVar = variablesRef.current.variables[variableNode.reference];
|
|
3765
3799
|
const targetUndefinedVar = variablesRef.current.knownUndefinedValues[variableNode.reference];
|
|
3766
3800
|
const isLoadingVariables = variablesRef.current.isLoading;
|
|
3767
3801
|
const currentState = variableNode.getState();
|
|
3768
|
-
if (currentState.isFresh && !targetVar) {
|
|
3802
|
+
if (currentState.isFresh && !targetVar && !targetUndefinedVar) {
|
|
3769
3803
|
return;
|
|
3770
3804
|
}
|
|
3771
|
-
const tooltip = (_c = (_b = (_a = targetVar == null ? void 0 : targetVar.tooltip) != null ? _a : targetVar == null ? void 0 : targetVar.helpText) != null ? _b : targetUndefinedVar == null ? void 0 : targetUndefinedVar.error) != null ? _c : targetUndefinedVar == null ? void 0 : targetUndefinedVar.info;
|
|
3805
|
+
const tooltip = (_d = (_c = (_b = (_a = targetVar == null ? void 0 : targetVar.tooltip) != null ? _a : targetVar == null ? void 0 : targetVar.helpText) != null ? _b : targetUndefinedVar == null ? void 0 : targetUndefinedVar.error) != null ? _c : targetUndefinedVar == null ? void 0 : targetUndefinedVar.warning) != null ? _d : targetUndefinedVar == null ? void 0 : targetUndefinedVar.info;
|
|
3772
3806
|
const newState = {
|
|
3773
3807
|
...currentState,
|
|
3774
3808
|
displayName: (targetVar == null ? void 0 : targetVar.displayName) || (targetUndefinedVar == null ? void 0 : targetUndefinedVar.displayName) || variableNode.reference,
|
|
3775
3809
|
isLoading: isLoadingVariables && !targetVar && !(targetUndefinedVar == null ? void 0 : targetUndefinedVar.info),
|
|
3776
3810
|
hasClickEvent: canEditVariable(variableNode.reference, targetVar),
|
|
3777
|
-
referenceIsValid: (targetUndefinedVar == null ? void 0 : targetUndefinedVar.info) ? "info" : isLoadingVariables ? true : Boolean(targetVar),
|
|
3811
|
+
referenceIsValid: (targetUndefinedVar == null ? void 0 : targetUndefinedVar.error) ? false : (targetUndefinedVar == null ? void 0 : targetUndefinedVar.warning) ? "warning" : (targetUndefinedVar == null ? void 0 : targetUndefinedVar.info) ? "info" : isLoadingVariables ? true : Boolean(targetVar),
|
|
3778
3812
|
tooltip,
|
|
3779
3813
|
isFresh: false
|
|
3780
3814
|
};
|
|
@@ -3784,14 +3818,14 @@ function VariablesPlugin({
|
|
|
3784
3818
|
},
|
|
3785
3819
|
[canEditVariable]
|
|
3786
3820
|
);
|
|
3787
|
-
|
|
3821
|
+
useEffect8(() => {
|
|
3788
3822
|
editor.update(() => {
|
|
3789
3823
|
$nodesOfType2(VariableNode).forEach((variableNode) => {
|
|
3790
3824
|
updateExistingNodeIfChanged(variableNode);
|
|
3791
3825
|
});
|
|
3792
3826
|
});
|
|
3793
|
-
}, [editor, variables, canEditVariable, updateExistingNodeIfChanged]);
|
|
3794
|
-
|
|
3827
|
+
}, [editor, variables, knownUndefinedValues, canEditVariable, updateExistingNodeIfChanged]);
|
|
3828
|
+
useEffect8(() => {
|
|
3795
3829
|
return editor.registerNodeTransform(VariableNode, (variableNode) => {
|
|
3796
3830
|
updateExistingNodeIfChanged(variableNode);
|
|
3797
3831
|
});
|
|
@@ -3970,7 +4004,7 @@ function VariableNodeComponent({
|
|
|
3970
4004
|
},
|
|
3971
4005
|
[isSelected, nodeKey]
|
|
3972
4006
|
);
|
|
3973
|
-
|
|
4007
|
+
useEffect9(() => {
|
|
3974
4008
|
return mergeRegister2(
|
|
3975
4009
|
editor.registerCommand(KEY_DELETE_COMMAND, onDelete, COMMAND_PRIORITY_LOW),
|
|
3976
4010
|
editor.registerCommand(KEY_BACKSPACE_COMMAND, onDelete, COMMAND_PRIORITY_LOW),
|
|
@@ -4087,10 +4121,10 @@ function EditorRefPlugin({
|
|
|
4087
4121
|
import { useLexicalComposerContext as useLexicalComposerContext5 } from "@lexical/react/LexicalComposerContext";
|
|
4088
4122
|
import { mergeRegister as mergeRegister3 } from "@lexical/utils";
|
|
4089
4123
|
import { $getSelection as $getSelection3, $isRangeSelection as $isRangeSelection2, COMMAND_PRIORITY_HIGH, PASTE_COMMAND } from "lexical";
|
|
4090
|
-
import { useEffect as
|
|
4124
|
+
import { useEffect as useEffect10 } from "react";
|
|
4091
4125
|
function PasteTransformerPlugin({ transformPaste }) {
|
|
4092
4126
|
const [editor] = useLexicalComposerContext5();
|
|
4093
|
-
|
|
4127
|
+
useEffect10(() => {
|
|
4094
4128
|
return mergeRegister3(
|
|
4095
4129
|
editor.registerCommand(
|
|
4096
4130
|
PASTE_COMMAND,
|
|
@@ -4554,10 +4588,10 @@ import { useMemo as useMemo10, useRef as useRef12, useState as useState12 } from
|
|
|
4554
4588
|
|
|
4555
4589
|
// src/components/Variables/composer/DisablePlugin.tsx
|
|
4556
4590
|
import { useLexicalComposerContext as useLexicalComposerContext7 } from "@lexical/react/LexicalComposerContext";
|
|
4557
|
-
import { useEffect as
|
|
4591
|
+
import { useEffect as useEffect12 } from "react";
|
|
4558
4592
|
function DisablePlugin({ disabled }) {
|
|
4559
4593
|
const [editor] = useLexicalComposerContext7();
|
|
4560
|
-
|
|
4594
|
+
useEffect12(() => {
|
|
4561
4595
|
editor.setEditable(!disabled);
|
|
4562
4596
|
}, [editor, disabled]);
|
|
4563
4597
|
return null;
|
|
@@ -4566,10 +4600,10 @@ function DisablePlugin({ disabled }) {
|
|
|
4566
4600
|
// src/components/Variables/composer/SingleLineTextPlugin.tsx
|
|
4567
4601
|
import { useLexicalComposerContext as useLexicalComposerContext8 } from "@lexical/react/LexicalComposerContext";
|
|
4568
4602
|
import { LineBreakNode } from "lexical";
|
|
4569
|
-
import { useEffect as
|
|
4603
|
+
import { useEffect as useEffect13 } from "react";
|
|
4570
4604
|
function SingleLineTextPlugin() {
|
|
4571
4605
|
const [editor] = useLexicalComposerContext8();
|
|
4572
|
-
|
|
4606
|
+
useEffect13(() => {
|
|
4573
4607
|
editor.registerNodeTransform(LineBreakNode, (node) => {
|
|
4574
4608
|
node.remove();
|
|
4575
4609
|
});
|
|
@@ -4691,10 +4725,10 @@ import {
|
|
|
4691
4725
|
CUT_COMMAND,
|
|
4692
4726
|
PASTE_COMMAND as PASTE_COMMAND2
|
|
4693
4727
|
} from "lexical";
|
|
4694
|
-
import { useEffect as
|
|
4728
|
+
import { useEffect as useEffect14 } from "react";
|
|
4695
4729
|
import { Fragment as Fragment9, jsx as jsx39, jsxs as jsxs22 } from "@emotion/react/jsx-runtime";
|
|
4696
4730
|
function VariablesComposerInput({
|
|
4697
|
-
css:
|
|
4731
|
+
css: css39,
|
|
4698
4732
|
placeholder,
|
|
4699
4733
|
...contentEditableProps
|
|
4700
4734
|
}) {
|
|
@@ -4713,7 +4747,7 @@ function VariablesComposerInput({
|
|
|
4713
4747
|
}
|
|
4714
4748
|
function RichishCopyAndPastePlugin() {
|
|
4715
4749
|
const [editor] = useLexicalComposerContext9();
|
|
4716
|
-
|
|
4750
|
+
useEffect14(() => {
|
|
4717
4751
|
return mergeRegister4(
|
|
4718
4752
|
editor.registerCommand(
|
|
4719
4753
|
COPY_COMMAND,
|
|
@@ -4815,7 +4849,8 @@ function InputVariables(props) {
|
|
|
4815
4849
|
editorRef,
|
|
4816
4850
|
filterVariable,
|
|
4817
4851
|
styleVariant = "default",
|
|
4818
|
-
renderMenuInPortal
|
|
4852
|
+
renderMenuInPortal,
|
|
4853
|
+
disableDismissEditorOnChange
|
|
4819
4854
|
} = props;
|
|
4820
4855
|
const [finalId] = useState13(id != null ? id : () => v42());
|
|
4821
4856
|
const { dispatch, canDispatch, isEditing } = useVariables(true);
|
|
@@ -4825,7 +4860,7 @@ function InputVariables(props) {
|
|
|
4825
4860
|
"div",
|
|
4826
4861
|
{
|
|
4827
4862
|
onKeyDown: () => {
|
|
4828
|
-
if (isEditing && canDispatch) {
|
|
4863
|
+
if (!disableDismissEditorOnChange && isEditing && canDispatch) {
|
|
4829
4864
|
dispatch({ type: "cancelEdit" });
|
|
4830
4865
|
}
|
|
4831
4866
|
},
|
|
@@ -5012,7 +5047,7 @@ import { useCallback as useCallback4 } from "react";
|
|
|
5012
5047
|
import { useLexicalComposerContext as useLexicalComposerContext10 } from "@lexical/react/LexicalComposerContext";
|
|
5013
5048
|
import { mergeRegister as mergeRegister5 } from "@lexical/utils";
|
|
5014
5049
|
import { $getNodeByKey as $getNodeByKey3, COMMAND_PRIORITY_HIGH as COMMAND_PRIORITY_HIGH3 } from "lexical";
|
|
5015
|
-
import { useEffect as
|
|
5050
|
+
import { useEffect as useEffect15, useRef as useRef13 } from "react";
|
|
5016
5051
|
function OnDisconnectPlugin({
|
|
5017
5052
|
onDisconnect
|
|
5018
5053
|
}) {
|
|
@@ -5020,7 +5055,7 @@ function OnDisconnectPlugin({
|
|
|
5020
5055
|
const { variables } = useVariables(true);
|
|
5021
5056
|
const variablesRef = useRef13(variables);
|
|
5022
5057
|
variablesRef.current = variables;
|
|
5023
|
-
|
|
5058
|
+
useEffect15(() => {
|
|
5024
5059
|
return mergeRegister5(
|
|
5025
5060
|
editor.registerCommand(
|
|
5026
5061
|
DISCONNECT_VARIABLE_COMMAND,
|
|
@@ -5157,19 +5192,17 @@ function ParameterVariables(props) {
|
|
|
5157
5192
|
children: [
|
|
5158
5193
|
editorRef ? /* @__PURE__ */ jsx43(EditorRefPlugin, { editorRef }) : null,
|
|
5159
5194
|
/* @__PURE__ */ jsx43(ControlledValuePlugin, { value, enabled: useInputWhenNoVariables }),
|
|
5160
|
-
/* @__PURE__ */ jsxs26(
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
|
-
|
|
5165
|
-
|
|
5166
|
-
|
|
5167
|
-
|
|
5168
|
-
|
|
5169
|
-
}
|
|
5170
|
-
|
|
5171
|
-
children: [
|
|
5172
|
-
/* @__PURE__ */ jsx43("div", { css: { flex: 1 }, children: useInputWhenNoVariables ? inputWhenNoVariables : /* @__PURE__ */ jsx43(
|
|
5195
|
+
/* @__PURE__ */ jsxs26(HorizontalRhythm7, { align: "center", gap: "xs", css: { width: "100%" }, children: [
|
|
5196
|
+
/* @__PURE__ */ jsx43(
|
|
5197
|
+
"div",
|
|
5198
|
+
{
|
|
5199
|
+
css: { flex: 1 },
|
|
5200
|
+
onKeyDown: () => {
|
|
5201
|
+
if (isEditing && canDispatch) {
|
|
5202
|
+
dispatch({ type: "cancelEdit" });
|
|
5203
|
+
}
|
|
5204
|
+
},
|
|
5205
|
+
children: useInputWhenNoVariables ? inputWhenNoVariables : /* @__PURE__ */ jsx43(
|
|
5173
5206
|
VariablesComposerInput,
|
|
5174
5207
|
{
|
|
5175
5208
|
"aria-label": ariaLabel,
|
|
@@ -5181,20 +5214,20 @@ function ParameterVariables(props) {
|
|
|
5181
5214
|
inputCss != null ? inputCss : css25``
|
|
5182
5215
|
]
|
|
5183
5216
|
}
|
|
5184
|
-
) }),
|
|
5185
|
-
disableVariablesForReals ? null : /* @__PURE__ */ jsx43(
|
|
5186
|
-
VariablesComposerVariableMenu,
|
|
5187
|
-
{
|
|
5188
|
-
...sharedMenuProps,
|
|
5189
|
-
buttonCss: [variableBindButton],
|
|
5190
|
-
tip: useInputWhenNoVariables ? void 0 : "Tip: access this list by typing $$",
|
|
5191
|
-
buttonProps: hasVariablesInValue ? { "aria-pressed": "true" } : void 0,
|
|
5192
|
-
replaceValueOnVariableInsert: useInputWhenNoVariables
|
|
5193
|
-
}
|
|
5194
5217
|
)
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5218
|
+
}
|
|
5219
|
+
),
|
|
5220
|
+
disableVariablesForReals ? null : /* @__PURE__ */ jsx43(
|
|
5221
|
+
VariablesComposerVariableMenu,
|
|
5222
|
+
{
|
|
5223
|
+
...sharedMenuProps,
|
|
5224
|
+
buttonCss: [variableBindButton],
|
|
5225
|
+
tip: useInputWhenNoVariables ? void 0 : "Tip: access this list by typing $$",
|
|
5226
|
+
buttonProps: hasVariablesInValue ? { "aria-pressed": "true" } : void 0,
|
|
5227
|
+
replaceValueOnVariableInsert: useInputWhenNoVariables
|
|
5228
|
+
}
|
|
5229
|
+
)
|
|
5230
|
+
] })
|
|
5198
5231
|
]
|
|
5199
5232
|
}
|
|
5200
5233
|
);
|
|
@@ -5202,7 +5235,7 @@ function ParameterVariables(props) {
|
|
|
5202
5235
|
|
|
5203
5236
|
// src/components/Variables/util/convertConnectedDataToVariable.ts
|
|
5204
5237
|
function convertConnectedDataToVariable(bindExpression, value) {
|
|
5205
|
-
const isValuePrimitive = typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
5238
|
+
const isValuePrimitive = typeof value === "string" && value.length > 0 || typeof value === "number" || typeof value === "boolean";
|
|
5206
5239
|
return {
|
|
5207
5240
|
ephemeral: true,
|
|
5208
5241
|
displayName: isValuePrimitive ? value.toString() : prettifyBindExpression(bindExpression),
|
|
@@ -5377,10 +5410,6 @@ function VariablesList() {
|
|
|
5377
5410
|
|
|
5378
5411
|
// src/components/DataResourceDynamicInputProvider.tsx
|
|
5379
5412
|
import { jsx as jsx45 } from "@emotion/react/jsx-runtime";
|
|
5380
|
-
var DataResourceInputContext = createContext4(void 0);
|
|
5381
|
-
var useDataResourceDynamicInputs = () => {
|
|
5382
|
-
return useContext6(DataResourceInputContext);
|
|
5383
|
-
};
|
|
5384
5413
|
function DataResourceDynamicInputProvider(props) {
|
|
5385
5414
|
const { children, dynamicInputs } = props;
|
|
5386
5415
|
if (dynamicInputs) {
|
|
@@ -5399,11 +5428,11 @@ function DataResourceDynamicInputProviderRenderer({
|
|
|
5399
5428
|
dynamicInputs
|
|
5400
5429
|
}) {
|
|
5401
5430
|
const variables = useDynamicInputsAsVariables(dynamicInputs);
|
|
5402
|
-
return /* @__PURE__ */ jsx45(
|
|
5431
|
+
return /* @__PURE__ */ jsx45(VariablesProvider, { value: variables, readOnly: true, children });
|
|
5403
5432
|
}
|
|
5404
5433
|
|
|
5405
5434
|
// src/components/DataResourceVariablesList.tsx
|
|
5406
|
-
import { Callout as Callout4, VerticalRhythm } from "@uniformdev/design-system";
|
|
5435
|
+
import { Callout as Callout4, VerticalRhythm as VerticalRhythm2 } from "@uniformdev/design-system";
|
|
5407
5436
|
import { jsx as jsx46 } from "@emotion/react/jsx-runtime";
|
|
5408
5437
|
function DataResourceVariablesList(props) {
|
|
5409
5438
|
const {
|
|
@@ -5435,7 +5464,7 @@ function DataResourceVariablesListExplicit({
|
|
|
5435
5464
|
}
|
|
5436
5465
|
return /* @__PURE__ */ jsx46(Callout4, { type: "note", children: "No settings are required." });
|
|
5437
5466
|
}
|
|
5438
|
-
return /* @__PURE__ */ jsx46(DataResourceDynamicInputProvider, { dynamicInputs, children: /* @__PURE__ */ jsx46(
|
|
5467
|
+
return /* @__PURE__ */ jsx46(DataResourceDynamicInputProvider, { dynamicInputs, children: /* @__PURE__ */ jsx46(VerticalRhythm2, { children: variableDefinitions.map((variableDefinition) => {
|
|
5439
5468
|
var _a, _b, _c;
|
|
5440
5469
|
const VariableRenderer = variableDefinition.type ? (_a = typeRenderers == null ? void 0 : typeRenderers[variableDefinition.type]) != null ? _a : TextVariableRenderer : TextVariableRenderer;
|
|
5441
5470
|
return /* @__PURE__ */ jsx46("div", { children: /* @__PURE__ */ jsx46(
|
|
@@ -6180,12 +6209,12 @@ import { LoadingIndicator as LoadingIndicator3, Theme as Theme2 } from "@uniform
|
|
|
6180
6209
|
|
|
6181
6210
|
// src/hooks/useInitializeUniformMeshSdk.ts
|
|
6182
6211
|
import { initializeUniformMeshSDK } from "@uniformdev/mesh-sdk";
|
|
6183
|
-
import { useEffect as
|
|
6212
|
+
import { useEffect as useEffect16, useRef as useRef14, useState as useState15 } from "react";
|
|
6184
6213
|
var useInitializeUniformMeshSdk = ({ autoResizingDisabled } = {}) => {
|
|
6185
6214
|
const [error, setError] = useState15();
|
|
6186
6215
|
const [sdk, setSdk] = useState15();
|
|
6187
6216
|
const initializationInProgress = useRef14(false);
|
|
6188
|
-
|
|
6217
|
+
useEffect16(
|
|
6189
6218
|
() => {
|
|
6190
6219
|
if (typeof window === "undefined" || sdk) {
|
|
6191
6220
|
return;
|
|
@@ -6266,23 +6295,22 @@ var DataRefreshButton = ({
|
|
|
6266
6295
|
};
|
|
6267
6296
|
|
|
6268
6297
|
// src/components/ObjectSearch/ObjectSearchContainer.tsx
|
|
6269
|
-
import { css as
|
|
6298
|
+
import { css as css33 } from "@emotion/react";
|
|
6270
6299
|
import { bindVariables } from "@uniformdev/canvas";
|
|
6271
|
-
import { Callout as Callout5, Container, IconsProvider, ScrollableList, VerticalRhythm as
|
|
6272
|
-
import React12 from "react";
|
|
6300
|
+
import { Callout as Callout5, Container, IconsProvider, ScrollableList, VerticalRhythm as VerticalRhythm3 } from "@uniformdev/design-system";
|
|
6273
6301
|
|
|
6274
6302
|
// src/components/ObjectSearch/hooks/ObjectSearchContext.tsx
|
|
6275
6303
|
import { bindVariablesToObject as bindVariablesToObject2 } from "@uniformdev/canvas";
|
|
6276
6304
|
import {
|
|
6277
|
-
createContext as
|
|
6305
|
+
createContext as createContext5,
|
|
6278
6306
|
useCallback as useCallback5,
|
|
6279
|
-
useContext as
|
|
6307
|
+
useContext as useContext7,
|
|
6280
6308
|
useDeferredValue,
|
|
6281
6309
|
useMemo as useMemo14,
|
|
6282
6310
|
useState as useState16
|
|
6283
6311
|
} from "react";
|
|
6284
6312
|
import { jsx as jsx59 } from "@emotion/react/jsx-runtime";
|
|
6285
|
-
var ObjectSearchContext =
|
|
6313
|
+
var ObjectSearchContext = createContext5({
|
|
6286
6314
|
onSetQuery: () => {
|
|
6287
6315
|
},
|
|
6288
6316
|
onSelectItem: () => {
|
|
@@ -6290,6 +6318,8 @@ var ObjectSearchContext = createContext6({
|
|
|
6290
6318
|
query: {},
|
|
6291
6319
|
boundQuery: {},
|
|
6292
6320
|
list: {},
|
|
6321
|
+
onSetList: () => {
|
|
6322
|
+
},
|
|
6293
6323
|
selectedListItems: [],
|
|
6294
6324
|
onRemoveAllSelectedItems: () => {
|
|
6295
6325
|
},
|
|
@@ -6373,7 +6403,7 @@ var ObjectSearchProvider = ({
|
|
|
6373
6403
|
return /* @__PURE__ */ jsx59(ObjectSearchContext.Provider, { value, children });
|
|
6374
6404
|
};
|
|
6375
6405
|
function useObjectSearchContext() {
|
|
6376
|
-
return
|
|
6406
|
+
return useContext7(ObjectSearchContext);
|
|
6377
6407
|
}
|
|
6378
6408
|
function bindQuery(query, inputs) {
|
|
6379
6409
|
const { result, errors } = bindVariablesToObject2({
|
|
@@ -6477,11 +6507,6 @@ var ObjectSearchListItem = ({
|
|
|
6477
6507
|
isMulti,
|
|
6478
6508
|
disabled,
|
|
6479
6509
|
children,
|
|
6480
|
-
editLink,
|
|
6481
|
-
editLinkIcon,
|
|
6482
|
-
createdAt,
|
|
6483
|
-
publishStatus,
|
|
6484
|
-
publishedAt,
|
|
6485
6510
|
...props
|
|
6486
6511
|
}) => {
|
|
6487
6512
|
const { onSelectItem, selectedListItems, isMulti: globalIsMulti } = useObjectSearchContext();
|
|
@@ -6534,18 +6559,201 @@ var ObjectSearchListItemLoadingSkeleton = () => {
|
|
|
6534
6559
|
return /* @__PURE__ */ jsx60("div", { role: "presentation", css: [ObjectListItemContainer, ObjectListItemLoading] });
|
|
6535
6560
|
};
|
|
6536
6561
|
|
|
6537
|
-
// src/components/ObjectSearch/
|
|
6538
|
-
import {
|
|
6539
|
-
|
|
6562
|
+
// src/components/ObjectSearch/ObjectSearchContainer.tsx
|
|
6563
|
+
import { jsx as jsx61, jsxs as jsxs35 } from "@emotion/react/jsx-runtime";
|
|
6564
|
+
var ObjectSearchContainer = ({
|
|
6565
|
+
label,
|
|
6566
|
+
enableDynamicInputToResultId,
|
|
6567
|
+
searchFilters,
|
|
6568
|
+
resultList,
|
|
6569
|
+
children
|
|
6570
|
+
}) => {
|
|
6571
|
+
var _a, _b;
|
|
6572
|
+
const { onSelectItem, selectedListItems, list } = useObjectSearchContext();
|
|
6573
|
+
const { flatVariables } = useVariables(true);
|
|
6574
|
+
const inputValue = (_b = (_a = selectedListItems == null ? void 0 : selectedListItems[0]) == null ? void 0 : _a.id) != null ? _b : "";
|
|
6575
|
+
const listItems = resultList != null ? resultList : /* @__PURE__ */ jsx61(
|
|
6576
|
+
ScrollableList,
|
|
6577
|
+
{
|
|
6578
|
+
role: "list",
|
|
6579
|
+
css: css33`
|
|
6580
|
+
> div {
|
|
6581
|
+
transition: max-height var(--duration-slow) var(--timing-ease-out);
|
|
6582
|
+
max-height: ${selectedListItems.length === 0 ? "50vh" : "184px"};
|
|
6583
|
+
}
|
|
6584
|
+
`,
|
|
6585
|
+
children: /* @__PURE__ */ jsx61(DefaultResultList, {})
|
|
6586
|
+
}
|
|
6587
|
+
);
|
|
6588
|
+
const body = /* @__PURE__ */ jsxs35(VerticalRhythm3, { children: [
|
|
6589
|
+
searchFilters,
|
|
6590
|
+
listItems
|
|
6591
|
+
] });
|
|
6592
|
+
const handleSelectedVariableChange = (selectedValue) => {
|
|
6593
|
+
var _a2;
|
|
6594
|
+
if (!selectedValue) {
|
|
6595
|
+
onSelectItem([]);
|
|
6596
|
+
return;
|
|
6597
|
+
}
|
|
6598
|
+
const { result, errors } = bindVariables({
|
|
6599
|
+
value: selectedValue,
|
|
6600
|
+
variables: flatVariables,
|
|
6601
|
+
errorPrefix: "Dynamic input"
|
|
6602
|
+
});
|
|
6603
|
+
if (!result) {
|
|
6604
|
+
onSelectItem([]);
|
|
6605
|
+
return;
|
|
6606
|
+
}
|
|
6607
|
+
const item = (_a2 = list.items) == null ? void 0 : _a2.find((i) => i.id === result);
|
|
6608
|
+
onSelectItem([
|
|
6609
|
+
{
|
|
6610
|
+
title: selectedValue,
|
|
6611
|
+
contentType: (errors == null ? void 0 : errors.length) ? errors[0] instanceof Error ? errors[0].message : errors[0] : `Current dynamic value "${result}" is not an ID in the options`,
|
|
6612
|
+
// spread any matched list item, overriding the above default props
|
|
6613
|
+
...item,
|
|
6614
|
+
// we want to make sure the ID is our dynamic value
|
|
6615
|
+
id: selectedValue
|
|
6616
|
+
}
|
|
6617
|
+
]);
|
|
6618
|
+
};
|
|
6619
|
+
return /* @__PURE__ */ jsx61(IconsProvider, { children: /* @__PURE__ */ jsxs35(VerticalRhythm3, { children: [
|
|
6620
|
+
/* @__PURE__ */ jsx61(Container, { backgroundColor: "gray-50", padding: "var(--spacing-base)", border: true, children: label ? /* @__PURE__ */ jsx61(
|
|
6621
|
+
InputVariables,
|
|
6622
|
+
{
|
|
6623
|
+
label,
|
|
6624
|
+
value: inputValue,
|
|
6625
|
+
onChange: (value) => {
|
|
6626
|
+
if (value === inputValue) {
|
|
6627
|
+
return;
|
|
6628
|
+
}
|
|
6629
|
+
handleSelectedVariableChange(value);
|
|
6630
|
+
},
|
|
6631
|
+
inputWhenNoVariables: body,
|
|
6632
|
+
disableVariables: !enableDynamicInputToResultId
|
|
6633
|
+
}
|
|
6634
|
+
) : body }),
|
|
6635
|
+
children
|
|
6636
|
+
] }) });
|
|
6637
|
+
};
|
|
6638
|
+
var DefaultResultList = () => {
|
|
6639
|
+
var _a;
|
|
6640
|
+
const { list } = useObjectSearchContext();
|
|
6641
|
+
if (!list.items) {
|
|
6642
|
+
return Array.from(Array(5).keys()).map((i) => /* @__PURE__ */ jsx61(ObjectSearchListItemLoadingSkeleton, {}, i));
|
|
6643
|
+
}
|
|
6644
|
+
if (list.items.length === 0) {
|
|
6645
|
+
return /* @__PURE__ */ jsx61(Callout5, { type: "info", children: "No results were found" });
|
|
6646
|
+
}
|
|
6647
|
+
return (_a = list.items) == null ? void 0 : _a.map((item) => /* @__PURE__ */ jsx61(ObjectSearchListItem, { ...item }, item.id));
|
|
6648
|
+
};
|
|
6649
|
+
|
|
6650
|
+
// src/components/ObjectSearch/ObjectSearchFilter.tsx
|
|
6651
|
+
import { DebouncedInputKeywordSearch, InputSelect as InputSelect6 } from "@uniformdev/design-system";
|
|
6652
|
+
import { useMemo as useMemo15, useState as useState17 } from "react";
|
|
6653
|
+
|
|
6654
|
+
// src/components/ObjectSearch/styles/ObjectSearchFilterContainer.styles.ts
|
|
6655
|
+
import { css as css34 } from "@emotion/react";
|
|
6656
|
+
var ObjectSearchFilterContainerLabel = css34`
|
|
6657
|
+
align-items: center;
|
|
6658
|
+
display: flex;
|
|
6659
|
+
font-size: var(--fs-sm);
|
|
6660
|
+
font-weight: var(--fw-bold);
|
|
6661
|
+
line-height: 1rem;
|
|
6662
|
+
margin-bottom: var(--spacing-sm);
|
|
6663
|
+
`;
|
|
6664
|
+
var ObjectSearchFilterContainer = css34`
|
|
6665
|
+
display: grid;
|
|
6666
|
+
gap: var(--spacing-base);
|
|
6667
|
+
`;
|
|
6668
|
+
var ObjectSearchFilterGrid = (gridColumns) => css34`
|
|
6669
|
+
display: grid;
|
|
6670
|
+
grid-template-columns: ${gridColumns};
|
|
6671
|
+
gap: var(--spacing-base);
|
|
6672
|
+
`;
|
|
6673
|
+
|
|
6674
|
+
// src/components/ObjectSearch/ObjectSearchFilter.tsx
|
|
6675
|
+
import { jsx as jsx62, jsxs as jsxs36 } from "@emotion/react/jsx-runtime";
|
|
6676
|
+
var ObjectSearchFilter = ({
|
|
6677
|
+
requireContentType,
|
|
6678
|
+
typeSelectorAllTypesOptionText = "All content types",
|
|
6679
|
+
searchInputName = "searchText",
|
|
6680
|
+
searchInputPlaceholderText = "Enter keyword to narrow your results",
|
|
6681
|
+
selectLabel = "Content Type Select",
|
|
6682
|
+
selectOptions
|
|
6683
|
+
}) => {
|
|
6684
|
+
var _a, _b;
|
|
6685
|
+
const { query, onSetQuery } = useObjectSearchContext();
|
|
6686
|
+
const [searchState, setSearchState] = useState17({
|
|
6687
|
+
contentType: (_a = query.contentType) != null ? _a : "",
|
|
6688
|
+
keyword: (_b = query.keyword) != null ? _b : ""
|
|
6689
|
+
});
|
|
6690
|
+
const handleFilterChange = (value) => {
|
|
6691
|
+
setSearchState((prev) => {
|
|
6692
|
+
return { ...prev, ...value };
|
|
6693
|
+
});
|
|
6694
|
+
onSetQuery({ ...query, ...value });
|
|
6695
|
+
};
|
|
6696
|
+
const memoizedSelectOptions = useMemo15(() => {
|
|
6697
|
+
if (!requireContentType && !(selectOptions == null ? void 0 : selectOptions.length)) {
|
|
6698
|
+
return [];
|
|
6699
|
+
}
|
|
6700
|
+
return [
|
|
6701
|
+
...!requireContentType ? [{ value: "any", label: typeSelectorAllTypesOptionText }] : [],
|
|
6702
|
+
...selectOptions != null ? selectOptions : []
|
|
6703
|
+
];
|
|
6704
|
+
}, [requireContentType, typeSelectorAllTypesOptionText, selectOptions]);
|
|
6705
|
+
const shouldRenderSelect = memoizedSelectOptions.length > 0;
|
|
6706
|
+
return /* @__PURE__ */ jsxs36(
|
|
6707
|
+
"fieldset",
|
|
6708
|
+
{
|
|
6709
|
+
css: [
|
|
6710
|
+
ObjectSearchFilterContainer,
|
|
6711
|
+
ObjectSearchFilterGrid(shouldRenderSelect ? "1fr 2fr" : "1fr")
|
|
6712
|
+
],
|
|
6713
|
+
children: [
|
|
6714
|
+
memoizedSelectOptions.length ? /* @__PURE__ */ jsx62(
|
|
6715
|
+
InputSelect6,
|
|
6716
|
+
{
|
|
6717
|
+
label: selectLabel,
|
|
6718
|
+
showLabel: false,
|
|
6719
|
+
onChange: (e) => handleFilterChange({ contentType: e.target.value }),
|
|
6720
|
+
options: memoizedSelectOptions,
|
|
6721
|
+
value: query.contentType
|
|
6722
|
+
}
|
|
6723
|
+
) : null,
|
|
6724
|
+
/* @__PURE__ */ jsx62(
|
|
6725
|
+
DebouncedInputKeywordSearch,
|
|
6726
|
+
{
|
|
6727
|
+
inputFieldName: searchInputName,
|
|
6728
|
+
placeholder: searchInputPlaceholderText,
|
|
6729
|
+
onSearchTextChanged: (keyword) => handleFilterChange({ keyword }),
|
|
6730
|
+
disabledFieldSubmission: true,
|
|
6731
|
+
defaultValue: searchState.keyword,
|
|
6732
|
+
delay: 300
|
|
6733
|
+
}
|
|
6734
|
+
)
|
|
6735
|
+
]
|
|
6736
|
+
}
|
|
6737
|
+
);
|
|
6738
|
+
};
|
|
6739
|
+
|
|
6740
|
+
// src/components/ObjectSearch/ObjectSearchFilterContainer.tsx
|
|
6741
|
+
import { jsx as jsx63, jsxs as jsxs37 } from "@emotion/react/jsx-runtime";
|
|
6742
|
+
var ObjectSearchFilterContainer2 = ({ label, children }) => {
|
|
6743
|
+
return /* @__PURE__ */ jsxs37("div", { children: [
|
|
6744
|
+
label ? /* @__PURE__ */ jsx63("span", { css: ObjectSearchFilterContainerLabel, children: label }) : null,
|
|
6745
|
+
/* @__PURE__ */ jsx63("div", { css: ObjectSearchFilterContainer, children })
|
|
6746
|
+
] });
|
|
6747
|
+
};
|
|
6540
6748
|
|
|
6541
6749
|
// src/components/ObjectSearch/ObjectSearchResultItem.tsx
|
|
6542
6750
|
import { Badge, Button as Button4, Popover as Popover2 } from "@uniformdev/design-system";
|
|
6543
6751
|
import { format as timeagoFormat } from "timeago.js";
|
|
6544
6752
|
|
|
6545
6753
|
// src/components/ObjectSearch/styles/ObjectSearchResultItemButton.styles.ts
|
|
6546
|
-
import { css as
|
|
6754
|
+
import { css as css35 } from "@emotion/react";
|
|
6547
6755
|
import { button as button2 } from "@uniformdev/design-system";
|
|
6548
|
-
var ButtonStyles =
|
|
6756
|
+
var ButtonStyles = css35`
|
|
6549
6757
|
${button2}
|
|
6550
6758
|
background: transparent;
|
|
6551
6759
|
border: 1px solid var(--typography-base);
|
|
@@ -6572,20 +6780,20 @@ var ButtonStyles = css33`
|
|
|
6572
6780
|
text-decoration: none;
|
|
6573
6781
|
}
|
|
6574
6782
|
`;
|
|
6575
|
-
var ButtonIcon =
|
|
6783
|
+
var ButtonIcon = css35`
|
|
6576
6784
|
width: 1rem;
|
|
6577
6785
|
height: 1rem;
|
|
6578
6786
|
`;
|
|
6579
6787
|
|
|
6580
6788
|
// src/components/ObjectSearch/ObjectSearchResultItemButton.tsx
|
|
6581
|
-
import { jsx as
|
|
6789
|
+
import { jsx as jsx64, jsxs as jsxs38 } from "@emotion/react/jsx-runtime";
|
|
6582
6790
|
var ObjectSearchResultItemButton = ({
|
|
6583
6791
|
text,
|
|
6584
6792
|
icon,
|
|
6585
6793
|
...props
|
|
6586
6794
|
}) => {
|
|
6587
|
-
return /* @__PURE__ */
|
|
6588
|
-
!icon ? null : /* @__PURE__ */
|
|
6795
|
+
return /* @__PURE__ */ jsxs38("button", { type: "button", css: ButtonStyles, ...props, children: [
|
|
6796
|
+
!icon ? null : /* @__PURE__ */ jsx64(Image, { src: icon, css: ButtonIcon }),
|
|
6589
6797
|
text
|
|
6590
6798
|
] });
|
|
6591
6799
|
};
|
|
@@ -6594,15 +6802,15 @@ var LinkButton = ({
|
|
|
6594
6802
|
icon,
|
|
6595
6803
|
...props
|
|
6596
6804
|
}) => {
|
|
6597
|
-
return /* @__PURE__ */
|
|
6598
|
-
!icon ? null : /* @__PURE__ */
|
|
6805
|
+
return /* @__PURE__ */ jsxs38("a", { ...props, css: ButtonStyles, target: "_blank", rel: "noopener noreferrer", children: [
|
|
6806
|
+
!icon ? null : /* @__PURE__ */ jsx64(Image, { src: icon, css: ButtonIcon }),
|
|
6599
6807
|
text
|
|
6600
6808
|
] });
|
|
6601
6809
|
};
|
|
6602
6810
|
|
|
6603
6811
|
// src/components/ObjectSearch/styles/ObjectSearchResultItem.styles.ts
|
|
6604
|
-
import { css as
|
|
6605
|
-
var ObjectSearchResultItemContainer =
|
|
6812
|
+
import { css as css36 } from "@emotion/react";
|
|
6813
|
+
var ObjectSearchResultItemContainer = css36`
|
|
6606
6814
|
align-items: center;
|
|
6607
6815
|
border: 1px solid var(--gray-300);
|
|
6608
6816
|
border-radius: var(--rounded-base);
|
|
@@ -6618,7 +6826,7 @@ var ObjectSearchResultItemContainer = css34`
|
|
|
6618
6826
|
}
|
|
6619
6827
|
}
|
|
6620
6828
|
`;
|
|
6621
|
-
var ObjectSearchDragHandle =
|
|
6829
|
+
var ObjectSearchDragHandle = css36`
|
|
6622
6830
|
border-left: 2px dotted var(--gray-300);
|
|
6623
6831
|
border-right: 2px dotted var(--gray-300);
|
|
6624
6832
|
position: absolute;
|
|
@@ -6627,41 +6835,41 @@ var ObjectSearchDragHandle = css34`
|
|
|
6627
6835
|
transition: opacity var(--duration-fast) var(--timing-ease-out);
|
|
6628
6836
|
opacity: 0;
|
|
6629
6837
|
`;
|
|
6630
|
-
var ObjectSearchResultItemSubtitle =
|
|
6838
|
+
var ObjectSearchResultItemSubtitle = css36`
|
|
6631
6839
|
color: var(--gray-500);
|
|
6632
6840
|
display: block;
|
|
6633
6841
|
font-size: var(--fs-xs);
|
|
6634
6842
|
line-height: 1;
|
|
6635
6843
|
`;
|
|
6636
|
-
var ObjectSearchResultItemTitle =
|
|
6844
|
+
var ObjectSearchResultItemTitle = css36`
|
|
6637
6845
|
align-items: center;
|
|
6638
6846
|
color: var(--typography-base);
|
|
6639
6847
|
display: flex;
|
|
6640
6848
|
gap: var(--spacing-xs);
|
|
6641
6849
|
`;
|
|
6642
|
-
var ObjectSearchResultItemTimeStamp =
|
|
6850
|
+
var ObjectSearchResultItemTimeStamp = css36`
|
|
6643
6851
|
color: var(--gray-500);
|
|
6644
6852
|
font-size: var(--fs-xs);
|
|
6645
6853
|
`;
|
|
6646
|
-
var ObjectSearchAuthorStateGroup =
|
|
6854
|
+
var ObjectSearchAuthorStateGroup = css36`
|
|
6647
6855
|
align-items: center;
|
|
6648
6856
|
display: flex;
|
|
6649
6857
|
gap: var(--spacing-sm);
|
|
6650
6858
|
`;
|
|
6651
|
-
var ObjectSearchUpdateGroup =
|
|
6859
|
+
var ObjectSearchUpdateGroup = css36`
|
|
6652
6860
|
display: grid;
|
|
6653
6861
|
`;
|
|
6654
|
-
var ObjectSearchContentContainer =
|
|
6862
|
+
var ObjectSearchContentContainer = css36`
|
|
6655
6863
|
display: flex;
|
|
6656
6864
|
gap: var(--spacing-base);
|
|
6657
6865
|
`;
|
|
6658
|
-
var ObjectSearchImage =
|
|
6866
|
+
var ObjectSearchImage = css36`
|
|
6659
6867
|
width: 56px;
|
|
6660
6868
|
object-fit: contain;
|
|
6661
6869
|
`;
|
|
6662
6870
|
|
|
6663
6871
|
// src/components/ObjectSearch/ObjectSearchResultItem.tsx
|
|
6664
|
-
import { jsx as
|
|
6872
|
+
import { jsx as jsx65, jsxs as jsxs39 } from "@emotion/react/jsx-runtime";
|
|
6665
6873
|
var ObjectSearchResultItem = ({
|
|
6666
6874
|
id,
|
|
6667
6875
|
title,
|
|
@@ -6685,66 +6893,70 @@ var ObjectSearchResultItem = ({
|
|
|
6685
6893
|
onSelectItem({ id, title: id });
|
|
6686
6894
|
onRemove == null ? void 0 : onRemove();
|
|
6687
6895
|
};
|
|
6688
|
-
return /* @__PURE__ */
|
|
6689
|
-
disableDnD ? null : /* @__PURE__ */
|
|
6690
|
-
/* @__PURE__ */
|
|
6691
|
-
!imageUrl ? null : /* @__PURE__ */
|
|
6692
|
-
/* @__PURE__ */
|
|
6693
|
-
/* @__PURE__ */
|
|
6694
|
-
/* @__PURE__ */
|
|
6896
|
+
return /* @__PURE__ */ jsxs39("div", { css: ObjectSearchResultItemContainer, "data-testid": "search-result-item", children: [
|
|
6897
|
+
disableDnD ? null : /* @__PURE__ */ jsx65("div", { role: "presentation", className: "drag-handle", css: ObjectSearchDragHandle }),
|
|
6898
|
+
/* @__PURE__ */ jsx65("div", { children: /* @__PURE__ */ jsxs39("div", { css: ObjectSearchContentContainer, children: [
|
|
6899
|
+
!imageUrl ? null : /* @__PURE__ */ jsx65("img", { src: imageUrl, alt: `Thumbnail for ${title}`, css: ObjectSearchImage }),
|
|
6900
|
+
/* @__PURE__ */ jsxs39("div", { children: [
|
|
6901
|
+
/* @__PURE__ */ jsx65("span", { css: ObjectSearchResultItemSubtitle, "data-testid": "sub-title", children: formatedContentType }),
|
|
6902
|
+
/* @__PURE__ */ jsxs39("span", { role: "heading", css: ObjectSearchResultItemTitle, "data-testid": "title", children: [
|
|
6695
6903
|
title != null ? title : name,
|
|
6696
|
-
!popoverData ? null : /* @__PURE__ */
|
|
6904
|
+
!popoverData ? null : /* @__PURE__ */ jsx65(Popover2, { baseId: title, ariaLabel: title, buttonText: `See ${title} details`, children: popoverData })
|
|
6697
6905
|
] }),
|
|
6698
|
-
!createdAt && !publishStatus ? null : /* @__PURE__ */
|
|
6699
|
-
!(publishStatus == null ? void 0 : publishStatus.text) ? null : /* @__PURE__ */
|
|
6700
|
-
!createdAt && !publishedAt ? null : /* @__PURE__ */
|
|
6701
|
-
!createdAt ? null : /* @__PURE__ */
|
|
6702
|
-
/* @__PURE__ */
|
|
6906
|
+
!createdAt && !publishStatus ? null : /* @__PURE__ */ jsxs39("div", { css: ObjectSearchAuthorStateGroup, children: [
|
|
6907
|
+
!(publishStatus == null ? void 0 : publishStatus.text) ? null : /* @__PURE__ */ jsx65(Badge, { ...publishStatus, size: "sm", uppercaseText: true }),
|
|
6908
|
+
!createdAt && !publishedAt ? null : /* @__PURE__ */ jsxs39("div", { css: ObjectSearchUpdateGroup, children: [
|
|
6909
|
+
!createdAt ? null : /* @__PURE__ */ jsxs39("small", { css: ObjectSearchResultItemTimeStamp, children: [
|
|
6910
|
+
/* @__PURE__ */ jsx65("strong", { children: "Last updated: " }),
|
|
6703
6911
|
timeagoFormat(createdAt)
|
|
6704
6912
|
] }),
|
|
6705
|
-
!publishedAt ? null : /* @__PURE__ */
|
|
6706
|
-
/* @__PURE__ */
|
|
6913
|
+
!publishedAt ? null : /* @__PURE__ */ jsxs39("small", { css: ObjectSearchResultItemTimeStamp, children: [
|
|
6914
|
+
/* @__PURE__ */ jsx65("strong", { children: "Last published: " }),
|
|
6707
6915
|
timeagoFormat(publishedAt)
|
|
6708
6916
|
] })
|
|
6709
6917
|
] })
|
|
6710
6918
|
] }),
|
|
6711
|
-
/* @__PURE__ */
|
|
6919
|
+
/* @__PURE__ */ jsx65("div", { children })
|
|
6712
6920
|
] })
|
|
6713
6921
|
] }) }),
|
|
6714
|
-
!editLink && hideRemoveButton ? null : /* @__PURE__ */
|
|
6715
|
-
!editLink ? null : /* @__PURE__ */
|
|
6716
|
-
hideRemoveButton ? null : /* @__PURE__ */
|
|
6922
|
+
!editLink && hideRemoveButton ? null : /* @__PURE__ */ jsxs39("div", { css: ObjectSearchAuthorStateGroup, children: [
|
|
6923
|
+
!editLink ? null : /* @__PURE__ */ jsx65(LinkButton, { text: "Edit", href: editLink, icon: editLinkIcon }),
|
|
6924
|
+
hideRemoveButton ? null : /* @__PURE__ */ jsx65(Button4, { buttonType: "ghostDestructive", onClick: onRemoveItem, children: "Remove" })
|
|
6717
6925
|
] })
|
|
6718
6926
|
] });
|
|
6719
6927
|
};
|
|
6720
6928
|
|
|
6929
|
+
// src/components/ObjectSearch/ObjectSearchResultList.tsx
|
|
6930
|
+
import { Button as Button5, Counter } from "@uniformdev/design-system";
|
|
6931
|
+
import { Draggable as Draggable3, Droppable as Droppable3 } from "react-beautiful-dnd";
|
|
6932
|
+
|
|
6721
6933
|
// src/components/ObjectSearch/styles/ObjectSearchResultList.styles.ts
|
|
6722
|
-
import { css as
|
|
6723
|
-
var ObjectSearchResultListContainer =
|
|
6934
|
+
import { css as css37 } from "@emotion/react";
|
|
6935
|
+
var ObjectSearchResultListContainer = css37`
|
|
6724
6936
|
align-items: center;
|
|
6725
6937
|
display: flex;
|
|
6726
6938
|
gap: var(--spacing-sm);
|
|
6727
6939
|
justify-content: space-between;
|
|
6728
6940
|
`;
|
|
6729
|
-
var ObjectSearchDragContainer =
|
|
6941
|
+
var ObjectSearchDragContainer = css37`
|
|
6730
6942
|
margin: 0 0 var(--spacing-sm);
|
|
6731
6943
|
`;
|
|
6732
|
-
var ObjectSearchContainerDragging =
|
|
6944
|
+
var ObjectSearchContainerDragging = css37`
|
|
6733
6945
|
box-shadow: var(--shadow-base);
|
|
6734
6946
|
opacity: var(--opacity-50);
|
|
6735
6947
|
`;
|
|
6736
|
-
var ObjectSearchResultListCounterContainer =
|
|
6948
|
+
var ObjectSearchResultListCounterContainer = css37`
|
|
6737
6949
|
align-items: center;
|
|
6738
6950
|
display: flex;
|
|
6739
6951
|
gap: var(--spacing-sm);
|
|
6740
6952
|
`;
|
|
6741
|
-
var ObjectSearchResultListTitle =
|
|
6953
|
+
var ObjectSearchResultListTitle = css37`
|
|
6742
6954
|
font-weight: var(--fw-bold);
|
|
6743
6955
|
line-height: 1;
|
|
6744
6956
|
`;
|
|
6745
6957
|
|
|
6746
6958
|
// src/components/ObjectSearch/ObjectSearchResultList.tsx
|
|
6747
|
-
import { Fragment as Fragment13, jsx as
|
|
6959
|
+
import { Fragment as Fragment13, jsx as jsx66, jsxs as jsxs40 } from "@emotion/react/jsx-runtime";
|
|
6748
6960
|
function ObjectSearchResultList({
|
|
6749
6961
|
resultLabelText = "Selected",
|
|
6750
6962
|
removeButtonText = "Remove all",
|
|
@@ -6752,13 +6964,13 @@ function ObjectSearchResultList({
|
|
|
6752
6964
|
hideRemoveButton = false,
|
|
6753
6965
|
resultLabelOverride,
|
|
6754
6966
|
additionalButtons,
|
|
6755
|
-
renderResultComponent = (value) => /* @__PURE__ */
|
|
6967
|
+
renderResultComponent = (value) => /* @__PURE__ */ jsx66(ObjectSearchResultItem, { ...value }),
|
|
6756
6968
|
multiSelectId,
|
|
6757
6969
|
disableDnD = false,
|
|
6758
6970
|
getContainerForDnDReparenting,
|
|
6759
|
-
whenNothingSelected
|
|
6971
|
+
whenNothingSelected = null
|
|
6760
6972
|
}) {
|
|
6761
|
-
const { selectedListItems, onRemoveAllSelectedItems, onSelectItem
|
|
6973
|
+
const { selectedListItems, onRemoveAllSelectedItems, onSelectItem } = useObjectSearchContext();
|
|
6762
6974
|
const handleRemoveAllSelectedItems = () => {
|
|
6763
6975
|
onRemoveAllSelectedItems();
|
|
6764
6976
|
onRemoveAllSelected == null ? void 0 : onRemoveAllSelected();
|
|
@@ -6779,7 +6991,7 @@ function ObjectSearchResultList({
|
|
|
6779
6991
|
...item,
|
|
6780
6992
|
disableDnD: selectedListItems.length === 1 || disableDnD
|
|
6781
6993
|
});
|
|
6782
|
-
return /* @__PURE__ */
|
|
6994
|
+
return /* @__PURE__ */ jsx66(
|
|
6783
6995
|
"div",
|
|
6784
6996
|
{
|
|
6785
6997
|
css: [
|
|
@@ -6794,19 +7006,16 @@ function ObjectSearchResultList({
|
|
|
6794
7006
|
}
|
|
6795
7007
|
);
|
|
6796
7008
|
};
|
|
6797
|
-
|
|
6798
|
-
|
|
6799
|
-
|
|
6800
|
-
|
|
6801
|
-
/* @__PURE__ */ jsxs37("div", { role: "group", css: ObjectSearchResultListContainer, children: [
|
|
6802
|
-
!resultLabelOverride ? /* @__PURE__ */ jsxs37("div", { role: "note", css: ObjectSearchResultListCounterContainer, children: [
|
|
6803
|
-
/* @__PURE__ */ jsx63("span", { css: ObjectSearchResultListTitle, children: resultLabelText }),
|
|
7009
|
+
return /* @__PURE__ */ jsxs40(Fragment13, { children: [
|
|
7010
|
+
/* @__PURE__ */ jsxs40("div", { role: "group", css: ObjectSearchResultListContainer, children: [
|
|
7011
|
+
!resultLabelOverride ? /* @__PURE__ */ jsxs40("div", { role: "note", css: ObjectSearchResultListCounterContainer, children: [
|
|
7012
|
+
/* @__PURE__ */ jsx66("span", { css: ObjectSearchResultListTitle, children: resultLabelText }),
|
|
6804
7013
|
" ",
|
|
6805
|
-
!selectedListItems.length ? null : /* @__PURE__ */
|
|
7014
|
+
!selectedListItems.length ? null : /* @__PURE__ */ jsx66(Counter, { count: selectedListItems.length })
|
|
6806
7015
|
] }) : resultLabelOverride,
|
|
6807
|
-
/* @__PURE__ */
|
|
7016
|
+
/* @__PURE__ */ jsxs40("div", { css: ObjectSearchResultListCounterContainer, children: [
|
|
6808
7017
|
additionalButtons,
|
|
6809
|
-
hideRemoveButton ? null : /* @__PURE__ */
|
|
7018
|
+
hideRemoveButton ? null : /* @__PURE__ */ jsx66(
|
|
6810
7019
|
Button5,
|
|
6811
7020
|
{
|
|
6812
7021
|
buttonType: "ghostDestructive",
|
|
@@ -6818,17 +7027,15 @@ function ObjectSearchResultList({
|
|
|
6818
7027
|
)
|
|
6819
7028
|
] })
|
|
6820
7029
|
] }),
|
|
6821
|
-
|
|
6822
|
-
showEmptyResults ? whenNothingSelected : null,
|
|
6823
|
-
showResults ? /* @__PURE__ */ jsx63(DragDropContext, { onDragEnd: (res) => onDragEnd(res), children: /* @__PURE__ */ jsx63(
|
|
7030
|
+
!selectedListItems.length ? whenNothingSelected : /* @__PURE__ */ jsx66(DragDropContext, { onDragEnd: (res) => onDragEnd(res), children: /* @__PURE__ */ jsx66(
|
|
6824
7031
|
Droppable3,
|
|
6825
7032
|
{
|
|
6826
7033
|
droppableId: multiSelectId != null ? multiSelectId : "canvas-multi-select",
|
|
6827
7034
|
renderClone: getContainerForDnDReparenting ? getDraggableItem : void 0,
|
|
6828
7035
|
getContainerForClone: getContainerForDnDReparenting,
|
|
6829
|
-
children: (provided) => /* @__PURE__ */
|
|
7036
|
+
children: (provided) => /* @__PURE__ */ jsxs40("div", { ...provided.droppableProps, ref: provided.innerRef, children: [
|
|
6830
7037
|
selectedListItems.map((item, i) => {
|
|
6831
|
-
return /* @__PURE__ */
|
|
7038
|
+
return /* @__PURE__ */ jsx66(
|
|
6832
7039
|
Draggable3,
|
|
6833
7040
|
{
|
|
6834
7041
|
draggableId: item.id,
|
|
@@ -6842,274 +7049,10 @@ function ObjectSearchResultList({
|
|
|
6842
7049
|
provided.placeholder
|
|
6843
7050
|
] })
|
|
6844
7051
|
}
|
|
6845
|
-
) })
|
|
7052
|
+
) })
|
|
6846
7053
|
] });
|
|
6847
7054
|
}
|
|
6848
7055
|
|
|
6849
|
-
// src/components/ObjectSearch/ObjectSearchContainer.tsx
|
|
6850
|
-
import { Fragment as Fragment14, jsx as jsx64, jsxs as jsxs38 } from "@emotion/react/jsx-runtime";
|
|
6851
|
-
var ObjectSearchContainer = ({
|
|
6852
|
-
label,
|
|
6853
|
-
enableDynamicInputToResultId,
|
|
6854
|
-
searchFilters,
|
|
6855
|
-
resultList,
|
|
6856
|
-
children = /* @__PURE__ */ jsx64(ObjectSearchResultList, {})
|
|
6857
|
-
}) => {
|
|
6858
|
-
var _a, _b;
|
|
6859
|
-
const { onSelectItem, selectedListItems, list, dynamicEntryId, onSetQuery, query } = useObjectSearchContext();
|
|
6860
|
-
const { flatVariables } = useVariables(true);
|
|
6861
|
-
const inputValue = (_b = dynamicEntryId != null ? dynamicEntryId : (_a = selectedListItems[0]) == null ? void 0 : _a.id) != null ? _b : "";
|
|
6862
|
-
const isDynamicEntryIdAvailable = React12.useMemo(
|
|
6863
|
-
() => Boolean(inputValue && hasReferencedVariables(inputValue)),
|
|
6864
|
-
[inputValue]
|
|
6865
|
-
);
|
|
6866
|
-
const listItems = resultList != null ? resultList : /* @__PURE__ */ jsx64(
|
|
6867
|
-
ScrollableList,
|
|
6868
|
-
{
|
|
6869
|
-
role: "list",
|
|
6870
|
-
css: css36`
|
|
6871
|
-
> div {
|
|
6872
|
-
transition: max-height var(--duration-slow) var(--timing-ease-out);
|
|
6873
|
-
max-height: ${selectedListItems.length === 0 ? "50vh" : "184px"};
|
|
6874
|
-
}
|
|
6875
|
-
`,
|
|
6876
|
-
children: /* @__PURE__ */ jsx64(DefaultResultList, {})
|
|
6877
|
-
}
|
|
6878
|
-
);
|
|
6879
|
-
const handleSelectedVariableChange = (selectedValue) => {
|
|
6880
|
-
var _a2;
|
|
6881
|
-
if (!selectedValue) {
|
|
6882
|
-
onSelectItem([]);
|
|
6883
|
-
return;
|
|
6884
|
-
}
|
|
6885
|
-
const { result, errors } = bindVariables({
|
|
6886
|
-
value: selectedValue,
|
|
6887
|
-
variables: flatVariables,
|
|
6888
|
-
errorPrefix: "Dynamic input"
|
|
6889
|
-
});
|
|
6890
|
-
if (!result) {
|
|
6891
|
-
onSelectItem([]);
|
|
6892
|
-
return;
|
|
6893
|
-
}
|
|
6894
|
-
const item = (_a2 = list.items) == null ? void 0 : _a2.find((i) => i.id === result);
|
|
6895
|
-
onSelectItem([
|
|
6896
|
-
{
|
|
6897
|
-
title: selectedValue,
|
|
6898
|
-
contentType: (errors == null ? void 0 : errors.length) ? errors[0] instanceof Error ? errors[0].message : errors[0] : `Current dynamic value "${result}" is not an ID in the options`,
|
|
6899
|
-
// spread any matched list item, overriding the above default props
|
|
6900
|
-
...item,
|
|
6901
|
-
// we want to make sure the ID is our dynamic value
|
|
6902
|
-
id: selectedValue
|
|
6903
|
-
}
|
|
6904
|
-
]);
|
|
6905
|
-
if (hasReferencedVariables(selectedValue)) {
|
|
6906
|
-
onSetQuery({ ...query, dynamicEntryId: selectedValue });
|
|
6907
|
-
}
|
|
6908
|
-
};
|
|
6909
|
-
const showSearchList = !label || !isDynamicEntryIdAvailable || !enableDynamicInputToResultId;
|
|
6910
|
-
return /* @__PURE__ */ jsx64(IconsProvider, { children: /* @__PURE__ */ jsxs38(VerticalRhythm2, { children: [
|
|
6911
|
-
/* @__PURE__ */ jsx64(Container, { backgroundColor: "gray-50", padding: "var(--spacing-base)", border: true, children: /* @__PURE__ */ jsxs38(VerticalRhythm2, { children: [
|
|
6912
|
-
label ? /* @__PURE__ */ jsx64(
|
|
6913
|
-
InputVariables,
|
|
6914
|
-
{
|
|
6915
|
-
id: "entryId",
|
|
6916
|
-
label,
|
|
6917
|
-
value: inputValue,
|
|
6918
|
-
onChange: (value) => {
|
|
6919
|
-
if (value === inputValue) {
|
|
6920
|
-
return;
|
|
6921
|
-
}
|
|
6922
|
-
handleSelectedVariableChange(value);
|
|
6923
|
-
},
|
|
6924
|
-
inputWhenNoVariables: /* @__PURE__ */ jsx64(Fragment14, { children: searchFilters }),
|
|
6925
|
-
disableVariables: !enableDynamicInputToResultId
|
|
6926
|
-
}
|
|
6927
|
-
) : searchFilters,
|
|
6928
|
-
showSearchList ? listItems : null
|
|
6929
|
-
] }) }),
|
|
6930
|
-
children
|
|
6931
|
-
] }) });
|
|
6932
|
-
};
|
|
6933
|
-
var DefaultResultList = () => {
|
|
6934
|
-
var _a, _b;
|
|
6935
|
-
const { list, isListLoading } = useObjectSearchContext();
|
|
6936
|
-
if (isListLoading || !list.items) {
|
|
6937
|
-
return Array.from(Array(5).keys()).map((i) => /* @__PURE__ */ jsx64(ObjectSearchListItemLoadingSkeleton, {}, i));
|
|
6938
|
-
}
|
|
6939
|
-
if (((_a = list.items) == null ? void 0 : _a.length) === 0) {
|
|
6940
|
-
return /* @__PURE__ */ jsx64(Callout5, { type: "info", children: "No results were found" });
|
|
6941
|
-
}
|
|
6942
|
-
return (_b = list.items) == null ? void 0 : _b.map((item) => /* @__PURE__ */ jsx64(ObjectSearchListItem, { ...item }, item.id));
|
|
6943
|
-
};
|
|
6944
|
-
|
|
6945
|
-
// src/components/ObjectSearch/ObjectSearchFilter.tsx
|
|
6946
|
-
import { DebouncedInputKeywordSearch, InputSelect as InputSelect6, VerticalRhythm as VerticalRhythm3 } from "@uniformdev/design-system";
|
|
6947
|
-
import { useMemo as useMemo15, useState as useState17 } from "react";
|
|
6948
|
-
import { useDebounce as useDebounce4 } from "react-use";
|
|
6949
|
-
|
|
6950
|
-
// src/utils/createLocationValidator.ts
|
|
6951
|
-
function createLocationValidator(setValue, validate) {
|
|
6952
|
-
return (dispatch) => setValue((previous) => {
|
|
6953
|
-
const { newValue, options } = dispatch(previous);
|
|
6954
|
-
return { newValue, options: validate(newValue, options) };
|
|
6955
|
-
});
|
|
6956
|
-
}
|
|
6957
|
-
|
|
6958
|
-
// src/utils/useContentDataResourceLocaleInfo.ts
|
|
6959
|
-
import { bindVariables as bindVariables2, createVariableReference as createVariableReference4, LOCALE_DYNAMIC_INPUT_NAME as LOCALE_DYNAMIC_INPUT_NAME2 } from "@uniformdev/canvas";
|
|
6960
|
-
import { useEffect as useEffect16, useRef as useRef15 } from "react";
|
|
6961
|
-
function useContentDataResourceLocaleInfo({
|
|
6962
|
-
locale,
|
|
6963
|
-
setLocale,
|
|
6964
|
-
dynamicInputs
|
|
6965
|
-
}) {
|
|
6966
|
-
var _a;
|
|
6967
|
-
const setLocaleRef = useRef15(setLocale);
|
|
6968
|
-
setLocaleRef.current = setLocale;
|
|
6969
|
-
const { flatVariables } = useVariables();
|
|
6970
|
-
const effectiveLocale = locale != null ? locale : dynamicInputs[LOCALE_DYNAMIC_INPUT_NAME2] ? createVariableReference4(LOCALE_DYNAMIC_INPUT_NAME2) : "";
|
|
6971
|
-
const boundLocale = (_a = bindVariables2({ variables: flatVariables, value: effectiveLocale }).result) != null ? _a : effectiveLocale;
|
|
6972
|
-
useEffect16(() => {
|
|
6973
|
-
if (locale === void 0 && effectiveLocale && setLocaleRef.current) {
|
|
6974
|
-
setLocaleRef.current(createVariableReference4(LOCALE_DYNAMIC_INPUT_NAME2));
|
|
6975
|
-
}
|
|
6976
|
-
}, [locale, effectiveLocale]);
|
|
6977
|
-
return { effectiveLocale, boundLocale: boundLocale ? boundLocale : void 0 };
|
|
6978
|
-
}
|
|
6979
|
-
|
|
6980
|
-
// src/components/ObjectSearch/styles/ObjectSearchFilterContainer.styles.ts
|
|
6981
|
-
import { css as css37 } from "@emotion/react";
|
|
6982
|
-
var ObjectSearchFilterContainerLabel = css37`
|
|
6983
|
-
align-items: center;
|
|
6984
|
-
display: flex;
|
|
6985
|
-
font-size: var(--fs-sm);
|
|
6986
|
-
font-weight: var(--fw-bold);
|
|
6987
|
-
line-height: 1rem;
|
|
6988
|
-
margin-bottom: var(--spacing-sm);
|
|
6989
|
-
`;
|
|
6990
|
-
var ObjectSearchFilterContainer = css37`
|
|
6991
|
-
display: grid;
|
|
6992
|
-
gap: var(--spacing-base);
|
|
6993
|
-
`;
|
|
6994
|
-
var ObjectSearchFilterGrid = (gridColumns) => css37`
|
|
6995
|
-
display: grid;
|
|
6996
|
-
grid-template-columns: ${gridColumns};
|
|
6997
|
-
gap: var(--spacing-base);
|
|
6998
|
-
`;
|
|
6999
|
-
|
|
7000
|
-
// src/components/ObjectSearch/ObjectSearchFilter.tsx
|
|
7001
|
-
import { jsx as jsx65, jsxs as jsxs39 } from "@emotion/react/jsx-runtime";
|
|
7002
|
-
var ObjectSearchFilter = ({
|
|
7003
|
-
requireContentType,
|
|
7004
|
-
typeSelectorAllTypesOptionText = "All content types",
|
|
7005
|
-
searchInputName = "searchText",
|
|
7006
|
-
searchInputPlaceholderText = "Enter keyword to narrow your results",
|
|
7007
|
-
selectLabel = "Content Type Select",
|
|
7008
|
-
localeFilterLabel = "Filter by locale",
|
|
7009
|
-
selectOptions
|
|
7010
|
-
}) => {
|
|
7011
|
-
var _a, _b, _c;
|
|
7012
|
-
const { query, onSetQuery, localeOptions, enableFilterByLocale } = useObjectSearchContext();
|
|
7013
|
-
const dynamicInputs = useDataResourceDynamicInputs();
|
|
7014
|
-
const { boundLocale = "", effectiveLocale } = useContentDataResourceLocaleInfo({
|
|
7015
|
-
locale: query.locale,
|
|
7016
|
-
dynamicInputs: dynamicInputs != null ? dynamicInputs : {},
|
|
7017
|
-
setLocale: (newLocale) => handleFilterChange({ locale: newLocale != null ? newLocale : "" })
|
|
7018
|
-
});
|
|
7019
|
-
const [searchState, setSearchState] = useState17({
|
|
7020
|
-
keyword: (_a = query.keyword) != null ? _a : "",
|
|
7021
|
-
contentType: (_b = query.contentType) != null ? _b : "",
|
|
7022
|
-
locale: (_c = query.locale) != null ? _c : ""
|
|
7023
|
-
});
|
|
7024
|
-
const handleFilterChange = (value) => {
|
|
7025
|
-
setSearchState((prev) => {
|
|
7026
|
-
return { ...prev, ...value };
|
|
7027
|
-
});
|
|
7028
|
-
};
|
|
7029
|
-
useDebounce4(
|
|
7030
|
-
() => {
|
|
7031
|
-
onSetQuery({ ...query, ...searchState });
|
|
7032
|
-
},
|
|
7033
|
-
500,
|
|
7034
|
-
[searchState]
|
|
7035
|
-
);
|
|
7036
|
-
const memoizedSelectOptions = useMemo15(() => {
|
|
7037
|
-
if (!requireContentType && !(selectOptions == null ? void 0 : selectOptions.length)) {
|
|
7038
|
-
return [];
|
|
7039
|
-
}
|
|
7040
|
-
return [
|
|
7041
|
-
...!requireContentType ? [{ value: "any", label: typeSelectorAllTypesOptionText }] : [],
|
|
7042
|
-
...selectOptions != null ? selectOptions : []
|
|
7043
|
-
];
|
|
7044
|
-
}, [requireContentType, typeSelectorAllTypesOptionText, selectOptions]);
|
|
7045
|
-
const shouldRenderSelect = memoizedSelectOptions.length > 0;
|
|
7046
|
-
return /* @__PURE__ */ jsxs39(VerticalRhythm3, { gap: "base", children: [
|
|
7047
|
-
/* @__PURE__ */ jsxs39(
|
|
7048
|
-
"fieldset",
|
|
7049
|
-
{
|
|
7050
|
-
css: [
|
|
7051
|
-
ObjectSearchFilterContainer,
|
|
7052
|
-
ObjectSearchFilterGrid(shouldRenderSelect ? "1fr 2fr" : "1fr")
|
|
7053
|
-
],
|
|
7054
|
-
children: [
|
|
7055
|
-
memoizedSelectOptions.length ? /* @__PURE__ */ jsx65(
|
|
7056
|
-
InputSelect6,
|
|
7057
|
-
{
|
|
7058
|
-
label: selectLabel,
|
|
7059
|
-
showLabel: false,
|
|
7060
|
-
onChange: (e) => handleFilterChange({ contentType: e.target.value }),
|
|
7061
|
-
options: memoizedSelectOptions,
|
|
7062
|
-
value: query.contentType,
|
|
7063
|
-
"data-testid": "select-entry"
|
|
7064
|
-
}
|
|
7065
|
-
) : null,
|
|
7066
|
-
/* @__PURE__ */ jsx65(
|
|
7067
|
-
DebouncedInputKeywordSearch,
|
|
7068
|
-
{
|
|
7069
|
-
inputFieldName: searchInputName,
|
|
7070
|
-
placeholder: searchInputPlaceholderText,
|
|
7071
|
-
onSearchTextChanged: (keyword) => handleFilterChange({ keyword }),
|
|
7072
|
-
disabledFieldSubmission: true,
|
|
7073
|
-
defaultValue: searchState.keyword,
|
|
7074
|
-
delay: 300
|
|
7075
|
-
}
|
|
7076
|
-
)
|
|
7077
|
-
]
|
|
7078
|
-
}
|
|
7079
|
-
),
|
|
7080
|
-
enableFilterByLocale && (localeOptions == null ? void 0 : localeOptions.length) && /* @__PURE__ */ jsx65(
|
|
7081
|
-
InputVariables,
|
|
7082
|
-
{
|
|
7083
|
-
label: localeFilterLabel,
|
|
7084
|
-
id: "locale",
|
|
7085
|
-
value: effectiveLocale,
|
|
7086
|
-
onChange: (newLocale) => handleFilterChange({ locale: newLocale != null ? newLocale : "" }),
|
|
7087
|
-
disableInlineMenu: true,
|
|
7088
|
-
inputWhenNoVariables: /* @__PURE__ */ jsx65(
|
|
7089
|
-
InputSelect6,
|
|
7090
|
-
{
|
|
7091
|
-
id: "locale",
|
|
7092
|
-
options: localeOptions,
|
|
7093
|
-
name: "locale",
|
|
7094
|
-
label: "",
|
|
7095
|
-
value: boundLocale,
|
|
7096
|
-
onChange: (e) => handleFilterChange({ locale: e.target.value })
|
|
7097
|
-
}
|
|
7098
|
-
)
|
|
7099
|
-
}
|
|
7100
|
-
)
|
|
7101
|
-
] });
|
|
7102
|
-
};
|
|
7103
|
-
|
|
7104
|
-
// src/components/ObjectSearch/ObjectSearchFilterContainer.tsx
|
|
7105
|
-
import { jsx as jsx66, jsxs as jsxs40 } from "@emotion/react/jsx-runtime";
|
|
7106
|
-
var ObjectSearchFilterContainer2 = ({ label, children }) => {
|
|
7107
|
-
return /* @__PURE__ */ jsxs40("div", { children: [
|
|
7108
|
-
label ? /* @__PURE__ */ jsx66("span", { css: ObjectSearchFilterContainerLabel, children: label }) : null,
|
|
7109
|
-
/* @__PURE__ */ jsx66("div", { css: ObjectSearchFilterContainer, children })
|
|
7110
|
-
] });
|
|
7111
|
-
};
|
|
7112
|
-
|
|
7113
7056
|
// src/components/ObjectSearch/QueryFilter.tsx
|
|
7114
7057
|
import { DebouncedInputKeywordSearch as DebouncedInputKeywordSearch2, Input as Input5, InputSelect as InputSelect7, VerticalRhythm as VerticalRhythm4 } from "@uniformdev/design-system";
|
|
7115
7058
|
import { useEffect as useEffect17, useState as useState18 } from "react";
|
|
@@ -7278,106 +7221,9 @@ var QueryFilter = ({
|
|
|
7278
7221
|
] });
|
|
7279
7222
|
};
|
|
7280
7223
|
|
|
7281
|
-
// src/components/ObjectSearch/ObjectSearchListOfSearchResults.tsx
|
|
7282
|
-
import { Callout as Callout6 } from "@uniformdev/design-system";
|
|
7283
|
-
import { jsx as jsx68 } from "@emotion/react/jsx-runtime";
|
|
7284
|
-
function ObjectSearchListOfSearchResults() {
|
|
7285
|
-
var _a, _b;
|
|
7286
|
-
const { list, isListLoading } = useObjectSearchContext();
|
|
7287
|
-
if (isListLoading) {
|
|
7288
|
-
return Array.from(Array(5).keys()).map((i) => /* @__PURE__ */ jsx68(ObjectSearchListItemLoadingSkeleton, {}, i));
|
|
7289
|
-
}
|
|
7290
|
-
if (((_a = list.items) == null ? void 0 : _a.length) === 0) {
|
|
7291
|
-
return /* @__PURE__ */ jsx68(Callout6, { type: "info", children: "No results were found" });
|
|
7292
|
-
}
|
|
7293
|
-
return (_b = list.items) == null ? void 0 : _b.map((item) => /* @__PURE__ */ jsx68(ObjectSearchListItem, { ...item }, item.id));
|
|
7294
|
-
}
|
|
7295
|
-
|
|
7296
|
-
// src/components/ObjectSearch/hooks/ControlledObjectSearchProvider.tsx
|
|
7297
|
-
import { useCallback as useCallback6, useDeferredValue as useDeferredValue2, useMemo as useMemo16 } from "react";
|
|
7298
|
-
import { jsx as jsx69 } from "@emotion/react/jsx-runtime";
|
|
7299
|
-
var ControlledObjectSearchProvider = ({
|
|
7300
|
-
selectedItems,
|
|
7301
|
-
searchResultItems,
|
|
7302
|
-
isSelectedItemsListLoading,
|
|
7303
|
-
isSearchResultsLoading,
|
|
7304
|
-
onSelectItemsChange,
|
|
7305
|
-
isMulti = false,
|
|
7306
|
-
children,
|
|
7307
|
-
onQueryChange = () => {
|
|
7308
|
-
},
|
|
7309
|
-
query = {},
|
|
7310
|
-
enableFilterByLocale,
|
|
7311
|
-
localeOptions,
|
|
7312
|
-
dynamicEntryId
|
|
7313
|
-
}) => {
|
|
7314
|
-
const { flatVariables } = useVariables(true);
|
|
7315
|
-
const querySearchDeferred = useDeferredValue2(query);
|
|
7316
|
-
const onSetQuery = useCallback6(
|
|
7317
|
-
(value2) => {
|
|
7318
|
-
const newQuery = { ...query, ...value2 };
|
|
7319
|
-
onQueryChange(newQuery);
|
|
7320
|
-
},
|
|
7321
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
7322
|
-
[onQueryChange]
|
|
7323
|
-
);
|
|
7324
|
-
const onSelectItem = useCallback6(
|
|
7325
|
-
(selectedResult) => {
|
|
7326
|
-
if (Array.isArray(selectedResult)) {
|
|
7327
|
-
onSelectItemsChange(selectedResult);
|
|
7328
|
-
} else {
|
|
7329
|
-
if (selectedItems == null ? void 0 : selectedItems.some((item) => item.id === selectedResult.id)) {
|
|
7330
|
-
onSelectItemsChange(selectedItems.filter((item) => item.id !== selectedResult.id));
|
|
7331
|
-
} else {
|
|
7332
|
-
onSelectItemsChange([...selectedItems != null ? selectedItems : [], selectedResult]);
|
|
7333
|
-
}
|
|
7334
|
-
}
|
|
7335
|
-
},
|
|
7336
|
-
[onSelectItemsChange, selectedItems]
|
|
7337
|
-
);
|
|
7338
|
-
const onRemoveAllSelectedItems = useCallback6(() => {
|
|
7339
|
-
onSelectItemsChange([]);
|
|
7340
|
-
}, [onSelectItemsChange]);
|
|
7341
|
-
const list = useMemo16(() => ({ items: searchResultItems }), [searchResultItems]);
|
|
7342
|
-
const boundQuery = useMemo16(() => bindQuery(query, flatVariables), [query, flatVariables]);
|
|
7343
|
-
const value = useMemo16(
|
|
7344
|
-
() => ({
|
|
7345
|
-
boundQuery,
|
|
7346
|
-
onSetQuery,
|
|
7347
|
-
query: querySearchDeferred,
|
|
7348
|
-
onSelectItem,
|
|
7349
|
-
selectedListItems: selectedItems != null ? selectedItems : [],
|
|
7350
|
-
onRemoveAllSelectedItems,
|
|
7351
|
-
list,
|
|
7352
|
-
isSelectedItemsListLoading,
|
|
7353
|
-
isListLoading: isSearchResultsLoading,
|
|
7354
|
-
isMulti,
|
|
7355
|
-
localeOptions,
|
|
7356
|
-
enableFilterByLocale,
|
|
7357
|
-
dynamicEntryId
|
|
7358
|
-
}),
|
|
7359
|
-
[
|
|
7360
|
-
boundQuery,
|
|
7361
|
-
onSetQuery,
|
|
7362
|
-
querySearchDeferred,
|
|
7363
|
-
onSelectItem,
|
|
7364
|
-
selectedItems,
|
|
7365
|
-
isSelectedItemsListLoading,
|
|
7366
|
-
isSearchResultsLoading,
|
|
7367
|
-
onRemoveAllSelectedItems,
|
|
7368
|
-
list,
|
|
7369
|
-
isMulti,
|
|
7370
|
-
localeOptions,
|
|
7371
|
-
enableFilterByLocale,
|
|
7372
|
-
dynamicEntryId
|
|
7373
|
-
]
|
|
7374
|
-
);
|
|
7375
|
-
return /* @__PURE__ */ jsx69(ObjectSearchContext.Provider, { value, children });
|
|
7376
|
-
};
|
|
7377
|
-
|
|
7378
7224
|
// src/components/ParamTypeDynamicDataProvider.tsx
|
|
7379
|
-
import { useEffect as useEffect18, useMemo as
|
|
7380
|
-
import { jsx as
|
|
7225
|
+
import { useEffect as useEffect18, useMemo as useMemo16, useRef as useRef15 } from "react";
|
|
7226
|
+
import { jsx as jsx68 } from "@emotion/react/jsx-runtime";
|
|
7381
7227
|
function ParamTypeDynamicDataProvider(props) {
|
|
7382
7228
|
const { children } = props;
|
|
7383
7229
|
const {
|
|
@@ -7385,11 +7231,11 @@ function ParamTypeDynamicDataProvider(props) {
|
|
|
7385
7231
|
} = useMeshLocation("paramType");
|
|
7386
7232
|
const dynamicInputsAsVariables = useDynamicInputsAsVariables(dynamicInputs);
|
|
7387
7233
|
const connectedDataAsVariables = useConnectedDataAsVariables(connectedData);
|
|
7388
|
-
const variables =
|
|
7234
|
+
const variables = useMemo16(
|
|
7389
7235
|
() => ({ ...connectedDataAsVariables, ...dynamicInputsAsVariables }),
|
|
7390
7236
|
[dynamicInputsAsVariables, connectedDataAsVariables]
|
|
7391
7237
|
);
|
|
7392
|
-
return /* @__PURE__ */
|
|
7238
|
+
return /* @__PURE__ */ jsx68(VariablesProvider, { value: variables, onChange: () => {
|
|
7393
7239
|
}, editVariableComponent: JsonMeshVariableEditor, children });
|
|
7394
7240
|
}
|
|
7395
7241
|
var JsonMeshVariableEditor = ({
|
|
@@ -7398,7 +7244,7 @@ var JsonMeshVariableEditor = ({
|
|
|
7398
7244
|
variable,
|
|
7399
7245
|
context
|
|
7400
7246
|
}) => {
|
|
7401
|
-
const sillyRef =
|
|
7247
|
+
const sillyRef = useRef15(false);
|
|
7402
7248
|
const { editConnectedData } = useMeshLocation("paramType");
|
|
7403
7249
|
useEffect18(() => {
|
|
7404
7250
|
if (sillyRef.current) {
|
|
@@ -7428,74 +7274,1651 @@ var JsonMeshVariableEditor = ({
|
|
|
7428
7274
|
return null;
|
|
7429
7275
|
};
|
|
7430
7276
|
|
|
7431
|
-
// src/components/SearchAndFilter/
|
|
7432
|
-
|
|
7433
|
-
|
|
7434
|
-
|
|
7435
|
-
|
|
7436
|
-
|
|
7437
|
-
|
|
7438
|
-
|
|
7439
|
-
|
|
7440
|
-
|
|
7441
|
-
|
|
7442
|
-
|
|
7443
|
-
|
|
7444
|
-
|
|
7445
|
-
|
|
7446
|
-
|
|
7447
|
-
|
|
7448
|
-
|
|
7449
|
-
|
|
7450
|
-
|
|
7451
|
-
|
|
7452
|
-
|
|
7453
|
-
|
|
7454
|
-
|
|
7455
|
-
|
|
7456
|
-
}
|
|
7457
|
-
|
|
7458
|
-
|
|
7459
|
-
|
|
7460
|
-
|
|
7461
|
-
|
|
7462
|
-
|
|
7463
|
-
|
|
7464
|
-
|
|
7465
|
-
|
|
7466
|
-
|
|
7467
|
-
|
|
7468
|
-
|
|
7469
|
-
|
|
7470
|
-
|
|
7471
|
-
|
|
7472
|
-
|
|
7473
|
-
}
|
|
7474
|
-
|
|
7475
|
-
|
|
7476
|
-
|
|
7477
|
-
|
|
7478
|
-
|
|
7479
|
-
|
|
7480
|
-
|
|
7481
|
-
|
|
7482
|
-
|
|
7483
|
-
}
|
|
7484
|
-
|
|
7485
|
-
|
|
7486
|
-
|
|
7487
|
-
|
|
7488
|
-
|
|
7489
|
-
|
|
7490
|
-
|
|
7491
|
-
|
|
7492
|
-
|
|
7493
|
-
|
|
7494
|
-
|
|
7495
|
-
|
|
7496
|
-
|
|
7497
|
-
|
|
7498
|
-
|
|
7277
|
+
// src/components/SearchAndFilter/constants.ts
|
|
7278
|
+
var NUMBER_OPERATORS = [
|
|
7279
|
+
{
|
|
7280
|
+
label: "equals...",
|
|
7281
|
+
symbol: "=",
|
|
7282
|
+
value: "eq",
|
|
7283
|
+
editorType: "number"
|
|
7284
|
+
},
|
|
7285
|
+
{
|
|
7286
|
+
label: "does not equal...",
|
|
7287
|
+
symbol: "\u2260",
|
|
7288
|
+
value: "neq",
|
|
7289
|
+
editorType: "number"
|
|
7290
|
+
},
|
|
7291
|
+
{
|
|
7292
|
+
label: "greater than...",
|
|
7293
|
+
symbol: ">",
|
|
7294
|
+
value: "gt",
|
|
7295
|
+
editorType: "number"
|
|
7296
|
+
},
|
|
7297
|
+
{
|
|
7298
|
+
label: "greater than or equal to...",
|
|
7299
|
+
symbol: "\u2265",
|
|
7300
|
+
value: "gte",
|
|
7301
|
+
editorType: "number"
|
|
7302
|
+
},
|
|
7303
|
+
{
|
|
7304
|
+
label: "less than...",
|
|
7305
|
+
symbol: "<",
|
|
7306
|
+
value: "lt",
|
|
7307
|
+
editorType: "number"
|
|
7308
|
+
},
|
|
7309
|
+
{
|
|
7310
|
+
label: "less than or equal to...",
|
|
7311
|
+
symbol: "\u2264",
|
|
7312
|
+
value: "lte",
|
|
7313
|
+
editorType: "number"
|
|
7314
|
+
},
|
|
7315
|
+
{
|
|
7316
|
+
label: "is empty",
|
|
7317
|
+
value: "ndef",
|
|
7318
|
+
editorType: "empty"
|
|
7319
|
+
},
|
|
7320
|
+
{
|
|
7321
|
+
label: "is between...",
|
|
7322
|
+
value: "between",
|
|
7323
|
+
editorType: "numberRange"
|
|
7324
|
+
},
|
|
7325
|
+
{
|
|
7326
|
+
label: "is not empty",
|
|
7327
|
+
value: "def",
|
|
7328
|
+
editorType: "empty"
|
|
7329
|
+
}
|
|
7330
|
+
];
|
|
7331
|
+
var DATE_OPERATORS = [
|
|
7332
|
+
{
|
|
7333
|
+
label: "is...",
|
|
7334
|
+
value: "eq",
|
|
7335
|
+
editorType: "date"
|
|
7336
|
+
},
|
|
7337
|
+
{
|
|
7338
|
+
label: "is between...",
|
|
7339
|
+
value: "between",
|
|
7340
|
+
editorType: "dateRange"
|
|
7341
|
+
},
|
|
7342
|
+
{
|
|
7343
|
+
label: "is before...",
|
|
7344
|
+
value: "lt",
|
|
7345
|
+
editorType: "date"
|
|
7346
|
+
},
|
|
7347
|
+
{
|
|
7348
|
+
label: "is after...",
|
|
7349
|
+
value: "gt",
|
|
7350
|
+
editorType: "date"
|
|
7351
|
+
},
|
|
7352
|
+
{
|
|
7353
|
+
label: "is on or before...",
|
|
7354
|
+
value: "lte",
|
|
7355
|
+
editorType: "date"
|
|
7356
|
+
},
|
|
7357
|
+
{
|
|
7358
|
+
label: "is on or after...",
|
|
7359
|
+
value: "gte",
|
|
7360
|
+
editorType: "date"
|
|
7361
|
+
},
|
|
7362
|
+
{
|
|
7363
|
+
label: "is empty",
|
|
7364
|
+
value: "ndef",
|
|
7365
|
+
editorType: "empty"
|
|
7366
|
+
},
|
|
7367
|
+
{
|
|
7368
|
+
label: "is not...",
|
|
7369
|
+
value: "neq",
|
|
7370
|
+
editorType: "date"
|
|
7371
|
+
},
|
|
7372
|
+
{
|
|
7373
|
+
label: "is not empty",
|
|
7374
|
+
value: "def",
|
|
7375
|
+
editorType: "empty"
|
|
7376
|
+
}
|
|
7377
|
+
];
|
|
7378
|
+
var TEXTBOX_OPERATORS = [
|
|
7379
|
+
{
|
|
7380
|
+
label: "is...",
|
|
7381
|
+
value: "eq",
|
|
7382
|
+
editorType: "text"
|
|
7383
|
+
},
|
|
7384
|
+
{
|
|
7385
|
+
label: "is empty",
|
|
7386
|
+
value: "ndef",
|
|
7387
|
+
editorType: "empty"
|
|
7388
|
+
},
|
|
7389
|
+
{
|
|
7390
|
+
label: "contains...",
|
|
7391
|
+
value: "match",
|
|
7392
|
+
editorType: "text"
|
|
7393
|
+
},
|
|
7394
|
+
{
|
|
7395
|
+
label: "starts with...",
|
|
7396
|
+
value: "starts",
|
|
7397
|
+
editorType: "text"
|
|
7398
|
+
},
|
|
7399
|
+
{
|
|
7400
|
+
label: "is not...",
|
|
7401
|
+
value: "neq",
|
|
7402
|
+
editorType: "text"
|
|
7403
|
+
},
|
|
7404
|
+
{
|
|
7405
|
+
label: "is not empty",
|
|
7406
|
+
value: "def",
|
|
7407
|
+
editorType: "empty"
|
|
7408
|
+
}
|
|
7409
|
+
];
|
|
7410
|
+
var USER_OPERATORS = [
|
|
7411
|
+
{
|
|
7412
|
+
label: "is...",
|
|
7413
|
+
value: "eq",
|
|
7414
|
+
editorType: "text"
|
|
7415
|
+
},
|
|
7416
|
+
{
|
|
7417
|
+
label: "contains...",
|
|
7418
|
+
value: "match",
|
|
7419
|
+
editorType: "text"
|
|
7420
|
+
},
|
|
7421
|
+
{
|
|
7422
|
+
label: "starts with...",
|
|
7423
|
+
value: "starts",
|
|
7424
|
+
editorType: "text"
|
|
7425
|
+
},
|
|
7426
|
+
{
|
|
7427
|
+
label: "is not...",
|
|
7428
|
+
value: "neq",
|
|
7429
|
+
editorType: "text"
|
|
7430
|
+
}
|
|
7431
|
+
];
|
|
7432
|
+
var SYSTEM_DATE_OPERATORS = [
|
|
7433
|
+
{
|
|
7434
|
+
label: "is...",
|
|
7435
|
+
value: "sys-date-eq",
|
|
7436
|
+
editorType: "date"
|
|
7437
|
+
},
|
|
7438
|
+
{
|
|
7439
|
+
label: "is between...",
|
|
7440
|
+
value: "sys-date-between",
|
|
7441
|
+
editorType: "dateRange"
|
|
7442
|
+
},
|
|
7443
|
+
{
|
|
7444
|
+
label: "is before...",
|
|
7445
|
+
value: "sys-date-lt",
|
|
7446
|
+
editorType: "date"
|
|
7447
|
+
},
|
|
7448
|
+
{
|
|
7449
|
+
label: "is after...",
|
|
7450
|
+
value: "sys-date-gt",
|
|
7451
|
+
editorType: "date"
|
|
7452
|
+
},
|
|
7453
|
+
{
|
|
7454
|
+
label: "is on or before...",
|
|
7455
|
+
value: "sys-date-lte",
|
|
7456
|
+
editorType: "date"
|
|
7457
|
+
},
|
|
7458
|
+
{
|
|
7459
|
+
label: "is on or after...",
|
|
7460
|
+
value: "sys-date-gte",
|
|
7461
|
+
editorType: "date"
|
|
7462
|
+
},
|
|
7463
|
+
{
|
|
7464
|
+
label: "is not...",
|
|
7465
|
+
value: "sys-date-neq",
|
|
7466
|
+
editorType: "date"
|
|
7467
|
+
}
|
|
7468
|
+
];
|
|
7469
|
+
var RICHTEXT_OPERATORS = [
|
|
7470
|
+
{
|
|
7471
|
+
label: "is empty",
|
|
7472
|
+
value: "ndef",
|
|
7473
|
+
editorType: "empty"
|
|
7474
|
+
},
|
|
7475
|
+
{
|
|
7476
|
+
label: "contains...",
|
|
7477
|
+
value: "match",
|
|
7478
|
+
editorType: "text"
|
|
7479
|
+
},
|
|
7480
|
+
{
|
|
7481
|
+
label: "starts with...",
|
|
7482
|
+
value: "starts",
|
|
7483
|
+
editorType: "text"
|
|
7484
|
+
},
|
|
7485
|
+
{
|
|
7486
|
+
label: "is not empty",
|
|
7487
|
+
value: "def",
|
|
7488
|
+
editorType: "empty"
|
|
7489
|
+
}
|
|
7490
|
+
];
|
|
7491
|
+
var CHECKBOX_OPERATORS = [
|
|
7492
|
+
{
|
|
7493
|
+
label: "is checked...",
|
|
7494
|
+
value: "def",
|
|
7495
|
+
editorType: "empty"
|
|
7496
|
+
},
|
|
7497
|
+
{
|
|
7498
|
+
label: "is not checked...",
|
|
7499
|
+
value: "ndef",
|
|
7500
|
+
editorType: "empty"
|
|
7501
|
+
}
|
|
7502
|
+
];
|
|
7503
|
+
var SYSTEM_FIELD_OPERATORS = [
|
|
7504
|
+
{
|
|
7505
|
+
label: "is...",
|
|
7506
|
+
value: "eq",
|
|
7507
|
+
editorType: "singleChoice"
|
|
7508
|
+
},
|
|
7509
|
+
{
|
|
7510
|
+
label: "is any of...",
|
|
7511
|
+
value: "in",
|
|
7512
|
+
editorType: "multiChoice"
|
|
7513
|
+
},
|
|
7514
|
+
{
|
|
7515
|
+
label: "is not...",
|
|
7516
|
+
value: "neq",
|
|
7517
|
+
editorType: "singleChoice"
|
|
7518
|
+
},
|
|
7519
|
+
{
|
|
7520
|
+
label: "is none of...",
|
|
7521
|
+
value: "nin",
|
|
7522
|
+
editorType: "multiChoice"
|
|
7523
|
+
}
|
|
7524
|
+
];
|
|
7525
|
+
var PUBLISH_STATUS_FIELD_OPERATORS = [
|
|
7526
|
+
{
|
|
7527
|
+
label: "is...",
|
|
7528
|
+
value: "eq",
|
|
7529
|
+
editorType: "statusSingleChoice"
|
|
7530
|
+
},
|
|
7531
|
+
{
|
|
7532
|
+
label: "is any of...",
|
|
7533
|
+
value: "in",
|
|
7534
|
+
editorType: "statusMultiChoice"
|
|
7535
|
+
},
|
|
7536
|
+
{
|
|
7537
|
+
label: "is not...",
|
|
7538
|
+
value: "neq",
|
|
7539
|
+
editorType: "statusSingleChoice"
|
|
7540
|
+
},
|
|
7541
|
+
{
|
|
7542
|
+
label: "is none of...",
|
|
7543
|
+
value: "nin",
|
|
7544
|
+
editorType: "statusMultiChoice"
|
|
7545
|
+
}
|
|
7546
|
+
];
|
|
7547
|
+
|
|
7548
|
+
// src/components/SearchAndFilter/FilterButton.tsx
|
|
7549
|
+
import { Counter as Counter2, Icon as Icon6 } from "@uniformdev/design-system";
|
|
7550
|
+
|
|
7551
|
+
// src/components/SearchAndFilter/styles/SearchAndFilter.styles.ts
|
|
7552
|
+
import { css as css38 } from "@emotion/react";
|
|
7553
|
+
import { cq, fadeInLtr } from "@uniformdev/design-system";
|
|
7554
|
+
var SearchAndFilterControlsWrapper = (gridColumns) => css38`
|
|
7555
|
+
align-items: stretch;
|
|
7556
|
+
display: grid;
|
|
7557
|
+
grid-template-columns: ${gridColumns};
|
|
7558
|
+
gap: var(--spacing-sm);
|
|
7559
|
+
`;
|
|
7560
|
+
var SearchAndFilterOutterControlWrapper = (gridColumns) => css38`
|
|
7561
|
+
align-items: stretch;
|
|
7562
|
+
display: grid;
|
|
7563
|
+
grid-template-columns: ${gridColumns};
|
|
7564
|
+
gap: var(--spacing-sm);
|
|
7565
|
+
`;
|
|
7566
|
+
var ConditionalFilterRow = css38`
|
|
7567
|
+
display: grid;
|
|
7568
|
+
grid-template-columns: 35px 1fr;
|
|
7569
|
+
gap: var(--spacing-sm);
|
|
7570
|
+
margin-left: var(--spacing-base);
|
|
7571
|
+
|
|
7572
|
+
${cq("380px")} {
|
|
7573
|
+
align-items: center;
|
|
7574
|
+
|
|
7575
|
+
&:after {
|
|
7576
|
+
content: '';
|
|
7577
|
+
display: block;
|
|
7578
|
+
height: 1px;
|
|
7579
|
+
background: var(--gray-300);
|
|
7580
|
+
width: calc(100% - var(--spacing-base));
|
|
7581
|
+
margin-left: var(--spacing-base);
|
|
7582
|
+
}
|
|
7583
|
+
&:last-of-type:after {
|
|
7584
|
+
display: none;
|
|
7585
|
+
}
|
|
7586
|
+
}
|
|
7587
|
+
|
|
7588
|
+
&:nth-of-type(2) {
|
|
7589
|
+
margin-left: 0;
|
|
7590
|
+
grid-template-columns: 50px 1fr;
|
|
7591
|
+
}
|
|
7592
|
+
|
|
7593
|
+
${cq("580px")} {
|
|
7594
|
+
&:after {
|
|
7595
|
+
display: none;
|
|
7596
|
+
}
|
|
7597
|
+
}
|
|
7598
|
+
|
|
7599
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
7600
|
+
animation: ${fadeInLtr} var(--duration-fast) var(--timing-ease-out);
|
|
7601
|
+
}
|
|
7602
|
+
`;
|
|
7603
|
+
var ConditionalInputRow = css38`
|
|
7604
|
+
display: flex;
|
|
7605
|
+
gap: var(--spacing-sm);
|
|
7606
|
+
flex-wrap: wrap;
|
|
7607
|
+
|
|
7608
|
+
${cq("380px")} {
|
|
7609
|
+
& > div:nth-child(-n + 2) {
|
|
7610
|
+
width: calc(50% - var(--spacing-sm));
|
|
7611
|
+
}
|
|
7612
|
+
|
|
7613
|
+
& > div:nth-child(n + 3) {
|
|
7614
|
+
width: calc(100% - 48px);
|
|
7615
|
+
}
|
|
7616
|
+
}
|
|
7617
|
+
${cq("764px")} {
|
|
7618
|
+
display: grid;
|
|
7619
|
+
grid-template-columns: 200px 160px 1fr 32px;
|
|
7620
|
+
|
|
7621
|
+
& > div:nth-child(n) {
|
|
7622
|
+
width: auto;
|
|
7623
|
+
}
|
|
7624
|
+
}
|
|
7625
|
+
`;
|
|
7626
|
+
var SearchInput = css38`
|
|
7627
|
+
max-height: 40px;
|
|
7628
|
+
min-height: unset;
|
|
7629
|
+
`;
|
|
7630
|
+
var FilterButton = css38`
|
|
7631
|
+
align-items: center;
|
|
7632
|
+
background: var(--white);
|
|
7633
|
+
border: 1px solid var(--gray-300);
|
|
7634
|
+
border-radius: var(--rounded-full);
|
|
7635
|
+
color: var(--typography-base);
|
|
7636
|
+
display: flex;
|
|
7637
|
+
font-size: var(--fs-sm);
|
|
7638
|
+
gap: var(--spacing-sm);
|
|
7639
|
+
padding: var(--spacing-sm) var(--spacing-base);
|
|
7640
|
+
max-height: 40px;
|
|
7641
|
+
transition: color var(--duration-fast) var(--timing-ease-out),
|
|
7642
|
+
background-color var(--duration-fast) var(--timing-ease-out),
|
|
7643
|
+
border-color var(--duration-fast) var(--timing-ease-out),
|
|
7644
|
+
box-shadow var(--duration-fast) var(--timing-ease-out);
|
|
7645
|
+
|
|
7646
|
+
svg {
|
|
7647
|
+
color: var(--gray-300);
|
|
7648
|
+
transition: color var(--duration-fast) var(--timing-ease-out);
|
|
7649
|
+
}
|
|
7650
|
+
|
|
7651
|
+
&:hover,
|
|
7652
|
+
:where([aria-expanded='true']) {
|
|
7653
|
+
outline: none;
|
|
7654
|
+
background: var(--gray-200);
|
|
7655
|
+
border-color: var(--gray-300);
|
|
7656
|
+
|
|
7657
|
+
svg {
|
|
7658
|
+
color: var(--typography-base);
|
|
7659
|
+
}
|
|
7660
|
+
}
|
|
7661
|
+
|
|
7662
|
+
&:disabled {
|
|
7663
|
+
opacity: var(--opacity-50);
|
|
7664
|
+
}
|
|
7665
|
+
`;
|
|
7666
|
+
var FilterButtonText = css38`
|
|
7667
|
+
overflow: hidden;
|
|
7668
|
+
text-overflow: ellipsis;
|
|
7669
|
+
white-space: nowrap;
|
|
7670
|
+
max-width: 14ch;
|
|
7671
|
+
`;
|
|
7672
|
+
var FilterButtonSelected = css38`
|
|
7673
|
+
background: var(--gray-100);
|
|
7674
|
+
border-color: var(--gray-300);
|
|
7675
|
+
|
|
7676
|
+
svg {
|
|
7677
|
+
color: var(--accent-dark);
|
|
7678
|
+
}
|
|
7679
|
+
`;
|
|
7680
|
+
var FilterButtonWithOptions = css38`
|
|
7681
|
+
:where([aria-expanded='true']) {
|
|
7682
|
+
background: var(--purple-rain-100);
|
|
7683
|
+
border-color: var(--accent-light);
|
|
7684
|
+
color: var(--typography-base);
|
|
7685
|
+
box-shadow: var(--elevation-100);
|
|
7686
|
+
|
|
7687
|
+
svg {
|
|
7688
|
+
color: var(--accent-dark);
|
|
7689
|
+
}
|
|
7690
|
+
}
|
|
7691
|
+
`;
|
|
7692
|
+
var SearchIcon = css38`
|
|
7693
|
+
color: var(--icon-color);
|
|
7694
|
+
position: absolute;
|
|
7695
|
+
inset: 0 var(--spacing-base) 0 auto;
|
|
7696
|
+
margin: auto;
|
|
7697
|
+
transition: color var(--duration-fast) var(--timing-ease-out);
|
|
7698
|
+
`;
|
|
7699
|
+
var AddConditionalBtn = css38`
|
|
7700
|
+
align-items: center;
|
|
7701
|
+
background: transparent;
|
|
7702
|
+
border: none;
|
|
7703
|
+
color: var(--primary-action-default);
|
|
7704
|
+
display: flex;
|
|
7705
|
+
gap: var(--spacing-sm);
|
|
7706
|
+
transition: color var(--duration-fast) var(--timing-ease-out);
|
|
7707
|
+
padding: 0;
|
|
7708
|
+
|
|
7709
|
+
&:hover,
|
|
7710
|
+
&:focus {
|
|
7711
|
+
color: var(--primary-action-hover);
|
|
7712
|
+
}
|
|
7713
|
+
|
|
7714
|
+
&:disabled {
|
|
7715
|
+
color: var(--gray-400);
|
|
7716
|
+
}
|
|
7717
|
+
`;
|
|
7718
|
+
var Title = css38`
|
|
7719
|
+
color: var(--typography-light);
|
|
7720
|
+
|
|
7721
|
+
&:focus {
|
|
7722
|
+
outline: none;
|
|
7723
|
+
}
|
|
7724
|
+
`;
|
|
7725
|
+
var ResetConditionsBtn = css38`
|
|
7726
|
+
background: transparent;
|
|
7727
|
+
border: none;
|
|
7728
|
+
color: var(--action-destructive-default);
|
|
7729
|
+
transition: color var(--duration-fast) var(--timing-ease-out);
|
|
7730
|
+
padding: 0;
|
|
7731
|
+
|
|
7732
|
+
&:hover,
|
|
7733
|
+
&:focus {
|
|
7734
|
+
color: var(--action-destructive-hover);
|
|
7735
|
+
}
|
|
7736
|
+
`;
|
|
7737
|
+
var IconBtn = css38`
|
|
7738
|
+
background: transparent;
|
|
7739
|
+
border: none;
|
|
7740
|
+
padding: var(--spacing-sm);
|
|
7741
|
+
`;
|
|
7742
|
+
var SearchAndFilterOptionsContainer = css38`
|
|
7743
|
+
background: var(--gray-50);
|
|
7744
|
+
border: 1px solid var(--gray-300);
|
|
7745
|
+
border-radius: var(--rounded-base);
|
|
7746
|
+
container-type: inline-size;
|
|
7747
|
+
display: flex;
|
|
7748
|
+
flex-direction: column;
|
|
7749
|
+
gap: var(--spacing-sm);
|
|
7750
|
+
padding: var(--spacing-md) 0 var(--spacing-base);
|
|
7751
|
+
will-change: height;
|
|
7752
|
+
position: relative;
|
|
7753
|
+
z-index: 1;
|
|
7754
|
+
`;
|
|
7755
|
+
var SearchAndFilterOptionsInnerContainer = css38`
|
|
7756
|
+
display: flex;
|
|
7757
|
+
flex-direction: column;
|
|
7758
|
+
gap: var(--spacing-sm);
|
|
7759
|
+
padding-inline: var(--spacing-md);
|
|
7760
|
+
`;
|
|
7761
|
+
var SearchAndFilterButtonGroup = css38`
|
|
7762
|
+
margin-top: var(--spacing-xs);
|
|
7763
|
+
margin-left: calc(56px + var(--spacing-md));
|
|
7764
|
+
`;
|
|
7765
|
+
|
|
7766
|
+
// src/components/SearchAndFilter/FilterButton.tsx
|
|
7767
|
+
import { jsx as jsx69, jsxs as jsxs42 } from "@emotion/react/jsx-runtime";
|
|
7768
|
+
var FilterButton2 = ({
|
|
7769
|
+
text = "Filters",
|
|
7770
|
+
icon = "filter-add",
|
|
7771
|
+
filterCount,
|
|
7772
|
+
hasSelectedValue,
|
|
7773
|
+
dataTestId,
|
|
7774
|
+
...props
|
|
7775
|
+
}) => {
|
|
7776
|
+
return /* @__PURE__ */ jsxs42(
|
|
7777
|
+
"button",
|
|
7778
|
+
{
|
|
7779
|
+
type: "button",
|
|
7780
|
+
css: [
|
|
7781
|
+
FilterButton,
|
|
7782
|
+
hasSelectedValue ? FilterButtonSelected : void 0,
|
|
7783
|
+
filterCount ? [FilterButtonWithOptions, FilterButtonSelected] : void 0
|
|
7784
|
+
],
|
|
7785
|
+
...props,
|
|
7786
|
+
"data-testid": dataTestId,
|
|
7787
|
+
children: [
|
|
7788
|
+
/* @__PURE__ */ jsx69(Icon6, { icon, iconColor: "currentColor", size: "1rem" }),
|
|
7789
|
+
/* @__PURE__ */ jsx69("span", { css: FilterButtonText, children: text }),
|
|
7790
|
+
filterCount ? /* @__PURE__ */ jsx69(Counter2, { count: filterCount, bgColor: "var(--white)" }) : null
|
|
7791
|
+
]
|
|
7792
|
+
}
|
|
7793
|
+
);
|
|
7794
|
+
};
|
|
7795
|
+
|
|
7796
|
+
// src/components/SearchAndFilter/FilterControls.tsx
|
|
7797
|
+
import { InputKeywordSearch as InputKeywordSearch2 } from "@uniformdev/design-system";
|
|
7798
|
+
import { useEffect as useEffect21, useState as useState21 } from "react";
|
|
7799
|
+
import { useDebounce as useDebounce5 } from "react-use";
|
|
7800
|
+
|
|
7801
|
+
// src/components/SearchAndFilter/hooks/useSearchAndFilter.tsx
|
|
7802
|
+
import { VerticalRhythm as VerticalRhythm5 } from "@uniformdev/design-system";
|
|
7803
|
+
import {
|
|
7804
|
+
createContext as createContext6,
|
|
7805
|
+
useCallback as useCallback6,
|
|
7806
|
+
useContext as useContext8,
|
|
7807
|
+
useDeferredValue as useDeferredValue2,
|
|
7808
|
+
useEffect as useEffect20,
|
|
7809
|
+
useMemo as useMemo17,
|
|
7810
|
+
useState as useState20
|
|
7811
|
+
} from "react";
|
|
7812
|
+
|
|
7813
|
+
// src/components/SearchAndFilter/FilterEditor.tsx
|
|
7814
|
+
import { FieldMessage, Input as Input6, InputComboBox, StatusBullet } from "@uniformdev/design-system";
|
|
7815
|
+
import { useEffect as useEffect19, useState as useState19 } from "react";
|
|
7816
|
+
import { useDebounce as useDebounce4 } from "react-use";
|
|
7817
|
+
import { Fragment as Fragment14, jsx as jsx70, jsxs as jsxs43 } from "@emotion/react/jsx-runtime";
|
|
7818
|
+
var readOnlyAttributes = {
|
|
7819
|
+
isSearchable: false,
|
|
7820
|
+
menuIsOpen: false,
|
|
7821
|
+
isClearable: false
|
|
7822
|
+
};
|
|
7823
|
+
var FilterMultiChoiceEditor = ({
|
|
7824
|
+
value,
|
|
7825
|
+
options,
|
|
7826
|
+
disabled,
|
|
7827
|
+
readOnly,
|
|
7828
|
+
valueTestId,
|
|
7829
|
+
...props
|
|
7830
|
+
}) => {
|
|
7831
|
+
const readOnlyProps = readOnly ? readOnlyAttributes : {};
|
|
7832
|
+
const isClearable = !readOnly || !disabled;
|
|
7833
|
+
return /* @__PURE__ */ jsx70("div", { "data-testid": valueTestId, children: /* @__PURE__ */ jsx70(
|
|
7834
|
+
InputComboBox,
|
|
7835
|
+
{
|
|
7836
|
+
...props,
|
|
7837
|
+
placeholder: "Type to search...",
|
|
7838
|
+
options,
|
|
7839
|
+
isMulti: true,
|
|
7840
|
+
isClearable,
|
|
7841
|
+
isDisabled: disabled,
|
|
7842
|
+
onChange: (e) => {
|
|
7843
|
+
var _a;
|
|
7844
|
+
return props.onChange((_a = e == null ? void 0 : e.map((option) => option.value)) != null ? _a : []);
|
|
7845
|
+
},
|
|
7846
|
+
value: options == null ? void 0 : options.filter((option) => value == null ? void 0 : value.includes(option.value)),
|
|
7847
|
+
"aria-readonly": readOnly,
|
|
7848
|
+
styles: {
|
|
7849
|
+
menu(base) {
|
|
7850
|
+
return {
|
|
7851
|
+
...base,
|
|
7852
|
+
minWidth: "max-content"
|
|
7853
|
+
};
|
|
7854
|
+
}
|
|
7855
|
+
},
|
|
7856
|
+
...readOnlyProps
|
|
7857
|
+
}
|
|
7858
|
+
) });
|
|
7859
|
+
};
|
|
7860
|
+
var FilterSingleChoiceEditor = ({
|
|
7861
|
+
options,
|
|
7862
|
+
value,
|
|
7863
|
+
disabled,
|
|
7864
|
+
readOnly,
|
|
7865
|
+
onChange,
|
|
7866
|
+
valueTestId
|
|
7867
|
+
}) => {
|
|
7868
|
+
const readOnlyProps = readOnly ? readOnlyAttributes : {};
|
|
7869
|
+
return /* @__PURE__ */ jsx70("div", { "data-testid": valueTestId, children: /* @__PURE__ */ jsx70(
|
|
7870
|
+
InputComboBox,
|
|
7871
|
+
{
|
|
7872
|
+
placeholder: "Type to search...",
|
|
7873
|
+
options,
|
|
7874
|
+
isClearable: true,
|
|
7875
|
+
onChange: (e) => {
|
|
7876
|
+
var _a;
|
|
7877
|
+
return onChange((_a = e == null ? void 0 : e.value) != null ? _a : "");
|
|
7878
|
+
},
|
|
7879
|
+
isDisabled: disabled,
|
|
7880
|
+
value: options == null ? void 0 : options.find((option) => option.value === value),
|
|
7881
|
+
"aria-readonly": readOnly,
|
|
7882
|
+
styles: {
|
|
7883
|
+
menu(base) {
|
|
7884
|
+
return {
|
|
7885
|
+
...base,
|
|
7886
|
+
minWidth: "max-content"
|
|
7887
|
+
};
|
|
7888
|
+
}
|
|
7889
|
+
},
|
|
7890
|
+
...readOnlyProps
|
|
7891
|
+
}
|
|
7892
|
+
) });
|
|
7893
|
+
};
|
|
7894
|
+
var CustomOptions = ({ label, value }) => {
|
|
7895
|
+
return /* @__PURE__ */ jsx70(StatusBullet, { status: label, message: value });
|
|
7896
|
+
};
|
|
7897
|
+
var StatusMultiEditor = ({
|
|
7898
|
+
options,
|
|
7899
|
+
value,
|
|
7900
|
+
disabled,
|
|
7901
|
+
readOnly,
|
|
7902
|
+
onChange,
|
|
7903
|
+
valueTestId
|
|
7904
|
+
}) => {
|
|
7905
|
+
const readOnlyProps = readOnly ? readOnlyAttributes : {};
|
|
7906
|
+
return /* @__PURE__ */ jsx70("div", { "data-testid": valueTestId, children: /* @__PURE__ */ jsx70(
|
|
7907
|
+
InputComboBox,
|
|
7908
|
+
{
|
|
7909
|
+
options,
|
|
7910
|
+
isMulti: true,
|
|
7911
|
+
onChange: (e) => {
|
|
7912
|
+
var _a;
|
|
7913
|
+
return onChange((_a = e.map((item) => item.value)) != null ? _a : []);
|
|
7914
|
+
},
|
|
7915
|
+
formatOptionLabel: CustomOptions,
|
|
7916
|
+
"aria-readonly": readOnly,
|
|
7917
|
+
value: options == null ? void 0 : options.filter((option) => value == null ? void 0 : value.includes(option.value)),
|
|
7918
|
+
isDisabled: disabled,
|
|
7919
|
+
styles: {
|
|
7920
|
+
menu(base) {
|
|
7921
|
+
return {
|
|
7922
|
+
...base,
|
|
7923
|
+
minWidth: "max-content"
|
|
7924
|
+
};
|
|
7925
|
+
}
|
|
7926
|
+
},
|
|
7927
|
+
...readOnlyProps
|
|
7928
|
+
}
|
|
7929
|
+
) });
|
|
7930
|
+
};
|
|
7931
|
+
var StatusSingleEditor = ({
|
|
7932
|
+
options,
|
|
7933
|
+
value,
|
|
7934
|
+
disabled,
|
|
7935
|
+
readOnly,
|
|
7936
|
+
onChange,
|
|
7937
|
+
valueTestId
|
|
7938
|
+
}) => {
|
|
7939
|
+
const readOnlyProps = readOnly ? readOnlyAttributes : {};
|
|
7940
|
+
return /* @__PURE__ */ jsx70("div", { "data-testid": valueTestId, children: /* @__PURE__ */ jsx70(
|
|
7941
|
+
InputComboBox,
|
|
7942
|
+
{
|
|
7943
|
+
options,
|
|
7944
|
+
onChange: (e) => {
|
|
7945
|
+
var _a;
|
|
7946
|
+
return onChange((_a = e == null ? void 0 : e.value) != null ? _a : "");
|
|
7947
|
+
},
|
|
7948
|
+
formatOptionLabel: CustomOptions,
|
|
7949
|
+
"aria-readonly": readOnly,
|
|
7950
|
+
value: options == null ? void 0 : options.find((option) => option.value === value),
|
|
7951
|
+
isDisabled: disabled,
|
|
7952
|
+
styles: {
|
|
7953
|
+
menu(base) {
|
|
7954
|
+
return {
|
|
7955
|
+
...base,
|
|
7956
|
+
minWidth: "max-content"
|
|
7957
|
+
};
|
|
7958
|
+
}
|
|
7959
|
+
},
|
|
7960
|
+
...readOnlyProps
|
|
7961
|
+
}
|
|
7962
|
+
) });
|
|
7963
|
+
};
|
|
7964
|
+
var TextEditor = ({
|
|
7965
|
+
onChange,
|
|
7966
|
+
ariaLabel,
|
|
7967
|
+
value,
|
|
7968
|
+
readOnly,
|
|
7969
|
+
valueTestId
|
|
7970
|
+
}) => {
|
|
7971
|
+
const [innerValue, setInnerValue] = useState19(value != null ? value : "");
|
|
7972
|
+
useDebounce4(() => onChange(innerValue), 500, [innerValue]);
|
|
7973
|
+
return /* @__PURE__ */ jsx70(
|
|
7974
|
+
Input6,
|
|
7975
|
+
{
|
|
7976
|
+
showLabel: false,
|
|
7977
|
+
label: ariaLabel,
|
|
7978
|
+
onChange: (e) => setInnerValue(e.currentTarget.value),
|
|
7979
|
+
placeholder: "Enter phrase to search\u2026",
|
|
7980
|
+
value: innerValue,
|
|
7981
|
+
readOnly,
|
|
7982
|
+
"data-testid": valueTestId
|
|
7983
|
+
}
|
|
7984
|
+
);
|
|
7985
|
+
};
|
|
7986
|
+
var NumberRangeEditor = ({
|
|
7987
|
+
onChange,
|
|
7988
|
+
disabled,
|
|
7989
|
+
ariaLabel,
|
|
7990
|
+
value,
|
|
7991
|
+
readOnly,
|
|
7992
|
+
valueTestId
|
|
7993
|
+
}) => {
|
|
7994
|
+
const [minValue, setMinValue] = useState19("");
|
|
7995
|
+
const [maxValue, setMaxValue] = useState19("");
|
|
7996
|
+
const [error, setError] = useState19("");
|
|
7997
|
+
useDebounce4(
|
|
7998
|
+
() => {
|
|
7999
|
+
if (minValue && maxValue && !error) {
|
|
8000
|
+
onChange([minValue, maxValue]);
|
|
8001
|
+
} else {
|
|
8002
|
+
onChange([]);
|
|
8003
|
+
}
|
|
8004
|
+
},
|
|
8005
|
+
500,
|
|
8006
|
+
[minValue, maxValue]
|
|
8007
|
+
);
|
|
8008
|
+
useEffect19(() => {
|
|
8009
|
+
if (!maxValue && !minValue) {
|
|
8010
|
+
return;
|
|
8011
|
+
}
|
|
8012
|
+
const max = Number(maxValue);
|
|
8013
|
+
const min = Number(minValue);
|
|
8014
|
+
if (max < min || min > max) {
|
|
8015
|
+
setError("Please enter a valid numeric range");
|
|
8016
|
+
return;
|
|
8017
|
+
}
|
|
8018
|
+
if (maxValue && !minValue || minValue && !maxValue) {
|
|
8019
|
+
setError("Please enter both a low and high number");
|
|
8020
|
+
return;
|
|
8021
|
+
}
|
|
8022
|
+
if (error) {
|
|
8023
|
+
setError("");
|
|
8024
|
+
}
|
|
8025
|
+
if (min && max) {
|
|
8026
|
+
setMinValue(minValue);
|
|
8027
|
+
setMaxValue(maxValue);
|
|
8028
|
+
}
|
|
8029
|
+
}, [maxValue, minValue, setError]);
|
|
8030
|
+
return /* @__PURE__ */ jsxs43(Fragment14, { children: [
|
|
8031
|
+
/* @__PURE__ */ jsxs43("div", { css: twoColumnGrid, "data-testid": valueTestId, children: [
|
|
8032
|
+
/* @__PURE__ */ jsx70(
|
|
8033
|
+
Input6,
|
|
8034
|
+
{
|
|
8035
|
+
label: `${ariaLabel}-min`,
|
|
8036
|
+
type: "number",
|
|
8037
|
+
showLabel: false,
|
|
8038
|
+
min: 0,
|
|
8039
|
+
placeholder: "Low",
|
|
8040
|
+
onChange: (e) => setMinValue(e.currentTarget.value),
|
|
8041
|
+
"aria-invalid": !error ? false : true,
|
|
8042
|
+
disabled,
|
|
8043
|
+
value: value ? value[0] : "",
|
|
8044
|
+
readOnly,
|
|
8045
|
+
"data-testid": "value-low"
|
|
8046
|
+
}
|
|
8047
|
+
),
|
|
8048
|
+
/* @__PURE__ */ jsx70(
|
|
8049
|
+
Input6,
|
|
8050
|
+
{
|
|
8051
|
+
type: "number",
|
|
8052
|
+
label: `${ariaLabel}-max`,
|
|
8053
|
+
showLabel: false,
|
|
8054
|
+
min: 0,
|
|
8055
|
+
placeholder: "High",
|
|
8056
|
+
onChange: (e) => setMaxValue(e.currentTarget.value),
|
|
8057
|
+
"aria-invalid": !error ? false : true,
|
|
8058
|
+
disabled,
|
|
8059
|
+
value: value ? value[1] : "",
|
|
8060
|
+
readOnly,
|
|
8061
|
+
"data-testid": "value-high"
|
|
8062
|
+
}
|
|
8063
|
+
)
|
|
8064
|
+
] }),
|
|
8065
|
+
/* @__PURE__ */ jsx70(ErrorContainer, { errorMessage: error })
|
|
8066
|
+
] });
|
|
8067
|
+
};
|
|
8068
|
+
var NumberEditor = ({
|
|
8069
|
+
ariaLabel,
|
|
8070
|
+
onChange,
|
|
8071
|
+
disabled,
|
|
8072
|
+
value,
|
|
8073
|
+
readOnly,
|
|
8074
|
+
valueTestId
|
|
8075
|
+
}) => {
|
|
8076
|
+
const [innerValue, setInnerValue] = useState19(value != null ? value : "");
|
|
8077
|
+
useDebounce4(() => onChange(innerValue), 500, [innerValue]);
|
|
8078
|
+
return /* @__PURE__ */ jsx70(
|
|
8079
|
+
Input6,
|
|
8080
|
+
{
|
|
8081
|
+
label: ariaLabel,
|
|
8082
|
+
type: "number",
|
|
8083
|
+
showLabel: false,
|
|
8084
|
+
min: 0,
|
|
8085
|
+
onChange: (e) => setInnerValue(e.currentTarget.value),
|
|
8086
|
+
disabled,
|
|
8087
|
+
value: innerValue,
|
|
8088
|
+
readOnly,
|
|
8089
|
+
"data-testid": valueTestId
|
|
8090
|
+
}
|
|
8091
|
+
);
|
|
8092
|
+
};
|
|
8093
|
+
var DateEditor = ({
|
|
8094
|
+
onChange,
|
|
8095
|
+
ariaLabel,
|
|
8096
|
+
disabled,
|
|
8097
|
+
value,
|
|
8098
|
+
readOnly,
|
|
8099
|
+
valueTestId
|
|
8100
|
+
}) => {
|
|
8101
|
+
const [innerValue, setInnerValue] = useState19(value != null ? value : "");
|
|
8102
|
+
useDebounce4(() => onChange(innerValue), 500, [innerValue]);
|
|
8103
|
+
return /* @__PURE__ */ jsx70(
|
|
8104
|
+
Input6,
|
|
8105
|
+
{
|
|
8106
|
+
type: "date",
|
|
8107
|
+
label: ariaLabel,
|
|
8108
|
+
showLabel: false,
|
|
8109
|
+
onChange: (e) => setInnerValue(e.currentTarget.value),
|
|
8110
|
+
disabled,
|
|
8111
|
+
value: innerValue,
|
|
8112
|
+
readOnly,
|
|
8113
|
+
"data-testid": valueTestId
|
|
8114
|
+
}
|
|
8115
|
+
);
|
|
8116
|
+
};
|
|
8117
|
+
var DateRangeEditor = ({
|
|
8118
|
+
ariaLabel,
|
|
8119
|
+
onChange,
|
|
8120
|
+
disabled,
|
|
8121
|
+
value,
|
|
8122
|
+
readOnly,
|
|
8123
|
+
valueTestId
|
|
8124
|
+
}) => {
|
|
8125
|
+
const [minDateValue, setMinDateValue] = useState19(value ? value[0] : "");
|
|
8126
|
+
const [maxDateValue, setMaxDateValue] = useState19(value ? value[1] : "");
|
|
8127
|
+
const [error, setError] = useState19("");
|
|
8128
|
+
useDebounce4(
|
|
8129
|
+
() => {
|
|
8130
|
+
if (minDateValue && maxDateValue && !error) {
|
|
8131
|
+
onChange([minDateValue, maxDateValue]);
|
|
8132
|
+
} else {
|
|
8133
|
+
onChange([]);
|
|
8134
|
+
}
|
|
8135
|
+
},
|
|
8136
|
+
500,
|
|
8137
|
+
[minDateValue, maxDateValue]
|
|
8138
|
+
);
|
|
8139
|
+
useEffect19(() => {
|
|
8140
|
+
if (!minDateValue || !maxDateValue) {
|
|
8141
|
+
return;
|
|
8142
|
+
}
|
|
8143
|
+
const minDate = new Date(minDateValue);
|
|
8144
|
+
const maxDate = new Date(maxDateValue);
|
|
8145
|
+
if (maxDate < minDate) {
|
|
8146
|
+
setError("The max date cannot be lower than the min date");
|
|
8147
|
+
return;
|
|
8148
|
+
}
|
|
8149
|
+
if (maxDate && !minDate) {
|
|
8150
|
+
setError("Please enter both a low and high date");
|
|
8151
|
+
return;
|
|
8152
|
+
}
|
|
8153
|
+
const minDateString = minDate.toDateString();
|
|
8154
|
+
const maxDateString = maxDate.toDateString();
|
|
8155
|
+
if (minDateString === maxDateString || maxDateString === minDateString) {
|
|
8156
|
+
setError("The min and max date cannot be the same");
|
|
8157
|
+
return;
|
|
8158
|
+
}
|
|
8159
|
+
if (minDate > maxDate) {
|
|
8160
|
+
setError("The min date cannot be higher than the max date");
|
|
8161
|
+
return;
|
|
8162
|
+
}
|
|
8163
|
+
if (error) {
|
|
8164
|
+
setError("");
|
|
8165
|
+
}
|
|
8166
|
+
if (minDate && maxDate) {
|
|
8167
|
+
setMinDateValue(minDateValue);
|
|
8168
|
+
setMaxDateValue(maxDateValue);
|
|
8169
|
+
} else {
|
|
8170
|
+
setMinDateValue("");
|
|
8171
|
+
setMaxDateValue("");
|
|
8172
|
+
}
|
|
8173
|
+
}, [minDateValue, maxDateValue, setError]);
|
|
8174
|
+
return /* @__PURE__ */ jsxs43(Fragment14, { children: [
|
|
8175
|
+
/* @__PURE__ */ jsxs43("div", { css: twoColumnGrid, "data-testid": valueTestId, children: [
|
|
8176
|
+
/* @__PURE__ */ jsx70(
|
|
8177
|
+
Input6,
|
|
8178
|
+
{
|
|
8179
|
+
label: `${ariaLabel}-min-date`,
|
|
8180
|
+
type: "date",
|
|
8181
|
+
showLabel: false,
|
|
8182
|
+
value: minDateValue,
|
|
8183
|
+
onChange: (e) => setMinDateValue(e.currentTarget.value),
|
|
8184
|
+
"aria-invalid": !error ? false : true,
|
|
8185
|
+
disabled,
|
|
8186
|
+
readOnly
|
|
8187
|
+
}
|
|
8188
|
+
),
|
|
8189
|
+
/* @__PURE__ */ jsx70(
|
|
8190
|
+
Input6,
|
|
8191
|
+
{
|
|
8192
|
+
label: `${ariaLabel}-max-date`,
|
|
8193
|
+
type: "date",
|
|
8194
|
+
showLabel: false,
|
|
8195
|
+
value: maxDateValue,
|
|
8196
|
+
onChange: (e) => setMaxDateValue(e.currentTarget.value),
|
|
8197
|
+
"aria-invalid": !error ? false : true,
|
|
8198
|
+
disabled,
|
|
8199
|
+
readOnly
|
|
8200
|
+
}
|
|
8201
|
+
)
|
|
8202
|
+
] }),
|
|
8203
|
+
/* @__PURE__ */ jsx70(ErrorContainer, { errorMessage: error })
|
|
8204
|
+
] });
|
|
8205
|
+
};
|
|
8206
|
+
var FilterEditorRenderer = ({ editorType, ...props }) => {
|
|
8207
|
+
const { filterMapper: contextFilterMapper } = useSearchAndFilter();
|
|
8208
|
+
const Editor = contextFilterMapper == null ? void 0 : contextFilterMapper[editorType];
|
|
8209
|
+
if (!Editor) {
|
|
8210
|
+
return null;
|
|
8211
|
+
}
|
|
8212
|
+
if (editorType === "empty") {
|
|
8213
|
+
return null;
|
|
8214
|
+
}
|
|
8215
|
+
return /* @__PURE__ */ jsx70(Editor, { ...props });
|
|
8216
|
+
};
|
|
8217
|
+
var filterMapper = {
|
|
8218
|
+
multiChoice: FilterMultiChoiceEditor,
|
|
8219
|
+
singleChoice: FilterSingleChoiceEditor,
|
|
8220
|
+
date: DateEditor,
|
|
8221
|
+
dateRange: DateRangeEditor,
|
|
8222
|
+
text: TextEditor,
|
|
8223
|
+
numberRange: NumberRangeEditor,
|
|
8224
|
+
number: NumberEditor,
|
|
8225
|
+
statusMultiChoice: StatusMultiEditor,
|
|
8226
|
+
statusSingleChoice: StatusSingleEditor,
|
|
8227
|
+
empty: null
|
|
8228
|
+
};
|
|
8229
|
+
var ErrorContainer = ({ errorMessage }) => {
|
|
8230
|
+
return /* @__PURE__ */ jsx70(
|
|
8231
|
+
"div",
|
|
8232
|
+
{
|
|
8233
|
+
css: {
|
|
8234
|
+
gridColumn: "span 6",
|
|
8235
|
+
order: 6
|
|
8236
|
+
},
|
|
8237
|
+
children: /* @__PURE__ */ jsx70(FieldMessage, { errorMessage })
|
|
8238
|
+
}
|
|
8239
|
+
);
|
|
8240
|
+
};
|
|
8241
|
+
var twoColumnGrid = {
|
|
8242
|
+
display: "grid",
|
|
8243
|
+
gridTemplateColumns: "1fr 1fr",
|
|
8244
|
+
gap: "var(--spacing-sm);"
|
|
8245
|
+
};
|
|
8246
|
+
|
|
8247
|
+
// src/components/SearchAndFilter/hooks/useSearchAndFilter.tsx
|
|
8248
|
+
import { jsx as jsx71 } from "@emotion/react/jsx-runtime";
|
|
8249
|
+
var SearchAndFilterContext = createContext6({
|
|
8250
|
+
searchTerm: "",
|
|
8251
|
+
setSearchTerm: () => {
|
|
8252
|
+
},
|
|
8253
|
+
filterVisibility: void 0,
|
|
8254
|
+
setFilterVisibility: () => {
|
|
8255
|
+
},
|
|
8256
|
+
filters: [],
|
|
8257
|
+
setFilters: () => {
|
|
8258
|
+
},
|
|
8259
|
+
handleAddFilter: () => {
|
|
8260
|
+
},
|
|
8261
|
+
handleResetFilters: () => {
|
|
8262
|
+
},
|
|
8263
|
+
handleDeleteFilter: () => {
|
|
8264
|
+
},
|
|
8265
|
+
filterOptions: [],
|
|
8266
|
+
validFilterQuery: [],
|
|
8267
|
+
filterMapper: {},
|
|
8268
|
+
totalResults: 0
|
|
8269
|
+
});
|
|
8270
|
+
var SearchAndFilterProvider = ({
|
|
8271
|
+
filters,
|
|
8272
|
+
filterOptions,
|
|
8273
|
+
filterVisible = false,
|
|
8274
|
+
defaultSearchTerm = "",
|
|
8275
|
+
onSearchChange,
|
|
8276
|
+
onChange,
|
|
8277
|
+
resetFilterValues = [{ field: "", operator: "", value: "" }],
|
|
8278
|
+
totalResults,
|
|
8279
|
+
filterMapper: filterMapper2 = filterMapper,
|
|
8280
|
+
children
|
|
8281
|
+
}) => {
|
|
8282
|
+
const [searchTerm, setSearchTerm] = useState20(defaultSearchTerm);
|
|
8283
|
+
const deferredSearchTerm = useDeferredValue2(searchTerm);
|
|
8284
|
+
const [filterVisibility, setFilterVisibility] = useState20(filterVisible);
|
|
8285
|
+
const handleSearchTerm = useCallback6(
|
|
8286
|
+
(term) => {
|
|
8287
|
+
setSearchTerm(term);
|
|
8288
|
+
onSearchChange == null ? void 0 : onSearchChange(term);
|
|
8289
|
+
},
|
|
8290
|
+
[setSearchTerm, onSearchChange]
|
|
8291
|
+
);
|
|
8292
|
+
const handleToggleFilterVisibility = useCallback6(
|
|
8293
|
+
(visible) => setFilterVisibility(visible),
|
|
8294
|
+
[setFilterVisibility]
|
|
8295
|
+
);
|
|
8296
|
+
const handleAddFilter = useCallback6(() => {
|
|
8297
|
+
onChange([...filters, { field: "", operator: "", value: "" }]);
|
|
8298
|
+
}, [filters, onChange]);
|
|
8299
|
+
const handleResetFilters = useCallback6(() => {
|
|
8300
|
+
onChange(resetFilterValues);
|
|
8301
|
+
}, [onChange, resetFilterValues]);
|
|
8302
|
+
const handleDeleteFilter = useCallback6(
|
|
8303
|
+
(index) => {
|
|
8304
|
+
const remainingFilters = filters.filter((_, i) => i !== index);
|
|
8305
|
+
onChange(remainingFilters);
|
|
8306
|
+
},
|
|
8307
|
+
[filters, onChange]
|
|
8308
|
+
);
|
|
8309
|
+
const validFilterQuery = useMemo17(() => {
|
|
8310
|
+
const hasValidFilters = filters.every((f) => f.field && f.operator && f.value);
|
|
8311
|
+
if (hasValidFilters) {
|
|
8312
|
+
return filters;
|
|
8313
|
+
}
|
|
8314
|
+
}, [filters]);
|
|
8315
|
+
useEffect20(() => {
|
|
8316
|
+
if (filterVisibility) {
|
|
8317
|
+
const handleEscKeyFilterClose = (e) => {
|
|
8318
|
+
if (e.key === "Escape") {
|
|
8319
|
+
setFilterVisibility(false);
|
|
8320
|
+
}
|
|
8321
|
+
};
|
|
8322
|
+
document.addEventListener("keydown", (e) => handleEscKeyFilterClose(e));
|
|
8323
|
+
return () => {
|
|
8324
|
+
document.removeEventListener("keydown", (e) => handleEscKeyFilterClose(e));
|
|
8325
|
+
};
|
|
8326
|
+
}
|
|
8327
|
+
}, [filterVisibility]);
|
|
8328
|
+
return /* @__PURE__ */ jsx71(
|
|
8329
|
+
SearchAndFilterContext.Provider,
|
|
8330
|
+
{
|
|
8331
|
+
value: {
|
|
8332
|
+
searchTerm: deferredSearchTerm,
|
|
8333
|
+
setSearchTerm: (e) => handleSearchTerm(e),
|
|
8334
|
+
filterVisibility,
|
|
8335
|
+
setFilterVisibility: (e) => handleToggleFilterVisibility(e),
|
|
8336
|
+
filters,
|
|
8337
|
+
setFilters: (e) => onChange(e),
|
|
8338
|
+
handleAddFilter,
|
|
8339
|
+
handleResetFilters,
|
|
8340
|
+
handleDeleteFilter,
|
|
8341
|
+
filterOptions,
|
|
8342
|
+
validFilterQuery,
|
|
8343
|
+
totalResults,
|
|
8344
|
+
filterMapper: filterMapper2
|
|
8345
|
+
},
|
|
8346
|
+
children: /* @__PURE__ */ jsx71(VerticalRhythm5, { children })
|
|
8347
|
+
}
|
|
8348
|
+
);
|
|
8349
|
+
};
|
|
8350
|
+
var useSearchAndFilter = () => {
|
|
8351
|
+
const value = useContext8(SearchAndFilterContext);
|
|
8352
|
+
return { ...value };
|
|
8353
|
+
};
|
|
8354
|
+
|
|
8355
|
+
// src/components/SearchAndFilter/FilterControls.tsx
|
|
8356
|
+
import { Fragment as Fragment15, jsx as jsx72, jsxs as jsxs44 } from "@emotion/react/jsx-runtime";
|
|
8357
|
+
var FilterControls = ({
|
|
8358
|
+
children,
|
|
8359
|
+
hideSearchInput
|
|
8360
|
+
}) => {
|
|
8361
|
+
const { setFilterVisibility, filterVisibility, setSearchTerm, validFilterQuery, searchTerm } = useSearchAndFilter();
|
|
8362
|
+
const [localeSearchTerm, setLocaleSearchTerm] = useState21("");
|
|
8363
|
+
useDebounce5(
|
|
8364
|
+
() => {
|
|
8365
|
+
setSearchTerm(localeSearchTerm);
|
|
8366
|
+
},
|
|
8367
|
+
300,
|
|
8368
|
+
[localeSearchTerm, searchTerm]
|
|
8369
|
+
);
|
|
8370
|
+
useEffect21(() => {
|
|
8371
|
+
if (searchTerm === "") {
|
|
8372
|
+
setLocaleSearchTerm("");
|
|
8373
|
+
}
|
|
8374
|
+
}, [searchTerm]);
|
|
8375
|
+
return /* @__PURE__ */ jsxs44(Fragment15, { children: [
|
|
8376
|
+
/* @__PURE__ */ jsx72(
|
|
8377
|
+
FilterButton2,
|
|
8378
|
+
{
|
|
8379
|
+
"aria-controls": "search-and-filter-options",
|
|
8380
|
+
"aria-label": "filter options",
|
|
8381
|
+
"aria-haspopup": "true",
|
|
8382
|
+
text: "Filter/Sort",
|
|
8383
|
+
"aria-expanded": filterVisibility === true,
|
|
8384
|
+
filterCount: validFilterQuery == null ? void 0 : validFilterQuery.length,
|
|
8385
|
+
onClick: () => setFilterVisibility(!filterVisibility),
|
|
8386
|
+
dataTestId: "filters-button"
|
|
8387
|
+
}
|
|
8388
|
+
),
|
|
8389
|
+
hideSearchInput ? null : /* @__PURE__ */ jsx72(
|
|
8390
|
+
InputKeywordSearch2,
|
|
8391
|
+
{
|
|
8392
|
+
placeholder: "Search...",
|
|
8393
|
+
onSearchTextChanged: (e) => setLocaleSearchTerm(e),
|
|
8394
|
+
value: localeSearchTerm,
|
|
8395
|
+
compact: true,
|
|
8396
|
+
rounded: true,
|
|
8397
|
+
css: SearchInput
|
|
8398
|
+
}
|
|
8399
|
+
),
|
|
8400
|
+
children
|
|
8401
|
+
] });
|
|
8402
|
+
};
|
|
8403
|
+
|
|
8404
|
+
// src/components/SearchAndFilter/FilterItem.tsx
|
|
8405
|
+
import { Icon as Icon7, InputComboBox as InputComboBox2 } from "@uniformdev/design-system";
|
|
8406
|
+
import { useMemo as useMemo18 } from "react";
|
|
8407
|
+
|
|
8408
|
+
// src/components/SearchAndFilter/FilterMenu.tsx
|
|
8409
|
+
import { HorizontalRhythm as HorizontalRhythm8, VerticalRhythm as VerticalRhythm6 } from "@uniformdev/design-system";
|
|
8410
|
+
import React12, { useEffect as useEffect22 } from "react";
|
|
8411
|
+
import { jsx as jsx73, jsxs as jsxs45 } from "@emotion/react/jsx-runtime";
|
|
8412
|
+
var SearchAndFilterOptionsContainer2 = ({
|
|
8413
|
+
buttonRow,
|
|
8414
|
+
additionalFiltersContainer,
|
|
8415
|
+
children
|
|
8416
|
+
}) => {
|
|
8417
|
+
return /* @__PURE__ */ jsxs45("div", { css: SearchAndFilterOptionsContainer, children: [
|
|
8418
|
+
/* @__PURE__ */ jsx73("div", { css: SearchAndFilterOptionsInnerContainer, children }),
|
|
8419
|
+
buttonRow ? /* @__PURE__ */ jsx73(
|
|
8420
|
+
HorizontalRhythm8,
|
|
8421
|
+
{
|
|
8422
|
+
css: SearchAndFilterButtonGroup,
|
|
8423
|
+
gap: "sm",
|
|
8424
|
+
align: "center",
|
|
8425
|
+
justify: "space-between",
|
|
8426
|
+
children: buttonRow
|
|
8427
|
+
}
|
|
8428
|
+
) : null,
|
|
8429
|
+
additionalFiltersContainer ? /* @__PURE__ */ jsx73("div", { children: additionalFiltersContainer }) : null
|
|
8430
|
+
] });
|
|
8431
|
+
};
|
|
8432
|
+
var FilterMenu = ({
|
|
8433
|
+
id,
|
|
8434
|
+
filterTitle = "Show results",
|
|
8435
|
+
menuControls,
|
|
8436
|
+
additionalFiltersContainer,
|
|
8437
|
+
children,
|
|
8438
|
+
dataTestId,
|
|
8439
|
+
resetButtonText = "reset"
|
|
8440
|
+
}) => {
|
|
8441
|
+
const { filterVisibility, setFilterVisibility, handleResetFilters, filters } = useSearchAndFilter();
|
|
8442
|
+
const innerMenuRef = React12.useRef(null);
|
|
8443
|
+
useEffect22(() => {
|
|
8444
|
+
var _a;
|
|
8445
|
+
if (filterVisibility) {
|
|
8446
|
+
(_a = innerMenuRef.current) == null ? void 0 : _a.focus();
|
|
8447
|
+
}
|
|
8448
|
+
}, [filterVisibility]);
|
|
8449
|
+
return /* @__PURE__ */ jsx73(VerticalRhythm6, { gap: "sm", "aria-haspopup": "true", id, "data-testid": dataTestId, children: filterVisibility ? /* @__PURE__ */ jsxs45(
|
|
8450
|
+
SearchAndFilterOptionsContainer2,
|
|
8451
|
+
{
|
|
8452
|
+
buttonRow: menuControls,
|
|
8453
|
+
additionalFiltersContainer,
|
|
8454
|
+
children: [
|
|
8455
|
+
/* @__PURE__ */ jsxs45(HorizontalRhythm8, { gap: "sm", align: "center", justify: "space-between", children: [
|
|
8456
|
+
/* @__PURE__ */ jsx73("span", { css: Title, ref: innerMenuRef, tabIndex: 0, children: filterTitle }),
|
|
8457
|
+
(filters == null ? void 0 : filters.length) ? /* @__PURE__ */ jsx73(
|
|
8458
|
+
"button",
|
|
8459
|
+
{
|
|
8460
|
+
type: "button",
|
|
8461
|
+
css: ResetConditionsBtn,
|
|
8462
|
+
onClick: () => {
|
|
8463
|
+
handleResetFilters();
|
|
8464
|
+
setFilterVisibility(false);
|
|
8465
|
+
},
|
|
8466
|
+
"data-testid": "reset-filters",
|
|
8467
|
+
children: resetButtonText
|
|
8468
|
+
}
|
|
8469
|
+
) : null
|
|
8470
|
+
] }),
|
|
8471
|
+
children
|
|
8472
|
+
]
|
|
8473
|
+
}
|
|
8474
|
+
) : null });
|
|
8475
|
+
};
|
|
8476
|
+
|
|
8477
|
+
// src/components/SearchAndFilter/FilterItem.tsx
|
|
8478
|
+
import { jsx as jsx74, jsxs as jsxs46 } from "@emotion/react/jsx-runtime";
|
|
8479
|
+
var FilterItem = ({
|
|
8480
|
+
index,
|
|
8481
|
+
paramOptions,
|
|
8482
|
+
operatorOptions,
|
|
8483
|
+
valueOptions,
|
|
8484
|
+
onParamChange,
|
|
8485
|
+
onOperatorChange,
|
|
8486
|
+
onValueChange
|
|
8487
|
+
}) => {
|
|
8488
|
+
var _a, _b;
|
|
8489
|
+
const { filters, handleDeleteFilter, filterOptions } = useSearchAndFilter();
|
|
8490
|
+
const label = filters[index].field !== "" ? filters[index].field : "unknown filter field";
|
|
8491
|
+
const operatorLabel = filters[index].operator !== "" ? `operator ${filters[index].operator}` : "unknown operator";
|
|
8492
|
+
const metaDataLabel = filters[index].value !== "" ? `value ${filters[index].value}` : "unknown value";
|
|
8493
|
+
const metaDataPossibleOptions = (_b = (_a = operatorOptions.find((op) => filters[index].operator === op.value)) == null ? void 0 : _a.editorType) != null ? _b : "singleChoice";
|
|
8494
|
+
const { selectedFieldValue, selectedOperatorValue, selectedMetaValue, readOnly, bindable } = useMemo18(() => {
|
|
8495
|
+
var _a2;
|
|
8496
|
+
const currentSelectedFilter = filterOptions.find((item) => {
|
|
8497
|
+
var _a3;
|
|
8498
|
+
return (_a3 = item.options) == null ? void 0 : _a3.find((op) => op.value === filters[index].field);
|
|
8499
|
+
});
|
|
8500
|
+
const selectedFieldValue2 = (_a2 = currentSelectedFilter == null ? void 0 : currentSelectedFilter.options) == null ? void 0 : _a2.find((item) => {
|
|
8501
|
+
return filters[index].field === item.value;
|
|
8502
|
+
});
|
|
8503
|
+
const isCurrentFieldReadOnly = selectedFieldValue2 == null ? void 0 : selectedFieldValue2.readOnly;
|
|
8504
|
+
const selectedOperatorValue2 = operatorOptions == null ? void 0 : operatorOptions.find((item) => {
|
|
8505
|
+
return filters[index].operator === item.value;
|
|
8506
|
+
});
|
|
8507
|
+
return {
|
|
8508
|
+
selectedFieldValue: selectedFieldValue2,
|
|
8509
|
+
selectedOperatorValue: selectedOperatorValue2 != null ? selectedOperatorValue2 : void 0,
|
|
8510
|
+
selectedMetaValue: filters[index].value,
|
|
8511
|
+
readOnly: isCurrentFieldReadOnly,
|
|
8512
|
+
bindable: selectedFieldValue2 == null ? void 0 : selectedFieldValue2.bindable
|
|
8513
|
+
};
|
|
8514
|
+
}, [filters, filterOptions, index, operatorOptions]);
|
|
8515
|
+
const readOnlyProps = readOnly ? {
|
|
8516
|
+
"aria-readonly": true,
|
|
8517
|
+
isSearchable: false,
|
|
8518
|
+
menuIsOpen: false,
|
|
8519
|
+
isClearable: false
|
|
8520
|
+
} : {};
|
|
8521
|
+
return /* @__PURE__ */ jsxs46("div", { css: ConditionalFilterRow, "data-testid": "filter-item", children: [
|
|
8522
|
+
/* @__PURE__ */ jsx74("span", { children: index === 0 ? "Where" : "and" }),
|
|
8523
|
+
/* @__PURE__ */ jsxs46("div", { css: ConditionalInputRow, children: [
|
|
8524
|
+
/* @__PURE__ */ jsx74(
|
|
8525
|
+
InputComboBox2,
|
|
8526
|
+
{
|
|
8527
|
+
"aria-label": label,
|
|
8528
|
+
options: paramOptions,
|
|
8529
|
+
onChange: (e) => {
|
|
8530
|
+
var _a2;
|
|
8531
|
+
onParamChange((_a2 = e == null ? void 0 : e.value) != null ? _a2 : "");
|
|
8532
|
+
},
|
|
8533
|
+
isOptionDisabled: (option) => {
|
|
8534
|
+
var _a2;
|
|
8535
|
+
return (_a2 = option == null ? void 0 : option.disabled) != null ? _a2 : false;
|
|
8536
|
+
},
|
|
8537
|
+
styles: {
|
|
8538
|
+
menu(base) {
|
|
8539
|
+
return {
|
|
8540
|
+
...base,
|
|
8541
|
+
minWidth: "max-content"
|
|
8542
|
+
};
|
|
8543
|
+
}
|
|
8544
|
+
},
|
|
8545
|
+
value: selectedFieldValue,
|
|
8546
|
+
...readOnlyProps,
|
|
8547
|
+
id: "filter-field",
|
|
8548
|
+
name: `filter-field-${index}`
|
|
8549
|
+
}
|
|
8550
|
+
),
|
|
8551
|
+
/* @__PURE__ */ jsx74(
|
|
8552
|
+
InputComboBox2,
|
|
8553
|
+
{
|
|
8554
|
+
"aria-label": operatorLabel,
|
|
8555
|
+
options: operatorOptions,
|
|
8556
|
+
onChange: (e) => {
|
|
8557
|
+
var _a2;
|
|
8558
|
+
return onOperatorChange((_a2 = e == null ? void 0 : e.value) != null ? _a2 : "");
|
|
8559
|
+
},
|
|
8560
|
+
isDisabled: !filters[index].field,
|
|
8561
|
+
value: selectedOperatorValue,
|
|
8562
|
+
styles: {
|
|
8563
|
+
menu(base) {
|
|
8564
|
+
return {
|
|
8565
|
+
...base,
|
|
8566
|
+
minWidth: "max-content"
|
|
8567
|
+
};
|
|
8568
|
+
}
|
|
8569
|
+
},
|
|
8570
|
+
...readOnlyProps,
|
|
8571
|
+
id: "filter-operator",
|
|
8572
|
+
name: `filter-operator-${index}`
|
|
8573
|
+
}
|
|
8574
|
+
),
|
|
8575
|
+
/* @__PURE__ */ jsx74(
|
|
8576
|
+
FilterEditorRenderer,
|
|
8577
|
+
{
|
|
8578
|
+
"aria-label": metaDataLabel,
|
|
8579
|
+
editorType: metaDataPossibleOptions,
|
|
8580
|
+
options: valueOptions,
|
|
8581
|
+
onChange: (e) => onValueChange(e != null ? e : ""),
|
|
8582
|
+
readOnly,
|
|
8583
|
+
bindable,
|
|
8584
|
+
disabled: !filters[index].operator,
|
|
8585
|
+
value: selectedMetaValue,
|
|
8586
|
+
valueTestId: "filter-value"
|
|
8587
|
+
}
|
|
8588
|
+
),
|
|
8589
|
+
readOnly || index === 0 ? null : /* @__PURE__ */ jsx74(
|
|
8590
|
+
"button",
|
|
8591
|
+
{
|
|
8592
|
+
type: "button",
|
|
8593
|
+
onClick: () => handleDeleteFilter(index),
|
|
8594
|
+
"aria-label": "delete filter",
|
|
8595
|
+
css: IconBtn,
|
|
8596
|
+
"data-testid": "delete-filter",
|
|
8597
|
+
children: /* @__PURE__ */ jsx74(Icon7, { icon: "trash", iconColor: "red", size: "1rem" })
|
|
8598
|
+
}
|
|
8599
|
+
)
|
|
8600
|
+
] })
|
|
8601
|
+
] });
|
|
8602
|
+
};
|
|
8603
|
+
var FilterItems = ({
|
|
8604
|
+
addButtonText = "add condition",
|
|
8605
|
+
additionalFiltersContainer
|
|
8606
|
+
}) => {
|
|
8607
|
+
const { filterOptions, filters, setFilters, handleAddFilter } = useSearchAndFilter();
|
|
8608
|
+
const handleUpdateFilter = (index, prop, value) => {
|
|
8609
|
+
var _a, _b, _c, _d, _e;
|
|
8610
|
+
const next = [...filters];
|
|
8611
|
+
next[index] = { ...next[index], [prop]: value };
|
|
8612
|
+
if (prop === "operator") {
|
|
8613
|
+
if (["eq", "neq", "lt", "gt"].includes(value) && Array.isArray(next[index].value)) {
|
|
8614
|
+
next[index].value = next[index].value[0];
|
|
8615
|
+
}
|
|
8616
|
+
if (filters[index].operator === "ndef" || filters[index].operator === "def") {
|
|
8617
|
+
next[index].value = "";
|
|
8618
|
+
}
|
|
8619
|
+
if (["between"].includes(value) && Array.isArray(next[index].value) === false) {
|
|
8620
|
+
next[index].value = [next[index].value, ""];
|
|
8621
|
+
}
|
|
8622
|
+
if (value === "def" || value === "true") {
|
|
8623
|
+
next[index].value = "true";
|
|
8624
|
+
}
|
|
8625
|
+
if (value === "ndef" || value === "false") {
|
|
8626
|
+
next[index].value = "false";
|
|
8627
|
+
}
|
|
8628
|
+
}
|
|
8629
|
+
if (prop === "field") {
|
|
8630
|
+
const firstOperatorInAvailableOperators = (_e = (_d = (_c = (_b = (_a = filterOptions.find((fo) => {
|
|
8631
|
+
var _a2;
|
|
8632
|
+
return (_a2 = fo.options) == null ? void 0 : _a2.find((op) => op.value === value);
|
|
8633
|
+
})) == null ? void 0 : _a.options) == null ? void 0 : _b.find((op) => op.value === next[index].field)) == null ? void 0 : _c.operatorOptions) == null ? void 0 : _d[0].value) != null ? _e : "eq";
|
|
8634
|
+
next[index].operator = firstOperatorInAvailableOperators;
|
|
8635
|
+
next[index].value = "";
|
|
8636
|
+
}
|
|
8637
|
+
setFilters(next);
|
|
8638
|
+
};
|
|
8639
|
+
return /* @__PURE__ */ jsx74(
|
|
8640
|
+
FilterMenu,
|
|
8641
|
+
{
|
|
8642
|
+
id: "search-and-filter-options",
|
|
8643
|
+
dataTestId: "search-and-filter-options",
|
|
8644
|
+
menuControls: /* @__PURE__ */ jsxs46(
|
|
8645
|
+
"button",
|
|
8646
|
+
{
|
|
8647
|
+
type: "button",
|
|
8648
|
+
css: AddConditionalBtn,
|
|
8649
|
+
onClick: handleAddFilter,
|
|
8650
|
+
"data-testid": "add-filter",
|
|
8651
|
+
children: [
|
|
8652
|
+
/* @__PURE__ */ jsx74(Icon7, { icon: "math-plus", iconColor: "currentColor", size: "1rem" }),
|
|
8653
|
+
addButtonText
|
|
8654
|
+
]
|
|
8655
|
+
}
|
|
8656
|
+
),
|
|
8657
|
+
additionalFiltersContainer,
|
|
8658
|
+
children: filters.map((item, i) => {
|
|
8659
|
+
var _a, _b, _c, _d, _e, _f;
|
|
8660
|
+
const availableTypeOptions = (_b = (_a = filterOptions.find((fo) => {
|
|
8661
|
+
var _a2;
|
|
8662
|
+
return (_a2 = fo.options) == null ? void 0 : _a2.find((op) => op.value === item.field);
|
|
8663
|
+
})) == null ? void 0 : _a.options) != null ? _b : [];
|
|
8664
|
+
const possibleValueOptions = (_d = (_c = availableTypeOptions == null ? void 0 : availableTypeOptions.find((op) => op.value === item.field)) == null ? void 0 : _c.valueOptions) != null ? _d : [];
|
|
8665
|
+
const possibleOperators = (_f = (_e = availableTypeOptions == null ? void 0 : availableTypeOptions.find((op) => op.value === item.field)) == null ? void 0 : _e.operatorOptions) != null ? _f : [];
|
|
8666
|
+
return /* @__PURE__ */ jsx74(
|
|
8667
|
+
FilterItem,
|
|
8668
|
+
{
|
|
8669
|
+
index: i,
|
|
8670
|
+
paramOptions: filterOptions,
|
|
8671
|
+
onParamChange: (e) => handleUpdateFilter(i, "field", e),
|
|
8672
|
+
operatorOptions: possibleOperators,
|
|
8673
|
+
onOperatorChange: (e) => handleUpdateFilter(i, "operator", e),
|
|
8674
|
+
onValueChange: (e) => handleUpdateFilter(i, "value", e),
|
|
8675
|
+
valueOptions: possibleValueOptions
|
|
8676
|
+
},
|
|
8677
|
+
i
|
|
8678
|
+
);
|
|
8679
|
+
})
|
|
8680
|
+
}
|
|
8681
|
+
);
|
|
8682
|
+
};
|
|
8683
|
+
|
|
8684
|
+
// src/components/SearchAndFilter/SearchAndFilter.tsx
|
|
8685
|
+
import { VerticalRhythm as VerticalRhythm7 } from "@uniformdev/design-system";
|
|
8686
|
+
|
|
8687
|
+
// src/components/SearchAndFilter/SearchAndFilterResultContainer.tsx
|
|
8688
|
+
import { Button as Button6, Callout as Callout6, HorizontalRhythm as HorizontalRhythm9, Paragraph } from "@uniformdev/design-system";
|
|
8689
|
+
import { Fragment as Fragment16, jsx as jsx75, jsxs as jsxs47 } from "@emotion/react/jsx-runtime";
|
|
8690
|
+
var SearchAndFilterResultContainer = ({
|
|
8691
|
+
buttonText,
|
|
8692
|
+
clearButtonLabel = "clear",
|
|
8693
|
+
calloutTitle,
|
|
8694
|
+
calloutText,
|
|
8695
|
+
onHandleClear,
|
|
8696
|
+
hideClearButton
|
|
8697
|
+
}) => {
|
|
8698
|
+
const { searchTerm, setSearchTerm, totalResults, setFilters, filters } = useSearchAndFilter();
|
|
8699
|
+
const automateCalloutTitle = () => {
|
|
8700
|
+
if (searchTerm && !filters.length) {
|
|
8701
|
+
return "No search results found";
|
|
8702
|
+
}
|
|
8703
|
+
if (filters.length && !searchTerm) {
|
|
8704
|
+
return "No results match the selected filters";
|
|
8705
|
+
}
|
|
8706
|
+
return "No matching results found";
|
|
8707
|
+
};
|
|
8708
|
+
const handleResetFilters = () => {
|
|
8709
|
+
if (searchTerm && !filters.length) {
|
|
8710
|
+
setSearchTerm("");
|
|
8711
|
+
return;
|
|
8712
|
+
} else if (!searchTerm && filters.length) {
|
|
8713
|
+
setFilters([{ field: "", operator: "", value: "" }]);
|
|
8714
|
+
return;
|
|
8715
|
+
} else {
|
|
8716
|
+
setSearchTerm("");
|
|
8717
|
+
setFilters([{ field: "", operator: "", value: "" }]);
|
|
8718
|
+
return;
|
|
8719
|
+
}
|
|
8720
|
+
};
|
|
8721
|
+
if (totalResults && totalResults > 0) {
|
|
8722
|
+
return null;
|
|
8723
|
+
}
|
|
8724
|
+
return /* @__PURE__ */ jsxs47(Fragment16, { children: [
|
|
8725
|
+
/* @__PURE__ */ jsxs47(HorizontalRhythm9, { children: [
|
|
8726
|
+
/* @__PURE__ */ jsxs47("span", { children: [
|
|
8727
|
+
totalResults,
|
|
8728
|
+
" results ",
|
|
8729
|
+
searchTerm ? `for "${searchTerm}"` : null
|
|
8730
|
+
] }),
|
|
8731
|
+
!searchTerm || hideClearButton ? null : /* @__PURE__ */ jsx75(Button6, { buttonType: "ghostDestructive", size: "zero", onClick: () => setSearchTerm(""), children: clearButtonLabel })
|
|
8732
|
+
] }),
|
|
8733
|
+
totalResults === 0 ? /* @__PURE__ */ jsxs47(Callout6, { title: calloutTitle != null ? calloutTitle : automateCalloutTitle(), type: "note", children: [
|
|
8734
|
+
calloutText ? /* @__PURE__ */ jsx75(Paragraph, { children: calloutText }) : null,
|
|
8735
|
+
hideClearButton ? null : /* @__PURE__ */ jsx75(Button6, { buttonType: "tertiaryOutline", size: "xs", onClick: onHandleClear != null ? onHandleClear : handleResetFilters, children: buttonText != null ? buttonText : "Clear search" })
|
|
8736
|
+
] }) : null
|
|
8737
|
+
] });
|
|
8738
|
+
};
|
|
8739
|
+
|
|
8740
|
+
// src/components/SearchAndFilter/SearchAndFilter.tsx
|
|
8741
|
+
import { jsx as jsx76, jsxs as jsxs48 } from "@emotion/react/jsx-runtime";
|
|
8742
|
+
var SearchAndFilter = ({
|
|
8743
|
+
filters,
|
|
8744
|
+
filterOptions,
|
|
8745
|
+
filterVisible,
|
|
8746
|
+
filterControls,
|
|
8747
|
+
viewSwitchControls,
|
|
8748
|
+
resultsContainerView = /* @__PURE__ */ jsx76(SearchAndFilterResultContainer, {}),
|
|
8749
|
+
filterMapper: filterMapper2 = filterMapper,
|
|
8750
|
+
additionalFiltersContainer,
|
|
8751
|
+
onChange,
|
|
8752
|
+
defaultSearchTerm,
|
|
8753
|
+
onSearchChange,
|
|
8754
|
+
totalResults,
|
|
8755
|
+
resetFilterValues = []
|
|
8756
|
+
}) => {
|
|
8757
|
+
return /* @__PURE__ */ jsx76(
|
|
8758
|
+
SearchAndFilterProvider,
|
|
8759
|
+
{
|
|
8760
|
+
filters,
|
|
8761
|
+
filterOptions,
|
|
8762
|
+
filterVisible,
|
|
8763
|
+
onChange,
|
|
8764
|
+
defaultSearchTerm,
|
|
8765
|
+
onSearchChange,
|
|
8766
|
+
totalResults,
|
|
8767
|
+
resetFilterValues,
|
|
8768
|
+
filterMapper: filterMapper2,
|
|
8769
|
+
children: /* @__PURE__ */ jsxs48(VerticalRhythm7, { "data-testid": "search-and-filter", children: [
|
|
8770
|
+
/* @__PURE__ */ jsxs48("div", { css: SearchAndFilterOutterControlWrapper(viewSwitchControls ? "1fr auto" : "1fr"), children: [
|
|
8771
|
+
/* @__PURE__ */ jsx76(
|
|
8772
|
+
"div",
|
|
8773
|
+
{
|
|
8774
|
+
css: SearchAndFilterControlsWrapper(viewSwitchControls ? "auto 1fr 0.05fr" : "auto 1fr"),
|
|
8775
|
+
children: !filterControls ? /* @__PURE__ */ jsx76(FilterControls, { hideSearchInput: !onSearchChange }) : filterControls
|
|
8776
|
+
}
|
|
8777
|
+
),
|
|
8778
|
+
viewSwitchControls
|
|
8779
|
+
] }),
|
|
8780
|
+
/* @__PURE__ */ jsx76(FilterItems, { additionalFiltersContainer }),
|
|
8781
|
+
resultsContainerView
|
|
8782
|
+
] })
|
|
8783
|
+
}
|
|
8784
|
+
);
|
|
8785
|
+
};
|
|
8786
|
+
|
|
8787
|
+
// src/components/SearchAndFilter/SearchOnlyFilter.tsx
|
|
8788
|
+
import { InputKeywordSearch as InputKeywordSearch3 } from "@uniformdev/design-system";
|
|
8789
|
+
import { createContext as createContext7, useState as useState22 } from "react";
|
|
8790
|
+
import { useDebounce as useDebounce6 } from "react-use";
|
|
8791
|
+
import { jsx as jsx77 } from "@emotion/react/jsx-runtime";
|
|
8792
|
+
var SearchOnlyContext = createContext7({
|
|
8793
|
+
searchTerm: "",
|
|
8794
|
+
setSearchTerm: () => {
|
|
8795
|
+
}
|
|
8796
|
+
});
|
|
8797
|
+
var SearchOnlyFilter = ({ onSearchChange, maxWidth }) => {
|
|
8798
|
+
const { searchTerm, setSearchTerm } = useSearchAndFilter();
|
|
8799
|
+
const [localeSearchTerm, setLocaleSearchTerm] = useState22("");
|
|
8800
|
+
useDebounce6(
|
|
8801
|
+
() => {
|
|
8802
|
+
setSearchTerm(localeSearchTerm);
|
|
8803
|
+
onSearchChange == null ? void 0 : onSearchChange(localeSearchTerm);
|
|
8804
|
+
},
|
|
8805
|
+
300,
|
|
8806
|
+
[localeSearchTerm]
|
|
8807
|
+
);
|
|
8808
|
+
return /* @__PURE__ */ jsx77(
|
|
8809
|
+
SearchOnlyContext.Provider,
|
|
8810
|
+
{
|
|
8811
|
+
value: {
|
|
8812
|
+
searchTerm,
|
|
8813
|
+
setSearchTerm: setLocaleSearchTerm
|
|
8814
|
+
},
|
|
8815
|
+
children: /* @__PURE__ */ jsx77("div", { css: { maxWidth: maxWidth != null ? maxWidth : "712px" }, children: /* @__PURE__ */ jsx77(
|
|
8816
|
+
InputKeywordSearch3,
|
|
8817
|
+
{
|
|
8818
|
+
placeholder: "Search...",
|
|
8819
|
+
onSearchTextChanged: (e) => setLocaleSearchTerm(e),
|
|
8820
|
+
value: localeSearchTerm,
|
|
8821
|
+
compact: true,
|
|
8822
|
+
rounded: true
|
|
8823
|
+
}
|
|
8824
|
+
) })
|
|
8825
|
+
}
|
|
8826
|
+
);
|
|
8827
|
+
};
|
|
8828
|
+
|
|
8829
|
+
// src/components/SearchAndFilter2/filtersMapper.tsx
|
|
8830
|
+
import { jsx as jsx78 } from "@emotion/react/jsx-runtime";
|
|
8831
|
+
function withInputVariables(WrappedComponent) {
|
|
8832
|
+
const WithInputVariables = (props) => {
|
|
8833
|
+
if (Array.isArray(props.value) || !props.bindable || props.disabled || props.readOnly) {
|
|
8834
|
+
return /* @__PURE__ */ jsx78(WrappedComponent, { ...props });
|
|
8835
|
+
}
|
|
8836
|
+
return /* @__PURE__ */ jsx78(
|
|
8837
|
+
InputVariables,
|
|
8838
|
+
{
|
|
8839
|
+
disableInlineMenu: true,
|
|
8840
|
+
showMenuPosition: "inline-right",
|
|
8841
|
+
onChange: (newValue) => props.onChange(newValue != null ? newValue : ""),
|
|
8842
|
+
value: props.value,
|
|
8843
|
+
disabled: props.disabled,
|
|
8844
|
+
inputWhenNoVariables: /* @__PURE__ */ jsx78(WrappedComponent, { ...props })
|
|
8845
|
+
}
|
|
8846
|
+
);
|
|
8847
|
+
};
|
|
8848
|
+
return WithInputVariables;
|
|
8849
|
+
}
|
|
8850
|
+
function withInputVariablesForMultiValue(WrappedComponent) {
|
|
8851
|
+
const WithInputVariables = (props) => {
|
|
8852
|
+
var _a;
|
|
8853
|
+
if (!props.bindable || props.disabled || props.readOnly) {
|
|
8854
|
+
return /* @__PURE__ */ jsx78(WrappedComponent, { ...props });
|
|
8855
|
+
}
|
|
8856
|
+
return /* @__PURE__ */ jsx78(
|
|
8857
|
+
InputVariables,
|
|
8858
|
+
{
|
|
8859
|
+
disableInlineMenu: true,
|
|
8860
|
+
showMenuPosition: "inline-right",
|
|
8861
|
+
onChange: (newValue) => props.onChange(newValue ? [newValue] : []),
|
|
8862
|
+
value: (_a = props.value) == null ? void 0 : _a[0],
|
|
8863
|
+
inputWhenNoVariables: /* @__PURE__ */ jsx78(WrappedComponent, { ...props })
|
|
8864
|
+
}
|
|
8865
|
+
);
|
|
8866
|
+
};
|
|
8867
|
+
return WithInputVariables;
|
|
8868
|
+
}
|
|
8869
|
+
var bindableFiltersMapper = {
|
|
8870
|
+
...filterMapper,
|
|
8871
|
+
multiChoice: withInputVariablesForMultiValue(FilterMultiChoiceEditor),
|
|
8872
|
+
singleChoice: withInputVariables(FilterSingleChoiceEditor),
|
|
8873
|
+
date: withInputVariables(DateEditor),
|
|
8874
|
+
text: withInputVariables(TextEditor),
|
|
8875
|
+
number: withInputVariables(NumberEditor)
|
|
8876
|
+
};
|
|
8877
|
+
|
|
8878
|
+
// src/utils/createLocationValidator.ts
|
|
8879
|
+
function createLocationValidator(setValue, validate) {
|
|
8880
|
+
return (dispatch) => setValue((previous) => {
|
|
8881
|
+
const { newValue, options } = dispatch(previous);
|
|
8882
|
+
return { newValue, options: validate(newValue, options) };
|
|
8883
|
+
});
|
|
8884
|
+
}
|
|
8885
|
+
|
|
8886
|
+
// src/utils/useContentDataResourceLocaleInfo.ts
|
|
8887
|
+
import { bindVariables as bindVariables2, createVariableReference as createVariableReference4, LOCALE_DYNAMIC_INPUT_NAME as LOCALE_DYNAMIC_INPUT_NAME2 } from "@uniformdev/canvas";
|
|
8888
|
+
import { useEffect as useEffect23, useRef as useRef16 } from "react";
|
|
8889
|
+
function useContentDataResourceLocaleInfo({
|
|
8890
|
+
locale,
|
|
8891
|
+
setLocale,
|
|
8892
|
+
dynamicInputs
|
|
8893
|
+
}) {
|
|
8894
|
+
var _a;
|
|
8895
|
+
const setLocaleRef = useRef16(setLocale);
|
|
8896
|
+
setLocaleRef.current = setLocale;
|
|
8897
|
+
const { flatVariables } = useVariables();
|
|
8898
|
+
const effectiveLocale = locale != null ? locale : dynamicInputs[LOCALE_DYNAMIC_INPUT_NAME2] ? createVariableReference4(LOCALE_DYNAMIC_INPUT_NAME2) : "";
|
|
8899
|
+
const boundLocale = (_a = bindVariables2({ variables: flatVariables, value: effectiveLocale }).result) != null ? _a : effectiveLocale;
|
|
8900
|
+
useEffect23(() => {
|
|
8901
|
+
if (locale === void 0 && effectiveLocale && setLocaleRef.current) {
|
|
8902
|
+
setLocaleRef.current(createVariableReference4(LOCALE_DYNAMIC_INPUT_NAME2));
|
|
8903
|
+
}
|
|
8904
|
+
}, [locale, effectiveLocale]);
|
|
8905
|
+
return { effectiveLocale, boundLocale: boundLocale ? boundLocale : void 0 };
|
|
8906
|
+
}
|
|
8907
|
+
|
|
8908
|
+
// src/index.ts
|
|
8909
|
+
import {
|
|
8910
|
+
AddListButton as AddListButton2,
|
|
8911
|
+
Button as Button7,
|
|
8912
|
+
Callout as Callout7,
|
|
8913
|
+
DrawerContent,
|
|
8914
|
+
Heading,
|
|
8915
|
+
Input as Input7,
|
|
8916
|
+
InputComboBox as InputComboBox3,
|
|
8917
|
+
InputKeywordSearch as InputKeywordSearch4,
|
|
8918
|
+
InputSelect as InputSelect8,
|
|
8919
|
+
InputToggle,
|
|
8920
|
+
Label,
|
|
8921
|
+
LoadingIndicator as LoadingIndicator5,
|
|
7499
8922
|
LoadingOverlay as LoadingOverlay2,
|
|
7500
8923
|
Menu as Menu4,
|
|
7501
8924
|
MenuItem as MenuItem3,
|
|
@@ -7524,30 +8947,40 @@ export {
|
|
|
7524
8947
|
$createVariableNode,
|
|
7525
8948
|
$isVariableNode,
|
|
7526
8949
|
AddListButton2 as AddListButton,
|
|
7527
|
-
|
|
8950
|
+
Button7 as Button,
|
|
8951
|
+
CHECKBOX_OPERATORS,
|
|
7528
8952
|
Callout7 as Callout,
|
|
7529
|
-
ControlledObjectSearchProvider,
|
|
7530
8953
|
ControlledValuePlugin,
|
|
8954
|
+
DATE_OPERATORS,
|
|
7531
8955
|
DISCONNECT_VARIABLE_COMMAND,
|
|
7532
8956
|
DamSelectedItem,
|
|
7533
8957
|
DataRefreshButton,
|
|
7534
8958
|
DataResourceDynamicInputProvider,
|
|
7535
|
-
DataResourceInputContext,
|
|
7536
8959
|
DataResourceVariablesList,
|
|
7537
8960
|
DataResourceVariablesListExplicit,
|
|
7538
8961
|
DataSourceEditor,
|
|
7539
8962
|
DataTypeEditor,
|
|
8963
|
+
DateEditor,
|
|
8964
|
+
DateRangeEditor,
|
|
7540
8965
|
DefaultSearchRow,
|
|
7541
8966
|
DefaultSelectedItem,
|
|
7542
8967
|
DrawerContent,
|
|
7543
8968
|
EDIT_VARIABLE_COMMAND,
|
|
7544
8969
|
EntrySearch,
|
|
8970
|
+
FilterButton2 as FilterButton,
|
|
8971
|
+
FilterControls,
|
|
8972
|
+
FilterEditorRenderer,
|
|
8973
|
+
FilterItem,
|
|
8974
|
+
FilterItems,
|
|
8975
|
+
FilterMenu,
|
|
8976
|
+
FilterMultiChoiceEditor,
|
|
8977
|
+
FilterSingleChoiceEditor,
|
|
7545
8978
|
Heading,
|
|
7546
8979
|
INSERT_VARIABLE_COMMAND,
|
|
7547
8980
|
icons_exports as Icons,
|
|
7548
|
-
|
|
7549
|
-
InputComboBox,
|
|
7550
|
-
|
|
8981
|
+
Input7 as Input,
|
|
8982
|
+
InputComboBox3 as InputComboBox,
|
|
8983
|
+
InputKeywordSearch4 as InputKeywordSearch,
|
|
7551
8984
|
InputSelect8 as InputSelect,
|
|
7552
8985
|
InputToggle,
|
|
7553
8986
|
InputVariables,
|
|
@@ -7558,18 +8991,20 @@ export {
|
|
|
7558
8991
|
Menu4 as Menu,
|
|
7559
8992
|
MenuItem3 as MenuItem,
|
|
7560
8993
|
MeshApp,
|
|
8994
|
+
NUMBER_OPERATORS,
|
|
8995
|
+
NumberEditor,
|
|
8996
|
+
NumberRangeEditor,
|
|
7561
8997
|
OPEN_INSERT_VARIABLE_COMMAND,
|
|
7562
8998
|
ObjectSearchContainer,
|
|
7563
|
-
ObjectSearchContext,
|
|
7564
8999
|
ObjectSearchFilter,
|
|
7565
9000
|
ObjectSearchFilterContainer2 as ObjectSearchFilterContainer,
|
|
7566
9001
|
ObjectSearchListItem,
|
|
7567
9002
|
ObjectSearchListItemLoadingSkeleton,
|
|
7568
|
-
ObjectSearchListOfSearchResults,
|
|
7569
9003
|
ObjectSearchProvider,
|
|
7570
9004
|
ObjectSearchResultItem,
|
|
7571
9005
|
ObjectSearchResultItemButton,
|
|
7572
9006
|
ObjectSearchResultList,
|
|
9007
|
+
PUBLISH_STATUS_FIELD_OPERATORS,
|
|
7573
9008
|
ParamTypeDynamicDataProvider,
|
|
7574
9009
|
ParameterConnectionIndicator,
|
|
7575
9010
|
ParameterGroup,
|
|
@@ -7597,6 +9032,7 @@ export {
|
|
|
7597
9032
|
ProductSearchRow,
|
|
7598
9033
|
ProductSelectedItem,
|
|
7599
9034
|
QueryFilter,
|
|
9035
|
+
RICHTEXT_OPERATORS,
|
|
7600
9036
|
RequestBody,
|
|
7601
9037
|
RequestHeaders,
|
|
7602
9038
|
RequestMethodSelect,
|
|
@@ -7606,20 +9042,33 @@ export {
|
|
|
7606
9042
|
RequestUrl,
|
|
7607
9043
|
RequestUrlInput,
|
|
7608
9044
|
ResolvableLoadingValue,
|
|
9045
|
+
SYSTEM_DATE_OPERATORS,
|
|
9046
|
+
SYSTEM_FIELD_OPERATORS,
|
|
7609
9047
|
ScrollableList2 as ScrollableList,
|
|
7610
9048
|
ScrollableListItem,
|
|
9049
|
+
SearchAndFilter,
|
|
9050
|
+
SearchAndFilterContext,
|
|
9051
|
+
SearchAndFilterOptionsContainer2 as SearchAndFilterOptionsContainer,
|
|
9052
|
+
SearchAndFilterProvider,
|
|
9053
|
+
SearchAndFilterResultContainer,
|
|
9054
|
+
SearchOnlyContext,
|
|
9055
|
+
SearchOnlyFilter,
|
|
7611
9056
|
SelectionField,
|
|
9057
|
+
StatusMultiEditor,
|
|
9058
|
+
StatusSingleEditor,
|
|
7612
9059
|
Switch,
|
|
9060
|
+
TEXTBOX_OPERATORS,
|
|
9061
|
+
TextEditor,
|
|
7613
9062
|
TextVariableRenderer,
|
|
7614
9063
|
Textarea,
|
|
7615
9064
|
Theme3 as Theme,
|
|
9065
|
+
USER_OPERATORS,
|
|
7616
9066
|
VariableEditor,
|
|
7617
9067
|
VariableNode,
|
|
7618
9068
|
VariablesList,
|
|
7619
9069
|
VariablesPlugin,
|
|
7620
9070
|
VariablesProvider,
|
|
7621
9071
|
badgeIcon,
|
|
7622
|
-
bindQuery,
|
|
7623
9072
|
bindableFiltersMapper,
|
|
7624
9073
|
convertConnectedDataToVariable,
|
|
7625
9074
|
createLocationValidator,
|
|
@@ -7651,6 +9100,7 @@ export {
|
|
|
7651
9100
|
entrySearchSelectInput,
|
|
7652
9101
|
entrySearchSelectOption,
|
|
7653
9102
|
entrySearchWrapper,
|
|
9103
|
+
filterMapper,
|
|
7654
9104
|
hasReferencedVariables,
|
|
7655
9105
|
prettifyBindExpression,
|
|
7656
9106
|
productSearchRowActiveIcon,
|
|
@@ -7692,7 +9142,6 @@ export {
|
|
|
7692
9142
|
urlEncodeRequestUrl,
|
|
7693
9143
|
useConnectedDataAsVariables,
|
|
7694
9144
|
useContentDataResourceLocaleInfo,
|
|
7695
|
-
useDataResourceDynamicInputs,
|
|
7696
9145
|
useDynamicInputsAsVariables,
|
|
7697
9146
|
useMeshLocation,
|
|
7698
9147
|
useObjectSearchContext,
|
|
@@ -7702,6 +9151,7 @@ export {
|
|
|
7702
9151
|
useRequest,
|
|
7703
9152
|
useRequestHeader,
|
|
7704
9153
|
useRequestParameter,
|
|
9154
|
+
useSearchAndFilter,
|
|
7705
9155
|
useUniformMeshSdk,
|
|
7706
9156
|
useVariableEditor,
|
|
7707
9157
|
useVariables,
|