@navikt/ds-react 4.7.4 → 4.8.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.
Files changed (39) hide show
  1. package/_docs.json +367 -0
  2. package/cjs/index.js +1 -0
  3. package/cjs/layout/stack/HStack.js +51 -0
  4. package/cjs/layout/stack/Spacer.js +21 -0
  5. package/cjs/layout/stack/Stack.js +51 -0
  6. package/cjs/layout/stack/VStack.js +51 -0
  7. package/cjs/layout/stack/index.js +9 -0
  8. package/cjs/layout/stack/package.json +6 -0
  9. package/cjs/layout/utilities/css.js +17 -0
  10. package/esm/index.d.ts +1 -0
  11. package/esm/index.js +1 -0
  12. package/esm/index.js.map +1 -1
  13. package/esm/layout/stack/HStack.d.ts +24 -0
  14. package/esm/layout/stack/HStack.js +26 -0
  15. package/esm/layout/stack/HStack.js.map +1 -0
  16. package/esm/layout/stack/Spacer.d.ts +14 -0
  17. package/esm/layout/stack/Spacer.js +15 -0
  18. package/esm/layout/stack/Spacer.js.map +1 -0
  19. package/esm/layout/stack/Stack.d.ts +26 -0
  20. package/esm/layout/stack/Stack.js +23 -0
  21. package/esm/layout/stack/Stack.js.map +1 -0
  22. package/esm/layout/stack/VStack.d.ts +24 -0
  23. package/esm/layout/stack/VStack.js +26 -0
  24. package/esm/layout/stack/VStack.js.map +1 -0
  25. package/esm/layout/stack/index.d.ts +3 -0
  26. package/esm/layout/stack/index.js +4 -0
  27. package/esm/layout/stack/index.js.map +1 -0
  28. package/esm/layout/utilities/css.d.ts +10 -0
  29. package/esm/layout/utilities/css.js +14 -0
  30. package/esm/layout/utilities/css.js.map +1 -0
  31. package/package.json +2 -2
  32. package/src/index.ts +1 -0
  33. package/src/layout/stack/HStack.tsx +30 -0
  34. package/src/layout/stack/Spacer.tsx +15 -0
  35. package/src/layout/stack/Stack.tsx +76 -0
  36. package/src/layout/stack/VStack.tsx +30 -0
  37. package/src/layout/stack/index.ts +3 -0
  38. package/src/layout/stack/stack.stories.tsx +161 -0
  39. package/src/layout/utilities/css.ts +56 -0
package/_docs.json CHANGED
@@ -16428,6 +16428,373 @@
16428
16428
  }
16429
16429
  }
16430
16430
  },
