elbe-ui 1.0.8 → 2.0.0

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 (141) hide show
  1. package/dist/elbe.css +150 -562
  2. package/dist/elbe.css.map +1 -1
  3. package/dist/index.d.ts +188 -46
  4. package/dist/index.js +8 -6
  5. package/dist/ui/app/app.d.ts +12 -0
  6. package/dist/ui/{components/layout/app_base.js → app/app.js} +24 -31
  7. package/dist/ui/app/app_ctxt.d.ts +35 -0
  8. package/dist/ui/app/app_ctxt.js +10 -0
  9. package/dist/ui/components/badge.d.ts +3 -3
  10. package/dist/ui/components/badge.js +16 -5
  11. package/dist/ui/components/banner.d.ts +3 -3
  12. package/dist/ui/components/banner.js +1 -1
  13. package/dist/ui/components/base/box.d.ts +82 -35
  14. package/dist/ui/components/base/box.js +56 -8
  15. package/dist/ui/components/base/card.d.ts +11 -12
  16. package/dist/ui/components/base/card.js +36 -19
  17. package/dist/ui/components/base/padded.d.ts +2 -4
  18. package/dist/ui/components/base/state_builder.d.ts +9 -0
  19. package/dist/ui/components/base/state_builder.js +33 -0
  20. package/dist/ui/components/button/button.d.ts +8 -6
  21. package/dist/ui/components/button/button.js +27 -16
  22. package/dist/ui/components/button/choose_button.d.ts +5 -3
  23. package/dist/ui/components/button/choose_button.js +9 -6
  24. package/dist/ui/components/button/icon_button.d.ts +6 -5
  25. package/dist/ui/components/button/icon_button.js +33 -23
  26. package/dist/ui/components/button/toggle_button.d.ts +5 -5
  27. package/dist/ui/components/button/toggle_button.js +13 -7
  28. package/dist/ui/components/dialog/dialog.d.ts +13 -0
  29. package/dist/ui/components/dialog/dialog.js +69 -0
  30. package/dist/ui/components/dialog/dialog_ctx.d.ts +34 -0
  31. package/dist/ui/components/dialog/dialog_ctx.js +44 -0
  32. package/dist/ui/components/dialog/dialogs/_alert.d.ts +7 -0
  33. package/dist/ui/components/dialog/dialogs/_alert.js +9 -0
  34. package/dist/ui/components/dialog/dialogs/_confirm.d.ts +9 -0
  35. package/dist/ui/components/dialog/dialogs/_confirm.js +21 -0
  36. package/dist/ui/components/error_view.js +3 -3
  37. package/dist/ui/components/footer.js +7 -7
  38. package/dist/ui/components/input/_labeled_input.d.ts +21 -0
  39. package/dist/ui/components/input/_labeled_input.js +21 -0
  40. package/dist/ui/components/input/checkbox.d.ts +4 -2
  41. package/dist/ui/components/input/checkbox.js +16 -8
  42. package/dist/ui/components/input/range.d.ts +5 -3
  43. package/dist/ui/components/input/range.js +20 -13
  44. package/dist/ui/components/input/select.d.ts +4 -3
  45. package/dist/ui/components/input/select.js +13 -40
  46. package/dist/ui/components/input/switch.d.ts +4 -2
  47. package/dist/ui/components/input/switch.js +30 -40
  48. package/dist/ui/components/input/text/input_field.d.ts +14 -19
  49. package/dist/ui/components/input/text/input_field.js +63 -61
  50. package/dist/ui/components/input/text/single_line.d.ts +11 -9
  51. package/dist/ui/components/input/text/single_line.js +15 -21
  52. package/dist/ui/components/layout/flex.d.ts +7 -3
  53. package/dist/ui/components/layout/flex.js +15 -12
  54. package/dist/ui/components/layout/header.d.ts +2 -2
  55. package/dist/ui/components/layout/header.js +25 -18
  56. package/dist/ui/components/layout/menu.js +74 -49
  57. package/dist/ui/components/layout/scroll.d.ts +1 -0
  58. package/dist/ui/components/layout/scroll.js +3 -1
  59. package/dist/ui/components/layout/toolbar.js +9 -6
  60. package/dist/ui/components/link.d.ts +4 -2
  61. package/dist/ui/components/link.js +24 -11
  62. package/dist/ui/components/progress_bar.d.ts +2 -2
  63. package/dist/ui/components/progress_bar.js +12 -9
  64. package/dist/ui/components/spinner.d.ts +2 -7
  65. package/dist/ui/components/spinner.js +15 -16
  66. package/dist/ui/components/text.d.ts +5 -6
  67. package/dist/ui/components/text.js +34 -21
  68. package/dist/ui/components/tooltip.d.ts +5 -0
  69. package/dist/ui/components/tooltip.js +48 -0
  70. package/dist/ui/theme/subthemes/_theme_geometry.d.ts +9 -0
  71. package/dist/ui/theme/subthemes/_theme_geometry.js +22 -0
  72. package/dist/ui/theme/subthemes/_theme_menu.d.ts +9 -0
  73. package/dist/ui/theme/subthemes/_theme_menu.js +12 -0
  74. package/dist/ui/theme/subthemes/_theme_motion.d.ts +9 -0
  75. package/dist/ui/theme/subthemes/_theme_motion.js +13 -0
  76. package/dist/ui/theme/subthemes/_theme_toast.d.ts +8 -0
  77. package/dist/ui/theme/subthemes/_theme_toast.js +11 -0
  78. package/dist/ui/theme/subthemes/_theme_type.d.ts +49 -0
  79. package/dist/ui/theme/subthemes/_theme_type.js +73 -0
  80. package/dist/ui/theme/subthemes/color/_seed.d.ts +2 -0
  81. package/dist/ui/theme/subthemes/color/_seed.js +105 -0
  82. package/dist/ui/theme/subthemes/color/_theme_color.d.ts +865 -0
  83. package/dist/ui/theme/subthemes/color/_theme_color.js +83 -0
  84. package/dist/ui/theme/subthemes/color/colors/_color_contrast.d.ts +284 -0
  85. package/dist/ui/theme/subthemes/color/colors/_color_contrast.js +17 -0
  86. package/dist/ui/theme/subthemes/color/colors/_color_kind.d.ts +242 -0
  87. package/dist/ui/theme/subthemes/color/colors/_color_kind.js +45 -0
  88. package/dist/ui/theme/subthemes/color/colors/_color_layer.d.ts +226 -0
  89. package/dist/ui/theme/subthemes/color/colors/_color_layer.js +95 -0
  90. package/dist/ui/theme/subthemes/color/colors/_color_manner.d.ts +280 -0
  91. package/dist/ui/theme/subthemes/color/colors/_color_manner.js +17 -0
  92. package/dist/ui/theme/subthemes/color/colors/_color_mode.d.ts +269 -0
  93. package/dist/ui/theme/subthemes/color/colors/_color_mode.js +16 -0
  94. package/dist/ui/theme/subthemes/color/colors/_color_rgba.d.ts +166 -0
  95. package/dist/ui/theme/subthemes/color/colors/_color_rgba.js +86 -0
  96. package/dist/ui/theme/subthemes/color/colors/_color_scheme.d.ts +256 -0
  97. package/dist/ui/theme/subthemes/color/colors/_color_scheme.js +17 -0
  98. package/dist/ui/theme/subthemes/color/colors/_color_state.d.ts +252 -0
  99. package/dist/ui/theme/subthemes/color/colors/_color_state.js +49 -0
  100. package/dist/ui/theme/subthemes/color/colors/_colordef.d.ts +22 -0
  101. package/dist/ui/theme/subthemes/color/colors/_colordef.js +34 -0
  102. package/dist/ui/theme/subthemes/color/colors/colors.d.ts +511 -0
  103. package/dist/ui/theme/subthemes/color/colors/colors.js +24 -0
  104. package/dist/ui/theme/theme.d.ts +984 -30
  105. package/dist/ui/theme/theme.js +14 -82
  106. package/dist/ui/theme/theme_context.d.ts +15 -17
  107. package/dist/ui/theme/theme_context.js +79 -18
  108. package/dist/ui/util/_util.d.ts +1 -0
  109. package/dist/ui/util/_util.js +3 -0
  110. package/dist/ui/util/error_view.js +3 -3
  111. package/dist/ui/util/merge_deep.d.ts +1 -0
  112. package/dist/ui/util/merge_deep.js +18 -0
  113. package/dist/ui/util/root.d.ts +17 -0
  114. package/dist/ui/util/root.js +23 -0
  115. package/dist/ui/util/toast/_toast.d.ts +5 -0
  116. package/dist/ui/util/toast/_toast.js +7 -0
  117. package/dist/ui/util/toast/toast_ctx.d.ts +28 -0
  118. package/dist/ui/util/toast/toast_ctx.js +62 -0
  119. package/dist/ui/util/toast/toast_legacy.d.ts +5 -0
  120. package/dist/ui/util/{toast.js → toast/toast_legacy.js} +4 -4
  121. package/dist/ui/util/util.d.ts +8 -0
  122. package/dist/ui/util/util.js +54 -1
  123. package/package.json +10 -8
  124. package/dist/ui/components/dialog.d.ts +0 -10
  125. package/dist/ui/components/dialog.js +0 -35
  126. package/dist/ui/components/layout/app_base.d.ts +0 -15
  127. package/dist/ui/components/layout/ctx_app_base.d.ts +0 -19
  128. package/dist/ui/components/layout/ctx_app_base.js +0 -12
  129. package/dist/ui/theme/color_theme.d.ts +0 -2
  130. package/dist/ui/theme/color_theme.js +0 -92
  131. package/dist/ui/theme/colors.d.ts +0 -133
  132. package/dist/ui/theme/colors.js +0 -309
  133. package/dist/ui/theme/geometry_theme.d.ts +0 -16
  134. package/dist/ui/theme/geometry_theme.js +0 -28
  135. package/dist/ui/theme/seed.d.ts +0 -53
  136. package/dist/ui/theme/seed.js +0 -4
  137. package/dist/ui/theme/type_theme.d.ts +0 -38
  138. package/dist/ui/theme/type_theme.js +0 -73
  139. package/dist/ui/util/confirm_dialog.d.ts +0 -10
  140. package/dist/ui/util/confirm_dialog.js +0 -46
  141. package/dist/ui/util/toast.d.ts +0 -5
