@xqmsg/ui-core 0.23.3 → 0.24.0

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.
@@ -19,7 +19,7 @@ export interface ValidationProps {
19
19
  isInvalid?: boolean;
20
20
  errorText?: string;
21
21
  }
22
- export interface InputFieldProps extends Omit<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, 'color' | 'height' | 'width' | 'size' | 'ref'>, FieldProps, Partial<InputProps> {
22
+ export interface InputFieldProps extends Omit<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, 'color' | 'height' | 'width' | 'size' | 'ref' | 'onChange' | 'defaultValue'>, FieldProps, Partial<InputProps> {
23
23
  }
24
24
  export interface TextareaFieldProps extends Omit<React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, 'color' | 'height' | 'width' | 'size' | 'ref'>, FieldProps, Partial<TextareaProps> {
25
25
  }
@@ -1,7 +1,7 @@
1
- import React from 'react';
1
+ import React, { ChangeEvent } from 'react';
2
2
  import { FieldOptions, ValidationProps, InputType } from './InputTypes';
3
3
  import { Control, FieldValues, UseFormClearErrors, UseFormSetError, UseFormSetValue } from 'react-hook-form';
4
- export interface InputProps<T extends FieldValues> extends ValidationProps {
4
+ export interface InputProps<T extends FieldValues = FieldValues> extends ValidationProps {
5
5
  inputType: InputType;
6
6
  name: string;
7
7
  ariaLabel: string;
@@ -14,7 +14,7 @@ export interface InputProps<T extends FieldValues> extends ValidationProps {
14
14
  maxLength?: number;
15
15
  helperText?: React.ReactNode;
16
16
  control: Control<T, any>;
17
- onChange?: (value?: string) => void;
17
+ onChange?: (e: ChangeEvent<HTMLInputElement>) => void;
18
18
  disabled?: boolean;
19
19
  tooltipText?: string;
20
20
  setValue: UseFormSetValue<T>;
@@ -1,9 +1,10 @@
1
1
  import React from 'react';
2
- import { Control, FieldValues, UseFormClearErrors, UseFormSetError, UseFormSetValue } from 'react-hook-form';
2
+ import { SelectProps } from '@chakra-ui/react';
3
+ import { Control, FieldValues, Path, UseFormClearErrors, UseFormSetError, UseFormSetValue } from 'react-hook-form';
3
4
  import { FieldOptions, ValidationProps } from 'src/components/input/InputTypes';
4
- export interface SelectNativeProps<T extends FieldValues> extends ValidationProps {
5
+ export interface SelectNativeProps<T extends FieldValues> extends ValidationProps, SelectProps {
5
6
  isRequired: boolean;
6
- name: string;
7
+ name: Path<T>;
7
8
  ariaLabel: string;
8
9
  placeholder?: string;
9
10
  defaultValue?: string;
@@ -13,7 +14,7 @@ export interface SelectNativeProps<T extends FieldValues> extends ValidationProp
13
14
  fullOptions?: FieldOptions;
14
15
  helperText?: React.ReactNode;
15
16
  control: Control<T, unknown>;
16
- onChange?: (value?: string) => void;
17
+ onChange?: (e: React.ChangeEvent<HTMLSelectElement>) => void;
17
18
  disabled?: boolean;
18
19
  tooltipText?: string;
19
20
  setValue: UseFormSetValue<T>;
@@ -24,4 +25,4 @@ export interface SelectNativeProps<T extends FieldValues> extends ValidationProp
24
25
  /**
25
26
  * A functional React component utilized to render the `SelectNative` component.
26
27
  */
27
- export declare const SelectNative: React.FC<SelectNativeProps<HTMLSelectElement>>;
28
+ export declare function SelectNative<T extends FieldValues = FieldValues>({ label, ariaLabel, className, placeholder, name, helperText, options, tooltipText, isInvalid, errorText, isRequired, defaultValue, fullOptions, control, disabled, onChange, setValue, setError, clearErrors, ...props }: SelectNativeProps<T>): React.ReactElement;
@@ -1,8 +1,8 @@
1
1
  import React, { PropsWithChildren } from 'react';
2
2
  import textTheme from '../../theme/components/text';
3
- export interface TextProps extends PropsWithChildren {
3
+ export declare type TextProps = PropsWithChildren & {
4
4
  variant: keyof typeof textTheme.variants;
5
- }
5
+ };
6
6
  /**
7
7
  * A functional React component utilized to render the `Text` component. The component is mainly
8
8
  * controlled by by the `variant` prop which determines `fontSize`, `fontWeight`, etc.
@@ -1168,9 +1168,7 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
1168
1168
  }))), isFocussed && /*#__PURE__*/React__default.createElement(Dropdown, {
1169
1169
  position: position,
1170
1170
  dropdownRef: dropdownMenuRef,
1171
- onSelectItem: function onSelectItem(option) {
1172
- return handleOnSelectItem(option);
1173
- },
1171
+ onSelectItem: handleOnSelectItem,
1174
1172
  options: options,
1175
1173
  optionIndex: optionIndex
1176
1174
  }));
@@ -1901,7 +1899,7 @@ function Input(_ref) {
1901
1899
  setError = _ref.setError,
1902
1900
  clearErrors = _ref.clearErrors,
1903
1901
  separators = _ref.separators;
1904
- var selectedInputField = function selectedInputField(onChange, onBlur, ref, value) {
1902
+ function selectedInputField(onChange, onBlur, ref, value) {
1905
1903
  switch (inputType) {
1906
1904
  case 'text':
1907
1905
  return /*#__PURE__*/React__default.createElement(StackedInput, {
@@ -2045,7 +2043,7 @@ function Input(_ref) {
2045
2043
  default:
2046
2044
  return null;
2047
2045
  }
2048
- };
2046
+ }
2049
2047
  var nonLabeledInputs = ['checkbox'];
2050
2048
  return /*#__PURE__*/React__default.createElement(reactHookForm.Controller, {
2051
2049
  control: control,
@@ -3023,7 +3021,7 @@ var _excluded$4 = ["label", "ariaLabel", "className", "placeholder", "name", "he
3023
3021
  /**
3024
3022
  * A functional React component utilized to render the `SelectNative` component.
3025
3023
  */
3026
- var SelectNative = function SelectNative(_ref) {
3024
+ function SelectNative(_ref) {
3027
3025
  var name = _ref.name,
3028
3026
  helperText = _ref.helperText,
3029
3027
  options = _ref.options,
@@ -3052,26 +3050,21 @@ var SelectNative = function SelectNative(_ref) {
3052
3050
  borderLeft: 'none',
3053
3051
  borderRight: 'none'
3054
3052
  };
3055
- var handleOnSelectItem = function handleOnSelectItem(selectedValue) {
3053
+ var handleOnSelectItem = function handleOnSelectItem(e) {
3054
+ var selectedValue = e.target.value;
3056
3055
  var selectedOption = options == null ? void 0 : options.find(function (_ref2) {
3057
3056
  var val = _ref2.value;
3058
3057
  return selectedValue === val;
3059
3058
  });
3060
3059
  if (selectedOption) {
3061
3060
  if (onChange) {
3062
- onChange(selectedOption.value);
3061
+ onChange(e);
3063
3062
  }
3064
3063
  setValue(name, selectedOption.value);
3065
3064
  } else {
3066
3065
  setValue(name, selectedValue);
3067
3066
  }
3068
3067
  };
3069
- React.useEffect(function () {
3070
- if (defaultValue) {
3071
- handleOnSelectItem(defaultValue);
3072
- }
3073
- // eslint-disable-next-line react-hooks/exhaustive-deps
3074
- }, [defaultValue]);
3075
3068
  return /*#__PURE__*/React__default.createElement(reactHookForm.Controller, {
3076
3069
  control: control,
3077
3070
  name: name,
@@ -3093,9 +3086,8 @@ var SelectNative = function SelectNative(_ref) {
3093
3086
  ref: ref,
3094
3087
  value: value,
3095
3088
  disabled: disabled != null ? disabled : false,
3096
- onChange: function onChange(e) {
3097
- return handleOnSelectItem(e.target.value);
3098
- },
3089
+ onChange: handleOnSelectItem,
3090
+ defaultValue: defaultValue,
3099
3091
  style: style
3100
3092
  }), options && options.map(function (i) {
3101
3093
  return /*#__PURE__*/React__default.createElement("option", {
@@ -3105,7 +3097,7 @@ var SelectNative = function SelectNative(_ref) {
3105
3097
  })), isInvalid ? /*#__PURE__*/React__default.createElement(react.FormErrorMessage, null, errorText) : helperText && /*#__PURE__*/React__default.createElement(react.FormHelperText, null, helperText));
3106
3098
  }
3107
3099
  });
3108
- };
3100
+ }
3109
3101
 
3110
3102
  /**
3111
3103
  * A functional React component utilized to render the `BorderedBox` component