@vygruppen/spor-react 12.24.16 → 13.0.1
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/.turbo/turbo-postinstall.log +2 -2
- package/CHANGELOG.md +24 -0
- package/dist/index.cjs +2753 -2646
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +887 -601
- package/dist/index.d.ts +887 -601
- package/dist/index.mjs +2712 -2605
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
- package/src/accordion/Accordion.tsx +34 -29
- package/src/accordion/Expandable.tsx +20 -21
- package/src/alert/Alert.tsx +7 -5
- package/src/alert/AlertIcon.tsx +19 -20
- package/src/alert/ExpandableAlert.tsx +65 -64
- package/src/alert/ServiceAlert.tsx +78 -78
- package/src/breadcrumb/Breadcrumb.tsx +37 -34
- package/src/button/Button.tsx +64 -57
- package/src/button/ButtonGroup.tsx +12 -10
- package/src/button/Clipboard.tsx +21 -18
- package/src/button/CloseButton.tsx +19 -17
- package/src/button/FloatingActionButton.tsx +41 -47
- package/src/button/IconButton.tsx +20 -18
- package/src/calendar/CalendarContext.tsx +1 -1
- package/src/color-mode/color-mode.tsx +7 -5
- package/src/datepicker/CalendarTriggerButton.tsx +11 -7
- package/src/datepicker/DateField.tsx +53 -51
- package/src/datepicker/DatePicker.tsx +127 -134
- package/src/datepicker/DateTimeSegment.tsx +44 -40
- package/src/datepicker/StyledField.tsx +39 -36
- package/src/dialog/Dialog.tsx +14 -11
- package/src/dialog/Drawer.tsx +74 -67
- package/src/input/AttachedInputs.tsx +35 -41
- package/src/input/Autocomplete.tsx +118 -129
- package/src/input/CardSelect.tsx +67 -65
- package/src/input/Checkbox.tsx +19 -17
- package/src/input/CheckboxGroup.tsx +0 -2
- package/src/input/ChoiceChip.tsx +42 -38
- package/src/input/Combobox.tsx +4 -4
- package/src/input/CountryCodeSelect.tsx +8 -8
- package/src/input/Field.tsx +78 -75
- package/src/input/FloatingLabel.tsx +6 -8
- package/src/input/Input.tsx +87 -92
- package/src/input/ListBox.tsx +3 -4
- package/src/input/Menu.tsx +149 -142
- package/src/input/NativeSelect.tsx +7 -5
- package/src/input/NumericStepper.tsx +15 -12
- package/src/input/PasswordInput.tsx +65 -61
- package/src/input/PhoneNumberInput.tsx +7 -7
- package/src/input/Popover.tsx +52 -55
- package/src/input/Radio.tsx +16 -11
- package/src/input/SearchInput.tsx +32 -31
- package/src/input/Select.tsx +106 -96
- package/src/input/Switch.tsx +43 -41
- package/src/input/Textarea.tsx +68 -66
- package/src/input/useFLoatingInputState.tsx +1 -1
- package/src/layout/PressableCard.tsx +11 -10
- package/src/layout/RadioCard.tsx +57 -53
- package/src/layout/Separator.tsx +8 -7
- package/src/layout/StaticCard.tsx +11 -10
- package/src/linjetag/LineIcon.tsx +48 -54
- package/src/linjetag/TravelTag.tsx +57 -59
- package/src/link/TextLink.tsx +50 -40
- package/src/loader/ProgressBar.tsx +41 -46
- package/src/loader/ProgressLoader.tsx +83 -86
- package/src/loader/Skeleton.tsx +56 -48
- package/src/logo/CargonetLogo.tsx +88 -87
- package/src/logo/VyLogo.tsx +80 -77
- package/src/logo/VyLogoPride.tsx +137 -135
- package/src/media-controller/JumpButton.tsx +30 -28
- package/src/media-controller/PlayPauseButton.tsx +8 -7
- package/src/media-controller/SkipButton.tsx +28 -26
- package/src/nudge/Nudge.tsx +66 -70
- package/src/pagination/Pagination.tsx +52 -46
- package/src/popover/index.tsx +46 -41
- package/src/progress-indicator/ProgressIndicator.tsx +10 -7
- package/src/stepper/Stepper.tsx +84 -81
- package/src/tab/Tabs.tsx +8 -4
- package/src/table/Table.tsx +89 -109
- package/src/tooltip.tsx +26 -22
- package/src/typography/Badge.tsx +8 -5
- package/src/typography/Code.tsx +8 -5
- package/src/typography/Heading.tsx +22 -23
- package/src/typography/Text.tsx +11 -9
- package/tsconfig.json +1 -0
package/src/stepper/Stepper.tsx
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
useSlotRecipe,
|
|
7
7
|
} from "@chakra-ui/react";
|
|
8
8
|
import { ArrowLeftFill24Icon } from "@vygruppen/spor-icon-react";
|
|
9
|
-
import {
|
|
9
|
+
import { PropsWithChildren } from "react";
|
|
10
10
|
|
|
11
11
|
import { Box, createTexts, IconButton, Text, useTranslation } from "..";
|
|
12
12
|
import { stepperSlotRecipe } from "../theme/slot-recipes/stepper";
|
|
@@ -58,90 +58,93 @@ type StepperProps = PropsWithChildren<StepperVariantProps> & {
|
|
|
58
58
|
* ```
|
|
59
59
|
**/
|
|
60
60
|
|
|
61
|
-
export const Stepper =
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
61
|
+
export const Stepper = function Stepper({
|
|
62
|
+
ref,
|
|
63
|
+
...props
|
|
64
|
+
}: StepperProps & {
|
|
65
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
66
|
+
}) {
|
|
67
|
+
const {
|
|
68
|
+
onClick = () => {},
|
|
69
|
+
onBackButtonClick,
|
|
70
|
+
steps,
|
|
71
|
+
activeStep: activeStepAsStringOrNumber,
|
|
72
|
+
heading,
|
|
73
|
+
headingLevel,
|
|
74
|
+
variant,
|
|
75
|
+
disabled,
|
|
76
|
+
css,
|
|
77
|
+
} = props;
|
|
78
|
+
const recipe = useSlotRecipe({ key: "stepper" });
|
|
79
|
+
const style = recipe({ variant });
|
|
80
|
+
const numberOfSteps = steps.length;
|
|
81
|
+
const activeStep = Number(activeStepAsStringOrNumber);
|
|
82
|
+
const { t } = useTranslation();
|
|
83
|
+
const hideBackButtonOnFirstStep = activeStep === 1 && !onBackButtonClick;
|
|
80
84
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
>
|
|
118
|
-
{heading}
|
|
119
|
-
</Text>
|
|
120
|
-
)}
|
|
121
|
-
<Box css={style.stepCounter} data-part="step-counter">
|
|
122
|
-
{t(texts.stepsOf(activeStep, numberOfSteps))}
|
|
123
|
-
</Box>
|
|
124
|
-
</Flex>
|
|
125
|
-
</Box>
|
|
126
|
-
<Flex justifyContent="center" display={["none", null, "flex"]}>
|
|
127
|
-
{steps.map((step, index) => (
|
|
128
|
-
<StepperStep
|
|
129
|
-
key={index}
|
|
130
|
-
stepNumber={index + 1}
|
|
131
|
-
variant={variant}
|
|
132
|
-
aria-current={index + 1 === activeStep ? "step" : undefined}
|
|
133
|
-
disabled={disabled}
|
|
85
|
+
return (
|
|
86
|
+
<Box css={{ ...style.root, ...css }} ref={ref}>
|
|
87
|
+
<StepperProvider
|
|
88
|
+
onClick={onClick}
|
|
89
|
+
activeStep={activeStep}
|
|
90
|
+
variant={variant}
|
|
91
|
+
numberOfSteps={numberOfSteps}
|
|
92
|
+
>
|
|
93
|
+
<Box css={style.container} data-part="root">
|
|
94
|
+
<Box css={style.innerContainer}>
|
|
95
|
+
<Flex
|
|
96
|
+
justifyContent="space-between"
|
|
97
|
+
alignItems="center"
|
|
98
|
+
gap={2}
|
|
99
|
+
flex={1}
|
|
100
|
+
>
|
|
101
|
+
<IconButton
|
|
102
|
+
aria-label={t(texts.back)}
|
|
103
|
+
icon={<ArrowLeftFill24Icon />}
|
|
104
|
+
variant="ghost"
|
|
105
|
+
size="sm"
|
|
106
|
+
visibility={hideBackButtonOnFirstStep ? "hidden" : "visible"}
|
|
107
|
+
onClick={() => {
|
|
108
|
+
const stepToGoTo = activeStep - 1;
|
|
109
|
+
if (onBackButtonClick) {
|
|
110
|
+
onBackButtonClick(stepToGoTo);
|
|
111
|
+
}
|
|
112
|
+
onClick(stepToGoTo);
|
|
113
|
+
}}
|
|
114
|
+
/>
|
|
115
|
+
{heading && (
|
|
116
|
+
<Text
|
|
117
|
+
variant="sm"
|
|
118
|
+
as={headingLevel}
|
|
119
|
+
css={style.title}
|
|
120
|
+
data-part="title"
|
|
134
121
|
>
|
|
135
|
-
{
|
|
136
|
-
</
|
|
137
|
-
)
|
|
122
|
+
{heading}
|
|
123
|
+
</Text>
|
|
124
|
+
)}
|
|
125
|
+
<Box css={style.stepCounter} data-part="step-counter">
|
|
126
|
+
{t(texts.stepsOf(activeStep, numberOfSteps))}
|
|
127
|
+
</Box>
|
|
138
128
|
</Flex>
|
|
139
129
|
</Box>
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
130
|
+
<Flex justifyContent="center" display={["none", null, "flex"]}>
|
|
131
|
+
{steps.map((step, index) => (
|
|
132
|
+
<StepperStep
|
|
133
|
+
key={index}
|
|
134
|
+
stepNumber={index + 1}
|
|
135
|
+
variant={variant}
|
|
136
|
+
aria-current={index + 1 === activeStep ? "step" : undefined}
|
|
137
|
+
disabled={disabled}
|
|
138
|
+
>
|
|
139
|
+
{step}
|
|
140
|
+
</StepperStep>
|
|
141
|
+
))}
|
|
142
|
+
</Flex>
|
|
143
|
+
</Box>
|
|
144
|
+
</StepperProvider>
|
|
145
|
+
</Box>
|
|
146
|
+
);
|
|
147
|
+
};
|
|
145
148
|
|
|
146
149
|
const texts = createTexts({
|
|
147
150
|
stepsOf: (activeStep, numberOfSteps) => ({
|
package/src/tab/Tabs.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
Tabs as ChakraTabs,
|
|
5
5
|
TabsRootProps as ChakraTabsRootProps,
|
|
6
6
|
} from "@chakra-ui/react";
|
|
7
|
-
import {
|
|
7
|
+
import { PropsWithChildren } from "react";
|
|
8
8
|
|
|
9
9
|
import { tabsSlotRecipe } from "../theme/slot-recipes/tabs";
|
|
10
10
|
|
|
@@ -58,11 +58,15 @@ export type TabsProps = Exclude<
|
|
|
58
58
|
/** Defaults to `start` */
|
|
59
59
|
justify?: "start" | "center" | "end";
|
|
60
60
|
};
|
|
61
|
-
export const Tabs =
|
|
61
|
+
export const Tabs = ({
|
|
62
|
+
ref,
|
|
63
|
+
...props
|
|
64
|
+
}: TabsProps & {
|
|
65
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
66
|
+
}) => {
|
|
62
67
|
const { variant = "core", size = "sm" } = props;
|
|
63
68
|
return <ChakraTabs.Root {...props} ref={ref} variant={variant} size={size} />;
|
|
64
|
-
}
|
|
65
|
-
Tabs.displayName = "Tabs";
|
|
69
|
+
};
|
|
66
70
|
|
|
67
71
|
export const TabsList = ChakraTabs.List;
|
|
68
72
|
export const TabsTrigger = ChakraTabs.Trigger;
|
package/src/table/Table.tsx
CHANGED
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
} from "@vygruppen/spor-icon-react";
|
|
17
17
|
import {
|
|
18
18
|
createContext,
|
|
19
|
-
forwardRef,
|
|
20
19
|
PropsWithChildren,
|
|
21
20
|
useContext,
|
|
22
21
|
useLayoutEffect,
|
|
@@ -52,75 +51,58 @@ export type TableProps = Exclude<ChakraTableProps, "variant" | "colorPalette"> &
|
|
|
52
51
|
variant?: "ghost" | "core";
|
|
53
52
|
colorPalette?: "grey" | "green" | "white";
|
|
54
53
|
sortable?: boolean;
|
|
54
|
+
ref?: React.Ref<HTMLTableElement>;
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const handleSort = (columnIndex: number) => {
|
|
91
|
-
if (!sortable) return;
|
|
92
|
-
setSortState(getNextSortState(sortState, columnIndex));
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
const recipe = useSlotRecipe({ key: "table" });
|
|
96
|
-
const styles = recipe({ variant, size });
|
|
97
|
-
|
|
98
|
-
return (
|
|
99
|
-
<ChakraTable.Root
|
|
100
|
-
variant={variant}
|
|
101
|
-
size={size}
|
|
102
|
-
colorPalette={colorPalette}
|
|
103
|
-
css={styles}
|
|
104
|
-
ref={ref}
|
|
105
|
-
{...rest}
|
|
57
|
+
export const Table = ({
|
|
58
|
+
variant = "ghost",
|
|
59
|
+
size,
|
|
60
|
+
colorPalette = "green",
|
|
61
|
+
children,
|
|
62
|
+
sortable = false,
|
|
63
|
+
ref,
|
|
64
|
+
...rest
|
|
65
|
+
}: TableProps) => {
|
|
66
|
+
const [sortState, setSortState] = useState<SortState>({
|
|
67
|
+
direction: "asc",
|
|
68
|
+
columnIndex: null,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const handleSort = (columnIndex: number) => {
|
|
72
|
+
if (!sortable) return;
|
|
73
|
+
setSortState(getNextSortState(sortState, columnIndex));
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const recipe = useSlotRecipe({ key: "table" });
|
|
77
|
+
const styles = recipe({ variant, size });
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<ChakraTable.Root
|
|
81
|
+
variant={variant}
|
|
82
|
+
size={size}
|
|
83
|
+
colorPalette={colorPalette}
|
|
84
|
+
css={styles}
|
|
85
|
+
ref={ref}
|
|
86
|
+
{...rest}
|
|
87
|
+
>
|
|
88
|
+
<SortContext.Provider
|
|
89
|
+
value={{ enabled: sortable, sortState, onSort: handleSort }}
|
|
106
90
|
>
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
TableColumnHeaderProps
|
|
123
|
-
>(({ children, ...rest }, ref) => {
|
|
91
|
+
{children}
|
|
92
|
+
</SortContext.Provider>
|
|
93
|
+
</ChakraTable.Root>
|
|
94
|
+
);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export type TableColumnHeaderProps = ChakraTableColumnHeaderProps & {
|
|
98
|
+
ref?: React.Ref<HTMLTableCellElement>;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export const TableColumnHeader = ({
|
|
102
|
+
children,
|
|
103
|
+
ref,
|
|
104
|
+
...rest
|
|
105
|
+
}: TableColumnHeaderProps) => {
|
|
124
106
|
const { enabled, sortState, onSort } = useTableSort();
|
|
125
107
|
const [columnIndex, setColumnIndex] = useState<number | null>(null);
|
|
126
108
|
const props = rest as Record<string, unknown>;
|
|
@@ -165,45 +147,43 @@ export const TableColumnHeader = forwardRef<
|
|
|
165
147
|
</HStack>
|
|
166
148
|
</ChakraTable.ColumnHeader>
|
|
167
149
|
);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
);
|
|
209
|
-
TableBody.displayName = "TableBody";
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export type TableBodyProps = ChakraTableBodyProps & {
|
|
153
|
+
ref?: React.Ref<HTMLTableSectionElement>;
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
export const TableBody = ({ children, ref, ...rest }: TableBodyProps) => {
|
|
157
|
+
const { sortState } = useTableSort();
|
|
158
|
+
const tbodyRef = useRef<HTMLTableSectionElement | null>(null);
|
|
159
|
+
const originalOrder = useRef<HTMLTableRowElement[]>([]);
|
|
160
|
+
const previousChildren = useRef(children);
|
|
161
|
+
|
|
162
|
+
useLayoutEffect(() => {
|
|
163
|
+
const tbody = tbodyRef.current;
|
|
164
|
+
if (!tbody) return;
|
|
165
|
+
|
|
166
|
+
if (
|
|
167
|
+
previousChildren.current !== children ||
|
|
168
|
+
originalOrder.current.length === 0
|
|
169
|
+
) {
|
|
170
|
+
originalOrder.current = captureRowOrder(tbody);
|
|
171
|
+
previousChildren.current = children;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
applyDomSort(tbody, sortState, originalOrder.current);
|
|
175
|
+
}, [sortState, children]);
|
|
176
|
+
|
|
177
|
+
return (
|
|
178
|
+
<ChakraTable.Body
|
|
179
|
+
ref={(element: HTMLTableSectionElement) => {
|
|
180
|
+
tbodyRef.current = element;
|
|
181
|
+
if (typeof ref === "function") ref(element);
|
|
182
|
+
else if (ref) ref.current = element;
|
|
183
|
+
}}
|
|
184
|
+
{...rest}
|
|
185
|
+
>
|
|
186
|
+
{children}
|
|
187
|
+
</ChakraTable.Body>
|
|
188
|
+
);
|
|
189
|
+
};
|
package/src/tooltip.tsx
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { Portal, Tooltip as ChakraTooltip } from "@chakra-ui/react";
|
|
4
|
-
import { forwardRef } from "react";
|
|
5
4
|
|
|
6
5
|
export const Tooltip = ChakraTooltip.Root;
|
|
7
6
|
|
|
8
|
-
export const TooltipTrigger =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
export const TooltipTrigger = ({
|
|
8
|
+
ref,
|
|
9
|
+
children,
|
|
10
|
+
...props
|
|
11
|
+
}: ChakraTooltip.TriggerProps & {
|
|
12
|
+
ref?: React.Ref<HTMLButtonElement>;
|
|
13
|
+
}) => {
|
|
12
14
|
const isStringChild = typeof children === "string";
|
|
13
15
|
|
|
14
16
|
return (
|
|
@@ -16,23 +18,25 @@ export const TooltipTrigger = forwardRef<
|
|
|
16
18
|
{children}
|
|
17
19
|
</ChakraTooltip.Trigger>
|
|
18
20
|
);
|
|
19
|
-
}
|
|
20
|
-
TooltipTrigger.displayName = "TooltipTrigger";
|
|
21
|
+
};
|
|
21
22
|
|
|
22
23
|
export type TooltipProps = ChakraTooltip.ContentProps;
|
|
23
24
|
|
|
24
|
-
export const TooltipContent =
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
25
|
+
export const TooltipContent = ({
|
|
26
|
+
ref,
|
|
27
|
+
children,
|
|
28
|
+
...props
|
|
29
|
+
}: TooltipProps & {
|
|
30
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
31
|
+
}) => {
|
|
32
|
+
return (
|
|
33
|
+
<Portal>
|
|
34
|
+
<ChakraTooltip.Positioner>
|
|
35
|
+
<ChakraTooltip.Content ref={ref} {...props}>
|
|
36
|
+
<ChakraTooltip.Arrow />
|
|
37
|
+
<ChakraTooltip.Content {...props}>{children}</ChakraTooltip.Content>
|
|
38
|
+
</ChakraTooltip.Content>
|
|
39
|
+
</ChakraTooltip.Positioner>
|
|
40
|
+
</Portal>
|
|
41
|
+
);
|
|
42
|
+
};
|
package/src/typography/Badge.tsx
CHANGED
|
@@ -5,20 +5,23 @@ import {
|
|
|
5
5
|
Box,
|
|
6
6
|
} from "@chakra-ui/react";
|
|
7
7
|
import { IconComponent } from "@vygruppen/spor-icon-react";
|
|
8
|
-
import { forwardRef } from "react";
|
|
9
8
|
|
|
10
9
|
export type BadgeProps = ChakraBadgeProps & {
|
|
11
10
|
icon?: IconComponent;
|
|
12
11
|
};
|
|
13
12
|
|
|
14
|
-
export const Badge =
|
|
15
|
-
{ icon, children, ...props },
|
|
13
|
+
export const Badge = function Badge({
|
|
16
14
|
ref,
|
|
17
|
-
|
|
15
|
+
icon,
|
|
16
|
+
children,
|
|
17
|
+
...props
|
|
18
|
+
}: BadgeProps & {
|
|
19
|
+
ref?: React.Ref<HTMLSpanElement>;
|
|
20
|
+
}) {
|
|
18
21
|
return (
|
|
19
22
|
<ChakraBadge ref={ref} {...props}>
|
|
20
23
|
{children}
|
|
21
24
|
{icon && <Box as={icon} />}
|
|
22
25
|
</ChakraBadge>
|
|
23
26
|
);
|
|
24
|
-
}
|
|
27
|
+
};
|
package/src/typography/Code.tsx
CHANGED
|
@@ -14,8 +14,11 @@ type CodeVariantProps = RecipeVariantProps<typeof codeRecipie> & CodeProps;
|
|
|
14
14
|
|
|
15
15
|
const StyledCode = chakra(ChakraCode, codeRecipie);
|
|
16
16
|
|
|
17
|
-
export const Code =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
export const Code = function Code({
|
|
18
|
+
ref,
|
|
19
|
+
...props
|
|
20
|
+
}: CodeVariantProps & {
|
|
21
|
+
ref?: React.Ref<HTMLElement>;
|
|
22
|
+
}) {
|
|
23
|
+
return <StyledCode {...props} ref={ref} />;
|
|
24
|
+
};
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
HeadingProps as ChakraHeadingProps,
|
|
5
5
|
Text,
|
|
6
6
|
} from "@chakra-ui/react";
|
|
7
|
-
import {
|
|
7
|
+
import { useId } from "react";
|
|
8
8
|
|
|
9
9
|
import { slugify } from "..";
|
|
10
10
|
|
|
@@ -42,28 +42,27 @@ export type HeadingProps = Omit<ChakraHeadingProps, "textStyle" | "as"> & {
|
|
|
42
42
|
* ```
|
|
43
43
|
*/
|
|
44
44
|
|
|
45
|
-
export const Heading =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
export const Heading = function Heading({
|
|
46
|
+
ref,
|
|
47
|
+
...props
|
|
48
|
+
}: HeadingProps & {
|
|
49
|
+
ref?: React.Ref<HTMLHeadingElement>;
|
|
50
|
+
}) {
|
|
51
|
+
const {
|
|
52
|
+
as,
|
|
53
|
+
variant = "xl-display",
|
|
54
|
+
autoId = false,
|
|
55
|
+
id: externalId,
|
|
56
|
+
...rest
|
|
57
|
+
} = props;
|
|
54
58
|
|
|
55
|
-
|
|
59
|
+
const reactId = useId();
|
|
56
60
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
: reactId;
|
|
63
|
-
}
|
|
61
|
+
function getId() {
|
|
62
|
+
if (externalId !== undefined) return externalId;
|
|
63
|
+
if (!autoId) return;
|
|
64
|
+
return typeof rest.children === "string" ? slugify(rest.children) : reactId;
|
|
65
|
+
}
|
|
64
66
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
);
|
|
68
|
-
},
|
|
69
|
-
);
|
|
67
|
+
return <Text as={as} textStyle={variant} id={getId()} ref={ref} {...rest} />;
|
|
68
|
+
};
|
package/src/typography/Text.tsx
CHANGED
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
Text as ChakraText,
|
|
4
4
|
TextProps as ChakraTextProps,
|
|
5
5
|
} from "@chakra-ui/react";
|
|
6
|
-
import { forwardRef } from "react";
|
|
7
6
|
|
|
8
7
|
export type TextProps = Omit<ChakraTextProps, "textStyle"> & {
|
|
9
8
|
/** The size and style of the text.
|
|
@@ -45,11 +44,14 @@ function resolveTextProps({
|
|
|
45
44
|
* <Text>Welcome to this paragraph of text.</Text>
|
|
46
45
|
* ```
|
|
47
46
|
*/
|
|
48
|
-
export const Text =
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
);
|
|
47
|
+
export const Text = function Text({
|
|
48
|
+
ref,
|
|
49
|
+
...props
|
|
50
|
+
}: TextProps & {
|
|
51
|
+
ref?: React.Ref<HTMLParagraphElement>;
|
|
52
|
+
}) {
|
|
53
|
+
const { variant, lineHeight, fontSize, ...rest } = props;
|
|
54
|
+
const resolvedProps = resolveTextProps({ variant, fontSize, lineHeight });
|
|
55
|
+
|
|
56
|
+
return <ChakraText {...resolvedProps} {...rest} ref={ref} />;
|
|
57
|
+
};
|