An open source design system that's fully customizable and agent ready
TypeScript
text input type (#962)
Andrey Goder2f04f0eaee4d
diff --git a/apps/storybook/stories/TextInput.stories.tsx b/apps/storybook/stories/TextInput.stories.tsxindex 5b86776271..3affbeec70 100644--- a/apps/storybook/stories/TextInput.stories.tsx+++ b/apps/storybook/stories/TextInput.stories.tsx@@ -441,6 +441,18 @@ export const WithTooltip: Story = {},};+export const Password: Story = {+ render: args => {+ const [value, setValue] = useState(args.value ?? '');+ return <XDSTextInput {...args} value={value} onChange={setValue} />;+ },+ args: {+ type: 'password',+ label: 'Password',+ placeholder: 'Enter your password',+ },+};+export const TooltipWithOptional: Story = {render: args => {const [value, setValue] = useState(args.value ?? '');diff --git a/packages/core/src/TextInput/TextInput.doc.mjs b/packages/core/src/TextInput/TextInput.doc.mjsindex d100a3e7b8..6f1aa9b50a 100644--- a/packages/core/src/TextInput/TextInput.doc.mjs+++ b/packages/core/src/TextInput/TextInput.doc.mjs@@ -25,6 +25,10 @@ export const docs = {label: 'With placeholder',code: '<XDSTextInput label="Email" value={email} onChange={setEmail} placeholder="[email protected]" />',},+ {+ label: 'Password input',+ code: '<XDSTextInput type="password" label="Password" value={password} onChange={setPassword} />',+ },{label: 'Hidden label',code: '<XDSTextInput label="Search" isLabelHidden value={query} onChange={setQuery} placeholder="Search..." />',@@ -75,6 +79,13 @@ export const docs = {},],props: [+ {+ name: 'type',+ type: "'text' | 'password' | 'email'",+ description:+ 'The HTML input type.',+ default: "'text'",+ },{name: 'label',type: 'string',@@ -277,6 +288,12 @@ export const docsZh = {},],props: [+ {+ name: 'type',+ type: "'text' | 'password' | 'email'",+ description: 'HTML 输入框类型。',+ default: "'text'",+ },{name: 'label',type: 'string',@@ -432,6 +449,7 @@ export const docsDense = {'aria-busy set during optimistic update or isLoading.',],propDescriptions: {+ type: 'HTML input type.',label: 'Label text for input; always rendered for a11y.',value: 'Current input value.',onChange: 'Fired on input value change.',diff --git a/packages/core/src/TextInput/XDSTextInput.tsx b/packages/core/src/TextInput/XDSTextInput.tsxindex ab7cdfd6cc..591feff119 100644--- a/packages/core/src/TextInput/XDSTextInput.tsx+++ b/packages/core/src/TextInput/XDSTextInput.tsx@@ -83,12 +83,19 @@ export type {import {xdsClassName, mergeProps} from '../utils';import {XDSBaseProps} from '../XDSBaseProps';+export type XDSTextInputType = 'text' | 'password' | 'email';+export interface XDSTextInputProps extends Omit<XDSBaseProps,'onChange' | 'defaultValue'> {/** Ref forwarded to the root element */ref?: React.Ref<HTMLInputElement>;+ /**+ * The HTML input type.+ * @default 'text'+ */+ type?: XDSTextInputType;/*** Label text for the input (always rendered for accessibility).*/@@ -180,6 +187,7 @@ export interface XDSTextInputProps extends Omit<* ```*/export function XDSTextInput({+ type = 'text',label,isLabelHidden = false,description,@@ -284,7 +292,7 @@ export function XDSTextInput({ref={ref}id={id}name={htmlName}- type="text"+ type={type}value={String(optimisticValue)}onChange={handleChange}placeholder={placeholder}diff --git a/packages/core/src/TextInput/index.ts b/packages/core/src/TextInput/index.tsindex d945a58f65..4d43d12af5 100644--- a/packages/core/src/TextInput/index.ts+++ b/packages/core/src/TextInput/index.ts@@ -12,6 +12,7 @@export {XDSTextInput} from './XDSTextInput';export type {XDSTextInputProps,+ XDSTextInputType,XDSTextInputSize,XDSTextInputStatus,XDSTextInputStatusType,