@cloudscape-design/components 3.0.793 → 3.0.794
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/alert/internal.d.ts.map +1 -1
- package/alert/internal.js +3 -3
- package/alert/internal.js.map +1 -1
- package/alert/styles.css.js +28 -27
- package/alert/styles.scoped.css +47 -42
- package/alert/styles.selectors.js +28 -27
- package/app-layout/visual-refresh-toolbar/compute-layout.d.ts +1 -0
- package/app-layout/visual-refresh-toolbar/compute-layout.d.ts.map +1 -1
- package/app-layout/visual-refresh-toolbar/compute-layout.js +2 -2
- package/app-layout/visual-refresh-toolbar/compute-layout.js.map +1 -1
- package/app-layout/visual-refresh-toolbar/contexts.d.ts +7 -0
- package/app-layout/visual-refresh-toolbar/contexts.d.ts.map +1 -0
- package/app-layout/visual-refresh-toolbar/contexts.js +6 -0
- package/app-layout/visual-refresh-toolbar/contexts.js.map +1 -0
- package/app-layout/visual-refresh-toolbar/index.d.ts.map +1 -1
- package/app-layout/visual-refresh-toolbar/index.js +56 -20
- package/app-layout/visual-refresh-toolbar/index.js.map +1 -1
- package/app-layout/visual-refresh-toolbar/toolbar/index.d.ts.map +1 -1
- package/app-layout/visual-refresh-toolbar/toolbar/index.js +3 -2
- package/app-layout/visual-refresh-toolbar/toolbar/index.js.map +1 -1
- package/button-dropdown/internal.js +3 -3
- package/button-dropdown/internal.js.map +1 -1
- package/flashbar/flash.d.ts.map +1 -1
- package/flashbar/flash.js +3 -3
- package/flashbar/flash.js.map +1 -1
- package/flashbar/styles.css.js +50 -50
- package/flashbar/styles.scoped.css +151 -164
- package/flashbar/styles.selectors.js +50 -50
- package/internal/environment.js +1 -1
- package/internal/environment.json +1 -1
- package/internal/manifest.json +1 -1
- package/internal/plugins/api.d.ts +3 -0
- package/internal/plugins/api.d.ts.map +1 -1
- package/internal/plugins/api.js +3 -0
- package/internal/plugins/api.js.map +1 -1
- package/internal/plugins/controllers/alert-flash-content.d.ts +9 -0
- package/internal/plugins/controllers/alert-flash-content.d.ts.map +1 -1
- package/internal/plugins/controllers/alert-flash-content.js +9 -1
- package/internal/plugins/controllers/alert-flash-content.js.map +1 -1
- package/internal/plugins/controllers/shared-react-contexts.d.ts +10 -0
- package/internal/plugins/controllers/shared-react-contexts.d.ts.map +1 -0
- package/internal/plugins/controllers/shared-react-contexts.js +27 -0
- package/internal/plugins/controllers/shared-react-contexts.js.map +1 -0
- package/internal/plugins/helpers/use-discovered-content.d.ts +3 -2
- package/internal/plugins/helpers/use-discovered-content.d.ts.map +1 -1
- package/internal/plugins/helpers/use-discovered-content.js +9 -2
- package/internal/plugins/helpers/use-discovered-content.js.map +1 -1
- package/internal/plugins/helpers/use-global-breadcrumbs.d.ts.map +1 -1
- package/internal/plugins/helpers/use-global-breadcrumbs.js +11 -3
- package/internal/plugins/helpers/use-global-breadcrumbs.js.map +1 -1
- package/multiselect/embedded.d.ts.map +1 -1
- package/multiselect/embedded.js +2 -7
- package/multiselect/embedded.js.map +1 -1
- package/multiselect/use-multiselect.d.ts +1 -1
- package/multiselect/use-multiselect.d.ts.map +1 -1
- package/multiselect/use-multiselect.js.map +1 -1
- package/package.json +1 -1
- package/property-filter/i18n-utils.d.ts.map +1 -1
- package/property-filter/i18n-utils.js +6 -3
- package/property-filter/i18n-utils.js.map +1 -1
- package/property-filter/index.d.ts.map +1 -1
- package/property-filter/index.js +20 -2
- package/property-filter/index.js.map +1 -1
- package/property-filter/interfaces.d.ts +4 -2
- package/property-filter/interfaces.d.ts.map +1 -1
- package/property-filter/interfaces.js.map +1 -1
- package/property-filter/internal.d.ts.map +1 -1
- package/property-filter/internal.js +5 -3
- package/property-filter/internal.js.map +1 -1
- package/property-filter/property-editor.d.ts +13 -2
- package/property-filter/property-editor.d.ts.map +1 -1
- package/property-filter/property-editor.js +19 -1
- package/property-filter/property-editor.js.map +1 -1
- package/property-filter/styles.css.js +39 -35
- package/property-filter/styles.scoped.css +66 -37
- package/property-filter/styles.selectors.js +39 -35
- package/property-filter/token-editor-inputs.d.ts +3 -3
- package/property-filter/token-editor-inputs.d.ts.map +1 -1
- package/property-filter/token-editor-inputs.js +29 -4
- package/property-filter/token-editor-inputs.js.map +1 -1
- package/property-filter/token-editor.d.ts.map +1 -1
- package/property-filter/token-editor.js +9 -1
- package/property-filter/token-editor.js.map +1 -1
- package/property-filter/utils.d.ts.map +1 -1
- package/property-filter/utils.js +10 -3
- package/property-filter/utils.js.map +1 -1
- package/select/utils/use-select.d.ts.map +1 -1
- package/select/utils/use-select.js +14 -7
- package/select/utils/use-select.js.map +1 -1
- package/table/use-column-widths.d.ts.map +1 -1
- package/table/use-column-widths.js +7 -1
- package/table/use-column-widths.js.map +1 -1
- package/test-utils/tsconfig.tsbuildinfo +1 -1
- package/text-filter/index.d.ts.map +1 -1
- package/text-filter/index.js +3 -1
- package/text-filter/index.js.map +1 -1
- package/text-filter/interfaces.d.ts +2 -1
- package/text-filter/interfaces.d.ts.map +1 -1
- package/text-filter/interfaces.js.map +1 -1
- package/text-filter/internal.d.ts.map +1 -1
- package/text-filter/internal.js +2 -2
- package/text-filter/internal.js.map +1 -1
- package/tutorial-panel/components/tutorial-detail-view/styles.css.js +20 -20
- package/tutorial-panel/components/tutorial-detail-view/styles.scoped.css +22 -21
- package/tutorial-panel/components/tutorial-detail-view/styles.selectors.js +20 -20
|
@@ -5,7 +5,7 @@ import { SelectListProps } from '../select/parts/plain-list';
|
|
|
5
5
|
import { TokenGroupProps } from '../token-group/interfaces';
|
|
6
6
|
import { MultiselectProps } from './interfaces';
|
|
7
7
|
type UseMultiselectOptions = SomeRequired<Pick<MultiselectProps, 'options' | 'selectedOptions' | 'filteringType' | 'filteringResultsText' | 'disabled' | 'noMatch' | 'renderHighlightedAriaLive' | 'deselectAriaLabel' | 'keepOpen' | 'onBlur' | 'onFocus' | 'onLoadItems' | 'onChange' | 'selectedAriaLabel'> & DropdownStatusProps & {
|
|
8
|
-
controlId
|
|
8
|
+
controlId?: string;
|
|
9
9
|
ariaLabelId: string;
|
|
10
10
|
footerId: string;
|
|
11
11
|
filteringValue: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-multiselect.d.ts","sourceRoot":"","sources":["../../../src/multiselect/use-multiselect.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAK9D,OAAO,EAAE,mBAAmB,EAAqB,MAAM,wCAAwC,CAAC;AAKhG,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAO7D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,KAAK,qBAAqB,GAAG,YAAY,CACvC,IAAI,CACF,gBAAgB,EACd,SAAS,GACT,iBAAiB,GACjB,eAAe,GACf,sBAAsB,GACtB,UAAU,GACV,SAAS,GACT,2BAA2B,GAC3B,mBAAmB,GACnB,UAAU,GACV,QAAQ,GACR,SAAS,GACT,aAAa,GACb,UAAU,GACV,mBAAmB,CACtB,GACC,mBAAmB,GAAG;IACpB,SAAS,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"use-multiselect.d.ts","sourceRoot":"","sources":["../../../src/multiselect/use-multiselect.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAK9D,OAAO,EAAE,mBAAmB,EAAqB,MAAM,wCAAwC,CAAC;AAKhG,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAO7D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,KAAK,qBAAqB,GAAG,YAAY,CACvC,IAAI,CACF,gBAAgB,EACd,SAAS,GACT,iBAAiB,GACjB,eAAe,GACf,sBAAsB,GACtB,UAAU,GACV,SAAS,GACT,2BAA2B,GAC3B,mBAAmB,GACnB,UAAU,GACV,QAAQ,GACR,SAAS,GACT,aAAa,GACb,UAAU,GACV,mBAAmB,CACtB,GACC,mBAAmB,GAAG;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C,WAAW,EAAE,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;CAC9C,EACH,SAAS,GAAG,iBAAiB,GAAG,eAAe,GAAG,YAAY,GAAG,UAAU,CAC5E,GAAG;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAE3B,wBAAgB,cAAc,CAAC,EAC7B,OAAO,EACP,aAAa,EACb,oBAAoB,EACpB,QAAQ,EACR,UAAU,EACV,KAAK,EACL,WAAW,EACX,YAAY,EACZ,SAAS,EACT,OAAO,EACP,yBAAyB,EACzB,eAAe,EACf,iBAAiB,EACjB,QAAQ,EACR,MAAM,EACN,OAAO,EACP,WAAW,EACX,QAAQ,EACR,SAAS,EACT,WAAW,EACX,QAAQ,EACR,cAAc,EACd,iBAAiB,EACjB,WAAW,EACX,QAAQ,EACR,GAAG,SAAS,EACb,EAAE,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BAqJc,gBAAgB;;;;;;;;;EAyCrD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-multiselect.js","sourceRoot":"","sources":["../../../src/multiselect/use-multiselect.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAc,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE9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IAAG;QACrF,eAAe,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC;KACzD,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useCallback, useEffect, useRef } from 'react';\n\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport { useInternalI18n } from '../i18n/context';\nimport { DropdownStatusProps, useDropdownStatus } from '../internal/components/dropdown-status';\nimport { OptionDefinition, OptionGroup } from '../internal/components/option/interfaces';\nimport { isGroup } from '../internal/components/option/utils/filter-options';\nimport { prepareOptions } from '../internal/components/option/utils/prepare-options';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { SomeRequired } from '../internal/types';\nimport { joinStrings } from '../internal/utils/strings';\nimport { SelectListProps } from '../select/parts/plain-list';\nimport { checkOptionValueField } from '../select/utils/check-option-value-field.js';\nimport { findOptionIndex } from '../select/utils/connect-options';\nimport { useAnnouncement } from '../select/utils/use-announcement';\nimport { useLoadItems } from '../select/utils/use-load-items';\nimport { useNativeSearch } from '../select/utils/use-native-search';\nimport { useSelect } from '../select/utils/use-select';\nimport { TokenGroupProps } from '../token-group/interfaces';\nimport { MultiselectProps } from './interfaces';\n\ntype UseMultiselectOptions = SomeRequired<\n Pick<\n MultiselectProps,\n | 'options'\n | 'selectedOptions'\n | 'filteringType'\n | 'filteringResultsText'\n | 'disabled'\n | 'noMatch'\n | 'renderHighlightedAriaLive'\n | 'deselectAriaLabel'\n | 'keepOpen'\n | 'onBlur'\n | 'onFocus'\n | 'onLoadItems'\n | 'onChange'\n | 'selectedAriaLabel'\n > &\n DropdownStatusProps & {\n controlId: string;\n ariaLabelId: string;\n footerId: string;\n filteringValue: string;\n setFilteringValue?: (value: string) => void;\n externalRef: React.Ref<MultiselectProps.Ref>;\n },\n 'options' | 'selectedOptions' | 'filteringType' | 'statusType' | 'keepOpen'\n> & { embedded?: boolean };\n\nexport function useMultiselect({\n options,\n filteringType,\n filteringResultsText,\n disabled,\n statusType,\n empty,\n loadingText,\n finishedText,\n errorText,\n noMatch,\n renderHighlightedAriaLive,\n selectedOptions,\n deselectAriaLabel,\n keepOpen,\n onBlur,\n onFocus,\n onLoadItems,\n onChange,\n controlId,\n ariaLabelId,\n footerId,\n filteringValue,\n setFilteringValue,\n externalRef,\n embedded,\n ...restProps\n}: UseMultiselectOptions) {\n checkOptionValueField('Multiselect', 'options', options);\n\n const i18n = useInternalI18n('multiselect');\n const i18nCommon = useInternalI18n('select');\n const recoveryText = i18nCommon('recoveryText', restProps.recoveryText);\n const errorIconAriaLabel = i18nCommon('errorIconAriaLabel', restProps.errorIconAriaLabel);\n const selectedAriaLabel = i18nCommon('selectedAriaLabel', restProps.selectedAriaLabel);\n\n if (restProps.recoveryText && !onLoadItems) {\n warnOnce('Multiselect', '`onLoadItems` must be provided for `recoveryText` to be displayed.');\n }\n\n const { handleLoadMore, handleRecoveryClick, fireLoadItems } = useLoadItems({\n onLoadItems,\n options,\n statusType,\n });\n const useInteractiveGroups = true;\n const { filteredOptions, parentMap, totalCount, matchesCount } = prepareOptions(\n options,\n filteringType,\n filteringValue\n );\n\n const updateSelectedOption = useCallback(\n (option: OptionDefinition | OptionGroup) => {\n const filtered = filteredOptions.filter(item => item.type !== 'parent').map(item => item.option);\n\n // switch between selection and deselection behavior, ignores disabled options to prevent\n // getting stuck on one behavior when an option is disabled and its state cannot be changed\n const isAllChildrenSelected = (optionsArray: OptionDefinition[]) =>\n optionsArray.every(item => findOptionIndex(selectedOptions, item) > -1 || item.disabled);\n const intersection = (visibleOptions: OptionDefinition[], options: OptionDefinition[]) =>\n visibleOptions.filter(item => findOptionIndex(options, item) > -1 && !item.disabled);\n const union = (visibleOptions: OptionDefinition[], options: OptionDefinition[]) =>\n visibleOptions.filter(item => findOptionIndex(options, item) === -1).concat(options);\n const select = (options: OptionDefinition[], selectedOptions: OptionDefinition[]) => {\n return union(selectedOptions, options);\n };\n const unselect = (options: OptionDefinition[], selectedOptions: OptionDefinition[]) => {\n return selectedOptions.filter(option => findOptionIndex(options, option) === -1);\n };\n let newSelectedOptions = [...selectedOptions];\n\n if (isGroup(option)) {\n const visibleOptions = intersection([...option.options], filtered);\n newSelectedOptions = isAllChildrenSelected(visibleOptions)\n ? unselect(visibleOptions, newSelectedOptions)\n : select(visibleOptions, newSelectedOptions);\n } else {\n newSelectedOptions = isAllChildrenSelected([option])\n ? unselect([option], newSelectedOptions)\n : select([option], newSelectedOptions);\n }\n\n fireNonCancelableEvent(onChange, {\n selectedOptions: newSelectedOptions,\n });\n },\n [onChange, selectedOptions, filteredOptions]\n );\n\n const scrollToIndex = useRef<SelectListProps.SelectListRef>(null);\n const {\n isOpen,\n highlightType,\n highlightedOption,\n highlightedIndex,\n getTriggerProps,\n getDropdownProps,\n getFilterProps,\n getMenuProps,\n getOptionProps,\n highlightOption,\n announceSelected,\n } = useSelect({\n selectedOptions,\n updateSelectedOption,\n options: filteredOptions,\n filteringType,\n onFocus,\n onBlur,\n externalRef,\n keepOpen,\n fireLoadItems,\n setFilteringValue,\n useInteractiveGroups,\n statusType,\n embedded,\n });\n\n const wrapperOnKeyDown = useNativeSearch({\n isEnabled: filteringType === 'none' && isOpen,\n options: filteredOptions,\n highlightOption: highlightOption,\n highlightedOption: highlightedOption?.option,\n useInteractiveGroups,\n });\n\n const isEmpty = !options || options.length === 0;\n const isNoMatch = filteredOptions && filteredOptions.length === 0;\n const isFiltered =\n filteringType !== 'none' && filteringValue.length > 0 && filteredOptions && filteredOptions.length > 0;\n const filteredText = isFiltered ? filteringResultsText?.(matchesCount, totalCount) : undefined;\n const dropdownStatus = useDropdownStatus({\n statusType,\n empty,\n loadingText,\n finishedText,\n errorText,\n recoveryText,\n isEmpty,\n isNoMatch,\n noMatch,\n isFiltered,\n filteringResultsText: filteredText,\n onRecoveryClick: handleRecoveryClick,\n errorIconAriaLabel: errorIconAriaLabel,\n hasRecoveryCallback: !!onLoadItems,\n });\n\n const announcement = useAnnouncement({\n announceSelected,\n highlightedOption,\n getParent: option => parentMap.get(option)?.option as undefined | OptionGroup,\n selectedAriaLabel,\n renderHighlightedAriaLive,\n });\n\n const tokens: TokenGroupProps['items'] = selectedOptions.map(option => ({\n label: option.label,\n disabled: disabled || option.disabled,\n labelTag: option.labelTag,\n description: option.description,\n iconAlt: option.iconAlt,\n iconName: option.iconName,\n iconUrl: option.iconUrl,\n iconSvg: option.iconSvg,\n tags: option.tags,\n dismissLabel: i18n('deselectAriaLabel', deselectAriaLabel?.(option), format =>\n format({ option__label: option.label ?? '' })\n ),\n }));\n\n useEffect(() => {\n scrollToIndex.current?.(highlightedIndex);\n }, [highlightedIndex]);\n\n const dropdownOnMouseDown = (event: React.MouseEvent) => {\n const target = event.target as HTMLElement;\n\n if (target !== document.activeElement) {\n // prevent currently focused element from losing it\n event.preventDefault();\n }\n };\n\n const tokenOnDismiss: TokenGroupProps['onDismiss'] = ({ detail }) => {\n const optionToDeselect = selectedOptions[detail.itemIndex];\n updateSelectedOption(optionToDeselect);\n const targetRef = getTriggerProps().ref;\n if (targetRef.current) {\n targetRef.current.focus();\n }\n };\n\n return {\n isOpen,\n tokens,\n announcement,\n dropdownStatus,\n filteringValue,\n filteredOptions,\n highlightType,\n scrollToIndex,\n getFilterProps,\n getTriggerProps,\n getMenuProps: () => ({\n ...getMenuProps(),\n onLoadMore: handleLoadMore,\n ariaLabelledby: joinStrings(ariaLabelId, controlId),\n ariaDescribedby: dropdownStatus.content ? footerId : undefined,\n embedded,\n }),\n getOptionProps,\n getTokenProps: () => ({ onDismiss: tokenOnDismiss }),\n getDropdownProps: () => ({ ...getDropdownProps(), onMouseDown: dropdownOnMouseDown }),\n getWrapperProps: () => ({ onKeyDown: wrapperOnKeyDown }),\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"use-multiselect.js","sourceRoot":"","sources":["../../../src/multiselect/use-multiselect.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AAC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AAC;QACpD,gBAAgB,EAAE,GAAG,EAAE,CAAC,iCAAM,gBAAgB,EAAE,KAAE,WAAW,EAAE,mBAAmB,IAAG;QACrF,eAAe,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC;KACzD,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useCallback, useEffect, useRef } from 'react';\n\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport { useInternalI18n } from '../i18n/context';\nimport { DropdownStatusProps, useDropdownStatus } from '../internal/components/dropdown-status';\nimport { OptionDefinition, OptionGroup } from '../internal/components/option/interfaces';\nimport { isGroup } from '../internal/components/option/utils/filter-options';\nimport { prepareOptions } from '../internal/components/option/utils/prepare-options';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { SomeRequired } from '../internal/types';\nimport { joinStrings } from '../internal/utils/strings';\nimport { SelectListProps } from '../select/parts/plain-list';\nimport { checkOptionValueField } from '../select/utils/check-option-value-field.js';\nimport { findOptionIndex } from '../select/utils/connect-options';\nimport { useAnnouncement } from '../select/utils/use-announcement';\nimport { useLoadItems } from '../select/utils/use-load-items';\nimport { useNativeSearch } from '../select/utils/use-native-search';\nimport { useSelect } from '../select/utils/use-select';\nimport { TokenGroupProps } from '../token-group/interfaces';\nimport { MultiselectProps } from './interfaces';\n\ntype UseMultiselectOptions = SomeRequired<\n Pick<\n MultiselectProps,\n | 'options'\n | 'selectedOptions'\n | 'filteringType'\n | 'filteringResultsText'\n | 'disabled'\n | 'noMatch'\n | 'renderHighlightedAriaLive'\n | 'deselectAriaLabel'\n | 'keepOpen'\n | 'onBlur'\n | 'onFocus'\n | 'onLoadItems'\n | 'onChange'\n | 'selectedAriaLabel'\n > &\n DropdownStatusProps & {\n controlId?: string;\n ariaLabelId: string;\n footerId: string;\n filteringValue: string;\n setFilteringValue?: (value: string) => void;\n externalRef: React.Ref<MultiselectProps.Ref>;\n },\n 'options' | 'selectedOptions' | 'filteringType' | 'statusType' | 'keepOpen'\n> & { embedded?: boolean };\n\nexport function useMultiselect({\n options,\n filteringType,\n filteringResultsText,\n disabled,\n statusType,\n empty,\n loadingText,\n finishedText,\n errorText,\n noMatch,\n renderHighlightedAriaLive,\n selectedOptions,\n deselectAriaLabel,\n keepOpen,\n onBlur,\n onFocus,\n onLoadItems,\n onChange,\n controlId,\n ariaLabelId,\n footerId,\n filteringValue,\n setFilteringValue,\n externalRef,\n embedded,\n ...restProps\n}: UseMultiselectOptions) {\n checkOptionValueField('Multiselect', 'options', options);\n\n const i18n = useInternalI18n('multiselect');\n const i18nCommon = useInternalI18n('select');\n const recoveryText = i18nCommon('recoveryText', restProps.recoveryText);\n const errorIconAriaLabel = i18nCommon('errorIconAriaLabel', restProps.errorIconAriaLabel);\n const selectedAriaLabel = i18nCommon('selectedAriaLabel', restProps.selectedAriaLabel);\n\n if (restProps.recoveryText && !onLoadItems) {\n warnOnce('Multiselect', '`onLoadItems` must be provided for `recoveryText` to be displayed.');\n }\n\n const { handleLoadMore, handleRecoveryClick, fireLoadItems } = useLoadItems({\n onLoadItems,\n options,\n statusType,\n });\n const useInteractiveGroups = true;\n const { filteredOptions, parentMap, totalCount, matchesCount } = prepareOptions(\n options,\n filteringType,\n filteringValue\n );\n\n const updateSelectedOption = useCallback(\n (option: OptionDefinition | OptionGroup) => {\n const filtered = filteredOptions.filter(item => item.type !== 'parent').map(item => item.option);\n\n // switch between selection and deselection behavior, ignores disabled options to prevent\n // getting stuck on one behavior when an option is disabled and its state cannot be changed\n const isAllChildrenSelected = (optionsArray: OptionDefinition[]) =>\n optionsArray.every(item => findOptionIndex(selectedOptions, item) > -1 || item.disabled);\n const intersection = (visibleOptions: OptionDefinition[], options: OptionDefinition[]) =>\n visibleOptions.filter(item => findOptionIndex(options, item) > -1 && !item.disabled);\n const union = (visibleOptions: OptionDefinition[], options: OptionDefinition[]) =>\n visibleOptions.filter(item => findOptionIndex(options, item) === -1).concat(options);\n const select = (options: OptionDefinition[], selectedOptions: OptionDefinition[]) => {\n return union(selectedOptions, options);\n };\n const unselect = (options: OptionDefinition[], selectedOptions: OptionDefinition[]) => {\n return selectedOptions.filter(option => findOptionIndex(options, option) === -1);\n };\n let newSelectedOptions = [...selectedOptions];\n\n if (isGroup(option)) {\n const visibleOptions = intersection([...option.options], filtered);\n newSelectedOptions = isAllChildrenSelected(visibleOptions)\n ? unselect(visibleOptions, newSelectedOptions)\n : select(visibleOptions, newSelectedOptions);\n } else {\n newSelectedOptions = isAllChildrenSelected([option])\n ? unselect([option], newSelectedOptions)\n : select([option], newSelectedOptions);\n }\n\n fireNonCancelableEvent(onChange, {\n selectedOptions: newSelectedOptions,\n });\n },\n [onChange, selectedOptions, filteredOptions]\n );\n\n const scrollToIndex = useRef<SelectListProps.SelectListRef>(null);\n const {\n isOpen,\n highlightType,\n highlightedOption,\n highlightedIndex,\n getTriggerProps,\n getDropdownProps,\n getFilterProps,\n getMenuProps,\n getOptionProps,\n highlightOption,\n announceSelected,\n } = useSelect({\n selectedOptions,\n updateSelectedOption,\n options: filteredOptions,\n filteringType,\n onFocus,\n onBlur,\n externalRef,\n keepOpen,\n fireLoadItems,\n setFilteringValue,\n useInteractiveGroups,\n statusType,\n embedded,\n });\n\n const wrapperOnKeyDown = useNativeSearch({\n isEnabled: filteringType === 'none' && isOpen,\n options: filteredOptions,\n highlightOption: highlightOption,\n highlightedOption: highlightedOption?.option,\n useInteractiveGroups,\n });\n\n const isEmpty = !options || options.length === 0;\n const isNoMatch = filteredOptions && filteredOptions.length === 0;\n const isFiltered =\n filteringType !== 'none' && filteringValue.length > 0 && filteredOptions && filteredOptions.length > 0;\n const filteredText = isFiltered ? filteringResultsText?.(matchesCount, totalCount) : undefined;\n const dropdownStatus = useDropdownStatus({\n statusType,\n empty,\n loadingText,\n finishedText,\n errorText,\n recoveryText,\n isEmpty,\n isNoMatch,\n noMatch,\n isFiltered,\n filteringResultsText: filteredText,\n onRecoveryClick: handleRecoveryClick,\n errorIconAriaLabel: errorIconAriaLabel,\n hasRecoveryCallback: !!onLoadItems,\n });\n\n const announcement = useAnnouncement({\n announceSelected,\n highlightedOption,\n getParent: option => parentMap.get(option)?.option as undefined | OptionGroup,\n selectedAriaLabel,\n renderHighlightedAriaLive,\n });\n\n const tokens: TokenGroupProps['items'] = selectedOptions.map(option => ({\n label: option.label,\n disabled: disabled || option.disabled,\n labelTag: option.labelTag,\n description: option.description,\n iconAlt: option.iconAlt,\n iconName: option.iconName,\n iconUrl: option.iconUrl,\n iconSvg: option.iconSvg,\n tags: option.tags,\n dismissLabel: i18n('deselectAriaLabel', deselectAriaLabel?.(option), format =>\n format({ option__label: option.label ?? '' })\n ),\n }));\n\n useEffect(() => {\n scrollToIndex.current?.(highlightedIndex);\n }, [highlightedIndex]);\n\n const dropdownOnMouseDown = (event: React.MouseEvent) => {\n const target = event.target as HTMLElement;\n\n if (target !== document.activeElement) {\n // prevent currently focused element from losing it\n event.preventDefault();\n }\n };\n\n const tokenOnDismiss: TokenGroupProps['onDismiss'] = ({ detail }) => {\n const optionToDeselect = selectedOptions[detail.itemIndex];\n updateSelectedOption(optionToDeselect);\n const targetRef = getTriggerProps().ref;\n if (targetRef.current) {\n targetRef.current.focus();\n }\n };\n\n return {\n isOpen,\n tokens,\n announcement,\n dropdownStatus,\n filteringValue,\n filteredOptions,\n highlightType,\n scrollToIndex,\n getFilterProps,\n getTriggerProps,\n getMenuProps: () => ({\n ...getMenuProps(),\n onLoadMore: handleLoadMore,\n ariaLabelledby: joinStrings(ariaLabelId, controlId),\n ariaDescribedby: dropdownStatus.content ? footerId : undefined,\n embedded,\n }),\n getOptionProps,\n getTokenProps: () => ({ onDismiss: tokenOnDismiss }),\n getDropdownProps: () => ({ ...getDropdownProps(), onMouseDown: dropdownOnMouseDown }),\n getWrapperProps: () => ({ onKeyDown: wrapperOnKeyDown }),\n };\n}\n"]}
|
package/package.json
CHANG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wBAAgB,qBAAqB,CAAC,GAAG,GAAE,WAAgB,GAAG,mBAAmB,CA4IhF;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,kBAAkB,EAAE,WAAW,EAAE,oBAAoB,sBA4BpG"}
|
|
@@ -14,11 +14,14 @@ export function usePropertyFilterI18n(def = {}) {
|
|
|
14
14
|
token__value: token.value,
|
|
15
15
|
}))) !== null && _a !== void 0 ? _a : (token => `${token.propertyLabel} ${token.operator} ${token.value}`);
|
|
16
16
|
function toFormatted(token) {
|
|
17
|
-
var _a, _b;
|
|
18
|
-
|
|
17
|
+
var _a, _b, _c;
|
|
18
|
+
let valueFormatter = (_a = token.property) === null || _a === void 0 ? void 0 : _a.getValueFormatter(token.operator);
|
|
19
|
+
if (!valueFormatter && ((_b = token.property) === null || _b === void 0 ? void 0 : _b.getTokenType(token.operator)) === 'enum') {
|
|
20
|
+
valueFormatter = value => (Array.isArray(value) ? value.join(', ') : value);
|
|
21
|
+
}
|
|
19
22
|
const propertyLabel = token.property ? token.property.propertyLabel : allPropertiesLabel !== null && allPropertiesLabel !== void 0 ? allPropertiesLabel : '';
|
|
20
23
|
const tokenValue = valueFormatter ? valueFormatter(token.value) : token.value;
|
|
21
|
-
return { propertyKey: (
|
|
24
|
+
return { propertyKey: (_c = token.property) === null || _c === void 0 ? void 0 : _c.propertyKey, propertyLabel, operator: token.operator, value: tokenValue };
|
|
22
25
|
}
|
|
23
26
|
return Object.assign(Object.assign({}, def), { allPropertiesLabel,
|
|
24
27
|
operationAndText,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n-utils.js","sourceRoot":"","sources":["../../../src/property-filter/i18n-utils.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AA0C7C,MAAM,UAAU,qBAAqB,CAAC,MAAmB,EAA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B,CAAC,QAA4B;IACzD,QAAQ,QAAQ,EAAE;QAChB,KAAK,GAAG;YACN,OAAO,QAAQ,CAAC;QAClB,KAAK,IAAI;YACP,OAAO,YAAY,CAAC;QACtB,KAAK,GAAG;YACN,OAAO,cAAc,CAAC;QACxB,KAAK,IAAI;YACP,OAAO,oBAAoB,CAAC;QAC9B,KAAK,GAAG;YACN,OAAO,WAAW,CAAC;QACrB,KAAK,IAAI;YACP,OAAO,iBAAiB,CAAC;QAC3B,KAAK,GAAG;YACN,OAAO,UAAU,CAAC;QACpB,KAAK,IAAI;YACP,OAAO,cAAc,CAAC;QACxB,KAAK,GAAG;YACN,OAAO,aAAa,CAAC;QACvB,KAAK,IAAI;YACP,OAAO,iBAAiB,CAAC;QAC3B,iEAAiE;QACjE,sFAAsF;QACtF,0BAA0B;QAC1B;YACE,OAAO,QAAQ,CAAC;KACnB;AACH,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useInternalI18n } from '../i18n/context';\nimport { ComparisonOperator, FormattedToken, I18nStrings, InternalToken, InternalTokenGroup } from './interfaces';\nimport { tokenGroupToTokens } from './utils';\n\nexport type I18nStringsOperators = Pick<\n I18nStrings,\n | 'operatorLessText'\n | 'operatorLessOrEqualText'\n | 'operatorGreaterText'\n | 'operatorGreaterOrEqualText'\n | 'operatorContainsText'\n | 'operatorDoesNotContainText'\n | 'operatorEqualsText'\n | 'operatorDoesNotEqualText'\n | 'operatorStartsWithText'\n | 'operatorDoesNotStartWithText'\n>;\n\n// Replacing i18n function with ones taking internal tokens as argument.\nexport type I18nStringsInternal = Omit<\n I18nStrings,\n | 'formatToken'\n | 'removeTokenButtonAriaLabel'\n | 'groupEditAriaLabel'\n | 'tokenEditorTokenActionsAriaLabel'\n | 'tokenEditorTokenRemoveAriaLabel'\n | 'tokenEditorAddExistingTokenAriaLabel'\n | 'tokenEditorAddExistingTokenLabel'\n> & {\n formatToken: (token: InternalToken) => {\n propertyLabel: string;\n operator: string;\n value: string;\n formattedText: string;\n };\n groupAriaLabel: (group: InternalTokenGroup) => string;\n groupEditAriaLabel: (group: InternalTokenGroup) => string;\n removeTokenButtonAriaLabel: (token: InternalToken) => string;\n tokenEditorTokenActionsAriaLabel: (token: InternalToken) => string;\n tokenEditorTokenRemoveAriaLabel: (token: InternalToken) => string;\n tokenEditorAddExistingTokenAriaLabel: (token: InternalToken) => string;\n tokenEditorAddExistingTokenLabel: (token: InternalToken) => string;\n};\n\nexport function usePropertyFilterI18n(def: I18nStrings = {}): I18nStringsInternal {\n const i18n = useInternalI18n('property-filter');\n\n const allPropertiesLabel = i18n('i18nStrings.allPropertiesLabel', def?.allPropertiesLabel);\n const operationAndText = i18n('i18nStrings.operationAndText', def?.operationAndText);\n const operationOrText = i18n('i18nStrings.operationOrText', def?.operationOrText);\n const formatToken =\n i18n(\n 'i18nStrings.formatToken',\n def.formatToken,\n format => token =>\n format({\n token__propertyLabel: token.propertyLabel,\n token__operator: getOperatorI18nString(token.operator),\n token__value: token.value,\n })\n ) ?? (token => `${token.propertyLabel} ${token.operator} ${token.value}`);\n\n function toFormatted(token: InternalToken): FormattedToken {\n const valueFormatter = token.property?.getValueFormatter(token.operator);\n const propertyLabel = token.property ? token.property.propertyLabel : allPropertiesLabel ?? '';\n const tokenValue = valueFormatter ? valueFormatter(token.value) : token.value;\n return { propertyKey: token.property?.propertyKey, propertyLabel, operator: token.operator, value: tokenValue };\n }\n\n return {\n ...def,\n allPropertiesLabel,\n operationAndText,\n operationOrText,\n applyActionText: i18n('i18nStrings.applyActionText', def?.applyActionText),\n cancelActionText: i18n('i18nStrings.cancelActionText', def?.cancelActionText),\n clearFiltersText: i18n('i18nStrings.clearFiltersText', def?.clearFiltersText),\n editTokenHeader: i18n('i18nStrings.editTokenHeader', def?.editTokenHeader),\n groupPropertiesText: i18n('i18nStrings.groupPropertiesText', def?.groupPropertiesText),\n groupValuesText: i18n('i18nStrings.groupValuesText', def?.groupValuesText),\n operatorContainsText: i18n('i18nStrings.operatorContainsText', def?.operatorContainsText),\n operatorDoesNotContainText: i18n('i18nStrings.operatorDoesNotContainText', def?.operatorDoesNotContainText),\n operatorDoesNotEqualText: i18n('i18nStrings.operatorDoesNotEqualText', def?.operatorDoesNotEqualText),\n operatorEqualsText: i18n('i18nStrings.operatorEqualsText', def?.operatorEqualsText),\n operatorGreaterOrEqualText: i18n('i18nStrings.operatorGreaterOrEqualText', def?.operatorGreaterOrEqualText),\n operatorGreaterText: i18n('i18nStrings.operatorGreaterText', def?.operatorGreaterText),\n operatorLessOrEqualText: i18n('i18nStrings.operatorLessOrEqualText', def?.operatorLessOrEqualText),\n operatorLessText: i18n('i18nStrings.operatorLessText', def?.operatorLessText),\n operatorStartsWithText: i18n('i18nStrings.operatorStartsWithText', def?.operatorStartsWithText),\n operatorDoesNotStartWithText: i18n('i18nStrings.operatorDoesNotStartWithText', def?.operatorDoesNotStartWithText),\n operatorText: i18n('i18nStrings.operatorText', def?.operatorText),\n operatorsText: i18n('i18nStrings.operatorsText', def?.operatorsText),\n propertyText: i18n('i18nStrings.propertyText', def?.propertyText),\n tokenLimitShowFewer: i18n('i18nStrings.tokenLimitShowFewer', def?.tokenLimitShowFewer),\n tokenLimitShowMore: i18n('i18nStrings.tokenLimitShowMore', def?.tokenLimitShowMore),\n valueText: i18n('i18nStrings.valueText', def?.valueText),\n tokenEditorTokenRemoveLabel: i18n('i18nStrings.tokenEditorTokenRemoveLabel', def?.tokenEditorTokenRemoveLabel),\n tokenEditorTokenRemoveFromGroupLabel: i18n(\n 'i18nStrings.tokenEditorTokenRemoveFromGroupLabel',\n def?.tokenEditorTokenRemoveFromGroupLabel\n ),\n tokenEditorAddNewTokenLabel: i18n('i18nStrings.tokenEditorAddNewTokenLabel', def?.tokenEditorAddNewTokenLabel),\n tokenEditorAddTokenActionsAriaLabel: i18n(\n 'i18nStrings.tokenEditorAddTokenActionsAriaLabel',\n def?.tokenEditorAddTokenActionsAriaLabel\n ),\n formatToken: token => {\n const formattedToken = toFormatted(token);\n return { ...formattedToken, formattedText: formatToken(toFormatted(token)) };\n },\n groupAriaLabel: group => {\n const tokens = tokenGroupToTokens<InternalToken>(group.tokens).map(toFormatted);\n const groupOperationLabel = (group.operation === 'and' ? operationAndText : operationOrText) ?? '';\n return tokens.map(token => formatToken(token)).join(` ${groupOperationLabel} `);\n },\n groupEditAriaLabel: group => {\n const tokens = tokenGroupToTokens<InternalToken>(group.tokens).map(token => toFormatted(token));\n const operation = group.operation;\n const operationLabel = (operation === 'and' ? operationAndText : operationOrText) ?? '';\n const formatter = i18n(\n 'i18nStrings.groupEditAriaLabel',\n def.groupEditAriaLabel,\n format => () =>\n format({\n group__operationLabel: operationLabel,\n group__formattedTokens__length: tokens.length.toString(),\n group__formattedTokens0__formattedText: tokens[0] ? formatToken(tokens[0]) : '',\n group__formattedTokens1__formattedText: tokens[1] ? formatToken(tokens[1]) : '',\n group__formattedTokens2__formattedText: tokens[2] ? formatToken(tokens[2]) : '',\n group__formattedTokens3__formattedText: tokens[3] ? formatToken(tokens[3]) : '',\n })\n );\n return formatter?.({ operation, operationLabel, tokens }) ?? '';\n },\n removeTokenButtonAriaLabel: token => {\n const formatter = i18n(\n 'i18nStrings.removeTokenButtonAriaLabel',\n def.removeTokenButtonAriaLabel,\n format => () => format({ token__formattedText: formatToken(toFormatted(token)) })\n );\n return formatter?.(toFormatted(token)) ?? '';\n },\n tokenEditorTokenActionsAriaLabel: (token: InternalToken) => {\n const formatter = i18n(\n 'i18nStrings.tokenEditorTokenActionsAriaLabel',\n def.tokenEditorTokenActionsAriaLabel,\n format => () => format({ token__formattedText: formatToken(toFormatted(token)) })\n );\n return formatter?.(toFormatted(token)) ?? '';\n },\n tokenEditorTokenRemoveAriaLabel: token => {\n const formatter = i18n(\n 'i18nStrings.tokenEditorTokenRemoveAriaLabel',\n def.tokenEditorTokenRemoveAriaLabel,\n format => () => format({ token__formattedText: formatToken(toFormatted(token)) })\n );\n return formatter?.(toFormatted(token)) ?? '';\n },\n tokenEditorAddExistingTokenAriaLabel: token => {\n const formatter = i18n(\n 'i18nStrings.tokenEditorAddExistingTokenAriaLabel',\n def.tokenEditorAddExistingTokenAriaLabel,\n format => () => format({ token__formattedText: formatToken(toFormatted(token)) })\n );\n return formatter?.(toFormatted(token)) ?? '';\n },\n tokenEditorAddExistingTokenLabel: token => {\n const formattedToken = toFormatted(token);\n const formatter = i18n(\n 'i18nStrings.tokenEditorAddExistingTokenLabel',\n def.tokenEditorAddExistingTokenLabel,\n format => () =>\n format({\n token__propertyLabel: formattedToken.propertyLabel,\n token__operator: formattedToken.operator,\n token__value: formattedToken.value,\n })\n );\n return formatter?.(toFormatted(token)) ?? '';\n },\n };\n}\n\nexport function operatorToDescription(operator: ComparisonOperator, i18nStrings: I18nStringsOperators) {\n switch (operator) {\n case '<':\n return i18nStrings.operatorLessText;\n case '<=':\n return i18nStrings.operatorLessOrEqualText;\n case '>':\n return i18nStrings.operatorGreaterText;\n case '>=':\n return i18nStrings.operatorGreaterOrEqualText;\n case ':':\n return i18nStrings.operatorContainsText;\n case '!:':\n return i18nStrings.operatorDoesNotContainText;\n case '=':\n return i18nStrings.operatorEqualsText;\n case '!=':\n return i18nStrings.operatorDoesNotEqualText;\n case '^':\n return i18nStrings.operatorStartsWithText;\n case '!^':\n return i18nStrings.operatorDoesNotStartWithText;\n // The line is ignored from coverage because it is not reachable.\n // The purpose of it is to prevent TS errors if ComparisonOperator type gets extended.\n /* istanbul ignore next */\n default:\n return '';\n }\n}\n\nfunction getOperatorI18nString(operator: ComparisonOperator): string {\n switch (operator) {\n case '=':\n return 'equals';\n case '!=':\n return 'not_equals';\n case '>':\n return 'greater_than';\n case '>=':\n return 'greater_than_equal';\n case '<':\n return 'less_than';\n case '<=':\n return 'less_than_equal';\n case ':':\n return 'contains';\n case '!:':\n return 'not_contains';\n case '^':\n return 'starts_with';\n case '!^':\n return 'not_starts_with';\n // The line is ignored from coverage because it is not reachable.\n // The purpose of it is to prevent TS errors if ComparisonOperator type gets extended.\n /* istanbul ignore next */\n default:\n return operator;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"i18n-utils.js","sourceRoot":"","sources":["../../../src/property-filter/i18n-utils.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AA0C7C,MAAM,UAAU,qBAAqB,CAAC,MAAmB,EAAE;;IACzD,MAAM,IAAI,GAAG,eAAe,CAAC,iBAAiB,CAAC,CAAC;IAEhD,MAAM,kBAAkB,GAAG,IAAI,CAAC,gCAAgC,EAAE,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,kBAAkB,CAAC,CAAC;IAC3F,MAAM,gBAAgB,GAAG,IAAI,CAAC,8BAA8B,EAAE,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,gBAAgB,CAAC,CAAC;IACrF,MAAM,eAAe,GAAG,IAAI,CAAC,6BAA6B,EAAE,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,eAAe,CAAC,CAAC;IAClF,MAAM,WAAW,GACf,MAAA,IAAI,CACF,yBAAyB,EACzB,GAAG,CAAC,WAAW,EACf,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAChB,MAAM,CAAC;QACL,oBAAoB,EAAE,KAAK,CAAC,aAAa;QACzC,eAAe,EAAE,qBAAqB,CAAC,KAAK,CAAC,QAAQ,CAAC;QACtD,YAAY,EAAE,KAAK,CAAC,KAAK;KAC1B,CAAC,CACL,mCAAI,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,aAAa,IAAI,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;IAE5E,SAAS,WAAW,CAAC,KAAoB;;QACvC,IAAI,cAAc,GAAG,MAAA,KAAK,CAAC,QAAQ,0CA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affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useInternalI18n } from '../i18n/context';\nimport { ComparisonOperator, FormattedToken, I18nStrings, InternalToken, InternalTokenGroup } from './interfaces';\nimport { tokenGroupToTokens } from './utils';\n\nexport type I18nStringsOperators = Pick<\n I18nStrings,\n | 'operatorLessText'\n | 'operatorLessOrEqualText'\n | 'operatorGreaterText'\n | 'operatorGreaterOrEqualText'\n | 'operatorContainsText'\n | 'operatorDoesNotContainText'\n | 'operatorEqualsText'\n | 'operatorDoesNotEqualText'\n | 'operatorStartsWithText'\n | 'operatorDoesNotStartWithText'\n>;\n\n// Replacing i18n function with ones taking internal tokens as argument.\nexport type I18nStringsInternal = Omit<\n I18nStrings,\n | 'formatToken'\n | 'removeTokenButtonAriaLabel'\n | 'groupEditAriaLabel'\n | 'tokenEditorTokenActionsAriaLabel'\n | 'tokenEditorTokenRemoveAriaLabel'\n | 'tokenEditorAddExistingTokenAriaLabel'\n | 'tokenEditorAddExistingTokenLabel'\n> & {\n formatToken: (token: InternalToken) => {\n propertyLabel: string;\n operator: string;\n value: string;\n formattedText: string;\n };\n groupAriaLabel: (group: InternalTokenGroup) => string;\n groupEditAriaLabel: (group: InternalTokenGroup) => string;\n removeTokenButtonAriaLabel: (token: InternalToken) => string;\n tokenEditorTokenActionsAriaLabel: (token: InternalToken) => string;\n tokenEditorTokenRemoveAriaLabel: (token: InternalToken) => string;\n tokenEditorAddExistingTokenAriaLabel: (token: InternalToken) => string;\n tokenEditorAddExistingTokenLabel: (token: InternalToken) => string;\n};\n\nexport function usePropertyFilterI18n(def: I18nStrings = {}): I18nStringsInternal {\n const i18n = useInternalI18n('property-filter');\n\n const allPropertiesLabel = i18n('i18nStrings.allPropertiesLabel', def?.allPropertiesLabel);\n const operationAndText = i18n('i18nStrings.operationAndText', def?.operationAndText);\n const operationOrText = i18n('i18nStrings.operationOrText', def?.operationOrText);\n const formatToken =\n i18n(\n 'i18nStrings.formatToken',\n def.formatToken,\n format => token =>\n format({\n token__propertyLabel: token.propertyLabel,\n token__operator: getOperatorI18nString(token.operator),\n token__value: token.value,\n })\n ) ?? (token => `${token.propertyLabel} ${token.operator} ${token.value}`);\n\n function toFormatted(token: InternalToken): FormattedToken {\n let valueFormatter = token.property?.getValueFormatter(token.operator);\n if (!valueFormatter && token.property?.getTokenType(token.operator) === 'enum') {\n valueFormatter = value => (Array.isArray(value) ? value.join(', ') : value);\n }\n const propertyLabel = token.property ? token.property.propertyLabel : allPropertiesLabel ?? '';\n const tokenValue = valueFormatter ? valueFormatter(token.value) : token.value;\n return { propertyKey: token.property?.propertyKey, propertyLabel, operator: token.operator, value: tokenValue };\n }\n\n return {\n ...def,\n allPropertiesLabel,\n operationAndText,\n operationOrText,\n applyActionText: i18n('i18nStrings.applyActionText', def?.applyActionText),\n cancelActionText: i18n('i18nStrings.cancelActionText', def?.cancelActionText),\n clearFiltersText: i18n('i18nStrings.clearFiltersText', def?.clearFiltersText),\n editTokenHeader: i18n('i18nStrings.editTokenHeader', def?.editTokenHeader),\n groupPropertiesText: i18n('i18nStrings.groupPropertiesText', def?.groupPropertiesText),\n groupValuesText: i18n('i18nStrings.groupValuesText', def?.groupValuesText),\n operatorContainsText: i18n('i18nStrings.operatorContainsText', def?.operatorContainsText),\n operatorDoesNotContainText: i18n('i18nStrings.operatorDoesNotContainText', def?.operatorDoesNotContainText),\n operatorDoesNotEqualText: i18n('i18nStrings.operatorDoesNotEqualText', def?.operatorDoesNotEqualText),\n operatorEqualsText: i18n('i18nStrings.operatorEqualsText', def?.operatorEqualsText),\n operatorGreaterOrEqualText: i18n('i18nStrings.operatorGreaterOrEqualText', def?.operatorGreaterOrEqualText),\n operatorGreaterText: i18n('i18nStrings.operatorGreaterText', def?.operatorGreaterText),\n operatorLessOrEqualText: i18n('i18nStrings.operatorLessOrEqualText', def?.operatorLessOrEqualText),\n operatorLessText: i18n('i18nStrings.operatorLessText', def?.operatorLessText),\n operatorStartsWithText: i18n('i18nStrings.operatorStartsWithText', def?.operatorStartsWithText),\n operatorDoesNotStartWithText: i18n('i18nStrings.operatorDoesNotStartWithText', def?.operatorDoesNotStartWithText),\n operatorText: i18n('i18nStrings.operatorText', def?.operatorText),\n operatorsText: i18n('i18nStrings.operatorsText', def?.operatorsText),\n propertyText: i18n('i18nStrings.propertyText', def?.propertyText),\n tokenLimitShowFewer: i18n('i18nStrings.tokenLimitShowFewer', def?.tokenLimitShowFewer),\n tokenLimitShowMore: i18n('i18nStrings.tokenLimitShowMore', def?.tokenLimitShowMore),\n valueText: i18n('i18nStrings.valueText', def?.valueText),\n tokenEditorTokenRemoveLabel: i18n('i18nStrings.tokenEditorTokenRemoveLabel', def?.tokenEditorTokenRemoveLabel),\n tokenEditorTokenRemoveFromGroupLabel: i18n(\n 'i18nStrings.tokenEditorTokenRemoveFromGroupLabel',\n def?.tokenEditorTokenRemoveFromGroupLabel\n ),\n tokenEditorAddNewTokenLabel: i18n('i18nStrings.tokenEditorAddNewTokenLabel', def?.tokenEditorAddNewTokenLabel),\n tokenEditorAddTokenActionsAriaLabel: i18n(\n 'i18nStrings.tokenEditorAddTokenActionsAriaLabel',\n def?.tokenEditorAddTokenActionsAriaLabel\n ),\n formatToken: token => {\n const formattedToken = toFormatted(token);\n return { ...formattedToken, formattedText: formatToken(toFormatted(token)) };\n },\n groupAriaLabel: group => {\n const tokens = tokenGroupToTokens<InternalToken>(group.tokens).map(toFormatted);\n const groupOperationLabel = (group.operation === 'and' ? operationAndText : operationOrText) ?? '';\n return tokens.map(token => formatToken(token)).join(` ${groupOperationLabel} `);\n },\n groupEditAriaLabel: group => {\n const tokens = tokenGroupToTokens<InternalToken>(group.tokens).map(token => toFormatted(token));\n const operation = group.operation;\n const operationLabel = (operation === 'and' ? operationAndText : operationOrText) ?? '';\n const formatter = i18n(\n 'i18nStrings.groupEditAriaLabel',\n def.groupEditAriaLabel,\n format => () =>\n format({\n group__operationLabel: operationLabel,\n group__formattedTokens__length: tokens.length.toString(),\n group__formattedTokens0__formattedText: tokens[0] ? formatToken(tokens[0]) : '',\n group__formattedTokens1__formattedText: tokens[1] ? formatToken(tokens[1]) : '',\n group__formattedTokens2__formattedText: tokens[2] ? formatToken(tokens[2]) : '',\n group__formattedTokens3__formattedText: tokens[3] ? formatToken(tokens[3]) : '',\n })\n );\n return formatter?.({ operation, operationLabel, tokens }) ?? '';\n },\n removeTokenButtonAriaLabel: token => {\n const formatter = i18n(\n 'i18nStrings.removeTokenButtonAriaLabel',\n def.removeTokenButtonAriaLabel,\n format => () => format({ token__formattedText: formatToken(toFormatted(token)) })\n );\n return formatter?.(toFormatted(token)) ?? '';\n },\n tokenEditorTokenActionsAriaLabel: (token: InternalToken) => {\n const formatter = i18n(\n 'i18nStrings.tokenEditorTokenActionsAriaLabel',\n def.tokenEditorTokenActionsAriaLabel,\n format => () => format({ token__formattedText: formatToken(toFormatted(token)) })\n );\n return formatter?.(toFormatted(token)) ?? '';\n },\n tokenEditorTokenRemoveAriaLabel: token => {\n const formatter = i18n(\n 'i18nStrings.tokenEditorTokenRemoveAriaLabel',\n def.tokenEditorTokenRemoveAriaLabel,\n format => () => format({ token__formattedText: formatToken(toFormatted(token)) })\n );\n return formatter?.(toFormatted(token)) ?? '';\n },\n tokenEditorAddExistingTokenAriaLabel: token => {\n const formatter = i18n(\n 'i18nStrings.tokenEditorAddExistingTokenAriaLabel',\n def.tokenEditorAddExistingTokenAriaLabel,\n format => () => format({ token__formattedText: formatToken(toFormatted(token)) })\n );\n return formatter?.(toFormatted(token)) ?? '';\n },\n tokenEditorAddExistingTokenLabel: token => {\n const formattedToken = toFormatted(token);\n const formatter = i18n(\n 'i18nStrings.tokenEditorAddExistingTokenLabel',\n def.tokenEditorAddExistingTokenLabel,\n format => () =>\n format({\n token__propertyLabel: formattedToken.propertyLabel,\n token__operator: formattedToken.operator,\n token__value: formattedToken.value,\n })\n );\n return formatter?.(toFormatted(token)) ?? '';\n },\n };\n}\n\nexport function operatorToDescription(operator: ComparisonOperator, i18nStrings: I18nStringsOperators) {\n switch (operator) {\n case '<':\n return i18nStrings.operatorLessText;\n case '<=':\n return i18nStrings.operatorLessOrEqualText;\n case '>':\n return i18nStrings.operatorGreaterText;\n case '>=':\n return i18nStrings.operatorGreaterOrEqualText;\n case ':':\n return i18nStrings.operatorContainsText;\n case '!:':\n return i18nStrings.operatorDoesNotContainText;\n case '=':\n return i18nStrings.operatorEqualsText;\n case '!=':\n return i18nStrings.operatorDoesNotEqualText;\n case '^':\n return i18nStrings.operatorStartsWithText;\n case '!^':\n return i18nStrings.operatorDoesNotStartWithText;\n // The line is ignored from coverage because it is not reachable.\n // The purpose of it is to prevent TS errors if ComparisonOperator type gets extended.\n /* istanbul ignore next */\n default:\n return '';\n }\n}\n\nfunction getOperatorI18nString(operator: ComparisonOperator): string {\n switch (operator) {\n case '=':\n return 'equals';\n case '!=':\n return 'not_equals';\n case '>':\n return 'greater_than';\n case '>=':\n return 'greater_than_equal';\n case '<':\n return 'less_than';\n case '<=':\n return 'less_than_equal';\n case ':':\n return 'contains';\n case '!:':\n return 'not_contains';\n case '^':\n return 'starts_with';\n case '!^':\n return 'not_starts_with';\n // The line is ignored from coverage because it is not reachable.\n // The purpose of it is to prevent TS errors if ComparisonOperator type gets extended.\n /* istanbul ignore next */\n default:\n return operator;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/property-filter/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B,OAAO,EAAE,mBAAmB,EAAO,MAAM,cAAc,CAAC;AAKxD,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAE/B,QAAA,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/property-filter/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B,OAAO,EAAE,mBAAmB,EAAO,MAAM,cAAc,CAAC;AAKxD,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAE/B,QAAA,MAAM,cAAc,qGAgFnB,CAAC;AAGF,eAAe,cAAc,CAAC"}
|
package/property-filter/index.js
CHANGED
|
@@ -9,7 +9,20 @@ import { applyDisplayName } from '../internal/utils/apply-display-name';
|
|
|
9
9
|
import PropertyFilterInternal from './internal';
|
|
10
10
|
import analyticsSelectors from './analytics-metadata/styles.css.js';
|
|
11
11
|
const PropertyFilter = React.forwardRef((_a, ref) => {
|
|
12
|
-
var
|
|
12
|
+
var _b;
|
|
13
|
+
var { filteringProperties, filteringOptions = [], customGroupsText = [], enableTokenGroups = false, disableFreeTextFiltering = false, asyncProperties, expandToViewport, hideOperations = false, tokenLimit, virtualScroll } = _a, rest = __rest(_a, ["filteringProperties", "filteringOptions", "customGroupsText", "enableTokenGroups", "disableFreeTextFiltering", "asyncProperties", "expandToViewport", "hideOperations", "tokenLimit", "virtualScroll"]);
|
|
14
|
+
let hasCustomForms = false;
|
|
15
|
+
let hasEnumTokens = false;
|
|
16
|
+
let hasCustomFormatters = false;
|
|
17
|
+
for (const property of filteringProperties) {
|
|
18
|
+
for (const operator of (_b = property.operators) !== null && _b !== void 0 ? _b : []) {
|
|
19
|
+
if (typeof operator === 'object') {
|
|
20
|
+
hasCustomForms = hasCustomForms || !!operator.form;
|
|
21
|
+
hasEnumTokens = hasEnumTokens || operator.tokenType === 'enum';
|
|
22
|
+
hasCustomFormatters = hasCustomFormatters || !!operator.format;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
13
26
|
const baseComponentProps = useBaseComponent('PropertyFilter', {
|
|
14
27
|
props: {
|
|
15
28
|
asyncProperties,
|
|
@@ -20,6 +33,11 @@ const PropertyFilter = React.forwardRef((_a, ref) => {
|
|
|
20
33
|
tokenLimit,
|
|
21
34
|
virtualScroll,
|
|
22
35
|
},
|
|
36
|
+
metadata: {
|
|
37
|
+
hasCustomForms,
|
|
38
|
+
hasEnumTokens,
|
|
39
|
+
hasCustomFormatters,
|
|
40
|
+
},
|
|
23
41
|
});
|
|
24
42
|
const componentAnalyticsMetadata = {
|
|
25
43
|
name: 'awsui.PropertyFilter',
|
|
@@ -33,7 +51,7 @@ const PropertyFilter = React.forwardRef((_a, ref) => {
|
|
|
33
51
|
warnOnce('PropertyFilter', 'Operations cannot be hidden when token groups are enabled.');
|
|
34
52
|
hideOperations = false;
|
|
35
53
|
}
|
|
36
|
-
return (React.createElement(PropertyFilterInternal, Object.assign({ ref: ref }, baseComponentProps, { filteringOptions: filteringOptions, customGroupsText: customGroupsText, enableTokenGroups: enableTokenGroups, disableFreeTextFiltering: disableFreeTextFiltering, asyncProperties: asyncProperties, expandToViewport: expandToViewport, hideOperations: hideOperations, tokenLimit: tokenLimit, virtualScroll: virtualScroll }, getAnalyticsMetadataAttribute({ component: componentAnalyticsMetadata }), rest)));
|
|
54
|
+
return (React.createElement(PropertyFilterInternal, Object.assign({ ref: ref }, baseComponentProps, { filteringProperties: filteringProperties, filteringOptions: filteringOptions, customGroupsText: customGroupsText, enableTokenGroups: enableTokenGroups, disableFreeTextFiltering: disableFreeTextFiltering, asyncProperties: asyncProperties, expandToViewport: expandToViewport, hideOperations: hideOperations, tokenLimit: tokenLimit, virtualScroll: virtualScroll }, getAnalyticsMetadataAttribute({ component: componentAnalyticsMetadata }), rest)));
|
|
37
55
|
});
|
|
38
56
|
applyDisplayName(PropertyFilter, 'PropertyFilter');
|
|
39
57
|
export default PropertyFilter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/property-filter/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AACzE,OAAO,EAAE,6BAA6B,EAAE,MAAM,kEAAkE,CAAC;AAEjH,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AAC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EAClC,cAAc,EAAE,cAAc,EAC9B,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,aAAa,IACxB,6BAA6B,CAAC,EAAE,SAAS,EAAE,0BAA0B,EAAE,CAAC,EACxE,IAAI,EACR,CACH,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 React from 'react';\n\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\nimport { getAnalyticsMetadataAttribute } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';\n\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { GeneratedAnalyticsMetadataPropertyFilterComponent } from './analytics-metadata/interfaces';\nimport { PropertyFilterProps, Ref } from './interfaces';\nimport PropertyFilterInternal from './internal';\n\nimport analyticsSelectors from './analytics-metadata/styles.css.js';\n\nexport { PropertyFilterProps };\n\nconst PropertyFilter = React.forwardRef(\n (\n {\n filteringProperties,\n filteringOptions = [],\n customGroupsText = [],\n enableTokenGroups = false,\n disableFreeTextFiltering = false,\n asyncProperties,\n expandToViewport,\n hideOperations = false,\n tokenLimit,\n virtualScroll,\n ...rest\n }: PropertyFilterProps,\n ref: React.Ref<Ref>\n ) => {\n let hasCustomForms = false;\n let hasEnumTokens = false;\n let hasCustomFormatters = false;\n for (const property of filteringProperties) {\n for (const operator of property.operators ?? []) {\n if (typeof operator === 'object') {\n hasCustomForms = hasCustomForms || !!operator.form;\n hasEnumTokens = hasEnumTokens || operator.tokenType === 'enum';\n hasCustomFormatters = hasCustomFormatters || !!operator.format;\n }\n }\n }\n\n const baseComponentProps = useBaseComponent('PropertyFilter', {\n props: {\n asyncProperties,\n disableFreeTextFiltering,\n enableTokenGroups,\n expandToViewport,\n hideOperations,\n tokenLimit,\n virtualScroll,\n },\n metadata: {\n hasCustomForms,\n hasEnumTokens,\n hasCustomFormatters,\n },\n });\n\n const componentAnalyticsMetadata: GeneratedAnalyticsMetadataPropertyFilterComponent = {\n name: 'awsui.PropertyFilter',\n label: `.${analyticsSelectors['search-field']} input`,\n properties: {\n disabled: `${!!rest.disabled}`,\n queryTokensCount: `${rest.query && rest.query.tokens ? rest.query.tokens.length : 0}`,\n },\n };\n\n if (hideOperations && enableTokenGroups) {\n warnOnce('PropertyFilter', 'Operations cannot be hidden when token groups are enabled.');\n hideOperations = false;\n }\n\n return (\n <PropertyFilterInternal\n ref={ref}\n {...baseComponentProps}\n filteringProperties={filteringProperties}\n filteringOptions={filteringOptions}\n customGroupsText={customGroupsText}\n enableTokenGroups={enableTokenGroups}\n disableFreeTextFiltering={disableFreeTextFiltering}\n asyncProperties={asyncProperties}\n expandToViewport={expandToViewport}\n hideOperations={hideOperations}\n tokenLimit={tokenLimit}\n virtualScroll={virtualScroll}\n {...getAnalyticsMetadataAttribute({ component: componentAnalyticsMetadata })}\n {...rest}\n />\n );\n }\n);\n\napplyDisplayName(PropertyFilter, 'PropertyFilter');\nexport default PropertyFilter;\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { PropertyFilterFreeTextFiltering, PropertyFilterOperation, PropertyFilterOperator, PropertyFilterOperatorExtended, PropertyFilterOperatorForm, PropertyFilterOperatorFormat, PropertyFilterOperatorFormProps, PropertyFilterOption, PropertyFilterProperty, PropertyFilterQuery, PropertyFilterToken, PropertyFilterTokenGroup } from '@cloudscape-design/collection-hooks';
|
|
2
|
+
import { PropertyFilterFreeTextFiltering, PropertyFilterOperation, PropertyFilterOperator, PropertyFilterOperatorExtended, PropertyFilterOperatorForm, PropertyFilterOperatorFormat, PropertyFilterOperatorFormProps, PropertyFilterOption, PropertyFilterProperty, PropertyFilterQuery, PropertyFilterToken, PropertyFilterTokenGroup, PropertyFilterTokenType } from '@cloudscape-design/collection-hooks';
|
|
3
3
|
import { AutosuggestProps } from '../autosuggest/interfaces';
|
|
4
4
|
import { BaseComponentProps } from '../internal/base-component';
|
|
5
5
|
import { ExpandToViewport } from '../internal/components/dropdown/interfaces';
|
|
@@ -33,7 +33,7 @@ export interface PropertyFilterProps extends BaseComponentProps, ExpandToViewpor
|
|
|
33
33
|
* `tokenGroups` property is used instead, which supports nested tokens.
|
|
34
34
|
*
|
|
35
35
|
* Each token has the following properties:
|
|
36
|
-
* * value [
|
|
36
|
+
* * value [unknown]: The value of the token to be used as a filter. Can be null or string for default tokens, string[] for enum tokens, and anything for tokens with custom forms.
|
|
37
37
|
* * propertyKey [string]: The key of the corresponding property in filteringProperties.
|
|
38
38
|
* * operator ['<' | '<=' | '>' | '>=' | ':' | '!:' | '=' | '!=' | '^' | '!^']: The operator which indicates how to filter the dataset using this token.
|
|
39
39
|
*/
|
|
@@ -307,6 +307,7 @@ export type ExtendedOperatorForm<TokenValue> = PropertyFilterOperatorForm<TokenV
|
|
|
307
307
|
export type ExtendedOperatorFormat<TokenValue> = PropertyFilterOperatorFormat<TokenValue>;
|
|
308
308
|
export type FilteringOption = PropertyFilterProps.FilteringOption;
|
|
309
309
|
export type FilteringProperty = PropertyFilterProps.FilteringProperty;
|
|
310
|
+
export type FilteringPropertyTokenType = PropertyFilterTokenType;
|
|
310
311
|
export type Query = PropertyFilterProps.Query;
|
|
311
312
|
export type LoadItemsDetail = PropertyFilterProps.LoadItemsDetail;
|
|
312
313
|
export type I18nStrings = PropertyFilterProps.I18nStrings;
|
|
@@ -322,6 +323,7 @@ export interface InternalFilteringProperty<TokenValue = any> {
|
|
|
322
323
|
propertyGroup?: string;
|
|
323
324
|
operators: readonly PropertyFilterOperator[];
|
|
324
325
|
defaultOperator: PropertyFilterOperator;
|
|
326
|
+
getTokenType: (operator?: PropertyFilterOperator) => FilteringPropertyTokenType;
|
|
325
327
|
getValueFormatter: (operator?: PropertyFilterOperator) => null | ((value: any) => string);
|
|
326
328
|
getValueFormRenderer: (operator?: PropertyFilterOperator) => null | PropertyFilterOperatorForm<TokenValue>;
|
|
327
329
|
externalProperty: PropertyFilterProperty;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/property-filter/interfaces.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EACL,+BAA+B,EAC/B,uBAAuB,EACvB,sBAAsB,EACtB,8BAA8B,EAC9B,0BAA0B,EAC1B,4BAA4B,EAC5B,+BAA+B,EAC/B,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/property-filter/interfaces.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EACL,+BAA+B,EAC/B,uBAAuB,EACvB,sBAAsB,EACtB,8BAA8B,EAC9B,0BAA0B,EAC1B,4BAA4B,EAC5B,+BAA+B,EAC/B,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAC/E,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,MAAM,WAAW,mBAAoB,SAAQ,kBAAkB,EAAE,gBAAgB,EAAE,qBAAqB;IACtG;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,C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,CAAC;IACnC,MAAM,EAAE,SAAS,CAAC,aAAa,CAAC,UAAU,CAAC,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC;CACjF;AAED,MAAM,MAAM,aAAa,GAAG,kBAAkB,CAAC;AAE/C,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,yBAAyB,CAAC;IAAC,QAAQ,EAAE,kBAAkB,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACtG;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,yBAAyB,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,GACjF;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":"AAAA,qEAAqE;AACrE,sCAAsC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React from 'react';\n\nimport {\n PropertyFilterFreeTextFiltering,\n PropertyFilterOperation,\n PropertyFilterOperator,\n PropertyFilterOperatorExtended,\n PropertyFilterOperatorForm,\n PropertyFilterOperatorFormat,\n PropertyFilterOperatorFormProps,\n PropertyFilterOption,\n PropertyFilterProperty,\n PropertyFilterQuery,\n PropertyFilterToken,\n PropertyFilterTokenGroup,\n} from '@cloudscape-design/collection-hooks';\n\nimport { AutosuggestProps } from '../autosuggest/interfaces';\nimport { BaseComponentProps } from '../internal/base-component';\nimport { ExpandToViewport } from '../internal/components/dropdown/interfaces';\nimport { DropdownStatusProps } from '../internal/components/dropdown-status';\nimport { FormFieldControlProps } from '../internal/context/form-field-context';\nimport { NonCancelableEventHandler } from '../internal/events';\n\nexport interface PropertyFilterProps extends BaseComponentProps, ExpandToViewport, FormFieldControlProps {\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 * @i18n\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, which has three properties: `operation`, `tokens`, and `tokenGroups`.\n * The `operation` property has two valid values: \"and\", \"or\", and controls the join operation to be applied between tokens when filtering the items.\n * The `tokens` property is an array of objects that will be displayed to the user beneath the filtering input. When `enableTokenGroups=true`, the\n * `tokenGroups` property is used instead, which supports nested tokens.\n *\n * Each token has the following properties:\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 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 * This property cannot be set when `enableTokenGroups=true`.\n */\n hideOperations?: boolean;\n /**\n * Activates token grouping mechanism to support token nesting (up to one level).\n * When `true`, the `query.tokens` property is ignored and `query.tokenGroups` is used instead.\n */\n enableTokenGroups?: boolean;\n /**\n * Fired when the `query` gets changed. Filter the dataset in response to this event using the values in the `detail` object.\n */\n onChange: NonCancelableEventHandler<PropertyFilterProps.Query>;\n /**\n * An array of properties by which the data set can be filtered. Each element has the following properties:\n *\n * * groupValuesLabel [string]: Localized string to display for the 'Values' group label for a specific property.\n * * key [string]: The identifier of this property.\n * * propertyLabel [string]: A human-readable string for the property.\n * * operators [Array]: A list of all operators supported by this property. If you omit the equals operator because your API does not support it, make sure to set `defaultOperator` to a supported operator from this list.\n * * group [string]: Optional identifier of a custom group that this filtering option is assigned to. Use to create additional groups below the default one. Make sure to also define labels for the group in the customGroupsText property. Notice that only one level of options nesting is supported.\n * * defaultOperator [ComparisonOperator]: Optional parameter that changes the default operator used with this filtering property. Use it only if your API does not support \"equals\" filtering terms with this property.\n */\n filteringProperties: ReadonlyArray<PropertyFilterProps.FilteringProperty>;\n /**\n * An array of possible values of the individual `filteringProperties`. Each element has the following properties:\n *\n * * `propertyKey` [string]: The key of the corresponding filtering property in the `filteringProperties` array.\n * * `value` [string]: The value that will be used as a suggestion when creating or modifying a filtering token.\n * * `label` [string]: Optional suggestion label to be matched instead of the value.\n *\n * Filtering options that require labels can only use `=` and `!=` operators. The token value must be labelled separately, for example:\n * ```\n * const filteringProperty = {\n * key: 'state',\n * propertyLabel: 'State',\n * operators: ['=', '!='].map(operator => ({ operator, format: getStateLabel }))\n * }\n * const filteringOptions = [\n * { propertyKey: 'state', value: 'STOPPED', label: getStateLabel('STOPPED') },\n * { propertyKey: 'state', value: 'STOPPING', label: getStateLabel('STOPPING') },\n * { propertyKey: 'state', value: 'RUNNING', label: getStateLabel('RUNNING') },\n * ]\n * ```\n */\n filteringOptions?: ReadonlyArray<PropertyFilterProps.FilteringOption>;\n /**\n * An array of objects that contain localized, human-readable strings for the labels of custom groups within the filtering dropdown. Use group property to associate the strings with your custom group of options. Define the following values for each group:\n *\n * * properties [string]: The group label in the filtering dropdown that contains the list of properties from this group. For example: Tags.\n * * values [string]: The group label in the filtering dropdown that contains the list of values from this group. For example: Tags values.\n * * group [string]: The identifier of a custom group.\n */\n customGroupsText?: PropertyFilterProps.GroupText[];\n /**\n * Set `disableFreeTextFiltering` only if you can’t filter the dataset using a filter that is applied to every column,\n * instead of a specific property. This would stop the user from creating such tokens.\n */\n disableFreeTextFiltering?: boolean;\n /**\n * An object configuring the operators for free text filtering, which has the following properties:\n *\n * * operators [Array]: A list of all operators supported for free text filtering. If you omit the contains operator because your API does not support it, make sure to set `defaultOperator` to a supported operator from this list.\n * * defaultOperator [ComparisonOperator]: An optional parameter that changes the default operator used for free text filtering. Use this parameter only if your API does not support \"contains\" free test filtering terms.\n */\n freeTextFiltering?: PropertyFilterProps.FreeTextFiltering;\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 * A slot that replaces the standard \"Clear filter\" button.\n * When using this slot, make sure to still provide a mechanism to clear all filters.\n */\n customFilterActions?: React.ReactNode;\n /**\n * Set `asyncProperties` if you need to load `filteringProperties` asynchronously. 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 * The label that will be passed down to the Autosuggest `ariaLabel` property.\n * See the [Autosuggest API](/components/autosuggest/?tabId=api) page for more details.\n */\n filteringAriaLabel?: string;\n /**\n * Placeholder for the filtering input.\n */\n filteringPlaceholder?: string;\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 * Constraint text that's displayed below the filtering input.\n * Use this to provide additional information about supported filters.\n */\n filteringConstraintText?: React.ReactNode;\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 /**\n * Adds an aria-label to the \"Show fewer\" button for the token group control.\n * Use to assign unique labels when there are multiple token groups with the same `tokenLimitShowFewer` label on one page.\n */\n tokenLimitShowFewerAriaLabel?: string;\n /**\n * Adds an aria-label to the \"Show more\" button for the token group control.\n * Use to assign unique labels when there are multiple token groups with the same `tokenLimitShowMore` label on one page.\n */\n tokenLimitShowMoreAriaLabel?: string;\n}\n\nexport namespace PropertyFilterProps {\n export type Token = PropertyFilterToken;\n export type TokenGroup = PropertyFilterTokenGroup;\n export type JoinOperation = PropertyFilterOperation;\n export type ComparisonOperator = PropertyFilterOperator;\n export type ExtendedOperator<TokenValue> = PropertyFilterOperatorExtended<TokenValue>;\n export type ExtendedOperatorFormProps<TokenValue> = PropertyFilterOperatorFormProps<TokenValue>;\n export type ExtendedOperatorForm<TokenValue> = PropertyFilterOperatorForm<TokenValue>;\n export type ExtendedOperatorFormat<TokenValue> = PropertyFilterOperatorFormat<TokenValue>;\n export type FilteringOption = PropertyFilterOption;\n export type FilteringProperty = PropertyFilterProperty;\n export type FreeTextFiltering = PropertyFilterFreeTextFiltering;\n export type Query = PropertyFilterQuery;\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 * @deprecated Use `filteringAriaLabel` on the component instead.\n */\n filteringAriaLabel?: string;\n\n /**\n * @deprecated Use `filteringPlaceholder` on the component instead.\n */\n filteringPlaceholder?: string;\n\n dismissAriaLabel?: string;\n clearAriaLabel?: 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 operatorStartsWithText?: string;\n operatorDoesNotStartWithText?: 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 formatToken?: (token: FormattedToken) => string;\n\n tokenLimitShowMore?: string;\n tokenLimitShowFewer?: string;\n clearFiltersText?: string;\n tokenOperatorAriaLabel?: string;\n removeTokenButtonAriaLabel?: (token: FormattedToken) => string;\n enteredTextLabel?: AutosuggestProps.EnteredTextLabel;\n\n groupEditAriaLabel?: (group: FormattedTokenGroup) => string;\n tokenEditorTokenActionsAriaLabel?: (token: FormattedToken) => string;\n tokenEditorTokenRemoveAriaLabel?: (token: FormattedToken) => string;\n tokenEditorTokenRemoveLabel?: string;\n tokenEditorTokenRemoveFromGroupLabel?: string;\n tokenEditorAddNewTokenLabel?: string;\n tokenEditorAddTokenActionsAriaLabel?: string;\n tokenEditorAddExistingTokenAriaLabel?: (token: FormattedToken) => string;\n tokenEditorAddExistingTokenLabel?: (token: FormattedToken) => string;\n }\n\n export interface FormattedToken {\n propertyKey?: string;\n propertyLabel: string;\n operator: ComparisonOperator;\n value: string;\n }\n\n export interface FormattedTokenGroup {\n tokens: FormattedToken[];\n operation: string;\n operationLabel: string;\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 TokenGroup = PropertyFilterProps.TokenGroup;\nexport type JoinOperation = PropertyFilterProps.JoinOperation;\nexport type ComparisonOperator = PropertyFilterProps.ComparisonOperator;\nexport type ExtendedOperator<TokenValue> = PropertyFilterOperatorExtended<TokenValue>;\nexport type ExtendedOperatorFormProps<TokenValue> = PropertyFilterOperatorFormProps<TokenValue>;\nexport type ExtendedOperatorForm<TokenValue> = PropertyFilterOperatorForm<TokenValue>;\nexport type ExtendedOperatorFormat<TokenValue> = PropertyFilterOperatorFormat<TokenValue>;\nexport type FilteringOption = PropertyFilterProps.FilteringOption;\nexport type FilteringProperty = PropertyFilterProps.FilteringProperty;\nexport type Query = PropertyFilterProps.Query;\nexport type LoadItemsDetail = PropertyFilterProps.LoadItemsDetail;\nexport type I18nStrings = PropertyFilterProps.I18nStrings;\nexport type GroupText = PropertyFilterProps.GroupText;\nexport type FilteringChangeDetail = PropertyFilterProps.FilteringChangeDetail;\nexport type FormattedToken = PropertyFilterProps.FormattedToken;\nexport type FormattedTokenGroup = PropertyFilterProps.FormattedTokenGroup;\nexport type Ref = PropertyFilterProps.Ref;\n\n// Utility types\n\nexport interface InternalFilteringProperty<TokenValue = any> {\n propertyKey: string;\n propertyLabel: string;\n groupValuesLabel: string;\n propertyGroup?: string;\n operators: readonly PropertyFilterOperator[];\n defaultOperator: PropertyFilterOperator;\n getValueFormatter: (operator?: PropertyFilterOperator) => null | ((value: any) => string);\n getValueFormRenderer: (operator?: PropertyFilterOperator) => null | PropertyFilterOperatorForm<TokenValue>;\n // Original property used in callbacks.\n externalProperty: PropertyFilterProperty;\n}\n\nexport interface InternalFilteringOption {\n property: null | InternalFilteringProperty;\n value: string;\n label: string;\n}\n\nexport interface InternalFreeTextFiltering {\n disabled: boolean;\n operators: readonly PropertyFilterOperator[];\n defaultOperator: PropertyFilterOperator;\n}\n\nexport interface InternalToken<TokenValue = any> {\n standaloneIndex?: number;\n property: null | InternalFilteringProperty<TokenValue>;\n operator: PropertyFilterOperator;\n value: TokenValue;\n}\n\nexport interface InternalTokenGroup<TokenValue = any> {\n operation: PropertyFilterOperation;\n tokens: readonly (InternalToken<TokenValue> | InternalTokenGroup<TokenValue>)[];\n}\n\nexport type InternalQuery = InternalTokenGroup;\n\nexport type ParsedText =\n | { step: 'property'; property: InternalFilteringProperty; operator: ComparisonOperator; value: string }\n | { step: 'operator'; property: InternalFilteringProperty; operatorPrefix: string }\n | { step: 'free-text'; operator?: ComparisonOperator; value: string };\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/property-filter/interfaces.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React from 'react';\n\nimport {\n PropertyFilterFreeTextFiltering,\n PropertyFilterOperation,\n PropertyFilterOperator,\n PropertyFilterOperatorExtended,\n PropertyFilterOperatorForm,\n PropertyFilterOperatorFormat,\n PropertyFilterOperatorFormProps,\n PropertyFilterOption,\n PropertyFilterProperty,\n PropertyFilterQuery,\n PropertyFilterToken,\n PropertyFilterTokenGroup,\n PropertyFilterTokenType,\n} from '@cloudscape-design/collection-hooks';\n\nimport { AutosuggestProps } from '../autosuggest/interfaces';\nimport { BaseComponentProps } from '../internal/base-component';\nimport { ExpandToViewport } from '../internal/components/dropdown/interfaces';\nimport { DropdownStatusProps } from '../internal/components/dropdown-status';\nimport { FormFieldControlProps } from '../internal/context/form-field-context';\nimport { NonCancelableEventHandler } from '../internal/events';\n\nexport interface PropertyFilterProps extends BaseComponentProps, ExpandToViewport, FormFieldControlProps {\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 * @i18n\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, which has three properties: `operation`, `tokens`, and `tokenGroups`.\n * The `operation` property has two valid values: \"and\", \"or\", and controls the join operation to be applied between tokens when filtering the items.\n * The `tokens` property is an array of objects that will be displayed to the user beneath the filtering input. When `enableTokenGroups=true`, the\n * `tokenGroups` property is used instead, which supports nested tokens.\n *\n * Each token has the following properties:\n * * value [unknown]: The value of the token to be used as a filter. Can be null or string for default tokens, string[] for enum tokens, and anything for tokens with custom forms.\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 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 * This property cannot be set when `enableTokenGroups=true`.\n */\n hideOperations?: boolean;\n /**\n * Activates token grouping mechanism to support token nesting (up to one level).\n * When `true`, the `query.tokens` property is ignored and `query.tokenGroups` is used instead.\n */\n enableTokenGroups?: boolean;\n /**\n * Fired when the `query` gets changed. Filter the dataset in response to this event using the values in the `detail` object.\n */\n onChange: NonCancelableEventHandler<PropertyFilterProps.Query>;\n /**\n * An array of properties by which the data set can be filtered. Each element has the following properties:\n *\n * * groupValuesLabel [string]: Localized string to display for the 'Values' group label for a specific property.\n * * key [string]: The identifier of this property.\n * * propertyLabel [string]: A human-readable string for the property.\n * * operators [Array]: A list of all operators supported by this property. If you omit the equals operator because your API does not support it, make sure to set `defaultOperator` to a supported operator from this list.\n * * group [string]: Optional identifier of a custom group that this filtering option is assigned to. Use to create additional groups below the default one. Make sure to also define labels for the group in the customGroupsText property. Notice that only one level of options nesting is supported.\n * * defaultOperator [ComparisonOperator]: Optional parameter that changes the default operator used with this filtering property. Use it only if your API does not support \"equals\" filtering terms with this property.\n */\n filteringProperties: ReadonlyArray<PropertyFilterProps.FilteringProperty>;\n /**\n * An array of possible values of the individual `filteringProperties`. Each element has the following properties:\n *\n * * `propertyKey` [string]: The key of the corresponding filtering property in the `filteringProperties` array.\n * * `value` [string]: The value that will be used as a suggestion when creating or modifying a filtering token.\n * * `label` [string]: Optional suggestion label to be matched instead of the value.\n *\n * Filtering options that require labels can only use `=` and `!=` operators. The token value must be labelled separately, for example:\n * ```\n * const filteringProperty = {\n * key: 'state',\n * propertyLabel: 'State',\n * operators: ['=', '!='].map(operator => ({ operator, format: getStateLabel }))\n * }\n * const filteringOptions = [\n * { propertyKey: 'state', value: 'STOPPED', label: getStateLabel('STOPPED') },\n * { propertyKey: 'state', value: 'STOPPING', label: getStateLabel('STOPPING') },\n * { propertyKey: 'state', value: 'RUNNING', label: getStateLabel('RUNNING') },\n * ]\n * ```\n */\n filteringOptions?: ReadonlyArray<PropertyFilterProps.FilteringOption>;\n /**\n * An array of objects that contain localized, human-readable strings for the labels of custom groups within the filtering dropdown. Use group property to associate the strings with your custom group of options. Define the following values for each group:\n *\n * * properties [string]: The group label in the filtering dropdown that contains the list of properties from this group. For example: Tags.\n * * values [string]: The group label in the filtering dropdown that contains the list of values from this group. For example: Tags values.\n * * group [string]: The identifier of a custom group.\n */\n customGroupsText?: PropertyFilterProps.GroupText[];\n /**\n * Set `disableFreeTextFiltering` only if you can’t filter the dataset using a filter that is applied to every column,\n * instead of a specific property. This would stop the user from creating such tokens.\n */\n disableFreeTextFiltering?: boolean;\n /**\n * An object configuring the operators for free text filtering, which has the following properties:\n *\n * * operators [Array]: A list of all operators supported for free text filtering. If you omit the contains operator because your API does not support it, make sure to set `defaultOperator` to a supported operator from this list.\n * * defaultOperator [ComparisonOperator]: An optional parameter that changes the default operator used for free text filtering. Use this parameter only if your API does not support \"contains\" free test filtering terms.\n */\n freeTextFiltering?: PropertyFilterProps.FreeTextFiltering;\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 * A slot that replaces the standard \"Clear filter\" button.\n * When using this slot, make sure to still provide a mechanism to clear all filters.\n */\n customFilterActions?: React.ReactNode;\n /**\n * Set `asyncProperties` if you need to load `filteringProperties` asynchronously. 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 * The label that will be passed down to the Autosuggest `ariaLabel` property.\n * See the [Autosuggest API](/components/autosuggest/?tabId=api) page for more details.\n */\n filteringAriaLabel?: string;\n /**\n * Placeholder for the filtering input.\n */\n filteringPlaceholder?: string;\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 * Constraint text that's displayed below the filtering input.\n * Use this to provide additional information about supported filters.\n */\n filteringConstraintText?: React.ReactNode;\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 /**\n * Adds an aria-label to the \"Show fewer\" button for the token group control.\n * Use to assign unique labels when there are multiple token groups with the same `tokenLimitShowFewer` label on one page.\n */\n tokenLimitShowFewerAriaLabel?: string;\n /**\n * Adds an aria-label to the \"Show more\" button for the token group control.\n * Use to assign unique labels when there are multiple token groups with the same `tokenLimitShowMore` label on one page.\n */\n tokenLimitShowMoreAriaLabel?: string;\n}\n\nexport namespace PropertyFilterProps {\n export type Token = PropertyFilterToken;\n export type TokenGroup = PropertyFilterTokenGroup;\n export type JoinOperation = PropertyFilterOperation;\n export type ComparisonOperator = PropertyFilterOperator;\n export type ExtendedOperator<TokenValue> = PropertyFilterOperatorExtended<TokenValue>;\n export type ExtendedOperatorFormProps<TokenValue> = PropertyFilterOperatorFormProps<TokenValue>;\n export type ExtendedOperatorForm<TokenValue> = PropertyFilterOperatorForm<TokenValue>;\n export type ExtendedOperatorFormat<TokenValue> = PropertyFilterOperatorFormat<TokenValue>;\n export type FilteringOption = PropertyFilterOption;\n export type FilteringProperty = PropertyFilterProperty;\n export type FreeTextFiltering = PropertyFilterFreeTextFiltering;\n export type Query = PropertyFilterQuery;\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 * @deprecated Use `filteringAriaLabel` on the component instead.\n */\n filteringAriaLabel?: string;\n\n /**\n * @deprecated Use `filteringPlaceholder` on the component instead.\n */\n filteringPlaceholder?: string;\n\n dismissAriaLabel?: string;\n clearAriaLabel?: 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 operatorStartsWithText?: string;\n operatorDoesNotStartWithText?: 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 formatToken?: (token: FormattedToken) => string;\n\n tokenLimitShowMore?: string;\n tokenLimitShowFewer?: string;\n clearFiltersText?: string;\n tokenOperatorAriaLabel?: string;\n removeTokenButtonAriaLabel?: (token: FormattedToken) => string;\n enteredTextLabel?: AutosuggestProps.EnteredTextLabel;\n\n groupEditAriaLabel?: (group: FormattedTokenGroup) => string;\n tokenEditorTokenActionsAriaLabel?: (token: FormattedToken) => string;\n tokenEditorTokenRemoveAriaLabel?: (token: FormattedToken) => string;\n tokenEditorTokenRemoveLabel?: string;\n tokenEditorTokenRemoveFromGroupLabel?: string;\n tokenEditorAddNewTokenLabel?: string;\n tokenEditorAddTokenActionsAriaLabel?: string;\n tokenEditorAddExistingTokenAriaLabel?: (token: FormattedToken) => string;\n tokenEditorAddExistingTokenLabel?: (token: FormattedToken) => string;\n }\n\n export interface FormattedToken {\n propertyKey?: string;\n propertyLabel: string;\n operator: ComparisonOperator;\n value: string;\n }\n\n export interface FormattedTokenGroup {\n tokens: FormattedToken[];\n operation: string;\n operationLabel: string;\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 TokenGroup = PropertyFilterProps.TokenGroup;\nexport type JoinOperation = PropertyFilterProps.JoinOperation;\nexport type ComparisonOperator = PropertyFilterProps.ComparisonOperator;\nexport type ExtendedOperator<TokenValue> = PropertyFilterOperatorExtended<TokenValue>;\nexport type ExtendedOperatorFormProps<TokenValue> = PropertyFilterOperatorFormProps<TokenValue>;\nexport type ExtendedOperatorForm<TokenValue> = PropertyFilterOperatorForm<TokenValue>;\nexport type ExtendedOperatorFormat<TokenValue> = PropertyFilterOperatorFormat<TokenValue>;\nexport type FilteringOption = PropertyFilterProps.FilteringOption;\nexport type FilteringProperty = PropertyFilterProps.FilteringProperty;\nexport type FilteringPropertyTokenType = PropertyFilterTokenType;\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 FormattedToken = PropertyFilterProps.FormattedToken;\nexport type FormattedTokenGroup = PropertyFilterProps.FormattedTokenGroup;\nexport type Ref = PropertyFilterProps.Ref;\n\n// Utility types\n\nexport interface InternalFilteringProperty<TokenValue = any> {\n propertyKey: string;\n propertyLabel: string;\n groupValuesLabel: string;\n propertyGroup?: string;\n operators: readonly PropertyFilterOperator[];\n defaultOperator: PropertyFilterOperator;\n getTokenType: (operator?: PropertyFilterOperator) => FilteringPropertyTokenType;\n getValueFormatter: (operator?: PropertyFilterOperator) => null | ((value: any) => string);\n getValueFormRenderer: (operator?: PropertyFilterOperator) => null | PropertyFilterOperatorForm<TokenValue>;\n // Original property used in callbacks.\n externalProperty: PropertyFilterProperty;\n}\n\nexport interface InternalFilteringOption {\n property: null | InternalFilteringProperty;\n value: string;\n label: string;\n}\n\nexport interface InternalFreeTextFiltering {\n disabled: boolean;\n operators: readonly PropertyFilterOperator[];\n defaultOperator: PropertyFilterOperator;\n}\n\nexport interface InternalToken<TokenValue = any> {\n standaloneIndex?: number;\n property: null | InternalFilteringProperty<TokenValue>;\n operator: PropertyFilterOperator;\n value: TokenValue;\n}\n\nexport interface InternalTokenGroup<TokenValue = any> {\n operation: PropertyFilterOperation;\n tokens: readonly (InternalToken<TokenValue> | InternalTokenGroup<TokenValue>)[];\n}\n\nexport type InternalQuery = InternalTokenGroup;\n\nexport type ParsedText =\n | { step: 'property'; property: InternalFilteringProperty; operator: ComparisonOperator; value: string }\n | { step: 'operator'; property: InternalFilteringProperty; operatorPrefix: string }\n | { step: 'free-text'; operator?: ComparisonOperator; value: string };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/property-filter/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAgD,MAAM,OAAO,CAAC;AAWrE,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAIlF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAOjD,OAAO,EAWL,mBAAmB,EAIpB,MAAM,cAAc,CAAC;AAUtB,MAAM,MAAM,2BAA2B,GAAG,YAAY,CACpD,mBAAmB,EACnB,kBAAkB,GAAG,kBAAkB,GAAG,mBAAmB,GAAG,0BAA0B,GAAG,gBAAgB,CAC9G,GACC,0BAA0B,CAAC;AAE7B,QAAA,MAAM,sBAAsB;;;;;;
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/property-filter/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAgD,MAAM,OAAO,CAAC;AAWrE,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAIlF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAOjD,OAAO,EAWL,mBAAmB,EAIpB,MAAM,cAAc,CAAC;AAUtB,MAAM,MAAM,2BAA2B,GAAG,YAAY,CACpD,mBAAmB,EACnB,kBAAkB,GAAG,kBAAkB,GAAG,mBAAmB,GAAG,0BAA0B,GAAG,gBAAgB,CAC9G,GACC,0BAA0B,CAAC;AAE7B,QAAA,MAAM,sBAAsB;;;;;;mFAia3B,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
|
|
@@ -16,7 +16,7 @@ import InternalSpaceBetween from '../space-between/internal';
|
|
|
16
16
|
import { SearchResults } from '../text-filter/search-results';
|
|
17
17
|
import { getAllowedOperators, getAutosuggestOptions, getQueryActions, parseText } from './controller';
|
|
18
18
|
import { usePropertyFilterI18n } from './i18n-utils';
|
|
19
|
-
import {
|
|
19
|
+
import { PropertyEditorContentCustom, PropertyEditorContentEnum, PropertyEditorFooter } from './property-editor';
|
|
20
20
|
import PropertyFilterAutosuggest from './property-filter-autosuggest';
|
|
21
21
|
import { TokenButton } from './token';
|
|
22
22
|
import { useLoadItems } from './use-load-items';
|
|
@@ -61,6 +61,7 @@ const PropertyFilterInternal = React.forwardRef((_a, ref) => {
|
|
|
61
61
|
propertyGroup: property === null || property === void 0 ? void 0 : property.group,
|
|
62
62
|
operators: ((_d = property === null || property === void 0 ? void 0 : property.operators) !== null && _d !== void 0 ? _d : []).map(op => (typeof op === 'string' ? op : op.operator)),
|
|
63
63
|
defaultOperator: (_e = property === null || property === void 0 ? void 0 : property.defaultOperator) !== null && _e !== void 0 ? _e : '=',
|
|
64
|
+
getTokenType: operator => { var _a, _b; return (operator ? (_b = (_a = extendedOperators.get(operator)) === null || _a === void 0 ? void 0 : _a.tokenType) !== null && _b !== void 0 ? _b : 'value' : 'value'); },
|
|
64
65
|
getValueFormatter: operator => { var _a, _b; return (operator ? (_b = (_a = extendedOperators.get(operator)) === null || _a === void 0 ? void 0 : _a.format) !== null && _b !== void 0 ? _b : null : null); },
|
|
65
66
|
getValueFormRenderer: operator => { var _a, _b; return (operator ? (_b = (_a = extendedOperators.get(operator)) === null || _a === void 0 ? void 0 : _a.form) !== null && _b !== void 0 ? _b : null : null); },
|
|
66
67
|
externalProperty: property,
|
|
@@ -201,6 +202,7 @@ const PropertyFilterInternal = React.forwardRef((_a, ref) => {
|
|
|
201
202
|
const customFormValue = customValueKey in customFormValueRecord ? customFormValueRecord[customValueKey] : null;
|
|
202
203
|
const setCustomFormValue = (value) => setCustomFormValueRecord({ [customValueKey]: value });
|
|
203
204
|
const operatorForm = propertyStep && propertyStep.property.getValueFormRenderer(propertyStep.operator);
|
|
205
|
+
const isEnumValue = (propertyStep === null || propertyStep === void 0 ? void 0 : propertyStep.property.getTokenType(propertyStep.operator)) === 'enum';
|
|
204
206
|
const searchResultsId = useUniqueId('property-filter-search-results');
|
|
205
207
|
const constraintTextId = useUniqueId('property-filter-constraint');
|
|
206
208
|
const textboxAriaDescribedBy = filteringConstraintText
|
|
@@ -211,9 +213,9 @@ const PropertyFilterInternal = React.forwardRef((_a, ref) => {
|
|
|
211
213
|
React.createElement("div", { className: clsx(styles['search-field'], analyticsSelectors['search-field']) },
|
|
212
214
|
customControl && React.createElement("div", { className: styles['custom-control'] }, customControl),
|
|
213
215
|
React.createElement("div", { className: styles['input-wrapper'] },
|
|
214
|
-
React.createElement(PropertyFilterAutosuggest, Object.assign({ ref: inputRef, virtualScroll: virtualScroll, enteredTextLabel: i18nStrings.enteredTextLabel, ariaLabel: filteringAriaLabel !== null && filteringAriaLabel !== void 0 ? filteringAriaLabel : i18nStrings.filteringAriaLabel, placeholder: filteringPlaceholder !== null && filteringPlaceholder !== void 0 ? filteringPlaceholder : i18nStrings.filteringPlaceholder, ariaLabelledby: rest.ariaLabelledby, ariaDescribedby: textboxAriaDescribedBy, controlId: rest.controlId, value: filteringText, disabled: disabled }, autosuggestOptions, { onChange: event => setFilteringText(event.detail.value), empty: filteringEmpty }, asyncAutosuggestProps, { expandToViewport: expandToViewport, onOptionClick: handleSelected, customForm: operatorForm
|
|
216
|
+
React.createElement(PropertyFilterAutosuggest, Object.assign({ ref: inputRef, virtualScroll: virtualScroll, enteredTextLabel: i18nStrings.enteredTextLabel, ariaLabel: filteringAriaLabel !== null && filteringAriaLabel !== void 0 ? filteringAriaLabel : i18nStrings.filteringAriaLabel, placeholder: filteringPlaceholder !== null && filteringPlaceholder !== void 0 ? filteringPlaceholder : i18nStrings.filteringPlaceholder, ariaLabelledby: rest.ariaLabelledby, ariaDescribedby: textboxAriaDescribedBy, controlId: rest.controlId, value: filteringText, disabled: disabled }, autosuggestOptions, { onChange: event => setFilteringText(event.detail.value), empty: filteringEmpty }, asyncAutosuggestProps, { expandToViewport: expandToViewport, onOptionClick: handleSelected, customForm: operatorForm || isEnumValue
|
|
215
217
|
? {
|
|
216
|
-
content: (React.createElement(
|
|
218
|
+
content: operatorForm ? (React.createElement(PropertyEditorContentCustom, { key: customValueKey, property: propertyStep.property, operator: propertyStep.operator, filter: propertyStep.value, operatorForm: operatorForm, value: customFormValue, onChange: setCustomFormValue })) : (React.createElement(PropertyEditorContentEnum, { key: customValueKey, property: propertyStep.property, filter: propertyStep.value, value: customFormValue, onChange: setCustomFormValue, asyncProps: asyncProps, filteringOptions: internalOptions, onLoadItems: inputLoadItemsHandlers.onLoadItems })),
|
|
217
219
|
footer: (React.createElement(PropertyEditorFooter, { key: customValueKey, property: propertyStep.property, operator: propertyStep.operator, value: customFormValue, i18nStrings: i18nStrings, onCancel: () => {
|
|
218
220
|
var _a, _b;
|
|
219
221
|
setFilteringText('');
|