@navikt/ds-react 5.9.2 → 5.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/_docs.json CHANGED
@@ -17323,6 +17323,151 @@
17323
17323
  }
17324
17324
  }
17325
17325
  },
17326
+ {
17327
+ "filePath": "src/layout/page/Page.tsx",
17328
+ "displayName": "PageComponent",
17329
+ "props": {
17330
+ "as": {
17331
+ "defaultValue": {
17332
+ "value": "\"div\""
17333
+ },
17334
+ "description": "Overrides html-tag",
17335
+ "name": "as",
17336
+ "parent": {
17337
+ "fileName": "src/layout/page/Page.tsx",
17338
+ "name": "PageProps"
17339
+ },
17340
+ "declarations": [
17341
+ {
17342
+ "fileName": "src/layout/page/Page.tsx",
17343
+ "name": "PageProps"
17344
+ }
17345
+ ],
17346
+ "required": false,
17347
+ "type": {
17348
+ "name": "\"div\" | \"body\""
17349
+ }
17350
+ },
17351
+ "background": {
17352
+ "defaultValue": {
17353
+ "value": "bg-default"
17354
+ },
17355
+ "description": "Background color. Accepts a color token.",
17356
+ "name": "background",
17357
+ "parent": {
17358
+ "fileName": "src/layout/page/Page.tsx",
17359
+ "name": "PageProps"
17360
+ },
17361
+ "declarations": [
17362
+ {
17363
+ "fileName": "src/layout/page/Page.tsx",
17364
+ "name": "PageProps"
17365
+ }
17366
+ ],
17367
+ "required": false,
17368
+ "type": {
17369
+ "name": "\"bg-default\" | \"bg-subtle\""
17370
+ }
17371
+ },
17372
+ "footer": {
17373
+ "defaultValue": null,
17374
+ "description": "Allows better positioning of footer",
17375
+ "name": "footer",
17376
+ "parent": {
17377
+ "fileName": "src/layout/page/Page.tsx",
17378
+ "name": "PageProps"
17379
+ },
17380
+ "declarations": [
17381
+ {
17382
+ "fileName": "src/layout/page/Page.tsx",
17383
+ "name": "PageProps"
17384
+ }
17385
+ ],
17386
+ "required": false,
17387
+ "type": {
17388
+ "name": "ReactNode"
17389
+ }
17390
+ },
17391
+ "footerPosition": {
17392
+ "defaultValue": null,
17393
+ "description": "Places footer below page-fold",
17394
+ "name": "footerPosition",
17395
+ "parent": {
17396
+ "fileName": "src/layout/page/Page.tsx",
17397
+ "name": "PageProps"
17398
+ },
17399
+ "declarations": [
17400
+ {
17401
+ "fileName": "src/layout/page/Page.tsx",
17402
+ "name": "PageProps"
17403
+ }
17404
+ ],
17405
+ "required": false,
17406
+ "type": {
17407
+ "name": "\"belowFold\""
17408
+ }
17409
+ },
17410
+ "contentBlockPadding": {
17411
+ "defaultValue": {
17412
+ "value": "end"
17413
+ },
17414
+ "description": "Adds a standardised padding of 4rem between content and footer",
17415
+ "name": "contentBlockPadding",
17416
+ "parent": {
17417
+ "fileName": "src/layout/page/Page.tsx",
17418
+ "name": "PageProps"
17419
+ },
17420
+ "declarations": [
17421
+ {
17422
+ "fileName": "src/layout/page/Page.tsx",
17423
+ "name": "PageProps"
17424
+ }
17425
+ ],
17426
+ "required": false,
17427
+ "type": {
17428
+ "name": "\"end\" | \"none\""
17429
+ }
17430
+ },
17431
+ "className": {
17432
+ "defaultValue": null,
17433
+ "description": "",
17434
+ "name": "className",
17435
+ "parent": {
17436
+ "fileName": "aksel/node_modules/@types/react/index.d.ts",
17437
+ "name": "HTMLAttributes"
17438
+ },
17439
+ "declarations": [
17440
+ {
17441
+ "fileName": "aksel/node_modules/@types/react/index.d.ts",
17442
+ "name": "HTMLAttributes"
17443
+ }
17444
+ ],
17445
+ "required": false,
17446
+ "type": {
17447
+ "name": "string"
17448
+ }
17449
+ },
17450
+ "ref": {
17451
+ "defaultValue": null,
17452
+ "description": "Allows getting a ref to the component instance.\nOnce the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref).\n@see https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom",
17453
+ "name": "ref",
17454
+ "parent": {
17455
+ "fileName": "aksel/node_modules/@types/react/index.d.ts",
17456
+ "name": "RefAttributes"
17457
+ },
17458
+ "declarations": [
17459
+ {
17460
+ "fileName": "aksel/node_modules/@types/react/index.d.ts",
17461
+ "name": "RefAttributes"
17462
+ }
17463
+ ],
17464
+ "required": false,
17465
+ "type": {
17466
+ "name": "Ref<HTMLElement>"
17467
+ }
17468
+ }
17469
+ }
17470
+ },
17326
17471
  {
17327
17472
  "filePath": "src/layout/responsive/Responsive.tsx",
17328
17473
  "displayName": "Hide",
@@ -19162,6 +19307,92 @@
19162
19307
  }
