@xqmsg/ui-core 0.26.1 → 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.
- package/dist/components/input/Input.stories.d.ts +1 -0
- package/dist/components/input/InputTypes.d.ts +2 -2
- package/dist/components/input/StackedNumberInput/StackedNumberInput.d.ts +20 -0
- package/dist/components/input/index.d.ts +10 -2
- package/dist/ui-core.cjs.development.js +96 -2
- package/dist/ui-core.cjs.development.js.map +1 -1
- package/dist/ui-core.cjs.production.min.js +1 -1
- package/dist/ui-core.cjs.production.min.js.map +1 -1
- package/dist/ui-core.esm.js +97 -3
- package/dist/ui-core.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/input/Input.stories.tsx +41 -4
- package/src/components/input/InputTypes.ts +5 -1
- package/src/components/input/StackedInput/StackedInput.tsx +1 -1
- package/src/components/input/StackedNumberInput/StackedNumberInput.tsx +121 -0
- package/src/components/input/index.tsx +43 -3
- package/src/theme/customXQChakraTheme.ts +1 -0
package/dist/ui-core.esm.js
CHANGED
|
@@ -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';
|
|
@@ -812,6 +812,7 @@ var _excluded = ["type", "isRequired", "rightElement", "leftElement", "defaultVa
|
|
|
812
812
|
* A functional React component utilized to render the `StackedInput` component.
|
|
813
813
|
*/
|
|
814
814
|
var StackedInput = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref) {
|
|
815
|
+
var _props$placeholder;
|
|
815
816
|
var _ref2$type = _ref2.type,
|
|
816
817
|
type = _ref2$type === void 0 ? 'text' : _ref2$type,
|
|
817
818
|
isRequired = _ref2.isRequired,
|
|
@@ -824,7 +825,7 @@ var StackedInput = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref)
|
|
|
824
825
|
var isMobile = variant === 'mobile';
|
|
825
826
|
var placeholder = isMobile && label ? label : undefined;
|
|
826
827
|
return /*#__PURE__*/React__default.createElement(InputGroup, null, leftElement && leftElement, label, /*#__PURE__*/React__default.createElement(Input$2, Object.assign({}, props, {
|
|
827
|
-
placeholder: placeholder,
|
|
828
|
+
placeholder: (_props$placeholder = props.placeholder) != null ? _props$placeholder : placeholder,
|
|
828
829
|
type: type,
|
|
829
830
|
isRequired: isRequired,
|
|
830
831
|
ref: _ref,
|
|
@@ -1630,6 +1631,69 @@ var StackedMultiSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
1630
1631
|
})));
|
|
1631
1632
|
});
|
|
1632
1633
|
|
|
1634
|
+
/**
|
|
1635
|
+
* A functional React component that renders Chakra UI's `NumberInput` wrapped
|
|
1636
|
+
* in an `InputGroup`, following the same pattern as `StackedInput`.
|
|
1637
|
+
*/
|
|
1638
|
+
var StackedNumberInput = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
1639
|
+
var name = _ref.name,
|
|
1640
|
+
id = _ref.id,
|
|
1641
|
+
placeholder = _ref.placeholder,
|
|
1642
|
+
isRequired = _ref.isRequired,
|
|
1643
|
+
isInvalid = _ref.isInvalid,
|
|
1644
|
+
disabled = _ref.disabled,
|
|
1645
|
+
value = _ref.value,
|
|
1646
|
+
defaultValue = _ref.defaultValue,
|
|
1647
|
+
min = _ref.min,
|
|
1648
|
+
max = _ref.max,
|
|
1649
|
+
_ref$step = _ref.step,
|
|
1650
|
+
step = _ref$step === void 0 ? 1 : _ref$step,
|
|
1651
|
+
_ref$precision = _ref.precision,
|
|
1652
|
+
precision = _ref$precision === void 0 ? 0 : _ref$precision,
|
|
1653
|
+
_ref$showStepper = _ref.showStepper,
|
|
1654
|
+
showStepper = _ref$showStepper === void 0 ? false : _ref$showStepper,
|
|
1655
|
+
variant = _ref.variant,
|
|
1656
|
+
className = _ref.className,
|
|
1657
|
+
label = _ref.label,
|
|
1658
|
+
leftElement = _ref.leftElement,
|
|
1659
|
+
rightElement = _ref.rightElement,
|
|
1660
|
+
_onChange = _ref.onChange,
|
|
1661
|
+
onBlur = _ref.onBlur;
|
|
1662
|
+
var isMobile = variant === 'mobile';
|
|
1663
|
+
var resolvedPlaceholder = isMobile && label ? label : placeholder;
|
|
1664
|
+
var inputValue = typeof value === 'string' || typeof value === 'number' ? value : undefined;
|
|
1665
|
+
var normalizedValue = precision === 0 && inputValue !== undefined && inputValue !== '' ? Number.isNaN(Number(inputValue)) ? inputValue : String(Math.round(Number(inputValue))) : inputValue;
|
|
1666
|
+
return /*#__PURE__*/React__default.createElement(InputGroup, null, leftElement && leftElement, label && !isMobile && label, /*#__PURE__*/React__default.createElement(NumberInput, {
|
|
1667
|
+
id: id,
|
|
1668
|
+
name: name,
|
|
1669
|
+
isRequired: isRequired,
|
|
1670
|
+
isInvalid: isInvalid,
|
|
1671
|
+
isDisabled: disabled,
|
|
1672
|
+
value: normalizedValue,
|
|
1673
|
+
defaultValue: defaultValue,
|
|
1674
|
+
min: min,
|
|
1675
|
+
max: max,
|
|
1676
|
+
step: step,
|
|
1677
|
+
precision: precision,
|
|
1678
|
+
onChange: function onChange(_, valueAsNumber) {
|
|
1679
|
+
return _onChange == null ? void 0 : _onChange({
|
|
1680
|
+
target: {
|
|
1681
|
+
name: name,
|
|
1682
|
+
value: Number.isNaN(valueAsNumber) ? '' : precision === 0 ? String(Math.round(valueAsNumber)) : String(valueAsNumber)
|
|
1683
|
+
}
|
|
1684
|
+
});
|
|
1685
|
+
},
|
|
1686
|
+
className: className,
|
|
1687
|
+
variant: variant === 'mobile' ? 'mobile' : 'default',
|
|
1688
|
+
width: "100%"
|
|
1689
|
+
}, /*#__PURE__*/React__default.createElement(NumberInputField, {
|
|
1690
|
+
ref: ref,
|
|
1691
|
+
placeholder: resolvedPlaceholder,
|
|
1692
|
+
onBlur: onBlur
|
|
1693
|
+
}), showStepper && /*#__PURE__*/React__default.createElement(NumberInputStepper, null, /*#__PURE__*/React__default.createElement(NumberIncrementStepper, null), /*#__PURE__*/React__default.createElement(NumberDecrementStepper, null))), rightElement && rightElement);
|
|
1694
|
+
});
|
|
1695
|
+
StackedNumberInput.displayName = 'StackedNumberInput';
|
|
1696
|
+
|
|
1633
1697
|
/**
|
|
1634
1698
|
* A functional React component utilized to render the `StackedPilledInput` component.
|
|
1635
1699
|
*/
|
|
@@ -2050,7 +2114,11 @@ function Input(_ref) {
|
|
|
2050
2114
|
truncatePillLength = _ref.truncatePillLength,
|
|
2051
2115
|
searchable = _ref.searchable,
|
|
2052
2116
|
_ref$overflowMode = _ref.overflowMode,
|
|
2053
|
-
overflowMode = _ref$overflowMode === void 0 ? 'scroll' : _ref$overflowMode
|
|
2117
|
+
overflowMode = _ref$overflowMode === void 0 ? 'scroll' : _ref$overflowMode,
|
|
2118
|
+
min = _ref.min,
|
|
2119
|
+
max = _ref.max,
|
|
2120
|
+
step = _ref.step,
|
|
2121
|
+
precision = _ref.precision;
|
|
2054
2122
|
function selectedInputField(onChange, onBlur, ref, value) {
|
|
2055
2123
|
switch (inputType) {
|
|
2056
2124
|
case 'text':
|
|
@@ -2074,6 +2142,31 @@ function Input(_ref) {
|
|
|
2074
2142
|
variant: variant,
|
|
2075
2143
|
label: label
|
|
2076
2144
|
});
|
|
2145
|
+
case 'number':
|
|
2146
|
+
return /*#__PURE__*/React__default.createElement(StackedNumberInput, {
|
|
2147
|
+
className: "input-" + inputType + " " + (className != null ? className : ''),
|
|
2148
|
+
"aria-label": ariaLabel,
|
|
2149
|
+
name: name,
|
|
2150
|
+
id: name,
|
|
2151
|
+
placeholder: placeholder,
|
|
2152
|
+
maxLength: maxLength,
|
|
2153
|
+
isRequired: isRequired,
|
|
2154
|
+
isInvalid: isInvalid,
|
|
2155
|
+
onChange: onChange,
|
|
2156
|
+
onBlur: onBlur,
|
|
2157
|
+
ref: ref,
|
|
2158
|
+
rightElement: rightElement,
|
|
2159
|
+
leftElement: leftElement,
|
|
2160
|
+
disabled: disabled,
|
|
2161
|
+
defaultValue: defaultValue,
|
|
2162
|
+
value: value,
|
|
2163
|
+
variant: variant,
|
|
2164
|
+
label: label,
|
|
2165
|
+
min: min,
|
|
2166
|
+
max: max,
|
|
2167
|
+
step: step,
|
|
2168
|
+
precision: precision
|
|
2169
|
+
});
|
|
2077
2170
|
case 'radio':
|
|
2078
2171
|
return /*#__PURE__*/React__default.createElement(StackedRadioGroup, {
|
|
2079
2172
|
className: "input-" + inputType + " " + (className != null ? className : ''),
|
|
@@ -5040,6 +5133,7 @@ var customXQChakraTheme = /*#__PURE__*/extendTheme( /*#__PURE__*/_extends$6({
|
|
|
5040
5133
|
FormError: FormError,
|
|
5041
5134
|
FormLabel: FormLabel,
|
|
5042
5135
|
Input: Input$1,
|
|
5136
|
+
NumberInput: Input$1,
|
|
5043
5137
|
Link: Link$1,
|
|
5044
5138
|
Menu: Menu$1,
|
|
5045
5139
|
Modal: Modal$1,
|