@mw-kit/mw-ui 1.6.7 → 1.6.8

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.
@@ -1,4 +1,6 @@
1
1
  import React from 'react';
2
2
  import { DateIntervalPickerProps } from './interfaces';
3
- declare const DatePicker: React.ForwardRefExoticComponent<DateIntervalPickerProps & React.RefAttributes<HTMLInputElement>>;
3
+ declare const DatePicker: React.ForwardRefExoticComponent<DateIntervalPickerProps & React.RefAttributes<HTMLInputElement>> & {
4
+ useDefaultDateIntervalState: () => [string, string];
5
+ };
4
6
  export default DatePicker;
@@ -26,6 +26,7 @@ export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement>
26
26
  arrows?: boolean;
27
27
  borderless?: boolean;
28
28
  paddingless?: boolean;
29
+ inputWidth?: string;
29
30
  }
30
31
  export interface StyledLabelProps extends React.LabelHTMLAttributes<HTMLLabelElement> {
31
32
  required: 1 | 0;
@@ -43,4 +44,5 @@ export interface StyledInputProps extends Omit<React.InputHTMLAttributes<HTMLInp
43
44
  arrows: 1 | 0;
44
45
  borderless: 1 | 0;
45
46
  paddingless: 1 | 0;
47
+ width?: string;
46
48
  }
@@ -1,5 +1,7 @@
1
1
  import React from 'react';
2
2
  import { Details, PhoneProps } from './interfaces';
3
- export declare const getDetails: (phone: string) => Details | null;
4
- declare const Phone: React.ForwardRefExoticComponent<PhoneProps & React.RefAttributes<HTMLInputElement>>;
3
+ export declare const getPhoneDetails: (phone: string) => Details | null;
4
+ declare const Phone: React.ForwardRefExoticComponent<PhoneProps & React.RefAttributes<HTMLInputElement>> & {
5
+ getPhoneDetails: (phone: string) => Details | null;
6
+ };
5
7
  export default Phone;
@@ -12,5 +12,8 @@ import { RangeProps } from './components/Range/interfaces';
12
12
  import { RadioButtonProps } from './components/RadioButton/interfaces';
13
13
  import { DateIntervalPickerProps } from './components/DateIntervalPicker/interfaces';
14
14
  export declare type Props = DateProps | TimeProps | CheckboxProps | SelectProps | PasswordProps | PhoneProps | DatePickerProps | RangeProps | DefaultInputProps | SwitchProps | RadioButtonProps | DateIntervalPickerProps;
15
- declare const Input: React.ForwardRefExoticComponent<(TimeProps & React.RefAttributes<HTMLInputElement>) | (DefaultInputProps & React.RefAttributes<HTMLInputElement>) | (DateProps & React.RefAttributes<HTMLInputElement>) | (CheckboxProps & React.RefAttributes<HTMLInputElement>) | (import("./components/Select/hooks/Select/interfaces").SelectProps & React.RefAttributes<HTMLInputElement>) | (import("./components/Select/hooks/SelectMultiple/interfaces").SelectProps & React.RefAttributes<HTMLInputElement>) | (PasswordProps & React.RefAttributes<HTMLInputElement>) | (PhoneProps & React.RefAttributes<HTMLInputElement>) | (DatePickerProps & React.RefAttributes<HTMLInputElement>) | (RangeProps & React.RefAttributes<HTMLInputElement>) | (SwitchProps & React.RefAttributes<HTMLInputElement>) | (RadioButtonProps & React.RefAttributes<HTMLInputElement>) | (DateIntervalPickerProps & React.RefAttributes<HTMLInputElement>)>;
15
+ declare const Input: React.ForwardRefExoticComponent<(TimeProps & React.RefAttributes<HTMLInputElement>) | (DefaultInputProps & React.RefAttributes<HTMLInputElement>) | (DateProps & React.RefAttributes<HTMLInputElement>) | (CheckboxProps & React.RefAttributes<HTMLInputElement>) | (import("./components/Select/hooks/Select/interfaces").SelectProps & React.RefAttributes<HTMLInputElement>) | (import("./components/Select/hooks/SelectMultiple/interfaces").SelectProps & React.RefAttributes<HTMLInputElement>) | (PasswordProps & React.RefAttributes<HTMLInputElement>) | (PhoneProps & React.RefAttributes<HTMLInputElement>) | (DatePickerProps & React.RefAttributes<HTMLInputElement>) | (RangeProps & React.RefAttributes<HTMLInputElement>) | (SwitchProps & React.RefAttributes<HTMLInputElement>) | (RadioButtonProps & React.RefAttributes<HTMLInputElement>) | (DateIntervalPickerProps & React.RefAttributes<HTMLInputElement>)> & {
16
+ useDefaultDateIntervalState: () => [string, string];
17
+ getPhoneDetails: (phone: string) => import("./components/Phone/interfaces").Details | null;
18
+ };
16
19
  export default Input;
