@xqmsg/ui-core 0.23.3 → 0.24.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.
@@ -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.
@@ -120,6 +120,34 @@ declare const _default: {
120
120
  bgGradient: string;
121
121
  shadow: string;
122
122
  };
123
+ danger: {
124
+ fontWeight: string;
125
+ color: string;
126
+ bg: string;
127
+ _hover: {
128
+ bg: string;
129
+ };
130
+ _active: {
131
+ color: string;
132
+ bg: string;
133
+ };
134
+ _focus: {
135
+ color: string;
136
+ bg: string;
137
+ };
138
+ _disabled: {
139
+ backgroundColor: string;
140
+ color: string;
141
+ };
142
+ borderRadius: string;
143
+ fontSize: string;
144
+ h: string;
145
+ border: string;
146
+ px: string;
147
+ py: string;
148
+ bgGradient: string;
149
+ shadow: string;
150
+ };
123
151
  'flat-primary': {
124
152
  bg: string;
125
153
  bgGradient: null;
@@ -233,6 +261,42 @@ declare const _default: {
233
261
  py: string;
234
262
  shadow: string;
235
263
  };
264
+ 'flat-danger': {
265
+ fontWeight: string;
266
+ color: string;
267
+ bg: string;
268
+ _hover: {
269
+ bg: string;
270
+ };
271
+ _active: {
272
+ color: string;
273
+ bg: string;
274
+ };
275
+ _focus: {
276
+ color: string;
277
+ bg: string;
278
+ };
279
+ _disabled: {
280
+ backgroundColor: string;
281
+ color: string;
282
+ };
283
+ bgGradient: null;
284
+ minWidth: string;
285
+ padding: string;
286
+ borderRadius: string;
287
+ border: string;
288
+ gap: string;
289
+ height: string;
290
+ fontSize: string;
291
+ lineHeight: string;
292
+ letterSpacing: string;
293
+ textAlign: string;
294
+ boxShadow: string;
295
+ h: string;
296
+ px: string;
297
+ py: string;
298
+ shadow: string;
299
+ };
236
300
  };
237
301
  defaultProps: {
238
302
  variant: string;
@@ -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
@@ -3783,6 +3775,28 @@ var variantTertiary = function variantTertiary() {
3783
3775
  }
3784
3776
  });
3785
3777
  };
3778
+ var variantDanger = function variantDanger() {
3779
+ return _extends$6({}, baseStyle$2, {
3780
+ fontWeight: '400',
3781
+ color: colors.label.primary.dark,
3782
+ bg: colors.label.error,
3783
+ _hover: {
3784
+ bg: colors.label.error
3785
+ },
3786
+ _active: {
3787
+ color: colors.label.primary.dark,
3788
+ bg: colors.label.error
3789
+ },
3790
+ _focus: {
3791
+ color: colors.label.primary.dark,
3792
+ bg: colors.label.error
3793
+ },
3794
+ _disabled: {
3795
+ backgroundColor: colors.label.error,
3796
+ color: colors.label.secondary.light
3797
+ }
3798
+ });
3799
+ };
3786
3800
  var variantPrimaryFlat = function variantPrimaryFlat() {
3787
3801
  return _extends$6({}, baseStyle$2, {
3788
3802
  bg: colors.fill.action,
@@ -3842,13 +3856,37 @@ var variantTertiaryFlat = function variantTertiaryFlat() {
3842
3856
  }
3843
3857
  });
3844
3858
  };
3859
+ var variantDangerFlat = function variantDangerFlat() {
3860
+ return _extends$6({}, variantPrimaryFlat(), {
3861
+ fontWeight: '400',
3862
+ color: colors.label.primary.dark,
3863
+ bg: colors.label.error,
3864
+ _hover: {
3865
+ bg: colors.label.error
3866
+ },
3867
+ _active: {
3868
+ color: colors.label.primary.dark,
3869
+ bg: colors.label.error
3870
+ },
3871
+ _focus: {
3872
+ color: colors.label.primary.dark,
3873
+ bg: colors.label.error
3874
+ },
3875
+ _disabled: {
3876
+ backgroundColor: colors.label.error,
3877
+ color: colors.label.secondary.light
3878
+ }
3879
+ });
3880
+ };
3845
3881
  var variants$2 = {
3846
3882
  primary: /*#__PURE__*/variantPrimary(),
3847
3883
  secondary: /*#__PURE__*/variantSecondary(),
3848
3884
  tertiary: /*#__PURE__*/variantTertiary(),
3885
+ danger: /*#__PURE__*/variantDanger(),
3849
3886
  'flat-primary': /*#__PURE__*/variantPrimaryFlat(),
3850
3887
  'flat-secondary': /*#__PURE__*/variantSecondaryFlat(),
3851
- 'flat-tertiary': /*#__PURE__*/variantTertiaryFlat()
3888
+ 'flat-tertiary': /*#__PURE__*/variantTertiaryFlat(),
3889
+ 'flat-danger': /*#__PURE__*/variantDangerFlat()
3852
3890
  };
3853
3891
  var defaultProps$2 = {
3854
3892
  variant: 'primary'