@navikt/ds-react 0.17.5 → 0.17.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cjs/index.js CHANGED
@@ -29,6 +29,7 @@ __exportStar(require("./modal"), exports);
29
29
  __exportStar(require("./pagination"), exports);
30
30
  __exportStar(require("./panel"), exports);
31
31
  __exportStar(require("./popover"), exports);
32
+ __exportStar(require("./read-more"), exports);
32
33
  __exportStar(require("./speech-bubble"), exports);
33
34
  __exportStar(require("./step-indicator"), exports);
34
35
  __exportStar(require("./tag"), exports);
@@ -0,0 +1,67 @@
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
+ const react_1 = __importStar(require("react"));
41
+ const classnames_1 = __importDefault(require("classnames"));
42
+ const react_collapse_1 = require("react-collapse");
43
+ const ds_icons_1 = require("@navikt/ds-icons");
44
+ const typography_1 = require("../typography");
45
+ const ReadMore = (0, react_1.forwardRef)((_a, ref) => {
46
+ var { className, header, renderContentWhenClosed = false, children, open, defaultOpen = false, onClick } = _a, rest = __rest(_a, ["className", "header", "renderContentWhenClosed", "children", "open", "defaultOpen", "onClick"]);
47
+ const [internalOpen, setInternalOpen] = (0, react_1.useState)(defaultOpen);
48
+ const CollapseComponent = renderContentWhenClosed
49
+ ? react_collapse_1.Collapse
50
+ : react_collapse_1.UnmountClosed;
51
+ const isOpened = open !== null && open !== void 0 ? open : internalOpen;
52
+ return (react_1.default.createElement(react_1.default.Fragment, null,
53
+ react_1.default.createElement("button", Object.assign({}, rest, { className: (0, classnames_1.default)("navds-read-more", "navds-body-short", "navds-body-short--small", className, {
54
+ "navds-read-more--open": isOpened,
55
+ }), onClick: (e) => {
56
+ if (open === undefined) {
57
+ setInternalOpen((isOpen) => !isOpen);
58
+ }
59
+ onClick === null || onClick === void 0 ? void 0 : onClick(e);
60
+ }, "aria-expanded": isOpened, ref: ref }),
61
+ react_1.default.createElement(ds_icons_1.Expand, { className: "navds-read-more__expand-icon", "aria-hidden": true }),
62
+ react_1.default.createElement("span", null, header)),
63
+ react_1.default.createElement(CollapseComponent, { isOpened: isOpened },
64
+ react_1.default.createElement("div", { className: "navds-read-more__content" },
65
+ react_1.default.createElement(typography_1.BodyLong, { size: "small" }, children)))));
66
+ });
67
+ exports.default = ReadMore;
@@ -0,0 +1,23 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.ReadMore = void 0;
21
+ var ReadMore_1 = require("./ReadMore");
22
+ Object.defineProperty(exports, "ReadMore", { enumerable: true, get: function () { return __importDefault(ReadMore_1).default; } });
23
+ __exportStar(require("./ReadMore"), exports);
@@ -0,0 +1,6 @@
1
+ {
2
+ "sideEffects": false,
3
+ "main": "./index.js",
4
+ "module": "../../esm/read-more/index.js",
5
+ "types": "../../esm/read-more/index.d.ts"
6
+ }
@@ -56,7 +56,6 @@ const ColumnHeader = (0, react_1.forwardRef)((_a, ref) => {
56
56
  ? () => { var _a; return (_a = context === null || context === void 0 ? void 0 : context.onSortChange) === null || _a === void 0 ? void 0 : _a.call(context, sortKey); }
57
57
  : undefined },
58
58
  children,
59
- ((_d = context === null || context === void 0 ? void 0 : context.sort) === null || _d === void 0 ? void 0 : _d.orderBy) === sortKey &&
60
- ((_e = context === null || context === void 0 ? void 0 : context.sort) === null || _e === void 0 ? void 0 : _e.direction) === "descending" ? (react_1.default.createElement(ds_icons_1.Down, { "aria-label": "sorter synkende" })) : (react_1.default.createElement(ds_icons_1.Up, { "aria-label": "sorter stigende" })))) : (children)));
59
+ ((_d = context === null || context === void 0 ? void 0 : context.sort) === null || _d === void 0 ? void 0 : _d.orderBy) === sortKey ? (((_e = context === null || context === void 0 ? void 0 : context.sort) === null || _e === void 0 ? void 0 : _e.direction) === "descending" ? (react_1.default.createElement(ds_icons_1.Down, { "aria-hidden": true })) : (react_1.default.createElement(ds_icons_1.Up, { "aria-hidden": true }))) : (react_1.default.createElement(ds_icons_1.UpDown, { "aria-hidden": true })))) : (children)));
61
60
  });
