@vygruppen/spor-react 11.3.10 → 12.0.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 +32 -11
- package/.turbo/turbo-typegen.log +23 -0
- package/CHANGELOG.md +239 -0
- package/dist/index.d.mts +2552 -8319
- package/dist/index.d.ts +2552 -8319
- package/dist/index.js +9609 -8608
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9487 -8455
- package/dist/index.mjs.map +1 -1
- package/package.json +21 -13
- package/src/accordion/Accordion.tsx +96 -45
- package/src/accordion/Expandable.tsx +54 -127
- package/src/accordion/helpers.ts +31 -0
- package/src/accordion/types.ts +60 -0
- package/src/alert/Alert.tsx +101 -0
- package/src/alert/AlertIcon.tsx +63 -45
- package/src/alert/ExpandableAlert.tsx +96 -64
- package/src/alert/ServiceAlert.tsx +127 -125
- package/src/alert/{index.tsx → index.ts} +1 -2
- package/src/breadcrumb/Breadcrumb.tsx +39 -24
- package/src/button/Button.tsx +86 -105
- package/src/button/ButtonGroup.tsx +45 -20
- package/src/button/Clipboard.tsx +82 -0
- package/src/button/CloseButton.tsx +4 -3
- package/src/button/FloatingActionButton.tsx +35 -41
- package/src/button/IconButton.tsx +34 -30
- package/src/button/index.tsx +1 -0
- package/src/color-mode/color-mode.tsx +75 -0
- package/src/color-mode/index.ts +1 -0
- package/src/datepicker/Calendar.tsx +17 -8
- package/src/datepicker/CalendarCell.tsx +20 -13
- package/src/datepicker/CalendarGrid.tsx +18 -10
- package/src/datepicker/CalendarHeader.tsx +2 -0
- package/src/datepicker/CalendarNavigationButton.tsx +1 -0
- package/src/datepicker/CalendarTriggerButton.tsx +43 -45
- package/src/datepicker/DateField.tsx +21 -12
- package/src/datepicker/DatePicker.tsx +61 -58
- package/src/datepicker/DateRangePicker.tsx +52 -58
- package/src/datepicker/DateTimeSegment.tsx +13 -5
- package/src/datepicker/RangeCalendar.tsx +13 -7
- package/src/datepicker/StyledField.tsx +25 -17
- package/src/datepicker/TimeField.tsx +10 -8
- package/src/datepicker/TimePicker.tsx +48 -45
- package/src/datepicker/types.ts +5 -0
- package/src/dialog/Dialog.tsx +56 -0
- package/src/dialog/Drawer.tsx +187 -0
- package/src/dialog/index.ts +2 -0
- package/src/dialog/types.ts +26 -0
- package/src/image/index.tsx +2 -2
- package/src/index.tsx +5 -3
- package/src/input/AttachedInputs.tsx +17 -42
- package/src/input/CardSelect.tsx +75 -162
- package/src/input/Checkbox.tsx +30 -6
- package/src/input/CheckboxGroup.tsx +25 -16
- package/src/input/ChoiceChip.tsx +58 -77
- package/src/input/Combobox.tsx +172 -172
- package/src/input/CountryCodeSelect.tsx +42 -28
- package/src/input/Dialog.tsx +1 -0
- package/src/input/Field.tsx +71 -0
- package/src/input/Fieldset.tsx +7 -0
- package/src/input/Input.tsx +68 -73
- package/src/input/InputGroup.tsx +66 -0
- package/src/input/ListBox.tsx +83 -70
- package/src/input/NativeSelect.tsx +68 -33
- package/src/input/NumericStepper.tsx +173 -171
- package/src/input/PasswordInput.tsx +99 -52
- package/src/input/PhoneNumberInput.tsx +69 -72
- package/src/input/Popover.tsx +1 -0
- package/src/input/Radio.tsx +37 -17
- package/src/input/SearchInput.tsx +24 -86
- package/src/input/Select.tsx +237 -0
- package/src/input/Switch.tsx +60 -18
- package/src/input/Textarea.tsx +53 -101
- package/src/input/{index.tsx → index.ts} +2 -8
- package/src/layout/PressableCard.tsx +12 -21
- package/src/layout/RadioCard.tsx +68 -101
- package/src/layout/Separator.tsx +32 -0
- package/src/layout/StaticCard.tsx +13 -33
- package/src/layout/index.tsx +3 -7
- package/src/linjetag/InfoTag.tsx +16 -9
- package/src/linjetag/LineIcon.tsx +74 -28
- package/src/linjetag/TravelTag.tsx +38 -27
- package/src/link/TextLink.tsx +25 -16
- package/src/list/index.tsx +24 -2
- package/src/loader/ClientOnly.tsx +8 -7
- package/src/loader/ColorInlineLoader.tsx +4 -3
- package/src/loader/ColorSpinner.tsx +5 -4
- package/src/loader/ContentLoader.tsx +6 -4
- package/src/loader/DarkFullScreenLoader.tsx +11 -3
- package/src/loader/DarkInlineLoader.tsx +5 -3
- package/src/loader/DarkSpinner.tsx +7 -3
- package/src/loader/LightFullScreenLoader.tsx +11 -3
- package/src/loader/LightInlineLoader.tsx +11 -3
- package/src/loader/LightSpinner.tsx +5 -3
- package/src/loader/Lottie.tsx +3 -3
- package/src/loader/ProgressBar.tsx +83 -84
- package/src/loader/ProgressLoader.tsx +120 -75
- package/src/loader/Skeleton.tsx +94 -19
- package/src/loader/index.tsx +0 -2
- package/src/loader/useHydrated.tsx +1 -0
- package/src/loader/useRotatingLabel.tsx +2 -1
- package/src/logo/CargonetLogo.tsx +89 -89
- package/src/logo/VyLogo.tsx +61 -42
- package/src/logo/VyLogoPride.tsx +137 -139
- package/src/media-controller/JumpButton.tsx +48 -38
- package/src/media-controller/PlayPauseButton.tsx +31 -29
- package/src/media-controller/SkipButton.tsx +38 -37
- package/src/nudge/Nudge.tsx +195 -123
- package/src/nudge/index.tsx +0 -1
- package/src/pagination/Pagination.tsx +221 -118
- package/src/pagination/types.ts +23 -0
- package/src/popover/index.tsx +67 -0
- package/src/progress-indicator/ProgressDot.tsx +11 -10
- package/src/progress-indicator/ProgressIndicator.tsx +28 -15
- package/src/provider/SporProvider.tsx +17 -14
- package/src/stepper/Stepper.tsx +88 -85
- package/src/stepper/StepperContext.tsx +2 -1
- package/src/stepper/StepperStep.tsx +28 -21
- package/src/tab/Tabs.tsx +62 -12
- package/src/tab/index.tsx +1 -9
- package/src/table/Table.tsx +35 -30
- package/src/table/index.tsx +11 -7
- package/src/theme/brand.ts +7 -0
- package/src/theme/index.ts +45 -37
- package/src/theme/recipes/attached-inputs.ts +43 -0
- package/src/theme/recipes/badge.ts +104 -0
- package/src/theme/recipes/button.ts +124 -0
- package/src/theme/recipes/choice-chip.ts +144 -0
- package/src/theme/recipes/close-button.ts +41 -0
- package/src/theme/recipes/code.ts +14 -0
- package/src/theme/recipes/group.ts +19 -0
- package/src/theme/recipes/index.ts +29 -0
- package/src/theme/recipes/input.ts +89 -0
- package/src/theme/recipes/link.ts +64 -0
- package/src/theme/recipes/nudge.ts +12 -0
- package/src/theme/recipes/pressable-card.ts +83 -0
- package/src/theme/recipes/progress-loader.ts +14 -0
- package/src/theme/recipes/separator.ts +85 -0
- package/src/theme/recipes/skeleton.ts +57 -0
- package/src/theme/recipes/static-card.ts +39 -0
- package/src/theme/recipes/textarea.ts +27 -0
- package/src/theme/semantic-tokens/colors.ts +22 -0
- package/src/theme/semantic-tokens/index.ts +24 -0
- package/src/theme/semantic-tokens/radii.ts +14 -0
- package/src/theme/semantic-tokens/shadows.ts +17 -0
- package/src/theme/slot-recipes/accordion.ts +131 -0
- package/src/theme/slot-recipes/alert-expandable.ts +133 -0
- package/src/theme/slot-recipes/alert-service.ts +66 -0
- package/src/theme/slot-recipes/alert.ts +72 -0
- package/src/theme/slot-recipes/anatomy.ts +269 -0
- package/src/theme/slot-recipes/breadcrumb.ts +61 -0
- package/src/theme/slot-recipes/checkbox.ts +89 -0
- package/src/theme/slot-recipes/datepicker.ts +214 -0
- package/src/theme/slot-recipes/dialog.ts +221 -0
- package/src/theme/slot-recipes/drawer.ts +205 -0
- package/src/theme/slot-recipes/field.ts +79 -0
- package/src/theme/slot-recipes/floating-action-button.ts +131 -0
- package/src/theme/slot-recipes/index.ts +65 -0
- package/src/theme/slot-recipes/info-tag.ts +62 -0
- package/src/theme/slot-recipes/line-icon.ts +140 -0
- package/src/theme/slot-recipes/list.ts +45 -0
- package/src/theme/slot-recipes/listbox.ts +72 -0
- package/src/theme/slot-recipes/media-controller-button.ts +131 -0
- package/src/theme/slot-recipes/native-select.ts +54 -0
- package/src/theme/slot-recipes/numeric-stepper.ts +65 -0
- package/src/theme/slot-recipes/pagination.ts +41 -0
- package/src/theme/slot-recipes/popover.ts +78 -0
- package/src/theme/slot-recipes/progress-bar.ts +39 -0
- package/src/theme/slot-recipes/progress-indicator.ts +22 -0
- package/src/theme/slot-recipes/radio-card.ts +112 -0
- package/src/theme/slot-recipes/radio.ts +80 -0
- package/src/theme/slot-recipes/select.ts +243 -0
- package/src/theme/slot-recipes/stepper.ts +92 -0
- package/src/theme/slot-recipes/switch.ts +147 -0
- package/src/theme/slot-recipes/table.ts +200 -0
- package/src/theme/slot-recipes/tabs.ts +169 -0
- package/src/theme/slot-recipes/toast.ts +56 -0
- package/src/theme/slot-recipes/travel-tag.ts +192 -0
- package/src/theme/tokens/animation-styles.ts +50 -0
- package/src/theme/tokens/animations.ts +22 -0
- package/src/theme/tokens/aspect-ratios.ts +22 -0
- package/src/theme/tokens/blurs.ts +28 -0
- package/src/theme/tokens/borders.ts +26 -0
- package/src/theme/{foundations → tokens}/breakpoints.ts +0 -1
- package/src/theme/tokens/colors.ts +10 -0
- package/src/theme/tokens/config.ts +10 -0
- package/src/theme/tokens/cursor.ts +28 -0
- package/src/theme/tokens/durations.ts +25 -0
- package/src/theme/tokens/easings.ts +16 -0
- package/src/theme/tokens/font-sizes.ts +30 -0
- package/src/theme/tokens/font-weights.ts +31 -0
- package/src/theme/tokens/fonts.ts +8 -0
- package/src/theme/tokens/global-css.ts +18 -0
- package/src/theme/tokens/index.ts +37 -0
- package/src/theme/tokens/keyframes.ts +255 -0
- package/src/theme/tokens/letter-spacings.ts +19 -0
- package/src/theme/tokens/line-heights.ts +19 -0
- package/src/theme/tokens/radii.ts +13 -0
- package/src/theme/tokens/sizes.ts +51 -0
- package/src/theme/tokens/spacing.ts +20 -0
- package/src/theme/tokens/text-styles.ts +89 -0
- package/src/theme/tokens/z-index.ts +17 -0
- package/src/theme/utils/accent-utils.ts +8 -21
- package/src/theme/utils/bg-utils.ts +4 -6
- package/src/theme/utils/brand-utils.ts +6 -19
- package/src/theme/utils/core-utils.ts +91 -0
- package/src/theme/utils/floating-utils.ts +20 -39
- package/src/theme/utils/ghost-utils.ts +7 -21
- package/src/theme/utils/input-utils.ts +32 -37
- package/src/theme/utils/outline-utils.ts +4 -11
- package/src/theme/utils/surface-utils.ts +5 -19
- package/src/theme/utils/types.ts +1 -0
- package/src/toast/index.tsx +1 -1
- package/src/toast/toast.tsx +105 -0
- package/src/transition/index.ts +2 -8
- package/src/typography/Badge.tsx +15 -61
- package/src/typography/Code.tsx +16 -28
- package/src/typography/Heading.tsx +34 -19
- package/src/typography/Text.tsx +9 -6
- package/src/typography/{index.tsx → index.ts} +1 -0
- package/src/util/externals.tsx +13 -27
- package/tsconfig.json +5 -1
- package/src/accordion/Accordion.test.tsx +0 -20
- package/src/alert/BaseAlert.test.tsx +0 -37
- package/src/alert/BaseAlert.tsx +0 -34
- package/src/alert/ClosableAlert.test.tsx +0 -37
- package/src/alert/ClosableAlert.tsx +0 -85
- package/src/alert/ExpandableAlert.test.tsx +0 -84
- package/src/alert/StaticAlert.tsx +0 -33
- package/src/button/Button.test.tsx +0 -23
- package/src/datepicker/TimePicker.test.tsx +0 -74
- package/src/input/FormControl.tsx +0 -2
- package/src/input/FormErrorMessage.tsx +0 -95
- package/src/input/FormLabel.tsx +0 -11
- package/src/input/InfoSelect.tsx +0 -274
- package/src/input/InputElement.tsx +0 -44
- package/src/input/RadioGroup.tsx +0 -47
- package/src/layout/Divider.tsx +0 -27
- package/src/layout/RadioCardGroup.tsx +0 -79
- package/src/layout/Stack.tsx +0 -42
- package/src/loader/SkeletonCircle.tsx +0 -13
- package/src/loader/SkeletonText.tsx +0 -14
- package/src/media-controller/index.test.tsx +0 -59
- package/src/modal/Drawer.tsx +0 -120
- package/src/modal/FullScreenDrawer.tsx +0 -239
- package/src/modal/Modal.tsx +0 -15
- package/src/modal/ModalHeader.tsx +0 -31
- package/src/modal/SimpleDrawer.tsx +0 -51
- package/src/modal/index.tsx +0 -5
- package/src/nudge/WizardNudge.tsx +0 -107
- package/src/theme/components/accordion.ts +0 -102
- package/src/theme/components/alert-expandable.ts +0 -125
- package/src/theme/components/alert-service.ts +0 -98
- package/src/theme/components/alert.ts +0 -71
- package/src/theme/components/badge.ts +0 -109
- package/src/theme/components/breadcrumb.ts +0 -60
- package/src/theme/components/button.ts +0 -125
- package/src/theme/components/card-select.ts +0 -117
- package/src/theme/components/checkbox.ts +0 -88
- package/src/theme/components/choice-chip.ts +0 -161
- package/src/theme/components/close-button.ts +0 -48
- package/src/theme/components/code.ts +0 -17
- package/src/theme/components/datepicker.ts +0 -198
- package/src/theme/components/divider.ts +0 -50
- package/src/theme/components/drawer.ts +0 -95
- package/src/theme/components/fab.ts +0 -109
- package/src/theme/components/form-label.ts +0 -17
- package/src/theme/components/form.ts +0 -27
- package/src/theme/components/index.ts +0 -45
- package/src/theme/components/info-select.ts +0 -85
- package/src/theme/components/info-tag.ts +0 -63
- package/src/theme/components/input.ts +0 -28
- package/src/theme/components/line-icon.ts +0 -129
- package/src/theme/components/link.ts +0 -78
- package/src/theme/components/list.ts +0 -23
- package/src/theme/components/listbox.ts +0 -77
- package/src/theme/components/media-controller-button.ts +0 -97
- package/src/theme/components/modal.ts +0 -96
- package/src/theme/components/numeric-stepper.ts +0 -65
- package/src/theme/components/pagination.ts +0 -74
- package/src/theme/components/popover.ts +0 -68
- package/src/theme/components/pressable-card.ts +0 -72
- package/src/theme/components/progress-bar.ts +0 -47
- package/src/theme/components/progress-indicator.ts +0 -44
- package/src/theme/components/radio-card.ts +0 -134
- package/src/theme/components/radio.ts +0 -68
- package/src/theme/components/select.ts +0 -74
- package/src/theme/components/skeleton.ts +0 -40
- package/src/theme/components/static-card.ts +0 -82
- package/src/theme/components/stepper.ts +0 -100
- package/src/theme/components/switch.ts +0 -112
- package/src/theme/components/table.ts +0 -161
- package/src/theme/components/tabs.ts +0 -135
- package/src/theme/components/textarea.ts +0 -33
- package/src/theme/components/toast.ts +0 -28
- package/src/theme/components/travel-tag.ts +0 -256
- package/src/theme/foundations/borders.ts +0 -11
- package/src/theme/foundations/colors.ts +0 -12
- package/src/theme/foundations/config.ts +0 -5
- package/src/theme/foundations/fontSizes.ts +0 -29
- package/src/theme/foundations/fontWeights.ts +0 -5
- package/src/theme/foundations/fonts.ts +0 -7
- package/src/theme/foundations/index.ts +0 -15
- package/src/theme/foundations/lineHeights.ts +0 -6
- package/src/theme/foundations/radii.ts +0 -12
- package/src/theme/foundations/shadows.ts +0 -8
- package/src/theme/foundations/sizes.ts +0 -36
- package/src/theme/foundations/spacing.ts +0 -31
- package/src/theme/foundations/styles.ts +0 -12
- package/src/theme/foundations/textStyles.ts +0 -74
- package/src/theme/foundations/zIndices.ts +0 -17
- package/src/theme/utils/base-utils.ts +0 -104
- package/src/theme/utils/focus-utils.ts +0 -10
- package/src/toast/ActionToast.test.tsx +0 -22
- package/src/toast/ActionToast.tsx +0 -28
- package/src/toast/BaseToast.test.tsx +0 -27
- package/src/toast/BaseToast.tsx +0 -75
- package/src/toast/ClosableToast.test.tsx +0 -17
- package/src/toast/ClosableToast.tsx +0 -40
- package/src/toast/useToast.tsx +0 -121
- package/src/tooltip/Tooltip.tsx +0 -70
- package/src/tooltip/index.tsx +0 -1
@@ -1,59 +0,0 @@
|
|
1
|
-
import { render } from "@testing-library/react";
|
2
|
-
import React from "react";
|
3
|
-
import { vi } from "vitest";
|
4
|
-
import { axe } from "vitest-axe";
|
5
|
-
import { JumpButton, PlayPauseButton, SkipButton } from ".";
|
6
|
-
|
7
|
-
describe("<PlayPauseButton />", () => {
|
8
|
-
it("works like a button", async () => {
|
9
|
-
const handleClick = vi.fn();
|
10
|
-
const { getByRole } = render(
|
11
|
-
<PlayPauseButton size="sm" isPlaying={true} onClick={handleClick} />,
|
12
|
-
);
|
13
|
-
getByRole("button").click();
|
14
|
-
expect(handleClick).toHaveBeenCalled();
|
15
|
-
});
|
16
|
-
|
17
|
-
it("is accessible", async () => {
|
18
|
-
const { container } = render(
|
19
|
-
<PlayPauseButton size="sm" isPlaying={true} onClick={() => {}} />,
|
20
|
-
);
|
21
|
-
expect(await axe(container)).toHaveNoViolations();
|
22
|
-
});
|
23
|
-
});
|
24
|
-
|
25
|
-
describe("<SkipButtonButton />", () => {
|
26
|
-
it("works like a button", async () => {
|
27
|
-
const handleClick = vi.fn();
|
28
|
-
const { getByRole } = render(
|
29
|
-
<SkipButton size="sm" direction="forward" onClick={handleClick} />,
|
30
|
-
);
|
31
|
-
getByRole("button").click();
|
32
|
-
expect(handleClick).toHaveBeenCalled();
|
33
|
-
});
|
34
|
-
|
35
|
-
it("is accessible", async () => {
|
36
|
-
const { container } = render(
|
37
|
-
<SkipButton size="sm" direction="forward" onClick={() => {}} />,
|
38
|
-
);
|
39
|
-
expect(await axe(container)).toHaveNoViolations();
|
40
|
-
});
|
41
|
-
});
|
42
|
-
|
43
|
-
describe("<JumpButtonButton />", () => {
|
44
|
-
it("works like a button", async () => {
|
45
|
-
const handleClick = vi.fn();
|
46
|
-
const { getByRole } = render(
|
47
|
-
<JumpButton size="sm" direction="forward" onClick={handleClick} />,
|
48
|
-
);
|
49
|
-
getByRole("button").click();
|
50
|
-
expect(handleClick).toHaveBeenCalled();
|
51
|
-
});
|
52
|
-
|
53
|
-
it("is accessible", async () => {
|
54
|
-
const { container } = render(
|
55
|
-
<JumpButton size="sm" direction="forward" onClick={() => {}} />,
|
56
|
-
);
|
57
|
-
expect(await axe(container)).toHaveNoViolations();
|
58
|
-
});
|
59
|
-
});
|
package/src/modal/Drawer.tsx
DELETED
@@ -1,120 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
Box,
|
3
|
-
BoxProps,
|
4
|
-
Center,
|
5
|
-
Drawer as ChakraDrawer,
|
6
|
-
DrawerContent as ChakraDrawerContent,
|
7
|
-
DrawerContentProps as ChakraDrawerContentProps,
|
8
|
-
DrawerProps as ChakraDrawerProps,
|
9
|
-
forwardRef,
|
10
|
-
useModalContext,
|
11
|
-
} from "@chakra-ui/react";
|
12
|
-
import React from "react";
|
13
|
-
import { useSwipeable } from "react-swipeable";
|
14
|
-
export {
|
15
|
-
DrawerBody,
|
16
|
-
DrawerCloseButton,
|
17
|
-
DrawerFooter,
|
18
|
-
DrawerOverlay,
|
19
|
-
} from "@chakra-ui/react";
|
20
|
-
export type { DrawerProps } from "@chakra-ui/react";
|
21
|
-
export { ModalHeader as DrawerHeader } from "./ModalHeader";
|
22
|
-
|
23
|
-
type DrawerProps = ChakraDrawerProps;
|
24
|
-
export const Drawer = (props: DrawerProps) => {
|
25
|
-
return (
|
26
|
-
<DrawerProvider placement={props.placement}>
|
27
|
-
<ChakraDrawer {...props} />
|
28
|
-
</DrawerProvider>
|
29
|
-
);
|
30
|
-
};
|
31
|
-
|
32
|
-
type DrawerContentProps = ChakraDrawerContentProps;
|
33
|
-
export const DrawerContent = forwardRef<DrawerContentProps, any>(
|
34
|
-
({ children, ...props }, ref) => {
|
35
|
-
const placement = useDrawerContext();
|
36
|
-
const { onClose } = useModalContext();
|
37
|
-
const handlers = useSwipeable({
|
38
|
-
onSwiped: (e) => {
|
39
|
-
const shouldClose =
|
40
|
-
(placement === "bottom" && e.dir === "Down") ||
|
41
|
-
(placement === "right" && e.dir === "Right") ||
|
42
|
-
(placement === "left" && e.dir === "Left") ||
|
43
|
-
(placement === "top" && e.dir === "Up") ||
|
44
|
-
(placement === "end" && e.dir === "Right") ||
|
45
|
-
(placement === "start" && e.dir === "Left");
|
46
|
-
if (shouldClose) {
|
47
|
-
onClose();
|
48
|
-
}
|
49
|
-
},
|
50
|
-
swipeDuration: 500,
|
51
|
-
});
|
52
|
-
|
53
|
-
const isTopOrBottom = placement === "top" || placement === "bottom";
|
54
|
-
const widthConstraits = isTopOrBottom
|
55
|
-
? { width: ["100%", "37.5rem"], mx: "auto" }
|
56
|
-
: {};
|
57
|
-
return (
|
58
|
-
<Box {...handlers}>
|
59
|
-
<ChakraDrawerContent
|
60
|
-
{...widthConstraits}
|
61
|
-
borderTopRadius={placement === "bottom" ? "md" : "none"}
|
62
|
-
borderBottomRadius={placement === "top" ? "md" : "none"}
|
63
|
-
{...props}
|
64
|
-
ref={ref}
|
65
|
-
>
|
66
|
-
<Box position="relative">
|
67
|
-
<Box maxHeight="100vh" maxWidth="100vw" overflow="auto">
|
68
|
-
{isTopOrBottom && <Notch />}
|
69
|
-
|
70
|
-
<Box>{children}</Box>
|
71
|
-
</Box>
|
72
|
-
</Box>
|
73
|
-
</ChakraDrawerContent>
|
74
|
-
</Box>
|
75
|
-
);
|
76
|
-
},
|
77
|
-
);
|
78
|
-
|
79
|
-
const Notch = forwardRef<BoxProps, any>((props, ref) => {
|
80
|
-
const placement = useDrawerContext();
|
81
|
-
return (
|
82
|
-
<Box
|
83
|
-
position="absolute"
|
84
|
-
left={0}
|
85
|
-
right={0}
|
86
|
-
top={placement === "bottom" ? 0 : undefined}
|
87
|
-
bottom={placement === "top" ? 0 : undefined}
|
88
|
-
zIndex="modal"
|
89
|
-
{...props}
|
90
|
-
ref={ref}
|
91
|
-
>
|
92
|
-
<Center
|
93
|
-
background={placement === "bottom" ? "bottom" : "top"}
|
94
|
-
padding={2}
|
95
|
-
borderRadius="md"
|
96
|
-
>
|
97
|
-
<Box
|
98
|
-
width="2.265rem"
|
99
|
-
height={1}
|
100
|
-
backgroundColor="steel"
|
101
|
-
borderRadius="xs"
|
102
|
-
/>
|
103
|
-
</Center>
|
104
|
-
</Box>
|
105
|
-
);
|
106
|
-
});
|
107
|
-
|
108
|
-
const DrawerContext = React.createContext<DrawerProps["placement"]>(undefined);
|
109
|
-
type DrawerProviderProps = {
|
110
|
-
children: React.ReactNode;
|
111
|
-
placement: DrawerProps["placement"];
|
112
|
-
};
|
113
|
-
const DrawerProvider = (props: DrawerProviderProps) => (
|
114
|
-
<DrawerContext.Provider value={props.placement}>
|
115
|
-
{props.children}
|
116
|
-
</DrawerContext.Provider>
|
117
|
-
);
|
118
|
-
const useDrawerContext = () => {
|
119
|
-
return React.useContext(DrawerContext);
|
120
|
-
};
|
@@ -1,239 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
Box,
|
3
|
-
DrawerBody,
|
4
|
-
DrawerContent,
|
5
|
-
DrawerHeader,
|
6
|
-
DrawerOverlay,
|
7
|
-
Flex,
|
8
|
-
useColorModeValue,
|
9
|
-
useMediaQuery,
|
10
|
-
useModalContext,
|
11
|
-
} from "@chakra-ui/react";
|
12
|
-
import tokens from "@vygruppen/spor-design-tokens";
|
13
|
-
import {
|
14
|
-
ArrowLeftFill24Icon,
|
15
|
-
ArrowLeftFill30Icon,
|
16
|
-
CloseFill24Icon,
|
17
|
-
CloseFill30Icon,
|
18
|
-
} from "@vygruppen/spor-icon-react";
|
19
|
-
import React, { useEffect, useState } from "react";
|
20
|
-
import { Button, IconButton } from "../button";
|
21
|
-
import { createTexts, useTranslation } from "../i18n";
|
22
|
-
import { Drawer } from "./Drawer";
|
23
|
-
import { DrawerBodyProps } from "./SimpleDrawer";
|
24
|
-
|
25
|
-
type DrawerPlacement = "top" | "right" | "bottom" | "left";
|
26
|
-
|
27
|
-
type FullScreenDrawerProps = {
|
28
|
-
/** The content inside the drawer */
|
29
|
-
children: React.ReactNode;
|
30
|
-
/** The title in the middle of the top menu */
|
31
|
-
title?: String;
|
32
|
-
/** Determines which side the drawer slides from */
|
33
|
-
placement?: DrawerPlacement;
|
34
|
-
/** A React component that will be placed to the left in the modal header */
|
35
|
-
leftButton?: React.ReactNode;
|
36
|
-
/** A React component that will be placed to the right in the modal header */
|
37
|
-
rightButton?: React.ReactNode;
|
38
|
-
/** Determines if the drawer is open or closed */
|
39
|
-
isOpen: boolean;
|
40
|
-
/** Function that will be called when the drawer closes */
|
41
|
-
onClose: () => void;
|
42
|
-
/** Props for drawer body */
|
43
|
-
body?: DrawerBodyProps;
|
44
|
-
};
|
45
|
-
|
46
|
-
export const FullScreenDrawer = ({
|
47
|
-
children,
|
48
|
-
title,
|
49
|
-
placement = "bottom",
|
50
|
-
leftButton = <DrawerBackButton />,
|
51
|
-
rightButton = <DrawerCloseButton />,
|
52
|
-
isOpen,
|
53
|
-
onClose,
|
54
|
-
body,
|
55
|
-
}: FullScreenDrawerProps) => {
|
56
|
-
const [isContentBoxScrolled, setContentBoxScrolled] = useState(false);
|
57
|
-
|
58
|
-
const onContentScroll = (e: React.UIEvent<HTMLDivElement, UIEvent>) => {
|
59
|
-
const target = e.target as HTMLDivElement;
|
60
|
-
|
61
|
-
if (target.scrollTop <= 0) {
|
62
|
-
setContentBoxScrolled(false);
|
63
|
-
return;
|
64
|
-
}
|
65
|
-
setContentBoxScrolled(true);
|
66
|
-
};
|
67
|
-
|
68
|
-
useEffect(() => {
|
69
|
-
setContentBoxScrolled(false);
|
70
|
-
}, [isOpen]);
|
71
|
-
|
72
|
-
return (
|
73
|
-
<Drawer isOpen={isOpen} onClose={onClose} placement={placement} size="full">
|
74
|
-
<DrawerOverlay />
|
75
|
-
<DrawerContent
|
76
|
-
height="100vh"
|
77
|
-
backgroundSize="100% 285px, 100%"
|
78
|
-
backgroundPosition="top"
|
79
|
-
backgroundRepeat="no-repeat"
|
80
|
-
>
|
81
|
-
<DrawerTopMenu
|
82
|
-
isScrolled={isContentBoxScrolled}
|
83
|
-
title={title}
|
84
|
-
leftButton={leftButton}
|
85
|
-
rightButton={rightButton}
|
86
|
-
/>
|
87
|
-
<DrawerBody overflow="auto" onScroll={onContentScroll} {...body}>
|
88
|
-
{children}
|
89
|
-
</DrawerBody>
|
90
|
-
</DrawerContent>
|
91
|
-
</Drawer>
|
92
|
-
);
|
93
|
-
};
|
94
|
-
|
95
|
-
type DrawerTopMenuProps = {
|
96
|
-
/** Optional title */
|
97
|
-
title?: String;
|
98
|
-
leftButton?: React.ReactNode;
|
99
|
-
rightButton?: React.ReactNode;
|
100
|
-
/** Whether or not the context this menu is placed in is scrolled */
|
101
|
-
isScrolled: boolean;
|
102
|
-
};
|
103
|
-
|
104
|
-
const DrawerTopMenu = ({
|
105
|
-
title,
|
106
|
-
leftButton,
|
107
|
-
rightButton,
|
108
|
-
isScrolled,
|
109
|
-
}: DrawerTopMenuProps) => {
|
110
|
-
const backgroundColor = useColorModeValue(
|
111
|
-
"bg.default.light",
|
112
|
-
"bg.default.dark",
|
113
|
-
);
|
114
|
-
|
115
|
-
return (
|
116
|
-
<Flex
|
117
|
-
width="100%"
|
118
|
-
backgroundColor={backgroundColor}
|
119
|
-
position="static"
|
120
|
-
paddingTop={[1.5, 2.5, 3, 3]}
|
121
|
-
paddingBottom={[1.5, 2.5, 3, 3]}
|
122
|
-
paddingLeft={[2, 3, 6, 9]}
|
123
|
-
paddingRight={[2, 3, 6, 9]}
|
124
|
-
transition="box-shadow 0.2s"
|
125
|
-
boxShadow={isScrolled ? "md" : undefined}
|
126
|
-
>
|
127
|
-
<Box flex="1">
|
128
|
-
<Box width="fit-content">{leftButton}</Box>
|
129
|
-
</Box>
|
130
|
-
<DrawerHeader
|
131
|
-
as="h2"
|
132
|
-
fontSize="md"
|
133
|
-
fontWeight="bold"
|
134
|
-
textAlign="center"
|
135
|
-
flex="2"
|
136
|
-
margin={0}
|
137
|
-
padding={0}
|
138
|
-
>
|
139
|
-
{title}
|
140
|
-
</DrawerHeader>
|
141
|
-
<Box flex="1">
|
142
|
-
<Box width="fit-content" marginLeft="auto">
|
143
|
-
{rightButton}
|
144
|
-
</Box>
|
145
|
-
</Box>
|
146
|
-
</Flex>
|
147
|
-
);
|
148
|
-
};
|
149
|
-
|
150
|
-
const DrawerCloseButton = () => {
|
151
|
-
const { onClose } = useModalContext();
|
152
|
-
const { t } = useTranslation();
|
153
|
-
|
154
|
-
const [isScreenSizeMinSm] = useMediaQuery(
|
155
|
-
`(min-width: ${tokens.size.breakpoint.sm})`,
|
156
|
-
);
|
157
|
-
|
158
|
-
if (isScreenSizeMinSm) {
|
159
|
-
return (
|
160
|
-
<Button
|
161
|
-
variant="ghost"
|
162
|
-
leftIcon={<CloseFill24Icon />}
|
163
|
-
onClick={onClose}
|
164
|
-
aria-label={t(texts.close)}
|
165
|
-
width="fit-content"
|
166
|
-
>
|
167
|
-
{t(texts.close)}
|
168
|
-
</Button>
|
169
|
-
);
|
170
|
-
}
|
171
|
-
|
172
|
-
return (
|
173
|
-
<IconButton
|
174
|
-
variant="ghost"
|
175
|
-
icon={<CloseFill30Icon />}
|
176
|
-
onClick={onClose}
|
177
|
-
aria-label={t(texts.close)}
|
178
|
-
/>
|
179
|
-
);
|
180
|
-
};
|
181
|
-
|
182
|
-
const DrawerBackButton = () => {
|
183
|
-
const { onClose } = useModalContext();
|
184
|
-
const { t } = useTranslation();
|
185
|
-
|
186
|
-
const [isScreenSizeMinSm] = useMediaQuery(
|
187
|
-
`(min-width: ${tokens.size.breakpoint.sm})`,
|
188
|
-
);
|
189
|
-
|
190
|
-
if (isScreenSizeMinSm) {
|
191
|
-
return (
|
192
|
-
<Button
|
193
|
-
variant="ghost"
|
194
|
-
leftIcon={<ArrowLeftFill24Icon />}
|
195
|
-
onClick={onClose}
|
196
|
-
aria-label={t(texts.backAriaLabel)}
|
197
|
-
width="fit-content"
|
198
|
-
>
|
199
|
-
{t(texts.back)}
|
200
|
-
</Button>
|
201
|
-
);
|
202
|
-
}
|
203
|
-
|
204
|
-
return (
|
205
|
-
<IconButton
|
206
|
-
variant="ghost"
|
207
|
-
icon={<ArrowLeftFill30Icon />}
|
208
|
-
onClick={onClose}
|
209
|
-
aria-label={t(texts.close)}
|
210
|
-
/>
|
211
|
-
);
|
212
|
-
};
|
213
|
-
|
214
|
-
const texts = createTexts({
|
215
|
-
close: {
|
216
|
-
nb: "Lukk",
|
217
|
-
nn: "Lukk",
|
218
|
-
en: "Close",
|
219
|
-
sv: "Stäng",
|
220
|
-
},
|
221
|
-
closeAriaLabel: {
|
222
|
-
nb: "Lukk vindu",
|
223
|
-
nn: "Lukk vindauge",
|
224
|
-
en: "Close window",
|
225
|
-
sv: "Stäng fönster",
|
226
|
-
},
|
227
|
-
back: {
|
228
|
-
nb: "Tilbake",
|
229
|
-
nn: "Tilbake",
|
230
|
-
en: "Back",
|
231
|
-
sv: "Tillbaka",
|
232
|
-
},
|
233
|
-
backAriaLabel: {
|
234
|
-
nb: "Gå tilbake",
|
235
|
-
nn: "Gå tilbake",
|
236
|
-
en: "Go back",
|
237
|
-
sv: "Gå tillbaka",
|
238
|
-
},
|
239
|
-
});
|
package/src/modal/Modal.tsx
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
export {
|
2
|
-
Modal,
|
3
|
-
ModalBody,
|
4
|
-
ModalCloseButton,
|
5
|
-
ModalContent,
|
6
|
-
ModalFooter,
|
7
|
-
ModalOverlay,
|
8
|
-
} from "@chakra-ui/react";
|
9
|
-
export type {
|
10
|
-
ModalBodyProps,
|
11
|
-
ModalContentProps,
|
12
|
-
ModalFooterProps,
|
13
|
-
ModalOverlayProps,
|
14
|
-
ModalProps,
|
15
|
-
} from "@chakra-ui/react";
|
@@ -1,31 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
forwardRef,
|
3
|
-
ModalHeader as ChakraModalHeader,
|
4
|
-
ModalHeaderProps as ChakraModalHeaderProps,
|
5
|
-
} from "@chakra-ui/react";
|
6
|
-
import React from "react";
|
7
|
-
|
8
|
-
export type ModalHeaderProps = ChakraModalHeaderProps & {
|
9
|
-
size?: "sm" | "lg";
|
10
|
-
};
|
11
|
-
|
12
|
-
/**
|
13
|
-
* ModalHeader
|
14
|
-
*
|
15
|
-
* You can specify the size with either `size="sm"` or `size="lg"`.
|
16
|
-
*/
|
17
|
-
export const ModalHeader = forwardRef<ModalHeaderProps, "header">(
|
18
|
-
({ size, ...props }, ref) => {
|
19
|
-
const styles = {
|
20
|
-
fontSize:
|
21
|
-
size === "lg"
|
22
|
-
? ["mobile.lg", "desktop.lg"]
|
23
|
-
: ["mobile.md", "desktop.md"],
|
24
|
-
textAlign:
|
25
|
-
size === "lg"
|
26
|
-
? "center"
|
27
|
-
: ("left" as ChakraModalHeaderProps["textAlign"]),
|
28
|
-
};
|
29
|
-
return <ChakraModalHeader as={"h1"} {...props} ref={ref} {...styles} />;
|
30
|
-
},
|
31
|
-
);
|
@@ -1,51 +0,0 @@
|
|
1
|
-
import React from "react";
|
2
|
-
import {
|
3
|
-
Drawer,
|
4
|
-
DrawerBody,
|
5
|
-
DrawerCloseButton,
|
6
|
-
DrawerContent,
|
7
|
-
DrawerHeader,
|
8
|
-
DrawerOverlay,
|
9
|
-
} from "./Drawer";
|
10
|
-
|
11
|
-
export type DrawerBodyProps = {
|
12
|
-
id?: string;
|
13
|
-
};
|
14
|
-
|
15
|
-
export type SimpleDrawerProps = {
|
16
|
-
children: React.ReactNode;
|
17
|
-
title?: React.ReactNode;
|
18
|
-
placement: "top" | "right" | "bottom" | "left";
|
19
|
-
isOpen: boolean;
|
20
|
-
onClose: () => void;
|
21
|
-
/** Props for drawer body */
|
22
|
-
body?: DrawerBodyProps;
|
23
|
-
};
|
24
|
-
/** A very basic drawer component that's easy to use
|
25
|
-
*
|
26
|
-
* ```tsx
|
27
|
-
* <SimpleDrawer placement="bottom" isOpen={isOpen} onClose={handleClose}>
|
28
|
-
* This is the drawer content
|
29
|
-
* </SimpleDrawer>
|
30
|
-
* ```
|
31
|
-
*
|
32
|
-
* For more advanced use cases, see the [Drawer](./Drawer.tsx) component.
|
33
|
-
*/
|
34
|
-
export const SimpleDrawer = ({
|
35
|
-
placement,
|
36
|
-
children,
|
37
|
-
title,
|
38
|
-
body,
|
39
|
-
...props
|
40
|
-
}: SimpleDrawerProps) => {
|
41
|
-
return (
|
42
|
-
<Drawer placement={placement} {...props}>
|
43
|
-
<DrawerOverlay />
|
44
|
-
<DrawerContent>
|
45
|
-
<DrawerCloseButton />
|
46
|
-
{title && <DrawerHeader>{title}</DrawerHeader>}
|
47
|
-
<DrawerBody {...body}>{children}</DrawerBody>
|
48
|
-
</DrawerContent>
|
49
|
-
</Drawer>
|
50
|
-
);
|
51
|
-
};
|
package/src/modal/index.tsx
DELETED
@@ -1,107 +0,0 @@
|
|
1
|
-
import { Box, usePopoverContext } from "@chakra-ui/react";
|
2
|
-
import { ArrowRightFill18Icon } from "@vygruppen/spor-icon-react";
|
3
|
-
import React, { useState } from "react";
|
4
|
-
import {
|
5
|
-
Button,
|
6
|
-
Flex,
|
7
|
-
Nudge,
|
8
|
-
NudgeProps,
|
9
|
-
ProgressIndicator,
|
10
|
-
createTexts,
|
11
|
-
useTranslation,
|
12
|
-
} from "..";
|
13
|
-
|
14
|
-
export type WizardNudgeProps = Omit<NudgeProps, "actions" | "content"> & {
|
15
|
-
/** Steps in the wizard. Each item is its own step. Should only be Step components */
|
16
|
-
content: React.ReactNode[];
|
17
|
-
/**
|
18
|
-
* Where the nudge should be placed by default.
|
19
|
-
*
|
20
|
-
* Note - this is a suggestion, and may be overridden by space concerns.
|
21
|
-
*/
|
22
|
-
placement?: "top" | "bottom" | "left" | "right";
|
23
|
-
};
|
24
|
-
/**
|
25
|
-
* A nudge that displays its children one at a time, with a step indicator.
|
26
|
-
*
|
27
|
-
* ```tsx
|
28
|
-
* <WizardNudge
|
29
|
-
* content={["First step", "Second step"]}
|
30
|
-
* name="my-wizard-nudge"
|
31
|
-
* introducedDate="2024-02-19"
|
32
|
-
* >
|
33
|
-
* <StaticCard width="fit-content" padding={2}>
|
34
|
-
* My new feature
|
35
|
-
* </StaticCard>
|
36
|
-
* </WizardNudge>
|
37
|
-
* ```
|
38
|
-
*/
|
39
|
-
export const WizardNudge = ({
|
40
|
-
children,
|
41
|
-
name,
|
42
|
-
onClose,
|
43
|
-
content,
|
44
|
-
...props
|
45
|
-
}: WizardNudgeProps) => {
|
46
|
-
const [currentStep, setCurrentStep] = useState(1);
|
47
|
-
const totalSteps = content.length;
|
48
|
-
const isLastStep = totalSteps === currentStep;
|
49
|
-
const onNext = () => setCurrentStep((prev) => prev + 1);
|
50
|
-
|
51
|
-
return (
|
52
|
-
<Nudge
|
53
|
-
onClose={onClose}
|
54
|
-
name={name}
|
55
|
-
content={content[currentStep - 1]}
|
56
|
-
actions={
|
57
|
-
<Flex gap={3} alignItems="center">
|
58
|
-
<ProgressIndicator
|
59
|
-
activeStep={currentStep}
|
60
|
-
numberOfSteps={totalSteps}
|
61
|
-
/>
|
62
|
-
<Box>
|
63
|
-
<NextOrCloseButton isLastStep={isLastStep} onNext={onNext} />
|
64
|
-
</Box>
|
65
|
-
</Flex>
|
66
|
-
}
|
67
|
-
{...props}
|
68
|
-
>
|
69
|
-
{children}
|
70
|
-
</Nudge>
|
71
|
-
);
|
72
|
-
};
|
73
|
-
|
74
|
-
type NextOrCloseButtonProps = {
|
75
|
-
isLastStep: boolean;
|
76
|
-
onNext: () => void;
|
77
|
-
};
|
78
|
-
const NextOrCloseButton = ({ isLastStep, onNext }: NextOrCloseButtonProps) => {
|
79
|
-
const { onClose } = usePopoverContext();
|
80
|
-
const { t } = useTranslation();
|
81
|
-
return (
|
82
|
-
<Button
|
83
|
-
variant="tertiary"
|
84
|
-
size="xs"
|
85
|
-
leftIcon={isLastStep ? undefined : <ArrowRightFill18Icon />}
|
86
|
-
onClick={isLastStep ? onClose : onNext}
|
87
|
-
width="fit-content"
|
88
|
-
>
|
89
|
-
{t(isLastStep ? texts.finish : texts.nextStep)}
|
90
|
-
</Button>
|
91
|
-
);
|
92
|
-
};
|
93
|
-
|
94
|
-
const texts = createTexts({
|
95
|
-
nextStep: {
|
96
|
-
nb: "Neste",
|
97
|
-
nn: "Neste",
|
98
|
-
sv: "Nästa",
|
99
|
-
en: "Next",
|
100
|
-
},
|
101
|
-
finish: {
|
102
|
-
nb: "Fullfør",
|
103
|
-
nn: "Fullfør",
|
104
|
-
sv: "Fullför",
|
105
|
-
en: "Finish",
|
106
|
-
},
|
107
|
-
});
|