16431
+ {
16432
+ "filePath": "src/layout/stack/HStack.tsx",
16433
+ "displayName": "HStack",
16434
+ "props": {
16435
+ "justify": {
16436
+ "defaultValue": null,
16437
+ "description": "Justify-content",
16438
+ "name": "justify",
16439
+ "parent": {
16440
+ "fileName": "react/src/layout/stack/Stack.tsx",
16441
+ "name": "StackProps"
16442
+ },
16443
+ "declarations": [
16444
+ {
16445
+ "fileName": "react/src/layout/stack/Stack.tsx",
16446
+ "name": "StackProps"
16447
+ }
16448
+ ],
16449
+ "required": false,
16450
+ "type": {
16451
+ "name": "\"start\" | \"center\" | \"end\" | \"space-around\" | \"space-between\" | \"space-evenly\""
16452
+ }
16453
+ },
16454
+ "align": {
16455
+ "defaultValue": null,
16456
+ "description": "Align-items",
16457
+ "name": "align",
16458
+ "parent": {
16459
+ "fileName": "react/src/layout/stack/Stack.tsx",
16460
+ "name": "StackProps"
16461
+ },
16462
+ "declarations": [
16463
+ {
16464
+ "fileName": "react/src/layout/stack/Stack.tsx",
16465
+ "name": "StackProps"
16466
+ }
16467
+ ],
16468
+ "required": false,
16469
+ "type": {
16470
+ "name": "\"start\" | \"center\" | \"end\" | \"baseline\" | \"stretch\""
16471
+ }
16472
+ },
16473
+ "wrap": {
16474
+ "defaultValue": null,
16475
+ "description": "flex-wrap",
16476
+ "name": "wrap",
16477
+ "parent": {
16478
+ "fileName": "react/src/layout/stack/Stack.tsx",
16479
+ "name": "StackProps"
16480
+ },
16481
+ "declarations": [
16482
+ {
16483
+ "fileName": "react/src/layout/stack/Stack.tsx",
16484
+ "name": "StackProps"
16485
+ }
16486
+ ],
16487
+ "required": false,
16488
+ "type": {
16489
+ "name": "boolean"
16490
+ }
16491
+ },
16492
+ "gap": {
16493
+ "defaultValue": null,
16494
+ "description": "@example gap='4'\ngap={{xs: '2', sm: '3', md: '4', lg: '5', xl: '6'}}",
16495
+ "name": "gap",
16496
+ "parent": {
16497
+ "fileName": "react/src/layout/stack/Stack.tsx",
16498
+ "name": "StackProps"
16499
+ },
16500
+ "declarations": [
16501
+ {
16502
+ "fileName": "react/src/layout/stack/Stack.tsx",
16503
+ "name": "StackProps"
16504
+ }
16505
+ ],
16506
+ "required": false,
16507
+ "type": {
16508
+ "name": "ResponsiveProp<SpacingScale>"
16509
+ }
16510
+ },
16511
+ "className": {
16512
+ "defaultValue": null,
16513
+ "description": "",
16514
+ "name": "className",
16515
+ "parent": {
16516
+ "fileName": "aksel/node_modules/@types/react/ts5.0/index.d.ts",
16517
+ "name": "HTMLAttributes"
16518
+ },
16519
+ "declarations": [
16520
+ {
16521
+ "fileName": "aksel/node_modules/@types/react/ts5.0/index.d.ts",
16522
+ "name": "HTMLAttributes"
16523
+ }
16524
+ ],
16525
+ "required": false,
16526
+ "type": {
16527
+ "name": "string"
16528
+ }
16529
+ },
16530
+ "ref": {
16531
+ "defaultValue": null,
16532
+ "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",
16533
+ "name": "ref",
16534
+ "parent": {
16535
+ "fileName": "aksel/node_modules/@types/react/ts5.0/index.d.ts",
16536
+ "name": "RefAttributes"
16537
+ },
16538
+ "declarations": [
16539
+ {
16540
+ "fileName": "aksel/node_modules/@types/react/ts5.0/index.d.ts",
16541
+ "name": "RefAttributes"
16542
+ }
16543
+ ],
16544
+ "required": false,
16545
+ "type": {
16546
+ "name": "Ref<HTMLDivElement>"
16547
+ }
16548
+ }
16549
+ }
16550
+ },
16551
+ {
16552
+ "filePath": "src/layout/stack/Spacer.tsx",
16553
+ "displayName": "Spacer",
16554
+ "props": {}
16555
+ },
16556
+ {
16557
+ "filePath": "src/layout/stack/Stack.tsx",
16558
+ "displayName": "Stack",
16559
+ "props": {
16560
+ "justify": {
16561
+ "defaultValue": null,
16562
+ "description": "Justify-content",
16563
+ "name": "justify",
16564
+ "parent": {
16565
+ "fileName": "src/layout/stack/Stack.tsx",
16566
+ "name": "StackProps"
16567
+ },
16568
+ "declarations": [
16569
+ {
16570
+ "fileName": "src/layout/stack/Stack.tsx",
16571
+ "name": "StackProps"
16572
+ }
16573
+ ],
16574
+ "required": false,
16575
+ "type": {
16576
+ "name": "\"start\" | \"center\" | \"end\" | \"space-around\" | \"space-between\" | \"space-evenly\""
16577
+ }
16578
+ },
16579
+ "align": {
16580
+ "defaultValue": null,
16581
+ "description": "Align-items",
16582
+ "name": "align",
16583
+ "parent": {
16584
+ "fileName": "src/layout/stack/Stack.tsx",
16585
+ "name": "StackProps"
16586
+ },
16587
+ "declarations": [
16588
+ {
16589
+ "fileName": "src/layout/stack/Stack.tsx",
16590
+ "name": "StackProps"
16591
+ }
16592
+ ],
16593
+ "required": false,
16594
+ "type": {
16595
+ "name": "\"start\" | \"center\" | \"end\" | \"baseline\" | \"stretch\""
16596
+ }
16597
+ },
16598
+ "wrap": {
16599
+ "defaultValue": {
16600
+ "value": "true"
16601
+ },
16602
+ "description": "flex-wrap",
16603
+ "name": "wrap",
16604
+ "parent": {
16605
+ "fileName": "src/layout/stack/Stack.tsx",
16606
+ "name": "StackProps"
16607
+ },
16608
+ "declarations": [
16609
+ {
16610
+ "fileName": "src/layout/stack/Stack.tsx",
16611
+ "name": "StackProps"
16612
+ }
16613
+ ],
16614
+ "required": false,
16615
+ "type": {
16616
+ "name": "boolean"
16617
+ }
16618
+ },
16619
+ "gap": {
16620
+ "defaultValue": null,
16621
+ "description": "@example gap='4'\ngap={{xs: '2', sm: '3', md: '4', lg: '5', xl: '6'}}",
16622
+ "name": "gap",
16623
+ "parent": {
16624
+ "fileName": "src/layout/stack/Stack.tsx",
16625
+ "name": "StackProps"
16626
+ },
16627
+ "declarations": [
16628
+ {
16629
+ "fileName": "src/layout/stack/Stack.tsx",
16630
+ "name": "StackProps"
16631
+ }
16632
+ ],
16633
+ "required": false,
16634
+ "type": {
16635
+ "name": "ResponsiveProp<SpacingScale>"
16636
+ }
16637
+ },
16638
+ "direction": {
16639
+ "defaultValue": null,
16640
+ "description": "",
16641
+ "name": "direction",
16642
+ "parent": {
16643
+ "fileName": "src/layout/stack/Stack.tsx",
16644
+ "name": "StackProps"
16645
+ },
16646
+ "declarations": [
16647
+ {
16648
+ "fileName": "src/layout/stack/Stack.tsx",
16649
+ "name": "StackProps"
16650
+ }
16651
+ ],
16652
+ "required": true,
16653
+ "type": {
16654
+ "name": "\"row\" | \"column\""
16655
+ }
16656
+ },
16657
+ "className": {
16658
+ "defaultValue": null,
16659
+ "description": "",
16660
+ "name": "className",
16661
+ "parent": {
16662
+ "fileName": "aksel/node_modules/@types/react/ts5.0/index.d.ts",
16663
+ "name": "HTMLAttributes"
16664
+ },
16665
+ "declarations": [
16666
+ {
16667
+ "fileName": "aksel/node_modules/@types/react/ts5.0/index.d.ts",
16668
+ "name": "HTMLAttributes"
16669
+ }
16670
+ ],
16671
+ "required": false,
16672
+ "type": {
16673
+ "name": "string"
16674
+ }
16675
+ },
16676
+ "ref": {
16677
+ "defaultValue": null,
16678
+ "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",
16679
+ "name": "ref",
16680
+ "parent": {
16681
+ "fileName": "aksel/node_modules/@types/react/ts5.0/index.d.ts",
16682
+ "name": "RefAttributes"
16683
+ },
16684
+ "declarations": [
16685
+ {
16686
+ "fileName": "aksel/node_modules/@types/react/ts5.0/index.d.ts",
16687
+ "name": "RefAttributes"
16688
+ }
16689
+ ],
16690
+ "required": false,
16691
+ "type": {
16692
+ "name": "Ref<HTMLDivElement>"
16693
+ }
16694
+ }
16695
+ }
16696
+ },
16697
+ {
16698
+ "filePath": "src/layout/stack/VStack.tsx",
16699
+ "displayName": "VStack",
16700
+ "props": {
16701
+ "justify": {
16702
+ "defaultValue": null,
16703
+ "description": "Justify-content",
16704
+ "name": "justify",
16705
+ "parent": {
16706
+ "fileName": "react/src/layout/stack/Stack.tsx",
16707
+ "name": "StackProps"
16708
+ },
16709
+ "declarations": [
16710
+ {
16711
+ "fileName": "react/src/layout/stack/Stack.tsx",
16712
+ "name": "StackProps"
16713
+ }
16714
+ ],
16715
+ "required": false,
16716
+ "type": {
16717
+ "name": "\"start\" | \"center\" | \"end\" | \"space-around\" | \"space-between\" | \"space-evenly\""
16718
+ }
16719
+ },
16720
+ "align": {
16721
+ "defaultValue": null,
16722
+ "description": "Align-items",
16723
+ "name": "align",
16724
+ "parent": {
16725
+ "fileName": "react/src/layout/stack/Stack.tsx",
16726
+ "name": "StackProps"
16727
+ },
16728
+ "declarations": [
16729
+ {
16730
+ "fileName": "react/src/layout/stack/Stack.tsx",
16731
+ "name": "StackProps"
16732
+ }
16733
+ ],
16734
+ "required": false,
16735
+ "type": {
16736
+ "name": "\"start\" | \"center\" | \"end\" | \"baseline\" | \"stretch\""
16737
+ }
16738
+ },
16739
+ "gap": {
16740
+ "defaultValue": null,
16741
+ "description": "@example gap='4'\ngap={{xs: '2', sm: '3', md: '4', lg: '5', xl: '6'}}",
16742
+ "name": "gap",
16743
+ "parent": {
16744
+ "fileName": "react/src/layout/stack/Stack.tsx",
16745
+ "name": "StackProps"
16746
+ },
16747
+ "declarations": [
16748
+ {
16749
+ "fileName": "react/src/layout/stack/Stack.tsx",
16750
+ "name": "StackProps"
16751
+ }
16752
+ ],
16753
+ "required": false,
16754
+ "type": {
16755
+ "name": "ResponsiveProp<SpacingScale>"
16756
+ }
16757
+ },
16758
+ "className": {
16759
+ "defaultValue": null,
16760
+ "description": "",
16761
+ "name": "className",
16762
+ "parent": {
16763
+ "fileName": "aksel/node_modules/@types/react/ts5.0/index.d.ts",
16764
+ "name": "HTMLAttributes"
16765
+ },
16766
+ "declarations": [
16767
+ {
16768
+ "fileName": "aksel/node_modules/@types/react/ts5.0/index.d.ts",
16769
+ "name": "HTMLAttributes"
16770
+ }
16771
+ ],
16772
+ "required": false,
16773
+ "type": {
16774
+ "name": "string"
16775
+ }
16776
+ },
16777
+ "ref": {
16778
+ "defaultValue": null,
16779
+ "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",
16780
+ "name": "ref",
16781
+ "parent": {
16782
+ "fileName": "aksel/node_modules/@types/react/ts5.0/index.d.ts",
16783
+ "name": "RefAttributes"
16784
+ },
16785
+ "declarations": [
16786
+ {
16787
+ "fileName": "aksel/node_modules/@types/react/ts5.0/index.d.ts",
16788
+ "name": "RefAttributes"
16789
+ }
16790
+ ],
16791
+ "required": false,
16792
+ "type": {
16793
+ "name": "Ref<HTMLDivElement>"
16794
+ }
16795
+ }
16796
+ }
16797
+ },
16431
16798
  {
16432
16799
  "filePath": "src/timeline/period/NonClickablePeriod.tsx",
16433
16800
  "displayName": "NonClickablePeriod",
package/cjs/index.js CHANGED
@@ -48,3 +48,4 @@ __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/stack"), exports);
@@ -0,0 +1,51 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.HStack = void 0;
27
+ const react_1 = __importStar(require("react"));
28
+ const Stack_1 = require("./Stack");
29
+ /**
30
+ * Layout-primitive for horizontal flexbox
31
+ *
32
+ * @see [📝 Documentation](https://aksel.nav.no/komponenter/core/Stack)
33
+ * @see 🏷️ {@link HStackProps}
34
+ * @see [🤖 OverridableComponent](https://aksel.nav.no/grunnleggende/kode/overridablecomponent) support
35
+ *
36
+ * @example
37
+ * <HStack gap="8">
38
+ * <MyComponent />
39
+ * <MyComponent />
40
+ * </HStack>
41
+ *
42
+ * @example
43
+ * // Responsive gap
44
+ * <HStack gap={{xs: "2", md: "6"}}>
45
+ * <MyComponent />
46
+ * <MyComponent />
47
+ * </HStack>
48
+ */
49
+ exports.HStack = (0, react_1.forwardRef)((props, ref) => {
50
+ return react_1.default.createElement(Stack_1.Stack, Object.assign({}, props, { ref: ref, direction: "row" }));
51
+ });
@@ -0,0 +1,21 @@
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.Spacer = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ /**
9
+ * Layout-primitive for auto-spacing between elements
10
+ *
11
+ * @see [📝 Documentation](https://aksel.nav.no/komponenter/core/Stack)
12
+ *
13
+ * @example
14
+ * <HStack gap="8">
15
+ * <MyComponent />
16
+ * <Spacer />
17
+ * <MyComponent />
18
+ * </HStack>
19
+ */
20
+ const Spacer = () => react_1.default.createElement("div", { className: "navds-stack__spacer" });
21
+ exports.Spacer = Spacer;
@@ -0,0 +1,51 @@
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.Stack = void 0;
41
+ const clsx_1 = __importDefault(require("clsx"));
42
+ const react_1 = __importStar(require("react"));
43
+ const css_1 = require("../utilities/css");
44
+ exports.Stack = (0, react_1.forwardRef)((_a, ref) => {
45
+ var { as: Component = "div", className, align, justify, wrap = true, gap, style: _style, direction } = _a, rest = __rest(_a, ["as", "className", "align", "justify", "wrap", "gap", "style", "direction"]);
46
+ const style = Object.assign(Object.assign({ "--ac-stack-direction": direction, "--ac-stack-align": align, "--ac-stack-justify": justify, "--ac-stack-wrap": wrap ? "wrap" : "nowrap" }, (0, css_1.getResponsiveProps)(`stack`, "gap", "spacing", gap)), _style);
47
+ return (react_1.default.createElement(Component, Object.assign({}, rest, { ref: ref, style: style, className: (0, clsx_1.default)("navds-stack", className, {
48
+ "navds-vstack": direction === "column",
49
+ "navds-hstack": direction === "row",
50
+ }) })));
51
+ });
@@ -0,0 +1,51 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.VStack = void 0;
27
+ const react_1 = __importStar(require("react"));
28
+ const Stack_1 = require("./Stack");
29
+ /**
30
+ * Layout-primitive for vetical flexbox
31
+ *
32
+ * @see [📝 Documentation](https://aksel.nav.no/komponenter/core/Stack)
33
+ * @see 🏷️ {@link VStackProps}
34
+ * @see [🤖 OverridableComponent](https://aksel.nav.no/grunnleggende/kode/overridablecomponent) support
35
+ *
36
+ * @example
37
+ * <VStack gap="8">
38
+ * <MyComponent />
39
+ * <MyComponent />
40
+ * </VStack>
41
+ *
42
+ * @example
43
+ * // Responsive gap
44
+ * <VStack gap={{xs: "2", md: "6"}}>
45
+ * <MyComponent />
46
+ * <MyComponent />
47
+ * </VStack>
48
+ */
49
+ exports.VStack = (0, react_1.forwardRef)((props, ref) => {
50
+ return react_1.default.createElement(Stack_1.Stack, Object.assign({}, props, { ref: ref, direction: "column", wrap: false }));
51
+ });
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Spacer = exports.VStack = exports.HStack = void 0;
4
+ var HStack_1 = require("./HStack");
5
+ Object.defineProperty(exports, "HStack", { enumerable: true, get: function () { return HStack_1.HStack; } });
6
+ var VStack_1 = require("./VStack");
7
+ Object.defineProperty(exports, "VStack", { enumerable: true, get: function () { return VStack_1.VStack; } });
8
+ var Spacer_1 = require("./Spacer");
9
+ Object.defineProperty(exports, "Spacer", { enumerable: true, get: function () { return Spacer_1.Spacer; } });
@@ -0,0 +1,6 @@
1
+ {
2
+ "sideEffects": false,
3
+ "main": "./index.js",
4
+ "module": "../../../esm/layout/stack/index.js",
5
+ "types": "../../../esm/layout/stack/index.d.ts"
6
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getResponsiveProps = void 0;
4
+ function getResponsiveProps(componentName, componentProp, tokenSubgroup, responsiveProp) {
5
+ if (!responsiveProp)
6
+ return {};
7
+ if (typeof responsiveProp === "string") {
8
+ return {
9
+ [`--ac-${componentName}-${componentProp}-xs`]: `var(--a-${tokenSubgroup}-${responsiveProp})`,
10
+ };
11
+ }
12
+ return Object.fromEntries(Object.entries(responsiveProp).map(([breakpointAlias, aliasOrScale]) => [
13
+ `--ac-${componentName}-${componentProp}-${breakpointAlias}`,
14
+ `var(--a-${tokenSubgroup}-${aliasOrScale})`,
15
+ ]));
16
+ }
17
+ exports.getResponsiveProps = getResponsiveProps;
package/esm/index.d.ts CHANGED
@@ -32,3 +32,4 @@ export * from "./toggle-group";
32
32
  export * from "./tooltip";
33
33
  export * from "./typography";
34
34
  export * from "./util";
35
+ export * from "./layout/stack";
package/esm/index.js CHANGED
@@ -32,4 +32,5 @@ export * from "./toggle-group";
32
32
  export * from "./tooltip";
33
33
  export * from "./typography";
34
34
  export * from "./util";
35
+ export * from "./layout/stack";
35
36
  //# 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"}
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"}
@@ -0,0 +1,24 @@
1
+ import { OverridableComponent } from "../../util/OverridableComponent";
2
+ import { StackProps } from "./Stack";
3
+ export type HStackProps = Omit<StackProps, "direction">;
4
+ /**
5
+ * Layout-primitive for horizontal flexbox
6
+ *
7
+ * @see [📝 Documentation](https://aksel.nav.no/komponenter/core/Stack)
8
+ * @see 🏷️ {@link HStackProps}
9
+ * @see [🤖 OverridableComponent](https://aksel.nav.no/grunnleggende/kode/overridablecomponent) support
10
+ *
11
+ * @example
12
+ * <HStack gap="8">
13
+ * <MyComponent />
14
+ * <MyComponent />
15
+ * </HStack>
16
+ *
17
+ * @example
18
+ * // Responsive gap
19
+ * <HStack gap={{xs: "2", md: "6"}}>
20
+ * <MyComponent />
21
+ * <MyComponent />
22
+ * </HStack>
23
+ */
24
+ export declare const HStack: OverridableComponent<HStackProps, HTMLDivElement>;
@@ -0,0 +1,26 @@
1
+ import React, { forwardRef } from "react";
2
+ import { Stack } from "./Stack";
3
+ /**
4
+ * Layout-primitive for horizontal flexbox
5
+ *
6
+ * @see [📝 Documentation](https://aksel.nav.no/komponenter/core/Stack)
7
+ * @see 🏷️ {@link HStackProps}
8
+ * @see [🤖 OverridableComponent](https://aksel.nav.no/grunnleggende/kode/overridablecomponent) support
9
+ *
10
+ * @example
11
+ * <HStack gap="8">
12
+ * <MyComponent />
13
+ * <MyComponent />
14
+ * </HStack>
15
+ *
16
+ * @example
17
+ * // Responsive gap
18
+ * <HStack gap={{xs: "2", md: "6"}}>
19
+ * <MyComponent />
20
+ * <MyComponent />
21
+ * </HStack>
22
+ */
23
+ export const HStack = forwardRef((props, ref) => {
24
+ return React.createElement(Stack, Object.assign({}, props, { ref: ref, direction: "row" }));
25
+ });
26
+ //# sourceMappingURL=HStack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HStack.js","sourceRoot":"","sources":["../../../src/layout/stack/HStack.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAc,KAAK,EAAE,MAAM,SAAS,CAAC;AAI5C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,MAAM,GACjB,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IACxB,OAAO,oBAAC,KAAK,oBAAK,KAAK,IAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAC,KAAK,IAAG,CAAC;AACxD,CAAC,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ /**
3
+ * Layout-primitive for auto-spacing between elements
4
+ *
5
+ * @see [📝 Documentation](https://aksel.nav.no/komponenter/core/Stack)
6
+ *
7
+ * @example
8
+ * <HStack gap="8">
9
+ * <MyComponent />
10
+ * <Spacer />
11
+ * <MyComponent />
12
+ * </HStack>
13
+ */
14
+ export declare const Spacer: () => React.JSX.Element;
@@ -0,0 +1,15 @@
1
+ import React from "react";
2
+ /**
3
+ * Layout-primitive for auto-spacing between elements
4
+ *
5
+ * @see [📝 Documentation](https://aksel.nav.no/komponenter/core/Stack)
6
+ *
7
+ * @example
8
+ * <HStack gap="8">
9
+ * <MyComponent />
10
+ * <Spacer />
11
+ * <MyComponent />
12
+ * </HStack>
13
+ */
14
+ export const Spacer = () => React.createElement("div", { className: "navds-stack__spacer" });
15
+ //# sourceMappingURL=Spacer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Spacer.js","sourceRoot":"","sources":["../../../src/layout/stack/Spacer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,6BAAK,SAAS,EAAC,qBAAqB,GAAG,CAAC"}
@@ -0,0 +1,26 @@
1
+ import React, { HTMLAttributes } from "react";
2
+ import { OverridableComponent } from "../../util/OverridableComponent";
3
+ import { ResponsiveProp, SpacingScale } from "../utilities/css";
4
+ export interface StackProps extends HTMLAttributes<HTMLDivElement> {
5
+ children: React.ReactNode;
6
+ /**
7
+ * Justify-content
8
+ */
9
+ justify?: "start" | "center" | "end" | "space-around" | "space-between" | "space-evenly";
10
+ /**
11
+ * Align-items
12
+ */
13
+ align?: "start" | "center" | "end" | "baseline" | "stretch";
14
+ /**
15
+ * flex-wrap
16
+ */
17
+ wrap?: boolean;
18
+ /**
19
+ * @example
20
+ * gap='4'
21
+ * gap={{xs: '2', sm: '3', md: '4', lg: '5', xl: '6'}}
22
+ */
23
+ gap?: ResponsiveProp<SpacingScale>;
24
+ direction: "row" | "column";
25
+ }
26
+ export declare const Stack: OverridableComponent<StackProps, HTMLDivElement>;
@@ -0,0 +1,23 @@
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
+ export const Stack = forwardRef((_a, ref) => {
16
+ var { as: Component = "div", className, align, justify, wrap = true, gap, style: _style, direction } = _a, rest = __rest(_a, ["as", "className", "align", "justify", "wrap", "gap", "style", "direction"]);
17
+ const style = Object.assign(Object.assign({ "--ac-stack-direction": direction, "--ac-stack-align": align, "--ac-stack-justify": justify, "--ac-stack-wrap": wrap ? "wrap" : "nowrap" }, getResponsiveProps(`stack`, "gap", "spacing", gap)), _style);
18
+ return (React.createElement(Component, Object.assign({}, rest, { ref: ref, style: style, className: cl("navds-stack", className, {
19
+ "navds-vstack": direction === "column",
20
+ "navds-hstack": direction === "row",
21
+ }) })));
22
+ });
23
+ //# sourceMappingURL=Stack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Stack.js","sourceRoot":"","sources":["../../../src/layout/stack/Stack.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAAE,UAAU,EAAkB,MAAM,OAAO,CAAC;AAE1D,OAAO,EACL,kBAAkB,GAGnB,MAAM,kBAAkB,CAAC;AA+B1B,MAAM,CAAC,MAAM,KAAK,GAChB,UAAU,CACR,CACE,EAUC,EACD,GAAG,EACH,EAAE;QAZF,EACE,EAAE,EAAE,SAAS,GAAG,KAAK,EACrB,SAAS,EACT,KAAK,EACL,OAAO,EACP,IAAI,GAAG,IAAI,EACX,GAAG,EACH,KAAK,EAAE,MAAM,EACb,SAAS,OAEV,EADI,IAAI,cATT,4EAUC,CADQ;IAIT,MAAM,KAAK,GAAG,8BACZ,sBAAsB,EAAE,SAAS,EACjC,kBAAkB,EAAE,KAAK,EACzB,oBAAoB,EAAE,OAAO,EAC7B,iBAAiB,EAAE,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,IACxC,kBAAkB,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,CAAC,GAClD,MAAM,CACa,CAAC;IAEzB,OAAO,CACL,oBAAC,SAAS,oBACJ,IAAI,IACR,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,EAAE,CAAC,aAAa,EAAE,SAAS,EAAE;YACtC,cAAc,EAAE,SAAS,KAAK,QAAQ;YACtC,cAAc,EAAE,SAAS,KAAK,KAAK;SACpC,CAAC,IACF,CACH,CAAC;AACJ,CAAC,CACF,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { OverridableComponent } from "../../util/OverridableComponent";
2
+ import { StackProps } from "./Stack";
3
+ export type VStackProps = Omit<StackProps, "direction" | "wrap">;
4
+ /**
5
+ * Layout-primitive for vetical flexbox
6
+ *
7
+ * @see [📝 Documentation](https://aksel.nav.no/komponenter/core/Stack)
8
+ * @see 🏷️ {@link VStackProps}
9
+ * @see [🤖 OverridableComponent](https://aksel.nav.no/grunnleggende/kode/overridablecomponent) support
10
+ *
11
+ * @example
12
+ * <VStack gap="8">
13
+ * <MyComponent />
14
+ * <MyComponent />
15
+ * </VStack>
16
+ *
17
+ * @example
18
+ * // Responsive gap
19
+ * <VStack gap={{xs: "2", md: "6"}}>
20
+ * <MyComponent />
21
+ * <MyComponent />
22
+ * </VStack>
23
+ */
24
+ export declare const VStack: OverridableComponent<VStackProps, HTMLDivElement>;
@@ -0,0 +1,26 @@
1
+ import React, { forwardRef } from "react";
2
+ import { Stack } from "./Stack";
3
+ /**
4
+ * Layout-primitive for vetical flexbox
5
+ *
6
+ * @see [📝 Documentation](https://aksel.nav.no/komponenter/core/Stack)
7
+ * @see 🏷️ {@link VStackProps}
8
+ * @see [🤖 OverridableComponent](https://aksel.nav.no/grunnleggende/kode/overridablecomponent) support
9
+ *
10
+ * @example
11
+ * <VStack gap="8">
12
+ * <MyComponent />
13
+ * <MyComponent />
14
+ * </VStack>
15
+ *
16
+ * @example
17
+ * // Responsive gap
18
+ * <VStack gap={{xs: "2", md: "6"}}>
19
+ * <MyComponent />
20
+ * <MyComponent />
21
+ * </VStack>
22
+ */
23
+ export const VStack = forwardRef((props, ref) => {
24
+ return React.createElement(Stack, Object.assign({}, props, { ref: ref, direction: "column", wrap: false }));
25
+ });
26
+ //# sourceMappingURL=VStack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VStack.js","sourceRoot":"","sources":["../../../src/layout/stack/VStack.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAc,KAAK,EAAE,MAAM,SAAS,CAAC;AAI5C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,MAAM,GACjB,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IACxB,OAAO,oBAAC,KAAK,oBAAK,KAAK,IAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAC,QAAQ,EAAC,IAAI,EAAE,KAAK,IAAI,CAAC;AACxE,CAAC,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { HStack, type HStackProps } from "./HStack";
2
+ export { VStack, type VStackProps } from "./VStack";
3
+ export { Spacer } from "./Spacer";
@@ -0,0 +1,4 @@
1
+ export { HStack } from "./HStack";
2
+ export { VStack } from "./VStack";
3
+ export { Spacer } from "./Spacer";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/layout/stack/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAoB,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,MAAM,EAAoB,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,10 @@
1
+ export type BreakpointsAlias = "xs" | "sm" | "md" | "lg" | "xl";
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
+ export type ResponsiveProp<T> = T | {
4
+ [Breakpoint in BreakpointsAlias]?: T;
5
+ };
6
+ export declare function getResponsiveProps(componentName: string, componentProp: string, tokenSubgroup: string, responsiveProp?: string | {
7
+ [Breakpoint in BreakpointsAlias]?: string;
8
+ }): {
9
+ [x: string]: string;
10
+ };
@@ -0,0 +1,14 @@
1
+ export function getResponsiveProps(componentName, componentProp, tokenSubgroup, responsiveProp) {
2
+ if (!responsiveProp)
3
+ return {};
4
+ if (typeof responsiveProp === "string") {
5
+ return {
6
+ [`--ac-${componentName}-${componentProp}-xs`]: `var(--a-${tokenSubgroup}-${responsiveProp})`,
7
+ };
8
+ }
9
+ return Object.fromEntries(Object.entries(responsiveProp).map(([breakpointAlias, aliasOrScale]) => [
10
+ `--ac-${componentName}-${componentProp}-${breakpointAlias}`,
11
+ `var(--a-${tokenSubgroup}-${aliasOrScale})`,
12
+ ]));
13
+ }
14
+ //# sourceMappingURL=css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css.js","sourceRoot":"","sources":["../../../src/layout/utilities/css.ts"],"names":[],"mappings":"AA8BA,MAAM,UAAU,kBAAkB,CAChC,aAAqB,EACrB,aAAqB,EACrB,aAAqB,EACrB,cAKK;IAEL,IAAI,CAAC,cAAc;QAAE,OAAO,EAAE,CAAC;IAE/B,IAAI,OAAO,cAAc,KAAK,QAAQ,EAAE;QACtC,OAAO;YACL,CAAC,QAAQ,aAAa,IAAI,aAAa,KAAK,CAAC,EAAE,WAAW,aAAa,IAAI,cAAc,GAAG;SAC7F,CAAC;KACH;IAED,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,eAAe,EAAE,YAAY,CAAC,EAAE,EAAE,CAAC;QACtE,QAAQ,aAAa,IAAI,aAAa,IAAI,eAAe,EAAE;QAC3D,WAAW,aAAa,IAAI,YAAY,GAAG;KAC5C,CAAC,CACH,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@navikt/ds-react",
3
- "version": "4.7.4",
3
+ "version": "4.8.0",
4
4
  "description": "Aksel react-components for NAV designsystem",
5
5
  "author": "Aksel | NAV designsystem team",
6
6
  "license": "MIT",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@floating-ui/react": "0.24.1",
41
- "@navikt/aksel-icons": "^4.7.4",
41
+ "@navikt/aksel-icons": "^4.8.0",
42
42
  "@radix-ui/react-tabs": "1.0.0",
43
43
  "@radix-ui/react-toggle-group": "1.0.0",
44
44
  "clsx": "^1.2.1",
package/src/index.ts CHANGED
@@ -32,3 +32,4 @@ export * from "./toggle-group";
32
32
  export * from "./tooltip";
33
33
  export * from "./typography";
34
34
  export * from "./util";
35
+ export * from "./layout/stack";
@@ -0,0 +1,30 @@
1
+ import React, { forwardRef } from "react";
2
+ import { OverridableComponent } from "../../util/OverridableComponent";
3
+ import { StackProps, Stack } from "./Stack";
4
+
5
+ export type HStackProps = Omit<StackProps, "direction">;
6
+
7
+ /**
8
+ * Layout-primitive for horizontal flexbox
9
+ *
10
+ * @see [📝 Documentation](https://aksel.nav.no/komponenter/core/Stack)
11
+ * @see 🏷️ {@link HStackProps}
12
+ * @see [🤖 OverridableComponent](https://aksel.nav.no/grunnleggende/kode/overridablecomponent) support
13
+ *
14
+ * @example
15
+ * <HStack gap="8">
16
+ * <MyComponent />
17
+ * <MyComponent />
18
+ * </HStack>
19
+ *
20
+ * @example
21
+ * // Responsive gap
22
+ * <HStack gap={{xs: "2", md: "6"}}>
23
+ * <MyComponent />
24
+ * <MyComponent />
25
+ * </HStack>
26
+ */
27
+ export const HStack: OverridableComponent<HStackProps, HTMLDivElement> =
28
+ forwardRef((props, ref) => {
29
+ return <Stack {...props} ref={ref} direction="row" />;
30
+ });
@@ -0,0 +1,15 @@
1
+ import React from "react";
2
+
3
+ /**
4
+ * Layout-primitive for auto-spacing between elements
5
+ *
6
+ * @see [📝 Documentation](https://aksel.nav.no/komponenter/core/Stack)
7
+ *
8
+ * @example
9
+ * <HStack gap="8">
10
+ * <MyComponent />
11
+ * <Spacer />
12
+ * <MyComponent />
13
+ * </HStack>
14
+ */
15
+ export const Spacer = () => <div className="navds-stack__spacer" />;
@@ -0,0 +1,76 @@
1
+ import cl from "clsx";
2
+ import React, { forwardRef, HTMLAttributes } from "react";
3
+ import { OverridableComponent } from "../../util/OverridableComponent";
4
+ import {
5
+ getResponsiveProps,
6
+ ResponsiveProp,
7
+ SpacingScale,
8
+ } from "../utilities/css";
9
+
10
+ export interface StackProps extends HTMLAttributes<HTMLDivElement> {
11
+ children: React.ReactNode;
12
+ /**
13
+ * Justify-content
14
+ */
15
+ justify?:
16
+ | "start"
17
+ | "center"
18
+ | "end"
19
+ | "space-around"
20
+ | "space-between"
21
+ | "space-evenly";
22
+ /**
23
+ * Align-items
24
+ */
25
+ align?: "start" | "center" | "end" | "baseline" | "stretch";
26
+ /**
27
+ * flex-wrap
28
+ */
29
+ wrap?: boolean;
30
+ /**
31
+ * @example
32
+ * gap='4'
33
+ * gap={{xs: '2', sm: '3', md: '4', lg: '5', xl: '6'}}
34
+ */
35
+ gap?: ResponsiveProp<SpacingScale>;
36
+ direction: "row" | "column";
37
+ }
38
+
39
+ export const Stack: OverridableComponent<StackProps, HTMLDivElement> =
40
+ forwardRef(
41
+ (
42
+ {
43
+ as: Component = "div",
44
+ className,
45
+ align,
46
+ justify,
47
+ wrap = true,
48
+ gap,
49
+ style: _style,
50
+ direction,
51
+ ...rest
52
+ },
53
+ ref
54
+ ) => {
55
+ const style = {
56
+ "--ac-stack-direction": direction,
57
+ "--ac-stack-align": align,
58
+ "--ac-stack-justify": justify,
59
+ "--ac-stack-wrap": wrap ? "wrap" : "nowrap",
60
+ ...getResponsiveProps(`stack`, "gap", "spacing", gap),
61
+ ..._style,
62
+ } as React.CSSProperties;
63
+
64
+ return (
65
+ <Component
66
+ {...rest}
67
+ ref={ref}
68
+ style={style}
69
+ className={cl("navds-stack", className, {
70
+ "navds-vstack": direction === "column",
71
+ "navds-hstack": direction === "row",
72
+ })}
73
+ />
74
+ );
75
+ }
76
+ );
@@ -0,0 +1,30 @@
1
+ import React, { forwardRef } from "react";
2
+ import { OverridableComponent } from "../../util/OverridableComponent";
3
+ import { StackProps, Stack } from "./Stack";
4
+
5
+ export type VStackProps = Omit<StackProps, "direction" | "wrap">;
6
+
7
+ /**
8
+ * Layout-primitive for vetical flexbox
9
+ *
10
+ * @see [📝 Documentation](https://aksel.nav.no/komponenter/core/Stack)
11
+ * @see 🏷️ {@link VStackProps}
12
+ * @see [🤖 OverridableComponent](https://aksel.nav.no/grunnleggende/kode/overridablecomponent) support
13
+ *
14
+ * @example
15
+ * <VStack gap="8">
16
+ * <MyComponent />
17
+ * <MyComponent />
18
+ * </VStack>
19
+ *
20
+ * @example
21
+ * // Responsive gap
22
+ * <VStack gap={{xs: "2", md: "6"}}>
23
+ * <MyComponent />
24
+ * <MyComponent />
25
+ * </VStack>
26
+ */
27
+ export const VStack: OverridableComponent<VStackProps, HTMLDivElement> =
28
+ forwardRef((props, ref) => {
29
+ return <Stack {...props} ref={ref} direction="column" wrap={false} />;
30
+ });
@@ -0,0 +1,3 @@
1
+ export { HStack, type HStackProps } from "./HStack";
2
+ export { VStack, type VStackProps } from "./VStack";
3
+ export { Spacer } from "./Spacer";
@@ -0,0 +1,161 @@
1
+ import React from "react";
2
+ import type { Meta } from "@storybook/react";
3
+ import { HStack, VStack, Spacer } from ".";
4
+
5
+ export default {
6
+ title: "ds-react/Stack",
7
+ component: HStack,
8
+ } satisfies Meta<typeof HStack>;
9
+
10
+ export const Horizontal = {
11
+ render: () => (
12
+ <HStack gap="4">
13
+ <Placeholders count={4} />
14
+ </HStack>
15
+ ),
16
+ };
17
+
18
+ export const Spacing = {
19
+ render: () => (
20
+ <div style={{ height: "80vh", display: "flex" }}>
21
+ <VStack gap="8">
22
+ <Spacer />
23
+ <HStack gap="4">
24
+ <Placeholders count={1} />
25
+ <Spacer />
26
+ <Placeholders count={1} />
27
+ </HStack>
28
+ <HStack gap="4">
29
+ <Placeholders count={1} />
30
+ <Placeholders count={1} />
31
+ </HStack>
32
+ <HStack gap="4">
33
+ <Placeholders count={2} />
34
+ </HStack>
35
+ </VStack>
36
+ </div>
37
+ ),
38
+ parameters: {
39
+ layout: "fullscreen",
40
+ },
41
+ };
42
+
43
+ export const Vertical = {
44
+ render: () => (
45
+ <VStack gap="4">
46
+ <Placeholders count={4} />
47
+ </VStack>
48
+ ),
49
+ };
50
+
51
+ export const VerticalDemo = {
52
+ render: () => (
53
+ <VStack gap="2">
54
+ <VStack>
55
+ <Placeholders count={4} />
56
+ </VStack>
57
+ <Placeholders count={4} />
58
+ <VStack>
59
+ <Placeholders count={4} />
60
+ </VStack>
61
+ </VStack>
62
+ ),
63
+ };
64
+
65
+ export const VerticalAlign = {
66
+ render: () => (
67
+ <VStack gap="4">
68
+ <VStack align="start">
69
+ <Placeholders count={2} />
70
+ </VStack>
71
+ <VStack align="center">
72
+ <Placeholders count={2} />
73
+ </VStack>
74
+ <VStack align="end">
75
+ <Placeholders count={2} />
76
+ </VStack>
77
+ </VStack>
78
+ ),
79
+ parameters: {
80
+ layout: "fullscreen",
81
+ },
82
+ };
83
+
84
+ export const OverrideComponent = {
85
+ render: () => (
86
+ <VStack gap="4" as="form" onSubmit={(e) => e.preventDefault()}>
87
+ <Placeholders count={4} />
88
+ </VStack>
89
+ ),
90
+ };
91
+
92
+ export const Responsive = {
93
+ render: () => (
94
+ <VStack gap={{ xs: "1", sm: "3", md: "6", lg: "10", xl: "16" }}>
95
+ <Placeholders count={4} />
96
+ </VStack>
97
+ ),
98
+ };
99
+
100
+ export const Nested = {
101
+ render: () => (
102
+ <VStack gap="16">
103
+ <Placeholders count={2}>
104
+ <VStack gap="4">
105
+ <Placeholders count={2} color="gray" />
106
+ </VStack>
107
+ </Placeholders>
108
+ </VStack>
109
+ ),
110
+ };
111
+
112
+ export const DividerDemo = {
113
+ render: () => (
114
+ <div style={{ height: "80vh", width: "40rem" }}>
115
+ <VStack gap={{ xs: "2", md: "6", lg: "12" }}>
116
+ <HStack gap={{ xs: "2", md: "6", lg: "12" }}>
117
+ <Placeholders count={1} />
118
+ <Spacer />
119
+ <Placeholders count={1} />
120
+ </HStack>
121
+ <hr
122
+ style={{
123
+ border: "none",
124
+ borderBottom: "1px solid var(--a-border-divider)",
125
+ margin: 0,
126
+ }}
127
+ />
128
+ <HStack gap={{ xs: "2", md: "6", lg: "12" }}>
129
+ <Placeholders count={2} />
130
+ </HStack>
131
+ </VStack>
132
+ </div>
133
+ ),
134
+ };
135
+
136
+ function Placeholders({
137
+ count,
138
+ children,
139
+ color,
140
+ }: {
141
+ count: number;
142
+ children?: React.ReactNode;
143
+ color?: string;
144
+ }) {
145
+ return (
146
+ <>
147
+ {Array.from({ length: count }, (_, i) => (
148
+ <div
149
+ key={i}
150
+ style={{
151
+ backgroundColor: color ?? "var(--a-purple-200)",
152
+ height: children ? "" : "3rem",
153
+ width: children ? "" : "3rem",
154
+ }}
155
+ >
156
+ {children}
157
+ </div>
158
+ ))}
159
+ </>
160
+ );
161
+ }
@@ -0,0 +1,56 @@
1
+ export type BreakpointsAlias = "xs" | "sm" | "md" | "lg" | "xl";
2
+ export type SpacingScale =
3
+ | "0"
4
+ | "05"
5
+ | "1"
6
+ | "2"
7
+ | "3"
8
+ | "4"
9
+ | "5"
10
+ | "6"
11
+ | "7"
12
+ | "8"
13
+ | "9"
14
+ | "10"
15
+ | "11"
16
+ | "12"
17
+ | "14"
18
+ | "16"
19
+ | "18"
20
+ | "20"
21
+ | "24"
22
+ | "32";
23
+
24
+ export type ResponsiveProp<T> =
25
+ | T
26
+ | {
27
+ // eslint-disable-next-line no-unused-vars
28
+ [Breakpoint in BreakpointsAlias]?: T;
29
+ };
30
+
31
+ export function getResponsiveProps(
32
+ componentName: string,
33
+ componentProp: string,
34
+ tokenSubgroup: string,
35
+ responsiveProp?:
36
+ | string
37
+ | {
38
+ // eslint-disable-next-line no-unused-vars
39
+ [Breakpoint in BreakpointsAlias]?: string;
40
+ }
41
+ ) {
42
+ if (!responsiveProp) return {};
43
+
44
+ if (typeof responsiveProp === "string") {
45
+ return {
46
+ [`--ac-${componentName}-${componentProp}-xs`]: `var(--a-${tokenSubgroup}-${responsiveProp})`,
47
+ };
48
+ }
49
+
50
+ return Object.fromEntries(
51
+ Object.entries(responsiveProp).map(([breakpointAlias, aliasOrScale]) => [
52
+ `--ac-${componentName}-${componentProp}-${breakpointAlias}`,
53
+ `var(--a-${tokenSubgroup}-${aliasOrScale})`,
54
+ ])
55
+ );
56
+ }