@signosoft/signpad-js 0.4.10 β†’ 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/README.md CHANGED
@@ -603,7 +603,7 @@ The component is primarily configured through a single `config` property. This o
603
603
 
604
604
  | Option | Type | Required | Description |
605
605
  | :---------- | :------- | :------- | :---------------------------------------------------------------------------- |
606
- | **`lease`** | `object` | **Yes** | Lease payload returned from the lease API call. Mandatory for initialization. |
606
+ | **`lease`** | `object` | Required for hardware mode | Lease payload returned from the lease API call. The component still renders without it, but driver initialization and hardware communication are disabled (see [Lease Setup](#-lease-setup)). |
607
607
 
608
608
  ### πŸ‘οΈ uiVisibilityOptions
609
609
 
@@ -640,7 +640,7 @@ Handles component localization. It can load external files or use inline definit
640
640
 
641
641
  | Field | Type | Description |
642
642
  | :------------- | :------- | :------------------------------------------------------------------------------------------------------------------------------------------------------- |
643
- | `lang` | `string` | The active language code. Built-in translations are bundled for `'en'`, `'cs'`, and `'pt'`; other languages can be supplied via `langPath` or `translations`. |
643
+ | `lang` | `string` | The active language code. Built-in translations are bundled for `'en'` and `'cs'`; other languages (including `'pt'`) require `langPath` or `translations`. |
644
644
  | `langPath` | `string` | URL path to fetch translation files. Expects files in `[path]/[lang].json` format. |
645
645
  | `translations` | `object` | An inline object containing key-value pairs (e.g., `{ "OK": "Confirm signature" }`). Overrides files. |
646
646
 
@@ -648,7 +648,7 @@ Handles component localization. It can load external files or use inline definit
648
648
 
649
649
  Localization is driven from `languageOptions`, but you can also provide overrides at runtime:
650
650
 
651
- 1. **Set the language code** in `config.languageOptions.lang`. English (`en`) is the fallback, Czech (`cs`) and Portuguese (`pt`) are shipped alongside it.
651
+ 1. **Set the language code** in `config.languageOptions.lang`. English (`en`) is the fallback, and Czech (`cs`) is bundled alongside it. Other languages, including Portuguese (`pt`), must be supplied via `langPath` or `translations` β€” they are not bundled.
652
652
  2. **Load a hosted file** by pointing `languageOptions.langPath` to the directory that contains `[lang].json`. The loader will fetch `${langPath}/${lang}.json` (or the exact file if you include the `.json` suffix).
653
653
  3. **Override only specific phrases** by passing a `translations` objectβ€”either a flat key map or a per-language map (`{ en: {...}, cs: {...} }`). Inline values take precedence over both built-in and fetched files.
654
654
  4. **Dynamic placeholders** (for example, `{device}` in `TEXT_SIGNING_WITH_DEVICE`) are replaced using the `LocalizationManager.t` helper. Keep the braces intact if you expect runtime interpolation.
@@ -751,7 +751,7 @@ The following methods are available on the component instance to control the sig
751
751
  | `connect()` | `Promise<void>` | Connects device to component |
752
752
  | `disconnect()` | `Promise<void>` | Disconnects device from component |
753
753
  | `startSigning()` | `Promise<void>` | Initializes a new signing session on the canvas and hardware. |
754
- | `stopSigning()` | `Promise<any>` | Low-level session stop that returns the raw driver payload. |
754
+ | `stopSigning()` | `Promise<any>` | Low-level session stop that returns the signature payload. |
755
755
  | `ok()` | `Promise<ISignatureConfirmationData \| undefined>` | Finalizes the session, cleans the device screen, and returns the signature data. |
756
756
  | `clear()` | `Promise<void>` | Wipes the signature from the UI and hardware without ending the session. |
757
757
  | `cancel()` | `Promise<void>` | Aborts the current session and resets the component state. |
@@ -818,40 +818,50 @@ This is the standard way to confirm a signature. It:
818
818
  ```
819
819
 
820
820
  ```js
821
- // [0] Points structure
821
+ // [0] Points structure β€” same IPenData shape documented under onPen below
822
822
  {
823
- absoluteX: number,
824
- absoluteY: number,
825
- inContact: boolean,
826
- pressure: number,
827
- ready: boolean,
828
823
  relativeX: number, // normalized 0..1
829
824
  relativeY: number, // normalized 0..1
830
- sequence: number,
831
- timestamp: number, // Unix ms (Date.now()) at the time of capture
832
- timestampInSeconds: number // seconds elapsed since the start of the signing session
825
+ pressure: number,
826
+ inContact: boolean,
827
+ timestamp: number, // Unix ms (Date.now()) at the time of capture
828
+ timestampInSeconds: number // seconds elapsed since the start of the signing session
833
829
  }
834
830
  ```
835
831
 
836
832
  ```js
837
- // [1] imageBase64 β€” plain base64 PNG string
833
+ // [1] imageBase64 β€” base64 PNG data URL, or null if no image could be captured
838
834
  "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA..."
839
835
  ```
840
836
 
841
837
  ```js
842
838
  // [2] Metadata structure
839
+ // The exact shape depends on whether a physical tablet or the mouse/touch
840
+ // fallback produced the signature β€” the two paths report different fields.
841
+
842
+ // Mouse / touch fallback:
843
843
  {
844
844
  canvas: {
845
- top: number,
846
- left: number,
847
- right: number,
848
- bottom: number,
849
845
  width: number,
850
846
  height: number,
851
847
  cssWidth: number,
852
848
  cssHeight: number,
853
849
  dpr: number
854
850
  },
851
+ tablet: undefined,
852
+ duration: number // seconds elapsed between the first and last recorded pen sample
853
+ }
854
+
855
+ // Physical tablet (driver-reported):
856
+ {
857
+ canvas: {
858
+ top?: number,
859
+ left?: number,
860
+ right?: number,
861
+ bottom?: number,
862
+ width: number,
863
+ height: number
864
+ },
855
865
  tablet: {
856
866
  name: string,
857
867
  aspectRatio: number,
@@ -862,8 +872,8 @@ This is the standard way to confirm a signature. It:
862
872
  serialNumber: Promise<string> | string,
863
873
  vendorId: number | null,
864
874
  productId: number | null
865
- },
866
- duration: number // seconds elapsed from startSigning() (or last clear) to stopSigning()
875
+ }
876
+ // no `duration` field is reported for the physical-tablet path
867
877
  }
868
878
  ```
869
879
 
@@ -875,22 +885,20 @@ This is the standard way to confirm a signature. It:
875
885
 
876
886
  ```js
877
887
  {
878
- absoluteX: number,
879
- absoluteY: number,
880
- inContact: boolean,
881
- pressure: number,
882
- ready: boolean,
883
888
  relativeX: number, // normalized 0..1
884
889
  relativeY: number, // normalized 0..1
885
- sequence: number,
886
- timestamp: number, // Unix ms (Date.now()) at the time of capture
887
- timestampInSeconds: number // seconds elapsed since the start of the signing session
890
+ pressure: number,
891
+ inContact: boolean,
892
+ timestamp: number, // Unix ms (Date.now()) at the time of capture
893
+ timestampInSeconds: number // seconds elapsed since the start of the signing session
888
894
  }
889
895
  ```
890
896
 
897
+ > The `IPenData` type also allows optional `absoluteX`, `absoluteY`, `ready`, and `sequence` fields for forward compatibility with the underlying driver, but the component does not currently populate them.
898
+
891
899
  #### πŸ“œ `stopSigning()`
892
900
 
893
- A low-level method that forces the driver to stop capturing data and returns the raw driver payload as a 3-element tuple `[penDataBatch, imageBase64, metadata]`. Unlike `ok()`, it does not trigger the full "Finalization" flow (UI transitions or device screen clearing).
901
+ A low-level method that forces the driver to stop capturing data and returns the signature payload as a 3-element tuple `[penDataBatch, imageBase64, metadata]`. Unlike `ok()`, it does not trigger the full "Finalization" flow (UI transitions or device screen clearing).
894
902
 
895
903
  - `penDataBatch` β€” array of `IPenData` points collected during the session
896
904
  - `imageBase64` β€” PNG data URL of the signature drawn on canvas, or `null` if unavailable
@@ -915,7 +923,7 @@ The component progresses through a finite set of states, exposed via the `Signpa
915
923
  | `WAITING_FOR_DEVICE_SELECTION` | `"waiting_for_device_selection"` | Browser HID picker is open, waiting for user selection. |
916
924
  | `CONNECTED_PHYSICAL` | `"connected_physical"` | Physical tablet connected and ready. |
917
925
  | `CONNECTED_MOUSE_FALLBACK` | `"connected_mouse_fallback"` | No tablet found; mouse/touch fallback is active. |
918
- | `SIGNING_ACTIVE` | `"signing_active"` | Pen input is live; user is drawing. |
926
+ | `SIGNING_ACTIVE` | `"signing_active"` | Defined for future use; the component does not currently transition to this state β€” drawing happens while still in `CONNECTED_PHYSICAL`/`CONNECTED_MOUSE_FALLBACK`. |
919
927
  | `PROCESSING_OK` | `"processing_ok"` | OK action is being processed (finalizing signature). |
920
928
  | `PROCESSING_CLEAR` | `"processing_clear"` | Clear action is being processed. |
921
929
  | `PROCESSING_CANCEL` | `"processing_cancel"` | Cancel action is being processed. |
@@ -1011,6 +1019,9 @@ signosoft-signpad {
1011
1019
  --sign-button-primary-text-base: var(--white-color);
1012
1020
  --sign-button-primary-text-hover: var(--white-color);
1013
1021
  --sign-button-primary-text-disabled: var(--white-color);
1022
+ --sign-button-primary-border-base: 1px solid var(--primary-color-0);
1023
+ --sign-button-primary-border-hover: 1px solid var(--primary-color-10);
1024
+ --sign-button-primary-border-disabled: 1px solid var(--grey-color);
1014
1025
 
1015
1026
  /* Link Buttons (Connect signpad) */
1016
1027
  --sign-button-link-bg-base: transparent;
@@ -1122,6 +1133,9 @@ signosoft-signpad {
1122
1133
  | `--sign-button-primary-text-base` | Text color for primary buttons. |
1123
1134
  | `--sign-button-primary-text-hover` | Hover text color. |
1124
1135
  | `--sign-button-primary-text-disabled` | Disabled text color. |
1136
+ | `--sign-button-primary-border-base` | Border of primary buttons. |
1137
+ | `--sign-button-primary-border-hover` | Hover border color. |
1138
+ | `--sign-button-primary-border-disabled` | Disabled border color. |
1125
1139
 
1126
1140
  #### Link/Connect Buttons
1127
1141
 
package/dist/index.d.ts CHANGED
@@ -57,7 +57,7 @@ declare class ButtonManager {
57
57
 
58
58
  /**
59
59
  * `CanvasManager` is a lightweight canvas utility.
60
- * Drawing is handled by SignatureLayer/SignatureCapture in `src/lib`.
60
+ * Drawing is handled by SignatureLayer from `@signosoft/tablet-driver`.
61
61
  */
62
62
  declare class CanvasManager {
63
63
  /** @private The target canvas element */
@@ -86,7 +86,7 @@ declare class CanvasManager {
86
86
  updateDrawingOptions(options: IDrawingOptions): void;
87
87
  /**
88
88
  * Draws a stroke segment for mouse/touch fallback input.
89
- * Physical tablet strokes are rendered by SignatureLayer/SignatureCapture.
89
+ * Physical tablet strokes are rendered by SignatureLayer.
90
90
  */
91
91
  drawSegment(penData: IPenData): void;
92
92
  /**
@@ -184,6 +184,8 @@ declare class ConnectionManager {
184
184
  /** @private Minimum delay between pen events (approx 60fps) */
185
185
  private throttleDelayMs;
186
186
  private penDataLog;
187
+ /** @private Wall-clock time when the current signing session started, for timestampInSeconds */
188
+ private sessionStartTime;
187
189
  private static readonly POINTER_FALLBACK_DEVICE_NAME;
188
190
  /**
189
191
  * @param component - The host SignosoftSignpad instance.
@@ -230,6 +232,11 @@ declare class ConnectionManager {
230
232
  */
231
233
  startSigning(canvas: HTMLCanvasElement, drawingOptions?: IDrawingOptions): Promise<boolean>;
232
234
  logPenData(data: IPenData): void;
235
+ /**
236
+ * Calculates the seconds elapsed since the start of the signing session.
237
+ * @private
238
+ */
239
+ private timestampToSeconds;
233
240
  private buildConfirmationData;
234
241
  /**
235
242
  * Stops the current signing session if active.