@opendikw/web-ui 0.1.0-rc.1

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 (53) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +47 -0
  3. package/dist/auth/index.d.ts +23 -0
  4. package/dist/auth/index.js +118 -0
  5. package/dist/controls/Button.d.ts +14 -0
  6. package/dist/controls/Button.js +16 -0
  7. package/dist/controls/EmptyState.d.ts +8 -0
  8. package/dist/controls/EmptyState.js +5 -0
  9. package/dist/controls/Field.d.ts +23 -0
  10. package/dist/controls/Field.js +11 -0
  11. package/dist/controls/FrontmatterChip.d.ts +16 -0
  12. package/dist/controls/FrontmatterChip.js +16 -0
  13. package/dist/controls/IconButton.d.ts +15 -0
  14. package/dist/controls/IconButton.js +11 -0
  15. package/dist/controls/MetricCard.d.ts +16 -0
  16. package/dist/controls/MetricCard.js +11 -0
  17. package/dist/controls/Notice.d.ts +8 -0
  18. package/dist/controls/Notice.js +13 -0
  19. package/dist/controls/SegmentedControl.d.ts +27 -0
  20. package/dist/controls/SegmentedControl.js +16 -0
  21. package/dist/controls/SoftLabel.d.ts +15 -0
  22. package/dist/controls/SoftLabel.js +14 -0
  23. package/dist/controls/StatusPill.d.ts +6 -0
  24. package/dist/controls/StatusPill.js +8 -0
  25. package/dist/controls/cx.d.ts +6 -0
  26. package/dist/controls/cx.js +8 -0
  27. package/dist/controls/index.d.ts +11 -0
  28. package/dist/controls/index.js +11 -0
  29. package/dist/hooks/index.d.ts +4 -0
  30. package/dist/hooks/index.js +3 -0
  31. package/dist/hooks/useAsyncResource.d.ts +7 -0
  32. package/dist/hooks/useAsyncResource.js +36 -0
  33. package/dist/hooks/useBilingualReader.d.ts +40 -0
  34. package/dist/hooks/useBilingualReader.js +154 -0
  35. package/dist/hooks/usePreviewTranslation.d.ts +24 -0
  36. package/dist/hooks/usePreviewTranslation.js +43 -0
  37. package/dist/reader/BilingualView.d.ts +32 -0
  38. package/dist/reader/BilingualView.js +75 -0
  39. package/dist/reader/MarkdownView.d.ts +12 -0
  40. package/dist/reader/MarkdownView.js +94 -0
  41. package/dist/reader/chart-spec.d.ts +17 -0
  42. package/dist/reader/chart-spec.js +174 -0
  43. package/dist/reader/index.d.ts +5 -0
  44. package/dist/reader/index.js +4 -0
  45. package/dist/reader/markdown-runtime.d.ts +37 -0
  46. package/dist/reader/markdown-runtime.js +701 -0
  47. package/dist/styles/controls.css +546 -0
  48. package/dist/styles/reader.css +701 -0
  49. package/dist/styles/tokens.css +200 -0
  50. package/dist/styles.d.ts +1 -0
  51. package/dist/theme/index.d.ts +12 -0
  52. package/dist/theme/index.js +40 -0
  53. package/package.json +71 -0
