@linzjs/lui 17.34.0 → 17.35.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,17 @@
1
+ ## [17.35.1](https://github.com/linz/lui/compare/v17.35.0...v17.35.1) (2023-02-15)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Adds event handler to LuiTab ([73f0cfb](https://github.com/linz/lui/commit/73f0cfba18f6a60f50238eef2548bddf236f9030))
7
+
8
+ # [17.35.0](https://github.com/linz/lui/compare/v17.34.0...v17.35.0) (2023-02-14)
9
+
10
+
11
+ ### Features
12
+
13
+ * **LuiDateInput:** Add date picker ([#814](https://github.com/linz/lui/issues/814)) ([a0411b1](https://github.com/linz/lui/commit/a0411b1bd741e0f419047e011b3593ce5b166253))
14
+
1
15
  # [17.34.0](https://github.com/linz/lui/compare/v17.33.2...v17.34.0) (2023-02-14)
2
16
 
3
17
  ## [17.33.2](https://github.com/linz/lui/compare/v17.33.1...v17.33.2) (2023-02-10)
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ declare type Input = JSX.IntrinsicElements['input'];
3
+ declare type Props = Omit<Input, 'pattern' | 'type' | 'placeholder'>;
4
+ export declare const DateInput: React.ForwardRefExoticComponent<Pick<Props, "key" | "accept" | "alt" | "autoComplete" | "autoFocus" | "capture" | "checked" | "crossOrigin" | "disabled" | "form" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "height" | "list" | "max" | "maxLength" | "min" | "minLength" | "multiple" | "name" | "readOnly" | "required" | "size" | "src" | "step" | "value" | "width" | "onChange" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture"> & React.RefAttributes<HTMLInputElement>>;
5
+ export default DateInput;
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ declare type ParseOptions = {
3
+ allowTwoDigitYear?: boolean;
4
+ };
5
+ export declare const parseTextDate: (value: JSX.IntrinsicElements['input']['value'], options?: ParseOptions) => string | undefined;
6
+ export {};
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { LuiTextInput } from '../LuiTextInput/LuiTextInput';
3
+ declare type Props = Omit<Parameters<typeof LuiTextInput>[0], 'as'>;
4
+ export declare const LuiDateInput: ({ inputProps, ...rest }: Props) => JSX.Element;
5
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { ChangeEventHandler, DetailedHTMLProps, InputHTMLAttributes } from 'react';
2
2
  export interface LuiTextInputProps {
3
3
  onChange?: ChangeEventHandler<HTMLInputElement>;
4
- inputProps?: DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
4
+ inputProps?: Omit<DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, 'ref'>;
5
5
  error?: string;
6
6
  warning?: string;
7
7
  hideLabel?: boolean;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  interface LuiTabProps {
3
- onClick: () => void;
3
+ onClick: (e?: React.MouseEvent<HTMLButtonElement>) => void;
4
4
  active: boolean;
5
5
  id: string;
6
6
  ariaControls: string;
package/dist/index.d.ts CHANGED
@@ -22,6 +22,7 @@ export { LuiFileInputBox } from './components/LuiFormElements/LuiFileInputBox/Lu
22
22
  export { LuiSelectInput } from './components/LuiFormElements/LuiSelectInput/LuiSelectInput';
23
23
  export { LuiTextAreaInput } from './components/LuiFormElements/LuiTextAreaInput/LuiTextAreaInput';
24
24
  export { LuiTextInput } from './components/LuiFormElements/LuiTextInput/LuiTextInput';
25
+ export { LuiDateInput } from './components/LuiFormElements/LuiDateInput/LuiDateInput';
25
26
  export { LuiRadioInput } from './components/LuiFormElements/LuiRadioInput/LuiRadioInput';
26
27
  export { LuiFormikCheckbox } from './components/LuiFormikForms/LuiFormikCheckbox/LuiFormikCheckbox';
27
28
  export { LuiFormikTextInput } from './components/LuiFormikForms/LuiFormikTextInput/LuiFormikTextInput';
package/dist/index.js CHANGED
@@ -11933,9 +11933,9 @@ function identifier$1(index) {
11933
11933
  return slice$1(index, position$1);
11934
11934
  }
11935
11935
  function compile$1(value) {
11936
- return dealloc$1(parse$3("", null, null, null, [""], value = alloc$1(value), 0, [0], value));
11936
+ return dealloc$1(parse$4("", null, null, null, [""], value = alloc$1(value), 0, [0], value));
11937
11937
  }
11938
- function parse$3(value, root2, parent2, rule, rules, rulesets, pseudo, points, declarations) {
11938
+ function parse$4(value, root2, parent2, rule, rules, rulesets, pseudo, points, declarations) {
11939
11939
  var index = 0;
11940
11940
  var offset = 0;
11941
11941
  var length2 = pseudo;
@@ -12002,16 +12002,16 @@ function parse$3(value, root2, parent2, rule, rules, rulesets, pseudo, points, d
12002
12002
  append$1(reference = ruleset$1(characters2, root2, parent2, index, offset, rules, points, type, props = [], children = [], length2), rulesets);
12003
12003
  if (character2 === 123)
12004
12004
  if (offset === 0)
12005
- parse$3(characters2, root2, reference, reference, props, rulesets, length2, points, children);
12005
+ parse$4(characters2, root2, reference, reference, props, rulesets, length2, points, children);
12006
12006
  else
12007
12007
  switch (atrule) {
12008
12008
  case 100:
12009
12009
  case 109:
12010
12010
  case 115:
12011
- parse$3(value, reference, reference, rule && append$1(ruleset$1(value, reference, reference, 0, 0, rules, points, type, rules, props = [], length2), children), rules, children, length2, points, rule ? props : children);
12011
+ parse$4(value, reference, reference, rule && append$1(ruleset$1(value, reference, reference, 0, 0, rules, points, type, rules, props = [], length2), children), rules, children, length2, points, rule ? props : children);
12012
12012
  break;
12013
12013
  default:
12014
- parse$3(characters2, reference, reference, reference, [""], children, 0, points, children);
12014
+ parse$4(characters2, reference, reference, reference, [""], children, 0, points, children);
12015
12015
  }
12016
12016
  }
12017
12017
  index = offset = property2 = 0, variable = ampersand = 1, type = characters2 = "", length2 = pseudo;
@@ -14255,7 +14255,7 @@ var parseValue = function (value) {
14255
14255
  return null
14256
14256
  };
14257
14257
 
14258
- var parse$2 = function (rule) { return rule.split(' ').map(parseValue); };
14258
+ var parse$3 = function (rule) { return rule.split(' ').map(parseValue); };
14259
14259
 
14260
14260
  var getSizeAtTrack = function (index, tracks, gap, end) {
14261
14261
  if ( gap === void 0 ) { gap = 0; }
@@ -14476,12 +14476,12 @@ Gutter.prototype.getRawComputedGap = function getRawComputedGap () {
14476
14476
 
14477
14477
  Gutter.prototype.setTracks = function setTracks (raw) {
14478
14478
  this.tracks = raw.split(' ');
14479
- this.trackValues = parse$2(raw);
14479
+ this.trackValues = parse$3(raw);
14480
14480
  };
14481
14481
 
14482
14482
  Gutter.prototype.setComputedTracks = function setComputedTracks (raw) {
14483
14483
  this.computedTracks = raw.split(' ');
14484
- this.computedPixels = parse$2(raw);
14484
+ this.computedPixels = parse$3(raw);
14485
14485
  };
14486
14486
 
14487
14487
  Gutter.prototype.setGap = function setGap (raw) {
@@ -15570,20 +15570,110 @@ function v4(options, buf, offset) {
15570
15570
  return stringify$1(rnds);
15571
15571
  }
15572
15572
 
15573
+ var mapFromDigits = function (value) {
15574
+ var trimmed = value.split(' ').join();
15575
+ var hasEightChars = trimmed.length === 8;
15576
+ var isNumber = !isNaN(Number(trimmed));
15577
+ if (isNumber && hasEightChars) {
15578
+ return "".concat(trimmed.slice(0, 2), "/").concat(trimmed.slice(2, 4), "/").concat(trimmed.slice(4));
15579
+ }
15580
+ return value;
15581
+ };
15582
+ var mapFromValidFormat = function (value) {
15583
+ // Valid format refers to yyyy-mm-dd
15584
+ var validDate = value.slice(0, 10);
15585
+ if (validDate.length !== 10) {
15586
+ return value;
15587
+ }
15588
+ var elements = validDate.split('-');
15589
+ if (elements.length !== 3) {
15590
+ return value;
15591
+ }
15592
+ var yyyy = elements[0], mm = elements[1], dd = elements[2];
15593
+ var isDay = dd.length === 2 && !isNaN(Number(dd));
15594
+ var isMonth = mm.length === 2 && !isNaN(Number(mm));
15595
+ var isYear = yyyy.length === 4 && !isNaN(Number(yyyy));
15596
+ if (isDay && isMonth && isYear) {
15597
+ return "".concat(dd, "/").concat(mm, "/").concat(yyyy);
15598
+ }
15599
+ return value;
15600
+ };
15601
+ var parse$2 = function (value, options) {
15602
+ value = mapFromDigits(value);
15603
+ value = mapFromValidFormat(value);
15604
+ var arr = value
15605
+ .split(/-|\//)
15606
+ .filter(Boolean)
15607
+ .map(function (val) { return Number(val); });
15608
+ if (arr.length !== 3) {
15609
+ return;
15610
+ }
15611
+ if (arr.some(function (val) { return isNaN(val); })) {
15612
+ return;
15613
+ }
15614
+ var dd = arr[0], mm = arr[1], yyyy = arr[2];
15615
+ if (String(yyyy).length !== 4) {
15616
+ if (yyyy <= 99 && (options === null || options === void 0 ? void 0 : options.allowTwoDigitYear)) {
15617
+ return parse$2("".concat(dd, "/").concat(mm, "/20").concat(yyyy.toString().padStart(2, '0')));
15618
+ }
15619
+ return;
15620
+ }
15621
+ var day = String(dd).padStart(2, '0');
15622
+ var month = String(mm).padStart(2, '0');
15623
+ var year = String(yyyy);
15624
+ var date = new Date("".concat(year, "-").concat(month, "-").concat(day));
15625
+ if (date.toString() === 'Invalid Date') {
15626
+ return;
15627
+ }
15628
+ var result = date.toISOString().split('T')[0];
15629
+ var _a = result.split('-'), convertedYear = _a[0], convertedMonth = _a[1], convertedDay = _a[2];
15630
+ var isDayMatch = convertedDay === day;
15631
+ var isMonthMatch = convertedMonth === month;
15632
+ var isYearMatch = convertedYear === year;
15633
+ var isValidDate = [isDayMatch, isMonthMatch, isYearMatch].every(Boolean);
15634
+ return isValidDate ? result : undefined;
15635
+ };
15636
+ var parseTextDate = function (value, options) {
15637
+ if (!value || typeof value !== 'string') {
15638
+ return;
15639
+ }
15640
+ try {
15641
+ return parse$2(value, options);
15642
+ }
15643
+ catch (_a) {
15644
+ return;
15645
+ }
15646
+ };
15647
+
15648
+ var DateInput = React$1.forwardRef(function (props, ref) {
15649
+ var valueProp = props.value, onChangeProp = props.onChange, onPasteProp = props.onPaste, inputProps = __rest$1(props, ["value", "onChange", "onPaste"]);
15650
+ var value = parseTextDate(valueProp);
15651
+ return (React__default["default"].createElement("input", __assign$3({}, inputProps, { ref: ref, pattern: "d{2}/d{2}/d{4}", placeholder: "dd/mm/yyyy", type: 'date', value: value, onChange: function (e) { return onChangeProp === null || onChangeProp === void 0 ? void 0 : onChangeProp(e); }, onPaste: function (e) {
15652
+ var data = e.clipboardData.getData('text');
15653
+ var parsedValue = parseTextDate(data, { allowTwoDigitYear: true });
15654
+ if (parsedValue) {
15655
+ e.currentTarget.value = parsedValue;
15656
+ }
15657
+ onPasteProp === null || onPasteProp === void 0 ? void 0 : onPasteProp(e);
15658
+ } })));
15659
+ });
15660
+
15573
15661
  function useGenerateOrDefaultId(idFromProps) {
15574
15662
  var id = React$1.useState(idFromProps ? idFromProps : v4())[0];
15575
15663
  return id;
15576
15664
  }
15665
+ var BareInput = function (props) { return (React__default["default"].createElement("input", __assign$3({}, props))); };
15577
15666
  var LuiTextInput = function (props) {
15578
- var _a;
15667
+ var _a, _b, _c;
15579
15668
  var id = useGenerateOrDefaultId((_a = props.inputProps) === null || _a === void 0 ? void 0 : _a.id);
15669
+ var LuiInput = ((_b = props.inputProps) === null || _b === void 0 ? void 0 : _b.type) === 'date' ? DateInput : BareInput;
15580
15670
  return (React__default["default"].createElement("div", { className: clsx$1('LuiTextInput', props.error && 'hasError', props.warning && 'hasWarning', props.className) },
15581
15671
  React__default["default"].createElement("label", { className: 'LuiTextInput-label', htmlFor: id },
15582
15672
  props.mandatory && React__default["default"].createElement("span", { className: "LuiTextInput-mandatory" }, "*"),
15583
15673
  React__default["default"].createElement("span", { className: 'LuiTextInput-label-text ' +
15584
15674
  clsx$1(props.hideLabel ? 'LuiScreenReadersOnly' : '') }, props.label),
15585
15675
  React__default["default"].createElement("span", { className: "LuiTextInput-inputWrapper" },
15586
- React__default["default"].createElement("input", __assign$3({ type: 'text', className: clsx$1('LuiTextInput-input', props.showPadlockIcon ? 'LuiTextInput-padlock-icon ' : '', props.size ? "LuiTextInput-".concat(props.size) : ''), min: "0", value: props.value, onChange: props.onChange }, props.inputProps, { id: id })),
15676
+ React__default["default"].createElement(LuiInput, __assign$3({ className: clsx$1('LuiTextInput-input', props.showPadlockIcon ? 'LuiTextInput-padlock-icon ' : '', props.size ? "LuiTextInput-".concat(props.size) : ''), min: ((_c = props.inputProps) === null || _c === void 0 ? void 0 : _c.type) === 'date' ? undefined : '0', value: props.value, onChange: props.onChange }, props.inputProps, { id: id })),
15587
15677
  props.icon),
15588
15678
  props.error && (React__default["default"].createElement("span", { className: "LuiTextInput-error" },
15589
15679
  React__default["default"].createElement(LuiIcon, { alt: "error", name: "ic_error", className: "LuiTextInput-error-icon", size: "sm", status: "error" }),
@@ -15729,6 +15819,12 @@ var LuiTextAreaInput = function (props) {
15729
15819
  props.error))));
15730
15820
  };
15731
15821
 
15822
+ var LuiDateInput = function (_a) {
15823
+ var inputProps = _a.inputProps, rest = __rest$1(_a, ["inputProps"]);
15824
+ var mapped = __assign$3({ inputProps: __assign$3(__assign$3({}, inputProps), { type: 'date' }) }, rest);
15825
+ return React__default["default"].createElement(LuiTextInput, __assign$3({}, mapped));
15826
+ };
15827
+
15732
15828
  // @NOTE Can use LuiRadioInput in block form and pass through your own legend (label)
15733
15829
  var LuiRadioInput = function (props) {
15734
15830
  var _a;
@@ -58458,6 +58554,7 @@ exports.LuiCloseableHeaderMenuItem = LuiCloseableHeaderMenuItem;
58458
58554
  exports.LuiCloseableHeaderMenuItemV2 = LuiCloseableHeaderMenuItemV2;
58459
58555
  exports.LuiComboSelect = LuiComboSelect;
58460
58556
  exports.LuiControlledMenu = LuiControlledMenu;
58557
+ exports.LuiDateInput = LuiDateInput;
58461
58558
  exports.LuiDrawerMenu = LuiDrawerMenu;
58462
58559
  exports.LuiDrawerMenuDivider = LuiDrawerMenuDivider;
58463
58560
  exports.LuiDrawerMenuDividerV2 = LuiDrawerMenuDividerV2;