@cloudscape-design/components 3.0.43 → 3.0.46

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.
Files changed (103) hide show
  1. package/autosuggest/internal.d.ts.map +1 -1
  2. package/autosuggest/internal.js +45 -78
  3. package/autosuggest/internal.js.map +1 -1
  4. package/autosuggest/load-more-controller.d.ts.map +1 -1
  5. package/autosuggest/load-more-controller.js +1 -1
  6. package/autosuggest/load-more-controller.js.map +1 -1
  7. package/autosuggest/options-controller.d.ts.map +1 -1
  8. package/autosuggest/options-controller.js +0 -1
  9. package/autosuggest/options-controller.js.map +1 -1
  10. package/autosuggest/styles.css.js +3 -4
  11. package/autosuggest/styles.scoped.css +3 -8
  12. package/autosuggest/styles.selectors.js +3 -4
  13. package/code-editor/index.d.ts.map +1 -1
  14. package/code-editor/index.js +13 -14
  15. package/code-editor/index.js.map +1 -1
  16. package/code-editor/styles.css.js +32 -33
  17. package/code-editor/styles.scoped.css +116 -122
  18. package/code-editor/styles.selectors.js +32 -33
  19. package/container/internal.d.ts +2 -1
  20. package/container/internal.d.ts.map +1 -1
  21. package/container/internal.js +3 -2
  22. package/container/internal.js.map +1 -1
  23. package/container/styles.css.js +16 -15
  24. package/container/styles.scoped.css +29 -24
  25. package/container/styles.selectors.js +16 -15
  26. package/date-picker/styles.css.js +24 -24
  27. package/date-picker/styles.scoped.css +41 -41
  28. package/date-picker/styles.selectors.js +24 -24
  29. package/date-range-picker/index.d.ts.map +1 -1
  30. package/date-range-picker/index.js +4 -9
  31. package/date-range-picker/index.js.map +1 -1
  32. package/date-range-picker/styles.css.js +41 -41
  33. package/date-range-picker/styles.scoped.css +50 -50
  34. package/date-range-picker/styles.selectors.js +41 -41
  35. package/expandable-section/expandable-section-container.d.ts.map +1 -1
  36. package/expandable-section/expandable-section-container.js +1 -1
  37. package/expandable-section/expandable-section-container.js.map +1 -1
  38. package/internal/components/autosuggest-input/index.d.ts +28 -0
  39. package/internal/components/autosuggest-input/index.d.ts.map +1 -0
  40. package/internal/components/autosuggest-input/index.js +141 -0
  41. package/internal/components/autosuggest-input/index.js.map +1 -0
  42. package/internal/components/autosuggest-input/styles.css.js +7 -0
  43. package/internal/components/autosuggest-input/styles.scoped.css +12 -0
  44. package/internal/components/autosuggest-input/styles.selectors.js +8 -0
  45. package/internal/environment.js +1 -1
  46. package/internal/generated/styles/tokens.d.ts +17 -0
  47. package/internal/generated/styles/tokens.js +17 -0
  48. package/internal/generated/theming/index.cjs +35 -1
  49. package/internal/generated/theming/index.cjs.d.ts +85 -0
  50. package/internal/generated/theming/index.d.ts +85 -0
  51. package/internal/generated/theming/index.js +35 -1
  52. package/internal/utils/date-time/format-date-range.d.ts +2 -0
  53. package/internal/utils/date-time/format-date-range.d.ts.map +1 -0
  54. package/internal/utils/date-time/format-date-range.js +11 -0
  55. package/internal/utils/date-time/format-date-range.js.map +1 -0
  56. package/internal/utils/date-time/index.d.ts +1 -0
  57. package/internal/utils/date-time/index.d.ts.map +1 -1
  58. package/internal/utils/date-time/index.js +1 -0
  59. package/internal/utils/date-time/index.js.map +1 -1
  60. package/package.json +1 -1
  61. package/property-filter/controller.d.ts +15 -29
  62. package/property-filter/controller.d.ts.map +1 -1
  63. package/property-filter/controller.js +10 -10
  64. package/property-filter/controller.js.map +1 -1
  65. package/property-filter/index.d.ts.map +1 -1
  66. package/property-filter/index.js +7 -13
  67. package/property-filter/index.js.map +1 -1
  68. package/property-filter/interfaces.d.ts +25 -0
  69. package/property-filter/interfaces.d.ts.map +1 -1
  70. package/property-filter/interfaces.js.map +1 -1
  71. package/property-filter/property-filter-autosuggest.d.ts +2 -3
  72. package/property-filter/property-filter-autosuggest.d.ts.map +1 -1
  73. package/property-filter/property-filter-autosuggest.js +39 -77
  74. package/property-filter/property-filter-autosuggest.js.map +1 -1
  75. package/property-filter/token-editor.d.ts +16 -7
  76. package/property-filter/token-editor.d.ts.map +1 -1
  77. package/property-filter/token-editor.js +1 -2
  78. package/property-filter/token-editor.js.map +1 -1
  79. package/property-filter/token.d.ts +20 -9
  80. package/property-filter/token.d.ts.map +1 -1
  81. package/property-filter/token.js +1 -1
  82. package/property-filter/token.js.map +1 -1
  83. package/property-filter/use-load-items.d.ts +1 -2
  84. package/property-filter/use-load-items.d.ts.map +1 -1
  85. package/property-filter/use-load-items.js.map +1 -1
  86. package/property-filter/utils.d.ts +4 -4
  87. package/property-filter/utils.d.ts.map +1 -1
  88. package/property-filter/utils.js.map +1 -1
  89. package/test-utils/dom/internal/autosuggest-input.d.ts +8 -0
  90. package/test-utils/dom/internal/autosuggest-input.js +41 -0
  91. package/test-utils/dom/internal/autosuggest-input.js.map +1 -0
  92. package/test-utils/selectors/internal/autosuggest-input.d.ts +8 -0
  93. package/test-utils/selectors/internal/autosuggest-input.js +41 -0
  94. package/test-utils/selectors/internal/autosuggest-input.js.map +1 -0
  95. package/test-utils/tsconfig.tsbuildinfo +1 -1
  96. package/autosuggest/dropdown-controller.d.ts +0 -20
  97. package/autosuggest/dropdown-controller.d.ts.map +0 -1
  98. package/autosuggest/dropdown-controller.js +0 -29
  99. package/autosuggest/dropdown-controller.js.map +0 -1
  100. package/autosuggest/input-controller.d.ts +0 -12
  101. package/autosuggest/input-controller.d.ts.map +0 -1
  102. package/autosuggest/input-controller.js +0 -38
  103. package/autosuggest/input-controller.js.map +0 -1
