@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.
@@ -1,5 +1,5 @@
1
1
  import React__default, { memo, forwardRef, createElement, useMemo, useCallback, Children, useEffect, useRef, useState } from 'react';
2
- import { Box, Button as Button$2, Alert as Alert$1, AlertDescription, Flex, Text as Text$2, Spinner, Checkbox as Checkbox$1, InputGroup, Input as Input$2, RadioGroup, Radio, InputRightElement, Textarea as Textarea$1, useOutsideClick, Switch as Switch$1, FormLabel as FormLabel$1, Popover as Popover$1, PopoverTrigger, PopoverContent, PopoverArrow, PopoverBody, FormControl, FormErrorMessage, FormHelperText, SimpleGrid, Image as Image$1, Select as Select$1, useMediaQuery, Grid, GridItem, IconButton, Collapse, Modal as Modal$2, ModalOverlay, ModalContent, ModalHeader, ModalBody, ModalFooter, Link as Link$2, Table as Table$1, Tbody, Tr, Td, TableContainer, Thead, Th, Tabs as Tabs$1, TabList, Tab, createMultiStyleConfigHelpers, defineStyle as defineStyle$1, extendTheme, useToast as useToast$1 } from '@chakra-ui/react';
2
+ import { Box, Button as Button$2, Alert as Alert$1, AlertDescription, Flex, Text as Text$2, Spinner, Checkbox as Checkbox$1, InputGroup, Input as Input$2, RadioGroup, Radio, InputRightElement, Textarea as Textarea$1, NumberInput, NumberInputField, NumberInputStepper, NumberIncrementStepper, NumberDecrementStepper, useOutsideClick, Switch as Switch$1, FormLabel as FormLabel$1, Popover as Popover$1, PopoverTrigger, PopoverContent, PopoverArrow, PopoverBody, FormControl, FormErrorMessage, FormHelperText, SimpleGrid, Image as Image$1, Select as Select$1, useMediaQuery, Grid, GridItem, IconButton, Collapse, Modal as Modal$2, ModalOverlay, ModalContent, ModalHeader, ModalBody, ModalFooter, Link as Link$2, Table as Table$1, Tbody, Tr, Td, TableContainer, Thead, Th, Tabs as Tabs$1, TabList, Tab, createMultiStyleConfigHelpers, defineStyle as defineStyle$1, extendTheme, useToast as useToast$1 } from '@chakra-ui/react';
3
3
  import { FormProvider, useWatch, Controller } from 'react-hook-form';
4
4
  import { truncate } from 'lodash-es';
5
5
  import { QuestionIcon, CloseIcon, HamburgerIcon } from '@chakra-ui/icons';
