@vygruppen/spor-react 2.3.4 → 2.4.1

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,19 +1,19 @@
1
- import { forwardRef, Accordion as Accordion$1, Skeleton as Skeleton$1, useButtonGroup, Button as Button$1, Box, Center, ButtonGroup as ButtonGroup$1, IconButton as IconButton$1, Stack as Stack$1, useStyleConfig, Badge as Badge$1, Code as Code$1, Text, useFormControlContext, useMultiStyleConfig, chakra, Flex, Checkbox as Checkbox$1, useCheckbox, FormControl as FormControl$1, FormLabel, InputGroup, InputLeftElement, Input as Input$1, InputRightElement, Select, useDisclosure, useControllableState, Radio as Radio$1, RadioGroup as RadioGroup$1, Switch as Switch$1, Textarea as Textarea$1, Link, ModalHeader as ModalHeader$1, useModalContext, DrawerContent as DrawerContent$1, Tabs as Tabs$1, Table as Table$1, defineStyleConfig as defineStyleConfig$1, createMultiStyleConfigHelpers as createMultiStyleConfigHelpers$1, AccordionItem, AccordionButton, AccordionIcon, AccordionPanel, SkeletonCircle as SkeletonCircle$1, SkeletonText as SkeletonText$1, useBreakpointValue, Popover, PopoverAnchor, Portal, PopoverContent, PopoverArrow, PopoverBody, Heading as Heading$1, CheckboxGroup as CheckboxGroup$1, useFormControl, useColorModeValue, useFormControlProps, Drawer as Drawer$1, DrawerOverlay, DrawerCloseButton, DrawerBody, usePopoverContext, DarkMode, PopoverTrigger, PopoverCloseButton, ChakraProvider, HStack, useToast as useToast$1, useInterval } from '@chakra-ui/react';
1
+ import { forwardRef, Accordion as Accordion$1, Skeleton as Skeleton$1, useButtonGroup, Button as Button$1, Box, Center, ButtonGroup as ButtonGroup$1, IconButton as IconButton$1, Stack as Stack$1, useStyleConfig, Badge as Badge$1, Code as Code$1, Text, useFormControlContext, useMultiStyleConfig, chakra, Flex, Checkbox as Checkbox$1, useCheckbox, FormControl as FormControl$1, FormLabel, InputGroup, InputLeftElement, Input as Input$1, InputRightElement, Select, useDisclosure, useControllableState, Radio as Radio$1, RadioGroup as RadioGroup$1, Switch as Switch$1, Textarea as Textarea$1, Link, ModalHeader as ModalHeader$1, useModalContext, DrawerContent as DrawerContent$1, Tabs as Tabs$1, Table as Table$1, defineStyleConfig as defineStyleConfig$1, createMultiStyleConfigHelpers as createMultiStyleConfigHelpers$1, AccordionItem, AccordionButton, AccordionIcon, AccordionPanel, SkeletonCircle as SkeletonCircle$1, SkeletonText as SkeletonText$1, useBreakpointValue, Popover, PopoverAnchor, Portal, PopoverContent, PopoverArrow, PopoverBody, Heading as Heading$1, CheckboxGroup as CheckboxGroup$1, List, ListItem, useColorModeValue, useFormControlProps, useFormControl, Drawer as Drawer$1, DrawerOverlay, DrawerCloseButton, DrawerBody, usePopoverContext, DarkMode, PopoverTrigger, PopoverCloseButton, ChakraProvider, HStack, useToast as useToast$1, useInterval } from '@chakra-ui/react';
2
2
  export { AccordionButton, AccordionIcon, AccordionItem, AccordionPanel, Box, Center, Collapse, Container, DarkMode, DrawerBody, DrawerCloseButton, DrawerFooter, DrawerOverlay, Fade, Flex, FormHelperText, Grid, GridItem, HStack, Image, Img, InputGroup, LightMode, Modal, ModalBody, ModalCloseButton, ModalContent, ModalFooter, ModalOverlay, Popover, PopoverAnchor, PopoverArrow, PopoverBody, PopoverCloseButton, PopoverContent, PopoverFooter, PopoverHeader, PopoverTrigger, ScaleFade, SimpleGrid, Slide, SlideFade, Spacer, Tab, TabList, TabPanel, TabPanels, TableCaption, Tbody, Td, Tfoot, Th, Thead, Tr, VStack, Wrap, WrapItem, extendTheme, useBreakpointValue, useClipboard, useColorMode, useColorModePreference, useColorModeValue, useControllableProp, useDisclosure, useMediaQuery, useMergeRefs, useOutsideClick, usePrefersReducedMotion, useTheme, useToken } from '@chakra-ui/react';
3
3
  import tokens10__default from '@vygruppen/spor-design-tokens';
4
4
  import * as tokens10 from '@vygruppen/spor-design-tokens';
5
5
  export { tokens10 as tokens };
6
6
  import * as React49 from 'react';
7
- import React49__default, { createContext, useRef, useState, useEffect, useId, Suspense, useCallback, useContext, useMemo } from 'react';
7
+ import React49__default, { createContext, forwardRef as forwardRef$1, useRef, useState, useEffect, useId, Suspense, useContext, useCallback, useMemo } from 'react';
8
8
  import { CloseFill30Icon, CloseFill24Icon, CloseFill18Icon, CloseOutline24Icon, SearchOutline24Icon, InformationFill24Icon, InformationFill18Icon, WarningFill24Icon, WarningFill18Icon, ErrorFill24Icon, ErrorFill18Icon, LinkOutOutline24Icon, CalendarOutline24Icon, DropdownLeftFill24Icon, DropdownRightFill24Icon, DropdownDownFill18Icon, DropdownDownFill24Icon, DropdownUpFill24Icon, ArrowRightFill18Icon, DropdownRightFill18Icon, ErrorOutline24Icon, AltTransportOutline24Icon, WarningOutline24Icon, SuccessOutline24Icon, InformationOutline24Icon, ArrowLeftOutline24Icon, ArrowRightOutline24Icon, TrainFill18Icon, TrainFill24Icon, TrainFill30Icon, ExpressBusFill18Icon, ExpressBusFill24Icon, ExpressBusFill30Icon, BusFill18Icon, BusFill24Icon, BusFill30Icon, FerryFill18Icon, FerryFill24Icon, FerryFill30Icon, SubwayFill18Icon, SubwayFill24Icon, SubwayFill30Icon, TramFill18Icon, TramFill24Icon, TramFill30Icon, AltTransportFill18Icon, AltTransportFill24Icon, AltTransportFill30Icon, WalkFill18Icon, WalkFill24Icon, WalkFill30Icon } from '@vygruppen/spor-icon-react';
