@navikt/ds-react 7.6.0 → 7.7.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/cjs/copybutton/CopyButton.d.ts +1 -6
- package/cjs/copybutton/CopyButton.js +8 -6
- package/cjs/copybutton/CopyButton.js.map +1 -1
- package/cjs/date/datepicker/parts/WeekNumber.js +11 -2
- package/cjs/date/datepicker/parts/WeekNumber.js.map +1 -1
- package/cjs/form/combobox/FilteredOptions/AddNewOption.js +3 -1
- package/cjs/form/combobox/FilteredOptions/AddNewOption.js.map +1 -1
- package/cjs/form/combobox/FilteredOptions/LoadingMessage.js +3 -1
- package/cjs/form/combobox/FilteredOptions/LoadingMessage.js.map +1 -1
- package/cjs/form/combobox/FilteredOptions/MaxSelectedMessage.js +6 -2
- package/cjs/form/combobox/FilteredOptions/MaxSelectedMessage.js.map +1 -1
- package/cjs/form/combobox/Input/Input.context.d.ts +1 -1
- package/cjs/form/combobox/Input/Input.context.js.map +1 -1
- package/cjs/form/combobox/Input/InputController.js +9 -7
- package/cjs/form/combobox/Input/InputController.js.map +1 -1
- package/cjs/form/combobox/Input/ToggleListButton.d.ts +1 -4
- package/cjs/form/combobox/Input/ToggleListButton.js +3 -5
- package/cjs/form/combobox/Input/ToggleListButton.js.map +1 -1
- package/cjs/form/combobox/SelectedOptions/SelectedOptions.js +8 -6
- package/cjs/form/combobox/SelectedOptions/SelectedOptions.js.map +1 -1
- package/cjs/form/combobox/types.d.ts +2 -7
- package/cjs/form/form-summary/FormSummaryEditLink.js +4 -2
- package/cjs/form/form-summary/FormSummaryEditLink.js.map +1 -1
- package/cjs/form/search/Search.js +8 -3
- package/cjs/form/search/Search.js.map +1 -1
- package/cjs/guide-panel/Illustration.js +3 -1
- package/cjs/guide-panel/Illustration.js.map +1 -1
- package/cjs/help-text/HelpText.d.ts +1 -1
- package/cjs/help-text/HelpText.js +6 -3
- package/cjs/help-text/HelpText.js.map +1 -1
- package/cjs/internal-header/InternalHeaderButton.d.ts +1 -1
- package/cjs/internal-header/InternalHeaderUserButton.d.ts +1 -1
- package/cjs/internal-header/InternalHeaderUserButton.js +1 -1
- package/cjs/internal-header/InternalHeaderUserButton.js.map +1 -1
- package/cjs/layout/base/BasePrimitive.js +4 -1
- package/cjs/layout/base/BasePrimitive.js.map +1 -1
- package/cjs/layout/bleed/Bleed.js +5 -2
- package/cjs/layout/bleed/Bleed.js.map +1 -1
- package/cjs/layout/box/Box.d.ts +6 -1
- package/cjs/layout/box/Box.darkside.d.ts +70 -0
- package/cjs/layout/box/Box.darkside.js +98 -0
- package/cjs/layout/box/Box.darkside.js.map +1 -0
- package/cjs/layout/box/Box.js +19 -6
- package/cjs/layout/box/Box.js.map +1 -1
- package/cjs/layout/box/index.js +2 -0
- package/cjs/layout/box/index.js.map +1 -1
- package/cjs/layout/grid/HGrid.js +4 -1
- package/cjs/layout/grid/HGrid.js.map +1 -1
- package/cjs/layout/page/Page.d.ts +1 -0
- package/cjs/layout/page/Page.js +5 -0
- package/cjs/layout/page/Page.js.map +1 -1
- package/cjs/layout/stack/Stack.js +4 -1
- package/cjs/layout/stack/Stack.js.map +1 -1
- package/cjs/layout/utilities/css.d.ts +2 -2
- package/cjs/layout/utilities/css.js +8 -9
- package/cjs/layout/utilities/css.js.map +1 -1
- package/cjs/layout/utilities/types.d.ts +10 -0
- package/cjs/util/i18n/locales/en.d.ts +19 -0
- package/cjs/util/i18n/locales/en.js +19 -0
- package/cjs/util/i18n/locales/en.js.map +1 -1
- package/cjs/util/i18n/locales/nb.d.ts +21 -0
- package/cjs/util/i18n/locales/nb.js +21 -0
- package/cjs/util/i18n/locales/nb.js.map +1 -1
- package/cjs/util/i18n/locales/nn.d.ts +19 -0
- package/cjs/util/i18n/locales/nn.js +19 -0
- package/cjs/util/i18n/locales/nn.js.map +1 -1
- package/esm/copybutton/CopyButton.d.ts +1 -6
- package/esm/copybutton/CopyButton.js +8 -6
- package/esm/copybutton/CopyButton.js.map +1 -1
- package/esm/date/datepicker/parts/WeekNumber.js +12 -3
- package/esm/date/datepicker/parts/WeekNumber.js.map +1 -1
- package/esm/form/combobox/FilteredOptions/AddNewOption.js +3 -1
- package/esm/form/combobox/FilteredOptions/AddNewOption.js.map +1 -1
- package/esm/form/combobox/FilteredOptions/LoadingMessage.js +3 -1
- package/esm/form/combobox/FilteredOptions/LoadingMessage.js.map +1 -1
- package/esm/form/combobox/FilteredOptions/MaxSelectedMessage.js +6 -2
- package/esm/form/combobox/FilteredOptions/MaxSelectedMessage.js.map +1 -1
- package/esm/form/combobox/Input/Input.context.d.ts +1 -1
- package/esm/form/combobox/Input/Input.context.js.map +1 -1
- package/esm/form/combobox/Input/InputController.js +9 -7
- package/esm/form/combobox/Input/InputController.js.map +1 -1
- package/esm/form/combobox/Input/ToggleListButton.d.ts +1 -4
- package/esm/form/combobox/Input/ToggleListButton.js +3 -5
- package/esm/form/combobox/Input/ToggleListButton.js.map +1 -1
- package/esm/form/combobox/SelectedOptions/SelectedOptions.js +8 -6
- package/esm/form/combobox/SelectedOptions/SelectedOptions.js.map +1 -1
- package/esm/form/combobox/types.d.ts +2 -7
- package/esm/form/form-summary/FormSummaryEditLink.js +4 -2
- package/esm/form/form-summary/FormSummaryEditLink.js.map +1 -1
- package/esm/form/search/Search.js +8 -3
- package/esm/form/search/Search.js.map +1 -1
- package/esm/guide-panel/Illustration.js +3 -1
- package/esm/guide-panel/Illustration.js.map +1 -1
- package/esm/help-text/HelpText.d.ts +1 -1
- package/esm/help-text/HelpText.js +6 -3
- package/esm/help-text/HelpText.js.map +1 -1
- package/esm/internal-header/InternalHeaderButton.d.ts +1 -1
- package/esm/internal-header/InternalHeaderUserButton.d.ts +1 -1
- package/esm/internal-header/InternalHeaderUserButton.js +1 -1
- package/esm/internal-header/InternalHeaderUserButton.js.map +1 -1
- package/esm/layout/base/BasePrimitive.js +4 -1
- package/esm/layout/base/BasePrimitive.js.map +1 -1
- package/esm/layout/bleed/Bleed.js +5 -2
- package/esm/layout/bleed/Bleed.js.map +1 -1
- package/esm/layout/box/Box.d.ts +6 -1
- package/esm/layout/box/Box.darkside.d.ts +70 -0
- package/esm/layout/box/Box.darkside.js +69 -0
- package/esm/layout/box/Box.darkside.js.map +1 -0
- package/esm/layout/box/Box.js +18 -5
- package/esm/layout/box/Box.js.map +1 -1
- package/esm/layout/grid/HGrid.js +4 -1
- package/esm/layout/grid/HGrid.js.map +1 -1
- package/esm/layout/page/Page.d.ts +1 -0
- package/esm/layout/page/Page.js +5 -0
- package/esm/layout/page/Page.js.map +1 -1
- package/esm/layout/stack/Stack.js +4 -1
- package/esm/layout/stack/Stack.js.map +1 -1
- package/esm/layout/utilities/css.d.ts +2 -2
- package/esm/layout/utilities/css.js +8 -9
- package/esm/layout/utilities/css.js.map +1 -1
- package/esm/layout/utilities/types.d.ts +10 -0
- package/esm/util/i18n/locales/en.d.ts +19 -0
- package/esm/util/i18n/locales/en.js +19 -0
- package/esm/util/i18n/locales/en.js.map +1 -1
- package/esm/util/i18n/locales/nb.d.ts +21 -0
- package/esm/util/i18n/locales/nb.js +21 -0
- package/esm/util/i18n/locales/nb.js.map +1 -1
- package/esm/util/i18n/locales/nn.d.ts +19 -0
- package/esm/util/i18n/locales/nn.js +19 -0
- package/esm/util/i18n/locales/nn.js.map +1 -1
- package/package.json +3 -3
- package/src/copybutton/CopyButton.tsx +14 -30
- package/src/date/datepicker/parts/WeekNumber.tsx +31 -6
- package/src/form/combobox/FilteredOptions/AddNewOption.tsx +3 -1
- package/src/form/combobox/FilteredOptions/LoadingMessage.tsx +3 -1
- package/src/form/combobox/FilteredOptions/MaxSelectedMessage.tsx +9 -2
- package/src/form/combobox/Input/Input.context.tsx +2 -2
- package/src/form/combobox/Input/InputController.tsx +13 -16
- package/src/form/combobox/Input/ToggleListButton.tsx +8 -24
- package/src/form/combobox/SelectedOptions/SelectedOptions.tsx +17 -11
- package/src/form/combobox/__tests__/combobox.test.tsx +2 -1
- package/src/form/combobox/types.ts +2 -7
- package/src/form/form-summary/FormSummaryEditLink.tsx +7 -6
- package/src/form/search/Search.tsx +33 -12
- package/src/guide-panel/Illustration.tsx +4 -1
- package/src/help-text/HelpText.tsx +8 -6
- package/src/internal-header/InternalHeaderButton.tsx +1 -1
- package/src/internal-header/InternalHeaderUserButton.tsx +2 -2
- package/src/layout/base/BasePrimitive.tsx +29 -25
- package/src/layout/bleed/Bleed.tsx +8 -0
- package/src/layout/box/Box.darkside.tsx +154 -0
- package/src/layout/box/Box.tsx +90 -61
- package/src/layout/box/index.ts +3 -0
- package/src/layout/grid/HGrid.tsx +7 -3
- package/src/layout/page/Page.tsx +10 -0
- package/src/layout/stack/Stack.tsx +8 -4
- package/src/layout/utilities/css.ts +18 -12
- package/src/layout/utilities/types.ts +24 -0
- package/src/util/i18n/locales/en.ts +19 -0
- package/src/util/i18n/locales/nb.ts +21 -0
- package/src/util/i18n/locales/nn.ts +19 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import cl from "clsx";
|
|
2
|
+
import React, { forwardRef } from "react";
|
|
3
|
+
import { BorderKeys } from "@navikt/ds-tokens/darkside/tokens/semantic-roles";
|
|
4
|
+
import { Slot } from "../../slot/Slot";
|
|
5
|
+
import { omit } from "../../util";
|
|
6
|
+
import { OverridableComponent } from "../../util/types";
|
|
7
|
+
import BasePrimitive, {
|
|
8
|
+
PRIMITIVE_PROPS,
|
|
9
|
+
PrimitiveProps,
|
|
10
|
+
} from "../base/BasePrimitive";
|
|
11
|
+
import { PrimitiveAsChildProps } from "../base/PrimitiveAsChildProps";
|
|
12
|
+
import { getResponsiveProps } from "../utilities/css";
|
|
13
|
+
import {
|
|
14
|
+
BorderRadiiToken,
|
|
15
|
+
ResponsiveProp,
|
|
16
|
+
SemanticRoleBgDarkside,
|
|
17
|
+
SemanticShadowTokens,
|
|
18
|
+
SemanticStaticBgDarkside,
|
|
19
|
+
SemanticStaticBorderDarkside,
|
|
20
|
+
SpaceDelimitedAttribute,
|
|
21
|
+
} from "../utilities/types";
|
|
22
|
+
|
|
23
|
+
export type BoxNewProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
24
|
+
/**
|
|
25
|
+
* CSS `background-color` property.
|
|
26
|
+
* Accepts a [background/surface color token](https://aksel.nav.no/grunnleggende/styling/design-tokens#afff774dad80).
|
|
27
|
+
*/
|
|
28
|
+
background?: SemanticStaticBgDarkside | SemanticRoleBgDarkside;
|
|
29
|
+
/**
|
|
30
|
+
* CSS `border-color` property.
|
|
31
|
+
* Accepts a [border color token](https://aksel.nav.no/grunnleggende/styling/design-tokens#adb1767e2f87).
|
|
32
|
+
*/
|
|
33
|
+
borderColor?: BorderKeys | SemanticStaticBorderDarkside;
|
|
34
|
+
/**
|
|
35
|
+
* CSS `border-radius` property.
|
|
36
|
+
* Accepts a [radius token](https://aksel.nav.no/grunnleggende/styling/design-tokens#6d79c5605d31)
|
|
37
|
+
* or an object of radius tokens for different breakpoints.
|
|
38
|
+
* @example
|
|
39
|
+
* borderRadius='full'
|
|
40
|
+
* borderRadius='0 full large small'
|
|
41
|
+
* borderRadius={{xs: 'small large', sm: '0', md: 'large', lg: 'full'}}
|
|
42
|
+
*/
|
|
43
|
+
borderRadius?: ResponsiveProp<SpaceDelimitedAttribute<BorderRadiiToken>>;
|
|
44
|
+
/**
|
|
45
|
+
* CSS `border-width` property. If this is not set there will be no border.
|
|
46
|
+
* @example
|
|
47
|
+
* borderWidth='2'
|
|
48
|
+
* borderWidth='1 2 3 4'
|
|
49
|
+
*/
|
|
50
|
+
borderWidth?: SpaceDelimitedAttribute<"0" | "1" | "2" | "3" | "4" | "5">;
|
|
51
|
+
/** Shadow on box. Accepts a shadow token.
|
|
52
|
+
* @example
|
|
53
|
+
* shadow='small'
|
|
54
|
+
*/
|
|
55
|
+
shadow?: SemanticShadowTokens;
|
|
56
|
+
} & PrimitiveProps &
|
|
57
|
+
PrimitiveAsChildProps;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
*
|
|
61
|
+
* Foundational Layout-primitive for generic encapsulation & styling.
|
|
62
|
+
*
|
|
63
|
+
* @see [📝 Documentation](https://aksel.nav.no/komponenter/primitives/box)
|
|
64
|
+
* @see 🏷️ {@link BoxProps}
|
|
65
|
+
* @see [🤖 OverridableComponent](https://aksel.nav.no/grunnleggende/kode/overridablecomponent) support
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* <Box padding="4">
|
|
69
|
+
* <BodyShort>Hei</BodyShort>
|
|
70
|
+
* </Box>
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* <Box padding={{xs: '2', sm: '3', md: '4', lg: '5', xl: '6'}}>
|
|
74
|
+
* <BodyShort>Hei</BodyShort>
|
|
75
|
+
* </Box>
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* <VStack gap="8">
|
|
79
|
+
* <Box padding="4">
|
|
80
|
+
* <BodyShort>Hei</BodyShort>
|
|
81
|
+
* </Box>
|
|
82
|
+
* <Box padding="4">
|
|
83
|
+
* <BodyShort>Hei</BodyShort>
|
|
84
|
+
* </Box>
|
|
85
|
+
* </VStack>
|
|
86
|
+
*/
|
|
87
|
+
export const BoxNew: OverridableComponent<BoxNewProps, HTMLDivElement> =
|
|
88
|
+
forwardRef(
|
|
89
|
+
(
|
|
90
|
+
{
|
|
91
|
+
children,
|
|
92
|
+
className,
|
|
93
|
+
as: Component = "div",
|
|
94
|
+
background,
|
|
95
|
+
borderColor,
|
|
96
|
+
borderWidth,
|
|
97
|
+
borderRadius,
|
|
98
|
+
shadow,
|
|
99
|
+
style: _style,
|
|
100
|
+
asChild,
|
|
101
|
+
...rest
|
|
102
|
+
},
|
|
103
|
+
ref,
|
|
104
|
+
) => {
|
|
105
|
+
const style: React.CSSProperties = {
|
|
106
|
+
..._style,
|
|
107
|
+
"--__axc-box-background": background
|
|
108
|
+
? `var(--ax-bg-${background})`
|
|
109
|
+
: undefined,
|
|
110
|
+
"--__axc-box-shadow": shadow ? `var(--ax-shadow-${shadow})` : undefined,
|
|
111
|
+
"--__axc-box-border-color": borderColor
|
|
112
|
+
? `var(--ax-border-${borderColor})`
|
|
113
|
+
: undefined,
|
|
114
|
+
"--__axc-box-border-width": borderWidth
|
|
115
|
+
? borderWidth
|
|
116
|
+
.split(" ")
|
|
117
|
+
.map((x) => `${x}px`)
|
|
118
|
+
.join(" ")
|
|
119
|
+
: undefined,
|
|
120
|
+
...getResponsiveProps(
|
|
121
|
+
"ax",
|
|
122
|
+
"box",
|
|
123
|
+
"border-radius",
|
|
124
|
+
"border-radius",
|
|
125
|
+
borderRadius,
|
|
126
|
+
false,
|
|
127
|
+
["0"],
|
|
128
|
+
),
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const Comp = asChild ? Slot : Component;
|
|
132
|
+
|
|
133
|
+
return (
|
|
134
|
+
<BasePrimitive {...rest}>
|
|
135
|
+
<Comp
|
|
136
|
+
{...omit(rest, PRIMITIVE_PROPS)}
|
|
137
|
+
ref={ref}
|
|
138
|
+
style={style}
|
|
139
|
+
className={cl("navds-box", className, {
|
|
140
|
+
"navds-box-bg": background,
|
|
141
|
+
"navds-box-border-color": borderColor,
|
|
142
|
+
"navds-box-border-width": borderWidth,
|
|
143
|
+
"navds-box-border-radius": borderRadius,
|
|
144
|
+
"navds-box-shadow": shadow,
|
|
145
|
+
})}
|
|
146
|
+
>
|
|
147
|
+
{children}
|
|
148
|
+
</Comp>
|
|
149
|
+
</BasePrimitive>
|
|
150
|
+
);
|
|
151
|
+
},
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
export default BoxNew;
|
package/src/layout/box/Box.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import React, { forwardRef } from "react";
|
|
3
|
+
import { UNSAFE_useAkselTheme } from "../../provider";
|
|
3
4
|
import { Slot } from "../../slot/Slot";
|
|
4
5
|
import { omit } from "../../util";
|
|
5
6
|
import { OverridableComponent } from "../../util/types";
|
|
@@ -18,6 +19,7 @@ import {
|
|
|
18
19
|
SpaceDelimitedAttribute,
|
|
19
20
|
SurfaceColorToken,
|
|
20
21
|
} from "../utilities/types";
|
|
22
|
+
import BoxNew from "./Box.darkside";
|
|
21
23
|
|
|
22
24
|
export type BoxProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
23
25
|
/**
|
|
@@ -55,6 +57,11 @@ export type BoxProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
|
55
57
|
} & PrimitiveProps &
|
|
56
58
|
PrimitiveAsChildProps;
|
|
57
59
|
|
|
60
|
+
interface BoxComponentType
|
|
61
|
+
extends OverridableComponent<BoxProps, HTMLDivElement> {
|
|
62
|
+
New: typeof BoxNew;
|
|
63
|
+
}
|
|
64
|
+
|
|
58
65
|
/**
|
|
59
66
|
* Foundational Layout-primitive for generic encapsulation & styling.
|
|
60
67
|
*
|
|
@@ -82,69 +89,91 @@ export type BoxProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
|
82
89
|
* </Box>
|
|
83
90
|
* </VStack>
|
|
84
91
|
*/
|
|
85
|
-
export const
|
|
86
|
-
(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
shadow,
|
|
96
|
-
style: _style,
|
|
97
|
-
asChild,
|
|
98
|
-
...rest
|
|
99
|
-
},
|
|
100
|
-
ref,
|
|
101
|
-
) => {
|
|
102
|
-
const style: React.CSSProperties = {
|
|
103
|
-
..._style,
|
|
104
|
-
"--__ac-box-background": background
|
|
105
|
-
? `var(--a-${background})`
|
|
106
|
-
: undefined,
|
|
107
|
-
"--__ac-box-shadow": shadow ? `var(--a-shadow-${shadow})` : undefined,
|
|
108
|
-
"--__ac-box-border-color": borderColor
|
|
109
|
-
? `var(--a-${borderColor})`
|
|
110
|
-
: undefined,
|
|
111
|
-
"--__ac-box-border-width": borderWidth
|
|
112
|
-
? borderWidth
|
|
113
|
-
.split(" ")
|
|
114
|
-
.map((x) => `${x}px`)
|
|
115
|
-
.join(" ")
|
|
116
|
-
: undefined,
|
|
117
|
-
...getResponsiveProps(
|
|
118
|
-
"box",
|
|
119
|
-
"border-radius",
|
|
120
|
-
"border-radius",
|
|
92
|
+
export const BoxComponent: OverridableComponent<BoxProps, HTMLDivElement> =
|
|
93
|
+
forwardRef(
|
|
94
|
+
(
|
|
95
|
+
{
|
|
96
|
+
children,
|
|
97
|
+
className,
|
|
98
|
+
as: Component = "div",
|
|
99
|
+
background,
|
|
100
|
+
borderColor,
|
|
101
|
+
borderWidth,
|
|
121
102
|
borderRadius,
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
103
|
+
shadow,
|
|
104
|
+
style: _style,
|
|
105
|
+
asChild,
|
|
106
|
+
...rest
|
|
107
|
+
},
|
|
108
|
+
ref,
|
|
109
|
+
) => {
|
|
110
|
+
const themeContext = UNSAFE_useAkselTheme(false);
|
|
111
|
+
|
|
112
|
+
if (
|
|
113
|
+
process.env.NODE_ENV !== "production" &&
|
|
114
|
+
themeContext &&
|
|
115
|
+
(background || borderColor || shadow)
|
|
116
|
+
) {
|
|
117
|
+
console.warn(
|
|
118
|
+
`<Box /> with properties 'background', 'borderColor' or 'shadow' cannot be used with AkselTheme (darkmode-support). To continue using these properties, migrate to '<Box.New>'`,
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const prefix = themeContext ? "ax" : "a";
|
|
123
|
+
|
|
124
|
+
const style: React.CSSProperties = {
|
|
125
|
+
..._style,
|
|
126
|
+
[`--__${prefix}c-box-background`]: background
|
|
127
|
+
? `var(--a-${background})`
|
|
128
|
+
: undefined,
|
|
129
|
+
[`--__${prefix}c-box-shadow`]: shadow
|
|
130
|
+
? `var(--a-shadow-${shadow})`
|
|
131
|
+
: undefined,
|
|
132
|
+
[`--__${prefix}c-box-border-color`]: borderColor
|
|
133
|
+
? `var(--a-${borderColor})`
|
|
134
|
+
: undefined,
|
|
135
|
+
[`--__${prefix}c-box-border-width`]: borderWidth
|
|
136
|
+
? borderWidth
|
|
137
|
+
.split(" ")
|
|
138
|
+
.map((x) => `${x}px`)
|
|
139
|
+
.join(" ")
|
|
140
|
+
: undefined,
|
|
141
|
+
...getResponsiveProps(
|
|
142
|
+
prefix,
|
|
143
|
+
"box",
|
|
144
|
+
"border-radius",
|
|
145
|
+
"border-radius",
|
|
146
|
+
borderRadius,
|
|
147
|
+
false,
|
|
148
|
+
["0"],
|
|
149
|
+
),
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const Comp = asChild ? Slot : Component;
|
|
153
|
+
|
|
154
|
+
return (
|
|
155
|
+
<BasePrimitive {...rest}>
|
|
156
|
+
<Comp
|
|
157
|
+
{...omit(rest, PRIMITIVE_PROPS)}
|
|
158
|
+
ref={ref}
|
|
159
|
+
style={style}
|
|
160
|
+
className={cl("navds-box", className, {
|
|
161
|
+
"navds-box-bg": background,
|
|
162
|
+
"navds-box-border-color": borderColor,
|
|
163
|
+
"navds-box-border-width": borderWidth,
|
|
164
|
+
"navds-box-border-radius": borderRadius,
|
|
165
|
+
"navds-box-shadow": shadow,
|
|
166
|
+
})}
|
|
167
|
+
>
|
|
168
|
+
{children}
|
|
169
|
+
</Comp>
|
|
170
|
+
</BasePrimitive>
|
|
171
|
+
);
|
|
172
|
+
},
|
|
173
|
+
);
|
|
126
174
|
|
|
127
|
-
|
|
175
|
+
export const Box = BoxComponent as BoxComponentType;
|
|
128
176
|
|
|
129
|
-
|
|
130
|
-
<BasePrimitive {...rest}>
|
|
131
|
-
<Comp
|
|
132
|
-
{...omit(rest, PRIMITIVE_PROPS)}
|
|
133
|
-
ref={ref}
|
|
134
|
-
style={style}
|
|
135
|
-
className={cl("navds-box", className, {
|
|
136
|
-
"navds-box-bg": background,
|
|
137
|
-
"navds-box-border-color": borderColor,
|
|
138
|
-
"navds-box-border-width": borderWidth,
|
|
139
|
-
"navds-box-border-radius": borderRadius,
|
|
140
|
-
"navds-box-shadow": shadow,
|
|
141
|
-
})}
|
|
142
|
-
>
|
|
143
|
-
{children}
|
|
144
|
-
</Comp>
|
|
145
|
-
</BasePrimitive>
|
|
146
|
-
);
|
|
147
|
-
},
|
|
148
|
-
);
|
|
177
|
+
Box.New = BoxNew;
|
|
149
178
|
|
|
150
179
|
export default Box;
|
package/src/layout/box/index.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
export { default as Box, type BoxProps } from "./Box";
|
|
3
|
+
|
|
4
|
+
/* TODO: Uncomment this when ready to expose darkmode-support. Remember to update top-level `index.ts` at the same time. */
|
|
5
|
+
/* export { default as BoxNew, type BoxNewProps } from "./Box.darkside"; */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import React, { forwardRef } from "react";
|
|
3
|
+
import { UNSAFE_useAkselTheme } from "../../provider";
|
|
3
4
|
import { Slot } from "../../slot/Slot";
|
|
4
5
|
import { OverridableComponent, omit } from "../../util";
|
|
5
6
|
import BasePrimitive, {
|
|
@@ -77,11 +78,14 @@ export const HGrid: OverridableComponent<HGridProps, HTMLDivElement> =
|
|
|
77
78
|
},
|
|
78
79
|
ref,
|
|
79
80
|
) => {
|
|
81
|
+
const themeContext = UNSAFE_useAkselTheme(false);
|
|
82
|
+
const prefix = themeContext ? "ax" : "a";
|
|
83
|
+
|
|
80
84
|
const styles: React.CSSProperties = {
|
|
81
85
|
...style,
|
|
82
|
-
|
|
83
|
-
...getResponsiveProps(`hgrid`, "gap", "spacing", gap),
|
|
84
|
-
...getResponsiveValue(`hgrid`, "columns", formatGrid(columns)),
|
|
86
|
+
[`--__${prefix}c-hgrid-align`]: align,
|
|
87
|
+
...getResponsiveProps(prefix, `hgrid`, "gap", "spacing", gap),
|
|
88
|
+
...getResponsiveValue(prefix, `hgrid`, "columns", formatGrid(columns)),
|
|
85
89
|
};
|
|
86
90
|
|
|
87
91
|
const Comp = asChild ? Slot : Component;
|
package/src/layout/page/Page.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import React, { forwardRef } from "react";
|
|
3
|
+
import { UNSAFE_useAkselTheme } from "../../provider";
|
|
3
4
|
import { OverridableComponent } from "../../util";
|
|
4
5
|
import { BackgroundColorToken } from "../utilities/types";
|
|
5
6
|
import { PageBlock } from "./parts/PageBlock";
|
|
@@ -14,6 +15,7 @@ export interface PageProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
14
15
|
* Background color.
|
|
15
16
|
* Accepts a [background color token](https://aksel.nav.no/grunnleggende/styling/design-tokens#753d1cf4d1d6).
|
|
16
17
|
* @default "bg-default"
|
|
18
|
+
* @deprecated 'background'-prop will be removed in future major-versions. Use `<Box asChild background="...">` wrapped around `<Page>`.
|
|
17
19
|
*/
|
|
18
20
|
background?: BackgroundColorToken;
|
|
19
21
|
/**
|
|
@@ -52,6 +54,14 @@ export const PageComponent: OverridableComponent<PageProps, HTMLElement> =
|
|
|
52
54
|
},
|
|
53
55
|
ref,
|
|
54
56
|
) => {
|
|
57
|
+
const themeContext = UNSAFE_useAkselTheme(false);
|
|
58
|
+
|
|
59
|
+
if (process.env.NODE_ENV !== "production" && themeContext && background) {
|
|
60
|
+
console.warn(
|
|
61
|
+
`Prop \`background\` is deprecated and cannot be used with theme-support. Instead wrap component with \`<Box asChild background>\``,
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
55
65
|
const style: React.CSSProperties = {
|
|
56
66
|
..._style,
|
|
57
67
|
"--__ac-page-background": `var(--a-${background})`,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import React, { HTMLAttributes, forwardRef } from "react";
|
|
3
|
+
import { UNSAFE_useAkselTheme } from "../../provider";
|
|
3
4
|
import { Slot } from "../../slot/Slot";
|
|
4
5
|
import { omit } from "../../util";
|
|
5
6
|
import { OverridableComponent } from "../../util/types";
|
|
@@ -83,12 +84,15 @@ export const Stack: OverridableComponent<StackProps, HTMLDivElement> =
|
|
|
83
84
|
},
|
|
84
85
|
ref,
|
|
85
86
|
) => {
|
|
87
|
+
const themeContext = UNSAFE_useAkselTheme(false);
|
|
88
|
+
const prefix = themeContext ? "ax" : "a";
|
|
89
|
+
|
|
86
90
|
const style: React.CSSProperties = {
|
|
87
91
|
..._style,
|
|
88
|
-
...getResponsiveProps(`stack`, "gap", "spacing", gap),
|
|
89
|
-
...getResponsiveValue(`stack`, "direction", direction),
|
|
90
|
-
...getResponsiveValue(`stack`, "align", align),
|
|
91
|
-
...getResponsiveValue(`stack`, "justify", justify),
|
|
92
|
+
...getResponsiveProps(prefix, `stack`, "gap", "spacing", gap),
|
|
93
|
+
...getResponsiveValue(prefix, `stack`, "direction", direction),
|
|
94
|
+
...getResponsiveValue(prefix, `stack`, "align", align),
|
|
95
|
+
...getResponsiveValue(prefix, `stack`, "justify", justify),
|
|
92
96
|
};
|
|
93
97
|
|
|
94
98
|
const Comp = asChild ? Slot : Component;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ResponsiveProp } from "./types";
|
|
2
2
|
|
|
3
3
|
export function getResponsiveValue<T = string>(
|
|
4
|
+
prefix: string,
|
|
4
5
|
componentName: string,
|
|
5
6
|
componentProp: string,
|
|
6
7
|
responsiveProp?: ResponsiveProp<T>,
|
|
@@ -11,13 +12,13 @@ export function getResponsiveValue<T = string>(
|
|
|
11
12
|
|
|
12
13
|
if (typeof responsiveProp === "string") {
|
|
13
14
|
return {
|
|
14
|
-
[`--
|
|
15
|
+
[`--__${prefix}c-${componentName}-${componentProp}-xs`]: responsiveProp,
|
|
15
16
|
};
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
return Object.fromEntries(
|
|
19
20
|
Object.entries(responsiveProp).map(([breakpointAlias, responsiveValue]) => [
|
|
20
|
-
`--
|
|
21
|
+
`--__${prefix}c-${componentName}-${componentProp}-${breakpointAlias}`,
|
|
21
22
|
responsiveValue,
|
|
22
23
|
]),
|
|
23
24
|
);
|
|
@@ -37,6 +38,7 @@ const translateTokenStringToCSS = (
|
|
|
37
38
|
tokenSubgroup: string,
|
|
38
39
|
tokenExceptions: string[],
|
|
39
40
|
invert: boolean,
|
|
41
|
+
prefix: string,
|
|
40
42
|
) => {
|
|
41
43
|
return tokenString
|
|
42
44
|
.split(" ")
|
|
@@ -54,7 +56,7 @@ const translateTokenStringToCSS = (
|
|
|
54
56
|
return "auto";
|
|
55
57
|
}
|
|
56
58
|
|
|
57
|
-
let output = `var(
|
|
59
|
+
let output = `var(--${prefix}-${tokenSubgroup}-${x})`;
|
|
58
60
|
if (tokenExceptions.includes(x)) {
|
|
59
61
|
output = translateExceptionToCSS(x);
|
|
60
62
|
}
|
|
@@ -70,6 +72,7 @@ const translateTokenStringToCSS = (
|
|
|
70
72
|
};
|
|
71
73
|
|
|
72
74
|
export function getResponsiveProps<T extends string>(
|
|
75
|
+
prefix: string,
|
|
73
76
|
componentName: string,
|
|
74
77
|
componentProp: string,
|
|
75
78
|
tokenSubgroup: string,
|
|
@@ -83,27 +86,30 @@ export function getResponsiveProps<T extends string>(
|
|
|
83
86
|
|
|
84
87
|
if (typeof responsiveProp === "string") {
|
|
85
88
|
return {
|
|
86
|
-
[`--
|
|
89
|
+
[`--__${prefix}c-${componentName}-${componentProp}-xs`]:
|
|
87
90
|
translateTokenStringToCSS(
|
|
88
91
|
componentProp,
|
|
89
92
|
responsiveProp,
|
|
90
93
|
tokenSubgroup,
|
|
91
94
|
tokenExceptions,
|
|
92
95
|
invert,
|
|
96
|
+
prefix,
|
|
93
97
|
),
|
|
94
98
|
};
|
|
95
99
|
}
|
|
96
100
|
|
|
97
101
|
const styleProps = {};
|
|
98
102
|
Object.entries(responsiveProp).forEach(([breakpointAlias, aliasOrScale]) => {
|
|
99
|
-
styleProps[
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
103
|
+
styleProps[
|
|
104
|
+
`--__${prefix}c-${componentName}-${componentProp}-${breakpointAlias}`
|
|
105
|
+
] = translateTokenStringToCSS(
|
|
106
|
+
componentProp,
|
|
107
|
+
aliasOrScale,
|
|
108
|
+
tokenSubgroup,
|
|
109
|
+
tokenExceptions,
|
|
110
|
+
invert,
|
|
111
|
+
prefix,
|
|
112
|
+
);
|
|
107
113
|
});
|
|
108
114
|
return styleProps;
|
|
109
115
|
}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/* Darkside tokens */
|
|
2
|
+
import { semanticTokenConfig } from "@navikt/ds-tokens/darkside/tokens/semantic";
|
|
3
|
+
import { SemanticTokensForAllRolesConfigT } from "@navikt/ds-tokens/darkside/tokens/semantic-roles";
|
|
4
|
+
import { shadowTokenConfig } from "@navikt/ds-tokens/darkside/tokens/shadow";
|
|
5
|
+
|
|
6
|
+
/* Old */
|
|
1
7
|
import borderRadii from "@navikt/ds-tokens/src/border.json";
|
|
2
8
|
import bgColors from "@navikt/ds-tokens/src/colors-bg.json";
|
|
3
9
|
import borderColors from "@navikt/ds-tokens/src/colors-border.json";
|
|
@@ -27,3 +33,21 @@ type FixedResponsiveT<T> = {
|
|
|
27
33
|
};
|
|
28
34
|
|
|
29
35
|
export type ResponsiveProp<T> = T | FixedResponsiveT<T>;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Darkside tokens
|
|
39
|
+
*/
|
|
40
|
+
export type SemanticShadowTokens = keyof ReturnType<
|
|
41
|
+
typeof shadowTokenConfig
|
|
42
|
+
>["shadow"];
|
|
43
|
+
|
|
44
|
+
export type SemanticStaticBgDarkside = keyof ReturnType<
|
|
45
|
+
typeof semanticTokenConfig
|
|
46
|
+
>["bg"];
|
|
47
|
+
|
|
48
|
+
export type SemanticRoleBgDarkside =
|
|
49
|
+
keyof SemanticTokensForAllRolesConfigT<"color">["bg"];
|
|
50
|
+
|
|
51
|
+
export type SemanticStaticBorderDarkside = keyof ReturnType<
|
|
52
|
+
typeof semanticTokenConfig
|
|
53
|
+
>["border"];
|
|
@@ -45,9 +45,16 @@ export default {
|
|
|
45
45
|
labelSuffix: "delete",
|
|
46
46
|
},
|
|
47
47
|
},
|
|
48
|
+
CopyButton: {
|
|
49
|
+
title: "Copy",
|
|
50
|
+
activeText: "Copied!",
|
|
51
|
+
},
|
|
48
52
|
ErrorSummary: {
|
|
49
53
|
heading: "You must correct the following errors before you can continue:",
|
|
50
54
|
},
|
|
55
|
+
FormSummary: {
|
|
56
|
+
editAnswer: "Edit answer",
|
|
57
|
+
},
|
|
51
58
|
Loader: {
|
|
52
59
|
title: "Waiting…",
|
|
53
60
|
},
|
|
@@ -117,4 +124,16 @@ export default {
|
|
|
117
124
|
closeDatePicker: "Close date picker",
|
|
118
125
|
closeMonthPicker: "Close month picker",
|
|
119
126
|
},
|
|
127
|
+
Combobox: {
|
|
128
|
+
addOption: "Add",
|
|
129
|
+
loading: "Searching…",
|
|
130
|
+
maxSelected: "{selected} of max {limit} are selected.",
|
|
131
|
+
clear: "Clear",
|
|
132
|
+
},
|
|
133
|
+
GuidePanel: {
|
|
134
|
+
illustrationLabel: "Illustration of advisor",
|
|
135
|
+
},
|
|
136
|
+
HelpText: {
|
|
137
|
+
title: "More information",
|
|
138
|
+
},
|
|
120
139
|
} satisfies Translations;
|
|
@@ -49,9 +49,16 @@ export default {
|
|
|
49
49
|
labelSuffix: "slett",
|
|
50
50
|
},
|
|
51
51
|
},
|
|
52
|
+
CopyButton: {
|
|
53
|
+
title: "Kopier",
|
|
54
|
+
activeText: "Kopiert!",
|
|
55
|
+
},
|
|
52
56
|
ErrorSummary: {
|
|
53
57
|
heading: "Du må rette disse feilene før du kan fortsette:",
|
|
54
58
|
},
|
|
59
|
+
FormSummary: {
|
|
60
|
+
editAnswer: "Endre svar",
|
|
61
|
+
},
|
|
55
62
|
Loader: {
|
|
56
63
|
title: "Venter…",
|
|
57
64
|
},
|
|
@@ -122,4 +129,18 @@ export default {
|
|
|
122
129
|
closeDatePicker: "Lukk datovelger",
|
|
123
130
|
closeMonthPicker: "Lukk månedsvelger",
|
|
124
131
|
},
|
|
132
|
+
Combobox: {
|
|
133
|
+
/** The input value will be appended to the end of this text, e.g. `Legg til "input value"`. */
|
|
134
|
+
addOption: "Legg til",
|
|
135
|
+
/** Loader title */
|
|
136
|
+
loading: "Søker…",
|
|
137
|
+
maxSelected: "{selected} av maks {limit} er valgt.",
|
|
138
|
+
clear: "Tøm",
|
|
139
|
+
},
|
|
140
|
+
GuidePanel: {
|
|
141
|
+
illustrationLabel: "Illustrasjon av veileder",
|
|
142
|
+
},
|
|
143
|
+
HelpText: {
|
|
144
|
+
title: "Mer informasjon",
|
|
145
|
+
},
|
|
125
146
|
} satisfies TranslationMap;
|
|
@@ -45,9 +45,16 @@ export default {
|
|
|
45
45
|
labelSuffix: "slett",
|
|
46
46
|
},
|
|
47
47
|
},
|
|
48
|
+
CopyButton: {
|
|
49
|
+
title: "Kopier",
|
|
50
|
+
activeText: "Kopiert!",
|
|
51
|
+
},
|
|
48
52
|
ErrorSummary: {
|
|
49
53
|
heading: "Du må rette desse feila før du kan halde fram:",
|
|
50
54
|
},
|
|
55
|
+
FormSummary: {
|
|
56
|
+
editAnswer: "Endre svar",
|
|
57
|
+
},
|
|
51
58
|
Loader: {
|
|
52
59
|
title: "Ventar…",
|
|
53
60
|
},
|
|
@@ -117,4 +124,16 @@ export default {
|
|
|
117
124
|
closeDatePicker: "Lukk datoveljar",
|
|
118
125
|
closeMonthPicker: "Lukk månadsveljar",
|
|
119
126
|
},
|
|
127
|
+
Combobox: {
|
|
128
|
+
addOption: "Legg til",
|
|
129
|
+
loading: "Søker…",
|
|
130
|
+
maxSelected: "{selected} av maks {limit} er valt.",
|
|
131
|
+
clear: "Tøm",
|
|
132
|
+
},
|
|
133
|
+
GuidePanel: {
|
|
134
|
+
illustrationLabel: "Illustrasjon av rettleiar",
|
|
135
|
+
},
|
|
136
|
+
HelpText: {
|
|
137
|
+
title: "Meir informasjon",
|
|
138
|
+
},
|
|
120
139
|
} satisfies Translations;
|