@xqmsg/ui-core 0.26.2 → 0.28.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.
@@ -6,6 +6,7 @@ export interface BannerProps {
6
6
  buttonText?: string;
7
7
  onClick?: () => void;
8
8
  type?: 'condensed' | 'expanded';
9
+ centered?: boolean;
9
10
  }
10
11
  /**
11
12
  * A functional React component utilized to render the `Banner` component
@@ -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,18 +7,18 @@ 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';
14
- sortValue: number;
14
+ sortValue?: number;
15
15
  };
16
16
  export interface ValidationProps {
17
17
  isRequired: boolean;
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;
@@ -202,7 +202,9 @@ var Banner = function Banner(_ref) {
202
202
  buttonText = _ref.buttonText,
203
203
  onClick = _ref.onClick,
204
204
  _ref$type = _ref.type,
205
- type = _ref$type === void 0 ? 'expanded' : _ref$type;
205
+ type = _ref$type === void 0 ? 'expanded' : _ref$type,
206
+ _ref$centered = _ref.centered,
207
+ centered = _ref$centered === void 0 ? false : _ref$centered;
206
208
  var Icon = React.useMemo(function () {
207
209
  switch (variant) {
208
210
  case 'error':
@@ -227,16 +229,20 @@ var Banner = function Banner(_ref) {
227
229
  }, [variant]);
228
230
  return /*#__PURE__*/React__default.createElement(react.Alert, {
229
231
  variant: variant,
230
- borderRadius: "4px"
232
+ borderRadius: "4px",
233
+ justifyContent: centered ? 'center' : undefined
231
234
  }, /*#__PURE__*/React__default.createElement(react.AlertDescription, null, /*#__PURE__*/React__default.createElement(react.Flex, {
232
- flexDirection: type === 'condensed' ? 'row' : 'column',
233
- alignItems: type === 'condensed' ? 'center' : '',
235
+ flexDirection: centered || type === 'condensed' ? 'row' : 'column',
236
+ alignItems: centered || type === 'condensed' ? 'center' : '',
237
+ justifyContent: centered ? 'center' : undefined,
234
238
  minHeight: "26px"
235
239
  }, /*#__PURE__*/React__default.createElement(react.Box, {
236
- pr: "8px"
240
+ pr: "8px",
241
+ pt: !centered && type !== 'condensed' ? '8px' : 0
237
242
  }, Icon), /*#__PURE__*/React__default.createElement(react.Box, {
238
- flexGrow: "1",
239
- pt: type === 'condensed' ? 0 : '8px'
243
+ flexGrow: centered ? undefined : '1',
244
+ pt: !centered && type !== 'condensed' ? '8px' : 0,
245
+ textAlign: centered ? 'center' : 'left'
240
246
  }, message), onClick && buttonText && /*#__PURE__*/React__default.createElement(react.Flex, {
241
247
  ml: type === 'condensed' ? 'auto' : '',
242
248
  pt: type === 'condensed' ? 0 : '8px',
@@ -1471,7 +1477,8 @@ var StackedMultiSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1471
1477
  });
1472
1478
  setLocalOptions(function (prevLocalOptions) {
1473
1479
  return [].concat(prevLocalOptions, [option]).sort(function (a, b) {
1474
- return a.sortValue - b.sortValue;
1480
+ var _a$sortValue, _b$sortValue;
1481
+ return ((_a$sortValue = a.sortValue) != null ? _a$sortValue : 0) - ((_b$sortValue = b.sortValue) != null ? _b$sortValue : 0);
1475
1482
  });
1476
1483
  });
1477
1484
  setLocalValues(function (prevLocalValues) {
@@ -1638,6 +1645,69 @@ var StackedMultiSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1638
1645
  })));
1639
1646
  });
1640
1647
 