9
9
  import { inlineLoaderColorData, spinnerColorData, contentLoaderData, fullScreenLoaderWhiteData, inlineLoaderDarkData, spinnerDarkData, fullScreenLoaderBlackData, inlineLoaderLightData, spinnerLightData } from '@vygruppen/spor-loader';
10
10
  import { useLottie } from 'lottie-react';
11
- import { useOverlayTrigger, useButton, useListBox, useOption, useProgressBar, useDatePicker, I18nProvider, useDateRangePicker, useDialog, usePopover, Overlay, DismissButton, useSelect, HiddenSelect, useCalendar, useDateField, useRangeCalendar, useTimeField, useCalendarGrid, useDateSegment, useCalendarCell } from 'react-aria';
11
+ import { usePopover, Overlay, DismissButton, useOverlayTrigger, useButton, useProgressBar, useDatePicker, I18nProvider, useDateRangePicker, useDialog, useFilter, useComboBox, useListBox, useOption, useListBoxSection, useSelect, HiddenSelect, useCalendar, useDateField, useRangeCalendar, useTimeField, useCalendarGrid, useDateSegment, useCalendarCell } from 'react-aria';
12
12
  import { motion } from 'framer-motion';
13
13
  import { DateFormatter, parseTime, createCalendar, Time, toCalendarDate, toCalendarDateTime, toCalendar, getMinimumDayInMonth, getMinimumMonthInYear, today, startOfWeek, startOfMonth, endOfWeek, endOfMonth, isSameDay, getDayOfWeek, maxDate, minDate, isEqualDay, getWeeksInMonth, getLocalTimeZone, GregorianCalendar, now, startOfYear, isSameMonth, isToday } from '@internationalized/date';
14
14
  export { Time } from '@internationalized/date';
15
- import { useOverlayTriggerState, Item, useTimeFieldState, useSelectState } from 'react-stately';
16
- export { Item } from 'react-stately';
15
+ import { useOverlayTriggerState, useTimeFieldState, useAsyncList, useComboBoxState, Item, useSelectState } from 'react-stately';
16
+ export { Item, Section } from 'react-stately';
17
17
  import { useSwipeable } from 'react-swipeable';
18
18
  import { Global, keyframes } from '@emotion/react';
19
19
  import { cssVar as cssVar$1, calc as calc$1, mode, getColor, anatomy as anatomy$1, orient, transparentize, generateStripe, randomColor, isDark } from '@chakra-ui/theme-tools';
@@ -950,7 +950,7 @@ var DarkSpinner = ({
950
950
  maxWidth,
951
951
  ...props
952
952
  }) => {
953
- return /* @__PURE__ */ React49__default.createElement(Center, { flexDirection: "column", ...props }, /* @__PURE__ */ React49__default.createElement(Box, { width, maxWidth }, /* @__PURE__ */ React49__default.createElement(ClientOnly, null, () => /* @__PURE__ */ React49__default.createElement(Lottie, { animationData: spinnerDarkData }))), children && /* @__PURE__ */ React49__default.createElement(Box, { mt: 3, fontWeight: "bold" }, children));
953
+ return /* @__PURE__ */ React49__default.createElement(Center, { flexDirection: "column", ...props }, /* @__PURE__ */ React49__default.createElement(Box, { width, maxWidth }, /* @__PURE__ */ React49__default.createElement(ClientOnly, null, () => /* @__PURE__ */ React49__default.createElement(Lottie, { animationData: spinnerDarkData }))), children && /* @__PURE__ */ React49__default.createElement(Box, { marginTop: 3, fontWeight: "bold" }, children));
954
954
  };
