@biblioteksentralen/react 1.0.0-beta.5 → 1.0.0-beta.7
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/README.md +11 -0
- package/dist/index.d.ts +118 -14
- package/dist/index.js +999 -43
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +558 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +22 -8
- package/.turbo/turbo-build.log +0 -8
- package/.turbo/turbo-test.log +0 -13
- package/.turbo/turbo-type-check.log +0 -4
- package/dist/BiblioteksentralenProvider.d.ts +0 -8
- package/dist/BiblioteksentralenProvider.js +0 -15
- package/dist/components/Alert.d.ts +0 -11
- package/dist/components/Alert.js +0 -59
- package/dist/components/Button.d.ts +0 -12
- package/dist/components/Button.js +0 -5
- package/dist/components/ConditionalWrapper.d.ts +0 -13
- package/dist/components/ConditionalWrapper.js +0 -15
- package/dist/components/ErrorBoundary.d.ts +0 -19
- package/dist/components/ErrorBoundary.js +0 -70
- package/dist/components/HashLinkTarget.d.ts +0 -14
- package/dist/components/HashLinkTarget.js +0 -35
- package/dist/components/HideWithCSS.d.ts +0 -10
- package/dist/components/HideWithCSS.js +0 -38
- package/dist/components/Input.d.ts +0 -15
- package/dist/components/Input.js +0 -63
- package/dist/components/Link.d.ts +0 -12
- package/dist/components/Link.js +0 -5
- package/dist/components/VisuallyHidden.d.ts +0 -6
- package/dist/components/VisuallyHidden.js +0 -68
- package/dist/components/withErrorBoundary.d.ts +0 -2
- package/dist/components/withErrorBoundary.js +0 -24
- package/dist/styles/chakraTheme/ButtonStyles.d.ts +0 -3
- package/dist/styles/chakraTheme/ButtonStyles.js +0 -52
- package/dist/styles/chakraTheme/CheckboxStyles.d.ts +0 -4
- package/dist/styles/chakraTheme/CheckboxStyles.js +0 -15
- package/dist/styles/chakraTheme/ContainerStyles.d.ts +0 -2
- package/dist/styles/chakraTheme/ContainerStyles.js +0 -8
- package/dist/styles/chakraTheme/HeadingStyles.d.ts +0 -2
- package/dist/styles/chakraTheme/HeadingStyles.js +0 -8
- package/dist/styles/chakraTheme/InputStyles.d.ts +0 -2
- package/dist/styles/chakraTheme/InputStyles.js +0 -42
- package/dist/styles/chakraTheme/LinkStyles.d.ts +0 -3
- package/dist/styles/chakraTheme/LinkStyles.js +0 -20
- package/dist/styles/chakraTheme/ModalStyles.d.ts +0 -2
- package/dist/styles/chakraTheme/ModalStyles.js +0 -13
- package/dist/styles/chakraTheme/SpinnerStyles.d.ts +0 -2
- package/dist/styles/chakraTheme/SpinnerStyles.js +0 -18
- package/dist/styles/chakraTheme/biblioteksentralenChakraTheme.d.ts +0 -2
- package/dist/styles/chakraTheme/biblioteksentralenChakraTheme.js +0 -35
- package/dist/styles/chakraTheme/sizes.d.ts +0 -8
- package/dist/styles/chakraTheme/sizes.js +0 -12
- package/src/BiblioteksentralenProvider.tsx +0 -16
- package/src/components/Alert.tsx +0 -60
- package/src/components/Button.tsx +0 -11
- package/src/components/ConditionalWrapper.tsx +0 -13
- package/src/components/ErrorBoundary.tsx +0 -60
- package/src/components/HashLinkTarget.tsx +0 -51
- package/src/components/HideWithCSS.tsx +0 -22
- package/src/components/Input.tsx +0 -37
- package/src/components/Link.tsx +0 -10
- package/src/components/VisuallyHidden.tsx +0 -36
- package/src/components/withErrorBoundary.tsx +0 -10
- package/src/index.ts +0 -16
- package/src/styles/chakraTheme/ButtonStyles.ts +0 -55
- package/src/styles/chakraTheme/CheckboxStyles.ts +0 -19
- package/src/styles/chakraTheme/ContainerStyles.ts +0 -7
- package/src/styles/chakraTheme/HeadingStyles.ts +0 -7
- package/src/styles/chakraTheme/InputStyles.ts +0 -41
- package/src/styles/chakraTheme/LinkStyles.ts +0 -23
- package/src/styles/chakraTheme/ModalStyles.ts +0 -12
- package/src/styles/chakraTheme/SpinnerStyles.ts +0 -13
- package/src/styles/chakraTheme/biblioteksentralenChakraTheme.ts +0 -34
- package/src/styles/chakraTheme/sizes.ts +0 -10
- package/tsconfig.json +0 -8
package/package.json
CHANGED
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@biblioteksentralen/react",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.7",
|
|
4
4
|
"description": "React library for reusable code in Biblioteksentralens js-apps",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
5
|
"keywords": [],
|
|
8
6
|
"author": "Biblioteksentralen",
|
|
9
7
|
"license": "MIT",
|
|
10
8
|
"private": false,
|
|
9
|
+
"main": "dist/index.js",
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"./dist/*.{js,mjs,d.ts,map}",
|
|
13
|
+
"*.md",
|
|
14
|
+
"LICENSE"
|
|
15
|
+
],
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"import": "./dist/index.mjs",
|
|
19
|
+
"require": "./dist/index.js",
|
|
20
|
+
"types": "./dist/index.d.ts"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
11
23
|
"prettier": {
|
|
12
24
|
"printWidth": 120
|
|
13
25
|
},
|
|
@@ -22,12 +34,14 @@
|
|
|
22
34
|
"date-fns": "^3.0.6"
|
|
23
35
|
},
|
|
24
36
|
"devDependencies": {
|
|
37
|
+
"@swc/core": "^1.3.102",
|
|
25
38
|
"@types/react": "^18.2.45",
|
|
26
39
|
"react": "^18.2.0",
|
|
27
40
|
"react-dom": "^18.2.0",
|
|
28
|
-
"
|
|
29
|
-
"@biblioteksentralen/
|
|
30
|
-
"@biblioteksentralen/utils": "1.0.0-beta.
|
|
41
|
+
"tsup": "^8.0.1",
|
|
42
|
+
"@biblioteksentralen/icons": "1.0.0-beta.9",
|
|
43
|
+
"@biblioteksentralen/utils": "1.0.0-beta.9",
|
|
44
|
+
"@biblioteksentralen/types": "1.0.0-beta.7"
|
|
31
45
|
},
|
|
32
46
|
"peerDependencies": {
|
|
33
47
|
"react": "^18.2.0",
|
|
@@ -37,7 +51,7 @@
|
|
|
37
51
|
"test": "vitest --watch=false",
|
|
38
52
|
"type-check": "tsc --noEmit",
|
|
39
53
|
"clean": "rm -rf dist",
|
|
40
|
-
"build": "pnpm run clean && tsc",
|
|
41
|
-
"
|
|
54
|
+
"build": "pnpm run clean && tsc && tsup src/index.ts && cp ../../LICENSE dist",
|
|
55
|
+
"clean:node_modules": "rm -rf node_modules"
|
|
42
56
|
}
|
|
43
57
|
}
|
package/.turbo/turbo-build.log
DELETED
package/.turbo/turbo-test.log
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> @biblioteksentralen/react@1.0.0-beta.4 test /Users/jorgenfulsebakke/repos/js-utils/packages/react
|
|
3
|
-
> vitest --watch=false
|
|
4
|
-
|
|
5
|
-
[33mThe CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.[39m
|
|
6
|
-
|
|
7
|
-
RUN v1.1.0 /Users/jorgenfulsebakke/repos/js-utils/packages/react
|
|
8
|
-
|
|
9
|
-
include: **/*.{test,spec}.?(c|m)[jt]s?(x)
|
|
10
|
-
exclude: **/node_modules/**, **/dist/**, **/cypress/**, **/.{idea,git,cache,output,temp}/**, **/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*
|
|
11
|
-
watch exclude: **/node_modules/**, **/dist/**
|
|
12
|
-
No test files found, exiting with code 0
|
|
13
|
-
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ChakraTheme } from "@chakra-ui/react";
|
|
2
|
-
import React, { ReactNode } from "react";
|
|
3
|
-
interface Props {
|
|
4
|
-
children: ReactNode;
|
|
5
|
-
customTheme?: Partial<ChakraTheme>;
|
|
6
|
-
}
|
|
7
|
-
export declare const BiblioteksentralenProvider: (props: Props) => React.JSX.Element;
|
|
8
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
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.BiblioteksentralenProvider = void 0;
|
|
7
|
-
var react_1 = require("@chakra-ui/react");
|
|
8
|
-
var react_2 = __importDefault(require("react"));
|
|
9
|
-
var biblioteksentralenChakraTheme_1 = require("./styles/chakraTheme/biblioteksentralenChakraTheme");
|
|
10
|
-
var emptyTheme = {};
|
|
11
|
-
var BiblioteksentralenProvider = function (props) {
|
|
12
|
-
var _a;
|
|
13
|
-
return (react_2.default.createElement(react_1.ChakraProvider, { theme: (0, react_1.extendTheme)(biblioteksentralenChakraTheme_1.biblioteksentralenChakraTheme, (_a = props.customTheme) !== null && _a !== void 0 ? _a : emptyTheme) }, props.children));
|
|
14
|
-
};
|
|
15
|
-
exports.BiblioteksentralenProvider = BiblioteksentralenProvider;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { AlertProps, FlexProps } from "@chakra-ui/react";
|
|
2
|
-
import React, { ReactNode } from "react";
|
|
3
|
-
type Status = Exclude<AlertProps["status"], undefined | "loading">;
|
|
4
|
-
type Variants = "inline";
|
|
5
|
-
interface Props extends FlexProps {
|
|
6
|
-
children: ReactNode;
|
|
7
|
-
status: Status;
|
|
8
|
-
variant?: Variants;
|
|
9
|
-
}
|
|
10
|
-
export declare function Alert({ status, children, variant, ...rest }: Props): React.JSX.Element;
|
|
11
|
-
export {};
|
package/dist/components/Alert.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
-
var t = {};
|
|
15
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
-
t[p] = s[p];
|
|
17
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
-
t[p[i]] = s[p[i]];
|
|
21
|
-
}
|
|
22
|
-
return t;
|
|
23
|
-
};
|
|
24
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
|
-
};
|
|
27
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.Alert = void 0;
|
|
29
|
-
var icons_1 = require("@biblioteksentralen/icons");
|
|
30
|
-
var utils_1 = require("@biblioteksentralen/utils");
|
|
31
|
-
var react_1 = require("@chakra-ui/react");
|
|
32
|
-
var react_2 = __importDefault(require("react"));
|
|
33
|
-
var colorLookup = {
|
|
34
|
-
info: { bg: utils_1.colors.lightBlue, color: utils_1.colors.accentBlueMedium },
|
|
35
|
-
warning: { bg: utils_1.colors.alertYellow, color: utils_1.colors.statusYellow },
|
|
36
|
-
success: { bg: "green.100", color: "green.600" },
|
|
37
|
-
error: { bg: utils_1.colors.alertRed, color: utils_1.colors.statusRed },
|
|
38
|
-
};
|
|
39
|
-
var iconLookup = {
|
|
40
|
-
info: react_2.default.createElement(icons_1.InformationIcon, { role: "img", "aria-label": "Informasjon" }),
|
|
41
|
-
warning: react_2.default.createElement(icons_1.BsExclamationCircle, { role: "img", "aria-label": "Advarsel" }),
|
|
42
|
-
success: react_2.default.createElement(icons_1.BsCheckCircle, { role: "img", "aria-label": "Suksess" }),
|
|
43
|
-
error: react_2.default.createElement(icons_1.BsXCircle, { role: "img", "aria-label": "Feil" }),
|
|
44
|
-
};
|
|
45
|
-
var variantStyles = {
|
|
46
|
-
inline: {
|
|
47
|
-
borderColor: "transparent",
|
|
48
|
-
backgroundColor: "transparent",
|
|
49
|
-
padding: "0",
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
function Alert(_a) {
|
|
53
|
-
var status = _a.status, children = _a.children, variant = _a.variant, rest = __rest(_a, ["status", "children", "variant"]);
|
|
54
|
-
var colors = colorLookup[status];
|
|
55
|
-
return (react_2.default.createElement(react_1.Flex, __assign({ role: "alert", flexWrap: "wrap", alignItems: "center", gridGap: "0.5rem 1rem", background: "white", border: "0.1rem solid", borderColor: colors.color, backgroundColor: colors.bg, padding: "0.75rem", borderRadius: "0.3rem" }, (variant ? variantStyles[variant] : {}), rest),
|
|
56
|
-
react_2.default.createElement(react_1.Box, { color: colors.color, flex: "0 0", marginLeft: "auto", marginRight: "auto", lineHeight: "1", fontSize: "1.5em" }, iconLookup[status]),
|
|
57
|
-
react_2.default.createElement(react_1.Box, { flex: "1" }, children)));
|
|
58
|
-
}
|
|
59
|
-
exports.Alert = Alert;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ButtonProps, ComponentWithAs } from "@chakra-ui/react";
|
|
2
|
-
import { Modify } from "@biblioteksentralen/types";
|
|
3
|
-
import { CustomButtonVariants } from "../styles/chakraTheme/ButtonStyles";
|
|
4
|
-
/**
|
|
5
|
-
* Re-exporting chackras Button with a customised types
|
|
6
|
-
* This causes both chakras native variants and our home-made variants to show up in auto-complete
|
|
7
|
-
*/
|
|
8
|
-
type ButtonVariants = ButtonProps["variant"] | CustomButtonVariants;
|
|
9
|
-
export declare const Button: ComponentWithAs<"button", Modify<ButtonProps, {
|
|
10
|
-
variant?: ButtonVariants;
|
|
11
|
-
}>>;
|
|
12
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { FunctionComponent, ReactNode } from "react";
|
|
2
|
-
type Props = {
|
|
3
|
-
children: ReactNode;
|
|
4
|
-
wrapper: FunctionComponent<{
|
|
5
|
-
children: ReactNode;
|
|
6
|
-
}>;
|
|
7
|
-
condition: boolean;
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Conditionally wrapps children with a component. If conditions are not met children mounted without the wrapper.
|
|
11
|
-
*/
|
|
12
|
-
export declare const ConditionalWrapper: FunctionComponent<Props>;
|
|
13
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
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.ConditionalWrapper = void 0;
|
|
7
|
-
var react_1 = __importDefault(require("react"));
|
|
8
|
-
/**
|
|
9
|
-
* Conditionally wrapps children with a component. If conditions are not met children mounted without the wrapper.
|
|
10
|
-
*/
|
|
11
|
-
var ConditionalWrapper = function (_a) {
|
|
12
|
-
var condition = _a.condition, children = _a.children, Wrapper = _a.wrapper;
|
|
13
|
-
return condition ? react_1.default.createElement(Wrapper, null, children) : react_1.default.createElement(react_1.default.Fragment, null, children);
|
|
14
|
-
};
|
|
15
|
-
exports.ConditionalWrapper = ConditionalWrapper;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React, { ErrorInfo, ReactNode } from "react";
|
|
2
|
-
interface Props {
|
|
3
|
-
boundaryName?: string;
|
|
4
|
-
children: ReactNode;
|
|
5
|
-
}
|
|
6
|
-
interface State {
|
|
7
|
-
hasError: boolean;
|
|
8
|
-
error?: Error;
|
|
9
|
-
errorInfo?: ErrorInfo;
|
|
10
|
-
}
|
|
11
|
-
export declare class ErrorBoundary extends React.Component<Props, State> {
|
|
12
|
-
constructor(props: any);
|
|
13
|
-
static getDerivedStateFromError(error: any): {
|
|
14
|
-
hasError: boolean;
|
|
15
|
-
};
|
|
16
|
-
componentDidCatch(error: any, errorInfo: any): void;
|
|
17
|
-
render(): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
|
|
18
|
-
}
|
|
19
|
-
export {};
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __assign = (this && this.__assign) || function () {
|
|
18
|
-
__assign = Object.assign || function(t) {
|
|
19
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
-
s = arguments[i];
|
|
21
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
-
t[p] = s[p];
|
|
23
|
-
}
|
|
24
|
-
return t;
|
|
25
|
-
};
|
|
26
|
-
return __assign.apply(this, arguments);
|
|
27
|
-
};
|
|
28
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
29
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
|
-
};
|
|
31
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.ErrorBoundary = void 0;
|
|
33
|
-
var utils_1 = require("@biblioteksentralen/utils");
|
|
34
|
-
var react_1 = require("@chakra-ui/react");
|
|
35
|
-
var react_2 = __importDefault(require("react"));
|
|
36
|
-
var Alert_1 = require("./Alert");
|
|
37
|
-
var StyledPre = function (props) { return (react_2.default.createElement(react_1.Box, __assign({ as: "pre", paddingTop: "0.5rem", wordBreak: "break-all", whiteSpace: "pre-wrap", fontSize: "0.8rem" }, props))); };
|
|
38
|
-
var ErrorBoundary = /** @class */ (function (_super) {
|
|
39
|
-
__extends(ErrorBoundary, _super);
|
|
40
|
-
function ErrorBoundary(props) {
|
|
41
|
-
var _this = _super.call(this, props) || this;
|
|
42
|
-
_this.state = { hasError: false };
|
|
43
|
-
return _this;
|
|
44
|
-
}
|
|
45
|
-
ErrorBoundary.getDerivedStateFromError = function (error) {
|
|
46
|
-
return { hasError: true };
|
|
47
|
-
};
|
|
48
|
-
ErrorBoundary.prototype.componentDidCatch = function (error, errorInfo) {
|
|
49
|
-
this.setState({ hasError: true, error: error, errorInfo: errorInfo });
|
|
50
|
-
console.error(error, { errorInfo: errorInfo, boundaryName: this.props.boundaryName });
|
|
51
|
-
};
|
|
52
|
-
ErrorBoundary.prototype.render = function () {
|
|
53
|
-
var _a, _b;
|
|
54
|
-
if (this.state.hasError) {
|
|
55
|
-
var stackTrace = (_a = this.state.errorInfo) === null || _a === void 0 ? void 0 : _a.componentStack;
|
|
56
|
-
var errormsg = (_b = this.state.error) === null || _b === void 0 ? void 0 : _b.message;
|
|
57
|
-
var info = this.props.boundaryName;
|
|
58
|
-
return (react_2.default.createElement("div", null,
|
|
59
|
-
react_2.default.createElement(Alert_1.Alert, { status: "error" },
|
|
60
|
-
react_2.default.createElement("p", null, "Beklager, det skjedde en teknisk feil."),
|
|
61
|
-
(0, utils_1.isDevelopment)() && (stackTrace || errormsg) && (react_2.default.createElement("div", null,
|
|
62
|
-
react_2.default.createElement(StyledPre, null, errormsg || ""),
|
|
63
|
-
react_2.default.createElement(StyledPre, null, info || ""),
|
|
64
|
-
react_2.default.createElement(StyledPre, null, stackTrace || ""))))));
|
|
65
|
-
}
|
|
66
|
-
return this.props.children;
|
|
67
|
-
};
|
|
68
|
-
return ErrorBoundary;
|
|
69
|
-
}(react_2.default.Component));
|
|
70
|
-
exports.ErrorBoundary = ErrorBoundary;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
interface Props {
|
|
3
|
-
id: string;
|
|
4
|
-
/**
|
|
5
|
-
* angir hvor mye luft til vil ha over HashLinkTarget ved bruk av hash-lenke, eks '4rem'
|
|
6
|
-
*/
|
|
7
|
-
spaceAbove?: string;
|
|
8
|
-
/**
|
|
9
|
-
* angir om du vil ha fokusramme rundt komponenten som mounter HashLinkTarget. Da må komponenten du wrapper med ha position: relative | absolute el
|
|
10
|
-
*/
|
|
11
|
-
focusOnParent?: boolean;
|
|
12
|
-
}
|
|
13
|
-
export declare function HashLinkTarget(props: Props): React.JSX.Element;
|
|
14
|
-
export {};
|
|
@@ -1,35 +0,0 @@
|
|
|
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.HashLinkTarget = void 0;
|
|
7
|
-
var react_1 = require("@chakra-ui/react");
|
|
8
|
-
var react_2 = __importDefault(require("react"));
|
|
9
|
-
var focusOnRelativeParentStyle = {
|
|
10
|
-
"&:focus-within": {
|
|
11
|
-
position: "static",
|
|
12
|
-
boxShadow: "none",
|
|
13
|
-
"&::after": {
|
|
14
|
-
content: '""',
|
|
15
|
-
position: "absolute",
|
|
16
|
-
top: 0,
|
|
17
|
-
left: 0,
|
|
18
|
-
height: "100%",
|
|
19
|
-
width: "100%",
|
|
20
|
-
pointerEvents: "none",
|
|
21
|
-
borderRadius: "0.25rem",
|
|
22
|
-
boxShadow: "var(--chakra-shadows-outline)",
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
/*
|
|
27
|
-
* Komponent som sørger for luft over anchors (elementer man kan lenke til med hash-lenker feks <a href="#min-overskrift">Ta meg til overskrift</a>)
|
|
28
|
-
*/
|
|
29
|
-
function HashLinkTarget(props) {
|
|
30
|
-
return (react_2.default.createElement(react_1.Box, { position: "relative", sx: props.focusOnParent ? focusOnRelativeParentStyle : undefined },
|
|
31
|
-
react_2.default.createElement(react_1.Box, { id: props.id, tabIndex: props.focusOnParent ? -1 : undefined, position: "absolute", top: "-".concat(props.spaceAbove || "2.5rem"), _focus: {
|
|
32
|
-
boxShadow: "none !important",
|
|
33
|
-
} })));
|
|
34
|
-
}
|
|
35
|
-
exports.HashLinkTarget = HashLinkTarget;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { BoxProps, ThemeTypings } from "@chakra-ui/react";
|
|
2
|
-
import { FunctionComponent, ReactNode } from "react";
|
|
3
|
-
type Props = {
|
|
4
|
-
children: ReactNode;
|
|
5
|
-
above?: ThemeTypings["breakpoints"];
|
|
6
|
-
below?: ThemeTypings["breakpoints"];
|
|
7
|
-
} & Omit<BoxProps, "display">;
|
|
8
|
-
/** Chakras <Hide /> component uses client side javascript to hide components. Causes components to flash on mobile while loading */
|
|
9
|
-
export declare const HideWithCSS: FunctionComponent<Props>;
|
|
10
|
-
export {};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
-
var t = {};
|
|
15
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
-
t[p] = s[p];
|
|
17
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
-
t[p[i]] = s[p[i]];
|
|
21
|
-
}
|
|
22
|
-
return t;
|
|
23
|
-
};
|
|
24
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
|
-
};
|
|
27
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.HideWithCSS = void 0;
|
|
29
|
-
var react_1 = require("@chakra-ui/react");
|
|
30
|
-
var react_2 = __importDefault(require("react"));
|
|
31
|
-
/** Chakras <Hide /> component uses client side javascript to hide components. Causes components to flash on mobile while loading */
|
|
32
|
-
var HideWithCSS = function (_a) {
|
|
33
|
-
var _b, _c;
|
|
34
|
-
var children = _a.children, above = _a.above, below = _a.below, chakraProps = __rest(_a, ["children", "above", "below"]);
|
|
35
|
-
var display = __assign(__assign({}, (!!below ? (_b = { base: "none" }, _b[below] = "block", _b) : {})), (!!above ? (_c = {}, _c[above] = "none", _c) : {}));
|
|
36
|
-
return (react_2.default.createElement(react_1.Box, __assign({}, chakraProps, { display: display }), children));
|
|
37
|
-
};
|
|
38
|
-
exports.HideWithCSS = HideWithCSS;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { FormLabelProps, InputProps } from "@chakra-ui/react";
|
|
2
|
-
import React from "react";
|
|
3
|
-
interface Props extends InputProps {
|
|
4
|
-
label: string;
|
|
5
|
-
hideLabel?: boolean;
|
|
6
|
-
labelProps?: FormLabelProps;
|
|
7
|
-
helperText?: string;
|
|
8
|
-
errorMessage?: string;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Creating custom input-component to make sure label is always set (for accessibility)
|
|
12
|
-
* Also handles some common needs (helper text and error message. For more advanced input-components we leave it to the consumers to compose custom input-components based on Chakra
|
|
13
|
-
*/
|
|
14
|
-
export declare const Input: React.ForwardRefExoticComponent<Props & React.RefAttributes<unknown>>;
|
|
15
|
-
export {};
|
package/dist/components/Input.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
-
}
|
|
19
|
-
Object.defineProperty(o, k2, desc);
|
|
20
|
-
}) : (function(o, m, k, k2) {
|
|
21
|
-
if (k2 === undefined) k2 = k;
|
|
22
|
-
o[k2] = m[k];
|
|
23
|
-
}));
|
|
24
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
-
}) : function(o, v) {
|
|
27
|
-
o["default"] = v;
|
|
28
|
-
});
|
|
29
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
-
if (mod && mod.__esModule) return mod;
|
|
31
|
-
var result = {};
|
|
32
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
-
__setModuleDefault(result, mod);
|
|
34
|
-
return result;
|
|
35
|
-
};
|
|
36
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
37
|
-
var t = {};
|
|
38
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
39
|
-
t[p] = s[p];
|
|
40
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
41
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
42
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
43
|
-
t[p[i]] = s[p[i]];
|
|
44
|
-
}
|
|
45
|
-
return t;
|
|
46
|
-
};
|
|
47
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
-
exports.Input = void 0;
|
|
49
|
-
var react_1 = require("@chakra-ui/react");
|
|
50
|
-
var react_2 = __importStar(require("react"));
|
|
51
|
-
var VisuallyHidden_1 = require("./VisuallyHidden");
|
|
52
|
-
/**
|
|
53
|
-
* Creating custom input-component to make sure label is always set (for accessibility)
|
|
54
|
-
* Also handles some common needs (helper text and error message. For more advanced input-components we leave it to the consumers to compose custom input-components based on Chakra
|
|
55
|
-
*/
|
|
56
|
-
exports.Input = (0, react_2.forwardRef)(function (props, ref) {
|
|
57
|
-
var labelProps = props.labelProps, label = props.label, helperText = props.helperText, errorMessage = props.errorMessage, hideLabel = props.hideLabel, inputProps = __rest(props, ["labelProps", "label", "helperText", "errorMessage", "hideLabel"]);
|
|
58
|
-
return (react_2.default.createElement(react_1.FormControl, { isInvalid: !!errorMessage },
|
|
59
|
-
react_2.default.createElement(react_1.FormLabel, __assign({ marginBottom: ".25em" }, labelProps), hideLabel ? react_2.default.createElement(VisuallyHidden_1.VisuallyHidden, null, label) : label),
|
|
60
|
-
react_2.default.createElement(react_1.Input, __assign({ ref: ref }, inputProps)),
|
|
61
|
-
errorMessage && react_2.default.createElement(react_1.FormErrorMessage, null, errorMessage),
|
|
62
|
-
helperText && react_2.default.createElement(react_1.FormHelperText, null, helperText)));
|
|
63
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Modify } from "@biblioteksentralen/types";
|
|
2
|
-
import { ComponentWithAs, LinkProps } from "@chakra-ui/react";
|
|
3
|
-
import { CustomLinkVariants } from "../styles/chakraTheme/LinkStyles";
|
|
4
|
-
/**
|
|
5
|
-
* Re-exporting chackras Link with a customised types
|
|
6
|
-
* This causes both chakras native variants and our home-made variants to show up in auto-complete
|
|
7
|
-
*/
|
|
8
|
-
type LinkVariants = LinkProps["variant"] | CustomLinkVariants;
|
|
9
|
-
export declare const Link: ComponentWithAs<"a", Modify<LinkProps, {
|
|
10
|
-
variant?: LinkVariants;
|
|
11
|
-
}>>;
|
|
12
|
-
export {};
|
package/dist/components/Link.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
exports.VisuallyHidden = void 0;
|
|
38
|
-
var react_1 = __importStar(require("react"));
|
|
39
|
-
var react_2 = require("@chakra-ui/react");
|
|
40
|
-
var utils_1 = require("@biblioteksentralen/utils");
|
|
41
|
-
// https://www.joshwcomeau.com/snippets/react-components/visually-hidden/
|
|
42
|
-
function VisuallyHidden(_a) {
|
|
43
|
-
var children = _a.children, rest = __rest(_a, ["children"]);
|
|
44
|
-
var _b = react_1.default.useState(false), forceShow = _b[0], setForceShow = _b[1];
|
|
45
|
-
(0, react_1.useEffect)(function () {
|
|
46
|
-
if ((0, utils_1.isDevelopment)()) {
|
|
47
|
-
var handleKeyDown_1 = function (ev) {
|
|
48
|
-
if (ev.key === "Alt") {
|
|
49
|
-
setForceShow(true);
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
var handleKeyUp_1 = function (ev) {
|
|
53
|
-
if (ev.key === "Alt") {
|
|
54
|
-
setForceShow(false);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
window.addEventListener("keydown", handleKeyDown_1);
|
|
58
|
-
window.addEventListener("keyup", handleKeyUp_1);
|
|
59
|
-
return function () {
|
|
60
|
-
window.removeEventListener("keydown", handleKeyDown_1);
|
|
61
|
-
window.removeEventListener("keyup", handleKeyUp_1);
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
}, []);
|
|
65
|
-
// position="fixed" løser bug der visually hidden ikke hindret tekst fra å ta plass i bredden
|
|
66
|
-
return forceShow ? react_1.default.createElement("span", null, children) : react_1.default.createElement(react_2.VisuallyHidden, { position: "fixed" }, children);
|
|
67
|
-
}
|
|
68
|
-
exports.VisuallyHidden = VisuallyHidden;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.withErrorBoundary = void 0;
|
|
18
|
-
var react_1 = __importDefault(require("react"));
|
|
19
|
-
var ErrorBoundary_1 = require("./ErrorBoundary");
|
|
20
|
-
var withErrorBoundary = function (Component, boundaryName) {
|
|
21
|
-
return react_1.default.forwardRef(function (props, ref) { return (react_1.default.createElement(ErrorBoundary_1.ErrorBoundary, { boundaryName: boundaryName },
|
|
22
|
-
react_1.default.createElement(Component, __assign({}, props, { ref: ref })))); });
|
|
23
|
-
};
|
|
24
|
-
exports.withErrorBoundary = withErrorBoundary;
|