@eifi1/ui-kit 0.4.1 → 0.5.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 +32 -0
- package/README.md +498 -57
- package/dist/chart.d.ts +10 -0
- package/dist/chart.js +10 -0
- package/dist/chart.js.map +1 -0
- package/dist/components/account-settings.d.ts +11 -0
- package/dist/components/account-settings.js +19 -12
- package/dist/components/account-settings.js.map +1 -1
- package/dist/components/alert-banner.d.ts +10 -6
- package/dist/components/alert-banner.js +20 -16
- package/dist/components/alert-banner.js.map +1 -1
- package/dist/components/amount-input.d.ts +30 -4
- package/dist/components/amount-input.js +36 -14
- package/dist/components/amount-input.js.map +1 -1
- package/dist/components/calculator.d.ts +24 -7
- package/dist/components/calculator.js +37 -20
- package/dist/components/calculator.js.map +1 -1
- package/dist/components/chart-zoom.d.ts +156 -0
- package/dist/components/chart-zoom.js +262 -0
- package/dist/components/chart-zoom.js.map +1 -0
- package/dist/components/chart.d.ts +28 -3
- package/dist/components/chart.js +71 -32
- package/dist/components/chart.js.map +1 -1
- package/dist/components/checkbox.d.ts +51 -0
- package/dist/components/checkbox.js +123 -0
- package/dist/components/checkbox.js.map +1 -0
- package/dist/components/chip.d.ts +128 -0
- package/dist/components/chip.js +357 -0
- package/dist/components/chip.js.map +1 -0
- package/dist/components/choice-parts.d.ts +24 -0
- package/dist/components/choice-parts.js +18 -0
- package/dist/components/choice-parts.js.map +1 -0
- package/dist/components/combobox-core.d.ts +52 -9
- package/dist/components/combobox-core.js +89 -19
- package/dist/components/combobox-core.js.map +1 -1
- package/dist/components/combobox.d.ts +43 -33
- package/dist/components/combobox.js +409 -340
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/currency-select.d.ts +48 -8
- package/dist/components/currency-select.js +107 -65
- package/dist/components/currency-select.js.map +1 -1
- package/dist/components/data-table-filter-popover.d.ts +15 -3
- package/dist/components/data-table-filter-popover.js +23 -17
- package/dist/components/data-table-filter-popover.js.map +1 -1
- package/dist/components/data-table-filters.d.ts +1 -1
- package/dist/components/data-table-filters.js +3 -2
- package/dist/components/data-table-filters.js.map +1 -1
- package/dist/components/data-table-labels.d.ts +53 -2
- package/dist/components/data-table-labels.js +31 -2
- package/dist/components/data-table-labels.js.map +1 -1
- package/dist/components/data-table-pagination.d.ts +3 -1
- package/dist/components/data-table-pagination.js +16 -10
- package/dist/components/data-table-pagination.js.map +1 -1
- package/dist/components/data-table-sort.js +1 -0
- package/dist/components/data-table-sort.js.map +1 -1
- package/dist/components/data-table.d.ts +1 -1
- package/dist/components/data-table.js +201 -85
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/date-picker.d.ts +25 -9
- package/dist/components/date-picker.js +232 -94
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/dropdown.d.ts +74 -19
- package/dist/components/dropdown.js +72 -22
- package/dist/components/dropdown.js.map +1 -1
- package/dist/components/entity-combobox.d.ts +5 -4
- package/dist/components/entity-combobox.js +107 -76
- package/dist/components/entity-combobox.js.map +1 -1
- package/dist/components/facing-pair.d.ts +36 -0
- package/dist/components/facing-pair.js +40 -0
- package/dist/components/facing-pair.js.map +1 -0
- package/dist/components/field-sync.d.ts +164 -0
- package/dist/components/field-sync.js +264 -0
- package/dist/components/field-sync.js.map +1 -0
- package/dist/components/file-dropzone.d.ts +21 -7
- package/dist/components/file-dropzone.js +28 -7
- package/dist/components/file-dropzone.js.map +1 -1
- package/dist/components/full-bleed-dialog.d.ts +37 -26
- package/dist/components/full-bleed-dialog.js +20 -5
- package/dist/components/full-bleed-dialog.js.map +1 -1
- package/dist/components/grouped-picker.d.ts +21 -10
- package/dist/components/grouped-picker.js +66 -52
- package/dist/components/grouped-picker.js.map +1 -1
- package/dist/components/hover-menu.d.ts +20 -4
- package/dist/components/hover-menu.js +15 -4
- package/dist/components/hover-menu.js.map +1 -1
- package/dist/components/mini-calendar.d.ts +102 -14
- package/dist/components/mini-calendar.js +256 -70
- package/dist/components/mini-calendar.js.map +1 -1
- package/dist/components/modal.d.ts +9 -3
- package/dist/components/modal.js +34 -45
- package/dist/components/modal.js.map +1 -1
- package/dist/components/month-picker.d.ts +79 -0
- package/dist/components/month-picker.js +342 -0
- package/dist/components/month-picker.js.map +1 -0
- package/dist/components/multi-entity-combobox.d.ts +7 -6
- package/dist/components/multi-entity-combobox.js +112 -72
- package/dist/components/multi-entity-combobox.js.map +1 -1
- package/dist/components/multi-select.d.ts +13 -11
- package/dist/components/multi-select.js +161 -84
- package/dist/components/multi-select.js.map +1 -1
- package/dist/components/number-field.d.ts +92 -0
- package/dist/components/number-field.js +111 -0
- package/dist/components/number-field.js.map +1 -0
- package/dist/components/number-input.d.ts +21 -2
- package/dist/components/number-input.js +2 -1
- package/dist/components/number-input.js.map +1 -1
- package/dist/components/numpad-sheet.d.ts +25 -4
- package/dist/components/numpad-sheet.js +30 -13
- package/dist/components/numpad-sheet.js.map +1 -1
- package/dist/components/page-contents.d.ts +90 -0
- package/dist/components/page-contents.js +170 -0
- package/dist/components/page-contents.js.map +1 -0
- package/dist/components/password-strength.d.ts +106 -0
- package/dist/components/password-strength.js +132 -0
- package/dist/components/password-strength.js.map +1 -0
- package/dist/components/picker-sheet.d.ts +23 -15
- package/dist/components/picker-sheet.js +34 -14
- package/dist/components/picker-sheet.js.map +1 -1
- package/dist/components/popover.d.ts +62 -4
- package/dist/components/popover.js +52 -2
- package/dist/components/popover.js.map +1 -1
- package/dist/components/search-field.d.ts +25 -7
- package/dist/components/search-field.js +7 -5
- package/dist/components/search-field.js.map +1 -1
- package/dist/components/series-chart-labels.d.ts +14 -0
- package/dist/components/series-chart-labels.js +11 -0
- package/dist/components/series-chart-labels.js.map +1 -0
- package/dist/components/series-chart.d.ts +207 -0
- package/dist/components/series-chart.js +223 -0
- package/dist/components/series-chart.js.map +1 -0
- package/dist/components/settings-fields.d.ts +14 -4
- package/dist/components/settings-fields.js +19 -8
- package/dist/components/settings-fields.js.map +1 -1
- package/dist/components/signature-pad.d.ts +119 -0
- package/dist/components/signature-pad.js +405 -0
- package/dist/components/signature-pad.js.map +1 -0
- package/dist/components/slider.d.ts +80 -0
- package/dist/components/slider.js +155 -0
- package/dist/components/slider.js.map +1 -0
- package/dist/components/sparkline.d.ts +93 -0
- package/dist/components/sparkline.js +205 -0
- package/dist/components/sparkline.js.map +1 -0
- package/dist/components/stat-tile.d.ts +151 -0
- package/dist/components/stat-tile.js +236 -0
- package/dist/components/stat-tile.js.map +1 -0
- package/dist/components/swipeable-row.d.ts +25 -2
- package/dist/components/swipeable-row.js +31 -0
- package/dist/components/swipeable-row.js.map +1 -1
- package/dist/components/switch.d.ts +60 -0
- package/dist/components/switch.js +81 -0
- package/dist/components/switch.js.map +1 -0
- package/dist/components/time-input.d.ts +58 -0
- package/dist/components/time-input.js +50 -0
- package/dist/components/time-input.js.map +1 -0
- package/dist/components/toggle-group.d.ts +18 -3
- package/dist/components/toggle-group.js +10 -6
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/toggle-legend.d.ts +115 -0
- package/dist/components/toggle-legend.js +114 -0
- package/dist/components/toggle-legend.js.map +1 -0
- package/dist/components/tooltip.d.ts +40 -11
- package/dist/components/tooltip.js +77 -20
- package/dist/components/tooltip.js.map +1 -1
- package/dist/components/treemap.d.ts +132 -0
- package/dist/components/treemap.js +179 -0
- package/dist/components/treemap.js.map +1 -0
- package/dist/components/ui.d.ts +159 -46
- package/dist/components/ui.js +220 -115
- package/dist/components/ui.js.map +1 -1
- package/dist/components/use-mobile-reveal.js +1 -0
- package/dist/components/use-mobile-reveal.js.map +1 -1
- package/dist/components/use-table-state.d.ts +1 -1
- package/dist/components/use-table-state.js +38 -17
- package/dist/components/use-table-state.js.map +1 -1
- package/dist/components/user-avatar.d.ts +5 -3
- package/dist/components/user-avatar.js +4 -2
- package/dist/components/user-avatar.js.map +1 -1
- package/dist/components/wizard-stepper.js +3 -2
- package/dist/components/wizard-stepper.js.map +1 -1
- package/dist/{data-table-filters-aXyf0Xub.d.ts → data-table-filters-DM1auUfH.d.ts} +27 -5
- package/dist/data-table.d.ts +7 -0
- package/dist/data-table.js +12 -0
- package/dist/data-table.js.map +1 -0
- package/dist/feedback/feedback-attachment.js +12 -11
- package/dist/feedback/feedback-attachment.js.map +1 -1
- package/dist/feedback/feedback-dialog.js +2 -1
- package/dist/feedback/feedback-dialog.js.map +1 -1
- package/dist/feedback/feedback-inbox.d.ts +33 -7
- package/dist/feedback/feedback-inbox.js +49 -37
- package/dist/feedback/feedback-inbox.js.map +1 -1
- package/dist/feedback.d.ts +5 -0
- package/dist/feedback.js +5 -0
- package/dist/feedback.js.map +1 -0
- package/dist/hooks/use-anchored-panel.js +1 -0
- package/dist/hooks/use-anchored-panel.js.map +1 -1
- package/dist/hooks/use-anchored-rect.js +1 -0
- package/dist/hooks/use-anchored-rect.js.map +1 -1
- package/dist/hooks/use-announce.d.ts +46 -0
- package/dist/hooks/use-announce.js +37 -0
- package/dist/hooks/use-announce.js.map +1 -0
- package/dist/hooks/use-body-scroll-lock.js +1 -0
- package/dist/hooks/use-body-scroll-lock.js.map +1 -1
- package/dist/hooks/use-close-transition.js +1 -0
- package/dist/hooks/use-close-transition.js.map +1 -1
- package/dist/hooks/use-dismiss.js +1 -0
- package/dist/hooks/use-dismiss.js.map +1 -1
- package/dist/hooks/use-focus-trap.d.ts +16 -0
- package/dist/hooks/use-focus-trap.js +67 -0
- package/dist/hooks/use-focus-trap.js.map +1 -0
- package/dist/hooks/use-media-query.js +1 -0
- package/dist/hooks/use-media-query.js.map +1 -1
- package/dist/hooks/use-overlay-history.js +27 -1
- package/dist/hooks/use-overlay-history.js.map +1 -1
- package/dist/hooks/use-row-swipe.js +1 -0
- package/dist/hooks/use-row-swipe.js.map +1 -1
- package/dist/i18n/defaults.d.ts +31 -0
- package/dist/i18n/defaults.js +63 -0
- package/dist/i18n/defaults.js.map +1 -0
- package/dist/i18n/kit-labels.d.ts +250 -0
- package/dist/i18n/kit-labels.js +184 -0
- package/dist/i18n/kit-labels.js.map +1 -0
- package/dist/index.d.ts +47 -22
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/calc.js +1 -0
- package/dist/lib/calc.js.map +1 -1
- package/dist/lib/cn.js +1 -0
- package/dist/lib/cn.js.map +1 -1
- package/dist/lib/dates.js +1 -0
- package/dist/lib/dates.js.map +1 -1
- package/dist/lib/logger.js +1 -0
- package/dist/lib/logger.js.map +1 -1
- package/dist/lib/safe-storage.js +1 -0
- package/dist/lib/safe-storage.js.map +1 -1
- package/dist/search/command-palette.d.ts +11 -1
- package/dist/search/command-palette.js +21 -15
- package/dist/search/command-palette.js.map +1 -1
- package/dist/search.d.ts +2 -0
- package/dist/search.js +3 -0
- package/dist/search.js.map +1 -0
- package/dist/shell/app-shell.d.ts +33 -4
- package/dist/shell/app-shell.js +275 -78
- package/dist/shell/app-shell.js.map +1 -1
- package/dist/shell/option-switcher-menu.js +3 -2
- package/dist/shell/option-switcher-menu.js.map +1 -1
- package/dist/shell/role-switcher.d.ts +6 -0
- package/dist/shell/role-switcher.js +7 -4
- package/dist/shell/role-switcher.js.map +1 -1
- package/dist/shell/top-bar.d.ts +15 -7
- package/dist/shell/top-bar.js +3 -5
- package/dist/shell/top-bar.js.map +1 -1
- package/dist/shell/topbar-action-menu.js +3 -2
- package/dist/shell/topbar-action-menu.js.map +1 -1
- package/dist/shell/topbar-controls.d.ts +5 -2
- package/dist/shell/topbar-controls.js +20 -15
- package/dist/shell/topbar-controls.js.map +1 -1
- package/dist/shell.d.ts +13 -0
- package/dist/shell.js +8 -0
- package/dist/shell.js.map +1 -0
- package/dist/theme/chart-palette.d.ts +19 -12
- package/dist/theme/chart-palette.js +24 -30
- package/dist/theme/chart-palette.js.map +1 -1
- package/dist/theme/color.d.ts +78 -0
- package/dist/theme/color.js +148 -0
- package/dist/theme/color.js.map +1 -0
- package/dist/theme/palette-derive.d.ts +140 -0
- package/dist/theme/palette-derive.js +376 -0
- package/dist/theme/palette-derive.js.map +1 -0
- package/dist/theme/palette-presets.d.ts +14 -1
- package/dist/theme/palette-presets.js +231 -3
- package/dist/theme/palette-presets.js.map +1 -1
- package/dist/theme/palette-store.js +1 -0
- package/dist/theme/palette-store.js.map +1 -1
- package/dist/theme/theme-store.js +1 -0
- package/dist/theme/theme-store.js.map +1 -1
- package/dist/tour/tour.d.ts +2 -1
- package/dist/tour/tour.js +15 -9
- package/dist/tour/tour.js.map +1 -1
- package/dist/tour.d.ts +2 -0
- package/dist/tour.js +3 -0
- package/dist/tour.js.map +1 -0
- package/dist/wizard/stepper-nav.js +10 -8
- package/dist/wizard/stepper-nav.js.map +1 -1
- package/dist/wizard/types.d.ts +18 -2
- package/dist/wizard/types.js +4 -1
- package/dist/wizard/types.js.map +1 -1
- package/dist/wizard/use-wizard.js +12 -4
- package/dist/wizard/use-wizard.js.map +1 -1
- package/dist/wizard/validation.js +1 -0
- package/dist/wizard/validation.js.map +1 -1
- package/dist/wizard/wizard-context.js +1 -0
- package/dist/wizard/wizard-context.js.map +1 -1
- package/dist/wizard/wizard-step.js +1 -0
- package/dist/wizard/wizard-step.js.map +1 -1
- package/dist/wizard/wizard-summary.js +5 -3
- package/dist/wizard/wizard-summary.js.map +1 -1
- package/dist/wizard.d.ts +8 -0
- package/dist/wizard.js +9 -0
- package/dist/wizard.js.map +1 -0
- package/package.json +66 -13
- package/src/chart.ts +22 -0
- package/src/components/account-settings.tsx +275 -0
- package/src/components/alert-banner.tsx +75 -0
- package/src/components/amount-input.tsx +471 -0
- package/src/components/calculator.tsx +252 -0
- package/src/components/chart-zoom.tsx +499 -0
- package/src/components/chart.tsx +363 -0
- package/src/components/checkbox.tsx +222 -0
- package/src/components/chip.tsx +570 -0
- package/src/components/choice-parts.ts +33 -0
- package/src/components/combobox-core.tsx +540 -0
- package/src/components/combobox.tsx +1026 -0
- package/src/components/currency-select.tsx +269 -0
- package/src/components/data-table-filter-popover.tsx +252 -0
- package/src/components/data-table-filters.ts +176 -0
- package/src/components/data-table-labels.ts +190 -0
- package/src/components/data-table-pagination.tsx +126 -0
- package/src/components/data-table-sort.ts +70 -0
- package/src/components/data-table.tsx +1740 -0
- package/src/components/date-picker.tsx +631 -0
- package/src/components/dropdown.tsx +341 -0
- package/src/components/entity-combobox.tsx +215 -0
- package/src/components/facing-pair.ts +86 -0
- package/src/components/field-sync.tsx +472 -0
- package/src/components/file-dropzone.tsx +181 -0
- package/src/components/full-bleed-dialog.tsx +179 -0
- package/src/components/grouped-picker.tsx +157 -0
- package/src/components/hover-menu.tsx +183 -0
- package/src/components/mini-calendar.tsx +554 -0
- package/src/components/modal.tsx +287 -0
- package/src/components/month-picker.tsx +549 -0
- package/src/components/multi-entity-combobox.tsx +226 -0
- package/src/components/multi-select.tsx +303 -0
- package/src/components/number-field.tsx +225 -0
- package/src/components/number-input.tsx +211 -0
- package/src/components/numpad-sheet.tsx +264 -0
- package/src/components/page-contents.tsx +289 -0
- package/src/components/password-strength.tsx +258 -0
- package/src/components/picker-sheet.tsx +251 -0
- package/src/components/popover.tsx +195 -0
- package/src/components/search-field.tsx +146 -0
- package/src/components/series-chart-labels.ts +26 -0
- package/src/components/series-chart.tsx +481 -0
- package/src/components/settings-fields.tsx +68 -0
- package/src/components/signature-pad.tsx +630 -0
- package/src/components/slider.tsx +313 -0
- package/src/components/sparkline.tsx +329 -0
- package/src/components/stat-tile.tsx +448 -0
- package/src/components/swipeable-row.tsx +271 -0
- package/src/components/switch.tsx +170 -0
- package/src/components/time-input.tsx +107 -0
- package/src/components/toggle-group.tsx +153 -0
- package/src/components/toggle-legend.tsx +229 -0
- package/src/components/tooltip.tsx +477 -0
- package/src/components/treemap.tsx +390 -0
- package/src/components/ui.tsx +1284 -0
- package/src/components/use-mobile-reveal.ts +54 -0
- package/src/components/use-table-state.ts +295 -0
- package/src/components/user-avatar.tsx +61 -0
- package/src/components/wizard-stepper.tsx +37 -0
- package/src/data-table.ts +19 -0
- package/src/feedback/feedback-attachment.tsx +246 -0
- package/src/feedback/feedback-dialog.tsx +209 -0
- package/src/feedback/feedback-inbox.tsx +615 -0
- package/src/feedback.ts +8 -0
- package/src/hooks/use-anchored-panel.ts +169 -0
- package/src/hooks/use-anchored-rect.ts +78 -0
- package/src/hooks/use-announce.ts +85 -0
- package/src/hooks/use-body-scroll-lock.ts +94 -0
- package/src/hooks/use-close-transition.ts +99 -0
- package/src/hooks/use-dismiss.ts +77 -0
- package/src/hooks/use-focus-trap.ts +160 -0
- package/src/hooks/use-media-query.ts +23 -0
- package/src/hooks/use-overlay-history.ts +345 -0
- package/src/hooks/use-row-swipe.ts +212 -0
- package/src/i18n/defaults.ts +68 -0
- package/src/i18n/kit-labels.tsx +447 -0
- package/src/index.ts +169 -0
- package/src/lib/calc.ts +309 -0
- package/src/lib/cn.ts +5 -0
- package/src/lib/dates.ts +187 -0
- package/src/lib/logger.ts +73 -0
- package/src/lib/safe-storage.ts +37 -0
- package/src/search/command-palette.tsx +342 -0
- package/src/search.ts +3 -0
- package/src/shell/app-shell.tsx +772 -0
- package/src/shell/option-switcher-menu.tsx +72 -0
- package/src/shell/role-switcher.tsx +46 -0
- package/src/shell/top-bar.tsx +39 -0
- package/src/shell/topbar-action-menu.tsx +91 -0
- package/src/shell/topbar-controls.tsx +229 -0
- package/src/shell.ts +10 -0
- package/src/theme/chart-palette.ts +145 -0
- package/src/theme/color.ts +266 -0
- package/src/theme/palette-derive.ts +681 -0
- package/src/theme/palette-presets.ts +760 -0
- package/src/theme/palette-store.ts +94 -0
- package/src/theme/theme-store.ts +145 -0
- package/src/tour/tour.tsx +586 -0
- package/src/tour.ts +3 -0
- package/src/vite-env.d.ts +26 -0
- package/src/wizard/stepper-nav.tsx +221 -0
- package/src/wizard/types.ts +178 -0
- package/src/wizard/use-wizard.ts +345 -0
- package/src/wizard/validation.ts +37 -0
- package/src/wizard/wizard-context.tsx +29 -0
- package/src/wizard/wizard-step.tsx +14 -0
- package/src/wizard/wizard-summary.tsx +69 -0
- package/src/wizard.ts +14 -0
- package/tokens.css +222 -20
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A drawn signature, captured on a canvas and handed back as a PNG data URL.
|
|
6
|
+
*
|
|
7
|
+
* Kastlan wrote the first one (`features/handover/components/signature-pad.tsx`) for
|
|
8
|
+
* the handover protocol, where tenant and inspector each sign on the same phone. This
|
|
9
|
+
* keeps its contract — draw, get a PNG — and fixes what a copy per app would keep
|
|
10
|
+
* getting wrong:
|
|
11
|
+
*
|
|
12
|
+
* 1. **Strokes are data, not pixels.** Each stroke is kept as a list of points, and
|
|
13
|
+
* the canvas is a VIEW of them. That is what lets a resize (a phone rotating
|
|
14
|
+
* mid-signature) keep the drawing instead of wiping it — setting `canvas.width`
|
|
15
|
+
* clears the bitmap, so a pixels-only pad loses everything — and what makes undo
|
|
16
|
+
* one `pop()`. The pixel buffer is sized to `devicePixelRatio`, so a stroke is
|
|
17
|
+
* sharp on a 3× screen rather than upscaled from a 1× bitmap.
|
|
18
|
+
* 2. **Smooth, and pressure-aware.** Segments are quadratic curves through the
|
|
19
|
+
* midpoints between samples, so a fast stroke is a curve, not a polyline; a pen
|
|
20
|
+
* that reports pressure varies the width, a mouse or finger (whose `pressure` is a
|
|
21
|
+
* constant 0.5, or junk) draws at the base width.
|
|
22
|
+
* 3. **Two inks.** On screen the ink is the computed `color` of the canvas, which is
|
|
23
|
+
* `--text-primary` — so it reads in the dark theme, where a hard-coded near-black
|
|
24
|
+
* stroke vanished into the surface. The exported PNG is re-rendered from the same
|
|
25
|
+
* strokes in `exportInk` (near-black by default) on a transparent background. A
|
|
26
|
+
* signature is a DOCUMENT artefact: it is printed on the protocol, shown on a white
|
|
27
|
+
* card, embedded in a PDF — none of which follow the signer's theme. Exporting
|
|
28
|
+
* the on-screen ink would have produced a pale-grey-on-transparent PNG for every
|
|
29
|
+
* dark-mode signer, invisible on white paper.
|
|
30
|
+
*
|
|
31
|
+
* **Accessibility.** A canvas has no content a screen reader or a keyboard can reach,
|
|
32
|
+
* and no amount of ARIA changes that — drawing is a pointer act. What the pad does:
|
|
33
|
+
* the canvas is `role="img"`, named by the visible label and described by the
|
|
34
|
+
* instructions and by its state ("Nothing drawn yet" / "Signature drawn"), so a
|
|
35
|
+
* screen-reader user knows what the box is and whether it holds anything; undo and
|
|
36
|
+
* clear are real buttons, and their effect is announced. What it cannot do is let
|
|
37
|
+
* someone sign without a pointer — hence `allowTypedName`, which offers a typed name
|
|
38
|
+
* instead. It is OPT-IN, because whether a typed name counts as a signature is a
|
|
39
|
+
* product and legal decision, not a UI one (Kastlan's handover accepts one; a flow
|
|
40
|
+
* that needs a drawn mark would not). Where a drawn mark is not strictly required,
|
|
41
|
+
* turn it on.
|
|
42
|
+
*/
|
|
43
|
+
/** Every string the pad renders or speaks. */
|
|
44
|
+
interface SignaturePadLabels {
|
|
45
|
+
/** Visible label above the pad, and the canvas's accessible name. The `label`
|
|
46
|
+
* prop overrides it per instance. */
|
|
47
|
+
label: string;
|
|
48
|
+
/** Under the label, and part of the canvas's description. */
|
|
49
|
+
instructions: string;
|
|
50
|
+
/** Appended to the instructions when `allowTypedName` is on. */
|
|
51
|
+
typedFallbackHint: string;
|
|
52
|
+
/** The canvas's state for a screen reader. */
|
|
53
|
+
empty: string;
|
|
54
|
+
signed: string;
|
|
55
|
+
undo: string;
|
|
56
|
+
clear: string;
|
|
57
|
+
/** Only rendered when `onSave` is given. */
|
|
58
|
+
save: string;
|
|
59
|
+
/** The mode switch (`allowTypedName`). */
|
|
60
|
+
useTyped: string;
|
|
61
|
+
useDrawn: string;
|
|
62
|
+
/** Label of the typed-name field. */
|
|
63
|
+
typedName: string;
|
|
64
|
+
/** Live-region messages after the matching button. */
|
|
65
|
+
cleared: string;
|
|
66
|
+
undone: string;
|
|
67
|
+
}
|
|
68
|
+
declare const DEFAULT_SIGNATURE_PAD_LABELS: SignaturePadLabels;
|
|
69
|
+
/** How the value handed back was made. */
|
|
70
|
+
interface SignatureDetail {
|
|
71
|
+
method: "drawn" | "typed";
|
|
72
|
+
/** The name as typed, when `method` is `"typed"` — the PNG shows it, but a host
|
|
73
|
+
* that stores a typed name as TEXT (Kastlan does) wants the string. */
|
|
74
|
+
typedName?: string;
|
|
75
|
+
}
|
|
76
|
+
/** The imperative handle: `ref.current.toDataURL()` at submit time, for a form that
|
|
77
|
+
* does not want to mirror the value into state on every stroke. */
|
|
78
|
+
interface SignaturePadHandle {
|
|
79
|
+
/** Remove every stroke and the typed name. Fires `onChange(null)`. */
|
|
80
|
+
clear: () => void;
|
|
81
|
+
/** The PNG, rendered in `exportInk` — or `null` while nothing is signed. */
|
|
82
|
+
toDataURL: () => string | null;
|
|
83
|
+
isEmpty: () => boolean;
|
|
84
|
+
}
|
|
85
|
+
interface SignaturePadProps extends Omit<ComponentPropsWithoutRef<"div">, "onChange"> {
|
|
86
|
+
/** Visible label; defaults to `labels.label`. */
|
|
87
|
+
label?: ReactNode;
|
|
88
|
+
/** Replaces `labels.instructions` for this instance (e.g. a legal note). */
|
|
89
|
+
description?: ReactNode;
|
|
90
|
+
/**
|
|
91
|
+
* After every finished stroke, undo, clear and typed-name edit: the PNG, or `null`
|
|
92
|
+
* once the pad is empty. Not called mid-stroke — encoding a PNG per pointer move
|
|
93
|
+
* would stall the drawing on a phone.
|
|
94
|
+
*/
|
|
95
|
+
onChange?: (dataUrl: string | null, detail: SignatureDetail) => void;
|
|
96
|
+
/** Renders a Save button, enabled once something is signed. */
|
|
97
|
+
onSave?: (dataUrl: string, detail: SignatureDetail) => void;
|
|
98
|
+
disabled?: boolean;
|
|
99
|
+
/** Paints the pad as wrong and sets `aria-invalid`. See {@link Input}'s `invalid`. */
|
|
100
|
+
invalid?: boolean;
|
|
101
|
+
/** Message under the pad; implies `invalid` and is attached with
|
|
102
|
+
* `aria-describedby`, like the kit's other fields. */
|
|
103
|
+
error?: ReactNode;
|
|
104
|
+
/** Offer a typed name as an alternative to drawing. See the accessibility note. */
|
|
105
|
+
allowTypedName?: boolean;
|
|
106
|
+
/** Ink of the exported PNG. Default near-black, legible on white. */
|
|
107
|
+
exportInk?: string;
|
|
108
|
+
/** Fill behind the exported PNG. Default transparent. */
|
|
109
|
+
exportBackground?: string;
|
|
110
|
+
/** Base stroke width in CSS pixels. Default 2.5. */
|
|
111
|
+
lineWidth?: number;
|
|
112
|
+
/** Classes for the canvas — its height, chiefly (default `h-40`). */
|
|
113
|
+
canvasClassName?: string;
|
|
114
|
+
/** User-facing strings; see {@link SignaturePadLabels}. */
|
|
115
|
+
labels?: Partial<SignaturePadLabels>;
|
|
116
|
+
}
|
|
117
|
+
declare const SignaturePad: react.ForwardRefExoticComponent<SignaturePadProps & react.RefAttributes<SignaturePadHandle>>;
|
|
118
|
+
|
|
119
|
+
export { DEFAULT_SIGNATURE_PAD_LABELS, type SignatureDetail, SignaturePad, type SignaturePadHandle, type SignaturePadLabels, type SignaturePadProps };
|
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef, useCallback, useEffect, useId, useImperativeHandle, useLayoutEffect, useRef, useState } from "react";
|
|
4
|
+
import { Eraser, Keyboard, PenLine, Undo2 } from "lucide-react";
|
|
5
|
+
import { cn } from "../lib/cn.js";
|
|
6
|
+
import { useAnnounce } from "../hooks/use-announce.js";
|
|
7
|
+
import { useKitLabels } from "../i18n/kit-labels.js";
|
|
8
|
+
import { Button, FIELD_INVALID, Input } from "./ui.js";
|
|
9
|
+
const DEFAULT_SIGNATURE_PAD_LABELS = {
|
|
10
|
+
label: "Signature",
|
|
11
|
+
instructions: "Sign in the box with a mouse, your finger or a pen.",
|
|
12
|
+
typedFallbackHint: "If you cannot draw, type your name instead.",
|
|
13
|
+
empty: "Nothing drawn yet",
|
|
14
|
+
signed: "Signature drawn",
|
|
15
|
+
undo: "Undo last stroke",
|
|
16
|
+
clear: "Clear",
|
|
17
|
+
save: "Save signature",
|
|
18
|
+
useTyped: "Type name instead",
|
|
19
|
+
useDrawn: "Draw instead",
|
|
20
|
+
typedName: "Full name",
|
|
21
|
+
cleared: "Signature cleared",
|
|
22
|
+
undone: "Last stroke removed"
|
|
23
|
+
};
|
|
24
|
+
const DEFAULT_EXPORT_INK = "#111111";
|
|
25
|
+
const SCRIPT_FONT = `"Segoe Script", "Bradley Hand", "Brush Script MT", cursive`;
|
|
26
|
+
const pressureWidth = (p) => 0.4 + 1.2 * p;
|
|
27
|
+
const mid = (a, b) => ({ x: (a.x + b.x) / 2, y: (a.y + b.y) / 2, p: (a.p + b.p) / 2 });
|
|
28
|
+
function drawSegment(ctx, pts, i, scale, width) {
|
|
29
|
+
const a = i === 1 ? pts[0] : mid(pts[i - 2], pts[i - 1]);
|
|
30
|
+
const c = pts[i - 1];
|
|
31
|
+
const b = mid(pts[i - 1], pts[i]);
|
|
32
|
+
ctx.lineWidth = width * scale * pressureWidth((a.p + b.p) / 2);
|
|
33
|
+
ctx.beginPath();
|
|
34
|
+
ctx.moveTo(a.x * scale, a.y * scale);
|
|
35
|
+
ctx.quadraticCurveTo(c.x * scale, c.y * scale, b.x * scale, b.y * scale);
|
|
36
|
+
ctx.stroke();
|
|
37
|
+
}
|
|
38
|
+
function drawTail(ctx, pts, scale, width) {
|
|
39
|
+
const last = pts[pts.length - 1];
|
|
40
|
+
if (pts.length === 1) {
|
|
41
|
+
ctx.beginPath();
|
|
42
|
+
ctx.arc(last.x * scale, last.y * scale, width * scale * pressureWidth(last.p) / 2, 0, Math.PI * 2);
|
|
43
|
+
ctx.fill();
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const from = pts.length === 2 ? pts[0] : mid(pts[pts.length - 2], last);
|
|
47
|
+
ctx.lineWidth = width * scale * pressureWidth(last.p);
|
|
48
|
+
ctx.beginPath();
|
|
49
|
+
ctx.moveTo(from.x * scale, from.y * scale);
|
|
50
|
+
ctx.lineTo(last.x * scale, last.y * scale);
|
|
51
|
+
ctx.stroke();
|
|
52
|
+
}
|
|
53
|
+
function prepare(ctx, ink, dpr) {
|
|
54
|
+
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
55
|
+
ctx.lineCap = "round";
|
|
56
|
+
ctx.lineJoin = "round";
|
|
57
|
+
ctx.strokeStyle = ink;
|
|
58
|
+
ctx.fillStyle = ink;
|
|
59
|
+
}
|
|
60
|
+
function drawName(ctx, name, w, h) {
|
|
61
|
+
let size = Math.min(48, h * 0.45);
|
|
62
|
+
ctx.font = `italic ${size}px ${SCRIPT_FONT}`;
|
|
63
|
+
const room = w * 0.85;
|
|
64
|
+
const measured = ctx.measureText(name).width;
|
|
65
|
+
if (measured > room) {
|
|
66
|
+
size = Math.max(12, size * room / measured);
|
|
67
|
+
ctx.font = `italic ${size}px ${SCRIPT_FONT}`;
|
|
68
|
+
}
|
|
69
|
+
ctx.textAlign = "center";
|
|
70
|
+
ctx.textBaseline = "alphabetic";
|
|
71
|
+
ctx.fillText(name, w / 2, h * 0.68);
|
|
72
|
+
}
|
|
73
|
+
const SignaturePad = forwardRef(function SignaturePad2({
|
|
74
|
+
label,
|
|
75
|
+
description,
|
|
76
|
+
onChange,
|
|
77
|
+
onSave,
|
|
78
|
+
disabled,
|
|
79
|
+
invalid,
|
|
80
|
+
error,
|
|
81
|
+
allowTypedName,
|
|
82
|
+
exportInk = DEFAULT_EXPORT_INK,
|
|
83
|
+
exportBackground,
|
|
84
|
+
lineWidth = 2.5,
|
|
85
|
+
canvasClassName,
|
|
86
|
+
labels: labelsProp,
|
|
87
|
+
className,
|
|
88
|
+
...rest
|
|
89
|
+
}, ref) {
|
|
90
|
+
const labels = useKitLabels("signaturePad", DEFAULT_SIGNATURE_PAD_LABELS, labelsProp);
|
|
91
|
+
const { announce, regionProps } = useAnnounce();
|
|
92
|
+
const labelId = useId();
|
|
93
|
+
const descId = useId();
|
|
94
|
+
const statusId = useId();
|
|
95
|
+
const errorId = useId();
|
|
96
|
+
const canvasRef = useRef(null);
|
|
97
|
+
const scene = useRef({
|
|
98
|
+
strokes: [],
|
|
99
|
+
mode: "drawn",
|
|
100
|
+
name: ""
|
|
101
|
+
});
|
|
102
|
+
const live = useRef(null);
|
|
103
|
+
const refWidth = useRef(0);
|
|
104
|
+
const [strokeCount, setStrokeCount] = useState(0);
|
|
105
|
+
const [mode, setMode] = useState("drawn");
|
|
106
|
+
const [typedName, setTypedName] = useState("");
|
|
107
|
+
const typed = mode === "typed";
|
|
108
|
+
const isEmpty = typed ? typedName.trim() === "" : strokeCount === 0;
|
|
109
|
+
const opts = useRef({ lineWidth, exportInk, exportBackground });
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
opts.current = { lineWidth, exportInk, exportBackground };
|
|
112
|
+
}, [lineWidth, exportInk, exportBackground]);
|
|
113
|
+
const sceneEmpty = () => {
|
|
114
|
+
const s = scene.current;
|
|
115
|
+
return s.mode === "typed" ? s.name.trim() === "" : s.strokes.length === 0;
|
|
116
|
+
};
|
|
117
|
+
const paintInto = useCallback((ctx, ink, w, h, dpr) => {
|
|
118
|
+
const { lineWidth: width } = opts.current;
|
|
119
|
+
const s = scene.current;
|
|
120
|
+
prepare(ctx, ink, dpr);
|
|
121
|
+
if (s.mode === "typed") {
|
|
122
|
+
if (s.name.trim()) drawName(ctx, s.name.trim(), w, h);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const scale = refWidth.current > 0 ? w / refWidth.current : 1;
|
|
126
|
+
for (const stroke of s.strokes) {
|
|
127
|
+
for (let i = 1; i < stroke.length; i += 1) drawSegment(ctx, stroke, i, scale, width);
|
|
128
|
+
drawTail(ctx, stroke, scale, width);
|
|
129
|
+
}
|
|
130
|
+
const pending = live.current?.stroke;
|
|
131
|
+
if (pending) for (let i = 1; i < pending.length; i += 1) drawSegment(ctx, pending, i, scale, width);
|
|
132
|
+
}, []);
|
|
133
|
+
const screenInk = (canvas) => (
|
|
134
|
+
// Read as `color` rather than as the custom property: `--text-primary` is whatever
|
|
135
|
+
// the palette wrote (a `color-mix()` in some presets), which a 2D context may not
|
|
136
|
+
// parse; `color` has already been resolved by the browser.
|
|
137
|
+
getComputedStyle(canvas).color || opts.current.exportInk
|
|
138
|
+
);
|
|
139
|
+
const repaint = useCallback(() => {
|
|
140
|
+
const canvas = canvasRef.current;
|
|
141
|
+
const ctx = canvas?.getContext("2d");
|
|
142
|
+
if (!canvas || !ctx) return;
|
|
143
|
+
const dpr = window.devicePixelRatio || 1;
|
|
144
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
145
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
146
|
+
paintInto(ctx, screenInk(canvas), canvas.width / dpr, canvas.height / dpr, dpr);
|
|
147
|
+
}, [paintInto]);
|
|
148
|
+
const resize = useCallback(() => {
|
|
149
|
+
const canvas = canvasRef.current;
|
|
150
|
+
if (!canvas) return;
|
|
151
|
+
const rect = canvas.getBoundingClientRect();
|
|
152
|
+
const dpr = window.devicePixelRatio || 1;
|
|
153
|
+
const w = Math.round(rect.width * dpr);
|
|
154
|
+
const h = Math.round(rect.height * dpr);
|
|
155
|
+
if (canvas.width !== w) canvas.width = w;
|
|
156
|
+
if (canvas.height !== h) canvas.height = h;
|
|
157
|
+
repaint();
|
|
158
|
+
}, [repaint]);
|
|
159
|
+
useLayoutEffect(() => {
|
|
160
|
+
resize();
|
|
161
|
+
}, [resize]);
|
|
162
|
+
useEffect(() => {
|
|
163
|
+
repaint();
|
|
164
|
+
}, [lineWidth, repaint]);
|
|
165
|
+
useEffect(() => {
|
|
166
|
+
const canvas = canvasRef.current;
|
|
167
|
+
if (!canvas) return;
|
|
168
|
+
const cleanups = [];
|
|
169
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
170
|
+
const ro = new ResizeObserver(() => resize());
|
|
171
|
+
ro.observe(canvas);
|
|
172
|
+
cleanups.push(() => ro.disconnect());
|
|
173
|
+
}
|
|
174
|
+
if (typeof MutationObserver !== "undefined") {
|
|
175
|
+
const mo = new MutationObserver(() => repaint());
|
|
176
|
+
mo.observe(document.documentElement, { attributes: true, attributeFilter: ["class", "style", "data-theme"] });
|
|
177
|
+
cleanups.push(() => mo.disconnect());
|
|
178
|
+
}
|
|
179
|
+
const mq = typeof window.matchMedia === "function" ? window.matchMedia("(prefers-color-scheme: dark)") : null;
|
|
180
|
+
if (mq?.addEventListener) {
|
|
181
|
+
mq.addEventListener("change", repaint);
|
|
182
|
+
cleanups.push(() => mq.removeEventListener("change", repaint));
|
|
183
|
+
}
|
|
184
|
+
return () => cleanups.forEach((fn) => fn());
|
|
185
|
+
}, [resize, repaint]);
|
|
186
|
+
const exportPng = useCallback(() => {
|
|
187
|
+
const canvas = canvasRef.current;
|
|
188
|
+
if (!canvas || sceneEmpty()) return null;
|
|
189
|
+
const { exportInk: ink, exportBackground: bg } = opts.current;
|
|
190
|
+
const dpr = window.devicePixelRatio || 1;
|
|
191
|
+
const out = document.createElement("canvas");
|
|
192
|
+
out.width = canvas.width;
|
|
193
|
+
out.height = canvas.height;
|
|
194
|
+
const ctx = out.getContext("2d");
|
|
195
|
+
if (!ctx) return null;
|
|
196
|
+
if (bg) {
|
|
197
|
+
ctx.fillStyle = bg;
|
|
198
|
+
ctx.fillRect(0, 0, out.width, out.height);
|
|
199
|
+
}
|
|
200
|
+
paintInto(ctx, ink, out.width / dpr, out.height / dpr, dpr);
|
|
201
|
+
return out.toDataURL("image/png");
|
|
202
|
+
}, [paintInto]);
|
|
203
|
+
const detail = () => {
|
|
204
|
+
const s = scene.current;
|
|
205
|
+
return s.mode === "typed" ? { method: "typed", typedName: s.name.trim() } : { method: "drawn" };
|
|
206
|
+
};
|
|
207
|
+
const onChangeRef = useRef(onChange);
|
|
208
|
+
useEffect(() => {
|
|
209
|
+
onChangeRef.current = onChange;
|
|
210
|
+
}, [onChange]);
|
|
211
|
+
const commit = () => {
|
|
212
|
+
const s = scene.current;
|
|
213
|
+
setStrokeCount(s.strokes.length);
|
|
214
|
+
setMode(s.mode);
|
|
215
|
+
setTypedName(s.name);
|
|
216
|
+
repaint();
|
|
217
|
+
onChangeRef.current?.(exportPng(), detail());
|
|
218
|
+
};
|
|
219
|
+
const clearScene = () => {
|
|
220
|
+
scene.current = { ...scene.current, strokes: [], name: "" };
|
|
221
|
+
live.current = null;
|
|
222
|
+
refWidth.current = 0;
|
|
223
|
+
commit();
|
|
224
|
+
};
|
|
225
|
+
useImperativeHandle(ref, () => ({ clear: clearScene, toDataURL: exportPng, isEmpty: sceneEmpty }));
|
|
226
|
+
const toPoint = (e, rect) => {
|
|
227
|
+
const scale = refWidth.current > 0 && rect.width > 0 ? rect.width / refWidth.current : 1;
|
|
228
|
+
return {
|
|
229
|
+
x: (e.clientX - rect.left) / scale,
|
|
230
|
+
y: (e.clientY - rect.top) / scale,
|
|
231
|
+
// Only a pen's pressure means anything: a mouse reports 0.5 while pressed and
|
|
232
|
+
// touch hardware reports 0, 1 or noise.
|
|
233
|
+
p: e.pointerType === "pen" && e.pressure > 0 ? e.pressure : 0.5
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
const onPointerDown = (e) => {
|
|
237
|
+
if (disabled || typed || live.current) return;
|
|
238
|
+
if (e.pointerType === "mouse" && e.button !== 0) return;
|
|
239
|
+
e.preventDefault();
|
|
240
|
+
const canvas = e.currentTarget;
|
|
241
|
+
canvas.setPointerCapture?.(e.pointerId);
|
|
242
|
+
const rect = canvas.getBoundingClientRect();
|
|
243
|
+
if (refWidth.current === 0) refWidth.current = rect.width || 1;
|
|
244
|
+
live.current = { id: e.pointerId, stroke: [toPoint(e, rect)] };
|
|
245
|
+
};
|
|
246
|
+
const onPointerMove = (e) => {
|
|
247
|
+
const pending = live.current;
|
|
248
|
+
if (!pending || pending.id !== e.pointerId) return;
|
|
249
|
+
e.preventDefault();
|
|
250
|
+
const canvas = e.currentTarget;
|
|
251
|
+
const rect = canvas.getBoundingClientRect();
|
|
252
|
+
const samples = e.nativeEvent.getCoalescedEvents?.() ?? [];
|
|
253
|
+
const events = samples.length > 0 ? samples : [e];
|
|
254
|
+
const ctx = canvas.getContext("2d");
|
|
255
|
+
if (ctx) prepare(ctx, screenInk(canvas), window.devicePixelRatio || 1);
|
|
256
|
+
const scale = refWidth.current > 0 && rect.width > 0 ? rect.width / refWidth.current : 1;
|
|
257
|
+
for (const ev of events) {
|
|
258
|
+
pending.stroke.push(toPoint(ev, rect));
|
|
259
|
+
if (ctx) drawSegment(ctx, pending.stroke, pending.stroke.length - 1, scale, opts.current.lineWidth);
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
const endStroke = (e) => {
|
|
263
|
+
const pending = live.current;
|
|
264
|
+
if (!pending || pending.id !== e.pointerId) return;
|
|
265
|
+
e.currentTarget.releasePointerCapture?.(e.pointerId);
|
|
266
|
+
live.current = null;
|
|
267
|
+
scene.current = { ...scene.current, strokes: [...scene.current.strokes, pending.stroke] };
|
|
268
|
+
commit();
|
|
269
|
+
};
|
|
270
|
+
const undo = () => {
|
|
271
|
+
if (disabled || scene.current.strokes.length === 0) return;
|
|
272
|
+
const strokes = scene.current.strokes.slice(0, -1);
|
|
273
|
+
if (strokes.length === 0) refWidth.current = 0;
|
|
274
|
+
scene.current = { ...scene.current, strokes };
|
|
275
|
+
commit();
|
|
276
|
+
announce(labels.undone);
|
|
277
|
+
};
|
|
278
|
+
const clear = () => {
|
|
279
|
+
if (disabled || sceneEmpty()) return;
|
|
280
|
+
clearScene();
|
|
281
|
+
announce(labels.cleared);
|
|
282
|
+
};
|
|
283
|
+
const switchMode = () => {
|
|
284
|
+
if (disabled) return;
|
|
285
|
+
scene.current = { ...scene.current, mode: scene.current.mode === "drawn" ? "typed" : "drawn" };
|
|
286
|
+
commit();
|
|
287
|
+
};
|
|
288
|
+
const onTypedChange = (name) => {
|
|
289
|
+
scene.current = { ...scene.current, name };
|
|
290
|
+
commit();
|
|
291
|
+
};
|
|
292
|
+
const save = () => {
|
|
293
|
+
if (disabled) return;
|
|
294
|
+
const png = exportPng();
|
|
295
|
+
if (png) onSave?.(png, detail());
|
|
296
|
+
};
|
|
297
|
+
const hasError = error !== void 0 && error !== null && error !== false && error !== "";
|
|
298
|
+
const isInvalid = Boolean(invalid) || hasError;
|
|
299
|
+
const describedBy = [descId, statusId, hasError ? errorId : null].filter(Boolean).join(" ");
|
|
300
|
+
const softDisabled = "aria-disabled:cursor-not-allowed aria-disabled:opacity-50";
|
|
301
|
+
return /* @__PURE__ */ jsxs("div", { ...rest, className: cn("relative space-y-1.5", className), "data-empty": isEmpty || void 0, children: [
|
|
302
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
303
|
+
/* @__PURE__ */ jsx("span", { id: labelId, className: "block text-sm font-medium text-[var(--text-primary)]", children: label ?? labels.label }),
|
|
304
|
+
/* @__PURE__ */ jsxs("p", { id: descId, className: "text-xs text-[var(--text-muted)]", children: [
|
|
305
|
+
description ?? labels.instructions,
|
|
306
|
+
allowTypedName && !typed ? ` ${labels.typedFallbackHint}` : null
|
|
307
|
+
] })
|
|
308
|
+
] }),
|
|
309
|
+
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
310
|
+
/* @__PURE__ */ jsx(
|
|
311
|
+
"canvas",
|
|
312
|
+
{
|
|
313
|
+
ref: canvasRef,
|
|
314
|
+
role: "img",
|
|
315
|
+
"aria-labelledby": labelId,
|
|
316
|
+
"aria-describedby": describedBy,
|
|
317
|
+
"data-invalid": isInvalid || void 0,
|
|
318
|
+
"data-disabled": disabled || void 0,
|
|
319
|
+
onPointerDown,
|
|
320
|
+
onPointerMove,
|
|
321
|
+
onPointerUp: endStroke,
|
|
322
|
+
onPointerCancel: endStroke,
|
|
323
|
+
className: cn(
|
|
324
|
+
// `touch-none` stops the page scrolling under a finger that is signing.
|
|
325
|
+
"block h-40 w-full touch-none select-none rounded-md border border-[var(--border)] bg-[var(--bg-surface)] text-[var(--text-primary)]",
|
|
326
|
+
typed || disabled ? "cursor-default" : "cursor-crosshair",
|
|
327
|
+
disabled && "opacity-60",
|
|
328
|
+
isInvalid && FIELD_INVALID,
|
|
329
|
+
canvasClassName
|
|
330
|
+
)
|
|
331
|
+
}
|
|
332
|
+
),
|
|
333
|
+
/* @__PURE__ */ jsx(
|
|
334
|
+
"div",
|
|
335
|
+
{
|
|
336
|
+
"aria-hidden": "true",
|
|
337
|
+
className: "pointer-events-none absolute inset-x-6 bottom-8 border-b border-dashed border-[var(--border-strong)]"
|
|
338
|
+
}
|
|
339
|
+
),
|
|
340
|
+
/* @__PURE__ */ jsx("span", { id: statusId, className: "sr-only", children: isEmpty ? labels.empty : labels.signed })
|
|
341
|
+
] }),
|
|
342
|
+
typed && /* @__PURE__ */ jsx(
|
|
343
|
+
Input,
|
|
344
|
+
{
|
|
345
|
+
label: labels.typedName,
|
|
346
|
+
value: typedName,
|
|
347
|
+
autoComplete: "name",
|
|
348
|
+
disabled,
|
|
349
|
+
onChange: (e) => onTypedChange(e.target.value)
|
|
350
|
+
}
|
|
351
|
+
),
|
|
352
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
353
|
+
!typed && /* @__PURE__ */ jsxs(
|
|
354
|
+
Button,
|
|
355
|
+
{
|
|
356
|
+
type: "button",
|
|
357
|
+
variant: "ghost",
|
|
358
|
+
onClick: undo,
|
|
359
|
+
"aria-disabled": disabled || strokeCount === 0 || void 0,
|
|
360
|
+
className: softDisabled,
|
|
361
|
+
children: [
|
|
362
|
+
/* @__PURE__ */ jsx(Undo2, { "aria-hidden": "true", className: "size-4" }),
|
|
363
|
+
labels.undo
|
|
364
|
+
]
|
|
365
|
+
}
|
|
366
|
+
),
|
|
367
|
+
/* @__PURE__ */ jsxs(
|
|
368
|
+
Button,
|
|
369
|
+
{
|
|
370
|
+
type: "button",
|
|
371
|
+
variant: "ghost",
|
|
372
|
+
onClick: clear,
|
|
373
|
+
"aria-disabled": disabled || isEmpty || void 0,
|
|
374
|
+
className: softDisabled,
|
|
375
|
+
children: [
|
|
376
|
+
/* @__PURE__ */ jsx(Eraser, { "aria-hidden": "true", className: "size-4" }),
|
|
377
|
+
labels.clear
|
|
378
|
+
]
|
|
379
|
+
}
|
|
380
|
+
),
|
|
381
|
+
allowTypedName && /* @__PURE__ */ jsxs(
|
|
382
|
+
Button,
|
|
383
|
+
{
|
|
384
|
+
type: "button",
|
|
385
|
+
variant: "secondary",
|
|
386
|
+
onClick: switchMode,
|
|
387
|
+
disabled,
|
|
388
|
+
children: [
|
|
389
|
+
typed ? /* @__PURE__ */ jsx(PenLine, { "aria-hidden": "true", className: "size-4" }) : /* @__PURE__ */ jsx(Keyboard, { "aria-hidden": "true", className: "size-4" }),
|
|
390
|
+
typed ? labels.useDrawn : labels.useTyped
|
|
391
|
+
]
|
|
392
|
+
}
|
|
393
|
+
),
|
|
394
|
+
onSave && /* @__PURE__ */ jsx(Button, { type: "button", variant: "brand", onClick: save, disabled: disabled || isEmpty, className: "ms-auto", children: labels.save })
|
|
395
|
+
] }),
|
|
396
|
+
hasError && /* @__PURE__ */ jsx("p", { id: errorId, className: "mt-1 text-[11px] leading-tight text-[var(--danger)]", children: error }),
|
|
397
|
+
/* @__PURE__ */ jsx("div", { ...regionProps })
|
|
398
|
+
] });
|
|
399
|
+
});
|
|
400
|
+
SignaturePad.displayName = "SignaturePad";
|
|
401
|
+
export {
|
|
402
|
+
DEFAULT_SIGNATURE_PAD_LABELS,
|
|
403
|
+
SignaturePad
|
|
404
|
+
};
|
|
405
|
+
//# sourceMappingURL=signature-pad.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/signature-pad.tsx"],"sourcesContent":["import { forwardRef, useCallback, useEffect, useId, useImperativeHandle, useLayoutEffect, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, PointerEvent as ReactPointerEvent, ReactNode } from \"react\";\nimport { Eraser, Keyboard, PenLine, Undo2 } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { useAnnounce } from \"../hooks/use-announce\";\nimport { useKitLabels } from \"../i18n/kit-labels\";\nimport { Button, FIELD_INVALID, Input } from \"./ui\";\n\n/**\n * A drawn signature, captured on a canvas and handed back as a PNG data URL.\n *\n * Kastlan wrote the first one (`features/handover/components/signature-pad.tsx`) for\n * the handover protocol, where tenant and inspector each sign on the same phone. This\n * keeps its contract — draw, get a PNG — and fixes what a copy per app would keep\n * getting wrong:\n *\n * 1. **Strokes are data, not pixels.** Each stroke is kept as a list of points, and\n * the canvas is a VIEW of them. That is what lets a resize (a phone rotating\n * mid-signature) keep the drawing instead of wiping it — setting `canvas.width`\n * clears the bitmap, so a pixels-only pad loses everything — and what makes undo\n * one `pop()`. The pixel buffer is sized to `devicePixelRatio`, so a stroke is\n * sharp on a 3× screen rather than upscaled from a 1× bitmap.\n * 2. **Smooth, and pressure-aware.** Segments are quadratic curves through the\n * midpoints between samples, so a fast stroke is a curve, not a polyline; a pen\n * that reports pressure varies the width, a mouse or finger (whose `pressure` is a\n * constant 0.5, or junk) draws at the base width.\n * 3. **Two inks.** On screen the ink is the computed `color` of the canvas, which is\n * `--text-primary` — so it reads in the dark theme, where a hard-coded near-black\n * stroke vanished into the surface. The exported PNG is re-rendered from the same\n * strokes in `exportInk` (near-black by default) on a transparent background. A\n * signature is a DOCUMENT artefact: it is printed on the protocol, shown on a white\n * card, embedded in a PDF — none of which follow the signer's theme. Exporting\n * the on-screen ink would have produced a pale-grey-on-transparent PNG for every\n * dark-mode signer, invisible on white paper.\n *\n * **Accessibility.** A canvas has no content a screen reader or a keyboard can reach,\n * and no amount of ARIA changes that — drawing is a pointer act. What the pad does:\n * the canvas is `role=\"img\"`, named by the visible label and described by the\n * instructions and by its state (\"Nothing drawn yet\" / \"Signature drawn\"), so a\n * screen-reader user knows what the box is and whether it holds anything; undo and\n * clear are real buttons, and their effect is announced. What it cannot do is let\n * someone sign without a pointer — hence `allowTypedName`, which offers a typed name\n * instead. It is OPT-IN, because whether a typed name counts as a signature is a\n * product and legal decision, not a UI one (Kastlan's handover accepts one; a flow\n * that needs a drawn mark would not). Where a drawn mark is not strictly required,\n * turn it on.\n */\n\n/* ── Labels ──────────────────────────────────────────────────────────────── */\n\n/** Every string the pad renders or speaks. */\nexport interface SignaturePadLabels {\n /** Visible label above the pad, and the canvas's accessible name. The `label`\n * prop overrides it per instance. */\n label: string;\n /** Under the label, and part of the canvas's description. */\n instructions: string;\n /** Appended to the instructions when `allowTypedName` is on. */\n typedFallbackHint: string;\n /** The canvas's state for a screen reader. */\n empty: string;\n signed: string;\n undo: string;\n clear: string;\n /** Only rendered when `onSave` is given. */\n save: string;\n /** The mode switch (`allowTypedName`). */\n useTyped: string;\n useDrawn: string;\n /** Label of the typed-name field. */\n typedName: string;\n /** Live-region messages after the matching button. */\n cleared: string;\n undone: string;\n}\n\nexport const DEFAULT_SIGNATURE_PAD_LABELS: SignaturePadLabels = {\n label: \"Signature\",\n instructions: \"Sign in the box with a mouse, your finger or a pen.\",\n typedFallbackHint: \"If you cannot draw, type your name instead.\",\n empty: \"Nothing drawn yet\",\n signed: \"Signature drawn\",\n undo: \"Undo last stroke\",\n clear: \"Clear\",\n save: \"Save signature\",\n useTyped: \"Type name instead\",\n useDrawn: \"Draw instead\",\n typedName: \"Full name\",\n cleared: \"Signature cleared\",\n undone: \"Last stroke removed\",\n};\n\n/* ── Types ───────────────────────────────────────────────────────────────── */\n\n/** How the value handed back was made. */\nexport interface SignatureDetail {\n method: \"drawn\" | \"typed\";\n /** The name as typed, when `method` is `\"typed\"` — the PNG shows it, but a host\n * that stores a typed name as TEXT (Kastlan does) wants the string. */\n typedName?: string;\n}\n\n/** The imperative handle: `ref.current.toDataURL()` at submit time, for a form that\n * does not want to mirror the value into state on every stroke. */\nexport interface SignaturePadHandle {\n /** Remove every stroke and the typed name. Fires `onChange(null)`. */\n clear: () => void;\n /** The PNG, rendered in `exportInk` — or `null` while nothing is signed. */\n toDataURL: () => string | null;\n isEmpty: () => boolean;\n}\n\nexport interface SignaturePadProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"onChange\"> {\n /** Visible label; defaults to `labels.label`. */\n label?: ReactNode;\n /** Replaces `labels.instructions` for this instance (e.g. a legal note). */\n description?: ReactNode;\n /**\n * After every finished stroke, undo, clear and typed-name edit: the PNG, or `null`\n * once the pad is empty. Not called mid-stroke — encoding a PNG per pointer move\n * would stall the drawing on a phone.\n */\n onChange?: (dataUrl: string | null, detail: SignatureDetail) => void;\n /** Renders a Save button, enabled once something is signed. */\n onSave?: (dataUrl: string, detail: SignatureDetail) => void;\n disabled?: boolean;\n /** Paints the pad as wrong and sets `aria-invalid`. See {@link Input}'s `invalid`. */\n invalid?: boolean;\n /** Message under the pad; implies `invalid` and is attached with\n * `aria-describedby`, like the kit's other fields. */\n error?: ReactNode;\n /** Offer a typed name as an alternative to drawing. See the accessibility note. */\n allowTypedName?: boolean;\n /** Ink of the exported PNG. Default near-black, legible on white. */\n exportInk?: string;\n /** Fill behind the exported PNG. Default transparent. */\n exportBackground?: string;\n /** Base stroke width in CSS pixels. Default 2.5. */\n lineWidth?: number;\n /** Classes for the canvas — its height, chiefly (default `h-40`). */\n canvasClassName?: string;\n /** User-facing strings; see {@link SignaturePadLabels}. */\n labels?: Partial<SignaturePadLabels>;\n}\n\n/* ── Drawing ─────────────────────────────────────────────────────────────── */\n\ninterface Point {\n x: number;\n y: number;\n /** 0–1. A constant 0.5 for anything that is not a pen. */\n p: number;\n}\n\ntype Stroke = Point[];\n\nconst DEFAULT_EXPORT_INK = \"#111111\";\n\n// A handwriting face where the platform has one, `cursive` everywhere else. Only\n// ever used to render a typed name onto the canvas.\nconst SCRIPT_FONT = `\"Segoe Script\", \"Bradley Hand\", \"Brush Script MT\", cursive`;\n\n/** Width multiplier from pressure: 0.5 (the no-pen constant) is exactly 1. */\nconst pressureWidth = (p: number) => 0.4 + 1.2 * p;\n\nconst mid = (a: Point, b: Point): Point => ({ x: (a.x + b.x) / 2, y: (a.y + b.y) / 2, p: (a.p + b.p) / 2 });\n\n/**\n * Segment `i` (1 ≤ i < n) of a stroke: a quadratic from the midpoint before sample\n * `i - 1` to the midpoint after it, with the sample as the control point. The live\n * drawing and the full repaint both go through here, so a stroke looks the same\n * before and after a resize.\n */\nfunction drawSegment(ctx: CanvasRenderingContext2D, pts: Stroke, i: number, scale: number, width: number) {\n const a = i === 1 ? pts[0] : mid(pts[i - 2], pts[i - 1]);\n const c = pts[i - 1];\n const b = mid(pts[i - 1], pts[i]);\n ctx.lineWidth = width * scale * pressureWidth((a.p + b.p) / 2);\n ctx.beginPath();\n ctx.moveTo(a.x * scale, a.y * scale);\n ctx.quadraticCurveTo(c.x * scale, c.y * scale, b.x * scale, b.y * scale);\n ctx.stroke();\n}\n\n/** The last half-segment, from the final midpoint to the final sample. Drawn once the\n * stroke is finished — while drawing, the pen is still there and it would be redrawn\n * on every move. A single tap is a dot. */\nfunction drawTail(ctx: CanvasRenderingContext2D, pts: Stroke, scale: number, width: number) {\n const last = pts[pts.length - 1];\n if (pts.length === 1) {\n ctx.beginPath();\n ctx.arc(last.x * scale, last.y * scale, (width * scale * pressureWidth(last.p)) / 2, 0, Math.PI * 2);\n ctx.fill();\n return;\n }\n const from = pts.length === 2 ? pts[0] : mid(pts[pts.length - 2], last);\n ctx.lineWidth = width * scale * pressureWidth(last.p);\n ctx.beginPath();\n ctx.moveTo(from.x * scale, from.y * scale);\n ctx.lineTo(last.x * scale, last.y * scale);\n ctx.stroke();\n}\n\nfunction prepare(ctx: CanvasRenderingContext2D, ink: string, dpr: number) {\n ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n ctx.lineCap = \"round\";\n ctx.lineJoin = \"round\";\n ctx.strokeStyle = ink;\n ctx.fillStyle = ink;\n}\n\n/** A typed name, as large as fits, on the pad's baseline. */\nfunction drawName(ctx: CanvasRenderingContext2D, name: string, w: number, h: number) {\n let size = Math.min(48, h * 0.45);\n ctx.font = `italic ${size}px ${SCRIPT_FONT}`;\n const room = w * 0.85;\n const measured = ctx.measureText(name).width;\n if (measured > room) {\n size = Math.max(12, (size * room) / measured);\n ctx.font = `italic ${size}px ${SCRIPT_FONT}`;\n }\n ctx.textAlign = \"center\";\n ctx.textBaseline = \"alphabetic\";\n ctx.fillText(name, w / 2, h * 0.68);\n}\n\n/* ── The component ───────────────────────────────────────────────────────── */\n\nexport const SignaturePad = forwardRef<SignaturePadHandle, SignaturePadProps>(function SignaturePad(\n {\n label,\n description,\n onChange,\n onSave,\n disabled,\n invalid,\n error,\n allowTypedName,\n exportInk = DEFAULT_EXPORT_INK,\n exportBackground,\n lineWidth = 2.5,\n canvasClassName,\n labels: labelsProp,\n className,\n ...rest\n },\n ref,\n) {\n // Prop > <UiKitProvider> > English, like every labelled component in the kit.\n const labels = useKitLabels(\"signaturePad\", DEFAULT_SIGNATURE_PAD_LABELS, labelsProp);\n const { announce, regionProps } = useAnnounce();\n const labelId = useId();\n const descId = useId();\n const statusId = useId();\n const errorId = useId();\n\n const canvasRef = useRef<HTMLCanvasElement>(null);\n /**\n * What is on the pad lives in a ref, not in state: a pointer move must not\n * re-render, and `onChange` has to see the pad AFTER a change, from inside the\n * handler that made it — before React has rendered anything. The state below\n * mirrors the parts the markup needs (empty or not, which mode, the field's text).\n */\n const scene = useRef<{ strokes: Stroke[]; mode: \"drawn\" | \"typed\"; name: string }>({\n strokes: [],\n mode: \"drawn\",\n name: \"\",\n });\n const live = useRef<{ id: number; stroke: Stroke } | null>(null);\n /**\n * The canvas width, in CSS px, the stored points are relative to. Fixed by the\n * first stroke; a later resize scales the drawing UNIFORMLY by `width / refWidth`,\n * so a rotated phone shows the same signature larger or smaller, never stretched.\n */\n const refWidth = useRef(0);\n const [strokeCount, setStrokeCount] = useState(0);\n const [mode, setMode] = useState<\"drawn\" | \"typed\">(\"drawn\");\n const [typedName, setTypedName] = useState(\"\");\n\n const typed = mode === \"typed\";\n const isEmpty = typed ? typedName.trim() === \"\" : strokeCount === 0;\n\n // Everything the paint and export paths read that can change between renders, so\n // the observers below subscribe once instead of on every keystroke.\n const opts = useRef({ lineWidth, exportInk, exportBackground });\n useEffect(() => {\n opts.current = { lineWidth, exportInk, exportBackground };\n }, [lineWidth, exportInk, exportBackground]);\n\n const sceneEmpty = () => {\n const s = scene.current;\n return s.mode === \"typed\" ? s.name.trim() === \"\" : s.strokes.length === 0;\n };\n\n /** The whole scene, painted into `ctx` at `w`×`h` CSS px. */\n const paintInto = useCallback((ctx: CanvasRenderingContext2D, ink: string, w: number, h: number, dpr: number) => {\n const { lineWidth: width } = opts.current;\n const s = scene.current;\n prepare(ctx, ink, dpr);\n if (s.mode === \"typed\") {\n if (s.name.trim()) drawName(ctx, s.name.trim(), w, h);\n return;\n }\n const scale = refWidth.current > 0 ? w / refWidth.current : 1;\n for (const stroke of s.strokes) {\n for (let i = 1; i < stroke.length; i += 1) drawSegment(ctx, stroke, i, scale, width);\n drawTail(ctx, stroke, scale, width);\n }\n const pending = live.current?.stroke;\n if (pending) for (let i = 1; i < pending.length; i += 1) drawSegment(ctx, pending, i, scale, width);\n }, []);\n\n /** The ink on screen: the canvas's own computed `color`, i.e. `--text-primary`. */\n const screenInk = (canvas: HTMLCanvasElement) =>\n // Read as `color` rather than as the custom property: `--text-primary` is whatever\n // the palette wrote (a `color-mix()` in some presets), which a 2D context may not\n // parse; `color` has already been resolved by the browser.\n getComputedStyle(canvas).color || opts.current.exportInk;\n\n /** Repaint the visible canvas from the scene, in the theme's ink. */\n const repaint = useCallback(() => {\n const canvas = canvasRef.current;\n const ctx = canvas?.getContext(\"2d\");\n if (!canvas || !ctx) return;\n const dpr = window.devicePixelRatio || 1;\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.clearRect(0, 0, canvas.width, canvas.height);\n paintInto(ctx, screenInk(canvas), canvas.width / dpr, canvas.height / dpr, dpr);\n }, [paintInto]);\n\n /** Size the bitmap to the element × devicePixelRatio, then repaint. */\n const resize = useCallback(() => {\n const canvas = canvasRef.current;\n if (!canvas) return;\n const rect = canvas.getBoundingClientRect();\n const dpr = window.devicePixelRatio || 1;\n const w = Math.round(rect.width * dpr);\n const h = Math.round(rect.height * dpr);\n // Assigning `width` clears the bitmap even when the value is unchanged, so only\n // when it moved — and the repaint puts the strokes back either way.\n if (canvas.width !== w) canvas.width = w;\n if (canvas.height !== h) canvas.height = h;\n repaint();\n }, [repaint]);\n\n useLayoutEffect(() => {\n resize();\n }, [resize]);\n\n // A changed base width redraws what is already there.\n useEffect(() => {\n repaint();\n }, [lineWidth, repaint]);\n\n useEffect(() => {\n const canvas = canvasRef.current;\n if (!canvas) return;\n const cleanups: Array<() => void> = [];\n if (typeof ResizeObserver !== \"undefined\") {\n const ro = new ResizeObserver(() => resize());\n ro.observe(canvas);\n cleanups.push(() => ro.disconnect());\n }\n // The ink follows the theme, and the theme is a class (`.dark`) or inline\n // variables (the palette store) on <html> — neither of which tells a canvas.\n if (typeof MutationObserver !== \"undefined\") {\n const mo = new MutationObserver(() => repaint());\n mo.observe(document.documentElement, { attributes: true, attributeFilter: [\"class\", \"style\", \"data-theme\"] });\n cleanups.push(() => mo.disconnect());\n }\n const mq = typeof window.matchMedia === \"function\" ? window.matchMedia(\"(prefers-color-scheme: dark)\") : null;\n if (mq?.addEventListener) {\n mq.addEventListener(\"change\", repaint);\n cleanups.push(() => mq.removeEventListener(\"change\", repaint));\n }\n return () => cleanups.forEach((fn) => fn());\n }, [resize, repaint]);\n\n /** The PNG, re-rendered off-screen in the export ink — `null` while empty. */\n const exportPng = useCallback((): string | null => {\n const canvas = canvasRef.current;\n if (!canvas || sceneEmpty()) return null;\n const { exportInk: ink, exportBackground: bg } = opts.current;\n const dpr = window.devicePixelRatio || 1;\n const out = document.createElement(\"canvas\");\n out.width = canvas.width;\n out.height = canvas.height;\n const ctx = out.getContext(\"2d\");\n if (!ctx) return null;\n if (bg) {\n ctx.fillStyle = bg;\n ctx.fillRect(0, 0, out.width, out.height);\n }\n paintInto(ctx, ink, out.width / dpr, out.height / dpr, dpr);\n return out.toDataURL(\"image/png\");\n }, [paintInto]);\n\n const detail = (): SignatureDetail => {\n const s = scene.current;\n return s.mode === \"typed\" ? { method: \"typed\", typedName: s.name.trim() } : { method: \"drawn\" };\n };\n\n /** After every change to the scene: sync the markup's mirror, repaint, tell the host. */\n const onChangeRef = useRef(onChange);\n useEffect(() => {\n onChangeRef.current = onChange;\n }, [onChange]);\n const commit = () => {\n const s = scene.current;\n setStrokeCount(s.strokes.length);\n setMode(s.mode);\n setTypedName(s.name);\n repaint();\n onChangeRef.current?.(exportPng(), detail());\n };\n\n const clearScene = () => {\n scene.current = { ...scene.current, strokes: [], name: \"\" };\n live.current = null;\n refWidth.current = 0;\n commit();\n };\n\n useImperativeHandle(ref, () => ({ clear: clearScene, toDataURL: exportPng, isEmpty: sceneEmpty }));\n\n /* ── Pointer ── */\n\n const toPoint = (e: { clientX: number; clientY: number; pressure: number; pointerType: string }, rect: DOMRect): Point => {\n const scale = refWidth.current > 0 && rect.width > 0 ? rect.width / refWidth.current : 1;\n return {\n x: (e.clientX - rect.left) / scale,\n y: (e.clientY - rect.top) / scale,\n // Only a pen's pressure means anything: a mouse reports 0.5 while pressed and\n // touch hardware reports 0, 1 or noise.\n p: e.pointerType === \"pen\" && e.pressure > 0 ? e.pressure : 0.5,\n };\n };\n\n const onPointerDown = (e: ReactPointerEvent<HTMLCanvasElement>) => {\n // One stroke at a time: a palm resting beside the pen is a second pointer.\n if (disabled || typed || live.current) return;\n if (e.pointerType === \"mouse\" && e.button !== 0) return;\n e.preventDefault();\n const canvas = e.currentTarget;\n canvas.setPointerCapture?.(e.pointerId);\n const rect = canvas.getBoundingClientRect();\n if (refWidth.current === 0) refWidth.current = rect.width || 1;\n live.current = { id: e.pointerId, stroke: [toPoint(e, rect)] };\n };\n\n const onPointerMove = (e: ReactPointerEvent<HTMLCanvasElement>) => {\n const pending = live.current;\n if (!pending || pending.id !== e.pointerId) return;\n e.preventDefault();\n const canvas = e.currentTarget;\n const rect = canvas.getBoundingClientRect();\n // Coalesced events: the samples the browser merged into this one move. A fast\n // flick on a 120 Hz pen is otherwise a handful of long straight chords.\n const samples = e.nativeEvent.getCoalescedEvents?.() ?? [];\n const events = samples.length > 0 ? samples : [e];\n const ctx = canvas.getContext(\"2d\");\n if (ctx) prepare(ctx, screenInk(canvas), window.devicePixelRatio || 1);\n const scale = refWidth.current > 0 && rect.width > 0 ? rect.width / refWidth.current : 1;\n for (const ev of events) {\n pending.stroke.push(toPoint(ev, rect));\n // Only the newest segment — a full repaint per move is O(ink) on every event.\n if (ctx) drawSegment(ctx, pending.stroke, pending.stroke.length - 1, scale, opts.current.lineWidth);\n }\n };\n\n const endStroke = (e: ReactPointerEvent<HTMLCanvasElement>) => {\n const pending = live.current;\n if (!pending || pending.id !== e.pointerId) return;\n e.currentTarget.releasePointerCapture?.(e.pointerId);\n live.current = null;\n scene.current = { ...scene.current, strokes: [...scene.current.strokes, pending.stroke] };\n commit();\n };\n\n /* ── Buttons ── */\n\n const undo = () => {\n if (disabled || scene.current.strokes.length === 0) return;\n const strokes = scene.current.strokes.slice(0, -1);\n if (strokes.length === 0) refWidth.current = 0;\n scene.current = { ...scene.current, strokes };\n commit();\n announce(labels.undone);\n };\n\n const clear = () => {\n if (disabled || sceneEmpty()) return;\n clearScene();\n announce(labels.cleared);\n };\n\n const switchMode = () => {\n if (disabled) return;\n scene.current = { ...scene.current, mode: scene.current.mode === \"drawn\" ? \"typed\" : \"drawn\" };\n commit();\n };\n\n const onTypedChange = (name: string) => {\n scene.current = { ...scene.current, name };\n commit();\n };\n\n const save = () => {\n if (disabled) return;\n const png = exportPng();\n if (png) onSave?.(png, detail());\n };\n\n const hasError = error !== undefined && error !== null && error !== false && error !== \"\";\n const isInvalid = Boolean(invalid) || hasError;\n const describedBy = [descId, statusId, hasError ? errorId : null].filter(Boolean).join(\" \");\n\n // `aria-disabled` rather than `disabled` on undo/clear: they disable THEMSELVES\n // (clear empties the pad, the last undo does too), and a natively disabled button\n // drops keyboard focus to <body> the moment it is activated.\n const softDisabled = \"aria-disabled:cursor-not-allowed aria-disabled:opacity-50\";\n\n return (\n <div {...rest} className={cn(\"relative space-y-1.5\", className)} data-empty={isEmpty || undefined}>\n <div>\n <span id={labelId} className=\"block text-sm font-medium text-[var(--text-primary)]\">\n {label ?? labels.label}\n </span>\n <p id={descId} className=\"text-xs text-[var(--text-muted)]\">\n {description ?? labels.instructions}\n {allowTypedName && !typed ? ` ${labels.typedFallbackHint}` : null}\n </p>\n </div>\n\n <div className=\"relative\">\n <canvas\n ref={canvasRef}\n role=\"img\"\n aria-labelledby={labelId}\n aria-describedby={describedBy}\n // No `aria-invalid` / `aria-disabled`: `img` supports neither. The error\n // reaches a screen reader through `aria-describedby`; the attributes below\n // are for styling and tests.\n data-invalid={isInvalid || undefined}\n data-disabled={disabled || undefined}\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={endStroke}\n onPointerCancel={endStroke}\n className={cn(\n // `touch-none` stops the page scrolling under a finger that is signing.\n \"block h-40 w-full touch-none select-none rounded-md border border-[var(--border)] bg-[var(--bg-surface)] text-[var(--text-primary)]\",\n typed || disabled ? \"cursor-default\" : \"cursor-crosshair\",\n disabled && \"opacity-60\",\n isInvalid && FIELD_INVALID,\n canvasClassName,\n )}\n />\n {/* The signing line — where people expect to sign. Decoration only. */}\n <div\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute inset-x-6 bottom-8 border-b border-dashed border-[var(--border-strong)]\"\n />\n <span id={statusId} className=\"sr-only\">\n {isEmpty ? labels.empty : labels.signed}\n </span>\n </div>\n\n {typed && (\n <Input\n label={labels.typedName}\n value={typedName}\n autoComplete=\"name\"\n disabled={disabled}\n onChange={(e) => onTypedChange(e.target.value)}\n />\n )}\n\n <div className=\"flex flex-wrap items-center gap-2\">\n {!typed && (\n <Button\n type=\"button\"\n variant=\"ghost\"\n onClick={undo}\n aria-disabled={disabled || strokeCount === 0 || undefined}\n className={softDisabled}\n >\n <Undo2 aria-hidden=\"true\" className=\"size-4\" />\n {labels.undo}\n </Button>\n )}\n <Button\n type=\"button\"\n variant=\"ghost\"\n onClick={clear}\n aria-disabled={disabled || isEmpty || undefined}\n className={softDisabled}\n >\n <Eraser aria-hidden=\"true\" className=\"size-4\" />\n {labels.clear}\n </Button>\n {allowTypedName && (\n <Button\n type=\"button\"\n variant=\"secondary\"\n onClick={switchMode}\n disabled={disabled}\n >\n {typed ? <PenLine aria-hidden=\"true\" className=\"size-4\" /> : <Keyboard aria-hidden=\"true\" className=\"size-4\" />}\n {typed ? labels.useDrawn : labels.useTyped}\n </Button>\n )}\n {onSave && (\n <Button type=\"button\" variant=\"brand\" onClick={save} disabled={disabled || isEmpty} className=\"ms-auto\">\n {labels.save}\n </Button>\n )}\n </div>\n\n {hasError && (\n <p id={errorId} className=\"mt-1 text-[11px] leading-tight text-[var(--danger)]\">\n {error}\n </p>\n )}\n {/* Rendered from the start and never unmounted — see useAnnounce. */}\n <div {...regionProps} />\n </div>\n );\n});\nSignaturePad.displayName = \"SignaturePad\";\n"],"mappings":";AA6gBQ,cAGA,YAHA;AA7gBR,SAAS,YAAY,aAAa,WAAW,OAAO,qBAAqB,iBAAiB,QAAQ,gBAAgB;AAElH,SAAS,QAAQ,UAAU,SAAS,aAAa;AACjD,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,QAAQ,eAAe,aAAa;AAsEtC,MAAM,+BAAmD;AAAA,EAC9D,OAAO;AAAA,EACP,cAAc;AAAA,EACd,mBAAmB;AAAA,EACnB,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AAAA,EACN,UAAU;AAAA,EACV,UAAU;AAAA,EACV,WAAW;AAAA,EACX,SAAS;AAAA,EACT,QAAQ;AACV;AAkEA,MAAM,qBAAqB;AAI3B,MAAM,cAAc;AAGpB,MAAM,gBAAgB,CAAC,MAAc,MAAM,MAAM;AAEjD,MAAM,MAAM,CAAC,GAAU,OAAqB,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,IAAI,EAAE,KAA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