@linzjs/lui 20.0.0 → 20.0.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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [20.0.1](https://github.com/linz/lui/compare/v20.0.0...v20.0.1) (2023-09-20)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **LuiDateInput:** fire onChange upon valid paste ([#1009](https://github.com/linz/lui/issues/1009)) ([3b15b3e](https://github.com/linz/lui/commit/3b15b3e28b13011eacc5a06504733b5280db4c76))
7
+
1
8
  # [20.0.0](https://github.com/linz/lui/compare/v19.0.0...v20.0.0) (2023-09-18)
2
9
 
3
10
  # [19.0.0](https://github.com/linz/lui/compare/v18.11.2...v19.0.0) (2023-09-14)
@@ -0,0 +1 @@
1
+ export declare const fireDateChange: (e: React.ClipboardEvent<HTMLInputElement>) => void;
package/dist/index.js CHANGED
@@ -28263,14 +28263,24 @@ var parseTextDate = function (value, options) {
28263
28263
  }
28264
28264
  };
28265
28265
 
28266
+ var fireDateChange = function (e) {
28267
+ var input = e.currentTarget;
28268
+ var clipboard = e.clipboardData.getData('text');
28269
+ var parsedValue = parseTextDate(clipboard, { allowTwoDigitYear: true });
28270
+ if (parsedValue) {
28271
+ var change = new InputEvent('change', {
28272
+ bubbles: true,
28273
+ cancelable: true
28274
+ });
28275
+ input.valueAsDate = new Date(parsedValue);
28276
+ input.dispatchEvent(change);
28277
+ }
28278
+ };
28279
+
28266
28280
  var DateInput = React.forwardRef(function (props, ref) {
28267
28281
  var valueProp = props.value, onChangeProp = props.onChange, onPasteProp = props.onPaste, inputProps = __rest(props, ["value", "onChange", "onPaste"]);
28268
- return (React__default["default"].createElement("input", __assign({}, inputProps, { ref: ref, pattern: "d{2}/d{2}/d{4}", placeholder: "dd/mm/yyyy", type: 'date', value: valueProp, onChange: function (e) { return onChangeProp === null || onChangeProp === void 0 ? void 0 : onChangeProp(e); }, onPaste: function (e) {
28269
- var data = e.clipboardData.getData('text');
28270
- var parsedValue = parseTextDate(data, { allowTwoDigitYear: true });
28271
- if (parsedValue) {
28272
- e.currentTarget.value = parsedValue;
28273
- }
28282
+ return (React__default["default"].createElement("input", __assign({}, inputProps, { ref: ref, pattern: "d{2}/d{2}/d{4}", placeholder: "dd/mm/yyyy", type: "date", value: valueProp, onChange: onChangeProp, onPaste: function (e) {
28283
+ fireDateChange(e);
28274
28284
  onPasteProp === null || onPasteProp === void 0 ? void 0 : onPasteProp(e);
28275
28285
  } })));
28276
28286
  });