elbe-ui 2.0.0 → 2.0.2

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.
@@ -1,6 +1,6 @@
1
1
  import { Context } from "react";
2
2
  import { BitParams, BitUseInterface } from "..";
3
- import { _BitCtrlMaker, _BitProvider } from "./_bit_utils";
3
+ import { _BitCtrlMaker, _BitProvider } from "./_bit_types";
4
4
  export declare function _makeBitProvider<D, P, I>(context: Context<BitUseInterface<D, P, I>>, bitP: BitParams<D, P, I> & {
5
5
  control: _BitCtrlMaker<D, P, I>;
6
6
  }): _BitProvider<P>;
@@ -8,9 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
- import { useEffect, useMemo, useState } from "react";
11
+ import { useEffect, useState } from "react";
12
12
  import { Column, ErrorView, Spinner, } from "..";
13
- import { _isFn } from "./_bit_utils";
13
+ import { _isFn } from "./_bit_types";
14
14
  function _LoadView({}) {
15
15
  return (_jsx(Column, { cross: "center", children: _jsx(Spinner, {}) }));
16
16
  }
@@ -128,7 +128,7 @@ export function _makeBitProvider(context, bitP) {
128
128
  const userCtrl = bitP.control(Object.assign(Object.assign({}, baseCtrl), { parameters: p, reload: _reload, consider: consider }));
129
129
  return Object.assign(Object.assign(Object.assign({}, baseCtrl), userCtrl), { reload: _reload, parameters: p, consider: consider });
130
130
  }
131
- const ctrl = useMemo(() => _make(), [state]);
131
+ const ctrl = _make();
132
132
  useEffect(() => {
133
133
  ctrl.reload(true);
134
134
  return () => {
@@ -147,7 +147,7 @@ export function _makeBitProvider(context, bitP) {
147
147
  };
148
148
  }, []);
149
149
  // ========== DEFINE THE JSX ELEMENT ==========
150
- return _jsx(context.Provider, { value: ctrl, children: p.children });
150
+ return (_jsx(context.Provider, { value: Object.assign({}, ctrl), children: p.children }));
151
151
  }
152
152
  return _BitProvider;
153
153
  }
package/dist/bit/bit.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Context } from "react";
2
2
  import { Maybe, PromiseOr } from "..";
3
- import { _BitCtrlInput, _BitCtrlMaker, _BitData, _BitGetInterface, _BitInterface } from "./_bit_utils";
3
+ import { _BitCtrlInput, _BitCtrlMaker, _BitData, _BitGetInterface, _BitInterface } from "./_bit_types";
4
4
  export type BitStates = "loading" | "error" | "data";
5
5
  export type BitContext<D> = Context<_BitData<D> | null>;