package/dist/index.js CHANGED
@@ -4,14 +4,17 @@ import "./elbe.css";
4
4
  export * as Wouter from "wouter";
5
5
  export * as wouter_hash from "wouter/use-hash-location";
6
6
  // exports
7
+ export * from "./ui/util/root";
7
8
  export * from "./api/api_worker";
8
9
  export * from "./api/error";
9
10
  export * from "./api/errors";
10
11
  export * from "./bit/bit";
11
- export * from "./ui/util/confirm_dialog";
12
+ export * from "./ui/components/dialog/dialog";
13
+ export * from "./ui/components/dialog/dialog_ctx";
12
14
  export * from "./ui/util/ctx_toolbar";
13
15
  export * from "./ui/util/l10n/l10n";
14
- export * from "./ui/util/toast";
16
+ export * from "./ui/util/toast/toast_ctx";
17
+ export * from "./ui/util/toast/toast_legacy";
15
18
  export * from "./ui/util/types";
16
19
  export * from "./ui/util/util";
17
20
  export * from "./ui/components/base/box";
@@ -23,8 +26,6 @@ export * from "./ui/components/button/choose_button";
23
26
  export * from "./ui/components/button/icon_button";
24
27
  export * from "./ui/components/button/toggle_button";
25
28
  export * from "./ui/components/layout/alignment";