1648
+ /**
1649
+ * A functional React component that renders Chakra UI's `NumberInput` wrapped
1650
+ * in an `InputGroup`, following the same pattern as `StackedInput`.
1651
+ */
1652
+ var StackedNumberInput = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
1653
+ var name = _ref.name,
1654
+ id = _ref.id,
1655
+ placeholder = _ref.placeholder,
1656
+ isRequired = _ref.isRequired,
1657
+ isInvalid = _ref.isInvalid,
1658
+ disabled = _ref.disabled,
1659
+ value = _ref.value,
1660
+ defaultValue = _ref.defaultValue,
1661
+ min = _ref.min,
1662
+ max = _ref.max,
1663
+ _ref$step = _ref.step,
1664
+ step = _ref$step === void 0 ? 1 : _ref$step,
1665
+ _ref$precision = _ref.precision,
1666
+ precision = _ref$precision === void 0 ? 0 : _ref$precision,
1667
+ _ref$showStepper = _ref.showStepper,
1668
+ showStepper = _ref$showStepper === void 0 ? false : _ref$showStepper,
1669
+ variant = _ref.variant,
1670
+ className = _ref.className,
1671
+ label = _ref.label,
1672
+ leftElement = _ref.leftElement,
1673
+ rightElement = _ref.rightElement,
1674
+ _onChange = _ref.onChange,
1675
+ onBlur = _ref.onBlur;
1676
+ var isMobile = variant === 'mobile';
1677
+ var resolvedPlaceholder = isMobile && label ? label : placeholder;
1678
+ var inputValue = typeof value === 'string' || typeof value === 'number' ? value : undefined;
1679
+ var normalizedValue = precision === 0 && inputValue !== undefined && inputValue !== '' ? Number.isNaN(Number(inputValue)) ? inputValue : String(Math.round(Number(inputValue))) : inputValue;
1680
+ return /*#__PURE__*/React__default.createElement(react.InputGroup, null, leftElement && leftElement, label && !isMobile && label, /*#__PURE__*/React__default.createElement(react.NumberInput, {
1681
+ id: id,
1682
+ name: name,
1683
+ isRequired: isRequired,
1684
+ isInvalid: isInvalid,
1685
+ isDisabled: disabled,
1686
+ value: normalizedValue,
1687
+ defaultValue: defaultValue,
1688
+ min: min,
1689
+ max: max,
1690
+ step: step,
1691
+ precision: precision,
1692
+ onChange: function onChange(_, valueAsNumber) {
1693
+ return _onChange == null ? void 0 : _onChange({
1694
+ target: {
1695
+ name: name,
1696
+ value: Number.isNaN(valueAsNumber) ? '' : precision === 0 ? String(Math.round(valueAsNumber)) : String(valueAsNumber)
1697
+ }
1698
+ });
1699
+ },
1700
+ className: className,
1701
+ variant: variant === 'mobile' ? 'mobile' : 'default',
1702
+ width: "100%"
1703
+ }, /*#__PURE__*/React__default.createElement(react.NumberInputField, {
1704
+ ref: ref,
1705
+ placeholder: resolvedPlaceholder,
1706
+ onBlur: onBlur
1707
+ }), showStepper && /*#__PURE__*/React__default.createElement(react.NumberInputStepper, null, /*#__PURE__*/React__default.createElement(react.NumberIncrementStepper, null), /*#__PURE__*/React__default.createElement(react.NumberDecrementStepper, null))), rightElement && rightElement);
1708
+ });
1709
+ StackedNumberInput.displayName = 'StackedNumberInput';
1710
+
1641
1711
  /**
1642
1712
  * A functional React component utilized to render the `StackedPilledInput` component.
1643
1713
  */
@@ -2058,7 +2128,11 @@ function Input(_ref) {
2058
2128
  truncatePillLength = _ref.truncatePillLength,
2059
2129
  searchable = _ref.searchable,
2060
2130
  _ref$overflowMode = _ref.overflowMode,
2061
- overflowMode = _ref$overflowMode === void 0 ? 'scroll' : _ref$overflowMode;
2131
+ overflowMode = _ref$overflowMode === void 0 ? 'scroll' : _ref$overflowMode,
2132
+ min = _ref.min,
2133
+ max = _ref.max,
2134
+ step = _ref.step,
2135
+ precision = _ref.precision;
2062
2136
  function selectedInputField(onChange, onBlur, ref, value) {
2063
2137
  switch (inputType) {
2064
2138
  case 'text':
@@ -2082,6 +2156,31 @@ function Input(_ref) {
2082
2156
  variant: variant,
2083
2157
  label: label
2084
2158
  });
2159
+ case 'number':
2160
+ return /*#__PURE__*/React__default.createElement(StackedNumberInput, {
2161
+ className: "input-" + inputType + " " + (className != null ? className : ''),
2162
+ "aria-label": ariaLabel,
2163
+ name: name,
2164
+ id: name,
2165
+ placeholder: placeholder,
2166
+ maxLength: maxLength,
2167
+ isRequired: isRequired,
2168
+ isInvalid: isInvalid,
2169
+ onChange: onChange,
2170
+ onBlur: onBlur,
2171
+ ref: ref,
2172
+ rightElement: rightElement,
2173
+ leftElement: leftElement,
2174
+ disabled: disabled,
2175
+ defaultValue: defaultValue,
2176
+ value: value,
2177
+ variant: variant,
2178
+ label: label,
2179
+ min: min,
2180
+ max: max,
2181
+ step: step,
2182
+ precision: precision
2183
+ });
2085
2184
  case 'radio':
2086
2185
  return /*#__PURE__*/React__default.createElement(StackedRadioGroup, {
2087
2186
  className: "input-" + inputType + " " + (className != null ? className : ''),
@@ -5048,6 +5147,7 @@ var customXQChakraTheme = /*#__PURE__*/react.extendTheme( /*#__PURE__*/_extends$
5048
5147
  FormError: FormError,
5049
5148
  FormLabel: FormLabel,
5050
5149
  Input: Input$1,
5150
+ NumberInput: Input$1,
5051
5151
  Link: Link$1,
5052
5152
  Menu: Menu$1,
5053
5153
  Modal: Modal$1,