@vygruppen/spor-react 7.0.1 → 7.1.0
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 +10 -10
- package/CHANGELOG.md +8 -0
- package/dist/{CountryCodeSelect-EKQUBVBJ.mjs → CountryCodeSelect-NMBC7YLP.mjs} +1 -1
- package/dist/{chunk-CSCLMQYA.mjs → chunk-UQDHT6S5.mjs} +97 -76
- package/dist/index.d.mts +47 -13
- package/dist/index.d.ts +47 -13
- package/dist/index.js +95 -74
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/stepper/Stepper.tsx +77 -53
- package/src/stepper/StepperStep.tsx +42 -51
- package/src/theme/components/stepper.ts +23 -9
package/.turbo/turbo-build.log
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
> @vygruppen/spor-react@7.0
|
2
|
+
> @vygruppen/spor-react@7.1.0 build
|
3
3
|
> tsup src/index.tsx --dts --treeshake --format cjs,esm
|
4
4
|
|
5
5
|
[34mCLI[39m Building entry: src/index.tsx
|
@@ -9,14 +9,14 @@
|
|
9
9
|
[34mCJS[39m Build start
|
10
10
|
[34mESM[39m Build start
|
11
11
|
"Collapse" is imported from external module "@chakra-ui/react" but never used in "dist/index.js".
|
12
|
-
"Collapse" is imported from external module "@chakra-ui/react" but never used in "dist/chunk-
|
12
|
+
"Collapse" is imported from external module "@chakra-ui/react" but never used in "dist/chunk-UQDHT6S5.mjs".
|
13
13
|
[34mDTS[39m Build start
|
14
|
-
[32mCJS[39m [1mdist/index.js [22m[
|
15
|
-
[32mCJS[39m ⚡️ Build success in
|
14
|
+
[32mCJS[39m [1mdist/index.js [22m[32m494.15 KB[39m
|
15
|
+
[32mCJS[39m ⚡️ Build success in 2222ms
|
16
16
|
[32mESM[39m [1mdist/index.mjs [22m[32m2.16 KB[39m
|
17
|
-
[32mESM[39m [1mdist/CountryCodeSelect-
|
18
|
-
[32mESM[39m [1mdist/chunk-
|
19
|
-
[32mESM[39m ⚡️ Build success in
|
20
|
-
[32mDTS[39m ⚡️ Build success in
|
21
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
22
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[
|
17
|
+
[32mESM[39m [1mdist/CountryCodeSelect-NMBC7YLP.mjs [22m[32m1.19 KB[39m
|
18
|
+
[32mESM[39m [1mdist/chunk-UQDHT6S5.mjs [22m[32m386.88 KB[39m
|
19
|
+
[32mESM[39m ⚡️ Build success in 2223ms
|
20
|
+
[32mDTS[39m ⚡️ Build success in 11100ms
|
21
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m264.83 KB[39m
|
22
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m264.83 KB[39m
|
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# @vygruppen/spor-react
|
2
2
|
|
3
|
+
## 7.1.0
|
4
|
+
|
5
|
+
### Minor Changes
|
6
|
+
|
7
|
+
- cd07ee5: Stepper: Redesign and re-implement the Stepper component.
|
8
|
+
|
9
|
+
This change also introduces a new prop – onBackButtonClick – which is called whenever the back button is clicked on smaller screen. It receives a boolean argument outlining whether or not the current step is the first one or not. If you don't pass this prop, the back button will be hidden on the first step.
|
10
|
+
|
3
11
|
## 7.0.1
|
4
12
|
|
5
13
|
### Patch Changes
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import tokens10__default from '@vygruppen/spor-design-tokens';
|
2
2
|
import * as tokens10 from '@vygruppen/spor-design-tokens';
|
3
3
|
export { tokens10 as tokens };
|
4
|
-
import { forwardRef, Divider as Divider$1, Stack as Stack$1, Accordion as Accordion$1, Skeleton as Skeleton$1, useButtonGroup, useStyleConfig, Box, Center, Flex, ButtonGroup as ButtonGroup$1, IconButton as IconButton$1, useMultiStyleConfig, Badge as Badge$1, Code as Code$1, Text, PopoverAnchor, FormLabel, useFormControlContext, PopoverContent, PopoverArrow, PopoverBody, FocusLock, Popover, InputGroup, PopoverTrigger, Portal, chakra, Checkbox as Checkbox$1, useCheckbox, FormControl as FormControl$1, InputLeftElement, Input as Input$1, InputRightElement, Select, useDisclosure, Button as Button$1, 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, useColorMode, SkeletonCircle as SkeletonCircle$1, SkeletonText as SkeletonText$1, useColorModeValue, Breadcrumb as Breadcrumb$1, BreadcrumbItem as BreadcrumbItem$1, BreadcrumbLink as BreadcrumbLink$1, Heading as Heading$1, CheckboxGroup as CheckboxGroup$1, List, ListItem, useFormControlProps, useFormControl, Drawer as Drawer$1, DrawerOverlay, DrawerCloseButton, DrawerBody, usePopoverContext, DarkMode, PopoverCloseButton, ChakraProvider,
|
4
|
+
import { forwardRef, Divider as Divider$1, Stack as Stack$1, Accordion as Accordion$1, Skeleton as Skeleton$1, useButtonGroup, useStyleConfig, Box, Center, Flex, ButtonGroup as ButtonGroup$1, IconButton as IconButton$1, useMultiStyleConfig, Badge as Badge$1, Code as Code$1, Text, PopoverAnchor, FormLabel, useFormControlContext, PopoverContent, PopoverArrow, PopoverBody, FocusLock, Popover, InputGroup, PopoverTrigger, Portal, chakra, Checkbox as Checkbox$1, useCheckbox, FormControl as FormControl$1, InputLeftElement, Input as Input$1, InputRightElement, Select, useDisclosure, Button as Button$1, 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, useColorMode, SkeletonCircle as SkeletonCircle$1, SkeletonText as SkeletonText$1, useColorModeValue, Breadcrumb as Breadcrumb$1, BreadcrumbItem as BreadcrumbItem$1, BreadcrumbLink as BreadcrumbLink$1, Heading as Heading$1, CheckboxGroup as CheckboxGroup$1, List, ListItem, useFormControlProps, useFormControl, Drawer as Drawer$1, DrawerOverlay, DrawerCloseButton, DrawerBody, usePopoverContext, DarkMode, PopoverCloseButton, ChakraProvider, useToast as useToast$1, useInterval } from '@chakra-ui/react';
|
5
5
|
export { AccordionButton, AccordionIcon, AccordionItem, AccordionPanel, Box, Center, Container, DarkMode, DrawerBody, DrawerCloseButton, DrawerFooter, DrawerOverlay, Fade, Flex, FormHelperText, Grid, GridItem, HStack, Image, Img, InputGroup, LightMode, ListItem, Modal, ModalBody, ModalCloseButton, ModalContent, ModalFooter, ModalOverlay, OrderedList, Popover, PopoverAnchor, PopoverArrow, PopoverBody, PopoverCloseButton, PopoverContent, PopoverFooter, PopoverHeader, PopoverTrigger, Portal, ScaleFade, SimpleGrid, Slide, SlideFade, Spacer, Tab, TabList, TabPanel, TabPanels, TableCaption, Tbody, Td, Tfoot, Th, Thead, Tr, UnorderedList, VStack, Wrap, WrapItem, defineStyleConfig, extendTheme, useBreakpointValue, useClipboard, useColorMode, useColorModePreference, useColorModeValue, useControllableProp, useDisclosure, useMediaQuery, useMergeRefs, useOutsideClick, usePrefersReducedMotion, useTheme, useToken } from '@chakra-ui/react';
|
6
6
|
import * as React69 from 'react';
|
7
7
|
import React69__default, { createContext, useEffect, forwardRef as forwardRef$1, useRef, useState, useId, Suspense, useContext, useCallback, useMemo, useLayoutEffect } from 'react';
|
8
|
-
import { CloseFill30Icon, CloseFill24Icon, CloseFill18Icon, CalendarOutline24Icon, CloseOutline24Icon, SearchOutline24Icon, InformationFill24Icon, InformationFill18Icon, WarningFill24Icon, WarningFill18Icon, ErrorFill24Icon, ErrorFill18Icon, LinkOutOutline24Icon, DropdownRightFill18Icon, DropdownLeftFill18Icon, DropdownDownFill18Icon, DropdownDownFill24Icon, DropdownUpFill24Icon, ArrowRightFill18Icon,
|
8
|
+
import { CloseFill30Icon, CloseFill24Icon, CloseFill18Icon, CalendarOutline24Icon, CloseOutline24Icon, SearchOutline24Icon, InformationFill24Icon, InformationFill18Icon, WarningFill24Icon, WarningFill18Icon, ErrorFill24Icon, ErrorFill18Icon, LinkOutOutline24Icon, DropdownRightFill18Icon, DropdownLeftFill18Icon, DropdownDownFill18Icon, DropdownDownFill24Icon, DropdownUpFill24Icon, ArrowRightFill18Icon, ArrowLeftFill24Icon, ArrowLeftOutline24Icon, ArrowRightOutline24Icon, ErrorOutline24Icon, AltTransportOutline24Icon, WarningOutline24Icon, SuccessOutline24Icon, InformationOutline24Icon, 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, fullScreenLoaderBlackData, inlineLoaderLightData, spinnerLightData, spinnerDarkData } from '@vygruppen/spor-loader';
|
10
10
|
import { useLottie } from 'lottie-react';
|
11
11
|
import { useDateSegment, useDateField, useDatePicker, I18nProvider, usePopover, DismissButton, Overlay, useOverlayTrigger, useButton, useProgressBar, useCalendar, useDateRangePicker, useDialog, useFilter, useComboBox, useListBox, useOption, useListBoxSection, useSelect, HiddenSelect, useCalendarGrid, useRangeCalendar, useTimeField, useCalendarCell } from 'react-aria';
|
@@ -3417,7 +3417,7 @@ var texts14 = createTexts({
|
|
3417
3417
|
sv: "Telefonnummer"
|
3418
3418
|
}
|
3419
3419
|
});
|
3420
|
-
var LazyCountryCodeSelect = React69__default.lazy(() => import('./CountryCodeSelect-
|
3420
|
+
var LazyCountryCodeSelect = React69__default.lazy(() => import('./CountryCodeSelect-NMBC7YLP.mjs'));
|
3421
3421
|
var Radio = forwardRef((props, ref) => {
|
3422
3422
|
return /* @__PURE__ */ React69__default.createElement(Radio$1, { ...props, ref });
|
3423
3423
|
});
|
@@ -4268,16 +4268,22 @@ var useStepper = () => {
|
|
4268
4268
|
var Stepper = ({
|
4269
4269
|
onClick = () => {
|
4270
4270
|
},
|
4271
|
+
onBackButtonClick,
|
4271
4272
|
steps,
|
4272
4273
|
activeStep: activeStepAsStringOrNumber,
|
4273
4274
|
title,
|
4274
|
-
|
4275
|
+
heading,
|
4276
|
+
headingLevel,
|
4277
|
+
variant,
|
4278
|
+
isDisabled
|
4275
4279
|
}) => {
|
4276
4280
|
const style = useMultiStyleConfig("Stepper", { variant });
|
4277
4281
|
const numberOfSteps = steps.length;
|
4278
4282
|
const activeStep = Number(activeStepAsStringOrNumber);
|
4279
4283
|
const { t: t2 } = useTranslation();
|
4280
|
-
|
4284
|
+
const hideBackButtonOnFirstStep = activeStep === 1 && !onBackButtonClick;
|
4285
|
+
const shownHeading = heading || title;
|
4286
|
+
return /* @__PURE__ */ React69__default.createElement(Box, { sx: style.root }, /* @__PURE__ */ React69__default.createElement(
|
4281
4287
|
StepperProvider,
|
4282
4288
|
{
|
4283
4289
|
onClick,
|
@@ -4285,40 +4291,51 @@ var Stepper = ({
|
|
4285
4291
|
variant,
|
4286
4292
|
numberOfSteps
|
4287
4293
|
},
|
4288
|
-
/* @__PURE__ */ React69__default.createElement(Box, {
|
4289
|
-
|
4290
|
-
{
|
4291
|
-
"aria-label": t2(texts22.back),
|
4292
|
-
icon: /* @__PURE__ */ React69__default.createElement(DropdownLeftFill24Icon, null),
|
4293
|
-
variant: "ghost",
|
4294
|
-
size: "sm",
|
4295
|
-
onClick: () => onClick(activeStep - 1),
|
4296
|
-
__css: style.backButton
|
4297
|
-
}
|
4298
|
-
), /* @__PURE__ */ React69__default.createElement(
|
4299
|
-
SimplePopover,
|
4294
|
+
/* @__PURE__ */ React69__default.createElement(Box, { sx: style.container }, /* @__PURE__ */ React69__default.createElement(Box, { sx: style.innerContainer }, /* @__PURE__ */ React69__default.createElement(
|
4295
|
+
Flex,
|
4300
4296
|
{
|
4301
|
-
|
4302
|
-
|
4297
|
+
justifyContent: "space-between",
|
4298
|
+
alignItems: "center",
|
4299
|
+
gap: 2,
|
4300
|
+
flex: 1
|
4303
4301
|
},
|
4304
|
-
|
4305
|
-
|
4302
|
+
/* @__PURE__ */ React69__default.createElement(
|
4303
|
+
IconButton,
|
4306
4304
|
{
|
4307
|
-
|
4308
|
-
|
4309
|
-
variant
|
4310
|
-
|
4311
|
-
|
4312
|
-
|
4313
|
-
|
4305
|
+
"aria-label": t2(texts22.back),
|
4306
|
+
icon: /* @__PURE__ */ React69__default.createElement(ArrowLeftFill24Icon, null),
|
4307
|
+
variant: "ghost",
|
4308
|
+
size: "sm",
|
4309
|
+
visibility: hideBackButtonOnFirstStep ? "hidden" : "visible",
|
4310
|
+
onClick: () => {
|
4311
|
+
if (onBackButtonClick) {
|
4312
|
+
onBackButtonClick(activeStep === 1);
|
4313
|
+
}
|
4314
|
+
onClick(activeStep - 1);
|
4315
|
+
}
|
4316
|
+
}
|
4317
|
+
),
|
4318
|
+
shownHeading && /* @__PURE__ */ React69__default.createElement(Text4, { flex: 1, variant: "sm", as: headingLevel, sx: style.title }, shownHeading),
|
4319
|
+
/* @__PURE__ */ React69__default.createElement(Box, { sx: style.stepCounter }, t2(texts22.stepsOf(activeStep, numberOfSteps)))
|
4320
|
+
)), /* @__PURE__ */ React69__default.createElement(Flex, { justifyContent: "center", display: ["none", null, "flex"] }, steps.map((step, index) => /* @__PURE__ */ React69__default.createElement(
|
4321
|
+
StepperStep,
|
4322
|
+
{
|
4323
|
+
key: index,
|
4324
|
+
stepNumber: index + 1,
|
4325
|
+
variant,
|
4326
|
+
"aria-current": index + 1 === activeStep ? "step" : void 0,
|
4327
|
+
isDisabled
|
4328
|
+
},
|
4329
|
+
step
|
4330
|
+
))))
|
4314
4331
|
));
|
4315
4332
|
};
|
4316
4333
|
var texts22 = createTexts({
|
4317
4334
|
stepsOf: (activeStep, numberOfSteps) => ({
|
4318
|
-
nb: `Steg ${activeStep}
|
4319
|
-
nn: `Steg ${activeStep}
|
4320
|
-
sv: `Steg ${activeStep}
|
4321
|
-
en: `Step ${activeStep}
|
4335
|
+
nb: `Steg ${activeStep}/${numberOfSteps}`,
|
4336
|
+
nn: `Steg ${activeStep}/${numberOfSteps}`,
|
4337
|
+
sv: `Steg ${activeStep}/${numberOfSteps}`,
|
4338
|
+
en: `Step ${activeStep}/${numberOfSteps}`
|
4322
4339
|
}),
|
4323
4340
|
back: {
|
4324
4341
|
nb: "Tilbake",
|
@@ -4330,7 +4347,8 @@ var texts22 = createTexts({
|
|
4330
4347
|
var StepperStep = ({
|
4331
4348
|
children,
|
4332
4349
|
stepNumber,
|
4333
|
-
variant
|
4350
|
+
variant,
|
4351
|
+
isDisabled: isDisabledOverride
|
4334
4352
|
}) => {
|
4335
4353
|
const { activeStep, onClick } = useStepper();
|
4336
4354
|
const state2 = getState(stepNumber, activeStep);
|
@@ -4338,45 +4356,42 @@ var StepperStep = ({
|
|
4338
4356
|
state: state2,
|
4339
4357
|
variant
|
4340
4358
|
});
|
4341
|
-
const
|
4342
|
-
|
4359
|
+
const disabledTextColor = useColorModeValue(
|
4360
|
+
"blackAlpha.400",
|
4361
|
+
"whiteAlpha.400"
|
4362
|
+
);
|
4363
|
+
const iconColor = useColorModeValue("blackAlpha.200", "whiteAlpha.200");
|
4364
|
+
const isDisabled = state2 !== "active" && isDisabledOverride || state2 === "disabled";
|
4365
|
+
return /* @__PURE__ */ React69__default.createElement(Box, { sx: style.stepContainer }, stepNumber > 1 && /* @__PURE__ */ React69__default.createElement(
|
4366
|
+
DropdownRightFill18Icon,
|
4367
|
+
{
|
4368
|
+
marginX: 5,
|
4369
|
+
display: ["none", null, "block"],
|
4370
|
+
color: iconColor
|
4371
|
+
}
|
4372
|
+
), isDisabled ? /* @__PURE__ */ React69__default.createElement(
|
4373
|
+
Text4,
|
4374
|
+
{
|
4375
|
+
variant: "xs",
|
4376
|
+
fontSize: "16px",
|
4377
|
+
color: disabledTextColor,
|
4378
|
+
cursor: "default",
|
4379
|
+
paddingX: 2
|
4380
|
+
},
|
4381
|
+
children
|
4382
|
+
) : /* @__PURE__ */ React69__default.createElement(
|
4343
4383
|
Button,
|
4344
4384
|
{
|
4345
4385
|
size: "xs",
|
4346
|
-
variant: state2 === "active" ? "primary" :
|
4347
|
-
|
4348
|
-
|
4386
|
+
variant: state2 === "active" ? "primary" : "ghost",
|
4387
|
+
onClick: state2 === "completed" ? () => onClick(stepNumber) : void 0,
|
4388
|
+
pointerEvents: state2 === "active" ? "none" : "auto",
|
4389
|
+
tabIndex: state2 === "active" ? -1 : void 0,
|
4390
|
+
sx: style.stepButton
|
4349
4391
|
},
|
4350
4392
|
children
|
4351
4393
|
));
|
4352
4394
|
};
|
4353
|
-
var getButtonStylesForState = (state2) => {
|
4354
|
-
switch (state2) {
|
4355
|
-
case "active":
|
4356
|
-
return {
|
4357
|
-
_hover: {},
|
4358
|
-
boxShadow: "none",
|
4359
|
-
_focus: {},
|
4360
|
-
_active: {},
|
4361
|
-
cursor: "auto"
|
4362
|
-
};
|
4363
|
-
case "completed":
|
4364
|
-
return {
|
4365
|
-
boxShadow: "none"
|
4366
|
-
};
|
4367
|
-
case "disabled":
|
4368
|
-
return {
|
4369
|
-
_disabled: {},
|
4370
|
-
_hover: {},
|
4371
|
-
_focus: {},
|
4372
|
-
_active: {},
|
4373
|
-
color: "dimGrey",
|
4374
|
-
cursor: "auto"
|
4375
|
-
};
|
4376
|
-
default:
|
4377
|
-
return {};
|
4378
|
-
}
|
4379
|
-
};
|
4380
4395
|
var getState = (stepNumber, activeStep) => {
|
4381
4396
|
if (stepNumber < activeStep) {
|
4382
4397
|
return "completed";
|
@@ -12578,7 +12593,6 @@ var parts14 = anatomy$1("stepper").parts(
|
|
12578
12593
|
"root",
|
12579
12594
|
"container",
|
12580
12595
|
"innerContainer",
|
12581
|
-
"backButton",
|
12582
12596
|
"title",
|
12583
12597
|
"stepCounter",
|
12584
12598
|
"stepContainer",
|
@@ -12608,13 +12622,8 @@ var config32 = helpers22.defineMultiStyleConfig({
|
|
12608
12622
|
overflow: "hidden",
|
12609
12623
|
display: ["flex", null, "none"],
|
12610
12624
|
alignItems: "center",
|
12611
|
-
justifyContent: "space-between"
|
12612
|
-
|
12613
|
-
backButton: {
|
12614
|
-
borderRadius: "xs",
|
12615
|
-
paddingX: 0,
|
12616
|
-
width: "auto",
|
12617
|
-
minWidth: "auto"
|
12625
|
+
justifyContent: "space-between",
|
12626
|
+
gap: 3
|
12618
12627
|
},
|
12619
12628
|
title: {
|
12620
12629
|
overflow: "hidden",
|
@@ -12622,8 +12631,8 @@ var config32 = helpers22.defineMultiStyleConfig({
|
|
12622
12631
|
WebkitLineClamp: 2,
|
12623
12632
|
display: "-webkit-box",
|
12624
12633
|
WebkitBoxOrient: "vertical",
|
12625
|
-
|
12626
|
-
|
12634
|
+
textAlign: "center",
|
12635
|
+
maxWidth: "80%"
|
12627
12636
|
},
|
12628
12637
|
stepContainer: {
|
12629
12638
|
display: "flex",
|
@@ -12642,7 +12651,19 @@ var config32 = helpers22.defineMultiStyleConfig({
|
|
12642
12651
|
}),
|
12643
12652
|
accent: (props) => ({
|
12644
12653
|
root: {
|
12645
|
-
backgroundColor: mode("seaMist", "pine")(props)
|
12654
|
+
backgroundColor: mode("seaMist", "pine")(props),
|
12655
|
+
color: mode("darkTeal", "seaMist")(props)
|
12656
|
+
},
|
12657
|
+
stepButton: {
|
12658
|
+
color: props.state === "disabled" ? mode("blackAlpha.400", "whiteAlpha.400")(props) : props.state === "completed" ? mode("darkTeal", "white")(props) : mode("white", "darkTeal")(props),
|
12659
|
+
_hover: {
|
12660
|
+
backgroundColor: props.state === "disabled" ? "transparent" : mode("coralGreen", "greenHaze")(props)
|
12661
|
+
}
|
12662
|
+
},
|
12663
|
+
backButton: {
|
12664
|
+
_hover: {
|
12665
|
+
backgroundColor: mode("coralGreen", "greenHaze")(props)
|
12666
|
+
}
|
12646
12667
|
}
|
12647
12668
|
})
|
12648
12669
|
},
|
package/dist/index.d.mts
CHANGED
@@ -1953,11 +1953,37 @@ type SporProviderProps = ChakraProviderProps & {
|
|
1953
1953
|
declare const SporProvider: ({ theme, language, brand, children, ...props }: SporProviderProps) => React__default.JSX.Element;
|
1954
1954
|
|
1955
1955
|
type StepperProps = {
|
1956
|
+
/** Callback for when a step is clicked */
|
1956
1957
|
onClick: (clickedStep: number) => void;
|
1958
|
+
/** Callback for when the back button is clicked (on smaller screens).
|
1959
|
+
* A boolean indicating whether or not the user is on the first step is passed as an argument.
|
1960
|
+
*
|
1961
|
+
* If this is not provided, the back button will not be shown on smaller screens on the first step.
|
1962
|
+
*/
|
1963
|
+
onBackButtonClick?: (isFirstStep: boolean) => void;
|
1964
|
+
/**
|
1965
|
+
* Heading shown on smaller devices
|
1966
|
+
* @deprecated Use `heading` instead
|
1967
|
+
*/
|
1957
1968
|
title?: string;
|
1969
|
+
/** Heading shown on smaller devices */
|
1970
|
+
heading?: string;
|
1971
|
+
/**
|
1972
|
+
* The heading level rendered for the heading shown on smaller devices.
|
1973
|
+
*
|
1974
|
+
* Defaults to h2
|
1975
|
+
* */
|
1976
|
+
headingLevel?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p";
|
1977
|
+
/** The currently active step */
|
1958
1978
|
activeStep: number;
|
1979
|
+
/** The labels of each step */
|
1959
1980
|
steps: string[];
|
1981
|
+
/** The variant.
|
1982
|
+
* "base" has a transparent background,
|
1983
|
+
* while "accent" has a slight accent color */
|
1960
1984
|
variant: "base" | "accent";
|
1985
|
+
/** Disables all clicks */
|
1986
|
+
isDisabled?: boolean;
|
1961
1987
|
};
|
1962
1988
|
/**
|
1963
1989
|
* A stepper is used to show which step of a process a user is currently in.
|
@@ -1966,21 +1992,22 @@ type StepperProps = {
|
|
1966
1992
|
*
|
1967
1993
|
* ```tsx
|
1968
1994
|
* <Stepper
|
1969
|
-
* title="
|
1995
|
+
* title="Example"
|
1970
1996
|
* onClick={handleStepClick}
|
1971
1997
|
* activeStep={2}
|
1972
|
-
* steps={['
|
1998
|
+
* steps={['Where', 'When', 'How']}
|
1973
1999
|
* />
|
1974
2000
|
* ```
|
1975
2001
|
**/
|
1976
|
-
declare const Stepper: ({ onClick, steps, activeStep: activeStepAsStringOrNumber, title, variant, }: StepperProps) => React__default.JSX.Element;
|
2002
|
+
declare const Stepper: ({ onClick, onBackButtonClick, steps, activeStep: activeStepAsStringOrNumber, title, heading, headingLevel, variant, isDisabled, }: StepperProps) => React__default.JSX.Element;
|
1977
2003
|
|
1978
2004
|
type StepperStepProps = {
|
1979
2005
|
children: React__default.ReactNode;
|
1980
2006
|
stepNumber: number;
|
1981
2007
|
variant: "base" | "accent";
|
2008
|
+
isDisabled?: boolean;
|
1982
2009
|
};
|
1983
|
-
declare const StepperStep: ({ children, stepNumber, variant, }: StepperStepProps) => React__default.JSX.Element;
|
2010
|
+
declare const StepperStep: ({ children, stepNumber, variant, isDisabled: isDisabledOverride, }: StepperStepProps) => React__default.JSX.Element;
|
1984
2011
|
|
1985
2012
|
type TabsProps = Exclude<TabsProps$1, "colorScheme" | "variant" | "orientation" | "size"> & {
|
1986
2013
|
colorScheme: "base" | "accent";
|
@@ -4733,12 +4760,7 @@ declare const theme: {
|
|
4733
4760
|
display: ("flex" | "none" | null)[];
|
4734
4761
|
alignItems: string;
|
4735
4762
|
justifyContent: string;
|
4736
|
-
|
4737
|
-
backButton: {
|
4738
|
-
borderRadius: string;
|
4739
|
-
paddingX: number;
|
4740
|
-
width: string;
|
4741
|
-
minWidth: string;
|
4763
|
+
gap: number;
|
4742
4764
|
};
|
4743
4765
|
title: {
|
4744
4766
|
overflow: string;
|
@@ -4746,8 +4768,8 @@ declare const theme: {
|
|
4746
4768
|
WebkitLineClamp: number;
|
4747
4769
|
display: string;
|
4748
4770
|
WebkitBoxOrient: string;
|
4749
|
-
marginLeft: number;
|
4750
4771
|
textAlign: string;
|
4772
|
+
maxWidth: string;
|
4751
4773
|
};
|
4752
4774
|
stepContainer: {
|
4753
4775
|
display: string;
|
@@ -4760,7 +4782,7 @@ declare const theme: {
|
|
4760
4782
|
} | undefined;
|
4761
4783
|
sizes?: {
|
4762
4784
|
[key: string]: _chakra_ui_styled_system.PartsStyleInterpolation<{
|
4763
|
-
keys: ("title" | "container" | "closeButton" | "root" | "innerContainer" | "
|
4785
|
+
keys: ("title" | "container" | "closeButton" | "root" | "innerContainer" | "stepCounter" | "stepContainer" | "stepButton" | "stepNumber" | "stepTitle")[];
|
4764
4786
|
}>;
|
4765
4787
|
} | undefined;
|
4766
4788
|
variants?: {
|
@@ -4772,6 +4794,18 @@ declare const theme: {
|
|
4772
4794
|
accent: (props: _chakra_ui_styled_system.StyleFunctionProps) => {
|
4773
4795
|
root: {
|
4774
4796
|
backgroundColor: string;
|
4797
|
+
color: string;
|
4798
|
+
};
|
4799
|
+
stepButton: {
|
4800
|
+
color: string;
|
4801
|
+
_hover: {
|
4802
|
+
backgroundColor: string;
|
4803
|
+
};
|
4804
|
+
};
|
4805
|
+
backButton: {
|
4806
|
+
_hover: {
|
4807
|
+
backgroundColor: string;
|
4808
|
+
};
|
4775
4809
|
};
|
4776
4810
|
};
|
4777
4811
|
} | undefined;
|
@@ -4780,7 +4814,7 @@ declare const theme: {
|
|
4780
4814
|
variant?: "base" | "accent" | undefined;
|
4781
4815
|
colorScheme?: string | undefined;
|
4782
4816
|
} | undefined;
|
4783
|
-
parts: ("title" | "container" | "closeButton" | "root" | "innerContainer" | "
|
4817
|
+
parts: ("title" | "container" | "closeButton" | "root" | "innerContainer" | "stepCounter" | "stepContainer" | "stepButton" | "stepNumber" | "stepTitle")[];
|
4784
4818
|
};
|
4785
4819
|
Switch: {
|
4786
4820
|
baseStyle?: {
|
package/dist/index.d.ts
CHANGED
@@ -1953,11 +1953,37 @@ type SporProviderProps = ChakraProviderProps & {
|
|
1953
1953
|
declare const SporProvider: ({ theme, language, brand, children, ...props }: SporProviderProps) => React__default.JSX.Element;
|
1954
1954
|
|
1955
1955
|
type StepperProps = {
|
1956
|
+
/** Callback for when a step is clicked */
|
1956
1957
|
onClick: (clickedStep: number) => void;
|
1958
|
+
/** Callback for when the back button is clicked (on smaller screens).
|
1959
|
+
* A boolean indicating whether or not the user is on the first step is passed as an argument.
|
1960
|
+
*
|
1961
|
+
* If this is not provided, the back button will not be shown on smaller screens on the first step.
|
1962
|
+
*/
|
1963
|
+
onBackButtonClick?: (isFirstStep: boolean) => void;
|
1964
|
+
/**
|
1965
|
+
* Heading shown on smaller devices
|
1966
|
+
* @deprecated Use `heading` instead
|
1967
|
+
*/
|
1957
1968
|
title?: string;
|
1969
|
+
/** Heading shown on smaller devices */
|
1970
|
+
heading?: string;
|
1971
|
+
/**
|
1972
|
+
* The heading level rendered for the heading shown on smaller devices.
|
1973
|
+
*
|
1974
|
+
* Defaults to h2
|
1975
|
+
* */
|
1976
|
+
headingLevel?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p";
|
1977
|
+
/** The currently active step */
|
1958
1978
|
activeStep: number;
|
1979
|
+
/** The labels of each step */
|
1959
1980
|
steps: string[];
|
1981
|
+
/** The variant.
|
1982
|
+
* "base" has a transparent background,
|
1983
|
+
* while "accent" has a slight accent color */
|
1960
1984
|
variant: "base" | "accent";
|
1985
|
+
/** Disables all clicks */
|
1986
|
+
isDisabled?: boolean;
|
1961
1987
|
};
|
1962
1988
|
/**
|
1963
1989
|
* A stepper is used to show which step of a process a user is currently in.
|
@@ -1966,21 +1992,22 @@ type StepperProps = {
|
|
1966
1992
|
*
|
1967
1993
|
* ```tsx
|
1968
1994
|
* <Stepper
|
1969
|
-
* title="
|
1995
|
+
* title="Example"
|
1970
1996
|
* onClick={handleStepClick}
|
1971
1997
|
* activeStep={2}
|
1972
|
-
* steps={['
|
1998
|
+
* steps={['Where', 'When', 'How']}
|
1973
1999
|
* />
|
1974
2000
|
* ```
|
1975
2001
|
**/
|
1976
|
-
declare const Stepper: ({ onClick, steps, activeStep: activeStepAsStringOrNumber, title, variant, }: StepperProps) => React__default.JSX.Element;
|
2002
|
+
declare const Stepper: ({ onClick, onBackButtonClick, steps, activeStep: activeStepAsStringOrNumber, title, heading, headingLevel, variant, isDisabled, }: StepperProps) => React__default.JSX.Element;
|
1977
2003
|
|
1978
2004
|
type StepperStepProps = {
|
1979
2005
|
children: React__default.ReactNode;
|
1980
2006
|
stepNumber: number;
|
1981
2007
|
variant: "base" | "accent";
|
2008
|
+
isDisabled?: boolean;
|
1982
2009
|
};
|
1983
|
-
declare const StepperStep: ({ children, stepNumber, variant, }: StepperStepProps) => React__default.JSX.Element;
|
2010
|
+
declare const StepperStep: ({ children, stepNumber, variant, isDisabled: isDisabledOverride, }: StepperStepProps) => React__default.JSX.Element;
|
1984
2011
|
|
1985
2012
|
type TabsProps = Exclude<TabsProps$1, "colorScheme" | "variant" | "orientation" | "size"> & {
|
1986
2013
|
colorScheme: "base" | "accent";
|
@@ -4733,12 +4760,7 @@ declare const theme: {
|
|
4733
4760
|
display: ("flex" | "none" | null)[];
|
4734
4761
|
alignItems: string;
|
4735
4762
|
justifyContent: string;
|
4736
|
-
|
4737
|
-
backButton: {
|
4738
|
-
borderRadius: string;
|
4739
|
-
paddingX: number;
|
4740
|
-
width: string;
|
4741
|
-
minWidth: string;
|
4763
|
+
gap: number;
|
4742
4764
|
};
|
4743
4765
|
title: {
|
4744
4766
|
overflow: string;
|
@@ -4746,8 +4768,8 @@ declare const theme: {
|
|
4746
4768
|
WebkitLineClamp: number;
|
4747
4769
|
display: string;
|
4748
4770
|
WebkitBoxOrient: string;
|
4749
|
-
marginLeft: number;
|
4750
4771
|
textAlign: string;
|
4772
|
+
maxWidth: string;
|
4751
4773
|
};
|
4752
4774
|
stepContainer: {
|
4753
4775
|
display: string;
|
@@ -4760,7 +4782,7 @@ declare const theme: {
|
|
4760
4782
|
} | undefined;
|
4761
4783
|
sizes?: {
|
4762
4784
|
[key: string]: _chakra_ui_styled_system.PartsStyleInterpolation<{
|
4763
|
-
keys: ("title" | "container" | "closeButton" | "root" | "innerContainer" | "
|
4785
|
+
keys: ("title" | "container" | "closeButton" | "root" | "innerContainer" | "stepCounter" | "stepContainer" | "stepButton" | "stepNumber" | "stepTitle")[];
|
4764
4786
|
}>;
|
4765
4787
|
} | undefined;
|
4766
4788
|
variants?: {
|
@@ -4772,6 +4794,18 @@ declare const theme: {
|
|
4772
4794
|
accent: (props: _chakra_ui_styled_system.StyleFunctionProps) => {
|
4773
4795
|
root: {
|
4774
4796
|
backgroundColor: string;
|
4797
|
+
color: string;
|
4798
|
+
};
|
4799
|
+
stepButton: {
|
4800
|
+
color: string;
|
4801
|
+
_hover: {
|
4802
|
+
backgroundColor: string;
|
4803
|
+
};
|
4804
|
+
};
|
4805
|
+
backButton: {
|
4806
|
+
_hover: {
|
4807
|
+
backgroundColor: string;
|
4808
|
+
};
|
4775
4809
|
};
|
4776
4810
|
};
|
4777
4811
|
} | undefined;
|
@@ -4780,7 +4814,7 @@ declare const theme: {
|
|
4780
4814
|
variant?: "base" | "accent" | undefined;
|
4781
4815
|
colorScheme?: string | undefined;
|
4782
4816
|
} | undefined;
|
4783
|
-
parts: ("title" | "container" | "closeButton" | "root" | "innerContainer" | "
|
4817
|
+
parts: ("title" | "container" | "closeButton" | "root" | "innerContainer" | "stepCounter" | "stepContainer" | "stepButton" | "stepNumber" | "stepTitle")[];
|
4784
4818
|
};
|
4785
4819
|
Switch: {
|
4786
4820
|
baseStyle?: {
|
package/dist/index.js
CHANGED
@@ -5140,16 +5140,22 @@ var init_Stepper = __esm({
|
|
5140
5140
|
exports.Stepper = ({
|
5141
5141
|
onClick = () => {
|
5142
5142
|
},
|
5143
|
+
onBackButtonClick,
|
5143
5144
|
steps,
|
5144
5145
|
activeStep: activeStepAsStringOrNumber,
|
5145
5146
|
title,
|
5146
|
-
|
5147
|
+
heading,
|
5148
|
+
headingLevel,
|
5149
|
+
variant,
|
5150
|
+
isDisabled
|
5147
5151
|
}) => {
|
5148
5152
|
const style = react.useMultiStyleConfig("Stepper", { variant });
|
5149
5153
|
const numberOfSteps = steps.length;
|
5150
5154
|
const activeStep = Number(activeStepAsStringOrNumber);
|
5151
5155
|
const { t: t2 } = useTranslation();
|
5152
|
-
|
5156
|
+
const hideBackButtonOnFirstStep = activeStep === 1 && !onBackButtonClick;
|
5157
|
+
const shownHeading = heading || title;
|
5158
|
+
return /* @__PURE__ */ React69__namespace.default.createElement(react.Box, { sx: style.root }, /* @__PURE__ */ React69__namespace.default.createElement(
|
5153
5159
|
StepperProvider,
|
5154
5160
|
{
|
5155
5161
|
onClick,
|
@@ -5157,40 +5163,51 @@ var init_Stepper = __esm({
|
|
5157
5163
|
variant,
|
5158
5164
|
numberOfSteps
|
5159
5165
|
},
|
5160
|
-
/* @__PURE__ */ React69__namespace.default.createElement(react.Box, {
|
5161
|
-
|
5162
|
-
{
|
5163
|
-
"aria-label": t2(texts23.back),
|
5164
|
-
icon: /* @__PURE__ */ React69__namespace.default.createElement(sporIconReact.DropdownLeftFill24Icon, null),
|
5165
|
-
variant: "ghost",
|
5166
|
-
size: "sm",
|
5167
|
-
onClick: () => onClick(activeStep - 1),
|
5168
|
-
__css: style.backButton
|
5169
|
-
}
|
5170
|
-
), /* @__PURE__ */ React69__namespace.default.createElement(
|
5171
|
-
exports.SimplePopover,
|
5166
|
+
/* @__PURE__ */ React69__namespace.default.createElement(react.Box, { sx: style.container }, /* @__PURE__ */ React69__namespace.default.createElement(react.Box, { sx: style.innerContainer }, /* @__PURE__ */ React69__namespace.default.createElement(
|
5167
|
+
react.Flex,
|
5172
5168
|
{
|
5173
|
-
|
5174
|
-
|
5169
|
+
justifyContent: "space-between",
|
5170
|
+
alignItems: "center",
|
5171
|
+
gap: 2,
|
5172
|
+
flex: 1
|
5175
5173
|
},
|
5176
|
-
|
5177
|
-
exports.
|
5174
|
+
/* @__PURE__ */ React69__namespace.default.createElement(
|
5175
|
+
exports.IconButton,
|
5178
5176
|
{
|
5179
|
-
|
5180
|
-
|
5181
|
-
variant
|
5182
|
-
|
5183
|
-
|
5184
|
-
|
5185
|
-
|
5177
|
+
"aria-label": t2(texts23.back),
|
5178
|
+
icon: /* @__PURE__ */ React69__namespace.default.createElement(sporIconReact.ArrowLeftFill24Icon, null),
|
5179
|
+
variant: "ghost",
|
5180
|
+
size: "sm",
|
5181
|
+
visibility: hideBackButtonOnFirstStep ? "hidden" : "visible",
|
5182
|
+
onClick: () => {
|
5183
|
+
if (onBackButtonClick) {
|
5184
|
+
onBackButtonClick(activeStep === 1);
|
5185
|
+
}
|
5186
|
+
onClick(activeStep - 1);
|
5187
|
+
}
|
5188
|
+
}
|
5189
|
+
),
|
5190
|
+
shownHeading && /* @__PURE__ */ React69__namespace.default.createElement(exports.Text, { flex: 1, variant: "sm", as: headingLevel, sx: style.title }, shownHeading),
|
5191
|
+
/* @__PURE__ */ React69__namespace.default.createElement(react.Box, { sx: style.stepCounter }, t2(texts23.stepsOf(activeStep, numberOfSteps)))
|
5192
|
+
)), /* @__PURE__ */ React69__namespace.default.createElement(react.Flex, { justifyContent: "center", display: ["none", null, "flex"] }, steps.map((step, index) => /* @__PURE__ */ React69__namespace.default.createElement(
|
5193
|
+
exports.StepperStep,
|
5194
|
+
{
|
5195
|
+
key: index,
|
5196
|
+
stepNumber: index + 1,
|
5197
|
+
variant,
|
5198
|
+
"aria-current": index + 1 === activeStep ? "step" : void 0,
|
5199
|
+
isDisabled
|
5200
|
+
},
|
5201
|
+
step
|
5202
|
+
))))
|
5186
5203
|
));
|
5187
5204
|
};
|
5188
5205
|
texts23 = createTexts({
|
5189
5206
|
stepsOf: (activeStep, numberOfSteps) => ({
|
5190
|
-
nb: `Steg ${activeStep}
|
5191
|
-
nn: `Steg ${activeStep}
|
5192
|
-
sv: `Steg ${activeStep}
|
5193
|
-
en: `Step ${activeStep}
|
5207
|
+
nb: `Steg ${activeStep}/${numberOfSteps}`,
|
5208
|
+
nn: `Steg ${activeStep}/${numberOfSteps}`,
|
5209
|
+
sv: `Steg ${activeStep}/${numberOfSteps}`,
|
5210
|
+
en: `Step ${activeStep}/${numberOfSteps}`
|
5194
5211
|
}),
|
5195
5212
|
back: {
|
5196
5213
|
nb: "Tilbake",
|
@@ -5201,7 +5218,7 @@ var init_Stepper = __esm({
|
|
5201
5218
|
});
|
5202
5219
|
}
|
5203
5220
|
});
|
5204
|
-
exports.StepperStep = void 0; var
|
5221
|
+
exports.StepperStep = void 0; var getState;
|
5205
5222
|
var init_StepperStep = __esm({
|
5206
5223
|
"src/stepper/StepperStep.tsx"() {
|
5207
5224
|
init_src();
|
@@ -5209,7 +5226,8 @@ var init_StepperStep = __esm({
|
|
5209
5226
|
exports.StepperStep = ({
|
5210
5227
|
children,
|
5211
5228
|
stepNumber,
|
5212
|
-
variant
|
5229
|
+
variant,
|
5230
|
+
isDisabled: isDisabledOverride
|
5213
5231
|
}) => {
|
5214
5232
|
const { activeStep, onClick } = useStepper();
|
5215
5233
|
const state2 = getState(stepNumber, activeStep);
|
@@ -5217,45 +5235,42 @@ var init_StepperStep = __esm({
|
|
5217
5235
|
state: state2,
|
5218
5236
|
variant
|
5219
5237
|
});
|
5220
|
-
const
|
5221
|
-
|
5238
|
+
const disabledTextColor = react.useColorModeValue(
|
5239
|
+
"blackAlpha.400",
|
5240
|
+
"whiteAlpha.400"
|
5241
|
+
);
|
5242
|
+
const iconColor = react.useColorModeValue("blackAlpha.200", "whiteAlpha.200");
|
5243
|
+
const isDisabled = state2 !== "active" && isDisabledOverride || state2 === "disabled";
|
5244
|
+
return /* @__PURE__ */ React69__namespace.default.createElement(react.Box, { sx: style.stepContainer }, stepNumber > 1 && /* @__PURE__ */ React69__namespace.default.createElement(
|
5245
|
+
sporIconReact.DropdownRightFill18Icon,
|
5246
|
+
{
|
5247
|
+
marginX: 5,
|
5248
|
+
display: ["none", null, "block"],
|
5249
|
+
color: iconColor
|
5250
|
+
}
|
5251
|
+
), isDisabled ? /* @__PURE__ */ React69__namespace.default.createElement(
|
5252
|
+
exports.Text,
|
5253
|
+
{
|
5254
|
+
variant: "xs",
|
5255
|
+
fontSize: "16px",
|
5256
|
+
color: disabledTextColor,
|
5257
|
+
cursor: "default",
|
5258
|
+
paddingX: 2
|
5259
|
+
},
|
5260
|
+
children
|
5261
|
+
) : /* @__PURE__ */ React69__namespace.default.createElement(
|
5222
5262
|
exports.Button,
|
5223
5263
|
{
|
5224
5264
|
size: "xs",
|
5225
|
-
variant: state2 === "active" ? "primary" :
|
5226
|
-
|
5227
|
-
|
5265
|
+
variant: state2 === "active" ? "primary" : "ghost",
|
5266
|
+
onClick: state2 === "completed" ? () => onClick(stepNumber) : void 0,
|
5267
|
+
pointerEvents: state2 === "active" ? "none" : "auto",
|
5268
|
+
tabIndex: state2 === "active" ? -1 : void 0,
|
5269
|
+
sx: style.stepButton
|
5228
5270
|
},
|
5229
5271
|
children
|
5230
5272
|
));
|
5231
5273
|
};
|
5232
|
-
getButtonStylesForState = (state2) => {
|
5233
|
-
switch (state2) {
|
5234
|
-
case "active":
|
5235
|
-
return {
|
5236
|
-
_hover: {},
|
5237
|
-
boxShadow: "none",
|
5238
|
-
_focus: {},
|
5239
|
-
_active: {},
|
5240
|
-
cursor: "auto"
|
5241
|
-
};
|
5242
|
-
case "completed":
|
5243
|
-
return {
|
5244
|
-
boxShadow: "none"
|
5245
|
-
};
|
5246
|
-
case "disabled":
|
5247
|
-
return {
|
5248
|
-
_disabled: {},
|
5249
|
-
_hover: {},
|
5250
|
-
_focus: {},
|
5251
|
-
_active: {},
|
5252
|
-
color: "dimGrey",
|
5253
|
-
cursor: "auto"
|
5254
|
-
};
|
5255
|
-
default:
|
5256
|
-
return {};
|
5257
|
-
}
|
5258
|
-
};
|
5259
5274
|
getState = (stepNumber, activeStep) => {
|
5260
5275
|
if (stepNumber < activeStep) {
|
5261
5276
|
return "completed";
|
@@ -14229,7 +14244,6 @@ var init_stepper2 = __esm({
|
|
14229
14244
|
"root",
|
14230
14245
|
"container",
|
14231
14246
|
"innerContainer",
|
14232
|
-
"backButton",
|
14233
14247
|
"title",
|
14234
14248
|
"stepCounter",
|
14235
14249
|
"stepContainer",
|
@@ -14259,13 +14273,8 @@ var init_stepper2 = __esm({
|
|
14259
14273
|
overflow: "hidden",
|
14260
14274
|
display: ["flex", null, "none"],
|
14261
14275
|
alignItems: "center",
|
14262
|
-
justifyContent: "space-between"
|
14263
|
-
|
14264
|
-
backButton: {
|
14265
|
-
borderRadius: "xs",
|
14266
|
-
paddingX: 0,
|
14267
|
-
width: "auto",
|
14268
|
-
minWidth: "auto"
|
14276
|
+
justifyContent: "space-between",
|
14277
|
+
gap: 3
|
14269
14278
|
},
|
14270
14279
|
title: {
|
14271
14280
|
overflow: "hidden",
|
@@ -14273,8 +14282,8 @@ var init_stepper2 = __esm({
|
|
14273
14282
|
WebkitLineClamp: 2,
|
14274
14283
|
display: "-webkit-box",
|
14275
14284
|
WebkitBoxOrient: "vertical",
|
14276
|
-
|
14277
|
-
|
14285
|
+
textAlign: "center",
|
14286
|
+
maxWidth: "80%"
|
14278
14287
|
},
|
14279
14288
|
stepContainer: {
|
14280
14289
|
display: "flex",
|
@@ -14293,7 +14302,19 @@ var init_stepper2 = __esm({
|
|
14293
14302
|
}),
|
14294
14303
|
accent: (props) => ({
|
14295
14304
|
root: {
|
14296
|
-
backgroundColor: themeTools.mode("seaMist", "pine")(props)
|
14305
|
+
backgroundColor: themeTools.mode("seaMist", "pine")(props),
|
14306
|
+
color: themeTools.mode("darkTeal", "seaMist")(props)
|
14307
|
+
},
|
14308
|
+
stepButton: {
|
14309
|
+
color: props.state === "disabled" ? themeTools.mode("blackAlpha.400", "whiteAlpha.400")(props) : props.state === "completed" ? themeTools.mode("darkTeal", "white")(props) : themeTools.mode("white", "darkTeal")(props),
|
14310
|
+
_hover: {
|
14311
|
+
backgroundColor: props.state === "disabled" ? "transparent" : themeTools.mode("coralGreen", "greenHaze")(props)
|
14312
|
+
}
|
14313
|
+
},
|
14314
|
+
backButton: {
|
14315
|
+
_hover: {
|
14316
|
+
backgroundColor: themeTools.mode("coralGreen", "greenHaze")(props)
|
14317
|
+
}
|
14297
14318
|
}
|
14298
14319
|
})
|
14299
14320
|
},
|
package/dist/index.mjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export { Accordion, AccordionButton, AccordionIcon, AccordionItem, AccordionPanel, AttachedInputs, Badge, Box, Brand, Breadcrumb, BreadcrumbItem, BreadcrumbLink, Button, ButtonGroup, Card, CardSelect, Center, Checkbox, CheckboxGroup, ChoiceChip, ClosableAlert, CloseButton, Code, ColorInlineLoader, ColorSpinner, Combobox, Container, ContentLoader, DarkFullScreenLoader, DarkInlineLoader, DarkMode, DarkSpinner, DatePicker, DateRangePicker, Divider, Drawer, DrawerBody, DrawerCloseButton, DrawerContent, DrawerFooter, ModalHeader as DrawerHeader, DrawerOverlay, Expandable, ExpandableAlert, ExpandableItem, Fade, Flex, FloatingActionButton, FormControl, FormErrorMessage, FormHelperText, FormLabel, Grid, GridItem, HStack, Heading, IconButton, Image, Img, InfoSelect, InfoTag, Input, InputGroup, InputLeftElement, InputRightElement, Item, ItemDescription, ItemLabel, JumpButton, Language, LanguageProvider, LightFullScreenLoader, LightInlineLoader, LightMode, LightSpinner, LineIcon, ListBox, ListItem, Modal, ModalBody, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalOverlay, NativeSelect, NumericStepper, OrderedList, PasswordInput, PhoneNumberInput, PlayPauseButton, Popover, PopoverAnchor, PopoverArrow, PopoverBody, PopoverCloseButton, PopoverContent, PopoverFooter, PopoverHeader, PopoverTrigger, PopoverWizardBody, Portal, ProgressBar, ProgressIndicator, ProgressLoader, Radio, RadioGroup, ScaleFade, SearchInput, Section, SimpleDrawer, SimpleGrid, SimplePopover, Skeleton, SkeletonCircle, SkeletonText, SkipButton, Slide, SlideFade, Spacer, SporProvider, Stack, StaticAlert, Stepper, StepperStep, Switch, Tab, TabList, TabPanel, TabPanels, Table, TableCaption, Tabs, Tbody, Td, Text, TextLink, Textarea, Tfoot, Th, Thead, Time, TimePicker, Tr, TravelTag, UnorderedList, VStack, VyLogo, WizardPopover, Wrap, WrapItem, brandTheme, createTexts, defineStyleConfig, extendTheme, fontFaces, theme, tokens, useBreakpointValue, useClipboard, useColorMode, useColorModePreference, useColorModeValue, useControllableProp, useDisclosure, useMediaQuery, useMergeRefs, useOutsideClick, usePrefersReducedMotion, useSize, useTheme, useToast, useToken, useTranslation } from './chunk-
|
1
|
+
export { Accordion, AccordionButton, AccordionIcon, AccordionItem, AccordionPanel, AttachedInputs, Badge, Box, Brand, Breadcrumb, BreadcrumbItem, BreadcrumbLink, Button, ButtonGroup, Card, CardSelect, Center, Checkbox, CheckboxGroup, ChoiceChip, ClosableAlert, CloseButton, Code, ColorInlineLoader, ColorSpinner, Combobox, Container, ContentLoader, DarkFullScreenLoader, DarkInlineLoader, DarkMode, DarkSpinner, DatePicker, DateRangePicker, Divider, Drawer, DrawerBody, DrawerCloseButton, DrawerContent, DrawerFooter, ModalHeader as DrawerHeader, DrawerOverlay, Expandable, ExpandableAlert, ExpandableItem, Fade, Flex, FloatingActionButton, FormControl, FormErrorMessage, FormHelperText, FormLabel, Grid, GridItem, HStack, Heading, IconButton, Image, Img, InfoSelect, InfoTag, Input, InputGroup, InputLeftElement, InputRightElement, Item, ItemDescription, ItemLabel, JumpButton, Language, LanguageProvider, LightFullScreenLoader, LightInlineLoader, LightMode, LightSpinner, LineIcon, ListBox, ListItem, Modal, ModalBody, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalOverlay, NativeSelect, NumericStepper, OrderedList, PasswordInput, PhoneNumberInput, PlayPauseButton, Popover, PopoverAnchor, PopoverArrow, PopoverBody, PopoverCloseButton, PopoverContent, PopoverFooter, PopoverHeader, PopoverTrigger, PopoverWizardBody, Portal, ProgressBar, ProgressIndicator, ProgressLoader, Radio, RadioGroup, ScaleFade, SearchInput, Section, SimpleDrawer, SimpleGrid, SimplePopover, Skeleton, SkeletonCircle, SkeletonText, SkipButton, Slide, SlideFade, Spacer, SporProvider, Stack, StaticAlert, Stepper, StepperStep, Switch, Tab, TabList, TabPanel, TabPanels, Table, TableCaption, Tabs, Tbody, Td, Text, TextLink, Textarea, Tfoot, Th, Thead, Time, TimePicker, Tr, TravelTag, UnorderedList, VStack, VyLogo, WizardPopover, Wrap, WrapItem, brandTheme, createTexts, defineStyleConfig, extendTheme, fontFaces, theme, tokens, useBreakpointValue, useClipboard, useColorMode, useColorModePreference, useColorModeValue, useControllableProp, useDisclosure, useMediaQuery, useMergeRefs, useOutsideClick, usePrefersReducedMotion, useSize, useTheme, useToast, useToken, useTranslation } from './chunk-UQDHT6S5.mjs';
|
package/package.json
CHANGED
package/src/stepper/Stepper.tsx
CHANGED
@@ -1,22 +1,42 @@
|
|
1
|
-
import { Flex,
|
2
|
-
import {
|
1
|
+
import { Flex, useMultiStyleConfig } from "@chakra-ui/react";
|
2
|
+
import { ArrowLeftFill24Icon } from "@vygruppen/spor-icon-react";
|
3
3
|
import React from "react";
|
4
4
|
import { StepperStep } from ".";
|
5
|
-
import {
|
6
|
-
Box,
|
7
|
-
IconButton,
|
8
|
-
SimplePopover,
|
9
|
-
createTexts,
|
10
|
-
useTranslation,
|
11
|
-
} from "..";
|
5
|
+
import { Box, IconButton, Text, createTexts, useTranslation } from "..";
|
12
6
|
import { StepperProvider } from "./StepperContext";
|
13
7
|
|
14
8
|
type StepperProps = {
|
9
|
+
/** Callback for when a step is clicked */
|
15
10
|
onClick: (clickedStep: number) => void;
|
11
|
+
/** Callback for when the back button is clicked (on smaller screens).
|
12
|
+
* A boolean indicating whether or not the user is on the first step is passed as an argument.
|
13
|
+
*
|
14
|
+
* If this is not provided, the back button will not be shown on smaller screens on the first step.
|
15
|
+
*/
|
16
|
+
onBackButtonClick?: (isFirstStep: boolean) => void;
|
17
|
+
/**
|
18
|
+
* Heading shown on smaller devices
|
19
|
+
* @deprecated Use `heading` instead
|
20
|
+
*/
|
16
21
|
title?: string;
|
22
|
+
/** Heading shown on smaller devices */
|
23
|
+
heading?: string;
|
24
|
+
/**
|
25
|
+
* The heading level rendered for the heading shown on smaller devices.
|
26
|
+
*
|
27
|
+
* Defaults to h2
|
28
|
+
* */
|
29
|
+
headingLevel?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p";
|
30
|
+
/** The currently active step */
|
17
31
|
activeStep: number;
|
32
|
+
/** The labels of each step */
|
18
33
|
steps: string[];
|
34
|
+
/** The variant.
|
35
|
+
* "base" has a transparent background,
|
36
|
+
* while "accent" has a slight accent color */
|
19
37
|
variant: "base" | "accent";
|
38
|
+
/** Disables all clicks */
|
39
|
+
isDisabled?: boolean;
|
20
40
|
};
|
21
41
|
/**
|
22
42
|
* A stepper is used to show which step of a process a user is currently in.
|
@@ -25,74 +45,78 @@ type StepperProps = {
|
|
25
45
|
*
|
26
46
|
* ```tsx
|
27
47
|
* <Stepper
|
28
|
-
* title="
|
48
|
+
* title="Example"
|
29
49
|
* onClick={handleStepClick}
|
30
50
|
* activeStep={2}
|
31
|
-
* steps={['
|
51
|
+
* steps={['Where', 'When', 'How']}
|
32
52
|
* />
|
33
53
|
* ```
|
34
54
|
**/
|
35
55
|
export const Stepper = ({
|
36
56
|
onClick = () => {},
|
57
|
+
onBackButtonClick,
|
37
58
|
steps,
|
38
59
|
activeStep: activeStepAsStringOrNumber,
|
39
60
|
title,
|
61
|
+
heading,
|
62
|
+
headingLevel,
|
40
63
|
variant,
|
64
|
+
isDisabled,
|
41
65
|
}: StepperProps) => {
|
42
66
|
const style = useMultiStyleConfig("Stepper", { variant });
|
43
67
|
const numberOfSteps = steps.length;
|
44
68
|
const activeStep = Number(activeStepAsStringOrNumber);
|
45
69
|
const { t } = useTranslation();
|
70
|
+
const hideBackButtonOnFirstStep = activeStep === 1 && !onBackButtonClick;
|
71
|
+
const shownHeading = heading || title;
|
46
72
|
return (
|
47
|
-
<Box
|
73
|
+
<Box sx={style.root}>
|
48
74
|
<StepperProvider
|
49
75
|
onClick={onClick}
|
50
76
|
activeStep={activeStep}
|
51
77
|
variant={variant}
|
52
78
|
numberOfSteps={numberOfSteps}
|
53
79
|
>
|
54
|
-
<Box
|
55
|
-
<Box
|
56
|
-
<
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
80
|
+
<Box sx={style.container}>
|
81
|
+
<Box sx={style.innerContainer}>
|
82
|
+
<Flex
|
83
|
+
justifyContent="space-between"
|
84
|
+
alignItems="center"
|
85
|
+
gap={2}
|
86
|
+
flex={1}
|
87
|
+
>
|
88
|
+
<IconButton
|
89
|
+
aria-label={t(texts.back)}
|
90
|
+
icon={<ArrowLeftFill24Icon />}
|
91
|
+
variant="ghost"
|
92
|
+
size="sm"
|
93
|
+
visibility={hideBackButtonOnFirstStep ? "hidden" : "visible"}
|
94
|
+
onClick={() => {
|
95
|
+
if (onBackButtonClick) {
|
96
|
+
onBackButtonClick(activeStep === 1);
|
97
|
+
}
|
98
|
+
onClick(activeStep - 1);
|
99
|
+
}}
|
100
|
+
/>
|
101
|
+
{shownHeading && (
|
102
|
+
<Text flex={1} variant="sm" as={headingLevel} sx={style.title}>
|
103
|
+
{shownHeading}
|
104
|
+
</Text>
|
66
105
|
)}
|
67
|
-
|
68
|
-
|
69
|
-
triggerElement={
|
70
|
-
<Box as="button" __css={style.stepCounter}>
|
71
|
-
{t(texts.stepsOf(activeStep, numberOfSteps))}
|
72
|
-
</Box>
|
73
|
-
}
|
74
|
-
borderRadius="xs"
|
75
|
-
>
|
76
|
-
{steps.map((step, index) => (
|
77
|
-
<StepperStep
|
78
|
-
key={step}
|
79
|
-
stepNumber={index + 1}
|
80
|
-
variant={variant}
|
81
|
-
>
|
82
|
-
{step}
|
83
|
-
</StepperStep>
|
84
|
-
))}
|
85
|
-
</SimplePopover>
|
86
|
-
</HStack>
|
87
|
-
{title && (
|
88
|
-
<Box as="h3" __css={style.title}>
|
89
|
-
{title}
|
106
|
+
<Box sx={style.stepCounter}>
|
107
|
+
{t(texts.stepsOf(activeStep, numberOfSteps))}
|
90
108
|
</Box>
|
91
|
-
|
109
|
+
</Flex>
|
92
110
|
</Box>
|
93
111
|
<Flex justifyContent="center" display={["none", null, "flex"]}>
|
94
112
|
{steps.map((step, index) => (
|
95
|
-
<StepperStep
|
113
|
+
<StepperStep
|
114
|
+
key={index}
|
115
|
+
stepNumber={index + 1}
|
116
|
+
variant={variant}
|
117
|
+
aria-current={index + 1 === activeStep ? "step" : undefined}
|
118
|
+
isDisabled={isDisabled}
|
119
|
+
>
|
96
120
|
{step}
|
97
121
|
</StepperStep>
|
98
122
|
))}
|
@@ -105,10 +129,10 @@ export const Stepper = ({
|
|
105
129
|
|
106
130
|
const texts = createTexts({
|
107
131
|
stepsOf: (activeStep, numberOfSteps) => ({
|
108
|
-
nb: `Steg ${activeStep}
|
109
|
-
nn: `Steg ${activeStep}
|
110
|
-
sv: `Steg ${activeStep}
|
111
|
-
en: `Step ${activeStep}
|
132
|
+
nb: `Steg ${activeStep}/${numberOfSteps}`,
|
133
|
+
nn: `Steg ${activeStep}/${numberOfSteps}`,
|
134
|
+
sv: `Steg ${activeStep}/${numberOfSteps}`,
|
135
|
+
en: `Step ${activeStep}/${numberOfSteps}`,
|
112
136
|
}),
|
113
137
|
back: {
|
114
138
|
nb: "Tilbake",
|
@@ -1,82 +1,73 @@
|
|
1
|
-
import { useMultiStyleConfig } from "@chakra-ui/react";
|
1
|
+
import { useColorModeValue, useMultiStyleConfig } from "@chakra-ui/react";
|
2
2
|
import { DropdownRightFill18Icon } from "@vygruppen/spor-icon-react";
|
3
3
|
import React from "react";
|
4
|
-
import { Box, Button } from "..";
|
4
|
+
import { Box, Button, Text } from "..";
|
5
5
|
import { useStepper } from "./StepperContext";
|
6
6
|
|
7
7
|
type StepperStepProps = {
|
8
8
|
children: React.ReactNode;
|
9
9
|
stepNumber: number;
|
10
10
|
variant: "base" | "accent";
|
11
|
+
isDisabled?: boolean;
|
11
12
|
};
|
12
13
|
export const StepperStep = ({
|
13
14
|
children,
|
14
15
|
stepNumber,
|
15
16
|
variant,
|
17
|
+
isDisabled: isDisabledOverride,
|
16
18
|
}: StepperStepProps) => {
|
17
19
|
const { activeStep, onClick } = useStepper();
|
18
|
-
const state = getState(stepNumber
|
20
|
+
const state = getState(stepNumber, activeStep);
|
19
21
|
const style = useMultiStyleConfig("Stepper", {
|
20
22
|
state,
|
21
23
|
variant,
|
22
24
|
});
|
25
|
+
const disabledTextColor = useColorModeValue(
|
26
|
+
"blackAlpha.400",
|
27
|
+
"whiteAlpha.400",
|
28
|
+
);
|
29
|
+
const iconColor = useColorModeValue("blackAlpha.200", "whiteAlpha.200");
|
23
30
|
|
24
|
-
const
|
31
|
+
const isDisabled =
|
32
|
+
(state !== "active" && isDisabledOverride) || state === "disabled";
|
25
33
|
|
26
34
|
return (
|
27
|
-
<Box
|
35
|
+
<Box sx={style.stepContainer}>
|
28
36
|
{stepNumber > 1 && (
|
29
|
-
<DropdownRightFill18Icon
|
37
|
+
<DropdownRightFill18Icon
|
38
|
+
marginX={5}
|
39
|
+
display={["none", null, "block"]}
|
40
|
+
color={iconColor}
|
41
|
+
/>
|
42
|
+
)}
|
43
|
+
{isDisabled ? (
|
44
|
+
<Text
|
45
|
+
variant="xs"
|
46
|
+
fontSize="16px"
|
47
|
+
color={disabledTextColor}
|
48
|
+
cursor="default"
|
49
|
+
paddingX={2}
|
50
|
+
>
|
51
|
+
{children}
|
52
|
+
</Text>
|
53
|
+
) : (
|
54
|
+
<Button
|
55
|
+
size="xs"
|
56
|
+
variant={state === "active" ? "primary" : "ghost"}
|
57
|
+
onClick={
|
58
|
+
state === "completed" ? () => onClick(stepNumber) : undefined
|
59
|
+
}
|
60
|
+
pointerEvents={state === "active" ? "none" : "auto"}
|
61
|
+
tabIndex={state === "active" ? -1 : undefined}
|
62
|
+
sx={style.stepButton}
|
63
|
+
>
|
64
|
+
{children}
|
65
|
+
</Button>
|
30
66
|
)}
|
31
|
-
|
32
|
-
<Button
|
33
|
-
size="xs"
|
34
|
-
variant={
|
35
|
-
state === "active"
|
36
|
-
? "primary"
|
37
|
-
: state === "completed"
|
38
|
-
? "tertiary"
|
39
|
-
: "ghost"
|
40
|
-
}
|
41
|
-
{...adjustedProps}
|
42
|
-
onClick={() => onClick(stepNumber)}
|
43
|
-
>
|
44
|
-
{children}
|
45
|
-
</Button>
|
46
67
|
</Box>
|
47
68
|
);
|
48
69
|
};
|
49
70
|
|
50
|
-
const getButtonStylesForState = (
|
51
|
-
state: "completed" | "active" | "disabled",
|
52
|
-
): Record<string, any> => {
|
53
|
-
switch (state) {
|
54
|
-
case "active":
|
55
|
-
return {
|
56
|
-
_hover: {},
|
57
|
-
boxShadow: "none",
|
58
|
-
_focus: {},
|
59
|
-
_active: {},
|
60
|
-
cursor: "auto",
|
61
|
-
};
|
62
|
-
case "completed":
|
63
|
-
return {
|
64
|
-
boxShadow: "none",
|
65
|
-
};
|
66
|
-
case "disabled":
|
67
|
-
return {
|
68
|
-
_disabled: {},
|
69
|
-
_hover: {},
|
70
|
-
_focus: {},
|
71
|
-
_active: {},
|
72
|
-
color: "dimGrey",
|
73
|
-
cursor: "auto",
|
74
|
-
};
|
75
|
-
default:
|
76
|
-
return {};
|
77
|
-
}
|
78
|
-
};
|
79
|
-
|
80
71
|
const getState = (stepNumber: number, activeStep: number) => {
|
81
72
|
if (stepNumber < activeStep) {
|
82
73
|
return "completed";
|
@@ -5,7 +5,6 @@ const parts = anatomy("stepper").parts(
|
|
5
5
|
"root",
|
6
6
|
"container",
|
7
7
|
"innerContainer",
|
8
|
-
"backButton",
|
9
8
|
"title",
|
10
9
|
"stepCounter",
|
11
10
|
"stepContainer",
|
@@ -38,12 +37,7 @@ const config = helpers.defineMultiStyleConfig({
|
|
38
37
|
display: ["flex", null, "none"],
|
39
38
|
alignItems: "center",
|
40
39
|
justifyContent: "space-between",
|
41
|
-
|
42
|
-
backButton: {
|
43
|
-
borderRadius: "xs",
|
44
|
-
paddingX: 0,
|
45
|
-
width: "auto",
|
46
|
-
minWidth: "auto",
|
40
|
+
gap: 3,
|
47
41
|
},
|
48
42
|
title: {
|
49
43
|
overflow: "hidden",
|
@@ -51,8 +45,8 @@ const config = helpers.defineMultiStyleConfig({
|
|
51
45
|
WebkitLineClamp: 2,
|
52
46
|
display: "-webkit-box",
|
53
47
|
WebkitBoxOrient: "vertical",
|
54
|
-
|
55
|
-
|
48
|
+
textAlign: "center",
|
49
|
+
maxWidth: "80%",
|
56
50
|
},
|
57
51
|
stepContainer: {
|
58
52
|
display: "flex",
|
@@ -72,6 +66,26 @@ const config = helpers.defineMultiStyleConfig({
|
|
72
66
|
accent: (props) => ({
|
73
67
|
root: {
|
74
68
|
backgroundColor: mode("seaMist", "pine")(props),
|
69
|
+
color: mode("darkTeal", "seaMist")(props),
|
70
|
+
},
|
71
|
+
stepButton: {
|
72
|
+
color:
|
73
|
+
props.state === "disabled"
|
74
|
+
? mode("blackAlpha.400", "whiteAlpha.400")(props)
|
75
|
+
: props.state === "completed"
|
76
|
+
? mode("darkTeal", "white")(props)
|
77
|
+
: mode("white", "darkTeal")(props),
|
78
|
+
_hover: {
|
79
|
+
backgroundColor:
|
80
|
+
props.state === "disabled"
|
81
|
+
? "transparent"
|
82
|
+
: mode("coralGreen", "greenHaze")(props),
|
83
|
+
},
|
84
|
+
},
|
85
|
+
backButton: {
|
86
|
+
_hover: {
|
87
|
+
backgroundColor: mode("coralGreen", "greenHaze")(props),
|
88
|
+
},
|
75
89
|
},
|
76
90
|
}),
|
77
91
|
},
|