26
- export * from "./ui/components/layout/app_base";
27
- export * from "./ui/components/layout/ctx_app_base";
28
29
  export * from "./ui/components/layout/flex";
29
30
  export * from "./ui/components/layout/header";
30
31
  export * from "./ui/components/layout/page";
@@ -37,15 +38,16 @@ export * from "./ui/components/input/switch";
37
38
  export * from "./ui/components/input/text/input_field";
38
39
  export * from "./ui/components/badge";
39
40
  export * from "./ui/components/banner";
40
- export * from "./ui/components/dialog";
41
+ export * from "./ui/components/dialog/dialog";
41
42
  export * from "./ui/components/error_view";
42
43
  export * from "./ui/components/footer";
43
44
  export * from "./ui/components/link";
44
45
  export * from "./ui/components/progress_bar";
45
46
  export * from "./ui/components/spinner";
46
47
  export * from "./ui/components/text";
48
+ export * from "./ui/app/app";
47
49
  export * from "./ui/components/dev/todo";
48
- export * from "./ui/theme/seed";
50
+ export * from "./ui/theme/subthemes/color/colors/colors";
49
51
  export * from "./ui/theme/theme";
50
52
  export * from "./ui/theme/theme_context";
51
53
  function None({}) {
@@ -0,0 +1,12 @@
1
+ import { ElbeRoute, ElbeThemeContext } from "../..";
2
+ import { AppConfig } from "./app_ctxt";
3
+ type _AppThemeConfig = {
4
+ themeContext: ElbeThemeContext;
5
+ themeSeed?: Partial<Parameters<_AppThemeConfig["themeContext"]["WithTheme"]>[0]["seed"]>;
6
+ };
7
+ type _AppProps = AppConfig & _AppThemeConfig;
8
+ type AppProps = _AppProps & {
9
+ children: ElbeRoute | ElbeRoute[];
10
+ };
11
+ export declare function ElbeApp(p: AppProps): import("react/jsx-runtime").JSX.Element;
12
+ export {};
@@ -1,40 +1,29 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useMemo, useState } from "react";
3
- import { Box, isMenuRoute, Wouter, } from "../../..";
4
- import { AppBaseContext } from "./ctx_app_base";
5
- import { Menu } from "./menu";
6
- /**
7
- * app base is a layout component that provides an optional side menu and a content area.
8
- * it is designed to be used as a base for other components and is
9
- * used to create a consistent layout for pages. You can also pass global actions
10
- * that will be displayed in the header of all pages.
11
- *
12
- * Provide `wouter.Route` or `MenuRoute` components as children to define the routes and menu items.
13
- */
14
- export function AppBase(p) {
15
- return _jsx(Wouter.Router, { children: _jsx(_AppBase, Object.assign({}, p)) });
3
+ import { Box, DialogsProvider, isMenuRoute, omit, ToastProvider, Wouter, } from "../..";
4
+ import { Menu } from "../components/layout/menu";
5
+ import { AppContext } from "./app_ctxt";
6
+ export function ElbeApp(p) {
7
+ var _a;
8
+ useMemo(() => {
9
+ if (p.title)
10
+ document.title = p.title;
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 }) }) }));
16
13
  }
17
14
  function _initialLocation() {
18
15
  return (window.location.pathname + window.location.search + window.location.hash);
19
16
  }
20
- function _AppBase(p) {
21
- var _a;
22
- const [menuOpen, setMenuOpen] = useState(false);
17
+ function _App(p) {
23
18
  const menuItems = useMemo(() => {
24
19
  return _extractMenuItems(p.children);
25
20
  }, [p.children]);
26
21
  const [location, navigate] = Wouter.useLocation();
27
22
  const [history, setHistory] = useState([_initialLocation()]);
28
- return (_jsx(AppBaseContext.Provider, { value: {
29
- menuOpen: menuOpen,
30
- icons: {
31
- logo: p.logo,
32
- logoDark: p.logoDark,
33
- endLogo: p.endLogo,
34
- endLogoDark: p.endLogoDark,
35
- },
36
- globalActions: (_a = p.globalActions) !== null && _a !== void 0 ? _a : [],
37
- setMenuOpen: (b) => setMenuOpen(b),
23
+ const [menuOpen, setMenuOpen] = useState(false);
24
+ return (_jsx(AppContext.Provider, { value: {
25
+ appConfig: p.config,
26
+ _appThemeContext: p.themeContext,
38
27
  router: {
39
28
  goBack: (steps = 1) => {
40
29
  if (history.length === 0)
@@ -58,11 +47,15 @@ function _AppBase(p) {
58
47
  history: history,
59
48
  location: location,
60
49
  },
61
- }, children: _jsxs(Box, { typeLabel: "app_base", scheme: "primary", style: {
62
- display: "flex",
63
- width: "100%",
64
- minHeight: "100vh",
65
- }, children: [menuItems.length > 0 && _jsx(Menu, { items: menuItems }), _jsx("div", { style: { flex: 1, width: "0px" }, children: _jsx(Wouter.Switch, { children: p.children }) })] }) }));
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 }) })] }) }) }) }));
66
59
  }
