@biblioteksentralen/react 1.0.0-beta.6 → 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/dist/index.mjs +558 -0
- package/package.json +5 -5
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,558 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
export * from "@chakra-ui/react";
|
|
3
|
+
|
|
4
|
+
// ../icons/dist/index.mjs
|
|
5
|
+
import React from "react";
|
|
6
|
+
import React2 from "react";
|
|
7
|
+
import React3 from "react";
|
|
8
|
+
import React4 from "react";
|
|
9
|
+
import React5 from "react";
|
|
10
|
+
import React6 from "react";
|
|
11
|
+
import React7 from "react";
|
|
12
|
+
import React8 from "react";
|
|
13
|
+
import * as React9 from "react";
|
|
14
|
+
import * as React10 from "react";
|
|
15
|
+
import * as React11 from "react";
|
|
16
|
+
import * as React12 from "react";
|
|
17
|
+
import React13 from "react";
|
|
18
|
+
import React14 from "react";
|
|
19
|
+
import React15 from "react";
|
|
20
|
+
import React16 from "react";
|
|
21
|
+
import React17 from "react";
|
|
22
|
+
import React18 from "react";
|
|
23
|
+
import React19 from "react";
|
|
24
|
+
import React20 from "react";
|
|
25
|
+
import React21 from "react";
|
|
26
|
+
import React22 from "react";
|
|
27
|
+
import React23 from "react";
|
|
28
|
+
import React24 from "react";
|
|
29
|
+
import React25 from "react";
|
|
30
|
+
import React26 from "react";
|
|
31
|
+
import React27 from "react";
|
|
32
|
+
import React28 from "react";
|
|
33
|
+
import React29 from "react";
|
|
34
|
+
import React30 from "react";
|
|
35
|
+
import React31 from "react";
|
|
36
|
+
import React32 from "react";
|
|
37
|
+
import * as React33 from "react";
|
|
38
|
+
import React34 from "react";
|
|
39
|
+
import React35 from "react";
|
|
40
|
+
import React36 from "react";
|
|
41
|
+
import React37 from "react";
|
|
42
|
+
import React38 from "react";
|
|
43
|
+
import React39 from "react";
|
|
44
|
+
import React40 from "react";
|
|
45
|
+
import React41 from "react";
|
|
46
|
+
import React42 from "react";
|
|
47
|
+
import * as React43 from "react";
|
|
48
|
+
import React44 from "react";
|
|
49
|
+
import React45 from "react";
|
|
50
|
+
import React46 from "react";
|
|
51
|
+
import React47 from "react";
|
|
52
|
+
import React48 from "react";
|
|
53
|
+
import React49 from "react";
|
|
54
|
+
import React50 from "react";
|
|
55
|
+
import React51 from "react";
|
|
56
|
+
import React52 from "react";
|
|
57
|
+
import React53 from "react";
|
|
58
|
+
import React54 from "react";
|
|
59
|
+
import React55 from "react";
|
|
60
|
+
import React56 from "react";
|
|
61
|
+
import React57 from "react";
|
|
62
|
+
import React58 from "react";
|
|
63
|
+
import React59 from "react";
|
|
64
|
+
import React60 from "react";
|
|
65
|
+
import React61 from "react";
|
|
66
|
+
import React62 from "react";
|
|
67
|
+
import React63 from "react";
|
|
68
|
+
import React64 from "react";
|
|
69
|
+
import React65 from "react";
|
|
70
|
+
import React66 from "react";
|
|
71
|
+
import React67 from "react";
|
|
72
|
+
import React68 from "react";
|
|
73
|
+
import * as React69 from "react";
|
|
74
|
+
import React70 from "react";
|
|
75
|
+
import React71 from "react";
|
|
76
|
+
import React72 from "react";
|
|
77
|
+
import React73 from "react";
|
|
78
|
+
import React74 from "react";
|
|
79
|
+
import React75 from "react";
|
|
80
|
+
import React76 from "react";
|
|
81
|
+
import React77 from "react";
|
|
82
|
+
import React78 from "react";
|
|
83
|
+
import React79 from "react";
|
|
84
|
+
import * as React80 from "react";
|
|
85
|
+
import React81 from "react";
|
|
86
|
+
import React82 from "react";
|
|
87
|
+
import React83 from "react";
|
|
88
|
+
import React84 from "react";
|
|
89
|
+
import React85 from "react";
|
|
90
|
+
import React86 from "react";
|
|
91
|
+
import React87 from "react";
|
|
92
|
+
import React88 from "react";
|
|
93
|
+
import React89 from "react";
|
|
94
|
+
import React90 from "react";
|
|
95
|
+
import React91 from "react";
|
|
96
|
+
import React92 from "react";
|
|
97
|
+
import React93 from "react";
|
|
98
|
+
var BsCheckCircle = (props) => /* @__PURE__ */ React16.createElement("svg", { fill: "currentColor", viewBox: "0 0 16 16", height: "1em", width: "1em", ...props }, /* @__PURE__ */ React16.createElement("path", { d: "M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z" }), /* @__PURE__ */ React16.createElement("path", { d: "M10.97 4.97a.235.235 0 0 0-.02.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-1.071-1.05z" }));
|
|
99
|
+
var BsExclamationCircle = (props) => /* @__PURE__ */ React21.createElement("svg", { fill: "currentColor", viewBox: "0 0 16 16", height: "1em", width: "1em", ...props }, /* @__PURE__ */ React21.createElement("path", { d: "M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z" }), /* @__PURE__ */ React21.createElement("path", { d: "M7.002 11a1 1 0 1 1 2 0 1 1 0 0 1-2 0zM7.1 4.995a.905.905 0 1 1 1.8 0l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 4.995z" }));
|
|
100
|
+
var BsXCircle = (props) => /* @__PURE__ */ React31.createElement("svg", { fill: "currentColor", viewBox: "0 0 16 16", height: "1em", width: "1em", ...props }, /* @__PURE__ */ React31.createElement("path", { d: "M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z" }), /* @__PURE__ */ React31.createElement("path", { d: "M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z" }));
|
|
101
|
+
var InformationIcon = (props) => /* @__PURE__ */ React69.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", ...props, viewBox: "2 2 20 20" }, /* @__PURE__ */ React69.createElement(
|
|
102
|
+
"path",
|
|
103
|
+
{
|
|
104
|
+
d: "M12 2.25c5.385 0 9.75 4.365 9.75 9.75s-4.365 9.75-9.75 9.75c-5.384 0-9.75-4.365-9.75-9.75S6.616 2.25 12 2.25zm0 1.5a8.25 8.25 0 1 0 0 16.5 8.25 8.25 0 0 0 0-16.5zm0 6.5a.75.75 0 0 1 .75.75v4.971l-.007.102a.75.75 0 0 1-1.493-.102V11l.007-.102A.75.75 0 0 1 12 10.25zm0-2.75A.75.75 0 1 1 12 9a.75.75 0 0 1 0-1.5z",
|
|
105
|
+
fill: "currentColor"
|
|
106
|
+
}
|
|
107
|
+
));
|
|
108
|
+
|
|
109
|
+
// ../utils/dist/index.mjs
|
|
110
|
+
import { format } from "date-fns";
|
|
111
|
+
import { nb } from "date-fns/locale";
|
|
112
|
+
var colors = {
|
|
113
|
+
black: "#000000",
|
|
114
|
+
grey90: "#181818",
|
|
115
|
+
grey80: "#333333",
|
|
116
|
+
grey60: "#585858",
|
|
117
|
+
grey45: "#8c8c8c",
|
|
118
|
+
grey30: "#b2b2b2",
|
|
119
|
+
grey15: "#d9d9d9",
|
|
120
|
+
grey10: "#e5e5e5",
|
|
121
|
+
grey05: "#f2f2f2",
|
|
122
|
+
white: "#ffffff",
|
|
123
|
+
bsR\u00F8dDark: "#870010",
|
|
124
|
+
bsR\u00F8dMedium: "#d53d40",
|
|
125
|
+
accentPurple: "#331433",
|
|
126
|
+
accentPeach: "#ffba99",
|
|
127
|
+
accentGreen: "#003b29",
|
|
128
|
+
accentBlueDark: "#001740",
|
|
129
|
+
accentBlueMedium: "#5996de",
|
|
130
|
+
accentYellow: "#ffc970",
|
|
131
|
+
lightBlue: "#dbe8ef",
|
|
132
|
+
lightGreen: "#dbe0db",
|
|
133
|
+
lightPeach: "#f4e7de",
|
|
134
|
+
lightPurple: "#ece8f3",
|
|
135
|
+
statusRed: "#ad313c",
|
|
136
|
+
statusYellow: "#bc5600",
|
|
137
|
+
statusGreen: "#24845b",
|
|
138
|
+
statusGreenLight: "#edf4f1",
|
|
139
|
+
alertRed: "#f8efef",
|
|
140
|
+
alertYellow: "#fff6e4",
|
|
141
|
+
neptune: {
|
|
142
|
+
"100": "#CFE6E8",
|
|
143
|
+
"200": "#9FCDD2",
|
|
144
|
+
"300": "#6FB5BB",
|
|
145
|
+
"400": "#3F9CA5",
|
|
146
|
+
"500": "#0F838E",
|
|
147
|
+
"600": "#0C6972",
|
|
148
|
+
"700": "#094F55",
|
|
149
|
+
"800": "#063439",
|
|
150
|
+
"900": "#031A1C"
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
function isDevelopment() {
|
|
154
|
+
return process.env.NODE_ENV === "development";
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// src/components/Alert.tsx
|
|
158
|
+
import { Box, Flex } from "@chakra-ui/react";
|
|
159
|
+
import React94 from "react";
|
|
160
|
+
var colorLookup = {
|
|
161
|
+
info: { bg: colors.lightBlue, color: colors.accentBlueMedium },
|
|
162
|
+
warning: { bg: colors.alertYellow, color: colors.statusYellow },
|
|
163
|
+
success: { bg: "green.100", color: "green.600" },
|
|
164
|
+
error: { bg: colors.alertRed, color: colors.statusRed }
|
|
165
|
+
};
|
|
166
|
+
var iconLookup = {
|
|
167
|
+
info: /* @__PURE__ */ React94.createElement(InformationIcon, { role: "img", "aria-label": "Informasjon" }),
|
|
168
|
+
warning: /* @__PURE__ */ React94.createElement(BsExclamationCircle, { role: "img", "aria-label": "Advarsel" }),
|
|
169
|
+
success: /* @__PURE__ */ React94.createElement(BsCheckCircle, { role: "img", "aria-label": "Suksess" }),
|
|
170
|
+
error: /* @__PURE__ */ React94.createElement(BsXCircle, { role: "img", "aria-label": "Feil" })
|
|
171
|
+
};
|
|
172
|
+
var variantStyles = {
|
|
173
|
+
inline: {
|
|
174
|
+
borderColor: "transparent",
|
|
175
|
+
backgroundColor: "transparent",
|
|
176
|
+
padding: "0"
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
function Alert({ status, children, variant, ...rest }) {
|
|
180
|
+
const colors2 = colorLookup[status];
|
|
181
|
+
return /* @__PURE__ */ React94.createElement(
|
|
182
|
+
Flex,
|
|
183
|
+
{
|
|
184
|
+
role: "alert",
|
|
185
|
+
flexWrap: "wrap",
|
|
186
|
+
alignItems: "center",
|
|
187
|
+
gridGap: "0.5rem 1rem",
|
|
188
|
+
background: "white",
|
|
189
|
+
border: `0.1rem solid`,
|
|
190
|
+
borderColor: colors2.color,
|
|
191
|
+
backgroundColor: colors2.bg,
|
|
192
|
+
padding: "0.75rem",
|
|
193
|
+
borderRadius: "0.3rem",
|
|
194
|
+
...variant ? variantStyles[variant] : {},
|
|
195
|
+
...rest
|
|
196
|
+
},
|
|
197
|
+
/* @__PURE__ */ React94.createElement(Box, { color: colors2.color, flex: "0 0", marginLeft: "auto", marginRight: "auto", lineHeight: "1", fontSize: "1.5em" }, iconLookup[status]),
|
|
198
|
+
/* @__PURE__ */ React94.createElement(Box, { flex: "1" }, children)
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// src/components/Button.tsx
|
|
203
|
+
import { Button as ChakraButton } from "@chakra-ui/react";
|
|
204
|
+
var Button = ChakraButton;
|
|
205
|
+
|
|
206
|
+
// src/components/ConditionalWrapper.tsx
|
|
207
|
+
import React95 from "react";
|
|
208
|
+
var ConditionalWrapper = ({ condition, children, wrapper: Wrapper }) => condition ? /* @__PURE__ */ React95.createElement(Wrapper, null, children) : /* @__PURE__ */ React95.createElement(React95.Fragment, null, children);
|
|
209
|
+
|
|
210
|
+
// src/components/HideWithCSS.tsx
|
|
211
|
+
import { Box as Box2 } from "@chakra-ui/react";
|
|
212
|
+
import React96 from "react";
|
|
213
|
+
var HideWithCSS = ({ children, above, below, ...chakraProps }) => {
|
|
214
|
+
const display = {
|
|
215
|
+
...!!below ? { base: "none", [below]: "block" } : {},
|
|
216
|
+
...!!above ? { [above]: "none" } : {}
|
|
217
|
+
};
|
|
218
|
+
return /* @__PURE__ */ React96.createElement(Box2, { ...chakraProps, display }, children);
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
// src/components/Input.tsx
|
|
222
|
+
import {
|
|
223
|
+
FormControl,
|
|
224
|
+
FormErrorMessage,
|
|
225
|
+
FormHelperText,
|
|
226
|
+
FormLabel,
|
|
227
|
+
Input as ChakraInput
|
|
228
|
+
} from "@chakra-ui/react";
|
|
229
|
+
import React98, { forwardRef } from "react";
|
|
230
|
+
|
|
231
|
+
// src/components/VisuallyHidden.tsx
|
|
232
|
+
import React97, { useEffect } from "react";
|
|
233
|
+
import { VisuallyHidden as ChakraVisuallyHidden } from "@chakra-ui/react";
|
|
234
|
+
function VisuallyHidden({ children, ...rest }) {
|
|
235
|
+
const [forceShow, setForceShow] = React97.useState(false);
|
|
236
|
+
useEffect(() => {
|
|
237
|
+
if (isDevelopment()) {
|
|
238
|
+
const handleKeyDown = (ev) => {
|
|
239
|
+
if (ev.key === "Alt") {
|
|
240
|
+
setForceShow(true);
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
const handleKeyUp = (ev) => {
|
|
244
|
+
if (ev.key === "Alt") {
|
|
245
|
+
setForceShow(false);
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
249
|
+
window.addEventListener("keyup", handleKeyUp);
|
|
250
|
+
return () => {
|
|
251
|
+
window.removeEventListener("keydown", handleKeyDown);
|
|
252
|
+
window.removeEventListener("keyup", handleKeyUp);
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
}, []);
|
|
256
|
+
return forceShow ? /* @__PURE__ */ React97.createElement("span", null, children) : /* @__PURE__ */ React97.createElement(ChakraVisuallyHidden, { position: "fixed" }, children);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// src/components/Input.tsx
|
|
260
|
+
var Input = forwardRef((props, ref) => {
|
|
261
|
+
const { labelProps, label, helperText, errorMessage, hideLabel, ...inputProps } = props;
|
|
262
|
+
return /* @__PURE__ */ React98.createElement(FormControl, { isInvalid: !!errorMessage }, /* @__PURE__ */ React98.createElement(FormLabel, { marginBottom: ".25em", ...labelProps }, hideLabel ? /* @__PURE__ */ React98.createElement(VisuallyHidden, null, label) : label), /* @__PURE__ */ React98.createElement(ChakraInput, { ref, ...inputProps }), errorMessage && /* @__PURE__ */ React98.createElement(FormErrorMessage, null, errorMessage), helperText && /* @__PURE__ */ React98.createElement(FormHelperText, null, helperText));
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
// src/components/Link.tsx
|
|
266
|
+
import { Link as ChakraLink } from "@chakra-ui/react";
|
|
267
|
+
var Link = ChakraLink;
|
|
268
|
+
|
|
269
|
+
// src/BiblioteksentralenProvider.tsx
|
|
270
|
+
import { ChakraProvider, extendTheme } from "@chakra-ui/react";
|
|
271
|
+
import React99 from "react";
|
|
272
|
+
|
|
273
|
+
// src/styles/chakraTheme/ButtonStyles.ts
|
|
274
|
+
var variants = {
|
|
275
|
+
primary: {
|
|
276
|
+
backgroundColor: colors.black,
|
|
277
|
+
color: "white",
|
|
278
|
+
_hover: {
|
|
279
|
+
backgroundColor: "hsla(0deg, 0%, 70%, 1)",
|
|
280
|
+
color: "black"
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
secondary: {
|
|
284
|
+
borderColor: "currentColor",
|
|
285
|
+
backgroundColor: "transparent",
|
|
286
|
+
color: "currentColor",
|
|
287
|
+
_hover: {
|
|
288
|
+
backgroundColor: "hsla(0deg, 0%, 50%, 0.15)"
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
tertiary: {
|
|
292
|
+
backgroundColor: "transparent",
|
|
293
|
+
color: "currentColor",
|
|
294
|
+
_hover: {
|
|
295
|
+
backgroundColor: "hsla(0deg, 0%, 50%, 0.15)",
|
|
296
|
+
color: "currentColor"
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
var ButtonStyles = {
|
|
301
|
+
baseStyle: {
|
|
302
|
+
border: "transparent 0.1em solid",
|
|
303
|
+
borderRadius: "0.35em",
|
|
304
|
+
fontWeight: 600,
|
|
305
|
+
_disabled: {
|
|
306
|
+
backgroundColor: `${colors.grey45} !important`,
|
|
307
|
+
color: "white !important",
|
|
308
|
+
opacity: 1
|
|
309
|
+
}
|
|
310
|
+
},
|
|
311
|
+
sizes: {
|
|
312
|
+
sm: {
|
|
313
|
+
padding: "0.2em 0.5em",
|
|
314
|
+
fontSize: "1rem"
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
variants,
|
|
318
|
+
defaultProps: {
|
|
319
|
+
variant: "primary"
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
// src/styles/chakraTheme/CheckboxStyles.ts
|
|
324
|
+
import { createMultiStyleConfigHelpers } from "@chakra-ui/react";
|
|
325
|
+
import { checkboxAnatomy } from "@chakra-ui/anatomy";
|
|
326
|
+
var { definePartsStyle, defineMultiStyleConfig: defineMultiStyleConfigWithTypeIssue } = createMultiStyleConfigHelpers(
|
|
327
|
+
checkboxAnatomy.keys
|
|
328
|
+
);
|
|
329
|
+
var defineMultiStyleConfig = defineMultiStyleConfigWithTypeIssue;
|
|
330
|
+
var baseStyle = definePartsStyle({
|
|
331
|
+
control: {
|
|
332
|
+
background: "white"
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
var CheckboxStyles = defineMultiStyleConfig({ baseStyle });
|
|
336
|
+
|
|
337
|
+
// src/styles/chakraTheme/ContainerStyles.ts
|
|
338
|
+
var ContainerStyles = {
|
|
339
|
+
baseStyle: {
|
|
340
|
+
px: ".75rem"
|
|
341
|
+
// Padding left/right
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
// src/styles/chakraTheme/HeadingStyles.ts
|
|
346
|
+
var HeadingStyles = {
|
|
347
|
+
baseStyle: {
|
|
348
|
+
fontWeight: "600"
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
// src/styles/chakraTheme/InputStyles.ts
|
|
353
|
+
import { mode } from "@chakra-ui/theme-tools";
|
|
354
|
+
var InputStyles = {
|
|
355
|
+
baseStyle: (props) => ({
|
|
356
|
+
field: {
|
|
357
|
+
_placeholder: {
|
|
358
|
+
color: mode("gray.500", "whiteAlpha.500")(props)
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}),
|
|
362
|
+
variants: {
|
|
363
|
+
filled: (props) => ({
|
|
364
|
+
field: {
|
|
365
|
+
bg: mode("gray.200", "whiteAlpha.100")(props),
|
|
366
|
+
_hover: {
|
|
367
|
+
bg: mode("gray.300", "whiteAlpha.200")(props)
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}),
|
|
371
|
+
outline: (props) => ({
|
|
372
|
+
field: {
|
|
373
|
+
borderColor: mode("gray.300", "whiteAlpha.300")(props),
|
|
374
|
+
_hover: {
|
|
375
|
+
borderColor: mode("gray.400", "whiteAlpha.400")(props)
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}),
|
|
379
|
+
flushed: (props) => ({
|
|
380
|
+
field: {
|
|
381
|
+
borderColor: mode("gray.300", "whiteAlpha.300")(props),
|
|
382
|
+
_hover: {
|
|
383
|
+
borderColor: mode("gray.400", "whiteAlpha.400")(props)
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
})
|
|
387
|
+
},
|
|
388
|
+
defaultProps: {
|
|
389
|
+
variant: "filled"
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
// src/styles/chakraTheme/LinkStyles.ts
|
|
394
|
+
var variants2 = {
|
|
395
|
+
plain: {
|
|
396
|
+
textDecoration: "none",
|
|
397
|
+
_hover: {
|
|
398
|
+
textDecoration: "underline"
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
var LinkStyles = {
|
|
403
|
+
baseStyle: {
|
|
404
|
+
textDecoration: "underline",
|
|
405
|
+
_hover: {
|
|
406
|
+
textDecoration: "none"
|
|
407
|
+
}
|
|
408
|
+
},
|
|
409
|
+
variants: variants2
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
// src/styles/chakraTheme/ModalStyles.ts
|
|
413
|
+
var ModalStyles = {
|
|
414
|
+
baseStyle: {
|
|
415
|
+
// Fix for modal height on Safari iOS:
|
|
416
|
+
// https://github.com/chakra-ui/chakra-ui/issues/4680#issuecomment-1301640929
|
|
417
|
+
dialogContainer: {
|
|
418
|
+
"@supports(height: -webkit-fill-available)": {},
|
|
419
|
+
height: "100%"
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
// src/styles/chakraTheme/SpinnerStyles.ts
|
|
425
|
+
import { Spinner } from "@chakra-ui/react";
|
|
426
|
+
var SpinnerStyles = {};
|
|
427
|
+
Spinner.defaultProps = {
|
|
428
|
+
...Spinner.defaultProps,
|
|
429
|
+
speed: ".8s",
|
|
430
|
+
color: colors.accentBlueMedium,
|
|
431
|
+
emptyColor: "rgba(0,0,0,.2)",
|
|
432
|
+
thickness: ".175em"
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
// src/styles/chakraTheme/sizes.ts
|
|
436
|
+
var container = {
|
|
437
|
+
sm: "40rem",
|
|
438
|
+
md: "48rem",
|
|
439
|
+
lg: "56rem",
|
|
440
|
+
// Forsøker 56rem som standardbredde etter testing med Katrine
|
|
441
|
+
xl: "80rem"
|
|
442
|
+
};
|
|
443
|
+
var sizes = {
|
|
444
|
+
container
|
|
445
|
+
};
|
|
446
|
+
|
|
447
|
+
// src/styles/chakraTheme/biblioteksentralenChakraTheme.ts
|
|
448
|
+
var biblioteksentralenChakraTheme = {
|
|
449
|
+
styles: {
|
|
450
|
+
global: {
|
|
451
|
+
html: {
|
|
452
|
+
fontSize: { base: "112.5%", md: "120%" },
|
|
453
|
+
// Sørger for smooth scrolling for interne lenker som scroller til annet sted på siden,
|
|
454
|
+
// men ikke hvis fokus er utenfor viduet, feks ved søk i tekst (ctrl + f)
|
|
455
|
+
"&:focus-within": { scrollBehavior: "smooth !important" }
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
},
|
|
459
|
+
components: {
|
|
460
|
+
Heading: HeadingStyles,
|
|
461
|
+
Spinner: SpinnerStyles,
|
|
462
|
+
Link: LinkStyles,
|
|
463
|
+
Button: ButtonStyles,
|
|
464
|
+
Input: InputStyles,
|
|
465
|
+
Container: ContainerStyles,
|
|
466
|
+
Modal: ModalStyles,
|
|
467
|
+
Checkbox: CheckboxStyles
|
|
468
|
+
},
|
|
469
|
+
sizes
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
// src/BiblioteksentralenProvider.tsx
|
|
473
|
+
var emptyTheme = {};
|
|
474
|
+
var BiblioteksentralenProvider = (props) => /* @__PURE__ */ React99.createElement(ChakraProvider, { theme: extendTheme(biblioteksentralenChakraTheme, props.customTheme ?? emptyTheme) }, props.children);
|
|
475
|
+
|
|
476
|
+
// src/components/ErrorBoundary.tsx
|
|
477
|
+
import { Box as Box3 } from "@chakra-ui/react";
|
|
478
|
+
import React100 from "react";
|
|
479
|
+
var StyledPre = (props) => /* @__PURE__ */ React100.createElement(Box3, { as: "pre", paddingTop: "0.5rem", wordBreak: "break-all", whiteSpace: "pre-wrap", fontSize: "0.8rem", ...props });
|
|
480
|
+
var ErrorBoundary = class extends React100.Component {
|
|
481
|
+
constructor(props) {
|
|
482
|
+
super(props);
|
|
483
|
+
this.state = { hasError: false };
|
|
484
|
+
}
|
|
485
|
+
static getDerivedStateFromError(error) {
|
|
486
|
+
return { hasError: true };
|
|
487
|
+
}
|
|
488
|
+
componentDidCatch(error, errorInfo) {
|
|
489
|
+
this.setState({ hasError: true, error, errorInfo });
|
|
490
|
+
console.error(error, { errorInfo, boundaryName: this.props.boundaryName });
|
|
491
|
+
}
|
|
492
|
+
render() {
|
|
493
|
+
if (this.state.hasError) {
|
|
494
|
+
const stackTrace = this.state.errorInfo?.componentStack;
|
|
495
|
+
const errormsg = this.state.error?.message;
|
|
496
|
+
const info = this.props.boundaryName;
|
|
497
|
+
return /* @__PURE__ */ React100.createElement("div", null, /* @__PURE__ */ React100.createElement(Alert, { status: "error" }, /* @__PURE__ */ React100.createElement("p", null, "Beklager, det skjedde en teknisk feil."), isDevelopment() && (stackTrace || errormsg) && /* @__PURE__ */ React100.createElement("div", null, /* @__PURE__ */ React100.createElement(StyledPre, null, errormsg || ""), /* @__PURE__ */ React100.createElement(StyledPre, null, info || ""), /* @__PURE__ */ React100.createElement(StyledPre, null, stackTrace || ""))));
|
|
498
|
+
}
|
|
499
|
+
return this.props.children;
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
|
|
503
|
+
// src/components/HashLinkTarget.tsx
|
|
504
|
+
import { Box as Box4 } from "@chakra-ui/react";
|
|
505
|
+
import React101 from "react";
|
|
506
|
+
var focusOnRelativeParentStyle = {
|
|
507
|
+
"&:focus-within": {
|
|
508
|
+
position: "static",
|
|
509
|
+
boxShadow: "none",
|
|
510
|
+
"&::after": {
|
|
511
|
+
content: '""',
|
|
512
|
+
position: "absolute",
|
|
513
|
+
top: 0,
|
|
514
|
+
left: 0,
|
|
515
|
+
height: "100%",
|
|
516
|
+
width: "100%",
|
|
517
|
+
pointerEvents: "none",
|
|
518
|
+
borderRadius: "0.25rem",
|
|
519
|
+
boxShadow: "var(--chakra-shadows-outline)"
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
};
|
|
523
|
+
function HashLinkTarget(props) {
|
|
524
|
+
return /* @__PURE__ */ React101.createElement(Box4, { position: "relative", sx: props.focusOnParent ? focusOnRelativeParentStyle : void 0 }, /* @__PURE__ */ React101.createElement(
|
|
525
|
+
Box4,
|
|
526
|
+
{
|
|
527
|
+
id: props.id,
|
|
528
|
+
tabIndex: props.focusOnParent ? -1 : void 0,
|
|
529
|
+
position: "absolute",
|
|
530
|
+
top: `-${props.spaceAbove || "2.5rem"}`,
|
|
531
|
+
_focus: {
|
|
532
|
+
boxShadow: "none !important"
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
));
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
// src/components/withErrorBoundary.tsx
|
|
539
|
+
import React102 from "react";
|
|
540
|
+
var withErrorBoundary = (Component, boundaryName) => {
|
|
541
|
+
return React102.forwardRef((props, ref) => /* @__PURE__ */ React102.createElement(ErrorBoundary, { boundaryName }, /* @__PURE__ */ React102.createElement(Component, { ...props, ref })));
|
|
542
|
+
};
|
|
543
|
+
export {
|
|
544
|
+
Alert,
|
|
545
|
+
BiblioteksentralenProvider,
|
|
546
|
+
Button,
|
|
547
|
+
ConditionalWrapper,
|
|
548
|
+
ErrorBoundary,
|
|
549
|
+
HashLinkTarget,
|
|
550
|
+
HideWithCSS,
|
|
551
|
+
Input,
|
|
552
|
+
Link,
|
|
553
|
+
VisuallyHidden,
|
|
554
|
+
biblioteksentralenChakraTheme,
|
|
555
|
+
colors,
|
|
556
|
+
withErrorBoundary
|
|
557
|
+
};
|
|
558
|
+
//# sourceMappingURL=index.mjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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
5
|
"keywords": [],
|
|
6
6
|
"author": "Biblioteksentralen",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"main": "dist/index.js",
|
|
10
10
|
"types": "dist/index.d.ts",
|
|
11
11
|
"files": [
|
|
12
|
-
"./dist/*.{js,d.ts,map}",
|
|
12
|
+
"./dist/*.{js,mjs,d.ts,map}",
|
|
13
13
|
"*.md",
|
|
14
14
|
"LICENSE"
|
|
15
15
|
],
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"react": "^18.2.0",
|
|
40
40
|
"react-dom": "^18.2.0",
|
|
41
41
|
"tsup": "^8.0.1",
|
|
42
|
-
"@biblioteksentralen/icons": "1.0.0-beta.
|
|
43
|
-
"@biblioteksentralen/
|
|
44
|
-
"@biblioteksentralen/
|
|
42
|
+
"@biblioteksentralen/icons": "1.0.0-beta.9",
|
|
43
|
+
"@biblioteksentralen/utils": "1.0.0-beta.9",
|
|
44
|
+
"@biblioteksentralen/types": "1.0.0-beta.7"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": "^18.2.0",
|