@seeqdev/qomponents 0.0.96 → 0.0.97

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.
@@ -25,6 +25,8 @@ export interface TextFieldProps {
25
25
  autoFocus?: boolean;
26
26
  inputWidth?: number;
27
27
  inputHeight?: number;
28
+ min?: number;
29
+ max?: number;
28
30
  }
29
31
  export interface DimensionStyle {
30
32
  width?: string;
package/dist/index.esm.js CHANGED
@@ -4688,7 +4688,7 @@ const sizeClasses = {
4688
4688
  * Textfield.
4689
4689
  */
4690
4690
  const TextField = React__default.forwardRef((props, ref) => {
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;
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, min, max, 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) => {
@@ -4723,7 +4723,11 @@ const TextField = React__default.forwardRef((props, ref) => {
4723
4723
  else if (inputGroup === 'right') {
4724
4724
  borderRadius = 'tw-rounded-r-sm tw-border-l-0 focus:tw-border-l active:tw-border-l';
4725
4725
  }
4726
- const appliedClasses = `${baseClasses$3} ${sizeClasses[size]} ${extraClassNames} ${lightTheme$1} ${darkTheme$1} ${borderRadius} ${showError ? errorClasses$2 : borderColorClasses$2} `;
4726
+ let hasError = showError;
4727
+ if ((min && Number(value) < min) || (max && Number(value) > max)) {
4728
+ hasError = true;
4729
+ }
4730
+ const appliedClasses = `${baseClasses$3} ${sizeClasses[size]} ${extraClassNames} ${lightTheme$1} ${darkTheme$1} ${borderRadius} ${hasError ? errorClasses$2 : borderColorClasses$2} `;
4727
4731
  const inputProp = setValidInputDimension(inputWidth, inputHeight)
4728
4732
  ? {
4729
4733
  style: setValidInputDimension(inputWidth, inputHeight),
@@ -4735,7 +4739,7 @@ const TextField = React__default.forwardRef((props, ref) => {
4735
4739
  if (minLength)
4736
4740
  inputLenghtProp.minLength = minLength;
4737
4741
  return (React__default.createElement(React__default.Fragment, null,
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 }),
4742
+ 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, min: min, max: max, ...inputLenghtProp, ...inputProp }),
4739
4743
  errorText && showError && React__default.createElement("div", { className: "tw-text-sq-danger-color tw-text-xs tw-mt-1" }, errorText)));
4740
4744
  });
4741
4745