62
61
  exports.default = ColumnHeader;
package/esm/index.d.ts CHANGED
@@ -13,6 +13,7 @@ export * from "./modal";
13
13
  export * from "./pagination";
14
14
  export * from "./panel";
15
15
  export * from "./popover";
16
+ export * from "./read-more";
16
17
  export * from "./speech-bubble";
17
18
  export * from "./step-indicator";
18
19
  export * from "./tag";
package/esm/index.js CHANGED
@@ -13,6 +13,7 @@ export * from "./modal";
13
13
  export * from "./pagination";
14
14
  export * from "./panel";
15
15
  export * from "./popover";
16
+ export * from "./read-more";
16
17
  export * from "./speech-bubble";
17
18
  export * from "./step-indicator";
18
19
  export * from "./tag";
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,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,OAAO,CAAC;AACtB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AAEvB,6BAA6B;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,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,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,OAAO,CAAC;AACtB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AAEvB,6BAA6B;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC"}
@@ -0,0 +1,28 @@
1
+ import React from "react";
2
+ export interface ReadMoreProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
3
+ /**
4
+ * Content inside read more
5
+ */
6
+ children: React.ReactNode;
7
+ /**
8
+ * Read more header content
9
+ */
10
+ header: React.ReactNode;
11
+ /**
12
+ * Opens component if 'true', closes if 'false'
13
+ * Using this props removes automatic control of open-state
14
+ */
15
+ open?: boolean;
16
+ /**
17
+ * Defaults the accordion to opened state
18
+ * @default false
19
+ */
20
+ defaultOpen?: boolean;
21
+ /**
22
+ * Removes content-element from dom when closed
23
+ * @default false
24
+ */
25
+ renderContentWhenClosed?: boolean;
26
+ }
27
+ declare const ReadMore: React.ForwardRefExoticComponent<ReadMoreProps & React.RefAttributes<HTMLButtonElement>>;
28
+ export default ReadMore;
@@ -0,0 +1,40 @@
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 React, { forwardRef, useState } from "react";
13
+ import cl from "classnames";
14
+ import { Collapse, UnmountClosed } from "react-collapse";
15
+ import { Expand } from "@navikt/ds-icons";
16
+ import { BodyLong } from "../typography";
17
+ const ReadMore = forwardRef((_a, ref) => {
18
+ var { className, header, renderContentWhenClosed = false, children, open, defaultOpen = false, onClick } = _a, rest = __rest(_a, ["className", "header", "renderContentWhenClosed", "children", "open", "defaultOpen", "onClick"]);
19
+ const [internalOpen, setInternalOpen] = useState(defaultOpen);
20
+ const CollapseComponent = renderContentWhenClosed
21
+ ? Collapse
22
+ : UnmountClosed;
23
+ const isOpened = open !== null && open !== void 0 ? open : internalOpen;
24
+ return (React.createElement(React.Fragment, null,
25
+ React.createElement("button", Object.assign({}, rest, { className: cl("navds-read-more", "navds-body-short", "navds-body-short--small", className, {
26
+ "navds-read-more--open": isOpened,
27
+ }), onClick: (e) => {
28
+ if (open === undefined) {
29
+ setInternalOpen((isOpen) => !isOpen);
30
+ }
31
+ onClick === null || onClick === void 0 ? void 0 : onClick(e);
32
+ }, "aria-expanded": isOpened, ref: ref }),
33
+ React.createElement(Expand, { className: "navds-read-more__expand-icon", "aria-hidden": true }),
34
+ React.createElement("span", null, header)),
35
+ React.createElement(CollapseComponent, { isOpened: isOpened },
36
+ React.createElement("div", { className: "navds-read-more__content" },
37
+ React.createElement(BodyLong, { size: "small" }, children)))));
38
+ });
39
+ export default ReadMore;
40
+ //# sourceMappingURL=ReadMore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReadMore.js","sourceRoot":"","sources":["../../src/read-more/ReadMore.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AA6BzC,MAAM,QAAQ,GAAG,UAAU,CACzB,CACE,EASC,EACD,GAAG,EACH,EAAE;QAXF,EACE,SAAS,EACT,MAAM,EACN,uBAAuB,GAAG,KAAK,EAC/B,QAAQ,EACR,IAAI,EACJ,WAAW,GAAG,KAAK,EACnB,OAAO,OAER,EADI,IAAI,cART,gGASC,CADQ;IAIT,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAU,WAAW,CAAC,CAAC;IACvE,MAAM,iBAAiB,GAAG,uBAAuB;QAC/C,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC,aAAa,CAAC;IAElB,MAAM,QAAQ,GAAG,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,YAAY,CAAC;IAEtC,OAAO,CACL;QACE,gDACM,IAAI,IACR,SAAS,EAAE,EAAE,CACX,iBAAiB,EACjB,kBAAkB,EAClB,yBAAyB,EACzB,SAAS,EACT;gBACE,uBAAuB,EAAE,QAAQ;aAClC,CACF,EACD,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;gBACb,IAAI,IAAI,KAAK,SAAS,EAAE;oBACtB,eAAe,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;iBACtC;gBACD,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAG,CAAC,CAAC,CAAC;YACf,CAAC,mBACc,QAAQ,EACvB,GAAG,EAAE,GAAG;YAER,oBAAC,MAAM,IAAC,SAAS,EAAC,8BAA8B,wBAAe;YAC/D,kCAAO,MAAM,CAAQ,CACd;QACT,oBAAC,iBAAiB,IAAC,QAAQ,EAAE,QAAQ;YACnC,6BAAK,SAAS,EAAC,0BAA0B;gBACvC,oBAAC,QAAQ,IAAC,IAAI,EAAC,OAAO,IAAE,QAAQ,CAAY,CACxC,CACY,CACnB,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { default as ReadMore } from "./ReadMore";
2
+ export * from "./ReadMore";
@@ -0,0 +1,3 @@
1
+ export { default as ReadMore } from "./ReadMore";
2
+ export * from "./ReadMore";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/read-more/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,cAAc,YAAY,CAAC"}
@@ -10,7 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import React, { forwardRef, useContext } from "react";
13
- import { Down, Up } from "@navikt/ds-icons";
13
+ import { Down, Up, UpDown } from "@navikt/ds-icons";
14
14
  import { TableContext } from "..";
