@cloudscape-design/components 3.0.31 → 3.0.32
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/app-layout/index.d.ts.map +1 -1
- package/app-layout/index.js +6 -21
- package/app-layout/index.js.map +1 -1
- package/app-layout/notifications/index.d.ts.map +1 -1
- package/app-layout/notifications/index.js +5 -16
- package/app-layout/notifications/index.js.map +1 -1
- package/app-layout/notifications/styles.css.js +1 -1
- package/app-layout/notifications/styles.scoped.css +2 -1
- package/app-layout/notifications/styles.selectors.js +1 -1
- package/autosuggest/internal.d.ts +0 -7
- package/autosuggest/internal.d.ts.map +1 -1
- package/autosuggest/internal.js +9 -20
- package/autosuggest/internal.js.map +1 -1
- package/internal/environment.js +1 -1
- package/package.json +1 -1
- package/property-filter/controller.d.ts +2 -2
- package/property-filter/controller.js +3 -3
- package/property-filter/controller.js.map +1 -1
- package/property-filter/index.d.ts.map +1 -1
- package/property-filter/index.js +3 -3
- package/property-filter/index.js.map +1 -1
- package/property-filter/property-filter-autosuggest.d.ts +14 -0
- package/property-filter/property-filter-autosuggest.d.ts.map +1 -0
- package/property-filter/property-filter-autosuggest.js +143 -0
- package/property-filter/property-filter-autosuggest.js.map +1 -0
- package/app-layout/dark-header/index.d.ts +0 -11
- package/app-layout/dark-header/index.d.ts.map +0 -1
- package/app-layout/dark-header/index.js +0 -10
- package/app-layout/dark-header/index.js.map +0 -1
- package/app-layout/dark-header/styles.css.js +0 -6
- package/app-layout/dark-header/styles.scoped.css +0 -13
- package/app-layout/dark-header/styles.selectors.js +0 -7
- package/app-layout/utils/use-sticky-position.d.ts +0 -2
- package/app-layout/utils/use-sticky-position.d.ts.map +0 -1
- package/app-layout/utils/use-sticky-position.js +0 -54
- package/app-layout/utils/use-sticky-position.js.map +0 -1
|
@@ -174,7 +174,7 @@ export var getAutosuggestOptions = function (parsedText, filteringOptions, filte
|
|
|
174
174
|
var _a = parsedText.property, propertyLabel_1 = _a.propertyLabel, groupValuesLabel = _a.groupValuesLabel;
|
|
175
175
|
var options = getPropertyOptions(parsedText.property, filteringOptions);
|
|
176
176
|
return {
|
|
177
|
-
|
|
177
|
+
filterText: parsedText.value,
|
|
178
178
|
options: [
|
|
179
179
|
{
|
|
180
180
|
options: (options || []).map(function (_a) {
|
|
@@ -192,7 +192,7 @@ export var getAutosuggestOptions = function (parsedText, filteringOptions, filte
|
|
|
192
192
|
}
|
|
193
193
|
case 'operator': {
|
|
194
194
|
return {
|
|
195
|
-
|
|
195
|
+
filterText: parsedText.property.propertyLabel + ' ' + parsedText.operatorPrefix,
|
|
196
196
|
options: __spreadArray(__spreadArray([], getPropertySuggestions(filteringProperties, customGroupsText, i18nStrings, filteringPropertyToAutosuggestOption), true), [
|
|
197
197
|
{
|
|
198
198
|
options: getAllowedOperators(parsedText.property).map(function (value) { return ({
|
|
@@ -210,7 +210,7 @@ export var getAutosuggestOptions = function (parsedText, filteringOptions, filte
|
|
|
210
210
|
var needsValueSuggestions = !!parsedText.value;
|
|
211
211
|
var needsPropertySuggestions = !(parsedText.step === 'free-text' && parsedText.operator === '!:');
|
|
212
212
|
return {
|
|
213
|
-
|
|
213
|
+
filterText: parsedText.value,
|
|
214
214
|
options: __spreadArray(__spreadArray([], (needsPropertySuggestions
|
|
215
215
|
? getPropertySuggestions(filteringProperties, customGroupsText, i18nStrings, filteringPropertyToAutosuggestOption)
|
|
216
216
|
: []), true), (needsValueSuggestions
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../src/property-filter/controller.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAG5D,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,mBAAmB,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEhH,MAAM,CAAC,IAAM,eAAe,GAAG,UAC7B,KAAmC,EACnC,QAAyC,EACzC,QAAyC,EACz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C;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\nimport { PropertyFilterProps } from './interfaces';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { AutosuggestProps } from '../autosuggest/interfaces';\nimport { InputProps } from '../input/interfaces';\nimport { matchFilteringProperty, matchOperator, matchOperatorPrefix, trimFirstSpace, trimStart } from './utils';\n\nexport const getQueryActions = (\n query: PropertyFilterProps['query'],\n onChange: PropertyFilterProps['onChange'],\n inputRef: React.RefObject<InputProps.Ref>,\n preventFocus: React.MutableRefObject<boolean>\n) => {\n const { tokens, operation } = query;\n const fireOnChange = (tokens: readonly PropertyFilterProps.Token[], operation: PropertyFilterProps.JoinOperation) =>\n fireNonCancelableEvent(onChange, { tokens, operation });\n const setToken = (index: number, newToken: PropertyFilterProps.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 preventFocus.current = true;\n inputRef.current?.focus();\n };\n const removeAllTokens = () => {\n fireOnChange([], operation);\n preventFocus.current = true;\n inputRef.current?.focus();\n };\n const addToken = (newToken: PropertyFilterProps.Token) => {\n const newTokens = [...tokens];\n newTokens.push(newToken);\n fireOnChange(newTokens, operation);\n };\n const setOperation = (newOperation: PropertyFilterProps.JoinOperation) => {\n fireOnChange(tokens, newOperation);\n };\n return {\n setToken,\n removeToken,\n removeAllTokens,\n addToken,\n setOperation,\n };\n};\n\nexport type ParsedText =\n | {\n step: 'property';\n property: PropertyFilterProps.FilteringProperty;\n operator: PropertyFilterProps.ComparisonOperator;\n value: string;\n }\n | { step: 'operator'; property: PropertyFilterProps.FilteringProperty; operatorPrefix: string }\n | { step: 'free-text'; operator?: PropertyFilterProps.ComparisonOperator; value: string };\n\nexport const getAllowedOperators = (\n property: PropertyFilterProps.FilteringProperty\n): PropertyFilterProps.ComparisonOperator[] => {\n const { operators, defaultOperator } = property;\n const operatorOrder = ['=', '!=', ':', '!:', '>=', '<=', '<', '>'] as const;\n const operatorSet: { [key: string]: true } = { [defaultOperator ?? '=']: true };\n operators?.forEach(op => (operatorSet[op] = true));\n return operatorOrder.filter(op => operatorSet[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: PropertyFilterProps['filteringProperties'] = [],\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: PropertyFilterProps.FilteringProperty,\n filteringOptions: PropertyFilterProps['filteringOptions']\n) => {\n return filteringOptions?.filter(option => option.propertyKey === filteringProperty.key);\n};\n\ninterface OptionGroup<T> {\n label: string;\n options: T[];\n}\n\ninterface ExtendedAutosuggestOption extends AutosuggestProps.Option {\n tokenValue: string;\n}\n\nexport const getAllValueSuggestions = (\n filteringOptions: PropertyFilterProps['filteringOptions'],\n filteringProperties: PropertyFilterProps['filteringProperties'],\n operator: PropertyFilterProps.ComparisonOperator | undefined = '=',\n i18nStrings: Pick<PropertyFilterProps.I18nStrings, 'groupValuesText'>,\n customGroupsText: PropertyFilterProps['customGroupsText']\n) => {\n const defaultGroup: OptionGroup<ExtendedAutosuggestOption> = {\n label: i18nStrings.groupValuesText,\n options: [],\n };\n const customGroups: { [K in string]: OptionGroup<ExtendedAutosuggestOption> } = {};\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 =\n 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 tokenValue: 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: PropertyFilterProps['filteringProperties'], key: string) => {\n const propertyMap = filteringProperties.reduce<{ [K: string]: PropertyFilterProps.FilteringProperty }>(\n (acc, property) => {\n acc[property.key] = property;\n return acc;\n },\n {}\n );\n return propertyMap[key] as PropertyFilterProps.FilteringProperty | undefined;\n};\n\nconst filteringPropertyToAutosuggestOption = (filteringProperty: PropertyFilterProps.FilteringProperty) => ({\n value: filteringProperty.propertyLabel,\n keepOpenOnSelect: true,\n});\n\nexport function getPropertySuggestions<T>(\n filteringProperties: PropertyFilterProps['filteringProperties'],\n customGroupsText: PropertyFilterProps['customGroupsText'],\n i18nStrings: Pick<PropertyFilterProps['i18nStrings'], 'groupPropertiesText'>,\n filteringPropertyToOption: (filteringProperty: PropertyFilterProps.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 =\n 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 type OperatorStrings =\n | 'operatorLessText'\n | 'operatorLessOrEqualText'\n | 'operatorGreaterText'\n | 'operatorGreaterOrEqualText'\n | 'operatorContainsText'\n | 'operatorDoesNotContainText'\n | 'operatorEqualsText'\n | 'operatorDoesNotEqualText';\nexport const getAutosuggestOptions = (\n parsedText: ParsedText,\n filteringOptions: PropertyFilterProps['filteringOptions'],\n filteringProperties: PropertyFilterProps['filteringProperties'],\n customGroupsText: PropertyFilterProps['customGroupsText'],\n i18nStrings: Pick<\n PropertyFilterProps['i18nStrings'],\n 'groupPropertiesText' | 'groupValuesText' | 'operatorsText' | OperatorStrings\n >\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 tokenValue: 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 = (\n operator: PropertyFilterProps.ComparisonOperator,\n i18nStrings: Pick<PropertyFilterProps['i18nStrings'], OperatorStrings>\n) => {\n const mapping: { [K in PropertyFilterProps.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":";AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAG5D,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,mBAAmB,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEhH,MAAM,CAAC,IAAM,eAAe,GAAG,UAC7B,KAAmC,EACnC,QAAyC,EACzC,QAAyC,EACzC,YAA6C;IAErC,IAAA,MAAM,GAAgB,KAAK,OAArB,EAAE,SAAS,GAAK,KAAK,UAAV,CAAW;IACpC,IAAM,YAAY,GAAG,UAAC,MAA4C,EAAE,SAA4C;QAC9G,OAAA,sBAAsB,CAAC,QAAQ,EAAE,EAAE,MAAM,QAAA,EAAE,SAAS,WAAA,EAAE,CAAC;IAAvD,CAAuD,CAAC;IAC1D,IAAM,QAAQ,GAAG,UAAC,KAAa,EAAE,QAAmC;QAClE,IAAM,SAAS,qBAAO,MAAM,OAAC,CAAC;QAC9B,IAAI,SAAS,IAAI,KAAK,GAAG,SAAS,CAAC,MAAM,EAAE;YACzC,SAAS,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC;SAC7B;QACD,YAAY,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACrC,CAAC,CAAC;IACF,IAAM,WAAW,GAAG,UAAC,KAAa;;QAChC,IAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,KAAK,KAAK,EAAX,CAAW,CAAC,CAAC;QACvD,YAAY,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACnC,YAAY,CAAC,OAAO,GAAG,IAAI,CAAC;QAC5B,MAAA,QAAQ,CAAC,OAAO,0CAAE,KAAK,EAAE,CAAC;IAC5B,CAAC,C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AEtE,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\nimport { PropertyFilterProps } from './interfaces';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { AutosuggestProps } from '../autosuggest/interfaces';\nimport { InputProps } from '../input/interfaces';\nimport { matchFilteringProperty, matchOperator, matchOperatorPrefix, trimFirstSpace, trimStart } from './utils';\n\nexport const getQueryActions = (\n query: PropertyFilterProps['query'],\n onChange: PropertyFilterProps['onChange'],\n inputRef: React.RefObject<InputProps.Ref>,\n preventFocus: React.MutableRefObject<boolean>\n) => {\n const { tokens, operation } = query;\n const fireOnChange = (tokens: readonly PropertyFilterProps.Token[], operation: PropertyFilterProps.JoinOperation) =>\n fireNonCancelableEvent(onChange, { tokens, operation });\n const setToken = (index: number, newToken: PropertyFilterProps.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 preventFocus.current = true;\n inputRef.current?.focus();\n };\n const removeAllTokens = () => {\n fireOnChange([], operation);\n preventFocus.current = true;\n inputRef.current?.focus();\n };\n const addToken = (newToken: PropertyFilterProps.Token) => {\n const newTokens = [...tokens];\n newTokens.push(newToken);\n fireOnChange(newTokens, operation);\n };\n const setOperation = (newOperation: PropertyFilterProps.JoinOperation) => {\n fireOnChange(tokens, newOperation);\n };\n return {\n setToken,\n removeToken,\n removeAllTokens,\n addToken,\n setOperation,\n };\n};\n\nexport type ParsedText =\n | {\n step: 'property';\n property: PropertyFilterProps.FilteringProperty;\n operator: PropertyFilterProps.ComparisonOperator;\n value: string;\n }\n | { step: 'operator'; property: PropertyFilterProps.FilteringProperty; operatorPrefix: string }\n | { step: 'free-text'; operator?: PropertyFilterProps.ComparisonOperator; value: string };\n\nexport const getAllowedOperators = (\n property: PropertyFilterProps.FilteringProperty\n): PropertyFilterProps.ComparisonOperator[] => {\n const { operators, defaultOperator } = property;\n const operatorOrder = ['=', '!=', ':', '!:', '>=', '<=', '<', '>'] as const;\n const operatorSet: { [key: string]: true } = { [defaultOperator ?? '=']: true };\n operators?.forEach(op => (operatorSet[op] = true));\n return operatorOrder.filter(op => operatorSet[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: PropertyFilterProps['filteringProperties'] = [],\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: PropertyFilterProps.FilteringProperty,\n filteringOptions: PropertyFilterProps['filteringOptions']\n) => {\n return filteringOptions?.filter(option => option.propertyKey === filteringProperty.key);\n};\n\ninterface OptionGroup<T> {\n label: string;\n options: T[];\n}\n\ninterface ExtendedAutosuggestOption extends AutosuggestProps.Option {\n tokenValue: string;\n}\n\nexport const getAllValueSuggestions = (\n filteringOptions: PropertyFilterProps['filteringOptions'],\n filteringProperties: PropertyFilterProps['filteringProperties'],\n operator: PropertyFilterProps.ComparisonOperator | undefined = '=',\n i18nStrings: Pick<PropertyFilterProps.I18nStrings, 'groupValuesText'>,\n customGroupsText: PropertyFilterProps['customGroupsText']\n) => {\n const defaultGroup: OptionGroup<ExtendedAutosuggestOption> = {\n label: i18nStrings.groupValuesText,\n options: [],\n };\n const customGroups: { [K in string]: OptionGroup<ExtendedAutosuggestOption> } = {};\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 =\n 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 tokenValue: 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: PropertyFilterProps['filteringProperties'], key: string) => {\n const propertyMap = filteringProperties.reduce<{ [K: string]: PropertyFilterProps.FilteringProperty }>(\n (acc, property) => {\n acc[property.key] = property;\n return acc;\n },\n {}\n );\n return propertyMap[key] as PropertyFilterProps.FilteringProperty | undefined;\n};\n\nconst filteringPropertyToAutosuggestOption = (filteringProperty: PropertyFilterProps.FilteringProperty) => ({\n value: filteringProperty.propertyLabel,\n keepOpenOnSelect: true,\n});\n\nexport function getPropertySuggestions<T>(\n filteringProperties: PropertyFilterProps['filteringProperties'],\n customGroupsText: PropertyFilterProps['customGroupsText'],\n i18nStrings: Pick<PropertyFilterProps['i18nStrings'], 'groupPropertiesText'>,\n filteringPropertyToOption: (filteringProperty: PropertyFilterProps.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 =\n 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 type OperatorStrings =\n | 'operatorLessText'\n | 'operatorLessOrEqualText'\n | 'operatorGreaterText'\n | 'operatorGreaterOrEqualText'\n | 'operatorContainsText'\n | 'operatorDoesNotContainText'\n | 'operatorEqualsText'\n | 'operatorDoesNotEqualText';\nexport const getAutosuggestOptions = (\n parsedText: ParsedText,\n filteringOptions: PropertyFilterProps['filteringOptions'],\n filteringProperties: PropertyFilterProps['filteringProperties'],\n customGroupsText: PropertyFilterProps['customGroupsText'],\n i18nStrings: Pick<\n PropertyFilterProps['i18nStrings'],\n 'groupPropertiesText' | 'groupValuesText' | 'operatorsText' | OperatorStrings\n >\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 tokenValue: 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 = (\n operator: PropertyFilterProps.ComparisonOperator,\n i18nStrings: Pick<PropertyFilterProps['i18nStrings'], OperatorStrings>\n) => {\n const mapping: { [K in PropertyFilterProps.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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/property-filter/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAoC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/property-filter/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAoC,MAAM,OAAO,CAAC;AAYzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAQnD,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAE/B,QAAA,MAAM,cAAc,qGA+PnB,CAAC;AAGF,eAAe,cAAc,CAAC"}
|
package/property-filter/index.js
CHANGED
|
@@ -4,7 +4,6 @@ import { __assign, __rest } from "tslib";
|
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import React, { useRef, useState, useMemo } from 'react';
|
|
6
6
|
import InternalSpaceBetween from '../space-between/internal';
|
|
7
|
-
import InternalAutosuggest from '../autosuggest/internal';
|
|
8
7
|
import { InternalButton } from '../button/internal';
|
|
9
8
|
import { getBaseProps } from '../internal/base-component';
|
|
10
9
|
import useForwardFocus from '../internal/hooks/forward-focus';
|
|
@@ -18,6 +17,7 @@ import { getQueryActions, parseText, getAutosuggestOptions, getAllowedOperators
|
|
|
18
17
|
import { useLoadItems } from './use-load-items';
|
|
19
18
|
import styles from './styles.css.js';
|
|
20
19
|
import useBaseComponent from '../internal/hooks/use-base-component';
|
|
20
|
+
import PropertyFilterAutosuggest from './property-filter-autosuggest';
|
|
21
21
|
var PropertyFilter = React.forwardRef(function (_a, ref) {
|
|
22
22
|
var disabled = _a.disabled, i18nStrings = _a.i18nStrings, countText = _a.countText, query = _a.query, hideOperations = _a.hideOperations, onChange = _a.onChange, filteringProperties = _a.filteringProperties, filteringOptions = _a.filteringOptions, customGroupsText = _a.customGroupsText, _b = _a.disableFreeTextFiltering, disableFreeTextFiltering = _b === void 0 ? false : _b, 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"]);
|
|
23
23
|
var __internalRootRef = useBaseComponent('PropertyFilter').__internalRootRef;
|
|
@@ -134,12 +134,12 @@ var PropertyFilter = React.forwardRef(function (_a, ref) {
|
|
|
134
134
|
return (React.createElement("span", __assign({}, baseProps, { className: clsx(baseProps.className, styles.root), ref: __internalRootRef }),
|
|
135
135
|
React.createElement("div", { className: styles['search-field'] },
|
|
136
136
|
customControl && React.createElement("div", { className: styles['custom-control'] }, customControl),
|
|
137
|
-
React.createElement(
|
|
137
|
+
React.createElement(PropertyFilterAutosuggest, __assign({ ref: inputRef, virtualScroll: virtualScroll, enteredTextLabel: i18nStrings.enteredTextLabel, className: styles.input, ariaLabel: i18nStrings.filteringAriaLabel, placeholder: i18nStrings.filteringPlaceholder, value: filteringText, disabled: disabled, onKeyDown: handleKeyDown }, autosuggestOptions, { onChange: function (event) { return setFilteringText(event.detail.value); }, empty: filteringEmpty }, asyncAutosuggestProps, { expandToViewport: expandToViewport, onOptionClick: handleSelected, onOpen: function (e) {
|
|
138
138
|
if (preventFocus.current) {
|
|
139
139
|
e.preventDefault();
|
|
140
140
|
preventFocus.current = false;
|
|
141
141
|
}
|
|
142
|
-
},
|
|
142
|
+
}, hideEnteredTextOption: disableFreeTextFiltering && parsedText.step !== 'property' })),
|
|
143
143
|
React.createElement("span", { "aria-live": "polite", "aria-atomic": "true", className: clsx(styles.results, showResults && styles['results-visible']) }, showResults ? countText : '')),
|
|
144
144
|
tokens && tokens.length > 0 && (React.createElement("div", { className: styles.tokens },
|
|
145
145
|
React.createElement(InternalSpaceBetween, { size: "xs", direction: "horizontal", id: controlId },
|
|
@@ -1 +1 @@
|
|
|
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,MAAM,OAAO,CAAC;AAEzD,OAAO,oBAAoB,MAAM,2BAA2B,CAAC;AAC7D,OAAO,mBAAiD,MAAM,yBAAyB,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,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,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 } from 'react';\n\nimport InternalSpaceBetween from '../space-between/internal';\nimport InternalAutosuggest, { InternalAutosuggestProps } from '../autosuggest/internal';\nimport { InternalButton } from '../button/internal';\nimport { getBaseProps } from '../internal/base-component';\nimport useForwardFocus from '../internal/hooks/forward-focus';\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 } from './interfaces';\nimport { Token } from './token';\nimport { getQueryActions, parseText, getAutosuggestOptions, ParsedText, getAllowedOperators } from './controller';\nimport { useLoadItems } from './use-load-items';\nimport styles from './styles.css.js';\nimport useBaseComponent from '../internal/hooks/use-base-component';\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<PropertyFilterProps.Ref>\n ) => {\n const { __internalRootRef } = useBaseComponent('PropertyFilter');\n const inputRef = useRef<HTMLInputElement>(null);\n const preventFocus = useRef<boolean>(false);\n const baseProps = getBaseProps(rest);\n useForwardFocus(ref, inputRef);\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 preventFocus\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: PropertyFilterProps.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: InternalAutosuggestProps['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: PropertyFilterProps.FilteringProperty | undefined;\n filteringText: string;\n filteringOperator: PropertyFilterProps.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: InternalAutosuggestProps['__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 if ('tokenValue' in option) {\n createToken((option as { tokenValue: string }).tokenValue);\n return;\n }\n // create a token from the 'use' option\n if (!('keepOpenOnSelect' in option)) {\n createToken(value);\n return;\n }\n\n // stop dropdown from closing\n event.preventDefault();\n const parsedText = parseText(value, filteringProperties, disableFreeTextFiltering);\n const loadMoreDetail = getLoadMoreDetail(parsedText, value);\n fireNonCancelableEvent(onLoadItems, { ...loadMoreDetail, firstPage: true, samePage: false });\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 setFilteringText(parsedText.property.propertyLabel + ' ' + operators[0] + ' ');\n }\n }\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 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 <InternalAutosuggest\n virtualScroll={virtualScroll}\n enteredTextLabel={i18nStrings.enteredTextLabel}\n ref={inputRef}\n className={styles.input}\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 __disableShowAll={true}\n __dropdownWidth={300}\n __onOptionClick={handleSelected}\n __onOpen={e => {\n if (preventFocus.current) {\n e.preventDefault();\n preventFocus.current = false;\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 <Token\n token={token}\n first={index === 0}\n operation={operation}\n key={index}\n removeToken={() => removeToken(index)}\n setToken={(newToken: PropertyFilterProps.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,MAAM,OAAO,CAAC;AAEzD,OAAO,oBAAoB,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAC9D,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;AAG5D,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,qBAAqB,EAAc,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAClH,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,yBAA6D,MAAM,+BAA+B,CAAC;AAI1G,IAAM,cAAc,GAAG,KAAK,CAAC,UAAU,CACrC,UACE,EAwBsB,EACtB,GAAuC;IAxBrC,IAAA,QAAQ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,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 } from 'react';\n\nimport InternalSpaceBetween from '../space-between/internal';\nimport { InternalButton } from '../button/internal';\nimport { getBaseProps } from '../internal/base-component';\nimport useForwardFocus from '../internal/hooks/forward-focus';\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 } from './interfaces';\nimport { Token } from './token';\nimport { getQueryActions, parseText, getAutosuggestOptions, ParsedText, getAllowedOperators } 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';\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<PropertyFilterProps.Ref>\n ) => {\n const { __internalRootRef } = useBaseComponent('PropertyFilter');\n const inputRef = useRef<HTMLInputElement>(null);\n const preventFocus = useRef<boolean>(false);\n const baseProps = getBaseProps(rest);\n useForwardFocus(ref, inputRef);\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 preventFocus\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: PropertyFilterProps.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: PropertyFilterProps.FilteringProperty | undefined;\n filteringText: string;\n filteringOperator: PropertyFilterProps.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 if ('tokenValue' in option) {\n createToken((option as { tokenValue: string }).tokenValue);\n return;\n }\n // create a token from the 'use' option\n if (!('keepOpenOnSelect' in option)) {\n createToken(value);\n return;\n }\n\n // stop dropdown from closing\n event.preventDefault();\n const parsedText = parseText(value, filteringProperties, disableFreeTextFiltering);\n const loadMoreDetail = getLoadMoreDetail(parsedText, value);\n fireNonCancelableEvent(onLoadItems, { ...loadMoreDetail, firstPage: true, samePage: false });\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 setFilteringText(parsedText.property.propertyLabel + ' ' + operators[0] + ' ');\n }\n }\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 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 className={styles.input}\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 onOpen={e => {\n if (preventFocus.current) {\n e.preventDefault();\n preventFocus.current = false;\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 <Token\n token={token}\n first={index === 0}\n operation={operation}\n key={index}\n removeToken={() => removeToken(index)}\n setToken={(newToken: PropertyFilterProps.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"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AutosuggestProps } from '../autosuggest/interfaces';
|
|
3
|
+
import { CancelableEventHandler } from '../internal/events';
|
|
4
|
+
import { InputProps } from '../input/interfaces';
|
|
5
|
+
import { InternalBaseComponentProps } from '../internal/hooks/use-base-component';
|
|
6
|
+
export interface PropertyFilterAutosuggestProps extends AutosuggestProps, InternalBaseComponentProps {
|
|
7
|
+
filterText?: string;
|
|
8
|
+
onOpen?: CancelableEventHandler<null>;
|
|
9
|
+
onOptionClick?: CancelableEventHandler<AutosuggestProps.Option>;
|
|
10
|
+
hideEnteredTextOption?: boolean;
|
|
11
|
+
}
|
|
12
|
+
declare const PropertyFilterAutosuggest: React.ForwardRefExoticComponent<PropertyFilterAutosuggestProps & React.RefAttributes<InputProps.Ref>>;
|
|
13
|
+
export default PropertyFilterAutosuggest;
|
|
14
|
+
//# sourceMappingURL=property-filter-autosuggest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"property-filter-autosuggest.d.ts","sourceRoot":"","sources":["../../../src/property-filter/property-filter-autosuggest.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAIlE,OAAO,EAAmB,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAU9E,OAAO,EAA0B,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEpF,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGjD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAKlF,MAAM,WAAW,8BAA+B,SAAQ,gBAAgB,EAAE,0BAA0B;IAClG,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,sBAAsB,CAAC,IAAI,CAAC,CAAC;IACtC,aAAa,CAAC,EAAE,sBAAsB,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAChE,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC;AAuBD,QAAA,MAAM,yBAAyB,uGA2M9B,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { __assign, __rest } from "tslib";
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import React, { useCallback, useRef, useState } from 'react';
|
|
6
|
+
import { useKeyboardHandler } from '../autosuggest/controller';
|
|
7
|
+
import { useAutosuggestItems } from '../autosuggest/options-controller';
|
|
8
|
+
import Dropdown from '../internal/components/dropdown';
|
|
9
|
+
import { useDropdownStatus } from '../internal/components/dropdown-status';
|
|
10
|
+
import DropdownFooter from '../internal/components/dropdown-footer';
|
|
11
|
+
import { useFormFieldContext } from '../internal/context/form-field-context';
|
|
12
|
+
import { getBaseProps } from '../internal/base-component';
|
|
13
|
+
import { generateUniqueId, useUniqueId } from '../internal/hooks/use-unique-id';
|
|
14
|
+
import useForwardFocus from '../internal/hooks/forward-focus';
|
|
15
|
+
import { fireNonCancelableEvent } from '../internal/events';
|
|
16
|
+
import InternalInput from '../input/internal';
|
|
17
|
+
import styles from '../autosuggest/styles.css.js';
|
|
18
|
+
import { fireCancelableEvent } from '../internal/events/index';
|
|
19
|
+
import AutosuggestOptionsList from '../autosuggest/options-list';
|
|
20
|
+
var DROPDOWN_WIDTH = 300;
|
|
21
|
+
var isInteractive = function (option) {
|
|
22
|
+
return !!option && !option.disabled && option.type !== 'parent';
|
|
23
|
+
};
|
|
24
|
+
var useLoadMoreItems = function (onLoadItems) {
|
|
25
|
+
var lastFilteringText = useRef(null);
|
|
26
|
+
return useCallback(function (firstPage, samePage, filteringText) {
|
|
27
|
+
if (samePage || !firstPage || filteringText === undefined || lastFilteringText.current !== filteringText) {
|
|
28
|
+
if (filteringText !== undefined) {
|
|
29
|
+
lastFilteringText.current = filteringText;
|
|
30
|
+
}
|
|
31
|
+
if (lastFilteringText.current !== null && onLoadItems) {
|
|
32
|
+
fireNonCancelableEvent(onLoadItems, { filteringText: lastFilteringText.current, firstPage: firstPage, samePage: samePage });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}, [onLoadItems]);
|
|
36
|
+
};
|
|
37
|
+
var PropertyFilterAutosuggest = React.forwardRef(function (props, ref) {
|
|
38
|
+
var _a;
|
|
39
|
+
var value = props.value, onChange = props.onChange, onLoadItems = props.onLoadItems, options = props.options, _b = props.filteringType, filteringType = _b === void 0 ? 'auto' : _b, _c = props.statusType, statusType = _c === void 0 ? 'finished' : _c, placeholder = props.placeholder, disabled = props.disabled, ariaLabel = props.ariaLabel, enteredTextLabel = props.enteredTextLabel, onKeyDown = props.onKeyDown, virtualScroll = props.virtualScroll, expandToViewport = props.expandToViewport, filterText = props.filterText, onOpen = props.onOpen, onOptionClick = props.onOptionClick, hideEnteredTextOption = props.hideEnteredTextOption, rest = __rest(props, ["value", "onChange", "onLoadItems", "options", "filteringType", "statusType", "placeholder", "disabled", "ariaLabel", "enteredTextLabel", "onKeyDown", "virtualScroll", "expandToViewport", "filterText", "onOpen", "onOptionClick", "hideEnteredTextOption"]);
|
|
40
|
+
var highlightText = filterText === undefined ? value : filterText;
|
|
41
|
+
var isKeyboard = useRef(false);
|
|
42
|
+
var _d = useState(false), open = _d[0], setOpen = _d[1];
|
|
43
|
+
var _e = useAutosuggestItems({
|
|
44
|
+
options: options || [],
|
|
45
|
+
filterValue: value,
|
|
46
|
+
filterText: highlightText,
|
|
47
|
+
filteringType: filteringType,
|
|
48
|
+
isKeyboard: isKeyboard,
|
|
49
|
+
hideEnteredTextLabel: hideEnteredTextOption
|
|
50
|
+
}), items = _e.items, highlightedOption = _e.highlightedOption, highlightedIndex = _e.highlightedIndex, highlightedType = _e.highlightedType, moveHighlight = _e.moveHighlight, resetHighlight = _e.resetHighlight, setHighlightedIndex = _e.setHighlightedIndex;
|
|
51
|
+
var openDropdown = function () { return setOpen(true); };
|
|
52
|
+
var closeDropdown = function () {
|
|
53
|
+
setOpen(false);
|
|
54
|
+
resetHighlight();
|
|
55
|
+
};
|
|
56
|
+
var handleBlur = function (event) {
|
|
57
|
+
var _a;
|
|
58
|
+
if (event.currentTarget.contains(event.relatedTarget) ||
|
|
59
|
+
((_a = dropdownFooterRef.current) === null || _a === void 0 ? void 0 : _a.contains(event.relatedTarget))) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
closeDropdown();
|
|
63
|
+
};
|
|
64
|
+
var selectOption = function (option) {
|
|
65
|
+
var value = option.value || '';
|
|
66
|
+
fireNonCancelableEvent(onChange, { value: value });
|
|
67
|
+
var selectedCancelled = fireCancelableEvent(onOptionClick, option);
|
|
68
|
+
if (!selectedCancelled) {
|
|
69
|
+
closeDropdown();
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
resetHighlight();
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
var selectHighlighted = function () {
|
|
76
|
+
if (highlightedOption) {
|
|
77
|
+
if (isInteractive(highlightedOption)) {
|
|
78
|
+
selectOption(highlightedOption);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
closeDropdown();
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
var fireLoadMore = useLoadMoreItems(onLoadItems);
|
|
86
|
+
var handleInputChange = function (e) {
|
|
87
|
+
openDropdown();
|
|
88
|
+
resetHighlight();
|
|
89
|
+
onChange && onChange(e);
|
|
90
|
+
};
|
|
91
|
+
var handleKeyDown = useKeyboardHandler(moveHighlight, openDropdown, selectHighlighted, isKeyboard, open, onKeyDown);
|
|
92
|
+
var handleLoadMore = useCallback(function () {
|
|
93
|
+
options && options.length && statusType === 'pending' && fireLoadMore(false, false);
|
|
94
|
+
}, [fireLoadMore, options, statusType]);
|
|
95
|
+
var handleRecoveryClick = useCallback(function () {
|
|
96
|
+
var _a;
|
|
97
|
+
fireLoadMore(false, true);
|
|
98
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
99
|
+
}, [fireLoadMore]);
|
|
100
|
+
var formFieldContext = useFormFieldContext(rest);
|
|
101
|
+
var baseProps = getBaseProps(rest);
|
|
102
|
+
var inputRef = useRef(null);
|
|
103
|
+
var dropdownFooterRef = useRef(null);
|
|
104
|
+
useForwardFocus(ref, inputRef);
|
|
105
|
+
var selfControlId = useUniqueId('input');
|
|
106
|
+
var controlId = (_a = formFieldContext.controlId) !== null && _a !== void 0 ? _a : selfControlId;
|
|
107
|
+
var dropdownId = useUniqueId('dropdown');
|
|
108
|
+
var listId = useUniqueId('list');
|
|
109
|
+
// From an a11y point of view we only count the dropdown as 'expanded' if there are items that a user can dropdown into
|
|
110
|
+
var expanded = open && items.length > 1;
|
|
111
|
+
var highlightedOptionId = highlightedOption ? generateUniqueId() : undefined;
|
|
112
|
+
var nativeAttributes = {
|
|
113
|
+
placeholder: placeholder,
|
|
114
|
+
onClick: openDropdown,
|
|
115
|
+
role: 'combobox',
|
|
116
|
+
'aria-autocomplete': 'list',
|
|
117
|
+
'aria-expanded': expanded,
|
|
118
|
+
'aria-controls': listId,
|
|
119
|
+
// 'aria-owns' needed for safari+vo to announce activedescendant content
|
|
120
|
+
'aria-owns': listId,
|
|
121
|
+
'aria-label': ariaLabel,
|
|
122
|
+
'aria-activedescendant': highlightedOptionId
|
|
123
|
+
};
|
|
124
|
+
var handleInputFocus = function () {
|
|
125
|
+
var openPrevented = fireCancelableEvent(onOpen, null);
|
|
126
|
+
if (!openPrevented) {
|
|
127
|
+
openDropdown();
|
|
128
|
+
fireLoadMore(true, false, '');
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
var isEmpty = !value && !items.length;
|
|
132
|
+
var showRecoveryLink = open && statusType === 'error' && props.recoveryText;
|
|
133
|
+
var dropdownStatus = useDropdownStatus(__assign(__assign({}, props), { isEmpty: isEmpty, onRecoveryClick: handleRecoveryClick }));
|
|
134
|
+
var handleMouseDown = function (event) {
|
|
135
|
+
// prevent currently focused element from losing it
|
|
136
|
+
event.preventDefault();
|
|
137
|
+
};
|
|
138
|
+
return (React.createElement("div", __assign({}, baseProps, { className: clsx(styles.root, baseProps.className), onBlur: handleBlur }),
|
|
139
|
+
React.createElement(Dropdown, { minWidth: DROPDOWN_WIDTH, stretchWidth: false, trigger: React.createElement(InternalInput, __assign({ type: "search", value: value, onChange: handleInputChange, __onDelayedInput: function (event) { return fireLoadMore(true, false, event.detail.value); }, onFocus: handleInputFocus, onKeyDown: handleKeyDown, disabled: disabled, ref: inputRef, autoComplete: false, __nativeAttributes: nativeAttributes }, formFieldContext, { controlId: controlId })), onMouseDown: handleMouseDown, open: open, dropdownId: dropdownId, footer: dropdownStatus.isSticky ? (React.createElement("div", { ref: dropdownFooterRef, className: styles['dropdown-footer'] },
|
|
140
|
+
React.createElement(DropdownFooter, { content: dropdownStatus.content, hasItems: items.length >= 1 }))) : null, expandToViewport: expandToViewport, hasContent: items.length >= 1 || dropdownStatus.content !== null, trapFocus: !!showRecoveryLink }, open && (React.createElement(AutosuggestOptionsList, { options: items, highlightedOption: highlightedOption, selectOption: selectOption, highlightedIndex: highlightedIndex, setHighlightedIndex: setHighlightedIndex, highlightedOptionId: highlightedOptionId, highlightText: highlightText, listId: listId, controlId: controlId, enteredTextLabel: enteredTextLabel, handleLoadMore: handleLoadMore, hasDropdownStatus: dropdownStatus.content !== null, virtualScroll: virtualScroll, listBottom: !dropdownStatus.isSticky ? React.createElement(DropdownFooter, { content: dropdownStatus.content }) : null, isKeyboard: isKeyboard, highlightedType: highlightedType })))));
|
|
141
|
+
});
|
|
142
|
+
export default PropertyFilterAutosuggest;
|
|
143
|
+
//# sourceMappingURL=property-filter-autosuggest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"property-filter-autosuggest.js","sourceRoot":"","sources":["../../../src/property-filter/property-filter-autosuggest.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAE,EAAO,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAElE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAGxE,OAAO,QAAQ,MAAM,iCAAiC,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,cAAc,MAAM,wCAAwC,CAAC;AAEpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC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,CAAC,CAAC,oBAAC,cAAc,IAAC,OAAO,EAAE,cAAc,CAAC,OAAO,GAAI,CAAC,CAAC,CAAC,IAAI,EACjG,UAAU,EAAE,UAAU,EACtB,eAAe,EAAE,eAAe,GAChC,CACH,CACQ,CACP,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,yBAAyB,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, { Ref, useCallback, useRef, useState } from 'react';\n\nimport { useKeyboardHandler } from '../autosuggest/controller';\nimport { useAutosuggestItems } from '../autosuggest/options-controller';\nimport { AutosuggestItem, AutosuggestProps } from '../autosuggest/interfaces';\n\nimport Dropdown from '../internal/components/dropdown';\nimport { useDropdownStatus } from '../internal/components/dropdown-status';\nimport DropdownFooter from '../internal/components/dropdown-footer';\n\nimport { useFormFieldContext } from '../internal/context/form-field-context';\nimport { getBaseProps } from '../internal/base-component';\nimport { generateUniqueId, useUniqueId } from '../internal/hooks/use-unique-id';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport { fireNonCancelableEvent, CancelableEventHandler } from '../internal/events';\nimport InternalInput from '../input/internal';\nimport { InputProps } from '../input/interfaces';\nimport styles from '../autosuggest/styles.css.js';\nimport { fireCancelableEvent } from '../internal/events/index';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport AutosuggestOptionsList from '../autosuggest/options-list';\n\nconst DROPDOWN_WIDTH = 300;\n\nexport interface PropertyFilterAutosuggestProps extends AutosuggestProps, InternalBaseComponentProps {\n filterText?: string;\n onOpen?: CancelableEventHandler<null>;\n onOptionClick?: CancelableEventHandler<AutosuggestProps.Option>;\n hideEnteredTextOption?: boolean;\n}\n\nconst isInteractive = (option?: AutosuggestItem) => {\n return !!option && !option.disabled && option.type !== 'parent';\n};\n\nconst useLoadMoreItems = (onLoadItems: AutosuggestProps['onLoadItems']) => {\n const lastFilteringText = useRef<string | null>(null);\n return useCallback(\n (firstPage: boolean, samePage: boolean, filteringText?: string) => {\n if (samePage || !firstPage || filteringText === undefined || lastFilteringText.current !== filteringText) {\n if (filteringText !== undefined) {\n lastFilteringText.current = filteringText;\n }\n if (lastFilteringText.current !== null && onLoadItems) {\n fireNonCancelableEvent(onLoadItems, { filteringText: lastFilteringText.current, firstPage, samePage });\n }\n }\n },\n [onLoadItems]\n );\n};\n\nconst PropertyFilterAutosuggest = React.forwardRef(\n (props: PropertyFilterAutosuggestProps, ref: Ref<InputProps.Ref>) => {\n const {\n value,\n onChange,\n onLoadItems,\n options,\n filteringType = 'auto',\n statusType = 'finished',\n placeholder,\n disabled,\n ariaLabel,\n enteredTextLabel,\n onKeyDown,\n virtualScroll,\n expandToViewport,\n filterText,\n onOpen,\n onOptionClick,\n hideEnteredTextOption,\n ...rest\n } = props;\n const highlightText = filterText === undefined ? value : filterText;\n\n const isKeyboard = useRef(false);\n const [open, setOpen] = useState(false);\n const {\n items,\n highlightedOption,\n highlightedIndex,\n highlightedType,\n moveHighlight,\n resetHighlight,\n setHighlightedIndex,\n } = useAutosuggestItems({\n options: options || [],\n filterValue: value,\n filterText: highlightText,\n filteringType,\n isKeyboard,\n hideEnteredTextLabel: hideEnteredTextOption,\n });\n const openDropdown = () => setOpen(true);\n const closeDropdown = () => {\n setOpen(false);\n resetHighlight();\n };\n const handleBlur: React.FocusEventHandler = event => {\n if (\n event.currentTarget.contains(event.relatedTarget) ||\n dropdownFooterRef.current?.contains(event.relatedTarget)\n ) {\n return;\n }\n closeDropdown();\n };\n const selectOption = (option: AutosuggestItem) => {\n const value = option.value || '';\n fireNonCancelableEvent(onChange, { value });\n const selectedCancelled = fireCancelableEvent(onOptionClick, option);\n if (!selectedCancelled) {\n closeDropdown();\n } else {\n resetHighlight();\n }\n };\n const selectHighlighted = () => {\n if (highlightedOption) {\n if (isInteractive(highlightedOption)) {\n selectOption(highlightedOption);\n }\n } else {\n closeDropdown();\n }\n };\n\n const fireLoadMore = useLoadMoreItems(onLoadItems);\n\n const handleInputChange: InputProps['onChange'] = e => {\n openDropdown();\n resetHighlight();\n onChange && onChange(e);\n };\n\n const handleKeyDown = useKeyboardHandler(\n moveHighlight,\n openDropdown,\n selectHighlighted,\n isKeyboard,\n open,\n onKeyDown\n );\n const handleLoadMore = useCallback(() => {\n options && options.length && statusType === 'pending' && fireLoadMore(false, false);\n }, [fireLoadMore, options, statusType]);\n const handleRecoveryClick = useCallback(() => {\n fireLoadMore(false, true);\n inputRef.current?.focus();\n }, [fireLoadMore]);\n\n const formFieldContext = useFormFieldContext(rest);\n const baseProps = getBaseProps(rest);\n const inputRef = useRef<HTMLInputElement>(null);\n const dropdownFooterRef = useRef<HTMLDivElement>(null);\n useForwardFocus(ref, inputRef);\n\n const selfControlId = useUniqueId('input');\n const controlId = formFieldContext.controlId ?? selfControlId;\n const dropdownId = useUniqueId('dropdown');\n const listId = useUniqueId('list');\n\n // From an a11y point of view we only count the dropdown as 'expanded' if there are items that a user can dropdown into\n const expanded = open && items.length > 1;\n const highlightedOptionId = highlightedOption ? generateUniqueId() : undefined;\n const nativeAttributes = {\n placeholder,\n onClick: openDropdown,\n role: 'combobox',\n 'aria-autocomplete': 'list',\n 'aria-expanded': expanded,\n 'aria-controls': listId,\n // 'aria-owns' needed for safari+vo to announce activedescendant content\n 'aria-owns': listId,\n 'aria-label': ariaLabel,\n 'aria-activedescendant': highlightedOptionId,\n };\n\n const handleInputFocus: InputProps['onFocus'] = () => {\n const openPrevented = fireCancelableEvent(onOpen, null);\n if (!openPrevented) {\n openDropdown();\n fireLoadMore(true, false, '');\n }\n };\n\n const isEmpty = !value && !items.length;\n const showRecoveryLink = open && statusType === 'error' && props.recoveryText;\n const dropdownStatus = useDropdownStatus({ ...props, isEmpty, onRecoveryClick: handleRecoveryClick });\n\n const handleMouseDown = (event: React.MouseEvent) => {\n // prevent currently focused element from losing it\n event.preventDefault();\n };\n\n return (\n <div {...baseProps} className={clsx(styles.root, baseProps.className)} onBlur={handleBlur}>\n <Dropdown\n minWidth={DROPDOWN_WIDTH}\n stretchWidth={false}\n trigger={\n <InternalInput\n type=\"search\"\n value={value}\n onChange={handleInputChange}\n __onDelayedInput={event => fireLoadMore(true, false, event.detail.value)}\n onFocus={handleInputFocus}\n onKeyDown={handleKeyDown}\n disabled={disabled}\n ref={inputRef}\n autoComplete={false}\n __nativeAttributes={nativeAttributes}\n {...formFieldContext}\n controlId={controlId}\n />\n }\n onMouseDown={handleMouseDown}\n open={open}\n dropdownId={dropdownId}\n footer={\n dropdownStatus.isSticky ? (\n <div ref={dropdownFooterRef} className={styles['dropdown-footer']}>\n <DropdownFooter content={dropdownStatus.content} hasItems={items.length >= 1} />\n </div>\n ) : null\n }\n expandToViewport={expandToViewport}\n hasContent={items.length >= 1 || dropdownStatus.content !== null}\n trapFocus={!!showRecoveryLink}\n >\n {open && (\n <AutosuggestOptionsList\n options={items}\n highlightedOption={highlightedOption}\n selectOption={selectOption}\n highlightedIndex={highlightedIndex}\n setHighlightedIndex={setHighlightedIndex}\n highlightedOptionId={highlightedOptionId}\n highlightText={highlightText}\n listId={listId}\n controlId={controlId}\n enteredTextLabel={enteredTextLabel}\n handleLoadMore={handleLoadMore}\n hasDropdownStatus={dropdownStatus.content !== null}\n virtualScroll={virtualScroll}\n listBottom={!dropdownStatus.isSticky ? <DropdownFooter content={dropdownStatus.content} /> : null}\n isKeyboard={isKeyboard}\n highlightedType={highlightedType}\n />\n )}\n </Dropdown>\n </div>\n );\n }\n);\n\nexport default PropertyFilterAutosuggest;\n"]}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export interface DarkHeaderProps {
|
|
3
|
-
isMobile: boolean;
|
|
4
|
-
toolsWidth: number;
|
|
5
|
-
navigationWidth: number;
|
|
6
|
-
children?: React.ReactNode;
|
|
7
|
-
topOffset?: number;
|
|
8
|
-
sticky?: boolean;
|
|
9
|
-
}
|
|
10
|
-
export declare function DarkHeader({ children, topOffset, sticky }: DarkHeaderProps): JSX.Element;
|
|
11
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/app-layout/dark-header/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,wBAAgB,UAAU,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,eAAe,eAS1E"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import clsx from 'clsx';
|
|
4
|
-
import React from 'react';
|
|
5
|
-
import styles from './styles.css.js';
|
|
6
|
-
export function DarkHeader(_a) {
|
|
7
|
-
var children = _a.children, topOffset = _a.topOffset, sticky = _a.sticky;
|
|
8
|
-
return (React.createElement("div", { className: clsx(styles['content-header'], sticky && styles['content-header-sticky']), style: { top: topOffset } }, children));
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/app-layout/dark-header/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAWrC,MAAM,UAAU,UAAU,CAAC,EAAgD;QAA9C,QAAQ,cAAA,EAAE,SAAS,eAAA,EAAE,MAAM,YAAA;IACtD,OAAO,CACL,6BACE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAAE,MAAM,IAAI,MAAM,CAAC,uBAAuB,CAAC,CAAC,EACpF,KAAK,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,IAExB,QAAQ,CACL,CACP,CAAC;AACJ,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 from 'react';\nimport styles from './styles.css.js';\n\nexport interface DarkHeaderProps {\n isMobile: boolean;\n toolsWidth: number;\n navigationWidth: number;\n children?: React.ReactNode;\n topOffset?: number;\n sticky?: boolean;\n}\n\nexport function DarkHeader({ children, topOffset, sticky }: DarkHeaderProps) {\n return (\n <div\n className={clsx(styles['content-header'], sticky && styles['content-header-sticky'])}\n style={{ top: topOffset }}\n >\n {children}\n </div>\n );\n}\n"]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
-
SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/
|
|
5
|
-
/*
|
|
6
|
-
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
7
|
-
SPDX-License-Identifier: Apache-2.0
|
|
8
|
-
*/
|
|
9
|
-
.awsui_content-header-sticky_szx2o_8sakc_9:not(#\9) {
|
|
10
|
-
/* stylelint-disable-next-line plugin/no-unsupported-browser-features */
|
|
11
|
-
position: sticky;
|
|
12
|
-
z-index: 825;
|
|
13
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-sticky-position.d.ts","sourceRoot":"","sources":["../../../../src/app-layout/utils/use-sticky-position.tsx"],"names":[],"mappings":"AAiBA,wBAAgB,iBAAiB,CAAC,SAAS,SAAI,yDAwC9C"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import React, { useEffect, useRef } from 'react';
|
|
4
|
-
import { useContainerQuery } from '../../internal/hooks/container-queries';
|
|
5
|
-
import { useMergeRefs } from '../../internal/hooks/use-merge-refs';
|
|
6
|
-
function getScrollableContainers(element) {
|
|
7
|
-
var node = element;
|
|
8
|
-
while ((node = node.parentElement) && node !== document.body) {
|
|
9
|
-
if (['scroll', 'auto'].indexOf(getComputedStyle(node).overflow) > -1) {
|
|
10
|
-
return node;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
export function useStickyPosition(topOffset) {
|
|
16
|
-
if (topOffset === void 0) { topOffset = 0; }
|
|
17
|
-
var _a = useContainerQuery(function (rect) { return rect.height; }), stickyHeight = _a[0], stickyMeasureRef = _a[1];
|
|
18
|
-
var stickyRefObject = useRef(null);
|
|
19
|
-
var stickyRef = useMergeRefs(stickyMeasureRef, stickyRefObject);
|
|
20
|
-
var _b = useContainerQuery(function (rect) { return rect.width; }), stickyWidth = _b[0], placeholderMeasureRef = _b[1];
|
|
21
|
-
var placeholderRefObject = useRef(null);
|
|
22
|
-
var placeholderRef = useMergeRefs(placeholderMeasureRef, placeholderRefObject);
|
|
23
|
-
var placeholder = React.createElement("div", { ref: placeholderRef });
|
|
24
|
-
useEffect(function () {
|
|
25
|
-
if (!stickyRefObject.current || !placeholderRefObject.current) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
var stickyElement = stickyRefObject.current;
|
|
29
|
-
var placeholder = placeholderRefObject.current;
|
|
30
|
-
var scrollParent = getScrollableContainers(stickyElement);
|
|
31
|
-
var handler = function () {
|
|
32
|
-
var stickyBox = stickyElement.getBoundingClientRect();
|
|
33
|
-
var containerBox = scrollParent ? scrollParent.getBoundingClientRect() : { top: 0 };
|
|
34
|
-
if (stickyBox.top - containerBox.top <= topOffset) {
|
|
35
|
-
stickyElement.style.position = 'fixed';
|
|
36
|
-
stickyElement.style.width = "".concat(stickyWidth, "px");
|
|
37
|
-
stickyElement.style.top = "".concat(topOffset, "px");
|
|
38
|
-
placeholder.style.height = "".concat(stickyHeight, "px");
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
stickyElement.style.position = '';
|
|
42
|
-
stickyElement.style.width = "";
|
|
43
|
-
stickyElement.style.top = "";
|
|
44
|
-
placeholder.style.height = "";
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
var eventTarget = scrollParent || window;
|
|
48
|
-
eventTarget.addEventListener('scroll', handler);
|
|
49
|
-
handler();
|
|
50
|
-
return function () { return eventTarget.removeEventListener('scroll', handler); };
|
|
51
|
-
}, [topOffset, stickyWidth, stickyHeight, stickyRefObject, placeholderRefObject]);
|
|
52
|
-
return [stickyRef, placeholder];
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=use-sticky-position.js.map
|