DocSpace-client/packages/components/input-phone/input-phone.stories.js

38 lines
1022 B
JavaScript
Raw Normal View History

2022-09-29 12:37:33 +00:00
import { useState } from "react";
import { options } from "./options";
2022-09-15 12:52:39 +00:00
import { InputPhone } from "./index";
2022-09-07 14:53:27 +00:00
export default {
2022-09-07 17:56:40 +00:00
title: "Components/InputPhone",
2022-09-07 14:53:27 +00:00
component: InputPhone,
};
2022-09-29 12:37:33 +00:00
const Template = ({ onChange, value, ...args }) => {
const [val, setValue] = useState(value);
const onChangeHandler = (e) => {
onChange(e.target.value);
setValue(e.target.value);
console.log(e.target.val);
};
return (
<div style={{ height: "300px" }}>
<InputPhone {...args} value={val} onChange={onChangeHandler} />
</div>
);
};
2022-09-07 14:53:27 +00:00
export const Default = Template.bind({});
2022-09-29 12:37:33 +00:00
Default.args = {
defaultCountry: {
locale: options[182].code, // default locale RU
dialCode: options[182].dialCode, // default dialCode +7
mask: options[182].mask, // default dialCode +7
icon: options[182].flag, // default flag Russia
},
phonePlaceholderText: "+7 XXX XXX-XX-XX",
searchPlaceholderText: "Search",
searchEmptyMessage: "Nothing found",
errorMessage: "Сountry code is invalid",
};