elbe-ui 0.4.0 → 0.4.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.
package/dist/index.d.ts CHANGED
@@ -4,7 +4,9 @@ export * from "./bit/ctrl_bit";
4
4
  export * from "./service/s_api";
5
5
  export * from "./ui/util/confirm_dialog";
6
6
  export * from "./ui/util/ctx_toolbar";
7
+ export * from "./ui/util/l10n/l10n";
7
8
  export * from "./ui/util/toast";
9
+ export * from "./ui/util/types";
8
10
  export * from "./ui/util/util";
9
11
  export * from "./ui/components/base/box";
10
12
  export * from "./ui/components/base/card";
package/dist/index.js CHANGED
@@ -7,7 +7,9 @@ export * from "./bit/ctrl_bit";
7
7
  export * from "./service/s_api";
8
8
  export * from "./ui/util/confirm_dialog";
9
9
  export * from "./ui/util/ctx_toolbar";
10
+ export * from "./ui/util/l10n/l10n";
10
11
  export * from "./ui/util/toast";
12
+ export * from "./ui/util/types";
11
13
  export * from "./ui/util/util";
12
14
  export * from "./ui/components/base/box";
13
15
  export * from "./ui/components/base/card";
@@ -1,6 +1,6 @@
1
1
  import React from "preact/compat";
2
2
  import type { ElbeColorKinds } from "../theme/colors";
3
- import type { ElbeChild, ElbeChildren } from "../util/util";
3
+ import type { ElbeChild, ElbeChildren } from "../util/types";
4
4
  import type { ElbeProps } from "./base/box";
