From e44f5696e8006bceb030520e8a6630d5dba847bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kry=C5=A1p=C3=ADn?= Date: Thu, 13 Jul 2023 15:08:53 +0200 Subject: [PATCH] BREAKING CHANGE(web-react): Rename CheckboxField component to `Checkbox` #DS-522 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Migration Guide Rename and use `Checkbox` component instead of `CheckboxField`. - `` → `` Please refer back to this guide or reach out to our team if you encounter any issues during migration. --- packages/web-react/scripts/entryPoints.js | 2 +- .../components/Checkbox/Checkbox.stories.ts | 22 +++++++ .../Checkbox.tsx} | 14 ++--- .../{CheckboxField => Checkbox}/README.md | 20 +++---- .../__tests__/Checkbox.test.tsx} | 40 ++++++------- .../__tests__/useCheckboxStyleProps.test.ts | 48 +++++++++++++++ .../src/components/Checkbox/index.ts | 3 + .../components/Checkbox/stories/Checkbox.tsx | 8 +++ .../stories/CheckboxHelperText.tsx} | 6 +- .../stories/CheckboxItem.tsx} | 6 +- .../Checkbox/stories/CheckboxProps.tsx | 7 +++ .../stories/CheckboxValidationState.tsx} | 14 ++--- .../stories/argTypes.ts | 0 .../Checkbox/useCheckboxStyleProps.ts | 59 +++++++++++++++++++ .../CheckboxField/CheckboxField.stories.ts | 22 ------- .../useCheckboxFieldStyleProps.test.ts | 48 --------------- .../src/components/CheckboxField/index.ts | 3 - .../CheckboxField/stories/CheckboxField.tsx | 8 --- .../stories/CheckboxFieldProps.tsx | 7 --- .../useCheckboxFieldStyleProps.ts | 59 ------------------- .../web-react/src/components/Field/README.md | 2 +- .../web-react/src/components/Item/README.md | 2 +- packages/web-react/src/components/index.ts | 2 +- .../types/{checkboxField.ts => checkbox.ts} | 4 +- packages/web-react/src/types/index.ts | 2 +- 25 files changed, 204 insertions(+), 204 deletions(-) create mode 100644 packages/web-react/src/components/Checkbox/Checkbox.stories.ts rename packages/web-react/src/components/{CheckboxField/CheckboxField.tsx => Checkbox/Checkbox.tsx} (71%) rename packages/web-react/src/components/{CheckboxField => Checkbox}/README.md (79%) rename packages/web-react/src/components/{CheckboxField/__tests__/CheckboxField.test.tsx => Checkbox/__tests__/Checkbox.test.tsx} (53%) create mode 100644 packages/web-react/src/components/Checkbox/__tests__/useCheckboxStyleProps.test.ts create mode 100644 packages/web-react/src/components/Checkbox/index.ts create mode 100644 packages/web-react/src/components/Checkbox/stories/Checkbox.tsx rename packages/web-react/src/components/{CheckboxField/stories/CheckboxFieldHelperText.tsx => Checkbox/stories/CheckboxHelperText.tsx} (57%) rename packages/web-react/src/components/{CheckboxField/stories/CheckboxFieldItem.tsx => Checkbox/stories/CheckboxItem.tsx} (54%) create mode 100644 packages/web-react/src/components/Checkbox/stories/CheckboxProps.tsx rename packages/web-react/src/components/{CheckboxField/stories/CheckboxFieldValidationState.tsx => Checkbox/stories/CheckboxValidationState.tsx} (76%) rename packages/web-react/src/components/{CheckboxField => Checkbox}/stories/argTypes.ts (100%) create mode 100644 packages/web-react/src/components/Checkbox/useCheckboxStyleProps.ts delete mode 100644 packages/web-react/src/components/CheckboxField/CheckboxField.stories.ts delete mode 100644 packages/web-react/src/components/CheckboxField/__tests__/useCheckboxFieldStyleProps.test.ts delete mode 100644 packages/web-react/src/components/CheckboxField/index.ts delete mode 100644 packages/web-react/src/components/CheckboxField/stories/CheckboxField.tsx delete mode 100644 packages/web-react/src/components/CheckboxField/stories/CheckboxFieldProps.tsx delete mode 100644 packages/web-react/src/components/CheckboxField/useCheckboxFieldStyleProps.ts rename packages/web-react/src/types/{checkboxField.ts => checkbox.ts} (85%) diff --git a/packages/web-react/scripts/entryPoints.js b/packages/web-react/scripts/entryPoints.js index 55b3435207..6ddd94cc97 100644 --- a/packages/web-react/scripts/entryPoints.js +++ b/packages/web-react/scripts/entryPoints.js @@ -7,7 +7,7 @@ const entryPoints = [ { dirs: ['components', 'Alert'] }, { dirs: ['components', 'Breadcrumbs'] }, { dirs: ['components', 'Button'] }, - { dirs: ['components', 'CheckboxField'] }, + { dirs: ['components', 'Checkbox'] }, { dirs: ['components', 'Collapse'] }, { dirs: ['components', 'Container'] }, { dirs: ['components', 'Dialog'] }, diff --git a/packages/web-react/src/components/Checkbox/Checkbox.stories.ts b/packages/web-react/src/components/Checkbox/Checkbox.stories.ts new file mode 100644 index 0000000000..11d92d8676 --- /dev/null +++ b/packages/web-react/src/components/Checkbox/Checkbox.stories.ts @@ -0,0 +1,22 @@ +import { ComponentMeta } from '@storybook/react'; +import argTypes from './stories/argTypes'; +import Checkbox from './Checkbox'; + +export default { + title: 'Components/Checkbox', + component: Checkbox, + parameters: { + docs: { + description: { + component: 'Use Checkbox when you have a group of choices and any selection from the group is allowed.', + }, + }, + }, + argTypes, +} as ComponentMeta; + +export { default as Checkbox } from './stories/Checkbox'; +export { default as CheckboxValidationState } from './stories/CheckboxValidationState'; +export { default as CheckboxHelperText } from './stories/CheckboxHelperText'; +export { default as CheckboxItem } from './stories/CheckboxItem'; +export { default as Props } from './stories/CheckboxProps'; diff --git a/packages/web-react/src/components/CheckboxField/CheckboxField.tsx b/packages/web-react/src/components/Checkbox/Checkbox.tsx similarity index 71% rename from packages/web-react/src/components/CheckboxField/CheckboxField.tsx rename to packages/web-react/src/components/Checkbox/Checkbox.tsx index 5935a4a4c3..6cda80b448 100644 --- a/packages/web-react/src/components/CheckboxField/CheckboxField.tsx +++ b/packages/web-react/src/components/Checkbox/Checkbox.tsx @@ -1,14 +1,14 @@ import React, { forwardRef, ForwardedRef } from 'react'; import classNames from 'classnames'; import { useStyleProps } from '../../hooks'; -import { SpiritCheckboxFieldProps } from '../../types'; +import { SpiritCheckboxProps } from '../../types'; import { useValidationText } from '../Field'; -import { useCheckboxFieldStyleProps } from './useCheckboxFieldStyleProps'; +import { useCheckboxStyleProps } from './useCheckboxStyleProps'; /* We need an exception for components exported with forwardRef */ -/* eslint no-underscore-dangle: ['error', { allow: ['_CheckboxField'] }] */ -const _CheckboxField = (props: SpiritCheckboxFieldProps, ref: ForwardedRef): JSX.Element => { - const { classProps, props: modifiedProps } = useCheckboxFieldStyleProps(props); +/* eslint no-underscore-dangle: ['error', { allow: ['_Checkbox'] }] */ +const _Checkbox = (props: SpiritCheckboxProps, ref: ForwardedRef): JSX.Element => { + const { classProps, props: modifiedProps } = useCheckboxStyleProps(props); const { id, label, @@ -52,6 +52,6 @@ const _CheckboxField = (props: SpiritCheckboxFieldProps, ref: ForwardedRef(_CheckboxField); +export const Checkbox = forwardRef(_Checkbox); -export default CheckboxField; +export default Checkbox; diff --git a/packages/web-react/src/components/CheckboxField/README.md b/packages/web-react/src/components/Checkbox/README.md similarity index 79% rename from packages/web-react/src/components/CheckboxField/README.md rename to packages/web-react/src/components/Checkbox/README.md index 998b3e16cb..ab06a8cec9 100644 --- a/packages/web-react/src/components/CheckboxField/README.md +++ b/packages/web-react/src/components/Checkbox/README.md @@ -1,6 +1,6 @@ -# CheckboxField +# Checkbox -CheckboxField enables the user to check/uncheck choice. +Checkbox enables the user to check/uncheck choice. It has input, a label, and an optional helperText. It could be disabled or have a validation state. The label could be hidden and show if the input is required. @@ -8,17 +8,17 @@ The label could be hidden and show if the input is required. Basic example usage: ```jsx - + ``` Advanced example usage: ```jsx - { - const { classProps, props: modifiedProps } = useCheckboxFieldStyleProps(props); +const CustomCheckbox = (props: SpiritCheckboxProps): JSX.Element => { + const { classProps, props: modifiedProps } = useCheckboxStyleProps(props); return (