@@ -195,7 +195,9 @@ var Banner = function Banner(_ref) {
195
195
  buttonText = _ref.buttonText,
196
196
  onClick = _ref.onClick,
197
197
  _ref$type = _ref.type,
198
- type = _ref$type === void 0 ? 'expanded' : _ref$type;
198
+ type = _ref$type === void 0 ? 'expanded' : _ref$type,
199
+ _ref$centered = _ref.centered,
200
+ centered = _ref$centered === void 0 ? false : _ref$centered;
199
201
  var Icon = useMemo(function () {
200
202
  switch (variant) {
201
203
  case 'error':
@@ -220,16 +222,20 @@ var Banner = function Banner(_ref) {
220
222
  }, [variant]);
221
223
  return /*#__PURE__*/React__default.createElement(Alert$1, {
222
224
  variant: variant,
223
- borderRadius: "4px"
225
+ borderRadius: "4px",
226
+ justifyContent: centered ? 'center' : undefined
224
227
  }, /*#__PURE__*/React__default.createElement(AlertDescription, null, /*#__PURE__*/React__default.createElement(Flex, {
225
- flexDirection: type === 'condensed' ? 'row' : 'column',
226
- alignItems: type === 'condensed' ? 'center' : '',
228
+ flexDirection: centered || type === 'condensed' ? 'row' : 'column',
229
+ alignItems: centered || type === 'condensed' ? 'center' : '',
230
+ justifyContent: centered ? 'center' : undefined,
227
231
  minHeight: "26px"
228
232
  }, /*#__PURE__*/React__default.createElement(Box, {
229
- pr: "8px"
233
+ pr: "8px",
234
+ pt: !centered && type !== 'condensed' ? '8px' : 0
230
235
  }, Icon), /*#__PURE__*/React__default.createElement(Box, {
231
- flexGrow: "1",
232
- pt: type === 'condensed' ? 0 : '8px'
236
+ flexGrow: centered ? undefined : '1',
237
+ pt: !centered && type !== 'condensed' ? '8px' : 0,
238
+ textAlign: centered ? 'center' : 'left'
233
239
  }, message), onClick && buttonText && /*#__PURE__*/React__default.createElement(Flex, {
234
240
  ml: type === 'condensed' ? 'auto' : '',
235
241
  pt: type === 'condensed' ? 0 : '8px',
@@ -1464,7 +1470,8 @@ var StackedMultiSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1464
1470
  });
1465
1471
  setLocalOptions(function (prevLocalOptions) {
1466
1472
  return [].concat(prevLocalOptions, [option]).sort(function (a, b) {
1467
- return a.sortValue - b.sortValue;
1473
+ var _a$sortValue, _b$sortValue;
1474
+ return ((_a$sortValue = a.sortValue) != null ? _a$sortValue : 0) - ((_b$sortValue = b.sortValue) != null ? _b$sortValue : 0);
1468
1475
  });
1469
1476
  });
1470
1477
  setLocalValues(function (prevLocalValues) {
@@ -1631,6 +1638,69 @@ var StackedMultiSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1631
1638
  })));
1632
1639
  });
1633
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(InputGroup, null, leftElement && leftElement, label && !isMobile && label, /*#__PURE__*/React__default.createElement(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(NumberInputField, {
1697
+ ref: ref,
1698
+ placeholder: resolvedPlaceholder,
1699
+ onBlur: onBlur
1700
+ }), showStepper && /*#__PURE__*/React__default.createElement(NumberInputStepper, null, /*#__PURE__*/React__default.createElement(NumberIncrementStepper, null), /*#__PURE__*/React__default.createElement(NumberDecrementStepper, null))), rightElement && rightElement);
1701
+ });
1702
+ StackedNumberInput.displayName = 'StackedNumberInput';
1703
+
1634
1704
  /**
1635
1705
  * A functional React component utilized to render the `StackedPilledInput` component.
1636
1706
  */
@@ -2051,7 +2121,11 @@ function Input(_ref) {
2051
2121
  truncatePillLength = _ref.truncatePillLength,
2052
2122
  searchable = _ref.searchable,
2053
2123
  _ref$overflowMode = _ref.overflowMode,
2054
- 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;
2055
2129
  function selectedInputField(onChange, onBlur, ref, value) {
2056
2130
  switch (inputType) {
2057
2131
  case 'text':
@@ -2075,6 +2149,31 @@ function Input(_ref) {
2075
2149
  variant: variant,
2076
2150
  label: label
2077
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
+ });
2078
2177
  case 'radio':
2079
2178
  return /*#__PURE__*/React__default.createElement(StackedRadioGroup, {
2080
2179
  className: "input-" + inputType + " " + (className != null ? className : ''),
@@ -5041,6 +5140,7 @@ var customXQChakraTheme = /*#__PURE__*/extendTheme( /*#__PURE__*/_extends$6({
5041
5140
  FormError: FormError,
5042
5141
  FormLabel: FormLabel,
5043
5142
  Input: Input$1,
5143
+ NumberInput: Input$1,
5044
5144
  Link: Link$1,
5045
5145
  Menu: Menu$1,
5046
5146
  Modal: Modal$1,