@theseam/ui-common 1.0.2-beta.57 → 1.0.2-beta.59

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.
@@ -0,0 +1,241 @@
1
+ import * as _almothafar_angular_signature_pad from '@almothafar/angular-signature-pad';
2
+ import { NgSignaturePadOptions } from '@almothafar/angular-signature-pad';
3
+ import * as _angular_core from '@angular/core';
4
+ import { InjectionToken, AfterViewInit } from '@angular/core';
5
+ import * as _fortawesome_fontawesome_common_types from '@fortawesome/fontawesome-common-types';
6
+ import { FormGroup, FormControl, ControlValueAccessor } from '@angular/forms';
7
+ import { NgxFileDropEntry } from 'ngx-file-drop';
8
+ import * as _angular_cdk_testing from '@angular/cdk/testing';
9
+ import { ComponentHarness, TestElement } from '@angular/cdk/testing';
10
+
11
+ /**
12
+ * Options for `szimek/signature_pad` exposed by
13
+ * `@almothafar/angular-signature-pad`. Re-exported here so consumers don't
14
+ * have to reach into the third-party module directly.
15
+ */
16
+ type SignaturePadOptions = NgSignaturePadOptions;
17
+ type SignatureInputOptions = NgSignaturePadOptions;
18
+ interface SignatureInputItem {
19
+ clear(): void;
20
+ }
21
+ interface SignatureInputContainer {
22
+ registerInputItem(type: string, item: SignatureInputItem): boolean;
23
+ unregisterInputItem(type: string, item: SignatureInputItem): boolean;
24
+ }
25
+ type SignatureInputType = 'pen' | 'text' | 'img';
26
+ type SignatureInputResetType = 'delete' | 'cancel';
27
+ type SignatureInputPanelResult = {
28
+ type: 'submit';
29
+ value: string;
30
+ } | {
31
+ type: 'cancel';
32
+ };
33
+
34
+ declare const THESEAM_SIGNATURE_INPUT_CONTAINER: InjectionToken<SignatureInputContainer>;
35
+
36
+ interface SignatureInputPanelForm {
37
+ pen: FormControl<string | null>;
38
+ text: FormControl<string | null>;
39
+ img: FormControl<string | null>;
40
+ }
41
+ declare class TheSeamSignatureInputPanelComponent implements SignatureInputContainer {
42
+ private readonly _layout;
43
+ private readonly _modalRef;
44
+ /** Emitted when the panel is submitted or canceled. */
45
+ readonly result: _angular_core.OutputEmitterRef<SignatureInputPanelResult>;
46
+ protected readonly _faSignature: _fortawesome_fontawesome_common_types.IconDefinition;
47
+ protected readonly _faUpload: _fortawesome_fontawesome_common_types.IconDefinition;
48
+ protected readonly _faKeyboard: _fortawesome_fontawesome_common_types.IconDefinition;
49
+ protected readonly _activeType: _angular_core.WritableSignal<SignatureInputType>;
50
+ protected readonly _resetType: _angular_core.Signal<SignatureInputResetType>;
51
+ readonly _form: FormGroup<SignatureInputPanelForm>;
52
+ private readonly _registeredInputItems;
53
+ private readonly _activeControl$;
54
+ private readonly _activeValue$;
55
+ private readonly _canSubmit$;
56
+ protected readonly _value: _angular_core.Signal<string | null>;
57
+ protected readonly _valueEmpty: _angular_core.Signal<boolean>;
58
+ protected readonly _canSubmit: _angular_core.Signal<boolean>;
59
+ protected readonly _isSm: _angular_core.Signal<boolean>;
60
+ showType(type: SignatureInputType): void;
61
+ registerInputItem(type: string, item: SignatureInputItem): boolean;
62
+ unregisterInputItem(type: string, item: SignatureInputItem): boolean;
63
+ reset(): void;
64
+ protected _onClearBtnClick(event: Event): void;
65
+ protected _onCancelBtnClick(event: Event): void;
66
+ protected _onSubmitBtnClick(event: Event): void;
67
+ private _emit;
68
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<TheSeamSignatureInputPanelComponent, never>;
69
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<TheSeamSignatureInputPanelComponent, "seam-signature-input-panel", never, {}, { "result": "result"; }, never, never, true, never>;
70
+ }
71
+
72
+ declare class TheSeamSignatureInputPenComponent implements ControlValueAccessor, SignatureInputItem {
73
+ private readonly _container;
74
+ private readonly _destroyRef;
75
+ readonly options: _angular_core.InputSignalWithTransform<_almothafar_angular_signature_pad.NgSignaturePadOptions, _almothafar_angular_signature_pad.NgSignaturePadOptions>;
76
+ readonly beginDrawing: _angular_core.OutputEmitterRef<MouseEvent | Touch>;
77
+ readonly endDrawing: _angular_core.OutputEmitterRef<MouseEvent | Touch>;
78
+ private readonly _signaturePad;
79
+ private readonly _value;
80
+ private readonly _disabled;
81
+ protected readonly _canvasWidth: _angular_core.Signal<number | undefined>;
82
+ protected readonly _canvasHeight: _angular_core.Signal<number | undefined>;
83
+ private _onChange;
84
+ private _onTouched;
85
+ constructor();
86
+ writeValue(value: string | null): void;
87
+ registerOnChange(fn: (value: string | null) => void): void;
88
+ registerOnTouched(fn: () => void): void;
89
+ setDisabledState(isDisabled: boolean): void;
90
+ clear(): void;
91
+ protected _drawStart(event: MouseEvent | Touch): void;
92
+ protected _drawComplete(event: MouseEvent | Touch): void;
93
+ private _getDataURL;
94
+ private _applyValueToPad;
95
+ private _setValue;
96
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<TheSeamSignatureInputPenComponent, never>;
97
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<TheSeamSignatureInputPenComponent, "seam-signature-input-pen", never, { "options": { "alias": "options"; "required": false; "isSignal": true; }; }, { "beginDrawing": "beginDrawing"; "endDrawing": "endDrawing"; }, never, never, true, never>;
98
+ }
99
+
100
+ type SignatureFontState = 'loading' | 'inactive' | 'active';
101
+ declare class TheSeamSignatureInputTextComponent implements ControlValueAccessor, SignatureInputItem, AfterViewInit {
102
+ private readonly _fontLoader;
103
+ private readonly _container;
104
+ private readonly _destroyRef;
105
+ private readonly _typeCanvas;
106
+ readonly _nameControl: FormControl<string | null>;
107
+ private readonly _fontState;
108
+ protected readonly _fontLoading: _angular_core.Signal<boolean>;
109
+ protected readonly _fontInactive: _angular_core.Signal<boolean>;
110
+ protected readonly _fontNotActive: _angular_core.Signal<boolean>;
111
+ private readonly _disabled;
112
+ protected readonly _disabledOrFontNotActive: _angular_core.Signal<boolean>;
113
+ protected readonly _canvasWidth = 500;
114
+ protected readonly _canvasHeight = 127;
115
+ /** Current form value (rendered bitmap data URL). */
116
+ private _value;
117
+ /**
118
+ * When the user last typed a name (if any) on this instance. `null` means
119
+ * there is no user-typed signature on this instance — the canvas should
120
+ * keep whatever image was restored from `_value`.
121
+ */
122
+ private _renderedText;
123
+ private _onChange;
124
+ private _onTouched;
125
+ constructor();
126
+ ngAfterViewInit(): void;
127
+ writeValue(value: string | null): void;
128
+ registerOnChange(fn: (value: string | null) => void): void;
129
+ registerOnTouched(fn: () => void): void;
130
+ setDisabledState(isDisabled: boolean): void;
131
+ clear(): void;
132
+ protected _onKeyDownEnter(): void;
133
+ protected _onNameInputBlur(): void;
134
+ /**
135
+ * Paint the given data URL onto the canvas as an image. Used when the
136
+ * component mounts with a pre-existing form value — the user's typed name
137
+ * isn't recoverable from the rendered bitmap, only the bitmap itself.
138
+ */
139
+ private _drawImageToCanvas;
140
+ /**
141
+ * Render `_nameControl.value` as text onto the canvas and publish the
142
+ * result as the form value. A null/empty name clears both.
143
+ */
144
+ private _drawTextToCanvas;
145
+ private _clearCanvas;
146
+ private _setValue;
147
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<TheSeamSignatureInputTextComponent, never>;
148
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<TheSeamSignatureInputTextComponent, "seam-signature-input-text", never, {}, {}, never, never, true, never>;
149
+ }
150
+
151
+ declare class TheSeamSignatureInputImgComponent implements ControlValueAccessor, SignatureInputItem {
152
+ static readonly MAX_FILE_SIZE: number;
153
+ private readonly _container;
154
+ private readonly _destroyRef;
155
+ /**
156
+ * The File is only needed for validation at selection time. Once it's been
157
+ * converted to a data URL and stored in the form value, we don't need the
158
+ * File again — so there's no point trying to round-trip it through
159
+ * writeValue / form state. The preview renders off the current form value.
160
+ */
161
+ protected readonly _fileControl: FormControl<File | null>;
162
+ private readonly _fileStatus;
163
+ protected readonly _sizeError: _angular_core.Signal<string | null>;
164
+ /**
165
+ * Single source of truth for both the form value and the preview image.
166
+ * External writes (writeValue) and successful uploads both funnel through
167
+ * here, so switching tabs and coming back always shows the last committed
168
+ * signature.
169
+ */
170
+ private readonly _value;
171
+ protected readonly _previewDataUrl: _angular_core.Signal<string | null>;
172
+ protected readonly _previewBackgroundImage: _angular_core.Signal<string | null>;
173
+ private _onChange;
174
+ private _onTouched;
175
+ constructor();
176
+ writeValue(value: string | null): void;
177
+ registerOnChange(fn: (value: string | null) => void): void;
178
+ registerOnTouched(fn: () => void): void;
179
+ setDisabledState(isDisabled: boolean): void;
180
+ clear(): void;
181
+ openFileBrowse(): void;
182
+ protected _onFileDropped(files: NgxFileDropEntry[]): void;
183
+ private _setValue;
184
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<TheSeamSignatureInputImgComponent, never>;
185
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<TheSeamSignatureInputImgComponent, "seam-signature-input-img", never, {}, {}, never, never, true, never>;
186
+ }
187
+
188
+ declare class TheSeamSignatureInputImgHarness extends ComponentHarness {
189
+ static hostSelector: string;
190
+ private readonly _fileDrop;
191
+ private readonly _sizeError;
192
+ private readonly _preview;
193
+ getSizeError(): Promise<string | null>;
194
+ hasPreview(): Promise<boolean>;
195
+ getPreviewSrc(): Promise<string | null>;
196
+ getFileDrop(): Promise<_angular_cdk_testing.TestElement>;
197
+ }
198
+
199
+ declare class TheSeamSignatureInputPenHarness extends ComponentHarness {
200
+ static hostSelector: string;
201
+ private readonly _canvas;
202
+ getCanvas(): Promise<_angular_cdk_testing.TestElement>;
203
+ getCanvasWidth(): Promise<number | null>;
204
+ getCanvasHeight(): Promise<number | null>;
205
+ }
206
+
207
+ declare class TheSeamSignatureInputTextHarness extends ComponentHarness {
208
+ static hostSelector: string;
209
+ private readonly _input;
210
+ private readonly _canvas;
211
+ getInput(): Promise<_angular_cdk_testing.TestElement>;
212
+ enterName(text: string): Promise<void>;
213
+ getInputValue(): Promise<string>;
214
+ isInputDisabled(): Promise<boolean>;
215
+ getCanvas(): Promise<_angular_cdk_testing.TestElement>;
216
+ }
217
+
218
+ declare class TheSeamSignatureInputPanelHarness extends ComponentHarness {
219
+ static hostSelector: string;
220
+ private readonly _drawBtn;
221
+ private readonly _typeBtn;
222
+ private readonly _uploadBtn;
223
+ private readonly _footerBtns;
224
+ private readonly _penHarness;
225
+ private readonly _textHarness;
226
+ private readonly _imgHarness;
227
+ showType(type: SignatureInputType): Promise<void>;
228
+ getActiveType(): Promise<SignatureInputType | null>;
229
+ getPen(): Promise<TheSeamSignatureInputPenHarness | null>;
230
+ getText(): Promise<TheSeamSignatureInputTextHarness | null>;
231
+ getImg(): Promise<TheSeamSignatureInputImgHarness | null>;
232
+ getClearOrDeleteButton(): Promise<TestElement>;
233
+ getCancelButton(): Promise<TestElement>;
234
+ getSubmitButton(): Promise<TestElement>;
235
+ isSubmitDisabled(): Promise<boolean>;
236
+ cancel(): Promise<void>;
237
+ submit(): Promise<void>;
238
+ }
239
+
240
+ export { THESEAM_SIGNATURE_INPUT_CONTAINER, TheSeamSignatureInputImgComponent, TheSeamSignatureInputImgHarness, TheSeamSignatureInputPanelComponent, TheSeamSignatureInputPanelHarness, TheSeamSignatureInputPenComponent, TheSeamSignatureInputPenHarness, TheSeamSignatureInputTextComponent, TheSeamSignatureInputTextHarness };
241
+ export type { SignatureFontState, SignatureInputContainer, SignatureInputItem, SignatureInputOptions, SignatureInputPanelResult, SignatureInputResetType, SignatureInputType, SignaturePadOptions };
@@ -0,0 +1,3 @@
1
+ {
2
+ "module": "../fesm2022/theseam-ui-common-signature-input.mjs"
3
+ }
@@ -1,14 +1,14 @@
1
1
  import { HandlerFunction } from 'storybook/actions';
