@navikt/ds-react 2.3.1 → 2.4.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 +206 -0
- package/cjs/index.js +7 -6
- package/cjs/list/List.js +61 -0
- package/cjs/list/ListItem.js +58 -0
- package/cjs/list/index.js +8 -0
- package/cjs/list/package.json +6 -0
- package/esm/index.d.ts +7 -6
- package/esm/index.js +7 -6
- package/esm/index.js.map +1 -1
- package/esm/list/List.d.ts +32 -0
- package/esm/list/List.js +33 -0
- package/esm/list/List.js.map +1 -0
- package/esm/list/ListItem.d.ts +16 -0
- package/esm/list/ListItem.js +30 -0
- package/esm/list/ListItem.js.map +1 -0
- package/esm/list/index.d.ts +2 -0
- package/esm/list/index.js +2 -0
- package/esm/list/index.js.map +1 -0
- package/package.json +2 -2
- package/src/index.ts +7 -6
- package/src/list/List.tsx +85 -0
- package/src/list/ListItem.tsx +71 -0
- package/src/list/index.ts +2 -0
- package/src/list/list.stories.tsx +119 -0
package/_docs.json
CHANGED
|
@@ -3708,6 +3708,212 @@
|
|
|
3708
3708
|
}
|
|
3709
3709
|
}
|
|
3710
3710
|
},
|
|
3711
|
+
{
|
|
3712
|
+
"filePath": "src/list/List.tsx",
|
|
3713
|
+
"displayName": "List",
|
|
3714
|
+
"props": {
|
|
3715
|
+
"as": {
|
|
3716
|
+
"defaultValue": {
|
|
3717
|
+
"value": "\"ul\""
|
|
3718
|
+
},
|
|
3719
|
+
"description": "HTML list element to render",
|
|
3720
|
+
"name": "as",
|
|
3721
|
+
"parent": {
|
|
3722
|
+
"fileName": "src/list/List.tsx",
|
|
3723
|
+
"name": "ListProps"
|
|
3724
|
+
},
|
|
3725
|
+
"declarations": [
|
|
3726
|
+
{
|
|
3727
|
+
"fileName": "src/list/List.tsx",
|
|
3728
|
+
"name": "ListProps"
|
|
3729
|
+
}
|
|
3730
|
+
],
|
|
3731
|
+
"required": false,
|
|
3732
|
+
"type": {
|
|
3733
|
+
"name": "\"ul\" | \"ol\""
|
|
3734
|
+
}
|
|
3735
|
+
},
|
|
3736
|
+
"title": {
|
|
3737
|
+
"defaultValue": null,
|
|
3738
|
+
"description": "List heading title",
|
|
3739
|
+
"name": "title",
|
|
3740
|
+
"parent": {
|
|
3741
|
+
"fileName": "src/list/List.tsx",
|
|
3742
|
+
"name": "ListProps"
|
|
3743
|
+
},
|
|
3744
|
+
"declarations": [
|
|
3745
|
+
{
|
|
3746
|
+
"fileName": "src/list/List.tsx",
|
|
3747
|
+
"name": "ListProps"
|
|
3748
|
+
}
|
|
3749
|
+
],
|
|
3750
|
+
"required": false,
|
|
3751
|
+
"type": {
|
|
3752
|
+
"name": "string"
|
|
3753
|
+
}
|
|
3754
|
+
},
|
|
3755
|
+
"description": {
|
|
3756
|
+
"defaultValue": null,
|
|
3757
|
+
"description": "List heading description",
|
|
3758
|
+
"name": "description",
|
|
3759
|
+
"parent": {
|
|
3760
|
+
"fileName": "src/list/List.tsx",
|
|
3761
|
+
"name": "ListProps"
|
|
3762
|
+
},
|
|
3763
|
+
"declarations": [
|
|
3764
|
+
{
|
|
3765
|
+
"fileName": "src/list/List.tsx",
|
|
3766
|
+
"name": "ListProps"
|
|
3767
|
+
}
|
|
3768
|
+
],
|
|
3769
|
+
"required": false,
|
|
3770
|
+
"type": {
|
|
3771
|
+
"name": "string"
|
|
3772
|
+
}
|
|
3773
|
+
},
|
|
3774
|
+
"headingTag": {
|
|
3775
|
+
"defaultValue": {
|
|
3776
|
+
"value": "\"h3\""
|
|
3777
|
+
},
|
|
3778
|
+
"description": "Allows setting a different HTML h-tag",
|
|
3779
|
+
"name": "headingTag",
|
|
3780
|
+
"parent": {
|
|
3781
|
+
"fileName": "src/list/List.tsx",
|
|
3782
|
+
"name": "ListProps"
|
|
3783
|
+
},
|
|
3784
|
+
"declarations": [
|
|
3785
|
+
{
|
|
3786
|
+
"fileName": "src/list/List.tsx",
|
|
3787
|
+
"name": "ListProps"
|
|
3788
|
+
}
|
|
3789
|
+
],
|
|
3790
|
+
"required": false,
|
|
3791
|
+
"type": {
|
|
3792
|
+
"name": "ElementType<any>"
|
|
3793
|
+
}
|
|
3794
|
+
},
|
|
3795
|
+
"className": {
|
|
3796
|
+
"defaultValue": null,
|
|
3797
|
+
"description": "",
|
|
3798
|
+
"name": "className",
|
|
3799
|
+
"parent": {
|
|
3800
|
+
"fileName": "aksel/node_modules/@types/react/index.d.ts",
|
|
3801
|
+
"name": "HTMLAttributes"
|
|
3802
|
+
},
|
|
3803
|
+
"declarations": [
|
|
3804
|
+
{
|
|
3805
|
+
"fileName": "aksel/node_modules/@types/react/index.d.ts",
|
|
3806
|
+
"name": "HTMLAttributes"
|
|
3807
|
+
}
|
|
3808
|
+
],
|
|
3809
|
+
"required": false,
|
|
3810
|
+
"type": {
|
|
3811
|
+
"name": "string"
|
|
3812
|
+
}
|
|
3813
|
+
}
|
|
3814
|
+
}
|
|
3815
|
+
},
|
|
3816
|
+
{
|
|
3817
|
+
"filePath": "src/list/ListItem.tsx",
|
|
3818
|
+
"displayName": "ListItem",
|
|
3819
|
+
"props": {
|
|
3820
|
+
"children": {
|
|
3821
|
+
"defaultValue": null,
|
|
3822
|
+
"description": "Content for description of the list item",
|
|
3823
|
+
"name": "children",
|
|
3824
|
+
"parent": {
|
|
3825
|
+
"fileName": "src/list/ListItem.tsx",
|
|
3826
|
+
"name": "ListItemProps"
|
|
3827
|
+
},
|
|
3828
|
+
"declarations": [
|
|
3829
|
+
{
|
|
3830
|
+
"fileName": "src/list/ListItem.tsx",
|
|
3831
|
+
"name": "ListItemProps"
|
|
3832
|
+
}
|
|
3833
|
+
],
|
|
3834
|
+
"required": true,
|
|
3835
|
+
"type": {
|
|
3836
|
+
"name": "ReactNode"
|
|
3837
|
+
}
|
|
3838
|
+
},
|
|
3839
|
+
"title": {
|
|
3840
|
+
"defaultValue": null,
|
|
3841
|
+
"description": "Title for the list item",
|
|
3842
|
+
"name": "title",
|
|
3843
|
+
"parent": {
|
|
3844
|
+
"fileName": "src/list/ListItem.tsx",
|
|
3845
|
+
"name": "ListItemProps"
|
|
3846
|
+
},
|
|
3847
|
+
"declarations": [
|
|
3848
|
+
{
|
|
3849
|
+
"fileName": "src/list/ListItem.tsx",
|
|
3850
|
+
"name": "ListItemProps"
|
|
3851
|
+
}
|
|
3852
|
+
],
|
|
3853
|
+
"required": false,
|
|
3854
|
+
"type": {
|
|
3855
|
+
"name": "string"
|
|
3856
|
+
}
|
|
3857
|
+
},
|
|
3858
|
+
"icon": {
|
|
3859
|
+
"defaultValue": null,
|
|
3860
|
+
"description": "",
|
|
3861
|
+
"name": "icon",
|
|
3862
|
+
"parent": {
|
|
3863
|
+
"fileName": "src/list/ListItem.tsx",
|
|
3864
|
+
"name": "ListItemProps"
|
|
3865
|
+
},
|
|
3866
|
+
"declarations": [
|
|
3867
|
+
{
|
|
3868
|
+
"fileName": "src/list/ListItem.tsx",
|
|
3869
|
+
"name": "ListItemProps"
|
|
3870
|
+
}
|
|
3871
|
+
],
|
|
3872
|
+
"required": false,
|
|
3873
|
+
"type": {
|
|
3874
|
+
"name": "ReactNode"
|
|
3875
|
+
}
|
|
3876
|
+
},
|
|
3877
|
+
"className": {
|
|
3878
|
+
"defaultValue": null,
|
|
3879
|
+
"description": "",
|
|
3880
|
+
"name": "className",
|
|
3881
|
+
"parent": {
|
|
3882
|
+
"fileName": "aksel/node_modules/@types/react/index.d.ts",
|
|
3883
|
+
"name": "HTMLAttributes"
|
|
3884
|
+
},
|
|
3885
|
+
"declarations": [
|
|
3886
|
+
{
|
|
3887
|
+
"fileName": "aksel/node_modules/@types/react/index.d.ts",
|
|
3888
|
+
"name": "HTMLAttributes"
|
|
3889
|
+
}
|
|
3890
|
+
],
|
|
3891
|
+
"required": false,
|
|
3892
|
+
"type": {
|
|
3893
|
+
"name": "string"
|
|
3894
|
+
}
|
|
3895
|
+
},
|
|
3896
|
+
"ref": {
|
|
3897
|
+
"defaultValue": null,
|
|
3898
|
+
"description": "",
|
|
3899
|
+
"name": "ref",
|
|
3900
|
+
"parent": {
|
|
3901
|
+
"fileName": "aksel/node_modules/@types/react/index.d.ts",
|
|
3902
|
+
"name": "RefAttributes"
|
|
3903
|
+
},
|
|
3904
|
+
"declarations": [
|
|
3905
|
+
{
|
|
3906
|
+
"fileName": "aksel/node_modules/@types/react/index.d.ts",
|
|
3907
|
+
"name": "RefAttributes"
|
|
3908
|
+
}
|
|
3909
|
+
],
|
|
3910
|
+
"required": false,
|
|
3911
|
+
"type": {
|
|
3912
|
+
"name": "Ref<HTMLLIElement>"
|
|
3913
|
+
}
|
|
3914
|
+
}
|
|
3915
|
+
}
|
|
3916
|
+
},
|
|
3711
3917
|
{
|
|
3712
3918
|
"filePath": "src/loader/Loader.tsx",
|
|
3713
3919
|
"displayName": "Loader",
|
package/cjs/index.js
CHANGED
|
@@ -16,28 +16,29 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./accordion"), exports);
|
|
18
18
|
__exportStar(require("./alert"), exports);
|
|
19
|
-
__exportStar(require("./provider"), exports);
|
|
20
19
|
__exportStar(require("./button"), exports);
|
|
20
|
+
__exportStar(require("./chat"), exports);
|
|
21
|
+
__exportStar(require("./chips"), exports);
|
|
21
22
|
__exportStar(require("./date"), exports);
|
|
22
23
|
__exportStar(require("./form"), exports);
|
|
23
24
|
__exportStar(require("./grid"), exports);
|
|
24
|
-
__exportStar(require("./help-text"), exports);
|
|
25
25
|
__exportStar(require("./guide-panel"), exports);
|
|
26
|
+
__exportStar(require("./help-text"), exports);
|
|
26
27
|
__exportStar(require("./link"), exports);
|
|
27
28
|
__exportStar(require("./link-panel"), exports);
|
|
29
|
+
__exportStar(require("./list"), exports);
|
|
28
30
|
__exportStar(require("./loader"), exports);
|
|
29
31
|
__exportStar(require("./modal"), exports);
|
|
30
32
|
__exportStar(require("./pagination"), exports);
|
|
31
33
|
__exportStar(require("./panel"), exports);
|
|
32
34
|
__exportStar(require("./popover"), exports);
|
|
35
|
+
__exportStar(require("./provider"), exports);
|
|
33
36
|
__exportStar(require("./read-more"), exports);
|
|
34
|
-
__exportStar(require("./chat"), exports);
|
|
35
|
-
__exportStar(require("./chips"), exports);
|
|
36
37
|
__exportStar(require("./stepper"), exports);
|
|
37
|
-
__exportStar(require("./tag"), exports);
|
|
38
|
-
__exportStar(require("./toggle-group"), exports);
|
|
39
38
|
__exportStar(require("./table"), exports);
|
|
40
39
|
__exportStar(require("./tabs"), exports);
|
|
40
|
+
__exportStar(require("./tag"), exports);
|
|
41
|
+
__exportStar(require("./toggle-group"), exports);
|
|
41
42
|
__exportStar(require("./tooltip"), exports);
|
|
42
43
|
__exportStar(require("./typography"), exports);
|
|
43
44
|
__exportStar(require("./util"), exports);
|
package/cjs/list/List.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
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.List = exports.ListContext = void 0;
|
|
41
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
42
|
+
const react_1 = __importStar(require("react"));
|
|
43
|
+
const typography_1 = require("../typography");
|
|
44
|
+
const useId_1 = require("../util/useId");
|
|
45
|
+
const ListItem_1 = require("./ListItem");
|
|
46
|
+
exports.ListContext = (0, react_1.createContext)({
|
|
47
|
+
listType: "ul",
|
|
48
|
+
});
|
|
49
|
+
exports.List = (0, react_1.forwardRef)((_a, ref) => {
|
|
50
|
+
var { children, className, as: ListTag = "ul", title, description, headingTag = "h3" } = _a, rest = __rest(_a, ["children", "className", "as", "title", "description", "headingTag"]);
|
|
51
|
+
const ariaId = (0, useId_1.useId)();
|
|
52
|
+
return (react_1.default.createElement(exports.ListContext.Provider, { value: {
|
|
53
|
+
listType: ListTag,
|
|
54
|
+
} },
|
|
55
|
+
react_1.default.createElement("div", Object.assign({}, rest, { ref: ref, className: (0, clsx_1.default)("navds-list", className) }),
|
|
56
|
+
title && (react_1.default.createElement(typography_1.Heading, { id: `tittel-${ariaId}`, size: "small", as: headingTag }, title)),
|
|
57
|
+
description && (react_1.default.createElement(typography_1.BodyShort, { id: `description-${ariaId}` }, description)),
|
|
58
|
+
react_1.default.createElement(ListTag, { "aria-labelledby": title && `tittel-${ariaId}`, "aria-describedby": description && `description-${ariaId}` }, children))));
|
|
59
|
+
});
|
|
60
|
+
exports.List.Item = ListItem_1.ListItem;
|
|
61
|
+
exports.default = exports.List;
|
|
@@ -0,0 +1,58 @@
|
|
|
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.ListItem = void 0;
|
|
41
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
42
|
+
const react_1 = __importStar(require("react"));
|
|
43
|
+
const typography_1 = require("../typography");
|
|
44
|
+
const List_1 = require("./List");
|
|
45
|
+
exports.ListItem = (0, react_1.forwardRef)((_a, ref) => {
|
|
46
|
+
var { className, children, title, icon } = _a, rest = __rest(_a, ["className", "children", "title", "icon"]);
|
|
47
|
+
const { listType } = (0, react_1.useContext)(List_1.ListContext);
|
|
48
|
+
return (react_1.default.createElement("li", Object.assign({}, rest, { ref: ref, className: (0, clsx_1.default)("navds-list__item", className) }),
|
|
49
|
+
listType === "ul" && (react_1.default.createElement("div", { className: (0, clsx_1.default)({
|
|
50
|
+
"navds-list__item-marker--icon": icon,
|
|
51
|
+
"navds-list__item-marker--bullet": !icon,
|
|
52
|
+
}) }, icon ? (icon) : (react_1.default.createElement("svg", { width: "6", height: "6", viewBox: "0 0 6 6", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": true, focusable: false, role: "img" },
|
|
53
|
+
react_1.default.createElement("rect", { width: "6", height: "6", rx: "3", fill: "currentColor" }))))),
|
|
54
|
+
react_1.default.createElement(typography_1.BodyShort, { as: "div", size: "small", className: "navds-list__item-content" },
|
|
55
|
+
title && (react_1.default.createElement(typography_1.Label, { as: "p", size: "small" }, title)),
|
|
56
|
+
children)));
|
|
57
|
+
});
|
|
58
|
+
exports.default = exports.ListItem;
|
|
@@ -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.List = void 0;
|
|
7
|
+
var List_1 = require("./List");
|
|
8
|
+
Object.defineProperty(exports, "List", { enumerable: true, get: function () { return __importDefault(List_1).default; } });
|
package/esm/index.d.ts
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
export * from "./accordion";
|
|
2
2
|
export * from "./alert";
|
|
3
|
-
export * from "./provider";
|
|
4
3
|
export * from "./button";
|
|
4
|
+
export * from "./chat";
|
|
5
|
+
export * from "./chips";
|
|
5
6
|
export * from "./date";
|
|
6
7
|
export * from "./form";
|
|
7
8
|
export * from "./grid";
|
|
8
|
-
export * from "./help-text";
|
|
9
9
|
export * from "./guide-panel";
|
|
10
|
+
export * from "./help-text";
|
|
10
11
|
export * from "./link";
|
|
11
12
|
export * from "./link-panel";
|
|
13
|
+
export * from "./list";
|
|
12
14
|
export * from "./loader";
|
|
13
15
|
export * from "./modal";
|
|
14
16
|
export * from "./pagination";
|
|
15
17
|
export * from "./panel";
|
|
16
18
|
export * from "./popover";
|
|
19
|
+
export * from "./provider";
|
|
17
20
|
export * from "./read-more";
|
|
18
|
-
export * from "./chat";
|
|
19
|
-
export * from "./chips";
|
|
20
21
|
export * from "./stepper";
|
|
21
|
-
export * from "./tag";
|
|
22
|
-
export * from "./toggle-group";
|
|
23
22
|
export * from "./table";
|
|
24
23
|
export * from "./tabs";
|
|
24
|
+
export * from "./tag";
|
|
25
|
+
export * from "./toggle-group";
|
|
25
26
|
export * from "./tooltip";
|
|
26
27
|
export * from "./typography";
|
|
27
28
|
export * from "./util";
|
package/esm/index.js
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
export * from "./accordion";
|
|
2
2
|
export * from "./alert";
|
|
3
|
-
export * from "./provider";
|
|
4
3
|
export * from "./button";
|
|
4
|
+
export * from "./chat";
|
|
5
|
+
export * from "./chips";
|
|
5
6
|
export * from "./date";
|
|
6
7
|
export * from "./form";
|
|
7
8
|
export * from "./grid";
|
|
8
|
-
export * from "./help-text";
|
|
9
9
|
export * from "./guide-panel";
|
|
10
|
+
export * from "./help-text";
|
|
10
11
|
export * from "./link";
|
|
11
12
|
export * from "./link-panel";
|
|
13
|
+
export * from "./list";
|
|
12
14
|
export * from "./loader";
|
|
13
15
|
export * from "./modal";
|
|
14
16
|
export * from "./pagination";
|
|
15
17
|
export * from "./panel";
|
|
16
18
|
export * from "./popover";
|
|
19
|
+
export * from "./provider";
|
|
17
20
|
export * from "./read-more";
|
|
18
|
-
export * from "./chat";
|
|
19
|
-
export * from "./chips";
|
|
20
21
|
export * from "./stepper";
|
|
21
|
-
export * from "./tag";
|
|
22
|
-
export * from "./toggle-group";
|
|
23
22
|
export * from "./table";
|
|
24
23
|
export * from "./tabs";
|
|
24
|
+
export * from "./tag";
|
|
25
|
+
export * from "./toggle-group";
|
|
25
26
|
export * from "./tooltip";
|
|
26
27
|
export * from "./typography";
|
|
27
28
|
export * from "./util";
|
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,
|
|
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,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,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,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ListItemType } from "./ListItem";
|
|
3
|
+
export interface ListProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
/**
|
|
6
|
+
* HTML list element to render
|
|
7
|
+
* @default "ul"
|
|
8
|
+
*/
|
|
9
|
+
as?: "ul" | "ol";
|
|
10
|
+
/**
|
|
11
|
+
* List heading title
|
|
12
|
+
*/
|
|
13
|
+
title?: string;
|
|
14
|
+
/**
|
|
15
|
+
* List heading description
|
|
16
|
+
*/
|
|
17
|
+
description?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Allows setting a different HTML h-tag
|
|
20
|
+
* @default "h3"
|
|
21
|
+
*/
|
|
22
|
+
headingTag?: React.ElementType<any>;
|
|
23
|
+
}
|
|
24
|
+
interface ListComponent extends React.ForwardRefExoticComponent<ListProps> {
|
|
25
|
+
Item: ListItemType;
|
|
26
|
+
}
|
|
27
|
+
interface ListContextProps {
|
|
28
|
+
listType: "ul" | "ol";
|
|
29
|
+
}
|
|
30
|
+
export declare const ListContext: React.Context<ListContextProps>;
|
|
31
|
+
export declare const List: ListComponent;
|
|
32
|
+
export default List;
|
package/esm/list/List.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
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, { createContext, forwardRef } from "react";
|
|
14
|
+
import { BodyShort, Heading } from "../typography";
|
|
15
|
+
import { useId } from "../util/useId";
|
|
16
|
+
import { ListItem } from "./ListItem";
|
|
17
|
+
export const ListContext = createContext({
|
|
18
|
+
listType: "ul",
|
|
19
|
+
});
|
|
20
|
+
export const List = forwardRef((_a, ref) => {
|
|
21
|
+
var { children, className, as: ListTag = "ul", title, description, headingTag = "h3" } = _a, rest = __rest(_a, ["children", "className", "as", "title", "description", "headingTag"]);
|
|
22
|
+
const ariaId = useId();
|
|
23
|
+
return (React.createElement(ListContext.Provider, { value: {
|
|
24
|
+
listType: ListTag,
|
|
25
|
+
} },
|
|
26
|
+
React.createElement("div", Object.assign({}, rest, { ref: ref, className: cl("navds-list", className) }),
|
|
27
|
+
title && (React.createElement(Heading, { id: `tittel-${ariaId}`, size: "small", as: headingTag }, title)),
|
|
28
|
+
description && (React.createElement(BodyShort, { id: `description-${ariaId}` }, description)),
|
|
29
|
+
React.createElement(ListTag, { "aria-labelledby": title && `tittel-${ariaId}`, "aria-describedby": description && `description-${ariaId}` }, children))));
|
|
30
|
+
});
|
|
31
|
+
List.Item = ListItem;
|
|
32
|
+
export default List;
|
|
33
|
+
//# sourceMappingURL=List.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"List.js","sourceRoot":"","sources":["../../src/list/List.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAgB,MAAM,YAAY,CAAC;AAgCpD,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAmB;IACzD,QAAQ,EAAE,IAAI;CACf,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,IAAI,GAAG,UAAU,CAC5B,CACE,EAQC,EACD,GAAG,EACH,EAAE;QAVF,EACE,QAAQ,EACR,SAAS,EACT,EAAE,EAAE,OAAO,GAAG,IAAI,EAClB,KAAK,EACL,WAAW,EACX,UAAU,GAAG,IAAI,OAElB,EADI,IAAI,cAPT,qEAQC,CADQ;IAIT,MAAM,MAAM,GAAG,KAAK,EAAE,CAAC;IAEvB,OAAO,CACL,oBAAC,WAAW,CAAC,QAAQ,IACnB,KAAK,EAAE;YACL,QAAQ,EAAE,OAAO;SAClB;QAED,6CAAS,IAAI,IAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,CAAC,YAAY,EAAE,SAAS,CAAC;YAC5D,KAAK,IAAI,CACR,oBAAC,OAAO,IAAC,EAAE,EAAE,UAAU,MAAM,EAAE,EAAE,IAAI,EAAC,OAAO,EAAC,EAAE,EAAE,UAAU,IACzD,KAAK,CACE,CACX;YACA,WAAW,IAAI,CACd,oBAAC,SAAS,IAAC,EAAE,EAAE,eAAe,MAAM,EAAE,IAAG,WAAW,CAAa,CAClE;YACD,oBAAC,OAAO,uBACW,KAAK,IAAI,UAAU,MAAM,EAAE,sBAC1B,WAAW,IAAI,eAAe,MAAM,EAAE,IAEvD,QAAQ,CACD,CACN,CACe,CACxB,CAAC;AACJ,CAAC,CACe,CAAC;AAEnB,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC;AAErB,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface ListItemProps extends React.HTMLAttributes<HTMLLIElement> {
|
|
3
|
+
/**
|
|
4
|
+
* Content for description of the list item
|
|
5
|
+
*/
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
/**
|
|
8
|
+
* Title for the list item
|
|
9
|
+
*/
|
|
10
|
+
title?: string;
|
|
11
|
+
icon?: React.ReactNode;
|
|
12
|
+
}
|
|
13
|
+
export interface ListItemType extends React.ForwardRefExoticComponent<ListItemProps & React.RefAttributes<HTMLLIElement>> {
|
|
14
|
+
}
|
|
15
|
+
export declare const ListItem: ListItemType;
|
|
16
|
+
export default ListItem;
|
|
@@ -0,0 +1,30 @@
|
|
|
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, useContext } from "react";
|
|
14
|
+
import { BodyShort, Label } from "../typography";
|
|
15
|
+
import { ListContext } from "./List";
|
|
16
|
+
export const ListItem = forwardRef((_a, ref) => {
|
|
17
|
+
var { className, children, title, icon } = _a, rest = __rest(_a, ["className", "children", "title", "icon"]);
|
|
18
|
+
const { listType } = useContext(ListContext);
|
|
19
|
+
return (React.createElement("li", Object.assign({}, rest, { ref: ref, className: cl("navds-list__item", className) }),
|
|
20
|
+
listType === "ul" && (React.createElement("div", { className: cl({
|
|
21
|
+
"navds-list__item-marker--icon": icon,
|
|
22
|
+
"navds-list__item-marker--bullet": !icon,
|
|
23
|
+
}) }, icon ? (icon) : (React.createElement("svg", { width: "6", height: "6", viewBox: "0 0 6 6", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": true, focusable: false, role: "img" },
|
|
24
|
+
React.createElement("rect", { width: "6", height: "6", rx: "3", fill: "currentColor" }))))),
|
|
25
|
+
React.createElement(BodyShort, { as: "div", size: "small", className: "navds-list__item-content" },
|
|
26
|
+
title && (React.createElement(Label, { as: "p", size: "small" }, title)),
|
|
27
|
+
children)));
|
|
28
|
+
});
|
|
29
|
+
export default ListItem;
|
|
30
|
+
//# sourceMappingURL=ListItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ListItem.js","sourceRoot":"","sources":["../../src/list/ListItem.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAsBrC,MAAM,CAAC,MAAM,QAAQ,GAAiB,UAAU,CAC9C,CAAC,EAA6C,EAAE,GAAG,EAAE,EAAE;QAAtD,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,OAAW,EAAN,IAAI,cAA3C,0CAA6C,CAAF;IAC1C,MAAM,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IAE7C,OAAO,CACL,4CAAQ,IAAI,IAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,CAAC,kBAAkB,EAAE,SAAS,CAAC;QACjE,QAAQ,KAAK,IAAI,IAAI,CACpB,6BACE,SAAS,EAAE,EAAE,CAAC;gBACZ,+BAA+B,EAAE,IAAI;gBACrC,iCAAiC,EAAE,CAAC,IAAI;aACzC,CAAC,IAED,IAAI,CAAC,CAAC,CAAC,CACN,IAAI,CACL,CAAC,CAAC,CAAC,CACF,6BACE,KAAK,EAAC,GAAG,EACT,MAAM,EAAC,GAAG,EACV,OAAO,EAAC,SAAS,EACjB,IAAI,EAAC,MAAM,EACX,KAAK,EAAC,4BAA4B,uBAElC,SAAS,EAAE,KAAK,EAChB,IAAI,EAAC,KAAK;YAEV,8BAAM,KAAK,EAAC,GAAG,EAAC,MAAM,EAAC,GAAG,EAAC,EAAE,EAAC,GAAG,EAAC,IAAI,EAAC,cAAc,GAAG,CACpD,CACP,CACG,CACP;QAED,oBAAC,SAAS,IAAC,EAAE,EAAC,KAAK,EAAC,IAAI,EAAC,OAAO,EAAC,SAAS,EAAC,0BAA0B;YAClE,KAAK,IAAI,CACR,oBAAC,KAAK,IAAC,EAAE,EAAC,GAAG,EAAC,IAAI,EAAC,OAAO,IACvB,KAAK,CACA,CACT;YACA,QAAQ,CACC,CACT,CACN,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/list/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,QAAQ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navikt/ds-react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Aksel react-components for NAV designsystem",
|
|
5
5
|
"author": "Aksel | NAV designsystem team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@floating-ui/react": "0.17.0",
|
|
40
|
-
"@navikt/ds-icons": "^2.
|
|
40
|
+
"@navikt/ds-icons": "^2.4.0",
|
|
41
41
|
"@radix-ui/react-tabs": "1.0.0",
|
|
42
42
|
"@radix-ui/react-toggle-group": "1.0.0",
|
|
43
43
|
"clsx": "^1.2.1",
|
package/src/index.ts
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
export * from "./accordion";
|
|
2
2
|
export * from "./alert";
|
|
3
|
-
export * from "./provider";
|
|
4
3
|
export * from "./button";
|
|
4
|
+
export * from "./chat";
|
|
5
|
+
export * from "./chips";
|
|
5
6
|
export * from "./date";
|
|
6
7
|
export * from "./form";
|
|
7
8
|
export * from "./grid";
|
|
8
|
-
export * from "./help-text";
|
|
9
9
|
export * from "./guide-panel";
|
|
10
|
+
export * from "./help-text";
|
|
10
11
|
export * from "./link";
|
|
11
12
|
export * from "./link-panel";
|
|
13
|
+
export * from "./list";
|
|
12
14
|
export * from "./loader";
|
|
13
15
|
export * from "./modal";
|
|
14
16
|
export * from "./pagination";
|
|
15
17
|
export * from "./panel";
|
|
16
18
|
export * from "./popover";
|
|
19
|
+
export * from "./provider";
|
|
17
20
|
export * from "./read-more";
|
|
18
|
-
export * from "./chat";
|
|
19
|
-
export * from "./chips";
|
|
20
21
|
export * from "./stepper";
|
|
21
|
-
export * from "./tag";
|
|
22
|
-
export * from "./toggle-group";
|
|
23
22
|
export * from "./table";
|
|
24
23
|
export * from "./tabs";
|
|
24
|
+
export * from "./tag";
|
|
25
|
+
export * from "./toggle-group";
|
|
25
26
|
export * from "./tooltip";
|
|
26
27
|
export * from "./typography";
|
|
27
28
|
export * from "./util";
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import cl from "clsx";
|
|
2
|
+
import React, { createContext, forwardRef } from "react";
|
|
3
|
+
import { BodyShort, Heading } from "../typography";
|
|
4
|
+
import { useId } from "../util/useId";
|
|
5
|
+
import { ListItem, ListItemType } from "./ListItem";
|
|
6
|
+
|
|
7
|
+
export interface ListProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
/**
|
|
10
|
+
* HTML list element to render
|
|
11
|
+
* @default "ul"
|
|
12
|
+
*/
|
|
13
|
+
as?: "ul" | "ol";
|
|
14
|
+
/**
|
|
15
|
+
* List heading title
|
|
16
|
+
*/
|
|
17
|
+
title?: string;
|
|
18
|
+
/**
|
|
19
|
+
* List heading description
|
|
20
|
+
*/
|
|
21
|
+
description?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Allows setting a different HTML h-tag
|
|
24
|
+
* @default "h3"
|
|
25
|
+
*/
|
|
26
|
+
headingTag?: React.ElementType<any>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface ListComponent extends React.ForwardRefExoticComponent<ListProps> {
|
|
30
|
+
Item: ListItemType;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface ListContextProps {
|
|
34
|
+
listType: "ul" | "ol";
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const ListContext = createContext<ListContextProps>({
|
|
38
|
+
listType: "ul",
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export const List = forwardRef<HTMLDivElement, ListProps>(
|
|
42
|
+
(
|
|
43
|
+
{
|
|
44
|
+
children,
|
|
45
|
+
className,
|
|
46
|
+
as: ListTag = "ul",
|
|
47
|
+
title,
|
|
48
|
+
description,
|
|
49
|
+
headingTag = "h3",
|
|
50
|
+
...rest
|
|
51
|
+
},
|
|
52
|
+
ref
|
|
53
|
+
) => {
|
|
54
|
+
const ariaId = useId();
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<ListContext.Provider
|
|
58
|
+
value={{
|
|
59
|
+
listType: ListTag,
|
|
60
|
+
}}
|
|
61
|
+
>
|
|
62
|
+
<div {...rest} ref={ref} className={cl("navds-list", className)}>
|
|
63
|
+
{title && (
|
|
64
|
+
<Heading id={`tittel-${ariaId}`} size="small" as={headingTag}>
|
|
65
|
+
{title}
|
|
66
|
+
</Heading>
|
|
67
|
+
)}
|
|
68
|
+
{description && (
|
|
69
|
+
<BodyShort id={`description-${ariaId}`}>{description}</BodyShort>
|
|
70
|
+
)}
|
|
71
|
+
<ListTag
|
|
72
|
+
aria-labelledby={title && `tittel-${ariaId}`}
|
|
73
|
+
aria-describedby={description && `description-${ariaId}`}
|
|
74
|
+
>
|
|
75
|
+
{children}
|
|
76
|
+
</ListTag>
|
|
77
|
+
</div>
|
|
78
|
+
</ListContext.Provider>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
) as ListComponent;
|
|
82
|
+
|
|
83
|
+
List.Item = ListItem;
|
|
84
|
+
|
|
85
|
+
export default List;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import cl from "clsx";
|
|
2
|
+
import React, { forwardRef, useContext } from "react";
|
|
3
|
+
import { BodyShort, Label } from "../typography";
|
|
4
|
+
import { ListContext } from "./List";
|
|
5
|
+
|
|
6
|
+
export interface ListItemProps extends React.HTMLAttributes<HTMLLIElement> {
|
|
7
|
+
/**
|
|
8
|
+
* Content for description of the list item
|
|
9
|
+
*/
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* Title for the list item
|
|
13
|
+
*/
|
|
14
|
+
title?: string;
|
|
15
|
+
/*
|
|
16
|
+
* Icon to be used as list marker
|
|
17
|
+
*/
|
|
18
|
+
icon?: React.ReactNode;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface ListItemType
|
|
22
|
+
extends React.ForwardRefExoticComponent<
|
|
23
|
+
ListItemProps & React.RefAttributes<HTMLLIElement>
|
|
24
|
+
> {}
|
|
25
|
+
|
|
26
|
+
export const ListItem: ListItemType = forwardRef(
|
|
27
|
+
({ className, children, title, icon, ...rest }, ref) => {
|
|
28
|
+
const { listType } = useContext(ListContext);
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<li {...rest} ref={ref} className={cl("navds-list__item", className)}>
|
|
32
|
+
{listType === "ul" && (
|
|
33
|
+
<div
|
|
34
|
+
className={cl({
|
|
35
|
+
"navds-list__item-marker--icon": icon,
|
|
36
|
+
"navds-list__item-marker--bullet": !icon,
|
|
37
|
+
})}
|
|
38
|
+
>
|
|
39
|
+
{icon ? (
|
|
40
|
+
icon
|
|
41
|
+
) : (
|
|
42
|
+
<svg
|
|
43
|
+
width="6"
|
|
44
|
+
height="6"
|
|
45
|
+
viewBox="0 0 6 6"
|
|
46
|
+
fill="none"
|
|
47
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
48
|
+
aria-hidden
|
|
49
|
+
focusable={false}
|
|
50
|
+
role="img"
|
|
51
|
+
>
|
|
52
|
+
<rect width="6" height="6" rx="3" fill="currentColor" />
|
|
53
|
+
</svg>
|
|
54
|
+
)}
|
|
55
|
+
</div>
|
|
56
|
+
)}
|
|
57
|
+
|
|
58
|
+
<BodyShort as="div" size="small" className="navds-list__item-content">
|
|
59
|
+
{title && (
|
|
60
|
+
<Label as="p" size="small">
|
|
61
|
+
{title}
|
|
62
|
+
</Label>
|
|
63
|
+
)}
|
|
64
|
+
{children}
|
|
65
|
+
</BodyShort>
|
|
66
|
+
</li>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
export default ListItem;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BabyChangingRoom,
|
|
3
|
+
Braille,
|
|
4
|
+
Cognition,
|
|
5
|
+
Refresh,
|
|
6
|
+
} from "@navikt/ds-icons";
|
|
7
|
+
import { Meta } from "@storybook/react";
|
|
8
|
+
import React from "react";
|
|
9
|
+
import { List } from "..";
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
title: "ds-react/List",
|
|
13
|
+
component: List,
|
|
14
|
+
} as Meta;
|
|
15
|
+
|
|
16
|
+
export const Default = {
|
|
17
|
+
render: () => {
|
|
18
|
+
return (
|
|
19
|
+
<List>
|
|
20
|
+
<List.Item title="Lorem Ipsum Dolor Sit Amet">
|
|
21
|
+
Lorem Ipsum Dolor Sit Amet
|
|
22
|
+
</List.Item>
|
|
23
|
+
<List.Item title="Consectetur Adipiscing Elit">
|
|
24
|
+
Beskrivelse på punktet i lista. Prøv å hold den kort og konsis.
|
|
25
|
+
</List.Item>
|
|
26
|
+
<List.Item title="Sed Do Eiusmod Tempor Incididunt">
|
|
27
|
+
Beskrivelse på punktet i lista. Prøv å hold den kort og konsis.
|
|
28
|
+
</List.Item>
|
|
29
|
+
</List>
|
|
30
|
+
);
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const Ordered = {
|
|
35
|
+
render: () => {
|
|
36
|
+
return (
|
|
37
|
+
<List as="ol">
|
|
38
|
+
<List.Item title="Lorem Ipsum Dolor Sit Amet">
|
|
39
|
+
Lorem Ipsum Dolor Sit Amet
|
|
40
|
+
</List.Item>
|
|
41
|
+
<List.Item title="Consectetur Adipiscing Elit">
|
|
42
|
+
Beskrivelse på punktet i lista. Prøv å hold den kort og konsis.
|
|
43
|
+
</List.Item>
|
|
44
|
+
<List.Item title="Sed Do Eiusmod Tempor Incididunt">
|
|
45
|
+
Beskrivelse på punktet i lista. Prøv å hold den kort og konsis.
|
|
46
|
+
</List.Item>
|
|
47
|
+
<List.Item title="Ut Labore Et Dolore Magna Aliqua">
|
|
48
|
+
Beskrivelse på punktet i lista. Prøv å hold den kort og konsis.
|
|
49
|
+
</List.Item>
|
|
50
|
+
<List.Item title="Enim Ad Minim Veniam">
|
|
51
|
+
Beskrivelse på punktet i lista. Prøv å hold den kort og konsis.
|
|
52
|
+
</List.Item>
|
|
53
|
+
<List.Item title="Quis Nostrud Exercitation Ullamco">
|
|
54
|
+
Beskrivelse på punktet i lista. Prøv å hold den kort og konsis.
|
|
55
|
+
</List.Item>
|
|
56
|
+
<List.Item title="Laboris Nisi Ut Aliquip Ex Ea Commodo">
|
|
57
|
+
Beskrivelse på punktet i lista. Prøv å hold den kort og konsis.
|
|
58
|
+
</List.Item>
|
|
59
|
+
<List.Item title="Duis Aute Irure Dolor In Reprehenderit">
|
|
60
|
+
Beskrivelse på punktet i lista. Prøv å hold den kort og konsis.
|
|
61
|
+
</List.Item>
|
|
62
|
+
<List.Item title="Voluptate Velit Esse Cillum Dolore">
|
|
63
|
+
Beskrivelse på punktet i lista. Prøv å hold den kort og konsis.
|
|
64
|
+
</List.Item>
|
|
65
|
+
<List.Item title="Eu Fugiat Nulla Pariatur">
|
|
66
|
+
Beskrivelse på punktet i lista. Prøv å hold den kort og konsis.
|
|
67
|
+
</List.Item>
|
|
68
|
+
</List>
|
|
69
|
+
);
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const WithHeading = {
|
|
74
|
+
render: () => {
|
|
75
|
+
return (
|
|
76
|
+
<List
|
|
77
|
+
title="Lorem Ipsum Dolor Sit Amet"
|
|
78
|
+
description="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam vel risus volutpat."
|
|
79
|
+
>
|
|
80
|
+
<List.Item title="Lorem Ipsum Dolor Sit Amet">
|
|
81
|
+
Beskrivelsen på punkter er nærmere forklart <a href="/">her</a>
|
|
82
|
+
</List.Item>
|
|
83
|
+
<List.Item title="Consectetur Adipiscing Elit">
|
|
84
|
+
Beskrivelsen på punkter er nærmere forklart <a href="/">her</a>
|
|
85
|
+
</List.Item>
|
|
86
|
+
<List.Item title="Sed Do Eiusmod Tempor Incididunt">
|
|
87
|
+
Beskrivelsen på punkter er nærmere forklart <a href="/">her</a>
|
|
88
|
+
</List.Item>
|
|
89
|
+
</List>
|
|
90
|
+
);
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export const Icons = {
|
|
95
|
+
render: () => {
|
|
96
|
+
return (
|
|
97
|
+
<List>
|
|
98
|
+
<List.Item
|
|
99
|
+
title="Lorem Ipsum Dolor Sit Amet"
|
|
100
|
+
icon={<Braille aria-hidden />}
|
|
101
|
+
>
|
|
102
|
+
Beskrivelsen på punkter er nærmere forklart <a href="/">her</a>
|
|
103
|
+
</List.Item>
|
|
104
|
+
<List.Item
|
|
105
|
+
title="Consectetur Adipiscing Elit"
|
|
106
|
+
icon={<Cognition aria-hidden />}
|
|
107
|
+
>
|
|
108
|
+
Beskrivelsen på punkter er nærmere forklart <a href="/">her</a>
|
|
109
|
+
</List.Item>
|
|
110
|
+
<List.Item icon={<BabyChangingRoom aria-hidden />}>
|
|
111
|
+
Beskrivelsen på punkter er nærmere forklart <a href="/">her</a>
|
|
112
|
+
</List.Item>
|
|
113
|
+
<List.Item icon={<Refresh aria-hidden />}>
|
|
114
|
+
Beskrivelsen på punkter er nærmere forklart <a href="/">her</a>
|
|
115
|
+
</List.Item>
|
|
116
|
+
</List>
|
|
117
|
+
);
|
|
118
|
+
},
|
|
119
|
+
};
|