@mw-kit/mw-ui 1.7.9 → 1.7.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -13767,6 +13767,13 @@ var getCalendar2 = function getCalendar2(calendar1) {
13767
13767
  date.setHours(0, 0, 0, 0);
13768
13768
  return getCalendar(date);
13769
13769
  };
13770
+ var getTimeProps = function getTimeProps(time, value) {
13771
+ if (time === true) return [{}, {}];
13772
+ if (!time) return [undefined, undefined];
13773
+ return time.map(function (e, i) {
13774
+ return typeof e === 'function' ? e(value[i]) : e;
13775
+ });
13776
+ };
13770
13777
 
13771
13778
  var _templateObject$i;
13772
13779
  var SubmitButton = styled__default(Button$1)(_templateObject$i || (_templateObject$i = _taggedTemplateLiteralLoose(["\n width: 105px;\n"])));
@@ -13834,7 +13841,7 @@ var Main$1 = React__default.forwardRef(function (props, ref) {
13834
13841
  setHoverDay = _useState4[1];
13835
13842
 
13836
13843
  React.useEffect(function () {
13837
- var timeProps = props.time === true ? [{}, {}] : props.time;
13844
+ var timeProps = getTimeProps(props.time, value);
13838
13845
  setHoverDay(null);
13839
13846
 
13840
13847
  if (value[0]) {
@@ -13851,7 +13858,7 @@ var Main$1 = React__default.forwardRef(function (props, ref) {
13851
13858
  }
13852
13859
 
13853
13860
  setInvalid(value.map(function (v, i) {
13854
- return isInvalid(v, time[i], timeProps ? timeProps[i] : undefined, min, max);
13861
+ return isInvalid(v, time[i], timeProps[i], min, max);
13855
13862
  }));
13856
13863
  }, [value, time, props.time]);
13857
13864
 
@@ -13859,8 +13866,8 @@ var Main$1 = React__default.forwardRef(function (props, ref) {
13859
13866
  return {};
13860
13867
  };
13861
13868
 
13862
- var getDay = function getDay(day) {
13863
- var dayProps = _getDay(day);
13869
+ var _getDay2 = function getDay(day, side) {
13870
+ var dayProps = _getDay(day, side);
13864
13871
 
13865
13872
  var _onClick2 = function onClick() {
13866
13873
  var newValue = [].concat(value);
@@ -13967,7 +13974,8 @@ var Main$1 = React__default.forwardRef(function (props, ref) {
13967
13974
  middle.setMonth(calendar1.month + 1);
13968
13975
  middle.setDate(1);
13969
13976
  middle.setHours(0, 0, 0, 0);
13970
- var inputs = props.time ? (props.time === true ? [{}, {}] : props.time).map(function (timeProps, index) {
13977
+ var inputs = getTimeProps(props.time, value).map(function (timeProps, index) {
13978
+ if (!timeProps) return undefined;
13971
13979
  var width = timeProps.seconds ? 'withSeconds' : 'withoutSeconds';
13972
13980
  return React__default.createElement(Time, Object.assign({
13973
13981
  key: index
@@ -13984,10 +13992,23 @@ var Main$1 = React__default.forwardRef(function (props, ref) {
13984
13992
  invalid: value[index] !== null && invalid[index] || timeInvalid[index],
13985
13993
  width: inputTimeWidth[width]
13986
13994
  }));
13987
- }) : [];
13995
+ });
13996
+
13997
+ var _onChangeMonth = props.onChangeMonth || function () {
13998
+ return Promise.resolve();
13999
+ };
14000
+
13988
14001
  return React__default.createElement(CalendarsContainer, null, React__default.createElement(BasicCalendar, Object.assign({}, calendarProps, {
13989
- getDay: getDay
13990
- }, {
14002
+ getDay: function getDay(c) {
14003
+ return _getDay2(c, 'left');
14004
+ },
14005
+ onChangeMonth: function (c) {
14006
+ try {
14007
+ return Promise.resolve(_onChangeMonth(c, 'left'));
14008
+ } catch (e) {
14009
+ return Promise.reject(e);
14010
+ }
14011
+ },
13991
14012
  ref: ref,
13992
14013
  label: React__default.createElement(LabelContainer$1, null, React__default.createElement("b", null, "Inicio:"), ' ', value[0] ? dateToIsoString(value[0]) : '––/––/––––'),
13993
14014
  calendar: [calendar1, function (v) {
@@ -14000,8 +14021,16 @@ var Main$1 = React__default.forwardRef(function (props, ref) {
14000
14021
  min: min,
14001
14022
  max: max
14002
14023
  }), inputs[0]), React__default.createElement(BasicCalendar, Object.assign({}, calendarProps, {
14003
- getDay: getDay
14004
- }, {
14024
+ getDay: function getDay(c) {
14025
+ return _getDay2(c, 'right');
14026
+ },
14027
+ onChangeMonth: function (c) {
14028
+ try {
14029
+ return Promise.resolve(_onChangeMonth(c, 'right'));
14030
+ } catch (e) {
14031
+ return Promise.reject(e);
14032
+ }
14033
+ },
14005
14034
  ref: ref,
14006
14035
  label: React__default.createElement(LabelContainer$1, null, React__default.createElement("b", null, "Fim:"), " ", value[1] ? dateToIsoString(value[1]) : '––/––/––––'),
14007
14036
  calendar: [calendar2, setCalendar2],
@@ -14030,12 +14059,17 @@ var SingleCalendar = React__default.forwardRef(function (props, ref) {
14030
14059
  var initialValue = props.initialValue,
14031
14060
  min = props.min,
14032
14061
  max = props.max;
14033
- var timeProps = props.time === true ? {} : props.time;
14034
14062
 
14035
14063
  var _ref = props.value || React.useState(initialValue && !isNaN(initialValue.getTime()) && isDateBetween(initialValue, min, max) ? initialValue : null),
14036
14064
  value = _ref[0],
14037
14065
  setValue = _ref[1];
14038
14066
 
14067
+ var timeProps = function () {
14068
+ if (props.time === true) return {};
14069
+ if (typeof props.time === 'function') return props.time(value);
14070
+ return props.time;
14071
+ }();
14072
+
14039
14073
  var _ref2 = props.invalid || React.useState(false),
14040
14074
  invalid = _ref2[0],
14041
14075
  setInvalid = _ref2[1];
@@ -16652,7 +16686,11 @@ var DateTime = React__default.forwardRef(function (props, ref) {
16652
16686
  onKeyDown: onKeyDown,
16653
16687
  icon: icon,
16654
16688
  ref: ref
16655
- })), React__default.createElement(Calendar, Object.assign({}, typeof picker === 'object' ? picker : {}, {
16689
+ })), React__default.createElement(Calendar, Object.assign({
16690
+ time: {
16691
+ seconds: props.seconds
16692
+ }
16693
+ }, typeof picker === 'object' ? picker : {}, {
16656
16694
  type: 'single',
16657
16695
  absolute: true,
16658
16696
  open: open,
@@ -16668,9 +16706,6 @@ var DateTime = React__default.forwardRef(function (props, ref) {
16668
16706
  max: max,
16669
16707
  references: {
16670
16708
  bottom: '35px'
16671
- },
16672
- time: {
16673
- seconds: props.seconds
16674
16709
  }
16675
16710
  })));
16676
16711
  });