From 7e74223bd2c3a2a0af1e84232858ff90813639a1 Mon Sep 17 00:00:00 2001 From: Hussam Ghazzi Date: Fri, 8 Nov 2024 20:03:33 +0000 Subject: [PATCH 01/11] feat(TextInput): Remove width props from TextInput --- .changeset/clean-ligers-approve.md | 5 +++++ .../src/internal/components/TextInputWrapper.tsx | 14 +++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) create mode 100644 .changeset/clean-ligers-approve.md diff --git a/.changeset/clean-ligers-approve.md b/.changeset/clean-ligers-approve.md new file mode 100644 index 00000000000..ee42748b015 --- /dev/null +++ b/.changeset/clean-ligers-approve.md @@ -0,0 +1,5 @@ +--- +"@primer/react": minor +--- + +Remove width props from TextInput diff --git a/packages/react/src/internal/components/TextInputWrapper.tsx b/packages/react/src/internal/components/TextInputWrapper.tsx index 56557456493..cd78ccd6d0e 100644 --- a/packages/react/src/internal/components/TextInputWrapper.tsx +++ b/packages/react/src/internal/components/TextInputWrapper.tsx @@ -1,7 +1,5 @@ import React from 'react' import styled from 'styled-components' -import type {MaxWidthProps, MinWidthProps, WidthProps} from 'styled-system' -import {maxWidth, minWidth, width} from 'styled-system' import type {SxProp} from '../../sx' import sx from '../../sx' import type {FormValidationStatus} from '../../utils/types/FormValidationStatus' @@ -19,10 +17,8 @@ export type StyledBaseWrapperProps = { /** @deprecated Use `size` prop instead */ variant?: TextInputSizes size?: TextInputSizes -} & WidthProps & - MinWidthProps & - MaxWidthProps & - SxProp & + width?: string +} & SxProp & React.ComponentPropsWithoutRef<'span'> export type StyledWrapperProps = { @@ -165,9 +161,6 @@ export const StyledTextInputBaseWrapper = styled.span` } & { - ${width} - ${minWidth} - ${maxWidth} ${sx} } ` @@ -183,6 +176,8 @@ export function TextInputBaseWrapper(props: React.PropsWithChildren ) From 19581849e73b1209456f7af4d3a65c356f51581a Mon Sep 17 00:00:00 2001 From: Hussam Ghazzi Date: Fri, 8 Nov 2024 20:09:43 +0000 Subject: [PATCH 02/11] type fixes --- packages/react/src/TextInput/TextInput.tsx | 16 +--------------- .../TextInputWithTokens/TextInputWithTokens.tsx | 4 ---- 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/packages/react/src/TextInput/TextInput.tsx b/packages/react/src/TextInput/TextInput.tsx index e272f04887f..acf5a581e4d 100644 --- a/packages/react/src/TextInput/TextInput.tsx +++ b/packages/react/src/TextInput/TextInput.tsx @@ -41,17 +41,7 @@ export type TextInputNonPassthroughProps = { trailingAction?: React.ReactElement> } & Pick< StyledWrapperProps, - | 'block' - | 'contrast' - | 'disabled' - | 'monospace' - | 'sx' - | 'width' - | 'maxWidth' - | 'minWidth' - | 'variant' - | 'size' - | 'validationStatus' + 'block' | 'contrast' | 'disabled' | 'monospace' | 'sx' | 'width' | 'variant' | 'size' | 'validationStatus' > export type TextInputProps = Merge, TextInputNonPassthroughProps> @@ -79,8 +69,6 @@ const TextInput = React.forwardRef( onBlur, // start deprecated props width: widthProp, - minWidth: minWidthProp, - maxWidth: maxWidthProp, variant: variantProp, // end deprecated props type = 'text', @@ -138,8 +126,6 @@ const TextInput = React.forwardRef( sx={sxProp} size={sizeProp} width={widthProp} - minWidth={minWidthProp} - maxWidth={maxWidthProp} variant={variantProp} hasLeadingVisual={Boolean(LeadingVisual || showLeadingLoadingIndicator)} hasTrailingVisual={Boolean(TrailingVisual || showTrailingLoadingIndicator)} diff --git a/packages/react/src/TextInputWithTokens/TextInputWithTokens.tsx b/packages/react/src/TextInputWithTokens/TextInputWithTokens.tsx index fa03c61a48e..9567de7b341 100644 --- a/packages/react/src/TextInputWithTokens/TextInputWithTokens.tsx +++ b/packages/react/src/TextInputWithTokens/TextInputWithTokens.tsx @@ -88,8 +88,6 @@ function TextInputWithTokensInnerComponent Date: Fri, 8 Nov 2024 17:33:39 -0500 Subject: [PATCH 03/11] =?UTF-8?q?Revert=20"Revert=20"feat(TextInput):=20Up?= =?UTF-8?q?date=20TextInput=20to=20use=20data=20attributes=20for=20?= =?UTF-8?q?=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit c424c36d50145371af67d0ff7a575dc5e4e30b7f. --- .changeset/real-fans-tap.md | 5 + .../TextInputWithTokens.tsx | 6 +- .../react/src/__tests__/Textarea.test.tsx | 8 +- .../__snapshots__/Autocomplete.test.tsx.snap | 1141 +++- .../__snapshots__/TextInput.test.tsx.snap | 5547 +++++++++++++---- .../TextInputWithTokens.test.tsx.snap | 4871 +++++++++++---- .../internal/components/TextInputWrapper.tsx | 363 +- packages/react/src/utils/testing.tsx | 12 +- 8 files changed, 9221 insertions(+), 2732 deletions(-) create mode 100644 .changeset/real-fans-tap.md diff --git a/.changeset/real-fans-tap.md b/.changeset/real-fans-tap.md new file mode 100644 index 00000000000..f419b1ad11d --- /dev/null +++ b/.changeset/real-fans-tap.md @@ -0,0 +1,5 @@ +--- +"@primer/react": minor +--- + +Convert TextInput to use data attributes diff --git a/packages/react/src/TextInputWithTokens/TextInputWithTokens.tsx b/packages/react/src/TextInputWithTokens/TextInputWithTokens.tsx index e2c97ac77f1..fa03c61a48e 100644 --- a/packages/react/src/TextInputWithTokens/TextInputWithTokens.tsx +++ b/packages/react/src/TextInputWithTokens/TextInputWithTokens.tsx @@ -13,7 +13,7 @@ import Token from '../Token/Token' import type {TokenSizeKeys} from '../Token/TokenBase' import type {TextInputSizes} from '../internal/components/TextInputWrapper' -import TextInputWrapper, {textInputHorizPadding} from '../internal/components/TextInputWrapper' +import TextInputWrapper from '../internal/components/TextInputWrapper' import UnstyledTextInput from '../internal/components/UnstyledTextInput' import TextInputInnerVisualSlot from '../internal/components/TextInputInnerVisualSlot' @@ -266,8 +266,8 @@ function TextInputWithTokensInnerComponent { width: '100%', display: 'flex', } - const defaultStyles = renderStyles(