@cloudscape-design/components 3.0.130 → 3.0.132
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/internal/environment.js +1 -1
- package/internal/manifest.json +1 -1
- package/package.json +1 -1
- package/property-filter/controller.d.ts.map +1 -1
- package/property-filter/controller.js +10 -13
- package/property-filter/controller.js.map +1 -1
- package/property-filter/filter-options.js +6 -2
- package/property-filter/filter-options.js.map +1 -1
- package/property-filter/index.d.ts.map +1 -1
- package/property-filter/index.js +3 -2
- package/property-filter/index.js.map +1 -1
- package/property-filter/interfaces.d.ts +15 -0
- package/property-filter/interfaces.d.ts.map +1 -1
- package/property-filter/interfaces.js.map +1 -1
- package/property-filter/token-editor.d.ts.map +1 -1
- package/property-filter/token-editor.js +11 -7
- package/property-filter/token-editor.js.map +1 -1
- package/property-filter/utils.d.ts +2 -1
- package/property-filter/utils.d.ts.map +1 -1
- package/property-filter/utils.js +14 -0
- package/property-filter/utils.js.map +1 -1
- package/table/use-sticky-header.d.ts.map +1 -1
- package/table/use-sticky-header.js +1 -4
- package/table/use-sticky-header.js.map +1 -1
package/internal/environment.js
CHANGED
package/internal/manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/property-filter/controller.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,kBAAkB,EAElB,eAAe,EACf,iBAAiB,EACjB,SAAS,EACT,WAAW,EACX,aAAa,EACb,UAAU,EACV,KAAK,EACL,KAAK,EACN,MAAM,cAAc,CAAC;AACtB,OAAO,EAA0B,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAGvF,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAE/E,eAAO,MAAM,eAAe,UACnB,KAAK,YACF,0BAA0B,KAAK,CAAC,YAChC,MAAM,SAAS,CAAC,mBAAmB,CAAC;sBAKrB,MAAM,YAAY,KAAK;yBAOpB,MAAM;;yBASN,KAAK;iCAKG,aAAa;CAUlD,CAAC;AAEF,eAAO,MAAM,mBAAmB,aAAc,iBAAiB,KAAG,kBAAkB,EAQnF,CAAC;AAQF,eAAO,MAAM,SAAS,kBACL,MAAM,sIAEK,OAAO,KAChC,
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/property-filter/controller.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,kBAAkB,EAElB,eAAe,EACf,iBAAiB,EACjB,SAAS,EACT,WAAW,EACX,aAAa,EACb,UAAU,EACV,KAAK,EACL,KAAK,EACN,MAAM,cAAc,CAAC;AACtB,OAAO,EAA0B,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAGvF,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAE/E,eAAO,MAAM,eAAe,UACnB,KAAK,YACF,0BAA0B,KAAK,CAAC,YAChC,MAAM,SAAS,CAAC,mBAAmB,CAAC;sBAKrB,MAAM,YAAY,KAAK;yBAOpB,MAAM;;yBASN,KAAK;iCAKG,aAAa;CAUlD,CAAC;AAEF,eAAO,MAAM,mBAAmB,aAAc,iBAAiB,KAAG,kBAAkB,EAQnF,CAAC;AAQF,eAAO,MAAM,SAAS,kBACL,MAAM,sIAEK,OAAO,KAChC,UAyCF,CAAC;AAEF,eAAO,MAAM,kBAAkB,sBACV,iBAAiB,oBAClB,SAAS,eAAe,EAAE,yEAG7C,CAAC;AAEF,UAAU,WAAW,CAAC,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,CAAC,EAAE,CAAC;CACd;AAED,eAAO,MAAM,sBAAsB,qBACf,SAAS,eAAe,EAAE,uBACvB,SAAS,iBAAiB,EAAE,YACvC,kBAAkB,GAAG,SAAS,eAC3B,WAAW,oBACN,SAAS,SAAS,EAAE,uFAmCvC,CAAC;AAEF,eAAO,MAAM,gBAAgB,wBAAyB,SAAS,iBAAiB,EAAE,OAAO,MAAM,6EAM9F,CAAC;AAEF,wBAAgB,mBAAmB,CACjC,mBAAmB,EAAE,SAAS,iBAAiB,EAAE,EACjD,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,kBAAkB,4FAS7B;AAED,wBAAgB,gCAAgC,CAC9C,mBAAmB,EAAE,SAAS,iBAAiB,EAAE,GAChD,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CA6BnD;AAQD,wBAAgB,sBAAsB,CAAC,CAAC,EACtC,mBAAmB,EAAE,SAAS,iBAAiB,EAAE,EACjD,gBAAgB,EAAE,SAAS,SAAS,EAAE,EACtC,WAAW,EAAE,WAAW,EACxB,yBAAyB,EAAE,CAAC,iBAAiB,EAAE,iBAAiB,KAAK,CAAC,oBA0BvE;AAED,eAAO,MAAM,qBAAqB,eACpB,UAAU,oBACJ,SAAS,eAAe,EAAE,uBACvB,SAAS,iBAAiB,EAAE,oBAC/B,SAAS,SAAS,EAAE,eACzB,WAAW;;;;;;;;;;;;;;;;;CAqEzB,CAAC;AAEF,eAAO,MAAM,qBAAqB,aAAc,kBAAkB,eAAe,WAAW,WAY3F,CAAC"}
|
|
@@ -79,16 +79,12 @@ export var parseText = function (filteringText, filteringProperties, disableFree
|
|
|
79
79
|
if (operator) {
|
|
80
80
|
var operatorLastIndex = textWithoutProperty.indexOf(operator) + operator.length;
|
|
81
81
|
var textWithoutPropertyAndOperator = textWithoutProperty.slice(operatorLastIndex);
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
// and we need to remove the first space, if the user added any more spaces only the
|
|
89
|
-
// first one will be removed.
|
|
90
|
-
value: trimFirstSpace(textWithoutPropertyAndOperator)
|
|
91
|
-
};
|
|
82
|
+
// We need to remove the first leading space in case the user presses space
|
|
83
|
+
// after the operator, for example: Owner: admin, will result in value of ` admin`
|
|
84
|
+
// and we need to remove the first space, if the user added any more spaces only the
|
|
85
|
+
// first one will be removed.
|
|
86
|
+
var value = trimFirstSpace(textWithoutPropertyAndOperator);
|
|
87
|
+
return { step: 'property', property: property, operator: operator, value: value };
|
|
92
88
|
}
|
|
93
89
|
var operatorPrefix = matchOperatorPrefix(allowedOps, trimStart(textWithoutProperty));
|
|
94
90
|
if (operatorPrefix !== null) {
|
|
@@ -110,6 +106,7 @@ export var getAllValueSuggestions = function (filteringOptions, filteringPropert
|
|
|
110
106
|
};
|
|
111
107
|
var customGroups = {};
|
|
112
108
|
filteringOptions.forEach(function (filteringOption) {
|
|
109
|
+
var _a;
|
|
113
110
|
var property = getPropertyByKey(filteringProperties, filteringOption.propertyKey);
|
|
114
111
|
// given option refers to a non-existent filtering property
|
|
115
112
|
if (!property) {
|
|
@@ -129,7 +126,7 @@ export var getAllValueSuggestions = function (filteringOptions, filteringPropert
|
|
|
129
126
|
var propertyGroup = property.group ? customGroups[property.group] : defaultGroup;
|
|
130
127
|
propertyGroup.options.push({
|
|
131
128
|
value: property.propertyLabel + ' ' + (operator || '=') + ' ' + filteringOption.value,
|
|
132
|
-
label: filteringOption.value,
|
|
129
|
+
label: (_a = filteringOption.label) !== null && _a !== void 0 ? _a : filteringOption.value,
|
|
133
130
|
__labelPrefix: property.propertyLabel + ' ' + (operator || '=')
|
|
134
131
|
});
|
|
135
132
|
});
|
|
@@ -216,10 +213,10 @@ export var getAutosuggestOptions = function (parsedText, filteringOptions, filte
|
|
|
216
213
|
options: [
|
|
217
214
|
{
|
|
218
215
|
options: options.map(function (_a) {
|
|
219
|
-
var value = _a.value;
|
|
216
|
+
var label = _a.label, value = _a.value;
|
|
220
217
|
return ({
|
|
221
218
|
value: propertyLabel_1 + ' ' + parsedText.operator + ' ' + value,
|
|
222
|
-
label: value,
|
|
219
|
+
label: label !== null && label !== void 0 ? label : value,
|
|
223
220
|
__labelPrefix: propertyLabel_1 + ' ' + parsedText.operator
|
|
224
221
|
});
|
|
225
222
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-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AAO,kCACF,CAAC,wBAAwB;oBAC1B,CAAC,CAAC,sBAAsB,CACpB,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,oCAAoC,CACrC;oBACH,CAAC,CAAC,EAAE,CAAC,SACJ,CAAC,qBAAqB;oBACvB,CAAC,CAAC,sBAAsB,CACpB,gBAAgB,EAChB,mBAAmB,EACnB,UAAU,CAAC,QAAQ,EACnB,WAAW,EACX,gBAAgB,CACjB;oBACH,CAAC,CAAC,EAAE,CAAC,OACR;aACF,CAAC;SACH;KACF;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,qBAAqB,GAAG,UAAC,QAA4B,EAAE,WAAwB;;IAC1F,IAAM,OAAO;QACX,GAAC,GAAG,IAAG,WAAW,CAAC,gBAAgB;QACnC,GAAC,IAAI,IAAG,WAAW,CAAC,uBAAuB;QAC3C,GAAC,GAAG,IAAG,WAAW,CAAC,mBAAmB;QACtC,GAAC,IAAI,IAAG,WAAW,CAAC,0BAA0B;QAC9C,GAAC,GAAG,IAAG,WAAW,CAAC,oBAAoB;QACvC,GAAC,IAAI,IAAG,WAAW,CAAC,0BAA0B;QAC9C,GAAC,GAAG,IAAG,WAAW,CAAC,kBAAkB;QACrC,GAAC,IAAI,IAAG,WAAW,CAAC,wBAAwB;WAC7C,CAAC;IACF,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC3B,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n ComparisonOperator,\n ExtendedOperatorForm,\n FilteringOption,\n FilteringProperty,\n GroupText,\n I18nStrings,\n JoinOperation,\n ParsedText,\n Query,\n Token,\n} from './interfaces';\nimport { fireNonCancelableEvent, NonCancelableEventHandler } from '../internal/events';\nimport { AutosuggestProps } from '../autosuggest/interfaces';\nimport { matchFilteringProperty, matchOperator, matchOperatorPrefix, trimFirstSpace, trimStart } from './utils';\nimport { AutosuggestInputRef } from '../internal/components/autosuggest-input';\n\nexport const getQueryActions = (\n query: Query,\n onChange: NonCancelableEventHandler<Query>,\n inputRef: React.RefObject<AutosuggestInputRef>\n) => {\n const { tokens, operation } = query;\n const fireOnChange = (tokens: readonly Token[], operation: JoinOperation) =>\n fireNonCancelableEvent(onChange, { tokens, operation });\n const setToken = (index: number, newToken: Token) => {\n const newTokens = [...tokens];\n if (newTokens && index < newTokens.length) {\n newTokens[index] = newToken;\n }\n fireOnChange(newTokens, operation);\n };\n const removeToken = (index: number) => {\n const newTokens = tokens.filter((_, i) => i !== index);\n fireOnChange(newTokens, operation);\n inputRef.current?.focus({ preventDropdown: true });\n };\n const removeAllTokens = () => {\n fireOnChange([], operation);\n inputRef.current?.focus({ preventDropdown: true });\n };\n const addToken = (newToken: Token) => {\n const newTokens = [...tokens];\n newTokens.push(newToken);\n fireOnChange(newTokens, operation);\n };\n const setOperation = (newOperation: JoinOperation) => {\n fireOnChange(tokens, newOperation);\n };\n return {\n setToken,\n removeToken,\n removeAllTokens,\n addToken,\n setOperation,\n };\n};\n\nexport const getAllowedOperators = (property: FilteringProperty): ComparisonOperator[] => {\n const { operators = [], defaultOperator } = property;\n const operatorOrder = ['=', '!=', ':', '!:', '>=', '<=', '<', '>'] as const;\n const operatorSet = new Set([\n defaultOperator ?? '=',\n ...operators.map(op => (typeof op === 'string' ? op : op.operator)),\n ]);\n return operatorOrder.filter(op => operatorSet.has(op));\n};\n\n/*\n * parses the value of the filtering input to figure out the current step of entering the token:\n * - \"property\": means that a filter on a particular column is being added, with operator already finalized\n * - \"operator\": means that a filter on a particular column is being added, with operator not yet finalized\n * - \"free-text\": means that a \"free text\" token is being added\n */\nexport const parseText = (\n filteringText: string,\n filteringProperties: readonly FilteringProperty[] = [],\n disableFreeTextFiltering: boolean\n): ParsedText => {\n const negatedGlobalQuery = /^(!:|!)(.*)/.exec(filteringText);\n if (!disableFreeTextFiltering && negatedGlobalQuery) {\n return {\n step: 'free-text',\n operator: '!:',\n value: negatedGlobalQuery[2],\n };\n }\n\n const property = matchFilteringProperty(filteringProperties, filteringText);\n if (!property) {\n return {\n step: 'free-text',\n value: filteringText,\n };\n }\n\n const allowedOps = getAllowedOperators(property);\n const textWithoutProperty = filteringText.substring(property.propertyLabel.length);\n const operator = matchOperator(allowedOps, trimStart(textWithoutProperty));\n if (operator) {\n const operatorLastIndex = textWithoutProperty.indexOf(operator) + operator.length;\n const textWithoutPropertyAndOperator = textWithoutProperty.slice(operatorLastIndex);\n return {\n step: 'property',\n property,\n operator,\n // We need to remove the first leading space in case the user presses space\n // after the operator, for example: Owner: admin, will result in value of ` admin`\n // and we need to remove the first space, if the user added any more spaces only the\n // first one will be removed.\n value: trimFirstSpace(textWithoutPropertyAndOperator),\n };\n }\n\n const operatorPrefix = matchOperatorPrefix(allowedOps, trimStart(textWithoutProperty));\n if (operatorPrefix !== null) {\n return { step: 'operator', property, operatorPrefix };\n }\n\n return {\n step: 'free-text',\n value: filteringText,\n };\n};\n\nexport const getPropertyOptions = (\n filteringProperty: FilteringProperty,\n filteringOptions: readonly FilteringOption[]\n) => {\n return filteringOptions.filter(option => option.propertyKey === filteringProperty.key);\n};\n\ninterface OptionGroup<T> {\n label: string;\n options: T[];\n}\n\nexport const getAllValueSuggestions = (\n filteringOptions: readonly FilteringOption[],\n filteringProperties: readonly FilteringProperty[],\n operator: ComparisonOperator | undefined = '=',\n i18nStrings: I18nStrings,\n customGroupsText: readonly GroupText[]\n) => {\n const defaultGroup: OptionGroup<AutosuggestProps.Option> = {\n label: i18nStrings.groupValuesText,\n options: [],\n };\n const customGroups: { [K in string]: OptionGroup<AutosuggestProps.Option> } = {};\n filteringOptions.forEach(filteringOption => {\n const property = getPropertyByKey(filteringProperties, filteringOption.propertyKey);\n // given option refers to a non-existent filtering property\n if (!property) {\n return;\n }\n // this option's filtering property does not support current operator\n if (getAllowedOperators(property).indexOf(operator) === -1) {\n return;\n }\n if (property.group && !customGroups[property.group]) {\n const label = customGroupsText.reduce<string>(\n (acc, customGroup) => (customGroup.group === property.group ? customGroup.values : acc),\n ''\n );\n customGroups[property.group] = {\n label,\n options: [],\n };\n }\n const propertyGroup = property.group ? customGroups[property.group] : defaultGroup;\n propertyGroup.options.push({\n value: property.propertyLabel + ' ' + (operator || '=') + ' ' + filteringOption.value,\n label: filteringOption.value,\n __labelPrefix: property.propertyLabel + ' ' + (operator || '='),\n });\n });\n return [defaultGroup, ...Object.keys(customGroups).map(group => customGroups[group])];\n};\n\nexport const getPropertyByKey = (filteringProperties: readonly FilteringProperty[], key: string) => {\n const propertyMap = filteringProperties.reduce<{ [K: string]: FilteringProperty }>((acc, property) => {\n acc[property.key] = property;\n return acc;\n }, {});\n return propertyMap[key] as FilteringProperty | undefined;\n};\n\nexport function getExtendedOperator(\n filteringProperties: readonly FilteringProperty[],\n property: string,\n operator: ComparisonOperator\n) {\n const matchedProperty = getPropertyByKey(filteringProperties, property);\n for (const matchedOperator of matchedProperty?.operators || []) {\n if (typeof matchedOperator === 'object' && matchedOperator.operator === operator) {\n return matchedOperator;\n }\n }\n return null;\n}\n\nexport function createPropertiesCompatibilityMap(\n filteringProperties: readonly FilteringProperty[]\n): (propertyA: string, propertyB: string) => boolean {\n const lookup: {\n [propertyKey: string]: { operator: string; form: ExtendedOperatorForm<any> | undefined }[];\n } = {};\n\n for (const property of filteringProperties) {\n lookup[property.key] = (property.operators || [])\n .map(operator =>\n typeof operator === 'object'\n ? { operator: operator.operator, form: operator.form }\n : { operator, form: undefined }\n )\n .sort((a, b) => a.operator.localeCompare(b.operator));\n }\n\n return (propertyA: string, propertyB: string) => {\n if (lookup[propertyA].length !== lookup[propertyB].length) {\n return false;\n }\n for (let i = 0; i < lookup[propertyA].length; i++) {\n if (lookup[propertyA][i].operator !== lookup[propertyB][i].operator) {\n return false;\n }\n if (lookup[propertyA][i].form !== lookup[propertyB][i].form) {\n return false;\n }\n }\n return true;\n };\n}\n\nconst filteringPropertyToAutosuggestOption = (filteringProperty: FilteringProperty) => ({\n value: filteringProperty.propertyLabel,\n label: filteringProperty.propertyLabel,\n keepOpenOnSelect: true,\n});\n\nexport function getPropertySuggestions<T>(\n filteringProperties: readonly FilteringProperty[],\n customGroupsText: readonly GroupText[],\n i18nStrings: I18nStrings,\n filteringPropertyToOption: (filteringProperty: FilteringProperty) => T\n) {\n const defaultGroup: OptionGroup<T> = {\n label: i18nStrings.groupPropertiesText,\n options: [],\n };\n const customGroups: { [K in string]: OptionGroup<T> } = {};\n\n filteringProperties.forEach(filteringProperty => {\n const { group } = filteringProperty;\n let optionsGroup = defaultGroup;\n if (group) {\n if (!customGroups[group]) {\n const label = customGroupsText.reduce<string>(\n (acc, customGroup) => (customGroup.group === group ? customGroup.properties : acc),\n ''\n );\n customGroups[group] = { options: [], label };\n }\n optionsGroup = customGroups[group];\n }\n optionsGroup.options.push(filteringPropertyToOption(filteringProperty));\n });\n const defaultGroupArray = defaultGroup.options.length ? [defaultGroup] : [];\n const customGroupsArray = Object.keys(customGroups).map(groupKey => customGroups[groupKey]);\n return [...defaultGroupArray, ...customGroupsArray];\n}\n\nexport const getAutosuggestOptions = (\n parsedText: ParsedText,\n filteringOptions: readonly FilteringOption[],\n filteringProperties: readonly FilteringProperty[],\n customGroupsText: readonly GroupText[],\n i18nStrings: I18nStrings\n) => {\n switch (parsedText.step) {\n case 'property': {\n const { propertyLabel, groupValuesLabel } = parsedText.property;\n const options = getPropertyOptions(parsedText.property, filteringOptions);\n return {\n filterText: parsedText.value,\n options: [\n {\n options: options.map(({ value }) => ({\n value: propertyLabel + ' ' + parsedText.operator + ' ' + value,\n label: value,\n __labelPrefix: propertyLabel + ' ' + parsedText.operator,\n })),\n label: groupValuesLabel,\n },\n ],\n };\n }\n case 'operator': {\n return {\n filterText: parsedText.property.propertyLabel + ' ' + parsedText.operatorPrefix,\n options: [\n ...getPropertySuggestions(\n filteringProperties,\n customGroupsText,\n i18nStrings,\n filteringPropertyToAutosuggestOption\n ),\n {\n options: getAllowedOperators(parsedText.property).map(value => ({\n value: parsedText.property.propertyLabel + ' ' + value + ' ',\n label: parsedText.property.propertyLabel + ' ' + value,\n description: operatorToDescription(value, i18nStrings),\n keepOpenOnSelect: true,\n })),\n label: i18nStrings.operatorsText,\n },\n ],\n };\n }\n case 'free-text': {\n const needsValueSuggestions = !!parsedText.value;\n const needsPropertySuggestions = !(parsedText.step === 'free-text' && parsedText.operator === '!:');\n return {\n filterText: parsedText.value,\n options: [\n ...(needsPropertySuggestions\n ? getPropertySuggestions(\n filteringProperties,\n customGroupsText,\n i18nStrings,\n filteringPropertyToAutosuggestOption\n )\n : []),\n ...(needsValueSuggestions\n ? getAllValueSuggestions(\n filteringOptions,\n filteringProperties,\n parsedText.operator,\n i18nStrings,\n customGroupsText\n )\n : []),\n ],\n };\n }\n }\n};\n\nexport const operatorToDescription = (operator: ComparisonOperator, i18nStrings: I18nStrings) => {\n const mapping: { [K in ComparisonOperator]: string } = {\n ['<']: i18nStrings.operatorLessText,\n ['<=']: i18nStrings.operatorLessOrEqualText,\n ['>']: i18nStrings.operatorGreaterText,\n ['>=']: i18nStrings.operatorGreaterOrEqualText,\n [':']: i18nStrings.operatorContainsText,\n ['!:']: i18nStrings.operatorDoesNotContainText,\n ['=']: i18nStrings.operatorEqualsText,\n ['!=']: i18nStrings.operatorDoesNotEqualText,\n };\n return mapping[operator];\n};\n"]}
|
|
1
|
+
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../src/property-filter/controller.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AActC,OAAO,EAAE,sBAAsB,EAA6B,MAAM,oBAAoB,CAAC;AAEvF,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,mBAAmB,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGhH,MAAM,CAAC,IAAM,eAAe,GAAG,UAC7B,KAAY,EACZ,QAA0C,EAC1C,QAA8C;IAEtC,IAAA,MAAM,GAAgB,KAAK,OAArB,EAAE,SAAS,GAAK,KAAK,UAAV,CAA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ACH,CAAC,CAAC,EAAE,CAAC,OACR;aACF,CAAC;SACH;KACF;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,qBAAqB,GAAG,UAAC,QAA4B,EAAE,WAAwB;;IAC1F,IAAM,OAAO;QACX,GAAC,GAAG,IAAG,WAAW,CAAC,gBAAgB;QACnC,GAAC,IAAI,IAAG,WAAW,CAAC,uBAAuB;QAC3C,GAAC,GAAG,IAAG,WAAW,CAAC,mBAAmB;QACtC,GAAC,IAAI,IAAG,WAAW,CAAC,0BAA0B;QAC9C,GAAC,GAAG,IAAG,WAAW,CAAC,oBAAoB;QACvC,GAAC,IAAI,IAAG,WAAW,CAAC,0BAA0B;QAC9C,GAAC,GAAG,IAAG,WAAW,CAAC,kBAAkB;QACrC,GAAC,IAAI,IAAG,WAAW,CAAC,wBAAwB;WAC7C,CAAC;IACF,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC3B,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n ComparisonOperator,\n ExtendedOperatorForm,\n FilteringOption,\n FilteringProperty,\n GroupText,\n I18nStrings,\n JoinOperation,\n ParsedText,\n Query,\n Token,\n} from './interfaces';\nimport { fireNonCancelableEvent, NonCancelableEventHandler } from '../internal/events';\nimport { AutosuggestProps } from '../autosuggest/interfaces';\nimport { matchFilteringProperty, matchOperator, matchOperatorPrefix, trimFirstSpace, trimStart } from './utils';\nimport { AutosuggestInputRef } from '../internal/components/autosuggest-input';\n\nexport const getQueryActions = (\n query: Query,\n onChange: NonCancelableEventHandler<Query>,\n inputRef: React.RefObject<AutosuggestInputRef>\n) => {\n const { tokens, operation } = query;\n const fireOnChange = (tokens: readonly Token[], operation: JoinOperation) =>\n fireNonCancelableEvent(onChange, { tokens, operation });\n const setToken = (index: number, newToken: Token) => {\n const newTokens = [...tokens];\n if (newTokens && index < newTokens.length) {\n newTokens[index] = newToken;\n }\n fireOnChange(newTokens, operation);\n };\n const removeToken = (index: number) => {\n const newTokens = tokens.filter((_, i) => i !== index);\n fireOnChange(newTokens, operation);\n inputRef.current?.focus({ preventDropdown: true });\n };\n const removeAllTokens = () => {\n fireOnChange([], operation);\n inputRef.current?.focus({ preventDropdown: true });\n };\n const addToken = (newToken: Token) => {\n const newTokens = [...tokens];\n newTokens.push(newToken);\n fireOnChange(newTokens, operation);\n };\n const setOperation = (newOperation: JoinOperation) => {\n fireOnChange(tokens, newOperation);\n };\n return {\n setToken,\n removeToken,\n removeAllTokens,\n addToken,\n setOperation,\n };\n};\n\nexport const getAllowedOperators = (property: FilteringProperty): ComparisonOperator[] => {\n const { operators = [], defaultOperator } = property;\n const operatorOrder = ['=', '!=', ':', '!:', '>=', '<=', '<', '>'] as const;\n const operatorSet = new Set([\n defaultOperator ?? '=',\n ...operators.map(op => (typeof op === 'string' ? op : op.operator)),\n ]);\n return operatorOrder.filter(op => operatorSet.has(op));\n};\n\n/*\n * parses the value of the filtering input to figure out the current step of entering the token:\n * - \"property\": means that a filter on a particular column is being added, with operator already finalized\n * - \"operator\": means that a filter on a particular column is being added, with operator not yet finalized\n * - \"free-text\": means that a \"free text\" token is being added\n */\nexport const parseText = (\n filteringText: string,\n filteringProperties: readonly FilteringProperty[] = [],\n disableFreeTextFiltering: boolean\n): ParsedText => {\n const negatedGlobalQuery = /^(!:|!)(.*)/.exec(filteringText);\n if (!disableFreeTextFiltering && negatedGlobalQuery) {\n return {\n step: 'free-text',\n operator: '!:',\n value: negatedGlobalQuery[2],\n };\n }\n\n const property = matchFilteringProperty(filteringProperties, filteringText);\n if (!property) {\n return {\n step: 'free-text',\n value: filteringText,\n };\n }\n\n const allowedOps = getAllowedOperators(property);\n const textWithoutProperty = filteringText.substring(property.propertyLabel.length);\n const operator = matchOperator(allowedOps, trimStart(textWithoutProperty));\n if (operator) {\n const operatorLastIndex = textWithoutProperty.indexOf(operator) + operator.length;\n const textWithoutPropertyAndOperator = textWithoutProperty.slice(operatorLastIndex);\n // We need to remove the first leading space in case the user presses space\n // after the operator, for example: Owner: admin, will result in value of ` admin`\n // and we need to remove the first space, if the user added any more spaces only the\n // first one will be removed.\n const value = trimFirstSpace(textWithoutPropertyAndOperator);\n return { step: 'property', property, operator, value };\n }\n\n const operatorPrefix = matchOperatorPrefix(allowedOps, trimStart(textWithoutProperty));\n if (operatorPrefix !== null) {\n return { step: 'operator', property, operatorPrefix };\n }\n\n return {\n step: 'free-text',\n value: filteringText,\n };\n};\n\nexport const getPropertyOptions = (\n filteringProperty: FilteringProperty,\n filteringOptions: readonly FilteringOption[]\n) => {\n return filteringOptions.filter(option => option.propertyKey === filteringProperty.key);\n};\n\ninterface OptionGroup<T> {\n label: string;\n options: T[];\n}\n\nexport const getAllValueSuggestions = (\n filteringOptions: readonly FilteringOption[],\n filteringProperties: readonly FilteringProperty[],\n operator: ComparisonOperator | undefined = '=',\n i18nStrings: I18nStrings,\n customGroupsText: readonly GroupText[]\n) => {\n const defaultGroup: OptionGroup<AutosuggestProps.Option> = {\n label: i18nStrings.groupValuesText,\n options: [],\n };\n const customGroups: { [K in string]: OptionGroup<AutosuggestProps.Option> } = {};\n filteringOptions.forEach(filteringOption => {\n const property = getPropertyByKey(filteringProperties, filteringOption.propertyKey);\n // given option refers to a non-existent filtering property\n if (!property) {\n return;\n }\n // this option's filtering property does not support current operator\n if (getAllowedOperators(property).indexOf(operator) === -1) {\n return;\n }\n if (property.group && !customGroups[property.group]) {\n const label = customGroupsText.reduce<string>(\n (acc, customGroup) => (customGroup.group === property.group ? customGroup.values : acc),\n ''\n );\n customGroups[property.group] = {\n label,\n options: [],\n };\n }\n const propertyGroup = property.group ? customGroups[property.group] : defaultGroup;\n propertyGroup.options.push({\n value: property.propertyLabel + ' ' + (operator || '=') + ' ' + filteringOption.value,\n label: filteringOption.label ?? filteringOption.value,\n __labelPrefix: property.propertyLabel + ' ' + (operator || '='),\n });\n });\n return [defaultGroup, ...Object.keys(customGroups).map(group => customGroups[group])];\n};\n\nexport const getPropertyByKey = (filteringProperties: readonly FilteringProperty[], key: string) => {\n const propertyMap = filteringProperties.reduce<{ [K: string]: FilteringProperty }>((acc, property) => {\n acc[property.key] = property;\n return acc;\n }, {});\n return propertyMap[key] as FilteringProperty | undefined;\n};\n\nexport function getExtendedOperator(\n filteringProperties: readonly FilteringProperty[],\n property: string,\n operator: ComparisonOperator\n) {\n const matchedProperty = getPropertyByKey(filteringProperties, property);\n for (const matchedOperator of matchedProperty?.operators || []) {\n if (typeof matchedOperator === 'object' && matchedOperator.operator === operator) {\n return matchedOperator;\n }\n }\n return null;\n}\n\nexport function createPropertiesCompatibilityMap(\n filteringProperties: readonly FilteringProperty[]\n): (propertyA: string, propertyB: string) => boolean {\n const lookup: {\n [propertyKey: string]: { operator: string; form: ExtendedOperatorForm<any> | undefined }[];\n } = {};\n\n for (const property of filteringProperties) {\n lookup[property.key] = (property.operators || [])\n .map(operator =>\n typeof operator === 'object'\n ? { operator: operator.operator, form: operator.form }\n : { operator, form: undefined }\n )\n .sort((a, b) => a.operator.localeCompare(b.operator));\n }\n\n return (propertyA: string, propertyB: string) => {\n if (lookup[propertyA].length !== lookup[propertyB].length) {\n return false;\n }\n for (let i = 0; i < lookup[propertyA].length; i++) {\n if (lookup[propertyA][i].operator !== lookup[propertyB][i].operator) {\n return false;\n }\n if (lookup[propertyA][i].form !== lookup[propertyB][i].form) {\n return false;\n }\n }\n return true;\n };\n}\n\nconst filteringPropertyToAutosuggestOption = (filteringProperty: FilteringProperty) => ({\n value: filteringProperty.propertyLabel,\n label: filteringProperty.propertyLabel,\n keepOpenOnSelect: true,\n});\n\nexport function getPropertySuggestions<T>(\n filteringProperties: readonly FilteringProperty[],\n customGroupsText: readonly GroupText[],\n i18nStrings: I18nStrings,\n filteringPropertyToOption: (filteringProperty: FilteringProperty) => T\n) {\n const defaultGroup: OptionGroup<T> = {\n label: i18nStrings.groupPropertiesText,\n options: [],\n };\n const customGroups: { [K in string]: OptionGroup<T> } = {};\n\n filteringProperties.forEach(filteringProperty => {\n const { group } = filteringProperty;\n let optionsGroup = defaultGroup;\n if (group) {\n if (!customGroups[group]) {\n const label = customGroupsText.reduce<string>(\n (acc, customGroup) => (customGroup.group === group ? customGroup.properties : acc),\n ''\n );\n customGroups[group] = { options: [], label };\n }\n optionsGroup = customGroups[group];\n }\n optionsGroup.options.push(filteringPropertyToOption(filteringProperty));\n });\n const defaultGroupArray = defaultGroup.options.length ? [defaultGroup] : [];\n const customGroupsArray = Object.keys(customGroups).map(groupKey => customGroups[groupKey]);\n return [...defaultGroupArray, ...customGroupsArray];\n}\n\nexport const getAutosuggestOptions = (\n parsedText: ParsedText,\n filteringOptions: readonly FilteringOption[],\n filteringProperties: readonly FilteringProperty[],\n customGroupsText: readonly GroupText[],\n i18nStrings: I18nStrings\n) => {\n switch (parsedText.step) {\n case 'property': {\n const { propertyLabel, groupValuesLabel } = parsedText.property;\n const options = getPropertyOptions(parsedText.property, filteringOptions);\n return {\n filterText: parsedText.value,\n options: [\n {\n options: options.map(({ label, value }) => ({\n value: propertyLabel + ' ' + parsedText.operator + ' ' + value,\n label: label ?? value,\n __labelPrefix: propertyLabel + ' ' + parsedText.operator,\n })),\n label: groupValuesLabel,\n },\n ],\n };\n }\n case 'operator': {\n return {\n filterText: parsedText.property.propertyLabel + ' ' + parsedText.operatorPrefix,\n options: [\n ...getPropertySuggestions(\n filteringProperties,\n customGroupsText,\n i18nStrings,\n filteringPropertyToAutosuggestOption\n ),\n {\n options: getAllowedOperators(parsedText.property).map(value => ({\n value: parsedText.property.propertyLabel + ' ' + value + ' ',\n label: parsedText.property.propertyLabel + ' ' + value,\n description: operatorToDescription(value, i18nStrings),\n keepOpenOnSelect: true,\n })),\n label: i18nStrings.operatorsText,\n },\n ],\n };\n }\n case 'free-text': {\n const needsValueSuggestions = !!parsedText.value;\n const needsPropertySuggestions = !(parsedText.step === 'free-text' && parsedText.operator === '!:');\n return {\n filterText: parsedText.value,\n options: [\n ...(needsPropertySuggestions\n ? getPropertySuggestions(\n filteringProperties,\n customGroupsText,\n i18nStrings,\n filteringPropertyToAutosuggestOption\n )\n : []),\n ...(needsValueSuggestions\n ? getAllValueSuggestions(\n filteringOptions,\n filteringProperties,\n parsedText.operator,\n i18nStrings,\n customGroupsText\n )\n : []),\n ],\n };\n }\n }\n};\n\nexport const operatorToDescription = (operator: ComparisonOperator, i18nStrings: I18nStrings) => {\n const mapping: { [K in ComparisonOperator]: string } = {\n ['<']: i18nStrings.operatorLessText,\n ['<=']: i18nStrings.operatorLessOrEqualText,\n ['>']: i18nStrings.operatorGreaterText,\n ['>=']: i18nStrings.operatorGreaterOrEqualText,\n [':']: i18nStrings.operatorContainsText,\n ['!:']: i18nStrings.operatorDoesNotContainText,\n ['=']: i18nStrings.operatorEqualsText,\n ['!=']: i18nStrings.operatorDoesNotEqualText,\n };\n return mapping[operator];\n};\n"]}
|
|
@@ -25,7 +25,11 @@ function isGroup(optionOrGroup) {
|
|
|
25
25
|
return 'options' in optionOrGroup;
|
|
26
26
|
}
|
|
27
27
|
function matchSingleOption(option, searchText) {
|
|
28
|
-
var _a;
|
|
29
|
-
|
|
28
|
+
var _a, _b;
|
|
29
|
+
searchText = searchText.toLowerCase();
|
|
30
|
+
var label = ((_a = option.label) !== null && _a !== void 0 ? _a : '').toLowerCase();
|
|
31
|
+
var labelPrefix = (_b = option.__labelPrefix) !== null && _b !== void 0 ? _b : '';
|
|
32
|
+
var value = (option.value ? option.value.slice(labelPrefix.length) : '').toLowerCase();
|
|
33
|
+
return label.indexOf(searchText) !== -1 || value.indexOf(searchText) !== -1;
|
|
30
34
|
}
|
|
31
35
|
//# sourceMappingURL=filter-options.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter-options.js","sourceRoot":"","sources":["../../../src/property-filter/filter-options.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAKtC,MAAM,UAAU,aAAa,CAC3B,OAA4E,EAC5E,UAAe;IAAf,2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CAAC,CAAC;YAC/D,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC3B,QAAQ,CAAC,IAAI,uBAAM,MAAM,KAAE,OAAO,EAAE,YAAY,IAAG,CAAC;aACrD;SACF;aAAM,IAAI,iBAAiB,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE;YAChD,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SACvB;KACF;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,OAAO,CAAC,aAAsC;IACrD,OAAO,SAAS,IAAI,aAAa,CAAC;AACpC,CAAC;AAED,SAAS,iBAAiB,CAAC,MAAwB,EAAE,UAAkB;;IACrE,UAAU,GAAG,UAAU,CAAC,WAAW,EAAE,CAAC;IAEtC,IAAM,KAAK,GAAG,CAAC,MAAA,MAAM,CAAC,KAAK,mCAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IACjD,IAAM,WAAW,GAAG,MAAA,MAAM,CAAC,aAAa,mCAAI,EAAE,CAAC;IAC/C,IAAM,KAAK,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IACzF,OAAO,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;AAC9E,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { AutosuggestProps } from '../autosuggest/interfaces';\nimport { OptionDefinition } from '../internal/components/option/interfaces';\n\nexport function filterOptions(\n options: readonly (AutosuggestProps.Option | AutosuggestProps.OptionGroup)[],\n searchText = ''\n): readonly (AutosuggestProps.Option | AutosuggestProps.OptionGroup)[] {\n if (!searchText) {\n return options;\n }\n\n const filtered: (AutosuggestProps.Option | AutosuggestProps.OptionGroup)[] = [];\n for (const option of options) {\n if (isGroup(option)) {\n const childOptions = filterOptions(option.options, searchText);\n if (childOptions.length > 0) {\n filtered.push({ ...option, options: childOptions });\n }\n } else if (matchSingleOption(option, searchText)) {\n filtered.push(option);\n }\n }\n return filtered;\n}\n\nfunction isGroup(optionOrGroup: AutosuggestProps.Option): optionOrGroup is AutosuggestProps.OptionGroup {\n return 'options' in optionOrGroup;\n}\n\nfunction matchSingleOption(option: OptionDefinition, searchText: string): boolean {\n searchText = searchText.toLowerCase();\n\n const label = (option.label ?? '').toLowerCase();\n const labelPrefix = option.__labelPrefix ?? '';\n const value = (option.value ? option.value.slice(labelPrefix.length) : '').toLowerCase();\n return label.indexOf(searchText) !== -1 || value.indexOf(searchText) !== -1;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/property-filter/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAyD,MAAM,OAAO,CAAC;AAW9E,OAAO,EAAE,mBAAmB,EAAiE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/property-filter/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAyD,MAAM,OAAO,CAAC;AAW9E,OAAO,EAAE,mBAAmB,EAAiE,MAAM,cAAc,CAAC;AAiBlH,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAE/B,QAAA,MAAM,cAAc,qGAqRnB,CAAC;AAGF,eAAe,cAAc,CAAC"}
|
package/property-filter/index.js
CHANGED
|
@@ -18,6 +18,7 @@ import styles from './styles.css.js';
|
|
|
18
18
|
import useBaseComponent from '../internal/hooks/use-base-component';
|
|
19
19
|
import PropertyFilterAutosuggest from './property-filter-autosuggest';
|
|
20
20
|
import { PropertyEditor } from './property-editor';
|
|
21
|
+
import { matchTokenValue } from './utils';
|
|
21
22
|
var PropertyFilter = React.forwardRef(function (_a, ref) {
|
|
22
23
|
var _b;
|
|
23
24
|
var disabled = _a.disabled, i18nStrings = _a.i18nStrings, countText = _a.countText, query = _a.query, hideOperations = _a.hideOperations, onChange = _a.onChange, filteringProperties = _a.filteringProperties, _c = _a.filteringOptions, filteringOptions = _c === void 0 ? [] : _c, _d = _a.customGroupsText, customGroupsText = _d === void 0 ? [] : _d, _e = _a.disableFreeTextFiltering, disableFreeTextFiltering = _e === void 0 ? false : _e, onLoadItems = _a.onLoadItems, virtualScroll = _a.virtualScroll, customControl = _a.customControl, filteringEmpty = _a.filteringEmpty, filteringLoadingText = _a.filteringLoadingText, filteringFinishedText = _a.filteringFinishedText, filteringErrorText = _a.filteringErrorText, filteringRecoveryText = _a.filteringRecoveryText, filteringStatusType = _a.filteringStatusType, asyncProperties = _a.asyncProperties, tokenLimit = _a.tokenLimit, expandToViewport = _a.expandToViewport, rest = __rest(_a, ["disabled", "i18nStrings", "countText", "query", "hideOperations", "onChange", "filteringProperties", "filteringOptions", "customGroupsText", "disableFreeTextFiltering", "onLoadItems", "virtualScroll", "customControl", "filteringEmpty", "filteringLoadingText", "filteringFinishedText", "filteringErrorText", "filteringRecoveryText", "filteringStatusType", "asyncProperties", "tokenLimit", "expandToViewport"]);
|
|
@@ -36,11 +37,11 @@ var PropertyFilter = React.forwardRef(function (_a, ref) {
|
|
|
36
37
|
var newToken;
|
|
37
38
|
switch (parsedText.step) {
|
|
38
39
|
case 'property': {
|
|
39
|
-
newToken = {
|
|
40
|
+
newToken = matchTokenValue({
|
|
40
41
|
propertyKey: parsedText.property.key,
|
|
41
42
|
operator: parsedText.operator,
|
|
42
43
|
value: parsedText.value
|
|
43
|
-
};
|
|
44
|
+
}, filteringOptions);
|
|
44
45
|
break;
|
|
45
46
|
}
|
|
46
47
|
case 'free-text': {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/property-filter/index.tsx"],"names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AE,QAAQ,IAC1F,WAAW,CAAC,gBAAgB,CACd,CACI,CACnB,CACP,CACI,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,gBAAgB,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;AACnD,eAAe,cAAc,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport clsx from 'clsx';\nimport React, { useRef, useState, useMemo, useImperativeHandle } from 'react';\n\nimport InternalSpaceBetween from '../space-between/internal';\nimport { InternalButton } from '../button/internal';\nimport { getBaseProps } from '../internal/base-component';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { KeyCode } from '../internal/keycode';\nimport SelectToggle from '../token-group/toggle';\nimport { generateUniqueId } from '../internal/hooks/use-unique-id/index';\nimport { fireNonCancelableEvent } from '../internal/events';\n\nimport { PropertyFilterProps, ParsedText, Ref, FilteringProperty, ComparisonOperator, Token } from './interfaces';\nimport { TokenButton } from './token';\nimport {\n getQueryActions,\n parseText,\n getAutosuggestOptions,\n getAllowedOperators,\n getExtendedOperator,\n} from './controller';\nimport { useLoadItems } from './use-load-items';\nimport styles from './styles.css.js';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport PropertyFilterAutosuggest, { PropertyFilterAutosuggestProps } from './property-filter-autosuggest';\nimport { PropertyEditor } from './property-editor';\nimport { AutosuggestInputRef } from '../internal/components/autosuggest-input';\n\nexport { PropertyFilterProps };\n\nconst PropertyFilter = React.forwardRef(\n (\n {\n disabled,\n i18nStrings,\n countText,\n query,\n hideOperations,\n onChange,\n filteringProperties,\n filteringOptions = [],\n customGroupsText = [],\n disableFreeTextFiltering = false,\n onLoadItems,\n virtualScroll,\n customControl,\n filteringEmpty,\n filteringLoadingText,\n filteringFinishedText,\n filteringErrorText,\n filteringRecoveryText,\n filteringStatusType,\n asyncProperties,\n tokenLimit,\n expandToViewport,\n ...rest\n }: PropertyFilterProps,\n ref: React.Ref<Ref>\n ) => {\n const { __internalRootRef } = useBaseComponent('PropertyFilter');\n const inputRef = useRef<AutosuggestInputRef>(null);\n const baseProps = getBaseProps(rest);\n useImperativeHandle(ref, () => ({ focus: () => inputRef.current?.focus() }), []);\n const { tokens, operation } = query;\n const showResults = tokens?.length && !disabled;\n const { addToken, removeToken, setToken, setOperation, removeAllTokens } = getQueryActions(\n query,\n onChange,\n inputRef\n );\n const [filteringText, setFilteringText] = useState<string>('');\n const parsedText = parseText(filteringText, filteringProperties, disableFreeTextFiltering);\n const autosuggestOptions = getAutosuggestOptions(\n parsedText,\n filteringOptions,\n filteringProperties,\n customGroupsText,\n i18nStrings\n );\n\n const createToken = (currentText: string) => {\n const parsedText = parseText(currentText, filteringProperties, disableFreeTextFiltering);\n let newToken: Token;\n switch (parsedText.step) {\n case 'property': {\n newToken = {\n propertyKey: parsedText.property.key,\n operator: parsedText.operator,\n value: parsedText.value,\n };\n break;\n }\n case 'free-text': {\n newToken = {\n operator: parsedText.operator || ':',\n value: parsedText.value,\n };\n break;\n }\n case 'operator': {\n newToken = {\n operator: ':',\n value: currentText,\n };\n break;\n }\n }\n if (disableFreeTextFiltering && !('propertyKey' in newToken)) {\n return;\n }\n addToken(newToken);\n setFilteringText('');\n };\n const ignoreKeyDown = useRef<boolean>(false);\n const handleKeyDown: PropertyFilterAutosuggestProps['onKeyDown'] = event => {\n if (filteringText && !ignoreKeyDown.current && event.detail.keyCode === KeyCode.enter) {\n createToken(filteringText);\n }\n };\n const getLoadMoreDetail = (parsedText: ParsedText, filteringText: string) => {\n const loadMoreDetail: {\n filteringProperty: FilteringProperty | undefined;\n filteringText: string;\n filteringOperator: ComparisonOperator | undefined;\n } = {\n filteringProperty: undefined,\n filteringText,\n filteringOperator: undefined,\n };\n if (parsedText.step === 'property') {\n loadMoreDetail.filteringProperty = parsedText.property;\n loadMoreDetail.filteringText = parsedText.value;\n loadMoreDetail.filteringOperator = parsedText.operator;\n }\n return loadMoreDetail;\n };\n const loadMoreDetail = getLoadMoreDetail(parsedText, filteringText);\n const inputLoadItemsHandlers = useLoadItems(\n onLoadItems,\n loadMoreDetail.filteringText,\n loadMoreDetail.filteringProperty,\n loadMoreDetail.filteringText,\n loadMoreDetail.filteringOperator\n );\n const asyncProps = {\n empty: filteringEmpty,\n loadingText: filteringLoadingText,\n finishedText: filteringFinishedText,\n errorText: filteringErrorText,\n recoveryText: filteringRecoveryText,\n statusType: filteringStatusType,\n };\n const asyncAutosuggestProps =\n !!filteringText.length || asyncProperties\n ? {\n ...inputLoadItemsHandlers,\n ...asyncProps,\n }\n : {};\n const handleSelected: PropertyFilterAutosuggestProps['onOptionClick'] = event => {\n // The ignoreKeyDown flag makes sure `createToken` routine runs only once. Autosuggest's `onKeyDown` fires,\n // when an item is selected from the list using \"enter\" key.\n ignoreKeyDown.current = true;\n setTimeout(() => {\n ignoreKeyDown.current = false;\n }, 0);\n const { detail: option } = event;\n const value = option.value || '';\n\n if (!('keepOpenOnSelect' in option)) {\n createToken(value);\n return;\n }\n\n // stop dropdown from closing\n event.preventDefault();\n\n const parsedText = parseText(value, filteringProperties, disableFreeTextFiltering);\n const loadMoreDetail = getLoadMoreDetail(parsedText, value);\n\n // Insert operator automatically if only one operator is defined for the given property.\n if (parsedText.step === 'operator') {\n const operators = getAllowedOperators(parsedText.property);\n if (value.trim() === parsedText.property.propertyLabel && operators.length === 1) {\n loadMoreDetail.filteringProperty = parsedText.property;\n loadMoreDetail.filteringOperator = operators[0];\n loadMoreDetail.filteringText = '';\n setFilteringText(parsedText.property.propertyLabel + ' ' + operators[0] + ' ');\n }\n }\n\n fireNonCancelableEvent(onLoadItems, { ...loadMoreDetail, firstPage: true, samePage: false });\n };\n const [tokensExpanded, setTokensExpanded] = useState(false);\n const toggleExpandedTokens = () => setTokensExpanded(!tokensExpanded);\n const hasHiddenOptions = tokenLimit !== undefined && tokens.length > tokenLimit;\n const slicedTokens = hasHiddenOptions && !tokensExpanded ? tokens.slice(0, tokenLimit) : tokens;\n const controlId = useMemo(() => generateUniqueId(), []);\n\n const operatorForm =\n parsedText.step === 'property' &&\n getExtendedOperator(filteringProperties, parsedText.property.key, parsedText.operator)?.form;\n\n return (\n <span {...baseProps} className={clsx(baseProps.className, styles.root)} ref={__internalRootRef}>\n <div className={styles['search-field']}>\n {customControl && <div className={styles['custom-control']}>{customControl}</div>}\n <PropertyFilterAutosuggest\n ref={inputRef}\n virtualScroll={virtualScroll}\n enteredTextLabel={i18nStrings.enteredTextLabel}\n ariaLabel={i18nStrings.filteringAriaLabel}\n placeholder={i18nStrings.filteringPlaceholder}\n value={filteringText}\n disabled={disabled}\n onKeyDown={handleKeyDown}\n {...autosuggestOptions}\n onChange={event => setFilteringText(event.detail.value)}\n empty={filteringEmpty}\n {...asyncAutosuggestProps}\n expandToViewport={expandToViewport}\n onOptionClick={handleSelected}\n customForm={\n operatorForm && (\n <PropertyEditor\n property={parsedText.property}\n operator={parsedText.operator}\n filter={parsedText.value}\n operatorForm={operatorForm}\n i18nStrings={i18nStrings}\n onCancel={() => {\n setFilteringText('');\n inputRef.current?.close();\n inputRef.current?.focus({ preventDropdown: true });\n }}\n onSubmit={token => {\n addToken(token);\n setFilteringText('');\n inputRef.current?.focus({ preventDropdown: true });\n inputRef.current?.close();\n }}\n />\n )\n }\n hideEnteredTextOption={disableFreeTextFiltering && parsedText.step !== 'property'}\n />\n <span\n aria-live=\"polite\"\n aria-atomic=\"true\"\n className={clsx(styles.results, showResults && styles['results-visible'])}\n >\n {showResults ? countText : ''}\n </span>\n </div>\n {tokens && tokens.length > 0 && (\n <div className={styles.tokens}>\n <InternalSpaceBetween size=\"xs\" direction=\"horizontal\" id={controlId}>\n {slicedTokens.map((token, index) => (\n <TokenButton\n token={token}\n first={index === 0}\n operation={operation}\n key={index}\n removeToken={() => removeToken(index)}\n setToken={(newToken: Token) => setToken(index, newToken)}\n setOperation={setOperation}\n filteringOptions={filteringOptions}\n filteringProperties={filteringProperties}\n asyncProps={asyncProps}\n onLoadItems={onLoadItems}\n i18nStrings={i18nStrings}\n asyncProperties={asyncProperties}\n hideOperations={hideOperations}\n customGroupsText={customGroupsText}\n disableFreeTextFiltering={disableFreeTextFiltering}\n disabled={disabled}\n expandToViewport={expandToViewport}\n />\n ))}\n {hasHiddenOptions && (\n <div className={styles['toggle-collapsed']}>\n <SelectToggle\n controlId={controlId}\n allHidden={tokenLimit === 0}\n expanded={tokensExpanded}\n numberOfHiddenOptions={tokens.length - slicedTokens.length}\n i18nStrings={{\n limitShowFewer: i18nStrings.tokenLimitShowFewer,\n limitShowMore: i18nStrings.tokenLimitShowMore,\n }}\n onClick={toggleExpandedTokens}\n />\n </div>\n )}\n <div className={styles.separator} />\n <InternalButton onClick={removeAllTokens} className={styles['remove-all']} disabled={disabled}>\n {i18nStrings.clearFiltersText}\n </InternalButton>\n </InternalSpaceBetween>\n </div>\n )}\n </span>\n );\n }\n);\n\napplyDisplayName(PropertyFilter, 'PropertyFilter');\nexport default PropertyFilter;\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/property-filter/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAE9E,OAAO,oBAAoB,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,YAAY,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;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WAAW,EACxB,eAAe,EAAE,eAAe,EAChC,cAAc,EAAE,cAAc,EAC9B,gBAAgB,EAAE,gBAAgB,EAClC,wBAAwB,EAAE,wBAAwB,EAClD,QAAQ,EAAE,QAAQ,EAClB,gBAAgB,EAAE,gBAAgB,GAClC,CACH,EArBmC,CAqBnC,CAAC;gBACD,gBAAgB,IAAI,CACnB,6BAAK,SAAS,EAAE,MAAM,CAAC,kBAAkB,CAAC;oBACxC,oBAAC,YAAY,IACX,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,UAAU,KAAK,CAAC,EAC3B,QAAQ,EAAE,cAAc,EACxB,qBAAqB,EAAE,MAAM,CAAC,MAAM,GAAG,YAAY,CAAC,MAAM,EAC1D,WAAW,EAAE;4BACX,cAAc,EAAE,WAAW,CAAC,mBAAmB;4BAC/C,aAAa,EAAE,WAAW,CAAC,kBAAkB;yBAC9C,EACD,OAAO,EAAE,oBAAoB,GAC7B,CACE,CACP;gBACD,6BAAK,SAAS,EAAE,MAAM,CAAC,SAAS,GAAI;gBACpC,oBAAC,cAAc,IAAC,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,CAAC,YAAY,CAAC,EAAE,QAAQ,EAAE,QAAQ,IAC1F,WAAW,CAAC,gBAAgB,CACd,CACI,CACnB,CACP,CACI,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,gBAAgB,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;AACnD,eAAe,cAAc,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport clsx from 'clsx';\nimport React, { useRef, useState, useMemo, useImperativeHandle } from 'react';\n\nimport InternalSpaceBetween from '../space-between/internal';\nimport { InternalButton } from '../button/internal';\nimport { getBaseProps } from '../internal/base-component';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { KeyCode } from '../internal/keycode';\nimport SelectToggle from '../token-group/toggle';\nimport { generateUniqueId } from '../internal/hooks/use-unique-id/index';\nimport { fireNonCancelableEvent } from '../internal/events';\n\nimport { PropertyFilterProps, ParsedText, Ref, FilteringProperty, ComparisonOperator, Token } from './interfaces';\nimport { TokenButton } from './token';\nimport {\n getQueryActions,\n parseText,\n getAutosuggestOptions,\n getAllowedOperators,\n getExtendedOperator,\n} from './controller';\nimport { useLoadItems } from './use-load-items';\nimport styles from './styles.css.js';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport PropertyFilterAutosuggest, { PropertyFilterAutosuggestProps } from './property-filter-autosuggest';\nimport { PropertyEditor } from './property-editor';\nimport { AutosuggestInputRef } from '../internal/components/autosuggest-input';\nimport { matchTokenValue } from './utils';\n\nexport { PropertyFilterProps };\n\nconst PropertyFilter = React.forwardRef(\n (\n {\n disabled,\n i18nStrings,\n countText,\n query,\n hideOperations,\n onChange,\n filteringProperties,\n filteringOptions = [],\n customGroupsText = [],\n disableFreeTextFiltering = false,\n onLoadItems,\n virtualScroll,\n customControl,\n filteringEmpty,\n filteringLoadingText,\n filteringFinishedText,\n filteringErrorText,\n filteringRecoveryText,\n filteringStatusType,\n asyncProperties,\n tokenLimit,\n expandToViewport,\n ...rest\n }: PropertyFilterProps,\n ref: React.Ref<Ref>\n ) => {\n const { __internalRootRef } = useBaseComponent('PropertyFilter');\n const inputRef = useRef<AutosuggestInputRef>(null);\n const baseProps = getBaseProps(rest);\n useImperativeHandle(ref, () => ({ focus: () => inputRef.current?.focus() }), []);\n const { tokens, operation } = query;\n const showResults = tokens?.length && !disabled;\n const { addToken, removeToken, setToken, setOperation, removeAllTokens } = getQueryActions(\n query,\n onChange,\n inputRef\n );\n const [filteringText, setFilteringText] = useState<string>('');\n const parsedText = parseText(filteringText, filteringProperties, disableFreeTextFiltering);\n const autosuggestOptions = getAutosuggestOptions(\n parsedText,\n filteringOptions,\n filteringProperties,\n customGroupsText,\n i18nStrings\n );\n\n const createToken = (currentText: string) => {\n const parsedText = parseText(currentText, filteringProperties, disableFreeTextFiltering);\n let newToken: Token;\n switch (parsedText.step) {\n case 'property': {\n newToken = matchTokenValue(\n {\n propertyKey: parsedText.property.key,\n operator: parsedText.operator,\n value: parsedText.value,\n },\n filteringOptions\n );\n break;\n }\n case 'free-text': {\n newToken = {\n operator: parsedText.operator || ':',\n value: parsedText.value,\n };\n break;\n }\n case 'operator': {\n newToken = {\n operator: ':',\n value: currentText,\n };\n break;\n }\n }\n if (disableFreeTextFiltering && !('propertyKey' in newToken)) {\n return;\n }\n addToken(newToken);\n setFilteringText('');\n };\n const ignoreKeyDown = useRef<boolean>(false);\n const handleKeyDown: PropertyFilterAutosuggestProps['onKeyDown'] = event => {\n if (filteringText && !ignoreKeyDown.current && event.detail.keyCode === KeyCode.enter) {\n createToken(filteringText);\n }\n };\n const getLoadMoreDetail = (parsedText: ParsedText, filteringText: string) => {\n const loadMoreDetail: {\n filteringProperty: FilteringProperty | undefined;\n filteringText: string;\n filteringOperator: ComparisonOperator | undefined;\n } = {\n filteringProperty: undefined,\n filteringText,\n filteringOperator: undefined,\n };\n if (parsedText.step === 'property') {\n loadMoreDetail.filteringProperty = parsedText.property;\n loadMoreDetail.filteringText = parsedText.value;\n loadMoreDetail.filteringOperator = parsedText.operator;\n }\n return loadMoreDetail;\n };\n const loadMoreDetail = getLoadMoreDetail(parsedText, filteringText);\n const inputLoadItemsHandlers = useLoadItems(\n onLoadItems,\n loadMoreDetail.filteringText,\n loadMoreDetail.filteringProperty,\n loadMoreDetail.filteringText,\n loadMoreDetail.filteringOperator\n );\n const asyncProps = {\n empty: filteringEmpty,\n loadingText: filteringLoadingText,\n finishedText: filteringFinishedText,\n errorText: filteringErrorText,\n recoveryText: filteringRecoveryText,\n statusType: filteringStatusType,\n };\n const asyncAutosuggestProps =\n !!filteringText.length || asyncProperties\n ? {\n ...inputLoadItemsHandlers,\n ...asyncProps,\n }\n : {};\n const handleSelected: PropertyFilterAutosuggestProps['onOptionClick'] = event => {\n // The ignoreKeyDown flag makes sure `createToken` routine runs only once. Autosuggest's `onKeyDown` fires,\n // when an item is selected from the list using \"enter\" key.\n ignoreKeyDown.current = true;\n setTimeout(() => {\n ignoreKeyDown.current = false;\n }, 0);\n const { detail: option } = event;\n const value = option.value || '';\n\n if (!('keepOpenOnSelect' in option)) {\n createToken(value);\n return;\n }\n\n // stop dropdown from closing\n event.preventDefault();\n\n const parsedText = parseText(value, filteringProperties, disableFreeTextFiltering);\n const loadMoreDetail = getLoadMoreDetail(parsedText, value);\n\n // Insert operator automatically if only one operator is defined for the given property.\n if (parsedText.step === 'operator') {\n const operators = getAllowedOperators(parsedText.property);\n if (value.trim() === parsedText.property.propertyLabel && operators.length === 1) {\n loadMoreDetail.filteringProperty = parsedText.property;\n loadMoreDetail.filteringOperator = operators[0];\n loadMoreDetail.filteringText = '';\n setFilteringText(parsedText.property.propertyLabel + ' ' + operators[0] + ' ');\n }\n }\n\n fireNonCancelableEvent(onLoadItems, { ...loadMoreDetail, firstPage: true, samePage: false });\n };\n const [tokensExpanded, setTokensExpanded] = useState(false);\n const toggleExpandedTokens = () => setTokensExpanded(!tokensExpanded);\n const hasHiddenOptions = tokenLimit !== undefined && tokens.length > tokenLimit;\n const slicedTokens = hasHiddenOptions && !tokensExpanded ? tokens.slice(0, tokenLimit) : tokens;\n const controlId = useMemo(() => generateUniqueId(), []);\n\n const operatorForm =\n parsedText.step === 'property' &&\n getExtendedOperator(filteringProperties, parsedText.property.key, parsedText.operator)?.form;\n\n return (\n <span {...baseProps} className={clsx(baseProps.className, styles.root)} ref={__internalRootRef}>\n <div className={styles['search-field']}>\n {customControl && <div className={styles['custom-control']}>{customControl}</div>}\n <PropertyFilterAutosuggest\n ref={inputRef}\n virtualScroll={virtualScroll}\n enteredTextLabel={i18nStrings.enteredTextLabel}\n ariaLabel={i18nStrings.filteringAriaLabel}\n placeholder={i18nStrings.filteringPlaceholder}\n value={filteringText}\n disabled={disabled}\n onKeyDown={handleKeyDown}\n {...autosuggestOptions}\n onChange={event => setFilteringText(event.detail.value)}\n empty={filteringEmpty}\n {...asyncAutosuggestProps}\n expandToViewport={expandToViewport}\n onOptionClick={handleSelected}\n customForm={\n operatorForm && (\n <PropertyEditor\n property={parsedText.property}\n operator={parsedText.operator}\n filter={parsedText.value}\n operatorForm={operatorForm}\n i18nStrings={i18nStrings}\n onCancel={() => {\n setFilteringText('');\n inputRef.current?.close();\n inputRef.current?.focus({ preventDropdown: true });\n }}\n onSubmit={token => {\n addToken(token);\n setFilteringText('');\n inputRef.current?.focus({ preventDropdown: true });\n inputRef.current?.close();\n }}\n />\n )\n }\n hideEnteredTextOption={disableFreeTextFiltering && parsedText.step !== 'property'}\n />\n <span\n aria-live=\"polite\"\n aria-atomic=\"true\"\n className={clsx(styles.results, showResults && styles['results-visible'])}\n >\n {showResults ? countText : ''}\n </span>\n </div>\n {tokens && tokens.length > 0 && (\n <div className={styles.tokens}>\n <InternalSpaceBetween size=\"xs\" direction=\"horizontal\" id={controlId}>\n {slicedTokens.map((token, index) => (\n <TokenButton\n token={token}\n first={index === 0}\n operation={operation}\n key={index}\n removeToken={() => removeToken(index)}\n setToken={(newToken: Token) => setToken(index, newToken)}\n setOperation={setOperation}\n filteringOptions={filteringOptions}\n filteringProperties={filteringProperties}\n asyncProps={asyncProps}\n onLoadItems={onLoadItems}\n i18nStrings={i18nStrings}\n asyncProperties={asyncProperties}\n hideOperations={hideOperations}\n customGroupsText={customGroupsText}\n disableFreeTextFiltering={disableFreeTextFiltering}\n disabled={disabled}\n expandToViewport={expandToViewport}\n />\n ))}\n {hasHiddenOptions && (\n <div className={styles['toggle-collapsed']}>\n <SelectToggle\n controlId={controlId}\n allHidden={tokenLimit === 0}\n expanded={tokensExpanded}\n numberOfHiddenOptions={tokens.length - slicedTokens.length}\n i18nStrings={{\n limitShowFewer: i18nStrings.tokenLimitShowFewer,\n limitShowMore: i18nStrings.tokenLimitShowMore,\n }}\n onClick={toggleExpandedTokens}\n />\n </div>\n )}\n <div className={styles.separator} />\n <InternalButton onClick={removeAllTokens} className={styles['remove-all']} disabled={disabled}>\n {i18nStrings.clearFiltersText}\n </InternalButton>\n </InternalSpaceBetween>\n </div>\n )}\n </span>\n );\n }\n);\n\napplyDisplayName(PropertyFilter, 'PropertyFilter');\nexport default PropertyFilter;\n"]}
|
|
@@ -63,6 +63,21 @@ export interface PropertyFilterProps extends BaseComponentProps, ExpandToViewpor
|
|
|
63
63
|
*
|
|
64
64
|
* * `propertyKey` [string]: The key of the corresponding filtering property in the `filteringProperties` array.
|
|
65
65
|
* * `value` [string]: The value that will be used as a suggestion when creating or modifying a filtering token.
|
|
66
|
+
* * `label` [string]: Optional suggestion label to be matched instead of the value.
|
|
67
|
+
*
|
|
68
|
+
* Filtering options that require labels can only use `=` and `!=` operators. The token value must be labelled separately, for example:
|
|
69
|
+
* ```
|
|
70
|
+
* const filteringProperty = {
|
|
71
|
+
* key: 'state',
|
|
72
|
+
* propertyLabel: 'State',
|
|
73
|
+
* operators: ['=', '!='].map(operator => ({ operator, format: getStateLabel }))
|
|
74
|
+
* }
|
|
75
|
+
* const filteringOptions = [
|
|
76
|
+
* { propertyKey: 'state', value: 'STOPPED', label: getStateLabel('STOPPED') },
|
|
77
|
+
* { propertyKey: 'state', value: 'STOPPING', label: getStateLabel('STOPPING') },
|
|
78
|
+
* { propertyKey: 'state', value: 'RUNNING', label: getStateLabel('RUNNING') },
|
|
79
|
+
* ]
|
|
80
|
+
* ```
|
|
66
81
|
*/
|
|
67
82
|
filteringOptions?: ReadonlyArray<PropertyFilterProps.FilteringOption>;
|
|
68
83
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/property-filter/interfaces.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,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EAAE,kBAAkB,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/property-filter/interfaces.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React from 'react';\nimport { BaseComponentProps } from '../internal/base-component';\nimport { NonCancelableEventHandler } from '../internal/events';\nimport { DropdownStatusProps } from '../internal/components/dropdown-status';\nimport { AutosuggestProps } from '../autosuggest/interfaces';\nimport { ExpandToViewport } from '../internal/components/dropdown/interfaces';\nimport {\n PropertyFilterOperation,\n PropertyFilterOperator,\n PropertyFilterOperatorExtended,\n PropertyFilterOperatorForm,\n PropertyFilterOperatorFormat,\n PropertyFilterOperatorFormProps,\n PropertyFilterOption,\n PropertyFilterProperty,\n PropertyFilterToken,\n} from '@cloudscape-design/collection-hooks';\n\nexport interface PropertyFilterProps extends BaseComponentProps, ExpandToViewport {\n /**\n * If set to `true`, the filtering input will be disabled.\n * Use it, for example, if you are fetching new items upon filtering change\n * in order to prevent the user from changing the filtering query.\n */\n disabled?: boolean;\n /**\n * An object containing all the necessary localized strings required by the component.\n */\n i18nStrings: PropertyFilterProps.I18nStrings;\n /**\n * Accepts a human-readable, localized string that indicates the number of results. For example, \"1 match\" or \"165 matches.\"\n * If the total number of results is unknown, also include an indication that there may be more results than\n * the number listed. For example, \"25+ matches.\"\n *\n * The count text is only displayed when `query.tokens` isn't empty.\n */\n countText?: string;\n /**\n * An object representing the current query displayed in the property filter. Has two properties: `tokens` and `operation`.\n * `tokens` is an array of objects that will be displayed to the user beneath the filtering input.\n * Each token has the following properties:\n *\n * * value [string]: The string value of the token to be used as a filter.\n * * propertyKey [string]: The key of the corresponding property in filteringProperties.\n * * operator ['<' | '<=' | '>' | '>=' | ':' | '!:' | '=' | '!=']: The operator which indicates how to filter the dataset using this token.\n *\n * `operation` has two valid values [and, or] and controls the join operation to be applied between tokens when filtering the items.\n */\n query: PropertyFilterProps.Query;\n /**\n * If hideOperations it set, the indicator of the operation (that is, `and` or `or`) and the selection of operations\n * (applied to the property and value token) are hidden from the user. Only use when you have a custom\n * filtering logic which combines tokens in different way than the default one. When used, ensure that\n * operations are communicated to the user in another way.\n */\n hideOperations?: boolean;\n /**\n * Fired when the `query` gets changed. Filter the dataset in response to this event using the values in the `detail` object.\n */\n onChange: NonCancelableEventHandler<PropertyFilterProps.Query>;\n /**\n * An array of properties by which the data set can be filtered. Each element has the following properties:\n *\n * * groupValuesLabel [string]: Localized string to display for the 'Values' group label for a specific property.\n * * key [string]: The identifier of this property.\n * * propertyLabel [string]: A human-readable string for the property.\n * * operators [Array]: A list of all operators supported by this property. If you omit the equals operator because your API does not support it, make sure to set `defaultOperator` to a supported operator from this list.\n * * group [string]: Optional identifier of a custom group that this filtering option is assigned to. Use to create additional groups below the default one. Make sure to also define labels for the group in the customGroupsText property. Notice that only one level of options nesting is supported.\n * * defaultOperator [ComparisonOperator]: Optional parameter that changes the default operator used with this filtering property. Use it only if your API does not support \"equals\" filtering terms with this property.\n */\n filteringProperties: ReadonlyArray<PropertyFilterProps.FilteringProperty>;\n /**\n * An array of possible values of the individual `filteringProperties`. Each element has the following properties:\n *\n * * `propertyKey` [string]: The key of the corresponding filtering property in the `filteringProperties` array.\n * * `value` [string]: The value that will be used as a suggestion when creating or modifying a filtering token.\n */\n filteringOptions?: ReadonlyArray<PropertyFilterProps.FilteringOption>;\n /**\n * An array of objects that contain localized, human-readable strings for the labels of custom groups within the filtering dropdown. Use group property to associate the strings with your custom group of options. Define the following values for each group:\n *\n * * properties [string]: The group label in the filtering dropdown that contains the list of properties from this group. For example: Tags.\n * * values [string]: The group label in the filtering dropdown that contains the list of values from this group. For example: Tags values.\n * * group [string]: The identifier of a custom group.\n */\n customGroupsText?: PropertyFilterProps.GroupText[];\n /**\n * Set `disableFreeTextFiltering` only if you can’t filter the dataset using a filter that is applied to every column,\n * instead of a specific property. This would stop the user from creating such tokens.\n */\n disableFreeTextFiltering?: boolean;\n /**\n * Use this event to asynchronously load filteringOptions, component currently needs. The detail object contains following properties:\n *\n * * `filteringProperty` - The property for which you need to fetch the options.\n * * `filteringOperator` - The operator for which you need to fetch the options.\n * * `filteringText` - The value that you need to use to fetch options.\n * * `firstPage` - Indicates that you should fetch the first page of options for a `filteringProperty` that match the `filteringText`.\n * * `samePage` - Indicates that you should fetch the same page that you have previously fetched (for example, when the user clicks on the recovery button).\n */\n onLoadItems?: NonCancelableEventHandler<PropertyFilterProps.LoadItemsDetail>;\n /**\n * If you have more than 500 `filteringOptions`, enable this flag to apply a performance optimization that makes\n * the filtering experience smoother. We don't recommend enabling the feature if you have less than 500 options,\n * because the improvements to performance are offset by a visible scrolling lag. When you set this flag to true,\n * it removes options that are not currently in view from the DOM.\n */\n virtualScroll?: boolean;\n /**\n * A slot located before the filtering input. Use it if for a Select component if your dataset supports property\n * filter queries only after an initial filter is applied.\n */\n customControl?: React.ReactNode;\n /**\n * Set `asyncProperties` if you need to load `filteringProperties` asynchronousely. This would cause extra `onLoadMore`\n * events to fire calling for more properties.\n */\n asyncProperties?: boolean;\n /**\n * Specifies the maximum number of displayed tokens. If the property isn't set, all of the tokens are displayed.\n */\n tokenLimit?: number;\n /**\n * Displayed when there are no options to display.\n * This is only shown when `statusType` is set to `finished` or not set at all.\n */\n filteringEmpty?: React.ReactNode;\n /**\n * Specifies the text to display when in the loading state.\n **/\n filteringLoadingText?: string;\n /**\n * Specifies the text to display at the bottom of the dropdown menu after pagination has reached the end.\n **/\n filteringFinishedText?: string;\n /**\n * Specifies the text to display when a data fetching error occurs. Make sure that you provide `recoveryText`.\n **/\n filteringErrorText?: string;\n /**\n * Specifies the text for the recovery button. The text is displayed next to the error text.\n * Use the `onLoadItems` event to perform a recovery action (for example, retrying the request).\n **/\n filteringRecoveryText?: string;\n /**\n * Specifies the current status of loading more options.\n * * `pending` - Indicates that no request in progress, but more options may be loaded.\n * * `loading` - Indicates that data fetching is in progress.\n * * `finished` - Indicates that pagination has finished and no more requests are expected.\n * * `error` - Indicates that an error occurred during fetch. You should use `recoveryText` to enable the user to recover.\n **/\n filteringStatusType?: DropdownStatusProps.StatusType;\n}\n\nexport namespace PropertyFilterProps {\n export type Token = PropertyFilterToken;\n export type JoinOperation = PropertyFilterOperation;\n export type ComparisonOperator = PropertyFilterOperator;\n export type ExtendedOperator<TokenValue> = PropertyFilterOperatorExtended<TokenValue>;\n export type ExtendedOperatorFormProps<TokenValue> = PropertyFilterOperatorFormProps<TokenValue>;\n export type ExtendedOperatorForm<TokenValue> = PropertyFilterOperatorForm<TokenValue>;\n export type ExtendedOperatorFormat<TokenValue> = PropertyFilterOperatorFormat<TokenValue>;\n export type FilteringOption = PropertyFilterOption;\n export type FilteringProperty = PropertyFilterProperty;\n\n export interface Query {\n tokens: ReadonlyArray<PropertyFilterProps.Token>;\n operation: PropertyFilterProps.JoinOperation;\n }\n\n export interface LoadItemsDetail {\n filteringProperty?: FilteringProperty;\n filteringOperator?: ComparisonOperator;\n filteringText: string;\n firstPage: boolean;\n samePage: boolean;\n }\n\n export interface I18nStrings {\n /**\n * Label that will be passed down to the Autosuggest `ariaLabel` property.\n * See the [Autosuggest API](/system/components/autosuggest/?tabId=api) page for more details.\n */\n filteringAriaLabel: string;\n dismissAriaLabel: string;\n\n filteringPlaceholder?: string;\n groupValuesText: string;\n groupPropertiesText: string;\n operatorsText: string;\n\n operationAndText: string;\n operationOrText: string;\n\n operatorLessText: string;\n operatorLessOrEqualText: string;\n operatorGreaterText: string;\n operatorGreaterOrEqualText: string;\n operatorContainsText: string;\n operatorDoesNotContainText: string;\n operatorEqualsText: string;\n operatorDoesNotEqualText: string;\n\n editTokenHeader: string;\n propertyText: string;\n operatorText: string;\n valueText: string;\n cancelActionText: string;\n applyActionText: string;\n allPropertiesLabel: string;\n\n tokenLimitShowMore?: string;\n tokenLimitShowFewer?: string;\n clearFiltersText: string;\n tokenOperatorAriaLabel?: string;\n removeTokenButtonAriaLabel: (token: PropertyFilterProps.Token) => string;\n enteredTextLabel: AutosuggestProps.EnteredTextLabel;\n }\n\n export interface GroupText {\n properties: string;\n values: string;\n group: string;\n }\n\n export interface FilteringChangeDetail {\n filteringText: string;\n filteringProperty?: FilteringProperty;\n }\n\n export interface Ref {\n /**\n * Sets focus on the underlying input control.\n */\n focus(): void;\n }\n}\n\n// Re-exported namespace interfaces to use module-style imports internally\n\nexport type Token = PropertyFilterProps.Token;\nexport type JoinOperation = PropertyFilterProps.JoinOperation;\nexport type ComparisonOperator = PropertyFilterProps.ComparisonOperator;\nexport type ExtendedOperator<TokenValue> = PropertyFilterOperatorExtended<TokenValue>;\nexport type ExtendedOperatorFormProps<TokenValue> = PropertyFilterOperatorFormProps<TokenValue>;\nexport type ExtendedOperatorForm<TokenValue> = PropertyFilterOperatorForm<TokenValue>;\nexport type ExtendedOperatorFormat<TokenValue> = PropertyFilterOperatorFormat<TokenValue>;\nexport type FilteringOption = PropertyFilterProps.FilteringOption;\nexport type FilteringProperty = PropertyFilterProps.FilteringProperty;\nexport type Query = PropertyFilterProps.Query;\nexport type LoadItemsDetail = PropertyFilterProps.LoadItemsDetail;\nexport type I18nStrings = PropertyFilterProps.I18nStrings;\nexport type GroupText = PropertyFilterProps.GroupText;\nexport type FilteringChangeDetail = PropertyFilterProps.FilteringChangeDetail;\nexport type Ref = PropertyFilterProps.Ref;\n\n// Utility types\n\nexport type ParsedText =\n | { step: 'property'; property: FilteringProperty; operator: ComparisonOperator; value: string }\n | { step: 'operator'; property: FilteringProperty; operatorPrefix: string }\n | { step: 'free-text'; operator?: ComparisonOperator; value: string };\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/property-filter/interfaces.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React from 'react';\nimport { BaseComponentProps } from '../internal/base-component';\nimport { NonCancelableEventHandler } from '../internal/events';\nimport { DropdownStatusProps } from '../internal/components/dropdown-status';\nimport { AutosuggestProps } from '../autosuggest/interfaces';\nimport { ExpandToViewport } from '../internal/components/dropdown/interfaces';\nimport {\n PropertyFilterOperation,\n PropertyFilterOperator,\n PropertyFilterOperatorExtended,\n PropertyFilterOperatorForm,\n PropertyFilterOperatorFormat,\n PropertyFilterOperatorFormProps,\n PropertyFilterOption,\n PropertyFilterProperty,\n PropertyFilterToken,\n} from '@cloudscape-design/collection-hooks';\n\nexport interface PropertyFilterProps extends BaseComponentProps, ExpandToViewport {\n /**\n * If set to `true`, the filtering input will be disabled.\n * Use it, for example, if you are fetching new items upon filtering change\n * in order to prevent the user from changing the filtering query.\n */\n disabled?: boolean;\n /**\n * An object containing all the necessary localized strings required by the component.\n */\n i18nStrings: PropertyFilterProps.I18nStrings;\n /**\n * Accepts a human-readable, localized string that indicates the number of results. For example, \"1 match\" or \"165 matches.\"\n * If the total number of results is unknown, also include an indication that there may be more results than\n * the number listed. For example, \"25+ matches.\"\n *\n * The count text is only displayed when `query.tokens` isn't empty.\n */\n countText?: string;\n /**\n * An object representing the current query displayed in the property filter. Has two properties: `tokens` and `operation`.\n * `tokens` is an array of objects that will be displayed to the user beneath the filtering input.\n * Each token has the following properties:\n *\n * * value [string]: The string value of the token to be used as a filter.\n * * propertyKey [string]: The key of the corresponding property in filteringProperties.\n * * operator ['<' | '<=' | '>' | '>=' | ':' | '!:' | '=' | '!=']: The operator which indicates how to filter the dataset using this token.\n *\n * `operation` has two valid values [and, or] and controls the join operation to be applied between tokens when filtering the items.\n */\n query: PropertyFilterProps.Query;\n /**\n * If hideOperations it set, the indicator of the operation (that is, `and` or `or`) and the selection of operations\n * (applied to the property and value token) are hidden from the user. Only use when you have a custom\n * filtering logic which combines tokens in different way than the default one. When used, ensure that\n * operations are communicated to the user in another way.\n */\n hideOperations?: boolean;\n /**\n * Fired when the `query` gets changed. Filter the dataset in response to this event using the values in the `detail` object.\n */\n onChange: NonCancelableEventHandler<PropertyFilterProps.Query>;\n /**\n * An array of properties by which the data set can be filtered. Each element has the following properties:\n *\n * * groupValuesLabel [string]: Localized string to display for the 'Values' group label for a specific property.\n * * key [string]: The identifier of this property.\n * * propertyLabel [string]: A human-readable string for the property.\n * * operators [Array]: A list of all operators supported by this property. If you omit the equals operator because your API does not support it, make sure to set `defaultOperator` to a supported operator from this list.\n * * group [string]: Optional identifier of a custom group that this filtering option is assigned to. Use to create additional groups below the default one. Make sure to also define labels for the group in the customGroupsText property. Notice that only one level of options nesting is supported.\n * * defaultOperator [ComparisonOperator]: Optional parameter that changes the default operator used with this filtering property. Use it only if your API does not support \"equals\" filtering terms with this property.\n */\n filteringProperties: ReadonlyArray<PropertyFilterProps.FilteringProperty>;\n /**\n * An array of possible values of the individual `filteringProperties`. Each element has the following properties:\n *\n * * `propertyKey` [string]: The key of the corresponding filtering property in the `filteringProperties` array.\n * * `value` [string]: The value that will be used as a suggestion when creating or modifying a filtering token.\n * * `label` [string]: Optional suggestion label to be matched instead of the value.\n *\n * Filtering options that require labels can only use `=` and `!=` operators. The token value must be labelled separately, for example:\n * ```\n * const filteringProperty = {\n * key: 'state',\n * propertyLabel: 'State',\n * operators: ['=', '!='].map(operator => ({ operator, format: getStateLabel }))\n * }\n * const filteringOptions = [\n * { propertyKey: 'state', value: 'STOPPED', label: getStateLabel('STOPPED') },\n * { propertyKey: 'state', value: 'STOPPING', label: getStateLabel('STOPPING') },\n * { propertyKey: 'state', value: 'RUNNING', label: getStateLabel('RUNNING') },\n * ]\n * ```\n */\n filteringOptions?: ReadonlyArray<PropertyFilterProps.FilteringOption>;\n /**\n * An array of objects that contain localized, human-readable strings for the labels of custom groups within the filtering dropdown. Use group property to associate the strings with your custom group of options. Define the following values for each group:\n *\n * * properties [string]: The group label in the filtering dropdown that contains the list of properties from this group. For example: Tags.\n * * values [string]: The group label in the filtering dropdown that contains the list of values from this group. For example: Tags values.\n * * group [string]: The identifier of a custom group.\n */\n customGroupsText?: PropertyFilterProps.GroupText[];\n /**\n * Set `disableFreeTextFiltering` only if you can’t filter the dataset using a filter that is applied to every column,\n * instead of a specific property. This would stop the user from creating such tokens.\n */\n disableFreeTextFiltering?: boolean;\n /**\n * Use this event to asynchronously load filteringOptions, component currently needs. The detail object contains following properties:\n *\n * * `filteringProperty` - The property for which you need to fetch the options.\n * * `filteringOperator` - The operator for which you need to fetch the options.\n * * `filteringText` - The value that you need to use to fetch options.\n * * `firstPage` - Indicates that you should fetch the first page of options for a `filteringProperty` that match the `filteringText`.\n * * `samePage` - Indicates that you should fetch the same page that you have previously fetched (for example, when the user clicks on the recovery button).\n */\n onLoadItems?: NonCancelableEventHandler<PropertyFilterProps.LoadItemsDetail>;\n /**\n * If you have more than 500 `filteringOptions`, enable this flag to apply a performance optimization that makes\n * the filtering experience smoother. We don't recommend enabling the feature if you have less than 500 options,\n * because the improvements to performance are offset by a visible scrolling lag. When you set this flag to true,\n * it removes options that are not currently in view from the DOM.\n */\n virtualScroll?: boolean;\n /**\n * A slot located before the filtering input. Use it if for a Select component if your dataset supports property\n * filter queries only after an initial filter is applied.\n */\n customControl?: React.ReactNode;\n /**\n * Set `asyncProperties` if you need to load `filteringProperties` asynchronousely. This would cause extra `onLoadMore`\n * events to fire calling for more properties.\n */\n asyncProperties?: boolean;\n /**\n * Specifies the maximum number of displayed tokens. If the property isn't set, all of the tokens are displayed.\n */\n tokenLimit?: number;\n /**\n * Displayed when there are no options to display.\n * This is only shown when `statusType` is set to `finished` or not set at all.\n */\n filteringEmpty?: React.ReactNode;\n /**\n * Specifies the text to display when in the loading state.\n **/\n filteringLoadingText?: string;\n /**\n * Specifies the text to display at the bottom of the dropdown menu after pagination has reached the end.\n **/\n filteringFinishedText?: string;\n /**\n * Specifies the text to display when a data fetching error occurs. Make sure that you provide `recoveryText`.\n **/\n filteringErrorText?: string;\n /**\n * Specifies the text for the recovery button. The text is displayed next to the error text.\n * Use the `onLoadItems` event to perform a recovery action (for example, retrying the request).\n **/\n filteringRecoveryText?: string;\n /**\n * Specifies the current status of loading more options.\n * * `pending` - Indicates that no request in progress, but more options may be loaded.\n * * `loading` - Indicates that data fetching is in progress.\n * * `finished` - Indicates that pagination has finished and no more requests are expected.\n * * `error` - Indicates that an error occurred during fetch. You should use `recoveryText` to enable the user to recover.\n **/\n filteringStatusType?: DropdownStatusProps.StatusType;\n}\n\nexport namespace PropertyFilterProps {\n export type Token = PropertyFilterToken;\n export type JoinOperation = PropertyFilterOperation;\n export type ComparisonOperator = PropertyFilterOperator;\n export type ExtendedOperator<TokenValue> = PropertyFilterOperatorExtended<TokenValue>;\n export type ExtendedOperatorFormProps<TokenValue> = PropertyFilterOperatorFormProps<TokenValue>;\n export type ExtendedOperatorForm<TokenValue> = PropertyFilterOperatorForm<TokenValue>;\n export type ExtendedOperatorFormat<TokenValue> = PropertyFilterOperatorFormat<TokenValue>;\n export type FilteringOption = PropertyFilterOption;\n export type FilteringProperty = PropertyFilterProperty;\n\n export interface Query {\n tokens: ReadonlyArray<PropertyFilterProps.Token>;\n operation: PropertyFilterProps.JoinOperation;\n }\n\n export interface LoadItemsDetail {\n filteringProperty?: FilteringProperty;\n filteringOperator?: ComparisonOperator;\n filteringText: string;\n firstPage: boolean;\n samePage: boolean;\n }\n\n export interface I18nStrings {\n /**\n * Label that will be passed down to the Autosuggest `ariaLabel` property.\n * See the [Autosuggest API](/system/components/autosuggest/?tabId=api) page for more details.\n */\n filteringAriaLabel: string;\n dismissAriaLabel: string;\n\n filteringPlaceholder?: string;\n groupValuesText: string;\n groupPropertiesText: string;\n operatorsText: string;\n\n operationAndText: string;\n operationOrText: string;\n\n operatorLessText: string;\n operatorLessOrEqualText: string;\n operatorGreaterText: string;\n operatorGreaterOrEqualText: string;\n operatorContainsText: string;\n operatorDoesNotContainText: string;\n operatorEqualsText: string;\n operatorDoesNotEqualText: string;\n\n editTokenHeader: string;\n propertyText: string;\n operatorText: string;\n valueText: string;\n cancelActionText: string;\n applyActionText: string;\n allPropertiesLabel: string;\n\n tokenLimitShowMore?: string;\n tokenLimitShowFewer?: string;\n clearFiltersText: string;\n tokenOperatorAriaLabel?: string;\n removeTokenButtonAriaLabel: (token: PropertyFilterProps.Token) => string;\n enteredTextLabel: AutosuggestProps.EnteredTextLabel;\n }\n\n export interface GroupText {\n properties: string;\n values: string;\n group: string;\n }\n\n export interface FilteringChangeDetail {\n filteringText: string;\n filteringProperty?: FilteringProperty;\n }\n\n export interface Ref {\n /**\n * Sets focus on the underlying input control.\n */\n focus(): void;\n }\n}\n\n// Re-exported namespace interfaces to use module-style imports internally\n\nexport type Token = PropertyFilterProps.Token;\nexport type JoinOperation = PropertyFilterProps.JoinOperation;\nexport type ComparisonOperator = PropertyFilterProps.ComparisonOperator;\nexport type ExtendedOperator<TokenValue> = PropertyFilterOperatorExtended<TokenValue>;\nexport type ExtendedOperatorFormProps<TokenValue> = PropertyFilterOperatorFormProps<TokenValue>;\nexport type ExtendedOperatorForm<TokenValue> = PropertyFilterOperatorForm<TokenValue>;\nexport type ExtendedOperatorFormat<TokenValue> = PropertyFilterOperatorFormat<TokenValue>;\nexport type FilteringOption = PropertyFilterProps.FilteringOption;\nexport type FilteringProperty = PropertyFilterProps.FilteringProperty;\nexport type Query = PropertyFilterProps.Query;\nexport type LoadItemsDetail = PropertyFilterProps.LoadItemsDetail;\nexport type I18nStrings = PropertyFilterProps.I18nStrings;\nexport type GroupText = PropertyFilterProps.GroupText;\nexport type FilteringChangeDetail = PropertyFilterProps.FilteringChangeDetail;\nexport type Ref = PropertyFilterProps.Ref;\n\n// Utility types\n\nexport type ParsedText =\n | { step: 'property'; property: FilteringProperty; operator: ComparisonOperator; value: string }\n | { step: 'operator'; property: FilteringProperty; operatorPrefix: string }\n | { step: 'free-text'; operator?: ComparisonOperator; value: string };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token-editor.d.ts","sourceRoot":"","sources":["../../../src/property-filter/token-editor.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAMhD,OAAO,EAEL,eAAe,EACf,iBAAiB,EACjB,SAAS,EACT,WAAW,EACX,eAAe,EACf,KAAK,EACN,MAAM,cAAc,CAAC;AAYtB,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mDAAmD,CAAC;
|
|
1
|
+
{"version":3,"file":"token-editor.d.ts","sourceRoot":"","sources":["../../../src/property-filter/token-editor.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAMhD,OAAO,EAEL,eAAe,EACf,iBAAiB,EACjB,SAAS,EACT,WAAW,EACX,eAAe,EACf,KAAK,EACN,MAAM,cAAc,CAAC;AAYtB,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mDAAmD,CAAC;AAwKxF,UAAU,gBAAgB;IACxB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,UAAU,EAAE,mBAAmB,CAAC;IAChC,gBAAgB,EAAE,SAAS,SAAS,EAAE,CAAC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,gBAAgB,EAAE,SAAS,eAAe,EAAE,CAAC;IAC7C,mBAAmB,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAClD,WAAW,EAAE,WAAW,CAAC;IACzB,WAAW,CAAC,EAAE,yBAAyB,CAAC,eAAe,CAAC,CAAC;IACzD,QAAQ,EAAE,CAAC,QAAQ,EAAE,KAAK,KAAK,IAAI,CAAC;IACpC,KAAK,EAAE,KAAK,CAAC;IACb,gBAAgB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACpC;AAED,wBAAgB,WAAW,CAAC,EAC1B,eAAe,EACf,UAAU,EACV,gBAAgB,EAChB,wBAAwB,EACxB,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,WAAW,EACX,WAAW,EACX,QAAQ,EACR,KAAK,EACL,gBAAgB,GACjB,EAAE,gBAAgB,eAuGlB"}
|
|
@@ -10,6 +10,7 @@ import { useLoadItems } from './use-load-items';
|
|
|
10
10
|
import { createPropertiesCompatibilityMap, getAllowedOperators, getPropertyOptions, getPropertyByKey, operatorToDescription, getPropertySuggestions, getExtendedOperator, } from './controller';
|
|
11
11
|
import InternalButton from '../button/internal';
|
|
12
12
|
import InternalFormField from '../form-field/internal';
|
|
13
|
+
import { matchTokenValue } from './utils';
|
|
13
14
|
var freeTextOperators = [':', '!:'];
|
|
14
15
|
function PropertyInput(_a) {
|
|
15
16
|
var propertyKey = _a.propertyKey, onChangePropertyKey = _a.onChangePropertyKey, asyncProps = _a.asyncProps, filteringProperties = _a.filteringProperties, onLoadItems = _a.onLoadItems, customGroupsText = _a.customGroupsText, i18nStrings = _a.i18nStrings, disableFreeTextFiltering = _a.disableFreeTextFiltering;
|
|
@@ -67,18 +68,21 @@ function OperatorInput(_a) {
|
|
|
67
68
|
: null, onChange: function (e) { return onChangeOperator(e.detail.selectedOption.value); } }));
|
|
68
69
|
}
|
|
69
70
|
function ValueInput(_a) {
|
|
70
|
-
var _b;
|
|
71
|
+
var _b, _c, _d;
|
|
71
72
|
var propertyKey = _a.propertyKey, operator = _a.operator, value = _a.value, onChangeValue = _a.onChangeValue, asyncProps = _a.asyncProps, filteringProperties = _a.filteringProperties, filteringOptions = _a.filteringOptions, onLoadItems = _a.onLoadItems, i18nStrings = _a.i18nStrings;
|
|
72
73
|
var property = propertyKey !== undefined ? getPropertyByKey(filteringProperties, propertyKey) : undefined;
|
|
73
|
-
var valueOptions = property
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
var valueOptions = property
|
|
75
|
+
? getPropertyOptions(property, filteringOptions).map(function (_a) {
|
|
76
|
+
var label = _a.label, value = _a.value;
|
|
77
|
+
return ({ label: label, value: value });
|
|
78
|
+
})
|
|
79
|
+
: [];
|
|
77
80
|
var valueAutosuggestHandlers = useLoadItems(onLoadItems, '', property);
|
|
78
81
|
var asyncValueAutosuggesProps = propertyKey
|
|
79
82
|
? __assign(__assign({}, valueAutosuggestHandlers), asyncProps) : { empty: asyncProps.empty };
|
|
83
|
+
var mathedOption = valueOptions.filter(function (option) { return option.value === value; })[0];
|
|
80
84
|
var OperatorForm = propertyKey && operator && ((_b = getExtendedOperator(filteringProperties, propertyKey, operator)) === null || _b === void 0 ? void 0 : _b.form);
|
|
81
|
-
return OperatorForm ? (React.createElement(OperatorForm, { value: value, onChange: onChangeValue, operator: operator })) : (React.createElement(InternalAutosuggest, __assign({ enteredTextLabel: i18nStrings.enteredTextLabel, value:
|
|
85
|
+
return OperatorForm ? (React.createElement(OperatorForm, { value: value, onChange: onChangeValue, operator: operator })) : (React.createElement(InternalAutosuggest, __assign({ enteredTextLabel: i18nStrings.enteredTextLabel, value: (_d = (_c = mathedOption === null || mathedOption === void 0 ? void 0 : mathedOption.label) !== null && _c !== void 0 ? _c : value) !== null && _d !== void 0 ? _d : '', onChange: function (e) { return onChangeValue(e.detail.value); }, disabled: !operator, options: valueOptions }, asyncValueAutosuggesProps, { virtualScroll: true })));
|
|
82
86
|
}
|
|
83
87
|
export function TokenEditor(_a) {
|
|
84
88
|
var asyncProperties = _a.asyncProperties, asyncProps = _a.asyncProps, customGroupsText = _a.customGroupsText, disableFreeTextFiltering = _a.disableFreeTextFiltering, expandToViewport = _a.expandToViewport, filteringOptions = _a.filteringOptions, filteringProperties = _a.filteringProperties, i18nStrings = _a.i18nStrings, onLoadItems = _a.onLoadItems, setToken = _a.setToken, token = _a.token, triggerComponent = _a.triggerComponent;
|
|
@@ -115,7 +119,7 @@ export function TokenEditor(_a) {
|
|
|
115
119
|
React.createElement("div", { className: styles['token-editor-actions'] },
|
|
116
120
|
React.createElement(InternalButton, { variant: "link", className: styles['token-editor-cancel'], onClick: closePopover }, i18nStrings.cancelActionText),
|
|
117
121
|
React.createElement(InternalButton, { className: styles['token-editor-submit'], onClick: function () {
|
|
118
|
-
setToken(temporaryToken);
|
|
122
|
+
setToken(matchTokenValue(temporaryToken, filteringOptions));
|
|
119
123
|
closePopover();
|
|
120
124
|
} }, i18nStrings.applyActionText))) }, triggerComponent));
|
|
121
125
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token-editor.js","sourceRoot":"","sources":["../../../src/property-filter/token-editor.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAGhD,OAAO,cAAc,MAAM,oBAAoB,CAAC;AAChD,OAAO,mBAAmB,MAAM,yBAAyB,CAAC;AAC1D,OAAO,eAAuC,MAAM,qBAAqB,CAAC;AAU1E,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EACL,gCAAgC,EAChC,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AAGtB,OAAO,cAAc,MAAM,oBAAoB,CAAC;AAChD,OAAO,iBAAiB,MAAM,wBAAwB,CAAC;AAEvD,IAAM,iBAAiB,GAAyB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AAa5D,SAAS,aAAa,CAAC,EASF;QARnB,WAAW,iBAAA,EACX,mBAAmB,yBAAA,EACnB,UAAU,gBAAA,EACV,mBAAmB,yBAAA,EACnB,WAAW,iBAAA,EACX,gBAAgB,sBAAA,EAChB,WAAW,iBAAA,EACX,wBAAwB,8BAAA;IAExB,IAAM,QAAQ,GAAG,WAAW,KAAK,SA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AO,EAAE;wBACP,QAAQ,CAAC,cAAc,CAAC,CAAC;wBACzB,YAAY,EAAE,CAAC;oBACjB,CAAC,IAEA,WAAW,CAAC,eAAe,CACb,CACb,CACF,IAGP,gBAAgB,CACD,CACnB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useState, useRef } from 'react';\n\nimport { SelectProps } from '../select/interfaces';\nimport InternalSelect from '../select/internal';\nimport InternalAutosuggest from '../autosuggest/internal';\nimport InternalPopover, { InternalPopoverRef } from '../popover/internal';\nimport {\n ComparisonOperator,\n FilteringOption,\n FilteringProperty,\n GroupText,\n I18nStrings,\n LoadItemsDetail,\n Token,\n} from './interfaces';\nimport styles from './styles.css.js';\nimport { useLoadItems } from './use-load-items';\nimport {\n createPropertiesCompatibilityMap,\n getAllowedOperators,\n getPropertyOptions,\n getPropertyByKey,\n operatorToDescription,\n getPropertySuggestions,\n getExtendedOperator,\n} from './controller';\nimport { NonCancelableEventHandler } from '../internal/events';\nimport { DropdownStatusProps } from '../internal/components/dropdown-status/interfaces';\nimport InternalButton from '../button/internal';\nimport InternalFormField from '../form-field/internal';\n\nconst freeTextOperators: ComparisonOperator[] = [':', '!:'];\n\ninterface PropertyInputProps {\n asyncProps: null | DropdownStatusProps;\n customGroupsText: readonly GroupText[];\n disableFreeTextFiltering?: boolean;\n filteringProperties: readonly FilteringProperty[];\n i18nStrings: I18nStrings;\n onChangePropertyKey: (propertyKey: undefined | string) => void;\n onLoadItems?: NonCancelableEventHandler<LoadItemsDetail>;\n propertyKey: undefined | string;\n}\n\nfunction PropertyInput({\n propertyKey,\n onChangePropertyKey,\n asyncProps,\n filteringProperties,\n onLoadItems,\n customGroupsText,\n i18nStrings,\n disableFreeTextFiltering,\n}: PropertyInputProps) {\n const property = propertyKey !== undefined ? getPropertyByKey(filteringProperties, propertyKey) : undefined;\n const propertySelectHandlers = useLoadItems(onLoadItems);\n const asyncPropertySelectProps = asyncProps ? { ...asyncProps, ...propertySelectHandlers } : {};\n const propertyOptions: (SelectProps.Option | SelectProps.OptionGroup)[] = getPropertySuggestions(\n filteringProperties,\n customGroupsText,\n i18nStrings,\n ({ propertyLabel, key }) => ({\n value: key,\n label: propertyLabel,\n dontCloseOnSelect: true,\n })\n );\n\n // Disallow selecting properties that have different representation.\n const checkPropertiesCompatible = createPropertiesCompatibilityMap(filteringProperties);\n propertyOptions.forEach(optionGroup => {\n if ('options' in optionGroup) {\n optionGroup.options.forEach(option => {\n if (propertyKey && option.value) {\n option.disabled = !checkPropertiesCompatible(option.value, propertyKey);\n }\n });\n }\n });\n\n const allPropertiesOption = {\n label: i18nStrings.allPropertiesLabel,\n value: undefined,\n };\n if (!disableFreeTextFiltering) {\n propertyOptions.unshift(allPropertiesOption);\n }\n return (\n <InternalSelect\n options={propertyOptions}\n selectedOption={\n property\n ? {\n value: propertyKey ?? undefined,\n label: property.propertyLabel,\n }\n : allPropertiesOption\n }\n onChange={e => onChangePropertyKey(e.detail.selectedOption.value)}\n {...asyncPropertySelectProps}\n />\n );\n}\n\ninterface OperatorInputProps {\n filteringProperties: readonly FilteringProperty[];\n i18nStrings: I18nStrings;\n onChangeOperator: (operator: ComparisonOperator) => void;\n operator: undefined | ComparisonOperator;\n propertyKey: undefined | string;\n}\n\nfunction OperatorInput({\n propertyKey,\n operator,\n onChangeOperator,\n filteringProperties,\n i18nStrings,\n}: OperatorInputProps) {\n const property = propertyKey !== undefined ? getPropertyByKey(filteringProperties, propertyKey) : undefined;\n const freeTextOperators: ComparisonOperator[] = [':', '!:'];\n const operatorOptions = (property ? getAllowedOperators(property) : freeTextOperators).map(operator => ({\n value: operator,\n label: operator,\n description: operatorToDescription(operator, i18nStrings),\n }));\n return (\n <InternalSelect\n options={operatorOptions}\n triggerVariant=\"option\"\n selectedOption={\n operator\n ? {\n value: operator,\n label: operator,\n description: operatorToDescription(operator, i18nStrings),\n }\n : null\n }\n onChange={e => onChangeOperator(e.detail.selectedOption.value as ComparisonOperator)}\n />\n );\n}\n\ninterface ValueInputProps {\n asyncProps: DropdownStatusProps;\n filteringOptions: readonly FilteringOption[];\n filteringProperties: readonly FilteringProperty[];\n i18nStrings: I18nStrings;\n onChangeValue: (value: string) => void;\n onLoadItems?: NonCancelableEventHandler<LoadItemsDetail>;\n operator: undefined | ComparisonOperator;\n propertyKey: undefined | string;\n value: undefined | string;\n}\n\nfunction ValueInput({\n propertyKey,\n operator,\n value,\n onChangeValue,\n asyncProps,\n filteringProperties,\n filteringOptions,\n onLoadItems,\n i18nStrings,\n}: ValueInputProps) {\n const property = propertyKey !== undefined ? getPropertyByKey(filteringProperties, propertyKey) : undefined;\n const valueOptions = property ? getPropertyOptions(property, filteringOptions).map(({ value }) => ({ value })) : [];\n const valueAutosuggestHandlers = useLoadItems(onLoadItems, '', property);\n const asyncValueAutosuggesProps = propertyKey\n ? { ...valueAutosuggestHandlers, ...asyncProps }\n : { empty: asyncProps.empty };\n\n const OperatorForm = propertyKey && operator && getExtendedOperator(filteringProperties, propertyKey, operator)?.form;\n\n return OperatorForm ? (\n <OperatorForm value={value} onChange={onChangeValue} operator={operator} />\n ) : (\n <InternalAutosuggest\n enteredTextLabel={i18nStrings.enteredTextLabel}\n value={value ?? ''}\n onChange={e => onChangeValue(e.detail.value)}\n disabled={!operator}\n options={valueOptions}\n {...asyncValueAutosuggesProps}\n virtualScroll={true}\n />\n );\n}\n\ninterface TokenEditorProps {\n asyncProperties?: boolean;\n asyncProps: DropdownStatusProps;\n customGroupsText: readonly GroupText[];\n disabled?: boolean;\n disableFreeTextFiltering?: boolean;\n expandToViewport?: boolean;\n filteringOptions: readonly FilteringOption[];\n filteringProperties: readonly FilteringProperty[];\n i18nStrings: I18nStrings;\n onLoadItems?: NonCancelableEventHandler<LoadItemsDetail>;\n setToken: (newToken: Token) => void;\n token: Token;\n triggerComponent?: React.ReactNode;\n}\n\nexport function TokenEditor({\n asyncProperties,\n asyncProps,\n customGroupsText,\n disableFreeTextFiltering,\n expandToViewport,\n filteringOptions,\n filteringProperties,\n i18nStrings,\n onLoadItems,\n setToken,\n token,\n triggerComponent,\n}: TokenEditorProps) {\n const [temporaryToken, setTemporaryToken] = useState<Token>(token);\n const popoverRef = useRef<InternalPopoverRef>(null);\n const closePopover = () => {\n popoverRef.current && popoverRef.current.dismissPopover();\n };\n\n const propertyKey = temporaryToken.propertyKey;\n const onChangePropertyKey = (newPropertyKey: undefined | string) => {\n const filteringProperty = filteringProperties.reduce<FilteringProperty | undefined>(\n (acc, property) => (property.key === newPropertyKey ? property : acc),\n undefined\n );\n const allowedOperators = filteringProperty ? getAllowedOperators(filteringProperty) : freeTextOperators;\n const operator =\n temporaryToken.operator && allowedOperators.indexOf(temporaryToken.operator) !== -1\n ? temporaryToken.operator\n : allowedOperators[0];\n setTemporaryToken({ ...temporaryToken, propertyKey: newPropertyKey, operator });\n };\n\n const operator = temporaryToken.operator;\n const onChangeOperator = (newOperator: ComparisonOperator) => {\n setTemporaryToken({ ...temporaryToken, operator: newOperator });\n };\n\n const value = temporaryToken.value;\n const onChangeValue = (newValue: string) => {\n setTemporaryToken({ ...temporaryToken, value: newValue });\n };\n\n return (\n <InternalPopover\n ref={popoverRef}\n className={styles['token-label']}\n triggerType=\"text\"\n header={i18nStrings.editTokenHeader}\n size=\"large\"\n position=\"right\"\n dismissAriaLabel={i18nStrings.dismissAriaLabel}\n __onOpen={() => setTemporaryToken(token)}\n renderWithPortal={expandToViewport}\n content={\n <div className={styles['token-editor']}>\n <div className={styles['token-editor-form']}>\n <InternalFormField label={i18nStrings.propertyText} className={styles['token-editor-field-property']}>\n <PropertyInput\n propertyKey={propertyKey}\n onChangePropertyKey={onChangePropertyKey}\n asyncProps={asyncProperties ? asyncProps : null}\n filteringProperties={filteringProperties}\n onLoadItems={onLoadItems}\n customGroupsText={customGroupsText}\n i18nStrings={i18nStrings}\n disableFreeTextFiltering={disableFreeTextFiltering}\n />\n </InternalFormField>\n\n <InternalFormField label={i18nStrings.operatorText} className={styles['token-editor-field-operator']}>\n <OperatorInput\n propertyKey={propertyKey}\n operator={operator}\n onChangeOperator={onChangeOperator}\n filteringProperties={filteringProperties}\n i18nStrings={i18nStrings}\n />\n </InternalFormField>\n\n <InternalFormField label={i18nStrings.valueText} className={styles['token-editor-field-value']}>\n <ValueInput\n propertyKey={propertyKey}\n operator={operator}\n value={value}\n onChangeValue={onChangeValue}\n asyncProps={asyncProps}\n filteringProperties={filteringProperties}\n filteringOptions={filteringOptions}\n onLoadItems={onLoadItems}\n i18nStrings={i18nStrings}\n />\n </InternalFormField>\n </div>\n\n <div className={styles['token-editor-actions']}>\n <InternalButton variant=\"link\" className={styles['token-editor-cancel']} onClick={closePopover}>\n {i18nStrings.cancelActionText}\n </InternalButton>\n <InternalButton\n className={styles['token-editor-submit']}\n onClick={() => {\n setToken(temporaryToken);\n closePopover();\n }}\n >\n {i18nStrings.applyActionText}\n </InternalButton>\n </div>\n </div>\n }\n >\n {triggerComponent}\n </InternalPopover>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"token-editor.js","sourceRoot":"","sources":["../../../src/property-filter/token-editor.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAGhD,OAAO,cAAc,MAAM,oBAAoB,CAAC;AAChD,OAAO,mBAAmB,MAAM,yBAAyB,CAAC;AAC1D,OAAO,eAAuC,MAAM,qBAAqB,CAAC;AAU1E,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EACL,gCAAgC,EAChC,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AAGtB,OAAO,cAAc,MAAM,oBAAoB,CAAC;AAChD,OAAO,iBAA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AS,EAAE,SAAS,EAAE,MAAM,CAAC,0BAA0B,CAAC;oBAC5F,oBAAC,UAAU,IACT,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,aAAa,EAC5B,UAAU,EAAE,UAAU,EACtB,mBAAmB,EAAE,mBAAmB,EACxC,gBAAgB,EAAE,gBAAgB,EAClC,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,WAAW,GACxB,CACgB,CAChB;YAEN,6BAAK,SAAS,EAAE,MAAM,CAAC,sBAAsB,CAAC;gBAC5C,oBAAC,cAAc,IAAC,OAAO,EAAC,MAAM,EAAC,SAAS,EAAE,MAAM,CAAC,qBAAqB,CAAC,EAAE,OAAO,EAAE,YAAY,IAC3F,WAAW,CAAC,gBAAgB,CACd;gBACjB,oBAAC,cAAc,IACb,SAAS,EAAE,MAAM,CAAC,qBAAqB,CAAC,EACxC,OAAO,EAAE;wBACP,QAAQ,CAAC,eAAe,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC,CAAC;wBAC5D,YAAY,EAAE,CAAC;oBACjB,CAAC,IAEA,WAAW,CAAC,eAAe,CACb,CACb,CACF,IAGP,gBAAgB,CACD,CACnB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useState, useRef } from 'react';\n\nimport { SelectProps } from '../select/interfaces';\nimport InternalSelect from '../select/internal';\nimport InternalAutosuggest from '../autosuggest/internal';\nimport InternalPopover, { InternalPopoverRef } from '../popover/internal';\nimport {\n ComparisonOperator,\n FilteringOption,\n FilteringProperty,\n GroupText,\n I18nStrings,\n LoadItemsDetail,\n Token,\n} from './interfaces';\nimport styles from './styles.css.js';\nimport { useLoadItems } from './use-load-items';\nimport {\n createPropertiesCompatibilityMap,\n getAllowedOperators,\n getPropertyOptions,\n getPropertyByKey,\n operatorToDescription,\n getPropertySuggestions,\n getExtendedOperator,\n} from './controller';\nimport { NonCancelableEventHandler } from '../internal/events';\nimport { DropdownStatusProps } from '../internal/components/dropdown-status/interfaces';\nimport InternalButton from '../button/internal';\nimport InternalFormField from '../form-field/internal';\nimport { matchTokenValue } from './utils';\n\nconst freeTextOperators: ComparisonOperator[] = [':', '!:'];\n\ninterface PropertyInputProps {\n asyncProps: null | DropdownStatusProps;\n customGroupsText: readonly GroupText[];\n disableFreeTextFiltering?: boolean;\n filteringProperties: readonly FilteringProperty[];\n i18nStrings: I18nStrings;\n onChangePropertyKey: (propertyKey: undefined | string) => void;\n onLoadItems?: NonCancelableEventHandler<LoadItemsDetail>;\n propertyKey: undefined | string;\n}\n\nfunction PropertyInput({\n propertyKey,\n onChangePropertyKey,\n asyncProps,\n filteringProperties,\n onLoadItems,\n customGroupsText,\n i18nStrings,\n disableFreeTextFiltering,\n}: PropertyInputProps) {\n const property = propertyKey !== undefined ? getPropertyByKey(filteringProperties, propertyKey) : undefined;\n const propertySelectHandlers = useLoadItems(onLoadItems);\n const asyncPropertySelectProps = asyncProps ? { ...asyncProps, ...propertySelectHandlers } : {};\n const propertyOptions: (SelectProps.Option | SelectProps.OptionGroup)[] = getPropertySuggestions(\n filteringProperties,\n customGroupsText,\n i18nStrings,\n ({ propertyLabel, key }) => ({\n value: key,\n label: propertyLabel,\n dontCloseOnSelect: true,\n })\n );\n\n // Disallow selecting properties that have different representation.\n const checkPropertiesCompatible = createPropertiesCompatibilityMap(filteringProperties);\n propertyOptions.forEach(optionGroup => {\n if ('options' in optionGroup) {\n optionGroup.options.forEach(option => {\n if (propertyKey && option.value) {\n option.disabled = !checkPropertiesCompatible(option.value, propertyKey);\n }\n });\n }\n });\n\n const allPropertiesOption = {\n label: i18nStrings.allPropertiesLabel,\n value: undefined,\n };\n if (!disableFreeTextFiltering) {\n propertyOptions.unshift(allPropertiesOption);\n }\n return (\n <InternalSelect\n options={propertyOptions}\n selectedOption={\n property\n ? {\n value: propertyKey ?? undefined,\n label: property.propertyLabel,\n }\n : allPropertiesOption\n }\n onChange={e => onChangePropertyKey(e.detail.selectedOption.value)}\n {...asyncPropertySelectProps}\n />\n );\n}\n\ninterface OperatorInputProps {\n filteringProperties: readonly FilteringProperty[];\n i18nStrings: I18nStrings;\n onChangeOperator: (operator: ComparisonOperator) => void;\n operator: undefined | ComparisonOperator;\n propertyKey: undefined | string;\n}\n\nfunction OperatorInput({\n propertyKey,\n operator,\n onChangeOperator,\n filteringProperties,\n i18nStrings,\n}: OperatorInputProps) {\n const property = propertyKey !== undefined ? getPropertyByKey(filteringProperties, propertyKey) : undefined;\n const freeTextOperators: ComparisonOperator[] = [':', '!:'];\n const operatorOptions = (property ? getAllowedOperators(property) : freeTextOperators).map(operator => ({\n value: operator,\n label: operator,\n description: operatorToDescription(operator, i18nStrings),\n }));\n return (\n <InternalSelect\n options={operatorOptions}\n triggerVariant=\"option\"\n selectedOption={\n operator\n ? {\n value: operator,\n label: operator,\n description: operatorToDescription(operator, i18nStrings),\n }\n : null\n }\n onChange={e => onChangeOperator(e.detail.selectedOption.value as ComparisonOperator)}\n />\n );\n}\n\ninterface ValueInputProps {\n asyncProps: DropdownStatusProps;\n filteringOptions: readonly FilteringOption[];\n filteringProperties: readonly FilteringProperty[];\n i18nStrings: I18nStrings;\n onChangeValue: (value: string) => void;\n onLoadItems?: NonCancelableEventHandler<LoadItemsDetail>;\n operator: undefined | ComparisonOperator;\n propertyKey: undefined | string;\n value: undefined | string;\n}\n\nfunction ValueInput({\n propertyKey,\n operator,\n value,\n onChangeValue,\n asyncProps,\n filteringProperties,\n filteringOptions,\n onLoadItems,\n i18nStrings,\n}: ValueInputProps) {\n const property = propertyKey !== undefined ? getPropertyByKey(filteringProperties, propertyKey) : undefined;\n const valueOptions = property\n ? getPropertyOptions(property, filteringOptions).map(({ label, value }) => ({ label, value }))\n : [];\n const valueAutosuggestHandlers = useLoadItems(onLoadItems, '', property);\n const asyncValueAutosuggesProps = propertyKey\n ? { ...valueAutosuggestHandlers, ...asyncProps }\n : { empty: asyncProps.empty };\n const [mathedOption] = valueOptions.filter(option => option.value === value);\n\n const OperatorForm = propertyKey && operator && getExtendedOperator(filteringProperties, propertyKey, operator)?.form;\n\n return OperatorForm ? (\n <OperatorForm value={value} onChange={onChangeValue} operator={operator} />\n ) : (\n <InternalAutosuggest\n enteredTextLabel={i18nStrings.enteredTextLabel}\n value={mathedOption?.label ?? value ?? ''}\n onChange={e => onChangeValue(e.detail.value)}\n disabled={!operator}\n options={valueOptions}\n {...asyncValueAutosuggesProps}\n virtualScroll={true}\n />\n );\n}\n\ninterface TokenEditorProps {\n asyncProperties?: boolean;\n asyncProps: DropdownStatusProps;\n customGroupsText: readonly GroupText[];\n disabled?: boolean;\n disableFreeTextFiltering?: boolean;\n expandToViewport?: boolean;\n filteringOptions: readonly FilteringOption[];\n filteringProperties: readonly FilteringProperty[];\n i18nStrings: I18nStrings;\n onLoadItems?: NonCancelableEventHandler<LoadItemsDetail>;\n setToken: (newToken: Token) => void;\n token: Token;\n triggerComponent?: React.ReactNode;\n}\n\nexport function TokenEditor({\n asyncProperties,\n asyncProps,\n customGroupsText,\n disableFreeTextFiltering,\n expandToViewport,\n filteringOptions,\n filteringProperties,\n i18nStrings,\n onLoadItems,\n setToken,\n token,\n triggerComponent,\n}: TokenEditorProps) {\n const [temporaryToken, setTemporaryToken] = useState<Token>(token);\n const popoverRef = useRef<InternalPopoverRef>(null);\n const closePopover = () => {\n popoverRef.current && popoverRef.current.dismissPopover();\n };\n\n const propertyKey = temporaryToken.propertyKey;\n const onChangePropertyKey = (newPropertyKey: undefined | string) => {\n const filteringProperty = filteringProperties.reduce<FilteringProperty | undefined>(\n (acc, property) => (property.key === newPropertyKey ? property : acc),\n undefined\n );\n const allowedOperators = filteringProperty ? getAllowedOperators(filteringProperty) : freeTextOperators;\n const operator =\n temporaryToken.operator && allowedOperators.indexOf(temporaryToken.operator) !== -1\n ? temporaryToken.operator\n : allowedOperators[0];\n setTemporaryToken({ ...temporaryToken, propertyKey: newPropertyKey, operator });\n };\n\n const operator = temporaryToken.operator;\n const onChangeOperator = (newOperator: ComparisonOperator) => {\n setTemporaryToken({ ...temporaryToken, operator: newOperator });\n };\n\n const value = temporaryToken.value;\n const onChangeValue = (newValue: string) => {\n setTemporaryToken({ ...temporaryToken, value: newValue });\n };\n\n return (\n <InternalPopover\n ref={popoverRef}\n className={styles['token-label']}\n triggerType=\"text\"\n header={i18nStrings.editTokenHeader}\n size=\"large\"\n position=\"right\"\n dismissAriaLabel={i18nStrings.dismissAriaLabel}\n __onOpen={() => setTemporaryToken(token)}\n renderWithPortal={expandToViewport}\n content={\n <div className={styles['token-editor']}>\n <div className={styles['token-editor-form']}>\n <InternalFormField label={i18nStrings.propertyText} className={styles['token-editor-field-property']}>\n <PropertyInput\n propertyKey={propertyKey}\n onChangePropertyKey={onChangePropertyKey}\n asyncProps={asyncProperties ? asyncProps : null}\n filteringProperties={filteringProperties}\n onLoadItems={onLoadItems}\n customGroupsText={customGroupsText}\n i18nStrings={i18nStrings}\n disableFreeTextFiltering={disableFreeTextFiltering}\n />\n </InternalFormField>\n\n <InternalFormField label={i18nStrings.operatorText} className={styles['token-editor-field-operator']}>\n <OperatorInput\n propertyKey={propertyKey}\n operator={operator}\n onChangeOperator={onChangeOperator}\n filteringProperties={filteringProperties}\n i18nStrings={i18nStrings}\n />\n </InternalFormField>\n\n <InternalFormField label={i18nStrings.valueText} className={styles['token-editor-field-value']}>\n <ValueInput\n propertyKey={propertyKey}\n operator={operator}\n value={value}\n onChangeValue={onChangeValue}\n asyncProps={asyncProps}\n filteringProperties={filteringProperties}\n filteringOptions={filteringOptions}\n onLoadItems={onLoadItems}\n i18nStrings={i18nStrings}\n />\n </InternalFormField>\n </div>\n\n <div className={styles['token-editor-actions']}>\n <InternalButton variant=\"link\" className={styles['token-editor-cancel']} onClick={closePopover}>\n {i18nStrings.cancelActionText}\n </InternalButton>\n <InternalButton\n className={styles['token-editor-submit']}\n onClick={() => {\n setToken(matchTokenValue(temporaryToken, filteringOptions));\n closePopover();\n }}\n >\n {i18nStrings.applyActionText}\n </InternalButton>\n </div>\n </div>\n }\n >\n {triggerComponent}\n </InternalPopover>\n );\n}\n"]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { ComparisonOperator, FilteringProperty } from './interfaces';
|
|
1
|
+
import { ComparisonOperator, FilteringOption, FilteringProperty, Token } from './interfaces';
|
|
2
2
|
export declare function matchFilteringProperty(filteringProperties: readonly FilteringProperty[], filteringText: string): null | FilteringProperty;
|
|
3
3
|
export declare function matchOperator(allowedOperators: readonly ComparisonOperator[], filteringText: string): null | ComparisonOperator;
|
|
4
4
|
export declare function matchOperatorPrefix(allowedOperators: readonly ComparisonOperator[], filteringText: string): null | string;
|
|
5
|
+
export declare function matchTokenValue(token: Token, filteringOptions: readonly FilteringOption[]): Token;
|
|
5
6
|
export declare function trimStart(source: string): string;
|
|
6
7
|
export declare function trimFirstSpace(source: string): string;
|
|
7
8
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/property-filter/utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/property-filter/utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAG7F,wBAAgB,sBAAsB,CACpC,mBAAmB,EAAE,SAAS,iBAAiB,EAAE,EACjD,aAAa,EAAE,MAAM,GACpB,IAAI,GAAG,iBAAiB,CAc1B;AAGD,wBAAgB,aAAa,CAC3B,gBAAgB,EAAE,SAAS,kBAAkB,EAAE,EAC/C,aAAa,EAAE,MAAM,GACpB,IAAI,GAAG,kBAAkB,CAc3B;AAGD,wBAAgB,mBAAmB,CACjC,gBAAgB,EAAE,SAAS,kBAAkB,EAAE,EAC/C,aAAa,EAAE,MAAM,GACpB,IAAI,GAAG,MAAM,CAUf;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,EAAE,gBAAgB,EAAE,SAAS,eAAe,EAAE,GAAG,KAAK,CAYjG;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAUhD;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAErD"}
|
package/property-filter/utils.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { __assign } from "tslib";
|
|
3
4
|
// Finds the longest property the filtering text starts from.
|
|
4
5
|
export function matchFilteringProperty(filteringProperties, filteringText) {
|
|
5
6
|
filteringText = filteringText.toLowerCase();
|
|
@@ -41,6 +42,19 @@ export function matchOperatorPrefix(allowedOperators, filteringText) {
|
|
|
41
42
|
}
|
|
42
43
|
return null;
|
|
43
44
|
}
|
|
45
|
+
export function matchTokenValue(token, filteringOptions) {
|
|
46
|
+
var _a, _b;
|
|
47
|
+
var value = token.value.toLowerCase();
|
|
48
|
+
var propertyOptions = filteringOptions.filter(function (option) { return option.propertyKey === token.propertyKey; });
|
|
49
|
+
for (var _i = 0, propertyOptions_1 = propertyOptions; _i < propertyOptions_1.length; _i++) {
|
|
50
|
+
var option = propertyOptions_1[_i];
|
|
51
|
+
var optionText = ((_b = (_a = option.label) !== null && _a !== void 0 ? _a : option.value) !== null && _b !== void 0 ? _b : '').toLowerCase();
|
|
52
|
+
if (optionText === value) {
|
|
53
|
+
return __assign(__assign({}, token), { value: option.value });
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return token;
|
|
57
|
+
}
|
|
44
58
|
export function trimStart(source) {
|
|
45
59
|
var spacesLength = 0;
|
|
46
60
|
for (var i = 0; i < source.length; i++) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/property-filter/utils.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/property-filter/utils.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAItC,6DAA6D;AAC7D,MAAM,UAAU,sBAAsB,CACpC,mBAAiD,EACjD,aAAqB;IAErB,aAAa,GAAG,aAAa,CAAC,WAAW,EAAE,CAAC;IAE5C,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,IAAI,eAAe,GAA6B,IAAI,CAAC;IAErD,KAAuB,UAAmB,EAAnB,2CAAmB,EAAnB,iCAAmB,EAAnB,IAAmB,EAAE;QAAvC,IAAM,QAAQ,4BAAA;QACjB,IAAI,QAAQ,CAAC,aAAa,CAAC,MAAM,GAAG,SAAS,IAAI,UAAU,CAAC,aAAa,EAAE,QAAQ,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,EAAE;YAChH,SAAS,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC;YAC1C,eAAe,GAAG,QAAQ,CAAC;SAC5B;KACF;IAED,OAAO,eAAe,CAAC;AACzB,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,aAAa,CAC3B,gBAA+C,EAC/C,aAAqB;IAErB,aAAa,GAAG,aAAa,CAAC,WAAW,EAAE,CAAC;IAE5C,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,IAAI,eAAe,GAA8B,IAAI,CAAC;IAEtD,KAAuB,UAAgB,EAAhB,qCAAgB,EAAhB,8BAAgB,EAAhB,IAAgB,EAAE;QAApC,IAAM,QAAQ,yBAAA;QACjB,IAAI,QAAQ,CAAC,MAAM,GAAG,SAAS,IAAI,UAAU,CAAC,aAAa,EAAE,QAAQ,CAAC,WAAW,EAAE,CAAC,EAAE;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AAC;IACrB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACtC,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;YACrB,YAAY,EAAE,CAAC;SAChB;aAAM;YACL,MAAM;SACP;KACF;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,MAAc;IAC3C,OAAO,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;AACtD,CAAC;AAED,SAAS,UAAU,CAAC,MAAc,EAAE,MAAc;IAChD,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACtC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { ComparisonOperator, FilteringOption, FilteringProperty, Token } from './interfaces';\n\n// Finds the longest property the filtering text starts from.\nexport function matchFilteringProperty(\n filteringProperties: readonly FilteringProperty[],\n filteringText: string\n): null | FilteringProperty {\n filteringText = filteringText.toLowerCase();\n\n let maxLength = 0;\n let matchedProperty: null | FilteringProperty = null;\n\n for (const property of filteringProperties) {\n if (property.propertyLabel.length > maxLength && startsWith(filteringText, property.propertyLabel.toLowerCase())) {\n maxLength = property.propertyLabel.length;\n matchedProperty = property;\n }\n }\n\n return matchedProperty;\n}\n\n// Finds the longest operator the filtering text starts from.\nexport function matchOperator(\n allowedOperators: readonly ComparisonOperator[],\n filteringText: string\n): null | ComparisonOperator {\n filteringText = filteringText.toLowerCase();\n\n let maxLength = 0;\n let matchedOperator: null | ComparisonOperator = null;\n\n for (const operator of allowedOperators) {\n if (operator.length > maxLength && startsWith(filteringText, operator.toLowerCase())) {\n maxLength = operator.length;\n matchedOperator = operator;\n }\n }\n\n return matchedOperator;\n}\n\n// Finds if the filtering text matches any operator prefix.\nexport function matchOperatorPrefix(\n allowedOperators: readonly ComparisonOperator[],\n filteringText: string\n): null | string {\n if (filteringText.trim().length === 0) {\n return '';\n }\n for (const operator of allowedOperators) {\n if (startsWith(operator.toLowerCase(), filteringText.toLowerCase())) {\n return filteringText;\n }\n }\n return null;\n}\n\nexport function matchTokenValue(token: Token, filteringOptions: readonly FilteringOption[]): Token {\n const value = token.value.toLowerCase();\n\n const propertyOptions = filteringOptions.filter(option => option.propertyKey === token.propertyKey);\n for (const option of propertyOptions) {\n const optionText = (option.label ?? option.value ?? '').toLowerCase();\n if (optionText === value) {\n return { ...token, value: option.value };\n }\n }\n\n return token;\n}\n\nexport function trimStart(source: string): string {\n let spacesLength = 0;\n for (let i = 0; i < source.length; i++) {\n if (source[i] === ' ') {\n spacesLength++;\n } else {\n break;\n }\n }\n return source.slice(spacesLength);\n}\n\nexport function trimFirstSpace(source: string): string {\n return source[0] === ' ' ? source.slice(1) : source;\n}\n\nfunction startsWith(source: string, target: string): boolean {\n return source.indexOf(target) === 0;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-sticky-header.d.ts","sourceRoot":"","sources":["../../../src/table/use-sticky-header.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmB,SAAS,EAAe,MAAM,OAAO,CAAC;AAkBhE,eAAO,MAAM,eAAe,aAChB,UAAU,WAAW,CAAC,YACtB,UAAU,WAAW,CAAC,qBACb,UAAU,WAAW,CAAC,qBACtB,UAAU,WAAW,CAAC,mBACxB,UAAU,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"use-sticky-header.d.ts","sourceRoot":"","sources":["../../../src/table/use-sticky-header.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmB,SAAS,EAAe,MAAM,OAAO,CAAC;AAkBhE,eAAO,MAAM,eAAe,aAChB,UAAU,WAAW,CAAC,YACtB,UAAU,WAAW,CAAC,qBACb,UAAU,WAAW,CAAC,qBACtB,UAAU,WAAW,CAAC,mBACxB,UAAU,WAAW,CAAC;4BA6CR,WAAW,GAAG,IAAI;;CAMlD,CAAC"}
|
|
@@ -35,9 +35,6 @@ export var useStickyHeader = function (tableRef, theadRef, secondaryTheadRef, se
|
|
|
35
35
|
}, [theadRef, secondaryTheadRef, secondaryTableRef, tableWrapperRef, tableRef]);
|
|
36
36
|
useLayoutEffect(function () {
|
|
37
37
|
syncColumnHeaderWidths();
|
|
38
|
-
// Content is not going to be layed out until the next frame in angular,
|
|
39
|
-
// so we need to sync the column headers again.
|
|
40
|
-
setTimeout(function () { return syncColumnHeaderWidths(); }, 0);
|
|
41
38
|
var secondaryTable = secondaryTableRef.current;
|
|
42
39
|
var primaryTable = tableWrapperRef.current;
|
|
43
40
|
return function () {
|
|
@@ -48,7 +45,7 @@ export var useStickyHeader = function (tableRef, theadRef, secondaryTheadRef, se
|
|
|
48
45
|
primaryTable.style.marginTop = '';
|
|
49
46
|
}
|
|
50
47
|
};
|
|
51
|
-
});
|
|
48
|
+
}, [secondaryTableRef, tableWrapperRef, syncColumnHeaderWidths]);
|
|
52
49
|
useResizeObserver(theadRef, syncColumnHeaderWidths);
|
|
53
50
|
var scrollToTop = function () {
|
|
54
51
|
if (!isMobile && theadRef.current && secondaryTheadRef.current && tableWrapperRef.current) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-sticky-header.js","sourceRoot":"","sources":["../../../src/table/use-sticky-header.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,eAAe,EAAa,WAAW,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAC;AAC5F,OAAO,eAAe,EAAE,EAAE,wBAAwB,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC3F,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;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,QAAQ,EAAE,sBAAsB,CAAC,CAAC;IACpD,IAAM,WAAW,GAAG;QAClB,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,OAAO,IAAI,iBAAiB,CAAC,OAAO,IAAI,eAAe,CAAC,OAAO,EAAE;YACzF,IAAM,UAAU,GAAG,wBAAwB,CAAC,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC;YACzF,IAAI,UAAU,GAAG,CAAC,EAAE;gBAClB,UAAU,CAAC,UAAU,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC;aACjD;SACF;IACH,CAAC,CAAC;IACM,IAAA,YAAY,GAAK,eAAe,CAAC,eAAe,EAAE,iBAAiB,CAAC,aAAxD,CAAyD;IAC7E,IAAM,WAAW,GAAG,UAAC,QAA4B;QAC/C,IAAI,CAAC,QAAQ,EAAE;YACb,YAAY,CAAC,QAAQ,CAAC,CAAC;SACxB;IACH,CAAC,CAAC;IACF,OAAO,EAAE,WAAW,aAAA,EAAE,WAAW,aAAA,EAAE,CAAC;AACtC,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { useLayoutEffect, RefObject, useCallback } from 'react';\nimport { useResizeObserver } from '../internal/hooks/container-queries/use-resize-observer';\nimport stickyScrolling, { calculateScrollingOffset, scrollUpBy } from './sticky-scrolling';\nimport { useMobile } from '../internal/hooks/use-mobile';\n\nfunction syncSizes(from: HTMLElement, to: HTMLElement) {\n const fromCells = Array.prototype.slice.apply(from.children);\n const toCells = Array.prototype.slice.apply(to.children);\n for (let i = 0; i < fromCells.length; i++) {\n let width = fromCells[i].style.width;\n // use auto if it is set by resizable columns or real size otherwise\n if (width !== 'auto') {\n width = `${fromCells[i].offsetWidth}px`;\n }\n toCells[i].style.width = width;\n }\n}\n\nexport const useStickyHeader = (\n tableRef: RefObject<HTMLElement>,\n theadRef: RefObject<HTMLElement>,\n secondaryTheadRef: RefObject<HTMLElement>,\n secondaryTableRef: RefObject<HTMLElement>,\n tableWrapperRef: RefObject<HTMLElement>\n) => {\n const isMobile = useMobile();\n // Sync the sizes of the column header copies in the sticky header with the originals\n const syncColumnHeaderWidths = useCallback(() => {\n if (\n tableRef.current &&\n theadRef.current &&\n secondaryTheadRef.current &&\n secondaryTableRef.current &&\n tableWrapperRef.current\n ) {\n syncSizes(theadRef.current, secondaryTheadRef.current);\n\n // Using the tableRef offsetWidth instead of the theadRef because in VR\n // the tableRef adds extra padding to the table and by default the theadRef will have a width\n // without the padding and will make the sticky header width incorrect.\n secondaryTableRef.current.style.width = `${tableRef.current.offsetWidth}px`;\n\n tableWrapperRef.current.style.marginTop = `-${theadRef.current.offsetHeight}px`;\n }\n }, [theadRef, secondaryTheadRef, secondaryTableRef, tableWrapperRef, tableRef]);\n useLayoutEffect(() => {\n syncColumnHeaderWidths();\n const secondaryTable = secondaryTableRef.current;\n const primaryTable = tableWrapperRef.current;\n return () => {\n if (secondaryTable) {\n secondaryTable.style.width = '';\n }\n if (primaryTable) {\n primaryTable.style.marginTop = '';\n }\n };\n }, [secondaryTableRef, tableWrapperRef, syncColumnHeaderWidths]);\n useResizeObserver(theadRef, syncColumnHeaderWidths);\n const scrollToTop = () => {\n if (!isMobile && theadRef.current && secondaryTheadRef.current && tableWrapperRef.current) {\n const scrollDist = calculateScrollingOffset(theadRef.current, secondaryTheadRef.current);\n if (scrollDist > 0) {\n scrollUpBy(scrollDist, tableWrapperRef.current);\n }\n }\n };\n const { scrollToItem } = stickyScrolling(tableWrapperRef, secondaryTheadRef);\n const scrollToRow = (itemNode: HTMLElement | null) => {\n if (!isMobile) {\n scrollToItem(itemNode);\n }\n };\n return { scrollToRow, scrollToTop };\n};\n"]}
|