@startlibs/form 1.0.0-alpha-10f → 1.0.0-alpha-9w.1

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 (3) hide show
  1. package/lib/index.js +286 -399
  2. package/package.json +5 -4
  3. package/src/index.js +24 -0
package/lib/index.js CHANGED
@@ -45,13 +45,12 @@ 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
47
  var _isFinite = _interopDefault(require('lodash/fp/isFinite'));
48
- var _negate = _interopDefault(require('lodash/fp/negate'));
49
48
  var _zipObject = _interopDefault(require('lodash/fp/zipObject'));
50
- var _last = _interopDefault(require('lodash/fp/last'));
51
49
  var _flatten = _interopDefault(require('lodash/fp/flatten'));
52
50
  var _fromPairs = _interopDefault(require('lodash/fp/fromPairs'));
53
51
  var _pick = _interopDefault(require('lodash/fp/pick'));
54
52
  var _toPairs = _interopDefault(require('lodash/fp/toPairs'));
53
+ var _negate = _interopDefault(require('lodash/fp/negate'));
55
54
  var _get = _interopDefault(require('lodash/fp/get'));
56
55
  var _entries = _interopDefault(require('lodash/fp/entries'));
57
56
 
@@ -138,9 +137,7 @@ var useProvideErrors = function useProvideErrors() {
138
137
  };
139
138
 
140
139
  var setErrors = function setErrors(newErrors) {
141
- console.log(parseMultipleErrors(newErrors));
142
- errors.openWith(parseMultipleErrors(newErrors));
143
- errors.get();
140
+ return errors.openWith(parseMultipleErrors(newErrors));
144
141
  };
145
142
 
