@biblioteksentralen/react 3.1.0 → 4.0.0-beta.1

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.
Files changed (108) hide show
  1. package/dist/ButtonStyles-CRAk2YIJ.d.mts +3 -0
  2. package/dist/ButtonStyles-CRAk2YIJ.d.ts +3 -0
  3. package/dist/chunk-2KZDHLEJ.mjs +9 -0
  4. package/dist/chunk-2KZDHLEJ.mjs.map +1 -0
  5. package/dist/chunk-3IJ454KG.mjs +185 -0
  6. package/dist/chunk-3IJ454KG.mjs.map +1 -0
  7. package/dist/chunk-5GJBW3WE.mjs +270 -0
  8. package/dist/chunk-5GJBW3WE.mjs.map +1 -0
  9. package/dist/chunk-7MKFY66H.mjs +65 -0
  10. package/dist/chunk-7MKFY66H.mjs.map +1 -0
  11. package/dist/chunk-BCT5QU5W.js +142 -0
  12. package/dist/chunk-BCT5QU5W.js.map +1 -0
  13. package/dist/chunk-BN5W6FVN.mjs +50 -0
  14. package/dist/chunk-BN5W6FVN.mjs.map +1 -0
  15. package/dist/chunk-BRFRPPOW.js +10 -0
  16. package/dist/chunk-BRFRPPOW.js.map +1 -0
  17. package/dist/chunk-BZS3AX26.mjs +6 -0
  18. package/dist/chunk-BZS3AX26.mjs.map +1 -0
  19. package/dist/chunk-CGCBID7S.mjs +41 -0
  20. package/dist/chunk-CGCBID7S.mjs.map +1 -0
  21. package/dist/chunk-J5IF7WUN.js +10 -0
  22. package/dist/chunk-J5IF7WUN.js.map +1 -0
  23. package/dist/chunk-NSYSPEHR.js +86 -0
  24. package/dist/chunk-NSYSPEHR.js.map +1 -0
  25. package/dist/chunk-NYKSRUWF.js +51 -0
  26. package/dist/chunk-NYKSRUWF.js.map +1 -0
  27. package/dist/chunk-O4EXBCND.js +19 -0
  28. package/dist/chunk-O4EXBCND.js.map +1 -0
  29. package/dist/chunk-PLWK7HEC.js +75 -0
  30. package/dist/chunk-PLWK7HEC.js.map +1 -0
  31. package/dist/chunk-PQLTQYZ3.mjs +41 -0
  32. package/dist/chunk-PQLTQYZ3.mjs.map +1 -0
  33. package/dist/chunk-QAW4IRLI.js +55 -0
  34. package/dist/chunk-QAW4IRLI.js.map +1 -0
  35. package/dist/chunk-QBXCCJ24.js +344 -0
  36. package/dist/chunk-QBXCCJ24.js.map +1 -0
  37. package/dist/chunk-QX75QJ7F.mjs +132 -0
  38. package/dist/chunk-QX75QJ7F.mjs.map +1 -0
  39. package/dist/chunk-RZUGRIUF.mjs +76 -0
  40. package/dist/chunk-RZUGRIUF.mjs.map +1 -0
  41. package/dist/chunk-UFIMO32F.js +275 -0
  42. package/dist/chunk-UFIMO32F.js.map +1 -0
  43. package/dist/chunk-VSICUYFB.js +51 -0
  44. package/dist/chunk-VSICUYFB.js.map +1 -0
  45. package/dist/chunk-WYQNSPEX.mjs +6 -0
  46. package/dist/chunk-WYQNSPEX.mjs.map +1 -0
  47. package/dist/components/AlertBS.d.mts +18 -0
  48. package/dist/components/AlertBS.d.ts +18 -0
  49. package/dist/components/AlertBS.js +9 -0
  50. package/dist/components/AlertBS.js.map +1 -0
  51. package/dist/components/AlertBS.mjs +5 -0
  52. package/dist/components/AlertBS.mjs.map +1 -0
  53. package/dist/components/BiblioteksentralenProvider.d.mts +10 -0
  54. package/dist/components/BiblioteksentralenProvider.d.ts +10 -0
  55. package/dist/components/BiblioteksentralenProvider.js +10 -0
  56. package/dist/components/BiblioteksentralenProvider.js.map +1 -0
  57. package/dist/components/BiblioteksentralenProvider.mjs +6 -0
  58. package/dist/components/BiblioteksentralenProvider.mjs.map +1 -0
  59. package/dist/components/ButtonBS.d.mts +16 -0
  60. package/dist/components/ButtonBS.d.ts +16 -0
  61. package/dist/components/ButtonBS.js +8 -0
  62. package/dist/components/ButtonBS.js.map +1 -0
  63. package/dist/components/ButtonBS.mjs +4 -0
  64. package/dist/components/ButtonBS.mjs.map +1 -0
  65. package/dist/components/ConditionalWrapperBS.d.mts +15 -0
  66. package/dist/components/ConditionalWrapperBS.d.ts +15 -0
  67. package/dist/components/ConditionalWrapperBS.js +8 -0
  68. package/dist/components/ConditionalWrapperBS.js.map +1 -0
  69. package/dist/components/ConditionalWrapperBS.mjs +4 -0
  70. package/dist/components/ConditionalWrapperBS.mjs.map +1 -0
  71. package/dist/components/ErrorBoundaryBS.d.mts +21 -0
  72. package/dist/components/ErrorBoundaryBS.d.ts +21 -0
  73. package/dist/components/ErrorBoundaryBS.js +10 -0
  74. package/dist/components/ErrorBoundaryBS.js.map +1 -0
  75. package/dist/components/ErrorBoundaryBS.mjs +6 -0
  76. package/dist/components/ErrorBoundaryBS.mjs.map +1 -0
  77. package/dist/components/HashLinkTargetBS.d.mts +16 -0
  78. package/dist/components/HashLinkTargetBS.d.ts +16 -0
  79. package/dist/components/HashLinkTargetBS.js +10 -0
  80. package/dist/components/HashLinkTargetBS.js.map +1 -0
  81. package/dist/components/HashLinkTargetBS.mjs +6 -0
  82. package/dist/components/HashLinkTargetBS.mjs.map +1 -0
  83. package/dist/components/IconButtonBS.d.mts +16 -0
  84. package/dist/components/IconButtonBS.d.ts +16 -0
  85. package/dist/components/IconButtonBS.js +8 -0
  86. package/dist/components/IconButtonBS.js.map +1 -0
  87. package/dist/components/IconButtonBS.mjs +4 -0
  88. package/dist/components/IconButtonBS.mjs.map +1 -0
  89. package/dist/components/InputBS.d.mts +18 -0
  90. package/dist/components/InputBS.d.ts +18 -0
  91. package/dist/components/InputBS.js +8 -0
  92. package/dist/components/InputBS.js.map +1 -0
  93. package/dist/components/InputBS.mjs +4 -0
  94. package/dist/components/InputBS.mjs.map +1 -0
  95. package/dist/components/withErrorBoundaryBS.d.mts +5 -0
  96. package/dist/components/withErrorBoundaryBS.d.ts +5 -0
  97. package/dist/components/withErrorBoundaryBS.js +11 -0
  98. package/dist/components/withErrorBoundaryBS.js.map +1 -0
  99. package/dist/components/withErrorBoundaryBS.mjs +7 -0
  100. package/dist/components/withErrorBoundaryBS.mjs.map +1 -0
  101. package/dist/index.d.mts +15 -0
  102. package/dist/index.d.ts +13 -106
  103. package/dist/index.js +38 -748
  104. package/dist/index.js.map +1 -1
  105. package/dist/index.mjs +13 -419
  106. package/dist/index.mjs.map +1 -1
  107. package/package.json +27 -11
  108. /package/{LICENSE → dist/LICENSE} +0 -0
