noecosystem-design 0.1.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/.editorconfig +12 -0
- package/.github/CODEOWNERS +10 -0
- package/.github/dependabot.yml +12 -0
- package/.github/pull_request_template.md +17 -0
- package/.github/workflows/ci.yml +173 -0
- package/.github/workflows/security.yml +40 -0
- package/.mcp.json +8 -0
- package/.node-version +1 -0
- package/AGENTS.md +62 -0
- package/CONTRIBUTING.md +9 -0
- package/README.md +48 -0
- package/SECURITY.md +7 -0
- package/apps/showcase/index.html +28 -0
- package/apps/showcase/package.json +30 -0
- package/apps/showcase/src/app.css +8 -0
- package/apps/showcase/src/app.tsx +10 -0
- package/apps/showcase/src/catalog/agent-composer-preview.tsx +17 -0
- package/apps/showcase/src/catalog/catalog-index.tsx +2676 -0
- package/apps/showcase/src/catalog/catalog-shell.browser.test.tsx +73 -0
- package/apps/showcase/src/catalog/catalog-shell.tsx +506 -0
- package/apps/showcase/src/main.tsx +17 -0
- package/apps/showcase/tsconfig.json +11 -0
- package/apps/showcase/vite.config.ts +15 -0
- package/apps/storybook/.storybook/main.ts +21 -0
- package/apps/storybook/.storybook/preview.tsx +87 -0
- package/apps/storybook/.storybook/vitest.setup.ts +26 -0
- package/apps/storybook/README.md +5 -0
- package/apps/storybook/package.json +31 -0
- package/apps/storybook/stories/AgentStates.stories.tsx +72 -0
- package/apps/storybook/stories/Bidi.stories.tsx +31 -0
- package/apps/storybook/stories/Button.stories.tsx +19 -0
- package/apps/storybook/stories/Surfaces.stories.tsx +28 -0
- package/apps/storybook/stories/catalog/about-page.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/activity-feed.stories.tsx +50 -0
- package/apps/storybook/stories/catalog/activity-gauge.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/agent-composer.stories.tsx +49 -0
- package/apps/storybook/stories/catalog/agent-message.stories.tsx +37 -0
- package/apps/storybook/stories/catalog/agent-plan.stories.tsx +35 -0
- package/apps/storybook/stories/catalog/agent-workspace.stories.tsx +60 -0
- package/apps/storybook/stories/catalog/alert.stories.tsx +41 -0
- package/apps/storybook/stories/catalog/app-frame.stories.tsx +47 -0
- package/apps/storybook/stories/catalog/approval-request.stories.tsx +30 -0
- package/apps/storybook/stories/catalog/avatar.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/badge-group.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/badge.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/banner.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/bidi-text.stories.tsx +47 -0
- package/apps/storybook/stories/catalog/blog-index-page.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/blog-post-page.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/blog-section.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/bottom-navigation.stories.tsx +27 -0
- package/apps/storybook/stories/catalog/button-group.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/button.stories.tsx +27 -0
- package/apps/storybook/stories/catalog/calendar.stories.tsx +47 -0
- package/apps/storybook/stories/catalog/card.stories.tsx +40 -0
- package/apps/storybook/stories/catalog/careers-section.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/carousel.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/chart-frame.stories.tsx +34 -0
- package/apps/storybook/stories/catalog/chart.stories.tsx +43 -0
- package/apps/storybook/stories/catalog/checkbox.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/code-and-terminal.stories.tsx +39 -0
- package/apps/storybook/stories/catalog/color-picker.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/command-menu.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/contact-page.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/contact-section.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/content-divider.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/content-section.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/context-menu.stories.tsx +66 -0
- package/apps/storybook/stories/catalog/credit-card.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/cta-section.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/dashboard-01.stories.tsx +28 -0
- package/apps/storybook/stories/catalog/dashboard-02.stories.tsx +28 -0
- package/apps/storybook/stories/catalog/dashboard-shell.stories.tsx +65 -0
- package/apps/storybook/stories/catalog/data-list.stories.tsx +37 -0
- package/apps/storybook/stories/catalog/data-table.stories.tsx +51 -0
- package/apps/storybook/stories/catalog/date-picker.stories.tsx +31 -0
- package/apps/storybook/stories/catalog/dialog.stories.tsx +68 -0
- package/apps/storybook/stories/catalog/direction-provider.stories.tsx +36 -0
- package/apps/storybook/stories/catalog/drawer.stories.tsx +58 -0
- package/apps/storybook/stories/catalog/dropdown.stories.tsx +67 -0
- package/apps/storybook/stories/catalog/email-template.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/empty-state.stories.tsx +19 -0
- package/apps/storybook/stories/catalog/error-state.stories.tsx +19 -0
- package/apps/storybook/stories/catalog/fab.stories.tsx +22 -0
- package/apps/storybook/stories/catalog/faq-page.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/faq-section.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/feature-section.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/featured-icon.stories.tsx +45 -0
- package/apps/storybook/stories/catalog/field.stories.tsx +35 -0
- package/apps/storybook/stories/catalog/file-uploader.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/filter-bar.stories.tsx +33 -0
- package/apps/storybook/stories/catalog/footer.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/forgot-password-page.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/gradient-picker.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/header-navigation.stories.tsx +46 -0
- package/apps/storybook/stories/catalog/hero-header.stories.tsx +36 -0
- package/apps/storybook/stories/catalog/icon-system.stories.tsx +48 -0
- package/apps/storybook/stories/catalog/illustration.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/image-picker.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/informational-page-01.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/informational-page-02.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/inline-cta.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/input.stories.tsx +21 -0
- package/apps/storybook/stories/catalog/landing-page.stories.tsx +28 -0
- package/apps/storybook/stories/catalog/legal-page.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/login-page.stories.tsx +42 -0
- package/apps/storybook/stories/catalog/marketing-404-page.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/marketing-header.stories.tsx +35 -0
- package/apps/storybook/stories/catalog/menu.stories.tsx +46 -0
- package/apps/storybook/stories/catalog/messaging.stories.tsx +33 -0
- package/apps/storybook/stories/catalog/metric-card.stories.tsx +20 -0
- package/apps/storybook/stories/catalog/metrics-section.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/mobile-screen.stories.tsx +56 -0
- package/apps/storybook/stories/catalog/multi-select.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/newsletter.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/not-found.stories.tsx +30 -0
- package/apps/storybook/stories/catalog/notification.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/page-header.stories.tsx +37 -0
- package/apps/storybook/stories/catalog/pagination.stories.tsx +27 -0
- package/apps/storybook/stories/catalog/pie-chart.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/pricing-page.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/pricing-section.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/progress-indicator.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/progress-steps.stories.tsx +33 -0
- package/apps/storybook/stories/catalog/qr-code.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/radar-chart.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/radio-group.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/rating.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/rich-text-editor.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/run-inspector.stories.tsx +23 -0
- package/apps/storybook/stories/catalog/section-footer.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/section-header.stories.tsx +31 -0
- package/apps/storybook/stories/catalog/select.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/settings-01.stories.tsx +24 -0
- package/apps/storybook/stories/catalog/settings-02.stories.tsx +24 -0
- package/apps/storybook/stories/catalog/settings-page.stories.tsx +48 -0
- package/apps/storybook/stories/catalog/sidebar-navigation.stories.tsx +40 -0
- package/apps/storybook/stories/catalog/sign-in-form.stories.tsx +28 -0
- package/apps/storybook/stories/catalog/sign-up-page.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/skeleton.stories.tsx +21 -0
- package/apps/storybook/stories/catalog/slider.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/social-button.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/social-proof.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/spinner.stories.tsx +15 -0
- package/apps/storybook/stories/catalog/store-button.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/tabs.stories.tsx +38 -0
- package/apps/storybook/stories/catalog/tags.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/team-page.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/team-section.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/testimonial-section.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/textarea.stories.tsx +22 -0
- package/apps/storybook/stories/catalog/toggle.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/tool-call.stories.tsx +40 -0
- package/apps/storybook/stories/catalog/tooltip.stories.tsx +30 -0
- package/apps/storybook/stories/catalog/tree-view.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/utility-button.stories.tsx +60 -0
- package/apps/storybook/stories/catalog/verification-code.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/verification-page.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/video-player.stories.tsx +18 -0
- package/apps/storybook/stories/catalog/workflow-canvas.stories.tsx +45 -0
- package/apps/storybook/stories/catalog/workflow-node.stories.tsx +24 -0
- package/apps/storybook/vitest.config.ts +39 -0
- package/apps/web/README.md +13 -0
- package/apps/web/app.js +483 -0
- package/apps/web/favicon.svg +6 -0
- package/apps/web/index.html +205 -0
- package/apps/web/styles.css +1823 -0
- package/artifacts/original-delivery/NOE-Design-System-Delivery/README-FIRST.txt +20 -0
- package/artifacts/original-delivery/NOE-Design-System-Delivery/SHA256SUMS.txt +11 -0
- package/artifacts/original-delivery/NOE-Design-System-Delivery/noe-delivery-metadata.json +25 -0
- package/artifacts/original-delivery/NOE-Design-System-Delivery/noe-design-system-evidence.zip +0 -0
- package/artifacts/original-delivery/NOE-Design-System-Delivery/noe-design-system-execution-report.md +60 -0
- package/artifacts/original-delivery/NOE-Design-System-Delivery/noe-design-system-manifest.json +106 -0
- package/artifacts/original-delivery/NOE-Design-System-Delivery/noe-design-system-source.tar.gz +0 -0
- package/artifacts/original-delivery/NOE-Design-System-Delivery/noe-design-system-source.zip +0 -0
- package/artifacts/original-delivery/NOE-Design-System-Delivery/noe-design-system.bundle +0 -0
- package/artifacts/original-delivery/NOE-Design-System-Delivery/noe-evidence-index.html +38 -0
- package/artifacts/original-delivery/NOE-Design-System-Delivery/noe-verification-status.txt +15 -0
- package/artifacts/original-delivery/NOE-Design-System-Delivery/noe-visual-contact-sheet.png +0 -0
- package/artifacts/original-delivery/noe-design-system-evidence/README.txt +13 -0
- package/artifacts/original-delivery/noe-design-system-evidence/evidence/browser-console.json +4 -0
- package/artifacts/original-delivery/noe-design-system-evidence/evidence/layout-audit.json +4 -0
- package/artifacts/original-delivery/noe-design-system-evidence/evidence/review/contact-sheet.png +0 -0
- package/artifacts/original-delivery/noe-design-system-evidence/evidence/screenshots/agent-en-dark-1024.png +0 -0
- package/artifacts/original-delivery/noe-design-system-evidence/evidence/screenshots/agent-en-dark-1280.png +0 -0
- package/artifacts/original-delivery/noe-design-system-evidence/evidence/screenshots/agent-en-dark-1440.png +0 -0
- package/artifacts/original-delivery/noe-design-system-evidence/evidence/screenshots/agent-en-dark-390.png +0 -0
- package/artifacts/original-delivery/noe-design-system-evidence/evidence/screenshots/agent-en-dark-768.png +0 -0
- package/artifacts/original-delivery/noe-design-system-evidence/evidence/screenshots/agent-en-light-1024.png +0 -0
- package/artifacts/original-delivery/noe-design-system-evidence/evidence/screenshots/agent-en-light-1280.png +0 -0
- package/artifacts/original-delivery/noe-design-system-evidence/evidence/screenshots/agent-en-light-1440.png +0 -0
- package/artifacts/original-delivery/noe-design-system-evidence/evidence/screenshots/agent-en-light-390.png +0 -0
- package/artifacts/original-delivery/noe-design-system-evidence/evidence/screenshots/agent-en-light-768.png +0 -0
- package/artifacts/original-delivery/noe-design-system-evidence/evidence/screenshots/agent-fa-dark-1024.png +0 -0
- package/artifacts/original-delivery/noe-design-system-evidence/evidence/screenshots/agent-fa-dark-1280.png +0 -0
- package/artifacts/original-delivery/noe-design-system-evidence/evidence/screenshots/agent-fa-dark-1440.png +0 -0
- package/artifacts/original-delivery/noe-design-system-evidence/evidence/screenshots/agent-fa-dark-390.png +0 -0
- package/artifacts/original-delivery/noe-design-system-evidence/evidence/screenshots/agent-fa-dark-768.png +0 -0
- package/artifacts/original-delivery/noe-design-system-evidence/evidence/screenshots/agent-fa-light-1024.png +0 -0
- package/artifacts/original-delivery/noe-design-system-evidence/evidence/screenshots/agent-fa-light-1280.png +0 -0
- package/artifacts/original-delivery/noe-design-system-evidence/evidence/screenshots/agent-fa-light-1440.png +0 -0
- package/artifacts/original-delivery/noe-design-system-evidence/evidence/screenshots/agent-fa-light-390.png +0 -0
- package/artifacts/original-delivery/noe-design-system-evidence/evidence/screenshots/agent-fa-light-768.png +0 -0
- package/artifacts/original-delivery/noe-design-system-evidence/evidence/screenshots/agent-pseudo-ltr-1024.png +0 -0
- package/artifacts/original-delivery/noe-design-system-evidence/evidence/screenshots/agent-pseudo-rtl-1024.png +0 -0
- package/artifacts/original-delivery/noe-design-system-evidence/evidence/screenshots/consumer-en-light-1440.png +0 -0
- package/artifacts/original-delivery/noe-design-system-evidence/evidence/screenshots/consumer-fa-dark-1440.png +0 -0
- package/artifacts/original-delivery/noe-design-system-evidence/evidence/screenshots/dashboard-en-light-1440.png +0 -0
- package/artifacts/original-delivery/noe-design-system-evidence/evidence/screenshots/dashboard-fa-dark-1440.png +0 -0
- package/artifacts/original-delivery/noe-design-system-evidence/evidence/screenshots/workflow-en-light-1440.png +0 -0
- package/artifacts/original-delivery/noe-design-system-evidence/evidence/screenshots/workflow-fa-dark-1440.png +0 -0
- package/artifacts/original-delivery/noe-design-system-evidence/evidence/screenshots-manifest.json +203 -0
- package/artifacts/original-delivery/noe-design-system-evidence/evidence/verification-result.json +165 -0
- package/artifacts/original-delivery/noe-design-system-evidence/evidence/verification-result.txt +32 -0
- package/artifacts/original-delivery/noe-design-system-evidence/evidence/visual-index.html +1 -0
- package/artifacts/original-delivery/noe-design-system-evidence/noe-delivery-metadata.json +25 -0
- package/artifacts/original-delivery/noe-design-system-evidence/noe-design-system-execution-report.md +60 -0
- package/artifacts/original-delivery/noe-design-system-evidence/noe-design-system-manifest.json +106 -0
- package/artifacts/original-delivery/noe-design-system-evidence/noe-verification-status.txt +15 -0
- package/artifacts/original-delivery/noe-design-system.bundle +0 -0
- package/artifacts/original-delivery/source-evidence/verification-result.json +165 -0
- package/artifacts/original-delivery/source-evidence/verification-result.txt +32 -0
- package/artifacts/registry-consumer-report.json +153 -0
- package/artifacts/source-inputs/persian-fonts/Woff/IRANYekanXFaNum-Black.woff +0 -0
- package/artifacts/source-inputs/persian-fonts/Woff/IRANYekanXFaNum-Bold.woff +0 -0
- package/artifacts/source-inputs/persian-fonts/Woff/IRANYekanXFaNum-DemiBold.woff +0 -0
- package/artifacts/source-inputs/persian-fonts/Woff/IRANYekanXFaNum-ExtraBlack.woff +0 -0
- package/artifacts/source-inputs/persian-fonts/Woff/IRANYekanXFaNum-ExtraBold.woff +0 -0
- package/artifacts/source-inputs/persian-fonts/Woff/IRANYekanXFaNum-Heavy.woff +0 -0
- package/artifacts/source-inputs/persian-fonts/Woff/IRANYekanXFaNum-Light.woff +0 -0
- package/artifacts/source-inputs/persian-fonts/Woff/IRANYekanXFaNum-Medium.woff +0 -0
- package/artifacts/source-inputs/persian-fonts/Woff/IRANYekanXFaNum-Regular.woff +0 -0
- package/artifacts/source-inputs/persian-fonts/Woff/IRANYekanXFaNum-Thin.woff +0 -0
- package/artifacts/source-inputs/persian-fonts/Woff/IRANYekanXFaNum-UltraLight.woff +0 -0
- package/artifacts/source-inputs/persian-fonts/Woff2/IRANYekanXFaNum-Black.woff2 +0 -0
- package/artifacts/source-inputs/persian-fonts/Woff2/IRANYekanXFaNum-Bold.woff2 +0 -0
- package/artifacts/source-inputs/persian-fonts/Woff2/IRANYekanXFaNum-DemiBold.woff2 +0 -0
- package/artifacts/source-inputs/persian-fonts/Woff2/IRANYekanXFaNum-ExtraBlack.woff2 +0 -0
- package/artifacts/source-inputs/persian-fonts/Woff2/IRANYekanXFaNum-ExtraBold.woff2 +0 -0
- package/artifacts/source-inputs/persian-fonts/Woff2/IRANYekanXFaNum-Heavy.woff2 +0 -0
- package/artifacts/source-inputs/persian-fonts/Woff2/IRANYekanXFaNum-Light.woff2 +0 -0
- package/artifacts/source-inputs/persian-fonts/Woff2/IRANYekanXFaNum-Medium.woff2 +0 -0
- package/artifacts/source-inputs/persian-fonts/Woff2/IRANYekanXFaNum-Regular.woff2 +0 -0
- package/artifacts/source-inputs/persian-fonts/Woff2/IRANYekanXFaNum-Thin.woff2 +0 -0
- package/artifacts/source-inputs/persian-fonts/Woff2/IRANYekanXFaNum-UltraLight.woff2 +0 -0
- package/biome.json +170 -0
- package/components.json +23 -0
- package/docs/adr/0001-semantic-foundation.md +5 -0
- package/docs/adr/0002-locale-direction.md +5 -0
- package/docs/adr/0003-registry-mcp.md +5 -0
- package/docs/adr/0004-testing-evidence.md +5 -0
- package/docs/adr/0005-noe-package-namespace.md +9 -0
- package/docs/adr/0006-icons8-icon-policy.md +9 -0
- package/docs/adr/0007-registry-publication-contract.md +9 -0
- package/docs/adr/0008-capability-library-adapter-boundaries.md +16 -0
- package/docs/adr/0009-calendar-system-jalali.md +29 -0
- package/docs/adr/0010-canonical-manifest-ownership.md +29 -0
- package/docs/adr/0011-palette-graphite-governance.md +27 -0
- package/docs/adr/0012-persian-font-gating.md +25 -0
- package/docs/adr/0013-cinematic-token-exception.md +32 -0
- package/docs/design-system/README.md +16 -0
- package/docs/design-system/accessibility.md +20 -0
- package/docs/design-system/agent-guide.md +11 -0
- package/docs/design-system/agentic-ui.md +21 -0
- package/docs/design-system/architecture.md +40 -0
- package/docs/design-system/brand.md +59 -0
- package/docs/design-system/ci-cd.md +46 -0
- package/docs/design-system/components.md +88 -0
- package/docs/design-system/contributing.md +7 -0
- package/docs/design-system/foundations.md +40 -0
- package/docs/design-system/i18n.md +24 -0
- package/docs/design-system/inventory.md +389 -0
- package/docs/design-system/mcp.md +7 -0
- package/docs/design-system/motion.md +7 -0
- package/docs/design-system/noe-brand-audit.md +33 -0
- package/docs/design-system/registry.md +16 -0
- package/docs/design-system/rtl.md +27 -0
- package/docs/design-system/security.md +16 -0
- package/docs/design-system/testing.md +39 -0
- package/docs/design-system/tokens.md +38 -0
- package/docs/design-system/visual-qa.md +10 -0
- package/docs/superpowers/plans/2026-08-25-noe-design-system-development-ready.md +833 -0
- package/docs/superpowers/plans/2026-08-26-noe-complete-catalog.md +422 -0
- package/docs/superpowers/specs/2026-08-25-noe-design-system-development-ready-design.md +260 -0
- package/docs/superpowers/specs/2026-08-26-noe-complete-catalog-design.md +187 -0
- package/llms.txt +20 -0
- package/package.json +68 -0
- package/packages/ai-ui/package.json +15 -0
- package/packages/ai-ui/src/activity-feed.tsx +60 -0
- package/packages/ai-ui/src/agent-composer.tsx +54 -0
- package/packages/ai-ui/src/agent-message.tsx +50 -0
- package/packages/ai-ui/src/agent-plan.tsx +69 -0
- package/packages/ai-ui/src/agent-workspace.tsx +63 -0
- package/packages/ai-ui/src/approval-request.tsx +93 -0
- package/packages/ai-ui/src/index.ts +8 -0
- package/packages/ai-ui/src/run-inspector.tsx +54 -0
- package/packages/ai-ui/src/tool-call.tsx +71 -0
- package/packages/data-ui/package.json +16 -0
- package/packages/data-ui/src/activity-gauge.tsx +38 -0
- package/packages/data-ui/src/chart-frame.tsx +41 -0
- package/packages/data-ui/src/chart.tsx +131 -0
- package/packages/data-ui/src/dashboard-01.tsx +39 -0
- package/packages/data-ui/src/dashboard-02.tsx +33 -0
- package/packages/data-ui/src/dashboard-shell.tsx +56 -0
- package/packages/data-ui/src/data-table.tsx +99 -0
- package/packages/data-ui/src/filter-bar.tsx +28 -0
- package/packages/data-ui/src/index.ts +12 -0
- package/packages/data-ui/src/metric-card.tsx +43 -0
- package/packages/data-ui/src/pagination.tsx +67 -0
- package/packages/data-ui/src/pie-chart.tsx +38 -0
- package/packages/data-ui/src/radar-chart.tsx +38 -0
- package/packages/design-tokens/package.json +23 -0
- package/packages/design-tokens/src/base.css +255 -0
- package/packages/design-tokens/src/fonts/IRANYekanXFaNum-Bold.woff2 +0 -0
- package/packages/design-tokens/src/fonts/IRANYekanXFaNum-DemiBold.woff2 +0 -0
- package/packages/design-tokens/src/fonts/IRANYekanXFaNum-Medium.woff2 +0 -0
- package/packages/design-tokens/src/fonts/IRANYekanXFaNum-Regular.woff2 +0 -0
- package/packages/design-tokens/src/fonts/IRANYekanXVF.ttf +0 -0
- package/packages/design-tokens/src/fonts/README.md +13 -0
- package/packages/design-tokens/src/fonts.css +49 -0
- package/packages/design-tokens/src/index.test.ts +36 -0
- package/packages/design-tokens/src/index.ts +5 -0
- package/packages/design-tokens/src/palette.ts +27 -0
- package/packages/design-tokens/src/tailwind.css +3 -0
- package/packages/design-tokens/src/theme.css +67 -0
- package/packages/design-tokens/src/tokens.css +251 -0
- package/packages/design-tokens/src/tokens.json +275 -0
- package/packages/design-tokens/src/tokens.mjs +276 -0
- package/packages/i18n/package.json +13 -0
- package/packages/i18n/src/index.ts +17 -0
- package/packages/i18n/src/messages/en.json +116 -0
- package/packages/i18n/src/messages/fa.json +116 -0
- package/packages/i18n/src/runtime.d.mts +42 -0
- package/packages/i18n/src/runtime.mjs +113 -0
- package/packages/i18n/src/translate.test.ts +50 -0
- package/packages/i18n/src/translate.ts +29 -0
- package/packages/icons/package.json +12 -0
- package/packages/icons/src/adapters.tsx +167 -0
- package/packages/icons/src/index.tsx +103 -0
- package/packages/registry/README.md +7 -0
- package/packages/registry/catalog-index.json +1345 -0
- package/packages/registry/component-audit.json +1038 -0
- package/packages/registry/coss-adoption.json +281 -0
- package/packages/registry/docs-index.json +1881 -0
- package/packages/registry/manifest.json +11081 -0
- package/packages/registry/manifest.schema.json +135 -0
- package/packages/registry/package.json +10 -0
- package/packages/registry/r/activity-feed.json +67 -0
- package/packages/registry/r/agent-composer.json +79 -0
- package/packages/registry/r/agent-message.json +72 -0
- package/packages/registry/r/agent-plan.json +67 -0
- package/packages/registry/r/agent-workspace.json +67 -0
- package/packages/registry/r/alert.json +68 -0
- package/packages/registry/r/app-frame.json +67 -0
- package/packages/registry/r/approval-request.json +84 -0
- package/packages/registry/r/badge.json +68 -0
- package/packages/registry/r/bidi-text.json +70 -0
- package/packages/registry/r/bottom-navigation.json +67 -0
- package/packages/registry/r/button.json +83 -0
- package/packages/registry/r/calendar.json +97 -0
- package/packages/registry/r/card.json +67 -0
- package/packages/registry/r/chart-frame.json +67 -0
- package/packages/registry/r/chart.json +67 -0
- package/packages/registry/r/code-block.json +67 -0
- package/packages/registry/r/context-menu.json +81 -0
- package/packages/registry/r/dashboard-01.json +86 -0
- package/packages/registry/r/dashboard-02.json +84 -0
- package/packages/registry/r/dashboard-shell.json +67 -0
- package/packages/registry/r/data-list.json +67 -0
- package/packages/registry/r/data-table.json +72 -0
- package/packages/registry/r/date-picker.json +117 -0
- package/packages/registry/r/dialog.json +84 -0
- package/packages/registry/r/direction-provider.json +54 -0
- package/packages/registry/r/drawer.json +80 -0
- package/packages/registry/r/dropdown.json +78 -0
- package/packages/registry/r/empty-state.json +67 -0
- package/packages/registry/r/error-state.json +67 -0
- package/packages/registry/r/fab.json +80 -0
- package/packages/registry/r/featured-icon.json +71 -0
- package/packages/registry/r/filter-bar.json +69 -0
- package/packages/registry/r/gradient-picker.json +62 -0
- package/packages/registry/r/header-navigation.json +67 -0
- package/packages/registry/r/hero-header.json +63 -0
- package/packages/registry/r/icon-system.json +59 -0
- package/packages/registry/r/image-picker.json +62 -0
- package/packages/registry/r/inline-cta.json +73 -0
- package/packages/registry/r/input.json +73 -0
- package/packages/registry/r/landing-page.json +70 -0
- package/packages/registry/r/login-page.json +71 -0
- package/packages/registry/r/marketing-header.json +63 -0
- package/packages/registry/r/menu.json +74 -0
- package/packages/registry/r/messaging.json +69 -0
- package/packages/registry/r/metric-card.json +67 -0
- package/packages/registry/r/mobile-screen.json +67 -0
- package/packages/registry/r/not-found.json +63 -0
- package/packages/registry/r/page-header.json +67 -0
- package/packages/registry/r/pagination.json +91 -0
- package/packages/registry/r/progress-steps.json +69 -0
- package/packages/registry/r/run-inspector.json +72 -0
- package/packages/registry/r/section-header.json +67 -0
- package/packages/registry/r/settings-01.json +94 -0
- package/packages/registry/r/settings-02.json +99 -0
- package/packages/registry/r/settings-page.json +67 -0
- package/packages/registry/r/sidebar-navigation.json +67 -0
- package/packages/registry/r/sign-in-form.json +89 -0
- package/packages/registry/r/skeleton.json +67 -0
- package/packages/registry/r/spinner.json +67 -0
- package/packages/registry/r/tabs.json +69 -0
- package/packages/registry/r/textarea.json +73 -0
- package/packages/registry/r/tool-call.json +72 -0
- package/packages/registry/r/tooltip.json +73 -0
- package/packages/registry/r/utility-button.json +83 -0
- package/packages/registry/r/workflow-canvas.json +67 -0
- package/packages/registry/r/workflow-node.json +72 -0
- package/packages/registry/r-planned-backup/about-page.json +14 -0
- package/packages/registry/r-planned-backup/activity-gauge.json +14 -0
- package/packages/registry/r-planned-backup/avatar.json +14 -0
- package/packages/registry/r-planned-backup/badge-group.json +14 -0
- package/packages/registry/r-planned-backup/banner.json +14 -0
- package/packages/registry/r-planned-backup/blog-index-page.json +14 -0
- package/packages/registry/r-planned-backup/blog-post-page.json +14 -0
- package/packages/registry/r-planned-backup/blog-section.json +14 -0
- package/packages/registry/r-planned-backup/button-group.json +14 -0
- package/packages/registry/r-planned-backup/careers-section.json +14 -0
- package/packages/registry/r-planned-backup/carousel.json +14 -0
- package/packages/registry/r-planned-backup/checkbox.json +14 -0
- package/packages/registry/r-planned-backup/color-picker.json +14 -0
- package/packages/registry/r-planned-backup/command-menu.json +14 -0
- package/packages/registry/r-planned-backup/contact-page.json +14 -0
- package/packages/registry/r-planned-backup/contact-section.json +14 -0
- package/packages/registry/r-planned-backup/content-divider.json +14 -0
- package/packages/registry/r-planned-backup/content-section.json +14 -0
- package/packages/registry/r-planned-backup/credit-card.json +14 -0
- package/packages/registry/r-planned-backup/cta-section.json +14 -0
- package/packages/registry/r-planned-backup/email-template.json +14 -0
- package/packages/registry/r-planned-backup/faq-page.json +14 -0
- package/packages/registry/r-planned-backup/faq-section.json +14 -0
- package/packages/registry/r-planned-backup/feature-section.json +14 -0
- package/packages/registry/r-planned-backup/file-uploader.json +14 -0
- package/packages/registry/r-planned-backup/footer.json +14 -0
- package/packages/registry/r-planned-backup/forgot-password-page.json +14 -0
- package/packages/registry/r-planned-backup/illustration.json +14 -0
- package/packages/registry/r-planned-backup/informational-page-01.json +14 -0
- package/packages/registry/r-planned-backup/informational-page-02.json +14 -0
- package/packages/registry/r-planned-backup/legal-page.json +14 -0
- package/packages/registry/r-planned-backup/marketing-404-page.json +14 -0
- package/packages/registry/r-planned-backup/metrics-section.json +14 -0
- package/packages/registry/r-planned-backup/multi-select.json +14 -0
- package/packages/registry/r-planned-backup/newsletter.json +14 -0
- package/packages/registry/r-planned-backup/notification.json +14 -0
- package/packages/registry/r-planned-backup/pie-chart.json +14 -0
- package/packages/registry/r-planned-backup/pricing-page.json +14 -0
- package/packages/registry/r-planned-backup/pricing-section.json +14 -0
- package/packages/registry/r-planned-backup/progress-indicator.json +14 -0
- package/packages/registry/r-planned-backup/qr-code.json +14 -0
- package/packages/registry/r-planned-backup/radar-chart.json +14 -0
- package/packages/registry/r-planned-backup/radio-group.json +14 -0
- package/packages/registry/r-planned-backup/rating.json +14 -0
- package/packages/registry/r-planned-backup/rich-text-editor.json +14 -0
- package/packages/registry/r-planned-backup/section-footer.json +14 -0
- package/packages/registry/r-planned-backup/select.json +14 -0
- package/packages/registry/r-planned-backup/sign-up-page.json +14 -0
- package/packages/registry/r-planned-backup/slider.json +14 -0
- package/packages/registry/r-planned-backup/social-button.json +14 -0
- package/packages/registry/r-planned-backup/social-proof.json +14 -0
- package/packages/registry/r-planned-backup/store-button.json +14 -0
- package/packages/registry/r-planned-backup/tags.json +14 -0
- package/packages/registry/r-planned-backup/team-page.json +14 -0
- package/packages/registry/r-planned-backup/team-section.json +14 -0
- package/packages/registry/r-planned-backup/testimonial-section.json +14 -0
- package/packages/registry/r-planned-backup/toggle.json +14 -0
- package/packages/registry/r-planned-backup/tree-view.json +14 -0
- package/packages/registry/r-planned-backup/verification-code.json +14 -0
- package/packages/registry/r-planned-backup/verification-page.json +14 -0
- package/packages/registry/r-planned-backup/video-player.json +14 -0
- package/packages/registry/registry.json +1997 -0
- package/packages/registry/search-index.json +3942 -0
- package/packages/testing/package.json +9 -0
- package/packages/testing/src/index.mjs +10 -0
- package/packages/ui/package.json +26 -0
- package/packages/ui/src/about-page.tsx +19 -0
- package/packages/ui/src/alert.tsx +67 -0
- package/packages/ui/src/app-frame.tsx +63 -0
- package/packages/ui/src/avatar.tsx +19 -0
- package/packages/ui/src/badge-group.tsx +19 -0
- package/packages/ui/src/badge.tsx +35 -0
- package/packages/ui/src/banner.tsx +19 -0
- package/packages/ui/src/bidi.tsx +80 -0
- package/packages/ui/src/blog-index-page.tsx +19 -0
- package/packages/ui/src/blog-post-page.tsx +19 -0
- package/packages/ui/src/blog-section.tsx +19 -0
- package/packages/ui/src/bottom-navigation.tsx +60 -0
- package/packages/ui/src/button-group.tsx +19 -0
- package/packages/ui/src/button.browser.test.tsx +38 -0
- package/packages/ui/src/button.tsx +81 -0
- package/packages/ui/src/calendar-system.test.ts +103 -0
- package/packages/ui/src/calendar-system.ts +120 -0
- package/packages/ui/src/calendar.browser.test.tsx +52 -0
- package/packages/ui/src/calendar.tsx +339 -0
- package/packages/ui/src/card.tsx +63 -0
- package/packages/ui/src/careers-section.tsx +19 -0
- package/packages/ui/src/carousel.tsx +19 -0
- package/packages/ui/src/checkbox.tsx +17 -0
- package/packages/ui/src/cinematic/cinematic.css +2020 -0
- package/packages/ui/src/cinematic/ecosystem-motion-showcase.tsx +265 -0
- package/packages/ui/src/cinematic/ecosystem-sphere.tsx +627 -0
- package/packages/ui/src/cinematic/index.ts +5 -0
- package/packages/ui/src/cinematic/kinetic-experience.tsx +207 -0
- package/packages/ui/src/cinematic/portfolio.ts +132 -0
- package/packages/ui/src/cinematic/system-anatomy.tsx +173 -0
- package/packages/ui/src/code.tsx +119 -0
- package/packages/ui/src/color-picker.tsx +22 -0
- package/packages/ui/src/command-menu.tsx +19 -0
- package/packages/ui/src/contact-page.tsx +19 -0
- package/packages/ui/src/contact-section.tsx +19 -0
- package/packages/ui/src/content-divider.tsx +19 -0
- package/packages/ui/src/content-section.tsx +19 -0
- package/packages/ui/src/context-menu.tsx +208 -0
- package/packages/ui/src/credit-card.tsx +19 -0
- package/packages/ui/src/cta-section.tsx +19 -0
- package/packages/ui/src/data-list.tsx +81 -0
- package/packages/ui/src/date-picker.browser.test.tsx +48 -0
- package/packages/ui/src/date-picker.tsx +248 -0
- package/packages/ui/src/dialog.browser.test.tsx +32 -0
- package/packages/ui/src/dialog.tsx +144 -0
- package/packages/ui/src/direction.tsx +46 -0
- package/packages/ui/src/drawer.tsx +179 -0
- package/packages/ui/src/dropdown.tsx +200 -0
- package/packages/ui/src/email-template.tsx +19 -0
- package/packages/ui/src/empty-state.tsx +43 -0
- package/packages/ui/src/error-state.tsx +44 -0
- package/packages/ui/src/fab.tsx +32 -0
- package/packages/ui/src/faq-page.tsx +19 -0
- package/packages/ui/src/faq-section.tsx +19 -0
- package/packages/ui/src/feature-section.tsx +19 -0
- package/packages/ui/src/featured-icon.tsx +63 -0
- package/packages/ui/src/field.browser.test.tsx +33 -0
- package/packages/ui/src/field.tsx +117 -0
- package/packages/ui/src/file-uploader.tsx +19 -0
- package/packages/ui/src/footer.tsx +19 -0
- package/packages/ui/src/forgot-password-page.tsx +19 -0
- package/packages/ui/src/gradient-picker.tsx +65 -0
- package/packages/ui/src/header-navigation.tsx +71 -0
- package/packages/ui/src/hero-header.tsx +57 -0
- package/packages/ui/src/illustration.tsx +19 -0
- package/packages/ui/src/image-picker.tsx +56 -0
- package/packages/ui/src/index.ts +110 -0
- package/packages/ui/src/informational-page-01.tsx +19 -0
- package/packages/ui/src/informational-page-02.tsx +19 -0
- package/packages/ui/src/inline-cta.tsx +29 -0
- package/packages/ui/src/input.tsx +44 -0
- package/packages/ui/src/landing-page.tsx +56 -0
- package/packages/ui/src/legal-page.tsx +19 -0
- package/packages/ui/src/lib/cn.ts +6 -0
- package/packages/ui/src/lib/i18n-messages.ts +40 -0
- package/packages/ui/src/login-page.tsx +78 -0
- package/packages/ui/src/marketing-404-page.tsx +19 -0
- package/packages/ui/src/marketing-header.tsx +53 -0
- package/packages/ui/src/menu.tsx +220 -0
- package/packages/ui/src/messaging.tsx +62 -0
- package/packages/ui/src/metrics-section.tsx +19 -0
- package/packages/ui/src/mobile-screen.tsx +37 -0
- package/packages/ui/src/multi-select.tsx +16 -0
- package/packages/ui/src/newsletter.tsx +19 -0
- package/packages/ui/src/not-found.tsx +60 -0
- package/packages/ui/src/notification.tsx +19 -0
- package/packages/ui/src/page-header.tsx +80 -0
- package/packages/ui/src/pricing-page.tsx +19 -0
- package/packages/ui/src/pricing-section.tsx +19 -0
- package/packages/ui/src/progress-indicator.tsx +19 -0
- package/packages/ui/src/progress-steps.tsx +85 -0
- package/packages/ui/src/qr-code.tsx +19 -0
- package/packages/ui/src/radio-group.tsx +26 -0
- package/packages/ui/src/rating.tsx +19 -0
- package/packages/ui/src/rich-text-editor.tsx +18 -0
- package/packages/ui/src/section-footer.tsx +19 -0
- package/packages/ui/src/section-header.tsx +37 -0
- package/packages/ui/src/select.tsx +27 -0
- package/packages/ui/src/settings-01.tsx +49 -0
- package/packages/ui/src/settings-02.tsx +58 -0
- package/packages/ui/src/settings-page.tsx +62 -0
- package/packages/ui/src/sidebar-navigation.tsx +77 -0
- package/packages/ui/src/sign-in-form.tsx +60 -0
- package/packages/ui/src/sign-up-page.tsx +19 -0
- package/packages/ui/src/skeleton.tsx +14 -0
- package/packages/ui/src/slider.tsx +13 -0
- package/packages/ui/src/social-button.tsx +19 -0
- package/packages/ui/src/social-proof.tsx +19 -0
- package/packages/ui/src/spinner.tsx +26 -0
- package/packages/ui/src/store-button.tsx +19 -0
- package/packages/ui/src/tabs.browser.test.tsx +33 -0
- package/packages/ui/src/tabs.tsx +175 -0
- package/packages/ui/src/tags.tsx +11 -0
- package/packages/ui/src/team-page.tsx +19 -0
- package/packages/ui/src/team-section.tsx +19 -0
- package/packages/ui/src/testimonial-section.tsx +19 -0
- package/packages/ui/src/textarea.tsx +45 -0
- package/packages/ui/src/theme-provider.browser.test.tsx +90 -0
- package/packages/ui/src/theme-provider.tsx +417 -0
- package/packages/ui/src/theme-toggle.tsx +107 -0
- package/packages/ui/src/toggle.tsx +34 -0
- package/packages/ui/src/tooltip.tsx +50 -0
- package/packages/ui/src/tree-view.tsx +19 -0
- package/packages/ui/src/utility-button.tsx +33 -0
- package/packages/ui/src/utils.ts +13 -0
- package/packages/ui/src/verification-code.tsx +27 -0
- package/packages/ui/src/verification-page.tsx +19 -0
- package/packages/ui/src/video-player.tsx +19 -0
- package/packages/workflow-ui/package.json +15 -0
- package/packages/workflow-ui/src/index.ts +2 -0
- package/packages/workflow-ui/src/workflow-canvas.tsx +51 -0
- package/packages/workflow-ui/src/workflow-node.tsx +61 -0
- package/playwright.config.ts +58 -0
- package/pnpm-workspace.yaml +5 -0
- package/registry.json +216 -0
- package/scripts/build-static.mjs +68 -0
- package/scripts/capture-visuals.py +106 -0
- package/scripts/capture-visuals.sh +10 -0
- package/scripts/create-visual-index.mjs +16 -0
- package/scripts/enrich-registry-payloads.mjs +83 -0
- package/scripts/fix-noe-imports.mjs +134 -0
- package/scripts/fix-registry-closure.mjs +110 -0
- package/scripts/fix-registry-deps-cleanup.mjs +149 -0
- package/scripts/fix-relative-for-registry.mjs +103 -0
- package/scripts/generate-design-tokens.mjs +134 -0
- package/scripts/generate-inventory.mjs +62 -0
- package/scripts/generate-manifest.mjs +1149 -0
- package/scripts/generate-phase4.mjs +875 -0
- package/scripts/validate-manifest.mjs +477 -0
- package/scripts/validate-pngs.mjs +31 -0
- package/scripts/verify-registry-consumer.mjs +319 -0
- package/scripts/verify-registry-dependencies.mjs +162 -0
- package/scripts/verify.mjs +316 -0
- package/tests/catalog-audit.test.mjs +156 -0
- package/tests/e2e/capture-visuals.mjs +34 -0
- package/tests/e2e/catalog-typography.spec.ts +110 -0
- package/tests/e2e/catalog.spec.ts +68 -0
- package/tests/e2e/direction.spec.ts +60 -0
- package/tests/e2e/responsive.spec.ts +30 -0
- package/tests/e2e/surfaces.spec.ts +51 -0
- package/tests/i18n.test.mjs +36 -0
- package/tests/icons.test.mjs +21 -0
- package/tests/registry-publication.test.mjs +88 -0
- package/tests/registry.test.mjs +51 -0
- package/tests/rtl.test.mjs +21 -0
- package/tests/static-app.test.mjs +49 -0
- package/tests/tokens.test.mjs +24 -0
- package/tests/workspace.test.mjs +25 -0
- package/tsconfig.base.json +69 -0
- package/tsconfig.json +27 -0
- package/tsconfig.verify.json +19 -0
- package/types/offline-react.d.ts +73 -0
- package/vitest.config.ts +91 -0
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
DEFAULT_PALETTE as TOKEN_DEFAULT_PALETTE,
|
|
5
|
+
PALETTE_COOKIE_KEY as TOKEN_PALETTE_COOKIE_KEY,
|
|
6
|
+
PALETTE_STORAGE_KEY as TOKEN_PALETTE_STORAGE_KEY,
|
|
7
|
+
PALETTES as TOKEN_PALETTES,
|
|
8
|
+
type Palette as TokenPalette,
|
|
9
|
+
isPalette as isTokenPalette,
|
|
10
|
+
} from '@noe/design-tokens/palette';
|
|
11
|
+
import { tokens } from '@noe/design-tokens';
|
|
12
|
+
|
|
13
|
+
export type ThemePreference = 'light' | 'dark' | 'system';
|
|
14
|
+
export type ResolvedTheme = 'light' | 'dark';
|
|
15
|
+
export type NoeTheme = ThemePreference;
|
|
16
|
+
|
|
17
|
+
export const PALETTES = TOKEN_PALETTES;
|
|
18
|
+
export type Palette = TokenPalette;
|
|
19
|
+
export const DEFAULT_PALETTE: Palette = TOKEN_DEFAULT_PALETTE;
|
|
20
|
+
// Re-export token-backed check for external consumers
|
|
21
|
+
export const isPalette = isTokenPalette;
|
|
22
|
+
|
|
23
|
+
const STORAGE_KEY = 'noecosystem-theme';
|
|
24
|
+
const EXPLORER_KEY = 'theme';
|
|
25
|
+
const COOKIE_KEY = 'noecosystem-theme';
|
|
26
|
+
const PALETTE_STORAGE_KEY = TOKEN_PALETTE_STORAGE_KEY;
|
|
27
|
+
const PALETTE_COOKIE_KEY = TOKEN_PALETTE_COOKIE_KEY;
|
|
28
|
+
|
|
29
|
+
type ThemeContextValue = {
|
|
30
|
+
theme: ThemePreference;
|
|
31
|
+
resolvedTheme: ResolvedTheme;
|
|
32
|
+
setTheme: (next: ThemePreference) => void;
|
|
33
|
+
toggle: () => void;
|
|
34
|
+
palette: Palette;
|
|
35
|
+
setPalette: (next: Palette) => void;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const ThemeContext = React.createContext<ThemeContextValue | null>(null);
|
|
39
|
+
|
|
40
|
+
function isTheme(value: unknown): value is ResolvedTheme {
|
|
41
|
+
return value === 'light' || value === 'dark';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function readStorage(key: string): string | null {
|
|
45
|
+
try {
|
|
46
|
+
return window.localStorage.getItem(key);
|
|
47
|
+
} catch {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function writeStorage(key: string, value: string) {
|
|
53
|
+
try {
|
|
54
|
+
window.localStorage.setItem(key, value);
|
|
55
|
+
} catch {}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function removeStorage(key: string) {
|
|
59
|
+
try {
|
|
60
|
+
window.localStorage.removeItem(key);
|
|
61
|
+
} catch {}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function readCookie(cookieKey: string = COOKIE_KEY): string | null {
|
|
65
|
+
try {
|
|
66
|
+
const prefix = `${cookieKey}=`;
|
|
67
|
+
const entry = document.cookie
|
|
68
|
+
.split(';')
|
|
69
|
+
.map((part) => part.trim())
|
|
70
|
+
.find((part) => part.startsWith(prefix));
|
|
71
|
+
return entry ? decodeURIComponent(entry.slice(prefix.length)) : null;
|
|
72
|
+
} catch {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function writeCookie(theme: string, cookieKey: string = COOKIE_KEY) {
|
|
78
|
+
if (typeof window === 'undefined' || typeof document === 'undefined') return;
|
|
79
|
+
const sharedDomain =
|
|
80
|
+
window.location.hostname === 'noecosystem.com' ||
|
|
81
|
+
window.location.hostname.endsWith('.noecosystem.com')
|
|
82
|
+
? '; Domain=.noecosystem.com'
|
|
83
|
+
: '';
|
|
84
|
+
const secure =
|
|
85
|
+
typeof window !== 'undefined' && window.location.protocol === 'https:' ? '; Secure' : '';
|
|
86
|
+
document.cookie = `${cookieKey}=${encodeURIComponent(theme)}; Path=/; Max-Age=31536000; SameSite=Lax${sharedDomain}${secure}`;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function preferredTheme(): ResolvedTheme {
|
|
90
|
+
if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') return 'dark';
|
|
91
|
+
return window.matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark';
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function readStoredPreference(storageKey: string): ThemePreference | null {
|
|
95
|
+
const shared = readStorage(storageKey);
|
|
96
|
+
if (isTheme(shared)) return shared;
|
|
97
|
+
const cookie = readCookie(COOKIE_KEY);
|
|
98
|
+
if (isTheme(cookie)) return cookie;
|
|
99
|
+
const explorer = readStorage(EXPLORER_KEY);
|
|
100
|
+
if (isTheme(explorer)) return explorer;
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function resolveTheme(preference: ThemePreference): ResolvedTheme {
|
|
105
|
+
return preference === 'system' ? preferredTheme() : preference;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function readStoredPalette(storageKey: string): Palette | null {
|
|
109
|
+
const fromStorage = readStorage(storageKey);
|
|
110
|
+
if (isPalette(fromStorage)) return fromStorage as Palette;
|
|
111
|
+
const paletteCookie = readCookie(storageKey);
|
|
112
|
+
if (isPalette(paletteCookie)) return paletteCookie as Palette;
|
|
113
|
+
const fallbackCookie = storageKey !== PALETTE_COOKIE_KEY ? readCookie(PALETTE_COOKIE_KEY) : null;
|
|
114
|
+
if (isPalette(fallbackCookie)) return fallbackCookie as Palette;
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function writePaletteStorage(palette: Palette, storageKey: string) {
|
|
119
|
+
writeStorage(storageKey, palette);
|
|
120
|
+
if (typeof document !== 'undefined') {
|
|
121
|
+
const sharedDomain =
|
|
122
|
+
window.location.hostname === 'noecosystem.com' ||
|
|
123
|
+
window.location.hostname.endsWith('.noecosystem.com')
|
|
124
|
+
? '; Domain=.noecosystem.com'
|
|
125
|
+
: '';
|
|
126
|
+
const secure = window.location.protocol === 'https:' ? '; Secure' : '';
|
|
127
|
+
document.cookie = `${storageKey}=${encodeURIComponent(palette)}; Path=/; Max-Age=31536000; SameSite=Lax${sharedDomain}${secure}`;
|
|
128
|
+
if (storageKey !== PALETTE_COOKIE_KEY) {
|
|
129
|
+
document.cookie = `${PALETTE_COOKIE_KEY}=${encodeURIComponent(palette)}; Path=/; Max-Age=31536000; SameSite=Lax${sharedDomain}${secure}`;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function removePaletteStorage(storageKey: string) {
|
|
135
|
+
removeStorage(storageKey);
|
|
136
|
+
if (storageKey !== PALETTE_STORAGE_KEY) removeStorage(PALETTE_STORAGE_KEY);
|
|
137
|
+
try {
|
|
138
|
+
if (typeof document !== 'undefined') {
|
|
139
|
+
document.cookie = `${storageKey}=; Path=/; Max-Age=0; SameSite=Lax`;
|
|
140
|
+
if (storageKey !== PALETTE_COOKIE_KEY) {
|
|
141
|
+
document.cookie = `${PALETTE_COOKIE_KEY}=; Path=/; Max-Age=0; SameSite=Lax`;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
} catch {}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function applyPaletteToDocument(palette: Palette) {
|
|
148
|
+
if (typeof document === 'undefined') return;
|
|
149
|
+
const root = document.documentElement;
|
|
150
|
+
root.setAttribute('data-noe-palette', palette);
|
|
151
|
+
(root as HTMLElement).dataset.noePalette = palette;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function applyThemeToDocument(theme: ResolvedTheme) {
|
|
155
|
+
if (typeof document === 'undefined') return;
|
|
156
|
+
const root = document.documentElement;
|
|
157
|
+
root.dataset.theme = theme;
|
|
158
|
+
root.classList.toggle('light', theme === 'light');
|
|
159
|
+
root.classList.toggle('dark', theme === 'dark');
|
|
160
|
+
root.style.colorScheme = theme;
|
|
161
|
+
const meta = document.querySelector<HTMLMetaElement>('meta[name="theme-color"]');
|
|
162
|
+
if (meta) {
|
|
163
|
+
const lightFallback = (tokens as unknown as { primitive: { color: { paper: Record<string, string> } } }).primitive?.color?.paper?.['100'] ?? '#f3f0ea';
|
|
164
|
+
const darkFallback = (tokens as unknown as { primitive: { color: { ink: Record<string, string> } } }).primitive?.color?.ink?.['950'] ?? '#252423';
|
|
165
|
+
const light = meta.getAttribute('data-theme-light') ?? lightFallback;
|
|
166
|
+
const dark = meta.getAttribute('data-theme-dark') ?? darkFallback;
|
|
167
|
+
meta.setAttribute('content', theme === 'light' ? light : dark);
|
|
168
|
+
}
|
|
169
|
+
if (typeof window !== 'undefined') {
|
|
170
|
+
window.dispatchEvent(new CustomEvent('noecosystem-themechange', { detail: { theme } }));
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export function ThemeProvider({
|
|
175
|
+
children,
|
|
176
|
+
defaultTheme = 'system',
|
|
177
|
+
storageKey = STORAGE_KEY,
|
|
178
|
+
defaultPalette = DEFAULT_PALETTE,
|
|
179
|
+
paletteStorageKey = PALETTE_STORAGE_KEY,
|
|
180
|
+
}: {
|
|
181
|
+
children: React.ReactNode;
|
|
182
|
+
defaultTheme?: ThemePreference;
|
|
183
|
+
storageKey?: string;
|
|
184
|
+
defaultPalette?: Palette;
|
|
185
|
+
paletteStorageKey?: string;
|
|
186
|
+
}) {
|
|
187
|
+
const [preference, setPreference] = React.useState<ThemePreference>(() => {
|
|
188
|
+
if (typeof window === 'undefined') return defaultTheme;
|
|
189
|
+
if (defaultTheme !== 'system' && isTheme(defaultTheme)) return defaultTheme;
|
|
190
|
+
const stored = readStoredPreference(storageKey);
|
|
191
|
+
return stored ?? 'system';
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
const [resolvedTheme, setResolvedTheme] = React.useState<ResolvedTheme>(() => {
|
|
195
|
+
if (typeof window === 'undefined') return 'dark';
|
|
196
|
+
if (preference !== 'system' && isTheme(preference)) return preference;
|
|
197
|
+
const stored = readStoredPreference(storageKey);
|
|
198
|
+
if (stored && isTheme(stored)) return stored;
|
|
199
|
+
if (typeof window !== 'undefined' && defaultTheme !== 'system' && isTheme(defaultTheme))
|
|
200
|
+
return defaultTheme;
|
|
201
|
+
return preferredTheme();
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
const [palette, setPaletteState] = React.useState<Palette>(() => {
|
|
205
|
+
if (typeof window === 'undefined') return isPalette(defaultPalette) ? defaultPalette : DEFAULT_PALETTE;
|
|
206
|
+
const stored = readStoredPalette(paletteStorageKey);
|
|
207
|
+
if (stored && isPalette(stored)) return stored;
|
|
208
|
+
if (isPalette(defaultPalette)) return defaultPalette;
|
|
209
|
+
return DEFAULT_PALETTE;
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
const syncTheme = React.useCallback(
|
|
213
|
+
(nextPreference: ThemePreference) => {
|
|
214
|
+
const nextResolved = resolveTheme(nextPreference);
|
|
215
|
+
setPreference(nextPreference);
|
|
216
|
+
setResolvedTheme(nextResolved);
|
|
217
|
+
applyThemeToDocument(nextResolved);
|
|
218
|
+
if (nextPreference === 'system') {
|
|
219
|
+
removeStorage(storageKey);
|
|
220
|
+
removeStorage(EXPLORER_KEY);
|
|
221
|
+
try {
|
|
222
|
+
if (typeof document !== 'undefined') {
|
|
223
|
+
document.cookie = `${COOKIE_KEY}=; Path=/; Max-Age=0; SameSite=Lax`;
|
|
224
|
+
}
|
|
225
|
+
} catch {}
|
|
226
|
+
} else {
|
|
227
|
+
writeStorage(storageKey, nextPreference);
|
|
228
|
+
writeStorage(EXPLORER_KEY, nextPreference);
|
|
229
|
+
writeCookie(nextPreference, COOKIE_KEY);
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
[storageKey],
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
React.useEffect(() => {
|
|
236
|
+
if (defaultTheme !== 'system' && isTheme(defaultTheme)) {
|
|
237
|
+
syncTheme(defaultTheme);
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
const stored = readStoredPreference(storageKey);
|
|
241
|
+
if (stored && isTheme(stored)) {
|
|
242
|
+
setPreference(stored);
|
|
243
|
+
setResolvedTheme(stored);
|
|
244
|
+
applyThemeToDocument(stored);
|
|
245
|
+
} else {
|
|
246
|
+
const sys = preferredTheme();
|
|
247
|
+
setPreference('system');
|
|
248
|
+
setResolvedTheme(sys);
|
|
249
|
+
applyThemeToDocument(sys);
|
|
250
|
+
}
|
|
251
|
+
}, [defaultTheme, syncTheme, storageKey]);
|
|
252
|
+
|
|
253
|
+
React.useEffect(() => {
|
|
254
|
+
if (preference !== 'system') return;
|
|
255
|
+
if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') return;
|
|
256
|
+
const media = window.matchMedia('(prefers-color-scheme: light)');
|
|
257
|
+
const onChange = () => {
|
|
258
|
+
const next = preferredTheme();
|
|
259
|
+
setResolvedTheme(next);
|
|
260
|
+
applyThemeToDocument(next);
|
|
261
|
+
};
|
|
262
|
+
media.addEventListener('change', onChange);
|
|
263
|
+
return () => media.removeEventListener('change', onChange);
|
|
264
|
+
}, [preference]);
|
|
265
|
+
|
|
266
|
+
React.useEffect(() => {
|
|
267
|
+
const onStorage = (event: StorageEvent) => {
|
|
268
|
+
if (event.key === storageKey) {
|
|
269
|
+
if (isTheme(event.newValue)) {
|
|
270
|
+
setPreference(event.newValue);
|
|
271
|
+
setResolvedTheme(event.newValue);
|
|
272
|
+
applyThemeToDocument(event.newValue);
|
|
273
|
+
} else if (event.newValue === null) {
|
|
274
|
+
const sys = preferredTheme();
|
|
275
|
+
setPreference('system');
|
|
276
|
+
setResolvedTheme(sys);
|
|
277
|
+
applyThemeToDocument(sys);
|
|
278
|
+
}
|
|
279
|
+
} else if (event.key === EXPLORER_KEY && !isTheme(readStorage(storageKey))) {
|
|
280
|
+
if (isTheme(event.newValue)) {
|
|
281
|
+
setPreference(event.newValue);
|
|
282
|
+
setResolvedTheme(event.newValue);
|
|
283
|
+
applyThemeToDocument(event.newValue);
|
|
284
|
+
} else if (event.newValue === null) {
|
|
285
|
+
const sys = preferredTheme();
|
|
286
|
+
setPreference('system');
|
|
287
|
+
setResolvedTheme(sys);
|
|
288
|
+
applyThemeToDocument(sys);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
if (typeof window !== 'undefined') window.addEventListener('storage', onStorage);
|
|
293
|
+
return () => {
|
|
294
|
+
if (typeof window !== 'undefined') window.removeEventListener('storage', onStorage);
|
|
295
|
+
};
|
|
296
|
+
}, [storageKey]);
|
|
297
|
+
|
|
298
|
+
const syncPalette = React.useCallback(
|
|
299
|
+
(nextPalette: Palette) => {
|
|
300
|
+
const validated = isPalette(nextPalette) ? nextPalette : DEFAULT_PALETTE;
|
|
301
|
+
setPaletteState(validated);
|
|
302
|
+
applyPaletteToDocument(validated);
|
|
303
|
+
writePaletteStorage(validated, paletteStorageKey);
|
|
304
|
+
},
|
|
305
|
+
[paletteStorageKey],
|
|
306
|
+
);
|
|
307
|
+
|
|
308
|
+
React.useEffect(() => {
|
|
309
|
+
const stored = readStoredPalette(paletteStorageKey);
|
|
310
|
+
const initialPalette = stored && isPalette(stored) ? stored : isPalette(defaultPalette) ? defaultPalette : DEFAULT_PALETTE;
|
|
311
|
+
const validated = isPalette(initialPalette) ? initialPalette : DEFAULT_PALETTE;
|
|
312
|
+
setPaletteState(validated);
|
|
313
|
+
applyPaletteToDocument(validated);
|
|
314
|
+
if (!isPalette(stored)) {
|
|
315
|
+
writePaletteStorage(validated, paletteStorageKey);
|
|
316
|
+
}
|
|
317
|
+
}, [paletteStorageKey, defaultPalette]);
|
|
318
|
+
|
|
319
|
+
React.useEffect(() => {
|
|
320
|
+
const onStorage = (event: StorageEvent) => {
|
|
321
|
+
if (event.key === paletteStorageKey || event.key === PALETTE_STORAGE_KEY || event.key === PALETTE_COOKIE_KEY) {
|
|
322
|
+
if (isPalette(event.newValue)) {
|
|
323
|
+
setPaletteState(event.newValue as Palette);
|
|
324
|
+
applyPaletteToDocument(event.newValue as Palette);
|
|
325
|
+
} else if (event.newValue === null) {
|
|
326
|
+
const fallback = isPalette(defaultPalette) ? defaultPalette : DEFAULT_PALETTE;
|
|
327
|
+
setPaletteState(fallback);
|
|
328
|
+
applyPaletteToDocument(fallback);
|
|
329
|
+
} else {
|
|
330
|
+
setPaletteState(DEFAULT_PALETTE);
|
|
331
|
+
applyPaletteToDocument(DEFAULT_PALETTE);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
if (typeof window !== 'undefined') window.addEventListener('storage', onStorage);
|
|
336
|
+
return () => {
|
|
337
|
+
if (typeof window !== 'undefined') window.removeEventListener('storage', onStorage);
|
|
338
|
+
};
|
|
339
|
+
}, [paletteStorageKey, defaultPalette]);
|
|
340
|
+
|
|
341
|
+
React.useEffect(() => {
|
|
342
|
+
return () => {
|
|
343
|
+
// Cleanup on unmount is not needed for persistence, but satisfy strict cleanup contract
|
|
344
|
+
};
|
|
345
|
+
}, []);
|
|
346
|
+
|
|
347
|
+
const setTheme = React.useCallback(
|
|
348
|
+
(next: ThemePreference) => {
|
|
349
|
+
syncTheme(next);
|
|
350
|
+
},
|
|
351
|
+
[syncTheme],
|
|
352
|
+
);
|
|
353
|
+
|
|
354
|
+
const toggle = React.useCallback(() => {
|
|
355
|
+
setTheme(resolvedTheme === 'dark' ? 'light' : 'dark');
|
|
356
|
+
}, [resolvedTheme, setTheme]);
|
|
357
|
+
|
|
358
|
+
const setPalette = React.useCallback(
|
|
359
|
+
(next: Palette) => {
|
|
360
|
+
syncPalette(next);
|
|
361
|
+
},
|
|
362
|
+
[syncPalette],
|
|
363
|
+
);
|
|
364
|
+
|
|
365
|
+
// Expose cleanup helper for tests that need to simulate logout/reset
|
|
366
|
+
const cleanupPalette = React.useCallback(() => {
|
|
367
|
+
removePaletteStorage(paletteStorageKey);
|
|
368
|
+
}, [paletteStorageKey]);
|
|
369
|
+
|
|
370
|
+
// Keep paletteStorageKey used to satisfy lint and support cleanup
|
|
371
|
+
void cleanupPalette;
|
|
372
|
+
|
|
373
|
+
const value = React.useMemo<ThemeContextValue>(
|
|
374
|
+
() => ({ theme: preference, resolvedTheme, setTheme, toggle, palette, setPalette }),
|
|
375
|
+
[preference, resolvedTheme, setTheme, toggle, palette, setPalette],
|
|
376
|
+
);
|
|
377
|
+
|
|
378
|
+
return <ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
export function useTheme() {
|
|
382
|
+
const ctx = React.useContext(ThemeContext);
|
|
383
|
+
if (!ctx)
|
|
384
|
+
throw new Error(
|
|
385
|
+
'useTheme must be used within ThemeProvider — wrap your app with <ThemeProvider>.',
|
|
386
|
+
);
|
|
387
|
+
return ctx;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
export function useThemeSafe(): ThemeContextValue | null {
|
|
391
|
+
return React.useContext(ThemeContext);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// Palette registry export for docs/tests
|
|
395
|
+
export { PALETTE_STORAGE_KEY, PALETTE_COOKIE_KEY };
|
|
396
|
+
|
|
397
|
+
// Theme init script — derives palettes from token registry to avoid duplication.
|
|
398
|
+
// Uses graphitesque fallback if storage contains invalid value.
|
|
399
|
+
const paletteListJson = JSON.stringify(TOKEN_PALETTES);
|
|
400
|
+
export const themeInitScript = `(() => {try {
|
|
401
|
+
const STORAGE_KEY="noecosystem-theme",EXPLORER_KEY="theme",COOKIE_KEY="noecosystem-theme";
|
|
402
|
+
const PALETTE_KEY="${PALETTE_STORAGE_KEY}",PALETTE_COOKIE="${PALETTE_COOKIE_KEY}";
|
|
403
|
+
const PALETTES=${paletteListJson};
|
|
404
|
+
const isTheme=v=>v==="light"||v==="dark";
|
|
405
|
+
const isPalette=v=>PALETTES.includes(v);
|
|
406
|
+
const read=k=>{try{return localStorage.getItem(k)}catch{return null}};
|
|
407
|
+
const cookie=(k)=>{try{const p=k+"=";const e=document.cookie.split(";").map(s=>s.trim()).find(s=>s.startsWith(p));return e?decodeURIComponent(e.slice(p.length)):null}catch{return null}};
|
|
408
|
+
const sys=window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark";
|
|
409
|
+
let t=read(STORAGE_KEY); if(!isTheme(t)) t=cookie(COOKIE_KEY); if(!isTheme(t)) t=read(EXPLORER_KEY); if(!isTheme(t)) t=sys;
|
|
410
|
+
document.documentElement.dataset.theme=t;
|
|
411
|
+
document.documentElement.classList.toggle("light",t==="light");
|
|
412
|
+
document.documentElement.classList.toggle("dark",t==="dark");
|
|
413
|
+
document.documentElement.style.colorScheme=t;
|
|
414
|
+
let p=read(PALETTE_KEY); if(!isPalette(p)) p=cookie(PALETTE_COOKIE); if(!isPalette(p)) p=cookie("${PALETTE_COOKIE_KEY}"); if(!isPalette(p)) p="${DEFAULT_PALETTE}";
|
|
415
|
+
document.documentElement.setAttribute("data-noe-palette",p);
|
|
416
|
+
document.documentElement.dataset.noePalette=p;
|
|
417
|
+
} catch {}})();`;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { MoonIcon, SunIcon } from '@noe/icons';
|
|
2
|
+
import type * as React from 'react';
|
|
3
|
+
import { Button } from './button';
|
|
4
|
+
import { cn } from './lib/cn';
|
|
5
|
+
import { t } from './lib/i18n-messages';
|
|
6
|
+
import { useThemeSafe } from './theme-provider';
|
|
7
|
+
|
|
8
|
+
export interface ThemeToggleProps
|
|
9
|
+
extends Omit<
|
|
10
|
+
React.ComponentProps<typeof Button>,
|
|
11
|
+
'onClick' | 'type' | 'aria-label' | 'aria-pressed'
|
|
12
|
+
> {
|
|
13
|
+
/**
|
|
14
|
+
* Whether to show a text label next to the icon.
|
|
15
|
+
* When true, the button displays the current theme label.
|
|
16
|
+
*/
|
|
17
|
+
showLabel?: boolean;
|
|
18
|
+
/** Accessible label override — defaults to i18n-aware "Toggle theme" */
|
|
19
|
+
'aria-label'?: string;
|
|
20
|
+
/** Locale for i18n messages — defaults to en. Pass fa for Persian. */
|
|
21
|
+
locale?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* ThemeToggle — composes the canonical Button primitive.
|
|
26
|
+
*
|
|
27
|
+
* - Uses `useTheme()` for single-source-of-truth theme switching.
|
|
28
|
+
* - No raw button element; delegates keyboard/focus to Button.
|
|
29
|
+
* - Prevents prop spreading from overriding internal onClick/type/accessible name.
|
|
30
|
+
* - Labels are intended to come from i18n messages: theme.toggle.light / theme.toggle.dark.
|
|
31
|
+
* This component accepts an explicit aria-label but does not hardcode Persian/English inspection of document.lang.
|
|
32
|
+
* - Icons use the icons package (SunIcon/MoonIcon) rather than raw inline SVG.
|
|
33
|
+
* - showLabel is respected: when true, renders text; otherwise icon-only with sr-only label.
|
|
34
|
+
*/
|
|
35
|
+
export function ThemeToggle({
|
|
36
|
+
className,
|
|
37
|
+
showLabel = false,
|
|
38
|
+
variant = 'ghost',
|
|
39
|
+
size = 'icon',
|
|
40
|
+
'aria-label': ariaLabelProp,
|
|
41
|
+
locale,
|
|
42
|
+
...rest
|
|
43
|
+
}: ThemeToggleProps) {
|
|
44
|
+
const ctx = useThemeSafe();
|
|
45
|
+
// Single controller: ThemeProvider is the only writer to document/localStorage.
|
|
46
|
+
// Outside provider, we do not mutate storage — render fallback and no-op toggle (warn in dev).
|
|
47
|
+
const resolvedTheme: 'light' | 'dark' = ctx?.resolvedTheme ?? 'light';
|
|
48
|
+
const toggle =
|
|
49
|
+
ctx?.toggle ??
|
|
50
|
+
(() => {
|
|
51
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
52
|
+
console.warn(
|
|
53
|
+
'[ThemeToggle] rendered outside ThemeProvider — toggle is no-op. Wrap with ThemeProvider.',
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
const isLight = resolvedTheme === 'light';
|
|
58
|
+
|
|
59
|
+
// i18n-aware labels — via message layer, not document.lang; locale prop drives language.
|
|
60
|
+
const defaultLabel = isLight ? t(locale, 'theme.toggle.dark') : t(locale, 'theme.toggle.light');
|
|
61
|
+
const accessibleLabel = ariaLabelProp ?? defaultLabel;
|
|
62
|
+
const title = accessibleLabel;
|
|
63
|
+
const showLabelText = isLight
|
|
64
|
+
? t(locale, 'theme.preference.light')
|
|
65
|
+
: t(locale, 'theme.preference.dark');
|
|
66
|
+
|
|
67
|
+
const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {
|
|
68
|
+
e.preventDefault();
|
|
69
|
+
toggle();
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<Button
|
|
74
|
+
{...rest}
|
|
75
|
+
variant={variant}
|
|
76
|
+
size={showLabel ? 'sm' : size}
|
|
77
|
+
type={'button' as const}
|
|
78
|
+
aria-label={accessibleLabel}
|
|
79
|
+
title={title}
|
|
80
|
+
aria-pressed={isLight}
|
|
81
|
+
data-theme={resolvedTheme}
|
|
82
|
+
data-noecosystem-theme-toggle=""
|
|
83
|
+
className={cn('noe-theme-toggle', showLabel && 'gap-2 px-3', className)}
|
|
84
|
+
onClick={handleClick as never}
|
|
85
|
+
>
|
|
86
|
+
<span className="relative grid size-5 place-items-center" aria-hidden="true">
|
|
87
|
+
<SunIcon
|
|
88
|
+
className={cn(
|
|
89
|
+
'absolute size-5 transition-opacity',
|
|
90
|
+
isLight ? 'opacity-0' : 'opacity-100',
|
|
91
|
+
)}
|
|
92
|
+
/>
|
|
93
|
+
<MoonIcon
|
|
94
|
+
className={cn(
|
|
95
|
+
'absolute size-5 transition-opacity',
|
|
96
|
+
isLight ? 'opacity-100' : 'opacity-0',
|
|
97
|
+
)}
|
|
98
|
+
/>
|
|
99
|
+
</span>
|
|
100
|
+
{showLabel ? (
|
|
101
|
+
<span className="text-sm">{showLabelText}</span>
|
|
102
|
+
) : (
|
|
103
|
+
<span className="sr-only">{accessibleLabel}</span>
|
|
104
|
+
)}
|
|
105
|
+
</Button>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import { cn } from './lib/cn';
|
|
3
|
+
export interface ToggleProps extends React.ComponentProps<'button'> {
|
|
4
|
+
pressed?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export function Toggle({
|
|
7
|
+
className,
|
|
8
|
+
pressed,
|
|
9
|
+
children,
|
|
10
|
+
...props
|
|
11
|
+
}: ToggleProps & { 'aria-label'?: string }) {
|
|
12
|
+
const ariaLabel = (props as { 'aria-label'?: string })['aria-label'] ?? 'Toggle';
|
|
13
|
+
return (
|
|
14
|
+
<button
|
|
15
|
+
role="switch"
|
|
16
|
+
aria-checked={!!pressed}
|
|
17
|
+
aria-label={ariaLabel}
|
|
18
|
+
data-state={pressed ? 'on' : 'off'}
|
|
19
|
+
className={cn(
|
|
20
|
+
'inline-flex h-6 w-10 items-center rounded-pill border border-border bg-muted p-0.5 transition-colors data-[state=on]:bg-accent',
|
|
21
|
+
className,
|
|
22
|
+
)}
|
|
23
|
+
data-slot="toggle"
|
|
24
|
+
{...props}
|
|
25
|
+
>
|
|
26
|
+
<span
|
|
27
|
+
className={cn(
|
|
28
|
+
'size-5 rounded-pill bg-surface-raised shadow transition-transform',
|
|
29
|
+
pressed ? 'translate-x-4' : 'translate-x-0',
|
|
30
|
+
)}
|
|
31
|
+
/>
|
|
32
|
+
</button>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip';
|
|
2
|
+
import type * as React from 'react';
|
|
3
|
+
|
|
4
|
+
import { useDirection } from './direction';
|
|
5
|
+
import { cn } from './lib/cn';
|
|
6
|
+
|
|
7
|
+
export const Tooltip = TooltipPrimitive.Root;
|
|
8
|
+
export const TooltipProvider = TooltipPrimitive.Provider;
|
|
9
|
+
|
|
10
|
+
export function TooltipTrigger({
|
|
11
|
+
className,
|
|
12
|
+
...props
|
|
13
|
+
}: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {
|
|
14
|
+
return (
|
|
15
|
+
<TooltipPrimitive.Trigger className={cn(className)} data-slot="tooltip-trigger" {...props} />
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface TooltipPopupProps extends React.ComponentProps<typeof TooltipPrimitive.Popup> {
|
|
20
|
+
portalProps?: React.ComponentProps<typeof TooltipPrimitive.Portal>;
|
|
21
|
+
positionerProps?: React.ComponentProps<typeof TooltipPrimitive.Positioner>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function TooltipPopup({
|
|
25
|
+
className,
|
|
26
|
+
children,
|
|
27
|
+
portalProps,
|
|
28
|
+
positionerProps,
|
|
29
|
+
...props
|
|
30
|
+
}: TooltipPopupProps) {
|
|
31
|
+
const direction = useDirection();
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<TooltipPrimitive.Portal {...portalProps}>
|
|
35
|
+
<TooltipPrimitive.Positioner sideOffset={6} {...positionerProps}>
|
|
36
|
+
<TooltipPrimitive.Popup
|
|
37
|
+
className={cn(
|
|
38
|
+
'z-(--noe-z-index-overlay) max-w-64 rounded-md border border-border bg-foreground px-2.5 py-1.5 text-xs leading-normal text-background shadow-raised outline-none transition-[opacity,transform] duration-(--noe-motion-duration-fast) ease-standard data-[ending-style]:scale-95 data-[ending-style]:opacity-0 data-[starting-style]:scale-95 data-[starting-style]:opacity-0',
|
|
39
|
+
className,
|
|
40
|
+
)}
|
|
41
|
+
data-slot="tooltip-popup"
|
|
42
|
+
dir={direction}
|
|
43
|
+
{...props}
|
|
44
|
+
>
|
|
45
|
+
{children}
|
|
46
|
+
</TooltipPrimitive.Popup>
|
|
47
|
+
</TooltipPrimitive.Positioner>
|
|
48
|
+
</TooltipPrimitive.Portal>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import { cn } from './lib/cn';
|
|
3
|
+
export interface TreeViewProps extends React.ComponentProps<'div'> {
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
}
|
|
6
|
+
export function TreeView({ className, children, ...props }: TreeViewProps) {
|
|
7
|
+
return (
|
|
8
|
+
<div
|
|
9
|
+
className={cn(
|
|
10
|
+
'rounded-md border border-border bg-surface-raised p-4 text-sm text-foreground',
|
|
11
|
+
className,
|
|
12
|
+
)}
|
|
13
|
+
data-slot="tree-view"
|
|
14
|
+
{...props}
|
|
15
|
+
>
|
|
16
|
+
{children ?? 'Tree View'}
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Button, type ButtonProps } from './button';
|
|
2
|
+
import { cn } from './lib/cn';
|
|
3
|
+
|
|
4
|
+
export interface UtilityButtonProps extends Omit<ButtonProps, 'variant' | 'size'> {
|
|
5
|
+
/** Visual intent — maps to Button variants but constrained to utility-appropriate set */
|
|
6
|
+
variant?: 'quiet' | 'ghost' | 'outline' | 'secondary';
|
|
7
|
+
size?: 'sm' | 'md' | 'lg' | 'icon';
|
|
8
|
+
/** Accessible label required for icon-only usage */
|
|
9
|
+
'aria-label': string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* UtilityButton — narrow-crown toolbar/icon action.
|
|
14
|
+
* Composes canonical Button primitive (no second primitive).
|
|
15
|
+
* Use for: toolbar actions, row-level utilities, compact icon triggers.
|
|
16
|
+
* Do not use for: primary form submission, destructive confirmation (use Button variant destructive).
|
|
17
|
+
*/
|
|
18
|
+
export function UtilityButton({
|
|
19
|
+
className,
|
|
20
|
+
variant = 'ghost',
|
|
21
|
+
size = 'icon',
|
|
22
|
+
...props
|
|
23
|
+
}: UtilityButtonProps) {
|
|
24
|
+
return (
|
|
25
|
+
<Button
|
|
26
|
+
variant={variant}
|
|
27
|
+
size={size}
|
|
28
|
+
className={cn('shrink-0', className)}
|
|
29
|
+
data-slot="utility-button"
|
|
30
|
+
{...props}
|
|
31
|
+
/>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { cn, cn as cx } from './lib/cn';
|
|
2
|
+
|
|
3
|
+
export type LogicalSide = 'start' | 'end' | 'top' | 'bottom';
|
|
4
|
+
|
|
5
|
+
/** Converts a logical placement to the physical swipe direction required by Base UI. */
|
|
6
|
+
export function resolveLogicalSide(
|
|
7
|
+
side: LogicalSide,
|
|
8
|
+
direction: 'ltr' | 'rtl',
|
|
9
|
+
): 'left' | 'right' | 'top' | 'bottom' {
|
|
10
|
+
if (side === 'top' || side === 'bottom') return side;
|
|
11
|
+
if (side === 'start') return direction === 'rtl' ? 'right' : 'left';
|
|
12
|
+
return direction === 'rtl' ? 'left' : 'right';
|
|
13
|
+
}
|