@beydesign/storybook 0.2.5 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -4,7 +4,7 @@ import { Box } from '@mui/material';
|
|
|
4
4
|
import { Typography, TypographySize, TypographyWeight } from '../Typography';
|
|
5
5
|
import { HintBubble, HintBubbleSize } from '../UI';
|
|
6
6
|
import { getIconComponent } from '../../utils';
|
|
7
|
-
export const TextInput = ({ label, value, onChange, placeholder, type = 'text', hintText, errorText, disabled, trailingText, style, hintBubbleText, hintBubbleProps, required, labelTrailingElement, labelContainerStyle, showPasswordToggle = true, fullWidth = false, }) => {
|
|
7
|
+
export const TextInput = ({ label, value, onChange, placeholder, type = 'text', hintText, errorText, disabled, trailingText, style, hintBubbleText, hintBubbleProps, required, labelTrailingElement, labelContainerStyle, showPasswordToggle = true, fullWidth = false, leadingIcon, }) => {
|
|
8
8
|
const [focused, setFocused] = useState(false);
|
|
9
9
|
const [showPassword, setShowPassword] = useState(false);
|
|
10
10
|
const isPassword = type === 'password';
|
|
@@ -30,7 +30,13 @@ export const TextInput = ({ label, value, onChange, placeholder, type = 'text',
|
|
|
30
30
|
? '1px solid var(--color-border-border-error)'
|
|
31
31
|
: focused
|
|
32
32
|
? '1px solid var(--color-border-border-component-active)'
|
|
33
|
-
: 'transparent'}`, children: [
|
|
33
|
+
: 'transparent'}`, children: [leadingIcon &&
|
|
34
|
+
getIconComponent(leadingIcon, {
|
|
35
|
+
width: '20px',
|
|
36
|
+
height: '20px',
|
|
37
|
+
color: iconColor,
|
|
38
|
+
'aria-hidden': 'true',
|
|
39
|
+
}), _jsx("input", { type: inputType, value: value, onChange: (e) => onChange(e.target.value), placeholder: placeholder, disabled: disabled, style: {
|
|
34
40
|
border: 'none',
|
|
35
41
|
outline: 'none',
|
|
36
42
|
width: '100%',
|
|
@@ -157,11 +157,21 @@ declare const meta: {
|
|
|
157
157
|
};
|
|
158
158
|
};
|
|
159
159
|
};
|
|
160
|
+
leadingIcon: {
|
|
161
|
+
control: "text";
|
|
162
|
+
description: string;
|
|
163
|
+
table: {
|
|
164
|
+
type: {
|
|
165
|
+
summary: string;
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
};
|
|
160
169
|
};
|
|
161
170
|
};
|
|
162
171
|
export default meta;
|
|
163
172
|
type Story = StoryObj<typeof meta>;
|
|
164
173
|
export declare const Default: Story;
|
|
174
|
+
export declare const WithLeadingIcon: Story;
|
|
165
175
|
export declare const Password: Story;
|
|
166
176
|
export declare const PasswordWithoutToggle: Story;
|
|
167
177
|
export declare const Email: Story;
|
|
@@ -122,6 +122,13 @@ const meta = {
|
|
|
122
122
|
defaultValue: { summary: 'false' },
|
|
123
123
|
},
|
|
124
124
|
},
|
|
125
|
+
leadingIcon: {
|
|
126
|
+
control: 'text',
|
|
127
|
+
description: 'Icon rendered before the input value (e.g. a search glass). Accepts a Phosphor icon name.',
|
|
128
|
+
table: {
|
|
129
|
+
type: { summary: 'IconName' },
|
|
130
|
+
},
|
|
131
|
+
},
|
|
125
132
|
},
|
|
126
133
|
};
|
|
127
134
|
export default meta;
|
|
@@ -133,6 +140,14 @@ export const Default = {
|
|
|
133
140
|
hintBubbleText: 'This is a hint bubble',
|
|
134
141
|
},
|
|
135
142
|
};
|
|
143
|
+
export const WithLeadingIcon = {
|
|
144
|
+
args: {
|
|
145
|
+
value: '',
|
|
146
|
+
placeholder: 'Search',
|
|
147
|
+
leadingIcon: 'MagnifyingGlass',
|
|
148
|
+
onChange: () => { },
|
|
149
|
+
},
|
|
150
|
+
};
|
|
136
151
|
export const Password = {
|
|
137
152
|
args: {
|
|
138
153
|
label: 'Password',
|
|
@@ -85,6 +85,8 @@ export type TextInputProps = {
|
|
|
85
85
|
* min-width. Use for side-by-side fields in a flex row. Defaults to `false`.
|
|
86
86
|
*/
|
|
87
87
|
fullWidth?: boolean;
|
|
88
|
+
/** Icon rendered before the input value (e.g. a search glass). */
|
|
89
|
+
leadingIcon?: IconName;
|
|
88
90
|
};
|
|
89
91
|
/**
|
|
90
92
|
* Toggle position variants
|