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
@@ -0,0 +1,21 @@
1
+ import { ColorSelection } from "../../theme/subthemes/color/colors/colors";
2
+ import { ElbeChildrenProps, ElbeStyleProps } from "../base/box";
3
+ export type LabeledInputProps = ElbeChildrenProps & ElbeStyleProps & {
4
+ label: string;
5
+ hideLabel?: boolean;
6
+ width?: number;
7
+ flex?: boolean | number;
8
+ manner?: Exclude<ColorSelection.Manners, "major" | "minor">;
9
+ disabled?: boolean;
10
+ tooltip?: string;
11
+ };
12
+ /**
13
+ * a wrapper for creating labeled input fields. This is used internally by various input components
14
+ * such as text fields, number fields, select fields, etc.
15
+ * @param p labeled input props
16
+ * @returns a labeled input component
17
+ */
18
+ export declare function LabeledInput(p: LabeledInputProps & {
19
+ typeLabel: string;
20
+ id: string;
21
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useApp } from "../../app/app_ctxt";
3
+ import { applyProps } from "../base/box";
4
+ import { WithStateTheme } from "../base/state_builder";
5
+ import { WithTooltip } from "../tooltip";
6
+ /**
7
+ * a wrapper for creating labeled input fields. This is used internally by various input components
8
+ * such as text fields, number fields, select fields, etc.
9
+ * @param p labeled input props
10
+ * @returns a labeled input component
11
+ */
12
+ export function LabeledInput(p) {
13
+ var _a, _b;
14
+ const { _appThemeContext } = useApp();
15
+ const baseTheme = _appThemeContext.useTheme();
16
+ return (_jsx(WithTooltip, { tooltip: p.tooltip, children: _jsx(WithStateTheme, { disabled: (_a = p.disabled) !== null && _a !== void 0 ? _a : false, theme: baseTheme, manner: p.manner, children: _jsxs("div", Object.assign({}, applyProps(p.typeLabel, p, [], Object.assign({ flex: p.flex ? (p.flex === true ? 1 : p.flex) : undefined, width: p.flex ? undefined : ((_b = p.width) !== null && _b !== void 0 ? _b : 12) + "rem", display: "flex", flexDirection: "column", alignItems: "stretch" }, p.style)), { children: [_jsx("label", { htmlFor: p.id, style: {
17
+ display: p.hideLabel ? "none" : "block",
18
+ fontSize: "0.8rem",
19
+ padding: "0.2rem 0.5rem",
20
+ }, children: p.label }), p.children] })) }) }));
21
+ }
@@ -1,3 +1,5 @@
1
1
  import { BooleanInputProps } from "../../..";
2
- import { ActionElbeProps } from "../base/box";
3
- export declare function Checkbox(p: BooleanInputProps & ActionElbeProps): import("react/jsx-runtime").JSX.Element;
2
+ import { ElbeActionProps } from "../base/box";
3
+ export declare function Checkbox(p: BooleanInputProps & ElbeActionProps & {
4
+ manner?: "flat" | "plain";
5
+ }): import("react/jsx-runtime").JSX.Element;
@@ -1,14 +1,22 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { _InputSpacer, useThemeConfig } from "../../..";
3
- import { applyProps } from "../base/box";
2
+ import { _InputSpacer, Text } from "../../..";
3
+ import { useApp } from "../../app/app_ctxt";
4
+ import { applyProps, styleBorderFromContext, } from "../base/box";
5
+ import { WithStateTheme } from "../base/state_builder";
6
+ import { WithTooltip } from "../tooltip";
4
7
  export function Checkbox(p) {
5
- const tConfig = useThemeConfig();
6
- return _InputSpacer(p, _jsxs("div", { className: `row ${p.onChange ? "" : "disabled"}`, style: {
8
+ const { _appThemeContext } = useApp();
9
+ const baseTheme = _appThemeContext.useTheme().useWith(({ color }) => {
10
+ var _a;
11
+ return ({
12
+ color: Object.assign(Object.assign({}, color), { selection: Object.assign(Object.assign({}, color.selection), { manner: p.value ? "major" : (_a = p.manner) !== null && _a !== void 0 ? _a : "flat" }) }),
13
+ });
14
+ }, [p.value, p.manner]);
15
+ return _InputSpacer(p, _jsx(WithTooltip, { tooltip: p.tooltip, children: _jsxs("div", Object.assign({}, applyProps("checkbox", Object.assign({ role: "checkbox" }, p), [], {
16
+ display: "flex",
17
+ alignItems: "center",
7
18
  gap: ".75rem",
8
19
  filter: p.onChange ? "" : "grayscale(1)",
9
20
  opacity: p.onChange ? "" : "0.5",
10
- }, children: [_jsx("input", Object.assign({ type: "checkbox" }, applyProps("checkbox", Object.assign({ role: "checkbox" }, p), p.value ? ["accent major"] : "accent minor", {
11
- background: p.value ? undefined : "transparent",
12
- transition: tConfig.reducedMotion ? "none" : undefined,
13
- }), { disabled: !p.onChange, checked: p.value, onClick: (e) => e.stopPropagation(), onChange: (e) => { var _a; return (_a = p.onChange) === null || _a === void 0 ? void 0 : _a.call(p, e.currentTarget.checked); } })), p.label && _jsx("div", { style: { marginTop: "-.25rem" }, children: p.label })] }));
21
+ }), { children: [_jsx(WithStateTheme, { theme: baseTheme, disabled: !p.onChange, children: _jsx("input", { type: "checkbox", disabled: !p.onChange, checked: p.value, onClick: (e) => e.stopPropagation(), onChange: (e) => { var _a; return (_a = p.onChange) === null || _a === void 0 ? void 0 : _a.call(p, e.currentTarget.checked); }, className: "elbe_colored", style: Object.assign({ width: "1.8rem", height: "1.8rem", cursor: "inherit" }, styleBorderFromContext) }) }), p.label && _jsx(Text, { v: p.label })] })) }));
14
22
  }
@@ -1,8 +1,10 @@
1
- import { ActionElbeProps } from "../base/box";
2
- export declare function Range({ value, onChange, min, max, step, ...elbe }: {
1
+ import { ElbeActionProps } from "../base/box";
2
+ type _RangeProps = ElbeActionProps & {
3
3
  value: number;
4
4
  min?: number;
5
5
  step?: number;
6
6
  max?: number;
7
7
  onChange?: ((value: number) => void) | null;
8
- } & ActionElbeProps): import("react/jsx-runtime").JSX.Element;
8
+ };
9
+ export declare function Range(p: _RangeProps): import("react/jsx-runtime").JSX.Element;
10
+ export {};
@@ -10,25 +10,32 @@ 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 { useTheme } from "../../theme/theme_context";
13
+ import { useApp } from "../../app/app_ctxt";
14
14
  import { _ElbeErr } from "../../util/error_view";
15
15
  import { applyProps } from "../base/box";
16
16
  import { Card } from "../base/card";
17
- export function Range(_a) {
18
- var { value, onChange, min = 0, max = 100, step = 1 } = _a, elbe = __rest(_a, ["value", "onChange", "min", "max", "step"]);
19
- const theme = useTheme();
20
- return min > max ? (_ElbeErr("Range: max is smaller than min")) : (_jsx(Card, { ariaLabel: null, scheme: "secondary", kind: "accent", manner: "minor", style: {
17
+ export function Range(p) {
18
+ 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: {
21
20
  overflow: "unset",
22
21
  backgroundColor: "transparent",
23
22
  padding: "0",
24
23
  margin: "0",
25
- border: "none",
24
+ borderStyle: "none",
26
25
  width: "100%",
27
- }, children: _jsx("input", Object.assign({ type: "range" }, applyProps("range", Object.assign({ role: "slider" }, elbe), null, {
28
- filter: onChange ? "" : "grayscale(1)",
29
- opacity: onChange ? "" : "0.5",
30
- cursor: onChange ? "pointer" : "not-allowed",
31
- width: "100%",
32
- borderRadius: theme.geometry.radius + "rem",
33
- }), { min: min, max: max, step: step, disabled: !onChange, value: value, onInput: (e) => onChange === null || onChange === void 0 ? void 0 : onChange(Number(e.currentTarget.value)) })) }));
26
+ }, children: _jsx(_StyledRange, Object.assign({}, p)) }));
27
+ }
28
+ function _StyledRange(_a) {
29
+ var _b, _c;
30
+ var { min = 0, max = 100, step = 1, value, onChange } = _a, elbe = __rest(_a, ["min", "max", "step", "value", "onChange"]);
31
+ const { _appThemeContext } = useApp();
32
+ const { theme } = _appThemeContext.useTheme().useWith((c) => ({
33
+ color: Object.assign(Object.assign({}, c.color), { selection: Object.assign(Object.assign({}, c.color.selection), { manner: "major" }) }),
34
+ }), []);
35
+ return (_jsx("input", Object.assign({ type: "range" }, applyProps("range", Object.assign({ role: "slider" }, elbe), null, Object.assign({ filter: onChange ? "" : "grayscale(1)", opacity: onChange ? "" : "0.5", cursor: onChange ? "pointer" : "not-allowed", width: "100%", borderRadius: theme.geometry.radius + "rem" }, {
36
+ "--elbe-range-dot-back": theme.color.isContrast
37
+ ? theme.color.currentColor.front.asCss()
38
+ : theme.color.currentColor.back.asCss(),
39
+ "--elbe-range-dot-border": (_c = (_b = theme.color.currentColor.border) === null || _b === void 0 ? void 0 : _b.asCss()) !== null && _c !== void 0 ? _c : "transparent",
40
+ })), { min: min, max: max, step: step, disabled: !onChange, value: value, onInput: (e) => onChange === null || onChange === void 0 ? void 0 : onChange(Number(e.currentTarget.value)) })));
34
41
  }