955
955
  var LightFullScreenLoader = ({
956
956
  width,
@@ -4019,43 +4019,74 @@ var AttachedInputs = ({
4019
4019
  }
4020
4020
  );
4021
4021
  };
4022
+ function Autosuggest({
4023
+ label,
4024
+ fetcher,
4025
+ children,
4026
+ onSelectionChange,
4027
+ ...boxProps
4028
+ }) {
4029
+ const list2 = useAsyncList({
4030
+ async load({ filterText }) {
4031
+ return {
4032
+ items: await fetcher(filterText)
4033
+ };
4034
+ }
4035
+ });
4036
+ return /* @__PURE__ */ React49__default.createElement(
4037
+ Combobox,
4038
+ {
4039
+ label,
4040
+ items: list2.items,
4041
+ inputValue: list2.filterText,
4042
+ onInputChange: list2.setFilterText,
4043
+ isLoading: list2.isLoading,
4044
+ onSelectionChange,
4045
+ ...boxProps
4046
+ },
4047
+ children
4048
+ );
4049
+ }
4022
4050
  var Dialog = ({ title, children, ...props }) => {
4023
4051
  const ref = useRef(null);
4024
4052
  const { dialogProps, titleProps } = useDialog(props, ref);
4025
4053
  return /* @__PURE__ */ React49__default.createElement(Box, { ...dialogProps, ref, outline: "none" }, title && /* @__PURE__ */ React49__default.createElement(Heading$1, { as: "h3", ...titleProps }, title), children);
4026
4054
  };
4027
- var Popover3 = ({
4028
- children,
4029
- state: state2,
4030
- triggerRef,
4031
- offset = 0,
4032
- crossOffset = 0,
4033
- placement = "bottom"
4034
- }) => {
4035
- var _a6;
4036
- const popoverRef = useRef(null);
4037
- const { popoverProps, underlayProps } = usePopover(
4038
- {
4039
- triggerRef,
4040
- popoverRef,
4041
- offset,
4042
- crossOffset,
4043
- placement
4044
- },
4045
- state2
4046
- );
4047
- return /* @__PURE__ */ React49__default.createElement(Overlay, null, /* @__PURE__ */ React49__default.createElement(Box, { ...underlayProps, position: "fixed", inset: "0" }), /* @__PURE__ */ React49__default.createElement(
4048
- Box,
4049
- {
4050
- ...popoverProps,
4051
- ref: popoverRef,
4052
- minWidth: ((_a6 = triggerRef.current) == null ? void 0 : _a6.clientWidth) ?? "auto"
4053
- },
4054
- /* @__PURE__ */ React49__default.createElement(DismissButton, { onDismiss: state2.close }),
4055
+ var Popover3 = forwardRef$1(
4056
+ ({
4055
4057
  children,
4056
- /* @__PURE__ */ React49__default.createElement(DismissButton, { onDismiss: state2.close })
4057
- ));
4058
- };
4058
+ state: state2,
4059
+ triggerRef,
4060
+ offset = 0,
4061
+ crossOffset = 0,
4062
+ placement = "bottom"
4063
+ }, ref) => {
4064
+ var _a6;
4065
+ const internalRef = useRef(null);
4066
+ const popoverRef = ref ?? internalRef;
4067
+ const { popoverProps, underlayProps } = usePopover(
4068
+ {
4069
+ triggerRef,
4070
+ popoverRef,
4071
+ offset,
4072
+ crossOffset,
4073
+ placement
4074
+ },
4075
+ state2
4076
+ );
4077
+ return /* @__PURE__ */ React49__default.createElement(Overlay, null, /* @__PURE__ */ React49__default.createElement(Box, { ...underlayProps, position: "fixed", inset: "0" }), /* @__PURE__ */ React49__default.createElement(
4078
+ Box,
4079
+ {
4080
+ ...popoverProps,
4081
+ ref: popoverRef,
4082
+ minWidth: ((_a6 = triggerRef.current) == null ? void 0 : _a6.clientWidth) ?? "auto"
4083
+ },
4084
+ /* @__PURE__ */ React49__default.createElement(DismissButton, { onDismiss: state2.close }),
4085
+ children,
4086
+ /* @__PURE__ */ React49__default.createElement(DismissButton, { onDismiss: state2.close })
4087
+ ));
4088
+ }
4089
+ );
4059
4090
 
4060
4091
  // src/input/CardSelect.tsx
4061
4092
  var CardSelect = forwardRef(
@@ -4188,6 +4219,370 @@ var ChoiceChip = forwardRef((props, ref) => {
4188
4219
  )
4189
4220
  );
4190
4221
  });
