diff --git a/code/ui/components/package.json b/code/ui/components/package.json index 1cab757ae8e..e3c856d3e11 100644 --- a/code/ui/components/package.json +++ b/code/ui/components/package.json @@ -67,7 +67,6 @@ "@storybook/theming": "workspace:*", "@storybook/types": "workspace:*", "memoizerific": "^1.11.3", - "use-resize-observer": "^9.1.0", "util-deprecate": "^1.0.2" }, "devDependencies": { @@ -82,7 +81,8 @@ "react-syntax-highlighter": "^15.4.5", "react-textarea-autosize": "^8.3.0", "ts-dedent": "^2.0.0", - "typescript": "^5.3.2" + "typescript": "^5.3.2", + "use-resize-observer": "^9.1.0" }, "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0", @@ -94,8 +94,7 @@ "bundler": { "entries": [ "./src/index.ts" - ], - "platform": "neutral" + ] }, "gitHead": "e6a7fd8a655c69780bc20b9749c2699e44beae17" } diff --git a/code/ui/components/src/components/form/input/input.tsx b/code/ui/components/src/components/form/input/input.tsx index 15f647c7cdb..7b761e49b14 100644 --- a/code/ui/components/src/components/form/input/input.tsx +++ b/code/ui/components/src/components/form/input/input.tsx @@ -1,11 +1,30 @@ -import type { HTMLProps, SelectHTMLAttributes } from 'react'; +import type { FC, HTMLProps, SelectHTMLAttributes } from 'react'; import React, { forwardRef } from 'react'; import type { Theme, CSSObject } from '@storybook/theming'; import { styled } from '@storybook/theming'; -import type { TextareaAutosizeProps } from 'react-textarea-autosize'; import TextareaAutoResize from 'react-textarea-autosize'; +/** + * these types are copied from `react-textarea-autosize`. + * I copied them because of https://github.com/storybookjs/storybook/issues/18734 + * Maybe there's some bug in `tsup` or `react-textarea-autosize`? + */ +type TextareaPropsRaw = React.TextareaHTMLAttributes; +type Style = Omit, 'maxHeight' | 'minHeight'> & { + height?: number; +}; +type TextareaHeightChangeMeta = { + rowHeight: number; +}; +export interface TextareaAutosizeProps extends Omit { + maxRows?: number; + minRows?: number; + onHeightChange?: (height: number, meta: TextareaHeightChangeMeta) => void; + cacheMeasurements?: boolean; + style?: Style; +} + const styleResets: CSSObject = { // resets appearance: 'none', @@ -189,8 +208,8 @@ type TextareaProps = Omit< align?: Alignments; valid?: ValidationStates; height?: number; -}; -export const Textarea = Object.assign( +} & React.RefAttributes; +export const Textarea: FC = Object.assign( styled( forwardRef(function Textarea({ size, valid, align, ...props }, ref) { return ;