@signosoft/signpad-js 0.2.0 → 0.2.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 +314 -17
- package/dist/index.d.ts +6 -10
- package/dist/signosoft-signpad.js +129 -152
- package/dist/signosoft-signpad.umd.cjs +15 -15
- package/docsVideo.gif +0 -0
- package/package.json +3 -3
- package/framework-docs/integration-angular.md +0 -100
- package/framework-docs/integration-js.md +0 -64
- package/framework-docs/integration-react.md +0 -42
- package/framework-docs/integration-vue.md +0 -67
package/README.md
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## 📍 Table of Contents
|
|
4
4
|
|
|
5
|
-
| Core Concepts & Overview | Getting Started & Usage | Advanced & Support
|
|
6
|
-
| :---------------------------------------- | :--------------------------------- |
|
|
7
|
-
| 📜 [Description](#-description) | 📦 [Installation](#-installation) |
|
|
8
|
-
| 🎬 [Demo](#-demo) | 🔐 [Licensing](#-get-your-license) | 📄 [License](#-license)
|
|
9
|
-
| ⚙️ [Tech stack](#-tech-stack--built-with) | 🚀 [Quick Start](#-quick-start) |
|
|
10
|
-
| | 📋 [Properties](#-properties) |
|
|
11
|
-
| | 🧩 [Methods](#-methods) |
|
|
12
|
-
| |
|
|
5
|
+
| Core Concepts & Overview | Getting Started & Usage | Advanced & Support |
|
|
6
|
+
| :---------------------------------------- | :--------------------------------- | :--------------------------------- |
|
|
7
|
+
| 📜 [Description](#-description) | 📦 [Installation](#-installation) | 🤝 [Feedback](#-feedback--support) |
|
|
8
|
+
| 🎬 [Demo](#-demo) | 🔐 [Licensing](#-get-your-license) | 📄 [License](#-license) |
|
|
9
|
+
| ⚙️ [Tech stack](#-tech-stack--built-with) | 🚀 [Quick Start](#-quick-start) | |
|
|
10
|
+
| | 📋 [Properties](#-properties) | |
|
|
11
|
+
| | 🧩 [Methods](#-methods) | |
|
|
12
|
+
| | 🎨 [Styling](#-styling--theming) | |
|
|
13
13
|
|
|
14
14
|
## 📜 Description
|
|
15
15
|
|
|
@@ -29,7 +29,7 @@ It expertly handles the complexities of **WebHID device connections**, signature
|
|
|
29
29
|
|
|
30
30
|
## 🎬 Demo
|
|
31
31
|
|
|
32
|
-
<img src="
|
|
32
|
+
<img src="https://unpkg.com/@signosoft/signpad-js@latest/docsVideo.gif" alt="Signosoft Demo" width="500" />
|
|
33
33
|
|
|
34
34
|
## ⚙️ Tech Stack / Built With
|
|
35
35
|
|
|
@@ -104,15 +104,312 @@ First, install the core package:
|
|
|
104
104
|
npm install your-library-name
|
|
105
105
|
```
|
|
106
106
|
|
|
107
|
-
### Framework Integration Guide
|
|
107
|
+
### 🧰 Framework Integration Guide
|
|
108
108
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
109
|
+
<details>
|
|
110
|
+
<summary>
|
|
111
|
+
<img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/angularjs/angularjs-original.svg" alt="Angular" width="15" height="15">
|
|
112
|
+
<b>Angular</b> <font color="green"><b>(Live)</b></font>
|
|
113
|
+
</summary>
|
|
114
|
+
<br>
|
|
115
|
+
|
|
116
|
+
# <img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/angular/angular-original.svg" alt="Angular" width="30" height="30"> Angular Integration Guide
|
|
117
|
+
|
|
118
|
+
This guide describes how to integrate the `@signosoft/signpad-js` web component into an Angular application.
|
|
119
|
+
|
|
120
|
+
## 1. Installation
|
|
121
|
+
|
|
122
|
+
Install the core package using npm:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
npm install @signosoft/signpad-js
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## 2. Create the Bridge Directive
|
|
129
|
+
|
|
130
|
+
Since `signosoft-signpad` is a Web Component, Angular requires a Directive to properly sync configuration changes and provide typed access to the component instance.
|
|
131
|
+
|
|
132
|
+
Create `signosoft-signpad.directive.ts`:
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
import {
|
|
136
|
+
Directive,
|
|
137
|
+
ElementRef,
|
|
138
|
+
Input,
|
|
139
|
+
OnChanges,
|
|
140
|
+
SimpleChanges,
|
|
141
|
+
} from "@angular/core";
|
|
142
|
+
import type { SignosoftSignpad, SignpadConfig } from "@signosoft/signpad-js";
|
|
143
|
+
|
|
144
|
+
@Directive({
|
|
145
|
+
selector: "signosoft-signpad",
|
|
146
|
+
standalone: true,
|
|
147
|
+
})
|
|
148
|
+
export class SignosoftSignpadDirective implements OnChanges {
|
|
149
|
+
@Input() config?: SignpadConfig;
|
|
150
|
+
|
|
151
|
+
constructor(private host: ElementRef<SignosoftSignpad>) {}
|
|
152
|
+
|
|
153
|
+
// Access the native Web Component instance
|
|
154
|
+
get signpadRef(): SignosoftSignpad {
|
|
155
|
+
return this.host.nativeElement;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
ngOnChanges(changes: SimpleChanges) {
|
|
159
|
+
const el = this.host.nativeElement as any;
|
|
160
|
+
for (const key of Object.keys(changes)) {
|
|
161
|
+
el[key] = (this as any)[key];
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## 3. Implementation in Component
|
|
168
|
+
|
|
169
|
+
Import the library, the directive, and add the **`CUSTOM_ELEMENTS_SCHEMA`**.
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
import { Component, ViewChild, CUSTOM_ELEMENTS_SCHEMA } from "@angular/core";
|
|
173
|
+
import "@signosoft/signpad-js"; // Import the Web Component registration
|
|
174
|
+
import {
|
|
175
|
+
type SignosoftSignpad,
|
|
176
|
+
type SignpadConfig,
|
|
177
|
+
} from "@signosoft/signpad-js";
|
|
178
|
+
import { SignosoftSignpadDirective } from "./directives/signosoft-signpad.directive";
|
|
179
|
+
|
|
180
|
+
@Component({
|
|
181
|
+
selector: "app-root",
|
|
182
|
+
standalone: true,
|
|
183
|
+
imports: [SignosoftSignpadDirective],
|
|
184
|
+
templateUrl: "./app.component.html",
|
|
185
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA], // Mandatory for custom HTML tags
|
|
186
|
+
})
|
|
187
|
+
export class AppComponent {
|
|
188
|
+
@ViewChild(SignosoftSignpadDirective)
|
|
189
|
+
signpadDirective!: SignosoftSignpadDirective;
|
|
190
|
+
|
|
191
|
+
config: SignpadConfig = {
|
|
192
|
+
licenseKey: "YOUR-LICENSE-KEY",
|
|
193
|
+
// More info in "properties" section
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
// Helper to access methods easily (ok, clear, cancel, etc.)
|
|
197
|
+
public get signpad(): SignosoftSignpad | undefined {
|
|
198
|
+
return this.signpadDirective?.signpadRef;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## 4. Component Template
|
|
204
|
+
|
|
205
|
+
Use the custom tag in your HTML and bind the configuration object.
|
|
206
|
+
|
|
207
|
+
```html
|
|
208
|
+
<div>
|
|
209
|
+
<div>
|
|
210
|
+
<signosoft-signpad [config]="config"></signosoft-signpad>
|
|
211
|
+
</div>
|
|
212
|
+
</div>
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
</details>
|
|
216
|
+
|
|
217
|
+
<details>
|
|
218
|
+
<summary>
|
|
219
|
+
<img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/react/react-original.svg" alt="React" width="15" height="15">
|
|
220
|
+
<b>React</b> <font color="green"><b>(Live)</b></font>
|
|
221
|
+
</summary>
|
|
222
|
+
<br>
|
|
223
|
+
|
|
224
|
+
# <img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/react/react-original.svg" alt="React" width="30" height="30"> React - Quick start
|
|
225
|
+
|
|
226
|
+
This guide describes how to integrate the `@signosoft/signpad-js` web component into a React application (Functional Components with Hooks).
|
|
227
|
+
|
|
228
|
+
## 1. Installation
|
|
229
|
+
|
|
230
|
+
Install the core package using npm:
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
npm install @signosoft/signpad-js
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
## 2. Implementation
|
|
237
|
+
|
|
238
|
+
In React, we use the `useRef` hook to interact with the component's methods (like `ok()` or `clear()`) and pass the configuration directly via props.
|
|
239
|
+
|
|
240
|
+
```tsx
|
|
241
|
+
import { useRef } from "react";
|
|
242
|
+
import "@signosoft/signpad-js"; // Registers the web component
|
|
243
|
+
import type { SignpadConfig } from "@signosoft/signpad-js";
|
|
244
|
+
|
|
245
|
+
function App() {
|
|
246
|
+
// Use ref to access component methods (ok, clear, connect, etc. by signpadRef.current)
|
|
247
|
+
const signpadRef = useRef<any>(null);
|
|
248
|
+
|
|
249
|
+
const config: SignpadConfig = {
|
|
250
|
+
licenseKey: "YOUR-LICENSE-KEY",
|
|
251
|
+
// More info in "properties" section
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
return (
|
|
255
|
+
<div>
|
|
256
|
+
<h1>Signosoft Signpad React Example</h1>
|
|
257
|
+
<signosoft-signpad ref={signpadRef} config={config} />
|
|
258
|
+
</div>
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export default App;
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
</details>
|
|
266
|
+
|
|
267
|
+
<details>
|
|
268
|
+
<summary>
|
|
269
|
+
<img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/vuejs/vuejs-original.svg" alt="Vue" width="15" height="15">
|
|
270
|
+
<b>Vue.js</b> <font color="green"><b>(Live)</b></font>
|
|
271
|
+
</summary>
|
|
272
|
+
<br>
|
|
273
|
+
|
|
274
|
+
# <img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/vuejs/vuejs-original.svg" alt="Vue" width="30" height="30"> Vue.js Integration Guide
|
|
275
|
+
|
|
276
|
+
This guide describes how to integrate the `@signosoft/signpad-js` web component into a Vue 3 application using the Composition API (`<script setup>`).
|
|
277
|
+
|
|
278
|
+
## 1. Installation
|
|
279
|
+
|
|
280
|
+
Install the core package using npm:
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
npm install @signosoft/signpad-js
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## 2. Configure Vue to recognize Custom Elements
|
|
287
|
+
|
|
288
|
+
By default, Vue will try to resolve `signosoft-signpad` as a Vue component and will throw a warning. You need to tell Vue to ignore this tag.
|
|
289
|
+
|
|
290
|
+
**If you are using Vite (`vite.config.ts`):**
|
|
291
|
+
|
|
292
|
+
```typescript
|
|
293
|
+
import { defineConfig } from "vite";
|
|
294
|
+
import vue from "@vitejs/plugin-vue";
|
|
295
|
+
|
|
296
|
+
export default defineConfig({
|
|
297
|
+
plugins: [
|
|
298
|
+
vue({
|
|
299
|
+
template: {
|
|
300
|
+
compilerOptions: {
|
|
301
|
+
// Treat all tags starting with 'signosoft-' as custom elements
|
|
302
|
+
isCustomElement: (tag) => tag.startsWith("signosoft-"),
|
|
303
|
+
},
|
|
304
|
+
},
|
|
305
|
+
}),
|
|
306
|
+
],
|
|
307
|
+
});
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
## 3. Implementation
|
|
311
|
+
|
|
312
|
+
In Vue 3, we use `ref` to hold the reference to the DOM element and pass the configuration via the `:config` attribute.
|
|
313
|
+
|
|
314
|
+
```typescript
|
|
315
|
+
<script setup lang="ts">
|
|
316
|
+
import { ref } from "vue";
|
|
317
|
+
import "@signosoft/signpad-js"; // Registers the Web Component
|
|
318
|
+
import type { SignpadConfig, SignosoftSignpad, IPenData } from "@signosoft/signpad-js";
|
|
319
|
+
|
|
320
|
+
// Use ref to access component methods (ok, clear, connect, etc. by signpadRef.value)
|
|
321
|
+
const signpadRef = ref<SignosoftSignpad | null>(null);
|
|
322
|
+
|
|
323
|
+
const signpadConfig: SignpadConfig = {
|
|
324
|
+
licenseKey: "YOUR-LICENSE-KEY",
|
|
325
|
+
// More info in "properties" section
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
</script>
|
|
329
|
+
|
|
330
|
+
<template>
|
|
331
|
+
<div>
|
|
332
|
+
<signosoft-signpad
|
|
333
|
+
ref="signpadRef"
|
|
334
|
+
:config="signpadConfig"
|
|
335
|
+
></signosoft-signpad>
|
|
336
|
+
</div>
|
|
337
|
+
</template>
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
</details>
|
|
341
|
+
|
|
342
|
+
<details>
|
|
343
|
+
<summary>
|
|
344
|
+
<img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/javascript/javascript-original.svg" alt="JS" width="15" height="15">
|
|
345
|
+
<b>Vanilla JS</b> <font color="green"><b>(Live)</b></font>
|
|
346
|
+
</summary>
|
|
347
|
+
<br>
|
|
348
|
+
|
|
349
|
+
# 🍦 Vanilla JS Integration Guide
|
|
350
|
+
|
|
351
|
+
This guide describes how to integrate the `@signosoft/signpad-js` web component into a plain JavaScript project without any frameworks.
|
|
352
|
+
|
|
353
|
+
## 1. Installation
|
|
354
|
+
|
|
355
|
+
Install the package via npm:
|
|
356
|
+
|
|
357
|
+
```bash
|
|
358
|
+
npm install @signosoft/signpad-js
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
Or, if you are not using a bundler, you can include the script directly in your HTML (ensure the path points to the compiled bundle in `node_modules` or a CDN).
|
|
362
|
+
|
|
363
|
+
## 2. JavaScript Implementation
|
|
364
|
+
|
|
365
|
+
In Vanilla JS, you interact with the component by selecting it from the DOM and assigning the configuration directly to its `config` property.
|
|
366
|
+
|
|
367
|
+
```javascript
|
|
368
|
+
import "@signosoft/signpad-js";
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* INTELLISENSE SUPPORT (Optional)
|
|
372
|
+
* Helps VS Code provide autocomplete for methods and properties.
|
|
373
|
+
* @type {import('@signosoft/signpad-js').SignosoftSignpad}
|
|
374
|
+
*/
|
|
375
|
+
const pad = document.querySelector("signosoft-signpad");
|
|
376
|
+
|
|
377
|
+
// 1. Initial Configuration
|
|
378
|
+
pad.config = {
|
|
379
|
+
licenseKey: "YOUR-LICENSE-KEY",
|
|
380
|
+
};
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
## 3. HTML Structure
|
|
384
|
+
|
|
385
|
+
Add the custom element tag to your HTML and create the necessary control buttons.
|
|
386
|
+
|
|
387
|
+
```html
|
|
388
|
+
<!-- index.html -->
|
|
389
|
+
<!DOCTYPE html>
|
|
390
|
+
<html lang="en">
|
|
391
|
+
<head>
|
|
392
|
+
<meta charset="UTF-8" />
|
|
393
|
+
<title>Signosoft Signpad - Vanilla JS</title>
|
|
394
|
+
</head>
|
|
395
|
+
<body>
|
|
396
|
+
<h1>Signosoft Signpad</h1>
|
|
397
|
+
<!-- The Web Component -->
|
|
398
|
+
<signosoft-signpad id="my-signpad"></signosoft-signpad>
|
|
399
|
+
<!-- Main logic script -->
|
|
400
|
+
<script type="module" src="main.js"></script>
|
|
401
|
+
</body>
|
|
402
|
+
</html>
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
## 4. Key Concepts
|
|
406
|
+
|
|
407
|
+
- **Direct Property Assignment:** Unlike some frameworks that use attributes, in Plain JS you should assign the configuration directly: `element.config = { ... }`.
|
|
408
|
+
- **Module System:** Ensure your `<script>` tag has `type="module"` to use the `import` statement.
|
|
409
|
+
- **Methods:** All methods like `.connect()`, `.ok()`, and `.clear()` are available directly on the DOM element object.
|
|
410
|
+
- **DOM Events:** The component dispatches standard DOM events (like `sign-ok`, `sign-clear`) which you can listen to using `addEventListener`.
|
|
411
|
+
|
|
412
|
+
</details>
|
|
116
413
|
|
|
117
414
|
## 📋 Properties
|
|
118
415
|
|
package/dist/index.d.ts
CHANGED
|
@@ -95,7 +95,7 @@ declare class CanvasManager {
|
|
|
95
95
|
* Handles coordinate normalization and pressure-based thickness.
|
|
96
96
|
* @param penData - Data containing coordinates (0-1), pressure, and contact status.
|
|
97
97
|
*/
|
|
98
|
-
drawSegment(penData:
|
|
98
|
+
drawSegment(penData: IPenData_2): void;
|
|
99
99
|
/**
|
|
100
100
|
* Wipes the canvas clean and resets the drawing state.
|
|
101
101
|
*/
|
|
@@ -193,7 +193,6 @@ declare class ConnectionManager {
|
|
|
193
193
|
private penDataToDispatch;
|
|
194
194
|
/** @private Minimum delay between pen events (approx 60fps) */
|
|
195
195
|
private throttleDelayMs;
|
|
196
|
-
private fetchShimInstalled;
|
|
197
196
|
/**
|
|
198
197
|
* @param component - The host SignosoftSignpad instance.
|
|
199
198
|
*/
|
|
@@ -269,10 +268,6 @@ declare class ConnectionManager {
|
|
|
269
268
|
* @returns Resolves when the driver is initialized.
|
|
270
269
|
*/
|
|
271
270
|
private initializeTabletWithLicense;
|
|
272
|
-
/**
|
|
273
|
-
* Installs a fetch shim to resolve lib assets when bundled.
|
|
274
|
-
*/
|
|
275
|
-
private installLibAsset;
|
|
276
271
|
isFallback(deviceInfo: any | null, isDeviceConnected: boolean, includeDisconnected: boolean): boolean;
|
|
277
272
|
/**
|
|
278
273
|
* Normalizes device info to always include deviceName.
|
|
@@ -321,8 +316,8 @@ export declare interface IEventCallbacks {
|
|
|
321
316
|
deviceInfo: any;
|
|
322
317
|
}>) => void;
|
|
323
318
|
onDisconnect?: (event: CustomEvent<void>) => void;
|
|
324
|
-
onPen?: (event: CustomEvent<
|
|
325
|
-
onOk?: (event: CustomEvent<
|
|
319
|
+
onPen?: (event: CustomEvent<IPenData_2>) => void;
|
|
320
|
+
onOk?: (event: CustomEvent<any>) => void;
|
|
326
321
|
onClear?: (event: CustomEvent<void>) => void;
|
|
327
322
|
onCancel?: (event: CustomEvent<void>) => void;
|
|
328
323
|
onError?: (event: CustomEvent<Error>) => void;
|
|
@@ -334,7 +329,7 @@ export declare interface ILanguageOptions {
|
|
|
334
329
|
translations?: ITranslationSet | Record<string, ITranslationSet>;
|
|
335
330
|
}
|
|
336
331
|
|
|
337
|
-
|
|
332
|
+
declare type IPenData_2 = {
|
|
338
333
|
relativeX: number;
|
|
339
334
|
relativeY: number;
|
|
340
335
|
absoluteX?: number;
|
|
@@ -344,9 +339,10 @@ export declare type IPenData = {
|
|
|
344
339
|
inContact: boolean;
|
|
345
340
|
[key: string]: any;
|
|
346
341
|
};
|
|
342
|
+
export { IPenData_2 as IPenData }
|
|
347
343
|
|
|
348
344
|
export declare interface IPenDataCallback {
|
|
349
|
-
(penData:
|
|
345
|
+
(penData: IPenData_2): void;
|
|
350
346
|
}
|
|
351
347
|
|
|
352
348
|
export declare interface ITranslationSet {
|