@cloudscape-design/components 3.0.1318 → 3.0.1319
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app-layout/drawer/overflow-menu.d.ts +2 -1
- package/app-layout/drawer/overflow-menu.d.ts.map +1 -1
- package/app-layout/drawer/overflow-menu.js.map +1 -1
- package/app-layout/visual-refresh-toolbar/drawer/global-ai-drawer.js.map +1 -1
- package/app-layout/visual-refresh-toolbar/drawer/global-bottom-drawer.js.map +1 -1
- package/app-layout/visual-refresh-toolbar/drawer/global-drawer.js.map +1 -1
- package/attribute-editor/styles.css.js +15 -15
- package/attribute-editor/styles.scoped.css +28 -25
- package/attribute-editor/styles.selectors.js +15 -15
- package/breadcrumb-group/implementation.d.ts +2 -1
- package/breadcrumb-group/implementation.d.ts.map +1 -1
- package/breadcrumb-group/implementation.js.map +1 -1
- package/breadcrumb-group/interfaces.d.ts +0 -4
- package/breadcrumb-group/interfaces.d.ts.map +1 -1
- package/breadcrumb-group/interfaces.js.map +1 -1
- package/breadcrumb-group/internal-interfaces.d.ts +5 -0
- package/breadcrumb-group/internal-interfaces.d.ts.map +1 -0
- package/breadcrumb-group/internal-interfaces.js +2 -0
- package/breadcrumb-group/internal-interfaces.js.map +1 -0
- package/breadcrumb-group/skeleton.js.map +1 -1
- package/button-dropdown/category-elements/category-element.d.ts +1 -1
- package/button-dropdown/category-elements/category-element.d.ts.map +1 -1
- package/button-dropdown/category-elements/category-element.js.map +1 -1
- package/button-dropdown/category-elements/expandable-category-element.d.ts +1 -1
- package/button-dropdown/category-elements/expandable-category-element.d.ts.map +1 -1
- package/button-dropdown/category-elements/expandable-category-element.js.map +1 -1
- package/button-dropdown/category-elements/mobile-expandable-category-element.d.ts +1 -1
- package/button-dropdown/category-elements/mobile-expandable-category-element.d.ts.map +1 -1
- package/button-dropdown/category-elements/mobile-expandable-category-element.js.map +1 -1
- package/button-dropdown/interfaces.d.ts +1 -102
- package/button-dropdown/interfaces.d.ts.map +1 -1
- package/button-dropdown/interfaces.js.map +1 -1
- package/button-dropdown/internal-interfaces.d.ts +103 -0
- package/button-dropdown/internal-interfaces.d.ts.map +1 -0
- package/button-dropdown/internal-interfaces.js +2 -0
- package/button-dropdown/internal-interfaces.js.map +1 -0
- package/button-dropdown/internal.d.ts +2 -1
- package/button-dropdown/internal.d.ts.map +1 -1
- package/button-dropdown/internal.js.map +1 -1
- package/button-dropdown/item-element/index.d.ts +1 -1
- package/button-dropdown/item-element/index.d.ts.map +1 -1
- package/button-dropdown/item-element/index.js.map +1 -1
- package/button-dropdown/items-list.d.ts +1 -1
- package/button-dropdown/items-list.d.ts.map +1 -1
- package/button-dropdown/items-list.js.map +1 -1
- package/button-group/icon-button-item.d.ts +2 -1
- package/button-group/icon-button-item.d.ts.map +1 -1
- package/button-group/icon-button-item.js.map +1 -1
- package/button-group/icon-toggle-button-item.d.ts +2 -1
- package/button-group/icon-toggle-button-item.d.ts.map +1 -1
- package/button-group/icon-toggle-button-item.js.map +1 -1
- package/button-group/interfaces.d.ts +0 -14
- package/button-group/interfaces.d.ts.map +1 -1
- package/button-group/interfaces.js.map +1 -1
- package/button-group/internal-interfaces.d.ts +15 -0
- package/button-group/internal-interfaces.d.ts.map +1 -0
- package/button-group/internal-interfaces.js +2 -0
- package/button-group/internal-interfaces.js.map +1 -0
- package/button-group/internal.d.ts +2 -1
- package/button-group/internal.d.ts.map +1 -1
- package/button-group/internal.js.map +1 -1
- package/column-layout/flexible-column-layout/index.d.ts +1 -1
- package/column-layout/flexible-column-layout/index.d.ts.map +1 -1
- package/column-layout/flexible-column-layout/index.js.map +1 -1
- package/column-layout/grid-column-layout.d.ts +1 -1
- package/column-layout/grid-column-layout.d.ts.map +1 -1
- package/column-layout/grid-column-layout.js.map +1 -1
- package/column-layout/interfaces.d.ts +0 -9
- package/column-layout/interfaces.d.ts.map +1 -1
- package/column-layout/interfaces.js.map +1 -1
- package/column-layout/internal-interfaces.d.ts +10 -0
- package/column-layout/internal-interfaces.d.ts.map +1 -0
- package/column-layout/internal-interfaces.js +2 -0
- package/column-layout/internal-interfaces.js.map +1 -0
- package/column-layout/internal.d.ts +1 -1
- package/column-layout/internal.d.ts.map +1 -1
- package/column-layout/internal.js.map +1 -1
- package/expandable-section/expandable-section-container.d.ts +1 -1
- package/expandable-section/expandable-section-container.d.ts.map +1 -1
- package/expandable-section/expandable-section-container.js.map +1 -1
- package/expandable-section/expandable-section-header.d.ts +2 -1
- package/expandable-section/expandable-section-header.d.ts.map +1 -1
- package/expandable-section/expandable-section-header.js.map +1 -1
- package/expandable-section/interfaces.d.ts +0 -1
- package/expandable-section/interfaces.d.ts.map +1 -1
- package/expandable-section/interfaces.js.map +1 -1
- package/expandable-section/internal-interfaces.d.ts +2 -0
- package/expandable-section/internal-interfaces.d.ts.map +1 -0
- package/expandable-section/internal-interfaces.js +2 -0
- package/expandable-section/internal-interfaces.js.map +1 -0
- package/expandable-section/internal.d.ts +2 -1
- package/expandable-section/internal.d.ts.map +1 -1
- package/expandable-section/internal.js.map +1 -1
- package/expandable-section/styles.css.js +35 -35
- package/expandable-section/styles.scoped.css +71 -74
- package/expandable-section/styles.selectors.js +35 -35
- package/expandable-section/utils.d.ts +1 -1
- package/expandable-section/utils.d.ts.map +1 -1
- package/expandable-section/utils.js.map +1 -1
- package/flashbar/collapsible-flashbar.d.ts +1 -1
- package/flashbar/collapsible-flashbar.d.ts.map +1 -1
- package/flashbar/collapsible-flashbar.js.map +1 -1
- package/flashbar/common.d.ts +2 -1
- package/flashbar/common.d.ts.map +1 -1
- package/flashbar/common.js.map +1 -1
- package/flashbar/implementation.d.ts +1 -1
- package/flashbar/implementation.d.ts.map +1 -1
- package/flashbar/implementation.js.map +1 -1
- package/flashbar/interfaces.d.ts +1 -3
- package/flashbar/interfaces.d.ts.map +1 -1
- package/flashbar/interfaces.js.map +1 -1
- package/flashbar/internal-interfaces.d.ts +3 -0
- package/flashbar/internal-interfaces.d.ts.map +1 -0
- package/flashbar/internal-interfaces.js +2 -0
- package/flashbar/internal-interfaces.js.map +1 -0
- package/flashbar/non-collapsible-flashbar.d.ts +1 -1
- package/flashbar/non-collapsible-flashbar.d.ts.map +1 -1
- package/flashbar/non-collapsible-flashbar.js.map +1 -1
- package/form-field/interfaces.d.ts +2 -15
- package/form-field/interfaces.d.ts.map +1 -1
- package/form-field/interfaces.js.map +1 -1
- package/form-field/internal-interfaces.d.ts +16 -0
- package/form-field/internal-interfaces.d.ts.map +1 -0
- package/form-field/internal-interfaces.js +2 -0
- package/form-field/internal-interfaces.js.map +1 -0
- package/form-field/internal.d.ts +1 -1
- package/form-field/internal.d.ts.map +1 -1
- package/form-field/internal.js.map +1 -1
- package/internal/base-component/styles.scoped.css +1 -1
- package/internal/components/menu-dropdown/interfaces.d.ts +1 -1
- package/internal/components/menu-dropdown/interfaces.d.ts.map +1 -1
- package/internal/components/menu-dropdown/interfaces.js.map +1 -1
- package/internal/environment.js +2 -2
- package/internal/environment.json +2 -2
- package/internal/manifest.json +1 -1
- package/item-card/interfaces.d.ts +0 -19
- package/item-card/interfaces.d.ts.map +1 -1
- package/item-card/interfaces.js.map +1 -1
- package/item-card/internal-interfaces.d.ts +21 -0
- package/item-card/internal-interfaces.d.ts.map +1 -0
- package/item-card/internal-interfaces.js +2 -0
- package/item-card/internal-interfaces.js.map +1 -0
- package/item-card/internal.d.ts +1 -1
- package/item-card/internal.d.ts.map +1 -1
- package/item-card/internal.js.map +1 -1
- package/manifest.json +2 -2
- package/mixed-line-bar-chart/chart-container.d.ts +2 -1
- package/mixed-line-bar-chart/chart-container.d.ts.map +1 -1
- package/mixed-line-bar-chart/chart-container.js.map +1 -1
- package/mixed-line-bar-chart/chart-legend.d.ts +2 -1
- package/mixed-line-bar-chart/chart-legend.d.ts.map +1 -1
- package/mixed-line-bar-chart/chart-legend.js.map +1 -1
- package/mixed-line-bar-chart/data-series.d.ts +2 -1
- package/mixed-line-bar-chart/data-series.d.ts.map +1 -1
- package/mixed-line-bar-chart/data-series.js.map +1 -1
- package/mixed-line-bar-chart/domain.d.ts +2 -1
- package/mixed-line-bar-chart/domain.d.ts.map +1 -1
- package/mixed-line-bar-chart/domain.js.map +1 -1
- package/mixed-line-bar-chart/format-highlighted.d.ts +2 -1
- package/mixed-line-bar-chart/format-highlighted.d.ts.map +1 -1
- package/mixed-line-bar-chart/format-highlighted.js.map +1 -1
- package/mixed-line-bar-chart/interfaces.d.ts +0 -5
- package/mixed-line-bar-chart/interfaces.d.ts.map +1 -1
- package/mixed-line-bar-chart/interfaces.js.map +1 -1
- package/mixed-line-bar-chart/internal-interfaces.d.ts +6 -0
- package/mixed-line-bar-chart/internal-interfaces.d.ts.map +1 -0
- package/mixed-line-bar-chart/internal-interfaces.js +2 -0
- package/mixed-line-bar-chart/internal-interfaces.js.map +1 -0
- package/mixed-line-bar-chart/make-scaled-bar-groups.d.ts +2 -1
- package/mixed-line-bar-chart/make-scaled-bar-groups.d.ts.map +1 -1
- package/mixed-line-bar-chart/make-scaled-bar-groups.js.map +1 -1
- package/mixed-line-bar-chart/make-scaled-series.d.ts +2 -1
- package/mixed-line-bar-chart/make-scaled-series.d.ts.map +1 -1
- package/mixed-line-bar-chart/make-scaled-series.js.map +1 -1
- package/mixed-line-bar-chart/utils.d.ts +2 -1
- package/mixed-line-bar-chart/utils.d.ts.map +1 -1
- package/mixed-line-bar-chart/utils.js.map +1 -1
- package/navigable-group/interfaces.d.ts +0 -2
- package/navigable-group/interfaces.d.ts.map +1 -1
- package/navigable-group/interfaces.js.map +1 -1
- package/navigable-group/internal-interfaces.d.ts +3 -0
- package/navigable-group/internal-interfaces.d.ts.map +1 -0
- package/navigable-group/internal-interfaces.js +4 -0
- package/navigable-group/internal-interfaces.js.map +1 -0
- package/navigable-group/internal.d.ts +2 -1
- package/navigable-group/internal.d.ts.map +1 -1
- package/navigable-group/internal.js.map +1 -1
- package/package.json +1 -1
- package/popover/arrow.d.ts +1 -1
- package/popover/arrow.d.ts.map +1 -1
- package/popover/arrow.js.map +1 -1
- package/popover/container.d.ts +2 -1
- package/popover/container.d.ts.map +1 -1
- package/popover/container.js.map +1 -1
- package/popover/interfaces.d.ts +0 -4
- package/popover/interfaces.d.ts.map +1 -1
- package/popover/interfaces.js.map +1 -1
- package/popover/internal-interfaces.d.ts +4 -0
- package/popover/internal-interfaces.d.ts.map +1 -0
- package/popover/internal-interfaces.js +4 -0
- package/popover/internal-interfaces.js.map +1 -0
- package/popover/use-popover-position.d.ts +2 -1
- package/popover/use-popover-position.d.ts.map +1 -1
- package/popover/use-popover-position.js.map +1 -1
- package/popover/utils/positions.d.ts +2 -1
- package/popover/utils/positions.d.ts.map +1 -1
- package/popover/utils/positions.js.map +1 -1
- package/property-filter/controller.d.ts +2 -1
- package/property-filter/controller.d.ts.map +1 -1
- package/property-filter/controller.js.map +1 -1
- package/property-filter/i18n-utils.d.ts +2 -1
- package/property-filter/i18n-utils.d.ts.map +1 -1
- package/property-filter/i18n-utils.js.map +1 -1
- package/property-filter/interfaces.d.ts +2 -51
- package/property-filter/interfaces.d.ts.map +1 -1
- package/property-filter/interfaces.js.map +1 -1
- package/property-filter/internal-interfaces.d.ts +51 -0
- package/property-filter/internal-interfaces.d.ts.map +1 -0
- package/property-filter/internal-interfaces.js +4 -0
- package/property-filter/internal-interfaces.js.map +1 -0
- package/property-filter/internal.d.ts.map +1 -1
- package/property-filter/internal.js.map +1 -1
- package/property-filter/property-editor.d.ts +2 -1
- package/property-filter/property-editor.d.ts.map +1 -1
- package/property-filter/property-editor.js.map +1 -1
- package/property-filter/token-editor-inputs.d.ts +2 -1
- package/property-filter/token-editor-inputs.d.ts.map +1 -1
- package/property-filter/token-editor-inputs.js.map +1 -1
- package/property-filter/token-editor.d.ts +2 -1
- package/property-filter/token-editor.d.ts.map +1 -1
- package/property-filter/token-editor.js.map +1 -1
- package/property-filter/token.d.ts +2 -1
- package/property-filter/token.d.ts.map +1 -1
- package/property-filter/token.js.map +1 -1
- package/property-filter/utils.d.ts +2 -1
- package/property-filter/utils.d.ts.map +1 -1
- package/property-filter/utils.js.map +1 -1
- package/table/interfaces.d.ts +0 -1
- package/table/interfaces.d.ts.map +1 -1
- package/table/interfaces.js.map +1 -1
- package/table/internal-interfaces.d.ts +2 -0
- package/table/internal-interfaces.d.ts.map +1 -0
- package/table/internal-interfaces.js +2 -0
- package/table/internal-interfaces.js.map +1 -0
- package/table/selection/use-group-selection.d.ts +2 -1
- package/table/selection/use-group-selection.d.ts.map +1 -1
- package/table/selection/use-group-selection.js.map +1 -1
- package/table/selection/use-selection-focus-move.d.ts +1 -1
- package/table/selection/use-selection-focus-move.d.ts.map +1 -1
- package/table/selection/use-selection-focus-move.js.map +1 -1
- package/table/selection/use-selection.d.ts +2 -1
- package/table/selection/use-selection.d.ts.map +1 -1
- package/table/selection/use-selection.js.map +1 -1
- package/table/thead.d.ts +2 -1
- package/table/thead.d.ts.map +1 -1
- package/table/thead.js.map +1 -1
- package/table/use-table-focus-navigation.d.ts +2 -1
- package/table/use-table-focus-navigation.d.ts.map +1 -1
- package/table/use-table-focus-navigation.js.map +1 -1
- package/tooltip/interfaces.d.ts +0 -10
- package/tooltip/interfaces.d.ts.map +1 -1
- package/tooltip/interfaces.js.map +1 -1
- package/tooltip/internal-interfaces.d.ts +11 -0
- package/tooltip/internal-interfaces.d.ts.map +1 -0
- package/tooltip/internal-interfaces.js +2 -0
- package/tooltip/internal-interfaces.js.map +1 -0
- package/tooltip/internal.d.ts +1 -1
- package/tooltip/internal.d.ts.map +1 -1
- package/tooltip/internal.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"positions.js","sourceRoot":"","sources":["../../../../src/popover/utils/positions.ts"],"names":[],"mappings":"AAiBA,MAAM,YAAY,GAAG,EAAE,CAAC;AAExB,MAAM,CAAC,MAAM,gBAAgB,GAAsD;IACjF,GAAG,EAAE;QACH,YAAY;QACZ,WAAW;QACX,UAAU;QACV,eAAe;QACf,cAAc;QACd,aAAa;QACb,WAAW;QACX,cAAc;QACd,U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,aAAa,GAAG,eAAe,GAAG,uBAAuB,CAAC;IAChE,MAAM,YAAY,GAAG,cAAc,GAAG,sBAAsB,CAAC;IAC7D,MAAM,iBAAiB,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;IACnE,MAAM,gBAAgB,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;IAEhE,OAAO;QACL,gBAAgB,EAAE,uBAAuB;QACzC,eAAe,EAAE,sBAAsB;QACvC,UAAU,EAAE,iBAAiB;QAC7B,SAAS,EAAE,gBAAgB;QAC3B,cAAc,EAAE,uBAAuB,GAAG,iBAAiB;QAC3D,aAAa,EAAE,sBAAsB,GAAG,gBAAgB;KACzD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAAW,EAAE,MAAY;IACvD,MAAM,WAAW,GAAG,KAAK,CAAC,eAAe,GAAG,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC;IAChE,MAAM,mBAAmB,GAAG,WAAW,GAAG,MAAM,CAAC,eAAe,CAAC;IACjE,MAAM,iBAAiB,GAAG,WAAW,GAAG,MAAM,CAAC,aAAa,CAAC;IAC7D,OAAO,mBAAmB,IAAI,iBAAiB,CAAC;AAClD,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BoundingBox, Dimensions, InternalPosition, PopoverProps, Rect } from '../interfaces';\n\n// A structure describing how the popover should be positioned\ninterface CalculatedPosition {\n scrollable?: boolean;\n internalPosition: InternalPosition;\n rect: BoundingBox;\n}\n\ninterface ElementGroup {\n body: Dimensions;\n trigger: BoundingBox;\n arrow: Dimensions;\n}\n\nconst ARROW_OFFSET = 12;\n\nexport const PRIORITY_MAPPING: Record<PopoverProps.Position, InternalPosition[]> = {\n top: [\n 'top-center',\n 'top-right',\n 'top-left',\n 'bottom-center',\n 'bottom-right',\n 'bottom-left',\n 'right-top',\n 'right-bottom',\n 'left-top',\n 'left-bottom',\n ],\n bottom: [\n 'bottom-center',\n 'bottom-right',\n 'bottom-left',\n 'top-center',\n 'top-right',\n 'top-left',\n 'right-top',\n 'right-bottom',\n 'left-top',\n 'left-bottom',\n ],\n left: [\n 'left-top',\n 'left-bottom',\n 'right-top',\n 'right-bottom',\n 'bottom-center',\n 'top-center',\n 'bottom-left',\n 'top-left',\n 'bottom-right',\n 'top-right',\n ],\n right: [\n 'right-top',\n 'right-bottom',\n 'left-top',\n 'left-bottom',\n 'bottom-center',\n 'top-center',\n 'bottom-right',\n 'top-right',\n 'bottom-left',\n 'top-left',\n ],\n};\n\nconst RECTANGLE_CALCULATIONS: Record<InternalPosition, (r: ElementGroup) => BoundingBox> = {\n 'top-center': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart: trigger.insetBlockStart - body.blockSize - arrow.blockSize,\n insetInlineStart: trigger.insetInlineStart + trigger.inlineSize / 2 - body.inlineSize / 2,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n 'top-right': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart: trigger.insetBlockStart - body.blockSize - arrow.blockSize,\n insetInlineStart: trigger.insetInlineStart + trigger.inlineSize / 2 - ARROW_OFFSET - arrow.inlineSize / 2,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n 'top-left': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart: trigger.insetBlockStart - body.blockSize - arrow.blockSize,\n insetInlineStart:\n trigger.insetInlineStart + trigger.inlineSize / 2 + ARROW_OFFSET + arrow.inlineSize / 2 - body.inlineSize,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n 'bottom-center': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart: trigger.insetBlockStart + trigger.blockSize + arrow.blockSize,\n insetInlineStart: trigger.insetInlineStart + trigger.inlineSize / 2 - body.inlineSize / 2,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n 'bottom-right': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart: trigger.insetBlockStart + trigger.blockSize + arrow.blockSize,\n insetInlineStart: trigger.insetInlineStart + trigger.inlineSize / 2 - ARROW_OFFSET - arrow.inlineSize / 2,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n 'bottom-left': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart: trigger.insetBlockStart + trigger.blockSize + arrow.blockSize,\n insetInlineStart:\n trigger.insetInlineStart + trigger.inlineSize / 2 + ARROW_OFFSET + arrow.inlineSize / 2 - body.inlineSize,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n 'right-top': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart: trigger.insetBlockStart + trigger.blockSize / 2 - ARROW_OFFSET - arrow.blockSize,\n insetInlineStart: trigger.insetInlineStart + trigger.inlineSize + arrow.blockSize,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n 'right-bottom': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart:\n trigger.insetBlockStart + trigger.blockSize / 2 - body.blockSize + ARROW_OFFSET + arrow.blockSize,\n insetInlineStart: trigger.insetInlineStart + trigger.inlineSize + arrow.blockSize,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n 'left-top': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart: trigger.insetBlockStart + trigger.blockSize / 2 - ARROW_OFFSET - arrow.blockSize,\n insetInlineStart: trigger.insetInlineStart - body.inlineSize - arrow.blockSize,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n 'left-bottom': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart:\n trigger.insetBlockStart + trigger.blockSize / 2 - body.blockSize + ARROW_OFFSET + arrow.blockSize,\n insetInlineStart: trigger.insetInlineStart - body.inlineSize - arrow.blockSize,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n};\n\nfunction fitIntoContainer(inner: BoundingBox, outer: BoundingBox): BoundingBox {\n let { insetInlineStart, inlineSize, insetBlockStart, blockSize } = inner;\n\n // Adjust left boundary.\n if (insetInlineStart < outer.insetInlineStart) {\n inlineSize = insetInlineStart + inlineSize - outer.insetInlineStart;\n insetInlineStart = outer.insetInlineStart;\n }\n // Adjust right boundary.\n else if (insetInlineStart + inlineSize > outer.insetInlineStart + outer.inlineSize) {\n inlineSize = outer.insetInlineStart + outer.inlineSize - insetInlineStart;\n }\n // Adjust top boundary.\n if (insetBlockStart < outer.insetBlockStart) {\n blockSize = insetBlockStart + blockSize - outer.insetBlockStart;\n insetBlockStart = outer.insetBlockStart;\n }\n // Adjust bottom boundary.\n else if (insetBlockStart + blockSize > outer.insetBlockStart + outer.blockSize) {\n blockSize = outer.insetBlockStart + outer.blockSize - insetBlockStart;\n }\n\n return { insetInlineStart, inlineSize, insetBlockStart, blockSize };\n}\n\nfunction getTallestRect(rect1: BoundingBox, rect2: BoundingBox): BoundingBox {\n return rect1.blockSize >= rect2.blockSize ? rect1 : rect2;\n}\n\nfunction getIntersection(rectangles: BoundingBox[]): BoundingBox | null {\n let boundingBox: BoundingBox | null = null;\n for (const currentRect of rectangles) {\n if (!boundingBox) {\n boundingBox = currentRect;\n continue;\n }\n const insetInlineStart = Math.max(boundingBox.insetInlineStart, currentRect.insetInlineStart);\n const insetBlockStart = Math.max(boundingBox.insetBlockStart, currentRect.insetBlockStart);\n const insetInlineEnd = Math.min(\n boundingBox.insetInlineStart + boundingBox.inlineSize,\n currentRect.insetInlineStart + currentRect.inlineSize\n );\n const insetBlockEnd = Math.min(\n boundingBox.insetBlockStart + boundingBox.blockSize,\n currentRect.insetBlockStart + currentRect.blockSize\n );\n\n if (insetInlineEnd < insetInlineStart || insetBlockEnd < insetBlockStart) {\n return null;\n }\n boundingBox = {\n insetInlineStart,\n insetBlockStart,\n inlineSize: insetInlineEnd - insetInlineStart,\n blockSize: insetBlockEnd - insetBlockStart,\n };\n }\n return boundingBox;\n}\n\n/**\n * Returns the area of the intersection of passed in rectangles or a null, if there is no intersection\n */\nexport function intersectRectangles(rectangles: BoundingBox[]): number | null {\n const boundingBox: BoundingBox | null = getIntersection(rectangles);\n return boundingBox && boundingBox.blockSize * boundingBox.inlineSize;\n}\n\ntype CandidatePosition = CalculatedPosition & { visibleArea: BoundingBox | null };\n\n/**\n * A functions that returns the correct popover position based on screen dimensions.\n */\nexport function calculatePosition({\n preferredPosition,\n fixedInternalPosition,\n trigger,\n arrow,\n body,\n container,\n viewport,\n // the popover is only bound by the viewport if it is rendered in a portal\n renderWithPortal,\n allowVerticalOverflow,\n minVisibleBlockSize,\n}: {\n preferredPosition: PopoverProps.Position;\n fixedInternalPosition?: InternalPosition;\n trigger: BoundingBox;\n arrow: Dimensions;\n body: Dimensions;\n container: BoundingBox;\n viewport: BoundingBox;\n // the popover is only bound by the viewport if it is rendered in a portal\n renderWithPortal?: boolean;\n allowVerticalOverflow?: boolean;\n minVisibleBlockSize?: number;\n}): CalculatedPosition {\n let bestOption: CandidatePosition | null = null;\n\n // If a fixed internal position is passed, only consider this one.\n const preferredInternalPositions = fixedInternalPosition\n ? [fixedInternalPosition]\n : PRIORITY_MAPPING[preferredPosition];\n\n // Attempt to position the popover based on the priority list for this position.\n for (const internalPosition of preferredInternalPositions) {\n const rect = RECTANGLE_CALCULATIONS[internalPosition]({ body, trigger, arrow });\n const visibleArea = renderWithPortal\n ? getIntersection([rect, viewport])\n : getIntersection([rect, viewport, container]);\n\n // When min visible block size is set, the popover is considered fitting the container if the available space\n // is the same or larger than min allowed, even if it means the scrollbar is needed.\n const fitsBlockSize =\n minVisibleBlockSize === undefined\n ? visibleArea && visibleArea.blockSize === body.blockSize\n : visibleArea && visibleArea.blockSize >= Math.min(body.blockSize, minVisibleBlockSize);\n const fitsInlineSize = visibleArea && visibleArea.inlineSize === body.inlineSize;\n\n if (fitsBlockSize && fitsInlineSize) {\n const scrollable = visibleArea && visibleArea.blockSize < body.blockSize;\n return { internalPosition, rect: scrollable ? fitIntoContainer(rect, viewport) : rect, scrollable };\n }\n\n const newOption = { rect, internalPosition, visibleArea };\n bestOption = getBestOption(newOption, bestOption);\n }\n\n // Use best possible placement.\n const internalPosition = bestOption?.internalPosition || 'right-top';\n // Get default rect for that placement.\n const rect = RECTANGLE_CALCULATIONS[internalPosition]({ body, trigger, arrow });\n\n // Get largest possible rect that fits into the viewport or container.\n\n // We allow the popover to overflow the viewport if allowVerticalOverflow is true _and_ the popover will be anchored to the top or the bottom.\n // If it is anchored to the right or left, we consider that it should have enough vertical space so that applying scroll to it is a better option.\n const tallestBoundingContainer = getTallestRect(viewport, container);\n const boundingContainer =\n allowVerticalOverflow && isTopOrBottom(internalPosition)\n ? {\n insetBlockStart: tallestBoundingContainer.insetBlockStart,\n blockSize: tallestBoundingContainer.blockSize,\n insetInlineStart: viewport.insetInlineStart,\n inlineSize: viewport.inlineSize,\n }\n : viewport;\n\n const optimizedRect = fitIntoContainer(rect, boundingContainer);\n\n // If largest possible rect is shorter than original - set body scroll.\n const scrollable = optimizedRect.blockSize < rect.blockSize;\n\n return { internalPosition, rect: optimizedRect, scrollable };\n}\n\nfunction getBestOption(option1: CandidatePosition, option2: CandidatePosition | null) {\n // Within calculatePosition, the only case where option2 will not be defined will be in the first call.\n // The only case where the visibleArea of an option will be null is when the popover is totally outside of the viewport.\n if (!option2?.visibleArea) {\n return option1;\n }\n if (!option1.visibleArea) {\n return option2;\n }\n // Only if none of the two options overflows horizontally, choose the best based on the visible height.\n if (option1.visibleArea.inlineSize === option2.visibleArea.inlineSize) {\n return option1.visibleArea.blockSize > option2.visibleArea.blockSize ? option1 : option2;\n }\n // Otherwise, choose the option that is less cut off horizontally.\n return option1.visibleArea.inlineSize > option2.visibleArea.inlineSize ? option1 : option2;\n}\n\nexport function getOffsetDimensions(element: HTMLElement) {\n return { offsetHeight: element.offsetHeight, offsetWidth: element.offsetWidth };\n}\n\nexport function getDimensions(element: HTMLElement) {\n const computedStyle = getComputedStyle(element);\n return {\n inlineSize: parseFloat(computedStyle.inlineSize),\n blockSize: parseFloat(computedStyle.blockSize),\n };\n}\n\nfunction isTopOrBottom(internalPosition: InternalPosition) {\n return ['top', 'bottom'].includes(internalPosition.split('-')[0]);\n}\n\nexport function clampRect(rect: Rect, bounds?: BoundingBox) {\n if (!bounds) {\n return rect;\n }\n const parentInlineEnd = bounds.insetInlineStart + bounds.inlineSize;\n const parentBlockEnd = bounds.insetBlockStart + bounds.blockSize;\n\n const clampedInsetInlineStart = Math.max(bounds.insetInlineStart, Math.min(rect.insetInlineStart, parentInlineEnd));\n const clampedInsetBlockStart = Math.max(bounds.insetBlockStart, Math.min(rect.insetBlockStart, parentBlockEnd));\n\n const maxInlineSize = parentInlineEnd - clampedInsetInlineStart;\n const maxBlockSize = parentBlockEnd - clampedInsetBlockStart;\n const clampedInlineSize = Math.min(rect.inlineSize, maxInlineSize);\n const clampedBlockSize = Math.min(rect.blockSize, maxBlockSize);\n\n return {\n insetInlineStart: clampedInsetInlineStart,\n insetBlockStart: clampedInsetBlockStart,\n inlineSize: clampedInlineSize,\n blockSize: clampedBlockSize,\n insetInlineEnd: clampedInsetInlineStart + clampedInlineSize,\n insetBlockEnd: clampedInsetBlockStart + clampedBlockSize,\n };\n}\n\nexport function isCenterOutside(child: Rect, parent: Rect) {\n const childCenter = child.insetBlockStart + child.blockSize / 2;\n const overflowsBlockStart = childCenter < parent.insetBlockStart;\n const overflowsBlockEnd = childCenter > parent.insetBlockEnd;\n return overflowsBlockStart || overflowsBlockEnd;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"positions.js","sourceRoot":"","sources":["../../../../src/popover/utils/positions.ts"],"names":[],"mappings":"AAkBA,MAAM,YAAY,GAAG,EAAE,CAAC;AAExB,MAAM,CAAC,MAAM,gBAAgB,GAAsD;IACjF,GAAG,EAAE;QACH,YAAY;QACZ,WAAW;QACX,UAAU;QACV,eAAe;QACf,cAAc;QACd,aAAa;QACb,WAAW;QACX,cAAc;Q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MAAM,aAAa,GAAG,eAAe,GAAG,uBAAuB,CAAC;IAChE,MAAM,YAAY,GAAG,cAAc,GAAG,sBAAsB,CAAC;IAC7D,MAAM,iBAAiB,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;IACnE,MAAM,gBAAgB,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;IAEhE,OAAO;QACL,gBAAgB,EAAE,uBAAuB;QACzC,eAAe,EAAE,sBAAsB;QACvC,UAAU,EAAE,iBAAiB;QAC7B,SAAS,EAAE,gBAAgB;QAC3B,cAAc,EAAE,uBAAuB,GAAG,iBAAiB;QAC3D,aAAa,EAAE,sBAAsB,GAAG,gBAAgB;KACzD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAAW,EAAE,MAAY;IACvD,MAAM,WAAW,GAAG,KAAK,CAAC,eAAe,GAAG,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC;IAChE,MAAM,mBAAmB,GAAG,WAAW,GAAG,MAAM,CAAC,eAAe,CAAC;IACjE,MAAM,iBAAiB,GAAG,WAAW,GAAG,MAAM,CAAC,aAAa,CAAC;IAC7D,OAAO,mBAAmB,IAAI,iBAAiB,CAAC;AAClD,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BoundingBox, Dimensions, PopoverProps, Rect } from '../interfaces';\nimport { InternalPosition } from '../internal-interfaces';\n\n// A structure describing how the popover should be positioned\ninterface CalculatedPosition {\n scrollable?: boolean;\n internalPosition: InternalPosition;\n rect: BoundingBox;\n}\n\ninterface ElementGroup {\n body: Dimensions;\n trigger: BoundingBox;\n arrow: Dimensions;\n}\n\nconst ARROW_OFFSET = 12;\n\nexport const PRIORITY_MAPPING: Record<PopoverProps.Position, InternalPosition[]> = {\n top: [\n 'top-center',\n 'top-right',\n 'top-left',\n 'bottom-center',\n 'bottom-right',\n 'bottom-left',\n 'right-top',\n 'right-bottom',\n 'left-top',\n 'left-bottom',\n ],\n bottom: [\n 'bottom-center',\n 'bottom-right',\n 'bottom-left',\n 'top-center',\n 'top-right',\n 'top-left',\n 'right-top',\n 'right-bottom',\n 'left-top',\n 'left-bottom',\n ],\n left: [\n 'left-top',\n 'left-bottom',\n 'right-top',\n 'right-bottom',\n 'bottom-center',\n 'top-center',\n 'bottom-left',\n 'top-left',\n 'bottom-right',\n 'top-right',\n ],\n right: [\n 'right-top',\n 'right-bottom',\n 'left-top',\n 'left-bottom',\n 'bottom-center',\n 'top-center',\n 'bottom-right',\n 'top-right',\n 'bottom-left',\n 'top-left',\n ],\n};\n\nconst RECTANGLE_CALCULATIONS: Record<InternalPosition, (r: ElementGroup) => BoundingBox> = {\n 'top-center': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart: trigger.insetBlockStart - body.blockSize - arrow.blockSize,\n insetInlineStart: trigger.insetInlineStart + trigger.inlineSize / 2 - body.inlineSize / 2,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n 'top-right': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart: trigger.insetBlockStart - body.blockSize - arrow.blockSize,\n insetInlineStart: trigger.insetInlineStart + trigger.inlineSize / 2 - ARROW_OFFSET - arrow.inlineSize / 2,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n 'top-left': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart: trigger.insetBlockStart - body.blockSize - arrow.blockSize,\n insetInlineStart:\n trigger.insetInlineStart + trigger.inlineSize / 2 + ARROW_OFFSET + arrow.inlineSize / 2 - body.inlineSize,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n 'bottom-center': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart: trigger.insetBlockStart + trigger.blockSize + arrow.blockSize,\n insetInlineStart: trigger.insetInlineStart + trigger.inlineSize / 2 - body.inlineSize / 2,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n 'bottom-right': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart: trigger.insetBlockStart + trigger.blockSize + arrow.blockSize,\n insetInlineStart: trigger.insetInlineStart + trigger.inlineSize / 2 - ARROW_OFFSET - arrow.inlineSize / 2,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n 'bottom-left': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart: trigger.insetBlockStart + trigger.blockSize + arrow.blockSize,\n insetInlineStart:\n trigger.insetInlineStart + trigger.inlineSize / 2 + ARROW_OFFSET + arrow.inlineSize / 2 - body.inlineSize,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n 'right-top': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart: trigger.insetBlockStart + trigger.blockSize / 2 - ARROW_OFFSET - arrow.blockSize,\n insetInlineStart: trigger.insetInlineStart + trigger.inlineSize + arrow.blockSize,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n 'right-bottom': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart:\n trigger.insetBlockStart + trigger.blockSize / 2 - body.blockSize + ARROW_OFFSET + arrow.blockSize,\n insetInlineStart: trigger.insetInlineStart + trigger.inlineSize + arrow.blockSize,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n 'left-top': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart: trigger.insetBlockStart + trigger.blockSize / 2 - ARROW_OFFSET - arrow.blockSize,\n insetInlineStart: trigger.insetInlineStart - body.inlineSize - arrow.blockSize,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n 'left-bottom': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart:\n trigger.insetBlockStart + trigger.blockSize / 2 - body.blockSize + ARROW_OFFSET + arrow.blockSize,\n insetInlineStart: trigger.insetInlineStart - body.inlineSize - arrow.blockSize,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n};\n\nfunction fitIntoContainer(inner: BoundingBox, outer: BoundingBox): BoundingBox {\n let { insetInlineStart, inlineSize, insetBlockStart, blockSize } = inner;\n\n // Adjust left boundary.\n if (insetInlineStart < outer.insetInlineStart) {\n inlineSize = insetInlineStart + inlineSize - outer.insetInlineStart;\n insetInlineStart = outer.insetInlineStart;\n }\n // Adjust right boundary.\n else if (insetInlineStart + inlineSize > outer.insetInlineStart + outer.inlineSize) {\n inlineSize = outer.insetInlineStart + outer.inlineSize - insetInlineStart;\n }\n // Adjust top boundary.\n if (insetBlockStart < outer.insetBlockStart) {\n blockSize = insetBlockStart + blockSize - outer.insetBlockStart;\n insetBlockStart = outer.insetBlockStart;\n }\n // Adjust bottom boundary.\n else if (insetBlockStart + blockSize > outer.insetBlockStart + outer.blockSize) {\n blockSize = outer.insetBlockStart + outer.blockSize - insetBlockStart;\n }\n\n return { insetInlineStart, inlineSize, insetBlockStart, blockSize };\n}\n\nfunction getTallestRect(rect1: BoundingBox, rect2: BoundingBox): BoundingBox {\n return rect1.blockSize >= rect2.blockSize ? rect1 : rect2;\n}\n\nfunction getIntersection(rectangles: BoundingBox[]): BoundingBox | null {\n let boundingBox: BoundingBox | null = null;\n for (const currentRect of rectangles) {\n if (!boundingBox) {\n boundingBox = currentRect;\n continue;\n }\n const insetInlineStart = Math.max(boundingBox.insetInlineStart, currentRect.insetInlineStart);\n const insetBlockStart = Math.max(boundingBox.insetBlockStart, currentRect.insetBlockStart);\n const insetInlineEnd = Math.min(\n boundingBox.insetInlineStart + boundingBox.inlineSize,\n currentRect.insetInlineStart + currentRect.inlineSize\n );\n const insetBlockEnd = Math.min(\n boundingBox.insetBlockStart + boundingBox.blockSize,\n currentRect.insetBlockStart + currentRect.blockSize\n );\n\n if (insetInlineEnd < insetInlineStart || insetBlockEnd < insetBlockStart) {\n return null;\n }\n boundingBox = {\n insetInlineStart,\n insetBlockStart,\n inlineSize: insetInlineEnd - insetInlineStart,\n blockSize: insetBlockEnd - insetBlockStart,\n };\n }\n return boundingBox;\n}\n\n/**\n * Returns the area of the intersection of passed in rectangles or a null, if there is no intersection\n */\nexport function intersectRectangles(rectangles: BoundingBox[]): number | null {\n const boundingBox: BoundingBox | null = getIntersection(rectangles);\n return boundingBox && boundingBox.blockSize * boundingBox.inlineSize;\n}\n\ntype CandidatePosition = CalculatedPosition & { visibleArea: BoundingBox | null };\n\n/**\n * A functions that returns the correct popover position based on screen dimensions.\n */\nexport function calculatePosition({\n preferredPosition,\n fixedInternalPosition,\n trigger,\n arrow,\n body,\n container,\n viewport,\n // the popover is only bound by the viewport if it is rendered in a portal\n renderWithPortal,\n allowVerticalOverflow,\n minVisibleBlockSize,\n}: {\n preferredPosition: PopoverProps.Position;\n fixedInternalPosition?: InternalPosition;\n trigger: BoundingBox;\n arrow: Dimensions;\n body: Dimensions;\n container: BoundingBox;\n viewport: BoundingBox;\n // the popover is only bound by the viewport if it is rendered in a portal\n renderWithPortal?: boolean;\n allowVerticalOverflow?: boolean;\n minVisibleBlockSize?: number;\n}): CalculatedPosition {\n let bestOption: CandidatePosition | null = null;\n\n // If a fixed internal position is passed, only consider this one.\n const preferredInternalPositions = fixedInternalPosition\n ? [fixedInternalPosition]\n : PRIORITY_MAPPING[preferredPosition];\n\n // Attempt to position the popover based on the priority list for this position.\n for (const internalPosition of preferredInternalPositions) {\n const rect = RECTANGLE_CALCULATIONS[internalPosition]({ body, trigger, arrow });\n const visibleArea = renderWithPortal\n ? getIntersection([rect, viewport])\n : getIntersection([rect, viewport, container]);\n\n // When min visible block size is set, the popover is considered fitting the container if the available space\n // is the same or larger than min allowed, even if it means the scrollbar is needed.\n const fitsBlockSize =\n minVisibleBlockSize === undefined\n ? visibleArea && visibleArea.blockSize === body.blockSize\n : visibleArea && visibleArea.blockSize >= Math.min(body.blockSize, minVisibleBlockSize);\n const fitsInlineSize = visibleArea && visibleArea.inlineSize === body.inlineSize;\n\n if (fitsBlockSize && fitsInlineSize) {\n const scrollable = visibleArea && visibleArea.blockSize < body.blockSize;\n return { internalPosition, rect: scrollable ? fitIntoContainer(rect, viewport) : rect, scrollable };\n }\n\n const newOption = { rect, internalPosition, visibleArea };\n bestOption = getBestOption(newOption, bestOption);\n }\n\n // Use best possible placement.\n const internalPosition = bestOption?.internalPosition || 'right-top';\n // Get default rect for that placement.\n const rect = RECTANGLE_CALCULATIONS[internalPosition]({ body, trigger, arrow });\n\n // Get largest possible rect that fits into the viewport or container.\n\n // We allow the popover to overflow the viewport if allowVerticalOverflow is true _and_ the popover will be anchored to the top or the bottom.\n // If it is anchored to the right or left, we consider that it should have enough vertical space so that applying scroll to it is a better option.\n const tallestBoundingContainer = getTallestRect(viewport, container);\n const boundingContainer =\n allowVerticalOverflow && isTopOrBottom(internalPosition)\n ? {\n insetBlockStart: tallestBoundingContainer.insetBlockStart,\n blockSize: tallestBoundingContainer.blockSize,\n insetInlineStart: viewport.insetInlineStart,\n inlineSize: viewport.inlineSize,\n }\n : viewport;\n\n const optimizedRect = fitIntoContainer(rect, boundingContainer);\n\n // If largest possible rect is shorter than original - set body scroll.\n const scrollable = optimizedRect.blockSize < rect.blockSize;\n\n return { internalPosition, rect: optimizedRect, scrollable };\n}\n\nfunction getBestOption(option1: CandidatePosition, option2: CandidatePosition | null) {\n // Within calculatePosition, the only case where option2 will not be defined will be in the first call.\n // The only case where the visibleArea of an option will be null is when the popover is totally outside of the viewport.\n if (!option2?.visibleArea) {\n return option1;\n }\n if (!option1.visibleArea) {\n return option2;\n }\n // Only if none of the two options overflows horizontally, choose the best based on the visible height.\n if (option1.visibleArea.inlineSize === option2.visibleArea.inlineSize) {\n return option1.visibleArea.blockSize > option2.visibleArea.blockSize ? option1 : option2;\n }\n // Otherwise, choose the option that is less cut off horizontally.\n return option1.visibleArea.inlineSize > option2.visibleArea.inlineSize ? option1 : option2;\n}\n\nexport function getOffsetDimensions(element: HTMLElement) {\n return { offsetHeight: element.offsetHeight, offsetWidth: element.offsetWidth };\n}\n\nexport function getDimensions(element: HTMLElement) {\n const computedStyle = getComputedStyle(element);\n return {\n inlineSize: parseFloat(computedStyle.inlineSize),\n blockSize: parseFloat(computedStyle.blockSize),\n };\n}\n\nfunction isTopOrBottom(internalPosition: InternalPosition) {\n return ['top', 'bottom'].includes(internalPosition.split('-')[0]);\n}\n\nexport function clampRect(rect: Rect, bounds?: BoundingBox) {\n if (!bounds) {\n return rect;\n }\n const parentInlineEnd = bounds.insetInlineStart + bounds.inlineSize;\n const parentBlockEnd = bounds.insetBlockStart + bounds.blockSize;\n\n const clampedInsetInlineStart = Math.max(bounds.insetInlineStart, Math.min(rect.insetInlineStart, parentInlineEnd));\n const clampedInsetBlockStart = Math.max(bounds.insetBlockStart, Math.min(rect.insetBlockStart, parentBlockEnd));\n\n const maxInlineSize = parentInlineEnd - clampedInsetInlineStart;\n const maxBlockSize = parentBlockEnd - clampedInsetBlockStart;\n const clampedInlineSize = Math.min(rect.inlineSize, maxInlineSize);\n const clampedBlockSize = Math.min(rect.blockSize, maxBlockSize);\n\n return {\n insetInlineStart: clampedInsetInlineStart,\n insetBlockStart: clampedInsetBlockStart,\n inlineSize: clampedInlineSize,\n blockSize: clampedBlockSize,\n insetInlineEnd: clampedInsetInlineStart + clampedInlineSize,\n insetBlockEnd: clampedInsetBlockStart + clampedBlockSize,\n };\n}\n\nexport function isCenterOutside(child: Rect, parent: Rect) {\n const childCenter = child.insetBlockStart + child.blockSize / 2;\n const overflowsBlockStart = childCenter < parent.insetBlockStart;\n const overflowsBlockEnd = childCenter > parent.insetBlockEnd;\n return overflowsBlockStart || overflowsBlockEnd;\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { NonCancelableEventHandler } from '../types/events';
|
|
2
2
|
import { I18nStringsOperators } from './i18n-utils';
|
|
3
|
-
import { ComparisonOperator, GroupText, I18nStrings,
|
|
3
|
+
import { ComparisonOperator, GroupText, I18nStrings, JoinOperation, Query } from './interfaces';
|
|
4
|
+
import { InternalFilteringOption, InternalFilteringProperty, InternalFreeTextFiltering, InternalQuery, InternalToken, InternalTokenGroup, ParsedText } from './internal-interfaces';
|
|
4
5
|
type I18nStringsController = I18nStringsOperators & Pick<I18nStrings, 'operatorsText' | 'groupPropertiesText' | 'groupValuesText'>;
|
|
5
6
|
export declare const getQueryActions: ({
|
|
6
7
|
query,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/property-filter/controller.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAyB,MAAM,cAAc,CAAC;AAC3E,OAAO,
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/property-filter/controller.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAyB,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,KAAK,EAAqB,MAAM,cAAc,CAAC;AACnH,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,yBAAyB,EACzB,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,UAAU,EACX,MAAM,uBAAuB,CAAC;AAY/B,KAAK,qBAAqB,GAAG,oBAAoB,GAC/C,IAAI,CAAC,WAAW,EAAE,eAAe,GAAG,qBAAqB,GAAG,iBAAiB,CAAC,CAAC;AAEjF,eAAO,MAAM,eAAe,GAAI,2DAK7B;IACD,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,yBAAyB,CAAC,KAAK,CAAC,CAAC;IAC3C,gBAAgB,EAAE,SAAS,uBAAuB,EAAE,CAAC;IACrD,iBAAiB,EAAE,OAAO,CAAC;CAC5B;sBAiB0B,aAAa;+BAKvB,MAAM,gBACL,aAAa,GAAG,kBAAkB,kBAChC,aAAa,EAAE;iCAmBG,aAAa;+BARf,MAAM;;CAazC,CAAC;AAIF,eAAO,MAAM,mBAAmB,GAAI,UAAU,yBAAyB,KAAG,kBAAkB,EAI3F,CAAC;AAEF,eAAO,MAAM,2BAA2B,GAAI,UAAU,yBAAyB,KAAG,kBAAkB,EAGnG,CAAC;AAQF,eAAO,MAAM,SAAS,GACpB,eAAe,MAAM,EACrB,qBAAqB,SAAS,yBAAyB,EAAE,EACzD,mBAAmB,yBAAyB,KAC3C,UA6CF,CAAC;AAEF,UAAU,WAAW,CAAC,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,CAAC,EAAE,CAAC;CACd;AAmDD,wBAAgB,sBAAsB,CAAC,CAAC,EACtC,mBAAmB,EAAE,SAAS,yBAAyB,EAAE,EACzD,gBAAgB,EAAE,SAAS,SAAS,EAAE,EACtC,WAAW,EAAE,qBAAqB,EAClC,yBAAyB,EAAE,CAAC,iBAAiB,EAAE,yBAAyB,KAAK,CAAC,oBA0B/E;AAED,eAAO,MAAM,qBAAqB,GAChC,YAAY,UAAU,EACtB,qBAAqB,SAAS,yBAAyB,EAAE,EACzD,kBAAkB,SAAS,uBAAuB,EAAE,EACpD,kBAAkB,SAAS,SAAS,EAAE,EACtC,aAAa,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiEnC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../src/property-filter/controller.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAGtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,OAAO,EAAwB,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAiB3E,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,SAAS,GACV,MAAM,SAAS,CAAC;AAKjB,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,CAAC,CAAC;YACpG,OAAO;gBACL,UAAU,EAAE,UAAU,CAAC,KAAK;gBAC5B,OAAO,EAAE;oBACP,GAAG,CAAC,wBAAwB;wBAC1B,CAAC,CAAC,sBAAsB,CACpB,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,oCAAoC,CACrC;wBACH,CAAC,CAAC,EAAE,CAAC;oBACP,GAAG,CAAC,qBAAqB;wBACvB,CAAC,CAAC,sBAAsB,CAAC,gBAAgB,EAAE,UAAU,CAAC,QAAQ,EAAE,WAAW,EAAE,gBAAgB,CAAC;wBAC9F,CAAC,CAAC,EAAE,CAAC;iBACR;aACF,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { AutosuggestProps } from '../autosuggest/interfaces';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { NonCancelableEventHandler } from '../types/events';\nimport { I18nStringsOperators, operatorToDescription } from './i18n-utils';\nimport {\n ComparisonOperator,\n GroupText,\n I18nStrings,\n InternalFilteringOption,\n InternalFilteringProperty,\n InternalFreeTextFiltering,\n InternalQuery,\n InternalToken,\n InternalTokenGroup,\n JoinOperation,\n ParsedText,\n Query,\n Token,\n TokenGroup,\n} from './interfaces';\nimport {\n isInternalToken,\n matchFilteringProperty,\n matchOperator,\n matchOperatorPrefix,\n matchTokenValue,\n removeOperator,\n tokenGroupToTokens,\n trimStart,\n} from './utils';\n\ntype I18nStringsController = I18nStringsOperators &\n Pick<I18nStrings, 'operatorsText' | 'groupPropertiesText' | 'groupValuesText'>;\n\nexport const getQueryActions = ({\n query,\n onChange,\n filteringOptions,\n enableTokenGroups,\n}: {\n query: InternalQuery;\n onChange: NonCancelableEventHandler<Query>;\n filteringOptions: readonly InternalFilteringOption[];\n enableTokenGroups: boolean;\n}) => {\n const setQuery = (query: InternalQuery) => {\n function transformToken(token: InternalToken | InternalTokenGroup): Token | TokenGroup {\n if (isInternalToken(token)) {\n return matchTokenValue(token, filteringOptions);\n }\n return { ...token, tokens: token.tokens.map(transformToken) };\n }\n const tokens = query.tokens.map(transformToken);\n\n if (enableTokenGroups) {\n fireNonCancelableEvent(onChange, { tokens: [], operation: query.operation, tokenGroups: tokens });\n } else {\n fireNonCancelableEvent(onChange, { tokens: tokenGroupToTokens<Token>(tokens), operation: query.operation });\n }\n };\n\n const addToken = (token: InternalToken) => {\n setQuery({ ...query, tokens: [...query.tokens, token] });\n };\n\n const updateToken = (\n updateIndex: number,\n updatedToken: InternalToken | InternalTokenGroup,\n releasedTokens: InternalToken[]\n ) => {\n const nestedTokens = tokenGroupToTokens<InternalToken>([updatedToken]);\n const capturedTokenIndices = nestedTokens.map(token => token.standaloneIndex).filter(index => index !== undefined);\n const tokens = query.tokens\n .map((token, index) => (index === updateIndex ? updatedToken : token))\n .filter((_, index) => index === updateIndex || !capturedTokenIndices.includes(index));\n tokens.push(...releasedTokens);\n setQuery({ ...query, tokens });\n };\n\n const removeToken = (removeIndex: number) => {\n setQuery({ ...query, tokens: query.tokens.filter((_, index) => index !== removeIndex) });\n };\n\n const removeAllTokens = () => {\n setQuery({ ...query, tokens: [] });\n };\n\n const updateOperation = (operation: JoinOperation) => {\n setQuery({ ...query, operation });\n };\n\n return { addToken, updateToken, updateOperation, removeToken, removeAllTokens };\n};\n\nconst operatorOrder = ['=', '!=', ':', '!:', '^', '!^', '>=', '<=', '<', '>'] as const;\n\nexport const getAllowedOperators = (property: InternalFilteringProperty): ComparisonOperator[] => {\n const { operators = [], defaultOperator } = property;\n const operatorSet = new Set([defaultOperator, ...operators]);\n return operatorOrder.filter(op => operatorSet.has(op));\n};\n\nexport const getAllowedFreeTextOperators = (freeText: InternalFreeTextFiltering): ComparisonOperator[] => {\n const operatorSet = new Set(freeText.operators);\n return operatorOrder.filter(op => operatorSet.has(op));\n};\n\n/*\n * parses the value of the filtering input to figure out the current step of entering the token:\n * - \"property\": means that a filter on a particular column is being added, with operator already finalized\n * - \"operator\": means that a filter on a particular column is being added, with operator not yet finalized\n * - \"free-text\": means that a \"free text\" token is being added\n */\nexport const parseText = (\n filteringText: string,\n filteringProperties: readonly InternalFilteringProperty[],\n freeTextFiltering: InternalFreeTextFiltering\n): ParsedText => {\n const property = matchFilteringProperty(filteringProperties, filteringText);\n if (!property) {\n if (!freeTextFiltering.disabled) {\n // For free text filtering, we allow ! as a shortcut for !:\n let freeTextOperators = getAllowedFreeTextOperators(freeTextFiltering);\n freeTextOperators = freeTextOperators.indexOf('!:') >= 0 ? ['!', ...freeTextOperators] : freeTextOperators;\n const operator = matchOperator(freeTextOperators, filteringText);\n if (operator) {\n return {\n step: 'free-text',\n operator: operator === '!' ? '!:' : operator,\n value: removeOperator(filteringText, operator),\n };\n }\n }\n\n return {\n step: 'free-text',\n value: filteringText,\n };\n }\n\n const allowedOps = getAllowedOperators(property);\n\n const textWithoutProperty = filteringText.substring(property.propertyLabel.length);\n const operator = matchOperator(allowedOps, trimStart(textWithoutProperty));\n if (operator) {\n return {\n step: 'property',\n property,\n operator,\n value: removeOperator(textWithoutProperty, operator),\n };\n }\n\n const operatorPrefix = matchOperatorPrefix(allowedOps, trimStart(textWithoutProperty));\n if (operatorPrefix !== null) {\n return { step: 'operator', property, operatorPrefix };\n }\n\n return {\n step: 'free-text',\n value: filteringText,\n };\n};\n\ninterface OptionGroup<T> {\n label: string;\n options: T[];\n}\n\nconst getAllValueSuggestions = (\n filteringOptions: readonly InternalFilteringOption[],\n operator: ComparisonOperator | undefined = '=',\n i18nStrings: I18nStringsController,\n customGroupsText: readonly GroupText[]\n) => {\n const defaultGroup: OptionGroup<AutosuggestProps.Option> = {\n label: i18nStrings.groupValuesText ?? '',\n options: [],\n };\n const customGroups: { [K in string]: OptionGroup<AutosuggestProps.Option> } = {};\n filteringOptions.forEach(filteringOption => {\n const property = filteringOption.property;\n // given option refers to a non-existent filtering property\n if (!property) {\n return;\n }\n // this option's filtering property does not support current operator\n if (getAllowedOperators(property).indexOf(operator) === -1) {\n return;\n }\n if (property.propertyGroup && !customGroups[property.propertyGroup]) {\n const label = customGroupsText.reduce<string>(\n (acc, customGroup) => (customGroup.group === property.propertyGroup ? customGroup.values : acc),\n ''\n );\n customGroups[property.propertyGroup] = {\n label,\n options: [],\n };\n }\n const propertyGroup = property.propertyGroup ? customGroups[property.propertyGroup] : defaultGroup;\n propertyGroup.options.push({\n value: property.propertyLabel + ' ' + (operator || '=') + ' ' + filteringOption.value,\n label: filteringOption.label,\n __labelPrefix: property.propertyLabel + ' ' + (operator || '='),\n tags: filteringOption.tags,\n filteringTags: filteringOption.filteringTags,\n });\n });\n return [defaultGroup, ...Object.keys(customGroups).map(group => customGroups[group])];\n};\n\nconst filteringPropertyToAutosuggestOption = (filteringProperty: InternalFilteringProperty) => ({\n value: filteringProperty.propertyLabel,\n label: filteringProperty.propertyLabel,\n keepOpenOnSelect: true,\n});\n\nexport function getPropertySuggestions<T>(\n filteringProperties: readonly InternalFilteringProperty[],\n customGroupsText: readonly GroupText[],\n i18nStrings: I18nStringsController,\n filteringPropertyToOption: (filteringProperty: InternalFilteringProperty) => T\n) {\n const defaultGroup: OptionGroup<T> = {\n label: i18nStrings.groupPropertiesText ?? '',\n options: [],\n };\n const customGroups: { [K in string]: OptionGroup<T> } = {};\n\n filteringProperties.forEach(filteringProperty => {\n const { propertyGroup } = filteringProperty;\n let optionsGroup = defaultGroup;\n if (propertyGroup) {\n if (!customGroups[propertyGroup]) {\n const label = customGroupsText.reduce<string>(\n (acc, customGroup) => (customGroup.group === propertyGroup ? customGroup.properties : acc),\n ''\n );\n customGroups[propertyGroup] = { options: [], label };\n }\n optionsGroup = customGroups[propertyGroup];\n }\n optionsGroup.options.push(filteringPropertyToOption(filteringProperty));\n });\n const defaultGroupArray = defaultGroup.options.length ? [defaultGroup] : [];\n const customGroupsArray = Object.keys(customGroups).map(groupKey => customGroups[groupKey]);\n return [...defaultGroupArray, ...customGroupsArray];\n}\n\nexport const getAutosuggestOptions = (\n parsedText: ParsedText,\n filteringProperties: readonly InternalFilteringProperty[],\n filteringOptions: readonly InternalFilteringOption[],\n customGroupsText: readonly GroupText[],\n i18nStrings: I18nStringsController\n) => {\n switch (parsedText.step) {\n case 'property': {\n const { propertyLabel, groupValuesLabel } = parsedText.property;\n const options = filteringOptions.filter(o => o.property === parsedText.property);\n return {\n filterText: parsedText.value,\n options: [\n {\n options: options.map(({ label, value, tags, filteringTags }) => ({\n value: propertyLabel + ' ' + parsedText.operator + ' ' + value,\n label: label,\n __labelPrefix: propertyLabel + ' ' + parsedText.operator,\n tags: tags,\n filteringTags: filteringTags,\n })),\n label: groupValuesLabel,\n },\n ],\n };\n }\n case 'operator': {\n return {\n filterText: parsedText.property.propertyLabel + ' ' + parsedText.operatorPrefix,\n options: [\n ...getPropertySuggestions(\n filteringProperties,\n customGroupsText,\n i18nStrings,\n filteringPropertyToAutosuggestOption\n ),\n {\n options: getAllowedOperators(parsedText.property).map(value => ({\n value: parsedText.property.propertyLabel + ' ' + value + ' ',\n label: parsedText.property.propertyLabel + ' ' + value,\n description: operatorToDescription(value, i18nStrings),\n keepOpenOnSelect: true,\n })),\n label: i18nStrings.operatorsText,\n },\n ],\n };\n }\n case 'free-text': {\n const needsValueSuggestions = !!parsedText.value;\n const needsPropertySuggestions = !(parsedText.step === 'free-text' && parsedText.operator === '!:');\n return {\n filterText: parsedText.value,\n options: [\n ...(needsPropertySuggestions\n ? getPropertySuggestions(\n filteringProperties,\n customGroupsText,\n i18nStrings,\n filteringPropertyToAutosuggestOption\n )\n : []),\n ...(needsValueSuggestions\n ? getAllValueSuggestions(filteringOptions, parsedText.operator, i18nStrings, customGroupsText)\n : []),\n ],\n };\n }\n }\n};\n"]}
|
|
1
|
+
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../src/property-filter/controller.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAGtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;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K,WAAW,CAAC,CAAC,CAAC;YACjB,MAAM,qBAAqB,GAAG,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC;YACjD,MAAM,wBAAwB,GAAG,CAAC,CAAC,UAAU,CAAC,IAAI,KAAK,WAAW,IAAI,UAAU,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC;YACpG,OAAO;gBACL,UAAU,EAAE,UAAU,CAAC,KAAK;gBAC5B,OAAO,EAAE;oBACP,GAAG,CAAC,wBAAwB;wBAC1B,CAAC,CAAC,sBAAsB,CACpB,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,oCAAoC,CACrC;wBACH,CAAC,CAAC,EAAE,CAAC;oBACP,GAAG,CAAC,qBAAqB;wBACvB,CAAC,CAAC,sBAAsB,CAAC,gBAAgB,EAAE,UAAU,CAAC,QAAQ,EAAE,WAAW,EAAE,gBAAgB,CAAC;wBAC9F,CAAC,CAAC,EAAE,CAAC;iBACR;aACF,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { AutosuggestProps } from '../autosuggest/interfaces';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { NonCancelableEventHandler } from '../types/events';\nimport { I18nStringsOperators, operatorToDescription } from './i18n-utils';\nimport { ComparisonOperator, GroupText, I18nStrings, JoinOperation, Query, Token, TokenGroup } from './interfaces';\nimport {\n InternalFilteringOption,\n InternalFilteringProperty,\n InternalFreeTextFiltering,\n InternalQuery,\n InternalToken,\n InternalTokenGroup,\n ParsedText,\n} from './internal-interfaces';\nimport {\n isInternalToken,\n matchFilteringProperty,\n matchOperator,\n matchOperatorPrefix,\n matchTokenValue,\n removeOperator,\n tokenGroupToTokens,\n trimStart,\n} from './utils';\n\ntype I18nStringsController = I18nStringsOperators &\n Pick<I18nStrings, 'operatorsText' | 'groupPropertiesText' | 'groupValuesText'>;\n\nexport const getQueryActions = ({\n query,\n onChange,\n filteringOptions,\n enableTokenGroups,\n}: {\n query: InternalQuery;\n onChange: NonCancelableEventHandler<Query>;\n filteringOptions: readonly InternalFilteringOption[];\n enableTokenGroups: boolean;\n}) => {\n const setQuery = (query: InternalQuery) => {\n function transformToken(token: InternalToken | InternalTokenGroup): Token | TokenGroup {\n if (isInternalToken(token)) {\n return matchTokenValue(token, filteringOptions);\n }\n return { ...token, tokens: token.tokens.map(transformToken) };\n }\n const tokens = query.tokens.map(transformToken);\n\n if (enableTokenGroups) {\n fireNonCancelableEvent(onChange, { tokens: [], operation: query.operation, tokenGroups: tokens });\n } else {\n fireNonCancelableEvent(onChange, { tokens: tokenGroupToTokens<Token>(tokens), operation: query.operation });\n }\n };\n\n const addToken = (token: InternalToken) => {\n setQuery({ ...query, tokens: [...query.tokens, token] });\n };\n\n const updateToken = (\n updateIndex: number,\n updatedToken: InternalToken | InternalTokenGroup,\n releasedTokens: InternalToken[]\n ) => {\n const nestedTokens = tokenGroupToTokens<InternalToken>([updatedToken]);\n const capturedTokenIndices = nestedTokens.map(token => token.standaloneIndex).filter(index => index !== undefined);\n const tokens = query.tokens\n .map((token, index) => (index === updateIndex ? updatedToken : token))\n .filter((_, index) => index === updateIndex || !capturedTokenIndices.includes(index));\n tokens.push(...releasedTokens);\n setQuery({ ...query, tokens });\n };\n\n const removeToken = (removeIndex: number) => {\n setQuery({ ...query, tokens: query.tokens.filter((_, index) => index !== removeIndex) });\n };\n\n const removeAllTokens = () => {\n setQuery({ ...query, tokens: [] });\n };\n\n const updateOperation = (operation: JoinOperation) => {\n setQuery({ ...query, operation });\n };\n\n return { addToken, updateToken, updateOperation, removeToken, removeAllTokens };\n};\n\nconst operatorOrder = ['=', '!=', ':', '!:', '^', '!^', '>=', '<=', '<', '>'] as const;\n\nexport const getAllowedOperators = (property: InternalFilteringProperty): ComparisonOperator[] => {\n const { operators = [], defaultOperator } = property;\n const operatorSet = new Set([defaultOperator, ...operators]);\n return operatorOrder.filter(op => operatorSet.has(op));\n};\n\nexport const getAllowedFreeTextOperators = (freeText: InternalFreeTextFiltering): ComparisonOperator[] => {\n const operatorSet = new Set(freeText.operators);\n return operatorOrder.filter(op => operatorSet.has(op));\n};\n\n/*\n * parses the value of the filtering input to figure out the current step of entering the token:\n * - \"property\": means that a filter on a particular column is being added, with operator already finalized\n * - \"operator\": means that a filter on a particular column is being added, with operator not yet finalized\n * - \"free-text\": means that a \"free text\" token is being added\n */\nexport const parseText = (\n filteringText: string,\n filteringProperties: readonly InternalFilteringProperty[],\n freeTextFiltering: InternalFreeTextFiltering\n): ParsedText => {\n const property = matchFilteringProperty(filteringProperties, filteringText);\n if (!property) {\n if (!freeTextFiltering.disabled) {\n // For free text filtering, we allow ! as a shortcut for !:\n let freeTextOperators = getAllowedFreeTextOperators(freeTextFiltering);\n freeTextOperators = freeTextOperators.indexOf('!:') >= 0 ? ['!', ...freeTextOperators] : freeTextOperators;\n const operator = matchOperator(freeTextOperators, filteringText);\n if (operator) {\n return {\n step: 'free-text',\n operator: operator === '!' ? '!:' : operator,\n value: removeOperator(filteringText, operator),\n };\n }\n }\n\n return {\n step: 'free-text',\n value: filteringText,\n };\n }\n\n const allowedOps = getAllowedOperators(property);\n\n const textWithoutProperty = filteringText.substring(property.propertyLabel.length);\n const operator = matchOperator(allowedOps, trimStart(textWithoutProperty));\n if (operator) {\n return {\n step: 'property',\n property,\n operator,\n value: removeOperator(textWithoutProperty, operator),\n };\n }\n\n const operatorPrefix = matchOperatorPrefix(allowedOps, trimStart(textWithoutProperty));\n if (operatorPrefix !== null) {\n return { step: 'operator', property, operatorPrefix };\n }\n\n return {\n step: 'free-text',\n value: filteringText,\n };\n};\n\ninterface OptionGroup<T> {\n label: string;\n options: T[];\n}\n\nconst getAllValueSuggestions = (\n filteringOptions: readonly InternalFilteringOption[],\n operator: ComparisonOperator | undefined = '=',\n i18nStrings: I18nStringsController,\n customGroupsText: readonly GroupText[]\n) => {\n const defaultGroup: OptionGroup<AutosuggestProps.Option> = {\n label: i18nStrings.groupValuesText ?? '',\n options: [],\n };\n const customGroups: { [K in string]: OptionGroup<AutosuggestProps.Option> } = {};\n filteringOptions.forEach(filteringOption => {\n const property = filteringOption.property;\n // given option refers to a non-existent filtering property\n if (!property) {\n return;\n }\n // this option's filtering property does not support current operator\n if (getAllowedOperators(property).indexOf(operator) === -1) {\n return;\n }\n if (property.propertyGroup && !customGroups[property.propertyGroup]) {\n const label = customGroupsText.reduce<string>(\n (acc, customGroup) => (customGroup.group === property.propertyGroup ? customGroup.values : acc),\n ''\n );\n customGroups[property.propertyGroup] = {\n label,\n options: [],\n };\n }\n const propertyGroup = property.propertyGroup ? customGroups[property.propertyGroup] : defaultGroup;\n propertyGroup.options.push({\n value: property.propertyLabel + ' ' + (operator || '=') + ' ' + filteringOption.value,\n label: filteringOption.label,\n __labelPrefix: property.propertyLabel + ' ' + (operator || '='),\n tags: filteringOption.tags,\n filteringTags: filteringOption.filteringTags,\n });\n });\n return [defaultGroup, ...Object.keys(customGroups).map(group => customGroups[group])];\n};\n\nconst filteringPropertyToAutosuggestOption = (filteringProperty: InternalFilteringProperty) => ({\n value: filteringProperty.propertyLabel,\n label: filteringProperty.propertyLabel,\n keepOpenOnSelect: true,\n});\n\nexport function getPropertySuggestions<T>(\n filteringProperties: readonly InternalFilteringProperty[],\n customGroupsText: readonly GroupText[],\n i18nStrings: I18nStringsController,\n filteringPropertyToOption: (filteringProperty: InternalFilteringProperty) => T\n) {\n const defaultGroup: OptionGroup<T> = {\n label: i18nStrings.groupPropertiesText ?? '',\n options: [],\n };\n const customGroups: { [K in string]: OptionGroup<T> } = {};\n\n filteringProperties.forEach(filteringProperty => {\n const { propertyGroup } = filteringProperty;\n let optionsGroup = defaultGroup;\n if (propertyGroup) {\n if (!customGroups[propertyGroup]) {\n const label = customGroupsText.reduce<string>(\n (acc, customGroup) => (customGroup.group === propertyGroup ? customGroup.properties : acc),\n ''\n );\n customGroups[propertyGroup] = { options: [], label };\n }\n optionsGroup = customGroups[propertyGroup];\n }\n optionsGroup.options.push(filteringPropertyToOption(filteringProperty));\n });\n const defaultGroupArray = defaultGroup.options.length ? [defaultGroup] : [];\n const customGroupsArray = Object.keys(customGroups).map(groupKey => customGroups[groupKey]);\n return [...defaultGroupArray, ...customGroupsArray];\n}\n\nexport const getAutosuggestOptions = (\n parsedText: ParsedText,\n filteringProperties: readonly InternalFilteringProperty[],\n filteringOptions: readonly InternalFilteringOption[],\n customGroupsText: readonly GroupText[],\n i18nStrings: I18nStringsController\n) => {\n switch (parsedText.step) {\n case 'property': {\n const { propertyLabel, groupValuesLabel } = parsedText.property;\n const options = filteringOptions.filter(o => o.property === parsedText.property);\n return {\n filterText: parsedText.value,\n options: [\n {\n options: options.map(({ label, value, tags, filteringTags }) => ({\n value: propertyLabel + ' ' + parsedText.operator + ' ' + value,\n label: label,\n __labelPrefix: propertyLabel + ' ' + parsedText.operator,\n tags: tags,\n filteringTags: filteringTags,\n })),\n label: groupValuesLabel,\n },\n ],\n };\n }\n case 'operator': {\n return {\n filterText: parsedText.property.propertyLabel + ' ' + parsedText.operatorPrefix,\n options: [\n ...getPropertySuggestions(\n filteringProperties,\n customGroupsText,\n i18nStrings,\n filteringPropertyToAutosuggestOption\n ),\n {\n options: getAllowedOperators(parsedText.property).map(value => ({\n value: parsedText.property.propertyLabel + ' ' + value + ' ',\n label: parsedText.property.propertyLabel + ' ' + value,\n description: operatorToDescription(value, i18nStrings),\n keepOpenOnSelect: true,\n })),\n label: i18nStrings.operatorsText,\n },\n ],\n };\n }\n case 'free-text': {\n const needsValueSuggestions = !!parsedText.value;\n const needsPropertySuggestions = !(parsedText.step === 'free-text' && parsedText.operator === '!:');\n return {\n filterText: parsedText.value,\n options: [\n ...(needsPropertySuggestions\n ? getPropertySuggestions(\n filteringProperties,\n customGroupsText,\n i18nStrings,\n filteringPropertyToAutosuggestOption\n )\n : []),\n ...(needsValueSuggestions\n ? getAllValueSuggestions(filteringOptions, parsedText.operator, i18nStrings, customGroupsText)\n : []),\n ],\n };\n }\n }\n};\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ComparisonOperator, I18nStrings
|
|
1
|
+
import { ComparisonOperator, I18nStrings } from './interfaces';
|
|
2
|
+
import { InternalToken, InternalTokenGroup } from './internal-interfaces';
|
|
2
3
|
export type I18nStringsOperators = Pick<I18nStrings, 'operatorLessText' | 'operatorLessOrEqualText' | 'operatorGreaterText' | 'operatorGreaterOrEqualText' | 'operatorContainsText' | 'operatorDoesNotContainText' | 'operatorEqualsText' | 'operatorDoesNotEqualText' | 'operatorStartsWithText' | 'operatorDoesNotStartWithText'>;
|
|
3
4
|
export type I18nStringsInternal = Omit<I18nStrings, 'formatToken' | 'removeTokenButtonAriaLabel' | 'groupEditAriaLabel' | 'tokenEditorTokenActionsAriaLabel' | 'tokenEditorTokenRemoveAriaLabel' | 'tokenEditorAddExistingTokenAriaLabel' | 'tokenEditorAddExistingTokenLabel'> & {
|
|
4
5
|
formatToken: (token: InternalToken) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n-utils.d.ts","sourceRoot":"","sources":["../../../src/property-filter/i18n-utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAkB,WAAW,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"i18n-utils.d.ts","sourceRoot":"","sources":["../../../src/property-filter/i18n-utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAkB,WAAW,EAAE,MAAM,cAAc,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAG1E,MAAM,MAAM,oBAAoB,GAAG,IAAI,CACrC,WAAW,EACT,kBAAkB,GAClB,yBAAyB,GACzB,qBAAqB,GACrB,4BAA4B,GAC5B,sBAAsB,GACtB,4BAA4B,GAC5B,oBAAoB,GACpB,0BAA0B,GAC1B,wBAAwB,GACxB,8B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,CAAC;QAC1C,KAAK,IAAI;YACP,OAAO,WAAW,CAAC,0BAA0B,CAAC;QAChD,KAAK,GAAG;YACN,OAAO,WAAW,CAAC,kBAAkB,CAAC;QACxC,KAAK,IAAI;YACP,OAAO,WAAW,CAAC,wBAAwB,CAAC;QAC9C,KAAK,GAAG;YACN,OAAO,WAAW,CAAC,sBAAsB,CAAC;QAC5C,KAAK,IAAI;YACP,OAAO,WAAW,CAAC,4BAA4B,CAAC;QAClD,iEAAiE;QACjE,sFAAsF;QACtF,0BAA0B;QAC1B;YACE,OAAO,EAAE,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAAS,qBAAqB,CAAC,QAA4B;IACzD,QAAQ,QAAQ,EAAE,CAAC;QACjB,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;IACpB,CAAC;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 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
|
+
{"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;AAGlD,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;IA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zD,QAAQ,QAAQ,EAAE,CAAC;QACjB,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;IACpB,CAAC;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 } from './interfaces';\nimport { InternalToken, InternalTokenGroup } from './internal-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,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { PropertyFilterOperation, PropertyFilterOperator, PropertyFilterOperatorExtended, PropertyFilterOperatorForm, PropertyFilterOperatorFormat, PropertyFilterOperatorFormProps, PropertyFilterOption, PropertyFilterProperty, PropertyFilterQuery, PropertyFilterToken, PropertyFilterTokenGroup
|
|
2
|
+
import { PropertyFilterOperation, PropertyFilterOperator, PropertyFilterOperatorExtended, PropertyFilterOperatorForm, PropertyFilterOperatorFormat, PropertyFilterOperatorFormProps, PropertyFilterOption, PropertyFilterProperty, PropertyFilterQuery, PropertyFilterToken, PropertyFilterTokenGroup } from '@cloudscape-design/collection-hooks';
|
|
3
3
|
import { AutosuggestProps } from '../autosuggest/interfaces';
|
|
4
4
|
import { ExpandToViewport } from '../dropdown/interfaces';
|
|
5
5
|
import { BaseComponentProps } from '../types/base-component';
|
|
@@ -332,53 +332,4 @@ export type LoadItemsDetail = PropertyFilterProps.LoadItemsDetail;
|
|
|
332
332
|
export type I18nStrings = PropertyFilterProps.I18nStrings;
|
|
333
333
|
export type GroupText = PropertyFilterProps.GroupText;
|
|
334
334
|
export type FormattedToken = PropertyFilterProps.FormattedToken;
|
|
335
|
-
export type Ref = PropertyFilterProps.Ref;
|
|
336
|
-
export interface InternalFilteringProperty<TokenValue = any> {
|
|
337
|
-
propertyKey: string;
|
|
338
|
-
propertyLabel: string;
|
|
339
|
-
groupValuesLabel: string;
|
|
340
|
-
propertyGroup?: string;
|
|
341
|
-
operators: readonly PropertyFilterOperator[];
|
|
342
|
-
defaultOperator: PropertyFilterOperator;
|
|
343
|
-
getTokenType: (operator?: PropertyFilterOperator) => PropertyFilterTokenType;
|
|
344
|
-
getValueFormatter: (operator?: PropertyFilterOperator) => null | ((value: any) => string);
|
|
345
|
-
getValueFormRenderer: (operator?: PropertyFilterOperator) => null | PropertyFilterOperatorForm<TokenValue>;
|
|
346
|
-
externalProperty: PropertyFilterProperty;
|
|
347
|
-
}
|
|
348
|
-
export interface InternalFilteringOption {
|
|
349
|
-
property: null | InternalFilteringProperty;
|
|
350
|
-
value: string;
|
|
351
|
-
label: string;
|
|
352
|
-
tags?: ReadonlyArray<string>;
|
|
353
|
-
filteringTags?: ReadonlyArray<string>;
|
|
354
|
-
}
|
|
355
|
-
export interface InternalFreeTextFiltering {
|
|
356
|
-
disabled: boolean;
|
|
357
|
-
operators: readonly (PropertyFilterOperator | PropertyFilterTextOperatorExtended)[];
|
|
358
|
-
defaultOperator: PropertyFilterOperator;
|
|
359
|
-
}
|
|
360
|
-
export interface InternalToken<TokenValue = any> {
|
|
361
|
-
standaloneIndex?: number;
|
|
362
|
-
property: null | InternalFilteringProperty<TokenValue>;
|
|
363
|
-
operator: PropertyFilterOperator;
|
|
364
|
-
value: TokenValue;
|
|
365
|
-
}
|
|
366
|
-
export interface InternalTokenGroup<TokenValue = any> {
|
|
367
|
-
operation: PropertyFilterOperation;
|
|
368
|
-
tokens: readonly (InternalToken<TokenValue> | InternalTokenGroup<TokenValue>)[];
|
|
369
|
-
}
|
|
370
|
-
export type InternalQuery = InternalTokenGroup;
|
|
371
|
-
export type ParsedText = {
|
|
372
|
-
step: 'property';
|
|
373
|
-
property: InternalFilteringProperty;
|
|
374
|
-
operator: ComparisonOperator;
|
|
375
|
-
value: string;
|
|
376
|
-
} | {
|
|
377
|
-
step: 'operator';
|
|
378
|
-
property: InternalFilteringProperty;
|
|
379
|
-
operatorPrefix: string;
|
|
380
|
-
} | {
|
|
381
|
-
step: 'free-text';
|
|
382
|
-
operator?: ComparisonOperator;
|
|
383
|
-
value: string;
|
|
384
|
-
};
|
|
335
|
+
export type Ref = PropertyFilterProps.Ref;
|
|
@@ -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,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,uBAAuB,EACvB,sBAAsB,EACtB,8BAA8B,EAC9B,0BAA0B,EAC1B,4BAA4B,EAC5B,+BAA+B,EAC/B,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EACzB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,MAAM,WAAW,mBAAoB,SAAQ,kBAAkB,EAAE,gBAAgB,EAAE,qBAAqB;IACtG;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,WAAW,CAAC,EAAE,mBAAmB,CAAC,WAAW,CAAC;IAC9C;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,OAAO,CAAC,EA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,GAAG,mBAAmB,CAAC,GAAG,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 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 { ExpandToViewport } from '../dropdown/interfaces';\nimport { BaseComponentProps } from '../types/base-component';\nimport { DropdownStatusProps } from '../types/dropdown-status';\nimport { NonCancelableEventHandler } from '../types/events';\nimport { FormFieldControlProps } from '../types/form-field';\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 * When the `countText` or `query` changes, it will be announced to assistive technologies.\n */\n countText?: string;\n\n /**\n * Set to `true` while the related collection is loading (e.g. during an async filtering action).\n * If set to `true`, the live announcement of countText by assistive technologies will be paused until it changes back to `false`.\n */\n loading?: boolean;\n\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, or use `readOnlyOperations`.\n *\n * This property cannot be set when `enableTokenGroups=true`.\n */\n hideOperations?: boolean;\n /**\n * If readOnlyOperations it set, the indicator of the operation (that is, `and` or `or`) is shown, but the\n * operation cannot be changed. This is also supported for nested tokens when `enableTokenGroups=true`.\n */\n readOnlyOperations?: 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 * * `tags` [string[]]: Optional list of tags giving further guidance about the option.\n * * `filteringTags` [string[]]: Optional list of additional tags used for automatic filtering.\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?: PropertyFilterProps.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\n// TODO: replace with PropertyFilterTextOperatorExtended from collection-hooks once it is released\nexport interface PropertyFilterTextOperatorExtended {\n operator: PropertyFilterOperator;\n match?: (item: unknown, text: string) => boolean;\n}\n// TODO: replace with PropertyFilterFreeTextFiltering from collection-hooks once it is released\nexport interface PropertyFilterFreeTextFiltering {\n operators?: readonly (PropertyFilterOperator | PropertyFilterTextOperatorExtended)[];\n defaultOperator?: PropertyFilterOperator;\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 export type StatusType = DropdownStatusProps.StatusType;\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 ExtendedOperatorForm<TokenValue> = PropertyFilterOperatorForm<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 FormattedToken = PropertyFilterProps.FormattedToken;\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) => PropertyFilterTokenType;\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 tags?: ReadonlyArray<string>;\n filteringTags?: ReadonlyArray<string>;\n}\n\nexport interface InternalFreeTextFiltering {\n disabled: boolean;\n operators: readonly (PropertyFilterOperator | PropertyFilterTextOperatorExtended)[];\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 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 { ExpandToViewport } from '../dropdown/interfaces';\nimport { BaseComponentProps } from '../types/base-component';\nimport { DropdownStatusProps } from '../types/dropdown-status';\nimport { NonCancelableEventHandler } from '../types/events';\nimport { FormFieldControlProps } from '../types/form-field';\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 * When the `countText` or `query` changes, it will be announced to assistive technologies.\n */\n countText?: string;\n\n /**\n * Set to `true` while the related collection is loading (e.g. during an async filtering action).\n * If set to `true`, the live announcement of countText by assistive technologies will be paused until it changes back to `false`.\n */\n loading?: boolean;\n\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, or use `readOnlyOperations`.\n *\n * This property cannot be set when `enableTokenGroups=true`.\n */\n hideOperations?: boolean;\n /**\n * If readOnlyOperations it set, the indicator of the operation (that is, `and` or `or`) is shown, but the\n * operation cannot be changed. This is also supported for nested tokens when `enableTokenGroups=true`.\n */\n readOnlyOperations?: 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 * * `tags` [string[]]: Optional list of tags giving further guidance about the option.\n * * `filteringTags` [string[]]: Optional list of additional tags used for automatic filtering.\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?: PropertyFilterProps.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\n// TODO: replace with PropertyFilterTextOperatorExtended from collection-hooks once it is released\nexport interface PropertyFilterTextOperatorExtended {\n operator: PropertyFilterOperator;\n match?: (item: unknown, text: string) => boolean;\n}\n// TODO: replace with PropertyFilterFreeTextFiltering from collection-hooks once it is released\nexport interface PropertyFilterFreeTextFiltering {\n operators?: readonly (PropertyFilterOperator | PropertyFilterTextOperatorExtended)[];\n defaultOperator?: PropertyFilterOperator;\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 export type StatusType = DropdownStatusProps.StatusType;\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 ExtendedOperatorForm<TokenValue> = PropertyFilterOperatorForm<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 FormattedToken = PropertyFilterProps.FormattedToken;\nexport type Ref = PropertyFilterProps.Ref;\n"]}
|