@deepfuture/dui-core 0.0.2 → 0.0.5
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 +9 -1
- package/apply-theme.d.ts +2 -0
- package/apply-theme.js +4 -0
- package/floating-portal-controller.js +11 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -163,7 +163,14 @@ A visual editor for design tokens. Edit colors with OKLCH sliders, tweak spacing
|
|
|
163
163
|
|
|
164
164
|
### Inspector
|
|
165
165
|
|
|
166
|
-
|
|
166
|
+
A runtime inspector and mutation API for DUI components. Two interfaces:
|
|
167
|
+
|
|
168
|
+
- **Visual UI** (Ctrl+Shift+I) — hover-highlight components, inspect properties/tokens/styles, edit theme CSS and design tokens live
|
|
169
|
+
- **Console API** — `window.__dui_inspect()`, `window.__dui_mutate.*`, `window.__dui_export()` for programmatic access by agents or scripts
|
|
170
|
+
|
|
171
|
+
Both share a changelog, so agent and human edits are visible to each other. Changes can be exported as structured source file diffs.
|
|
172
|
+
|
|
173
|
+
See **[Inspector docs](docs/inspector.md)** for the full API reference and usage guide.
|
|
167
174
|
|
|
168
175
|
## Documentation
|
|
169
176
|
|
|
@@ -172,6 +179,7 @@ Toggle with **Ctrl+Shift+I** to inspect any DUI component at runtime — view pr
|
|
|
172
179
|
- [Creating Components](docs/creating-components.md) — guide for adding new components
|
|
173
180
|
- [Theming](docs/theming.md) — theme system, design tokens, writing component styles
|
|
174
181
|
- [Consuming](docs/consuming.md) — integrating DUI into an app
|
|
182
|
+
- [Inspector](docs/inspector.md) — runtime inspection, mutation API, and visual editor
|
|
175
183
|
- [Accessibility](docs/accessibility.md) — accessibility patterns and guidelines
|
|
176
184
|
|
|
177
185
|
## Contributing
|
package/apply-theme.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export interface DuiTheme {
|
|
|
12
12
|
base: CSSResult;
|
|
13
13
|
/** Tag name → component aesthetic styles. */
|
|
14
14
|
styles: Map<string, CSSResult>;
|
|
15
|
+
/** Optional prose stylesheet for .dui-prose rich-text styling. */
|
|
16
|
+
prose?: CSSStyleSheet;
|
|
15
17
|
}
|
|
16
18
|
export interface ApplyThemeOptions {
|
|
17
19
|
theme: DuiTheme;
|
package/apply-theme.js
CHANGED
|
@@ -14,6 +14,10 @@ export function applyTheme({ theme, components }) {
|
|
|
14
14
|
if (!document.adoptedStyleSheets.includes(theme.tokens)) {
|
|
15
15
|
document.adoptedStyleSheets = [...document.adoptedStyleSheets, theme.tokens];
|
|
16
16
|
}
|
|
17
|
+
// 1b. Inject prose stylesheet if present (idempotent)
|
|
18
|
+
if (theme.prose && !document.adoptedStyleSheets.includes(theme.prose)) {
|
|
19
|
+
document.adoptedStyleSheets = [...document.adoptedStyleSheets, theme.prose];
|
|
20
|
+
}
|
|
17
21
|
// 2. For each component, create a themed subclass and register it
|
|
18
22
|
for (const Base of components) {
|
|
19
23
|
const tagName = Base.tagName;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* provided overlay root) so that popups escape `container-type` ancestors.
|
|
5
5
|
*/
|
|
6
6
|
import { adoptStyles, render, } from "lit";
|
|
7
|
+
import { getActiveTheme } from "./apply-theme.js";
|
|
7
8
|
import { notifyPopupClosing, notifyPopupOpening } from "./popup-coordinator.js";
|
|
8
9
|
import { onTransitionEnd, startFixedAutoUpdate, waitForAnimationFrame, } from "./floating-popup-utils.js";
|
|
9
10
|
export class FloatingPortalController {
|
|
@@ -161,9 +162,17 @@ export class FloatingPortalController {
|
|
|
161
162
|
positioner.style.pointerEvents = "none";
|
|
162
163
|
positioner.setAttribute("data-floating-portal", "");
|
|
163
164
|
positioner.setAttribute("data-dui-portal-for", this.#host.tagName.toLowerCase());
|
|
164
|
-
|
|
165
|
+
const theme = getActiveTheme();
|
|
166
|
+
const themeTag = this.#host.tagName.toLowerCase();
|
|
167
|
+
const themeComponentStyles = theme?.styles.get(themeTag);
|
|
168
|
+
const allStyles = [
|
|
169
|
+
...(this.#styles ?? []),
|
|
170
|
+
...(theme?.base ? [theme.base] : []),
|
|
171
|
+
...(themeComponentStyles ? [themeComponentStyles] : []),
|
|
172
|
+
];
|
|
173
|
+
if (allStyles.length > 0) {
|
|
165
174
|
const shadow = positioner.attachShadow({ mode: "open" });
|
|
166
|
-
adoptStyles(shadow,
|
|
175
|
+
adoptStyles(shadow, allStyles);
|
|
167
176
|
}
|
|
168
177
|
overlayRoot.appendChild(positioner);
|
|
169
178
|
this.#positioner = positioner;
|