15
15
  import HeaderCell from "./HeaderCell";
16
16
  const ColumnHeader = forwardRef((_a, ref) => {
@@ -28,8 +28,7 @@ const ColumnHeader = forwardRef((_a, ref) => {
28
28
  ? () => { var _a; return (_a = context === null || context === void 0 ? void 0 : context.onSortChange) === null || _a === void 0 ? void 0 : _a.call(context, sortKey); }
29
29
  : undefined },
30
30
  children,
31
- ((_d = context === null || context === void 0 ? void 0 : context.sort) === null || _d === void 0 ? void 0 : _d.orderBy) === sortKey &&
32
- ((_e = context === null || context === void 0 ? void 0 : context.sort) === null || _e === void 0 ? void 0 : _e.direction) === "descending" ? (React.createElement(Down, { "aria-label": "sorter synkende" })) : (React.createElement(Up, { "aria-label": "sorter stigende" })))) : (children)));
31
+ ((_d = context === null || context === void 0 ? void 0 : context.sort) === null || _d === void 0 ? void 0 : _d.orderBy) === sortKey ? (((_e = context === null || context === void 0 ? void 0 : context.sort) === null || _e === void 0 ? void 0 : _e.direction) === "descending" ? (React.createElement(Down, { "aria-hidden": true })) : (React.createElement(Up, { "aria-hidden": true }))) : (React.createElement(UpDown, { "aria-hidden": true })))) : (children)));
33
32
  });