package/dist/index.js CHANGED
@@ -182,14 +182,15 @@ var dateToIsoString = function dateToIsoString(date, time, fullYear, pattern) {
182
182
 
183
183
  var dateData = [date.getDate().toString().padStart(2, '0'), (date.getMonth() + 1).toString().padStart(2, '0'), date.getFullYear().toString().padStart(4, '0')];
184
184
  if (fullYear === false) dateData[2] = dateData[2].substring(2, 4);
185
+ var dateStr = dateData.join('/');
185
186
 
186
187
  if (pattern === 'us') {
187
188
  var tmp = dateData[0];
188
189
  dateData[0] = dateData[2];
189
190
  dateData[2] = tmp;
191
+ dateStr = dateData.join('-');
190
192
  }
191
193
 
192
- var dateStr = dateData.join('/');
193
194
  if (!time) return dateStr;
194
195
  var timeStr = [date.getHours().toString().padStart(2, '0'), date.getMinutes().toString().padStart(2, '0'), date.getSeconds().toString().padStart(2, '0')].join(':');
195
196
  return [dateStr, timeStr].join(' ');
@@ -12606,7 +12607,7 @@ var IconContainer = styled__default.button(_templateObject$c || (_templateObject
12606
12607
  if (!onClick || disabled) return;
12607
12608
  return styled.css(_templateObject2$a || (_templateObject2$a = _taggedTemplateLiteralLoose(["\n cursor: pointer;\n "])));
12608
12609
  });
12609
- var Input = styled__default.input(_templateObject3$a || (_templateObject3$a = _taggedTemplateLiteralLoose(["\n ", ";\n\n color: ", ";\n\n line-height: 17px;\n\n ::placeholder {\n color: ", ";\n\n line-height: 17px;\n\n ", "\n }\n\n width: 100%;\n box-sizing: border-box;\n\n ", ";\n\n border-width: 1px;\n border-style: solid;\n border-color: ", ";\n border-radius: 4px;\n\n background-color: ", ";\n\n box-shadow: none;\n outline: none;\n\n ", "\n\n ", "\n"])), function (_ref2) {
12610
+ var Input = styled__default.input(_templateObject3$a || (_templateObject3$a = _taggedTemplateLiteralLoose(["\n ", ";\n\n color: ", ";\n\n line-height: 17px;\n\n ::placeholder {\n color: ", ";\n\n line-height: 17px;\n\n ", "\n }\n\n display: block;\n width: ", ";\n box-sizing: border-box;\n\n ", ";\n\n border-width: 1px;\n border-style: solid;\n border-color: ", ";\n border-radius: 4px;\n\n background-color: ", ";\n\n box-shadow: none;\n outline: none;\n\n ", "\n\n ", "\n"])), function (_ref2) {
12610
12611
  var theme = _ref2.theme;
12611
12612
  return theme.useTypography('p');
12612
12613
  }, function (_ref3) {
@@ -12629,59 +12630,62 @@ var Input = styled__default.input(_templateObject3$a || (_templateObject3$a = _t
12629
12630
 
12630
12631
  return styled.css(_templateObject5$8 || (_templateObject5$8 = _taggedTemplateLiteralLoose(["\n opacity: 0.5;\n font-size: 14px;\n letter-spacing: 0px;\n "])));
12631
12632
  }, function (_ref7) {
12632
- var theme = _ref7.theme,
12633
- paddingless = _ref7.paddingless;
12634
- if (paddingless) return;
12635
- return styled.css(_templateObject6$6 || (_templateObject6$6 = _taggedTemplateLiteralLoose(["\n padding: ", " ", ";\n "])), theme.spacings.s2, theme.spacings.s3);
12633
+ var width = _ref7.width;
12634
+ return width || '100%';
12636
12635
  }, function (_ref8) {
12637
12636
  var theme = _ref8.theme,
12638
- invalid = _ref8.invalid,
12639
- borderless = _ref8.borderless;
12640
- if (borderless) return 'transparent';
12641
- return invalid ? theme.colors.warningRed : theme.colors.lightGrey;
12637
+ paddingless = _ref8.paddingless;
12638
+ if (paddingless) return;
12639
+ return styled.css(_templateObject6$6 || (_templateObject6$6 = _taggedTemplateLiteralLoose(["\n padding: ", " ", ";\n "])), theme.spacings.s2, theme.spacings.s3);
12642
12640
  }, function (_ref9) {
12643
12641
  var theme = _ref9.theme,
12644
- invalid = _ref9.invalid;
12645
- return invalid ? theme.getColor('warningRed', 5) : theme.colors.white;
12642
+ invalid = _ref9.invalid,
12643
+ borderless = _ref9.borderless;
12644
+ if (borderless) return 'transparent';
12645
+ return invalid ? theme.colors.warningRed : theme.colors.lightGrey;
12646
12646
  }, function (_ref10) {
12647
- var arrows = _ref10.arrows;
12647
+ var theme = _ref10.theme,
12648
+ invalid = _ref10.invalid;
12649
+ return invalid ? theme.getColor('warningRed', 5) : theme.colors.white;
12650
+ }, function (_ref11) {
12651
+ var arrows = _ref11.arrows;
12648
12652
  if (arrows) return;
12649
12653
  return styled.css(_templateObject7$4 || (_templateObject7$4 = _taggedTemplateLiteralLoose(["\n /* Chrome, Safari, Edge, Opera */\n :-webkit-outer-spin-button,\n :-webkit-inner-spin-button {\n -webkit-appearance: none;\n margin: 0;\n }\n\n /* Firefox */\n -moz-appearance: textfield;\n "])));
12650
- }, function (_ref11) {
12651
- var readOnly = _ref11.readOnly,
12652
- onClick = _ref11.onClick,
12653
- disabled = _ref11.disabled;
12654
+ }, function (_ref12) {
12655
+ var readOnly = _ref12.readOnly,
12656
+ onClick = _ref12.onClick,
12657
+ disabled = _ref12.disabled;
12654
12658
  if (!readOnly) return;
12655
12659
  return styled.css(_templateObject8$3 || (_templateObject8$3 = _taggedTemplateLiteralLoose(["\n cursor: ", ";\n "])), !onClick || disabled ? 'unset' : 'pointer');
12656
12660
  });
12657
- var Label = styled__default.label(_templateObject9$3 || (_templateObject9$3 = _taggedTemplateLiteralLoose(["\n ", ";\n\n color: ", ";\n\n width: ", ";\n box-sizing: border-box;\n position: relative;\n display: block;\n\n ", "\n\n > div:first-child {\n display: inline-block;\n margin-bottom: ", ";\n\n ", "\n }\n\n > ", " {\n bottom: ", ";\n }\n\n ", "\n"])), function (_ref12) {
12658
- var theme = _ref12.theme;
12659
- return theme.useTypography('p');
12660
- }, function (_ref13) {
12661
+ var Label = styled__default.label(_templateObject9$3 || (_templateObject9$3 = _taggedTemplateLiteralLoose(["\n ", ";\n\n color: ", ";\n\n width: ", ";\n box-sizing: border-box;\n position: relative;\n display: block;\n\n ", "\n\n > div:first-child {\n display: inline-block;\n margin-bottom: ", ";\n\n ", "\n }\n\n > ", " {\n bottom: ", ";\n }\n\n ", "\n"])), function (_ref13) {
12661
12662
  var theme = _ref13.theme;
12662
- return theme.colors.greyishBlue;
12663
+ return theme.useTypography('p');
12663
12664
  }, function (_ref14) {
12664
- var width = _ref14.width;
12665
- return width || '100%';
12665
+ var theme = _ref14.theme;
12666
+ return theme.colors.greyishBlue;
12666
12667
  }, function (_ref15) {
12667
- var disabled = _ref15.disabled;
12668
+ var width = _ref15.width;
12669
+ return width || '100%';
12670
+ }, function (_ref16) {
12671
+ var disabled = _ref16.disabled;
12668
12672
  if (!disabled) return;
12669
12673
  return styled.css(_templateObject10$2 || (_templateObject10$2 = _taggedTemplateLiteralLoose(["\n opacity: 0.5;\n "])));
12670
- }, function (_ref16) {
12671
- var theme = _ref16.theme;
12672
- return theme.spacings.s1;
12673
12674
  }, function (_ref17) {
12674
- var required = _ref17.required;
12675
+ var theme = _ref17.theme;
12676
+ return theme.spacings.s1;
12677
+ }, function (_ref18) {
12678
+ var required = _ref18.required;
12675
12679
  if (!required) return;
12676
12680
  return styled.css(_templateObject11$1 || (_templateObject11$1 = _taggedTemplateLiteralLoose(["\n :after {\n content: ' *';\n }\n "])));
12677
- }, IconContainer, function (_ref18) {
12678
- var theme = _ref18.theme,
12679
- paddingless = _ref18.paddingless;
12680
- return paddingless ? '2px' : "calc(" + theme.spacings.s2 + " + 1px)";
12681
- }, function (_ref19) {
12681
+ }, IconContainer, function (_ref19) {
12682
12682
  var theme = _ref19.theme,
12683
- icon = _ref19.icon,
12684
12683
  paddingless = _ref19.paddingless;
12684
+ return paddingless ? '2px' : "calc(" + theme.spacings.s2 + " + 1px)";
12685
+ }, function (_ref20) {
12686
+ var theme = _ref20.theme,
12687
+ icon = _ref20.icon,
12688
+ paddingless = _ref20.paddingless;
12685
12689
  if (!icon) return;
12686
12690
  var width = icon.width,
12687
12691
  position = icon.position;
@@ -12731,12 +12735,13 @@ var Input$1 = React__default.forwardRef(function (props, ref) {
12731
12735
  iconOnClick = props.icon.onClick;
12732
12736
  }
12733
12737
 
12734
- var inputProps = filterObject(props, ['label', 'invalid', 'required', 'icon', 'mask', 'loading', 'clearable', 'setValue', 'onPressEnter', 'htmlDisabled', 'width', 'arrows', 'borderless', 'paddingless'], {
12738
+ var inputProps = filterObject(props, ['label', 'invalid', 'required', 'icon', 'mask', 'loading', 'clearable', 'setValue', 'onPressEnter', 'htmlDisabled', 'width', 'inputWidth', 'arrows', 'borderless', 'paddingless'], {
12735
12739
  invalid: intInvalid,
12736
12740
  type: 'text',
12737
12741
  arrows: intArrows,
12738
12742
  borderless: intBorderless,
12739
- paddingless: intPaddingless
12743
+ paddingless: intPaddingless,
12744
+ width: props.inputWidth
12740
12745
  });
12741
12746
 
12742
12747
  var onChange = inputProps.onChange || function () {};
@@ -12803,7 +12808,7 @@ var Input$1 = React__default.forwardRef(function (props, ref) {
12803
12808
  }
12804
12809
 
12805
12810
  if (loading) {
12806
- position = position || 'left';
12811
+ position = position || 'right';
12807
12812
  icon = {
12808
12813
  type: 'jsx',
12809
12814
  icon: React__default.createElement(Loader, {
@@ -14297,7 +14302,7 @@ var Label$2 = styled__default.div(_templateObject3$e || (_templateObject3$e = _t
14297
14302
  return theme.colors.darkestGrey;
14298
14303
  });
14299
14304
 
14300
- var getDetails = function getDetails(phone) {
14305
+ var getPhoneDetails = function getPhoneDetails(phone) {
14301
14306
  if (!notEmptyString(phone)) return null;
14302
14307
  var splitted = phone.replace(/[^0-9\s]/g, '').split(' ');
14303
14308
  if (splitted.length < 2) return null;
@@ -14344,7 +14349,7 @@ var Button$2 = function Button(props) {
14344
14349
  }));
14345
14350
  };
14346
14351
 
14347
- var Phone = React__default.forwardRef(function (props, ref) {
14352
+ var Component = React__default.forwardRef(function (props, ref) {
14348
14353
  var value = props.value,
14349
14354
  setValue = props.setValue;
14350
14355
 
@@ -14361,7 +14366,7 @@ var Phone = React__default.forwardRef(function (props, ref) {
14361
14366
  setOpen = _useState3[1];
14362
14367
 
14363
14368
  React.useEffect(function () {
14364
- var details = getDetails(value || '');
14369
+ var details = getPhoneDetails(value || '');
14365
14370
  setCountry(details ? details.country : countries.br);
14366
14371
  }, [value]);
14367
14372
  var options = Object.keys(countries).map(function (iso) {
@@ -14386,7 +14391,7 @@ var Phone = React__default.forwardRef(function (props, ref) {
14386
14391
  };
14387
14392
 
14388
14393
  React.useEffect(function () {
14389
- var details = getDetails(value || '');
14394
+ var details = getPhoneDetails(value || '');
14390
14395
  setCountry(details ? details.country : countries.br);
14391
14396
  }, [value]);
14392
14397
  React.useEffect(function () {
@@ -14445,7 +14450,10 @@ var Phone = React__default.forwardRef(function (props, ref) {
14445
14450
  }
14446
14451
  }));
14447
14452
  });
14448
- Phone.displayName = 'Phone';
14453
+ Component.displayName = 'Phone';
14454
+ var Phone = Object.assign(Component, {
14455
+ getPhoneDetails: getPhoneDetails
14456
+ });
14449
14457
 
14450
14458
  var _templateObject$l, _templateObject2$h, _templateObject3$f, _templateObject4$c, _templateObject5$b, _templateObject6$9, _templateObject7$7, _templateObject8$5, _templateObject9$5;
14451
14459
  var RelativeContainer$4 = styled__default.div(_templateObject$l || (_templateObject$l = _taggedTemplateLiteralLoose(["\n position: relative;\n\n input {\n color: transparent;\n }\n"])));
@@ -15119,8 +15127,8 @@ var intervalTypes = {
15119
15127
  var start = new Date(base);
15120
15128
  start.setDate(start.getDate() - start.getUTCDay());
15121
15129
  start.setHours(0, 0, 0, 0);
15122
- var end = new Date(base);
15123
- end.setDate(start.getDate() - start.getUTCDay() + 6);
15130
+ var end = new Date(start);
15131
+ end.setDate(start.getDate() + 6);
15124
15132
  end.setHours(23, 59, 59, 0);
15125
15133
  return [start, end];
15126
15134
  },
@@ -15160,7 +15168,7 @@ var intervalTypes = {
15160
15168
  var start = new Date(base);
15161
15169
  start.setDate(1);
15162
15170
  start.setHours(0, 0, 0, 0);
15163
- var end = new Date(base);
15171
+ var end = new Date(start);
15164
15172
  end.setMonth(end.getMonth() + 1);
15165
15173
  end.setDate(0);
15166
15174
  end.setHours(23, 59, 59, 0);
@@ -15283,7 +15291,7 @@ var Button$4 = styled__default.button(_templateObject9$7 || (_templateObject9$7
15283
15291
  return styled.css(_templateObject10$5 || (_templateObject10$5 = _taggedTemplateLiteralLoose(["\n :not(:disabled) {\n cursor: pointer;\n }\n "])));
15284
15292
  });
15285
15293
 
15286
- var DatePicker$1 = React__default.forwardRef(function (props, ref) {
15294
+ var Component$1 = React__default.forwardRef(function (props, ref) {
15287
15295
  var value = parse(props.value);
15288
15296
  var disabled = props.disabled || props.loading;
15289
15297
 
@@ -15460,9 +15468,21 @@ var DatePicker$1 = React__default.forwardRef(function (props, ref) {
15460
15468
  time: {}
15461
15469
  }));
15462
15470
  });
15463
- DatePicker$1.displayName = 'DatePicker';
15471
+ Component$1.displayName = 'DatePicker';
15472
+
15473
+ var useDefaultDateIntervalState = function useDefaultDateIntervalState() {
15474
+ var start = new Date();
15475
+ start.setHours(0, 0, 0, 0);
15476
+ var end = new Date();
15477
+ end.setHours(23, 59, 59, 0);
15478
+ return [start.toISOString(), end.toISOString()];
15479
+ };
15464
15480
 
15465
- var Input$3 = React__default.forwardRef(function (props, ref) {
15481
+ var DatePicker$1 = Object.assign(Component$1, {
15482
+ useDefaultDateIntervalState: useDefaultDateIntervalState
15483
+ });
15484
+
15485
+ var Component$2 = React__default.forwardRef(function (props, ref) {
15466
15486
  switch (props.type) {
15467
15487
  case 'date':
15468
15488
  {
@@ -15552,7 +15572,11 @@ var Input$3 = React__default.forwardRef(function (props, ref) {
15552
15572
  }
15553
15573
  }
15554
15574
  });
15555
- Input$3.displayName = 'Input';
15575
+ Component$2.displayName = 'Input';
15576
+ var Input$3 = Object.assign(Component$2, {
15577
+ useDefaultDateIntervalState: DatePicker$1.useDefaultDateIntervalState,
15578
+ getPhoneDetails: Phone.getPhoneDetails
15579
+ });
15556
15580
 
15557
15581
  var Portal = function Portal(props) {
15558
15582
  var id = props.id,