@economic/taco 2.42.1 → 2.43.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.
- package/dist/components/Datepicker/Datepicker.d.ts +2 -2
- package/dist/esm/packages/taco/src/components/Datepicker/Datepicker.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Datepicker/useDatepicker.js +10 -13
- package/dist/esm/packages/taco/src/components/Datepicker/useDatepicker.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js +5 -4
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js.map +1 -1
- package/dist/esm/packages/taco/src/index.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/dataTypes.js +5 -15
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/dataTypes.js.map +1 -1
- package/dist/esm/packages/taco/src/utils/date.js +19 -7
- package/dist/esm/packages/taco/src/utils/date.js.map +1 -1
- package/dist/taco.cjs.development.js +35 -32
- package/dist/taco.cjs.development.js.map +1 -1
- package/dist/taco.cjs.production.min.js +1 -1
- package/dist/taco.cjs.production.min.js.map +1 -1
- package/dist/utils/date.d.ts +2 -1
- package/package.json +2 -2
@@ -6174,17 +6174,29 @@ const Combobox = /*#__PURE__*/React.forwardRef(function Combobox(props, ref) {
|
|
6174
6174
|
const isWeakEqual = (leftDate, rightDate) => {
|
6175
6175
|
return leftDate.getFullYear() === rightDate.getFullYear() && leftDate.getMonth() === rightDate.getMonth() && leftDate.getDate() === rightDate.getDate();
|
6176
6176
|
};
|
6177
|
-
|
6178
|
-
|
6179
|
-
|
6177
|
+
function parse(date) {
|
6178
|
+
let value;
|
6179
|
+
if (dateFns.isDate(date)) {
|
6180
|
+
value = date;
|
6181
|
+
} else if (typeof date === 'string') {
|
6182
|
+
value = parseFromISOString(date);
|
6180
6183
|
}
|
6181
|
-
const value = dateFns.isDate(date) ? date : dateFns.toDate(date);
|
6182
6184
|
if (!dateFns.isValid(value)) {
|
6183
6185
|
return undefined;
|
6184
6186
|
}
|
6187
|
+
return value;
|
6188
|
+
}
|
6189
|
+
function format(date, mask = 'dd.mm.yy') {
|
6190
|
+
if (date === undefined) {
|
6191
|
+
return undefined;
|
6192
|
+
}
|
6193
|
+
const value = parse(date);
|
6194
|
+
if (!dateFns.isValid(value) || value === undefined) {
|
6195
|
+
return undefined;
|
6196
|
+
}
|
6185
6197
|
const pad = v => String(v).length === 1 ? `0${v}` : v.toString();
|
6186
6198
|
return mask.replace('dd', pad(value.getDate())).replace('mm', pad(value.getMonth() + 1)).replace('yy', String(value.getFullYear()).slice(2));
|
6187
|
-
}
|
6199
|
+
}
|
6188
6200
|
const parseFromCustomString = (date = '', mask = 'dd.mm.yy', defaultMonth = undefined, defaultYear = undefined) => {
|
6189
6201
|
if (!date || !date.length) {
|
6190
6202
|
return undefined;
|
@@ -6238,26 +6250,24 @@ const useDatepicker = ({
|
|
6238
6250
|
value,
|
6239
6251
|
...props
|
6240
6252
|
}, ref) => {
|
6253
|
+
var _format;
|
6241
6254
|
const inputRef = useMergedRef(ref);
|
6242
6255
|
const {
|
6243
6256
|
formatting
|
6244
6257
|
} = useLocalization();
|
6245
|
-
const [internalValue, setInternalValue] = React.useState(
|
6258
|
+
const [internalValue, setInternalValue] = React.useState((_format = format(value, formatting.date)) !== null && _format !== void 0 ? _format : '');
|
6259
|
+
const originalValueAsDate = parse(value);
|
6246
6260
|
// update internal value if it changed 'externally'
|
6247
6261
|
React.useEffect(() => {
|
6248
|
-
|
6249
|
-
|
6250
|
-
|
6251
|
-
setInternalValue(formattedValue);
|
6252
|
-
}
|
6253
|
-
} else {
|
6254
|
-
setInternalValue('');
|
6262
|
+
const formattedValue = format(value, formatting.date);
|
6263
|
+
if (formattedValue !== internalValue) {
|
6264
|
+
setInternalValue(formattedValue !== null && formattedValue !== void 0 ? formattedValue : '');
|
6255
6265
|
}
|
6256
6266
|
}, [value]);
|
6257
6267
|
// event handlers
|
6258
6268
|
const handleInputBlur = event => {
|
6259
6269
|
event.persist();
|
6260
|
-
const valueAsDate = parseFromCustomString(event.target.value, 'dd.mm.yy',
|
6270
|
+
const valueAsDate = parseFromCustomString(event.target.value, 'dd.mm.yy', originalValueAsDate === null || originalValueAsDate === void 0 ? void 0 : originalValueAsDate.getMonth(), originalValueAsDate === null || originalValueAsDate === void 0 ? void 0 : originalValueAsDate.getFullYear());
|
6261
6271
|
const formattedValue = valueAsDate ? format(valueAsDate) || '' : '';
|
6262
6272
|
event.target.value = formattedValue;
|
6263
6273
|
if (onChange) {
|
@@ -6281,7 +6291,7 @@ const useDatepicker = ({
|
|
6281
6291
|
if (props.onKeyDown) {
|
6282
6292
|
props.onKeyDown(event);
|
6283
6293
|
}
|
6284
|
-
if (
|
6294
|
+
if (event.key === 'Enter') {
|
6285
6295
|
event.target.dispatchEvent(new Event('focusout', {
|
6286
6296
|
bubbles: true
|
6287
6297
|
}));
|
@@ -6300,7 +6310,7 @@ const useDatepicker = ({
|
|
6300
6310
|
const calendarProps = {
|
6301
6311
|
...calendar,
|
6302
6312
|
onChange: handleChange,
|
6303
|
-
value
|
6313
|
+
value: originalValueAsDate
|
6304
6314
|
};
|
6305
6315
|
return {
|
6306
6316
|
input: inputProps,
|
@@ -9816,17 +9826,8 @@ const dataTypes = {
|
|
9816
9826
|
sortingFn: 'datetime',
|
9817
9827
|
filterComparators: [exports.TableFilterComparator.IsEqualTo, exports.TableFilterComparator.IsNotEqualTo, exports.TableFilterComparator.IsGreaterThan, exports.TableFilterComparator.IsLessThan, exports.TableFilterComparator.IsGreaterThanOrEqualTo, exports.TableFilterComparator.IsLessThanOrEqualTo, exports.TableFilterComparator.IsBetween, exports.TableFilterComparator.IsEmpty, exports.TableFilterComparator.IsNotEmpty],
|
9818
9828
|
getDisplayValue: (value, options) => {
|
9819
|
-
|
9820
|
-
|
9821
|
-
}
|
9822
|
-
if (dateFns.isDate(value)) {
|
9823
|
-
var _format, _options$localization;
|
9824
|
-
return (_format = format(value, options === null || options === void 0 ? void 0 : (_options$localization = options.localization) === null || _options$localization === void 0 ? void 0 : _options$localization.formatting.date)) !== null && _format !== void 0 ? _format : '';
|
9825
|
-
} else if (typeof value === 'string') {
|
9826
|
-
var _format2, _options$localization2;
|
9827
|
-
return (_format2 = format(parseFromISOString(value), options === null || options === void 0 ? void 0 : (_options$localization2 = options.localization) === null || _options$localization2 === void 0 ? void 0 : _options$localization2.formatting.date)) !== null && _format2 !== void 0 ? _format2 : '';
|
9828
|
-
}
|
9829
|
-
return String(value);
|
9829
|
+
var _date$format, _options$localization;
|
9830
|
+
return (_date$format = format(value, options === null || options === void 0 ? void 0 : (_options$localization = options.localization) === null || _options$localization === void 0 ? void 0 : _options$localization.formatting.date)) !== null && _date$format !== void 0 ? _date$format : '';
|
9830
9831
|
}
|
9831
9832
|
},
|
9832
9833
|
boolean: {
|
@@ -9839,11 +9840,11 @@ const dataTypes = {
|
|
9839
9840
|
sortingFn: 'basic',
|
9840
9841
|
filterComparators: [exports.TableFilterComparator.IsEqualTo, exports.TableFilterComparator.IsNotEqualTo, exports.TableFilterComparator.IsGreaterThan, exports.TableFilterComparator.IsLessThan, exports.TableFilterComparator.IsGreaterThanOrEqualTo, exports.TableFilterComparator.IsLessThanOrEqualTo, exports.TableFilterComparator.IsBetween, exports.TableFilterComparator.IsEmpty, exports.TableFilterComparator.IsNotEmpty],
|
9841
9842
|
getDisplayValue: (value, options) => {
|
9842
|
-
var _options$
|
9843
|
+
var _options$localization2;
|
9843
9844
|
if (value === undefined) {
|
9844
9845
|
return '';
|
9845
9846
|
}
|
9846
|
-
return new Intl.NumberFormat(options === null || options === void 0 ? void 0 : (_options$
|
9847
|
+
return new Intl.NumberFormat(options === null || options === void 0 ? void 0 : (_options$localization2 = options.localization) === null || _options$localization2 === void 0 ? void 0 : _options$localization2.locale, {
|
9847
9848
|
minimumFractionDigits: 2
|
9848
9849
|
}).format(Number(value));
|
9849
9850
|
}
|
@@ -19260,10 +19261,11 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
19260
19261
|
}
|
19261
19262
|
};
|
19262
19263
|
if (type === 'datepicker') {
|
19264
|
+
const valueAsDate = parse(value);
|
19263
19265
|
const handleChange = event => {
|
19264
19266
|
const newDate = event.detail;
|
19265
|
-
if (!
|
19266
|
-
props.onChange(
|
19267
|
+
if (!valueAsDate || !newDate || dateFns.isDate(valueAsDate) && dateFns.isDate(newDate) && !isWeakEqual(valueAsDate, newDate)) {
|
19268
|
+
props.onChange(newDate);
|
19267
19269
|
}
|
19268
19270
|
};
|
19269
19271
|
return /*#__PURE__*/React__default.createElement(Datepicker, Object.assign({}, commonProps, {
|
@@ -19272,7 +19274,7 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
19272
19274
|
onFocus: handleFocus,
|
19273
19275
|
onKeyDown: handleInputKeyDown,
|
19274
19276
|
ref: controlRef,
|
19275
|
-
value:
|
19277
|
+
value: valueAsDate
|
19276
19278
|
}));
|
19277
19279
|
}
|
19278
19280
|
if (type === 'textarea') {
|
@@ -20863,6 +20865,7 @@ exports.isMacOs = isMacOs;
|
|
20863
20865
|
exports.isPressingMetaKey = isPressingMetaKey;
|
20864
20866
|
exports.isWeakEqual = isWeakEqual;
|
20865
20867
|
exports.mergeRefs = mergeRefs;
|
20868
|
+
exports.parse = parse;
|
20866
20869
|
exports.parseFromCustomString = parseFromCustomString;
|
20867
20870
|
exports.parseFromISOString = parseFromISOString;
|
20868
20871
|
exports.removeChildTableRow = removeChildTableRow;
|