@vygruppen/spor-react 12.1.1 → 12.1.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/.turbo/turbo-build.log +11 -11
- package/.turbo/turbo-typegen.log +1 -1
- package/CHANGELOG.md +6 -0
- package/dist/index.d.mts +3 -39
- package/dist/index.d.ts +3 -39
- package/dist/index.js +56 -48
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +60 -52
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/button/Button.tsx +65 -53
- package/src/link/TextLink.tsx +44 -9
- package/src/theme/recipes/button.ts +5 -0
package/dist/index.mjs
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
import { useSlotRecipe, Accordion as Accordion$1, Stack, Box, HStack, Progress, defineRecipe, chakra, Text, useRecipe, Circle, Skeleton as Skeleton$1,
|
1
|
+
import { useSlotRecipe, Accordion as Accordion$1, Stack, Box, HStack, Progress, defineRecipe, chakra, Text, useRecipe, Circle, Skeleton as Skeleton$1, Button as Button$1, Group as Group$1, Badge as Badge$1, Code as Code$1, Clipboard as Clipboard$1, IconButton as IconButton$1, useDisclosure, Alert as Alert$1, Span, Flex, Breadcrumb as Breadcrumb$1, ClientOnly as ClientOnly$1, Field as Field$1, defineSlotRecipe, PopoverAnchor, useFieldContext, Popover as Popover$1, Portal, Dialog, createContext as createContext$1, Drawer as Drawer$1, Grid, GridItem, usePopoverContext, Checkbox as Checkbox$1, CheckboxGroup as CheckboxGroup$1, Fieldset as Fieldset$1, InputElement, Input as Input$1, List as List$1, ListItem, NativeSelect as NativeSelect$1, useControllableState, createListCollection, RadioGroup as RadioGroup$1, Select as Select$1, Switch as Switch$1, Textarea as Textarea$1, FieldLabel as FieldLabel$1, RadioCard as RadioCard$1, Separator as Separator$1, Link, Center, Pagination as Pagination$1, usePaginationContext, createToaster, Tabs as Tabs$1, Table as Table$1, defineSemanticTokens, defineTokens, defineAnimationStyles, defineGlobalStyles, defineTextStyles, createSystem, defaultBaseConfig, VisuallyHidden, defineConfig, BreadcrumbCurrentLink as BreadcrumbCurrentLink$1, BreadcrumbEllipsis as BreadcrumbEllipsis$1, BreadcrumbLink as BreadcrumbLink$1, useCheckbox, ChakraProvider, Toaster as Toaster$1, Toast, Icon } from '@chakra-ui/react';
|
2
2
|
export { Box, Center, Collapsible, Container, Em, Flex, For, FormatByte, FormatNumber, Grid, GridItem, HStack, Image, Kbd, LocaleProvider, Portal, Show, SimpleGrid, Spacer, Span, Stack, TableBody, TableCaption, TableCell, TableColumn, TableColumnHeader, TableFooter, TableHeader, TableRoot, TableRow, VStack, VisuallyHidden, createListCollection, createSystem, defineConfig, defineRecipe, defineStyle, useBreakpointValue, useCheckbox, useClipboard, useControllableProp, useDisclosure, useMediaQuery, useToken } from '@chakra-ui/react';
|
3
|
-
import { DropdownDownFill24Icon, CheckmarkFill18Icon, CopyOutline18Icon, CloseFill30Icon, CloseFill24Icon, CloseFill18Icon, DropdownDownFill18Icon, ServiceFill24Icon, WarningFill24Icon, DropdownRightFill18Icon, CalendarOutline24Icon, ArrowLeftFill24Icon, CloseOutline24Icon, SearchOutline24Icon, InformationFill24Icon, InformationFill18Icon, WarningFill18Icon, ErrorFill24Icon, ErrorFill18Icon,
|
3
|
+
import { DropdownDownFill24Icon, CheckmarkFill18Icon, CopyOutline18Icon, CloseFill30Icon, CloseFill24Icon, CloseFill18Icon, DropdownDownFill18Icon, ServiceFill24Icon, WarningFill24Icon, DropdownRightFill18Icon, CalendarOutline24Icon, ArrowLeftFill24Icon, CloseOutline24Icon, SearchOutline24Icon, InformationFill24Icon, InformationFill18Icon, WarningFill18Icon, ErrorFill24Icon, ErrorFill18Icon, Forward15MediaControllerFill30Icon, Backward15MediaControllerFill30Icon, PauseMediaControllerFill24Icon, PlayMediaControllerFill24Icon, NextMediaControllerFill30Icon, PreviousMediaControllerFill30Icon, ArrowRightFill18Icon, DropdownLeftOutline18Icon, DropdownRightOutline18Icon, WalkFill30Icon, WalkFill24Icon, WalkFill18Icon, AltTransportFill30Icon, AltTransportFill24Icon, AltTransportFill18Icon, TramFill30Icon, TramFill24Icon, TramFill18Icon, SubwayFill30Icon, SubwayFill24Icon, SubwayFill18Icon, FerryFill30Icon, FerryFill24Icon, FerryFill18Icon, BusFill30Icon, BusFill24Icon, BusFill18Icon, ExpressBusFill30Icon, ExpressBusFill24Icon, ExpressBusFill18Icon, TrainFill30Icon, TrainFill24Icon, TrainFill18Icon, LinkOutOutline24Icon, QuestionFill24Icon, ErrorOutline24Icon, SuccessFill24Icon, ArrowLeftOutline24Icon, ArrowRightOutline24Icon, DropdownLeftFill18Icon, SuccessFill18Icon } from '@vygruppen/spor-icon-react';
|
4
4
|
import * as React67 from 'react';
|
5
|
-
import React67__default, { forwardRef, createContext, useId, useEffect, useRef, useState, useMemo, useLayoutEffect, useContext } from 'react';
|
6
|
-
import {
|
5
|
+
import React67__default, { forwardRef, createContext, useId, cloneElement, useEffect, useRef, useState, isValidElement, useMemo, useLayoutEffect, useContext } from 'react';
|
6
|
+
import { spinnerColorData, inlineLoaderColorData, contentLoaderData, fullScreenLoaderWhiteData, inlineLoaderDarkData, spinnerLightData, spinnerDarkData, fullScreenLoaderBlackData, inlineLoaderLightData } from '@vygruppen/spor-loader';
|
7
7
|
import ReactLottie from 'lottie-react';
|
8
8
|
import { useInterval } from 'usehooks-ts';
|
9
9
|
export { useIsClient, useMap, useOnClickOutside } from 'usehooks-ts';
|
@@ -548,22 +548,36 @@ var Skeleton = forwardRef(
|
|
548
548
|
);
|
549
549
|
|
550
550
|
// src/button/Button.tsx
|
551
|
+
var ButtonContent = ({
|
552
|
+
leftIcon,
|
553
|
+
children,
|
554
|
+
rightIcon
|
555
|
+
}) => /* @__PURE__ */ React67__default.createElement(React67__default.Fragment, null, leftIcon, children, rightIcon && /* @__PURE__ */ React67__default.createElement(Span, { marginLeft: "auto" }, rightIcon));
|
556
|
+
var LoadingContent = ({
|
557
|
+
children,
|
558
|
+
loadingText
|
559
|
+
}) => /* @__PURE__ */ React67__default.createElement(React67__default.Fragment, null, /* @__PURE__ */ React67__default.createElement(Flex, { gap: "1", visibility: "hidden" }, children), /* @__PURE__ */ React67__default.createElement(Center, { position: "absolute", inset: "1px 0" }, /* @__PURE__ */ React67__default.createElement(ColorInlineLoader, { width: "80%", marginX: 2, marginY: 2 }), loadingText && /* @__PURE__ */ React67__default.createElement(Box, null, loadingText)));
|
551
560
|
var Button = forwardRef(
|
552
|
-
(
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
} =
|
565
|
-
const ariaLabel =
|
566
|
-
const
|
561
|
+
({
|
562
|
+
loading,
|
563
|
+
disabled,
|
564
|
+
loadingText,
|
565
|
+
variant = "primary",
|
566
|
+
size = "md",
|
567
|
+
leftIcon,
|
568
|
+
rightIcon,
|
569
|
+
type = "button",
|
570
|
+
children,
|
571
|
+
...rest
|
572
|
+
}, ref) => {
|
573
|
+
const { t } = useTranslation();
|
574
|
+
const ariaLabel = loading ? String(loadingText ?? t(texts2.loadingText)) : rest["aria-label"];
|
575
|
+
const renderContent = () => {
|
576
|
+
const content = rest.asChild ? children.props.children : children;
|
577
|
+
if (loading)
|
578
|
+
return /* @__PURE__ */ React67__default.createElement(LoadingContent, { size, loadingText }, /* @__PURE__ */ React67__default.createElement(ButtonContent, { leftIcon, rightIcon }, content));
|
579
|
+
return /* @__PURE__ */ React67__default.createElement(ButtonContent, { leftIcon, rightIcon }, content);
|
580
|
+
};
|
567
581
|
return /* @__PURE__ */ React67__default.createElement(
|
568
582
|
Button$1,
|
569
583
|
{
|
@@ -577,38 +591,12 @@ var Button = forwardRef(
|
|
577
591
|
size,
|
578
592
|
...rest
|
579
593
|
},
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
maxWidth: getLoaderWidth(size),
|
584
|
-
width: "80%",
|
585
|
-
marginX: 2,
|
586
|
-
marginY: 2
|
587
|
-
}
|
588
|
-
), loadingText && /* @__PURE__ */ React67__default.createElement(Box, null, loadingText))) : buttonContent
|
594
|
+
rest.asChild ? cloneElement(children, {
|
595
|
+
children: renderContent()
|
596
|
+
}) : renderContent()
|
589
597
|
);
|
590
598
|
}
|
591
599
|
);
|
592
|
-
function getLoaderWidth(size) {
|
593
|
-
switch (size) {
|
594
|
-
case "xs":
|
595
|
-
return "4rem";
|
596
|
-
case "sm":
|
597
|
-
return "4rem";
|
598
|
-
case "md":
|
599
|
-
return "5rem";
|
600
|
-
case "lg":
|
601
|
-
default:
|
602
|
-
return "6rem";
|
603
|
-
}
|
604
|
-
}
|
605
|
-
function useCorrectAriaLabel(props) {
|
606
|
-
const { t } = useTranslation();
|
607
|
-
if (props.loading) {
|
608
|
-
return String(props.loadingText) ?? t(texts2.loadingText);
|
609
|
-
}
|
610
|
-
return props["aria-label"];
|
611
|
-
}
|
612
600
|
var texts2 = createTexts({
|
613
601
|
loadingText: {
|
614
602
|
nb: "Laster\u2026",
|
@@ -4738,14 +4726,29 @@ var getDeviationLevelIcon = ({
|
|
4738
4726
|
return null;
|
4739
4727
|
}
|
4740
4728
|
};
|
4729
|
+
var ExternalIcon = ({ label }) => /* @__PURE__ */ React67__default.createElement(React67__default.Fragment, null, /* @__PURE__ */ React67__default.createElement(LinkOutOutline24Icon, { "aria-hidden": true }), /* @__PURE__ */ React67__default.createElement(VisuallyHidden, null, label));
|
4741
4730
|
var TextLink = forwardRef(
|
4742
|
-
({ children, ...props }, ref) => {
|
4743
|
-
var _a5;
|
4731
|
+
({ children, external, href, ...props }, ref) => {
|
4744
4732
|
const { t } = useTranslation();
|
4745
|
-
const
|
4746
|
-
|
4733
|
+
const isExternal = external ?? Boolean((href == null ? void 0 : href.startsWith("http://")) || (href == null ? void 0 : href.startsWith("https://")));
|
4734
|
+
const externalLabel = t ? t(texts18.externalLink) : texts18.externalLink.en;
|
4735
|
+
if (props.asChild && isValidElement(children)) {
|
4736
|
+
return /* @__PURE__ */ React67__default.createElement(Link, { href, ...props, ref }, cloneElement(children, {
|
4737
|
+
...children.props,
|
4738
|
+
children: /* @__PURE__ */ React67__default.createElement(React67__default.Fragment, null, children.props.children, isExternal && /* @__PURE__ */ React67__default.createElement(ExternalIcon, { label: externalLabel }))
|
4739
|
+
}));
|
4740
|
+
}
|
4741
|
+
return /* @__PURE__ */ React67__default.createElement(Link, { href, ...props, ref }, children, isExternal && /* @__PURE__ */ React67__default.createElement(ExternalIcon, { label: externalLabel }));
|
4747
4742
|
}
|
4748
4743
|
);
|
4744
|
+
var texts18 = createTexts({
|
4745
|
+
externalLink: {
|
4746
|
+
nb: "Ekstern lenke",
|
4747
|
+
nn: "Ekstern lenke",
|
4748
|
+
sv: "Extern l\xE4nk",
|
4749
|
+
en: "External link"
|
4750
|
+
}
|
4751
|
+
});
|
4749
4752
|
var List = List$1.Root;
|
4750
4753
|
var ListItem2 = List$1.Item;
|
4751
4754
|
var ListIndicator = List$1.Indicator;
|
@@ -6197,6 +6200,7 @@ var buttonRecipe = defineRecipe({
|
|
6197
6200
|
transitionDuration: "normal",
|
6198
6201
|
cursor: "pointer",
|
6199
6202
|
textWrap: "wrap",
|
6203
|
+
width: "fit-content",
|
6200
6204
|
paddingX: 3,
|
6201
6205
|
paddingY: 1,
|
6202
6206
|
_disabled: {
|
@@ -6301,6 +6305,10 @@ var buttonRecipe = defineRecipe({
|
|
6301
6305
|
fontWeight: "bold"
|
6302
6306
|
}
|
6303
6307
|
}
|
6308
|
+
},
|
6309
|
+
defaultVariants: {
|
6310
|
+
variant: "primary",
|
6311
|
+
size: "md"
|
6304
6312
|
}
|
6305
6313
|
});
|
6306
6314
|
|