@vygruppen/spor-react 9.13.1 → 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 & {
@@ -1966,31 +1967,17 @@ type DrawerProps = DrawerProps$1;
1966
1967
  declare const Drawer: (props: DrawerProps) => React.JSX.Element;
1967
1968
  declare const DrawerContent: _chakra_ui_system_dist_system_types.ComponentWithAs<any, DrawerContentProps>;
1968
1969
 
1969
- type DrawerPlacement = "top" | "right" | "bottom" | "left";
1970
- type FullScreenDrawerProps = {
1971
- /** The content inside the drawer */
1972
- children: React.ReactNode;
1973
- /** The title in the middle of the top menu */
1974
- title?: String;
1975
- /** Determines which side the drawer slides from */
1976
- placement?: DrawerPlacement;
1977
- /** A React component that will be placed to the left in the modal header */
1978
- leftButton?: React.ReactNode;
1979
- /** A React component that will be placed to the right in the modal header */
1980
- rightButton?: React.ReactNode;
1981
- /** Determines if the drawer is open or closed */
1982
- isOpen: boolean;
1983
- /** Function that will be called when the drawer closes */
1984
- onClose: () => void;
1970
+ type DrawerBodyProps = {
1971
+ id?: string;
1985
1972
  };
1986
- declare const FullScreenDrawer: ({ children, title, placement, leftButton, rightButton, isOpen, onClose, }: FullScreenDrawerProps) => React.JSX.Element;
1987
-
1988
1973
  type SimpleDrawerProps = {
1989
1974
  children: React.ReactNode;
1990
1975
  title?: React.ReactNode;
1991
1976
  placement: "top" | "right" | "bottom" | "left";
1992
1977
  isOpen: boolean;
1993
1978
  onClose: () => void;
1979
+ /** Props for drawer body */
1980
+ body?: DrawerBodyProps;
1994
1981
  };
1995
1982
  /** A very basic drawer component that's easy to use
1996
1983
  *
@@ -2002,7 +1989,28 @@ type SimpleDrawerProps = {
2002
1989
  *
2003
1990
  * For more advanced use cases, see the [Drawer](./Drawer.tsx) component.
2004
1991
  */
2005
- 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;
2006
2014
 
2007
2015
  type TooltipProps = PopoverProps & {
2008
2016
  /**
@@ -5908,6 +5916,11 @@ declare const theme: {
5908
5916
  RadioCard: {
5909
5917
  baseStyle?: ((props: any) => {
5910
5918
  container: {
5919
+ overflow: string;
5920
+ fontSize: string;
5921
+ display: string;
5922
+ cursor: string;
5923
+ borderRadius: string;
5911
5924
  transitionProperty: string;
5912
5925
  transitionDuration: string;
5913
5926
  _disabled: {
@@ -5925,18 +5938,6 @@ declare const theme: {
5925
5938
  backgroundColor: string;
5926
5939
  pointerEvents: string;
5927
5940
  };
5928
- _focusVisible: {
5929
- outlineWidth: string;
5930
- outlineColor: string;
5931
- outlineStyle: string;
5932
- outlineOffset: string;
5933
- };
5934
- border: string;
5935
- overflow: string;
5936
- fontSize: string;
5937
- display: string;
5938
- cursor: string;
5939
- borderRadius: string;
5940
5941
  };
5941
5942
  checked: {
5942
5943
  backgroundColor: string;
@@ -5952,7 +5953,7 @@ declare const theme: {
5952
5953
  }) | undefined;
5953
5954
  sizes?: {
5954
5955
  [key: string]: _chakra_ui_styled_system.PartsStyleInterpolation<{
5955
- keys: ("container" | "checked" | "radioInput")[];
5956
+ keys: ("container" | "checked" | "radioInput" | "focused" | "focusedChecked")[];
5956
5957
  }>;
5957
5958
  } | undefined;
5958
5959
  variants?: {
@@ -5980,9 +5981,6 @@ declare const theme: {
5980
5981
  outlineColor: string;
5981
5982
  backgroundColor: string;
5982
5983
  };
5983
- _focus: {
5984
- outlineColor: string;
5985
- };
5986
5984
  outlineWidth: string;
5987
5985
  outlineColor: string;
5988
5986
  outlineStyle: string;
@@ -6012,9 +6010,6 @@ declare const theme: {
6012
6010
  outlineColor: string;
6013
6011
  backgroundColor: string;
6014
6012
  };
6015
- _focus: {
6016
- outlineColor: string;
6017
- };
6018
6013
  outline: string;
6019
6014
  outlineColor: string;
6020
6015
  backgroundColor: string;
@@ -6041,12 +6036,30 @@ declare const theme: {
6041
6036
  outlineColor: string;
6042
6037
  backgroundColor: string;
6043
6038
  };
6044
- _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;
6045
6051
  outlineOffset: string;
6052
+ outlineWidth: string;
6046
6053
  outlineColor: string;
6047
- outline: string;
6048
6054
  outlineStyle: string;
6055
+ } | {
6056
+ boxShadow: string;
6057
+ outlineOffset: string;
6058
+ outline: string;
6059
+ outlineColor: string;
6049
6060
  };
6061
+ outlineColor: string;
6062
+ outline: string;
6050
6063
  };
6051
6064
  };
6052
6065
  floating: (props: _chakra_ui_styled_system.StyleFunctionProps) => {
@@ -6063,9 +6076,6 @@ declare const theme: {
6063
6076
  outlineColor: string;
6064
6077
  backgroundColor: string;
6065
6078
  };
6066
- _focus: {
6067
- outlineColor: string;
6068
- };
6069
6079
  outline: string;
6070
6080
  outlineColor: string;
6071
6081
  backgroundColor: string;
@@ -6081,12 +6091,24 @@ declare const theme: {
6081
6091
  outlineColor: string;
6082
6092
  backgroundColor: string;
6083
6093
  };
6084
- _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;
6085
6106
  outlineOffset: string;
6086
- outlineColor: string;
6087
6107
  outline: string;
6088
- outlineStyle: string;
6108
+ outlineColor: string;
6089
6109
  };
6110
+ outlineColor: string;
6111
+ outline: string;
6090
6112
  };
6091
6113
  };
6092
6114
  } | undefined;
@@ -6095,7 +6117,7 @@ declare const theme: {
6095
6117
  variant?: "base" | "floating" | undefined;
6096
6118
  colorScheme?: string | undefined;
6097
6119
  } | undefined;
6098
- parts: ("container" | "checked" | "radioInput")[];
6120
+ parts: ("container" | "checked" | "radioInput" | "focused" | "focusedChecked")[];
6099
6121
  };
6100
6122
  Radio: {
6101
6123
  baseStyle?: ((props: _chakra_ui_styled_system.StyleFunctionProps) => {
@@ -9550,4 +9572,4 @@ declare const Text: _chakra_ui_system_dist_system_types.ComponentWithAs<"p", Tex
9550
9572
  **/
9551
9573
  declare function slugify(text: string | string[], maxLength?: number): string;
9552
9574
 
9553
- 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
@@ -2191,19 +2191,7 @@ var init_RadioCardGroup = __esm({
2191
2191
  defaultValue: defaultValue || ""
2192
2192
  }
2193
2193
  },
2194
- /* @__PURE__ */ React88__namespace.default.createElement(
2195
- react.Stack,
2196
- {
2197
- as: "fieldset",
2198
- direction: direction2,
2199
- "aria-labelledby": groupLabel || name,
2200
- role: "radiogroup",
2201
- tabIndex: 0,
2202
- ...props
2203
- },
2204
- groupLabel && /* @__PURE__ */ React88__namespace.default.createElement(exports.FormLabel, { as: "legend", id: groupLabel }, groupLabel),
2205
- children
2206
- )
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)
2207
2195
  );
2208
2196
  };