19163
19308
  }
19164
19309
  },
19310
+ {
19311
+ "filePath": "src/layout/page/parts/PageBlock.tsx",
19312
+ "displayName": "PageBlock",
19313
+ "props": {
19314
+ "width": {
19315
+ "defaultValue": {
19316
+ "value": "max-width: 100%;"
19317
+ },
19318
+ "description": "Predefined max-width\n@example lg: 1024px\nxl: 1280px\n2xl: 1440px",
19319
+ "name": "width",
19320
+ "parent": {
19321
+ "fileName": "src/layout/page/parts/PageBlock.tsx",
19322
+ "name": "PageBlockProps"
19323
+ },
19324
+ "declarations": [
19325
+ {
19326
+ "fileName": "src/layout/page/parts/PageBlock.tsx",
19327
+ "name": "PageBlockProps"
19328
+ }
19329
+ ],
19330
+ "required": false,
19331
+ "type": {
19332
+ "name": "\"lg\" | \"xl\" | \"2xl\""
19333
+ }
19334
+ },
19335
+ "gutters": {
19336
+ "defaultValue": {
19337
+ "value": "false"
19338
+ },
19339
+ "description": "Adds a standardised responsive padding-inline\n@example 3rem on > md\n1rem on < md",
19340
+ "name": "gutters",
19341
+ "parent": {
19342
+ "fileName": "src/layout/page/parts/PageBlock.tsx",
19343
+ "name": "PageBlockProps"
19344
+ },
19345
+ "declarations": [
19346
+ {
19347
+ "fileName": "src/layout/page/parts/PageBlock.tsx",
19348
+ "name": "PageBlockProps"
19349
+ }
19350
+ ],
19351
+ "required": false,
19352
+ "type": {
19353
+ "name": "boolean"
19354
+ }
19355
+ },
19356
+ "className": {
19357
+ "defaultValue": null,
19358
+ "description": "",
19359
+ "name": "className",
19360
+ "parent": {
19361
+ "fileName": "aksel/node_modules/@types/react/index.d.ts",
19362
+ "name": "HTMLAttributes"
19363
+ },
19364
+ "declarations": [
19365
+ {
19366
+ "fileName": "aksel/node_modules/@types/react/index.d.ts",
19367
+ "name": "HTMLAttributes"
19368
+ }
19369
+ ],
19370
+ "required": false,
19371
+ "type": {
19372
+ "name": "string"
19373
+ }
19374
+ },
19375
+ "ref": {
19376
+ "defaultValue": null,
19377
+ "description": "Allows getting a ref to the component instance.\nOnce the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref).\n@see https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom",
19378
+ "name": "ref",
19379
+ "parent": {
19380
+ "fileName": "aksel/node_modules/@types/react/index.d.ts",
19381
+ "name": "RefAttributes"
19382
+ },
19383
+ "declarations": [
19384
+ {
19385
+ "fileName": "aksel/node_modules/@types/react/index.d.ts",
19386
+ "name": "RefAttributes"
19387
+ }
19388
+ ],
19389
+ "required": false,
19390
+ "type": {
19391
+ "name": "Ref<HTMLDivElement>"
19392
+ }
19393
+ }
19394
+ }
19395
+ },
19165
19396
  {
19166
19397
  "filePath": "src/layout/sidemal-test/content-box/ContentBox.tsx",
19167
19398
  "displayName": "ContentBox",
package/cjs/index.js CHANGED
@@ -54,3 +54,4 @@ __exportStar(require("./layout/stack"), exports);
54
54
  __exportStar(require("./layout/grid"), exports);
55
55
  __exportStar(require("./layout/content-container"), exports);
56
56
  __exportStar(require("./layout/responsive"), exports);
57
+ __exportStar(require("./layout/page"), exports);
@@ -0,0 +1,86 @@
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.PageComponent = void 0;
41
+ const clsx_1 = __importDefault(require("clsx"));
42
+ const react_1 = __importStar(require("react"));
43
+ const PageBlock_1 = require("./parts/PageBlock");
44
+ exports.PageComponent = (0, react_1.forwardRef)((_a, ref) => {
45
+ var { as: Component = "div", className, style: _style, footer, children, footerPosition, background = "bg-default", contentBlockPadding = "end" } = _a, rest = __rest(_a, ["as", "className", "style", "footer", "children", "footerPosition", "background", "contentBlockPadding"]);
46
+ const style = Object.assign(Object.assign({}, _style), { "--__ac-page-background": `var(--a-${background})` });
47
+ const belowFold = footerPosition === "belowFold";
48
+ return (react_1.default.createElement(Component, Object.assign({}, rest, { className: (0, clsx_1.default)("navds-page", className), ref: ref, style: style }),
49
+ react_1.default.createElement("div", { className: (0, clsx_1.default)({
50
+ "navds-page__content--fullheight": belowFold,
51
+ "navds-page__content--grow": !belowFold,
52
+ "navds-page__content--padding": contentBlockPadding === "end",
53
+ }) }, children),
54
+ footer));
55
+ });
56
+ /**
57
+ * Page helps with establishing a top-level layout for your page
58
+ *
59
+ * @see [📝 Documentation](https://aksel.nav.no/komponenter/primitives/page)
60
+ * @see 🏷️ {@link PageProps}
61
+ * @see [🤖 OverridableComponent](https://aksel.nav.no/grunnleggende/kode/overridablecomponent) support
62
+ *
63
+ * @example
64
+ * ```jsx
65
+ * <Page
66
+ * footer={<Page.Block width="xl" gutters />}
67
+ * >
68
+ * <Page.Block width="xl" gutters />// Header
69
+ * <Page.Block width="xl" gutters />// Content
70
+ * </Page>
71
+ * ```
72
+ * @example
73
+ * Footer placed below page-fold
74
+ * ```jsx
75
+ * <Page
76
+ * footer={<Page.Block width="xl" gutters />}
77
+ * footerPosition="belowFold"
78
+ * >
79
+ * <Page.Block width="xl" gutters />// Header
80
+ * <Page.Block width="xl" gutters />// Content
81
+ * </Page>
82
+ * ```
83
+ */
84
+ const Page = exports.PageComponent;
85
+ Page.Block = PageBlock_1.PageBlock;
86
+ exports.default = Page;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Page = void 0;
7
+ var Page_1 = require("./Page");
8
+ Object.defineProperty(exports, "Page", { enumerable: true, get: function () { return __importDefault(Page_1).default; } });
@@ -0,0 +1,6 @@
1
+ {
2
+ "sideEffects": false,
3
+ "main": "./index.js",
4
+ "module": "../../../esm/layout/page/index.js",
5
+ "types": "../../../esm/layout/page/index.d.ts"
6
+ }
@@ -0,0 +1,76 @@
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.PageBlock = exports.widths = void 0;
41
+ const clsx_1 = __importDefault(require("clsx"));
42
+ const react_1 = __importStar(require("react"));
43
+ exports.widths = ["lg", "xl", "2xl"];
44
+ /**
45
+ * Acts as a top-level container for defining max-width, gutters and horizontal centering
46
+ *
47
+ * @see [📝 Documentation](https://aksel.nav.no/komponenter/primitives/page)
48
+ * @see 🏷️ {@link PageBlockProps}
49
+ * @see [🤖 OverridableComponent](https://aksel.nav.no/grunnleggende/kode/overridablecomponent) support
50
+ *
51
+ * @example
52
+ * ```jsx
53
+ * <Page
54
+ * footer={<Page.Block width="xl" gutters />}
55
+ * >
56
+ * <Page.Block width="xl" gutters />// Header
57
+ * <Page.Block width="xl" gutters />// Content
58
+ * </Page>
59
+ * ```
60
+ * @example
61
+ * With background bleed
62
+ * Wrapping `Page.Block` with `Box` allows the background-color to use full screen-width
63
+ * ```jsx
64
+ * <Page
65
+ * footer={<Box background="..."><Page.Block width="xl" gutters /></Box>}
66
+ * footerPosition="belowFold"
67
+ * >
68
+ * <Box background="..."><Page.Block width="xl" gutters /></Box>//Header
69
+ * <Box background="..."><Page.Block width="xl" gutters /></Box>//Content
70
+ * </Page>
71
+ * ```
72
+ */
73
+ exports.PageBlock = (0, react_1.forwardRef)((_a, ref) => {
74
+ var { as: Component = "div", gutters, className, width } = _a, rest = __rest(_a, ["as", "gutters", "className", "width"]);
75
+ return (react_1.default.createElement(Component, Object.assign({}, rest, { className: (0, clsx_1.default)("navds-pageblock", `navds-pageblock--${width}`, className, { "navds-pageblock--gutters": gutters }), ref: ref })));
76
+ });
@@ -57,11 +57,7 @@ exports.ExpandableRow = (0, react_1.forwardRef)((_a, ref) => {
57
57
  }
58
58
  e.stopPropagation();
59
59
  };
60
- const onRowClick = (e) => {
61
- if (e.target.nodeName === "TD" || e.target.nodeName === "TH") {
62
- expansionHandler(e);
63
- }
64
- };
60
+ const onRowClick = (e) => !isInteractiveTarget(e.target) && expansionHandler(e);
65
61
  return (react_1.default.createElement(react_1.default.Fragment, null,
66
62
  react_1.default.createElement(Row_1.default, Object.assign({}, rest, { ref: ref, className: (0, clsx_1.default)("navds-table__expandable-row", className, {
67
63
  "navds-table__expandable-row--open": isOpen,
@@ -82,4 +78,13 @@ exports.ExpandableRow = (0, react_1.forwardRef)((_a, ref) => {
82
78
  react_1.default.createElement("td", { colSpan: colSpan, className: "navds-table__expanded-row-cell" },
83
79
  react_1.default.createElement(AnimateHeight_1.default, { className: "navds-table__expanded-row-collapse", innerClassName: "navds-table__expanded-row-content", height: isOpen ? "auto" : 0, duration: 250 }, content)))));
84
80
  });
81
+ function isInteractiveTarget(elm) {
82
+ if (elm.nodeName === "TD" || elm.nodeName === "TH" || !elm.parentElement) {
83
+ return false;
84
+ }
85
+ if (["BUTTON", "DETAILS", "LABEL", "SELECT", "TEXTAREA", "INPUT", "A"].includes(elm.nodeName)) {
86
+ return true;
87
+ }
88
+ return isInteractiveTarget(elm.parentElement);
89
+ }
85
90
  exports.default = exports.ExpandableRow;
package/esm/index.d.ts CHANGED
@@ -38,3 +38,4 @@ export * from "./layout/stack";
38
38
  export * from "./layout/grid";
39
39
  export * from "./layout/content-container";
40
40
  export * from "./layout/responsive";
41
+ export * from "./layout/page";
package/esm/index.js CHANGED
@@ -38,4 +38,5 @@ export * from "./layout/stack";
38
38
  export * from "./layout/grid";
39
39
  export * from "./layout/content-container";
40
40
  export * from "./layout/responsive";
41
+ export * from "./layout/page";
41
42
  //# sourceMappingURL=index.js.map
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,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,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,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC"}
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,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,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,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC"}
@@ -0,0 +1,63 @@
1
+ import bgColors from "@navikt/ds-tokens/src/colors-bg.json";
2
+ import React from "react";
3
+ import { OverridableComponent } from "../../util";
4
+ import { PageBlock } from "./parts/PageBlock";
5
+ export interface PageProps extends React.HTMLAttributes<HTMLElement> {
6
+ /**
7
+ * Overrides html-tag
8
+ * @default "div"
9
+ */
10
+ as?: "div" | "body";
11
+ /**
12
+ * Background color. Accepts a color token.
13
+ * @default bg-default
14
+ */
15
+ background?: keyof typeof bgColors.a;
16
+ /**
17
+ * Allows better positioning of footer
18
+ */
19
+ footer?: React.ReactNode;
20
+ /**
21
+ * Places footer below page-fold
22
+ */
23
+ footerPosition?: "belowFold";
24
+ /**
25
+ * Adds a standardised padding of 4rem between content and footer
26
+ * @default block-end
27
+ */
28
+ contentBlockPadding?: "end" | "none";
29
+ }
30
+ interface PageComponentType extends OverridableComponent<PageProps, HTMLElement> {
31
+ Block: typeof PageBlock;
32
+ }
33
+ export declare const PageComponent: OverridableComponent<PageProps, HTMLElement>;
34
+ /**
35
+ * Page helps with establishing a top-level layout for your page
36
+ *
37
+ * @see [📝 Documentation](https://aksel.nav.no/komponenter/primitives/page)
38
+ * @see 🏷️ {@link PageProps}
39
+ * @see [🤖 OverridableComponent](https://aksel.nav.no/grunnleggende/kode/overridablecomponent) support
40
+ *
41
+ * @example
42
+ * ```jsx
43
+ * <Page
44
+ * footer={<Page.Block width="xl" gutters />}
45
+ * >
46
+ * <Page.Block width="xl" gutters />// Header
47
+ * <Page.Block width="xl" gutters />// Content
48
+ * </Page>
49
+ * ```
50
+ * @example
51
+ * Footer placed below page-fold
52
+ * ```jsx
53
+ * <Page
54
+ * footer={<Page.Block width="xl" gutters />}
55
+ * footerPosition="belowFold"
56
+ * >
57
+ * <Page.Block width="xl" gutters />// Header
58
+ * <Page.Block width="xl" gutters />// Content
59
+ * </Page>
60
+ * ```
61
+ */
62
+ declare const Page: PageComponentType;
63
+ export default Page;
@@ -0,0 +1,58 @@
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 { PageBlock } from "./parts/PageBlock";
15
+ export const PageComponent = forwardRef((_a, ref) => {
16
+ var { as: Component = "div", className, style: _style, footer, children, footerPosition, background = "bg-default", contentBlockPadding = "end" } = _a, rest = __rest(_a, ["as", "className", "style", "footer", "children", "footerPosition", "background", "contentBlockPadding"]);
17
+ const style = Object.assign(Object.assign({}, _style), { "--__ac-page-background": `var(--a-${background})` });
18
+ const belowFold = footerPosition === "belowFold";
19
+ return (React.createElement(Component, Object.assign({}, rest, { className: cl("navds-page", className), ref: ref, style: style }),
20
+ React.createElement("div", { className: cl({
21
+ "navds-page__content--fullheight": belowFold,
22
+ "navds-page__content--grow": !belowFold,
23
+ "navds-page__content--padding": contentBlockPadding === "end",
24
+ }) }, children),
25
+ footer));
26
+ });
27
+ /**
28
+ * Page helps with establishing a top-level layout for your page
29
+ *
30
+ * @see [📝 Documentation](https://aksel.nav.no/komponenter/primitives/page)
31
+ * @see 🏷️ {@link PageProps}
32
+ * @see [🤖 OverridableComponent](https://aksel.nav.no/grunnleggende/kode/overridablecomponent) support
33
+ *
34
+ * @example
35
+ * ```jsx
36
+ * <Page
37
+ * footer={<Page.Block width="xl" gutters />}
38
+ * >
39
+ * <Page.Block width="xl" gutters />// Header
40
+ * <Page.Block width="xl" gutters />// Content
41
+ * </Page>
42
+ * ```
43
+ * @example
44
+ * Footer placed below page-fold
45
+ * ```jsx
46
+ * <Page
47
+ * footer={<Page.Block width="xl" gutters />}
48
+ * footerPosition="belowFold"
49
+ * >
50
+ * <Page.Block width="xl" gutters />// Header
51
+ * <Page.Block width="xl" gutters />// Content
52
+ * </Page>
53
+ * ```
54
+ */
55
+ const Page = PageComponent;
56
+ Page.Block = PageBlock;
57
+ export default Page;
58
+ //# sourceMappingURL=Page.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Page.js","sourceRoot":"","sources":["../../../src/layout/page/Page.tsx"],"names":[],"mappings":";;;;;;;;;;;AACA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAiC9C,MAAM,CAAC,MAAM,aAAa,GACxB,UAAU,CACR,CACE,EAUC,EACD,GAAG,EACH,EAAE;QAZF,EACE,EAAE,EAAE,SAAS,GAAG,KAAK,EACrB,SAAS,EACT,KAAK,EAAE,MAAM,EACb,MAAM,EACN,QAAQ,EACR,cAAc,EACd,UAAU,GAAG,YAAY,EACzB,mBAAmB,GAAG,KAAK,OAE5B,EADI,IAAI,cATT,yGAUC,CADQ;IAIT,MAAM,KAAK,mCACN,MAAM,KACT,wBAAwB,EAAE,WAAW,UAAU,GAAG,GACnD,CAAC;IAEF,MAAM,SAAS,GAAG,cAAc,KAAK,WAAW,CAAC;IAEjD,OAAO,CACL,oBAAC,SAAS,oBACJ,IAAI,IACR,SAAS,EAAE,EAAE,CAAC,YAAY,EAAE,SAAS,CAAC,EACtC,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK;QAEZ,6BACE,SAAS,EAAE,EAAE,CAAC;gBACZ,iCAAiC,EAAE,SAAS;gBAC5C,2BAA2B,EAAE,CAAC,SAAS;gBACvC,8BAA8B,EAAE,mBAAmB,KAAK,KAAK;aAC9D,CAAC,IAED,QAAQ,CACL;QACL,MAAM,CACG,CACb,CAAC;AACJ,CAAC,CACF,CAAC;AAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,IAAI,GAAG,aAAkC,CAAC;AAEhD,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;AAEvB,eAAe,IAAI,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { default as Page, type PageProps } from "./Page";
2
+ export { type PageBlockProps } from "./parts/PageBlock";
@@ -0,0 +1,2 @@
1
+ export { default as Page } from "./Page";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/layout/page/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,IAAI,EAAkB,MAAM,QAAQ,CAAC"}
@@ -0,0 +1,52 @@
1
+ import React from "react";
2
+ import { OverridableComponent } from "../../../util/OverridableComponent";
3
+ export declare const widths: readonly ["lg", "xl", "2xl"];
4
+ export interface PageBlockProps extends React.HTMLAttributes<HTMLDivElement> {
5
+ /**
6
+ * Predefined max-width
7
+ * @example
8
+ * lg: 1024px
9
+ * xl: 1280px
10
+ * 2xl: 1440px
11
+ * @default max-width: 100%;
12
+ */
13
+ width?: (typeof widths)[number];
14
+ /**
15
+ * Adds a standardised responsive padding-inline
16
+ * @example
17
+ * 3rem on > md
18
+ * 1rem on < md
19
+ * @default false
20
+ */
21
+ gutters?: boolean;
22
+ }
23
+ /**
24
+ * Acts as a top-level container for defining max-width, gutters and horizontal centering
25
+ *
26
+ * @see [📝 Documentation](https://aksel.nav.no/komponenter/primitives/page)
27
+ * @see 🏷️ {@link PageBlockProps}
28
+ * @see [🤖 OverridableComponent](https://aksel.nav.no/grunnleggende/kode/overridablecomponent) support
29
+ *
30
+ * @example
31
+ * ```jsx
32
+ * <Page
33
+ * footer={<Page.Block width="xl" gutters />}
34
+ * >
35
+ * <Page.Block width="xl" gutters />// Header
36
+ * <Page.Block width="xl" gutters />// Content
37
+ * </Page>
38
+ * ```
39
+ * @example
40
+ * With background bleed
41
+ * Wrapping `Page.Block` with `Box` allows the background-color to use full screen-width
42
+ * ```jsx
43
+ * <Page
44
+ * footer={<Box background="..."><Page.Block width="xl" gutters /></Box>}
45
+ * footerPosition="belowFold"
46
+ * >
47
+ * <Box background="..."><Page.Block width="xl" gutters /></Box>//Header
48
+ * <Box background="..."><Page.Block width="xl" gutters /></Box>//Content
49
+ * </Page>
50
+ * ```
51
+ */
52
+ export declare const PageBlock: OverridableComponent<PageBlockProps, HTMLDivElement>;