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