@vygruppen/spor-react 2.4.0 → 2.4.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/.turbo/turbo-build.log +9 -9
- package/CHANGELOG.md +12 -0
- package/dist/{CountryCodeSelect-5DBHKSF3.mjs → CountryCodeSelect-FDAGWNSZ.mjs} +1 -1
- package/dist/{chunk-D5OFVN6X.mjs → chunk-C3DS6BFF.mjs} +49 -7
- package/dist/index.d.ts +13 -6
- package/dist/index.js +48 -6
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/input/Autosuggest.tsx +39 -5
- package/src/input/Combobox.tsx +57 -4
- package/src/input/ListBox.tsx +6 -4
package/.turbo/turbo-build.log
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
> @vygruppen/spor-react@2.4.
|
2
|
+
> @vygruppen/spor-react@2.4.2 build
|
3
3
|
> tsup src/index.tsx --dts --treeshake --format cjs,esm
|
4
4
|
|
5
5
|
[34mCLI[39m Building entry: src/index.tsx
|
@@ -9,13 +9,13 @@
|
|
9
9
|
[34mCJS[39m Build start
|
10
10
|
[34mESM[39m Build start
|
11
11
|
[34mDTS[39m Build start
|
12
|
-
"toTime" is imported from external module "@internationalized/date" but never used in "dist/chunk-D5OFVN6X.mjs".
|
13
12
|
"toTime" is imported from external module "@internationalized/date" but never used in "dist/index.js".
|
13
|
+
"toTime" is imported from external module "@internationalized/date" but never used in "dist/chunk-C3DS6BFF.mjs".
|
14
|
+
[32mCJS[39m [1mdist/index.js [22m[32m895.96 KB[39m
|
15
|
+
[32mCJS[39m ⚡️ Build success in 4923ms
|
14
16
|
[32mESM[39m [1mdist/index.mjs [22m[32m2.08 KB[39m
|
15
|
-
[32mESM[39m [1mdist/CountryCodeSelect-
|
16
|
-
[32mESM[39m [1mdist/chunk-
|
17
|
-
[32mESM[39m ⚡️ Build success in
|
18
|
-
[
|
19
|
-
[
|
20
|
-
[32mDTS[39m ⚡️ Build success in 21721ms
|
21
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m260.75 KB[39m
|
17
|
+
[32mESM[39m [1mdist/CountryCodeSelect-FDAGWNSZ.mjs [22m[32m351.67 KB[39m
|
18
|
+
[32mESM[39m [1mdist/chunk-C3DS6BFF.mjs [22m[32m416.15 KB[39m
|
19
|
+
[32mESM[39m ⚡️ Build success in 4924ms
|
20
|
+
[32mDTS[39m ⚡️ Build success in 18562ms
|
21
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m261.82 KB[39m
|
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# @vygruppen/spor-react
|
2
2
|
|
3
|
+
## 2.4.2
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- a5f843bc: Autosuggest: Return the entire item selected, not just the list
|
8
|
+
|
9
|
+
## 2.4.1
|
10
|
+
|
11
|
+
### Patch Changes
|
12
|
+
|
13
|
+
- 3dfeccd7: Add some spacing and styling props to both Combobox and Autosuggest
|
14
|
+
|
3
15
|
## 2.4.0
|
4
16
|
|
5
17
|
### Minor Changes
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { createTexts, useTranslation, InfoSelect, SelectItem } from './chunk-
|
1
|
+
import { createTexts, useTranslation, InfoSelect, SelectItem } from './chunk-C3DS6BFF.mjs';
|
2
2
|
import React from 'react';
|
3
3
|
|
4
4
|
// ../../node_modules/awesome-phonenumber/index-esm.mjs
|
@@ -4023,7 +4023,8 @@ function Autosuggest({
|
|
4023
4023
|
label,
|
4024
4024
|
fetcher,
|
4025
4025
|
children,
|
4026
|
-
onSelectionChange
|
4026
|
+
onSelectionChange,
|
4027
|
+
...props
|
4027
4028
|
}) {
|
4028
4029
|
const list2 = useAsyncList({
|
4029
4030
|
async load({ filterText }) {
|
@@ -4032,6 +4033,12 @@ function Autosuggest({
|
|
4032
4033
|
};
|
4033
4034
|
}
|
4034
4035
|
});
|
4036
|
+
const handleSelectionChange = (key) => {
|
4037
|
+
if (!onSelectionChange) {
|
4038
|
+
return;
|
4039
|
+
}
|
4040
|
+
return onSelectionChange(list2.getItem(key));
|
4041
|
+
};
|
4035
4042
|
return /* @__PURE__ */ React49__default.createElement(
|
4036
4043
|
Combobox,
|
4037
4044
|
{
|
@@ -4039,8 +4046,9 @@ function Autosuggest({
|
|
4039
4046
|
items: list2.items,
|
4040
4047
|
inputValue: list2.filterText,
|
4041
4048
|
onInputChange: list2.setFilterText,
|
4049
|
+
onSelectionChange: handleSelectionChange,
|
4042
4050
|
isLoading: list2.isLoading,
|
4043
|
-
|
4051
|
+
...props
|
4044
4052
|
},
|
4045
4053
|
children
|
4046
4054
|
);
|
@@ -4220,6 +4228,23 @@ var ChoiceChip = forwardRef((props, ref) => {
|
|
4220
4228
|
function Combobox({
|
4221
4229
|
label,
|
4222
4230
|
isLoading,
|
4231
|
+
leftIcon,
|
4232
|
+
rightIcon,
|
4233
|
+
borderBottomLeftRadius = "sm",
|
4234
|
+
borderBottomRightRadius = "sm",
|
4235
|
+
borderTopLeftRadius = "sm",
|
4236
|
+
borderTopRightRadius = "sm",
|
4237
|
+
marginBottom,
|
4238
|
+
marginTop,
|
4239
|
+
marginX,
|
4240
|
+
marginY,
|
4241
|
+
paddingBottom,
|
4242
|
+
paddingRight,
|
4243
|
+
paddingTop,
|
4244
|
+
paddingLeft,
|
4245
|
+
paddingX,
|
4246
|
+
paddingY,
|
4247
|
+
onFocus,
|
4223
4248
|
...rest
|
4224
4249
|
}) {
|
4225
4250
|
const { contains: contains2 } = useFilter({ sensitivity: "base" });
|
@@ -4248,7 +4273,22 @@ function Combobox({
|
|
4248
4273
|
...inputProps,
|
4249
4274
|
ref: inputRef,
|
4250
4275
|
label,
|
4251
|
-
|
4276
|
+
onFocus,
|
4277
|
+
borderBottomLeftRadius: state2.isOpen ? 0 : borderBottomLeftRadius,
|
4278
|
+
borderBottomRightRadius: state2.isOpen ? 0 : borderBottomRightRadius,
|
4279
|
+
borderTopLeftRadius,
|
4280
|
+
borderTopRightRadius,
|
4281
|
+
marginBottom,
|
4282
|
+
marginTop,
|
4283
|
+
marginX,
|
4284
|
+
marginY,
|
4285
|
+
paddingBottom,
|
4286
|
+
paddingRight,
|
4287
|
+
paddingTop,
|
4288
|
+
paddingLeft,
|
4289
|
+
paddingX,
|
4290
|
+
paddingY,
|
4291
|
+
leftIcon,
|
4252
4292
|
rightIcon: isLoading ? /* @__PURE__ */ React49__default.createElement(
|
4253
4293
|
ColorSpinner,
|
4254
4294
|
{
|
@@ -4261,7 +4301,7 @@ function Combobox({
|
|
4261
4301
|
}
|
4262
4302
|
}
|
4263
4303
|
}
|
4264
|
-
) :
|
4304
|
+
) : rightIcon
|
4265
4305
|
}
|
4266
4306
|
), state2.isOpen && /* @__PURE__ */ React49__default.createElement(
|
4267
4307
|
Popover3,
|
@@ -4364,7 +4404,7 @@ function ListBox({
|
|
4364
4404
|
sx: styles2.container,
|
4365
4405
|
"aria-busy": isLoading
|
4366
4406
|
},
|
4367
|
-
|
4407
|
+
Array.from(state2.collection).map(
|
4368
4408
|
(item) => item.type === "section" ? /* @__PURE__ */ React49__default.createElement(ListBoxSection, { key: item.key, section: item, state: state2 }) : /* @__PURE__ */ React49__default.createElement(Option, { key: item.key, item, state: state2 })
|
4369
4409
|
)
|
4370
4410
|
);
|
@@ -4431,7 +4471,9 @@ function ListBoxSection({ section, state: state2 }) {
|
|
4431
4471
|
...headingProps
|
4432
4472
|
},
|
4433
4473
|
section.rendered
|
4434
|
-
), /* @__PURE__ */ React49__default.createElement(List, { ...groupProps, padding: 0, listStyleType: "none" },
|
4474
|
+
), /* @__PURE__ */ React49__default.createElement(List, { ...groupProps, padding: 0, listStyleType: "none" }, Array.from(state2.collection.getChildren(section.key)).map(
|
4475
|
+
(item) => /* @__PURE__ */ React49__default.createElement(Option, { key: item.key, item, state: state2 })
|
4476
|
+
)));
|
4435
4477
|
}
|
4436
4478
|
|
4437
4479
|
// src/input/InfoSelect.tsx
|
@@ -4887,7 +4929,7 @@ var texts13 = createTexts({
|
|
4887
4929
|
sv: "Telefonnummer"
|
4888
4930
|
}
|
4889
4931
|
});
|
4890
|
-
var LazyCountryCodeSelect = React49__default.lazy(() => import('./CountryCodeSelect-
|
4932
|
+
var LazyCountryCodeSelect = React49__default.lazy(() => import('./CountryCodeSelect-FDAGWNSZ.mjs'));
|
4891
4933
|
var Radio = forwardRef((props, ref) => {
|
4892
4934
|
return /* @__PURE__ */ React49__default.createElement(Radio$1, { ...props, ref });
|
4893
4935
|
});
|
package/dist/index.d.ts
CHANGED
@@ -644,10 +644,17 @@ type AutosuggestProps<T> = {
|
|
644
644
|
* */
|
645
645
|
children: ComboboxProps<T>["children"];
|
646
646
|
/**
|
647
|
-
* Callback for when the selection changes.
|
647
|
+
* Callback for when the selection changes. Returns the entire item.
|
648
648
|
*/
|
649
|
-
onSelectionChange?:
|
650
|
-
|
649
|
+
onSelectionChange?: (item: T) => void;
|
650
|
+
/** The selected item key (controlled) */
|
651
|
+
selectedKey?: ComboboxProps<T>["selectedKey"];
|
652
|
+
/** What should open the menu.
|
653
|
+
*
|
654
|
+
* Defaults to "input"
|
655
|
+
*/
|
656
|
+
menuTrigger?: ComboboxProps<T>["menuTrigger"];
|
657
|
+
} & Pick<InputProps, "marginTop" | "marginBottom" | "marginY" | "marginX" | "paddingTop" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingY" | "paddingX" | "leftIcon" | "rightIcon" | "borderTopRightRadius" | "borderTopLeftRadius" | "borderBottomRightRadius" | "borderBottomLeftRadius" | "onFocus">;
|
651
658
|
/**
|
652
659
|
* A component that provides an autocomplete search field with suggestions.
|
653
660
|
*
|
@@ -679,7 +686,7 @@ type AutosuggestProps<T> = {
|
|
679
686
|
* };
|
680
687
|
* ```
|
681
688
|
*/
|
682
|
-
declare function Autosuggest<T extends object>({ label, fetcher, children, onSelectionChange, }: AutosuggestProps<T>): React__default.JSX.Element;
|
689
|
+
declare function Autosuggest<T extends object>({ label, fetcher, children, onSelectionChange, ...props }: AutosuggestProps<T>): React__default.JSX.Element;
|
683
690
|
|
684
691
|
type CardSelectProps = BoxProps & {
|
685
692
|
/** The design of the trigger button.
|
@@ -816,7 +823,7 @@ type ComboboxProps<T> = AriaComboBoxProps<T> & {
|
|
816
823
|
label: string;
|
817
824
|
/** Whether or not the combobox is waiting for new suggestions */
|
818
825
|
isLoading?: boolean;
|
819
|
-
}
|
826
|
+
} & Pick<InputProps, "marginTop" | "marginBottom" | "marginY" | "marginX" | "paddingTop" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingY" | "paddingX" | "leftIcon" | "rightIcon" | "borderTopRightRadius" | "borderTopLeftRadius" | "borderBottomRightRadius" | "borderBottomLeftRadius" | "onFocus">;
|
820
827
|
/**
|
821
828
|
* A combobox is a combination of an input and a list of suggestions.
|
822
829
|
*
|
@@ -840,7 +847,7 @@ type ComboboxProps<T> = AriaComboBoxProps<T> & {
|
|
840
847
|
* </Combobox>
|
841
848
|
* ```
|
842
849
|
*/
|
843
|
-
declare function Combobox<T extends object>({ label, isLoading, ...rest }: ComboboxProps<T>): React__default.JSX.Element;
|
850
|
+
declare function Combobox<T extends object>({ label, isLoading, leftIcon, rightIcon, borderBottomLeftRadius, borderBottomRightRadius, borderTopLeftRadius, borderTopRightRadius, marginBottom, marginTop, marginX, marginY, paddingBottom, paddingRight, paddingTop, paddingLeft, paddingX, paddingY, onFocus, ...rest }: ComboboxProps<T>): React__default.JSX.Element;
|
844
851
|
|
845
852
|
type FormControlProps = FormControlProps$1;
|
846
853
|
declare const FormControl: _chakra_ui_system_dist_system_types.ComponentWithAs<"div", FormControlProps$1>;
|
package/dist/index.js
CHANGED
@@ -3754,7 +3754,8 @@ function Autosuggest({
|
|
3754
3754
|
label,
|
3755
3755
|
fetcher,
|
3756
3756
|
children,
|
3757
|
-
onSelectionChange
|
3757
|
+
onSelectionChange,
|
3758
|
+
...props
|
3758
3759
|
}) {
|
3759
3760
|
const list2 = reactStately.useAsyncList({
|
3760
3761
|
async load({ filterText }) {
|
@@ -3763,6 +3764,12 @@ function Autosuggest({
|
|
3763
3764
|
};
|
3764
3765
|
}
|
3765
3766
|
});
|
3767
|
+
const handleSelectionChange = (key) => {
|
3768
|
+
if (!onSelectionChange) {
|
3769
|
+
return;
|
3770
|
+
}
|
3771
|
+
return onSelectionChange(list2.getItem(key));
|
3772
|
+
};
|
3766
3773
|
return /* @__PURE__ */ React49__namespace.default.createElement(
|
3767
3774
|
Combobox,
|
3768
3775
|
{
|
@@ -3770,8 +3777,9 @@ function Autosuggest({
|
|
3770
3777
|
items: list2.items,
|
3771
3778
|
inputValue: list2.filterText,
|
3772
3779
|
onInputChange: list2.setFilterText,
|
3780
|
+
onSelectionChange: handleSelectionChange,
|
3773
3781
|
isLoading: list2.isLoading,
|
3774
|
-
|
3782
|
+
...props
|
3775
3783
|
},
|
3776
3784
|
children
|
3777
3785
|
);
|
@@ -4735,6 +4743,23 @@ var init_ChoiceChip = __esm({
|
|
4735
4743
|
function Combobox({
|
4736
4744
|
label,
|
4737
4745
|
isLoading,
|
4746
|
+
leftIcon,
|
4747
|
+
rightIcon,
|
4748
|
+
borderBottomLeftRadius = "sm",
|
4749
|
+
borderBottomRightRadius = "sm",
|
4750
|
+
borderTopLeftRadius = "sm",
|
4751
|
+
borderTopRightRadius = "sm",
|
4752
|
+
marginBottom,
|
4753
|
+
marginTop,
|
4754
|
+
marginX,
|
4755
|
+
marginY,
|
4756
|
+
paddingBottom,
|
4757
|
+
paddingRight,
|
4758
|
+
paddingTop,
|
4759
|
+
paddingLeft,
|
4760
|
+
paddingX,
|
4761
|
+
paddingY,
|
4762
|
+
onFocus,
|
4738
4763
|
...rest
|
4739
4764
|
}) {
|
4740
4765
|
const { contains: contains2 } = reactAria.useFilter({ sensitivity: "base" });
|
@@ -4763,7 +4788,22 @@ function Combobox({
|
|
4763
4788
|
...inputProps,
|
4764
4789
|
ref: inputRef,
|
4765
4790
|
label,
|
4766
|
-
|
4791
|
+
onFocus,
|
4792
|
+
borderBottomLeftRadius: state2.isOpen ? 0 : borderBottomLeftRadius,
|
4793
|
+
borderBottomRightRadius: state2.isOpen ? 0 : borderBottomRightRadius,
|
4794
|
+
borderTopLeftRadius,
|
4795
|
+
borderTopRightRadius,
|
4796
|
+
marginBottom,
|
4797
|
+
marginTop,
|
4798
|
+
marginX,
|
4799
|
+
marginY,
|
4800
|
+
paddingBottom,
|
4801
|
+
paddingRight,
|
4802
|
+
paddingTop,
|
4803
|
+
paddingLeft,
|
4804
|
+
paddingX,
|
4805
|
+
paddingY,
|
4806
|
+
leftIcon,
|
4767
4807
|
rightIcon: isLoading ? /* @__PURE__ */ React49__namespace.default.createElement(
|
4768
4808
|
exports.ColorSpinner,
|
4769
4809
|
{
|
@@ -4776,7 +4816,7 @@ function Combobox({
|
|
4776
4816
|
}
|
4777
4817
|
}
|
4778
4818
|
}
|
4779
|
-
) :
|
4819
|
+
) : rightIcon
|
4780
4820
|
}
|
4781
4821
|
), state2.isOpen && /* @__PURE__ */ React49__namespace.default.createElement(
|
4782
4822
|
Popover3,
|
@@ -4899,7 +4939,7 @@ function ListBox({
|
|
4899
4939
|
sx: styles2.container,
|
4900
4940
|
"aria-busy": isLoading
|
4901
4941
|
},
|
4902
|
-
|
4942
|
+
Array.from(state2.collection).map(
|
4903
4943
|
(item) => item.type === "section" ? /* @__PURE__ */ React49__namespace.default.createElement(ListBoxSection, { key: item.key, section: item, state: state2 }) : /* @__PURE__ */ React49__namespace.default.createElement(Option, { key: item.key, item, state: state2 })
|
4904
4944
|
)
|
4905
4945
|
);
|
@@ -4957,7 +4997,9 @@ function ListBoxSection({ section, state: state2 }) {
|
|
4957
4997
|
...headingProps
|
4958
4998
|
},
|
4959
4999
|
section.rendered
|
4960
|
-
), /* @__PURE__ */ React49__namespace.default.createElement(react.List, { ...groupProps, padding: 0, listStyleType: "none" },
|
5000
|
+
), /* @__PURE__ */ React49__namespace.default.createElement(react.List, { ...groupProps, padding: 0, listStyleType: "none" }, Array.from(state2.collection.getChildren(section.key)).map(
|
5001
|
+
(item) => /* @__PURE__ */ React49__namespace.default.createElement(Option, { key: item.key, item, state: state2 })
|
5002
|
+
)));
|
4961
5003
|
}
|
4962
5004
|
exports.SelectItem = void 0; exports.SelectItemLabel = void 0; exports.SelectItemDescription = void 0; var OptionContext, useOptionContext;
|
4963
5005
|
var init_ListBox = __esm({
|
package/dist/index.mjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export { Accordion, AccordionButton, AccordionIcon, AccordionItem, AccordionPanel, AttachedInputs, Autosuggest, Badge, Box, Button, ButtonGroup, Card, CardSelect, Center, Checkbox, CheckboxGroup, ChoiceChip, ClosableAlert, CloseButton, Code, Collapse, ColorInlineLoader, ColorSpinner, Combobox, Container, ContentLoader, DarkFullScreenLoader, DarkInlineLoader, DarkMode, DarkSpinner, DatePicker, DateRangePicker, Divider, Drawer, DrawerBody, DrawerCloseButton, DrawerContent, DrawerFooter, ModalHeader as DrawerHeader, DrawerOverlay, Expandable, ExpandableAlert, ExpandableItem, Fade, Flex, FloatingActionButton, FormControl, FormErrorMessage, FormHelperText, FormLabel, Grid, GridItem, HStack, Heading, IconButton, Image, Img, InfoSelect, InfoTag, Input, InputGroup, InputLeftElement, InputRightElement, Item, ItemDescription, ItemLabel, JumpButton, Language, LanguageProvider, LightFullScreenLoader, LightInlineLoader, LightMode, LightSpinner, LineIcon, ListBox, Modal, ModalBody, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalOverlay, NativeSelect, NumericStepper, PasswordInput, PhoneNumberInput, PlayPauseButton, Popover, PopoverAnchor, PopoverArrow, PopoverBody, PopoverCloseButton, PopoverContent, PopoverFooter, PopoverHeader, PopoverTrigger, PopoverWizardBody, ProgressBar, ProgressLoader, Radio, RadioGroup, ScaleFade, SearchInput, Section, SelectItem, SelectItemDescription, SelectItemLabel, SimpleDrawer, SimpleGrid, SimplePopover, Skeleton, SkeletonCircle, SkeletonText, SkipButton, Slide, SlideFade, Spacer, SporProvider, Stack, StaticAlert, Stepper, StepperStep, Switch, Tab, TabList, TabPanel, TabPanels, Table, TableCaption, Tabs, Tbody, Td, Text, TextLink, Textarea, Tfoot, Th, Thead, Time, TimePicker, Tr, TravelTag, VStack, VyLogo, WizardPopover, Wrap, WrapItem, createTexts, extendTheme, fontFaces, theme, tokens, useBreakpointValue, useClipboard, useColorMode, useColorModePreference, useColorModeValue, useControllableProp, useDisclosure, useMediaQuery, useMergeRefs, useOutsideClick, usePrefersReducedMotion, useTheme, useToast, useToken, useTranslation } from './chunk-
|
1
|
+
export { Accordion, AccordionButton, AccordionIcon, AccordionItem, AccordionPanel, AttachedInputs, Autosuggest, Badge, Box, Button, ButtonGroup, Card, CardSelect, Center, Checkbox, CheckboxGroup, ChoiceChip, ClosableAlert, CloseButton, Code, Collapse, ColorInlineLoader, ColorSpinner, Combobox, Container, ContentLoader, DarkFullScreenLoader, DarkInlineLoader, DarkMode, DarkSpinner, DatePicker, DateRangePicker, Divider, Drawer, DrawerBody, DrawerCloseButton, DrawerContent, DrawerFooter, ModalHeader as DrawerHeader, DrawerOverlay, Expandable, ExpandableAlert, ExpandableItem, Fade, Flex, FloatingActionButton, FormControl, FormErrorMessage, FormHelperText, FormLabel, Grid, GridItem, HStack, Heading, IconButton, Image, Img, InfoSelect, InfoTag, Input, InputGroup, InputLeftElement, InputRightElement, Item, ItemDescription, ItemLabel, JumpButton, Language, LanguageProvider, LightFullScreenLoader, LightInlineLoader, LightMode, LightSpinner, LineIcon, ListBox, Modal, ModalBody, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalOverlay, NativeSelect, NumericStepper, PasswordInput, PhoneNumberInput, PlayPauseButton, Popover, PopoverAnchor, PopoverArrow, PopoverBody, PopoverCloseButton, PopoverContent, PopoverFooter, PopoverHeader, PopoverTrigger, PopoverWizardBody, ProgressBar, ProgressLoader, Radio, RadioGroup, ScaleFade, SearchInput, Section, SelectItem, SelectItemDescription, SelectItemLabel, SimpleDrawer, SimpleGrid, SimplePopover, Skeleton, SkeletonCircle, SkeletonText, SkipButton, Slide, SlideFade, Spacer, SporProvider, Stack, StaticAlert, Stepper, StepperStep, Switch, Tab, TabList, TabPanel, TabPanels, Table, TableCaption, Tabs, Tbody, Td, Text, TextLink, Textarea, Tfoot, Th, Thead, Time, TimePicker, Tr, TravelTag, VStack, VyLogo, WizardPopover, Wrap, WrapItem, createTexts, extendTheme, fontFaces, theme, tokens, useBreakpointValue, useClipboard, useColorMode, useColorModePreference, useColorModeValue, useControllableProp, useDisclosure, useMediaQuery, useMergeRefs, useOutsideClick, usePrefersReducedMotion, useTheme, useToast, useToken, useTranslation } from './chunk-C3DS6BFF.mjs';
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import React from "react";
|
2
2
|
import { useAsyncList } from "react-stately";
|
3
|
-
import { Combobox, ComboboxProps } from "../";
|
3
|
+
import { Combobox, ComboboxProps, InputProps } from "../";
|
4
4
|
|
5
5
|
type AutosuggestProps<T> = {
|
6
6
|
/** The label of the search field */
|
@@ -39,10 +39,36 @@ type AutosuggestProps<T> = {
|
|
39
39
|
* */
|
40
40
|
children: ComboboxProps<T>["children"];
|
41
41
|
/**
|
42
|
-
* Callback for when the selection changes.
|
42
|
+
* Callback for when the selection changes. Returns the entire item.
|
43
43
|
*/
|
44
|
-
onSelectionChange?:
|
45
|
-
|
44
|
+
onSelectionChange?: (item: T) => void;
|
45
|
+
/** The selected item key (controlled) */
|
46
|
+
selectedKey?: ComboboxProps<T>["selectedKey"];
|
47
|
+
/** What should open the menu.
|
48
|
+
*
|
49
|
+
* Defaults to "input"
|
50
|
+
*/
|
51
|
+
menuTrigger?: ComboboxProps<T>["menuTrigger"];
|
52
|
+
} & Pick<
|
53
|
+
InputProps,
|
54
|
+
| "marginTop"
|
55
|
+
| "marginBottom"
|
56
|
+
| "marginY"
|
57
|
+
| "marginX"
|
58
|
+
| "paddingTop"
|
59
|
+
| "paddingBottom"
|
60
|
+
| "paddingLeft"
|
61
|
+
| "paddingRight"
|
62
|
+
| "paddingY"
|
63
|
+
| "paddingX"
|
64
|
+
| "leftIcon"
|
65
|
+
| "rightIcon"
|
66
|
+
| "borderTopRightRadius"
|
67
|
+
| "borderTopLeftRadius"
|
68
|
+
| "borderBottomRightRadius"
|
69
|
+
| "borderBottomLeftRadius"
|
70
|
+
| "onFocus"
|
71
|
+
>;
|
46
72
|
/**
|
47
73
|
* A component that provides an autocomplete search field with suggestions.
|
48
74
|
*
|
@@ -79,6 +105,7 @@ export function Autosuggest<T extends object>({
|
|
79
105
|
fetcher,
|
80
106
|
children,
|
81
107
|
onSelectionChange,
|
108
|
+
...props
|
82
109
|
}: AutosuggestProps<T>) {
|
83
110
|
const list = useAsyncList<T>({
|
84
111
|
async load({ filterText }) {
|
@@ -87,14 +114,21 @@ export function Autosuggest<T extends object>({
|
|
87
114
|
};
|
88
115
|
},
|
89
116
|
});
|
117
|
+
const handleSelectionChange = (key: React.Key) => {
|
118
|
+
if (!onSelectionChange) {
|
119
|
+
return;
|
120
|
+
}
|
121
|
+
return onSelectionChange(list.getItem(key));
|
122
|
+
};
|
90
123
|
return (
|
91
124
|
<Combobox
|
92
125
|
label={label}
|
93
126
|
items={list.items}
|
94
127
|
inputValue={list.filterText}
|
95
128
|
onInputChange={list.setFilterText}
|
129
|
+
onSelectionChange={handleSelectionChange}
|
96
130
|
isLoading={list.isLoading}
|
97
|
-
|
131
|
+
{...props}
|
98
132
|
>
|
99
133
|
{children}
|
100
134
|
</Combobox>
|
package/src/input/Combobox.tsx
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import React, { useRef } from "react";
|
2
2
|
import { AriaComboBoxProps, useComboBox, useFilter } from "react-aria";
|
3
3
|
import { useComboBoxState } from "react-stately";
|
4
|
-
import { ColorSpinner, FormControl, Input, ListBox } from "..";
|
4
|
+
import { ColorSpinner, FormControl, Input, InputProps, ListBox } from "..";
|
5
5
|
import { Popover } from "./Popover";
|
6
6
|
|
7
7
|
export type ComboboxProps<T> = AriaComboBoxProps<T> & {
|
@@ -9,7 +9,26 @@ export type ComboboxProps<T> = AriaComboBoxProps<T> & {
|
|
9
9
|
label: string;
|
10
10
|
/** Whether or not the combobox is waiting for new suggestions */
|
11
11
|
isLoading?: boolean;
|
12
|
-
}
|
12
|
+
} & Pick<
|
13
|
+
InputProps,
|
14
|
+
| "marginTop"
|
15
|
+
| "marginBottom"
|
16
|
+
| "marginY"
|
17
|
+
| "marginX"
|
18
|
+
| "paddingTop"
|
19
|
+
| "paddingBottom"
|
20
|
+
| "paddingLeft"
|
21
|
+
| "paddingRight"
|
22
|
+
| "paddingY"
|
23
|
+
| "paddingX"
|
24
|
+
| "leftIcon"
|
25
|
+
| "rightIcon"
|
26
|
+
| "borderTopRightRadius"
|
27
|
+
| "borderTopLeftRadius"
|
28
|
+
| "borderBottomRightRadius"
|
29
|
+
| "borderBottomLeftRadius"
|
30
|
+
| "onFocus"
|
31
|
+
>;
|
13
32
|
/**
|
14
33
|
* A combobox is a combination of an input and a list of suggestions.
|
15
34
|
*
|
@@ -36,6 +55,23 @@ export type ComboboxProps<T> = AriaComboBoxProps<T> & {
|
|
36
55
|
export function Combobox<T extends object>({
|
37
56
|
label,
|
38
57
|
isLoading,
|
58
|
+
leftIcon,
|
59
|
+
rightIcon,
|
60
|
+
borderBottomLeftRadius = "sm",
|
61
|
+
borderBottomRightRadius = "sm",
|
62
|
+
borderTopLeftRadius = "sm",
|
63
|
+
borderTopRightRadius = "sm",
|
64
|
+
marginBottom,
|
65
|
+
marginTop,
|
66
|
+
marginX,
|
67
|
+
marginY,
|
68
|
+
paddingBottom,
|
69
|
+
paddingRight,
|
70
|
+
paddingTop,
|
71
|
+
paddingLeft,
|
72
|
+
paddingX,
|
73
|
+
paddingY,
|
74
|
+
onFocus,
|
39
75
|
...rest
|
40
76
|
}: ComboboxProps<T>) {
|
41
77
|
const { contains } = useFilter({ sensitivity: "base" });
|
@@ -67,7 +103,22 @@ export function Combobox<T extends object>({
|
|
67
103
|
{...inputProps}
|
68
104
|
ref={inputRef}
|
69
105
|
label={label}
|
70
|
-
|
106
|
+
onFocus={onFocus}
|
107
|
+
borderBottomLeftRadius={state.isOpen ? 0 : borderBottomLeftRadius}
|
108
|
+
borderBottomRightRadius={state.isOpen ? 0 : borderBottomRightRadius}
|
109
|
+
borderTopLeftRadius={borderTopLeftRadius}
|
110
|
+
borderTopRightRadius={borderTopRightRadius}
|
111
|
+
marginBottom={marginBottom}
|
112
|
+
marginTop={marginTop}
|
113
|
+
marginX={marginX}
|
114
|
+
marginY={marginY}
|
115
|
+
paddingBottom={paddingBottom}
|
116
|
+
paddingRight={paddingRight}
|
117
|
+
paddingTop={paddingTop}
|
118
|
+
paddingLeft={paddingLeft}
|
119
|
+
paddingX={paddingX}
|
120
|
+
paddingY={paddingY}
|
121
|
+
leftIcon={leftIcon}
|
71
122
|
rightIcon={
|
72
123
|
isLoading ? (
|
73
124
|
<ColorSpinner
|
@@ -80,7 +131,9 @@ export function Combobox<T extends object>({
|
|
80
131
|
},
|
81
132
|
}}
|
82
133
|
/>
|
83
|
-
) :
|
134
|
+
) : (
|
135
|
+
rightIcon
|
136
|
+
)
|
84
137
|
}
|
85
138
|
/>
|
86
139
|
{state.isOpen && (
|
package/src/input/ListBox.tsx
CHANGED
@@ -80,7 +80,7 @@ export function ListBox<T extends object>({
|
|
80
80
|
sx={styles.container}
|
81
81
|
aria-busy={isLoading}
|
82
82
|
>
|
83
|
-
{
|
83
|
+
{Array.from(state.collection).map((item) =>
|
84
84
|
item.type === "section" ? (
|
85
85
|
<ListBoxSection key={item.key} section={item} state={state} />
|
86
86
|
) : (
|
@@ -203,9 +203,11 @@ function ListBoxSection({ section, state }: ListBoxSectionProps) {
|
|
203
203
|
</Box>
|
204
204
|
)}
|
205
205
|
<List {...groupProps} padding={0} listStyleType="none">
|
206
|
-
{
|
207
|
-
|
208
|
-
|
206
|
+
{Array.from(state.collection.getChildren(section.key)).map(
|
207
|
+
(item: any) => (
|
208
|
+
<Option key={item.key} item={item} state={state} />
|
209
|
+
)
|
210
|
+
)}
|
209
211
|
</List>
|
210
212
|
</ListItem>
|
211
213
|
);
|