@wallarm-org/design-system 1.12.0 → 1.12.1
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/components/FilterInput/FilterInputMenu/FilterInputValueMenu/NestedValueMenu.js +11 -3
- package/dist/components/FilterInput/FilterInputMenu/FilterInputValueMenu/useValueMenuState.js +21 -3
- package/dist/components/FilterInput/hooks/useFilterInputAutocomplete/lib/deriveAutocompleteValues.d.ts +1 -1
- package/dist/components/FilterInput/hooks/useFilterInputAutocomplete/lib/deriveAutocompleteValues.js +2 -0
- package/dist/components/FilterInput/hooks/useFilterInputAutocomplete/useChipEditing.d.ts +1 -0
- package/dist/components/FilterInput/hooks/useFilterInputAutocomplete/useChipEditing.js +2 -0
- package/dist/components/FilterInput/hooks/useFilterInputAutocomplete/useFilterInputAutocomplete.js +2 -2
- package/dist/metadata/components.json +2 -2
- package/package.json +1 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Fragment as external_react_Fragment, useMemo, useRef } from "react";
|
|
2
|
+
import { Fragment as external_react_Fragment, useCallback, useMemo, useRef } from "react";
|
|
3
3
|
import { cn } from "../../../../utils/cn.js";
|
|
4
4
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuFooter, DropdownMenuGroup, DropdownMenuLabel, DropdownMenuSeparator } from "../../../DropdownMenu/index.js";
|
|
5
|
+
import { useFloatingRecomputeOn } from "../../hooks/useFloatingRecomputeOn.js";
|
|
5
6
|
import { buildValueMenuSections } from "../../lib/buildValueMenuSections.js";
|
|
6
7
|
import { MenuEmptyState } from "../MenuEmptyState.js";
|
|
7
8
|
import { NestedValueMenuItem } from "./NestedValueMenuItem.js";
|
|
@@ -41,13 +42,20 @@ const NestedValueMenu = ({ values, onSelect, onCommit, open = false, onOpenChang
|
|
|
41
42
|
if (el) rowElsRef.current.set(id, el);
|
|
42
43
|
else rowElsRef.current.delete(id);
|
|
43
44
|
};
|
|
45
|
+
const openParentIdRef = useRef(state.openParentId);
|
|
46
|
+
openParentIdRef.current = state.openParentId;
|
|
47
|
+
const getSubmenuAnchorRect = useCallback(()=>{
|
|
48
|
+
const id = openParentIdRef.current;
|
|
49
|
+
return id && rowElsRef.current.get(id)?.getBoundingClientRect() || null;
|
|
50
|
+
}, []);
|
|
44
51
|
const submenuPositioning = useMemo(()=>({
|
|
45
52
|
placement: 'right-start',
|
|
46
53
|
gutter: 4,
|
|
47
|
-
getAnchorRect:
|
|
54
|
+
getAnchorRect: getSubmenuAnchorRect
|
|
48
55
|
}), [
|
|
49
|
-
|
|
56
|
+
getSubmenuAnchorRect
|
|
50
57
|
]);
|
|
58
|
+
useFloatingRecomputeOn(state.openParentId, null != state.openParentId);
|
|
51
59
|
const openParentRow = state.openParentRow;
|
|
52
60
|
const submenuSelectAllRow = openParentRow && multiSelect ? {
|
|
53
61
|
id: SELECT_ALL_ID,
|
package/dist/components/FilterInput/FilterInputMenu/FilterInputValueMenu/useValueMenuState.js
CHANGED
|
@@ -49,12 +49,30 @@ const useValueMenuState = ({ values, open, multiSelect, initialValues, highlight
|
|
|
49
49
|
blurCommitRef,
|
|
50
50
|
commitChecked
|
|
51
51
|
]);
|
|
52
|
-
const flatItems = useMemo(()=>
|
|
52
|
+
const flatItems = useMemo(()=>{
|
|
53
|
+
const items = values.map((opt)=>({
|
|
53
54
|
id: String(opt.value),
|
|
54
55
|
label: opt.label,
|
|
55
56
|
value: opt.value
|
|
56
|
-
}))
|
|
57
|
-
|
|
57
|
+
}));
|
|
58
|
+
const known = new Set(items.map((item)=>item.id));
|
|
59
|
+
const selected = multiSelect ? checkedValues : null != highlightValue ? [
|
|
60
|
+
highlightValue
|
|
61
|
+
] : [];
|
|
62
|
+
const orphans = selected.filter((value)=>!known.has(String(value))).map((value)=>({
|
|
63
|
+
id: String(value),
|
|
64
|
+
label: String(value),
|
|
65
|
+
value
|
|
66
|
+
}));
|
|
67
|
+
return orphans.length > 0 ? [
|
|
68
|
+
...orphans,
|
|
69
|
+
...items
|
|
70
|
+
] : items;
|
|
71
|
+
}, [
|
|
72
|
+
values,
|
|
73
|
+
multiSelect,
|
|
74
|
+
checkedValues,
|
|
75
|
+
highlightValue
|
|
58
76
|
]);
|
|
59
77
|
const handleItemSelect = (item)=>{
|
|
60
78
|
if (multiSelect) {
|
|
@@ -8,7 +8,7 @@ interface DeriveOptions {
|
|
|
8
8
|
conditions: Condition[];
|
|
9
9
|
buildingMultiValue: string | undefined;
|
|
10
10
|
dateRangeFromValue: string | null | undefined;
|
|
11
|
-
/** Segment text when inline-editing a value. */
|
|
11
|
+
/** Segment text when inline-editing a value — set only once the user typed. */
|
|
12
12
|
segmentFilterText?: string;
|
|
13
13
|
/** Which triplet is being built: 0 = base, 1 = paired second. */
|
|
14
14
|
buildingSide?: 0 | 1;
|
package/dist/components/FilterInput/hooks/useFilterInputAutocomplete/lib/deriveAutocompleteValues.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { NO_VALUE_PLACEHOLDER, chipIdToConditionIndex, collectLeaves, getDateDisplayLabel, getFieldValues, getOperatorLabel, hasStaticAllowlist, isMultiSelectOperator, isNoValueOperator } from "../../../lib/index.js";
|
|
2
|
+
import { resolveMultiValues } from "./valueResolution.js";
|
|
2
3
|
const displayBaseValue = (value, field)=>{
|
|
3
4
|
const options = collectLeaves(getFieldValues(field));
|
|
4
5
|
const resolve = (v)=>options.find((opt)=>String(opt.value) === String(v))?.label ?? String(v ?? '');
|
|
@@ -19,6 +20,7 @@ const deriveAutocompleteValues = ({ editingChipId, selectedField, selectedOperat
|
|
|
19
20
|
} : rawEditingCondition;
|
|
20
21
|
const editingMultiValues = (()=>{
|
|
21
22
|
if (!editingCondition || !selectedOperator || !isMultiSelectOperator(selectedOperator)) return [];
|
|
23
|
+
if (void 0 !== segmentFilterText && selectedField) return resolveMultiValues(selectedField, segmentFilterText.trim()).resolved;
|
|
22
24
|
const values = Array.isArray(editingCondition.value) ? editingCondition.value : null != editingCondition.value ? [
|
|
23
25
|
editingCondition.value
|
|
24
26
|
] : [];
|
|
@@ -19,6 +19,7 @@ export declare const useChipEditing: ({ conditions, chips, fields, setMenuAnchor
|
|
|
19
19
|
editingSegment: import("../../FilterInputField/FilterInputChip").SegmentVariant | null;
|
|
20
20
|
editingSide: 0 | 1;
|
|
21
21
|
isBuildingEdit: boolean;
|
|
22
|
+
userHasTyped: boolean;
|
|
22
23
|
setEditingSegment: import("react").Dispatch<import("react").SetStateAction<import("../../FilterInputField/FilterInputChip").SegmentVariant | null>>;
|
|
23
24
|
segmentFilterText: string;
|
|
24
25
|
segmentMenuFilterText: string;
|
|
@@ -117,6 +117,7 @@ const useChipEditing = ({ conditions, chips, fields, setMenuAnchor, setSelectedF
|
|
|
117
117
|
editingSegment,
|
|
118
118
|
editingSide,
|
|
119
119
|
isBuildingEdit,
|
|
120
|
+
userHasTyped,
|
|
120
121
|
setEditingSegment,
|
|
121
122
|
segmentFilterText: segmentDisplayText,
|
|
122
123
|
segmentMenuFilterText,
|
|
@@ -132,6 +133,7 @@ const useChipEditing = ({ conditions, chips, fields, setMenuAnchor, setSelectedF
|
|
|
132
133
|
editingSegment,
|
|
133
134
|
editingSide,
|
|
134
135
|
isBuildingEdit,
|
|
136
|
+
userHasTyped,
|
|
135
137
|
segmentDisplayText,
|
|
136
138
|
segmentMenuFilterText,
|
|
137
139
|
handleSegmentFilterChange,
|
package/dist/components/FilterInput/hooks/useFilterInputAutocomplete/useFilterInputAutocomplete.js
CHANGED
|
@@ -214,13 +214,13 @@ const useFilterInputAutocomplete = ({ fields, conditions, chips, upsertCondition
|
|
|
214
214
|
conditions,
|
|
215
215
|
buildingMultiValue,
|
|
216
216
|
dateRangeFromValue: dateRange.fromValue,
|
|
217
|
-
segmentFilterText: editing.editingSegment === SEGMENT_VARIANT.value ? editing.
|
|
217
|
+
segmentFilterText: editing.editingSegment === SEGMENT_VARIANT.value && editing.userHasTyped ? editing.segmentFilterText : void 0,
|
|
218
218
|
buildingSide,
|
|
219
219
|
buildingBase,
|
|
220
220
|
editingSide: editing.editingSide
|
|
221
221
|
});
|
|
222
222
|
const isMultiValueValueEdit = null != editing.editingChipId && editing.editingSegment === SEGMENT_VARIANT.value && null != selectedOperator && isMultiSelectOperator(selectedOperator);
|
|
223
|
-
const liveSegmentFilterText = isMultiValueValueEdit && null != buildingMultiValue &&
|
|
223
|
+
const liveSegmentFilterText = isMultiValueValueEdit && null != buildingMultiValue && !editing.userHasTyped ? buildingMultiValue : editing.segmentFilterText;
|
|
224
224
|
return {
|
|
225
225
|
inputText,
|
|
226
226
|
menuState,
|