5
5
  export type BadgeProps = {
6
6
  count?: number;
@@ -1,6 +1,5 @@
1
1
  import { Component } from "preact";
2
- import type { ElbeColorModes, ElbeColorSchemes } from "../../theme/colors";
3
- import type { ElbeChildren } from "../../util/util";
2
+ import { ElbeChildren, ElbeColorModes, ElbeColorSchemes } from "../../..";
4
3
  import { AriaRoles } from "./roles";
5
4
  export type ElbeProps = {
6
5
  id?: string;
@@ -26,12 +25,6 @@ export declare function applyProps(typeLabel: string, p: ElbeProps, classes?: st
26
25
  flex?: string | number | null | undefined;
27
26
  cssText?: string | null;
28
27
  [Symbol.iterator]?: string | number | null | undefined;
29
- clipPath?: string | number | null | undefined;
30
- filter?: string | number | null | undefined;
31
- marker?: string | number | null | undefined;
32
- mask?: string | number | null | undefined;
33
- font?: string | number | null | undefined;
34
- resize?: string | number | null | undefined;
35
28
  border?: string | number | null | undefined;
36
29
  accentColor?: string | number | null | undefined;
37
30
  alignContent?: string | number | null | undefined;
@@ -138,6 +131,7 @@ export declare function applyProps(typeLabel: string, p: ElbeProps, classes?: st
138
131
  caretColor?: string | number | null | undefined;
139
132
  clear?: string | number | null | undefined;
140
133
  clip?: string | number | null | undefined;
134
+ clipPath?: string | number | null | undefined;
141
135
  clipRule?: string | number | null | undefined;
142
136
  color?: string | number | null | undefined;
143
137
  colorInterpolation?: string | number | null | undefined;
@@ -179,6 +173,7 @@ export declare function applyProps(typeLabel: string, p: ElbeProps, classes?: st
179
173
  fill?: string | number | null | undefined;
180
174
  fillOpacity?: string | number | null | undefined;
181
175
  fillRule?: string | number | null | undefined;
176
+ filter?: string | number | null | undefined;
182
177
  flexBasis?: string | number | null | undefined;
183
178
  flexDirection?: string | number | null | undefined;
184
179
  flexFlow?: string | number | null | undefined;
@@ -188,6 +183,7 @@ export declare function applyProps(typeLabel: string, p: ElbeProps, classes?: st
188
183
  float?: string | number | null | undefined;
189
184
  floodColor?: string | number | null | undefined;
190
185
  floodOpacity?: string | number | null | undefined;
186
+ font?: string | number | null | undefined;
191
187
  fontFamily?: string | number | null | undefined;
192
188
  fontFeatureSettings?: string | number | null | undefined;
193
189
  fontKerning?: string | number | null | undefined;
@@ -268,9 +264,11 @@ export declare function applyProps(typeLabel: string, p: ElbeProps, classes?: st
268
264
  marginLeft?: string | number | null | undefined;
269
265
  marginRight?: string | number | null | undefined;
270
266
  marginTop?: string | number | null | undefined;
267
+ marker?: string | number | null | undefined;
271
268
  markerEnd?: string | number | null | undefined;
272
269
  markerMid?: string | number | null | undefined;
273
270
  markerStart?: string | number | null | undefined;
271
+ mask?: string | number | null | undefined;
274
272
  maskClip?: string | number | null | undefined;
275
273
  maskComposite?: string | number | null | undefined;
276
274
  maskImage?: string | number | null | undefined;
@@ -345,6 +343,7 @@ export declare function applyProps(typeLabel: string, p: ElbeProps, classes?: st
345
343
  printColorAdjust?: string | number | null | undefined;
346
344
  quotes?: string | number | null | undefined;
347
345
  r?: string | number | null | undefined;
346
+ resize?: string | number | null | undefined;
348
347
  right?: string | number | null | undefined;
349
348
  rotate?: string | number | null | undefined;
350
349
  rowGap?: string | number | null | undefined;
@@ -545,12 +544,6 @@ export declare class Box extends Component<ElbeBoxProps & {
545
544
  flex?: string | number | null | undefined;
546
545
  cssText?: string | null;
547
546
  [Symbol.iterator]?: string | number | null | undefined;
548
- clipPath?: string | number | null | undefined;
549
- filter?: string | number | null | undefined;
550
- marker?: string | number | null | undefined;
551
- mask?: string | number | null | undefined;
552
- font?: string | number | null | undefined;
553
- resize?: string | number | null | undefined;
554
547
  border?: string | number | null | undefined;
555
548
  accentColor?: string | number | null | undefined;
556
549
  alignContent?: string | number | null | undefined;
@@ -657,6 +650,7 @@ export declare class Box extends Component<ElbeBoxProps & {
657
650
  caretColor?: string | number | null | undefined;
658
651
  clear?: string | number | null | undefined;
659
652
  clip?: string | number | null | undefined;
653
+ clipPath?: string | number | null | undefined;
660
654
  clipRule?: string | number | null | undefined;
661
655
  color?: string | number | null | undefined;
662
656
  colorInterpolation?: string | number | null | undefined;
@@ -698,6 +692,7 @@ export declare class Box extends Component<ElbeBoxProps & {
698
692
  fill?: string | number | null | undefined;
699
693
  fillOpacity?: string | number | null | undefined;
700
694
  fillRule?: string | number | null | undefined;
695
+ filter?: string | number | null | undefined;
701
696
  flexBasis?: string | number | null | undefined;
702
697
  flexDirection?: string | number | null | undefined;
703
698
  flexFlow?: string | number | null | undefined;
@@ -707,6 +702,7 @@ export declare class Box extends Component<ElbeBoxProps & {
707
702
  float?: string | number | null | undefined;
708
703
  floodColor?: string | number | null | undefined;
709
704
  floodOpacity?: string | number | null | undefined;
705
+ font?: string | number | null | undefined;
710
706
  fontFamily?: string | number | null | undefined;
711
707
  fontFeatureSettings?: string | number | null | undefined;
712
708
  fontKerning?: string | number | null | undefined;
@@ -787,9 +783,11 @@ export declare class Box extends Component<ElbeBoxProps & {
787
783
  marginLeft?: string | number | null | undefined;
788
784
  marginRight?: string | number | null | undefined;
789
785
  marginTop?: string | number | null | undefined;
786
+ marker?: string | number | null | undefined;
790
787
  markerEnd?: string | number | null | undefined;
791
788
  markerMid?: string | number | null | undefined;
792
789
  markerStart?: string | number | null | undefined;
790
+ mask?: string | number | null | undefined;
793
791
  maskClip?: string | number | null | undefined;
794
792
  maskComposite?: string | number | null | undefined;
795
793
  maskImage?: string | number | null | undefined;
@@ -864,6 +862,7 @@ export declare class Box extends Component<ElbeBoxProps & {
864
862
  printColorAdjust?: string | number | null | undefined;
865
863
  quotes?: string | number | null | undefined;
866
864
  r?: string | number | null | undefined;
865
+ resize?: string | number | null | undefined;
867
866
  right?: string | number | null | undefined;
868
867
  rotate?: string | number | null | undefined;
869
868
  rowGap?: string | number | null | undefined;
@@ -1055,12 +1054,6 @@ export declare class Box extends Component<ElbeBoxProps & {
1055
1054
  flex?: string | number | null | undefined;
1056
1055
  cssText?: string | null;
1057
1056
  [Symbol.iterator]?: string | number | null | undefined;
1058
- clipPath?: string | number | null | undefined;
1059
- filter?: string | number | null | undefined;
1060
- marker?: string | number | null | undefined;
1061
- mask?: string | number | null | undefined;
1062
- font?: string | number | null | undefined;
1063
- resize?: string | number | null | undefined;
1064
1057
  border?: string | number | null | undefined;
1065
1058
  accentColor?: string | number | null | undefined;
1066
1059
  alignContent?: string | number | null | undefined;
@@ -1167,6 +1160,7 @@ export declare class Box extends Component<ElbeBoxProps & {
1167
1160
  caretColor?: string | number | null | undefined;
1168
1161
  clear?: string | number | null | undefined;
1169
1162
  clip?: string | number | null | undefined;
1163
+ clipPath?: string | number | null | undefined;
1170
1164
  clipRule?: string | number | null | undefined;
1171
1165
  color?: string | number | null | undefined;
1172
1166
  colorInterpolation?: string | number | null | undefined;
@@ -1208,6 +1202,7 @@ export declare class Box extends Component<ElbeBoxProps & {
1208
1202
  fill?: string | number | null | undefined;
1209
1203
  fillOpacity?: string | number | null | undefined;
1210
1204
  fillRule?: string | number | null | undefined;
1205
+ filter?: string | number | null | undefined;
1211
1206
  flexBasis?: string | number | null | undefined;
1212
1207
  flexDirection?: string | number | null | undefined;
1213
1208
  flexFlow?: string | number | null | undefined;
@@ -1217,6 +1212,7 @@ export declare class Box extends Component<ElbeBoxProps & {
1217
1212
  float?: string | number | null | undefined;
1218
1213
  floodColor?: string | number | null | undefined;
1219
1214
  floodOpacity?: string | number | null | undefined;
1215
+ font?: string | number | null | undefined;
1220
1216
  fontFamily?: string | number | null | undefined;
1221
1217
  fontFeatureSettings?: string | number | null | undefined;
1222
1218
  fontKerning?: string | number | null | undefined;
@@ -1297,9 +1293,11 @@ export declare class Box extends Component<ElbeBoxProps & {
1297
1293
  marginLeft?: string | number | null | undefined;
1298
1294
  marginRight?: string | number | null | undefined;
1299
1295
  marginTop?: string | number | null | undefined;
1296
+ marker?: string | number | null | undefined;
1300
1297
  markerEnd?: string | number | null | undefined;
1301
1298
  markerMid?: string | number | null | undefined;
1302
1299
  markerStart?: string | number | null | undefined;
1300
+ mask?: string | number | null | undefined;
1303
1301
  maskClip?: string | number | null | undefined;
1304
1302
  maskComposite?: string | number | null | undefined;
1305
1303
  maskImage?: string | number | null | undefined;
@@ -1374,6 +1372,7 @@ export declare class Box extends Component<ElbeBoxProps & {
1374
1372
  printColorAdjust?: string | number | null | undefined;
1375
1373
  quotes?: string | number | null | undefined;
1376
1374
  r?: string | number | null | undefined;
1375
+ resize?: string | number | null | undefined;
1377
1376
  right?: string | number | null | undefined;
1378
1377
  rotate?: string | number | null | undefined;
1379
1378
  rowGap?: string | number | null | undefined;
@@ -1565,12 +1564,6 @@ export declare class Box extends Component<ElbeBoxProps & {
1565
1564
  flex?: string | number | null | undefined;
1566
1565
  cssText?: string | null;
1567
1566
  [Symbol.iterator]?: string | number | null | undefined;
1568
- clipPath?: string | number | null | undefined;
1569
- filter?: string | number | null | undefined;
1570
- marker?: string | number | null | undefined;
1571
- mask?: string | number | null | undefined;
1572
- font?: string | number | null | undefined;
1573
- resize?: string | number | null | undefined;
1574
1567
  border?: string | number | null | undefined;
1575
1568
  accentColor?: string | number | null | undefined;
1576
1569
  alignContent?: string | number | null | undefined;
@@ -1677,6 +1670,7 @@ export declare class Box extends Component<ElbeBoxProps & {
1677
1670
  caretColor?: string | number | null | undefined;
1678
1671
  clear?: string | number | null | undefined;
1679
1672
  clip?: string | number | null | undefined;
1673
+ clipPath?: string | number | null | undefined;
1680
1674
  clipRule?: string | number | null | undefined;
1681
1675
  color?: string | number | null | undefined;
1682
1676
  colorInterpolation?: string | number | null | undefined;
@@ -1718,6 +1712,7 @@ export declare class Box extends Component<ElbeBoxProps & {
1718
1712
  fill?: string | number | null | undefined;
1719
1713
  fillOpacity?: string | number | null | undefined;
1720
1714
  fillRule?: string | number | null | undefined;
1715
+ filter?: string | number | null | undefined;
1721
1716
  flexBasis?: string | number | null | undefined;
1722
1717
  flexDirection?: string | number | null | undefined;
1723
1718
  flexFlow?: string | number | null | undefined;
@@ -1727,6 +1722,7 @@ export declare class Box extends Component<ElbeBoxProps & {
1727
1722
  float?: string | number | null | undefined;
1728
1723
  floodColor?: string | number | null | undefined;
1729
1724
  floodOpacity?: string | number | null | undefined;
1725
+ font?: string | number | null | undefined;
1730
1726
  fontFamily?: string | number | null | undefined;
1731
1727
  fontFeatureSettings?: string | number | null | undefined;
1732
1728
  fontKerning?: string | number | null | undefined;
@@ -1807,9 +1803,11 @@ export declare class Box extends Component<ElbeBoxProps & {
1807
1803
  marginLeft?: string | number | null | undefined;
1808
1804
  marginRight?: string | number | null | undefined;
1809
1805
  marginTop?: string | number | null | undefined;
1806
+ marker?: string | number | null | undefined;
1810
1807
  markerEnd?: string | number | null | undefined;
1811
1808
  markerMid?: string | number | null | undefined;
1812
1809
  markerStart?: string | number | null | undefined;
1810
+ mask?: string | number | null | undefined;
1813
1811
  maskClip?: string | number | null | undefined;
1814
1812
  maskComposite?: string | number | null | undefined;
1815
1813
  maskImage?: string | number | null | undefined;
@@ -1884,6 +1882,7 @@ export declare class Box extends Component<ElbeBoxProps & {
1884
1882
  printColorAdjust?: string | number | null | undefined;
1885
1883
  quotes?: string | number | null | undefined;
1886
1884
  r?: string | number | null | undefined;
1885
+ resize?: string | number | null | undefined;
1887
1886
  right?: string | number | null | undefined;
1888
1887
  rotate?: string | number | null | undefined;
1889
1888
  rowGap?: string | number | null | undefined;
@@ -2075,12 +2074,6 @@ export declare class Box extends Component<ElbeBoxProps & {
2075
2074
  flex?: string | number | null | undefined;
2076
2075
  cssText?: string | null;
2077
2076
  [Symbol.iterator]?: string | number | null | undefined;
2078
- clipPath?: string | number | null | undefined;
2079
- filter?: string | number | null | undefined;
2080
- marker?: string | number | null | undefined;
2081
- mask?: string | number | null | undefined;
2082
- font?: string | number | null | undefined;
2083
- resize?: string | number | null | undefined;
2084
2077
  border?: string | number | null | undefined;
2085
2078
  accentColor?: string | number | null | undefined;
2086
2079
  alignContent?: string | number | null | undefined;
@@ -2187,6 +2180,7 @@ export declare class Box extends Component<ElbeBoxProps & {
2187
2180
  caretColor?: string | number | null | undefined;
2188
2181
  clear?: string | number | null | undefined;
2189
2182
  clip?: string | number | null | undefined;
2183
+ clipPath?: string | number | null | undefined;
2190
2184
  clipRule?: string | number | null | undefined;
2191
2185
  color?: string | number | null | undefined;
2192
2186
  colorInterpolation?: string | number | null | undefined;
@@ -2228,6 +2222,7 @@ export declare class Box extends Component<ElbeBoxProps & {
2228
2222
  fill?: string | number | null | undefined;
2229
2223
  fillOpacity?: string | number | null | undefined;
2230
2224
  fillRule?: string | number | null | undefined;
2225
+ filter?: string | number | null | undefined;
2231
2226
  flexBasis?: string | number | null | undefined;
2232
2227
  flexDirection?: string | number | null | undefined;
2233
2228
  flexFlow?: string | number | null | undefined;
@@ -2237,6 +2232,7 @@ export declare class Box extends Component<ElbeBoxProps & {
2237
2232
  float?: string | number | null | undefined;
2238
2233
  floodColor?: string | number | null | undefined;
2239
2234
  floodOpacity?: string | number | null | undefined;
2235
+ font?: string | number | null | undefined;
2240
2236
  fontFamily?: string | number | null | undefined;
2241
2237
  fontFeatureSettings?: string | number | null | undefined;
2242
2238
  fontKerning?: string | number | null | undefined;
@@ -2317,9 +2313,11 @@ export declare class Box extends Component<ElbeBoxProps & {
2317
2313
  marginLeft?: string | number | null | undefined;
2318
2314
  marginRight?: string | number | null | undefined;
2319
2315
  marginTop?: string | number | null | undefined;
2316
+ marker?: string | number | null | undefined;
2320
2317
  markerEnd?: string | number | null | undefined;
2321
2318
  markerMid?: string | number | null | undefined;
2322
2319
  markerStart?: string | number | null | undefined;
2320
+ mask?: string | number | null | undefined;
2323
2321
  maskClip?: string | number | null | undefined;
2324
2322
  maskComposite?: string | number | null | undefined;
2325
2323
  maskImage?: string | number | null | undefined;
@@ -2394,6 +2392,7 @@ export declare class Box extends Component<ElbeBoxProps & {
2394
2392
  printColorAdjust?: string | number | null | undefined;
2395
2393
  quotes?: string | number | null | undefined;
2396
2394
  r?: string | number | null | undefined;
2395
+ resize?: string | number | null | undefined;
2397
2396
  right?: string | number | null | undefined;
2398
2397
  rotate?: string | number | null | undefined;
2399
2398
  rowGap?: string | number | null | undefined;
@@ -1,6 +1,4 @@
1
- import type { ElbeColorKinds, ElbeColorManners, ElbeColorModes, ElbeColorSchemes } from "../../theme/colors";
2
- import type { ElbeChildren } from "../../util/util";
3
- import { type ElbeProps } from "./box";
1
+ import { ElbeChildren, ElbeColorKinds, ElbeColorManners, ElbeColorModes, ElbeColorSchemes, ElbeProps } from "../../..";
4
2
  export declare const elevatedShadow = "0 0 15px rgba(0,0,0,.2)";
5
3
  export declare function Card({ mode, scheme, kind, manner, padding, margin, onTap, onLongTap, frosted, bordered, elevated, sharp, disabled, overflow, children, ...elbe }: {
6
4
  mode?: ElbeColorModes;
@@ -10,7 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import { jsx as _jsx } from "preact/jsx-runtime";
13
- import { applyProps } from "./box";
13
+ import { applyProps, } from "../../..";
14
14
  export const elevatedShadow = "0 0 15px rgba(0,0,0,.2)";
15
15
  export function Card(_a) {
16
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"]);
@@ -1,4 +1,4 @@
1
- import type { ElbeChildren } from "../util/util";
1
+ import type { ElbeChildren } from "../util/types";
2
2
  export declare function ElbeDialog({ title, open, onClose, children, _style, }: {
3
3
  _style?: string;
4
4
  title: string;
@@ -1,4 +1,4 @@
1
- import { ElbeChild } from "../../util/util";
1
+ import { ElbeChild } from "../../util/types";
2
2
  import { HeaderLogos } from "./header";
3
3
  export interface _AppBaseState {
4
4
  menuSelected: string | null;
@@ -28,7 +28,7 @@ export function Header(p) {
28
28
  borderColor: tConfig.highVis || scroll ? null : "transparent",
29
29
  gap: "1rem",
30
30
  zIndex: 80,
31
- }, children: [p.leading === "back" && _backBtn, p.leading === "close" && _closeBtn, typeof p.leading === "function"
31
+ }, children: [p.leading === "back" && _backBtn, p.leading === "close" && _closeBtn, p.leading && p.leading !== "back" && p.leading !== "close"
32
32
  ? p.leading
33
33
  : appBase &&
34
34
  layoutMode != "wide" && (_jsx(IconButton.plain, { ariaLabel: "open/close menu", onTap: () => appBase.setMenuOpen(!appBase.menuOpen), icon: MenuIcon })), _jsx(_Logo, { logo: (_a = p.logo) !== null && _a !== void 0 ? _a : appBase === null || appBase === void 0 ? void 0 : appBase.icons.logo, logoDark: (_b = p.logoDark) !== null && _b !== void 0 ? _b : appBase === null || appBase === void 0 ? void 0 : appBase.icons.logoDark, lMargin: 0.5 }), typeof p.title === "string" ? (_jsx(Text.h3, { style: {
@@ -1,4 +1,4 @@
1
- import { ElbeChild } from "../../util/util";
1
+ import { ElbeChild } from "../../..";
2
2
  import { IconChild } from "../button/icon_button";
3
3
  export type MenuItem = {
4
4
  id: string;
@@ -1,7 +1,6 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "preact/jsx-runtime";
2
2
  import { MenuIcon } from "lucide-react";
3
- import { useThemeConfig } from "../../..";
4
- import { useLayoutMode } from "../../util/util";
3
+ import { useLayoutMode, useTheme, useThemeConfig } from "../../..";
5
4
  import { Card, elevatedShadow } from "../base/card";
6
5
  import { Button } from "../button/button";
7
6
  import { useAppBase } from "./ctx_app_base";
@@ -10,6 +9,7 @@ export function Menu(p) {
10
9
  const layoutMode = useLayoutMode();
11
10
  const appBase = useAppBase();
12
11
  const tConfig = useThemeConfig();
12
+ const theme = useTheme();
13
13
  const topBot = { top: [], bottom: [] };
14
14
  for (let i of p.items) {
15
15
  if (i.bottom)
@@ -17,12 +17,13 @@ export function Menu(p) {
17
17
  else
18
18
  topBot.top.push(i);
19
19
  }
20
+ const wideOrOpen = () => appBase.menuOpen || layoutMode == "wide";
20
21
  const menuWidth = () => appBase.menuOpen
21
22
  ? layoutMode === "mobile"
22
23
  ? "100vw"
23
- : "260px"
24
+ : `${17 + theme.geometry.borderWidth}rem`
24
25
  : layoutMode === "wide"
25
- ? "4rem"
26
+ ? `${4 + theme.geometry.borderWidth}rem`
26
27
  : "0";
27
28
  return (_jsxs(_Fragment, { children: [layoutMode == "wide" && (_jsx("div", { style: {
28
29
  width: menuWidth(),
@@ -33,20 +34,22 @@ export function Menu(p) {
33
34
  width: "100vw",
34
35
  height: "100vh",
35
36
  }
36
- : {})) }), _jsxs(Card, { onTap: () => {
37
+ : {})) }), _jsx(Card, { onTap: () => {
37
38
  if (layoutMode == "wide")
38
39
  return;
39
40
  appBase.setMenuOpen(false);
40
- }, scheme: "primary", padding: 0.5, style: Object.assign({ zIndex: 101, position: "fixed", left: 0, top: 0, height: "100vh", overflow: "hidden", width: menuWidth(), display: appBase.menuOpen || layoutMode == "wide" ? "flex" : "none", flexDirection: "column", justifyContent: "start", alignItems: "stretch", borderTopLeftRadius: 0, borderBottomLeftRadius: 0, border: "none", borderRight: tConfig.highVis
41
- ? "1px solid var(--c-context-front)"
42
- : "none", gap: "1rem", transition: "width 200ms ease-in-out" }, (layoutMode === "narrow" && appBase.menuOpen
41
+ }, sharp: layoutMode == "mobile", bordered: true, scheme: "primary", padding: wideOrOpen() ? 0.5 : 0, style: Object.assign({ zIndex: 101, position: "fixed", left: 0, top: 0, height: "100vh", overflow: "hidden", width: menuWidth(), display: "flex",
42
+ //display: appBase.menuOpen || layoutMode == "wide" ? "flex" : "none",
43
+ flexDirection: "column", justifyContent: "start", alignItems: "stretch", borderTopLeftRadius: 0, borderBottomLeftRadius: 0, borderLeft: "none", borderTop: "none", borderBottom: "none", borderColor: tConfig.highVis ? null : "transparent", gap: "1rem", transition: tConfig.reducedMotion
44
+ ? "none"
45
+ : "width 200ms ease-in-out" }, (layoutMode === "narrow" && appBase.menuOpen
43
46
  ? {
44
47
  boxShadow: elevatedShadow,
45
48
  }
46
- : {})), children: [_jsx(Button.plain, { contentAlign: "start", ariaLabel: "open/close menu", onTap: () => appBase.setMenuOpen(!appBase.menuOpen), icon: MenuIcon, style: {
47
- marginBottom: ".5rem",
48
- borderRadius: "3rem",
49
- } }), _jsx(Column, { flex: 1, scroll: true, noScrollbar: true, children: topBot.top.map((i) => (_jsx(_MenuItemView, { item: i }))) }), topBot.bottom.map((i) => (_jsx(_MenuItemView, { item: i })))] })] }));
49
+ : {})), children: wideOrOpen() && (_jsxs(_Fragment, { children: [_jsx(Button.plain, { contentAlign: "start", ariaLabel: "open/close menu", onTap: () => appBase.setMenuOpen(!appBase.menuOpen), icon: MenuIcon, style: {
50
+ marginBottom: ".5rem",
51
+ borderRadius: "3rem",
52
+ } }), _jsx(Column, { flex: 1, scroll: true, noScrollbar: true, children: topBot.top.map((i) => (_jsx(_MenuItemView, { item: i }))) }), topBot.bottom.map((i) => (_jsx(_MenuItemView, { item: i })))] })) })] }));
50
53
  }
51
54
  function _MenuItemView({ item }) {
52
55
  const appBase = useAppBase();
@@ -1,6 +1,6 @@
1
1
  import React from "preact/compat";
2
2
  import type { ElbeTypeVariants } from "../theme/type_theme";
3
- import type { ElbeChildren } from "../util/util";
3
+ import type { ElbeChildren } from "../util/types";
4
4
  import { type ElbeProps } from "./base/box";
5
5
  export type TextProps = {
6
6
  align?: "start" | "center" | "end";
@@ -0,0 +1,35 @@
1
+ import React from "preact/compat";
2
+ import { ElbeChildren } from "../types";
3
+ type _LocaleID = `${string}_${string}` | `${string}`;
4
+ type _LocaleIDEasy = `${string}_${string}_easy` | _LocaleID;
5
+ type _L10nData = {
6
+ [key: string]: any;
7
+ };
8
+ export interface _L10nState<T extends _L10nData> {
9
+ /** the current locale */
10
+ c: T;
11
+ locale: string;
12
+ easyLang: boolean;
13
+ setLocale: (locale: string) => void;
14
+ setEasyLang: (easyLang: boolean) => void;
15
+ }
16
+ type _L10nProps = {
17
+ children: ElbeChildren;
18
+ initialLocale?: _LocaleID;
19
+ initialEasyLang?: boolean;
20
+ };
21
+ /**
22
+ * L10nBase is a function that creates a localization context provider and a hook to use the localization context.
23
+ * @param fallback this is the fallback locale, which is used if no other locale is found. It is the basis for the locale type and must thus be complete.
24
+ * @param supported this is a list of supported locales. It is a map of locale IDs to partial localization data. The keys are the locale IDs, and the values are the localization data.
25
+ * @returns an object with the L10n component and the useL10n hook.
26
+ */
27
+ export declare function makeL10n<T extends _L10nData>(fallback: {
28
+ [locale: _LocaleIDEasy]: T;
29
+ }, supported: {
30
+ [locale: _LocaleIDEasy]: Partial<T>;
31
+ }): {
32
+ L10n: React.FunctionComponent<_L10nProps>;
33
+ useL10n: () => _L10nState<T>;
34
+ };
35
+ export {};
@@ -0,0 +1,68 @@
1
+ import { jsx as _jsx } from "preact/jsx-runtime";
2
+ import { createContext } from "preact";
3
+ import { useContext, useEffect, useState } from "preact/hooks";
4
+ const _L10nContext = createContext(null);
5
+ function _useL10n() {
6
+ const ctx = useContext(_L10nContext);
7
+ if (!ctx)
8
+ throw new Error("useL10n must be used within a L10n");
9
+ return ctx;
10
+ }
11
+ /**
12
+ * L10nBase is a function that creates a localization context provider and a hook to use the localization context.
13
+ * @param fallback this is the fallback locale, which is used if no other locale is found. It is the basis for the locale type and must thus be complete.
14
+ * @param supported this is a list of supported locales. It is a map of locale IDs to partial localization data. The keys are the locale IDs, and the values are the localization data.
15
+ * @returns an object with the L10n component and the useL10n hook.
16
+ */
17
+ export function makeL10n(fallback, supported) {
18
+ if (Object.keys(supported).length === 0) {
19
+ throw new Error("L10nBase: No fallback locales provided");
20
+ }
21
+ const fallbackLocale = Object.keys(fallback)[0];
22
+ const fallbackValue = fallback[fallbackLocale];
23
+ const supportedLocales = Object.assign(Object.assign({}, supported), fallback);
24
+ const useL10n = (_useL10n);
25
+ const L10n = (p) => {
26
+ var _a, _b;
27
+ const [loc, setLoc] = useState((_a = p.initialLocale) !== null && _a !== void 0 ? _a : navigator.language);
28
+ const [easy, setEasy] = useState((_b = p.initialEasyLang) !== null && _b !== void 0 ? _b : false);
29
+ const [currentLang, setCurrentLang] = useState(fallbackValue);
30
+ useEffect(() => {
31
+ var _a;
32
+ const match = _bestMatch(loc, easy, Object.keys(supportedLocales));
33
+ setCurrentLang(Object.assign(Object.assign({}, fallbackValue), ((_a = supportedLocales[match !== null && match !== void 0 ? match : ""]) !== null && _a !== void 0 ? _a : {})));
34
+ }, [loc, easy]);
35
+ return (_jsx(_L10nContext.Provider, { value: {
36
+ c: currentLang,
37
+ locale: loc,
38
+ easyLang: easy,
39
+ setLocale: (l) => setLoc(l),
40
+ setEasyLang: (e) => setEasy(e),
41
+ }, children: p.children }));
42
+ };
43
+ return { L10n, useL10n };
44
+ }
45
+ function _locale(l) {
46
+ const parts = l.split("_");
47
+ const easy = parts.length > 2 && parts[2] === "easy";
48
+ const region = parts.length > 1 ? parts[1].toLowerCase() : null;
49
+ const lang = parts[0].toLowerCase();
50
+ return { full: l, lang, region, easy };
51
+ }
52
+ function _bestMatch(locale, easy, locales) {
53
+ const loc = _locale(locale.replaceAll("-", "_"));
54
+ const asLocales = locales.map((l) => _locale(l));
55
+ // filter by language
56
+ const langMatch = asLocales.filter((l) => loc.lang === l.lang);
57
+ // filter by easy
58
+ const easyMatch = langMatch.filter((l) => l.easy === easy);
59
+ // filter by region
60
+ const regionMatch = easyMatch.filter((l) => l.region === loc.region);
61
+ if (regionMatch.length > 0)
62
+ return regionMatch[0].full;
63
+ if (easyMatch.length > 0)
64
+ return easyMatch[0].full;
65
+ if (langMatch.length > 0)
66
+ return langMatch[0].full;
67
+ return null;
68
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @see https://stackoverflow.com/questions/53953814/typescript-check-if-a-type-is-a-union/53955431
3
+ */
4
+ type IsSingleton<T> = [T] extends [UnionToIntersection<T>] ? true : false;
5
+ /**
6
+ * @author https://stackoverflow.com/users/2887218/jcalz
7
+ * @see https://stackoverflow.com/a/50375286/10325032
8
+ */
9
+ type UnionToIntersection<Union> = (Union extends any ? (argument: Union) => void : never) extends (argument: infer Intersection) => void ? Intersection : never;
10
+ export type SingletonOnly<T> = IsSingleton<T> extends true ? T : never;
11
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ export type int = number;
2
+ export type float = number;
3
+ /** a unix epoch timestamp in milliseconds */
4
+ export type UnixMS = int;
5
+ export type ElbeChild = React.ReactNode;
6
+ export type ElbeChildren = ElbeChild[] | ElbeChild;
7
+ export type s = string;
8
+ export type n = number;
9
+ export type b = boolean;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,8 +1,4 @@
1
- import type React from "preact/compat";
2
- export type int = number;
3
- export type float = number;
4
- export type ElbeChild = React.ReactNode;
5
- export type ElbeChildren = ElbeChild[] | ElbeChild;
1
+ import { int } from "../..";
6
2
  export declare function clamp(value: number, min: number, max: number): number;
7
3
  export declare function classString(classes: (string | false | null | undefined)[]): string;
8
4
  /**
@@ -1,5 +1,5 @@
1
1
  import { useEffect, useState } from "preact/compat";
2
- import { showToast } from "./toast";
2
+ import { showToast } from "../..";
3
3
  export function clamp(value, min, max) {
4
4
  return Math.min(Math.max(value, min), max);
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "elbe-ui",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "author": "Robin Naumann",
5
5
  "license": "MIT",
6
6
  "repository": {