@xqmsg/ui-core 0.26.2 → 0.27.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.
@@ -8,6 +8,7 @@ interface StoryFormSchema {
8
8
  prop4?: string;
9
9
  prop5?: string;
10
10
  prop6?: boolean;
11
+ prop7?: number;
11
12
  }
12
13
  export default meta;
13
14
  export declare const Default: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, InputProps<StoryFormSchema>>;
@@ -7,7 +7,7 @@ export declare type FieldProps = {
7
7
  isInvalid?: boolean;
8
8
  errorText?: string;
9
9
  };
10
- export declare type InputType = 'text' | 'select' | 'multi-select' | 'pilled-text' | 'textarea' | 'radio' | 'checkbox' | 'switch';
10
+ export declare type InputType = 'text' | 'select' | 'multi-select' | 'pilled-text' | 'textarea' | 'radio' | 'checkbox' | 'switch' | 'number';
11
11
  export declare type FieldOption = {
12
12
  label: string;
13
13
  value: string | 'section_header';
@@ -18,7 +18,7 @@ export interface ValidationProps {
18
18
  isInvalid?: boolean;
19
19
  errorText?: string;
20
20
  }
21
- export interface InputFieldProps extends Omit<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, 'color' | 'height' | 'width' | 'size' | 'ref' | 'onChange' | 'defaultValue'>, FieldProps, Partial<InputProps> {
21
+ export interface InputFieldProps extends Omit<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, 'color' | 'height' | 'width' | 'size' | 'ref' | 'onChange' | 'defaultValue' | 'min' | 'max' | 'step'>, FieldProps, Partial<InputProps> {
22
22
  }
23
23
  export interface TextareaFieldProps extends Omit<React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, 'color' | 'height' | 'width' | 'size' | 'ref'>, FieldProps, Partial<TextareaProps> {
24
24
  }
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import { InputFieldProps } from '../InputTypes';
3
+ export interface StackedNumberInputProps extends InputFieldProps {
4
+ isRequired?: boolean;
5
+ leftElement?: React.ReactNode;
6
+ rightElement?: React.ReactNode;
7
+ variant?: string;
8
+ label?: string;
9
+ min?: number;
10
+ max?: number;
11
+ step?: number;
12
+ precision?: number;
13
+ showStepper?: boolean;
14
+ }
15
+ /**
16
+ * A functional React component that renders Chakra UI's `NumberInput` wrapped
17
+ * in an `InputGroup`, following the same pattern as `StackedInput`.
18
+ */
19
+ declare const StackedNumberInput: React.ForwardRefExoticComponent<StackedNumberInputProps & React.RefAttributes<HTMLInputElement>>;
20
+ export default StackedNumberInput;
@@ -6,7 +6,7 @@ export interface InputProps<T extends FieldValues = FieldValues> extends Validat
6
6
  name: string;
7
7
  ariaLabel: string;
8
8
  placeholder?: string;
9
- defaultValue?: string;
9
+ defaultValue?: string | number;
10
10
  label?: string;
11
11
  className?: string;
12
12
  options?: FieldOption[];
@@ -28,9 +28,17 @@ export interface InputProps<T extends FieldValues = FieldValues> extends Validat
28
28
  truncatePillLength?: number;
29
29
  searchable?: boolean;
30
30
  overflowMode?: 'scroll' | 'wrap';
31
+ /** Minimum value (numberInput only) */
32
+ min?: number;
33
+ /** Maximum value (numberInput only) */
34
+ max?: number;
35
+ /** Increment/decrement step (numberInput only) */
36
+ step?: number;
37
+ /** Number of decimal places (numberInput only) */
38
+ precision?: number;
31
39
  }
32
40
  /**
33
41
  * A functional React component utilized to render the `Input` component. Utilizes a switch statement
34
42
  * to render the correct input based on the `inputType`.
35
43
  */
36
- export declare function Input<T extends FieldValues>({ inputType, label, ariaLabel, className, placeholder, name, helperText, options, tooltipText, isInvalid, errorText, isRequired, maxLength, defaultValue, fullOptions, control, disabled, rightElement, leftElement, variant, onChange, setValue, setError, clearErrors, separators, loadingOptions, truncatePillLength, searchable, overflowMode, }: InputProps<T>): React.JSX.Element;
44
+ export declare function Input<T extends FieldValues>({ inputType, label, ariaLabel, className, placeholder, name, helperText, options, tooltipText, isInvalid, errorText, isRequired, maxLength, defaultValue, fullOptions, control, disabled, rightElement, leftElement, variant, onChange, setValue, setError, clearErrors, separators, loadingOptions, truncatePillLength, searchable, overflowMode, min, max, step, precision, }: InputProps<T>): React.JSX.Element;
@@ -1638,6 +1638,69 @@ var StackedMultiSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1638
1638
  })));
1639
1639
  });
1640
1640
 
