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,103 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
fromCalendarDate,
|
|
5
|
+
getDaysInJalaliMonth,
|
|
6
|
+
getDaysInMonth,
|
|
7
|
+
getPersianYMD,
|
|
8
|
+
isJalaliLeapYear,
|
|
9
|
+
jalaliToDateUTC,
|
|
10
|
+
toCalendarDate,
|
|
11
|
+
} from './calendar-system';
|
|
12
|
+
|
|
13
|
+
describe('isJalaliLeapYear — Intl source of truth', () => {
|
|
14
|
+
test('1403 is leap (Esfand 30 exists), 1404 is not', () => {
|
|
15
|
+
expect(isJalaliLeapYear(1403)).toBe(true);
|
|
16
|
+
expect(getDaysInJalaliMonth(1403, 12)).toBe(30);
|
|
17
|
+
// 1403-12-30 should map to 2025-03-20
|
|
18
|
+
expect(jalaliToDateUTC(1403, 12, 30).toISOString()).toBe('2025-03-20T00:00:00.000Z');
|
|
19
|
+
expect(getPersianYMD(new Date('2025-03-20T00:00:00Z'))).toEqual({
|
|
20
|
+
year: 1403,
|
|
21
|
+
month: 12,
|
|
22
|
+
day: 30,
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
test('1404 is not leap', () => {
|
|
26
|
+
expect(isJalaliLeapYear(1404)).toBe(false);
|
|
27
|
+
expect(getDaysInJalaliMonth(1404, 12)).toBe(29);
|
|
28
|
+
expect(() => jalaliToDateUTC(1404, 12, 30)).toThrow();
|
|
29
|
+
expect(new Date('2026-03-20T00:00:00Z')).toEqual(jalaliToDateUTC(1404, 12, 29));
|
|
30
|
+
});
|
|
31
|
+
test('1400-1408 brute force via Intl', () => {
|
|
32
|
+
// Verify 1403 and 1408 are leap per Intl, others not in that window
|
|
33
|
+
expect(isJalaliLeapYear(1400)).toBe(false);
|
|
34
|
+
expect(isJalaliLeapYear(1401)).toBe(false);
|
|
35
|
+
expect(isJalaliLeapYear(1402)).toBe(false);
|
|
36
|
+
expect(isJalaliLeapYear(1408)).toBe(true);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe('Jalali round-trip', () => {
|
|
41
|
+
test('Date -> Persian YMD -> Date round-trip for range 2020-2030', () => {
|
|
42
|
+
for (let y = 2020; y <= 2030; y++) {
|
|
43
|
+
for (let m = 0; m < 12; m++) {
|
|
44
|
+
const d = new Date(Date.UTC(y, m, 15));
|
|
45
|
+
const ymd = toCalendarDate(d, 'persian');
|
|
46
|
+
const back = fromCalendarDate(ymd.year, ymd.month, ymd.day, 'persian');
|
|
47
|
+
expect(back.toISOString()).toBe(d.toISOString());
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
test('Gregorian round-trip', () => {
|
|
52
|
+
const d = new Date(Date.UTC(2025, 0, 15));
|
|
53
|
+
const ymd = toCalendarDate(d, 'gregory');
|
|
54
|
+
expect(ymd).toEqual({ year: 2025, month: 1, day: 15 });
|
|
55
|
+
expect(fromCalendarDate(2025, 1, 15, 'gregory').toISOString()).toBe(d.toISOString());
|
|
56
|
+
});
|
|
57
|
+
test('timezone/UTC: fromCalendarDate always UTC', () => {
|
|
58
|
+
const d = fromCalendarDate(1403, 12, 30, 'persian');
|
|
59
|
+
expect(d.getUTCHours()).toBe(0);
|
|
60
|
+
expect(d.getUTCMinutes()).toBe(0);
|
|
61
|
+
expect(d.getUTCSeconds()).toBe(0);
|
|
62
|
+
expect(d.toISOString()).toBe('2025-03-20T00:00:00.000Z');
|
|
63
|
+
});
|
|
64
|
+
test('getDaysInMonth gregorian vs jalali', () => {
|
|
65
|
+
expect(getDaysInMonth(2024, 2, 'gregory')).toBe(29); // leap
|
|
66
|
+
expect(getDaysInMonth(2025, 2, 'gregory')).toBe(28);
|
|
67
|
+
expect(getDaysInMonth(1403, 12, 'persian')).toBe(30);
|
|
68
|
+
expect(getDaysInMonth(1404, 12, 'persian')).toBe(29);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
describe('Calendar weekday offset', () => {
|
|
73
|
+
test('firstWeekday for Persian vs Gregorian uses known Gregorian weekday', () => {
|
|
74
|
+
// 2025-01-01 is Wednesday (UTCDay 3). For gregory calendar, firstWeekday = 3.
|
|
75
|
+
// For persian, same Gregorian date 2025-01-01 corresponds to 1403-10-12, but firstWeekday for a Persian month is (greg+1)%7
|
|
76
|
+
const gregJan1 = fromCalendarDate(2025, 1, 1, 'gregory');
|
|
77
|
+
expect(gregJan1.getUTCDay()).toBe(3); // Wednesday
|
|
78
|
+
expect(gregJan1.getUTCDay()).toBe(3);
|
|
79
|
+
const persianOffset = (gregJan1.getUTCDay() + 1) % 7;
|
|
80
|
+
expect(persianOffset).toBe(4); // Thursday column in Persian week (Sat=0)
|
|
81
|
+
// Verify 1403-12-01 = 2025-02-19 is Wednesday as well (UTCDay 3) -> persian offset 4
|
|
82
|
+
const first14031201 = fromCalendarDate(1403, 12, 1, 'persian');
|
|
83
|
+
expect(first14031201.getUTCDay()).toBe(3);
|
|
84
|
+
expect((first14031201.getUTCDay() + 1) % 7).toBe(4);
|
|
85
|
+
});
|
|
86
|
+
test('timezone: fromCalendarDate is UTC midnight and round-trips via UTC', () => {
|
|
87
|
+
const d = fromCalendarDate(1403, 12, 30, 'persian');
|
|
88
|
+
expect(d.toISOString()).toBe('2025-03-20T00:00:00.000Z');
|
|
89
|
+
expect(d.getUTCHours()).toBe(0);
|
|
90
|
+
expect(d.getUTCMinutes()).toBe(0);
|
|
91
|
+
// getPersianYMD is UTC-based, so local TZ does not shift date
|
|
92
|
+
const ymd = getPersianYMD(new Date('2025-03-20T12:00:00Z'));
|
|
93
|
+
expect(ymd).toEqual({ year: 1403, month: 12, day: 30 });
|
|
94
|
+
});
|
|
95
|
+
test('end of month: daysInMonth for all months and leap boundaries', () => {
|
|
96
|
+
// 1403 Esfand 30 exists, 1404 Esfand 29 is last
|
|
97
|
+
expect(getDaysInJalaliMonth(1403, 6)).toBe(31);
|
|
98
|
+
expect(getDaysInJalaliMonth(1403, 11)).toBe(30);
|
|
99
|
+
expect(getDaysInJalaliMonth(1403, 12)).toBe(30);
|
|
100
|
+
expect(getDaysInJalaliMonth(1404, 12)).toBe(29);
|
|
101
|
+
expect(getDaysInMonth(2024, 2, 'gregory')).toBe(29);
|
|
102
|
+
});
|
|
103
|
+
});
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calendar system abstraction — separated from locale formatting.
|
|
3
|
+
* Supports `gregory` (default) and `persian` (Jalali) via Intl `ca-*` and binary search.
|
|
4
|
+
* Adapted from injast-core `src/utils/dateHelpers.ts` and `WheelDatePicker.tsx` (Jalali logic),
|
|
5
|
+
* but decoupled from MUI and from locale formatters. Locale formatting (numbers, month names)
|
|
6
|
+
* is handled via `Intl.DateTimeFormat` with the consumer's locale, not the calendar system.
|
|
7
|
+
* Jalali support is extension-point: `calendar="persian"` is available, default is `gregory` unless locale `fa` opts in.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export type CalendarSystem = 'gregory' | 'persian';
|
|
11
|
+
|
|
12
|
+
const persianDateFormatter = new Intl.DateTimeFormat('en-US-u-ca-persian', {
|
|
13
|
+
year: 'numeric',
|
|
14
|
+
month: 'numeric',
|
|
15
|
+
day: 'numeric',
|
|
16
|
+
timeZone: 'UTC',
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export function getPersianYMD(date: Date): { year: number; month: number; day: number } {
|
|
20
|
+
const parts = persianDateFormatter.formatToParts(date);
|
|
21
|
+
const year = Number(parts.find((p) => p.type === 'year')?.value);
|
|
22
|
+
const month = Number(parts.find((p) => p.type === 'month')?.value);
|
|
23
|
+
const day = Number(parts.find((p) => p.type === 'day')?.value);
|
|
24
|
+
if (!year || !month || !day) throw new Error('Failed to parse Persian date');
|
|
25
|
+
return { year, month, day };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Convert Jalali (y,m,d) to JS Date (UTC) via binary search — no jalaali-js needed, uses Intl. */
|
|
29
|
+
export function jalaliToDateUTC(jy: number, jm: number, jd: number): Date {
|
|
30
|
+
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
31
|
+
const approxYear = jy + 621;
|
|
32
|
+
let lowDay = Math.floor(Date.UTC(approxYear - 2, 0, 1) / DAY_MS);
|
|
33
|
+
let highDay = Math.floor(Date.UTC(approxYear + 2, 11, 31) / DAY_MS);
|
|
34
|
+
while (lowDay <= highDay) {
|
|
35
|
+
const midDay = Math.floor((lowDay + highDay) / 2);
|
|
36
|
+
const midDate = new Date(midDay * DAY_MS);
|
|
37
|
+
const { year, month, day } = getPersianYMD(midDate);
|
|
38
|
+
if (year === jy && month === jm && day === jd) return midDate;
|
|
39
|
+
const isBefore =
|
|
40
|
+
year < jy || (year === jy && month < jm) || (year === jy && month === jm && day < jd);
|
|
41
|
+
if (isBefore) lowDay = midDay + 1;
|
|
42
|
+
else highDay = midDay - 1;
|
|
43
|
+
}
|
|
44
|
+
throw new Error('Invalid Jalali date');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Jalali leap year — derived from Intl `ca-persian` (source of truth), not approximate 128-year formula. */
|
|
48
|
+
export function isJalaliLeapYear(jy: number): boolean {
|
|
49
|
+
try {
|
|
50
|
+
const d = jalaliToDateUTC(jy, 12, 30);
|
|
51
|
+
const ymd = getPersianYMD(d);
|
|
52
|
+
return ymd.year === jy && ymd.month === 12 && ymd.day === 30;
|
|
53
|
+
} catch {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function getDaysInJalaliMonth(jy: number, jm: number): number {
|
|
59
|
+
if (jm <= 6) return 31;
|
|
60
|
+
if (jm <= 11) return 30;
|
|
61
|
+
return isJalaliLeapYear(jy) ? 30 : 29;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function getDaysInGregorianMonth(year: number, month: number): number {
|
|
65
|
+
return new Date(Date.UTC(year, month, 0)).getUTCDate();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function toCalendarDate(
|
|
69
|
+
date: Date,
|
|
70
|
+
calendar: CalendarSystem,
|
|
71
|
+
): { year: number; month: number; day: number } {
|
|
72
|
+
if (calendar === 'persian') return getPersianYMD(date);
|
|
73
|
+
return { year: date.getUTCFullYear(), month: date.getUTCMonth() + 1, day: date.getUTCDate() };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function fromCalendarDate(
|
|
77
|
+
year: number,
|
|
78
|
+
month: number,
|
|
79
|
+
day: number,
|
|
80
|
+
calendar: CalendarSystem,
|
|
81
|
+
): Date {
|
|
82
|
+
if (calendar === 'persian') return jalaliToDateUTC(year, month, day);
|
|
83
|
+
return new Date(Date.UTC(year, month - 1, day));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function getDaysInMonth(year: number, month: number, calendar: CalendarSystem): number {
|
|
87
|
+
return calendar === 'persian'
|
|
88
|
+
? getDaysInJalaliMonth(year, month)
|
|
89
|
+
: getDaysInGregorianMonth(year, month);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export const PERSIAN_MONTHS = [
|
|
93
|
+
{ value: 1, label: 'فروردین' },
|
|
94
|
+
{ value: 2, label: 'اردیبهشت' },
|
|
95
|
+
{ value: 3, label: 'خرداد' },
|
|
96
|
+
{ value: 4, label: 'تیر' },
|
|
97
|
+
{ value: 5, label: 'مرداد' },
|
|
98
|
+
{ value: 6, label: 'شهریور' },
|
|
99
|
+
{ value: 7, label: 'مهر' },
|
|
100
|
+
{ value: 8, label: 'آبان' },
|
|
101
|
+
{ value: 9, label: 'آذر' },
|
|
102
|
+
{ value: 10, label: 'دی' },
|
|
103
|
+
{ value: 11, label: 'بهمن' },
|
|
104
|
+
{ value: 12, label: 'اسفند' },
|
|
105
|
+
] as const;
|
|
106
|
+
|
|
107
|
+
export const GREGORIAN_MONTHS = [
|
|
108
|
+
{ value: 1, label: 'January' },
|
|
109
|
+
{ value: 2, label: 'February' },
|
|
110
|
+
{ value: 3, label: 'March' },
|
|
111
|
+
{ value: 4, label: 'April' },
|
|
112
|
+
{ value: 5, label: 'May' },
|
|
113
|
+
{ value: 6, label: 'June' },
|
|
114
|
+
{ value: 7, label: 'July' },
|
|
115
|
+
{ value: 8, label: 'August' },
|
|
116
|
+
{ value: 9, label: 'September' },
|
|
117
|
+
{ value: 10, label: 'October' },
|
|
118
|
+
{ value: 11, label: 'November' },
|
|
119
|
+
{ value: 12, label: 'December' },
|
|
120
|
+
] as const;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { expect, test } from 'vitest';
|
|
2
|
+
import { userEvent } from 'vitest/browser';
|
|
3
|
+
import { render } from 'vitest-browser-react';
|
|
4
|
+
|
|
5
|
+
import { Calendar } from './calendar';
|
|
6
|
+
|
|
7
|
+
test('Calendar keyboard navigation stays scoped when two calendars are mounted', async () => {
|
|
8
|
+
await render(
|
|
9
|
+
<div>
|
|
10
|
+
<div data-testid="cal1">
|
|
11
|
+
<Calendar value={new Date('2025-03-15T00:00:00Z')} onValueChange={() => {}} />
|
|
12
|
+
</div>
|
|
13
|
+
<div data-testid="cal2">
|
|
14
|
+
<Calendar value={new Date('2025-03-15T00:00:00Z')} onValueChange={() => {}} />
|
|
15
|
+
</div>
|
|
16
|
+
</div>,
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const cal1 = document.querySelector('[data-testid="cal1"]') as HTMLElement;
|
|
20
|
+
const cal2 = document.querySelector('[data-testid="cal2"]') as HTMLElement;
|
|
21
|
+
const day15Cal1 = cal1.querySelector('[data-day="15"]') as HTMLButtonElement;
|
|
22
|
+
const day16Cal1 = cal1.querySelector('[data-day="16"]') as HTMLButtonElement;
|
|
23
|
+
const day16Cal2 = cal2.querySelector('[data-day="16"]') as HTMLButtonElement;
|
|
24
|
+
|
|
25
|
+
expect(day15Cal1).toBeTruthy();
|
|
26
|
+
expect(day16Cal1).toBeTruthy();
|
|
27
|
+
day15Cal1.focus();
|
|
28
|
+
await expect.element(day15Cal1).toHaveFocus();
|
|
29
|
+
|
|
30
|
+
await userEvent.keyboard('{ArrowRight}');
|
|
31
|
+
|
|
32
|
+
await expect.element(day16Cal1).toHaveFocus();
|
|
33
|
+
expect(document.activeElement).not.toBe(day16Cal2);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test('Calendar respects min/max — out-of-range days are disabled', async () => {
|
|
37
|
+
await render(
|
|
38
|
+
<Calendar
|
|
39
|
+
value={new Date('2025-03-15T00:00:00Z')}
|
|
40
|
+
min={new Date('2025-03-10T00:00:00Z')}
|
|
41
|
+
max={new Date('2025-03-20T00:00:00Z')}
|
|
42
|
+
/>,
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const day9 = document.querySelector('[data-day="9"]') as HTMLButtonElement | null;
|
|
46
|
+
const day10 = document.querySelector('[data-day="10"]') as HTMLButtonElement;
|
|
47
|
+
const day21 = document.querySelector('[data-day="21"]') as HTMLButtonElement | null;
|
|
48
|
+
|
|
49
|
+
if (day9) await expect.element(day9).toBeDisabled();
|
|
50
|
+
await expect.element(day10).not.toBeDisabled();
|
|
51
|
+
if (day21) await expect.element(day21).toBeDisabled();
|
|
52
|
+
});
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import { ChevronIcon } from '@noe/icons';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Button } from './button';
|
|
4
|
+
import {
|
|
5
|
+
type CalendarSystem,
|
|
6
|
+
fromCalendarDate,
|
|
7
|
+
getDaysInMonth,
|
|
8
|
+
PERSIAN_MONTHS,
|
|
9
|
+
toCalendarDate,
|
|
10
|
+
} from './calendar-system';
|
|
11
|
+
import { cn } from './lib/cn';
|
|
12
|
+
import { t } from './lib/i18n-messages';
|
|
13
|
+
|
|
14
|
+
export type { CalendarSystem };
|
|
15
|
+
|
|
16
|
+
export interface CalendarProps
|
|
17
|
+
extends Omit<React.ComponentProps<'div'>, 'onChange' | 'defaultValue'> {
|
|
18
|
+
calendar?: CalendarSystem;
|
|
19
|
+
value?: Date | null;
|
|
20
|
+
defaultValue?: Date | null;
|
|
21
|
+
onValueChange?: (date: Date | null) => void;
|
|
22
|
+
locale?: string | undefined;
|
|
23
|
+
min?: Date | null | undefined;
|
|
24
|
+
max?: Date | null | undefined;
|
|
25
|
+
/** i18n labels */
|
|
26
|
+
labels?: {
|
|
27
|
+
previousMonth?: string;
|
|
28
|
+
nextMonth?: string;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Calendar — month grid with navigation, calendar-system abstraction (gregory/persian).
|
|
34
|
+
* Calendar system (year/month/day) is separate from locale formatting (month names, numbers).
|
|
35
|
+
* Jalali logic is from injast-core (Intl ca-persian + binary search), no jalaali-js dep.
|
|
36
|
+
* Tokenized, RTL-safe (logical gap, `dir` propagation), keyboard navigable, respects reduced-motion.
|
|
37
|
+
* Semantics: uses <table> with <thead>/<tbody> to satisfy a11y and avoid hydration mismatches.
|
|
38
|
+
*/
|
|
39
|
+
export function Calendar({
|
|
40
|
+
calendar = 'gregory',
|
|
41
|
+
value,
|
|
42
|
+
defaultValue,
|
|
43
|
+
onValueChange,
|
|
44
|
+
locale,
|
|
45
|
+
min,
|
|
46
|
+
max,
|
|
47
|
+
labels,
|
|
48
|
+
className,
|
|
49
|
+
...props
|
|
50
|
+
}: CalendarProps) {
|
|
51
|
+
const isControlled = value !== undefined;
|
|
52
|
+
const [internal, setInternal] = React.useState<Date | null>(defaultValue ?? null);
|
|
53
|
+
const selected = isControlled ? (value ?? null) : internal;
|
|
54
|
+
|
|
55
|
+
const today = React.useMemo(() => new Date(), []);
|
|
56
|
+
const initial = selected ?? today;
|
|
57
|
+
const initialCal = toCalendarDate(initial, calendar);
|
|
58
|
+
const [viewYear, setViewYear] = React.useState(initialCal.year);
|
|
59
|
+
const [viewMonth, setViewMonth] = React.useState(initialCal.month);
|
|
60
|
+
|
|
61
|
+
React.useEffect(() => {
|
|
62
|
+
if (selected) {
|
|
63
|
+
const cal = toCalendarDate(selected, calendar);
|
|
64
|
+
setViewYear(cal.year);
|
|
65
|
+
setViewMonth(cal.month);
|
|
66
|
+
}
|
|
67
|
+
}, [selected, calendar]);
|
|
68
|
+
|
|
69
|
+
const daysInMonth = getDaysInMonth(viewYear, viewMonth, calendar);
|
|
70
|
+
const firstDayDate = fromCalendarDate(viewYear, viewMonth, 1, calendar);
|
|
71
|
+
const gregWeekday = firstDayDate.getUTCDay(); // 0=Sun
|
|
72
|
+
// Persian week starts Saturday. Gregorian starts Sunday.
|
|
73
|
+
const firstWeekday = calendar === 'persian' ? (gregWeekday + 1) % 7 : gregWeekday;
|
|
74
|
+
|
|
75
|
+
const monthLabel =
|
|
76
|
+
calendar === 'persian'
|
|
77
|
+
? (PERSIAN_MONTHS.find((m) => m.value === viewMonth)?.label ?? String(viewMonth))
|
|
78
|
+
: new Intl.DateTimeFormat(locale ?? 'en-US', { month: 'long', timeZone: 'UTC' }).format(
|
|
79
|
+
new Date(Date.UTC(viewYear, viewMonth - 1, 1)),
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const yearLabel = new Intl.NumberFormat(
|
|
83
|
+
locale ?? (calendar === 'persian' ? 'fa-IR' : 'en-US'),
|
|
84
|
+
).format(viewYear);
|
|
85
|
+
|
|
86
|
+
const canPrev = React.useMemo(() => {
|
|
87
|
+
if (!min) return true;
|
|
88
|
+
const prevMonth = viewMonth === 1 ? 12 : viewMonth - 1;
|
|
89
|
+
const prevYear = viewMonth === 1 ? viewYear - 1 : viewYear;
|
|
90
|
+
const lastDay = getDaysInMonth(prevYear, prevMonth, calendar);
|
|
91
|
+
const prevDate = fromCalendarDate(prevYear, prevMonth, lastDay, calendar);
|
|
92
|
+
return prevDate >= min;
|
|
93
|
+
}, [min, viewMonth, viewYear, calendar]);
|
|
94
|
+
|
|
95
|
+
const canNext = React.useMemo(() => {
|
|
96
|
+
if (!max) return true;
|
|
97
|
+
const nextMonth = viewMonth === 12 ? 1 : viewMonth + 1;
|
|
98
|
+
const nextYear = viewMonth === 12 ? viewYear + 1 : viewYear;
|
|
99
|
+
const nextDate = fromCalendarDate(nextYear, nextMonth, 1, calendar);
|
|
100
|
+
return nextDate <= max;
|
|
101
|
+
}, [max, viewMonth, viewYear, calendar]);
|
|
102
|
+
|
|
103
|
+
const onPrev = () => {
|
|
104
|
+
if (!canPrev) return;
|
|
105
|
+
if (viewMonth === 1) {
|
|
106
|
+
setViewYear((y) => y - 1);
|
|
107
|
+
setViewMonth(12);
|
|
108
|
+
} else setViewMonth((m) => m - 1);
|
|
109
|
+
};
|
|
110
|
+
const onNext = () => {
|
|
111
|
+
if (!canNext) return;
|
|
112
|
+
if (viewMonth === 12) {
|
|
113
|
+
setViewYear((y) => y + 1);
|
|
114
|
+
setViewMonth(1);
|
|
115
|
+
} else setViewMonth((m) => m + 1);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const onSelect = (day: number) => {
|
|
119
|
+
const date = fromCalendarDate(viewYear, viewMonth, day, calendar);
|
|
120
|
+
if (min && date < min) return;
|
|
121
|
+
if (max && date > max) return;
|
|
122
|
+
if (!isControlled) setInternal(date);
|
|
123
|
+
onValueChange?.(date);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const weekdays =
|
|
127
|
+
locale?.startsWith('fa') || calendar === 'persian'
|
|
128
|
+
? ['ش', 'ی', 'د', 'س', 'چ', 'پ', 'ج']
|
|
129
|
+
: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];
|
|
130
|
+
|
|
131
|
+
// Build weeks: array of 7-cell rows
|
|
132
|
+
const weeks: (number | null)[][] = [];
|
|
133
|
+
let day = 1;
|
|
134
|
+
for (let w = 0; w < 6; w++) {
|
|
135
|
+
const week: (number | null)[] = [];
|
|
136
|
+
for (let c = 0; c < 7; c++) {
|
|
137
|
+
const cellIndex = w * 7 + c;
|
|
138
|
+
if (cellIndex < firstWeekday || day > daysInMonth) week.push(null);
|
|
139
|
+
else {
|
|
140
|
+
week.push(day);
|
|
141
|
+
day++;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
weeks.push(week);
|
|
145
|
+
if (day > daysInMonth) break;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const prevLabel = labels?.previousMonth ?? t(locale, 'calendar.previousMonth');
|
|
149
|
+
const nextLabel = labels?.nextMonth ?? t(locale, 'calendar.nextMonth');
|
|
150
|
+
const tableRef = React.useRef<HTMLTableElement>(null);
|
|
151
|
+
|
|
152
|
+
// Roving tabindex: focus selected day, else today, else first day
|
|
153
|
+
const getTabIndex = (d: number) => {
|
|
154
|
+
if (selected) {
|
|
155
|
+
const cal = toCalendarDate(selected, calendar);
|
|
156
|
+
if (cal.year === viewYear && cal.month === viewMonth && cal.day === d) return 0;
|
|
157
|
+
}
|
|
158
|
+
const t = toCalendarDate(today, calendar);
|
|
159
|
+
if (t.year === viewYear && t.month === viewMonth && t.day === d) return 0;
|
|
160
|
+
if (!selected && t.year !== viewYear) return d === 1 ? 0 : -1;
|
|
161
|
+
return -1;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
const handleKeyDown: React.KeyboardEventHandler<HTMLTableElement> = (e) => {
|
|
165
|
+
const active = document.activeElement as HTMLElement | null;
|
|
166
|
+
const currentDay = active?.getAttribute('data-day');
|
|
167
|
+
if (!currentDay) return;
|
|
168
|
+
const d = Number(currentDay);
|
|
169
|
+
if (Number.isNaN(d)) return;
|
|
170
|
+
let targetDay: number | null = null;
|
|
171
|
+
let targetMonth = viewMonth;
|
|
172
|
+
let targetYear = viewYear;
|
|
173
|
+
switch (e.key) {
|
|
174
|
+
case 'ArrowRight':
|
|
175
|
+
e.preventDefault();
|
|
176
|
+
targetDay = d + 1;
|
|
177
|
+
break;
|
|
178
|
+
case 'ArrowLeft':
|
|
179
|
+
e.preventDefault();
|
|
180
|
+
targetDay = d - 1;
|
|
181
|
+
break;
|
|
182
|
+
case 'ArrowUp':
|
|
183
|
+
e.preventDefault();
|
|
184
|
+
targetDay = d - 7;
|
|
185
|
+
break;
|
|
186
|
+
case 'ArrowDown':
|
|
187
|
+
e.preventDefault();
|
|
188
|
+
targetDay = d + 7;
|
|
189
|
+
break;
|
|
190
|
+
case 'Home':
|
|
191
|
+
e.preventDefault();
|
|
192
|
+
targetDay = 1;
|
|
193
|
+
break;
|
|
194
|
+
case 'End':
|
|
195
|
+
e.preventDefault();
|
|
196
|
+
targetDay = daysInMonth;
|
|
197
|
+
break;
|
|
198
|
+
case 'PageUp':
|
|
199
|
+
e.preventDefault();
|
|
200
|
+
if (viewMonth === 1) {
|
|
201
|
+
targetYear = viewYear - 1;
|
|
202
|
+
targetMonth = 12;
|
|
203
|
+
} else targetMonth = viewMonth - 1;
|
|
204
|
+
break;
|
|
205
|
+
case 'PageDown':
|
|
206
|
+
e.preventDefault();
|
|
207
|
+
if (viewMonth === 12) {
|
|
208
|
+
targetYear = viewYear + 1;
|
|
209
|
+
targetMonth = 1;
|
|
210
|
+
} else targetMonth = viewMonth + 1;
|
|
211
|
+
break;
|
|
212
|
+
default:
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
if (e.key === 'PageUp' || e.key === 'PageDown') {
|
|
216
|
+
if (targetMonth !== viewMonth || targetYear !== viewYear) {
|
|
217
|
+
setViewYear(targetYear);
|
|
218
|
+
setViewMonth(targetMonth);
|
|
219
|
+
}
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
if (targetDay !== null) {
|
|
223
|
+
if (targetDay < 1 || targetDay > daysInMonth) {
|
|
224
|
+
// navigate to adjacent month
|
|
225
|
+
if (targetDay < 1 && canPrev) onPrev();
|
|
226
|
+
else if (targetDay > daysInMonth && canNext) onNext();
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
const scope = tableRef.current ?? document;
|
|
230
|
+
const nextBtn = scope.querySelector<HTMLButtonElement>(`[data-day="${targetDay}"]`);
|
|
231
|
+
nextBtn?.focus();
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
return (
|
|
236
|
+
<div
|
|
237
|
+
className={cn(
|
|
238
|
+
'w-[18rem] rounded-md border border-border bg-surface-raised p-3 shadow-raised',
|
|
239
|
+
className,
|
|
240
|
+
)}
|
|
241
|
+
data-slot="calendar"
|
|
242
|
+
data-calendar={calendar}
|
|
243
|
+
{...props}
|
|
244
|
+
>
|
|
245
|
+
<div className="mb-3 flex items-center justify-between gap-2">
|
|
246
|
+
<Button
|
|
247
|
+
variant="ghost"
|
|
248
|
+
size="icon"
|
|
249
|
+
aria-label={prevLabel}
|
|
250
|
+
disabled={!canPrev}
|
|
251
|
+
onClick={onPrev}
|
|
252
|
+
>
|
|
253
|
+
<ChevronIcon direction="backward" className="size-4" />
|
|
254
|
+
</Button>
|
|
255
|
+
<div className="text-sm font-medium text-foreground" dir="auto">
|
|
256
|
+
{monthLabel} {yearLabel}
|
|
257
|
+
</div>
|
|
258
|
+
<Button
|
|
259
|
+
variant="ghost"
|
|
260
|
+
size="icon"
|
|
261
|
+
aria-label={nextLabel}
|
|
262
|
+
disabled={!canNext}
|
|
263
|
+
onClick={onNext}
|
|
264
|
+
>
|
|
265
|
+
<ChevronIcon direction="forward" className="size-4" />
|
|
266
|
+
</Button>
|
|
267
|
+
</div>
|
|
268
|
+
<table
|
|
269
|
+
ref={tableRef}
|
|
270
|
+
aria-label={`${monthLabel} ${yearLabel}`}
|
|
271
|
+
className="w-full border-collapse"
|
|
272
|
+
onKeyDown={handleKeyDown}
|
|
273
|
+
>
|
|
274
|
+
<thead>
|
|
275
|
+
<tr className="grid grid-cols-7 gap-1">
|
|
276
|
+
{weekdays.map((d) => (
|
|
277
|
+
<th
|
|
278
|
+
key={d}
|
|
279
|
+
scope="col"
|
|
280
|
+
className="py-1 text-center text-xs font-medium text-muted-foreground"
|
|
281
|
+
>
|
|
282
|
+
{d}
|
|
283
|
+
</th>
|
|
284
|
+
))}
|
|
285
|
+
</tr>
|
|
286
|
+
</thead>
|
|
287
|
+
<tbody className="flex flex-col gap-1">
|
|
288
|
+
{weeks.map((week, wi) => (
|
|
289
|
+
<tr key={`week-${wi}`} className="grid grid-cols-7 gap-1">
|
|
290
|
+
{week.map((d, ci) =>
|
|
291
|
+
d === null ? (
|
|
292
|
+
<td key={`empty-${wi}-${ci}`} aria-hidden="true" />
|
|
293
|
+
) : (
|
|
294
|
+
(() => {
|
|
295
|
+
const date = fromCalendarDate(viewYear, viewMonth, d, calendar);
|
|
296
|
+
const calSelected = selected ? toCalendarDate(selected, calendar) : null;
|
|
297
|
+
const isSelected =
|
|
298
|
+
!!calSelected &&
|
|
299
|
+
calSelected.year === viewYear &&
|
|
300
|
+
calSelected.month === viewMonth &&
|
|
301
|
+
calSelected.day === d;
|
|
302
|
+
const t = toCalendarDate(today, calendar);
|
|
303
|
+
const isToday = t.year === viewYear && t.month === viewMonth && t.day === d;
|
|
304
|
+
const disabled = (min && date < min) || (max && date > max) || false;
|
|
305
|
+
return (
|
|
306
|
+
<td key={d} className="flex justify-center">
|
|
307
|
+
<button
|
|
308
|
+
type="button"
|
|
309
|
+
data-day={d}
|
|
310
|
+
tabIndex={getTabIndex(d)}
|
|
311
|
+
aria-pressed={isSelected}
|
|
312
|
+
aria-current={isToday ? 'date' : undefined}
|
|
313
|
+
disabled={Boolean(disabled)}
|
|
314
|
+
onClick={() => onSelect(d)}
|
|
315
|
+
className={cn(
|
|
316
|
+
'flex size-8 items-center justify-center rounded-md text-sm tabular-nums focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-ring disabled:opacity-30',
|
|
317
|
+
isSelected
|
|
318
|
+
? 'bg-accent text-accent-foreground'
|
|
319
|
+
: isToday
|
|
320
|
+
? 'border border-accent text-accent'
|
|
321
|
+
: 'text-foreground hover:bg-muted',
|
|
322
|
+
)}
|
|
323
|
+
>
|
|
324
|
+
{new Intl.NumberFormat(
|
|
325
|
+
locale ?? (calendar === 'persian' ? 'fa-IR' : 'en-US'),
|
|
326
|
+
).format(d)}
|
|
327
|
+
</button>
|
|
328
|
+
</td>
|
|
329
|
+
);
|
|
330
|
+
})()
|
|
331
|
+
),
|
|
332
|
+
)}
|
|
333
|
+
</tr>
|
|
334
|
+
))}
|
|
335
|
+
</tbody>
|
|
336
|
+
</table>
|
|
337
|
+
</div>
|
|
338
|
+
);
|
|
339
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { cn } from './lib/cn';
|
|
4
|
+
|
|
5
|
+
export function Card({ className, ...props }: React.ComponentProps<'section'>) {
|
|
6
|
+
return (
|
|
7
|
+
<section
|
|
8
|
+
className={cn(
|
|
9
|
+
'flex flex-col overflow-hidden rounded-lg border border-border bg-surface-raised text-foreground',
|
|
10
|
+
className,
|
|
11
|
+
)}
|
|
12
|
+
data-slot="card"
|
|
13
|
+
{...props}
|
|
14
|
+
/>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function CardHeader({ className, ...props }: React.ComponentProps<'header'>) {
|
|
19
|
+
return (
|
|
20
|
+
<header
|
|
21
|
+
className={cn('flex flex-col gap-2 px-6 pt-6', className)}
|
|
22
|
+
data-slot="card-header"
|
|
23
|
+
{...props}
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function CardTitle({ className, ...props }: React.ComponentProps<'h3'>) {
|
|
29
|
+
return (
|
|
30
|
+
<h3
|
|
31
|
+
className={cn('font-heading text-lg font-semibold leading-snug tracking-tight', className)}
|
|
32
|
+
data-slot="card-title"
|
|
33
|
+
{...props}
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function CardDescription({ className, ...props }: React.ComponentProps<'p'>) {
|
|
39
|
+
return (
|
|
40
|
+
<p
|
|
41
|
+
className={cn('m-0 text-sm leading-normal text-muted-foreground', className)}
|
|
42
|
+
data-slot="card-description"
|
|
43
|
+
{...props}
|
|
44
|
+
/>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function CardPanel({ className, ...props }: React.ComponentProps<'div'>) {
|
|
49
|
+
return <div className={cn('px-6 py-5', className)} data-slot="card-panel" {...props} />;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function CardFooter({ className, ...props }: React.ComponentProps<'footer'>) {
|
|
53
|
+
return (
|
|
54
|
+
<footer
|
|
55
|
+
className={cn(
|
|
56
|
+
'flex items-center gap-2 border-t border-border bg-surface-sunken/50 px-6 py-4',
|
|
57
|
+
className,
|
|
58
|
+
)}
|
|
59
|
+
data-slot="card-footer"
|
|
60
|
+
{...props}
|
|
61
|
+
/>
|
|
62
|
+
);
|
|
63
|
+
}
|