@helsenorge/designsystem-react 14.0.0-beta.9 → 14.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/lib/AnchorLink.js +2 -2
- package/lib/AnchorLink.js.map +1 -1
- package/lib/Avatar.js +2 -2
- package/lib/Avatar.js.map +1 -1
- package/lib/Badge.js +2 -2
- package/lib/Badge.js.map +1 -1
- package/lib/Button.js +6 -6
- package/lib/Button.js.map +1 -1
- package/lib/CHANGELOG.md +341 -11
- package/lib/Checkbox.js +6 -6
- package/lib/Checkbox.js.map +1 -1
- package/lib/Close.js +3 -3
- package/lib/Close.js.map +1 -1
- package/lib/DictionaryTrigger.js +2 -2
- package/lib/DictionaryTrigger.js.map +1 -1
- package/lib/DoctorSmall.js +22 -34
- package/lib/DoctorSmall.js.map +1 -1
- package/lib/Drawer.js +6 -5
- package/lib/Drawer.js.map +1 -1
- package/lib/Duolist.js +5 -5
- package/lib/Duolist.js.map +1 -1
- package/lib/ElementHeader.js +9 -9
- package/lib/ElementHeader.js.map +1 -1
- package/lib/ElementHeaderText.js +4 -4
- package/lib/ElementHeaderText.js.map +1 -1
- package/lib/ErrorWrapper.js +2 -2
- package/lib/ErrorWrapper.js.map +1 -1
- package/lib/Expander.js +8 -8
- package/lib/Expander.js.map +1 -1
- package/lib/FormFieldTag.js +2 -2
- package/lib/FormFieldTag.js.map +1 -1
- package/lib/FormGroup.js +5 -5
- package/lib/FormGroup.js.map +1 -1
- package/lib/FormLayout.js +3 -3
- package/lib/FormLayout.js.map +1 -1
- package/lib/HelpDetails.js +3 -3
- package/lib/HelpDetails.js.map +1 -1
- package/lib/HelpTriggerIcon.js +12 -8
- package/lib/HelpTriggerIcon.js.map +1 -1
- package/lib/HelpTriggerStandalone.js +2 -2
- package/lib/HelpTriggerStandalone.js.map +1 -1
- package/lib/HighlightPanel.js +3 -3
- package/lib/HighlightPanel.js.map +1 -1
- package/lib/HorizontalScroll.js +4 -4
- package/lib/HorizontalScroll.js.map +1 -1
- package/lib/Icon.js +2 -2
- package/lib/Icon.js.map +1 -1
- package/lib/IllustrationNames.js +6 -2
- package/lib/IllustrationNames.js.map +1 -1
- package/lib/InfoTeaser.js +3 -3
- package/lib/InfoTeaser.js.map +1 -1
- package/lib/Input.js +9 -7
- package/lib/Input.js.map +1 -1
- package/lib/LazyIcon.js +3 -0
- package/lib/LazyIcon.js.map +1 -1
- package/lib/LazyIllustration.js +5 -1
- package/lib/LazyIllustration.js.map +1 -1
- package/lib/LinkList.js +5 -5
- package/lib/LinkList.js.map +1 -1
- package/lib/List.js +2 -2
- package/lib/List.js.map +1 -1
- package/lib/ListEditMode.js +4 -4
- package/lib/ListEditMode.js.map +1 -1
- package/lib/MaxCharacters.js +2 -2
- package/lib/MaxCharacters.js.map +1 -1
- package/lib/PanelTitle.js +2 -2
- package/lib/PanelTitle.js.map +1 -1
- package/lib/PopOver.js +2 -2
- package/lib/PopOver.js.map +1 -1
- package/lib/Select.js +4 -4
- package/lib/Select.js.map +1 -1
- package/lib/SingleSelectItem.js +3 -3
- package/lib/SingleSelectItem.js.map +1 -1
- package/lib/Slider.js +18 -10
- package/lib/Slider.js.map +1 -1
- package/lib/Spacer.js +2 -2
- package/lib/Spacer.js.map +1 -1
- package/lib/StatusDot.js +4 -4
- package/lib/StatusDot.js.map +1 -1
- package/lib/StatusDotList.js +2 -2
- package/lib/StatusDotList.js.map +1 -1
- package/lib/StepButtons.js +5 -5
- package/lib/StepButtons.js.map +1 -1
- package/lib/StorkMedium.js +96 -0
- package/lib/StorkMedium.js.map +1 -0
- package/lib/TabList.js +8 -8
- package/lib/TabList.js.map +1 -1
- package/lib/TabPanel.js +2 -2
- package/lib/TabPanel.js.map +1 -1
- package/lib/TableBody.js +3 -3
- package/lib/TableBody.js.map +1 -1
- package/lib/TableCell.js +3 -3
- package/lib/TableCell.js.map +1 -1
- package/lib/TableExpandedRow.js +5 -5
- package/lib/TableExpandedRow.js.map +1 -1
- package/lib/TableExpanderCell.js +3 -3
- package/lib/TableExpanderCell.js.map +1 -1
- package/lib/TableHead.js +7 -7
- package/lib/TableHead.js.map +1 -1
- package/lib/TableHeadCell.js +6 -6
- package/lib/TableHeadCell.js.map +1 -1
- package/lib/TableRow.js +6 -6
- package/lib/TableRow.js.map +1 -1
- package/lib/Textarea.js +17 -16
- package/lib/Textarea.js.map +1 -1
- package/lib/ThinkingMedium.js +98 -0
- package/lib/ThinkingMedium.js.map +1 -0
- package/lib/Title.js +2 -2
- package/lib/Title.js.map +1 -1
- package/lib/Toast.js +3 -3
- package/lib/Toast.js.map +1 -1
- package/lib/components/ArticleTeaser/index.js +4 -4
- package/lib/components/ArticleTeaser/index.js.map +1 -1
- package/lib/components/Button/styles.module.scss +1 -3
- package/lib/components/Chip/index.js +2 -2
- package/lib/components/Chip/index.js.map +1 -1
- package/lib/components/Drawer/styles.module.scss +4 -21
- package/lib/components/Drawer/styles.module.scss.d.ts +1 -1
- package/lib/components/Dropdown/index.js +5 -5
- package/lib/components/Dropdown/index.js.map +1 -1
- package/lib/components/DropdownOld/index.js +3 -3
- package/lib/components/DropdownOld/index.js.map +1 -1
- package/lib/components/EmptyState/index.js +2 -2
- package/lib/components/EmptyState/index.js.map +1 -1
- package/lib/components/ExpanderHierarchy/Expander.d.ts +1 -1
- package/lib/components/ExpanderHierarchy/index.js +7 -7
- package/lib/components/ExpanderHierarchy/index.js.map +1 -1
- package/lib/components/ExpanderList/index.js +19 -10
- package/lib/components/ExpanderList/index.js.map +1 -1
- package/lib/components/FavoriteButton/index.js +2 -2
- package/lib/components/FavoriteButton/index.js.map +1 -1
- package/lib/components/HelpBubble/index.js +3 -3
- package/lib/components/HelpBubble/index.js.map +1 -1
- package/lib/components/HelpPanel/index.js +2 -2
- package/lib/components/HelpPanel/index.js.map +1 -1
- package/lib/components/HelpTriggerIcon/HelpSign.d.ts +0 -1
- package/lib/components/HelpTriggerInline/index.js +2 -2
- package/lib/components/HelpTriggerInline/index.js.map +1 -1
- package/lib/components/HelpTriggerInline/styles.module.scss +1 -0
- package/lib/components/Icons/AdditionalIconInformation.d.ts +12 -0
- package/lib/components/Icons/AdditionalIconInformation.js +12 -0
- package/lib/components/Icons/AdditionalIconInformation.js.map +1 -1
- package/lib/components/Icons/IconNames.d.ts +1 -1
- package/lib/components/Icons/IconNames.js +3 -0
- package/lib/components/Icons/IconNames.js.map +1 -1
- package/lib/components/Icons/MeasuringTape.d.ts +3 -0
- package/lib/components/Icons/MeasuringTape.js +8 -0
- package/lib/components/Icons/MeasuringTape.js.map +1 -0
- package/lib/components/Icons/StarFill.d.ts +4 -0
- package/lib/components/Icons/StarFill.js +16 -0
- package/lib/components/Icons/StarFill.js.map +1 -0
- package/lib/components/Icons/StarStroke.d.ts +4 -0
- package/lib/components/Icons/StarStroke.js +16 -0
- package/lib/components/Icons/StarStroke.js.map +1 -0
- package/lib/components/Illustrations/IllustrationNames.d.ts +1 -1
- package/lib/components/Illustrations/Stork.d.ts +11 -0
- package/lib/components/Illustrations/Stork.js +16 -0
- package/lib/components/Illustrations/Stork.js.map +1 -0
- package/lib/components/Illustrations/StorkMedium.d.ts +4 -0
- package/lib/components/Illustrations/StorkMedium.js +2 -0
- package/lib/components/Illustrations/Thinking.d.ts +9 -0
- package/lib/components/Illustrations/Thinking.js +16 -0
- package/lib/components/Illustrations/Thinking.js.map +1 -0
- package/lib/components/Illustrations/ThinkingMedium.d.ts +4 -0
- package/lib/components/Illustrations/ThinkingMedium.js +2 -0
- package/lib/components/Loader/index.js +19 -17
- package/lib/components/Loader/index.js.map +1 -1
- package/lib/components/Modal/index.js +9 -9
- package/lib/components/Modal/index.js.map +1 -1
- package/lib/components/NotificationPanel/index.js +6 -6
- package/lib/components/NotificationPanel/index.js.map +1 -1
- package/lib/components/Panel/index.js +12 -12
- package/lib/components/Panel/index.js.map +1 -1
- package/lib/components/PanelList/index.js +3 -3
- package/lib/components/PanelList/index.js.map +1 -1
- package/lib/components/PopMenu/index.js +3 -3
- package/lib/components/PopMenu/index.js.map +1 -1
- package/lib/components/Progressbar/index.js +2 -2
- package/lib/components/Progressbar/index.js.map +1 -1
- package/lib/components/PromoPanel/index.js +2 -2
- package/lib/components/PromoPanel/index.js.map +1 -1
- package/lib/components/ServiceMessage/ServiceMessage.d.ts +3 -0
- package/lib/components/ServiceMessage/index.js +7 -7
- package/lib/components/ServiceMessage/index.js.map +1 -1
- package/lib/components/SharingStatus/index.js +4 -4
- package/lib/components/SharingStatus/index.js.map +1 -1
- package/lib/components/Step/index.js +2 -2
- package/lib/components/Step/index.js.map +1 -1
- package/lib/components/Stepper/index.js +2 -2
- package/lib/components/Stepper/index.js.map +1 -1
- package/lib/components/StickyNote/index.js +16 -13
- package/lib/components/StickyNote/index.js.map +1 -1
- package/lib/components/Table/index.js +3 -3
- package/lib/components/Table/index.js.map +1 -1
- package/lib/components/Tabs/index.js +4 -4
- package/lib/components/Tabs/index.js.map +1 -1
- package/lib/components/Tag/index.js +2 -2
- package/lib/components/Tag/index.js.map +1 -1
- package/lib/components/Tile/index.js +6 -5
- package/lib/components/Tile/index.js.map +1 -1
- package/lib/components/Toggle/index.js +16 -16
- package/lib/components/Toggle/index.js.map +1 -1
- package/lib/components/Toggle/styles.module.scss +4 -4
- package/lib/components/Validation/index.js +2 -2
- package/lib/components/Validation/index.js.map +1 -1
- package/lib/declaration.d.ts +9 -0
- package/lib/floating-ui.react.js +126 -129
- package/lib/floating-ui.react.js.map +1 -1
- package/lib/global.d.ts +3 -0
- package/lib/hooks/useIsServerSide.d.ts +1 -1
- package/lib/resources/Resources.d.ts +145 -0
- package/lib/scss/bootstrap/scss/mixins/_grid.scss +2 -1
- package/lib/types.d.ts +1 -0
- package/lib/useBreakpoint.js +15 -24
- package/lib/useBreakpoint.js.map +1 -1
- package/lib/useExpand.js +5 -3
- package/lib/useExpand.js.map +1 -1
- package/lib/useIsServerSide.js +5 -6
- package/lib/useIsServerSide.js.map +1 -1
- package/lib/useToggle.js +5 -3
- package/lib/useToggle.js.map +1 -1
- package/lib/utils2.js +7 -7
- package/lib/utils2.js.map +1 -1
- package/lib/utils3.js +5 -5
- package/lib/utils3.js.map +1 -1
- package/lib/utils6.js +2 -2
- package/lib/utils6.js.map +1 -1
- package/package.json +1 -1
- package/scss/bootstrap/scss/mixins/_grid.scss +2 -1
package/lib/global.d.ts
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/* eslint:disable */
|
|
2
|
+
/*
|
|
3
|
+
* This file is automatically generated by SOT
|
|
4
|
+
*
|
|
5
|
+
* This file is for typings support only, it will not supply the actual text, you will still need to download the correct culture spesific .resx file.
|
|
6
|
+
*/
|
|
7
|
+
export type HNDesignsystemDropdown = {
|
|
8
|
+
/**
|
|
9
|
+
* Lukk
|
|
10
|
+
*/
|
|
11
|
+
closeText: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type HNDesignsystemPanel = {
|
|
15
|
+
/**
|
|
16
|
+
* Se detaljer
|
|
17
|
+
*/
|
|
18
|
+
expandButtonOpen: string;
|
|
19
|
+
/**
|
|
20
|
+
* Skjul detaljer
|
|
21
|
+
*/
|
|
22
|
+
expandButtonClose: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type HNDesignsystemClose = {
|
|
26
|
+
/**
|
|
27
|
+
* Lukk
|
|
28
|
+
*/
|
|
29
|
+
ariaLabel: string;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type HNDesignsystemInfoTeaser = {
|
|
33
|
+
/**
|
|
34
|
+
* Vis mindre
|
|
35
|
+
*/
|
|
36
|
+
expandButtonOpen: string;
|
|
37
|
+
/**
|
|
38
|
+
* Vis mer
|
|
39
|
+
*/
|
|
40
|
+
expandButtonClose: string;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type HNDesignsystemArticleTeaser = {
|
|
44
|
+
/**
|
|
45
|
+
* Vis mer
|
|
46
|
+
*/
|
|
47
|
+
expandButtonClose: string;
|
|
48
|
+
/**
|
|
49
|
+
* Vis mindre
|
|
50
|
+
*/
|
|
51
|
+
expandButtonOpen: string;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export type HNDesignsystemHelpBubble = {
|
|
55
|
+
/**
|
|
56
|
+
* Hjelpetekst
|
|
57
|
+
*/
|
|
58
|
+
ariaLabel: string;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export type HNDesignsystemHelpDrawer = {
|
|
62
|
+
/**
|
|
63
|
+
* Hjelpetekst
|
|
64
|
+
*/
|
|
65
|
+
ariaLabel: string;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export type HNDesignsystemFavoriteButton = {
|
|
69
|
+
/**
|
|
70
|
+
* Favorittmarkering
|
|
71
|
+
*/
|
|
72
|
+
ariaLabel: string;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export type HNDesignsystemTabs = {
|
|
76
|
+
/**
|
|
77
|
+
* Scroll til høyre
|
|
78
|
+
*/
|
|
79
|
+
ariaLabelRightButton: string;
|
|
80
|
+
/**
|
|
81
|
+
* Scroll til venstre
|
|
82
|
+
*/
|
|
83
|
+
ariaLabelLeftButton: string;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export type HNDesignsystemDrawer = {
|
|
87
|
+
/**
|
|
88
|
+
* Lukk
|
|
89
|
+
*/
|
|
90
|
+
ariaLabelCloseBtn: string;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export type HNDesignsystemFormFieldTag = {
|
|
94
|
+
/**
|
|
95
|
+
* Alle felt må fylles ut
|
|
96
|
+
*/
|
|
97
|
+
allRequired: string;
|
|
98
|
+
/**
|
|
99
|
+
* Må fylles ut
|
|
100
|
+
*/
|
|
101
|
+
requiredField: string;
|
|
102
|
+
/**
|
|
103
|
+
* Valgfritt
|
|
104
|
+
*/
|
|
105
|
+
optional: string;
|
|
106
|
+
/**
|
|
107
|
+
* Alle felt er valgfrie
|
|
108
|
+
*/
|
|
109
|
+
allOptional: string;
|
|
110
|
+
/**
|
|
111
|
+
* Velg én
|
|
112
|
+
*/
|
|
113
|
+
requiredRadiobuttonList: string;
|
|
114
|
+
/**
|
|
115
|
+
* Velg én eller flere
|
|
116
|
+
*/
|
|
117
|
+
requiredCheckboxList: string;
|
|
118
|
+
/**
|
|
119
|
+
* Må velges
|
|
120
|
+
*/
|
|
121
|
+
requiredSingleCheckbox: string;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export type HNDesignsystemTextArea = {
|
|
125
|
+
/**
|
|
126
|
+
* tegn
|
|
127
|
+
*/
|
|
128
|
+
characters: string;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export type HNDesignsystemLinkList = {
|
|
132
|
+
/**
|
|
133
|
+
* Slett
|
|
134
|
+
*/
|
|
135
|
+
editMode_deleteButtonAriaLabel: string;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export type HNDesignsystemInput = {
|
|
139
|
+
/**
|
|
140
|
+
* tegn
|
|
141
|
+
*/
|
|
142
|
+
characters: string;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
/* eslint:enable */
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
// fjerner denne i vår kopi
|
|
32
|
+
// @include deprecate('The `make-container-max-widths` mixin', 'v4.5.2', 'v5');
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
@mixin make-col-ready($gutter: $grid-gutter-width) {
|
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
type PickByValue<T, V> = Pick<T, { [K in keyof T]: T[K] extends V ? K : never }[keyof T]>;
|
package/lib/useBreakpoint.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as screen, t as breakpoints } from "./grid.js";
|
|
2
|
-
import {
|
|
2
|
+
import { useSyncExternalStore } from "react";
|
|
3
3
|
let Breakpoint = /* @__PURE__ */ function(Breakpoint$1) {
|
|
4
4
|
Breakpoint$1[Breakpoint$1["xxs"] = breakpoints.xxs] = "xxs";
|
|
5
5
|
Breakpoint$1[Breakpoint$1["xs"] = breakpoints.xs] = "xs";
|
|
@@ -17,30 +17,21 @@ function getCurrentBreakpoint() {
|
|
|
17
17
|
};
|
|
18
18
|
}).find((entry) => entry.mq.matches)?.breakpoint ?? Breakpoint.xxs;
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
setBreakpoint(getCurrentBreakpoint());
|
|
30
|
-
};
|
|
31
|
-
mq.addEventListener("change", handler);
|
|
32
|
-
return {
|
|
33
|
-
mq,
|
|
34
|
-
handler
|
|
35
|
-
};
|
|
20
|
+
function subscribeToBreakpointChanges(callback) {
|
|
21
|
+
const mediaQueryList = Object.values(screen).map((mediaQuery) => {
|
|
22
|
+
const mq = window.matchMedia(mediaQuery);
|
|
23
|
+
mq.addEventListener("change", callback);
|
|
24
|
+
return mq;
|
|
25
|
+
});
|
|
26
|
+
return () => {
|
|
27
|
+
mediaQueryList.forEach((mq) => {
|
|
28
|
+
mq.removeEventListener("change", callback);
|
|
36
29
|
});
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}, []);
|
|
43
|
-
return breakpoint;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
var getServerSnapshot = () => Breakpoint.xxs;
|
|
33
|
+
const useBreakpoint = () => {
|
|
34
|
+
return useSyncExternalStore(subscribeToBreakpointChanges, getCurrentBreakpoint, getServerSnapshot);
|
|
44
35
|
};
|
|
45
36
|
export { useBreakpoint as n, Breakpoint as t };
|
|
46
37
|
|
package/lib/useBreakpoint.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBreakpoint.js","names":[],"sources":["../src/hooks/useBreakpoint.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useBreakpoint.js","names":[],"sources":["../src/hooks/useBreakpoint.ts"],"sourcesContent":["import { useSyncExternalStore } from 'react';\n\nimport { breakpoints, screen } from '../theme/grid';\n\nexport enum Breakpoint {\n xxs = breakpoints.xxs,\n xs = breakpoints.xs,\n sm = breakpoints.sm,\n md = breakpoints.md,\n lg = breakpoints.lg,\n xl = breakpoints.xl,\n}\n\n/** Sjekker nettleserens media queries fra største til minste; det høyeste treffet gjelder */\nfunction getCurrentBreakpoint(): Breakpoint {\n const mediaQueryList = Object.entries(screen)\n .reverse() // Sjekk xl, lg, md, osv. i synkende rekkefølge\n .map(([size, mediaQuery]) => {\n return {\n breakpoint: Breakpoint[size as keyof typeof Breakpoint],\n mq: window.matchMedia(mediaQuery),\n };\n });\n\n const matched = mediaQueryList.find(entry => entry.mq.matches);\n return matched?.breakpoint ?? Breakpoint.xxs;\n}\n\n/** Event listeners for media queries - dette varslet React ved endringer */\nfunction subscribeToBreakpointChanges(callback: () => void): () => void {\n const mediaQueryList = Object.values(screen).map(mediaQuery => {\n const mq = window.matchMedia(mediaQuery);\n mq.addEventListener('change', callback);\n return mq;\n });\n\n return (): void => {\n mediaQueryList.forEach(mq => {\n mq.removeEventListener('change', callback);\n });\n };\n}\n\n/** Brukes ved server side rendering der window ikke finnes. Returnerer minste breakpoint som default */\nconst getServerSnapshot = (): Breakpoint => Breakpoint.xxs;\n\nexport const useBreakpoint = (): Breakpoint => {\n return useSyncExternalStore(subscribeToBreakpointChanges, getCurrentBreakpoint, getServerSnapshot);\n};\n"],"mappings":";;AAIA,IAAY,aAAA,yBAAA,cAAL;AACL,cAAA,aAAA,SAAM,YAAY,OAAA;AAClB,cAAA,aAAA,QAAK,YAAY,MAAA;AACjB,cAAA,aAAA,QAAK,YAAY,MAAA;AACjB,cAAA,aAAA,QAAK,YAAY,MAAA;AACjB,cAAA,aAAA,QAAK,YAAY,MAAA;AACjB,cAAA,aAAA,QAAK,YAAY,MAAA;;;AAInB,SAAS,uBAAmC;AAW1C,QAVuB,OAAO,QAAQ,OAAO,CAC1C,SAAS,CACT,KAAK,CAAC,MAAM,gBAAgB;AAC3B,SAAO;GACL,YAAY,WAAW;GACvB,IAAI,OAAO,WAAW,WAAW;GAClC;GACD,CAE2B,MAAK,UAAS,MAAM,GAAG,QAAQ,EAC9C,cAAc,WAAW;;AAI3C,SAAS,6BAA6B,UAAkC;CACtE,MAAM,iBAAiB,OAAO,OAAO,OAAO,CAAC,KAAI,eAAc;EAC7D,MAAM,KAAK,OAAO,WAAW,WAAW;AACxC,KAAG,iBAAiB,UAAU,SAAS;AACvC,SAAO;GACP;AAEF,cAAmB;AACjB,iBAAe,SAAQ,OAAM;AAC3B,MAAG,oBAAoB,UAAU,SAAS;IAC1C;;;AAKN,IAAM,0BAAsC,WAAW;AAEvD,MAAa,sBAAkC;AAC7C,QAAO,qBAAqB,8BAA8B,sBAAsB,kBAAkB"}
|
package/lib/useExpand.js
CHANGED
|
@@ -2,10 +2,12 @@ import { t as usePrevious } from "./usePrevious.js";
|
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
3
|
const useExpand = (expanded, onExpand) => {
|
|
4
4
|
const [isExpanded, setIsExpanded] = useState(expanded);
|
|
5
|
+
const [prevExpanded, setPrevExpanded] = useState(expanded);
|
|
5
6
|
const previousIsExpanded = usePrevious(isExpanded);
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
if (expanded !== prevExpanded) {
|
|
8
|
+
setPrevExpanded(expanded);
|
|
9
|
+
setIsExpanded(expanded);
|
|
10
|
+
}
|
|
9
11
|
useEffect(() => {
|
|
10
12
|
if (onExpand && isExpanded !== !!previousIsExpanded) onExpand(isExpanded);
|
|
11
13
|
}, [isExpanded, onExpand]);
|
package/lib/useExpand.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useExpand.js","names":[],"sources":["../src/hooks/useExpand.ts"],"sourcesContent":["import type { Dispatch, SetStateAction } from 'react';\nimport { useEffect, useState } from 'react';\n\nimport { usePrevious } from './usePrevious';\n\nexport const useExpand = (expanded: boolean, onExpand?: (isExpanded: boolean) => void): [boolean, Dispatch<SetStateAction<boolean>>] => {\n const [isExpanded, setIsExpanded] = useState(expanded);\n const previousIsExpanded = usePrevious(isExpanded);\n\n
|
|
1
|
+
{"version":3,"file":"useExpand.js","names":[],"sources":["../src/hooks/useExpand.ts"],"sourcesContent":["import type { Dispatch, SetStateAction } from 'react';\nimport { useEffect, useState } from 'react';\n\nimport { usePrevious } from './usePrevious';\n\nexport const useExpand = (expanded: boolean, onExpand?: (isExpanded: boolean) => void): [boolean, Dispatch<SetStateAction<boolean>>] => {\n const [isExpanded, setIsExpanded] = useState(expanded);\n const [prevExpanded, setPrevExpanded] = useState(expanded);\n const previousIsExpanded = usePrevious(isExpanded);\n\n if (expanded !== prevExpanded) {\n setPrevExpanded(expanded);\n setIsExpanded(expanded);\n }\n\n useEffect(() => {\n if (onExpand && isExpanded !== !!previousIsExpanded) {\n onExpand(isExpanded);\n }\n }, [isExpanded, onExpand]);\n\n return [isExpanded, setIsExpanded];\n};\n"],"mappings":";;AAKA,MAAa,aAAa,UAAmB,aAA2F;CACtI,MAAM,CAAC,YAAY,iBAAiB,SAAS,SAAS;CACtD,MAAM,CAAC,cAAc,mBAAmB,SAAS,SAAS;CAC1D,MAAM,qBAAqB,YAAY,WAAW;AAElD,KAAI,aAAa,cAAc;AAC7B,kBAAgB,SAAS;AACzB,gBAAc,SAAS;;AAGzB,iBAAgB;AACd,MAAI,YAAY,eAAe,CAAC,CAAC,mBAC/B,UAAS,WAAW;IAErB,CAAC,YAAY,SAAS,CAAC;AAE1B,QAAO,CAAC,YAAY,cAAc"}
|
package/lib/useIsServerSide.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useSyncExternalStore } from "react";
|
|
2
|
+
var emptySubscribe = () => () => {};
|
|
3
|
+
var getClientSnapshot = () => false;
|
|
4
|
+
var getServerSnapshot = () => true;
|
|
2
5
|
const useIsServerSide = () => {
|
|
3
|
-
|
|
4
|
-
useEffect(() => {
|
|
5
|
-
setIsServerSide(false);
|
|
6
|
-
}, []);
|
|
7
|
-
return isServerSide;
|
|
6
|
+
return useSyncExternalStore(emptySubscribe, getClientSnapshot, getServerSnapshot);
|
|
8
7
|
};
|
|
9
8
|
export { useIsServerSide as t };
|
|
10
9
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIsServerSide.js","names":[],"sources":["../src/hooks/useIsServerSide.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useIsServerSide.js","names":[],"sources":["../src/hooks/useIsServerSide.ts"],"sourcesContent":["import { useSyncExternalStore } from 'react';\n\nconst emptySubscribe = (): (() => void) => (): void => {};\nconst getClientSnapshot = (): boolean => false;\nconst getServerSnapshot = (): boolean => true;\n\n/**\n * Sjekk om React kjører på server, eller ikke.\n *\n * @returns true dersom koden kjører på server\n */\nexport const useIsServerSide = (): boolean => {\n return useSyncExternalStore(emptySubscribe, getClientSnapshot, getServerSnapshot);\n};\n"],"mappings":";AAEA,IAAM,6BAAiD;AACvD,IAAM,0BAAmC;AACzC,IAAM,0BAAmC;AAOzC,MAAa,wBAAiC;AAC5C,QAAO,qBAAqB,gBAAgB,mBAAmB,kBAAkB"}
|
package/lib/useToggle.js
CHANGED
|
@@ -2,13 +2,15 @@ import { t as usePrevious } from "./usePrevious.js";
|
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
3
|
const useToggle = (initialValue, callback) => {
|
|
4
4
|
const [value, setValue] = useState(initialValue);
|
|
5
|
+
const [prevInitialValue, setPrevInitialValue] = useState(initialValue);
|
|
5
6
|
const previousValue = usePrevious(value);
|
|
7
|
+
if (initialValue !== prevInitialValue) {
|
|
8
|
+
setPrevInitialValue(initialValue);
|
|
9
|
+
setValue(initialValue);
|
|
10
|
+
}
|
|
6
11
|
const toggleValue = () => {
|
|
7
12
|
setValue(!value);
|
|
8
13
|
};
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
if (initialValue !== value) setValue(initialValue);
|
|
11
|
-
}, [initialValue]);
|
|
12
14
|
useEffect(() => {
|
|
13
15
|
if (callback && value !== !!previousValue) callback(value);
|
|
14
16
|
}, [value, callback]);
|
package/lib/useToggle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useToggle.js","names":[],"sources":["../src/hooks/useToggle.ts"],"sourcesContent":["import { useState, useEffect } from 'react';\n\nimport { usePrevious } from './usePrevious';\n\n/**\n * Hook for å toggle en boolean og kjøre en callback når verdien endres\n *\n * @param initialValue Initiell verdi for boolean\n * @param callback Funksjon som kalles når value endrer verdi (optional)\n * @returns Objekt med nåværende verdi og funksjon som kan kalles for å toggle verdien\n */\nexport const useToggle = (initialValue: boolean, callback?: (value: boolean) => void): { value: boolean; toggleValue: () => void } => {\n const [value, setValue] = useState(initialValue);\n const previousValue = usePrevious(value);\n\n
|
|
1
|
+
{"version":3,"file":"useToggle.js","names":[],"sources":["../src/hooks/useToggle.ts"],"sourcesContent":["import { useState, useEffect } from 'react';\n\nimport { usePrevious } from './usePrevious';\n\n/**\n * Hook for å toggle en boolean og kjøre en callback når verdien endres\n *\n * @param initialValue Initiell verdi for boolean\n * @param callback Funksjon som kalles når value endrer verdi (optional)\n * @returns Objekt med nåværende verdi og funksjon som kan kalles for å toggle verdien\n */\nexport const useToggle = (initialValue: boolean, callback?: (value: boolean) => void): { value: boolean; toggleValue: () => void } => {\n const [value, setValue] = useState(initialValue);\n const [prevInitialValue, setPrevInitialValue] = useState(initialValue);\n const previousValue = usePrevious(value);\n\n if (initialValue !== prevInitialValue) {\n setPrevInitialValue(initialValue);\n setValue(initialValue);\n }\n\n const toggleValue = (): void => {\n setValue(!value);\n };\n\n useEffect(() => {\n if (callback && value !== !!previousValue) {\n callback(value);\n }\n }, [value, callback]);\n\n return { value, toggleValue };\n};\n"],"mappings":";;AAWA,MAAa,aAAa,cAAuB,aAAqF;CACpI,MAAM,CAAC,OAAO,YAAY,SAAS,aAAa;CAChD,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,aAAa;CACtE,MAAM,gBAAgB,YAAY,MAAM;AAExC,KAAI,iBAAiB,kBAAkB;AACrC,sBAAoB,aAAa;AACjC,WAAS,aAAa;;CAGxB,MAAM,oBAA0B;AAC9B,WAAS,CAAC,MAAM;;AAGlB,iBAAgB;AACd,MAAI,YAAY,UAAU,CAAC,CAAC,cAC1B,UAAS,MAAM;IAEhB,CAAC,OAAO,SAAS,CAAC;AAErB,QAAO;EAAE;EAAO;EAAa"}
|
package/lib/utils2.js
CHANGED
|
@@ -3,14 +3,14 @@ import { t as isComponent } from "./component.js";
|
|
|
3
3
|
import { t as Spacer_default } from "./Spacer.js";
|
|
4
4
|
import { t as FormFieldTag_default } from "./FormFieldTag.js";
|
|
5
5
|
import { t as StatusDot_default } from "./StatusDot.js";
|
|
6
|
-
import
|
|
6
|
+
import cn from "classnames";
|
|
7
7
|
import React from "react";
|
|
8
8
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import styles from "./components/Label/styles.module.scss";
|
|
10
10
|
const Sublabel = ({ children, className, id, onColor, sublabelTexts, testId }) => {
|
|
11
11
|
const mapSublabels = (hideFromScreenReader) => {
|
|
12
12
|
return sublabelTexts && sublabelTexts.map((sublabelText, index) => {
|
|
13
|
-
const labelClasses =
|
|
13
|
+
const labelClasses = cn(styles.label, styles["sublabel"], {
|
|
14
14
|
[styles["sublabel--subdued"]]: sublabelText.type === "subdued",
|
|
15
15
|
[styles["sublabel--on-dark"]]: onColor === FormOnColor.ondark
|
|
16
16
|
});
|
|
@@ -40,13 +40,13 @@ const Sublabel = ({ children, className, id, onColor, sublabelTexts, testId }) =
|
|
|
40
40
|
};
|
|
41
41
|
var Label = ({ afterLabelChildren, children, className, formFieldTag, htmlFor, htmlMarkup = "label", labelClassName, labelTextClassName, labelId, labelTexts, onColor = FormOnColor.onwhite, statusDot, sublabel, sublabelWrapperClassName, testId, afterLabelChildrenClassName }) => {
|
|
42
42
|
const hasChildren = children && typeof children !== "undefined";
|
|
43
|
-
const labelWrapperClasses =
|
|
44
|
-
const mainLabelWrapperClasses =
|
|
45
|
-
const afterLabelChildrenClasses =
|
|
43
|
+
const labelWrapperClasses = cn(styles["label-wrapper"], { [styles["label-wrapper--no-bottom-margin"]]: hasChildren }, className);
|
|
44
|
+
const mainLabelWrapperClasses = cn({ [styles["label-wrapper--after-label-children"]]: afterLabelChildren });
|
|
45
|
+
const afterLabelChildrenClasses = cn(styles["after-label-children"], afterLabelChildrenClassName);
|
|
46
46
|
const mapLabels = () => {
|
|
47
47
|
if (typeof labelTexts === "undefined") return null;
|
|
48
48
|
return labelTexts.map((labelText, index) => {
|
|
49
|
-
const labelClasses =
|
|
49
|
+
const labelClasses = cn(styles.label, {
|
|
50
50
|
[styles["label--subdued"]]: labelText.type === "subdued",
|
|
51
51
|
[styles["label--on-dark"]]: onColor === FormOnColor.ondark
|
|
52
52
|
}, labelTextClassName);
|
|
@@ -115,7 +115,7 @@ const renderLabelAsParent = (props) => {
|
|
|
115
115
|
htmlFor: props.inputId,
|
|
116
116
|
onColor: props.onColor,
|
|
117
117
|
children: props.children,
|
|
118
|
-
labelClassName:
|
|
118
|
+
labelClassName: cn(props.labelClassName, props.label.props.labelClassName),
|
|
119
119
|
labelTextClassName: props.labelTextClassName,
|
|
120
120
|
htmlMarkup: props.markup || "label",
|
|
121
121
|
sublabelWrapperClassName: props.sublabelWrapperClassName,
|
package/lib/utils2.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils2.js","names":["Sublabel: React.FC<SublabelProps>","Label: FunctionComponent<LabelProps>"],"sources":["../src/components/Label/SubLabel.tsx","../src/components/Label/Label.tsx","../src/components/Label/utils.tsx"],"sourcesContent":["import cn from 'classnames';\n\nimport type { LabelText } from './Label';\n\nimport { AnalyticsId, FormOnColor } from '../../constants';\nimport Spacer from '../Spacer';\n\nimport styles from './styles.module.scss';\n\nexport interface SublabelProps {\n /** Sets the content of the Sublabel */\n children?: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** id that is placed on the wrapper */\n id: string;\n /** Array of sublabel strings. Can be of type semibold or normal */\n onColor?: FormOnColor;\n /** Array of sublabel strings. Can be of type semibold or normal */\n sublabelTexts?: LabelText[];\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const Sublabel: React.FC<SublabelProps> = ({ children, className, id, onColor, sublabelTexts, testId }) => {\n const mapSublabels = (hideFromScreenReader?: boolean): React.ReactNode => {\n return (\n sublabelTexts &&\n sublabelTexts.map((sublabelText, index) => {\n const labelClasses = cn(styles.label, styles['sublabel'], {\n [styles['sublabel--subdued']]: sublabelText.type === 'subdued',\n [styles['sublabel--on-dark']]: onColor === FormOnColor.ondark,\n });\n return (\n hideFromScreenReader === sublabelText.hideFromScreenReader && (\n <span className={labelClasses} key={index}>\n {sublabelText.text}\n </span>\n )\n );\n })\n );\n };\n\n const subLabels = mapSublabels();\n const ariaHiddenSublabels = mapSublabels(true);\n\n return (\n <>\n <Spacer size={'3xs'} />\n {(subLabels || children) && (\n <div className={className} id={id} data-testid={testId} data-analyticsid={AnalyticsId.Sublabel}>\n {subLabels}\n {children}\n </div>\n )}\n {ariaHiddenSublabels && (\n <div className={className} data-testid={testId}>\n {ariaHiddenSublabels}\n </div>\n )}\n </>\n );\n};\n","import type { FunctionComponent } from 'react';\nimport React from 'react';\n\nimport cn from 'classnames';\n\nimport type { SublabelProps } from './SubLabel';\nimport type { FormFieldTagProps } from '../FormFieldTag';\nimport type { StatusDotProps } from '../StatusDot';\n\nimport { Sublabel } from './SubLabel';\nimport { AnalyticsId, FormOnColor } from '../../constants';\nimport { isComponent } from '../../utils/component';\nimport FormFieldTag from '../FormFieldTag';\nimport Spacer from '../Spacer';\nimport StatusDot from '../StatusDot';\n\nimport styles from './styles.module.scss';\n\nexport type LabelText = {\n hideFromScreenReader?: boolean;\n text: string;\n type?: 'normal' | 'subdued';\n};\n\nexport type LabelTags = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'span' | 'label' | 'p' | 'legend';\n\nexport interface LabelProps {\n /** Component shown after label - discourage use of this */\n afterLabelChildren?: React.ReactNode;\n /** Sets the content of the Label */\n children?: React.ReactNode;\n /** Sets a tag that describes whether the form field is required or optional */\n formFieldTag?: React.ReactNode;\n /** Adds custom classes to the label tag. */\n labelClassName?: string;\n /** Adds custom classes to the label text. */\n labelTextClassName?: string;\n /** Adds custom classes to the element. */\n className?: string;\n /** Id that is put on the \"for\" attribute of the label */\n htmlFor?: string;\n /** Changes the underlying element of the label */\n htmlMarkup?: LabelTags;\n /** Id som plasseres på <label/> */\n labelId?: string;\n /** Array of main label strings. Can be of type semibold or normal */\n labelTexts?: LabelText[];\n /** Array of sublabel strings. Can be of type semibold or normal */\n onColor?: keyof typeof FormOnColor;\n /** StatusDot placed underneath the last sublabel */\n statusDot?: React.ReactNode;\n /** Sublabel component */\n sublabel?: React.ReactNode;\n /** Adds custom classes to the div wrapping the sublabels. */\n sublabelWrapperClassName?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Gives a custom classname to the afterLabelChildren wrapper. Used in checkbox and radiobutton */\n afterLabelChildrenClassName?: string;\n}\n\nconst Label: FunctionComponent<LabelProps> = ({\n afterLabelChildren,\n children,\n className,\n formFieldTag,\n htmlFor,\n htmlMarkup = 'label',\n labelClassName,\n labelTextClassName,\n labelId,\n labelTexts,\n onColor = FormOnColor.onwhite,\n statusDot,\n sublabel,\n sublabelWrapperClassName,\n testId,\n afterLabelChildrenClassName,\n}) => {\n const hasChildren = children && typeof children !== 'undefined';\n const labelWrapperClasses = cn(styles['label-wrapper'], { [styles['label-wrapper--no-bottom-margin']]: hasChildren }, className);\n const mainLabelWrapperClasses = cn({\n [styles['label-wrapper--after-label-children']]: afterLabelChildren,\n });\n const afterLabelChildrenClasses = cn(styles['after-label-children'], afterLabelChildrenClassName);\n\n const mapLabels = (): React.ReactNode => {\n if (typeof labelTexts === 'undefined') return null;\n\n return labelTexts.map((labelText, index) => {\n const labelClasses = cn(\n styles.label,\n {\n [styles['label--subdued']]: labelText.type === 'subdued',\n [styles['label--on-dark']]: onColor === FormOnColor.ondark,\n },\n labelTextClassName\n );\n return (\n <span aria-hidden={labelText.hideFromScreenReader} className={labelClasses} key={index}>\n {labelText.text}\n </span>\n );\n });\n };\n const CustomTag = htmlMarkup;\n\n return (\n <div className={labelWrapperClasses}>\n <div className={mainLabelWrapperClasses}>\n <CustomTag className={labelClassName} id={labelId} htmlFor={htmlFor} data-testid={testId} data-analyticsid={AnalyticsId.Label}>\n <span className={styles['label-content-wrapper']}>\n {children}\n <span className={styles.label__texts}>{mapLabels()}</span>\n </span>\n </CustomTag>\n {afterLabelChildren && <div className={afterLabelChildrenClasses}>{afterLabelChildren}</div>}\n </div>\n {(sublabel || statusDot || formFieldTag) && (\n <div className={sublabelWrapperClassName}>\n {formFieldTag && isComponent<FormFieldTagProps>(formFieldTag, FormFieldTag) && React.cloneElement(formFieldTag)}\n {sublabel &&\n isComponent<SublabelProps>(sublabel, Sublabel) &&\n React.cloneElement(sublabel, {\n onColor: onColor as FormOnColor,\n })}\n {statusDot && isComponent<StatusDotProps>(statusDot, StatusDot) && (\n <>\n <Spacer size={'3xs'} />\n {React.cloneElement(statusDot, {\n onColor: onColor === FormOnColor.ondark ? 'ondark' : 'onwhite',\n })}\n </>\n )}\n </div>\n )}\n </div>\n );\n};\n\nexport default Label;\n","import React from 'react';\n\nimport cn from 'classnames';\n\nimport type { LabelProps, LabelTags } from './Label';\nimport type { FormOnColor } from '../../constants';\n\nimport Label from './Label';\nimport { isComponent } from '../../utils/component';\n\nexport const getLabelText = (label: React.ReactNode): string => {\n let allLabelText = '';\n\n if (isComponent<LabelProps>(label, Label)) {\n label.props.labelTexts?.forEach(labelText => {\n allLabelText += !labelText.hideFromScreenReader ? labelText.text : '';\n });\n }\n\n return allLabelText;\n};\n\ninterface RenderLabelProps {\n label: React.ReactNode;\n inputId: string;\n onColor: FormOnColor;\n markup?: LabelTags;\n}\n\nexport const renderLabel = (props: RenderLabelProps): React.ReactNode => {\n return (\n <>\n {props.label && isComponent<LabelProps>(props.label, Label)\n ? React.cloneElement(props.label, {\n htmlFor: props.inputId,\n htmlMarkup: props.markup || 'label',\n onColor: props.onColor,\n })\n : typeof props.label === 'string' && (\n <Label labelTexts={[{ text: props.label, type: 'normal' }]} htmlFor={props.inputId} onColor={props.onColor} />\n )}\n </>\n );\n};\n\ninterface RenderLabelAsParentProps {\n label: React.ReactNode;\n children: React.ReactNode;\n inputId: string;\n onColor: FormOnColor;\n labelClassName?: string;\n labelTextClassName?: string;\n sublabelWrapperClassName?: string;\n large?: boolean;\n markup?: LabelTags;\n afterLabelChildrenClassName?: string;\n}\n\nexport const renderLabelAsParent = (props: RenderLabelAsParentProps): React.ReactNode => {\n return (\n <>\n {props.label && isComponent<LabelProps>(props.label, Label)\n ? React.cloneElement(props.label, {\n htmlFor: props.inputId,\n onColor: props.onColor,\n children: props.children,\n labelClassName: cn(props.labelClassName, props.label.props.labelClassName),\n labelTextClassName: props.labelTextClassName,\n htmlMarkup: props.markup || 'label',\n sublabelWrapperClassName: props.sublabelWrapperClassName,\n sublabel: props.large ? undefined : props.label.props.sublabel,\n statusDot: props.large ? undefined : props.label.props.statusDot,\n afterLabelChildrenClassName: props.afterLabelChildrenClassName,\n })\n : typeof props.label === 'string' && (\n <Label\n labelTexts={[{ text: props.label, type: 'subdued' }]}\n htmlFor={props.inputId}\n onColor={props.onColor}\n htmlMarkup={props.markup || 'label'}\n labelClassName={props.labelClassName}\n labelTextClassName={props.labelTextClassName}\n sublabelWrapperClassName={props.sublabelWrapperClassName}\n afterLabelChildrenClassName={props.afterLabelChildrenClassName}\n >\n {props.children}\n </Label>\n )}\n </>\n );\n};\n"],"mappings":";;;;;;;;;AAwBA,MAAaA,YAAqC,EAAE,UAAU,WAAW,IAAI,SAAS,e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O,MAAM;GAAU,CAAC;EAAE,SAAS,MAAM;EAAS,SAAS,MAAM;GAAW,EAAA,CAEnH;;AAiBP,MAAa,uBAAuB,UAAqD;AACvF,QACE,oBAAA,UAAA,EAAA,UACG,MAAM,SAAS,YAAwB,MAAM,OAAO,cAAM,GACvD,MAAM,aAAa,MAAM,OAAO;EAC9B,SAAS,MAAM;EACf,SAAS,MAAM;EACf,UAAU,MAAM;EAChB,gBAAgB,WAAG,MAAM,gBAAgB,MAAM,MAAM,MAAM,eAAe;EAC1E,oBAAoB,MAAM;EAC1B,YAAY,MAAM,UAAU;EAC5B,0BAA0B,MAAM;EAChC,UAAU,MAAM,QAAQ,KAAA,IAAY,MAAM,MAAM,MAAM;EACtD,WAAW,MAAM,QAAQ,KAAA,IAAY,MAAM,MAAM,MAAM;EACvD,6BAA6B,MAAM;EACpC,CAAC,GACF,OAAO,MAAM,UAAU,YACrB,oBAAC,eAAA;EACC,YAAY,CAAC;GAAE,MAAM,MAAM;GAAO,MAAM;GAAW,CAAC;EACpD,SAAS,MAAM;EACf,SAAS,MAAM;EACf,YAAY,MAAM,UAAU;EAC5B,gBAAgB,MAAM;EACtB,oBAAoB,MAAM;EAC1B,0BAA0B,MAAM;EAChC,6BAA6B,MAAM;YAElC,MAAM;GACD,EAAA,CAEb"}
|
|
1
|
+
{"version":3,"file":"utils2.js","names":["Sublabel: React.FC<SublabelProps>","Label: FunctionComponent<LabelProps>"],"sources":["../src/components/Label/SubLabel.tsx","../src/components/Label/Label.tsx","../src/components/Label/utils.tsx"],"sourcesContent":["import cn from 'classnames';\n\nimport type { LabelText } from './Label';\n\nimport { AnalyticsId, FormOnColor } from '../../constants';\nimport Spacer from '../Spacer';\n\nimport styles from './styles.module.scss';\n\nexport interface SublabelProps {\n /** Sets the content of the Sublabel */\n children?: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** id that is placed on the wrapper */\n id: string;\n /** Array of sublabel strings. Can be of type semibold or normal */\n onColor?: FormOnColor;\n /** Array of sublabel strings. Can be of type semibold or normal */\n sublabelTexts?: LabelText[];\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const Sublabel: React.FC<SublabelProps> = ({ children, className, id, onColor, sublabelTexts, testId }) => {\n const mapSublabels = (hideFromScreenReader?: boolean): React.ReactNode => {\n return (\n sublabelTexts &&\n sublabelTexts.map((sublabelText, index) => {\n const labelClasses = cn(styles.label, styles['sublabel'], {\n [styles['sublabel--subdued']]: sublabelText.type === 'subdued',\n [styles['sublabel--on-dark']]: onColor === FormOnColor.ondark,\n });\n return (\n hideFromScreenReader === sublabelText.hideFromScreenReader && (\n <span className={labelClasses} key={index}>\n {sublabelText.text}\n </span>\n )\n );\n })\n );\n };\n\n const subLabels = mapSublabels();\n const ariaHiddenSublabels = mapSublabels(true);\n\n return (\n <>\n <Spacer size={'3xs'} />\n {(subLabels || children) && (\n <div className={className} id={id} data-testid={testId} data-analyticsid={AnalyticsId.Sublabel}>\n {subLabels}\n {children}\n </div>\n )}\n {ariaHiddenSublabels && (\n <div className={className} data-testid={testId}>\n {ariaHiddenSublabels}\n </div>\n )}\n </>\n );\n};\n","import type { FunctionComponent } from 'react';\nimport React from 'react';\n\nimport cn from 'classnames';\n\nimport type { SublabelProps } from './SubLabel';\nimport type { FormFieldTagProps } from '../FormFieldTag';\nimport type { StatusDotProps } from '../StatusDot';\n\nimport { Sublabel } from './SubLabel';\nimport { AnalyticsId, FormOnColor } from '../../constants';\nimport { isComponent } from '../../utils/component';\nimport FormFieldTag from '../FormFieldTag';\nimport Spacer from '../Spacer';\nimport StatusDot from '../StatusDot';\n\nimport styles from './styles.module.scss';\n\nexport type LabelText = {\n hideFromScreenReader?: boolean;\n text: string;\n type?: 'normal' | 'subdued';\n};\n\nexport type LabelTags = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'span' | 'label' | 'p' | 'legend';\n\nexport interface LabelProps {\n /** Component shown after label - discourage use of this */\n afterLabelChildren?: React.ReactNode;\n /** Sets the content of the Label */\n children?: React.ReactNode;\n /** Sets a tag that describes whether the form field is required or optional */\n formFieldTag?: React.ReactNode;\n /** Adds custom classes to the label tag. */\n labelClassName?: string;\n /** Adds custom classes to the label text. */\n labelTextClassName?: string;\n /** Adds custom classes to the element. */\n className?: string;\n /** Id that is put on the \"for\" attribute of the label */\n htmlFor?: string;\n /** Changes the underlying element of the label */\n htmlMarkup?: LabelTags;\n /** Id som plasseres på <label/> */\n labelId?: string;\n /** Array of main label strings. Can be of type semibold or normal */\n labelTexts?: LabelText[];\n /** Array of sublabel strings. Can be of type semibold or normal */\n onColor?: keyof typeof FormOnColor;\n /** StatusDot placed underneath the last sublabel */\n statusDot?: React.ReactNode;\n /** Sublabel component */\n sublabel?: React.ReactNode;\n /** Adds custom classes to the div wrapping the sublabels. */\n sublabelWrapperClassName?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Gives a custom classname to the afterLabelChildren wrapper. Used in checkbox and radiobutton */\n afterLabelChildrenClassName?: string;\n}\n\nconst Label: FunctionComponent<LabelProps> = ({\n afterLabelChildren,\n children,\n className,\n formFieldTag,\n htmlFor,\n htmlMarkup = 'label',\n labelClassName,\n labelTextClassName,\n labelId,\n labelTexts,\n onColor = FormOnColor.onwhite,\n statusDot,\n sublabel,\n sublabelWrapperClassName,\n testId,\n afterLabelChildrenClassName,\n}) => {\n const hasChildren = children && typeof children !== 'undefined';\n const labelWrapperClasses = cn(styles['label-wrapper'], { [styles['label-wrapper--no-bottom-margin']]: hasChildren }, className);\n const mainLabelWrapperClasses = cn({\n [styles['label-wrapper--after-label-children']]: afterLabelChildren,\n });\n const afterLabelChildrenClasses = cn(styles['after-label-children'], afterLabelChildrenClassName);\n\n const mapLabels = (): React.ReactNode => {\n if (typeof labelTexts === 'undefined') return null;\n\n return labelTexts.map((labelText, index) => {\n const labelClasses = cn(\n styles.label,\n {\n [styles['label--subdued']]: labelText.type === 'subdued',\n [styles['label--on-dark']]: onColor === FormOnColor.ondark,\n },\n labelTextClassName\n );\n return (\n <span aria-hidden={labelText.hideFromScreenReader} className={labelClasses} key={index}>\n {labelText.text}\n </span>\n );\n });\n };\n const CustomTag = htmlMarkup;\n\n return (\n <div className={labelWrapperClasses}>\n <div className={mainLabelWrapperClasses}>\n <CustomTag className={labelClassName} id={labelId} htmlFor={htmlFor} data-testid={testId} data-analyticsid={AnalyticsId.Label}>\n <span className={styles['label-content-wrapper']}>\n {children}\n <span className={styles.label__texts}>{mapLabels()}</span>\n </span>\n </CustomTag>\n {afterLabelChildren && <div className={afterLabelChildrenClasses}>{afterLabelChildren}</div>}\n </div>\n {(sublabel || statusDot || formFieldTag) && (\n <div className={sublabelWrapperClassName}>\n {formFieldTag && isComponent<FormFieldTagProps>(formFieldTag, FormFieldTag) && React.cloneElement(formFieldTag)}\n {sublabel &&\n isComponent<SublabelProps>(sublabel, Sublabel) &&\n React.cloneElement(sublabel, {\n onColor: onColor as FormOnColor,\n })}\n {statusDot && isComponent<StatusDotProps>(statusDot, StatusDot) && (\n <>\n <Spacer size={'3xs'} />\n {React.cloneElement(statusDot, {\n onColor: onColor === FormOnColor.ondark ? 'ondark' : 'onwhite',\n })}\n </>\n )}\n </div>\n )}\n </div>\n );\n};\n\nexport default Label;\n","import React from 'react';\n\nimport cn from 'classnames';\n\nimport type { LabelProps, LabelTags } from './Label';\nimport type { FormOnColor } from '../../constants';\n\nimport Label from './Label';\nimport { isComponent } from '../../utils/component';\n\nexport const getLabelText = (label: React.ReactNode): string => {\n let allLabelText = '';\n\n if (isComponent<LabelProps>(label, Label)) {\n label.props.labelTexts?.forEach(labelText => {\n allLabelText += !labelText.hideFromScreenReader ? labelText.text : '';\n });\n }\n\n return allLabelText;\n};\n\ninterface RenderLabelProps {\n label: React.ReactNode;\n inputId: string;\n onColor: FormOnColor;\n markup?: LabelTags;\n}\n\nexport const renderLabel = (props: RenderLabelProps): React.ReactNode => {\n return (\n <>\n {props.label && isComponent<LabelProps>(props.label, Label)\n ? React.cloneElement(props.label, {\n htmlFor: props.inputId,\n htmlMarkup: props.markup || 'label',\n onColor: props.onColor,\n })\n : typeof props.label === 'string' && (\n <Label labelTexts={[{ text: props.label, type: 'normal' }]} htmlFor={props.inputId} onColor={props.onColor} />\n )}\n </>\n );\n};\n\ninterface RenderLabelAsParentProps {\n label: React.ReactNode;\n children: React.ReactNode;\n inputId: string;\n onColor: FormOnColor;\n labelClassName?: string;\n labelTextClassName?: string;\n sublabelWrapperClassName?: string;\n large?: boolean;\n markup?: LabelTags;\n afterLabelChildrenClassName?: string;\n}\n\nexport const renderLabelAsParent = (props: RenderLabelAsParentProps): React.ReactNode => {\n return (\n <>\n {props.label && isComponent<LabelProps>(props.label, Label)\n ? React.cloneElement(props.label, {\n htmlFor: props.inputId,\n onColor: props.onColor,\n children: props.children,\n labelClassName: cn(props.labelClassName, props.label.props.labelClassName),\n labelTextClassName: props.labelTextClassName,\n htmlMarkup: props.markup || 'label',\n sublabelWrapperClassName: props.sublabelWrapperClassName,\n sublabel: props.large ? undefined : props.label.props.sublabel,\n statusDot: props.large ? undefined : props.label.props.statusDot,\n afterLabelChildrenClassName: props.afterLabelChildrenClassName,\n })\n : typeof props.label === 'string' && (\n <Label\n labelTexts={[{ text: props.label, type: 'subdued' }]}\n htmlFor={props.inputId}\n onColor={props.onColor}\n htmlMarkup={props.markup || 'label'}\n labelClassName={props.labelClassName}\n labelTextClassName={props.labelTextClassName}\n sublabelWrapperClassName={props.sublabelWrapperClassName}\n afterLabelChildrenClassName={props.afterLabelChildrenClassName}\n >\n {props.children}\n </Label>\n )}\n </>\n );\n};\n"],"mappings":";;;;;;;;;AAwBA,MAAaA,YAAqC,EAAE,UAAU,WAAW,IAAI,SAAS,eAAe,aAAa;CAChH,MAAM,gBAAgB,yBAAoD;AACxE,SACE,iBACA,cAAc,KAAK,cAAc,UAAU;GACzC,MAAM,eAAe,GAAG,OAAO,OAAO,OAAO,aAAa;KACvD,OAAO,uBAAuB,aAAa,SAAS;KACpD,OAAO,uBAAuB,YAAY,YAAY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Aa,MAAM,OAAO;EAC9B,SAAS,MAAM;EACf,SAAS,MAAM;EACf,UAAU,MAAM;EAChB,gBAAgB,GAAG,MAAM,gBAAgB,MAAM,MAAM,MAAM,eAAe;EAC1E,oBAAoB,MAAM;EAC1B,YAAY,MAAM,UAAU;EAC5B,0BAA0B,MAAM;EAChC,UAAU,MAAM,QAAQ,KAAA,IAAY,MAAM,MAAM,MAAM;EACtD,WAAW,MAAM,QAAQ,KAAA,IAAY,MAAM,MAAM,MAAM;EACvD,6BAA6B,MAAM;EACpC,CAAC,GACF,OAAO,MAAM,UAAU,YACrB,oBAAC,eAAA;EACC,YAAY,CAAC;GAAE,MAAM,MAAM;GAAO,MAAM;GAAW,CAAC;EACpD,SAAS,MAAM;EACf,SAAS,MAAM;EACf,YAAY,MAAM,UAAU;EAC5B,gBAAgB,MAAM;EACtB,oBAAoB,MAAM;EAC1B,0BAA0B,MAAM;EAChC,6BAA6B,MAAM;YAElC,MAAM;GACD,EAAA,CAEb"}
|
package/lib/utils3.js
CHANGED
|
@@ -6,7 +6,7 @@ import { t as useIdWithFallback } from "./useIdWithFallback.js";
|
|
|
6
6
|
import { t as getAriaDescribedBy } from "./accessibility.js";
|
|
7
7
|
import { t as ErrorWrapper_default } from "./ErrorWrapper.js";
|
|
8
8
|
import { r as renderLabelAsParent, t as getLabelText } from "./utils2.js";
|
|
9
|
-
import
|
|
9
|
+
import cn from "classnames";
|
|
10
10
|
import { useState } from "react";
|
|
11
11
|
import { jsx } from "react/jsx-runtime";
|
|
12
12
|
import radioButtonStyles from "./components/RadioButton/styles.module.scss";
|
|
@@ -21,14 +21,14 @@ const RadioButton = (props) => {
|
|
|
21
21
|
const { refObject, isFocused } = usePseudoClasses(isMutableRefObject(ref) ? ref : null);
|
|
22
22
|
const mergedRefs = mergeRefs([ref, refObject]);
|
|
23
23
|
const errorTextId = useIdWithFallback(errorTextIdProp);
|
|
24
|
-
const radioButtonWrapperClasses =
|
|
24
|
+
const radioButtonWrapperClasses = cn(radioButtonStyles["radio-button-wrapper"], {
|
|
25
25
|
[radioButtonStyles["radio-button-wrapper__large"]]: isLarge,
|
|
26
26
|
[radioButtonStyles["radio-button-wrapper__large--focused"]]: isLarge && isFocused,
|
|
27
27
|
[radioButtonStyles["radio-button-wrapper__large--selected"]]: isLarge && checked && isFocused,
|
|
28
28
|
[radioButtonStyles["radio-button-wrapper__large--invalid"]]: isLarge && onCherry && isFocused,
|
|
29
29
|
[radioButtonStyles["radio-button-wrapper__large--on-blueberry"]]: isLarge && onBlueberry && isFocused
|
|
30
30
|
});
|
|
31
|
-
const radioButtonLabelClasses =
|
|
31
|
+
const radioButtonLabelClasses = cn(radioButtonStyles["radio-button-label"], {
|
|
32
32
|
[radioButtonStyles["radio-button-label--disabled"]]: disabled,
|
|
33
33
|
[radioButtonStyles["radio-button-label--on-dark"]]: onDark,
|
|
34
34
|
[radioButtonStyles["radio-button-label--invalid"]]: invalid,
|
|
@@ -36,7 +36,7 @@ const RadioButton = (props) => {
|
|
|
36
36
|
[radioButtonStyles["radio-button-label__large--focused"]]: isFocused && isLarge,
|
|
37
37
|
[radioButtonStyles["radio-button-label__large--disabled"]]: isLarge && disabled
|
|
38
38
|
}, labelClassNames);
|
|
39
|
-
const radioButtonClasses =
|
|
39
|
+
const radioButtonClasses = cn(radioButtonStyles["radio-button"], {
|
|
40
40
|
[radioButtonStyles["radio-button--on-dark"]]: onDark,
|
|
41
41
|
[radioButtonStyles["radio-button--disabled"]]: disabled,
|
|
42
42
|
[radioButtonStyles["radio-button--on-blueberry"]]: onBlueberry,
|
|
@@ -89,7 +89,7 @@ var RadioButton_default = RadioButton;
|
|
|
89
89
|
const getRadioLabelClasses = (radioId, onColor, large, checkedRadioId) => {
|
|
90
90
|
const onCherry = onColor === "oninvalid";
|
|
91
91
|
const checked = radioId === checkedRadioId;
|
|
92
|
-
return
|
|
92
|
+
return cn({
|
|
93
93
|
[radioButtonStyles["radio-button-label__large--on-grey"]]: large && onColor === "ongrey" && !checked,
|
|
94
94
|
[radioButtonStyles["radio-button-label__large--on-blueberry"]]: onColor === "onblueberry" && !checked && large,
|
|
95
95
|
[radioButtonStyles["radio-button-label__large--selected"]]: large && checked && !onCherry,
|
package/lib/utils3.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils3.js","names":["RadioButton: React.FC<RadioButtonProps>"],"sources":["../src/components/RadioButton/RadioButton.tsx","../src/components/RadioButton/utils.ts"],"sourcesContent":["import { useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport type { ErrorWrapperClassNameProps } from '../ErrorWrapper';\n\nimport { AnalyticsId, FormOnColor, FormSize } from '../../constants';\nimport { useIdWithFallback } from '../../hooks/useIdWithFallback';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { getAriaDescribedBy } from '../../utils/accessibility';\nimport { isMutableRefObject, mergeRefs } from '../../utils/refs';\nimport { uuid } from '../../utils/uuid';\nimport ErrorWrapper from '../ErrorWrapper';\nimport { getLabelText, renderLabelAsParent } from '../Label/utils';\n\nimport radioButtonStyles from './styles.module.scss';\n\nexport interface RadioButtonProps\n extends\n ErrorWrapperClassNameProps,\n Pick<\n React.InputHTMLAttributes<HTMLInputElement>,\n 'aria-describedby' | 'name' | 'value' | 'disabled' | 'checked' | 'defaultChecked' | 'required' | 'onChange'\n > {\n /** Adds custom classes to the element. */\n className?: string;\n /** The <Label/> next to the radioButton - sublabels kan ikke kombineres med large variant */\n label: React.ReactNode;\n /** Adds custom classes to the label element. */\n labelClassNames?: string;\n /** input id of the radioButton */\n inputId?: string;\n /** Changes the visuals of the radioButton */\n onColor?: keyof typeof FormOnColor;\n /** Changes the visuals of the radioButton. Large version only works when used inside a FormGroup wrapper. */\n size?: keyof typeof FormSize;\n /** Activates Error style for the radioButton - This is can be true while errorText is empty, when in a FormGroup */\n error?: boolean;\n /** Error text to show above the component */\n errorText?: string;\n /** Error text id */\n errorTextId?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Ref passed to the input element */\n ref?: React.Ref<HTMLInputElement | null>;\n}\n\nexport const RadioButton: React.FC<RadioButtonProps> = props => {\n const {\n className,\n defaultChecked,\n onChange,\n disabled,\n label,\n inputId = uuid(),\n onColor = FormOnColor.onwhite,\n name = inputId,\n size,\n errorText,\n errorTextId: errorTextIdProp,\n error = !!errorText,\n errorWrapperClassName,\n value = getLabelText(label),\n testId,\n required,\n labelClassNames,\n ref,\n ...rest\n } = props;\n const invalid = error || onColor === FormOnColor.oninvalid;\n const onDark = onColor === FormOnColor.ondark;\n const onBlueberry = onColor === FormOnColor.onblueberry;\n const onCherry = onColor === FormOnColor.oninvalid;\n const isLarge = size === FormSize.large;\n const [checked, changeChecked] = useState<boolean>();\n const { refObject, isFocused } = usePseudoClasses<HTMLInputElement>(isMutableRefObject(ref) ? ref : null);\n const mergedRefs = mergeRefs([ref, refObject]);\n const errorTextId = useIdWithFallback(errorTextIdProp);\n\n const radioButtonWrapperClasses = classNames(radioButtonStyles['radio-button-wrapper'], {\n [radioButtonStyles['radio-button-wrapper__large']]: isLarge,\n [radioButtonStyles['radio-button-wrapper__large--focused']]: isLarge && isFocused,\n [radioButtonStyles['radio-button-wrapper__large--selected']]: isLarge && checked && isFocused,\n [radioButtonStyles['radio-button-wrapper__large--invalid']]: isLarge && onCherry && isFocused,\n [radioButtonStyles['radio-button-wrapper__large--on-blueberry']]: isLarge && onBlueberry && isFocused,\n });\n const radioButtonLabelClasses = classNames(\n radioButtonStyles['radio-button-label'],\n {\n [radioButtonStyles['radio-button-label--disabled']]: disabled,\n [radioButtonStyles['radio-button-label--on-dark']]: onDark,\n [radioButtonStyles['radio-button-label--invalid']]: invalid,\n [radioButtonStyles['radio-button-label__large']]: isLarge,\n [radioButtonStyles['radio-button-label__large--focused']]: isFocused && isLarge,\n [radioButtonStyles['radio-button-label__large--disabled']]: isLarge && disabled,\n },\n labelClassNames\n );\n const radioButtonClasses = classNames(\n radioButtonStyles['radio-button'],\n {\n [radioButtonStyles['radio-button--on-dark']]: onDark,\n [radioButtonStyles['radio-button--disabled']]: disabled,\n [radioButtonStyles['radio-button--on-blueberry']]: onBlueberry,\n [radioButtonStyles['radio-button--invalid']]: invalid,\n [radioButtonStyles['radio-button__large']]: isLarge,\n [radioButtonStyles['radio-button__large--disabled']]: isLarge && disabled,\n [radioButtonStyles['radio-button__large--invalid']]: isLarge && invalid,\n },\n className\n );\n\n const change = (e: React.ChangeEvent<HTMLInputElement>): void => {\n changeChecked(e.target.checked);\n if (onChange) onChange(e);\n };\n\n const getLabelContent = (): React.ReactNode => (\n <input\n {...rest}\n id={inputId}\n name={name}\n className={radioButtonClasses}\n type=\"radio\"\n disabled={disabled}\n value={value}\n ref={mergedRefs}\n defaultChecked={defaultChecked}\n aria-describedby={getAriaDescribedBy(props, errorTextId)}\n required={required}\n onChange={(e): void => change(e)}\n />\n );\n\n return (\n <ErrorWrapper className={errorWrapperClassName} errorText={errorText} errorTextId={errorTextId}>\n <div data-testid={testId} data-analyticsid={AnalyticsId.RadioButton} className={radioButtonWrapperClasses}>\n {renderLabelAsParent({\n label: label,\n children: getLabelContent(),\n inputId: inputId,\n onColor: onColor as FormOnColor,\n labelClassName: radioButtonLabelClasses,\n sublabelWrapperClassName: radioButtonStyles['radiobutton-sublabel-wrapper'],\n large: isLarge,\n afterLabelChildrenClassName: radioButtonStyles['radiobutton-afterlabelchildren-wrapper'],\n })}\n </div>\n </ErrorWrapper>\n );\n};\n\nRadioButton.displayName = 'RadioButton';\n\nexport default RadioButton;\n","import classNames from 'classnames';\n\nimport type { FormOnColor } from '../../constants';\n\nimport radioButtonStyles from './styles.module.scss';\n\nexport const getRadioLabelClasses = (\n radioId: string,\n onColor: FormOnColor,\n large: boolean,\n checkedRadioId?: string\n): string | undefined => {\n const onCherry = onColor === 'oninvalid';\n const checked = radioId === checkedRadioId;\n\n return classNames({\n [radioButtonStyles['radio-button-label__large--on-grey']]: large && onColor === 'ongrey' && !checked,\n [radioButtonStyles['radio-button-label__large--on-blueberry']]: onColor === 'onblueberry' && !checked && large,\n [radioButtonStyles['radio-button-label__large--selected']]: large && checked && !onCherry,\n [radioButtonStyles['radio-button-label__large--selected-invalid']]: large && checked && onCherry,\n });\n};\n"],"mappings":";;;;;;;;;;;;AAgDA,MAAaA,eAA0C,UAAS;CAC9D,MAAM,EACJ,WACA,gBACA,UACA,UACA,OACA,UAAU,MAAM,EAChB,UAAU,YAAY,SACtB,OAAO,SACP,MACA,WACA,aAAa,iBACb,QAAQ,CAAC,CAAC,WACV,uBACA,QAAQ,aAAa,MAAM,EAC3B,QACA,UACA,iBACA,KACA,GAAG,SACD;CACJ,MAAM,UAAU,SAAS,YAAY,YAAY;CACjD,MAAM,SAAS,YAAY,YAAY;CACvC,MAAM,cAAc,YAAY,YAAY;CAC5C,MAAM,WAAW,YAAY,YAAY;CACzC,MAAM,UAAU,SAAS,SAAS;CAClC,MAAM,CAAC,SAAS,iBAAiB,UAAmB;CACpD,MAAM,EAAE,WAAW,cAAc,iBAAmC,mBAAmB,IAAI,GAAG,MAAM,KAAK;CACzG,MAAM,aAAa,UAAU,CAAC,KAAK,UAAU,CAAC;CAC9C,MAAM,cAAc,kBAAkB,gBAAgB;CAEtD,MAAM,4BAA4B,
|
|
1
|
+
{"version":3,"file":"utils3.js","names":["RadioButton: React.FC<RadioButtonProps>"],"sources":["../src/components/RadioButton/RadioButton.tsx","../src/components/RadioButton/utils.ts"],"sourcesContent":["import { useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport type { ErrorWrapperClassNameProps } from '../ErrorWrapper';\n\nimport { AnalyticsId, FormOnColor, FormSize } from '../../constants';\nimport { useIdWithFallback } from '../../hooks/useIdWithFallback';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { getAriaDescribedBy } from '../../utils/accessibility';\nimport { isMutableRefObject, mergeRefs } from '../../utils/refs';\nimport { uuid } from '../../utils/uuid';\nimport ErrorWrapper from '../ErrorWrapper';\nimport { getLabelText, renderLabelAsParent } from '../Label/utils';\n\nimport radioButtonStyles from './styles.module.scss';\n\nexport interface RadioButtonProps\n extends\n ErrorWrapperClassNameProps,\n Pick<\n React.InputHTMLAttributes<HTMLInputElement>,\n 'aria-describedby' | 'name' | 'value' | 'disabled' | 'checked' | 'defaultChecked' | 'required' | 'onChange'\n > {\n /** Adds custom classes to the element. */\n className?: string;\n /** The <Label/> next to the radioButton - sublabels kan ikke kombineres med large variant */\n label: React.ReactNode;\n /** Adds custom classes to the label element. */\n labelClassNames?: string;\n /** input id of the radioButton */\n inputId?: string;\n /** Changes the visuals of the radioButton */\n onColor?: keyof typeof FormOnColor;\n /** Changes the visuals of the radioButton. Large version only works when used inside a FormGroup wrapper. */\n size?: keyof typeof FormSize;\n /** Activates Error style for the radioButton - This is can be true while errorText is empty, when in a FormGroup */\n error?: boolean;\n /** Error text to show above the component */\n errorText?: string;\n /** Error text id */\n errorTextId?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Ref passed to the input element */\n ref?: React.Ref<HTMLInputElement | null>;\n}\n\nexport const RadioButton: React.FC<RadioButtonProps> = props => {\n const {\n className,\n defaultChecked,\n onChange,\n disabled,\n label,\n inputId = uuid(),\n onColor = FormOnColor.onwhite,\n name = inputId,\n size,\n errorText,\n errorTextId: errorTextIdProp,\n error = !!errorText,\n errorWrapperClassName,\n value = getLabelText(label),\n testId,\n required,\n labelClassNames,\n ref,\n ...rest\n } = props;\n const invalid = error || onColor === FormOnColor.oninvalid;\n const onDark = onColor === FormOnColor.ondark;\n const onBlueberry = onColor === FormOnColor.onblueberry;\n const onCherry = onColor === FormOnColor.oninvalid;\n const isLarge = size === FormSize.large;\n const [checked, changeChecked] = useState<boolean>();\n const { refObject, isFocused } = usePseudoClasses<HTMLInputElement>(isMutableRefObject(ref) ? ref : null);\n const mergedRefs = mergeRefs([ref, refObject]);\n const errorTextId = useIdWithFallback(errorTextIdProp);\n\n const radioButtonWrapperClasses = classNames(radioButtonStyles['radio-button-wrapper'], {\n [radioButtonStyles['radio-button-wrapper__large']]: isLarge,\n [radioButtonStyles['radio-button-wrapper__large--focused']]: isLarge && isFocused,\n [radioButtonStyles['radio-button-wrapper__large--selected']]: isLarge && checked && isFocused,\n [radioButtonStyles['radio-button-wrapper__large--invalid']]: isLarge && onCherry && isFocused,\n [radioButtonStyles['radio-button-wrapper__large--on-blueberry']]: isLarge && onBlueberry && isFocused,\n });\n const radioButtonLabelClasses = classNames(\n radioButtonStyles['radio-button-label'],\n {\n [radioButtonStyles['radio-button-label--disabled']]: disabled,\n [radioButtonStyles['radio-button-label--on-dark']]: onDark,\n [radioButtonStyles['radio-button-label--invalid']]: invalid,\n [radioButtonStyles['radio-button-label__large']]: isLarge,\n [radioButtonStyles['radio-button-label__large--focused']]: isFocused && isLarge,\n [radioButtonStyles['radio-button-label__large--disabled']]: isLarge && disabled,\n },\n labelClassNames\n );\n const radioButtonClasses = classNames(\n radioButtonStyles['radio-button'],\n {\n [radioButtonStyles['radio-button--on-dark']]: onDark,\n [radioButtonStyles['radio-button--disabled']]: disabled,\n [radioButtonStyles['radio-button--on-blueberry']]: onBlueberry,\n [radioButtonStyles['radio-button--invalid']]: invalid,\n [radioButtonStyles['radio-button__large']]: isLarge,\n [radioButtonStyles['radio-button__large--disabled']]: isLarge && disabled,\n [radioButtonStyles['radio-button__large--invalid']]: isLarge && invalid,\n },\n className\n );\n\n const change = (e: React.ChangeEvent<HTMLInputElement>): void => {\n changeChecked(e.target.checked);\n if (onChange) onChange(e);\n };\n\n const getLabelContent = (): React.ReactNode => (\n <input\n {...rest}\n id={inputId}\n name={name}\n className={radioButtonClasses}\n type=\"radio\"\n disabled={disabled}\n value={value}\n ref={mergedRefs}\n defaultChecked={defaultChecked}\n aria-describedby={getAriaDescribedBy(props, errorTextId)}\n required={required}\n onChange={(e): void => change(e)}\n />\n );\n\n return (\n <ErrorWrapper className={errorWrapperClassName} errorText={errorText} errorTextId={errorTextId}>\n <div data-testid={testId} data-analyticsid={AnalyticsId.RadioButton} className={radioButtonWrapperClasses}>\n {renderLabelAsParent({\n label: label,\n children: getLabelContent(),\n inputId: inputId,\n onColor: onColor as FormOnColor,\n labelClassName: radioButtonLabelClasses,\n sublabelWrapperClassName: radioButtonStyles['radiobutton-sublabel-wrapper'],\n large: isLarge,\n afterLabelChildrenClassName: radioButtonStyles['radiobutton-afterlabelchildren-wrapper'],\n })}\n </div>\n </ErrorWrapper>\n );\n};\n\nRadioButton.displayName = 'RadioButton';\n\nexport default RadioButton;\n","import classNames from 'classnames';\n\nimport type { FormOnColor } from '../../constants';\n\nimport radioButtonStyles from './styles.module.scss';\n\nexport const getRadioLabelClasses = (\n radioId: string,\n onColor: FormOnColor,\n large: boolean,\n checkedRadioId?: string\n): string | undefined => {\n const onCherry = onColor === 'oninvalid';\n const checked = radioId === checkedRadioId;\n\n return classNames({\n [radioButtonStyles['radio-button-label__large--on-grey']]: large && onColor === 'ongrey' && !checked,\n [radioButtonStyles['radio-button-label__large--on-blueberry']]: onColor === 'onblueberry' && !checked && large,\n [radioButtonStyles['radio-button-label__large--selected']]: large && checked && !onCherry,\n [radioButtonStyles['radio-button-label__large--selected-invalid']]: large && checked && onCherry,\n });\n};\n"],"mappings":";;;;;;;;;;;;AAgDA,MAAaA,eAA0C,UAAS;CAC9D,MAAM,EACJ,WACA,gBACA,UACA,UACA,OACA,UAAU,MAAM,EAChB,UAAU,YAAY,SACtB,OAAO,SACP,MACA,WACA,aAAa,iBACb,QAAQ,CAAC,CAAC,WACV,uBACA,QAAQ,aAAa,MAAM,EAC3B,QACA,UACA,iBACA,KACA,GAAG,SACD;CACJ,MAAM,UAAU,SAAS,YAAY,YAAY;CACjD,MAAM,SAAS,YAAY,YAAY;CACvC,MAAM,cAAc,YAAY,YAAY;CAC5C,MAAM,WAAW,YAAY,YAAY;CACzC,MAAM,UAAU,SAAS,SAAS;CAClC,MAAM,CAAC,SAAS,iBAAiB,UAAmB;CACpD,MAAM,EAAE,WAAW,cAAc,iBAAmC,mBAAmB,IAAI,GAAG,MAAM,KAAK;CACzG,MA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A6B,kBAAkB;IAChD,CAAC;IACE;GACO;;AAInB,YAAY,cAAc;AAE1B,IAAA,sBAAe;ACrJf,MAAa,wBACX,SACA,SACA,OACA,mBACuB;CACvB,MAAM,WAAW,YAAY;CAC7B,MAAM,UAAU,YAAY;AAE5B,QAAO,GAAW;GACf,kBAAkB,wCAAwC,SAAS,YAAY,YAAY,CAAC;GAC5F,kBAAkB,6CAA6C,YAAY,iBAAiB,CAAC,WAAW;GACxG,kBAAkB,yCAAyC,SAAS,WAAW,CAAC;GAChF,kBAAkB,iDAAiD,SAAS,WAAW;EACzF,CAAC"}
|
package/lib/utils6.js
CHANGED
|
@@ -2,9 +2,9 @@ import { t as Breakpoint } from "./useBreakpoint.js";
|
|
|
2
2
|
import { r as ResponsiveTableVariant } from "./constants3.js";
|
|
3
3
|
import { t as isTouchDevice } from "./device.js";
|
|
4
4
|
import React from "react";
|
|
5
|
-
import
|
|
5
|
+
import tableStyles from "./components/Table/styles.module.scss";
|
|
6
6
|
var configUsesCss = (config) => config.variant === ResponsiveTableVariant.centeredoverflow || config.variant === ResponsiveTableVariant.block;
|
|
7
|
-
var mapConfigToClass = (config) => config.variant === "centeredoverflow" || config.variant === "block" ?
|
|
7
|
+
var mapConfigToClass = (config) => config.variant === "centeredoverflow" || config.variant === "block" ? tableStyles[`table--${config.variant}-${config.breakpoint}`] : "";
|
|
8
8
|
var sortByBreakpointsDescending = (a, b) => Breakpoint[a.breakpoint] - Breakpoint[b.breakpoint];
|
|
9
9
|
var isValidForCurrentBreakpoint = (config, breakpoint) => Breakpoint[config.breakpoint] >= breakpoint;
|
|
10
10
|
var getConfigForBreakpoint = (config, breakpoint) => {
|
package/lib/utils6.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils6.js","names":["clone: Partial<T>"],"sources":["../src/components/Table/utils.ts"],"sourcesContent":["import React from 'react';\n\nimport type { ModeType } from './constants';\nimport type { BreakpointConfig } from './Table';\n\nimport { ResponsiveTableVariant } from './constants';\nimport { Breakpoint } from '../../hooks/useBreakpoint';\nimport { isTouchDevice } from '../../utils/device';\n\nimport styles from './styles.module.scss';\n\n/**\n * Sjekk om det skal brukes CSS for å bestemme responsivt utseende på dette breakpoint\n * @param config Konfigurasjon for responsiv oppførsel\n * @returns true om breakpoint bruker CSS\n */\nconst configUsesCss = (config: BreakpointConfig): boolean =>\n config.variant === ResponsiveTableVariant.centeredoverflow || config.variant === ResponsiveTableVariant.block;\n\n/**\n * Lag klassenavn for CSS-config\n * @param config Konfigurasjon for responsiv oppførsel\n * @returns CSS-klassenavn\n */\nconst mapConfigToClass = (config: BreakpointConfig): string =>\n config.variant === 'centeredoverflow' || config.variant === 'block' ? styles[`table--${config.variant}-${config.breakpoint}`] : '';\n\n/**\n * Sorter konfigurasjon etter breakpoints, fra største til minste\n * @param a Konfigurasjon for responsiv oppførsel\n * @param b Konfigurasjon for responsiv oppførsel\n * @returns Sortert liste\n */\nconst sortByBreakpointsDescending = (a: BreakpointConfig, b: BreakpointConfig): number =>\n Breakpoint[a.breakpoint] - Breakpoint[b.breakpoint];\n\n/**\n * Sjekk om en konfigurasjon skal brukes for nåværende breakpoint\n * @param a Konfigurasjon for responsiv oppførsel\n * @param breakpoint Nåværende breakpoint\n * @returns true dersom config skal brukes for breakpointet\n */\nconst isValidForCurrentBreakpoint = (config: BreakpointConfig, breakpoint: Breakpoint): boolean =>\n Breakpoint[config.breakpoint] >= breakpoint;\n\n/**\n * Finn konfigurasjon for nåværende breakpoint\n * @param config Konfigurasjon for responsiv oppførsel\n * @param breakpoint Nåværende breakpoint\n * @returns Konfigurasjon for responsiv oppførsel\n */\nconst getConfigForBreakpoint = (config: BreakpointConfig | BreakpointConfig[], breakpoint: Breakpoint): BreakpointConfig | undefined => {\n if (Array.isArray(config)) {\n config.sort(sortByBreakpointsDescending);\n\n return config.find(x => isValidForCurrentBreakpoint(x, breakpoint));\n } else if (config && isValidForCurrentBreakpoint(config, breakpoint)) {\n return config;\n }\n};\n\n/**\n * Finn konfigurasjon for nåværende breakpoint og tabellbredde\n * @param config Konfigurasjon for responsiv oppførsel\n * @param breakpoint Nåværende breakpoint\n * @param tableWidth Bredde på tabell i px\n * @returns Konfigurasjon for responsiv oppførsel uten fallbackVariant\n */\nexport const getCurrentConfig = (\n config: BreakpointConfig | BreakpointConfig[],\n breakpoint: Breakpoint,\n tableWidth: number,\n windowWidth: number\n): Omit<BreakpointConfig, 'fallbackVariant'> | undefined => {\n const breakpointConfig = getConfigForBreakpoint(config, breakpoint);\n const canUseHorizontalScroll = isTouchDevice();\n const canUseCenteredOverflow = tableWidth <= windowWidth;\n\n if (!breakpointConfig) {\n return;\n }\n\n if (\n breakpointConfig.variant === ResponsiveTableVariant.centeredoverflow &&\n !canUseCenteredOverflow &&\n breakpointConfig.fallbackVariant === ResponsiveTableVariant.horizontalscroll\n ) {\n return {\n variant: canUseHorizontalScroll ? ResponsiveTableVariant.horizontalscroll : ResponsiveTableVariant.none,\n breakpoint: breakpointConfig.breakpoint,\n };\n }\n\n if (\n breakpointConfig.variant === ResponsiveTableVariant.centeredoverflow &&\n !canUseCenteredOverflow &&\n breakpointConfig.fallbackVariant !== ResponsiveTableVariant.centeredoverflow\n ) {\n return {\n variant: breakpointConfig.fallbackVariant ?? ResponsiveTableVariant.none,\n breakpoint: breakpointConfig.breakpoint,\n };\n }\n\n if (\n breakpointConfig.variant === ResponsiveTableVariant.horizontalscroll &&\n !canUseHorizontalScroll &&\n breakpointConfig.fallbackVariant === ResponsiveTableVariant.centeredoverflow\n ) {\n return {\n variant: canUseCenteredOverflow ? ResponsiveTableVariant.centeredoverflow : ResponsiveTableVariant.none,\n breakpoint: breakpointConfig.breakpoint,\n };\n }\n\n if (\n breakpointConfig.variant === ResponsiveTableVariant.horizontalscroll &&\n !canUseHorizontalScroll &&\n breakpointConfig.fallbackVariant !== ResponsiveTableVariant.horizontalscroll\n ) {\n return {\n variant: breakpointConfig.fallbackVariant ?? ResponsiveTableVariant.none,\n breakpoint: breakpointConfig.breakpoint,\n };\n }\n\n return breakpointConfig;\n};\n\n/**\n * Finn klassenavn for responsiv oppførsel\n * @param config Konfigurasjon for responsiv oppførsel\n * @returns Klassenavn\n */\nexport const getBreakpointClass = (config?: BreakpointConfig): string | undefined =>\n config && configUsesCss(config) ? mapConfigToClass(config) : undefined;\n\n/**\n * Finn riktig posisjon for horisontal sentrering av tabell som skal vises \"centeredoverflow\"\n * @param parentWidth Bredde på element som tabellen ligger i\n * @param tableWidth Bredde på tabellen\n * @returns Styling som posisjonerer tabellen riktig\n */\nexport const getCenteredOverflowTableStyle = (parentWidth: number, tableWidth: number): React.CSSProperties | undefined => {\n if (parentWidth >= tableWidth) {\n return;\n }\n\n const COLUMN_GUTTER_WIDTH_PX = 8;\n\n return { left: `${(parentWidth - tableWidth) / 2 - COLUMN_GUTTER_WIDTH_PX}px` };\n};\n\n/**\n * Map children and inject the `mode` prop into element children, but never on React.Fragment.\n * If a Fragment is encountered, its children are mapped and updated, while the Fragment wrapper is preserved.\n */\nexport const mapChildrenWithMode = (children: React.ReactNode, mode: ModeType | undefined): React.ReactNode =>\n React.Children.map(children, child => {\n if (!React.isValidElement(child)) return child;\n if (child.type === React.Fragment) {\n const fragmentChildren = (child.props as { children?: React.ReactNode }).children;\n const mapped = React.Children.map(fragmentChildren, gc =>\n React.isValidElement<{ mode?: ModeType }>(gc) ? React.cloneElement(gc, { mode }) : gc\n );\n return React.cloneElement(child, undefined, mapped);\n }\n return React.cloneElement(child as React.ReactElement<{ mode?: ModeType }>, { mode });\n });\n\n/**\n * Create a shallow copy of an object with specific keys omitted.\n */\nexport const omitProps = <T extends Record<PropertyKey, unknown>>(obj: T, keys: Array<keyof T>): Partial<T> => {\n const clone: Partial<T> = { ...obj };\n for (const k of keys) {\n delete clone[k];\n }\n return clone;\n};\n"],"mappings":";;;;;AAgBA,IAAM,iBAAiB,WACrB,OAAO,YAAY,uBAAuB,oBAAoB,OAAO,YAAY,uBAAuB;AAO1G,IAAM,oBAAoB,WACxB,OAAO,YAAY,sBAAsB,OAAO,YAAY,UAAU,
|
|
1
|
+
{"version":3,"file":"utils6.js","names":["clone: Partial<T>"],"sources":["../src/components/Table/utils.ts"],"sourcesContent":["import React from 'react';\n\nimport type { ModeType } from './constants';\nimport type { BreakpointConfig } from './Table';\n\nimport { ResponsiveTableVariant } from './constants';\nimport { Breakpoint } from '../../hooks/useBreakpoint';\nimport { isTouchDevice } from '../../utils/device';\n\nimport styles from './styles.module.scss';\n\n/**\n * Sjekk om det skal brukes CSS for å bestemme responsivt utseende på dette breakpoint\n * @param config Konfigurasjon for responsiv oppførsel\n * @returns true om breakpoint bruker CSS\n */\nconst configUsesCss = (config: BreakpointConfig): boolean =>\n config.variant === ResponsiveTableVariant.centeredoverflow || config.variant === ResponsiveTableVariant.block;\n\n/**\n * Lag klassenavn for CSS-config\n * @param config Konfigurasjon for responsiv oppførsel\n * @returns CSS-klassenavn\n */\nconst mapConfigToClass = (config: BreakpointConfig): string =>\n config.variant === 'centeredoverflow' || config.variant === 'block' ? styles[`table--${config.variant}-${config.breakpoint}`] : '';\n\n/**\n * Sorter konfigurasjon etter breakpoints, fra største til minste\n * @param a Konfigurasjon for responsiv oppførsel\n * @param b Konfigurasjon for responsiv oppførsel\n * @returns Sortert liste\n */\nconst sortByBreakpointsDescending = (a: BreakpointConfig, b: BreakpointConfig): number =>\n Breakpoint[a.breakpoint] - Breakpoint[b.breakpoint];\n\n/**\n * Sjekk om en konfigurasjon skal brukes for nåværende breakpoint\n * @param a Konfigurasjon for responsiv oppførsel\n * @param breakpoint Nåværende breakpoint\n * @returns true dersom config skal brukes for breakpointet\n */\nconst isValidForCurrentBreakpoint = (config: BreakpointConfig, breakpoint: Breakpoint): boolean =>\n Breakpoint[config.breakpoint] >= breakpoint;\n\n/**\n * Finn konfigurasjon for nåværende breakpoint\n * @param config Konfigurasjon for responsiv oppførsel\n * @param breakpoint Nåværende breakpoint\n * @returns Konfigurasjon for responsiv oppførsel\n */\nconst getConfigForBreakpoint = (config: BreakpointConfig | BreakpointConfig[], breakpoint: Breakpoint): BreakpointConfig | undefined => {\n if (Array.isArray(config)) {\n config.sort(sortByBreakpointsDescending);\n\n return config.find(x => isValidForCurrentBreakpoint(x, breakpoint));\n } else if (config && isValidForCurrentBreakpoint(config, breakpoint)) {\n return config;\n }\n};\n\n/**\n * Finn konfigurasjon for nåværende breakpoint og tabellbredde\n * @param config Konfigurasjon for responsiv oppførsel\n * @param breakpoint Nåværende breakpoint\n * @param tableWidth Bredde på tabell i px\n * @returns Konfigurasjon for responsiv oppførsel uten fallbackVariant\n */\nexport const getCurrentConfig = (\n config: BreakpointConfig | BreakpointConfig[],\n breakpoint: Breakpoint,\n tableWidth: number,\n windowWidth: number\n): Omit<BreakpointConfig, 'fallbackVariant'> | undefined => {\n const breakpointConfig = getConfigForBreakpoint(config, breakpoint);\n const canUseHorizontalScroll = isTouchDevice();\n const canUseCenteredOverflow = tableWidth <= windowWidth;\n\n if (!breakpointConfig) {\n return;\n }\n\n if (\n breakpointConfig.variant === ResponsiveTableVariant.centeredoverflow &&\n !canUseCenteredOverflow &&\n breakpointConfig.fallbackVariant === ResponsiveTableVariant.horizontalscroll\n ) {\n return {\n variant: canUseHorizontalScroll ? ResponsiveTableVariant.horizontalscroll : ResponsiveTableVariant.none,\n breakpoint: breakpointConfig.breakpoint,\n };\n }\n\n if (\n breakpointConfig.variant === ResponsiveTableVariant.centeredoverflow &&\n !canUseCenteredOverflow &&\n breakpointConfig.fallbackVariant !== ResponsiveTableVariant.centeredoverflow\n ) {\n return {\n variant: breakpointConfig.fallbackVariant ?? ResponsiveTableVariant.none,\n breakpoint: breakpointConfig.breakpoint,\n };\n }\n\n if (\n breakpointConfig.variant === ResponsiveTableVariant.horizontalscroll &&\n !canUseHorizontalScroll &&\n breakpointConfig.fallbackVariant === ResponsiveTableVariant.centeredoverflow\n ) {\n return {\n variant: canUseCenteredOverflow ? ResponsiveTableVariant.centeredoverflow : ResponsiveTableVariant.none,\n breakpoint: breakpointConfig.breakpoint,\n };\n }\n\n if (\n breakpointConfig.variant === ResponsiveTableVariant.horizontalscroll &&\n !canUseHorizontalScroll &&\n breakpointConfig.fallbackVariant !== ResponsiveTableVariant.horizontalscroll\n ) {\n return {\n variant: breakpointConfig.fallbackVariant ?? ResponsiveTableVariant.none,\n breakpoint: breakpointConfig.breakpoint,\n };\n }\n\n return breakpointConfig;\n};\n\n/**\n * Finn klassenavn for responsiv oppførsel\n * @param config Konfigurasjon for responsiv oppførsel\n * @returns Klassenavn\n */\nexport const getBreakpointClass = (config?: BreakpointConfig): string | undefined =>\n config && configUsesCss(config) ? mapConfigToClass(config) : undefined;\n\n/**\n * Finn riktig posisjon for horisontal sentrering av tabell som skal vises \"centeredoverflow\"\n * @param parentWidth Bredde på element som tabellen ligger i\n * @param tableWidth Bredde på tabellen\n * @returns Styling som posisjonerer tabellen riktig\n */\nexport const getCenteredOverflowTableStyle = (parentWidth: number, tableWidth: number): React.CSSProperties | undefined => {\n if (parentWidth >= tableWidth) {\n return;\n }\n\n const COLUMN_GUTTER_WIDTH_PX = 8;\n\n return { left: `${(parentWidth - tableWidth) / 2 - COLUMN_GUTTER_WIDTH_PX}px` };\n};\n\n/**\n * Map children and inject the `mode` prop into element children, but never on React.Fragment.\n * If a Fragment is encountered, its children are mapped and updated, while the Fragment wrapper is preserved.\n */\nexport const mapChildrenWithMode = (children: React.ReactNode, mode: ModeType | undefined): React.ReactNode =>\n React.Children.map(children, child => {\n if (!React.isValidElement(child)) return child;\n if (child.type === React.Fragment) {\n const fragmentChildren = (child.props as { children?: React.ReactNode }).children;\n const mapped = React.Children.map(fragmentChildren, gc =>\n React.isValidElement<{ mode?: ModeType }>(gc) ? React.cloneElement(gc, { mode }) : gc\n );\n return React.cloneElement(child, undefined, mapped);\n }\n return React.cloneElement(child as React.ReactElement<{ mode?: ModeType }>, { mode });\n });\n\n/**\n * Create a shallow copy of an object with specific keys omitted.\n */\nexport const omitProps = <T extends Record<PropertyKey, unknown>>(obj: T, keys: Array<keyof T>): Partial<T> => {\n const clone: Partial<T> = { ...obj };\n for (const k of keys) {\n delete clone[k];\n }\n return clone;\n};\n"],"mappings":";;;;;AAgBA,IAAM,iBAAiB,WACrB,OAAO,YAAY,uBAAuB,oBAAoB,OAAO,YAAY,uBAAuB;AAO1G,IAAM,oBAAoB,WACxB,OAAO,YAAY,sBAAsB,OAAO,YAAY,UAAU,YAAO,UAAU,OAAO,QAAQ,GAAG,OAAO,gBAAgB;AAQlI,IAAM,+BAA+B,GAAqB,MACxD,WAAW,EAAE,cAAc,WAAW,EAAE;AAQ1C,IAAM,+BAA+B,QAA0B,eAC7D,WAAW,OAAO,eAAe;AAQnC,IAAM,0BAA0B,QAA+C,eAAyD;AACtI,KAAI,MAAM,QAAQ,OAAO,EAAE;AACzB,SAAO,KAAK,4BAA4B;AAExC,SAAO,OAAO,MAAK,MAAK,4BAA4B,GAAG,WAAW,CAAC;YAC1D,UAAU,4BAA4B,QAAQ,WAAW,CAClE,QAAO;;AAWX,MAAa,oBACX,QACA,YACA,YACA,gBAC0D;CAC1D,MAAM,mBAAmB,uBAAuB,QAAQ,WAAW;CACnE,MAAM,yBAAyB,eAAe;CAC9C,MAAM,yBAAyB,cAAc;AAE7C,KAAI,CAAC,iBACH;AAGF,KACE,iBAAiB,YAAY,uBAAuB,oBACpD,CAAC,0BACD,iBAAiB,oBAAoB,uBAAuB,iBAE5D,QAAO;EACL,SAAS,yBAAyB,uBAAuB,mBAAmB,uBAAuB;EACnG,YAAY,iBAAiB;EAC9B;AAGH,KACE,iBAAiB,YAAY,uBAAuB,oBACpD,CAAC,0BACD,iBAAiB,oBAAoB,uBAAuB,iBAE5D,QAAO;EACL,SAAS,iBAAiB,mBAAmB,uBAAuB;EACpE,YAAY,iBAAiB;EAC9B;AAGH,KACE,iBAAiB,YAAY,uBAAuB,oBACpD,CAAC,0BACD,iBAAiB,oBAAoB,uBAAuB,iBAE5D,QAAO;EACL,SAAS,yBAAyB,uBAAuB,mBAAmB,uBAAuB;EACnG,YAAY,iBAAiB;EAC9B;AAGH,KACE,iBAAiB,YAAY,uBAAuB,oBACpD,CAAC,0BACD,iBAAiB,oBAAoB,uBAAuB,iBAE5D,QAAO;EACL,SAAS,iBAAiB,mBAAmB,uBAAuB;EACpE,YAAY,iBAAiB;EAC9B;AAGH,QAAO;;AAQT,MAAa,sBAAsB,WACjC,UAAU,cAAc,OAAO,GAAG,iBAAiB,OAAO,GAAG,KAAA;AAQ/D,MAAa,iCAAiC,aAAqB,eAAwD;AACzH,KAAI,eAAe,WACjB;AAKF,QAAO,EAAE,MAAM,IAAI,cAAc,cAAc,IAFhB,EAE2C,KAAK;;AAOjF,MAAa,uBAAuB,UAA2B,SAC7D,MAAM,SAAS,IAAI,WAAU,UAAS;AACpC,KAAI,CAAC,MAAM,eAAe,MAAM,CAAE,QAAO;AACzC,KAAI,MAAM,SAAS,MAAM,UAAU;EACjC,MAAM,mBAAoB,MAAM,MAAyC;EACzE,MAAM,SAAS,MAAM,SAAS,IAAI,mBAAkB,OAClD,MAAM,eAAoC,GAAG,GAAG,MAAM,aAAa,IAAI,EAAE,MAAM,CAAC,GAAG,GACpF;AACD,SAAO,MAAM,aAAa,OAAO,KAAA,GAAW,OAAO;;AAErD,QAAO,MAAM,aAAa,OAAkD,EAAE,MAAM,CAAC;EACrF;AAKJ,MAAa,aAAqD,KAAQ,SAAqC;CAC7G,MAAMA,QAAoB,EAAE,GAAG,KAAK;AACpC,MAAK,MAAM,KAAK,KACd,QAAO,MAAM;AAEf,QAAO"}
|
package/package.json
CHANGED
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
// fjerner denne i vår kopi
|
|
32
|
+
// @include deprecate('The `make-container-max-widths` mixin', 'v4.5.2', 'v5');
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
@mixin make-col-ready($gutter: $grid-gutter-width) {
|