@vygruppen/spor-react 12.13.1 → 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 +15 -0
- package/dist/index.cjs +99 -33
- 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 +100 -33
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- 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/Popover.tsx +0 -7
- package/src/input/Textarea.tsx +35 -1
- package/src/theme/slot-recipes/collapsible.ts +2 -0
- package/src/theme/slot-recipes/datepicker.ts +5 -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';
|
@@ -16,7 +16,6 @@ export { Item, Section } from 'react-stately';
|
|
16
16
|
import { GregorianCalendar, createCalendar, getLocalTimeZone, endOfMonth, getWeeksInMonth, isSameMonth, isToday, parseTime } from '@internationalized/date';
|
17
17
|
export { Time } from '@internationalized/date';
|
18
18
|
import { useSwipeable } from 'react-swipeable';
|
19
|
-
import ReactDOM from 'react-dom';
|
20
19
|
import { getSupportedCallingCodes } from 'awesome-phonenumber';
|
21
20
|
import { Global } from '@emotion/react';
|
22
21
|
import tokens23__default from '@vygruppen/spor-design-tokens';
|
@@ -1312,24 +1311,17 @@ FloatingLabel.displayName = "FloatingLabel";
|
|
1312
1311
|
var floatingLabelStyles = defineStyle({
|
1313
1312
|
paddingX: 3,
|
1314
1313
|
fontWeight: "normal",
|
1315
|
-
fontSize: ["mobile.xs", "desktop.xs"],
|
1316
|
-
color: "text",
|
1317
1314
|
pointerEvents: "none",
|
1318
1315
|
zIndex: "docked",
|
1319
1316
|
_disabled: {
|
1320
1317
|
opacity: 0.4
|
1321
1318
|
},
|
1322
1319
|
pos: "absolute",
|
1323
|
-
top: "0.3rem",
|
1324
1320
|
transition: "position",
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
fontSize: ["mobile.sm", "desktop.sm"]
|
1330
|
-
},
|
1331
|
-
_peerFocusVisible: {
|
1332
|
-
/* For when input is in focus */
|
1321
|
+
top: "0.9rem",
|
1322
|
+
color: "text",
|
1323
|
+
fontSize: ["mobile.sm", "desktop.sm"],
|
1324
|
+
"&[data-float]": {
|
1333
1325
|
fontSize: ["mobile.xs", "desktop.xs"],
|
1334
1326
|
color: "text",
|
1335
1327
|
top: "0.3rem"
|
@@ -1362,6 +1354,7 @@ var Field3 = React27.forwardRef(
|
|
1362
1354
|
required,
|
1363
1355
|
direction,
|
1364
1356
|
id,
|
1357
|
+
shouldFloat,
|
1365
1358
|
...rest
|
1366
1359
|
} = props;
|
1367
1360
|
const recipe = useSlotRecipe({ key: "field" });
|
@@ -1383,7 +1376,7 @@ var Field3 = React27.forwardRef(
|
|
1383
1376
|
/* @__PURE__ */ jsx(Field.RequiredIndicator, {})
|
1384
1377
|
] }),
|
1385
1378
|
children,
|
1386
|
-
label && floatingLabel && /* @__PURE__ */ jsxs(FloatingLabel, { children: [
|
1379
|
+
label && floatingLabel && /* @__PURE__ */ jsxs(FloatingLabel, { "data-float": shouldFloat ? true : void 0, children: [
|
1387
1380
|
label,
|
1388
1381
|
/* @__PURE__ */ jsx(Field.RequiredIndicator, {})
|
1389
1382
|
] }),
|
@@ -1875,7 +1868,14 @@ var getAriaLabel = (segmentType) => {
|
|
1875
1868
|
};
|
1876
1869
|
var StyledField = forwardRef(
|
1877
1870
|
function StyledField2(props, ref) {
|
1878
|
-
const {
|
1871
|
+
const {
|
1872
|
+
children,
|
1873
|
+
variant,
|
1874
|
+
isDisabled,
|
1875
|
+
isActive,
|
1876
|
+
overrideBorderColor,
|
1877
|
+
...otherProps
|
1878
|
+
} = props;
|
1879
1879
|
const { invalid } = useFieldContext() ?? {
|
1880
1880
|
};
|
1881
1881
|
const recipe = useSlotRecipe({
|
@@ -1887,6 +1887,8 @@ var StyledField = forwardRef(
|
|
1887
1887
|
{
|
1888
1888
|
...otherProps,
|
1889
1889
|
css: styles.wrapper,
|
1890
|
+
"data-active": isActive ? "" : void 0,
|
1891
|
+
style: overrideBorderColor ? { outlineColor: overrideBorderColor } : void 0,
|
1890
1892
|
ref,
|
1891
1893
|
"aria-invalid": invalid,
|
1892
1894
|
"aria-disabled": isDisabled,
|
@@ -1929,7 +1931,10 @@ var DatePicker = forwardRef(
|
|
1929
1931
|
});
|
1930
1932
|
const styles = recipe({ variant });
|
1931
1933
|
const locale = useCurrentLocale();
|
1934
|
+
const shouldShowCalendar = state.isOpen && !props.isDisabled && !props.noCalendar;
|
1932
1935
|
const onFieldClick = () => {
|
1936
|
+
if (props.noCalendar)
|
1937
|
+
return;
|
1933
1938
|
state.setOpen(true);
|
1934
1939
|
};
|
1935
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(
|
@@ -1961,12 +1966,14 @@ var DatePicker = forwardRef(
|
|
1961
1966
|
StyledField,
|
1962
1967
|
{
|
1963
1968
|
variant,
|
1964
|
-
onClick: onFieldClick,
|
1969
|
+
onClick: props.noCalendar ? void 0 : onFieldClick,
|
1965
1970
|
paddingX: 3,
|
1966
1971
|
minHeight,
|
1967
1972
|
isDisabled: props.isDisabled,
|
1973
|
+
isActive: props.isActive,
|
1974
|
+
overrideBorderColor: props.overrideBorderColor,
|
1968
1975
|
children: [
|
1969
|
-
/* @__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(
|
1970
1977
|
CalendarTriggerButton,
|
1971
1978
|
{
|
1972
1979
|
paddingLeft: 1,
|
@@ -1990,8 +1997,7 @@ var DatePicker = forwardRef(
|
|
1990
1997
|
) })
|
1991
1998
|
}
|
1992
1999
|
),
|
1993
|
-
|
1994
|
-
state.isOpen && !props.isDisabled && !withPortal && popoverContent
|
2000
|
+
shouldShowCalendar && (withPortal ? /* @__PURE__ */ jsx(Portal, { children: popoverContent }) : popoverContent)
|
1995
2001
|
] })
|
1996
2002
|
}
|
1997
2003
|
) });
|
@@ -2561,8 +2567,6 @@ var Popover = forwardRef(
|
|
2561
2567
|
...popoverProps,
|
2562
2568
|
ref: popoverRef,
|
2563
2569
|
minWidth: ((_a5 = triggerRef.current) == null ? void 0 : _a5.clientWidth) ?? "auto",
|
2564
|
-
position: "absolute",
|
2565
|
-
zIndex: 1400,
|
2566
2570
|
children: [
|
2567
2571
|
/* @__PURE__ */ jsx(DismissButton, { onDismiss: state.close }),
|
2568
2572
|
children,
|
@@ -2571,9 +2575,6 @@ var Popover = forwardRef(
|
|
2571
2575
|
}
|
2572
2576
|
);
|
2573
2577
|
if (isNonModal) {
|
2574
|
-
if (globalThis.window !== void 0 && typeof document !== "undefined") {
|
2575
|
-
return ReactDOM.createPortal(popoverBox, document.body);
|
2576
|
-
}
|
2577
2578
|
return popoverBox;
|
2578
2579
|
}
|
2579
2580
|
return /* @__PURE__ */ jsxs(Overlay, { children: [
|
@@ -2805,6 +2806,13 @@ var Input = forwardRef(
|
|
2805
2806
|
const recipe = useRecipe({ key: "input" });
|
2806
2807
|
const [recipeProps, restProps] = recipe.splitVariantProps(props);
|
2807
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;
|
2808
2816
|
return /* @__PURE__ */ jsxs(
|
2809
2817
|
Field3,
|
2810
2818
|
{
|
@@ -2814,14 +2822,12 @@ var Input = forwardRef(
|
|
2814
2822
|
hidden,
|
2815
2823
|
errorText,
|
2816
2824
|
id: props.id,
|
2817
|
-
label: (
|
2818
|
-
|
2819
|
-
|
2820
|
-
|
2821
|
-
label
|
2822
|
-
] })
|
2823
|
-
),
|
2825
|
+
label: /* @__PURE__ */ jsxs(Flex, { children: [
|
2826
|
+
/* @__PURE__ */ jsx(Box, { visibility: "hidden", children: startElement }),
|
2827
|
+
label
|
2828
|
+
] }),
|
2824
2829
|
floatingLabel: true,
|
2830
|
+
shouldFloat,
|
2825
2831
|
children: [
|
2826
2832
|
startElement && /* @__PURE__ */ jsx(InputElement, { pointerEvents: "none", paddingX: 2, children: startElement }),
|
2827
2833
|
/* @__PURE__ */ jsx(
|
@@ -2835,6 +2841,24 @@ var Input = forwardRef(
|
|
2835
2841
|
paddingRight: endElement ? "2.6rem" : void 0,
|
2836
2842
|
...restProps,
|
2837
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
|
+
},
|
2838
2862
|
placeholder: "",
|
2839
2863
|
css: styles
|
2840
2864
|
}
|
@@ -2999,6 +3023,7 @@ var NativeSelect = React27.forwardRef(function NativeSelect2(props, ref) {
|
|
2999
3023
|
errorText,
|
3000
3024
|
id: rest.id,
|
3001
3025
|
floatingLabel: true,
|
3026
|
+
shouldFloat: true,
|
3002
3027
|
children: /* @__PURE__ */ jsxs(
|
3003
3028
|
NativeSelect$1.Root,
|
3004
3029
|
{
|
@@ -3672,11 +3697,23 @@ var Textarea = forwardRef(
|
|
3672
3697
|
readOnly,
|
3673
3698
|
helperText,
|
3674
3699
|
floatingLabel,
|
3700
|
+
value,
|
3701
|
+
defaultValue,
|
3702
|
+
onFocus,
|
3703
|
+
onBlur,
|
3704
|
+
onChange,
|
3675
3705
|
...restProps
|
3676
3706
|
} = props;
|
3677
3707
|
const recipe = useRecipe({ key: "textarea" });
|
3678
3708
|
const styles = recipe({ variant });
|
3679
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;
|
3680
3717
|
return /* @__PURE__ */ jsxs(
|
3681
3718
|
Field3,
|
3682
3719
|
{
|
@@ -3686,6 +3723,7 @@ var Textarea = forwardRef(
|
|
3686
3723
|
required,
|
3687
3724
|
readOnly,
|
3688
3725
|
floatingLabel,
|
3726
|
+
shouldFloat,
|
3689
3727
|
position: "relative",
|
3690
3728
|
children: [
|
3691
3729
|
/* @__PURE__ */ jsx(
|
@@ -3695,11 +3733,33 @@ var Textarea = forwardRef(
|
|
3695
3733
|
css: styles,
|
3696
3734
|
className: "peer",
|
3697
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
|
+
},
|
3698
3751
|
style: { "--label-height": `${labelHeight}px` },
|
3699
3752
|
placeholder: " "
|
3700
3753
|
}
|
3701
3754
|
),
|
3702
|
-
/* @__PURE__ */ jsx(
|
3755
|
+
/* @__PURE__ */ jsx(
|
3756
|
+
FloatingLabel,
|
3757
|
+
{
|
3758
|
+
ref: labelRef,
|
3759
|
+
"data-float": shouldFloat ? true : void 0,
|
3760
|
+
children: label
|
3761
|
+
}
|
3762
|
+
)
|
3703
3763
|
]
|
3704
3764
|
}
|
3705
3765
|
);
|
@@ -7053,6 +7113,8 @@ var collapsibleSlotRecipe = defineSlotRecipe({
|
|
7053
7113
|
className: "chakra-collapsible",
|
7054
7114
|
base: {
|
7055
7115
|
content: {
|
7116
|
+
margin: -1,
|
7117
|
+
padding: 1,
|
7056
7118
|
overflow: "hidden",
|
7057
7119
|
_open: {
|
7058
7120
|
animationName: "expand-height, fade-in",
|
@@ -7090,6 +7152,10 @@ var datePickerSlotRecipe = defineSlotRecipe({
|
|
7090
7152
|
_focusWithin: {
|
7091
7153
|
outline: "2px solid",
|
7092
7154
|
outlineColor: "outline.focus"
|
7155
|
+
},
|
7156
|
+
"&[data-active]": {
|
7157
|
+
outline: "2px solid",
|
7158
|
+
outlineColor: "outline.focus"
|
7093
7159
|
}
|
7094
7160
|
},
|
7095
7161
|
inputLabel: {
|
@@ -7133,7 +7199,8 @@ var datePickerSlotRecipe = defineSlotRecipe({
|
|
7133
7199
|
outline: "1px solid",
|
7134
7200
|
outlineColor: "floating.outline",
|
7135
7201
|
boxShadow: "md",
|
7136
|
-
backgroundColor: "floating.surface"
|
7202
|
+
backgroundColor: "floating.surface",
|
7203
|
+
minHeight: "min-content"
|
7137
7204
|
},
|
7138
7205
|
rangeCalendarPopover: {
|
7139
7206
|
width: "43rem",
|