@vygruppen/spor-react 12.13.2 → 12.13.4

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.cts CHANGED
@@ -543,6 +543,7 @@ type FieldBaseProps = {
543
543
  helperText?: React$1.ReactNode;
544
544
  errorText?: React$1.ReactNode;
545
545
  floatingLabel?: boolean;
546
+ shouldFloat?: boolean;
546
547
  };
547
548
  type FieldProps = Omit<Field$1.RootProps, "label" | "onChange" | "onBlur"> & React$1.PropsWithChildren<FieldVariantProps> & FieldBaseProps;
548
549
  /**
@@ -581,6 +582,13 @@ declare const datePickerSlotRecipe: _chakra_ui_react.SlotRecipeDefinition<"cell"
581
582
  outline: "1px solid";
582
583
  outlineColor: "core.outline";
583
584
  };
585
+ "&[data-active]": {
586
+ outline: "2px solid";
587
+ outlineColor: "outline.focus";
588
+ _hover: {
589
+ outlineColor: "outline.focus";
590
+ };
591
+ };
584
592
  };
585
593
  _invalid: {
586
594
  outline: "2px solid";
@@ -605,6 +613,13 @@ declare const datePickerSlotRecipe: _chakra_ui_react.SlotRecipeDefinition<"cell"
605
613
  outline: "1px solid";
606
614
  outlineColor: "core.outline";
607
615
  };
616
+ "&[data-active]": {
617
+ outline: "2px solid";
618
+ outlineColor: "outline.focus";
619
+ _hover: {
620
+ outlineColor: "outline.focus";
621
+ };
622
+ };
608
623
  };
609
624
  _invalid: {
610
625
  outline: "2px solid";
@@ -622,6 +637,13 @@ declare const datePickerSlotRecipe: _chakra_ui_react.SlotRecipeDefinition<"cell"
622
637
  outline: "1px solid";
623
638
  outlineColor: "core.outline";
624
639
  };
640
+ "&[data-active]": {
641
+ outline: "2px solid";
642
+ outlineColor: "outline.focus";
643
+ _hover: {
644
+ outlineColor: "outline.focus";
645
+ };
646
+ };
625
647
  };
626
648
  _invalid: {
627
649
  outline: "2px solid";
@@ -656,6 +678,10 @@ declare const DatePicker: React__default.ForwardRefExoticComponent<Omit<AriaDate
656
678
  withPortal?: boolean;
657
679
  onChange?: (value: DateValue | null) => void;
658
680
  positioning?: PopoverRootProps["positioning"];
681
+ noCalendar?: boolean;
682
+ overrideBorderColor?: string;
683
+ isActive?: boolean;
684
+ onClick?: () => void;
659
685
  } & FieldBaseProps & React__default.RefAttributes<HTMLDivElement>>;
660
686
 
661
687
  type DateRangePickerProps = Omit<AriaDateRangePickerProps<DateValue>, "onChange" | "errorMessage" | "isInvalid" | "isRequired"> & Pick<BoxProps, "minHeight"> & PropsWithChildren<DatePickerVariantProps> & CalendarVariants & {
package/dist/index.d.ts CHANGED
@@ -543,6 +543,7 @@ type FieldBaseProps = {
543
543
  helperText?: React$1.ReactNode;
544
544
  errorText?: React$1.ReactNode;
545
545
  floatingLabel?: boolean;
546
+ shouldFloat?: boolean;
546
547
  };
547
548
  type FieldProps = Omit<Field$1.RootProps, "label" | "onChange" | "onBlur"> & React$1.PropsWithChildren<FieldVariantProps> & FieldBaseProps;
548
549
  /**
@@ -581,6 +582,13 @@ declare const datePickerSlotRecipe: _chakra_ui_react.SlotRecipeDefinition<"cell"
581
582
  outline: "1px solid";
582
583
  outlineColor: "core.outline";
583
584
  };
585
+ "&[data-active]": {
586
+ outline: "2px solid";
587
+ outlineColor: "outline.focus";
588
+ _hover: {
589
+ outlineColor: "outline.focus";
590
+ };
591
+ };
584
592
  };
585
593
  _invalid: {
586
594
  outline: "2px solid";
@@ -605,6 +613,13 @@ declare const datePickerSlotRecipe: _chakra_ui_react.SlotRecipeDefinition<"cell"
605
613
  outline: "1px solid";
606
614
  outlineColor: "core.outline";
607
615
  };
616
+ "&[data-active]": {
617
+ outline: "2px solid";
618
+ outlineColor: "outline.focus";
619
+ _hover: {
620
+ outlineColor: "outline.focus";
621
+ };
622
+ };
608
623
  };
609
624
  _invalid: {
610
625
  outline: "2px solid";
@@ -622,6 +637,13 @@ declare const datePickerSlotRecipe: _chakra_ui_react.SlotRecipeDefinition<"cell"
622
637
  outline: "1px solid";
623
638
  outlineColor: "core.outline";
624
639
  };
640
+ "&[data-active]": {
641
+ outline: "2px solid";
642
+ outlineColor: "outline.focus";
643
+ _hover: {
644
+ outlineColor: "outline.focus";
645
+ };
646
+ };
625
647
  };
626
648
  _invalid: {
627
649
  outline: "2px solid";
@@ -656,6 +678,10 @@ declare const DatePicker: React__default.ForwardRefExoticComponent<Omit<AriaDate
656
678
  withPortal?: boolean;
657
679
  onChange?: (value: DateValue | null) => void;
658
680
  positioning?: PopoverRootProps["positioning"];
681
+ noCalendar?: boolean;
682
+ overrideBorderColor?: string;
683
+ isActive?: boolean;
684
+ onClick?: () => void;
659
685
  } & FieldBaseProps & React__default.RefAttributes<HTMLDivElement>>;
660
686
 
661
687
  type DateRangePickerProps = Omit<AriaDateRangePickerProps<DateValue>, "onChange" | "errorMessage" | "isInvalid" | "isRequired"> & Pick<BoxProps, "minHeight"> & PropsWithChildren<DatePickerVariantProps> & CalendarVariants & {
package/dist/index.mjs CHANGED
@@ -2,7 +2,7 @@ import { useSlotRecipe, Accordion as Accordion$1, Stack, Box, HStack, Progress,
2
2
  export { AspectRatio, Box, BreadcrumbCurrentLink, BreadcrumbEllipsis, BreadcrumbLink, Center, ClientOnly, Collapsible, Container, Em, Flex, For, FormatByte, FormatNumber, Grid, GridItem, HStack, Icon, Image, Kbd, LocaleProvider, Portal, Show, SimpleGrid, Spacer, Span, Stack, TableBody, TableCaption, TableCell, TableColumn, TableColumnGroup, TableColumnHeader, TableFooter, TableHeader, TableRoot, TableRow, VStack, VisuallyHidden, createIcon, createListCollection, createSystem, defineConfig, defineRecipe, defineStyle, chakra as spor, useBreakpointValue, useCheckbox, useClipboard, useControllableProp, useDisclosure, useMediaQuery, useRecipe, useSlotRecipe, useToken } from '@chakra-ui/react';
3
3
  import { DropdownDownFill24Icon, CopyOutline18Icon, CheckmarkFill18Icon, CloseFill18Icon, CloseFill30Icon, CloseFill24Icon, ServiceFill24Icon, QuestionFill24Icon, ErrorOutline24Icon, ErrorFill24Icon, AltTransportFill24Icon, WarningFill24Icon, SuccessFill24Icon, InformationFill24Icon, DropdownDownFill18Icon, DropdownRightFill18Icon, CalendarOutline24Icon, ArrowLeftFill24Icon, CloseOutline24Icon, SearchOutline24Icon, InformationFill18Icon, WarningFill18Icon, ErrorFill18Icon, Forward15MediaControllerFill30Icon, Backward15MediaControllerFill30Icon, PauseMediaControllerFill24Icon, PlayMediaControllerFill24Icon, NextMediaControllerFill30Icon, PreviousMediaControllerFill30Icon, ArrowRightFill18Icon, DropdownLeftOutline18Icon, DropdownRightOutline18Icon, WalkFill30Icon, WalkFill24Icon, WalkFill18Icon, AltTransportFill30Icon, AltTransportFill18Icon, TramFill30Icon, TramFill24Icon, TramFill18Icon, SubwayFill30Icon, SubwayFill24Icon, SubwayFill18Icon, FerryFill30Icon, FerryFill24Icon, FerryFill18Icon, BusFill30Icon, BusFill24Icon, BusFill18Icon, ExpressBusFill30Icon, ExpressBusFill24Icon, ExpressBusFill18Icon, TrainFill30Icon, TrainFill24Icon, TrainFill18Icon, LinkOutOutline24Icon, LinkOutOutline18Icon, ArrowLeftOutline24Icon, ArrowRightOutline24Icon, DropdownLeftFill18Icon, SuccessFill18Icon } from '@vygruppen/spor-icon-react';
4
4
  import * as React27 from 'react';
5
- import React27__default, { forwardRef, createContext, useId, cloneElement, useEffect, useRef, isValidElement, useState, useMemo, useLayoutEffect, useContext } from 'react';
5
+ import React27__default, { forwardRef, createContext, useId, cloneElement, useEffect, useRef, useState, isValidElement, useMemo, useLayoutEffect, useContext } from 'react';
6
6
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
7
7
  import { spinnerColorData, inlineLoaderColorData, contentLoaderData, fullScreenLoaderWhiteData, inlineLoaderDarkData, spinnerLightData, spinnerDarkData, fullScreenLoaderBlackData, inlineLoaderLightData } from '@vygruppen/spor-loader';
8
8
  import ReactLottie from 'lottie-react';
@@ -1311,24 +1311,17 @@ FloatingLabel.displayName = "FloatingLabel";
1311
1311
  var floatingLabelStyles = defineStyle({
1312
1312
  paddingX: 3,
1313
1313
  fontWeight: "normal",
1314
- fontSize: ["mobile.xs", "desktop.xs"],
1315
- color: "text",
1316
1314
  pointerEvents: "none",
1317
1315
  zIndex: "docked",
1318
1316
  _disabled: {
1319
1317
  opacity: 0.4
1320
1318
  },
1321
1319
  pos: "absolute",
1322
- top: "0.3rem",
1323
1320
  transition: "position",
1324
- _peerPlaceholderShown: {
1325
- /* For when input is not in focus */
1326
- top: "0.9rem",
1327
- color: "text",
1328
- fontSize: ["mobile.sm", "desktop.sm"]
1329
- },
1330
- _peerFocusVisible: {
1331
- /* For when input is in focus */
1321
+ top: "0.9rem",
1322
+ color: "text",
1323
+ fontSize: ["mobile.sm", "desktop.sm"],
1324
+ "&[data-float]": {
1332
1325
  fontSize: ["mobile.xs", "desktop.xs"],
1333
1326
  color: "text",
1334
1327
  top: "0.3rem"
@@ -1361,6 +1354,7 @@ var Field3 = React27.forwardRef(
1361
1354
  required,
1362
1355
  direction,
1363
1356
  id,
1357
+ shouldFloat,
1364
1358
  ...rest
1365
1359
  } = props;
1366
1360
  const recipe = useSlotRecipe({ key: "field" });
@@ -1382,7 +1376,7 @@ var Field3 = React27.forwardRef(
1382
1376
  /* @__PURE__ */ jsx(Field.RequiredIndicator, {})
1383
1377
  ] }),
