Skip to content

Commit d70f5eb

Browse files
committed
remove public api changes
1 parent 5b663c2 commit d70f5eb

File tree

13 files changed

+177
-157
lines changed

13 files changed

+177
-157
lines changed

pages/property-filter/common-props.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33
import { PropertyFilterProps } from '~components/property-filter';
4+
import { I18nStringsTokenGroups } from '~components/property-filter/interfaces';
45

56
import {
67
DateForm,
@@ -183,7 +184,9 @@ export const i18nStrings: PropertyFilterProps.I18nStrings = {
183184

184185
formatToken,
185186
removeTokenButtonAriaLabel: token => `Remove token, ${formatToken(token)}`,
187+
};
186188

189+
export const i18nStringsTokenGroups: I18nStringsTokenGroups = {
187190
groupEditAriaLabel: group => `Edit group with ${group.tokens.length} tokens`,
188191
tokenEditorTokenActionsAriaLabel: token => `Filter remove actions for ${formatToken(token)}`,
189192
tokenEditorTokenRemoveAriaLabel: token => `Remove filter, ${formatToken(token)}`,

pages/property-filter/split-panel-app-layout-integration.page.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Button from '~components/button';
1010
import Header from '~components/header';
1111
import I18nProvider from '~components/i18n';
1212
import messages from '~components/i18n/messages/all.en';
13-
import PropertyFilter from '~components/property-filter';
13+
import PropertyFilter from '~components/property-filter/internal';
1414
import SplitPanel from '~components/split-panel';
1515
import Table from '~components/table';
1616

@@ -100,6 +100,8 @@ export default function () {
100100
enableTokenGroups={true}
101101
expandToViewport={true}
102102
filteringEmpty="No properties"
103+
customGroupsText={[]}
104+
disableFreeTextFiltering={false}
103105
/>
104106
}
105107
columnDefinitions={columnDefinitions.slice(0, 2)}

pages/property-filter/token-editor.page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
columnDefinitions,
1212
filteringProperties as commonFilteringProperties,
1313
i18nStrings,
14+
i18nStringsTokenGroups,
1415
labels,
1516
} from './common-props';
1617

@@ -27,6 +28,7 @@ const commonProps = {
2728
filteringProperties,
2829
filteringOptions: [],
2930
i18nStrings,
31+
i18nStringsTokenGroups,
3032
countText: '5 matches',
3133
disableFreeTextFiltering: false,
3234
virtualScroll: true,

src/__tests__/__snapshots__/documenter.test.ts.snap

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -12177,12 +12177,6 @@ in order to prevent the user from changing the filtering query.",
1217712177
"optional": true,
1217812178
"type": "boolean",
1217912179
},
12180-
Object {
12181-
"defaultValue": "false",
12182-
"name": "enableTokenGroups",
12183-
"optional": true,
12184-
"type": "boolean",
12185-
},
1218612180
Object {
1218712181
"description": "By default, the dropdown height is constrained to fit inside the height of its next scrollable container element.
1218812182
Enabling this property will allow the dropdown to extend beyond that container by using fixed positioning and
@@ -12377,11 +12371,6 @@ operations are communicated to the user in another way.",
1237712371
"optional": true,
1237812372
"type": "(token: PropertyFilterProps.FormattedToken) => string",
1237912373
},
12380-
Object {
12381-
"name": "groupEditAriaLabel",
12382-
"optional": true,
12383-
"type": "(group: PropertyFilterProps.FormattedTokenGroup) => string",
12384-
},
1238512374
Object {
1238612375
"name": "groupPropertiesText",
1238712376
"optional": true,
@@ -12472,46 +12461,6 @@ operations are communicated to the user in another way.",
1247212461
"optional": true,
1247312462
"type": "(token: PropertyFilterProps.FormattedToken) => string",
1247412463
},
12475-
Object {
12476-
"name": "tokenEditorAddExistingTokenAriaLabel",
12477-
"optional": true,
12478-
"type": "(token: PropertyFilterProps.FormattedToken) => string",
12479-
},
12480-
Object {
12481-
"name": "tokenEditorAddExistingTokenLabel",
12482-
"optional": true,
12483-
"type": "(token: PropertyFilterProps.FormattedToken) => string",
12484-
},
12485-
Object {
12486-
"name": "tokenEditorAddNewTokenLabel",
12487-
"optional": true,
12488-
"type": "string",
12489-
},
12490-
Object {
12491-
"name": "tokenEditorAddTokenActionsAriaLabel",
12492-
"optional": true,
12493-
"type": "string",
12494-
},
12495-
Object {
12496-
"name": "tokenEditorTokenActionsAriaLabel",
12497-
"optional": true,
12498-
"type": "(token: PropertyFilterProps.FormattedToken) => string",
12499-
},
12500-
Object {
12501-
"name": "tokenEditorTokenRemoveAriaLabel",
12502-
"optional": true,
12503-
"type": "(token: PropertyFilterProps.FormattedToken) => string",
12504-
},
12505-
Object {
12506-
"name": "tokenEditorTokenRemoveFromGroupLabel",
12507-
"optional": true,
12508-
"type": "string",
12509-
},
12510-
Object {
12511-
"name": "tokenEditorTokenRemoveLabel",
12512-
"optional": true,
12513-
"type": "string",
12514-
},
1251512464
Object {
1251612465
"name": "tokenLimitShowFewer",
1251712466
"optional": true,

src/property-filter/__tests__/common.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@
44
import React, { useState } from 'react';
55

66
import PropertyFilter from '../../../lib/components/property-filter';
7-
import { FilteringProperty, I18nStrings, InternalFilteringProperty, PropertyFilterProps, Token } from '../interfaces';
7+
import {
8+
FilteringProperty,
9+
I18nStrings,
10+
I18nStringsTokenGroups,
11+
InternalFilteringProperty,
12+
PropertyFilterProps,
13+
Token,
14+
} from '../interfaces';
815

916
export const i18nStrings: I18nStrings = {
1017
dismissAriaLabel: 'Dismiss',
@@ -40,13 +47,16 @@ export const i18nStrings: I18nStrings = {
4047
enteredTextLabel: (text: string) => `Use: "${text}"`,
4148

4249
formatToken: token => `${token.propertyLabel} ${formatOperator(token.operator)} ${token.value}`,
50+
removeTokenButtonAriaLabel: (token: Token) =>
51+
'Remove token ' + token.propertyKey + ' ' + formatOperator(token.operator) + ' ' + token.value,
52+
};
53+
54+
export const i18nStringsTokenGroups: I18nStringsTokenGroups = {
4355
groupEditAriaLabel: group =>
4456
'Edit filter, ' +
4557
group.tokens
4658
.map(token => `${token.propertyLabel} ${formatOperator(token.operator)} ${token.value}`)
4759
.join(` ${group.operationLabel} `),
48-
removeTokenButtonAriaLabel: (token: Token) =>
49-
'Remove token ' + token.propertyKey + ' ' + formatOperator(token.operator) + ' ' + token.value,
5060
tokenEditorTokenActionsAriaLabel: token =>
5161
`Remove actions, ${token.propertyLabel} ${formatOperator(token.operator)} ${token.value}`,
5262
tokenEditorTokenRemoveAriaLabel: token =>

src/property-filter/__tests__/property-filter-token-editor.test.tsx

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,11 @@ import { act, fireEvent, render } from '@testing-library/react';
66

77
import TestI18nProvider from '../../../lib/components/i18n/testing';
88
import { useMobile } from '../../../lib/components/internal/hooks/use-mobile';
9-
import PropertyFilter from '../../../lib/components/property-filter';
10-
import {
11-
FilteringOption,
12-
FilteringProperty,
13-
PropertyFilterProps,
14-
Ref,
15-
} from '../../../lib/components/property-filter/interfaces';
9+
import { FilteringOption, FilteringProperty, Ref } from '../../../lib/components/property-filter/interfaces';
10+
import PropertyFilterInternal, { PropertyFilterInternalProps } from '../../../lib/components/property-filter/internal';
1611
import createWrapper from '../../../lib/components/test-utils/dom';
17-
import { createDefaultProps, i18nStrings, providedI18nStrings } from './common';
12+
import { PropertyFilterWrapperInternal } from '../../../lib/components/test-utils/dom/property-filter';
13+
import { createDefaultProps, i18nStrings, i18nStringsTokenGroups, providedI18nStrings } from './common';
1814

1915
jest.mock('../../../lib/components/internal/hooks/use-mobile', () => ({
2016
...jest.requireActual('../../../lib/components/internal/hooks/use-mobile'),
@@ -69,20 +65,29 @@ const filteringOptions: readonly FilteringOption[] = [
6965
{ propertyKey: 'default-operator', value: 'value' },
7066
];
7167

72-
const defaultProps = createDefaultProps(filteringProperties, filteringOptions);
73-
74-
function renderComponent(props?: Partial<PropertyFilterProps & { ref: React.Ref<Ref> }>, withI18nProvider = false) {
68+
const defaultProps = {
69+
filteringOptions: [],
70+
customGroupsText: [],
71+
disableFreeTextFiltering: false,
72+
i18nStringsTokenGroups,
73+
...createDefaultProps(filteringProperties, filteringOptions),
74+
};
75+
76+
function renderComponent(
77+
props?: Partial<PropertyFilterInternalProps & { ref: React.Ref<Ref> }>,
78+
withI18nProvider = false
79+
) {
7580
return withI18nProvider
7681
? render(
7782
<TestI18nProvider messages={providedI18nStrings}>
78-
<PropertyFilter {...defaultProps} {...props} />
83+
<PropertyFilterInternal {...defaultProps} {...props} />
7984
</TestI18nProvider>
8085
)
81-
: render(<PropertyFilter {...defaultProps} {...props} />);
86+
: render(<PropertyFilterInternal {...defaultProps} {...props} />);
8287
}
8388

8489
function openEditor(tokenIndex: number, options: { expandToViewport?: boolean; isMobile?: boolean }) {
85-
const propertyFilter = createWrapper().findPropertyFilter()!;
90+
const propertyFilter = new PropertyFilterWrapperInternal(createWrapper().findPropertyFilter()!.getElement());
8691
const token = propertyFilter.findTokens()[tokenIndex];
8792
if (token.findEditButton()) {
8893
token.findEditButton()!.click();
@@ -96,7 +101,7 @@ function findEditor(
96101
tokenIndex: number,
97102
{ expandToViewport = false, isMobile = false }: { expandToViewport?: boolean; isMobile?: boolean }
98103
) {
99-
const propertyFilter = createWrapper().findPropertyFilter()!;
104+
const propertyFilter = new PropertyFilterWrapperInternal(createWrapper().findPropertyFilter()!.getElement());
100105
const editor = propertyFilter.findTokens()[tokenIndex].findEditorDropdown({ expandToViewport })!;
101106
return editor
102107
? {
@@ -467,7 +472,7 @@ describe('token editor with groups', () => {
467472
jest.mocked(useMobile).mockReturnValue(false);
468473
});
469474

470-
function render(props: Partial<PropertyFilterProps>) {
475+
function render(props: Partial<PropertyFilterInternalProps>) {
471476
return renderComponent({ enableTokenGroups: true, ...props });
472477
}
473478

src/property-filter/__tests__/property-filter-token-list.test.tsx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ import { act, render } from '@testing-library/react';
66

77
import PropertyFilter from '../../../lib/components/property-filter';
88
import { PropertyFilterProps, Ref } from '../../../lib/components/property-filter/interfaces';
9+
import PropertyFilterInternal, { PropertyFilterInternalProps } from '../../../lib/components/property-filter/internal';
910
import createWrapper, { PropertyFilterWrapper } from '../../../lib/components/test-utils/dom';
10-
import { createDefaultProps, i18nStrings, StatefulPropertyFilter } from './common';
11+
import { PropertyFilterWrapperInternal } from '../../../lib/components/test-utils/dom/property-filter';
12+
import { createDefaultProps, i18nStrings, i18nStringsTokenGroups, StatefulPropertyFilter } from './common';
1113

1214
const defaultProps = createDefaultProps(
1315
[
@@ -301,13 +303,23 @@ describe('grouped token', () => {
301303
const tokenJane = { propertyKey: 'string', operator: '=', value: 'Jane' };
302304
const tokenJack = { propertyKey: 'string', operator: '=', value: 'Jack' };
303305

304-
function render(props: Partial<PropertyFilterProps>) {
305-
const { propertyFilterWrapper: wrapper } = renderComponent({ ...props, enableTokenGroups: true });
306-
return wrapper;
306+
function renderInternalComponent(props: Partial<PropertyFilterInternalProps>) {
307+
const { container } = render(
308+
<PropertyFilterInternal
309+
{...defaultProps}
310+
enableTokenGroups={true}
311+
i18nStringsTokenGroups={i18nStringsTokenGroups}
312+
filteringOptions={[]}
313+
customGroupsText={[]}
314+
disableFreeTextFiltering={false}
315+
{...props}
316+
/>
317+
);
318+
return new PropertyFilterWrapperInternal(container);
307319
}
308320

309321
test('token group has correct ARIA label and edit button ARIA label', () => {
310-
const wrapper = render({
322+
const wrapper = renderInternalComponent({
311323
query: { operation: 'and', tokenGroups: [{ operation: 'or', tokens: [tokenJohn, tokenJane] }], tokens: [] },
312324
});
313325

@@ -319,7 +331,7 @@ describe('grouped token', () => {
319331

320332
test('changes group operation', () => {
321333
const onChange = jest.fn();
322-
const wrapper = render({
334+
const wrapper = renderInternalComponent({
323335
query: { operation: 'and', tokenGroups: [{ operation: 'and', tokens: [tokenJohn, tokenJane] }], tokens: [] },
324336
onChange,
325337
});
@@ -341,7 +353,7 @@ describe('grouped token', () => {
341353

342354
test('removes token from group', () => {
343355
const onChange = jest.fn();
344-
const wrapper = render({
356+
const wrapper = renderInternalComponent({
345357
query: {
346358
operation: 'and',
347359
tokenGroups: [{ operation: 'and', tokens: [tokenJohn, tokenJane, tokenJack] }],

src/property-filter/filtering-token/__tests__/filtering-token.test.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import React from 'react';
55
import { render } from '@testing-library/react';
66

77
import FilteringToken, { FilteringTokenProps } from '../../../../lib/components/property-filter/filtering-token';
8-
import { FilteringTokenWrapper } from '../../../../lib/components/test-utils/dom/property-filter';
8+
import { FilteringTokenWrapperInternal } from '../../../../lib/components/test-utils/dom/property-filter';
99

1010
const token1 = {
1111
content: 'property1 = value',
@@ -46,9 +46,11 @@ const defaultProps: FilteringTokenProps = {
4646
popoverSize: 'content',
4747
};
4848

49-
function renderToken(props: Partial<FilteringTokenProps>): FilteringTokenWrapper {
49+
function renderToken(props: Partial<FilteringTokenProps>): FilteringTokenWrapperInternal {
5050
const { container } = render(<FilteringToken {...defaultProps} {...props} />);
51-
return new FilteringTokenWrapper(container.querySelector<HTMLElement>(`.${FilteringTokenWrapper.rootSelector}`)!);
51+
return new FilteringTokenWrapperInternal(
52+
container.querySelector<HTMLElement>(`.${FilteringTokenWrapperInternal.rootSelector}`)!
53+
);
5254
}
5355

5456
test('renders a single token as role="group" with token ARIA label and dismiss button', () => {

src/property-filter/i18n-utils.ts

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
import { useInternalI18n } from '../i18n/context';
5-
import { ComparisonOperator, FormattedToken, I18nStrings, InternalToken, InternalTokenGroup } from './interfaces';
5+
import {
6+
ComparisonOperator,
7+
FormattedToken,
8+
I18nStrings,
9+
I18nStringsTokenGroups,
10+
InternalToken,
11+
InternalTokenGroup,
12+
} from './interfaces';
613
import { tokenGroupToTokens } from './utils';
714

815
export type I18nStringsOperators = Pick<
@@ -20,32 +27,31 @@ export type I18nStringsOperators = Pick<
2027
>;
2128

2229
// Replacing i18n function with ones taking internal tokens as argument.
23-
export type I18nStringsInternal = Omit<
24-
I18nStrings,
25-
| 'formatToken'
26-
| 'removeTokenButtonAriaLabel'
27-
| 'groupEditAriaLabel'
28-
| 'tokenEditorTokenActionsAriaLabel'
29-
| 'tokenEditorTokenRemoveAriaLabel'
30-
| 'tokenEditorAddExistingTokenAriaLabel'
31-
| 'tokenEditorAddExistingTokenLabel'
32-
> & {
33-
formatToken: (token: InternalToken) => {
34-
propertyLabel: string;
35-
operator: string;
36-
value: string;
37-
formattedText: string;
30+
export type I18nStringsInternal = Omit<I18nStrings, 'formatToken' | 'removeTokenButtonAriaLabel'> &
31+
Omit<
32+
I18nStringsTokenGroups,
33+
| 'groupEditAriaLabel'
34+
| 'tokenEditorTokenActionsAriaLabel'
35+
| 'tokenEditorTokenRemoveAriaLabel'
36+
| 'tokenEditorAddExistingTokenAriaLabel'
37+
| 'tokenEditorAddExistingTokenLabel'
38+
> & {
39+
formatToken: (token: InternalToken) => {
40+
propertyLabel: string;
41+
operator: string;
42+
value: string;
43+
formattedText: string;
44+
};
45+
groupAriaLabel: (group: InternalTokenGroup) => string;
46+
groupEditAriaLabel: (group: InternalTokenGroup) => string;
47+
removeTokenButtonAriaLabel: (token: InternalToken) => string;
48+
tokenEditorTokenActionsAriaLabel: (token: InternalToken) => string;
49+
tokenEditorTokenRemoveAriaLabel: (token: InternalToken) => string;
50+
tokenEditorAddExistingTokenAriaLabel: (token: InternalToken) => string;
51+
tokenEditorAddExistingTokenLabel: (token: InternalToken) => string;
3852
};
39-
groupAriaLabel: (group: InternalTokenGroup) => string;
40-
groupEditAriaLabel: (group: InternalTokenGroup) => string;
41-
removeTokenButtonAriaLabel: (token: InternalToken) => string;
42-
tokenEditorTokenActionsAriaLabel: (token: InternalToken) => string;
43-
tokenEditorTokenRemoveAriaLabel: (token: InternalToken) => string;
44-
tokenEditorAddExistingTokenAriaLabel: (token: InternalToken) => string;
45-
tokenEditorAddExistingTokenLabel: (token: InternalToken) => string;
46-
};
4753

48-
export function usePropertyFilterI18n(def: I18nStrings = {}): I18nStringsInternal {
54+
export function usePropertyFilterI18n(def: I18nStrings & I18nStringsTokenGroups = {}): I18nStringsInternal {
4955
const i18n = useInternalI18n('property-filter');
5056

5157
const allPropertiesLabel = i18n('i18nStrings.allPropertiesLabel', def?.allPropertiesLabel);

0 commit comments

Comments
 (0)