@mirai/ui 1.0.145 → 1.0.151
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/README.md +52 -27
- package/build/components/Action/Action.js +5 -3
- package/build/components/Action/Action.js.map +1 -1
- package/build/components/Action/Action.module.css +5 -0
- package/build/components/Action/__tests__/__snapshots__/Action.test.js.snap +10 -0
- package/build/components/Button/Button.module.css +9 -10
- package/build/components/Form/Form.js +5 -3
- package/build/components/Form/Form.js.map +1 -1
- package/build/components/Form/__tests__/__snapshots__/Form.test.jsx.snap +6 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -205,6 +205,37 @@ const MyComponent = () => (
|
|
|
205
205
|
--mirai-ui-radio-size: var(--mirai-ui-space-L);
|
|
206
206
|
```
|
|
207
207
|
|
|
208
|
+
### ScrollView
|
|
209
|
+
|
|
210
|
+
This primitive is used to make vertically scrollable views and receives the following props:
|
|
211
|
+
|
|
212
|
+
- `behavior:string` type of scroll animation
|
|
213
|
+
- `children:node`
|
|
214
|
+
- `height:number` height value
|
|
215
|
+
- `horizontal:boolean` layout direction
|
|
216
|
+
- `scrollEventThrottle:number` scroll timeout value
|
|
217
|
+
- `scrollIndicator:boolean` if true the scroll indicator is shown
|
|
218
|
+
- `scrollTo:number` coordinate to scroll to
|
|
219
|
+
- `snap:bool` if you want use the CSS feature `scroll-snap`
|
|
220
|
+
- `tag:string` html tag of resulting element
|
|
221
|
+
- `width:number` width value
|
|
222
|
+
- `onscroll:function` executed when user scrolls over the element
|
|
223
|
+
|
|
224
|
+
```jsx
|
|
225
|
+
import { ScrollView, View } from '@mirai/ui';
|
|
226
|
+
|
|
227
|
+
const MyComponent = ({ isDesktop }) => (
|
|
228
|
+
<ScrollView horizontal={isDesktop} onScroll={() => console.log('scrolling')}>
|
|
229
|
+
<View>Box 1</View>
|
|
230
|
+
<View>Box 2</View>
|
|
231
|
+
</ScrollView>
|
|
232
|
+
);
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### Select
|
|
236
|
+
|
|
237
|
+
> @TODO
|
|
238
|
+
|
|
208
239
|
### Switch
|
|
209
240
|
|
|
210
241
|
This primitive returns a _mobile_ checkbox button based on the following properties:
|
|
@@ -239,33 +270,6 @@ const MyComponent = () => (
|
|
|
239
270
|
--mirai-ui-switch-size: var(--mirai-ui-space-L);
|
|
240
271
|
```
|
|
241
272
|
|
|
242
|
-
### ScrollView
|
|
243
|
-
|
|
244
|
-
This primitive is used to make vertically scrollable views and receives the following props:
|
|
245
|
-
|
|
246
|
-
- `behavior:string` type of scroll animation
|
|
247
|
-
- `children:node`
|
|
248
|
-
- `height:number` height value
|
|
249
|
-
- `horizontal:boolean` layout direction
|
|
250
|
-
- `scrollEventThrottle:number` scroll timeout value
|
|
251
|
-
- `scrollIndicator:boolean` if true the scroll indicator is shown
|
|
252
|
-
- `scrollTo:number` coordinate to scroll to
|
|
253
|
-
- `snap:bool` if you want use the CSS feature `scroll-snap`
|
|
254
|
-
- `tag:string` html tag of resulting element
|
|
255
|
-
- `width:number` width value
|
|
256
|
-
- `onscroll:function` executed when user scrolls over the element
|
|
257
|
-
|
|
258
|
-
```jsx
|
|
259
|
-
import { ScrollView, View } from '@mirai/ui';
|
|
260
|
-
|
|
261
|
-
const MyComponent = ({ isDesktop }) => (
|
|
262
|
-
<ScrollView horizontal={isDesktop} onScroll={() => console.log('scrolling')}>
|
|
263
|
-
<View>Box 1</View>
|
|
264
|
-
<View>Box 2</View>
|
|
265
|
-
</ScrollView>
|
|
266
|
-
);
|
|
267
|
-
```
|
|
268
|
-
|
|
269
273
|
### Text
|
|
270
274
|
|
|
271
275
|
A primitive for displaying text. It receives the following props:
|
|
@@ -324,6 +328,7 @@ React components assembled with primitives.
|
|
|
324
328
|
|
|
325
329
|
A hyperlink component that receives the following props:
|
|
326
330
|
|
|
331
|
+
- `bold:boolean` modifying font-weight
|
|
327
332
|
- `children:node|string`
|
|
328
333
|
- `disabled:boolean` applying 'disabled' attribute
|
|
329
334
|
- `href:string` applying 'href' attribute & force `a` tag
|
|
@@ -482,6 +487,14 @@ const MyComponent = props => {
|
|
|
482
487
|
--mirai-ui-calendar-week-margin: 2px;
|
|
483
488
|
```
|
|
484
489
|
|
|
490
|
+
### Form
|
|
491
|
+
|
|
492
|
+
> @TODO
|
|
493
|
+
|
|
494
|
+
### InputDate
|
|
495
|
+
|
|
496
|
+
> @TODO
|
|
497
|
+
|
|
485
498
|
### InputNumber
|
|
486
499
|
|
|
487
500
|
Input number component controlling the value with 2 buttons. Receives the following props:
|
|
@@ -578,6 +591,14 @@ const MyComponent = () => {
|
|
|
578
591
|
--mirai-ui-input-option-padding-y: var(--mirai-ui-space-S);
|
|
579
592
|
```
|
|
580
593
|
|
|
594
|
+
### InputPhone
|
|
595
|
+
|
|
596
|
+
> @TODO
|
|
597
|
+
|
|
598
|
+
### InputSelect
|
|
599
|
+
|
|
600
|
+
> @TODO
|
|
601
|
+
|
|
581
602
|
### InputText
|
|
582
603
|
|
|
583
604
|
Text input component receiving the following props:
|
|
@@ -728,6 +749,10 @@ const MyComponent = (props) => {
|
|
|
728
749
|
--mirai-ui-modal-shadow: var(--mirai-ui-shadow);
|
|
729
750
|
```
|
|
730
751
|
|
|
752
|
+
### Notification
|
|
753
|
+
|
|
754
|
+
> @TODO
|
|
755
|
+
|
|
731
756
|
### Progress
|
|
732
757
|
|
|
733
758
|
A progress component receiving the following props:
|
|
@@ -10,7 +10,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
10
10
|
var _helpers = require("../../helpers");
|
|
11
11
|
var _primitives = require("../../primitives");
|
|
12
12
|
var _ActionModule = _interopRequireDefault(require("./Action.module.css"));
|
|
13
|
-
var _excluded = ["children", "disabled", "href", "inline", "large", "small", "tag", "target", "underline", "wide", "onPress"];
|
|
13
|
+
var _excluded = ["bold", "children", "disabled", "href", "inline", "large", "small", "tag", "target", "underline", "wide", "onPress"];
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
16
16
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
@@ -20,7 +20,8 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
|
20
20
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
21
21
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
22
22
|
var Action = function Action(_ref) {
|
|
23
|
-
var
|
|
23
|
+
var bold = _ref.bold,
|
|
24
|
+
children = _ref.children,
|
|
24
25
|
disabled = _ref.disabled,
|
|
25
26
|
href = _ref.href,
|
|
26
27
|
inline = _ref.inline,
|
|
@@ -37,7 +38,7 @@ var Action = function Action(_ref) {
|
|
|
37
38
|
disabled: disabled,
|
|
38
39
|
href: href,
|
|
39
40
|
tag: href ? 'a' : tag,
|
|
40
|
-
className: (0, _helpers.styles)(_ActionModule.default.action, disabled && _ActionModule.default.disabled, inline && _ActionModule.default.inline, large && _ActionModule.default.large, small && _ActionModule.default.small, underline && _ActionModule.default.underline, wide && _ActionModule.default.wide, others.className),
|
|
41
|
+
className: (0, _helpers.styles)(_ActionModule.default.action, bold && _ActionModule.default.bold, disabled && _ActionModule.default.disabled, inline && _ActionModule.default.inline, large && _ActionModule.default.large, small && _ActionModule.default.small, underline && _ActionModule.default.underline, wide && _ActionModule.default.wide, others.className),
|
|
41
42
|
onPress: function onPress(event) {
|
|
42
43
|
_onPress && _onPress(event);
|
|
43
44
|
if (href && target) window.open(href, target);else if (href) window.location = href;
|
|
@@ -47,6 +48,7 @@ var Action = function Action(_ref) {
|
|
|
47
48
|
exports.Action = Action;
|
|
48
49
|
Action.displayName = 'Component:Action';
|
|
49
50
|
Action.propTypes = {
|
|
51
|
+
bold: _propTypes.default.bool,
|
|
50
52
|
children: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]),
|
|
51
53
|
disabled: _propTypes.default.bool,
|
|
52
54
|
href: _propTypes.default.string,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Action.js","names":["Action","children","disabled","href","inline","large","small","tag","target","underline","wide","onPress","others","React","createElement","Pressable","className","styles","style","action","event","window","open","location","displayName","propTypes","PropTypes","oneOfType","string","node","
|
|
1
|
+
{"version":3,"file":"Action.js","names":["Action","bold","children","disabled","href","inline","large","small","tag","target","underline","wide","onPress","others","React","createElement","Pressable","className","styles","style","action","event","window","open","location","displayName","propTypes","PropTypes","bool","oneOfType","string","node","onEnter","func","onLeave"],"sources":["../../../src/components/Action/Action.jsx"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\n\nimport { styles } from '../../helpers';\nimport { Pressable } from '../../primitives';\nimport style from './Action.module.css';\n\nconst Action = ({\n bold,\n children,\n disabled,\n href,\n inline,\n large,\n small,\n tag = 'button',\n target,\n underline,\n wide,\n onPress,\n ...others\n}) =>\n React.createElement(\n Pressable,\n {\n ...others,\n disabled,\n href,\n tag: href ? 'a' : tag,\n className: styles(\n style.action,\n bold && style.bold,\n disabled && style.disabled,\n inline && style.inline,\n large && style.large,\n small && style.small,\n underline && style.underline,\n wide && style.wide,\n others.className,\n ),\n onPress: (event) => {\n onPress && onPress(event);\n if (href && target) window.open(href, target);\n else if (href) window.location = href;\n },\n },\n children,\n );\n\nAction.displayName = 'Component:Action';\n\nAction.propTypes = {\n bold: PropTypes.bool,\n children: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),\n disabled: PropTypes.bool,\n href: PropTypes.string,\n inline: PropTypes.bool,\n large: PropTypes.bool,\n small: PropTypes.bool,\n tag: PropTypes.string,\n target: PropTypes.string,\n underline: PropTypes.bool,\n wide: PropTypes.bool,\n onEnter: PropTypes.func,\n onLeave: PropTypes.func,\n onPress: PropTypes.func,\n};\n\nexport { Action };\n"],"mappings":";;;;;;;AAAA;AACA;AAEA;AACA;AACA;AAAwC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAExC,IAAMA,MAAM,GAAG,SAATA,MAAM;EAAA,IACVC,IAAI,QAAJA,IAAI;IACJC,QAAQ,QAARA,QAAQ;IACRC,QAAQ,QAARA,QAAQ;IACRC,IAAI,QAAJA,IAAI;IACJC,MAAM,QAANA,MAAM;IACNC,KAAK,QAALA,KAAK;IACLC,KAAK,QAALA,KAAK;IAAA,gBACLC,GAAG;IAAHA,GAAG,yBAAG,QAAQ;IACdC,MAAM,QAANA,MAAM;IACNC,SAAS,QAATA,SAAS;IACTC,IAAI,QAAJA,IAAI;IACJC,QAAO,QAAPA,OAAO;IACJC,MAAM;EAAA,oBAETC,cAAK,CAACC,aAAa,CACjBC,qBAAS,kCAEJH,MAAM;IACTV,QAAQ,EAARA,QAAQ;IACRC,IAAI,EAAJA,IAAI;IACJI,GAAG,EAAEJ,IAAI,GAAG,G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kBAAS,CAACC,IAAI;EACzBjB,IAAI,EAAEgB,kBAAS,CAACC,IAAI;EACpBI,OAAO,EAAEL,kBAAS,CAACM,IAAI;EACvBC,OAAO,EAAEP,kBAAS,CAACM,IAAI;EACvBrB,OAAO,EAAEe,kBAAS,CAACM;AACrB,CAAC"}
|
|
@@ -14,6 +14,11 @@
|
|
|
14
14
|
color: var(--mirai-ui-content);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
.action.bold {
|
|
18
|
+
font-family: var(--mirai-ui-font-bold);
|
|
19
|
+
font-weight: var(--mirai-ui-font-bold-weight);
|
|
20
|
+
}
|
|
21
|
+
|
|
17
22
|
.action.disabled,
|
|
18
23
|
.action.disabled * {
|
|
19
24
|
color: var(--mirai-ui-action-color-disabled);
|
|
@@ -10,6 +10,16 @@ exports[`component:<Action> inherit:className 1`] = `
|
|
|
10
10
|
</DocumentFragment>
|
|
11
11
|
`;
|
|
12
12
|
|
|
13
|
+
exports[`component:<Action> prop:bold 1`] = `
|
|
14
|
+
<DocumentFragment>
|
|
15
|
+
<button
|
|
16
|
+
class="pressable action bold"
|
|
17
|
+
>
|
|
18
|
+
children
|
|
19
|
+
</button>
|
|
20
|
+
</DocumentFragment>
|
|
21
|
+
`;
|
|
22
|
+
|
|
13
23
|
exports[`component:<Action> prop:disabled 1`] = `
|
|
14
24
|
<DocumentFragment>
|
|
15
25
|
<button
|
|
@@ -94,6 +94,15 @@ button.button.busy .spinner {
|
|
|
94
94
|
transform: translateY(0%);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
.button:not(:disabled).secondary:hover:not(:active) {
|
|
98
|
+
box-shadow: inset 0 0 0 var(--mirai-ui-border-width) var(--mirai-ui-button-color-hover);
|
|
99
|
+
color: var(--mirai-ui-button-color-focus);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.button:not(:disabled):not(.secondary):hover {
|
|
103
|
+
background-color: var(--mirai-ui-button-color-hover);
|
|
104
|
+
}
|
|
105
|
+
|
|
97
106
|
.busyContainer {
|
|
98
107
|
align-items: center;
|
|
99
108
|
justify-content: center;
|
|
@@ -180,13 +189,3 @@ button.button.busy .spinner {
|
|
|
180
189
|
left: calc(var(--mirai-ui-space-S) * 0.75);
|
|
181
190
|
}
|
|
182
191
|
|
|
183
|
-
@media only screen and (min-width: 600px) {
|
|
184
|
-
.button:not(:disabled).secondary:hover:not(:active) {
|
|
185
|
-
box-shadow: inset 0 0 0 var(--mirai-ui-border-width) var(--mirai-ui-button-color-hover);
|
|
186
|
-
color: var(--mirai-ui-button-color-focus);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
.button:not(:disabled):not(.secondary):hover {
|
|
190
|
-
background-color: var(--mirai-ui-button-color-hover);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
@@ -9,11 +9,10 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _Form = require("./Form.constants");
|
|
11
11
|
var _helpers = require("./helpers");
|
|
12
|
-
var _excluded = ["children", "debounce", "schema", "showErrors", "validateOnMount", "onBlur", "onChange", "onError", "onFocus", "onSubmit"];
|
|
12
|
+
var _excluded = ["children", "debounce", "schema", "showErrors", "tag", "validateOnMount", "onBlur", "onChange", "onError", "onFocus", "onSubmit"];
|
|
13
13
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
14
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
-
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); }
|
|
17
16
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
18
17
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
18
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -34,6 +33,8 @@ var Form = function Form(_ref) {
|
|
|
34
33
|
_ref$schema = _ref.schema,
|
|
35
34
|
schema = _ref$schema === void 0 ? {} : _ref$schema,
|
|
36
35
|
showErrors = _ref.showErrors,
|
|
36
|
+
_ref$tag = _ref.tag,
|
|
37
|
+
tag = _ref$tag === void 0 ? 'form' : _ref$tag,
|
|
37
38
|
_ref$validateOnMount = _ref.validateOnMount,
|
|
38
39
|
validateOnMount = _ref$validateOnMount === void 0 ? false : _ref$validateOnMount,
|
|
39
40
|
onBlur = _ref.onBlur,
|
|
@@ -145,7 +146,7 @@ var Form = function Form(_ref) {
|
|
|
145
146
|
event.preventDefault();
|
|
146
147
|
};
|
|
147
148
|
return (0, _react.useMemo)(function () {
|
|
148
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
149
|
+
return /*#__PURE__*/_react.default.createElement(tag, _objectSpread(_objectSpread({}, others), {}, {
|
|
149
150
|
onSubmit: handleSubmit
|
|
150
151
|
}), _react.default.Children.map(children, function (child, index) {
|
|
151
152
|
var _objectSpread4;
|
|
@@ -183,6 +184,7 @@ Form.propTypes = {
|
|
|
183
184
|
debounce: _propTypes.default.number,
|
|
184
185
|
schema: _propTypes.default.shape({}),
|
|
185
186
|
showErrors: _propTypes.default.bool,
|
|
187
|
+
tag: _propTypes.default.string,
|
|
186
188
|
validateOnMount: _propTypes.default.bool,
|
|
187
189
|
onBlur: _propTypes.default.func,
|
|
188
190
|
onChange: _propTypes.default.func,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.js","names":["Form","children","debounce","DEFAULT_TIMEOUT_ONCHANGE","schema","showErrors","validateOnMount","onBlur","onChange","onError","onFocus","onSubmit","others","useState","error","setError","initialValue","setInitialValue","touched","setTouched","values","setValues","useEffect","nextValues","getChildrenValues","nextChildrenKeys","Object","keys","sort","length","JSON","stringify","nextError","getChildrenErrors","collision","some","key","groupState","value","timer","setTimeout","clearTimeout","handleChange","field","fieldValue","handleError","DEFAULT_TIMEOUT_ONERROR","hasError","changed","errors","handleFocus","event","handleSubmit","preventDefault","useMemo","React","Children","map","child","index","props","type","displayName","getField","cloneElement","FIELDS_WITHOUT_ERRORS","includes","undefined","FIELDS_BOOLEAN","onPress","propTypes","PropTypes","node","number","shape","bool","func"],"sources":["../../../src/components/Form/Form.jsx"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React, { useEffect, useMemo, useState } from 'react';\n\nimport {\n DEFAULT_TIMEOUT_ONCHANGE,\n DEFAULT_TIMEOUT_ONERROR,\n FIELDS_BOOLEAN,\n FIELDS_WITHOUT_ERRORS,\n} from './Form.constants';\nimport { getChildrenErrors, getChildrenValues, getField, groupState } from './helpers';\n\nconst Form = ({\n children,\n debounce = DEFAULT_TIMEOUT_ONCHANGE,\n schema = {},\n showErrors,\n validateOnMount = false,\n onBlur,\n onChange,\n onError,\n onFocus,\n onSubmit,\n ...others\n}) => {\n const [error, setError] = useState({});\n const [initialValue, setInitialValue] = useState({});\n const [touched, setTouched] = useState({});\n const [values, setValues] = useState({});\n\n useEffect(() => {\n const nextValues = getChildrenValues(children);\n const nextChildrenKeys = Object.keys(nextValues).sort();\n\n if (!Object.keys(nextValues).length) return;\n\n if (JSON.stringify(nextChildrenKeys) !== JSON.stringify(Object.keys(initialValue).sort())) {\n setInitialValue(nextValues);\n setValues(nextValues);\n\n if (validateOnMount) {\n const nextError = getChildrenErrors({ children, schema, values: nextValues });\n setError(nextError);\n onError && onError(nextError);\n } else {\n setError({});\n }\n setTouched({});\n } else {\n const collision = nextChildrenKeys.some((key) => JSON.stringify(values[key]) !== JSON.stringify(nextValues[key]));\n if (collision) setValues(nextValues);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [children]);\n\n useEffect(() => {\n if (!onChange || values === initialValue || !Object.keys(values).length) return;\n\n if (!debounce) return onChange(values, groupState({ initialValue, value: values, touched }));\n\n const timer = setTimeout(() => onChange(values, groupState({ initialValue, value: values, touched })), debounce);\n return () => clearTimeout(timer);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [values]);\n\n const handleChange = (field, fieldValue) => {\n const nextValues = { ...values, [field]: fieldValue };\n\n setValues(nextValues);\n setTimeout(() => handleError(nextValues), DEFAULT_TIMEOUT_ONERROR);\n };\n\n const handleError = (values) => {\n const nextError = getChildrenErrors({ children, schema, values });\n const hasError = Object.keys(nextError).length > 0;\n const changed = JSON.stringify(error) !== JSON.stringify(nextError);\n\n if (changed) {\n setError(nextError);\n onError && onError(nextError, hasError);\n }\n\n return { changed, errors: nextError, hasError };\n };\n\n const handleFocus = (field, event) => {\n setTouched({ ...touched, [field]: true });\n if (onFocus) onFocus(field, event);\n };\n\n const handleSubmit = (event) => {\n const { errors, hasError } = handleError(values);\n\n if (hasError && onError) onError(errors, hasError);\n else if (onSubmit) onSubmit(values, groupState({ initialValue, value: values, touched }), event);\n event.preventDefault();\n };\n\n return useMemo(\n () => (\n <form {...others} onSubmit={handleSubmit}>\n {React.Children.map(children, (child, index) => {\n if (!child || child === null) return;\n\n const { props = {}, type: { displayName } = {} } = child || {};\n const { type } = props;\n const field = getField(props);\n\n return React.cloneElement(child, {\n key: index,\n ...(field\n ? {\n ...props,\n ...schema[field],\n error: !FIELDS_WITHOUT_ERRORS.includes(displayName)\n ? props.error || (showErrors && error[field])\n : undefined,\n [FIELDS_BOOLEAN.includes(displayName) ? 'checked' : 'value']: values[field],\n onBlur: onBlur ? (event) => onBlur(field, event) : undefined,\n onChange: (value) => handleChange(field, value),\n onFocus: (event) => handleFocus(field, event),\n }\n : type === 'submit'\n ? { ...props, onPress: handleSubmit }\n : undefined),\n });\n })}\n </form>\n ),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [children, error, others, schema],\n );\n};\n\nForm.displayName = 'Component:Form';\n\nForm.propTypes = {\n children: PropTypes.node,\n debounce: PropTypes.number,\n schema: PropTypes.shape({}),\n showErrors: PropTypes.bool,\n validateOnMount: PropTypes.bool,\n onBlur: PropTypes.func,\n onChange: PropTypes.func,\n onError: PropTypes.func,\n onFocus: PropTypes.func,\n onSubmit: PropTypes.func,\n};\n\nexport { Form };\n"],"mappings":";;;;;;;AAAA;AACA;AAEA;AAMA;AAAuF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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,"file":"Form.js","names":["Form","children","debounce","DEFAULT_TIMEOUT_ONCHANGE","schema","showErrors","tag","validateOnMount","onBlur","onChange","onError","onFocus","onSubmit","others","useState","error","setError","initialValue","setInitialValue","touched","setTouched","values","setValues","useEffect","nextValues","getChildrenValues","nextChildrenKeys","Object","keys","sort","length","JSON","stringify","nextError","getChildrenErrors","collision","some","key","groupState","value","timer","setTimeout","clearTimeout","handleChange","field","fieldValue","handleError","DEFAULT_TIMEOUT_ONERROR","hasError","changed","errors","handleFocus","event","handleSubmit","preventDefault","useMemo","React","createElement","Children","map","child","index","props","type","displayName","getField","cloneElement","FIELDS_WITHOUT_ERRORS","includes","undefined","FIELDS_BOOLEAN","onPress","propTypes","PropTypes","node","number","shape","bool","string","func"],"sources":["../../../src/components/Form/Form.jsx"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React, { useEffect, useMemo, useState } from 'react';\n\nimport {\n DEFAULT_TIMEOUT_ONCHANGE,\n DEFAULT_TIMEOUT_ONERROR,\n FIELDS_BOOLEAN,\n FIELDS_WITHOUT_ERRORS,\n} from './Form.constants';\nimport { getChildrenErrors, getChildrenValues, getField, groupState } from './helpers';\n\nconst Form = ({\n children,\n debounce = DEFAULT_TIMEOUT_ONCHANGE,\n schema = {},\n showErrors,\n tag = 'form',\n validateOnMount = false,\n onBlur,\n onChange,\n onError,\n onFocus,\n onSubmit,\n ...others\n}) => {\n const [error, setError] = useState({});\n const [initialValue, setInitialValue] = useState({});\n const [touched, setTouched] = useState({});\n const [values, setValues] = useState({});\n\n useEffect(() => {\n const nextValues = getChildrenValues(children);\n const nextChildrenKeys = Object.keys(nextValues).sort();\n\n if (!Object.keys(nextValues).length) return;\n\n if (JSON.stringify(nextChildrenKeys) !== JSON.stringify(Object.keys(initialValue).sort())) {\n setInitialValue(nextValues);\n setValues(nextValues);\n\n if (validateOnMount) {\n const nextError = getChildrenErrors({ children, schema, values: nextValues });\n setError(nextError);\n onError && onError(nextError);\n } else {\n setError({});\n }\n setTouched({});\n } else {\n const collision = nextChildrenKeys.some((key) => JSON.stringify(values[key]) !== JSON.stringify(nextValues[key]));\n if (collision) setValues(nextValues);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [children]);\n\n useEffect(() => {\n if (!onChange || values === initialValue || !Object.keys(values).length) return;\n\n if (!debounce) return onChange(values, groupState({ initialValue, value: values, touched }));\n\n const timer = setTimeout(() => onChange(values, groupState({ initialValue, value: values, touched })), debounce);\n return () => clearTimeout(timer);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [values]);\n\n const handleChange = (field, fieldValue) => {\n const nextValues = { ...values, [field]: fieldValue };\n\n setValues(nextValues);\n setTimeout(() => handleError(nextValues), DEFAULT_TIMEOUT_ONERROR);\n };\n\n const handleError = (values) => {\n const nextError = getChildrenErrors({ children, schema, values });\n const hasError = Object.keys(nextError).length > 0;\n const changed = JSON.stringify(error) !== JSON.stringify(nextError);\n\n if (changed) {\n setError(nextError);\n onError && onError(nextError, hasError);\n }\n\n return { changed, errors: nextError, hasError };\n };\n\n const handleFocus = (field, event) => {\n setTouched({ ...touched, [field]: true });\n if (onFocus) onFocus(field, event);\n };\n\n const handleSubmit = (event) => {\n const { errors, hasError } = handleError(values);\n\n if (hasError && onError) onError(errors, hasError);\n else if (onSubmit) onSubmit(values, groupState({ initialValue, value: values, touched }), event);\n event.preventDefault();\n };\n\n return useMemo(\n () =>\n React.createElement(\n tag,\n { ...others, onSubmit: handleSubmit },\n React.Children.map(children, (child, index) => {\n if (!child || child === null) return;\n\n const { props = {}, type: { displayName } = {} } = child || {};\n const { type } = props;\n const field = getField(props);\n\n return React.cloneElement(child, {\n key: index,\n ...(field\n ? {\n ...props,\n ...schema[field],\n error: !FIELDS_WITHOUT_ERRORS.includes(displayName)\n ? props.error || (showErrors && error[field])\n : undefined,\n [FIELDS_BOOLEAN.includes(displayName) ? 'checked' : 'value']: values[field],\n onBlur: onBlur ? (event) => onBlur(field, event) : undefined,\n onChange: (value) => handleChange(field, value),\n onFocus: (event) => handleFocus(field, event),\n }\n : type === 'submit'\n ? { ...props, onPress: handleSubmit }\n : undefined),\n });\n }),\n ),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [children, error, others, schema],\n );\n};\n\nForm.displayName = 'Component:Form';\n\nForm.propTypes = {\n children: PropTypes.node,\n debounce: PropTypes.number,\n schema: PropTypes.shape({}),\n showErrors: PropTypes.bool,\n tag: PropTypes.string,\n validateOnMount: PropTypes.bool,\n onBlur: PropTypes.func,\n onChange: PropTypes.func,\n onError: PropTypes.func,\n onFocus: PropTypes.func,\n onSubmit: PropTypes.func,\n};\n\nexport { Form };\n"],"mappings":";;;;;;;AAAA;AACA;AAEA;AAMA;AAAuF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEvF,IAAMA,IAAI,GAAG,SAAPA,IAAI,OAaJ;EAAA,IAZJC,QAAQ,QAARA,QAAQ;IAAA,qBACRC,QAAQ;IAARA,QAAQ,8BAAGC,8BAAwB;IAAA,mBACnCC,MAAM;IAANA,MAAM,4BAAG,CAAC,CAAC;IACXC,UAAU,QAAVA,UAAU;IAAA,gBACVC,GAAG;IAAHA,GAAG,yBAAG,MAAM;IAAA,4BACZC,eAAe;IAAfA,eAAe,qCAAG,KAAK;IACvBC,MAAM,QAANA,MAAM;IACNC,QAAQ,QAARA,QAAQ;IACRC,OAAO,QAAPA,OAAO;IACPC,OAAO,QAAPA,OAAO;IACPC,QAAQ,QAARA,QAAQ;IACLC,MAAM;EAET,gBAA0B,IAAAC,eAAQ,EAAC,CAAC,CAAC,CAAC;IAAA;IAA/BC,KAAK;IAAEC,QAAQ;EACtB,iBAAwC,IAAAF,eAAQ,EAAC,CAAC,CAAC,CAAC;IAAA;IAA7CG,YAAY;IAAEC,eAAe;EACpC,iBAA8B,IAAAJ,eAAQ,EAAC,CAAC,CAAC,CAAC;IAAA;IAAnCK,OAAO;IAAEC,UAA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AACH,CAAC;AAAC;AAEFJ,IAAI,CAACgE,WAAW,GAAG,gBAAgB;AAEnChE,IAAI,CAACwE,SAAS,GAAG;EACfvE,QAAQ,EAAEwE,kBAAS,CAACC,IAAI;EACxBxE,QAAQ,EAAEuE,kBAAS,CAACE,MAAM;EAC1BvE,MAAM,EAAEqE,kBAAS,CAACG,KAAK,CAAC,CAAC,CAAC,CAAC;EAC3BvE,UAAU,EAAEoE,kBAAS,CAACI,IAAI;EAC1BvE,GAAG,EAAEmE,kBAAS,CAACK,MAAM;EACrBvE,eAAe,EAAEkE,kBAAS,CAACI,IAAI;EAC/BrE,MAAM,EAAEiE,kBAAS,CAACM,IAAI;EACtBtE,QAAQ,EAAEgE,kBAAS,CAACM,IAAI;EACxBrE,OAAO,EAAE+D,kBAAS,CAACM,IAAI;EACvBpE,OAAO,EAAE8D,kBAAS,CAACM,IAAI;EACvBnE,QAAQ,EAAE6D,kBAAS,CAACM;AACtB,CAAC"}
|
|
@@ -38,6 +38,12 @@ exports[`component:<Form> prop:children 1`] = `
|
|
|
38
38
|
</DocumentFragment>
|
|
39
39
|
`;
|
|
40
40
|
|
|
41
|
+
exports[`component:<Form> prop:tag 1`] = `
|
|
42
|
+
<DocumentFragment>
|
|
43
|
+
<fieldset />
|
|
44
|
+
</DocumentFragment>
|
|
45
|
+
`;
|
|
46
|
+
|
|
41
47
|
exports[`component:<Form> renders 1`] = `
|
|
42
48
|
<DocumentFragment>
|
|
43
49
|
<form />
|