@vendorflow/components 2.0.52 → 2.0.56

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.
@@ -61,20 +61,31 @@ var react_1 = __importStar(require("react"));
61
61
  var date_fns_1 = require("date-fns");
62
62
  var lab_1 = require("@mui/lab");
63
63
  var material_1 = require("@mui/material");
64
+ var lodash_1 = require("lodash");
64
65
  function InputDate(props) {
65
66
  var _a = props.clearable, clearable = _a === void 0 ? true : _a, label = props.label, name = props.name, onChange = props.onChange, _b = props.inputFormat, inputFormat = _b === void 0 ? 'MM/dd/yyyy' : _b, _c = props.InputProps, InputProps = _c === void 0 ? {} : _c, restOfProps = __rest(props, ["clearable", "label", "name", "onChange", "inputFormat", "InputProps"]);
66
67
  var _d = __read((0, react_1.useState)(null), 2), value = _d[0], setValue = _d[1];
67
68
  (0, react_1.useEffect)(function () {
68
- if (props.value !== value) {
69
- setValue(props.value);
69
+ var datetime = convertToDateTime(props.value);
70
+ if (((0, lodash_1.isNull)(value) && !(0, lodash_1.isNull)(datetime)) ||
71
+ (!(0, lodash_1.isNull)(value) && (0, lodash_1.isNull)(datetime)) ||
72
+ (value && !(0, date_fns_1.isSameDay)(datetime, value))) {
73
+ setValue(datetime);
70
74
  }
71
75
  }, [props.value]);
72
76
  function handleOnChange(date) {
73
77
  setValue(date);
74
78
  if (date === null || (0, date_fns_1.isValid)(date)) {
75
- onChange({ target: { name: name, value: date ? (0, date_fns_1.formatISO)(date) : null } });
79
+ var localDate = convertToLocalDate(date);
80
+ onChange({ target: { name: name, value: localDate } });
76
81
  }
77
82
  }
83
+ function convertToLocalDate(date) {
84
+ return date && (0, date_fns_1.isValid)(date) ? (0, date_fns_1.formatISO)(date, { representation: 'date' }) : null;
85
+ }
86
+ function convertToDateTime(date) {
87
+ return date ? (0, date_fns_1.parseISO)(date) : null;
88
+ }
78
89
  return (react_1.default.createElement(lab_1.DatePicker, __assign({}, restOfProps, { clearable: clearable, inputFormat: inputFormat, renderInput: function (params) { return react_1.default.createElement(material_1.TextField, __assign({}, params, InputProps, { size: (InputProps === null || InputProps === void 0 ? void 0 : InputProps.size) || 'small' })); }, label: label, onChange: handleOnChange, value: value })));
79
90
  }
80
91
  exports.default = InputDate;
@@ -121,13 +121,13 @@ function InputSearchDropdown(props) {
121
121
  return ((_a = value) === null || _a === void 0 ? void 0 : _a.length) || 0;
122
122
  }
123
123
  return ((0, react_1.jsx)("div", null,
124
- (0, react_1.jsx)(material_1.Autocomplete, __assign({ autoHighlight: autoHighlight, clearOnEscape: clearOnEscape, filterOptions: !disableFilter ? filterOptions || handleOptionFilter() : function (options) { return options; }, filterSelectedOptions: filterSelectedOptions, onChange: handleOnChange, openOnFocus: openOnFocus, renderInput: renderInput || renderDefaultInput, renderTags: renderTags || renderDefaultTags, selectOnFocus: selectOnFocus, multiple: multiple, classes: mainStyles, size: size }, restOfProps, { value: getValue() })),
124
+ (0, react_1.jsx)(material_1.Autocomplete, __assign({ css: (0, react_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n // TODO: this is due to a bug in MaterialUI clear up when resolve -- should file a PR ticket\n &&& .MuiInputBase-root {\n padding-right: 39px;\n }\n "], ["\n // TODO: this is due to a bug in MaterialUI clear up when resolve -- should file a PR ticket\n &&& .MuiInputBase-root {\n padding-right: 39px;\n }\n "]))), autoHighlight: autoHighlight, clearOnEscape: clearOnEscape, filterOptions: !disableFilter ? filterOptions || handleOptionFilter() : function (options) { return options; }, filterSelectedOptions: filterSelectedOptions, onChange: handleOnChange, openOnFocus: openOnFocus, renderInput: renderInput || renderDefaultInput, renderTags: renderTags || renderDefaultTags, selectOnFocus: selectOnFocus, multiple: multiple, classes: mainStyles, size: size }, restOfProps, { value: getValue() })),
125
125
  (0, react_1.jsx)("div", null,
126
- helperText && ((0, react_1.jsx)(material_1.Typography, { css: (0, react_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n float: left;\n margin-left: 14px;\n margin-top: 4px;\n color: ", ";\n width: calc(100% - 82px);\n "], ["\n float: left;\n margin-left: 14px;\n margin-top: 4px;\n color: ", ";\n width: calc(100% - 82px);\n "])), error ? 'red' : 'rgba(0, 0, 0, 0.54)'), variant: "caption" }, helperText)),
127
- multiple && max && ((0, react_1.jsx)(material_1.Typography, { css: (0, react_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n font-size: 0.75rem;\n text-align: right;\n float: right;\n margin-left: 14px;\n margin-right: 14px;\n margin-top: 4px;\n color: ", ";\n width: 40px;\n "], ["\n font-size: 0.75rem;\n text-align: right;\n float: right;\n margin-left: 14px;\n margin-right: 14px;\n margin-top: 4px;\n color: ", ";\n width: 40px;\n "])), error ? 'red' : 'rgba(0, 0, 0, 0.54)'), variant: "subtitle1" },
126
+ helperText && ((0, react_1.jsx)(material_1.Typography, { css: (0, react_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n float: left;\n margin-left: 14px;\n margin-top: 4px;\n color: ", ";\n width: calc(100% - 82px);\n "], ["\n float: left;\n margin-left: 14px;\n margin-top: 4px;\n color: ", ";\n width: calc(100% - 82px);\n "])), error ? 'red' : 'rgba(0, 0, 0, 0.54)'), variant: "caption" }, helperText)),
127
+ multiple && max && ((0, react_1.jsx)(material_1.Typography, { css: (0, react_1.css)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n font-size: 0.75rem;\n text-align: right;\n float: right;\n margin-left: 14px;\n margin-right: 14px;\n margin-top: 4px;\n color: ", ";\n width: 40px;\n "], ["\n font-size: 0.75rem;\n text-align: right;\n float: right;\n margin-left: 14px;\n margin-right: 14px;\n margin-top: 4px;\n color: ", ";\n width: 40px;\n "])), error ? 'red' : 'rgba(0, 0, 0, 0.54)'), variant: "subtitle1" },
128
128
  getCount(),
129
129
  "/",
130
130
  max)))));
131
131
  }
132
132
  exports.default = InputSearchDropdown;
133
- var templateObject_1, templateObject_2, templateObject_3;
133
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vendorflow/components",
3
- "version": "2.0.52",
3
+ "version": "2.0.56",
4
4
  "description": "React components for vendorflow",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",