@cloudscape-design/components 3.0.32 → 3.0.33
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/breadcrumb-group/item/item.d.ts.map +1 -1
- package/breadcrumb-group/item/item.js +1 -1
- package/breadcrumb-group/item/item.js.map +1 -1
- package/internal/environment.js +1 -1
- package/package.json +1 -1
- package/property-filter/controller.d.ts +2 -2
- package/property-filter/controller.d.ts.map +1 -1
- package/property-filter/controller.js +6 -1
- package/property-filter/controller.js.map +1 -1
- package/property-filter/interfaces.d.ts +5 -1
- package/property-filter/interfaces.d.ts.map +1 -1
- package/property-filter/interfaces.js.map +1 -1
- package/property-filter/use-load-items.d.ts +1 -1
- package/tabs/tab-header-bar.d.ts.map +1 -1
- package/tabs/tab-header-bar.js +2 -2
- package/tabs/tab-header-bar.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../../../../src/breadcrumb-group/item/item.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAQ1E,wBAAgB,cAAc,CAAC,CAAC,SAAS,oBAAoB,CAAC,IAAI,EAAE,EAClE,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,MAAc,EACd,YAAoB,GACrB,EAAE,mBAAmB,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../../../../src/breadcrumb-group/item/item.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAQ1E,wBAAgB,cAAc,CAAC,CAAC,SAAS,oBAAoB,CAAC,IAAI,EAAE,EAClE,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,MAAc,EACd,YAAoB,GACrB,EAAE,mBAAmB,CAAC,CAAC,CAAC,eA6BxB"}
|
|
@@ -20,7 +20,7 @@ export function BreadcrumbItem(_a) {
|
|
|
20
20
|
fireCancelableEvent(onClick, getEventDetail(item), event);
|
|
21
21
|
};
|
|
22
22
|
return (React.createElement("div", { className: clsx(styles.breadcrumb, isLast && styles.last) },
|
|
23
|
-
React.createElement("a", __assign({}, focusVisible, { href: item.href || '#', className: clsx(styles.anchor, (_b = {}, _b[styles.compressed] = isCompressed, _b)), "aria-current": isLast ? 'page' : undefined, "aria-disabled": isLast && 'true', onClick: isLast ? preventDefault : onClickHandler }),
|
|
23
|
+
React.createElement("a", __assign({}, focusVisible, { href: isLast ? undefined : item.href || '#', className: clsx(styles.anchor, (_b = {}, _b[styles.compressed] = isCompressed, _b)), "aria-current": isLast ? 'page' : undefined, "aria-disabled": isLast && 'true', onClick: isLast ? preventDefault : onClickHandler, tabIndex: isLast ? 0 : undefined }),
|
|
24
24
|
React.createElement("span", { className: styles.text }, item.text)),
|
|
25
25
|
!isLast ? (React.createElement("span", { className: styles.icon },
|
|
26
26
|
React.createElement(InternalIcon, { name: "angle-right" }))) : null));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item.js","sourceRoot":"","sources":["../../../../src/breadcrumb-group/item/item.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,YAAY,MAAM,qBAAqB,CAAC;AAC/C,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,eAAe,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,UAAU,cAAc,CAAsC,EAM3C;;QALvB,IAAI,UAAA,EACJ,OAAO,aAAA,EACP,QAAQ,cAAA,EACR,cAAc,EAAd,MAAM,mBAAG,KAAK,KAAA,EACd,oBAA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","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport { BreadcrumbGroupProps, BreadcrumbItemProps } from '../interfaces';\nimport InternalIcon from '../../icon/internal';\nimport styles from './styles.css.js';\nimport clsx from 'clsx';\nimport useFocusVisible from '../../internal/hooks/focus-visible';\nimport { fireCancelableEvent, isPlainLeftClick } from '../../internal/events';\nimport { getEventDetail } from '../internal';\n\nexport function BreadcrumbItem<T extends BreadcrumbGroupProps.Item>({\n item,\n onClick,\n onFollow,\n isLast = false,\n isCompressed = false,\n}: BreadcrumbItemProps<T>) {\n const focusVisible = useFocusVisible();\n const preventDefault = (event: React.MouseEvent) => event.preventDefault();\n const onClickHandler = (event: React.MouseEvent) => {\n if (isPlainLeftClick(event)) {\n fireCancelableEvent(onFollow, getEventDetail(item), event);\n }\n fireCancelableEvent(onClick, getEventDetail(item), event);\n };\n return (\n <div className={clsx(styles.breadcrumb, isLast && styles.last)}>\n <a\n {...focusVisible}\n href={isLast ? undefined : item.href || '#'}\n className={clsx(styles.anchor, { [styles.compressed]: isCompressed })}\n aria-current={isLast ? 'page' : undefined} // Active breadcrumb item is implemented according to WAI-ARIA 1.1\n aria-disabled={isLast && 'true'}\n onClick={isLast ? preventDefault : onClickHandler}\n tabIndex={isLast ? 0 : undefined} // tabIndex is added to the last crumb to keep it in the index without an href\n >\n <span className={styles.text}>{item.text}</span>\n </a>\n {!isLast ? (\n <span className={styles.icon}>\n <InternalIcon name=\"angle-right\" />\n </span>\n ) : null}\n </div>\n );\n}\n"]}
|
package/internal/environment.js
CHANGED
package/package.json
CHANGED
|
@@ -23,7 +23,7 @@ export declare type ParsedText = {
|
|
|
23
23
|
value: string;
|
|
24
24
|
};
|
|
25
25
|
export declare const getAllowedOperators: (property: PropertyFilterProps.FilteringProperty) => PropertyFilterProps.ComparisonOperator[];
|
|
26
|
-
export declare const parseText: (filteringText: string, filteringProperties: readonly
|
|
26
|
+
export declare const parseText: (filteringText: string, filteringProperties: readonly PropertyFilterProps.FilteringProperty[] | undefined, disableFreeTextFiltering: boolean) => ParsedText;
|
|
27
27
|
export declare const getPropertyOptions: (filteringProperty: PropertyFilterProps.FilteringProperty, filteringOptions: PropertyFilterProps['filteringOptions']) => import("@cloudscape-design/collection-hooks").PropertyFilterOption[] | undefined;
|
|
28
28
|
interface OptionGroup<T> {
|
|
29
29
|
label: string;
|
|
@@ -33,7 +33,7 @@ interface ExtendedAutosuggestOption extends AutosuggestProps.Option {
|
|
|
33
33
|
tokenValue: string;
|
|
34
34
|
}
|
|
35
35
|
export declare const getAllValueSuggestions: (filteringOptions: PropertyFilterProps['filteringOptions'], filteringProperties: PropertyFilterProps['filteringProperties'], operator: PropertyFilterProps.ComparisonOperator | undefined, i18nStrings: Pick<PropertyFilterProps.I18nStrings, 'groupValuesText'>, customGroupsText: PropertyFilterProps['customGroupsText']) => OptionGroup<ExtendedAutosuggestOption>[];
|
|
36
|
-
export declare const getPropertyByKey: (filteringProperties: PropertyFilterProps['filteringProperties'], key: string) =>
|
|
36
|
+
export declare const getPropertyByKey: (filteringProperties: PropertyFilterProps['filteringProperties'], key: string) => PropertyFilterProps.FilteringProperty | undefined;
|
|
37
37
|
export declare function getPropertySuggestions<T>(filteringProperties: PropertyFilterProps['filteringProperties'], customGroupsText: PropertyFilterProps['customGroupsText'], i18nStrings: Pick<PropertyFilterProps['i18nStrings'], 'groupPropertiesText'>, filteringPropertyToOption: (filteringProperty: PropertyFilterProps.FilteringProperty) => T): OptionGroup<T>[];
|
|
38
38
|
export declare type OperatorStrings = 'operatorLessText' | 'operatorLessOrEqualText' | 'operatorGreaterText' | 'operatorGreaterOrEqualText' | 'operatorContainsText' | 'operatorDoesNotContainText' | 'operatorEqualsText' | 'operatorDoesNotEqualText';
|
|
39
39
|
export declare const getAutosuggestOptions: (parsedText: ParsedText, filteringOptions: PropertyFilterProps['filteringOptions'], filteringProperties: PropertyFilterProps['filteringProperties'], customGroupsText: PropertyFilterProps['customGroupsText'], i18nStrings: Pick<PropertyFilterProps['i18nStrings'], 'groupPropertiesText' | 'groupValuesText' | 'operatorsText' | OperatorStrings>) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/property-filter/controller.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGjD,eAAO,MAAM,eAAe,UACnB,mBAAmB,CAAC,OAAO,CAAC,YACzB,mBAAmB,CAAC,UAAU,CAAC,YAC/B,MAAM,SAAS,CAAC,WAAW,GAAG,CAAC,gBAC3B,MAAM,gBAAgB,CAAC,OAAO,CAAC;sBAKpB,MAAM,YAAY,oBAAoB,KAAK;yBAOxC,MAAM;;yBAWN,oBAAoB,KAAK;iCAKjB,oBAAoB,aAAa;CAUtE,CAAC;AAEF,oBAAY,UAAU,GAClB;IACE,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,mBAAmB,CAAC,iBAAiB,CAAC;IAChD,QAAQ,EAAE,mBAAmB,CAAC,kBAAkB,CAAC;IACjD,KAAK,EAAE,MAAM,CAAC;CACf,GACD;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,mBAAmB,CAAC,iBAAiB,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,GAC7F;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,EAAE,mBAAmB,CAAC,kBAAkB,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5F,eAAO,MAAM,mBAAmB,aACpB,oBAAoB,iBAAiB,KAC9C,oBAAoB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/property-filter/controller.ts"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,eAAe,CAAC,WAavE,CAAC"}
|
|
@@ -47,7 +47,12 @@ export var getAllowedOperators = function (property) {
|
|
|
47
47
|
var operators = property.operators, defaultOperator = property.defaultOperator;
|
|
48
48
|
var operatorOrder = ['=', '!=', ':', '!:', '>=', '<=', '<', '>'];
|
|
49
49
|
var operatorSet = (_a = {}, _a[defaultOperator !== null && defaultOperator !== void 0 ? defaultOperator : '='] = true, _a);
|
|
50
|
-
|
|
50
|
+
// TODO: remove unknown type annotation once extended operators are supported.
|
|
51
|
+
operators === null || operators === void 0 ? void 0 : operators.forEach(function (op) {
|
|
52
|
+
if (typeof op === 'string') {
|
|
53
|
+
operatorSet[op] = true;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
51
56
|
return operatorOrder.filter(function (op) { return operatorSet[op]; });
|
|
52
57
|
};
|
|
53
58
|
/*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../src/property-filter/controller.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAG5D,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,mBAAmB,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEhH,MAAM,CAAC,IAAM,eAAe,GAAG,UAC7B,KAAmC,EACnC,QAAyC,EACzC,QAAyC,EACzC,YAA6C;IAErC,IAAA,MAAM,GAAgB,KAAK,OAArB,EAAE,SAAS,GAAK,KAAK,UAAV,CAAW;IACpC,IAAM,YAAY,GAAG,UAAC,MAA4C,EAAE,SAA4C;QAC9G,OAAA,sBAAsB,CAAC,QAAQ,EAAE,EAAE,MAAM,QAAA,EAAE,SAAS,WAAA,EAAE,CAAC;IAAvD,CAAuD,CAAC;IAC1D,IAAM,QAAQ,GAAG,UAAC,KAAa,EAAE,QAAmC;QAClE,IAAM,SAAS,qBAAO,MAAM,OAAC,CAAC;QAC9B,IAAI,SAAS,IAAI,KAAK,GAA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pG,OAAO;gBACL,UAAU,EAAE,UAAU,CAAC,KAAK;gBAC5B,OAAO,kCACF,CAAC,wBAAwB;oBAC1B,CAAC,CAAC,sBAAsB,CACpB,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,oCAAoC,CACrC;oBACH,CAAC,CAAC,EAAE,CAAC,SACJ,CAAC,qBAAqB;oBACvB,CAAC,CAAC,sBAAsB,CACpB,gBAAgB,EAChB,mBAAmB,EACnB,UAAU,CAAC,QAAQ,EACnB,WAAW,EACX,gBAAgB,CACjB;oBACH,CAAC,CAAC,EAAE,CAAC,OACR;aACF,CAAC;SACH;KACF;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,qBAAqB,GAAG,UACnC,QAAgD,EAChD,WAAsE;;IAEtE,IAAM,OAAO;QACX,GAAC,GAAG,IAAG,WAAW,CAAC,gBAAgB;QACnC,GAAC,IAAI,IAAG,WAAW,CAAC,uBAAuB;QAC3C,GAAC,GAAG,IAAG,WAAW,CAAC,mBAAmB;QACtC,GAAC,IAAI,IAAG,WAAW,CAAC,0BAA0B;QAC9C,GAAC,GAAG,IAAG,WAAW,CAAC,oBAAoB;QACvC,GAAC,IAAI,IAAG,WAAW,CAAC,0BAA0B;QAC9C,GAAC,GAAG,IAAG,WAAW,CAAC,kBAAkB;QACrC,GAAC,IAAI,IAAG,WAAW,CAAC,wBAAwB;WAC7C,CAAC;IACF,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC3B,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { PropertyFilterProps } from './interfaces';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { AutosuggestProps } from '../autosuggest/interfaces';\nimport { InputProps } from '../input/interfaces';\nimport { matchFilteringProperty, matchOperator, matchOperatorPrefix, trimFirstSpace, trimStart } from './utils';\n\nexport const getQueryActions = (\n query: PropertyFilterProps['query'],\n onChange: PropertyFilterProps['onChange'],\n inputRef: React.RefObject<InputProps.Ref>,\n preventFocus: React.MutableRefObject<boolean>\n) => {\n const { tokens, operation } = query;\n const fireOnChange = (tokens: readonly PropertyFilterProps.Token[], operation: PropertyFilterProps.JoinOperation) =>\n fireNonCancelableEvent(onChange, { tokens, operation });\n const setToken = (index: number, newToken: PropertyFilterProps.Token) => {\n const newTokens = [...tokens];\n if (newTokens && index < newTokens.length) {\n newTokens[index] = newToken;\n }\n fireOnChange(newTokens, operation);\n };\n const removeToken = (index: number) => {\n const newTokens = tokens.filter((_, i) => i !== index);\n fireOnChange(newTokens, operation);\n preventFocus.current = true;\n inputRef.current?.focus();\n };\n const removeAllTokens = () => {\n fireOnChange([], operation);\n preventFocus.current = true;\n inputRef.current?.focus();\n };\n const addToken = (newToken: PropertyFilterProps.Token) => {\n const newTokens = [...tokens];\n newTokens.push(newToken);\n fireOnChange(newTokens, operation);\n };\n const setOperation = (newOperation: PropertyFilterProps.JoinOperation) => {\n fireOnChange(tokens, newOperation);\n };\n return {\n setToken,\n removeToken,\n removeAllTokens,\n addToken,\n setOperation,\n };\n};\n\nexport type ParsedText =\n | {\n step: 'property';\n property: PropertyFilterProps.FilteringProperty;\n operator: PropertyFilterProps.ComparisonOperator;\n value: string;\n }\n | { step: 'operator'; property: PropertyFilterProps.FilteringProperty; operatorPrefix: string }\n | { step: 'free-text'; operator?: PropertyFilterProps.ComparisonOperator; value: string };\n\nexport const getAllowedOperators = (\n property: PropertyFilterProps.FilteringProperty\n): PropertyFilterProps.ComparisonOperator[] => {\n const { operators, defaultOperator } = property;\n const operatorOrder = ['=', '!=', ':', '!:', '>=', '<=', '<', '>'] as const;\n const operatorSet: { [key: string]: true } = { [defaultOperator ?? '=']: true };\n operators?.forEach(op => (operatorSet[op] = true));\n return operatorOrder.filter(op => operatorSet[op]);\n};\n\n/*\n * parses the value of the filtering input to figure out the current step of entering the token:\n * - \"property\": means that a filter on a particular column is being added, with operator already finalized\n * - \"operator\": means that a filter on a particular column is being added, with operator not yet finalized\n * - \"free-text\": means that a \"free text\" token is being added\n */\nexport const parseText = (\n filteringText: string,\n filteringProperties: PropertyFilterProps['filteringProperties'] = [],\n disableFreeTextFiltering: boolean\n): ParsedText => {\n const negatedGlobalQuery = /^(!:|!)(.*)/.exec(filteringText);\n if (!disableFreeTextFiltering && negatedGlobalQuery) {\n return {\n step: 'free-text',\n operator: '!:',\n value: negatedGlobalQuery[2],\n };\n }\n\n const property = matchFilteringProperty(filteringProperties, filteringText);\n if (!property) {\n return {\n step: 'free-text',\n value: filteringText,\n };\n }\n\n const allowedOps = getAllowedOperators(property);\n const textWithoutProperty = filteringText.substring(property.propertyLabel.length);\n const operator = matchOperator(allowedOps, trimStart(textWithoutProperty));\n if (operator) {\n const operatorLastIndex = textWithoutProperty.indexOf(operator) + operator.length;\n const textWithoutPropertyAndOperator = textWithoutProperty.slice(operatorLastIndex);\n return {\n step: 'property',\n property,\n operator,\n // We need to remove the first leading space in case the user presses space\n // after the operator, for example: Owner: admin, will result in value of ` admin`\n // and we need to remove the first space, if the user added any more spaces only the\n // first one will be removed.\n value: trimFirstSpace(textWithoutPropertyAndOperator),\n };\n }\n\n const operatorPrefix = matchOperatorPrefix(allowedOps, trimStart(textWithoutProperty));\n if (operatorPrefix !== null) {\n return { step: 'operator', property, operatorPrefix };\n }\n\n return {\n step: 'free-text',\n value: filteringText,\n };\n};\n\nexport const getPropertyOptions = (\n filteringProperty: PropertyFilterProps.FilteringProperty,\n filteringOptions: PropertyFilterProps['filteringOptions']\n) => {\n return filteringOptions?.filter(option => option.propertyKey === filteringProperty.key);\n};\n\ninterface OptionGroup<T> {\n label: string;\n options: T[];\n}\n\ninterface ExtendedAutosuggestOption extends AutosuggestProps.Option {\n tokenValue: string;\n}\n\nexport const getAllValueSuggestions = (\n filteringOptions: PropertyFilterProps['filteringOptions'],\n filteringProperties: PropertyFilterProps['filteringProperties'],\n operator: PropertyFilterProps.ComparisonOperator | undefined = '=',\n i18nStrings: Pick<PropertyFilterProps.I18nStrings, 'groupValuesText'>,\n customGroupsText: PropertyFilterProps['customGroupsText']\n) => {\n const defaultGroup: OptionGroup<ExtendedAutosuggestOption> = {\n label: i18nStrings.groupValuesText,\n options: [],\n };\n const customGroups: { [K in string]: OptionGroup<ExtendedAutosuggestOption> } = {};\n filteringOptions?.forEach(filteringOption => {\n const property = getPropertyByKey(filteringProperties, filteringOption.propertyKey);\n // given option refers to a non-existent filtering property\n if (!property) {\n return;\n }\n // this option's filtering property does not support current operator\n if (getAllowedOperators(property).indexOf(operator) === -1) {\n return;\n }\n if (property.group && !customGroups[property.group]) {\n const label =\n customGroupsText?.reduce<string>(\n (acc, customGroup) => (customGroup.group === property.group ? customGroup.values : acc),\n ''\n ) || '';\n customGroups[property.group] = {\n label,\n options: [],\n };\n }\n const propertyGroup = property.group ? customGroups[property.group] : defaultGroup;\n propertyGroup.options.push({\n tokenValue: property.propertyLabel + (operator || '=') + filteringOption.value,\n label: filteringOption.value,\n __labelPrefix: property.propertyLabel + ' ' + (operator || '='),\n });\n });\n return [defaultGroup, ...Object.keys(customGroups).map(group => customGroups[group])];\n};\n\nexport const getPropertyByKey = (filteringProperties: PropertyFilterProps['filteringProperties'], key: string) => {\n const propertyMap = filteringProperties.reduce<{ [K: string]: PropertyFilterProps.FilteringProperty }>(\n (acc, property) => {\n acc[property.key] = property;\n return acc;\n },\n {}\n );\n return propertyMap[key] as PropertyFilterProps.FilteringProperty | undefined;\n};\n\nconst filteringPropertyToAutosuggestOption = (filteringProperty: PropertyFilterProps.FilteringProperty) => ({\n value: filteringProperty.propertyLabel,\n keepOpenOnSelect: true,\n});\n\nexport function getPropertySuggestions<T>(\n filteringProperties: PropertyFilterProps['filteringProperties'],\n customGroupsText: PropertyFilterProps['customGroupsText'],\n i18nStrings: Pick<PropertyFilterProps['i18nStrings'], 'groupPropertiesText'>,\n filteringPropertyToOption: (filteringProperty: PropertyFilterProps.FilteringProperty) => T\n) {\n const defaultGroup: OptionGroup<T> = {\n label: i18nStrings.groupPropertiesText,\n options: [],\n };\n const customGroups: { [K in string]: OptionGroup<T> } = {};\n\n filteringProperties.forEach(filteringProperty => {\n const { group } = filteringProperty;\n let optionsGroup = defaultGroup;\n if (group) {\n if (!customGroups[group]) {\n const label =\n customGroupsText?.reduce<string>(\n (acc, customGroup) => (customGroup.group === group ? customGroup.properties : acc),\n ''\n ) || '';\n customGroups[group] = { options: [], label };\n }\n optionsGroup = customGroups[group];\n }\n optionsGroup.options.push(filteringPropertyToOption(filteringProperty));\n });\n const defaultGroupArray = defaultGroup.options.length ? [defaultGroup] : [];\n const customGroupsArray = Object.keys(customGroups).map(groupKey => customGroups[groupKey]);\n return [...defaultGroupArray, ...customGroupsArray];\n}\n\nexport type OperatorStrings =\n | 'operatorLessText'\n | 'operatorLessOrEqualText'\n | 'operatorGreaterText'\n | 'operatorGreaterOrEqualText'\n | 'operatorContainsText'\n | 'operatorDoesNotContainText'\n | 'operatorEqualsText'\n | 'operatorDoesNotEqualText';\nexport const getAutosuggestOptions = (\n parsedText: ParsedText,\n filteringOptions: PropertyFilterProps['filteringOptions'],\n filteringProperties: PropertyFilterProps['filteringProperties'],\n customGroupsText: PropertyFilterProps['customGroupsText'],\n i18nStrings: Pick<\n PropertyFilterProps['i18nStrings'],\n 'groupPropertiesText' | 'groupValuesText' | 'operatorsText' | OperatorStrings\n >\n) => {\n switch (parsedText.step) {\n case 'property': {\n const { propertyLabel, groupValuesLabel } = parsedText.property;\n const options = getPropertyOptions(parsedText.property, filteringOptions);\n return {\n filterText: parsedText.value,\n options: [\n {\n options: (options || []).map(({ value }) => ({\n tokenValue: propertyLabel + parsedText.operator + value,\n label: value,\n __labelPrefix: propertyLabel + ' ' + parsedText.operator,\n })),\n label: groupValuesLabel,\n },\n ],\n };\n }\n case 'operator': {\n return {\n filterText: parsedText.property.propertyLabel + ' ' + parsedText.operatorPrefix,\n options: [\n ...getPropertySuggestions(\n filteringProperties,\n customGroupsText,\n i18nStrings,\n filteringPropertyToAutosuggestOption\n ),\n {\n options: getAllowedOperators(parsedText.property).map(value => ({\n value: parsedText.property.propertyLabel + ' ' + value + ' ',\n label: parsedText.property.propertyLabel + ' ' + value,\n description: operatorToDescription(value, i18nStrings),\n keepOpenOnSelect: true,\n })),\n label: i18nStrings.operatorsText,\n },\n ],\n };\n }\n case 'free-text': {\n const needsValueSuggestions = !!parsedText.value;\n const needsPropertySuggestions = !(parsedText.step === 'free-text' && parsedText.operator === '!:');\n return {\n filterText: parsedText.value,\n options: [\n ...(needsPropertySuggestions\n ? getPropertySuggestions(\n filteringProperties,\n customGroupsText,\n i18nStrings,\n filteringPropertyToAutosuggestOption\n )\n : []),\n ...(needsValueSuggestions\n ? getAllValueSuggestions(\n filteringOptions,\n filteringProperties,\n parsedText.operator,\n i18nStrings,\n customGroupsText\n )\n : []),\n ],\n };\n }\n }\n};\n\nexport const operatorToDescription = (\n operator: PropertyFilterProps.ComparisonOperator,\n i18nStrings: Pick<PropertyFilterProps['i18nStrings'], OperatorStrings>\n) => {\n const mapping: { [K in PropertyFilterProps.ComparisonOperator]: string } = {\n ['<']: i18nStrings.operatorLessText,\n ['<=']: i18nStrings.operatorLessOrEqualText,\n ['>']: i18nStrings.operatorGreaterText,\n ['>=']: i18nStrings.operatorGreaterOrEqualText,\n [':']: i18nStrings.operatorContainsText,\n ['!:']: i18nStrings.operatorDoesNotContainText,\n ['=']: i18nStrings.operatorEqualsText,\n ['!=']: i18nStrings.operatorDoesNotEqualText,\n };\n return mapping[operator];\n};\n"]}
|
|
1
|
+
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../src/property-filter/controller.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAG5D,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,mBAAmB,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEhH,MAAM,CAAC,IAAM,eAAe,GAAG,UAC7B,KAAmC,EACnC,QAAyC,EACzC,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BAAkB;QACrC,GAAC,IAAI,IAAG,WAAW,CAAC,wBAAwB;WAC7C,CAAC;IACF,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC3B,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { PropertyFilterProps } from './interfaces';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { AutosuggestProps } from '../autosuggest/interfaces';\nimport { InputProps } from '../input/interfaces';\nimport { matchFilteringProperty, matchOperator, matchOperatorPrefix, trimFirstSpace, trimStart } from './utils';\n\nexport const getQueryActions = (\n query: PropertyFilterProps['query'],\n onChange: PropertyFilterProps['onChange'],\n inputRef: React.RefObject<InputProps.Ref>,\n preventFocus: React.MutableRefObject<boolean>\n) => {\n const { tokens, operation } = query;\n const fireOnChange = (tokens: readonly PropertyFilterProps.Token[], operation: PropertyFilterProps.JoinOperation) =>\n fireNonCancelableEvent(onChange, { tokens, operation });\n const setToken = (index: number, newToken: PropertyFilterProps.Token) => {\n const newTokens = [...tokens];\n if (newTokens && index < newTokens.length) {\n newTokens[index] = newToken;\n }\n fireOnChange(newTokens, operation);\n };\n const removeToken = (index: number) => {\n const newTokens = tokens.filter((_, i) => i !== index);\n fireOnChange(newTokens, operation);\n preventFocus.current = true;\n inputRef.current?.focus();\n };\n const removeAllTokens = () => {\n fireOnChange([], operation);\n preventFocus.current = true;\n inputRef.current?.focus();\n };\n const addToken = (newToken: PropertyFilterProps.Token) => {\n const newTokens = [...tokens];\n newTokens.push(newToken);\n fireOnChange(newTokens, operation);\n };\n const setOperation = (newOperation: PropertyFilterProps.JoinOperation) => {\n fireOnChange(tokens, newOperation);\n };\n return {\n setToken,\n removeToken,\n removeAllTokens,\n addToken,\n setOperation,\n };\n};\n\nexport type ParsedText =\n | {\n step: 'property';\n property: PropertyFilterProps.FilteringProperty;\n operator: PropertyFilterProps.ComparisonOperator;\n value: string;\n }\n | { step: 'operator'; property: PropertyFilterProps.FilteringProperty; operatorPrefix: string }\n | { step: 'free-text'; operator?: PropertyFilterProps.ComparisonOperator; value: string };\n\nexport const getAllowedOperators = (\n property: PropertyFilterProps.FilteringProperty\n): PropertyFilterProps.ComparisonOperator[] => {\n const { operators, defaultOperator } = property;\n const operatorOrder = ['=', '!=', ':', '!:', '>=', '<=', '<', '>'] as const;\n const operatorSet: { [key: string]: true } = { [defaultOperator ?? '=']: true };\n // TODO: remove unknown type annotation once extended operators are supported.\n operators?.forEach((op: unknown) => {\n if (typeof op === 'string') {\n operatorSet[op] = true;\n }\n });\n return operatorOrder.filter(op => operatorSet[op]);\n};\n\n/*\n * parses the value of the filtering input to figure out the current step of entering the token:\n * - \"property\": means that a filter on a particular column is being added, with operator already finalized\n * - \"operator\": means that a filter on a particular column is being added, with operator not yet finalized\n * - \"free-text\": means that a \"free text\" token is being added\n */\nexport const parseText = (\n filteringText: string,\n filteringProperties: PropertyFilterProps['filteringProperties'] = [],\n disableFreeTextFiltering: boolean\n): ParsedText => {\n const negatedGlobalQuery = /^(!:|!)(.*)/.exec(filteringText);\n if (!disableFreeTextFiltering && negatedGlobalQuery) {\n return {\n step: 'free-text',\n operator: '!:',\n value: negatedGlobalQuery[2],\n };\n }\n\n const property = matchFilteringProperty(filteringProperties, filteringText);\n if (!property) {\n return {\n step: 'free-text',\n value: filteringText,\n };\n }\n\n const allowedOps = getAllowedOperators(property);\n const textWithoutProperty = filteringText.substring(property.propertyLabel.length);\n const operator = matchOperator(allowedOps, trimStart(textWithoutProperty));\n if (operator) {\n const operatorLastIndex = textWithoutProperty.indexOf(operator) + operator.length;\n const textWithoutPropertyAndOperator = textWithoutProperty.slice(operatorLastIndex);\n return {\n step: 'property',\n property,\n operator,\n // We need to remove the first leading space in case the user presses space\n // after the operator, for example: Owner: admin, will result in value of ` admin`\n // and we need to remove the first space, if the user added any more spaces only the\n // first one will be removed.\n value: trimFirstSpace(textWithoutPropertyAndOperator),\n };\n }\n\n const operatorPrefix = matchOperatorPrefix(allowedOps, trimStart(textWithoutProperty));\n if (operatorPrefix !== null) {\n return { step: 'operator', property, operatorPrefix };\n }\n\n return {\n step: 'free-text',\n value: filteringText,\n };\n};\n\nexport const getPropertyOptions = (\n filteringProperty: PropertyFilterProps.FilteringProperty,\n filteringOptions: PropertyFilterProps['filteringOptions']\n) => {\n return filteringOptions?.filter(option => option.propertyKey === filteringProperty.key);\n};\n\ninterface OptionGroup<T> {\n label: string;\n options: T[];\n}\n\ninterface ExtendedAutosuggestOption extends AutosuggestProps.Option {\n tokenValue: string;\n}\n\nexport const getAllValueSuggestions = (\n filteringOptions: PropertyFilterProps['filteringOptions'],\n filteringProperties: PropertyFilterProps['filteringProperties'],\n operator: PropertyFilterProps.ComparisonOperator | undefined = '=',\n i18nStrings: Pick<PropertyFilterProps.I18nStrings, 'groupValuesText'>,\n customGroupsText: PropertyFilterProps['customGroupsText']\n) => {\n const defaultGroup: OptionGroup<ExtendedAutosuggestOption> = {\n label: i18nStrings.groupValuesText,\n options: [],\n };\n const customGroups: { [K in string]: OptionGroup<ExtendedAutosuggestOption> } = {};\n filteringOptions?.forEach(filteringOption => {\n const property = getPropertyByKey(filteringProperties, filteringOption.propertyKey);\n // given option refers to a non-existent filtering property\n if (!property) {\n return;\n }\n // this option's filtering property does not support current operator\n if (getAllowedOperators(property).indexOf(operator) === -1) {\n return;\n }\n if (property.group && !customGroups[property.group]) {\n const label =\n customGroupsText?.reduce<string>(\n (acc, customGroup) => (customGroup.group === property.group ? customGroup.values : acc),\n ''\n ) || '';\n customGroups[property.group] = {\n label,\n options: [],\n };\n }\n const propertyGroup = property.group ? customGroups[property.group] : defaultGroup;\n propertyGroup.options.push({\n tokenValue: property.propertyLabel + (operator || '=') + filteringOption.value,\n label: filteringOption.value,\n __labelPrefix: property.propertyLabel + ' ' + (operator || '='),\n });\n });\n return [defaultGroup, ...Object.keys(customGroups).map(group => customGroups[group])];\n};\n\nexport const getPropertyByKey = (filteringProperties: PropertyFilterProps['filteringProperties'], key: string) => {\n const propertyMap = filteringProperties.reduce<{ [K: string]: PropertyFilterProps.FilteringProperty }>(\n (acc, property) => {\n acc[property.key] = property;\n return acc;\n },\n {}\n );\n return propertyMap[key] as PropertyFilterProps.FilteringProperty | undefined;\n};\n\nconst filteringPropertyToAutosuggestOption = (filteringProperty: PropertyFilterProps.FilteringProperty) => ({\n value: filteringProperty.propertyLabel,\n keepOpenOnSelect: true,\n});\n\nexport function getPropertySuggestions<T>(\n filteringProperties: PropertyFilterProps['filteringProperties'],\n customGroupsText: PropertyFilterProps['customGroupsText'],\n i18nStrings: Pick<PropertyFilterProps['i18nStrings'], 'groupPropertiesText'>,\n filteringPropertyToOption: (filteringProperty: PropertyFilterProps.FilteringProperty) => T\n) {\n const defaultGroup: OptionGroup<T> = {\n label: i18nStrings.groupPropertiesText,\n options: [],\n };\n const customGroups: { [K in string]: OptionGroup<T> } = {};\n\n filteringProperties.forEach(filteringProperty => {\n const { group } = filteringProperty;\n let optionsGroup = defaultGroup;\n if (group) {\n if (!customGroups[group]) {\n const label =\n customGroupsText?.reduce<string>(\n (acc, customGroup) => (customGroup.group === group ? customGroup.properties : acc),\n ''\n ) || '';\n customGroups[group] = { options: [], label };\n }\n optionsGroup = customGroups[group];\n }\n optionsGroup.options.push(filteringPropertyToOption(filteringProperty));\n });\n const defaultGroupArray = defaultGroup.options.length ? [defaultGroup] : [];\n const customGroupsArray = Object.keys(customGroups).map(groupKey => customGroups[groupKey]);\n return [...defaultGroupArray, ...customGroupsArray];\n}\n\nexport type OperatorStrings =\n | 'operatorLessText'\n | 'operatorLessOrEqualText'\n | 'operatorGreaterText'\n | 'operatorGreaterOrEqualText'\n | 'operatorContainsText'\n | 'operatorDoesNotContainText'\n | 'operatorEqualsText'\n | 'operatorDoesNotEqualText';\nexport const getAutosuggestOptions = (\n parsedText: ParsedText,\n filteringOptions: PropertyFilterProps['filteringOptions'],\n filteringProperties: PropertyFilterProps['filteringProperties'],\n customGroupsText: PropertyFilterProps['customGroupsText'],\n i18nStrings: Pick<\n PropertyFilterProps['i18nStrings'],\n 'groupPropertiesText' | 'groupValuesText' | 'operatorsText' | OperatorStrings\n >\n) => {\n switch (parsedText.step) {\n case 'property': {\n const { propertyLabel, groupValuesLabel } = parsedText.property;\n const options = getPropertyOptions(parsedText.property, filteringOptions);\n return {\n filterText: parsedText.value,\n options: [\n {\n options: (options || []).map(({ value }) => ({\n tokenValue: propertyLabel + parsedText.operator + value,\n label: value,\n __labelPrefix: propertyLabel + ' ' + parsedText.operator,\n })),\n label: groupValuesLabel,\n },\n ],\n };\n }\n case 'operator': {\n return {\n filterText: parsedText.property.propertyLabel + ' ' + parsedText.operatorPrefix,\n options: [\n ...getPropertySuggestions(\n filteringProperties,\n customGroupsText,\n i18nStrings,\n filteringPropertyToAutosuggestOption\n ),\n {\n options: getAllowedOperators(parsedText.property).map(value => ({\n value: parsedText.property.propertyLabel + ' ' + value + ' ',\n label: parsedText.property.propertyLabel + ' ' + value,\n description: operatorToDescription(value, i18nStrings),\n keepOpenOnSelect: true,\n })),\n label: i18nStrings.operatorsText,\n },\n ],\n };\n }\n case 'free-text': {\n const needsValueSuggestions = !!parsedText.value;\n const needsPropertySuggestions = !(parsedText.step === 'free-text' && parsedText.operator === '!:');\n return {\n filterText: parsedText.value,\n options: [\n ...(needsPropertySuggestions\n ? getPropertySuggestions(\n filteringProperties,\n customGroupsText,\n i18nStrings,\n filteringPropertyToAutosuggestOption\n )\n : []),\n ...(needsValueSuggestions\n ? getAllValueSuggestions(\n filteringOptions,\n filteringProperties,\n parsedText.operator,\n i18nStrings,\n customGroupsText\n )\n : []),\n ],\n };\n }\n }\n};\n\nexport const operatorToDescription = (\n operator: PropertyFilterProps.ComparisonOperator,\n i18nStrings: Pick<PropertyFilterProps['i18nStrings'], OperatorStrings>\n) => {\n const mapping: { [K in PropertyFilterProps.ComparisonOperator]: string } = {\n ['<']: i18nStrings.operatorLessText,\n ['<=']: i18nStrings.operatorLessOrEqualText,\n ['>']: i18nStrings.operatorGreaterText,\n ['>=']: i18nStrings.operatorGreaterOrEqualText,\n [':']: i18nStrings.operatorContainsText,\n ['!:']: i18nStrings.operatorDoesNotContainText,\n ['=']: i18nStrings.operatorEqualsText,\n ['!=']: i18nStrings.operatorDoesNotEqualText,\n };\n return mapping[operator];\n};\n"]}
|
|
@@ -143,8 +143,12 @@ export declare namespace PropertyFilterProps {
|
|
|
143
143
|
type Token = PropertyFilterToken;
|
|
144
144
|
type JoinOperation = PropertyFilterOperation;
|
|
145
145
|
type ComparisonOperator = PropertyFilterOperator;
|
|
146
|
-
type FilteringProperty = PropertyFilterProperty;
|
|
147
146
|
type FilteringOption = PropertyFilterOption;
|
|
147
|
+
interface FilteringProperty extends PropertyFilterProperty {
|
|
148
|
+
groupValuesLabel: string;
|
|
149
|
+
propertyLabel: string;
|
|
150
|
+
group?: string;
|
|
151
|
+
}
|
|
148
152
|
interface Query {
|
|
149
153
|
tokens: ReadonlyArray<PropertyFilterProps.Token>;
|
|
150
154
|
operation: PropertyFilterProps.JoinOperation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/property-filter/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAC9E,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,qCAAqC,CAAC;AAE7C,MAAM,WAAW,mBAAoB,SAAQ,kBAAkB,EAAE,gBAAgB;IAC/E;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAA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CAAC,gBAAgB,CAAC;KACrD;IAED,UAAiB,SAAS;QACxB,UAAU,EAAE,MAAM,CAAC;QACnB,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;KACf;IAED,UAAiB,qBAAqB;QACpC,aAAa,EAAE,MAAM,CAAC;QACtB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;KACvC;IAED,UAAiB,GAAG;QAClB;;WAEG;QACH,KAAK,IAAI,IAAI,CAAC;KACf;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/property-filter/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BaseComponentProps } from '../internal/base-component';\nimport { NonCancelableEventHandler } from '../internal/events';\nimport { DropdownStatusProps } from '../internal/components/dropdown-status';\nimport { AutosuggestProps } from '../autosuggest/interfaces';\nimport { ExpandToViewport } from '../internal/components/dropdown/interfaces';\nimport {\n PropertyFilterOperator,\n PropertyFilterOperation,\n PropertyFilterToken,\n PropertyFilterProperty,\n PropertyFilterOption,\n} from '@cloudscape-design/collection-hooks';\n\nexport interface PropertyFilterProps extends BaseComponentProps, ExpandToViewport {\n /**\n * If set to `true`, the filtering input will be disabled.\n * Use it, for example, if you are fetching new items upon filtering change\n * in order to prevent the user from changing the filtering query.\n */\n disabled?: boolean;\n /**\n * An object containing all the necessary localized strings required by the component.\n */\n i18nStrings: PropertyFilterProps.I18nStrings;\n /**\n * Accepts a human-readable, localized string that indicates the number of results. For example, \"1 match\" or \"165 matches.\"\n * If the total number of results is unknown, also include an indication that there may be more results than\n * the number listed. For example, \"25+ matches.\"\n *\n * The count text is only displayed when `query.tokens` isn't empty.\n */\n countText?: string;\n /**\n * An object representing the current query displayed in the property filter. Has two properties: `tokens` and `operation`.\n * `tokens` is an array of objects that will be displayed to the user beneath the filtering input.\n * Each token has the following properties:\n *\n * * value [string]: The string value of the token to be used as a filter.\n * * propertyKey [string]: The key of the corresponding property in filteringProperties.\n * * operator ['<' | '<=' | '>' | '>=' | ':' | '!:' | '=' | '!=']: The operator which indicates how to filter the dataset using this token.\n *\n * `operation` has two valid values [and, or] and controls the join operation to be applied between tokens when filtering the items.\n */\n query: PropertyFilterProps.Query;\n /**\n * If hideOperations it set, the indicator of the operation (that is, `and` or `or`) and the selection of operations\n * (applied to the property and value token) are hidden from the user. Only use when you have a custom\n * filtering logic which combines tokens in different way than the default one. When used, ensure that\n * operations are communicated to the user in another way.\n */\n hideOperations?: boolean;\n /**\n * Fired when the `query` gets changed. Filter the dataset in response to this event using the values in the `detail` object.\n */\n onChange: NonCancelableEventHandler<PropertyFilterProps.Query>;\n /**\n * An array of properties by which the data set can be filtered. Each element has the following properties:\n *\n * * groupValuesLabel [string]: Localized string to display for the 'Values' group label for a specific property.\n * * key [string]: The identifier of this property.\n * * propertyLabel [string]: A human-readable string for the property.\n * * operators [Array]: A list of all operators supported by this property. If you omit the equals operator because your API does not support it, make sure to set `defaultOperator` to a supported operator from this list.\n * * group [string]: Optional identifier of a custom group that this filtering option is assigned to. Use to create additional groups below the default one. Make sure to also define labels for the group in the customGroupsText property. Notice that only one level of options nesting is supported.\n * * defaultOperator [ComparisonOperator]: Optional parameter that changes the default operator used with this filtering property. Use it only if your API does not support \"equals\" filtering terms with this property.\n */\n filteringProperties: ReadonlyArray<PropertyFilterProps.FilteringProperty>;\n /**\n * An array of possible values of the individual `filteringProperties`. Each element has the following properties:\n *\n * * `propertyKey` [string]: The key of the corresponding filtering property in the `filteringProperties` array.\n * * `value` [string]: The value that will be used as a suggestion when creating or modifying a filtering token.\n */\n filteringOptions?: ReadonlyArray<PropertyFilterProps.FilteringOption>;\n /**\n * An array of objects that contain localized, human-readable strings for the labels of custom groups within the filtering dropdown. Use group property to associate the strings with your custom group of options. Define the following values for each group:\n *\n * * properties [string]: The group label in the filtering dropdown that contains the list of properties from this group. For example: Tags.\n * * values [string]: The group label in the filtering dropdown that contains the list of values from this group. For example: Tags values.\n * * group [string]: The identifier of a custom group.\n */\n customGroupsText?: PropertyFilterProps.GroupText[];\n /**\n * Set `disableFreeTextFiltering` only if you can’t filter the dataset using a filter that is applied to every column,\n * instead of a specific property. This would stop the user from creating such tokens.\n */\n disableFreeTextFiltering?: boolean;\n /**\n * Use this event to asynchronously load filteringOptions, component currently needs. The detail object contains following properties:\n *\n * * `filteringProperty` - The property for which you need to fetch the options.\n * * `filteringOperator` - The operator for which you need to fetch the options.\n * * `filteringText` - The value that you need to use to fetch options.\n * * `firstPage` - Indicates that you should fetch the first page of options for a `filteringProperty` that match the `filteringText`.\n * * `samePage` - Indicates that you should fetch the same page that you have previously fetched (for example, when the user clicks on the recovery button).\n */\n onLoadItems?: NonCancelableEventHandler<PropertyFilterProps.LoadItemsDetail>;\n /**\n * If you have more than 500 `filteringOptions`, enable this flag to apply a performance optimization that makes\n * the filtering experience smoother. We don't recommend enabling the feature if you have less than 500 options,\n * because the improvements to performance are offset by a visible scrolling lag. When you set this flag to true,\n * it removes options that are not currently in view from the DOM.\n */\n virtualScroll?: boolean;\n /**\n * A slot located before the filtering input. Use it if for a Select component if your dataset supports property\n * filter queries only after an initial filter is applied.\n */\n customControl?: React.ReactNode;\n /**\n * Set `asyncProperties` if you need to load `filteringProperties` asynchronousely. This would cause extra `onLoadMore`\n * events to fire calling for more properties.\n */\n asyncProperties?: boolean;\n /**\n * Specifies the maximum number of displayed tokens. If the property isn't set, all of the tokens are displayed.\n */\n tokenLimit?: number;\n /**\n * Displayed when there are no options to display.\n * This is only shown when `statusType` is set to `finished` or not set at all.\n */\n filteringEmpty?: React.ReactNode;\n /**\n * Specifies the text to display when in the loading state.\n **/\n filteringLoadingText?: string;\n /**\n * Specifies the text to display at the bottom of the dropdown menu after pagination has reached the end.\n **/\n filteringFinishedText?: string;\n /**\n * Specifies the text to display when a data fetching error occurs. Make sure that you provide `recoveryText`.\n **/\n filteringErrorText?: string;\n /**\n * Specifies the text for the recovery button. The text is displayed next to the error text.\n * Use the `onLoadItems` event to perform a recovery action (for example, retrying the request).\n **/\n filteringRecoveryText?: string;\n /**\n * Specifies the current status of loading more options.\n * * `pending` - Indicates that no request in progress, but more options may be loaded.\n * * `loading` - Indicates that data fetching is in progress.\n * * `finished` - Indicates that pagination has finished and no more requests are expected.\n * * `error` - Indicates that an error occurred during fetch. You should use `recoveryText` to enable the user to recover.\n **/\n filteringStatusType?: DropdownStatusProps.StatusType;\n}\n\nexport namespace PropertyFilterProps {\n export type Token = PropertyFilterToken;\n export type JoinOperation = PropertyFilterOperation;\n export type ComparisonOperator = PropertyFilterOperator;\n export type FilteringProperty = PropertyFilterProperty;\n export type FilteringOption = PropertyFilterOption;\n export interface Query {\n tokens: ReadonlyArray<PropertyFilterProps.Token>;\n operation: PropertyFilterProps.JoinOperation;\n }\n\n export interface LoadItemsDetail {\n filteringProperty?: FilteringProperty;\n filteringOperator?: ComparisonOperator;\n filteringText: string;\n firstPage: boolean;\n samePage: boolean;\n }\n\n export interface I18nStrings {\n /**\n * Label that will be passed down to the Autosuggest `ariaLabel` property.\n * See the [Autosuggest API](/system/components/autosuggest/?tabId=api) page for more details.\n */\n filteringAriaLabel: string;\n dismissAriaLabel: string;\n\n filteringPlaceholder?: string;\n groupValuesText: string;\n groupPropertiesText: string;\n operatorsText: string;\n\n operationAndText: string;\n operationOrText: string;\n\n operatorLessText: string;\n operatorLessOrEqualText: string;\n operatorGreaterText: string;\n operatorGreaterOrEqualText: string;\n operatorContainsText: string;\n operatorDoesNotContainText: string;\n operatorEqualsText: string;\n operatorDoesNotEqualText: string;\n\n editTokenHeader: string;\n propertyText: string;\n operatorText: string;\n valueText: string;\n cancelActionText: string;\n applyActionText: string;\n allPropertiesLabel: string;\n\n tokenLimitShowMore?: string;\n tokenLimitShowFewer?: string;\n clearFiltersText: string;\n removeTokenButtonAriaLabel: (token: PropertyFilterProps.Token) => string;\n enteredTextLabel: AutosuggestProps.EnteredTextLabel;\n }\n\n export interface GroupText {\n properties: string;\n values: string;\n group: string;\n }\n\n export interface FilteringChangeDetail {\n filteringText: string;\n filteringProperty?: FilteringProperty;\n }\n\n export interface Ref {\n /**\n * Sets focus on the underlying input control.\n */\n focus(): void;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/property-filter/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BaseComponentProps } from '../internal/base-component';\nimport { NonCancelableEventHandler } from '../internal/events';\nimport { DropdownStatusProps } from '../internal/components/dropdown-status';\nimport { AutosuggestProps } from '../autosuggest/interfaces';\nimport { ExpandToViewport } from '../internal/components/dropdown/interfaces';\nimport {\n PropertyFilterOperator,\n PropertyFilterOperation,\n PropertyFilterToken,\n PropertyFilterProperty,\n PropertyFilterOption,\n} from '@cloudscape-design/collection-hooks';\n\nexport interface PropertyFilterProps extends BaseComponentProps, ExpandToViewport {\n /**\n * If set to `true`, the filtering input will be disabled.\n * Use it, for example, if you are fetching new items upon filtering change\n * in order to prevent the user from changing the filtering query.\n */\n disabled?: boolean;\n /**\n * An object containing all the necessary localized strings required by the component.\n */\n i18nStrings: PropertyFilterProps.I18nStrings;\n /**\n * Accepts a human-readable, localized string that indicates the number of results. For example, \"1 match\" or \"165 matches.\"\n * If the total number of results is unknown, also include an indication that there may be more results than\n * the number listed. For example, \"25+ matches.\"\n *\n * The count text is only displayed when `query.tokens` isn't empty.\n */\n countText?: string;\n /**\n * An object representing the current query displayed in the property filter. Has two properties: `tokens` and `operation`.\n * `tokens` is an array of objects that will be displayed to the user beneath the filtering input.\n * Each token has the following properties:\n *\n * * value [string]: The string value of the token to be used as a filter.\n * * propertyKey [string]: The key of the corresponding property in filteringProperties.\n * * operator ['<' | '<=' | '>' | '>=' | ':' | '!:' | '=' | '!=']: The operator which indicates how to filter the dataset using this token.\n *\n * `operation` has two valid values [and, or] and controls the join operation to be applied between tokens when filtering the items.\n */\n query: PropertyFilterProps.Query;\n /**\n * If hideOperations it set, the indicator of the operation (that is, `and` or `or`) and the selection of operations\n * (applied to the property and value token) are hidden from the user. Only use when you have a custom\n * filtering logic which combines tokens in different way than the default one. When used, ensure that\n * operations are communicated to the user in another way.\n */\n hideOperations?: boolean;\n /**\n * Fired when the `query` gets changed. Filter the dataset in response to this event using the values in the `detail` object.\n */\n onChange: NonCancelableEventHandler<PropertyFilterProps.Query>;\n /**\n * An array of properties by which the data set can be filtered. Each element has the following properties:\n *\n * * groupValuesLabel [string]: Localized string to display for the 'Values' group label for a specific property.\n * * key [string]: The identifier of this property.\n * * propertyLabel [string]: A human-readable string for the property.\n * * operators [Array]: A list of all operators supported by this property. If you omit the equals operator because your API does not support it, make sure to set `defaultOperator` to a supported operator from this list.\n * * group [string]: Optional identifier of a custom group that this filtering option is assigned to. Use to create additional groups below the default one. Make sure to also define labels for the group in the customGroupsText property. Notice that only one level of options nesting is supported.\n * * defaultOperator [ComparisonOperator]: Optional parameter that changes the default operator used with this filtering property. Use it only if your API does not support \"equals\" filtering terms with this property.\n */\n filteringProperties: ReadonlyArray<PropertyFilterProps.FilteringProperty>;\n /**\n * An array of possible values of the individual `filteringProperties`. Each element has the following properties:\n *\n * * `propertyKey` [string]: The key of the corresponding filtering property in the `filteringProperties` array.\n * * `value` [string]: The value that will be used as a suggestion when creating or modifying a filtering token.\n */\n filteringOptions?: ReadonlyArray<PropertyFilterProps.FilteringOption>;\n /**\n * An array of objects that contain localized, human-readable strings for the labels of custom groups within the filtering dropdown. Use group property to associate the strings with your custom group of options. Define the following values for each group:\n *\n * * properties [string]: The group label in the filtering dropdown that contains the list of properties from this group. For example: Tags.\n * * values [string]: The group label in the filtering dropdown that contains the list of values from this group. For example: Tags values.\n * * group [string]: The identifier of a custom group.\n */\n customGroupsText?: PropertyFilterProps.GroupText[];\n /**\n * Set `disableFreeTextFiltering` only if you can’t filter the dataset using a filter that is applied to every column,\n * instead of a specific property. This would stop the user from creating such tokens.\n */\n disableFreeTextFiltering?: boolean;\n /**\n * Use this event to asynchronously load filteringOptions, component currently needs. The detail object contains following properties:\n *\n * * `filteringProperty` - The property for which you need to fetch the options.\n * * `filteringOperator` - The operator for which you need to fetch the options.\n * * `filteringText` - The value that you need to use to fetch options.\n * * `firstPage` - Indicates that you should fetch the first page of options for a `filteringProperty` that match the `filteringText`.\n * * `samePage` - Indicates that you should fetch the same page that you have previously fetched (for example, when the user clicks on the recovery button).\n */\n onLoadItems?: NonCancelableEventHandler<PropertyFilterProps.LoadItemsDetail>;\n /**\n * If you have more than 500 `filteringOptions`, enable this flag to apply a performance optimization that makes\n * the filtering experience smoother. We don't recommend enabling the feature if you have less than 500 options,\n * because the improvements to performance are offset by a visible scrolling lag. When you set this flag to true,\n * it removes options that are not currently in view from the DOM.\n */\n virtualScroll?: boolean;\n /**\n * A slot located before the filtering input. Use it if for a Select component if your dataset supports property\n * filter queries only after an initial filter is applied.\n */\n customControl?: React.ReactNode;\n /**\n * Set `asyncProperties` if you need to load `filteringProperties` asynchronousely. This would cause extra `onLoadMore`\n * events to fire calling for more properties.\n */\n asyncProperties?: boolean;\n /**\n * Specifies the maximum number of displayed tokens. If the property isn't set, all of the tokens are displayed.\n */\n tokenLimit?: number;\n /**\n * Displayed when there are no options to display.\n * This is only shown when `statusType` is set to `finished` or not set at all.\n */\n filteringEmpty?: React.ReactNode;\n /**\n * Specifies the text to display when in the loading state.\n **/\n filteringLoadingText?: string;\n /**\n * Specifies the text to display at the bottom of the dropdown menu after pagination has reached the end.\n **/\n filteringFinishedText?: string;\n /**\n * Specifies the text to display when a data fetching error occurs. Make sure that you provide `recoveryText`.\n **/\n filteringErrorText?: string;\n /**\n * Specifies the text for the recovery button. The text is displayed next to the error text.\n * Use the `onLoadItems` event to perform a recovery action (for example, retrying the request).\n **/\n filteringRecoveryText?: string;\n /**\n * Specifies the current status of loading more options.\n * * `pending` - Indicates that no request in progress, but more options may be loaded.\n * * `loading` - Indicates that data fetching is in progress.\n * * `finished` - Indicates that pagination has finished and no more requests are expected.\n * * `error` - Indicates that an error occurred during fetch. You should use `recoveryText` to enable the user to recover.\n **/\n filteringStatusType?: DropdownStatusProps.StatusType;\n}\n\nexport namespace PropertyFilterProps {\n export type Token = PropertyFilterToken;\n export type JoinOperation = PropertyFilterOperation;\n export type ComparisonOperator = PropertyFilterOperator;\n export type FilteringOption = PropertyFilterOption;\n export interface FilteringProperty extends PropertyFilterProperty {\n groupValuesLabel: string;\n propertyLabel: string;\n group?: string;\n }\n\n export interface Query {\n tokens: ReadonlyArray<PropertyFilterProps.Token>;\n operation: PropertyFilterProps.JoinOperation;\n }\n\n export interface LoadItemsDetail {\n filteringProperty?: FilteringProperty;\n filteringOperator?: ComparisonOperator;\n filteringText: string;\n firstPage: boolean;\n samePage: boolean;\n }\n\n export interface I18nStrings {\n /**\n * Label that will be passed down to the Autosuggest `ariaLabel` property.\n * See the [Autosuggest API](/system/components/autosuggest/?tabId=api) page for more details.\n */\n filteringAriaLabel: string;\n dismissAriaLabel: string;\n\n filteringPlaceholder?: string;\n groupValuesText: string;\n groupPropertiesText: string;\n operatorsText: string;\n\n operationAndText: string;\n operationOrText: string;\n\n operatorLessText: string;\n operatorLessOrEqualText: string;\n operatorGreaterText: string;\n operatorGreaterOrEqualText: string;\n operatorContainsText: string;\n operatorDoesNotContainText: string;\n operatorEqualsText: string;\n operatorDoesNotEqualText: string;\n\n editTokenHeader: string;\n propertyText: string;\n operatorText: string;\n valueText: string;\n cancelActionText: string;\n applyActionText: string;\n allPropertiesLabel: string;\n\n tokenLimitShowMore?: string;\n tokenLimitShowFewer?: string;\n clearFiltersText: string;\n removeTokenButtonAriaLabel: (token: PropertyFilterProps.Token) => string;\n enteredTextLabel: AutosuggestProps.EnteredTextLabel;\n }\n\n export interface GroupText {\n properties: string;\n values: string;\n group: string;\n }\n\n export interface FilteringChangeDetail {\n filteringText: string;\n filteringProperty?: FilteringProperty;\n }\n\n export interface Ref {\n /**\n * Sets focus on the underlying input control.\n */\n focus(): void;\n }\n}\n"]}
|
|
@@ -7,7 +7,7 @@ import { PropertyFilterProps } from './interfaces';
|
|
|
7
7
|
* the same event from firing twice in a row. This means, refocusing the control sometimes results in
|
|
8
8
|
* `onLoadItems` firing, but sometimes not.
|
|
9
9
|
*/
|
|
10
|
-
export declare const useLoadItems: (onLoadItems: PropertyFilterProps['onLoadItems'], focusFilteringText?: string | undefined, currentFilteringProperty?:
|
|
10
|
+
export declare const useLoadItems: (onLoadItems: PropertyFilterProps['onLoadItems'], focusFilteringText?: string | undefined, currentFilteringProperty?: PropertyFilterProps.FilteringProperty | undefined, currentFilteringText?: string | undefined, currentFilteringOperator?: import("@cloudscape-design/collection-hooks").PropertyFilterOperator | undefined) => {
|
|
11
11
|
onBlur: () => void;
|
|
12
12
|
onFocus: () => void;
|
|
13
13
|
onLoadItems: NonCancelableEventHandler<import("../internal/components/dropdown/interfaces").OptionsLoadItemsDetail>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tab-header-bar.d.ts","sourceRoot":"","sources":["../../../src/tabs/tab-header-bar.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAiBzC,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,CAAC,YAAY,EAAE,SAAS,CAAC,YAAY,KAAK,IAAI,CAAC;IACzD,WAAW,EAAE,SAAS,CAAC,aAAa,CAAC,CAAC;IACtC,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IACxB,OAAO,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,WAAW,EACX,IAAI,EACJ,OAAO,EACP,WAAW,EACX,SAAS,EACT,cAAc,GACf,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"tab-header-bar.d.ts","sourceRoot":"","sources":["../../../src/tabs/tab-header-bar.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAiBzC,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,CAAC,YAAY,EAAE,SAAS,CAAC,YAAY,KAAK,IAAI,CAAC;IACzD,WAAW,EAAE,SAAS,CAAC,aAAa,CAAC,CAAC;IACtC,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IACxB,OAAO,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,WAAW,EACX,IAAI,EACJ,OAAO,EACP,WAAW,EACX,SAAS,EACT,cAAc,GACf,EAAE,iBAAiB,eAoRnB"}
|
package/tabs/tab-header-bar.js
CHANGED
|
@@ -95,10 +95,10 @@ export function TabHeaderBar(_a) {
|
|
|
95
95
|
//converted span to div as list should not be a child of span for HTML validation
|
|
96
96
|
React.createElement("div", { className: classes, ref: containerRef },
|
|
97
97
|
horizontalOverflow && (React.createElement("span", { ref: leftOverflowButton, className: leftButtonClasses },
|
|
98
|
-
React.createElement(InternalButton, { variant: "icon", iconName: "angle-left", __nativeAttributes: paginationButtonAttributes, disabled: !leftOverflow, onClick: function () { return onPaginationClick(headerBarRef, -1); } }))),
|
|
98
|
+
React.createElement(InternalButton, { formAction: "none", variant: "icon", iconName: "angle-left", __nativeAttributes: paginationButtonAttributes, disabled: !leftOverflow, onClick: function () { return onPaginationClick(headerBarRef, -1); } }))),
|
|
99
99
|
React.createElement("ul", { role: "tablist", className: styles['tabs-header-list'], "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, ref: headerBarRef, onScroll: onScroll }, tabs.map(renderTabHeader)),
|
|
100
100
|
horizontalOverflow && (React.createElement("span", { className: rightButtonClasses },
|
|
101
|
-
React.createElement(InternalButton, { variant: "icon", iconName: "angle-right", __nativeAttributes: paginationButtonAttributes, disabled: !rightOverflow, onClick: function () { return onPaginationClick(headerBarRef, 1); } })))));
|
|
101
|
+
React.createElement(InternalButton, { formAction: "none", variant: "icon", iconName: "angle-right", __nativeAttributes: paginationButtonAttributes, disabled: !rightOverflow, onClick: function () { return onPaginationClick(headerBarRef, 1); } })))));
|
|
102
102
|
function renderTabHeader(tab) {
|
|
103
103
|
var _a;
|
|
104
104
|
var enabledTabsWithCurrentTab = tabs.filter(function (tab) { return !tab.disabled || tab.id === activeTabId; });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tab-header-bar.js","sourceRoot":"","sources":["../../../src/tabs/tab-header-bar.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE3D,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EAChB,cAAc,GACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAYrE,MAAM,UAAU,YAAY,CAAC,EAQT;;QAPlB,QAAQ,cAA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-Identifier: Apache-2.0\nimport React, { useRef, useState, useEffect } from 'react';\nimport { TabsProps } from './interfaces';\nimport clsx from 'clsx';\nimport styles from './styles.css.js';\nimport { InternalButton } from '../button/internal';\nimport useFocusVisible from '../internal/hooks/focus-visible';\nimport { useContainerQuery } from '../internal/hooks/container-queries';\nimport { KeyCode } from '../internal/keycode';\nimport {\n onPaginationClick,\n hasHorizontalOverflow,\n hasLeftOverflow,\n hasRightOverflow,\n scrollIntoView,\n} from './scroll-utils';\nimport { isPlainLeftClick } from '../internal/events';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\n\nexport interface TabHeaderBarProps {\n onChange: (changeDetail: TabsProps.ChangeDetail) => void;\n activeTabId: TabsProps['activeTabId'];\n tabs: TabsProps['tabs'];\n variant: TabsProps['variant'];\n idNamespace: string;\n ariaLabel?: string;\n ariaLabelledby?: string;\n}\n\nexport function TabHeaderBar({\n onChange,\n activeTabId,\n tabs,\n variant,\n idNamespace,\n ariaLabel,\n ariaLabelledby,\n}: TabHeaderBarProps) {\n const focusVisible = useFocusVisible();\n\n const headerBarRef = useRef<HTMLUListElement>(null);\n const activeTabHeaderRef = useRef<HTMLAnchorElement>(null);\n const leftOverflowButton = useRef<HTMLElement>(null);\n\n const isVisualRefresh = useVisualRefresh();\n\n const [widthChange, containerRef] = useContainerQuery<number>(rect => rect.width);\n const tabRefs = useRef<Map<string, HTMLElement>>(new Map());\n const [horizontalOverflow, setHorizontalOverflow] = useState(false);\n const [leftOverflow, setLeftOverflow] = useState(false);\n const [rightOverflow, setRightOverflow] = useState(false);\n\n useEffect(() => {\n if (headerBarRef.current) {\n setHorizontalOverflow(hasHorizontalOverflow(headerBarRef.current, leftOverflowButton));\n setLeftOverflow(hasLeftOverflow(headerBarRef.current));\n setRightOverflow(hasRightOverflow(headerBarRef.current));\n }\n }, [widthChange, tabs]);\n\n const scrollIntoViewIfPossible = (smooth: boolean) => {\n if (!activeTabId) {\n return;\n }\n const activeTabRef = tabRefs.current.get(activeTabId);\n if (activeTabRef && headerBarRef.current) {\n scrollIntoView(activeTabRef, headerBarRef.current, smooth);\n }\n };\n\n useEffect(() => {\n // Delay scrollIntoView as the position is depending on parent elements\n // (effects are called inside-out in the component tree).\n // Wait one frame to allow parents to complete it's calculation.\n requestAnimationFrame(() => {\n scrollIntoViewIfPossible(false);\n });\n // Non-smooth scrolling should not be called upon activeId change\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [horizontalOverflow, widthChange, tabs.length]);\n\n useEffect(() => {\n scrollIntoViewIfPossible(true);\n // Smooth scrolling should only be called upon activeId change\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [activeTabId]);\n\n useEffect(() => {\n /*\n When the selected tab changes and we are currently already focused on a tab,\n move the focus to the newly selected tab.\n */\n if (headerBarRef.current?.contains(document.activeElement)) {\n if (document.activeElement !== activeTabHeaderRef.current) {\n activeTabHeaderRef.current?.focus({ preventScroll: true });\n }\n }\n }, [activeTabId]);\n\n const onScroll = () => {\n if (headerBarRef.current) {\n setLeftOverflow(hasLeftOverflow(headerBarRef.current));\n setRightOverflow(hasRightOverflow(headerBarRef.current));\n }\n };\n\n const classes = clsx({\n [styles['tabs-header']]: true,\n [styles['tabs-header-with-divider']]: variant === 'default' || isVisualRefresh,\n });\n\n const leftButtonClasses = clsx({\n [styles['pagination-button']]: true,\n [styles['pagination-button-left']]: true,\n [styles['pagination-button-left-scrollable']]: leftOverflow,\n });\n\n const rightButtonClasses = clsx({\n [styles['pagination-button']]: true,\n [styles['pagination-button-right']]: true,\n [styles['pagination-button-right-scrollable']]: rightOverflow,\n });\n\n const paginationButtonAttributes = {\n 'aria-hidden': true,\n tabIndex: -1,\n };\n\n return (\n //converted span to div as list should not be a child of span for HTML validation\n <div className={classes} ref={containerRef}>\n {horizontalOverflow && (\n <span ref={leftOverflowButton} className={leftButtonClasses}>\n <InternalButton\n variant=\"icon\"\n iconName=\"angle-left\"\n __nativeAttributes={paginationButtonAttributes}\n disabled={!leftOverflow}\n onClick={() => onPaginationClick(headerBarRef, -1)}\n />\n </span>\n )}\n <ul\n role=\"tablist\"\n className={styles['tabs-header-list']}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n ref={headerBarRef}\n onScroll={onScroll}\n >\n {tabs.map(renderTabHeader)}\n </ul>\n {horizontalOverflow && (\n <span className={rightButtonClasses}>\n <InternalButton\n variant=\"icon\"\n iconName=\"angle-right\"\n __nativeAttributes={paginationButtonAttributes}\n disabled={!rightOverflow}\n onClick={() => onPaginationClick(headerBarRef, 1)}\n />\n </span>\n )}\n </div>\n );\n\n function renderTabHeader(tab: TabsProps.Tab) {\n const enabledTabsWithCurrentTab = tabs.filter(tab => !tab.disabled || tab.id === activeTabId);\n\n const highlightTab = function (enabledTabIndex: number) {\n const tab = enabledTabsWithCurrentTab[enabledTabIndex];\n if (tab.id === activeTabId) {\n return;\n }\n\n onChange({ activeTabId: tab.id, activeTabHref: tab.href });\n };\n\n const handleKeyDown = function (\n event: React.KeyboardEvent<HTMLAnchorElement> | React.KeyboardEvent<HTMLButtonElement>\n ) {\n const { keyCode } = event;\n const specialKeys = [KeyCode.right, KeyCode.left, KeyCode.end, KeyCode.home, KeyCode.pageUp, KeyCode.pageDown];\n if (specialKeys.indexOf(keyCode) === -1) {\n return;\n }\n event.preventDefault();\n const activeIndex = enabledTabsWithCurrentTab.indexOf(tab);\n switch (keyCode) {\n case KeyCode.right:\n if (activeIndex + 1 === enabledTabsWithCurrentTab.length) {\n highlightTab(0);\n } else {\n highlightTab(activeIndex + 1);\n }\n return;\n case KeyCode.left:\n if (activeIndex === 0) {\n highlightTab(enabledTabsWithCurrentTab.length - 1);\n } else {\n highlightTab(activeIndex - 1);\n }\n return;\n case KeyCode.end:\n highlightTab(enabledTabsWithCurrentTab.length - 1);\n return;\n case KeyCode.home:\n highlightTab(0);\n return;\n case KeyCode.pageDown:\n if (rightOverflow) {\n onPaginationClick(headerBarRef, 1);\n }\n return;\n case KeyCode.pageUp:\n if (leftOverflow) {\n onPaginationClick(headerBarRef, -1);\n }\n return;\n }\n };\n\n const clickTab = (event: React.MouseEvent) => {\n if (tab.disabled) {\n event.preventDefault();\n return;\n }\n\n // if the primary mouse button is clicked with a modifier key, the browser will handle opening a new tab\n const specialKey = !isPlainLeftClick(event);\n if (specialKey && tab.href) {\n return;\n }\n\n event.preventDefault();\n // for browsers that do not focus buttons on button click\n if (!tab.href) {\n const clickedTabRef = tabRefs.current.get(tab.id);\n if (clickedTabRef) {\n const childElement = clickedTabRef.firstChild as HTMLButtonElement;\n if (childElement && childElement !== document.activeElement) {\n childElement.focus({ preventScroll: true });\n }\n }\n }\n\n if (tab.id === activeTabId) {\n return;\n }\n\n onChange({ activeTabId: tab.id, activeTabHref: tab.href });\n };\n\n const classes = clsx({\n [styles['tabs-tab-link']]: true,\n [styles.refresh]: isVisualRefresh,\n [styles['tabs-tab-active']]: activeTabId === tab.id && !tab.disabled,\n [styles['tabs-tab-disabled']]: tab.disabled,\n });\n\n const commonProps: (JSX.IntrinsicElements['a'] | JSX.IntrinsicElements['button']) & { 'data-testid': string } = {\n className: classes,\n ...focusVisible,\n role: 'tab',\n 'aria-selected': tab.id === activeTabId,\n 'aria-controls': `${idNamespace}-${tab.id}-panel`,\n 'data-testid': tab.id,\n children: <span className={styles['tabs-tab-label']}>{tab.label}</span>,\n };\n\n if (tab.disabled) {\n commonProps['aria-disabled'] = 'true';\n } else {\n commonProps.onClick = clickTab;\n }\n\n if (tab.id === activeTabId) {\n commonProps.ref = activeTabHeaderRef;\n commonProps.tabIndex = 0;\n commonProps.onKeyDown = (\n event: React.KeyboardEvent<HTMLAnchorElement> | React.KeyboardEvent<HTMLButtonElement>\n ) => handleKeyDown(event);\n } else {\n commonProps.tabIndex = -1;\n }\n\n let trigger = null;\n if (tab.href) {\n const anchorProps = commonProps as JSX.IntrinsicElements['a'];\n anchorProps.href = tab.href;\n trigger = <a {...anchorProps} />;\n } else {\n const buttonProps = commonProps as JSX.IntrinsicElements['button'];\n buttonProps.type = 'button';\n if (tab.disabled) {\n buttonProps.disabled = true;\n }\n trigger = <button {...buttonProps} />;\n }\n\n return (\n <li\n ref={element => tabRefs.current.set(tab.id, element as HTMLElement)}\n className={styles['tabs-tab']}\n role=\"presentation\"\n key={tab.id}\n >\n {trigger}\n </li>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tab-header-bar.js","sourceRoot":"","sources":["../../../src/tabs/tab-header-bar.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE3D,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EAChB,cAAc,GACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAYrE,MAAM,UAAU,YAAY,CAAC,EAQT;;QAPlB,QAAQ,cAAA,EACR,WAAW,iBAAA,EACX,IAAI,UAAA,EACJ,OAAO,aAAA,EACP,WAAW,iBAAA,EACX,SAAS,eAAA,EACT,cAAc,oBAAA;IAEd,IAAM,YAAY,GAAG,eAAe,EAAE,CAAC;IAEvC,IAAM,YAAY,GAAG,MAAM,CAAmB,IAAI,CAAC,CAAC;IACpD,IAAM,kBAAkB,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAC;IAC3D,IAAM,kBAAkB,GAAG,MAA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,GAAG,CAAC,CAAC;YACzB,WAAW,CAAC,SAAS,GAAG,UACtB,KAAsF,IACnF,OAAA,aAAa,CAAC,KAAK,CAAC,EAApB,CAAoB,CAAC;SAC3B;aAAM;YACL,WAAW,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;SAC3B;QAED,IAAI,OAAO,GAAG,IAAI,CAAC;QACnB,IAAI,GAAG,CAAC,IAAI,EAAE;YACZ,IAAM,WAAW,GAAG,WAAyC,CAAC;YAC9D,WAAW,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;YAC5B,OAAO,GAAG,sCAAO,WAAW,EAAI,CAAC;SAClC;aAAM;YACL,IAAM,WAAW,GAAG,WAA8C,CAAC;YACnE,WAAW,CAAC,IAAI,GAAG,QAAQ,CAAC;YAC5B,IAAI,GAAG,CAAC,QAAQ,EAAE;gBAChB,WAAW,CAAC,QAAQ,GAAG,IAAI,CAAC;aAC7B;YACD,OAAO,GAAG,2CAAY,WAAW,EAAI,CAAC;SACvC;QAED,OAAO,CACL,4BACE,GAAG,EAAE,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,OAAsB,CAAC,EAAnD,CAAmD,EACnE,SAAS,EAAE,MAAM,CAAC,UAAU,CAAC,EAC7B,IAAI,EAAC,cAAc,EACnB,GAAG,EAAE,GAAG,CAAC,EAAE,IAEV,OAAO,CACL,CACN,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef, useState, useEffect } from 'react';\nimport { TabsProps } from './interfaces';\nimport clsx from 'clsx';\nimport styles from './styles.css.js';\nimport { InternalButton } from '../button/internal';\nimport useFocusVisible from '../internal/hooks/focus-visible';\nimport { useContainerQuery } from '../internal/hooks/container-queries';\nimport { KeyCode } from '../internal/keycode';\nimport {\n onPaginationClick,\n hasHorizontalOverflow,\n hasLeftOverflow,\n hasRightOverflow,\n scrollIntoView,\n} from './scroll-utils';\nimport { isPlainLeftClick } from '../internal/events';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\n\nexport interface TabHeaderBarProps {\n onChange: (changeDetail: TabsProps.ChangeDetail) => void;\n activeTabId: TabsProps['activeTabId'];\n tabs: TabsProps['tabs'];\n variant: TabsProps['variant'];\n idNamespace: string;\n ariaLabel?: string;\n ariaLabelledby?: string;\n}\n\nexport function TabHeaderBar({\n onChange,\n activeTabId,\n tabs,\n variant,\n idNamespace,\n ariaLabel,\n ariaLabelledby,\n}: TabHeaderBarProps) {\n const focusVisible = useFocusVisible();\n\n const headerBarRef = useRef<HTMLUListElement>(null);\n const activeTabHeaderRef = useRef<HTMLAnchorElement>(null);\n const leftOverflowButton = useRef<HTMLElement>(null);\n\n const isVisualRefresh = useVisualRefresh();\n\n const [widthChange, containerRef] = useContainerQuery<number>(rect => rect.width);\n const tabRefs = useRef<Map<string, HTMLElement>>(new Map());\n const [horizontalOverflow, setHorizontalOverflow] = useState(false);\n const [leftOverflow, setLeftOverflow] = useState(false);\n const [rightOverflow, setRightOverflow] = useState(false);\n\n useEffect(() => {\n if (headerBarRef.current) {\n setHorizontalOverflow(hasHorizontalOverflow(headerBarRef.current, leftOverflowButton));\n setLeftOverflow(hasLeftOverflow(headerBarRef.current));\n setRightOverflow(hasRightOverflow(headerBarRef.current));\n }\n }, [widthChange, tabs]);\n\n const scrollIntoViewIfPossible = (smooth: boolean) => {\n if (!activeTabId) {\n return;\n }\n const activeTabRef = tabRefs.current.get(activeTabId);\n if (activeTabRef && headerBarRef.current) {\n scrollIntoView(activeTabRef, headerBarRef.current, smooth);\n }\n };\n\n useEffect(() => {\n // Delay scrollIntoView as the position is depending on parent elements\n // (effects are called inside-out in the component tree).\n // Wait one frame to allow parents to complete it's calculation.\n requestAnimationFrame(() => {\n scrollIntoViewIfPossible(false);\n });\n // Non-smooth scrolling should not be called upon activeId change\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [horizontalOverflow, widthChange, tabs.length]);\n\n useEffect(() => {\n scrollIntoViewIfPossible(true);\n // Smooth scrolling should only be called upon activeId change\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [activeTabId]);\n\n useEffect(() => {\n /*\n When the selected tab changes and we are currently already focused on a tab,\n move the focus to the newly selected tab.\n */\n if (headerBarRef.current?.contains(document.activeElement)) {\n if (document.activeElement !== activeTabHeaderRef.current) {\n activeTabHeaderRef.current?.focus({ preventScroll: true });\n }\n }\n }, [activeTabId]);\n\n const onScroll = () => {\n if (headerBarRef.current) {\n setLeftOverflow(hasLeftOverflow(headerBarRef.current));\n setRightOverflow(hasRightOverflow(headerBarRef.current));\n }\n };\n\n const classes = clsx({\n [styles['tabs-header']]: true,\n [styles['tabs-header-with-divider']]: variant === 'default' || isVisualRefresh,\n });\n\n const leftButtonClasses = clsx({\n [styles['pagination-button']]: true,\n [styles['pagination-button-left']]: true,\n [styles['pagination-button-left-scrollable']]: leftOverflow,\n });\n\n const rightButtonClasses = clsx({\n [styles['pagination-button']]: true,\n [styles['pagination-button-right']]: true,\n [styles['pagination-button-right-scrollable']]: rightOverflow,\n });\n\n const paginationButtonAttributes = {\n 'aria-hidden': true,\n tabIndex: -1,\n };\n\n return (\n //converted span to div as list should not be a child of span for HTML validation\n <div className={classes} ref={containerRef}>\n {horizontalOverflow && (\n <span ref={leftOverflowButton} className={leftButtonClasses}>\n <InternalButton\n formAction=\"none\"\n variant=\"icon\"\n iconName=\"angle-left\"\n __nativeAttributes={paginationButtonAttributes}\n disabled={!leftOverflow}\n onClick={() => onPaginationClick(headerBarRef, -1)}\n />\n </span>\n )}\n <ul\n role=\"tablist\"\n className={styles['tabs-header-list']}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n ref={headerBarRef}\n onScroll={onScroll}\n >\n {tabs.map(renderTabHeader)}\n </ul>\n {horizontalOverflow && (\n <span className={rightButtonClasses}>\n <InternalButton\n formAction=\"none\"\n variant=\"icon\"\n iconName=\"angle-right\"\n __nativeAttributes={paginationButtonAttributes}\n disabled={!rightOverflow}\n onClick={() => onPaginationClick(headerBarRef, 1)}\n />\n </span>\n )}\n </div>\n );\n\n function renderTabHeader(tab: TabsProps.Tab) {\n const enabledTabsWithCurrentTab = tabs.filter(tab => !tab.disabled || tab.id === activeTabId);\n\n const highlightTab = function (enabledTabIndex: number) {\n const tab = enabledTabsWithCurrentTab[enabledTabIndex];\n if (tab.id === activeTabId) {\n return;\n }\n\n onChange({ activeTabId: tab.id, activeTabHref: tab.href });\n };\n\n const handleKeyDown = function (\n event: React.KeyboardEvent<HTMLAnchorElement> | React.KeyboardEvent<HTMLButtonElement>\n ) {\n const { keyCode } = event;\n const specialKeys = [KeyCode.right, KeyCode.left, KeyCode.end, KeyCode.home, KeyCode.pageUp, KeyCode.pageDown];\n if (specialKeys.indexOf(keyCode) === -1) {\n return;\n }\n event.preventDefault();\n const activeIndex = enabledTabsWithCurrentTab.indexOf(tab);\n switch (keyCode) {\n case KeyCode.right:\n if (activeIndex + 1 === enabledTabsWithCurrentTab.length) {\n highlightTab(0);\n } else {\n highlightTab(activeIndex + 1);\n }\n return;\n case KeyCode.left:\n if (activeIndex === 0) {\n highlightTab(enabledTabsWithCurrentTab.length - 1);\n } else {\n highlightTab(activeIndex - 1);\n }\n return;\n case KeyCode.end:\n highlightTab(enabledTabsWithCurrentTab.length - 1);\n return;\n case KeyCode.home:\n highlightTab(0);\n return;\n case KeyCode.pageDown:\n if (rightOverflow) {\n onPaginationClick(headerBarRef, 1);\n }\n return;\n case KeyCode.pageUp:\n if (leftOverflow) {\n onPaginationClick(headerBarRef, -1);\n }\n return;\n }\n };\n\n const clickTab = (event: React.MouseEvent) => {\n if (tab.disabled) {\n event.preventDefault();\n return;\n }\n\n // if the primary mouse button is clicked with a modifier key, the browser will handle opening a new tab\n const specialKey = !isPlainLeftClick(event);\n if (specialKey && tab.href) {\n return;\n }\n\n event.preventDefault();\n // for browsers that do not focus buttons on button click\n if (!tab.href) {\n const clickedTabRef = tabRefs.current.get(tab.id);\n if (clickedTabRef) {\n const childElement = clickedTabRef.firstChild as HTMLButtonElement;\n if (childElement && childElement !== document.activeElement) {\n childElement.focus({ preventScroll: true });\n }\n }\n }\n\n if (tab.id === activeTabId) {\n return;\n }\n\n onChange({ activeTabId: tab.id, activeTabHref: tab.href });\n };\n\n const classes = clsx({\n [styles['tabs-tab-link']]: true,\n [styles.refresh]: isVisualRefresh,\n [styles['tabs-tab-active']]: activeTabId === tab.id && !tab.disabled,\n [styles['tabs-tab-disabled']]: tab.disabled,\n });\n\n const commonProps: (JSX.IntrinsicElements['a'] | JSX.IntrinsicElements['button']) & { 'data-testid': string } = {\n className: classes,\n ...focusVisible,\n role: 'tab',\n 'aria-selected': tab.id === activeTabId,\n 'aria-controls': `${idNamespace}-${tab.id}-panel`,\n 'data-testid': tab.id,\n children: <span className={styles['tabs-tab-label']}>{tab.label}</span>,\n };\n\n if (tab.disabled) {\n commonProps['aria-disabled'] = 'true';\n } else {\n commonProps.onClick = clickTab;\n }\n\n if (tab.id === activeTabId) {\n commonProps.ref = activeTabHeaderRef;\n commonProps.tabIndex = 0;\n commonProps.onKeyDown = (\n event: React.KeyboardEvent<HTMLAnchorElement> | React.KeyboardEvent<HTMLButtonElement>\n ) => handleKeyDown(event);\n } else {\n commonProps.tabIndex = -1;\n }\n\n let trigger = null;\n if (tab.href) {\n const anchorProps = commonProps as JSX.IntrinsicElements['a'];\n anchorProps.href = tab.href;\n trigger = <a {...anchorProps} />;\n } else {\n const buttonProps = commonProps as JSX.IntrinsicElements['button'];\n buttonProps.type = 'button';\n if (tab.disabled) {\n buttonProps.disabled = true;\n }\n trigger = <button {...buttonProps} />;\n }\n\n return (\n <li\n ref={element => tabRefs.current.set(tab.id, element as HTMLElement)}\n className={styles['tabs-tab']}\n role=\"presentation\"\n key={tab.id}\n >\n {trigger}\n </li>\n );\n }\n}\n"]}
|