@startlibs/form 1.0.0-alpha-10c → 1.0.0-alpha-10f
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 +106 -258
- package/package.json +3 -4
package/lib/index.js
CHANGED
|
@@ -44,14 +44,10 @@ var _filter = _interopDefault(require('lodash/fp/filter'));
|
|
|
44
44
|
var _map = _interopDefault(require('lodash/fp/map'));
|
|
45
45
|
var _stubFalse = _interopDefault(require('lodash/fp/stubFalse'));
|
|
46
46
|
var _isObject = _interopDefault(require('lodash/fp/isObject'));
|
|
47
|
-
require('@babel/runtime/helpers/awaitAsyncGenerator');
|
|
48
|
-
require('@babel/runtime/helpers/wrapAsyncGenerator');
|
|
49
|
-
var _ = _interopDefault(require('lodash/fp'));
|
|
50
|
-
require('@babel/runtime/helpers/typeof');
|
|
51
|
-
var createEmotion = _interopDefault(require('create-emotion'));
|
|
52
47
|
var _isFinite = _interopDefault(require('lodash/fp/isFinite'));
|
|
53
48
|
var _negate = _interopDefault(require('lodash/fp/negate'));
|
|
54
49
|
var _zipObject = _interopDefault(require('lodash/fp/zipObject'));
|
|
50
|
+
var _last = _interopDefault(require('lodash/fp/last'));
|
|
55
51
|
var _flatten = _interopDefault(require('lodash/fp/flatten'));
|
|
56
52
|
var _fromPairs = _interopDefault(require('lodash/fp/fromPairs'));
|
|
57
53
|
var _pick = _interopDefault(require('lodash/fp/pick'));
|
|
@@ -3061,206 +3057,6 @@ var FormMeta = function FormMeta(_ref3) {
|
|
|
3061
3057
|
return utils.ifUndefined(utils.callIfFunction(children, value, setValue), value, null);
|
|
3062
3058
|
};
|
|
3063
3059
|
|
|
3064
|
-
var scrollWidth = function () {
|
|
3065
|
-
if (!window.document) return 0;
|
|
3066
|
-
var html = document.documentElement;
|
|
3067
|
-
var oldOverflow = html.style.overflowY;
|
|
3068
|
-
html.style.overflowY = 'scroll';
|
|
3069
|
-
var width = window.innerWidth - html.clientWidth;
|
|
3070
|
-
html.style.overflowY = oldOverflow;
|
|
3071
|
-
return width;
|
|
3072
|
-
}();
|
|
3073
|
-
|
|
3074
|
-
var callIfFunction = function callIfFunction(prop) {
|
|
3075
|
-
for (var _len6 = arguments.length, args = new Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) {
|
|
3076
|
-
args[_key6 - 1] = arguments[_key6];
|
|
3077
|
-
}
|
|
3078
|
-
|
|
3079
|
-
return typeof prop === "function" ? prop.apply(void 0, args) : prop;
|
|
3080
|
-
};
|
|
3081
|
-
|
|
3082
|
-
var moveElement = _.curry(function (from, to, list) {
|
|
3083
|
-
var el = list[from];
|
|
3084
|
-
|
|
3085
|
-
var without = _.pullAt(from, list);
|
|
3086
|
-
|
|
3087
|
-
without.splice(to, 0, el);
|
|
3088
|
-
return without;
|
|
3089
|
-
});
|
|
3090
|
-
var unsetOrRemoveAt = _.curry(function (path, value) {
|
|
3091
|
-
var pathArr = toPath(path);
|
|
3092
|
-
|
|
3093
|
-
var _pathArr$slice = pathArr.slice(-1),
|
|
3094
|
-
_pathArr$slice2 = _slicedToArray(_pathArr$slice, 1),
|
|
3095
|
-
lastKey = _pathArr$slice2[0];
|
|
3096
|
-
|
|
3097
|
-
return update(pathArr.slice(0, -1), function (v) {
|
|
3098
|
-
return Array.isArray(v) ? removeAt(lastKey, v) : unset(lastKey, v);
|
|
3099
|
-
}, value);
|
|
3100
|
-
});
|
|
3101
|
-
|
|
3102
|
-
var sanitizePath = function sanitizePath(path) {
|
|
3103
|
-
return Array.isArray(path) ? path.map(sanitizePath) : typeof path === 'number' ? path.toString() : path === undefined ? [] : path;
|
|
3104
|
-
};
|
|
3105
|
-
|
|
3106
|
-
var toPath = function toPath(path) {
|
|
3107
|
-
return _.toPath(sanitizePath(path));
|
|
3108
|
-
};
|
|
3109
|
-
|
|
3110
|
-
var isEmptyPath = function isEmptyPath(path) {
|
|
3111
|
-
return path && !path.length;
|
|
3112
|
-
};
|
|
3113
|
-
|
|
3114
|
-
var update = _.curry(function (path, updater, state) {
|
|
3115
|
-
var sanitizedPath = sanitizePath(path);
|
|
3116
|
-
|
|
3117
|
-
if (isEmptyPath(sanitizedPath)) {
|
|
3118
|
-
return updater(state);
|
|
3119
|
-
} else {
|
|
3120
|
-
return _.update(sanitizedPath, updater, state);
|
|
3121
|
-
}
|
|
3122
|
-
});
|
|
3123
|
-
var get = _.curry(function (path, state) {
|
|
3124
|
-
var sanitizedPath = sanitizePath(path);
|
|
3125
|
-
|
|
3126
|
-
if (isEmptyPath(sanitizedPath)) {
|
|
3127
|
-
return state;
|
|
3128
|
-
} else {
|
|
3129
|
-
return _.get(sanitizedPath, state);
|
|
3130
|
-
}
|
|
3131
|
-
});
|
|
3132
|
-
var set = _.curry(function (path, value, state) {
|
|
3133
|
-
var sanitizedPath = sanitizePath(path);
|
|
3134
|
-
|
|
3135
|
-
if (isEmptyPath(sanitizedPath)) {
|
|
3136
|
-
return value;
|
|
3137
|
-
} else {
|
|
3138
|
-
return _.set(sanitizedPath, value, state);
|
|
3139
|
-
}
|
|
3140
|
-
});
|
|
3141
|
-
var unset = _.curry(function (path, state) {
|
|
3142
|
-
var sanitizedPath = sanitizePath(path);
|
|
3143
|
-
|
|
3144
|
-
if (isEmptyPath(sanitizedPath)) {
|
|
3145
|
-
return undefined;
|
|
3146
|
-
} else {
|
|
3147
|
-
return _.unset(sanitizedPath, state);
|
|
3148
|
-
}
|
|
3149
|
-
});
|
|
3150
|
-
var removeNAt = _.curry(function (pos, n, value) {
|
|
3151
|
-
return _toConsumableArray(value.slice(0, Number(pos))).concat(_toConsumableArray(value.slice(Number(pos) + n)));
|
|
3152
|
-
});
|
|
3153
|
-
var removeAt = removeNAt(_.__, 1);
|
|
3154
|
-
var when = _.curry(function (cond, fn, value) {
|
|
3155
|
-
return callIfFunction(cond, value) ? fn(value) : value;
|
|
3156
|
-
});
|
|
3157
|
-
var assign = _.curry(function (a, b) {
|
|
3158
|
-
return _.assign(b, a);
|
|
3159
|
-
});
|
|
3160
|
-
var concat = _.curry(function (a, b) {
|
|
3161
|
-
return _.concat(b, a);
|
|
3162
|
-
});
|
|
3163
|
-
var each = _.each.convert({
|
|
3164
|
-
cap: false
|
|
3165
|
-
});
|
|
3166
|
-
var find = _.find.convert({
|
|
3167
|
-
cap: false
|
|
3168
|
-
});
|
|
3169
|
-
var filter = _.filter.convert({
|
|
3170
|
-
cap: false
|
|
3171
|
-
});
|
|
3172
|
-
var map = _.map.convert({
|
|
3173
|
-
cap: false
|
|
3174
|
-
});
|
|
3175
|
-
var insertAt = _.curry(function (pos, newElements, value) {
|
|
3176
|
-
return _toConsumableArray(value.slice(0, pos).concat(newElements)).concat(_toConsumableArray(value.slice(pos)));
|
|
3177
|
-
});
|
|
3178
|
-
|
|
3179
|
-
function _templateObject$3() {
|
|
3180
|
-
var data = _taggedTemplateLiteral(["\n ", ""]);
|
|
3181
|
-
|
|
3182
|
-
_templateObject$3 = function _templateObject() {
|
|
3183
|
-
return data;
|
|
3184
|
-
};
|
|
3185
|
-
|
|
3186
|
-
return data;
|
|
3187
|
-
}
|
|
3188
|
-
|
|
3189
|
-
var checkCustomScreenWidth = function checkCustomScreenWidth(sizeParis, customWidth) {
|
|
3190
|
-
var currentWidth = callIfFunction(customWidth);
|
|
3191
|
-
return !sizeParis.find(function (_ref4) {
|
|
3192
|
-
var _ref5 = _slicedToArray(_ref4, 2),
|
|
3193
|
-
size = _ref5[0],
|
|
3194
|
-
type = _ref5[1];
|
|
3195
|
-
|
|
3196
|
-
if (type === "min-width") {
|
|
3197
|
-
return currentWidth < size;
|
|
3198
|
-
}
|
|
3199
|
-
|
|
3200
|
-
if (type === "max-width") {
|
|
3201
|
-
return currentWidth > size;
|
|
3202
|
-
}
|
|
3203
|
-
});
|
|
3204
|
-
};
|
|
3205
|
-
|
|
3206
|
-
var media = function media() {
|
|
3207
|
-
for (var _len3 = arguments.length, sizePairs = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
3208
|
-
sizePairs[_key3] = arguments[_key3];
|
|
3209
|
-
}
|
|
3210
|
-
|
|
3211
|
-
return function () {
|
|
3212
|
-
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
3213
|
-
args[_key4] = arguments[_key4];
|
|
3214
|
-
}
|
|
3215
|
-
|
|
3216
|
-
return styled.css(["", ""], function (props) {
|
|
3217
|
-
var _props$theme, _props$theme2;
|
|
3218
|
-
|
|
3219
|
-
return ((_props$theme = props.theme) === null || _props$theme === void 0 ? void 0 : _props$theme.overrideMediaWidth) ? checkCustomScreenWidth(sizePairs, (_props$theme2 = props.theme) === null || _props$theme2 === void 0 ? void 0 : _props$theme2.overrideMediaWidth) ? styled.css.apply(void 0, args) : "" : styled.css(["@media ", "{", "}"], sizePairs.map(function (_ref6) {
|
|
3220
|
-
var _ref7 = _slicedToArray(_ref6, 2),
|
|
3221
|
-
size = _ref7[0],
|
|
3222
|
-
type = _ref7[1];
|
|
3223
|
-
|
|
3224
|
-
return "(".concat(type, ": ").concat(size + scrollWidth, "px)");
|
|
3225
|
-
}).join(' and '), styled.css.apply(void 0, args));
|
|
3226
|
-
});
|
|
3227
|
-
};
|
|
3228
|
-
};
|
|
3229
|
-
media.mobile = media([600, 'max-width']);
|
|
3230
|
-
|
|
3231
|
-
media.between = function (min, max) {
|
|
3232
|
-
return media([min, 'min-width'], [max, 'max-width']);
|
|
3233
|
-
};
|
|
3234
|
-
|
|
3235
|
-
media.max = function (n) {
|
|
3236
|
-
return media([n, 'max-width']);
|
|
3237
|
-
};
|
|
3238
|
-
|
|
3239
|
-
media.min = function (n) {
|
|
3240
|
-
return media([n, 'min-width']);
|
|
3241
|
-
};
|
|
3242
|
-
|
|
3243
|
-
media.desktop = media([601, 'min-width']);
|
|
3244
|
-
|
|
3245
|
-
var getFrameOffset = function getFrameOffset(i, total) {
|
|
3246
|
-
return Math.round(i * 100 / (total - 1));
|
|
3247
|
-
};
|
|
3248
|
-
|
|
3249
|
-
var emotion = createEmotion({
|
|
3250
|
-
nonce: __webpack_nonce__
|
|
3251
|
-
});
|
|
3252
|
-
var oneWayAnimation = function oneWayAnimation() {
|
|
3253
|
-
for (var _len5 = arguments.length, frames = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
3254
|
-
frames[_key5] = arguments[_key5];
|
|
3255
|
-
}
|
|
3256
|
-
|
|
3257
|
-
return emotion.keyframes(_templateObject$3(), frames.map(function (frame, i) {
|
|
3258
|
-
return !frame ? '' : "".concat(getFrameOffset(i, frames.length), "% {\n ").concat(frame, "\n }");
|
|
3259
|
-
}));
|
|
3260
|
-
};
|
|
3261
|
-
var identityTranslateFrames = oneWayAnimation('transform: translateY(0);', 'transform: translateY(0);');
|
|
3262
|
-
var identityOpacityFrames = oneWayAnimation('opacity: 1;', 'opacity:1;');
|
|
3263
|
-
|
|
3264
3060
|
var addRootPath = function addRootPath(errorRootPath, errors, path) {
|
|
3265
3061
|
var rootPath = [].concat(errorRootPath || [], path);
|
|
3266
3062
|
return Object.keys(errors).reduce(function (acc, error) {
|
|
@@ -3371,7 +3167,7 @@ var ConfirmEditableBoxes = React.forwardRef(function (_ref, ref) {
|
|
|
3371
3167
|
|
|
3372
3168
|
var modifiedEditablesPath = function modifiedEditablesPath(boxes) {
|
|
3373
3169
|
return modifiedEditableBoxes(boxes).map(function (_) {
|
|
3374
|
-
return _.path;
|
|
3170
|
+
return utils.callIfFunction(_.path);
|
|
3375
3171
|
});
|
|
3376
3172
|
};
|
|
3377
3173
|
|
|
@@ -3399,7 +3195,7 @@ var ConfirmEditableBoxes = React.forwardRef(function (_ref, ref) {
|
|
|
3399
3195
|
var validated = modifiedEditableBoxes(sharedBoxes()).reduce(function (_ref5, box) {
|
|
3400
3196
|
var success = _ref5.success,
|
|
3401
3197
|
errors = _ref5.errors;
|
|
3402
|
-
var index = box.path;
|
|
3198
|
+
var index = utils.callIfFunction(box.path);
|
|
3403
3199
|
|
|
3404
3200
|
var _box$modifiedValue = box.modifiedValue(),
|
|
3405
3201
|
_box$modifiedValue2 = _slicedToArray(_box$modifiedValue, 2),
|
|
@@ -3699,18 +3495,38 @@ var EditableBoxPresentation = styled__default(React.forwardRef(function (_ref13,
|
|
|
3699
3495
|
var SharedEditableTabBox = function SharedEditableTabBox(_ref15) {
|
|
3700
3496
|
var path = _ref15.path,
|
|
3701
3497
|
isSingle = _ref15.isSingle,
|
|
3702
|
-
|
|
3498
|
+
_ref15$checkIsNew = _ref15.checkIsNew,
|
|
3499
|
+
checkIsNew = _ref15$checkIsNew === void 0 ? function (a, b) {
|
|
3500
|
+
return a !== b;
|
|
3501
|
+
} : _ref15$checkIsNew,
|
|
3502
|
+
props = _objectWithoutProperties(_ref15, ["path", "isSingle", "checkIsNew"]);
|
|
3703
3503
|
|
|
3704
3504
|
var editableGroup = React.useContext(EditableContext);
|
|
3705
3505
|
var form = React.useContext(FormContext);
|
|
3706
|
-
var isNew = core.useRefState(
|
|
3506
|
+
var isNew = core.useRefState(function () {
|
|
3507
|
+
return isSingle ? false : checkIsNew(utils._s.get(path, form.getOriginalValues()), form.getValue(path));
|
|
3508
|
+
});
|
|
3707
3509
|
var internalBox = React__default.useRef();
|
|
3510
|
+
var pathRef = core.useRefMemo(path);
|
|
3708
3511
|
|
|
3709
3512
|
var loading = function loading() {
|
|
3710
3513
|
return internalBox.current.loading;
|
|
3711
3514
|
};
|
|
3712
3515
|
|
|
3713
|
-
var
|
|
3516
|
+
var modifiedValue = function modifiedValue() {
|
|
3517
|
+
var oldItem = internalBox.current.getValue(undefined, form.getOriginalValues());
|
|
3518
|
+
var newItem = internalBox.current.getValue();
|
|
3519
|
+
return newItem !== oldItem ? [newItem, true] : [oldItem, false];
|
|
3520
|
+
};
|
|
3521
|
+
|
|
3522
|
+
var selfRef = React.useRef({
|
|
3523
|
+
loading: loading,
|
|
3524
|
+
path: function path() {
|
|
3525
|
+
return pathRef.current;
|
|
3526
|
+
},
|
|
3527
|
+
form: form,
|
|
3528
|
+
modifiedValue: modifiedValue
|
|
3529
|
+
});
|
|
3714
3530
|
|
|
3715
3531
|
var resetField = function resetField() {
|
|
3716
3532
|
return form.resetField([].concat(path));
|
|
@@ -3730,12 +3546,6 @@ var SharedEditableTabBox = function SharedEditableTabBox(_ref15) {
|
|
|
3730
3546
|
editableGroup.sharedBoxes.register(selfRef.current);
|
|
3731
3547
|
};
|
|
3732
3548
|
|
|
3733
|
-
var modifiedValue = function modifiedValue() {
|
|
3734
|
-
var oldItem = internalBox.current.getValue(undefined, form.getOriginalValues());
|
|
3735
|
-
var newItem = internalBox.current.getValue();
|
|
3736
|
-
return newItem !== oldItem ? [newItem, true] : [oldItem, false];
|
|
3737
|
-
};
|
|
3738
|
-
|
|
3739
3549
|
var validate = function validate(props, path) {
|
|
3740
3550
|
var errors = editableGroup.itemValidation(props, path);
|
|
3741
3551
|
|
|
@@ -3826,12 +3636,6 @@ var SharedEditableTabBox = function SharedEditableTabBox(_ref15) {
|
|
|
3826
3636
|
}
|
|
3827
3637
|
};
|
|
3828
3638
|
|
|
3829
|
-
selfRef.current = {
|
|
3830
|
-
loading: loading,
|
|
3831
|
-
path: path,
|
|
3832
|
-
form: form,
|
|
3833
|
-
modifiedValue: modifiedValue
|
|
3834
|
-
};
|
|
3835
3639
|
return React__default.createElement(EditableBoxPresentation, _extends({
|
|
3836
3640
|
ref: internalBox,
|
|
3837
3641
|
resetField: resetField,
|
|
@@ -3855,7 +3659,6 @@ var EditableBox = function EditableBox(_ref17) {
|
|
|
3855
3659
|
|
|
3856
3660
|
var editableGroup = React.useContext(EditableContext);
|
|
3857
3661
|
var form = React.useContext(FormContext);
|
|
3858
|
-
var selfRef = React.useRef();
|
|
3859
3662
|
var internalBox = React__default.useRef();
|
|
3860
3663
|
|
|
3861
3664
|
var resetField = function resetField() {
|
|
@@ -3908,14 +3711,17 @@ var EditableBox = function EditableBox(_ref17) {
|
|
|
3908
3711
|
return internalBox.current.loading;
|
|
3909
3712
|
};
|
|
3910
3713
|
|
|
3911
|
-
|
|
3714
|
+
var pathRef = core.useRefMemo(path);
|
|
3715
|
+
var selfRef = React.useRef({
|
|
3912
3716
|
loading: loading,
|
|
3913
|
-
path: path
|
|
3717
|
+
path: function path() {
|
|
3718
|
+
return pathRef.current;
|
|
3719
|
+
},
|
|
3914
3720
|
form: form,
|
|
3915
3721
|
modifiedValue: modifiedValue,
|
|
3916
3722
|
handleSubmit: handleSubmit,
|
|
3917
3723
|
close: close
|
|
3918
|
-
};
|
|
3724
|
+
});
|
|
3919
3725
|
return React__default.createElement(EditableBoxPresentation, _extends({
|
|
3920
3726
|
ref: internalBox,
|
|
3921
3727
|
resetField: resetField,
|
|
@@ -3990,10 +3796,10 @@ var Radiobox = function Radiobox(_ref) {
|
|
|
3990
3796
|
}));
|
|
3991
3797
|
};
|
|
3992
3798
|
|
|
3993
|
-
function _templateObject$
|
|
3799
|
+
function _templateObject$3() {
|
|
3994
3800
|
var data = _taggedTemplateLiteral(["\n padding: 7px 12px 7px 32px;\n "]);
|
|
3995
3801
|
|
|
3996
|
-
_templateObject$
|
|
3802
|
+
_templateObject$3 = function _templateObject() {
|
|
3997
3803
|
return data;
|
|
3998
3804
|
};
|
|
3999
3805
|
|
|
@@ -4019,7 +3825,7 @@ var CheckboxContent = styled__default.div.withConfig({
|
|
|
4019
3825
|
displayName: "SimpleCheckbox__CheckboxContent",
|
|
4020
3826
|
componentId: "am8pps-4"
|
|
4021
3827
|
})(["cursor:pointer;position:relative;padding-left:2rem;", ""], function (props) {
|
|
4022
|
-
return props.framed && styled.css(["border:1px solid ", ";border-radius:6px;min-height:3rem;min-width:8rem;background:white;:hover{background:rgb(245,245,245);}:active{background:rgb(235,235,235);}padding:10px 12px 10px 32px;", " ", " ", " ", " ", ""], utils.getColor('gray210'), utils.media.desktop(_templateObject$
|
|
3828
|
+
return props.framed && styled.css(["border:1px solid ", ";border-radius:6px;min-height:3rem;min-width:8rem;background:white;:hover{background:rgb(245,245,245);}:active{background:rgb(235,235,235);}padding:10px 12px 10px 32px;", " ", " ", " ", " ", ""], utils.getColor('gray210'), utils.media.desktop(_templateObject$3()), function (props) {
|
|
4023
3829
|
return props.hasErrors && styled.css(["border-color:", " !important;"], utils.getColor('alert'));
|
|
4024
3830
|
}, function (props) {
|
|
4025
3831
|
return props.checked && props.highlightSelected && styled.css(["border-color:", ";background:", ";:hover{background:", ";}", "{", "{color:", ";}}"], utils.getColor('main'), function (props) {
|
|
@@ -4075,10 +3881,10 @@ var SimpleCheckbox = styled__default(function (_ref) {
|
|
|
4075
3881
|
componentId: "am8pps-5"
|
|
4076
3882
|
})(["cursor:pointer;position:relative;margin-bottom:1rem;display:block;", ""], utils.ifProp('disabled', styled.css(["pointer-events:none;"])));
|
|
4077
3883
|
|
|
4078
|
-
function _templateObject$
|
|
3884
|
+
function _templateObject$4() {
|
|
4079
3885
|
var data = _taggedTemplateLiteral(["\n padding: 7px 12px 7px 32px;\n "]);
|
|
4080
3886
|
|
|
4081
|
-
_templateObject$
|
|
3887
|
+
_templateObject$4 = function _templateObject() {
|
|
4082
3888
|
return data;
|
|
4083
3889
|
};
|
|
4084
3890
|
|
|
@@ -4104,7 +3910,7 @@ var RadioboxContent = styled__default.div.withConfig({
|
|
|
4104
3910
|
displayName: "SimpleRadiobox__RadioboxContent",
|
|
4105
3911
|
componentId: "qv83xo-4"
|
|
4106
3912
|
})(["cursor:pointer;position:relative;padding-left:2rem;", ""], function (props) {
|
|
4107
|
-
return props.framed && styled.css(["border:1px solid ", ";border-radius:6px;min-height:3rem;min-width:8rem;background:white;:hover{background:rgb(245,245,245);}:active{background:rgb(235,235,235);}padding:10px 12px 10px 32px;", " ", " ", " ", " ", ""], utils.getColor('gray210'), utils.media.desktop(_templateObject$
|
|
3913
|
+
return props.framed && styled.css(["border:1px solid ", ";border-radius:6px;min-height:3rem;min-width:8rem;background:white;:hover{background:rgb(245,245,245);}:active{background:rgb(235,235,235);}padding:10px 12px 10px 32px;", " ", " ", " ", " ", ""], utils.getColor('gray210'), utils.media.desktop(_templateObject$4()), function (props) {
|
|
4108
3914
|
return props.hasErrors && styled.css(["border-color:", " !important;"], utils.getColor('alert'));
|
|
4109
3915
|
}, function (props) {
|
|
4110
3916
|
return props.checked && props.highlightSelected && styled.css(["border-color:", ";background:", ";:hover{background:", ";}", "{:before{background-color:", ";}}"], utils.getColor('main'), function (props) {
|
|
@@ -4206,10 +4012,10 @@ function _templateObject2$2() {
|
|
|
4206
4012
|
return data;
|
|
4207
4013
|
}
|
|
4208
4014
|
|
|
4209
|
-
function _templateObject$
|
|
4015
|
+
function _templateObject$5() {
|
|
4210
4016
|
var data = _taggedTemplateLiteral(["\n width: 2.5rem;\n "]);
|
|
4211
4017
|
|
|
4212
|
-
_templateObject$
|
|
4018
|
+
_templateObject$5 = function _templateObject() {
|
|
4213
4019
|
return data;
|
|
4214
4020
|
};
|
|
4215
4021
|
|
|
@@ -4222,7 +4028,7 @@ var LEVELS = [DAY, MONTH, YEAR];
|
|
|
4222
4028
|
var DatePickerContainer = styled__default.div.withConfig({
|
|
4223
4029
|
displayName: "DatePicker__DatePickerContainer",
|
|
4224
4030
|
componentId: "sc-1wo8j4d-0"
|
|
4225
|
-
})(["width:20rem;position:absolute;z-index:10;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;}}"], utils.getColor('gray210'), utils.media.mobile(_templateObject$
|
|
4031
|
+
})(["width:20rem;position:absolute;z-index:10;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;}}"], utils.getColor('gray210'), utils.media.mobile(_templateObject$5()));
|
|
4226
4032
|
var CalendarHeader = styled__default.div.withConfig({
|
|
4227
4033
|
displayName: "DatePicker__CalendarHeader",
|
|
4228
4034
|
componentId: "sc-1wo8j4d-1"
|
|
@@ -4895,10 +4701,10 @@ function getClosestNextLeapYear(year) {
|
|
|
4895
4701
|
return y;
|
|
4896
4702
|
}
|
|
4897
4703
|
|
|
4898
|
-
function _templateObject$
|
|
4704
|
+
function _templateObject$6() {
|
|
4899
4705
|
var data = _taggedTemplateLiteral(["\n padding 1rem;\n "]);
|
|
4900
4706
|
|
|
4901
|
-
_templateObject$
|
|
4707
|
+
_templateObject$6 = function _templateObject() {
|
|
4902
4708
|
return data;
|
|
4903
4709
|
};
|
|
4904
4710
|
|
|
@@ -4921,7 +4727,7 @@ var ExpandableBoxStyled = styled__default.div.withConfig({
|
|
|
4921
4727
|
return polished.darken(0.05, utils.getColor("gray240")(props));
|
|
4922
4728
|
}, function (props) {
|
|
4923
4729
|
return polished.darken(0.08, utils.getColor("gray240")(props));
|
|
4924
|
-
}) : styled.css(["padding 1.5rem;", " ", ""], utils.media.max(340)(_templateObject$
|
|
4730
|
+
}) : styled.css(["padding 1.5rem;", " ", ""], utils.media.max(340)(_templateObject$6()), function (props) {
|
|
4925
4731
|
return props.fixMarginBottom && "\n padding-bottom: 0.5rem !important;\n ";
|
|
4926
4732
|
});
|
|
4927
4733
|
}, components.SwitchDiv);
|
|
@@ -5108,10 +4914,10 @@ var FlipDiv$1 = function FlipDiv(_ref3) {
|
|
|
5108
4914
|
}));
|
|
5109
4915
|
};
|
|
5110
4916
|
|
|
5111
|
-
function _templateObject$
|
|
4917
|
+
function _templateObject$7() {
|
|
5112
4918
|
var data = _taggedTemplateLiteral(["\n padding-right: 2.25rem;\n background: rgba(0,0,0,0.075);\n "]);
|
|
5113
4919
|
|
|
5114
|
-
_templateObject$
|
|
4920
|
+
_templateObject$7 = function _templateObject() {
|
|
5115
4921
|
return data;
|
|
5116
4922
|
};
|
|
5117
4923
|
|
|
@@ -5203,7 +5009,7 @@ var RichTextContainer = styled__default.div.withConfig({
|
|
|
5203
5009
|
}, function (props) {
|
|
5204
5010
|
return props.focus && "\n border-color: ".concat(utils.getColor('gray180'), ";\n box-shadow: 0px 0px 0px 2px rgba(0,0,0,0.1);\n ");
|
|
5205
5011
|
}, function (props) {
|
|
5206
|
-
return props.locked && css(_templateObject$
|
|
5012
|
+
return props.locked && css(_templateObject$7());
|
|
5207
5013
|
});
|
|
5208
5014
|
var RichTextInput = styled__default.div.withConfig({
|
|
5209
5015
|
displayName: "RichText__RichTextInput",
|
|
@@ -5322,6 +5128,10 @@ var cleanEditor = function cleanEditor(editor, acceptedTags) {
|
|
|
5322
5128
|
clean(el.childNodes);
|
|
5323
5129
|
el.removeAttribute('class');
|
|
5324
5130
|
|
|
5131
|
+
if (tagName === 'a') {
|
|
5132
|
+
el.setAttribute('target', '_blank');
|
|
5133
|
+
}
|
|
5134
|
+
|
|
5325
5135
|
if (el.getAttribute('style')) {
|
|
5326
5136
|
var usedStyles = _toPairs(_pick(acceptedStyles, el.style)).filter(function (_ref) {
|
|
5327
5137
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
@@ -5504,7 +5314,6 @@ var RichText = function RichText(_ref5) {
|
|
|
5504
5314
|
};
|
|
5505
5315
|
|
|
5506
5316
|
var containerBlur = function containerBlur(e) {
|
|
5507
|
-
// console.log(e.target,e.currentTarget)
|
|
5508
5317
|
if (containerFocused.isOpen !== 1) {
|
|
5509
5318
|
containerFocused.close();
|
|
5510
5319
|
triggerScrollForPanel(Date.now());
|
|
@@ -5521,6 +5330,10 @@ var RichText = function RichText(_ref5) {
|
|
|
5521
5330
|
|
|
5522
5331
|
var keydownHandler = function keydownHandler(e) {
|
|
5523
5332
|
if (containerFocused.isOpen === 2) {
|
|
5333
|
+
if (formatTools.indexOf('link') < 0) {
|
|
5334
|
+
return;
|
|
5335
|
+
}
|
|
5336
|
+
|
|
5524
5337
|
if (e.key === "k" && e.ctrlKey || e.key === "k" && e.metaKey) {
|
|
5525
5338
|
e.preventDefault();
|
|
5526
5339
|
execCommand(null, 'link');
|
|
@@ -5569,17 +5382,23 @@ var RichText = function RichText(_ref5) {
|
|
|
5569
5382
|
_anchor.innerHTML = '​';
|
|
5570
5383
|
|
|
5571
5384
|
if (range.collapsed) {
|
|
5572
|
-
|
|
5385
|
+
range.insertNode(_anchor);
|
|
5573
5386
|
} else {
|
|
5387
|
+
if (range.commonAncestorContainer === input.current) {
|
|
5388
|
+
range.setStart(range.endContainer, 0);
|
|
5389
|
+
}
|
|
5390
|
+
|
|
5574
5391
|
document.execCommand('createLink', false, '_');
|
|
5575
5392
|
_anchor = window.getSelection().anchorNode;
|
|
5576
5393
|
}
|
|
5577
5394
|
|
|
5578
|
-
var _parent =
|
|
5395
|
+
var _parent = range.commonAncestorContainer.nodeType === 3 ? range.commonAncestorContainer.parentNode : range.commonAncestorContainer;
|
|
5579
5396
|
|
|
5580
|
-
_parent.
|
|
5397
|
+
var links = _parent.querySelectorAll("a[href='_']");
|
|
5581
5398
|
|
|
5582
|
-
|
|
5399
|
+
Array.from(links).slice(0, -1).forEach(removeLinkFromNode);
|
|
5400
|
+
nodeEl = _last(links);
|
|
5401
|
+
nodeEl.setAttribute('href', ' ');
|
|
5583
5402
|
}
|
|
5584
5403
|
}
|
|
5585
5404
|
|
|
@@ -5617,11 +5436,25 @@ var RichText = function RichText(_ref5) {
|
|
|
5617
5436
|
containerFocused.openWith(1);
|
|
5618
5437
|
focus();
|
|
5619
5438
|
}
|
|
5439
|
+
|
|
5440
|
+
if (command === 'insertUnorderedList' || command === 'insertOrderedList') {
|
|
5441
|
+
var _range2 = document.createRange();
|
|
5442
|
+
|
|
5443
|
+
_range2.setStart(startSelectionToken.get().nextSibling, 0);
|
|
5444
|
+
|
|
5445
|
+
var _end = endSelectionToken.get().nextSibling;
|
|
5446
|
+
startSelectionToken.get().remove();
|
|
5447
|
+
endSelectionToken.get().remove();
|
|
5448
|
+
startSelectionToken.set(null);
|
|
5449
|
+
endSelectionToken.set(null);
|
|
5450
|
+
|
|
5451
|
+
_range2.setEnd(_end, 0);
|
|
5452
|
+
}
|
|
5620
5453
|
};
|
|
5621
5454
|
|
|
5622
5455
|
var execCommandMouseUp = function execCommandMouseUp() {
|
|
5623
5456
|
if (startSelectionToken.get()) {
|
|
5624
|
-
window.getSelection().removeAllRanges()
|
|
5457
|
+
// window.getSelection().removeAllRanges()
|
|
5625
5458
|
var range = document.createRange();
|
|
5626
5459
|
range.setStart(startSelectionToken.get().nextSibling, 0);
|
|
5627
5460
|
var end = endSelectionToken.get().nextSibling;
|
|
@@ -5637,8 +5470,9 @@ var RichText = function RichText(_ref5) {
|
|
|
5637
5470
|
|
|
5638
5471
|
commands.get().forEach(function (c) {
|
|
5639
5472
|
return parseAndExecCommand(c);
|
|
5640
|
-
});
|
|
5641
|
-
|
|
5473
|
+
}); // commands.set(_.without(['insertUnorderedList','insertOrderedList','outdent','indent']))
|
|
5474
|
+
|
|
5475
|
+
commands.set([]);
|
|
5642
5476
|
setFormValue(input.current.innerHTML);
|
|
5643
5477
|
containerFocused.openWith(2);
|
|
5644
5478
|
toggleButtonsState();
|
|
@@ -5788,10 +5622,14 @@ var RichText = function RichText(_ref5) {
|
|
|
5788
5622
|
});
|
|
5789
5623
|
};
|
|
5790
5624
|
|
|
5625
|
+
var removeLinkFromNode = function removeLinkFromNode(node) {
|
|
5626
|
+
node.outerHTML = node.innerHTML === "\u200B" ? '' : node.innerHTML;
|
|
5627
|
+
};
|
|
5628
|
+
|
|
5791
5629
|
var removeLink = function removeLink(e) {
|
|
5792
5630
|
if (e) e.preventDefault();
|
|
5793
5631
|
alreadyCancelled.set(true);
|
|
5794
|
-
activeLinkNode.current
|
|
5632
|
+
removeLinkFromNode(activeLinkNode.current);
|
|
5795
5633
|
linkPopup.close();
|
|
5796
5634
|
|
|
5797
5635
|
if (input.current) {
|
|
@@ -5888,6 +5726,8 @@ var EditLinkPopup = function EditLinkPopup(_ref7) {
|
|
|
5888
5726
|
values = _ref7.values;
|
|
5889
5727
|
var linkPopup = React.useRef();
|
|
5890
5728
|
var formRef = React.useRef();
|
|
5729
|
+
var linkTextRef = React.useRef();
|
|
5730
|
+
var linkUrlRef = React.useRef();
|
|
5891
5731
|
var LABELS = React.useContext(core.StartlibsContext).labels.RichText;
|
|
5892
5732
|
|
|
5893
5733
|
var preValidation = function preValidation(formValues) {
|
|
@@ -5910,7 +5750,8 @@ var EditLinkPopup = function EditLinkPopup(_ref7) {
|
|
|
5910
5750
|
|
|
5911
5751
|
var checkEscOrEnter = function checkEscOrEnter(e) {
|
|
5912
5752
|
if (e.keyCode === 27) {
|
|
5913
|
-
e.stopPropagation()
|
|
5753
|
+
e.stopPropagation();
|
|
5754
|
+
cancel(e);
|
|
5914
5755
|
} else if (e.keyCode === 13) {
|
|
5915
5756
|
e.preventDefault();
|
|
5916
5757
|
e.stopPropagation();
|
|
@@ -5929,6 +5770,13 @@ var EditLinkPopup = function EditLinkPopup(_ref7) {
|
|
|
5929
5770
|
'left': left + 'px',
|
|
5930
5771
|
'top': top + 'px'
|
|
5931
5772
|
});
|
|
5773
|
+
|
|
5774
|
+
if (values.linkText) {
|
|
5775
|
+
linkUrlRef.current.focus();
|
|
5776
|
+
} else {
|
|
5777
|
+
linkTextRef.current.focus();
|
|
5778
|
+
}
|
|
5779
|
+
|
|
5932
5780
|
return cancel;
|
|
5933
5781
|
}, []);
|
|
5934
5782
|
return React__default.createElement(WithForm, {
|
|
@@ -5945,12 +5793,12 @@ var EditLinkPopup = function EditLinkPopup(_ref7) {
|
|
|
5945
5793
|
className: "popup rich-text-link-editor ignore-link",
|
|
5946
5794
|
contentEditable: false
|
|
5947
5795
|
}, React__default.createElement(TextInput, {
|
|
5948
|
-
|
|
5796
|
+
ref: linkTextRef,
|
|
5949
5797
|
mandatory: true,
|
|
5950
5798
|
path: "linkText",
|
|
5951
5799
|
label: LABELS.popupLinkText
|
|
5952
5800
|
}), React__default.createElement(TextInput, {
|
|
5953
|
-
|
|
5801
|
+
ref: linkUrlRef,
|
|
5954
5802
|
mandatory: true,
|
|
5955
5803
|
path: "linkUrl",
|
|
5956
5804
|
label: LABELS.popupLinkUrl
|
|
@@ -6067,16 +5915,16 @@ var ToggleCheckbox = styled__default(function (_ref) {
|
|
|
6067
5915
|
}).withConfig({
|
|
6068
5916
|
displayName: "ToggleCheckbox",
|
|
6069
5917
|
componentId: "sc-11ob8ah-4"
|
|
6070
|
-
})(["position:relative;background-color:rgba(0,0,0,0.06);border-radius:6px;padding:0.75rem 1rem;min-height:36px;font-weight:600;font-weight:500;margin-bottom:1rem;cursor:pointer;display:flex;align-items:center;justify-content:space-between;:hover{background-color:rgba(0,0,0,0.08);}:active{background-color:rgba(0,0,0,0.1);}& ~ &{margin-top:-0.5rem;}", " ", ""], function (props) {
|
|
5918
|
+
})(["position:relative;background-color:rgba(0,0,0,0.06);border-radius:6px;padding:0.75rem 1rem;min-height:36px;font-weight:600;font-weight:500;margin-bottom:1rem;cursor:pointer;display:flex;align-items:center;justify-content:space-between;:hover{background-color:rgba(0,0,0,0.08);}:active{background-color:rgba(0,0,0,0.1);}& ~ &{margin-top:-0.5rem;}", " ", " ", ""], function (props) {
|
|
6071
5919
|
return !props.noFocus && styled.css([":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);}}"]);
|
|
6072
5920
|
}, function (props) {
|
|
6073
5921
|
return props.disabled && "\n opacity: 0.8;\n pointer-events:none;\n ";
|
|
6074
|
-
});
|
|
5922
|
+
}, utils.customTheme('ToggleCheckboxBox'));
|
|
6075
5923
|
|
|
6076
|
-
function _templateObject$
|
|
5924
|
+
function _templateObject$8() {
|
|
6077
5925
|
var data = _taggedTemplateLiteral(["\n min-width: 0;\n ", "\n "]);
|
|
6078
5926
|
|
|
6079
|
-
_templateObject$
|
|
5927
|
+
_templateObject$8 = function _templateObject() {
|
|
6080
5928
|
return data;
|
|
6081
5929
|
};
|
|
6082
5930
|
|
|
@@ -6095,7 +5943,7 @@ var TabButton = styled__default(components.Button).withConfig({
|
|
|
6095
5943
|
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 ";
|
|
6096
5944
|
}, function (props) {
|
|
6097
5945
|
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 ";
|
|
6098
|
-
}, utils.media.mobile(_templateObject$
|
|
5946
|
+
}, utils.media.mobile(_templateObject$8(), function (props) {
|
|
6099
5947
|
return props.icon ? "\n padding-left: 1.25rem;\n padding-right: 1rem;\n " : "\n padding-left: 0.25rem;\n padding-right: 0.25rem;\n ";
|
|
6100
5948
|
}), utils.customTheme('TabButton'));
|
|
6101
5949
|
var InnerButton = styled__default.a.withConfig({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startlibs/form",
|
|
3
|
-
"version": "1.0.0-alpha-
|
|
3
|
+
"version": "1.0.0-alpha-10f",
|
|
4
4
|
"description": "Startlibs Form",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -8,9 +8,8 @@
|
|
|
8
8
|
"peerDependencies": {
|
|
9
9
|
"lodash": "^4.17.11",
|
|
10
10
|
"polished": "^1.1.3",
|
|
11
|
-
"react": "^
|
|
12
|
-
"react-dom": "^
|
|
13
|
-
"react-hot-loader": "^4.3.5",
|
|
11
|
+
"react": "^18.0",
|
|
12
|
+
"react-dom": "^18.0",
|
|
14
13
|
"styled-components": "^5.2.0"
|
|
15
14
|
},
|
|
16
15
|
"devDependencies": {
|