@mw-kit/mw-ui 1.7.2 → 1.7.4

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.
@@ -12353,8 +12353,8 @@ var MenuComponent = function MenuComponent(props, ref) {
12353
12353
  if (rule === undefined) {
12354
12354
  var _onClick = option.onClick || function () {};
12355
12355
 
12356
- onClick = function onClick() {
12357
- _onClick(index);
12356
+ onClick = function onClick(e) {
12357
+ _onClick(index, option, e);
12358
12358
 
12359
12359
  closeMenu();
12360
12360
  };
@@ -13635,22 +13635,21 @@ var Header$1 = function Header() {
13635
13635
  };
13636
13636
 
13637
13637
  var getOptions = function getOptions(props, options) {
13638
- return options.map(function (option, index) {
13638
+ return options.map(function (option) {
13639
13639
  var label = isString(option.label) ? {
13640
13640
  text: option.label,
13641
13641
  element: option.label
13642
13642
  } : option.label;
13643
13643
  var value = option.value,
13644
- onClick = option.onClick;
13644
+ onClick = option.onClick,
13645
+ data = option.data;
13645
13646
  return {
13646
13647
  label: label,
13647
- onClick: onClick ? function () {
13648
- onClick(index, {
13649
- label: label,
13650
- value: value
13651
- });
13648
+ data: data,
13649
+ onClick: onClick ? function (index, _option, event) {
13650
+ onClick(index, option, event);
13652
13651
  } : function () {
13653
- props.setValue(value);
13652
+ props.setValue(value, option);
13654
13653
  }
13655
13654
  };
13656
13655
  });
@@ -13710,7 +13709,9 @@ var Footer$1 = function Footer() {
13710
13709
  setOpen = context.setOpen;
13711
13710
 
13712
13711
  var onClick = function onClick() {
13713
- setValue([].concat(checked));
13712
+ setValue(checked.map(function (c) {
13713
+ return c.value;
13714
+ }), [].concat(checked));
13714
13715
  setOpen(false);
13715
13716
  };
13716
13717
 
@@ -13756,9 +13757,7 @@ var Header$2 = function Header() {
13756
13757
 
13757
13758
  var onClick = function onClick() {
13758
13759
  setChecked(function (prev) {
13759
- return prev.length === options.length ? [] : options.map(function (option) {
13760
- return option.value;
13761
- });
13760
+ return prev.length === options.length ? [] : [].concat(options);
13762
13761
  });
13763
13762
  };
13764
13763
 
@@ -13797,7 +13796,9 @@ var getOptions$1 = function getOptions(options, checked, setChecked) {
13797
13796
  text: label.text,
13798
13797
  element: React__default.createElement(Checkbox, {
13799
13798
  type: 'checkbox',
13800
- checked: checked.includes(option.value),
13799
+ checked: checked.findIndex(function (e) {
13800
+ return e.value === option.value;
13801
+ }) !== -1,
13801
13802
  label: option.disabled && option.disabledText ? React__default.createElement(Popup, {
13802
13803
  on: 'click',
13803
13804
  trigger: React__default.createElement("div", null, label.element),
@@ -13811,9 +13812,9 @@ var getOptions$1 = function getOptions(options, checked, setChecked) {
13811
13812
  var isChecked = event.target.checked;
13812
13813
  setChecked(function (prev) {
13813
13814
  var newState = prev.filter(function (v) {
13814
- return v !== option.value;
13815
+ return v.value !== option.value;
13815
13816
  });
13816
- if (isChecked) newState.push(option.value);
13817
+ if (isChecked) newState.push(_extends({}, option));
13817
13818
  return newState;
13818
13819
  });
13819
13820
  },
@@ -13836,19 +13837,61 @@ var getInputValue$1 = function getInputValue(value) {
13836
13837
  };
13837
13838
 
13838
13839
  var useSelectMultiple = function useSelectMultiple(props) {
13840
+ var init = function init() {
13841
+ return props.value.length === 0 ? [] : typeof props.value[0] === 'string' ? [].concat(props.value).map(function (value) {
13842
+ return {
13843
+ value: value,
13844
+ label: value
13845
+ };
13846
+ }) : [].concat(props.value);
13847
+ };
13848
+
13839
13849
  var _useState = useState([]),
13840
13850
  options = _useState[0],
13841
13851
  setOptions = _useState[1];
13842
13852
 
13843
- var _useState2 = useState([].concat(props.value)),
13844
- checked = _useState2[0],
13845
- setChecked = _useState2[1];
13853
+ var _useState2 = useState(init),
13854
+ inital = _useState2[0],
13855
+ setInitial = _useState2[1];
13856
+
13857
+ var _useState3 = useState(init),
13858
+ checked = _useState3[0],
13859
+ setChecked = _useState3[1];
13860
+
13861
+ useEffect(function () {
13862
+ var getOption = function getOption(def, options, prev) {
13863
+ var index = options.findIndex(function (o) {
13864
+ return o.value === def.value;
13865
+ });
13866
+ if (index !== -1) return _extends({}, options[index]);else {
13867
+ var _index = prev.findIndex(function (o) {
13868
+ return o.value === def.value;
13869
+ });
13870
+
13871
+ if (_index !== -1) return _extends({}, prev[_index]);
13872
+ }
13873
+ return def;
13874
+ };
13846
13875
 
13876
+ var mapper = function mapper(prev) {
13877
+ return props.value.length > 0 && typeof props.value[0] === 'string' ? props.value.map(function (value) {
13878
+ return getOption({
13879
+ value: value,
13880
+ label: value
13881
+ }, options, prev);
13882
+ }) : props.value.map(function (value) {
13883
+ return getOption(value, options, prev);
13884
+ });
13885
+ };
13886
+
13887
+ setInitial(mapper);
13888
+ setChecked(mapper);
13889
+ }, [props.value, options]);
13847
13890
  var parsedOptions = getOptions$1(options, checked, setChecked);
13848
13891
  var inputValue = getInputValue$1(props.value);
13849
13892
 
13850
13893
  var onReset = function onReset() {
13851
- setChecked([].concat(props.value));
13894
+ setChecked([].concat(inital));
13852
13895
  };
13853
13896
 
13854
13897
  var returnData = {
@@ -13992,6 +14035,12 @@ var Select = React__default.forwardRef(function (props, ref) {
13992
14035
  setSearch('');
13993
14036
  };
13994
14037
 
14038
+ var onClick = function onClick() {
14039
+ setOpen(function (prev) {
14040
+ return !prev;
14041
+ });
14042
+ };
14043
+
13995
14044
  return getContext({
13996
14045
  setOpen: setOpen,
13997
14046
  search: [search, setSearch],
@@ -14006,11 +14055,7 @@ var Select = React__default.forwardRef(function (props, ref) {
14006
14055
  }, React__default.createElement(Input$1, Object.assign({}, inputProps, {
14007
14056
  type: 'search',
14008
14057
  readOnly: true,
14009
- onClick: function onClick() {
14010
- setOpen(function (prev) {
14011
- return !prev;
14012
- });
14013
- },
14058
+ onClick: onClick,
14014
14059
  loading: loading,
14015
14060
  icon: {
14016
14061
  position: 'right',
@@ -14018,7 +14063,8 @@ var Select = React__default.forwardRef(function (props, ref) {
14018
14063
  type: 'semantic',
14019
14064
  icon: open ? 'caret up' : 'caret down',
14020
14065
  width: '14px'
14021
- }
14066
+ },
14067
+ onClick: onClick
14022
14068
  },
14023
14069
  ref: ref
14024
14070
  })), React__default.createElement(Menu, Object.assign({}, menuProps, {
@@ -15273,7 +15319,7 @@ var parse = function parse(value) {
15273
15319
  });
15274
15320
  };
15275
15321
 
15276
- var _templateObject$q, _templateObject2$l, _templateObject3$j, _templateObject4$g, _templateObject5$f, _templateObject6$d, _templateObject7$b, _templateObject8$7, _templateObject9$7, _templateObject10$5, _templateObject11$4;
15322
+ var _templateObject$q, _templateObject2$l, _templateObject3$j, _templateObject4$g, _templateObject5$f, _templateObject6$d, _templateObject7$b, _templateObject8$7, _templateObject9$7, _templateObject10$5;
15277
15323
  var RelativeContainer$5 = styled.div(_templateObject$q || (_templateObject$q = _taggedTemplateLiteralLoose(["\n position: relative;\n user-select: none;\n min-width: 220px;\n\n > :nth-child(1) input {\n color: transparent;\n }\n"])));
15278
15324
  var LabelContainer$3 = styled.div(_templateObject2$l || (_templateObject2$l = _taggedTemplateLiteralLoose(["\n ", "\n line-height: 17px;\n flex: 1;\n text-align: center;\n\n ", ";\n"])), function (_ref) {
15279
15325
  var theme = _ref.theme;
@@ -15283,7 +15329,7 @@ var LabelContainer$3 = styled.div(_templateObject2$l || (_templateObject2$l = _t
15283
15329
  if (!onClick) return;
15284
15330
  return css(_templateObject3$j || (_templateObject3$j = _taggedTemplateLiteralLoose(["\n :not(:disabled) {\n cursor: pointer;\n }\n "])));
15285
15331
  });
15286
- var Container$a = styled.div(_templateObject4$g || (_templateObject4$g = _taggedTemplateLiteralLoose(["\n position: absolute;\n bottom: 1px;\n left: 1px;\n display: flex;\n align-items: center;\n border-radius: 4px;\n white-space: nowrap;\n gap: ", ";\n border-width: 1px;\n border-style: solid;\n border-color: ", ";\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n"])), function (_ref3) {
15332
+ var Container$a = styled.div(_templateObject4$g || (_templateObject4$g = _taggedTemplateLiteralLoose(["\n position: absolute;\n bottom: 1px;\n left: 1px;\n display: flex;\n align-items: center;\n border-radius: 4px;\n white-space: nowrap;\n gap: ", ";\n border-width: 1px;\n border-style: solid;\n border-color: ", ";\n\n width: 100%;\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n"])), function (_ref3) {
15287
15333
  var theme = _ref3.theme;
15288
15334
  return theme.spacings.s1;
15289
15335
  }, function (_ref4) {
@@ -15292,33 +15338,28 @@ var Container$a = styled.div(_templateObject4$g || (_templateObject4$g = _tagged
15292
15338
  return invalid ? theme.colors.warningRed : theme.colors.lightGrey;
15293
15339
  }, function (_ref5) {
15294
15340
  var theme = _ref5.theme,
15295
- iconWidth = _ref5.iconWidth,
15296
15341
  paddingless = _ref5.paddingless;
15297
-
15298
- if (paddingless) {
15299
- return css(_templateObject5$f || (_templateObject5$f = _taggedTemplateLiteralLoose(["\n width: calc(100% - 2px - ", ");\n "])), iconWidth);
15300
- }
15301
-
15302
- return css(_templateObject6$d || (_templateObject6$d = _taggedTemplateLiteralLoose(["\n width: calc(100% - 2px - ", " - ", ");\n padding: ", " 0 ", " ", ";\n "])), iconWidth, theme.spacings.s3, theme.spacings.s2, theme.spacings.s2, theme.spacings.s3);
15342
+ if (paddingless) return;
15343
+ return css(_templateObject5$f || (_templateObject5$f = _taggedTemplateLiteralLoose(["\n padding: ", " ", " ", "\n ", ";\n "])), theme.spacings.s2, theme.spacings.s1, theme.spacings.s2, theme.spacings.s3);
15303
15344
  }, function (_ref6) {
15304
15345
  var invalid = _ref6.invalid,
15305
15346
  theme = _ref6.theme;
15306
15347
  if (!invalid) return;
15307
- return css(_templateObject7$b || (_templateObject7$b = _taggedTemplateLiteralLoose(["\n color: ", ";\n "])), theme.colors.warningRed);
15348
+ return css(_templateObject6$d || (_templateObject6$d = _taggedTemplateLiteralLoose(["\n color: ", ";\n "])), theme.colors.warningRed);
15308
15349
  }, function (_ref7) {
15309
15350
  var invalid = _ref7.invalid,
15310
15351
  theme = _ref7.theme;
15311
15352
  if (!invalid) return;
15312
- return css(_templateObject8$7 || (_templateObject8$7 = _taggedTemplateLiteralLoose(["\n color: ", ";\n "])), theme.colors.warningRed);
15353
+ return css(_templateObject7$b || (_templateObject7$b = _taggedTemplateLiteralLoose(["\n color: ", ";\n "])), theme.colors.warningRed);
15313
15354
  }, function (_ref8) {
15314
15355
  var disabled = _ref8.disabled;
15315
15356
  if (!disabled) return;
15316
- return css(_templateObject9$7 || (_templateObject9$7 = _taggedTemplateLiteralLoose(["\n opacity: 0.5;\n "])));
15357
+ return css(_templateObject8$7 || (_templateObject8$7 = _taggedTemplateLiteralLoose(["\n opacity: 0.5;\n "])));
15317
15358
  });
15318
- var Button$4 = styled.button(_templateObject10$5 || (_templateObject10$5 = _taggedTemplateLiteralLoose(["\n display: flex;\n background-color: transparent;\n border: none;\n padding: 0;\n box-shadow: none;\n\n ", ";\n"])), function (_ref9) {
15359
+ var Button$4 = styled.button(_templateObject9$7 || (_templateObject9$7 = _taggedTemplateLiteralLoose(["\n display: flex;\n background-color: transparent;\n border: none;\n padding: 0;\n box-shadow: none;\n\n ", ";\n"])), function (_ref9) {
15319
15360
  var onClick = _ref9.onClick;
15320
15361
  if (!onClick) return;
15321
- return css(_templateObject11$4 || (_templateObject11$4 = _taggedTemplateLiteralLoose(["\n :not(:disabled) {\n cursor: pointer;\n }\n "])));
15362
+ return css(_templateObject10$5 || (_templateObject10$5 = _taggedTemplateLiteralLoose(["\n :not(:disabled) {\n cursor: pointer;\n }\n "])));
15322
15363
  });
15323
15364
 
15324
15365
  var Component$1 = React__default.forwardRef(function (props, ref) {
@@ -15426,19 +15467,9 @@ var Component$1 = React__default.forwardRef(function (props, ref) {
15426
15467
  },
15427
15468
  type: 'text',
15428
15469
  ref: ref,
15429
- icon: {
15430
- icon: {
15431
- type: 'feather',
15432
- icon: 'calendar',
15433
- width: '24px'
15434
- },
15435
- position: 'right',
15436
- onClick: onClick
15437
- },
15438
15470
  borderless: true,
15439
15471
  htmlDisabled: true
15440
15472
  })), React__default.createElement(Container$a, {
15441
- iconWidth: '24px',
15442
15473
  invalid: props.invalid ? 1 : 0,
15443
15474
  disabled: props.disabled ? 1 : 0,
15444
15475
  paddingless: props.paddingless ? 1 : 0
@@ -15469,6 +15500,13 @@ var Component$1 = React__default.forwardRef(function (props, ref) {
15469
15500
  icon: 'chevron_right',
15470
15501
  color: props.invalid ? 'warningRed' : 'grey',
15471
15502
  strokeWidth: '3px'
15503
+ })), React__default.createElement(Button$4, {
15504
+ onClick: onClick
15505
+ }, React__default.createElement(Icon, {
15506
+ type: 'feather',
15507
+ icon: 'calendar',
15508
+ color: props.invalid ? 'warningRed' : 'grey',
15509
+ width: '24px'
15472
15510
  })));
15473
15511
  }()), React__default.createElement(Menu, {
15474
15512
  open: open === 'menu',
@@ -16457,7 +16495,7 @@ var Toast = function Toast(props) {
16457
16495
  })), React__default.createElement(IconContent, null, React__default.createElement("h4", null, props.title), React__default.createElement("p", null, " ", props.description)));
16458
16496
  };
16459
16497
 
16460
- var _templateObject$C, _templateObject2$r, _templateObject3$o, _templateObject4$k, _templateObject5$j, _templateObject6$h, _templateObject7$e, _templateObject8$a, _templateObject9$a, _templateObject10$8, _templateObject11$5;
16498
+ var _templateObject$C, _templateObject2$r, _templateObject3$o, _templateObject4$k, _templateObject5$j, _templateObject6$h, _templateObject7$e, _templateObject8$a, _templateObject9$a, _templateObject10$8, _templateObject11$4;
16461
16499
  var Container$e = styled.div(_templateObject$C || (_templateObject$C = _taggedTemplateLiteralLoose(["\n width: 100%;\n height: 300px;\n position: absolute;\n padding: 14px;\n"])));
16462
16500
  var Header$4 = styled.div(_templateObject2$r || (_templateObject2$r = _taggedTemplateLiteralLoose(["\n display: flex;\n"])));
16463
16501
  var HeaderImage = styled.div(_templateObject3$o || (_templateObject3$o = _taggedTemplateLiteralLoose(["\n width: 43px;\n height: 44px;\n background-color: #ebebeb;\n"])));
@@ -16474,7 +16512,7 @@ var HeaderLine = styled.div(_templateObject6$h || (_templateObject6$h = _taggedT
16474
16512
  }, function (props) {
16475
16513
  return props.size === 'large' && css(_templateObject10$8 || (_templateObject10$8 = _taggedTemplateLiteralLoose(["\n width: 75%;\n "])));
16476
16514
  });
16477
- var MainLine = styled(HeaderLine)(_templateObject11$5 || (_templateObject11$5 = _taggedTemplateLiteralLoose(["\n margin-bottom: 14px;\n margin-left: 0;\n"])));
16515
+ var MainLine = styled(HeaderLine)(_templateObject11$4 || (_templateObject11$4 = _taggedTemplateLiteralLoose(["\n margin-bottom: 14px;\n margin-left: 0;\n"])));
16478
16516
 
16479
16517
  var Template1 = function Template1(props) {
16480
16518
  if (!props.loading) return React__default.createElement(React__default.Fragment, null);
@@ -16859,7 +16897,7 @@ var Template8$1 = function Template8(props) {
16859
16897
  })), React__default.createElement(Main$2, null, React__default.createElement(Circle$2, null)));
16860
16898
  };
16861
16899
 
16862
- var _templateObject$M, _templateObject2$B, _templateObject3$y, _templateObject4$t, _templateObject5$s, _templateObject6$p, _templateObject7$m, _templateObject8$i, _templateObject9$g, _templateObject10$b, _templateObject11$6;
16900
+ var _templateObject$M, _templateObject2$B, _templateObject3$y, _templateObject4$t, _templateObject5$s, _templateObject6$p, _templateObject7$m, _templateObject8$i, _templateObject9$g, _templateObject10$b, _templateObject11$5;
16863
16901
  var Container$n = styled.div(_templateObject$M || (_templateObject$M = _taggedTemplateLiteralLoose(["\n width: 395px;\n height: 245px;\n display: flex;\n flex-direction: column;\n align-items: center;\n background: #f5f5f5 0% 0% no-repeat padding-box;\n"])));
16864
16902
  var Header$a = styled.div(_templateObject2$B || (_templateObject2$B = _taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n padding: 14px;\n width: 100%;\n"])));
16865
16903
  var HeaderLine$9 = styled.div(_templateObject3$y || (_templateObject3$y = _taggedTemplateLiteralLoose(["\n height: ", ";\n background-color: #ebebeb;\n margin-left: 7px;\n\n & + div {\n margin-top: 7px;\n }\n\n ", "\n ", "\n\n ", "\n\n ", "\n"])), function (props) {
@@ -16882,7 +16920,7 @@ var CustomLine$6 = styled(HeaderLine$9)(_templateObject8$i || (_templateObject8$
16882
16920
  });
16883
16921
  var GraphLine = styled(CustomLine$6)(_templateObject9$g || (_templateObject9$g = _taggedTemplateLiteralLoose(["\n margin: 0 7px;\n"])));
16884
16922
  var Main$3 = styled.div(_templateObject10$b || (_templateObject10$b = _taggedTemplateLiteralLoose(["\n flex: 1;\n padding: 0 7px 72px 7px;\n width: 100%;\n display: flex;\n flex-direction: row;\n align-items: flex-end;\n justify-content: center;\n"])));
16885
- var Circle$3 = styled.div(_templateObject11$6 || (_templateObject11$6 = _taggedTemplateLiteralLoose(["\n width: 128px;\n height: 128px;\n background-color: #ebebeb;\n border-radius: 50%;\n"])));
16923
+ var Circle$3 = styled.div(_templateObject11$5 || (_templateObject11$5 = _taggedTemplateLiteralLoose(["\n width: 128px;\n height: 128px;\n background-color: #ebebeb;\n border-radius: 50%;\n"])));
16886
16924
 
16887
16925
  var Template10 = function Template10(props) {
16888
16926
  if (!props.loading) return React__default.createElement(React__default.Fragment, null);
@@ -17677,7 +17715,7 @@ var useContext$2 = function useContext() {
17677
17715
  return React__default.useContext(Provider$2);
17678
17716
  };
17679
17717
 
17680
- var _templateObject$S, _templateObject2$F, _templateObject3$C, _templateObject4$w, _templateObject5$u, _templateObject6$q, _templateObject7$n, _templateObject8$j, _templateObject9$h, _templateObject10$c, _templateObject11$7, _templateObject12$4, _templateObject13$4, _templateObject14$3, _templateObject15$2;
17718
+ var _templateObject$S, _templateObject2$F, _templateObject3$C, _templateObject4$w, _templateObject5$u, _templateObject6$q, _templateObject7$n, _templateObject8$j, _templateObject9$h, _templateObject10$c, _templateObject11$6, _templateObject12$4, _templateObject13$4, _templateObject14$3, _templateObject15$2;
17681
17719
  var aligns = {
17682
17720
  self: {
17683
17721
  horizontal: {
@@ -17768,7 +17806,7 @@ var Col = styled.div(_templateObject$S || (_templateObject$S = _taggedTemplateLi
17768
17806
  var bordered = _ref5.bordered,
17769
17807
  lightestGrey = _ref5.theme.colors.lightestGrey;
17770
17808
  if (!bordered) return;
17771
- return css(_templateObject11$7 || (_templateObject11$7 = _taggedTemplateLiteralLoose(["\n :not(:last-child) {\n border-right: 1px solid ", ";\n }\n "])), lightestGrey);
17809
+ return css(_templateObject11$6 || (_templateObject11$6 = _taggedTemplateLiteralLoose(["\n :not(:last-child) {\n border-right: 1px solid ", ";\n }\n "])), lightestGrey);
17772
17810
  }, function (_ref6) {
17773
17811
  var fontColor = _ref6.fontColor,
17774
17812
  theme = _ref6.theme;