tycho-storybook 0.2.0 → 0.2.2
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.
- package/dist/IconButton/IconButton.js +8 -1
- package/dist/TextField/TextField.d.ts +2 -3
- package/dist/TextField/TextField.js +3 -3
- package/dist/TextField/TextField.stories.d.ts +1 -0
- package/dist/TextField/TextField.stories.js +19 -0
- package/dist/TextField/styles.scss +4 -0
- package/package.json +1 -1
|
@@ -9,7 +9,14 @@ export default function IconButton({ name, className, disabled = false, active =
|
|
|
9
9
|
const getClassNames = cx("ds-icon-button", className, size, mode, color, {
|
|
10
10
|
active: !disabled && active,
|
|
11
11
|
});
|
|
12
|
-
const
|
|
12
|
+
const getIconSize = () => {
|
|
13
|
+
if (size === "large")
|
|
14
|
+
return "small";
|
|
15
|
+
if (size === "medium")
|
|
16
|
+
return "small";
|
|
17
|
+
return size;
|
|
18
|
+
};
|
|
19
|
+
const renderButton = () => (_jsx("button", { type: "button", disabled: disabled, className: getClassNames, onClick: onClick, children: _jsx(Icon, { name: name, size: getIconSize(), filled: filledIcon, className: spin ? "spin" : "" }) }));
|
|
13
20
|
if (disabled)
|
|
14
21
|
return renderButton();
|
|
15
22
|
return (_jsx(Tooltip, { title: title, placement: "top", arrow: true, children: renderButton() }));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UseFormReturn } from 'react-hook-form';
|
|
2
2
|
import './styles.scss';
|
|
3
|
-
type DefaultEndAdornmentType = 'password' | '
|
|
3
|
+
type DefaultEndAdornmentType = 'password' | 'close';
|
|
4
4
|
type Props = {
|
|
5
5
|
attr: string;
|
|
6
6
|
label: string;
|
|
@@ -16,7 +16,6 @@ type Props = {
|
|
|
16
16
|
startAdornment?: React.ReactNode;
|
|
17
17
|
endAdornment?: React.ReactNode[];
|
|
18
18
|
defaultEndAdornments?: DefaultEndAdornmentType[];
|
|
19
|
-
defaultValue?: any;
|
|
20
19
|
onChange?: (attr: string, value: any) => void;
|
|
21
20
|
onFocus?: (e: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement, Element>) => void;
|
|
22
21
|
onKeyDown?: (e: React.KeyboardEvent<HTMLDivElement>) => void;
|
|
@@ -25,5 +24,5 @@ type Props = {
|
|
|
25
24
|
infoIcon?: string;
|
|
26
25
|
inputRef?: React.Ref<HTMLInputElement | HTMLTextAreaElement>;
|
|
27
26
|
};
|
|
28
|
-
export default function TextField({ className, attr, label, createdForm, disabled, title, placeholder, multiline, maxChars, required, startAdornment, endAdornment, defaultEndAdornments,
|
|
27
|
+
export default function TextField({ className, attr, label, createdForm, disabled, title, placeholder, multiline, maxChars, required, startAdornment, endAdornment, defaultEndAdornments, showEndAdornment, onChange, onFocus, onKeyDown, onRemove, rows, infoIcon, inputRef, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
29
28
|
export {};
|
|
@@ -10,7 +10,7 @@ import Tooltip from '../Tooltip';
|
|
|
10
10
|
import { textFieldTheme } from './TextFieldTheme';
|
|
11
11
|
import { setCurrentInput } from './inputRefManager';
|
|
12
12
|
import './styles.scss';
|
|
13
|
-
export default function TextField({ className, attr, label, createdForm, disabled, title, placeholder, multiline, maxChars, required, startAdornment, endAdornment, defaultEndAdornments = ['close'],
|
|
13
|
+
export default function TextField({ className, attr, label, createdForm, disabled, title, placeholder, multiline, maxChars, required, startAdornment, endAdornment, defaultEndAdornments = ['close'], showEndAdornment = true, onChange, onFocus, onKeyDown, onRemove, rows = 4, infoIcon, inputRef, }) {
|
|
14
14
|
const outerTheme = useTheme();
|
|
15
15
|
const [showPassword, setShowPassword] = useState(false);
|
|
16
16
|
const [active, setActive] = useState(false);
|
|
@@ -28,9 +28,9 @@ export default function TextField({ className, attr, label, createdForm, disable
|
|
|
28
28
|
adornments.push(_jsx(Icon, { name: showPassword ? 'visibility_off' : 'visibility', size: "small", onClick: () => setShowPassword(!showPassword), className: "pointer" }, "password"));
|
|
29
29
|
}
|
|
30
30
|
// Check for info adornment
|
|
31
|
-
if (
|
|
31
|
+
if (infoIcon) {
|
|
32
32
|
const infoIconElement = (_jsx(Icon, { name: "info", size: "small", className: `icon-info pointer ${disabled ? 'd-none' : ''}` }));
|
|
33
|
-
adornments.push(_jsx(Tooltip, { title: infoIcon, mode: "simple", children: infoIconElement }, "info"));
|
|
33
|
+
adornments.push(_jsx(Tooltip, { title: infoIcon, mode: "simple", children: _jsx("span", { children: infoIconElement }) }, "info"));
|
|
34
34
|
}
|
|
35
35
|
// Check for close adornment - show when value is not undefined and value is not equal to defaultValue
|
|
36
36
|
if (defaultEndAdornments.includes('close') &&
|
|
@@ -61,3 +61,22 @@ export const WithEndAdornment = {
|
|
|
61
61
|
] }));
|
|
62
62
|
},
|
|
63
63
|
};
|
|
64
|
+
export const WithInfoIcon = {
|
|
65
|
+
args: {
|
|
66
|
+
attr: 'email',
|
|
67
|
+
label: 'Email Address',
|
|
68
|
+
placeholder: 'Enter your email...',
|
|
69
|
+
infoIcon: 'Please enter a valid email address',
|
|
70
|
+
},
|
|
71
|
+
render: (args) => {
|
|
72
|
+
const createdForm = useForm({
|
|
73
|
+
defaultValues: {
|
|
74
|
+
[args.attr]: '',
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
const handleChange = (attr, value) => {
|
|
78
|
+
console.log(`Attribute: ${attr}, Value: ${String(value)}`);
|
|
79
|
+
};
|
|
80
|
+
return (_jsx(TextField, { ...args, createdForm: createdForm, onChange: handleChange }));
|
|
81
|
+
},
|
|
82
|
+
};
|