entasis 0.13.7 → 0.13.8
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/dist/components/Form/Form/form.state.svelte.d.ts +4 -0
- package/dist/components/Form/Form/visibility.d.ts +2 -0
- package/dist/components/Form/MultiStepForm/multiStepForm.state.svelte.d.ts +4 -0
- package/dist/components/Form/SignatureInput/SignatureInput.svelte +39 -1
- package/dist/components/Form/SignatureInput/index.d.ts +1 -1
- package/dist/components/Form/SignatureInput/signatureInput.mcp.d.ts +1 -1
- package/dist/components/Form/SignatureInput/signatureInput.mcp.js +1 -0
- package/dist/components/Form/SignatureInput/signatureInput.props.d.ts +9 -0
- package/dist/components/Form/SignatureInput/signatureInput.theme.d.ts +18 -3
- package/dist/components/Form/SignatureInput/signatureInput.theme.js +13 -2
- package/dist/generated/componentContract.d.ts +1 -1
- package/dist/generated/componentContract.js +1 -0
- package/package.json +1 -1
|
@@ -527,6 +527,7 @@ export declare class FormState<I extends FormInputs = FormInputs> {
|
|
|
527
527
|
} & Omit<import("../Field/field.js").InputProps<"signature">, "theme"> & {
|
|
528
528
|
format?: import("../SignatureInput/signatureInput.strokes.ts").SignatureFormat;
|
|
529
529
|
inkColor?: string;
|
|
530
|
+
imageInk?: import("../SignatureInput/signatureInput.props.ts").SignatureImageInk;
|
|
530
531
|
strokeWidth?: number;
|
|
531
532
|
placeholder?: string;
|
|
532
533
|
clearLabel?: string;
|
|
@@ -1412,6 +1413,7 @@ export declare class FormState<I extends FormInputs = FormInputs> {
|
|
|
1412
1413
|
} & Omit<import("../Field/field.js").InputProps<"signature">, "theme"> & {
|
|
1413
1414
|
format?: import("../SignatureInput/signatureInput.strokes.ts").SignatureFormat;
|
|
1414
1415
|
inkColor?: string;
|
|
1416
|
+
imageInk?: import("../SignatureInput/signatureInput.props.ts").SignatureImageInk;
|
|
1415
1417
|
strokeWidth?: number;
|
|
1416
1418
|
placeholder?: string;
|
|
1417
1419
|
clearLabel?: string;
|
|
@@ -2493,6 +2495,7 @@ export declare class FormState<I extends FormInputs = FormInputs> {
|
|
|
2493
2495
|
} & Omit<import("../Field/field.js").InputProps<"signature">, "theme"> & {
|
|
2494
2496
|
format?: import("../SignatureInput/signatureInput.strokes.ts").SignatureFormat;
|
|
2495
2497
|
inkColor?: string;
|
|
2498
|
+
imageInk?: import("../SignatureInput/signatureInput.props.ts").SignatureImageInk;
|
|
2496
2499
|
strokeWidth?: number;
|
|
2497
2500
|
placeholder?: string;
|
|
2498
2501
|
clearLabel?: string;
|
|
@@ -3378,6 +3381,7 @@ export declare class FormState<I extends FormInputs = FormInputs> {
|
|
|
3378
3381
|
} & Omit<import("../Field/field.js").InputProps<"signature">, "theme"> & {
|
|
3379
3382
|
format?: import("../SignatureInput/signatureInput.strokes.ts").SignatureFormat;
|
|
3380
3383
|
inkColor?: string;
|
|
3384
|
+
imageInk?: import("../SignatureInput/signatureInput.props.ts").SignatureImageInk;
|
|
3381
3385
|
strokeWidth?: number;
|
|
3382
3386
|
placeholder?: string;
|
|
3383
3387
|
clearLabel?: string;
|
|
@@ -1400,6 +1400,7 @@ export declare function prepareInputProps(input: FormFieldInput, size: Sizes, la
|
|
|
1400
1400
|
format?: import("../SignatureInput/signatureInput.strokes.ts").SignatureFormat | undefined;
|
|
1401
1401
|
clearLabel?: string | undefined;
|
|
1402
1402
|
inkColor?: string | undefined;
|
|
1403
|
+
imageInk?: import("../SignatureInput/signatureInput.props.ts").SignatureImageInk | undefined;
|
|
1403
1404
|
strokeWidth?: number | undefined;
|
|
1404
1405
|
undoLabel?: string | undefined;
|
|
1405
1406
|
display?: string;
|
|
@@ -7755,6 +7756,7 @@ export declare function prepareInputProps(input: FormFieldInput, size: Sizes, la
|
|
|
7755
7756
|
format?: import("../SignatureInput/signatureInput.strokes.ts").SignatureFormat | undefined;
|
|
7756
7757
|
clearLabel?: string | undefined;
|
|
7757
7758
|
inkColor?: string | undefined;
|
|
7759
|
+
imageInk?: import("../SignatureInput/signatureInput.props.ts").SignatureImageInk | undefined;
|
|
7758
7760
|
strokeWidth?: number | undefined;
|
|
7759
7761
|
undoLabel?: string | undefined;
|
|
7760
7762
|
display?: string;
|
|
@@ -442,6 +442,7 @@ export declare class MultiStepFormState<I extends MultiStepFormItems = FormStep[
|
|
|
442
442
|
} & Omit<import("../Field/field.ts").InputProps<"signature">, "theme"> & {
|
|
443
443
|
format?: import("../SignatureInput/signatureInput.strokes.ts").SignatureFormat;
|
|
444
444
|
inkColor?: string;
|
|
445
|
+
imageInk?: import("../SignatureInput/signatureInput.props.ts").SignatureImageInk;
|
|
445
446
|
strokeWidth?: number;
|
|
446
447
|
placeholder?: string;
|
|
447
448
|
clearLabel?: string;
|
|
@@ -1327,6 +1328,7 @@ export declare class MultiStepFormState<I extends MultiStepFormItems = FormStep[
|
|
|
1327
1328
|
} & Omit<import("../Field/field.ts").InputProps<"signature">, "theme"> & {
|
|
1328
1329
|
format?: import("../SignatureInput/signatureInput.strokes.ts").SignatureFormat;
|
|
1329
1330
|
inkColor?: string;
|
|
1331
|
+
imageInk?: import("../SignatureInput/signatureInput.props.ts").SignatureImageInk;
|
|
1330
1332
|
strokeWidth?: number;
|
|
1331
1333
|
placeholder?: string;
|
|
1332
1334
|
clearLabel?: string;
|
|
@@ -2408,6 +2410,7 @@ export declare class MultiStepFormState<I extends MultiStepFormItems = FormStep[
|
|
|
2408
2410
|
} & Omit<import("../Field/field.ts").InputProps<"signature">, "theme"> & {
|
|
2409
2411
|
format?: import("../SignatureInput/signatureInput.strokes.ts").SignatureFormat;
|
|
2410
2412
|
inkColor?: string;
|
|
2413
|
+
imageInk?: import("../SignatureInput/signatureInput.props.ts").SignatureImageInk;
|
|
2411
2414
|
strokeWidth?: number;
|
|
2412
2415
|
placeholder?: string;
|
|
2413
2416
|
clearLabel?: string;
|
|
@@ -3293,6 +3296,7 @@ export declare class MultiStepFormState<I extends MultiStepFormItems = FormStep[
|
|
|
3293
3296
|
} & Omit<import("../Field/field.ts").InputProps<"signature">, "theme"> & {
|
|
3294
3297
|
format?: import("../SignatureInput/signatureInput.strokes.ts").SignatureFormat;
|
|
3295
3298
|
inkColor?: string;
|
|
3299
|
+
imageInk?: import("../SignatureInput/signatureInput.props.ts").SignatureImageInk;
|
|
3296
3300
|
strokeWidth?: number;
|
|
3297
3301
|
placeholder?: string;
|
|
3298
3302
|
clearLabel?: string;
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
size = 'normal',
|
|
34
34
|
format = 'png',
|
|
35
35
|
inkColor = '#000000',
|
|
36
|
+
imageInk = 'theme',
|
|
36
37
|
strokeWidth = 2.5,
|
|
37
38
|
placeholder,
|
|
38
39
|
clearLabel,
|
|
@@ -125,6 +126,27 @@
|
|
|
125
126
|
|
|
126
127
|
const hasInk = $derived(strokes.length > 0 || current !== null);
|
|
127
128
|
const image = $derived(hasInk ? null : (field.value ?? null));
|
|
129
|
+
|
|
130
|
+
// A mask image is fetched in CORS mode: a URL from another origin that does not allow it would
|
|
131
|
+
// paint nothing. Such a URL is probed once and, when refused, shown as the image itself.
|
|
132
|
+
let refusedMask = $state<string | null>(null);
|
|
133
|
+
const ownsImage = (url: string) =>
|
|
134
|
+
/^(data|blob):/.test(url) || new URL(url, location.href).origin === location.origin;
|
|
135
|
+
$effect(() => {
|
|
136
|
+
if (imageInk !== 'theme' || !image || ownsImage(image)) return;
|
|
137
|
+
const probe = new Image();
|
|
138
|
+
probe.crossOrigin = 'anonymous';
|
|
139
|
+
probe.onerror = () => (refusedMask = image);
|
|
140
|
+
probe.src = image;
|
|
141
|
+
return () => {
|
|
142
|
+
probe.onerror = null;
|
|
143
|
+
};
|
|
144
|
+
});
|
|
145
|
+
const imageMode = $derived(imageInk === 'theme' && refusedMask !== image ? 'theme' : 'as-is');
|
|
146
|
+
// Quoted for `url()`: a data URL may hold characters CSS would end the string on.
|
|
147
|
+
const maskImage = $derived(
|
|
148
|
+
image ? `url("${image.replace(/["\\\n]/g, (char) => encodeURIComponent(char))}")` : undefined
|
|
149
|
+
);
|
|
128
150
|
const shapes = $derived(
|
|
129
151
|
[...strokes, ...(current ? [current] : [])].flatMap((stroke) =>
|
|
130
152
|
strokeShapes(stroke, strokeWidth)
|
|
@@ -277,7 +299,23 @@
|
|
|
277
299
|
</div>
|
|
278
300
|
{/if}
|
|
279
301
|
{#if image}
|
|
280
|
-
|
|
302
|
+
{#if imageMode === 'theme'}
|
|
303
|
+
<span
|
|
304
|
+
data-slot="signature-image"
|
|
305
|
+
data-ink="theme"
|
|
306
|
+
class={classes.image({ ink: 'theme' })}
|
|
307
|
+
style:mask-image={maskImage}
|
|
308
|
+
style:-webkit-mask-image={maskImage}
|
|
309
|
+
></span>
|
|
310
|
+
{:else}
|
|
311
|
+
<img
|
|
312
|
+
data-slot="signature-image"
|
|
313
|
+
data-ink="as-is"
|
|
314
|
+
src={image}
|
|
315
|
+
alt=""
|
|
316
|
+
class={classes.image({ ink: 'as-is' })}
|
|
317
|
+
/>
|
|
318
|
+
{/if}
|
|
281
319
|
{/if}
|
|
282
320
|
<svg data-slot="signature-ink" class={classes.ink()} aria-hidden="true" focusable="false">
|
|
283
321
|
<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round">
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { default as SignatureInput } from './SignatureInput.svelte';
|
|
2
|
-
export type { SignatureInputProps } from './signatureInput.props.js';
|
|
2
|
+
export type { SignatureImageInk, SignatureInputProps } from './signatureInput.props.js';
|
|
3
3
|
export type { SignatureFormat, SignaturePoint, SignatureStroke } from './signatureInput.strokes.js';
|
|
4
4
|
export { signatureInputTheme, setSignatureInputTheme, useSignatureInputTheme, type SignatureInputTheme, type SignatureInputThemeProps } from './signatureInput.theme.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const signatureInputDescription = "\n# SignatureInput Component\n\nSignatureInput is a form field where a person signs with a mouse, a finger or a pen. Its value is the signature as an image: a data URL cropped to the ink (PNG by default, or SVG), ready to store, submit or place in a document.\n\n## Basic usage\n\n```svelte\n<script lang=\"ts\">\n import { SignatureInput } from './index.ts';\n\n let signature = $state<string | null>(null);\n</script>\n\n<SignatureInput label=\"Signature\" required bind:value={signature} />\n```\n\nIn a Form or `ask()`, use `type: 'signature'`:\n\n```ts\nimport { ask } from 'entasis/ask';\n\nconst result = await ask({\n title: 'Sign the mandate',\n inputs: { signature: { type: 'signature', label: 'Signature', required: true } },\n confirm: 'Sign',\n cancel: 'Cancel'\n});\n```\n\n## Props\n\nExtends the shared Field props (`label`, `description`, `helper`, `required`, `disabled`, `readOnly`, `name`, `size`, `density`, `labelPosition`, `messages`, `onValidate`, `errors`, `focused`, `visible`) plus:\n\n- **value**: `string | null` (bindable) \u2014 the signature as a data URL, or `null` while the pad is empty.\n- **defaultValue**: `string | null` \u2014 initial value when `value` is omitted. Any image data URL works: a saved signature shows in the pad, scaled to fit.\n- **onValueChange**: `(value: string | null) => void` \u2014 called once per finished stroke, undo and clear.\n- **format**: `'png' | 'svg'` (default `'png'`) \u2014 the image the value holds. A PNG is drawn at twice the pad's resolution; an SVG keeps every stroke as a vector path.\n- **inkColor**: `string` (default `'#000000'`) \u2014 CSS color of the ink in the exported image, so a signature reads on a white document whatever the app's theme. The pad itself draws in the theme's text color.\n- **strokeWidth**: `number` (default `2.5`) \u2014 line width in CSS pixels at a medium pen pressure. A pen's pressure makes the line thinner or thicker (half to one and a half times); a mouse or a finger draws at this width.\n- **placeholder**: `string` \u2014 hint on the signing line while the pad is empty. Defaults to the i18n `signatureInputPlaceholder` (\"Sign here\").\n- **clearLabel**, **undoLabel**: `string` \u2014 accessible labels and tooltips of the two buttons.\n- **i18n**: `Partial<Messages>` \u2014 per-instance translations.\n- **size**: `'small' | 'normal' | 'large'` \u2014 pad height (112, 144 or 176 px) and placeholder text size. Override the height with the `pad` theme part.\n- **theme**: `SignatureInputThemeProps` and Field theme parts.\n\n## Behaviour\n\n- Each stroke runs from pointer down to pointer up and is smoothed through its samples. The value updates when a stroke ends, not while it is drawn.\n- The undo button (or Ctrl/Cmd+Z on the pad) removes the last stroke; the clear button (or Delete/Backspace on the pad) empties the pad and sets the value to `null`. Both show only while the pad is editable and has a signature.\n- A value set from outside (a saved signature, a Form reset) replaces the strokes and shows as an image. Drawing over it starts a new signature: the image is replaced, not added to. Undo only steps back through strokes drawn since.\n- `disabled` and `readOnly` stop drawing and hide the buttons; a read-only pad still shows, focuses, validates and submits its value. A stroke in progress is dropped when the pad becomes disabled or read-only.\n- Required: an empty pad (`null` or `''`) fails `required`.\n- Native forms: a hidden input (`FieldHiddenInputs`) submits the data URL under `name`.\n\n## Accessibility\n\n- The pad is the field's control: it is focusable, labelled by the field label (or \"Signature\" without one), and has `role=\"img\"` with a description of its state (\"No signature yet\u2026\" or \"Signed.\"). Errors and descriptions are linked by Field.\n- Drawing is a path-based gesture with no keyboard equivalent: signing by hand is the purpose of the field. Keyboard users can clear and undo with the buttons and keys above. When a keyboard-only path to consent is needed, pair the pad with another field (a typed full name, a consent checkbox).\n- The ink, placeholder and image are decorative (`aria-hidden`, empty `alt`).\n\n## Styling hooks\n\n- `data-slot`: `signature-frame`, `signature-pad`, `signature-ink`, `signature-image`, `signature-placeholder`, `signature-actions`.\n- On the pad: `data-filled=\"true\"` while it holds a signature, `data-drawing=\"true\"` during a stroke.\n\n## Theme parts\n\n`frame` (the pad and its buttons), `pad` (variants `size`, `interactive`, `disabled`, `hasError`), `ink` (the SVG of strokes), `image` (a value set from outside), `placeholder` (the signing line and hint), `actions` (the undo and clear buttons).\n\n## Exports\n\n`SignatureInput`, `SignatureInputProps`, `SignatureFormat`, `SignaturePoint`, `SignatureStroke`, `signatureInputTheme`, `setSignatureInputTheme`, `useSignatureInputTheme`, `SignatureInputTheme`, `SignatureInputThemeProps`.\n";
|
|
1
|
+
export declare const signatureInputDescription = "\n# SignatureInput Component\n\nSignatureInput is a form field where a person signs with a mouse, a finger or a pen. Its value is the signature as an image: a data URL cropped to the ink (PNG by default, or SVG), ready to store, submit or place in a document.\n\n## Basic usage\n\n```svelte\n<script lang=\"ts\">\n import { SignatureInput } from './index.ts';\n\n let signature = $state<string | null>(null);\n</script>\n\n<SignatureInput label=\"Signature\" required bind:value={signature} />\n```\n\nIn a Form or `ask()`, use `type: 'signature'`:\n\n```ts\nimport { ask } from 'entasis/ask';\n\nconst result = await ask({\n title: 'Sign the mandate',\n inputs: { signature: { type: 'signature', label: 'Signature', required: true } },\n confirm: 'Sign',\n cancel: 'Cancel'\n});\n```\n\n## Props\n\nExtends the shared Field props (`label`, `description`, `helper`, `required`, `disabled`, `readOnly`, `name`, `size`, `density`, `labelPosition`, `messages`, `onValidate`, `errors`, `focused`, `visible`) plus:\n\n- **value**: `string | null` (bindable) \u2014 the signature as a data URL, or `null` while the pad is empty.\n- **defaultValue**: `string | null` \u2014 initial value when `value` is omitted. Any image data URL works: a saved signature shows in the pad, scaled to fit.\n- **onValueChange**: `(value: string | null) => void` \u2014 called once per finished stroke, undo and clear.\n- **format**: `'png' | 'svg'` (default `'png'`) \u2014 the image the value holds. A PNG is drawn at twice the pad's resolution; an SVG keeps every stroke as a vector path.\n- **inkColor**: `string` (default `'#000000'`) \u2014 CSS color of the ink in the exported image, so a signature reads on a white document whatever the app's theme. The pad itself draws in the theme's text color.\n- **imageInk**: `'theme' | 'as-is'` (default `'theme'`) \u2014 how a value set from outside (a saved signature) shows in the pad. `'theme'` paints its shape in the pad's ink color, like live strokes (the image becomes a CSS mask over `bg-current`; only its transparency counts), so a black signature saved for paper reads on a dark theme without the app knowing which mode is on. `'as-is'` shows the image unchanged: for a signature with several colors or an opaque background. The value is never changed. A URL from another origin is fetched in CORS mode for the mask; when that origin refuses CORS, the pad falls back to the image as it is.\n- **strokeWidth**: `number` (default `2.5`) \u2014 line width in CSS pixels at a medium pen pressure. A pen's pressure makes the line thinner or thicker (half to one and a half times); a mouse or a finger draws at this width.\n- **placeholder**: `string` \u2014 hint on the signing line while the pad is empty. Defaults to the i18n `signatureInputPlaceholder` (\"Sign here\").\n- **clearLabel**, **undoLabel**: `string` \u2014 accessible labels and tooltips of the two buttons.\n- **i18n**: `Partial<Messages>` \u2014 per-instance translations.\n- **size**: `'small' | 'normal' | 'large'` \u2014 pad height (112, 144 or 176 px) and placeholder text size. Override the height with the `pad` theme part.\n- **theme**: `SignatureInputThemeProps` and Field theme parts.\n\n## Behaviour\n\n- Each stroke runs from pointer down to pointer up and is smoothed through its samples. The value updates when a stroke ends, not while it is drawn.\n- The undo button (or Ctrl/Cmd+Z on the pad) removes the last stroke; the clear button (or Delete/Backspace on the pad) empties the pad and sets the value to `null`. Both show only while the pad is editable and has a signature.\n- A value set from outside (a saved signature, a Form reset) replaces the strokes and shows as an image. Drawing over it starts a new signature: the image is replaced, not added to. Undo only steps back through strokes drawn since.\n- `disabled` and `readOnly` stop drawing and hide the buttons; a read-only pad still shows, focuses, validates and submits its value. A stroke in progress is dropped when the pad becomes disabled or read-only.\n- Required: an empty pad (`null` or `''`) fails `required`.\n- Native forms: a hidden input (`FieldHiddenInputs`) submits the data URL under `name`.\n\n## Accessibility\n\n- The pad is the field's control: it is focusable, labelled by the field label (or \"Signature\" without one), and has `role=\"img\"` with a description of its state (\"No signature yet\u2026\" or \"Signed.\"). Errors and descriptions are linked by Field.\n- Drawing is a path-based gesture with no keyboard equivalent: signing by hand is the purpose of the field. Keyboard users can clear and undo with the buttons and keys above. When a keyboard-only path to consent is needed, pair the pad with another field (a typed full name, a consent checkbox).\n- The ink, placeholder and image are decorative (`aria-hidden`, empty `alt`).\n\n## Styling hooks\n\n- `data-slot`: `signature-frame`, `signature-pad`, `signature-ink`, `signature-image`, `signature-placeholder`, `signature-actions`.\n- On the pad: `data-filled=\"true\"` while it holds a signature, `data-drawing=\"true\"` during a stroke.\n\n## Theme parts\n\n`frame` (the pad and its buttons), `pad` (variants `size`, `interactive`, `disabled`, `hasError`), `ink` (the SVG of strokes), `image` (a value set from outside), `placeholder` (the signing line and hint), `actions` (the undo and clear buttons).\n\n## Exports\n\n`SignatureInput`, `SignatureInputProps`, `SignatureFormat`, `SignaturePoint`, `SignatureStroke`, `signatureInputTheme`, `setSignatureInputTheme`, `useSignatureInputTheme`, `SignatureInputTheme`, `SignatureInputThemeProps`.\n";
|
|
@@ -37,6 +37,7 @@ Extends the shared Field props (\`label\`, \`description\`, \`helper\`, \`requir
|
|
|
37
37
|
- **onValueChange**: \`(value: string | null) => void\` — called once per finished stroke, undo and clear.
|
|
38
38
|
- **format**: \`'png' | 'svg'\` (default \`'png'\`) — the image the value holds. A PNG is drawn at twice the pad's resolution; an SVG keeps every stroke as a vector path.
|
|
39
39
|
- **inkColor**: \`string\` (default \`'#000000'\`) — CSS color of the ink in the exported image, so a signature reads on a white document whatever the app's theme. The pad itself draws in the theme's text color.
|
|
40
|
+
- **imageInk**: \`'theme' | 'as-is'\` (default \`'theme'\`) — how a value set from outside (a saved signature) shows in the pad. \`'theme'\` paints its shape in the pad's ink color, like live strokes (the image becomes a CSS mask over \`bg-current\`; only its transparency counts), so a black signature saved for paper reads on a dark theme without the app knowing which mode is on. \`'as-is'\` shows the image unchanged: for a signature with several colors or an opaque background. The value is never changed. A URL from another origin is fetched in CORS mode for the mask; when that origin refuses CORS, the pad falls back to the image as it is.
|
|
40
41
|
- **strokeWidth**: \`number\` (default \`2.5\`) — line width in CSS pixels at a medium pen pressure. A pen's pressure makes the line thinner or thicker (half to one and a half times); a mouse or a finger draws at this width.
|
|
41
42
|
- **placeholder**: \`string\` — hint on the signing line while the pad is empty. Defaults to the i18n \`signatureInputPlaceholder\` ("Sign here").
|
|
42
43
|
- **clearLabel**, **undoLabel**: \`string\` — accessible labels and tooltips of the two buttons.
|
|
@@ -3,6 +3,7 @@ import type { WithAttachments } from '../../../types/props.js';
|
|
|
3
3
|
import type { InputProps } from '../Field/field.js';
|
|
4
4
|
import type { SignatureFormat } from './signatureInput.strokes.js';
|
|
5
5
|
import type { SignatureInputThemeProps } from './signatureInput.theme.js';
|
|
6
|
+
export type SignatureImageInk = 'theme' | 'as-is';
|
|
6
7
|
export type SignatureInputProps = WithAttachments<Omit<InputProps<'signature'>, 'theme'> & {
|
|
7
8
|
/**
|
|
8
9
|
* Image the value holds, as a data URL cropped to the ink: `'png'` (default, drawn at twice
|
|
@@ -14,6 +15,14 @@ export type SignatureInputProps = WithAttachments<Omit<InputProps<'signature'>,
|
|
|
14
15
|
* white document whatever the app's theme; the pad itself draws in the theme's text color.
|
|
15
16
|
*/
|
|
16
17
|
inkColor?: string;
|
|
18
|
+
/**
|
|
19
|
+
* How a value set from outside (a saved signature) shows in the pad. `'theme'` (default)
|
|
20
|
+
* paints its shape in the pad's ink color, as live strokes are, so a black signature saved
|
|
21
|
+
* for paper still reads on a dark theme; only its transparency counts. `'as-is'` shows the
|
|
22
|
+
* image unchanged: for a signature with several colors or an opaque background. The value
|
|
23
|
+
* itself is never changed.
|
|
24
|
+
*/
|
|
25
|
+
imageInk?: SignatureImageInk;
|
|
17
26
|
/** Line width in CSS pixels at a medium pen pressure. Defaults to 2.5. */
|
|
18
27
|
strokeWidth?: number;
|
|
19
28
|
/** Hint on the signing line while the pad is empty. Defaults to the i18n `signatureInputPlaceholder`. */
|
|
@@ -21,7 +21,12 @@ export declare const signatureInputTheme: {
|
|
|
21
21
|
};
|
|
22
22
|
}> & import("../../../utils/cva/types.ts").CVAClassProp) | undefined) => string;
|
|
23
23
|
ink: (props?: import("../../../utils/cva/types.ts").CVAClassProp | undefined) => string;
|
|
24
|
-
image: (props?: import("../../../utils/cva/types.ts").
|
|
24
|
+
image: (props?: (import("../../../utils/cva/types.ts").CVAVariantSchema<{
|
|
25
|
+
ink: {
|
|
26
|
+
theme: string;
|
|
27
|
+
'as-is': string;
|
|
28
|
+
};
|
|
29
|
+
}> & import("../../../utils/cva/types.ts").CVAClassProp) | undefined) => string;
|
|
25
30
|
placeholder: (props?: (import("../../../utils/cva/types.ts").CVAVariantSchema<{
|
|
26
31
|
size: {
|
|
27
32
|
small: string;
|
|
@@ -55,7 +60,12 @@ export declare const setSignatureInputTheme: (theme: InferComponentTheme<{
|
|
|
55
60
|
};
|
|
56
61
|
}> & import("../../../utils/cva/types.ts").CVAClassProp) | undefined) => string;
|
|
57
62
|
ink: (props?: import("../../../utils/cva/types.ts").CVAClassProp | undefined) => string;
|
|
58
|
-
image: (props?: import("../../../utils/cva/types.ts").
|
|
63
|
+
image: (props?: (import("../../../utils/cva/types.ts").CVAVariantSchema<{
|
|
64
|
+
ink: {
|
|
65
|
+
theme: string;
|
|
66
|
+
'as-is': string;
|
|
67
|
+
};
|
|
68
|
+
}> & import("../../../utils/cva/types.ts").CVAClassProp) | undefined) => string;
|
|
59
69
|
placeholder: (props?: (import("../../../utils/cva/types.ts").CVAVariantSchema<{
|
|
60
70
|
size: {
|
|
61
71
|
small: string;
|
|
@@ -87,7 +97,12 @@ export declare const useSignatureInputTheme: import("../../../utils/cva/theme.ts
|
|
|
87
97
|
};
|
|
88
98
|
}> & import("../../../utils/cva/types.ts").CVAClassProp) | undefined) => string;
|
|
89
99
|
ink: (props?: import("../../../utils/cva/types.ts").CVAClassProp | undefined) => string;
|
|
90
|
-
image: (props?: import("../../../utils/cva/types.ts").
|
|
100
|
+
image: (props?: (import("../../../utils/cva/types.ts").CVAVariantSchema<{
|
|
101
|
+
ink: {
|
|
102
|
+
theme: string;
|
|
103
|
+
'as-is': string;
|
|
104
|
+
};
|
|
105
|
+
}> & import("../../../utils/cva/types.ts").CVAClassProp) | undefined) => string;
|
|
91
106
|
placeholder: (props?: (import("../../../utils/cva/types.ts").CVAVariantSchema<{
|
|
92
107
|
size: {
|
|
93
108
|
small: string;
|
|
@@ -37,9 +37,20 @@ const defaultPad = cva({
|
|
|
37
37
|
const defaultInk = cva({
|
|
38
38
|
base: 'pointer-events-none absolute inset-0 size-full overflow-visible'
|
|
39
39
|
});
|
|
40
|
-
// A value set from outside (a saved signature) shows
|
|
40
|
+
// A value set from outside (a saved signature) shows scaled to fit the pad. With `imageInk`
|
|
41
|
+
// 'theme' it is a mask over the pad's ink color (`bg-current`), so a black signature saved for
|
|
42
|
+
// paper reads on a dark surface; 'as-is' is the image itself.
|
|
41
43
|
const defaultImage = cva({
|
|
42
|
-
base: 'pointer-events-none absolute inset-0 size-full
|
|
44
|
+
base: 'pointer-events-none absolute inset-0 size-full p-md',
|
|
45
|
+
variants: {
|
|
46
|
+
ink: {
|
|
47
|
+
theme: 'bg-current [mask-clip:content-box] [mask-origin:content-box] [mask-position:center] [mask-repeat:no-repeat] [mask-size:contain]',
|
|
48
|
+
'as-is': 'object-contain'
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
defaultVariants: {
|
|
52
|
+
ink: 'theme'
|
|
53
|
+
}
|
|
43
54
|
});
|
|
44
55
|
// The line to sign on and its hint: decorative, gone as soon as there is ink.
|
|
45
56
|
const defaultPlaceholder = cva({
|
|
@@ -799,7 +799,7 @@ export declare const componentInventory: readonly [{
|
|
|
799
799
|
readonly id: "signature-input";
|
|
800
800
|
readonly subpath: "entasis/signature-input";
|
|
801
801
|
readonly sourceIndex: "src/lib/components/Form/SignatureInput/index.ts";
|
|
802
|
-
readonly exportedSymbols: readonly ["SignatureFormat", "SignatureInput", "SignatureInputProps", "SignatureInputTheme", "SignatureInputThemeProps", "SignaturePoint", "SignatureStroke", "setSignatureInputTheme", "signatureInputTheme", "useSignatureInputTheme"];
|
|
802
|
+
readonly exportedSymbols: readonly ["SignatureFormat", "SignatureImageInk", "SignatureInput", "SignatureInputProps", "SignatureInputTheme", "SignatureInputThemeProps", "SignaturePoint", "SignatureStroke", "setSignatureInputTheme", "signatureInputTheme", "useSignatureInputTheme"];
|
|
803
803
|
readonly docs: readonly [{
|
|
804
804
|
readonly id: "signature-input";
|
|
805
805
|
readonly route: "/components/signature-input";
|
|
@@ -1936,6 +1936,7 @@ export const componentInventory = [
|
|
|
1936
1936
|
sourceIndex: 'src/lib/components/Form/SignatureInput/index.ts',
|
|
1937
1937
|
exportedSymbols: [
|
|
1938
1938
|
'SignatureFormat',
|
|
1939
|
+
'SignatureImageInk',
|
|
1939
1940
|
'SignatureInput',
|
|
1940
1941
|
'SignatureInputProps',
|
|
1941
1942
|
'SignatureInputTheme',
|