146
143
  var setError = function setError(errorPath, errorValue) {
@@ -1107,9 +1104,7 @@ var Container = styled__default.div.withConfig({
1107
1104
  var Label = styled__default.label.withConfig({
1108
1105
  displayName: "Field__Label",
1109
1106
  componentId: "p9woft-2"
1110
- })(["font-weight:500;display:inline-block;font-size:", "px;margin-bottom:.5rem;", " ", ""], function (props) {
1111
- return props.labelFontSize ? props.labelFontSize : '14';
1112
- }, function (props) {
1107
+ })(["font-weight:500;display:inline-block;font-size:14px;margin-bottom:.5rem;", " ", ""], function (props) {
1113
1108
  return props.isOnImage && 'color: #fff;';
1114
1109
  }, utils.customTheme("FieldLabel"));
1115
1110
  var HelpText = styled__default.span.withConfig({
@@ -1135,16 +1130,14 @@ var Field = React__default.forwardRef(function (_ref, ref) {
1135
1130
  mandatory = _ref.mandatory,
1136
1131
  onImage = _ref.onImage,
1137
1132
  children = _ref.children,
1138
- labelFontSize = _ref.labelFontSize,
1139
- rest = _objectWithoutProperties(_ref, ["label", "helpText", "descText", "bellowDescText", "className", "labelClick", "focused", "mandatory", "onImage", "children", "labelFontSize"]);
1133
+ rest = _objectWithoutProperties(_ref, ["label", "helpText", "descText", "bellowDescText", "className", "labelClick", "focused", "mandatory", "onImage", "children"]);
1140
1134
 
1141
1135
  return React__default.createElement(Container, _extends({
1142
1136
  ref: ref
1143
1137
  }, rest, {
1144
1138
  className: className
1145
1139
  }), label && React__default.createElement(Label, _extends({}, rest, {
1146
- onClick: labelClick,
1147
- labelFontSize: labelFontSize
1140
+ onClick: labelClick
1148
1141
  }), label, mandatory && React__default.createElement(Mandatory, {
1149
1142
  mandatory: mandatory
1150
1143
  }, "*"), helpText && React__default.createElement(HelpText, null, " ", helpText), descText && React__default.createElement(FieldDescription, null, descText)), children, bellowDescText && React__default.createElement(BellowFieldDescription, null, bellowDescText));
@@ -3167,7 +3160,7 @@ var ConfirmEditableBoxes = React.forwardRef(function (_ref, ref) {
3167
3160
 
3168
3161
  var modifiedEditablesPath = function modifiedEditablesPath(boxes) {
3169
3162
  return modifiedEditableBoxes(boxes).map(function (_) {
3170
- return utils.callIfFunction(_.path);
3163
+ return _.path;
3171
3164
  });
3172
3165
  };
3173
3166
 
@@ -3195,7 +3188,7 @@ var ConfirmEditableBoxes = React.forwardRef(function (_ref, ref) {
3195
3188
  var validated = modifiedEditableBoxes(sharedBoxes()).reduce(function (_ref5, box) {
3196
3189
  var success = _ref5.success,
3197
3190
  errors = _ref5.errors;
3198
- var index = utils.callIfFunction(box.path);
3191
+ var index = box.path;
3199
3192
 
3200
3193
  var _box$modifiedValue = box.modifiedValue(),
3201
3194
  _box$modifiedValue2 = _slicedToArray(_box$modifiedValue, 2),
@@ -3494,39 +3487,18 @@ var EditableBoxPresentation = styled__default(React.forwardRef(function (_ref13,
3494
3487
 
3495
3488
  var SharedEditableTabBox = function SharedEditableTabBox(_ref15) {
3496
3489
  var path = _ref15.path,
3497
- isSingle = _ref15.isSingle,
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"]);
3490
+ props = _objectWithoutProperties(_ref15, ["path"]);
3503
3491
 
3504
3492
  var editableGroup = React.useContext(EditableContext);
3505
3493
  var form = React.useContext(FormContext);
3506
- var isNew = core.useRefState(function () {
3507
- return isSingle ? false : checkIsNew(utils._s.get(path, form.getOriginalValues()), form.getValue(path));
3508
- });
3494
+ var isNew = core.useRefState(utils._s.get(path, form.getOriginalValues()) !== form.getValue(path));
3509
3495
  var internalBox = React__default.useRef();
3510
- var pathRef = core.useRefMemo(path);
3511
3496
 
3512
3497
  var loading = function loading() {
3513
3498
  return internalBox.current.loading;
3514
3499
  };
3515
3500
 
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
- });
3501
+ var selfRef = React.useRef();
3530
3502
 
3531
3503
  var resetField = function resetField() {
3532
3504
  return form.resetField([].concat(path));
@@ -3546,6 +3518,12 @@ var SharedEditableTabBox = function SharedEditableTabBox(_ref15) {
3546
3518
  editableGroup.sharedBoxes.register(selfRef.current);
3547
3519
  };
3548
3520
 
3521
+ var modifiedValue = function modifiedValue() {
3522
+ var oldItem = internalBox.current.getValue(undefined, form.getOriginalValues());
3523
+ var newItem = internalBox.current.getValue();
3524
+ return newItem !== oldItem ? [newItem, true] : [oldItem, false];
3525
+ };
3526
+
3549
3527
  var validate = function validate(props, path) {
3550
3528
  var errors = editableGroup.itemValidation(props, path);
3551
3529
 
@@ -3636,6 +3614,12 @@ var SharedEditableTabBox = function SharedEditableTabBox(_ref15) {
3636
3614
  }
3637
3615
  };
3638
3616
 
3617
+ selfRef.current = {
3618
+ loading: loading,
3619
+ path: path,
3620
+ form: form,
3621
+ modifiedValue: modifiedValue
3622
+ };
3639
3623
  return React__default.createElement(EditableBoxPresentation, _extends({
3640
3624
  ref: internalBox,
3641
3625
  resetField: resetField,
@@ -3659,6 +3643,7 @@ var EditableBox = function EditableBox(_ref17) {
3659
3643
 
3660
3644
  var editableGroup = React.useContext(EditableContext);
3661
3645
  var form = React.useContext(FormContext);
3646
+ var selfRef = React.useRef();
3662
3647
  var internalBox = React__default.useRef();
3663
3648
 
3664
3649
  var resetField = function resetField() {
@@ -3711,17 +3696,14 @@ var EditableBox = function EditableBox(_ref17) {
3711
3696
  return internalBox.current.loading;
3712
3697
  };
3713
3698
 
3714
- var pathRef = core.useRefMemo(path);
3715
- var selfRef = React.useRef({
3699
+ selfRef.current = {
3716
3700
  loading: loading,
3717
- path: function path() {
3718
- return pathRef.current;
3719
- },
3701
+ path: path,
3720
3702
  form: form,
3721
3703
  modifiedValue: modifiedValue,
3722
3704
  handleSubmit: handleSubmit,
3723
3705
  close: close
3724
- });
3706
+ };
3725
3707
  return React__default.createElement(EditableBoxPresentation, _extends({
3726
3708
  ref: internalBox,
3727
3709
  resetField: resetField,
@@ -4287,9 +4269,10 @@ var DatePicker = React.forwardRef(function (_ref, maybeInputRef) {
4287
4269
 
4288
4270
  var stopFocusPropagation = function stopFocusPropagation(e) {
4289
4271
  return e.stopPropagation();
4290
- };
4272
+ }; // const calendarValue = new Date(!isNaN(time) && formValue !== -1 ? offsetedTime : now())
4273
+
4291
4274
 
4292
- var calendarValue = new Date(!isNaN(time) && formValue !== -1 ? offsetedTime : now());
4275
+ var calendarValue = new Date(!isNaN(time) && formValue !== -1 ? offsetedTime : nowTimeZoneAdjusted(timezoneOffset));
4293
4276
  calendarValue.setUTCHours(0, 0, 0);
4294
4277
  return React__default.createElement(Field, {
4295
4278
  helpText: helpText,
@@ -4485,6 +4468,15 @@ function now() {
4485
4468
  return dt;
4486
4469
  }
4487
4470
 
4471
+ function nowTimeZoneAdjusted(timezoneOffset) {
4472
+ var timezoneOffsetMilliseconds = timezoneOffset * 3600000; // 3600000 milliseconds in an hour
4473
+
4474
+ var dt = new Date();
4475
+ dt.setTime(dt.getTime() + timezoneOffsetMilliseconds);
4476
+ dt.setUTCHours(0, 0, 0, 0);
4477
+ return dt;
4478
+ }
4479
+
4488
4480
  function inRange(context, date) {
4489
4481
  return context.min <= date && context.max >= date;
4490
4482
  }
@@ -4701,232 +4693,6 @@ function getClosestNextLeapYear(year) {
4701
4693
  return y;
4702
4694
  }
4703
4695
 
4704
- function _templateObject$6() {
4705
- var data = _taggedTemplateLiteral(["\n padding 1rem;\n "]);
4706
-
4707
- _templateObject$6 = function _templateObject() {
4708
- return data;
4709
- };
4710
-
4711
- return data;
4712
- }
4713
-
4714
- var shouldPreventExpand = function shouldPreventExpand(fn) {
4715
- return function (e) {
4716
- return e.target.closest('body,[data-expand="false"],label,input,textarea,button').matches('body,[data-expand="true"]') && fn(e);
4717
- };
4718
- };
4719
-
4720
- var ExpandableBoxStyled = styled__default.div.withConfig({
4721
- displayName: "ExpandableBox__ExpandableBoxStyled",
4722
- componentId: "sc-1nsk1wq-0"
4723
- })(["padding:1rem;border-radius:6px;background:", ";font-size:14px;outline:none;transition:background 0.25s linear;position:relative;", " ", " & ~ &{margin-top:0.75rem;}", " &{margin-top:0.75rem;}"], utils.getColor('gray240'), function (props) {
4724
- return props.small && "\n padding: 0.875rem 1rem;\n min-height: 3rem;\n ";
4725
- }, function (props) {
4726
- return props.collapsed ? styled.css(["cursor:pointer;padding-right:3.25rem;:hover{background:", ";}:active{background:", ";}"], function (props) {
4727
- return polished.darken(0.05, utils.getColor("gray240")(props));
4728
- }, function (props) {
4729
- return polished.darken(0.08, utils.getColor("gray240")(props));
4730
- }) : styled.css(["padding 1.5rem;", " ", ""], utils.media.max(340)(_templateObject$6()), function (props) {
4731
- return props.fixMarginBottom && "\n padding-bottom: 0.5rem !important;\n ";
4732
- });
4733
- }, components.SwitchDiv);
4734
- var EditIcon = styled__default(components.Icon).attrs({
4735
- icon: 'edit'
4736
- }).withConfig({
4737
- displayName: "ExpandableBox__EditIcon",
4738
- componentId: "sc-1nsk1wq-1"
4739
- })(["position:absolute;top:50%;transform:translateY(-50%);right:-24px;color:rgba(0,0,0,0.25);font-size:20px;"]);
4740
- var checkErrors = function checkErrors() {
4741
- for (var _len = arguments.length, checks = new Array(_len), _key = 0; _key < _len; _key++) {
4742
- checks[_key] = arguments[_key];
4743
- }
4744
-
4745
- return function (v, setErrors) {
4746
- var results = checks.map(function (c) {
4747
- return c(v);
4748
- }).filter(Boolean);
4749
-
4750
- if (!results.length) {
4751
- return true;
4752
- }
4753
-
4754
- var messages = results.filter(_negate(_isBoolean));
4755
-
4756
- if (messages.length) {
4757
- setErrors.apply(void 0, _toConsumableArray(messages));
4758
- }
4759
-
4760
- return false;
4761
- };
4762
- };
4763
- var timing = utils.animationTiming('0.25s ease-out');
4764
- var switchAnimation = utils.oneWayAnimation('opacity: 1;transform:translateY(0);', 'opacity: 0;', 'opacity: 0; transform:translateY(30px);');
4765
- var ExpandableBox = function ExpandableBox(_ref) {
4766
- var children = _ref.children,
4767
- info = _ref.info,
4768
- isOpen = _ref.isOpen,
4769
- openWhen = _ref.openWhen,
4770
- path = _ref.path,
4771
- _ref$retargetFilter = _ref.retargetFilter,
4772
- retargetFilter = _ref$retargetFilter === void 0 ? function (el) {
4773
- var _el$tagName;
4774
-
4775
- return (el === null || el === void 0 ? void 0 : (_el$tagName = el.tagName) === null || _el$tagName === void 0 ? void 0 : _el$tagName.toLowerCase()) === "button";
4776
- } : _ref$retargetFilter,
4777
- _ref$isValid = _ref.isValid,
4778
- isValid = _ref$isValid === void 0 ? function () {
4779
- return true;
4780
- } : _ref$isValid,
4781
- fixMarginBottom = _ref.fixMarginBottom,
4782
- _ref$animation = _ref.animation,
4783
- animation = _ref$animation === void 0 ? switchAnimation : _ref$animation,
4784
- _ref$animationTiming = _ref.animationTiming,
4785
- animationTiming = _ref$animationTiming === void 0 ? timing : _ref$animationTiming;
4786
- var flipAnimation = core.useLazyConstant(components.willUseFlipSwitch);
4787
-
4788
- var _useFormValue = form.useFormValue(path),
4789
- _useFormValue2 = _slicedToArray(_useFormValue, 3),
4790
- value = _useFormValue2[0],
4791
- setValue = _useFormValue2[1],
4792
- getValue = _useFormValue2[2];
4793
-
4794
- var _useTransientErrorHel = useTransientErrorHelper(),
4795
- _useTransientErrorHel2 = _slicedToArray(_useTransientErrorHel, 2),
4796
- _setErrors = _useTransientErrorHel2[0],
4797
- clearErrors = _useTransientErrorHel2[1];
4798
-
4799
- var setErrors = function setErrors() {
4800
- for (var _len2 = arguments.length, errors = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
4801
- errors[_key2] = arguments[_key2];
4802
- }
4803
-
4804
- _setErrors(errors.length ? errors.map(function (k) {
4805
- return _isString(k) ? [k, ''] : k;
4806
- }) : [[path, '']]);
4807
-
4808
- return true;
4809
- };
4810
-
4811
- var expand = core.useToggle(isOpen, function (newV, prevV) {
4812
- if (newV === 0 || prevV === 0) {
4813
- return;
4814
- }
4815
-
4816
- if (newV === false) {
4817
- var result = isValid(getValue(), setErrors);
4818
-
4819
- if (result === true) {
4820
- clearErrors();
4821
- }
4822
-
4823
- return result;
4824
- }
4825
- });
4826
- var openWhenResult = utils.callIfFunction(openWhen);
4827
- React.useEffect(function () {
4828
- if (openWhenResult) {
4829
- expand.open();
4830
- }
4831
- }, [openWhenResult]);
4832
- React.useEffect(function () {
4833
- return function () {
4834
- if (expand.get() === 0) {
4835
- expand.close();
4836
- }
4837
- };
4838
- }, [expand.isOpen]);
4839
- var utils$1 = core.useLazyConstant(function () {
4840
- return {
4841
- close: utils.constrainEvent(expand.close),
4842
- setValue: setValue
4843
- };
4844
- });
4845
-
4846
- var onBlur = function onBlur(e) {
4847
- if (e.currentTarget !== e.relatedTarget && (!e.relatedTarget || !e.currentTarget.contains(e.relatedTarget))) {
4848
- if (utils.callIfFunction(retargetFilter, e.relatedTarget)) {
4849
- e.target.focus();
4850
- } else {
4851
- expand.close();
4852
- }
4853
- }
4854
- };
4855
-
4856
- return React__default.createElement(ExpandableBoxStyled, {
4857
- tabIndex: -1,
4858
- onBlur: onBlur,
4859
- collapsed: !expand.isOpen,
4860
- fixMarginBottom: fixMarginBottom,
4861
- onClick: shouldPreventExpand(expand.open)
4862
- }, React__default.createElement(FlipDiv$1, {
4863
- key: expand.isOpen,
4864
- useAnimation: flipAnimation,
4865
- animation: animation,
4866
- animationTiming: animationTiming
4867
- }, expand.isOpen ? utils.callIfFunction(children, value, utils$1) : React__default.createElement(React__default.Fragment, null, utils.callIfFunction(info, value, utils$1), React__default.createElement(EditIcon, null))));
4868
- };
4869
-
4870
- var overflowEffect = function overflowEffect(element) {
4871
- var _element$offsetParent;
4872
-
4873
- if (!(element === null || element === void 0 ? void 0 : (_element$offsetParent = element.offsetParent) === null || _element$offsetParent === void 0 ? void 0 : _element$offsetParent.parentElement)) {
4874
- return;
4875
- }
4876
-
4877
- var parentDom = element.offsetParent.parentElement;
4878
- var previousOverflow = parentDom.style.overflow;
4879
- parentDom.style.overflow = 'hidden';
4880
- return function () {
4881
- return parentDom.style.overflow = previousOverflow;
4882
- };
4883
- };
4884
-
4885
- var PseudoExpandableBox = function PseudoExpandableBox(_ref2) {
4886
- var children = _ref2.children,
4887
- small = _ref2.small,
4888
- onClick = _ref2.onClick;
4889
- return React__default.createElement(ExpandableBoxStyled, {
4890
- collapsed: true,
4891
- small: small,
4892
- onClick: onClick
4893
- }, React__default.createElement(FlipDivStyle, null, children, React__default.createElement(EditIcon, null)));
4894
- };
4895
- var FlipDivStyle = styled__default.div.withConfig({
4896
- displayName: "ExpandableBox__FlipDivStyle",
4897
- componentId: "sc-1nsk1wq-2"
4898
- })(["position:relative;"]);
4899
-
4900
- var FlipDiv$1 = function FlipDiv(_ref3) {
4901
- var useAnimation = _ref3.useAnimation,
4902
- animation = _ref3.animation,
4903
- animationTiming = _ref3.animationTiming,
4904
- props = _objectWithoutProperties(_ref3, ["useAnimation", "animation", "animationTiming"]);
4905
-
4906
- var ref = React.useRef();
4907
- useAnimation(ref, null, null, {
4908
- switchAnimation: animation,
4909
- timing: animationTiming,
4910
- effect: overflowEffect
4911
- });
4912
- return React__default.createElement(FlipDivStyle, _extends({}, props, {
4913
- ref: ref
4914
- }));
4915
- };
4916
-
4917
- function _templateObject$7() {
4918
- var data = _taggedTemplateLiteral(["\n padding-right: 2.25rem;\n background: rgba(0,0,0,0.075);\n "]);
4919
-
4920
- _templateObject$7 = function _templateObject() {
4921
- return data;
4922
- };
4923
-
4924
- return data;
4925
- }
4926
- var InputIcon$1 = styled__default(components.Icon).withConfig({
4927
- displayName: "RichText__InputIcon",
4928
- componentId: "x8c1ig-0"
4929
- })(["position:absolute;outline:none;bottom:0;font-size:21px;line-height:3rem;right:0;width:2rem;pointer-events:none;color:", ";"], utils.getColor('gray150'));
4930
4696
  var FORMAT_TOOLS = {
4931
4697
  'bold': ['b', 'strong'],
4932
4698
  'italic': 'i',
@@ -5001,19 +4767,17 @@ var FIX_STYLE = {
5001
4767
  };
5002
4768
  var RichTextContainer = styled__default.div.withConfig({
5003
4769
  displayName: "RichText__RichTextContainer",
5004
- componentId: "x8c1ig-1"
5005
- })(["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) {
4770
+ componentId: "x8c1ig-0"
4771
+ })(["position:relative;width:100%;border:1px solid ", ";border-radius:6px;background:white;", ";", ";", ""], utils.getColor('gray210'), function (props) {
5006
4772
  return props.hasErrors && "border-color: ".concat(utils.getColor(props)('alert'));
5007
4773
  }, function (props) {
5008
4774
  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 ");
5009
4775
  }, function (props) {
5010
4776
  return props.focus && "\n border-color: ".concat(utils.getColor('gray180'), ";\n box-shadow: 0px 0px 0px 2px rgba(0,0,0,0.1);\n ");
5011
- }, function (props) {
5012
- return props.locked && css(_templateObject$7());
5013
4777
  });
5014
4778
  var RichTextInput = styled__default.div.withConfig({
5015
4779
  displayName: "RichText__RichTextInput",
5016
- componentId: "x8c1ig-2"
4780
+ componentId: "x8c1ig-1"
5017
4781
  })(["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) {
5018
4782
  return props.minHeight || 78;
5019
4783
  }, function (props) {
@@ -5021,15 +4785,15 @@ var RichTextInput = styled__default.div.withConfig({
5021
4785
  });
5022
4786
  var ToolsContainer = styled__default.div.withConfig({
5023
4787
  displayName: "RichText__ToolsContainer",
5024
- componentId: "x8c1ig-3"
4788
+ componentId: "x8c1ig-2"
5025
4789
  })(["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'));
5026
4790
  var ToolButton = styled__default(components.Button).withConfig({
5027
4791
  displayName: "RichText__ToolButton",
5028
- componentId: "x8c1ig-4"
4792
+ componentId: "x8c1ig-3"
5029
4793
  })(["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'));
5030
4794
  var ToolSeparator = styled__default.span.withConfig({
5031
4795
  displayName: "RichText__ToolSeparator",
5032
- componentId: "x8c1ig-5"
4796
+ componentId: "x8c1ig-4"
5033
4797
  })(["border-left:1px solid ", ";margin-left:0.75rem;margin-right:0.5rem;line-height:2rem;vertical-align:-6px;"], utils.getColor('gray180'));
5034
4798
  var JS_CLASS = "EDITOR--JS";
5035
4799
 
@@ -5128,10 +4892,6 @@ var cleanEditor = function cleanEditor(editor, acceptedTags) {
5128
4892
  clean(el.childNodes);
5129
4893
  el.removeAttribute('class');
5130
4894
 
5131
- if (tagName === 'a') {
5132
- el.setAttribute('target', '_blank');
5133
- }
5134
-
5135
4895
  if (el.getAttribute('style')) {
5136
4896
  var usedStyles = _toPairs(_pick(acceptedStyles, el.style)).filter(function (_ref) {
5137
4897
  var _ref2 = _slicedToArray(_ref, 2),
@@ -5227,7 +4987,7 @@ var RichText = function RichText(_ref5) {
5227
4987
  placeholder = _ref5.placeholder,
5228
4988
  className = _ref5.className,
5229
4989
  _ref5$formatTools = _ref5.formatTools,
5230
- formatTools = _ref5$formatTools === void 0 ? ['link', 'bold', 'italic', 'underline', 'strikethrough'] : _ref5$formatTools,
4990
+ formatTools = _ref5$formatTools === void 0 ? ['bold', 'italic', 'underline', 'strikethrough'] : _ref5$formatTools,
5231
4991
  _ref5$reformatText = _ref5.reformatText,
5232
4992
  reformatText = _ref5$reformatText === void 0 ? _identity : _ref5$reformatText,
5233
4993
  mandatory = _ref5.mandatory,
@@ -5235,11 +4995,7 @@ var RichText = function RichText(_ref5) {
5235
4995
  helpText = _ref5.helpText,
5236
4996
  linkColor = _ref5.linkColor,
5237
4997
  _ref5$tabIndex = _ref5.tabIndex,
5238
- tabIndex = _ref5$tabIndex === void 0 ? 1 : _ref5$tabIndex,
5239
- value = _ref5.value,
5240
- setValue = _ref5.setValue,
5241
- raw = _ref5.raw,
5242
- locked = _ref5.locked;
4998
+ tabIndex = _ref5$tabIndex === void 0 ? 1 : _ref5$tabIndex;
5243
4999
  var linkPopup = core.usePopupToggle();
5244
5000
  var input = core.useEnsureRef(inputRef);
5245
5001
  var activeLinkNode = React.useRef();
@@ -5251,34 +5007,21 @@ var RichText = function RichText(_ref5) {
5251
5007
  var commands = core.useRefState([]);
5252
5008
  var containerFocused = core.useToggle();
5253
5009
  var needsNormalize = core.useRefState();
5254
- var alreadyCancelled = core.useRefState(); // const [formValue, setFormValue] = useInput({path})
5010
+ var alreadyCancelled = core.useRefState();
5255
5011
 
5256
5012
  var _useInput = useInput({
5257
- path: path,
5258
- value: value,
5259
- setValue: setValue
5260
- }, raw),
5261
- _useInput2 = _slicedToArray(_useInput, 3),
5013
+ path: path
5014
+ }),
5015
+ _useInput2 = _slicedToArray(_useInput, 2),
5262
5016
  formValue = _useInput2[0],
5263
- setFormValue = _useInput2[1],
5264
- hasErrors = _useInput2[2].hasErrors; // const tempValue = useConstant(formValue)
5017
+ setFormValue = _useInput2[1];
5265
5018
 
5019
+ var tempValue = core.useConstant(formValue);
5266
5020
 
5267
- var _useState = React.useState(formValue),
5021
+ var _useState = React.useState({}),
5268
5022
  _useState2 = _slicedToArray(_useState, 2),
5269
- tempValue = _useState2[0],
5270
- setTempValue = _useState2[1];
5271
-
5272
- React.useEffect(function () {
5273
- if (value === formValue && formValue !== tempValue) {
5274
- setTempValue(formValue);
5275
- }
5276
- }, [path]);
5277
-
5278
- var _useState3 = React.useState({}),
5279
- _useState4 = _slicedToArray(_useState3, 2),
5280
- activatedTools = _useState4[0],
5281
- setActivatedTools = _useState4[1];
5023
+ activatedTools = _useState2[0],
5024
+ setActivatedTools = _useState2[1];
5282
5025
 
5283
5026
  var validElements = core.useLazyConstant(function () {
5284
5027
  return ['br', 'div', 'p', 'span'].concat(_flatten(formatTools.map(function (tool) {
@@ -5314,6 +5057,8 @@ var RichText = function RichText(_ref5) {
5314
5057
  };
5315
5058
 
5316
5059
  var containerBlur = function containerBlur(e) {
5060
+ console.log(e.target, e.currentTarget);
5061
+
5317
5062
  if (containerFocused.isOpen !== 1) {
5318
5063
  containerFocused.close();
5319
5064
  triggerScrollForPanel(Date.now());
@@ -5328,26 +5073,6 @@ var RichText = function RichText(_ref5) {
5328
5073
  }
5329
5074
  };
5330
5075
 
5331
- var keydownHandler = function keydownHandler(e) {
5332
- if (containerFocused.isOpen === 2) {
5333
- if (formatTools.indexOf('link') < 0) {
5334
- return;
5335
- }
5336
-
5337
- if (e.key === "k" && e.ctrlKey || e.key === "k" && e.metaKey) {
5338
- e.preventDefault();
5339
- execCommand(null, 'link');
5340
- }
5341
- }
5342
- };
5343
-
5344
- React.useEffect(function () {
5345
- document.addEventListener('keydown', keydownHandler);
5346
- return function () {
5347
- return document.removeEventListener('keydown', keydownHandler);
5348
- };
5349
- }, [containerFocused.isOpen]);
5350
-
5351
5076
  var execCommand = function execCommand(e, command) {
5352
5077
  if (command === 'link') {
5353
5078
  var nodeEl;
@@ -5382,23 +5107,17 @@ var RichText = function RichText(_ref5) {
5382
5107
  _anchor.innerHTML = '&#8203;';
5383
5108
 
5384
5109
  if (range.collapsed) {
5385
- range.insertNode(_anchor);
5110
+ window.getSelection().getRangeAt(0).insertNode(_anchor);
5386
5111
  } else {
5387
- if (range.commonAncestorContainer === input.current) {
5388
- range.setStart(range.endContainer, 0);
5389
- }
5390
-
5391
5112
  document.execCommand('createLink', false, '_');
5392
5113
  _anchor = window.getSelection().anchorNode;
5393
5114
  }
5394
5115
 
5395
- var _parent = range.commonAncestorContainer.nodeType === 3 ? range.commonAncestorContainer.parentNode : range.commonAncestorContainer;
5116
+ var _parent = _anchor.nodeName === 'A' ? _anchor : _anchor.parentElement.matches('a') ? _anchor.parentElement : _anchor.nextSibling;
5396
5117
 
5397
- var links = _parent.querySelectorAll("a[href='_']");
5118
+ _parent.setAttribute('href', ' ');
5398
5119
 
5399
- Array.from(links).slice(0, -1).forEach(removeLinkFromNode);
5400
- nodeEl = _last(links);
5401
- nodeEl.setAttribute('href', ' ');
5120
+ nodeEl = _parent;
5402
5121
  }
5403
5122
  }
5404
5123
 
@@ -5436,25 +5155,11 @@ var RichText = function RichText(_ref5) {
5436
5155
  containerFocused.openWith(1);
5437
5156
  focus();
5438
5157
  }
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
- }
5453
5158
  };
5454
5159
 
5455
5160
  var execCommandMouseUp = function execCommandMouseUp() {
5456
5161
  if (startSelectionToken.get()) {
5457
- // window.getSelection().removeAllRanges()
5162
+ window.getSelection().removeAllRanges();
5458
5163
  var range = document.createRange();
5459
5164
  range.setStart(startSelectionToken.get().nextSibling, 0);
5460
5165
  var end = endSelectionToken.get().nextSibling;
@@ -5470,9 +5175,8 @@ var RichText = function RichText(_ref5) {
5470
5175
 
5471
5176
  commands.get().forEach(function (c) {
5472
5177
  return parseAndExecCommand(c);
5473
- }); // commands.set(_.without(['insertUnorderedList','insertOrderedList','outdent','indent']))
5474
-
5475
- commands.set([]);
5178
+ });
5179
+ commands.set(_without(['insertUnorderedList', 'insertOrderedList', 'outdent', 'indent']));
5476
5180
  setFormValue(input.current.innerHTML);
5477
5181
  containerFocused.openWith(2);
5478
5182
  toggleButtonsState();
@@ -5622,14 +5326,10 @@ var RichText = function RichText(_ref5) {
5622
5326
  });
5623
5327
  };
5624
5328
 
5625
- var removeLinkFromNode = function removeLinkFromNode(node) {
5626
- node.outerHTML = node.innerHTML === "\u200B" ? '' : node.innerHTML;
5627
- };
5628
-
5629
5329
  var removeLink = function removeLink(e) {
5630
5330
  if (e) e.preventDefault();
5631
5331
  alreadyCancelled.set(true);
5632
- removeLinkFromNode(activeLinkNode.current);
5332
+ activeLinkNode.current.outerHTML = activeLinkNode.current.innerHTML === "\u200B" ? '' : activeLinkNode.current.innerHTML;
5633
5333
  linkPopup.close();
5634
5334
 
5635
5335
  if (input.current) {
@@ -5698,8 +5398,6 @@ var RichText = function RichText(_ref5) {
5698
5398
  className: JS_CLASS,
5699
5399
  minHeight: minHeight,
5700
5400
  placeholder: placeholder
5701
- }), locked && React__default.createElement(InputIcon$1, {
5702
- icon: "lock"
5703
5401
  }), linkPopup.isOpen && React__default.createElement(EditLinkPopup, {
5704
5402
  input: input,
5705
5403
  activeLinkNode: activeLinkNode,
@@ -5726,22 +5424,19 @@ var EditLinkPopup = function EditLinkPopup(_ref7) {
5726
5424
  values = _ref7.values;
5727
5425
  var linkPopup = React.useRef();
5728
5426
  var formRef = React.useRef();
5729
- var linkTextRef = React.useRef();
5730
- var linkUrlRef = React.useRef();
5731
- var LABELS = React.useContext(core.StartlibsContext).labels.RichText;
5732
5427
 
5733
5428
  var preValidation = function preValidation(formValues) {
5734
5429
  var errors;
5735
5430
 
5736
5431
  if (!formValues.linkText) {
5737
5432
  errors = {
5738
- 'linkText': [LABELS.linkTextError]
5433
+ 'linkText': ['Campos com asterisco (*) são obrigatórios.']
5739
5434
  };
5740
5435
  }
5741
5436
 
5742
5437
  if (!formValues.linkUrl || formValues.linkUrl === ' ' || !utils.linkRegex.test(formValues.linkUrl.trim())) {
5743
5438
  errors = _objectSpread({}, errors, {
5744
- 'linkUrl': [LABELS.linkUrlError]
5439
+ 'linkUrl': ['Adicione um endereço válido.']
5745
5440
  });
5746
5441
  }
5747
5442
 
@@ -5750,8 +5445,7 @@ var EditLinkPopup = function EditLinkPopup(_ref7) {
5750
5445
 
5751
5446
  var checkEscOrEnter = function checkEscOrEnter(e) {
5752
5447
  if (e.keyCode === 27) {
5753
- e.stopPropagation();
5754
- cancel(e);
5448
+ e.stopPropagation().cancel(e);
5755
5449
  } else if (e.keyCode === 13) {
5756
5450
  e.preventDefault();
5757
5451
  e.stopPropagation();
@@ -5770,13 +5464,6 @@ var EditLinkPopup = function EditLinkPopup(_ref7) {
5770
5464
  'left': left + 'px',
5771
5465
  'top': top + 'px'
5772
5466
  });
5773
-
5774
- if (values.linkText) {
5775
- linkUrlRef.current.focus();
5776
- } else {
5777
- linkTextRef.current.focus();
5778
- }
5779
-
5780
5467
  return cancel;
5781
5468
  }, []);
5782
5469
  return React__default.createElement(WithForm, {
@@ -5793,29 +5480,230 @@ var EditLinkPopup = function EditLinkPopup(_ref7) {
5793
5480
  className: "popup rich-text-link-editor ignore-link",
5794
5481
  contentEditable: false
5795
5482
  }, React__default.createElement(TextInput, {
5796
- ref: linkTextRef,
5483
+ autoFocus: !values.linkText,
5797
5484
  mandatory: true,
5798
5485
  path: "linkText",
5799
- label: LABELS.popupLinkText
5486
+ label: "Texto de exibi\xE7\xE3o"
5800
5487
  }), React__default.createElement(TextInput, {
5801
- ref: linkUrlRef,
5488
+ autoFocus: values.linkText,
5802
5489
  mandatory: true,
5803
5490
  path: "linkUrl",
5804
- label: LABELS.popupLinkUrl
5491
+ label: "Endere\xE7o completo"
5805
5492
  }), React__default.createElement("div", {
5806
5493
  className: "popup-footer"
5807
5494
  }, React__default.createElement(components.Button, {
5808
5495
  className: "remove-link",
5809
5496
  icon: "remove",
5810
5497
  onClick: removeLink
5811
- }, LABELS.popupRemove), React__default.createElement(components.Button, {
5498
+ }, "Remover Link"), React__default.createElement(components.Button, {
5812
5499
  onClick: cancel,
5813
5500
  tabIndex: 0
5814
- }, LABELS.popupCancel), React__default.createElement(components.Button, {
5501
+ }, "Cancelar"), React__default.createElement(components.Button, {
5815
5502
  highlight: true,
5816
5503
  onClick: form.willSubmitForm
5817
- }, LABELS.popupConfirm)), React__default.createElement(Errors, null));
5504
+ }, "Aplicar")), React__default.createElement(Errors, null));
5505
+ });
5506
+ };
5507
+
5508
+ function _templateObject$6() {
5509
+ var data = _taggedTemplateLiteral(["\n padding 1rem;\n "]);
5510
+
5511
+ _templateObject$6 = function _templateObject() {
5512
+ return data;
5513
+ };
5514
+
5515
+ return data;
5516
+ }
5517
+
5518
+ var shouldPreventExpand = function shouldPreventExpand(fn) {
5519
+ return function (e) {
5520
+ return e.target.closest('body,[data-expand="false"],label,input,textarea,button').matches('body,[data-expand="true"]') && fn(e);
5521
+ };
5522
+ };
5523
+
5524
+ var ExpandableBoxStyled = styled__default.div.withConfig({
5525
+ displayName: "ExpandableBox__ExpandableBoxStyled",
5526
+ componentId: "sc-1nsk1wq-0"
5527
+ })(["padding:1rem;border-radius:8px;background:", ";font-size:14px;outline:none;transition:background 0.25s linear;", " & ~ &{margin-top:0.75rem;}", " &{margin-top:0.75rem;}"], utils.getColor('gray240'), function (props) {
5528
+ return props.collapsed ? styled.css(["cursor:pointer;padding-right:3.25rem;:hover{background:", ";}:active{background:", ";}"], function (props) {
5529
+ return polished.darken(0.05, utils.getColor("gray240")(props));
5530
+ }, function (props) {
5531
+ return polished.darken(0.08, utils.getColor("gray240")(props));
5532
+ }) : styled.css(["padding 1.5rem;", " ", ""], utils.media.max(340)(_templateObject$6()), function (props) {
5533
+ return props.fixMarginBottom && "\n padding-bottom: 0.5rem !important;\n ";
5818
5534
  });
5535
+ }, components.SwitchDiv);
5536
+ var EditIcon = styled__default(components.Icon).attrs({
5537
+ icon: 'edit'
5538
+ }).withConfig({
5539
+ displayName: "ExpandableBox__EditIcon",
5540
+ componentId: "sc-1nsk1wq-1"
5541
+ })(["position:absolute;top:50%;transform:translateY(-50%);right:-24px;color:rgba(0,0,0,0.25);font-size:20px;"]);
5542
+ var checkErrors = function checkErrors() {
5543
+ for (var _len = arguments.length, checks = new Array(_len), _key = 0; _key < _len; _key++) {
5544
+ checks[_key] = arguments[_key];
5545
+ }
5546
+
5547
+ return function (v, setErrors) {
5548
+ var results = checks.map(function (c) {
5549
+ return c(v);
5550
+ }).filter(Boolean);
5551
+
5552
+ if (!results.length) {
5553
+ return true;
5554
+ }
5555
+
5556
+ var messages = results.filter(_negate(_isBoolean));
5557
+
5558
+ if (messages.length) {
5559
+ setErrors.apply(void 0, _toConsumableArray(messages));
5560
+ }
5561
+
5562
+ return false;
5563
+ };
5564
+ };
5565
+ var timing = utils.animationTiming('0.25s ease-out');
5566
+ var switchAnimation = utils.oneWayAnimation('opacity: 1;transform:translateY(0);', 'opacity: 0;', 'opacity: 0; transform:translateY(30px);');
5567
+ var ExpandableBox = function ExpandableBox(_ref) {
5568
+ var children = _ref.children,
5569
+ info = _ref.info,
5570
+ isOpen = _ref.isOpen,
5571
+ openWhen = _ref.openWhen,
5572
+ path = _ref.path,
5573
+ _ref$retargetFilter = _ref.retargetFilter,
5574
+ retargetFilter = _ref$retargetFilter === void 0 ? function (el) {
5575
+ var _el$tagName;
5576
+
5577
+ return (el === null || el === void 0 ? void 0 : (_el$tagName = el.tagName) === null || _el$tagName === void 0 ? void 0 : _el$tagName.toLowerCase()) === "button";
5578
+ } : _ref$retargetFilter,
5579
+ _ref$isValid = _ref.isValid,
5580
+ isValid = _ref$isValid === void 0 ? function () {
5581
+ return true;
5582
+ } : _ref$isValid,
5583
+ fixMarginBottom = _ref.fixMarginBottom,
5584
+ _ref$animation = _ref.animation,
5585
+ animation = _ref$animation === void 0 ? switchAnimation : _ref$animation,
5586
+ _ref$animationTiming = _ref.animationTiming,
5587
+ animationTiming = _ref$animationTiming === void 0 ? timing : _ref$animationTiming;
5588
+ var flipAnimation = core.useLazyConstant(components.willUseFlipSwitch);
5589
+
5590
+ var _useFormValue = form.useFormValue(path),
5591
+ _useFormValue2 = _slicedToArray(_useFormValue, 3),
5592
+ value = _useFormValue2[0],
5593
+ setValue = _useFormValue2[1],
5594
+ getValue = _useFormValue2[2];
5595
+
5596
+ var _useTransientErrorHel = useTransientErrorHelper(),
5597
+ _useTransientErrorHel2 = _slicedToArray(_useTransientErrorHel, 2),
5598
+ _setErrors = _useTransientErrorHel2[0],
5599
+ clearErrors = _useTransientErrorHel2[1];
5600
+
5601
+ var setErrors = function setErrors() {
5602
+ for (var _len2 = arguments.length, errors = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
5603
+ errors[_key2] = arguments[_key2];
5604
+ }
5605
+
5606
+ _setErrors(errors.length ? errors.map(function (k) {
5607
+ return _isString(k) ? [k, ''] : k;
5608
+ }) : [[path, '']]);
5609
+
5610
+ return true;
5611
+ };
5612
+
5613
+ var expand = core.useToggle(isOpen, function (newV, prevV) {
5614
+ if (newV === 0 || prevV === 0) {
5615
+ return;
5616
+ }
5617
+
5618
+ if (newV === false) {
5619
+ var result = isValid(getValue(), setErrors);
5620
+
5621
+ if (result === true) {
5622
+ clearErrors();
5623
+ }
5624
+
5625
+ return result;
5626
+ }
5627
+ });
5628
+ var openWhenResult = utils.callIfFunction(openWhen);
5629
+ React.useEffect(function () {
5630
+ if (openWhenResult) {
5631
+ expand.open();
5632
+ }
5633
+ }, [openWhenResult]);
5634
+ React.useEffect(function () {
5635
+ return function () {
5636
+ if (expand.get() === 0) {
5637
+ expand.close();
5638
+ }
5639
+ };
5640
+ }, [expand.isOpen]);
5641
+ var utils$1 = core.useLazyConstant(function () {
5642
+ return {
5643
+ close: utils.constrainEvent(expand.close),
5644
+ setValue: setValue
5645
+ };
5646
+ });
5647
+
5648
+ var onBlur = function onBlur(e) {
5649
+ if (e.currentTarget !== e.relatedTarget && (!e.relatedTarget || !e.currentTarget.contains(e.relatedTarget))) {
5650
+ if (utils.callIfFunction(retargetFilter, e.relatedTarget)) {
5651
+ e.target.focus();
5652
+ } else {
5653
+ expand.close();
5654
+ }
5655
+ }
5656
+ };
5657
+
5658
+ return React__default.createElement(ExpandableBoxStyled, {
5659
+ tabIndex: -1,
5660
+ onBlur: onBlur,
5661
+ collapsed: !expand.isOpen,
5662
+ fixMarginBottom: fixMarginBottom,
5663
+ onClick: shouldPreventExpand(expand.open)
5664
+ }, React__default.createElement(FlipDiv$1, {
5665
+ key: expand.isOpen,
5666
+ useAnimation: flipAnimation,
5667
+ animation: animation,
5668
+ animationTiming: animationTiming
5669
+ }, expand.isOpen ? utils.callIfFunction(children, value, utils$1) : React__default.createElement(React__default.Fragment, null, utils.callIfFunction(info, value, utils$1), React__default.createElement(EditIcon, null))));
5670
+ };
5671
+
5672
+ var overflowEffect = function overflowEffect(element) {
5673
+ var _element$offsetParent;
5674
+
5675
+ if (!(element === null || element === void 0 ? void 0 : (_element$offsetParent = element.offsetParent) === null || _element$offsetParent === void 0 ? void 0 : _element$offsetParent.parentElement)) {
5676
+ return;
5677
+ }
5678
+
5679
+ var parentDom = element.offsetParent.parentElement;
5680
+ var previousOverflow = parentDom.style.overflow;
5681
+ parentDom.style.overflow = 'hidden';
5682
+ return function () {
5683
+ return parentDom.style.overflow = previousOverflow;
5684
+ };
5685
+ };
5686
+
5687
+ var FlipDivStyle = styled__default.div.withConfig({
5688
+ displayName: "ExpandableBox__FlipDivStyle",
5689
+ componentId: "sc-1nsk1wq-2"
5690
+ })(["position:relative;"]);
5691
+
5692
+ var FlipDiv$1 = function FlipDiv(_ref2) {
5693
+ var useAnimation = _ref2.useAnimation,
5694
+ animation = _ref2.animation,
5695
+ animationTiming = _ref2.animationTiming,
5696
+ props = _objectWithoutProperties(_ref2, ["useAnimation", "animation", "animationTiming"]);
5697
+
5698
+ var ref = React.useRef();
5699
+ useAnimation(ref, null, null, {
5700
+ switchAnimation: animation,
5701
+ timing: animationTiming,
5702
+ effect: overflowEffect
5703
+ });
5704
+ return React__default.createElement(FlipDivStyle, _extends({}, props, {
5705
+ ref: ref
5706
+ }));
5819
5707
  };
5820
5708
 
5821
5709
  var IconRadioBoxText = styled__default.div.withConfig({
@@ -5883,11 +5771,11 @@ var Toggle = styled__default.div.withConfig({
5883
5771
  var ToggleLabel = styled__default.div.withConfig({
5884
5772
  displayName: "ToggleCheckbox__ToggleLabel",
5885
5773
  componentId: "sc-11ob8ah-2"
5886
- })(["flex-basis:0;flex-grow:1;display:inline-block;font-size:14px;"]);
5774
+ })(["flex-basis:0;flex-grow:1;display:inline-block;font-size:13px;"]);
5887
5775
  var DescText$2 = styled__default.div.withConfig({
5888
5776
  displayName: "ToggleCheckbox__DescText",
5889
5777
  componentId: "sc-11ob8ah-3"
5890
- })(["font-weight:400;color:rgba(0,0,0,0.4);font-size:12px;margin-top:0.25rem;"]);
5778
+ })(["font-weight:400;color:", ";font-size:12px;margin-top:0.25rem;"], utils.getColor('gray120'));
5891
5779
  var ToggleCheckbox = styled__default(function (_ref) {
5892
5780
  var path = _ref.path,
5893
5781
  disabled = _ref.disabled,
@@ -5915,16 +5803,16 @@ var ToggleCheckbox = styled__default(function (_ref) {
5915
5803
  }).withConfig({
5916
5804
  displayName: "ToggleCheckbox",
5917
5805
  componentId: "sc-11ob8ah-4"
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) {
5806
+ })(["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) {
5919
5807
  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);}}"]);
5920
5808
  }, function (props) {
5921
5809
  return props.disabled && "\n opacity: 0.8;\n pointer-events:none;\n ";
5922
- }, utils.customTheme('ToggleCheckboxBox'));
5810
+ });
5923
5811
 
5924
- function _templateObject$8() {
5812
+ function _templateObject$7() {
5925
5813
  var data = _taggedTemplateLiteral(["\n min-width: 0;\n ", "\n "]);
5926
5814
 
5927
- _templateObject$8 = function _templateObject() {
5815
+ _templateObject$7 = function _templateObject() {
5928
5816
  return data;
5929
5817
  };
5930
5818
 
@@ -5943,7 +5831,7 @@ var TabButton = styled__default(components.Button).withConfig({
5943
5831
  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 ";
5944
5832
  }, function (props) {
5945
5833
  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 ";
5946
- }, utils.media.mobile(_templateObject$8(), function (props) {
5834
+ }, utils.media.mobile(_templateObject$7(), function (props) {
5947
5835
  return props.icon ? "\n padding-left: 1.25rem;\n padding-right: 1rem;\n " : "\n padding-left: 0.25rem;\n padding-right: 0.25rem;\n ";
5948
5836
  }), utils.customTheme('TabButton'));
5949
5837
  var InnerButton = styled__default.a.withConfig({
@@ -6054,16 +5942,16 @@ var buildValidation = function buildValidation(validations) {
6054
5942
  };
6055
5943
  };
6056
5944
  var responseFailure = function responseFailure(fn) {
6057
- return function (v, response, _ref5) {
5945
+ return function (_, response, _ref5) {
6058
5946
  var setErrors = _ref5.setErrors;
6059
5947
  var errorSetter = setErrors;
6060
- var r = [].concat(response, v);
5948
+ var r = [].concat(response, _);
6061
5949
  console.log(r);
6062
5950
  var error = fn.apply(void 0, _toConsumableArray(r));
6063
5951
 
6064
5952
  if (error === true) ; else if (error) {
6065
5953
  errorSetter(error);
6066
- } else if (!_get('response[0].errors')) {
5954
+ } else {
6067
5955
  errorSetter({
6068
5956
  "": [messages.SERVER_ERROR]
6069
5957
  });
@@ -6119,7 +6007,6 @@ exports.IfFormValue = IfFormValue;
6119
6007
  exports.InputboxGroup = InputboxGroup;
6120
6008
  exports.Option = Option;
6121
6009
  exports.PathContext = PathContext;
6122
- exports.PseudoExpandableBox = PseudoExpandableBox;
6123
6010
  exports.Radiobox = Radiobox;
6124
6011
  exports.RadioboxGroup = RadioboxGroup;
6125
6012
  exports.RichText = RichText;
package/package.json CHANGED
@@ -1,15 +1,16 @@
1
1
  {
2
2
  "name": "@startlibs/form",
3
- "version": "1.0.0-alpha-10f",
3
+ "version": "1.0.0-alpha-9w.1",
4
4
  "description": "Startlibs Form",
5
- "main": "lib/index.js",
5
+ "main": "src/index.js",
6
6
  "sideEffects": false,
7
7
  "source": true,
8
8
  "peerDependencies": {
9
9
  "lodash": "^4.17.11",
10
10
  "polished": "^1.1.3",
11
- "react": "^18.0",
12
- "react-dom": "^18.0",
11
+ "react": "^16.8",
12
+ "react-dom": "^16.8",
13
+ "react-hot-loader": "^4.3.5",
13
14
  "styled-components": "^5.2.0"
14
15
  },
15
16
  "devDependencies": {
package/src/index.js ADDED
@@ -0,0 +1,24 @@
1
+ export * from './Form'
2
+ export * from './enhanceInput'
3
+ export * from './Field'
4
+ export * from './useConfirmDialog'
5
+ export * from './TextInput'
6
+ export * from './Errors'
7
+ export * from './withFormImageInput'
8
+ export * from './Checkbox'
9
+ export * from './Combobox'
10
+ export * from './ComboboxWithCustom'
11
+ export * from './AutoComplete'
12
+ export * from './EditableBox'
13
+ export * from './FormValue'
14
+ export * from './Radiobox'
15
+ export * from './InputboxGroup'
16
+ export * from './DatePicker'
17
+ export * from './RichText'
18
+ export * from './ExpandableBox'
19
+ export * from './alt/radiobox/IconRadioBox'
20
+ export * from './alt/checkbox/SimpleCheckbox'
21
+ export * from './alt/checkbox/ToggleCheckbox'
22
+ export * from './alt/radiobox/TabRadiobox'
23
+ export * from './alt/radiobox/SimpleRadiobox'
24
+ export {validation} from './validation'