@wallarm-org/design-system 0.68.0 → 0.68.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/FilterInputMenu.js +4 -2
- package/dist/components/FilterInput/hooks/useFilterInputExpression/buildChips.js +2 -1
- package/dist/components/FilterInput/lib/index.d.ts +1 -1
- package/dist/components/FilterInput/lib/index.js +2 -2
- package/dist/components/FilterInput/lib/validation.d.ts +15 -0
- package/dist/components/FilterInput/lib/validation.js +10 -1
- package/dist/metadata/components.json +2 -2
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo } from "react";
|
|
3
3
|
import { SEGMENT_VARIANT } from "../FilterInputField/FilterInputChip/index.js";
|
|
4
|
-
import { findValueLabelInFields, getCurrentValueTokenText, getFieldValues, getValueFilterText, isBetweenOperator, isMultiSelectOperator } from "../lib/index.js";
|
|
4
|
+
import { canBorrowCrossFieldLabel, findValueLabelInFields, getCurrentValueTokenText, getFieldValues, getValueFilterText, isBetweenOperator, isMultiSelectOperator } from "../lib/index.js";
|
|
5
5
|
import { FilterInputDateValueMenu } from "./FilterInputDateValueMenu/index.js";
|
|
6
6
|
import { FilterInputFieldMenu } from "./FilterInputFieldMenu/index.js";
|
|
7
7
|
import { FilterInputOperatorMenu } from "./FilterInputOperatorMenu.js";
|
|
@@ -42,6 +42,7 @@ const FilterInputMenu = ({ fields, autocomplete })=>{
|
|
|
42
42
|
const key = String(v);
|
|
43
43
|
const i = indexByKey.get(key);
|
|
44
44
|
if (null != i && result[i].label !== key) continue;
|
|
45
|
+
if (!canBorrowCrossFieldLabel(selectedField, v)) continue;
|
|
45
46
|
const label = findValueLabelInFields(v, fields);
|
|
46
47
|
if (void 0 !== label) if (null != i) result[i] = {
|
|
47
48
|
...result[i],
|
|
@@ -61,7 +62,8 @@ const FilterInputMenu = ({ fields, autocomplete })=>{
|
|
|
61
62
|
selectedFieldValues,
|
|
62
63
|
editingMultiValues,
|
|
63
64
|
editingSingleValue,
|
|
64
|
-
fields
|
|
65
|
+
fields,
|
|
66
|
+
selectedField
|
|
65
67
|
]);
|
|
66
68
|
const valueFilterText = getValueFilterText(currentTokenText, selectedOperator, menuValues);
|
|
67
69
|
const showOperatorMenu = !!selectedField;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SEGMENT_VARIANT } from "../../FilterInputField/FilterInputChip/index.js";
|
|
2
|
-
import { NO_VALUE_PLACEHOLDER, findOptionByValue, findValueLabelInFields, getDateDisplayLabel, getInvalidValueIndices, getOperatorLabel, isNoValueOperator } from "../../lib/index.js";
|
|
2
|
+
import { NO_VALUE_PLACEHOLDER, canBorrowCrossFieldLabel, findOptionByValue, findValueLabelInFields, getDateDisplayLabel, getInvalidValueIndices, getOperatorLabel, isNoValueOperator } from "../../lib/index.js";
|
|
3
3
|
const INVALID_DATE = 'Invalid Date';
|
|
4
4
|
const DATE_RANGE_SEPARATOR = ' – ';
|
|
5
5
|
const MULTI_VALUE_SEPARATOR = ', ';
|
|
@@ -25,6 +25,7 @@ const makeEmptyChip = (i, error)=>({
|
|
|
25
25
|
const resolveValueLabel = (value, field, fields)=>{
|
|
26
26
|
const own = findOptionByValue(field, value)?.label;
|
|
27
27
|
if (void 0 !== own) return own;
|
|
28
|
+
if (!canBorrowCrossFieldLabel(field, value)) return;
|
|
28
29
|
return findValueLabelInFields(value, fields);
|
|
29
30
|
};
|
|
30
31
|
const resolveDisplayValue = (condition, field, fields)=>{
|
|
@@ -15,4 +15,4 @@ export { type FilterParseError, isFilterParseError, parseExpression } from './pa
|
|
|
15
15
|
export { SEGMENT_TO_MENU } from './segmentMenu';
|
|
16
16
|
export { serializeExpression } from './serializeExpression';
|
|
17
17
|
export { createStatusCodeInputFilter, createStatusCodeNormalizer, createStatusCodeSerializer, createStatusCodeSuggestions, createStatusCodeValidator, } from './statusCode';
|
|
18
|
-
export { findMatchingFieldValue, getInvalidValueIndices, isValidFieldValue, validateValueForField, } from './validation';
|
|
18
|
+
export { canBorrowCrossFieldLabel, findMatchingFieldValue, getInvalidValueIndices, isValidFieldValue, validateValueForField, } from './validation';
|
|
@@ -14,5 +14,5 @@ import { isFilterParseError, parseExpression } from "./parseExpression/index.js"
|
|
|
14
14
|
import { SEGMENT_TO_MENU } from "./segmentMenu.js";
|
|
15
15
|
import { serializeExpression } from "./serializeExpression.js";
|
|
16
16
|
import { createStatusCodeInputFilter, createStatusCodeNormalizer, createStatusCodeSerializer, createStatusCodeSuggestions, createStatusCodeValidator } from "./statusCode/index.js";
|
|
17
|
-
import { findMatchingFieldValue, getInvalidValueIndices, isValidFieldValue, validateValueForField } from "./validation.js";
|
|
18
|
-
export { CONNECTOR_ID_PATTERN, COUNTRY_OPTIONS, DATE_PRESETS, MENU_BASE_GUTTER, MENU_CHIP_GUTTER_OFFSET, NO_VALUE_OPERATORS, NO_VALUE_PLACEHOLDER, OPERATORS_BY_TYPE, OPERATOR_LABELS, OPERATOR_LABELS_BY_TYPE, OPERATOR_SYMBOLS, QUERY_BAR_SELECTOR, SEGMENT_TO_MENU, VARIANT_LABELS, applyAcceptChar, applyFieldValueTransforms, applyKnownFieldHelpers, buildAnchoredRect, chipIdToConditionIndex, createStatusCodeInputFilter, createStatusCodeNormalizer, createStatusCodeSerializer, createStatusCodeSuggestions, createStatusCodeValidator, filterAndSort, findChipSplitIndex, findMatchingFieldValue, findOptionByValue, findValueLabelInFields, formatDateForChip, getCurrentValueTokenText, getDateDisplayLabel, getFieldOperators, getFieldValues, getInvalidValueIndices, getKnownFieldSerializer, getOperatorFromLabel, getOperatorLabel, getValueFilterText, hasFieldValues, hasStaticAllowlist, isBetweenOperator, isBuildingComplete, isDatePreset, isFilterParseError, isMenuRelated, isMultiSelectOperator, isNoValueOperator, isOperatorAllowedForField, isValidFieldValue, isValueShapeCompatible, nextBuildingMenu, parseExpression, serializeExpression, toAnchorBounds, validateValueForField };
|
|
17
|
+
import { canBorrowCrossFieldLabel, findMatchingFieldValue, getInvalidValueIndices, isValidFieldValue, validateValueForField } from "./validation.js";
|
|
18
|
+
export { CONNECTOR_ID_PATTERN, COUNTRY_OPTIONS, DATE_PRESETS, MENU_BASE_GUTTER, MENU_CHIP_GUTTER_OFFSET, NO_VALUE_OPERATORS, NO_VALUE_PLACEHOLDER, OPERATORS_BY_TYPE, OPERATOR_LABELS, OPERATOR_LABELS_BY_TYPE, OPERATOR_SYMBOLS, QUERY_BAR_SELECTOR, SEGMENT_TO_MENU, VARIANT_LABELS, applyAcceptChar, applyFieldValueTransforms, applyKnownFieldHelpers, buildAnchoredRect, canBorrowCrossFieldLabel, chipIdToConditionIndex, createStatusCodeInputFilter, createStatusCodeNormalizer, createStatusCodeSerializer, createStatusCodeSuggestions, createStatusCodeValidator, filterAndSort, findChipSplitIndex, findMatchingFieldValue, findOptionByValue, findValueLabelInFields, formatDateForChip, getCurrentValueTokenText, getDateDisplayLabel, getFieldOperators, getFieldValues, getInvalidValueIndices, getKnownFieldSerializer, getOperatorFromLabel, getOperatorLabel, getValueFilterText, hasFieldValues, hasStaticAllowlist, isBetweenOperator, isBuildingComplete, isDatePreset, isFilterParseError, isMenuRelated, isMultiSelectOperator, isNoValueOperator, isOperatorAllowedForField, isValidFieldValue, isValueShapeCompatible, nextBuildingMenu, parseExpression, serializeExpression, toAnchorBounds, validateValueForField };
|
|
@@ -9,6 +9,21 @@ import type { Condition, FieldMetadata, FieldType, FieldValueOption } from '../t
|
|
|
9
9
|
* (`7d`, `1h`, …) or any value `Date` can parse (ISO etc.).
|
|
10
10
|
*/
|
|
11
11
|
export declare const isValueOfType: (value: string | number | boolean, type: FieldType) => boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Whether a chip/menu may borrow a value's human label from *another* field's
|
|
14
|
+
* options. Only consulted when the current field doesn't define the value
|
|
15
|
+
* itself.
|
|
16
|
+
*
|
|
17
|
+
* String/enum fields always may: a value carried over after a field change keeps
|
|
18
|
+
* the label it had on its origin field (accepted trade-off, AS-1134). Typed
|
|
19
|
+
* fields (integer/float/date/boolean) may borrow only for a value that is NOT a
|
|
20
|
+
* valid value of their own type — such a value must have been carried from a
|
|
21
|
+
* differently-typed field. A type-conforming value (e.g. `1` typed into the
|
|
22
|
+
* integer `total_requests` field) is a genuine user entry and must never be
|
|
23
|
+
* relabelled from an unrelated field that happens to define the same value
|
|
24
|
+
* (AS-1171).
|
|
25
|
+
*/
|
|
26
|
+
export declare const canBorrowCrossFieldLabel: (field: FieldMetadata | null | undefined, value: string | number | boolean | null | undefined) => boolean;
|
|
12
27
|
/** Find a field value option matching by label or value (case-insensitive) */
|
|
13
28
|
export declare const findMatchingFieldValue: (fieldValues: FieldValueOption[], text: string) => FieldValueOption | undefined;
|
|
14
29
|
/** Check if a single value matches any option in the field's values list */
|
|
@@ -30,6 +30,15 @@ const isValueOfType = (value, type)=>{
|
|
|
30
30
|
return true;
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
|
+
const UNTYPED_FIELD_TYPES = new Set([
|
|
34
|
+
'string',
|
|
35
|
+
'enum'
|
|
36
|
+
]);
|
|
37
|
+
const canBorrowCrossFieldLabel = (field, value)=>{
|
|
38
|
+
if (null == value) return false;
|
|
39
|
+
if (!field || UNTYPED_FIELD_TYPES.has(field.type)) return true;
|
|
40
|
+
return !isValueOfType(value, field.type);
|
|
41
|
+
};
|
|
33
42
|
const findMatchingFieldValue = (fieldValues, text)=>fieldValues.find((v)=>v.label.toLowerCase() === text.toLowerCase() || String(v.value).toLowerCase() === text.toLowerCase());
|
|
34
43
|
const isValidFieldValue = (fieldValues, v)=>fieldValues.some((opt)=>opt.value === v || String(opt.value).toLowerCase() === String(v).toLowerCase());
|
|
35
44
|
const getInvalidValueIndices = (field, values)=>{
|
|
@@ -56,4 +65,4 @@ const validateValueForField = (field, value)=>{
|
|
|
56
65
|
];
|
|
57
66
|
return getInvalidValueIndices(field, values).length > 0;
|
|
58
67
|
};
|
|
59
|
-
export { findMatchingFieldValue, getInvalidValueIndices, isValidFieldValue, isValueOfType, validateValueForField };
|
|
68
|
+
export { canBorrowCrossFieldLabel, findMatchingFieldValue, getInvalidValueIndices, isValidFieldValue, isValueOfType, validateValueForField };
|