@mirai/ui 1.0.155 → 1.0.156
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.
|
@@ -110,6 +110,7 @@ var Story = function Story(props) {
|
|
|
110
110
|
label: "Email",
|
|
111
111
|
hint: "Should contains @mirai.com",
|
|
112
112
|
required: true,
|
|
113
|
+
showRequired: true,
|
|
113
114
|
type: "email",
|
|
114
115
|
value: form.email
|
|
115
116
|
}), /*#__PURE__*/_react.default.createElement(_.InputText, {
|
|
@@ -118,6 +119,7 @@ var Story = function Story(props) {
|
|
|
118
119
|
hint: "At least 10 chars.",
|
|
119
120
|
label: "Password",
|
|
120
121
|
required: true,
|
|
122
|
+
showRequired: true,
|
|
121
123
|
minLength: 10,
|
|
122
124
|
type: "password",
|
|
123
125
|
value: form.password
|
|
@@ -135,6 +137,7 @@ var Story = function Story(props) {
|
|
|
135
137
|
max: "31/12/2022",
|
|
136
138
|
min: "10/04/1980",
|
|
137
139
|
required: true,
|
|
140
|
+
showRequired: true,
|
|
138
141
|
type: "inputDate",
|
|
139
142
|
value: form.dateOfBirth
|
|
140
143
|
}), /*#__PURE__*/_react.default.createElement(_.InputPhone, {
|
|
@@ -144,6 +147,7 @@ var Story = function Story(props) {
|
|
|
144
147
|
labelPrefix: "Prefix",
|
|
145
148
|
prefixes: ['+34', '+44', '+001', '+999', '+39', '+56'],
|
|
146
149
|
required: true,
|
|
150
|
+
showRequired: true,
|
|
147
151
|
type: "inputPhone",
|
|
148
152
|
value: form.phone
|
|
149
153
|
}), /*#__PURE__*/_react.default.createElement(_.InputText, {
|
|
@@ -155,14 +159,14 @@ var Story = function Story(props) {
|
|
|
155
159
|
name: "children",
|
|
156
160
|
label: "Children",
|
|
157
161
|
hint: "Ages 0 - 17",
|
|
158
|
-
value: form.children
|
|
159
|
-
required: true
|
|
162
|
+
value: form.children
|
|
160
163
|
}), /*#__PURE__*/_react.default.createElement(_.InputOption, {
|
|
161
164
|
type: "checkbox",
|
|
162
165
|
name: "checkbox",
|
|
163
166
|
label: "checkbox",
|
|
164
167
|
checked: form.checkbox,
|
|
165
|
-
required: true
|
|
168
|
+
required: true,
|
|
169
|
+
showRequired: true
|
|
166
170
|
}), /*#__PURE__*/_react.default.createElement(_.InputOption, {
|
|
167
171
|
type: "switch",
|
|
168
172
|
name: "switch",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.stories.js","names":["title","Story","props","useState","condition","setCondition","email","checkbox","dateOfBirth","switch","radio","form","setForm","error","setError","useEffect","handleChange","next","others","console","log","handleEnter","handleError","handleLeave","handleSubmit","value","includes","password","emptyOption","gender","phone","bio","children","Array","from","keys","map","index","Object","length","justifyContent","marginTop","marginRight","storyName","args","debounce","schema","showErrors","validateOnMount","argTypes"],"sources":["../../../src/components/Form/Form.stories.jsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\n\nimport { Button, InputDate, InputNumber, InputOption, InputPhone, InputText, InputSelect, Text, View } from '../../';\nimport { Form } from './Form';\n\nexport default { title: 'Components' };\n\nexport const Story = (props) => {\n const [condition, setCondition] = useState(false);\n const [form, setForm] = useState({\n email: 'javi@mirai.com',\n checkbox: true,\n dateOfBirth: '04/10/1980',\n switch: true,\n radio: 'radio-2',\n });\n const [error, setError] = useState({});\n\n useEffect(\n () =>\n setForm({\n email: 'javi@mirai.com',\n checkbox: true,\n dateOfBirth: '04/10/1980',\n switch: true,\n radio: 'radio-2',\n }),\n [],\n ); // * Simulate a state hydration\n\n const handleChange = (next, ...others) => {\n setForm(next);\n console.log('<Form>::onChange', next, ...others);\n };\n\n const handleEnter = (...others) => console.log('<Form>::onEnter', ...others);\n\n const handleError = (next, ...others) => {\n setError(next);\n console.log('<Form>::onError', next, ...others);\n };\n\n const handleLeave = (...others) => console.log('<Form>::onLeave', ...others);\n\n const handleSubmit = (...others) => console.log('<Form>::onSubmit', ...others);\n\n return (\n <>\n <Form\n {...props}\n onLeave={handleLeave}\n onChange={handleChange}\n onError={handleError}\n onEnter={handleEnter}\n onSubmit={handleSubmit}\n >\n <View row>\n <Text headline>Form component</Text>\n </View>\n\n <InputText\n name=\"email\"\n error={!!error.email}\n test={(value) => value.includes('@mirai.com')}\n label=\"Email\"\n hint=\"Should contains @mirai.com\"\n required\n type=\"email\"\n value={form.email}\n />\n <InputText\n name=\"password\"\n error={!!error.password}\n hint=\"At least 10 chars.\"\n label=\"Password\"\n required\n minLength={10}\n type=\"password\"\n value={form.password}\n />\n <InputSelect\n name=\"gender\"\n emptyOption=\"Select...\"\n error={!!error.emptyOption}\n label=\"Your gender\"\n options={['one', 'two', 'three', 'four', 'five']}\n value={form.gender}\n />\n <InputDate\n name=\"dateOfBirth\"\n error={!!error.dateOfBirth}\n label=\"Your birthdate\"\n max=\"31/12/2022\"\n min=\"10/04/1980\"\n required\n type=\"inputDate\"\n value={form.dateOfBirth}\n />\n <InputPhone\n name=\"phone\"\n error={!!error.phone}\n label=\"Phone\"\n labelPrefix=\"Prefix\"\n prefixes={['+34', '+44', '+001', '+999', '+39', '+56']}\n required\n type=\"inputPhone\"\n value={form.phone}\n />\n <InputText name=\"bio\" label=\"Bio\" multiLine value={form.bio} />\n <InputNumber name=\"children\" label=\"Children\" hint=\"Ages 0 - 17\" value={form.children}
|
|
1
|
+
{"version":3,"file":"Form.stories.js","names":["title","Story","props","useState","condition","setCondition","email","checkbox","dateOfBirth","switch","radio","form","setForm","error","setError","useEffect","handleChange","next","others","console","log","handleEnter","handleError","handleLeave","handleSubmit","value","includes","password","emptyOption","gender","phone","bio","children","Array","from","keys","map","index","Object","length","justifyContent","marginTop","marginRight","storyName","args","debounce","schema","showErrors","validateOnMount","argTypes"],"sources":["../../../src/components/Form/Form.stories.jsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\n\nimport { Button, InputDate, InputNumber, InputOption, InputPhone, InputText, InputSelect, Text, View } from '../../';\nimport { Form } from './Form';\n\nexport default { title: 'Components' };\n\nexport const Story = (props) => {\n const [condition, setCondition] = useState(false);\n const [form, setForm] = useState({\n email: 'javi@mirai.com',\n checkbox: true,\n dateOfBirth: '04/10/1980',\n switch: true,\n radio: 'radio-2',\n });\n const [error, setError] = useState({});\n\n useEffect(\n () =>\n setForm({\n email: 'javi@mirai.com',\n checkbox: true,\n dateOfBirth: '04/10/1980',\n switch: true,\n radio: 'radio-2',\n }),\n [],\n ); // * Simulate a state hydration\n\n const handleChange = (next, ...others) => {\n setForm(next);\n console.log('<Form>::onChange', next, ...others);\n };\n\n const handleEnter = (...others) => console.log('<Form>::onEnter', ...others);\n\n const handleError = (next, ...others) => {\n setError(next);\n console.log('<Form>::onError', next, ...others);\n };\n\n const handleLeave = (...others) => console.log('<Form>::onLeave', ...others);\n\n const handleSubmit = (...others) => console.log('<Form>::onSubmit', ...others);\n\n return (\n <>\n <Form\n {...props}\n onLeave={handleLeave}\n onChange={handleChange}\n onError={handleError}\n onEnter={handleEnter}\n onSubmit={handleSubmit}\n >\n <View row>\n <Text headline>Form component</Text>\n </View>\n\n <InputText\n name=\"email\"\n error={!!error.email}\n test={(value) => value.includes('@mirai.com')}\n label=\"Email\"\n hint=\"Should contains @mirai.com\"\n required\n showRequired\n type=\"email\"\n value={form.email}\n />\n <InputText\n name=\"password\"\n error={!!error.password}\n hint=\"At least 10 chars.\"\n label=\"Password\"\n required\n showRequired\n minLength={10}\n type=\"password\"\n value={form.password}\n />\n <InputSelect\n name=\"gender\"\n emptyOption=\"Select...\"\n error={!!error.emptyOption}\n label=\"Your gender\"\n options={['one', 'two', 'three', 'four', 'five']}\n value={form.gender}\n />\n <InputDate\n name=\"dateOfBirth\"\n error={!!error.dateOfBirth}\n label=\"Your birthdate\"\n max=\"31/12/2022\"\n min=\"10/04/1980\"\n required\n showRequired\n type=\"inputDate\"\n value={form.dateOfBirth}\n />\n <InputPhone\n name=\"phone\"\n error={!!error.phone}\n label=\"Phone\"\n labelPrefix=\"Prefix\"\n prefixes={['+34', '+44', '+001', '+999', '+39', '+56']}\n required\n showRequired\n type=\"inputPhone\"\n value={form.phone}\n />\n <InputText name=\"bio\" label=\"Bio\" multiLine value={form.bio} />\n <InputNumber name=\"children\" label=\"Children\" hint=\"Ages 0 - 17\" value={form.children} />\n <InputOption type=\"checkbox\" name=\"checkbox\" label=\"checkbox\" checked={form.checkbox} required showRequired />\n <InputOption type=\"switch\" name=\"switch\" label=\"switch\" checked={form.switch} />\n {Array.from(Array(2).keys()).map((index) => (\n <InputOption\n key={index}\n type=\"radio\"\n name=\"radio\"\n value={`radio-${index}`}\n label={`radio-${index}`}\n checked={form.radio === `radio-${index}`}\n />\n ))}\n {condition && <InputText label=\"condition\" name=\"condition\" />}\n\n <Button disabled={Object.keys(error).length !== 0} type=\"submit\" wide>\n Submit\n </Button>\n </Form>\n\n <View row style={{ justifyContent: 'flex-end', marginTop: 'var(--mirai-ui-space-L)' }}>\n <Button small secondary onPress={() => setForm({})} style={{ marginRight: 'var(--mirai-ui-space-M)' }}>\n Reset\n </Button>\n <Button small secondary onPress={() => setCondition(!condition)}>\n {`${condition ? 'Hide' : 'Show'} dynamic field`}\n </Button>\n </View>\n </>\n );\n};\n\nStory.storyName = 'Form';\n\nStory.args = {\n debounce: 0,\n schema: {},\n showErrors: false,\n validateOnMount: false,\n // inherited properties\n ['data-testid']: 'test-story',\n style: {},\n};\n\nStory.argTypes = {};\n"],"mappings":";;;;;;;AAAA;AAEA;AACA;AAA8B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAEf;EAAEA,KAAK,EAAE;AAAa,CAAC;AAAA;AAE/B,IAAMC,KAAK,GAAG,SAARA,KAAK,CAAIC,KAAK,EAAK;EAC9B,gBAAkC,IAAAC,eAAQ,EAAC,KAAK,CAAC;IAAA;IAA1CC,SAAS;IAAEC,YAAY;EAC9B,iBAAwB,IAAAF,eAAQ,EAAC;MAC/BG,KAAK,EAAE,gBAAgB;MACvBC,QAAQ,EAAE,IAAI;MACdC,WAAW,EAAE,YAAY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K,CAACgD,QAAQ,GAAG,CAAC,CAAC"}
|
|
@@ -33,7 +33,7 @@ var getInputErrors = function getInputErrors() {
|
|
|
33
33
|
var errors = {};
|
|
34
34
|
|
|
35
35
|
// Common
|
|
36
|
-
if (required && (value === undefined || value.length === 0)) errors.required = true;
|
|
36
|
+
if (required && (value === undefined || value === false || value.length === 0)) errors.required = true;
|
|
37
37
|
if (minLength > 0 && value.length < minLength) errors.minLength = true;
|
|
38
38
|
if (regexp && regexp.exec && regexp.exec(value) === null) errors.regexp = true;
|
|
39
39
|
if (test && !test(value)) errors.test = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getInputErrors.js","names":["getInputErrors","minLength","regexp","required","test","type","value","others","errors","undefined","length","exec","isValidDate","isValidEmail","isValidPhone","format","getInputDateErrors","getInputPhoneErrors","Object","keys"],"sources":["../../src/helpers/getInputErrors.js"],"sourcesContent":["import { getInputDateErrors } from './getInputDateErrors';\nimport { getInputPhoneErrors } from './getInputPhoneErrors';\nimport { isValidDate } from './isValidDate';\nimport { isValidEmail } from './isValidEmail';\nimport { isValidPhone } from './isValidPhone';\n\nexport const getInputErrors = ({\n minLength = 0,\n regexp,\n required,\n test,\n type = 'text',\n value = '',\n ...others\n} = {}) => {\n let errors = {};\n\n // Common\n if (required && (value === undefined || value.length === 0)) errors.required = true;\n if (minLength > 0 && value.length < minLength) errors.minLength = true;\n if (regexp && regexp.exec && regexp.exec(value) === null) errors.regexp = true;\n if (test && !test(value)) errors.test = true;\n // Email, Phone & Date format\n if (\n (type === 'date' && !isValidDate(value, others)) ||\n (type === 'email' && !isValidEmail(value)) ||\n (type === 'tel' && !isValidPhone(value))\n )\n errors.format = true;\n // Custom Inputs\n if (type === 'inputDate') errors = { ...errors, ...getInputDateErrors({ ...others, value }) };\n if (type === 'inputPhone') errors = { ...errors, ...getInputPhoneErrors({ ...others, value }) };\n\n return Object.keys(errors).length > 0 ? errors : undefined;\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AAA8C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEvC,IAAMA,cAAc,GAAG,SAAjBA,cAAc,GAQhB;EAAA,+EAAP,CAAC,CAAC;IAAA,sBAPJC,SAAS;IAATA,SAAS,+BAAG,CAAC;IACbC,MAAM,QAANA,MAAM;IACNC,QAAQ,QAARA,QAAQ;IACRC,IAAI,QAAJA,IAAI;IAAA,iBACJC,IAAI;IAAJA,IAAI,0BAAG,MAAM;IAAA,kBACbC,KAAK;IAALA,KAAK,2BAAG,EAAE;IACPC,MAAM;EAET,IAAIC,MAAM,GAAG,CAAC,CAAC;;EAEf;EACA,IAAIL,QAAQ,KAAKG,KAAK,KAAKG,SAAS,IAAIH,KAAK,CAACI,MAAM,KAAK,CAAC,CAAC,EAAEF,MAAM,CAACL,QAAQ,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"getInputErrors.js","names":["getInputErrors","minLength","regexp","required","test","type","value","others","errors","undefined","length","exec","isValidDate","isValidEmail","isValidPhone","format","getInputDateErrors","getInputPhoneErrors","Object","keys"],"sources":["../../src/helpers/getInputErrors.js"],"sourcesContent":["import { getInputDateErrors } from './getInputDateErrors';\nimport { getInputPhoneErrors } from './getInputPhoneErrors';\nimport { isValidDate } from './isValidDate';\nimport { isValidEmail } from './isValidEmail';\nimport { isValidPhone } from './isValidPhone';\n\nexport const getInputErrors = ({\n minLength = 0,\n regexp,\n required,\n test,\n type = 'text',\n value = '',\n ...others\n} = {}) => {\n let errors = {};\n\n // Common\n if (required && (value === undefined || value === false || value.length === 0)) errors.required = true;\n if (minLength > 0 && value.length < minLength) errors.minLength = true;\n if (regexp && regexp.exec && regexp.exec(value) === null) errors.regexp = true;\n if (test && !test(value)) errors.test = true;\n // Email, Phone & Date format\n if (\n (type === 'date' && !isValidDate(value, others)) ||\n (type === 'email' && !isValidEmail(value)) ||\n (type === 'tel' && !isValidPhone(value))\n )\n errors.format = true;\n // Custom Inputs\n if (type === 'inputDate') errors = { ...errors, ...getInputDateErrors({ ...others, value }) };\n if (type === 'inputPhone') errors = { ...errors, ...getInputPhoneErrors({ ...others, value }) };\n\n return Object.keys(errors).length > 0 ? errors : undefined;\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AAA8C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEvC,IAAMA,cAAc,GAAG,SAAjBA,cAAc,GAQhB;EAAA,+EAAP,CAAC,CAAC;IAAA,sBAPJC,SAAS;IAATA,SAAS,+BAAG,CAAC;IACbC,MAAM,QAANA,MAAM;IACNC,QAAQ,QAARA,QAAQ;IACRC,IAAI,QAAJA,IAAI;IAAA,iBACJC,IAAI;IAAJA,IAAI,0BAAG,MAAM;IAAA,kBACbC,KAAK;IAALA,KAAK,2BAAG,EAAE;IACPC,MAAM;EAET,IAAIC,MAAM,GAAG,CAAC,CAAC;;EAEf;EACA,IAAIL,QAAQ,KAAKG,KAAK,KAAKG,SAAS,IAAIH,KAAK,KAAK,KAAK,IAAIA,KAAK,CAACI,MAAM,KAAK,CAAC,CAAC,EAAEF,MAAM,CAACL,QAAQ,GAAG,IAAI;EACtG,IAAIF,SAAS,GAAG,CAAC,IAAIK,KAAK,CAACI,MAAM,GAAGT,SAAS,EAAEO,MAAM,CAACP,SAAS,GAAG,IAAI;EACtE,IAAIC,MAAM,IAAIA,MAAM,CAACS,IAAI,IAAIT,MAAM,CAACS,IAAI,CAACL,KAAK,CAAC,KAAK,IAAI,EAAEE,MAAM,CAACN,MAAM,GAAG,IAAI;EAC9E,IAAIE,IAAI,IAAI,CAACA,IAAI,CAACE,KAAK,CAAC,EAAEE,MAAM,CAACJ,IAAI,GAAG,IAAI;EAC5C;EACA,IACGC,IAAI,KAAK,MAAM,IAAI,CAAC,IAAAO,wBAAW,EAACN,KAAK,EAAEC,MAAM,CAAC,IAC9CF,IAAI,KAAK,OAAO,IAAI,CAAC,IAAAQ,0BAAY,EAACP,KAAK,CAAE,IACzCD,IAAI,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