@seeqdev/qomponents 0.0.94 → 0.0.96

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.
@@ -10,16 +10,21 @@ export interface TextAreaProps {
10
10
  onChange?: React.ChangeEventHandler<FormControlElement>;
11
11
  /** function that will be called on key up within the TextArea */
12
12
  onKeyUp?: React.KeyboardEventHandler<FormControlElement>;
13
+ onKeyDown?: React.KeyboardEventHandler<FormControlElement>;
14
+ onFocus?: React.FocusEventHandler<HTMLTextAreaElement>;
15
+ onBlur?: React.FocusEventHandler<FormControlElement>;
13
16
  /** placeholder text displayed when TextArea is empty */
14
17
  placeholder?: string;
15
18
  /** set readonly to true if TextArea can not be edited */
16
19
  readonly?: boolean;
20
+ /** set disabled to true if TextArea is disabled */
21
+ disabled?: boolean;
17
22
  /** specifies the visible number of lines in the TextArea */
18
23
  rows?: number;
19
24
  /** specifies the visible width of the TextArea */
20
25
  cols?: number;
21
26
  /** set this to true to focus the TextArea when page loads */
22
- autofocus?: boolean;
27
+ autoFocus?: boolean;
23
28
  /** id that will be used in the data-testid attribute on the TextArea */
24
29
  testId?: string;
25
30
  /** value of the TextArea */
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
- import { TextFieldProps } from './TextField.types';
2
+ import { InputLengthStyleProps, TextFieldProps } from './TextField.types';
3
3
  import '../styles.css';
4
4
  /**
5
5
  * Textfield.
6
6
  */
7
- export declare const TextField: React.FunctionComponent<TextFieldProps>;
7
+ export declare const TextField: React.FunctionComponent<TextFieldProps & InputLengthStyleProps>;
@@ -1,6 +1,7 @@
1
1
  import { FormControlElement, InputGroupPlacement } from '../types';
2
2
  export interface TextFieldProps {
3
3
  readonly?: boolean;
4
+ disabled?: boolean;
4
5
  onChange?: React.ChangeEventHandler<FormControlElement>;
5
6
  onKeyUp?: React.KeyboardEventHandler<FormControlElement>;
6
7
  onKeyDown?: React.KeyboardEventHandler<FormControlElement>;
@@ -12,7 +13,7 @@ export interface TextFieldProps {
12
13
  value?: string | string[] | number;
13
14
  placeholder?: string;
14
15
  extraClassNames?: string;
15
- type?: 'text' | 'password' | 'number';
16
+ type?: 'text' | 'password' | 'number' | 'email';
16
17
  testId?: string;
17
18
  ref?: any;
18
19
  inputGroup?: InputGroupPlacement;
@@ -29,3 +30,7 @@ export interface DimensionStyle {
29
30
  width?: string;
30
31
  height?: string;
31
32
  }
33
+ export interface InputLengthStyleProps {
34
+ maxLength?: number;
35
+ minLength?: number;
36
+ }
package/dist/index.esm.js CHANGED
@@ -4675,11 +4675,11 @@ const borderColorClasses$2 = [
4675
4675
  'active:tw-border-sq-color-dark',
4676
4676
  ].join(' ');
4677
4677
  const baseClasses$3 = 'tw-h-inputs tw-leading-normal tw-outline-none tw-py-1 tw-px-3' +
4678
- ' disabled:tw-pointer-events-none' +
4678
+ ' disabled:tw-pointer-events-none disabled:tw-bg-sq-light-gray disabled:dark:tw-bg-sq-dark-disabled-gray' +
4679
4679
  ' disabled:tw-cursor-not-allowed tw-p-1 tw-border-solid tw-border tw-placeholder-gray-400' +
4680
4680
  ' dark:tw-placeholder-sq-dark-text-lighter specTextField';
4681
- const darkTheme$1 = 'dark:tw-bg-sq-dark-background dark:tw-text-sq-dark-text';
4682
- const lightTheme$1 = 'tw-text-sq-text-color';
4681
+ const darkTheme$1 = 'dark:tw-bg-sq-dark-background dark:tw-text-sq-dark-text disabled:dark:tw-text-sq-dark-text-lighter';
4682
+ const lightTheme$1 = 'tw-text-sq-text-color disabled:tw-text-sq-darkish-gray';
4683
4683
  const sizeClasses = {
4684
4684
  sm: 'tw-text-sm',
4685
4685
  lg: 'tw-text-xl',
@@ -4688,7 +4688,7 @@ const sizeClasses = {
4688
4688
  * Textfield.
4689
4689
  */
4690
4690
  const TextField = React__default.forwardRef((props, ref) => {
4691
- const { readonly = false, onChange, onKeyUp, onFocus, onBlur, onKeyDown, id, name, size = 'sm', value, placeholder, extraClassNames, testId, type = 'text', inputGroup, step, showError, errorText, required = false, autoComplete = 'off', inputWidth = undefined, inputHeight = undefined, } = props;
4691
+ const { readonly = false, disabled = false, onChange, onKeyUp, onFocus, onBlur, onKeyDown, id, name, size = 'sm', value, placeholder, extraClassNames, testId, type = 'text', inputGroup, step, showError, errorText, maxLength, minLength, required = false, autoComplete = 'off', inputWidth = undefined, inputHeight = undefined, autoFocus = false, } = props;
4692
4692
  const internalRef = useRef(null);
4693
4693
  const [cursor, setCursor] = useState(null);
4694
4694
  const setAllRefs = (receivedRef) => {
@@ -4698,7 +4698,7 @@ const TextField = React__default.forwardRef((props, ref) => {
4698
4698
  };
4699
4699
  useEffect(() => {
4700
4700
  const input = internalRef.current;
4701
- if (input && type !== 'number')
4701
+ if (input && type !== 'number' && type !== 'email')
4702
4702
  input.setSelectionRange(cursor, cursor);
4703
4703
  }, [ref, cursor, value]);
4704
4704
  const handleChange = (e) => {
@@ -4724,13 +4724,18 @@ const TextField = React__default.forwardRef((props, ref) => {
4724
4724
  borderRadius = 'tw-rounded-r-sm tw-border-l-0 focus:tw-border-l active:tw-border-l';
4725
4725
  }
4726
4726
  const appliedClasses = `${baseClasses$3} ${sizeClasses[size]} ${extraClassNames} ${lightTheme$1} ${darkTheme$1} ${borderRadius} ${showError ? errorClasses$2 : borderColorClasses$2} `;
4727
- const styleProp = setValidInputDimension(inputWidth, inputHeight)
4727
+ const inputProp = setValidInputDimension(inputWidth, inputHeight)
4728
4728
  ? {
4729
4729
  style: setValidInputDimension(inputWidth, inputHeight),
4730
4730
  }
4731
4731
  : {};
4732
+ const inputLenghtProp = {};
4733
+ if (maxLength)
4734
+ inputLenghtProp.maxLength = maxLength;
4735
+ if (minLength)
4736
+ inputLenghtProp.minLength = minLength;
4732
4737
  return (React__default.createElement(React__default.Fragment, null,
4733
- React__default.createElement("input", { ref: setAllRefs, "data-testid": testId, name: name, id: id, type: type, value: value, className: appliedClasses, placeholder: placeholder, disabled: readonly, autoComplete: autoComplete, onChange: handleChange, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown, onKeyUp: onKeyUp, step: step, required: required, ...styleProp }),
4738
+ React__default.createElement("input", { ref: setAllRefs, "data-testid": testId, name: name, id: id, type: type, value: value, className: appliedClasses, placeholder: placeholder, disabled: disabled, readOnly: readonly, autoComplete: autoComplete, onChange: handleChange, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown, onKeyUp: onKeyUp, step: step, required: required, autoFocus: autoFocus, ...inputLenghtProp, ...inputProp }),
4734
4739
  errorText && showError && React__default.createElement("div", { className: "tw-text-sq-danger-color tw-text-xs tw-mt-1" }, errorText)));
4735
4740
  });
4736
4741
 
@@ -4758,9 +4763,11 @@ const Checkbox = (props) => {
4758
4763
  };
4759
4764
 
4760
4765
  const baseClasses$1 = 'tw-leading-normal tw-outline-none tw-py-1 tw-px-3 tw-rounded-sm' +
4766
+ ' disabled:tw-pointer-events-none disabled:tw-bg-sq-light-gray disabled:dark:tw-bg-sq-dark-disabled-gray' +
4761
4767
  ' disabled:tw-cursor-not-allowed tw-p-1 tw-border-solid tw-border tw-text-sm';
4762
- const darkTheme = 'dark:tw-bg-sq-dark-background dark:tw-text-sq-dark-text ' + 'dark:tw-placeholder-sq-dark-text-lighter';
4763
- const lightTheme = 'tw-text-sq-text-color tw-placeholder-gray-400';
4768
+ const darkTheme = 'dark:tw-bg-sq-dark-background dark:tw-text-sq-dark-text ' +
4769
+ 'dark:tw-placeholder-sq-dark-text-lighter disabled:dark:tw-text-sq-dark-text-lighter';
4770
+ const lightTheme = 'tw-text-sq-text-color tw-placeholder-gray-400 disabled:tw-text-sq-darkish-gray';
4764
4771
  const errorClasses$1 = 'tw-border-sq-danger-color';
4765
4772
  const borderColorClasses$1 = [
4766
4773
  'tw-border-sq-disabled-gray',
@@ -4773,9 +4780,9 @@ const borderColorClasses$1 = [
4773
4780
  /**
4774
4781
  * TextArea.
4775
4782
  */
4776
- const TextArea = ({ readonly = false, onChange, onKeyUp, id, name, rows = 3, cols = undefined, value, placeholder, extraClassNames, testId, autofocus = false, showError, }) => {
4783
+ const TextArea = ({ readonly = false, disabled = false, onChange, onKeyUp, onFocus, onBlur, onKeyDown, id, name, rows = 3, cols = undefined, value, placeholder, showError, extraClassNames, testId, autoFocus = false, }) => {
4777
4784
  const appliedClasses = `${baseClasses$1} ${extraClassNames} ${lightTheme} ${darkTheme} ${showError ? errorClasses$1 : borderColorClasses$1}`;
4778
- return (React__default.createElement("textarea", { "data-testid": testId, name: name, id: id, value: value, className: appliedClasses, placeholder: placeholder, disabled: readonly, onChange: onChange, onKeyUp: onKeyUp, rows: rows, cols: cols, autoFocus: autofocus }));
4785
+ return (React__default.createElement("textarea", { "data-testid": testId, name: name, id: id, value: value, className: appliedClasses, placeholder: placeholder, disabled: disabled, readOnly: readonly, onChange: onChange, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown, onKeyUp: onKeyUp, rows: rows, cols: cols, autoFocus: autoFocus }));
4779
4786
  };
4780
4787
 
4781
4788
  /**