@memobit/libs 3.26.4 → 3.28.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 (47) hide show
  1. package/dist/components/Banner/Banner2.js +15 -13
  2. package/dist/components/BoldText/BoldText.js +5 -0
  3. package/dist/components/Calendar/Calendar2.js +108 -135
  4. package/dist/components/ColorPicker/ColorPicker.css +1 -1
  5. package/dist/components/ColorPicker/ColorPicker2.js +114 -114
  6. package/dist/components/ConfirmDialog/ConfirmDialog2.js +13 -11
  7. package/dist/components/ConfirmPopover/ConfirmPopover2.js +26 -24
  8. package/dist/components/ContextMenu/ContextMenu2.js +46 -33
  9. package/dist/components/ControlPanel/ControlPanel2.js +95 -93
  10. package/dist/components/ControlPanel/ControlPanelFilter.js +205 -193
  11. package/dist/components/ControlPanel/ControlPanelOptions.js +190 -185
  12. package/dist/components/DataView/DataView.CardView.js +83 -81
  13. package/dist/components/DataView/DataView.ColumnSelector.js +27 -25
  14. package/dist/components/DataView/DataView.TableView.js +74 -72
  15. package/dist/components/DataView/DataView2.js +169 -167
  16. package/dist/components/DatePicker/DatePicker2.js +71 -69
  17. package/dist/components/Drawer/Drawer2.js +58 -55
  18. package/dist/components/Dropdown/Dropdown2.js +187 -189
  19. package/dist/components/InputDate/InputDate2.js +43 -41
  20. package/dist/components/InputSearch/InputSearch2.js +27 -25
  21. package/dist/components/MenuBar/MenuBar.css +1 -0
  22. package/dist/components/MenuBar/MenuBar2.js +46 -0
  23. package/dist/components/Modal/Modal2.js +49 -47
  24. package/dist/components/Pagination/Pagination2.js +44 -47
  25. package/dist/components/ScrollToTop/ScrollToTop2.js +18 -16
  26. package/dist/components/ThemeSettings/ThemeSettings2.js +131 -123
  27. package/dist/components/TipsOfTheDay/TipsOfTheDay2.js +16 -12
  28. package/dist/components/Toast/Toast2.js +38 -33
  29. package/dist/components/ToolButton/ToolButton.css +1 -0
  30. package/dist/components/ToolButton/ToolButton2.js +36 -0
  31. package/dist/components/ToolPalette/ToolPalette.css +1 -0
  32. package/dist/components/ToolPalette/ToolPalette2.js +83 -0
  33. package/dist/components/Toolbar/Toolbar2.js +58 -56
  34. package/dist/contexts/LanguageContext/LanguageContext.context.js +9 -0
  35. package/dist/contexts/LanguageContext/LanguageContext.js +19 -0
  36. package/dist/contexts/LanguageContext/libMessages.js +240 -0
  37. package/dist/helpers/Datetime.js +84 -68
  38. package/dist/helpers/Language.js +8 -0
  39. package/dist/helpers/Pagination.js +5 -4
  40. package/dist/helpers/VersionInfo.js +1 -1
  41. package/dist/hooks/useLanguage.js +16 -0
  42. package/dist/index.d.ts +133 -6
  43. package/dist/index.js +417 -399
  44. package/dist/memobit-icons.json +4 -0
  45. package/dist/version.js +2 -2
  46. package/dist/version.json +4 -4
  47. package/package.json +1 -1
@@ -1,197 +1,205 @@
1
1
  import './ThemeSettings.css';
2
- import { useTheme as H } from "./useTheme.js";
3
- import { Checkbox as Q } from "../Checkbox/Checkbox2.js";
4
- import { Dropdown as V } from "../Dropdown/Dropdown2.js";
5
- import { InputSearch as W } from "../InputSearch/InputSearch2.js";
6
- import { Drawer as K } from "../Drawer/Drawer2.js";
2
+ import { libMessages as W } from "../../contexts/LanguageContext/libMessages.js";
3
+ import { useTheme as K } from "./useTheme.js";
4
+ import { useMessages as U } from "../../hooks/useLanguage.js";
5
+ import { Checkbox as B } from "../Checkbox/Checkbox2.js";
6
+ import { Dropdown as J } from "../Dropdown/Dropdown2.js";
7
+ import { InputSearch as X } from "../InputSearch/InputSearch2.js";
8
+ import { Drawer as Y } from "../Drawer/Drawer2.js";
7
9
  import { ToggleSwitch as L } from "../ToggleSwitch/ToggleSwitch2.js";
