@navikt/ds-react 5.4.1 → 5.5.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/_docs.json +650 -454
- package/cjs/index.js +1 -0
- package/cjs/layout/box/Box.js +84 -0
- package/cjs/layout/box/index.js +5 -0
- package/cjs/layout/box/package.json +6 -0
- package/cjs/layout/utilities/css.js +21 -13
- package/cjs/layout/utilities/types.js +2 -0
- package/cjs/skeleton/Skeleton.js +1 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/esm/layout/box/Box.d.ts +78 -0
- package/esm/layout/box/Box.js +56 -0
- package/esm/layout/box/Box.js.map +1 -0
- package/esm/layout/box/index.d.ts +1 -0
- package/esm/layout/box/index.js +2 -0
- package/esm/layout/box/index.js.map +1 -0
- package/esm/layout/utilities/css.d.ts +7 -7
- package/esm/layout/utilities/css.js +18 -10
- package/esm/layout/utilities/css.js.map +1 -1
- package/esm/layout/utilities/types.d.ts +9 -0
- package/esm/layout/utilities/types.js +2 -0
- package/esm/layout/utilities/types.js.map +1 -0
- package/esm/skeleton/Skeleton.js +1 -0
- package/esm/skeleton/Skeleton.js.map +1 -1
- package/package.json +3 -2
- package/src/grid/grid.stories.tsx +1 -1
- package/src/index.ts +1 -0
- package/src/layout/box/Box.stories.tsx +384 -0
- package/src/layout/box/Box.tsx +148 -0
- package/src/layout/box/index.ts +1 -0
- package/src/layout/grid/h-grid.stories.tsx +1 -1
- package/src/layout/responsive/hide.stories.tsx +1 -1
- package/src/layout/responsive/show.stories.tsx +1 -1
- package/src/layout/stack/stack.stories.tsx +1 -1
- package/src/layout/utilities/css.ts +34 -16
- package/src/layout/utilities/types.ts +14 -0
- package/src/skeleton/Skeleton.tsx +1 -0
- package/src/skeleton/skeleton.stories.tsx +4 -3
package/cjs/index.js
CHANGED
|
@@ -48,6 +48,7 @@ __exportStar(require("./toggle-group"), exports);
|
|
|
48
48
|
__exportStar(require("./tooltip"), exports);
|
|
49
49
|
__exportStar(require("./typography"), exports);
|
|
50
50
|
__exportStar(require("./util"), exports);
|
|
51
|
+
__exportStar(require("./layout/box"), exports);
|
|
51
52
|
__exportStar(require("./layout/stack"), exports);
|
|
52
53
|
__exportStar(require("./layout/grid"), exports);
|
|
53
54
|
__exportStar(require("./layout/content-container"), exports);
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
26
|
+
var t = {};
|
|
27
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
+
t[p] = s[p];
|
|
29
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
+
t[p[i]] = s[p[i]];
|
|
33
|
+
}
|
|
34
|
+
return t;
|
|
35
|
+
};
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.Box = void 0;
|
|
41
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
42
|
+
const react_1 = __importStar(require("react"));
|
|
43
|
+
const css_1 = require("../utilities/css");
|
|
44
|
+
/**
|
|
45
|
+
* Foundational Layout-primitive for generic encapsulation & styling.
|
|
46
|
+
*
|
|
47
|
+
* @see [📝 Documentation](https://aksel.nav.no/komponenter/primitives/box)
|
|
48
|
+
* @see 🏷️ {@link BoxProps}
|
|
49
|
+
* @see [🤖 OverridableComponent](https://aksel.nav.no/grunnleggende/kode/overridablecomponent) support
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* <Box padding="4">
|
|
53
|
+
* <BodyShort>Hei</BodyShort>
|
|
54
|
+
* </Box>
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* <Box padding={{xs: '2', sm: '3', md: '4', lg: '5', xl: '6'}}>
|
|
58
|
+
* <BodyShort>Hei</BodyShort>
|
|
59
|
+
* </Box>
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* <VStack gap="8">
|
|
63
|
+
* <Box padding="4">
|
|
64
|
+
* <BodyShort>Hei</BodyShort>
|
|
65
|
+
* </Box>
|
|
66
|
+
* <Box padding="4">
|
|
67
|
+
* <BodyShort>Hei</BodyShort>
|
|
68
|
+
* </Box>
|
|
69
|
+
* </VStack>
|
|
70
|
+
*/
|
|
71
|
+
exports.Box = (0, react_1.forwardRef)((_a, ref) => {
|
|
72
|
+
var { as: Component = "div", background, borderColor, borderWidth, borderRadius, className, padding, paddingInline, paddingBlock, shadow, style: _style } = _a, rest = __rest(_a, ["as", "background", "borderColor", "borderWidth", "borderRadius", "className", "padding", "paddingInline", "paddingBlock", "shadow", "style"]);
|
|
73
|
+
const style = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, _style), { "--__ac-box-background": background
|
|
74
|
+
? `var(--a-${background})`
|
|
75
|
+
: undefined, "--__ac-box-shadow": shadow ? `var(--a-shadow-${shadow})` : undefined, "--__ac-box-border-color": borderColor
|
|
76
|
+
? `var(--a-${borderColor})`
|
|
77
|
+
: undefined, "--__ac-box-border-width": borderWidth
|
|
78
|
+
? borderWidth
|
|
79
|
+
.split(" ")
|
|
80
|
+
.map((x) => `${x}px`)
|
|
81
|
+
.join(" ")
|
|
82
|
+
: undefined }), (0, css_1.getResponsiveProps)("box", "border-radius", "border-radius", borderRadius, ["0"])), (0, css_1.getResponsiveProps)("box", "padding", "spacing", padding)), (0, css_1.getResponsiveProps)("box", "padding-inline", "spacing", paddingInline)), (0, css_1.getResponsiveProps)("box", "padding-block", "spacing", paddingBlock));
|
|
83
|
+
return (react_1.default.createElement(Component, Object.assign({}, rest, { className: (0, clsx_1.default)("navds-box", className), ref: ref, style: style })));
|
|
84
|
+
});
|
|
@@ -1,33 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
function
|
|
3
|
+
exports.getResponsiveProps = exports.getResponsiveValue = void 0;
|
|
4
|
+
function getResponsiveValue(componentName, componentProp, responsiveProp) {
|
|
5
5
|
if (!responsiveProp) {
|
|
6
6
|
return {};
|
|
7
7
|
}
|
|
8
8
|
if (typeof responsiveProp === "string") {
|
|
9
9
|
return {
|
|
10
|
-
[`--__ac-${componentName}-${componentProp}-xs`]:
|
|
10
|
+
[`--__ac-${componentName}-${componentProp}-xs`]: responsiveProp,
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
|
-
return Object.fromEntries(Object.entries(responsiveProp).map(([breakpointAlias,
|
|
13
|
+
return Object.fromEntries(Object.entries(responsiveProp).map(([breakpointAlias, responsiveValue]) => [
|
|
14
14
|
`--__ac-${componentName}-${componentProp}-${breakpointAlias}`,
|
|
15
|
-
|
|
15
|
+
responsiveValue,
|
|
16
16
|
]));
|
|
17
17
|
}
|
|
18
|
-
exports.
|
|
19
|
-
function
|
|
18
|
+
exports.getResponsiveValue = getResponsiveValue;
|
|
19
|
+
function getResponsiveProps(componentName, componentProp, tokenSubgroup, responsiveProp, tokenExceptions = []) {
|
|
20
20
|
if (!responsiveProp) {
|
|
21
21
|
return {};
|
|
22
22
|
}
|
|
23
23
|
if (typeof responsiveProp === "string") {
|
|
24
24
|
return {
|
|
25
|
-
[`--__ac-${componentName}-${componentProp}-xs`]: responsiveProp
|
|
25
|
+
[`--__ac-${componentName}-${componentProp}-xs`]: responsiveProp
|
|
26
|
+
.split(" ")
|
|
27
|
+
.map((x) => tokenExceptions.includes(x) ? x : `var(--a-${tokenSubgroup}-${x})`)
|
|
28
|
+
.join(" "),
|
|
26
29
|
};
|
|
27
30
|
}
|
|
28
|
-
return Object.fromEntries(Object.entries(responsiveProp).map(([breakpointAlias,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
return Object.fromEntries(Object.entries(responsiveProp).map(([breakpointAlias, aliasOrScale]) => {
|
|
32
|
+
return [
|
|
33
|
+
`--__ac-${componentName}-${componentProp}-${breakpointAlias}`,
|
|
34
|
+
aliasOrScale
|
|
35
|
+
.split(" ")
|
|
36
|
+
.map((x) => tokenExceptions.includes(x) ? x : `var(--a-${tokenSubgroup}-${x})`)
|
|
37
|
+
.join(" "),
|
|
38
|
+
];
|
|
39
|
+
}));
|
|
32
40
|
}
|
|
33
|
-
exports.
|
|
41
|
+
exports.getResponsiveProps = getResponsiveProps;
|
package/cjs/skeleton/Skeleton.js
CHANGED
|
@@ -55,6 +55,7 @@ exports.Skeleton = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
55
55
|
"navds-skeleton--has-children": Boolean(children),
|
|
56
56
|
"navds-skeleton--no-height": !height,
|
|
57
57
|
"navds-skeleton--no-width": !width,
|
|
58
|
+
"navds-skeleton--inline": As === "span",
|
|
58
59
|
}), style: Object.assign(Object.assign({}, style), { width, height }), "aria-hidden": true }), children));
|
|
59
60
|
});
|
|
60
61
|
exports.default = exports.Skeleton;
|
package/esm/index.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export * from "./toggle-group";
|
|
|
32
32
|
export * from "./tooltip";
|
|
33
33
|
export * from "./typography";
|
|
34
34
|
export * from "./util";
|
|
35
|
+
export * from "./layout/box";
|
|
35
36
|
export * from "./layout/stack";
|
|
36
37
|
export * from "./layout/grid";
|
|
37
38
|
export * from "./layout/content-container";
|
package/esm/index.js
CHANGED
|
@@ -32,6 +32,7 @@ export * from "./toggle-group";
|
|
|
32
32
|
export * from "./tooltip";
|
|
33
33
|
export * from "./typography";
|
|
34
34
|
export * from "./util";
|
|
35
|
+
export * from "./layout/box";
|
|
35
36
|
export * from "./layout/stack";
|
|
36
37
|
export * from "./layout/grid";
|
|
37
38
|
export * from "./layout/content-container";
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,eA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AAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { OverridableComponent } from "../../util/OverridableComponent";
|
|
3
|
+
import { BorderRadiiToken } from "../utilities/types";
|
|
4
|
+
import { SpaceDelimitedAttribute, ResponsiveProp, SpacingScale } from "../utilities/css";
|
|
5
|
+
import { BackgroundToken, BorderColorToken, ShadowToken } from "../utilities/types";
|
|
6
|
+
export interface BoxProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
7
|
+
/** Background color. Accepts a color token. */
|
|
8
|
+
background?: BackgroundToken;
|
|
9
|
+
/** Border color. Accepts a color token. */
|
|
10
|
+
borderColor?: BorderColorToken;
|
|
11
|
+
/** Border radius. Accepts a radius token, or an object of radius tokens for different breakpoints.
|
|
12
|
+
* @example
|
|
13
|
+
* borderRadius='full'
|
|
14
|
+
* borderRadius='0 full large small'
|
|
15
|
+
* borderRadius={{xs: 'small large', sm: '0', md: 'large', lg: 'full'}}
|
|
16
|
+
*/
|
|
17
|
+
borderRadius?: ResponsiveProp<SpaceDelimitedAttribute<BorderRadiiToken>>;
|
|
18
|
+
/**
|
|
19
|
+
* Border-width. If this is not set there will be no border.
|
|
20
|
+
* @example
|
|
21
|
+
* borderWidth='2'
|
|
22
|
+
* borderWidth='1 2 3 4'
|
|
23
|
+
*/
|
|
24
|
+
borderWidth?: SpaceDelimitedAttribute<"0" | "1" | "2" | "3" | "4" | "5">;
|
|
25
|
+
/** Spacing around children. Accepts a spacing token or an object of spacing tokens for different breakpoints.
|
|
26
|
+
* @example
|
|
27
|
+
* padding='4'
|
|
28
|
+
* padding={{xs: '2', sm: '3', md: '4', lg: '5', xl: '6'}}
|
|
29
|
+
*/
|
|
30
|
+
padding?: ResponsiveProp<SpacingScale>;
|
|
31
|
+
/** Horizontal padding around children. Accepts a spacing token or an object of spacing tokens for different breakpoints.
|
|
32
|
+
* @example
|
|
33
|
+
* paddingInline='4'
|
|
34
|
+
* paddingInline='4 5'
|
|
35
|
+
* paddingInline={{xs: '0 32', sm: '3', md: '4 5', lg: '5', xl: '6'}}
|
|
36
|
+
*/
|
|
37
|
+
paddingInline?: ResponsiveProp<SpacingScale | `${SpacingScale} ${SpacingScale}`>;
|
|
38
|
+
/** Vertical padding around children. Accepts a spacing token or an object of spacing tokens for different breakpoints.
|
|
39
|
+
* @example
|
|
40
|
+
* paddingBlock='4'
|
|
41
|
+
* paddingBlock='4 5'
|
|
42
|
+
* paddingBlock={{xs: '2', sm: '3', md: '4', lg: '5', xl: '6'}}
|
|
43
|
+
*/
|
|
44
|
+
paddingBlock?: ResponsiveProp<SpacingScale | `${SpacingScale} ${SpacingScale}`>;
|
|
45
|
+
/** Shadow on box. Accepts a shadow token.
|
|
46
|
+
* @example
|
|
47
|
+
* shadow='small'
|
|
48
|
+
*/
|
|
49
|
+
shadow?: ShadowToken;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Foundational Layout-primitive for generic encapsulation & styling.
|
|
53
|
+
*
|
|
54
|
+
* @see [📝 Documentation](https://aksel.nav.no/komponenter/primitives/box)
|
|
55
|
+
* @see 🏷️ {@link BoxProps}
|
|
56
|
+
* @see [🤖 OverridableComponent](https://aksel.nav.no/grunnleggende/kode/overridablecomponent) support
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* <Box padding="4">
|
|
60
|
+
* <BodyShort>Hei</BodyShort>
|
|
61
|
+
* </Box>
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* <Box padding={{xs: '2', sm: '3', md: '4', lg: '5', xl: '6'}}>
|
|
65
|
+
* <BodyShort>Hei</BodyShort>
|
|
66
|
+
* </Box>
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* <VStack gap="8">
|
|
70
|
+
* <Box padding="4">
|
|
71
|
+
* <BodyShort>Hei</BodyShort>
|
|
72
|
+
* </Box>
|
|
73
|
+
* <Box padding="4">
|
|
74
|
+
* <BodyShort>Hei</BodyShort>
|
|
75
|
+
* </Box>
|
|
76
|
+
* </VStack>
|
|
77
|
+
*/
|
|
78
|
+
export declare const Box: OverridableComponent<BoxProps, HTMLDivElement>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import cl from "clsx";
|
|
13
|
+
import React, { forwardRef } from "react";
|
|
14
|
+
import { getResponsiveProps, } from "../utilities/css";
|
|
15
|
+
/**
|
|
16
|
+
* Foundational Layout-primitive for generic encapsulation & styling.
|
|
17
|
+
*
|
|
18
|
+
* @see [📝 Documentation](https://aksel.nav.no/komponenter/primitives/box)
|
|
19
|
+
* @see 🏷️ {@link BoxProps}
|
|
20
|
+
* @see [🤖 OverridableComponent](https://aksel.nav.no/grunnleggende/kode/overridablecomponent) support
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* <Box padding="4">
|
|
24
|
+
* <BodyShort>Hei</BodyShort>
|
|
25
|
+
* </Box>
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* <Box padding={{xs: '2', sm: '3', md: '4', lg: '5', xl: '6'}}>
|
|
29
|
+
* <BodyShort>Hei</BodyShort>
|
|
30
|
+
* </Box>
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* <VStack gap="8">
|
|
34
|
+
* <Box padding="4">
|
|
35
|
+
* <BodyShort>Hei</BodyShort>
|
|
36
|
+
* </Box>
|
|
37
|
+
* <Box padding="4">
|
|
38
|
+
* <BodyShort>Hei</BodyShort>
|
|
39
|
+
* </Box>
|
|
40
|
+
* </VStack>
|
|
41
|
+
*/
|
|
42
|
+
export const Box = forwardRef((_a, ref) => {
|
|
43
|
+
var { as: Component = "div", background, borderColor, borderWidth, borderRadius, className, padding, paddingInline, paddingBlock, shadow, style: _style } = _a, rest = __rest(_a, ["as", "background", "borderColor", "borderWidth", "borderRadius", "className", "padding", "paddingInline", "paddingBlock", "shadow", "style"]);
|
|
44
|
+
const style = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, _style), { "--__ac-box-background": background
|
|
45
|
+
? `var(--a-${background})`
|
|
46
|
+
: undefined, "--__ac-box-shadow": shadow ? `var(--a-shadow-${shadow})` : undefined, "--__ac-box-border-color": borderColor
|
|
47
|
+
? `var(--a-${borderColor})`
|
|
48
|
+
: undefined, "--__ac-box-border-width": borderWidth
|
|
49
|
+
? borderWidth
|
|
50
|
+
.split(" ")
|
|
51
|
+
.map((x) => `${x}px`)
|
|
52
|
+
.join(" ")
|
|
53
|
+
: undefined }), getResponsiveProps("box", "border-radius", "border-radius", borderRadius, ["0"])), getResponsiveProps("box", "padding", "spacing", padding)), getResponsiveProps("box", "padding-inline", "spacing", paddingInline)), getResponsiveProps("box", "padding-block", "spacing", paddingBlock));
|
|
54
|
+
return (React.createElement(Component, Object.assign({}, rest, { className: cl("navds-box", className), ref: ref, style: style })));
|
|
55
|
+
});
|
|
56
|
+
//# sourceMappingURL=Box.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Box.js","sourceRoot":"","sources":["../../../src/layout/box/Box.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,EAIL,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAyD1B;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,MAAM,GAAG,GAAmD,UAAU,CAC3E,CACE,EAaC,EACD,GAAG,EACH,EAAE;QAfF,EACE,EAAE,EAAE,SAAS,GAAG,KAAK,EACrB,UAAU,EACV,WAAW,EACX,WAAW,EACX,YAAY,EACZ,SAAS,EACT,OAAO,EACP,aAAa,EACb,YAAY,EACZ,MAAM,EACN,KAAK,EAAE,MAAM,OAEd,EADI,IAAI,cAZT,8IAaC,CADQ;IAIT,MAAM,KAAK,2FACN,MAAM,KACT,uBAAuB,EAAE,UAAU;YACjC,CAAC,CAAC,WAAW,UAAU,GAAG;YAC1B,CAAC,CAAC,SAAS,EACb,mBAAmB,EAAE,MAAM,CAAC,CAAC,CAAC,kBAAkB,MAAM,GAAG,CAAC,CAAC,CAAC,SAAS,EACrE,yBAAyB,EAAE,WAAW;YACpC,CAAC,CAAC,WAAW,WAAW,GAAG;YAC3B,CAAC,CAAC,SAAS,EACb,yBAAyB,EAAE,WAAW;YACpC,CAAC,CAAC,WAAW;iBACR,KAAK,CAAC,GAAG,CAAC;iBACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC;iBACpB,IAAI,CAAC,GAAG,CAAC;YACd,CAAC,CAAC,SAAS,KACV,kBAAkB,CACnB,KAAK,EACL,eAAe,EACf,eAAe,EACf,YAAY,EACZ,CAAC,GAAG,CAAC,CACN,GACE,kBAAkB,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,GACxD,kBAAkB,CAAC,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,aAAa,CAAC,GACrE,kBAAkB,CAAC,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,YAAY,CAAC,CACvE,CAAC;IAEF,OAAO,CACL,oBAAC,SAAS,oBACJ,IAAI,IACR,SAAS,EAAE,EAAE,CAAC,WAAW,EAAE,SAAS,CAAC,EACrC,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,IACZ,CACH,CAAC;AACJ,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Box, type BoxProps } from "./Box";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/layout/box/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAiB,MAAM,OAAO,CAAC"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export type BreakpointsAlias = "xs" | "sm" | "md" | "lg" | "xl";
|
|
2
2
|
export type SpacingScale = "0" | "05" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "10" | "11" | "12" | "14" | "16" | "18" | "20" | "24" | "32";
|
|
3
|
-
type
|
|
3
|
+
export type SpaceDelimitedAttribute<T extends string> = T | `${T} ${T}` | `${T} ${T} ${T}` | `${T} ${T} ${T} ${T}`;
|
|
4
|
+
type FixedResponsiveT<T> = {
|
|
4
5
|
[Breakpoint in BreakpointsAlias]?: T;
|
|
5
6
|
};
|
|
6
|
-
export type ResponsiveProp<T> = T |
|
|
7
|
-
export
|
|
8
|
-
export declare function getResponsiveProps<T = string>(componentName: string, componentProp: string, tokenSubgroup: string, responsiveProp?: ResponsiveProp<T>): {
|
|
9
|
-
[x: string]: string;
|
|
10
|
-
};
|
|
11
|
-
export declare function getResponsiveValue<T = string>(componentName: string, componentProp: string, responsiveProp?: ResponsiveValue<T>): {
|
|
7
|
+
export type ResponsiveProp<T> = T | FixedResponsiveT<T>;
|
|
8
|
+
export declare function getResponsiveValue<T = string>(componentName: string, componentProp: string, responsiveProp?: ResponsiveProp<T>): {
|
|
12
9
|
[k: string]: T;
|
|
13
10
|
};
|
|
11
|
+
export declare function getResponsiveProps<T extends string>(componentName: string, componentProp: string, tokenSubgroup: string, responsiveProp?: ResponsiveProp<T>, tokenExceptions?: string[]): {
|
|
12
|
+
[x: string]: string;
|
|
13
|
+
};
|
|
14
14
|
export {};
|
|
@@ -1,29 +1,37 @@
|
|
|
1
|
-
export function
|
|
1
|
+
export function getResponsiveValue(componentName, componentProp, responsiveProp) {
|
|
2
2
|
if (!responsiveProp) {
|
|
3
3
|
return {};
|
|
4
4
|
}
|
|
5
5
|
if (typeof responsiveProp === "string") {
|
|
6
6
|
return {
|
|
7
|
-
[`--__ac-${componentName}-${componentProp}-xs`]:
|
|
7
|
+
[`--__ac-${componentName}-${componentProp}-xs`]: responsiveProp,
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
|
-
return Object.fromEntries(Object.entries(responsiveProp).map(([breakpointAlias,
|
|
10
|
+
return Object.fromEntries(Object.entries(responsiveProp).map(([breakpointAlias, responsiveValue]) => [
|
|
11
11
|
`--__ac-${componentName}-${componentProp}-${breakpointAlias}`,
|
|
12
|
-
|
|
12
|
+
responsiveValue,
|
|
13
13
|
]));
|
|
14
14
|
}
|
|
15
|
-
export function
|
|
15
|
+
export function getResponsiveProps(componentName, componentProp, tokenSubgroup, responsiveProp, tokenExceptions = []) {
|
|
16
16
|
if (!responsiveProp) {
|
|
17
17
|
return {};
|
|
18
18
|
}
|
|
19
19
|
if (typeof responsiveProp === "string") {
|
|
20
20
|
return {
|
|
21
|
-
[`--__ac-${componentName}-${componentProp}-xs`]: responsiveProp
|
|
21
|
+
[`--__ac-${componentName}-${componentProp}-xs`]: responsiveProp
|
|
22
|
+
.split(" ")
|
|
23
|
+
.map((x) => tokenExceptions.includes(x) ? x : `var(--a-${tokenSubgroup}-${x})`)
|
|
24
|
+
.join(" "),
|
|
22
25
|
};
|
|
23
26
|
}
|
|
24
|
-
return Object.fromEntries(Object.entries(responsiveProp).map(([breakpointAlias,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
return Object.fromEntries(Object.entries(responsiveProp).map(([breakpointAlias, aliasOrScale]) => {
|
|
28
|
+
return [
|
|
29
|
+
`--__ac-${componentName}-${componentProp}-${breakpointAlias}`,
|
|
30
|
+
aliasOrScale
|
|
31
|
+
.split(" ")
|
|
32
|
+
.map((x) => tokenExceptions.includes(x) ? x : `var(--a-${tokenSubgroup}-${x})`)
|
|
33
|
+
.join(" "),
|
|
34
|
+
];
|
|
35
|
+
}));
|
|
28
36
|
}
|
|
29
37
|
//# sourceMappingURL=css.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"css.js","sourceRoot":"","sources":["../../../src/layout/utilities/css.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"css.js","sourceRoot":"","sources":["../../../src/layout/utilities/css.ts"],"names":[],"mappings":"AAqCA,MAAM,UAAU,kBAAkB,CAChC,aAAqB,EACrB,aAAqB,EACrB,cAAkC;IAElC,IAAI,CAAC,cAAc,EAAE;QACnB,OAAO,EAAE,CAAC;KACX;IAED,IAAI,OAAO,cAAc,KAAK,QAAQ,EAAE;QACtC,OAAO;YACL,CAAC,UAAU,aAAa,IAAI,aAAa,KAAK,CAAC,EAAE,cAAc;SAChE,CAAC;KACH;IAED,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,eAAe,EAA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ds-tokens/src/colors-surface.json";
|
|
3
|
+
import borderColors from "@navikt/ds-tokens/src/colors-border.json";
|
|
4
|
+
import borderRadii from "@navikt/ds-tokens/src/border.json";
|
|
5
|
+
import shadows from "@navikt/ds-tokens/src/shadow.json";
|
|
6
|
+
export type BackgroundToken = keyof typeof bgColors.a | keyof typeof surfaceColors.a;
|
|
7
|
+
export type BorderColorToken = keyof typeof borderColors.a;
|
|
8
|
+
export type BorderRadiiToken = keyof (typeof borderRadii.a)["border-radius"] | "0";
|
|
9
|
+
export type ShadowToken = keyof typeof shadows.a.shadow;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/layout/utilities/types.ts"],"names":[],"mappings":""}
|
package/esm/skeleton/Skeleton.js
CHANGED
|
@@ -26,6 +26,7 @@ export const Skeleton = forwardRef((_a, ref) => {
|
|
|
26
26
|
"navds-skeleton--has-children": Boolean(children),
|
|
27
27
|
"navds-skeleton--no-height": !height,
|
|
28
28
|
"navds-skeleton--no-width": !width,
|
|
29
|
+
"navds-skeleton--inline": As === "span",
|
|
29
30
|
}), style: Object.assign(Object.assign({}, style), { width, height }), "aria-hidden": true }), children));
|
|
30
31
|
});
|
|
31
32
|
export default Skeleton;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Skeleton.js","sourceRoot":"","sources":["../../src/skeleton/Skeleton.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,MAAM,MAAM,CAAC;AAuBtB;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAChC,CACE,EASC,EACD,GAAG,EACH,EAAE;QAXF,EACE,SAAS,EACT,QAAQ,EACR,MAAM,EACN,KAAK,EACL,KAAK,EACL,OAAO,GAAG,MAAM,EAChB,EAAE,EAAE,EAAE,GAAG,KAAK,OAEf,EADI,IAAI,cART,sEASC,CADQ;IAIT,OAAO,CACL,oBAAC,EAAE,oBACG,IAAI,IACR,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CACX,gBAAgB,EAChB,SAAS,EACT,mBAAmB,OAAO,EAAE,EAC5B;YACE,8BAA8B,EAAE,OAAO,CAAC,QAAQ,CAAC;YACjD,2BAA2B,EAAE,CAAC,MAAM;YACpC,0BAA0B,EAAE,CAAC,KAAK;
|
|
1
|
+
{"version":3,"file":"Skeleton.js","sourceRoot":"","sources":["../../src/skeleton/Skeleton.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,MAAM,MAAM,CAAC;AAuBtB;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAChC,CACE,EASC,EACD,GAAG,EACH,EAAE;QAXF,EACE,SAAS,EACT,QAAQ,EACR,MAAM,EACN,KAAK,EACL,KAAK,EACL,OAAO,GAAG,MAAM,EAChB,EAAE,EAAE,EAAE,GAAG,KAAK,OAEf,EADI,IAAI,cART,sEASC,CADQ;IAIT,OAAO,CACL,oBAAC,EAAE,oBACG,IAAI,IACR,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CACX,gBAAgB,EAChB,SAAS,EACT,mBAAmB,OAAO,EAAE,EAC5B;YACE,8BAA8B,EAAE,OAAO,CAAC,QAAQ,CAAC;YACjD,2BAA2B,EAAE,CAAC,MAAM;YACpC,0BAA0B,EAAE,CAAC,KAAK;YAClC,wBAAwB,EAAE,EAAE,KAAK,MAAM;SACxC,CACF,EACD,KAAK,kCAAO,KAAK,KAAE,KAAK,EAAE,MAAM,6BAG/B,QAAQ,CACN,CACN,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navikt/ds-react",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.5.0",
|
|
4
4
|
"description": "Aksel react-components for NAV designsystem",
|
|
5
5
|
"author": "Aksel | NAV designsystem team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@floating-ui/react": "0.24.1",
|
|
41
|
-
"@navikt/aksel-icons": "^5.
|
|
41
|
+
"@navikt/aksel-icons": "^5.5.0",
|
|
42
|
+
"@navikt/ds-tokens": "^5.5.0",
|
|
42
43
|
"@radix-ui/react-tabs": "1.0.0",
|
|
43
44
|
"@radix-ui/react-toggle-group": "1.0.0",
|
|
44
45
|
"clsx": "^1.2.1",
|
package/src/index.ts
CHANGED
|
@@ -32,6 +32,7 @@ export * from "./toggle-group";
|
|
|
32
32
|
export * from "./tooltip";
|
|
33
33
|
export * from "./typography";
|
|
34
34
|
export * from "./util";
|
|
35
|
+
export * from "./layout/box";
|
|
35
36
|
export * from "./layout/stack";
|
|
36
37
|
export * from "./layout/grid";
|
|
37
38
|
export * from "./layout/content-container";
|