diff --git a/packages/bento-design-system/package.json b/packages/bento-design-system/package.json index ad48c5270..44654907e 100644 --- a/packages/bento-design-system/package.json +++ b/packages/bento-design-system/package.json @@ -121,7 +121,6 @@ "clsx": "1.2.1", "deepmerge-ts": "4.3.0", "lodash.pick": "4.4.0", - "react-cool-dimensions": "2.0.7", "react-dropzone": "14.2.9", "react-input-mask": "2.0.4", "react-is": "18.3.1", diff --git a/packages/bento-design-system/src/DateField/Input.tsx b/packages/bento-design-system/src/DateField/Input.tsx index 37fecc06d..40e9016a1 100644 --- a/packages/bento-design-system/src/DateField/Input.tsx +++ b/packages/bento-design-system/src/DateField/Input.tsx @@ -19,7 +19,6 @@ import { useBentoConfig } from "../BentoConfigContext"; import { getRadiusPropsFromConfig } from "../util/BorderRadiusConfig"; import { Body } from "../Typography/Body/Body"; import { Inline } from "../Layout/Inline"; -import useDimensions from "react-cool-dimensions"; import { IconCalendar, IconMinus } from "../Icons"; import { AriaButtonProps } from "@react-types/button"; import { IconButton } from "../IconButton/IconButton"; @@ -89,11 +88,6 @@ export function Input(props: Props) { const config = useBentoConfig().input; const dateFieldConfig = useBentoConfig().dateField; - const { observe: rightAccessoryRef, width: rightAccessoryWidth } = useDimensions({ - // This is needed to include the padding in the width - useBorderBoxSize: true, - }); - const { validationState, isDisabled, isReadOnly } = match(props) .with({ type: "single" }, (props) => { return { @@ -128,6 +122,8 @@ export function Input(props: Props) { return ( - {props.type === "single" ? ( - - ) : ( - - - - - - - - - - )} + + {props.type === "single" ? ( + + ) : ( + + + + + + + + + + )} + {!isReadOnly && ( - + { if (props.kind === "currency") { @@ -73,7 +67,7 @@ export function BaseNumberInput(props: Props) { .with([__.nullish, not(__.nullish)], () => rightAccessoryContent) .with([not(__.nullish), __.nullish], () => props.rightAccessory) .with([not(__.nullish), not(__.nullish)], () => ( - + {props.rightAccessory} {rightAccessoryContent} @@ -81,7 +75,17 @@ export function BaseNumberInput(props: Props) { .exhaustive(); return ( - + {rightAccessory && ( - + {rightAccessory} )} diff --git a/packages/bento-design-system/src/SearchBar/SearchBar.css.ts b/packages/bento-design-system/src/SearchBar/SearchBar.css.ts deleted file mode 100644 index 97209f0c7..000000000 --- a/packages/bento-design-system/src/SearchBar/SearchBar.css.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { style } from "@vanilla-extract/css"; -import { bentoSprinkles } from "../internal"; - -export const input = style([ - bentoSprinkles({ - outline: "none", - }), - { - selectors: { - [`&::-webkit-search-decoration, - &::-webkit-search-cancel-button, - &::-webkit-search-results-button, - &::-webkit-search-results-decoration`]: { - WebkitAppearance: "none", - }, - }, - }, -]); - -export const inputContainer = style({}); diff --git a/packages/bento-design-system/src/SearchBar/SearchBar.tsx b/packages/bento-design-system/src/SearchBar/SearchBar.tsx index 9d9ce6c19..1a0dc91db 100644 --- a/packages/bento-design-system/src/SearchBar/SearchBar.tsx +++ b/packages/bento-design-system/src/SearchBar/SearchBar.tsx @@ -1,14 +1,9 @@ import { useTextField } from "@react-aria/textfield"; import { HTMLAttributes, useRef } from "react"; -import { LocalizedString, Box, Field, IconButton } from ".."; -import { inputRecipe } from "../Field/Field.css"; -import { bodyRecipe } from "../Typography/Body/Body.css"; -import { input, inputContainer } from "./SearchBar.css"; +import { LocalizedString, Field, IconButton, BaseTextInput } from ".."; import { useDefaultMessages } from "../util/useDefaultMessages"; import { useBentoConfig } from "../BentoConfigContext"; import { AtLeast } from "../util/AtLeast"; -import { getReadOnlyBackgroundStyle } from "../Field/utils"; -import { getRadiusPropsFromConfig } from "../util/BorderRadiusConfig"; type Props = AtLeast, "aria-label" | "aria-labelledby">> & { value: string; @@ -34,7 +29,7 @@ export function SearchBar(props: Props) { const { defaultMessages } = useDefaultMessages(); - const rightAccessoryContent = + const rightAccessory = props.value.length > 0 ? ( - - - {config.searchIcon({ size: config.searchIconSize })} - - - {rightAccessoryContent && ( - - {rightAccessoryContent} - - )} - + ); } diff --git a/packages/bento-design-system/src/TextField/BaseTextInput.tsx b/packages/bento-design-system/src/TextField/BaseTextInput.tsx index 07c04d6ab..c4f75f3c1 100644 --- a/packages/bento-design-system/src/TextField/BaseTextInput.tsx +++ b/packages/bento-design-system/src/TextField/BaseTextInput.tsx @@ -3,10 +3,9 @@ import { Box } from "../Box/Box"; import { Children } from "../util/Children"; import { LocalizedString } from "../util/LocalizedString"; import { getRadiusPropsFromConfig } from "../util/BorderRadiusConfig"; -import { inputRecipe } from "../Field/Field.css"; +import { inputContainerRecipe, input } from "../Field/Field.css"; import { bodyRecipe } from "../Typography/Body/Body.css"; import { getReadOnlyBackgroundStyle } from "../Field/utils"; -import useDimensions from "react-cool-dimensions"; import { match } from "ts-pattern"; import { Columns } from "../Layout/Columns"; import { IconButton } from "../IconButton/IconButton"; @@ -18,9 +17,10 @@ type Props = { inputRef: React.Ref; placeholder?: LocalizedString; validationState?: "valid" | "invalid"; - type?: "text" | "email" | "url" | "password"; + type?: "text" | "email" | "url" | "password" | "search"; disabled?: boolean; isReadOnly?: boolean; + leftAccessory?: Children; rightAccessory?: Children; showPasswordLabel?: never; hidePasswordLabel?: never; @@ -30,11 +30,6 @@ export function BaseTextInput(props: Props) { const config = useBentoConfig().input; const { defaultMessages } = useDefaultMessages(); - const { observe: rightAccessoryRef, width: rightAccessoryWidth } = useDimensions({ - // This is needed to include the padding in the width - useBorderBoxSize: true, - }); - const [showPassword, setShowPassword] = useState(false); const passwordIcon = showPassword ? config.passwordHideIcon : config.passwordShowIcon; const passwordIconLabel = showPassword @@ -43,13 +38,13 @@ export function BaseTextInput(props: Props) { const type = match(props.type ?? "text") .with("password", () => (showPassword ? "text" : "password")) - .with("text", "email", "url", () => props.type) + .with("text", "email", "url", "search", () => props.type) .exhaustive(); const rightAccessory = match(props.type ?? "text") .with("password", () => ( // if we have both a rightAccessory and type='password', display the accessory on the left of the password toggle field - + )) - .with("email", "text", "url", () => props.rightAccessory) + .with("email", "text", "url", "search", () => props.rightAccessory) .exhaustive(); return ( - + + {props.leftAccessory && ( + + {props.leftAccessory} + + )} {rightAccessory && ( - + {rightAccessory} )} diff --git a/packages/bento-design-system/src/reset.css.ts b/packages/bento-design-system/src/reset.css.ts index 1a892f577..264efb39e 100644 --- a/packages/bento-design-system/src/reset.css.ts +++ b/packages/bento-design-system/src/reset.css.ts @@ -36,6 +36,14 @@ const input = style({ ":disabled": { cursor: "inherit", }, + selectors: { + [`&::-webkit-search-decoration, + &::-webkit-search-cancel-button, + &::-webkit-search-results-button, + &::-webkit-search-results-decoration`]: { + WebkitAppearance: "none", + }, + }, }); const label = style({ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4f1d3cf6a..1877c81eb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -131,7 +131,6 @@ importers: postcss: 8.4.47 prettier: 2.8.8 react: 18.3.1 - react-cool-dimensions: 2.0.7 react-dom: 18.3.1 react-dropzone: 14.2.9 react-input-mask: 2.0.4 @@ -206,7 +205,6 @@ importers: clsx: 1.2.1 deepmerge-ts: 4.3.0 lodash.pick: 4.4.0 - react-cool-dimensions: 2.0.7_react@18.3.1 react-dropzone: 14.2.9_react@18.3.1 react-input-mask: 2.0.4_nnrd3gsncyragczmpvfhocinkq react-is: 18.3.1 @@ -18667,14 +18665,6 @@ packages: react-dom: 18.3.1_react@18.3.1 dev: true - /react-cool-dimensions/2.0.7_react@18.3.1: - resolution: {integrity: sha512-z1VwkAAJ5d8QybDRuYIXTE41RxGr5GYsv1bQhbOBE8cMfoZQZpcF0odL64vdgrQVzat2jayedj1GoYi80FWcbA==} - peerDependencies: - react: '>= 16.8.0 || 18' - dependencies: - react: 18.3.1 - dev: false - /react-dev-utils/12.0.1_ui7adrgquoqvodctsjvyz7u2xe: resolution: {integrity: sha512-84Ivxmr17KjUupyqzFode6xKhjwuEJDROWKJy/BthkL7Wn6NJ8h4WE6k/exAv6ImS+0oZLRRW5j/aINMHyeGeQ==} engines: {node: '>=14'}