@startlibs/form 1.0.0-alpha-10b → 1.0.0-alpha-10e

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.
Files changed (2) hide show
  1. package/lib/index.js +76 -238
  2. 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$4() {
3789
+ function _templateObject$3() {
3994
3790
  var data = _taggedTemplateLiteral(["\n padding: 7px 12px 7px 32px;\n "]);
3995
3791
 
3996
- _templateObject$4 = function _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$4()), function (props) {
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$5() {
3874
+ function _templateObject$4() {
4079
3875
  var data = _taggedTemplateLiteral(["\n padding: 7px 12px 7px 32px;\n "]);
4080
3876
 
4081
- _templateObject$5 = function _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$5()), function (props) {
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$6() {
4005
+ function _templateObject$5() {
4210
4006
  var data = _taggedTemplateLiteral(["\n width: 2.5rem;\n "]);
4211
4007
 
4212
- _templateObject$6 = function _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$6()));
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$7() {
4694
+ function _templateObject$6() {
4899
4695
  var data = _taggedTemplateLiteral(["\n padding 1rem;\n "]);
4900
4696
 
4901
- _templateObject$7 = function _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$7()), function (props) {
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,10 +4904,10 @@ var FlipDiv$1 = function FlipDiv(_ref3) {
5108
4904
  }));
5109
4905
  };
5110
4906
 
5111
- function _templateObject$8() {
4907
+ function _templateObject$7() {
5112
4908
  var data = _taggedTemplateLiteral(["\n padding-right: 2.25rem;\n background: rgba(0,0,0,0.075);\n "]);
5113
4909
 
5114
- _templateObject$8 = function _templateObject() {
4910
+ _templateObject$7 = function _templateObject() {
5115
4911
  return data;
5116
4912
  };
5117
4913
 
@@ -5203,7 +4999,7 @@ var RichTextContainer = styled__default.div.withConfig({
5203
4999
  }, function (props) {
5204
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 ");
5205
5001
  }, function (props) {
5206
- return props.locked && css(_templateObject$8());
5002
+ return props.locked && css(_templateObject$7());
5207
5003
  });
5208
5004
  var RichTextInput = styled__default.div.withConfig({
5209
5005
  displayName: "RichText__RichTextInput",
@@ -5322,6 +5118,10 @@ var cleanEditor = function cleanEditor(editor, acceptedTags) {
5322
5118
  clean(el.childNodes);
5323
5119
  el.removeAttribute('class');
5324
5120
 
5121
+ if (tagName === 'a') {
5122
+ el.setAttribute('target', '_blank');
5123
+ }
5124
+
5325
5125
  if (el.getAttribute('style')) {
5326
5126
  var usedStyles = _toPairs(_pick(acceptedStyles, el.style)).filter(function (_ref) {
5327
5127
  var _ref2 = _slicedToArray(_ref, 2),
@@ -5504,7 +5304,6 @@ var RichText = function RichText(_ref5) {
5504
5304
  };
5505
5305
 
5506
5306
  var containerBlur = function containerBlur(e) {
5507
- // console.log(e.target,e.currentTarget)
5508
5307
  if (containerFocused.isOpen !== 1) {
5509
5308
  containerFocused.close();
5510
5309
  triggerScrollForPanel(Date.now());
@@ -5521,7 +5320,11 @@ var RichText = function RichText(_ref5) {
5521
5320
 
5522
5321
  var keydownHandler = function keydownHandler(e) {
5523
5322
  if (containerFocused.isOpen === 2) {
5524
- if (e.key === "k" && e.ctrlKey) {
5323
+ if (formatTools.indexOf('link') < 0) {
5324
+ return;
5325
+ }
5326
+
5327
+ if (e.key === "k" && e.ctrlKey || e.key === "k" && e.metaKey) {
5525
5328
  e.preventDefault();
5526
5329
  execCommand(null, 'link');
5527
5330
  }
@@ -5569,17 +5372,23 @@ var RichText = function RichText(_ref5) {
5569
5372
  _anchor.innerHTML = '&#8203;';
5570
5373
 
5571
5374
  if (range.collapsed) {
5572
- window.getSelection().getRangeAt(0).insertNode(_anchor);
5375
+ range.insertNode(_anchor);
5573
5376
  } else {
5377
+ if (range.commonAncestorContainer === input.current) {
5378
+ range.setStart(range.endContainer, 0);
5379
+ }
5380
+
5574
5381
  document.execCommand('createLink', false, '_');
5575
5382
  _anchor = window.getSelection().anchorNode;
5576
5383
  }
5577
5384
 
5578
- var _parent = _anchor.nodeName === 'A' ? _anchor : _anchor.parentElement.matches('a') ? _anchor.parentElement : _anchor.nextSibling;
5385
+ var _parent = range.commonAncestorContainer.nodeType === 3 ? range.commonAncestorContainer.parentNode : range.commonAncestorContainer;
5579
5386
 
5580
- _parent.setAttribute('href', ' ');
5387
+ var links = _parent.querySelectorAll("a[href='_']");
5581
5388
 
5582
- nodeEl = _parent;
5389
+ Array.from(links).slice(0, -1).forEach(removeLinkFromNode);
5390
+ nodeEl = _last(links);
5391
+ nodeEl.setAttribute('href', ' ');
5583
5392
  }
5584
5393
  }
5585
5394
 
@@ -5617,11 +5426,25 @@ var RichText = function RichText(_ref5) {
5617
5426
  containerFocused.openWith(1);
5618
5427
  focus();
5619
5428
  }
5429
+
5430
+ if (command === 'insertUnorderedList' || command === 'insertOrderedList') {
5431
+ var _range2 = document.createRange();
5432
+
5433
+ _range2.setStart(startSelectionToken.get().nextSibling, 0);
5434
+
5435
+ var _end = endSelectionToken.get().nextSibling;
5436
+ startSelectionToken.get().remove();
5437
+ endSelectionToken.get().remove();
5438
+ startSelectionToken.set(null);
5439
+ endSelectionToken.set(null);
5440
+
5441
+ _range2.setEnd(_end, 0);
5442
+ }
5620
5443
  };
5621
5444
 
5622
5445
  var execCommandMouseUp = function execCommandMouseUp() {
5623
5446
  if (startSelectionToken.get()) {
5624
- window.getSelection().removeAllRanges();
5447
+ // window.getSelection().removeAllRanges()
5625
5448
  var range = document.createRange();
5626
5449
  range.setStart(startSelectionToken.get().nextSibling, 0);
5627
5450
  var end = endSelectionToken.get().nextSibling;
@@ -5637,8 +5460,9 @@ var RichText = function RichText(_ref5) {
5637
5460
 
5638
5461
  commands.get().forEach(function (c) {
5639
5462
  return parseAndExecCommand(c);
5640
- });
5641
- commands.set(_without(['insertUnorderedList', 'insertOrderedList', 'outdent', 'indent']));
5463
+ }); // commands.set(_.without(['insertUnorderedList','insertOrderedList','outdent','indent']))
5464
+
5465
+ commands.set([]);
5642
5466
  setFormValue(input.current.innerHTML);
5643
5467
  containerFocused.openWith(2);
5644
5468
  toggleButtonsState();
@@ -5788,10 +5612,14 @@ var RichText = function RichText(_ref5) {
5788
5612
  });
5789
5613
  };
5790
5614
 
5615
+ var removeLinkFromNode = function removeLinkFromNode(node) {
5616
+ node.outerHTML = node.innerHTML === "\u200B" ? '' : node.innerHTML;
5617
+ };
5618
+
5791
5619
  var removeLink = function removeLink(e) {
5792
5620
  if (e) e.preventDefault();
5793
5621
  alreadyCancelled.set(true);
5794
- activeLinkNode.current.outerHTML = activeLinkNode.current.innerHTML === "\u200B" ? '' : activeLinkNode.current.innerHTML;
5622
+ removeLinkFromNode(activeLinkNode.current);
5795
5623
  linkPopup.close();
5796
5624
 
5797
5625
  if (input.current) {
@@ -5888,6 +5716,8 @@ var EditLinkPopup = function EditLinkPopup(_ref7) {
5888
5716
  values = _ref7.values;
5889
5717
  var linkPopup = React.useRef();
5890
5718
  var formRef = React.useRef();
5719
+ var linkTextRef = React.useRef();
5720
+ var linkUrlRef = React.useRef();
5891
5721
  var LABELS = React.useContext(core.StartlibsContext).labels.RichText;
5892
5722
 
5893
5723
  var preValidation = function preValidation(formValues) {
@@ -5910,7 +5740,8 @@ var EditLinkPopup = function EditLinkPopup(_ref7) {
5910
5740
 
5911
5741
  var checkEscOrEnter = function checkEscOrEnter(e) {
5912
5742
  if (e.keyCode === 27) {
5913
- e.stopPropagation().cancel(e);
5743
+ e.stopPropagation();
5744
+ cancel(e);
5914
5745
  } else if (e.keyCode === 13) {
5915
5746
  e.preventDefault();
5916
5747
  e.stopPropagation();
@@ -5929,6 +5760,13 @@ var EditLinkPopup = function EditLinkPopup(_ref7) {
5929
5760
  'left': left + 'px',
5930
5761
  'top': top + 'px'
5931
5762
  });
5763
+
5764
+ if (values.linkText) {
5765
+ linkUrlRef.current.focus();
5766
+ } else {
5767
+ linkTextRef.current.focus();
5768
+ }
5769
+
5932
5770
  return cancel;
5933
5771
  }, []);
5934
5772
  return React__default.createElement(WithForm, {
@@ -5945,12 +5783,12 @@ var EditLinkPopup = function EditLinkPopup(_ref7) {
5945
5783
  className: "popup rich-text-link-editor ignore-link",
5946
5784
  contentEditable: false
5947
5785
  }, React__default.createElement(TextInput, {
5948
- autoFocus: !values.linkText,
5786
+ ref: linkTextRef,
5949
5787
  mandatory: true,
5950
5788
  path: "linkText",
5951
5789
  label: LABELS.popupLinkText
5952
5790
  }), React__default.createElement(TextInput, {
5953
- autoFocus: values.linkText,
5791
+ ref: linkUrlRef,
5954
5792
  mandatory: true,
5955
5793
  path: "linkUrl",
5956
5794
  label: LABELS.popupLinkUrl
@@ -6067,16 +5905,16 @@ var ToggleCheckbox = styled__default(function (_ref) {
6067
5905
  }).withConfig({
6068
5906
  displayName: "ToggleCheckbox",
6069
5907
  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) {
5908
+ })(["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
5909
  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
5910
  }, function (props) {
6073
5911
  return props.disabled && "\n opacity: 0.8;\n pointer-events:none;\n ";
6074
- });
5912
+ }, utils.customTheme('ToggleCheckboxBox'));
6075
5913
 
6076
- function _templateObject$9() {
5914
+ function _templateObject$8() {
6077
5915
  var data = _taggedTemplateLiteral(["\n min-width: 0;\n ", "\n "]);
6078
5916
 
6079
- _templateObject$9 = function _templateObject() {
5917
+ _templateObject$8 = function _templateObject() {
6080
5918
  return data;
6081
5919
  };
6082
5920
 
@@ -6095,7 +5933,7 @@ var TabButton = styled__default(components.Button).withConfig({
6095
5933
  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
5934
  }, function (props) {
6097
5935
  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$9(), function (props) {
5936
+ }, utils.media.mobile(_templateObject$8(), function (props) {
6099
5937
  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
5938
  }), utils.customTheme('TabButton'));
6101
5939
  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-10b",
3
+ "version": "1.0.0-alpha-10e",
4
4
  "description": "Startlibs Form",
5
5
  "main": "lib/index.js",
6
6
  "sideEffects": false,