6
6
  export type BitTriMap<T, D> = {
package/dist/bit/bit.js CHANGED
@@ -14,6 +14,7 @@ import { _makeBitProvider } from "./_bit_provider";
14
14
  export function createBit(_a) {
15
15
  var { control = () => ({}) } = _a, p = __rest(_a, ["control"]);
16
16
  const context = createContext(null);
17
+ context.displayName = p.debugLabel || "BitContext";
17
18
  {
18
19
  return {
19
20
  Provider: _makeBitProvider(context, Object.assign(Object.assign({}, p), { control })),
@@ -1,12 +1,13 @@
1
- import { ElbeRoute, ElbeThemeContext } from "../..";
1
+ import { ElbeRoute, ElbeThemeConfig, ElbeThemeContext, ElbeThemeData } from "../..";
2
2
  import { AppConfig } from "./app_ctxt";
3
3
  type _AppThemeConfig = {
4
4
  themeContext: ElbeThemeContext;
5
5
  themeSeed?: Partial<Parameters<_AppThemeConfig["themeContext"]["WithTheme"]>[0]["seed"]>;
6
+ themeSelector?: (config: ElbeThemeConfig<ElbeThemeData>) => Partial<ElbeThemeConfig<ElbeThemeData>>;
6
7
  };
7
8
  type _AppProps = AppConfig & _AppThemeConfig;
8
9
  type AppProps = _AppProps & {
9
- children: ElbeRoute | ElbeRoute[];
10
+ children?: ElbeRoute | ElbeRoute[];
10
11
  };
11
12
  export declare function ElbeApp(p: AppProps): import("react/jsx-runtime").JSX.Element;
12
13
  export {};
@@ -9,55 +9,70 @@ export function ElbeApp(p) {
9
9
  if (p.title)
10
10
  document.title = p.title;
11
11
  }, [p.title]);
12
- return (_jsx(p.themeContext.WithTheme, { seed: p.themeSeed, children: _jsx(Wouter.Router, { base: (_a = p.routerConfig) === null || _a === void 0 ? void 0 : _a.basePath, children: _jsx(_App, { config: omit(p, "children", "themeContext", "themeSeed"), themeContext: p.themeContext, children: p.children }) }) }));
12
+ const trueBase = useMemo(() => {
13
+ var _a, _b;
14
+ const path = (_b = (_a = p.routerConfig) === null || _a === void 0 ? void 0 : _a.basePath) !== null && _b !== void 0 ? _b : "/";
15
+ return path === "/" ? undefined : path;
16
+ }, [(_a = p.routerConfig) === null || _a === void 0 ? void 0 : _a.basePath]);
17
+ return (_jsx(p.themeContext.WithTheme, { seed: p.themeSeed, children: _jsx(Wouter.Router, { base: trueBase, children: _jsx(_App, { config: omit(p, "children", "themeContext", "themeSeed", "themeSelector"), themeContext: p.themeContext, themeSelector: p.themeSelector, children: p.children }) }) }));
13
18
  }
14
19
  function _initialLocation() {
15
20
  return (window.location.pathname + window.location.search + window.location.hash);
16
21
  }
17
22
  function _App(p) {
23
+ var _a;
24
+ const theme = p.themeContext.useTheme();
25
+ const themeSelected = theme.useWith((_a = p.themeSelector) !== null && _a !== void 0 ? _a : (() => ({})), [
26
+ p.config,
27
+ p.themeSelector,
28
+ ]);
18
29
  const menuItems = useMemo(() => {
19
30
  return _extractMenuItems(p.children);
20
31
  }, [p.children]);
21
32
  const [location, navigate] = Wouter.useLocation();
22
33
  const [history, setHistory] = useState([_initialLocation()]);
23
34
  const [menuOpen, setMenuOpen] = useState(false);
24
- return (_jsx(AppContext.Provider, { value: {
25
- appConfig: p.config,
26
- _appThemeContext: p.themeContext,
27
- router: {
28
- goBack: (steps = 1) => {
29
- if (history.length === 0)
30
- return;
31
- const targetIndex = Math.max(0, history.length - 1 - steps);
32
- const target = history[targetIndex];
33
- setHistory((h) => h.slice(0, targetIndex + 1));
34
- navigate(target, { replace: true });
35
- },
36
- go: (p, replace) => {
37
- setHistory((h) => {
38
- if (replace === "all")
39
- return [p];
40
- const repl = Math.max(0, replace !== null && replace !== void 0 ? replace : 0);
41
- if (repl === 0)
42
- return [...h, p];
43
- return [...h.slice(0, -repl), p];
44
- });
45
- navigate(p, { replace: (replace !== null && replace !== void 0 ? replace : 0) !== 0 });
35
+ return (_jsx(p.themeContext.WithTheme, { theme: themeSelected, children: _jsx(AppContext.Provider, { value: {
36
+ appConfig: p.config,
37
+ _appThemeContext: p.themeContext,
38
+ router: {
39
+ goBack: (steps = 1) => {
40
+ if (history.length === 0)
41
+ return;
42
+ const targetIndex = Math.max(0, history.length - 1 - steps);
43
+ const target = history[targetIndex];
44
+ setHistory((h) => h.slice(0, targetIndex + 1));
45
+ navigate(target, { replace: true });
46
+ },
47
+ go: (p, replace) => {
48
+ setHistory((h) => {
49
+ if (replace === "all")
50
+ return [p];
51
+ const repl = Math.max(0, replace !== null && replace !== void 0 ? replace : 0);
52
+ if (repl === 0)
53
+ return [...h, p];
54
+ return [...h.slice(0, -repl), p];
55
+ });
56
+ navigate(p, { replace: (replace !== null && replace !== void 0 ? replace : 0) !== 0 });
57
+ },
58
+ history: history,
59
+ location: location,
46
60
  },
47
- history: history,
48
- location: location,
49
- },
50
- menu: {
51
- isOpen: menuOpen,
52
- setOpen: (s) => setMenuOpen(s),
53
- },
54
- }, children: _jsx(ToastProvider, { children: _jsx(DialogsProvider, { children: _jsxs(Box, { typeLabel: "app_base", scheme: "primary", style: {
55
- display: "flex",
56
- width: "100%",
57
- minHeight: "100vh",
58
- }, children: [menuItems.length > 0 && _jsx(Menu, { items: menuItems }), _jsx("div", { style: { flex: 1, width: "0px" }, children: _jsx(Wouter.Switch, { children: p.children }) })] }) }) }) }));
61
+ menu: menuItems.length === 0
62
+ ? undefined
63
+ : {
64
+ isOpen: menuOpen,
65
+ setOpen: (s) => setMenuOpen(s),
66
+ },
67
+ }, children: _jsx(ToastProvider, { children: _jsx(DialogsProvider, { children: _jsxs(Box, { typeLabel: "app_base", scheme: "primary", style: {
68
+ display: "flex",
69
+ width: "100%",
70
+ minHeight: "100vh",
71
+ }, children: [menuItems.length > 0 && _jsx(Menu, { items: menuItems }), _jsx("div", { style: { flex: 1, width: "0px" }, children: _jsx(Wouter.Switch, { children: p.children }) })] }) }) }) }) }));
59
72
  }
60
73
  function _extractMenuItems(children) {
74
+ if (!children)
75
+ return [];
61
76
  const childs = Array.isArray(children) ? children : [children];
62
77
  const items = [];
63
78
  for (const child of childs) {
@@ -23,7 +23,7 @@ type _RouterState = {
23
23
  export interface AppState {
24
24
  appConfig: AppConfig;
25
25
  router: _RouterState;
26
- menu: _MenuState;
26
+ menu?: _MenuState;
27
27
  /**
28
28
  * @private this field is only to be used within elbe components.
29
29
  */
@@ -13,6 +13,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import { useMemo } from "react";
14
14
  import { _Box, } from "../../..";
15
15
  import { useApp } from "../../app/app_ctxt";
16
+ import { css } from "../../util/_util";
16
17
  import { WithTooltip } from "../tooltip";
17
18
  export function Card(_a) {
18
19
  var _b, _c;
@@ -22,11 +23,15 @@ export function Card(_a) {
22
23
  const isBordered = useMemo(() => {
23
24
  return (bordered !== null && bordered !== void 0 ? bordered : false) || theme.color.isContrast;
24
25
  }, [bordered, theme.color.isContrast]);
25
- return (_jsx(WithTooltip, { tooltip: elbe.tooltip, children: _jsx(_Box, { mode: mode, scheme: scheme, kind: kind, manner: manner, padding: padding, margin: margin, state: state, className: elbe.className, flex: elbe.flex, elevated: elevated, frosted: frosted, style: Object.assign({ overflow: overflow, borderRadius: sharp ? 0 : `${theme.geometry.radius}rem`, borderStyle: isBordered ? "solid" : undefined, borderWidth: isBordered
26
- ? `${theme.geometry.borderWidth}rem`
27
- : undefined, borderColor: isBordered
28
- ? "var(--elbe-context-color-border, transparent)"
29
- : undefined, opacity: onTap === null ? 0.5 : 1 }, ((_b = elbe.style) !== null && _b !== void 0 ? _b : {})), native: Object.assign(Object.assign(Object.assign({}, (onTap !== undefined
26
+ const styles = {
27
+ radius: sharp ? 0 : `${theme.geometry.radius}rem`,
28
+ borderStyle: isBordered ? "solid" : undefined,
29
+ borderWidth: isBordered ? `${theme.geometry.borderWidth}rem` : undefined,
30
+ borderColor: isBordered
31
+ ? "var(--elbe-context-color-border, transparent)"
32
+ : undefined,
33
+ };
34
+ return (_jsx(WithTooltip, { tooltip: elbe.tooltip, children: _jsx(_Box, { mode: mode, scheme: scheme, kind: kind, manner: manner, padding: padding, margin: margin, state: state, className: elbe.className, flex: elbe.flex, elevated: elevated, frosted: frosted, style: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ overflow: overflow }, css.borderRadius(styles.radius)), css.borderStyle(styles.borderStyle)), css.borderWidth(styles.borderWidth)), css.borderColor(styles.borderColor)), { opacity: onTap === null ? 0.5 : 1 }), ((_b = elbe.style) !== null && _b !== void 0 ? _b : {})), native: Object.assign(Object.assign(Object.assign({}, (onTap !== undefined
30
35
  ? {
31
36
  onClick: (e) => {
32
37
  e.preventDefault();
@@ -11,19 +11,13 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import { useApp } from "../../app/app_ctxt";
14
+ import { css } from "../../util/_util";
14
15
  import { _ElbeErr } from "../../util/error_view";
15
16
  import { applyProps } from "../base/box";
16
17
  import { Card } from "../base/card";
17
18
  export function Range(p) {
18
19
  var _a, _b;
19
- return ((_a = p.min) !== null && _a !== void 0 ? _a : 0) > ((_b = p.max) !== null && _b !== void 0 ? _b : 100) ? (_ElbeErr("Range: max is smaller than min")) : (_jsx(Card, { ariaLabel: null, scheme: "secondary", kind: "accent", manner: "minor", tooltip: p.tooltip, style: {
20
- overflow: "unset",
21
- backgroundColor: "transparent",
22
- padding: "0",
23
- margin: "0",
24
- borderStyle: "none",
25
- width: "100%",
26
- }, children: _jsx(_StyledRange, Object.assign({}, p)) }));
20
+ return ((_a = p.min) !== null && _a !== void 0 ? _a : 0) > ((_b = p.max) !== null && _b !== void 0 ? _b : 100) ? (_ElbeErr("Range: max is smaller than min")) : (_jsx(Card, { ariaLabel: null, scheme: "secondary", kind: "accent", manner: "minor", tooltip: p.tooltip, style: Object.assign({ overflow: "unset", backgroundColor: "transparent", padding: "0", margin: "0", width: "100%" }, css.borderStyle("none")), children: _jsx(_StyledRange, Object.assign({}, p)) }));
27
21
  }
28
22
  function _StyledRange(_a) {
29
23
  var _b, _c;
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { KindAlertIcon, Text } from "../../../..";
3
3
  import { useApp } from "../../../app/app_ctxt";
4
+ import { css } from "../../../util/_util";
4
5
  import { randomAlphaNum } from "../../../util/util";
5
6
  import { Card } from "../../base/card";
6
7
  import { Row } from "../../layout/flex";
@@ -54,12 +55,7 @@ function _Field(p) {
54
55
  : p.successMessage
55
56
  ? { kind: "success", msg: p.successMessage }
56
57
  : null;
57
- return (_jsx(LabeledInput, Object.assign({}, p, { id: id, disabled: !p.onInput, typeLabel: "text-field", manner: manner, children: _jsxs(Card, { className: "elbe-focussink", style: {
58
- display: "flex",
59
- flexDirection: "column",
60
- alignItems: "stretch",
61
- borderStyle: "none",
62
- }, kind: msg === null || msg === void 0 ? void 0 : msg.kind, padding: 0, manner: msg ? "major" : undefined, children: [_jsx(Card
58
+ return (_jsx(LabeledInput, Object.assign({}, p, { id: id, disabled: !p.onInput, typeLabel: "text-field", manner: manner, children: _jsxs(Card, { className: "elbe-focussink", style: Object.assign({ display: "flex", flexDirection: "column", alignItems: "stretch" }, css.borderStyle("none")), kind: msg === null || msg === void 0 ? void 0 : msg.kind, padding: 0, manner: msg ? "major" : undefined, children: [_jsx(Card
63
59
  // inner card for input only
64
60
  , {
65
61
  // inner card for input only
@@ -35,7 +35,8 @@ export function Header(p) {
35
35
  zIndex: 80,
36
36
  }, children: [p.leading && p.leading !== "back" && p.leading !== "close"
37
37
  ? p.leading
38
- : !layoutMode.isWide && (_jsx(IconButton.plain, { ariaLabel: "open/close menu", onTap: () => menu.setOpen(!menu.isOpen), icon: MenuIcon })), p.leading === "back" && _jsx(BackButton, {}), p.leading === "close" && _jsx(BackButton, { close: true }), !layoutMode.isMobile && (_jsx(_Logo, { logo: (_b = p.logo) !== null && _b !== void 0 ? _b : (_c = appConfig === null || appConfig === void 0 ? void 0 : appConfig.icons) === null || _c === void 0 ? void 0 : _c.logo, logoDark: (_d = p.logoDark) !== null && _d !== void 0 ? _d : (_e = appConfig === null || appConfig === void 0 ? void 0 : appConfig.icons) === null || _e === void 0 ? void 0 : _e.logoDark, lMargin: 0.5 })), (!appConfig || layoutMode.isWide) && (_jsx("div", { style: { margin: "-1rem", width: "1.5rem" } })), _jsx(_HeaderTitle, { title: p.title, center: (_f = p.centerTitle) !== null && _f !== void 0 ? _f : false }), _jsx(_Toolbar, { actions: [...((_g = p.actions) !== null && _g !== void 0 ? _g : []), ...((_h = appConfig === null || appConfig === void 0 ? void 0 : appConfig.globalActions) !== null && _h !== void 0 ? _h : [])] }), layoutMode.isWide && (_jsx(_Logo, { logo: (_j = p.endLogo) !== null && _j !== void 0 ? _j : (_k = appConfig === null || appConfig === void 0 ? void 0 : appConfig.icons) === null || _k === void 0 ? void 0 : _k.endLogo, logoDark: (_l = p.endLogoDark) !== null && _l !== void 0 ? _l : (_m = appConfig === null || appConfig === void 0 ? void 0 : appConfig.icons) === null || _m === void 0 ? void 0 : _m.endLogoDark, rMargin: 0.5 }))] }));
38
+ : !layoutMode.isWide &&
39
+ menu && (_jsx(IconButton.plain, { ariaLabel: "open/close menu", onTap: () => menu.setOpen(!menu.isOpen), icon: MenuIcon })), p.leading === "back" && _jsx(BackButton, {}), p.leading === "close" && _jsx(BackButton, { close: true }), !layoutMode.isMobile && (_jsx(_Logo, { logo: (_b = p.logo) !== null && _b !== void 0 ? _b : (_c = appConfig === null || appConfig === void 0 ? void 0 : appConfig.icons) === null || _c === void 0 ? void 0 : _c.logo, logoDark: (_d = p.logoDark) !== null && _d !== void 0 ? _d : (_e = appConfig === null || appConfig === void 0 ? void 0 : appConfig.icons) === null || _e === void 0 ? void 0 : _e.logoDark, lMargin: 0.5 })), (!appConfig || layoutMode.isWide) && (_jsx("div", { style: { margin: "-1rem", width: "1.5rem" } })), _jsx(_HeaderTitle, { title: p.title, center: (_f = p.centerTitle) !== null && _f !== void 0 ? _f : false }), _jsx(_Toolbar, { actions: [...((_g = p.actions) !== null && _g !== void 0 ? _g : []), ...((_h = appConfig === null || appConfig === void 0 ? void 0 : appConfig.globalActions) !== null && _h !== void 0 ? _h : [])] }), layoutMode.isWide && (_jsx(_Logo, { logo: (_j = p.endLogo) !== null && _j !== void 0 ? _j : (_k = appConfig === null || appConfig === void 0 ? void 0 : appConfig.icons) === null || _k === void 0 ? void 0 : _k.endLogo, logoDark: (_l = p.endLogoDark) !== null && _l !== void 0 ? _l : (_m = appConfig === null || appConfig === void 0 ? void 0 : appConfig.icons) === null || _m === void 0 ? void 0 : _m.endLogoDark, rMargin: 0.5 }))] }));
39
40
  }
40
41
  export function _Logo(p) {
41
42
  var _a, _b;
@@ -1,4 +1,4 @@
1
1
  import { MenuItem } from "../../..";
2
2
  export declare function Menu(p: {
3
3
  items: MenuItem[];
4
- }): import("react/jsx-runtime").JSX.Element;
4
+ }): import("react/jsx-runtime").JSX.Element | null;
@@ -30,6 +30,8 @@ export function Menu(p) {
30
30
  }
31
31
  return topBot;
32
32
  }, [p.items]);
33
+ if (!menu)
34
+ return null;
33
35
  return (_jsxs(_Fragment, { children: [layoutMode.isWide && (_jsx("div", { style: {
34
36
  width: menuWidth,
35
37
  minWidth: menuWidth,
@@ -44,6 +46,8 @@ function _Menu(p) {
44
46
  const { _appThemeContext, menu, appConfig } = useApp();
45
47
  const { theme } = _appThemeContext.useTheme();
46
48
  const layoutMode = useLayoutMode();
49
+ if (!menu)
50
+ return null;
47
51
  return (_jsx(Card, { onTap: () => {
48
52
  if (layoutMode.isWide)
49
53
  return;
@@ -73,6 +77,8 @@ function _Menu(p) {
73
77
  }
74
78
  function _MenuItemView({ item }) {
75
79
  const { menu, router } = useApp();
80
+ if (!menu)
81
+ return null;
76
82
  return (_jsx(Button
77
83
  //sharp
78
84
  , {
@@ -1 +1,8 @@
1
+ import React from "react";
1
2
  export declare function elevatedShadow(dark: boolean): string;
3
+ export declare namespace css {
4
+ function borderRadius(v: React.CSSProperties["borderTopLeftRadius"] | undefined): React.CSSProperties;
5
+ function borderStyle(v: React.CSSProperties["borderLeftStyle"] | undefined): React.CSSProperties;
6
+ function borderWidth(v: React.CSSProperties["borderLeftWidth"] | undefined): React.CSSProperties;
7
+ function borderColor(v: React.CSSProperties["borderLeftColor"] | undefined): React.CSSProperties;
8
+ }
@@ -1,3 +1,42 @@
1
1
  export function elevatedShadow(dark) {
2
2
  return `0px 0px .625rem -.125rem ${dark ? "#ffffff60" : "#00000060"}`;
3
3
  }
4
+ export var css;
5
+ (function (css) {
6
+ function borderRadius(v) {
7
+ return {
8
+ borderTopLeftRadius: v,
9
+ borderTopRightRadius: v,
10
+ borderBottomLeftRadius: v,
11
+ borderBottomRightRadius: v,
12
+ };
13
+ }
14
+ css.borderRadius = borderRadius;
15
+ function borderStyle(v) {
16
+ return {
17
+ borderLeftStyle: v,
18
+ borderRightStyle: v,
19
+ borderTopStyle: v,
20
+ borderBottomStyle: v,
21
+ };
22
+ }
23
+ css.borderStyle = borderStyle;
24
+ function borderWidth(v) {
25
+ return {
26
+ borderLeftWidth: v,
27
+ borderRightWidth: v,
28
+ borderTopWidth: v,
29
+ borderBottomWidth: v,
30
+ };
31
+ }
32
+ css.borderWidth = borderWidth;
33
+ function borderColor(v) {
34
+ return {
35
+ borderLeftColor: v,
36
+ borderRightColor: v,
37
+ borderTopColor: v,
38
+ borderBottomColor: v,
39
+ };
40
+ }
41
+ css.borderColor = borderColor;
42
+ })(css || (css = {}));
@@ -45,3 +45,10 @@ export declare function dictWithoutUndefined<T extends Dict<any>>(obj?: T): {
45
45
  [key in keyof T]: Exclude<T[key], undefined>;
46
46
  };
47
47
  export declare function hash(v: any): string;
48
+ /**
49
+ * get the content of a metatag by its name. A metatag is like:
50
+ * `<meta name="name" content="content">`
51
+ * @param name the name of the metatag
52
+ * @returns the content of the metatag or null if not found
53
+ */
54
+ export declare function metaTagContent(name: string): string | null;
@@ -141,3 +141,18 @@ export function hash(v) {
141
141
  }
142
142
  return hash.toString();
143
143
  }
144
+ /**
145
+ * get the content of a metatag by its name. A metatag is like:
146
+ * `<meta name="name" content="content">`
147
+ * @param name the name of the metatag
148
+ * @returns the content of the metatag or null if not found
149
+ */
150
+ export function metaTagContent(name) {
151
+ const metas = document.getElementsByTagName("meta");
152
+ for (let i = 0; i < metas.length; i++) {
153
+ if (metas[i].getAttribute("name") === name) {
154
+ return metas[i].getAttribute("content");
155
+ }
156
+ }
157
+ return null;
158
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "elbe-ui",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "author": "Robin Naumann",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -19,7 +19,7 @@
19
19
  "main": "dist/index.js",
20
20
  "types": "dist/index.d.ts",
21
21
  "scripts": {
22
- "build:ts": "tsc",
22
+ "build:ts": "bun i && tsc",
23
23
  "build:dts": "tsc --declaration",
24
24
  "build:css": "sass -q style/elbe-util.scss dist/elbe.css",
25
25
  "build": "rm -rf ./dist && bun run build:ts && bun run build:dts && bun run build:css ",
@@ -31,14 +31,14 @@
31
31
  "sass": "^1.97.0"
32
32
  },
33
33
  "peerDependencies": {
34
- "typescript": "^5.9.3"
34
+ "@types/react-dom": "^19.2.3",
35
+ "typescript": "^5.9.3",
36
+ "react": "^19.2.3",
37
+ "react-dom": "^19.2.3"
35
38
  },
36
39
  "dependencies": {
37
- "@types/react-dom": "^19.2.3",
38
40
  "colors-convert": "^1.4.1",
39
41
  "lucide-react": "^0.561.0",
40
- "react": "^19.2.3",
41
- "react-dom": "^19.2.3",
42
42
  "wouter": "^3.8.1"
43
43
  }
44
44
  }
File without changes
File without changes