@@ -0,0 +1,200 @@
1
+ :root,
2
+ html[data-theme="light"] {
3
+ color-scheme: light;
4
+ /* PR1: Fonts — UI sans, editorial serif for titles, mono for IDs/paths */
5
+ --font-ui:
6
+ "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
7
+ "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans CN", "Noto Sans CJK SC",
8
+ sans-serif;
9
+ --font-serif:
10
+ "IBM Plex Serif", ui-serif, Georgia, "Songti SC", "Source Han Serif CN", "Noto Serif CJK SC",
11
+ serif;
12
+ --font-mono:
13
+ "IBM Plex Mono", ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", "Sarasa Mono SC",
14
+ "Microsoft YaHei Mono", monospace;
15
+ font-family: var(--font-ui);
16
+ font-synthesis: none;
17
+ text-rendering: optimizeLegibility;
18
+ /* PR1: Warm-stone neutrals (no green tint) — accent stands alone */
19
+ --bg: #f5f3ee;
20
+ --surface: #ffffff;
21
+ --surface-soft: #faf9f5;
22
+ --surface-2: #f0eee8;
23
+ --line: #e2dfd6;
24
+ --line-strong: #cdc9bd;
25
+ --hairline: #ebe8df;
26
+ --text: #1a1d1c;
27
+ --muted: #6c6f6a;
28
+ --subtle: #95968f;
29
+ /* PR1: Single deep petrol accent — higher contrast against warm-stone */
30
+ --accent: #0d5e57;
31
+ --accent-strong: #094540;
32
+ --accent-soft: #e2eeec;
33
+ --green: #2f7a4d;
34
+ --amber: #8a5a14;
35
+ --red: #a8362c;
36
+ --blue: #2f6aa8;
37
+ --scan-gray: #dfe6e8;
38
+ --reader-bg: #ffffff;
39
+ --reader-text: #1f2624;
40
+ --reader-muted: #6c6f6a;
41
+ --reader-heading: #14181b;
42
+ --reader-link: #094540;
43
+ --reader-code-bg: #14181b;
44
+ --reader-border: #e2dfd6;
45
+ --reader-quote-bg: #eef5f3;
46
+ --reader-table-bg: #f0eee8;
47
+ /* PR1: Replaced 24px blur shadow (invisible on warm-stone) with 1px hairline */
48
+ --shadow: 0 1px 0 rgba(20, 29, 28, 0.04);
49
+ --radius: 8px;
50
+ /* Focus: single source of truth, derived from --accent so it tracks the
51
+ theme automatically. --focus-ring is the soft box-shadow ring for text
52
+ fields; --focus-outline is the crisp keyboard outline for other controls. */
53
+ --focus-ring: 0 0 0 3px color-mix(in srgb, var(--accent) 24%, transparent);
54
+ --focus-outline: 2px solid var(--accent);
55
+ /* --danger aliases --red so destructive controls (.secondary-button--danger,
56
+ .agent-session-menu__item--danger) actually recolor. Defined once: it tracks
57
+ the theme through --red, which the dark block overrides. */
58
+ --danger: var(--red);
59
+ /* Type roles — collapse ad-hoc sizes onto six roles across the three voices.
60
+ CSS has no compound type token, so each role is size / line-height / tracking. */
61
+ --type-display-size: 32px;
62
+ --type-display-lh: 1.18;
63
+ --type-display-ls: -0.01em;
64
+ --type-title-page-size: 30px;
65
+ --type-title-page-lh: 1.1;
66
+ --type-title-page-ls: -0.01em;
67
+ --type-title-size: 17px;
68
+ --type-title-lh: 1.3;
69
+ --type-title-ls: -0.005em;
70
+ --type-body-size: 15px;
71
+ --type-body-lh: 1.55;
72
+ --type-body-ls: 0;
73
+ --type-body-sm-size: 13px;
74
+ --type-body-sm-lh: 1.45;
75
+ --type-body-sm-ls: 0;
76
+ --type-label-size: 11px;
77
+ --type-label-lh: 1.2;
78
+ --type-label-ls: 0.04em;
79
+ /* Spacing — 4px base. Half-steps (-1h/-2h/-3h) record entrenched 6/10/14px
80
+ usage; never reach past them for a NEW layout decision. Rhythm: 8 inside a
81
+ group (--space-2), 16 between groups (--space-4), 32–40 between sections. */
82
+ --space-0: 0;
83
+ --space-1: 4px;
84
+ --space-1h: 6px;
85
+ --space-2: 8px;
86
+ --space-2h: 10px;
87
+ --space-3: 12px;
88
+ --space-3h: 14px;
89
+ --space-4: 16px;
90
+ --space-5: 20px;
91
+ --space-6: 24px;
92
+ --space-8: 32px;
93
+ --space-10: 40px;
94
+ --space-12: 48px;
95
+ /* Motion — durations reconcile the de-facto 120/140/240ms; 100/160/180 retire.
96
+ --ease-emphasis is the slight-overshoot curve, reserved for deliberate
97
+ enter/select moments, never color fades. Pair with prefers-reduced-motion. */
98
+ --dur-fast: 120ms;
99
+ --dur-state: 140ms;
100
+ --dur-popover: 180ms;
101
+ --dur-overlay: 240ms;
102
+ --ease-standard: cubic-bezier(0.2, 0, 0, 1);
103
+ --ease-emphasis: cubic-bezier(0.175, 0.885, 0.32, 1.1);
104
+ /* Alpha line / overlay — layer over any surface and track the theme via
105
+ color-mix, retiring scattered literals (#cbd8d4 / #c5dad5 / #9fb0aa /
106
+ rgba(255,255,255,.7)). No dark override: all derive from --text / --accent. */
107
+ --line-alpha: color-mix(in srgb, var(--text) 12%, transparent);
108
+ --line-alpha-strong: color-mix(in srgb, var(--text) 22%, transparent);
109
+ --overlay-hover: color-mix(in srgb, var(--text) 5%, transparent);
110
+ --overlay-active: color-mix(in srgb, var(--text) 9%, transparent);
111
+ --accent-border-hover: color-mix(in srgb, var(--accent) 35%, var(--line));
112
+ }
113
+
114
+ html[data-theme="dark"] {
115
+ color-scheme: dark;
116
+ /* PR1: Warm-dark neutrals, accent shifted to petrol family */
117
+ --bg: #14140f;
118
+ --surface: #1b1b15;
119
+ --surface-soft: #161611;
120
+ --surface-2: #25241d;
121
+ --line: #2f2d24;
122
+ --line-strong: #4e4a3c;
123
+ --hairline: #232017;
124
+ --text: #f0eee7;
125
+ --muted: #b0aca0;
126
+ --subtle: #87826f;
127
+ --accent: #4eb8a6;
128
+ --accent-strong: #92e3d4;
129
+ --accent-soft: #142a26;
130
+ --green: #5ec78a;
131
+ --amber: #e3ad4c;
132
+ --red: #ef7f75;
133
+ --blue: #75aee9;
134
+ --scan-gray: #3a382e;
135
+ --reader-bg: #1b1b15;
136
+ --reader-text: #e2dccc;
137
+ --reader-muted: #ada89b;
138
+ --reader-heading: #f4f1e7;
139
+ --reader-link: #92e3d4;
140
+ --reader-code-bg: #11110c;
141
+ --reader-border: #2f2d24;
142
+ --reader-quote-bg: #1f2a26;
143
+ --reader-table-bg: #25241d;
144
+ --shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
145
+ }
146
+
147
+ * {
148
+ box-sizing: border-box;
149
+ }
150
+
151
+ body {
152
+ margin: 0;
153
+ min-width: 320px;
154
+ min-height: 100vh;
155
+ /* Base the cascade on the body type role (15px) so unsized text and
156
+ `font: inherit` controls (buttons/inputs/selects) ride the six-role scale
157
+ instead of the 16px UA default. Line-height stays per-element. */
158
+ font-size: var(--type-body-size);
159
+ background: var(--bg);
160
+ color: var(--text);
161
+ }
162
+
163
+ button,
164
+ input,
165
+ select,
166
+ textarea {
167
+ font: inherit;
168
+ }
169
+
170
+ button {
171
+ cursor: pointer;
172
+ }
173
+
174
+ button:disabled {
175
+ cursor: not-allowed;
176
+ opacity: 0.55;
177
+ }
178
+
179
+ input,
180
+ select,
181
+ textarea {
182
+ width: 100%;
183
+ border: 1px solid var(--line-strong);
184
+ border-radius: 7px;
185
+ background: var(--surface);
186
+ color: var(--text);
187
+ outline: none;
188
+ }
189
+
190
+ input,
191
+ select {
192
+ height: 36px;
193
+ padding: 0 10px;
194
+ }
195
+
196
+ textarea {
197
+ min-height: 82px;
198
+ resize: vertical;
199
+ padding: 10px;
200
+ }
@@ -0,0 +1 @@
1
+ declare module "*.css";
@@ -0,0 +1,12 @@
1
+ export type ThemePreference = "system" | "light" | "dark";
2
+ export type ResolvedTheme = "light" | "dark";
3
+ export declare function isThemePreference(value: string | null): value is ThemePreference;
4
+ export declare function resolveTheme(preference: ThemePreference): ResolvedTheme;
5
+ /** The application owns the storage key. OS changes never persist a resolved preference. */
6
+ export declare function useTheme({ storageKey }: {
7
+ storageKey: string;
8
+ }): {
9
+ preference: ThemePreference;
10
+ resolved: ResolvedTheme;
11
+ setPreference: (next: ThemePreference) => void;
12
+ };
@@ -0,0 +1,40 @@
1
+ import { useCallback, useEffect, useState } from "react";
2
+ export function isThemePreference(value) {
3
+ return value === "system" || value === "light" || value === "dark";
4
+ }
5
+ export function resolveTheme(preference) {
6
+ if (preference !== "system")
7
+ return preference;
8
+ return window.matchMedia?.("(prefers-color-scheme: dark)").matches ? "dark" : "light";
9
+ }
10
+ /** The application owns the storage key. OS changes never persist a resolved preference. */
11
+ export function useTheme({ storageKey }) {
12
+ const [preference, updatePreference] = useState(() => {
13
+ const stored = localStorage.getItem(storageKey);
14
+ return isThemePreference(stored) ? stored : "system";
15
+ });
16
+ useEffect(() => {
17
+ const stored = localStorage.getItem(storageKey);
18
+ updatePreference(isThemePreference(stored) ? stored : "system");
19
+ }, [storageKey]);
20
+ const [resolved, setResolved] = useState(() => resolveTheme(preference));
21
+ useEffect(() => {
22
+ const media = window.matchMedia?.("(prefers-color-scheme: dark)");
23
+ const apply = () => {
24
+ const next = resolveTheme(preference);
25
+ setResolved(next);
26
+ document.documentElement.dataset.theme = next;
27
+ document.documentElement.style.colorScheme = next;
28
+ };
29
+ apply();
30
+ if (preference !== "system" || !media)
31
+ return;
32
+ media.addEventListener?.("change", apply);
33
+ return () => media.removeEventListener?.("change", apply);
34
+ }, [preference]);
35
+ const setPreference = useCallback((next) => {
36
+ localStorage.setItem(storageKey, next);
37
+ updatePreference(next);
38
+ }, [storageKey]);
39
+ return { preference, resolved, setPreference };
40
+ }
package/package.json ADDED
@@ -0,0 +1,71 @@
1
+ {
2
+ "name": "@opendikw/web-ui",
3
+ "version": "0.1.0-rc.1",
4
+ "type": "module",
5
+ "license": "MIT",
6
+ "engines": {
7
+ "node": ">=24.0.0"
8
+ },
9
+ "files": [
10
+ "dist",
11
+ "README.md",
12
+ "LICENSE"
13
+ ],
14
+ "exports": {
15
+ "./controls": {
16
+ "types": "./dist/controls/index.d.ts",
17
+ "import": "./dist/controls/index.js"
18
+ },
19
+ "./reader": {
20
+ "types": "./dist/reader/index.d.ts",
21
+ "import": "./dist/reader/index.js"
22
+ },
23
+ "./hooks": {
24
+ "types": "./dist/hooks/index.d.ts",
25
+ "import": "./dist/hooks/index.js"
26
+ },
27
+ "./auth": {
28
+ "types": "./dist/auth/index.d.ts",
29
+ "import": "./dist/auth/index.js"
30
+ },
31
+ "./theme": {
32
+ "types": "./dist/theme/index.d.ts",
33
+ "import": "./dist/theme/index.js"
34
+ },
35
+ "./tokens.css": {
36
+ "types": "./dist/styles.d.ts",
37
+ "default": "./dist/styles/tokens.css"
38
+ },
39
+ "./controls.css": {
40
+ "types": "./dist/styles.d.ts",
41
+ "default": "./dist/styles/controls.css"
42
+ },
43
+ "./reader.css": {
44
+ "types": "./dist/styles.d.ts",
45
+ "default": "./dist/styles/reader.css"
46
+ }
47
+ },
48
+ "sideEffects": [
49
+ "**/*.css"
50
+ ],
51
+ "peerDependencies": {
52
+ "react": ">=19 <20",
53
+ "react-dom": ">=19 <20"
54
+ },
55
+ "repository": {
56
+ "type": "git",
57
+ "url": "git+https://github.com/OpenDIKW/dikw-web.git",
58
+ "directory": "packages/web-ui"
59
+ },
60
+ "publishConfig": {
61
+ "access": "public"
62
+ },
63
+ "dependencies": {
64
+ "@opendikw/web-client": "0.1.0-rc.1",
65
+ "lucide-react": "1.49.0",
66
+ "markdown-it": "15.0.2",
67
+ "katex": "0.18.9",
68
+ "mermaid": "11.17.2",
69
+ "echarts": "6.1.0"
70
+ }
71
+ }