@vygruppen/spor-react 2.4.1 → 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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @vygruppen/spor-react@2.4.1 build
2
+ > @vygruppen/spor-react@2.4.2 build
3
3
  > tsup src/index.tsx --dts --treeshake --format cjs,esm
4
4
 
5
5
  CLI Building entry: src/index.tsx
@@ -10,12 +10,12 @@
10
10
  ESM Build start
11
11
  DTS Build start
12
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-FLORQZEA.mjs".
14
- CJS dist/index.js 895.79 KB
15
- CJS ⚡️ Build success in 5871ms
13
+ "toTime" is imported from external module "@internationalized/date" but never used in "dist/chunk-C3DS6BFF.mjs".
14
+ CJS dist/index.js 895.96 KB
15
+ CJS ⚡️ Build success in 4923ms
16
16
  ESM dist/index.mjs 2.08 KB
17
- ESM dist/CountryCodeSelect-MNHFBDDO.mjs 351.67 KB
18
- ESM dist/chunk-FLORQZEA.mjs 415.99 KB
19
- ESM ⚡️ Build success in 5874ms
20
- DTS ⚡️ Build success in 22290ms
21
- DTS dist/index.d.ts 261.60 KB
17
+ ESM dist/CountryCodeSelect-FDAGWNSZ.mjs 351.67 KB
18
+ ESM dist/chunk-C3DS6BFF.mjs 416.15 KB
19
+ ESM ⚡️ Build success in 4924ms
20
+ DTS ⚡️ Build success in 18562ms
21
+ DTS dist/index.d.ts 261.82 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
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
+
3
9
  ## 2.4.1
4
10
 
5
11
  ### Patch Changes
@@ -1,4 +1,4 @@
1
- import { createTexts, useTranslation, InfoSelect, SelectItem } from './chunk-FLORQZEA.mjs';
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
@@ -4024,7 +4024,7 @@ function Autosuggest({
4024
4024
  fetcher,
4025
4025
  children,
4026
4026
  onSelectionChange,
4027
- ...boxProps
4027
+ ...props
4028
4028
  }) {
4029
4029
  const list2 = useAsyncList({
4030
4030
  async load({ filterText }) {
@@ -4033,6 +4033,12 @@ function Autosuggest({
4033
4033
  };
4034
4034
  }
4035
4035
  });
4036
+ const handleSelectionChange = (key) => {
4037
+ if (!onSelectionChange) {
4038
+ return;
4039
+ }
4040
+ return onSelectionChange(list2.getItem(key));
4041
+ };
4036
4042
  return /* @__PURE__ */ React49__default.createElement(
4037
4043
  Combobox,
4038
4044
  {
@@ -4040,9 +4046,9 @@ function Autosuggest({
4040
4046
  items: list2.items,
4041
4047
  inputValue: list2.filterText,
4042
4048
  onInputChange: list2.setFilterText,
4049
+ onSelectionChange: handleSelectionChange,
4043
4050
  isLoading: list2.isLoading,
4044
- onSelectionChange,
4045
- ...boxProps
4051
+ ...props
4046
4052
  },
4047
4053
  children
4048
4054
  );
@@ -4923,7 +4929,7 @@ var texts13 = createTexts({
4923
4929
  sv: "Telefonnummer"
4924
4930
  }
4925
4931
  });
4926
- var LazyCountryCodeSelect = React49__default.lazy(() => import('./CountryCodeSelect-MNHFBDDO.mjs'));
4932
+ var LazyCountryCodeSelect = React49__default.lazy(() => import('./CountryCodeSelect-FDAGWNSZ.mjs'));
4927
4933
  var Radio = forwardRef((props, ref) => {
4928
4934
  return /* @__PURE__ */ React49__default.createElement(Radio$1, { ...props, ref });
4929
4935
  });
package/dist/index.d.ts CHANGED
@@ -644,9 +644,16 @@ 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?: ComboboxProps<T>["onSelectionChange"];
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"];
650
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.
@@ -679,7 +686,7 @@ type AutosuggestProps<T> = {
679
686
  * };
680
687
  * ```
681
688
  */
682
- declare function Autosuggest<T extends object>({ label, fetcher, children, onSelectionChange, ...boxProps }: 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.
package/dist/index.js CHANGED
@@ -3755,7 +3755,7 @@ function Autosuggest({
3755
3755
  fetcher,
3756
3756
  children,
3757
3757
  onSelectionChange,
3758
- ...boxProps
3758
+ ...props
3759
3759
  }) {
3760
3760
  const list2 = reactStately.useAsyncList({
3761
3761
  async load({ filterText }) {
@@ -3764,6 +3764,12 @@ function Autosuggest({
3764
3764
  };
3765
3765
  }
3766
3766
  });
3767
+ const handleSelectionChange = (key) => {
3768
+ if (!onSelectionChange) {
3769
+ return;
3770
+ }
3771
+ return onSelectionChange(list2.getItem(key));
3772
+ };
3767
3773
  return /* @__PURE__ */ React49__namespace.default.createElement(
3768
3774
  Combobox,
3769
3775
  {
@@ -3771,9 +3777,9 @@ function Autosuggest({
3771
3777
  items: list2.items,
3772
3778
  inputValue: list2.filterText,
3773
3779
  onInputChange: list2.setFilterText,
3780
+ onSelectionChange: handleSelectionChange,
3774
3781
  isLoading: list2.isLoading,
3775
- onSelectionChange,
3776
- ...boxProps
3782
+ ...props
3777
3783
  },
3778
3784
  children
3779
3785
  );
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-FLORQZEA.mjs';
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
  {
2
2
  "name": "@vygruppen/spor-react",
3
- "version": "2.4.1",
3
+ "version": "2.4.2",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -39,9 +39,16 @@ 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?: ComboboxProps<T>["onSelectionChange"];
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"];
45
52
  } & Pick<
46
53
  InputProps,
47
54
  | "marginTop"
@@ -98,7 +105,7 @@ export function Autosuggest<T extends object>({
98
105
  fetcher,
99
106
  children,
100
107
  onSelectionChange,
101
- ...boxProps
108
+ ...props
102
109
  }: AutosuggestProps<T>) {
103
110
  const list = useAsyncList<T>({
104
111
  async load({ filterText }) {
@@ -107,15 +114,21 @@ export function Autosuggest<T extends object>({
107
114
  };
108
115
  },
109
116
  });
117
+ const handleSelectionChange = (key: React.Key) => {
118
+ if (!onSelectionChange) {
119
+ return;
120
+ }
121
+ return onSelectionChange(list.getItem(key));
122
+ };
110
123
  return (
111
124
  <Combobox
112
125
  label={label}
113
126
  items={list.items}
114
127
  inputValue={list.filterText}
115
128
  onInputChange={list.setFilterText}
129
+ onSelectionChange={handleSelectionChange}
116
130
  isLoading={list.isLoading}
117
- onSelectionChange={onSelectionChange}
118
- {...boxProps}
131
+ {...props}
119
132
  >
120
133
  {children}
121
134
  </Combobox>