4222
+ function Combobox({
4223
+ label,
4224
+ isLoading,
4225
+ leftIcon,
4226
+ rightIcon,
4227
+ borderBottomLeftRadius = "sm",
4228
+ borderBottomRightRadius = "sm",
4229
+ borderTopLeftRadius = "sm",
4230
+ borderTopRightRadius = "sm",
4231
+ marginBottom,
4232
+ marginTop,
4233
+ marginX,
4234
+ marginY,
4235
+ paddingBottom,
4236
+ paddingRight,
4237
+ paddingTop,
4238
+ paddingLeft,
4239
+ paddingX,
4240
+ paddingY,
4241
+ onFocus,
4242
+ ...rest
4243
+ }) {
4244
+ const { contains: contains2 } = useFilter({ sensitivity: "base" });
4245
+ const state2 = useComboBoxState({
4246
+ ...rest,
4247
+ defaultFilter: contains2
4248
+ });
4249
+ const inputRef = useRef(null);
4250
+ const listBoxRef = useRef(null);
4251
+ const popoverRef = useRef(null);
4252
+ const {
4253
+ inputProps: { size: size2, ...inputProps },
4254
+ listBoxProps
4255
+ } = useComboBox(
4256
+ {
4257
+ ...rest,
4258
+ inputRef,
4259
+ listBoxRef,
4260
+ popoverRef
4261
+ },
4262
+ state2
4263
+ );
4264
+ return /* @__PURE__ */ React49__default.createElement(FormControl, null, /* @__PURE__ */ React49__default.createElement(
4265
+ Input,
4266
+ {
4267
+ ...inputProps,
4268
+ ref: inputRef,
4269
+ label,
4270
+ onFocus,
4271
+ borderBottomLeftRadius: state2.isOpen ? 0 : borderBottomLeftRadius,
4272
+ borderBottomRightRadius: state2.isOpen ? 0 : borderBottomRightRadius,
4273
+ borderTopLeftRadius,
4274
+ borderTopRightRadius,
4275
+ marginBottom,
4276
+ marginTop,
4277
+ marginX,
4278
+ marginY,
4279
+ paddingBottom,
4280
+ paddingRight,
4281
+ paddingTop,
4282
+ paddingLeft,
4283
+ paddingX,
4284
+ paddingY,
4285
+ leftIcon,
4286
+ rightIcon: isLoading ? /* @__PURE__ */ React49__default.createElement(
4287
+ ColorSpinner,
4288
+ {
4289
+ width: "1.5rem",
4290
+ alignSelf: "center",
4291
+ css: {
4292
+ div: {
4293
+ display: "flex",
4294
+ alignItems: "center"
4295
+ }
4296
+ }
4297
+ }
4298
+ ) : rightIcon
4299
+ }
4300
+ ), state2.isOpen && /* @__PURE__ */ React49__default.createElement(
4301
+ Popover3,
4302
+ {
4303
+ state: state2,
4304
+ triggerRef: inputRef,
4305
+ ref: popoverRef,
4306
+ placement: "bottom start"
4307
+ },
4308
+ /* @__PURE__ */ React49__default.createElement(
4309
+ ListBox,
4310
+ {
4311
+ ...listBoxProps,
4312
+ state: state2,
4313
+ listBoxRef,
4314
+ borderBottomRadius: "sm"
4315
+ },
4316
+ rest.children
4317
+ )
4318
+ ));
4319
+ }
4320
+ var FormControl = forwardRef((props, ref) => {
4321
+ return /* @__PURE__ */ React49__default.createElement(FormControl$1, { ...props, ref });
4322
+ });
4323
+ var FormErrorMessage = ({
4324
+ children,
4325
+ ...boxProps
4326
+ }) => {
4327
+ const formControlContext = useFormControlContext();
4328
+ if (!formControlContext) {
4329
+ throw new Error(
4330
+ "FormErrorMessage must be used within a FormControl component"
4331
+ );
4332
+ }
4333
+ if (!formControlContext.isInvalid) {
4334
+ return null;
4335
+ }
4336
+ const { ref, ...errorMessageProps } = formControlContext.getErrorMessageProps();
4337
+ return /* @__PURE__ */ React49__default.createElement(Box, { position: "relative", ref }, /* @__PURE__ */ React49__default.createElement(
4338
+ Box,
4339
+ {
4340
+ borderRadius: "xs",
4341
+ backgroundColor: "lightRed",
4342
+ color: "darkGrey",
4343
+ paddingX: 1.5,
4344
+ paddingY: 1,
4345
+ textStyle: "xs",
4346
+ width: "fit-content",
4347
+ position: "absolute",
4348
+ top: -0.5,
4349
+ left: 3,
4350
+ zIndex: "popover",
4351
+ maxWidth: "50ch",
4352
+ ...errorMessageProps,
4353
+ ...boxProps
4354
+ },
4355
+ /* @__PURE__ */ React49__default.createElement(Arrow, { position: "absolute", top: "-0.25em", left: "1em" }),
4356
+ children
4357
+ ));
4358
+ };
4359
+ var Arrow = (props) => {
4360
+ return /* @__PURE__ */ React49__default.createElement(
4361
+ Box,
4362
+ {
4363
+ ...props,
4364
+ as: "svg",
4365
+ width: "16",
4366
+ height: "16",
4367
+ viewBox: "0 0 16 16",
4368
+ fill: "none",
4369
+ transform: "rotate(45deg)"
4370
+ },
4371
+ /* @__PURE__ */ React49__default.createElement(
4372
+ Box,
4373
+ {
4374
+ as: "path",
4375
+ fill: "lightRed",
4376
+ d: "M 0\n 0 Q 2.4 6 0 12 Q 6 9.6 12 12 Q 9.6 6 12 0 Q 6 2.4 0 0 z"
4377
+ }
4378
+ )
4379
+ );
4380
+ };
4381
+ var FormLabel3 = forwardRef((props, ref) => {
4382
+ return /* @__PURE__ */ React49__default.createElement(FormLabel, { ...props, ref });
4383
+ });
4384
+ var SelectItem = Item;
4385
+ function ListBox({
4386
+ isLoading,
4387
+ listBoxRef,
4388
+ state: state2,
4389
+ ...props
4390
+ }) {
4391
+ const { listBoxProps } = useListBox(props, state2, listBoxRef);
4392
+ const styles2 = useMultiStyleConfig("ListBox", {});
4393
+ return /* @__PURE__ */ React49__default.createElement(
4394
+ List,
4395
+ {
4396
+ ...listBoxProps,
4397
+ ref: listBoxRef,
4398
+ sx: styles2.container,
4399
+ "aria-busy": isLoading
4400
+ },
4401
+ Array.from(state2.collection).map(
4402
+ (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 })
4403
+ )
4404
+ );
4405
+ }
4406
+ function ItemLabel({ children }) {
4407
+ let { labelProps } = useOptionContext();
4408
+ const styles2 = useMultiStyleConfig("ListBox", {});
4409
+ return /* @__PURE__ */ React49__default.createElement(Box, { ...labelProps, sx: styles2.label }, children);
4410
+ }
4411
+ var SelectItemLabel = ItemLabel;
4412
+ function ItemDescription({ children }) {
4413
+ let { descriptionProps } = useOptionContext();
4414
+ const styles2 = useMultiStyleConfig("ListBox", {});
4415
+ return /* @__PURE__ */ React49__default.createElement(Box, { ...descriptionProps, sx: styles2.description }, children);
4416
+ }
4417
+ var SelectItemDescription = ItemDescription;
4418
+ function Option({ item, state: state2 }) {
4419
+ const ref = useRef(null);
4420
+ const {
4421
+ optionProps,
4422
+ isSelected,
4423
+ isDisabled,
4424
+ isFocused,
4425
+ labelProps,
4426
+ descriptionProps
4427
+ } = useOption({ key: item.key }, state2, ref);
4428
+ const styles2 = useMultiStyleConfig("ListBox", {});
4429
+ let dataFields = {};
4430
+ if (isSelected) {
4431
+ dataFields["data-selected"] = true;
4432
+ }
4433
+ if (isDisabled) {
4434
+ dataFields["data-disabled"] = true;
4435
+ }
4436
+ if (isFocused) {
4437
+ dataFields["data-focus"] = true;
4438
+ }
4439
+ return /* @__PURE__ */ React49__default.createElement(OptionContext.Provider, { value: { labelProps, descriptionProps } }, /* @__PURE__ */ React49__default.createElement(ListItem, { ...optionProps, ...dataFields, ref, sx: styles2.item }, item.rendered));
4440
+ }
4441
+ var OptionContext = React49__default.createContext({
4442
+ labelProps: {},
4443
+ descriptionProps: {}
4444
+ });
4445
+ var useOptionContext = () => {
4446
+ return useContext(OptionContext);
4447
+ };
4448
+ function ListBoxSection({ section, state: state2 }) {
4449
+ const { itemProps, headingProps, groupProps } = useListBoxSection({
4450
+ heading: section.rendered,
4451
+ "aria-label": section["aria-label"]
4452
+ });
4453
+ const isFirstSection = section.key !== state2.collection.getFirstKey();
4454
+ const titleBackgroundColor = useColorModeValue("platinum", "dimGrey");
4455
+ const titleColor = useColorModeValue("darkGrey", "white");
4456
+ return /* @__PURE__ */ React49__default.createElement(ListItem, { ...itemProps }, section.rendered && /* @__PURE__ */ React49__default.createElement(
4457
+ Box,
4458
+ {
4459
+ textStyle: "xs",
4460
+ backgroundColor: titleBackgroundColor,
4461
+ color: titleColor,
4462
+ paddingX: 3,
4463
+ paddingY: 1,
4464
+ marginTop: isFirstSection ? 0 : 0,
4465
+ ...headingProps
4466
+ },
4467
+ section.rendered
4468
+ ), /* @__PURE__ */ React49__default.createElement(List, { ...groupProps, padding: 0, listStyleType: "none" }, Array.from(state2.collection.getChildren(section.key)).map(
4469
+ (item) => /* @__PURE__ */ React49__default.createElement(Option, { key: item.key, item, state: state2 })
4470
+ )));
4471
+ }
4472
+
4473
+ // src/input/InfoSelect.tsx
4474
+ function InfoSelect({
4475
+ placeholder,
4476
+ width = "100%",
4477
+ height = "auto",
4478
+ onChange,
4479
+ value,
4480
+ isLabelSrOnly,
4481
+ defaultValue,
4482
+ ...props
4483
+ }) {
4484
+ const renamedProps = {
4485
+ onSelectionChange: onChange,
4486
+ selectedKey: value,
4487
+ defaultSelectedKey: defaultValue,
4488
+ ...props
4489
+ };
4490
+ const state2 = useSelectState(renamedProps);
4491
+ const triggerRef = useRef(null);
4492
+ const listboxRef = useRef(null);
4493
+ const { labelProps, triggerProps, valueProps, menuProps } = useSelect(
4494
+ renamedProps,
4495
+ state2,
4496
+ triggerRef
4497
+ );
4498
+ const styles2 = useMultiStyleConfig("InfoSelect", {
4499
+ isOpen: state2.isOpen,
4500
+ isLabelSrOnly
4501
+ });
4502
+ const { buttonProps } = useButton(triggerProps, triggerRef);
4503
+ const { t: t2 } = useTranslation();
4504
+ const formControl = useFormControlProps(props);
4505
+ return /* @__PURE__ */ React49__default.createElement(Box, { sx: styles2.container }, /* @__PURE__ */ React49__default.createElement(chakra.div, { ...labelProps, sx: styles2.label }, props.label), /* @__PURE__ */ React49__default.createElement(
4506
+ HiddenSelect,
4507
+ {
4508
+ state: state2,
4509
+ triggerRef,
4510
+ label: props.label,
4511
+ name: props.name
4512
+ }
4513
+ ), /* @__PURE__ */ React49__default.createElement(
4514
+ chakra.button,
4515
+ {
4516
+ type: "button",
4517
+ ref: triggerRef,
4518
+ sx: styles2.button,
4519
+ ...buttonProps,
4520
+ width,
4521
+ height,
4522
+ "data-attachable": true,
4523
+ "aria-invalid": formControl.isInvalid,
4524
+ "aria-describedby": formControl["aria-describedby"]
4525
+ },
4526
+ /* @__PURE__ */ React49__default.createElement(Box, { ...valueProps }, state2.selectedItem ? state2.selectedItem.textValue ?? state2.selectedItem.rendered : placeholder ?? t2(texts10.selectAnOption)),
4527
+ /* @__PURE__ */ React49__default.createElement(Box, { sx: styles2.arrowIcon }, state2.isOpen ? /* @__PURE__ */ React49__default.createElement(DropdownUpFill24Icon, null) : /* @__PURE__ */ React49__default.createElement(DropdownDownFill24Icon, null))
4528
+ ), state2.isOpen && /* @__PURE__ */ React49__default.createElement(Popover3, { state: state2, triggerRef }, /* @__PURE__ */ React49__default.createElement(
4529
+ ListBox,
4530
+ {
4531
+ ...menuProps,
4532
+ state: state2,
4533
+ listBoxRef: listboxRef,
4534
+ borderBottomRadius: "sm"
4535
+ },
4536
+ props.children
4537
+ )));
4538
+ }
4539
+ var texts10 = createTexts({
4540
+ selectAnOption: {
4541
+ nb: "Velg et alternativ",
4542
+ nn: "Velg eit alternativ",
4543
+ sv: "V\xE4lj ett alternativ",
4544
+ en: "Choose an option"
4545
+ }
4546
+ });
4547
+ var Input = forwardRef(
4548
+ ({ label, leftIcon, rightIcon, id, ...props }, ref) => {
4549
+ const formControlProps = useFormControlContext();
4550
+ const fallbackId = `input-${useId()}`;
4551
+ const inputId = id ?? (formControlProps == null ? void 0 : formControlProps.id) ?? fallbackId;
4552
+ return /* @__PURE__ */ React49__default.createElement(InputGroup, { position: "relative" }, leftIcon && /* @__PURE__ */ React49__default.createElement(InputLeftElement, null, leftIcon), /* @__PURE__ */ React49__default.createElement(
4553
+ Input$1,
4554
+ {
4555
+ "data-attachable": true,
4556
+ paddingLeft: leftIcon ? 7 : void 0,
4557
+ paddingRight: rightIcon ? 7 : void 0,
4558
+ ...props,
4559
+ id: inputId,
4560
+ ref,
4561
+ placeholder: " "
4562
+ }
4563
+ ), /* @__PURE__ */ React49__default.createElement(FormLabel, { htmlFor: inputId, pointerEvents: "none" }, label), rightIcon && /* @__PURE__ */ React49__default.createElement(InputRightElement, null, rightIcon));
4564
+ }
4565
+ );
4566
+ var InputLeftElement2 = forwardRef(
4567
+ (props, ref) => /* @__PURE__ */ React49__default.createElement(InputLeftElement, { ...props, ref })
4568
+ );
4569
+ var InputRightElement2 = forwardRef(
4570
+ (props, ref) => /* @__PURE__ */ React49__default.createElement(InputRightElement, { ...props, ref })
4571
+ );
4572
+ var NativeSelect = forwardRef(
4573
+ ({ label, ...props }, ref) => {
4574
+ const styles2 = useMultiStyleConfig("Select", props);
4575
+ return /* @__PURE__ */ React49__default.createElement(FormControl, null, /* @__PURE__ */ React49__default.createElement(
4576
+ Select,
4577
+ {
4578
+ "data-attachable": true,
4579
+ ...props,
4580
+ rootProps: { __css: styles2.root },
4581
+ ref
4582
+ }
4583
+ ), label && /* @__PURE__ */ React49__default.createElement(FormLabel3, null, label));
4584
+ }
4585
+ );
4191
4586
  var colors = {
4192
4587
  ...tokens10__default.color.alias,
4193
4588
  ...tokens10__default.color.palette,
@@ -4262,7 +4657,7 @@ function NumericStepper({
4262
4657
  VerySmallButton,
4263
4658
  {
4264
4659
  icon: /* @__PURE__ */ React49__default.createElement(SubtractIcon, { color: "white" }),
4265
- "aria-label": t2(texts10.decrementButtonAriaLabel),
4660
+ "aria-label": t2(texts11.decrementButtonAriaLabel),
4266
4661
  onClick: () => onChange(value - 1),
4267
4662
  visibility: value <= minValue ? "hidden" : "visible",
4268
4663
  isDisabled: formControlProps.disabled
@@ -4320,7 +4715,7 @@ function NumericStepper({
4320
4715
  VerySmallButton,
4321
4716
  {
4322
4717
  icon: /* @__PURE__ */ React49__default.createElement(AddIcon, { color: "white" }),
4323
- "aria-label": t2(texts10.incrementButtonAriaLabel),
4718
+ "aria-label": t2(texts11.incrementButtonAriaLabel),
4324
4719
  onClick: () => onChange(value + 1),
4325
4720
  visibility: value >= maxValue ? "hidden" : "visible",
4326
4721
  isDisabled: formControlProps.disabled
@@ -4400,7 +4795,7 @@ var AddIcon = (props) => /* @__PURE__ */ React49__default.createElement(
4400
4795
  }
4401
4796
  )
4402
4797
  );
4403
- var texts10 = createTexts({
4798
+ var texts11 = createTexts({
4404
4799
  decrementButtonAriaLabel: {
4405
4800
  nb: "Trekk fra 1",
4406
4801
  en: "Subtract 1",
@@ -4414,228 +4809,6 @@ var texts10 = createTexts({
4414
4809
  sv: "L\xE4gg till 1"
4415
4810
  }
4416
4811
  });
4417
- var FormControl = forwardRef((props, ref) => {
4418
- return /* @__PURE__ */ React49__default.createElement(FormControl$1, { ...props, ref });
4419
- });
4420
- var FormErrorMessage = ({
4421
- children,
4422
- ...boxProps
4423
- }) => {
4424
- const formControlContext = useFormControlContext();
4425
- if (!formControlContext) {
4426
- throw new Error(
4427
- "FormErrorMessage must be used within a FormControl component"
4428
- );
4429
- }
4430
- if (!formControlContext.isInvalid) {
4431
- return null;
4432
- }
4433
- const { ref, ...errorMessageProps } = formControlContext.getErrorMessageProps();
4434
- return /* @__PURE__ */ React49__default.createElement(Box, { position: "relative", ref }, /* @__PURE__ */ React49__default.createElement(
4435
- Box,
4436
- {
4437
- borderRadius: "xs",
4438
- backgroundColor: "lightRed",
4439
- color: "darkGrey",
4440
- paddingX: 1.5,
4441
- paddingY: 1,
4442
- textStyle: "xs",
4443
- width: "fit-content",
4444
- position: "absolute",
4445
- top: -1.5,
4446
- left: 3,
4447
- zIndex: "popover",
4448
- maxWidth: "50ch",
4449
- ...errorMessageProps,
4450
- ...boxProps
4451
- },
4452
- /* @__PURE__ */ React49__default.createElement(Arrow, { position: "absolute", top: "-0.25em", left: "1em" }),
4453
- children
4454
- ));
4455
- };
4456
- var Arrow = (props) => {
4457
- return /* @__PURE__ */ React49__default.createElement(
4458
- Box,
4459
- {
4460
- ...props,
4461
- as: "svg",
4462
- width: "16",
4463
- height: "16",
4464
- viewBox: "0 0 16 16",
4465
- fill: "none",
4466
- transform: "rotate(45deg)"
4467
- },
4468
- /* @__PURE__ */ React49__default.createElement(
4469
- Box,
4470
- {
4471
- as: "path",
4472
- fill: "lightRed",
4473
- d: "M 0\n 0 Q 2.4 6 0 12 Q 6 9.6 12 12 Q 9.6 6 12 0 Q 6 2.4 0 0 z"
4474
- }
4475
- )
4476
- );
4477
- };
4478
- var FormLabel3 = forwardRef((props, ref) => {
4479
- return /* @__PURE__ */ React49__default.createElement(FormLabel, { ...props, ref });
4480
- });
4481
- var ListBox = forwardRef((props, ref) => {
4482
- const { state: state2, listBoxOptions, ...rest } = props;
4483
- const styles2 = useMultiStyleConfig("ListBox", {});
4484
- const internalRef = useRef(null);
4485
- const listBoxRef = ref ?? internalRef;
4486
- const { listBoxProps } = useListBox(listBoxOptions, state2, listBoxRef);
4487
- return /* @__PURE__ */ React49__default.createElement(
4488
- Box,
4489
- {
4490
- as: "ul",
4491
- ...listBoxProps,
4492
- sx: styles2.container,
4493
- ref: listBoxRef,
4494
- ...rest
4495
- },
4496
- Array.from(state2.collection).map((item) => /* @__PURE__ */ React49__default.createElement(Option, { key: item.key, item, state: state2 }))
4497
- );
4498
- });
4499
- var OptionContext = React49__default.createContext({
4500
- labelProps: {},
4501
- descriptionProps: {}
4502
- });
4503
- var useOptionContext = () => {
4504
- return useContext(OptionContext);
4505
- };
4506
- var Option = ({ item, state: state2 }) => {
4507
- const ref = useRef(null);
4508
- const styles2 = useMultiStyleConfig("ListBox", {});
4509
- const { optionProps, labelProps, descriptionProps } = useOption(
4510
- { key: item.key },
4511
- state2,
4512
- ref
4513
- );
4514
- return /* @__PURE__ */ React49__default.createElement(chakra.li, { ...optionProps, ref, sx: styles2.item }, /* @__PURE__ */ React49__default.createElement(OptionContext.Provider, { value: { labelProps, descriptionProps } }, item.rendered));
4515
- };
4516
- function SelectItemLabel({ children }) {
4517
- let { labelProps } = useOptionContext();
4518
- const styles2 = useMultiStyleConfig("ListBox", {});
4519
- return /* @__PURE__ */ React49__default.createElement(Box, { ...labelProps, sx: styles2.label }, children);
4520
- }
4521
- function SelectItemDescription({
4522
- children
4523
- }) {
4524
- let { descriptionProps } = useOptionContext();
4525
- const styles2 = useMultiStyleConfig("ListBox", {});
4526
- return /* @__PURE__ */ React49__default.createElement(Box, { ...descriptionProps, sx: styles2.description }, children);
4527
- }
4528
-
4529
- // src/input/InfoSelect.tsx
4530
- function InfoSelect({
4531
- placeholder,
4532
- width = "100%",
4533
- height = "auto",
4534
- onChange,
4535
- value,
4536
- isLabelSrOnly,
4537
- defaultValue,
4538
- ...props
4539
- }) {
4540
- const renamedProps = {
4541
- onSelectionChange: onChange,
4542
- selectedKey: value,
4543
- defaultSelectedKey: defaultValue,
4544
- ...props
4545
- };
4546
- const state2 = useSelectState(renamedProps);
4547
- const triggerRef = useRef(null);
4548
- const { labelProps, triggerProps, valueProps, menuProps } = useSelect(
4549
- renamedProps,
4550
- state2,
4551
- triggerRef
4552
- );
4553
- const styles2 = useMultiStyleConfig("InfoSelect", {
4554
- isOpen: state2.isOpen,
4555
- isLabelSrOnly
4556
- });
4557
- const { buttonProps } = useButton(triggerProps, triggerRef);
4558
- const { t: t2 } = useTranslation();
4559
- const formControl = useFormControlProps(props);
4560
- return /* @__PURE__ */ React49__default.createElement(Box, { sx: styles2.container }, /* @__PURE__ */ React49__default.createElement(chakra.div, { ...labelProps, sx: styles2.label }, props.label), /* @__PURE__ */ React49__default.createElement(
4561
- HiddenSelect,
4562
- {
4563
- state: state2,
4564
- triggerRef,
4565
- label: props.label,
4566
- name: props.name
4567
- }
4568
- ), /* @__PURE__ */ React49__default.createElement(
4569
- chakra.button,
4570
- {
4571
- type: "button",
4572
- ref: triggerRef,
4573
- sx: styles2.button,
4574
- ...buttonProps,
4575
- width,
4576
- height,
4577
- "data-attachable": true,
4578
- "aria-invalid": formControl.isInvalid,
4579
- "aria-describedby": formControl["aria-describedby"]
4580
- },
4581
- /* @__PURE__ */ React49__default.createElement(Box, { ...valueProps }, state2.selectedItem ? state2.selectedItem.textValue ?? state2.selectedItem.rendered : placeholder ?? t2(texts11.selectAnOption)),
4582
- /* @__PURE__ */ React49__default.createElement(Box, { sx: styles2.arrowIcon }, state2.isOpen ? /* @__PURE__ */ React49__default.createElement(DropdownUpFill24Icon, null) : /* @__PURE__ */ React49__default.createElement(DropdownDownFill24Icon, null))
4583
- ), state2.isOpen && /* @__PURE__ */ React49__default.createElement(Popover3, { state: state2, triggerRef }, /* @__PURE__ */ React49__default.createElement(
4584
- ListBox,
4585
- {
4586
- listBoxOptions: menuProps,
4587
- state: state2,
4588
- borderBottomRadius: "sm"
4589
- }
4590
- )));
4591
- }
4592
- var texts11 = createTexts({
4593
- selectAnOption: {
4594
- nb: "Velg et alternativ",
4595
- nn: "Velg eit alternativ",
4596
- sv: "V\xE4lj ett alternativ",
4597
- en: "Choose an option"
4598
- }
4599
- });
4600
- var Input = forwardRef(
4601
- ({ label, leftIcon, rightIcon, id, ...props }, ref) => {
4602
- const formControlProps = useFormControlContext();
4603
- const fallbackId = `input-${useId()}`;
4604
- const inputId = id ?? (formControlProps == null ? void 0 : formControlProps.id) ?? fallbackId;
4605
- return /* @__PURE__ */ React49__default.createElement(InputGroup, { position: "relative" }, leftIcon && /* @__PURE__ */ React49__default.createElement(InputLeftElement, null, leftIcon), /* @__PURE__ */ React49__default.createElement(
4606
- Input$1,
4607
- {
4608
- "data-attachable": true,
4609
- paddingLeft: leftIcon ? 7 : void 0,
4610
- paddingRight: rightIcon ? 7 : void 0,
4611
- ...props,
4612
- id: inputId,
4613
- ref,
4614
- placeholder: " "
4615
- }
4616
- ), /* @__PURE__ */ React49__default.createElement(FormLabel, { htmlFor: inputId, pointerEvents: "none" }, label), rightIcon && /* @__PURE__ */ React49__default.createElement(InputRightElement, null, rightIcon));
4617
- }
4618
- );
4619
- var InputLeftElement2 = forwardRef(
4620
- (props, ref) => /* @__PURE__ */ React49__default.createElement(InputLeftElement, { ...props, ref })
4621
- );
4622
- var InputRightElement2 = forwardRef(
4623
- (props, ref) => /* @__PURE__ */ React49__default.createElement(InputRightElement, { ...props, ref })
4624
- );
4625
- var NativeSelect = forwardRef(
4626
- ({ label, ...props }, ref) => {
4627
- const styles2 = useMultiStyleConfig("Select", props);
4628
- return /* @__PURE__ */ React49__default.createElement(FormControl, null, /* @__PURE__ */ React49__default.createElement(
4629
- Select,
4630
- {
4631
- "data-attachable": true,
4632
- ...props,
4633
- rootProps: { __css: styles2.root },
4634
- ref
4635
- }
4636
- ), label && /* @__PURE__ */ React49__default.createElement(FormLabel3, null, label));
4637
- }
4638
- );
4639
4812
  var PasswordInput = forwardRef(
4640
4813
  ({ leftIcon, id, label, ...props }, ref) => {
4641
4814
  const { isOpen: isShowingPassword, onToggle } = useDisclosure();
@@ -4705,7 +4878,7 @@ var PhoneNumberInput = forwardRef(
4705
4878
  height: "100%",
4706
4879
  value: "+47"
4707
4880
  },
4708
- /* @__PURE__ */ React49__default.createElement(Item, { key: "+47" }, "+47")
4881
+ /* @__PURE__ */ React49__default.createElement(SelectItem, { key: "+47" }, "+47")
4709
4882
  )
4710
4883
  },
4711
4884
  /* @__PURE__ */ React49__default.createElement(
@@ -4750,7 +4923,7 @@ var texts13 = createTexts({
4750
4923
  sv: "Telefonnummer"
4751
4924
  }
4752
4925
  });
4753
- var LazyCountryCodeSelect = React49__default.lazy(() => import('./CountryCodeSelect-WGG2Z3VI.mjs'));
4926
+ var LazyCountryCodeSelect = React49__default.lazy(() => import('./CountryCodeSelect-MNHFBDDO.mjs'));
4754
4927
  var Radio = forwardRef((props, ref) => {
4755
4928
  return /* @__PURE__ */ React49__default.createElement(Radio$1, { ...props, ref });
4756
4929
  });
@@ -12873,19 +13046,19 @@ var config24 = helpers15.defineMultiStyleConfig({
12873
13046
  },
12874
13047
  _focus: {
12875
13048
  outline: "none",
12876
- background: mode("mint", "darkTeal")(props)
13049
+ backgroundColor: mode("mint", "darkTeal")(props)
12877
13050
  },
12878
13051
  _selected: {
12879
- background: mode("pine", "pine")(props),
13052
+ backgroundColor: mode("pine", "pine")(props),
12880
13053
  color: mode("white", "white")(props)
12881
13054
  }
12882
13055
  },
12883
13056
  label: {},
12884
13057
  description: {
12885
13058
  fontSize: ["mobile.xs", "desktop.xs"],
12886
- color: "dimGrey",
13059
+ color: mode("dimGrey", "silver")(props),
12887
13060
  "[aria-selected='true'] &": {
12888
- color: "lightGrey"
13061
+ color: mode("lightGrey", "platinum")(props)
12889
13062
  }
12890
13063
  }
12891
13064
  })
@@ -14378,4 +14551,4 @@ var getToastComponent = (opts) => {
14378
14551
  return ({ id }) => /* @__PURE__ */ React49__default.createElement(BaseToast, { id, variant: opts.variant }, opts.text);
14379
14552
  };
14380
14553
 
14381
- export { Accordion, AttachedInputs, Badge, Button, ButtonGroup, Card, CardSelect, Checkbox, CheckboxGroup, ChoiceChip, ClosableAlert, CloseButton, Code, ColorInlineLoader, ColorSpinner, ContentLoader, DarkFullScreenLoader, DarkInlineLoader, DarkSpinner, DatePicker, DateRangePicker, Divider, Drawer, DrawerContent, Expandable, ExpandableAlert, ExpandableItem, FloatingActionButton, FormControl, FormErrorMessage, FormLabel3 as FormLabel, Heading, IconButton, InfoSelect, InfoTag, Input, InputLeftElement2 as InputLeftElement, InputRightElement2 as InputRightElement, JumpButton, Language, LanguageProvider, LightFullScreenLoader, LightInlineLoader, LightSpinner, LineIcon, ListBox, ModalHeader, NativeSelect, NumericStepper, PasswordInput, PhoneNumberInput, PlayPauseButton, PopoverWizardBody, ProgressBar, ProgressLoader, Radio, RadioGroup, SearchInput, SelectItemDescription, SelectItemLabel, SimpleDrawer, SimplePopover, Skeleton, SkeletonCircle, SkeletonText, SkipButton, SporProvider, Stack, StaticAlert, Stepper, StepperStep, Switch, Table, Tabs, Text4 as Text, TextLink, Textarea, TimePicker, TravelTag, VyLogo, WizardPopover, createTexts, fontFaces, theme, useToast, useTranslation };
14554
+ export { Accordion, AttachedInputs, Autosuggest, Badge, Button, ButtonGroup, Card, CardSelect, Checkbox, CheckboxGroup, ChoiceChip, ClosableAlert, CloseButton, Code, ColorInlineLoader, ColorSpinner, Combobox, ContentLoader, DarkFullScreenLoader, DarkInlineLoader, DarkSpinner, DatePicker, DateRangePicker, Divider, Drawer, DrawerContent, Expandable, ExpandableAlert, ExpandableItem, FloatingActionButton, FormControl, FormErrorMessage, FormLabel3 as FormLabel, Heading, IconButton, InfoSelect, InfoTag, Input, InputLeftElement2 as InputLeftElement, InputRightElement2 as InputRightElement, ItemDescription, ItemLabel, JumpButton, Language, LanguageProvider, LightFullScreenLoader, LightInlineLoader, LightSpinner, LineIcon, ListBox, ModalHeader, NativeSelect, NumericStepper, PasswordInput, PhoneNumberInput, PlayPauseButton, PopoverWizardBody, ProgressBar, ProgressLoader, Radio, RadioGroup, SearchInput, SelectItem, SelectItemDescription, SelectItemLabel, SimpleDrawer, SimplePopover, Skeleton, SkeletonCircle, SkeletonText, SkipButton, SporProvider, Stack, StaticAlert, Stepper, StepperStep, Switch, Table, Tabs, Text4 as Text, TextLink, Textarea, TimePicker, TravelTag, VyLogo, WizardPopover, createTexts, fontFaces, theme, useToast, useTranslation };