nudge-ui 0.2.0 → 0.2.2
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/bin/nudge-ui.mjs +3 -1
- package/dist/cli/agentCommand.d.ts +8 -0
- package/dist/cli/agentCommand.js +59 -0
- package/dist/client.mjs +878 -11
- package/dist/hosts/astro/astroRuntimeConfig.js +1 -1
- package/dist/hosts/astro/clientTransport.js +63 -11
- package/dist/hosts/astro/integration.d.ts +2 -2
- package/dist/hosts/astro/integration.js +4 -3
- package/dist/hosts/environment.d.ts +15 -0
- package/dist/hosts/environment.js +16 -0
- package/dist/hosts/next/sidecar.d.ts +4 -0
- package/dist/hosts/next/sidecar.js +56 -7
- package/dist/hosts/next/wrapper.d.ts +2 -0
- package/dist/hosts/next/wrapper.js +32 -3
- package/dist/hosts/projectBridge.d.ts +21 -0
- package/dist/hosts/projectBridge.js +98 -0
- package/dist/hosts/static/cli.d.ts +1 -1
- package/dist/hosts/static/cli.js +6 -1
- package/dist/hosts/static/manifest.d.ts +1 -1
- package/dist/hosts/static/manifest.js +3 -1
- package/dist/hosts/static/server.js +45 -3
- package/dist/hosts/vite/vite.d.ts +6 -1
- package/dist/hosts/vite/vite.js +82 -15
- package/dist/inspector/agent/McpConnectionDialog.d.ts +5 -4
- package/dist/inspector/agent/McpConnectionDialog.js +20 -37
- package/dist/inspector/agent/client.d.ts +16 -3
- package/dist/inspector/agent/client.js +114 -11
- package/dist/inspector/agent/connectionStatus.d.ts +3 -3
- package/dist/inspector/agent/connectionStatus.js +11 -4
- package/dist/inspector/agent/httpTransport.d.ts +8 -0
- package/dist/inspector/agent/httpTransport.js +78 -18
- package/dist/inspector/agent/protocol.d.ts +11 -3
- package/dist/inspector/agent/protocol.js +1 -1
- package/dist/inspector/agent/verification.d.ts +1 -1
- package/dist/inspector/agent/verification.js +69 -12
- package/dist/inspector/canvas/CanvasCard.d.ts +5 -3
- package/dist/inspector/canvas/CanvasCard.js +181 -91
- package/dist/inspector/canvas/CanvasElementOverlay.js +288 -52
- package/dist/inspector/canvas/CanvasToolbar.d.ts +12 -0
- package/dist/inspector/canvas/CanvasToolbar.js +24 -0
- package/dist/inspector/canvas/CanvasWorkspace.d.ts +4 -1
- package/dist/inspector/canvas/CanvasWorkspace.js +410 -72
- package/dist/inspector/canvas/activeCanvasDocument.d.ts +5 -0
- package/dist/inspector/canvas/activeCanvasDocument.js +23 -0
- package/dist/inspector/canvas/canvasResize.d.ts +30 -0
- package/dist/inspector/canvas/canvasResize.js +52 -0
- package/dist/inspector/canvas/canvasStore.d.ts +30 -6
- package/dist/inspector/canvas/canvasStore.js +128 -61
- package/dist/inspector/canvas/frameProtocol.d.ts +82 -5
- package/dist/inspector/canvas/frameProtocol.js +63 -2
- package/dist/inspector/canvas/keyboardShortcuts.d.ts +4 -0
- package/dist/inspector/canvas/keyboardShortcuts.js +16 -0
- package/dist/inspector/canvas/linkEligibility.d.ts +0 -5
- package/dist/inspector/canvas/linkEligibility.js +0 -29
- package/dist/inspector/canvas/projection.d.ts +7 -0
- package/dist/inspector/canvas/projection.js +118 -25
- package/dist/inspector/canvas/rendererBootstrap.js +42 -29
- package/dist/inspector/canvas/rendererElementSelector.d.ts +1 -1
- package/dist/inspector/canvas/rendererElementSelector.js +385 -58
- package/dist/inspector/canvas/rendererMessageRouter.d.ts +11 -0
- package/dist/inspector/canvas/rendererMessageRouter.js +43 -0
- package/dist/inspector/canvas/rendererSelectionProxy.js +6 -2
- package/dist/inspector/canvas/sessionStore.d.ts +1 -0
- package/dist/inspector/canvas/sessionStore.js +12 -4
- package/dist/inspector/canvas/staleChangeDetector.js +16 -14
- package/dist/inspector/changes/changesLog.js +31 -1
- package/dist/inspector/changes/managedStyleProjection.d.ts +1 -1
- package/dist/inspector/changes/managedStyleProjection.js +3 -3
- package/dist/inspector/changes/structuralTypes.d.ts +4 -0
- package/dist/inspector/changes/workspaceChanges.d.ts +4 -0
- package/dist/inspector/changes/workspaceChanges.js +29 -3
- package/dist/inspector/clientManifest.d.ts +7 -0
- package/dist/inspector/clientManifest.js +12 -0
- package/dist/inspector/componentSemantics/adapterRegistry.js +4 -3
- package/dist/inspector/componentSemantics/runtimeBridge.d.ts +2 -2
- package/dist/inspector/componentSemantics/runtimeBridge.js +16 -3
- package/dist/inspector/index.d.ts +2 -0
- package/dist/inspector/index.js +80 -32
- package/dist/inspector/inline-text/inlineTextDiagnostics.d.ts +10 -0
- package/dist/inspector/inline-text/inlineTextDiagnostics.js +65 -0
- package/dist/inspector/inline-text/inlineTextEditor.d.ts +3 -5
- package/dist/inspector/inline-text/inlineTextEditor.js +74 -206
- package/dist/inspector/inline-text/inlineTextFeedback.d.ts +5 -0
- package/dist/inspector/inline-text/inlineTextFeedback.js +27 -0
- package/dist/inspector/inline-text/inlineTextLifecycle.js +2 -0
- package/dist/inspector/inline-text/textEditChange.d.ts +14 -0
- package/dist/inspector/inline-text/textEditChange.js +165 -0
- package/dist/inspector/inspection/selectionProperty.d.ts +1 -0
- package/dist/inspector/inspection/selectionProperty.js +1 -0
- package/dist/inspector/overlay/DomNavigator.d.ts +10 -0
- package/dist/inspector/overlay/DomNavigator.js +40 -0
- package/dist/inspector/overlay/InspectorOverlay.js +6 -2
- package/dist/inspector/overlay/clickPolicy.d.ts +18 -2
- package/dist/inspector/overlay/clickPolicy.js +34 -3
- package/dist/inspector/overlay/elementSelector.d.ts +1 -1
- package/dist/inspector/overlay/elementSelector.js +18 -7
- package/dist/inspector/overlay/selectedGeometry.js +21 -2
- package/dist/inspector/overlay/spacingGestures.d.ts +45 -0
- package/dist/inspector/overlay/spacingGestures.js +351 -0
- package/dist/inspector/overlay/structuralGestures.d.ts +2 -2
- package/dist/inspector/overlay/structuralGestures.js +12 -10
- package/dist/inspector/projection/managedStylesheet.js +4 -1
- package/dist/inspector/projection/renderedInstance.d.ts +2 -0
- package/dist/inspector/projection/renderedInstance.js +5 -1
- package/dist/inspector/projection/structuralProjection.d.ts +2 -0
- package/dist/inspector/projection/structuralProjection.js +85 -1
- package/dist/inspector/projection/structuralProjectionBoundary.js +17 -1
- package/dist/inspector/projection/textProjection.d.ts +2 -0
- package/dist/inspector/projection/textProjection.js +10 -4
- package/dist/inspector/prompt/clipboardHandoff.d.ts +1 -1
- package/dist/inspector/prompt/clipboardHandoff.js +3 -3
- package/dist/inspector/prompt/generatePrompt.d.ts +2 -1
- package/dist/inspector/prompt/generatePrompt.js +19 -2
- package/dist/inspector/runtime/editorShell.d.ts +2 -0
- package/dist/inspector/runtime/editorShell.js +4 -0
- package/dist/inspector/runtime/runtimeConfig.d.ts +5 -1
- package/dist/inspector/runtime/runtimeConfig.js +4 -0
- package/dist/inspector/selection/hierarchy.d.ts +6 -0
- package/dist/inspector/selection/hierarchy.js +8 -0
- package/dist/inspector/selection/selectionStore.js +2 -0
- package/dist/inspector/settings/SettingsDialog.d.ts +1 -1
- package/dist/inspector/settings/SettingsDialog.js +12 -2
- package/dist/inspector/shell/AppShell.js +5 -1
- package/dist/inspector/shell/ChangesLog.js +26 -22
- package/dist/inspector/shell/CopyPromptButton.js +102 -19
- package/dist/inspector/shell/EmptyState.js +1 -1
- package/dist/inspector/shell/InspectorShell.d.ts +0 -1
- package/dist/inspector/shell/InspectorShell.js +38 -42
- package/dist/inspector/shell/PeekOriginalButton.d.ts +7 -0
- package/dist/inspector/shell/PeekOriginalButton.js +57 -0
- package/dist/inspector/shell/PeekOriginalIcon.d.ts +7 -0
- package/dist/inspector/shell/PeekOriginalIcon.js +9 -0
- package/dist/inspector/shell/originalPreview.d.ts +9 -0
- package/dist/inspector/shell/originalPreview.js +61 -0
- package/dist/inspector/shell/shortcuts.d.ts +3 -0
- package/dist/inspector/shell/shortcuts.js +15 -0
- package/dist/inspector/sketch/SketchChanges.d.ts +2 -0
- package/dist/inspector/sketch/SketchChanges.js +72 -0
- package/dist/inspector/sketch/SketchEditor.d.ts +21 -0
- package/dist/inspector/sketch/SketchEditor.js +402 -0
- package/dist/inspector/sketch/SketchEntryButton.d.ts +4 -0
- package/dist/inspector/sketch/SketchEntryButton.js +11 -0
- package/dist/inspector/sketch/SketchFrameOverlay.d.ts +11 -0
- package/dist/inspector/sketch/SketchFrameOverlay.js +119 -0
- package/dist/inspector/sketch/SketchLayersPanel.d.ts +2 -0
- package/dist/inspector/sketch/SketchLayersPanel.js +63 -0
- package/dist/inspector/sketch/SketchOverlay.d.ts +19 -0
- package/dist/inspector/sketch/SketchOverlay.js +420 -0
- package/dist/inspector/sketch/SketchPromptPanel.d.ts +15 -0
- package/dist/inspector/sketch/SketchPromptPanel.js +18 -0
- package/dist/inspector/sketch/SketchWorkspace.d.ts +13 -0
- package/dist/inspector/sketch/SketchWorkspace.js +152 -0
- package/dist/inspector/sketch/capture.d.ts +55 -0
- package/dist/inspector/sketch/capture.js +350 -0
- package/dist/inspector/sketch/freehand.d.ts +13 -0
- package/dist/inspector/sketch/freehand.js +64 -0
- package/dist/inspector/sketch/geometry.d.ts +17 -0
- package/dist/inspector/sketch/geometry.js +98 -0
- package/dist/inspector/sketch/handoff.d.ts +21 -0
- package/dist/inspector/sketch/handoff.js +72 -0
- package/dist/inspector/sketch/interaction.d.ts +21 -0
- package/dist/inspector/sketch/interaction.js +98 -0
- package/dist/inspector/sketch/model.d.ts +104 -0
- package/dist/inspector/sketch/model.js +282 -0
- package/dist/inspector/sketch/persistence.d.ts +21 -0
- package/dist/inspector/sketch/persistence.js +205 -0
- package/dist/inspector/sketch/raster.d.ts +22 -0
- package/dist/inspector/sketch/raster.js +203 -0
- package/dist/inspector/sketch/sketchNote.d.ts +10 -0
- package/dist/inspector/sketch/sketchNote.js +30 -0
- package/dist/inspector/sketch/store.d.ts +47 -0
- package/dist/inspector/sketch/store.js +434 -0
- package/dist/inspector/styleEditors/BorderEditor.js +15 -19
- package/dist/inspector/styleEditors/BorderRadiusEditor.js +6 -6
- package/dist/inspector/styleEditors/BoxShadowEditor.js +12 -1
- package/dist/inspector/styleEditors/ColorPicker.js +11 -36
- package/dist/inspector/styleEditors/GapField.d.ts +3 -2
- package/dist/inspector/styleEditors/GapField.js +2 -2
- package/dist/inspector/styleEditors/GridSection.js +1 -1
- package/dist/inspector/styleEditors/LayoutSection.js +11 -8
- package/dist/inspector/styleEditors/SpacingBox.js +31 -33
- package/dist/inspector/styleEditors/layoutPreviewState.d.ts +5 -0
- package/dist/inspector/styleEditors/layoutPreviewState.js +19 -0
- package/dist/inspector/styleEditors/layoutValue.js +3 -0
- package/dist/inspector/styleEditors/nudgeValue.d.ts +11 -0
- package/dist/inspector/styleEditors/nudgeValue.js +93 -5
- package/dist/inspector/styleEditors/stylePresence.d.ts +7 -0
- package/dist/inspector/styleEditors/stylePresence.js +22 -0
- package/dist/inspector/styleEditors/textRelevance.d.ts +3 -0
- package/dist/inspector/styleEditors/textRelevance.js +35 -0
- package/dist/inspector/styleEditors/useFieldVisibility.d.ts +6 -0
- package/dist/inspector/styleEditors/useFieldVisibility.js +26 -0
- package/dist/inspector/tokens/TokenField.js +130 -7
- package/dist/inspector/tokens/TokensPanel.js +2 -1
- package/dist/inspector/tokens/dragPointerLock.d.ts +8 -0
- package/dist/inspector/tokens/dragPointerLock.js +70 -0
- package/dist/inspector/tokens/editActions.d.ts +2 -0
- package/dist/inspector/tokens/editActions.js +2 -2
- package/dist/inspector/tokens/resolution/cssomCollector.d.ts +1 -1
- package/dist/inspector/tokens/resolution/cssomCollector.js +9 -5
- package/dist/inspector/tokens/resolution/ruleMatching.d.ts +40 -0
- package/dist/inspector/tokens/resolution/ruleMatching.js +423 -0
- package/dist/inspector/tokens/resolution/selectorSemantics.d.ts +19 -3
- package/dist/inspector/tokens/resolution/selectorSemantics.js +378 -4
- package/dist/inspector/tokens/resolution.d.ts +3 -26
- package/dist/inspector/tokens/resolution.js +44 -735
- package/dist/inspector/tokens/tokenAvailability.d.ts +18 -0
- package/dist/inspector/tokens/tokenAvailability.js +204 -0
- package/dist/inspector/ui/Button.d.ts +1 -1
- package/dist/inspector/ui/Disclosure.d.ts +22 -0
- package/dist/inspector/ui/Disclosure.js +13 -0
- package/dist/inspector/ui/SideValuesField.js +2 -2
- package/dist/inspector/ui/StatusCallout.d.ts +4 -1
- package/dist/inspector/ui/StatusCallout.js +2 -2
- package/dist/inspector/ui/dragCursor.d.ts +8 -0
- package/dist/inspector/ui/dragCursor.js +21 -0
- package/dist/inspector/ui/styles.js +21 -17
- package/dist/internal/agent-protocol.d.ts +65 -1
- package/dist/internal/agent-protocol.js +183 -3
- package/dist/nudge-ui.mjs +276 -58
- package/dist/transport/editor.d.ts +47 -0
- package/dist/transport/editor.js +163 -0
- package/dist/transport/index.d.ts +1 -0
- package/dist/transport/index.js +1 -0
- package/dist/transport/routes.d.ts +10 -0
- package/dist/transport/routes.js +10 -0
- package/package.json +3 -1
- package/dist/inspector/shell/DomNavigation.d.ts +0 -8
- package/dist/inspector/shell/DomNavigation.js +0 -30
- package/dist/inspector/shell/panelLayout.d.ts +0 -2
- package/dist/inspector/shell/panelLayout.js +0 -29
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { TokenDefinition, TokenEntry, TokenTable } from "../../css/model/index.js";
|
|
2
|
+
export declare function buildTokenTable(entries: readonly TokenEntry[]): TokenTable;
|
|
3
|
+
export declare function getTokenTable(): TokenTable;
|
|
4
|
+
/**
|
|
5
|
+
* The build-time catalog is intentionally an inventory of every project token.
|
|
6
|
+
* Element edits must instead use only custom properties resolved in that
|
|
7
|
+
* element's cascade; a token defined by a lazy stylesheet is not usable until
|
|
8
|
+
* that stylesheet is attached to the document. Entries are cached per element
|
|
9
|
+
* until the element or stylesheet revision changes; the derived table reuses
|
|
10
|
+
* `buildTokenTable`'s input-identity memo.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getAvailableTokenEntriesForElement(el: HTMLElement, definitions?: readonly TokenDefinition[]): TokenEntry[];
|
|
13
|
+
/**
|
|
14
|
+
* Produces the page catalog used by the global Tokens settings section. When
|
|
15
|
+
* the document exposes mappable source identities, declarations from unloaded
|
|
16
|
+
* CSS files are removed. Opaque compiled URLs leave the adapter catalog intact.
|
|
17
|
+
*/
|
|
18
|
+
export declare function getAvailableTokenCatalog(root?: HTMLElement, definitions?: readonly TokenDefinition[]): TokenDefinition[];
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { interpretValue } from "../../css/value-semantics/index.js";
|
|
2
|
+
import { getElementComputedStyle } from "../runtime/domRealm.js";
|
|
3
|
+
import { getNudgeUiRuntimeConfig } from "../runtime/runtimeConfig.js";
|
|
4
|
+
import { createInspectorValueContext } from "./valueSemanticsAdapter.js";
|
|
5
|
+
import { collectRules as collectCssomRules, documentRevisions as getDocumentRevisions, registerResolutionLineage, } from "./resolution/cssomCollector.js";
|
|
6
|
+
const tokenTableMemo = new WeakMap();
|
|
7
|
+
export function buildTokenTable(entries) {
|
|
8
|
+
const cached = tokenTableMemo.get(entries);
|
|
9
|
+
if (cached)
|
|
10
|
+
return cached;
|
|
11
|
+
const table = {};
|
|
12
|
+
for (const entry of entries) {
|
|
13
|
+
table[entry.name] = entry;
|
|
14
|
+
if (entry.cssName)
|
|
15
|
+
table[entry.cssName] = entry;
|
|
16
|
+
}
|
|
17
|
+
tokenTableMemo.set(entries, table);
|
|
18
|
+
return table;
|
|
19
|
+
}
|
|
20
|
+
let tableCache = null;
|
|
21
|
+
let tableSource = null;
|
|
22
|
+
export function getTokenTable() {
|
|
23
|
+
const { tokens } = getNudgeUiRuntimeConfig();
|
|
24
|
+
if (tableCache !== null && tableSource === tokens)
|
|
25
|
+
return tableCache;
|
|
26
|
+
tableCache = buildTokenTable(tokens);
|
|
27
|
+
tableSource = tokens;
|
|
28
|
+
return tableCache;
|
|
29
|
+
}
|
|
30
|
+
function isCustomPropertyToken(definition) {
|
|
31
|
+
return definition.cssName.startsWith("--");
|
|
32
|
+
}
|
|
33
|
+
function entryFromDefinition(definition, value) {
|
|
34
|
+
return {
|
|
35
|
+
name: definition.name,
|
|
36
|
+
cssName: definition.cssName,
|
|
37
|
+
value,
|
|
38
|
+
source: definition.declarations[0]?.source ?? "",
|
|
39
|
+
cssValue: definition.cssValue,
|
|
40
|
+
adapter: definition.adapter,
|
|
41
|
+
origin: definition.origin,
|
|
42
|
+
editable: definition.editable,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
const tokenEntriesCache = new WeakMap();
|
|
46
|
+
/**
|
|
47
|
+
* The build-time catalog is intentionally an inventory of every project token.
|
|
48
|
+
* Element edits must instead use only custom properties resolved in that
|
|
49
|
+
* element's cascade; a token defined by a lazy stylesheet is not usable until
|
|
50
|
+
* that stylesheet is attached to the document. Entries are cached per element
|
|
51
|
+
* until the element or stylesheet revision changes; the derived table reuses
|
|
52
|
+
* `buildTokenTable`'s input-identity memo.
|
|
53
|
+
*/
|
|
54
|
+
export function getAvailableTokenEntriesForElement(el, definitions = getNudgeUiRuntimeConfig().tokenCatalog) {
|
|
55
|
+
const revisions = getDocumentRevisions(el.ownerDocument ?? document);
|
|
56
|
+
const cached = tokenEntriesCache.get(el);
|
|
57
|
+
if (cached && cached.elementRevision === revisions.element
|
|
58
|
+
&& cached.stylesheetRevision === revisions.stylesheet
|
|
59
|
+
&& cached.definitions === definitions) {
|
|
60
|
+
return cached.entries;
|
|
61
|
+
}
|
|
62
|
+
registerResolutionLineage(el);
|
|
63
|
+
const computed = getElementComputedStyle(el);
|
|
64
|
+
const available = definitions.flatMap((definition) => {
|
|
65
|
+
if (!isCustomPropertyToken(definition)) {
|
|
66
|
+
// Literal adapters (for example Tailwind v3) do not have a browser
|
|
67
|
+
// custom property to probe. Their adapter owns their availability.
|
|
68
|
+
return [entryFromDefinition(definition, definition.declarations[0]?.value ?? "")];
|
|
69
|
+
}
|
|
70
|
+
const value = computed.getPropertyValue(definition.cssName).trim();
|
|
71
|
+
return value ? [entryFromDefinition(definition, value)] : [];
|
|
72
|
+
});
|
|
73
|
+
const intermediateTable = buildTokenTable(available);
|
|
74
|
+
const entries = available.map((entry) => ({
|
|
75
|
+
...entry,
|
|
76
|
+
value: interpretValue("--nudge-ui-token", entry.value, createInspectorValueContext(intermediateTable))[0].resolvedValue,
|
|
77
|
+
}));
|
|
78
|
+
tokenEntriesCache.set(el, {
|
|
79
|
+
elementRevision: revisions.element,
|
|
80
|
+
stylesheetRevision: revisions.stylesheet,
|
|
81
|
+
definitions,
|
|
82
|
+
entries,
|
|
83
|
+
});
|
|
84
|
+
return entries;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Replaces build-time token declaration hints with declarations serialized by
|
|
88
|
+
* the browser from the stylesheets currently attached to this document.
|
|
89
|
+
*/
|
|
90
|
+
function hydrateTokenCatalogFromCssom(definitions, doc = document) {
|
|
91
|
+
const needsHydration = (definition) => definition.declarations.length === 0
|
|
92
|
+
|| (definition.adapter === "vanilla-extract" && definition.declarations.every((declaration) => declaration.value.trim() === `var(${definition.cssName})`
|
|
93
|
+
&& !declaration.context.selector
|
|
94
|
+
&& !declaration.context.wrappers?.length));
|
|
95
|
+
const known = new Set(definitions.filter(needsHydration).map((definition) => definition.cssName));
|
|
96
|
+
const declarations = new Map();
|
|
97
|
+
for (const rule of collectCssomRules(doc).rules) {
|
|
98
|
+
if (rule.source === "#nudge-ui-styles")
|
|
99
|
+
continue;
|
|
100
|
+
for (const declaration of rule.declarations) {
|
|
101
|
+
if (!known.has(declaration.property))
|
|
102
|
+
continue;
|
|
103
|
+
const wrappers = [
|
|
104
|
+
...(rule.layer ? [{ kind: "layer", params: rule.layer }] : []),
|
|
105
|
+
...(rule.atRules ?? []).flatMap((atRule) => atRule.kind === "media" || atRule.kind === "supports"
|
|
106
|
+
? [{ kind: atRule.kind, params: atRule.params }]
|
|
107
|
+
: []),
|
|
108
|
+
];
|
|
109
|
+
const list = declarations.get(declaration.property) ?? [];
|
|
110
|
+
list.push({
|
|
111
|
+
id: `${declaration.property}\u0000${rule.source ?? "cssom"}\u0000${rule.sourceOrder ?? list.length}`,
|
|
112
|
+
order: rule.sourceOrder,
|
|
113
|
+
value: declaration.value,
|
|
114
|
+
source: rule.source ?? "cssom",
|
|
115
|
+
important: Boolean(declaration.important),
|
|
116
|
+
context: {
|
|
117
|
+
selector: rule.selectorText,
|
|
118
|
+
...(wrappers.length > 0 ? { wrappers } : {}),
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
declarations.set(declaration.property, list);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return definitions.map((definition) => {
|
|
125
|
+
if (!needsHydration(definition))
|
|
126
|
+
return definition;
|
|
127
|
+
const accepted = declarations.get(definition.cssName);
|
|
128
|
+
return accepted?.length ? { ...definition, declarations: accepted } : definition;
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
function sourceFile(source) {
|
|
132
|
+
return source.replace(/:\d+$/, "").split(/[?#]/, 1)[0] ?? source;
|
|
133
|
+
}
|
|
134
|
+
function normalizedPath(value) {
|
|
135
|
+
return decodeURIComponent(value).replace(/\\/g, "/").replace(/^file:\/\//, "").replace(/\/+$/, "");
|
|
136
|
+
}
|
|
137
|
+
function loadedStylesheetSources(doc) {
|
|
138
|
+
const sourceIdentityByPath = new Map();
|
|
139
|
+
for (const node of doc.querySelectorAll('style[data-vite-dev-id], link[rel~="stylesheet"][href]')) {
|
|
140
|
+
const providesAuthoredIdentity = node.tagName === "STYLE";
|
|
141
|
+
const source = providesAuthoredIdentity
|
|
142
|
+
? node.dataset.viteDevId
|
|
143
|
+
: node.getAttribute("href");
|
|
144
|
+
if (!source)
|
|
145
|
+
continue;
|
|
146
|
+
const path = normalizedPath(source.split(/[?#]/, 1)[0] ?? source);
|
|
147
|
+
sourceIdentityByPath.set(path, providesAuthoredIdentity || sourceIdentityByPath.get(path) === true);
|
|
148
|
+
}
|
|
149
|
+
return Array.from(sourceIdentityByPath, ([path, providesAuthoredIdentity]) => ({
|
|
150
|
+
path,
|
|
151
|
+
providesAuthoredIdentity,
|
|
152
|
+
}));
|
|
153
|
+
}
|
|
154
|
+
function isLoadedCssSource(source, loadedSources) {
|
|
155
|
+
const file = sourceFile(source);
|
|
156
|
+
if (!/\.css$/i.test(file) || loadedSources.length === 0)
|
|
157
|
+
return true;
|
|
158
|
+
const normalizedFile = normalizedPath(file);
|
|
159
|
+
return loadedSources.some((loaded) => loaded === normalizedFile
|
|
160
|
+
|| loaded.endsWith(`/${normalizedFile}`)
|
|
161
|
+
|| normalizedFile.endsWith(`/${loaded}`));
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Returns stylesheet identities only when the browser gave us a complete,
|
|
165
|
+
* authored-source mapping. A compiled host can expose a mixture of source-like
|
|
166
|
+
* and opaque CSS URLs; treating the mapped subset as complete would make
|
|
167
|
+
* declarations behind the opaque URLs look lazy even while their variables are
|
|
168
|
+
* live in the document.
|
|
169
|
+
*/
|
|
170
|
+
function confidentlyLoadedStylesheetSources(definitions, loadedSources) {
|
|
171
|
+
const cssSources = definitions.flatMap((definition) => definition.declarations
|
|
172
|
+
.map((declaration) => declaration.source)
|
|
173
|
+
.filter((source) => /\.css$/i.test(sourceFile(source))));
|
|
174
|
+
const known = new Set();
|
|
175
|
+
for (const loaded of loadedSources) {
|
|
176
|
+
if (loaded.providesAuthoredIdentity
|
|
177
|
+
|| cssSources.some((source) => isLoadedCssSource(source, [loaded.path]))) {
|
|
178
|
+
known.add(loaded.path);
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
// One opaque compiled URL can contain any authored declaration, so the
|
|
182
|
+
// document does not provide enough evidence to remove unloaded sources.
|
|
183
|
+
return [];
|
|
184
|
+
}
|
|
185
|
+
return [...known];
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Produces the page catalog used by the global Tokens settings section. When
|
|
189
|
+
* the document exposes mappable source identities, declarations from unloaded
|
|
190
|
+
* CSS files are removed. Opaque compiled URLs leave the adapter catalog intact.
|
|
191
|
+
*/
|
|
192
|
+
export function getAvailableTokenCatalog(root = document.documentElement, definitions = getNudgeUiRuntimeConfig().tokenCatalog) {
|
|
193
|
+
const computed = getElementComputedStyle(root);
|
|
194
|
+
const hydrated = hydrateTokenCatalogFromCssom(definitions, root.ownerDocument ?? document);
|
|
195
|
+
const loadedSources = confidentlyLoadedStylesheetSources(hydrated, loadedStylesheetSources(root.ownerDocument ?? document));
|
|
196
|
+
return hydrated.flatMap((definition) => {
|
|
197
|
+
if (!isCustomPropertyToken(definition))
|
|
198
|
+
return [definition];
|
|
199
|
+
if (!computed.getPropertyValue(definition.cssName).trim())
|
|
200
|
+
return [];
|
|
201
|
+
const declarations = definition.declarations.filter((declaration) => isLoadedCssSource(declaration.source, loadedSources));
|
|
202
|
+
return declarations.length > 0 ? [{ ...definition, declarations }] : [];
|
|
203
|
+
});
|
|
204
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ButtonHTMLAttributes, ReactElement } from "react";
|
|
2
2
|
export type ButtonVariant = "primary" | "secondary" | "quiet" | "danger" | "disabled";
|
|
3
|
-
export type ButtonSize = "default" | "compact";
|
|
3
|
+
export type ButtonSize = "default" | "compact" | "large";
|
|
4
4
|
export type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
5
5
|
variant?: ButtonVariant;
|
|
6
6
|
size?: ButtonSize;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from "react";
|
|
2
|
+
export interface DisclosureProps {
|
|
3
|
+
readonly title: ReactNode;
|
|
4
|
+
/** Optional accessory rendered between the label and the chevron (e.g. a count badge). */
|
|
5
|
+
readonly badge?: ReactNode;
|
|
6
|
+
readonly children: ReactNode;
|
|
7
|
+
readonly className?: string;
|
|
8
|
+
readonly triggerClassName?: string;
|
|
9
|
+
readonly panelClassName?: string;
|
|
10
|
+
readonly defaultOpen?: boolean;
|
|
11
|
+
readonly open?: boolean;
|
|
12
|
+
readonly onOpenChange?: (open: boolean) => void;
|
|
13
|
+
/** Keeps panel content in the DOM while collapsed, matching native details behavior. */
|
|
14
|
+
readonly keepMounted?: boolean;
|
|
15
|
+
readonly "data-test"?: string;
|
|
16
|
+
readonly triggerDataTest?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A single collapsible disclosure built on Base UI Collapsible.
|
|
20
|
+
* Replaces native details/summary for consistent 12px label styling and chevron.
|
|
21
|
+
*/
|
|
22
|
+
export declare function Disclosure({ title, badge, children, className, triggerClassName, panelClassName, defaultOpen, open, onOpenChange, keepMounted, "data-test": dataTest, triggerDataTest, }: DisclosureProps): ReactElement;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Collapsible } from "@base-ui/react/collapsible";
|
|
3
|
+
import { IconChevronDown } from "@tabler/icons-react";
|
|
4
|
+
/**
|
|
5
|
+
* A single collapsible disclosure built on Base UI Collapsible.
|
|
6
|
+
* Replaces native details/summary for consistent 12px label styling and chevron.
|
|
7
|
+
*/
|
|
8
|
+
export function Disclosure({ title, badge, children, className, triggerClassName, panelClassName, defaultOpen, open, onOpenChange, keepMounted = true, "data-test": dataTest, triggerDataTest, }) {
|
|
9
|
+
function handleOpenChange(next) {
|
|
10
|
+
onOpenChange?.(next);
|
|
11
|
+
}
|
|
12
|
+
return (_jsxs(Collapsible.Root, { className: `disclosure${className ? ` ${className}` : ""}`, "data-test": dataTest, defaultOpen: defaultOpen, open: open, onOpenChange: handleOpenChange, children: [_jsxs(Collapsible.Trigger, { className: `disclosure__trigger${triggerClassName ? ` ${triggerClassName}` : ""}`, "data-test": triggerDataTest, children: [_jsx("span", { className: "disclosure__label", children: title }), badge, _jsx(IconChevronDown, { className: "disclosure__chevron", size: 15, stroke: 2, "aria-hidden": "true" })] }), _jsx(Collapsible.Panel, { keepMounted: keepMounted, className: `disclosure__panel${panelClassName ? ` ${panelClassName}` : ""}`, children: children })] }));
|
|
13
|
+
}
|
|
@@ -36,7 +36,7 @@ export function SideValuesField({ label, sides, pairedControls, defaultExpanded
|
|
|
36
36
|
}
|
|
37
37
|
return (_jsx("div", { className: "side-values", "data-test": dataTest, "data-property": dataProperty, "data-empty": empty ? "true" : undefined, ...(hasPairedControls
|
|
38
38
|
? { "data-expanded": isExpanded ? "true" : "false" }
|
|
39
|
-
: {}), children: empty ? (_jsxs("div", { className: "side-values__header", children: [_jsx("span", { className: "side-values__label", children: displayLabel }), emptyAction ?? (_jsx(IconButton, { variant: "quiet", size: "default", "data-test": "add-value", label: `Add ${labelText}`, title: `Add ${labelText}`, onClick: onAdd, children: _jsx(IconPlus, { size: 16, "aria-hidden": "true" }) }))] })) : hasPairedControls ? (_jsxs(_Fragment, { children: [showLabel ? (_jsx("div", { className: "side-values__header", children: _jsx("span", { className: "side-values__label", children: displayLabel }) })) : null, _jsxs("div", { className: "side-values__value-row", children: [isExpanded ? (_jsx(SideControls, { label: label, sides: sides })) : (_jsx("div", { className: "side-values__pairs", role: "group", "aria-label": `${labelText} Grouped Sides`, children: orderedPairedControls.map(({ axis, control, icon }) => (_jsxs(ControlSurface, { className: "side-values__side", "data-test": `pair-value-${axis}`, "data-axis": axis, "aria-label": `${labelText} ${axis === "horizontal" ? "Left And Right" : "Top And Bottom"}`, title: `${labelText} ${axis === "horizontal" ? "Left And Right" : "Top And Bottom"}`, children: [icon
|
|
39
|
+
: {}), children: empty ? (_jsxs("div", { className: "side-values__header", children: [_jsx("span", { className: "side-values__label", children: displayLabel }), emptyAction ?? (_jsx(IconButton, { variant: "quiet", size: "default", "data-test": "add-value", label: `Add ${labelText}`, title: `Add ${labelText}`, onClick: onAdd, children: _jsx(IconPlus, { size: 16, "aria-hidden": "true" }) }))] })) : hasPairedControls ? (_jsxs(_Fragment, { children: [showLabel ? (_jsx("div", { className: "side-values__header", children: _jsx("span", { className: "side-values__label", children: displayLabel }) })) : null, _jsxs("div", { className: "side-values__value-row", children: [isExpanded ? (_jsx(SideControls, { label: label, sides: sides })) : (_jsx("div", { className: "side-values__pairs", role: "group", "aria-label": `${labelText} Grouped Sides`, children: orderedPairedControls.map(({ axis, control, icon }) => (_jsxs(ControlSurface, { className: "side-values__side", "data-test": `pair-value-${axis}`, "data-axis": axis, "aria-label": `${labelText} ${axis === "horizontal" ? "Left And Right" : "Top And Bottom"}`, title: `${labelText} ${axis === "horizontal" ? "Left And Right" : "Top And Bottom"}`, children: [icon !== undefined ? icon : _jsx(AxisIndicator, { axis: axis }), _jsx("div", { className: "side-values__control", children: control })] }, axis))) })), _jsx(ToggleButton, { variant: "quiet", size: "default", "data-test": "individual-sides", label: isExpanded ? `Collapse ${labelText} Sides` : `Expand ${labelText} Sides`, title: isExpanded ? "Collapse To Grouped Sides" : "Expand To Individual Sides", pressed: isExpanded, onPressedChange: toggleExpanded, children: _jsx(IconBorderSides, { size: 16, "aria-hidden": "true" }) })] })] })) : (_jsxs(_Fragment, { children: [showLabel ? (_jsx("div", { className: "side-values__header", children: _jsx("span", { className: "side-values__label", children: displayLabel }) })) : null, _jsx(SideControls, { label: label, sides: sides })] })) }));
|
|
40
40
|
}
|
|
41
41
|
export function SideControls({ label, sides, layout = "sides", }) {
|
|
42
42
|
const displayOrder = layout === "corners" ? SIDE_NAMES : SIDE_DISPLAY_ORDER;
|
|
@@ -45,7 +45,7 @@ export function SideControls({ label, sides, layout = "sides", }) {
|
|
|
45
45
|
.filter((slot) => slot !== undefined);
|
|
46
46
|
const labelText = typeof label === "string" ? formatInspectorLabel(label) : String(label);
|
|
47
47
|
const itemGroupLabel = layout === "corners" ? "Individual Corners" : "Individual Sides";
|
|
48
|
-
return (_jsx("div", { className: "side-values__grid", "data-layout": layout, role: "group", "aria-label": `${labelText} ${itemGroupLabel}`, children: orderedSides.map(({ side, control, icon, sideLabel }) => (_jsxs(ControlSurface, { className: "side-values__side", "data-test": `side-value-${side}`, "data-side": side, "aria-label": `${labelText} ${sideLabel ?? formatInspectorLabel(side)}`, children: [icon
|
|
48
|
+
return (_jsx("div", { className: "side-values__grid", "data-layout": layout, role: "group", "aria-label": `${labelText} ${itemGroupLabel}`, children: orderedSides.map(({ side, control, icon, sideLabel }) => (_jsxs(ControlSurface, { className: "side-values__side", "data-test": `side-value-${side}`, "data-side": side, "aria-label": `${labelText} ${sideLabel ?? formatInspectorLabel(side)}`, children: [icon !== undefined ? icon : _jsx(SideIndicator, { side: side }), _jsx("div", { className: "side-values__control", children: control })] }, side))) }));
|
|
49
49
|
}
|
|
50
50
|
function AxisIndicator({ axis }) {
|
|
51
51
|
const emphasis = axis === "horizontal"
|
|
@@ -5,5 +5,8 @@ export interface StatusCalloutProps {
|
|
|
5
5
|
className?: string;
|
|
6
6
|
"data-test"?: string;
|
|
7
7
|
"data-lost"?: string;
|
|
8
|
+
role?: "status" | "alert";
|
|
9
|
+
"aria-live"?: "off" | "polite" | "assertive";
|
|
10
|
+
"aria-atomic"?: "true" | "false";
|
|
8
11
|
}
|
|
9
|
-
export declare function StatusCallout({ children, tone, className, "data-test": dataTest, "data-lost": dataLost }: StatusCalloutProps): ReactElement;
|
|
12
|
+
export declare function StatusCallout({ children, tone, className, "data-test": dataTest, "data-lost": dataLost, role, "aria-live": ariaLive, "aria-atomic": ariaAtomic, }: StatusCalloutProps): ReactElement;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
export function StatusCallout({ children, tone = "neutral", className, "data-test": dataTest, "data-lost": dataLost }) {
|
|
3
|
-
return (_jsx("div", { className: `status-callout status-callout--${tone}${className ? ` ${className}` : ""}`, "data-test": dataTest, "data-lost": dataLost, children: children }));
|
|
2
|
+
export function StatusCallout({ children, tone = "neutral", className, "data-test": dataTest, "data-lost": dataLost, role, "aria-live": ariaLive, "aria-atomic": ariaAtomic, }) {
|
|
3
|
+
return (_jsx("div", { className: `status-callout status-callout--${tone}${className ? ` ${className}` : ""}`, "data-test": dataTest, "data-lost": dataLost, role: role, "aria-live": ariaLive, "aria-atomic": ariaAtomic, children: children }));
|
|
4
4
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const DRAG_CURSOR_URL: string;
|
|
2
|
+
export declare const DRAG_CURSOR: string;
|
|
3
|
+
export declare const DRAG_CURSOR_STYLES: string;
|
|
4
|
+
/** Shows the same cursor at a fixed viewport point while the native cursor is locked. */
|
|
5
|
+
export declare function showLockedDragCursor(doc: Document, point: {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
}): () => void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const DRAG_CURSOR_SVG = `<svg width="18" height="9.5" viewBox="0 0 36 19" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<g filter="url(#right)"><path d="M19.1253 13.3682V3.50181C19.1253 2.77104 19.8836 2.28706 20.5464 2.5948L31.1718 7.52799C31.9436 7.88635 31.9436 8.98365 31.1718 9.34201L20.5464 14.2752C19.8836 14.5829 19.1253 14.099 19.1253 13.3682Z" fill="black" stroke="white"/></g>
|
|
3
|
+
<g filter="url(#left)"><path d="M16.1253 13.3682V3.50181C16.1253 2.77104 15.367 2.28706 14.7042 2.5948L4.07889 7.52799C3.30704 7.88635 3.30704 8.98365 4.07889 9.34201L14.7042 14.2752C15.367 14.5829 16.1253 14.099 16.1253 13.3682Z" fill="black" stroke="white"/></g>
|
|
4
|
+
<defs>
|
|
5
|
+
<filter id="right" x="15.6253" y="0" width="19.6253" height="18.87" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/><feOffset dy="1"/><feGaussianBlur stdDeviation="1.5"/><feComposite in2="hardAlpha" operator="out"/><feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/><feBlend mode="normal" in2="BackgroundImageFix" result="shadow"/><feBlend mode="normal" in="SourceGraphic" in2="shadow" result="shape"/></filter>
|
|
6
|
+
<filter id="left" x="0" y="0" width="19.6253" height="18.87" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/><feOffset dy="1"/><feGaussianBlur stdDeviation="1.5"/><feComposite in2="hardAlpha" operator="out"/><feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/><feBlend mode="normal" in2="BackgroundImageFix" result="shadow"/><feBlend mode="normal" in="SourceGraphic" in2="shadow" result="shape"/></filter>
|
|
7
|
+
</defs></svg>`;
|
|
8
|
+
export const DRAG_CURSOR_URL = `data:image/svg+xml,${encodeURIComponent(DRAG_CURSOR_SVG)}`;
|
|
9
|
+
export const DRAG_CURSOR = `url("${DRAG_CURSOR_URL}") 9 4, ew-resize`;
|
|
10
|
+
export const DRAG_CURSOR_STYLES = `:host { --nudge-drag-cursor: ${DRAG_CURSOR}; }`;
|
|
11
|
+
/** Shows the same cursor at a fixed viewport point while the native cursor is locked. */
|
|
12
|
+
export function showLockedDragCursor(doc, point) {
|
|
13
|
+
const cursor = doc.createElement("img");
|
|
14
|
+
cursor.src = DRAG_CURSOR_URL;
|
|
15
|
+
cursor.alt = "";
|
|
16
|
+
cursor.setAttribute("aria-hidden", "true");
|
|
17
|
+
cursor.dataset.test = "locked-drag-cursor";
|
|
18
|
+
cursor.style.cssText = `all: initial; position: fixed; left: ${point.x - 9}px; top: ${point.y - 4}px; width: 18px; height: 9.5px; pointer-events: none; z-index: 2147483647; user-select: none;`;
|
|
19
|
+
doc.documentElement.append(cursor);
|
|
20
|
+
return () => cursor.remove();
|
|
21
|
+
}
|