2
2
  import * as i0 from '@angular/core';
3
- import { ModuleWithProviders, OnDestroy, Injector, InjectionToken, ComponentRef } from '@angular/core';
4
- import { ReplaySubject, Observable } from 'rxjs';
3
+ import { ModuleWithProviders, Injector, TemplateRef, InjectionToken, ComponentRef } from '@angular/core';
4
+ import * as i2 from '@angular/common';
5
+ import * as i3 from '@angular/router';
6
+ import * as i4 from '@theseam/ui-common/scrollbar';
5
7
  import { ModalConfig } from '@theseam/ui-common/modal';
6
8
  import { ComponentType } from '@theseam/ui-common/models';
7
- import * as i3 from '@angular/common';
8
- import * as i4 from '@angular/router';
9
- import * as i5 from '@theseam/ui-common/scrollbar';
9
+ import { Decorator, AngularRenderer } from '@storybook/angular';
10
+ import { Observable } from 'rxjs';
10
11
  import { TheSeamPreferencesAccessor } from '@theseam/ui-common/services';
11
- import { AngularRenderer } from '@storybook/angular';
12
12
  import { DecoratorFunction } from 'storybook/internal/csf';
13
13
 
14
14
  declare type ArgType = any;
@@ -73,28 +73,39 @@ declare class StoryEmptyWithRouteComponent {
73
73
  static ɵcmp: i0.ɵɵComponentDeclaration<StoryEmptyWithRouteComponent, "ng-component", never, {}, {}, never, never, false, never>;
74
74
  }
