@vygruppen/spor-react 12.13.2 → 12.13.3
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/.turbo/turbo-build.log +12 -12
- package/.turbo/turbo-postinstall.log +1 -1
- package/CHANGELOG.md +7 -0
- package/dist/index.cjs +95 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.mjs +96 -26
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/datepicker/DatePicker.tsx +29 -14
- package/src/datepicker/StyledField.tsx +16 -1
- package/src/input/Field.tsx +3 -1
- package/src/input/FloatingLabel.tsx +6 -11
- package/src/input/Input.tsx +33 -2
- package/src/input/NativeSelect.tsx +1 -0
- package/src/input/Textarea.tsx +35 -1
- package/src/theme/slot-recipes/datepicker.ts +4 -0
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
|
/**
|
@@ -656,6 +657,9 @@ declare const DatePicker: React__default.ForwardRefExoticComponent<Omit<AriaDate
|
|
656
657
|
withPortal?: boolean;
|
657
658
|
onChange?: (value: DateValue | null) => void;
|
658
659
|
positioning?: PopoverRootProps["positioning"];
|
660
|
+
noCalendar?: boolean;
|
661
|
+
overrideBorderColor?: string;
|
662
|
+
isActive?: boolean;
|
659
663
|
} & FieldBaseProps & React__default.RefAttributes<HTMLDivElement>>;
|
660
664
|
|
661
665
|
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
|
/**
|
@@ -656,6 +657,9 @@ declare const DatePicker: React__default.ForwardRefExoticComponent<Omit<AriaDate
|
|
656
657
|
withPortal?: boolean;
|
657
658
|
onChange?: (value: DateValue | null) => void;
|
658
659
|
positioning?: PopoverRootProps["positioning"];
|
660
|
+
noCalendar?: boolean;
|
661
|
+
overrideBorderColor?: string;
|
662
|
+
isActive?: boolean;
|
659
663
|
} & FieldBaseProps & React__default.RefAttributes<HTMLDivElement>>;
|
660
664
|
|
661
665
|
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,
|
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
|
-
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
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 {
|
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({
|
@@ -1886,6 +1887,8 @@ var StyledField = forwardRef(
|
|
1886
1887
|
{
|
1887
1888
|
...otherProps,
|
1888
1889
|
css: styles.wrapper,
|
1890
|
+
"data-active": isActive ? "" : void 0,
|
1891
|
+
style: overrideBorderColor ? { outlineColor: overrideBorderColor } : void 0,
|
1889
1892
|
ref,
|
1890
1893
|
"aria-invalid": invalid,
|
1891
1894
|
"aria-disabled": isDisabled,
|
@@ -1928,7 +1931,10 @@ var DatePicker = forwardRef(
|
|
1928
1931
|
});
|
1929
1932
|
const styles = recipe({ variant });
|
1930
1933
|
const locale = useCurrentLocale();
|
1934
|
+
const shouldShowCalendar = state.isOpen && !props.isDisabled && !props.noCalendar;
|
1931
1935
|
const onFieldClick = () => {
|
1936
|
+
if (props.noCalendar)
|
1937
|
+
return;
|
1932
1938
|
state.setOpen(true);
|
1933
1939
|
};
|
1934
1940
|
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(
|
@@ -1960,12 +1966,14 @@ var DatePicker = forwardRef(
|
|
1960
1966
|
StyledField,
|
1961
1967
|
{
|
1962
1968
|
variant,
|
1963
|
-
onClick: onFieldClick,
|
1969
|
+
onClick: props.noCalendar ? void 0 : onFieldClick,
|
1964
1970
|
paddingX: 3,
|
1965
1971
|
minHeight,
|
1966
1972
|
isDisabled: props.isDisabled,
|
1973
|
+
isActive: props.isActive,
|
1974
|
+
overrideBorderColor: props.overrideBorderColor,
|
1967
1975
|
children: [
|
1968
|
-
/* @__PURE__ */ jsx(Popover$1.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
1976
|
+
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
1977
|
CalendarTriggerButton,
|
1970
1978
|
{
|
1971
1979
|
paddingLeft: 1,
|
@@ -1989,8 +1997,7 @@ var DatePicker = forwardRef(
|
|
1989
1997
|
) })
|
1990
1998
|
}
|
1991
1999
|
),
|
1992
|
-
|
1993
|
-
state.isOpen && !props.isDisabled && !withPortal && popoverContent
|
2000
|
+
shouldShowCalendar && (withPortal ? /* @__PURE__ */ jsx(Portal, { children: popoverContent }) : popoverContent)
|
1994
2001
|
] })
|
1995
2002
|
}
|
1996
2003
|
) });
|
@@ -2799,6 +2806,13 @@ var Input = forwardRef(
|
|
2799
2806
|
const recipe = useRecipe({ key: "input" });
|
2800
2807
|
const [recipeProps, restProps] = recipe.splitVariantProps(props);
|
2801
2808
|
const styles = recipe(recipeProps);
|
2809
|
+
const [focused, setFocused] = useState(false);
|
2810
|
+
const isControlled = props.value !== void 0;
|
2811
|
+
const [uncontrolledValue, setUncontrolledValue] = useState(
|
2812
|
+
props.defaultValue ? String(props.defaultValue) : ""
|
2813
|
+
);
|
2814
|
+
const inputValue = isControlled ? String(props.value ?? "") : uncontrolledValue;
|
2815
|
+
const shouldFloat = inputValue.length > 0 || focused;
|
2802
2816
|
return /* @__PURE__ */ jsxs(
|
2803
2817
|
Field3,
|
2804
2818
|
{
|
@@ -2808,14 +2822,12 @@ var Input = forwardRef(
|
|
2808
2822
|
hidden,
|
2809
2823
|
errorText,
|
2810
2824
|
id: props.id,
|
2811
|
-
label: (
|
2812
|
-
|
2813
|
-
|
2814
|
-
|
2815
|
-
label
|
2816
|
-
] })
|
2817
|
-
),
|
2825
|
+
label: /* @__PURE__ */ jsxs(Flex, { children: [
|
2826
|
+
/* @__PURE__ */ jsx(Box, { visibility: "hidden", children: startElement }),
|
2827
|
+
label
|
2828
|
+
] }),
|
2818
2829
|
floatingLabel: true,
|
2830
|
+
shouldFloat,
|
2819
2831
|
children: [
|
2820
2832
|
startElement && /* @__PURE__ */ jsx(InputElement, { pointerEvents: "none", paddingX: 2, children: startElement }),
|
2821
2833
|
/* @__PURE__ */ jsx(
|
@@ -2829,6 +2841,24 @@ var Input = forwardRef(
|
|
2829
2841
|
paddingRight: endElement ? "2.6rem" : void 0,
|
2830
2842
|
...restProps,
|
2831
2843
|
className: `peer ${props.className}`,
|
2844
|
+
value: isControlled ? props.value : void 0,
|
2845
|
+
onFocus: (e) => {
|
2846
|
+
var _a5;
|
2847
|
+
(_a5 = props.onFocus) == null ? void 0 : _a5.call(props, e);
|
2848
|
+
setFocused(true);
|
2849
|
+
},
|
2850
|
+
onBlur: (e) => {
|
2851
|
+
var _a5;
|
2852
|
+
(_a5 = props.onBlur) == null ? void 0 : _a5.call(props, e);
|
2853
|
+
setFocused(false);
|
2854
|
+
},
|
2855
|
+
onChange: (e) => {
|
2856
|
+
var _a5;
|
2857
|
+
(_a5 = props.onChange) == null ? void 0 : _a5.call(props, e);
|
2858
|
+
if (!isControlled) {
|
2859
|
+
setUncontrolledValue(e.target.value);
|
2860
|
+
}
|
2861
|
+
},
|
2832
2862
|
placeholder: "",
|
2833
2863
|
css: styles
|
2834
2864
|
}
|
@@ -2993,6 +3023,7 @@ var NativeSelect = React27.forwardRef(function NativeSelect2(props, ref) {
|
|
2993
3023
|
errorText,
|
2994
3024
|
id: rest.id,
|
2995
3025
|
floatingLabel: true,
|
3026
|
+
shouldFloat: true,
|
2996
3027
|
children: /* @__PURE__ */ jsxs(
|
2997
3028
|
NativeSelect$1.Root,
|
2998
3029
|
{
|
@@ -3666,11 +3697,23 @@ var Textarea = forwardRef(
|
|
3666
3697
|
readOnly,
|
3667
3698
|
helperText,
|
3668
3699
|
floatingLabel,
|
3700
|
+
value,
|
3701
|
+
defaultValue,
|
3702
|
+
onFocus,
|
3703
|
+
onBlur,
|
3704
|
+
onChange,
|
3669
3705
|
...restProps
|
3670
3706
|
} = props;
|
3671
3707
|
const recipe = useRecipe({ key: "textarea" });
|
3672
3708
|
const styles = recipe({ variant });
|
3673
3709
|
const { labelRef, labelHeight } = useLabelHeight(label);
|
3710
|
+
const [focused, setFocused] = useState(false);
|
3711
|
+
const isControlled = value !== void 0;
|
3712
|
+
const [uncontrolledValue, setUncontrolledValue] = useState(
|
3713
|
+
defaultValue ? String(defaultValue) : ""
|
3714
|
+
);
|
3715
|
+
const inputValue = isControlled ? String(value ?? "") : uncontrolledValue;
|
3716
|
+
const shouldFloat = inputValue.length > 0 || focused;
|
3674
3717
|
return /* @__PURE__ */ jsxs(
|
3675
3718
|
Field3,
|
3676
3719
|
{
|
@@ -3680,6 +3723,7 @@ var Textarea = forwardRef(
|
|
3680
3723
|
required,
|
3681
3724
|
readOnly,
|
3682
3725
|
floatingLabel,
|
3726
|
+
shouldFloat,
|
3683
3727
|
position: "relative",
|
3684
3728
|
children: [
|
3685
3729
|
/* @__PURE__ */ jsx(
|
@@ -3689,11 +3733,33 @@ var Textarea = forwardRef(
|
|
3689
3733
|
css: styles,
|
3690
3734
|
className: "peer",
|
3691
3735
|
ref,
|
3736
|
+
value: isControlled ? value : void 0,
|
3737
|
+
defaultValue,
|
3738
|
+
onFocus: (e) => {
|
3739
|
+
onFocus == null ? void 0 : onFocus(e);
|
3740
|
+
setFocused(true);
|
3741
|
+
},
|
3742
|
+
onBlur: (e) => {
|
3743
|
+
onBlur == null ? void 0 : onBlur(e);
|
3744
|
+
setFocused(false);
|
3745
|
+
},
|
3746
|
+
onChange: (e) => {
|
3747
|
+
onChange == null ? void 0 : onChange(e);
|
3748
|
+
if (!isControlled)
|
3749
|
+
setUncontrolledValue(e.target.value);
|
3750
|
+
},
|
3692
3751
|
style: { "--label-height": `${labelHeight}px` },
|
3693
3752
|
placeholder: " "
|
3694
3753
|
}
|
3695
3754
|
),
|
3696
|
-
/* @__PURE__ */ jsx(
|
3755
|
+
/* @__PURE__ */ jsx(
|
3756
|
+
FloatingLabel,
|
3757
|
+
{
|
3758
|
+
ref: labelRef,
|
3759
|
+
"data-float": shouldFloat ? true : void 0,
|
3760
|
+
children: label
|
3761
|
+
}
|
3762
|
+
)
|
3697
3763
|
]
|
3698
3764
|
}
|
3699
3765
|
);
|
@@ -7086,6 +7152,10 @@ var datePickerSlotRecipe = defineSlotRecipe({
|
|
7086
7152
|
_focusWithin: {
|
7087
7153
|
outline: "2px solid",
|
7088
7154
|
outlineColor: "outline.focus"
|
7155
|
+
},
|
7156
|
+
"&[data-active]": {
|
7157
|
+
outline: "2px solid",
|
7158
|
+
outlineColor: "outline.focus"
|
7089
7159
|
}
|
7090
7160
|
},
|
7091
7161
|
inputLabel: {
|