8
- import { FAVORITE_THEMES as k, THEME_CONFIGS as U, getThemeAppearance as B } from "./themeConfig.js";
10
+ import { FAVORITE_THEMES as A, THEME_CONFIGS as Z, getThemeAppearance as ee } from "./themeConfig.js";
9
11
  /* empty css */
10
- import { useEffect as x, useMemo as J, useRef as R, useState as v } from "react";
11
- import { Fragment as X, jsx as t, jsxs as a } from "react/jsx-runtime";
12
- import { previewPalettes as Y } from "@memobit/themes";
13
- var Z = [
14
- {
15
- value: "all",
16
- label: "All"
17
- },
18
- {
19
- value: "light",
20
- label: "Light"
21
- },
22
- {
23
- value: "dark",
24
- label: "Dark"
25
- }
26
- ], de = ({ isOpen: r, onClose: g, allowedThemes: d, currentApp: o, showEffects: I = !0, showSearch: w = !0, showFavorites: b = !0, showAppearanceFilter: P = !0 }) => {
27
- const { theme: f, effects: n, setPreviewTheme: $, setPreviewEffects: N, commitPreview: M, clearPreview: D } = H(), O = ["Card", "Modal"], j = [
12
+ import { useEffect as M, useMemo as te, useRef as I, useState as v } from "react";
13
+ import { Fragment as se, jsx as t, jsxs as l } from "react/jsx-runtime";
14
+ import { previewPalettes as ae } from "@memobit/themes";
15
+ var _e = ({ isOpen: o, onClose: w, allowedThemes: d, currentApp: m, showEffects: R = !0, showSearch: b = !0, showFavorites: N = !0, showAppearanceFilter: P = !0 }) => {
16
+ const s = U(W), { theme: p, effects: i, setPreviewTheme: D, setPreviewEffects: C, commitPreview: O, clearPreview: $ } = K(), j = [
28
17
  {
29
- label: "None",
18
+ value: "all",
19
+ label: s.appearanceAll
20
+ },
21
+ {
22
+ value: "light",
23
+ label: s.appearanceLight
24
+ },
25
+ {
26
+ value: "dark",
27
+ label: s.appearanceDark
28
+ }
29
+ ], q = [{
30
+ value: "Card",
31
+ label: s.effectComponentCard
32
+ }, {
33
+ value: "Modal",
34
+ label: s.effectComponentModal
35
+ }], z = [
36
+ {
37
+ label: s.effectNone,
30
38
  value: ""
31
39
  },
32
40
  {
33
- label: "Note Container",
41
+ label: s.effectNoteContainer,
34
42
  value: "note-container-effect"
35
43
  },
36
44
  {
37
- label: "Infuse",
45
+ label: s.effectInfuse,
38
46
  value: "infuse-effect"
39
47
  },
40
48
  {
41
- label: "Up Lift",
49
+ label: s.effectUpLift,
42
50
  value: "up-lift-effect"
43
51
  },
44
52
  {
45
- label: "Glow",
53
+ label: s.effectGlow,
46
54
  value: "glow-effect"
47
55
  }
48
- ], [i, C] = v(""), [m, y] = v(!1), [h, S] = v(!1), [c, F] = v("all"), E = R(null), p = R(!1), _ = o?.trim().toLowerCase() ?? "", T = J(() => {
49
- let e = U;
56
+ ], [c, y] = v(""), [h, T] = v(!1), [f, F] = v(!1), [r, E] = v("all"), S = I(null), u = I(!1), _ = m?.trim().toLowerCase() ?? "", k = te(() => {
57
+ let e = Z;
50
58
  if (d && d.length > 0) {
51
- const s = new Set(d);
52
- e = e.filter((l) => s.has(l.value));
59
+ const a = new Set(d);
60
+ e = e.filter((n) => a.has(n.value));
53
61
  }
54
- if (m && (e = e.filter((s) => k.has(s.value))), h && _ && (e = e.filter((s) => (s.recommendedApps ?? []).some((l) => l.toLowerCase() === _))), c !== "all" && (e = e.filter((s) => B(s.value) === c)), i.trim()) {
55
- const s = i.toLowerCase().trim();
56
- e = e.filter((l) => l.label.toLowerCase().includes(s) || (l.recommendedApps ?? []).some((u) => u.toLowerCase().includes(s)));
62
+ if (h && (e = e.filter((a) => A.has(a.value))), f && _ && (e = e.filter((a) => (a.recommendedApps ?? []).some((n) => n.toLowerCase() === _))), r !== "all" && (e = e.filter((a) => ee(a.value) === r)), c.trim()) {
63
+ const a = c.toLowerCase().trim();
64
+ e = e.filter((n) => n.label.toLowerCase().includes(a) || (n.recommendedApps ?? []).some((g) => g.toLowerCase().includes(a)));
57
65
  }
58
66
  return e;
59
67
  }, [
60
- i,
61
- m,
68
+ c,
62
69
  h,
70
+ f,
63
71
  _,
64
- c,
72
+ r,
65
73
  d
66
74
  ]);
67
- x(() => {
68
- r ? (C(""), y(!1), S(!1), F("all")) : p.current = !1;
69
- }, [r]), x(() => {
70
- if (!r || i || m || h || c !== "all" || p.current) return;
75
+ M(() => {
76
+ o ? (y(""), T(!1), F(!1), E("all")) : u.current = !1;
77
+ }, [o]), M(() => {
78
+ if (!o || c || h || f || r !== "all" || u.current) return;
71
79
  const e = window.requestAnimationFrame(() => {
72
- E.current?.scrollIntoView({
80
+ S.current?.scrollIntoView({
73
81
  block: "center",
74
82
  inline: "nearest"
75
- }), p.current = !0;
83
+ }), u.current = !0;
76
84
  });
77
85
  return () => window.cancelAnimationFrame(e);
78
86
  }, [
79
- r,
80
- i,
81
- m,
82
- h,
87
+ o,
83
88
  c,
84
- f
89
+ h,
90
+ f,
91
+ r,
92
+ p
85
93
  ]);
86
- const q = (e) => {
87
- $(e);
88
- }, z = (e) => {
89
- const s = !e || Array.isArray(e) ? "" : e.value;
90
- N({
91
- effect: s,
92
- components: n.components
94
+ const G = (e) => {
95
+ D(e);
96
+ }, H = (e) => {
97
+ const a = !e || Array.isArray(e) ? "" : e.value;
98
+ C({
99
+ effect: a,
100
+ components: i.components
93
101
  });
94
- }, G = (e, s) => {
95
- const l = s ? [...n.components, e] : n.components.filter((u) => u !== e);
96
- N({
97
- effect: n.effect,
98
- components: l
102
+ }, Q = (e, a) => {
103
+ const n = a ? [...i.components, e] : i.components.filter((g) => g !== e);
104
+ C({
105
+ effect: i.effect,
106
+ components: n
99
107
  });
100
- }, A = () => {
101
- D(), g();
108
+ }, x = () => {
109
+ $(), w();
110
+ }, V = () => {
111
+ O(), w();
102
112
  };
103
- return /* @__PURE__ */ t(K, {
104
- isOpen: r,
105
- onClose: A,
106
- title: "Theme Settings",
113
+ return /* @__PURE__ */ t(Y, {
114
+ isOpen: o,
115
+ onClose: x,
116
+ title: s.themeSettings,
107
117
  position: "right",
108
118
  width: "520px",
109
119
  maxWidth: "calc(100vw - 32px)",
110
120
  className: "theme-settings-drawer",
111
121
  secondary: {
112
- text: "Cancel",
122
+ text: s.cancel,
113
123
  variant: "default",
114
- onClick: A,
124
+ onClick: x,
115
125
  icon: "clear"
116
126
  },
117
127
  primary: {
118
- text: "Save changes",
128
+ text: s.saveChanges,
119
129
  variant: "success",
120
- onClick: () => {
121
- M(), g();
122
- },
130
+ onClick: V,
123
131
  icon: "save"
124
132
  },
125
133
  children: /* @__PURE__ */ t("div", {
126
134
  className: "theme-settings",
127
- children: /* @__PURE__ */ a("div", {
135
+ children: /* @__PURE__ */ l("div", {
128
136
  className: "theme-settings__content",
129
- children: [/* @__PURE__ */ a("div", {
137
+ children: [/* @__PURE__ */ l("div", {
130
138
  className: "theme-settings__section",
131
139
  children: [
132
- /* @__PURE__ */ t("label", { children: "Select Theme" }),
133
- (w || b || o) && /* @__PURE__ */ a("div", {
140
+ /* @__PURE__ */ t("label", { children: s.selectTheme }),
141
+ (b || N || m) && /* @__PURE__ */ l("div", {
134
142
  className: "theme-settings__toolbar",
135
143
  children: [
136
- w && /* @__PURE__ */ t(W, {
137
- placeholder: "Search themes...",
138
- value: i,
139
- onChange: C
144
+ b && /* @__PURE__ */ t(X, {
145
+ placeholder: s.searchThemes,
146
+ value: c,
147
+ onChange: y
140
148
  }),
141
- o && /* @__PURE__ */ t(L, {
142
- checked: h,
143
- onChange: S,
144
- onLabel: `For ${o}`,
145
- offLabel: `For ${o}`,
149
+ m && /* @__PURE__ */ t(L, {
150
+ checked: f,
151
+ onChange: F,
152
+ onLabel: s.themesForApp(m),
153
+ offLabel: s.themesForApp(m),
146
154
  size: "small"
147
155
  }),
148
- b && /* @__PURE__ */ t(L, {
149
- checked: m,
150
- onChange: y,
151
- onLabel: "Favorites",
152
- offLabel: "Favorites",
156
+ N && /* @__PURE__ */ t(L, {
157
+ checked: h,
158
+ onChange: T,
159
+ onLabel: s.favorites,
160
+ offLabel: s.favorites,
153
161
  size: "small"
154
162
  })
155
163
  ]
156
164
  }),
157
165
  P && /* @__PURE__ */ t("div", {
158
166
  className: "theme-settings__appearance",
159
- children: Z.map((e) => /* @__PURE__ */ t("button", {
167
+ children: j.map((e) => /* @__PURE__ */ t("button", {
160
168
  type: "button",
161
- className: `theme-settings__appearance-option ${c === e.value ? "theme-settings__appearance-option--active" : ""}`,
162
- onClick: () => F(e.value),
169
+ className: `theme-settings__appearance-option ${r === e.value ? "theme-settings__appearance-option--active" : ""}`,
170
+ onClick: () => E(e.value),
163
171
  children: e.label
164
172
  }, e.value))
165
173
  }),
166
174
  /* @__PURE__ */ t("div", {
167
175
  className: "theme-settings__grid",
168
- children: T.length === 0 ? /* @__PURE__ */ t("div", {
176
+ children: k.length === 0 ? /* @__PURE__ */ t("div", {
169
177
  className: "theme-settings__empty",
170
- children: "No themes found"
171
- }) : T.map((e) => /* @__PURE__ */ a("button", {
172
- ref: f === e.value ? E : null,
178
+ children: s.noThemes
179
+ }) : k.map((e) => /* @__PURE__ */ l("button", {
180
+ ref: p === e.value ? S : null,
173
181
  type: "button",
174
- className: `theme-settings__swatch ${f === e.value ? "theme-settings__swatch--active" : ""}`,
175
- onClick: () => q(e.value),
176
- children: [/* @__PURE__ */ a("div", {
182
+ className: `theme-settings__swatch ${p === e.value ? "theme-settings__swatch--active" : ""}`,
183
+ onClick: () => G(e.value),
184
+ children: [/* @__PURE__ */ l("div", {
177
185
  className: "theme-settings__preview",
178
- style: Y[e.value],
186
+ style: ae[e.value],
179
187
  children: [
180
- k.has(e.value) && /* @__PURE__ */ t("span", {
188
+ A.has(e.value) && /* @__PURE__ */ t("span", {
181
189
  className: "theme-settings__favorite-badge",
182
190
  children: "⭐"
183
191
  }),
184
192
  /* @__PURE__ */ t("div", { className: "theme-settings__preview-header" }),
185
- /* @__PURE__ */ a("div", {
193
+ /* @__PURE__ */ l("div", {
186
194
  className: "theme-settings__preview-body",
187
- children: [/* @__PURE__ */ a("div", {
195
+ children: [/* @__PURE__ */ l("div", {
188
196
  className: "theme-settings__preview-card",
189
197
  children: [
190
198
  /* @__PURE__ */ t("div", { className: "theme-settings__preview-line theme-settings__preview-line--accent" }),
191
199
  /* @__PURE__ */ t("div", { className: "theme-settings__preview-line" }),
192
200
  /* @__PURE__ */ t("div", { className: "theme-settings__preview-line theme-settings__preview-line--short" })
193
201
  ]
194
- }), /* @__PURE__ */ a("div", {
202
+ }), /* @__PURE__ */ l("div", {
195
203
  className: "theme-settings__preview-sidebar",
196
204
  children: [
197
205
  /* @__PURE__ */ t("div", { className: "theme-settings__preview-dot" }),
@@ -211,29 +219,29 @@ var Z = [
211
219
  }, e.value))
212
220
  })
213
221
  ]
214
- }), I && /* @__PURE__ */ a(X, { children: [/* @__PURE__ */ a("div", {
222
+ }), R && /* @__PURE__ */ l(se, { children: [/* @__PURE__ */ l("div", {
215
223
  className: "theme-settings__section",
216
224
  children: [/* @__PURE__ */ t("label", {
217
225
  htmlFor: "effect-selector",
218
- children: "Component Effect"
219
- }), /* @__PURE__ */ t(V, {
226
+ children: s.componentEffect
227
+ }), /* @__PURE__ */ t(J, {
220
228
  id: "effect-selector",
221
229
  name: "effect",
222
- options: j,
223
- value: n.effect,
224
- onChange: z,
225
- placeholder: "Choose an effect"
230
+ options: z,
231
+ value: i.effect,
232
+ onChange: H,
233
+ placeholder: s.chooseEffect
226
234
  })]
227
- }), /* @__PURE__ */ a("div", {
235
+ }), /* @__PURE__ */ l("div", {
228
236
  className: "theme-settings__section",
229
- children: [/* @__PURE__ */ t("label", { children: "Apply Effect To:" }), /* @__PURE__ */ t("div", {
237
+ children: [/* @__PURE__ */ t("label", { children: s.applyEffectTo }), /* @__PURE__ */ t("div", {
230
238
  className: "theme-settings__components",
231
- children: O.map((e) => /* @__PURE__ */ t(Q, {
232
- label: e,
233
- checked: n.components.includes(e),
234
- onChange: (s) => G(e, s),
235
- disabled: !n.effect
236
- }, e))
239
+ children: q.map((e) => /* @__PURE__ */ t(B, {
240
+ label: e.label,
241
+ checked: i.components.includes(e.value),
242
+ onChange: (a) => Q(e.value, a),
243
+ disabled: !i.effect
244
+ }, e.value))
237
245
  })]
238
246
  })] })]
239
247
  })
@@ -241,5 +249,5 @@ var Z = [
241
249
  });
242
250
  };
243
251
  export {
244
- de as ThemeSettings
252
+ _e as ThemeSettings
245
253
  };
@@ -1,24 +1,28 @@
1
1
  import './TipsOfTheDay.css';
2
- import { Icon as e } from "../Icon/Icon2.js";
3
- import { Card as m } from "../Card/Card2.js";
2
+ import { Icon as t } from "../Icon/Icon2.js";
3
+ import { libMessages as s } from "../../contexts/LanguageContext/libMessages.js";
4
+ import { useMessages as n } from "../../hooks/useLanguage.js";
5
+ import { Card as p } from "../Card/Card2.js";
4
6
  /* empty css */
5
7
  import "react";
6
- import { jsx as o, jsxs as t } from "react/jsx-runtime";
7
- var n = (r, a) => Math.floor(Math.random() * (a - r + 1) + r), l = ({ list: r }) => {
8
- const a = n(0, r.length - 1);
9
- return /* @__PURE__ */ t(m, {
8
+ import { jsx as e, jsxs as a } from "react/jsx-runtime";
9
+ var i = (r, o) => Math.floor(Math.random() * (o - r + 1) + r), g = ({ list: r }) => {
10
+ const o = n(s), m = i(0, r.length - 1);
11
+ return /* @__PURE__ */ a(p, {
10
12
  className: "tips-of-the-day",
11
13
  children: [
12
- /* @__PURE__ */ t("h3", { children: [
13
- /* @__PURE__ */ o(e, { name: "sparkle" }),
14
- " Tip Of The Day ",
15
- /* @__PURE__ */ o(e, { name: "sparkle" })
14
+ /* @__PURE__ */ a("h3", { children: [
15
+ /* @__PURE__ */ e(t, { name: "sparkle" }),
16
+ " ",
17
+ o.tipOfTheDay,
18
+ " ",
19
+ /* @__PURE__ */ e(t, { name: "sparkle" })
16
20
  ] }),
17
21
  " ",
18
- /* @__PURE__ */ o("h4", { children: r[a] })
22
+ /* @__PURE__ */ e("h4", { children: r[m] })
19
23
  ]
20
24
  });
21
25
  };
22
26
  export {
23
- l as TipsOfTheDay
27
+ g as TipsOfTheDay
24
28
  };
@@ -1,39 +1,44 @@
1
1
  import './Toast.css';
2
- import { Icon as m } from "../Icon/Icon2.js";
3
- import { Tooltip as n } from "../Tooltip/Tooltip2.js";
2
+ import { Icon as n } from "../Icon/Icon2.js";
3
+ import { libMessages as p } from "../../contexts/LanguageContext/libMessages.js";
4
+ import { useMessages as f } from "../../hooks/useLanguage.js";
5
+ import { Tooltip as u } from "../Tooltip/Tooltip2.js";
4
6
  /* empty css */
5
- import { useEffect as p } from "react";
6
- import { jsx as t, jsxs as u } from "react/jsx-runtime";
7
- var N = ({ message: r, type: a = "success", onClose: s, position: i = "top-right", showDismissButton: c = !0, timeout: o = 3e3, action: e }) => (p(() => {
8
- const l = setTimeout(() => {
9
- s();
10
- }, o);
11
- return () => clearTimeout(l);
12
- }, [s, o]), /* @__PURE__ */ u("div", {
13
- className: `toast toast--fixed toast-${a} toast--${i}`,
14
- children: [
15
- /* @__PURE__ */ t("span", {
16
- className: "toast__message",
17
- children: r
18
- }),
19
- e && /* @__PURE__ */ t("button", {
20
- className: "toast__action",
21
- onClick: e.onClick,
22
- children: e.label
23
- }),
24
- c && /* @__PURE__ */ t(n, {
25
- title: "Close",
26
- children: /* @__PURE__ */ t("button", {
27
- className: "toast__close",
28
- onClick: s,
29
- children: /* @__PURE__ */ t(m, {
30
- name: "clear",
31
- size: "sm"
7
+ import { useEffect as d } from "react";
8
+ import { jsx as t, jsxs as h } from "react/jsx-runtime";
9
+ var j = ({ message: r, type: a = "success", onClose: s, position: i = "top-right", showDismissButton: m = !0, timeout: o = 3e3, action: e }) => {
10
+ const c = f(p);
11
+ return d(() => {
12
+ const l = setTimeout(() => {
13
+ s();
14
+ }, o);
15
+ return () => clearTimeout(l);
16
+ }, [s, o]), /* @__PURE__ */ h("div", {
17
+ className: `toast toast--fixed toast-${a} toast--${i}`,
18
+ children: [
19
+ /* @__PURE__ */ t("span", {
20
+ className: "toast__message",
21
+ children: r
22
+ }),
23
+ e && /* @__PURE__ */ t("button", {
24
+ className: "toast__action",
25
+ onClick: e.onClick,
26
+ children: e.label
27
+ }),
28
+ m && /* @__PURE__ */ t(u, {
29
+ title: c.close,
30
+ children: /* @__PURE__ */ t("button", {
31
+ className: "toast__close",
32
+ onClick: s,
33
+ children: /* @__PURE__ */ t(n, {
34
+ name: "clear",
35
+ size: "sm"
36
+ })
32
37
  })
33
38
  })
34
- })
35
- ]
36
- }));
39
+ ]
40
+ });
41
+ };
37
42
  export {
38
- N as Toast
43
+ j as Toast
39
44
  };
@@ -0,0 +1 @@
1
+ .tool-button--active.button,.tool-button--active.button:hover{background:var(--list-hover-background-color);color:var(--body-accent-color)}.tool-button--danger.button:not(:disabled),.tool-button--danger.button:not(:disabled):hover{color:var(--body-danger-color)}.tool-button--mirrored svg{transform:scaleX(-1)}.tool-button__badged{display:flex;position:relative}.tool-button__badged--disabled{opacity:.5}.tool-button__badge{padding:0 var(--spacing-2);border-radius:var(--radius-sm);background:var(--body-accent-color);color:var(--button-info-color);font-size:var(--font-size-xxs);font-weight:var(--font-weight-bold);line-height:var(--line-height-tight);pointer-events:none;position:absolute;bottom:0;right:0}
@@ -0,0 +1,36 @@
1
+ import './ToolButton.css';
2
+ import { Button as p } from "../Button/Button2.js";
3
+ import { Tooltip as d } from "../Tooltip/Tooltip2.js";
4
+ /* empty css */
5
+ import { jsx as t, jsxs as _ } from "react/jsx-runtime";
6
+ var v = ({ icon: r, hint: a, onClick: s, disabled: o, active: e, danger: i, mirrored: m, badge: n, hintPosition: u = "bottom", className: b }) => {
7
+ const c = [
8
+ "tool-button",
9
+ m && "tool-button--mirrored",
10
+ i && "tool-button--danger",
11
+ e && "tool-button--active",
12
+ b
13
+ ].filter(Boolean).join(" "), l = /* @__PURE__ */ t(p, {
14
+ variant: "plain",
15
+ size: "small",
16
+ icon: r,
17
+ onClick: s,
18
+ disabled: o,
19
+ className: c
20
+ });
21
+ return /* @__PURE__ */ t(d, {
22
+ title: a,
23
+ position: u,
24
+ disabled: o,
25
+ children: n ? /* @__PURE__ */ _("span", {
26
+ className: `tool-button__badged${o ? " tool-button__badged--disabled" : ""}`,
27
+ children: [l, /* @__PURE__ */ t("span", {
28
+ className: "tool-button__badge",
29
+ children: n
30
+ })]
31
+ }) : l
32
+ });
33
+ };
34
+ export {
35
+ v as ToolButton
36
+ };
@@ -0,0 +1 @@
1
+ .tool-palette{--tool-palette-slot:38px;align-items:center;gap:var(--spacing-12);padding:var(--spacing-8) var(--spacing-4);background:var(--card-background-color);border-right:1px solid var(--border-color);flex-direction:column;flex:none;display:flex}.tool-palette__tools{width:calc(var(--tool-palette-slot) * var(--tool-palette-columns));flex-wrap:wrap;display:flex}.tool-palette__slot{width:var(--tool-palette-slot);justify-content:center;display:flex;position:relative}.tool-palette__slot--grouped:after{right:var(--spacing-2);bottom:var(--spacing-2);border-bottom:var(--spacing-4) solid var(--body-color-muted);border-left:var(--spacing-4) solid transparent;content:"";pointer-events:none;width:0;height:0;position:absolute}.tool-palette__menu{min-width:200px;padding:var(--spacing-4);flex-direction:column;display:flex}.tool-palette__menu-item.button{justify-content:flex-start;width:100%}.tool-palette__menu-item--active.button{color:var(--body-accent-color)}.tool-palette__menu-label{text-align:left;flex:1}.tool-palette__menu-shortcut{margin-left:var(--spacing-24);color:var(--body-color-muted);font-size:var(--font-size-xs)}
@@ -0,0 +1,83 @@
1
+ import './ToolPalette.css';
2
+ import { Button as v } from "../Button/Button2.js";
3
+ import { ContextMenu as w } from "../ContextMenu/ContextMenu2.js";
4
+ import { ToolButton as j } from "../ToolButton/ToolButton2.js";
5
+ /* empty css */
6
+ import { useState as m } from "react";
7
+ import { jsx as e, jsxs as _ } from "react/jsx-runtime";
8
+ var D = ({ items: f, activeId: n, onSelect: x, columns: $ = 2, children: b, className: h }) => {
9
+ const c = /* @__PURE__ */ new Map();
10
+ for (const t of f) {
11
+ const o = t.group ?? t.id;
12
+ c.set(o, [...c.get(o) ?? [], t]);
13
+ }
14
+ const [y, C] = m({}), [s, a] = m(null), i = (t) => t.group ?? t.id, p = (t) => t.find((o) => o.id === n) ?? t.find((o) => o.id === y[i(t[0])]) ?? t[0], r = (t) => {
15
+ C((o) => ({
16
+ ...o,
17
+ [i(t)]: t.id
18
+ })), x(t.id);
19
+ }, N = (t) => {
20
+ const o = p(t);
21
+ o.id !== n || t.length === 1 ? r(o) : r(t[(t.indexOf(o) + 1) % t.length]);
22
+ }, k = (t, o) => {
23
+ t.preventDefault(), o.length > 1 && a({
24
+ group: o,
25
+ x: t.clientX,
26
+ y: t.clientY
27
+ });
28
+ }, u = (t) => t.shortcut ? `${t.label} (${t.shortcut})` : t.label, M = { "--tool-palette-columns": $ };
29
+ return /* @__PURE__ */ _("nav", {
30
+ className: `tool-palette${h ? ` ${h}` : ""}`,
31
+ style: M,
32
+ children: [
33
+ /* @__PURE__ */ e("div", {
34
+ className: "tool-palette__tools",
35
+ children: [...c.values()].map((t) => {
36
+ const o = p(t), d = t.filter((l) => l !== o).map((l) => l.label);
37
+ return /* @__PURE__ */ e("span", {
38
+ className: `tool-palette__slot${t.length > 1 ? " tool-palette__slot--grouped" : ""}`,
39
+ onContextMenu: (l) => k(l, t),
40
+ children: /* @__PURE__ */ e(j, {
41
+ icon: o.icon,
42
+ hint: d.length > 0 ? `${u(o)} · also ${d.join(", ")}` : u(o),
43
+ hintPosition: "right",
44
+ onClick: () => N(t),
45
+ active: o.id === n
46
+ })
47
+ }, i(o));
48
+ })
49
+ }),
50
+ b,
51
+ s && /* @__PURE__ */ e(w, {
52
+ position: {
53
+ x: s.x,
54
+ y: s.y
55
+ },
56
+ onClose: () => a(null),
57
+ autoClose: !0,
58
+ children: /* @__PURE__ */ e("div", {
59
+ className: "tool-palette__menu",
60
+ children: s.group.map((t) => /* @__PURE__ */ _(v, {
61
+ variant: "plain",
62
+ size: "small",
63
+ icon: t.icon,
64
+ className: `tool-palette__menu-item${t.id === n ? " tool-palette__menu-item--active" : ""}`,
65
+ onClick: () => {
66
+ a(null), r(t);
67
+ },
68
+ children: [/* @__PURE__ */ e("span", {
69
+ className: "tool-palette__menu-label",
70
+ children: t.label
71
+ }), t.shortcut && /* @__PURE__ */ e("span", {
72
+ className: "tool-palette__menu-shortcut",
73
+ children: t.shortcut
74
+ })]
75
+ }, t.id))
76
+ })
77
+ })
78
+ ]
79
+ });
80
+ };
81
+ export {
82
+ D as ToolPalette
83
+ };