@vamos-ui/react 0.0.0-stage → 0.3.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/LICENSE +21 -0
- package/README.md +27 -2
- package/dist/blocks/block-heading.d.ts +29 -0
- package/dist/blocks/block-heading.js +39 -0
- package/dist/blocks/block-image.d.ts +52 -0
- package/dist/blocks/block-image.js +48 -0
- package/dist/blocks/block-link.d.ts +30 -0
- package/dist/blocks/block-link.js +36 -0
- package/dist/blocks/create-blocks.d.ts +54 -0
- package/dist/blocks/create-blocks.js +52 -0
- package/dist/blocks/index.d.ts +55 -0
- package/dist/blocks/index.js +59 -0
- package/dist/blocks/json-ld.d.ts +18 -0
- package/dist/blocks/json-ld.js +44 -0
- package/dist/blocks/labels.d.ts +20 -0
- package/dist/blocks/labels.js +43 -0
- package/dist/blocks/rich-text.d.ts +36 -0
- package/dist/blocks/rich-text.js +106 -0
- package/dist/blocks/schema/define-block.d.ts +151 -0
- package/dist/blocks/schema/define-block.js +120 -0
- package/dist/blocks/schema/emphasis.d.ts +17 -0
- package/dist/blocks/schema/emphasis.js +69 -0
- package/dist/blocks/schema/fields.d.ts +497 -0
- package/dist/blocks/schema/fields.js +240 -0
- package/dist/blocks/schema/icons.d.ts +2 -0
- package/dist/blocks/schema/icons.js +26 -0
- package/dist/blocks/schema/index.d.ts +18 -0
- package/dist/blocks/schema/index.js +21 -0
- package/dist/blocks/schema/lint-types.d.ts +16 -0
- package/dist/blocks/schema/lint-types.js +2 -0
- package/dist/blocks/schema/lint.d.ts +32 -0
- package/dist/blocks/schema/lint.js +164 -0
- package/dist/blocks/schema/localize.d.ts +20 -0
- package/dist/blocks/schema/localize.js +29 -0
- package/dist/blocks/schema/localized.d.ts +25 -0
- package/dist/blocks/schema/localized.js +53 -0
- package/dist/blocks/schema/migrate.d.ts +24 -0
- package/dist/blocks/schema/migrate.js +75 -0
- package/dist/blocks/schema/nodes.d.ts +196 -0
- package/dist/blocks/schema/nodes.js +78 -0
- package/dist/blocks/schema/rich-doc-schema.d.ts +32 -0
- package/dist/blocks/schema/rich-doc-schema.js +66 -0
- package/dist/blocks/schema/rich-doc.d.ts +90 -0
- package/dist/blocks/schema/rich-doc.js +62 -0
- package/dist/blocks/schema/safety.d.ts +20 -0
- package/dist/blocks/schema/safety.js +49 -0
- package/dist/blocks/schema/types.d.ts +172 -0
- package/dist/blocks/schema/types.js +3 -0
- package/dist/blocks/schema/validate.d.ts +17 -0
- package/dist/blocks/schema/validate.js +32 -0
- package/dist/blocks/schema/walk.d.ts +22 -0
- package/dist/blocks/schema/walk.js +60 -0
- package/dist/blocks/section-header.d.ts +38 -0
- package/dist/blocks/section-header.js +22 -0
- package/dist/blocks/section.d.ts +59 -0
- package/dist/blocks/section.js +66 -0
- package/dist/blocks/site/_kit-1.d.ts +101 -0
- package/dist/blocks/site/_kit-1.js +137 -0
- package/dist/blocks/site/_site-icon-1.d.ts +6 -0
- package/dist/blocks/site/_site-icon-1.js +15 -0
- package/dist/blocks/site/announcement-bar.d.ts +42 -0
- package/dist/blocks/site/announcement-bar.js +38 -0
- package/dist/blocks/site/announcement-dismiss.d.ts +18 -0
- package/dist/blocks/site/announcement-dismiss.js +28 -0
- package/dist/blocks/site/article-layout.d.ts +65 -0
- package/dist/blocks/site/article-layout.js +88 -0
- package/dist/blocks/site/blog-list.d.ts +79 -0
- package/dist/blocks/site/blog-list.js +78 -0
- package/dist/blocks/site/comparison-table.d.ts +54 -0
- package/dist/blocks/site/comparison-table.js +38 -0
- package/dist/blocks/site/consent-banner.d.ts +52 -0
- package/dist/blocks/site/consent-banner.js +33 -0
- package/dist/blocks/site/contact-dock.d.ts +52 -0
- package/dist/blocks/site/contact-dock.js +55 -0
- package/dist/blocks/site/contact-form.d.ts +60 -0
- package/dist/blocks/site/contact-form.js +45 -0
- package/dist/blocks/site/cta-booking.d.ts +43 -0
- package/dist/blocks/site/cta-booking.js +69 -0
- package/dist/blocks/site/cta.d.ts +74 -0
- package/dist/blocks/site/cta.js +113 -0
- package/dist/blocks/site/embed-facade.d.ts +20 -0
- package/dist/blocks/site/embed-facade.js +21 -0
- package/dist/blocks/site/faq.d.ts +48 -0
- package/dist/blocks/site/faq.js +52 -0
- package/dist/blocks/site/feature-grid.d.ts +46 -0
- package/dist/blocks/site/feature-grid.js +50 -0
- package/dist/blocks/site/feature-tabs.d.ts +22 -0
- package/dist/blocks/site/feature-tabs.js +11 -0
- package/dist/blocks/site/footer.d.ts +68 -0
- package/dist/blocks/site/footer.js +61 -0
- package/dist/blocks/site/gallery-section.d.ts +42 -0
- package/dist/blocks/site/gallery-section.js +48 -0
- package/dist/blocks/site/hero-video.d.ts +15 -0
- package/dist/blocks/site/hero-video.js +31 -0
- package/dist/blocks/site/hero.d.ts +64 -0
- package/dist/blocks/site/hero.js +73 -0
- package/dist/blocks/site/logo-strip.d.ts +44 -0
- package/dist/blocks/site/logo-strip.js +27 -0
- package/dist/blocks/site/map-hours.d.ts +83 -0
- package/dist/blocks/site/map-hours.js +125 -0
- package/dist/blocks/site/media-text.d.ts +45 -0
- package/dist/blocks/site/media-text.js +56 -0
- package/dist/blocks/site/menu-list.d.ts +74 -0
- package/dist/blocks/site/menu-list.js +84 -0
- package/dist/blocks/site/navbar-submenu.d.ts +18 -0
- package/dist/blocks/site/navbar-submenu.js +51 -0
- package/dist/blocks/site/navbar.d.ts +67 -0
- package/dist/blocks/site/navbar.js +64 -0
- package/dist/blocks/site/not-found.d.ts +40 -0
- package/dist/blocks/site/not-found.js +38 -0
- package/dist/blocks/site/page-intro.d.ts +46 -0
- package/dist/blocks/site/page-intro.js +44 -0
- package/dist/blocks/site/pricing-table.d.ts +67 -0
- package/dist/blocks/site/pricing-table.js +83 -0
- package/dist/blocks/site/process.d.ts +36 -0
- package/dist/blocks/site/process.js +42 -0
- package/dist/blocks/site/registry-1.d.ts +720 -0
- package/dist/blocks/site/registry-1.js +783 -0
- package/dist/blocks/site/registry-2.d.ts +914 -0
- package/dist/blocks/site/registry-2.js +563 -0
- package/dist/blocks/site/rich-text-section.d.ts +34 -0
- package/dist/blocks/site/rich-text-section.js +32 -0
- package/dist/blocks/site/shared/brand-icons.d.ts +21 -0
- package/dist/blocks/site/shared/brand-icons.js +56 -0
- package/dist/blocks/site/shared/consent-gate.d.ts +41 -0
- package/dist/blocks/site/shared/consent-gate.js +43 -0
- package/dist/blocks/site/shared/consent-island.d.ts +38 -0
- package/dist/blocks/site/shared/consent-island.js +63 -0
- package/dist/blocks/site/shared/consent.d.ts +49 -0
- package/dist/blocks/site/shared/consent.js +130 -0
- package/dist/blocks/site/shared/contact-form-island.d.ts +41 -0
- package/dist/blocks/site/shared/contact-form-island.js +100 -0
- package/dist/blocks/site/shared/copy-link.d.ts +10 -0
- package/dist/blocks/site/shared/copy-link.js +25 -0
- package/dist/blocks/site/shared/dock-avoid.d.ts +15 -0
- package/dist/blocks/site/shared/dock-avoid.js +107 -0
- package/dist/blocks/site/shared/dock-hours.d.ts +13 -0
- package/dist/blocks/site/shared/dock-hours.js +25 -0
- package/dist/blocks/site/shared/gallery-lightbox.d.ts +12 -0
- package/dist/blocks/site/shared/gallery-lightbox.js +10 -0
- package/dist/blocks/site/shared/island-keys.d.ts +10 -0
- package/dist/blocks/site/shared/island-keys.js +44 -0
- package/dist/blocks/site/shared/kit-2.d.ts +55 -0
- package/dist/blocks/site/shared/kit-2.js +84 -0
- package/dist/blocks/site/shared/labels-2.d.ts +209 -0
- package/dist/blocks/site/shared/labels-2.js +427 -0
- package/dist/blocks/site/shared/open-now.d.ts +22 -0
- package/dist/blocks/site/shared/open-now.js +27 -0
- package/dist/blocks/site/shared/opening-hours.d.ts +117 -0
- package/dist/blocks/site/shared/opening-hours.js +245 -0
- package/dist/blocks/site/shared/site-accent.d.ts +48 -0
- package/dist/blocks/site/shared/site-accent.js +249 -0
- package/dist/blocks/site/shared/site-form.d.ts +79 -0
- package/dist/blocks/site/shared/site-form.js +111 -0
- package/dist/blocks/site/shared/site-routing.d.ts +54 -0
- package/dist/blocks/site/shared/site-routing.js +86 -0
- package/dist/blocks/site/shared/testimonials-carousel.d.ts +17 -0
- package/dist/blocks/site/shared/testimonials-carousel.js +64 -0
- package/dist/blocks/site/site-shell.d.ts +108 -0
- package/dist/blocks/site/site-shell.js +254 -0
- package/dist/blocks/site/stats-band.d.ts +42 -0
- package/dist/blocks/site/stats-band.js +45 -0
- package/dist/blocks/site/team.d.ts +44 -0
- package/dist/blocks/site/team.js +48 -0
- package/dist/blocks/site/testimonials.d.ts +68 -0
- package/dist/blocks/site/testimonials.js +66 -0
- package/dist/blocks/types.d.ts +63 -0
- package/dist/blocks/types.js +2 -0
- package/dist/business/approval-flow.d.ts +152 -0
- package/dist/business/approval-flow.js +221 -0
- package/dist/business/export-core.d.ts +55 -0
- package/dist/business/export-core.js +101 -0
- package/dist/business/export.d.ts +148 -0
- package/dist/business/export.js +264 -0
- package/dist/business/import-core.d.ts +104 -0
- package/dist/business/import-core.js +281 -0
- package/dist/business/import-wizard.d.ts +186 -0
- package/dist/business/import-wizard.js +401 -0
- package/dist/business/index.d.ts +12 -0
- package/dist/business/index.js +22 -0
- package/dist/business/line-items-core.d.ts +129 -0
- package/dist/business/line-items-core.js +183 -0
- package/dist/business/line-items.d.ts +119 -0
- package/dist/business/line-items.js +299 -0
- package/dist/business/multi-step-form.d.ts +131 -0
- package/dist/business/multi-step-form.js +337 -0
- package/dist/business/permission-core.d.ts +59 -0
- package/dist/business/permission-core.js +99 -0
- package/dist/business/permission-matrix.d.ts +158 -0
- package/dist/business/permission-matrix.js +341 -0
- package/dist/business/setup-checklist.d.ts +80 -0
- package/dist/business/setup-checklist.js +92 -0
- package/dist/business/signer-status.d.ts +53 -0
- package/dist/business/signer-status.js +76 -0
- package/dist/charts/area-chart.d.ts +35 -0
- package/dist/charts/area-chart.js +33 -0
- package/dist/charts/bar-chart.d.ts +27 -0
- package/dist/charts/bar-chart.js +46 -0
- package/dist/charts/bar-list.d.ts +47 -0
- package/dist/charts/bar-list.js +60 -0
- package/dist/charts/chart-shell.d.ts +173 -0
- package/dist/charts/chart-shell.js +205 -0
- package/dist/charts/chart.d.ts +73 -0
- package/dist/charts/chart.js +106 -0
- package/dist/charts/combo-chart.d.ts +29 -0
- package/dist/charts/combo-chart.js +47 -0
- package/dist/charts/donut-chart.d.ts +33 -0
- package/dist/charts/donut-chart.js +113 -0
- package/dist/charts/funnel.d.ts +51 -0
- package/dist/charts/funnel.js +69 -0
- package/dist/charts/gauge.d.ts +62 -0
- package/dist/charts/gauge.js +104 -0
- package/dist/charts/heatmap.d.ts +81 -0
- package/dist/charts/heatmap.js +338 -0
- package/dist/charts/index.d.ts +12 -0
- package/dist/charts/index.js +14 -0
- package/dist/charts/line-chart.d.ts +21 -0
- package/dist/charts/line-chart.js +36 -0
- package/dist/charts/test-utils.d.ts +2 -0
- package/dist/charts/test-utils.js +38 -0
- package/dist/charts/utils.d.ts +130 -0
- package/dist/charts/utils.js +262 -0
- package/dist/components/_qr-core.d.ts +26 -0
- package/dist/components/_qr-core.js +376 -0
- package/dist/components/accordion.d.ts +47 -0
- package/dist/components/accordion.js +70 -0
- package/dist/components/activity-timeline.d.ts +149 -0
- package/dist/components/activity-timeline.js +122 -0
- package/dist/components/address-field.d.ts +116 -0
- package/dist/components/address-field.js +219 -0
- package/dist/components/alert-dialog.d.ts +99 -0
- package/dist/components/alert-dialog.js +192 -0
- package/dist/components/alert.d.ts +42 -0
- package/dist/components/alert.js +82 -0
- package/dist/components/app-shell.d.ts +159 -0
- package/dist/components/app-shell.js +289 -0
- package/dist/components/attachment-list.d.ts +96 -0
- package/dist/components/attachment-list.js +196 -0
- package/dist/components/audit-log.d.ts +150 -0
- package/dist/components/audit-log.js +205 -0
- package/dist/components/avatar.d.ts +87 -0
- package/dist/components/avatar.js +126 -0
- package/dist/components/backup-codes.d.ts +42 -0
- package/dist/components/backup-codes.js +67 -0
- package/dist/components/badge.d.ts +41 -0
- package/dist/components/badge.js +68 -0
- package/dist/components/breadcrumb.d.ts +78 -0
- package/dist/components/breadcrumb.js +106 -0
- package/dist/components/button-group.d.ts +52 -0
- package/dist/components/button-group.js +77 -0
- package/dist/components/button.d.ts +58 -0
- package/dist/components/button.js +107 -0
- package/dist/components/calendar.d.ts +240 -0
- package/dist/components/calendar.js +483 -0
- package/dist/components/card.d.ts +66 -0
- package/dist/components/card.js +76 -0
- package/dist/components/carousel.d.ts +170 -0
- package/dist/components/carousel.js +348 -0
- package/dist/components/checkbox.d.ts +78 -0
- package/dist/components/checkbox.js +138 -0
- package/dist/components/color-picker.d.ts +112 -0
- package/dist/components/color-picker.js +235 -0
- package/dist/components/combobox.d.ts +136 -0
- package/dist/components/combobox.js +294 -0
- package/dist/components/command.d.ts +281 -0
- package/dist/components/command.js +498 -0
- package/dist/components/comment-thread.d.ts +252 -0
- package/dist/components/comment-thread.js +449 -0
- package/dist/components/context-menu.d.ts +77 -0
- package/dist/components/context-menu.js +82 -0
- package/dist/components/currency-input.d.ts +43 -0
- package/dist/components/currency-input.js +85 -0
- package/dist/components/date-picker.d.ts +141 -0
- package/dist/components/date-picker.js +241 -0
- package/dist/components/date-range-picker.d.ts +91 -0
- package/dist/components/date-range-picker.js +251 -0
- package/dist/components/description-list.d.ts +92 -0
- package/dist/components/description-list.js +42 -0
- package/dist/components/dialog.d.ts +139 -0
- package/dist/components/dialog.js +185 -0
- package/dist/components/dropdown-menu.d.ts +100 -0
- package/dist/components/dropdown-menu.js +102 -0
- package/dist/components/editor-layout.d.ts +166 -0
- package/dist/components/editor-layout.js +237 -0
- package/dist/components/empty-state.d.ts +49 -0
- package/dist/components/empty-state.js +68 -0
- package/dist/components/entity-card.d.ts +83 -0
- package/dist/components/entity-card.js +92 -0
- package/dist/components/file-upload.d.ts +256 -0
- package/dist/components/file-upload.js +490 -0
- package/dist/components/formatted-input.d.ts +177 -0
- package/dist/components/formatted-input.js +399 -0
- package/dist/components/hierarchy-chart.d.ts +190 -0
- package/dist/components/hierarchy-chart.js +890 -0
- package/dist/components/hover-card.d.ts +21 -0
- package/dist/components/hover-card.js +32 -0
- package/dist/components/iban-input.d.ts +38 -0
- package/dist/components/iban-input.js +112 -0
- package/dist/components/id-input.d.ts +65 -0
- package/dist/components/id-input.js +130 -0
- package/dist/components/image.d.ts +130 -0
- package/dist/components/image.js +168 -0
- package/dist/components/input-otp.d.ts +62 -0
- package/dist/components/input-otp.js +73 -0
- package/dist/components/input.d.ts +141 -0
- package/dist/components/input.js +187 -0
- package/dist/components/item.d.ts +96 -0
- package/dist/components/item.js +113 -0
- package/dist/components/kbd.d.ts +64 -0
- package/dist/components/kbd.js +119 -0
- package/dist/components/list-layout.d.ts +144 -0
- package/dist/components/list-layout.js +210 -0
- package/dist/components/native-select.d.ts +33 -0
- package/dist/components/native-select.js +48 -0
- package/dist/components/navigation-menu.d.ts +127 -0
- package/dist/components/navigation-menu.js +129 -0
- package/dist/components/notification-center.d.ts +164 -0
- package/dist/components/notification-center.js +399 -0
- package/dist/components/page-header.d.ts +60 -0
- package/dist/components/page-header.js +60 -0
- package/dist/components/pagination.d.ts +121 -0
- package/dist/components/pagination.js +174 -0
- package/dist/components/phone-input.d.ts +49 -0
- package/dist/components/phone-input.js +266 -0
- package/dist/components/pin-map.d.ts +58 -0
- package/dist/components/pin-map.js +167 -0
- package/dist/components/popover.d.ts +38 -0
- package/dist/components/popover.js +69 -0
- package/dist/components/progress.d.ts +79 -0
- package/dist/components/progress.js +97 -0
- package/dist/components/qr-code.d.ts +36 -0
- package/dist/components/qr-code.js +27 -0
- package/dist/components/radio-group.d.ts +43 -0
- package/dist/components/radio-group.js +81 -0
- package/dist/components/record-detail-layout.d.ts +167 -0
- package/dist/components/record-detail-layout.js +233 -0
- package/dist/components/record-picker.d.ts +199 -0
- package/dist/components/record-picker.js +650 -0
- package/dist/components/resizable.d.ts +50 -0
- package/dist/components/resizable.js +88 -0
- package/dist/components/scroll-area.d.ts +40 -0
- package/dist/components/scroll-area.js +56 -0
- package/dist/components/select.d.ts +126 -0
- package/dist/components/select.js +137 -0
- package/dist/components/separator.d.ts +31 -0
- package/dist/components/separator.js +41 -0
- package/dist/components/settings-layout.d.ts +134 -0
- package/dist/components/settings-layout.js +180 -0
- package/dist/components/sheet.d.ts +103 -0
- package/dist/components/sheet.js +165 -0
- package/dist/components/sidebar.d.ts +171 -0
- package/dist/components/sidebar.js +421 -0
- package/dist/components/signature-pad.d.ts +85 -0
- package/dist/components/signature-pad.js +283 -0
- package/dist/components/skeleton.d.ts +64 -0
- package/dist/components/skeleton.js +53 -0
- package/dist/components/sla-timer.d.ts +75 -0
- package/dist/components/sla-timer.js +142 -0
- package/dist/components/slider.d.ts +57 -0
- package/dist/components/slider.js +133 -0
- package/dist/components/slug-input.d.ts +69 -0
- package/dist/components/slug-input.js +201 -0
- package/dist/components/sparkline.d.ts +54 -0
- package/dist/components/sparkline.js +122 -0
- package/dist/components/spinner.d.ts +34 -0
- package/dist/components/spinner.js +34 -0
- package/dist/components/stat.d.ts +135 -0
- package/dist/components/stat.js +130 -0
- package/dist/components/status-picker.d.ts +107 -0
- package/dist/components/status-picker.js +175 -0
- package/dist/components/stepper.d.ts +86 -0
- package/dist/components/stepper.js +103 -0
- package/dist/components/switch.d.ts +34 -0
- package/dist/components/switch.js +70 -0
- package/dist/components/table.d.ts +101 -0
- package/dist/components/table.js +72 -0
- package/dist/components/tabs.d.ts +103 -0
- package/dist/components/tabs.js +173 -0
- package/dist/components/tag-input.d.ts +77 -0
- package/dist/components/tag-input.js +305 -0
- package/dist/components/task-list.d.ts +89 -0
- package/dist/components/task-list.js +238 -0
- package/dist/components/time-picker.d.ts +119 -0
- package/dist/components/time-picker.js +399 -0
- package/dist/components/toast.d.ts +87 -0
- package/dist/components/toast.js +142 -0
- package/dist/components/toggle.d.ts +77 -0
- package/dist/components/toggle.js +109 -0
- package/dist/components/tooltip.d.ts +69 -0
- package/dist/components/tooltip.js +105 -0
- package/dist/components/top-bar.d.ts +87 -0
- package/dist/components/top-bar.js +99 -0
- package/dist/components/tour.d.ts +60 -0
- package/dist/components/tour.js +139 -0
- package/dist/components/tree-select.d.ts +89 -0
- package/dist/components/tree-select.js +243 -0
- package/dist/components/tree-view.d.ts +109 -0
- package/dist/components/tree-view.js +170 -0
- package/dist/components/typography.d.ts +107 -0
- package/dist/components/typography.js +128 -0
- package/dist/components/user-picker.d.ts +89 -0
- package/dist/components/user-picker.js +162 -0
- package/dist/components/version-history.d.ts +191 -0
- package/dist/components/version-history.js +431 -0
- package/dist/data-table/csv.d.ts +27 -0
- package/dist/data-table/csv.js +68 -0
- package/dist/data-table/data-table.d.ts +423 -0
- package/dist/data-table/data-table.js +1259 -0
- package/dist/data-table/filter-bar.d.ts +146 -0
- package/dist/data-table/filter-bar.js +569 -0
- package/dist/data-table/filter-fns.d.ts +65 -0
- package/dist/data-table/filter-fns.js +382 -0
- package/dist/data-table/index.d.ts +8 -0
- package/dist/data-table/index.js +9 -0
- package/dist/data-table/saved-views.d.ts +100 -0
- package/dist/data-table/saved-views.js +251 -0
- package/dist/data-table/types.d.ts +168 -0
- package/dist/data-table/types.js +87 -0
- package/dist/data-table/url-state.d.ts +94 -0
- package/dist/data-table/url-state.js +303 -0
- package/dist/data-table/view-state.d.ts +16 -0
- package/dist/data-table/view-state.js +81 -0
- package/dist/editor/_test-setup.d.ts +1 -0
- package/dist/editor/_test-setup.js +33 -0
- package/dist/editor/block-editor.d.ts +137 -0
- package/dist/editor/block-editor.js +280 -0
- package/dist/editor/commands.d.ts +31 -0
- package/dist/editor/commands.js +150 -0
- package/dist/editor/context.d.ts +108 -0
- package/dist/editor/context.js +30 -0
- package/dist/editor/convert.d.ts +66 -0
- package/dist/editor/convert.js +567 -0
- package/dist/editor/drag-handle.d.ts +10 -0
- package/dist/editor/drag-handle.js +69 -0
- package/dist/editor/extensions.d.ts +34 -0
- package/dist/editor/extensions.js +239 -0
- package/dist/editor/index.d.ts +14 -0
- package/dist/editor/index.js +17 -0
- package/dist/editor/inserter.d.ts +12 -0
- package/dist/editor/inserter.js +88 -0
- package/dist/editor/inspector.d.ts +17 -0
- package/dist/editor/inspector.js +65 -0
- package/dist/editor/items.d.ts +62 -0
- package/dist/editor/items.js +195 -0
- package/dist/editor/labels.d.ts +119 -0
- package/dist/editor/labels.js +130 -0
- package/dist/editor/markdown.d.ts +14 -0
- package/dist/editor/markdown.js +209 -0
- package/dist/editor/menus.d.ts +20 -0
- package/dist/editor/menus.js +236 -0
- package/dist/editor/nodes.d.ts +14 -0
- package/dist/editor/nodes.js +201 -0
- package/dist/editor/outline.d.ts +11 -0
- package/dist/editor/outline.js +52 -0
- package/dist/editor/schema-form.d.ts +64 -0
- package/dist/editor/schema-form.js +290 -0
- package/dist/editor/slash-menu.d.ts +15 -0
- package/dist/editor/slash-menu.js +119 -0
- package/dist/fonts/catalog.d.ts +53 -0
- package/dist/fonts/catalog.js +121 -0
- package/dist/fonts/font-picker.d.ts +70 -0
- package/dist/fonts/font-picker.js +225 -0
- package/dist/fonts/index.d.ts +6 -0
- package/dist/fonts/index.js +7 -0
- package/dist/fonts/loader.d.ts +66 -0
- package/dist/fonts/loader.js +161 -0
- package/dist/fonts/pairing-picker.d.ts +31 -0
- package/dist/fonts/pairing-picker.js +81 -0
- package/dist/fonts/pairings.d.ts +84 -0
- package/dist/fonts/pairings.js +149 -0
- package/dist/fonts/provider.d.ts +34 -0
- package/dist/fonts/provider.js +51 -0
- package/dist/form/index.d.ts +1 -0
- package/dist/form/index.js +1 -0
- package/dist/format/core.d.ts +149 -0
- package/dist/format/core.js +357 -0
- package/dist/format/index.d.ts +4 -0
- package/dist/format/index.js +5 -0
- package/dist/format/use-format.d.ts +1 -0
- package/dist/format/use-format.js +3 -0
- package/dist/index.d.ts +91 -0
- package/dist/index.js +92 -0
- package/dist/lib/cn.d.ts +3 -0
- package/dist/lib/cn.js +16 -0
- package/dist/lib/color.d.ts +64 -0
- package/dist/lib/color.js +177 -0
- package/dist/lib/compose-refs.d.ts +24 -0
- package/dist/lib/compose-refs.js +45 -0
- package/dist/lib/data-islands.d.ts +194 -0
- package/dist/lib/data-islands.js +368 -0
- package/dist/lib/date.d.ts +129 -0
- package/dist/lib/date.js +386 -0
- package/dist/lib/field-context.d.ts +64 -0
- package/dist/lib/field-context.js +62 -0
- package/dist/lib/floating-arrow.d.ts +18 -0
- package/dist/lib/floating-arrow.js +15 -0
- package/dist/lib/islands.d.ts +38 -0
- package/dist/lib/islands.js +40 -0
- package/dist/lib/labels.d.ts +51 -0
- package/dist/lib/labels.js +56 -0
- package/dist/lib/layer.d.ts +36 -0
- package/dist/lib/layer.js +42 -0
- package/dist/lib/locale.d.ts +85 -0
- package/dist/lib/locale.js +105 -0
- package/dist/lib/menu.d.ts +58 -0
- package/dist/lib/menu.js +99 -0
- package/dist/lib/message-format.d.ts +20 -0
- package/dist/lib/message-format.js +116 -0
- package/dist/lib/nav.d.ts +132 -0
- package/dist/lib/nav.js +178 -0
- package/dist/lib/provider.d.ts +100 -0
- package/dist/lib/provider.js +105 -0
- package/dist/lib/public.d.ts +23 -0
- package/dist/lib/public.js +34 -0
- package/dist/lib/sr-name.d.ts +18 -0
- package/dist/lib/sr-name.js +17 -0
- package/dist/lib/text.d.ts +100 -0
- package/dist/lib/text.js +233 -0
- package/dist/lib/theme-scope.d.ts +58 -0
- package/dist/lib/theme-scope.js +59 -0
- package/dist/lib/use-async-list.d.ts +60 -0
- package/dist/lib/use-async-list.js +119 -0
- package/dist/lib/use-container-width.d.ts +19 -0
- package/dist/lib/use-container-width.js +39 -0
- package/dist/lib/use-controllable-state.d.ts +33 -0
- package/dist/lib/use-controllable-state.js +56 -0
- package/dist/lib/use-edge-fade.d.ts +13 -0
- package/dist/lib/use-edge-fade.js +43 -0
- package/dist/lib/use-formatted-input.d.ts +69 -0
- package/dist/lib/use-formatted-input.js +152 -0
- package/dist/lib/use-hotkeys.d.ts +80 -0
- package/dist/lib/use-hotkeys.js +221 -0
- package/dist/lib/use-hover-intent.d.ts +44 -0
- package/dist/lib/use-hover-intent.js +119 -0
- package/dist/lib/use-media-query.d.ts +21 -0
- package/dist/lib/use-media-query.js +28 -0
- package/dist/lib/use-reduced-motion.d.ts +8 -0
- package/dist/lib/use-reduced-motion.js +13 -0
- package/dist/lib/use-tree.d.ts +153 -0
- package/dist/lib/use-tree.js +534 -0
- package/dist/lib/value-format.d.ts +25 -0
- package/dist/lib/value-format.js +56 -0
- package/dist/lib/variants.d.ts +131 -0
- package/dist/lib/variants.js +109 -0
- package/dist/locale-data/core/date.d.ts +24 -0
- package/dist/locale-data/core/date.js +68 -0
- package/dist/locale-data/core/decimal.d.ts +19 -0
- package/dist/locale-data/core/decimal.js +79 -0
- package/dist/locale-data/core/holidays.d.ts +30 -0
- package/dist/locale-data/core/holidays.js +79 -0
- package/dist/locale-data/core/iban.d.ts +29 -0
- package/dist/locale-data/core/iban.js +74 -0
- package/dist/locale-data/core/index.d.ts +7 -0
- package/dist/locale-data/core/index.js +6 -0
- package/dist/locale-data/core/types.d.ts +173 -0
- package/dist/locale-data/core/types.js +6 -0
- package/dist/locale-data/core/week-info.d.ts +23 -0
- package/dist/locale-data/core/week-info.js +85 -0
- package/dist/locale-data/core/working-days.d.ts +27 -0
- package/dist/locale-data/core/working-days.js +133 -0
- package/dist/locale-data/index.d.ts +2 -0
- package/dist/locale-data/index.js +4 -0
- package/dist/locale-data/tr/address-tr.json +1 -0
- package/dist/locale-data/tr/address.d.ts +23 -0
- package/dist/locale-data/tr/address.js +52 -0
- package/dist/locale-data/tr/holidays.d.ts +31 -0
- package/dist/locale-data/tr/holidays.js +81 -0
- package/dist/locale-data/tr/iban.d.ts +21 -0
- package/dist/locale-data/tr/iban.js +45 -0
- package/dist/locale-data/tr/id.d.ts +36 -0
- package/dist/locale-data/tr/id.js +120 -0
- package/dist/locale-data/tr/index.d.ts +12 -0
- package/dist/locale-data/tr/index.js +33 -0
- package/dist/locale-data/tr/kdv.d.ts +91 -0
- package/dist/locale-data/tr/kdv.js +222 -0
- package/dist/locales/en.d.ts +2102 -0
- package/dist/locales/en.js +2088 -0
- package/dist/locales/tr.d.ts +2086 -0
- package/dist/locales/tr.js +2087 -0
- package/dist/media/focal-point.d.ts +42 -0
- package/dist/media/focal-point.js +96 -0
- package/dist/media/gallery-layout.d.ts +19 -0
- package/dist/media/gallery-layout.js +61 -0
- package/dist/media/gallery.d.ts +64 -0
- package/dist/media/gallery.js +140 -0
- package/dist/media/image-cropper.d.ts +86 -0
- package/dist/media/image-cropper.js +170 -0
- package/dist/media/image-field.d.ts +115 -0
- package/dist/media/image-field.js +212 -0
- package/dist/media/index.d.ts +19 -0
- package/dist/media/index.js +23 -0
- package/dist/media/lightbox.d.ts +82 -0
- package/dist/media/lightbox.js +171 -0
- package/dist/media/link-preview.d.ts +97 -0
- package/dist/media/link-preview.js +177 -0
- package/dist/media/media-library.d.ts +244 -0
- package/dist/media/media-library.js +776 -0
- package/dist/media/media-picker.d.ts +96 -0
- package/dist/media/media-picker.js +209 -0
- package/dist/media/media-provider.d.ts +23 -0
- package/dist/media/media-provider.js +44 -0
- package/dist/media/media-utils.d.ts +39 -0
- package/dist/media/media-utils.js +145 -0
- package/dist/media/memory-adapter.d.ts +22 -0
- package/dist/media/memory-adapter.js +162 -0
- package/dist/media/rest-adapter.d.ts +90 -0
- package/dist/media/rest-adapter.js +208 -0
- package/dist/media/serp.d.ts +62 -0
- package/dist/media/serp.js +108 -0
- package/dist/media/test-fixtures.d.ts +3 -0
- package/dist/media/test-fixtures.js +37 -0
- package/dist/media/types.d.ts +183 -0
- package/dist/media/types.js +3 -0
- package/dist/media/use-pan-zoom.d.ts +51 -0
- package/dist/media/use-pan-zoom.js +156 -0
- package/dist/media/use-upload-queue.d.ts +64 -0
- package/dist/media/use-upload-queue.js +115 -0
- package/dist/media/video-player.d.ts +135 -0
- package/dist/media/video-player.js +319 -0
- package/dist/motion/core.d.ts +32 -0
- package/dist/motion/core.js +77 -0
- package/dist/motion/count-up.d.ts +29 -0
- package/dist/motion/count-up.js +92 -0
- package/dist/motion/index.d.ts +11 -0
- package/dist/motion/index.js +13 -0
- package/dist/motion/motion-scope.d.ts +17 -0
- package/dist/motion/motion-scope.js +16 -0
- package/dist/motion/page-transition.d.ts +33 -0
- package/dist/motion/page-transition.js +61 -0
- package/dist/motion/parallax.d.ts +37 -0
- package/dist/motion/parallax.js +90 -0
- package/dist/motion/pointer.d.ts +38 -0
- package/dist/motion/pointer.js +117 -0
- package/dist/motion/reveal.d.ts +72 -0
- package/dist/motion/reveal.js +133 -0
- package/dist/motion/scroll-shrink.d.ts +18 -0
- package/dist/motion/scroll-shrink.js +47 -0
- package/dist/motion/skeleton-swap.d.ts +17 -0
- package/dist/motion/skeleton-swap.js +43 -0
- package/dist/motion/text-reveal.d.ts +30 -0
- package/dist/motion/text-reveal.js +29 -0
- package/dist/motion/ticker.d.ts +35 -0
- package/dist/motion/ticker.js +16 -0
- package/dist/next/index.d.ts +42 -0
- package/dist/next/index.js +36 -0
- package/dist/render/block-renderer.d.ts +56 -0
- package/dist/render/block-renderer.js +137 -0
- package/dist/render/index.d.ts +6 -0
- package/dist/render/index.js +7 -0
- package/dist/render/prepare.d.ts +61 -0
- package/dist/render/prepare.js +119 -0
- package/dist/scheduler/core/duration.d.ts +83 -0
- package/dist/scheduler/core/duration.js +174 -0
- package/dist/scheduler/core/gantt.d.ts +63 -0
- package/dist/scheduler/core/gantt.js +226 -0
- package/dist/scheduler/core/index.d.ts +6 -0
- package/dist/scheduler/core/index.js +7 -0
- package/dist/scheduler/core/layout.d.ts +97 -0
- package/dist/scheduler/core/layout.js +249 -0
- package/dist/scheduler/core/time-scale.d.ts +89 -0
- package/dist/scheduler/core/time-scale.js +173 -0
- package/dist/scheduler/gantt.d.ts +125 -0
- package/dist/scheduler/gantt.js +532 -0
- package/dist/scheduler/index.d.ts +6 -0
- package/dist/scheduler/index.js +7 -0
- package/dist/scheduler/resource-calendar.d.ts +218 -0
- package/dist/scheduler/resource-calendar.js +661 -0
- package/dist/scheduler/scheduler.d.ts +168 -0
- package/dist/scheduler/scheduler.js +768 -0
- package/dist/scheduler/shared.d.ts +63 -0
- package/dist/scheduler/shared.js +145 -0
- package/dist/scheduler/time-tracker.d.ts +138 -0
- package/dist/scheduler/time-tracker.js +403 -0
- package/dist/sortable/core.d.ts +67 -0
- package/dist/sortable/core.js +167 -0
- package/dist/sortable/index.d.ts +8 -0
- package/dist/sortable/index.js +10 -0
- package/dist/sortable/kanban-core.d.ts +70 -0
- package/dist/sortable/kanban-core.js +67 -0
- package/dist/sortable/kanban.d.ts +147 -0
- package/dist/sortable/kanban.js +472 -0
- package/dist/sortable/sortable-list.d.ts +71 -0
- package/dist/sortable/sortable-list.js +76 -0
- package/dist/sortable/sortable-tree.d.ts +105 -0
- package/dist/sortable/sortable-tree.js +462 -0
- package/dist/sortable/sortable.d.ts +188 -0
- package/dist/sortable/sortable.js +485 -0
- package/dist/sortable/use-pointer-drag.d.ts +75 -0
- package/dist/sortable/use-pointer-drag.js +173 -0
- package/dist/sortable/use-time-scale.d.ts +11 -0
- package/dist/sortable/use-time-scale.js +19 -0
- package/dist/styles/base.css +51 -0
- package/dist/styles/blocks.css +949 -0
- package/dist/styles/calendar.css +642 -0
- package/dist/styles/charts.css +264 -0
- package/dist/styles/data.css +474 -0
- package/dist/styles/editors.css +1022 -0
- package/dist/styles/forms.css +406 -0
- package/dist/styles/media.css +515 -0
- package/dist/styles/motion.css +389 -0
- package/dist/styles/navigation.css +293 -0
- package/dist/styles/overlays.css +244 -0
- package/dist/styles.css +743 -0
- package/package.json +160 -4
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
export const CHART_HEIGHTS = { sm: 160, md: 260, lg: 360 };
|
|
2
|
+
const PALETTE = ["chart-1", "chart-2", "chart-3", "chart-4", "chart-5", "chart-6"];
|
|
3
|
+
/** `"chart-2"` → `"var(--chart-2)"`. */
|
|
4
|
+
export function resolveChartColor(color) {
|
|
5
|
+
return `var(--${color})`;
|
|
6
|
+
}
|
|
7
|
+
/** The first `n` palette tokens (wraps after 6). */
|
|
8
|
+
export function seriesPalette(n) {
|
|
9
|
+
return Array.from({ length: n }, (_, i) => PALETTE[i % PALETTE.length]);
|
|
10
|
+
}
|
|
11
|
+
/** A CSS-identifier-safe version of a series key, used in `--series-<key>` variables. */
|
|
12
|
+
export function seriesVarName(key) {
|
|
13
|
+
return `--series-${key.replace(/[^a-zA-Z0-9_-]/g, "_")}`;
|
|
14
|
+
}
|
|
15
|
+
/** `var(--series-<key>)` — the colour of a series inside a Chart. */
|
|
16
|
+
export function seriesColor(key) {
|
|
17
|
+
return `var(${seriesVarName(key)})`;
|
|
18
|
+
}
|
|
19
|
+
const AUTO_PATTERNS = ["solid", "dashed", "dotted"];
|
|
20
|
+
/** Fills in colour and pattern defaults for every series of a config. */
|
|
21
|
+
export function resolveSeries(config) {
|
|
22
|
+
const keys = Object.keys(config);
|
|
23
|
+
const auto = keys.length > 3;
|
|
24
|
+
return keys.map((key, index) => {
|
|
25
|
+
const s = config[key];
|
|
26
|
+
return {
|
|
27
|
+
...s,
|
|
28
|
+
key,
|
|
29
|
+
index,
|
|
30
|
+
color: s.color ?? PALETTE[index % PALETTE.length],
|
|
31
|
+
pattern: s.pattern ?? (auto ? AUTO_PATTERNS[index % AUTO_PATTERNS.length] : "solid"),
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/** SVG dash array for a pattern. */
|
|
36
|
+
export function patternDash(pattern) {
|
|
37
|
+
if (pattern === "dashed")
|
|
38
|
+
return "6 4";
|
|
39
|
+
if (pattern === "dotted")
|
|
40
|
+
return "1.5 3.5";
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
const CHART_DATE_PRESETS = {
|
|
44
|
+
"day-month": { month: "short", day: "numeric" },
|
|
45
|
+
month: { month: "short" },
|
|
46
|
+
"month-short-year": { month: "short", year: "2-digit" },
|
|
47
|
+
hour: { hour: "numeric" },
|
|
48
|
+
"weekday-short": { weekday: "short" },
|
|
49
|
+
};
|
|
50
|
+
const isMissing = (v) => v === null || v === undefined || (typeof v === "number" && Number.isNaN(v));
|
|
51
|
+
/**
|
|
52
|
+
* Writes a value with a FormatSpec. `compact` shortens numbers and money for axis ticks
|
|
53
|
+
* ("$1.2M", "₺1,2 Mn"); tooltips and tables use the full form. Missing values → "—".
|
|
54
|
+
*/
|
|
55
|
+
export function formatValue(f, spec, value, options = {}) {
|
|
56
|
+
if (isMissing(value))
|
|
57
|
+
return "—";
|
|
58
|
+
// compactFrom: plain numbers shorten from this size (axes whose top tick is ≥ 10K pass 1000 so every tick reads alike)
|
|
59
|
+
const { compact, compactFrom = 10000 } = options;
|
|
60
|
+
if (typeof spec === "function")
|
|
61
|
+
return spec(value, f.locale);
|
|
62
|
+
const num = typeof value === "number" ? value : typeof value === "string" && value.trim() !== "" && !Number.isNaN(Number(value)) ? Number(value) : NaN;
|
|
63
|
+
if (spec && typeof spec === "object") {
|
|
64
|
+
if ("date" in spec) {
|
|
65
|
+
const preset = spec.date;
|
|
66
|
+
const o = typeof preset === "string" ? (CHART_DATE_PRESETS[preset] ?? {}) : preset;
|
|
67
|
+
const opts = { ...o, ...(spec.timeZoneName ? { timeZoneName: spec.timeZoneName } : {}) };
|
|
68
|
+
if (typeof preset === "string" && !CHART_DATE_PRESETS[preset])
|
|
69
|
+
return f.date(value, preset);
|
|
70
|
+
return f.date(value, opts);
|
|
71
|
+
}
|
|
72
|
+
if ("relative" in spec)
|
|
73
|
+
return f.relative(value);
|
|
74
|
+
if ("currency" in spec) {
|
|
75
|
+
const c = compact || spec.compact;
|
|
76
|
+
return f.currency(value, { currency: spec.currency, ...(c ? { notation: "compact", minimumFractionDigits: 0, maximumFractionDigits: 1 } : {}) });
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (Number.isNaN(num))
|
|
80
|
+
return String(value);
|
|
81
|
+
switch (spec) {
|
|
82
|
+
case "integer":
|
|
83
|
+
return compact && Math.abs(num) >= compactFrom ? f.compact(num) : f.number(num, { maximumFractionDigits: 0 });
|
|
84
|
+
case "compact":
|
|
85
|
+
return f.compact(num);
|
|
86
|
+
case "percent":
|
|
87
|
+
return f.percent(num);
|
|
88
|
+
case "currency":
|
|
89
|
+
return compact ? f.currency(num, { notation: "compact", minimumFractionDigits: 0, maximumFractionDigits: 1 }) : f.currency(num);
|
|
90
|
+
case "duration":
|
|
91
|
+
return f.duration(num, compact ? { maxParts: 1 } : undefined);
|
|
92
|
+
case "bytes":
|
|
93
|
+
return f.bytes(num);
|
|
94
|
+
case "number":
|
|
95
|
+
default:
|
|
96
|
+
return compact && Math.abs(num) >= compactFrom ? f.compact(num) : f.number(num, { maximumFractionDigits: 2 });
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/** Default x formatter: `YYYY-MM-DD` strings become "Nov 1", everything else is printed as is. */
|
|
100
|
+
export function formatCategory(f, spec, value, long = false) {
|
|
101
|
+
if (spec)
|
|
102
|
+
return formatValue(f, spec, value);
|
|
103
|
+
if (typeof value === "string" && /^\d{4}-\d{2}-\d{2}$/.test(value))
|
|
104
|
+
return f.date(value, long ? "medium" : { month: "short", day: "numeric" });
|
|
105
|
+
return isMissing(value) ? "—" : String(value);
|
|
106
|
+
}
|
|
107
|
+
/** Estimated pixel width of a y-axis from its longest formatted tick (11px tabular text). */
|
|
108
|
+
export function estimateAxisWidth(labels, fontSize = 11) {
|
|
109
|
+
const longest = labels.reduce((m, s) => Math.max(m, s.length), 0);
|
|
110
|
+
return Math.min(128, Math.max(32, Math.ceil(longest * fontSize * 0.68) + 16));
|
|
111
|
+
}
|
|
112
|
+
/** Numeric min / max over some keys of the rows (stacked → per-row sums). */
|
|
113
|
+
export function extent(rows, keys, stacked = false) {
|
|
114
|
+
let min = Infinity;
|
|
115
|
+
let max = -Infinity;
|
|
116
|
+
for (const row of rows) {
|
|
117
|
+
if (stacked) {
|
|
118
|
+
let pos = 0;
|
|
119
|
+
let neg = 0;
|
|
120
|
+
for (const k of keys) {
|
|
121
|
+
const v = Number(row[k]);
|
|
122
|
+
if (!Number.isFinite(v))
|
|
123
|
+
continue;
|
|
124
|
+
if (v >= 0)
|
|
125
|
+
pos += v;
|
|
126
|
+
else
|
|
127
|
+
neg += v;
|
|
128
|
+
}
|
|
129
|
+
min = Math.min(min, neg);
|
|
130
|
+
max = Math.max(max, pos);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
for (const k of keys) {
|
|
134
|
+
const v = row[k];
|
|
135
|
+
if (v === null || v === undefined)
|
|
136
|
+
continue;
|
|
137
|
+
const n = Number(v);
|
|
138
|
+
if (!Number.isFinite(n))
|
|
139
|
+
continue;
|
|
140
|
+
min = Math.min(min, n);
|
|
141
|
+
max = Math.max(max, n);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (min === Infinity)
|
|
146
|
+
return [0, 0];
|
|
147
|
+
return [min, max];
|
|
148
|
+
}
|
|
149
|
+
/** Rounds a max up to a "nice" tick (1, 2, 2.5, 5 × 10ⁿ). */
|
|
150
|
+
export function niceCeil(v) {
|
|
151
|
+
if (v <= 0)
|
|
152
|
+
return 0;
|
|
153
|
+
const exp = Math.floor(Math.log10(v));
|
|
154
|
+
const base = 10 ** exp;
|
|
155
|
+
const f = v / base;
|
|
156
|
+
const nice = f <= 1 ? 1 : f <= 2 ? 2 : f <= 2.5 ? 2.5 : f <= 5 ? 5 : 10;
|
|
157
|
+
return nice * base;
|
|
158
|
+
}
|
|
159
|
+
/** A "nice" tick step at or above `v` (1, 1.5, 2, 2.5, 3, 4, 5, 6, 8 × 10ⁿ). */
|
|
160
|
+
export function niceStep(v) {
|
|
161
|
+
if (v <= 0)
|
|
162
|
+
return 0;
|
|
163
|
+
const exp = Math.floor(Math.log10(v));
|
|
164
|
+
const base = 10 ** exp;
|
|
165
|
+
const f = v / base;
|
|
166
|
+
const steps = [1, 1.5, 2, 2.5, 3, 4, 5, 6, 8, 10];
|
|
167
|
+
const nice = steps.find((s) => f <= s + 1e-9) ?? 10;
|
|
168
|
+
return Number((nice * base).toPrecision(12));
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Two value-axis domains whose zero lines meet (Combo). Each input is a `[min, max]` extent.
|
|
172
|
+
* Returns domains with the same negative share, so neither axis exaggerates.
|
|
173
|
+
*/
|
|
174
|
+
export function alignZeroDomains(a, b) {
|
|
175
|
+
const norm = ([lo, hi]) => [Math.min(0, lo), Math.max(0, hi, lo < 0 && hi <= 0 ? 0 : hi)];
|
|
176
|
+
const [aLo, aHi] = norm(a);
|
|
177
|
+
const [bLo, bHi] = norm(b);
|
|
178
|
+
const share = (lo, hi) => (hi - lo === 0 ? 0 : -lo / (hi - lo));
|
|
179
|
+
const s = Math.max(share(aLo, aHi), share(bLo, bHi));
|
|
180
|
+
const fit = (lo, hi) => {
|
|
181
|
+
if (s === 0)
|
|
182
|
+
return [0, niceStep(hi / 4) * 4 || 1];
|
|
183
|
+
if (s >= 1)
|
|
184
|
+
return [lo || -1, 0];
|
|
185
|
+
const top = Math.max(hi, (-lo * (1 - s)) / s);
|
|
186
|
+
const bottom = -(top * s) / (1 - s);
|
|
187
|
+
return [Math.min(lo, bottom), top];
|
|
188
|
+
};
|
|
189
|
+
return [fit(aLo, aHi), fit(bLo, bHi)];
|
|
190
|
+
}
|
|
191
|
+
/** Min / max / average of one series (nulls skipped). `null` when the series has no numbers. */
|
|
192
|
+
export function seriesStats(rows, key) {
|
|
193
|
+
let min = Infinity;
|
|
194
|
+
let max = -Infinity;
|
|
195
|
+
let sum = 0;
|
|
196
|
+
let count = 0;
|
|
197
|
+
let minIndex = 0;
|
|
198
|
+
let maxIndex = 0;
|
|
199
|
+
rows.forEach((row, i) => {
|
|
200
|
+
const raw = row[key];
|
|
201
|
+
if (raw === null || raw === undefined)
|
|
202
|
+
return;
|
|
203
|
+
const v = Number(raw);
|
|
204
|
+
if (!Number.isFinite(v))
|
|
205
|
+
return;
|
|
206
|
+
if (v < min) {
|
|
207
|
+
min = v;
|
|
208
|
+
minIndex = i;
|
|
209
|
+
}
|
|
210
|
+
if (v > max) {
|
|
211
|
+
max = v;
|
|
212
|
+
maxIndex = i;
|
|
213
|
+
}
|
|
214
|
+
sum += v;
|
|
215
|
+
count++;
|
|
216
|
+
});
|
|
217
|
+
if (!count)
|
|
218
|
+
return null;
|
|
219
|
+
return { key, min, max, avg: sum / count, minIndex, maxIndex, count };
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* A one-paragraph text summary of a chart for screen readers:
|
|
223
|
+
* "Nov 1 – Nov 30. Visits: low 812 (Nov 3), high 1,402 (Nov 28), average 1,090."
|
|
224
|
+
*/
|
|
225
|
+
export function summarizeSeries(options) {
|
|
226
|
+
const { f, rows, series, x, xFormat } = options;
|
|
227
|
+
if (!rows.length)
|
|
228
|
+
return "";
|
|
229
|
+
const xText = (i) => (x ? formatCategory(f, xFormat, rows[i]?.[x]) : String(i + 1));
|
|
230
|
+
const fill = (tpl, vars) => tpl.replace(/\{(\w+)\}/g, (_, k) => vars[k] ?? "");
|
|
231
|
+
const parts = [];
|
|
232
|
+
if (x && rows.length > 1)
|
|
233
|
+
parts.push(fill(options.templates?.range ?? "{from} – {to}.", { from: xText(0), to: xText(rows.length - 1) }));
|
|
234
|
+
for (const s of series) {
|
|
235
|
+
const st = seriesStats(rows, s.key);
|
|
236
|
+
if (!st)
|
|
237
|
+
continue;
|
|
238
|
+
const fmt = (v) => formatValue(f, s.format, v);
|
|
239
|
+
parts.push(fill(options.templates?.series ?? "{label}: low {min} ({minAt}), high {max} ({maxAt}), average {avg}.", {
|
|
240
|
+
label: s.label,
|
|
241
|
+
min: fmt(st.min),
|
|
242
|
+
minAt: xText(st.minIndex),
|
|
243
|
+
max: fmt(st.max),
|
|
244
|
+
maxAt: xText(st.maxIndex),
|
|
245
|
+
avg: fmt(Math.round(st.avg * 100) / 100),
|
|
246
|
+
}));
|
|
247
|
+
}
|
|
248
|
+
return parts.join(" ");
|
|
249
|
+
}
|
|
250
|
+
/** Equal-count (quantile) break points for `steps` buckets. Returns `steps - 1` thresholds. */
|
|
251
|
+
export function quantileBreaks(values, steps) {
|
|
252
|
+
const sorted = values.filter((v) => Number.isFinite(v) && v > 0).sort((a, b) => a - b);
|
|
253
|
+
if (!sorted.length)
|
|
254
|
+
return Array.from({ length: steps - 2 }, () => Infinity);
|
|
255
|
+
const out = [];
|
|
256
|
+
// bucket 0 is reserved for zero; the rest split the positive values.
|
|
257
|
+
for (let i = 1; i < steps - 1; i++) {
|
|
258
|
+
const q = sorted[Math.min(sorted.length - 1, Math.floor((i / (steps - 1)) * sorted.length))];
|
|
259
|
+
out.push(q);
|
|
260
|
+
}
|
|
261
|
+
return out;
|
|
262
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type QrErrorCorrection = "L" | "M" | "Q" | "H";
|
|
2
|
+
export interface QrMatrix {
|
|
3
|
+
/** Modules per side (version × 4 + 17). */
|
|
4
|
+
size: number;
|
|
5
|
+
version: number;
|
|
6
|
+
mask: number;
|
|
7
|
+
errorCorrection: QrErrorCorrection;
|
|
8
|
+
/** `modules[y][x]` — true = dark. */
|
|
9
|
+
modules: boolean[][];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Encode text (UTF-8, byte mode) as a QR matrix.
|
|
13
|
+
* Throws when the text does not fit version 40 at the chosen level.
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* const qr = encodeQr("otpauth://totp/Northpoint:ada@example.com?secret=…", { errorCorrection: "M" });
|
|
17
|
+
* qr.size; // 41 (version 6)
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function encodeQr(text: string, options?: {
|
|
21
|
+
errorCorrection?: QrErrorCorrection;
|
|
22
|
+
minVersion?: number;
|
|
23
|
+
mask?: number;
|
|
24
|
+
}): QrMatrix;
|
|
25
|
+
/** One SVG path (`d`) drawing every dark module, offset by `margin` modules. */
|
|
26
|
+
export declare function qrPath(qr: Pick<QrMatrix, "size" | "modules">, margin?: number): string;
|
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
// QR Code Model 2 encoder (ISO/IEC 18004), byte mode, versions 1–40, all four error
|
|
2
|
+
// correction levels, automatic mask choice. Pure and dependency-free so it runs in RSC.
|
|
3
|
+
// Follows the structure of the public-domain-style reference algorithm (Nayuki).
|
|
4
|
+
const ECL_INDEX = { L: 0, M: 1, Q: 2, H: 3 };
|
|
5
|
+
const ECL_FORMAT = { L: 1, M: 0, Q: 3, H: 2 };
|
|
6
|
+
// prettier-ignore
|
|
7
|
+
const ECC_CODEWORDS_PER_BLOCK = [
|
|
8
|
+
[-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
|
|
9
|
+
[-1, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28],
|
|
10
|
+
[-1, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
|
|
11
|
+
[-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
|
|
12
|
+
];
|
|
13
|
+
// prettier-ignore
|
|
14
|
+
const NUM_ERROR_CORRECTION_BLOCKS = [
|
|
15
|
+
[-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25],
|
|
16
|
+
[-1, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49],
|
|
17
|
+
[-1, 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68],
|
|
18
|
+
[-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81],
|
|
19
|
+
];
|
|
20
|
+
const bit = (x, i) => ((x >>> i) & 1) !== 0;
|
|
21
|
+
function rawDataModules(ver) {
|
|
22
|
+
let result = (16 * ver + 128) * ver + 64;
|
|
23
|
+
if (ver >= 2) {
|
|
24
|
+
const numAlign = Math.floor(ver / 7) + 2;
|
|
25
|
+
result -= (25 * numAlign - 10) * numAlign - 55;
|
|
26
|
+
if (ver >= 7)
|
|
27
|
+
result -= 36;
|
|
28
|
+
}
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
function dataCodewords(ver, ecl) {
|
|
32
|
+
const e = ECL_INDEX[ecl];
|
|
33
|
+
return Math.floor(rawDataModules(ver) / 8) - ECC_CODEWORDS_PER_BLOCK[e][ver] * NUM_ERROR_CORRECTION_BLOCKS[e][ver];
|
|
34
|
+
}
|
|
35
|
+
/* Reed–Solomon over GF(2^8), polynomial 0x11D. */
|
|
36
|
+
function gfMul(x, y) {
|
|
37
|
+
let z = 0;
|
|
38
|
+
for (let i = 7; i >= 0; i--) {
|
|
39
|
+
z = (z << 1) ^ ((z >>> 7) * 0x11d);
|
|
40
|
+
z ^= ((y >>> i) & 1) * x;
|
|
41
|
+
}
|
|
42
|
+
return z & 0xff;
|
|
43
|
+
}
|
|
44
|
+
function rsDivisor(degree) {
|
|
45
|
+
const result = new Array(degree - 1).fill(0);
|
|
46
|
+
result.push(1);
|
|
47
|
+
let root = 1;
|
|
48
|
+
for (let i = 0; i < degree; i++) {
|
|
49
|
+
for (let j = 0; j < result.length; j++) {
|
|
50
|
+
result[j] = gfMul(result[j], root);
|
|
51
|
+
if (j + 1 < result.length)
|
|
52
|
+
result[j] ^= result[j + 1];
|
|
53
|
+
}
|
|
54
|
+
root = gfMul(root, 0x02);
|
|
55
|
+
}
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
function rsRemainder(data, divisor) {
|
|
59
|
+
const result = divisor.map(() => 0);
|
|
60
|
+
for (const b of data) {
|
|
61
|
+
const factor = b ^ result.shift();
|
|
62
|
+
result.push(0);
|
|
63
|
+
divisor.forEach((coef, i) => (result[i] ^= gfMul(coef, factor)));
|
|
64
|
+
}
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
/** UTF-8 bytes without TextEncoder (works everywhere). */
|
|
68
|
+
function utf8(text) {
|
|
69
|
+
const out = [];
|
|
70
|
+
for (const ch of text) {
|
|
71
|
+
const cp = ch.codePointAt(0);
|
|
72
|
+
if (cp < 0x80)
|
|
73
|
+
out.push(cp);
|
|
74
|
+
else if (cp < 0x800)
|
|
75
|
+
out.push(0xc0 | (cp >> 6), 0x80 | (cp & 63));
|
|
76
|
+
else if (cp < 0x10000)
|
|
77
|
+
out.push(0xe0 | (cp >> 12), 0x80 | ((cp >> 6) & 63), 0x80 | (cp & 63));
|
|
78
|
+
else
|
|
79
|
+
out.push(0xf0 | (cp >> 18), 0x80 | ((cp >> 12) & 63), 0x80 | ((cp >> 6) & 63), 0x80 | (cp & 63));
|
|
80
|
+
}
|
|
81
|
+
return out;
|
|
82
|
+
}
|
|
83
|
+
class Grid {
|
|
84
|
+
version;
|
|
85
|
+
size;
|
|
86
|
+
modules;
|
|
87
|
+
fn;
|
|
88
|
+
constructor(version) {
|
|
89
|
+
this.version = version;
|
|
90
|
+
this.size = version * 4 + 17;
|
|
91
|
+
this.modules = Array.from({ length: this.size }, () => new Array(this.size).fill(false));
|
|
92
|
+
this.fn = Array.from({ length: this.size }, () => new Array(this.size).fill(false));
|
|
93
|
+
}
|
|
94
|
+
setFn(x, y, dark) {
|
|
95
|
+
this.modules[y][x] = dark;
|
|
96
|
+
this.fn[y][x] = true;
|
|
97
|
+
}
|
|
98
|
+
alignmentPositions() {
|
|
99
|
+
if (this.version === 1)
|
|
100
|
+
return [];
|
|
101
|
+
const numAlign = Math.floor(this.version / 7) + 2;
|
|
102
|
+
const step = Math.floor((this.version * 8 + numAlign * 3 + 5) / (numAlign * 4 - 4)) * 2;
|
|
103
|
+
const result = [6];
|
|
104
|
+
for (let pos = this.size - 7; result.length < numAlign; pos -= step)
|
|
105
|
+
result.splice(1, 0, pos);
|
|
106
|
+
return result;
|
|
107
|
+
}
|
|
108
|
+
drawFunctionPatterns(ecl) {
|
|
109
|
+
const n = this.size;
|
|
110
|
+
for (let i = 0; i < n; i++) {
|
|
111
|
+
this.setFn(6, i, i % 2 === 0);
|
|
112
|
+
this.setFn(i, 6, i % 2 === 0);
|
|
113
|
+
}
|
|
114
|
+
this.finder(3, 3);
|
|
115
|
+
this.finder(n - 4, 3);
|
|
116
|
+
this.finder(3, n - 4);
|
|
117
|
+
const pos = this.alignmentPositions();
|
|
118
|
+
const k = pos.length;
|
|
119
|
+
for (let i = 0; i < k; i++)
|
|
120
|
+
for (let j = 0; j < k; j++) {
|
|
121
|
+
if ((i === 0 && j === 0) || (i === 0 && j === k - 1) || (i === k - 1 && j === 0))
|
|
122
|
+
continue;
|
|
123
|
+
for (let dy = -2; dy <= 2; dy++)
|
|
124
|
+
for (let dx = -2; dx <= 2; dx++)
|
|
125
|
+
this.setFn(pos[i] + dx, pos[j] + dy, Math.max(Math.abs(dx), Math.abs(dy)) !== 1);
|
|
126
|
+
}
|
|
127
|
+
this.drawFormat(ecl, 0);
|
|
128
|
+
this.drawVersion();
|
|
129
|
+
}
|
|
130
|
+
finder(x, y) {
|
|
131
|
+
for (let dy = -4; dy <= 4; dy++)
|
|
132
|
+
for (let dx = -4; dx <= 4; dx++) {
|
|
133
|
+
const d = Math.max(Math.abs(dx), Math.abs(dy));
|
|
134
|
+
const xx = x + dx;
|
|
135
|
+
const yy = y + dy;
|
|
136
|
+
if (xx >= 0 && xx < this.size && yy >= 0 && yy < this.size)
|
|
137
|
+
this.setFn(xx, yy, d !== 2 && d !== 4);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
drawFormat(ecl, mask) {
|
|
141
|
+
const data = (ECL_FORMAT[ecl] << 3) | mask;
|
|
142
|
+
let rem = data;
|
|
143
|
+
for (let i = 0; i < 10; i++)
|
|
144
|
+
rem = (rem << 1) ^ ((rem >>> 9) * 0x537);
|
|
145
|
+
const bits = ((data << 10) | rem) ^ 0x5412;
|
|
146
|
+
const n = this.size;
|
|
147
|
+
for (let i = 0; i <= 5; i++)
|
|
148
|
+
this.setFn(8, i, bit(bits, i));
|
|
149
|
+
this.setFn(8, 7, bit(bits, 6));
|
|
150
|
+
this.setFn(8, 8, bit(bits, 7));
|
|
151
|
+
this.setFn(7, 8, bit(bits, 8));
|
|
152
|
+
for (let i = 9; i < 15; i++)
|
|
153
|
+
this.setFn(14 - i, 8, bit(bits, i));
|
|
154
|
+
for (let i = 0; i < 8; i++)
|
|
155
|
+
this.setFn(n - 1 - i, 8, bit(bits, i));
|
|
156
|
+
for (let i = 8; i < 15; i++)
|
|
157
|
+
this.setFn(8, n - 15 + i, bit(bits, i));
|
|
158
|
+
this.setFn(8, n - 8, true);
|
|
159
|
+
}
|
|
160
|
+
drawVersion() {
|
|
161
|
+
if (this.version < 7)
|
|
162
|
+
return;
|
|
163
|
+
let rem = this.version;
|
|
164
|
+
for (let i = 0; i < 12; i++)
|
|
165
|
+
rem = (rem << 1) ^ ((rem >>> 11) * 0x1f25);
|
|
166
|
+
const bits = (this.version << 12) | rem;
|
|
167
|
+
for (let i = 0; i < 18; i++) {
|
|
168
|
+
const b = bit(bits, i);
|
|
169
|
+
const a = this.size - 11 + (i % 3);
|
|
170
|
+
const c = Math.floor(i / 3);
|
|
171
|
+
this.setFn(a, c, b);
|
|
172
|
+
this.setFn(c, a, b);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
drawCodewords(data) {
|
|
176
|
+
let i = 0;
|
|
177
|
+
const n = this.size;
|
|
178
|
+
for (let right = n - 1; right >= 1; right -= 2) {
|
|
179
|
+
if (right === 6)
|
|
180
|
+
right = 5;
|
|
181
|
+
for (let vert = 0; vert < n; vert++)
|
|
182
|
+
for (let j = 0; j < 2; j++) {
|
|
183
|
+
const x = right - j;
|
|
184
|
+
const upward = ((right + 1) & 2) === 0;
|
|
185
|
+
const y = upward ? n - 1 - vert : vert;
|
|
186
|
+
if (!this.fn[y][x] && i < data.length * 8) {
|
|
187
|
+
this.modules[y][x] = bit(data[i >>> 3], 7 - (i & 7));
|
|
188
|
+
i++;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
applyMask(mask) {
|
|
194
|
+
for (let y = 0; y < this.size; y++)
|
|
195
|
+
for (let x = 0; x < this.size; x++) {
|
|
196
|
+
let invert;
|
|
197
|
+
switch (mask) {
|
|
198
|
+
case 0:
|
|
199
|
+
invert = (x + y) % 2 === 0;
|
|
200
|
+
break;
|
|
201
|
+
case 1:
|
|
202
|
+
invert = y % 2 === 0;
|
|
203
|
+
break;
|
|
204
|
+
case 2:
|
|
205
|
+
invert = x % 3 === 0;
|
|
206
|
+
break;
|
|
207
|
+
case 3:
|
|
208
|
+
invert = (x + y) % 3 === 0;
|
|
209
|
+
break;
|
|
210
|
+
case 4:
|
|
211
|
+
invert = (Math.floor(x / 3) + Math.floor(y / 2)) % 2 === 0;
|
|
212
|
+
break;
|
|
213
|
+
case 5:
|
|
214
|
+
invert = ((x * y) % 2) + ((x * y) % 3) === 0;
|
|
215
|
+
break;
|
|
216
|
+
case 6:
|
|
217
|
+
invert = (((x * y) % 2) + ((x * y) % 3)) % 2 === 0;
|
|
218
|
+
break;
|
|
219
|
+
default: invert = (((x + y) % 2) + ((x * y) % 3)) % 2 === 0;
|
|
220
|
+
}
|
|
221
|
+
if (!this.fn[y][x] && invert)
|
|
222
|
+
this.modules[y][x] = !this.modules[y][x];
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
penalty() {
|
|
226
|
+
const n = this.size;
|
|
227
|
+
const m = this.modules;
|
|
228
|
+
let score = 0;
|
|
229
|
+
const line = (get) => {
|
|
230
|
+
let run = 1;
|
|
231
|
+
let s = 0;
|
|
232
|
+
for (let i = 1; i <= n; i++) {
|
|
233
|
+
if (i < n && get(i) === get(i - 1))
|
|
234
|
+
run++;
|
|
235
|
+
else {
|
|
236
|
+
if (run >= 5)
|
|
237
|
+
s += 3 + (run - 5);
|
|
238
|
+
run = 1;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
// Finder-like 1:1:3:1:1 with four light modules on one side.
|
|
242
|
+
for (let i = 0; i + 10 < n + 4; i++) {
|
|
243
|
+
const at = (k) => (k < 0 || k >= n ? false : get(k));
|
|
244
|
+
const core = at(i) && !at(i + 1) && at(i + 2) && at(i + 3) && at(i + 4) && !at(i + 5) && at(i + 6);
|
|
245
|
+
if (!core)
|
|
246
|
+
continue;
|
|
247
|
+
const before = !at(i - 1) && !at(i - 2) && !at(i - 3) && !at(i - 4);
|
|
248
|
+
const after = !at(i + 7) && !at(i + 8) && !at(i + 9) && !at(i + 10);
|
|
249
|
+
if (before || after)
|
|
250
|
+
s += 40;
|
|
251
|
+
}
|
|
252
|
+
return s;
|
|
253
|
+
};
|
|
254
|
+
for (let y = 0; y < n; y++)
|
|
255
|
+
score += line((x) => m[y][x]);
|
|
256
|
+
for (let x = 0; x < n; x++)
|
|
257
|
+
score += line((y) => m[y][x]);
|
|
258
|
+
for (let y = 0; y < n - 1; y++)
|
|
259
|
+
for (let x = 0; x < n - 1; x++) {
|
|
260
|
+
const c = m[y][x];
|
|
261
|
+
if (c === m[y][x + 1] && c === m[y + 1][x] && c === m[y + 1][x + 1])
|
|
262
|
+
score += 3;
|
|
263
|
+
}
|
|
264
|
+
let dark = 0;
|
|
265
|
+
for (const row of m)
|
|
266
|
+
for (const c of row)
|
|
267
|
+
if (c)
|
|
268
|
+
dark++;
|
|
269
|
+
const total = n * n;
|
|
270
|
+
score += (Math.ceil(Math.abs(dark * 20 - total * 10) / total) - 1) * 10;
|
|
271
|
+
return score;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Encode text (UTF-8, byte mode) as a QR matrix.
|
|
276
|
+
* Throws when the text does not fit version 40 at the chosen level.
|
|
277
|
+
*
|
|
278
|
+
* ```ts
|
|
279
|
+
* const qr = encodeQr("otpauth://totp/Northpoint:ada@example.com?secret=…", { errorCorrection: "M" });
|
|
280
|
+
* qr.size; // 41 (version 6)
|
|
281
|
+
* ```
|
|
282
|
+
*/
|
|
283
|
+
export function encodeQr(text, options = {}) {
|
|
284
|
+
const ecl = options.errorCorrection ?? "M";
|
|
285
|
+
const bytes = utf8(text);
|
|
286
|
+
let version = Math.max(1, Math.min(40, options.minVersion ?? 1));
|
|
287
|
+
let capacityBits = 0;
|
|
288
|
+
for (;; version++) {
|
|
289
|
+
if (version > 40)
|
|
290
|
+
throw new RangeError("QR: text is too long to encode");
|
|
291
|
+
const ccBits = version < 10 ? 8 : 16;
|
|
292
|
+
capacityBits = dataCodewords(version, ecl) * 8;
|
|
293
|
+
if (4 + ccBits + bytes.length * 8 <= capacityBits)
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
// Bit stream: mode (byte = 0100), length, data, terminator, padding.
|
|
297
|
+
const bits = [];
|
|
298
|
+
const push = (value, len) => {
|
|
299
|
+
for (let i = len - 1; i >= 0; i--)
|
|
300
|
+
bits.push((value >>> i) & 1);
|
|
301
|
+
};
|
|
302
|
+
push(0b0100, 4);
|
|
303
|
+
push(bytes.length, version < 10 ? 8 : 16);
|
|
304
|
+
for (const b of bytes)
|
|
305
|
+
push(b, 8);
|
|
306
|
+
push(0, Math.min(4, capacityBits - bits.length));
|
|
307
|
+
push(0, (8 - (bits.length % 8)) % 8);
|
|
308
|
+
for (let pad = 0xec; bits.length < capacityBits; pad ^= 0xec ^ 0x11)
|
|
309
|
+
push(pad, 8);
|
|
310
|
+
const data = [];
|
|
311
|
+
for (let i = 0; i < bits.length; i += 8)
|
|
312
|
+
data.push(bits.slice(i, i + 8).reduce((acc, b) => (acc << 1) | b, 0));
|
|
313
|
+
// Error correction + interleave.
|
|
314
|
+
const e = ECL_INDEX[ecl];
|
|
315
|
+
const numBlocks = NUM_ERROR_CORRECTION_BLOCKS[e][version];
|
|
316
|
+
const eccLen = ECC_CODEWORDS_PER_BLOCK[e][version];
|
|
317
|
+
const rawCodewords = Math.floor(rawDataModules(version) / 8);
|
|
318
|
+
const numShort = numBlocks - (rawCodewords % numBlocks);
|
|
319
|
+
const shortLen = Math.floor(rawCodewords / numBlocks);
|
|
320
|
+
const divisor = rsDivisor(eccLen);
|
|
321
|
+
const blocks = [];
|
|
322
|
+
for (let i = 0, k = 0; i < numBlocks; i++) {
|
|
323
|
+
const dat = data.slice(k, k + shortLen - eccLen + (i < numShort ? 0 : 1));
|
|
324
|
+
k += dat.length;
|
|
325
|
+
const ecc = rsRemainder(dat, divisor);
|
|
326
|
+
if (i < numShort)
|
|
327
|
+
dat.push(0);
|
|
328
|
+
blocks.push(dat.concat(ecc));
|
|
329
|
+
}
|
|
330
|
+
const codewords = [];
|
|
331
|
+
for (let i = 0; i < blocks[0].length; i++)
|
|
332
|
+
blocks.forEach((block, j) => {
|
|
333
|
+
if (i !== shortLen - eccLen || j >= numShort)
|
|
334
|
+
codewords.push(block[i]);
|
|
335
|
+
});
|
|
336
|
+
// Place, then pick the mask with the lowest penalty.
|
|
337
|
+
const grid = new Grid(version);
|
|
338
|
+
grid.drawFunctionPatterns(ecl);
|
|
339
|
+
grid.drawCodewords(codewords);
|
|
340
|
+
let mask = options.mask ?? -1;
|
|
341
|
+
if (mask < 0 || mask > 7) {
|
|
342
|
+
let best = Infinity;
|
|
343
|
+
for (let candidate = 0; candidate < 8; candidate++) {
|
|
344
|
+
grid.applyMask(candidate);
|
|
345
|
+
grid.drawFormat(ecl, candidate);
|
|
346
|
+
const p = grid.penalty();
|
|
347
|
+
if (p < best) {
|
|
348
|
+
best = p;
|
|
349
|
+
mask = candidate;
|
|
350
|
+
}
|
|
351
|
+
grid.applyMask(candidate); // undo (XOR)
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
grid.applyMask(mask);
|
|
355
|
+
grid.drawFormat(ecl, mask);
|
|
356
|
+
return { size: grid.size, version, mask, errorCorrection: ecl, modules: grid.modules };
|
|
357
|
+
}
|
|
358
|
+
/** One SVG path (`d`) drawing every dark module, offset by `margin` modules. */
|
|
359
|
+
export function qrPath(qr, margin = 0) {
|
|
360
|
+
let d = "";
|
|
361
|
+
for (let y = 0; y < qr.size; y++) {
|
|
362
|
+
let x = 0;
|
|
363
|
+
while (x < qr.size) {
|
|
364
|
+
if (!qr.modules[y][x]) {
|
|
365
|
+
x++;
|
|
366
|
+
continue;
|
|
367
|
+
}
|
|
368
|
+
let run = 1;
|
|
369
|
+
while (x + run < qr.size && qr.modules[y][x + run])
|
|
370
|
+
run++;
|
|
371
|
+
d += `M${x + margin} ${y + margin}h${run}v1h-${run}z`;
|
|
372
|
+
x += run;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
return d;
|
|
376
|
+
}
|