@@ -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,EACzC,YAA6C;IAErC,IAAA,MAAM,GAAgB,KAAK,OAArB,EAAE,SAAS,GAAK,KAAK,UAAV,C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AAQ,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 // TODO: remove unknown type annotation once extended operators are supported.\n operators?.forEach((op: unknown) => {\n if (typeof op === 'string') {\n operatorSet[op] = true;\n }\n });\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":"AAAA,qEAAqE;AACrE,sCAAsC;;AAatC,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,CAAW;IACpC,IAAM,YAAY,GAAG,UAAC,MAAwB,EAAE,SAAwB;QACtE,OAAA,sBAAsB,CAAC,QAAQ,EAAE,EAAE,MAAM,QAAA,EAAE,SAAS,WAAA,EAAE,CAAC;IAAvD,CAAuD,CAAC;IAC1D,IAAM,QAAQ,GAAG,UAAC,KAAa,EAAE,QAAe;QAC9C,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,MAAA,QAAQ,CAAC,OAAO,0CAAE,WAAW,EAAE,CAAC;IAClC,CAAC,CA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AC,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 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?.focusNoOpen();\n };\n const removeAllTokens = () => {\n fireOnChange([], operation);\n inputRef.current?.focusNoOpen();\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: { [key: string]: true } = { [defaultOperator ?? '=']: true };\n // TODO: remove unknown type annotation once extended operators are supported.\n operators?.forEach((op: unknown) => {\n if (typeof op === 'string') {\n operatorSet[op] = true;\n }\n });\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: 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\ninterface ExtendedAutosuggestOption extends AutosuggestProps.Option {\n tokenValue: string;\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<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 = 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: 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\nconst filteringPropertyToAutosuggestOption = (filteringProperty: FilteringProperty) => ({\n value: 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 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 = (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 +1 @@
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"}
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,EAAiE,MAAM,cAAc,CAAC;AASlH,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAE/B,QAAA,MAAM,cAAc,qGAuPnB,CAAC;AAGF,eAAe,cAAc,CAAC"}
@@ -12,23 +12,22 @@ import { KeyCode } from '../internal/keycode';
12
12
  import SelectToggle from '../token-group/toggle';