@@ -0,0 +1,3 @@
1
+ type CustomButtonVariants = "primary" | "secondary" | "tertiary";
2
+
3
+ export type { CustomButtonVariants as C };
@@ -0,0 +1,3 @@
1
+ type CustomButtonVariants = "primary" | "secondary" | "tertiary";
2
+
3
+ export type { CustomButtonVariants as C };
@@ -0,0 +1,9 @@
1
+ "use client";
2
+ // src/components/ConditionalWrapperBS.tsx
3
+ import React from "react";
4
+ var ConditionalWrapperBS = function(param) {
5
+ var condition = param.condition, children = param.children, Wrapper = param.wrapper;
6
+ return condition ? /* @__PURE__ */ React.createElement(Wrapper, null, children) : /* @__PURE__ */ React.createElement(React.Fragment, null, children);
7
+ };
8
+ export { ConditionalWrapperBS };
9
+ //# sourceMappingURL=chunk-2KZDHLEJ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/danielwinsvold/Code/js-utils/packages/react/dist/chunk-2KZDHLEJ.mjs","../src/components/ConditionalWrapperBS.tsx"],"names":["React","ConditionalWrapperBS","condition","children","wrapper","Wrapper","createElement","Fragment"],"mappings":"AAAA;AAEA,0CAA0C;ACF1C,OAAOA,WAA6C,QAAA;AAW7C,IAAMC,uBAAiD;QAAGC,kBAAAA,WAAWC,iBAAAA,UAAUC,AAASC,gBAATD;WACpFF,YAAY,aAAA,GAAAF,MAAAM,aAAA,CAACD,SAAA,MAASF,YAAsB,aAAA,GAAAH,MAAAM,aAAA,CAAAN,MAAAO,QAAA,EAAA,MAAGJ;;ADNjD,SACEF,oBAAoB,GACpB","sourcesContent":["\"use client\";\n\n// src/components/ConditionalWrapperBS.tsx\nimport React from \"react\";\nvar ConditionalWrapperBS = ({ condition, children, wrapper: Wrapper }) => condition ? /* @__PURE__ */ React.createElement(Wrapper, null, children) : /* @__PURE__ */ React.createElement(React.Fragment, null, children);\n\nexport {\n ConditionalWrapperBS\n};\n","import React, { FunctionComponent, ReactNode } from \"react\";\n\ntype Props = {\n children: ReactNode;\n wrapper: FunctionComponent<{ children: ReactNode }>;\n condition: boolean;\n};\n\n/**\n * Conditionally wrapps children with a component. If conditions are not met children mounted without the wrapper.\n */\nexport const ConditionalWrapperBS: FunctionComponent<Props> = ({ condition, children, wrapper: Wrapper }) =>\n condition ? <Wrapper>{children}</Wrapper> : <>{children}</>;\n"]}
@@ -0,0 +1,185 @@
1
+ "use client";
2
+ function _assert_this_initialized(self) {
3
+ if (self === void 0) {
4
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
5
+ }
6
+ return self;
7
+ }
8
+ function _class_call_check(instance, Constructor) {
9
+ if (!(instance instanceof Constructor)) {
10
+ throw new TypeError("Cannot call a class as a function");
11
+ }
12
+ }
13
+ function _defineProperties(target, props) {
14
+ for(var i = 0; i < props.length; i++){
15
+ var descriptor = props[i];
16
+ descriptor.enumerable = descriptor.enumerable || false;
17
+ descriptor.configurable = true;
18
+ if ("value" in descriptor) descriptor.writable = true;
19
+ Object.defineProperty(target, descriptor.key, descriptor);
20
+ }
21
+ }
22
+ function _create_class(Constructor, protoProps, staticProps) {
23
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
24
+ if (staticProps) _defineProperties(Constructor, staticProps);
25
+ return Constructor;
26
+ }
27
+ function _define_property(obj, key, value) {
28
+ if (key in obj) {
29
+ Object.defineProperty(obj, key, {
30
+ value: value,
31
+ enumerable: true,
32
+ configurable: true,
33
+ writable: true
34
+ });
35
+ } else {
36
+ obj[key] = value;
37
+ }
38
+ return obj;
39
+ }
40
+ function _get_prototype_of(o) {
41
+ _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
42
+ return o.__proto__ || Object.getPrototypeOf(o);
43
+ };
44
+ return _get_prototype_of(o);
45
+ }
46
+ function _inherits(subClass, superClass) {
47
+ if (typeof superClass !== "function" && superClass !== null) {
48
+ throw new TypeError("Super expression must either be null or a function");
49
+ }
50
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
51
+ constructor: {
52
+ value: subClass,
53
+ writable: true,
54
+ configurable: true
55
+ }
56
+ });
57
+ if (superClass) _set_prototype_of(subClass, superClass);
58
+ }
59
+ function _object_spread(target) {
60
+ for(var i = 1; i < arguments.length; i++){
61
+ var source = arguments[i] != null ? arguments[i] : {};
62
+ var ownKeys = Object.keys(source);
63
+ if (typeof Object.getOwnPropertySymbols === "function") {
64
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
65
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
66
+ }));
67
+ }
68
+ ownKeys.forEach(function(key) {
69
+ _define_property(target, key, source[key]);
70
+ });
71
+ }
72
+ return target;
73
+ }
74
+ function _possible_constructor_return(self, call) {
75
+ if (call && (_type_of(call) === "object" || typeof call === "function")) {
76
+ return call;
77
+ }
78
+ return _assert_this_initialized(self);
79
+ }
80
+ function _set_prototype_of(o, p) {
81
+ _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
82
+ o.__proto__ = p;
83
+ return o;
84
+ };
85
+ return _set_prototype_of(o, p);
86
+ }
87
+ function _type_of(obj) {
88
+ "@swc/helpers - typeof";
89
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
90
+ }
91
+ function _is_native_reflect_construct() {
92
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
93
+ if (Reflect.construct.sham) return false;
94
+ if (typeof Proxy === "function") return true;
95
+ try {
96
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
97
+ return true;
98
+ } catch (e) {
99
+ return false;
100
+ }
101
+ }
102
+ function _create_super(Derived) {
103
+ var hasNativeReflectConstruct = _is_native_reflect_construct();
104
+ return function _createSuperInternal() {
105
+ var Super = _get_prototype_of(Derived), result;
106
+ if (hasNativeReflectConstruct) {
107
+ var NewTarget = _get_prototype_of(this).constructor;
108
+ result = Reflect.construct(Super, arguments, NewTarget);
109
+ } else {
110
+ result = Super.apply(this, arguments);
111
+ }
112
+ return _possible_constructor_return(this, result);
113
+ };
114
+ }
115
+ import { AlertBS } from "./chunk-QX75QJ7F.mjs";
116
+ import { isDevelopment } from "./chunk-BN5W6FVN.mjs";
117
+ // src/components/ErrorBoundaryBS.tsx
118
+ import { Box } from "@chakra-ui/react";
119
+ import React from "react";
120
+ var StyledPre = function(props) {
121
+ return /* @__PURE__ */ React.createElement(Box, _object_spread({
122
+ as: "pre",
123
+ paddingTop: "0.5rem",
124
+ wordBreak: "break-all",
125
+ whiteSpace: "pre-wrap",
126
+ fontSize: "0.8rem"
127
+ }, props));
128
+ };
129
+ var ErrorBoundaryBS = /*#__PURE__*/ function(_React_Component) {
130
+ "use strict";
131
+ _inherits(ErrorBoundaryBS, _React_Component);
132
+ var _super = _create_super(ErrorBoundaryBS);
133
+ function ErrorBoundaryBS(props) {
134
+ _class_call_check(this, ErrorBoundaryBS);
135
+ var _this;
136
+ _this = _super.call(this, props);
137
+ _this.state = {
138
+ hasError: false
139
+ };
140
+ return _this;
141
+ }
142
+ _create_class(ErrorBoundaryBS, [
143
+ {
144
+ key: "componentDidCatch",
145
+ value: function componentDidCatch(error, errorInfo) {
146
+ this.setState({
147
+ hasError: true,
148
+ error: error,
149
+ errorInfo: errorInfo
150
+ });
151
+ console.error(error, {
152
+ errorInfo: errorInfo,
153
+ boundaryName: this.props.boundaryName
154
+ });
155
+ }
156
+ },
157
+ {
158
+ key: "render",
159
+ value: function render() {
160
+ if (this.state.hasError) {
161
+ var _this_state_errorInfo, _this_state_error;
162
+ var stackTrace = (_this_state_errorInfo = this.state.errorInfo) === null || _this_state_errorInfo === void 0 ? void 0 : _this_state_errorInfo.componentStack;
163
+ var errormsg = (_this_state_error = this.state.error) === null || _this_state_error === void 0 ? void 0 : _this_state_error.message;
164
+ var info = this.props.boundaryName;
165
+ return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(AlertBS, {
166
+ status: "error"
167
+ }, /* @__PURE__ */ React.createElement("p", null, "Beklager, det skjedde en teknisk feil."), isDevelopment() && (stackTrace || errormsg) && /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(StyledPre, null, errormsg || ""), /* @__PURE__ */ React.createElement(StyledPre, null, info || ""), /* @__PURE__ */ React.createElement(StyledPre, null, stackTrace || ""))));
168
+ }
169
+ return this.props.children;
170
+ }
171
+ }
172
+ ], [
173
+ {
174
+ key: "getDerivedStateFromError",
175
+ value: function getDerivedStateFromError(error) {
176
+ return {
177
+ hasError: true
178
+ };
179
+ }
180
+ }
181
+ ]);
182
+ return ErrorBoundaryBS;
183
+ }(React.Component);
184
+ export { ErrorBoundaryBS };
185
+ //# sourceMappingURL=chunk-3IJ454KG.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/danielwinsvold/Code/js-utils/packages/react/dist/chunk-3IJ454KG.mjs","../src/components/ErrorBoundaryBS.tsx"],"names":["AlertBS","isDevelopment","Box","React","StyledPre","props","createElement","as","paddingTop","wordBreak","whiteSpace","fontSize","ErrorBoundaryBS","state","hasError","componentDidCatch","error","errorInfo","setState","console","boundaryName","render","stackTrace","componentStack","errormsg","message","info","status","children","getDerivedStateFromError","Component"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,SACEA,OAAO,QACF,uBAAuB;AAC9B,SACEC,aAAa,QACR,uBAAuB;AAE9B,qCAAqC;ACPrC,SAASC,GAAA,QAAqB,mBAAA;AAC9B,OAAOC,WAAqC,QAAA;AAc5C,IAAMC,YAAY,SAACC;WACjB,aAAA,GAAAF,MAAAG,aAAA,CAACJ,KAAA;QAAIK,IAAG;QAAMC,YAAW;QAASC,WAAU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OC,KAAAA;mBAAP,SAAOA,yBAAyBb,KAAA;gBAC9B,OAAO;oBAAEF,UAAU;gBAAK;YAC1B;;;;EARmCX,MAAM2B,SAAA;ADe3C,SACElB,eAAe,GACf","sourcesContent":["\"use client\";\nimport {\n AlertBS\n} from \"./chunk-QX75QJ7F.mjs\";\nimport {\n isDevelopment\n} from \"./chunk-BN5W6FVN.mjs\";\n\n// src/components/ErrorBoundaryBS.tsx\nimport { Box } from \"@chakra-ui/react\";\nimport React from \"react\";\nvar StyledPre = (props) => /* @__PURE__ */ React.createElement(Box, { as: \"pre\", paddingTop: \"0.5rem\", wordBreak: \"break-all\", whiteSpace: \"pre-wrap\", fontSize: \"0.8rem\", ...props });\nvar ErrorBoundaryBS = class extends React.Component {\n constructor(props) {\n super(props);\n this.state = { hasError: false };\n }\n static getDerivedStateFromError(error) {\n return { hasError: true };\n }\n componentDidCatch(error, errorInfo) {\n this.setState({ hasError: true, error, errorInfo });\n console.error(error, { errorInfo, boundaryName: this.props.boundaryName });\n }\n render() {\n if (this.state.hasError) {\n const stackTrace = this.state.errorInfo?.componentStack;\n const errormsg = this.state.error?.message;\n const info = this.props.boundaryName;\n return /* @__PURE__ */ React.createElement(\"div\", null, /* @__PURE__ */ React.createElement(AlertBS, { status: \"error\" }, /* @__PURE__ */ React.createElement(\"p\", null, \"Beklager, det skjedde en teknisk feil.\"), isDevelopment() && (stackTrace || errormsg) && /* @__PURE__ */ React.createElement(\"div\", null, /* @__PURE__ */ React.createElement(StyledPre, null, errormsg || \"\"), /* @__PURE__ */ React.createElement(StyledPre, null, info || \"\"), /* @__PURE__ */ React.createElement(StyledPre, null, stackTrace || \"\"))));\n }\n return this.props.children;\n }\n};\n\nexport {\n ErrorBoundaryBS\n};\n","import { isDevelopment } from \"@biblioteksentralen/utils\";\nimport { Box, BoxProps } from \"@chakra-ui/react\";\nimport React, { ErrorInfo, ReactNode } from \"react\";\nimport { AlertBS } from \"./AlertBS\";\n\ninterface Props {\n boundaryName?: string;\n children: ReactNode;\n}\n\ninterface State {\n hasError: boolean;\n error?: Error;\n errorInfo?: ErrorInfo;\n}\n\nconst StyledPre = (props: BoxProps) => (\n <Box as=\"pre\" paddingTop=\"0.5rem\" wordBreak=\"break-all\" whiteSpace=\"pre-wrap\" fontSize=\"0.8rem\" {...props} />\n);\n\nexport class ErrorBoundaryBS extends React.Component<Props, State> {\n constructor(props: any) {\n super(props);\n this.state = { hasError: false };\n }\n\n static getDerivedStateFromError(error: any) {\n return { hasError: true };\n }\n\n componentDidCatch(error: any, errorInfo: any) {\n this.setState({ hasError: true, error, errorInfo });\n console.error(error, { errorInfo, boundaryName: this.props.boundaryName });\n }\n\n render() {\n if (this.state.hasError) {\n const stackTrace = this.state.errorInfo?.componentStack;\n const errormsg = this.state.error?.message;\n const info = this.props.boundaryName;\n\n return (\n <div>\n <AlertBS status=\"error\">\n <p>Beklager, det skjedde en teknisk feil.</p>\n {isDevelopment() && (stackTrace || errormsg) && (\n <div>\n <StyledPre>{errormsg || \"\"}</StyledPre>\n <StyledPre>{info || \"\"}</StyledPre>\n <StyledPre>{stackTrace || \"\"}</StyledPre>\n </div>\n )}\n </AlertBS>\n </div>\n );\n }\n\n return this.props.children;\n }\n}\n"]}
@@ -0,0 +1,270 @@
1
+ "use client";
2
+ function _define_property(obj, key, value) {
3
+ if (key in obj) {
4
+ Object.defineProperty(obj, key, {
5
+ value: value,
6
+ enumerable: true,
7
+ configurable: true,
8
+ writable: true
9
+ });
10
+ } else {
11
+ obj[key] = value;
12
+ }
13
+ return obj;
14
+ }
15
+ function _object_spread(target) {
16
+ for(var i = 1; i < arguments.length; i++){
17
+ var source = arguments[i] != null ? arguments[i] : {};
18
+ var ownKeys = Object.keys(source);
19
+ if (typeof Object.getOwnPropertySymbols === "function") {
20
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
21
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
22
+ }));
23
+ }
24
+ ownKeys.forEach(function(key) {
25
+ _define_property(target, key, source[key]);
26
+ });
27
+ }
28
+ return target;
29
+ }
30
+ var _defaultConfig_theme_recipes_button_variants, _defaultConfig_theme_recipes_button, _defaultConfig_theme_recipes, _defaultConfig_theme;
31
+ import { colors } from "./chunk-BN5W6FVN.mjs";
32
+ // src/styles/chakraTheme/biblioteksentralenChakraTheme.ts
33
+ import { defineConfig, defineTokens } from "@chakra-ui/react";
34
+ // src/styles/chakraTheme/ButtonStyles.ts
35
+ import { defaultConfig, defineRecipe } from "@chakra-ui/react";
36
+ var variants = _object_spread({
37
+ primary: {
38
+ backgroundColor: colors.black,
39
+ color: "white",
40
+ _hover: {
41
+ backgroundColor: "hsla(0deg, 0%, 70%, 1)",
42
+ color: "black"
43
+ }
44
+ },
45
+ secondary: {
46
+ borderColor: "currentColor",
47
+ color: "currentColor",
48
+ backgroundColor: "transparent",
49
+ _hover: {
50
+ backgroundColor: "currentColor/7"
51
+ }
52
+ },
53
+ tertiary: {
54
+ color: "currentColor",
55
+ backgroundColor: "transparent",
56
+ _hover: {
57
+ backgroundColor: "currentColor/7"
58
+ }
59
+ }
60
+ }, (_defaultConfig_theme = defaultConfig.theme) === null || _defaultConfig_theme === void 0 ? void 0 : (_defaultConfig_theme_recipes = _defaultConfig_theme.recipes) === null || _defaultConfig_theme_recipes === void 0 ? void 0 : (_defaultConfig_theme_recipes_button = _defaultConfig_theme_recipes.button) === null || _defaultConfig_theme_recipes_button === void 0 ? void 0 : (_defaultConfig_theme_recipes_button_variants = _defaultConfig_theme_recipes_button.variants) === null || _defaultConfig_theme_recipes_button_variants === void 0 ? void 0 : _defaultConfig_theme_recipes_button_variants.variant);
61
+ var ButtonStyles = defineRecipe({
62
+ base: {
63
+ borderColor: "transparent",
64
+ borderWidth: "0.1em",
65
+ fontWeight: 600,
66
+ _disabled: {
67
+ backgroundColor: "".concat(colors.grey45),
68
+ color: "white",
69
+ opacity: 1
70
+ }
71
+ },
72
+ variants: {
73
+ variant: variants,
74
+ size: {
75
+ sm: {
76
+ h: "8",
77
+ px: "2",
78
+ textStyle: "md"
79
+ },
80
+ md: {
81
+ textStyle: "md"
82
+ },
83
+ lg: {
84
+ h: "12",
85
+ textStyle: "lg"
86
+ }
87
+ }
88
+ },
89
+ defaultVariants: {
90
+ variant: "primary",
91
+ size: "md"
92
+ }
93
+ });
94
+ // src/styles/chakraTheme/ContainerStyles.ts
95
+ import { defineRecipe as defineRecipe2 } from "@chakra-ui/react";
96
+ var ContainerStyles = defineRecipe2({
97
+ base: {
98
+ px: ".75rem"
99
+ }
100
+ });
101
+ // src/styles/chakraTheme/HeadingStyles.ts
102
+ import { defineRecipe as defineRecipe3 } from "@chakra-ui/react";
103
+ var HeadingStyles = defineRecipe3({
104
+ base: {
105
+ fontWeight: "600"
106
+ }
107
+ });
108
+ // src/styles/chakraTheme/InputStyles.ts
109
+ import { defineRecipe as defineRecipe4 } from "@chakra-ui/react";
110
+ var variants2 = {
111
+ subtle: {
112
+ backgroundColor: {
113
+ _light: "gray.200",
114
+ _dark: "whiteAlpha.100"
115
+ },
116
+ _hover: {
117
+ bg: {
118
+ _light: "gray.300",
119
+ _dark: "whiteAlpha.200"
120
+ }
121
+ }
122
+ },
123
+ outline: {
124
+ borderColor: {
125
+ _light: "gray.300",
126
+ _dark: "whiteAlpha.300"
127
+ },
128
+ _hover: {
129
+ borderColor: {
130
+ _light: "gray.400",
131
+ _dark: "whiteAlpha.400"
132
+ }
133
+ }
134
+ },
135
+ flushed: {
136
+ borderColor: {
137
+ _light: "gray.300",
138
+ _dark: "whiteAlpha.300"
139
+ },
140
+ _hover: {
141
+ borderColor: {
142
+ _light: "gray.400",
143
+ _dark: "whiteAlpha.400"
144
+ }
145
+ }
146
+ }
147
+ };
148
+ var InputStyles = defineRecipe4({
149
+ base: {
150
+ _placeholder: {
151
+ color: {
152
+ _light: "gray.500",
153
+ _dark: "whiteAlpha.500"
154
+ }
155
+ }
156
+ },
157
+ variants: {
158
+ variant: variants2
159
+ },
160
+ defaultVariants: {
161
+ variant: "subtle"
162
+ }
163
+ });
164
+ // src/styles/chakraTheme/SpinnerStyles.ts
165
+ import { defineRecipe as defineRecipe5 } from "@chakra-ui/react";
166
+ var SpinnerStyles = defineRecipe5({
167
+ base: {
168
+ animationDuration: ".8s",
169
+ color: colors.accentBlueMedium,
170
+ // Todo: Legg til trackColor: https://chakra-ui.com/docs/components/spinner#track-color
171
+ borderWidth: ".175em"
172
+ }
173
+ });
174
+ // src/styles/chakraTheme/sizes.ts
175
+ var container = {
176
+ sm: {
177
+ value: "40rem"
178
+ },
179
+ md: {
180
+ value: "48rem"
181
+ },
182
+ lg: {
183
+ value: "56rem"
184
+ },
185
+ // Forsøker 56rem som standardbredde etter testing med Katrine
186
+ xl: {
187
+ value: "80rem"
188
+ }
189
+ };
190
+ var sizes = {
191
+ container: container
192
+ };
193
+ // src/styles/chakraTheme/LinkStyles.ts
194
+ import { defineRecipe as defineRecipe6 } from "@chakra-ui/react";
195
+ var variants3 = {
196
+ plain: {
197
+ color: "currentColor",
198
+ textDecoration: "none",
199
+ textDecorationColor: "currentColor",
200
+ _hover: {
201
+ textDecorationColor: "currentColor",
202
+ textDecoration: "underline"
203
+ }
204
+ },
205
+ underline: {
206
+ color: "currentColor",
207
+ textDecoration: "underline",
208
+ textDecorationColor: "currentColor",
209
+ _hover: {
210
+ textDecoration: "none"
211
+ }
212
+ }
213
+ };
214
+ var LinkStyles = defineRecipe6({
215
+ base: {
216
+ _focus: {
217
+ outline: "none"
218
+ }
219
+ },
220
+ variants: {
221
+ variant: variants3
222
+ },
223
+ defaultVariants: {
224
+ variant: "underline"
225
+ }
226
+ });
227
+ // src/styles/chakraTheme/biblioteksentralenChakraTheme.ts
228
+ var tokens = defineTokens({
229
+ sizes: sizes
230
+ });
231
+ var globalHyphens = {
232
+ hyphens: "auto",
233
+ hyphenateLimitChars: "8 5 3"
234
+ };
235
+ var focusStyle = {
236
+ outline: "none !important",
237
+ boxShadow: "0 0 0 .05rem ".concat(colors.white, ", 0 0 0 .25rem ").concat(colors.accentBlueMedium, ", 0 0 0 .3rem ").concat(colors.white, " !important"),
238
+ transition: "box-shadow 0.1s ease-out"
239
+ };
240
+ var biblioteksentralenChakraTheme = defineConfig({
241
+ theme: {
242
+ tokens: tokens,
243
+ recipes: {
244
+ heading: HeadingStyles,
245
+ button: ButtonStyles,
246
+ input: InputStyles,
247
+ link: LinkStyles,
248
+ container: ContainerStyles,
249
+ spinner: SpinnerStyles
250
+ }
251
+ },
252
+ globalCss: {
253
+ html: {
254
+ fontSize: {
255
+ base: "112.5%",
256
+ md: "120%"
257
+ },
258
+ // Sørger for smooth scrolling for interne lenker som scroller til annet sted på siden,
259
+ // men ikke hvis fokus er utenfor viduet, feks ved søk i tekst (ctrl + f)
260
+ "&:focus-within": {
261
+ scrollBehavior: "smooth !important"
262
+ }
263
+ },
264
+ body: _object_spread({}, globalHyphens),
265
+ // Felles fokus-styling for alle elementer for å sikre at de har en tydelig og uniform visuell indikasjon når de er i fokus
266
+ "*:focus-visible": focusStyle
267
+ }
268
+ });
269
+ export { focusStyle, biblioteksentralenChakraTheme };
270
+ //# sourceMappingURL=chunk-5GJBW3WE.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/danielwinsvold/Code/js-utils/packages/react/dist/chunk-5GJBW3WE.mjs","../src/styles/chakraTheme/ButtonStyles.ts","../src/styles/chakraTheme/biblioteksentralenChakraTheme.ts","../src/styles/chakraTheme/ContainerStyles.ts","../src/styles/chakraTheme/HeadingStyles.ts","../src/styles/chakraTheme/InputStyles.ts","../src/styles/chakraTheme/SpinnerStyles.ts","../src/styles/chakraTheme/sizes.ts","../src/styles/chakraTheme/LinkStyles.ts"],"names":["defaultConfig","colors","defineConfig","defineTokens","defineRecipe","variants","primary","backgroundColor","black","color","_hover","secondary","borderColor","tertiary","theme","recipes","button","variant","ButtonStyles","base","borderWidth","fontWeight","_disabled","grey45","opacity","size","sm","h","px","textStyle","md","lg","defaultVariants","ContainerStyles","HeadingStyles","subtle","_light","_dark","bg","outline","flushed","InputStyles","_placeholder","SpinnerStyles","animationDuration","accentBlueMedium","container","value","xl","sizes","plain","textDecoration","textDecorationColor","underline","LinkStyles","_focus","tokens","globalHyphens","hyphens","hyphenateLimitChars","focusStyle","boxShadow","white","transition","biblioteksentralenChakraTheme","heading","input","link","spinner","globalCss","html","fontSize","scrollBehavior","body"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IC8BKA,8CAAAA,qCAAAA,8BAAAA;AD7BL,SACEC,MAAM,QACD,uBAAuB;AAE9B,0DAA0D;AEL1D,SAASC,YAAA,EAAcC,YAAA,QAAoB,mBAAA;AFQ3C,yCAAyC;ACPzC,SAASH,aAAA,EAAeI,YAAA,QAAuC,mBAAA;AAI/D,IAAMC,WAA4D;IAChEC,SAAS;QACPC,iBAAiBN,OAAOO,KAAA;QACxBC,OAAO;QACPC,QAAQ;YACNH,iBAAiB;YACjBE,OAAO;QACT;IACF;IACAE,WAAW;QACTC,aAAa;QACbH,OAAO;QACPF,iBAAiB;QACjBG,QAAQ;YACNH,iBAAiB;QACnB;IACF;IACAM,UAAU;QACRJ,OAAO;QACPF,iBAAiB;QACjBG,QAAQ;YACNH,iBAAiB;QACnB;IACF;IAEGP,uBAAAA,cAAcc,KAAA,cAAdd,4CAAAA,+BAAAA,qBAAqBe,OAAA,cAArBf,oDAAAA,sCAAAA,6BAA8BgB,MAAA,cAA9BhB,2DAAAA,+CAAAA,oCAAsCK,QAAA,cAAtCL,mEAAAA,6CAAgDiB,OAAA;AAG9C,IAAMC,eAAed,aAAa;IACvCe,MAAM;QACJP,aAAa;QACbQ,aAAa;QACbC,YAAY;QACZC,WAAW;YACTf,iBAAiB,GAAgB,OAAbN,OAAOsB,MAAM;YACjCd,OAAO;YACPe,SAAS;QACX;IACF;IACAnB,UAAU;QACRY,SAASZ;QACToB,MAAM;YACJC,IAAI;gBACFC,GAAG;gBACHC,IAAI;gBACJC,WAAW;YACb;YACAC,IAAI;gBACFD,WAA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AEpD,MAAM;gBAAUW,IAAI;YAAO;YAAA,uFAAA;YAAA,yEAAA;YAGvC,kBAAkB;gBAAE0C,gBAAgB;YAAoB;QAC1D;QACAC,MAAM,mBACDhB;QACL,2HAAA;QAEA,mBAAmBG;IACrB;AACF;AF0KA,SACEA,UAAU,EACVI,6BAA6B,GAC7B","sourcesContent":["\"use client\";\nimport {\n colors\n} from \"./chunk-BN5W6FVN.mjs\";\n\n// src/styles/chakraTheme/biblioteksentralenChakraTheme.ts\nimport { defineConfig, defineTokens } from \"@chakra-ui/react\";\n\n// src/styles/chakraTheme/ButtonStyles.ts\nimport { defaultConfig, defineRecipe } from \"@chakra-ui/react\";\nvar variants = {\n primary: {\n backgroundColor: colors.black,\n color: \"white\",\n _hover: {\n backgroundColor: \"hsla(0deg, 0%, 70%, 1)\",\n color: \"black\"\n }\n },\n secondary: {\n borderColor: \"currentColor\",\n color: \"currentColor\",\n backgroundColor: \"transparent\",\n _hover: {\n backgroundColor: \"currentColor/7\"\n }\n },\n tertiary: {\n color: \"currentColor\",\n backgroundColor: \"transparent\",\n _hover: {\n backgroundColor: \"currentColor/7\"\n }\n },\n // Inherit variants from Chakra's default config. Seems like they are overridden by our custom variants by default.\n ...defaultConfig.theme?.recipes?.button?.variants?.variant\n};\nvar ButtonStyles = defineRecipe({\n base: {\n borderColor: \"transparent\",\n borderWidth: \"0.1em\",\n fontWeight: 600,\n _disabled: {\n backgroundColor: `${colors.grey45}`,\n color: \"white\",\n opacity: 1\n }\n },\n variants: {\n variant: variants,\n size: {\n sm: {\n h: \"8\",\n px: \"2\",\n textStyle: \"md\"\n },\n md: {\n textStyle: \"md\"\n },\n lg: {\n h: \"12\",\n textStyle: \"lg\"\n }\n }\n },\n defaultVariants: {\n variant: \"primary\",\n size: \"md\"\n }\n});\n\n// src/styles/chakraTheme/ContainerStyles.ts\nimport { defineRecipe as defineRecipe2 } from \"@chakra-ui/react\";\nvar ContainerStyles = defineRecipe2({\n base: {\n px: \".75rem\"\n // Padding left/right\n }\n});\n\n// src/styles/chakraTheme/HeadingStyles.ts\nimport { defineRecipe as defineRecipe3 } from \"@chakra-ui/react\";\nvar HeadingStyles = defineRecipe3({\n base: {\n fontWeight: \"600\"\n }\n});\n\n// src/styles/chakraTheme/InputStyles.ts\nimport { defineRecipe as defineRecipe4 } from \"@chakra-ui/react\";\nvar variants2 = {\n subtle: {\n backgroundColor: { _light: \"gray.200\", _dark: \"whiteAlpha.100\" },\n _hover: {\n bg: { _light: \"gray.300\", _dark: \"whiteAlpha.200\" }\n }\n },\n outline: {\n borderColor: { _light: \"gray.300\", _dark: \"whiteAlpha.300\" },\n _hover: {\n borderColor: { _light: \"gray.400\", _dark: \"whiteAlpha.400\" }\n }\n },\n flushed: {\n borderColor: { _light: \"gray.300\", _dark: \"whiteAlpha.300\" },\n _hover: {\n borderColor: { _light: \"gray.400\", _dark: \"whiteAlpha.400\" }\n }\n }\n};\nvar InputStyles = defineRecipe4({\n base: {\n _placeholder: {\n color: { _light: \"gray.500\", _dark: \"whiteAlpha.500\" }\n }\n },\n variants: {\n variant: variants2\n },\n defaultVariants: {\n variant: \"subtle\"\n }\n});\n\n// src/styles/chakraTheme/SpinnerStyles.ts\nimport { defineRecipe as defineRecipe5 } from \"@chakra-ui/react\";\nvar SpinnerStyles = defineRecipe5({\n base: {\n animationDuration: \".8s\",\n color: colors.accentBlueMedium,\n // Todo: Legg til trackColor: https://chakra-ui.com/docs/components/spinner#track-color\n borderWidth: \".175em\"\n }\n});\n\n// src/styles/chakraTheme/sizes.ts\nvar container = {\n sm: { value: \"40rem\" },\n md: { value: \"48rem\" },\n lg: { value: \"56rem\" },\n // Forsøker 56rem som standardbredde etter testing med Katrine\n xl: { value: \"80rem\" }\n};\nvar sizes = {\n container\n};\n\n// src/styles/chakraTheme/LinkStyles.ts\nimport { defineRecipe as defineRecipe6 } from \"@chakra-ui/react\";\nvar variants3 = {\n plain: {\n color: \"currentColor\",\n textDecoration: \"none\",\n textDecorationColor: \"currentColor\",\n _hover: {\n textDecorationColor: \"currentColor\",\n textDecoration: \"underline\"\n }\n },\n underline: {\n color: \"currentColor\",\n textDecoration: \"underline\",\n textDecorationColor: \"currentColor\",\n _hover: {\n textDecoration: \"none\"\n }\n }\n};\nvar LinkStyles = defineRecipe6({\n base: {\n _focus: {\n outline: \"none\"\n }\n },\n variants: {\n variant: variants3\n },\n defaultVariants: {\n variant: \"underline\"\n }\n});\n\n// src/styles/chakraTheme/biblioteksentralenChakraTheme.ts\nvar tokens = defineTokens({\n sizes\n});\nvar globalHyphens = {\n hyphens: \"auto\",\n hyphenateLimitChars: \"8 5 3\"\n // minimum word-length / min letters first line / min letters second line\n};\nvar focusStyle = {\n outline: \"none !important\",\n boxShadow: `0 0 0 .05rem ${colors.white}, 0 0 0 .25rem ${colors.accentBlueMedium}, 0 0 0 .3rem ${colors.white} !important`,\n transition: \"box-shadow 0.1s ease-out\"\n // Transition makes the newly focused element \"pop in\" and easier to spot\n};\nvar biblioteksentralenChakraTheme = defineConfig({\n theme: {\n tokens,\n recipes: {\n heading: HeadingStyles,\n button: ButtonStyles,\n input: InputStyles,\n link: LinkStyles,\n container: ContainerStyles,\n spinner: SpinnerStyles\n }\n },\n globalCss: {\n html: {\n fontSize: { base: \"112.5%\", md: \"120%\" },\n // Sørger for smooth scrolling for interne lenker som scroller til annet sted på siden,\n // men ikke hvis fokus er utenfor viduet, feks ved søk i tekst (ctrl + f)\n \"&:focus-within\": { scrollBehavior: \"smooth !important\" }\n },\n body: {\n ...globalHyphens\n },\n // Felles fokus-styling for alle elementer for å sikre at de har en tydelig og uniform visuell indikasjon når de er i fokus\n \"*:focus-visible\": focusStyle\n }\n});\n\nexport {\n focusStyle,\n biblioteksentralenChakraTheme\n};\n","import { colors } from \"@biblioteksentralen/utils\";\nimport { defaultConfig, defineRecipe, SystemStyleObject } from \"@chakra-ui/react\";\n\nexport type CustomButtonVariants = \"primary\" | \"secondary\" | \"tertiary\";\n\nconst variants: Record<CustomButtonVariants, SystemStyleObject> = {\n primary: {\n backgroundColor: colors.black,\n color: \"white\",\n _hover: {\n backgroundColor: \"hsla(0deg, 0%, 70%, 1)\",\n color: \"black\",\n },\n },\n secondary: {\n borderColor: \"currentColor\",\n color: \"currentColor\",\n backgroundColor: \"transparent\",\n _hover: {\n backgroundColor: \"currentColor/7\",\n },\n },\n tertiary: {\n color: \"currentColor\",\n backgroundColor: \"transparent\",\n _hover: {\n backgroundColor: \"currentColor/7\",\n },\n },\n // Inherit variants from Chakra's default config. Seems like they are overridden by our custom variants by default.\n ...defaultConfig.theme?.recipes?.button?.variants?.variant,\n};\n\nexport const ButtonStyles = defineRecipe({\n base: {\n borderColor: \"transparent\",\n borderWidth: \"0.1em\",\n fontWeight: 600,\n _disabled: {\n backgroundColor: `${colors.grey45}`,\n color: \"white\",\n opacity: 1,\n },\n },\n variants: {\n variant: variants,\n size: {\n sm: {\n h: \"8\",\n px: \"2\",\n textStyle: \"md\",\n },\n md: {\n textStyle: \"md\",\n },\n lg: {\n h: \"12\",\n textStyle: \"lg\",\n },\n },\n },\n defaultVariants: {\n variant: \"primary\",\n size: \"md\",\n },\n});\n","import { defineConfig, defineTokens } from \"@chakra-ui/react\";\nimport { ButtonStyles } from \"./ButtonStyles\";\nimport { ContainerStyles } from \"./ContainerStyles\";\nimport { HeadingStyles } from \"./HeadingStyles\";\nimport { InputStyles } from \"./InputStyles\";\nimport { SpinnerStyles } from \"./SpinnerStyles\";\nimport { sizes } from \"./sizes\";\nimport { LinkStyles } from \"./LinkStyles\";\nimport { colors } from \"@biblioteksentralen/utils\";\n\nconst tokens = defineTokens({\n sizes,\n});\n\n// https://blog.logrocket.com/guide-css-word-wrap-overflow-wrap-word-break/\n// https://medium.com/clear-left-thinking/all-you-need-to-know-about-hyphenation-in-css-2baee2d89179\n// Skrur på hyphens auto som default fordi vi har masse mikrotekster og små elementer der layout knekker uten dette, og vi lager stadig nye og glemmer å ta hensyn til dette.\n// Så kan man optionaly sette hyphens: none de stedene man ikke ønsker det, men har ikke sett noe som knekker/blir rart pga dette enda\nconst globalHyphens = {\n hyphens: \"auto\",\n hyphenateLimitChars: \"8 5 3\", // minimum word-length / min letters first line / min letters second line\n};\n\nexport const focusStyle = {\n outline: \"none !important\",\n boxShadow: `0 0 0 .05rem ${colors.white}, 0 0 0 .25rem ${colors.accentBlueMedium}, 0 0 0 .3rem ${colors.white} !important`,\n transition: \"box-shadow 0.1s ease-out\", // Transition makes the newly focused element \"pop in\" and easier to spot\n};\n\nexport const biblioteksentralenChakraTheme = defineConfig({\n theme: {\n tokens,\n recipes: {\n heading: HeadingStyles,\n button: ButtonStyles,\n input: InputStyles,\n link: LinkStyles,\n container: ContainerStyles,\n spinner: SpinnerStyles,\n },\n },\n globalCss: {\n html: {\n fontSize: { base: \"112.5%\", md: \"120%\" },\n // Sørger for smooth scrolling for interne lenker som scroller til annet sted på siden,\n // men ikke hvis fokus er utenfor viduet, feks ved søk i tekst (ctrl + f)\n \"&:focus-within\": { scrollBehavior: \"smooth !important\" },\n },\n body: {\n ...globalHyphens,\n },\n // Felles fokus-styling for alle elementer for å sikre at de har en tydelig og uniform visuell indikasjon når de er i fokus\n \"*:focus-visible\": focusStyle,\n },\n});\n","import { defineRecipe } from \"@chakra-ui/react\";\n\nexport const ContainerStyles = defineRecipe({\n base: {\n px: \".75rem\", // Padding left/right\n },\n});\n","import { defineRecipe } from \"@chakra-ui/react\";\n\nexport const HeadingStyles = defineRecipe({\n base: {\n fontWeight: \"600\",\n },\n});\n","import { defineRecipe, SystemStyleObject } from \"@chakra-ui/react\";\n\nconst variants: Record<string, SystemStyleObject> = {\n subtle: {\n backgroundColor: { _light: \"gray.200\", _dark: \"whiteAlpha.100\" },\n _hover: {\n bg: { _light: \"gray.300\", _dark: \"whiteAlpha.200\" },\n },\n },\n outline: {\n borderColor: { _light: \"gray.300\", _dark: \"whiteAlpha.300\" },\n _hover: {\n borderColor: { _light: \"gray.400\", _dark: \"whiteAlpha.400\" },\n },\n },\n flushed: {\n borderColor: { _light: \"gray.300\", _dark: \"whiteAlpha.300\" },\n _hover: {\n borderColor: { _light: \"gray.400\", _dark: \"whiteAlpha.400\" },\n },\n },\n};\n\nexport const InputStyles = defineRecipe({\n base: {\n _placeholder: {\n color: { _light: \"gray.500\", _dark: \"whiteAlpha.500\" },\n },\n },\n variants: {\n variant: variants,\n },\n defaultVariants: {\n variant: \"subtle\",\n },\n});\n","import { colors } from \"@biblioteksentralen/utils\";\nimport { defineRecipe } from \"@chakra-ui/react\";\n\nexport const SpinnerStyles = defineRecipe({\n base: {\n animationDuration: \".8s\",\n color: colors.accentBlueMedium,\n // Todo: Legg til trackColor: https://chakra-ui.com/docs/components/spinner#track-color\n borderWidth: \".175em\",\n },\n});\n","const container = {\n sm: { value: \"40rem\" },\n md: { value: \"48rem\" },\n lg: { value: \"56rem\" }, // Forsøker 56rem som standardbredde etter testing med Katrine\n xl: { value: \"80rem\" },\n};\n\nexport const sizes = {\n container,\n};\n","import { defineRecipe, SystemStyleObject } from \"@chakra-ui/react\";\n\nexport type CustomLinkVariants = \"plain\" | \"underline\";\n\nconst variants: Record<CustomLinkVariants, SystemStyleObject> = {\n plain: {\n color: \"currentColor\",\n textDecoration: \"none\",\n textDecorationColor: \"currentColor\",\n _hover: {\n textDecorationColor: \"currentColor\",\n textDecoration: \"underline\",\n },\n },\n underline: {\n color: \"currentColor\",\n textDecoration: \"underline\",\n textDecorationColor: \"currentColor\",\n _hover: {\n textDecoration: \"none\",\n },\n },\n};\n\nexport const LinkStyles = defineRecipe({\n base: {\n _focus: {\n outline: \"none\",\n },\n },\n variants: {\n variant: variants,\n },\n defaultVariants: {\n variant: \"underline\",\n },\n});\n"]}
@@ -0,0 +1,65 @@
1
+ "use client";
2
+ function _define_property(obj, key, value) {
3
+ if (key in obj) {
4
+ Object.defineProperty(obj, key, {
5
+ value: value,
6
+ enumerable: true,
7
+ configurable: true,
8
+ writable: true
9
+ });
10
+ } else {
11
+ obj[key] = value;
12
+ }
13
+ return obj;
14
+ }
15
+ function _object_spread(target) {
16
+ for(var i = 1; i < arguments.length; i++){
17
+ var source = arguments[i] != null ? arguments[i] : {};
18
+ var ownKeys = Object.keys(source);
19
+ if (typeof Object.getOwnPropertySymbols === "function") {
20
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
21
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
22
+ }));
23
+ }
24
+ ownKeys.forEach(function(key) {
25
+ _define_property(target, key, source[key]);
26
+ });
27
+ }
28
+ return target;
29
+ }
30
+ import { focusStyle } from "./chunk-5GJBW3WE.mjs";
31
+ // src/components/HashLinkTargetBS.tsx
32
+ import { Box } from "@chakra-ui/react";
33
+ import React from "react";
34
+ var focusOnRelativeParentStyle = {
35
+ _focusWithin: {
36
+ position: "static",
37
+ boxShadow: "none",
38
+ "&::after": _object_spread({
39
+ content: '""',
40
+ position: "absolute",
41
+ top: 0,
42
+ left: 0,
43
+ height: "100%",
44
+ width: "100%",
45
+ pointerEvents: "none",
46
+ borderRadius: "0.25rem"
47
+ }, focusStyle)
48
+ }
49
+ };
50
+ function HashLinkTargetBS(props) {
51
+ return /* @__PURE__ */ React.createElement(Box, {
52
+ position: "relative",
53
+ css: props.focusOnParent ? focusOnRelativeParentStyle : void 0
54
+ }, /* @__PURE__ */ React.createElement(Box, {
55
+ id: props.id,
56
+ tabIndex: props.focusOnParent ? -1 : void 0,
57
+ position: "absolute",
58
+ top: "-".concat(props.spaceAbove || "2.5rem"),
59
+ _focus: {
60
+ boxShadow: "none !important"
61
+ }
62
+ }));
63
+ }
64
+ export { HashLinkTargetBS };
65
+ //# sourceMappingURL=chunk-7MKFY66H.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/danielwinsvold/Code/js-utils/packages/react/dist/chunk-7MKFY66H.mjs","../src/components/HashLinkTargetBS.tsx"],"names":["focusStyle","Box","React","focusOnRelativeParentStyle","_focusWithin","position","boxShadow","content","top","left","height","width","pointerEvents","borderRadius","HashLinkTargetBS","props","createElement","css","focusOnParent","id","tabIndex","spaceAbove","_focus"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,SACEA,UAAU,QACL,uBAAuB;AAE9B,sCAAsC;ACLtC,SAASC,GAAA,QAAW,mBAAA;AACpB,OAAOC,WAAW,QAAA;AAelB,IAAMC,6BAA6B;IACjCC,cAAc;QACZC,UAAU;QACVC,WAAW;QACX,YAAY;YACVC,SAAS;YACTF,UAAU;YACVG,KAAK;YACLC,MAAM;YACNC,QAAQ;YACRC,OAAO;YACPC,eAAe;YACfC,cAAc;WACXb;IAEP;AACF;AAKO,SAASc,iBAAiBC,KAAA;IAC/B,OACE,aAAA,GAAAb,MAAAc,aAAA,CAACf,KAAA;QAAII,UAAS;QAAWY,KAAKF,MAAMG,aAAA,GAAgBf,6BAA6B,KAAA;IAAA,GAC/E,aAAA,GAAAD,MAAAc,aAAA,CAACf,KAAA;QACCkB,IAAIJ,MAAMI,EAAA;QACVC,UAAUL,MAAMG,aAAA,GAAgB,CAAA,IAAK,KAAA;QACrCb,UAAS;QACTG,KAAK,IAAgC,OAA5BO,MAAMM,UAAA,IAAc;QAC7BC,QAAQ;YACNhB,WAAW;QACb;IAAA;AAIR;ADXA,SACEQ,gBAAgB,GAChB","sourcesContent":["\"use client\";\nimport {\n focusStyle\n} from \"./chunk-5GJBW3WE.mjs\";\n\n// src/components/HashLinkTargetBS.tsx\nimport { Box } from \"@chakra-ui/react\";\nimport React from \"react\";\nvar focusOnRelativeParentStyle = {\n _focusWithin: {\n position: \"static\",\n boxShadow: \"none\",\n \"&::after\": {\n content: '\"\"',\n position: \"absolute\",\n top: 0,\n left: 0,\n height: \"100%\",\n width: \"100%\",\n pointerEvents: \"none\",\n borderRadius: \"0.25rem\",\n ...focusStyle\n }\n }\n};\nfunction HashLinkTargetBS(props) {\n return /* @__PURE__ */ React.createElement(Box, { position: \"relative\", css: props.focusOnParent ? focusOnRelativeParentStyle : void 0 }, /* @__PURE__ */ React.createElement(\n Box,\n {\n id: props.id,\n tabIndex: props.focusOnParent ? -1 : void 0,\n position: \"absolute\",\n top: `-${props.spaceAbove || \"2.5rem\"}`,\n _focus: {\n boxShadow: \"none !important\"\n }\n }\n ));\n}\n\nexport {\n HashLinkTargetBS\n};\n","import { Box } from \"@chakra-ui/react\";\nimport React from \"react\";\nimport { focusStyle } from \"../styles/chakraTheme/biblioteksentralenChakraTheme\";\n\ninterface Props {\n id: string;\n /**\n * angir hvor mye luft til vil ha over HashLinkTarget ved bruk av hash-lenke, eks '4rem'\n */\n spaceAbove?: string;\n /**\n * angir om du vil ha fokusramme rundt komponenten som mounter HashLinkTarget. Da må komponenten du wrapper med ha position: relative | absolute el\n */\n focusOnParent?: boolean;\n}\n\nconst focusOnRelativeParentStyle = {\n _focusWithin: {\n position: \"static\",\n boxShadow: \"none\",\n \"&::after\": {\n content: '\"\"',\n position: \"absolute\",\n top: 0,\n left: 0,\n height: \"100%\",\n width: \"100%\",\n pointerEvents: \"none\",\n borderRadius: \"0.25rem\",\n ...focusStyle,\n },\n },\n};\n\n/*\n * 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>)\n */\nexport function HashLinkTargetBS(props: Props) {\n return (\n <Box position=\"relative\" css={props.focusOnParent ? focusOnRelativeParentStyle : undefined}>\n <Box\n id={props.id}\n tabIndex={props.focusOnParent ? -1 : undefined}\n position=\"absolute\"\n top={`-${props.spaceAbove || \"2.5rem\"}`}\n _focus={{\n boxShadow: \"none !important\",\n }}\n />\n </Box>\n );\n}\n"]}