1384
1378
  children,
1385
- label && floatingLabel && /* @__PURE__ */ jsxs(FloatingLabel, { children: [
1379
+ label && floatingLabel && /* @__PURE__ */ jsxs(FloatingLabel, { "data-float": shouldFloat ? true : void 0, children: [
1386
1380
  label,
1387
1381
  /* @__PURE__ */ jsx(Field.RequiredIndicator, {})
1388
1382
  ] }),
@@ -1874,7 +1868,14 @@ var getAriaLabel = (segmentType) => {
1874
1868
  };
1875
1869
  var StyledField = forwardRef(
1876
1870
  function StyledField2(props, ref) {
1877
- const { children, variant, isDisabled, ...otherProps } = props;
1871
+ const {
1872
+ children,
1873
+ variant,
1874
+ isDisabled,
1875
+ isActive,
1876
+ overrideBorderColor,
1877
+ ...otherProps
1878
+ } = props;
1878
1879
  const { invalid } = useFieldContext() ?? {
1879
1880
  };
1880
1881
  const recipe = useSlotRecipe({
@@ -1885,7 +1886,11 @@ var StyledField = forwardRef(
1885
1886
  Box,
1886
1887
  {
1887
1888
  ...otherProps,
1888
- css: styles.wrapper,
1889
+ css: {
1890
+ ...styles.wrapper,
1891
+ outlineColor: overrideBorderColor || void 0
1892
+ },
1893
+ "data-active": isActive ? "" : void 0,
1889
1894
  ref,
1890
1895
  "aria-invalid": invalid,
1891
1896
  "aria-disabled": isDisabled,
@@ -1928,8 +1933,13 @@ var DatePicker = forwardRef(
1928
1933
  });
1929
1934
  const styles = recipe({ variant });
1930
1935
  const locale = useCurrentLocale();
1936
+ const shouldShowCalendar = state.isOpen && !props.isDisabled && !props.noCalendar;
1931
1937
  const onFieldClick = () => {
1932
- state.setOpen(true);
1938
+ var _a5;
1939
+ if (!props.noCalendar) {
1940
+ state.setOpen(true);
1941
+ }
1942
+ (_a5 = props.onClick) == null ? void 0 : _a5.call(props);
1933
1943
  };
1934
1944
  const popoverContent = /* @__PURE__ */ jsx(Popover$1.Positioner, { children: /* @__PURE__ */ jsx(Popover$1.Content, { css: styles.calendarPopover, children: /* @__PURE__ */ jsx(Popover$1.Body, { minWidth: "20rem", children: /* @__PURE__ */ jsx(
1935
1945
  Calendar,
@@ -1964,8 +1974,10 @@ var DatePicker = forwardRef(
1964
1974
  paddingX: 3,
1965
1975
  minHeight,
1966
1976
  isDisabled: props.isDisabled,
1977
+ isActive: props.isActive,
1978
+ overrideBorderColor: props.overrideBorderColor,
1967
1979
  children: [
1968
- /* @__PURE__ */ jsx(Popover$1.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(
1980
+ props.noCalendar ? /* @__PURE__ */ jsx(Box, { pr: 3, pl: 0.5, mr: 0.5, children: /* @__PURE__ */ jsx(CalendarOutline24Icon, {}) }) : /* @__PURE__ */ jsx(Popover$1.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(
1969
1981
  CalendarTriggerButton,
1970
1982
  {
1971
1983
  paddingLeft: 1,
@@ -1989,8 +2001,7 @@ var DatePicker = forwardRef(
1989
2001
  ) })
1990
2002
  }
1991
2003
  ),
1992
- state.isOpen && !props.isDisabled && withPortal && /* @__PURE__ */ jsx(Portal, { children: popoverContent }),
1993
- state.isOpen && !props.isDisabled && !withPortal && popoverContent
2004
+ shouldShowCalendar && (withPortal ? /* @__PURE__ */ jsx(Portal, { children: popoverContent }) : popoverContent)
1994
2005
  ] })
1995
2006
  }
1996
2007
  ) });
@@ -2799,6 +2810,13 @@ var Input = forwardRef(
2799
2810
  const recipe = useRecipe({ key: "input" });
2800
2811
  const [recipeProps, restProps] = recipe.splitVariantProps(props);
2801
2812
  const styles = recipe(recipeProps);
2813
+ const [focused, setFocused] = useState(false);
2814
+ const isControlled = props.value !== void 0;
2815
+ const [uncontrolledValue, setUncontrolledValue] = useState(
2816
+ props.defaultValue ? String(props.defaultValue) : ""
2817
+ );
2818
+ const inputValue = isControlled ? String(props.value ?? "") : uncontrolledValue;
2819
+ const shouldFloat = inputValue.length > 0 || focused;
2802
2820
  return /* @__PURE__ */ jsxs(
2803
2821
  Field3,
2804
2822
  {
@@ -2808,14 +2826,12 @@ var Input = forwardRef(
2808
2826
  hidden,
2809
2827
  errorText,
2810
2828
  id: props.id,
2811
- label: (
2812
- // Render startElement invisibly to align label text with input content when an icon is present
2813
- /* @__PURE__ */ jsxs(Flex, { children: [
2814
- /* @__PURE__ */ jsx(Box, { visibility: "hidden", children: startElement }),
2815
- label
2816
- ] })
2817
- ),
2829
+ label: /* @__PURE__ */ jsxs(Flex, { children: [
2830
+ /* @__PURE__ */ jsx(Box, { visibility: "hidden", children: startElement }),
2831
+ label
2832
+ ] }),
2818
2833
  floatingLabel: true,
2834
+ shouldFloat,
2819
2835
  children: [
2820
2836
  startElement && /* @__PURE__ */ jsx(InputElement, { pointerEvents: "none", paddingX: 2, children: startElement }),
2821
2837
  /* @__PURE__ */ jsx(
@@ -2829,6 +2845,24 @@ var Input = forwardRef(
2829
2845
  paddingRight: endElement ? "2.6rem" : void 0,
2830
2846
  ...restProps,
2831
2847
  className: `peer ${props.className}`,
2848
+ value: isControlled ? props.value : void 0,
2849
+ onFocus: (e) => {
2850
+ var _a5;
2851
+ (_a5 = props.onFocus) == null ? void 0 : _a5.call(props, e);
2852
+ setFocused(true);
2853
+ },
2854
+ onBlur: (e) => {
2855
+ var _a5;
2856
+ (_a5 = props.onBlur) == null ? void 0 : _a5.call(props, e);
2857
+ setFocused(false);
2858
+ },
2859
+ onChange: (e) => {
2860
+ var _a5;
2861
+ (_a5 = props.onChange) == null ? void 0 : _a5.call(props, e);
2862
+ if (!isControlled) {
2863
+ setUncontrolledValue(e.target.value);
2864
+ }
2865
+ },
2832
2866
  placeholder: "",
2833
2867
  css: styles
2834
2868
  }
@@ -2993,6 +3027,7 @@ var NativeSelect = React27.forwardRef(function NativeSelect2(props, ref) {
2993
3027
  errorText,
2994
3028
  id: rest.id,
2995
3029
  floatingLabel: true,
3030
+ shouldFloat: true,
2996
3031
  children: /* @__PURE__ */ jsxs(
2997
3032
  NativeSelect$1.Root,
2998
3033
  {
@@ -3666,11 +3701,23 @@ var Textarea = forwardRef(
3666
3701
  readOnly,
3667
3702
  helperText,
3668
3703
  floatingLabel,
3704
+ value,
3705
+ defaultValue,
3706
+ onFocus,
3707
+ onBlur,
3708
+ onChange,
3669
3709
  ...restProps
3670
3710
  } = props;
3671
3711
  const recipe = useRecipe({ key: "textarea" });
3672
3712
  const styles = recipe({ variant });
3673
3713
  const { labelRef, labelHeight } = useLabelHeight(label);
3714
+ const [focused, setFocused] = useState(false);
3715
+ const isControlled = value !== void 0;
3716
+ const [uncontrolledValue, setUncontrolledValue] = useState(
3717
+ defaultValue ? String(defaultValue) : ""
3718
+ );
3719
+ const inputValue = isControlled ? String(value ?? "") : uncontrolledValue;
3720
+ const shouldFloat = inputValue.length > 0 || focused;
3674
3721
  return /* @__PURE__ */ jsxs(
3675
3722
  Field3,
3676
3723
  {
@@ -3680,6 +3727,7 @@ var Textarea = forwardRef(
3680
3727
  required,
3681
3728
  readOnly,
3682
3729
  floatingLabel,
3730
+ shouldFloat,
3683
3731
  position: "relative",
3684
3732
  children: [
3685
3733
  /* @__PURE__ */ jsx(
@@ -3689,11 +3737,33 @@ var Textarea = forwardRef(
3689
3737
  css: styles,
3690
3738
  className: "peer",
3691
3739
  ref,
3740
+ value: isControlled ? value : void 0,
3741
+ defaultValue,
3742
+ onFocus: (e) => {
3743
+ onFocus == null ? void 0 : onFocus(e);
3744
+ setFocused(true);
3745
+ },
3746
+ onBlur: (e) => {
3747
+ onBlur == null ? void 0 : onBlur(e);
3748
+ setFocused(false);
3749
+ },
3750
+ onChange: (e) => {
3751
+ onChange == null ? void 0 : onChange(e);
3752
+ if (!isControlled)
3753
+ setUncontrolledValue(e.target.value);
3754
+ },
3692
3755
  style: { "--label-height": `${labelHeight}px` },
3693
3756
  placeholder: " "
3694
3757
  }
3695
3758
  ),
3696
- /* @__PURE__ */ jsx(FloatingLabel, { ref: labelRef, children: label })
3759
+ /* @__PURE__ */ jsx(
3760
+ FloatingLabel,
3761
+ {
3762
+ ref: labelRef,
3763
+ "data-float": shouldFloat ? true : void 0,
3764
+ children: label
3765
+ }
3766
+ )
3697
3767
  ]
3698
3768
  }
3699
3769
  );
@@ -7086,6 +7156,13 @@ var datePickerSlotRecipe = defineSlotRecipe({
7086
7156
  _focusWithin: {
7087
7157
  outline: "2px solid",
7088
7158
  outlineColor: "outline.focus"
7159
+ },
7160
+ "&[data-active]": {
7161
+ outline: "2px solid",
7162
+ outlineColor: "outline.focus",
7163
+ "&:hover": {
7164
+ outlineColor: "outline.focus"
7165
+ }
7089
7166
  }
7090
7167
  },
7091
7168
  inputLabel: {
@@ -7212,6 +7289,13 @@ var datePickerSlotRecipe = defineSlotRecipe({
7212
7289
  backgroundColor: "ghost.surface.active",
7213
7290
  outline: "1px solid",
7214
7291
  outlineColor: "core.outline"
7292
+ },
7293
+ "&[data-active]": {
7294
+ outline: "2px solid",
7295
+ outlineColor: "outline.focus",
7296
+ _hover: {
7297
+ outlineColor: "outline.focus"
7298
+ }
7215
7299
  }
7216
7300
  },
7217
7301
  _invalid: {
@@ -7236,6 +7320,13 @@ var datePickerSlotRecipe = defineSlotRecipe({
7236
7320
  backgroundColor: "ghost.surface.active",
7237
7321
  outline: "1px solid",
7238
7322
  outlineColor: "core.outline"
7323
+ },
7324
+ "&[data-active]": {
7325
+ outline: "2px solid",
7326
+ outlineColor: "outline.focus",
7327
+ _hover: {
7328
+ outlineColor: "outline.focus"
7329
+ }
7239
7330
  }
7240
7331
  },
7241
7332
  _invalid: {
@@ -7253,6 +7344,13 @@ var datePickerSlotRecipe = defineSlotRecipe({
7253
7344
  backgroundColor: "ghost.surface.active",
7254
7345
  outline: "1px solid",
7255
7346
  outlineColor: "core.outline"
7347
+ },
7348
+ "&[data-active]": {
7349
+ outline: "2px solid",
7350
+ outlineColor: "outline.focus",
7351
+ _hover: {
7352
+ outlineColor: "outline.focus"
7353
+ }
7256
7354
  }
7257
7355
  },
7258
7356
  _invalid: {