UNPKG

@hisptz/react-ui

Version:

A collection of reusable complex DHIS2 react ui components.

74 lines (71 loc) 2.16 kB
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } import { DevTool } from "@hookform/devtools"; import React from "react"; import { Controller, FormProvider, useForm } from "react-hook-form"; import { CustomInput } from "../../index"; import Input from "./components/Input"; import { VALUE_TYPES } from "./constants"; const Template = args => /*#__PURE__*/React.createElement(CustomInput, args); export const NativeInputs = Template.bind({}); NativeInputs.args = { valueType: VALUE_TYPES.TEXT.name, label: "Text", name: "text", mandatory: true, input: { name: "", onChange: () => { console.log("onChange"); } } }; export default { title: "Components/Custom Inputs/CustomInput", component: Input, decorators: [(InputStory, _ref) => { let { args } = _ref; console.log(args); const form = useForm(); return /*#__PURE__*/React.createElement(FormProvider, form, /*#__PURE__*/React.createElement("div", { style: { display: "flex", justifyContent: "center", width: "100%" } }, /*#__PURE__*/React.createElement("div", { style: { height: "100%", display: "flex", flexDirection: "row", justifyContent: "center", alignItems: "center" } }, /*#__PURE__*/React.createElement(Controller, { name: "text", render: _ref2 => { let { field, fieldState } = _ref2; return /*#__PURE__*/React.createElement(InputStory, _extends({}, args, { input: field }, field, fieldState)); } }))), /*#__PURE__*/React.createElement(DevTool, null)); }], parameters: { actions: { handles: ["onChange"] } }, argTypes: { valueType: { control: { type: "select", options: Object.keys(VALUE_TYPES) } } } };