@signosoft/signpad-js 0.3.1 → 0.3.2
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 +43 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -40,11 +40,11 @@ It expertly handles the complexities of **WebHID device connections**, signature
|
|
|
40
40
|
|
|
41
41
|
## 🔐 Lease Setup
|
|
42
42
|
|
|
43
|
-
To use the Signosoft Signpad component
|
|
43
|
+
To use the Signosoft Signpad component with physical signature hardware, a valid `lease` is **required**.
|
|
44
44
|
|
|
45
45
|
#### 🛑 CRITICAL: Mandatory Initialization
|
|
46
46
|
|
|
47
|
-
Without a valid lease, the component
|
|
47
|
+
Without a valid lease, the component can still render, but driver initialization and hardware communication features will be <b>disabled</b>.
|
|
48
48
|
|
|
49
49
|
### 1. Lease flow
|
|
50
50
|
|
|
@@ -129,7 +129,7 @@ To ensure proper communication via the **WebHID API**:
|
|
|
129
129
|
First, install the core package:
|
|
130
130
|
|
|
131
131
|
```bash
|
|
132
|
-
npm install
|
|
132
|
+
npm install @signosoft/signpad-js
|
|
133
133
|
```
|
|
134
134
|
|
|
135
135
|
### 🧰 Framework Integration Guide
|
|
@@ -608,6 +608,7 @@ Toggles the visibility of specific User Interface elements.
|
|
|
608
608
|
| :------------------------- | :-------- | :-------------------------------------------------------------- |
|
|
609
609
|
| `topBarVisible` | `boolean` | Shows/hides the entire top navigation bar. |
|
|
610
610
|
| `topBarClearButtonVisible` | `boolean` | Shows a "Clear" button in the top-left corner. |
|
|
611
|
+
| `topBarConnectButtonVisible` | `boolean` | Shows the connect/disconnect button area in the top-right corner. |
|
|
611
612
|
| `bottomBarVisible` | `boolean` | Shows/hides the entire bottom action bar. |
|
|
612
613
|
| `okButtonVisible` | `boolean` | Shows the **OK** button in the bottom bar. |
|
|
613
614
|
| `clearButtonVisible` | `boolean` | Shows the **Clear** button in the bottom bar. |
|
|
@@ -634,7 +635,7 @@ Handles component localization. It can load external files or use inline definit
|
|
|
634
635
|
|
|
635
636
|
| Field | Type | Description |
|
|
636
637
|
| :------------- | :------- | :---------------------------------------------------------------------------------------------------- |
|
|
637
|
-
| `lang` | `string` | The active language code
|
|
638
|
+
| `lang` | `string` | The active language code. Built-in translations are bundled for `'en'` and `'cs'`; other languages can be supplied via `langPath` or `translations`. |
|
|
638
639
|
| `langPath` | `string` | URL path to fetch translation files. Expects files in `[path]/[lang].json` format. |
|
|
639
640
|
| `translations` | `object` | An inline object containing key-value pairs (e.g., `{ "OK": "Confirm signature" }`). Overrides files. |
|
|
640
641
|
|
|
@@ -658,13 +659,13 @@ Standard event listeners triggered _after_ specific actions. Useful for observin
|
|
|
658
659
|
|
|
659
660
|
| Callback | Payload | Description |
|
|
660
661
|
| :------------- | :----------------------------------------------- | :------------------------------------------------------------------------------------------------- |
|
|
661
|
-
| `onPen` | `event: CustomEvent<IPenData
|
|
662
|
-
| `onConnect` | `event: CustomEvent
|
|
663
|
-
| `onDisconnect` |
|
|
662
|
+
| `onPen` | `event: CustomEvent<IPenData>` | Dispatched when a device or mouse fallback are in contact with component or signature pad display. |
|
|
663
|
+
| `onConnect` | `event: CustomEvent<{ deviceInfo: any }>` | Dispatched when a device or mouse fallback connects. |
|
|
664
|
+
| `onDisconnect` | `event: CustomEvent<void>` | Dispatched when the hardware connection is closed. |
|
|
664
665
|
| `onOk` | `event: CustomEvent<ISignatureConfirmationData>` | Dispatched when signature is confirmed. |
|
|
665
|
-
| `onClear` |
|
|
666
|
-
| `onCancel` |
|
|
667
|
-
| `onError` | `
|
|
666
|
+
| `onClear` | `event: CustomEvent<void>` | Dispatched when the canvas has been cleared. |
|
|
667
|
+
| `onCancel` | `event: CustomEvent<void>` | Dispatched when the user aborts the session. |
|
|
668
|
+
| `onError` | `event: CustomEvent<Error>` | Dispatched on critical failures (lease, driver, connection, etc.). |
|
|
668
669
|
|
|
669
670
|
> `actionHandlers` and `eventCallbacks` are separate hooks and can both be configured.
|
|
670
671
|
|
|
@@ -689,7 +690,8 @@ this.config = {
|
|
|
689
690
|
eventCallbacks: {
|
|
690
691
|
onConnect: (e) =>
|
|
691
692
|
console.log("Pad connected:", e.detail.deviceInfo.deviceName),
|
|
692
|
-
onError: (
|
|
693
|
+
onError: (event) =>
|
|
694
|
+
console.error("Signpad Error:", event.detail.message),
|
|
693
695
|
},
|
|
694
696
|
};
|
|
695
697
|
```
|
|
@@ -703,7 +705,7 @@ The following methods are available on the component instance to control the sig
|
|
|
703
705
|
| `connect()` | `Promise<boolean>` | Connects device to component |
|
|
704
706
|
| `disconnect()` | `Promise<void>` | Disconnects device from component |
|
|
705
707
|
| `startSigning()` | `Promise<void>` | Initializes a new signing session on the canvas and hardware. |
|
|
706
|
-
| `stopSigning()` | `Promise<any>` |
|
|
708
|
+
| `stopSigning()` | `Promise<any>` | Low-level session stop that returns the raw driver payload. |
|
|
707
709
|
| `ok()` | `Promise<ISignatureConfirmationData \| undefined>` | Finalizes the session, cleans the device screen, and returns the signature data. |
|
|
708
710
|
| `clear()` | `Promise<void>` | Wipes the signature from the UI and hardware without ending the session. |
|
|
709
711
|
| `cancel()` | `Promise<void>` | Aborts the current session and resets the component state. |
|
|
@@ -848,7 +850,9 @@ This is the standard way to confirm a signature. It:
|
|
|
848
850
|
|
|
849
851
|
#### 📜 `stopSigning()`
|
|
850
852
|
|
|
851
|
-
A low-level method that forces the driver to stop capturing data and returns the raw
|
|
853
|
+
A low-level method that forces the driver to stop capturing data and returns the raw driver payload. Unlike `ok()`, it does not trigger the full "Finalization" flow (UI transitions or device screen clearing).
|
|
854
|
+
|
|
855
|
+
> Note: `stopSigning()` intentionally exposes the unnormalized raw result, which is why it is documented as `Promise<any>`.
|
|
852
856
|
|
|
853
857
|
#### 📜 `clear()`
|
|
854
858
|
|
|
@@ -890,15 +894,24 @@ signosoft-signpad {
|
|
|
890
894
|
|
|
891
895
|
/* CSS Variables */
|
|
892
896
|
--sign-font-family: Arial, Helvetica, sans-serif;
|
|
897
|
+
--sign-common-border-radius: 8px;
|
|
893
898
|
|
|
894
899
|
/* Top Bar */
|
|
895
900
|
--sign-top-bar-bg-base: var(--background-color-10);
|
|
896
901
|
--sign-top-bar-text-base: var(--primary-color-0);
|
|
897
902
|
--sign-top-bar-padding: var(--spacing-constraints);
|
|
898
903
|
--sign-top-bar-min-height: var(--min-height);
|
|
904
|
+
--sign-top-bar-border-top-left-radius: var(--sign-common-border-radius);
|
|
905
|
+
--sign-top-bar-border-top-right-radius: var(--sign-common-border-radius);
|
|
906
|
+
--sign-top-bar-border-bottom-left-radius: 0;
|
|
907
|
+
--sign-top-bar-border-bottom-right-radius: 0;
|
|
899
908
|
|
|
900
909
|
/* Canvas Area */
|
|
901
910
|
--sign-canvas-bg-base: var(--background-color-0);
|
|
911
|
+
--sign-canvas-wrapper-border-top-left-radius: 0;
|
|
912
|
+
--sign-canvas-wrapper-border-top-right-radius: 0;
|
|
913
|
+
--sign-canvas-wrapper-border-bottom-left-radius: 0;
|
|
914
|
+
--sign-canvas-wrapper-border-bottom-right-radius: 0;
|
|
902
915
|
|
|
903
916
|
/* Line */
|
|
904
917
|
--sign-line-height: 22px;
|
|
@@ -914,6 +927,10 @@ signosoft-signpad {
|
|
|
914
927
|
--sign-bottom-bar-padding: var(--spacing-constraints);
|
|
915
928
|
--sign-bottom-bar-min-height: var(--min-height);
|
|
916
929
|
--sign-bottom-bar-gap: 12px;
|
|
930
|
+
--sign-bottom-bar-border-top-left-radius: 0;
|
|
931
|
+
--sign-bottom-bar-border-top-right-radius: 0;
|
|
932
|
+
--sign-bottom-bar-border-bottom-left-radius: var(--sign-common-border-radius);
|
|
933
|
+
--sign-bottom-bar-border-bottom-right-radius: var(--sign-common-border-radius);
|
|
917
934
|
|
|
918
935
|
/* Button general settings */
|
|
919
936
|
--sign-button-font-size: 16px;
|
|
@@ -968,6 +985,7 @@ signosoft-signpad {
|
|
|
968
985
|
| `--white-color` | `#ffffff` | Pure white color. |
|
|
969
986
|
| `--grey-color` | `#b5b9be` | Disabled state color. |
|
|
970
987
|
| `--sign-font-family` | `Arial, sans-serif` | Global font family. |
|
|
988
|
+
| `--sign-common-border-radius` | `8px` | Shared radius token reused by bars and buttons. |
|
|
971
989
|
|
|
972
990
|
#### Layout & Constraints
|
|
973
991
|
|
|
@@ -984,12 +1002,20 @@ signosoft-signpad {
|
|
|
984
1002
|
| `--sign-top-bar-text-base` | `var(--primary-color-0)` | Text color in the top bar. |
|
|
985
1003
|
| `--sign-top-bar-padding` | `var(--spacing-constraints)` | Inner padding of the top bar. |
|
|
986
1004
|
| `--sign-top-bar-min-height` | `var(--min-height)` | Minimum height of the top bar. |
|
|
1005
|
+
| `--sign-top-bar-border-top-left-radius` | `var(--sign-common-border-radius)` | Top-left radius of the top bar. |
|
|
1006
|
+
| `--sign-top-bar-border-top-right-radius` | `var(--sign-common-border-radius)` | Top-right radius of the top bar. |
|
|
1007
|
+
| `--sign-top-bar-border-bottom-left-radius` | `0` | Bottom-left radius of the top bar. |
|
|
1008
|
+
| `--sign-top-bar-border-bottom-right-radius` | `0` | Bottom-right radius of the top bar. |
|
|
987
1009
|
|
|
988
1010
|
#### Canvas & Signature Line
|
|
989
1011
|
|
|
990
1012
|
| Variable | Default | Description |
|
|
991
1013
|
| :---------------------------------- | :--------------------------------------------- | :-------------------------------------------- |
|
|
992
1014
|
| `--sign-canvas-bg-base` | `var(--background-color-0)` | Background color of the drawing area. |
|
|
1015
|
+
| `--sign-canvas-wrapper-border-top-left-radius` | `0` | Top-left canvas radius, typically rounded when the top bar is hidden. |
|
|
1016
|
+
| `--sign-canvas-wrapper-border-top-right-radius` | `0` | Top-right canvas radius, typically rounded when the top bar is hidden. |
|
|
1017
|
+
| `--sign-canvas-wrapper-border-bottom-left-radius` | `0` | Bottom-left canvas radius, typically rounded when the bottom bar is hidden. |
|
|
1018
|
+
| `--sign-canvas-wrapper-border-bottom-right-radius` | `0` | Bottom-right canvas radius, typically rounded when the bottom bar is hidden. |
|
|
993
1019
|
| `--sign-line-height` | `22px` | Vertical offset/height for the guide line. |
|
|
994
1020
|
| `--sign-line-margin-bottom` | `16px` | Bottom spacing used in canvas line layout. |
|
|
995
1021
|
| `--sign-line-border-base` | `var(--primary-color-10)` | Color of the signature guide line. |
|
|
@@ -1006,6 +1032,10 @@ signosoft-signpad {
|
|
|
1006
1032
|
| `--sign-bottom-bar-padding` | `var(--spacing-constraints)` | Inner padding of the bottom bar. |
|
|
1007
1033
|
| `--sign-bottom-bar-min-height` | `var(--min-height)` | Minimum height of the bottom bar. |
|
|
1008
1034
|
| `--sign-bottom-bar-gap` | `12px` | Space between buttons in the bottom bar. |
|
|
1035
|
+
| `--sign-bottom-bar-border-top-left-radius` | `0` | Top-left radius of the bottom bar. |
|
|
1036
|
+
| `--sign-bottom-bar-border-top-right-radius` | `0` | Top-right radius of the bottom bar. |
|
|
1037
|
+
| `--sign-bottom-bar-border-bottom-left-radius` | `var(--sign-common-border-radius)` | Bottom-left radius of the bottom bar. |
|
|
1038
|
+
| `--sign-bottom-bar-border-bottom-right-radius` | `var(--sign-common-border-radius)` | Bottom-right radius of the bottom bar. |
|
|
1009
1039
|
|
|
1010
1040
|
#### Buttons (General)
|
|
1011
1041
|
|