2209
2197
  }
@@ -2213,7 +2201,7 @@ var init_RadioCard = __esm({
2213
2201
  "src/layout/RadioCard.tsx"() {
2214
2202
  init_RadioCardGroup();
2215
2203
  exports.RadioCard = react.forwardRef(
2216
- ({ children, value = "base", isDisabled, ...props }, ref) => {
2204
+ ({ children, value, isDisabled, ...props }, ref) => {
2217
2205
  const context = React88.useContext(exports.RadioCardGroupContext);
2218
2206
  if (!context) {
2219
2207
  throw new Error(
@@ -2222,52 +2210,72 @@ var init_RadioCard = __esm({
2222
2210
  }
2223
2211
  const { name, selectedValue, onChange, variant } = context;
2224
2212
  const styles3 = react.useMultiStyleConfig("RadioCard", { variant });
2213
+ const [isKeyboardUser, setKeyboardUser] = React88.useState(false);
2214
+ const [isFocused, setFocus] = React88.useState(false);
2225
2215
  const isChecked = selectedValue === value;
2226
- const radioCardId = `radio-card-${React88.useId()}`;
2227
2216
  React88.useEffect(() => {
2228
- if (isChecked && typeof ref !== "function" && (ref == null ? void 0 : ref.current)) {
2229
- ref.current.focus();
2230
- }
2231
- }, [isChecked]);
2232
- const handleKeyDown = (event) => {
2233
- if (event.key === "Enter" || event.key === " ") {
2234
- onChange(value);
2235
- }
2236
- if (event.key === "ArrowRight" || event.key === "ArrowDown" || event.key === "ArrowLeft" || event.key === "ArrowUp") {
2237
- const nextRadioCard = event.currentTarget.nextElementSibling;
2238
- if (nextRadioCard) {
2239
- nextRadioCard.focus();
2217
+ const handleMouseDown = () => setKeyboardUser(false);
2218
+ const handleKeyDown = (event) => {
2219
+ if (event.key === " ") {
2220
+ setFocus(false);
2221
+ } else {
2222
+ setKeyboardUser(true);
2240
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);
2241
2237
  }
2242
- };
2243
- return /* @__PURE__ */ React88__namespace.default.createElement(react.Box, { as: "label", "aria-label": String(children), onKeyDown: handleKeyDown }, /* @__PURE__ */ React88__namespace.default.createElement(
2244
- react.chakra.input,
2245
- {
2246
- type: "radio",
2247
- id: radioCardId,
2248
- ref,
2249
- value,
2250
- name,
2251
- checked: isChecked,
2252
- onChange: () => onChange(value),
2253
- disabled: isDisabled,
2254
- __css: styles3.radioInput
2255
- }
2256
- ), /* @__PURE__ */ React88__namespace.default.createElement(
2238
+ }, [isKeyboardUser, isChecked]);
2239
+ const inputId = `radio-card-${React88.useId()}`;
2240
+ return /* @__PURE__ */ React88__namespace.default.createElement(
2257
2241
  react.Box,
2258
2242
  {
2259
- ...props,
2260
- tabIndex: 0,
2261
- ref,
2262
- role: "radio",
2263
- "aria-checked": isChecked,
2264
- "aria-labelledby": radioCardId,
2265
- __css: { ...styles3.container, ...isChecked && styles3.checked },
2266
- "data-checked": isChecked,
2267
- "data-disabled": isDisabled
2243
+ onFocus: () => isKeyboardUser && setFocus(true),
2244
+ onBlur: () => setFocus(false)
2268
2245
  },
2269
- children
2270
- ));
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
+ );
2271
2279
  }
2272
2280
  );
2273
2281
  }
@@ -5196,7 +5204,8 @@ var init_FullScreenDrawer = __esm({
5196
5204
  leftButton = null,
5197
5205
  rightButton = /* @__PURE__ */ React88__namespace.default.createElement(DrawerCloseButton2, null),
5198
5206
  isOpen,
5199
- onClose
5207
+ onClose,
5208
+ body
5200
5209
  }) => {
5201
5210
  const [isContentBoxScrolled, setContentBoxScrolled] = React88.useState(false);
5202
5211
  const onContentScroll = (e) => {
@@ -5227,7 +5236,7 @@ var init_FullScreenDrawer = __esm({
5227
5236
  rightButton
5228
5237
  }
5229
5238
  ),
5230
- /* @__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)
5231
5240
  ));
5232
5241
  };
5233
5242
  DrawerTopMenu = ({
@@ -5322,9 +5331,10 @@ var init_SimpleDrawer = __esm({
5322
5331
  placement,
5323
5332
  children,
5324
5333
  title,
5334
+ body,
5325
5335
  ...props
5326
5336
  }) => {
5327
- 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)));
5328
5338
  };
5329
5339
  }
5330
5340
  });
@@ -15038,20 +15048,23 @@ var init_radio_card = __esm({
15038
15048
  "src/theme/components/radio-card.ts"() {
15039
15049
  init_base_utils();
15040
15050
  init_floating_utils();
15041
- init_focus_utils();
15042
15051
  init_outline_utils();
15043
- 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
+ );
15044
15059
  helpers24 = react.createMultiStyleConfigHelpers(parts17.keys);
15045
15060
  config33 = helpers24.defineMultiStyleConfig({
15046
15061
  baseStyle: (props) => ({
15047
15062
  container: {
15048
- border: "none",
15049
15063
  overflow: "hidden",
15050
15064
  fontSize: "inherit",
15051
15065
  display: "block",
15052
15066
  cursor: "pointer",
15053
15067
  borderRadius: "sm",
15054
- ...focusVisibleStyles(props),
15055
15068
  transitionProperty: "common",
15056
15069
  transitionDuration: "fast",
15057
15070
  _disabled: {
@@ -15086,9 +15099,6 @@ var init_radio_card = __esm({
15086
15099
  _active: {
15087
15100
  ...baseBackground("active", props),
15088
15101
  ...baseBorder("active", props)
15089
- },
15090
- _focus: {
15091
- ...outlineBorder("focus", props)
15092
15102
  }
15093
15103
  },
15094
15104
  checked: {
@@ -15098,12 +15108,23 @@ var init_radio_card = __esm({
15098
15108
  _active: {
15099
15109
  ...baseBackground("active", props),
15100
15110
  ...baseBorder("active", props)
15101
- },
15102
- _focus: {
15103
- outline: "4px solid",
15104
- outlineStyle: "double",
15105
- ...outlineBorder("focus", props),
15106
- 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"
15107
15128
  }
15108
15129
  }
15109
15130
  }),
@@ -15120,9 +15141,6 @@ var init_radio_card = __esm({
15120
15141
  _active: {
15121
15142
  ...floatingBackground("active", props),
15122
15143
  ...floatingBorder("active", props)
15123
- },
15124
- _focus: {
15125
- ...outlineBorder("focus", props)
15126
15144
  }
15127
15145
  },
15128
15146
  checked: {
@@ -15133,12 +15151,23 @@ var init_radio_card = __esm({
15133
15151
  _active: {
15134
15152
  ...floatingBackground("active", props),
15135
15153
  ...floatingBorder("active", props)
15136
- },
15137
- _focus: {
15138
- outline: "4px solid",
15139
- outlineStyle: "double",
15140
- ...outlineBorder("focus", props),
15141
- 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"
15142
15171
  }
15143
15172
  }
15144
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-NMEIV2NI.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.1",
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,57 +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
- if (nextRadioCard) {
77
- nextRadioCard.focus();
78
- }
79
- }
80
- };
86
+ const inputId = `radio-card-${useId()}`;
81
87
 
82
88
  return (
83
- <Box as="label" aria-label={String(children)} onKeyDown={handleKeyDown}>
89
+ <Box
90
+ onFocus={() => isKeyboardUser && setFocus(true)}
91
+ onBlur={() => setFocus(false)}
92
+ >
84
93
  <chakra.input
85
94
  type="radio"
86
- id={radioCardId}
87
- ref={ref}
88
- value={value}
95
+ id={inputId}
89
96
  name={name}
97
+ ref={ref}
90
98
  checked={isChecked}
91
99
  onChange={() => onChange(value)}
92
100
  disabled={isDisabled}
93
101
  __css={styles.radioInput}
94
102
  />
95
103
  <Box
96
- {...props}
97
- tabIndex={0}
98
- ref={ref}
99
- role="radio"
104
+ as="label"
105
+ name={name}
106
+ htmlFor={inputId}
100
107
  aria-checked={isChecked}
101
- aria-labelledby={radioCardId}
102
- __css={{ ...styles.container, ...(isChecked && styles.checked) }}
103
108
  data-checked={isChecked}
104
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
+ }}
105
117
  >
106
118
  {children}
107
119
  </Box>
@@ -1,7 +1,6 @@
1
1
  import { BoxProps, Stack } from "@chakra-ui/react";
2
2
  import React, { useState } from "react";
3
3
  import { FormLabel } from "../input";
4
- import { RadioCard } from "./RadioCard";
5
4
 
6
5
  /**
7
6
  * RadioCardGroupContext is used to pass down the state and handlers to the RadioCard components.
@@ -15,6 +14,7 @@ type RadioGroupContextProps = {
15
14
  onChange: (value: string) => void;
16
15
  variant?: "base" | "floating";
17
16
  defaultValue?: string;
17
+ value?: string;
18
18
  };
19
19
 
20
20
  export const RadioCardGroupContext =
@@ -59,14 +59,7 @@ export const RadioCardGroup: React.FC<RadioCardGroupProps> = ({
59
59
  defaultValue: defaultValue || "",
60
60
  }}
61
61
  >
62
- <Stack
63
- as="fieldset"
64
- direction={direction}
65
- aria-labelledby={groupLabel || name}
66
- role="radiogroup"
67
- tabIndex={0}
68
- {...props}
69
- >
62
+ <Stack as="fieldset" direction={direction} {...props}>
70
63
  {groupLabel && (
71
64
  <FormLabel as="legend" id={groupLabel}>
72
65
  {groupLabel}