13
13
  import { generateUniqueId } from '../internal/hooks/use-unique-id/index';
14
14
  import { fireNonCancelableEvent } from '../internal/events';
15
- import { Token } from './token';
15
+ import { TokenButton } from './token';
16
16
  import { getQueryActions, parseText, getAutosuggestOptions, getAllowedOperators } from './controller';
17
17
  import { useLoadItems } from './use-load-items';
18
18
  import styles from './styles.css.js';
19
19
  import useBaseComponent from '../internal/hooks/use-base-component';
20
20
  import PropertyFilterAutosuggest from './property-filter-autosuggest';
21
21
  var PropertyFilter = React.forwardRef(function (_a, ref) {
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"]);
22
+ var disabled = _a.disabled, i18nStrings = _a.i18nStrings, countText = _a.countText, query = _a.query, hideOperations = _a.hideOperations, onChange = _a.onChange, filteringProperties = _a.filteringProperties, _b = _a.filteringOptions, filteringOptions = _b === void 0 ? [] : _b, _c = _a.customGroupsText, customGroupsText = _c === void 0 ? [] : _c, _d = _a.disableFreeTextFiltering, disableFreeTextFiltering = _d === void 0 ? false : _d, 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;
24
24
  var inputRef = useRef(null);
25
- var preventFocus = useRef(false);
26
25
  var baseProps = getBaseProps(rest);
27
26
  useForwardFocus(ref, inputRef);
28
27
  var tokens = query.tokens, operation = query.operation;
29
28
  var showResults = (tokens === null || tokens === void 0 ? void 0 : tokens.length) && !disabled;
30
- var _c = getQueryActions(query, onChange, inputRef, preventFocus), addToken = _c.addToken, removeToken = _c.removeToken, setToken = _c.setToken, setOperation = _c.setOperation, removeAllTokens = _c.removeAllTokens;
31
- var _d = useState(''), filteringText = _d[0], setFilteringText = _d[1];
29
+ var _e = getQueryActions(query, onChange, inputRef), addToken = _e.addToken, removeToken = _e.removeToken, setToken = _e.setToken, setOperation = _e.setOperation, removeAllTokens = _e.removeAllTokens;
30
+ var _f = useState(''), filteringText = _f[0], setFilteringText = _f[1];
32
31
  var parsedText = parseText(filteringText, filteringProperties, disableFreeTextFiltering);
33
32
  var autosuggestOptions = getAutosuggestOptions(parsedText, filteringOptions, filteringProperties, customGroupsText, i18nStrings);
34
33
  var createToken = function (currentText) {
@@ -126,7 +125,7 @@ var PropertyFilter = React.forwardRef(function (_a, ref) {
126
125
  }
127
126
  }
128
127
  };
129
- var _e = useState(false), tokensExpanded = _e[0], setTokensExpanded = _e[1];
128
+ var _g = useState(false), tokensExpanded = _g[0], setTokensExpanded = _g[1];
130
129
  var toggleExpandedTokens = function () { return setTokensExpanded(!tokensExpanded); };
131
130
  var hasHiddenOptions = tokenLimit !== undefined && tokens.length > tokenLimit;
132
131
  var slicedTokens = hasHiddenOptions && !tokensExpanded ? tokens.slice(0, tokenLimit) : tokens;
@@ -134,16 +133,11 @@ var PropertyFilter = React.forwardRef(function (_a, ref) {
134
133
  return (React.createElement("span", __assign({}, baseProps, { className: clsx(baseProps.className, styles.root), ref: __internalRootRef }),
135
134
  React.createElement("div", { className: styles['search-field'] },
136
135
  customControl && React.createElement("div", { className: styles['custom-control'] }, customControl),
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
- if (preventFocus.current) {
139
- e.preventDefault();
140
- preventFocus.current = false;
141
- }
142
- }, hideEnteredTextOption: disableFreeTextFiltering && parsedText.step !== 'property' })),
136
+ 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, hideEnteredTextOption: disableFreeTextFiltering && parsedText.step !== 'property' })),
143
137
  React.createElement("span", { "aria-live": "polite", "aria-atomic": "true", className: clsx(styles.results, showResults && styles['results-visible']) }, showResults ? countText : '')),
