diff --git a/README.md b/README.md index 2423184f65..6811d2b364 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Here is a basic example that renders a primary button: import Button from '@cloudscape-design/components/button'; import '@cloudscape-design/global-styles/index.css'; -function App { +function App() { return ; } ``` diff --git a/build-tools/tasks/generate-i18n-messages.js b/build-tools/tasks/generate-i18n-messages.js index f502a76fd5..9c8e7d7b82 100644 --- a/build-tools/tasks/generate-i18n-messages.js +++ b/build-tools/tasks/generate-i18n-messages.js @@ -11,7 +11,6 @@ const { writeFile } = require('../utils/files'); const namespace = '@cloudscape-design/components'; const destinationDir = path.join(targetPath, 'components/i18n/messages'); -const internalDestinationDir = path.join(targetPath, 'components/internal/i18n/messages'); const declarationFile = `import { I18nProviderProps } from "../provider"; declare const messages: I18nProviderProps.Messages; export default messages; @@ -36,21 +35,16 @@ module.exports = function generateI18nMessages() { ); allParsedMessages[locale] = { ...(allParsedMessages[locale] ?? {}), ...parsedMessages }; const resultFormat = { [namespace]: { [locale]: parsedMessages } }; - - for (const directory of [destinationDir, internalDestinationDir]) { - writeFile(path.join(directory, `${subset}.${locale}.json`), JSON.stringify(resultFormat)); - writeFile(path.join(directory, `${subset}.${locale}.d.ts`), declarationFile); - writeFile(path.join(directory, `${subset}.${locale}.js`), `export default ${JSON.stringify(resultFormat)}`); - } + writeFile(path.join(destinationDir, `${subset}.${locale}.json`), JSON.stringify(resultFormat)); + writeFile(path.join(destinationDir, `${subset}.${locale}.d.ts`), declarationFile); + writeFile(path.join(destinationDir, `${subset}.${locale}.js`), `export default ${JSON.stringify(resultFormat)}`); } // Generate a ".all" file containing all locales. const resultFormat = { [namespace]: allParsedMessages }; - for (const directory of [destinationDir, internalDestinationDir]) { - writeFile(path.join(directory, `all.all.json`), JSON.stringify(resultFormat)); - writeFile(path.join(directory, `all.all.d.ts`), declarationFile); - writeFile(path.join(directory, `all.all.js`), `export default ${JSON.stringify(resultFormat)}`); - } + writeFile(path.join(destinationDir, `all.all.json`), JSON.stringify(resultFormat)); + writeFile(path.join(destinationDir, `all.all.d.ts`), declarationFile); + writeFile(path.join(destinationDir, `all.all.js`), `export default ${JSON.stringify(resultFormat)}`); return Promise.resolve(); }; diff --git a/build-tools/tasks/package-json.js b/build-tools/tasks/package-json.js index dd5acb92bd..76fa174b48 100644 --- a/build-tools/tasks/package-json.js +++ b/build-tools/tasks/package-json.js @@ -47,16 +47,6 @@ function getComponentsExports() { result[`./i18n/messages/${subset}.${locale}.json`] = `./i18n/messages/${subset}.${locale}.json`; } - // i18n beta specific imports (delete after people switch over) - result['./internal/i18n'] = './internal/i18n/index.js'; - result[`./internal/i18n/messages/all.all`] = `./internal/i18n/messages/all.all.js`; - result[`./internal/i18n/messages/all.all.json`] = `./internal/i18n/messages/all.all.json`; - for (const translationFile of fs.readdirSync('src/i18n/messages')) { - const [subset, locale] = translationFile.split('.'); - result[`./internal/i18n/messages/${subset}.${locale}`] = `./internal/i18n/messages/${subset}.${locale}.js`; - result[`./internal/i18n/messages/${subset}.${locale}.json`] = `./internal/i18n/messages/${subset}.${locale}.json`; - } - return result; } diff --git a/package-lock.json b/package-lock.json index 8731d611ab..dbf73401f1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -749,122 +749,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@cloudscape-design/browser-test-tools": { - "version": "3.0.30", - "resolved": "https://registry.npmjs.org/@cloudscape-design/browser-test-tools/-/browser-test-tools-3.0.30.tgz", - "integrity": "sha512-JoW7rlwJCVBIVUJ5IVR/rCqV2DLE4wrxn8vAF5DUN6U7KC0k8WsmtS28oo0lqftfdUYPSz3U97Bb+3NmPQIC9Q==", - "dev": true, - "dependencies": { - "@types/pngjs": "^6.0.1", - "aws-sdk": "^2.1354.0", - "get-stream": "^6.0.1", - "lodash": "^4.17.21", - "p-retry": "^4.6.2", - "pixelmatch": "^5.3.0", - "pngjs": "^6.0.0", - "webdriverio": "^7.25.2" - } - }, - "node_modules/@cloudscape-design/collection-hooks": { - "version": "1.0.22", - "resolved": "https://registry.npmjs.org/@cloudscape-design/collection-hooks/-/collection-hooks-1.0.22.tgz", - "integrity": "sha512-U5n438CmBuh+FdpREHYlViX/qCU7WcChBJ2gDAeWllNYEtb4/jwtQ2SITuipAZ9QONahkBCQX9JQNKzDfPnPEA==", - "peerDependencies": { - "react": "^16.8.0 || ^17.0.0 || ^18.0.0" - } - }, - "node_modules/@cloudscape-design/component-toolkit": { - "version": "1.0.0-beta.19", - "resolved": "https://registry.npmjs.org/@cloudscape-design/component-toolkit/-/component-toolkit-1.0.0-beta.19.tgz", - "integrity": "sha512-uk53JrX70DBP1xytDENeu6oxZhpBYJqz8dUGG9ku+MCRhOJFuVC2Uadn2BQvFh3TBTXE4Xj98I669pZOa6C5sA==", - "dependencies": { - "@juggle/resize-observer": "^3.3.1", - "tslib": "^2.3.1" - } - }, - "node_modules/@cloudscape-design/documenter": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@cloudscape-design/documenter/-/documenter-1.0.11.tgz", - "integrity": "sha512-DtezRxmwq5vxd74pPHmKvZ6dTHnQRl6ZFRcCAkzzhHZKnvQlU0mEO5As1ZymggJ69OMcoLB+iczvUpnSYsa7tQ==", - "dev": true, - "dependencies": { - "change-case": "^4.1.1", - "micromatch": "^4.0.2", - "typedoc": "~0.19.2" - } - }, - "node_modules/@cloudscape-design/eslint-plugin": { - "resolved": "build-tools/eslint", - "link": true - }, - "node_modules/@cloudscape-design/global-styles": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@cloudscape-design/global-styles/-/global-styles-1.0.11.tgz", - "integrity": "sha512-pHGImwi5K+Dk/FUQHTvoVeEowWZAoRfTMzIEz2eri5fbK4U/Xp7UuhEqoWhNoLDtcw87/o2qHTP0We95mhVOqg==", - "dev": true - }, - "node_modules/@cloudscape-design/jest-preset": { - "version": "2.0.16", - "resolved": "https://registry.npmjs.org/@cloudscape-design/jest-preset/-/jest-preset-2.0.16.tgz", - "integrity": "sha512-Caf52TPSL/flvS8q/o0BQnzRoWEUb6iaKvzU1SKdVn1OD9gVnJD5mC6HK/RPhFIjkxzh7V+Ce/pAZavvYmux5w==", - "dev": true, - "dependencies": { - "@babel/plugin-transform-modules-commonjs": "^7.9.0" - }, - "peerDependencies": { - "babel-jest": ">=24", - "jest": ">=24" - } - }, - "node_modules/@cloudscape-design/test-utils-converter": { - "version": "1.0.12", - "resolved": "https://registry.npmjs.org/@cloudscape-design/test-utils-converter/-/test-utils-converter-1.0.12.tgz", - "integrity": "sha512-nh9iHPP3THidg4lIw0yZTA2PGxNKzjvBbmDr2oHXa6nXZ5VokdSgkIUi1HZRwNWuSyyjuZyMg5YgNVYqEWPgQQ==", - "dev": true, - "dependencies": { - "@babel/core": "^7.16.0", - "@babel/plugin-syntax-decorators": "^7.16.0", - "@babel/plugin-syntax-typescript": "^7.16.0" - } - }, - "node_modules/@cloudscape-design/test-utils-core": { - "version": "1.0.12", - "resolved": "https://registry.npmjs.org/@cloudscape-design/test-utils-core/-/test-utils-core-1.0.12.tgz", - "integrity": "sha512-dSyFtq73nZM8AQeanBJhZazZSufRsGzYe144qAr8yGWpDZzxSkj8YgyjJccHVE0avGwj+aunL6SMlUkILaZw0Q==", - "dependencies": { - "css-selector-tokenizer": "^0.8.0", - "css.escape": "^1.5.1" - } - }, - "node_modules/@cloudscape-design/theming-build": { - "version": "1.0.36", - "resolved": "https://registry.npmjs.org/@cloudscape-design/theming-build/-/theming-build-1.0.36.tgz", - "integrity": "sha512-PwaiX9xqpnrTrFEBpVfwgRg2ydiOhzvBGB8XkZFXhqaDEqKr+hdT7r7iCfMET7UZoXjme/zntK9cMyAydPWVFA==", - "dev": true, - "dependencies": { - "autoprefixer": "^10.4.8", - "glob": "^7.2.3", - "jsonschema": "^1.4.1", - "loader-utils": "^3.2.1", - "lodash": "^4.17.21", - "postcss": "^8.4.16", - "postcss-discard-empty": "^5.1.1", - "postcss-initial": "^3.0.4", - "postcss-inline-svg": "^5.0.0", - "postcss-modules": "^4.3.1", - "sass": "^1.49.0", - "string-hash": "^1.1.3", - "tslib": "^2.4.0" - } - }, - "node_modules/@cloudscape-design/theming-runtime": { - "version": "1.0.29", - "resolved": "https://registry.npmjs.org/@cloudscape-design/theming-runtime/-/theming-runtime-1.0.29.tgz", - "integrity": "sha512-UC49ObLxLmmsADpuAZN8UkelVyiIQgCLY+1rpMkLoWIXBhhz+vwxBzfKLLFv2pC4zuEI16/1VwO6IYWtOzMK3A==", - "dependencies": { - "tslib": "^2.4.0" - } - }, "node_modules/@csstools/css-parser-algorithms": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/@csstools/css-parser-algorithms/-/css-parser-algorithms-2.3.0.tgz", @@ -19565,118 +19449,6 @@ "version": "0.2.3", "dev": true }, - "@cloudscape-design/browser-test-tools": { - "version": "3.0.30", - "resolved": "https://registry.npmjs.org/@cloudscape-design/browser-test-tools/-/browser-test-tools-3.0.30.tgz", - "integrity": "sha512-JoW7rlwJCVBIVUJ5IVR/rCqV2DLE4wrxn8vAF5DUN6U7KC0k8WsmtS28oo0lqftfdUYPSz3U97Bb+3NmPQIC9Q==", - "dev": true, - "requires": { - "@types/pngjs": "^6.0.1", - "aws-sdk": "^2.1354.0", - "get-stream": "^6.0.1", - "lodash": "^4.17.21", - "p-retry": "^4.6.2", - "pixelmatch": "^5.3.0", - "pngjs": "^6.0.0", - "webdriverio": "^7.25.2" - } - }, - "@cloudscape-design/collection-hooks": { - "version": "1.0.22", - "resolved": "https://registry.npmjs.org/@cloudscape-design/collection-hooks/-/collection-hooks-1.0.22.tgz", - "integrity": "sha512-U5n438CmBuh+FdpREHYlViX/qCU7WcChBJ2gDAeWllNYEtb4/jwtQ2SITuipAZ9QONahkBCQX9JQNKzDfPnPEA==", - "requires": {} - }, - "@cloudscape-design/component-toolkit": { - "version": "1.0.0-beta.19", - "resolved": "https://registry.npmjs.org/@cloudscape-design/component-toolkit/-/component-toolkit-1.0.0-beta.19.tgz", - "integrity": "sha512-uk53JrX70DBP1xytDENeu6oxZhpBYJqz8dUGG9ku+MCRhOJFuVC2Uadn2BQvFh3TBTXE4Xj98I669pZOa6C5sA==", - "requires": { - "@juggle/resize-observer": "^3.3.1", - "tslib": "^2.3.1" - } - }, - "@cloudscape-design/documenter": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@cloudscape-design/documenter/-/documenter-1.0.11.tgz", - "integrity": "sha512-DtezRxmwq5vxd74pPHmKvZ6dTHnQRl6ZFRcCAkzzhHZKnvQlU0mEO5As1ZymggJ69OMcoLB+iczvUpnSYsa7tQ==", - "dev": true, - "requires": { - "change-case": "^4.1.1", - "micromatch": "^4.0.2", - "typedoc": "~0.19.2" - } - }, - "@cloudscape-design/eslint-plugin": { - "version": "file:build-tools/eslint", - "requires": { - "micromatch": "^4.0.4" - } - }, - "@cloudscape-design/global-styles": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@cloudscape-design/global-styles/-/global-styles-1.0.11.tgz", - "integrity": "sha512-pHGImwi5K+Dk/FUQHTvoVeEowWZAoRfTMzIEz2eri5fbK4U/Xp7UuhEqoWhNoLDtcw87/o2qHTP0We95mhVOqg==", - "dev": true - }, - "@cloudscape-design/jest-preset": { - "version": "2.0.16", - "resolved": "https://registry.npmjs.org/@cloudscape-design/jest-preset/-/jest-preset-2.0.16.tgz", - "integrity": "sha512-Caf52TPSL/flvS8q/o0BQnzRoWEUb6iaKvzU1SKdVn1OD9gVnJD5mC6HK/RPhFIjkxzh7V+Ce/pAZavvYmux5w==", - "dev": true, - "requires": { - "@babel/plugin-transform-modules-commonjs": "^7.9.0" - } - }, - "@cloudscape-design/test-utils-converter": { - "version": "1.0.12", - "resolved": "https://registry.npmjs.org/@cloudscape-design/test-utils-converter/-/test-utils-converter-1.0.12.tgz", - "integrity": "sha512-nh9iHPP3THidg4lIw0yZTA2PGxNKzjvBbmDr2oHXa6nXZ5VokdSgkIUi1HZRwNWuSyyjuZyMg5YgNVYqEWPgQQ==", - "dev": true, - "requires": { - "@babel/core": "^7.16.0", - "@babel/plugin-syntax-decorators": "^7.16.0", - "@babel/plugin-syntax-typescript": "^7.16.0" - } - }, - "@cloudscape-design/test-utils-core": { - "version": "1.0.12", - "resolved": "https://registry.npmjs.org/@cloudscape-design/test-utils-core/-/test-utils-core-1.0.12.tgz", - "integrity": "sha512-dSyFtq73nZM8AQeanBJhZazZSufRsGzYe144qAr8yGWpDZzxSkj8YgyjJccHVE0avGwj+aunL6SMlUkILaZw0Q==", - "requires": { - "css-selector-tokenizer": "^0.8.0", - "css.escape": "^1.5.1" - } - }, - "@cloudscape-design/theming-build": { - "version": "1.0.36", - "resolved": "https://registry.npmjs.org/@cloudscape-design/theming-build/-/theming-build-1.0.36.tgz", - "integrity": "sha512-PwaiX9xqpnrTrFEBpVfwgRg2ydiOhzvBGB8XkZFXhqaDEqKr+hdT7r7iCfMET7UZoXjme/zntK9cMyAydPWVFA==", - "dev": true, - "requires": { - "autoprefixer": "^10.4.8", - "glob": "^7.2.3", - "jsonschema": "^1.4.1", - "loader-utils": "^3.2.1", - "lodash": "^4.17.21", - "postcss": "^8.4.16", - "postcss-discard-empty": "^5.1.1", - "postcss-initial": "^3.0.4", - "postcss-inline-svg": "^5.0.0", - "postcss-modules": "^4.3.1", - "sass": "^1.49.0", - "string-hash": "^1.1.3", - "tslib": "^2.4.0" - } - }, - "@cloudscape-design/theming-runtime": { - "version": "1.0.29", - "resolved": "https://registry.npmjs.org/@cloudscape-design/theming-runtime/-/theming-runtime-1.0.29.tgz", - "integrity": "sha512-UC49ObLxLmmsADpuAZN8UkelVyiIQgCLY+1rpMkLoWIXBhhz+vwxBzfKLLFv2pC4zuEI16/1VwO6IYWtOzMK3A==", - "requires": { - "tslib": "^2.4.0" - } - }, "@csstools/css-parser-algorithms": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/@csstools/css-parser-algorithms/-/css-parser-algorithms-2.3.0.tgz", diff --git a/pages/alert/simple.page.tsx b/pages/alert/simple.page.tsx index b5a609b4b9..375f93fb6e 100644 --- a/pages/alert/simple.page.tsx +++ b/pages/alert/simple.page.tsx @@ -7,7 +7,7 @@ import ScreenshotArea from '../utils/screenshot-area'; import SpaceBetween from '~components/space-between'; import styles from './styles.scss'; -import { I18nProvider } from '~components/internal/i18n'; +import { I18nProvider } from '~components/i18n'; import messages from '~components/i18n/messages/all.all'; export default function AlertScenario() { diff --git a/pages/funnel-analytics/with-error-alert-in-wizard.page.tsx b/pages/funnel-analytics/with-error-alert-in-wizard.page.tsx index 07e49c5fb3..35fee9be7b 100644 --- a/pages/funnel-analytics/with-error-alert-in-wizard.page.tsx +++ b/pages/funnel-analytics/with-error-alert-in-wizard.page.tsx @@ -7,6 +7,7 @@ import { i18nStrings } from '../wizard/common'; import Alert from '~components/alert'; import Container from '~components/container'; import Header from '~components/header'; +import Link from '~components/link'; export default function WizardPage() { const [errorMode, setErrorMode] = useState(0); @@ -14,6 +15,7 @@ export default function WizardPage() { const steps: WizardProps.Step[] = [ { title: 'Step 1', + info: Info, content: (
Content 1
diff --git a/pages/property-filter/hooks.page.tsx b/pages/property-filter/hooks.page.tsx index 3e967896ba..fda30b68dd 100644 --- a/pages/property-filter/hooks.page.tsx +++ b/pages/property-filter/hooks.page.tsx @@ -11,7 +11,7 @@ import { allItems, TableItem } from './table.data'; import { columnDefinitions, i18nStrings, filteringProperties } from './common-props'; import { useCollection } from '@cloudscape-design/collection-hooks'; -import { I18nProvider } from '~components/internal/i18n'; +import { I18nProvider } from '~components/i18n'; import messages from '~components/i18n/messages/all.all'; export default function () { diff --git a/src/alert/internal.tsx b/src/alert/internal.tsx index 4033301117..7084da95ce 100644 --- a/src/alert/internal.tsx +++ b/src/alert/internal.tsx @@ -15,7 +15,7 @@ import { AlertProps } from './interfaces'; import { InternalBaseComponentProps } from '../internal/hooks/use-base-component'; import { useMergeRefs } from '../internal/hooks/use-merge-refs'; import { SomeRequired } from '../internal/types'; -import { useInternalI18n } from '../internal/i18n/context'; +import { useInternalI18n } from '../i18n/context'; import { DATA_ATTR_ANALYTICS_ALERT } from '../internal/analytics/selectors'; const typeToIcon: Record = { diff --git a/src/app-layout/index.tsx b/src/app-layout/index.tsx index 4b3f139503..d1dd6a7e6b 100644 --- a/src/app-layout/index.tsx +++ b/src/app-layout/index.tsx @@ -43,7 +43,7 @@ import { isDevelopment } from '../internal/is-development'; import { warnOnce } from '@cloudscape-design/component-toolkit/internal'; import RefreshedAppLayout from './visual-refresh'; -import { useInternalI18n } from '../internal/i18n/context'; +import { useInternalI18n } from '../i18n/context'; import { useSplitPanelFocusControl } from './utils/use-split-panel-focus-control'; import { useDrawerFocusControl } from './utils/use-drawer-focus-control'; import { awsuiPluginsInternal } from '../internal/plugins/api'; diff --git a/src/area-chart/__tests__/area-chart-initial-state.test.tsx b/src/area-chart/__tests__/area-chart-initial-state.test.tsx index abd0ce12a8..54e3cdde28 100644 --- a/src/area-chart/__tests__/area-chart-initial-state.test.tsx +++ b/src/area-chart/__tests__/area-chart-initial-state.test.tsx @@ -9,7 +9,7 @@ import popoverStyles from '../../../lib/components/popover/styles.css.js'; import chartWrapperStyles from '../../../lib/components/internal/components/chart-wrapper/styles.css.js'; import cartesianStyles from '../../../lib/components/internal/components/cartesian-chart/styles.css.js'; import { warnOnce } from '@cloudscape-design/component-toolkit/internal'; -import TestI18nProvider from '../../../lib/components/internal/i18n/testing'; +import TestI18nProvider from '../../../lib/components/i18n/testing'; import { cloneDeep } from 'lodash'; import '../../__a11y__/to-validate-a11y'; diff --git a/src/area-chart/chart-container.tsx b/src/area-chart/chart-container.tsx index 5a45dc7e2d..13b868d671 100644 --- a/src/area-chart/chart-container.tsx +++ b/src/area-chart/chart-container.tsx @@ -7,7 +7,7 @@ import ChartPlot from '../internal/components/chart-plot'; import AxisLabel from '../internal/components/cartesian-chart/axis-label'; import LabelsMeasure from '../internal/components/cartesian-chart/labels-measure'; import LeftLabels from '../internal/components/cartesian-chart/left-labels'; -import BottomLabels from '../internal/components/cartesian-chart/bottom-labels'; +import BottomLabels, { useBottomLabels } from '../internal/components/cartesian-chart/bottom-labels'; import EmphasizedBaseline from '../internal/components/cartesian-chart/emphasized-baseline'; import { AreaChartProps } from './interfaces'; import { ChartModel } from './model'; @@ -77,9 +77,14 @@ function ChartContainer({ detailTotalFormatter = deprecatedDetailTotalFormatter, }: ChartContainerProps) { const [leftLabelsWidth, setLeftLabelsWidth] = useState(0); - const [bottomLabelsHeight, setBottomLabelsHeight] = useState(0); const [containerWidth, containerWidthRef] = useContainerWidth(DEFAULT_CHART_WIDTH); + const bottomLabelsProps = useBottomLabels({ + ticks: model.computed.xTicks, + scale: model.computed.xScale, + tickFormatter: xTickFormatter as TickFormatter, + }); + // Calculate the width of the plot area and tell it to the parent. const plotWidth = Math.max(0, containerWidth - leftLabelsWidth - LEFT_LABELS_MARGIN); useEffect(() => { @@ -110,7 +115,7 @@ function ChartContainer({ return ( } leftAxisLabelMeasure={ @@ -126,8 +131,8 @@ function ChartContainer({ ({ diff --git a/src/area-chart/elements/use-highlight-details.ts b/src/area-chart/elements/use-highlight-details.ts index 33ec3a567f..6b6f33d955 100644 --- a/src/area-chart/elements/use-highlight-details.ts +++ b/src/area-chart/elements/use-highlight-details.ts @@ -3,7 +3,7 @@ import { useSelector } from '../async-store'; import { CartesianChartProps } from '../../internal/components/cartesian-chart/interfaces'; import { ChartSeriesDetailItem } from '../../internal/components/chart-series-details'; -import { useInternalI18n } from '../../internal/i18n/context'; +import { useInternalI18n } from '../../i18n/context'; import { AreaChartProps } from '../interfaces'; import { ChartModel } from '../model'; diff --git a/src/attribute-editor/__tests__/attribute-editor.test.tsx b/src/attribute-editor/__tests__/attribute-editor.test.tsx index 27cc2fe26f..789c01c0b1 100644 --- a/src/attribute-editor/__tests__/attribute-editor.test.tsx +++ b/src/attribute-editor/__tests__/attribute-editor.test.tsx @@ -7,7 +7,7 @@ import AttributeEditor, { AttributeEditorProps } from '../../../lib/components/a import styles from '../../../lib/components/attribute-editor/styles.css.js'; import liveRegionStyles from '../../../lib/components/internal/components/live-region/styles.css.js'; import Input from '../../../lib/components/input'; -import TestI18nProvider from '../../../lib/components/internal/i18n/testing'; +import TestI18nProvider from '../../../lib/components/i18n/testing'; interface Item { key: string; diff --git a/src/attribute-editor/row.tsx b/src/attribute-editor/row.tsx index eaf2f02af4..a5504e80c5 100644 --- a/src/attribute-editor/row.tsx +++ b/src/attribute-editor/row.tsx @@ -12,7 +12,7 @@ import InternalGrid from '../grid/internal'; import { InternalButton } from '../button/internal'; import clsx from 'clsx'; import { useUniqueId } from '../internal/hooks/use-unique-id'; -import { useInternalI18n } from '../internal/i18n/context'; +import { useInternalI18n } from '../i18n/context'; const Divider = () => ; diff --git a/src/autosuggest/autosuggest-option.tsx b/src/autosuggest/autosuggest-option.tsx index b578f23b72..4d5140a4d7 100644 --- a/src/autosuggest/autosuggest-option.tsx +++ b/src/autosuggest/autosuggest-option.tsx @@ -10,7 +10,7 @@ import { getTestOptionIndexes } from '../internal/components/options-list/utils/ import styles from './styles.css.js'; import { AutosuggestItem } from './interfaces'; import { HighlightType } from '../internal/components/options-list/utils/use-highlight-option'; -import { useInternalI18n } from '../internal/i18n/context'; +import { useInternalI18n } from '../i18n/context'; export interface AutosuggestOptionProps extends BaseComponentProps { nativeAttributes?: Record; diff --git a/src/autosuggest/internal.tsx b/src/autosuggest/internal.tsx index 9242ba6f8e..01322bcfc4 100644 --- a/src/autosuggest/internal.tsx +++ b/src/autosuggest/internal.tsx @@ -26,7 +26,7 @@ import { useAutosuggestLoadMore } from './load-more-controller'; import { OptionsLoadItemsDetail } from '../internal/components/dropdown/interfaces'; import AutosuggestInput, { AutosuggestInputRef } from '../internal/components/autosuggest-input'; import { useFormFieldContext } from '../contexts/form-field'; -import { useInternalI18n } from '../internal/i18n/context'; +import { useInternalI18n } from '../i18n/context'; import styles from './styles.css.js'; import { warnOnce } from '@cloudscape-design/component-toolkit/internal'; diff --git a/src/breadcrumb-group/__tests__/breadcrumb-group.test.tsx b/src/breadcrumb-group/__tests__/breadcrumb-group.test.tsx index c0d12451c7..27736b3804 100644 --- a/src/breadcrumb-group/__tests__/breadcrumb-group.test.tsx +++ b/src/breadcrumb-group/__tests__/breadcrumb-group.test.tsx @@ -4,7 +4,7 @@ import React from 'react'; import { render, act } from '@testing-library/react'; import styles from '../../../lib/components/breadcrumb-group/styles.css.js'; import itemStyles from '../../../lib/components/breadcrumb-group/item/styles.css.js'; -import TestI18nProvider from '../../../lib/components/internal/i18n/testing'; +import TestI18nProvider from '../../../lib/components/i18n/testing'; import BreadcrumbGroup, { BreadcrumbGroupProps } from '../../../lib/components/breadcrumb-group'; import createWrapper, { BreadcrumbGroupWrapper } from '../../../lib/components/test-utils/dom'; diff --git a/src/breadcrumb-group/internal.tsx b/src/breadcrumb-group/internal.tsx index ebcec37c33..a827d5117b 100644 --- a/src/breadcrumb-group/internal.tsx +++ b/src/breadcrumb-group/internal.tsx @@ -15,7 +15,7 @@ import { getBaseProps } from '../internal/base-component'; import { useMobile } from '../internal/hooks/use-mobile'; import { InternalBaseComponentProps } from '../internal/hooks/use-base-component'; import { checkSafeUrl } from '../internal/utils/check-safe-url'; -import { useInternalI18n } from '../internal/i18n/context'; +import { useInternalI18n } from '../i18n/context'; /** * Provided for backwards compatibility diff --git a/src/calendar/internal.tsx b/src/calendar/internal.tsx index 0f6a5a9504..50132373c3 100644 --- a/src/calendar/internal.tsx +++ b/src/calendar/internal.tsx @@ -17,7 +17,7 @@ import { InternalBaseComponentProps } from '../internal/hooks/use-base-component import { getBaseDate } from './utils/navigation'; import { useDateCache } from '../internal/hooks/use-date-cache/index.js'; import { useUniqueId } from '../internal/hooks/use-unique-id/index.js'; -import { useInternalI18n } from '../internal/i18n/context.js'; +import { useInternalI18n } from '../i18n/context.js'; export type DayIndex = 0 | 1 | 2 | 3 | 4 | 5 | 6; diff --git a/src/cards/__tests__/cards.test.tsx b/src/cards/__tests__/cards.test.tsx index 8d4746ae23..7aff0105b7 100644 --- a/src/cards/__tests__/cards.test.tsx +++ b/src/cards/__tests__/cards.test.tsx @@ -6,7 +6,7 @@ import Cards, { CardsProps } from '../../../lib/components/cards'; import { CardsWrapper, PaginationWrapper } from '../../../lib/components/test-utils/dom'; import { useMobile } from '../../../lib/components/internal/hooks/use-mobile'; import liveRegionStyles from '../../../lib/components/internal/components/live-region/styles.css.js'; -import TestI18nProvider from '../../../lib/components/internal/i18n/testing'; +import TestI18nProvider from '../../../lib/components/i18n/testing'; import styles from '../../../lib/components/cards/styles.css.js'; jest.mock('../../../lib/components/internal/hooks/use-mobile', () => ({ diff --git a/src/cards/index.tsx b/src/cards/index.tsx index 09720a0388..dc886e056e 100644 --- a/src/cards/index.tsx +++ b/src/cards/index.tsx @@ -22,7 +22,7 @@ import LiveRegion from '../internal/components/live-region'; import useMouseDownTarget from '../internal/hooks/use-mouse-down-target'; import { useMobile } from '../internal/hooks/use-mobile'; import { supportsStickyPosition } from '../internal/utils/dom'; -import { useInternalI18n } from '../internal/i18n/context'; +import { useInternalI18n } from '../i18n/context'; import { useContainerQuery } from '@cloudscape-design/component-toolkit'; import { AnalyticsFunnelSubStep } from '../internal/analytics/components/analytics-funnel'; diff --git a/src/code-editor/__tests__/code-editor.test.tsx b/src/code-editor/__tests__/code-editor.test.tsx index 22a158106c..2573bf4d3f 100644 --- a/src/code-editor/__tests__/code-editor.test.tsx +++ b/src/code-editor/__tests__/code-editor.test.tsx @@ -18,7 +18,7 @@ import { warnOnce } from '@cloudscape-design/component-toolkit/internal'; import liveRegionStyles from '../../../lib/components/internal/components/live-region/styles.css.js'; import { createWrapper } from '@cloudscape-design/test-utils-core/dom'; import '../../__a11y__/to-validate-a11y'; -import TestI18nProvider from '../../../lib/components/internal/i18n/testing'; +import TestI18nProvider from '../../../lib/components/i18n/testing'; jest.mock('@cloudscape-design/component-toolkit/internal', () => ({ ...jest.requireActual('@cloudscape-design/component-toolkit/internal'), diff --git a/src/code-editor/index.tsx b/src/code-editor/index.tsx index 11fc2301c7..5d84835b7c 100644 --- a/src/code-editor/index.tsx +++ b/src/code-editor/index.tsx @@ -31,7 +31,7 @@ import useBaseComponent from '../internal/hooks/use-base-component'; import useForwardFocus from '../internal/hooks/forward-focus'; import { applyDisplayName } from '../internal/utils/apply-display-name'; import { useCurrentMode } from '@cloudscape-design/component-toolkit/internal'; -import { useInternalI18n } from '../internal/i18n/context'; +import { useInternalI18n } from '../i18n/context'; import { StatusBar } from './status-bar'; import { useFormFieldContext } from '../internal/context/form-field-context'; import { useVisualRefresh } from '../internal/hooks/use-visual-mode'; diff --git a/src/code-editor/status-bar.tsx b/src/code-editor/status-bar.tsx index 198984587a..a6f3966194 100644 --- a/src/code-editor/status-bar.tsx +++ b/src/code-editor/status-bar.tsx @@ -7,7 +7,7 @@ import LiveRegion from '../internal/components/live-region/index'; import { TabButton } from './tab-button'; import { InternalButton } from '../button/internal'; import { CodeEditorProps } from './interfaces'; -import { useInternalI18n } from '../internal/i18n/context.js'; +import { useInternalI18n } from '../i18n/context.js'; import { useContainerQuery } from '@cloudscape-design/component-toolkit'; interface StatusBarProps { diff --git a/src/collection-preferences/__tests__/collection-preferences.test.tsx b/src/collection-preferences/__tests__/collection-preferences.test.tsx index 6d089ca9c7..3daaf40bca 100644 --- a/src/collection-preferences/__tests__/collection-preferences.test.tsx +++ b/src/collection-preferences/__tests__/collection-preferences.test.tsx @@ -13,7 +13,7 @@ import { stripedRowsPreference, contentDisplayPreference, } from './shared'; -import TestI18nProvider from '../../../lib/components/internal/i18n/testing'; +import TestI18nProvider from '../../../lib/components/i18n/testing'; const expectVisibleModal = (wrapper: CollectionPreferencesWrapper, visible = true) => { if (visible) { diff --git a/src/collection-preferences/content-display/index.tsx b/src/collection-preferences/content-display/index.tsx index 3b66f05039..55a6c12918 100644 --- a/src/collection-preferences/content-display/index.tsx +++ b/src/collection-preferences/content-display/index.tsx @@ -13,7 +13,7 @@ import useDragAndDropReorder from './use-drag-and-drop-reorder'; import useLiveAnnouncements from './use-live-announcements'; import Portal from '../../internal/components/portal'; import ContentDisplayOption from './content-display-option'; -import { useInternalI18n } from '../../internal/i18n/context'; +import { useInternalI18n } from '../../i18n/context'; const componentPrefix = 'content-display'; diff --git a/src/collection-preferences/index.tsx b/src/collection-preferences/index.tsx index 50adcb5ee2..1f6f0ed6c9 100644 --- a/src/collection-preferences/index.tsx +++ b/src/collection-preferences/index.tsx @@ -28,7 +28,7 @@ import { applyDisplayName } from '../internal/utils/apply-display-name'; import useBaseComponent from '../internal/hooks/use-base-component'; import ContentDisplayPreference from './content-display'; import { warnOnce } from '@cloudscape-design/component-toolkit/internal'; -import { useInternalI18n } from '../internal/i18n/context'; +import { useInternalI18n } from '../i18n/context'; export { CollectionPreferencesProps }; diff --git a/src/collection-preferences/utils.tsx b/src/collection-preferences/utils.tsx index 5df9a1425b..6c9abc1148 100644 --- a/src/collection-preferences/utils.tsx +++ b/src/collection-preferences/utils.tsx @@ -10,7 +10,7 @@ import InternalSpaceBetween from '../space-between/internal'; import { useContainerBreakpoints } from '../internal/hooks/container-queries'; import { CollectionPreferencesProps } from './interfaces'; import styles from './styles.css.js'; -import { useInternalI18n } from '../internal/i18n/context'; +import { useInternalI18n } from '../i18n/context'; export const copyPreferences = ({ pageSize, diff --git a/src/date-picker/index.tsx b/src/date-picker/index.tsx index 9f2ee6d5ff..98df59bc2c 100644 --- a/src/date-picker/index.tsx +++ b/src/date-picker/index.tsx @@ -26,7 +26,7 @@ import FocusLock from '../internal/components/focus-lock'; import { parseDate } from '../internal/utils/date-time'; import LiveRegion from '../internal/components/live-region'; import { useFormFieldContext } from '../contexts/form-field.js'; -import { useLocale } from '../internal/i18n/context.js'; +import { useLocale } from '../i18n/context.js'; export { DatePickerProps }; diff --git a/src/date-range-picker/__tests__/date-range-picker-absolute.test.tsx b/src/date-range-picker/__tests__/date-range-picker-absolute.test.tsx index 8735ac9b1c..f5c24eb20c 100644 --- a/src/date-range-picker/__tests__/date-range-picker-absolute.test.tsx +++ b/src/date-range-picker/__tests__/date-range-picker-absolute.test.tsx @@ -7,7 +7,7 @@ import DateRangePicker, { DateRangePickerProps } from '../../../lib/components/d import { i18nStrings } from './i18n-strings'; import { isValidRange } from './is-valid-range'; import '../../__a11y__/to-validate-a11y'; -import TestI18nProvider from '../../../lib/components/internal/i18n/testing'; +import TestI18nProvider from '../../../lib/components/i18n/testing'; const defaultProps: DateRangePickerProps = { locale: 'en-US', diff --git a/src/date-range-picker/__tests__/date-range-picker-relative.test.tsx b/src/date-range-picker/__tests__/date-range-picker-relative.test.tsx index a596f5c3c5..46e0877284 100644 --- a/src/date-range-picker/__tests__/date-range-picker-relative.test.tsx +++ b/src/date-range-picker/__tests__/date-range-picker-relative.test.tsx @@ -10,7 +10,7 @@ import { i18nStrings } from './i18n-strings'; import { changeMode } from './change-mode'; import { isValidRange } from './is-valid-range'; import '../../__a11y__/to-validate-a11y'; -import TestI18nProvider from '../../../lib/components/internal/i18n/testing'; +import TestI18nProvider from '../../../lib/components/i18n/testing'; const defaultProps: DateRangePickerProps = { locale: 'en-US', diff --git a/src/date-range-picker/__tests__/date-range-picker.test.tsx b/src/date-range-picker/__tests__/date-range-picker.test.tsx index 710859dd7f..43c21b7c50 100644 --- a/src/date-range-picker/__tests__/date-range-picker.test.tsx +++ b/src/date-range-picker/__tests__/date-range-picker.test.tsx @@ -12,7 +12,7 @@ import { isValidRange } from './is-valid-range'; import { changeMode } from './change-mode'; import { warnOnce } from '@cloudscape-design/component-toolkit/internal'; import styles from '../../../lib/components/date-range-picker/styles.css.js'; -import TestI18nProvider from '../../../lib/components/internal/i18n/testing'; +import TestI18nProvider from '../../../lib/components/i18n/testing'; jest.mock('@cloudscape-design/component-toolkit/internal', () => ({ ...jest.requireActual('@cloudscape-design/component-toolkit/internal'), diff --git a/src/date-range-picker/calendar/index.tsx b/src/date-range-picker/calendar/index.tsx index bb1d895e6c..e01b247fe4 100644 --- a/src/date-range-picker/calendar/index.tsx +++ b/src/date-range-picker/calendar/index.tsx @@ -20,7 +20,7 @@ import { getBaseDate } from '../../calendar/utils/navigation'; import { useMobile } from '../../internal/hooks/use-mobile/index.js'; import RangeInputs from './range-inputs.js'; import { findDateToFocus, findMonthToDisplay } from './utils'; -import { useInternalI18n } from '../../internal/i18n/context.js'; +import { useInternalI18n } from '../../i18n/context.js'; export interface DateRangePickerCalendarProps extends BaseComponentProps { value: DateRangePickerProps.PendingAbsoluteValue; diff --git a/src/date-range-picker/calendar/range-inputs.tsx b/src/date-range-picker/calendar/range-inputs.tsx index 724ceadf43..2fdd19c3e1 100644 --- a/src/date-range-picker/calendar/range-inputs.tsx +++ b/src/date-range-picker/calendar/range-inputs.tsx @@ -9,7 +9,7 @@ import InternalFormField from '../../form-field/internal'; import InternalDateInput from '../../date-input/internal'; import { TimeInputProps } from '../../time-input/interfaces'; import InternalTimeInput from '../../time-input/internal'; -import { useInternalI18n } from '../../internal/i18n/context.js'; +import { useInternalI18n } from '../../i18n/context.js'; type I18nStrings = Pick< RangeCalendarI18nStrings, diff --git a/src/date-range-picker/dropdown.tsx b/src/date-range-picker/dropdown.tsx index d3778e97fc..422092f245 100644 --- a/src/date-range-picker/dropdown.tsx +++ b/src/date-range-picker/dropdown.tsx @@ -17,7 +17,7 @@ import clsx from 'clsx'; import InternalAlert from '../alert/internal'; import LiveRegion from '../internal/components/live-region'; import { getDefaultMode, joinAbsoluteValue, splitAbsoluteValue } from './utils'; -import { useInternalI18n } from '../internal/i18n/context'; +import { useInternalI18n } from '../i18n/context'; export const VALID_RANGE: DateRangePickerProps.ValidRangeResult = { valid: true }; diff --git a/src/date-range-picker/index.tsx b/src/date-range-picker/index.tsx index a225e712c6..e4ef7426b6 100644 --- a/src/date-range-picker/index.tsx +++ b/src/date-range-picker/index.tsx @@ -28,7 +28,7 @@ import { usePrevious } from '../internal/hooks/use-previous/index.js'; import { useUniqueId } from '../internal/hooks/use-unique-id'; import { formatDateRange, isIsoDateOnly } from '../internal/utils/date-time'; import { formatValue } from './utils.js'; -import { useInternalI18n } from '../internal/i18n/context.js'; +import { useInternalI18n } from '../i18n/context.js'; export { DateRangePickerProps }; diff --git a/src/date-range-picker/mode-switcher.tsx b/src/date-range-picker/mode-switcher.tsx index 054ac9b540..6315b924fc 100644 --- a/src/date-range-picker/mode-switcher.tsx +++ b/src/date-range-picker/mode-switcher.tsx @@ -5,7 +5,7 @@ import { DateRangePickerProps } from './interfaces'; import InternalSegmentedControl from '../segmented-control/internal'; import styles from './styles.css.js'; -import { useInternalI18n } from '../internal/i18n/context'; +import { useInternalI18n } from '../i18n/context'; interface ModeSwitcherProps extends Pick { mode: 'absolute' | 'relative'; diff --git a/src/date-range-picker/relative-range/index.tsx b/src/date-range-picker/relative-range/index.tsx index 1da59dc037..d2d2882181 100644 --- a/src/date-range-picker/relative-range/index.tsx +++ b/src/date-range-picker/relative-range/index.tsx @@ -11,7 +11,7 @@ import InternalRadioGroup from '../../radio-group/internal'; import InternalSelect from '../../select/internal'; import InternalSpaceBetween from '../../space-between/internal'; import styles from './styles.css.js'; -import { useInternalI18n } from '../../internal/i18n/context'; +import { useInternalI18n } from '../../i18n/context'; export interface RelativeRangePickerProps { dateOnly: boolean; diff --git a/src/flashbar/collapsible-flashbar.tsx b/src/flashbar/collapsible-flashbar.tsx index e91cdc4364..80ecc3496d 100644 --- a/src/flashbar/collapsible-flashbar.tsx +++ b/src/flashbar/collapsible-flashbar.tsx @@ -20,7 +20,7 @@ import { useFlashbar } from './common'; import { throttle } from '../internal/utils/throttle'; import { scrollElementIntoView } from '../internal/utils/scrollable-containers'; import { findUpUntil } from '../internal/utils/dom'; -import { useInternalI18n } from '../internal/i18n/context'; +import { useInternalI18n } from '../i18n/context'; export { FlashbarProps }; diff --git a/src/flashbar/non-collapsible-flashbar.tsx b/src/flashbar/non-collapsible-flashbar.tsx index 16148b726a..094f00837e 100644 --- a/src/flashbar/non-collapsible-flashbar.tsx +++ b/src/flashbar/non-collapsible-flashbar.tsx @@ -11,7 +11,7 @@ import { getVisualContextClassname } from '../internal/components/visual-context import styles from './styles.css.js'; import { useFlashbar } from './common'; -import { useInternalI18n } from '../internal/i18n/context'; +import { useInternalI18n } from '../i18n/context'; export { FlashbarProps }; diff --git a/src/form-field/internal.tsx b/src/form-field/internal.tsx index 9c71db2b19..23dec3213c 100644 --- a/src/form-field/internal.tsx +++ b/src/form-field/internal.tsx @@ -15,7 +15,7 @@ import { getAriaDescribedBy, getGridDefinition, getSlotIds } from './util'; import styles from './styles.css.js'; import { InternalFormFieldProps } from './interfaces'; import { joinStrings } from '../internal/utils/strings'; -import { useInternalI18n } from '../internal/i18n/context'; +import { useInternalI18n } from '../i18n/context'; import { InfoLinkLabelContext } from '../internal/context/info-link-label-context'; import { FunnelMetrics } from '../internal/analytics'; diff --git a/src/form/internal.tsx b/src/form/internal.tsx index 6a3dd3cc01..196b652948 100644 --- a/src/form/internal.tsx +++ b/src/form/internal.tsx @@ -10,7 +10,7 @@ import styles from './styles.css.js'; import { FormLayoutProps, FormProps } from './interfaces'; import { InternalBaseComponentProps } from '../internal/hooks/use-base-component'; import LiveRegion from '../internal/components/live-region'; -import { useInternalI18n } from '../internal/i18n/context'; +import { useInternalI18n } from '../i18n/context'; import { useFunnel } from '../internal/analytics/hooks/use-funnel'; import { FunnelMetrics } from '../internal/analytics'; diff --git a/src/help-panel/__tests__/help-panel.test.tsx b/src/help-panel/__tests__/help-panel.test.tsx index 92cfdfacda..e493b194e1 100644 --- a/src/help-panel/__tests__/help-panel.test.tsx +++ b/src/help-panel/__tests__/help-panel.test.tsx @@ -4,7 +4,7 @@ import React from 'react'; import { render } from '@testing-library/react'; import createWrapper from '../../../lib/components/test-utils/dom'; import HelpPanel from '../../../lib/components/help-panel'; -import TestI18nProvider from '../../../lib/components/internal/i18n/testing'; +import TestI18nProvider from '../../../lib/components/i18n/testing'; function renderHelpPanel(jsx: React.ReactElement) { const { container } = render(jsx); diff --git a/src/help-panel/index.tsx b/src/help-panel/index.tsx index e2eab53c45..1f842c60d5 100644 --- a/src/help-panel/index.tsx +++ b/src/help-panel/index.tsx @@ -9,7 +9,7 @@ import { applyDisplayName } from '../internal/utils/apply-display-name'; import useBaseComponent from '../internal/hooks/use-base-component'; import { HelpPanelProps } from './interfaces'; import LiveRegion from '../internal/components/live-region'; -import { useInternalI18n } from '../internal/i18n/context'; +import { useInternalI18n } from '../i18n/context'; export { HelpPanelProps }; diff --git a/src/input/internal.tsx b/src/input/internal.tsx index 5f9983fb67..3214887afa 100644 --- a/src/input/internal.tsx +++ b/src/input/internal.tsx @@ -14,7 +14,7 @@ import { useDebounceCallback } from '../internal/hooks/use-debounce-callback'; import { FormFieldValidationControlProps, useFormFieldContext } from '../internal/context/form-field-context'; import { InternalBaseComponentProps } from '../internal/hooks/use-base-component'; import styles from './styles.css.js'; -import { useInternalI18n } from '../internal/i18n/context'; +import { useInternalI18n } from '../i18n/context'; export interface InternalInputProps extends BaseComponentProps, diff --git a/src/internal/components/abstract-switch/__tests__/abstract-switch.test.tsx b/src/internal/components/abstract-switch/__tests__/abstract-switch.test.tsx index 3cea1cf1f0..63a74d6166 100644 --- a/src/internal/components/abstract-switch/__tests__/abstract-switch.test.tsx +++ b/src/internal/components/abstract-switch/__tests__/abstract-switch.test.tsx @@ -33,12 +33,13 @@ describe('Abstract switch', () => { expect(container).toValidateA11y(); }); - describe('aria-labelledby', () => { - test('should not have a labelId if a label is not provided', () => { + describe('labels and descriptions', () => { + test('should be default use `label` and `description`', () => { const wrapper = renderAbstractSwitch({ controlClassName: '', outlineClassName: '', styledControl:
, + label: 'Label goes here', controlId: 'custom-id', description: 'Description goes here', nativeControl: nativeControlProps => , @@ -46,51 +47,50 @@ describe('Abstract switch', () => { }); const nativeControl = wrapper.find('.switch-element')!.getElement(); - expect(nativeControl).not.toHaveAttribute('aria-labelledby'); - expect(wrapper.find('#custom-id-label')).toBeNull(); + + expect(nativeControl).toHaveAccessibleName('Label goes here'); + expect(nativeControl).toHaveAccessibleDescription('Description goes here'); }); - test('should be set to labelId if a label is provided', () => { + test('label can be overwritten by `ariaLabel`', () => { const wrapper = renderAbstractSwitch({ controlClassName: '', outlineClassName: '', styledControl:
, label: 'Label goes here', controlId: 'custom-id', - description: 'Description goes here', + ariaLabel: 'Custom aria label', nativeControl: nativeControlProps => , onClick: noop, }); const nativeControl = wrapper.find('.switch-element')!.getElement(); - expect(nativeControl).toHaveAttribute('aria-labelledby', 'custom-id-label'); - expect(nativeControl).toHaveAttribute('aria-describedby', 'custom-id-description'); - - expect(wrapper.find('#custom-id-label')?.getElement()).toHaveTextContent('Label goes here'); - expect(wrapper.find('#custom-id-description')?.getElement()).toHaveTextContent('Description goes here'); + expect(nativeControl).toHaveAccessibleName('Custom aria label'); }); - test('should include labelId if an ariaLabelledBy id is provided', () => { + test('can add additional labelledby and describedby references', () => { const wrapper = renderAbstractSwitch({ controlClassName: '', outlineClassName: '', - styledControl:
, + styledControl: ( +
+ Custom label + Custom description +
+ ), controlId: 'custom-id', ariaLabelledby: 'some-custom-label', ariaDescribedby: 'some-custom-description', - label: 'label', - description: 'description', + label: 'Default label', + description: 'Default description', nativeControl: nativeControlProps => , onClick: noop, }); const nativeControl = wrapper.find('.switch-element')!.getElement(); - expect(nativeControl).toHaveAttribute('aria-labelledby', 'custom-id-label some-custom-label'); - expect(nativeControl).toHaveAttribute('aria-describedby', 'some-custom-description custom-id-description'); - - expect(wrapper.find('#custom-id-label')).not.toBe(null); - expect(wrapper.find('#custom-id-description')).not.toBe(null); + expect(nativeControl).toHaveAccessibleName('Default label Custom label'); + expect(nativeControl).toHaveAccessibleDescription('Custom description Default description'); }); }); }); diff --git a/src/internal/components/abstract-switch/index.tsx b/src/internal/components/abstract-switch/index.tsx index 1c2be80489..72ad2bbba9 100644 --- a/src/internal/components/abstract-switch/index.tsx +++ b/src/internal/components/abstract-switch/index.tsx @@ -54,7 +54,7 @@ export default function AbstractSwitch({ const descriptionId = `${id}-description`; const ariaLabelledByIds = []; - if (label) { + if (label && !ariaLabel) { ariaLabelledByIds.push(labelId); } if (ariaLabelledby) { diff --git a/src/internal/components/cartesian-chart/bottom-labels.tsx b/src/internal/components/cartesian-chart/bottom-labels.tsx index 7ea22783bd..d595409d35 100644 --- a/src/internal/components/cartesian-chart/bottom-labels.tsx +++ b/src/internal/components/cartesian-chart/bottom-labels.tsx @@ -1,6 +1,6 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -import React, { memo, useEffect, useRef } from 'react'; +import React, { memo, useRef } from 'react'; import clsx from 'clsx'; import { ChartDataTypes } from './interfaces'; @@ -8,44 +8,33 @@ import { ChartScale, NumericChartScale } from './scales'; import { TICK_LENGTH, TICK_LINE_HEIGHT, TICK_MARGIN } from './constants'; import styles from './styles.css.js'; -import { formatTicks, getVisibleTicks } from './label-utils'; -import { useInternalI18n } from '../../i18n/context'; +import { formatTicks, getVisibleTicks, FormattedTick } from './label-utils'; +import { useInternalI18n } from '../../../i18n/context'; interface BottomLabelsProps { axis?: 'x' | 'y'; width: number; height: number; scale: ChartScale | NumericChartScale; - ticks: readonly ChartDataTypes[]; - tickFormatter?: (value: ChartDataTypes) => string; title?: string; ariaRoleDescription?: string; - autoHeight: (value: number) => void; offsetLeft?: number; offsetRight?: number; + virtualTextRef: React.Ref; + formattedTicks: readonly FormattedTick[]; } -export default memo(BottomLabels) as typeof BottomLabels; - -// Renders the visible tick labels on the bottom axis, as well as their grid lines. -function BottomLabels({ - axis = 'x', - width, - height, - scale, +export function useBottomLabels({ ticks, + scale, tickFormatter, - title, - ariaRoleDescription, - autoHeight, - offsetLeft = 0, - offsetRight = 0, -}: BottomLabelsProps) { - const i18n = useInternalI18n('[charts]'); +}: { + scale: ChartScale | NumericChartScale; + ticks: readonly ChartDataTypes[]; + tickFormatter?: (value: ChartDataTypes) => string; +}) { const virtualTextRef = useRef(null); - const xOffset = scale.isCategorical() && axis === 'x' ? Math.max(0, scale.d3Scale.bandwidth() - 1) / 2 : 0; - const cacheRef = useRef<{ [label: string]: number }>({}); const getLabelSpace = (label: string) => { if (cacheRef.current[label] !== undefined) { @@ -65,21 +54,38 @@ function BottomLabels({ virtualTextRef.current.textContent = ''; } + let height = TICK_LENGTH + TICK_MARGIN; + for (const { lines } of formattedTicks) { + height = Math.max(height, TICK_LENGTH + TICK_MARGIN + lines.length * TICK_LINE_HEIGHT); + } + + return { virtualTextRef, formattedTicks, height }; +} + +export default memo(BottomLabels) as typeof BottomLabels; + +// Renders the visible tick labels on the bottom axis, as well as their grid lines. +function BottomLabels({ + axis = 'x', + width, + height, + scale, + title, + ariaRoleDescription, + offsetLeft = 0, + offsetRight = 0, + virtualTextRef, + formattedTicks, +}: BottomLabelsProps) { + const i18n = useInternalI18n('[charts]'); + + const xOffset = scale.isCategorical() && axis === 'x' ? Math.max(0, scale.d3Scale.bandwidth() - 1) / 2 : 0; + const from = 0 - offsetLeft - xOffset; const until = width + offsetRight - xOffset; const balanceLabels = axis === 'x' && scale.scaleType !== 'log'; const visibleTicks = getVisibleTicks(formattedTicks, from, until, balanceLabels); - let maxHeight = TICK_LENGTH + TICK_MARGIN; - for (const { lines } of formattedTicks) { - maxHeight = Math.max(maxHeight, TICK_LENGTH + TICK_MARGIN + lines.length * TICK_LINE_HEIGHT); - } - - // Tell elements's height to the parent. - useEffect(() => { - autoHeight(maxHeight); - }, [autoHeight, maxHeight]); - return ( { label: string; diff --git a/src/internal/components/chart-plot/index.tsx b/src/internal/components/chart-plot/index.tsx index 931b2e330b..620ee2ca20 100644 --- a/src/internal/components/chart-plot/index.tsx +++ b/src/internal/components/chart-plot/index.tsx @@ -11,7 +11,7 @@ import LiveRegion from '../live-region/index'; import ApplicationController, { ApplicationRef } from './application-controller'; import FocusOutline from './focus-outline'; import { Offset } from '../interfaces'; -import { useInternalI18n } from '../../i18n/context.js'; +import { useInternalI18n } from '../../../i18n/context'; const DEFAULT_PLOT_FOCUS_OFFSET = 3; const DEFAULT_ELEMENT_FOCUS_OFFSET = 3; diff --git a/src/internal/components/chart-status-container/__tests__/i18n.test.tsx b/src/internal/components/chart-status-container/__tests__/i18n.test.tsx index 79a1c3d65a..c7e6551520 100644 --- a/src/internal/components/chart-status-container/__tests__/i18n.test.tsx +++ b/src/internal/components/chart-status-container/__tests__/i18n.test.tsx @@ -3,7 +3,7 @@ import React from 'react'; import { render } from '@testing-library/react'; import createWrapper from '../../../../../lib/components/test-utils/dom'; -import TestI18nProvider from '../../../../../lib/components/internal/i18n/testing'; +import TestI18nProvider from '../../../../../lib/components/i18n/testing'; import ChartStatusContainer from '../../../../../lib/components/internal/components/chart-status-container'; import styles from '../../../../../lib/components/internal/components/chart-status-container/styles.css.js'; diff --git a/src/internal/components/chart-status-container/index.tsx b/src/internal/components/chart-status-container/index.tsx index ae57d58d2f..5294f5b723 100644 --- a/src/internal/components/chart-status-container/index.tsx +++ b/src/internal/components/chart-status-container/index.tsx @@ -8,7 +8,7 @@ import InternalStatusIndicator from '../../../status-indicator/internal'; import InternalLink from '../../../link/internal'; import styles from './styles.css.js'; -import { useInternalI18n } from '../../i18n/context'; +import { useInternalI18n } from '../../../i18n/context'; interface ChartStatusContainerProps extends BaseComponentProps { statusType: 'loading' | 'finished' | 'error'; diff --git a/src/internal/components/dropdown/index.tsx b/src/internal/components/dropdown/index.tsx index 60bb85009b..d4037f122c 100644 --- a/src/internal/components/dropdown/index.tsx +++ b/src/internal/components/dropdown/index.tsx @@ -60,6 +60,8 @@ interface TransitionContentProps { onMouseDown?: React.MouseEventHandler; id?: string; role?: string; + ariaLabelledby?: string; + ariaDescribedby?: string; } const TransitionContent = ({ @@ -80,6 +82,8 @@ const TransitionContent = ({ onMouseDown, id, role, + ariaLabelledby, + ariaDescribedby, }: TransitionContentProps) => { const contentRef = useMergeRefs(dropdownRef, transitionRef); return ( @@ -96,6 +100,8 @@ const TransitionContent = ({ ref={contentRef} id={id} role={role} + aria-labelledby={ariaLabelledby} + aria-describedby={ariaDescribedby} data-open={open} data-animating={state !== 'exited'} aria-hidden={!open} @@ -140,6 +146,8 @@ const Dropdown = ({ contentKey, dropdownContentId, dropdownContentRole, + ariaLabelledby, + ariaDescribedby, }: DropdownProps) => { const wrapperRef = useRef(null); const triggerRef = useRef(null); @@ -404,6 +412,8 @@ const Dropdown = ({ position={position} id={dropdownContentId} role={dropdownContentRole} + ariaLabelledby={ariaLabelledby} + ariaDescribedby={ariaDescribedby} > {children} diff --git a/src/internal/components/dropdown/interfaces.ts b/src/internal/components/dropdown/interfaces.ts index de74406cbb..abb1e3abdf 100644 --- a/src/internal/components/dropdown/interfaces.ts +++ b/src/internal/components/dropdown/interfaces.ts @@ -141,6 +141,14 @@ export interface DropdownProps extends ExpandToViewport { * HTML role for the dropdown content wrapper */ dropdownContentRole?: string; + /** + * Labelledby for the dropdown (required when role="dialog") + */ + ariaLabelledby?: string; + /** + * Describedby for the dropdown (recommended when role="dialog") + */ + ariaDescribedby?: string; } export interface ExpandToViewport { diff --git a/src/internal/components/token-list/token-limit-toggle.tsx b/src/internal/components/token-list/token-limit-toggle.tsx index 60dcaa4c16..e8628cd38c 100644 --- a/src/internal/components/token-list/token-limit-toggle.tsx +++ b/src/internal/components/token-list/token-limit-toggle.tsx @@ -7,7 +7,7 @@ import { fireNonCancelableEvent, NonCancelableEventHandler } from '../../events' import { I18nStrings } from './interfaces'; import styles from './styles.css.js'; -import { useInternalI18n } from '../../i18n/context'; +import { useInternalI18n } from '../../../i18n/context'; interface TokenLimitToggleProps { controlId?: string; allHidden: boolean; diff --git a/src/internal/hooks/container-queries/use-height-measure.ts b/src/internal/hooks/container-queries/use-height-measure.ts index 95ad87721b..0d28e3276d 100644 --- a/src/internal/hooks/container-queries/use-height-measure.ts +++ b/src/internal/hooks/container-queries/use-height-measure.ts @@ -14,7 +14,7 @@ export function useHeightMeasure( ) { const [measuredHeight, setHeight] = useState(0); // eslint-disable-next-line react-hooks/exhaustive-deps - const stableGetMeasure = useCallback(getMeasure, deps); + const stableGetMeasure = useCallback(getMeasure, [...deps, skip]); useResizeObserver(stableGetMeasure, entry => !skip && setHeight(entry.borderBoxHeight)); return !skip ? measuredHeight : undefined; } diff --git a/src/internal/i18n/context.ts b/src/internal/i18n/context.ts deleted file mode 100644 index 39d5ba7957..0000000000 --- a/src/internal/i18n/context.ts +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -export * from '../../i18n/context'; diff --git a/src/internal/i18n/index.ts b/src/internal/i18n/index.ts deleted file mode 100644 index e626d75d8a..0000000000 --- a/src/internal/i18n/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -export { I18nProvider, I18nProviderProps } from '../../i18n'; diff --git a/src/internal/i18n/provider.ts b/src/internal/i18n/provider.ts deleted file mode 100644 index 505970f402..0000000000 --- a/src/internal/i18n/provider.ts +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -export { I18nProvider, I18nProviderProps } from '../../i18n/provider'; diff --git a/src/internal/i18n/testing.ts b/src/internal/i18n/testing.ts deleted file mode 100644 index 1ebff62a21..0000000000 --- a/src/internal/i18n/testing.ts +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -export { default, TestI18nProviderProps } from '../../i18n/testing'; diff --git a/src/link/__tests__/index.test.tsx b/src/link/__tests__/index.test.tsx index 59bbf7d660..ecbcc4b359 100644 --- a/src/link/__tests__/index.test.tsx +++ b/src/link/__tests__/index.test.tsx @@ -6,7 +6,7 @@ import Link, { LinkProps } from '../../../lib/components/link'; import styles from '../../../lib/components/link/styles.css.js'; import createWrapper from '../../../lib/components/test-utils/dom'; import { linkRelExpectations, linkTargetExpectations } from '../../__tests__/target-rel-test-helper'; -import TestI18nProvider from '../../../lib/components/internal/i18n/testing'; +import TestI18nProvider from '../../../lib/components/i18n/testing'; import FormField from '../../../lib/components/form-field'; import Header from '../../../lib/components/header'; diff --git a/src/link/internal.tsx b/src/link/internal.tsx index c3ca7c64b6..5cc60a8f6f 100644 --- a/src/link/internal.tsx +++ b/src/link/internal.tsx @@ -13,7 +13,7 @@ import { InternalBaseComponentProps } from '../internal/hooks/use-base-component import { useMergeRefs } from '../internal/hooks/use-merge-refs'; import { useVisualRefresh } from '../internal/hooks/use-visual-mode'; import { checkSafeUrl } from '../internal/utils/check-safe-url'; -import { useInternalI18n } from '../internal/i18n/context'; +import { useInternalI18n } from '../i18n/context'; import { InfoLinkLabelContext } from '../internal/context/info-link-label-context'; import { useFunnel, useFunnelStep, useFunnelSubStep } from '../internal/analytics/hooks/use-funnel'; diff --git a/src/mixed-line-bar-chart/chart-container.tsx b/src/mixed-line-bar-chart/chart-container.tsx index 9f09421fa3..fef07046a2 100644 --- a/src/mixed-line-bar-chart/chart-container.tsx +++ b/src/mixed-line-bar-chart/chart-container.tsx @@ -9,7 +9,7 @@ import ChartPlot, { ChartPlotRef } from '../internal/components/chart-plot'; import AxisLabel from '../internal/components/cartesian-chart/axis-label'; import LabelsMeasure from '../internal/components/cartesian-chart/labels-measure'; import LeftLabels from '../internal/components/cartesian-chart/left-labels'; -import BottomLabels from '../internal/components/cartesian-chart/bottom-labels'; +import BottomLabels, { useBottomLabels } from '../internal/components/cartesian-chart/bottom-labels'; import VerticalGridLines from '../internal/components/cartesian-chart/vertical-grid-lines'; import EmphasizedBaseline from '../internal/components/cartesian-chart/emphasized-baseline'; import HighlightedPoint from '../internal/components/cartesian-chart/highlighted-point'; @@ -80,6 +80,25 @@ export interface ChartContainerProps { plotContainerRef: React.RefObject; } +interface BaseAxisProps { + tickCount: number; + tickFormatter: TickFormatter; + title?: string; + ariaRoleDescription?: string; +} + +interface XAxisProps extends BaseAxisProps { + axis: 'x'; + scale: ChartScale; + ticks: ChartDataTypes[]; +} + +interface YAxisProps extends BaseAxisProps { + axis: 'y'; + scale: NumericChartScale; + ticks: number[]; +} + export default function ChartContainer({ fitHeight, height: explicitPlotHeight, @@ -113,7 +132,6 @@ export default function ChartContainer({ const verticalMarkerRef = useRef(null); const [leftLabelsWidth, setLeftLabelsWidth] = useState(0); - const [bottomLabelsHeight, setBottomLabelsHeight] = useState(0); const [verticalMarkerX, setVerticalMarkerX] = useState | null>(null); const [containerWidth, containerMeasureRef] = useContainerWidth(500); const plotWidth = containerWidth ? containerWidth - leftLabelsWidth - LEFT_LABELS_MARGIN : 500; @@ -121,36 +139,63 @@ export default function ChartContainer({ const containerRef = useMergeRefs(containerMeasureRef, containerRefObject); const popoverRef = useRef(null); - const plotMeasureRef = useRef(null); - const measuredHeight = useHeightMeasure(() => plotMeasureRef.current, !fitHeight || !bottomLabelsHeight); - const plotHeight = fitHeight ? (bottomLabelsHeight ? measuredHeight ?? 0 : 0) : explicitPlotHeight; - - const isRefresh = useVisualRefresh(); - - const linesOnly = series.every(({ series }) => series.type === 'line' || series.type === 'threshold'); - const xDomain = (props.xDomain || computeDomainX(series, xScaleType)) as | readonly number[] | readonly string[] | readonly Date[]; const yDomain = (props.yDomain || computeDomainY(series, yScaleType, stackedBars)) as readonly number[]; - const xTickCount = getXTickCount(plotWidth); - const yTickCount = getYTickCount(plotHeight); - - const rangeBottomTop: [number, number] = [0, plotHeight]; - const rangeTopBottom: [number, number] = [plotHeight, 0]; - const rangeLeftRight: [number, number] = [0, plotWidth]; - const xScale = new ChartScale(xScaleType, xDomain, horizontalBars ? rangeBottomTop : rangeLeftRight, linesOnly); - const yScale = new NumericChartScale( - yScaleType, - yDomain, - horizontalBars ? rangeLeftRight : rangeTopBottom, - props.yDomain ? null : yTickCount - ); + const linesOnly = series.every(({ series }) => series.type === 'line' || series.type === 'threshold'); + + function getXAxisProps(size: number, range: [from: number, until: number]): XAxisProps { + const tickCount = getXTickCount(size); + const scale = new ChartScale(xScaleType, xDomain, range, linesOnly); + const ticks = createXTicks(scale, tickCount); + return { + axis: 'x', + tickCount, + scale, + ticks, + tickFormatter: xTickFormatter as TickFormatter, + title: xTitle, + ariaRoleDescription: i18nStrings.xAxisAriaRoleDescription, + }; + } + + function getYAxisProps(size: number, range: [from: number, until: number]): YAxisProps { + const tickCount = getYTickCount(size); + const scale = new NumericChartScale(yScaleType, yDomain, range, props.yDomain ? null : tickCount); + const ticks = createYTicks(scale, tickCount); + return { + axis: 'y', + tickCount, + scale, + ticks, + tickFormatter: yTickFormatter as TickFormatter, + title: yTitle, + ariaRoleDescription: i18nStrings.yAxisAriaRoleDescription, + }; + } + + const bottomAxisProps = !horizontalBars + ? getXAxisProps(plotWidth, [0, plotWidth]) + : getYAxisProps(plotWidth, [0, plotWidth]); - const xTicks = createXTicks(xScale, xTickCount); - const yTicks = createYTicks(yScale, yTickCount); + const bottomLabelsProps = useBottomLabels({ ...bottomAxisProps }); + + const plotMeasureRef = useRef(null); + const measuredHeight = useHeightMeasure(() => plotMeasureRef.current, !fitHeight); + const plotHeight = fitHeight ? measuredHeight ?? 0 : explicitPlotHeight; + + const leftAxisProps = !horizontalBars + ? getYAxisProps(plotHeight, [plotHeight, 0]) + : getXAxisProps(plotHeight, [0, plotHeight]); + + const xAxisProps = bottomAxisProps.axis === 'x' ? bottomAxisProps : leftAxisProps.axis === 'x' ? leftAxisProps : null; + const yAxisProps = bottomAxisProps.axis === 'y' ? bottomAxisProps : leftAxisProps.axis === 'y' ? leftAxisProps : null; + if (!xAxisProps || !yAxisProps) { + throw new Error('Invariant violation: invalid axis props.'); + } /** * Interactions @@ -163,16 +208,9 @@ export default function ChartContainer({ // When "horizontalBars" is enabled, the axes are inverted. const x = !horizontalBars ? 'x' : 'y'; const y = !horizontalBars ? 'y' : 'x'; - const xy = { - ticks: { x: xTicks, y: yTicks }, - scale: { x: xScale, y: yScale }, - tickFormatter: { x: xTickFormatter, y: yTickFormatter }, - title: { x: xTitle, y: yTitle }, - ariaRoleDescription: { x: i18nStrings.xAxisAriaRoleDescription, y: i18nStrings.yAxisAriaRoleDescription }, - }; - const scaledSeries = makeScaledSeries(visibleSeries, xScale, yScale); - const barGroups: ScaledBarGroup[] = makeScaledBarGroups(visibleSeries, xScale, plotWidth, plotHeight, y); + const scaledSeries = makeScaledSeries(visibleSeries, xAxisProps.scale, yAxisProps.scale); + const barGroups: ScaledBarGroup[] = makeScaledBarGroups(visibleSeries, xAxisProps.scale, plotWidth, plotHeight, y); const { isPopoverOpen, isPopoverPinned, showPopover, pinPopover, dismissPopover } = usePopover(); @@ -248,8 +286,8 @@ export default function ChartContainer({ visibleSeries, scaledSeries, barGroups, - xScale, - yScale, + xScale: xAxisProps.scale, + yScale: yAxisProps.scale, highlightedPoint, highlightedGroupIndex, highlightedSeries, @@ -367,13 +405,13 @@ export default function ChartContainer({ const onSVGKeyDown = handlers.onKeyDown; - const xOffset = xScale.isCategorical() ? Math.max(0, xScale.d3Scale.bandwidth() - 1) / 2 : 0; + const xOffset = xAxisProps.scale.isCategorical() ? Math.max(0, xAxisProps.scale.d3Scale.bandwidth() - 1) / 2 : 0; let verticalLineX: number | null = null; if (verticalMarkerX !== null) { verticalLineX = verticalMarkerX.scaledX; } else if (isGroupNavigation && highlightedGroupIndex !== null) { - const x = xScale.d3Scale(barGroups[highlightedGroupIndex].x as any) ?? null; + const x = xAxisProps.scale.d3Scale(barGroups[highlightedGroupIndex].x as any) ?? null; if (x !== null) { verticalLineX = xOffset + x; } @@ -449,27 +487,29 @@ export default function ChartContainer({ const isLineXKeyboardFocused = isPlotFocused && !highlightedPoint && verticalMarkerX; + const isRefresh = useVisualRefresh(); + return ( } + leftAxisLabel={} leftAxisLabelMeasure={ } - bottomAxisLabel={} + bottomAxisLabel={} chartPlot={ ({ - {horizontalBars && } + {horizontalBars && ( + + )} {emphasizeBaselineAxis && linesOnly && ( - + )} ({ stackedBars={stackedBars} isGroupNavigation={isGroupNavigation} visibleSeries={visibleSeries} - xScale={xScale} - yScale={yScale} + xScale={xAxisProps.scale} + yScale={yAxisProps.scale} /> {emphasizeBaselineAxis && !linesOnly && ( - + )} ({ /> )} - {isGroupNavigation && xScale.isCategorical() && ( + {isGroupNavigation && xAxisProps.scale.isCategorical() && ( ({ )} } diff --git a/src/modal/internal.tsx b/src/modal/internal.tsx index f5850b60ab..43ab7a9ad6 100644 --- a/src/modal/internal.tsx +++ b/src/modal/internal.tsx @@ -21,7 +21,7 @@ import { ModalProps } from './interfaces'; import styles from './styles.css.js'; import { SomeRequired } from '../internal/types'; import FocusLock from '../internal/components/focus-lock'; -import { useInternalI18n } from '../internal/i18n/context'; +import { useInternalI18n } from '../i18n/context'; import { useIntersectionObserver } from '../internal/hooks/use-intersection-observer'; import { useContainerQuery } from '@cloudscape-design/component-toolkit'; diff --git a/src/multiselect/__tests__/multiselect.test.tsx b/src/multiselect/__tests__/multiselect.test.tsx index 1c82529e85..b1250268e0 100644 --- a/src/multiselect/__tests__/multiselect.test.tsx +++ b/src/multiselect/__tests__/multiselect.test.tsx @@ -8,7 +8,7 @@ import tokenGroupStyles from '../../../lib/components/token-group/styles.css.js' import selectPartsStyles from '../../../lib/components/select/parts/styles.css.js'; import '../../__a11y__/to-validate-a11y'; import statusIconStyles from '../../../lib/components/status-indicator/styles.selectors.js'; -import TestI18nProvider from '../../../lib/components/internal/i18n/testing'; +import TestI18nProvider from '../../../lib/components/i18n/testing'; const defaultOptions: MultiselectProps.Options = [ { label: 'First', value: '1' }, @@ -482,6 +482,16 @@ describe('a11y properties', () => { wrapper.findDropdown().getElement().parentNode!.querySelector(`#${controlledId}`)!.getAttribute('role') ).toBe('dialog'); }); + test('dropdown (role="dialog") should receive a label when filtering enabled', () => { + const { wrapper } = renderMultiselect( + + ); + wrapper.openDropdown(); + const controlledId = wrapper.findTrigger().getElement().getAttribute('aria-controls'); + expect(wrapper.findDropdown().getElement().parentNode!.querySelector(`#${controlledId}`)!).toHaveAccessibleName( + 'multiselect-label' + ); + }); }); test('Trigger receives focus when autofocus is true', () => { diff --git a/src/multiselect/internal.tsx b/src/multiselect/internal.tsx index 5c2f298fab..306efc7f05 100644 --- a/src/multiselect/internal.tsx +++ b/src/multiselect/internal.tsx @@ -35,7 +35,7 @@ import { MultiselectProps } from './interfaces'; import styles from './styles.css.js'; import ScreenreaderOnly from '../internal/components/screenreader-only'; import { joinStrings } from '../internal/utils/strings'; -import { useInternalI18n } from '../internal/i18n/context'; +import { useInternalI18n } from '../i18n/context'; type InternalMultiselectProps = MultiselectProps & InternalBaseComponentProps; @@ -289,6 +289,8 @@ const InternalMultiselect = React.forwardRef( const mergedRef = useMergeRefs(rootRef, __internalRootRef); + const dropdownProps = getDropdownProps(); + return (
= { nextPageLabel: '', diff --git a/src/pie-chart/__tests__/pie-chart.test.tsx b/src/pie-chart/__tests__/pie-chart.test.tsx index b720528295..a07b8094ef 100644 --- a/src/pie-chart/__tests__/pie-chart.test.tsx +++ b/src/pie-chart/__tests__/pie-chart.test.tsx @@ -10,7 +10,7 @@ import styles from '../../../lib/components/pie-chart/styles.css.js'; import chartWrapperStyles from '../../../lib/components/internal/components/chart-wrapper/styles.css.js'; import * as colors from '../../../lib/design-tokens'; import { act } from 'react-dom/test-utils'; -import TestI18nProvider from '../../../lib/components/internal/i18n/testing'; +import TestI18nProvider from '../../../lib/components/i18n/testing'; const variants: Array['variant']> = ['pie', 'donut']; const sizes: Array['size']> = ['small', 'medium', 'large']; diff --git a/src/pie-chart/pie-chart.tsx b/src/pie-chart/pie-chart.tsx index 55ecf33d82..c2ffcb7547 100644 --- a/src/pie-chart/pie-chart.tsx +++ b/src/pie-chart/pie-chart.tsx @@ -17,7 +17,7 @@ import { defaultDetails, getDimensionsBySize } from './utils'; import Segments from './segments'; import ChartPlot, { ChartPlotRef } from '../internal/components/chart-plot'; import { SomeRequired } from '../internal/types'; -import { useInternalI18n } from '../internal/i18n/context'; +import { useInternalI18n } from '../i18n/context'; import { nodeBelongs } from '../internal/utils/node-belongs'; import clsx from 'clsx'; import { useVisualRefresh } from '../internal/hooks/use-visual-mode'; diff --git a/src/pie-chart/segments.tsx b/src/pie-chart/segments.tsx index 131f67bbdb..2e3040d12c 100644 --- a/src/pie-chart/segments.tsx +++ b/src/pie-chart/segments.tsx @@ -8,7 +8,7 @@ import { Dimension } from './utils'; import { InternalChartDatum } from './pie-chart'; import styles from './styles.css.js'; import clsx from 'clsx'; -import { useInternalI18n } from '../internal/i18n/context'; +import { useInternalI18n } from '../i18n/context'; interface SegmentsProps { pieData: Array>>; diff --git a/src/pie-chart/utils.ts b/src/pie-chart/utils.ts index 48aa91e576..bc52ddf169 100644 --- a/src/pie-chart/utils.ts +++ b/src/pie-chart/utils.ts @@ -1,6 +1,6 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -import { ComponentFormatFunction } from '../internal/i18n/context'; +import { ComponentFormatFunction } from '../i18n/context'; import { PieChartProps } from './interfaces'; import styles from './styles.css.js'; diff --git a/src/popover/__tests__/popover.test.tsx b/src/popover/__tests__/popover.test.tsx index 19c899297f..cf50d99916 100644 --- a/src/popover/__tests__/popover.test.tsx +++ b/src/popover/__tests__/popover.test.tsx @@ -8,7 +8,7 @@ import '../../__a11y__/to-validate-a11y'; import styles from '../../../lib/components/popover/styles.selectors.js'; import { KeyCode } from '@cloudscape-design/test-utils-core/dist/utils'; -import TestI18nProvider from '../../../lib/components/internal/i18n/testing'; +import TestI18nProvider from '../../../lib/components/i18n/testing'; class PopoverInternalWrapper extends PopoverWrapper { findBody({ renderWithPortal } = { renderWithPortal: false }): ElementWrapper | null { diff --git a/src/popover/body.tsx b/src/popover/body.tsx index 11e27434ee..254e6aeee7 100644 --- a/src/popover/body.tsx +++ b/src/popover/body.tsx @@ -10,7 +10,7 @@ import { InternalButton } from '../button/internal'; import FocusLock from '../internal/components/focus-lock'; import styles from './styles.css.js'; -import { useInternalI18n } from '../internal/i18n/context'; +import { useInternalI18n } from '../i18n/context'; export interface PopoverBodyProps { dismissButton: boolean; diff --git a/src/popover/internal.tsx b/src/popover/internal.tsx index 84d8c283d6..190740eff3 100644 --- a/src/popover/internal.tsx +++ b/src/popover/internal.tsx @@ -18,7 +18,7 @@ import { NonCancelableEventHandler, fireNonCancelableEvent } from '../internal/e import { InternalBaseComponentProps } from '../internal/hooks/use-base-component'; import { useMergeRefs } from '../internal/hooks/use-merge-refs'; import { usePortalModeClasses } from '../internal/hooks/use-portal-mode-classes'; -import { useInternalI18n } from '../internal/i18n/context'; +import { useInternalI18n } from '../i18n/context'; import { useUniqueId } from '../internal/hooks/use-unique-id'; import { getFirstFocusable } from '../internal/components/focus-lock/utils'; diff --git a/src/property-filter/index.tsx b/src/property-filter/index.tsx index 5c0157e9e3..7b06901707 100644 --- a/src/property-filter/index.tsx +++ b/src/property-filter/index.tsx @@ -32,7 +32,7 @@ import { PropertyEditor } from './property-editor'; import { AutosuggestInputRef } from '../internal/components/autosuggest-input'; import { matchTokenValue } from './utils'; import { PropertyFilterOperator } from '@cloudscape-design/collection-hooks'; -import { useInternalI18n } from '../internal/i18n/context'; +import { useInternalI18n } from '../i18n/context'; import TokenList from '../internal/components/token-list'; import { SearchResults } from '../text-filter/search-results'; diff --git a/src/s3-resource-selector/__tests__/main.test.tsx b/src/s3-resource-selector/__tests__/main.test.tsx index cc052c68e5..cfcefdc089 100644 --- a/src/s3-resource-selector/__tests__/main.test.tsx +++ b/src/s3-resource-selector/__tests__/main.test.tsx @@ -6,7 +6,7 @@ import S3ResourceSelector, { S3ResourceSelectorProps } from '../../../lib/compon import createWrapper, { S3ResourceSelectorWrapper } from '../../../lib/components/test-utils/dom'; import { buckets, i18nStrings, objects, versions, waitForFetch } from './fixtures'; import FormField from '../../../lib/components/form-field'; -import TestI18nProvider from '../../../lib/components/internal/i18n/testing'; +import TestI18nProvider from '../../../lib/components/i18n/testing'; jest.setTimeout(10_000); diff --git a/src/s3-resource-selector/__tests__/s3-in-context.test.tsx b/src/s3-resource-selector/__tests__/s3-in-context.test.tsx index 895cb26e23..7884a7f24b 100644 --- a/src/s3-resource-selector/__tests__/s3-in-context.test.tsx +++ b/src/s3-resource-selector/__tests__/s3-in-context.test.tsx @@ -7,7 +7,7 @@ import FormField from '../../../lib/components/form-field'; import S3ResourceSelector from '../../../lib/components/s3-resource-selector'; import createWrapper from '../../../lib/components/test-utils/dom'; import { buckets, i18nStrings, objects, versions, waitForFetch } from './fixtures'; -import TestI18nProvider from '../../../lib/components/internal/i18n/testing'; +import TestI18nProvider from '../../../lib/components/i18n/testing'; const defaultProps = { resource: { uri: '' }, diff --git a/src/s3-resource-selector/s3-in-context/index.tsx b/src/s3-resource-selector/s3-in-context/index.tsx index 45ca3fa2c6..9c661f59eb 100644 --- a/src/s3-resource-selector/s3-in-context/index.tsx +++ b/src/s3-resource-selector/s3-in-context/index.tsx @@ -15,7 +15,7 @@ import { validate, getErrorText } from './validation'; import styles from './styles.css.js'; import { SearchInput } from './search-input'; import LiveRegion from '../../internal/components/live-region'; -import { useInternalI18n } from '../../internal/i18n/context'; +import { useInternalI18n } from '../../i18n/context'; interface S3InContextProps { i18nStrings: S3ResourceSelectorProps.I18nStrings | undefined; diff --git a/src/s3-resource-selector/s3-in-context/validation.ts b/src/s3-resource-selector/s3-in-context/validation.ts index 0eb10785ae..f8474196f5 100644 --- a/src/s3-resource-selector/s3-in-context/validation.ts +++ b/src/s3-resource-selector/s3-in-context/validation.ts @@ -1,6 +1,6 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -import { ComponentFormatFunction } from '../../internal/i18n/context'; +import { ComponentFormatFunction } from '../../i18n/context'; import { S3ResourceSelectorProps } from '../interfaces'; // https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html diff --git a/src/s3-resource-selector/s3-modal/basic-table.tsx b/src/s3-resource-selector/s3-modal/basic-table.tsx index ca811e1161..d265f34d7d 100644 --- a/src/s3-resource-selector/s3-modal/basic-table.tsx +++ b/src/s3-resource-selector/s3-modal/basic-table.tsx @@ -14,7 +14,7 @@ import useForwardFocus, { ForwardFocusRef } from '../../internal/hooks/forward-f import { useStableEventHandler } from '../../internal/hooks/use-stable-event-handler'; import { S3ResourceSelectorProps } from '../interfaces'; import { EmptyState } from './empty-state'; -import { ComponentFormatFunction } from '../../internal/i18n/context'; +import { ComponentFormatFunction } from '../../i18n/context'; interface BasicS3TableStrings { labelRefresh?: string; diff --git a/src/s3-resource-selector/s3-modal/buckets-table.tsx b/src/s3-resource-selector/s3-modal/buckets-table.tsx index 12c4703e2b..0c764851e7 100644 --- a/src/s3-resource-selector/s3-modal/buckets-table.tsx +++ b/src/s3-resource-selector/s3-modal/buckets-table.tsx @@ -8,7 +8,7 @@ import { S3ResourceSelectorProps } from '../interfaces'; import { compareDates, getColumnAriaLabel, includes } from './table-utils'; import { formatDefault } from './column-formats'; import { BasicS3Table, getSharedI18Strings } from './basic-table'; -import { useInternalI18n } from '../../internal/i18n/context'; +import { useInternalI18n } from '../../i18n/context'; interface BucketsTableProps { forwardFocusRef: React.Ref; diff --git a/src/s3-resource-selector/s3-modal/index.tsx b/src/s3-resource-selector/s3-modal/index.tsx index d517e63760..08e4984ad9 100644 --- a/src/s3-resource-selector/s3-modal/index.tsx +++ b/src/s3-resource-selector/s3-modal/index.tsx @@ -14,7 +14,7 @@ import { ObjectsTable } from './objects-table'; import { VersionsTable } from './versions-table'; import styles from './styles.css.js'; import { joinObjectPath } from '../utils'; -import { useInternalI18n } from '../../internal/i18n/context'; +import { useInternalI18n } from '../../i18n/context'; export interface S3ModalProps { alert: React.ReactNode; diff --git a/src/s3-resource-selector/s3-modal/objects-table.tsx b/src/s3-resource-selector/s3-modal/objects-table.tsx index 4ce9b6d78e..812a037820 100644 --- a/src/s3-resource-selector/s3-modal/objects-table.tsx +++ b/src/s3-resource-selector/s3-modal/objects-table.tsx @@ -10,7 +10,7 @@ import { ForwardFocusRef } from '../../internal/hooks/forward-focus'; import { formatSize, formatDefault } from './column-formats'; import { BasicS3Table, getSharedI18Strings } from './basic-table'; import { joinObjectPath } from '../utils'; -import { useInternalI18n } from '../../internal/i18n/context'; +import { useInternalI18n } from '../../i18n/context'; interface ObjectsTableProps { forwardFocusRef: React.Ref; diff --git a/src/s3-resource-selector/s3-modal/table-utils.ts b/src/s3-resource-selector/s3-modal/table-utils.ts index de1aba4c81..57e544b316 100644 --- a/src/s3-resource-selector/s3-modal/table-utils.ts +++ b/src/s3-resource-selector/s3-modal/table-utils.ts @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 import { S3ResourceSelectorProps } from '../interfaces'; import { TableProps } from '../../table/interfaces'; -import { ComponentFormatFunction } from '../../internal/i18n/context'; +import { ComponentFormatFunction } from '../../i18n/context'; export function includes(array: ReadonlyArray | undefined, item: T) { return !!array && array.indexOf(item) > -1; diff --git a/src/s3-resource-selector/s3-modal/versions-table.tsx b/src/s3-resource-selector/s3-modal/versions-table.tsx index c538972f6b..53f5f973c5 100644 --- a/src/s3-resource-selector/s3-modal/versions-table.tsx +++ b/src/s3-resource-selector/s3-modal/versions-table.tsx @@ -8,7 +8,7 @@ import { ForwardFocusRef } from '../../internal/hooks/forward-focus'; import { formatSize, formatDefault } from './column-formats'; import { BasicS3Table, getSharedI18Strings } from './basic-table'; import { joinObjectPath } from '../utils'; -import { useInternalI18n } from '../../internal/i18n/context'; +import { useInternalI18n } from '../../i18n/context'; interface VersionsTableProps { forwardFocusRef: React.Ref; diff --git a/src/select/__tests__/select-a11y.test.tsx b/src/select/__tests__/select-a11y.test.tsx index d64b8fca8e..c1f3dca290 100644 --- a/src/select/__tests__/select-a11y.test.tsx +++ b/src/select/__tests__/select-a11y.test.tsx @@ -46,6 +46,13 @@ describe.each([false, true])('expandToViewport=%s', expandToViewport => { await expect(container).toValidateA11y(); }); + test('with filtering', async () => { + const { container, wrapper } = renderSelect({ filteringType: 'auto', filteringAriaLabel: 'Filter' }); + wrapper.openDropdown(); + expect(wrapper.findDropdown({ expandToViewport })!.findOptionByValue('1')).toBeTruthy(); + await expect(container).toValidateA11y(); + }); + test('Option should have aria-selected', () => { const { wrapper } = renderSelect({ selectedOption: { label: 'First', value: '1' } }); wrapper.openDropdown(); diff --git a/src/select/__tests__/select.test.tsx b/src/select/__tests__/select.test.tsx index 0b16b07b18..87c843b239 100644 --- a/src/select/__tests__/select.test.tsx +++ b/src/select/__tests__/select.test.tsx @@ -332,6 +332,18 @@ describe.each([false, true])('expandToViewport=%s', expandToViewport => { .getAttribute('role') ).toBe('dialog'); }); + + test('dropdown (role="dialog") should receive a label when filtering enabled', () => { + const { wrapper } = renderSelect({ + filteringType: 'auto', + ariaLabel: 'select-label', + }); + wrapper.openDropdown(); + const controlledId = wrapper.findTrigger().getElement().getAttribute('aria-controls'); + expect( + wrapper.findDropdown({ expandToViewport }).getElement().parentNode!.querySelector(`#${controlledId}`)! + ).toHaveAccessibleName('select-label'); + }); }); describe('Filtering results', () => { diff --git a/src/select/internal.tsx b/src/select/internal.tsx index 148bb82d92..0eeada2e5e 100644 --- a/src/select/internal.tsx +++ b/src/select/internal.tsx @@ -30,7 +30,7 @@ import { OptionGroup } from '../internal/components/option/interfaces.js'; import { SomeRequired } from '../internal/types'; import ScreenreaderOnly from '../internal/components/screenreader-only/index.js'; import { joinStrings } from '../internal/utils/strings/join-strings.js'; -import { useInternalI18n } from '../internal/i18n/context.js'; +import { useInternalI18n } from '../i18n/context.js'; export interface InternalSelectProps extends SomeRequired, InternalBaseComponentProps { __inFilteringToken?: boolean; @@ -222,6 +222,8 @@ const InternalSelect = React.forwardRef( const mergedRef = useMergeRefs(rootRef, __internalRootRef); + const dropdownProps = getDropdownProps(); + return (
({ diff --git a/src/split-panel/index.tsx b/src/split-panel/index.tsx index 522b97f8a9..cb7e663ce2 100644 --- a/src/split-panel/index.tsx +++ b/src/split-panel/index.tsx @@ -25,7 +25,7 @@ import { useVisualRefresh } from '../internal/hooks/use-visual-mode'; import { useUniqueId } from '../internal/hooks/use-unique-id'; import { SplitPanelContentSide } from './side'; import { SplitPanelContentBottom } from './bottom'; -import { useInternalI18n } from '../internal/i18n/context'; +import { useInternalI18n } from '../i18n/context'; export { SplitPanelProps }; diff --git a/src/table/__tests__/header-cell.test.tsx b/src/table/__tests__/header-cell.test.tsx index 06b4eeffc1..89884b8184 100644 --- a/src/table/__tests__/header-cell.test.tsx +++ b/src/table/__tests__/header-cell.test.tsx @@ -9,7 +9,7 @@ import { renderHook } from '../../__tests__/render-hook'; import styles from '../../../lib/components/table/header-cell/styles.css.js'; import resizerStyles from '../../../lib/components/table/resizer/styles.css.js'; import { useStickyColumns } from '../../../lib/components/table/sticky-columns'; -import TestI18nProvider from '../../../lib/components/internal/i18n/testing'; +import TestI18nProvider from '../../../lib/components/i18n/testing'; const testItem = { test: 'test', diff --git a/src/table/body-cell/index.tsx b/src/table/body-cell/index.tsx index 13a963aff8..981dcbf55b 100644 --- a/src/table/body-cell/index.tsx +++ b/src/table/body-cell/index.tsx @@ -8,7 +8,7 @@ import { TableProps } from '../interfaces'; import { TableTdElement, TableTdElementProps } from './td-element'; import { InlineEditor } from './inline-editor'; import LiveRegion from '../../internal/components/live-region/index.js'; -import { useInternalI18n } from '../../internal/i18n/context'; +import { useInternalI18n } from '../../i18n/context'; import { usePrevious } from '../../internal/hooks/use-previous'; const submitHandlerFallback = () => { diff --git a/src/table/body-cell/inline-editor.tsx b/src/table/body-cell/inline-editor.tsx index 9a941a6781..32092f54a2 100644 --- a/src/table/body-cell/inline-editor.tsx +++ b/src/table/body-cell/inline-editor.tsx @@ -10,7 +10,7 @@ import styles from './styles.css.js'; import { Optional } from '../../internal/types'; import FocusLock, { FocusLockRef } from '../../internal/components/focus-lock'; import LiveRegion from '../../internal/components/live-region'; -import { useInternalI18n } from '../../internal/i18n/context'; +import { useInternalI18n } from '../../i18n/context'; // A function that does nothing const noop = () => undefined; diff --git a/src/table/header-cell/index.tsx b/src/table/header-cell/index.tsx index 4a79ac0f7a..9ba182646c 100644 --- a/src/table/header-cell/index.tsx +++ b/src/table/header-cell/index.tsx @@ -11,7 +11,7 @@ import { Resizer } from '../resizer'; import { useUniqueId } from '../../internal/hooks/use-unique-id'; import { InteractiveComponent } from '../thead'; import { getStickyClassNames } from '../utils'; -import { useInternalI18n } from '../../internal/i18n/context'; +import { useInternalI18n } from '../../i18n/context'; import { StickyColumnsModel, useStickyCellStyles } from '../sticky-columns'; import { useMergeRefs } from '../../internal/hooks/use-merge-refs'; diff --git a/src/tabs/__tests__/tabs.test.tsx b/src/tabs/__tests__/tabs.test.tsx index 48576a4542..a4907c7a43 100644 --- a/src/tabs/__tests__/tabs.test.tsx +++ b/src/tabs/__tests__/tabs.test.tsx @@ -7,7 +7,7 @@ import Tabs, { TabsProps } from '../../../lib/components/tabs'; import styles from '../../../lib/components/tabs/styles.css.js'; import createWrapper, { TabsWrapper } from '../../../lib/components/test-utils/dom'; import { KeyCode } from '@cloudscape-design/test-utils-core/dist/utils'; -import TestI18nProvider from '../../../lib/components/internal/i18n/testing'; +import TestI18nProvider from '../../../lib/components/i18n/testing'; let mockHorizontalOverflow = false; jest.mock('../../../lib/components/tabs/scroll-utils', () => { diff --git a/src/tabs/tab-header-bar.tsx b/src/tabs/tab-header-bar.tsx index b4a42e5b58..fceec8dfdf 100644 --- a/src/tabs/tab-header-bar.tsx +++ b/src/tabs/tab-header-bar.tsx @@ -15,7 +15,7 @@ import { } from './scroll-utils'; import { hasModifierKeys, isPlainLeftClick } from '../internal/events'; import { useVisualRefresh } from '../internal/hooks/use-visual-mode'; -import { useInternalI18n } from '../internal/i18n/context'; +import { useInternalI18n } from '../i18n/context'; import { useContainerQuery } from '@cloudscape-design/component-toolkit'; export interface TabHeaderBarProps { diff --git a/src/tag-editor/__tests__/tag-editor.test.tsx b/src/tag-editor/__tests__/tag-editor.test.tsx index e998ffec14..2a420b606f 100644 --- a/src/tag-editor/__tests__/tag-editor.test.tsx +++ b/src/tag-editor/__tests__/tag-editor.test.tsx @@ -7,7 +7,7 @@ import TagEditor, { TagEditorProps } from '../../../lib/components/tag-editor'; import createWrapper, { TagEditorWrapper } from '../../../lib/components/test-utils/dom'; import { i18nStrings, MAX_KEY_LENGTH, MAX_VALUE_LENGTH } from './common'; -import TestI18nProvider from '../../../lib/components/internal/i18n/testing'; +import TestI18nProvider from '../../../lib/components/i18n/testing'; const defaultProps = { i18nStrings, diff --git a/src/tag-editor/index.tsx b/src/tag-editor/index.tsx index cea6216164..05a80ab978 100644 --- a/src/tag-editor/index.tsx +++ b/src/tag-editor/index.tsx @@ -24,7 +24,7 @@ import styles from './styles.css.js'; import { applyDisplayName } from '../internal/utils/apply-display-name'; import useBaseComponent from '../internal/hooks/use-base-component'; import LiveRegion from '../internal/components/live-region'; -import { useInternalI18n } from '../internal/i18n/context'; +import { useInternalI18n } from '../i18n/context'; export { TagEditorProps }; diff --git a/src/tag-editor/validation.ts b/src/tag-editor/validation.ts index 6f06fa322a..c62baddf31 100644 --- a/src/tag-editor/validation.ts +++ b/src/tag-editor/validation.ts @@ -1,6 +1,6 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -import { ComponentFormatFunction } from '../internal/i18n/context'; +import { ComponentFormatFunction } from '../i18n/context'; import { TagEditorProps } from './interfaces'; /** diff --git a/src/tiles/tile.tsx b/src/tiles/tile.tsx index 2d1621f010..e96e8cf8a0 100644 --- a/src/tiles/tile.tsx +++ b/src/tiles/tile.tsx @@ -23,7 +23,6 @@ interface TileProps { export const Tile = React.forwardRef( ({ item, selected, name, breakpoint, onChange }: TileProps, forwardedRef: React.Ref) => { const internalRef = useRef(null); - const controlId = item.controlId || `${name}-value-${item.value}`; const isVisualRefresh = useVisualRefresh(); const mergedRef = useMergeRefs(internalRef, forwardedRef); @@ -58,7 +57,7 @@ export const Tile = React.forwardRef( label={item.label} description={item.description} disabled={item.disabled} - controlId={controlId} + controlId={item.controlId} />
{item.image &&
{item.image}
} diff --git a/src/token-group/__tests__/token-group.test.tsx b/src/token-group/__tests__/token-group.test.tsx index ac46004966..1a74b7be05 100644 --- a/src/token-group/__tests__/token-group.test.tsx +++ b/src/token-group/__tests__/token-group.test.tsx @@ -11,7 +11,7 @@ import icons from '../../../lib/components/icon/icons'; import selectors from '../../../lib/components/token-group/styles.selectors.js'; import optionSelectors from '../../../lib/components/internal/components/option/styles.selectors.js'; import tokenListSelectors from '../../../lib/components/internal/components/token-list/styles.selectors.js'; -import TestI18nProvider from '../../../lib/components/internal/i18n/testing'; +import TestI18nProvider from '../../../lib/components/i18n/testing'; function renderTokenGroup(props: TokenGroupProps = {}): TokenGroupWrapper { const { container } = render(); diff --git a/src/top-navigation/__tests__/top-navigation.test.tsx b/src/top-navigation/__tests__/top-navigation.test.tsx index fb2beb6ac0..460fdc677a 100644 --- a/src/top-navigation/__tests__/top-navigation.test.tsx +++ b/src/top-navigation/__tests__/top-navigation.test.tsx @@ -10,7 +10,7 @@ import createWrapper from '../../../lib/components/test-utils/dom'; import TopNavigationWrapper, { OverflowMenu as OverflowMenuWrapper, } from '../../../lib/components/test-utils/dom/top-navigation'; -import TestI18nProvider from '../../../lib/components/internal/i18n/testing'; +import TestI18nProvider from '../../../lib/components/i18n/testing'; export const I18N_STRINGS: TopNavigationProps.I18nStrings = { searchIconAriaLabel: 'Search', diff --git a/src/top-navigation/internal.tsx b/src/top-navigation/internal.tsx index 295b9ad158..d087a0730a 100644 --- a/src/top-navigation/internal.tsx +++ b/src/top-navigation/internal.tsx @@ -19,7 +19,7 @@ import { ButtonTrigger } from '../internal/components/menu-dropdown'; import styles from './styles.css.js'; import { checkSafeUrl } from '../internal/utils/check-safe-url'; import { SomeRequired } from '../internal/types'; -import { useInternalI18n } from '../internal/i18n/context'; +import { useInternalI18n } from '../i18n/context'; export type InternalTopNavigationProps = SomeRequired & InternalBaseComponentProps; diff --git a/src/top-navigation/parts/overflow-menu/index.tsx b/src/top-navigation/parts/overflow-menu/index.tsx index 70fe885659..65f30f45d5 100644 --- a/src/top-navigation/parts/overflow-menu/index.tsx +++ b/src/top-navigation/parts/overflow-menu/index.tsx @@ -10,7 +10,7 @@ import { HeaderProps } from './header'; import styles from '../../styles.css.js'; import { TopNavigationProps } from '../../interfaces'; -import { useInternalI18n } from '../../../internal/i18n/context'; +import { useInternalI18n } from '../../../i18n/context'; interface OverflowMenuProps { headerText?: string; items?: TopNavigationProps['utilities']; diff --git a/src/wizard/__tests__/wizard.test.tsx b/src/wizard/__tests__/wizard.test.tsx index 69fafd4d02..f0a15a7f07 100644 --- a/src/wizard/__tests__/wizard.test.tsx +++ b/src/wizard/__tests__/wizard.test.tsx @@ -7,7 +7,7 @@ import liveRegionStyles from '../../../lib/components/internal/components/live-r import createWrapper from '../../../lib/components/test-utils/dom'; import Button from '../../../lib/components/button'; import Wizard, { WizardProps } from '../../../lib/components/wizard'; -import TestI18nProvider from '../../../lib/components/internal/i18n/testing'; +import TestI18nProvider from '../../../lib/components/i18n/testing'; import styles from '../../../lib/components/wizard/styles.selectors.js'; import { DEFAULT_I18N_SETS, DEFAULT_STEPS } from './common'; diff --git a/src/wizard/internal.tsx b/src/wizard/internal.tsx index ecf22be8e0..eebfee85a8 100644 --- a/src/wizard/internal.tsx +++ b/src/wizard/internal.tsx @@ -13,7 +13,7 @@ import { useMergeRefs } from '../internal/hooks/use-merge-refs'; import { useVisualRefresh } from '../internal/hooks/use-visual-mode'; import { InternalBaseComponentProps } from '../internal/hooks/use-base-component'; -import { useInternalI18n } from '../internal/i18n/context'; +import { useInternalI18n } from '../i18n/context'; import { FunnelMetrics } from '../internal/analytics'; import { useFunnel } from '../internal/analytics/hooks/use-funnel'; diff --git a/src/wizard/wizard-form.tsx b/src/wizard/wizard-form.tsx index a0bc70e1b1..dbd4147dbf 100644 --- a/src/wizard/wizard-form.tsx +++ b/src/wizard/wizard-form.tsx @@ -63,49 +63,57 @@ export default function WizardForm({ return ( <> - -
- {i18nStrings.collapsedStepsLabel?.(activeStepIndex + 1, steps.length)} -
- - - {title} - {isOptional && {` - ${i18nStrings.optional}`}} - - -
{({ funnelStepProps }) => ( - onSkipToClick(skipToTargetIndex)} - showPrevious={activeStepIndex !== 0} - isPrimaryLoading={isPrimaryLoading} - showSkipTo={showSkipTo} - skipToButtonText={skipToButtonText} - /> - } - secondaryActions={secondaryActions} - errorText={errorText} - errorIconAriaLabel={i18nStrings.errorIconAriaLabel} - {...funnelStepProps} - > - {content} - + <> + +
+ {i18nStrings.collapsedStepsLabel?.(activeStepIndex + 1, steps.length)} +
+ + + {title} + {isOptional && {` - ${i18nStrings.optional}`}} + + +
+ + onSkipToClick(skipToTargetIndex)} + showPrevious={activeStepIndex !== 0} + isPrimaryLoading={isPrimaryLoading} + showSkipTo={showSkipTo} + skipToButtonText={skipToButtonText} + /> + } + secondaryActions={secondaryActions} + errorText={errorText} + errorIconAriaLabel={i18nStrings.errorIconAriaLabel} + {...funnelStepProps} + > + {content} + + )}