@vygruppen/spor-react 9.13.0 → 9.13.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/index.d.ts CHANGED
@@ -109,6 +109,7 @@ type RadioGroupContextProps = {
109
109
  onChange: (value: string) => void;
110
110
  variant?: "base" | "floating";
111
111
  defaultValue?: string;
112
+ value?: string;
112
113
  };
113
114
  declare const RadioCardGroupContext: React.Context<RadioGroupContextProps | null>;
114
115
  type RadioCardGroupProps = BoxProps & {
@@ -118,6 +119,7 @@ type RadioCardGroupProps = BoxProps & {
118
119
  direction?: "row" | "column";
119
120
  groupLabel?: string;
120
121
  defaultValue?: string;
122
+ onChange?: (value: string) => void;
121
123
  };
122
124
  declare const RadioCardGroup: React.FC<RadioCardGroupProps>;
123
125
 
@@ -1965,31 +1967,17 @@ type DrawerProps = DrawerProps$1;
1965
1967
  declare const Drawer: (props: DrawerProps) => React.JSX.Element;
1966
1968
  declare const DrawerContent: _chakra_ui_system_dist_system_types.ComponentWithAs<any, DrawerContentProps>;
1967
1969
 
1968
- type DrawerPlacement = "top" | "right" | "bottom" | "left";
1969
- type FullScreenDrawerProps = {
1970
- /** The content inside the drawer */
1971
- children: React.ReactNode;
1972
- /** The title in the middle of the top menu */
1973
- title?: String;
1974
- /** Determines which side the drawer slides from */
1975
- placement?: DrawerPlacement;
1976
- /** A React component that will be placed to the left in the modal header */
1977
- leftButton?: React.ReactNode;
1978
- /** A React component that will be placed to the right in the modal header */
1979
- rightButton?: React.ReactNode;
1980
- /** Determines if the drawer is open or closed */
1981
- isOpen: boolean;
1982
- /** Function that will be called when the drawer closes */
1983
- onClose: () => void;
1970
+ type DrawerBodyProps = {
1971
+ id?: string;
1984
1972
  };
1985
- declare const FullScreenDrawer: ({ children, title, placement, leftButton, rightButton, isOpen, onClose, }: FullScreenDrawerProps) => React.JSX.Element;
1986
-
1987
1973
  type SimpleDrawerProps = {
1988
1974
  children: React.ReactNode;
1989
1975
  title?: React.ReactNode;
1990
1976
  placement: "top" | "right" | "bottom" | "left";
1991
1977
  isOpen: boolean;
1992
1978
  onClose: () => void;
1979
+ /** Props for drawer body */
1980
+ body?: DrawerBodyProps;
1993
1981
  };
1994
1982
  /** A very basic drawer component that's easy to use
1995
1983
  *
@@ -2001,7 +1989,28 @@ type SimpleDrawerProps = {
2001
1989
  *
2002
1990
  * For more advanced use cases, see the [Drawer](./Drawer.tsx) component.
2003
1991
  */
2004
- declare const SimpleDrawer: ({ placement, children, title, ...props }: SimpleDrawerProps) => React.JSX.Element;
1992
+ declare const SimpleDrawer: ({ placement, children, title, body, ...props }: SimpleDrawerProps) => React.JSX.Element;
1993
+
1994
+ type DrawerPlacement = "top" | "right" | "bottom" | "left";
1995
+ type FullScreenDrawerProps = {
1996
+ /** The content inside the drawer */
1997
+ children: React.ReactNode;
1998
+ /** The title in the middle of the top menu */
1999
+ title?: String;
2000
+ /** Determines which side the drawer slides from */
2001
+ placement?: DrawerPlacement;
2002
+ /** A React component that will be placed to the left in the modal header */
2003
+ leftButton?: React.ReactNode;
2004
+ /** A React component that will be placed to the right in the modal header */
2005
+ rightButton?: React.ReactNode;
2006
+ /** Determines if the drawer is open or closed */
2007
+ isOpen: boolean;
2008
+ /** Function that will be called when the drawer closes */
2009
+ onClose: () => void;
2010
+ /** Props for drawer body */
2011
+ body?: DrawerBodyProps;
2012
+ };
2013
+ declare const FullScreenDrawer: ({ children, title, placement, leftButton, rightButton, isOpen, onClose, body, }: FullScreenDrawerProps) => React.JSX.Element;
2005
2014
 
2006
2015
  type TooltipProps = PopoverProps & {
2007
2016
  /**
@@ -5907,6 +5916,11 @@ declare const theme: {
5907
5916
  RadioCard: {
5908
5917
  baseStyle?: ((props: any) => {
5909
5918
  container: {
5919
+ overflow: string;
5920
+ fontSize: string;
5921
+ display: string;
5922
+ cursor: string;
5923
+ borderRadius: string;
5910
5924
  transitionProperty: string;
5911
5925
  transitionDuration: string;
5912
5926
  _disabled: {
@@ -5924,18 +5938,6 @@ declare const theme: {
5924
5938
  backgroundColor: string;
5925
5939
  pointerEvents: string;
5926
5940
  };
5927
- _focusVisible: {
5928
- outlineWidth: string;
5929
- outlineColor: string;
5930
- outlineStyle: string;
5931
- outlineOffset: string;
5932
- };
5933
- border: string;
5934
- overflow: string;
5935
- fontSize: string;
5936
- display: string;
5937
- cursor: string;
5938
- borderRadius: string;
5939
5941
  };
5940
5942
  checked: {
5941
5943
  backgroundColor: string;
@@ -5951,7 +5953,7 @@ declare const theme: {
5951
5953
  }) | undefined;
5952
5954
  sizes?: {
5953
5955
  [key: string]: _chakra_ui_styled_system.PartsStyleInterpolation<{
5954
- keys: ("container" | "checked" | "radioInput")[];
5956
+ keys: ("container" | "checked" | "radioInput" | "focused" | "focusedChecked")[];
5955
5957
  }>;
5956
5958
  } | undefined;
5957
5959
  variants?: {
@@ -5979,9 +5981,6 @@ declare const theme: {
5979
5981
  outlineColor: string;
5980
5982
  backgroundColor: string;
5981
5983
  };
5982
- _focus: {
5983
- outlineColor: string;
5984
- };
5985
5984
  outlineWidth: string;
5986
5985
  outlineColor: string;
5987
5986
  outlineStyle: string;
@@ -6011,9 +6010,6 @@ declare const theme: {
6011
6010
  outlineColor: string;
6012
6011
  backgroundColor: string;
6013
6012
  };
6014
- _focus: {
6015
- outlineColor: string;
6016
- };
6017
6013
  outline: string;
6018
6014
  outlineColor: string;
6019
6015
  backgroundColor: string;
@@ -6040,12 +6036,30 @@ declare const theme: {
6040
6036
  outlineColor: string;
6041
6037
  backgroundColor: string;
6042
6038
  };
6043
- _focus: {
6039
+ };
6040
+ focusedChecked: {
6041
+ outlineOffset: string;
6042
+ outlineColor: string;
6043
+ outline: string;
6044
+ outlineStyle: string;
6045
+ };
6046
+ focused: {
6047
+ outlineOffset: string;
6048
+ boxShadow: string;
6049
+ _hover: {
6050
+ boxShadow: string;
6044
6051
  outlineOffset: string;
6052
+ outlineWidth: string;
6045
6053
  outlineColor: string;
6046
- outline: string;
6047
6054
  outlineStyle: string;
6055
+ } | {
6056
+ boxShadow: string;
6057
+ outlineOffset: string;
6058
+ outline: string;
6059
+ outlineColor: string;
6048
6060
  };
6061
+ outlineColor: string;
6062
+ outline: string;
6049
6063
  };
6050
6064
  };
6051
6065
  floating: (props: _chakra_ui_styled_system.StyleFunctionProps) => {
@@ -6062,9 +6076,6 @@ declare const theme: {
6062
6076
  outlineColor: string;
6063
6077
  backgroundColor: string;
6064
6078
  };
6065
- _focus: {
6066
- outlineColor: string;
6067
- };
6068
6079
  outline: string;
6069
6080
  outlineColor: string;
6070
6081
  backgroundColor: string;
@@ -6080,12 +6091,24 @@ declare const theme: {
6080
6091
  outlineColor: string;
6081
6092
  backgroundColor: string;
6082
6093
  };
6083
- _focus: {
6094
+ };
6095
+ focusedChecked: {
6096
+ outlineOffset: string;
6097
+ outlineColor: string;
6098
+ outline: string;
6099
+ outlineStyle: string;
6100
+ };
6101
+ focused: {
6102
+ outlineOffset: string;
6103
+ boxShadow: string;
6104
+ _hover: {
6105
+ boxShadow: string;
6084
6106
  outlineOffset: string;
6085
- outlineColor: string;
6086
6107
  outline: string;
6087
- outlineStyle: string;
6108
+ outlineColor: string;
6088
6109
  };
6110
+ outlineColor: string;
6111
+ outline: string;
6089
6112
  };
6090
6113
  };
6091
6114
  } | undefined;
@@ -6094,7 +6117,7 @@ declare const theme: {
6094
6117
  variant?: "base" | "floating" | undefined;
6095
6118
  colorScheme?: string | undefined;
6096
6119
  } | undefined;
6097
- parts: ("container" | "checked" | "radioInput")[];
6120
+ parts: ("container" | "checked" | "radioInput" | "focused" | "focusedChecked")[];
6098
6121
  };
6099
6122
  Radio: {
6100
6123
  baseStyle?: ((props: _chakra_ui_styled_system.StyleFunctionProps) => {
@@ -9549,4 +9572,4 @@ declare const Text: _chakra_ui_system_dist_system_types.ComponentWithAs<"p", Tex
9549
9572
  **/
9550
9573
  declare function slugify(text: string | string[], maxLength?: number): string;
9551
9574
 
9552
- export { Accordion, AccordionProps, AttachedInputs, Badge, BadgeProps, Brand, Breadcrumb, BreadcrumbItem, BreadcrumbLink, Button, ButtonGroup, ButtonGroupProps, ButtonProps, Card, CardProps, CardSelect, Checkbox, CheckboxGroup, CheckboxGroupProps, CheckboxProps, ChoiceChip, ChoiceChipProps, ClosableAlert, CloseButton, CloseButtonProps, Code, CodeProps, ColorInlineLoader, ColorInlineLoaderProps, ColorSpinner, ColorSpinnerProps, Combobox, ComboboxProps, ContentLoader, ContentLoaderProps, DarkFullScreenLoader, DarkInlineLoader, DarkInlineLoaderProps, DarkSpinner, DarkSpinnerProps, DatePicker, DateRangePicker, Divider, DividerProps, Drawer, DrawerContent, ModalHeader as DrawerHeader, Expandable, ExpandableAlert, ExpandableItem, ExpandableItemProps, FloatingActionButton, FormControl, FormControlProps, FormErrorMessage, FormErrorMessageProps, FormLabel, FormLabelProps, FullScreenDrawer, Heading, HeadingProps, IconButton, IconButtonProps, InfoSelect, InfoTag, InfoTagProps, Input, InputElementProps, InputLeftElement, InputProps, InputRightElement, ItemDescription, ItemLabel, JumpButton, Language, LanguageProvider, LightFullScreenLoader, LightInlineLoader, LightInlineLoaderProps, LightSpinner, LightSpinnerProps, LineIcon, LineIconProps, ListBox, ModalHeader, ModalHeaderProps, NativeSelect, NativeSelectProps, Nudge, NudgeProps, NumericStepper, Pagination, PasswordInput, PasswordInputProps, PhoneNumberInput, PlayPauseButton, PressableCard, PrideProvider, ProgressBar, ProgressIndicator, ProgressLoader, Radio, RadioCard, RadioCardGroup, RadioCardGroupContext, RadioCardProps, RadioGroup, RadioGroupProps, RadioProps, SearchInput, SearchInputProps, SimpleDrawer, SimpleDrawerProps, Skeleton, SkeletonCircle, SkeletonCircleProps, SkeletonProps, SkeletonText, SkeletonTextProps, SkipButton, SpinnerProps, SporProvider, Stack, StackProps, StaticAlert, StaticCard, StaticCardProps, Stepper, StepperStep, Switch, SwitchProps, Table, TableProps, Tabs, TabsProps, Text, TextLink, TextProps, Textarea, TextareaProps, TimePicker, ToastOptions, TogglePride, Tooltip, TooltipProps, Translations, TravelTag, TravelTagProps, VyLogo, VyLogoDefault, VyLogoDefaultProps, VyLogoPride, VyLogoPrideProps, VyLogoProps, WizardNudge, WizardNudgeProps, brandTheme, createTexts, fontFaces, slugify, theme, usePride, useToast, useTranslation };
9575
+ export { Accordion, AccordionProps, AttachedInputs, Badge, BadgeProps, Brand, Breadcrumb, BreadcrumbItem, BreadcrumbLink, Button, ButtonGroup, ButtonGroupProps, ButtonProps, Card, CardProps, CardSelect, Checkbox, CheckboxGroup, CheckboxGroupProps, CheckboxProps, ChoiceChip, ChoiceChipProps, ClosableAlert, CloseButton, CloseButtonProps, Code, CodeProps, ColorInlineLoader, ColorInlineLoaderProps, ColorSpinner, ColorSpinnerProps, Combobox, ComboboxProps, ContentLoader, ContentLoaderProps, DarkFullScreenLoader, DarkInlineLoader, DarkInlineLoaderProps, DarkSpinner, DarkSpinnerProps, DatePicker, DateRangePicker, Divider, DividerProps, Drawer, DrawerBodyProps, DrawerContent, ModalHeader as DrawerHeader, Expandable, ExpandableAlert, ExpandableItem, ExpandableItemProps, FloatingActionButton, FormControl, FormControlProps, FormErrorMessage, FormErrorMessageProps, FormLabel, FormLabelProps, FullScreenDrawer, Heading, HeadingProps, IconButton, IconButtonProps, InfoSelect, InfoTag, InfoTagProps, Input, InputElementProps, InputLeftElement, InputProps, InputRightElement, ItemDescription, ItemLabel, JumpButton, Language, LanguageProvider, LightFullScreenLoader, LightInlineLoader, LightInlineLoaderProps, LightSpinner, LightSpinnerProps, LineIcon, LineIconProps, ListBox, ModalHeader, ModalHeaderProps, NativeSelect, NativeSelectProps, Nudge, NudgeProps, NumericStepper, Pagination, PasswordInput, PasswordInputProps, PhoneNumberInput, PlayPauseButton, PressableCard, PrideProvider, ProgressBar, ProgressIndicator, ProgressLoader, Radio, RadioCard, RadioCardGroup, RadioCardGroupContext, RadioCardProps, RadioGroup, RadioGroupProps, RadioProps, SearchInput, SearchInputProps, SimpleDrawer, SimpleDrawerProps, Skeleton, SkeletonCircle, SkeletonCircleProps, SkeletonProps, SkeletonText, SkeletonTextProps, SkipButton, SpinnerProps, SporProvider, Stack, StackProps, StaticAlert, StaticCard, StaticCardProps, Stepper, StepperStep, Switch, SwitchProps, Table, TableProps, Tabs, TabsProps, Text, TextLink, TextProps, Textarea, TextareaProps, TimePicker, ToastOptions, TogglePride, Tooltip, TooltipProps, Translations, TravelTag, TravelTagProps, VyLogo, VyLogoDefault, VyLogoDefaultProps, VyLogoPride, VyLogoPrideProps, VyLogoProps, WizardNudge, WizardNudgeProps, brandTheme, createTexts, fontFaces, slugify, theme, usePride, useToast, useTranslation };
package/dist/index.js CHANGED
@@ -2170,6 +2170,7 @@ var init_RadioCardGroup = __esm({
2170
2170
  direction: direction2 = "row",
2171
2171
  groupLabel,
2172
2172
  defaultValue,
2173
+ onChange,
2173
2174
  ...props
2174
2175
  }) => {
2175
2176
  const [selectedValue, setSelectedValue] = React88.useState(
@@ -2177,6 +2178,7 @@ var init_RadioCardGroup = __esm({
2177
2178
  );
2178
2179
  const handleChange = (value) => {
2179
2180
  setSelectedValue(value);
2181
+ onChange && onChange(value);
2180
2182
  };
2181
2183
  return /* @__PURE__ */ React88__namespace.default.createElement(
2182
2184
  exports.RadioCardGroupContext.Provider,
@@ -2189,19 +2191,7 @@ var init_RadioCardGroup = __esm({
2189
2191
  defaultValue: defaultValue || ""
2190
2192
  }
2191
2193
  },
2192
- /* @__PURE__ */ React88__namespace.default.createElement(
2193
- react.Stack,
2194
- {
2195
- as: "fieldset",
2196
- direction: direction2,
2197
- "aria-labelledby": groupLabel || name,
2198
- role: "radiogroup",
2199
- tabIndex: 0,
2200
- ...props
2201
- },
2202
- groupLabel && /* @__PURE__ */ React88__namespace.default.createElement(exports.FormLabel, { as: "legend", id: groupLabel }, groupLabel),
2203
- children
2204
- )
2194
+ /* @__PURE__ */ React88__namespace.default.createElement(react.Stack, { as: "fieldset", direction: direction2, ...props }, groupLabel && /* @__PURE__ */ React88__namespace.default.createElement(exports.FormLabel, { as: "legend", id: groupLabel }, groupLabel), children)
2205
2195
  );
2206
2196
  };
2207
2197
  }
@@ -2211,7 +2201,7 @@ var init_RadioCard = __esm({
2211
2201
  "src/layout/RadioCard.tsx"() {
2212
2202
  init_RadioCardGroup();
2213
2203
  exports.RadioCard = react.forwardRef(
2214
- ({ children, value = "base", isDisabled, ...props }, ref) => {
2204
+ ({ children, value, isDisabled, ...props }, ref) => {
2215
2205
  const context = React88.useContext(exports.RadioCardGroupContext);
2216
2206
  if (!context) {
2217
2207
  throw new Error(
@@ -2220,50 +2210,72 @@ var init_RadioCard = __esm({
2220
2210
  }
2221
2211
  const { name, selectedValue, onChange, variant } = context;
2222
2212
  const styles3 = react.useMultiStyleConfig("RadioCard", { variant });
2213
+ const [isKeyboardUser, setKeyboardUser] = React88.useState(false);
2214
+ const [isFocused, setFocus] = React88.useState(false);
2223
2215
  const isChecked = selectedValue === value;
2224
- const radioCardId = `radio-card-${React88.useId()}`;
2225
2216
  React88.useEffect(() => {
2226
- if (isChecked && typeof ref !== "function" && (ref == null ? void 0 : ref.current)) {
2227
- ref.current.focus();
2228
- }
2229
- }, [isChecked]);
2230
- const handleKeyDown = (event) => {
2231
- if (event.key === "Enter" || event.key === " ") {
2232
- onChange(value);
2233
- }
2234
- if (event.key === "ArrowRight" || event.key === "ArrowDown" || event.key === "ArrowLeft" || event.key === "ArrowUp") {
2235
- const nextRadioCard = event.currentTarget.nextElementSibling;
2236
- nextRadioCard.focus();
2237
- }
2238
- };
2239
- return /* @__PURE__ */ React88__namespace.default.createElement(react.Box, { as: "label", "aria-label": String(children), onKeyDown: handleKeyDown }, /* @__PURE__ */ React88__namespace.default.createElement(
2240
- react.chakra.input,
2241
- {
2242
- type: "radio",
2243
- id: radioCardId,
2244
- ref,
2245
- value,
2246
- name,
2247
- checked: isChecked,
2248
- onChange: () => onChange(value),
2249
- disabled: isDisabled,
2250
- __css: styles3.radioInput
2217
+ const handleMouseDown = () => setKeyboardUser(false);
2218
+ const handleKeyDown = (event) => {
2219
+ if (event.key === " ") {
2220
+ setFocus(false);
2221
+ } else {
2222
+ setKeyboardUser(true);
2223
+ }
2224
+ };
2225
+ window.addEventListener("mousedown", handleMouseDown);
2226
+ window.addEventListener("keydown", handleKeyDown);
2227
+ return () => {
2228
+ window.removeEventListener("mousedown", handleMouseDown);
2229
+ window.removeEventListener("keydown", handleKeyDown);
2230
+ };
2231
+ }, []);
2232
+ React88.useEffect(() => {
2233
+ if (isKeyboardUser && isChecked) {
2234
+ setFocus(true);
2235
+ } else {
2236
+ setFocus(false);
2251
2237
  }
2252
- ), /* @__PURE__ */ React88__namespace.default.createElement(
2238
+ }, [isKeyboardUser, isChecked]);
2239
+ const inputId = `radio-card-${React88.useId()}`;
2240
+ return /* @__PURE__ */ React88__namespace.default.createElement(
2253
2241
  react.Box,
2254
2242
  {
2255
- ...props,
2256
- tabIndex: 0,
2257
- ref,
2258
- role: "radio",
2259
- "aria-checked": isChecked,
2260
- "aria-labelledby": radioCardId,
2261
- __css: { ...styles3.container, ...isChecked && styles3.checked },
2262
- "data-checked": isChecked,
2263
- "data-disabled": isDisabled
2243
+ onFocus: () => isKeyboardUser && setFocus(true),
2244
+ onBlur: () => setFocus(false)
2264
2245
  },
2265
- children
2266
- ));
2246
+ /* @__PURE__ */ React88__namespace.default.createElement(
2247
+ react.chakra.input,
2248
+ {
2249
+ type: "radio",
2250
+ id: inputId,
2251
+ name,
2252
+ ref,
2253
+ checked: isChecked,
2254
+ onChange: () => onChange(value),
2255
+ disabled: isDisabled,
2256
+ __css: styles3.radioInput
2257
+ }
2258
+ ),
2259
+ /* @__PURE__ */ React88__namespace.default.createElement(
2260
+ react.Box,
2261
+ {
2262
+ as: "label",
2263
+ name,
2264
+ htmlFor: inputId,
2265
+ "aria-checked": isChecked,
2266
+ "data-checked": isChecked,
2267
+ "data-disabled": isDisabled,
2268
+ ...props,
2269
+ __css: {
2270
+ ...styles3.container,
2271
+ ...isChecked && styles3.checked,
2272
+ ...isFocused && !isChecked && styles3.focused,
2273
+ ...isChecked && isFocused && styles3.focusedChecked
2274
+ }
2275
+ },
2276
+ children
2277
+ )
2278
+ );
2267
2279
  }
2268
2280
  );
2269
2281
  }
@@ -5192,7 +5204,8 @@ var init_FullScreenDrawer = __esm({
5192
5204
  leftButton = null,
5193
5205
  rightButton = /* @__PURE__ */ React88__namespace.default.createElement(DrawerCloseButton2, null),
5194
5206
  isOpen,
5195
- onClose
5207
+ onClose,
5208
+ body
5196
5209
  }) => {
5197
5210
  const [isContentBoxScrolled, setContentBoxScrolled] = React88.useState(false);
5198
5211
  const onContentScroll = (e) => {
@@ -5223,7 +5236,7 @@ var init_FullScreenDrawer = __esm({
5223
5236
  rightButton
5224
5237
  }
5225
5238
  ),
5226
- /* @__PURE__ */ React88__namespace.default.createElement(react.DrawerBody, { overflow: "auto", onScroll: onContentScroll }, children)
5239
+ /* @__PURE__ */ React88__namespace.default.createElement(react.DrawerBody, { overflow: "auto", onScroll: onContentScroll, ...body }, children)
5227
5240
  ));
5228
5241
  };
5229
5242
  DrawerTopMenu = ({
@@ -5318,9 +5331,10 @@ var init_SimpleDrawer = __esm({
5318
5331
  placement,
5319
5332
  children,
5320
5333
  title,
5334
+ body,
5321
5335
  ...props
5322
5336
  }) => {
5323
- return /* @__PURE__ */ React88__namespace.default.createElement(exports.Drawer, { placement, ...props }, /* @__PURE__ */ React88__namespace.default.createElement(react.DrawerOverlay, null), /* @__PURE__ */ React88__namespace.default.createElement(exports.DrawerContent, null, /* @__PURE__ */ React88__namespace.default.createElement(react.DrawerCloseButton, null), title && /* @__PURE__ */ React88__namespace.default.createElement(exports.ModalHeader, null, title), /* @__PURE__ */ React88__namespace.default.createElement(react.DrawerBody, null, children)));
5337
+ return /* @__PURE__ */ React88__namespace.default.createElement(exports.Drawer, { placement, ...props }, /* @__PURE__ */ React88__namespace.default.createElement(react.DrawerOverlay, null), /* @__PURE__ */ React88__namespace.default.createElement(exports.DrawerContent, null, /* @__PURE__ */ React88__namespace.default.createElement(react.DrawerCloseButton, null), title && /* @__PURE__ */ React88__namespace.default.createElement(exports.ModalHeader, null, title), /* @__PURE__ */ React88__namespace.default.createElement(react.DrawerBody, { ...body }, children)));
5324
5338
  };
5325
5339
  }
5326
5340
  });
@@ -15034,20 +15048,23 @@ var init_radio_card = __esm({
15034
15048
  "src/theme/components/radio-card.ts"() {
15035
15049
  init_base_utils();
15036
15050
  init_floating_utils();
15037
- init_focus_utils();
15038
15051
  init_outline_utils();
15039
- parts17 = themeTools.anatomy("radio-card").parts("container", "checked", "radioInput");
15052
+ parts17 = themeTools.anatomy("radio-card").parts(
15053
+ "container",
15054
+ "checked",
15055
+ "radioInput",
15056
+ "focused",
15057
+ "focusedChecked"
15058
+ );
15040
15059
  helpers24 = react.createMultiStyleConfigHelpers(parts17.keys);
15041
15060
  config33 = helpers24.defineMultiStyleConfig({
15042
15061
  baseStyle: (props) => ({
15043
15062
  container: {
15044
- border: "none",
15045
15063
  overflow: "hidden",
15046
15064
  fontSize: "inherit",
15047
15065
  display: "block",
15048
15066
  cursor: "pointer",
15049
15067
  borderRadius: "sm",
15050
- ...focusVisibleStyles(props),
15051
15068
  transitionProperty: "common",
15052
15069
  transitionDuration: "fast",
15053
15070
  _disabled: {
@@ -15082,9 +15099,6 @@ var init_radio_card = __esm({
15082
15099
  _active: {
15083
15100
  ...baseBackground("active", props),
15084
15101
  ...baseBorder("active", props)
15085
- },
15086
- _focus: {
15087
- ...outlineBorder("focus", props)
15088
15102
  }
15089
15103
  },
15090
15104
  checked: {
@@ -15094,12 +15108,23 @@ var init_radio_card = __esm({
15094
15108
  _active: {
15095
15109
  ...baseBackground("active", props),
15096
15110
  ...baseBorder("active", props)
15097
- },
15098
- _focus: {
15099
- outline: "4px solid",
15100
- outlineStyle: "double",
15101
- ...outlineBorder("focus", props),
15102
- outlineOffset: "-1px"
15111
+ }
15112
+ },
15113
+ focusedChecked: {
15114
+ outline: "4px solid",
15115
+ outlineStyle: "double",
15116
+ ...outlineBorder("focus", props),
15117
+ outlineOffset: "-1px"
15118
+ },
15119
+ focused: {
15120
+ outline: "2px solid",
15121
+ ...outlineBorder("focus", props),
15122
+ outlineOffset: "1px",
15123
+ boxShadow: `inset 0 0 0 1px rgba(0, 0, 0, 0.40)`,
15124
+ _hover: {
15125
+ ...baseBorder("hover", props),
15126
+ boxShadow: "none",
15127
+ outlineOffset: "0px"
15103
15128
  }
15104
15129
  }
15105
15130
  }),
@@ -15116,9 +15141,6 @@ var init_radio_card = __esm({
15116
15141
  _active: {
15117
15142
  ...floatingBackground("active", props),
15118
15143
  ...floatingBorder("active", props)
15119
- },
15120
- _focus: {
15121
- ...outlineBorder("focus", props)
15122
15144
  }
15123
15145
  },
15124
15146
  checked: {
@@ -15129,12 +15151,23 @@ var init_radio_card = __esm({
15129
15151
  _active: {
15130
15152
  ...floatingBackground("active", props),
15131
15153
  ...floatingBorder("active", props)
15132
- },
15133
- _focus: {
15134
- outline: "4px solid",
15135
- outlineStyle: "double",
15136
- ...outlineBorder("focus", props),
15137
- outlineOffset: "-1px"
15154
+ }
15155
+ },
15156
+ focusedChecked: {
15157
+ outline: "4px solid",
15158
+ outlineStyle: "double",
15159
+ ...outlineBorder("focus", props),
15160
+ outlineOffset: "-1px"
15161
+ },
15162
+ focused: {
15163
+ outline: "2px solid",
15164
+ ...outlineBorder("focus", props),
15165
+ outlineOffset: "1px",
15166
+ boxShadow: `inset 0 0 0 1px rgba(0, 0, 0, 0.10)`,
15167
+ _hover: {
15168
+ ...floatingBorder("hover", props),
15169
+ boxShadow: "md",
15170
+ outlineOffset: "0px"
15138
15171
  }
15139
15172
  }
15140
15173
  })
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- export { Accordion, AccordionButton, AccordionIcon, AccordionItem, AccordionPanel, AttachedInputs, Badge, Box, Brand, Breadcrumb, BreadcrumbItem, BreadcrumbLink, 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, FullScreenDrawer, 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, ListItem, Modal, ModalBody, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalOverlay, NativeSelect, Nudge, NumericStepper, OrderedList, Pagination, PasswordInput, PhoneNumberInput, PlayPauseButton, Portal, PressableCard, PrideProvider, ProgressBar, ProgressIndicator, ProgressLoader, Radio, RadioCard, RadioCardGroup, RadioCardGroupContext, RadioGroup, ScaleFade, SearchInput, Section, SimpleDrawer, SimpleGrid, Skeleton, SkeletonCircle, SkeletonText, SkipButton, Slide, SlideFade, Spacer, SporProvider, Stack, StaticAlert, StaticCard, Stepper, StepperStep, Switch, Tab, TabList, TabPanel, TabPanels, Table, TableCaption, Tabs, Tbody, Td, Text, TextLink, Textarea, Tfoot, Th, Thead, Time, TimePicker, TogglePride, Tooltip, Tr, TravelTag, UnorderedList, VStack, VyLogo, VyLogoDefault, VyLogoPride, WizardNudge, Wrap, WrapItem, brandTheme, createTexts, defineStyleConfig, extendTheme, fontFaces, slugify, theme, tokens, useBreakpointValue, useClipboard, useColorMode, useColorModePreference, useColorModeValue, useControllableProp, useDisclosure, useMediaQuery, useMergeRefs, useOutsideClick, usePrefersReducedMotion, usePride, useSize, useTheme, useToast, useToken, useTranslation } from './chunk-KJYJYQBK.mjs';
1
+ export { Accordion, AccordionButton, AccordionIcon, AccordionItem, AccordionPanel, AttachedInputs, Badge, Box, Brand, Breadcrumb, BreadcrumbItem, BreadcrumbLink, 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, FullScreenDrawer, 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, ListItem, Modal, ModalBody, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalOverlay, NativeSelect, Nudge, NumericStepper, OrderedList, Pagination, PasswordInput, PhoneNumberInput, PlayPauseButton, Portal, PressableCard, PrideProvider, ProgressBar, ProgressIndicator, ProgressLoader, Radio, RadioCard, RadioCardGroup, RadioCardGroupContext, RadioGroup, ScaleFade, SearchInput, Section, SimpleDrawer, SimpleGrid, Skeleton, SkeletonCircle, SkeletonText, SkipButton, Slide, SlideFade, Spacer, SporProvider, Stack, StaticAlert, StaticCard, Stepper, StepperStep, Switch, Tab, TabList, TabPanel, TabPanels, Table, TableCaption, Tabs, Tbody, Td, Text, TextLink, Textarea, Tfoot, Th, Thead, Time, TimePicker, TogglePride, Tooltip, Tr, TravelTag, UnorderedList, VStack, VyLogo, VyLogoDefault, VyLogoPride, WizardNudge, Wrap, WrapItem, brandTheme, createTexts, defineStyleConfig, extendTheme, fontFaces, slugify, theme, tokens, useBreakpointValue, useClipboard, useColorMode, useColorModePreference, useColorModeValue, useControllableProp, useDisclosure, useMediaQuery, useMergeRefs, useOutsideClick, usePrefersReducedMotion, usePride, useSize, useTheme, useToast, useToken, useTranslation } from './chunk-UOSLFTBE.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vygruppen/spor-react",
3
- "version": "9.13.0",
3
+ "version": "9.13.2",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -5,7 +5,7 @@ import {
5
5
  forwardRef,
6
6
  useMultiStyleConfig,
7
7
  } from "@chakra-ui/react";
8
- import React, { useContext, useEffect, useId } from "react";
8
+ import React, { useContext, useEffect, useId, useState } from "react";
9
9
  import { RadioCardGroupContext } from "./RadioCardGroup";
10
10
 
11
11
  /**
@@ -38,7 +38,7 @@ export type RadioCardProps = BoxProps & {
38
38
  };
39
39
 
40
40
  export const RadioCard = forwardRef(
41
- ({ children, value = "base", isDisabled, ...props }: RadioCardProps, ref) => {
41
+ ({ children, value, isDisabled, ...props }: RadioCardProps, ref) => {
42
42
  const context = useContext(RadioCardGroupContext);
43
43
 
44
44
  if (!context) {
@@ -51,55 +51,69 @@ export const RadioCard = forwardRef(
51
51
 
52
52
  const styles = useMultiStyleConfig("RadioCard", { variant });
53
53
 
54
+ const [isKeyboardUser, setKeyboardUser] = useState(false);
55
+ const [isFocused, setFocus] = useState(false);
56
+
54
57
  const isChecked = selectedValue === value;
55
58
 
56
- const radioCardId = `radio-card-${useId()}`;
59
+ useEffect(() => {
60
+ const handleMouseDown = () => setKeyboardUser(false);
61
+ const handleKeyDown = (event: KeyboardEvent) => {
62
+ if (event.key === " ") {
63
+ setFocus(false);
64
+ } else {
65
+ setKeyboardUser(true);
66
+ }
67
+ };
68
+
69
+ window.addEventListener("mousedown", handleMouseDown);
70
+ window.addEventListener("keydown", handleKeyDown);
71
+
72
+ return () => {
73
+ window.removeEventListener("mousedown", handleMouseDown);
74
+ window.removeEventListener("keydown", handleKeyDown);
75
+ };
76
+ }, []);
57
77
 
58
78
  useEffect(() => {
59
- if (isChecked && typeof ref !== "function" && ref?.current) {
60
- ref.current.focus();
79
+ if (isKeyboardUser && isChecked) {
80
+ setFocus(true);
81
+ } else {
82
+ setFocus(false);
61
83
  }
62
- }, [isChecked]);
84
+ }, [isKeyboardUser, isChecked]);
63
85
 
64
- const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {
65
- if (event.key === "Enter" || event.key === " ") {
66
- onChange(value);
67
- }
68
- if (
69
- event.key === "ArrowRight" ||
70
- event.key === "ArrowDown" ||
71
- event.key === "ArrowLeft" ||
72
- event.key === "ArrowUp"
73
- ) {
74
- const nextRadioCard = event.currentTarget
75
- .nextElementSibling as HTMLElement;
76
- nextRadioCard.focus();
77
- }
78
- };
86
+ const inputId = `radio-card-${useId()}`;
79
87
 
80
88
  return (
81
- <Box as="label" aria-label={String(children)} onKeyDown={handleKeyDown}>
89
+ <Box
90
+ onFocus={() => isKeyboardUser && setFocus(true)}
91
+ onBlur={() => setFocus(false)}
92
+ >
82
93
  <chakra.input
83
94
  type="radio"
84
- id={radioCardId}
85
- ref={ref}
86
- value={value}
95
+ id={inputId}
87
96
  name={name}
97
+ ref={ref}
88
98
  checked={isChecked}
89
99
  onChange={() => onChange(value)}
90
100
  disabled={isDisabled}
91
101
  __css={styles.radioInput}
92
102
  />
93
103
  <Box
94
- {...props}
95
- tabIndex={0}
96
- ref={ref}
97
- role="radio"
104
+ as="label"
105
+ name={name}
106
+ htmlFor={inputId}
98
107
  aria-checked={isChecked}
99
- aria-labelledby={radioCardId}
100
- __css={{ ...styles.container, ...(isChecked && styles.checked) }}
101
108
  data-checked={isChecked}
102
109
  data-disabled={isDisabled}
110
+ {...props}
111
+ __css={{
112
+ ...styles.container,
113
+ ...(isChecked && styles.checked),
114
+ ...(isFocused && !isChecked && styles.focused),
115
+ ...(isChecked && isFocused && styles.focusedChecked),
116
+ }}
103
117
  >
104
118
  {children}
105
119
  </Box>