144
138
  tokens && tokens.length > 0 && (React.createElement("div", { className: styles.tokens },
145
139
  React.createElement(InternalSpaceBetween, { size: "xs", direction: "horizontal", id: controlId },
146
- slicedTokens.map(function (token, index) { return (React.createElement(Token, { token: token, first: index === 0, operation: operation, key: index, removeToken: function () { return removeToken(index); }, setToken: function (newToken) { return setToken(index, newToken); }, setOperation: setOperation, filteringOptions: filteringOptions, filteringProperties: filteringProperties, asyncProps: asyncProps, onLoadItems: onLoadItems, i18nStrings: i18nStrings, asyncProperties: asyncProperties, hideOperations: hideOperations, customGroupsText: customGroupsText, disableFreeTextFiltering: disableFreeTextFiltering, disabled: disabled, expandToViewport: expandToViewport })); }),
140
+ slicedTokens.map(function (token, index) { return (React.createElement(TokenButton, { token: token, first: index === 0, operation: operation, key: index, removeToken: function () { return removeToken(index); }, setToken: function (newToken) { return setToken(index, newToken); }, setOperation: setOperation, filteringOptions: filteringOptions, filteringProperties: filteringProperties, asyncProps: asyncProps, onLoadItems: onLoadItems, i18nStrings: i18nStrings, asyncProperties: asyncProperties, hideOperations: hideOperations, customGroupsText: customGroupsText, disableFreeTextFiltering: disableFreeTextFiltering, disabled: disabled, expandToViewport: expandToViewport })); }),
147
141
  hasHiddenOptions && (React.createElement("div", { className: styles['toggle-collapsed'] },
148
142
  React.createElement(SelectToggle, { controlId: controlId, allHidden: tokenLimit === 0, expanded: tokensExpanded, numberOfHiddenOptions: tokens.length - slicedTokens.length, i18nStrings: {
149
143
  limitShowFewer: i18nStrings.tokenLimitShowF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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"]}
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,EAA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,gBAAgB,EAClC,mBAAmB,EAAE,mBAAmB,EACxC,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,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 } 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, ParsedText, Ref, FilteringProperty, ComparisonOperator, Token } from './interfaces';\nimport { TokenButton } from './token';\nimport { getQueryActions, parseText, getAutosuggestOptions, 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';\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 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 );\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 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 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"]}
@@ -210,4 +210,29 @@ export declare namespace PropertyFilterProps {
210
210
  focus(): void;
211
211
  }
212
212
  }
213
+ export declare type Token = PropertyFilterProps.Token;
214
+ export declare type JoinOperation = PropertyFilterProps.JoinOperation;
215
+ export declare type ComparisonOperator = PropertyFilterProps.ComparisonOperator;
216
+ export declare type FilteringOption = PropertyFilterProps.FilteringOption;
217
+ export declare type FilteringProperty = PropertyFilterProps.FilteringProperty;
218
+ export declare type Query = PropertyFilterProps.Query;
219
+ export declare type LoadItemsDetail = PropertyFilterProps.LoadItemsDetail;
220
+ export declare type I18nStrings = PropertyFilterProps.I18nStrings;
221
+ export declare type GroupText = PropertyFilterProps.GroupText;
222
+ export declare type FilteringChangeDetail = PropertyFilterProps.FilteringChangeDetail;
223
+ export declare type Ref = PropertyFilterProps.Ref;
224
+ export declare type ParsedText = {
225
+ step: 'property';
226
+ property: FilteringProperty;
227
+ operator: ComparisonOperator;
228
+ value: string;
229
+ } | {
230
+ step: 'operator';
231
+ property: FilteringProperty;
232
+ operatorPrefix: string;
233
+ } | {
234
+ step: 'free-text';
235
+ operator?: ComparisonOperator;
236
+ value: string;
237
+ };
213
238
  //# sourceMappingURL=interfaces.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/property-filter/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAC9E,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,qCAAqC,CAAC;AAE7C,MAAM,WAAW,mBAAoB,SAAQ,kBAAkB,EAAE,gBAAgB;IAC/E;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,WAAW,EAAE,mBAAmB,CAAC,WAAW,CAAC;IAC7C;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;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tD,oBAAY,qBAAqB,GAAG,mBAAmB,CAAC,qBAAqB,CAAC;AAC9E,oBAAY,GAAG,GAAG,mBAAmB,CAAC,GAAG,CAAC;AAI1C,oBAAY,UAAU,GAClB;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,iBAAiB,CAAC;IAAC,QAAQ,EAAE,kBAAkB,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC9F;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,iBAAiB,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,GACzE;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,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":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\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 PropertyFilterOperator,\n PropertyFilterOperation,\n PropertyFilterToken,\n PropertyFilterProperty,\n PropertyFilterOption,\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 FilteringOption = PropertyFilterOption;\n export interface FilteringProperty extends PropertyFilterProperty {\n groupValuesLabel: string;\n propertyLabel: string;\n group?: string;\n }\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 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"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/property-filter/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\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 PropertyFilterOperator,\n PropertyFilterOperation,\n PropertyFilterToken,\n PropertyFilterProperty,\n PropertyFilterOption,\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 FilteringOption = PropertyFilterOption;\n export interface FilteringProperty extends PropertyFilterProperty {\n groupValuesLabel: string;\n propertyLabel: string;\n group?: string;\n }\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 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 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,14 +1,13 @@
1
1
  import React from 'react';
2
2
  import { AutosuggestProps } from '../autosuggest/interfaces';
3
3
  import { CancelableEventHandler } from '../internal/events';
4
- import { InputProps } from '../input/interfaces';
5
4
  import { InternalBaseComponentProps } from '../internal/hooks/use-base-component';
5
+ import { AutosuggestInputRef } from '../internal/components/autosuggest-input';
6
6
  export interface PropertyFilterAutosuggestProps extends AutosuggestProps, InternalBaseComponentProps {
7
7
  filterText?: string;
8
- onOpen?: CancelableEventHandler<null>;
9
8
  onOptionClick?: CancelableEventHandler<AutosuggestProps.Option>;
10
9
  hideEnteredTextOption?: boolean;
11
10
  }
12
- declare const PropertyFilterAutosuggest: React.ForwardRefExoticComponent<PropertyFilterAutosuggestProps & React.RefAttributes<InputProps.Ref>>;
11
+ declare const PropertyFilterAutosuggest: React.ForwardRefExoticComponent<PropertyFilterAutosuggestProps & React.RefAttributes<AutosuggestInputRef>>;
13
12
  export default PropertyFilterAutosuggest;
14
13
  //# sourceMappingURL=property-filter-autosuggest.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"property-filter-autosuggest.d.ts","sourceRoot":"","sources":["../../../src/property-filter/property-filter-autosuggest.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAsB,MAAM,OAAO,CAAC;AAI3C,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;AAQlF,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;AAED,QAAA,MAAM,yBAAyB,uGAwL9B,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
1
+ {"version":3,"file":"property-filter-autosuggest.d.ts","sourceRoot":"","sources":["../../../src/property-filter/property-filter-autosuggest.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAsB,MAAM,OAAO,CAAC;AAG3C,OAAO,EAAmB,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAM9E,OAAO,EAEL,sBAAsB,EAGvB,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAIlF,OAAyB,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAKjG,MAAM,WAAW,8BAA+B,SAAQ,gBAAgB,EAAE,0BAA0B;IAClG,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,sBAAsB,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAChE,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED,QAAA,MAAM,yBAAyB,4GAsJ9B,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
@@ -1,29 +1,25 @@
1
- import { __assign, __rest } from "tslib";
2
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
2
  // SPDX-License-Identifier: Apache-2.0
4
- import clsx from 'clsx';
3
+ import { __assign, __rest } from "tslib";
5
4
  import React, { useRef } from 'react';
6
- import { useInputKeydownHandler } from '../autosuggest/input-controller';
7
5
  import { useAutosuggestItems } from '../autosuggest/options-controller';
8
- import Dropdown from '../internal/components/dropdown';
9
6
  import { useDropdownStatus } from '../internal/components/dropdown-status';
10
7
  import DropdownFooter from '../internal/components/dropdown-footer';
11
- import { useFormFieldContext } from '../internal/context/form-field-context';
12
- import { getBaseProps } from '../internal/base-component';
13
8
  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';
9
+ import { fireNonCancelableEvent, } from '../internal/events';
17
10
  import styles from '../autosuggest/styles.css.js';
18
11
  import { fireCancelableEvent } from '../internal/events/index';
19
12
  import AutosuggestOptionsList from '../autosuggest/options-list';
20
- import { useAutosuggestDropdown } from '../autosuggest/dropdown-controller';
21
13
  import { useAutosuggestLoadMore } from '../autosuggest/load-more-controller';
14
+ import AutosuggestInput from '../internal/components/autosuggest-input';
15
+ import { useMergeRefs } from '../internal/hooks/use-merge-refs';
22
16
  var DROPDOWN_WIDTH = 300;
23
17
  var PropertyFilterAutosuggest = React.forwardRef(function (props, ref) {
24
18
  var _a;
25
- 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"]);
19
+ var value = props.value, onChange = props.onChange, onFocus = props.onFocus, onBlur = props.onBlur, 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, onOptionClick = props.onOptionClick, hideEnteredTextOption = props.hideEnteredTextOption, rest = __rest(props, ["value", "onChange", "onFocus", "onBlur", "onLoadItems", "options", "filteringType", "statusType", "placeholder", "disabled", "ariaLabel", "enteredTextLabel", "onKeyDown", "virtualScroll", "expandToViewport", "filterText", "onOptionClick", "hideEnteredTextOption"]);
26
20
  var highlightText = filterText === undefined ? value : filterText;
21
+ var autosuggestInputRef = useRef(null);
22
+ var mergedRef = useMergeRefs(autosuggestInputRef, ref);
27
23
  var _d = useAutosuggestItems({
28
24
  options: options || [],
29
25
  filterValue: value,
@@ -31,98 +27,64 @@ var PropertyFilterAutosuggest = React.forwardRef(function (props, ref) {
31
27
  filteringType: filteringType,
32
28
  hideEnteredTextLabel: hideEnteredTextOption,
33
29
  onSelectItem: function (option) {
30
+ var _a;
34
31
  var value = option.value || '';
35
32
  fireNonCancelableEvent(onChange, { value: value });
36
33
  var selectedCancelled = fireCancelableEvent(onOptionClick, option);
37
34
  if (!selectedCancelled) {
38
- autosuggestDropdownHandlers.closeDropdown();
35
+ (_a = autosuggestInputRef.current) === null || _a === void 0 ? void 0 : _a.close();
39
36
  }
40
37
  else {
41
38
  autosuggestItemsHandlers.resetHighlightWithKeyboard();
42
39
  }
43
40
  }
44
41
  }), autosuggestItemsState = _d[0], autosuggestItemsHandlers = _d[1];
45
- var _e = useAutosuggestDropdown({
46
- onClose: function () { return autosuggestItemsHandlers.resetHighlightWithKeyboard(); }
47
- }), open = _e[0].open, autosuggestDropdownHandlers = _e[1], autosuggestDropdownRefs = _e[2];
48
42
  var autosuggestLoadMoreHandlers = useAutosuggestLoadMore({
49
43
  options: options,
50
44
  statusType: statusType,
51
45
  onLoadItems: function (detail) { return fireNonCancelableEvent(onLoadItems, detail); }
52
46
  });
53
- var handleInputChange = function (e) {
54
- autosuggestDropdownHandlers.openDropdown();
47
+ var handleChange = function (event) {
48
+ autosuggestItemsHandlers.resetHighlightWithKeyboard();
49
+ fireNonCancelableEvent(onChange, event.detail);
50
+ };
51
+ var handleDelayedInput = function (event) {
52
+ autosuggestLoadMoreHandlers.fireLoadMoreOnInputChange(event.detail.value);
53
+ };
54
+ var handleFocus = function () {
55
+ autosuggestLoadMoreHandlers.fireLoadMoreOnInputFocus();
56
+ fireCancelableEvent(onFocus, null);
57
+ };
58
+ var handleBlur = function () {
59
+ fireCancelableEvent(onBlur, null);
60
+ };
61
+ var handleKeyDown = function (e) {
62
+ fireCancelableEvent(onKeyDown, e.detail);
63
+ };
64
+ var handlePressArrowDown = function () {
65
+ autosuggestItemsHandlers.moveHighlightWithKeyboard(1);
66
+ };
67
+ var handlePressArrowUp = function () {
68
+ autosuggestItemsHandlers.moveHighlightWithKeyboard(-1);
69
+ };
70
+ var handlePressEnter = function () {
71
+ return autosuggestItemsHandlers.selectHighlightedOptionWithKeyboard();
72
+ };
73
+ var handleCloseDropdown = function () {
55
74
  autosuggestItemsHandlers.resetHighlightWithKeyboard();
56
- onChange && onChange(e);
57
75
  };
58
- var handleKeyDown = useInputKeydownHandler({
59
- open: open,
60
- onPressArrowDown: function () {
61
- autosuggestItemsHandlers.moveHighlightWithKeyboard(1);
62
- autosuggestDropdownHandlers.openDropdown();
63
- },
64
- onPressArrowUp: function () {
65
- autosuggestItemsHandlers.moveHighlightWithKeyboard(-1);
66
- autosuggestDropdownHandlers.openDropdown();
67
- },
68
- onPressEnter: function () {
69
- if (!autosuggestItemsHandlers.selectHighlightedOptionWithKeyboard()) {
70
- autosuggestDropdownHandlers.closeDropdown();
71
- }
72
- },
73
- onPressEsc: function () {
74
- if (open) {
75
- autosuggestDropdownHandlers.closeDropdown();
76
- }
77
- else if (value) {
78
- fireNonCancelableEvent(onChange, { value: '' });
79
- }
80
- },
81
- onKeyDown: function (e) {
82
- fireCancelableEvent(onKeyDown, e.detail);
83
- }
84
- });
85
76
  var handleRecoveryClick = function () {
86
77
  var _a;
87
78
  autosuggestLoadMoreHandlers.fireLoadMoreOnRecoveryClick();
88
- (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
79
+ (_a = autosuggestInputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
89
80
  };
90
- var formFieldContext = useFormFieldContext(rest);
91
- var baseProps = getBaseProps(rest);
92
- var inputRef = useRef(null);
93
- useForwardFocus(ref, inputRef);
94
81
  var selfControlId = useUniqueId('input');
95
- var controlId = (_a = formFieldContext.controlId) !== null && _a !== void 0 ? _a : selfControlId;
96
- var dropdownId = useUniqueId('dropdown');
82
+ var controlId = (_a = rest.controlId) !== null && _a !== void 0 ? _a : selfControlId;
97
83
  var listId = useUniqueId('list');
98
- // From an a11y point of view we only count the dropdown as 'expanded' if there are items that a user can dropdown into
99
- var expanded = open && autosuggestItemsState.items.length > 1;
100
84
  var highlightedOptionId = autosuggestItemsState.highlightedOption ? generateUniqueId() : undefined;
101
- var nativeAttributes = {
102
- placeholder: placeholder,
103
- onClick: autosuggestDropdownHandlers.openDropdown,
104
- role: 'combobox',
105
- 'aria-autocomplete': 'list',
106
- 'aria-expanded': expanded,
107
- 'aria-controls': listId,
108
- // 'aria-owns' needed for safari+vo to announce activedescendant content
109
- 'aria-owns': listId,
110
- 'aria-label': ariaLabel,
111
- 'aria-activedescendant': highlightedOptionId
112
- };
113
- var handleInputFocus = function () {
114
- var openPrevented = fireCancelableEvent(onOpen, null);
115
- if (!openPrevented) {
116
- autosuggestDropdownHandlers.openDropdown();
117
- autosuggestLoadMoreHandlers.fireLoadMoreOnInputFocus();
118
- }
119
- };
120
85
  var isEmpty = !value && !autosuggestItemsState.items.length;
121
- var showRecoveryLink = open && statusType === 'error' && props.recoveryText;
122
86
  var dropdownStatus = useDropdownStatus(__assign(__assign({}, props), { isEmpty: isEmpty, onRecoveryClick: handleRecoveryClick }));
123
- return (React.createElement("div", __assign({}, baseProps, { className: clsx(styles.root, baseProps.className), onBlur: autosuggestDropdownHandlers.handleBlur }),
124
- React.createElement(Dropdown, { minWidth: DROPDOWN_WIDTH, stretchWidth: false, trigger: React.createElement(InternalInput, __assign({ type: "search", value: value, onChange: handleInputChange, __onDelayedInput: function (event) { return autosuggestLoadMoreHandlers.fireLoadMoreOnInputChange(event.detail.value); }, onFocus: handleInputFocus, onKeyDown: handleKeyDown, disabled: disabled, ref: inputRef, autoComplete: false, __nativeAttributes: nativeAttributes }, formFieldContext, { controlId: controlId })), onMouseDown: autosuggestDropdownHandlers.handleMouseDown, open: open, dropdownId: dropdownId, footer: dropdownStatus.isSticky ? (React.createElement("div", { ref: autosuggestDropdownRefs.footerRef, className: styles['dropdown-footer'] },
125
- React.createElement(DropdownFooter, { content: dropdownStatus.content, hasItems: autosuggestItemsState.items.length >= 1 }))) : null, expandToViewport: expandToViewport, hasContent: autosuggestItemsState.items.length >= 1 || dropdownStatus.content !== null, trapFocus: !!showRecoveryLink }, open && (React.createElement(AutosuggestOptionsList, { autosuggestItemsState: autosuggestItemsState, autosuggestItemsHandlers: autosuggestItemsHandlers, highlightedOptionId: highlightedOptionId, highlightText: highlightText, listId: listId, controlId: controlId, enteredTextLabel: enteredTextLabel, handleLoadMore: autosuggestLoadMoreHandlers.fireLoadMoreOnScroll, hasDropdownStatus: dropdownStatus.content !== null, virtualScroll: virtualScroll, listBottom: !dropdownStatus.isSticky ? React.createElement(DropdownFooter, { content: dropdownStatus.content }) : null })))));
87
+ return (React.createElement(AutosuggestInput, __assign({ ref: mergedRef, className: styles.root, value: value, onChange: handleChange, onFocus: handleFocus, onBlur: handleBlur, onKeyDown: handleKeyDown, controlId: controlId, placeholder: placeholder, disabled: disabled, ariaLabel: ariaLabel, expandToViewport: expandToViewport, ariaControls: listId, ariaActivedescendant: highlightedOptionId, dropdownExpanded: autosuggestItemsState.items.length > 1, dropdownContent: React.createElement(AutosuggestOptionsList, { autosuggestItemsState: autosuggestItemsState, autosuggestItemsHandlers: autosuggestItemsHandlers, highlightedOptionId: highlightedOptionId, highlightText: highlightText, listId: listId, controlId: controlId, enteredTextLabel: enteredTextLabel, handleLoadMore: autosuggestLoadMoreHandlers.fireLoadMoreOnScroll, hasDropdownStatus: dropdownStatus.content !== null, virtualScroll: virtualScroll, listBottom: !dropdownStatus.isSticky ? React.createElement(DropdownFooter, { content: dropdownStatus.content }) : null }), dropdownFooter: dropdownStatus.isSticky ? (React.createElement(DropdownFooter, { content: dropdownStatus.content, hasItems: autosuggestItemsState.items.length >= 1 })) : null, dropdownWidth: DROPDOWN_WIDTH, onCloseDropdown: handleCloseDropdown, onDelayedInput: handleDelayedInput, onPressArrowDown: handlePressArrowDown, onPressArrowUp: handlePressArrowUp, onPressEnter: handlePressEnter }, rest)));
126
88
  });
127
89
  export default PropertyFilterAutosuggest;
128
90
  //# sourceMappingURL=property-filter-autosuggest.js.map