@biblioteksentralen/react 1.0.0-beta.5 → 1.0.0-beta.6
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.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/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# React library for reusable code in Biblioteksentralens js-apps
|
|
2
|
+
|
|
3
|
+
Simple React utility library for usage in Biblioteksentralen. Feel free to use, but functionality might not work as expected outside Biblioteksentralen context.
|
|
4
|
+
|
|
5
|
+
Written in typescript.
|
|
6
|
+
|
|
7
|
+
React components are written for usage in Nextjs, and might rely upon nextjs to work properly.
|
|
8
|
+
|
|
9
|
+
## Storybook
|
|
10
|
+
|
|
11
|
+
We have a storybook you can visit to see our components here: [https://biblioteksentralen.github.io/js-utils](https://biblioteksentralen.github.io/js-utils)
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,118 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { FlexProps, AlertProps, ComponentWithAs, ButtonProps, ThemeTypings, BoxProps, InputProps, FormLabelProps, LinkProps, ChakraTheme } from '@chakra-ui/react';
|
|
2
|
+
export * from '@chakra-ui/react';
|
|
3
|
+
import React, { ReactNode, FunctionComponent, HTMLAttributes, ErrorInfo } from 'react';
|
|
4
|
+
import { Modify } from '@biblioteksentralen/types';
|
|
5
|
+
export { colors } from '@biblioteksentralen/utils';
|
|
6
|
+
import { ChakraTheme as ChakraTheme$1 } from '@chakra-ui/theme';
|
|
7
|
+
|
|
8
|
+
type Status = Exclude<AlertProps["status"], undefined | "loading">;
|
|
9
|
+
type Variants = "inline";
|
|
10
|
+
interface Props$7 extends FlexProps {
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
status: Status;
|
|
13
|
+
variant?: Variants;
|
|
14
|
+
}
|
|
15
|
+
declare function Alert({ status, children, variant, ...rest }: Props$7): React.JSX.Element;
|
|
16
|
+
|
|
17
|
+
type CustomButtonVariants = "primary" | "secondary" | "tertiary";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Re-exporting chackras Button with a customised types
|
|
21
|
+
* This causes both chakras native variants and our home-made variants to show up in auto-complete
|
|
22
|
+
*/
|
|
23
|
+
type ButtonVariants = ButtonProps["variant"] | CustomButtonVariants;
|
|
24
|
+
declare const Button: ComponentWithAs<"button", Modify<ButtonProps, {
|
|
25
|
+
variant?: ButtonVariants;
|
|
26
|
+
}>>;
|
|
27
|
+
|
|
28
|
+
type Props$6 = {
|
|
29
|
+
children: ReactNode;
|
|
30
|
+
wrapper: FunctionComponent<{
|
|
31
|
+
children: ReactNode;
|
|
32
|
+
}>;
|
|
33
|
+
condition: boolean;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Conditionally wrapps children with a component. If conditions are not met children mounted without the wrapper.
|
|
37
|
+
*/
|
|
38
|
+
declare const ConditionalWrapper: FunctionComponent<Props$6>;
|
|
39
|
+
|
|
40
|
+
type Props$5 = {
|
|
41
|
+
children: ReactNode;
|
|
42
|
+
above?: ThemeTypings["breakpoints"];
|
|
43
|
+
below?: ThemeTypings["breakpoints"];
|
|
44
|
+
} & Omit<BoxProps, "display">;
|
|
45
|
+
/** Chakras <Hide /> component uses client side javascript to hide components. Causes components to flash on mobile while loading */
|
|
46
|
+
declare const HideWithCSS: FunctionComponent<Props$5>;
|
|
47
|
+
|
|
48
|
+
interface Props$4 extends InputProps {
|
|
49
|
+
label: string;
|
|
50
|
+
hideLabel?: boolean;
|
|
51
|
+
labelProps?: FormLabelProps;
|
|
52
|
+
helperText?: string;
|
|
53
|
+
errorMessage?: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Creating custom input-component to make sure label is always set (for accessibility)
|
|
57
|
+
* 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
|
|
58
|
+
*/
|
|
59
|
+
declare const Input: React.ForwardRefExoticComponent<Props$4 & React.RefAttributes<unknown>>;
|
|
60
|
+
|
|
61
|
+
type CustomLinkVariants = "plain";
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Re-exporting chackras Link with a customised types
|
|
65
|
+
* This causes both chakras native variants and our home-made variants to show up in auto-complete
|
|
66
|
+
*/
|
|
67
|
+
type LinkVariants = LinkProps["variant"] | CustomLinkVariants;
|
|
68
|
+
declare const Link: ComponentWithAs<"a", Modify<LinkProps, {
|
|
69
|
+
variant?: LinkVariants;
|
|
70
|
+
}>>;
|
|
71
|
+
|
|
72
|
+
interface Props$3 extends HTMLAttributes<HTMLSpanElement> {
|
|
73
|
+
children: ReactNode;
|
|
74
|
+
}
|
|
75
|
+
declare function VisuallyHidden({ children, ...rest }: Props$3): React.JSX.Element;
|
|
76
|
+
|
|
77
|
+
interface Props$2 {
|
|
78
|
+
children: ReactNode;
|
|
79
|
+
customTheme?: Partial<ChakraTheme>;
|
|
80
|
+
}
|
|
81
|
+
declare const BiblioteksentralenProvider: (props: Props$2) => React.JSX.Element;
|
|
82
|
+
|
|
83
|
+
interface Props$1 {
|
|
84
|
+
boundaryName?: string;
|
|
85
|
+
children: ReactNode;
|
|
86
|
+
}
|
|
87
|
+
interface State {
|
|
88
|
+
hasError: boolean;
|
|
89
|
+
error?: Error;
|
|
90
|
+
errorInfo?: ErrorInfo;
|
|
91
|
+
}
|
|
92
|
+
declare class ErrorBoundary extends React.Component<Props$1, State> {
|
|
93
|
+
constructor(props: any);
|
|
94
|
+
static getDerivedStateFromError(error: any): {
|
|
95
|
+
hasError: boolean;
|
|
96
|
+
};
|
|
97
|
+
componentDidCatch(error: any, errorInfo: any): void;
|
|
98
|
+
render(): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
interface Props {
|
|
102
|
+
id: string;
|
|
103
|
+
/**
|
|
104
|
+
* angir hvor mye luft til vil ha over HashLinkTarget ved bruk av hash-lenke, eks '4rem'
|
|
105
|
+
*/
|
|
106
|
+
spaceAbove?: string;
|
|
107
|
+
/**
|
|
108
|
+
* angir om du vil ha fokusramme rundt komponenten som mounter HashLinkTarget. Da må komponenten du wrapper med ha position: relative | absolute el
|
|
109
|
+
*/
|
|
110
|
+
focusOnParent?: boolean;
|
|
111
|
+
}
|
|
112
|
+
declare function HashLinkTarget(props: Props): React.JSX.Element;
|
|
113
|
+
|
|
114
|
+
declare const withErrorBoundary: <Props>(Component: React.ComponentType<Props>, boundaryName: string) => React.ForwardRefExoticComponent<React.PropsWithoutRef<Props> & React.RefAttributes<unknown>>;
|
|
115
|
+
|
|
116
|
+
declare const biblioteksentralenChakraTheme: Partial<ChakraTheme$1>;
|
|
117
|
+
|
|
118
|
+
export { Alert, BiblioteksentralenProvider, Button, ConditionalWrapper, ErrorBoundary, HashLinkTarget, HideWithCSS, Input, Link, VisuallyHidden, biblioteksentralenChakraTheme, withErrorBoundary };
|