@vamos-ui/react 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +100 -0
- package/dist/blocks/site/_kit-1.js +135 -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 +112 -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 +51 -0
- package/dist/blocks/site/feature-grid.d.ts +46 -0
- package/dist/blocks/site/feature-grid.js +49 -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 +47 -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 +67 -0
- package/dist/blocks/site/logo-strip.d.ts +42 -0
- package/dist/blocks/site/logo-strip.js +26 -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 +55 -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 +82 -0
- package/dist/blocks/site/process.d.ts +36 -0
- package/dist/blocks/site/process.js +41 -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 +97 -0
- package/dist/blocks/site/site-shell.js +227 -0
- package/dist/blocks/site/stats-band.d.ts +40 -0
- package/dist/blocks/site/stats-band.js +41 -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 +65 -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 +11 -0
- package/dist/business/index.js +20 -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/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 +42 -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/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/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 +275 -0
- package/dist/components/command.js +493 -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/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/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/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/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 +86 -0
- package/dist/index.js +87 -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 +22 -0
- package/dist/lib/public.js +33 -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 +138 -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/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 +101 -0
- package/dist/sortable/sortable-tree.js +450 -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/navigation.css +293 -0
- package/dist/styles/overlays.css +244 -0
- package/dist/styles.css +742 -0
- package/package.json +156 -4
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turkish public holidays (Law 2429 on national holidays and general holidays).
|
|
3
|
+
*
|
|
4
|
+
* Fixed-date holidays are generated for any year. Religious holidays follow the lunar calendar
|
|
5
|
+
* and are NOT computed: published dates can differ from computed Umm al-Qura dates. They ship
|
|
6
|
+
* as a static table from the Diyanet İşleri Başkanlığı "Dini Günler" calendar.
|
|
7
|
+
*
|
|
8
|
+
* Source: Diyanet İşleri Başkanlığı, Dini Günler takvimi 2025, 2026, 2027 (the 2027 table was
|
|
9
|
+
* announced on 2026-08-24), cross-checked against national press listings of the
|
|
10
|
+
* official holiday calendar.
|
|
11
|
+
* Verified: 2026-11-10. Review every year in January and extend `RELIGIOUS` (target 2035).
|
|
12
|
+
*
|
|
13
|
+
* Government "bridge" days (idari izin) bind only the public sector and are not included;
|
|
14
|
+
* add them as a custom provider (`createHolidayProvider`).
|
|
15
|
+
*/
|
|
16
|
+
import { addDays } from "../core/date.js";
|
|
17
|
+
import { createHolidayProvider } from "../core/holidays.js";
|
|
18
|
+
export const TR_HOLIDAYS_SOURCE = {
|
|
19
|
+
source: "Diyanet İşleri Başkanlığı — Dini Günler takvimi (2025–2027); Law 2429",
|
|
20
|
+
verifiedOn: "2026-11-10",
|
|
21
|
+
coverage: { from: "2025-01-01", to: "2027-12-31" },
|
|
22
|
+
};
|
|
23
|
+
/** First days of the religious holidays, as published by Diyanet. */
|
|
24
|
+
export const TR_RELIGIOUS_HOLIDAYS = [
|
|
25
|
+
{ year: 2025, ramazan: "2025-03-30", kurban: "2025-06-06", verified: true },
|
|
26
|
+
{ year: 2026, ramazan: "2026-03-20", kurban: "2026-05-27", verified: true },
|
|
27
|
+
{ year: 2027, ramazan: "2027-03-09", kurban: "2027-05-16", verified: true },
|
|
28
|
+
];
|
|
29
|
+
const FIXED = [
|
|
30
|
+
{ md: "01-01", id: "tr-new-year", name: "New Year's Day", localName: "Yılbaşı" },
|
|
31
|
+
{ md: "04-23", id: "tr-sovereignty-children", name: "National Sovereignty and Children's Day", localName: "Ulusal Egemenlik ve Çocuk Bayramı" },
|
|
32
|
+
{ md: "05-01", id: "tr-labour", name: "Labour and Solidarity Day", localName: "Emek ve Dayanışma Günü" },
|
|
33
|
+
{ md: "05-19", id: "tr-ataturk-youth-sports", name: "Commemoration of Atatürk, Youth and Sports Day", localName: "Atatürk'ü Anma, Gençlik ve Spor Bayramı" },
|
|
34
|
+
{ md: "07-15", id: "tr-democracy", name: "Democracy and National Unity Day", localName: "Demokrasi ve Millî Birlik Günü" },
|
|
35
|
+
{ md: "08-30", id: "tr-victory", name: "Victory Day", localName: "Zafer Bayramı" },
|
|
36
|
+
{ md: "10-28", id: "tr-republic-eve", name: "Republic Day Eve", localName: "Cumhuriyet Bayramı Arifesi", partial: true },
|
|
37
|
+
{ md: "10-29", id: "tr-republic", name: "Republic Day", localName: "Cumhuriyet Bayramı" },
|
|
38
|
+
];
|
|
39
|
+
const ORDINAL_EN = ["day 1", "day 2", "day 3", "day 4"];
|
|
40
|
+
function religious(row) {
|
|
41
|
+
const out = [];
|
|
42
|
+
const feast = (first, days, key) => {
|
|
43
|
+
const en = key === "ramadan" ? "Ramadan Feast" : "Sacrifice Feast";
|
|
44
|
+
const tr = key === "ramadan" ? "Ramazan Bayramı" : "Kurban Bayramı";
|
|
45
|
+
out.push({ date: addDays(first, -1), id: `tr-${key}-eve`, name: `${en} Eve`, localName: `${tr} Arifesi`, kind: "public", partial: { from: "13:00" }, verified: row.verified });
|
|
46
|
+
for (let i = 0; i < days; i++) {
|
|
47
|
+
out.push({ date: addDays(first, i), id: `tr-${key}-${i + 1}`, name: `${en} (${ORDINAL_EN[i]})`, localName: `${tr} (${i + 1}. gün)`, kind: "public", verified: row.verified });
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
feast(row.ramazan, 3, "ramadan");
|
|
51
|
+
feast(row.kurban, 4, "sacrifice");
|
|
52
|
+
return out;
|
|
53
|
+
}
|
|
54
|
+
/** All Turkish public holidays of one year (religious ones only inside the table's coverage). */
|
|
55
|
+
export function trHolidaysForYear(year) {
|
|
56
|
+
const y = String(year).padStart(4, "0");
|
|
57
|
+
const fixed = FIXED.map((f) => ({
|
|
58
|
+
date: `${y}-${f.md}`,
|
|
59
|
+
id: f.id,
|
|
60
|
+
name: f.name,
|
|
61
|
+
localName: f.localName,
|
|
62
|
+
kind: "public",
|
|
63
|
+
...(f.partial ? { partial: { from: "13:00" } } : {}),
|
|
64
|
+
verified: true,
|
|
65
|
+
}));
|
|
66
|
+
const row = TR_RELIGIOUS_HOLIDAYS.find((r) => r.year === year);
|
|
67
|
+
return [...fixed, ...(row ? religious(row) : [])];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The `tr` holiday provider. Names are English in `name` and official Turkish in `localName`.
|
|
71
|
+
*
|
|
72
|
+
* ```ts
|
|
73
|
+
* trHolidays.get({ start: "2026-10-01", end: "2026-10-31" });
|
|
74
|
+
* // [{ date: "2026-10-28", name: "Republic Day Eve", partial: { from: "13:00" }, … }, { date: "2026-10-29", … }]
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export const trHolidays = createHolidayProvider({
|
|
78
|
+
id: "tr",
|
|
79
|
+
holidays: trHolidaysForYear,
|
|
80
|
+
coverage: { ...TR_HOLIDAYS_SOURCE.coverage },
|
|
81
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turkish IBAN: 26 characters = "TR" + 2 check digits + 5-digit bank code + reserved "0" +
|
|
3
|
+
* 16-character account number.
|
|
4
|
+
*/
|
|
5
|
+
import { formatIban } from "../core/iban.js";
|
|
6
|
+
import type { IbanCountryRule, IdResult } from "../core/types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Bank names by 5-digit EFT participant code — the major banks only.
|
|
9
|
+
* TODO(data): replace with a table generated from the TCMB EFT participant list by script.
|
|
10
|
+
*/
|
|
11
|
+
export declare const TR_BANK_NAMES: Readonly<Record<string, string>>;
|
|
12
|
+
/** The 5-digit bank code of a TR IBAN ("TR33 0006 1…" → "00061"). */
|
|
13
|
+
export declare function trIbanBankCode(iban: string): string | undefined;
|
|
14
|
+
export declare const trIbanRule: IbanCountryRule;
|
|
15
|
+
/** Validates a Turkish IBAN (rejects other countries with `reason: "country"`). */
|
|
16
|
+
export declare function validateTrIban(value: string): IdResult & {
|
|
17
|
+
bankCode?: string;
|
|
18
|
+
bankName?: string;
|
|
19
|
+
};
|
|
20
|
+
/** Display format "TR33 0006 1005 1978 6457 8413 26". */
|
|
21
|
+
export declare const formatTrIban: typeof formatIban;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turkish IBAN: 26 characters = "TR" + 2 check digits + 5-digit bank code + reserved "0" +
|
|
3
|
+
* 16-character account number.
|
|
4
|
+
*/
|
|
5
|
+
import { formatIban, normalizeIban, validateIban } from "../core/iban.js";
|
|
6
|
+
/**
|
|
7
|
+
* Bank names by 5-digit EFT participant code — the major banks only.
|
|
8
|
+
* TODO(data): replace with a table generated from the TCMB EFT participant list by script.
|
|
9
|
+
*/
|
|
10
|
+
export const TR_BANK_NAMES = {
|
|
11
|
+
"00010": "Ziraat Bankası",
|
|
12
|
+
"00012": "Halkbank",
|
|
13
|
+
"00015": "VakıfBank",
|
|
14
|
+
"00046": "Akbank",
|
|
15
|
+
"00062": "Garanti BBVA",
|
|
16
|
+
"00064": "İşbank",
|
|
17
|
+
"00067": "Yapı Kredi",
|
|
18
|
+
"00111": "QNB",
|
|
19
|
+
"00134": "DenizBank",
|
|
20
|
+
"00205": "Kuveyt Türk",
|
|
21
|
+
};
|
|
22
|
+
/** The 5-digit bank code of a TR IBAN ("TR33 0006 1…" → "00061"). */
|
|
23
|
+
export function trIbanBankCode(iban) {
|
|
24
|
+
const v = normalizeIban(iban);
|
|
25
|
+
return v.startsWith("TR") && v.length >= 9 ? v.slice(4, 9) : undefined;
|
|
26
|
+
}
|
|
27
|
+
export const trIbanRule = {
|
|
28
|
+
country: "TR",
|
|
29
|
+
length: 26,
|
|
30
|
+
bban: /^\d{5}0[0-9A-Z]{16}$/,
|
|
31
|
+
bankName: (code) => TR_BANK_NAMES[code],
|
|
32
|
+
};
|
|
33
|
+
/** Validates a Turkish IBAN (rejects other countries with `reason: "country"`). */
|
|
34
|
+
export function validateTrIban(value) {
|
|
35
|
+
const v = normalizeIban(value);
|
|
36
|
+
if (v && !v.startsWith("TR") && /^[A-Z]{2}/.test(v))
|
|
37
|
+
return { valid: false, value: v, reason: "country" };
|
|
38
|
+
const r = validateIban(v, [trIbanRule]);
|
|
39
|
+
if (!r.valid)
|
|
40
|
+
return r;
|
|
41
|
+
const bankCode = v.slice(4, 9);
|
|
42
|
+
return { ...r, bankCode, bankName: TR_BANK_NAMES[bankCode] };
|
|
43
|
+
}
|
|
44
|
+
/** Display format "TR33 0006 1005 1978 6457 8413 26". */
|
|
45
|
+
export const formatTrIban = formatIban;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turkish identification numbers: TCKN (citizens), YKN (foreign residents, same checksum,
|
|
3
|
+
* starts with 99) and VKN (tax number). Includes the combined tax-id rule used on invoices,
|
|
4
|
+
* where sole proprietors invoice with their TCKN (UBL-TR `PartyIdentification@schemeID`).
|
|
5
|
+
*/
|
|
6
|
+
import type { IdResult, IdRule } from "../core/types.js";
|
|
7
|
+
/** The two TCKN check digits (d10, d11) for the first nine digits. */
|
|
8
|
+
export declare function tcknCheckDigits(first9: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Validates a TCKN or YKN.
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* validateTckn("10000000146"); // { valid: true, value: "10000000146", kind: "tr-tckn" }
|
|
14
|
+
* validateTckn("99000000068"); // { valid: true, …, kind: "tr-ykn" }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare function validateTckn(value: string): IdResult;
|
|
18
|
+
/** The VKN check digit (d10) for the first nine digits. */
|
|
19
|
+
export declare function vknCheckDigit(first9: string): string;
|
|
20
|
+
/** Validates a 10-digit VKN (vergi kimlik numarası). */
|
|
21
|
+
export declare function validateVkn(value: string): IdResult;
|
|
22
|
+
/**
|
|
23
|
+
* Invoice tax id: a 10-digit VKN or an 11-digit TCKN / YKN. `kind` maps to the e-invoice
|
|
24
|
+
* scheme (`tr-vkn` → `VKN`, `tr-tckn` / `tr-ykn` → `TCKN`).
|
|
25
|
+
*/
|
|
26
|
+
export declare function validateTrTaxId(value: string): IdResult;
|
|
27
|
+
/** UBL-TR `schemeID` for a valid tax id result. */
|
|
28
|
+
export declare function trTaxSchemeId(result: IdResult): "VKN" | "TCKN" | undefined;
|
|
29
|
+
/** Privacy mask for read-only views: first 3 and last 2 digits ("123******01"). */
|
|
30
|
+
export declare function maskTrId(value: string, visibleStart?: number, visibleEnd?: number): string;
|
|
31
|
+
/** TCKN / YKN rule for Formatted inputs. */
|
|
32
|
+
export declare const trTcknRule: IdRule;
|
|
33
|
+
/** VKN rule for Formatted inputs. */
|
|
34
|
+
export declare const trVknRule: IdRule;
|
|
35
|
+
/** Combined VKN-or-TCKN rule for invoice parties. */
|
|
36
|
+
export declare const trTaxIdRule: IdRule;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
const digitsOnly = (v) => v.replace(/[\s\-.]/g, "");
|
|
2
|
+
/** The two TCKN check digits (d10, d11) for the first nine digits. */
|
|
3
|
+
export function tcknCheckDigits(first9) {
|
|
4
|
+
const d = [...first9].map(Number);
|
|
5
|
+
if (d.length !== 9 || d.some((x) => !Number.isInteger(x)))
|
|
6
|
+
throw new RangeError("tcknCheckDigits: expected 9 digits");
|
|
7
|
+
const odd = d[0] + d[2] + d[4] + d[6] + d[8];
|
|
8
|
+
const even = d[1] + d[3] + d[5] + d[7];
|
|
9
|
+
const d10 = (((odd * 7 - even) % 10) + 10) % 10;
|
|
10
|
+
const d11 = (d.reduce((s, x) => s + x, 0) + d10) % 10;
|
|
11
|
+
return `${d10}${d11}`;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Validates a TCKN or YKN.
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* validateTckn("10000000146"); // { valid: true, value: "10000000146", kind: "tr-tckn" }
|
|
18
|
+
* validateTckn("99000000068"); // { valid: true, …, kind: "tr-ykn" }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export function validateTckn(value) {
|
|
22
|
+
const v = digitsOnly(value);
|
|
23
|
+
if (!v)
|
|
24
|
+
return { valid: false, value: v, reason: "empty" };
|
|
25
|
+
if (!/^\d+$/.test(v))
|
|
26
|
+
return { valid: false, value: v, reason: "chars" };
|
|
27
|
+
if (v.length !== 11)
|
|
28
|
+
return { valid: false, value: v, reason: "length" };
|
|
29
|
+
const kind = v.startsWith("99") ? "tr-ykn" : "tr-tckn";
|
|
30
|
+
if (v[0] === "0" || /^(\d)\1{10}$/.test(v))
|
|
31
|
+
return { valid: false, value: v, kind, reason: "pattern" };
|
|
32
|
+
if (tcknCheckDigits(v.slice(0, 9)) !== v.slice(9))
|
|
33
|
+
return { valid: false, value: v, kind, reason: "checksum" };
|
|
34
|
+
return { valid: true, value: v, kind };
|
|
35
|
+
}
|
|
36
|
+
/** The VKN check digit (d10) for the first nine digits. */
|
|
37
|
+
export function vknCheckDigit(first9) {
|
|
38
|
+
const d = [...first9].map(Number);
|
|
39
|
+
if (d.length !== 9 || d.some((x) => !Number.isInteger(x)))
|
|
40
|
+
throw new RangeError("vknCheckDigit: expected 9 digits");
|
|
41
|
+
let sum = 0;
|
|
42
|
+
for (let i = 0; i < 9; i++) {
|
|
43
|
+
const t = (d[i] + 9 - i) % 10;
|
|
44
|
+
let r = (t * 2 ** (9 - i)) % 9;
|
|
45
|
+
if (t !== 0 && r === 0)
|
|
46
|
+
r = 9;
|
|
47
|
+
sum += r;
|
|
48
|
+
}
|
|
49
|
+
return String((10 - (sum % 10)) % 10);
|
|
50
|
+
}
|
|
51
|
+
/** Validates a 10-digit VKN (vergi kimlik numarası). */
|
|
52
|
+
export function validateVkn(value) {
|
|
53
|
+
const v = digitsOnly(value);
|
|
54
|
+
if (!v)
|
|
55
|
+
return { valid: false, value: v, reason: "empty" };
|
|
56
|
+
if (!/^\d+$/.test(v))
|
|
57
|
+
return { valid: false, value: v, reason: "chars" };
|
|
58
|
+
if (v.length !== 10)
|
|
59
|
+
return { valid: false, value: v, reason: "length" };
|
|
60
|
+
if (vknCheckDigit(v.slice(0, 9)) !== v[9])
|
|
61
|
+
return { valid: false, value: v, kind: "tr-vkn", reason: "checksum" };
|
|
62
|
+
return { valid: true, value: v, kind: "tr-vkn" };
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Invoice tax id: a 10-digit VKN or an 11-digit TCKN / YKN. `kind` maps to the e-invoice
|
|
66
|
+
* scheme (`tr-vkn` → `VKN`, `tr-tckn` / `tr-ykn` → `TCKN`).
|
|
67
|
+
*/
|
|
68
|
+
export function validateTrTaxId(value) {
|
|
69
|
+
const v = digitsOnly(value);
|
|
70
|
+
if (v.length === 11)
|
|
71
|
+
return validateTckn(v);
|
|
72
|
+
if (v.length === 10)
|
|
73
|
+
return validateVkn(v);
|
|
74
|
+
if (!v)
|
|
75
|
+
return { valid: false, value: v, reason: "empty" };
|
|
76
|
+
return { valid: false, value: v, reason: /^\d+$/.test(v) ? "length" : "chars" };
|
|
77
|
+
}
|
|
78
|
+
/** UBL-TR `schemeID` for a valid tax id result. */
|
|
79
|
+
export function trTaxSchemeId(result) {
|
|
80
|
+
if (!result.valid)
|
|
81
|
+
return undefined;
|
|
82
|
+
return result.kind === "tr-vkn" ? "VKN" : "TCKN";
|
|
83
|
+
}
|
|
84
|
+
/** Privacy mask for read-only views: first 3 and last 2 digits ("123******01"). */
|
|
85
|
+
export function maskTrId(value, visibleStart = 3, visibleEnd = 2) {
|
|
86
|
+
const v = digitsOnly(value);
|
|
87
|
+
if (v.length <= visibleStart + visibleEnd)
|
|
88
|
+
return v;
|
|
89
|
+
return v.slice(0, visibleStart) + "*".repeat(v.length - visibleStart - visibleEnd) + v.slice(-visibleEnd);
|
|
90
|
+
}
|
|
91
|
+
/** TCKN / YKN rule for Formatted inputs. */
|
|
92
|
+
export const trTcknRule = {
|
|
93
|
+
id: "tr-tckn",
|
|
94
|
+
label: "Turkish ID number (TCKN)",
|
|
95
|
+
lengths: [11],
|
|
96
|
+
normalize: digitsOnly,
|
|
97
|
+
validate: validateTckn,
|
|
98
|
+
format: digitsOnly,
|
|
99
|
+
mask: (v) => maskTrId(v),
|
|
100
|
+
};
|
|
101
|
+
/** VKN rule for Formatted inputs. */
|
|
102
|
+
export const trVknRule = {
|
|
103
|
+
id: "tr-vkn",
|
|
104
|
+
label: "Turkish tax number (VKN)",
|
|
105
|
+
lengths: [10],
|
|
106
|
+
normalize: digitsOnly,
|
|
107
|
+
validate: validateVkn,
|
|
108
|
+
format: digitsOnly,
|
|
109
|
+
mask: (v) => maskTrId(v, 3, 2),
|
|
110
|
+
};
|
|
111
|
+
/** Combined VKN-or-TCKN rule for invoice parties. */
|
|
112
|
+
export const trTaxIdRule = {
|
|
113
|
+
id: "tr-tax-id",
|
|
114
|
+
label: "Tax number (VKN or TCKN)",
|
|
115
|
+
lengths: [10, 11],
|
|
116
|
+
normalize: digitsOnly,
|
|
117
|
+
validate: validateTrTaxId,
|
|
118
|
+
format: digitsOnly,
|
|
119
|
+
mask: (v) => maskTrId(v),
|
|
120
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { LocaleDataPack, WeekInfo, WorkCalendar } from "../core/types.js";
|
|
2
|
+
export { trHolidays, trHolidaysForYear, TR_HOLIDAYS_SOURCE, TR_RELIGIOUS_HOLIDAYS } from "./holidays.js";
|
|
3
|
+
export { validateTckn, validateVkn, validateTrTaxId, tcknCheckDigits, vknCheckDigit, trTaxSchemeId, maskTrId, trTcknRule, trVknRule, trTaxIdRule } from "./id.js";
|
|
4
|
+
export { validateTrIban, formatTrIban, trIbanBankCode, trIbanRule, TR_BANK_NAMES } from "./iban.js";
|
|
5
|
+
export { trKdv, TR_KDV_RATES, activeTaxRates, vatFromNet, netFromGross, grossFromNet, withheldVat, allocateProRata, computeKdv, needsExemptionCode, trNumberToWords, trAmountInWords, type KdvLineInput, type KdvLineResult, type KdvBreakdown, type KdvOptions, } from "./kdv.js";
|
|
6
|
+
export { loadTrAddressData, trProvinces, trDistricts, findTrProvince, checkTrPostalCode, trAddress, type TrAddressData, type TrAddressRow } from "./address.js";
|
|
7
|
+
/** Monday start, Saturday–Sunday weekend, minimal days 1 (CLDR "TR"). */
|
|
8
|
+
export declare const trWeekInfo: WeekInfo;
|
|
9
|
+
/** A ready work calendar: Mon–Fri, 09:00–18:00, Turkish public holidays. */
|
|
10
|
+
export declare const trWorkCalendar: WorkCalendar;
|
|
11
|
+
/** The full `tr` pack. */
|
|
12
|
+
export declare const trPack: LocaleDataPack;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// `tr` locale data pack: week info, holidays, ID / IBAN rules, KDV, address data. React-free.
|
|
2
|
+
import { weekInfoForRegion } from "../core/week-info.js";
|
|
3
|
+
import { trHolidays } from "./holidays.js";
|
|
4
|
+
import { trTaxIdRule, trTcknRule, trVknRule } from "./id.js";
|
|
5
|
+
import { trIbanRule } from "./iban.js";
|
|
6
|
+
import { trAmountInWords, trKdv } from "./kdv.js";
|
|
7
|
+
import { trAddress } from "./address.js";
|
|
8
|
+
export { trHolidays, trHolidaysForYear, TR_HOLIDAYS_SOURCE, TR_RELIGIOUS_HOLIDAYS } from "./holidays.js";
|
|
9
|
+
export { validateTckn, validateVkn, validateTrTaxId, tcknCheckDigits, vknCheckDigit, trTaxSchemeId, maskTrId, trTcknRule, trVknRule, trTaxIdRule } from "./id.js";
|
|
10
|
+
export { validateTrIban, formatTrIban, trIbanBankCode, trIbanRule, TR_BANK_NAMES } from "./iban.js";
|
|
11
|
+
export { trKdv, TR_KDV_RATES, activeTaxRates, vatFromNet, netFromGross, grossFromNet, withheldVat, allocateProRata, computeKdv, needsExemptionCode, trNumberToWords, trAmountInWords, } from "./kdv.js";
|
|
12
|
+
export { loadTrAddressData, trProvinces, trDistricts, findTrProvince, checkTrPostalCode, trAddress } from "./address.js";
|
|
13
|
+
/** Monday start, Saturday–Sunday weekend, minimal days 1 (CLDR "TR"). */
|
|
14
|
+
export const trWeekInfo = weekInfoForRegion("TR");
|
|
15
|
+
/** A ready work calendar: Mon–Fri, 09:00–18:00, Turkish public holidays. */
|
|
16
|
+
export const trWorkCalendar = {
|
|
17
|
+
locale: "tr-TR",
|
|
18
|
+
workDays: [1, 2, 3, 4, 5],
|
|
19
|
+
businessHours: [{ start: "09:00", end: "18:00" }],
|
|
20
|
+
holidays: trHolidays,
|
|
21
|
+
};
|
|
22
|
+
/** The full `tr` pack. */
|
|
23
|
+
export const trPack = {
|
|
24
|
+
code: "tr",
|
|
25
|
+
weekInfo: trWeekInfo,
|
|
26
|
+
holidays: trHolidays,
|
|
27
|
+
idRules: [trTcknRule, trVknRule, trTaxIdRule],
|
|
28
|
+
iban: [trIbanRule],
|
|
29
|
+
phone: { defaultCountry: "TR", displayFormat: "national" },
|
|
30
|
+
money: { currency: "TRY", suffixStyle: "local", amountInWords: trAmountInWords },
|
|
31
|
+
taxScheme: trKdv,
|
|
32
|
+
address: trAddress,
|
|
33
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { IsoDate, TaxRate, TaxScheme } from "../core/types.js";
|
|
2
|
+
/** Historic start dates are simplified to 2008-01-01: the kit only models rates from 2008 on. */
|
|
3
|
+
export declare const TR_KDV_RATES: TaxRate[];
|
|
4
|
+
/**
|
|
5
|
+
* KDV scheme. Exemption and withholding codes are a starter subset.
|
|
6
|
+
* TODO(data): generate the full lists from the GİB code lists and review them every January.
|
|
7
|
+
*/
|
|
8
|
+
export declare const trKdv: TaxScheme;
|
|
9
|
+
/** Rates in force on `date`. */
|
|
10
|
+
export declare function activeTaxRates(scheme: TaxScheme, date: IsoDate): TaxRate[];
|
|
11
|
+
/** VAT on a net amount, half-up to 2 places ("100.00" at 20 → "20.00"). */
|
|
12
|
+
export declare function vatFromNet(net: string, rate: number): string;
|
|
13
|
+
/** Net from a VAT-inclusive amount: `gross / (1 + rate)`, half-up ("120.00" at 20 → "100.00"). */
|
|
14
|
+
export declare function netFromGross(gross: string, rate: number): string;
|
|
15
|
+
/** Gross from net: `net + vatFromNet(net)`. */
|
|
16
|
+
export declare function grossFromNet(net: string, rate: number): string;
|
|
17
|
+
/** Withheld VAT: `vat × num / den`, half-up ("18.00" at 9/10 → "16.20"). */
|
|
18
|
+
export declare function withheldVat(vat: string, ratio: [number, number]): string;
|
|
19
|
+
/**
|
|
20
|
+
* Splits `total` across `weights` pro-rata, exact to the kuruş (largest remainder), so the
|
|
21
|
+
* parts always add up to `total`. Used to allocate a document discount to line bases.
|
|
22
|
+
*/
|
|
23
|
+
export declare function allocateProRata(total: string, weights: string[]): string[];
|
|
24
|
+
export interface KdvLineInput {
|
|
25
|
+
/** Decimal string; net or gross according to `entry`. Discounts already applied. */
|
|
26
|
+
amount: string;
|
|
27
|
+
/** Percent (20). */
|
|
28
|
+
rate: number;
|
|
29
|
+
entry?: "net" | "gross";
|
|
30
|
+
/** Withholding code from the scheme (e.g. "602"). */
|
|
31
|
+
withholding?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface KdvLineResult {
|
|
34
|
+
net: string;
|
|
35
|
+
vat: string;
|
|
36
|
+
gross: string;
|
|
37
|
+
withheld: string;
|
|
38
|
+
}
|
|
39
|
+
export interface KdvBreakdown {
|
|
40
|
+
lines: KdvLineResult[];
|
|
41
|
+
/** "KDV Matrahı (%20)" / "Hesaplanan KDV (%20)" rows. */
|
|
42
|
+
byRate: {
|
|
43
|
+
rate: number;
|
|
44
|
+
base: string;
|
|
45
|
+
vat: string;
|
|
46
|
+
}[];
|
|
47
|
+
/** "KDV Tevkifatı (9/10)" rows. */
|
|
48
|
+
withholding: {
|
|
49
|
+
code: string;
|
|
50
|
+
ratio: [number, number];
|
|
51
|
+
vat: string;
|
|
52
|
+
withheld: string;
|
|
53
|
+
}[];
|
|
54
|
+
totalNet: string;
|
|
55
|
+
totalVat: string;
|
|
56
|
+
totalWithheld: string;
|
|
57
|
+
/** Net + VAT. */
|
|
58
|
+
grandTotal: string;
|
|
59
|
+
/** Grand total − withheld VAT. */
|
|
60
|
+
payable: string;
|
|
61
|
+
}
|
|
62
|
+
export interface KdvOptions {
|
|
63
|
+
scheme?: TaxScheme;
|
|
64
|
+
/** Default: the scheme's (`"line"` for tr-kdv). */
|
|
65
|
+
rounding?: "line" | "document";
|
|
66
|
+
/** A document-level discount on the net total, allocated pro-rata to line bases. */
|
|
67
|
+
documentDiscount?: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Per-line and per-rate KDV totals with exact half-up rounding. One implementation for client
|
|
71
|
+
* and server.
|
|
72
|
+
*
|
|
73
|
+
* ```ts
|
|
74
|
+
* computeKdv([{ amount: "1000.00", rate: 20, withholding: "602" }]);
|
|
75
|
+
* // totalVat "200.00", totalWithheld "180.00", grandTotal "1200.00", payable "1020.00"
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export declare function computeKdv(lines: KdvLineInput[], options?: KdvOptions): KdvBreakdown;
|
|
79
|
+
/** True when a 0% line has the exemption code the scheme requires. */
|
|
80
|
+
export declare function needsExemptionCode(scheme: TaxScheme, rate: number, code?: string): boolean;
|
|
81
|
+
/** "1234" → "Bin İki Yüz Otuz Dört" (no "Bir" before "Bin" or "Yüz"). */
|
|
82
|
+
export declare function trNumberToWords(n: bigint): string;
|
|
83
|
+
/**
|
|
84
|
+
* Turkish amount in words for printed invoices.
|
|
85
|
+
*
|
|
86
|
+
* ```ts
|
|
87
|
+
* trAmountInWords("1234.50", "TRY"); // "Yalnız Bin İki Yüz Otuz Dört Türk Lirası Elli Kuruş"
|
|
88
|
+
* trAmountInWords("250", "USD"); // "Yalnız İki Yüz Elli ABD Doları"
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
export declare function trAmountInWords(decimal: string, currency?: string): string;
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turkish VAT (KDV): rates, exemption and withholding (tevkifat) codes, and exact decimal
|
|
3
|
+
* helpers for net / gross / VAT, withholding, document discounts and per-rate breakdowns.
|
|
4
|
+
*
|
|
5
|
+
* Rates are dated data: 0 / 1 / 10 / 20 % since 10 July 2023 (Presidential Decree 7346; 8 → 10
|
|
6
|
+
* and 18 → 20). Calculations do not replace an accountant's review. The rounding mode must match
|
|
7
|
+
* the e-invoice integrator's or documents get rejected.
|
|
8
|
+
*/
|
|
9
|
+
import { fromUnits, mulDivRound, toUnits } from "../core/decimal.js";
|
|
10
|
+
/** Historic start dates are simplified to 2008-01-01: the kit only models rates from 2008 on. */
|
|
11
|
+
export const TR_KDV_RATES = [
|
|
12
|
+
{ value: 0, label: "0%", validFrom: "2008-01-01" },
|
|
13
|
+
{ value: 1, label: "1%", validFrom: "2008-01-01" },
|
|
14
|
+
{ value: 8, label: "8%", validFrom: "2008-01-01", validTo: "2023-07-09" },
|
|
15
|
+
{ value: 18, label: "18%", validFrom: "2008-01-01", validTo: "2023-07-09" },
|
|
16
|
+
{ value: 10, label: "10%", validFrom: "2023-07-10" },
|
|
17
|
+
{ value: 20, label: "20%", validFrom: "2023-07-10" },
|
|
18
|
+
];
|
|
19
|
+
/**
|
|
20
|
+
* KDV scheme. Exemption and withholding codes are a starter subset.
|
|
21
|
+
* TODO(data): generate the full lists from the GİB code lists and review them every January.
|
|
22
|
+
*/
|
|
23
|
+
export const trKdv = {
|
|
24
|
+
id: "tr-kdv",
|
|
25
|
+
rates: TR_KDV_RATES,
|
|
26
|
+
zeroRateRequiresExemption: true,
|
|
27
|
+
exemptionCodes: [
|
|
28
|
+
{ code: "301", label: "Exports of goods (KDV Law 11/1-a)", localLabel: "11/1-a Mal ihracatı" },
|
|
29
|
+
{ code: "350", label: "Other exemptions", localLabel: "Diğer istisnalar" },
|
|
30
|
+
],
|
|
31
|
+
withholding: [
|
|
32
|
+
{ code: "601", label: "Construction works and related engineering services", localLabel: "Yapım işleri ile bu işlerle birlikte ifa edilen mühendislik-mimarlık ve etüt-proje hizmetleri", ratio: [4, 10] },
|
|
33
|
+
{ code: "602", label: "Survey, planning, consulting, audit and similar services", localLabel: "Etüt, plan-proje, danışmanlık, denetim ve benzeri hizmetler", ratio: [9, 10] },
|
|
34
|
+
{ code: "604", label: "Catering services", localLabel: "Yemek servis hizmeti", ratio: [5, 10] },
|
|
35
|
+
],
|
|
36
|
+
rounding: "line",
|
|
37
|
+
priceEntry: ["net", "gross"],
|
|
38
|
+
};
|
|
39
|
+
/** Rates in force on `date`. */
|
|
40
|
+
export function activeTaxRates(scheme, date) {
|
|
41
|
+
return scheme.rates.filter((r) => r.validFrom <= date && (!r.validTo || r.validTo >= date));
|
|
42
|
+
}
|
|
43
|
+
const S = 2; // money scale
|
|
44
|
+
const RS = 4; // rate scale
|
|
45
|
+
const HUNDRED = 100n * 10n ** BigInt(RS);
|
|
46
|
+
const rateUnits = (rate) => toUnits(String(rate), RS);
|
|
47
|
+
/** VAT on a net amount, half-up to 2 places ("100.00" at 20 → "20.00"). */
|
|
48
|
+
export function vatFromNet(net, rate) {
|
|
49
|
+
return fromUnits(mulDivRound(toUnits(net, S), rateUnits(rate), HUNDRED), S);
|
|
50
|
+
}
|
|
51
|
+
/** Net from a VAT-inclusive amount: `gross / (1 + rate)`, half-up ("120.00" at 20 → "100.00"). */
|
|
52
|
+
export function netFromGross(gross, rate) {
|
|
53
|
+
return fromUnits(mulDivRound(toUnits(gross, S), HUNDRED, HUNDRED + rateUnits(rate)), S);
|
|
54
|
+
}
|
|
55
|
+
/** Gross from net: `net + vatFromNet(net)`. */
|
|
56
|
+
export function grossFromNet(net, rate) {
|
|
57
|
+
const n = toUnits(net, S);
|
|
58
|
+
return fromUnits(n + mulDivRound(n, rateUnits(rate), HUNDRED), S);
|
|
59
|
+
}
|
|
60
|
+
/** Withheld VAT: `vat × num / den`, half-up ("18.00" at 9/10 → "16.20"). */
|
|
61
|
+
export function withheldVat(vat, ratio) {
|
|
62
|
+
return fromUnits(mulDivRound(toUnits(vat, S), BigInt(ratio[0]), BigInt(ratio[1])), S);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Splits `total` across `weights` pro-rata, exact to the kuruş (largest remainder), so the
|
|
66
|
+
* parts always add up to `total`. Used to allocate a document discount to line bases.
|
|
67
|
+
*/
|
|
68
|
+
export function allocateProRata(total, weights) {
|
|
69
|
+
const t = toUnits(total, S);
|
|
70
|
+
const neg = t < 0n;
|
|
71
|
+
const abs = neg ? -t : t;
|
|
72
|
+
const w = weights.map((x) => {
|
|
73
|
+
const u = toUnits(x, S);
|
|
74
|
+
return u < 0n ? -u : u;
|
|
75
|
+
});
|
|
76
|
+
const sum = w.reduce((a, b) => a + b, 0n);
|
|
77
|
+
if (w.length === 0)
|
|
78
|
+
return [];
|
|
79
|
+
const parts = sum === 0n ? w.map((_, i) => (i === 0 ? abs : 0n)) : w.map((x) => (abs * x) / sum);
|
|
80
|
+
if (sum !== 0n) {
|
|
81
|
+
let left = abs - parts.reduce((a, b) => a + b, 0n);
|
|
82
|
+
const order = w.map((x, i) => ({ i, r: (abs * x) % sum })).sort((a, b) => (b.r > a.r ? 1 : b.r < a.r ? -1 : a.i - b.i));
|
|
83
|
+
for (let k = 0; left > 0n; k++, left--)
|
|
84
|
+
parts[order[k % order.length].i] += 1n;
|
|
85
|
+
}
|
|
86
|
+
return parts.map((p) => fromUnits(neg ? -p : p, S));
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Per-line and per-rate KDV totals with exact half-up rounding. One implementation for client
|
|
90
|
+
* and server.
|
|
91
|
+
*
|
|
92
|
+
* ```ts
|
|
93
|
+
* computeKdv([{ amount: "1000.00", rate: 20, withholding: "602" }]);
|
|
94
|
+
* // totalVat "200.00", totalWithheld "180.00", grandTotal "1200.00", payable "1020.00"
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export function computeKdv(lines, options = {}) {
|
|
98
|
+
const scheme = options.scheme ?? trKdv;
|
|
99
|
+
const rounding = options.rounding ?? scheme.rounding;
|
|
100
|
+
const nets = lines.map((l) => (l.entry === "gross" ? netFromGross(l.amount, l.rate) : fromUnits(toUnits(l.amount, S), S)));
|
|
101
|
+
const discounts = options.documentDiscount ? allocateProRata(options.documentDiscount, nets) : nets.map(() => "0.00");
|
|
102
|
+
const ratioOf = (code) => (code ? scheme.withholding?.find((w) => w.code === code)?.ratio : undefined);
|
|
103
|
+
const out = lines.map((l, i) => {
|
|
104
|
+
const net = toUnits(nets[i], S) - toUnits(discounts[i], S);
|
|
105
|
+
// Gross entry without a document discount keeps the entered gross exactly.
|
|
106
|
+
const vat = l.entry === "gross" && !options.documentDiscount ? toUnits(l.amount, S) - net : mulDivRound(net, rateUnits(l.rate), HUNDRED);
|
|
107
|
+
const ratio = ratioOf(l.withholding);
|
|
108
|
+
const withheld = ratio ? mulDivRound(vat, BigInt(ratio[0]), BigInt(ratio[1])) : 0n;
|
|
109
|
+
return { net: fromUnits(net, S), vat: fromUnits(vat, S), gross: fromUnits(net + vat, S), withheld: fromUnits(withheld, S) };
|
|
110
|
+
});
|
|
111
|
+
const rateMap = new Map();
|
|
112
|
+
const whMap = new Map();
|
|
113
|
+
lines.forEach((l, i) => {
|
|
114
|
+
const r = rateMap.get(l.rate) ?? { base: 0n, vat: 0n };
|
|
115
|
+
r.base += toUnits(out[i].net, S);
|
|
116
|
+
r.vat += toUnits(out[i].vat, S);
|
|
117
|
+
rateMap.set(l.rate, r);
|
|
118
|
+
});
|
|
119
|
+
if (rounding === "document") {
|
|
120
|
+
for (const [rate, r] of rateMap)
|
|
121
|
+
r.vat = mulDivRound(r.base, rateUnits(rate), HUNDRED);
|
|
122
|
+
}
|
|
123
|
+
lines.forEach((l, i) => {
|
|
124
|
+
const ratio = ratioOf(l.withholding);
|
|
125
|
+
if (!ratio || !l.withholding)
|
|
126
|
+
return;
|
|
127
|
+
const w = whMap.get(l.withholding) ?? { ratio, vat: 0n, withheld: 0n };
|
|
128
|
+
w.vat += toUnits(out[i].vat, S);
|
|
129
|
+
w.withheld += toUnits(out[i].withheld, S);
|
|
130
|
+
whMap.set(l.withholding, w);
|
|
131
|
+
});
|
|
132
|
+
if (rounding === "document")
|
|
133
|
+
for (const w of whMap.values())
|
|
134
|
+
w.withheld = mulDivRound(w.vat, BigInt(w.ratio[0]), BigInt(w.ratio[1]));
|
|
135
|
+
const totalNet = [...rateMap.values()].reduce((s, r) => s + r.base, 0n);
|
|
136
|
+
const totalVat = [...rateMap.values()].reduce((s, r) => s + r.vat, 0n);
|
|
137
|
+
const totalWithheld = [...whMap.values()].reduce((s, w) => s + w.withheld, 0n);
|
|
138
|
+
return {
|
|
139
|
+
lines: out,
|
|
140
|
+
byRate: [...rateMap].sort((a, b) => b[0] - a[0]).map(([rate, r]) => ({ rate, base: fromUnits(r.base, S), vat: fromUnits(r.vat, S) })),
|
|
141
|
+
withholding: [...whMap].map(([code, w]) => ({ code, ratio: w.ratio, vat: fromUnits(w.vat, S), withheld: fromUnits(w.withheld, S) })),
|
|
142
|
+
totalNet: fromUnits(totalNet, S),
|
|
143
|
+
totalVat: fromUnits(totalVat, S),
|
|
144
|
+
totalWithheld: fromUnits(totalWithheld, S),
|
|
145
|
+
grandTotal: fromUnits(totalNet + totalVat, S),
|
|
146
|
+
payable: fromUnits(totalNet + totalVat - totalWithheld, S),
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
/** True when a 0% line has the exemption code the scheme requires. */
|
|
150
|
+
export function needsExemptionCode(scheme, rate, code) {
|
|
151
|
+
return rate === 0 && !!scheme.zeroRateRequiresExemption && !scheme.exemptionCodes?.some((c) => c.code === code);
|
|
152
|
+
}
|
|
153
|
+
// ---------------------------------------------------------------------------------------------
|
|
154
|
+
// Amount in words (required on printed Turkish invoices)
|
|
155
|
+
// ---------------------------------------------------------------------------------------------
|
|
156
|
+
const ONES = ["", "Bir", "İki", "Üç", "Dört", "Beş", "Altı", "Yedi", "Sekiz", "Dokuz"];
|
|
157
|
+
const TENS = ["", "On", "Yirmi", "Otuz", "Kırk", "Elli", "Altmış", "Yetmiş", "Seksen", "Doksan"];
|
|
158
|
+
const SCALES = ["", "Bin", "Milyon", "Milyar", "Trilyon", "Katrilyon"];
|
|
159
|
+
function threeDigits(n) {
|
|
160
|
+
const h = Math.floor(n / 100);
|
|
161
|
+
const t = Math.floor((n % 100) / 10);
|
|
162
|
+
const o = n % 10;
|
|
163
|
+
const out = [];
|
|
164
|
+
if (h)
|
|
165
|
+
out.push(...(h > 1 ? [ONES[h]] : []), "Yüz");
|
|
166
|
+
if (t)
|
|
167
|
+
out.push(TENS[t]);
|
|
168
|
+
if (o)
|
|
169
|
+
out.push(ONES[o]);
|
|
170
|
+
return out;
|
|
171
|
+
}
|
|
172
|
+
/** "1234" → "Bin İki Yüz Otuz Dört" (no "Bir" before "Bin" or "Yüz"). */
|
|
173
|
+
export function trNumberToWords(n) {
|
|
174
|
+
if (n === 0n)
|
|
175
|
+
return "Sıfır";
|
|
176
|
+
const neg = n < 0n;
|
|
177
|
+
let v = neg ? -n : n;
|
|
178
|
+
const groups = [];
|
|
179
|
+
while (v > 0n) {
|
|
180
|
+
groups.push(Number(v % 1000n));
|
|
181
|
+
v /= 1000n;
|
|
182
|
+
}
|
|
183
|
+
if (groups.length > SCALES.length)
|
|
184
|
+
throw new RangeError("trNumberToWords: number too large");
|
|
185
|
+
const words = [];
|
|
186
|
+
for (let i = groups.length - 1; i >= 0; i--) {
|
|
187
|
+
const g = groups[i];
|
|
188
|
+
if (!g)
|
|
189
|
+
continue;
|
|
190
|
+
if (i === 1 && g === 1)
|
|
191
|
+
words.push("Bin");
|
|
192
|
+
else
|
|
193
|
+
words.push(...threeDigits(g), ...(SCALES[i] ? [SCALES[i]] : []));
|
|
194
|
+
}
|
|
195
|
+
return (neg ? "Eksi " : "") + words.join(" ");
|
|
196
|
+
}
|
|
197
|
+
const CURRENCY_TR = {
|
|
198
|
+
TRY: ["Türk Lirası", "Kuruş"],
|
|
199
|
+
USD: ["ABD Doları", "Sent"],
|
|
200
|
+
EUR: ["Avro", "Sent"],
|
|
201
|
+
GBP: ["İngiliz Sterlini", "Peni"],
|
|
202
|
+
CHF: ["İsviçre Frangı", "Santim"],
|
|
203
|
+
};
|
|
204
|
+
/**
|
|
205
|
+
* Turkish amount in words for printed invoices.
|
|
206
|
+
*
|
|
207
|
+
* ```ts
|
|
208
|
+
* trAmountInWords("1234.50", "TRY"); // "Yalnız Bin İki Yüz Otuz Dört Türk Lirası Elli Kuruş"
|
|
209
|
+
* trAmountInWords("250", "USD"); // "Yalnız İki Yüz Elli ABD Doları"
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
export function trAmountInWords(decimal, currency = "TRY") {
|
|
213
|
+
const units = toUnits(decimal, 2);
|
|
214
|
+
const abs = units < 0n ? -units : units;
|
|
215
|
+
const major = abs / 100n;
|
|
216
|
+
const minor = Number(abs % 100n);
|
|
217
|
+
const [majorName, minorName] = CURRENCY_TR[currency.toUpperCase()] ?? [currency.toUpperCase(), ""];
|
|
218
|
+
let out = `Yalnız ${units < 0n ? "Eksi " : ""}${trNumberToWords(major)} ${majorName}`;
|
|
219
|
+
if (minor)
|
|
220
|
+
out += ` ${trNumberToWords(BigInt(minor))}${minorName ? ` ${minorName}` : ""}`;
|
|
221
|
+
return out;
|
|
222
|
+
}
|