@@ -1,5 +1,6 @@
1
- import { ActionElbeProps } from "../base/box";
2
- export declare function Select<T>({ options, value, label, hideLabel, width, onChange, ...elbe }: {
1
+ import { ElbeActionProps } from "../base/box";
2
+ import { LabeledInputProps } from "./_labeled_input";
3
+ export declare function Select<T>(p: ElbeActionProps & LabeledInputProps & {
3
4
  options: {
4
5
  key: T;
5
6
  label: string;
@@ -9,4 +10,4 @@ export declare function Select<T>({ options, value, label, hideLabel, width, onC
9
10
  hideLabel?: boolean;
10
11
  width?: number;
11
12
  onChange?: (value: T) => any;
12
- } & ActionElbeProps): import("react/jsx-runtime").JSX.Element;
13
+ }): import("react/jsx-runtime").JSX.Element;
@@ -1,49 +1,22 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
13
2
  import { randomAlphaNum } from "../../util/util";
14
- import { applyProps } from "../base/box";
15
- export function Select(_a) {
16
- var _b;
17
- var { options, value, label, hideLabel, width, onChange } = _a, elbe = __rest(_a, ["options", "value", "label", "hideLabel", "width", "onChange"]);
18
- const id = (_b = elbe.id) !== null && _b !== void 0 ? _b : randomAlphaNum(8, "input_field_");
19
- let valueIndex = options.findIndex((o) => o.key === value);
3
+ import { styleBorderFromContext, styleColorFromContext, } from "../base/box";
4
+ import { LabeledInput } from "./_labeled_input";
5
+ export function Select(p) {
6
+ var _a;
7
+ const id = (_a = p.id) !== null && _a !== void 0 ? _a : randomAlphaNum(8, "input_field_");
8
+ let valueIndex = p.options.findIndex((o) => o.key === p.value);
20
9
  // If the value is not found, select the first option without a key (if any) or the first option
21
10
  if (valueIndex === -1) {
22
- valueIndex = options.findIndex((v) => !v.key);
11
+ valueIndex = p.options.findIndex((v) => !v.key);
23
12
  if (valueIndex === -1) {
24
13
  valueIndex = 0;
25
14
  }
26
15
  }
27
16
  let valStr = "-".repeat(valueIndex + 1);
28
- return (_jsxs("div", { style: {
29
- flex: elbe.flex ? (elbe.flex === true ? 1 : elbe.flex) : undefined,
30
- width: elbe.flex ? undefined : (width !== null && width !== void 0 ? width : 12) + "rem",
31
- display: "flex",
32
- flexDirection: "column",
33
- alignItems: "stretch",
34
- filter: onChange ? undefined : "grayscale(1) opacity(0.5)",
35
- pointerEvents: onChange ? undefined : "none",
36
- cursor: onChange ? undefined : "not-allowed",
37
- }, "data-tooltip": elbe.tooltip, children: [_jsx("label", { htmlFor: id, style: {
38
- display: hideLabel ? "none" : "block",
39
- fontSize: "0.8rem",
40
- padding: "0.2rem 0.5rem",
41
- }, children: label }), _jsx("select", Object.assign({ id: id }, applyProps("select", elbe, [], {
42
- minHeight: "3rem",
43
- cursor: onChange ? "pointer" : "not-allowed",
44
- }), { value: valStr, disabled: !onChange, role: "combobox", onChange: (e) => {
45
- const index = e.currentTarget.value.length - 1;
46
- const selectedOption = options[index];
47
- selectedOption && onChange ? onChange(selectedOption.key) : null;
48
- }, children: options.map(({ key, label }, i) => (_jsx("option", { value: "-".repeat(i + 1), children: label }, JSON.stringify(key)))) }))] }));
17
+ return (_jsx(LabeledInput, Object.assign({}, p, { id: id, disabled: !p.onChange, typeLabel: "select", children: _jsx("select", { id: id, value: valStr, disabled: !p.onChange, role: "combobox", className: "elbe-focussink", style: Object.assign(Object.assign({ padding: "0 0.75rem", height: "3rem", minWidth: "12rem", width: "100%", cursor: "inherit" }, styleColorFromContext), styleBorderFromContext), onChange: (e) => {
18
+ const index = e.currentTarget.value.length - 1;
19
+ const selectedOption = p.options[index];
20
+ selectedOption && p.onChange ? p.onChange(selectedOption.key) : null;
21
+ }, children: p.options.map(({ key, label }, i) => (_jsx("option", { value: "-".repeat(i + 1), children: label }, JSON.stringify(key)))) }) })));
49
22
  }
@@ -1,10 +1,12 @@
1
1
  import { JSX } from "react/jsx-runtime";
2
- import { ActionElbeProps } from "../../..";
2
+ import { ElbeActionProps } from "../../..";
3
3
  export type BooleanInputProps = {
4
4
  value: boolean;
5
5
  label?: string;
6
6
  compact?: boolean;
7
7
  onChange?: ((checked: boolean) => void) | null;
8
8
  };
9
- export declare function Switch(p: BooleanInputProps & ActionElbeProps): JSX.Element;
9
+ export declare function Switch(p: BooleanInputProps & ElbeActionProps & {
10
+ manner?: "flat" | "plain";
11
+ }): JSX.Element;
10
12
  export declare function _InputSpacer(p: BooleanInputProps, children: JSX.Element): JSX.Element;
@@ -1,45 +1,35 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { CheckIcon, XIcon } from "lucide-react";
3
- import { applyProps } from "../../..";
4
- import { useThemeConfig } from "../../theme/theme_context";
3
+ import { applyProps, styleBorderFromContext } from "../../..";
4
+ import { useApp } from "../../app/app_ctxt";
5
+ import { WithStateTheme } from "../base/state_builder";
6
+ import { WithTooltip } from "../tooltip";
5
7
  export function Switch(p) {
6
- const tConfig = useThemeConfig();
7
- return _InputSpacer(p, _jsx("button", Object.assign({ onClick: (e) => {
8
- var _a;
9
- (_a = p.onChange) === null || _a === void 0 ? void 0 : _a.call(p, !p.value);
10
- e.stopPropagation();
11
- } }, applyProps("switch", Object.assign({ role: "switch" }, p), ["bordered card accent"], {
12
- minHeight: 0,
13
- minWidth: 0,
14
- filter: p.onChange ? "" : "grayscale(1)",
15
- opacity: p.onChange ? "" : "0.5",
16
- height: "1.8rem",
17
- width: "2.7rem",
18
- position: "relative",
19
- padding: 0,
20
- borderColor: "var(--c-context-front)",
21
- backgroundColor: p.value
22
- ? "var(--c-context-front)"
23
- : "var(--c-context-back)",
24
- display: "flex",
25
- alignItems: "center",
26
- transition: tConfig.reducedMotion ? "none" : "background-color 0.25s",
27
- }), { children: _jsx("div", { style: {
28
- position: "absolute",
29
- left: p.value ? "1.2rem" : "0.4rem",
30
- height: ".8rem",
31
- width: ".8rem",
32
- display: "flex",
33
- alignItems: "center",
34
- justifyContent: "center",
35
- transition: tConfig.reducedMotion ? "none" : "left 0.25s",
36
- }, children: p.value ? (_jsx(CheckIcon, { color: "var(--c-context-back)",
37
- //width=".8rem"
38
- //height=".8rem"
39
- absoluteStrokeWidth: false, strokeWidth: "0.3rem" })) : (_jsx(XIcon, { color: "var(--c-context-front)",
40
- //width=".8rem"
41
- //height=".8rem"
42
- absoluteStrokeWidth: false, strokeWidth: "0.3rem" })) }) })));
8
+ const { _appThemeContext } = useApp();
9
+ const baseTheme = _appThemeContext.useTheme().useWith(({ color }) => {
10
+ var _a;
11
+ return ({
12
+ color: Object.assign(Object.assign({}, color), { selection: Object.assign(Object.assign({}, color.selection), { manner: p.value ? "major" : (_a = p.manner) !== null && _a !== void 0 ? _a : "flat" }) }),
13
+ });
14
+ }, [p.value, p.manner]);
15
+ return _InputSpacer(p, _jsx(WithTooltip, { tooltip: p.tooltip, children: _jsxs(WithStateTheme, { theme: baseTheme, disabled: !p.onChange, children: [_jsx("button", Object.assign({ onClick: (e) => {
16
+ var _a;
17
+ (_a = p.onChange) === null || _a === void 0 ? void 0 : _a.call(p, !p.value);
18
+ e.stopPropagation();
19
+ } }, applyProps("switch", Object.assign({ role: "switch" }, p), ["elbe_colored"], Object.assign(Object.assign({}, styleBorderFromContext), { minHeight: 0, minWidth: 0, filter: p.onChange ? "" : "grayscale(1)", opacity: p.onChange ? "" : "0.5", height: "1.8rem", width: "2.7rem", position: "relative", padding: 0, display: "flex", alignItems: "center", cursor: "inherit", transition: baseTheme.theme.motion.reduced
20
+ ? "none"
21
+ : "background-color 0.25s" })), { children: _jsx("div", { style: {
22
+ position: "absolute",
23
+ left: p.value ? "1.2rem" : "0.4rem",
24
+ height: ".8rem",
25
+ width: ".8rem",
26
+ display: "flex",
27
+ alignItems: "center",
28
+ justifyContent: "center",
29
+ transition: baseTheme.theme.motion.reduced
30
+ ? "none"
31
+ : "left 0.25s",
32
+ }, children: p.value ? (_jsx(CheckIcon, { color: "var(--elbe-context-color-front)", strokeWidth: "0.25rem" })) : (_jsx(XIcon, { color: "var(--elbe-context-color-front)", strokeWidth: "0.25rem" })) }) })), " "] }) }));
43
33
  }
44
34
  export function _InputSpacer(p, children) {
45
35
  return (_jsx("div", { onClick: () => { var _a; return (_a = p.onChange) === null || _a === void 0 ? void 0 : _a.call(p, !p.value); }, style: {
@@ -1,28 +1,23 @@
1
- import React from "react";
2
- import { ElbeProps } from "../../base/box";
1
+ import { ElbeActionProps } from "../../base/box";
2
+ import { LabeledInputProps } from "../_labeled_input";
3
3
  import { SLInputFieldProps } from "./single_line";
4
- export type InputFieldProps = {
5
- id?: string;
6
- label: string;
7
- hideLabel?: boolean;
4
+ export type InputFieldProps = ElbeActionProps & LabeledInputProps & {
8
5
  hint?: string;
9
6
  value: string | number;
10
7
  onInput?: (value: string) => void;
11
- width?: number;
12
8
  infoMessage?: string;
13
9
  warningMessage?: string;
14
10
  errorMessage?: string;
15
11
  successMessage?: string;
16
- } & ElbeProps;
17
- export declare class Field<T extends InputFieldProps> extends React.Component<T & {
18
- type: "text" | "number" | "password" | "date" | "time" | "email" | "area";
19
- }> {
20
- static text: (p: SLInputFieldProps) => import("react/jsx-runtime").JSX.Element;
21
- static number: (p: SLInputFieldProps) => import("react/jsx-runtime").JSX.Element;
22
- static password: (p: SLInputFieldProps) => import("react/jsx-runtime").JSX.Element;
23
- static date: (p: SLInputFieldProps) => import("react/jsx-runtime").JSX.Element;
24
- static time: (p: SLInputFieldProps) => import("react/jsx-runtime").JSX.Element;
25
- static email: (p: SLInputFieldProps) => import("react/jsx-runtime").JSX.Element;
26
- static multiLine: (p: InputFieldProps) => import("react/jsx-runtime").JSX.Element;
27
- render(): import("react/jsx-runtime").JSX.Element;
12
+ };
13
+ type SingleLineInputFieldProps = InputFieldProps & SLInputFieldProps;
14
+ export declare namespace Field {
15
+ function text(p: SingleLineInputFieldProps): import("react/jsx-runtime").JSX.Element;
16
+ function number(p: SingleLineInputFieldProps): import("react/jsx-runtime").JSX.Element;
17
+ function password(p: SingleLineInputFieldProps): import("react/jsx-runtime").JSX.Element;
18
+ function date(p: SingleLineInputFieldProps): import("react/jsx-runtime").JSX.Element;
19
+ function time(p: SingleLineInputFieldProps): import("react/jsx-runtime").JSX.Element;
20
+ function email(p: SingleLineInputFieldProps): import("react/jsx-runtime").JSX.Element;
21
+ function multiLine(p: InputFieldProps): import("react/jsx-runtime").JSX.Element;
28
22
  }
23
+ export {};
@@ -1,71 +1,73 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
- import React from "react";
14
2
  import { KindAlertIcon, Text } from "../../../..";
3
+ import { useApp } from "../../../app/app_ctxt";
15
4
  import { randomAlphaNum } from "../../../util/util";
16
- import { applyProps } from "../../base/box";
17
5
  import { Card } from "../../base/card";
18
6
  import { Row } from "../../layout/flex";
7
+ import { LabeledInput } from "../_labeled_input";
19
8
  import { _MultiLineField } from "./multi_line";
20
9
  import { _SingleLineField } from "./single_line";
21
- export class Field extends React.Component {
22
- render() {
23
- var _a, _b, _c;
24
- const _d = this.props, { label, hint, type, value, onInput } = _d, elbe = __rest(_d, ["label", "hint", "type", "value", "onInput"]);
25
- const id = (_a = this.props.id) !== null && _a !== void 0 ? _a : randomAlphaNum(8, "input_field_");
26
- const msg = this.props
27
- .errorMessage
28
- ? { kind: "error", msg: this.props.errorMessage }
29
- : this.props.warningMessage
30
- ? { kind: "warning", msg: this.props.warningMessage }
31
- : this.props.infoMessage
32
- ? { kind: "info", msg: this.props.infoMessage }
33
- : this.props.successMessage
34
- ? { kind: "success", msg: this.props.successMessage }
10
+ export var Field;
11
+ (function (Field) {
12
+ function text(p) {
13
+ return _jsx(_Field, Object.assign({}, p, { inputType: "text" }));
14
+ }
15
+ Field.text = text;
16
+ function number(p) {
17
+ return _jsx(_Field, Object.assign({}, p, { inputType: "number" }));
18
+ }
19
+ Field.number = number;
20
+ function password(p) {
21
+ return _jsx(_Field, Object.assign({}, p, { inputType: "password" }));
22
+ }
23
+ Field.password = password;
24
+ function date(p) {
25
+ return _jsx(_Field, Object.assign({}, p, { inputType: "date" }));
26
+ }
27
+ Field.date = date;
28
+ function time(p) {
29
+ return _jsx(_Field, Object.assign({}, p, { inputType: "time" }));
30
+ }
31
+ Field.time = time;
32
+ function email(p) {
33
+ return _jsx(_Field, Object.assign({}, p, { inputType: "email" }));
34
+ }
35
+ Field.email = email;
36
+ function multiLine(p) {
37
+ return _jsx(_Field, Object.assign({}, p, { inputType: "area" }));
38
+ }
39
+ Field.multiLine = multiLine;
40
+ })(Field || (Field = {}));
41
+ function _Field(p) {
42
+ var _a, _b;
43
+ {
44
+ const { _appThemeContext } = useApp();
45
+ const usedTheme = _appThemeContext.useTheme();
46
+ const id = (_a = p.id) !== null && _a !== void 0 ? _a : randomAlphaNum(8, "input_field_");
47
+ const manner = (_b = p.manner) !== null && _b !== void 0 ? _b : "plain";
48
+ const msg = p.errorMessage
49
+ ? { kind: "error", msg: p.errorMessage }
50
+ : p.warningMessage
51
+ ? { kind: "warning", msg: p.warningMessage }
52
+ : p.infoMessage
53
+ ? { kind: "info", msg: p.infoMessage }
54
+ : p.successMessage
55
+ ? { kind: "success", msg: p.successMessage }
35
56
  : null;
36
- return (_jsxs("div", { style: {
37
- flex: this.props.flex
38
- ? this.props.flex === true
39
- ? 1
40
- : this.props.flex
41
- : undefined,
42
- width: this.props.flex ? undefined : ((_b = this.props.width) !== null && _b !== void 0 ? _b : 12) + "rem",
43
- display: "flex",
44
- flexDirection: "column",
45
- alignItems: "stretch",
46
- filter: this.props.onInput ? undefined : "grayscale(1) opacity(0.5)",
47
- pointerEvents: this.props.onInput ? undefined : "none",
48
- cursor: this.props.onInput ? undefined : "not-allowed",
49
- }, "data-tooltip": (_c = this.props) === null || _c === void 0 ? void 0 : _c.tooltip, children: [_jsx("label", { htmlFor: id, style: {
50
- display: this.props.hideLabel ? "none" : "block",
51
- fontSize: "0.8rem",
52
- padding: "0.2rem 0.5rem",
53
- }, children: label }), _jsxs(Card, { style: {
54
- display: "flex",
55
- flexDirection: "column",
56
- alignItems: "stretch",
57
- border: "none",
58
- }, kind: msg === null || msg === void 0 ? void 0 : msg.kind, padding: 0, manner: msg ? "major" : "plain", children: [_jsx(Card, { padding: 0, style: {
59
- border: "none",
60
- }, kind: "plain", children: _jsx(Card, Object.assign({ kind: msg === null || msg === void 0 ? void 0 : msg.kind, manner: msg ? "minor" : "plain", overflow: "hidden", padding: 0, bordered: true }, applyProps("text-field", elbe, ["text_field_base"], this.props.style), { children: type === "area" ? (_jsx(_MultiLineField, { props: this.props, id: id })) : (_jsx(_SingleLineField, { props: this.props, msg: msg, type: type !== null && type !== void 0 ? type : "text", id: id })) })) }), msg && (_jsxs(Row, { gap: 0.5, style: {
61
- padding: "0.25rem 0.5rem",
62
- }, children: [_jsx(KindAlertIcon, { kind: msg.kind, size: "body-s" }), _jsx(Text.s, { bold: true, v: msg.msg, flex: true })] }))] })] }));
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
63
+ // inner card for input only
64
+ , {
65
+ // inner card for input only
66
+ kind: msg === null || msg === void 0 ? void 0 : msg.kind, manner: msg ? "minor" : undefined, overflow: "hidden", padding: 0, bordered: true, style: {
67
+ transition: "none",
68
+ }, children: p.inputType === "area" ? (_jsx(_MultiLineField, { props: p, id: id })) : (_jsx(_SingleLineField, { leading: p.leading, trailing: p.trailing, onLeadingTap: p.onLeadingTap, onTrailingTap: p.onTrailingTap, onInput: p.onInput, value: String(p.value), hint: p.hint, inputType: p.inputType, message: msg, manner: manner })) }), msg && (_jsxs(Row, { gap: 0.5, style: {
69
+ padding: "0.25rem 0.5rem",
70
+ marginBottom: `${usedTheme.theme.geometry.borderWidth}rem`,
71
+ }, children: [_jsx(KindAlertIcon, { kind: msg.kind, size: "body-s" }), _jsx(Text.s, { bold: true, v: msg.msg, flex: true })] }))] }) })));
63
72
  }
64
73
  }
65
- Field.text = (p) => _jsx(Field, Object.assign({}, p, { type: "text" }));
66
- Field.number = (p) => _jsx(Field, Object.assign({}, p, { type: "number" }));
67
- Field.password = (p) => _jsx(Field, Object.assign({}, p, { type: "password" }));
68
- Field.date = (p) => _jsx(Field, Object.assign({}, p, { type: "date" }));
69
- Field.time = (p) => _jsx(Field, Object.assign({}, p, { type: "time" }));
70
- Field.email = (p) => _jsx(Field, Object.assign({}, p, { type: "email" }));
71
- Field.multiLine = (p) => _jsx(Field, Object.assign({}, p, { type: "area" }));
@@ -1,18 +1,20 @@
1
- import { ElbeAlertKinds, IconChild, InputFieldProps } from "../../../..";
1
+ import { ColorSelection, IconChild } from "../../../..";
2
2
  type _InputMsg = {
3
- kind: ElbeAlertKinds;
3
+ kind: ColorSelection.KindsAlert;
4
4
  msg: string;
5
5
  };
6
- export interface SLInputFieldProps extends InputFieldProps {
6
+ export type SLInputFieldProps = {
7
7
  leading?: IconChild;
8
8
  onLeadingTap?: () => void;
9
9
  trailing?: IconChild;
10
10
  onTrailingTap?: () => void;
11
- }
12
- export declare function _SingleLineField(p: {
13
- props: SLInputFieldProps;
14
- msg: _InputMsg | null;
15
- type: string;
16
- id: string;
11
+ onInput?: (value: string) => void;
12
+ value: string;
13
+ hint?: string;
14
+ manner?: ColorSelection.Manners;
15
+ message?: _InputMsg | null;
16
+ };
17
+ export declare function _SingleLineField(p: SLInputFieldProps & {
18
+ inputType: string;
17
19
  }): import("react/jsx-runtime").JSX.Element;
18
20
  export {};
@@ -1,28 +1,22 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { applyProps, Card, IconButton, Row, Spaced, } from "../../../..";
2
+ import { IconButton, Row, Spaced, } from "../../../..";
3
3
  export function _SingleLineField(p) {
4
- var _a, _b, _c;
5
- return (_jsxs(Row, { gap: 0, children: [_jsx(_Supplement, { kind: (_a = p.msg) === null || _a === void 0 ? void 0 : _a.kind, icon: p.props.leading, onTap: p.props.onLeadingTap }), _jsx("input", Object.assign({ type: p.type }, applyProps("text_field", Object.assign(Object.assign({}, p.props), { id: p.id, ariaLabel: (_b = p.props.ariaLabel) !== null && _b !== void 0 ? _b : p.props.label }), null, {
6
- width: "100%",
7
- height: "3rem",
8
- flex: 1,
9
- border: "none",
10
- outline: "none",
11
- background: "none",
12
- }), { size: 5, placeholder: p.props.hint, value: p.props.value, onInput: (e) => p.props.onInput && p.props.onInput(e.currentTarget.value), readOnly: p.props.onInput ? false : true })), _jsx(_Supplement, { kind: (_c = p.msg) === null || _c === void 0 ? void 0 : _c.kind, trailing: true, icon: p.props.trailing, onTap: p.props.onTrailingTap })] }));
4
+ var _a, _b, _c, _d;
5
+ return (_jsxs(Row, { gap: 0, children: [_jsx(_Supplement, { kind: (_a = p.message) === null || _a === void 0 ? void 0 : _a.kind, icon: p.leading, onMessage: !!p.message, onEnabled: !!p.onInput, onTap: p.onLeadingTap, manner: (_b = p.manner) !== null && _b !== void 0 ? _b : "plain" }), _jsx("input", { type: p.inputType, style: {
6
+ width: "100%",
7
+ height: "3rem",
8
+ flex: 1,
9
+ border: "none",
10
+ outline: "none",
11
+ background: "none",
12
+ }, size: 5, placeholder: p.hint, value: p.value, onInput: (e) => p.onInput && p.onInput(e.currentTarget.value), readOnly: p.onInput ? false : true }), _jsx(_Supplement, { kind: (_c = p.message) === null || _c === void 0 ? void 0 : _c.kind, trailing: true, icon: p.trailing, onMessage: !!p.message, onEnabled: !!p.onInput, onTap: p.onTrailingTap, manner: (_d = p.manner) !== null && _d !== void 0 ? _d : "plain" })] }));
13
13
  }
14
14
  function _Supplement(p) {
15
15
  if (!p.icon)
16
16
  return _jsx(Spaced, { width: 0.75 });
17
- return (_jsx(Card, { sharp: true, padding: 0, style: {
18
- border: "none",
19
- background: p.onTap ? undefined : "transparent",
20
- }, children: _jsx(IconButton, { kind: p.kind, manner: p.kind ? "minor" : "plain", ariaLabel: p.trailing ? "trailing icon" : "leading icon", icon: p.icon, style: {
21
- borderRadius: 0,
22
- background: p.onTap ? undefined : "transparent",
23
- }, onTap: (e) => {
24
- var _a;
25
- e.stopPropagation();
26
- (_a = p.onTap) === null || _a === void 0 ? void 0 : _a.call(p);
27
- } }) }));
17
+ return (_jsx(IconButton, { kind: p.kind, manner: p.onMessage ? "minor" : p.manner, ariaLabel: p.trailing ? "trailing icon" : "leading icon", icon: p.icon, style: {
18
+ borderRadius: 0,
19
+ transition: "none",
20
+ backgroundColor: p.onEnabled ? undefined : "transparent",
21
+ }, onTap: p.onTap && p.onEnabled ? () => { var _a; return (_a = p.onTap) === null || _a === void 0 ? void 0 : _a.call(p); } : undefined }));
28
22
  }
@@ -6,9 +6,13 @@ export type FlexProps = {
6
6
  noScrollbar?: boolean;
7
7
  main?: "start" | "center" | "end" | "stretch" | "space-between" | "space-around" | "space-evenly";
8
8
  cross?: "start" | "center" | "end" | "stretch" | "space-between" | "space-around" | "space-evenly";
9
- } & ElbeProps;
9
+ };
10
10
  export declare function FlexSpace({}: {}): import("react/jsx-runtime").JSX.Element;
11
- export declare function Column({ gap, main, cross, children, noScrollbar, scroll, ...p }: FlexProps): import("react/jsx-runtime").JSX.Element;
12
- export declare function Row({ gap, main, cross, wrap, children, noScrollbar, scroll, ...p }: FlexProps & {
11
+ export declare function Column({ gap, main, cross, children, noScrollbar, scroll, ...p }: FlexProps & ElbeProps): import("react/jsx-runtime").JSX.Element;
12
+ export declare function Row({ gap, main, cross, wrap, children, noScrollbar, scroll, ...p }: FlexProps & ElbeProps & {
13
+ wrap?: boolean;
14
+ }): import("react/jsx-runtime").JSX.Element;
15
+ export declare function FlexLayout({ gap, main, cross, direction, children, noScrollbar, scroll, wrap, ...p }: FlexProps & ElbeProps & {
16
+ direction?: "row" | "column";
13
17
  wrap?: boolean;
14
18
  }): import("react/jsx-runtime").JSX.Element;