34
33
  export default ColumnHeader;
35
34
  //# sourceMappingURL=ColumnHeader.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ColumnHeader.js","sourceRoot":"","sources":["../../src/table/ColumnHeader.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,UAA+B,MAAM,cAAc,CAAC;AAmB3D,MAAM,YAAY,GAAqB,UAAU,CAC/C,CAAC,EAA2D,EAAE,GAAG,EAAE,EAAE;;QAApE,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,GAAG,KAAK,EAAE,OAAO,OAAW,EAAN,IAAI,cAAzD,gDAA2D,CAAF;IACxD,MAAM,OAAO,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;IAEzC,IAAI,QAAQ,IAAI,CAAC,OAAO,EAAE;QACxB,OAAO,CAAC,IAAI,CAAC,wDAAwD,CAAC,CAAC;KACxE;IAED,OAAO,CACL,oBAAC,UAAU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CAAC,CAAC,CAAC,CAC1C,oBAAC,IAAI,0BAAe,CACrB,CAAC,CAAC,CAAC,CACF,oBAAC,EAAE,0BAAe,CACnB,CACF,CAAC,CAAC,CAAC,CACF,oBAAC,MAAM,0BAAe,CACvB,CACM,CACV,CAAC,CAAC,CAAC,CACF,QAAQ,CACT,CACU,CACd,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,YAAY,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@navikt/ds-react",
3
- "version": "0.17.5",
3
+ "version": "0.17.8",
4
4
  "private": false,
5
5
  "description": "NAV designsystem react components",
6
6
  "author": "NAV Designsystem team",
@@ -35,7 +35,7 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@material-ui/core": "^4.12.3",
38
- "@navikt/ds-icons": "^0.8.5",
38
+ "@navikt/ds-icons": "^0.8.6",
39
39
  "@popperjs/core": "^2.10.1",
40
40
  "@radix-ui/react-toggle-group": "0.1.5",
41
41
  "classnames": "^2.2.6",
@@ -51,6 +51,7 @@
51
51
  "@testing-library/user-event": "^13.2.1",
52
52
  "@types/faker": "^5.5.8",
53
53
  "@types/jest": "^27.0.1",
54
+ "@types/react-collapse": "^5.0.1",
54
55
  "@types/react-modal": "^3.13.1",
55
56
  "@types/styled-components": "^5.1.14",
56
57
  "copyfiles": "^2.4.1",
@@ -66,5 +67,5 @@
66
67
  "@types/react": "^17.0.30",
67
68
  "react": "^17.0.0"
68
69
  },
69
- "gitHead": "b2a71fd227ccbe3709094c0c85d1174694dda450"
70
+ "gitHead": "a3b28bb9ad1ca3a3a188d643ee26918d36805bf2"
70
71
  }
package/src/index.ts CHANGED
@@ -13,6 +13,7 @@ export * from "./modal";
13
13
  export * from "./pagination";
14
14
  export * from "./panel";