1641
+ /**
1642
+ * A functional React component that renders Chakra UI's `NumberInput` wrapped
1643
+ * in an `InputGroup`, following the same pattern as `StackedInput`.
1644
+ */
1645
+ var StackedNumberInput = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
1646
+ var name = _ref.name,
1647
+ id = _ref.id,
1648
+ placeholder = _ref.placeholder,
1649
+ isRequired = _ref.isRequired,
1650
+ isInvalid = _ref.isInvalid,
1651
+ disabled = _ref.disabled,
1652
+ value = _ref.value,
1653
+ defaultValue = _ref.defaultValue,
1654
+ min = _ref.min,
1655
+ max = _ref.max,
1656
+ _ref$step = _ref.step,
1657
+ step = _ref$step === void 0 ? 1 : _ref$step,
1658
+ _ref$precision = _ref.precision,
1659
+ precision = _ref$precision === void 0 ? 0 : _ref$precision,
1660
+ _ref$showStepper = _ref.showStepper,
1661
+ showStepper = _ref$showStepper === void 0 ? false : _ref$showStepper,
1662
+ variant = _ref.variant,
1663
+ className = _ref.className,
1664
+ label = _ref.label,
1665
+ leftElement = _ref.leftElement,
1666
+ rightElement = _ref.rightElement,
1667
+ _onChange = _ref.onChange,
1668
+ onBlur = _ref.onBlur;
1669
+ var isMobile = variant === 'mobile';
1670
+ var resolvedPlaceholder = isMobile && label ? label : placeholder;
1671
+ var inputValue = typeof value === 'string' || typeof value === 'number' ? value : undefined;
1672
+ var normalizedValue = precision === 0 && inputValue !== undefined && inputValue !== '' ? Number.isNaN(Number(inputValue)) ? inputValue : String(Math.round(Number(inputValue))) : inputValue;
1673
+ return /*#__PURE__*/React__default.createElement(react.InputGroup, null, leftElement && leftElement, label && !isMobile && label, /*#__PURE__*/React__default.createElement(react.NumberInput, {
1674
+ id: id,
1675
+ name: name,
1676
+ isRequired: isRequired,
1677
+ isInvalid: isInvalid,
1678
+ isDisabled: disabled,
1679
+ value: normalizedValue,
1680
+ defaultValue: defaultValue,
1681
+ min: min,
1682
+ max: max,
1683
+ step: step,
1684
+ precision: precision,
1685
+ onChange: function onChange(_, valueAsNumber) {
1686
+ return _onChange == null ? void 0 : _onChange({
1687
+ target: {
1688
+ name: name,
1689
+ value: Number.isNaN(valueAsNumber) ? '' : precision === 0 ? String(Math.round(valueAsNumber)) : String(valueAsNumber)
1690
+ }
1691
+ });
1692
+ },
1693
+ className: className,
1694
+ variant: variant === 'mobile' ? 'mobile' : 'default',
1695
+ width: "100%"
1696
+ }, /*#__PURE__*/React__default.createElement(react.NumberInputField, {
1697
+ ref: ref,
1698
+ placeholder: resolvedPlaceholder,
1699
+ onBlur: onBlur
1700
+ }), showStepper && /*#__PURE__*/React__default.createElement(react.NumberInputStepper, null, /*#__PURE__*/React__default.createElement(react.NumberIncrementStepper, null), /*#__PURE__*/React__default.createElement(react.NumberDecrementStepper, null))), rightElement && rightElement);
1701
+ });
1702
+ StackedNumberInput.displayName = 'StackedNumberInput';
1703
+
1641
1704
  /**
1642
1705
  * A functional React component utilized to render the `StackedPilledInput` component.
1643
1706
  */
@@ -2058,7 +2121,11 @@ function Input(_ref) {
2058
2121
  truncatePillLength = _ref.truncatePillLength,
2059
2122
  searchable = _ref.searchable,
2060
2123
  _ref$overflowMode = _ref.overflowMode,
2061
- overflowMode = _ref$overflowMode === void 0 ? 'scroll' : _ref$overflowMode;
2124
+ overflowMode = _ref$overflowMode === void 0 ? 'scroll' : _ref$overflowMode,
2125
+ min = _ref.min,
2126
+ max = _ref.max,
2127
+ step = _ref.step,
2128
+ precision = _ref.precision;
2062
2129
  function selectedInputField(onChange, onBlur, ref, value) {
2063
2130
  switch (inputType) {
2064
2131
  case 'text':
@@ -2082,6 +2149,31 @@ function Input(_ref) {
2082
2149
  variant: variant,
2083
2150
  label: label
2084
2151
  });
2152
+ case 'number':
2153
+ return /*#__PURE__*/React__default.createElement(StackedNumberInput, {
2154
+ className: "input-" + inputType + " " + (className != null ? className : ''),
2155
+ "aria-label": ariaLabel,
2156
+ name: name,
2157
+ id: name,
2158
+ placeholder: placeholder,
2159
+ maxLength: maxLength,
2160
+ isRequired: isRequired,
2161
+ isInvalid: isInvalid,
2162
+ onChange: onChange,
2163
+ onBlur: onBlur,
2164
+ ref: ref,
2165
+ rightElement: rightElement,
2166
+ leftElement: leftElement,
2167
+ disabled: disabled,
2168
+ defaultValue: defaultValue,
2169
+ value: value,
2170
+ variant: variant,
2171
+ label: label,
2172
+ min: min,
2173
+ max: max,
2174
+ step: step,
2175
+ precision: precision
2176
+ });
2085
2177
  case 'radio':
2086
2178
  return /*#__PURE__*/React__default.createElement(StackedRadioGroup, {
2087
2179
  className: "input-" + inputType + " " + (className != null ? className : ''),
@@ -5048,6 +5140,7 @@ var customXQChakraTheme = /*#__PURE__*/react.extendTheme( /*#__PURE__*/_extends$
5048
5140
  FormError: FormError,
5049
5141
  FormLabel: FormLabel,
5050
5142
  Input: Input$1,
5143
+ NumberInput: Input$1,
5051
5144
  Link: Link$1,
5052
5145
  Menu: Menu$1,
5053
5146
  Modal: Modal$1,