67
60
  function _extractMenuItems(children) {
68
61
  const childs = Array.isArray(children) ? children : [children];
@@ -0,0 +1,35 @@
1
+ import { HeaderLogos } from "../components/layout/header";
2
+ import { ElbeThemeContext } from "../theme/theme_context";
3
+ import { ElbeChild, ElbeChildren, int } from "../util/types";
4
+ export type AppConfig = {
5
+ title?: string;
6
+ icons?: HeaderLogos;
7
+ globalActions?: ElbeChild[];
8
+ footer?: ElbeChildren | null;
9
+ routerConfig?: {
10
+ basePath?: string;
11
+ };
12
+ };
13
+ type _MenuState = {
14
+ isOpen: boolean;
15
+ setOpen: (s: boolean) => void;
16
+ };
17
+ type _RouterState = {
18
+ go: (path: string, replace?: int | "all") => void;
19
+ goBack: (steps?: number) => void;
20
+ history: string[];
21
+ location: string;
22
+ };
23
+ export interface AppState {
24
+ appConfig: AppConfig;
25
+ router: _RouterState;
26
+ menu: _MenuState;
27
+ /**
28
+ * @private this field is only to be used within elbe components.
29
+ */
30
+ _appThemeContext: ElbeThemeContext;
31
+ }
32
+ export declare const AppContext: import("react").Context<AppState | null>;
33
+ export declare function useApp(): AppState;
34
+ export declare function useMaybeApp(): AppState | null;
35
+ export {};
@@ -0,0 +1,10 @@
1
+ import { createContext, useContext } from "react";
2
+ import { throwError, tryOrNull } from "../util/util";
3
+ export const AppContext = createContext(null);
4
+ export function useApp() {
5
+ var _a;
6
+ return ((_a = tryOrNull(() => useContext(AppContext))) !== null && _a !== void 0 ? _a : throwError("useApp must be used within an ElbeApp context. try using useMaybeApp()"));
7
+ }
8
+ export function useMaybeApp() {
9
+ return tryOrNull(() => useContext(AppContext));
10
+ }
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import type { ElbeColorKinds } from "../theme/colors";
2
+ import { ColorSelection } from "../theme/subthemes/color/colors/colors";
3
3
  import type { ElbeChild, ElbeChildren } from "../util/types";
4
4
  import type { ElbeProps } from "./base/box";
5
5
  export type BadgeProps = {
@@ -11,10 +11,10 @@ export type BadgeProps = {
11
11
  } & ElbeProps;
12
12
  export declare function TestBadge(p: BadgeProps): Badge;
13
13
  export declare class Badge extends React.Component<BadgeProps & {
14
- kind: ElbeColorKinds;
14
+ kind: ColorSelection.Kinds;
15
15
  }> {
16
16
  constructor(props: BadgeProps & {
17
- kind: ElbeColorKinds;
17
+ kind: ColorSelection.Kinds;
18
18
  });
19
19
  static accent(p: BadgeProps): import("react/jsx-runtime").JSX.Element;
20
20
  static error(p: BadgeProps): import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import React from "react";
3
+ import { useApp } from "../app/app_ctxt";
3
4
  export function TestBadge(p) {
4
5
  return new Badge(Object.assign(Object.assign({}, p), { kind: "accent" }));
5
6
  }
@@ -23,10 +24,20 @@ export class Badge extends React.Component {
23
24
  return _jsx(Badge, Object.assign({}, p, { kind: "info" }));
24
25
  }
25
26
  render() {
26
- var _a, _b;
27
- return (_jsxs("div", { style: {
28
- position: "relative",
29
- display: "inline-block",
30
- }, children: [this.props.child, this.props.children, _jsx("div", { className: `b ${this.props.kind} major ${(_a = this.props.className) !== null && _a !== void 0 ? _a : ""}`, style: Object.assign({ position: "absolute", top: "-0.25rem", right: "-0.25rem", minWidth: "1.5rem", minHeight: "1.5rem", padding: "0rem .4rem", borderRadius: "3rem", fontWeight: "bold", display: "flex", justifyContent: "center", alignItems: "center", visibility: this.props.hidden ? "hidden" : "visible" }, this.props.style), children: (_b = this.props.label) !== null && _b !== void 0 ? _b : this.props.count })] }));
27
+ return _jsx(_Badge, Object.assign({}, this.props));
31
28
  }
32
29
  }
30
+ function _Badge(p) {
31
+ var _a;
32
+ const { _appThemeContext } = useApp();
33
+ const theme = _appThemeContext.useTheme().useWith(({ color }) => {
34
+ var _a;
35
+ return ({
36
+ color: Object.assign(Object.assign({}, color), { selection: Object.assign(Object.assign({}, color.selection), { kind: (_a = p.kind) !== null && _a !== void 0 ? _a : "accent", manner: "major" }) }),
37
+ });
38
+ }, [p.kind]);
39
+ return (_jsxs("div", { style: {
40
+ position: "relative",
41
+ display: "inline-block",
42
+ }, children: [p.child, p.children, _jsx("div", { style: Object.assign({ position: "absolute", top: "-0.25rem", right: "-0.25rem", minWidth: "1.5rem", minHeight: "1.5rem", padding: "0rem .4rem", borderRadius: "3rem", fontWeight: "bold", display: "flex", justifyContent: "center", alignItems: "center", visibility: p.hidden ? "hidden" : "visible", backgroundColor: theme.theme.color.currentColor.back.asCss(), color: theme.theme.color.currentColor.front.asCss() }, p.style), children: (_a = p.label) !== null && _a !== void 0 ? _a : p.count })] }));
43
+ }
@@ -1,10 +1,10 @@
1
- import { ElbeAlertKinds, IconChild } from "../..";
1
+ import { ColorSelection, IconChild } from "../..";
2
2
  export declare function KindAlertIcon({ kind, size, }: {
3
- kind: ElbeAlertKinds;
3
+ kind: ColorSelection.KindsAlert;
4
4
  size?: "body-s" | "body-m" | "body-l";
5
5
  }): import("react/jsx-runtime").JSX.Element;
6
6
  export declare function Banner({ kind, manner, title, onDismiss, dismissIcon, children, }: {
7
- kind: ElbeAlertKinds;
7
+ kind: ColorSelection.KindsAlert;
8
8
  manner?: "major" | "minor";
9
9
  title?: string;
10
10
  onDismiss?: () => void;
@@ -19,5 +19,5 @@ export function KindAlertIcon({ kind, size = "body-m", }) {
19
19
  return _jsx(Icon, { size: `${scale * 1.5}rem` });
20
20
  }
21
21
  export function Banner({ kind, manner = "major", title, onDismiss, dismissIcon = XIcon, children, }) {
22
- return (_jsx(Card, { kind: kind, manner: manner, padding: 0, children: _jsxs(Row, { cross: "start", gap: 0, children: [_jsx(Align, { size: 3, children: _jsx(KindAlertIcon, { kind: kind }) }), _jsxs(Column, { gap: 0.5, className: "flex-1", style: { padding: ".9rem 0", paddingRight: onDismiss ? "0" : "1rem" }, children: [title && _jsx(Text, { bold: true, v: title }), children] }), onDismiss && (_jsx(IconButton, { manner: manner, kind: kind, transparent: manner === "minor", ariaLabel: "close", icon: dismissIcon, onTap: onDismiss }))] }) }));
22
+ return (_jsx(Card, { kind: kind, manner: manner, padding: 0, children: _jsxs(Row, { cross: "start", gap: 0, children: [_jsx(Align, { size: 3, children: _jsx(KindAlertIcon, { kind: kind }) }), _jsxs(Column, { gap: 0.5, flex: true, style: { padding: ".9rem 0", paddingRight: onDismiss ? "0" : "1rem" }, children: [title && _jsx(Text, { bold: true, v: title }), children] }), onDismiss && (_jsx(IconButton, { manner: manner, kind: kind, transparent: manner === "minor", ariaLabel: "close", icon: dismissIcon, onTap: onDismiss }))] }) }));
23
23
  }
@@ -1,54 +1,101 @@
1
1
  import { Component } from "react";
2
- import { ElbeChildren, ElbeColorModes, ElbeColorSchemes } from "../../..";
2
+ import { ColorSelection, ElbeChildren } from "../../..";
3
3
  import { AriaRoles } from "./roles";
4
+ export declare const styleColorFromContext: React.CSSProperties;
5
+ export declare const styleBorderFromContext: React.CSSProperties;
4
6
  export type ElbeProps = {
5
7
  id?: string;
6
- className?: string;
7
- style?: React.CSSProperties;
8
8
  tooltip?: string;
9
9
  flex?: boolean | number;
10
10
  typeLabel?: string;
11
11
  ariaLabel?: string | null;
12
12
  role?: AriaRoles | null;
13
- onKeyDown?: (e: React.KeyboardEvent) => void;
14
- onKeyUp?: (e: React.KeyboardEvent) => void;
15
- onClick?: (e: React.MouseEvent) => void;
16
- onContextMenu?: (e: React.MouseEvent) => void;
17
- onDoubleClick?: (e: React.MouseEvent) => void;
18
- onMouseDown?: (e: React.MouseEvent) => void;
19
- onMouseUp?: (e: React.MouseEvent) => void;
20
- onMouseEnter?: (e: React.MouseEvent) => void;
21
- onMouseLeave?: (e: React.MouseEvent) => void;
22
- onFocus?: (e: React.FocusEvent) => void;
23
- onBlur?: (e: React.FocusEvent) => void;
24
- tabIndex?: number;
25
- autoFocus?: boolean;
13
+ style?: React.CSSProperties;
14
+ className?: string | string[];
15
+ native?: {
16
+ onKeyDown?: (e: React.KeyboardEvent) => void;
17
+ onKeyUp?: (e: React.KeyboardEvent) => void;
18
+ onClick?: (e: React.MouseEvent) => void;
19
+ onContextMenu?: (e: React.MouseEvent) => void;
20
+ onDoubleClick?: (e: React.MouseEvent) => void;
21
+ onMouseDown?: (e: React.MouseEvent) => void;
22
+ onMouseUp?: (e: React.MouseEvent) => void;
23
+ onMouseEnter?: (e: React.MouseEvent) => void;
24
+ onMouseLeave?: (e: React.MouseEvent) => void;
25
+ onFocus?: (e: React.FocusEvent) => void;
26
+ onBlur?: (e: React.FocusEvent) => void;
27
+ tabIndex?: number;
28
+ autoFocus?: boolean;
29
+ };
26
30
  };
27
- export type ActionElbeProps = ElbeProps & {
31
+ export type ElbeActionProps = ElbeProps & {
28
32
  ariaLabel: string | null;
29
33
  };
34
+ export type ElbeStyleProps = {
35
+ style?: React.CSSProperties;
36
+ };
37
+ export type ElbeChildrenProps = {
38
+ children?: ElbeChildren;
39
+ };
30
40
  export declare function applyProps(typeLabel: string, p: ElbeProps, classes?: string | null | (string | false | null | undefined)[], style?: React.CSSProperties): {
31
41
  [key: string]: any;
32
42
  };
33
- export type ElbeBoxProps = {
34
- mode?: ElbeColorModes;
43
+ export type ElbeBoxProps = ElbeProps & ElbeStyleProps & ElbeChildrenProps & {
44
+ mode?: ColorSelection.Modes;
45
+ kind?: ColorSelection.Kinds;
46
+ manner?: ColorSelection.Manners;
47
+ state?: ColorSelection.States;
35
48
  padding?: number;
36
49
  margin?: number;
37
- children: ElbeChildren;
38
- } & ElbeProps;
39
- export declare class Box extends Component<ElbeBoxProps & {
40
- scheme: ElbeColorSchemes;
50
+ frosted?: boolean;
51
+ elevated?: boolean;
52
+ };
53
+ export declare class Box extends Component<ElbeBoxProps & ElbeStyleProps & {
54
+ scheme?: ColorSelection.Schemes;
41
55
  }> {
42
- static primary: (p: ElbeBoxProps) => import("react").DetailedReactHTMLElement<{
43
- [key: string]: any;
44
- }, HTMLElement>;
45
- static secondary: (p: ElbeBoxProps) => import("react").DetailedReactHTMLElement<{
46
- [key: string]: any;
47
- }, HTMLElement>;
48
- static inverse: (p: ElbeBoxProps) => import("react").DetailedReactHTMLElement<{
49
- [key: string]: any;
50
- }, HTMLElement>;
51
- render(): import("react").DetailedReactHTMLElement<{
52
- [key: string]: any;
53
- }, HTMLElement>;
56
+ static primary: (p: ElbeBoxProps) => import("react").CElement<ElbeProps & ElbeStyleProps & ElbeChildrenProps & {
57
+ mode?: ColorSelection.Modes;
58
+ kind?: ColorSelection.Kinds;
59
+ manner?: ColorSelection.Manners;
60
+ state?: ColorSelection.States;
61
+ padding?: number;
62
+ margin?: number;
63
+ frosted?: boolean;
64
+ elevated?: boolean;
65
+ } & {
66
+ scheme?: ColorSelection.Schemes;
67
+ }, Box>;
68
+ static secondary: (p: ElbeBoxProps) => import("react").CElement<ElbeProps & ElbeStyleProps & ElbeChildrenProps & {
69
+ mode?: ColorSelection.Modes;
70
+ kind?: ColorSelection.Kinds;
71
+ manner?: ColorSelection.Manners;
72
+ state?: ColorSelection.States;
73
+ padding?: number;
74
+ margin?: number;
75
+ frosted?: boolean;
76
+ elevated?: boolean;
77
+ } & {
78
+ scheme?: ColorSelection.Schemes;
79
+ }, Box>;
80
+ static inverse: (p: ElbeBoxProps) => import("react").CElement<ElbeProps & ElbeStyleProps & ElbeChildrenProps & {
81
+ mode?: ColorSelection.Modes;
82
+ kind?: ColorSelection.Kinds;
83
+ manner?: ColorSelection.Manners;
84
+ state?: ColorSelection.States;
85
+ padding?: number;
86
+ margin?: number;
87
+ frosted?: boolean;
88
+ elevated?: boolean;
89
+ } & {
90
+ scheme?: ColorSelection.Schemes;
91
+ }, Box>;
92
+ render(): import("react/jsx-runtime").JSX.Element;
54
93
  }
94
+ /**
95
+ * @private
96
+ * @param p
97
+ * @returns
98
+ */
99
+ export declare function _Box(p: ElbeBoxProps & {
100
+ scheme?: ColorSelection.Schemes;
101
+ }): import("react/jsx-runtime").JSX.Element;
@@ -9,23 +9,71 @@ var __rest = (this && this.__rest) || function (s, e) {
9
9
  }
10
10
  return t;
11
11
  };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
12
13
  import { Component, createElement } from "react";
14
+ import { useApp } from "../../app/app_ctxt";
15
+ import { elevatedShadow } from "../../util/_util";
16
+ export const styleColorFromContext = {
17
+ backgroundColor: "var(--elbe-context-color-back)",
18
+ color: "var(--elbe-context-color-front)",
19
+ borderColor: "var(--elbe-context-color-border)",
20
+ };
21
+ export const styleBorderFromContext = {
22
+ borderTopColor: "var(--elbe-context-color-border)",
23
+ borderRightColor: "var(--elbe-context-color-border)",
24
+ borderBottomColor: "var(--elbe-context-color-border)",
25
+ borderLeftColor: "var(--elbe-context-color-border)",
26
+ borderTopStyle: "solid",
27
+ borderRightStyle: "solid",
28
+ borderBottomStyle: "solid",
29
+ borderLeftStyle: "solid",
30
+ borderTopWidth: "var(--elbe-context-geometry-border-width)",
31
+ borderRightWidth: "var(--elbe-context-geometry-border-width)",
32
+ borderBottomWidth: "var(--elbe-context-geometry-border-width)",
33
+ borderLeftWidth: "var(--elbe-context-geometry-border-width)",
34
+ borderRadius: "var(--elbe-context-geometry-border-radius)",
35
+ };
13
36
  export function applyProps(typeLabel, p, classes, style) {
14
- var _a, _b, _c, _d;
37
+ var _a, _b, _c, _d, _e, _f;
38
+ const eNonNative = Object.assign(Object.assign({}, p), { native: undefined });
39
+ const eNative = (_a = p.native) !== null && _a !== void 0 ? _a : {};
15
40
  if (Array.isArray(classes)) {
16
41
  classes = classes.filter((c) => c).join(" ");
17
42
  }
18
- const args = Object.assign(Object.assign({ id: p.id, onKeyDown: p.onKeyDown, onKeyUp: p.onKeyUp, onClick: p.onClick, onContextMenu: p.onContextMenu, onDoubleClick: p.onDoubleClick, onMouseDown: p.onMouseDown, onMouseUp: p.onMouseUp, onMouseEnter: p.onMouseEnter, onMouseLeave: p.onMouseLeave, onFocus: p.onFocus, onBlur: p.onBlur, tabIndex: p.tabIndex, autoFocus: p.autoFocus, role: (_a = p.role) !== null && _a !== void 0 ? _a : undefined, className: `${classes || ""} ${p.className || ""}`, style: Object.assign(Object.assign(Object.assign({}, (style !== null && style !== void 0 ? style : {})), ((_b = p.style) !== null && _b !== void 0 ? _b : {})), (p.flex ? { flex: p.flex === true ? 1 : p.flex } : {})) }, (p.tooltip ? { ["data-tooltip"]: p.tooltip } : {})), { ["aria-label"]: (_c = p.ariaLabel) !== null && _c !== void 0 ? _c : undefined,
43
+ const args = Object.assign(Object.assign(Object.assign(Object.assign({ id: eNonNative.id }, eNative), { role: (_b = eNonNative.role) !== null && _b !== void 0 ? _b : undefined, className: `${classes || ""} ${(_c = eNonNative === null || eNonNative === void 0 ? void 0 : eNonNative.className) !== null && _c !== void 0 ? _c : ""}`, style: Object.assign(Object.assign(Object.assign({}, (style !== null && style !== void 0 ? style : {})), ((_d = eNonNative === null || eNonNative === void 0 ? void 0 : eNonNative.style) !== null && _d !== void 0 ? _d : {})), (eNonNative.flex
44
+ ? { flex: eNonNative.flex === true ? 1 : eNonNative.flex }
45
+ : {})) }), (eNonNative.tooltip ? { ["data-tooltip"]: eNonNative.tooltip } : {})), { ["aria-label"]: (_e = eNonNative.ariaLabel) !== null && _e !== void 0 ? _e : undefined,
19
46
  //@ts-ignore
20
- ["data-type"]: (_d = p.typeLabel) !== null && _d !== void 0 ? _d : (!!typeLabel ? `elbe_${typeLabel}` : undefined) });
47
+ ["data-type"]: (_f = eNonNative.typeLabel) !== null && _f !== void 0 ? _f : (!!typeLabel ? `elbe_${typeLabel}` : undefined) });
21
48
  return args;
22
49
  }
23
50
  export class Box extends Component {
24
51
  render() {
25
- const _a = this.props, { scheme, mode, padding, margin, children } = _a, elbe = __rest(_a, ["scheme", "mode", "padding", "margin", "children"]);
26
- return createElement("div", applyProps("box", elbe, [scheme, mode], Object.assign({ padding: `${padding}rem`, margin: `${margin}rem` }, elbe.style)), children);
52
+ return _jsx(_Box, Object.assign({}, this.props));
27
53
  }
28
54
  }
29
- Box.primary = (p) => new Box(Object.assign(Object.assign({}, p), { scheme: "primary" })).render();
30
- Box.secondary = (p) => new Box(Object.assign(Object.assign({}, p), { scheme: "secondary" })).render();
31
- Box.inverse = (p) => new Box(Object.assign(Object.assign({}, p), { scheme: "inverse" })).render();
55
+ Box.primary = (p) => createElement(Box, Object.assign(Object.assign({}, p), { scheme: "primary" }));
56
+ Box.secondary = (p) => createElement(Box, Object.assign(Object.assign({}, p), { scheme: "secondary" }));
57
+ Box.inverse = (p) => createElement(Box, Object.assign(Object.assign({}, p), { scheme: "inverse" }));
58
+ /**
59
+ * @private
60
+ * @param p
61
+ * @returns
62
+ */
63
+ export function _Box(p) {
64
+ const { _appThemeContext } = useApp();
65
+ const usedTheme = _appThemeContext.useTheme().useWith(({ color }) => {
66
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
67
+ return {
68
+ color: Object.assign(Object.assign({}, color), { selection: Object.assign(Object.assign({}, color.selection), { scheme: (_b = (_a = p.scheme) !== null && _a !== void 0 ? _a : color.selection.scheme) !== null && _b !== void 0 ? _b : "primary", mode: (_d = (_c = p.mode) !== null && _c !== void 0 ? _c : color.selection.mode) !== null && _d !== void 0 ? _d : "light", kind: (_f = (_e = p.kind) !== null && _e !== void 0 ? _e : color.selection.kind) !== null && _f !== void 0 ? _f : "plain", manner: (_h = (_g = p.manner) !== null && _g !== void 0 ? _g : color.selection.manner) !== null && _h !== void 0 ? _h : "plain", state: (_k = (_j = p.state) !== null && _j !== void 0 ? _j : color.selection.state) !== null && _k !== void 0 ? _k : "neutral" }) }),
69
+ };
70
+ }, [p.scheme, p.mode, p.kind, p.manner, p.state]);
71
+ const { scheme, mode, padding, margin, frosted, elevated, children } = p, elbe = __rest(p, ["scheme", "mode", "padding", "margin", "frosted", "elevated", "children"]);
72
+ return (_jsx(_appThemeContext.WithTheme, { theme: usedTheme, children: _jsx("div", Object.assign({}, applyProps("box", elbe, [], Object.assign({ padding: `${padding}rem`, margin: `${margin}rem`, backgroundColor: frosted
73
+ ? usedTheme.theme.color.currentColor.back.withAlpha(0.4).asCss()
74
+ : usedTheme.theme.color.currentColor.back.asCss(), boxShadow: elevated
75
+ ? elevatedShadow(usedTheme.theme.color.isDark)
76
+ : undefined, backdropFilter: frosted ? "blur(.5rem)" : undefined, transition: usedTheme.theme.motion.reduced
77
+ ? undefined
78
+ : "background 0.3s ease" }, elbe.style)), { children: children })) }));
79
+ }
@@ -1,19 +1,18 @@
1
- import { ElbeChildren, ElbeColorKinds, ElbeColorManners, ElbeColorModes, ElbeColorSchemes, ElbeProps } from "../../..";
2
- export declare const elevatedShadow = "0 0 15px rgba(0,0,0,.2)";
3
- export declare function Card({ mode, scheme, kind, manner, padding, margin, onTap, onLongTap, frosted, bordered, elevated, sharp, disabled, overflow, children, ...elbe }: {
4
- mode?: ElbeColorModes;
5
- scheme?: ElbeColorSchemes;
6
- kind?: ElbeColorKinds;
7
- manner?: ElbeColorManners;
1
+ import { ColorSelection, ElbeChildren, ElbeChildrenProps, ElbeProps, ElbeStyleProps } from "../../..";
2
+ export declare function Card({ mode, scheme, kind, manner, state, padding, margin, onTap, onLongTap, frosted, bordered, elevated, sharp, overflow, children, ...elbe }: {
3
+ mode?: ColorSelection.Modes;
4
+ scheme?: ColorSelection.Schemes;
5
+ kind?: ColorSelection.Kinds;
6
+ manner?: ColorSelection.Manners;
7
+ state?: ColorSelection.States;
8
8
  padding?: number;
9
9
  margin?: number;
10
- onTap?: () => void;
11
- onLongTap?: () => void;
10
+ onTap?: (() => void) | null;
11
+ onLongTap?: (() => void) | null;
12
12
  frosted?: boolean;
13
13
  elevated?: boolean;
14
14
  bordered?: boolean;
15
15
  sharp?: boolean;
16
- disabled?: boolean;
17
- overflow?: "hidden" | "scroll" | "auto";
16
+ overflow?: "auto" | "hidden" | "scroll";
18
17
  children?: ElbeChildren;
19
- } & ElbeProps): import("react/jsx-runtime").JSX.Element;
18
+ } & ElbeProps & ElbeStyleProps & ElbeChildrenProps): import("react/jsx-runtime").JSX.Element;
@@ -10,24 +10,41 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
- import { applyProps, } from "../../..";
14
- export const elevatedShadow = "0 0 15px rgba(0,0,0,.2)";
13
+ import { useMemo } from "react";
14
+ import { _Box, } from "../../..";
15
+ import { useApp } from "../../app/app_ctxt";
16
+ import { WithTooltip } from "../tooltip";
15
17
  export function Card(_a) {
16
- var { mode, scheme = "primary", kind, manner, padding = 1, margin = 0, onTap, onLongTap, frosted, bordered, elevated, sharp, disabled, overflow, children } = _a, elbe = __rest(_a, ["mode", "scheme", "kind", "manner", "padding", "margin", "onTap", "onLongTap", "frosted", "bordered", "elevated", "sharp", "disabled", "overflow", "children"]);
17
- return (_jsx("div", Object.assign({}, applyProps("card", elbe, [
18
- "card",
19
- mode,
20
- scheme,
21
- kind,
22
- manner,
23
- frosted && "frosted",
24
- bordered && "bordered",
25
- sharp && "sharp",
26
- disabled && "disabled",
27
- ], {
28
- padding: `${padding}rem`,
29
- margin: `${margin}rem`,
30
- overflow: overflow,
31
- boxShadow: elevated ? elevatedShadow : undefined,
32
- }), { onClick: onTap, onContextMenu: onLongTap, children: children })));
18
+ var _b, _c;
19
+ var { mode, scheme, kind, manner, state, padding = 1, margin = 0, onTap, onLongTap, frosted, bordered, elevated, sharp, overflow, children } = _a, elbe = __rest(_a, ["mode", "scheme", "kind", "manner", "state", "padding", "margin", "onTap", "onLongTap", "frosted", "bordered", "elevated", "sharp", "overflow", "children"]);
20
+ const { _appThemeContext } = useApp();
21
+ const { theme } = _appThemeContext.useTheme();
22
+ const isBordered = useMemo(() => {
23
+ return (bordered !== null && bordered !== void 0 ? bordered : false) || theme.color.isContrast;
24
+ }, [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
30
+ ? {
31
+ onClick: (e) => {
32
+ e.preventDefault();
33
+ e.stopPropagation();
34
+ if (onTap === null)
35
+ return;
36
+ onTap === null || onTap === void 0 ? void 0 : onTap();
37
+ },
38
+ }
39
+ : {})), (onLongTap !== undefined
40
+ ? {
41
+ onContextMenu: (e) => {
42
+ e.preventDefault();
43
+ e.stopPropagation();
44
+ if (onLongTap === null)
45
+ return;
46
+ onLongTap === null || onLongTap === void 0 ? void 0 : onLongTap();
47
+ },
48
+ }
49
+ : {})), ((_c = elbe.native) !== null && _c !== void 0 ? _c : {})), children: children }) }));
33
50
  }
@@ -1,8 +1,6 @@
1
1
  import React from "react";
2
- import { ElbeProps } from "./box";
3
- export type PaddedProps = ElbeProps & {
4
- children: any;
5
- };
2
+ import { ElbeChildrenProps, ElbeProps } from "./box";
3
+ export type PaddedProps = ElbeProps & ElbeChildrenProps;
6
4
  export declare class Padded extends React.Component<PaddedProps & {
7
5
  top?: number;
8
6
  right?: number;
@@ -0,0 +1,9 @@
1
+ import { ColorSelection } from "../../theme/subthemes/color/colors/colors";
2
+ import { ElbeThemeContextData } from "../../theme/theme";
3
+ import { ElbeChildren } from "../../util/types";
4
+ export declare function WithStateTheme(p: {
5
+ theme: ElbeThemeContextData<{}>;
6
+ manner?: Exclude<ColorSelection.Manners, "major" | "minor">;
7
+ disabled?: boolean;
8
+ children: ElbeChildren;
9
+ }): import("react/jsx-runtime").JSX.Element;