@xqmsg/ui-core 0.14.1 → 0.14.2
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/StackedMultiSelect/index.d.ts +4 -1
- package/dist/components/input/StackedPilledInput/index.d.ts +4 -1
- package/dist/components/input/index.d.ts +4 -2
- package/dist/ui-core.cjs.development.js +98 -24
- 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 +101 -27
- package/dist/ui-core.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/form/section/index.tsx +2 -0
- package/src/components/input/Input.stories.tsx +10 -0
- package/src/components/input/StackedMultiSelect/index.tsx +153 -101
- package/src/components/input/StackedPilledInput/index.tsx +231 -191
- package/src/components/input/components/dropdown/index.tsx +7 -2
- package/src/components/input/components/token/assets/svg/close.svg +1 -1
- package/src/components/input/components/token/index.tsx +15 -9
- package/src/components/input/index.tsx +12 -0
package/dist/ui-core.esm.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import React__default, { useMemo, useCallback, useRef, useEffect, useState } from 'react';
|
|
1
|
+
import React__default, { useMemo, useCallback, useRef, useEffect, useState, memo, forwardRef, createElement } from 'react';
|
|
2
2
|
import { Image, Alert as Alert$1, AlertDescription, Box, Flex, Button as Button$2, Text as Text$2, Icon as Icon$1, Spinner, InputGroup, Checkbox, Input as Input$2, RadioGroup, Radio, useOutsideClick, InputRightElement, Textarea as Textarea$1, Switch as Switch$1, FormLabel as FormLabel$1, FormControl, FormErrorMessage, FormHelperText, SimpleGrid, useMediaQuery, Grid, GridItem, IconButton, Collapse, TableContainer, Table as Table$2, Thead, Tr, Th, Tbody, Td, TableCaption, Tabs as Tabs$1, TabList, Tab, extendTheme, ChakraProvider } from '@chakra-ui/react';
|
|
3
3
|
import { FormProvider, useWatch, Controller } from 'react-hook-form';
|
|
4
|
-
import {
|
|
4
|
+
import { truncate } from 'lodash-es';
|
|
5
|
+
import { CloseIcon, HamburgerIcon } from '@chakra-ui/icons';
|
|
5
6
|
import { HiOutlineRefresh } from 'react-icons/hi';
|
|
6
7
|
import { createBreakpoints, transparentize, mode, getColor } from '@chakra-ui/theme-tools';
|
|
7
8
|
import { defineStyle } from '@chakra-ui/system';
|
|
@@ -503,7 +504,8 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
503
504
|
color: colors.label.secondary.light,
|
|
504
505
|
fontSize: "13px",
|
|
505
506
|
fontWeight: "bold",
|
|
506
|
-
px: "8px"
|
|
507
|
+
px: "8px",
|
|
508
|
+
bg: "inherit"
|
|
507
509
|
}, idx > 0 && /*#__PURE__*/React__default.createElement(Box, {
|
|
508
510
|
my: "3px",
|
|
509
511
|
borderTop: "2px solid",
|
|
@@ -523,14 +525,18 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
523
525
|
color: colors.label.primary.dark,
|
|
524
526
|
bg: colors.fill.action,
|
|
525
527
|
borderRadius: '4px'
|
|
526
|
-
}
|
|
528
|
+
},
|
|
529
|
+
bg: "inherit"
|
|
527
530
|
}, option.label));
|
|
528
531
|
});
|
|
529
532
|
}, [onSelectItem, options]);
|
|
530
533
|
return /*#__PURE__*/React__default.createElement(Box, {
|
|
531
534
|
bg: colors.fill.light.quaternary,
|
|
532
|
-
backdropFilter: "
|
|
535
|
+
backdropFilter: "auto",
|
|
536
|
+
backdropBlur: "64px",
|
|
533
537
|
borderRadius: "4px",
|
|
538
|
+
border: "0.25px solid",
|
|
539
|
+
borderColor: colors.fill.light.tertiary,
|
|
534
540
|
mt: "3px",
|
|
535
541
|
maxH: "320px",
|
|
536
542
|
overflowY: "auto",
|
|
@@ -538,7 +544,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
538
544
|
py: "4px",
|
|
539
545
|
position: "absolute",
|
|
540
546
|
width: "100%",
|
|
541
|
-
zIndex:
|
|
547
|
+
zIndex: 100
|
|
542
548
|
}, DropdownContent);
|
|
543
549
|
};
|
|
544
550
|
|
|
@@ -645,7 +651,24 @@ var StackedTextarea = /*#__PURE__*/React__default.forwardRef(function (_ref2, _r
|
|
|
645
651
|
}, props));
|
|
646
652
|
});
|
|
647
653
|
|
|
648
|
-
var
|
|
654
|
+
var _path;
|
|
655
|
+
function _extends$1() { _extends$1 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); }
|
|
656
|
+
var SvgClose = function SvgClose(props, ref) {
|
|
657
|
+
return /*#__PURE__*/createElement("svg", _extends$1({
|
|
658
|
+
viewBox: "0 0 56 56",
|
|
659
|
+
fill: "none",
|
|
660
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
661
|
+
ref: ref
|
|
662
|
+
}, props), _path || (_path = /*#__PURE__*/createElement("path", {
|
|
663
|
+
fillRule: "evenodd",
|
|
664
|
+
clipRule: "evenodd",
|
|
665
|
+
d: "M28 56c15.464 0 28-12.536 28-28S43.463 0 28 0 0 12.536 0 28s12.536 28 28 28Zm-6.02-37.731a2.625 2.625 0 0 0-3.712 3.712L24.288 28l-6.02 6.019a2.625 2.625 0 1 0 3.713 3.712l6.018-6.019 6.02 6.02a2.625 2.625 0 0 0 3.712-3.713L31.71 28l6.02-6.019a2.625 2.625 0 0 0-3.713-3.712L28 24.288l-6.02-6.02Z",
|
|
666
|
+
fill: "#3C3C43",
|
|
667
|
+
fillOpacity: 0.6
|
|
668
|
+
})));
|
|
669
|
+
};
|
|
670
|
+
var ForwardRef = /*#__PURE__*/forwardRef(SvgClose);
|
|
671
|
+
var Memo = /*#__PURE__*/memo(ForwardRef);
|
|
649
672
|
|
|
650
673
|
var Token = function Token(_ref) {
|
|
651
674
|
var label = _ref.label,
|
|
@@ -655,17 +678,23 @@ var Token = function Token(_ref) {
|
|
|
655
678
|
borderRadius: "full",
|
|
656
679
|
backgroundColor: "#7676801F",
|
|
657
680
|
alignItems: "center",
|
|
658
|
-
|
|
681
|
+
width: "fit-content",
|
|
682
|
+
w: "auto",
|
|
683
|
+
h: "auto",
|
|
659
684
|
pl: "8px",
|
|
660
685
|
pr: "4px",
|
|
661
|
-
py: "2px"
|
|
686
|
+
py: "2px",
|
|
687
|
+
position: "relative"
|
|
662
688
|
}, /*#__PURE__*/React__default.createElement(Text$2, {
|
|
663
689
|
color: colors.label.primary.light,
|
|
664
|
-
fontSize: "13px"
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
690
|
+
fontSize: "13px",
|
|
691
|
+
pr: "4px"
|
|
692
|
+
}, truncate(label.trim(), {
|
|
693
|
+
length: 15,
|
|
694
|
+
omission: '...'
|
|
695
|
+
})), /*#__PURE__*/React__default.createElement(Memo, {
|
|
696
|
+
width: "13px",
|
|
697
|
+
height: "13px",
|
|
669
698
|
onClick: onDelete,
|
|
670
699
|
cursor: "pointer"
|
|
671
700
|
}));
|
|
@@ -681,7 +710,9 @@ var StackedMultiSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
681
710
|
control = _ref2.control,
|
|
682
711
|
name = _ref2.name,
|
|
683
712
|
placeholder = _ref2.placeholder,
|
|
684
|
-
disabled = _ref2.disabled
|
|
713
|
+
disabled = _ref2.disabled,
|
|
714
|
+
maxLength = _ref2.maxLength,
|
|
715
|
+
setError = _ref2.setError;
|
|
685
716
|
var watchedValue = useWatch({
|
|
686
717
|
control: control,
|
|
687
718
|
name: name
|
|
@@ -703,6 +734,12 @@ var StackedMultiSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
703
734
|
useOutsideClick({
|
|
704
735
|
ref: dropdownRef,
|
|
705
736
|
handler: function handler() {
|
|
737
|
+
if (maxLength && localValues.length > maxLength) {
|
|
738
|
+
setError(name, {
|
|
739
|
+
message: "Exceeded maximum of " + maxLength + " options"
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
|
|
706
743
|
return setIsFocussed(false);
|
|
707
744
|
}
|
|
708
745
|
}); // gets latest watched form value (common delimited) from RHF state and creates a list
|
|
@@ -712,16 +749,24 @@ var StackedMultiSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
712
749
|
setLocalValues([]);
|
|
713
750
|
}
|
|
714
751
|
|
|
715
|
-
if (watchedValue !== undefined && watchedValue != null && watchedValue.length) {
|
|
752
|
+
if (maxLength && watchedValue !== undefined && watchedValue.length <= maxLength && watchedValue != null && watchedValue.length) {
|
|
716
753
|
setLocalValues(watchedValue.split(',').filter(Boolean).map(function (value) {
|
|
717
754
|
return options.find(function (option) {
|
|
718
755
|
return option.value === value;
|
|
719
756
|
});
|
|
720
757
|
}));
|
|
721
758
|
}
|
|
722
|
-
}, [options, watchedValue]);
|
|
759
|
+
}, [maxLength, options, watchedValue]);
|
|
723
760
|
|
|
724
761
|
var handleChange = function handleChange(option) {
|
|
762
|
+
console.log(localValues.length, maxLength);
|
|
763
|
+
|
|
764
|
+
if (maxLength && localValues.length > maxLength) {
|
|
765
|
+
return setError(name, {
|
|
766
|
+
message: "Exceeded maximum of " + maxLength + " options"
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
|
|
725
770
|
var newValue = [].concat(localValues, [option]).map(function (_ref3) {
|
|
726
771
|
var value = _ref3.value;
|
|
727
772
|
return value;
|
|
@@ -782,7 +827,14 @@ var StackedMultiSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
782
827
|
cursor: disabled ? 'not-allowed' : 'pointer'
|
|
783
828
|
}, /*#__PURE__*/React__default.createElement(Flex, {
|
|
784
829
|
height: "28px",
|
|
785
|
-
alignItems: "center"
|
|
830
|
+
alignItems: "center",
|
|
831
|
+
overflowX: "auto",
|
|
832
|
+
maxWidth: "90%",
|
|
833
|
+
style: {
|
|
834
|
+
scrollbarWidth: 'none'
|
|
835
|
+
/* Firefox */
|
|
836
|
+
|
|
837
|
+
}
|
|
786
838
|
}, localValues.length ? localValues.map(function (option) {
|
|
787
839
|
return /*#__PURE__*/React__default.createElement(Box, {
|
|
788
840
|
mr: "4px"
|
|
@@ -820,7 +872,10 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
820
872
|
setValue = _ref2.setValue,
|
|
821
873
|
control = _ref2.control,
|
|
822
874
|
placeholder = _ref2.placeholder,
|
|
823
|
-
disabled = _ref2.disabled
|
|
875
|
+
disabled = _ref2.disabled,
|
|
876
|
+
maxLength = _ref2.maxLength,
|
|
877
|
+
setError = _ref2.setError,
|
|
878
|
+
clearErrors = _ref2.clearErrors;
|
|
824
879
|
var watchedValue = useWatch({
|
|
825
880
|
control: control,
|
|
826
881
|
name: name
|
|
@@ -858,6 +913,13 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
858
913
|
|
|
859
914
|
var onHandleKeyDown = function onHandleKeyDown(e) {
|
|
860
915
|
if (e.key === ' ' || e.key === 'Enter' || e.key === ',') {
|
|
916
|
+
if (maxLength && lastestFormValueToArray.length >= maxLength) {
|
|
917
|
+
return setError(name, {
|
|
918
|
+
type: 'maxLength',
|
|
919
|
+
message: "Exceeded maximum of " + maxLength + " options"
|
|
920
|
+
});
|
|
921
|
+
}
|
|
922
|
+
|
|
861
923
|
if (e.key === 'Enter' && !localValue.trim().length && tokenIndex !== null) {
|
|
862
924
|
setLocalValue(lastestFormValueToArray[tokenIndex]);
|
|
863
925
|
|
|
@@ -933,7 +995,10 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
933
995
|
};
|
|
934
996
|
|
|
935
997
|
var onBlur = function onBlur() {
|
|
998
|
+
clearErrors(name);
|
|
999
|
+
|
|
936
1000
|
if (localValue.trim()) {
|
|
1001
|
+
if (maxLength && watchedValue.length + localValue.trim().length > maxLength) return setLocalValue('');
|
|
937
1002
|
var filteredUniqueValues = Array.from(new Set([].concat(lastestFormValueToArray, localValue.trim().split(','))));
|
|
938
1003
|
setValue(name, filteredUniqueValues.toString().replace(/\s/g, ''), {
|
|
939
1004
|
shouldValidate: true,
|
|
@@ -973,8 +1038,8 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
973
1038
|
}, /*#__PURE__*/React__default.createElement(Flex, {
|
|
974
1039
|
height: "28px",
|
|
975
1040
|
alignItems: "center",
|
|
976
|
-
|
|
977
|
-
|
|
1041
|
+
width: "fit-content",
|
|
1042
|
+
maxW: "80%",
|
|
978
1043
|
overflowX: "auto",
|
|
979
1044
|
style: {
|
|
980
1045
|
scrollbarWidth: 'none'
|
|
@@ -989,7 +1054,6 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
989
1054
|
onClick: function onClick() {
|
|
990
1055
|
return setTokenIndex(index);
|
|
991
1056
|
},
|
|
992
|
-
// width="fit-content"
|
|
993
1057
|
width: "100%"
|
|
994
1058
|
}, /*#__PURE__*/React__default.createElement(Token, {
|
|
995
1059
|
label: label,
|
|
@@ -1081,7 +1145,9 @@ function Input(_ref) {
|
|
|
1081
1145
|
control = _ref.control,
|
|
1082
1146
|
disabled = _ref.disabled,
|
|
1083
1147
|
onChange = _ref.onChange,
|
|
1084
|
-
setValue = _ref.setValue
|
|
1148
|
+
setValue = _ref.setValue,
|
|
1149
|
+
setError = _ref.setError,
|
|
1150
|
+
clearErrors = _ref.clearErrors;
|
|
1085
1151
|
|
|
1086
1152
|
var selectedInputField = function selectedInputField(onChange, onBlur, ref, value) {
|
|
1087
1153
|
switch (inputType) {
|
|
@@ -1177,7 +1243,10 @@ function Input(_ref) {
|
|
|
1177
1243
|
value: value,
|
|
1178
1244
|
setValue: setValue,
|
|
1179
1245
|
control: control,
|
|
1180
|
-
|
|
1246
|
+
setError: setError,
|
|
1247
|
+
clearErrors: clearErrors,
|
|
1248
|
+
placeholder: placeholder,
|
|
1249
|
+
maxLength: maxLength
|
|
1181
1250
|
});
|
|
1182
1251
|
|
|
1183
1252
|
case 'pilled-text':
|
|
@@ -1193,7 +1262,10 @@ function Input(_ref) {
|
|
|
1193
1262
|
disabled: disabled,
|
|
1194
1263
|
value: value,
|
|
1195
1264
|
setValue: setValue,
|
|
1196
|
-
|
|
1265
|
+
setError: setError,
|
|
1266
|
+
clearErrors: clearErrors,
|
|
1267
|
+
control: control,
|
|
1268
|
+
maxLength: maxLength
|
|
1197
1269
|
});
|
|
1198
1270
|
|
|
1199
1271
|
case 'switch':
|
|
@@ -1285,7 +1357,9 @@ function FormSection(_ref) {
|
|
|
1285
1357
|
maxLength: maxLength,
|
|
1286
1358
|
isInvalid: !!form.formState.errors[name],
|
|
1287
1359
|
defaultValue: defaultValue,
|
|
1288
|
-
setValue: form.setValue
|
|
1360
|
+
setValue: form.setValue,
|
|
1361
|
+
setError: form.setError,
|
|
1362
|
+
clearErrors: form.clearErrors
|
|
1289
1363
|
});
|
|
1290
1364
|
}));
|
|
1291
1365
|
}
|
|
@@ -1361,7 +1435,7 @@ var Layout = function Layout(_ref) {
|
|
|
1361
1435
|
onClick: function onClick() {
|
|
1362
1436
|
return setShow(!show);
|
|
1363
1437
|
},
|
|
1364
|
-
icon: show ? /*#__PURE__*/React__default.createElement(CloseIcon
|
|
1438
|
+
icon: show ? /*#__PURE__*/React__default.createElement(CloseIcon, null) : /*#__PURE__*/React__default.createElement(HamburgerIcon, null),
|
|
1365
1439
|
_focus: {
|
|
1366
1440
|
boxShadow: 'none'
|
|
1367
1441
|
}
|