@hellboy/ds 0.1.3 → 0.2.7
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/README.md +512 -162
- package/{src/style/components/badge → dist/components}/badge.css +9 -25
- package/dist/components/badge.d.mts +12 -0
- package/dist/components/badge.d.ts +12 -0
- package/dist/components/badge.js +42 -0
- package/dist/components/badge.mjs +15 -0
- package/dist/components/banner.css +280 -0
- package/dist/components/banner.d.mts +12 -0
- package/dist/components/banner.d.ts +12 -0
- package/dist/components/banner.js +184 -0
- package/dist/components/banner.mjs +147 -0
- package/dist/components/button-group.css +289 -0
- package/dist/components/button-group.d.mts +81 -0
- package/dist/components/button-group.d.ts +81 -0
- package/dist/components/button-group.js +180 -0
- package/dist/components/button-group.mjs +143 -0
- package/{src/style/components/button → dist/components}/button.css +59 -62
- package/dist/components/button.d.mts +57 -0
- package/dist/components/button.d.ts +57 -0
- package/dist/components/button.js +129 -0
- package/dist/components/button.mjs +92 -0
- package/{src/style/components/card → dist/components}/card.css +9 -30
- package/dist/components/card.d.mts +31 -0
- package/dist/components/card.d.ts +31 -0
- package/dist/components/card.js +59 -0
- package/dist/components/card.mjs +32 -0
- package/{src/style → dist}/components/checkbox.css +51 -43
- package/dist/components/checkbox.d.mts +31 -0
- package/dist/components/checkbox.d.ts +31 -0
- package/dist/components/checkbox.js +130 -0
- package/dist/components/checkbox.mjs +93 -0
- package/{src/style/components/code-block → dist/components}/code-block.css +3 -7
- package/dist/components/code-block.d.mts +24 -0
- package/dist/components/code-block.d.ts +24 -0
- package/dist/components/code-block.js +43 -0
- package/dist/components/code-block.mjs +16 -0
- package/dist/components/color-control.css +285 -0
- package/dist/components/color-control.d.mts +5 -0
- package/dist/components/color-control.d.ts +5 -0
- package/dist/components/color-control.js +534 -0
- package/dist/components/color-control.mjs +497 -0
- package/dist/components/dialog.css +930 -0
- package/dist/components/dialog.d.mts +32 -0
- package/dist/components/dialog.d.ts +32 -0
- package/dist/components/dialog.js +1111 -0
- package/dist/components/dialog.mjs +1074 -0
- package/dist/components/divider.css +356 -0
- package/dist/components/divider.d.mts +32 -0
- package/dist/components/divider.d.ts +32 -0
- package/dist/components/divider.js +344 -0
- package/dist/components/divider.mjs +307 -0
- package/{src/style/components/drag-handle → dist/components}/drag-handle.css +3 -18
- package/dist/components/drag-handle.d.mts +11 -0
- package/dist/components/drag-handle.d.ts +11 -0
- package/dist/components/drag-handle.js +103 -0
- package/dist/components/drag-handle.mjs +66 -0
- package/dist/components/drawer.css +1027 -0
- package/dist/components/drawer.d.mts +14 -0
- package/dist/components/drawer.d.ts +14 -0
- package/dist/components/drawer.js +1072 -0
- package/dist/components/drawer.mjs +1035 -0
- package/dist/components/floating-bar.css +17 -0
- package/dist/components/floating-bar.d.mts +25 -0
- package/dist/components/floating-bar.d.ts +25 -0
- package/dist/components/floating-bar.js +52 -0
- package/dist/components/floating-bar.mjs +25 -0
- package/dist/components/footer.css +40 -0
- package/dist/components/footer.d.mts +8 -0
- package/dist/components/footer.d.ts +8 -0
- package/dist/components/footer.js +44 -0
- package/dist/components/footer.mjs +17 -0
- package/dist/components/grid.css +47 -0
- package/dist/components/grid.d.mts +27 -0
- package/dist/components/grid.d.ts +27 -0
- package/dist/components/grid.js +52 -0
- package/dist/components/grid.mjs +25 -0
- package/dist/components/header.css +1075 -0
- package/dist/components/header.d.mts +35 -0
- package/dist/components/header.d.ts +35 -0
- package/dist/components/header.js +1402 -0
- package/dist/components/header.mjs +1365 -0
- package/dist/components/hero.css +121 -0
- package/dist/components/hero.d.mts +111 -0
- package/dist/components/hero.d.ts +111 -0
- package/dist/components/hero.js +285 -0
- package/dist/components/hero.mjs +248 -0
- package/{src/style/components/icons → dist/components}/icons.css +14 -15
- package/dist/components/icons.d.mts +104 -0
- package/dist/components/icons.d.ts +104 -0
- package/dist/components/icons.js +239 -0
- package/dist/components/icons.mjs +203 -0
- package/{src/style/components/input → dist/components}/input.css +189 -102
- package/dist/components/input.d.mts +114 -0
- package/dist/components/input.d.ts +114 -0
- package/dist/components/input.js +926 -0
- package/dist/components/input.mjs +879 -0
- package/dist/components/layout.css +551 -0
- package/dist/components/layout.d.mts +16 -0
- package/dist/components/layout.d.ts +16 -0
- package/dist/components/layout.js +387 -0
- package/dist/components/layout.mjs +352 -0
- package/{src/style/components/list → dist/components}/list.css +47 -41
- package/dist/components/list.d.mts +46 -0
- package/dist/components/list.d.ts +46 -0
- package/dist/components/list.js +124 -0
- package/dist/components/list.mjs +96 -0
- package/dist/components/navbar.css +706 -0
- package/dist/components/navbar.d.mts +56 -0
- package/dist/components/navbar.d.ts +56 -0
- package/dist/components/navbar.js +994 -0
- package/dist/components/navbar.mjs +952 -0
- package/{src/style/components/page-index → dist/components}/page-index.css +2 -47
- package/dist/components/page-index.d.mts +25 -0
- package/dist/components/page-index.d.ts +25 -0
- package/dist/components/page-index.js +239 -0
- package/dist/components/page-index.mjs +202 -0
- package/{src/style/components/page → dist/components}/page.css +4 -15
- package/dist/components/page.d.mts +30 -0
- package/dist/components/page.d.ts +30 -0
- package/dist/components/page.js +40 -0
- package/dist/components/page.mjs +13 -0
- package/dist/components/popover.css +87 -0
- package/dist/components/popover.d.mts +22 -0
- package/dist/components/popover.d.ts +22 -0
- package/dist/components/popover.js +243 -0
- package/dist/components/popover.mjs +206 -0
- package/{src/style → dist}/components/radio.css +8 -51
- package/dist/components/radio.d.mts +59 -0
- package/dist/components/radio.d.ts +59 -0
- package/dist/components/radio.js +133 -0
- package/dist/components/radio.mjs +95 -0
- package/dist/components/section.css +993 -0
- package/dist/components/section.d.mts +33 -0
- package/dist/components/section.d.ts +33 -0
- package/dist/components/section.js +1401 -0
- package/dist/components/section.mjs +1364 -0
- package/dist/components/select.css +391 -0
- package/dist/components/select.d.mts +63 -0
- package/dist/components/select.d.ts +63 -0
- package/dist/components/select.js +452 -0
- package/dist/components/select.mjs +415 -0
- package/{src/style/components/slider → dist/components}/slider.css +55 -33
- package/dist/components/slider.d.mts +69 -0
- package/dist/components/slider.d.ts +69 -0
- package/dist/components/slider.js +254 -0
- package/dist/components/slider.mjs +217 -0
- package/dist/components/switch.css +1081 -0
- package/dist/components/switch.d.mts +33 -0
- package/dist/components/switch.d.ts +33 -0
- package/dist/components/switch.js +1092 -0
- package/dist/components/switch.mjs +1055 -0
- package/{src/style/components/table → dist/components}/table.css +3 -28
- package/dist/components/table.d.mts +42 -0
- package/dist/components/table.d.ts +42 -0
- package/dist/components/table.js +108 -0
- package/dist/components/table.mjs +76 -0
- package/dist/components/tag.css +97 -0
- package/dist/components/tag.d.mts +12 -0
- package/dist/components/tag.d.ts +12 -0
- package/dist/components/tag.js +42 -0
- package/dist/components/tag.mjs +15 -0
- package/dist/components/textarea.css +1359 -0
- package/dist/components/textarea.d.mts +84 -0
- package/dist/components/textarea.d.ts +84 -0
- package/dist/components/textarea.js +1962 -0
- package/dist/components/textarea.mjs +1924 -0
- package/{src/style/components/theme-control → dist/components}/theme-control.css +3 -7
- package/dist/components/theme-control.d.mts +9 -0
- package/dist/components/theme-control.d.ts +9 -0
- package/dist/components/theme-control.js +235 -0
- package/dist/components/theme-control.mjs +200 -0
- package/{src/style/components/tooltip → dist/components}/tooltip.css +5 -13
- package/dist/components/tooltip.d.mts +12 -0
- package/dist/components/tooltip.d.ts +12 -0
- package/dist/components/tooltip.js +200 -0
- package/dist/components/tooltip.mjs +163 -0
- package/dist/icons-Czahnf-r.d.mts +15 -0
- package/dist/icons-Czahnf-r.d.ts +15 -0
- package/dist/index.css +2914 -2067
- package/dist/index.d.mts +144 -721
- package/dist/index.d.ts +144 -721
- package/dist/index.js +4076 -2282
- package/dist/index.mjs +4132 -2366
- package/dist/theme.css +34 -34
- package/package.json +27 -8
- package/dist/index.css.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/hellboy-ds-0.1.2.tgz +0 -0
- package/src/components/badge/Badge.tsx +0 -29
- package/src/components/badge/index.ts +0 -1
- package/src/components/banner/Banner.tsx +0 -48
- package/src/components/banner/banner.css +0 -44
- package/src/components/banner/index.ts +0 -1
- package/src/components/button/button.tsx +0 -127
- package/src/components/button/index.ts +0 -1
- package/src/components/card/card.tsx +0 -57
- package/src/components/card/index.ts +0 -1
- package/src/components/checkbox/Checkbox.tsx +0 -98
- package/src/components/checkbox/index.ts +0 -1
- package/src/components/code-block/code-block.tsx +0 -44
- package/src/components/code-block/index.ts +0 -1
- package/src/components/color-control/color-control.tsx +0 -322
- package/src/components/color-control/index.ts +0 -1
- package/src/components/drag-handle/DragHandle.tsx +0 -78
- package/src/components/drag-handle/index.ts +0 -1
- package/src/components/drawer/drawer.tsx +0 -82
- package/src/components/drawer/index.ts +0 -1
- package/src/components/floating-bar/floating-bar.tsx +0 -52
- package/src/components/floating-bar/index.ts +0 -2
- package/src/components/footer/footer.tsx +0 -28
- package/src/components/footer/index.ts +0 -1
- package/src/components/grid/Grid.tsx +0 -53
- package/src/components/grid/index.ts +0 -1
- package/src/components/header/header.tsx +0 -57
- package/src/components/header/index.ts +0 -1
- package/src/components/icons/icons.tsx +0 -44
- package/src/components/icons/index.ts +0 -1
- package/src/components/index.ts +0 -29
- package/src/components/input/DatePicker.tsx +0 -133
- package/src/components/input/Input.tsx +0 -220
- package/src/components/input/InputDate.tsx +0 -10
- package/src/components/input/InputDateTime.tsx +0 -10
- package/src/components/input/InputEmail.tsx +0 -10
- package/src/components/input/InputField.tsx +0 -137
- package/src/components/input/InputNumber.tsx +0 -10
- package/src/components/input/InputPassword.tsx +0 -10
- package/src/components/input/InputSearch.tsx +0 -10
- package/src/components/input/InputTel.tsx +0 -10
- package/src/components/input/InputText.tsx +0 -10
- package/src/components/input/InputTime.tsx +0 -10
- package/src/components/input/InputUrl.tsx +0 -10
- package/src/components/input/TimePicker.tsx +0 -151
- package/src/components/input/index.ts +0 -11
- package/src/components/layout/Layout.tsx +0 -244
- package/src/components/layout/index.ts +0 -1
- package/src/components/list/List.tsx +0 -159
- package/src/components/list/index.ts +0 -1
- package/src/components/navbar/MenuCategory.tsx +0 -20
- package/src/components/navbar/MenuGroup.tsx +0 -288
- package/src/components/navbar/MenuItem.tsx +0 -65
- package/src/components/navbar/Navbar.tsx +0 -23
- package/src/components/navbar/index.ts +0 -4
- package/src/components/page/index.ts +0 -1
- package/src/components/page/page.tsx +0 -46
- package/src/components/page-index/PageIndex.tsx +0 -275
- package/src/components/page-index/index.ts +0 -1
- package/src/components/popover/index.ts +0 -1
- package/src/components/popover/popover.tsx +0 -199
- package/src/components/radio/Radio.tsx +0 -176
- package/src/components/radio/index.ts +0 -1
- package/src/components/section/index.ts +0 -1
- package/src/components/section/section.tsx +0 -66
- package/src/components/select/Select.tsx +0 -212
- package/src/components/select/index.ts +0 -1
- package/src/components/slider/Slider.tsx +0 -267
- package/src/components/slider/index.ts +0 -1
- package/src/components/switch/index.ts +0 -1
- package/src/components/switch/switch.tsx +0 -99
- package/src/components/table/Table.tsx +0 -147
- package/src/components/table/index.ts +0 -1
- package/src/components/theme-control/index.ts +0 -1
- package/src/components/theme-control/theme-control.tsx +0 -78
- package/src/components/tooltip/index.ts +0 -1
- package/src/components/tooltip/tooltip.tsx +0 -207
- package/src/contexts/NavbarTooltipContext.tsx +0 -48
- package/src/contexts/index.ts +0 -1
- package/src/foundations/motion.md +0 -136
- package/src/index.ts +0 -40
- package/src/style/_shared/field.css +0 -69
- package/src/style/components/color-control/color-control.css +0 -126
- package/src/style/components/drawer/drawer.css +0 -210
- package/src/style/components/floating-bar/floating-bar.css +0 -39
- package/src/style/components/footer/footer.css +0 -108
- package/src/style/components/grid/grid.css +0 -33
- package/src/style/components/header/header.css +0 -44
- package/src/style/components/layout/layout.css +0 -205
- package/src/style/components/navbar/navbar.css +0 -342
- package/src/style/components/popover/popover.css +0 -44
- package/src/style/components/section/section.css +0 -67
- package/src/style/components/select/select.css +0 -143
- package/src/style/components/switch/switch.css +0 -267
- package/src/style/foundations/global.css +0 -316
- package/src/style/foundations/motion.css +0 -164
- package/src/style/foundations/spacing.css +0 -51
- package/src/style/foundations/typography.css +0 -39
- package/src/style/foundations/z-index.css +0 -81
- package/src/style/modes/dark.css +0 -146
- package/src/style/modes/light.css +0 -147
- package/src/style/semantic.css +0 -52
- package/src/style/styles.css +0 -51
- package/src/style/themes/theme.json +0 -37
- package/src/utils/README.md +0 -305
- package/src/utils/USER_PREFERENCES.md +0 -558
- package/src/utils/theme.ts +0 -127
- package/src/utils/user-preferences.ts +0 -577
- package/tsconfig.json +0 -25
- package/tsup.config.ts +0 -52
|
@@ -1,35 +1,31 @@
|
|
|
1
|
+
/* src/style/components/theme-control/theme-control.css */
|
|
1
2
|
.theme-control {
|
|
2
3
|
display: flex;
|
|
3
4
|
flex-direction: column;
|
|
4
5
|
gap: var(--spacing-2, 0.5rem);
|
|
5
6
|
}
|
|
6
|
-
|
|
7
7
|
.theme-control__option {
|
|
8
8
|
display: flex;
|
|
9
9
|
align-items: center;
|
|
10
10
|
gap: var(--spacing-3, 0.75rem);
|
|
11
11
|
padding: var(--spacing-2, 0.5rem);
|
|
12
|
-
border-radius: var(--
|
|
12
|
+
border-radius: var(--radius-sm, 4px);
|
|
13
13
|
cursor: pointer;
|
|
14
14
|
transition: all var(--transition-base, 0.2s ease);
|
|
15
15
|
color: var(--color-foreground-1);
|
|
16
16
|
}
|
|
17
|
-
|
|
18
17
|
.theme-control__option:hover:not(:disabled) {
|
|
19
18
|
background: var(--color-bg-2);
|
|
20
19
|
}
|
|
21
|
-
|
|
22
20
|
.theme-control__option:focus-visible:not(:disabled) {
|
|
23
21
|
outline: 2px solid var(--color-action-primary);
|
|
24
22
|
outline-offset: 2px;
|
|
25
23
|
}
|
|
26
|
-
|
|
27
24
|
.theme-control__option--active {
|
|
28
25
|
background: var(--color-action-primary);
|
|
29
26
|
color: var(--color-on-action-primary);
|
|
30
27
|
}
|
|
31
|
-
|
|
32
28
|
.theme-control__icon {
|
|
33
29
|
width: 20px;
|
|
34
30
|
height: 20px;
|
|
35
|
-
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
31
|
+
|
|
32
|
+
// src/components/theme-control/index.ts
|
|
33
|
+
var theme_control_exports = {};
|
|
34
|
+
__export(theme_control_exports, {
|
|
35
|
+
ThemeControl: () => ThemeControl
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(theme_control_exports);
|
|
38
|
+
|
|
39
|
+
// src/components/theme-control/theme-control.tsx
|
|
40
|
+
var React = __toESM(require("react"));
|
|
41
|
+
|
|
42
|
+
// src/utils/user-preferences.ts
|
|
43
|
+
var DEFAULT_CONFIG = {
|
|
44
|
+
backend: "localStorage",
|
|
45
|
+
prefix: "hellboy-ds",
|
|
46
|
+
dbName: "hellboy-ds-prefs",
|
|
47
|
+
storeName: "preferences"
|
|
48
|
+
};
|
|
49
|
+
var config = { ...DEFAULT_CONFIG };
|
|
50
|
+
var getStorageKey = (key) => {
|
|
51
|
+
return `${config.prefix}:${key}`;
|
|
52
|
+
};
|
|
53
|
+
var isLocalStorageAvailable = () => {
|
|
54
|
+
try {
|
|
55
|
+
const test = "__storage_test__";
|
|
56
|
+
localStorage.setItem(test, test);
|
|
57
|
+
localStorage.removeItem(test);
|
|
58
|
+
return true;
|
|
59
|
+
} catch {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
var IndexedDBStore = class {
|
|
64
|
+
constructor() {
|
|
65
|
+
__publicField(this, "db", null);
|
|
66
|
+
}
|
|
67
|
+
async init() {
|
|
68
|
+
if (typeof window === "undefined" || !window.indexedDB) {
|
|
69
|
+
throw new Error("IndexedDB not available");
|
|
70
|
+
}
|
|
71
|
+
return new Promise((resolve, reject) => {
|
|
72
|
+
const request = indexedDB.open(config.dbName, 1);
|
|
73
|
+
request.onerror = () => reject(request.error);
|
|
74
|
+
request.onsuccess = () => {
|
|
75
|
+
this.db = request.result;
|
|
76
|
+
resolve();
|
|
77
|
+
};
|
|
78
|
+
request.onupgradeneeded = (event) => {
|
|
79
|
+
const db = event.target.result;
|
|
80
|
+
if (!db.objectStoreNames.contains(config.storeName)) {
|
|
81
|
+
db.createObjectStore(config.storeName, { keyPath: "key" });
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
async get(key) {
|
|
87
|
+
if (!this.db) await this.init();
|
|
88
|
+
return new Promise((resolve, reject) => {
|
|
89
|
+
const transaction = this.db.transaction([config.storeName], "readonly");
|
|
90
|
+
const store = transaction.objectStore(config.storeName);
|
|
91
|
+
const request = store.get(key);
|
|
92
|
+
request.onsuccess = () => resolve(request.result?.value);
|
|
93
|
+
request.onerror = () => reject(request.error);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
async set(key, value) {
|
|
97
|
+
if (!this.db) await this.init();
|
|
98
|
+
return new Promise((resolve, reject) => {
|
|
99
|
+
const transaction = this.db.transaction([config.storeName], "readwrite");
|
|
100
|
+
const store = transaction.objectStore(config.storeName);
|
|
101
|
+
const request = store.put({ key, value });
|
|
102
|
+
request.onsuccess = () => resolve();
|
|
103
|
+
request.onerror = () => reject(request.error);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
async remove(key) {
|
|
107
|
+
if (!this.db) await this.init();
|
|
108
|
+
return new Promise((resolve, reject) => {
|
|
109
|
+
const transaction = this.db.transaction([config.storeName], "readwrite");
|
|
110
|
+
const store = transaction.objectStore(config.storeName);
|
|
111
|
+
const request = store.delete(key);
|
|
112
|
+
request.onsuccess = () => resolve();
|
|
113
|
+
request.onerror = () => reject(request.error);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
async clear() {
|
|
117
|
+
if (!this.db) await this.init();
|
|
118
|
+
return new Promise((resolve, reject) => {
|
|
119
|
+
const transaction = this.db.transaction([config.storeName], "readwrite");
|
|
120
|
+
const store = transaction.objectStore(config.storeName);
|
|
121
|
+
const request = store.clear();
|
|
122
|
+
request.onsuccess = () => resolve();
|
|
123
|
+
request.onerror = () => reject(request.error);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
var indexedDBStore = new IndexedDBStore();
|
|
128
|
+
var getPreference = (key, defaultValue) => {
|
|
129
|
+
try {
|
|
130
|
+
if (config.backend === "localStorage" && isLocalStorageAvailable()) {
|
|
131
|
+
const stored = localStorage.getItem(getStorageKey(key));
|
|
132
|
+
if (stored !== null) {
|
|
133
|
+
return JSON.parse(stored);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return defaultValue;
|
|
137
|
+
} catch (error) {
|
|
138
|
+
console.warn(`Failed to get preference "${key}":`, error);
|
|
139
|
+
return defaultValue;
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
var setPreference = (key, value) => {
|
|
143
|
+
try {
|
|
144
|
+
if (config.backend === "localStorage" && isLocalStorageAvailable()) {
|
|
145
|
+
localStorage.setItem(getStorageKey(key), JSON.stringify(value));
|
|
146
|
+
}
|
|
147
|
+
} catch (error) {
|
|
148
|
+
console.warn(`Failed to set preference "${key}":`, error);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
// src/utils/theme.ts
|
|
153
|
+
var THEME_KEY = "theme";
|
|
154
|
+
var ATTR_NAME = "data-theme";
|
|
155
|
+
var applyTheme = (theme) => {
|
|
156
|
+
document.documentElement.setAttribute(ATTR_NAME, theme);
|
|
157
|
+
};
|
|
158
|
+
var getTheme = () => {
|
|
159
|
+
const dataTheme = document.documentElement.getAttribute(ATTR_NAME);
|
|
160
|
+
if (dataTheme === "light" || dataTheme === "dark") return dataTheme;
|
|
161
|
+
try {
|
|
162
|
+
const stored = getPreference(THEME_KEY);
|
|
163
|
+
if (stored === "light" || stored === "dark") return stored;
|
|
164
|
+
} catch (e) {
|
|
165
|
+
}
|
|
166
|
+
if (typeof window !== "undefined" && window.matchMedia("(prefers-color-scheme: dark)").matches) {
|
|
167
|
+
return "dark";
|
|
168
|
+
}
|
|
169
|
+
return "light";
|
|
170
|
+
};
|
|
171
|
+
var getSavedTheme = () => getTheme();
|
|
172
|
+
var setTheme = (theme) => {
|
|
173
|
+
if (!["light", "dark"].includes(theme)) {
|
|
174
|
+
console.warn(`Invalid theme: ${theme}. Using 'light' as fallback.`);
|
|
175
|
+
theme = "light";
|
|
176
|
+
}
|
|
177
|
+
try {
|
|
178
|
+
setPreference(THEME_KEY, theme);
|
|
179
|
+
} catch (e) {
|
|
180
|
+
}
|
|
181
|
+
applyTheme(theme);
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
// src/components/theme-control/theme-control.tsx
|
|
185
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
186
|
+
var themeOptions = [
|
|
187
|
+
{
|
|
188
|
+
value: "light",
|
|
189
|
+
label: "Light",
|
|
190
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { className: "theme-control__icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
191
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "12", cy: "12", r: "5" }),
|
|
192
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "12", y1: "1", x2: "12", y2: "3" }),
|
|
193
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "12", y1: "21", x2: "12", y2: "23" }),
|
|
194
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "4.22", y1: "4.22", x2: "5.64", y2: "5.64" }),
|
|
195
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "18.36", y1: "18.36", x2: "19.78", y2: "19.78" }),
|
|
196
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "1", y1: "12", x2: "3", y2: "12" }),
|
|
197
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "21", y1: "12", x2: "23", y2: "12" }),
|
|
198
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "4.22", y1: "19.78", x2: "5.64", y2: "18.36" }),
|
|
199
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "18.36", y1: "5.64", x2: "19.78", y2: "4.22" })
|
|
200
|
+
] })
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
value: "dark",
|
|
204
|
+
label: "Dark",
|
|
205
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { className: "theme-control__icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" }) })
|
|
206
|
+
}
|
|
207
|
+
];
|
|
208
|
+
var ThemeControl = ({ onThemeChange }) => {
|
|
209
|
+
const [currentTheme, setCurrentTheme] = React.useState(() => {
|
|
210
|
+
return getSavedTheme();
|
|
211
|
+
});
|
|
212
|
+
React.useEffect(() => {
|
|
213
|
+
setTheme(currentTheme);
|
|
214
|
+
onThemeChange?.(currentTheme);
|
|
215
|
+
}, [currentTheme, onThemeChange]);
|
|
216
|
+
const handleThemeSelect = (theme) => {
|
|
217
|
+
setCurrentTheme(theme);
|
|
218
|
+
};
|
|
219
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "theme-control", children: themeOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
220
|
+
"div",
|
|
221
|
+
{
|
|
222
|
+
className: `theme-control__option ${currentTheme === option.value ? "theme-control__option--active" : ""}`,
|
|
223
|
+
onClick: () => handleThemeSelect(option.value),
|
|
224
|
+
children: [
|
|
225
|
+
option.icon,
|
|
226
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: option.label })
|
|
227
|
+
]
|
|
228
|
+
},
|
|
229
|
+
option.value
|
|
230
|
+
)) });
|
|
231
|
+
};
|
|
232
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
233
|
+
0 && (module.exports = {
|
|
234
|
+
ThemeControl
|
|
235
|
+
});
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
|
|
5
|
+
// src/components/theme-control/theme-control.tsx
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
|
|
8
|
+
// src/utils/user-preferences.ts
|
|
9
|
+
var DEFAULT_CONFIG = {
|
|
10
|
+
backend: "localStorage",
|
|
11
|
+
prefix: "hellboy-ds",
|
|
12
|
+
dbName: "hellboy-ds-prefs",
|
|
13
|
+
storeName: "preferences"
|
|
14
|
+
};
|
|
15
|
+
var config = { ...DEFAULT_CONFIG };
|
|
16
|
+
var getStorageKey = (key) => {
|
|
17
|
+
return `${config.prefix}:${key}`;
|
|
18
|
+
};
|
|
19
|
+
var isLocalStorageAvailable = () => {
|
|
20
|
+
try {
|
|
21
|
+
const test = "__storage_test__";
|
|
22
|
+
localStorage.setItem(test, test);
|
|
23
|
+
localStorage.removeItem(test);
|
|
24
|
+
return true;
|
|
25
|
+
} catch {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var IndexedDBStore = class {
|
|
30
|
+
constructor() {
|
|
31
|
+
__publicField(this, "db", null);
|
|
32
|
+
}
|
|
33
|
+
async init() {
|
|
34
|
+
if (typeof window === "undefined" || !window.indexedDB) {
|
|
35
|
+
throw new Error("IndexedDB not available");
|
|
36
|
+
}
|
|
37
|
+
return new Promise((resolve, reject) => {
|
|
38
|
+
const request = indexedDB.open(config.dbName, 1);
|
|
39
|
+
request.onerror = () => reject(request.error);
|
|
40
|
+
request.onsuccess = () => {
|
|
41
|
+
this.db = request.result;
|
|
42
|
+
resolve();
|
|
43
|
+
};
|
|
44
|
+
request.onupgradeneeded = (event) => {
|
|
45
|
+
const db = event.target.result;
|
|
46
|
+
if (!db.objectStoreNames.contains(config.storeName)) {
|
|
47
|
+
db.createObjectStore(config.storeName, { keyPath: "key" });
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
async get(key) {
|
|
53
|
+
if (!this.db) await this.init();
|
|
54
|
+
return new Promise((resolve, reject) => {
|
|
55
|
+
const transaction = this.db.transaction([config.storeName], "readonly");
|
|
56
|
+
const store = transaction.objectStore(config.storeName);
|
|
57
|
+
const request = store.get(key);
|
|
58
|
+
request.onsuccess = () => resolve(request.result?.value);
|
|
59
|
+
request.onerror = () => reject(request.error);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
async set(key, value) {
|
|
63
|
+
if (!this.db) await this.init();
|
|
64
|
+
return new Promise((resolve, reject) => {
|
|
65
|
+
const transaction = this.db.transaction([config.storeName], "readwrite");
|
|
66
|
+
const store = transaction.objectStore(config.storeName);
|
|
67
|
+
const request = store.put({ key, value });
|
|
68
|
+
request.onsuccess = () => resolve();
|
|
69
|
+
request.onerror = () => reject(request.error);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
async remove(key) {
|
|
73
|
+
if (!this.db) await this.init();
|
|
74
|
+
return new Promise((resolve, reject) => {
|
|
75
|
+
const transaction = this.db.transaction([config.storeName], "readwrite");
|
|
76
|
+
const store = transaction.objectStore(config.storeName);
|
|
77
|
+
const request = store.delete(key);
|
|
78
|
+
request.onsuccess = () => resolve();
|
|
79
|
+
request.onerror = () => reject(request.error);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
async clear() {
|
|
83
|
+
if (!this.db) await this.init();
|
|
84
|
+
return new Promise((resolve, reject) => {
|
|
85
|
+
const transaction = this.db.transaction([config.storeName], "readwrite");
|
|
86
|
+
const store = transaction.objectStore(config.storeName);
|
|
87
|
+
const request = store.clear();
|
|
88
|
+
request.onsuccess = () => resolve();
|
|
89
|
+
request.onerror = () => reject(request.error);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
var indexedDBStore = new IndexedDBStore();
|
|
94
|
+
var getPreference = (key, defaultValue) => {
|
|
95
|
+
try {
|
|
96
|
+
if (config.backend === "localStorage" && isLocalStorageAvailable()) {
|
|
97
|
+
const stored = localStorage.getItem(getStorageKey(key));
|
|
98
|
+
if (stored !== null) {
|
|
99
|
+
return JSON.parse(stored);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return defaultValue;
|
|
103
|
+
} catch (error) {
|
|
104
|
+
console.warn(`Failed to get preference "${key}":`, error);
|
|
105
|
+
return defaultValue;
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
var setPreference = (key, value) => {
|
|
109
|
+
try {
|
|
110
|
+
if (config.backend === "localStorage" && isLocalStorageAvailable()) {
|
|
111
|
+
localStorage.setItem(getStorageKey(key), JSON.stringify(value));
|
|
112
|
+
}
|
|
113
|
+
} catch (error) {
|
|
114
|
+
console.warn(`Failed to set preference "${key}":`, error);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// src/utils/theme.ts
|
|
119
|
+
var THEME_KEY = "theme";
|
|
120
|
+
var ATTR_NAME = "data-theme";
|
|
121
|
+
var applyTheme = (theme) => {
|
|
122
|
+
document.documentElement.setAttribute(ATTR_NAME, theme);
|
|
123
|
+
};
|
|
124
|
+
var getTheme = () => {
|
|
125
|
+
const dataTheme = document.documentElement.getAttribute(ATTR_NAME);
|
|
126
|
+
if (dataTheme === "light" || dataTheme === "dark") return dataTheme;
|
|
127
|
+
try {
|
|
128
|
+
const stored = getPreference(THEME_KEY);
|
|
129
|
+
if (stored === "light" || stored === "dark") return stored;
|
|
130
|
+
} catch (e) {
|
|
131
|
+
}
|
|
132
|
+
if (typeof window !== "undefined" && window.matchMedia("(prefers-color-scheme: dark)").matches) {
|
|
133
|
+
return "dark";
|
|
134
|
+
}
|
|
135
|
+
return "light";
|
|
136
|
+
};
|
|
137
|
+
var getSavedTheme = () => getTheme();
|
|
138
|
+
var setTheme = (theme) => {
|
|
139
|
+
if (!["light", "dark"].includes(theme)) {
|
|
140
|
+
console.warn(`Invalid theme: ${theme}. Using 'light' as fallback.`);
|
|
141
|
+
theme = "light";
|
|
142
|
+
}
|
|
143
|
+
try {
|
|
144
|
+
setPreference(THEME_KEY, theme);
|
|
145
|
+
} catch (e) {
|
|
146
|
+
}
|
|
147
|
+
applyTheme(theme);
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
// src/components/theme-control/theme-control.tsx
|
|
151
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
152
|
+
var themeOptions = [
|
|
153
|
+
{
|
|
154
|
+
value: "light",
|
|
155
|
+
label: "Light",
|
|
156
|
+
icon: /* @__PURE__ */ jsxs("svg", { className: "theme-control__icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
157
|
+
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "5" }),
|
|
158
|
+
/* @__PURE__ */ jsx("line", { x1: "12", y1: "1", x2: "12", y2: "3" }),
|
|
159
|
+
/* @__PURE__ */ jsx("line", { x1: "12", y1: "21", x2: "12", y2: "23" }),
|
|
160
|
+
/* @__PURE__ */ jsx("line", { x1: "4.22", y1: "4.22", x2: "5.64", y2: "5.64" }),
|
|
161
|
+
/* @__PURE__ */ jsx("line", { x1: "18.36", y1: "18.36", x2: "19.78", y2: "19.78" }),
|
|
162
|
+
/* @__PURE__ */ jsx("line", { x1: "1", y1: "12", x2: "3", y2: "12" }),
|
|
163
|
+
/* @__PURE__ */ jsx("line", { x1: "21", y1: "12", x2: "23", y2: "12" }),
|
|
164
|
+
/* @__PURE__ */ jsx("line", { x1: "4.22", y1: "19.78", x2: "5.64", y2: "18.36" }),
|
|
165
|
+
/* @__PURE__ */ jsx("line", { x1: "18.36", y1: "5.64", x2: "19.78", y2: "4.22" })
|
|
166
|
+
] })
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
value: "dark",
|
|
170
|
+
label: "Dark",
|
|
171
|
+
icon: /* @__PURE__ */ jsx("svg", { className: "theme-control__icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ jsx("path", { d: "M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" }) })
|
|
172
|
+
}
|
|
173
|
+
];
|
|
174
|
+
var ThemeControl = ({ onThemeChange }) => {
|
|
175
|
+
const [currentTheme, setCurrentTheme] = React.useState(() => {
|
|
176
|
+
return getSavedTheme();
|
|
177
|
+
});
|
|
178
|
+
React.useEffect(() => {
|
|
179
|
+
setTheme(currentTheme);
|
|
180
|
+
onThemeChange?.(currentTheme);
|
|
181
|
+
}, [currentTheme, onThemeChange]);
|
|
182
|
+
const handleThemeSelect = (theme) => {
|
|
183
|
+
setCurrentTheme(theme);
|
|
184
|
+
};
|
|
185
|
+
return /* @__PURE__ */ jsx("div", { className: "theme-control", children: themeOptions.map((option) => /* @__PURE__ */ jsxs(
|
|
186
|
+
"div",
|
|
187
|
+
{
|
|
188
|
+
className: `theme-control__option ${currentTheme === option.value ? "theme-control__option--active" : ""}`,
|
|
189
|
+
onClick: () => handleThemeSelect(option.value),
|
|
190
|
+
children: [
|
|
191
|
+
option.icon,
|
|
192
|
+
/* @__PURE__ */ jsx("span", { children: option.label })
|
|
193
|
+
]
|
|
194
|
+
},
|
|
195
|
+
option.value
|
|
196
|
+
)) });
|
|
197
|
+
};
|
|
198
|
+
export {
|
|
199
|
+
ThemeControl
|
|
200
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/*
|
|
2
|
-
|
|
1
|
+
/* src/style/components/tooltip/tooltip.css */
|
|
3
2
|
.tooltip {
|
|
4
|
-
position: fixed;
|
|
3
|
+
position: fixed;
|
|
4
|
+
z-index: var(--z-tooltip);
|
|
5
5
|
background: var(--color-bg-1);
|
|
6
6
|
border: 1px solid var(--color-bg-3);
|
|
7
7
|
border-color: rgba(0, 0, 0, 0.15);
|
|
8
8
|
border-radius: var(--radius-base);
|
|
9
|
-
box-shadow:
|
|
9
|
+
box-shadow: var(--shadow-md);
|
|
10
10
|
max-width: 200px;
|
|
11
11
|
padding: var(--spacing-2, 0.5rem) var(--spacing-3, 0.75rem);
|
|
12
12
|
font-size: var(--font-size-xs, 0.75rem);
|
|
@@ -14,28 +14,22 @@
|
|
|
14
14
|
color: var(--color-foreground-1);
|
|
15
15
|
white-space: nowrap;
|
|
16
16
|
animation: tooltip-fade-in var(--transition-fast, 0.15s ease);
|
|
17
|
-
/* Prevent initial flash by starting hidden */
|
|
18
17
|
opacity: 0;
|
|
19
18
|
visibility: hidden;
|
|
20
19
|
pointer-events: none;
|
|
21
20
|
}
|
|
22
|
-
|
|
23
21
|
.tooltip--top {
|
|
24
22
|
margin-bottom: var(--spacing-1);
|
|
25
23
|
}
|
|
26
|
-
|
|
27
24
|
.tooltip--bottom {
|
|
28
25
|
margin-top: var(--spacing-1);
|
|
29
26
|
}
|
|
30
|
-
|
|
31
27
|
.tooltip--left {
|
|
32
28
|
margin-right: var(--spacing-1);
|
|
33
29
|
}
|
|
34
|
-
|
|
35
30
|
.tooltip--right {
|
|
36
31
|
margin-left: var(--spacing-1);
|
|
37
32
|
}
|
|
38
|
-
|
|
39
33
|
@keyframes tooltip-fade-in {
|
|
40
34
|
from {
|
|
41
35
|
opacity: 0;
|
|
@@ -46,7 +40,5 @@
|
|
|
46
40
|
transform: translateY(0);
|
|
47
41
|
}
|
|
48
42
|
}
|
|
49
|
-
|
|
50
43
|
.tooltip__content {
|
|
51
|
-
|
|
52
|
-
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
interface TooltipProps {
|
|
4
|
+
content: React.ReactNode;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
placement?: 'top' | 'bottom' | 'left' | 'right';
|
|
7
|
+
delay?: number;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
declare const Tooltip: React.FC<TooltipProps>;
|
|
11
|
+
|
|
12
|
+
export { Tooltip, type TooltipProps };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
interface TooltipProps {
|
|
4
|
+
content: React.ReactNode;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
placement?: 'top' | 'bottom' | 'left' | 'right';
|
|
7
|
+
delay?: number;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
declare const Tooltip: React.FC<TooltipProps>;
|
|
11
|
+
|
|
12
|
+
export { Tooltip, type TooltipProps };
|