@startlibs/form 1.0.1 → 1.0.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/lib/index.js +907 -1002
- package/package.json +1 -1
- package/rollup.config.js +1 -1
package/lib/index.js
CHANGED
|
@@ -1,97 +1,89 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
var _negate = _interopDefault(require('lodash/fp/negate'));
|
|
58
|
-
var _zipObject = _interopDefault(require('lodash/fp/zipObject'));
|
|
59
|
-
var _last = _interopDefault(require('lodash/fp/last'));
|
|
60
|
-
var _flatten = _interopDefault(require('lodash/fp/flatten'));
|
|
61
|
-
var _fromPairs = _interopDefault(require('lodash/fp/fromPairs'));
|
|
62
|
-
var _pick = _interopDefault(require('lodash/fp/pick'));
|
|
63
|
-
var _toPairs = _interopDefault(require('lodash/fp/toPairs'));
|
|
64
|
-
var _entries = _interopDefault(require('lodash/fp/entries'));
|
|
1
|
+
import _extends from '@babel/runtime/helpers/extends';
|
|
2
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
3
|
+
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
4
|
+
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
5
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
6
|
+
import _objectSpread from '@babel/runtime/helpers/objectSpread';
|
|
7
|
+
import _set from 'lodash/fp/set';
|
|
8
|
+
import _update from 'lodash/fp/update';
|
|
9
|
+
import _isFunction from 'lodash/fp/isFunction';
|
|
10
|
+
import _get from 'lodash/fp/get';
|
|
11
|
+
import React, { useContext, useState, useMemo, useImperativeHandle, forwardRef, useEffect, useRef, useLayoutEffect, useCallback } from 'react';
|
|
12
|
+
import { willUseSpreadState, useRefState, StartlibsContext, useToggle, useIsUnmounted, useConsumerCatalog, usePopupToggle, useEnsureRef, usePreviousForEffect, useLazyConstant, useUpdateEffect, Fill, usePrevious, StartlibsConsumer, useRefMemo, useRecycleFocus, useRefToggle } from '@startlibs/core';
|
|
13
|
+
import { _s, callIfFunction, ifUndefined, formatPath, getMargin, customTheme, getColor, constrainEvent, media, addExtraProp, using, isTouchDevice, getScrollParent, digitsToPattern, intToHour, isElementInView, identityFn, getUID, normalizeText, stopPropagation, lazyValue, ifProp, formatDate, getNumberInputType, formatDateToPattern, parseDate, animationTiming, oneWayAnimation, linkRegex } from '@startlibs/utils';
|
|
14
|
+
import { useProvideErrors as useProvideErrors$1, useDraftConfirmation as useDraftConfirmation$1, ErrorsContext as ErrorsContext$1, useFormValue as useFormValue$1, HelpText as HelpText$1, WithForm as WithForm$1, Errors as Errors$1, useInput as useInput$1, Field as Field$1, FormContext as FormContext$1, TextInput as TextInput$1, useFormMeta as useFormMeta$1, Combobox as Combobox$1, PathContext as PathContext$1, FormValue as FormValue$1, SimpleRadiobox as SimpleRadiobox$1, SimpleCheckbox as SimpleCheckbox$1, enhanceInput as enhanceInput$1, useTransientErrorHelper as useTransientErrorHelper$1, Radiobox as Radiobox$1, Checkbox as Checkbox$1 } from '@startlibs/form';
|
|
15
|
+
import { Icon, TextButton, useDialog, useDialogWithToggle, Button, setNotification, Dialog, Loading, TransitionDiv, ContextListMenu, ListItem, willUseIsSticky, usePositioning, getDialogLayersSize, ListSeparator, ContextMenu, Li, willUseFlipSwitch, fixDoubledLastMarginBottom, SwitchDiv, SplitColumnsContainer } from '@startlibs/components';
|
|
16
|
+
import _identity from 'lodash/fp/identity';
|
|
17
|
+
import styled, { css as css$1 } from 'styled-components';
|
|
18
|
+
import _taggedTemplateLiteral from '@babel/runtime/helpers/taggedTemplateLiteral';
|
|
19
|
+
import { darken, lighten, desaturate } from 'polished';
|
|
20
|
+
import _isRegExp from 'lodash/fp/isRegExp';
|
|
21
|
+
import _isString from 'lodash/fp/isString';
|
|
22
|
+
import _difference from 'lodash/fp/difference';
|
|
23
|
+
import _property from 'lodash/fp/property';
|
|
24
|
+
import _uniqBy from 'lodash/fp/uniqBy';
|
|
25
|
+
import { createSelector } from 'reselect';
|
|
26
|
+
import _filter from 'lodash/fp/filter';
|
|
27
|
+
import _union from 'lodash/fp/union';
|
|
28
|
+
import _flow from 'lodash/fp/flow';
|
|
29
|
+
import _stubFalse from 'lodash/fp/stubFalse';
|
|
30
|
+
import _isFinite from 'lodash/fp/isFinite';
|
|
31
|
+
import _sortBy from 'lodash/fp/sortBy';
|
|
32
|
+
import { FixedSizeList } from 'react-window';
|
|
33
|
+
import _toPath from 'lodash/fp/toPath';
|
|
34
|
+
import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
|
|
35
|
+
import _createClass from '@babel/runtime/helpers/createClass';
|
|
36
|
+
import _possibleConstructorReturn from '@babel/runtime/helpers/possibleConstructorReturn';
|
|
37
|
+
import _getPrototypeOf from '@babel/runtime/helpers/getPrototypeOf';
|
|
38
|
+
import _inherits from '@babel/runtime/helpers/inherits';
|
|
39
|
+
import _map from 'lodash/fp/map';
|
|
40
|
+
import _isObject from 'lodash/fp/isObject';
|
|
41
|
+
import _unionBy from 'lodash/fp/unionBy';
|
|
42
|
+
import _uniq from 'lodash/fp/uniq';
|
|
43
|
+
import _differenceBy from 'lodash/fp/differenceBy';
|
|
44
|
+
import _intersection from 'lodash/fp/intersection';
|
|
45
|
+
import _intersectionBy from 'lodash/fp/intersectionBy';
|
|
46
|
+
import _isArray from 'lodash/fp/isArray';
|
|
47
|
+
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
48
|
+
import _isBoolean from 'lodash/fp/isBoolean';
|
|
49
|
+
import _negate from 'lodash/fp/negate';
|
|
50
|
+
import _zipObject from 'lodash/fp/zipObject';
|
|
51
|
+
import _last from 'lodash/fp/last';
|
|
52
|
+
import _flatten from 'lodash/fp/flatten';
|
|
53
|
+
import _fromPairs from 'lodash/fp/fromPairs';
|
|
54
|
+
import _pick from 'lodash/fp/pick';
|
|
55
|
+
import _toPairs from 'lodash/fp/toPairs';
|
|
56
|
+
import _entries from 'lodash/fp/entries';
|
|
65
57
|
|
|
66
58
|
var getFormResponse = function getFormResponse(setter) {
|
|
67
59
|
var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
68
60
|
return function (_, v) {
|
|
69
|
-
return setter(
|
|
61
|
+
return setter(_s.get(path, v));
|
|
70
62
|
};
|
|
71
63
|
};
|
|
72
64
|
var getFormValues = function getFormValues(setter) {
|
|
73
65
|
var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
74
66
|
return function (values) {
|
|
75
|
-
return setter(
|
|
67
|
+
return setter(_s.get(path, values));
|
|
76
68
|
};
|
|
77
69
|
};
|
|
78
|
-
var FormContext =
|
|
79
|
-
var ComponentMetaContext =
|
|
70
|
+
var FormContext = React.createContext({});
|
|
71
|
+
var ComponentMetaContext = React.createContext({});
|
|
80
72
|
|
|
81
|
-
var _willUseSpreadState =
|
|
73
|
+
var _willUseSpreadState = willUseSpreadState(),
|
|
82
74
|
_willUseSpreadState2 = _slicedToArray(_willUseSpreadState, 3),
|
|
83
75
|
useProvideValues = _willUseSpreadState2[0],
|
|
84
76
|
useSpreadValue = _willUseSpreadState2[1],
|
|
85
77
|
FormValueContext = _willUseSpreadState2[2];
|
|
86
78
|
|
|
87
|
-
var _willUseSpreadState3 =
|
|
79
|
+
var _willUseSpreadState3 = willUseSpreadState(),
|
|
88
80
|
_willUseSpreadState4 = _slicedToArray(_willUseSpreadState3, 2),
|
|
89
81
|
useProvideMeta = _willUseSpreadState4[0],
|
|
90
82
|
useMeta = _willUseSpreadState4[1];
|
|
91
83
|
|
|
92
84
|
var useFormValue = useSpreadValue;
|
|
93
85
|
var useFormValueRef = function useFormValueRef() {
|
|
94
|
-
var _useContext =
|
|
86
|
+
var _useContext = useContext(FormValueContext),
|
|
95
87
|
_useContext2 = _slicedToArray(_useContext, 2),
|
|
96
88
|
get = _useContext2[0],
|
|
97
89
|
set = _useContext2[1];
|
|
@@ -133,35 +125,35 @@ var useForm = function useForm(_ref, ref) {
|
|
|
133
125
|
alwaysSave: alwaysSave,
|
|
134
126
|
action: action
|
|
135
127
|
};
|
|
136
|
-
var currentInitialValues =
|
|
128
|
+
var currentInitialValues = useRefState(initialValues);
|
|
137
129
|
currentInitialValues.set(initialValues);
|
|
138
|
-
var startlibs =
|
|
130
|
+
var startlibs = useContext(StartlibsContext);
|
|
139
131
|
|
|
140
|
-
var _useState =
|
|
132
|
+
var _useState = useState(false),
|
|
141
133
|
_useState2 = _slicedToArray(_useState, 2),
|
|
142
134
|
hasChanged = _useState2[0],
|
|
143
135
|
setHasChangedValue = _useState2[1];
|
|
144
136
|
|
|
145
|
-
var hasChangedRef =
|
|
146
|
-
var shouldResubmitForm =
|
|
137
|
+
var hasChangedRef = useRefState(false);
|
|
138
|
+
var shouldResubmitForm = useToggle(false, function (next, prev) {
|
|
147
139
|
return prev && !next && errorsUtils.removeErrorPath('_shouldResubmitForm');
|
|
148
140
|
});
|
|
149
|
-
var resubmittingForm =
|
|
150
|
-
var loading =
|
|
151
|
-
var isUnmounted =
|
|
141
|
+
var resubmittingForm = useRefState(false);
|
|
142
|
+
var loading = useToggle();
|
|
143
|
+
var isUnmounted = useIsUnmounted();
|
|
152
144
|
|
|
153
|
-
var _useProvideErrors =
|
|
145
|
+
var _useProvideErrors = useProvideErrors$1(),
|
|
154
146
|
_useProvideErrors2 = _slicedToArray(_useProvideErrors, 3),
|
|
155
147
|
ErrorsProvider = _useProvideErrors2[0],
|
|
156
148
|
errorsContext = _useProvideErrors2[1],
|
|
157
149
|
errorsUtils = _useProvideErrors2[2];
|
|
158
150
|
|
|
159
|
-
var _useConsumerCatalog =
|
|
151
|
+
var _useConsumerCatalog = useConsumerCatalog(),
|
|
160
152
|
_useConsumerCatalog2 = _slicedToArray(_useConsumerCatalog, 2),
|
|
161
153
|
registeredComponentMetas = _useConsumerCatalog2[0],
|
|
162
154
|
componentMetasManager = _useConsumerCatalog2[1];
|
|
163
155
|
|
|
164
|
-
var _useDraftConfirmation =
|
|
156
|
+
var _useDraftConfirmation = useDraftConfirmation$1(function () {
|
|
165
157
|
return submitForm(undefined, {
|
|
166
158
|
isConfirming: true
|
|
167
159
|
});
|
|
@@ -176,7 +168,7 @@ var useForm = function useForm(_ref, ref) {
|
|
|
176
168
|
setHasChanged(true);
|
|
177
169
|
}
|
|
178
170
|
|
|
179
|
-
|
|
171
|
+
callIfFunction(onChange, prev, next, utils);
|
|
180
172
|
};
|
|
181
173
|
|
|
182
174
|
var setHasChanged = function setHasChanged(v) {
|
|
@@ -197,7 +189,7 @@ var useForm = function useForm(_ref, ref) {
|
|
|
197
189
|
getValues = _useProvideValues2$[0],
|
|
198
190
|
_setValues = _useProvideValues2$[1];
|
|
199
191
|
|
|
200
|
-
var _useProvideMeta = useProvideMeta(
|
|
192
|
+
var _useProvideMeta = useProvideMeta(callIfFunction(meta, initialValues), function (prev, next) {
|
|
201
193
|
if (prev.submittingFiles !== 0 && next.submittingFiles === 0) {
|
|
202
194
|
if (resubmittingForm.get()) {
|
|
203
195
|
if (shouldResubmitForm.get()) {
|
|
@@ -234,7 +226,7 @@ var useForm = function useForm(_ref, ref) {
|
|
|
234
226
|
values = _args.length > 0 && _args[0] !== undefined ? _args[0] : getValues();
|
|
235
227
|
validation = _args.length > 1 && _args[1] !== undefined ? _args[1] : preValidation;
|
|
236
228
|
_context.next = 4;
|
|
237
|
-
return
|
|
229
|
+
return callIfFunction(validation, values, utils);
|
|
238
230
|
|
|
239
231
|
case 4:
|
|
240
232
|
errors = _context.sent;
|
|
@@ -265,8 +257,8 @@ var useForm = function useForm(_ref, ref) {
|
|
|
265
257
|
file = _ref3.file,
|
|
266
258
|
image = _ref3.image;
|
|
267
259
|
|
|
268
|
-
if (
|
|
269
|
-
return
|
|
260
|
+
if (_s.get(path, acc) === file) {
|
|
261
|
+
return _s.set(path, image, acc);
|
|
270
262
|
} else {
|
|
271
263
|
return acc;
|
|
272
264
|
}
|
|
@@ -311,7 +303,7 @@ var useForm = function useForm(_ref, ref) {
|
|
|
311
303
|
return _context2.abrupt("return", new Promise(function () {}));
|
|
312
304
|
|
|
313
305
|
case 3:
|
|
314
|
-
values =
|
|
306
|
+
values = ifUndefined(callIfFunction(optValues, getValues()), getValues());
|
|
315
307
|
|
|
316
308
|
if (!getMeta('submittingFiles')) {
|
|
317
309
|
_context2.next = 10;
|
|
@@ -359,7 +351,7 @@ var useForm = function useForm(_ref, ref) {
|
|
|
359
351
|
}
|
|
360
352
|
|
|
361
353
|
loading.close();
|
|
362
|
-
|
|
354
|
+
callIfFunction(onNonPreValidation, values, errors);
|
|
363
355
|
throw {
|
|
364
356
|
unvalidated: errors
|
|
365
357
|
};
|
|
@@ -435,7 +427,7 @@ var useForm = function useForm(_ref, ref) {
|
|
|
435
427
|
|
|
436
428
|
_context2.prev = 47;
|
|
437
429
|
_context2.next = 50;
|
|
438
|
-
return onFailure(request, _context2.t0, utils
|
|
430
|
+
return onFailure(request, _context2.t0, utils);
|
|
439
431
|
|
|
440
432
|
case 50:
|
|
441
433
|
_context2.next = 55;
|
|
@@ -479,7 +471,7 @@ var useForm = function useForm(_ref, ref) {
|
|
|
479
471
|
};
|
|
480
472
|
|
|
481
473
|
var inputs = [loading, hasChanged, errorsContext, initialValues, transform, preValidation, onSuccess, onFailure, alwaysSave, action, shouldResubmitForm];
|
|
482
|
-
var utils
|
|
474
|
+
var utils = useMemo(function () {
|
|
483
475
|
return _objectSpread({
|
|
484
476
|
setValue: function setValue(path, value) {
|
|
485
477
|
var hasChanged = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
@@ -496,22 +488,22 @@ var useForm = function useForm(_ref, ref) {
|
|
|
496
488
|
});
|
|
497
489
|
},
|
|
498
490
|
resetForm: function resetForm() {
|
|
499
|
-
_setValues(
|
|
491
|
+
_setValues(ifUndefined(currentInitialValues.get(), {}));
|
|
500
492
|
|
|
501
493
|
setHasChanged(false);
|
|
502
494
|
},
|
|
503
495
|
resetField: function resetField(path) {
|
|
504
|
-
var initialValue =
|
|
496
|
+
var initialValue = _s.get(path, currentInitialValues.get());
|
|
505
497
|
|
|
506
498
|
if (initialValue !== getValues(path)) {
|
|
507
|
-
_setValues(
|
|
499
|
+
_setValues(_s.set(path, initialValue));
|
|
508
500
|
}
|
|
509
501
|
},
|
|
510
502
|
getOriginalValues: function getOriginalValues() {
|
|
511
503
|
return currentInitialValues.get();
|
|
512
504
|
},
|
|
513
505
|
getOriginalValue: function getOriginalValue(path) {
|
|
514
|
-
return
|
|
506
|
+
return _s.get(path, currentInitialValues.get());
|
|
515
507
|
},
|
|
516
508
|
getValues: getValues,
|
|
517
509
|
getValue: getValues,
|
|
@@ -534,28 +526,28 @@ var useForm = function useForm(_ref, ref) {
|
|
|
534
526
|
}
|
|
535
527
|
}, errorsUtils);
|
|
536
528
|
}, inputs);
|
|
537
|
-
|
|
538
|
-
return utils
|
|
529
|
+
useImperativeHandle(ref, function () {
|
|
530
|
+
return utils;
|
|
539
531
|
}, inputs);
|
|
540
532
|
return [function (children) {
|
|
541
|
-
return
|
|
542
|
-
value: utils
|
|
543
|
-
},
|
|
533
|
+
return React.createElement(FormContext.Provider, {
|
|
534
|
+
value: utils
|
|
535
|
+
}, React.createElement(ComponentMetaContext.Provider, {
|
|
544
536
|
value: componentMetasManager
|
|
545
|
-
},
|
|
537
|
+
}, React.createElement(ValuesProvider, {
|
|
546
538
|
value: valuesManager
|
|
547
|
-
},
|
|
539
|
+
}, React.createElement(MetaProvider, {
|
|
548
540
|
value: metaManager
|
|
549
|
-
},
|
|
541
|
+
}, React.createElement(ErrorsProvider, {
|
|
550
542
|
value: errorsContext
|
|
551
|
-
}, !skipDom ?
|
|
543
|
+
}, !skipDom ? React.createElement("form", {
|
|
552
544
|
autoComplete: autoComplete,
|
|
553
545
|
noValidate: true,
|
|
554
546
|
onSubmit: willSubmitForm
|
|
555
|
-
},
|
|
556
|
-
}, utils
|
|
547
|
+
}, callIfFunction(children, utils)) : callIfFunction(children, utils))))), confirmDraftContent);
|
|
548
|
+
}, utils];
|
|
557
549
|
};
|
|
558
|
-
var WithForm =
|
|
550
|
+
var WithForm = forwardRef(function (_ref5, ref) {
|
|
559
551
|
var children = _ref5.children,
|
|
560
552
|
rest = _objectWithoutProperties(_ref5, ["children"]);
|
|
561
553
|
|
|
@@ -567,7 +559,7 @@ var Form = function Form(_ref6) {
|
|
|
567
559
|
onSuccess = _ref6.onSuccess,
|
|
568
560
|
onFailure = _ref6.onFailure,
|
|
569
561
|
children = _ref6.children;
|
|
570
|
-
var form =
|
|
562
|
+
var form = useContext(FormContext);
|
|
571
563
|
|
|
572
564
|
var onSubmit = function onSubmit(e) {
|
|
573
565
|
if (e) e.preventDefault();
|
|
@@ -579,16 +571,16 @@ var Form = function Form(_ref6) {
|
|
|
579
571
|
});
|
|
580
572
|
};
|
|
581
573
|
|
|
582
|
-
return typeof children === 'function' ? children(onSubmit) :
|
|
574
|
+
return typeof children === 'function' ? children(onSubmit) : React.createElement("form", {
|
|
583
575
|
noValidate: true,
|
|
584
576
|
onSubmit: onSubmit
|
|
585
577
|
}, children);
|
|
586
578
|
};
|
|
587
579
|
|
|
588
580
|
var withForm = function withForm(Component) {
|
|
589
|
-
return
|
|
590
|
-
return
|
|
591
|
-
return
|
|
581
|
+
return React.forwardRef(function (props, ref) {
|
|
582
|
+
return React.createElement(WithForm, props, function (form) {
|
|
583
|
+
return React.createElement(Component, _extends({
|
|
592
584
|
form: form
|
|
593
585
|
}, props, {
|
|
594
586
|
ref: ref
|
|
@@ -598,9 +590,9 @@ var withForm = function withForm(Component) {
|
|
|
598
590
|
};
|
|
599
591
|
var withForm2 = function withForm2() {
|
|
600
592
|
return function (Component) {
|
|
601
|
-
return
|
|
602
|
-
return
|
|
603
|
-
return
|
|
593
|
+
return React.forwardRef(function (props, ref) {
|
|
594
|
+
return React.createElement(WithForm, props, function (form) {
|
|
595
|
+
return React.createElement(Component, _extends({
|
|
604
596
|
form: form
|
|
605
597
|
}, props, {
|
|
606
598
|
ref: ref
|
|
@@ -610,7 +602,7 @@ var withForm2 = function withForm2() {
|
|
|
610
602
|
};
|
|
611
603
|
};
|
|
612
604
|
|
|
613
|
-
var PathContext =
|
|
605
|
+
var PathContext = React.createContext([]);
|
|
614
606
|
var enhancedInputDisplayName = 'EnhancedInput';
|
|
615
607
|
|
|
616
608
|
var skipValidation = function skipValidation() {
|
|
@@ -622,7 +614,7 @@ var formInput = function formInput(_ref) {
|
|
|
622
614
|
_ref$isChecked = _ref.isChecked,
|
|
623
615
|
isChecked = _ref$isChecked === void 0 ? _identity : _ref$isChecked,
|
|
624
616
|
_ref$truthSource = _ref.truthSource,
|
|
625
|
-
truthSource = _ref$truthSource === void 0 ?
|
|
617
|
+
truthSource = _ref$truthSource === void 0 ? useFormValue$1 : _ref$truthSource,
|
|
626
618
|
_ref$transform = _ref.transform,
|
|
627
619
|
transform = _ref$transform === void 0 ? _identity : _ref$transform,
|
|
628
620
|
_ref$validation = _ref.validation,
|
|
@@ -630,13 +622,13 @@ var formInput = function formInput(_ref) {
|
|
|
630
622
|
onChange = _ref.onChange,
|
|
631
623
|
fieldValue = _ref.fieldValue,
|
|
632
624
|
propPath = _ref.path;
|
|
633
|
-
var contextPath =
|
|
625
|
+
var contextPath = useContext(PathContext);
|
|
634
626
|
|
|
635
|
-
var _useContext =
|
|
627
|
+
var _useContext = useContext(ErrorsContext$1),
|
|
636
628
|
paths = _useContext.paths;
|
|
637
629
|
|
|
638
|
-
var path =
|
|
639
|
-
var formattedPath =
|
|
630
|
+
var path = ifUndefined(propPath, contextPath);
|
|
631
|
+
var formattedPath = formatPath(path);
|
|
640
632
|
|
|
641
633
|
var _truthSource = truthSource(formattedPath),
|
|
642
634
|
_truthSource2 = _slicedToArray(_truthSource, 2),
|
|
@@ -655,7 +647,7 @@ var formInput = function formInput(_ref) {
|
|
|
655
647
|
}
|
|
656
648
|
|
|
657
649
|
setFormValue(transform(value, opts));
|
|
658
|
-
|
|
650
|
+
callIfFunction(onChange, callIfFunction(value, formValue), opts);
|
|
659
651
|
};
|
|
660
652
|
|
|
661
653
|
var setValueFromEventTarget = function setValueFromEventTarget(e) {
|
|
@@ -671,10 +663,10 @@ var formInput = function formInput(_ref) {
|
|
|
671
663
|
};
|
|
672
664
|
|
|
673
665
|
var toggleItem = function toggleItem() {
|
|
674
|
-
return setValue(
|
|
666
|
+
return setValue(_s.itemToggle(fieldValue));
|
|
675
667
|
};
|
|
676
668
|
|
|
677
|
-
return [
|
|
669
|
+
return [ifUndefined(formValue, undefinedPlaceholder), setValue, {
|
|
678
670
|
hasErrors: paths.has(formattedPath),
|
|
679
671
|
setFromField: setFromField,
|
|
680
672
|
toggle: toggle,
|
|
@@ -701,14 +693,14 @@ var rawInput = function rawInput(_ref2) {
|
|
|
701
693
|
fieldValue = _ref2.fieldValue,
|
|
702
694
|
defaultValue = _ref2.defaultValue;
|
|
703
695
|
|
|
704
|
-
var _useState =
|
|
696
|
+
var _useState = useState(ifUndefined(value, defaultValue)),
|
|
705
697
|
_useState2 = _slicedToArray(_useState, 2),
|
|
706
698
|
rawValue = _useState2[0],
|
|
707
699
|
setRawValue = _useState2[1];
|
|
708
700
|
|
|
709
|
-
var errorUtils =
|
|
710
|
-
var formattedPath =
|
|
711
|
-
|
|
701
|
+
var errorUtils = useContext(ErrorsContext$1);
|
|
702
|
+
var formattedPath = formatPath(path);
|
|
703
|
+
useEffect(function () {
|
|
712
704
|
setRawValue(value);
|
|
713
705
|
}, [value]);
|
|
714
706
|
|
|
@@ -721,7 +713,7 @@ var rawInput = function rawInput(_ref2) {
|
|
|
721
713
|
|
|
722
714
|
var transformedValue = transform(value);
|
|
723
715
|
setValueProp(transformedValue, element);
|
|
724
|
-
|
|
716
|
+
callIfFunction(onChange, transformedValue, rawValue, {
|
|
725
717
|
element: element
|
|
726
718
|
});
|
|
727
719
|
};
|
|
@@ -739,7 +731,7 @@ var rawInput = function rawInput(_ref2) {
|
|
|
739
731
|
};
|
|
740
732
|
|
|
741
733
|
var toggleItem = function toggleItem() {
|
|
742
|
-
return setValue(
|
|
734
|
+
return setValue(_s.itemToggle(fieldValue));
|
|
743
735
|
};
|
|
744
736
|
|
|
745
737
|
return [value, setValue, {
|
|
@@ -753,7 +745,7 @@ var rawInput = function rawInput(_ref2) {
|
|
|
753
745
|
};
|
|
754
746
|
|
|
755
747
|
var useInput = function useInput(props, raw) {
|
|
756
|
-
var _useState3 =
|
|
748
|
+
var _useState3 = useState(raw),
|
|
757
749
|
_useState4 = _slicedToArray(_useState3, 1),
|
|
758
750
|
isRaw = _useState4[0];
|
|
759
751
|
|
|
@@ -776,11 +768,11 @@ var EnhanceInput = function EnhanceInput(_ref3) {
|
|
|
776
768
|
}, utils));
|
|
777
769
|
};
|
|
778
770
|
var enhanceInput = function enhanceInput(InputComponent) {
|
|
779
|
-
return
|
|
771
|
+
return React.forwardRef(function (_ref4, ref) {
|
|
780
772
|
var props = _extends({}, _ref4);
|
|
781
773
|
|
|
782
|
-
return
|
|
783
|
-
return
|
|
774
|
+
return React.createElement(EnhanceInput, props, function (formInput) {
|
|
775
|
+
return React.createElement(InputComponent, _extends({}, props, {
|
|
784
776
|
ref: ref,
|
|
785
777
|
formInput: formInput
|
|
786
778
|
}));
|
|
@@ -788,39 +780,39 @@ var enhanceInput = function enhanceInput(InputComponent) {
|
|
|
788
780
|
});
|
|
789
781
|
};
|
|
790
782
|
|
|
791
|
-
var Mandatory =
|
|
783
|
+
var Mandatory = styled.span.withConfig({
|
|
792
784
|
displayName: "Field__Mandatory",
|
|
793
785
|
componentId: "p9woft-0"
|
|
794
786
|
})(["color:#c3282d;margin-left:1px;vertical-align:top;line-height:100%;margin-top:-1px;", ""], function (props) {
|
|
795
787
|
return typeof props.mandatory === 'string' && "color: ".concat(props.mandatory, ";");
|
|
796
788
|
});
|
|
797
|
-
var Container =
|
|
789
|
+
var Container = styled.div.withConfig({
|
|
798
790
|
displayName: "Field__Container",
|
|
799
791
|
componentId: "p9woft-1"
|
|
800
792
|
})(["position:relative;margin-bottom:", ";text-align:left;"], function (props) {
|
|
801
|
-
return
|
|
793
|
+
return getMargin(props.theme.Field.margins)(props);
|
|
802
794
|
});
|
|
803
|
-
var Label =
|
|
795
|
+
var Label = styled.label.withConfig({
|
|
804
796
|
displayName: "Field__Label",
|
|
805
797
|
componentId: "p9woft-2"
|
|
806
798
|
})(["font-weight:500;display:inline-block;font-size:", "px;margin-bottom:.5rem;", " ", ""], function (props) {
|
|
807
799
|
return props.labelFontSize ? props.labelFontSize : '14';
|
|
808
800
|
}, function (props) {
|
|
809
801
|
return props.isOnImage && 'color: #fff;';
|
|
810
|
-
},
|
|
811
|
-
var HelpText =
|
|
802
|
+
}, customTheme("FieldLabel"));
|
|
803
|
+
var HelpText = styled.span.withConfig({
|
|
812
804
|
displayName: "Field__HelpText",
|
|
813
805
|
componentId: "p9woft-3"
|
|
814
806
|
})(["color:rgba(0,0,0,0.4);font-weight:400;"]);
|
|
815
|
-
var FieldDescription =
|
|
807
|
+
var FieldDescription = styled.span.withConfig({
|
|
816
808
|
displayName: "Field__FieldDescription",
|
|
817
809
|
componentId: "p9woft-4"
|
|
818
810
|
})(["color:rgba(0,0,0,0.4);display:block;font-size:12px;margin:0.25rem 0 0;font-weight:400;"]);
|
|
819
|
-
var BellowFieldDescription =
|
|
811
|
+
var BellowFieldDescription = styled(FieldDescription).withConfig({
|
|
820
812
|
displayName: "Field__BellowFieldDescription",
|
|
821
813
|
componentId: "p9woft-5"
|
|
822
814
|
})(["margin:0.5rem 0 0;"]);
|
|
823
|
-
var Field =
|
|
815
|
+
var Field = React.forwardRef(function (_ref, ref) {
|
|
824
816
|
var label = _ref.label,
|
|
825
817
|
helpText = _ref.helpText,
|
|
826
818
|
descText = _ref.descText,
|
|
@@ -834,16 +826,16 @@ var Field = React__default.forwardRef(function (_ref, ref) {
|
|
|
834
826
|
labelFontSize = _ref.labelFontSize,
|
|
835
827
|
rest = _objectWithoutProperties(_ref, ["label", "helpText", "descText", "bellowDescText", "className", "labelClick", "focused", "mandatory", "onImage", "children", "labelFontSize"]);
|
|
836
828
|
|
|
837
|
-
return
|
|
829
|
+
return React.createElement(Container, _extends({
|
|
838
830
|
ref: ref
|
|
839
831
|
}, rest, {
|
|
840
832
|
className: className
|
|
841
|
-
}), label &&
|
|
833
|
+
}), label && React.createElement(Label, _extends({}, rest, {
|
|
842
834
|
onClick: labelClick,
|
|
843
835
|
labelFontSize: labelFontSize
|
|
844
|
-
}), label, mandatory &&
|
|
836
|
+
}), label, mandatory && React.createElement(Mandatory, {
|
|
845
837
|
mandatory: mandatory
|
|
846
|
-
}, "*"), helpText &&
|
|
838
|
+
}, "*"), helpText && React.createElement(HelpText, null, " ", helpText), descText && React.createElement(FieldDescription, null, descText)), children, bellowDescText && React.createElement(BellowFieldDescription, null, bellowDescText));
|
|
847
839
|
});
|
|
848
840
|
Field.Label = Label;
|
|
849
841
|
Field.Container = Container;
|
|
@@ -860,39 +852,39 @@ function _templateObject() {
|
|
|
860
852
|
|
|
861
853
|
return data;
|
|
862
854
|
}
|
|
863
|
-
var FieldBoxIcon =
|
|
855
|
+
var FieldBoxIcon = styled(Icon).withConfig({
|
|
864
856
|
displayName: "FieldBox__FieldBoxIcon",
|
|
865
857
|
componentId: "sc-18ntu84-0"
|
|
866
858
|
})(["font-size:25px;width:25px;text-align:center;margin-right:0.75rem;margin-left:-0.25rem;"]);
|
|
867
|
-
var FieldBoxAction =
|
|
859
|
+
var FieldBoxAction = styled.div.withConfig({
|
|
868
860
|
displayName: "FieldBox__FieldBoxAction",
|
|
869
861
|
componentId: "sc-18ntu84-1"
|
|
870
|
-
})(["margin-left:auto;color:", ";padding-left:1rem;font-size:13px;font-weight:500;"],
|
|
871
|
-
var FieldBoxHelpText =
|
|
862
|
+
})(["margin-left:auto;color:", ";padding-left:1rem;font-size:13px;font-weight:500;"], getColor('main'));
|
|
863
|
+
var FieldBoxHelpText = styled.span.withConfig({
|
|
872
864
|
displayName: "FieldBox__FieldBoxHelpText",
|
|
873
865
|
componentId: "sc-18ntu84-2"
|
|
874
866
|
})(["font-weight:400;color:rgba(0,0,0,0.4);font-size:12px;"]);
|
|
875
|
-
var FieldBoxContent =
|
|
867
|
+
var FieldBoxContent = styled.div.withConfig({
|
|
876
868
|
displayName: "FieldBox__FieldBoxContent",
|
|
877
869
|
componentId: "sc-18ntu84-3"
|
|
878
870
|
})(["margin-right:auto;min-width:0;"]);
|
|
879
|
-
var DeleteButton =
|
|
871
|
+
var DeleteButton = styled(Icon).attrs({
|
|
880
872
|
icon: 'x'
|
|
881
873
|
}).withConfig({
|
|
882
874
|
displayName: "FieldBox__DeleteButton",
|
|
883
875
|
componentId: "sc-18ntu84-4"
|
|
884
|
-
})(["width:24px;height:24px;line-height:24px;border-radius:50%;display:inline-block;font-size:18px;margin-left:0.75rem;text-align:center;cursor:pointer;color:", ";background-color:rgba(0,0,0,0.08);flex-shrink:0;:hover{background:rgba(0,0,0,0.11);}:active{background:rgba(0,0,0,0.13);}"],
|
|
885
|
-
var DropdownButton =
|
|
876
|
+
})(["width:24px;height:24px;line-height:24px;border-radius:50%;display:inline-block;font-size:18px;margin-left:0.75rem;text-align:center;cursor:pointer;color:", ";background-color:rgba(0,0,0,0.08);flex-shrink:0;:hover{background:rgba(0,0,0,0.11);}:active{background:rgba(0,0,0,0.13);}"], getColor('gray120'));
|
|
877
|
+
var DropdownButton = styled(Icon).attrs({
|
|
886
878
|
icon: 'arrow-down'
|
|
887
879
|
}).withConfig({
|
|
888
880
|
displayName: "FieldBox__DropdownButton",
|
|
889
881
|
componentId: "sc-18ntu84-5"
|
|
890
|
-
})(["width:24px;height:24px;line-height:24px;border-radius:50%;display:inline-block;font-size:14px;margin-left:0.75rem;text-align:center;cursor:pointer;color:", ";background-color:rgba(0,0,0,0.08);flex-shrink:0;position:relative;:hover{background:rgba(0,0,0,0.11);}:active{background:rgba(0,0,0,0.13);}"],
|
|
891
|
-
var DescText =
|
|
882
|
+
})(["width:24px;height:24px;line-height:24px;border-radius:50%;display:inline-block;font-size:14px;margin-left:0.75rem;text-align:center;cursor:pointer;color:", ";background-color:rgba(0,0,0,0.08);flex-shrink:0;position:relative;:hover{background:rgba(0,0,0,0.11);}:active{background:rgba(0,0,0,0.13);}"], getColor('gray120'));
|
|
883
|
+
var DescText = styled.div.withConfig({
|
|
892
884
|
displayName: "FieldBox__DescText",
|
|
893
885
|
componentId: "sc-18ntu84-6"
|
|
894
886
|
})(["font-weight:400;color:rgba(0,0,0,0.4);font-size:12px;margin-top:0.25rem;"]);
|
|
895
|
-
var FieldBox =
|
|
887
|
+
var FieldBox = styled(function (_ref) {
|
|
896
888
|
var className = _ref.className,
|
|
897
889
|
label = _ref.label,
|
|
898
890
|
helpText = _ref.helpText,
|
|
@@ -906,33 +898,33 @@ var FieldBox = styled__default(function (_ref) {
|
|
|
906
898
|
dropDownMenu = _ref.dropDownMenu,
|
|
907
899
|
props = _objectWithoutProperties(_ref, ["className", "label", "helpText", "descText", "actionLabel", "rightContainer", "onClick", "icon", "remove", "children", "dropDownMenu"]);
|
|
908
900
|
|
|
909
|
-
var menuToggle =
|
|
910
|
-
return
|
|
901
|
+
var menuToggle = usePopupToggle();
|
|
902
|
+
return React.createElement("div", _extends({
|
|
911
903
|
className: className,
|
|
912
904
|
onClick: onClick
|
|
913
|
-
}, props), icon &&
|
|
905
|
+
}, props), icon && React.createElement(FieldBoxIcon, {
|
|
914
906
|
icon: icon
|
|
915
|
-
}),
|
|
907
|
+
}), React.createElement(FieldBoxContent, null, label, helpText && React.createElement(HelpText$1, null, " ", helpText), descText && React.createElement(DescText, null, descText), children), actionLabel && React.createElement(TextButton, null, actionLabel), rightContainer && React.createElement("div", {
|
|
916
908
|
className: "rightContainer"
|
|
917
|
-
}, rightContainer), remove &&
|
|
918
|
-
onClick:
|
|
919
|
-
}), dropDownMenu &&
|
|
920
|
-
onClick:
|
|
921
|
-
}, menuToggle.isOpen &&
|
|
909
|
+
}, rightContainer), remove && React.createElement(DeleteButton, {
|
|
910
|
+
onClick: constrainEvent(remove)
|
|
911
|
+
}), dropDownMenu && React.createElement(DropdownButton, {
|
|
912
|
+
onClick: constrainEvent(menuToggle.toggle)
|
|
913
|
+
}, menuToggle.isOpen && callIfFunction(dropDownMenu)));
|
|
922
914
|
}).withConfig({
|
|
923
915
|
displayName: "FieldBox",
|
|
924
916
|
componentId: "sc-18ntu84-7"
|
|
925
|
-
})(["display:flex;align-items:center;width:100%;background:", ";border-radius:6px;min-height:42px;padding:1rem 1.25rem;align-items:center;font-size:14px;color:", ";position:relative;transition:border-radius 0.5s ease;", " & ~ &{margin-top:0.75rem;}", " ", ",.rightContainer{margin-left:1rem;}"],
|
|
926
|
-
return props.onClick &&
|
|
927
|
-
return
|
|
917
|
+
})(["display:flex;align-items:center;width:100%;background:", ";border-radius:6px;min-height:42px;padding:1rem 1.25rem;align-items:center;font-size:14px;color:", ";position:relative;transition:border-radius 0.5s ease;", " & ~ &{margin-top:0.75rem;}", " ", ",.rightContainer{margin-left:1rem;}"], getColor('lightBluishGray'), getColor('gray60'), function (props) {
|
|
918
|
+
return props.onClick && css$1(["cursor:pointer;:hover{background:", ";}:active{background:", ";transition:none;}"], function (props) {
|
|
919
|
+
return darken(0.035, getColor('lightBluishGray')(props));
|
|
928
920
|
}, function (props) {
|
|
929
|
-
return
|
|
921
|
+
return darken(0.05, getColor('lightBluishGray')(props));
|
|
930
922
|
});
|
|
931
|
-
},
|
|
923
|
+
}, media.mobile(_templateObject()), TextButton);
|
|
932
924
|
|
|
933
925
|
var useConfirmDialog = function useConfirmDialog(dialog, args, toggleCallback) {
|
|
934
|
-
return
|
|
935
|
-
return
|
|
926
|
+
return useDialog(function (closeDialog) {
|
|
927
|
+
return addExtraProp(callIfFunction(dialog, closeDialog), {
|
|
936
928
|
closeDialog: closeDialog
|
|
937
929
|
});
|
|
938
930
|
}, args, toggleCallback);
|
|
@@ -942,8 +934,8 @@ var useConfirmDialogWithProps = function useConfirmDialogWithProps(dialog, args)
|
|
|
942
934
|
_ref$overrideClose = _ref.overrideClose,
|
|
943
935
|
overrideClose = _ref$overrideClose === void 0 ? true : _ref$overrideClose;
|
|
944
936
|
|
|
945
|
-
return
|
|
946
|
-
return
|
|
937
|
+
return useDialogWithToggle(function (toggle) {
|
|
938
|
+
return addExtraProp(callIfFunction(dialog, toggle.isOpen, toggle.close), {
|
|
947
939
|
closeDialog: toggle.close
|
|
948
940
|
}, overrideClose);
|
|
949
941
|
}, args);
|
|
@@ -959,7 +951,7 @@ var ConfirmDialog = function ConfirmDialog(_ref2) {
|
|
|
959
951
|
_ref2$cancelLabel = _ref2.cancelLabel,
|
|
960
952
|
cancelLabel = _ref2$cancelLabel === void 0 ? "Cancelar" : _ref2$cancelLabel,
|
|
961
953
|
_ref2$cancelButton = _ref2.cancelButton,
|
|
962
|
-
cancelButton = _ref2$cancelButton === void 0 ? cancelLabel &&
|
|
954
|
+
cancelButton = _ref2$cancelButton === void 0 ? cancelLabel && React.createElement(Button, {
|
|
963
955
|
tabIndex: 2
|
|
964
956
|
}, cancelLabel) : _ref2$cancelButton,
|
|
965
957
|
onFailure = _ref2.onFailure,
|
|
@@ -987,7 +979,7 @@ var ConfirmDialog = function ConfirmDialog(_ref2) {
|
|
|
987
979
|
skipErrors = _ref2.skipErrors,
|
|
988
980
|
hidden = _ref2.hidden,
|
|
989
981
|
skipCheckFocus = _ref2.skipCheckFocus;
|
|
990
|
-
return
|
|
982
|
+
return React.createElement(WithForm$1, {
|
|
991
983
|
alwaysSave: alwaysSave,
|
|
992
984
|
ref: formRef,
|
|
993
985
|
preValidation: preValidation,
|
|
@@ -1003,20 +995,20 @@ var ConfirmDialog = function ConfirmDialog(_ref2) {
|
|
|
1003
995
|
props[_key] = arguments[_key];
|
|
1004
996
|
}
|
|
1005
997
|
|
|
1006
|
-
return Promise.resolve(
|
|
998
|
+
return Promise.resolve(callIfFunction.apply(void 0, [_onSuccess].concat(props))).then(function (v) {
|
|
1007
999
|
if (!keepOnSuccess) {
|
|
1008
1000
|
closeDialog();
|
|
1009
1001
|
}
|
|
1010
1002
|
|
|
1011
1003
|
if (notify) {
|
|
1012
|
-
|
|
1004
|
+
setNotification(notify);
|
|
1013
1005
|
}
|
|
1014
1006
|
|
|
1015
1007
|
return v;
|
|
1016
1008
|
});
|
|
1017
1009
|
}
|
|
1018
|
-
}, function (form
|
|
1019
|
-
return !hidden &&
|
|
1010
|
+
}, function (form) {
|
|
1011
|
+
return !hidden && React.createElement(Dialog, {
|
|
1020
1012
|
className: className,
|
|
1021
1013
|
title: title,
|
|
1022
1014
|
skipCheckFocus: skipCheckFocus,
|
|
@@ -1024,23 +1016,23 @@ var ConfirmDialog = function ConfirmDialog(_ref2) {
|
|
|
1024
1016
|
confirmChanges: confirmChanges,
|
|
1025
1017
|
isLoading: isLoading,
|
|
1026
1018
|
closeDialog: closeDialog,
|
|
1027
|
-
form: form
|
|
1019
|
+
form: form,
|
|
1028
1020
|
stickyFooter: stickyFooter,
|
|
1029
1021
|
auxiliarActions: auxiliarActions,
|
|
1030
1022
|
fullscreen: fullscreen,
|
|
1031
1023
|
fullscreenOnMobile: fullscreenOnMobile,
|
|
1032
|
-
footer: (cancelButton || alternativeButton || confirm) &&
|
|
1024
|
+
footer: (cancelButton || alternativeButton || confirm) && React.createElement(React.Fragment, null, cancelButton && addExtraProp(callIfFunction(cancelButton, closeDialog), {
|
|
1033
1025
|
onClick: closeDialog
|
|
1034
|
-
}, false),
|
|
1035
|
-
form: form
|
|
1026
|
+
}, false), callIfFunction(alternativeButton, closeDialog), confirm && using(callIfFunction(confirm, {
|
|
1027
|
+
form: form,
|
|
1036
1028
|
isLoading: isLoading
|
|
1037
1029
|
}))(function (c) {
|
|
1038
|
-
return c &&
|
|
1039
|
-
isLoading: form
|
|
1030
|
+
return c && addExtraProp(c, {
|
|
1031
|
+
isLoading: form.isLoading,
|
|
1040
1032
|
type: "submit"
|
|
1041
1033
|
});
|
|
1042
1034
|
}))
|
|
1043
|
-
},
|
|
1035
|
+
}, callIfFunction(children, form), !skipErrors && React.createElement(Errors$1, {
|
|
1044
1036
|
autoScroll: true
|
|
1045
1037
|
}));
|
|
1046
1038
|
});
|
|
@@ -1076,55 +1068,55 @@ function _templateObject$1() {
|
|
|
1076
1068
|
|
|
1077
1069
|
return data;
|
|
1078
1070
|
}
|
|
1079
|
-
var InputLoading =
|
|
1071
|
+
var InputLoading = styled(Loading).withConfig({
|
|
1080
1072
|
displayName: "TextInput__InputLoading",
|
|
1081
1073
|
componentId: "yzpeng-0"
|
|
1082
|
-
})(["bottom:8px;right:0.6rem;left:auto;top:auto;", " "],
|
|
1083
|
-
var Input =
|
|
1074
|
+
})(["bottom:8px;right:0.6rem;left:auto;top:auto;", " "], media.mobile(_templateObject$1()));
|
|
1075
|
+
var Input = styled.input.withConfig({
|
|
1084
1076
|
displayName: "TextInput__Input",
|
|
1085
1077
|
componentId: "yzpeng-1"
|
|
1086
|
-
})(["width:100%;font-size:14px;border:1px solid ", ";border-radius:6px;outline:0;outline:none;color:", ";background:white;position:relative;height:3rem;padding:0 0.7rem;overflow:auto;", "::-webkit-input-placeholder{color:rgba(0,0,0,0.3);}::-moz-placeholder{color:rgba(0,0,0,0.3);}:-moz-placeholder{color:rgba(0,0,0,0.3);}:-ms-input-placeholder{color:rgba(0,0,0,0.3);}", "::-ms-clear{display:none;}", " ", " ", ""],
|
|
1087
|
-
return !props.hasTextBox && !props.noFocus &&
|
|
1088
|
-
return props.hasErrors &&
|
|
1078
|
+
})(["width:100%;font-size:14px;border:1px solid ", ";border-radius:6px;outline:0;outline:none;color:", ";background:white;position:relative;height:3rem;padding:0 0.7rem;overflow:auto;", "::-webkit-input-placeholder{color:rgba(0,0,0,0.3);}::-moz-placeholder{color:rgba(0,0,0,0.3);}:-moz-placeholder{color:rgba(0,0,0,0.3);}:-ms-input-placeholder{color:rgba(0,0,0,0.3);}", "::-ms-clear{display:none;}", " ", " ", ""], getColor('gray210'), getColor('gray60'), media.mobile(_templateObject2()), function (props) {
|
|
1079
|
+
return !props.hasTextBox && !props.noFocus && css$1([":focus{border-color:", ";box-shadow:0px 0px 0px 2px rgba(0,0,0,0.1);}", ""], getColor('gray180'), function (props) {
|
|
1080
|
+
return props.hasErrors && css$1(["border-color:", " !important;"], getColor('alert'));
|
|
1089
1081
|
});
|
|
1090
1082
|
}, function (props) {
|
|
1091
|
-
return props.locked &&
|
|
1083
|
+
return props.locked && css$1(["padding-right:2.25rem;background:rgba(0,0,0,0.075);pointer-events:none;"]);
|
|
1092
1084
|
}, function (props) {
|
|
1093
|
-
return props.isTextArea &&
|
|
1085
|
+
return props.isTextArea && css$1(["resize:none;min-height:", "px;padding:.7rem;display:block;", " ", ""], function (props) {
|
|
1094
1086
|
return props.regularInputHeight ? 36 : props.minHeight || 60;
|
|
1095
1087
|
}, function (props) {
|
|
1096
1088
|
return props.autoResize ? 'overflow:hidden;' : 'overflow:auto;';
|
|
1097
|
-
},
|
|
1089
|
+
}, media.mobile(_templateObject3(), function (props) {
|
|
1098
1090
|
return props.regularInputHeight && 'min-height: 42px;';
|
|
1099
1091
|
}));
|
|
1100
|
-
},
|
|
1101
|
-
var InputWithTextBox =
|
|
1092
|
+
}, customTheme('TextInput'));
|
|
1093
|
+
var InputWithTextBox = styled.div.withConfig({
|
|
1102
1094
|
displayName: "TextInput__InputWithTextBox",
|
|
1103
1095
|
componentId: "yzpeng-2"
|
|
1104
1096
|
})(["display:flex;border-radius:6px;position:relative;:before{position:absolute;border-radius:6px;top:0;bottom:0;right:0;left:0;z-index:2;pointer-events:none;}", " ", " ", ""], function (props) {
|
|
1105
|
-
return props.focused &&
|
|
1097
|
+
return props.focused && css$1(["box-shadow:0px 0px 0px 2px rgba(0,0,0,0.1);:before{content:'';border:1px solid ", ";}"], getColor('gray180'));
|
|
1106
1098
|
}, function (props) {
|
|
1107
|
-
return props.hasErrors &&
|
|
1099
|
+
return props.hasErrors && css$1([":before{content:'';border:1px solid ", ";}"], getColor('alert'));
|
|
1108
1100
|
}, function (props) {
|
|
1109
|
-
return (props.textBoxBefore || props.textBoxAfter) &&
|
|
1101
|
+
return (props.textBoxBefore || props.textBoxAfter) && css$1(["input{border-top-left-radius:0;border-bottom-left-radius:0;}"]);
|
|
1110
1102
|
});
|
|
1111
|
-
var TextBox =
|
|
1103
|
+
var TextBox = styled.span.withConfig({
|
|
1112
1104
|
displayName: "TextInput__TextBox",
|
|
1113
1105
|
componentId: "yzpeng-3"
|
|
1114
1106
|
})(["display:flex;align-items:center;padding:0 0.7rem;z-index:1;background-color:", ";border:1px solid ", ";cursor:text;white-space:nowrap;"], function (props) {
|
|
1115
|
-
return
|
|
1116
|
-
},
|
|
1117
|
-
var TextBoxBefore =
|
|
1107
|
+
return darken(0.075, getColor('gray240')(props));
|
|
1108
|
+
}, getColor('gray210'));
|
|
1109
|
+
var TextBoxBefore = styled(TextBox).withConfig({
|
|
1118
1110
|
displayName: "TextInput__TextBoxBefore",
|
|
1119
1111
|
componentId: "yzpeng-4"
|
|
1120
1112
|
})(["border-top-left-radius:6px;border-bottom-left-radius:6px;margin-right:-1px;"]);
|
|
1121
|
-
var TextBoxAfter =
|
|
1113
|
+
var TextBoxAfter = styled(TextBox).withConfig({
|
|
1122
1114
|
displayName: "TextInput__TextBoxAfter",
|
|
1123
1115
|
componentId: "yzpeng-5"
|
|
1124
1116
|
})(["border-top-right-radius:6px;border-bottom-right-radius:6px;margin-left:-1px;"]);
|
|
1125
1117
|
|
|
1126
1118
|
var doAutoResize = function doAutoResize(element) {
|
|
1127
|
-
var scrollContainer =
|
|
1119
|
+
var scrollContainer = getScrollParent(element);
|
|
1128
1120
|
var lastTop = scrollContainer.scrollTop || scrollContainer.pageYOffset;
|
|
1129
1121
|
element.style.height = 'auto';
|
|
1130
1122
|
element.style.height = element.scrollHeight + 'px';
|
|
@@ -1152,7 +1144,7 @@ var useTextInput = function useTextInput(_ref, ref) {
|
|
|
1152
1144
|
deleteTrailing = _ref.deleteTrailing,
|
|
1153
1145
|
rest = _objectWithoutProperties(_ref, ["onFocus", "onBlur", "autoResize", "constraint", "pattern", "path", "rawValue", "rawSetValue", "rawHasErrors", "transformOnBlur", "raw", "showValue", "deleteTrailing"]);
|
|
1154
1146
|
|
|
1155
|
-
var _useInput =
|
|
1147
|
+
var _useInput = useInput$1(_objectSpread({
|
|
1156
1148
|
path: path,
|
|
1157
1149
|
value: rawValue,
|
|
1158
1150
|
setValue: rawSetValue
|
|
@@ -1162,34 +1154,34 @@ var useTextInput = function useTextInput(_ref, ref) {
|
|
|
1162
1154
|
setFormValue = _useInput2[1],
|
|
1163
1155
|
hasErrors = _useInput2[2].hasErrors;
|
|
1164
1156
|
|
|
1165
|
-
var _useState =
|
|
1157
|
+
var _useState = useState(),
|
|
1166
1158
|
_useState2 = _slicedToArray(_useState, 2),
|
|
1167
1159
|
focused = _useState2[0],
|
|
1168
1160
|
setFocused = _useState2[1];
|
|
1169
1161
|
|
|
1170
|
-
var lastSelection =
|
|
1171
|
-
var lastValue =
|
|
1162
|
+
var lastSelection = useRefState();
|
|
1163
|
+
var lastValue = useRefState(showValue(formValue));
|
|
1172
1164
|
|
|
1173
1165
|
var handleOnFocus = function handleOnFocus(e) {
|
|
1174
1166
|
setFocused(true);
|
|
1175
|
-
|
|
1167
|
+
callIfFunction(onFocus, e);
|
|
1176
1168
|
};
|
|
1177
1169
|
|
|
1178
1170
|
var handleOnBlur = function handleOnBlur(e) {
|
|
1179
1171
|
setFocused(false);
|
|
1180
|
-
|
|
1172
|
+
callIfFunction(onBlur, e);
|
|
1181
1173
|
|
|
1182
1174
|
if (transformOnBlur) {
|
|
1183
1175
|
setFormValue(transformOnBlur(formValue));
|
|
1184
1176
|
}
|
|
1185
1177
|
};
|
|
1186
1178
|
|
|
1187
|
-
|
|
1179
|
+
useEffect(function () {
|
|
1188
1180
|
if (lastSelection.get() === 1 && constraint === 'capitalize') {
|
|
1189
1181
|
ref.current.setSelectionRange(lastSelection.get(), lastSelection.get());
|
|
1190
1182
|
}
|
|
1191
1183
|
});
|
|
1192
|
-
|
|
1184
|
+
useEffect(function () {
|
|
1193
1185
|
if (autoResize) {
|
|
1194
1186
|
doAutoResize(ref.current);
|
|
1195
1187
|
}
|
|
@@ -1242,7 +1234,7 @@ var useTextInput = function useTextInput(_ref, ref) {
|
|
|
1242
1234
|
var number = parseFloat(value.replace(',', '.'));
|
|
1243
1235
|
var commas = value.split(',');
|
|
1244
1236
|
var fixedNumber = number.toFixed(2);
|
|
1245
|
-
newValue = !!commas[0] && commas.length === 2 && parseFloat(fixedNumber) === number && fixedNumber.split('.')[1].indexOf(commas[1]) === 0 ? value :
|
|
1237
|
+
newValue = !!commas[0] && commas.length === 2 && parseFloat(fixedNumber) === number && fixedNumber.split('.')[1].indexOf(commas[1]) === 0 ? value : digitsToPattern('>3???????#,##', value);
|
|
1246
1238
|
} else if (constraint === 'capitalize') {
|
|
1247
1239
|
// v = "R$ "+(parseInt(v.replace(/[^1-9]*([0-9]*)(,?)([0-9]{0,3}).*/,"$1$3") || 0)/100).toFixed(2).replace(".",",");
|
|
1248
1240
|
newValue = value.replace(/^[a-z]/, function (e) {
|
|
@@ -1258,7 +1250,7 @@ var useTextInput = function useTextInput(_ref, ref) {
|
|
|
1258
1250
|
if ((newValue + '').length > 4 || newValue > 2399) {
|
|
1259
1251
|
newValue = prevValue;
|
|
1260
1252
|
} else {
|
|
1261
|
-
var resultHour =
|
|
1253
|
+
var resultHour = intToHour(newValue, false);
|
|
1262
1254
|
var val = resultHour.replace(/\D/g, '');
|
|
1263
1255
|
var result = isNaN(parseInt(val, 10)) ? undefined : parseInt(val, 10);
|
|
1264
1256
|
newValue = constraint === 'hour-int' ? result : resultHour;
|
|
@@ -1266,15 +1258,15 @@ var useTextInput = function useTextInput(_ref, ref) {
|
|
|
1266
1258
|
}
|
|
1267
1259
|
}
|
|
1268
1260
|
} else if (constraint === 'cpf') {
|
|
1269
|
-
newValue =
|
|
1261
|
+
newValue = digitsToPattern('###.###.###-##', value);
|
|
1270
1262
|
} else if (constraint === 'cnpj') {
|
|
1271
|
-
newValue =
|
|
1263
|
+
newValue = digitsToPattern('##.###.###/####-##', value);
|
|
1272
1264
|
} else if (_isFunction(constraint)) {
|
|
1273
1265
|
newValue = constraint(value);
|
|
1274
1266
|
} else if (_isRegExp(constraint)) {
|
|
1275
1267
|
newValue = value.replace(constraint, '');
|
|
1276
1268
|
} else {
|
|
1277
|
-
newValue =
|
|
1269
|
+
newValue = digitsToPattern(constraint, value);
|
|
1278
1270
|
}
|
|
1279
1271
|
|
|
1280
1272
|
lastValue.set(showValue(newValue));
|
|
@@ -1287,7 +1279,7 @@ var useTextInput = function useTextInput(_ref, ref) {
|
|
|
1287
1279
|
onBlur: handleOnBlur
|
|
1288
1280
|
}, rawHasErrors || hasErrors, focused];
|
|
1289
1281
|
};
|
|
1290
|
-
var TextInput =
|
|
1282
|
+
var TextInput = styled(forwardRef(function (_ref2, forwardedRef) {
|
|
1291
1283
|
var _ref2$showValue = _ref2.showValue,
|
|
1292
1284
|
showValue = _ref2$showValue === void 0 ? _identity : _ref2$showValue,
|
|
1293
1285
|
label = _ref2.label,
|
|
@@ -1305,7 +1297,7 @@ var TextInput = styled__default(React.forwardRef(function (_ref2, forwardedRef)
|
|
|
1305
1297
|
_ref2$fieldClassName = _ref2.fieldClassName,
|
|
1306
1298
|
fieldClassName = _ref2$fieldClassName === void 0 ? '' : _ref2$fieldClassName,
|
|
1307
1299
|
_ref2$FieldType = _ref2.FieldType,
|
|
1308
|
-
FieldType = _ref2$FieldType === void 0 ?
|
|
1300
|
+
FieldType = _ref2$FieldType === void 0 ? Field$1 : _ref2$FieldType,
|
|
1309
1301
|
margin = _ref2.margin,
|
|
1310
1302
|
rawValue = _ref2.value,
|
|
1311
1303
|
rawSetValue = _ref2.setValue,
|
|
@@ -1327,7 +1319,7 @@ var TextInput = styled__default(React.forwardRef(function (_ref2, forwardedRef)
|
|
|
1327
1319
|
tabIndex = _ref2$tabIndex === void 0 ? 1 : _ref2$tabIndex,
|
|
1328
1320
|
rest = _objectWithoutProperties(_ref2, ["showValue", "label", "type", "helpText", "descText", "bellowDescText", "mandatory", "isLoading", "locked", "textBoxBefore", "textBoxAfter", "className", "fieldClassName", "FieldType", "margin", "value", "setValue", "hasErrors", "textarea", "onImage", "autoFocus", "noFocus", "onFocus", "onBlur", "pattern", "autoResize", "constraint", "path", "raw", "tabIndex"]);
|
|
1329
1321
|
|
|
1330
|
-
var ref =
|
|
1322
|
+
var ref = useEnsureRef(forwardedRef);
|
|
1331
1323
|
|
|
1332
1324
|
var _useTextInput = useTextInput(_objectSpread({
|
|
1333
1325
|
path: path,
|
|
@@ -1356,42 +1348,42 @@ var TextInput = styled__default(React.forwardRef(function (_ref2, forwardedRef)
|
|
|
1356
1348
|
|
|
1357
1349
|
var WithTextBox = function WithTextBox(input) {
|
|
1358
1350
|
if (textBoxBefore) {
|
|
1359
|
-
return
|
|
1351
|
+
return React.createElement(InputWithTextBox, {
|
|
1360
1352
|
focused: focused,
|
|
1361
1353
|
hasErrors: hasErrors,
|
|
1362
1354
|
onClick: focusInput,
|
|
1363
1355
|
textBoxBefore: true
|
|
1364
|
-
},
|
|
1356
|
+
}, React.createElement(TextBoxBefore, null, textBoxBefore), input);
|
|
1365
1357
|
} else if (textBoxAfter) {
|
|
1366
|
-
return
|
|
1358
|
+
return React.createElement(InputWithTextBox, {
|
|
1367
1359
|
focused: focused,
|
|
1368
1360
|
hasErrors: hasErrors,
|
|
1369
1361
|
onClick: focusInput
|
|
1370
|
-
}, input,
|
|
1362
|
+
}, input, React.createElement(TextBoxAfter, null, textBoxAfter));
|
|
1371
1363
|
} else {
|
|
1372
1364
|
return input;
|
|
1373
1365
|
}
|
|
1374
1366
|
};
|
|
1375
1367
|
|
|
1376
|
-
var input = WithTextBox(
|
|
1368
|
+
var input = WithTextBox(React.createElement(Input, _extends({}, rest, {
|
|
1377
1369
|
as: inputTag,
|
|
1378
1370
|
className: !label ? className : undefined,
|
|
1379
1371
|
isTextArea: textarea,
|
|
1380
1372
|
"data-hj-whitelist": type !== "password",
|
|
1381
1373
|
locked: locked,
|
|
1382
|
-
autoFocus: !
|
|
1374
|
+
autoFocus: !isTouchDevice() && autoFocus,
|
|
1383
1375
|
noFocus: noFocus,
|
|
1384
1376
|
hasErrors: hasErrors,
|
|
1385
1377
|
isOnImage: onImage,
|
|
1386
1378
|
ref: ref,
|
|
1387
1379
|
tabIndex: tabIndex,
|
|
1388
1380
|
type: type,
|
|
1389
|
-
value:
|
|
1381
|
+
value: ifUndefined(showValue(value), ''),
|
|
1390
1382
|
hasTextBox: textBoxBefore || textBoxAfter,
|
|
1391
1383
|
autoResize: autoResize,
|
|
1392
1384
|
rows: 1
|
|
1393
1385
|
}, events)));
|
|
1394
|
-
return !label ? input :
|
|
1386
|
+
return !label ? input : React.createElement(FieldType, {
|
|
1395
1387
|
className: fieldClassName + ' ' + className,
|
|
1396
1388
|
value: value,
|
|
1397
1389
|
focused: focused,
|
|
@@ -1403,7 +1395,7 @@ var TextInput = styled__default(React.forwardRef(function (_ref2, forwardedRef)
|
|
|
1403
1395
|
label: label,
|
|
1404
1396
|
labelClick: focusInput,
|
|
1405
1397
|
margin: margin
|
|
1406
|
-
}, isLoading &&
|
|
1398
|
+
}, isLoading && React.createElement(InputLoading, {
|
|
1407
1399
|
absolute: true,
|
|
1408
1400
|
size: 20
|
|
1409
1401
|
}), input);
|
|
@@ -1412,20 +1404,20 @@ var TextInput = styled__default(React.forwardRef(function (_ref2, forwardedRef)
|
|
|
1412
1404
|
componentId: "yzpeng-6"
|
|
1413
1405
|
})([""]);
|
|
1414
1406
|
TextInput.Input = Input;
|
|
1415
|
-
var FloatingFieldType =
|
|
1407
|
+
var FloatingFieldType = styled(Field$1).withConfig({
|
|
1416
1408
|
displayName: "TextInput__FloatingFieldType",
|
|
1417
1409
|
componentId: "yzpeng-7"
|
|
1418
|
-
})(["input{height:5rem;box-shadow:0 1px 4px rgba(0,0,0,.2);border-radius:4px;font-size:16px;font-weight:400;padding:16px 1rem 0;}", "{position:absolute;top:1.5rem;left:1rem;font-size:20px;font-weight:normal;transition:all .2s ease;color:rgba(0,0,0,.2);pointer-events:none;z-index:1;", "}"],
|
|
1410
|
+
})(["input{height:5rem;box-shadow:0 1px 4px rgba(0,0,0,.2);border-radius:4px;font-size:16px;font-weight:400;padding:16px 1rem 0;}", "{position:absolute;top:1.5rem;left:1rem;font-size:20px;font-weight:normal;transition:all .2s ease;color:rgba(0,0,0,.2);pointer-events:none;z-index:1;", "}"], Field$1.Label, function (props) {
|
|
1419
1411
|
return (props.value || props.focused) && "\n top: 12px;\n font-size: 14px;\n color: rgba(0,0,0,.4);\n ";
|
|
1420
1412
|
});
|
|
1421
1413
|
var FloatLabelTextInput = function FloatLabelTextInput(props) {
|
|
1422
|
-
return
|
|
1414
|
+
return React.createElement(TextInput, _extends({}, props, {
|
|
1423
1415
|
FieldType: FloatingFieldType
|
|
1424
1416
|
}));
|
|
1425
1417
|
};
|
|
1426
1418
|
|
|
1427
1419
|
var errorsInsidePathSelector = function errorsInsidePathSelector() {
|
|
1428
|
-
return
|
|
1420
|
+
return createSelector([identityFn(0), identityFn(1)], function (path, entries) {
|
|
1429
1421
|
return path ? entries.filter(function (_ref) {
|
|
1430
1422
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
1431
1423
|
_ = _ref2[0],
|
|
@@ -1438,8 +1430,8 @@ var errorsInsidePathSelector = function errorsInsidePathSelector() {
|
|
|
1438
1430
|
|
|
1439
1431
|
var parseError = function parseError(value, path) {
|
|
1440
1432
|
return Array.isArray(value) ? value.map(function (v) {
|
|
1441
|
-
return [v,
|
|
1442
|
-
}) : [[value,
|
|
1433
|
+
return [v, formatPath(path)];
|
|
1434
|
+
}) : [[value, formatPath(path)]];
|
|
1443
1435
|
};
|
|
1444
1436
|
|
|
1445
1437
|
var parseMultipleErrors = function parseMultipleErrors(objOrArray) {
|
|
@@ -1452,11 +1444,11 @@ var parseMultipleErrors = function parseMultipleErrors(objOrArray) {
|
|
|
1452
1444
|
}));
|
|
1453
1445
|
};
|
|
1454
1446
|
|
|
1455
|
-
var ErrorsContext =
|
|
1456
|
-
var ErrorFilterContext =
|
|
1447
|
+
var ErrorsContext = React.createContext({});
|
|
1448
|
+
var ErrorFilterContext = React.createContext(_identity);
|
|
1457
1449
|
var ErrorFilterProvider = ErrorFilterContext.Provider;
|
|
1458
1450
|
var useProvideErrors = function useProvideErrors() {
|
|
1459
|
-
var errors =
|
|
1451
|
+
var errors = useToggle([]);
|
|
1460
1452
|
|
|
1461
1453
|
var addError = function addError(value, path) {
|
|
1462
1454
|
return errors.openWith(function (errors) {
|
|
@@ -1477,7 +1469,7 @@ var useProvideErrors = function useProvideErrors() {
|
|
|
1477
1469
|
v = _ref6[0],
|
|
1478
1470
|
p = _ref6[1];
|
|
1479
1471
|
|
|
1480
|
-
return !(value === v && (p + '.').indexOf(
|
|
1472
|
+
return !(value === v && (p + '.').indexOf(formatPath(path) + '.') >= 0);
|
|
1481
1473
|
});
|
|
1482
1474
|
});
|
|
1483
1475
|
};
|
|
@@ -1489,7 +1481,7 @@ var useProvideErrors = function useProvideErrors() {
|
|
|
1489
1481
|
_ = _ref8[0],
|
|
1490
1482
|
p = _ref8[1];
|
|
1491
1483
|
|
|
1492
|
-
return
|
|
1484
|
+
return formatPath(path) !== p;
|
|
1493
1485
|
});
|
|
1494
1486
|
});
|
|
1495
1487
|
};
|
|
@@ -1501,7 +1493,7 @@ var useProvideErrors = function useProvideErrors() {
|
|
|
1501
1493
|
_ = _ref10[0],
|
|
1502
1494
|
p = _ref10[1];
|
|
1503
1495
|
|
|
1504
|
-
return (p + '.').indexOf(
|
|
1496
|
+
return (p + '.').indexOf(formatPath(path) + '.') < 0;
|
|
1505
1497
|
}) : [];
|
|
1506
1498
|
});
|
|
1507
1499
|
};
|
|
@@ -1516,13 +1508,13 @@ var useProvideErrors = function useProvideErrors() {
|
|
|
1516
1508
|
return errors.openWith(parseMultipleErrors([[errorPath, errorValue]]));
|
|
1517
1509
|
};
|
|
1518
1510
|
|
|
1519
|
-
var memoizeErorrsInsidePath =
|
|
1511
|
+
var memoizeErorrsInsidePath = useMemo(errorsInsidePathSelector, []);
|
|
1520
1512
|
|
|
1521
1513
|
var getErrorsInsidePath = function getErrorsInsidePath(path) {
|
|
1522
|
-
return memoizeErorrsInsidePath(
|
|
1514
|
+
return memoizeErorrsInsidePath(formatPath(path), errors.get());
|
|
1523
1515
|
};
|
|
1524
1516
|
|
|
1525
|
-
var utils
|
|
1517
|
+
var utils = {
|
|
1526
1518
|
addErrors: addErrors,
|
|
1527
1519
|
addError: addError,
|
|
1528
1520
|
setErrors: setErrors,
|
|
@@ -1548,7 +1540,7 @@ var useProvideErrors = function useProvideErrors() {
|
|
|
1548
1540
|
});
|
|
1549
1541
|
}
|
|
1550
1542
|
};
|
|
1551
|
-
var paths =
|
|
1543
|
+
var paths = useMemo(function () {
|
|
1552
1544
|
return new Set(errors.isOpen.map(function (_ref13) {
|
|
1553
1545
|
var _ref14 = _slicedToArray(_ref13, 2),
|
|
1554
1546
|
_ = _ref14[0],
|
|
@@ -1559,13 +1551,13 @@ var useProvideErrors = function useProvideErrors() {
|
|
|
1559
1551
|
return _;
|
|
1560
1552
|
}));
|
|
1561
1553
|
}, [errors.isOpen]);
|
|
1562
|
-
var providerValue =
|
|
1554
|
+
var providerValue = useMemo(function () {
|
|
1563
1555
|
return _objectSpread({
|
|
1564
1556
|
paths: paths,
|
|
1565
1557
|
errors: errors.isOpen
|
|
1566
|
-
}, utils
|
|
1558
|
+
}, utils);
|
|
1567
1559
|
}, [errors.isOpen]);
|
|
1568
|
-
return [ErrorsContext.Provider, providerValue, utils
|
|
1560
|
+
return [ErrorsContext.Provider, providerValue, utils];
|
|
1569
1561
|
};
|
|
1570
1562
|
var useErrors = function useErrors() {
|
|
1571
1563
|
var _useProvideErrors = useProvideErrors(),
|
|
@@ -1574,22 +1566,22 @@ var useErrors = function useErrors() {
|
|
|
1574
1566
|
value = _useProvideErrors2[1],
|
|
1575
1567
|
utils = _useProvideErrors2[2];
|
|
1576
1568
|
|
|
1577
|
-
return [utils,
|
|
1569
|
+
return [utils, React.createElement(Provider, {
|
|
1578
1570
|
value: value
|
|
1579
|
-
},
|
|
1571
|
+
}, React.createElement(Errors, null))];
|
|
1580
1572
|
};
|
|
1581
1573
|
var useHasError = function useHasError(path) {
|
|
1582
|
-
var _useContext =
|
|
1574
|
+
var _useContext = useContext(ErrorsContext),
|
|
1583
1575
|
paths = _useContext.paths;
|
|
1584
1576
|
|
|
1585
|
-
return paths.has(
|
|
1577
|
+
return paths.has(formatPath(path));
|
|
1586
1578
|
};
|
|
1587
1579
|
var useErrorsUtils = function useErrorsUtils() {
|
|
1588
|
-
return
|
|
1580
|
+
return useContext(ErrorsContext);
|
|
1589
1581
|
};
|
|
1590
1582
|
var useTransientErrorHelper = function useTransientErrorHelper() {
|
|
1591
1583
|
var utils = useErrorsUtils();
|
|
1592
|
-
var showingErrors =
|
|
1584
|
+
var showingErrors = useRef([]);
|
|
1593
1585
|
|
|
1594
1586
|
var clearCurrentErrors = function clearCurrentErrors() {
|
|
1595
1587
|
showingErrors.current.forEach(function (_ref15) {
|
|
@@ -1608,7 +1600,7 @@ var useTransientErrorHelper = function useTransientErrorHelper() {
|
|
|
1608
1600
|
showingErrors.current = newErrors;
|
|
1609
1601
|
};
|
|
1610
1602
|
|
|
1611
|
-
|
|
1603
|
+
useEffect(function () {
|
|
1612
1604
|
return function () {
|
|
1613
1605
|
clearCurrentErrors();
|
|
1614
1606
|
};
|
|
@@ -1621,12 +1613,12 @@ var Errors = function Errors(_ref17) {
|
|
|
1621
1613
|
className = _ref17.className,
|
|
1622
1614
|
autoScroll = _ref17.autoScroll;
|
|
1623
1615
|
|
|
1624
|
-
var _useContext2 =
|
|
1616
|
+
var _useContext2 = useContext(ErrorsContext),
|
|
1625
1617
|
getErrorsInsidePath = _useContext2.getErrorsInsidePath,
|
|
1626
1618
|
willRemoveError = _useContext2.willRemoveError;
|
|
1627
1619
|
|
|
1628
|
-
var contextFilter =
|
|
1629
|
-
var ref =
|
|
1620
|
+
var contextFilter = useContext(ErrorFilterContext);
|
|
1621
|
+
var ref = useRef();
|
|
1630
1622
|
var errors = filter ? getErrorsInsidePath(path).filter(filter) : contextFilter(getErrorsInsidePath(path));
|
|
1631
1623
|
|
|
1632
1624
|
var uniqErrors = _uniqBy(_property(0), errors).filter(function (_ref18) {
|
|
@@ -1636,14 +1628,14 @@ var Errors = function Errors(_ref17) {
|
|
|
1636
1628
|
return v;
|
|
1637
1629
|
});
|
|
1638
1630
|
|
|
1639
|
-
var prevErrors =
|
|
1640
|
-
|
|
1631
|
+
var prevErrors = usePreviousForEffect(uniqErrors);
|
|
1632
|
+
useEffect(function () {
|
|
1641
1633
|
var _ref$current;
|
|
1642
1634
|
|
|
1643
1635
|
var changed = _difference(uniqErrors, prevErrors);
|
|
1644
1636
|
|
|
1645
1637
|
if (autoScroll && changed.length && ((_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.scrollIntoView)) {
|
|
1646
|
-
|
|
1638
|
+
isElementInView(ref.current).then(function (inView) {
|
|
1647
1639
|
if (!inView) {
|
|
1648
1640
|
ref.current.scrollIntoView({
|
|
1649
1641
|
behavior: "smooth"
|
|
@@ -1652,47 +1644,47 @@ var Errors = function Errors(_ref17) {
|
|
|
1652
1644
|
});
|
|
1653
1645
|
}
|
|
1654
1646
|
}, [uniqErrors]);
|
|
1655
|
-
return
|
|
1647
|
+
return React.createElement(TransitionDiv, {
|
|
1656
1648
|
block: true
|
|
1657
|
-
}, uniqErrors.length > 0 &&
|
|
1649
|
+
}, uniqErrors.length > 0 && React.createElement(Errors.Container, {
|
|
1658
1650
|
ref: ref,
|
|
1659
1651
|
className: className
|
|
1660
1652
|
}, uniqErrors.map(function (_ref20) {
|
|
1661
1653
|
var _ref21 = _slicedToArray(_ref20, 1),
|
|
1662
1654
|
value = _ref21[0];
|
|
1663
1655
|
|
|
1664
|
-
return value && value !== true &&
|
|
1656
|
+
return value && value !== true && React.createElement(Errors.Item, {
|
|
1665
1657
|
key: value
|
|
1666
|
-
}, value,
|
|
1658
|
+
}, value, React.createElement(Errors.CloseIcon, {
|
|
1667
1659
|
onClick: willRemoveError(value, path)
|
|
1668
1660
|
}));
|
|
1669
1661
|
})));
|
|
1670
1662
|
};
|
|
1671
1663
|
Errors.displayName = 'Errors';
|
|
1672
|
-
Errors.Container =
|
|
1664
|
+
Errors.Container = styled.ul.withConfig({
|
|
1673
1665
|
displayName: "Errors__Container",
|
|
1674
1666
|
componentId: "sc-1vuw7bx-0"
|
|
1675
1667
|
})(["list-style-type:none;margin:0;padding:0;"]);
|
|
1676
|
-
Errors.Item =
|
|
1668
|
+
Errors.Item = styled.li.withConfig({
|
|
1677
1669
|
displayName: "Errors__Item",
|
|
1678
1670
|
componentId: "sc-1vuw7bx-1"
|
|
1679
1671
|
})(["background-color:", ";padding:1rem 3.5rem 1rem 1rem;border-radius:8px;border:1px solid ", ";color:", ";position:relative;text-align:left;font-size:13px;line-height:130%;& ~ &{margin-top:0.5rem;}", ""], function (props) {
|
|
1680
|
-
return
|
|
1672
|
+
return lighten(0.42, props.theme.colors.alert);
|
|
1681
1673
|
}, function (props) {
|
|
1682
|
-
return
|
|
1683
|
-
},
|
|
1684
|
-
Errors.CloseIcon =
|
|
1674
|
+
return lighten(0.35, props.theme.colors.alert);
|
|
1675
|
+
}, getColor('alert'), customTheme('ErrorItem'));
|
|
1676
|
+
Errors.CloseIcon = styled(Icon).attrs({
|
|
1685
1677
|
icon: 'x'
|
|
1686
1678
|
}).withConfig({
|
|
1687
1679
|
displayName: "Errors__CloseIcon",
|
|
1688
1680
|
componentId: "sc-1vuw7bx-2"
|
|
1689
|
-
})(["color:", ";font-weight:600;display:inline-block;background-color:", ";width:21px;height:21px;line-height:21px;text-align:center;border-radius:50%;cursor:pointer;position:absolute;top:10px;right:10px;font-size:14px;z-index:2;&:hover{background-color:", ";}"],
|
|
1690
|
-
return
|
|
1681
|
+
})(["color:", ";font-weight:600;display:inline-block;background-color:", ";width:21px;height:21px;line-height:21px;text-align:center;border-radius:50%;cursor:pointer;position:absolute;top:10px;right:10px;font-size:14px;z-index:2;&:hover{background-color:", ";}"], getColor('alert'), function (props) {
|
|
1682
|
+
return lighten(0.35, props.theme.colors.alert);
|
|
1691
1683
|
}, function (props) {
|
|
1692
|
-
return
|
|
1684
|
+
return lighten(0.32, props.theme.colors.alert);
|
|
1693
1685
|
});
|
|
1694
1686
|
|
|
1695
|
-
var FileInput =
|
|
1687
|
+
var FileInput = styled.input.attrs({
|
|
1696
1688
|
type: 'file'
|
|
1697
1689
|
}).withConfig({
|
|
1698
1690
|
displayName: "withFormImageInput__FileInput",
|
|
@@ -1715,10 +1707,10 @@ var WithImageInput = function WithImageInput(_ref) {
|
|
|
1715
1707
|
onTouchEnd = _ref.onTouchEnd,
|
|
1716
1708
|
rest = _objectWithoutProperties(_ref, ["children", "multiple", "path", "preValidation", "onChangeFile", "onClose", "onClick", "uploadFetcher", "onSuccess", "onFailure", "ajaxError", "onTouchEnd"]);
|
|
1717
1709
|
|
|
1718
|
-
var form
|
|
1719
|
-
var loading =
|
|
1710
|
+
var form = useContext(FormContext$1);
|
|
1711
|
+
var loading = useToggle();
|
|
1720
1712
|
|
|
1721
|
-
var _useState =
|
|
1713
|
+
var _useState = useState(),
|
|
1722
1714
|
_useState2 = _slicedToArray(_useState, 2),
|
|
1723
1715
|
tempImage = _useState2[0],
|
|
1724
1716
|
setTempImage = _useState2[1];
|
|
@@ -1730,7 +1722,7 @@ var WithImageInput = function WithImageInput(_ref) {
|
|
|
1730
1722
|
|
|
1731
1723
|
var imagePath = getPath('image');
|
|
1732
1724
|
|
|
1733
|
-
var _useFormValue =
|
|
1725
|
+
var _useFormValue = useFormValue$1(imagePath),
|
|
1734
1726
|
_useFormValue2 = _slicedToArray(_useFormValue, 1),
|
|
1735
1727
|
formImage = _useFormValue2[0];
|
|
1736
1728
|
|
|
@@ -1741,7 +1733,7 @@ var WithImageInput = function WithImageInput(_ref) {
|
|
|
1741
1733
|
|
|
1742
1734
|
if (validations.length) {
|
|
1743
1735
|
validations.forEach(function (v) {
|
|
1744
|
-
return form
|
|
1736
|
+
return form.setError(getPath('image').join('.'), v);
|
|
1745
1737
|
});
|
|
1746
1738
|
return files.filter(function (file) {
|
|
1747
1739
|
return !preValidation(file);
|
|
@@ -1753,7 +1745,7 @@ var WithImageInput = function WithImageInput(_ref) {
|
|
|
1753
1745
|
|
|
1754
1746
|
var handleFileEvent = function handleFileEvent(e) {
|
|
1755
1747
|
e.preventDefault();
|
|
1756
|
-
|
|
1748
|
+
callIfFunction(onClose);
|
|
1757
1749
|
var files = Array.from((e.nativeEvent.dataTransfer || e.nativeEvent.target).files);
|
|
1758
1750
|
|
|
1759
1751
|
if (files.length > 0) {
|
|
@@ -1771,11 +1763,11 @@ var WithImageInput = function WithImageInput(_ref) {
|
|
|
1771
1763
|
};
|
|
1772
1764
|
|
|
1773
1765
|
var path = getIndexedPath();
|
|
1774
|
-
var oldUploadStatus = form
|
|
1775
|
-
var oldImage = form
|
|
1776
|
-
var oldImageHeight = form
|
|
1777
|
-
var oldImageWidth = form
|
|
1778
|
-
var oldFilename = form
|
|
1766
|
+
var oldUploadStatus = form.getMeta(getIndexedPath('uploadStatus'));
|
|
1767
|
+
var oldImage = form.getValue(getIndexedPath('image'));
|
|
1768
|
+
var oldImageHeight = form.getValue(getIndexedPath('imageHeight'));
|
|
1769
|
+
var oldImageWidth = form.getValue(getIndexedPath('imageWidth'));
|
|
1770
|
+
var oldFilename = form.getValue(getIndexedPath('fileName'));
|
|
1779
1771
|
var objectUrl = URL.createObjectURL(file);
|
|
1780
1772
|
var image = document.createElement('img');
|
|
1781
1773
|
|
|
@@ -1788,28 +1780,28 @@ var WithImageInput = function WithImageInput(_ref) {
|
|
|
1788
1780
|
imageWidth: imageWidth,
|
|
1789
1781
|
imageHeight: imageHeight
|
|
1790
1782
|
};
|
|
1791
|
-
form
|
|
1792
|
-
form
|
|
1783
|
+
form.setValues(_flow(_set(getIndexedPath('filename'), file.name), _set(getIndexedPath('image'), file), _set(getIndexedPath('imageWidth'), imageWidth), _set(getIndexedPath('imageHeight'), imageHeight)));
|
|
1784
|
+
form.setMeta(_flow(_update('submittingFiles', function (v) {
|
|
1793
1785
|
return v ? v + 1 : 1;
|
|
1794
1786
|
}), _update('uploadingPaths', _union([path.join(".")])), _set(getIndexedPath('uploadStatus'), 'loading')));
|
|
1795
1787
|
setTempImage(objectUrl);
|
|
1796
|
-
|
|
1788
|
+
callIfFunction(onChangeFile, file);
|
|
1797
1789
|
loading.open();
|
|
1798
1790
|
uploadFetcher(file, newValues).then(function (_ref2) {
|
|
1799
1791
|
var image = _ref2.image,
|
|
1800
1792
|
uploadStatus = _ref2.uploadStatus;
|
|
1801
1793
|
loading.close();
|
|
1802
1794
|
|
|
1803
|
-
if (form
|
|
1804
|
-
form
|
|
1795
|
+
if (form.getValue(getIndexedPath('image')) !== file) {
|
|
1796
|
+
form.setMeta(_update(['submittingFiles'], function (v) {
|
|
1805
1797
|
return v - 1;
|
|
1806
1798
|
}));
|
|
1807
1799
|
return;
|
|
1808
1800
|
}
|
|
1809
1801
|
|
|
1810
|
-
form
|
|
1811
|
-
form
|
|
1812
|
-
form
|
|
1802
|
+
form.clearErrors();
|
|
1803
|
+
form.setValue(getIndexedPath('image'), image, false);
|
|
1804
|
+
form.setMeta(_flow(_update('uploadingPaths', _difference(_difference.placeholder, [path.join(".")])), _update(['submittingFiles'], function (v) {
|
|
1813
1805
|
return v - 1;
|
|
1814
1806
|
}), _update(['submittedFiles'], function (v) {
|
|
1815
1807
|
return (v || []).concat([{
|
|
@@ -1819,7 +1811,7 @@ var WithImageInput = function WithImageInput(_ref) {
|
|
|
1819
1811
|
}]);
|
|
1820
1812
|
}), _set(getIndexedPath('uploadStatus'), uploadStatus)));
|
|
1821
1813
|
setTempImage(null);
|
|
1822
|
-
|
|
1814
|
+
callIfFunction(onSuccess, {
|
|
1823
1815
|
image: image,
|
|
1824
1816
|
uploadStatus: uploadStatus,
|
|
1825
1817
|
imageWidth: imageWidth,
|
|
@@ -1828,16 +1820,16 @@ var WithImageInput = function WithImageInput(_ref) {
|
|
|
1828
1820
|
}).catch(function (e) {
|
|
1829
1821
|
loading.close();
|
|
1830
1822
|
|
|
1831
|
-
if (form
|
|
1832
|
-
form
|
|
1823
|
+
if (form.getValue(getIndexedPath('image')) !== file) {
|
|
1824
|
+
form.setMeta(_update(['submittingFiles'], function (v) {
|
|
1833
1825
|
return v - 1;
|
|
1834
1826
|
}));
|
|
1835
1827
|
return;
|
|
1836
1828
|
}
|
|
1837
1829
|
|
|
1838
|
-
form
|
|
1839
|
-
form
|
|
1840
|
-
form
|
|
1830
|
+
form.setError(getIndexedPath('image').join('.'), callIfFunction(ajaxError, _get('[1].status', e)));
|
|
1831
|
+
form.setValues(_flow(_set(getIndexedPath('filename'), oldFilename), _set(getIndexedPath('image'), oldImage), _set(getIndexedPath('imageWidth'), oldImageWidth), _set(getIndexedPath('imageHeight'), oldImageHeight)), false);
|
|
1832
|
+
form.setMeta(_flow(_update('uploadingPaths', _difference(_difference.placeholder, [path.join(".")])), _update(['submittingFiles'], function (v) {
|
|
1841
1833
|
return v - 1;
|
|
1842
1834
|
}), _update(['submittedFiles'], function (v) {
|
|
1843
1835
|
return (v || []).concat([{
|
|
@@ -1847,7 +1839,7 @@ var WithImageInput = function WithImageInput(_ref) {
|
|
|
1847
1839
|
}]);
|
|
1848
1840
|
}), _set(getIndexedPath('uploadStatus'), oldUploadStatus)));
|
|
1849
1841
|
setTempImage(null);
|
|
1850
|
-
|
|
1842
|
+
callIfFunction(onFailure);
|
|
1851
1843
|
});
|
|
1852
1844
|
if (eventTarget && eventTarget.parentNode && typeof eventTarget.parentNode.click === 'function') eventTarget.parentNode.click();
|
|
1853
1845
|
};
|
|
@@ -1856,14 +1848,14 @@ var WithImageInput = function WithImageInput(_ref) {
|
|
|
1856
1848
|
};
|
|
1857
1849
|
|
|
1858
1850
|
var handleClick = function handleClick(e) {
|
|
1859
|
-
|
|
1851
|
+
callIfFunction(onClick, e);
|
|
1860
1852
|
};
|
|
1861
1853
|
|
|
1862
1854
|
var handleTouchEnd = function handleTouchEnd(e) {
|
|
1863
|
-
|
|
1855
|
+
callIfFunction(onTouchEnd, e);
|
|
1864
1856
|
};
|
|
1865
1857
|
|
|
1866
|
-
return children(
|
|
1858
|
+
return children(React.createElement(FileInput, {
|
|
1867
1859
|
multiple: multiple,
|
|
1868
1860
|
onChange: handleFileEvent,
|
|
1869
1861
|
onClick: handleClick,
|
|
@@ -1895,10 +1887,10 @@ var WithFileInput = function WithFileInput(_ref3) {
|
|
|
1895
1887
|
maxFiles = _ref3.maxFiles,
|
|
1896
1888
|
rest = _objectWithoutProperties(_ref3, ["children", "multiple", "path", "preValidation", "onChangeFile", "onClose", "onClick", "uploadFetcher", "onSuccess", "onFailure", "ajaxError", "onTouchEnd", "maxFiles"]);
|
|
1897
1889
|
|
|
1898
|
-
var form
|
|
1899
|
-
var loading =
|
|
1890
|
+
var form = useContext(FormContext$1);
|
|
1891
|
+
var loading = useToggle();
|
|
1900
1892
|
|
|
1901
|
-
var _useState3 =
|
|
1893
|
+
var _useState3 = useState(),
|
|
1902
1894
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
1903
1895
|
tempImage = _useState4[0],
|
|
1904
1896
|
setTempImage = _useState4[1];
|
|
@@ -1912,7 +1904,7 @@ var WithFileInput = function WithFileInput(_ref3) {
|
|
|
1912
1904
|
|
|
1913
1905
|
if (validations.length) {
|
|
1914
1906
|
validations.forEach(function (v) {
|
|
1915
|
-
return form
|
|
1907
|
+
return form.setError(getPath('file', 0).join('.'), v);
|
|
1916
1908
|
});
|
|
1917
1909
|
return files.filter(function (file) {
|
|
1918
1910
|
return !preValidation(file);
|
|
@@ -1924,7 +1916,7 @@ var WithFileInput = function WithFileInput(_ref3) {
|
|
|
1924
1916
|
|
|
1925
1917
|
var handleFileEvent = function handleFileEvent(e) {
|
|
1926
1918
|
e.preventDefault();
|
|
1927
|
-
|
|
1919
|
+
callIfFunction(onClose);
|
|
1928
1920
|
var files = Array.from((e.nativeEvent.dataTransfer || e.nativeEvent.target).files);
|
|
1929
1921
|
|
|
1930
1922
|
if (files.length > 0) {
|
|
@@ -1935,10 +1927,10 @@ var WithFileInput = function WithFileInput(_ref3) {
|
|
|
1935
1927
|
};
|
|
1936
1928
|
|
|
1937
1929
|
var handleFile = function handleFile(file, eventTarget) {
|
|
1938
|
-
var currentFileIndex = (form
|
|
1930
|
+
var currentFileIndex = (form.getValue(getPath()) || []).length;
|
|
1939
1931
|
|
|
1940
1932
|
if (currentFileIndex >= maxFiles) {
|
|
1941
|
-
form
|
|
1933
|
+
form.setErrors({
|
|
1942
1934
|
'': 'Número máximo de arquivos atingido'
|
|
1943
1935
|
});
|
|
1944
1936
|
return;
|
|
@@ -1952,37 +1944,37 @@ var WithFileInput = function WithFileInput(_ref3) {
|
|
|
1952
1944
|
|
|
1953
1945
|
var getIndexedPath = createGetIndexedPath(currentFileIndex);
|
|
1954
1946
|
var path = getIndexedPath();
|
|
1955
|
-
var oldUploadStatus = form
|
|
1956
|
-
var oldFile = form
|
|
1957
|
-
var oldFilename = form
|
|
1958
|
-
var uid =
|
|
1959
|
-
form
|
|
1960
|
-
form
|
|
1947
|
+
var oldUploadStatus = form.getMeta(getIndexedPath('uploadStatus'));
|
|
1948
|
+
var oldFile = form.getValue(getIndexedPath('file'));
|
|
1949
|
+
var oldFilename = form.getValue(getIndexedPath('fileName'));
|
|
1950
|
+
var uid = getUID();
|
|
1951
|
+
form.setValues(_flow(_set(getIndexedPath('filename'), file.name), _set(getIndexedPath('file'), file), _set(getIndexedPath('uid'), uid)));
|
|
1952
|
+
form.setMeta(_flow(_update('submittingFiles', function (v) {
|
|
1961
1953
|
return v ? v + 1 : 1;
|
|
1962
1954
|
}), _update('uploadingPaths', _union([path.join(".")])), _set(getIndexedPath('uploadStatus'), 'loading')));
|
|
1963
|
-
|
|
1955
|
+
callIfFunction(onChangeFile, file);
|
|
1964
1956
|
loading.open();
|
|
1965
1957
|
uploadFetcher(file).then(function (_ref4) {
|
|
1966
1958
|
var file = _ref4.file,
|
|
1967
1959
|
uploadStatus = _ref4.uploadStatus,
|
|
1968
1960
|
response = _ref4.response;
|
|
1969
1961
|
loading.close();
|
|
1970
|
-
var list = form
|
|
1962
|
+
var list = form.getValue(getPath()) || [];
|
|
1971
1963
|
var index = list.findIndex(function (f) {
|
|
1972
1964
|
return f.uid === uid;
|
|
1973
1965
|
});
|
|
1974
1966
|
|
|
1975
1967
|
if (index < 0) {
|
|
1976
|
-
form
|
|
1968
|
+
form.setMeta(_update(['submittingFiles'], function (v) {
|
|
1977
1969
|
return v - 1;
|
|
1978
1970
|
}));
|
|
1979
1971
|
return;
|
|
1980
1972
|
}
|
|
1981
1973
|
|
|
1982
1974
|
var getIndexedPath = createGetIndexedPath(index);
|
|
1983
|
-
form
|
|
1984
|
-
form
|
|
1985
|
-
form
|
|
1975
|
+
form.clearErrors();
|
|
1976
|
+
form.setValue(getIndexedPath('file'), response, false);
|
|
1977
|
+
form.setMeta(_flow(_update('uploadingPaths', _difference(_difference.placeholder, [path.join(".")])), _update(['submittingFiles'], function (v) {
|
|
1986
1978
|
return v - 1;
|
|
1987
1979
|
}), _update(['submittedFiles'], function (v) {
|
|
1988
1980
|
return (v || []).concat([{
|
|
@@ -1990,36 +1982,36 @@ var WithFileInput = function WithFileInput(_ref3) {
|
|
|
1990
1982
|
file: file
|
|
1991
1983
|
}]);
|
|
1992
1984
|
}), _set(getIndexedPath('uploadStatus'), uploadStatus)));
|
|
1993
|
-
|
|
1985
|
+
callIfFunction(onSuccess, {
|
|
1994
1986
|
file: file,
|
|
1995
1987
|
uploadStatus: uploadStatus
|
|
1996
1988
|
});
|
|
1997
1989
|
}).catch(function (e) {
|
|
1998
1990
|
loading.close();
|
|
1999
|
-
var list = form
|
|
1991
|
+
var list = form.getValue(getPath()) || [];
|
|
2000
1992
|
var index = list.findIndex(function (f) {
|
|
2001
1993
|
return f.uid === uid;
|
|
2002
1994
|
});
|
|
2003
1995
|
|
|
2004
1996
|
if (index < 0) {
|
|
2005
|
-
form
|
|
1997
|
+
form.setMeta(_update(['submittingFiles'], function (v) {
|
|
2006
1998
|
return v - 1;
|
|
2007
1999
|
}));
|
|
2008
2000
|
return;
|
|
2009
2001
|
}
|
|
2010
2002
|
|
|
2011
2003
|
var getIndexedPath = createGetIndexedPath(index);
|
|
2012
|
-
form
|
|
2004
|
+
form.setError(getIndexedPath('file').join('.'), callIfFunction(ajaxError, _get('[1].status', e)));
|
|
2013
2005
|
|
|
2014
2006
|
if (oldFile) {
|
|
2015
|
-
form
|
|
2007
|
+
form.setValues(_flow(_set(getIndexedPath('filename'), oldFilename), _set(getIndexedPath('file'), oldFile)), false);
|
|
2016
2008
|
} else {
|
|
2017
|
-
form
|
|
2009
|
+
form.setValues(_update(getPath(), _filter(function (f) {
|
|
2018
2010
|
return f.uid !== uid;
|
|
2019
2011
|
})), false);
|
|
2020
2012
|
}
|
|
2021
2013
|
|
|
2022
|
-
form
|
|
2014
|
+
form.setMeta(_flow(_update('uploadingPaths', _difference(_difference.placeholder, [path.join(".")])), _update(['submittingFiles'], function (v) {
|
|
2023
2015
|
return v - 1;
|
|
2024
2016
|
}), _update(['submittedFiles'], function (v) {
|
|
2025
2017
|
return (v || []).concat([{
|
|
@@ -2027,20 +2019,20 @@ var WithFileInput = function WithFileInput(_ref3) {
|
|
|
2027
2019
|
file: file
|
|
2028
2020
|
}]);
|
|
2029
2021
|
}), _set(getIndexedPath('uploadStatus'), oldUploadStatus)));
|
|
2030
|
-
|
|
2022
|
+
callIfFunction(onFailure);
|
|
2031
2023
|
});
|
|
2032
2024
|
if (eventTarget && eventTarget.parentNode && typeof eventTarget.parentNode.click === 'function') eventTarget.parentNode.click();
|
|
2033
2025
|
};
|
|
2034
2026
|
|
|
2035
2027
|
var handleClick = function handleClick(e) {
|
|
2036
|
-
|
|
2028
|
+
callIfFunction(onClick, e);
|
|
2037
2029
|
};
|
|
2038
2030
|
|
|
2039
2031
|
var handleTouchEnd = function handleTouchEnd(e) {
|
|
2040
|
-
|
|
2032
|
+
callIfFunction(onTouchEnd, e);
|
|
2041
2033
|
};
|
|
2042
2034
|
|
|
2043
|
-
return children(
|
|
2035
|
+
return children(React.createElement(FileInput, {
|
|
2044
2036
|
multiple: multiple,
|
|
2045
2037
|
onChange: handleFileEvent,
|
|
2046
2038
|
onClick: handleClick,
|
|
@@ -2054,7 +2046,7 @@ var WithFileInput = function WithFileInput(_ref3) {
|
|
|
2054
2046
|
});
|
|
2055
2047
|
};
|
|
2056
2048
|
|
|
2057
|
-
var HiddenInput =
|
|
2049
|
+
var HiddenInput = styled.input.withConfig({
|
|
2058
2050
|
displayName: "Checkbox__HiddenInput",
|
|
2059
2051
|
componentId: "sc-19o1zxv-0"
|
|
2060
2052
|
})(["opacity:0 !important;position:absolute;pointer-events:none;"]);
|
|
@@ -2073,9 +2065,9 @@ var Checkbox = function Checkbox(_ref) {
|
|
|
2073
2065
|
raw = _ref.raw,
|
|
2074
2066
|
rest = _objectWithoutProperties(_ref, ["className", "children", "isChecked", "isList", "onClick", "disabled", "inverted", "path", "tabIndex", "raw"]);
|
|
2075
2067
|
|
|
2076
|
-
var focused =
|
|
2068
|
+
var focused = useToggle();
|
|
2077
2069
|
|
|
2078
|
-
var _useInput =
|
|
2070
|
+
var _useInput = useInput$1(_objectSpread({
|
|
2079
2071
|
path: path,
|
|
2080
2072
|
isChecked: isChecked
|
|
2081
2073
|
}, rest), raw),
|
|
@@ -2094,7 +2086,7 @@ var Checkbox = function Checkbox(_ref) {
|
|
|
2094
2086
|
var value = isChecked(testInvert(isList ? (v === null || v === void 0 ? void 0 : v.indexOf(rest.fieldValue)) >= 0 : v));
|
|
2095
2087
|
|
|
2096
2088
|
var _onClick = function _onClick(e) {
|
|
2097
|
-
|
|
2089
|
+
callIfFunction(onClick, e);
|
|
2098
2090
|
|
|
2099
2091
|
if (!e.isDefaultPrevented()) {
|
|
2100
2092
|
if (isList) {
|
|
@@ -2107,11 +2099,11 @@ var Checkbox = function Checkbox(_ref) {
|
|
|
2107
2099
|
}
|
|
2108
2100
|
};
|
|
2109
2101
|
|
|
2110
|
-
return
|
|
2102
|
+
return React.createElement("label", {
|
|
2111
2103
|
onClick: _onClick,
|
|
2112
2104
|
"data-drag": "false",
|
|
2113
2105
|
className: className
|
|
2114
|
-
}, !
|
|
2106
|
+
}, !isTouchDevice() && React.createElement(HiddenInput, {
|
|
2115
2107
|
onFocus: focused.open,
|
|
2116
2108
|
onBlur: focused.close,
|
|
2117
2109
|
disabled: disabled,
|
|
@@ -2157,50 +2149,50 @@ function _templateObject$2() {
|
|
|
2157
2149
|
|
|
2158
2150
|
return data;
|
|
2159
2151
|
}
|
|
2160
|
-
var ComboboxMenu =
|
|
2152
|
+
var ComboboxMenu = styled(ContextListMenu).withConfig({
|
|
2161
2153
|
displayName: "Combobox__ComboboxMenu",
|
|
2162
2154
|
componentId: "u2hz6i-0"
|
|
2163
|
-
})(["z-index:100;background-color:white;border-radius:4px 4px 6px 6px;margin-top:-1px;margin-bottom:0.5rem;box-shadow:0 2px 2px 0 rgba(0,0,0,0.14),0 3px 10px -2px rgba(0,0,0,0.15),0 1px 2px 0px rgba(0,0,0,0.2);border:1px solid #b4b4b4;max-height:25rem;width:auto;", " > *{font-size:13px;}", " ", " ", ""],
|
|
2164
|
-
return props.withoutIcons &&
|
|
2155
|
+
})(["z-index:100;background-color:white;border-radius:4px 4px 6px 6px;margin-top:-1px;margin-bottom:0.5rem;box-shadow:0 2px 2px 0 rgba(0,0,0,0.14),0 3px 10px -2px rgba(0,0,0,0.15),0 1px 2px 0px rgba(0,0,0,0.2);border:1px solid #b4b4b4;max-height:25rem;width:auto;", " > *{font-size:13px;}", " ", " ", ""], ListItem, media.mobile(_templateObject$2(), ListItem), function (props) {
|
|
2156
|
+
return props.withoutIcons && css$1(["", " > *{padding-left:1.25rem;padding-right:1.25rem;}"], ListItem);
|
|
2165
2157
|
}, function (props) {
|
|
2166
2158
|
return props.withWindowing && "\n overflow: hidden;\n padding: 0;\n ";
|
|
2167
2159
|
});
|
|
2168
|
-
var ComboboxInput =
|
|
2160
|
+
var ComboboxInput = styled.div.withConfig({
|
|
2169
2161
|
displayName: "Combobox__ComboboxInput",
|
|
2170
2162
|
componentId: "u2hz6i-1"
|
|
2171
|
-
})(["width:100%;font-size:14px;border:1px solid ", ";border-radius:6px;color:", ";background:white;position:relative;display:block;min-height:3rem;padding:0.5rem 2.5rem 0.5rem 0.7rem;overflow:auto;outline:0;outline:none;cursor:pointer;user-select:none;overflow:hidden;display:flex;align-items:center;word-break:break-word;", " ", " ", ":focus{border-color:", ";box-shadow:0px 0px 0px 2px rgba(0,0,0,0.1);}", " input{position:absolute;top:-1px;left:0;border:none;", "}"],
|
|
2163
|
+
})(["width:100%;font-size:14px;border:1px solid ", ";border-radius:6px;color:", ";background:white;position:relative;display:block;min-height:3rem;padding:0.5rem 2.5rem 0.5rem 0.7rem;overflow:auto;outline:0;outline:none;cursor:pointer;user-select:none;overflow:hidden;display:flex;align-items:center;word-break:break-word;", " ", " ", ":focus{border-color:", ";box-shadow:0px 0px 0px 2px rgba(0,0,0,0.1);}", " input{position:absolute;top:-1px;left:0;border:none;", "}"], getColor('gray210'), getColor('gray60'), function (props) {
|
|
2172
2164
|
return props.suggestive && "\n padding-right: 0.7rem;\n ";
|
|
2173
|
-
},
|
|
2165
|
+
}, media.mobile(_templateObject2$1(), function (props) {
|
|
2174
2166
|
return props.suggestive && "\n padding-right: 1rem;\n ";
|
|
2175
2167
|
}), function (props) {
|
|
2176
|
-
return props.isFocused &&
|
|
2177
|
-
},
|
|
2178
|
-
return props.hasErrors &&
|
|
2168
|
+
return props.isFocused && css$1(["border-color:", ";box-shadow:0px 0px 0px 2px rgba(0,0,0,0.1);"], getColor('gray180'));
|
|
2169
|
+
}, getColor('gray180'), function (props) {
|
|
2170
|
+
return props.hasErrors && css$1(["border-color:", " !important;"], getColor('alert'));
|
|
2179
2171
|
}, function (props) {
|
|
2180
2172
|
return !props.suggestive && "\n padding-right: 2.5rem;\n ";
|
|
2181
2173
|
});
|
|
2182
|
-
var ComboboxDropdownIcon =
|
|
2174
|
+
var ComboboxDropdownIcon = styled(Icon).withConfig({
|
|
2183
2175
|
displayName: "Combobox__ComboboxDropdownIcon",
|
|
2184
2176
|
componentId: "u2hz6i-2"
|
|
2185
|
-
})(["position:absolute;top:51%;transform:translateY(-50%);right:1rem;color:", ";"],
|
|
2186
|
-
var FooterOptionsContainer =
|
|
2177
|
+
})(["position:absolute;top:51%;transform:translateY(-50%);right:1rem;color:", ";"], getColor('gray60'));
|
|
2178
|
+
var FooterOptionsContainer = styled.div.withConfig({
|
|
2187
2179
|
displayName: "Combobox__FooterOptionsContainer",
|
|
2188
2180
|
componentId: "u2hz6i-3"
|
|
2189
2181
|
})(["background:white;border-top:1px solid rgba(0,0,0,0.1);padding:0;", ""], function (props) {
|
|
2190
2182
|
return !props.hasWindoning && "\n padding: 0.5rem 0;\n margin: 0.5rem 0 -0.5rem;\n bottom: -0.5rem;\n position: sticky;\n ";
|
|
2191
2183
|
});
|
|
2192
|
-
var ComboboxPlaceholder =
|
|
2184
|
+
var ComboboxPlaceholder = styled.div.withConfig({
|
|
2193
2185
|
displayName: "Combobox__ComboboxPlaceholder",
|
|
2194
2186
|
componentId: "u2hz6i-4"
|
|
2195
2187
|
})(["color:rgba(0,0,0,0.3);"]);
|
|
2196
|
-
var ComboboxLoading =
|
|
2188
|
+
var ComboboxLoading = styled(Loading).withConfig({
|
|
2197
2189
|
displayName: "Combobox__ComboboxLoading",
|
|
2198
2190
|
componentId: "u2hz6i-5"
|
|
2199
|
-
})(["bottom:6px;right:0.6rem;left:auto;top:auto;", ""],
|
|
2191
|
+
})(["bottom:6px;right:0.6rem;left:auto;top:auto;", ""], media.mobile(_templateObject3$1()));
|
|
2200
2192
|
var SEPARATOR = {};
|
|
2201
2193
|
var NO_DIGITABLE_FOUND = "Nenhum resultado encontrado"; //shouldRecenter?
|
|
2202
2194
|
|
|
2203
|
-
var Combobox =
|
|
2195
|
+
var Combobox = styled(React.forwardRef(function (_ref, ref) {
|
|
2204
2196
|
var _ref$getLabel = _ref.getLabel,
|
|
2205
2197
|
getLabel = _ref$getLabel === void 0 ? _identity : _ref$getLabel,
|
|
2206
2198
|
getLabelAs = _ref.getLabelAs,
|
|
@@ -2245,25 +2237,25 @@ var Combobox = styled__default(React__default.forwardRef(function (_ref, ref) {
|
|
|
2245
2237
|
} : _ref$check,
|
|
2246
2238
|
rest = _objectWithoutProperties(_ref, ["getLabel", "getLabelAs", "getBoxLabelAs", "getIcon", "scrollContainer", "className", "options", "autoFocus", "autoOpenMenu", "mandatory", "placeholder", "disabled", "fieldValue", "label", "path", "withWindowing", "tabIndex", "fieldClassName", "descText", "helpText", "raw", "digitable", "digitableConstraint", "digitableAsOption", "suggestive", "onDigitableChange", "footerOptions", "isLoading", "isOptionDisabled", "menuRef", "overrideSetValue", "transformOnSelect", "check"]);
|
|
2247
2239
|
|
|
2248
|
-
var selectedElement =
|
|
2249
|
-
var selectedElementIndex =
|
|
2250
|
-
var fieldRef =
|
|
2251
|
-
var windowingRef =
|
|
2252
|
-
var skipFocus =
|
|
2253
|
-
var skipHover =
|
|
2254
|
-
var skipDigitableSetValue =
|
|
2255
|
-
var listElement =
|
|
2256
|
-
var container =
|
|
2257
|
-
var keyState =
|
|
2258
|
-
var contextMenu =
|
|
2259
|
-
var hover =
|
|
2260
|
-
var strongHover =
|
|
2261
|
-
var scrollToVisibility =
|
|
2262
|
-
var autoCompleteUID =
|
|
2263
|
-
return
|
|
2240
|
+
var selectedElement = useRef();
|
|
2241
|
+
var selectedElementIndex = useRef();
|
|
2242
|
+
var fieldRef = useRef();
|
|
2243
|
+
var windowingRef = useRef();
|
|
2244
|
+
var skipFocus = useRefState(autoFocus);
|
|
2245
|
+
var skipHover = useRefState();
|
|
2246
|
+
var skipDigitableSetValue = useRefState();
|
|
2247
|
+
var listElement = useEnsureRef(menuRef);
|
|
2248
|
+
var container = useEnsureRef(ref);
|
|
2249
|
+
var keyState = useRefState();
|
|
2250
|
+
var contextMenu = useToggle(false);
|
|
2251
|
+
var hover = useToggle();
|
|
2252
|
+
var strongHover = useRefState();
|
|
2253
|
+
var scrollToVisibility = useToggle();
|
|
2254
|
+
var autoCompleteUID = useLazyConstant(function () {
|
|
2255
|
+
return getUID();
|
|
2264
2256
|
});
|
|
2265
2257
|
|
|
2266
|
-
var _useInput =
|
|
2258
|
+
var _useInput = useInput$1(_objectSpread({
|
|
2267
2259
|
fieldValue: fieldValue,
|
|
2268
2260
|
path: path
|
|
2269
2261
|
}, rest), raw),
|
|
@@ -2272,15 +2264,15 @@ var Combobox = styled__default(React__default.forwardRef(function (_ref, ref) {
|
|
|
2272
2264
|
confirmValue = _useInput2[1],
|
|
2273
2265
|
hasErrors = _useInput2[2].hasErrors;
|
|
2274
2266
|
|
|
2275
|
-
var value =
|
|
2267
|
+
var value = useToggle(formValue);
|
|
2276
2268
|
|
|
2277
2269
|
var _setValue = function setValue(v) {
|
|
2278
2270
|
value.openWith(v);
|
|
2279
2271
|
};
|
|
2280
2272
|
|
|
2281
|
-
var digitableValue =
|
|
2282
|
-
var digitableRef =
|
|
2283
|
-
var ignoringFilter =
|
|
2273
|
+
var digitableValue = useToggle(getLabel(value.isOpen));
|
|
2274
|
+
var digitableRef = useRef();
|
|
2275
|
+
var ignoringFilter = useToggle();
|
|
2284
2276
|
|
|
2285
2277
|
var setHover = function setHover(v) {
|
|
2286
2278
|
hover.openWith(v);
|
|
@@ -2292,7 +2284,7 @@ var Combobox = styled__default(React__default.forwardRef(function (_ref, ref) {
|
|
|
2292
2284
|
}
|
|
2293
2285
|
};
|
|
2294
2286
|
|
|
2295
|
-
|
|
2287
|
+
React.useLayoutEffect(function () {
|
|
2296
2288
|
if (digitable && !skipDigitableSetValue.get()) {
|
|
2297
2289
|
if (contextMenu.isOpen) {
|
|
2298
2290
|
digitableRef.current.select();
|
|
@@ -2309,26 +2301,26 @@ var Combobox = styled__default(React__default.forwardRef(function (_ref, ref) {
|
|
|
2309
2301
|
|
|
2310
2302
|
skipDigitableSetValue.set(false);
|
|
2311
2303
|
}, [contextMenu.isOpen]);
|
|
2312
|
-
|
|
2304
|
+
useEffect(function () {
|
|
2313
2305
|
contextMenu.isOpen && recenterScroll();
|
|
2314
2306
|
}, [contextMenu.isOpen]);
|
|
2315
|
-
|
|
2307
|
+
useEffect(function () {
|
|
2316
2308
|
selectedElement.current && scrollToVisibility.isOpen && makeOptionVisible();
|
|
2317
2309
|
}, [hover]);
|
|
2318
|
-
|
|
2310
|
+
useEffect(function () {
|
|
2319
2311
|
var _container$current;
|
|
2320
2312
|
|
|
2321
2313
|
autoFocus && ((_container$current = container.current) === null || _container$current === void 0 ? void 0 : _container$current.focus());
|
|
2322
2314
|
}, []);
|
|
2323
|
-
|
|
2315
|
+
useEffect(function () {
|
|
2324
2316
|
autoOpenMenu && toggleCombobox();
|
|
2325
2317
|
}, []);
|
|
2326
|
-
|
|
2318
|
+
useUpdateEffect(function () {
|
|
2327
2319
|
if (value.isOpen !== formValue && !contextMenu.isOpen) {
|
|
2328
2320
|
confirmValue(value.isOpen);
|
|
2329
2321
|
}
|
|
2330
2322
|
}, [!!contextMenu.isOpen]);
|
|
2331
|
-
|
|
2323
|
+
useEffect(function () {
|
|
2332
2324
|
if (formValue !== value.isOpen) {
|
|
2333
2325
|
_setValue(formValue);
|
|
2334
2326
|
}
|
|
@@ -2339,19 +2331,19 @@ var Combobox = styled__default(React__default.forwardRef(function (_ref, ref) {
|
|
|
2339
2331
|
});
|
|
2340
2332
|
}
|
|
2341
2333
|
}, [formValue]);
|
|
2342
|
-
var filteredOptions =
|
|
2334
|
+
var filteredOptions = useMemo(function () {
|
|
2343
2335
|
return _flow(_filter(function (v) {
|
|
2344
2336
|
if (!digitable || !digitableValue.isOpen || ignoringFilter.isOpen) {
|
|
2345
2337
|
return true;
|
|
2346
2338
|
}
|
|
2347
2339
|
|
|
2348
|
-
return
|
|
2340
|
+
return normalizeText(getLabel(v)).includes(normalizeText(digitableValue.isOpen));
|
|
2349
2341
|
}), _sortBy(function (v) {
|
|
2350
|
-
return
|
|
2342
|
+
return normalizeText(getLabel(v)).indexOf(normalizeText(digitableValue.isOpen)) > 0;
|
|
2351
2343
|
}))(options);
|
|
2352
2344
|
}, [options, digitable, digitableValue.isOpen, ignoringFilter.isOpen]);
|
|
2353
|
-
var digitableOption =
|
|
2354
|
-
var option = filteredOptions.length < 8 && digitableAsOption && !!digitableValue.isOpen &&
|
|
2345
|
+
var digitableOption = useMemo(function () {
|
|
2346
|
+
var option = filteredOptions.length < 8 && digitableAsOption && !!digitableValue.isOpen && callIfFunction(digitableAsOption, digitableValue.isOpen);
|
|
2355
2347
|
return option || !filteredOptions.length && digitable && !suggestive && NO_DIGITABLE_FOUND;
|
|
2356
2348
|
}, [digitableValue.isOpen, filteredOptions.length]);
|
|
2357
2349
|
var availableOptions = filteredOptions.concat(digitableOption || []);
|
|
@@ -2359,7 +2351,7 @@ var Combobox = styled__default(React__default.forwardRef(function (_ref, ref) {
|
|
|
2359
2351
|
return v !== SEPARATOR;
|
|
2360
2352
|
});
|
|
2361
2353
|
var withPlaceholder = !value.isOpen && value.isOpen !== 0 && placeholder;
|
|
2362
|
-
|
|
2354
|
+
useUpdateEffect(function () {
|
|
2363
2355
|
if (suggestive) {
|
|
2364
2356
|
return;
|
|
2365
2357
|
}
|
|
@@ -2367,7 +2359,7 @@ var Combobox = styled__default(React__default.forwardRef(function (_ref, ref) {
|
|
|
2367
2359
|
if (hover.isOpen) {
|
|
2368
2360
|
setHover(allOptions[0] === NO_DIGITABLE_FOUND ? allOptions[1] : allOptions[0]);
|
|
2369
2361
|
} else if (digitableValue.isOpen) {
|
|
2370
|
-
setHover(
|
|
2362
|
+
setHover(ifUndefined(value.isOpen, allOptions[0]));
|
|
2371
2363
|
}
|
|
2372
2364
|
}, [digitableValue.isOpen]);
|
|
2373
2365
|
|
|
@@ -2446,7 +2438,7 @@ var Combobox = styled__default(React__default.forwardRef(function (_ref, ref) {
|
|
|
2446
2438
|
if (allOptions.indexOf(value.isOpen) >= 0) {
|
|
2447
2439
|
_setValue(transformOnSelect(value.isOpen));
|
|
2448
2440
|
} else {
|
|
2449
|
-
_setValue(transformOnSelect(
|
|
2441
|
+
_setValue(transformOnSelect(callIfFunction(digitableAsOption, digitableValue.get()) || digitableValue.get()));
|
|
2450
2442
|
}
|
|
2451
2443
|
} else if (strongHover.get() === hover.get()) {
|
|
2452
2444
|
_setValue(transformOnSelect(strongHover.get()));
|
|
@@ -2550,13 +2542,13 @@ var Combobox = styled__default(React__default.forwardRef(function (_ref, ref) {
|
|
|
2550
2542
|
|
|
2551
2543
|
var createOption = function createOption(option, i, props, opts) {
|
|
2552
2544
|
if (option === SEPARATOR) {
|
|
2553
|
-
return
|
|
2545
|
+
return React.createElement(ListSeparator, {
|
|
2554
2546
|
key: "separator" + i
|
|
2555
2547
|
});
|
|
2556
2548
|
}
|
|
2557
2549
|
|
|
2558
2550
|
if (option === NO_DIGITABLE_FOUND) {
|
|
2559
|
-
return
|
|
2551
|
+
return React.createElement(Option, {
|
|
2560
2552
|
key: NO_DIGITABLE_FOUND + i,
|
|
2561
2553
|
disabled: true,
|
|
2562
2554
|
label: NO_DIGITABLE_FOUND
|
|
@@ -2572,15 +2564,15 @@ var Combobox = styled__default(React__default.forwardRef(function (_ref, ref) {
|
|
|
2572
2564
|
selectedElementIndex.current = i;
|
|
2573
2565
|
}
|
|
2574
2566
|
|
|
2575
|
-
return
|
|
2567
|
+
return React.createElement(Option, _extends({
|
|
2576
2568
|
key: label + i,
|
|
2577
2569
|
option: option,
|
|
2578
|
-
disabled:
|
|
2579
|
-
icon:
|
|
2570
|
+
disabled: callIfFunction(isOptionDisabled, option, label),
|
|
2571
|
+
icon: callIfFunction(getIcon, option),
|
|
2580
2572
|
checked: checked,
|
|
2581
2573
|
label: getLabelAs ? getLabelAs(option) : label,
|
|
2582
2574
|
setValue: function setValue(v) {
|
|
2583
|
-
if (!
|
|
2575
|
+
if (!callIfFunction(overrideSetValue, v, {
|
|
2584
2576
|
setValue: _setValue,
|
|
2585
2577
|
close: contextMenu.close
|
|
2586
2578
|
})) {
|
|
@@ -2628,9 +2620,9 @@ var Combobox = styled__default(React__default.forwardRef(function (_ref, ref) {
|
|
|
2628
2620
|
|
|
2629
2621
|
if (!((_listElement$current2 = listElement.current) === null || _listElement$current2 === void 0 ? void 0 : _listElement$current2.contains(e.relatedTarget))) {
|
|
2630
2622
|
if (!availableOptions.length && digitableAsOption && digitableValue.get()) {
|
|
2631
|
-
_setValue(transformOnSelect(
|
|
2623
|
+
_setValue(transformOnSelect(callIfFunction(digitableAsOption, digitableValue.get())));
|
|
2632
2624
|
} else if (suggestive) {
|
|
2633
|
-
_setValue(transformOnSelect(
|
|
2625
|
+
_setValue(transformOnSelect(callIfFunction(digitableAsOption, digitableValue.get()) || digitableValue.get()));
|
|
2634
2626
|
} else if (formValue !== value.isOpen) {
|
|
2635
2627
|
confirmValue(value.isOpen);
|
|
2636
2628
|
}
|
|
@@ -2639,7 +2631,7 @@ var Combobox = styled__default(React__default.forwardRef(function (_ref, ref) {
|
|
|
2639
2631
|
}
|
|
2640
2632
|
};
|
|
2641
2633
|
|
|
2642
|
-
return
|
|
2634
|
+
return React.createElement(Field$1, {
|
|
2643
2635
|
className: fieldClassName,
|
|
2644
2636
|
mandatory: mandatory,
|
|
2645
2637
|
descText: descText,
|
|
@@ -2647,7 +2639,7 @@ var Combobox = styled__default(React__default.forwardRef(function (_ref, ref) {
|
|
|
2647
2639
|
label: label,
|
|
2648
2640
|
labelClick: toggleCombobox,
|
|
2649
2641
|
ref: fieldRef
|
|
2650
|
-
},
|
|
2642
|
+
}, React.createElement(ComboboxInput, {
|
|
2651
2643
|
onBlur: onBlur,
|
|
2652
2644
|
onFocus: onFocus,
|
|
2653
2645
|
onClick: onClickInput,
|
|
@@ -2660,7 +2652,7 @@ var Combobox = styled__default(React__default.forwardRef(function (_ref, ref) {
|
|
|
2660
2652
|
comboboxIsOpen: contextMenu.isOpen,
|
|
2661
2653
|
isFocused: digitable && !!contextMenu.isOpen,
|
|
2662
2654
|
suggestive: suggestive
|
|
2663
|
-
}, digitable && !!contextMenu.isOpen ?
|
|
2655
|
+
}, digitable && !!contextMenu.isOpen ? React.createElement(TextInput$1, {
|
|
2664
2656
|
raw: true,
|
|
2665
2657
|
tabIndex: tabIndex,
|
|
2666
2658
|
autoFocus: true,
|
|
@@ -2675,12 +2667,12 @@ var Combobox = styled__default(React__default.forwardRef(function (_ref, ref) {
|
|
|
2675
2667
|
value: digitableValue.isOpen || "",
|
|
2676
2668
|
placeholder: placeholder,
|
|
2677
2669
|
onChange: onDigitableChange
|
|
2678
|
-
}) : withPlaceholder ?
|
|
2670
|
+
}) : withPlaceholder ? React.createElement(ComboboxPlaceholder, null, placeholder) : React.createElement("div", null, getBoxLabelAs ? getBoxLabelAs(value.isOpen) : getLabel(value.isOpen)), isLoading ? React.createElement(ComboboxLoading, {
|
|
2679
2671
|
absolute: true,
|
|
2680
2672
|
size: 20
|
|
2681
|
-
}) : !suggestive &&
|
|
2673
|
+
}) : !suggestive && React.createElement(ComboboxDropdownIcon, {
|
|
2682
2674
|
icon: "arrow-down"
|
|
2683
|
-
}), !!contextMenu.isOpen && (!suggestive || !digitable || allOptions.length && digitableValue.isOpen) &&
|
|
2675
|
+
}), !!contextMenu.isOpen && (!suggestive || !digitable || allOptions.length && digitableValue.isOpen) && React.createElement(ComboboxMenuContainer, {
|
|
2684
2676
|
withWindowing: withWindowing,
|
|
2685
2677
|
ref: listElement,
|
|
2686
2678
|
windowingRef: windowingRef,
|
|
@@ -2696,7 +2688,7 @@ var Combobox = styled__default(React__default.forwardRef(function (_ref, ref) {
|
|
|
2696
2688
|
componentId: "u2hz6i-6"
|
|
2697
2689
|
})(["user-select:none;"]);
|
|
2698
2690
|
|
|
2699
|
-
var _willUseIsSticky =
|
|
2691
|
+
var _willUseIsSticky = willUseIsSticky(),
|
|
2700
2692
|
_willUseIsSticky2 = _slicedToArray(_willUseIsSticky, 1),
|
|
2701
2693
|
WithIsSticky = _willUseIsSticky2[0];
|
|
2702
2694
|
|
|
@@ -2710,7 +2702,7 @@ var Option = function Option(_ref2) {
|
|
|
2710
2702
|
setRef = _ref2.setRef,
|
|
2711
2703
|
props = _objectWithoutProperties(_ref2, ["setValue", "icon", "option", "onHover", "checked", "label", "setRef"]);
|
|
2712
2704
|
|
|
2713
|
-
return
|
|
2705
|
+
return React.createElement(ListItem, _extends({
|
|
2714
2706
|
hover: checked,
|
|
2715
2707
|
tabIndex: -1,
|
|
2716
2708
|
onMouseOver: function onMouseOver(e) {
|
|
@@ -2721,12 +2713,12 @@ var Option = function Option(_ref2) {
|
|
|
2721
2713
|
e.stopPropagation();
|
|
2722
2714
|
setValue(option);
|
|
2723
2715
|
}
|
|
2724
|
-
}, props),
|
|
2716
|
+
}, props), React.createElement("a", null, icon && React.createElement(Icon, {
|
|
2725
2717
|
icon: icon
|
|
2726
2718
|
}), label));
|
|
2727
2719
|
};
|
|
2728
2720
|
var ITEM_HEIGHT = 37;
|
|
2729
|
-
var ComboboxMenuContainer =
|
|
2721
|
+
var ComboboxMenuContainer = React.forwardRef(function (_ref3, ref) {
|
|
2730
2722
|
var options = _ref3.options,
|
|
2731
2723
|
digitableAsOption = _ref3.digitableAsOption,
|
|
2732
2724
|
footerOptions = _ref3.footerOptions,
|
|
@@ -2736,7 +2728,7 @@ var ComboboxMenuContainer = React__default.forwardRef(function (_ref3, ref) {
|
|
|
2736
2728
|
digitableValue = _ref3.digitableValue,
|
|
2737
2729
|
windowingRef = _ref3.windowingRef;
|
|
2738
2730
|
|
|
2739
|
-
var _usePositioning =
|
|
2731
|
+
var _usePositioning = usePositioning(ref, {
|
|
2740
2732
|
fill: true,
|
|
2741
2733
|
on: options.length
|
|
2742
2734
|
}),
|
|
@@ -2749,16 +2741,16 @@ var ComboboxMenuContainer = React__default.forwardRef(function (_ref3, ref) {
|
|
|
2749
2741
|
};
|
|
2750
2742
|
|
|
2751
2743
|
var slot = 'Popup';
|
|
2752
|
-
var slotName =
|
|
2753
|
-
return
|
|
2744
|
+
var slotName = useMemo(function () {
|
|
2745
|
+
return getDialogLayersSize() === 0 ? slot : slot + '-' + (getDialogLayersSize() - 1);
|
|
2754
2746
|
}, []);
|
|
2755
|
-
return
|
|
2747
|
+
return React.createElement(React.Fragment, null, positionPlaceholder, React.createElement(Fill, {
|
|
2756
2748
|
name: slotName
|
|
2757
|
-
},
|
|
2749
|
+
}, React.createElement(ComboboxMenu, _extends({}, positionInfo, {
|
|
2758
2750
|
ref: ref,
|
|
2759
2751
|
withWindowing: withWindowing,
|
|
2760
2752
|
withoutIcons: !getIcon
|
|
2761
|
-
}), withWindowing ?
|
|
2753
|
+
}), withWindowing ? React.createElement(FixedSizeList, {
|
|
2762
2754
|
ref: windowingRef,
|
|
2763
2755
|
height: getMenuHeight(options),
|
|
2764
2756
|
itemCount: options.length,
|
|
@@ -2770,10 +2762,10 @@ var ComboboxMenuContainer = React__default.forwardRef(function (_ref3, ref) {
|
|
|
2770
2762
|
return createOption(options[index], index, {
|
|
2771
2763
|
style: style
|
|
2772
2764
|
});
|
|
2773
|
-
}) : options.map(createOption).filter(Boolean), footerOptions &&
|
|
2765
|
+
}) : options.map(createOption).filter(Boolean), footerOptions && React.createElement(WithIsSticky, {
|
|
2774
2766
|
intersection: true
|
|
2775
2767
|
}, function (sentinel, isSticky) {
|
|
2776
|
-
return
|
|
2768
|
+
return React.createElement(React.Fragment, null, React.createElement(FooterOptionsContainer, {
|
|
2777
2769
|
isSticky: isSticky,
|
|
2778
2770
|
className: "JS-list-footer",
|
|
2779
2771
|
hasWindoning: withWindowing
|
|
@@ -2799,24 +2791,24 @@ var ComboboxWithCustom = function ComboboxWithCustom(_ref) {
|
|
|
2799
2791
|
tabIndex = _ref$tabIndex === void 0 ? 1 : _ref$tabIndex,
|
|
2800
2792
|
extra = _objectWithoutProperties(_ref, ["options", "label", "constraint", "path", "getLabel", "getBoxLabelAs", "valueOnCustom", "customIndex", "tabIndex"]);
|
|
2801
2793
|
|
|
2802
|
-
var customValue =
|
|
2794
|
+
var customValue = useToggle();
|
|
2803
2795
|
|
|
2804
|
-
var _useFormValue =
|
|
2796
|
+
var _useFormValue = useFormValue$1(path),
|
|
2805
2797
|
_useFormValue2 = _slicedToArray(_useFormValue, 2),
|
|
2806
2798
|
value = _useFormValue2[0],
|
|
2807
2799
|
setValue = _useFormValue2[1];
|
|
2808
2800
|
|
|
2809
|
-
var _useFormMeta =
|
|
2801
|
+
var _useFormMeta = useFormMeta$1(["onCustom"].concat(_toPath(path))),
|
|
2810
2802
|
_useFormMeta2 = _slicedToArray(_useFormMeta, 2),
|
|
2811
2803
|
meta = _useFormMeta2[0],
|
|
2812
2804
|
setMeta = _useFormMeta2[1];
|
|
2813
2805
|
|
|
2814
|
-
var prevTitle =
|
|
2815
|
-
|
|
2806
|
+
var prevTitle = usePrevious(value);
|
|
2807
|
+
useLayoutEffect(function () {
|
|
2816
2808
|
if (value === options[customIndex]) {
|
|
2817
2809
|
setMeta(true);
|
|
2818
2810
|
customValue.openWith('');
|
|
2819
|
-
setValue(
|
|
2811
|
+
setValue(callIfFunction(valueOnCustom, prevTitle));
|
|
2820
2812
|
}
|
|
2821
2813
|
}, [value]);
|
|
2822
2814
|
|
|
@@ -2838,7 +2830,7 @@ var ComboboxWithCustom = function ComboboxWithCustom(_ref) {
|
|
|
2838
2830
|
};
|
|
2839
2831
|
|
|
2840
2832
|
var titleOptions = !value || options.indexOf(value) >= 0 ? options : [value].concat(options);
|
|
2841
|
-
return customValue.isOpen !== false ?
|
|
2833
|
+
return customValue.isOpen !== false ? React.createElement(TextInput$1, _extends({
|
|
2842
2834
|
label: label,
|
|
2843
2835
|
tabIndex: tabIndex,
|
|
2844
2836
|
autoFocus: true,
|
|
@@ -2850,7 +2842,7 @@ var ComboboxWithCustom = function ComboboxWithCustom(_ref) {
|
|
|
2850
2842
|
onKeyDown: updateCustomValue,
|
|
2851
2843
|
constraint: constraint,
|
|
2852
2844
|
raw: true
|
|
2853
|
-
}, extra)) :
|
|
2845
|
+
}, extra)) : React.createElement(Combobox$1, _extends({
|
|
2854
2846
|
getBoxLabelAs: function getBoxLabelAs(v) {
|
|
2855
2847
|
return v === options[customIndex] ? '' : _getBoxLabelAs(v);
|
|
2856
2848
|
},
|
|
@@ -2904,50 +2896,50 @@ function _templateObject$3() {
|
|
|
2904
2896
|
}
|
|
2905
2897
|
var ua = navigator.userAgent.toLowerCase();
|
|
2906
2898
|
var isSafari = ua.indexOf('safari') >= 0 && ua.indexOf('chrome') < 0;
|
|
2907
|
-
var InputLoading$1 =
|
|
2899
|
+
var InputLoading$1 = styled(Loading).withConfig({
|
|
2908
2900
|
displayName: "AutoComplete__InputLoading",
|
|
2909
2901
|
componentId: "g0526o-0"
|
|
2910
2902
|
})(["bottom:8px;right:0.6rem;left:auto;top:50%;transform:translate(-50%);"]);
|
|
2911
|
-
var AutoCompleteInput =
|
|
2903
|
+
var AutoCompleteInput = styled.div.withConfig({
|
|
2912
2904
|
displayName: "AutoComplete__AutoCompleteInput",
|
|
2913
2905
|
componentId: "g0526o-1"
|
|
2914
|
-
})(["width:100%;font-size:14px;border:1px solid ", ";border-radius:6px;color:", ";cursor:text;background:white;position:relative;outline:0;outline:none;min-height:3rem;line-height:28px;padding:0.25rem 0.7rem;display:flex;align-items:center;flex-wrap:wrap;", " ", " ", " ", " ", ""],
|
|
2915
|
-
return props.focused && "\n border-color: ".concat(
|
|
2906
|
+
})(["width:100%;font-size:14px;border:1px solid ", ";border-radius:6px;color:", ";cursor:text;background:white;position:relative;outline:0;outline:none;min-height:3rem;line-height:28px;padding:0.25rem 0.7rem;display:flex;align-items:center;flex-wrap:wrap;", " ", " ", " ", " ", ""], getColor('gray210'), getColor('gray60'), function (props) {
|
|
2907
|
+
return props.focused && "\n border-color: ".concat(getColor('gray180'), ";\n box-shadow: 0px 0px 0px 2px rgba(0,0,0,0.075);\n ");
|
|
2916
2908
|
}, function (props) {
|
|
2917
|
-
return props.hasErrors &&
|
|
2918
|
-
},
|
|
2919
|
-
return props.withDropdown &&
|
|
2920
|
-
},
|
|
2921
|
-
var AutoCompletePlaceholder =
|
|
2909
|
+
return props.hasErrors && css$1(["border-color:", " !important;"], getColor('alert'));
|
|
2910
|
+
}, media.mobile(_templateObject$3()), function (props) {
|
|
2911
|
+
return props.withDropdown && css$1(["padding-right:3rem;", ""], media.mobile(_templateObject2$2()));
|
|
2912
|
+
}, customTheme('TextInput'));
|
|
2913
|
+
var AutoCompletePlaceholder = styled.span.withConfig({
|
|
2922
2914
|
displayName: "AutoComplete__AutoCompletePlaceholder",
|
|
2923
2915
|
componentId: "g0526o-2"
|
|
2924
|
-
})(["position:absolute;top:50%;transform:translateY(-50%);pointer-events:none;color:rgba(0,0,0,0.3);left:0.7rem;right:0.7rem;", ""],
|
|
2925
|
-
var AutoCompleteTextboxDiv =
|
|
2916
|
+
})(["position:absolute;top:50%;transform:translateY(-50%);pointer-events:none;color:rgba(0,0,0,0.3);left:0.7rem;right:0.7rem;", ""], media.mobile(_templateObject3$2()));
|
|
2917
|
+
var AutoCompleteTextboxDiv = styled.div.withConfig({
|
|
2926
2918
|
displayName: "AutoComplete__AutoCompleteTextboxDiv",
|
|
2927
2919
|
componentId: "g0526o-3"
|
|
2928
2920
|
})(["display:inline-block;outline:0;outline:none;padding:0 1px;line-height:130%;"]);
|
|
2929
|
-
var AddedBox =
|
|
2921
|
+
var AddedBox = styled.span.withConfig({
|
|
2930
2922
|
displayName: "AutoComplete__AddedBox",
|
|
2931
2923
|
componentId: "g0526o-4"
|
|
2932
2924
|
})(["background-color:rgb(230,230,230);padding:5px 2rem 5px 0.75rem;border-radius:12px;font-size:13px;position:relative;margin-left:-3px;margin-right:9px;white-space:nowrap;cursor:default;line-height:normal;max-width:90%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;", ""], isSafari ? "\n vertical-align: 2px;\n " : "\n vertical-align: -7px;\n ");
|
|
2933
|
-
var RemoveIcon =
|
|
2925
|
+
var RemoveIcon = styled(Icon).withConfig({
|
|
2934
2926
|
displayName: "AutoComplete__RemoveIcon",
|
|
2935
2927
|
componentId: "g0526o-5"
|
|
2936
|
-
})(["width:20px;height:20px;border-radius:50%;display:inline-block;position:absolute;top:50%;line-height:20px;transform:translateY(-50%);right:2px;font-size:14px;text-align:center;cursor:pointer;color:", ";:hover{background-color:", ";color:", ";}"],
|
|
2937
|
-
return
|
|
2928
|
+
})(["width:20px;height:20px;border-radius:50%;display:inline-block;position:absolute;top:50%;line-height:20px;transform:translateY(-50%);right:2px;font-size:14px;text-align:center;cursor:pointer;color:", ";:hover{background-color:", ";color:", ";}"], getColor('gray120'), getColor('gray210'), function (props) {
|
|
2929
|
+
return darken(0.05, getColor('alert')(props));
|
|
2938
2930
|
});
|
|
2939
|
-
var AutoCompleteMenu =
|
|
2931
|
+
var AutoCompleteMenu = styled(ContextMenu).withConfig({
|
|
2940
2932
|
displayName: "AutoComplete__AutoCompleteMenu",
|
|
2941
2933
|
componentId: "g0526o-6"
|
|
2942
|
-
})(["box-shadow:0 2px 3px 1px rgba(0,0,0,0.2),0 0px 0px 1px rgba(0,0,0,0.05);max-height:22rem;overflow:auto;", "{> *{padding:11px;}}"],
|
|
2943
|
-
var AutoCompleteError =
|
|
2934
|
+
})(["box-shadow:0 2px 3px 1px rgba(0,0,0,0.2),0 0px 0px 1px rgba(0,0,0,0.05);max-height:22rem;overflow:auto;", "{> *{padding:11px;}}"], ContextMenu.ListItem);
|
|
2935
|
+
var AutoCompleteError = styled(Errors$1).withConfig({
|
|
2944
2936
|
displayName: "AutoComplete__AutoCompleteError",
|
|
2945
2937
|
componentId: "g0526o-7"
|
|
2946
|
-
})(["", "{background:transparent;border:none;color:", ";padding:0;margin-top:0.5rem;font-weight:600;", "{display:none;}}"],
|
|
2947
|
-
var DropdownIconContainer =
|
|
2938
|
+
})(["", "{background:transparent;border:none;color:", ";padding:0;margin-top:0.5rem;font-weight:600;", "{display:none;}}"], Errors$1.Item, getColor('alert'), Errors$1.CloseIcon);
|
|
2939
|
+
var DropdownIconContainer = styled(Icon).withConfig({
|
|
2948
2940
|
displayName: "AutoComplete__DropdownIconContainer",
|
|
2949
2941
|
componentId: "g0526o-8"
|
|
2950
|
-
})(["position:absolute;right:0;bottom:0;width:3rem;height:3rem;bottom:-1px;", " ", "{position:absolute;width:2rem;height:2rem;line-height:2rem;top:50%;left:50%;transform:translate(-50%,-50%);background:rgba(0,0,0,0.1);border-radius:50%;text-align:center;cursor:pointer;color:", ";:hover,:active{background:rgba(0,0,0,0.15);}}"],
|
|
2942
|
+
})(["position:absolute;right:0;bottom:0;width:3rem;height:3rem;bottom:-1px;", " ", "{position:absolute;width:2rem;height:2rem;line-height:2rem;top:50%;left:50%;transform:translate(-50%,-50%);background:rgba(0,0,0,0.1);border-radius:50%;text-align:center;cursor:pointer;color:", ";:hover,:active{background:rgba(0,0,0,0.15);}}"], media.mobile(_templateObject4()), Icon, getColor('gray90'));
|
|
2951
2943
|
|
|
2952
2944
|
var focusBeforeLast = function focusBeforeLast(e) {
|
|
2953
2945
|
if (e.target && e.target !== e.currentTarget) return;
|
|
@@ -2970,25 +2962,25 @@ var setSelectionRange = function setSelectionRange(input, selectionStart) {
|
|
|
2970
2962
|
sel.addRange(range);
|
|
2971
2963
|
};
|
|
2972
2964
|
|
|
2973
|
-
var AutoComplete =
|
|
2965
|
+
var AutoComplete = React.forwardRef(function (_ref, outerRef) {
|
|
2974
2966
|
var path = _ref.path,
|
|
2975
2967
|
_ref$AutoCompleteLi = _ref.AutoCompleteLi,
|
|
2976
|
-
AutoCompleteLi = _ref$AutoCompleteLi === void 0 ?
|
|
2968
|
+
AutoCompleteLi = _ref$AutoCompleteLi === void 0 ? Li : _ref$AutoCompleteLi,
|
|
2977
2969
|
_ref$CompletedBox = _ref.CompletedBox,
|
|
2978
2970
|
CompletedBox = _ref$CompletedBox === void 0 ? function (_ref2) {
|
|
2979
2971
|
var label = _ref2.label,
|
|
2980
2972
|
remove = _ref2.remove,
|
|
2981
2973
|
value = _ref2.value;
|
|
2982
|
-
return
|
|
2974
|
+
return React.createElement(AddedBox, {
|
|
2983
2975
|
title: label
|
|
2984
|
-
}, label,
|
|
2976
|
+
}, label, React.createElement(RemoveIcon, {
|
|
2985
2977
|
icon: "x",
|
|
2986
2978
|
onClick: remove
|
|
2987
2979
|
}));
|
|
2988
2980
|
} : _ref$CompletedBox,
|
|
2989
2981
|
_ref$EditableInput = _ref.EditableInput,
|
|
2990
2982
|
EditableInput = _ref$EditableInput === void 0 ? function (props) {
|
|
2991
|
-
return
|
|
2983
|
+
return React.createElement(AutoCompleteTextboxDiv, props);
|
|
2992
2984
|
} : _ref$EditableInput,
|
|
2993
2985
|
_ref$getLabel = _ref.getLabel,
|
|
2994
2986
|
getLabel = _ref$getLabel === void 0 ? function (v) {
|
|
@@ -3041,11 +3033,11 @@ var AutoComplete = React__default.forwardRef(function (_ref, outerRef) {
|
|
|
3041
3033
|
value = _ref.value,
|
|
3042
3034
|
setValue = _ref.setValue,
|
|
3043
3035
|
raw = _ref.raw;
|
|
3044
|
-
var autoCompleteBox =
|
|
3045
|
-
var hoverIndex =
|
|
3046
|
-
var isLoading =
|
|
3036
|
+
var autoCompleteBox = useToggle();
|
|
3037
|
+
var hoverIndex = useToggle();
|
|
3038
|
+
var isLoading = useToggle();
|
|
3047
3039
|
|
|
3048
|
-
var _useInput =
|
|
3040
|
+
var _useInput = useInput$1({
|
|
3049
3041
|
path: path,
|
|
3050
3042
|
transform: transform,
|
|
3051
3043
|
value: value,
|
|
@@ -3056,21 +3048,21 @@ var AutoComplete = React__default.forwardRef(function (_ref, outerRef) {
|
|
|
3056
3048
|
setFormValue = _useInput2[1],
|
|
3057
3049
|
hasErrors = _useInput2[2].hasErrors;
|
|
3058
3050
|
|
|
3059
|
-
var _useProvideErrors =
|
|
3051
|
+
var _useProvideErrors = useProvideErrors$1(),
|
|
3060
3052
|
_useProvideErrors2 = _slicedToArray(_useProvideErrors, 2),
|
|
3061
3053
|
ErrorProvider = _useProvideErrors2[0],
|
|
3062
3054
|
errorUtils = _useProvideErrors2[1];
|
|
3063
3055
|
|
|
3064
|
-
var hooksRef =
|
|
3065
|
-
var ref =
|
|
3066
|
-
var queries =
|
|
3067
|
-
var editables =
|
|
3068
|
-
var listSize =
|
|
3069
|
-
var suggestionsFetchCache =
|
|
3070
|
-
var suggestionsLabelMapCache =
|
|
3071
|
-
var lastSuggestionQuery =
|
|
3056
|
+
var hooksRef = useEnsureRef(outerRef);
|
|
3057
|
+
var ref = useRef();
|
|
3058
|
+
var queries = useRefState([]);
|
|
3059
|
+
var editables = useRefState([(formValue || []).length]);
|
|
3060
|
+
var listSize = useRefState(editables.get()[0]);
|
|
3061
|
+
var suggestionsFetchCache = useRefState({});
|
|
3062
|
+
var suggestionsLabelMapCache = useRefState({});
|
|
3063
|
+
var lastSuggestionQuery = useRefState('');
|
|
3072
3064
|
|
|
3073
|
-
var _useState =
|
|
3065
|
+
var _useState = useState([]),
|
|
3074
3066
|
_useState2 = _slicedToArray(_useState, 2),
|
|
3075
3067
|
autoCompleteList = _useState2[0],
|
|
3076
3068
|
setAutoCompleteList = _useState2[1];
|
|
@@ -3079,9 +3071,9 @@ var AutoComplete = React__default.forwardRef(function (_ref, outerRef) {
|
|
|
3079
3071
|
return formValue || [];
|
|
3080
3072
|
};
|
|
3081
3073
|
|
|
3082
|
-
var shouldFocusInput =
|
|
3083
|
-
var recentlyAdded =
|
|
3084
|
-
|
|
3074
|
+
var shouldFocusInput = useToggle();
|
|
3075
|
+
var recentlyAdded = useRefState();
|
|
3076
|
+
useEffect(function () {
|
|
3085
3077
|
if (autoFocus) {
|
|
3086
3078
|
focusInput();
|
|
3087
3079
|
}
|
|
@@ -3093,7 +3085,7 @@ var AutoComplete = React__default.forwardRef(function (_ref, outerRef) {
|
|
|
3093
3085
|
});
|
|
3094
3086
|
};
|
|
3095
3087
|
|
|
3096
|
-
|
|
3088
|
+
useEffect(function () {
|
|
3097
3089
|
if (shouldFocusInput.isOpen) focusBeforeLast({
|
|
3098
3090
|
currentTarget: ref.current,
|
|
3099
3091
|
target: ref.current
|
|
@@ -3189,7 +3181,7 @@ var AutoComplete = React__default.forwardRef(function (_ref, outerRef) {
|
|
|
3189
3181
|
}
|
|
3190
3182
|
};
|
|
3191
3183
|
|
|
3192
|
-
|
|
3184
|
+
useEffect(function () {
|
|
3193
3185
|
var newValue = formValue || [];
|
|
3194
3186
|
|
|
3195
3187
|
if (newValue.length !== listSize.get()) {
|
|
@@ -3210,7 +3202,7 @@ var AutoComplete = React__default.forwardRef(function (_ref, outerRef) {
|
|
|
3210
3202
|
|
|
3211
3203
|
if (recentlyAdded.get()) {
|
|
3212
3204
|
recentlyAdded.set(false);
|
|
3213
|
-
|
|
3205
|
+
callIfFunction(onAddValue, formValue, setFormValue);
|
|
3214
3206
|
}
|
|
3215
3207
|
}, [formValue]);
|
|
3216
3208
|
|
|
@@ -3260,7 +3252,7 @@ var AutoComplete = React__default.forwardRef(function (_ref, outerRef) {
|
|
|
3260
3252
|
var onChange = function onChange(index, value) {
|
|
3261
3253
|
errorUtils.clearErrors();
|
|
3262
3254
|
|
|
3263
|
-
var newValue =
|
|
3255
|
+
var newValue = _s.set([index], value, getValue());
|
|
3264
3256
|
|
|
3265
3257
|
listSize.set(newValue.length);
|
|
3266
3258
|
setFormValue(newValue);
|
|
@@ -3270,8 +3262,8 @@ var AutoComplete = React__default.forwardRef(function (_ref, outerRef) {
|
|
|
3270
3262
|
var index = Math.max(lastIsEditable() ? getValue().length - 1 : getValue().length, 0);
|
|
3271
3263
|
editables.set(_flow(_filter(function (_) {
|
|
3272
3264
|
return _ !== index;
|
|
3273
|
-
}),
|
|
3274
|
-
setFormValue(
|
|
3265
|
+
}), _s.concat([index + 1])));
|
|
3266
|
+
setFormValue(_s.set(index, value, getValue()));
|
|
3275
3267
|
listSize.set(index);
|
|
3276
3268
|
recentlyAdded.set(true);
|
|
3277
3269
|
|
|
@@ -3285,7 +3277,7 @@ var AutoComplete = React__default.forwardRef(function (_ref, outerRef) {
|
|
|
3285
3277
|
return _ >= index ? _ - 1 : 1;
|
|
3286
3278
|
}));
|
|
3287
3279
|
|
|
3288
|
-
var newList =
|
|
3280
|
+
var newList = _s.unset(index, getValue()).filter(function (_) {
|
|
3289
3281
|
return _ !== undefined;
|
|
3290
3282
|
});
|
|
3291
3283
|
|
|
@@ -3318,7 +3310,7 @@ var AutoComplete = React__default.forwardRef(function (_ref, outerRef) {
|
|
|
3318
3310
|
}
|
|
3319
3311
|
};
|
|
3320
3312
|
|
|
3321
|
-
|
|
3313
|
+
React.useImperativeHandle(hooksRef, function () {
|
|
3322
3314
|
return {
|
|
3323
3315
|
addValue: addValue,
|
|
3324
3316
|
confirm: confirm,
|
|
@@ -3343,7 +3335,7 @@ var AutoComplete = React__default.forwardRef(function (_ref, outerRef) {
|
|
|
3343
3335
|
|
|
3344
3336
|
var tryOpenSuggestions = function tryOpenSuggestions(e) {
|
|
3345
3337
|
if (autoCompleteBox.get()) {
|
|
3346
|
-
|
|
3338
|
+
stopPropagation(onBlur)(e);
|
|
3347
3339
|
} else {
|
|
3348
3340
|
errorUtils.clearErrors();
|
|
3349
3341
|
refreshSuggestions(lastIsEditable() ? getValue().slice(-1)[0] : '', false, true);
|
|
@@ -3351,7 +3343,7 @@ var AutoComplete = React__default.forwardRef(function (_ref, outerRef) {
|
|
|
3351
3343
|
}
|
|
3352
3344
|
};
|
|
3353
3345
|
|
|
3354
|
-
var input =
|
|
3346
|
+
var input = React.createElement(React.Fragment, null, React.createElement(AutoCompleteInput, {
|
|
3355
3347
|
className: className,
|
|
3356
3348
|
ref: ref,
|
|
3357
3349
|
onFocus: autoCompleteList.length ? autoCompleteBox.open : undefined,
|
|
@@ -3366,8 +3358,8 @@ var AutoComplete = React__default.forwardRef(function (_ref, outerRef) {
|
|
|
3366
3358
|
},
|
|
3367
3359
|
focused: autoCompleteBox.isOpen,
|
|
3368
3360
|
withDropdown: withDropdown
|
|
3369
|
-
},
|
|
3370
|
-
return editables.get().indexOf(i) >= 0 ?
|
|
3361
|
+
}, React.createElement("span", null, "\u200B"), valueWithEditable.map(function (v, i) {
|
|
3362
|
+
return editables.get().indexOf(i) >= 0 ? React.createElement(AutoCompleteTextbox, {
|
|
3371
3363
|
value: v,
|
|
3372
3364
|
index: i,
|
|
3373
3365
|
confirmKeys: confirmKeys,
|
|
@@ -3381,7 +3373,7 @@ var AutoComplete = React__default.forwardRef(function (_ref, outerRef) {
|
|
|
3381
3373
|
tabIndex: tabIndex,
|
|
3382
3374
|
confirmIfNew: confirmIfNew,
|
|
3383
3375
|
confirmIfNewKeys: confirmIfNewKeys
|
|
3384
|
-
}) :
|
|
3376
|
+
}) : React.createElement(CompletedBox, {
|
|
3385
3377
|
key: _getUniqueKey(v),
|
|
3386
3378
|
label: getLabel(v),
|
|
3387
3379
|
value: v,
|
|
@@ -3389,15 +3381,15 @@ var AutoComplete = React__default.forwardRef(function (_ref, outerRef) {
|
|
|
3389
3381
|
return _remove(i);
|
|
3390
3382
|
}
|
|
3391
3383
|
});
|
|
3392
|
-
}),
|
|
3384
|
+
}), React.createElement("span", null, "\u200B"), (!formValue || !formValue.join('')) && placeholder && React.createElement(AutoCompletePlaceholder, {
|
|
3393
3385
|
onClick: function onClick(e) {
|
|
3394
3386
|
return ref.current.click();
|
|
3395
3387
|
}
|
|
3396
|
-
}, placeholder), withDropdown && !isLoading.isOpen &&
|
|
3388
|
+
}, placeholder), withDropdown && !isLoading.isOpen && React.createElement(DropdownIconContainer, {
|
|
3397
3389
|
onClick: tryOpenSuggestions
|
|
3398
|
-
},
|
|
3390
|
+
}, React.createElement(Icon, {
|
|
3399
3391
|
icon: "arrow-down"
|
|
3400
|
-
})), autoCompleteBox.isOpen !== false && !errorUtils.errors.length && autoCompleteList.length > 0 &&
|
|
3392
|
+
})), autoCompleteBox.isOpen !== false && !errorUtils.errors.length && autoCompleteList.length > 0 && React.createElement(AutoCompleteMenu, {
|
|
3401
3393
|
hoverIndex: hoverIndex.isOpen,
|
|
3402
3394
|
autoHover: autoSelect,
|
|
3403
3395
|
onClick: function onClick(e) {
|
|
@@ -3408,7 +3400,7 @@ var AutoComplete = React__default.forwardRef(function (_ref, outerRef) {
|
|
|
3408
3400
|
at: "bottom left",
|
|
3409
3401
|
fill: true
|
|
3410
3402
|
}, autoCompleteList.map(function (value) {
|
|
3411
|
-
return
|
|
3403
|
+
return React.createElement(AutoCompleteLi, {
|
|
3412
3404
|
className: !translatable ? 'notranslate' : null,
|
|
3413
3405
|
key: _getUniqueKey(value),
|
|
3414
3406
|
label: getListItem(value),
|
|
@@ -3419,10 +3411,10 @@ var AutoComplete = React__default.forwardRef(function (_ref, outerRef) {
|
|
|
3419
3411
|
return addValue(value);
|
|
3420
3412
|
}
|
|
3421
3413
|
});
|
|
3422
|
-
}))),
|
|
3414
|
+
}))), React.createElement(ErrorProvider, {
|
|
3423
3415
|
value: errorUtils
|
|
3424
|
-
},
|
|
3425
|
-
return withoutField ? input :
|
|
3416
|
+
}, React.createElement(AutoCompleteError, null)));
|
|
3417
|
+
return withoutField ? input : React.createElement(Field$1, {
|
|
3426
3418
|
bellowDescText: bellowDescText,
|
|
3427
3419
|
className: fieldClassName,
|
|
3428
3420
|
value: formValue,
|
|
@@ -3431,7 +3423,7 @@ var AutoComplete = React__default.forwardRef(function (_ref, outerRef) {
|
|
|
3431
3423
|
helpText: helpText,
|
|
3432
3424
|
label: label,
|
|
3433
3425
|
labelClick: focusInput
|
|
3434
|
-
}, isLoading.isOpen &&
|
|
3426
|
+
}, isLoading.isOpen && React.createElement(InputLoading$1, {
|
|
3435
3427
|
absolute: true,
|
|
3436
3428
|
size: 24
|
|
3437
3429
|
}), input);
|
|
@@ -3586,12 +3578,12 @@ function (_React$Component) {
|
|
|
3586
3578
|
}
|
|
3587
3579
|
}, rest);
|
|
3588
3580
|
|
|
3589
|
-
return typeof EditableInput === 'function' ? EditableInput(props) :
|
|
3581
|
+
return typeof EditableInput === 'function' ? EditableInput(props) : React.createElement(EditableInput, props);
|
|
3590
3582
|
}
|
|
3591
3583
|
}]);
|
|
3592
3584
|
|
|
3593
3585
|
return AutoCompleteTextbox;
|
|
3594
|
-
}(
|
|
3586
|
+
}(React.Component);
|
|
3595
3587
|
|
|
3596
3588
|
var addRootPath = function addRootPath(errorRootPath, errors, path) {
|
|
3597
3589
|
var rootPath = [].concat(errorRootPath || [], path);
|
|
@@ -3601,15 +3593,15 @@ var addRootPath = function addRootPath(errorRootPath, errors, path) {
|
|
|
3601
3593
|
}, {});
|
|
3602
3594
|
};
|
|
3603
3595
|
|
|
3604
|
-
var EditableContext =
|
|
3605
|
-
var ConfirmEditableBoxes =
|
|
3596
|
+
var EditableContext = React.createContext({});
|
|
3597
|
+
var ConfirmEditableBoxes = forwardRef(function (_ref, ref) {
|
|
3606
3598
|
var children = _ref.children,
|
|
3607
3599
|
_ref$itemValidation = _ref.itemValidation,
|
|
3608
3600
|
itemValidation = _ref$itemValidation === void 0 ? _stubFalse : _ref$itemValidation,
|
|
3609
3601
|
_ref$listValidation = _ref.listValidation,
|
|
3610
3602
|
_ref$transform = _ref.transform,
|
|
3611
3603
|
transform = _ref$transform === void 0 ? _identity : _ref$transform;
|
|
3612
|
-
var submitAll =
|
|
3604
|
+
var submitAll = useCallback(
|
|
3613
3605
|
/*#__PURE__*/
|
|
3614
3606
|
function () {
|
|
3615
3607
|
var _ref2 = _asyncToGenerator(
|
|
@@ -3659,24 +3651,24 @@ var ConfirmEditableBoxes = React.forwardRef(function (_ref, ref) {
|
|
|
3659
3651
|
};
|
|
3660
3652
|
}(), []);
|
|
3661
3653
|
|
|
3662
|
-
var _useDraftConfirmation =
|
|
3654
|
+
var _useDraftConfirmation = useDraftConfirmation$1(submitAll),
|
|
3663
3655
|
_useDraftConfirmation2 = _slicedToArray(_useDraftConfirmation, 3),
|
|
3664
3656
|
confirmDraftContent = _useDraftConfirmation2[0],
|
|
3665
3657
|
draftToggle = _useDraftConfirmation2[1],
|
|
3666
3658
|
draftConfirmation = _useDraftConfirmation2[2];
|
|
3667
3659
|
|
|
3668
|
-
|
|
3669
|
-
return draftToggle.openWith(
|
|
3660
|
+
useEffect(function () {
|
|
3661
|
+
return draftToggle.openWith(lazyValue(function () {
|
|
3670
3662
|
return hasModifiedBoxes();
|
|
3671
3663
|
}));
|
|
3672
3664
|
}, []);
|
|
3673
3665
|
|
|
3674
|
-
var _useConsumerCatalog =
|
|
3666
|
+
var _useConsumerCatalog = useConsumerCatalog(),
|
|
3675
3667
|
_useConsumerCatalog2 = _slicedToArray(_useConsumerCatalog, 2),
|
|
3676
3668
|
sharedBoxes = _useConsumerCatalog2[0],
|
|
3677
3669
|
sharedBoxesManager = _useConsumerCatalog2[1];
|
|
3678
3670
|
|
|
3679
|
-
var _useConsumerCatalog3 =
|
|
3671
|
+
var _useConsumerCatalog3 = useConsumerCatalog(),
|
|
3680
3672
|
_useConsumerCatalog4 = _slicedToArray(_useConsumerCatalog3, 2),
|
|
3681
3673
|
standaloneBoxes = _useConsumerCatalog4[0],
|
|
3682
3674
|
standaloneBoxesManager = _useConsumerCatalog4[1];
|
|
@@ -3689,7 +3681,7 @@ var ConfirmEditableBoxes = React.forwardRef(function (_ref, ref) {
|
|
|
3689
3681
|
return editableBoxes(boxes).length > 0;
|
|
3690
3682
|
};
|
|
3691
3683
|
|
|
3692
|
-
var provide =
|
|
3684
|
+
var provide = useMemo(function () {
|
|
3693
3685
|
return {
|
|
3694
3686
|
sharedBoxes: sharedBoxesManager,
|
|
3695
3687
|
standaloneBoxes: standaloneBoxesManager,
|
|
@@ -3697,17 +3689,17 @@ var ConfirmEditableBoxes = React.forwardRef(function (_ref, ref) {
|
|
|
3697
3689
|
transform: transform
|
|
3698
3690
|
};
|
|
3699
3691
|
}, []);
|
|
3700
|
-
var confirm =
|
|
3692
|
+
var confirm = useCallback(function (cb) {
|
|
3701
3693
|
var dialogType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'submit-draft';
|
|
3702
3694
|
return draftConfirmation(dialogType, cb);
|
|
3703
3695
|
}, [draftConfirmation]);
|
|
3704
|
-
var discard =
|
|
3696
|
+
var discard = useCallback(function (cb) {
|
|
3705
3697
|
return draftConfirmation('discard-draft', cb);
|
|
3706
3698
|
}, [draftConfirmation]);
|
|
3707
3699
|
|
|
3708
3700
|
var modifiedEditablesPath = function modifiedEditablesPath(boxes) {
|
|
3709
3701
|
return modifiedEditableBoxes(boxes).map(function (_) {
|
|
3710
|
-
return
|
|
3702
|
+
return callIfFunction(_.path);
|
|
3711
3703
|
});
|
|
3712
3704
|
};
|
|
3713
3705
|
|
|
@@ -3735,7 +3727,7 @@ var ConfirmEditableBoxes = React.forwardRef(function (_ref, ref) {
|
|
|
3735
3727
|
var validated = modifiedEditableBoxes(sharedBoxes()).reduce(function (_ref5, box) {
|
|
3736
3728
|
var success = _ref5.success,
|
|
3737
3729
|
errors = _ref5.errors;
|
|
3738
|
-
var index =
|
|
3730
|
+
var index = callIfFunction(box.path);
|
|
3739
3731
|
|
|
3740
3732
|
var _box$modifiedValue = box.modifiedValue(),
|
|
3741
3733
|
_box$modifiedValue2 = _slicedToArray(_box$modifiedValue, 2),
|
|
@@ -3751,7 +3743,7 @@ var ConfirmEditableBoxes = React.forwardRef(function (_ref, ref) {
|
|
|
3751
3743
|
};
|
|
3752
3744
|
}
|
|
3753
3745
|
|
|
3754
|
-
var newProps =
|
|
3746
|
+
var newProps = _s.set(index, transform(newItem, index), success);
|
|
3755
3747
|
|
|
3756
3748
|
return {
|
|
3757
3749
|
success: newProps,
|
|
@@ -3825,7 +3817,7 @@ var ConfirmEditableBoxes = React.forwardRef(function (_ref, ref) {
|
|
|
3825
3817
|
}
|
|
3826
3818
|
};
|
|
3827
3819
|
|
|
3828
|
-
var methods =
|
|
3820
|
+
var methods = useMemo(function () {
|
|
3829
3821
|
return {
|
|
3830
3822
|
confirm: confirm,
|
|
3831
3823
|
discard: discard,
|
|
@@ -3835,26 +3827,26 @@ var ConfirmEditableBoxes = React.forwardRef(function (_ref, ref) {
|
|
|
3835
3827
|
modifiedEditablesPath: modifiedEditablesPath
|
|
3836
3828
|
};
|
|
3837
3829
|
}, [draftConfirmation]);
|
|
3838
|
-
|
|
3830
|
+
useImperativeHandle(ref, function () {
|
|
3839
3831
|
return methods;
|
|
3840
3832
|
}, [methods]);
|
|
3841
|
-
return
|
|
3833
|
+
return React.createElement(React.Fragment, null, confirmDraftContent, React.createElement(EditableContext.Provider, {
|
|
3842
3834
|
value: provide
|
|
3843
|
-
},
|
|
3835
|
+
}, callIfFunction(children, methods)));
|
|
3844
3836
|
});
|
|
3845
3837
|
|
|
3846
3838
|
var FlipDiv = function FlipDiv(_ref12) {
|
|
3847
3839
|
var useAnimation = _ref12.useAnimation,
|
|
3848
3840
|
props = _objectWithoutProperties(_ref12, ["useAnimation"]);
|
|
3849
3841
|
|
|
3850
|
-
var ref =
|
|
3842
|
+
var ref = useRef();
|
|
3851
3843
|
useAnimation(ref);
|
|
3852
|
-
return
|
|
3844
|
+
return React.createElement("div", _extends({}, props, {
|
|
3853
3845
|
ref: ref
|
|
3854
3846
|
}));
|
|
3855
3847
|
};
|
|
3856
3848
|
|
|
3857
|
-
var EditableBoxPresentation =
|
|
3849
|
+
var EditableBoxPresentation = styled(forwardRef(function (_ref13, ref) {
|
|
3858
3850
|
var _ref13$view = _ref13.view,
|
|
3859
3851
|
view = _ref13$view === void 0 ? function (value) {
|
|
3860
3852
|
return value === undefined || value === null ? '' : String(value);
|
|
@@ -3881,27 +3873,27 @@ var EditableBoxPresentation = styled__default(React.forwardRef(function (_ref13,
|
|
|
3881
3873
|
className = _ref13.className,
|
|
3882
3874
|
submitRef = _ref13.submitRef,
|
|
3883
3875
|
path = _ref13.path;
|
|
3884
|
-
var popup =
|
|
3885
|
-
var editing =
|
|
3886
|
-
var loading =
|
|
3887
|
-
var form
|
|
3876
|
+
var popup = usePopupToggle();
|
|
3877
|
+
var editing = useToggle(editingIsOpen);
|
|
3878
|
+
var loading = useToggle();
|
|
3879
|
+
var form = useContext(FormContext$1);
|
|
3888
3880
|
|
|
3889
3881
|
var closeBox = function closeBox(params) {
|
|
3890
|
-
|
|
3882
|
+
callIfFunction(onClose, params);
|
|
3891
3883
|
editing.close();
|
|
3892
3884
|
};
|
|
3893
3885
|
|
|
3894
|
-
|
|
3886
|
+
useEffect(function () {
|
|
3895
3887
|
return function () {
|
|
3896
|
-
return
|
|
3888
|
+
return callIfFunction(onClose, true);
|
|
3897
3889
|
};
|
|
3898
3890
|
}, []);
|
|
3899
|
-
|
|
3891
|
+
useEffect(function () {
|
|
3900
3892
|
if (editing.isOpen) {
|
|
3901
|
-
|
|
3893
|
+
callIfFunction(onOpen);
|
|
3902
3894
|
}
|
|
3903
3895
|
}, [editing.isOpen]);
|
|
3904
|
-
|
|
3896
|
+
useImperativeHandle(ref, function () {
|
|
3905
3897
|
return {
|
|
3906
3898
|
loading: loading,
|
|
3907
3899
|
closeBox: closeBox,
|
|
@@ -3937,18 +3929,18 @@ var EditableBoxPresentation = styled__default(React.forwardRef(function (_ref13,
|
|
|
3937
3929
|
};
|
|
3938
3930
|
|
|
3939
3931
|
var getPath = function getPath(extraPath) {
|
|
3940
|
-
return
|
|
3932
|
+
return _s.toPath(path).concat(_s.toPath(extraPath));
|
|
3941
3933
|
};
|
|
3942
3934
|
|
|
3943
3935
|
var getValue = function getValue(extraPath, otherProps) {
|
|
3944
|
-
return otherProps ?
|
|
3936
|
+
return otherProps ? _s.get(getPath(extraPath), otherProps) : form.getValue(getPath(extraPath));
|
|
3945
3937
|
};
|
|
3946
3938
|
|
|
3947
3939
|
var setValue = function setValue(value, extraPath) {
|
|
3948
|
-
return form
|
|
3940
|
+
return form.setValue(getPath(extraPath), value);
|
|
3949
3941
|
};
|
|
3950
3942
|
|
|
3951
|
-
var flipAnimation =
|
|
3943
|
+
var flipAnimation = useLazyConstant(willUseFlipSwitch);
|
|
3952
3944
|
var disabledClick = readOnly || disabled;
|
|
3953
3945
|
|
|
3954
3946
|
var openBox = function openBox() {
|
|
@@ -3956,9 +3948,9 @@ var EditableBoxPresentation = styled__default(React.forwardRef(function (_ref13,
|
|
|
3956
3948
|
};
|
|
3957
3949
|
|
|
3958
3950
|
var formattedPath = getPath();
|
|
3959
|
-
return
|
|
3951
|
+
return React.createElement(PathContext$1.Provider, {
|
|
3960
3952
|
value: formattedPath
|
|
3961
|
-
},
|
|
3953
|
+
}, React.createElement(FlipDiv, {
|
|
3962
3954
|
key: editing.isOpen,
|
|
3963
3955
|
useAnimation: flipAnimation,
|
|
3964
3956
|
onKeyDown: tryClose,
|
|
@@ -3966,34 +3958,34 @@ var EditableBoxPresentation = styled__default(React.forwardRef(function (_ref13,
|
|
|
3966
3958
|
onTouchStart: onTouchStart,
|
|
3967
3959
|
className: 'editable-box ' + (!disabledClick ? 'clickable ' : '') + (editing.isOpen ? 'expanded' : 'collapsed') + ' ' + className,
|
|
3968
3960
|
onClick: editing.isOpen || disabledClick ? undefined : openBox
|
|
3969
|
-
}, !editing.isOpen && !disabledClick && !(withDelete || withContextMenu) &&
|
|
3961
|
+
}, !editing.isOpen && !disabledClick && !(withDelete || withContextMenu) && React.createElement(Button, {
|
|
3970
3962
|
tabIndex: tabIndex,
|
|
3971
3963
|
className: "edit-button",
|
|
3972
3964
|
small: true,
|
|
3973
3965
|
onlyIcon: true,
|
|
3974
3966
|
icon: "edit"
|
|
3975
|
-
}), !editing.isOpen && !disabledClick && (withDelete || withContextMenu) &&
|
|
3967
|
+
}), !editing.isOpen && !disabledClick && (withDelete || withContextMenu) && React.createElement(Button, {
|
|
3976
3968
|
tabIndex: tabIndex,
|
|
3977
3969
|
className: "edit-button arrow-down",
|
|
3978
3970
|
small: true,
|
|
3979
3971
|
onlyIcon: true,
|
|
3980
3972
|
icon: "arrow-down",
|
|
3981
|
-
onClick:
|
|
3982
|
-
}, popup.isOpen &&
|
|
3973
|
+
onClick: stopPropagation(popup.toggle)
|
|
3974
|
+
}, popup.isOpen && React.createElement(ContextMenu, null, React.createElement(Li, {
|
|
3983
3975
|
label: "Editar",
|
|
3984
3976
|
icon: "edit-line",
|
|
3985
3977
|
onClick: openBox
|
|
3986
|
-
}), withDelete &&
|
|
3978
|
+
}), withDelete && React.createElement(Li, {
|
|
3987
3979
|
label: "Deletar",
|
|
3988
3980
|
icon: "remove",
|
|
3989
3981
|
onClick: handleDelete
|
|
3990
|
-
}), withContextMenu)),
|
|
3982
|
+
}), withContextMenu)), React.createElement("form", {
|
|
3991
3983
|
onSubmit: onSubmit
|
|
3992
|
-
},
|
|
3984
|
+
}, React.createElement(FormValue$1, {
|
|
3993
3985
|
path: formattedPath,
|
|
3994
|
-
key:
|
|
3986
|
+
key: formatPath(formattedPath)
|
|
3995
3987
|
}, function (value) {
|
|
3996
|
-
return
|
|
3988
|
+
return fixDoubledLastMarginBottom(editing.isOpen ? edit(value, {
|
|
3997
3989
|
getPath: getPath,
|
|
3998
3990
|
getValue: getValue,
|
|
3999
3991
|
path: formattedPath,
|
|
@@ -4004,27 +3996,27 @@ var EditableBoxPresentation = styled__default(React.forwardRef(function (_ref13,
|
|
|
4004
3996
|
getValue: getValue,
|
|
4005
3997
|
path: formattedPath
|
|
4006
3998
|
}));
|
|
4007
|
-
}),
|
|
3999
|
+
}), React.createElement(Errors$1, {
|
|
4008
4000
|
path: formattedPath
|
|
4009
|
-
}), editing.isOpen &&
|
|
4001
|
+
}), editing.isOpen && React.createElement("div", {
|
|
4010
4002
|
className: "editable-box-footer"
|
|
4011
|
-
},
|
|
4003
|
+
}, React.createElement("div", null, withDelete && React.createElement(Button, {
|
|
4012
4004
|
icon: "remove",
|
|
4013
4005
|
hover: "alert",
|
|
4014
4006
|
tabIndex: tabIndex + 2,
|
|
4015
4007
|
onClick: handleDelete
|
|
4016
|
-
}, "Deletar")),
|
|
4008
|
+
}, "Deletar")), React.createElement(StartlibsConsumer, null, function (_ref14) {
|
|
4017
4009
|
var labels = _ref14.labels;
|
|
4018
|
-
return
|
|
4010
|
+
return React.createElement("div", null, React.createElement(Button, {
|
|
4019
4011
|
tabIndex: tabIndex + 1,
|
|
4020
4012
|
onClick: handleCancel
|
|
4021
|
-
}, labels.EditableBox.cancel),
|
|
4013
|
+
}, labels.EditableBox.cancel), React.createElement(Button, {
|
|
4022
4014
|
buttonRef: submitRef,
|
|
4023
4015
|
isLoading: loading.isOpen,
|
|
4024
4016
|
highlight: true,
|
|
4025
4017
|
tabIndex: tabIndex,
|
|
4026
4018
|
type: "submit"
|
|
4027
|
-
},
|
|
4019
|
+
}, callIfFunction(saveLabel, isNew) || (isNew ? labels.EditableBox.saveNew : labels.EditableBox.save)));
|
|
4028
4020
|
}))), children));
|
|
4029
4021
|
})).withConfig({
|
|
4030
4022
|
displayName: "EditableBox__EditableBoxPresentation",
|
|
@@ -4042,35 +4034,35 @@ var SharedEditableTabBox = function SharedEditableTabBox(_ref15) {
|
|
|
4042
4034
|
} : _ref15$checkIsNew,
|
|
4043
4035
|
props = _objectWithoutProperties(_ref15, ["path", "isSingle", "checkIsNew"]);
|
|
4044
4036
|
|
|
4045
|
-
var editableGroup =
|
|
4046
|
-
var form
|
|
4047
|
-
var isNew =
|
|
4048
|
-
return isSingle ? false : checkIsNew(
|
|
4037
|
+
var editableGroup = useContext(EditableContext);
|
|
4038
|
+
var form = useContext(FormContext$1);
|
|
4039
|
+
var isNew = useRefState(function () {
|
|
4040
|
+
return isSingle ? false : checkIsNew(_s.get(path, form.getOriginalValues()), form.getValue(path));
|
|
4049
4041
|
});
|
|
4050
|
-
var internalBox =
|
|
4051
|
-
var pathRef =
|
|
4042
|
+
var internalBox = React.useRef();
|
|
4043
|
+
var pathRef = useRefMemo(path);
|
|
4052
4044
|
|
|
4053
4045
|
var loading = function loading() {
|
|
4054
4046
|
return internalBox.current.loading;
|
|
4055
4047
|
};
|
|
4056
4048
|
|
|
4057
4049
|
var modifiedValue = function modifiedValue() {
|
|
4058
|
-
var oldItem = internalBox.current.getValue(undefined, form
|
|
4050
|
+
var oldItem = internalBox.current.getValue(undefined, form.getOriginalValues());
|
|
4059
4051
|
var newItem = internalBox.current.getValue();
|
|
4060
4052
|
return newItem !== oldItem ? [newItem, true] : [oldItem, false];
|
|
4061
4053
|
};
|
|
4062
4054
|
|
|
4063
|
-
var selfRef =
|
|
4055
|
+
var selfRef = useRef({
|
|
4064
4056
|
loading: loading,
|
|
4065
4057
|
path: function path() {
|
|
4066
4058
|
return pathRef.current;
|
|
4067
4059
|
},
|
|
4068
|
-
form: form
|
|
4060
|
+
form: form,
|
|
4069
4061
|
modifiedValue: modifiedValue
|
|
4070
4062
|
});
|
|
4071
4063
|
|
|
4072
4064
|
var resetField = function resetField() {
|
|
4073
|
-
return form
|
|
4065
|
+
return form.resetField([].concat(path));
|
|
4074
4066
|
};
|
|
4075
4067
|
|
|
4076
4068
|
var onClose = function onClose(skipReset) {
|
|
@@ -4078,7 +4070,7 @@ var SharedEditableTabBox = function SharedEditableTabBox(_ref15) {
|
|
|
4078
4070
|
resetField();
|
|
4079
4071
|
}
|
|
4080
4072
|
|
|
4081
|
-
form
|
|
4073
|
+
form.clearErrors(_s.toPath(path));
|
|
4082
4074
|
editableGroup.sharedBoxes.unregister(selfRef.current);
|
|
4083
4075
|
isNew.set(false);
|
|
4084
4076
|
};
|
|
@@ -4091,7 +4083,7 @@ var SharedEditableTabBox = function SharedEditableTabBox(_ref15) {
|
|
|
4091
4083
|
var errors = editableGroup.itemValidation(props, path);
|
|
4092
4084
|
|
|
4093
4085
|
if (errors) {
|
|
4094
|
-
form
|
|
4086
|
+
form.setErrors(addRootPath(form.getMeta('errorRootPath'), errors, path));
|
|
4095
4087
|
}
|
|
4096
4088
|
|
|
4097
4089
|
return errors;
|
|
@@ -4119,17 +4111,17 @@ var SharedEditableTabBox = function SharedEditableTabBox(_ref15) {
|
|
|
4119
4111
|
var transform = editableGroup.transform;
|
|
4120
4112
|
|
|
4121
4113
|
if (isNew.get()) {
|
|
4122
|
-
var arrayPath =
|
|
4114
|
+
var arrayPath = _s.toPath(path);
|
|
4123
4115
|
|
|
4124
4116
|
var index = arrayPath.slice(-1);
|
|
4125
4117
|
|
|
4126
|
-
var newProps =
|
|
4118
|
+
var newProps = _s.update(arrayPath.slice(0, -1), _s.insertAt(index, transform(newItem, path)), form.getOriginalValues());
|
|
4127
4119
|
|
|
4128
|
-
return form
|
|
4120
|
+
return form.submitForm(newProps);
|
|
4129
4121
|
} else {
|
|
4130
|
-
var _newProps =
|
|
4122
|
+
var _newProps = _s.set(path, transform(newItem, path), form.getOriginalValues());
|
|
4131
4123
|
|
|
4132
|
-
return form
|
|
4124
|
+
return form.submitForm(_newProps);
|
|
4133
4125
|
}
|
|
4134
4126
|
};
|
|
4135
4127
|
|
|
@@ -4141,19 +4133,19 @@ var SharedEditableTabBox = function SharedEditableTabBox(_ref15) {
|
|
|
4141
4133
|
});
|
|
4142
4134
|
}
|
|
4143
4135
|
|
|
4144
|
-
var original = form
|
|
4136
|
+
var original = form.getOriginalValues();
|
|
4145
4137
|
|
|
4146
|
-
var newProps =
|
|
4138
|
+
var newProps = _s.unsetOrRemoveAt(path, original);
|
|
4147
4139
|
|
|
4148
|
-
if (
|
|
4140
|
+
if (_s.get(_s.toPath(path).slice(0, -1), original).length !== _s.get(_s.toPath(path).slice(0, -1), newProps).length) {
|
|
4149
4141
|
internalBox.current.loading.open();
|
|
4150
|
-
var fetch = form
|
|
4142
|
+
var fetch = form.submitForm(newProps);
|
|
4151
4143
|
fetch.then(function (_ref16) {
|
|
4152
4144
|
var errors = _ref16.errors;
|
|
4153
4145
|
internalBox.current.loading.close();
|
|
4154
4146
|
|
|
4155
4147
|
if (!errors) {
|
|
4156
|
-
form
|
|
4148
|
+
form.setValues(_s.unsetOrRemoveAt(path));
|
|
4157
4149
|
}
|
|
4158
4150
|
}).catch(function () {
|
|
4159
4151
|
return internalBox.current.loading.close();
|
|
@@ -4172,14 +4164,14 @@ var SharedEditableTabBox = function SharedEditableTabBox(_ref15) {
|
|
|
4172
4164
|
var prevKeys = Array.isArray(path) ? path.slice(0, path.length - 1) : [];
|
|
4173
4165
|
|
|
4174
4166
|
if (isNew.get() && typeof lastKey === 'number') {
|
|
4175
|
-
form
|
|
4167
|
+
form.setValues(_s.unsetOrRemoveAt(path));
|
|
4176
4168
|
} else {
|
|
4177
|
-
form
|
|
4169
|
+
form.resetField(path);
|
|
4178
4170
|
close();
|
|
4179
4171
|
}
|
|
4180
4172
|
};
|
|
4181
4173
|
|
|
4182
|
-
return
|
|
4174
|
+
return React.createElement(EditableBoxPresentation, _extends({
|
|
4183
4175
|
ref: internalBox,
|
|
4184
4176
|
resetField: resetField,
|
|
4185
4177
|
onOpen: onOpen,
|
|
@@ -4200,12 +4192,12 @@ var EditableBox = function EditableBox(_ref17) {
|
|
|
4200
4192
|
isNew = _ref17.isNew,
|
|
4201
4193
|
props = _objectWithoutProperties(_ref17, ["path", "onCancel", "onClose", "isNew"]);
|
|
4202
4194
|
|
|
4203
|
-
var editableGroup =
|
|
4204
|
-
var form
|
|
4205
|
-
var internalBox =
|
|
4195
|
+
var editableGroup = useContext(EditableContext);
|
|
4196
|
+
var form = useContext(FormContext$1);
|
|
4197
|
+
var internalBox = React.useRef();
|
|
4206
4198
|
|
|
4207
4199
|
var resetField = function resetField() {
|
|
4208
|
-
return path ? form
|
|
4200
|
+
return path ? form.resetField([].concat(path)) : form.resetForm();
|
|
4209
4201
|
};
|
|
4210
4202
|
|
|
4211
4203
|
var _onClose = function _onClose(skipReset) {
|
|
@@ -4213,13 +4205,13 @@ var EditableBox = function EditableBox(_ref17) {
|
|
|
4213
4205
|
resetField();
|
|
4214
4206
|
}
|
|
4215
4207
|
|
|
4216
|
-
form
|
|
4208
|
+
form.clearErrors(path);
|
|
4217
4209
|
editableGroup.standaloneBoxes.unregister(selfRef.current);
|
|
4218
|
-
|
|
4210
|
+
callIfFunction(onClose);
|
|
4219
4211
|
};
|
|
4220
4212
|
|
|
4221
4213
|
var modifiedValue = function modifiedValue() {
|
|
4222
|
-
var oldItem = internalBox.current.getValue(undefined, form
|
|
4214
|
+
var oldItem = internalBox.current.getValue(undefined, form.getOriginalValues());
|
|
4223
4215
|
var newItem = internalBox.current.getValue();
|
|
4224
4216
|
return newItem !== oldItem ? [newItem, true] : [oldItem, false];
|
|
4225
4217
|
};
|
|
@@ -4233,7 +4225,7 @@ var EditableBox = function EditableBox(_ref17) {
|
|
|
4233
4225
|
};
|
|
4234
4226
|
|
|
4235
4227
|
var _onCancel = function _onCancel(close) {
|
|
4236
|
-
if (
|
|
4228
|
+
if (callIfFunction(onCancel, close) !== false) {
|
|
4237
4229
|
close();
|
|
4238
4230
|
}
|
|
4239
4231
|
};
|
|
@@ -4243,29 +4235,29 @@ var EditableBox = function EditableBox(_ref17) {
|
|
|
4243
4235
|
};
|
|
4244
4236
|
|
|
4245
4237
|
var onSave = function onSave() {
|
|
4246
|
-
return form
|
|
4238
|
+
return form.submitForm();
|
|
4247
4239
|
};
|
|
4248
4240
|
|
|
4249
4241
|
var handleSubmit = function handleSubmit() {
|
|
4250
|
-
return form
|
|
4242
|
+
return form.handleSubmit();
|
|
4251
4243
|
};
|
|
4252
4244
|
|
|
4253
4245
|
var loading = function loading() {
|
|
4254
4246
|
return internalBox.current.loading;
|
|
4255
4247
|
};
|
|
4256
4248
|
|
|
4257
|
-
var pathRef =
|
|
4258
|
-
var selfRef =
|
|
4249
|
+
var pathRef = useRefMemo(path);
|
|
4250
|
+
var selfRef = useRef({
|
|
4259
4251
|
loading: loading,
|
|
4260
4252
|
path: function path() {
|
|
4261
4253
|
return pathRef.current;
|
|
4262
4254
|
},
|
|
4263
|
-
form: form
|
|
4255
|
+
form: form,
|
|
4264
4256
|
modifiedValue: modifiedValue,
|
|
4265
4257
|
handleSubmit: handleSubmit,
|
|
4266
4258
|
close: close
|
|
4267
4259
|
});
|
|
4268
|
-
return
|
|
4260
|
+
return React.createElement(EditableBoxPresentation, _extends({
|
|
4269
4261
|
ref: internalBox,
|
|
4270
4262
|
resetField: resetField,
|
|
4271
4263
|
onOpen: onOpen,
|
|
@@ -4273,7 +4265,7 @@ var EditableBox = function EditableBox(_ref17) {
|
|
|
4273
4265
|
onDelete: onDelete,
|
|
4274
4266
|
onCancel: _onCancel,
|
|
4275
4267
|
onSave: onSave,
|
|
4276
|
-
form: form
|
|
4268
|
+
form: form,
|
|
4277
4269
|
path: path,
|
|
4278
4270
|
isNew: isNew
|
|
4279
4271
|
}, props));
|
|
@@ -4287,12 +4279,12 @@ var FormValue = function FormValue(_ref) {
|
|
|
4287
4279
|
_ref$format = _ref.format,
|
|
4288
4280
|
format = _ref$format === void 0 ? _identity : _ref$format;
|
|
4289
4281
|
|
|
4290
|
-
var _useFormValue =
|
|
4282
|
+
var _useFormValue = useFormValue$1(path, inputs || []),
|
|
4291
4283
|
_useFormValue2 = _slicedToArray(_useFormValue, 2),
|
|
4292
4284
|
value = _useFormValue2[0],
|
|
4293
4285
|
setValue = _useFormValue2[1];
|
|
4294
4286
|
|
|
4295
|
-
return
|
|
4287
|
+
return ifUndefined(callIfFunction(children, format(value), setValue), _isObject(value) ? null : value, null);
|
|
4296
4288
|
};
|
|
4297
4289
|
var IfFormValue = function IfFormValue(_ref2) {
|
|
4298
4290
|
var path = _ref2.path,
|
|
@@ -4303,7 +4295,7 @@ var IfFormValue = function IfFormValue(_ref2) {
|
|
|
4303
4295
|
invert = _ref2.invert,
|
|
4304
4296
|
rest = _objectWithoutProperties(_ref2, ["path", "children", "inputs", "check", "invert"]);
|
|
4305
4297
|
|
|
4306
|
-
var _useFormValue3 =
|
|
4298
|
+
var _useFormValue3 = useFormValue$1(path, inputs || []),
|
|
4307
4299
|
_useFormValue4 = _slicedToArray(_useFormValue3, 2),
|
|
4308
4300
|
value = _useFormValue4[0],
|
|
4309
4301
|
setValue = _useFormValue4[1];
|
|
@@ -4312,23 +4304,23 @@ var IfFormValue = function IfFormValue(_ref2) {
|
|
|
4312
4304
|
return invert ? !v : !!v;
|
|
4313
4305
|
};
|
|
4314
4306
|
|
|
4315
|
-
return
|
|
4307
|
+
return React.createElement(TransitionDiv, rest, doInvert(callIfFunction(check, value)) ? ifUndefined(callIfFunction(children, value, setValue), _isObject(value) ? null : value, null) : null);
|
|
4316
4308
|
};
|
|
4317
4309
|
var IfFormValueUpdate = function IfFormValueUpdate(_ref3) {
|
|
4318
4310
|
var path = _ref3.path,
|
|
4319
4311
|
children = _ref3.children,
|
|
4320
4312
|
updatePath = _ref3.updatePath;
|
|
4321
4313
|
|
|
4322
|
-
var _useFormValue5 =
|
|
4314
|
+
var _useFormValue5 = useFormValue$1(path, []),
|
|
4323
4315
|
_useFormValue6 = _slicedToArray(_useFormValue5, 1),
|
|
4324
4316
|
readValue = _useFormValue6[0];
|
|
4325
4317
|
|
|
4326
|
-
var _useFormValue7 =
|
|
4318
|
+
var _useFormValue7 = useFormValue$1(updatePath, []),
|
|
4327
4319
|
_useFormValue8 = _slicedToArray(_useFormValue7, 2),
|
|
4328
4320
|
setValue = _useFormValue8[1];
|
|
4329
4321
|
|
|
4330
|
-
|
|
4331
|
-
setValue(
|
|
4322
|
+
useUpdateEffect(function () {
|
|
4323
|
+
setValue(callIfFunction(children, readValue));
|
|
4332
4324
|
}, [readValue]);
|
|
4333
4325
|
return null;
|
|
4334
4326
|
};
|
|
@@ -4344,7 +4336,7 @@ var SwitchOnFormValue = function SwitchOnFormValue(_ref4) {
|
|
|
4344
4336
|
map = _ref4$map === void 0 ? _identity : _ref4$map,
|
|
4345
4337
|
rest = _objectWithoutProperties(_ref4, ["path", "children", "inputs", "on", "off", "check", "invert", "map"]);
|
|
4346
4338
|
|
|
4347
|
-
var _useFormValue9 =
|
|
4339
|
+
var _useFormValue9 = useFormValue$1(path, inputs || []),
|
|
4348
4340
|
_useFormValue10 = _slicedToArray(_useFormValue9, 2),
|
|
4349
4341
|
value = _useFormValue10[0],
|
|
4350
4342
|
setValue = _useFormValue10[1];
|
|
@@ -4353,26 +4345,26 @@ var SwitchOnFormValue = function SwitchOnFormValue(_ref4) {
|
|
|
4353
4345
|
return invert ? !v : v;
|
|
4354
4346
|
};
|
|
4355
4347
|
|
|
4356
|
-
var isOn = check || invert ? doInvert(
|
|
4348
|
+
var isOn = check || invert ? doInvert(callIfFunction(check, value)) : value;
|
|
4357
4349
|
var mappedValue = map(value);
|
|
4358
|
-
var onKey =
|
|
4359
|
-
return
|
|
4350
|
+
var onKey = useMemo(function () {
|
|
4351
|
+
return getUID();
|
|
4360
4352
|
}, [isOn, mappedValue]);
|
|
4361
|
-
return
|
|
4353
|
+
return React.createElement(SwitchDiv, _extends({
|
|
4362
4354
|
on: onKey
|
|
4363
|
-
}, rest), isOn ? on && on[mappedValue] ?
|
|
4355
|
+
}, rest), isOn ? on && on[mappedValue] ? callIfFunction(on[mappedValue], value, setValue) : ifUndefined(callIfFunction(on, value, setValue), _isObject(value) ? null : value, null) : ifUndefined(callIfFunction(off, value, setValue), _isObject(value) ? null : value, null));
|
|
4364
4356
|
};
|
|
4365
4357
|
var FormMeta = function FormMeta(_ref5) {
|
|
4366
4358
|
var path = _ref5.path,
|
|
4367
4359
|
children = _ref5.children,
|
|
4368
4360
|
inputs = _ref5.inputs;
|
|
4369
4361
|
|
|
4370
|
-
var _useFormMeta =
|
|
4362
|
+
var _useFormMeta = useFormMeta$1(path, inputs || []),
|
|
4371
4363
|
_useFormMeta2 = _slicedToArray(_useFormMeta, 2),
|
|
4372
4364
|
value = _useFormMeta2[0],
|
|
4373
4365
|
setValue = _useFormMeta2[1];
|
|
4374
4366
|
|
|
4375
|
-
return
|
|
4367
|
+
return ifUndefined(callIfFunction(children, value, setValue), value, null);
|
|
4376
4368
|
};
|
|
4377
4369
|
var IfFormMeta = function IfFormMeta(_ref6) {
|
|
4378
4370
|
var path = _ref6.path,
|
|
@@ -4383,7 +4375,7 @@ var IfFormMeta = function IfFormMeta(_ref6) {
|
|
|
4383
4375
|
invert = _ref6.invert,
|
|
4384
4376
|
rest = _objectWithoutProperties(_ref6, ["path", "children", "inputs", "check", "invert"]);
|
|
4385
4377
|
|
|
4386
|
-
var _useFormMeta3 =
|
|
4378
|
+
var _useFormMeta3 = useFormMeta$1(path, inputs || []),
|
|
4387
4379
|
_useFormMeta4 = _slicedToArray(_useFormMeta3, 2),
|
|
4388
4380
|
value = _useFormMeta4[0],
|
|
4389
4381
|
setValue = _useFormMeta4[1];
|
|
@@ -4392,7 +4384,7 @@ var IfFormMeta = function IfFormMeta(_ref6) {
|
|
|
4392
4384
|
return invert ? !v : !!v;
|
|
4393
4385
|
};
|
|
4394
4386
|
|
|
4395
|
-
return
|
|
4387
|
+
return React.createElement(TransitionDiv, rest, doInvert(callIfFunction(check, value)) ? ifUndefined(callIfFunction(children, value, setValue), _isObject(value) ? null : value, null) : null);
|
|
4396
4388
|
};
|
|
4397
4389
|
var LazyFormValues = function LazyFormValues(_ref7) {
|
|
4398
4390
|
var value = _ref7.value,
|
|
@@ -4401,23 +4393,23 @@ var LazyFormValues = function LazyFormValues(_ref7) {
|
|
|
4401
4393
|
children = _ref7.children;
|
|
4402
4394
|
var currentValue = value.read();
|
|
4403
4395
|
|
|
4404
|
-
var _useState =
|
|
4396
|
+
var _useState = useState(false),
|
|
4405
4397
|
_useState2 = _slicedToArray(_useState, 2),
|
|
4406
4398
|
loaded = _useState2[0],
|
|
4407
4399
|
setLoaded = _useState2[1];
|
|
4408
4400
|
|
|
4409
|
-
var formUtils =
|
|
4410
|
-
|
|
4401
|
+
var formUtils = useContext(FormContext$1);
|
|
4402
|
+
useEffect(function () {
|
|
4411
4403
|
formUtils.setValues(format(currentValue), false);
|
|
4412
|
-
setLoaded(
|
|
4404
|
+
setLoaded(getUID);
|
|
4413
4405
|
return function () {
|
|
4414
4406
|
return value.refresh();
|
|
4415
4407
|
};
|
|
4416
4408
|
}, []);
|
|
4417
|
-
return
|
|
4409
|
+
return callIfFunction(children, loaded);
|
|
4418
4410
|
};
|
|
4419
4411
|
|
|
4420
|
-
var HiddenInput$1 =
|
|
4412
|
+
var HiddenInput$1 = styled.input.withConfig({
|
|
4421
4413
|
displayName: "Radiobox__HiddenInput",
|
|
4422
4414
|
componentId: "pelyer-0"
|
|
4423
4415
|
})(["opacity:0 !important;position:absolute;pointer-events:none;"]);
|
|
@@ -4433,9 +4425,9 @@ var Radiobox = function Radiobox(_ref) {
|
|
|
4433
4425
|
raw = _ref.raw,
|
|
4434
4426
|
rest = _objectWithoutProperties(_ref, ["className", "children", "disabled", "isChecked", "fieldValue", "path", "tabIndex", "raw"]);
|
|
4435
4427
|
|
|
4436
|
-
var focused =
|
|
4428
|
+
var focused = useToggle();
|
|
4437
4429
|
|
|
4438
|
-
var _useInput =
|
|
4430
|
+
var _useInput = useInput$1(_objectSpread({
|
|
4439
4431
|
fieldValue: fieldValue,
|
|
4440
4432
|
path: path,
|
|
4441
4433
|
isChecked: isChecked
|
|
@@ -4448,7 +4440,7 @@ var Radiobox = function Radiobox(_ref) {
|
|
|
4448
4440
|
hasErrors = _useInput2$.hasErrors;
|
|
4449
4441
|
|
|
4450
4442
|
var checked = isChecked ? isChecked(value) : value === fieldValue;
|
|
4451
|
-
return
|
|
4443
|
+
return React.createElement("label", {
|
|
4452
4444
|
"data-drag": "false",
|
|
4453
4445
|
onClick: function onClick(e) {
|
|
4454
4446
|
e.preventDefault();
|
|
@@ -4458,7 +4450,7 @@ var Radiobox = function Radiobox(_ref) {
|
|
|
4458
4450
|
}
|
|
4459
4451
|
},
|
|
4460
4452
|
className: className
|
|
4461
|
-
}, !
|
|
4453
|
+
}, !isTouchDevice() && React.createElement(HiddenInput$1, {
|
|
4462
4454
|
onFocus: focused.open,
|
|
4463
4455
|
onBlur: focused.close,
|
|
4464
4456
|
disabled: disabled,
|
|
@@ -4476,12 +4468,12 @@ var Radiobox = function Radiobox(_ref) {
|
|
|
4476
4468
|
}));
|
|
4477
4469
|
};
|
|
4478
4470
|
|
|
4479
|
-
var InputboxGroup =
|
|
4471
|
+
var InputboxGroup = styled(function (_ref) {
|
|
4480
4472
|
var path = _ref.path,
|
|
4481
4473
|
className = _ref.className,
|
|
4482
4474
|
column = _ref.column,
|
|
4483
4475
|
_ref$as = _ref.as,
|
|
4484
|
-
as = _ref$as === void 0 ? column ?
|
|
4476
|
+
as = _ref$as === void 0 ? column ? SplitColumnsContainer : 'div' : _ref$as,
|
|
4485
4477
|
children = _ref.children,
|
|
4486
4478
|
label = _ref.label,
|
|
4487
4479
|
descText = _ref.descText,
|
|
@@ -4490,21 +4482,21 @@ var InputboxGroup = styled__default(function (_ref) {
|
|
|
4490
4482
|
margin = _ref.margin,
|
|
4491
4483
|
rest = _objectWithoutProperties(_ref, ["path", "className", "column", "as", "children", "label", "descText", "helpText", "mandatory", "margin"]);
|
|
4492
4484
|
|
|
4493
|
-
var size =
|
|
4485
|
+
var size = React.Children.count(children);
|
|
4494
4486
|
var Wrapper = as;
|
|
4495
|
-
var boxes =
|
|
4487
|
+
var boxes = React.createElement(Wrapper, {
|
|
4496
4488
|
className: className
|
|
4497
|
-
},
|
|
4489
|
+
}, React.Children.toArray(children).filter(function (child) {
|
|
4498
4490
|
return child.props;
|
|
4499
4491
|
}).map(function (child, i, arr) {
|
|
4500
|
-
return
|
|
4492
|
+
return React.cloneElement(child, _objectSpread({
|
|
4501
4493
|
isFirst: i === 0,
|
|
4502
4494
|
isLast: i === arr.length - 1,
|
|
4503
4495
|
index: i,
|
|
4504
4496
|
path: path
|
|
4505
4497
|
}, rest, child.props));
|
|
4506
4498
|
}));
|
|
4507
|
-
return label ?
|
|
4499
|
+
return label ? React.createElement(Field, {
|
|
4508
4500
|
label: label,
|
|
4509
4501
|
mandatory: mandatory,
|
|
4510
4502
|
descText: descText,
|
|
@@ -4519,10 +4511,10 @@ var InputboxGroup = styled__default(function (_ref) {
|
|
|
4519
4511
|
}, function (props) {
|
|
4520
4512
|
return props.unevenlyWide && "\n width: 100%;\n display: flex;\n label {\n flex-grow: 1;\n }\n ";
|
|
4521
4513
|
}, function (props) {
|
|
4522
|
-
return props.horizontal ? "\n @supports (flex-wrap: wrap) {\n display: flex;\n flex-wrap: wrap;\n }\n min-height: 3rem;\n ".concat(
|
|
4514
|
+
return props.horizontal ? "\n @supports (flex-wrap: wrap) {\n display: flex;\n flex-wrap: wrap;\n }\n min-height: 3rem;\n ".concat(SimpleRadiobox$1, ", ").concat(SimpleCheckbox$1, " {\n margin-right: 1.5rem;\n margin-bottom: 0.5rem;\n }\n ") : "\n ".concat(SimpleRadiobox$1, ", ").concat(SimpleCheckbox$1, " {\n margin-bottom: 0.5rem;\n :last-child {\n margin-bottom: 1.5rem;\n }\n }\n ");
|
|
4523
4515
|
}, function (props) {
|
|
4524
|
-
return props.framedBoxes &&
|
|
4525
|
-
return props.horizontal && "\n margin: -4px;\n width: calc(100% + 8px);\n ".concat(
|
|
4516
|
+
return props.framedBoxes && css$1(["", ""], function (props) {
|
|
4517
|
+
return props.horizontal && "\n margin: -4px;\n width: calc(100% + 8px);\n ".concat(SimpleRadiobox$1, ", ").concat(SimpleCheckbox$1, " {\n margin: 4px;\n }\n ");
|
|
4526
4518
|
});
|
|
4527
4519
|
});
|
|
4528
4520
|
var RadioboxGroup = InputboxGroup;
|
|
@@ -4552,7 +4544,7 @@ CheckboxGroup.createCheckManager = function () {
|
|
|
4552
4544
|
};
|
|
4553
4545
|
|
|
4554
4546
|
var shiftSelect = function shiftSelect(availableItems, item) {
|
|
4555
|
-
var lastSelectedIndex = getIndex(lastSelected,
|
|
4547
|
+
var lastSelectedIndex = getIndex(lastSelected, callIfFunction(availableItems));
|
|
4556
4548
|
lastSelected = item;
|
|
4557
4549
|
return function () {
|
|
4558
4550
|
var currentlySelected = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
@@ -4561,7 +4553,7 @@ CheckboxGroup.createCheckManager = function () {
|
|
|
4561
4553
|
return select(item)(currentlySelected);
|
|
4562
4554
|
} else {
|
|
4563
4555
|
var removing = path.length ? _intersectionBy(path, [item], currentlySelected).length : (currentlySelected === null || currentlySelected === void 0 ? void 0 : currentlySelected.indexOf(item)) >= 0;
|
|
4564
|
-
var currentIndex = getIndex(item,
|
|
4556
|
+
var currentIndex = getIndex(item, callIfFunction(availableItems));
|
|
4565
4557
|
var firstIndex = currentIndex > lastSelectedIndex ? lastSelectedIndex : currentIndex;
|
|
4566
4558
|
var lastIndex = currentIndex > lastSelectedIndex ? currentIndex + 1 : lastSelectedIndex + 1;
|
|
4567
4559
|
|
|
@@ -4603,68 +4595,68 @@ var CALENDAR_LEVEL_DAY = 'day';
|
|
|
4603
4595
|
var CALENDAR_LEVEL_MONTH = 'month';
|
|
4604
4596
|
var CALENDAR_LEVEL_YEAR = 'year';
|
|
4605
4597
|
var LEVELS = [CALENDAR_LEVEL_DAY, CALENDAR_LEVEL_MONTH, CALENDAR_LEVEL_YEAR];
|
|
4606
|
-
var DatePickerContainer =
|
|
4598
|
+
var DatePickerContainer = styled.div.withConfig({
|
|
4607
4599
|
displayName: "DatePicker__DatePickerContainer",
|
|
4608
4600
|
componentId: "sc-1wo8j4d-0"
|
|
4609
|
-
})(["width:20rem;position:absolute;z-index:100;background-color:white;border-radius:5px;border:1px solid ", ";user-select:none;box-shadow:0 0 4px 0 rgba(0,0,0,0.2);font-size:13px;text-align:center;animation:0.2s datePickerFadeInDown ease-out;display:none;@supports (flex-wrap:wrap){display:block;}input{padding-right:2.25rem;", "}@keyframes datePickerFadeInDown{from{opacity:0;transform:translateY(-10px);pointer-events:none;}to{opacity:1;transform:none;pointer-events:none;}}"],
|
|
4610
|
-
var CalendarHeader =
|
|
4601
|
+
})(["width:20rem;position:absolute;z-index:100;background-color:white;border-radius:5px;border:1px solid ", ";user-select:none;box-shadow:0 0 4px 0 rgba(0,0,0,0.2);font-size:13px;text-align:center;animation:0.2s datePickerFadeInDown ease-out;display:none;@supports (flex-wrap:wrap){display:block;}input{padding-right:2.25rem;", "}@keyframes datePickerFadeInDown{from{opacity:0;transform:translateY(-10px);pointer-events:none;}to{opacity:1;transform:none;pointer-events:none;}}"], getColor('gray210'), media.mobile(_templateObject$4()));
|
|
4602
|
+
var CalendarHeader = styled.div.withConfig({
|
|
4611
4603
|
displayName: "DatePicker__CalendarHeader",
|
|
4612
4604
|
componentId: "sc-1wo8j4d-1"
|
|
4613
4605
|
})(["display:flex;padding:0.5rem;align-items:center;"]);
|
|
4614
|
-
var CalendarContentContainer =
|
|
4606
|
+
var CalendarContentContainer = styled.div.withConfig({
|
|
4615
4607
|
displayName: "DatePicker__CalendarContentContainer",
|
|
4616
4608
|
componentId: "sc-1wo8j4d-2"
|
|
4617
4609
|
})(["padding:0 0.5rem 0.5rem 0.5rem;display:flex;flex-wrap:wrap;justify-content:space-around;"]);
|
|
4618
|
-
var WeekHeader =
|
|
4610
|
+
var WeekHeader = styled(CalendarContentContainer).withConfig({
|
|
4619
4611
|
displayName: "DatePicker__WeekHeader",
|
|
4620
4612
|
componentId: "sc-1wo8j4d-3"
|
|
4621
4613
|
})(["font-size:12px;font-weight:600;cursor:default;span{width:2.5rem;}"]);
|
|
4622
|
-
var CalendarClickable =
|
|
4614
|
+
var CalendarClickable = styled.a.withConfig({
|
|
4623
4615
|
displayName: "DatePicker__CalendarClickable",
|
|
4624
4616
|
componentId: "sc-1wo8j4d-4"
|
|
4625
4617
|
})([":hover,:focus{background-color:rgba(0,0,0,0.1);cursor:pointer;}"]);
|
|
4626
|
-
var TitleButton =
|
|
4618
|
+
var TitleButton = styled(CalendarClickable).withConfig({
|
|
4627
4619
|
displayName: "DatePicker__TitleButton",
|
|
4628
4620
|
componentId: "sc-1wo8j4d-5"
|
|
4629
4621
|
})(["font-size:16px;font-weight:600;flex-grow:1;border-radius:4px;line-height:3rem;"]);
|
|
4630
|
-
var NavigationButton =
|
|
4622
|
+
var NavigationButton = styled(CalendarClickable).withConfig({
|
|
4631
4623
|
displayName: "DatePicker__NavigationButton",
|
|
4632
4624
|
componentId: "sc-1wo8j4d-6"
|
|
4633
|
-
})(["font-size:21px;width:3rem;text-align:center;border-radius:4px;height:3rem;", "{line-height:3rem;}"],
|
|
4634
|
-
var CalendarContent =
|
|
4625
|
+
})(["font-size:21px;width:3rem;text-align:center;border-radius:4px;height:3rem;", "{line-height:3rem;}"], Icon);
|
|
4626
|
+
var CalendarContent = styled(CalendarClickable).withConfig({
|
|
4635
4627
|
displayName: "DatePicker__CalendarContent",
|
|
4636
4628
|
componentId: "sc-1wo8j4d-7"
|
|
4637
|
-
})(["line-height:2.25rem;flex-grow:1;display:inline-block;border-radius:5px;margin-top:0.25rem;margin-left:0.25rem;", " ", " ", " ", " "],
|
|
4638
|
-
return
|
|
4639
|
-
},
|
|
4640
|
-
var DayItem =
|
|
4629
|
+
})(["line-height:2.25rem;flex-grow:1;display:inline-block;border-radius:5px;margin-top:0.25rem;margin-left:0.25rem;", " ", " ", " ", " "], ifProp('isEdge', css$1(["color:rgba(0,0,0,0.4);"])), ifProp('isSelected', css$1(["box-shadow:inset 0 0 0 1px ", ";"], getColor('gray210'))), ifProp('isDisabled', "pointer-events: none;\n opacity: 0.5;"), ifProp('isCurrent', css$1(["background:", ";color:#FFF;:hover{background-color:", ";}", ""], getColor('main'), function (props) {
|
|
4630
|
+
return darken(0.075, getColor('main')(props));
|
|
4631
|
+
}, ifProp('isSelected', 'box-shadow: none;'))));
|
|
4632
|
+
var DayItem = styled(CalendarContent).withConfig({
|
|
4641
4633
|
displayName: "DatePicker__DayItem",
|
|
4642
4634
|
componentId: "sc-1wo8j4d-8"
|
|
4643
4635
|
})(["", " flex-basis:12%;"], function (props) {
|
|
4644
4636
|
return props.index % 7 === 0 && 'margin-left:0;';
|
|
4645
4637
|
});
|
|
4646
|
-
var MonthItem =
|
|
4638
|
+
var MonthItem = styled(CalendarContent).withConfig({
|
|
4647
4639
|
displayName: "DatePicker__MonthItem",
|
|
4648
4640
|
componentId: "sc-1wo8j4d-9"
|
|
4649
4641
|
})(["", " flex-basis:30%;"], function (props) {
|
|
4650
4642
|
return props.index % 3 === 0 && 'margin-left:0;';
|
|
4651
4643
|
});
|
|
4652
|
-
var YearItem =
|
|
4644
|
+
var YearItem = styled(CalendarContent).withConfig({
|
|
4653
4645
|
displayName: "DatePicker__YearItem",
|
|
4654
4646
|
componentId: "sc-1wo8j4d-10"
|
|
4655
4647
|
})(["", " flex-basis:30%;"], function (props) {
|
|
4656
4648
|
return props.index % 3 === 0 && 'margin-left:0;';
|
|
4657
4649
|
});
|
|
4658
|
-
var DatePickerInputIcon =
|
|
4650
|
+
var DatePickerInputIcon = styled(Icon).withConfig({
|
|
4659
4651
|
displayName: "DatePicker__DatePickerInputIcon",
|
|
4660
4652
|
componentId: "sc-1wo8j4d-11"
|
|
4661
|
-
})(["position:absolute;outline:none;bottom:0;font-size:21px;line-height:3rem;right:0;width:2rem;cursor:pointer;color:", ";:hover{color:", ";}display:none;@supports (flex-wrap:wrap){display:block;}", " ", ""],
|
|
4653
|
+
})(["position:absolute;outline:none;bottom:0;font-size:21px;line-height:3rem;right:0;width:2rem;cursor:pointer;color:", ";:hover{color:", ";}display:none;@supports (flex-wrap:wrap){display:block;}", " ", ""], getColor('gray150'), getColor('main'), function (props) {
|
|
4662
4654
|
return props.disabled && 'pointer-events: none;';
|
|
4663
|
-
},
|
|
4664
|
-
var ClearButton =
|
|
4655
|
+
}, media.mobile(_templateObject2$3()));
|
|
4656
|
+
var ClearButton = styled(Icon).withConfig({
|
|
4665
4657
|
displayName: "DatePicker__ClearButton",
|
|
4666
4658
|
componentId: "sc-1wo8j4d-12"
|
|
4667
|
-
})(["color:", ";font-size:12px;position:absolute;right:40px;bottom:0;transform:translateY(-50%);cursor:pointer;width:1.5rem;line-height:1.5rem;text-align:center;border-radius:50%;background:rgba(0,0,0,0.1);:hover{background:#f7d3d4;color:", ";}"],
|
|
4659
|
+
})(["color:", ";font-size:12px;position:absolute;right:40px;bottom:0;transform:translateY(-50%);cursor:pointer;width:1.5rem;line-height:1.5rem;text-align:center;border-radius:50%;background:rgba(0,0,0,0.1);:hover{background:#f7d3d4;color:", ";}"], getColor('gray90'), getColor('alert'));
|
|
4668
4660
|
|
|
4669
4661
|
var KeyMapper = function KeyMapper(level) {
|
|
4670
4662
|
var upDownSpacing = level === CALENDAR_LEVEL_DAY ? 7 : 3;
|
|
@@ -4696,7 +4688,7 @@ var getUTCDateBefore = function getUTCDateBefore(year) {
|
|
|
4696
4688
|
return new Date(Date.UTC(year, month, date, hour, min, sec, ms));
|
|
4697
4689
|
};
|
|
4698
4690
|
|
|
4699
|
-
var DatePicker =
|
|
4691
|
+
var DatePicker = forwardRef(function (_ref, maybeInputRef) {
|
|
4700
4692
|
var _ref$format = _ref.format,
|
|
4701
4693
|
format = _ref$format === void 0 ? 'dd/MM/yyyy' : _ref$format,
|
|
4702
4694
|
_ref$min = _ref.min,
|
|
@@ -4719,9 +4711,9 @@ var DatePicker = React.forwardRef(function (_ref, maybeInputRef) {
|
|
|
4719
4711
|
level = _ref.level,
|
|
4720
4712
|
rest = _objectWithoutProperties(_ref, ["format", "min", "max", "weekStartsMonday", "label", "mandatory", "tabIndex", "helpText", "path", "timezoneOffset", "placeholder", "onBlur", "raw", "disabled", "level"]);
|
|
4721
4713
|
|
|
4722
|
-
var inputRef =
|
|
4714
|
+
var inputRef = useEnsureRef(maybeInputRef);
|
|
4723
4715
|
|
|
4724
|
-
var _useInput =
|
|
4716
|
+
var _useInput = useInput$1(_objectSpread({
|
|
4725
4717
|
path: path
|
|
4726
4718
|
}, rest), raw),
|
|
4727
4719
|
_useInput2 = _slicedToArray(_useInput, 3),
|
|
@@ -4733,25 +4725,25 @@ var DatePicker = React.forwardRef(function (_ref, maybeInputRef) {
|
|
|
4733
4725
|
return setUnoffsetedFormValue(_isFinite(newV) && newV !== -1 ? newV - timezoneOffset * 36e5 : newV);
|
|
4734
4726
|
};
|
|
4735
4727
|
|
|
4736
|
-
var popup =
|
|
4737
|
-
var calendarElement =
|
|
4738
|
-
var messages =
|
|
4728
|
+
var popup = usePopupToggle();
|
|
4729
|
+
var calendarElement = useRef();
|
|
4730
|
+
var messages = useContext(StartlibsContext).dateMessages;
|
|
4739
4731
|
var time = Number(formValue);
|
|
4740
4732
|
var offsetedTime = time + timezoneOffset * 36e5;
|
|
4741
4733
|
|
|
4742
|
-
var _useState =
|
|
4734
|
+
var _useState = useState(!isNaN(time) ? formatDate(new Date(offsetedTime), format, messages) : ''),
|
|
4743
4735
|
_useState2 = _slicedToArray(_useState, 2),
|
|
4744
4736
|
textValue = _useState2[0],
|
|
4745
4737
|
setRawTextValue = _useState2[1];
|
|
4746
4738
|
|
|
4747
|
-
var prevValue =
|
|
4739
|
+
var prevValue = usePrevious(textValue);
|
|
4748
4740
|
|
|
4749
|
-
var _useState3 =
|
|
4741
|
+
var _useState3 = useState(false),
|
|
4750
4742
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
4751
4743
|
hasFormatErrors = _useState4[0],
|
|
4752
4744
|
setHasFormatErrors = _useState4[1];
|
|
4753
4745
|
|
|
4754
|
-
|
|
4746
|
+
useEffect(function () {
|
|
4755
4747
|
if (textValue && prevValue && textValue.length > prevValue.length + 1) {
|
|
4756
4748
|
setTimeout(function () {
|
|
4757
4749
|
return inputRef.current.setSelectionRange(inputRef.current.value.length + 1, inputRef.current.value.length + 1);
|
|
@@ -4761,15 +4753,15 @@ var DatePicker = React.forwardRef(function (_ref, maybeInputRef) {
|
|
|
4761
4753
|
|
|
4762
4754
|
var setTextValue = function setTextValue(textValue) {
|
|
4763
4755
|
var value = formValue === -1 || isNaN(formValue) ? now() : new Date(Number(formValue));
|
|
4764
|
-
var date =
|
|
4756
|
+
var date = parseDate(textValue, value, format, messages);
|
|
4765
4757
|
|
|
4766
4758
|
if (isNaN(date.getTime())) {
|
|
4767
4759
|
var nextMonth = new Date(value);
|
|
4768
4760
|
var closestLeapYear = new Date(value);
|
|
4769
4761
|
nextMonth.setUTCMonth(value.getUTCMonth() + 1);
|
|
4770
4762
|
closestLeapYear.setUTCFullYear(getClosestNextLeapYear(value.getUTCFullYear()));
|
|
4771
|
-
var nextMonthDate =
|
|
4772
|
-
var closestLeapYearDate =
|
|
4763
|
+
var nextMonthDate = parseDate(textValue, nextMonth, format, messages);
|
|
4764
|
+
var closestLeapYearDate = parseDate(textValue, closestLeapYear, format, messages);
|
|
4773
4765
|
setRawTextValue(textValue);
|
|
4774
4766
|
setHasFormatErrors(isNaN(nextMonthDate.getTime()) && isNaN(closestLeapYearDate));
|
|
4775
4767
|
} else if (!inRange({
|
|
@@ -4787,7 +4779,7 @@ var DatePicker = React.forwardRef(function (_ref, maybeInputRef) {
|
|
|
4787
4779
|
};
|
|
4788
4780
|
|
|
4789
4781
|
var updateText = function updateText(date) {
|
|
4790
|
-
setTextValue(
|
|
4782
|
+
setTextValue(formatDate(date, format, messages));
|
|
4791
4783
|
setHasFormatErrors(false);
|
|
4792
4784
|
};
|
|
4793
4785
|
|
|
@@ -4803,7 +4795,7 @@ var DatePicker = React.forwardRef(function (_ref, maybeInputRef) {
|
|
|
4803
4795
|
setFormValue(undefined);
|
|
4804
4796
|
setHasFormatErrors(false);
|
|
4805
4797
|
} else {
|
|
4806
|
-
var date =
|
|
4798
|
+
var date = parseDate(textValue, new Date(formValue), format, messages, true);
|
|
4807
4799
|
|
|
4808
4800
|
if (isNaN(date.getTime())) {
|
|
4809
4801
|
setHasFormatErrors(true);
|
|
@@ -4821,7 +4813,7 @@ var DatePicker = React.forwardRef(function (_ref, maybeInputRef) {
|
|
|
4821
4813
|
confirmValue();
|
|
4822
4814
|
}
|
|
4823
4815
|
|
|
4824
|
-
|
|
4816
|
+
callIfFunction(onBlur);
|
|
4825
4817
|
}, 1);
|
|
4826
4818
|
};
|
|
4827
4819
|
|
|
@@ -4871,32 +4863,32 @@ var DatePicker = React.forwardRef(function (_ref, maybeInputRef) {
|
|
|
4871
4863
|
|
|
4872
4864
|
var calendarValue = new Date(!isNaN(time) && formValue !== -1 ? offsetedTime : nowTimeZoneAdjusted(timezoneOffset));
|
|
4873
4865
|
calendarValue.setUTCHours(0, 0, 0);
|
|
4874
|
-
return
|
|
4866
|
+
return React.createElement(Field$1, {
|
|
4875
4867
|
helpText: helpText,
|
|
4876
4868
|
label: label,
|
|
4877
4869
|
mandatory: mandatory,
|
|
4878
4870
|
onClick: onClick,
|
|
4879
4871
|
onFocus: popup.open,
|
|
4880
4872
|
onBlur: _onBlur
|
|
4881
|
-
},
|
|
4873
|
+
}, React.createElement(TextInput$1, {
|
|
4882
4874
|
raw: true,
|
|
4883
4875
|
disabled: disabled,
|
|
4884
|
-
type:
|
|
4876
|
+
type: getNumberInputType(),
|
|
4885
4877
|
tabIndex: tabIndex,
|
|
4886
4878
|
ref: inputRef,
|
|
4887
|
-
constraint:
|
|
4879
|
+
constraint: formatDateToPattern(format),
|
|
4888
4880
|
value: textValue,
|
|
4889
4881
|
setValue: setTextValue,
|
|
4890
4882
|
placeholder: placeholder,
|
|
4891
4883
|
hasErrors: hasErrors || hasFormatErrors,
|
|
4892
4884
|
onKeyDown: onKeyDown
|
|
4893
|
-
}),
|
|
4885
|
+
}), React.createElement(DatePickerInputIcon, {
|
|
4894
4886
|
tabIndex: -1,
|
|
4895
4887
|
onFocus: stopFocusPropagation,
|
|
4896
4888
|
disabled: disabled,
|
|
4897
4889
|
onClick: iconClick,
|
|
4898
4890
|
icon: "calendar"
|
|
4899
|
-
}), popup.isOpen &&
|
|
4891
|
+
}), popup.isOpen && React.createElement(DatePickerCalendar, {
|
|
4900
4892
|
raw: true,
|
|
4901
4893
|
min: min,
|
|
4902
4894
|
max: max,
|
|
@@ -4998,21 +4990,21 @@ function (_React$Component) {
|
|
|
4998
4990
|
_this.getView = function () {
|
|
4999
4991
|
switch (_this.state.level) {
|
|
5000
4992
|
case CALENDAR_LEVEL_DAY:
|
|
5001
|
-
return
|
|
4993
|
+
return React.createElement(Calendar, _extends({}, _this.props, _this.state, {
|
|
5002
4994
|
handleChange: _this.handleChange,
|
|
5003
4995
|
changeCurrentDate: _this.setCurrentDatePlus,
|
|
5004
4996
|
up: _this.up
|
|
5005
4997
|
}));
|
|
5006
4998
|
|
|
5007
4999
|
case CALENDAR_LEVEL_MONTH:
|
|
5008
|
-
return
|
|
5000
|
+
return React.createElement(Months, _extends({}, _this.props, _this.state, {
|
|
5009
5001
|
handleChange: _this.handleChange,
|
|
5010
5002
|
changeCurrentDate: _this.setCurrentDatePlus,
|
|
5011
5003
|
up: _this.up
|
|
5012
5004
|
}));
|
|
5013
5005
|
|
|
5014
5006
|
case CALENDAR_LEVEL_YEAR:
|
|
5015
|
-
return
|
|
5007
|
+
return React.createElement(Years, _extends({}, _this.props, _this.state, {
|
|
5016
5008
|
handleChange: _this.handleChange,
|
|
5017
5009
|
changeCurrentDate: _this.setCurrentDatePlus
|
|
5018
5010
|
}));
|
|
@@ -5045,7 +5037,7 @@ function (_React$Component) {
|
|
|
5045
5037
|
}, {
|
|
5046
5038
|
key: "render",
|
|
5047
5039
|
value: function render() {
|
|
5048
|
-
return
|
|
5040
|
+
return React.createElement("div", {
|
|
5049
5041
|
ref: this.setRef,
|
|
5050
5042
|
tabIndex: -1,
|
|
5051
5043
|
onFocus: this.props.refocus,
|
|
@@ -5055,10 +5047,10 @@ function (_React$Component) {
|
|
|
5055
5047
|
}]);
|
|
5056
5048
|
|
|
5057
5049
|
return RawDatePickerCalendar;
|
|
5058
|
-
}(
|
|
5050
|
+
}(React.Component);
|
|
5059
5051
|
|
|
5060
5052
|
RawDatePickerCalendar.defaultProps = defaultProps;
|
|
5061
|
-
var DatePickerCalendar =
|
|
5053
|
+
var DatePickerCalendar = enhanceInput$1(RawDatePickerCalendar);
|
|
5062
5054
|
|
|
5063
5055
|
function now() {
|
|
5064
5056
|
var dt = new Date();
|
|
@@ -5122,30 +5114,30 @@ var Calendar = function Calendar(_ref2) {
|
|
|
5122
5114
|
|
|
5123
5115
|
var previousMonth = getUTCDateBefore(currentDate.getUTCFullYear(), currentDate.getUTCMonth());
|
|
5124
5116
|
var nextMonth = getUTCDate(currentDate.getUTCFullYear(), currentDate.getUTCMonth() + 1);
|
|
5125
|
-
return
|
|
5117
|
+
return React.createElement(DatePickerContainer, null, React.createElement(CalendarHeader, null, React.createElement(NavigationButton, {
|
|
5126
5118
|
disabled: !inRange({
|
|
5127
5119
|
min: min,
|
|
5128
5120
|
max: max
|
|
5129
5121
|
}, previousMonth),
|
|
5130
5122
|
onClick: changeCurrentDate(-1, CALENDAR_LEVEL_MONTH)
|
|
5131
|
-
},
|
|
5123
|
+
}, React.createElement(Icon, {
|
|
5132
5124
|
icon: "arrow-left-line"
|
|
5133
|
-
})),
|
|
5125
|
+
})), React.createElement(TitleButton, {
|
|
5134
5126
|
onClick: up
|
|
5135
|
-
}, messages('month', currentMonth), " ", currentDate.getUTCFullYear()),
|
|
5127
|
+
}, messages('month', currentMonth), " ", currentDate.getUTCFullYear()), React.createElement(NavigationButton, {
|
|
5136
5128
|
disabled: !inRange({
|
|
5137
5129
|
min: min,
|
|
5138
5130
|
max: max
|
|
5139
5131
|
}, nextMonth),
|
|
5140
5132
|
onClick: changeCurrentDate(1, CALENDAR_LEVEL_MONTH)
|
|
5141
|
-
},
|
|
5133
|
+
}, React.createElement(Icon, {
|
|
5142
5134
|
icon: "arrow-right-line"
|
|
5143
|
-
}))),
|
|
5144
|
-
return
|
|
5135
|
+
}))), React.createElement(WeekHeader, null, [0, 1, 2, 3, 4, 5, 6].map(function (day) {
|
|
5136
|
+
return React.createElement("span", {
|
|
5145
5137
|
key: day
|
|
5146
5138
|
}, messages('day', (day + dayOffset) % 7).slice(0, 3));
|
|
5147
|
-
})),
|
|
5148
|
-
return
|
|
5139
|
+
})), React.createElement(CalendarContentContainer, null, mapDays(currentDate, dayOffset, function (date, day, index) {
|
|
5140
|
+
return React.createElement(DayItem, {
|
|
5149
5141
|
index: index,
|
|
5150
5142
|
key: date.getTime(),
|
|
5151
5143
|
onClick: handleDateChange,
|
|
@@ -5180,26 +5172,26 @@ var Months = function Months(_ref3) {
|
|
|
5180
5172
|
handleChange(new Date(date.setUTCMonth(e.currentTarget.getAttribute('data-month'))));
|
|
5181
5173
|
};
|
|
5182
5174
|
|
|
5183
|
-
return
|
|
5175
|
+
return React.createElement(DatePickerContainer, null, React.createElement(CalendarHeader, null, React.createElement(NavigationButton, {
|
|
5184
5176
|
disabled: !inRange({
|
|
5185
5177
|
min: min,
|
|
5186
5178
|
max: max
|
|
5187
5179
|
}, getUTCDateBefore(currentDate.getUTCFullYear())),
|
|
5188
5180
|
onClick: changeCurrentDate(-1, CALENDAR_LEVEL_YEAR)
|
|
5189
|
-
},
|
|
5181
|
+
}, React.createElement(Icon, {
|
|
5190
5182
|
icon: "arrow-left-line"
|
|
5191
|
-
})),
|
|
5183
|
+
})), React.createElement(TitleButton, {
|
|
5192
5184
|
onClick: up
|
|
5193
|
-
}, currentDate.getUTCFullYear()),
|
|
5185
|
+
}, currentDate.getUTCFullYear()), React.createElement(NavigationButton, {
|
|
5194
5186
|
disabled: !inRange({
|
|
5195
5187
|
min: min,
|
|
5196
5188
|
max: max
|
|
5197
5189
|
}, getUTCDate(currentDate.getUTCFullYear() + 1)),
|
|
5198
5190
|
onClick: changeCurrentDate(1, CALENDAR_LEVEL_YEAR)
|
|
5199
|
-
},
|
|
5191
|
+
}, React.createElement(Icon, {
|
|
5200
5192
|
icon: "arrow-right-line"
|
|
5201
|
-
}))),
|
|
5202
|
-
return
|
|
5193
|
+
}))), React.createElement(CalendarContentContainer, null, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11].map(function (month) {
|
|
5194
|
+
return React.createElement(MonthItem, {
|
|
5203
5195
|
disabled: !inRange({
|
|
5204
5196
|
min: min,
|
|
5205
5197
|
max: max
|
|
@@ -5245,24 +5237,24 @@ var Years = function Years(_ref4) {
|
|
|
5245
5237
|
handleChange(new Date(date.setUTCFullYear(e.currentTarget.getAttribute('data-year'))));
|
|
5246
5238
|
};
|
|
5247
5239
|
|
|
5248
|
-
return
|
|
5240
|
+
return React.createElement(DatePickerContainer, null, React.createElement(CalendarHeader, null, React.createElement(NavigationButton, {
|
|
5249
5241
|
disabled: !inRange({
|
|
5250
5242
|
min: min,
|
|
5251
5243
|
max: max
|
|
5252
5244
|
}, getUTCDateBefore(currentDate.getUTCFullYear())),
|
|
5253
5245
|
onClick: changeCurrentDate(-10, CALENDAR_LEVEL_YEAR)
|
|
5254
|
-
},
|
|
5246
|
+
}, React.createElement(Icon, {
|
|
5255
5247
|
icon: "arrow-left-line"
|
|
5256
|
-
})),
|
|
5248
|
+
})), React.createElement(TitleButton, null, currentYear - currentYear % 10, "-", currentYear - currentYear % 10 + 9), React.createElement(NavigationButton, {
|
|
5257
5249
|
disabled: !inRange({
|
|
5258
5250
|
min: min,
|
|
5259
5251
|
max: max
|
|
5260
5252
|
}, getUTCDate(currentDate.getUTCFullYear() + 10)),
|
|
5261
5253
|
onClick: changeCurrentDate(10, CALENDAR_LEVEL_YEAR)
|
|
5262
|
-
},
|
|
5254
|
+
}, React.createElement(Icon, {
|
|
5263
5255
|
icon: "arrow-right-line"
|
|
5264
|
-
}))),
|
|
5265
|
-
return
|
|
5256
|
+
}))), React.createElement(CalendarContentContainer, null, mapYears(currentDate, function (year, outside, i) {
|
|
5257
|
+
return React.createElement(YearItem, {
|
|
5266
5258
|
key: year,
|
|
5267
5259
|
onClick: handleYearChange,
|
|
5268
5260
|
disabled: !inRange({
|
|
@@ -5305,21 +5297,21 @@ var shouldPreventExpand = function shouldPreventExpand(e, fn) {
|
|
|
5305
5297
|
return !e.target.closest('body,[data-expand="false"],label,input,textarea,button').matches('body,[data-expand="true"]');
|
|
5306
5298
|
};
|
|
5307
5299
|
|
|
5308
|
-
var ExpandableBoxStyled =
|
|
5300
|
+
var ExpandableBoxStyled = styled.div.withConfig({
|
|
5309
5301
|
displayName: "ExpandableBox__ExpandableBoxStyled",
|
|
5310
5302
|
componentId: "sc-1nsk1wq-0"
|
|
5311
|
-
})(["padding:1rem;border-radius:6px;background:", ";font-size:14px;outline:none;transition:background 0.2s linear;position:relative;", " ", " & ~ &{margin-top:0.75rem;}", " &{margin-top:0.75rem;}"],
|
|
5303
|
+
})(["padding:1rem;border-radius:6px;background:", ";font-size:14px;outline:none;transition:background 0.2s linear;position:relative;", " ", " & ~ &{margin-top:0.75rem;}", " &{margin-top:0.75rem;}"], getColor('lightBluishGray'), function (props) {
|
|
5312
5304
|
return props.small && "\n padding: 0.875rem 1rem;\n min-height: 3rem;\n ";
|
|
5313
5305
|
}, function (props) {
|
|
5314
|
-
return props.collapsed ?
|
|
5315
|
-
return
|
|
5306
|
+
return props.collapsed ? css$1(["cursor:pointer;padding-right:3.25rem;:hover{background:", ";}:active{background:", ";transition:none;}"], function (props) {
|
|
5307
|
+
return darken(0.035, getColor('lightBluishGray')(props));
|
|
5316
5308
|
}, function (props) {
|
|
5317
|
-
return
|
|
5318
|
-
}) :
|
|
5309
|
+
return darken(0.05, getColor('lightBluishGray')(props));
|
|
5310
|
+
}) : css$1(["padding:1.5rem;", " ", ""], media.max(340)(_templateObject$5()), function (props) {
|
|
5319
5311
|
return props.fixMarginBottom && "\n padding-bottom: 0.5rem !important;\n ";
|
|
5320
5312
|
});
|
|
5321
|
-
},
|
|
5322
|
-
var EditIcon =
|
|
5313
|
+
}, SwitchDiv);
|
|
5314
|
+
var EditIcon = styled(Icon).attrs({
|
|
5323
5315
|
icon: 'edit'
|
|
5324
5316
|
}).withConfig({
|
|
5325
5317
|
displayName: "ExpandableBox__EditIcon",
|
|
@@ -5348,10 +5340,10 @@ var checkErrors = function checkErrors() {
|
|
|
5348
5340
|
return false;
|
|
5349
5341
|
};
|
|
5350
5342
|
};
|
|
5351
|
-
var timing =
|
|
5352
|
-
var switchAnimation =
|
|
5343
|
+
var timing = animationTiming('0.25s ease-out');
|
|
5344
|
+
var switchAnimation = oneWayAnimation('opacity: 1;transform:translateY(0);', 'opacity: 0;', 'opacity: 0; transform:translateY(30px);');
|
|
5353
5345
|
var hasAnyExpanded = 0;
|
|
5354
|
-
var ExpandableBox =
|
|
5346
|
+
var ExpandableBox = styled(function (_ref) {
|
|
5355
5347
|
var className = _ref.className,
|
|
5356
5348
|
children = _ref.children,
|
|
5357
5349
|
overflowEffect = _ref.overflowEffect,
|
|
@@ -5381,22 +5373,22 @@ var ExpandableBox = styled__default(function (_ref) {
|
|
|
5381
5373
|
animation = _ref$animation === void 0 ? switchAnimation : _ref$animation,
|
|
5382
5374
|
_ref$animationTiming = _ref.animationTiming,
|
|
5383
5375
|
animationTiming = _ref$animationTiming === void 0 ? timing : _ref$animationTiming;
|
|
5384
|
-
var flipAnimation =
|
|
5376
|
+
var flipAnimation = useLazyConstant(willUseFlipSwitch);
|
|
5385
5377
|
|
|
5386
|
-
var _useFormValue =
|
|
5378
|
+
var _useFormValue = useFormValue$1(path),
|
|
5387
5379
|
_useFormValue2 = _slicedToArray(_useFormValue, 3),
|
|
5388
5380
|
value = _useFormValue2[0],
|
|
5389
5381
|
setValue = _useFormValue2[1],
|
|
5390
5382
|
getValue = _useFormValue2[2];
|
|
5391
5383
|
|
|
5392
|
-
var _useTransientErrorHel =
|
|
5384
|
+
var _useTransientErrorHel = useTransientErrorHelper$1(),
|
|
5393
5385
|
_useTransientErrorHel2 = _slicedToArray(_useTransientErrorHel, 2),
|
|
5394
5386
|
_setErrors = _useTransientErrorHel2[0],
|
|
5395
5387
|
clearErrors = _useTransientErrorHel2[1];
|
|
5396
5388
|
|
|
5397
|
-
var previousValue =
|
|
5398
|
-
var isAutoOpened =
|
|
5399
|
-
var containerRef =
|
|
5389
|
+
var previousValue = useRefState();
|
|
5390
|
+
var isAutoOpened = useToggle(isOpen);
|
|
5391
|
+
var containerRef = useRef();
|
|
5400
5392
|
|
|
5401
5393
|
var setErrors = function setErrors() {
|
|
5402
5394
|
for (var _len2 = arguments.length, errors = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
@@ -5410,7 +5402,7 @@ var ExpandableBox = styled__default(function (_ref) {
|
|
|
5410
5402
|
return true;
|
|
5411
5403
|
};
|
|
5412
5404
|
|
|
5413
|
-
var expand =
|
|
5405
|
+
var expand = useToggle(isOpen, function (newV, prevV) {
|
|
5414
5406
|
if (newV === 0 || prevV === 0) {
|
|
5415
5407
|
return;
|
|
5416
5408
|
}
|
|
@@ -5426,25 +5418,25 @@ var ExpandableBox = styled__default(function (_ref) {
|
|
|
5426
5418
|
}
|
|
5427
5419
|
});
|
|
5428
5420
|
|
|
5429
|
-
var _useRecycleFocus =
|
|
5421
|
+
var _useRecycleFocus = useRecycleFocus(containerRef, recycleTab && expand.isOpen, recycleTab),
|
|
5430
5422
|
_useRecycleFocus2 = _slicedToArray(_useRecycleFocus, 2),
|
|
5431
5423
|
firstFocus = _useRecycleFocus2[0],
|
|
5432
5424
|
lastFocus = _useRecycleFocus2[1];
|
|
5433
5425
|
|
|
5434
|
-
var openWhenResult =
|
|
5435
|
-
|
|
5426
|
+
var openWhenResult = callIfFunction(openWhen);
|
|
5427
|
+
useEffect(function () {
|
|
5436
5428
|
if (openWhenResult) {
|
|
5437
5429
|
expand.open();
|
|
5438
5430
|
}
|
|
5439
5431
|
}, [openWhenResult]);
|
|
5440
|
-
|
|
5432
|
+
useEffect(function () {
|
|
5441
5433
|
return function () {
|
|
5442
5434
|
if (expand.get() === 0) {
|
|
5443
5435
|
expand.close();
|
|
5444
5436
|
}
|
|
5445
5437
|
};
|
|
5446
5438
|
}, [expand.isOpen]);
|
|
5447
|
-
|
|
5439
|
+
useEffect(function () {
|
|
5448
5440
|
if (expand.get() && !isAutoOpened.get()) {
|
|
5449
5441
|
previousValue.set(getValue());
|
|
5450
5442
|
hasAnyExpanded += 1;
|
|
@@ -5459,9 +5451,9 @@ var ExpandableBox = styled__default(function (_ref) {
|
|
|
5459
5451
|
expand.close();
|
|
5460
5452
|
};
|
|
5461
5453
|
|
|
5462
|
-
var utils
|
|
5454
|
+
var utils = useLazyConstant(function () {
|
|
5463
5455
|
return {
|
|
5464
|
-
close:
|
|
5456
|
+
close: constrainEvent(expand.close),
|
|
5465
5457
|
setValue: setValue,
|
|
5466
5458
|
cancel: cancel
|
|
5467
5459
|
};
|
|
@@ -5469,7 +5461,7 @@ var ExpandableBox = styled__default(function (_ref) {
|
|
|
5469
5461
|
|
|
5470
5462
|
var onBlur = function onBlur(e) {
|
|
5471
5463
|
if (e.currentTarget !== e.relatedTarget && (!e.relatedTarget || !e.currentTarget.contains(e.relatedTarget))) {
|
|
5472
|
-
var retarget =
|
|
5464
|
+
var retarget = callIfFunction(retargetFilter, e.relatedTarget);
|
|
5473
5465
|
|
|
5474
5466
|
if (retarget === true) {
|
|
5475
5467
|
e.target.focus();
|
|
@@ -5492,10 +5484,10 @@ var ExpandableBox = styled__default(function (_ref) {
|
|
|
5492
5484
|
};
|
|
5493
5485
|
|
|
5494
5486
|
var onClick = function onClick(e) {
|
|
5495
|
-
return !shouldPreventExpand(e) &&
|
|
5487
|
+
return !shouldPreventExpand(e) && callIfFunction(canExpand, e) && !hasAnyExpanded && expand.open();
|
|
5496
5488
|
};
|
|
5497
5489
|
|
|
5498
|
-
return
|
|
5490
|
+
return React.createElement(ExpandableBoxStyled, {
|
|
5499
5491
|
className: className + (expand.isOpen && (enterConfirms || escCancels) ? " JS-dialog-skip-evts" : ""),
|
|
5500
5492
|
ref: containerRef,
|
|
5501
5493
|
tabIndex: -1,
|
|
@@ -5505,13 +5497,13 @@ var ExpandableBox = styled__default(function (_ref) {
|
|
|
5505
5497
|
fixMarginBottom: fixMarginBottom,
|
|
5506
5498
|
onClick: onClick,
|
|
5507
5499
|
onKeyDown: checkEscEnter
|
|
5508
|
-
}, expand.isOpen && firstFocus,
|
|
5500
|
+
}, expand.isOpen && firstFocus, React.createElement(FlipDiv$1, {
|
|
5509
5501
|
key: expand.isOpen,
|
|
5510
5502
|
overflowEffect: overflowEffect,
|
|
5511
5503
|
useAnimation: flipAnimation,
|
|
5512
5504
|
animation: animation,
|
|
5513
5505
|
animationTiming: animationTiming
|
|
5514
|
-
}, expand.isOpen ?
|
|
5506
|
+
}, expand.isOpen ? callIfFunction(children, value, utils) : React.createElement(React.Fragment, null, callIfFunction(info, value, utils), withIcon && React.createElement(EditIcon, null))), expand.isOpen && lastFocus);
|
|
5515
5507
|
}).withConfig({
|
|
5516
5508
|
displayName: "ExpandableBox",
|
|
5517
5509
|
componentId: "sc-1nsk1wq-2"
|
|
@@ -5521,13 +5513,13 @@ var PseudoExpandableBox = function PseudoExpandableBox(_ref2) {
|
|
|
5521
5513
|
var children = _ref2.children,
|
|
5522
5514
|
small = _ref2.small,
|
|
5523
5515
|
onClick = _ref2.onClick;
|
|
5524
|
-
return
|
|
5516
|
+
return React.createElement(ExpandableBoxStyled, {
|
|
5525
5517
|
collapsed: true,
|
|
5526
5518
|
small: small,
|
|
5527
5519
|
onClick: onClick
|
|
5528
|
-
},
|
|
5520
|
+
}, React.createElement(FlipDivStyle, null, children, React.createElement(EditIcon, null)));
|
|
5529
5521
|
};
|
|
5530
|
-
var FlipDivStyle =
|
|
5522
|
+
var FlipDivStyle = styled.div.withConfig({
|
|
5531
5523
|
displayName: "ExpandableBox__FlipDivStyle",
|
|
5532
5524
|
componentId: "sc-1nsk1wq-3"
|
|
5533
5525
|
})(["position:relative;"]);
|
|
@@ -5539,13 +5531,13 @@ var FlipDiv$1 = function FlipDiv(_ref3) {
|
|
|
5539
5531
|
overflowEffect = _ref3.overflowEffect,
|
|
5540
5532
|
props = _objectWithoutProperties(_ref3, ["useAnimation", "animation", "animationTiming", "overflowEffect"]);
|
|
5541
5533
|
|
|
5542
|
-
var ref =
|
|
5534
|
+
var ref = useRef();
|
|
5543
5535
|
useAnimation(ref, null, null, {
|
|
5544
5536
|
switchAnimation: animation,
|
|
5545
5537
|
timing: animationTiming,
|
|
5546
5538
|
effect: overflowEffect
|
|
5547
5539
|
});
|
|
5548
|
-
return
|
|
5540
|
+
return React.createElement(FlipDivStyle, _extends({}, props, {
|
|
5549
5541
|
ref: ref
|
|
5550
5542
|
}));
|
|
5551
5543
|
};
|
|
@@ -5559,10 +5551,10 @@ function _templateObject$6() {
|
|
|
5559
5551
|
|
|
5560
5552
|
return data;
|
|
5561
5553
|
}
|
|
5562
|
-
var InputIcon =
|
|
5554
|
+
var InputIcon = styled(Icon).withConfig({
|
|
5563
5555
|
displayName: "RichText__InputIcon",
|
|
5564
5556
|
componentId: "x8c1ig-0"
|
|
5565
|
-
})(["position:absolute;outline:none;bottom:0;font-size:21px;line-height:3rem;right:0;width:2rem;pointer-events:none;color:", ";"],
|
|
5557
|
+
})(["position:absolute;outline:none;bottom:0;font-size:21px;line-height:3rem;right:0;width:2rem;pointer-events:none;color:", ";"], getColor('gray150'));
|
|
5566
5558
|
var FORMAT_TOOLS = {
|
|
5567
5559
|
'bold': ['b', 'strong'],
|
|
5568
5560
|
'italic': 'i',
|
|
@@ -5635,38 +5627,38 @@ var FIX_STYLE = {
|
|
|
5635
5627
|
return '';
|
|
5636
5628
|
}
|
|
5637
5629
|
};
|
|
5638
|
-
var RichTextContainer =
|
|
5630
|
+
var RichTextContainer = styled.div.withConfig({
|
|
5639
5631
|
displayName: "RichText__RichTextContainer",
|
|
5640
5632
|
componentId: "x8c1ig-1"
|
|
5641
|
-
})(["position:relative;width:100%;border:1px solid ", ";border-radius:6px;background:white;", ";", ";", " ", " ul{list-style-type:disc;}ul,ol{padding-inline-start:25px;margin-block-start:0.5em;margin-block-end:0.5em;}"],
|
|
5642
|
-
return props.hasErrors && "border-color: ".concat(
|
|
5633
|
+
})(["position:relative;width:100%;border:1px solid ", ";border-radius:6px;background:white;", ";", ";", " ", " ul{list-style-type:disc;}ul,ol{padding-inline-start:25px;margin-block-start:0.5em;margin-block-end:0.5em;}"], getColor('gray210'), function (props) {
|
|
5634
|
+
return props.hasErrors && "border-color: ".concat(getColor(props)('alert'));
|
|
5643
5635
|
}, function (props) {
|
|
5644
5636
|
return props.showToolbar && "\n ".concat(ToolsContainer, " {\n transition: 0.5s;\n max-height: 7.5rem;\n transition: 0.6s;\n pointer-events: auto;\n }\n ");
|
|
5645
5637
|
}, function (props) {
|
|
5646
|
-
return props.focus && "\n border-color: ".concat(
|
|
5638
|
+
return props.focus && "\n border-color: ".concat(getColor('gray180'), ";\n box-shadow: 0px 0px 0px 2px rgba(0,0,0,0.1);\n ");
|
|
5647
5639
|
}, function (props) {
|
|
5648
5640
|
return props.locked && css(_templateObject$6());
|
|
5649
5641
|
});
|
|
5650
|
-
var RichTextInput =
|
|
5642
|
+
var RichTextInput = styled.div.withConfig({
|
|
5651
5643
|
displayName: "RichText__RichTextInput",
|
|
5652
5644
|
componentId: "x8c1ig-2"
|
|
5653
|
-
})(["width:100%;font-size:14px;outline:0;outline:none;color:", ";background:white;min-height:", "px;outline:0;padding:0.7rem;overflow:auto;border-radius:5px;b,strong{font-weight:600;}&[contenteditable=true]:empty:before{content:attr(placeholder);color:rgba(0,0,0,0.3);}", ""],
|
|
5645
|
+
})(["width:100%;font-size:14px;outline:0;outline:none;color:", ";background:white;min-height:", "px;outline:0;padding:0.7rem;overflow:auto;border-radius:5px;b,strong{font-weight:600;}&[contenteditable=true]:empty:before{content:attr(placeholder);color:rgba(0,0,0,0.3);}", ""], getColor('gray60'), function (props) {
|
|
5654
5646
|
return props.minHeight || 78;
|
|
5655
5647
|
}, function (props) {
|
|
5656
5648
|
return props.disabled && "\n &[disabled] {\n background: rgba(0, 0, 0, 0.075) !important;\n opacity: 0.75 !important;\n }\n ";
|
|
5657
5649
|
});
|
|
5658
|
-
var ToolsContainer =
|
|
5650
|
+
var ToolsContainer = styled.div.withConfig({
|
|
5659
5651
|
displayName: "RichText__ToolsContainer",
|
|
5660
5652
|
componentId: "x8c1ig-3"
|
|
5661
|
-
})(["background:", ";padding:0 0.125rem;border-top-left-radius:5px;border-top-right-radius:5px;transition:0.225s;max-height:0;pointer-events:none;overflow:hidden;"],
|
|
5662
|
-
var ToolButton =
|
|
5653
|
+
})(["background:", ";padding:0 0.125rem;border-top-left-radius:5px;border-top-right-radius:5px;transition:0.225s;max-height:0;pointer-events:none;overflow:hidden;"], getColor('gray240'));
|
|
5654
|
+
var ToolButton = styled(Button).withConfig({
|
|
5663
5655
|
displayName: "RichText__ToolButton",
|
|
5664
5656
|
componentId: "x8c1ig-4"
|
|
5665
|
-
})(["min-height:2rem;min-width:2rem;background:transparent;box-shadow:none;margin:0.25rem 0.125rem;& ~ &{margin-left:0.125rem;}.icon{font-size:23px;color:", ";position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);}&:hover,&.activated:hover{background:rgba(0,0,0,0.13);}&.activated{background:rgba(0,0,0,0.1);}&:focus:after{content:none;}"],
|
|
5666
|
-
var ToolSeparator =
|
|
5657
|
+
})(["min-height:2rem;min-width:2rem;background:transparent;box-shadow:none;margin:0.25rem 0.125rem;& ~ &{margin-left:0.125rem;}.icon{font-size:23px;color:", ";position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);}&:hover,&.activated:hover{background:rgba(0,0,0,0.13);}&.activated{background:rgba(0,0,0,0.1);}&:focus:after{content:none;}"], getColor('gray90'));
|
|
5658
|
+
var ToolSeparator = styled.span.withConfig({
|
|
5667
5659
|
displayName: "RichText__ToolSeparator",
|
|
5668
5660
|
componentId: "x8c1ig-5"
|
|
5669
|
-
})(["border-left:1px solid ", ";margin-left:0.75rem;margin-right:0.5rem;line-height:2rem;vertical-align:-6px;"],
|
|
5661
|
+
})(["border-left:1px solid ", ";margin-left:0.75rem;margin-right:0.5rem;line-height:2rem;vertical-align:-6px;"], getColor('gray180'));
|
|
5670
5662
|
var JS_CLASS = "EDITOR--JS";
|
|
5671
5663
|
|
|
5672
5664
|
var getNextRegularCharIndex = function getNextRegularCharIndex(text, offset, direction) {
|
|
@@ -5876,20 +5868,20 @@ var RichText = function RichText(_ref5) {
|
|
|
5876
5868
|
setValue = _ref5.setValue,
|
|
5877
5869
|
raw = _ref5.raw,
|
|
5878
5870
|
locked = _ref5.locked;
|
|
5879
|
-
var linkPopup =
|
|
5880
|
-
var input =
|
|
5881
|
-
var activeLinkNode =
|
|
5882
|
-
var container =
|
|
5883
|
-
var linkJustCreated =
|
|
5884
|
-
|
|
5885
|
-
var startSelectionToken =
|
|
5886
|
-
var endSelectionToken =
|
|
5887
|
-
var commands =
|
|
5888
|
-
var containerFocused =
|
|
5889
|
-
var needsNormalize =
|
|
5890
|
-
var alreadyCancelled =
|
|
5891
|
-
|
|
5892
|
-
var _useInput =
|
|
5871
|
+
var linkPopup = usePopupToggle();
|
|
5872
|
+
var input = useEnsureRef(inputRef);
|
|
5873
|
+
var activeLinkNode = useRef();
|
|
5874
|
+
var container = useRef();
|
|
5875
|
+
var linkJustCreated = useRefState(); // auto-hide needs
|
|
5876
|
+
|
|
5877
|
+
var startSelectionToken = useRefState();
|
|
5878
|
+
var endSelectionToken = useRefState();
|
|
5879
|
+
var commands = useRefState([]);
|
|
5880
|
+
var containerFocused = useToggle();
|
|
5881
|
+
var needsNormalize = useRefState();
|
|
5882
|
+
var alreadyCancelled = useRefState(); // const [formValue, setFormValue] = useInput({path})
|
|
5883
|
+
|
|
5884
|
+
var _useInput = useInput$1({
|
|
5893
5885
|
path: path,
|
|
5894
5886
|
value: value,
|
|
5895
5887
|
setValue: setValue
|
|
@@ -5900,28 +5892,28 @@ var RichText = function RichText(_ref5) {
|
|
|
5900
5892
|
hasErrors = _useInput2[2].hasErrors; // const tempValue = useConstant(formValue)
|
|
5901
5893
|
|
|
5902
5894
|
|
|
5903
|
-
var _useState =
|
|
5895
|
+
var _useState = useState(formValue),
|
|
5904
5896
|
_useState2 = _slicedToArray(_useState, 2),
|
|
5905
5897
|
tempValue = _useState2[0],
|
|
5906
5898
|
setTempValue = _useState2[1];
|
|
5907
5899
|
|
|
5908
|
-
|
|
5900
|
+
useEffect(function () {
|
|
5909
5901
|
if (value === formValue && formValue !== tempValue) {
|
|
5910
5902
|
setTempValue(formValue);
|
|
5911
5903
|
}
|
|
5912
5904
|
}, [path]);
|
|
5913
5905
|
|
|
5914
|
-
var _useState3 =
|
|
5906
|
+
var _useState3 = useState({}),
|
|
5915
5907
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
5916
5908
|
activatedTools = _useState4[0],
|
|
5917
5909
|
setActivatedTools = _useState4[1];
|
|
5918
5910
|
|
|
5919
|
-
var validElements =
|
|
5911
|
+
var validElements = useLazyConstant(function () {
|
|
5920
5912
|
return ['br', 'div', 'p', 'span'].concat(_flatten(formatTools.map(function (tool) {
|
|
5921
5913
|
return FORMAT_TOOLS[tool] || [];
|
|
5922
5914
|
})));
|
|
5923
5915
|
});
|
|
5924
|
-
|
|
5916
|
+
useEffect(function () {
|
|
5925
5917
|
cleanEditor(input.current, validElements);
|
|
5926
5918
|
}, []);
|
|
5927
5919
|
|
|
@@ -5929,7 +5921,7 @@ var RichText = function RichText(_ref5) {
|
|
|
5929
5921
|
return input.current && input.current.focus();
|
|
5930
5922
|
};
|
|
5931
5923
|
|
|
5932
|
-
|
|
5924
|
+
useEffect(function () {
|
|
5933
5925
|
if (needsNormalize.get()) {
|
|
5934
5926
|
input.current.normalize();
|
|
5935
5927
|
needsNormalize.set(false);
|
|
@@ -5977,7 +5969,7 @@ var RichText = function RichText(_ref5) {
|
|
|
5977
5969
|
}
|
|
5978
5970
|
};
|
|
5979
5971
|
|
|
5980
|
-
|
|
5972
|
+
useEffect(function () {
|
|
5981
5973
|
document.addEventListener('keydown', keydownHandler);
|
|
5982
5974
|
return function () {
|
|
5983
5975
|
return document.removeEventListener('keydown', keydownHandler);
|
|
@@ -6197,7 +6189,7 @@ var RichText = function RichText(_ref5) {
|
|
|
6197
6189
|
var match = range.toString().match(/[\s\t\n\r]([^\s\t\n\r]*)$/);
|
|
6198
6190
|
|
|
6199
6191
|
if (match) {
|
|
6200
|
-
if (/^(https?:\/\/|www\.)/.test(match[1]) &&
|
|
6192
|
+
if (/^(https?:\/\/|www\.)/.test(match[1]) && linkRegex.test(match[1])) {
|
|
6201
6193
|
range.setStart(range.startContainer, match.index + 1);
|
|
6202
6194
|
range.endContainer.splitText(range.endContainer.textContent.length - 1);
|
|
6203
6195
|
var newNode = document.createElement('a');
|
|
@@ -6285,7 +6277,7 @@ var RichText = function RichText(_ref5) {
|
|
|
6285
6277
|
};
|
|
6286
6278
|
|
|
6287
6279
|
var toolButton = function toolButton(tool) {
|
|
6288
|
-
return
|
|
6280
|
+
return React.createElement(ToolButton, {
|
|
6289
6281
|
key: tool,
|
|
6290
6282
|
tabIndex: -1,
|
|
6291
6283
|
onMouseDown: function onMouseDown(e) {
|
|
@@ -6296,28 +6288,28 @@ var RichText = function RichText(_ref5) {
|
|
|
6296
6288
|
},
|
|
6297
6289
|
className: 'button exec-command rich-text-button only-icon ' + (activatedTools[tool] ? 'activated' : ''),
|
|
6298
6290
|
type: "button"
|
|
6299
|
-
},
|
|
6291
|
+
}, React.createElement("span", {
|
|
6300
6292
|
className: 'icon icon-' + tool
|
|
6301
6293
|
}));
|
|
6302
6294
|
};
|
|
6303
6295
|
|
|
6304
|
-
var richTextElement =
|
|
6296
|
+
var richTextElement = React.createElement(RichTextContainer, {
|
|
6305
6297
|
linkColor: linkColor,
|
|
6306
6298
|
ref: container,
|
|
6307
|
-
onClick:
|
|
6299
|
+
onClick: stopPropagation(),
|
|
6308
6300
|
onFocus: containerFocus,
|
|
6309
6301
|
onBlur: containerBlur,
|
|
6310
6302
|
focus: containerFocused.isOpen,
|
|
6311
6303
|
showToolbar: !disabled & !autoHideToolbar || containerFocused.isOpen,
|
|
6312
6304
|
className: className
|
|
6313
|
-
},
|
|
6305
|
+
}, React.createElement(ToolsContainer, {
|
|
6314
6306
|
className: "rich-text-tools"
|
|
6315
6307
|
}, formatTools.map(function (t, i) {
|
|
6316
|
-
return t === 'separator' ?
|
|
6308
|
+
return t === 'separator' ? React.createElement(ToolSeparator, {
|
|
6317
6309
|
className: "separator",
|
|
6318
6310
|
key: "separator-" + i
|
|
6319
6311
|
}) : toolButton(t);
|
|
6320
|
-
})),
|
|
6312
|
+
})), React.createElement(RichTextInput, {
|
|
6321
6313
|
contentEditable: !disabled,
|
|
6322
6314
|
ref: input,
|
|
6323
6315
|
onBlur: onBlur,
|
|
@@ -6334,9 +6326,9 @@ var RichText = function RichText(_ref5) {
|
|
|
6334
6326
|
className: JS_CLASS,
|
|
6335
6327
|
minHeight: minHeight,
|
|
6336
6328
|
placeholder: placeholder
|
|
6337
|
-
}), locked &&
|
|
6329
|
+
}), locked && React.createElement(InputIcon, {
|
|
6338
6330
|
icon: "lock"
|
|
6339
|
-
}), linkPopup.isOpen &&
|
|
6331
|
+
}), linkPopup.isOpen && React.createElement(EditLinkPopup, {
|
|
6340
6332
|
input: input,
|
|
6341
6333
|
activeLinkNode: activeLinkNode,
|
|
6342
6334
|
cancel: cancelRichTextLink,
|
|
@@ -6344,7 +6336,7 @@ var RichText = function RichText(_ref5) {
|
|
|
6344
6336
|
removeLink: removeLink,
|
|
6345
6337
|
saveLink: saveRichTextLink
|
|
6346
6338
|
}));
|
|
6347
|
-
return label ?
|
|
6339
|
+
return label ? React.createElement(Field$1, {
|
|
6348
6340
|
labelClick: focus,
|
|
6349
6341
|
descText: descText,
|
|
6350
6342
|
helpText: helpText,
|
|
@@ -6360,11 +6352,11 @@ var EditLinkPopup = function EditLinkPopup(_ref7) {
|
|
|
6360
6352
|
input = _ref7.input,
|
|
6361
6353
|
saveLink = _ref7.saveLink,
|
|
6362
6354
|
values = _ref7.values;
|
|
6363
|
-
var linkPopup =
|
|
6364
|
-
var formRef =
|
|
6365
|
-
var linkTextRef =
|
|
6366
|
-
var linkUrlRef =
|
|
6367
|
-
var LABELS =
|
|
6355
|
+
var linkPopup = useRef();
|
|
6356
|
+
var formRef = useRef();
|
|
6357
|
+
var linkTextRef = useRef();
|
|
6358
|
+
var linkUrlRef = useRef();
|
|
6359
|
+
var LABELS = useContext(StartlibsContext).labels.RichText;
|
|
6368
6360
|
|
|
6369
6361
|
var preValidation = function preValidation(formValues) {
|
|
6370
6362
|
var errors;
|
|
@@ -6375,7 +6367,7 @@ var EditLinkPopup = function EditLinkPopup(_ref7) {
|
|
|
6375
6367
|
};
|
|
6376
6368
|
}
|
|
6377
6369
|
|
|
6378
|
-
if (!formValues.linkUrl || formValues.linkUrl === ' ' || !
|
|
6370
|
+
if (!formValues.linkUrl || formValues.linkUrl === ' ' || !linkRegex.test(formValues.linkUrl.trim())) {
|
|
6379
6371
|
errors = _objectSpread({}, errors, {
|
|
6380
6372
|
'linkUrl': [LABELS.linkUrlError]
|
|
6381
6373
|
});
|
|
@@ -6395,7 +6387,7 @@ var EditLinkPopup = function EditLinkPopup(_ref7) {
|
|
|
6395
6387
|
}
|
|
6396
6388
|
};
|
|
6397
6389
|
|
|
6398
|
-
|
|
6390
|
+
useEffect(function () {
|
|
6399
6391
|
var currentActiveLinkNode = activeLinkNode.current;
|
|
6400
6392
|
var currentLinkPopup = linkPopup.current;
|
|
6401
6393
|
var offsetLeft = currentActiveLinkNode.getClientRects().length > 1 ? input.offsetLeft : currentActiveLinkNode.offsetLeft;
|
|
@@ -6415,86 +6407,86 @@ var EditLinkPopup = function EditLinkPopup(_ref7) {
|
|
|
6415
6407
|
|
|
6416
6408
|
return cancel;
|
|
6417
6409
|
}, []);
|
|
6418
|
-
return
|
|
6410
|
+
return React.createElement(WithForm$1, {
|
|
6419
6411
|
skipDom: true,
|
|
6420
6412
|
ref: formRef,
|
|
6421
6413
|
action: saveLink,
|
|
6422
6414
|
values: values,
|
|
6423
6415
|
preValidation: preValidation
|
|
6424
|
-
}, function (form
|
|
6425
|
-
return
|
|
6426
|
-
onClick:
|
|
6416
|
+
}, function (form) {
|
|
6417
|
+
return React.createElement("div", {
|
|
6418
|
+
onClick: stopPropagation(),
|
|
6427
6419
|
ref: linkPopup,
|
|
6428
6420
|
onKeyDown: checkEscOrEnter,
|
|
6429
6421
|
className: "popup rich-text-link-editor ignore-link",
|
|
6430
6422
|
contentEditable: false
|
|
6431
|
-
},
|
|
6423
|
+
}, React.createElement(TextInput$1, {
|
|
6432
6424
|
ref: linkTextRef,
|
|
6433
6425
|
mandatory: true,
|
|
6434
6426
|
path: "linkText",
|
|
6435
6427
|
label: LABELS.popupLinkText
|
|
6436
|
-
}),
|
|
6428
|
+
}), React.createElement(TextInput$1, {
|
|
6437
6429
|
ref: linkUrlRef,
|
|
6438
6430
|
mandatory: true,
|
|
6439
6431
|
path: "linkUrl",
|
|
6440
6432
|
label: LABELS.popupLinkUrl
|
|
6441
|
-
}),
|
|
6433
|
+
}), React.createElement("div", {
|
|
6442
6434
|
className: "popup-footer"
|
|
6443
|
-
},
|
|
6435
|
+
}, React.createElement(Button, {
|
|
6444
6436
|
className: "remove-link",
|
|
6445
6437
|
icon: "remove",
|
|
6446
6438
|
onClick: removeLink
|
|
6447
|
-
}, LABELS.popupRemove),
|
|
6439
|
+
}, LABELS.popupRemove), React.createElement(Button, {
|
|
6448
6440
|
onClick: cancel,
|
|
6449
6441
|
tabIndex: 0
|
|
6450
|
-
}, LABELS.popupCancel),
|
|
6442
|
+
}, LABELS.popupCancel), React.createElement(Button, {
|
|
6451
6443
|
highlight: true,
|
|
6452
|
-
onClick: form
|
|
6453
|
-
}, LABELS.popupConfirm)),
|
|
6444
|
+
onClick: form.willSubmitForm
|
|
6445
|
+
}, LABELS.popupConfirm)), React.createElement(Errors$1, null));
|
|
6454
6446
|
});
|
|
6455
6447
|
};
|
|
6456
6448
|
|
|
6457
|
-
var IconRadioBoxText =
|
|
6449
|
+
var IconRadioBoxText = styled.div.withConfig({
|
|
6458
6450
|
displayName: "IconRadioBox__IconRadioBoxText",
|
|
6459
6451
|
componentId: "ka3uhk-0"
|
|
6460
|
-
})(["flex-grow:1;padding:0 0.5rem 0.5rem;min-height:2rem;display:flex;justify-content:center;align-items:center;text-align:center;font-size:12px;color:", ";", " ", ""],
|
|
6461
|
-
return props.checked &&
|
|
6452
|
+
})(["flex-grow:1;padding:0 0.5rem 0.5rem;min-height:2rem;display:flex;justify-content:center;align-items:center;text-align:center;font-size:12px;color:", ";", " ", ""], getColor('gray120'), function (props) {
|
|
6453
|
+
return props.checked && css$1(["color:", ";"], getColor('main'));
|
|
6462
6454
|
}, function (props) {
|
|
6463
|
-
return props.highlightedDesc &&
|
|
6464
|
-
return props.checked &&
|
|
6465
|
-
return
|
|
6455
|
+
return props.highlightedDesc && css$1(["background:", ";padding:0.25rem 0.5rem;min-height:3rem;", ""], getColor('gray240'), function (props) {
|
|
6456
|
+
return props.checked && css$1(["background:", ";"], function (props) {
|
|
6457
|
+
return desaturate(0.3, lighten(0.52, getColor("main")(props)));
|
|
6466
6458
|
});
|
|
6467
6459
|
});
|
|
6468
6460
|
});
|
|
6469
|
-
var IconRadioBoxIconContainer =
|
|
6461
|
+
var IconRadioBoxIconContainer = styled.div.withConfig({
|
|
6470
6462
|
displayName: "IconRadioBox__IconRadioBoxIconContainer",
|
|
6471
6463
|
componentId: "ka3uhk-1"
|
|
6472
6464
|
})(["display:flex;justify-content:center;align-items:center;text-align:center;"]);
|
|
6473
|
-
var Wrapper =
|
|
6465
|
+
var Wrapper = styled.div.withConfig({
|
|
6474
6466
|
displayName: "IconRadioBox__Wrapper",
|
|
6475
6467
|
componentId: "ka3uhk-2"
|
|
6476
|
-
})(["width:100%;display:flex;flex-direction:column;cursor:pointer;border-radius:6px;background-color:white;border:1px solid ", ";overflow:hidden;color:", ";", "{font-size:100px;line-height:50px;line-height:76px;width:100%;}", " input{opacity:0;position:absolute;left:-20000000px;}", " ", ""],
|
|
6477
|
-
return props.checked &&
|
|
6468
|
+
})(["width:100%;display:flex;flex-direction:column;cursor:pointer;border-radius:6px;background-color:white;border:1px solid ", ";overflow:hidden;color:", ";", "{font-size:100px;line-height:50px;line-height:76px;width:100%;}", " input{opacity:0;position:absolute;left:-20000000px;}", " ", ""], getColor('gray210'), getColor('gray150'), Icon, function (props) {
|
|
6469
|
+
return props.checked && css$1(["color:", ";border-color:", ";"], getColor('main'), getColor('main'));
|
|
6478
6470
|
}, function (props) {
|
|
6479
6471
|
return props.focused && "\n ".concat(IconRadioBoxIconContainer, "::after {\n content: '';\n position: absolute;\n top: -4px;\n right: -4px;\n left: -4px;\n bottom: -4px;\n border-radius: 10px;\n border: 3px solid rgba(0, 0, 0, 0.15);\n }");
|
|
6480
|
-
},
|
|
6481
|
-
var IconRadioBox =
|
|
6472
|
+
}, customTheme("IconRadioBox"));
|
|
6473
|
+
var IconRadioBox = styled(function (_ref) {
|
|
6482
6474
|
var icon = _ref.icon,
|
|
6483
6475
|
label = _ref.label,
|
|
6484
6476
|
highlightedDesc = _ref.highlightedDesc,
|
|
6485
6477
|
props = _objectWithoutProperties(_ref, ["icon", "label", "highlightedDesc"]);
|
|
6486
6478
|
|
|
6487
|
-
return
|
|
6479
|
+
return React.createElement(Radiobox$1, props, function (_ref2) {
|
|
6488
6480
|
var checked = _ref2.checked,
|
|
6489
6481
|
focused = _ref2.focused,
|
|
6490
6482
|
hasErrors = _ref2.hasErrors,
|
|
6491
6483
|
disabled = _ref2.disabled;
|
|
6492
|
-
return
|
|
6484
|
+
return React.createElement(Wrapper, {
|
|
6493
6485
|
checked: checked,
|
|
6494
6486
|
focused: focused
|
|
6495
|
-
},
|
|
6487
|
+
}, React.createElement(IconRadioBoxIconContainer, null, React.createElement(Icon, {
|
|
6496
6488
|
icon: icon
|
|
6497
|
-
})), checked,
|
|
6489
|
+
})), checked, React.createElement(IconRadioBoxText, {
|
|
6498
6490
|
highlightedDesc: highlightedDesc,
|
|
6499
6491
|
checked: checked
|
|
6500
6492
|
}, label));
|
|
@@ -6513,41 +6505,41 @@ function _templateObject$7() {
|
|
|
6513
6505
|
|
|
6514
6506
|
return data;
|
|
6515
6507
|
}
|
|
6516
|
-
var CheckboxPseudoInput =
|
|
6508
|
+
var CheckboxPseudoInput = styled.div.withConfig({
|
|
6517
6509
|
displayName: "SimpleCheckbox__CheckboxPseudoInput",
|
|
6518
6510
|
componentId: "am8pps-0"
|
|
6519
|
-
})(["border-radius:4px;content:'';border:1px solid ", ";width:18px;height:18px;background-color:white;position:absolute;left:-2rem;top:50%;transform:translateY(-50%);", " ", "{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-weight:bold;font-size:16px;color:", ";}"],
|
|
6520
|
-
var TextLabel =
|
|
6511
|
+
})(["border-radius:4px;content:'';border:1px solid ", ";width:18px;height:18px;background-color:white;position:absolute;left:-2rem;top:50%;transform:translateY(-50%);", " ", "{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-weight:bold;font-size:16px;color:", ";}"], getColor('gray210'), ifProp('focused', css$1(["box-shadow:0 0 0 2px rgba(0,0,0,0.1);border-color:", ";"], getColor('gray180'))), Icon, getColor('gray90'));
|
|
6512
|
+
var TextLabel = styled.span.withConfig({
|
|
6521
6513
|
displayName: "SimpleCheckbox__TextLabel",
|
|
6522
6514
|
componentId: "am8pps-1"
|
|
6523
6515
|
})(["font-size:13px;line-height:16px;margin:2px 0;display:block;"]);
|
|
6524
|
-
var DescText$1 =
|
|
6516
|
+
var DescText$1 = styled.div.withConfig({
|
|
6525
6517
|
displayName: "SimpleCheckbox__DescText",
|
|
6526
6518
|
componentId: "am8pps-2"
|
|
6527
6519
|
})(["color:rgba(0,0,0,0.4);display:block;font-size:12px;font-weight:400;"]);
|
|
6528
|
-
var TextLabelContainer =
|
|
6520
|
+
var TextLabelContainer = styled.div.withConfig({
|
|
6529
6521
|
displayName: "SimpleCheckbox__TextLabelContainer",
|
|
6530
6522
|
componentId: "am8pps-3"
|
|
6531
|
-
})(["display:flex;align-items:center;position:relative;", "{margin-left:0.25rem;}"],
|
|
6532
|
-
var CheckboxContent =
|
|
6523
|
+
})(["display:flex;align-items:center;position:relative;", "{margin-left:0.25rem;}"], HelpText$1);
|
|
6524
|
+
var CheckboxContent = styled.div.withConfig({
|
|
6533
6525
|
displayName: "SimpleCheckbox__CheckboxContent",
|
|
6534
6526
|
componentId: "am8pps-4"
|
|
6535
6527
|
})(["cursor:pointer;position:relative;padding-left:2rem;transition:background 0.2s linear;", ""], function (props) {
|
|
6536
|
-
return props.framed &&
|
|
6537
|
-
return props.hasErrors &&
|
|
6528
|
+
return props.framed && css$1(["border:1px solid ", ";border-radius:6px;min-height:3rem;min-width:8rem;background:white;width:100%;align-items:center;display:flex;:hover{background:rgb(245,245,245);}:active{background:rgb(235,235,235);transition:none;}padding:10px 12px 10px 32px;", " ", " ", " ", " ", ""], getColor('gray210'), media.desktop(_templateObject$7()), function (props) {
|
|
6529
|
+
return props.hasErrors && css$1(["border-color:", " !important;"], getColor('alert'));
|
|
6538
6530
|
}, function (props) {
|
|
6539
|
-
return props.checked && props.highlightSelected &&
|
|
6540
|
-
return
|
|
6531
|
+
return props.checked && props.highlightSelected && css$1(["border-color:", ";background:", ";:hover{background:", ";}", "{", "{color:", ";}}"], getColor('main'), function (props) {
|
|
6532
|
+
return desaturate(0.3, lighten(0.52, getColor("main")(props)));
|
|
6541
6533
|
}, function (props) {
|
|
6542
|
-
return
|
|
6543
|
-
}, CheckboxPseudoInput,
|
|
6534
|
+
return desaturate(0.3, lighten(0.52, getColor("main")(props)));
|
|
6535
|
+
}, CheckboxPseudoInput, Icon, getColor('main'));
|
|
6544
6536
|
}, function (props) {
|
|
6545
|
-
return props.checked && props.ultraHighlightSelected &&
|
|
6537
|
+
return props.checked && props.ultraHighlightSelected && css$1(["border-color:", ";background:", ";color:white;a,a.link{color:white;}:hover{background:", ";}", "{", "{color:", ";}}", "{color:rgba(255,255,255,0.65);}", "{color:rgba(255,255,255,0.65);}"], getColor('main'), getColor('main'), getColor('main'), CheckboxPseudoInput, Icon, getColor('main'), HelpText$1, DescText$1);
|
|
6546
6538
|
}, function (props) {
|
|
6547
|
-
return props.disabled &&
|
|
6539
|
+
return props.disabled && css$1(["background-color:rgba(0,0,0,0.075) !important;color:rgba(0,0,0,0.6);!important;&[disabled]{opacity:0.75 !important;}", "{background:transparent;}"], CheckboxPseudoInput);
|
|
6548
6540
|
});
|
|
6549
6541
|
});
|
|
6550
|
-
var SimpleCheckbox =
|
|
6542
|
+
var SimpleCheckbox = styled(function (_ref) {
|
|
6551
6543
|
var path = _ref.path,
|
|
6552
6544
|
disabled = _ref.disabled,
|
|
6553
6545
|
label = _ref.label,
|
|
@@ -6562,7 +6554,7 @@ var SimpleCheckbox = styled__default(function (_ref) {
|
|
|
6562
6554
|
ultraHighlightSelected = _ref.ultraHighlightSelected,
|
|
6563
6555
|
rest = _objectWithoutProperties(_ref, ["path", "disabled", "label", "descText", "helpText", "isFirst", "isLast", "tabIndex", "className", "framedBoxes", "highlightSelected", "ultraHighlightSelected"]);
|
|
6564
6556
|
|
|
6565
|
-
return
|
|
6557
|
+
return React.createElement(Checkbox$1, _extends({
|
|
6566
6558
|
className: className,
|
|
6567
6559
|
path: path,
|
|
6568
6560
|
tabIndex: tabIndex
|
|
@@ -6570,66 +6562,66 @@ var SimpleCheckbox = styled__default(function (_ref) {
|
|
|
6570
6562
|
var checked = _ref2.checked,
|
|
6571
6563
|
hasErrors = _ref2.hasErrors,
|
|
6572
6564
|
focused = _ref2.focused;
|
|
6573
|
-
return
|
|
6565
|
+
return React.createElement(CheckboxContent, {
|
|
6574
6566
|
checked: checked,
|
|
6575
6567
|
framed: framedBoxes,
|
|
6576
6568
|
highlightSelected: highlightSelected,
|
|
6577
6569
|
ultraHighlightSelected: ultraHighlightSelected,
|
|
6578
6570
|
hasErrors: hasErrors,
|
|
6579
6571
|
disabled: disabled
|
|
6580
|
-
},
|
|
6572
|
+
}, React.createElement("div", {
|
|
6581
6573
|
className: "textContainer"
|
|
6582
|
-
},
|
|
6574
|
+
}, React.createElement(TextLabelContainer, null, React.createElement(CheckboxPseudoInput, {
|
|
6583
6575
|
focused: focused,
|
|
6584
6576
|
tabIndex: tabIndex
|
|
6585
|
-
}, checked &&
|
|
6577
|
+
}, checked && React.createElement(Icon, {
|
|
6586
6578
|
icon: "check"
|
|
6587
|
-
})),
|
|
6579
|
+
})), React.createElement(TextLabel, null, label), helpText && React.createElement(HelpText$1, null, helpText)), descText && React.createElement(DescText$1, null, descText)));
|
|
6588
6580
|
});
|
|
6589
6581
|
}).withConfig({
|
|
6590
6582
|
displayName: "SimpleCheckbox",
|
|
6591
6583
|
componentId: "am8pps-5"
|
|
6592
|
-
})(["cursor:pointer;position:relative;margin-bottom:1rem;display:flex;", " .textContainer{width:100%;}"],
|
|
6584
|
+
})(["cursor:pointer;position:relative;margin-bottom:1rem;display:flex;", " .textContainer{width:100%;}"], ifProp('disabled', css$1(["pointer-events:none;"])));
|
|
6593
6585
|
|
|
6594
|
-
var ToggleContainer =
|
|
6586
|
+
var ToggleContainer = styled.div.withConfig({
|
|
6595
6587
|
displayName: "ToggleCheckbox__ToggleContainer",
|
|
6596
6588
|
componentId: "sc-11ob8ah-0"
|
|
6597
6589
|
})([""]);
|
|
6598
|
-
var Toggle =
|
|
6590
|
+
var Toggle = styled.div.withConfig({
|
|
6599
6591
|
displayName: "ToggleCheckbox__Toggle",
|
|
6600
6592
|
componentId: "sc-11ob8ah-1"
|
|
6601
6593
|
})(["cursor:pointer;flex-shrink:0;margin-left:1rem;float:right;transition:0.25s ease;width:2.75rem;height:18px;border-radius:18px;background:", ";display:inline-block;position:relative;font-weight:600;:after{content:'';transition:0.25s ease;border-radius:50%;display:block;position:absolute;top:50%;transform:translateY(-50%);width:14px;height:14px;background:white;", "}", ""], function (props) {
|
|
6602
|
-
return props.checked ?
|
|
6594
|
+
return props.checked ? getColor('main') : 'rgba(0,0,0,0.14)';
|
|
6603
6595
|
}, function (props) {
|
|
6604
|
-
return props.checked ?
|
|
6605
|
-
},
|
|
6606
|
-
var ToggleLabel =
|
|
6596
|
+
return props.checked ? css$1(["margin-left:-2px;left:100%;transform:translate(-100%,-50%);"]) : css$1(["margin-left:2px;left:0;"]);
|
|
6597
|
+
}, customTheme('ToggleCheckbox'));
|
|
6598
|
+
var ToggleLabel = styled.div.withConfig({
|
|
6607
6599
|
displayName: "ToggleCheckbox__ToggleLabel",
|
|
6608
6600
|
componentId: "sc-11ob8ah-2"
|
|
6609
6601
|
})(["flex-basis:0;flex-grow:1;display:inline-block;font-size:14px;"]);
|
|
6610
|
-
var DescText$2 =
|
|
6602
|
+
var DescText$2 = styled.div.withConfig({
|
|
6611
6603
|
displayName: "ToggleCheckbox__DescText",
|
|
6612
6604
|
componentId: "sc-11ob8ah-3"
|
|
6613
6605
|
})(["font-weight:400;color:rgba(0,0,0,0.4);font-size:12px;margin-top:0.25rem;"]);
|
|
6614
|
-
var ToggleCheckboxStyled =
|
|
6606
|
+
var ToggleCheckboxStyled = styled(Checkbox$1).withConfig({
|
|
6615
6607
|
displayName: "ToggleCheckbox__ToggleCheckboxStyled",
|
|
6616
6608
|
componentId: "sc-11ob8ah-4"
|
|
6617
6609
|
})(["position:relative;border-radius:6px;padding:1rem;min-height:42px;font-weight:500;cursor:pointer;display:flex;align-items:center;justify-content:space-between;transition:background 0.2s linear;& ~ &{margin-top:-1rem;}", " ", " ", " ", " ", ""], function (props) {
|
|
6618
|
-
return props.margin ?
|
|
6610
|
+
return props.margin ? css$1(["margin-bottom:", "px;"], function (props) {
|
|
6619
6611
|
return props.margin;
|
|
6620
|
-
}) :
|
|
6612
|
+
}) : css$1(["margin-bottom:1.5rem;& ~ &{margin-top:-1rem;}"]);
|
|
6621
6613
|
}, function (props) {
|
|
6622
|
-
return props.gray ? "\n background-color: rgba(0,0,0,0.06);\n :hover {\n background-color: rgba(0,0,0,0.08);\n }\n :active {\n background-color: rgba(0,0,0,0.1);\n transition: none;\n }\n " :
|
|
6623
|
-
return
|
|
6614
|
+
return props.gray ? "\n background-color: rgba(0,0,0,0.06);\n :hover {\n background-color: rgba(0,0,0,0.08);\n }\n :active {\n background-color: rgba(0,0,0,0.1);\n transition: none;\n }\n " : css$1(["background-color:", ";:hover{background:", ";}:active{background:", ";transition:none;}"], getColor('lightBluishGray'), function (props) {
|
|
6615
|
+
return darken(0.035, getColor('lightBluishGray')(props));
|
|
6624
6616
|
}, function (props) {
|
|
6625
|
-
return
|
|
6617
|
+
return darken(0.05, getColor('lightBluishGray')(props));
|
|
6626
6618
|
});
|
|
6627
6619
|
}, function (props) {
|
|
6628
|
-
return !props.noFocus &&
|
|
6620
|
+
return !props.noFocus && css$1([":focus-within{background-color:rgba(0,0,0,0.09);:after{content:'';pointer-events:none;position:absolute;top:-3px;right:-3px;left:-3px;bottom:-3px;border-radius:9px;border:2px solid rgba(0,0,0,0.15);}}"]);
|
|
6629
6621
|
}, function (props) {
|
|
6630
6622
|
return props.disabled && "\n opacity: 0.8;\n pointer-events:none;\n ";
|
|
6631
|
-
},
|
|
6632
|
-
var ToggleCheckbox =
|
|
6623
|
+
}, customTheme('ToggleCheckboxBox'));
|
|
6624
|
+
var ToggleCheckbox = styled(function (_ref) {
|
|
6633
6625
|
var path = _ref.path,
|
|
6634
6626
|
disabled = _ref.disabled,
|
|
6635
6627
|
rightInfo = _ref.rightInfo,
|
|
@@ -6642,7 +6634,7 @@ var ToggleCheckbox = styled__default(function (_ref) {
|
|
|
6642
6634
|
className = _ref.className,
|
|
6643
6635
|
rest = _objectWithoutProperties(_ref, ["path", "disabled", "rightInfo", "label", "descText", "helpText", "tabIndex", "noFocus", "margin", "className"]);
|
|
6644
6636
|
|
|
6645
|
-
return
|
|
6637
|
+
return React.createElement(ToggleCheckboxStyled, _extends({
|
|
6646
6638
|
path: path,
|
|
6647
6639
|
tabIndex: tabIndex,
|
|
6648
6640
|
disabled: disabled,
|
|
@@ -6654,9 +6646,9 @@ var ToggleCheckbox = styled__default(function (_ref) {
|
|
|
6654
6646
|
checked = _ref2.checked,
|
|
6655
6647
|
hasErrors = _ref2.hasErrors,
|
|
6656
6648
|
focused = _ref2.focused;
|
|
6657
|
-
return
|
|
6649
|
+
return React.createElement(React.Fragment, null, React.createElement(ToggleLabel, null, label, helpText && React.createElement(HelpText$1, null, " ", helpText), React.createElement(TransitionDiv, {
|
|
6658
6650
|
block: true
|
|
6659
|
-
}, descText &&
|
|
6651
|
+
}, descText && React.createElement(DescText$2, null, descText))), rightInfo, React.createElement(Toggle, {
|
|
6660
6652
|
checked: checked
|
|
6661
6653
|
}));
|
|
6662
6654
|
});
|
|
@@ -6674,27 +6666,27 @@ function _templateObject$8() {
|
|
|
6674
6666
|
|
|
6675
6667
|
return data;
|
|
6676
6668
|
}
|
|
6677
|
-
var TabButton =
|
|
6669
|
+
var TabButton = styled(Button).withConfig({
|
|
6678
6670
|
displayName: "TabRadiobox__TabButton",
|
|
6679
6671
|
componentId: "sc-1vu3bcn-0"
|
|
6680
6672
|
})(["width:100%;margin-left:0;padding:9px 1rem;flex-grow:1;background:", ";box-shadow:none;color:", ";border:1px solid ", ";border-left-width:0;height:100%;:hover{background:", ";}", " ", " ", " ", " ", " ", ""], function (props) {
|
|
6681
|
-
return props.white ? 'white' :
|
|
6682
|
-
},
|
|
6683
|
-
return
|
|
6684
|
-
},
|
|
6673
|
+
return props.white ? 'white' : getColor('gray240');
|
|
6674
|
+
}, getColor('gray120'), getColor('gray210'), function (props) {
|
|
6675
|
+
return desaturate(0.6, lighten(0.5, getColor("main")(props)));
|
|
6676
|
+
}, ifProp('checked', css$1(["&,&:hover{border-color:", ";background-color:", ";border-left-width:1px;color:#fff;cursor:default;}"], getColor('main'), getColor('main'))), function (props) {
|
|
6685
6677
|
return props.isFirst && "\n border-left-width: 1px;\n ";
|
|
6686
6678
|
}, function (props) {
|
|
6687
6679
|
return props.isFirst !== undefined && !props.isFirst && "\n border-bottom-left-radius: 0;\n border-top-left-radius: 0;\n :focus:after{\n border-bottom-left-radius: 2px;\n border-top-left-radius: 2px;\n }\n ";
|
|
6688
6680
|
}, function (props) {
|
|
6689
6681
|
return props.isLast !== undefined && !props.isLast && "\n border-bottom-right-radius: 0;\n border-top-right-radius: 0;\n :focus:after{\n border-bottom-right-radius: 2px;\n border-top-right-radius: 2px;\n z-index: 2;\n }\n ";
|
|
6690
|
-
},
|
|
6682
|
+
}, media.mobile(_templateObject$8(), function (props) {
|
|
6691
6683
|
return props.icon ? "\n padding-left: 1.25rem;\n padding-right: 1rem;\n " : "\n padding-left: 0.25rem;\n padding-right: 0.25rem;\n ";
|
|
6692
|
-
}),
|
|
6693
|
-
var InnerButton =
|
|
6684
|
+
}), customTheme('TabButton'));
|
|
6685
|
+
var InnerButton = styled.a.withConfig({
|
|
6694
6686
|
displayName: "TabRadiobox__InnerButton",
|
|
6695
6687
|
componentId: "sc-1vu3bcn-1"
|
|
6696
6688
|
})([""]);
|
|
6697
|
-
var TabRadiobox =
|
|
6689
|
+
var TabRadiobox = styled(function (_ref) {
|
|
6698
6690
|
var isLast = _ref.isLast,
|
|
6699
6691
|
isFirst = _ref.isFirst,
|
|
6700
6692
|
label = _ref.label,
|
|
@@ -6702,12 +6694,12 @@ var TabRadiobox = styled__default(function (_ref) {
|
|
|
6702
6694
|
icon = _ref.icon,
|
|
6703
6695
|
props = _objectWithoutProperties(_ref, ["isLast", "isFirst", "label", "white", "icon"]);
|
|
6704
6696
|
|
|
6705
|
-
return
|
|
6697
|
+
return React.createElement(Radiobox$1, props, function (_ref2) {
|
|
6706
6698
|
var disabled = _ref2.disabled,
|
|
6707
6699
|
checked = _ref2.checked,
|
|
6708
6700
|
hasErrors = _ref2.hasErrors,
|
|
6709
6701
|
focused = _ref2.focused;
|
|
6710
|
-
return
|
|
6702
|
+
return React.createElement(TabButton, {
|
|
6711
6703
|
innerAs: InnerButton,
|
|
6712
6704
|
tabIndex: -1,
|
|
6713
6705
|
focused: focused,
|
|
@@ -6724,28 +6716,28 @@ var TabRadiobox = styled__default(function (_ref) {
|
|
|
6724
6716
|
componentId: "sc-1vu3bcn-2"
|
|
6725
6717
|
})(["display:inline-block;"]);
|
|
6726
6718
|
|
|
6727
|
-
var Tab =
|
|
6719
|
+
var Tab = styled.div.withConfig({
|
|
6728
6720
|
displayName: "CleanTabRadiobox__Tab",
|
|
6729
6721
|
componentId: "uh7jfp-0"
|
|
6730
|
-
})(["width:100%;font-size:16px;color:", ";font-weight:500;margin-left:0;padding:12px 2.5rem;flex-grow:1;height:100%;border-bottom:1px solid ", ";position:relative;", " ", ""],
|
|
6731
|
-
return props.checked ?
|
|
6732
|
-
},
|
|
6733
|
-
var InnerButton$1 =
|
|
6722
|
+
})(["width:100%;font-size:16px;color:", ";font-weight:500;margin-left:0;padding:12px 2.5rem;flex-grow:1;height:100%;border-bottom:1px solid ", ";position:relative;", " ", ""], getColor("gray120"), getColor("gray210"), function (props) {
|
|
6723
|
+
return props.checked ? css$1(["color:", ";:after{content:'';position:absolute;bottom:-2px;left:0;right:0;height:3px;background:", ";border-radius:10px;}"], getColor("main"), getColor("main")) : css$1(["cursor:pointer;:hover{color:", ";}"], getColor("gray90"));
|
|
6724
|
+
}, customTheme('CleanTabButton'));
|
|
6725
|
+
var InnerButton$1 = styled.a.withConfig({
|
|
6734
6726
|
displayName: "CleanTabRadiobox__InnerButton",
|
|
6735
6727
|
componentId: "uh7jfp-1"
|
|
6736
6728
|
})([""]);
|
|
6737
|
-
var CleanTabRadiobox =
|
|
6729
|
+
var CleanTabRadiobox = styled(function (_ref) {
|
|
6738
6730
|
var label = _ref.label,
|
|
6739
6731
|
white = _ref.white,
|
|
6740
6732
|
icon = _ref.icon,
|
|
6741
6733
|
props = _objectWithoutProperties(_ref, ["label", "white", "icon"]);
|
|
6742
6734
|
|
|
6743
|
-
return
|
|
6735
|
+
return React.createElement(Radiobox$1, props, function (_ref2) {
|
|
6744
6736
|
var disabled = _ref2.disabled,
|
|
6745
6737
|
checked = _ref2.checked,
|
|
6746
6738
|
hasErrors = _ref2.hasErrors,
|
|
6747
6739
|
focused = _ref2.focused;
|
|
6748
|
-
return
|
|
6740
|
+
return React.createElement(Tab, {
|
|
6749
6741
|
innerAs: InnerButton$1,
|
|
6750
6742
|
tabIndex: -1,
|
|
6751
6743
|
focused: focused,
|
|
@@ -6767,42 +6759,42 @@ function _templateObject$9() {
|
|
|
6767
6759
|
|
|
6768
6760
|
return data;
|
|
6769
6761
|
}
|
|
6770
|
-
var CssCircle =
|
|
6762
|
+
var CssCircle = styled.div.withConfig({
|
|
6771
6763
|
displayName: "SimpleRadiobox__CssCircle",
|
|
6772
6764
|
componentId: "qv83xo-0"
|
|
6773
|
-
})(["border-radius:50%;content:'';border:1px solid ", ";width:18px;height:18px;background-color:white;position:absolute;left:-2rem;top:50%;transform:translateY(-50%);", " ", ""],
|
|
6774
|
-
var TextLabel$1 =
|
|
6765
|
+
})(["border-radius:50%;content:'';border:1px solid ", ";width:18px;height:18px;background-color:white;position:absolute;left:-2rem;top:50%;transform:translateY(-50%);", " ", ""], getColor('gray210'), ifProp('focused', css$1(["box-shadow:0 0 0 2px rgba(0,0,0,0.1);border-color:", ";"], getColor('gray180'))), ifProp('checked', css$1([":before{content:'';width:8px;height:8px;top:50%;transform:translateY(-50%);left:4px;border-radius:50%;position:absolute;background-color:", ";}"], getColor('gray90'))));
|
|
6766
|
+
var TextLabel$1 = styled.span.withConfig({
|
|
6775
6767
|
displayName: "SimpleRadiobox__TextLabel",
|
|
6776
6768
|
componentId: "qv83xo-1"
|
|
6777
6769
|
})(["font-size:13px;line-height:16px;margin:2px 0.25rem 2px 0;display:block;"]);
|
|
6778
|
-
var DescText$3 =
|
|
6770
|
+
var DescText$3 = styled.div.withConfig({
|
|
6779
6771
|
displayName: "SimpleRadiobox__DescText",
|
|
6780
6772
|
componentId: "qv83xo-2"
|
|
6781
6773
|
})(["color:rgba(0,0,0,0.4);display:block;font-size:12px;font-weight:400;"]);
|
|
6782
|
-
var TextLabelContainer$1 =
|
|
6774
|
+
var TextLabelContainer$1 = styled.div.withConfig({
|
|
6783
6775
|
displayName: "SimpleRadiobox__TextLabelContainer",
|
|
6784
6776
|
componentId: "qv83xo-3"
|
|
6785
6777
|
})(["display:flex;align-items:center;position:relative;flex-wrap:wrap;"]);
|
|
6786
|
-
var RadioboxContent =
|
|
6778
|
+
var RadioboxContent = styled.div.withConfig({
|
|
6787
6779
|
displayName: "SimpleRadiobox__RadioboxContent",
|
|
6788
6780
|
componentId: "qv83xo-4"
|
|
6789
6781
|
})(["cursor:pointer;position:relative;padding-left:2rem;transition:background 0.2s linear;", ""], function (props) {
|
|
6790
|
-
return props.framed &&
|
|
6791
|
-
return props.hasErrors &&
|
|
6782
|
+
return props.framed && css$1(["border:1px solid ", ";border-radius:6px;min-height:3rem;min-width:8rem;background:white;width:100%;align-items:center;display:flex;:hover{background:rgb(245,245,245);}:active{background:rgb(235,235,235);transition:none;}padding:10px 12px 10px 32px;", " ", " ", " ", " ", ""], getColor('gray210'), media.desktop(_templateObject$9()), function (props) {
|
|
6783
|
+
return props.hasErrors && css$1(["border-color:", " !important;"], getColor('alert'));
|
|
6792
6784
|
}, function (props) {
|
|
6793
|
-
return props.checked && props.highlightSelected &&
|
|
6794
|
-
return
|
|
6785
|
+
return props.checked && props.highlightSelected && css$1(["border-color:", ";background:", ";:hover{background:", ";}", "{:before{background-color:", ";}}"], getColor('main'), function (props) {
|
|
6786
|
+
return desaturate(0.3, lighten(0.52, getColor("main")(props)));
|
|
6795
6787
|
}, function (props) {
|
|
6796
|
-
return
|
|
6797
|
-
}, CssCircle,
|
|
6788
|
+
return desaturate(0.3, lighten(0.52, getColor("main")(props)));
|
|
6789
|
+
}, CssCircle, getColor('main'));
|
|
6798
6790
|
}, function (props) {
|
|
6799
|
-
return props.checked && props.ultraHighlightSelected &&
|
|
6791
|
+
return props.checked && props.ultraHighlightSelected && css$1(["border-color:", ";background:", ";color:white;:hover{background:", ";}", "{:before{background-color:", ";}}", "{color:rgba(255,255,255,0.65);}", "{color:rgba(255,255,255,0.65);}"], getColor('main'), getColor('main'), getColor('main'), CssCircle, getColor('main'), HelpText$1, DescText$3);
|
|
6800
6792
|
}, function (props) {
|
|
6801
|
-
return props.disabled &&
|
|
6793
|
+
return props.disabled && css$1(["background-color:rgba(0,0,0,0.075) !important;&[disabled]{opacity:0.75 !important;}", "{background:rgba(255,255,255,0.25);}"], CssCircle);
|
|
6802
6794
|
});
|
|
6803
6795
|
});
|
|
6804
|
-
var SimpleRadiobox =
|
|
6805
|
-
return
|
|
6796
|
+
var SimpleRadiobox = styled(function (props) {
|
|
6797
|
+
return React.createElement(Radiobox$1, props, function (_ref) {
|
|
6806
6798
|
var disabled = _ref.disabled,
|
|
6807
6799
|
checked = _ref.checked,
|
|
6808
6800
|
hasErrors = _ref.hasErrors,
|
|
@@ -6811,44 +6803,44 @@ var SimpleRadiobox = styled__default(function (props) {
|
|
|
6811
6803
|
framedBoxes = _ref.framedBoxes,
|
|
6812
6804
|
highlightSelected = _ref.highlightSelected,
|
|
6813
6805
|
ultraHighlightSelected = _ref.ultraHighlightSelected;
|
|
6814
|
-
return
|
|
6806
|
+
return React.createElement(RadioboxContent, {
|
|
6815
6807
|
checked: checked,
|
|
6816
6808
|
framed: props.framedBoxes,
|
|
6817
6809
|
highlightSelected: props.highlightSelected,
|
|
6818
6810
|
ultraHighlightSelected: props.ultraHighlightSelected,
|
|
6819
6811
|
hasErrors: hasErrors,
|
|
6820
6812
|
disabled: disabled
|
|
6821
|
-
},
|
|
6813
|
+
}, React.createElement("div", {
|
|
6822
6814
|
className: "textContainer"
|
|
6823
|
-
},
|
|
6815
|
+
}, React.createElement(TextLabelContainer$1, null, React.createElement(CssCircle, {
|
|
6824
6816
|
checked: checked,
|
|
6825
6817
|
focused: focused,
|
|
6826
6818
|
tabIndex: tabIndex
|
|
6827
|
-
}),
|
|
6819
|
+
}), React.createElement(TextLabel$1, null, props.label), props.helpText && React.createElement(HelpText$1, null, " ", props.helpText)), props.descText && React.createElement(DescText$3, null, props.descText)));
|
|
6828
6820
|
});
|
|
6829
6821
|
}).withConfig({
|
|
6830
6822
|
displayName: "SimpleRadiobox",
|
|
6831
6823
|
componentId: "qv83xo-5"
|
|
6832
|
-
})(["cursor:pointer;position:relative;margin-bottom:1rem;display:flex;", " .textContainer{width:100%;}"],
|
|
6824
|
+
})(["cursor:pointer;position:relative;margin-bottom:1rem;display:flex;", " .textContainer{width:100%;}"], ifProp('disabled', css$1(["pointer-events:none;"])));
|
|
6833
6825
|
|
|
6834
6826
|
var useDraftConfirmation = function useDraftConfirmation(submit, discard, meta) {
|
|
6835
|
-
var loading =
|
|
6836
|
-
var dialog =
|
|
6837
|
-
var draft =
|
|
6838
|
-
var promiseResolver =
|
|
6839
|
-
var startlibs =
|
|
6827
|
+
var loading = useToggle();
|
|
6828
|
+
var dialog = useToggle();
|
|
6829
|
+
var draft = useRefToggle();
|
|
6830
|
+
var promiseResolver = useRefState();
|
|
6831
|
+
var startlibs = useContext(StartlibsContext);
|
|
6840
6832
|
|
|
6841
6833
|
var confirmation = function confirmation() {
|
|
6842
6834
|
var dialogType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'submit-draft';
|
|
6843
6835
|
var callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
6844
6836
|
|
|
6845
|
-
if (
|
|
6837
|
+
if (callIfFunction(draft.isOpen)) {
|
|
6846
6838
|
dialog.openWith(dialogType);
|
|
6847
6839
|
return new Promise(function (res) {
|
|
6848
6840
|
return promiseResolver.set(function () {
|
|
6849
6841
|
return function (r) {
|
|
6850
6842
|
dialog.close();
|
|
6851
|
-
|
|
6843
|
+
callIfFunction(callback, r);
|
|
6852
6844
|
res(r);
|
|
6853
6845
|
};
|
|
6854
6846
|
});
|
|
@@ -6874,7 +6866,7 @@ var useDraftConfirmation = function useDraftConfirmation(submit, discard, meta)
|
|
|
6874
6866
|
return submit();
|
|
6875
6867
|
|
|
6876
6868
|
case 4:
|
|
6877
|
-
|
|
6869
|
+
callIfFunction(promiseResolver.get());
|
|
6878
6870
|
_context.next = 9;
|
|
6879
6871
|
break;
|
|
6880
6872
|
|
|
@@ -6902,8 +6894,8 @@ var useDraftConfirmation = function useDraftConfirmation(submit, discard, meta)
|
|
|
6902
6894
|
}();
|
|
6903
6895
|
|
|
6904
6896
|
var discardAndResolve = function discardAndResolve() {
|
|
6905
|
-
|
|
6906
|
-
|
|
6897
|
+
callIfFunction(discard);
|
|
6898
|
+
callIfFunction(promiseResolver.get());
|
|
6907
6899
|
};
|
|
6908
6900
|
|
|
6909
6901
|
var Dialog = startlibs.dialogs[dialog.isOpen];
|
|
@@ -6914,7 +6906,7 @@ var useDraftConfirmation = function useDraftConfirmation(submit, discard, meta)
|
|
|
6914
6906
|
}
|
|
6915
6907
|
}
|
|
6916
6908
|
|
|
6917
|
-
var feedback = dialog.isOpen ?
|
|
6909
|
+
var feedback = dialog.isOpen ? React.createElement(Dialog, _extends({
|
|
6918
6910
|
submit: submitAndResolve,
|
|
6919
6911
|
discard: discardAndResolve,
|
|
6920
6912
|
isLoading: loading.isOpen,
|
|
@@ -7001,7 +6993,7 @@ var buildValidation = function buildValidation(validations) {
|
|
|
7001
6993
|
v = _ref4[1];
|
|
7002
6994
|
|
|
7003
6995
|
return v.length;
|
|
7004
|
-
}), _fromPairs)(
|
|
6996
|
+
}), _fromPairs)(callIfFunction(validations)), callIfFunction(custom, values)));
|
|
7005
6997
|
};
|
|
7006
6998
|
};
|
|
7007
6999
|
var buildAsyncValidation = function buildAsyncValidation(validations) {
|
|
@@ -7055,7 +7047,7 @@ var buildAsyncValidation = function buildAsyncValidation(validations) {
|
|
|
7055
7047
|
});
|
|
7056
7048
|
});
|
|
7057
7049
|
_context2.next = 6;
|
|
7058
|
-
return
|
|
7050
|
+
return callIfFunction(validations);
|
|
7059
7051
|
|
|
7060
7052
|
case 6:
|
|
7061
7053
|
_context2.t4 = _context2.sent;
|
|
@@ -7065,7 +7057,7 @@ var buildAsyncValidation = function buildAsyncValidation(validations) {
|
|
|
7065
7057
|
case 9:
|
|
7066
7058
|
_context2.t5 = _context2.sent;
|
|
7067
7059
|
_context2.next = 12;
|
|
7068
|
-
return
|
|
7060
|
+
return callIfFunction(custom, props);
|
|
7069
7061
|
|
|
7070
7062
|
case 12:
|
|
7071
7063
|
_context2.t6 = _context2.sent;
|
|
@@ -7117,91 +7109,4 @@ var validation = {
|
|
|
7117
7109
|
responseFailure: responseFailure
|
|
7118
7110
|
};
|
|
7119
7111
|
|
|
7120
|
-
|
|
7121
|
-
exports.AutoCompleteTextbox = AutoCompleteTextbox;
|
|
7122
|
-
exports.BellowFieldDescription = BellowFieldDescription;
|
|
7123
|
-
exports.CALENDAR_LEVEL_DAY = CALENDAR_LEVEL_DAY;
|
|
7124
|
-
exports.CALENDAR_LEVEL_MONTH = CALENDAR_LEVEL_MONTH;
|
|
7125
|
-
exports.CALENDAR_LEVEL_YEAR = CALENDAR_LEVEL_YEAR;
|
|
7126
|
-
exports.Checkbox = Checkbox;
|
|
7127
|
-
exports.CheckboxGroup = CheckboxGroup;
|
|
7128
|
-
exports.CleanTabRadiobox = CleanTabRadiobox;
|
|
7129
|
-
exports.Combobox = Combobox;
|
|
7130
|
-
exports.ComboboxInput = ComboboxInput;
|
|
7131
|
-
exports.ComboboxMenu = ComboboxMenu;
|
|
7132
|
-
exports.ComboboxWithCustom = ComboboxWithCustom;
|
|
7133
|
-
exports.ComponentMetaContext = ComponentMetaContext;
|
|
7134
|
-
exports.ConfirmDialog = ConfirmDialog;
|
|
7135
|
-
exports.ConfirmEditableBoxes = ConfirmEditableBoxes;
|
|
7136
|
-
exports.DatePicker = DatePicker;
|
|
7137
|
-
exports.EditableBox = EditableBox;
|
|
7138
|
-
exports.EnhanceInput = EnhanceInput;
|
|
7139
|
-
exports.ErrorFilterProvider = ErrorFilterProvider;
|
|
7140
|
-
exports.Errors = Errors;
|
|
7141
|
-
exports.ErrorsContext = ErrorsContext;
|
|
7142
|
-
exports.ExpandableBox = ExpandableBox;
|
|
7143
|
-
exports.Field = Field;
|
|
7144
|
-
exports.FieldBox = FieldBox;
|
|
7145
|
-
exports.FieldBoxAction = FieldBoxAction;
|
|
7146
|
-
exports.FieldBoxHelpText = FieldBoxHelpText;
|
|
7147
|
-
exports.FieldBoxIcon = FieldBoxIcon;
|
|
7148
|
-
exports.FieldDescription = FieldDescription;
|
|
7149
|
-
exports.FileInput = FileInput;
|
|
7150
|
-
exports.FloatLabelTextInput = FloatLabelTextInput;
|
|
7151
|
-
exports.Form = Form;
|
|
7152
|
-
exports.FormContext = FormContext;
|
|
7153
|
-
exports.FormDialog = FormDialog;
|
|
7154
|
-
exports.FormMeta = FormMeta;
|
|
7155
|
-
exports.FormValue = FormValue;
|
|
7156
|
-
exports.HelpText = HelpText;
|
|
7157
|
-
exports.IconRadioBox = IconRadioBox;
|
|
7158
|
-
exports.IconRadioBoxIconContainer = IconRadioBoxIconContainer;
|
|
7159
|
-
exports.IconRadioBoxText = IconRadioBoxText;
|
|
7160
|
-
exports.IfFormMeta = IfFormMeta;
|
|
7161
|
-
exports.IfFormValue = IfFormValue;
|
|
7162
|
-
exports.IfFormValueUpdate = IfFormValueUpdate;
|
|
7163
|
-
exports.InputboxGroup = InputboxGroup;
|
|
7164
|
-
exports.LazyFormValues = LazyFormValues;
|
|
7165
|
-
exports.NO_DIGITABLE_FOUND = NO_DIGITABLE_FOUND;
|
|
7166
|
-
exports.Option = Option;
|
|
7167
|
-
exports.PathContext = PathContext;
|
|
7168
|
-
exports.PseudoExpandableBox = PseudoExpandableBox;
|
|
7169
|
-
exports.Radiobox = Radiobox;
|
|
7170
|
-
exports.RadioboxGroup = RadioboxGroup;
|
|
7171
|
-
exports.RichText = RichText;
|
|
7172
|
-
exports.RichTextContainer = RichTextContainer;
|
|
7173
|
-
exports.RichTextInput = RichTextInput;
|
|
7174
|
-
exports.SEPARATOR = SEPARATOR;
|
|
7175
|
-
exports.SimpleCheckbox = SimpleCheckbox;
|
|
7176
|
-
exports.SimpleRadiobox = SimpleRadiobox;
|
|
7177
|
-
exports.SwitchOnFormValue = SwitchOnFormValue;
|
|
7178
|
-
exports.Tab = Tab;
|
|
7179
|
-
exports.TabButton = TabButton;
|
|
7180
|
-
exports.TabRadiobox = TabRadiobox;
|
|
7181
|
-
exports.TextInput = TextInput;
|
|
7182
|
-
exports.ToggleCheckbox = ToggleCheckbox;
|
|
7183
|
-
exports.WithFileInput = WithFileInput;
|
|
7184
|
-
exports.WithForm = WithForm;
|
|
7185
|
-
exports.WithImageInput = WithImageInput;
|
|
7186
|
-
exports.checkErrors = checkErrors;
|
|
7187
|
-
exports.enhanceInput = enhanceInput;
|
|
7188
|
-
exports.enhancedInputDisplayName = enhancedInputDisplayName;
|
|
7189
|
-
exports.getFormResponse = getFormResponse;
|
|
7190
|
-
exports.getFormValues = getFormValues;
|
|
7191
|
-
exports.useConfirmDialog = useConfirmDialog;
|
|
7192
|
-
exports.useConfirmDialogWithProps = useConfirmDialogWithProps;
|
|
7193
|
-
exports.useDraftConfirmation = useDraftConfirmation;
|
|
7194
|
-
exports.useErrors = useErrors;
|
|
7195
|
-
exports.useErrorsUtils = useErrorsUtils;
|
|
7196
|
-
exports.useForm = useForm;
|
|
7197
|
-
exports.useFormMeta = useFormMeta;
|
|
7198
|
-
exports.useFormValue = useFormValue;
|
|
7199
|
-
exports.useFormValueRef = useFormValueRef;
|
|
7200
|
-
exports.useHasError = useHasError;
|
|
7201
|
-
exports.useInput = useInput;
|
|
7202
|
-
exports.useProvideErrors = useProvideErrors;
|
|
7203
|
-
exports.useTextInput = useTextInput;
|
|
7204
|
-
exports.useTransientErrorHelper = useTransientErrorHelper;
|
|
7205
|
-
exports.validation = validation;
|
|
7206
|
-
exports.withForm = withForm;
|
|
7207
|
-
exports.withForm2 = withForm2;
|
|
7112
|
+
export { AutoComplete, AutoCompleteTextbox, BellowFieldDescription, CALENDAR_LEVEL_DAY, CALENDAR_LEVEL_MONTH, CALENDAR_LEVEL_YEAR, Checkbox, CheckboxGroup, CleanTabRadiobox, Combobox, ComboboxInput, ComboboxMenu, ComboboxWithCustom, ComponentMetaContext, ConfirmDialog, ConfirmEditableBoxes, DatePicker, EditableBox, EnhanceInput, ErrorFilterProvider, Errors, ErrorsContext, ExpandableBox, Field, FieldBox, FieldBoxAction, FieldBoxHelpText, FieldBoxIcon, FieldDescription, FileInput, FloatLabelTextInput, Form, FormContext, FormDialog, FormMeta, FormValue, HelpText, IconRadioBox, IconRadioBoxIconContainer, IconRadioBoxText, IfFormMeta, IfFormValue, IfFormValueUpdate, InputboxGroup, LazyFormValues, NO_DIGITABLE_FOUND, Option, PathContext, PseudoExpandableBox, Radiobox, RadioboxGroup, RichText, RichTextContainer, RichTextInput, SEPARATOR, SimpleCheckbox, SimpleRadiobox, SwitchOnFormValue, Tab, TabButton, TabRadiobox, TextInput, ToggleCheckbox, WithFileInput, WithForm, WithImageInput, checkErrors, enhanceInput, enhancedInputDisplayName, getFormResponse, getFormValues, useConfirmDialog, useConfirmDialogWithProps, useDraftConfirmation, useErrors, useErrorsUtils, useForm, useFormMeta, useFormValue, useFormValueRef, useHasError, useInput, useProvideErrors, useTextInput, useTransientErrorHelper, validation, withForm, withForm2 };
|