@startlibs/form 1.0.0-alpha-10a → 1.0.0-alpha-10d
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 +90 -232
- package/package.json +1 -1
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) {
|
|
@@ -3990,10 +3786,10 @@ var Radiobox = function Radiobox(_ref) {
|
|
|
3990
3786
|
}));
|
|
3991
3787
|
};
|
|
3992
3788
|
|
|
3993
|
-
function _templateObject$
|
|
3789
|
+
function _templateObject$3() {
|
|
3994
3790
|
var data = _taggedTemplateLiteral(["\n padding: 7px 12px 7px 32px;\n "]);
|
|
3995
3791
|
|
|
3996
|
-
_templateObject$
|
|
3792
|
+
_templateObject$3 = function _templateObject() {
|
|
3997
3793
|
return data;
|
|
3998
3794
|
};
|
|
3999
3795
|
|
|
@@ -4019,7 +3815,7 @@ var CheckboxContent = styled__default.div.withConfig({
|
|
|
4019
3815
|
displayName: "SimpleCheckbox__CheckboxContent",
|
|
4020
3816
|
componentId: "am8pps-4"
|
|
4021
3817
|
})(["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$
|
|
3818
|
+
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
3819
|
return props.hasErrors && styled.css(["border-color:", " !important;"], utils.getColor('alert'));
|
|
4024
3820
|
}, function (props) {
|
|
4025
3821
|
return props.checked && props.highlightSelected && styled.css(["border-color:", ";background:", ";:hover{background:", ";}", "{", "{color:", ";}}"], utils.getColor('main'), function (props) {
|
|
@@ -4075,10 +3871,10 @@ var SimpleCheckbox = styled__default(function (_ref) {
|
|
|
4075
3871
|
componentId: "am8pps-5"
|
|
4076
3872
|
})(["cursor:pointer;position:relative;margin-bottom:1rem;display:block;", ""], utils.ifProp('disabled', styled.css(["pointer-events:none;"])));
|
|
4077
3873
|
|
|
4078
|
-
function _templateObject$
|
|
3874
|
+
function _templateObject$4() {
|
|
4079
3875
|
var data = _taggedTemplateLiteral(["\n padding: 7px 12px 7px 32px;\n "]);
|
|
4080
3876
|
|
|
4081
|
-
_templateObject$
|
|
3877
|
+
_templateObject$4 = function _templateObject() {
|
|
4082
3878
|
return data;
|
|
4083
3879
|
};
|
|
4084
3880
|
|
|
@@ -4104,7 +3900,7 @@ var RadioboxContent = styled__default.div.withConfig({
|
|
|
4104
3900
|
displayName: "SimpleRadiobox__RadioboxContent",
|
|
4105
3901
|
componentId: "qv83xo-4"
|
|
4106
3902
|
})(["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$
|
|
3903
|
+
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
3904
|
return props.hasErrors && styled.css(["border-color:", " !important;"], utils.getColor('alert'));
|
|
4109
3905
|
}, function (props) {
|
|
4110
3906
|
return props.checked && props.highlightSelected && styled.css(["border-color:", ";background:", ";:hover{background:", ";}", "{:before{background-color:", ";}}"], utils.getColor('main'), function (props) {
|
|
@@ -4206,10 +4002,10 @@ function _templateObject2$2() {
|
|
|
4206
4002
|
return data;
|
|
4207
4003
|
}
|
|
4208
4004
|
|
|
4209
|
-
function _templateObject$
|
|
4005
|
+
function _templateObject$5() {
|
|
4210
4006
|
var data = _taggedTemplateLiteral(["\n width: 2.5rem;\n "]);
|
|
4211
4007
|
|
|
4212
|
-
_templateObject$
|
|
4008
|
+
_templateObject$5 = function _templateObject() {
|
|
4213
4009
|
return data;
|
|
4214
4010
|
};
|
|
4215
4011
|
|
|
@@ -4222,7 +4018,7 @@ var LEVELS = [DAY, MONTH, YEAR];
|
|
|
4222
4018
|
var DatePickerContainer = styled__default.div.withConfig({
|
|
4223
4019
|
displayName: "DatePicker__DatePickerContainer",
|
|
4224
4020
|
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$
|
|
4021
|
+
})(["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
4022
|
var CalendarHeader = styled__default.div.withConfig({
|
|
4227
4023
|
displayName: "DatePicker__CalendarHeader",
|
|
4228
4024
|
componentId: "sc-1wo8j4d-1"
|
|
@@ -4895,10 +4691,10 @@ function getClosestNextLeapYear(year) {
|
|
|
4895
4691
|
return y;
|
|
4896
4692
|
}
|
|
4897
4693
|
|
|
4898
|
-
function _templateObject$
|
|
4694
|
+
function _templateObject$6() {
|
|
4899
4695
|
var data = _taggedTemplateLiteral(["\n padding 1rem;\n "]);
|
|
4900
4696
|
|
|
4901
|
-
_templateObject$
|
|
4697
|
+
_templateObject$6 = function _templateObject() {
|
|
4902
4698
|
return data;
|
|
4903
4699
|
};
|
|
4904
4700
|
|
|
@@ -4921,7 +4717,7 @@ var ExpandableBoxStyled = styled__default.div.withConfig({
|
|
|
4921
4717
|
return polished.darken(0.05, utils.getColor("gray240")(props));
|
|
4922
4718
|
}, function (props) {
|
|
4923
4719
|
return polished.darken(0.08, utils.getColor("gray240")(props));
|
|
4924
|
-
}) : styled.css(["padding 1.5rem;", " ", ""], utils.media.max(340)(_templateObject$
|
|
4720
|
+
}) : styled.css(["padding 1.5rem;", " ", ""], utils.media.max(340)(_templateObject$6()), function (props) {
|
|
4925
4721
|
return props.fixMarginBottom && "\n padding-bottom: 0.5rem !important;\n ";
|
|
4926
4722
|
});
|
|
4927
4723
|
}, components.SwitchDiv);
|
|
@@ -5108,6 +4904,19 @@ var FlipDiv$1 = function FlipDiv(_ref3) {
|
|
|
5108
4904
|
}));
|
|
5109
4905
|
};
|
|
5110
4906
|
|
|
4907
|
+
function _templateObject$7() {
|
|
4908
|
+
var data = _taggedTemplateLiteral(["\n padding-right: 2.25rem;\n background: rgba(0,0,0,0.075);\n "]);
|
|
4909
|
+
|
|
4910
|
+
_templateObject$7 = function _templateObject() {
|
|
4911
|
+
return data;
|
|
4912
|
+
};
|
|
4913
|
+
|
|
4914
|
+
return data;
|
|
4915
|
+
}
|
|
4916
|
+
var InputIcon$1 = styled__default(components.Icon).withConfig({
|
|
4917
|
+
displayName: "RichText__InputIcon",
|
|
4918
|
+
componentId: "x8c1ig-0"
|
|
4919
|
+
})(["position:absolute;outline:none;bottom:0;font-size:21px;line-height:3rem;right:0;width:2rem;pointer-events:none;color:", ";"], utils.getColor('gray150'));
|
|
5111
4920
|
var FORMAT_TOOLS = {
|
|
5112
4921
|
'bold': ['b', 'strong'],
|
|
5113
4922
|
'italic': 'i',
|
|
@@ -5182,17 +4991,19 @@ var FIX_STYLE = {
|
|
|
5182
4991
|
};
|
|
5183
4992
|
var RichTextContainer = styled__default.div.withConfig({
|
|
5184
4993
|
displayName: "RichText__RichTextContainer",
|
|
5185
|
-
componentId: "x8c1ig-
|
|
5186
|
-
})(["position:relative;width:100%;border:1px solid ", ";border-radius:6px;background:white;", ";", ";", ""], utils.getColor('gray210'), function (props) {
|
|
4994
|
+
componentId: "x8c1ig-1"
|
|
4995
|
+
})(["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;}"], utils.getColor('gray210'), function (props) {
|
|
5187
4996
|
return props.hasErrors && "border-color: ".concat(utils.getColor(props)('alert'));
|
|
5188
4997
|
}, function (props) {
|
|
5189
4998
|
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 ");
|
|
5190
4999
|
}, function (props) {
|
|
5191
5000
|
return props.focus && "\n border-color: ".concat(utils.getColor('gray180'), ";\n box-shadow: 0px 0px 0px 2px rgba(0,0,0,0.1);\n ");
|
|
5001
|
+
}, function (props) {
|
|
5002
|
+
return props.locked && css(_templateObject$7());
|
|
5192
5003
|
});
|
|
5193
5004
|
var RichTextInput = styled__default.div.withConfig({
|
|
5194
5005
|
displayName: "RichText__RichTextInput",
|
|
5195
|
-
componentId: "x8c1ig-
|
|
5006
|
+
componentId: "x8c1ig-2"
|
|
5196
5007
|
})(["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);}", ""], utils.getColor('gray60'), function (props) {
|
|
5197
5008
|
return props.minHeight || 78;
|
|
5198
5009
|
}, function (props) {
|
|
@@ -5200,15 +5011,15 @@ var RichTextInput = styled__default.div.withConfig({
|
|
|
5200
5011
|
});
|
|
5201
5012
|
var ToolsContainer = styled__default.div.withConfig({
|
|
5202
5013
|
displayName: "RichText__ToolsContainer",
|
|
5203
|
-
componentId: "x8c1ig-
|
|
5014
|
+
componentId: "x8c1ig-3"
|
|
5204
5015
|
})(["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;"], utils.getColor('gray240'));
|
|
5205
5016
|
var ToolButton = styled__default(components.Button).withConfig({
|
|
5206
5017
|
displayName: "RichText__ToolButton",
|
|
5207
|
-
componentId: "x8c1ig-
|
|
5018
|
+
componentId: "x8c1ig-4"
|
|
5208
5019
|
})(["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;}"], utils.getColor('gray90'));
|
|
5209
5020
|
var ToolSeparator = styled__default.span.withConfig({
|
|
5210
5021
|
displayName: "RichText__ToolSeparator",
|
|
5211
|
-
componentId: "x8c1ig-
|
|
5022
|
+
componentId: "x8c1ig-5"
|
|
5212
5023
|
})(["border-left:1px solid ", ";margin-left:0.75rem;margin-right:0.5rem;line-height:2rem;vertical-align:-6px;"], utils.getColor('gray180'));
|
|
5213
5024
|
var JS_CLASS = "EDITOR--JS";
|
|
5214
5025
|
|
|
@@ -5307,6 +5118,10 @@ var cleanEditor = function cleanEditor(editor, acceptedTags) {
|
|
|
5307
5118
|
clean(el.childNodes);
|
|
5308
5119
|
el.removeAttribute('class');
|
|
5309
5120
|
|
|
5121
|
+
if (tagName === 'a') {
|
|
5122
|
+
el.setAttribute('target', '_blank');
|
|
5123
|
+
}
|
|
5124
|
+
|
|
5310
5125
|
if (el.getAttribute('style')) {
|
|
5311
5126
|
var usedStyles = _toPairs(_pick(acceptedStyles, el.style)).filter(function (_ref) {
|
|
5312
5127
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
@@ -5413,7 +5228,8 @@ var RichText = function RichText(_ref5) {
|
|
|
5413
5228
|
tabIndex = _ref5$tabIndex === void 0 ? 1 : _ref5$tabIndex,
|
|
5414
5229
|
value = _ref5.value,
|
|
5415
5230
|
setValue = _ref5.setValue,
|
|
5416
|
-
raw = _ref5.raw
|
|
5231
|
+
raw = _ref5.raw,
|
|
5232
|
+
locked = _ref5.locked;
|
|
5417
5233
|
var linkPopup = core.usePopupToggle();
|
|
5418
5234
|
var input = core.useEnsureRef(inputRef);
|
|
5419
5235
|
var activeLinkNode = React.useRef();
|
|
@@ -5503,6 +5319,26 @@ var RichText = function RichText(_ref5) {
|
|
|
5503
5319
|
}
|
|
5504
5320
|
};
|
|
5505
5321
|
|
|
5322
|
+
var keydownHandler = function keydownHandler(e) {
|
|
5323
|
+
if (containerFocused.isOpen === 2) {
|
|
5324
|
+
if (formatTools.indexOf('link') < 0) {
|
|
5325
|
+
return;
|
|
5326
|
+
}
|
|
5327
|
+
|
|
5328
|
+
if (e.key === "k" && e.ctrlKey || e.key === "k" && e.metaKey) {
|
|
5329
|
+
e.preventDefault();
|
|
5330
|
+
execCommand(null, 'link');
|
|
5331
|
+
}
|
|
5332
|
+
}
|
|
5333
|
+
};
|
|
5334
|
+
|
|
5335
|
+
React.useEffect(function () {
|
|
5336
|
+
document.addEventListener('keydown', keydownHandler);
|
|
5337
|
+
return function () {
|
|
5338
|
+
return document.removeEventListener('keydown', keydownHandler);
|
|
5339
|
+
};
|
|
5340
|
+
}, [containerFocused.isOpen]);
|
|
5341
|
+
|
|
5506
5342
|
var execCommand = function execCommand(e, command) {
|
|
5507
5343
|
if (command === 'link') {
|
|
5508
5344
|
var nodeEl;
|
|
@@ -5537,17 +5373,23 @@ var RichText = function RichText(_ref5) {
|
|
|
5537
5373
|
_anchor.innerHTML = '​';
|
|
5538
5374
|
|
|
5539
5375
|
if (range.collapsed) {
|
|
5540
|
-
|
|
5376
|
+
range.insertNode(_anchor);
|
|
5541
5377
|
} else {
|
|
5378
|
+
if (range.commonAncestorContainer === input.current) {
|
|
5379
|
+
range.setStart(range.endContainer, 0);
|
|
5380
|
+
}
|
|
5381
|
+
|
|
5542
5382
|
document.execCommand('createLink', false, '_');
|
|
5543
5383
|
_anchor = window.getSelection().anchorNode;
|
|
5544
5384
|
}
|
|
5545
5385
|
|
|
5546
|
-
var _parent =
|
|
5386
|
+
var _parent = range.commonAncestorContainer.nodeType === 3 ? range.commonAncestorContainer.parentNode : range.commonAncestorContainer;
|
|
5547
5387
|
|
|
5548
|
-
_parent.
|
|
5388
|
+
var links = _parent.querySelectorAll("a[href='_']");
|
|
5549
5389
|
|
|
5550
|
-
|
|
5390
|
+
Array.from(links).slice(0, -1).forEach(removeLinkFromNode);
|
|
5391
|
+
nodeEl = _last(links);
|
|
5392
|
+
nodeEl.setAttribute('href', ' ');
|
|
5551
5393
|
}
|
|
5552
5394
|
}
|
|
5553
5395
|
|
|
@@ -5756,10 +5598,14 @@ var RichText = function RichText(_ref5) {
|
|
|
5756
5598
|
});
|
|
5757
5599
|
};
|
|
5758
5600
|
|
|
5601
|
+
var removeLinkFromNode = function removeLinkFromNode(node) {
|
|
5602
|
+
node.outerHTML = node.innerHTML === "\u200B" ? '' : node.innerHTML;
|
|
5603
|
+
};
|
|
5604
|
+
|
|
5759
5605
|
var removeLink = function removeLink(e) {
|
|
5760
5606
|
if (e) e.preventDefault();
|
|
5761
5607
|
alreadyCancelled.set(true);
|
|
5762
|
-
activeLinkNode.current
|
|
5608
|
+
removeLinkFromNode(activeLinkNode.current);
|
|
5763
5609
|
linkPopup.close();
|
|
5764
5610
|
|
|
5765
5611
|
if (input.current) {
|
|
@@ -5828,6 +5674,8 @@ var RichText = function RichText(_ref5) {
|
|
|
5828
5674
|
className: JS_CLASS,
|
|
5829
5675
|
minHeight: minHeight,
|
|
5830
5676
|
placeholder: placeholder
|
|
5677
|
+
}), locked && React__default.createElement(InputIcon$1, {
|
|
5678
|
+
icon: "lock"
|
|
5831
5679
|
}), linkPopup.isOpen && React__default.createElement(EditLinkPopup, {
|
|
5832
5680
|
input: input,
|
|
5833
5681
|
activeLinkNode: activeLinkNode,
|
|
@@ -5854,6 +5702,8 @@ var EditLinkPopup = function EditLinkPopup(_ref7) {
|
|
|
5854
5702
|
values = _ref7.values;
|
|
5855
5703
|
var linkPopup = React.useRef();
|
|
5856
5704
|
var formRef = React.useRef();
|
|
5705
|
+
var linkTextRef = React.useRef();
|
|
5706
|
+
var linkUrlRef = React.useRef();
|
|
5857
5707
|
var LABELS = React.useContext(core.StartlibsContext).labels.RichText;
|
|
5858
5708
|
|
|
5859
5709
|
var preValidation = function preValidation(formValues) {
|
|
@@ -5876,7 +5726,8 @@ var EditLinkPopup = function EditLinkPopup(_ref7) {
|
|
|
5876
5726
|
|
|
5877
5727
|
var checkEscOrEnter = function checkEscOrEnter(e) {
|
|
5878
5728
|
if (e.keyCode === 27) {
|
|
5879
|
-
e.stopPropagation()
|
|
5729
|
+
e.stopPropagation();
|
|
5730
|
+
cancel(e);
|
|
5880
5731
|
} else if (e.keyCode === 13) {
|
|
5881
5732
|
e.preventDefault();
|
|
5882
5733
|
e.stopPropagation();
|
|
@@ -5895,6 +5746,13 @@ var EditLinkPopup = function EditLinkPopup(_ref7) {
|
|
|
5895
5746
|
'left': left + 'px',
|
|
5896
5747
|
'top': top + 'px'
|
|
5897
5748
|
});
|
|
5749
|
+
|
|
5750
|
+
if (values.linkText) {
|
|
5751
|
+
linkUrlRef.current.focus();
|
|
5752
|
+
} else {
|
|
5753
|
+
linkTextRef.current.focus();
|
|
5754
|
+
}
|
|
5755
|
+
|
|
5898
5756
|
return cancel;
|
|
5899
5757
|
}, []);
|
|
5900
5758
|
return React__default.createElement(WithForm, {
|
|
@@ -5911,12 +5769,12 @@ var EditLinkPopup = function EditLinkPopup(_ref7) {
|
|
|
5911
5769
|
className: "popup rich-text-link-editor ignore-link",
|
|
5912
5770
|
contentEditable: false
|
|
5913
5771
|
}, React__default.createElement(TextInput, {
|
|
5914
|
-
|
|
5772
|
+
ref: linkTextRef,
|
|
5915
5773
|
mandatory: true,
|
|
5916
5774
|
path: "linkText",
|
|
5917
5775
|
label: LABELS.popupLinkText
|
|
5918
5776
|
}), React__default.createElement(TextInput, {
|
|
5919
|
-
|
|
5777
|
+
ref: linkUrlRef,
|
|
5920
5778
|
mandatory: true,
|
|
5921
5779
|
path: "linkUrl",
|
|
5922
5780
|
label: LABELS.popupLinkUrl
|