15
15
  export * from "./popover";
16
+ export * from "./read-more";
16
17
  export * from "./speech-bubble";
17
18
  export * from "./step-indicator";
18
19
  export * from "./tag";
@@ -0,0 +1,90 @@
1
+ import React, { forwardRef, useState } from "react";
2
+ import cl from "classnames";
3
+ import { Collapse, UnmountClosed } from "react-collapse";
4
+ import { Expand } from "@navikt/ds-icons";
5
+ import { BodyLong } from "../typography";
6
+
7
+ export interface ReadMoreProps
8
+ extends React.ButtonHTMLAttributes<HTMLButtonElement> {
9
+ /**
10
+ * Content inside read more
11
+ */
12
+ children: React.ReactNode;
13
+ /**
14
+ * Read more header content
15
+ */
16
+ header: React.ReactNode;
17
+ /**
18
+ * Opens component if 'true', closes if 'false'
19
+ * Using this props removes automatic control of open-state
20
+ */
21
+ open?: boolean;
22
+ /**
23
+ * Defaults the accordion to opened state
24
+ * @default false
25
+ */
26
+ defaultOpen?: boolean;
27
+ /**
28
+ * Removes content-element from dom when closed
29
+ * @default false
30
+ */
31
+ renderContentWhenClosed?: boolean;
32
+ }
33
+
34
+ const ReadMore = forwardRef<HTMLButtonElement, ReadMoreProps>(
35
+ (
36
+ {
37
+ className,
38
+ header,
39
+ renderContentWhenClosed = false,
40
+ children,
41
+ open,
42
+ defaultOpen = false,
43
+ onClick,
44
+ ...rest
45
+ },
46
+ ref
47
+ ) => {
48
+ const [internalOpen, setInternalOpen] = useState<boolean>(defaultOpen);
49
+ const CollapseComponent = renderContentWhenClosed
50
+ ? Collapse
51
+ : UnmountClosed;
52
+
53
+ const isOpened = open ?? internalOpen;
54
+
55
+ return (
56
+ <>
57
+ <button
58
+ {...rest}
59
+ className={cl(
60
+ "navds-read-more",
61
+ "navds-body-short",
62
+ "navds-body-short--small",
63
+ className,
64
+ {
65
+ "navds-read-more--open": isOpened,
66
+ }
67
+ )}
68
+ onClick={(e) => {
69
+ if (open === undefined) {
70
+ setInternalOpen((isOpen) => !isOpen);
71
+ }
72
+ onClick?.(e);
73
+ }}
74
+ aria-expanded={isOpened}
75
+ ref={ref}
76
+ >
77
+ <Expand className="navds-read-more__expand-icon" aria-hidden />
78
+ <span>{header}</span>
79
+ </button>
80
+ <CollapseComponent isOpened={isOpened}>
81
+ <div className="navds-read-more__content">
82
+ <BodyLong size="small">{children}</BodyLong>
83
+ </div>
84
+ </CollapseComponent>
85
+ </>
86
+ );
87
+ }
88
+ );
89
+
90
+ export default ReadMore;
@@ -0,0 +1,2 @@
1
+ export { default as ReadMore } from "./ReadMore";
2
+ export * from "./ReadMore";
@@ -0,0 +1,60 @@
1
+ import React, { useState } from "react";
2
+ import { ReadMore } from ".";
3
+ import { Link } from "..";
4
+
5
+ export default {
6
+ title: "ds-react/read-more",
7
+ component: ReadMore,
8
+ };
9
+
10
+ export const All = () => {
11
+ const [open, setOpen] = useState(false);
12
+
13
+ return (
14
+ <>
15
+ <h1>Read more</h1>
16
+ <h2>Controlled</h2>
17
+ <ReadMore
18
+ open={open}
19
+ onClick={() => setOpen(!open)}
20
+ header="ReadMore header text"
21
+ >
22
+ Magna aliquip aliquip fugiat nostrud nostrud velit pariatur veniam
23
+ officia laboris voluptate officia pariatur.Lorem est ex anim velit
24
+ occaecat nisi qui nostrud sit consectetur consectetur officia nostrud
25
+ ullamco. Est ex duis proident nostrud elit qui laborum anim minim eu
26
+ eiusmod. Veniam in nostrud sunt tempor velit incididunt sint ex dolor
27
+ qui velit id eu.{" "}
28
+ <Link href="example.com">Deserunt magna sunt velit in</Link>. Est
29
+ exercitation id cillum qui do. Minim adipisicing nostrud commodo
30
+ proident occaecat aliquip nulla anim proident reprehenderit. Magna ipsum
31
+ officia veniam cupidatat duis veniam dolore reprehenderit mollit
32
+ velit.Ut consequat commodo minim occaecat id pariatur. Nisi enim tempor
33
+ laborum commodo. Tempor sit quis nostrud eu cupidatat sunt commodo
34
+ reprehenderit irure deserunt eiusmod ipsum. Exercitation quis commodo
35
+ cillum eiusmod eiusmod. Do laborum qui proident commodo adipisicing
36
+ eiusmod id.
37
+ </ReadMore>
38
+ <h2>Un-controlled</h2>
39
+ <ReadMore header="ReadMore header text">
40
+ Magna aliquip aliquip fugiat nostrud nostrud velit pariatur veniam
41
+ officia laboris voluptate officia pariatur.Lorem est ex anim velit
42
+ occaecat nisi qui nostrud sit consectetur consectetur officia nostrud
43
+ ullamco. Est ex duis proident nostrud elit qui laborum anim minim eu
44
+ eiusmod. Veniam in nostrud sunt tempor velit incididunt sint ex dolor
45
+ qui velit id eu. Deserunt magna sunt velit in. Est exercitation id
46
+ cillum qui do. Minim adipisicing nostrud commodo proident occaecat
47
+ aliquip nulla anim proident reprehenderit. Magna ipsum officia veniam
48
+ cupidatat duis veniam dolore reprehenderit mollit velit.Ut consequat
49
+ commodo minim occaecat id pariatur. Nisi enim tempor laborum commodo.
50
+ Tempor sit quis nostrud eu cupidatat sunt commodo reprehenderit irure
51
+ deserunt eiusmod ipsum. Exercitation quis commodo cillum eiusmod
52
+ eiusmod. Do laborum qui proident commodo adipisicing eiusmod id.
53
+ </ReadMore>
54
+ <h2>Default open</h2>
55
+ <ReadMore header="ReadMore header text" defaultOpen>
56
+ Body
57
+ </ReadMore>
58
+ </>
59
+ );
60
+ };
@@ -1,5 +1,5 @@
1
1
  import React, { forwardRef, useContext } from "react";
2
- import { Down, Up } from "@navikt/ds-icons";
2
+ import { Down, Up, UpDown } from "@navikt/ds-icons";
3
3
  import { TableContext } from "..";
4
4
  import HeaderCell, { HeaderCellProps } from "./HeaderCell";
5
5
 
@@ -52,11 +52,14 @@ const ColumnHeader: ColumnHeaderType = forwardRef(
52
52
  }
53
53
  >
54
54
  {children}
55
- {context?.sort?.orderBy === sortKey &&
56
- context?.sort?.direction === "descending" ? (
57
- <Down aria-label="sorter synkende" />
55
+ {context?.sort?.orderBy === sortKey ? (
56
+ context?.sort?.direction === "descending" ? (
57
+ <Down aria-hidden />
58
+ ) : (
59
+ <Up aria-hidden />
60
+ )
58
61
  ) : (
59
- <Up aria-label="sorter stigende" />
62
+ <UpDown aria-hidden />
60
63
  )}
61
64
  </button>
62
65
  ) : (