75
75
 
76
- declare class StoryModalContainerComponent<T, D = any> implements OnDestroy {
77
- private _injector;
78
- private readonly _ngUnsubscribe;
79
- set component(c: ComponentType<T>);
80
- set data(d: D);
81
- modalConfig?: ModalConfig<D>;
82
- _component: ReplaySubject<ComponentType<T>>;
83
- _data: ReplaySubject<D>;
84
- _outletData$: Observable<{
85
- component: ComponentType<T>;
86
- injector: Injector;
87
- } | null>;
76
+ /**
77
+ * Renders its content (or an imperatively provided component/template) inside
78
+ * a stand-in modal frame so stories can preview components that are normally
79
+ * opened through the modal service.
80
+ *
81
+ * Three ways to provide content, checked in order:
82
+ * 1. `[component]` input — renders via `ngComponentOutlet`. Kept for
83
+ * compatibility with existing app stories.
84
+ * 2. `[template]` input — renders a `TemplateRef` via `ngTemplateOutlet`.
85
+ * 3. Projected content (`<ng-content>`) — the preferred form for new stories
86
+ * because Storybook's default template auto-binds inputs/outputs.
87
+ */
88
+ declare class StoryModalContainerComponent<T = unknown, D = any> {
89
+ private readonly _injector;
88
90
  constructor(_injector: Injector);
89
- ngOnDestroy(): void;
91
+ set component(c: ComponentType<T> | null | undefined);
92
+ set data(d: D | null | undefined);
93
+ set modalConfig(config: ModalConfig<D> | null | undefined);
94
+ get modalConfig(): ModalConfig<D> | null;
95
+ template?: TemplateRef<unknown> | null;
96
+ protected readonly _component: i0.WritableSignal<ComponentType<T> | null>;
97
+ private readonly _data;
98
+ private readonly _modalConfig;
99
+ protected readonly _componentInjector: i0.Signal<Injector>;
100
+ protected readonly _modalSizeClass: i0.Signal<string>;
90
101
  private _createInjector;
91
102
  static ɵfac: i0.ɵɵFactoryDeclaration<StoryModalContainerComponent<any, any>, never>;
92
- static ɵcmp: i0.ɵɵComponentDeclaration<StoryModalContainerComponent<any, any>, "story-modal-container-component", never, { "component": { "alias": "component"; "required": false; }; "data": { "alias": "data"; "required": false; }; "modalConfig": { "alias": "modalConfig"; "required": false; }; }, {}, never, never, false, never>;
103
+ static ɵcmp: i0.ɵɵComponentDeclaration<StoryModalContainerComponent<any, any>, "story-modal-container-component", never, { "component": { "alias": "component"; "required": false; }; "data": { "alias": "data"; "required": false; }; "modalConfig": { "alias": "modalConfig"; "required": false; }; "template": { "alias": "template"; "required": false; }; }, {}, never, ["*"], true, never>;
93
104
  }
94
105
 
95
106
  declare class StoryHelperComponentsModule {
96
107
  static ɵfac: i0.ɵɵFactoryDeclaration<StoryHelperComponentsModule, never>;
97
- static ɵmod: i0.ɵɵNgModuleDeclaration<StoryHelperComponentsModule, [typeof StoryEmptyWithRouteComponent, typeof StoryModalContainerComponent], [typeof i3.CommonModule, typeof i4.RouterModule, typeof i5.TheSeamOverlayScrollbarDirective], [typeof StoryEmptyWithRouteComponent, typeof StoryModalContainerComponent]>;
108
+ static ɵmod: i0.ɵɵNgModuleDeclaration<StoryHelperComponentsModule, [typeof StoryEmptyWithRouteComponent], [typeof i2.CommonModule, typeof i3.RouterModule, typeof i4.TheSeamOverlayScrollbarDirective, typeof StoryModalContainerComponent], [typeof StoryEmptyWithRouteComponent, typeof StoryModalContainerComponent]>;
98
109
  static ɵinj: i0.ɵɵInjectorDeclaration<StoryHelperComponentsModule>;
99
110
  }
100
111
 
@@ -109,6 +120,32 @@ declare class StoryInitialRouteService {
109
120
 
110
121
  declare function storyInitialRouteFactory(_storyInitialRouteService: StoryInitialRouteService): () => void;
111
122
 
123
+ interface StoryModalDecoratorOptions {
124
+ /**
125
+ * Passed through to `StoryModalContainerComponent`'s `modalConfig` input.
126
+ * Commonly used to opt into a Bootstrap modal size, e.g.
127
+ * `{ modalSize: 'lg' }`.
128
+ */
129
+ modalConfig?: ModalConfig;
130
+ }
131
+ /**
132
+ * Wraps a story's rendered component in `<story-modal-container-component>`
133
+ * so it previews inside a stand-in modal frame. Storybook's default template
134
+ * binds the story's args to the wrapped component, so inputs/outputs (e.g.
135
+ * for the Actions addon) work without extra wiring.
136
+ *
137
+ * Use as an entry in a story's `decorators` array:
138
+ *
139
+ * ```ts
140
+ * const meta: Meta<MyModalComponent> = {
141
+ * title: 'Modal/My',
142
+ * component: MyModalComponent,
143
+ * decorators: [storyModalDecorator({ modalConfig: { modalSize: 'lg' } })],
144
+ * }
145
+ * ```
146
+ */
147
+ declare function storyModalDecorator(options?: StoryModalDecoratorOptions): Decorator;
148
+
112
149
  /**
113
150
  * Can be used to trigger an event on a target element when the story component has been bootstrapped.
114
151
  *
@@ -157,5 +194,5 @@ declare const INJECTOR_TO_ARGS_PROPERTY_NAME = "__getInjector";
157
194
  declare const addInjectorGetterToArgs: (argName?: string) => DecoratorFunction<AngularRenderer>;
158
195
  declare const getInjectorFromArgs: (args: any, argName?: string) => Injector;
159
196
 
160
- export { INJECTOR_TO_ARGS_PROPERTY_NAME, STORY_INITIAL_ROUTE_URL, StoryEmptyComponent, StoryEmptyWithRouteComponent, StoryHelperComponentsModule, StoryInitialRouteModule, StoryInitialRouteService, StoryModalContainerComponent, StoryPreferencesAccessorService, addInjectorGetterToArgs, argsToTpl, buttonTypeArgType, getInjectorFromArgs, onStoryBootstrappedTrigger, routeButton, routesArgType, sizeArgType, storyInitialRouteFactory, themeArgType, themeWithOutlineArgType };
161
- export type { ArgsTplOptions, ArgsTplParts };
197
+ export { INJECTOR_TO_ARGS_PROPERTY_NAME, STORY_INITIAL_ROUTE_URL, StoryEmptyComponent, StoryEmptyWithRouteComponent, StoryHelperComponentsModule, StoryInitialRouteModule, StoryInitialRouteService, StoryModalContainerComponent, StoryPreferencesAccessorService, addInjectorGetterToArgs, argsToTpl, buttonTypeArgType, getInjectorFromArgs, onStoryBootstrappedTrigger, routeButton, routesArgType, sizeArgType, storyInitialRouteFactory, storyModalDecorator, themeArgType, themeWithOutlineArgType };
198
+ export type { ArgsTplOptions, ArgsTplParts, StoryModalDecoratorOptions };