diff --git a/.storybook/main.js b/.storybook/main.js index 7dbb1d398f..3a2be1e3f7 100644 --- a/.storybook/main.js +++ b/.storybook/main.js @@ -3,9 +3,12 @@ const createCompiler = require('@storybook/addon-docs/mdx-compiler-plugin'); const modulesPath = path.resolve(__dirname, '../modules'); const getSpecifications = require('../modules/docs/utils/get-specifications'); +const {createDocProgram} = require('../modules/docs/docgen/createDocProgram'); const processDocs = process.env.SKIP_DOCGEN !== 'true'; +const Doc = createDocProgram(); + module.exports = { stories: [ '../modules/docs/mdx/**/*.mdx', @@ -64,8 +67,18 @@ module.exports = { include: [modulesPath], exclude: /examples|stories|spec|codemod|docs/, loaders: [ + // loaders are run in reverse order. style-transform-loader needs to be done first { loader: path.resolve(__dirname, 'symbol-doc-loader'), + options: { + Doc, + }, + }, + { + loader: path.resolve(__dirname, 'style-transform-loader'), + options: { + Doc, + }, }, ], enforce: 'pre', diff --git a/.storybook/routes.js b/.storybook/routes.js index a79057bd52..f0dfd354fe 100644 --- a/.storybook/routes.js +++ b/.storybook/routes.js @@ -12,7 +12,7 @@ const routes = { '/components/buttons/segmented-control/': 'preview-segmented-control--basic', '/components/containers/card/': 'components-containers-card--basic', '/components/containers/side-panel/': 'preview-side-panel--basic', - '/components/containers/table/': 'preview-table--basic', + '/components/containers/table/': 'components-containers-table--basic', '/components/containers/tabs/': 'components-containers-tabs--basic', '/components/indicators/banner/': 'components-indicators-banner--basic', '/components/indicators/loading-dots/': 'components-indicators-loading-dots--basic', @@ -20,7 +20,7 @@ const routes = { '/components/indicators/status-indicator/': 'preview-status-indicator--basic', '/components/inputs/checkbox/': 'components-inputs-checkbox--basic', '/components/inputs/color-input/': 'components-inputs-color-picker-color-input--basic', - '/components/inputs/form-field/': 'components-inputs-form-field--basic', + '/components/inputs/form-field/': 'preview-inputs-form-field--basic', '/components/inputs/radio/': 'components-inputs-radio--basic', '/components/inputs/select/': 'components-inputs-select--basic', '/components/inputs/switch/': 'components-inputs-switch--basic', diff --git a/.storybook/style-transform-loader.js b/.storybook/style-transform-loader.js new file mode 100644 index 0000000000..77b499a6cb --- /dev/null +++ b/.storybook/style-transform-loader.js @@ -0,0 +1,33 @@ +// @ts-check +const {getOptions} = require('loader-utils'); +const {transform} = require('@workday/canvas-kit-styling-transform/testing'); + +/** @typedef {import('webpack').loader.Loader} Loader */ +/** @typedef {import('webpack').loader.LoaderContext} LoaderContext */ + +// Tracks files that have been processed. If a file is already processed, it +// means the file has been updated and we need to update the Typescript program +// so the changes are reflected in our doc output. If we don't update the TS +// program, the docs will be processed with the outdated cache of the file +// contents. +const filesProcessedMap = new Map(); + +/** + * @this {LoaderContext} + * @param {Parameters[0]} source + */ +function styleTransformLoader(source) { + const { + /** @type {any} */ + Doc, + } = getOptions(this); + + if (filesProcessedMap.has(this.resourcePath)) { + Doc.update(); + } + filesProcessedMap.set(this.resourcePath, true); + + return transform(Doc.program, this.resourcePath); +} + +module.exports = styleTransformLoader; diff --git a/.storybook/symbol-doc-loader.js b/.storybook/symbol-doc-loader.js index c0a2f37c85..9c0b39a1c3 100644 --- a/.storybook/symbol-doc-loader.js +++ b/.storybook/symbol-doc-loader.js @@ -1,32 +1,23 @@ // @ts-check -const {createDocProgram} = require('../modules/docs/docgen/createDocProgram'); const routes = require('./routes'); +const {getOptions} = require('loader-utils'); const routeKeys = Object.keys(routes); -// Tracks files that have been processed. If a file is already processed, it -// means the file has been updated and we need to update the Typescript program -// so the changes are reflected in our doc output. If we don't update the TS -// program, the docs will be processed with the outdated cache of the file -// contents. -const filesProcessedMap = new Map(); - /** @typedef {import('webpack').loader.Loader} Loader */ /** @typedef {import('webpack').loader.LoaderContext} LoaderContext */ -let {parser, update} = createDocProgram(); - /** * @this {LoaderContext} * @param {Parameters[0]} source */ function symbolDocLoader(source) { - if (filesProcessedMap.has(this.resourcePath)) { - parser = update(); - } - filesProcessedMap.set(this.resourcePath, true); + const { + /** @type {any} */ + Doc, + } = getOptions(this); - const docs = parser.getExportedSymbols(this.resourcePath); + const docs = Doc.parser.getExportedSymbols(this.resourcePath); return ( source + diff --git a/CHANGELOG.md b/CHANGELOG.md index f7a59a65dd..fa820666da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,24 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### Components - fix: Handle empty stack ref in useAssistiveHideSiblings ([#2920](https://github.com/Workday/canvas-kit/pull/2920)) ([@NicholasBoll](https://github.com/NicholasBoll)) +## [v11.1.10](https://github.com/Workday/canvas-kit/releases/tag/v11.1.10) (2024-09-16) + + + + +## [v11.1.9](https://github.com/Workday/canvas-kit/releases/tag/v11.1.9) (2024-09-16) + +### Documentation, examples + +- docs: Fixing NotificationBadge storybook example ([#2903](https://github.com/Workday/canvas-kit/pull/2903)) ([@williamjstanton](https://github.com/williamjstanton), William Stanton) + + +## [v11.1.8](https://github.com/Workday/canvas-kit/releases/tag/v11.1.8) (2024-09-06) + +### Components + +- fix: Updated ButtonColors interface to deprecated focusRing from focus ([#2906](https://github.com/Workday/canvas-kit/pull/2906)) ([@josh-bagwell](https://github.com/josh-bagwell)) + Deprecated the use of focusRing within focus in the colors prop on buttons as this does not work with our current styling methods. Added support for boxShadowInner and boxShadowOuter within focus in colors prop. ## [v10.3.59](https://github.com/Workday/canvas-kit/releases/tag/v10.3.59) (2024-09-06) @@ -16,6 +34,26 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline - fix: Updated ButtonColors interface to deprecated focusRing from focus ([#2906](https://github.com/Workday/canvas-kit/pull/2906)) ([@josh-bagwell](https://github.com/josh-bagwell)) Deprecated the use of focusRing within focus in the colors prop on buttons as this does not work with our current styling methods. Added support for boxShadowInner and boxShadowOuter within focus in colors prop. +## [v11.1.7](https://github.com/Workday/canvas-kit/releases/tag/v11.1.7) (2024-08-29) + +### Accessibility + +- fix(color-picker): Add support for a11y labels on color swatches ([#2894](https://github.com/Workday/canvas-kit/pull/2894)) ([@wooksauce](https://github.com/wooksauce), Kiwook Kwon) + + +## [v11.1.6](https://github.com/Workday/canvas-kit/releases/tag/v11.1.6) (2024-08-27) + +### Components + +- fix: Make overflow items inert ([#2886](https://github.com/Workday/canvas-kit/pull/2886)) ([@NicholasBoll](https://github.com/NicholasBoll), manuel.carrera) +- fix(select): Forward ref to Select input ([#2892](https://github.com/Workday/canvas-kit/pull/2892)) ([@mannycarrera4](https://github.com/mannycarrera4), manuel.carrera) + +### Infrastructure + +- fix: Enable styling compat mode to ensure proper style merging ([#2890](https://github.com/Workday/canvas-kit/pull/2890)) ([@mannycarrera4](https://github.com/mannycarrera4), manuel.carrera) + We're seeing style merging issues when using createStyles or createStencil. It only happens when every style override of the element uses these utilities and @emotion/react or @emotion/styled is not used on the same element. These utilities rely on module execution order and we're having a few reports where modules are possibly executing out of order. In order to allow everyone to use createStyles and createStencil without worrying about style merge issues, we're going to enable compat mode all the time. We'll look into possible out-of-order execution issues in the future and plan to re-enable full static mode (for better performance) once we know why this is happening and have a proper workaround. + + For more information, please read our [discussion](https://github.com/Workday/canvas-kit/discussions/2893) ## [v10.3.58](https://github.com/Workday/canvas-kit/releases/tag/v10.3.58) (2024-08-27) @@ -40,6 +78,11 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline We're seeing style merging issues when using createStyles or createStencil. It only happens when every style override of the element uses these utilities and @emotion/react or @emotion/styled is not used on the same element. These utilities rely on module execution order and we're having a few reports where modules are possibly executing out of order. In order to allow everyone to use createStyles and createStencil without worrying about style merge issues, we're going to enable compat mode all the time. We'll look into possible out-of-order execution issues in the future and plan to re-enable full static mode (for better performance) once we know why this is happening and have a proper workaround. For more information, please read our [discussion](https://github.com/Workday/canvas-kit/discussions/2893) +## [v11.1.5](https://github.com/Workday/canvas-kit/releases/tag/v11.1.5) (2024-08-23) + +### Components + +- fix(combobox): Show selected state when multiple is enabled ([#2882](https://github.com/Workday/canvas-kit/pull/2882)) ([@NicholasBoll](https://github.com/NicholasBoll)) ## [v10.3.55](https://github.com/Workday/canvas-kit/releases/tag/v10.3.55) (2024-08-22) @@ -47,6 +90,11 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### Components - fix(combobox): Show selected state when multiple is enabled ([#2882](https://github.com/Workday/canvas-kit/pull/2882)) ([@NicholasBoll](https://github.com/NicholasBoll)) +## [v11.1.4](https://github.com/Workday/canvas-kit/releases/tag/v11.1.4) (2024-08-21) + +### Documentation + +- docs: Update CanvasProvider info on install page ([#2878](https://github.com/Workday/canvas-kit/pull/2878)) ([@mannycarrera4](https://github.com/mannycarrera4), manuel.carrera, [@alanbsmith](https://github.com/alanbsmith)) ## [v10.3.54](https://github.com/Workday/canvas-kit/releases/tag/v10.3.54) (2024-08-21) @@ -54,6 +102,11 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### Documentation - docs: Update CanvasProvider info on install page ([#2878](https://github.com/Workday/canvas-kit/pull/2878)) ([@mannycarrera4](https://github.com/mannycarrera4), manuel.carrera, [@alanbsmith](https://github.com/alanbsmith)) +## [v11.1.3](https://github.com/Workday/canvas-kit/releases/tag/v11.1.3) (2024-08-20) + +### Components + +- fix: Update select to trigger onChange ([#2874](https://github.com/Workday/canvas-kit/pull/2874)) ([@mannycarrera4](https://github.com/mannycarrera4), manuel.carrera) ## [v10.3.53](https://github.com/Workday/canvas-kit/releases/tag/v10.3.53) (2024-08-20) @@ -61,6 +114,16 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### Components - fix: Update select to trigger onChange ([#2874](https://github.com/Workday/canvas-kit/pull/2874)) ([@mannycarrera4](https://github.com/mannycarrera4), manuel.carrera) +## [v11.1.2](https://github.com/Workday/canvas-kit/releases/tag/v11.1.2) (2024-08-20) + + + + +## [v11.1.1](https://github.com/Workday/canvas-kit/releases/tag/v11.1.1) (2024-08-20) + +### Components + +- fix(select): Clicking the input closes the menu ([#2869](https://github.com/Workday/canvas-kit/pull/2869)) ([@NicholasBoll](https://github.com/NicholasBoll)) ## [v10.3.52](https://github.com/Workday/canvas-kit/releases/tag/v10.3.52) (2024-08-14) @@ -68,6 +131,23 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### Components - fix(select): Clicking the input closes the menu ([#2869](https://github.com/Workday/canvas-kit/pull/2869)) ([@NicholasBoll](https://github.com/NicholasBoll)) +## [v11.1.0](https://github.com/Workday/canvas-kit/releases/tag/v11.1.0) (2024-08-14) + + + + +## [v11.0.27](https://github.com/Workday/canvas-kit/releases/tag/v11.0.27) (2024-08-12) + +### Components + +- fix(Checkbox): Remove console warning ([#2863](https://github.com/Workday/canvas-kit/pull/2863)) ([@thunguyen19](https://github.com/thunguyen19)) + + +## [v11.0.26](https://github.com/Workday/canvas-kit/releases/tag/v11.0.26) (2024-08-05) + +### Accessibility + +- fix: Set aria-modal to false for better accessibility ([#2855](https://github.com/Workday/canvas-kit/pull/2855)) ([@mannycarrera4](https://github.com/mannycarrera4), manuel.carrera) ## [v10.3.51](https://github.com/Workday/canvas-kit/releases/tag/v10.3.51) (2024-08-05) @@ -75,6 +155,12 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### Accessibility - fix: Set aria-modal to false for better accessibility ([#2855](https://github.com/Workday/canvas-kit/pull/2855)) ([@mannycarrera4](https://github.com/mannycarrera4), manuel.carrera) +## [v11.0.25](https://github.com/Workday/canvas-kit/releases/tag/v11.0.25) (2024-08-05) + +### Components + +- fix(combobox): Use correct state for aria-selected ([#2849](https://github.com/Workday/canvas-kit/pull/2849)) ([@NicholasBoll](https://github.com/NicholasBoll)) + This change fixes `aria-selected` in `Combobox.Menu.Item` components, but this does change the visuals of what is considered "selected". If you have any visual tests that have a screenshot of a selected state, the visual regression will have to be updated. The same is true for DOM-based snapshot tests. `aria-selected="true"` will now be added when an item is selected and not just when the virtual cursor is on the item. If your snapshot captures this DOM state, the snapshot will have to be updated. ## [v10.3.50](https://github.com/Workday/canvas-kit/releases/tag/v10.3.50) (2024-08-05) @@ -83,6 +169,18 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline - fix(combobox): Use correct state for aria-selected ([#2849](https://github.com/Workday/canvas-kit/pull/2849)) ([@NicholasBoll](https://github.com/NicholasBoll)) This change fixes `aria-selected` in `Combobox.Menu.Item` components, but this does change the visuals of what is considered "selected". If you have any visual tests that have a screenshot of a selected state, the visual regression will have to be updated. The same is true for DOM-based snapshot tests. `aria-selected="true"` will now be added when an item is selected and not just when the virtual cursor is on the item. If your snapshot captures this DOM state, the snapshot will have to be updated. +## [v11.0.24](https://github.com/Workday/canvas-kit/releases/tag/v11.0.24) (2024-08-05) + +### Components + +- fix(SearchForm): Suppress forwarding props warning ([#2850](https://github.com/Workday/canvas-kit/pull/2850)) ([@thunguyen19](https://github.com/thunguyen19), Thu Nguyen) + + +## [v11.0.23](https://github.com/Workday/canvas-kit/releases/tag/v11.0.23) (2024-07-30) + +### Components + +- fix: Support marginTop and marginBottom on ListBox ([#2844](https://github.com/Workday/canvas-kit/pull/2844)) ([@NicholasBoll](https://github.com/NicholasBoll)) ## [v10.3.49](https://github.com/Workday/canvas-kit/releases/tag/v10.3.49) (2024-07-29) @@ -92,16 +190,40 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline - fix: Support marginTop and marginBottom on ListBox ([#2844](https://github.com/Workday/canvas-kit/pull/2844)) ([@NicholasBoll](https://github.com/NicholasBoll)) +## [v11.0.22](https://github.com/Workday/canvas-kit/releases/tag/v11.0.22) (2024-07-29) + +### Documentation + +- docs: Fix stencil docs typo ([#2847](https://github.com/Workday/canvas-kit/pull/2847)) ([@alanbsmith](https://github.com/alanbsmith)) + + +## [v10.3.48](https://github.com/Workday/canvas-kit/releases/tag/v10.3.48) (2024-07-24) +## [v11.0.21](https://github.com/Workday/canvas-kit/releases/tag/v11.0.21) (2024-07-24) + +### Documentation + +- fix: Fix Popup ExternalWindow example import ([#2841](https://github.com/Workday/canvas-kit/pull/2841)) ([@jamesfan](https://github.com/jamesfan)) + + ## [v10.3.48](https://github.com/Workday/canvas-kit/releases/tag/v10.3.48) (2024-07-24) ### Documentation - fix: Fix Popup ExternalWindow example import ([#2841](https://github.com/Workday/canvas-kit/pull/2841)) ([@jamesfan](https://github.com/jamesfan)) +## [v11.0.20](https://github.com/Workday/canvas-kit/releases/tag/v11.0.20) (2024-07-22) + + ## [v10.3.47](https://github.com/Workday/canvas-kit/releases/tag/v10.3.47) (2024-07-22) +## [v11.0.19](https://github.com/Workday/canvas-kit/releases/tag/v11.0.19) (2024-07-19) + +### Components + +- fix(avatar): Lazy load avatar images ([#2834](https://github.com/Workday/canvas-kit/pull/2834)) ([@NicholasBoll](https://github.com/NicholasBoll)) +- fix: Popups render in the target's window ([#2829](https://github.com/Workday/canvas-kit/pull/2829)) ([@NicholasBoll](https://github.com/NicholasBoll), [@mannycarrera4](https://github.com/mannycarrera4)) ## [v10.3.46](https://github.com/Workday/canvas-kit/releases/tag/v10.3.46) (2024-07-19) @@ -116,6 +238,32 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### Components - fix(avatar): Lazy load avatar images ([#2834](https://github.com/Workday/canvas-kit/pull/2834)) ([@NicholasBoll](https://github.com/NicholasBoll)) +## [v11.0.18](https://github.com/Workday/canvas-kit/releases/tag/v11.0.18) (2024-07-18) + +### Components + +- fix(avatar): Lazy load avatar images ([#2833](https://github.com/Workday/canvas-kit/pull/2833)) ([@NicholasBoll](https://github.com/NicholasBoll)) + + +## [v11.0.17](https://github.com/Workday/canvas-kit/releases/tag/v11.0.17) (2024-07-17) + +### Documentation + +- docs: Fixing and updating the AriaLiveRegion storybook examples ([#2818](https://github.com/Workday/canvas-kit/pull/2818)) ([@williamjstanton](https://github.com/williamjstanton), William Stanton, [@mannycarrera4](https://github.com/mannycarrera4), [@josh-bagwell](https://github.com/josh-bagwell), manuel.carrera) + + +## [v11.0.16](https://github.com/Workday/canvas-kit/releases/tag/v11.0.16) (2024-07-17) + +### Infrastructure + +- chore: SNYK Security upgrade markdown-to-jsx from 6.11.4 to 7.2.0 ([#2826](https://github.com/Workday/canvas-kit/pull/2826)) ([@mannycarrera4](https://github.com/mannycarrera4), [@snyk-bot](https://github.com/snyk-bot), manuel.carrera) + + +## [v11.0.15](https://github.com/Workday/canvas-kit/releases/tag/v11.0.15) (2024-07-11) + +### Components + +- fix(select): Add conditional for Select in React.StrictMode ([#2822](https://github.com/Workday/canvas-kit/pull/2822)) ([@NicholasBoll](https://github.com/NicholasBoll)) ## [v10.3.44](https://github.com/Workday/canvas-kit/releases/tag/v10.3.44) (2024-07-10) @@ -123,6 +271,44 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### Components - fix(select): Add conditional for Select in React.StrictMode ([#2822](https://github.com/Workday/canvas-kit/pull/2822)) ([@NicholasBoll](https://github.com/NicholasBoll)) +## [v11.0.14](https://github.com/Workday/canvas-kit/releases/tag/v11.0.14) (2024-07-10) + +### Components + +- fix: Upgrade vulnerable packages for security ([#2812](https://github.com/Workday/canvas-kit/pull/2812)) ([@mannycarrera4](https://github.com/mannycarrera4), manuel.carrera) + + +## [v11.0.13](https://github.com/Workday/canvas-kit/releases/tag/v11.0.13) (2024-07-09) + +### Components + +- fix: Prevent style-only props from being forwarded to elements ([#2819](https://github.com/Workday/canvas-kit/pull/2819)) ([@wainokray-ho](https://github.com/wainokray-ho)) + + +## [v11.0.12](https://github.com/Workday/canvas-kit/releases/tag/v11.0.12) (2024-07-08) + +### Components + +- fix: Fix backwards compatibility with colors prop for buttons ([#2816](https://github.com/Workday/canvas-kit/pull/2816)) ([@mannycarrera4](https://github.com/mannycarrera4), manuel.carrera) + +### Infrastructure + +- fix: Revert jscodeshift version ([#2813](https://github.com/Workday/canvas-kit/pull/2813)) ([@mannycarrera4](https://github.com/mannycarrera4), manuel.carrera) + + +## [v11.0.11](https://github.com/Workday/canvas-kit/releases/tag/v11.0.11) (2024-06-26) + +### Infrastructure + +- chore: Update SNYK deps to non vulnerable versions ([#2784](https://github.com/Workday/canvas-kit/pull/2784)) ([@mannycarrera4](https://github.com/mannycarrera4), manuel.carrera) + Fix some security issues found by SNYK in our codemod package. + + +## [v11.0.10](https://github.com/Workday/canvas-kit/releases/tag/v11.0.10) (2024-06-26) + +### Components + +- fix: Grow Prop Fix for Buttons ([#2790](https://github.com/Workday/canvas-kit/pull/2790)) ([@josh-bagwell](https://github.com/josh-bagwell), [@mannycarrera4](https://github.com/mannycarrera4)) ## [v10.3.43](https://github.com/Workday/canvas-kit/releases/tag/v10.3.43) (2024-06-25) @@ -130,6 +316,35 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### Components - fix: Grow Prop Fix for Buttons ([#2790](https://github.com/Workday/canvas-kit/pull/2790)) ([@josh-bagwell](https://github.com/josh-bagwell), [@mannycarrera4](https://github.com/mannycarrera4)) +## [v11.0.9](https://github.com/Workday/canvas-kit/releases/tag/v11.0.9) (2024-06-24) + +### Documentation + +- docs: Add v10 to versions table ([#2792](https://github.com/Workday/canvas-kit/pull/2792)) ([@sheelah](https://github.com/sheelah), Sheelah Brennan) + + +## [v11.0.8](https://github.com/Workday/canvas-kit/releases/tag/v11.0.8) (2024-06-18) + + + + +## [v11.0.7](https://github.com/Workday/canvas-kit/releases/tag/v11.0.7) (2024-06-17) + +### Documentation + +- chore: Add robust example in storybook for ToolbarDropdown button ([#2782](https://github.com/Workday/canvas-kit/pull/2782)) ([@NehaAhujaa](https://github.com/NehaAhujaa), Neha Ahuja) + +### Infrastructure + +- fix: Delete unused folder ([#2771](https://github.com/Workday/canvas-kit/pull/2771)) ([@mannycarrera4](https://github.com/mannycarrera4), manuel.carrera) + + +## [v11.0.6](https://github.com/Workday/canvas-kit/releases/tag/v11.0.6) (2024-06-10) + +### Components + +- fix: Prevent undefined from overriding model defaultConfig ([#2766](https://github.com/Workday/canvas-kit/pull/2766)) ([@NicholasBoll](https://github.com/NicholasBoll)) +- fix(select): Update aria-haspopup to 'menu' ([#2760](https://github.com/Workday/canvas-kit/pull/2760)) ([@NicholasBoll](https://github.com/NicholasBoll)) ## [v10.3.42](https://github.com/Workday/canvas-kit/releases/tag/v10.3.42) (2024-06-10) @@ -144,6 +359,131 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### Components - fix: Prevent undefined from overriding model defaultConfig ([#2766](https://github.com/Workday/canvas-kit/pull/2766)) ([@NicholasBoll](https://github.com/NicholasBoll)) +## [v11.0.5](https://github.com/Workday/canvas-kit/releases/tag/v11.0.5) (2024-06-10) + +### Components + +- fix: Fix backwards compatibility for hover state colors in System Icon ([#2764](https://github.com/Workday/canvas-kit/pull/2764)) ([@RayRedGoose](https://github.com/RayRedGoose)) + + +## [v11.0.4](https://github.com/Workday/canvas-kit/releases/tag/v11.0.4) (2024-06-10) + +### Dependencies + +- chore: Updated Canvas Tokens Web Dependency to version 2.0.0 ([#2762](https://github.com/Workday/canvas-kit/pull/2762)) ([@josh-bagwell](https://github.com/josh-bagwell)) + + +## [v11.0.3](https://github.com/Workday/canvas-kit/releases/tag/v11.0.3) (2024-05-28) + +### Components + +- chore: Updated mergeStyles to accept grid styleprops ([#2759](https://github.com/Workday/canvas-kit/pull/2759)) ([@josh-bagwell](https://github.com/josh-bagwell)) + + +## [v11.0.2](https://github.com/Workday/canvas-kit/releases/tag/v11.0.2) (2024-05-28) + +### Documentation + +- docs: Update v11 upgrade guide ([@alanbsmith](https://github.com/alanbsmith)) + + +## [v11.0.1](https://github.com/Workday/canvas-kit/releases/tag/v11.0.1) (2024-05-24) + +### Documentation + +- fix: Add explicit info about tokens ([#2754](https://github.com/Workday/canvas-kit/pull/2754)) ([@mannycarrera4](https://github.com/mannycarrera4), manuel.carrera, [@josh-bagwell](https://github.com/josh-bagwell)) + + +## [v11.0.0](https://github.com/Workday/canvas-kit/releases/tag/v11.0.0) (2024-05-22) + +### BREAKING CHANGES + +- [#2472](https://github.com/Workday/canvas-kit/pull/2472) - The prop `hasError` for Preview components `FormField`, `TexInput` and `TextArea` have been renamed to `error` and accepts the values: `"error" | "alert" | undefined` +- [#2546](https://github.com/Workday/canvas-kit/pull/2546) There may be slight visual changes. +- [#2567](https://github.com/Workday/canvas-kit/pull/2567) There may be slight visual changes. +- [#2583](https://github.com/Workday/canvas-kit/pull/2583) There may be slight visual changes. +- [#2600](https://github.com/Workday/canvas-kit/pull/2600) - `rowState` no longer exists. + - The component is now a compound component with access to lower level elements. +- [#2615](https://github.com/Workday/canvas-kit/pull/2615) Impacts only internal Canvas Kit code. `Icon` component has been removed and no longer used. +- [#2697](https://github.com/Workday/canvas-kit/pull/2697) Adds `box-sizing: border-box` to all stencils. If your stencil did not add this style already, it may change the way `width` works for the component. Our intent is to make all elements use border box layouts to make width calculations more predictable. This change may change the way your component works if you use the `width` style property. + +### category + +- chore: Refactor StatusIndicator component ([#2620](https://github.com/Workday/canvas-kit/pull/2620)) ([@harshanarisetty](https://github.com/harshanarisetty)) + `StatusIndicator` now uses [Canvas Tokens](https://workday.github.io/canvas-tokens/?path=/docs/docs-getting-started--docs) and our [new styling utilities](https://workday.github.io/canvas-kit/?path=/docs/styling-basics--create-modifiers#createstyles-api). + The component now supports the `cs` prop, but otherwise the API has not changed. It should behave + identically as it did in previous versions. + +### category + +- feat(loading-dots): Use static styling utilities ([#2540](https://github.com/Workday/canvas-kit/pull/2540)) ([@harshanarisetty](https://github.com/harshanarisetty)) + +### Components + +- chore: Update CountBadge styles ([#2442](https://github.com/Workday/canvas-kit/pull/2442)) ([@alanbsmith](https://github.com/alanbsmith), manuel.carrera) +- feat: Update FormField Preview API to support different inputs ([#2472](https://github.com/Workday/canvas-kit/pull/2472)) ([@mannycarrera4](https://github.com/mannycarrera4), manuel.carrera, [@RayRedGoose](https://github.com/RayRedGoose)) + - `TextInput` from Preview has been deprecated. Please use `FormField` from Preview. + - `TextArea` from Preview has been deprecated. Please use `FormField` from Preview. + - `FormField` from Main has been deprecated. Please use `FormField` from Preview. + - `orientation` prop defaults to `vertical` and is no longer required. + - `FormField.Input` can be used by any `input` + - `FormField` does **not** support the `useFieldSet` prop that the `FormField` in [Main](#main) + does. In order to achieve the same behavior, set the `as` prop on the `FormField` element to + `fieldset` and the `as` prop of `FormField.Label` to `legend` +- feat: Text style refactoring ([#2455](https://github.com/Workday/canvas-kit/pull/2455)) ([@RayRedGoose](https://github.com/RayRedGoose), [@mannycarrera4](https://github.com/mannycarrera4), manuel.carrera) + Text related components have been refactored to support the new `cs` prop and v10 styling utilities. Type level components,`Title`, `Heading`, `BodyText` and `Subtext`, as well as `Text` and `LabelText` updated to use the new system level tokens via CSS variables from the CanvasProvider. `LabelText` has been deprecated. +- chore: Refactor Card Styles ([#2471](https://github.com/Workday/canvas-kit/pull/2471)) ([@alanbsmith](https://github.com/alanbsmith), [@RayRedGoose](https://github.com/RayRedGoose)) +- feat: Component Style Updates from Audit ([#2485](https://github.com/Workday/canvas-kit/pull/2485)) ([@josh-bagwell](https://github.com/josh-bagwell), [@mannycarrera4](https://github.com/mannycarrera4)) + Style updates will have minor visual changes. +- chore: Bump canvas-kit-styling version ([@alanbsmith](https://github.com/alanbsmith)) +- chore: Bump canvas kit styling ([@](https://github.com/)) +- fix: Update testing to use preview formfield ([@](https://github.com/)) +- test: Add inverse variant visual tests ([#2544](https://github.com/Workday/canvas-kit/pull/2544)) ([@RayRedGoose](https://github.com/RayRedGoose)) +- chore: Refactor FormField in Preview to use new styling utilities and tokens ([#2541](https://github.com/Workday/canvas-kit/pull/2541)) ([@mannycarrera4](https://github.com/mannycarrera4), manuel.carrera) + Update FormField in Preview to use our new styling utilities and tokens. +- chore: Radio Styles Refactor ([#2546](https://github.com/Workday/canvas-kit/pull/2546)) ([@josh-bagwell](https://github.com/josh-bagwell)) + `Radio` and `RadioGroup` now use Canvas Tokens and our new styling utilities. The component now supports the `cs` prop, but otherwise the API has not changed. It should behave identically as it did in previous versions however, there may be some slight visual changes. +- chore: Refactor Checkbox styles ([#2542](https://github.com/Workday/canvas-kit/pull/2542)) ([@RayRedGoose](https://github.com/RayRedGoose), [@mannycarrera4](https://github.com/mannycarrera4), [@alanbsmith](https://github.com/alanbsmith)) + `Checkbox` now uses Canvas Tokens and our new styling utilities. The component now supports the `cs` prop, but otherwise the API has not changed. It should behave identically as it did in previous versions. +- chore: Table(Preview) Styles Refactor ([#2567](https://github.com/Workday/canvas-kit/pull/2567)) ([@josh-bagwell](https://github.com/josh-bagwell)) + Table now uses Canvas Tokens and our new styling utilities. The component now supports the cs prop, but otherwise the API has not changed. It should behave identically as it did in previous versions however, there may be some slight visual changes. +- fix: Fix build script on css packages ([@NicholasBoll](https://github.com/NicholasBoll)) +- chore: Switch Styles Refactor ([#2583](https://github.com/Workday/canvas-kit/pull/2583)) ([@josh-bagwell](https://github.com/josh-bagwell)) + Switch now uses Canvas Tokens and our new styling utilities. The component now supports the cs prop, but otherwise the API has not changed. It should behave identically as it did in previous versions however, there may be some slight visual changes. +- chore: Updated Radio(Preview) & Table(Preview) with createStencil ([#2585](https://github.com/Workday/canvas-kit/pull/2585)) ([@josh-bagwell](https://github.com/josh-bagwell)) +- chore: Table Promotion from preview ([#2600](https://github.com/Workday/canvas-kit/pull/2600)) ([@josh-bagwell](https://github.com/josh-bagwell)) + We've promoted the compound `Table` component from Preview to Main. This compound component API allows for more flexibility and access to lower level elements. +- feat: Add support for stencil extension ([#2612](https://github.com/Workday/canvas-kit/pull/2612)) ([@NicholasBoll](https://github.com/NicholasBoll)) +- chore: Refactor Select and Combobox to use new styling utilities and tokens ([#2570](https://github.com/Workday/canvas-kit/pull/2570)) ([@mannycarrera4](https://github.com/mannycarrera4), manuel.carrera, [@josh-bagwell](https://github.com/josh-bagwell), [@RayRedGoose](https://github.com/RayRedGoose)) +- chore: Refactor icon components ([#2615](https://github.com/Workday/canvas-kit/pull/2615)) ([@RayRedGoose](https://github.com/RayRedGoose), [@alanbsmith](https://github.com/alanbsmith), [@NicholasBoll](https://github.com/NicholasBoll), [@mannycarrera4](https://github.com/mannycarrera4), manuel.carrera) + Icon components, `Svg`, `SystemIcon`, `AccentIcon`, `AppletIcon`, `Graphic` now uses Canvas Tokens + and new styling utilities. Components now supports the `cs` prop instead `styles`, but otherwise the API has not changed. It should behave similar as it did in previous versions. +- chore: Update Text to use system tokens ([#2659](https://github.com/Workday/canvas-kit/pull/2659)) ([@mannycarrera4](https://github.com/mannycarrera4), manuel.carrera, [@RayRedGoose](https://github.com/RayRedGoose)) + Update our Text components to use our system tokens. +- fix: Make variable names safe for Emotion ([#2687](https://github.com/Workday/canvas-kit/pull/2687)) ([@NicholasBoll](https://github.com/NicholasBoll)) +- chore: Update Card color tokens ([#2682](https://github.com/Workday/canvas-kit/pull/2682)) ([@alanbsmith](https://github.com/alanbsmith)) +- chore: Update FormField and Select to use system colors ([#2685](https://github.com/Workday/canvas-kit/pull/2685)) ([@RayRedGoose](https://github.com/RayRedGoose)) +- chore: Update checkbox to use system color tokens ([#2683](https://github.com/Workday/canvas-kit/pull/2683)) ([@RayRedGoose](https://github.com/RayRedGoose)) +- feat: Add box-sizing:border-box automatically to all stencils ([#2697](https://github.com/Workday/canvas-kit/pull/2697)) ([@NicholasBoll](https://github.com/NicholasBoll)) + +### Documentation + +- fix: Update usage of deprecated form field across examples ([#2491](https://github.com/Workday/canvas-kit/pull/2491)) ([@mannycarrera4](https://github.com/mannycarrera4), manuel.carrera, [@RayRedGoose](https://github.com/RayRedGoose)) +- fix: Update upgrade guide for 11 ([#2678](https://github.com/Workday/canvas-kit/pull/2678)) ([@mannycarrera4](https://github.com/mannycarrera4), manuel.carrera) +- ci: Fix SymbolDoc ([#2696](https://github.com/Workday/canvas-kit/pull/2696)) ([@NicholasBoll](https://github.com/NicholasBoll)) + +### Infrastructure + +- feat: Add initial v11 setup ([#2476](https://github.com/Workday/canvas-kit/pull/2476)) ([@RayRedGoose](https://github.com/RayRedGoose)) +- ci: Fix missing dependency ([@NicholasBoll](https://github.com/NicholasBoll)) +- feat: Generate CSS kits from React kits ([#2578](https://github.com/Workday/canvas-kit/pull/2578)) ([@NicholasBoll](https://github.com/NicholasBoll)) +- feat: Add per-module prefix ([#2582](https://github.com/Workday/canvas-kit/pull/2582)) ([@NicholasBoll](https://github.com/NicholasBoll)) +- chore: Bump canvas-tokens-web ([#2681](https://github.com/Workday/canvas-kit/pull/2681)) ([@alanbsmith](https://github.com/alanbsmith)) +- ci: Run style transform in Storybook ([#2677](https://github.com/Workday/canvas-kit/pull/2677)) ([@NicholasBoll](https://github.com/NicholasBoll)) + +### Styling + +- fix(styling): Fix variables in stencil config ([#2624](https://github.com/Workday/canvas-kit/pull/2624)) ([@NicholasBoll](https://github.com/NicholasBoll)) ## [v10.3.40](https://github.com/Workday/canvas-kit/releases/tag/v10.3.40) (2024-05-17) diff --git a/cypress/integration/RadioPreview.spec.ts b/cypress/integration/RadioPreview.spec.ts index 2d19457d51..55f1b89e93 100644 --- a/cypress/integration/RadioPreview.spec.ts +++ b/cypress/integration/RadioPreview.spec.ts @@ -68,7 +68,7 @@ describe('Radio Preview', () => { }); it(`the "Deep dish" radio button should have an aria-describedby`, () => { - cy.findByLabelText('Deep dish').should('have.attr', 'aria-describedby', 'hint-alert'); + cy.findByLabelText('Deep dish').should('have.attr', 'aria-describedby', 'hint-hint-alert'); }); }); }); diff --git a/lerna.json b/lerna.json index 1ec9070876..af5712dce9 100644 --- a/lerna.json +++ b/lerna.json @@ -2,7 +2,7 @@ "packages": [ "modules/**" ], - "version": "10.3.60", + "version": "11.1.10", "npmClient": "yarn", "useWorkspaces": true, "command": { diff --git a/modules/codemod/index.js b/modules/codemod/index.js index 25bb957c32..f52a5ab1d6 100755 --- a/modules/codemod/index.js +++ b/modules/codemod/index.js @@ -4,7 +4,13 @@ const {spawn} = require('child_process'); const chalk = require('chalk'); -const {_: commands, path, ignoreConfig, ignorePattern, verbose} = require('yargs') +const { + _: commands, + path, + ignoreConfig, + ignorePattern, + verbose, +} = require('yargs') .scriptName('canvas-kit-codemod') .usage(chalk.bold.blueBright('$0 [path]')) .options({ @@ -61,6 +67,13 @@ const {_: commands, path, ignoreConfig, ignorePattern, verbose} = require('yargs describe: chalk.gray('The path to execute the transform in (recursively).'), }); }) + .command('v11 [path]', chalk.gray('Canvas Kit v10 > v11 upgrade transform'), yargs => { + yargs.positional('path', { + type: 'string', + default: '.', + describe: chalk.gray('The path to execute the transform in (recursively).'), + }); + }) .demandCommand(1, chalk.red.bold('You must provide a transform to apply.')) .strictCommands() .fail((msg, err, yargs) => { @@ -84,9 +97,10 @@ const ignoreConfigArg = ignoreConfig ? `--ignore-config=${ignoreConfig}` : ''; console.log(ignorePattern); console.log(chalk.blueBright(`\nApplying ${transform} transform to '${path}'\n`)); -const args = `-t ${__dirname}/dist/es6/${transform} ${path} --parser tsx --extensions js,jsx,ts,tsx ${ignoreConfigArg} --ignore-pattern=${ignorePattern} --verbose=${verbose}`.split( - ' ' -); +const args = + `-t ${__dirname}/dist/es6/${transform} ${path} --parser tsx --extensions js,jsx,ts,tsx ${ignoreConfigArg} --ignore-pattern=${ignorePattern} --verbose=${verbose}`.split( + ' ' + ); const proc = spawn(`jscodeshift`, args); diff --git a/modules/codemod/lib/v11/index.ts b/modules/codemod/lib/v11/index.ts new file mode 100644 index 0000000000..f0816f548d --- /dev/null +++ b/modules/codemod/lib/v11/index.ts @@ -0,0 +1,16 @@ +import {Transform} from 'jscodeshift'; + +import renameHasErrorPreview from './renameHasErrorPreview'; +import replaceStylesIconProp from './replaceStylesIconProp'; + +const transform: Transform = (file, api, options) => { + // These will run in order. If your transform depends on others, place yours after dependent transforms + const fixes = [ + // add codemods here + renameHasErrorPreview, + replaceStylesIconProp, + ]; + return fixes.reduce((source, fix) => fix({...file, source}, api, options) as string, file.source); +}; + +export default transform; diff --git a/modules/codemod/lib/v11/renameHasErrorPreview.ts b/modules/codemod/lib/v11/renameHasErrorPreview.ts new file mode 100644 index 0000000000..85da0fc357 --- /dev/null +++ b/modules/codemod/lib/v11/renameHasErrorPreview.ts @@ -0,0 +1,66 @@ +import {API, FileInfo, Options, JSXOpeningElement, JSXIdentifier} from 'jscodeshift'; +import {hasImportSpecifiers} from '../v6/utils'; +import {getImportRenameMap} from './utils/getImportRenameMap'; +const textInputPackage = '@workday/canvas-kit-preview-react/text-input'; +const textAreaPackage = '@workday/canvas-kit-preview-react/text-area'; +const formFieldPackage = '@workday/canvas-kit-preview-react/form-field'; +const packages = [textInputPackage, textAreaPackage, formFieldPackage]; +const packageImports = ['TextInput', 'FormField', 'TextArea']; + +export default function transformer(file: FileInfo, api: API, options: Options) { + const j = api.jscodeshift; + + const root = j(file.source); + + // exit if the named imports aren't found + if (!hasImportSpecifiers(api, root, packages, packageImports)) { + return file.source; + } + + // getImportRenameMap utility will tell us if the file containsCanvasImports + // and give us an importMap to track what identifiers we need to update + const {importMap, styledMap} = getImportRenameMap(j, root, '@workday/canvas-kit-preview-react'); + + root + .find(j.JSXOpeningElement, (value: JSXOpeningElement) => { + const isCorrectImport = Object.entries(importMap).some( + ([original, imported]) => + imported === (value.name as JSXIdentifier).name && packageImports.includes(original) + ); + + const isCorrectStyled = Object.entries(styledMap).some( + ([original, styled]) => + styled === (value.name as JSXIdentifier).name && packageImports.includes(original) + ); + + return isCorrectImport || isCorrectStyled; + }) + .forEach(nodePath => { + nodePath.node.attributes?.forEach(attr => { + if (attr.type === 'JSXAttribute') { + if (attr.name.name === 'hasError') { + attr.name.name = 'error'; + if (attr.value && attr.value.type === 'JSXExpressionContainer') { + const value = attr.value.expression as any; + + if (value.type === 'BooleanLiteral') { + if (value.value) { + attr.value = j.stringLiteral('error'); + } else { + attr.value = j.jsxExpressionContainer(j.identifier('undefined')); + } + } else if (value.type === 'Identifier') { + attr.value.expression = j.conditionalExpression( + j.identifier(value.name), + j.stringLiteral('error'), + j.identifier('undefined') + ); + } + } + } + } + }); + }); + + return root.toSource(); +} diff --git a/modules/codemod/lib/v11/replaceStylesIconProp.ts b/modules/codemod/lib/v11/replaceStylesIconProp.ts new file mode 100644 index 0000000000..b95b63d8f9 --- /dev/null +++ b/modules/codemod/lib/v11/replaceStylesIconProp.ts @@ -0,0 +1,52 @@ +import {API, FileInfo, Options, JSXOpeningElement, JSXIdentifier} from 'jscodeshift'; +import {hasImportSpecifiers} from '../v6/utils'; +import {getImportRenameMap} from './utils/getImportRenameMap'; + +const packages = ['@workday/canvas-kit-react', '@workday/canvas-kit-react/icon']; +const packageImports = ['Svg', 'SystemIcon', 'AccentIcon']; + +export default function transformer(file: FileInfo, api: API, options: Options) { + const j = api.jscodeshift; + + const root = j(file.source); + + // exit if the named imports aren't found + if (!hasImportSpecifiers(api, root, packages, packageImports)) { + return file.source; + } + + // getImportRenameMap utility will tell us if the file containsCanvasImports + // and give us an importMap to track what identifiers we need to update + const {importMap, styledMap} = getImportRenameMap( + j, + root, + '@workday/canvas-kit-react', + '@workday/canvas-kit-react/icon' + ); + + root + .find(j.JSXOpeningElement, (value: JSXOpeningElement) => { + const isCorrectImport = Object.entries(importMap).some( + ([original, imported]) => + imported === (value.name as JSXIdentifier).name && packageImports.includes(original) + ); + + const isCorrectStyled = Object.entries(styledMap).some( + ([original, styled]) => + styled === (value.name as JSXIdentifier).name && packageImports.includes(original) + ); + + return isCorrectImport || isCorrectStyled; + }) + .forEach(nodePath => { + nodePath.node.attributes?.forEach(attr => { + if (attr.type === 'JSXAttribute') { + if (attr.name.name === 'styles') { + attr.name.name = 'cs'; + } + } + }); + }); + + return root.toSource(); +} diff --git a/modules/codemod/lib/v11/spec/expectTransformFactory.ts b/modules/codemod/lib/v11/spec/expectTransformFactory.ts new file mode 100644 index 0000000000..d2ec7424b0 --- /dev/null +++ b/modules/codemod/lib/v11/spec/expectTransformFactory.ts @@ -0,0 +1,6 @@ +import {runInlineTest} from 'jscodeshift/dist/testUtils'; + +export const expectTransformFactory = + (fn: Function) => (input: string, expected: string, options?: Record) => { + return runInlineTest(fn, options, {source: input}, expected, {parser: 'tsx'}); + }; diff --git a/modules/codemod/lib/v11/spec/renameHasErrorPreview.spec.ts b/modules/codemod/lib/v11/spec/renameHasErrorPreview.spec.ts new file mode 100644 index 0000000000..ced898fc02 --- /dev/null +++ b/modules/codemod/lib/v11/spec/renameHasErrorPreview.spec.ts @@ -0,0 +1,177 @@ +import {expectTransformFactory} from './expectTransformFactory'; +import transform from '../renameHasErrorPreview'; +import {stripIndent} from 'common-tags'; + +const expectTransform = expectTransformFactory(transform); + +describe('renameHasError', () => { + it('should not change non-canvas imports', () => { + const input = stripIndent` + import {TextInput} from '@workday/any-other-package' + import {TextArea} from './text-area' + import {FormField} from 'any-other-package' + <> + +