nudge-ui 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -0
- package/bin/nudge-ui.mjs +7 -0
- package/dist/LICENSE +21 -0
- package/dist/client.mjs +261 -0
- package/dist/compiler/ast.d.ts +18 -0
- package/dist/compiler/ast.js +75 -0
- package/dist/compiler/componentContractTypes.d.ts +19 -0
- package/dist/compiler/componentContractTypes.js +1 -0
- package/dist/compiler/componentContracts.d.ts +2 -0
- package/dist/compiler/componentContracts.js +260 -0
- package/dist/compiler/componentInstrumentation.d.ts +32 -0
- package/dist/compiler/componentInstrumentation.js +140 -0
- package/dist/compiler/componentPolicyResolution.d.ts +71 -0
- package/dist/compiler/componentPolicyResolution.js +388 -0
- package/dist/compiler/index.d.ts +9 -0
- package/dist/compiler/index.js +9 -0
- package/dist/compiler/packageComponentContracts.d.ts +32 -0
- package/dist/compiler/packageComponentContracts.js +308 -0
- package/dist/compiler/reactComponentProtocols.d.ts +145 -0
- package/dist/compiler/reactComponentProtocols.js +47 -0
- package/dist/compiler/reactIdentity.d.ts +15 -0
- package/dist/compiler/reactIdentity.js +339 -0
- package/dist/compiler/sourcePaths.d.ts +12 -0
- package/dist/compiler/sourcePaths.js +27 -0
- package/dist/css/dialects/index.d.ts +62 -0
- package/dist/css/dialects/index.js +103 -0
- package/dist/css/dialects/tailwind.d.ts +46 -0
- package/dist/css/dialects/tailwind.js +119 -0
- package/dist/css/dialects/vanillaExtract.d.ts +20 -0
- package/dist/css/dialects/vanillaExtract.js +32 -0
- package/dist/css/index.d.ts +10 -0
- package/dist/css/index.js +10 -0
- package/dist/css/model/index.d.ts +190 -0
- package/dist/css/model/index.js +10 -0
- package/dist/css/token-inventory/index.d.ts +26 -0
- package/dist/css/token-inventory/index.js +24 -0
- package/dist/css/token-inventory/inventory.d.ts +8 -0
- package/dist/css/token-inventory/inventory.js +421 -0
- package/dist/css/token-inventory/parseStylesheet.d.ts +16 -0
- package/dist/css/token-inventory/parseStylesheet.js +155 -0
- package/dist/css/token-inventory/policy.d.ts +47 -0
- package/dist/css/token-inventory/policy.js +50 -0
- package/dist/css/token-inventory/types.d.ts +97 -0
- package/dist/css/token-inventory/types.js +1 -0
- package/dist/css/value-semantics/borderSemantics.d.ts +28 -0
- package/dist/css/value-semantics/borderSemantics.js +91 -0
- package/dist/css/value-semantics/boxSemantics.d.ts +37 -0
- package/dist/css/value-semantics/boxSemantics.js +71 -0
- package/dist/css/value-semantics/colorSemantics.d.ts +99 -0
- package/dist/css/value-semantics/colorSemantics.js +526 -0
- package/dist/css/value-semantics/cssSyntax.d.ts +19 -0
- package/dist/css/value-semantics/cssSyntax.js +111 -0
- package/dist/css/value-semantics/fontSemantics.d.ts +35 -0
- package/dist/css/value-semantics/fontSemantics.js +131 -0
- package/dist/css/value-semantics/index.d.ts +20 -0
- package/dist/css/value-semantics/index.js +15 -0
- package/dist/css/value-semantics/propertyPolicy.d.ts +118 -0
- package/dist/css/value-semantics/propertyPolicy.js +356 -0
- package/dist/css/value-semantics/stringMaps.d.ts +2 -0
- package/dist/css/value-semantics/stringMaps.js +1 -0
- package/dist/css/value-semantics/structuredValues.d.ts +64 -0
- package/dist/css/value-semantics/structuredValues.js +250 -0
- package/dist/css/value-semantics/tokenInterpretation.d.ts +90 -0
- package/dist/css/value-semantics/tokenInterpretation.js +193 -0
- package/dist/css/virtual-design-tokens.d.ts +17 -0
- package/dist/hosts/astro/astroRuntimeConfig.d.ts +12 -0
- package/dist/hosts/astro/astroRuntimeConfig.js +26 -0
- package/dist/hosts/astro/clientAsset.d.ts +12 -0
- package/dist/hosts/astro/clientAsset.js +51 -0
- package/dist/hosts/astro/clientTransport.d.ts +3 -0
- package/dist/hosts/astro/clientTransport.js +57 -0
- package/dist/hosts/astro/index.d.ts +3 -0
- package/dist/hosts/astro/index.js +2 -0
- package/dist/hosts/astro/integration.d.ts +35 -0
- package/dist/hosts/astro/integration.js +96 -0
- package/dist/hosts/astro/middleware.d.ts +13 -0
- package/dist/hosts/astro/middleware.js +22 -0
- package/dist/hosts/astro/projectContext.d.ts +11 -0
- package/dist/hosts/astro/projectContext.js +34 -0
- package/dist/hosts/astro/responseInstrumentation.d.ts +41 -0
- package/dist/hosts/astro/responseInstrumentation.js +80 -0
- package/dist/hosts/next/index.d.ts +4 -0
- package/dist/hosts/next/index.js +7 -0
- package/dist/hosts/next/loader.d.ts +66 -0
- package/dist/hosts/next/loader.js +346 -0
- package/dist/hosts/next/loaders/identity-loader.cjs +228257 -0
- package/dist/hosts/next/loaders/loader-plugin.cjs +228257 -0
- package/dist/hosts/next/manifest.d.ts +38 -0
- package/dist/hosts/next/manifest.js +30 -0
- package/dist/hosts/next/mount.d.ts +12 -0
- package/dist/hosts/next/mount.js +23 -0
- package/dist/hosts/next/repositoryScope.d.ts +20 -0
- package/dist/hosts/next/repositoryScope.js +33 -0
- package/dist/hosts/next/sidecar.d.ts +27 -0
- package/dist/hosts/next/sidecar.js +526 -0
- package/dist/hosts/next/wrapper.d.ts +67 -0
- package/dist/hosts/next/wrapper.js +310 -0
- package/dist/hosts/static/cli.d.ts +12 -0
- package/dist/hosts/static/cli.js +77 -0
- package/dist/hosts/static/html/bootstrap.d.ts +27 -0
- package/dist/hosts/static/html/bootstrap.js +93 -0
- package/dist/hosts/static/index.d.ts +4 -0
- package/dist/hosts/static/index.js +4 -0
- package/dist/hosts/static/manifest.d.ts +18 -0
- package/dist/hosts/static/manifest.js +51 -0
- package/dist/hosts/static/server.d.ts +72 -0
- package/dist/hosts/static/server.js +554 -0
- package/dist/hosts/vite/index.d.ts +20 -0
- package/dist/hosts/vite/index.js +48 -0
- package/dist/hosts/vite/react.d.ts +67 -0
- package/dist/hosts/vite/react.js +231 -0
- package/dist/hosts/vite/tokens/activeStylesheets.d.ts +28 -0
- package/dist/hosts/vite/tokens/activeStylesheets.js +70 -0
- package/dist/hosts/vite/tokens/fileMap.d.ts +2 -0
- package/dist/hosts/vite/tokens/fileMap.js +1 -0
- package/dist/hosts/vite/tokens/viteStylesheetArtifacts.d.ts +46 -0
- package/dist/hosts/vite/tokens/viteStylesheetArtifacts.js +104 -0
- package/dist/hosts/vite/virtual/design-tokens.d.ts +9 -0
- package/dist/hosts/vite/virtual/design-tokens.js +7 -0
- package/dist/hosts/vite/virtual-design-tokens.d.ts +1 -0
- package/dist/hosts/vite/vite.d.ts +62 -0
- package/dist/hosts/vite/vite.js +854 -0
- package/dist/html/dom.d.ts +13 -0
- package/dist/html/dom.js +46 -0
- package/dist/html/identity.d.ts +40 -0
- package/dist/html/identity.js +196 -0
- package/dist/html/insertions.d.ts +26 -0
- package/dist/html/insertions.js +59 -0
- package/dist/inspector/agent/McpConnectionDialog.d.ts +26 -0
- package/dist/inspector/agent/McpConnectionDialog.js +135 -0
- package/dist/inspector/agent/client.d.ts +98 -0
- package/dist/inspector/agent/client.js +728 -0
- package/dist/inspector/agent/connectionStatus.d.ts +13 -0
- package/dist/inspector/agent/connectionStatus.js +35 -0
- package/dist/inspector/agent/httpTransport.d.ts +21 -0
- package/dist/inspector/agent/httpTransport.js +347 -0
- package/dist/inspector/agent/protocol.d.ts +95 -0
- package/dist/inspector/agent/protocol.js +9 -0
- package/dist/inspector/agent/verification.d.ts +39 -0
- package/dist/inspector/agent/verification.js +207 -0
- package/dist/inspector/canvas/CanvasCard.d.ts +10 -0
- package/dist/inspector/canvas/CanvasCard.js +275 -0
- package/dist/inspector/canvas/CanvasElementOverlay.d.ts +2 -0
- package/dist/inspector/canvas/CanvasElementOverlay.js +301 -0
- package/dist/inspector/canvas/CanvasWorkspace.d.ts +2 -0
- package/dist/inspector/canvas/CanvasWorkspace.js +301 -0
- package/dist/inspector/canvas/LockedWorkspaceNotice.d.ts +6 -0
- package/dist/inspector/canvas/LockedWorkspaceNotice.js +17 -0
- package/dist/inspector/canvas/StaleChangeIndicator.d.ts +7 -0
- package/dist/inspector/canvas/StaleChangeIndicator.js +43 -0
- package/dist/inspector/canvas/agentPresentation.d.ts +87 -0
- package/dist/inspector/canvas/agentPresentation.js +421 -0
- package/dist/inspector/canvas/canvasGestures.d.ts +12 -0
- package/dist/inspector/canvas/canvasGestures.js +21 -0
- package/dist/inspector/canvas/canvasStore.d.ts +108 -0
- package/dist/inspector/canvas/canvasStore.js +448 -0
- package/dist/inspector/canvas/frameProtocol.d.ts +231 -0
- package/dist/inspector/canvas/frameProtocol.js +165 -0
- package/dist/inspector/canvas/linkEligibility.d.ts +8 -0
- package/dist/inspector/canvas/linkEligibility.js +68 -0
- package/dist/inspector/canvas/measurementProjection.d.ts +8 -0
- package/dist/inspector/canvas/measurementProjection.js +16 -0
- package/dist/inspector/canvas/normalizeUrl.d.ts +7 -0
- package/dist/inspector/canvas/normalizeUrl.js +27 -0
- package/dist/inspector/canvas/projection.d.ts +41 -0
- package/dist/inspector/canvas/projection.js +232 -0
- package/dist/inspector/canvas/rendererBootstrap.d.ts +4 -0
- package/dist/inspector/canvas/rendererBootstrap.js +410 -0
- package/dist/inspector/canvas/rendererCidIndex.d.ts +11 -0
- package/dist/inspector/canvas/rendererCidIndex.js +21 -0
- package/dist/inspector/canvas/rendererElementSelector.d.ts +2 -0
- package/dist/inspector/canvas/rendererElementSelector.js +378 -0
- package/dist/inspector/canvas/rendererSelectionProxy.d.ts +2 -0
- package/dist/inspector/canvas/rendererSelectionProxy.js +61 -0
- package/dist/inspector/canvas/rendererStylesheet.d.ts +16 -0
- package/dist/inspector/canvas/rendererStylesheet.js +221 -0
- package/dist/inspector/canvas/resizeHandleScale.d.ts +13 -0
- package/dist/inspector/canvas/resizeHandleScale.js +20 -0
- package/dist/inspector/canvas/roleDetection.d.ts +5 -0
- package/dist/inspector/canvas/roleDetection.js +21 -0
- package/dist/inspector/canvas/sessionStore.d.ts +71 -0
- package/dist/inspector/canvas/sessionStore.js +453 -0
- package/dist/inspector/canvas/staleChangeDetector.d.ts +11 -0
- package/dist/inspector/canvas/staleChangeDetector.js +217 -0
- package/dist/inspector/canvas/toolbarScale.d.ts +7 -0
- package/dist/inspector/canvas/toolbarScale.js +11 -0
- package/dist/inspector/canvas/workspaceLease.d.ts +26 -0
- package/dist/inspector/canvas/workspaceLease.js +214 -0
- package/dist/inspector/changes/changesLog.d.ts +46 -0
- package/dist/inspector/changes/changesLog.js +209 -0
- package/dist/inspector/changes/codecs.d.ts +98 -0
- package/dist/inspector/changes/codecs.js +389 -0
- package/dist/inspector/changes/editModel.d.ts +74 -0
- package/dist/inspector/changes/editModel.js +120 -0
- package/dist/inspector/changes/managedStyleProjection.d.ts +6 -0
- package/dist/inspector/changes/managedStyleProjection.js +109 -0
- package/dist/inspector/changes/model.d.ts +13 -0
- package/dist/inspector/changes/model.js +163 -0
- package/dist/inspector/changes/presentation.d.ts +14 -0
- package/dist/inspector/changes/presentation.js +81 -0
- package/dist/inspector/changes/previewDiagnostics.d.ts +39 -0
- package/dist/inspector/changes/previewDiagnostics.js +172 -0
- package/dist/inspector/changes/structuralTypes.d.ts +35 -0
- package/dist/inspector/changes/structuralTypes.js +1 -0
- package/dist/inspector/changes/types.d.ts +76 -0
- package/dist/inspector/changes/types.js +16 -0
- package/dist/inspector/changes/workspaceChanges.d.ts +43 -0
- package/dist/inspector/changes/workspaceChanges.js +239 -0
- package/dist/inspector/clientManifest.d.ts +24 -0
- package/dist/inspector/clientManifest.js +69 -0
- package/dist/inspector/componentSemantics/ComponentPropsSection.d.ts +5 -0
- package/dist/inspector/componentSemantics/ComponentPropsSection.js +44 -0
- package/dist/inspector/componentSemantics/adapterRegistry.d.ts +11 -0
- package/dist/inspector/componentSemantics/adapterRegistry.js +75 -0
- package/dist/inspector/componentSemantics/boundaries.d.ts +2 -0
- package/dist/inspector/componentSemantics/boundaries.js +10 -0
- package/dist/inspector/componentSemantics/changeAction.d.ts +3 -0
- package/dist/inspector/componentSemantics/changeAction.js +6 -0
- package/dist/inspector/componentSemantics/changeModel.d.ts +8 -0
- package/dist/inspector/componentSemantics/changeModel.js +60 -0
- package/dist/inspector/componentSemantics/index.d.ts +4 -0
- package/dist/inspector/componentSemantics/index.js +2 -0
- package/dist/inspector/componentSemantics/reactRuntime.d.ts +10 -0
- package/dist/inspector/componentSemantics/reactRuntime.js +186 -0
- package/dist/inspector/componentSemantics/runtimeBridge.d.ts +25 -0
- package/dist/inspector/componentSemantics/runtimeBridge.js +161 -0
- package/dist/inspector/componentSemantics/runtimeTypes.d.ts +2 -0
- package/dist/inspector/componentSemantics/runtimeTypes.js +1 -0
- package/dist/inspector/componentSemantics/textBinding.d.ts +69 -0
- package/dist/inspector/componentSemantics/textBinding.js +514 -0
- package/dist/inspector/componentSemantics/types.d.ts +96 -0
- package/dist/inspector/componentSemantics/types.js +5 -0
- package/dist/inspector/conformance/borderCases.d.ts +7 -0
- package/dist/inspector/conformance/borderCases.js +428 -0
- package/dist/inspector/conformance/colorCases.d.ts +8 -0
- package/dist/inspector/conformance/colorCases.js +470 -0
- package/dist/inspector/conformance/fixture.d.ts +68 -0
- package/dist/inspector/conformance/fixture.js +153 -0
- package/dist/inspector/conformance/projection.d.ts +2 -0
- package/dist/inspector/conformance/projection.js +3 -0
- package/dist/inspector/conformance/spacingCases.d.ts +6 -0
- package/dist/inspector/conformance/spacingCases.js +417 -0
- package/dist/inspector/conformance/typographyCases.d.ts +7 -0
- package/dist/inspector/conformance/typographyCases.js +174 -0
- package/dist/inspector/editScope.d.ts +4 -0
- package/dist/inspector/editScope.js +5 -0
- package/dist/inspector/index.d.ts +20 -0
- package/dist/inspector/index.js +236 -0
- package/dist/inspector/inline-text/inlineTextEditor.d.ts +74 -0
- package/dist/inspector/inline-text/inlineTextEditor.js +1207 -0
- package/dist/inspector/inline-text/inlineTextLifecycle.d.ts +2 -0
- package/dist/inspector/inline-text/inlineTextLifecycle.js +17 -0
- package/dist/inspector/inline-text/textChangeBoundary.d.ts +6 -0
- package/dist/inspector/inline-text/textChangeBoundary.js +1 -0
- package/dist/inspector/inspection/bridge.d.ts +72 -0
- package/dist/inspector/inspection/bridge.js +134 -0
- package/dist/inspector/inspection/browserCssInspection.d.ts +74 -0
- package/dist/inspector/inspection/browserCssInspection.js +317 -0
- package/dist/inspector/inspection/browserCssInspectionRegistry.d.ts +12 -0
- package/dist/inspector/inspection/browserCssInspectionRegistry.js +66 -0
- package/dist/inspector/inspection/selectionProperty.d.ts +32 -0
- package/dist/inspector/inspection/selectionProperty.js +33 -0
- package/dist/inspector/inspection/useBrowserCssInspection.d.ts +20 -0
- package/dist/inspector/inspection/useBrowserCssInspection.js +159 -0
- package/dist/inspector/overlay/DropGuideOverlay.d.ts +17 -0
- package/dist/inspector/overlay/DropGuideOverlay.js +17 -0
- package/dist/inspector/overlay/InspectorOverlay.d.ts +5 -0
- package/dist/inspector/overlay/InspectorOverlay.js +328 -0
- package/dist/inspector/overlay/MeasurementGuideOverlay.d.ts +19 -0
- package/dist/inspector/overlay/MeasurementGuideOverlay.js +40 -0
- package/dist/inspector/overlay/clickPolicy.d.ts +7 -0
- package/dist/inspector/overlay/clickPolicy.js +13 -0
- package/dist/inspector/overlay/dropGuide.d.ts +22 -0
- package/dist/inspector/overlay/dropGuide.js +48 -0
- package/dist/inspector/overlay/elementSelector.d.ts +1 -0
- package/dist/inspector/overlay/elementSelector.js +100 -0
- package/dist/inspector/overlay/frameThrottle.d.ts +10 -0
- package/dist/inspector/overlay/frameThrottle.js +38 -0
- package/dist/inspector/overlay/interactionStyles.d.ts +3 -0
- package/dist/inspector/overlay/interactionStyles.js +70 -0
- package/dist/inspector/overlay/measurementGeometry.d.ts +25 -0
- package/dist/inspector/overlay/measurementGeometry.js +104 -0
- package/dist/inspector/overlay/overlayGeometry.d.ts +40 -0
- package/dist/inspector/overlay/overlayGeometry.js +59 -0
- package/dist/inspector/overlay/selectedGeometry.d.ts +7 -0
- package/dist/inspector/overlay/selectedGeometry.js +51 -0
- package/dist/inspector/overlay/structuralGestures.d.ts +28 -0
- package/dist/inspector/overlay/structuralGestures.js +180 -0
- package/dist/inspector/projection/cssEscapes.d.ts +3 -0
- package/dist/inspector/projection/cssEscapes.js +20 -0
- package/dist/inspector/projection/managedStylesheet.d.ts +33 -0
- package/dist/inspector/projection/managedStylesheet.js +240 -0
- package/dist/inspector/projection/renderedInstance.d.ts +56 -0
- package/dist/inspector/projection/renderedInstance.js +306 -0
- package/dist/inspector/projection/structuralProjection.d.ts +93 -0
- package/dist/inspector/projection/structuralProjection.js +560 -0
- package/dist/inspector/projection/structuralProjectionBoundary.d.ts +5 -0
- package/dist/inspector/projection/structuralProjectionBoundary.js +65 -0
- package/dist/inspector/projection/textProjection.d.ts +53 -0
- package/dist/inspector/projection/textProjection.js +705 -0
- package/dist/inspector/projection/workspaceProjection.d.ts +43 -0
- package/dist/inspector/projection/workspaceProjection.js +58 -0
- package/dist/inspector/prompt/PromptSettingsDialog.d.ts +15 -0
- package/dist/inspector/prompt/PromptSettingsDialog.js +17 -0
- package/dist/inspector/prompt/clipboardHandoff.d.ts +34 -0
- package/dist/inspector/prompt/clipboardHandoff.js +212 -0
- package/dist/inspector/prompt/copyToClipboard.d.ts +1 -0
- package/dist/inspector/prompt/copyToClipboard.js +34 -0
- package/dist/inspector/prompt/detectFramework.d.ts +6 -0
- package/dist/inspector/prompt/detectFramework.js +4 -0
- package/dist/inspector/prompt/generatePrompt.d.ts +7 -0
- package/dist/inspector/prompt/generatePrompt.js +391 -0
- package/dist/inspector/prompt/promptSettings.d.ts +8 -0
- package/dist/inspector/prompt/promptSettings.js +28 -0
- package/dist/inspector/runtime/devFlag.d.ts +28 -0
- package/dist/inspector/runtime/devFlag.js +50 -0
- package/dist/inspector/runtime/documentStylesheetOrder.d.ts +19 -0
- package/dist/inspector/runtime/documentStylesheetOrder.js +89 -0
- package/dist/inspector/runtime/domRealm.d.ts +4 -0
- package/dist/inspector/runtime/domRealm.js +11 -0
- package/dist/inspector/runtime/runtimeConfig.d.ts +119 -0
- package/dist/inspector/runtime/runtimeConfig.js +276 -0
- package/dist/inspector/runtime/staticHtmlRuntimeIdentity.d.ts +32 -0
- package/dist/inspector/runtime/staticHtmlRuntimeIdentity.js +149 -0
- package/dist/inspector/runtime/useRuntimeConfig.d.ts +10 -0
- package/dist/inspector/runtime/useRuntimeConfig.js +13 -0
- package/dist/inspector/selection/editScope.d.ts +32 -0
- package/dist/inspector/selection/editScope.js +140 -0
- package/dist/inspector/selection/editTarget.d.ts +8 -0
- package/dist/inspector/selection/editTarget.js +11 -0
- package/dist/inspector/selection/hierarchy.d.ts +7 -0
- package/dist/inspector/selection/hierarchy.js +42 -0
- package/dist/inspector/selection/resolveSelection.d.ts +10 -0
- package/dist/inspector/selection/resolveSelection.js +60 -0
- package/dist/inspector/selection/selectionStore.d.ts +41 -0
- package/dist/inspector/selection/selectionStore.js +262 -0
- package/dist/inspector/selection/selectionTarget.d.ts +5 -0
- package/dist/inspector/selection/selectionTarget.js +50 -0
- package/dist/inspector/selection/sourceSite.d.ts +2 -0
- package/dist/inspector/selection/sourceSite.js +12 -0
- package/dist/inspector/selection/styleSelection.d.ts +22 -0
- package/dist/inspector/selection/styleSelection.js +104 -0
- package/dist/inspector/session/index.d.ts +3 -0
- package/dist/inspector/session/index.js +2 -0
- package/dist/inspector/session/lifecycle.d.ts +22 -0
- package/dist/inspector/session/lifecycle.js +63 -0
- package/dist/inspector/session/sessionContext.d.ts +21 -0
- package/dist/inspector/session/sessionContext.js +28 -0
- package/dist/inspector/session/sessionFactory.d.ts +29 -0
- package/dist/inspector/session/sessionFactory.js +73 -0
- package/dist/inspector/settings/SettingsDialog.d.ts +12 -0
- package/dist/inspector/settings/SettingsDialog.js +46 -0
- package/dist/inspector/shell/AppShell.d.ts +2 -0
- package/dist/inspector/shell/AppShell.js +9 -0
- package/dist/inspector/shell/ChangesLog.d.ts +6 -0
- package/dist/inspector/shell/ChangesLog.js +92 -0
- package/dist/inspector/shell/CopyPromptButton.d.ts +9 -0
- package/dist/inspector/shell/CopyPromptButton.js +159 -0
- package/dist/inspector/shell/DomNavigation.d.ts +8 -0
- package/dist/inspector/shell/DomNavigation.js +30 -0
- package/dist/inspector/shell/EmptyState.d.ts +2 -0
- package/dist/inspector/shell/EmptyState.js +15 -0
- package/dist/inspector/shell/InspectorShell.d.ts +11 -0
- package/dist/inspector/shell/InspectorShell.js +268 -0
- package/dist/inspector/shell/openStore.d.ts +6 -0
- package/dist/inspector/shell/openStore.js +29 -0
- package/dist/inspector/shell/panelLayout.d.ts +2 -0
- package/dist/inspector/shell/panelLayout.js +29 -0
- package/dist/inspector/shell/shortcuts.d.ts +3 -0
- package/dist/inspector/shell/shortcuts.js +25 -0
- package/dist/inspector/shell/stateValue.d.ts +3 -0
- package/dist/inspector/shell/stateValue.js +34 -0
- package/dist/inspector/shell/styleState.d.ts +7 -0
- package/dist/inspector/shell/styleState.js +13 -0
- package/dist/inspector/spacing/projection.d.ts +43 -0
- package/dist/inspector/spacing/projection.js +136 -0
- package/dist/inspector/styleEditors/AppearanceSection.d.ts +13 -0
- package/dist/inspector/styleEditors/AppearanceSection.js +6 -0
- package/dist/inspector/styleEditors/AspectRatioField.d.ts +17 -0
- package/dist/inspector/styleEditors/AspectRatioField.js +10 -0
- package/dist/inspector/styleEditors/BorderEditor.d.ts +13 -0
- package/dist/inspector/styleEditors/BorderEditor.js +295 -0
- package/dist/inspector/styleEditors/BorderRadiusEditor.d.ts +14 -0
- package/dist/inspector/styleEditors/BorderRadiusEditor.js +108 -0
- package/dist/inspector/styleEditors/BoxShadowEditor.d.ts +13 -0
- package/dist/inspector/styleEditors/BoxShadowEditor.js +13 -0
- package/dist/inspector/styleEditors/ColorPicker.d.ts +15 -0
- package/dist/inspector/styleEditors/ColorPicker.js +73 -0
- package/dist/inspector/styleEditors/GapField.d.ts +17 -0
- package/dist/inspector/styleEditors/GapField.js +12 -0
- package/dist/inspector/styleEditors/GridChildSection.d.ts +14 -0
- package/dist/inspector/styleEditors/GridChildSection.js +91 -0
- package/dist/inspector/styleEditors/GridPicker.d.ts +13 -0
- package/dist/inspector/styleEditors/GridPicker.js +179 -0
- package/dist/inspector/styleEditors/GridSection.d.ts +17 -0
- package/dist/inspector/styleEditors/GridSection.js +27 -0
- package/dist/inspector/styleEditors/GridValueField.d.ts +17 -0
- package/dist/inspector/styleEditors/GridValueField.js +70 -0
- package/dist/inspector/styleEditors/InsetSection.d.ts +15 -0
- package/dist/inspector/styleEditors/InsetSection.js +15 -0
- package/dist/inspector/styleEditors/LayoutBlockedIndicator.d.ts +6 -0
- package/dist/inspector/styleEditors/LayoutBlockedIndicator.js +6 -0
- package/dist/inspector/styleEditors/LayoutComboField.d.ts +18 -0
- package/dist/inspector/styleEditors/LayoutComboField.js +138 -0
- package/dist/inspector/styleEditors/LayoutDropdown.d.ts +14 -0
- package/dist/inspector/styleEditors/LayoutDropdown.js +34 -0
- package/dist/inspector/styleEditors/LayoutSection.d.ts +13 -0
- package/dist/inspector/styleEditors/LayoutSection.js +342 -0
- package/dist/inspector/styleEditors/OpacityEditor.d.ts +13 -0
- package/dist/inspector/styleEditors/OpacityEditor.js +34 -0
- package/dist/inspector/styleEditors/PositionInsets.d.ts +15 -0
- package/dist/inspector/styleEditors/PositionInsets.js +12 -0
- package/dist/inspector/styleEditors/SpacingBox.d.ts +29 -0
- package/dist/inspector/styleEditors/SpacingBox.js +189 -0
- package/dist/inspector/styleEditors/Typography.d.ts +13 -0
- package/dist/inspector/styleEditors/Typography.js +137 -0
- package/dist/inspector/styleEditors/completeCssValue.d.ts +8 -0
- package/dist/inspector/styleEditors/completeCssValue.js +34 -0
- package/dist/inspector/styleEditors/gridChildModel.d.ts +74 -0
- package/dist/inspector/styleEditors/gridChildModel.js +138 -0
- package/dist/inspector/styleEditors/layoutValue.d.ts +24 -0
- package/dist/inspector/styleEditors/layoutValue.js +103 -0
- package/dist/inspector/styleEditors/nudgeValue.d.ts +8 -0
- package/dist/inspector/styleEditors/nudgeValue.js +71 -0
- package/dist/inspector/styleEditors/rowLookup.d.ts +11 -0
- package/dist/inspector/styleEditors/rowLookup.js +13 -0
- package/dist/inspector/styleEditors/stringRecord.d.ts +4 -0
- package/dist/inspector/styleEditors/stringRecord.js +1 -0
- package/dist/inspector/styleEditors/valuePolicy.d.ts +20 -0
- package/dist/inspector/styleEditors/valuePolicy.js +82 -0
- package/dist/inspector/testing.d.ts +10 -0
- package/dist/inspector/testing.js +9 -0
- package/dist/inspector/tokens/TokenChip.d.ts +24 -0
- package/dist/inspector/tokens/TokenChip.js +23 -0
- package/dist/inspector/tokens/TokenDropdown.d.ts +13 -0
- package/dist/inspector/tokens/TokenDropdown.js +59 -0
- package/dist/inspector/tokens/TokenField.d.ts +68 -0
- package/dist/inspector/tokens/TokenField.js +485 -0
- package/dist/inspector/tokens/TokenLabel.d.ts +7 -0
- package/dist/inspector/tokens/TokenLabel.js +23 -0
- package/dist/inspector/tokens/TokensPanel.d.ts +5 -0
- package/dist/inspector/tokens/TokensPanel.js +47 -0
- package/dist/inspector/tokens/catalog.d.ts +51 -0
- package/dist/inspector/tokens/catalog.js +184 -0
- package/dist/inspector/tokens/editActions.d.ts +35 -0
- package/dist/inspector/tokens/editActions.js +164 -0
- package/dist/inspector/tokens/resolution/cascade.d.ts +14 -0
- package/dist/inspector/tokens/resolution/cascade.js +31 -0
- package/dist/inspector/tokens/resolution/cssomCollector.d.ts +43 -0
- package/dist/inspector/tokens/resolution/cssomCollector.js +528 -0
- package/dist/inspector/tokens/resolution/selectorSemantics.d.ts +12 -0
- package/dist/inspector/tokens/resolution/selectorSemantics.js +106 -0
- package/dist/inspector/tokens/resolution.d.ts +56 -0
- package/dist/inspector/tokens/resolution.js +1401 -0
- package/dist/inspector/tokens/tokenEdits.d.ts +3 -0
- package/dist/inspector/tokens/tokenEdits.js +22 -0
- package/dist/inspector/tokens/valueSemanticsAdapter.d.ts +6 -0
- package/dist/inspector/tokens/valueSemanticsAdapter.js +68 -0
- package/dist/inspector/ui/AtRuleContext.d.ts +18 -0
- package/dist/inspector/ui/AtRuleContext.js +54 -0
- package/dist/inspector/ui/Button.d.ts +9 -0
- package/dist/inspector/ui/Button.js +4 -0
- package/dist/inspector/ui/ColorSwatch.d.ts +7 -0
- package/dist/inspector/ui/ColorSwatch.js +6 -0
- package/dist/inspector/ui/ControlSurface.d.ts +14 -0
- package/dist/inspector/ui/ControlSurface.js +10 -0
- package/dist/inspector/ui/FieldRow.d.ts +14 -0
- package/dist/inspector/ui/FieldRow.js +15 -0
- package/dist/inspector/ui/IconButton.d.ts +14 -0
- package/dist/inspector/ui/IconButton.js +5 -0
- package/dist/inspector/ui/InspectorPopover.d.ts +17 -0
- package/dist/inspector/ui/InspectorPopover.js +13 -0
- package/dist/inspector/ui/PopoverListbox.d.ts +37 -0
- package/dist/inspector/ui/PopoverListbox.js +21 -0
- package/dist/inspector/ui/SegmentedControl.d.ts +24 -0
- package/dist/inspector/ui/SegmentedControl.js +16 -0
- package/dist/inspector/ui/Select.d.ts +25 -0
- package/dist/inspector/ui/Select.js +56 -0
- package/dist/inspector/ui/SideValuesField.d.ts +44 -0
- package/dist/inspector/ui/SideValuesField.js +76 -0
- package/dist/inspector/ui/StatusCallout.d.ts +9 -0
- package/dist/inspector/ui/StatusCallout.js +4 -0
- package/dist/inspector/ui/TextInput.d.ts +12 -0
- package/dist/inspector/ui/TextInput.js +5 -0
- package/dist/inspector/ui/ToggleButton.d.ts +11 -0
- package/dist/inspector/ui/ToggleButton.js +6 -0
- package/dist/inspector/ui/assets/grid.svg +14 -0
- package/dist/inspector/ui/css.d.ts +9 -0
- package/dist/inspector/ui/labels.d.ts +1 -0
- package/dist/inspector/ui/labels.js +7 -0
- package/dist/inspector/ui/styles.d.ts +1 -0
- package/dist/inspector/ui/styles.js +68 -0
- package/dist/inspector/virtual-modules.d.ts +7 -0
- package/dist/inspector/vite-env.d.ts +10 -0
- package/dist/internal/agent-protocol.d.ts +232 -0
- package/dist/internal/agent-protocol.js +237 -0
- package/dist/nudge-ui.mjs +15722 -0
- package/dist/project/files.d.ts +19 -0
- package/dist/project/files.js +226 -0
- package/dist/project/identity.d.ts +6 -0
- package/dist/project/identity.js +19 -0
- package/dist/project/pathPolicy.d.ts +8 -0
- package/dist/project/pathPolicy.js +12 -0
- package/dist/project/tokens.d.ts +36 -0
- package/dist/project/tokens.js +223 -0
- package/dist/transport/index.d.ts +8 -0
- package/dist/transport/index.js +8 -0
- package/dist/transport/routes.d.ts +13 -0
- package/dist/transport/routes.js +16 -0
- package/package.json +137 -0
|
@@ -0,0 +1,485 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { IconLinkOff } from "@tabler/icons-react";
|
|
4
|
+
import { applyValueEdit, normalizeOpacityPercent, selectTokens, } from "../../css/value-semantics/index.js";
|
|
5
|
+
import { promoteToToken, swapToken } from "./editActions.js";
|
|
6
|
+
import { setStyle } from "./editActions.js";
|
|
7
|
+
import { completeCssValue } from "../styleEditors/completeCssValue.js";
|
|
8
|
+
import { nudgeCssValue, nudgeOpacityValue } from "../styleEditors/nudgeValue.js";
|
|
9
|
+
import { valuePolicyFor } from "../styleEditors/valuePolicy.js";
|
|
10
|
+
import { IconButton } from "../ui/IconButton.js";
|
|
11
|
+
import { PopoverListbox } from "../ui/PopoverListbox.js";
|
|
12
|
+
import { ColorSwatch } from "../ui/ColorSwatch.js";
|
|
13
|
+
import { getStateStyleValue } from "../shell/stateValue.js";
|
|
14
|
+
import { AtRuleIndicator, useFieldAtRules } from "../ui/AtRuleContext.js";
|
|
15
|
+
import { TokenChip } from "./TokenChip.js";
|
|
16
|
+
import { isMultiTarget } from "../selection/editTarget.js";
|
|
17
|
+
const NON_COLOR_FACTS = { hasEmbeddedAlpha: false, isExpression: false, opacityEditable: false };
|
|
18
|
+
function colorFacts(value) {
|
|
19
|
+
return selectTokens({
|
|
20
|
+
entries: [{ name: "--nudge-ui-preview", value, source: "runtime" }],
|
|
21
|
+
}).candidates[0]?.color ?? NON_COLOR_FACTS;
|
|
22
|
+
}
|
|
23
|
+
function tokenGroup(entry) {
|
|
24
|
+
return selectTokens({ entries: [entry] }).candidates[0]?.group ?? "generic";
|
|
25
|
+
}
|
|
26
|
+
function computedRaw(el, property) {
|
|
27
|
+
const value = getStateStyleValue(el, property);
|
|
28
|
+
if (property !== "line-height")
|
|
29
|
+
return value;
|
|
30
|
+
return lineHeightPercentage(value, getStateStyleValue(el, "font-size")) ?? value;
|
|
31
|
+
}
|
|
32
|
+
function structuredBorderValue(property, row) {
|
|
33
|
+
const structure = row?.structure;
|
|
34
|
+
if (!structure)
|
|
35
|
+
return null;
|
|
36
|
+
if (property.endsWith("-width"))
|
|
37
|
+
return structure.width;
|
|
38
|
+
if (property.endsWith("-style"))
|
|
39
|
+
return structure.style;
|
|
40
|
+
if (property.endsWith("-color"))
|
|
41
|
+
return structure.color;
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
function lineHeightPercentage(lineHeight, fontSize) {
|
|
45
|
+
const lineHeightPx = parsePixels(lineHeight);
|
|
46
|
+
const fontSizePx = parsePixels(fontSize);
|
|
47
|
+
if (lineHeightPx === null || fontSizePx === null || fontSizePx === 0)
|
|
48
|
+
return null;
|
|
49
|
+
return `${formatNumber((lineHeightPx / fontSizePx) * 100)}%`;
|
|
50
|
+
}
|
|
51
|
+
function parsePixels(value) {
|
|
52
|
+
const match = /^([+-]?(?:(?:\d+\.?\d*)|(?:\.\d+)))px$/i.exec(value.trim());
|
|
53
|
+
if (!match)
|
|
54
|
+
return null;
|
|
55
|
+
const number = Number(match[1]);
|
|
56
|
+
return Number.isFinite(number) ? number : null;
|
|
57
|
+
}
|
|
58
|
+
function formatNumber(value) {
|
|
59
|
+
return String(Number(value.toFixed(12)));
|
|
60
|
+
}
|
|
61
|
+
function stripCssUnit(value) {
|
|
62
|
+
return value.replace(/^(-?\d+(?:\.\d+)?)(px|rem|em|vh|vw|vmin|vmax|%|ch|ex|cm|mm|in|pt|pc)$/i, "$1");
|
|
63
|
+
}
|
|
64
|
+
/** Returns the first family in a CSS family list without splitting var() fallbacks. */
|
|
65
|
+
function primaryFontFamily(value) {
|
|
66
|
+
let depth = 0;
|
|
67
|
+
let quote = null;
|
|
68
|
+
for (let index = 0; index < value.length; index++) {
|
|
69
|
+
const char = value[index];
|
|
70
|
+
if (quote) {
|
|
71
|
+
if (char === "\\")
|
|
72
|
+
index++;
|
|
73
|
+
else if (char === quote)
|
|
74
|
+
quote = null;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (char === "'" || char === '"') {
|
|
78
|
+
quote = char;
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
if (char === "(")
|
|
82
|
+
depth++;
|
|
83
|
+
else if (char === ")")
|
|
84
|
+
depth = Math.max(0, depth - 1);
|
|
85
|
+
else if (char === "," && depth === 0)
|
|
86
|
+
return value.slice(0, index).trim();
|
|
87
|
+
}
|
|
88
|
+
return value.trim();
|
|
89
|
+
}
|
|
90
|
+
function rgbToHex(value) {
|
|
91
|
+
const match = value.match(/^rgba?\(\s*(\d+(?:\.\d+)?)\D+(\d+(?:\.\d+)?)\D+(\d+(?:\.\d+)?)/i);
|
|
92
|
+
if (!match)
|
|
93
|
+
return null;
|
|
94
|
+
return `#${[match[1], match[2], match[3]]
|
|
95
|
+
.map((part) => Math.max(0, Math.min(255, Math.round(Number(part)))).toString(16).padStart(2, "0"))
|
|
96
|
+
.join("")}`;
|
|
97
|
+
}
|
|
98
|
+
export function colorValueToHex(value) {
|
|
99
|
+
const trimmed = value.trim();
|
|
100
|
+
const hex = trimmed.match(/^#([\da-f]{4}|[\da-f]{8})$/i);
|
|
101
|
+
if (hex) {
|
|
102
|
+
const raw = hex[1];
|
|
103
|
+
const rgb = raw.length === 4 ? raw.slice(0, 3).split("").map((part) => part + part).join("") : raw.slice(0, 6);
|
|
104
|
+
return `#${rgb}`.toLowerCase();
|
|
105
|
+
}
|
|
106
|
+
if (/^#([\da-f]{3}|[\da-f]{6})$/i.test(trimmed)) {
|
|
107
|
+
const short = trimmed.match(/^#([\da-f])([\da-f])([\da-f])$/i);
|
|
108
|
+
if (short)
|
|
109
|
+
return `#${short[1]}${short[1]}${short[2]}${short[2]}${short[3]}${short[3]}`.toLowerCase();
|
|
110
|
+
return trimmed.toLowerCase();
|
|
111
|
+
}
|
|
112
|
+
const directRgb = rgbToHex(trimmed);
|
|
113
|
+
if (directRgb)
|
|
114
|
+
return directRgb;
|
|
115
|
+
if (typeof document === "undefined")
|
|
116
|
+
return null;
|
|
117
|
+
const probe = document.createElement("span");
|
|
118
|
+
probe.setAttribute("data-nudge-ui", "value-probe");
|
|
119
|
+
probe.style.color = "";
|
|
120
|
+
probe.style.color = trimmed;
|
|
121
|
+
if (!probe.style.color)
|
|
122
|
+
return null;
|
|
123
|
+
document.body.appendChild(probe);
|
|
124
|
+
const resolved = getComputedStyle(probe).color;
|
|
125
|
+
probe.remove();
|
|
126
|
+
return rgbToHex(resolved);
|
|
127
|
+
}
|
|
128
|
+
function browserRecognizesColor(value) {
|
|
129
|
+
const trimmed = value.trim();
|
|
130
|
+
if (!trimmed || /var\(/i.test(trimmed) || typeof document === "undefined")
|
|
131
|
+
return false;
|
|
132
|
+
const probe = document.createElement("span");
|
|
133
|
+
probe.setAttribute("data-nudge-ui", "value-probe");
|
|
134
|
+
probe.style.color = "";
|
|
135
|
+
probe.style.color = trimmed;
|
|
136
|
+
return probe.style.color !== "";
|
|
137
|
+
}
|
|
138
|
+
function NativeColorSwatch({ value, onChange, disabled, }) {
|
|
139
|
+
const resolvedHex = colorValueToHex(value);
|
|
140
|
+
const hex = resolvedHex ?? "#000000";
|
|
141
|
+
const hasRenderableColor = resolvedHex !== null || browserRecognizesColor(value);
|
|
142
|
+
return (_jsxs("label", { className: "token-color-control", "data-resolved": hasRenderableColor ? "true" : "false", children: [_jsx(ColorSwatch, { color: resolvedHex ?? (value.trim() || "transparent"), "data-test": "token-color-swatch" }), _jsx("input", { className: "token-color-control__input", "data-test": "token-color-input", type: "color", value: hex, disabled: disabled, "aria-label": "Choose color", onChange: (event) => onChange(event.target.value) })] }));
|
|
143
|
+
}
|
|
144
|
+
export function TokenValueField(props) {
|
|
145
|
+
const { property, domElement, semanticSlot, committedValue, resolvedValue = committedValue, activeTokenName: controlledTokenName = null, entries, suggestions = [], inputDataTest = "raw-input", allowedTokenNames, isColor = false, disabled = false, mixed = false, formatRawValue = (value) => value.trim(), onCommitRaw, onSelectToken, onUnlink, attributionTokens = [], leading, trailing, className, label, opacity, color, onCommitOpacity, atRules, chipVariant = "default", } = props;
|
|
146
|
+
const inheritedAtRules = useFieldAtRules(property);
|
|
147
|
+
const fieldAtRules = atRules ?? inheritedAtRules;
|
|
148
|
+
const controlledToken = controlledTokenName ? entries.find((entry) => entry.name === controlledTokenName) : null;
|
|
149
|
+
const authoredColor = isColor
|
|
150
|
+
? color ?? colorFacts(committedValue)
|
|
151
|
+
: NON_COLOR_FACTS;
|
|
152
|
+
const controlledTokenColor = isColor && controlledToken
|
|
153
|
+
? colorFacts(controlledToken.value)
|
|
154
|
+
: null;
|
|
155
|
+
const controlledTokenHasEmbeddedAlpha = Boolean(isColor && controlledTokenName
|
|
156
|
+
&& (controlledTokenColor?.hasEmbeddedAlpha || (!opacity && authoredColor.hasEmbeddedAlpha)));
|
|
157
|
+
const defaultOpacityValue = isColor && !controlledTokenHasEmbeddedAlpha ? "100%" : "";
|
|
158
|
+
const [rawValue, setRawValue] = useState(committedValue);
|
|
159
|
+
const [opacityValue, setOpacityValue] = useState(opacity?.value ?? defaultOpacityValue);
|
|
160
|
+
const [activeTokenName, setActiveTokenName] = useState(controlledTokenName);
|
|
161
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
162
|
+
const [isTokenPickerOpen, setTokenPickerOpen] = useState(false);
|
|
163
|
+
const inputRef = useRef(null);
|
|
164
|
+
const selectedFromPopover = useRef(false);
|
|
165
|
+
const cancelOnBlur = useRef(false);
|
|
166
|
+
const isNavigatingSuggestions = useRef(false);
|
|
167
|
+
useEffect(() => {
|
|
168
|
+
setRawValue(committedValue);
|
|
169
|
+
setActiveTokenName(controlledTokenName);
|
|
170
|
+
setOpacityValue(opacity?.value ?? defaultOpacityValue);
|
|
171
|
+
}, [committedValue, controlledTokenName, defaultOpacityValue, mixed, opacity?.value, property]);
|
|
172
|
+
const activeToken = activeTokenName
|
|
173
|
+
? entries.find((entry) => entry.name === activeTokenName) ?? { name: activeTokenName, value: resolvedValue, source: "runtime" }
|
|
174
|
+
: null;
|
|
175
|
+
const activeTokenColor = isColor && activeToken
|
|
176
|
+
? colorFacts(activeToken.value)
|
|
177
|
+
: null;
|
|
178
|
+
const activeTokenHasEmbeddedAlpha = Boolean(isColor && activeToken
|
|
179
|
+
&& (activeTokenColor?.hasEmbeddedAlpha || (!opacity && activeTokenName === controlledTokenName && authoredColor.hasEmbeddedAlpha)));
|
|
180
|
+
const showOpacity = isColor && !activeTokenHasEmbeddedAlpha
|
|
181
|
+
&& authoredColor.opacityEditable
|
|
182
|
+
&& (Boolean(activeTokenName) || attributionTokens.length === 0 || Boolean(opacity));
|
|
183
|
+
// One classification pass per entries change. selectTokens costs up to
|
|
184
|
+
// three CSS.supports calls per token, so classifying per token per render
|
|
185
|
+
// (chip mode is unbounded; raw mode runs per keystroke) dominates this
|
|
186
|
+
// field's render cost. Map misses fall back to direct classification for
|
|
187
|
+
// synthetic entries that are not part of the catalog list.
|
|
188
|
+
const groupByTokenName = useMemo(() => {
|
|
189
|
+
const groups = new Map();
|
|
190
|
+
for (const entry of entries)
|
|
191
|
+
groups.set(entry.name, tokenGroup(entry));
|
|
192
|
+
return groups;
|
|
193
|
+
}, [entries]);
|
|
194
|
+
const relevantTokens = useMemo(() => {
|
|
195
|
+
const candidates = allowedTokenNames
|
|
196
|
+
? entries.filter((entry) => allowedTokenNames.has(entry.name))
|
|
197
|
+
: selectTokens({
|
|
198
|
+
element: domElement,
|
|
199
|
+
property,
|
|
200
|
+
slot: semanticSlot,
|
|
201
|
+
entries,
|
|
202
|
+
currentToken: activeTokenName,
|
|
203
|
+
}).candidates.map(({ entry }) => entry);
|
|
204
|
+
return candidates.filter((entry) => entry.name !== property);
|
|
205
|
+
}, [activeTokenName, allowedTokenNames, domElement, entries, property, semanticSlot]);
|
|
206
|
+
const filteredTokens = useMemo(() => {
|
|
207
|
+
const target = rawValue.toLowerCase();
|
|
208
|
+
return relevantTokens.filter((entry) => !target
|
|
209
|
+
|| entry.name.toLowerCase().includes(target)
|
|
210
|
+
|| entry.value.toLowerCase().includes(target));
|
|
211
|
+
}, [rawValue, relevantTokens]);
|
|
212
|
+
const availableSuggestions = useMemo(() => {
|
|
213
|
+
return Array.from(new Set(suggestions));
|
|
214
|
+
}, [suggestions]);
|
|
215
|
+
function handleSuggestionSelect(value) {
|
|
216
|
+
const rawSuggestion = decodeRawSuggestion(value);
|
|
217
|
+
if (rawSuggestion !== null) {
|
|
218
|
+
selectedFromPopover.current = true;
|
|
219
|
+
cancelOnBlur.current = false;
|
|
220
|
+
const formatted = formatRawValue(rawSuggestion);
|
|
221
|
+
setActiveTokenName(null);
|
|
222
|
+
setRawValue(formatted);
|
|
223
|
+
onCommitRaw(formatted);
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
const chosen = relevantTokens.find((entry) => entry.name === value);
|
|
227
|
+
if (chosen)
|
|
228
|
+
handleTokenSelect(chosen);
|
|
229
|
+
}
|
|
230
|
+
function commitRawValue(value = rawValue) {
|
|
231
|
+
if (mixed && value.trim().toLowerCase() === "mixed")
|
|
232
|
+
return;
|
|
233
|
+
const formatted = formatRawValue(value);
|
|
234
|
+
if (!formatted) {
|
|
235
|
+
setRawValue(committedValue);
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
setRawValue(formatted);
|
|
239
|
+
setActiveTokenName(null);
|
|
240
|
+
onCommitRaw(formatted);
|
|
241
|
+
}
|
|
242
|
+
function handleDelink() {
|
|
243
|
+
// A token-backed alpha expression is represented by a chip, but unlinking
|
|
244
|
+
// it should preserve the complete authored color expression and its alpha.
|
|
245
|
+
const value = opacity ? committedValue : activeToken?.value || resolvedValue || committedValue;
|
|
246
|
+
setActiveTokenName(null);
|
|
247
|
+
setRawValue(value);
|
|
248
|
+
onUnlink(value);
|
|
249
|
+
}
|
|
250
|
+
function handleTokenSelect(chosen) {
|
|
251
|
+
selectedFromPopover.current = true;
|
|
252
|
+
cancelOnBlur.current = false;
|
|
253
|
+
if (onSelectToken(chosen) === false)
|
|
254
|
+
return;
|
|
255
|
+
setActiveTokenName(chosen.name);
|
|
256
|
+
setRawValue(chosen.value);
|
|
257
|
+
}
|
|
258
|
+
function handleRawBlur() {
|
|
259
|
+
if (selectedFromPopover.current) {
|
|
260
|
+
selectedFromPopover.current = false;
|
|
261
|
+
setIsFocused(false);
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
if (!cancelOnBlur.current)
|
|
265
|
+
commitRawValue();
|
|
266
|
+
cancelOnBlur.current = false;
|
|
267
|
+
setIsFocused(false);
|
|
268
|
+
}
|
|
269
|
+
function handleRawKeyDown(event) {
|
|
270
|
+
const direction = arrowDirection(event.key);
|
|
271
|
+
if (direction && !event.altKey && !event.ctrlKey && !event.metaKey) {
|
|
272
|
+
const next = property === "opacity"
|
|
273
|
+
? nudgeOpacityValue(rawValue, direction, event.shiftKey)
|
|
274
|
+
: nudgeCssValue(property, rawValue, direction, event.shiftKey);
|
|
275
|
+
if (next) {
|
|
276
|
+
event.preventDefault();
|
|
277
|
+
event.stopPropagation();
|
|
278
|
+
isNavigatingSuggestions.current = false;
|
|
279
|
+
setRawValue(next);
|
|
280
|
+
setActiveTokenName(null);
|
|
281
|
+
onCommitRaw(next);
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
286
|
+
isNavigatingSuggestions.current = true;
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
if (event.key === "Escape") {
|
|
290
|
+
event.preventDefault();
|
|
291
|
+
event.stopPropagation();
|
|
292
|
+
setRawValue(committedValue);
|
|
293
|
+
cancelOnBlur.current = true;
|
|
294
|
+
setIsFocused(false);
|
|
295
|
+
inputRef.current?.blur();
|
|
296
|
+
}
|
|
297
|
+
else if (event.key === "Enter" && !isNavigatingSuggestions.current) {
|
|
298
|
+
event.preventDefault();
|
|
299
|
+
event.stopPropagation();
|
|
300
|
+
setIsFocused(false);
|
|
301
|
+
inputRef.current?.blur();
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
function commitOpacityValue(value = opacityValue) {
|
|
305
|
+
if (!showOpacity || !onCommitOpacity)
|
|
306
|
+
return;
|
|
307
|
+
const normalized = normalizeOpacityPercent(value);
|
|
308
|
+
if (normalized === null) {
|
|
309
|
+
setOpacityValue(opacity?.value ?? "100%");
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
if (onCommitOpacity(normalized) === false) {
|
|
313
|
+
setOpacityValue(opacity?.value ?? defaultOpacityValue);
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
setOpacityValue(normalized);
|
|
317
|
+
}
|
|
318
|
+
const opacityControl = showOpacity ? (_jsx("input", { className: "token-opacity-input", "data-test": "color-opacity-input", type: "text", inputMode: "decimal", value: opacityValue, disabled: disabled || !onCommitOpacity, "aria-label": `Opacity for ${property}`, onChange: (event) => setOpacityValue(event.target.value), onBlur: () => commitOpacityValue(), onKeyDown: (event) => {
|
|
319
|
+
const direction = arrowDirection(event.key);
|
|
320
|
+
if (direction && !event.altKey && !event.ctrlKey && !event.metaKey) {
|
|
321
|
+
const next = nudgeOpacityValue(opacityValue, direction, event.shiftKey);
|
|
322
|
+
if (next) {
|
|
323
|
+
event.preventDefault();
|
|
324
|
+
event.stopPropagation();
|
|
325
|
+
setOpacityValue(next);
|
|
326
|
+
commitOpacityValue(next);
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
if (event.key === "Escape") {
|
|
331
|
+
event.preventDefault();
|
|
332
|
+
setOpacityValue(opacity?.value ?? "100%");
|
|
333
|
+
event.currentTarget.blur();
|
|
334
|
+
}
|
|
335
|
+
else if (event.key === "Enter") {
|
|
336
|
+
event.preventDefault();
|
|
337
|
+
event.currentTarget.blur();
|
|
338
|
+
}
|
|
339
|
+
} })) : null;
|
|
340
|
+
const colorPreview = activeToken ? resolvedValue || activeToken.value : resolvedValue || rawValue;
|
|
341
|
+
const colorControlEl = isColor ? (_jsx(NativeColorSwatch, { value: colorPreview, disabled: disabled, onChange: (value) => commitRawValue(value) })) : null;
|
|
342
|
+
const rawSuggestionItems = availableSuggestions.map(rawSuggestion);
|
|
343
|
+
if (activeToken) {
|
|
344
|
+
const chipValue = chipVariant === "small" ? stripCssUnit(activeToken.value) : activeToken.name;
|
|
345
|
+
const embedColorSwatch = isColor && chipVariant !== "small";
|
|
346
|
+
return (_jsxs("span", { className: `token-field${isColor ? " token-field--color" : ""}${embedColorSwatch ? " token-field--color-chip" : ""}${className ? ` ${className}` : ""}`, "data-test": "token-field", "data-property": property, "aria-label": label, title: label, children: [leading ? _jsx("span", { className: "token-field__leading", children: leading }) : null, embedColorSwatch ? null : colorControlEl, _jsxs(TokenChip, { size: chipVariant, "data-group": groupByTokenName.get(activeToken.name) ?? tokenGroup(activeToken), children: [_jsx(PopoverListbox, { query: "", value: activeToken.name, open: isTokenPickerOpen, trigger: (_jsxs(TokenChip.Picker, { children: [embedColorSwatch ? colorControlEl : null, _jsx(TokenChip.Label, { title: activeToken.name, children: chipValue })] })), triggerClassName: "token-chip__trigger", triggerDataTest: "token-chip", triggerAriaLabel: `Change ${property} token`, searchable: true, searchPlaceholder: "Search tokens\u2026", searchAriaLabel: "Search tokens", items: [...rawSuggestionItems, ...relevantTokens.map((entry) => tokenSuggestion(entry, groupByTokenName))], onQueryChange: () => undefined, onOpenChange: setTokenPickerOpen, disabled: disabled, onSelect: (value) => {
|
|
347
|
+
handleSuggestionSelect(value);
|
|
348
|
+
} }), _jsx(TokenChip.Action, { children: _jsx(IconButton, { variant: "quiet", size: "compact", style: { borderRadius: "var(--radius-4)" }, label: "Replace with raw value", "data-test": "delink-btn", disabled: disabled, onClick: handleDelink, children: _jsx(IconLinkOff, { size: chipVariant === "small" ? 12 : 14, stroke: 1.75, "aria-hidden": "true" }) }) })] }), opacityControl, _jsx(AtRuleIndicator, { atRules: fieldAtRules }), trailing ? _jsx("span", { className: "token-field__trailing", children: trailing }) : null] }));
|
|
349
|
+
}
|
|
350
|
+
const showPopover = isFocused && (filteredTokens.length > 0 || availableSuggestions.length > 0);
|
|
351
|
+
return (_jsxs("span", { className: `token-field token-field--raw${isColor ? " token-field--color" : ""}${className ? ` ${className}` : ""}`, "data-test": "token-field", "data-property": property, "aria-label": label, title: label, children: [leading ? _jsx("span", { className: "token-field__leading", children: leading }) : null, colorControlEl, _jsx(PopoverListbox, { query: rawValue, value: null, open: showPopover, placeholder: property, inputRef: inputRef, inputAppearance: "embedded", inputDataTest: inputDataTest, inputOnFocus: () => {
|
|
352
|
+
setIsFocused(true);
|
|
353
|
+
if (mixed && rawValue.trim().toLowerCase() === "mixed")
|
|
354
|
+
setRawValue("");
|
|
355
|
+
}, inputOnBlur: handleRawBlur, inputOnKeyDown: handleRawKeyDown, items: [
|
|
356
|
+
...availableSuggestions.map(rawSuggestion),
|
|
357
|
+
...filteredTokens.slice(0, 30).map((entry) => tokenSuggestion(entry, groupByTokenName)),
|
|
358
|
+
], onQueryChange: (value) => {
|
|
359
|
+
isNavigatingSuggestions.current = false;
|
|
360
|
+
setRawValue(value);
|
|
361
|
+
}, onOpenChange: setIsFocused, disabled: disabled, onSelect: (value) => {
|
|
362
|
+
handleSuggestionSelect(value);
|
|
363
|
+
} }), opacityControl, _jsx(AtRuleIndicator, { atRules: fieldAtRules }), trailing ? _jsx("span", { className: "token-field__trailing", children: trailing }) : null] }));
|
|
364
|
+
}
|
|
365
|
+
function arrowDirection(key) {
|
|
366
|
+
if (key === "ArrowUp")
|
|
367
|
+
return 1;
|
|
368
|
+
if (key === "ArrowDown")
|
|
369
|
+
return -1;
|
|
370
|
+
return null;
|
|
371
|
+
}
|
|
372
|
+
export function TokenField(props) {
|
|
373
|
+
const { property, semanticSlot, tokenRow, selection, initialValue, displayValue, domElement: el, editTarget, entries, suggestions, inputDataTest, onAfterEdit, editMetadata, leading, trailing, className, label, chipVariant, formatRawValue: formatRawValueProp, disabled = false, mixed = false, attributionTokens, } = props;
|
|
374
|
+
const selectedProperty = selection && selection.elements.length > 1
|
|
375
|
+
? selection.getProperty(property)
|
|
376
|
+
: null;
|
|
377
|
+
const selectionMixed = selectedProperty?.value.kind === "mixed";
|
|
378
|
+
const effectiveMixed = mixed || selectionMixed;
|
|
379
|
+
const selectionDisplayValue = selectedProperty?.value.kind === "common"
|
|
380
|
+
? selectedProperty.value.value
|
|
381
|
+
: undefined;
|
|
382
|
+
const effectiveMetadata = editTarget && isMultiTarget(editTarget) ? undefined : editMetadata;
|
|
383
|
+
const tokenBackedOpacityName = tokenRow?.tokenName
|
|
384
|
+
&& tokenRow.opacity
|
|
385
|
+
&& tokenRow.opacity.tokenName !== tokenRow.tokenName
|
|
386
|
+
? tokenRow.tokenName
|
|
387
|
+
: null;
|
|
388
|
+
const expression = Boolean(tokenRow && (tokenRow.capability === "raw" || tokenRow.capability === "composite"
|
|
389
|
+
|| tokenRow.modifiers?.some((modifier) => modifier.kind === "alpha")
|
|
390
|
+
|| tokenRow.color?.isExpression));
|
|
391
|
+
const authored = tokenRow?.authored ?? tokenRow?.declaredValue ?? "";
|
|
392
|
+
const isCalcAuthored = /\bcalc\s*\(/i.test(authored);
|
|
393
|
+
const selectedTokenName = selectedProperty?.token.kind === "common"
|
|
394
|
+
? selectedProperty.token.name
|
|
395
|
+
: null;
|
|
396
|
+
const activeTokenName = effectiveMixed
|
|
397
|
+
? null
|
|
398
|
+
: tokenBackedOpacityName
|
|
399
|
+
?? (expression || isCalcAuthored
|
|
400
|
+
? null
|
|
401
|
+
: selectedProperty ? selectedTokenName : tokenRow?.tokenName ?? null);
|
|
402
|
+
const fallbackValue = initialValue ?? structuredBorderValue(property, tokenRow) ?? computedRaw(el, property);
|
|
403
|
+
// When a calc() was simplified to a numeric value we suppress the token
|
|
404
|
+
// chip so the UI shows the resolved pixel value, not the internal
|
|
405
|
+
// multiplier token (e.g. --spacing). The authored expression stays
|
|
406
|
+
// accessible via the row for diagnostics.
|
|
407
|
+
const authoredOrComputed = tokenBackedOpacityName
|
|
408
|
+
? authored
|
|
409
|
+
: expression || (!activeTokenName && !isCalcAuthored)
|
|
410
|
+
? structuredBorderValue(property, tokenRow) ?? tokenRow?.authored ?? tokenRow?.declaredValue ?? fallbackValue
|
|
411
|
+
: tokenRow?.resolvedValue ?? fallbackValue;
|
|
412
|
+
const committedValue = effectiveMixed
|
|
413
|
+
? displayValue ?? "Mixed"
|
|
414
|
+
: displayValue ?? selectionDisplayValue ?? (property === "font-family" && !activeTokenName
|
|
415
|
+
? primaryFontFamily(authoredOrComputed)
|
|
416
|
+
: authoredOrComputed);
|
|
417
|
+
const currentToken = activeTokenName
|
|
418
|
+
? entries.find((entry) => entry.name === activeTokenName) ?? null
|
|
419
|
+
: null;
|
|
420
|
+
return (_jsx(TokenValueField, { property: property, domElement: el, semanticSlot: semanticSlot, committedValue: committedValue, resolvedValue: tokenRow?.propertyOpacity?.value ?? tokenRow?.resolvedValue ?? committedValue, activeTokenName: activeTokenName, attributionTokens: attributionTokens
|
|
421
|
+
?? (selectedProperty?.token.kind === "mixed" ? ["Mixed tokens"] : undefined)
|
|
422
|
+
?? (expression
|
|
423
|
+
? tokenRow?.tokens?.filter((token) => token.name !== tokenRow.opacity?.tokenName).map((token) => token.name)
|
|
424
|
+
: undefined), opacity: tokenRow?.opacity, color: tokenRow?.color, entries: entries, suggestions: suggestions, inputDataTest: inputDataTest, disabled: disabled, mixed: effectiveMixed, isColor: selectTokens({ property, slot: semanticSlot, entries: [] }).preferredGroup === "color", formatRawValue: (value) => {
|
|
425
|
+
if (formatRawValueProp)
|
|
426
|
+
return formatRawValueProp(value);
|
|
427
|
+
return completeCssValue(value.trim(), valuePolicyFor(property));
|
|
428
|
+
}, onCommitRaw: (value) => {
|
|
429
|
+
if (setStyle(editTarget ?? el, property, value, effectiveMetadata))
|
|
430
|
+
onAfterEdit?.();
|
|
431
|
+
}, onCommitOpacity: (value) => {
|
|
432
|
+
const authored = tokenRow?.authored ?? tokenRow?.declaredValue ?? committedValue;
|
|
433
|
+
const result = applyValueEdit({ kind: "color-opacity", authored, opacity: value });
|
|
434
|
+
if (!result.ok || !setStyle(editTarget ?? el, property, result.value, effectiveMetadata))
|
|
435
|
+
return false;
|
|
436
|
+
onAfterEdit?.();
|
|
437
|
+
return true;
|
|
438
|
+
}, onSelectToken: (chosen) => {
|
|
439
|
+
const targetProperty = tokenRow?.property ?? property;
|
|
440
|
+
if (activeTokenName && tokenBackedOpacityName && currentToken) {
|
|
441
|
+
const result = applyValueEdit({
|
|
442
|
+
kind: "color-token",
|
|
443
|
+
authored,
|
|
444
|
+
currentToken,
|
|
445
|
+
nextToken: chosen,
|
|
446
|
+
});
|
|
447
|
+
if (!result.ok || !setStyle(editTarget ?? el, targetProperty, result.value, effectiveMetadata))
|
|
448
|
+
return false;
|
|
449
|
+
onAfterEdit?.();
|
|
450
|
+
return true;
|
|
451
|
+
}
|
|
452
|
+
const change = activeTokenName
|
|
453
|
+
? swapToken(editTarget ?? el, targetProperty, chosen, currentToken, effectiveMetadata)
|
|
454
|
+
: promoteToToken(editTarget ?? el, property, chosen, effectiveMetadata);
|
|
455
|
+
if (!change)
|
|
456
|
+
return false;
|
|
457
|
+
onAfterEdit?.();
|
|
458
|
+
return true;
|
|
459
|
+
}, onUnlink: (value) => {
|
|
460
|
+
setStyle(editTarget ?? el, property, value, effectiveMetadata);
|
|
461
|
+
onAfterEdit?.();
|
|
462
|
+
}, leading: leading, trailing: trailing, className: className, label: label, chipVariant: chipVariant }));
|
|
463
|
+
}
|
|
464
|
+
function tokenSuggestion(entry, groups) {
|
|
465
|
+
return {
|
|
466
|
+
value: entry.name,
|
|
467
|
+
label: entry.name,
|
|
468
|
+
"data-test": "suggestion-item",
|
|
469
|
+
leading: (groups.get(entry.name) ?? tokenGroup(entry)) === "color"
|
|
470
|
+
? _jsx(ColorSwatch, { color: entry.value })
|
|
471
|
+
: undefined,
|
|
472
|
+
trailing: _jsx("span", { children: entry.value }),
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
const RAW_SUGGESTION_PREFIX = "\u0000raw:";
|
|
476
|
+
function rawSuggestion(value) {
|
|
477
|
+
return {
|
|
478
|
+
value: `${RAW_SUGGESTION_PREFIX}${value}`,
|
|
479
|
+
label: value,
|
|
480
|
+
"data-test": "raw-suggestion-item",
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
function decodeRawSuggestion(value) {
|
|
484
|
+
return value.startsWith(RAW_SUGGESTION_PREFIX) ? value.slice(RAW_SUGGESTION_PREFIX.length) : null;
|
|
485
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactElement } from "react";
|
|
2
|
+
type TokenLabelElement = "code" | "span";
|
|
3
|
+
export interface TokenLabelProps extends HTMLAttributes<HTMLElement> {
|
|
4
|
+
as?: TokenLabelElement;
|
|
5
|
+
}
|
|
6
|
+
export declare function TokenLabel({ as, className, children, title, ...props }: TokenLabelProps): ReactElement;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
function textContent(children) {
|
|
3
|
+
if (children === null || children === undefined || typeof children === "boolean")
|
|
4
|
+
return "";
|
|
5
|
+
if (typeof children === "string" || typeof children === "number" || typeof children === "bigint") {
|
|
6
|
+
return String(children);
|
|
7
|
+
}
|
|
8
|
+
if (Array.isArray(children))
|
|
9
|
+
return children.map(textContent).join("");
|
|
10
|
+
return "";
|
|
11
|
+
}
|
|
12
|
+
export function TokenLabel({ as = "span", className, children, title, ...props }) {
|
|
13
|
+
const childText = textContent(children);
|
|
14
|
+
const labelProps = {
|
|
15
|
+
...props,
|
|
16
|
+
className: `token-label${className ? ` ${className}` : ""}`,
|
|
17
|
+
title: title ?? childText,
|
|
18
|
+
};
|
|
19
|
+
const content = _jsx("span", { className: "token-label__content", children: children });
|
|
20
|
+
return as === "code"
|
|
21
|
+
? _jsx("code", { ...labelProps, children: content })
|
|
22
|
+
: _jsx("span", { ...labelProps, children: content });
|
|
23
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo, useState } from "react";
|
|
3
|
+
import { isTokenChange, useChanges } from "../changes/changesLog.js";
|
|
4
|
+
import { TextInput } from "../ui/TextInput.js";
|
|
5
|
+
import { ControlSurface } from "../ui/ControlSurface.js";
|
|
6
|
+
import { TokenValueField } from "./TokenField.js";
|
|
7
|
+
import { TOKEN_GROUP_LABELS, TOKEN_GROUP_ORDER, aliasName, compatibleTokenNames, contextLabel, filterTokenRows, } from "./catalog.js";
|
|
8
|
+
import { setGlobalTokenValue } from "./tokenEdits.js";
|
|
9
|
+
import { TokenLabel } from "./TokenLabel.js";
|
|
10
|
+
function rowChange(row, changes) {
|
|
11
|
+
return changes.find((change) => isTokenChange(change)
|
|
12
|
+
&& change.tokenName === row.definition.cssName
|
|
13
|
+
&& change.file === row.file
|
|
14
|
+
&& change.line === row.line);
|
|
15
|
+
}
|
|
16
|
+
export function TokensPanel({ rows }) {
|
|
17
|
+
const [query, setQuery] = useState("");
|
|
18
|
+
const visibleRows = useMemo(() => filterTokenRows(rows, query), [query, rows]);
|
|
19
|
+
const entries = useMemo(() => rows.map((row) => ({
|
|
20
|
+
name: row.definition.cssName,
|
|
21
|
+
value: row.resolvedValue || row.authoredValue,
|
|
22
|
+
source: row.activeDeclaration?.source ?? row.definition.declarations[0]?.source ?? "",
|
|
23
|
+
})), [rows]);
|
|
24
|
+
return (_jsxs("section", { className: "tokens-panel", "data-test": "tokens-panel", children: [_jsx("div", { className: "tokens-panel__tools", children: _jsx(TextInput, { type: "search", value: query, placeholder: "Search tokens", "aria-label": "Search tokens", "data-test": "token-search", onChange: (event) => setQuery(event.target.value) }) }), TOKEN_GROUP_ORDER.map((group) => {
|
|
25
|
+
const groupedRows = visibleRows.filter((row) => row.group === group);
|
|
26
|
+
if (groupedRows.length === 0)
|
|
27
|
+
return null;
|
|
28
|
+
return (_jsxs("section", { className: "token-group", "data-test": "token-group", "data-group": group, children: [_jsx("div", { className: "token-group__heading", children: TOKEN_GROUP_LABELS[group] }), groupedRows.map((row) => (_jsx(TokenCatalogItem, { row: row, rows: rows, entries: entries }, row.definition.cssName)))] }, group));
|
|
29
|
+
}), visibleRows.length === 0 ? (_jsx("div", { className: "tokens-panel__empty", "data-test": "tokens-empty", children: "No matching tokens" })) : null] }));
|
|
30
|
+
}
|
|
31
|
+
function TokenCatalogItem({ row, rows, entries, }) {
|
|
32
|
+
const changes = useChanges();
|
|
33
|
+
const activeChange = rowChange(row, changes);
|
|
34
|
+
const committedValue = activeChange?.rawValue ?? row.authoredValue;
|
|
35
|
+
const activeAlias = aliasName(committedValue);
|
|
36
|
+
const effectiveRows = rows.map((candidate) => ({
|
|
37
|
+
...candidate,
|
|
38
|
+
authoredValue: rowChange(candidate, changes)?.rawValue ?? candidate.authoredValue,
|
|
39
|
+
}));
|
|
40
|
+
const effectiveRow = effectiveRows.find((candidate) => candidate.definition.cssName === row.definition.cssName
|
|
41
|
+
&& candidate.file === row.file
|
|
42
|
+
&& candidate.line === row.line) ?? row;
|
|
43
|
+
const allowed = compatibleTokenNames(effectiveRow, effectiveRows);
|
|
44
|
+
const variants = row.definition.declarations.filter((declaration) => declaration !== row.activeDeclaration);
|
|
45
|
+
const tokenName = row.definition.name || row.definition.cssName;
|
|
46
|
+
return (_jsxs("article", { className: "token-row", "data-test": "global-token-row", "data-token-name": row.definition.cssName, "data-active": row.activeDeclaration ? "true" : "false", children: [_jsxs("div", { className: "token-row__inline", children: [_jsx(TokenLabel, { as: "code", className: "token-row__name", title: tokenName, children: tokenName }), row.activeDeclaration ? (_jsx(ControlSurface, { children: _jsx(TokenValueField, { property: row.definition.cssName, committedValue: committedValue, resolvedValue: row.resolvedValue || committedValue, activeTokenName: activeAlias, entries: entries, allowedTokenNames: allowed, isColor: row.group === "color", onCommitRaw: (value) => setGlobalTokenValue(row, value), onSelectToken: (token) => { setGlobalTokenValue(row, `var(${token.name})`); }, onUnlink: (value) => setGlobalTokenValue(row, value) }) })) : (_jsx(TextInput, { disabled: true, value: "Inactive in current theme", "aria-label": `${row.definition.cssName} inactive` }))] }), variants.length > 0 ? (_jsxs("details", { className: "token-variants", "data-test": "token-variants", children: [_jsxs("summary", { children: ["Variants (", variants.length, ")"] }), _jsx("div", { className: "token-variants__list", children: variants.map((declaration) => (_jsxs("div", { className: "token-variant", children: [_jsx("span", { className: "token-variant__context", children: contextLabel(declaration.context) }), _jsx("code", { children: declaration.value }), _jsx("span", { children: declaration.source })] }, `${declaration.source}-${contextLabel(declaration.context)}`))) })] })) : null] }));
|
|
47
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { TokenContext, TokenDeclaration, TokenDefinition } from "../../css/model/index.js";
|
|
2
|
+
import type { StyleRuleContext } from "../changes/editModel.js";
|
|
3
|
+
import type { TokenGroup } from "../../css/value-semantics/index.js";
|
|
4
|
+
export type TokenCatalogGroup = TokenGroup;
|
|
5
|
+
export { TOKEN_GROUP_LABELS, TOKEN_GROUP_ORDER } from "../../css/value-semantics/index.js";
|
|
6
|
+
export interface TokenCatalogRow {
|
|
7
|
+
definition: TokenDefinition;
|
|
8
|
+
activeDeclaration: TokenDeclaration | null;
|
|
9
|
+
authoredValue: string;
|
|
10
|
+
resolvedValue: string;
|
|
11
|
+
selector: string;
|
|
12
|
+
styleContext: StyleRuleContext;
|
|
13
|
+
contextLabel: string;
|
|
14
|
+
file: string;
|
|
15
|
+
line: number;
|
|
16
|
+
group: TokenCatalogGroup;
|
|
17
|
+
}
|
|
18
|
+
export interface TokenRuntime {
|
|
19
|
+
root: HTMLElement;
|
|
20
|
+
mediaMatches(query: string): boolean;
|
|
21
|
+
supports(condition: string): boolean;
|
|
22
|
+
computedToken(name: string): string;
|
|
23
|
+
selectorMatches(selector: string): boolean;
|
|
24
|
+
scopeMatches(scope: string): boolean;
|
|
25
|
+
layerOrder(name: string): number | undefined;
|
|
26
|
+
}
|
|
27
|
+
export declare function isTokenContextActive(context: TokenContext, runtime: TokenRuntime): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Strips host-declared structural scoping markers from a selector so
|
|
30
|
+
* human-facing labels present only author vocabulary (ADR-0011). The marker
|
|
31
|
+
* grammar — Astro's `[data-astro-cid-<hash>]` attribute selectors or
|
|
32
|
+
* `.astro-<hash>` classes, a future Vue/Svelte equivalent — is declared by
|
|
33
|
+
* the host Adapter through the runtime configuration; the raw selector is
|
|
34
|
+
* retained in `context.selector` so resolution keeps matching the rendered
|
|
35
|
+
* DOM. A `:where(...)` wrapper left empty by the removals disappears
|
|
36
|
+
* entirely.
|
|
37
|
+
*/
|
|
38
|
+
export declare function humanizeSelector(selector: string, scopingPattern: RegExp | null): string;
|
|
39
|
+
export declare function contextLabel(context: TokenContext): string;
|
|
40
|
+
export declare function sourceParts(source: string): {
|
|
41
|
+
file: string;
|
|
42
|
+
line: number;
|
|
43
|
+
};
|
|
44
|
+
export declare function styleContext(context: TokenContext): StyleRuleContext;
|
|
45
|
+
export declare function selectorForContext(context: TokenContext): string;
|
|
46
|
+
export declare function classifyCatalogToken(name: string, value?: string): TokenCatalogGroup;
|
|
47
|
+
export declare function buildTokenCatalogRows(catalog: TokenDefinition[], root?: HTMLElement, suppliedRuntime?: TokenRuntime): TokenCatalogRow[];
|
|
48
|
+
export declare function filterTokenRows(rows: readonly TokenCatalogRow[], query: string): TokenCatalogRow[];
|
|
49
|
+
export declare function aliasName(value: string): string | null;
|
|
50
|
+
export declare function createsAliasCycle(tokenName: string, candidateName: string, authoredValues: ReadonlyMap<string, string>): boolean;
|
|
51
|
+
export declare function compatibleTokenNames(row: TokenCatalogRow, rows: readonly TokenCatalogRow[]): Set<string>;
|