@ngneers/controls 0.0.1-pre1
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/api/index.d.ts +134 -0
- package/custom-types/index.d.ts +7 -0
- package/dialog/index.d.ts +43 -0
- package/fesm2022/ngneers-controls-api.mjs +318 -0
- package/fesm2022/ngneers-controls-api.mjs.map +1 -0
- package/fesm2022/ngneers-controls-custom-types.mjs +4 -0
- package/fesm2022/ngneers-controls-custom-types.mjs.map +1 -0
- package/fesm2022/ngneers-controls-dialog.mjs +74 -0
- package/fesm2022/ngneers-controls-dialog.mjs.map +1 -0
- package/fesm2022/ngneers-controls-form-field.mjs +33 -0
- package/fesm2022/ngneers-controls-form-field.mjs.map +1 -0
- package/fesm2022/ngneers-controls-icon.mjs +53 -0
- package/fesm2022/ngneers-controls-icon.mjs.map +1 -0
- package/fesm2022/ngneers-controls-lazy-cacher.mjs +30 -0
- package/fesm2022/ngneers-controls-lazy-cacher.mjs.map +1 -0
- package/fesm2022/ngneers-controls-list-box.mjs +119 -0
- package/fesm2022/ngneers-controls-list-box.mjs.map +1 -0
- package/fesm2022/ngneers-controls-popover.mjs +80 -0
- package/fesm2022/ngneers-controls-popover.mjs.map +1 -0
- package/fesm2022/ngneers-controls-scroller.mjs +163 -0
- package/fesm2022/ngneers-controls-scroller.mjs.map +1 -0
- package/fesm2022/ngneers-controls-select.mjs +155 -0
- package/fesm2022/ngneers-controls-select.mjs.map +1 -0
- package/fesm2022/ngneers-controls-text-field.mjs +23 -0
- package/fesm2022/ngneers-controls-text-field.mjs.map +1 -0
- package/fesm2022/ngneers-controls-utils.mjs +104 -0
- package/fesm2022/ngneers-controls-utils.mjs.map +1 -0
- package/fesm2022/ngneers-controls.mjs +6 -0
- package/fesm2022/ngneers-controls.mjs.map +1 -0
- package/form-field/index.d.ts +19 -0
- package/icon/index.d.ts +30 -0
- package/index.d.ts +2 -0
- package/lazy-cacher/index.d.ts +14 -0
- package/list-box/index.d.ts +58 -0
- package/package.json +78 -0
- package/popover/index.d.ts +41 -0
- package/scroller/index.d.ts +95 -0
- package/select/index.d.ts +86 -0
- package/text-field/index.d.ts +10 -0
- package/utils/index.d.ts +36 -0
package/api/index.d.ts
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Signal, ElementRef, Type, Provider, Injector } from '@angular/core';
|
|
3
|
+
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
4
|
+
import { FormFieldBase } from '@ngneers/controls/form-field';
|
|
5
|
+
|
|
6
|
+
declare function elementSizeSignal(element: HTMLElement): Signal<{
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
}>;
|
|
10
|
+
|
|
11
|
+
declare class GetElementRef {
|
|
12
|
+
readonly elementRef: ElementRef<any>;
|
|
13
|
+
readonly nativeElement: any;
|
|
14
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<GetElementRef, never>;
|
|
15
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<GetElementRef, "[ngnElementRef]", ["ngnElementRef"], {}, {}, never, never, true, never>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type PredefinedFilterFunctions = 'contains' | 'startsWith' | 'endsWith' | 'equals' | 'fuzzy';
|
|
19
|
+
type FilterConfigInternal<T extends object> = FilterConfig<T> & {
|
|
20
|
+
filterFieldsCallback: (item: T) => string | string[];
|
|
21
|
+
fieldItems?: keyof T;
|
|
22
|
+
};
|
|
23
|
+
type FilterConfig<T extends object> = {
|
|
24
|
+
splitWords?: boolean;
|
|
25
|
+
caseSensitive?: boolean;
|
|
26
|
+
filterFn?: FilterFn<T>;
|
|
27
|
+
};
|
|
28
|
+
type FilterFn<T extends object> = PredefinedFilterFunctions | ((value: string, item: T) => Promise<boolean> | boolean);
|
|
29
|
+
declare function filterOptions<T extends object>(options: T[], filterText: string, filterOptions: FilterConfigInternal<T>): Promise<readonly T[]>;
|
|
30
|
+
|
|
31
|
+
declare function valueControlBaseProvider<T extends Type<ValueControlBase<any>>>(type: T): {
|
|
32
|
+
provide: typeof NG_VALUE_ACCESSOR;
|
|
33
|
+
useExisting: T;
|
|
34
|
+
multi: boolean;
|
|
35
|
+
};
|
|
36
|
+
declare abstract class ValueControlBase<T> implements FormFieldBase, ControlValueAccessor {
|
|
37
|
+
readonly label: i0.InputSignal<string | null>;
|
|
38
|
+
readonly inputId: i0.InputSignal<string>;
|
|
39
|
+
protected readonly value: i0.WritableSignal<T | null>;
|
|
40
|
+
writeValue(value: T | null): void;
|
|
41
|
+
private _onChange;
|
|
42
|
+
registerOnChange(fn: (value: T | null) => void): void;
|
|
43
|
+
private _onTouched;
|
|
44
|
+
registerOnTouched(fn: () => void): void;
|
|
45
|
+
protected onTouched(): void;
|
|
46
|
+
protected onChange(value: T): void;
|
|
47
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ValueControlBase<any>, never>;
|
|
48
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ValueControlBase<any>, "ng-component", never, { "label": { "alias": "label"; "required": false; "isSignal": true; }; "inputId": { "alias": "inputId"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
declare function provideNgnControls(): Provider[];
|
|
52
|
+
|
|
53
|
+
declare class NgnTemplate<T> {
|
|
54
|
+
readonly ngnTemplate: i0.InputSignal<T>;
|
|
55
|
+
static ngTemplateContextGuard<T>(dir: NgnTemplate<T>, ctx: unknown): ctx is T;
|
|
56
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NgnTemplate<any>, never>;
|
|
57
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<NgnTemplate<any>, "ng-template[ngnTemplate]", never, { "ngnTemplate": { "alias": "ngnTemplate"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* A noop with return type T.
|
|
61
|
+
* This function is used to define typed properties to use in a template.
|
|
62
|
+
*/
|
|
63
|
+
declare function templateTypesFn<T extends Record<string, Record<string, any>>>(): T;
|
|
64
|
+
/**
|
|
65
|
+
* A noop with return type `{ $implicit: Implicit } & Named`.
|
|
66
|
+
* This function is used to define a typed property to use in a template.
|
|
67
|
+
*/
|
|
68
|
+
declare function templateTypeFn<Implicit, Named extends Record<string, any> = object>(): {
|
|
69
|
+
$implicit: Implicit;
|
|
70
|
+
} & Named;
|
|
71
|
+
|
|
72
|
+
type NgnItem<T = any, K extends keyof T = any> = {
|
|
73
|
+
data?: T;
|
|
74
|
+
label: string;
|
|
75
|
+
value: T[K];
|
|
76
|
+
testId?: string;
|
|
77
|
+
items?: NgnItem<T, K>[];
|
|
78
|
+
};
|
|
79
|
+
type NgnItemFields<T, K extends keyof T> = {
|
|
80
|
+
label: keyof T;
|
|
81
|
+
value: K;
|
|
82
|
+
testId?: keyof T;
|
|
83
|
+
groupItems?: keyof T;
|
|
84
|
+
};
|
|
85
|
+
declare function transformToNgnItem<T extends object, K extends keyof T>(item: T, fields: NgnItemFields<T, K>): NgnItem<T, K>;
|
|
86
|
+
declare function transformToNgnItems<T extends object, K extends keyof T>(items: readonly T[], fields: {
|
|
87
|
+
label: keyof T;
|
|
88
|
+
value: K;
|
|
89
|
+
testId?: keyof T;
|
|
90
|
+
groupItems?: keyof T;
|
|
91
|
+
}): NgnItem<T, K>[];
|
|
92
|
+
declare function mapToItems(items: readonly NgnItem[]): NgnItem[];
|
|
93
|
+
declare function flatItems(items: readonly NgnItem[]): NgnItem[];
|
|
94
|
+
|
|
95
|
+
type PositioningSizeConstraints = {
|
|
96
|
+
/**
|
|
97
|
+
* The width of the floating element. When a number is provided, it is relative to the width of the reference element.
|
|
98
|
+
* When a string is provided, it is used as the CSS width value.
|
|
99
|
+
*/
|
|
100
|
+
width?: number | string;
|
|
101
|
+
/**
|
|
102
|
+
* The maximum width of the floating element. When a number is provided, it is relative to the width of the reference element.
|
|
103
|
+
* When a string is provided, it is used as the CSS max-width value.
|
|
104
|
+
*/
|
|
105
|
+
maxWidth?: number | string;
|
|
106
|
+
/**
|
|
107
|
+
* The height of the floating element. When a string is provided, it is used as the CSS height value.
|
|
108
|
+
*/
|
|
109
|
+
height?: string;
|
|
110
|
+
/**
|
|
111
|
+
* The maximum height of the floating element. When a string is provided, it is used as the CSS max-height value.
|
|
112
|
+
*/
|
|
113
|
+
maxHeight?: string;
|
|
114
|
+
};
|
|
115
|
+
type PositioningOptions = {
|
|
116
|
+
injector?: Injector;
|
|
117
|
+
placement?: 'top' | 'bottom' | 'left' | 'right';
|
|
118
|
+
flip?: boolean;
|
|
119
|
+
resize?: boolean;
|
|
120
|
+
shift?: boolean;
|
|
121
|
+
offset?: number;
|
|
122
|
+
stopped?: boolean;
|
|
123
|
+
sizeConstraints?: PositioningSizeConstraints;
|
|
124
|
+
};
|
|
125
|
+
type AutoPositioningHandle = {
|
|
126
|
+
stop: () => void;
|
|
127
|
+
start: () => void;
|
|
128
|
+
isRunning: () => boolean;
|
|
129
|
+
};
|
|
130
|
+
declare function positionElement(referenceEl: HTMLElement, floatingEl: HTMLElement, options?: PositioningOptions): void;
|
|
131
|
+
declare function autoPositionElement(referenceEl: HTMLElement, floatingEl: HTMLElement, options?: PositioningOptions): AutoPositioningHandle;
|
|
132
|
+
|
|
133
|
+
export { GetElementRef, NgnTemplate, ValueControlBase, autoPositionElement, elementSizeSignal, filterOptions, flatItems, mapToItems, positionElement, provideNgnControls, templateTypeFn, templateTypesFn, transformToNgnItem, transformToNgnItems, valueControlBaseProvider };
|
|
134
|
+
export type { AutoPositioningHandle, FilterConfig, FilterConfigInternal, FilterFn, NgnItem, NgnItemFields, PositioningOptions, PositioningSizeConstraints, PredefinedFilterFunctions };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { TemplateRef } from '@angular/core';
|
|
3
|
+
|
|
4
|
+
declare abstract class DialogTemplates {
|
|
5
|
+
private readonly _defaultHeaderTemplate;
|
|
6
|
+
private readonly _userHeaderTemplate;
|
|
7
|
+
readonly templateHeader: _angular_core.InputSignal<TemplateRef<unknown> | null>;
|
|
8
|
+
protected readonly headerTemplate: _angular_core.Signal<TemplateRef<unknown>>;
|
|
9
|
+
private readonly _defaultFooterTemplate;
|
|
10
|
+
private readonly _userFooterTemplate;
|
|
11
|
+
readonly templateFooter: _angular_core.InputSignal<TemplateRef<unknown> | null>;
|
|
12
|
+
protected readonly footerTemplate: _angular_core.Signal<TemplateRef<unknown>>;
|
|
13
|
+
/**
|
|
14
|
+
* Types for the dialog templates.
|
|
15
|
+
*/
|
|
16
|
+
readonly templateTypes: {
|
|
17
|
+
header: {
|
|
18
|
+
headerId: string;
|
|
19
|
+
title: string | null;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<DialogTemplates, never>;
|
|
23
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<DialogTemplates, "ng-component", never, { "templateHeader": { "alias": "templateHeader"; "required": false; "isSignal": true; }; "templateFooter": { "alias": "templateFooter"; "required": false; "isSignal": true; }; }, {}, ["_userHeaderTemplate", "_userFooterTemplate"], never, true, never>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
declare class Dialog extends DialogTemplates {
|
|
27
|
+
protected readonly headerId: string;
|
|
28
|
+
private readonly _dialogElement;
|
|
29
|
+
protected readonly lazyContent: _angular_core.Signal<TemplateRef<unknown> | undefined>;
|
|
30
|
+
readonly open: _angular_core.InputSignal<boolean>;
|
|
31
|
+
readonly cache: _angular_core.InputSignal<boolean>;
|
|
32
|
+
readonly modal: _angular_core.InputSignal<boolean>;
|
|
33
|
+
readonly autofocus: _angular_core.InputSignal<boolean>;
|
|
34
|
+
readonly title: _angular_core.InputSignal<string | null>;
|
|
35
|
+
readonly closeOnEscape: _angular_core.InputSignal<boolean>;
|
|
36
|
+
readonly closed: _angular_core.OutputEmitterRef<void>;
|
|
37
|
+
constructor();
|
|
38
|
+
protected onCancel(): void;
|
|
39
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<Dialog, never>;
|
|
40
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<Dialog, "ngn-dialog", never, { "open": { "alias": "open"; "required": false; "isSignal": true; }; "cache": { "alias": "cache"; "required": false; "isSignal": true; }; "modal": { "alias": "modal"; "required": false; "isSignal": true; }; "autofocus": { "alias": "autofocus"; "required": false; "isSignal": true; }; "title": { "alias": "title"; "required": false; "isSignal": true; }; "closeOnEscape": { "alias": "closeOnEscape"; "required": false; "isSignal": true; }; }, { "closed": "closed"; }, ["lazyContent"], ["*"], true, never>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { Dialog };
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { signal, inject, DestroyRef, ElementRef, Directive, input, Component } from '@angular/core';
|
|
3
|
+
import { fuzzyMatch, notNullish, generateElementId, NgnGlobal } from '@ngneers/controls/utils';
|
|
4
|
+
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
5
|
+
import { flip, shift, computePosition, offset, size, autoUpdate } from '@floating-ui/dom';
|
|
6
|
+
|
|
7
|
+
function elementSizeSignal(element) {
|
|
8
|
+
const sizeSignal = signal({
|
|
9
|
+
width: element.clientWidth,
|
|
10
|
+
height: element.clientHeight,
|
|
11
|
+
});
|
|
12
|
+
const destroyRef = inject(DestroyRef);
|
|
13
|
+
if (typeof ResizeObserver === 'undefined') {
|
|
14
|
+
return sizeSignal; // ResizeObserver is not supported, return initial size
|
|
15
|
+
}
|
|
16
|
+
const resizeObserver = new ResizeObserver(entries => {
|
|
17
|
+
const firstEntry = entries[0];
|
|
18
|
+
sizeSignal.set({
|
|
19
|
+
width: firstEntry.contentRect.width,
|
|
20
|
+
height: firstEntry.contentRect.height,
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
resizeObserver.observe(element);
|
|
24
|
+
destroyRef.onDestroy(() => {
|
|
25
|
+
resizeObserver.disconnect();
|
|
26
|
+
});
|
|
27
|
+
return sizeSignal;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
class GetElementRef {
|
|
31
|
+
elementRef = inject(ElementRef);
|
|
32
|
+
nativeElement = this.elementRef.nativeElement;
|
|
33
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.5", ngImport: i0, type: GetElementRef, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
34
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.0.5", type: GetElementRef, isStandalone: true, selector: "[ngnElementRef]", exportAs: ["ngnElementRef"], ngImport: i0 });
|
|
35
|
+
}
|
|
36
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.5", ngImport: i0, type: GetElementRef, decorators: [{
|
|
37
|
+
type: Directive,
|
|
38
|
+
args: [{ selector: '[ngnElementRef]', exportAs: 'ngnElementRef' }]
|
|
39
|
+
}] });
|
|
40
|
+
|
|
41
|
+
async function filterItem(item, filterText, options) {
|
|
42
|
+
const text = options.caseSensitive ? filterText : filterText.toLowerCase();
|
|
43
|
+
const filterFieldsCallbackResult = options.filterFieldsCallback?.(item);
|
|
44
|
+
const fields = Array.isArray(filterFieldsCallbackResult)
|
|
45
|
+
? filterFieldsCallbackResult
|
|
46
|
+
: [filterFieldsCallbackResult];
|
|
47
|
+
const words = options.splitWords ? text.split(/\s+/) : [text];
|
|
48
|
+
const itemDoesMatch = (await Promise.all(fields.map(async (field) => {
|
|
49
|
+
const value = String(field);
|
|
50
|
+
const valueStr = options.caseSensitive ? value : value.toLowerCase();
|
|
51
|
+
return await itemMatches(words, options, valueStr, item);
|
|
52
|
+
}))).some(result => result);
|
|
53
|
+
if (itemDoesMatch) {
|
|
54
|
+
return item;
|
|
55
|
+
}
|
|
56
|
+
if (!options.fieldItems) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
const childItems = item[options.fieldItems];
|
|
60
|
+
if (!childItems || !Array.isArray(childItems) || childItems.length === 0) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
const matchingChildren = await filterOptions(childItems, filterText, options);
|
|
64
|
+
if (matchingChildren.length > 0) {
|
|
65
|
+
return {
|
|
66
|
+
...item,
|
|
67
|
+
[options.fieldItems]: matchingChildren,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
async function itemMatches(words, filterOptions, itemString, item) {
|
|
73
|
+
const results = await Promise.all(words.map(async (word) => {
|
|
74
|
+
switch (filterOptions.filterFn ?? 'contains') {
|
|
75
|
+
case 'contains':
|
|
76
|
+
return itemString.includes(word);
|
|
77
|
+
case 'startsWith':
|
|
78
|
+
return itemString.startsWith(word);
|
|
79
|
+
case 'endsWith':
|
|
80
|
+
return itemString.endsWith(word);
|
|
81
|
+
case 'equals':
|
|
82
|
+
return itemString === word;
|
|
83
|
+
case 'fuzzy':
|
|
84
|
+
return fuzzyMatch(itemString, word);
|
|
85
|
+
default:
|
|
86
|
+
if (typeof filterOptions.filterFn !== 'function') {
|
|
87
|
+
throw new Error(`Invalid filter function: ${filterOptions.filterFn}. Expected a function or one of the predefined filter functions.`);
|
|
88
|
+
}
|
|
89
|
+
return await filterOptions.filterFn(word, item);
|
|
90
|
+
}
|
|
91
|
+
}));
|
|
92
|
+
return results.some(result => result);
|
|
93
|
+
}
|
|
94
|
+
async function filterOptions(options, filterText, filterOptions) {
|
|
95
|
+
if (!filterText) {
|
|
96
|
+
return options;
|
|
97
|
+
}
|
|
98
|
+
return (await Promise.all(options.map(async (option) => await filterItem(option, filterText, filterOptions)))).filter(notNullish);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
102
|
+
function valueControlBaseProvider(type) {
|
|
103
|
+
return {
|
|
104
|
+
provide: NG_VALUE_ACCESSOR,
|
|
105
|
+
useExisting: type,
|
|
106
|
+
multi: true,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
class ValueControlBase {
|
|
110
|
+
label = input(null);
|
|
111
|
+
inputId = input(generateElementId());
|
|
112
|
+
value = signal(null);
|
|
113
|
+
writeValue(value) {
|
|
114
|
+
this.value.set(value ?? null);
|
|
115
|
+
}
|
|
116
|
+
_onChange = () => { };
|
|
117
|
+
registerOnChange(fn) {
|
|
118
|
+
this._onChange = fn;
|
|
119
|
+
}
|
|
120
|
+
_onTouched = () => { };
|
|
121
|
+
registerOnTouched(fn) {
|
|
122
|
+
this._onTouched = fn;
|
|
123
|
+
}
|
|
124
|
+
onTouched() {
|
|
125
|
+
this._onTouched();
|
|
126
|
+
}
|
|
127
|
+
onChange(value) {
|
|
128
|
+
this._onChange(value ?? null);
|
|
129
|
+
}
|
|
130
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.5", ngImport: i0, type: ValueControlBase, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
131
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.0.5", type: ValueControlBase, isStandalone: true, selector: "ng-component", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, inputId: { classPropertyName: "inputId", publicName: "inputId", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: '', isInline: true });
|
|
132
|
+
}
|
|
133
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.5", ngImport: i0, type: ValueControlBase, decorators: [{
|
|
134
|
+
type: Component,
|
|
135
|
+
args: [{
|
|
136
|
+
template: '',
|
|
137
|
+
imports: [],
|
|
138
|
+
}]
|
|
139
|
+
}] });
|
|
140
|
+
|
|
141
|
+
function provideNgnControls() {
|
|
142
|
+
return [NgnGlobal];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
class NgnTemplate {
|
|
146
|
+
ngnTemplate = input.required();
|
|
147
|
+
static ngTemplateContextGuard(dir, ctx) {
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.5", ngImport: i0, type: NgnTemplate, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
151
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.0.5", type: NgnTemplate, isStandalone: true, selector: "ng-template[ngnTemplate]", inputs: { ngnTemplate: { classPropertyName: "ngnTemplate", publicName: "ngnTemplate", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0 });
|
|
152
|
+
}
|
|
153
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.5", ngImport: i0, type: NgnTemplate, decorators: [{
|
|
154
|
+
type: Directive,
|
|
155
|
+
args: [{
|
|
156
|
+
selector: 'ng-template[ngnTemplate]',
|
|
157
|
+
}]
|
|
158
|
+
}] });
|
|
159
|
+
/**
|
|
160
|
+
* A noop with return type T.
|
|
161
|
+
* This function is used to define typed properties to use in a template.
|
|
162
|
+
*/
|
|
163
|
+
function templateTypesFn() {
|
|
164
|
+
return {};
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* A noop with return type `{ $implicit: Implicit } & Named`.
|
|
168
|
+
* This function is used to define a typed property to use in a template.
|
|
169
|
+
*/
|
|
170
|
+
function templateTypeFn() {
|
|
171
|
+
return {};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function transformToNgnItem(item, fields) {
|
|
175
|
+
const rawItems = fields.groupItems ? item[fields.groupItems] : undefined;
|
|
176
|
+
if (rawItems && !Array.isArray(rawItems)) {
|
|
177
|
+
throw new Error(`Expected groupItems to be an array, but got ${typeof rawItems} for item: ${JSON.stringify(item)}`);
|
|
178
|
+
}
|
|
179
|
+
const items = rawItems?.length
|
|
180
|
+
? transformToNgnItems(rawItems, fields)
|
|
181
|
+
: undefined;
|
|
182
|
+
return {
|
|
183
|
+
data: item,
|
|
184
|
+
label: item[fields.label],
|
|
185
|
+
value: item[fields.value],
|
|
186
|
+
testId: fields.testId ? item[fields.testId] : undefined,
|
|
187
|
+
items: items,
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
function transformToNgnItems(items, fields) {
|
|
191
|
+
return items.map(item => transformToNgnItem(item, fields));
|
|
192
|
+
}
|
|
193
|
+
function mapToItems(items) {
|
|
194
|
+
return items
|
|
195
|
+
.map(item => {
|
|
196
|
+
if (item.items) {
|
|
197
|
+
return item.items;
|
|
198
|
+
}
|
|
199
|
+
return [item];
|
|
200
|
+
})
|
|
201
|
+
.flat();
|
|
202
|
+
}
|
|
203
|
+
function flatItems(items) {
|
|
204
|
+
return items
|
|
205
|
+
.map(item => {
|
|
206
|
+
if (item.items) {
|
|
207
|
+
return [item, ...item.items];
|
|
208
|
+
}
|
|
209
|
+
return [item];
|
|
210
|
+
})
|
|
211
|
+
.flat();
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function mergeWithDefaults(options) {
|
|
215
|
+
return {
|
|
216
|
+
placement: 'bottom',
|
|
217
|
+
flip: true,
|
|
218
|
+
resize: true,
|
|
219
|
+
shift: true,
|
|
220
|
+
offset: 4,
|
|
221
|
+
stopped: false,
|
|
222
|
+
...options,
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
function positionElement(referenceEl, floatingEl, options = {}) {
|
|
226
|
+
options = mergeWithDefaults(options);
|
|
227
|
+
const flipMiddleware = options.flip
|
|
228
|
+
? flip(options.shift ? { crossAxis: 'alignment', fallbackAxisSideDirection: 'end' } : undefined)
|
|
229
|
+
: undefined;
|
|
230
|
+
const shiftMiddleware = options.shift ? shift() : undefined;
|
|
231
|
+
if (options.sizeConstraints) {
|
|
232
|
+
if (options.sizeConstraints.width || options.sizeConstraints.maxWidth) {
|
|
233
|
+
const refWidth = referenceEl.offsetWidth;
|
|
234
|
+
if (options.sizeConstraints.width) {
|
|
235
|
+
if (typeof options.sizeConstraints.width === 'string') {
|
|
236
|
+
floatingEl.style.width = options.sizeConstraints.width;
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
const widthConstraints = options.sizeConstraints.width * refWidth;
|
|
240
|
+
floatingEl.style.width = `min(100%, ${widthConstraints}px)`;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
if (options.sizeConstraints.maxWidth) {
|
|
244
|
+
if (typeof options.sizeConstraints.maxWidth === 'string') {
|
|
245
|
+
floatingEl.style.maxWidth = options.sizeConstraints.maxWidth;
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
const maxWidthConstraints = options.sizeConstraints.maxWidth * refWidth;
|
|
249
|
+
floatingEl.style.maxWidth = `min(100%, ${maxWidthConstraints}px)`;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (options.sizeConstraints.height || options.sizeConstraints.maxHeight) {
|
|
254
|
+
if (options.sizeConstraints.height) {
|
|
255
|
+
floatingEl.style.height = options.sizeConstraints.height;
|
|
256
|
+
}
|
|
257
|
+
if (options.sizeConstraints.maxHeight) {
|
|
258
|
+
floatingEl.style.maxHeight = options.sizeConstraints.maxHeight;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
computePosition(referenceEl, floatingEl, {
|
|
263
|
+
placement: options.placement,
|
|
264
|
+
middleware: [
|
|
265
|
+
options.offset ? offset(options.offset) : undefined,
|
|
266
|
+
...(options.placement?.includes('-')
|
|
267
|
+
? [flipMiddleware, shiftMiddleware]
|
|
268
|
+
: [shiftMiddleware, flipMiddleware]),
|
|
269
|
+
options.resize
|
|
270
|
+
? size({
|
|
271
|
+
apply({ availableHeight }) {
|
|
272
|
+
Object.assign(floatingEl.style, {
|
|
273
|
+
maxHeight: `${Math.min(Number(options.sizeConstraints?.maxHeight ?? availableHeight), availableHeight)}px`,
|
|
274
|
+
});
|
|
275
|
+
},
|
|
276
|
+
})
|
|
277
|
+
: undefined,
|
|
278
|
+
].filter(Boolean),
|
|
279
|
+
}).then(({ x, y }) => {
|
|
280
|
+
Object.assign(floatingEl.style, {
|
|
281
|
+
left: `${x}px`,
|
|
282
|
+
top: `${y}px`,
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
function autoPositionElement(referenceEl, floatingEl, options = {}) {
|
|
287
|
+
options = mergeWithDefaults(options);
|
|
288
|
+
let cleanup;
|
|
289
|
+
const destroyRef = options.injector?.get(DestroyRef) ?? inject(DestroyRef);
|
|
290
|
+
function startAutoUpdate() {
|
|
291
|
+
cleanup = autoUpdate(referenceEl, floatingEl, () => {
|
|
292
|
+
positionElement(referenceEl, floatingEl, options);
|
|
293
|
+
});
|
|
294
|
+
return cleanup;
|
|
295
|
+
}
|
|
296
|
+
destroyRef.onDestroy(() => {
|
|
297
|
+
cleanup?.();
|
|
298
|
+
cleanup = undefined;
|
|
299
|
+
});
|
|
300
|
+
return {
|
|
301
|
+
start: () => {
|
|
302
|
+
cleanup?.();
|
|
303
|
+
startAutoUpdate();
|
|
304
|
+
},
|
|
305
|
+
stop: () => {
|
|
306
|
+
cleanup?.();
|
|
307
|
+
cleanup = undefined;
|
|
308
|
+
},
|
|
309
|
+
isRunning: () => !!cleanup,
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Generated bundle index. Do not edit.
|
|
315
|
+
*/
|
|
316
|
+
|
|
317
|
+
export { GetElementRef, NgnTemplate, ValueControlBase, autoPositionElement, elementSizeSignal, filterOptions, flatItems, mapToItems, positionElement, provideNgnControls, templateTypeFn, templateTypesFn, transformToNgnItem, transformToNgnItems, valueControlBaseProvider };
|
|
318
|
+
//# sourceMappingURL=ngneers-controls-api.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ngneers-controls-api.mjs","sources":["../../../packages/controls/src/api/dom.ts","../../../packages/controls/src/api/element-ref.ts","../../../packages/controls/src/api/filtering.ts","../../../packages/controls/src/api/value-control-base.ts","../../../packages/controls/src/api/provider.ts","../../../packages/controls/src/api/template.ts","../../../packages/controls/src/api/ngn-items.ts","../../../packages/controls/src/api/positioning.ts","../../../packages/controls/src/api/ngneers-controls-api.ts"],"sourcesContent":["import { DestroyRef, inject, signal, Signal } from '@angular/core';\r\n\r\nexport function elementSizeSignal(element: HTMLElement): Signal<{ width: number; height: number }> {\r\n const sizeSignal = signal<{ width: number; height: number }>({\r\n width: element.clientWidth,\r\n height: element.clientHeight,\r\n });\r\n\r\n const destroyRef = inject(DestroyRef);\r\n if (typeof ResizeObserver === 'undefined') {\r\n return sizeSignal; // ResizeObserver is not supported, return initial size\r\n }\r\n const resizeObserver = new ResizeObserver(entries => {\r\n const firstEntry = entries[0];\r\n sizeSignal.set({\r\n width: firstEntry.contentRect.width,\r\n height: firstEntry.contentRect.height,\r\n });\r\n });\r\n resizeObserver.observe(element);\r\n destroyRef.onDestroy(() => {\r\n resizeObserver.disconnect();\r\n });\r\n return sizeSignal;\r\n}\r\n","import { Directive, ElementRef, inject } from '@angular/core';\r\n\r\n@Directive({ selector: '[ngnElementRef]', exportAs: 'ngnElementRef' })\r\nexport class GetElementRef {\r\n public readonly elementRef = inject(ElementRef);\r\n public readonly nativeElement = this.elementRef.nativeElement;\r\n}\r\n","import { fuzzyMatch, notNullish } from '@ngneers/controls/utils';\r\n\r\nexport type PredefinedFilterFunctions = 'contains' | 'startsWith' | 'endsWith' | 'equals' | 'fuzzy';\r\n\r\nexport type FilterConfigInternal<T extends object> = FilterConfig<T> & {\r\n filterFieldsCallback: (item: T) => string | string[];\r\n fieldItems?: keyof T;\r\n};\r\n\r\nexport type FilterConfig<T extends object> = {\r\n splitWords?: boolean;\r\n caseSensitive?: boolean;\r\n filterFn?: FilterFn<T>;\r\n};\r\n\r\nexport type FilterFn<T extends object> =\r\n | PredefinedFilterFunctions\r\n | ((value: string, item: T) => Promise<boolean> | boolean);\r\n\r\nasync function filterItem<T extends object>(\r\n item: T,\r\n filterText: string,\r\n options: FilterConfigInternal<T>\r\n): Promise<T | null> {\r\n const text = options.caseSensitive ? filterText : filterText.toLowerCase();\r\n const filterFieldsCallbackResult = options.filterFieldsCallback?.(item);\r\n const fields = Array.isArray(filterFieldsCallbackResult)\r\n ? filterFieldsCallbackResult\r\n : [filterFieldsCallbackResult];\r\n const words = options.splitWords ? text.split(/\\s+/) : [text];\r\n\r\n const itemDoesMatch = (\r\n await Promise.all(\r\n fields.map(async field => {\r\n const value = String(field);\r\n const valueStr = options.caseSensitive ? value : value.toLowerCase();\r\n return await itemMatches<T>(words, options, valueStr, item);\r\n })\r\n )\r\n ).some(result => result);\r\n if (itemDoesMatch) {\r\n return item;\r\n }\r\n if (!options.fieldItems) {\r\n return null;\r\n }\r\n const childItems = item[options.fieldItems] as T[];\r\n if (!childItems || !Array.isArray(childItems) || childItems.length === 0) {\r\n return null;\r\n }\r\n const matchingChildren = await filterOptions(childItems, filterText, options);\r\n if (matchingChildren.length > 0) {\r\n return {\r\n ...item,\r\n [options.fieldItems]: matchingChildren,\r\n };\r\n }\r\n return null;\r\n}\r\n\r\nasync function itemMatches<T extends object>(\r\n words: string[],\r\n filterOptions: FilterConfigInternal<T>,\r\n itemString: string,\r\n item: T\r\n): Promise<boolean> {\r\n const results = await Promise.all(\r\n words.map(async word => {\r\n switch (filterOptions.filterFn ?? 'contains') {\r\n case 'contains':\r\n return itemString.includes(word);\r\n case 'startsWith':\r\n return itemString.startsWith(word);\r\n case 'endsWith':\r\n return itemString.endsWith(word);\r\n case 'equals':\r\n return itemString === word;\r\n case 'fuzzy':\r\n return fuzzyMatch(itemString, word);\r\n default:\r\n if (typeof filterOptions.filterFn !== 'function') {\r\n throw new Error(\r\n `Invalid filter function: ${filterOptions.filterFn}. Expected a function or one of the predefined filter functions.`\r\n );\r\n }\r\n return await filterOptions.filterFn(word, item);\r\n }\r\n })\r\n );\r\n return results.some(result => result);\r\n}\r\n\r\nexport async function filterOptions<T extends object>(\r\n options: T[],\r\n filterText: string,\r\n filterOptions: FilterConfigInternal<T>\r\n): Promise<readonly T[]> {\r\n if (!filterText) {\r\n return options;\r\n }\r\n return (\r\n await Promise.all(\r\n options.map(async option => await filterItem(option, filterText, filterOptions))\r\n )\r\n ).filter(notNullish);\r\n}\r\n","import { Component, input, signal, Type } from '@angular/core';\r\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\r\nimport { FormFieldBase } from '@ngneers/controls/form-field';\r\nimport { generateElementId } from '@ngneers/controls/utils';\r\n\r\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\r\nexport function valueControlBaseProvider<T extends Type<ValueControlBase<any>>>(\r\n type: T\r\n): { provide: typeof NG_VALUE_ACCESSOR; useExisting: T; multi: boolean } {\r\n return {\r\n provide: NG_VALUE_ACCESSOR,\r\n useExisting: type,\r\n multi: true,\r\n };\r\n}\r\n\r\n@Component({\r\n template: '',\r\n imports: [],\r\n})\r\nexport abstract class ValueControlBase<T> implements FormFieldBase, ControlValueAccessor {\r\n public readonly label = input<string | null>(null);\r\n public readonly inputId = input<string>(generateElementId());\r\n\r\n protected readonly value = signal<T | null>(null);\r\n\r\n public writeValue(value: T | null): void {\r\n this.value.set(value ?? null);\r\n }\r\n private _onChange: (_: T | null) => void = () => {};\r\n public registerOnChange(fn: (value: T | null) => void): void {\r\n this._onChange = fn;\r\n }\r\n private _onTouched: () => void = () => {};\r\n public registerOnTouched(fn: () => void): void {\r\n this._onTouched = fn;\r\n }\r\n\r\n protected onTouched() {\r\n this._onTouched();\r\n }\r\n\r\n protected onChange(value: T) {\r\n this._onChange(value ?? null);\r\n }\r\n}\r\n","import { Provider } from '@angular/core';\nimport { NgnGlobal } from '@ngneers/controls/utils';\n\nexport function provideNgnControls(): Provider[] {\n return [NgnGlobal];\n}\n","import { Directive, input } from '@angular/core';\n\n@Directive({\n selector: 'ng-template[ngnTemplate]',\n})\nexport class NgnTemplate<T> {\n public readonly ngnTemplate = input.required<T>();\n\n public static ngTemplateContextGuard<T>(dir: NgnTemplate<T>, ctx: unknown): ctx is T {\n return true;\n }\n}\n\n/**\n * A noop with return type T.\n * This function is used to define typed properties to use in a template.\n */\nexport function templateTypesFn<T extends Record<string, Record<string, any>>>() {\n return {} as T;\n}\n\n/**\n * A noop with return type `{ $implicit: Implicit } & Named`.\n * This function is used to define a typed property to use in a template.\n */\nexport function templateTypeFn<Implicit, Named extends Record<string, any> = object>() {\n return {} as { $implicit: Implicit } & Named;\n}\n","export type NgnItem<T = any, K extends keyof T = any> = {\r\n data?: T;\r\n label: string;\r\n value: T[K];\r\n testId?: string;\r\n items?: NgnItem<T, K>[];\r\n};\r\n\r\nexport type NgnItemFields<T, K extends keyof T> = {\r\n label: keyof T;\r\n value: K;\r\n testId?: keyof T;\r\n groupItems?: keyof T;\r\n};\r\n\r\nexport function transformToNgnItem<T extends object, K extends keyof T>(\r\n item: T,\r\n fields: NgnItemFields<T, K>\r\n): NgnItem<T, K> {\r\n const rawItems = fields.groupItems ? item[fields.groupItems] : undefined;\r\n if (rawItems && !Array.isArray(rawItems)) {\r\n throw new Error(\r\n `Expected groupItems to be an array, but got ${typeof rawItems} for item: ${JSON.stringify(item)}`\r\n );\r\n }\r\n const items = (rawItems as T[])?.length\r\n ? transformToNgnItems(rawItems as T[], fields)\r\n : undefined;\r\n return {\r\n data: item,\r\n label: item[fields.label] as string,\r\n value: item[fields.value],\r\n testId: fields.testId ? (item[fields.testId] as string) : undefined,\r\n items: items,\r\n };\r\n}\r\n\r\nexport function transformToNgnItems<T extends object, K extends keyof T>(\r\n items: readonly T[],\r\n fields: {\r\n label: keyof T;\r\n value: K;\r\n testId?: keyof T;\r\n groupItems?: keyof T;\r\n }\r\n): NgnItem<T, K>[] {\r\n return items.map(item => transformToNgnItem(item, fields));\r\n}\r\n\r\nexport function mapToItems(items: readonly NgnItem[]): NgnItem[] {\r\n return items\r\n .map(item => {\r\n if (item.items) {\r\n return item.items;\r\n }\r\n return [item];\r\n })\r\n .flat();\r\n}\r\n\r\nexport function flatItems(items: readonly NgnItem[]): NgnItem[] {\r\n return items\r\n .map(item => {\r\n if (item.items) {\r\n return [item, ...item.items];\r\n }\r\n return [item];\r\n })\r\n .flat();\r\n}\r\n","import { DestroyRef, inject, Injector } from '@angular/core';\r\nimport { autoUpdate, computePosition, flip, offset, shift, size } from '@floating-ui/dom';\r\n\r\nexport type PositioningSizeConstraints = {\r\n /**\r\n * The width of the floating element. When a number is provided, it is relative to the width of the reference element.\r\n * When a string is provided, it is used as the CSS width value.\r\n */\r\n width?: number | string;\r\n /**\r\n * The maximum width of the floating element. When a number is provided, it is relative to the width of the reference element.\r\n * When a string is provided, it is used as the CSS max-width value.\r\n */\r\n maxWidth?: number | string;\r\n /**\r\n * The height of the floating element. When a string is provided, it is used as the CSS height value.\r\n */\r\n height?: string;\r\n /**\r\n * The maximum height of the floating element. When a string is provided, it is used as the CSS max-height value.\r\n */\r\n maxHeight?: string;\r\n};\r\n\r\nexport type PositioningOptions = {\r\n injector?: Injector;\r\n placement?: 'top' | 'bottom' | 'left' | 'right';\r\n flip?: boolean;\r\n resize?: boolean;\r\n shift?: boolean;\r\n offset?: number;\r\n stopped?: boolean;\r\n sizeConstraints?: PositioningSizeConstraints;\r\n};\r\n\r\nexport type AutoPositioningHandle = {\r\n stop: () => void;\r\n start: () => void;\r\n isRunning: () => boolean;\r\n};\r\n\r\nfunction mergeWithDefaults(options: PositioningOptions): PositioningOptions {\r\n return {\r\n placement: 'bottom',\r\n flip: true,\r\n resize: true,\r\n shift: true,\r\n offset: 4,\r\n stopped: false,\r\n ...options,\r\n };\r\n}\r\n\r\nexport function positionElement(\r\n referenceEl: HTMLElement,\r\n floatingEl: HTMLElement,\r\n options: PositioningOptions = {}\r\n) {\r\n options = mergeWithDefaults(options);\r\n\r\n const flipMiddleware = options.flip\r\n ? flip(options.shift ? { crossAxis: 'alignment', fallbackAxisSideDirection: 'end' } : undefined)\r\n : undefined;\r\n const shiftMiddleware = options.shift ? shift() : undefined;\r\n\r\n if (options.sizeConstraints) {\r\n if (options.sizeConstraints.width || options.sizeConstraints.maxWidth) {\r\n const refWidth = referenceEl.offsetWidth;\r\n if (options.sizeConstraints.width) {\r\n if (typeof options.sizeConstraints.width === 'string') {\r\n floatingEl.style.width = options.sizeConstraints.width;\r\n } else {\r\n const widthConstraints = options.sizeConstraints.width * refWidth;\r\n floatingEl.style.width = `min(100%, ${widthConstraints}px)`;\r\n }\r\n }\r\n if (options.sizeConstraints.maxWidth) {\r\n if (typeof options.sizeConstraints.maxWidth === 'string') {\r\n floatingEl.style.maxWidth = options.sizeConstraints.maxWidth;\r\n } else {\r\n const maxWidthConstraints = options.sizeConstraints.maxWidth * refWidth;\r\n floatingEl.style.maxWidth = `min(100%, ${maxWidthConstraints}px)`;\r\n }\r\n }\r\n }\r\n if (options.sizeConstraints.height || options.sizeConstraints.maxHeight) {\r\n if (options.sizeConstraints.height) {\r\n floatingEl.style.height = options.sizeConstraints.height;\r\n }\r\n if (options.sizeConstraints.maxHeight) {\r\n floatingEl.style.maxHeight = options.sizeConstraints.maxHeight;\r\n }\r\n }\r\n }\r\n\r\n computePosition(referenceEl, floatingEl, {\r\n placement: options.placement,\r\n middleware: [\r\n options.offset ? offset(options.offset) : undefined,\r\n ...(options.placement?.includes('-')\r\n ? [flipMiddleware, shiftMiddleware]\r\n : [shiftMiddleware, flipMiddleware]),\r\n options.resize\r\n ? size({\r\n apply({ availableHeight }) {\r\n Object.assign(floatingEl.style, {\r\n maxHeight: `${Math.min(Number(options.sizeConstraints?.maxHeight ?? availableHeight), availableHeight)}px`,\r\n });\r\n },\r\n })\r\n : undefined,\r\n ].filter(Boolean),\r\n }).then(({ x, y }) => {\r\n Object.assign(floatingEl.style, {\r\n left: `${x}px`,\r\n top: `${y}px`,\r\n });\r\n });\r\n}\r\n\r\nexport function autoPositionElement(\r\n referenceEl: HTMLElement,\r\n floatingEl: HTMLElement,\r\n options: PositioningOptions = {}\r\n): AutoPositioningHandle {\r\n options = mergeWithDefaults(options);\r\n\r\n let cleanup: (() => void) | undefined;\r\n const destroyRef = options.injector?.get(DestroyRef) ?? inject(DestroyRef);\r\n\r\n function startAutoUpdate() {\r\n cleanup = autoUpdate(referenceEl, floatingEl, () => {\r\n positionElement(referenceEl, floatingEl, options);\r\n });\r\n return cleanup;\r\n }\r\n\r\n destroyRef.onDestroy(() => {\r\n cleanup?.();\r\n cleanup = undefined;\r\n });\r\n return {\r\n start: () => {\r\n cleanup?.();\r\n startAutoUpdate();\r\n },\r\n stop: () => {\r\n cleanup?.();\r\n cleanup = undefined;\r\n },\r\n isRunning: () => !!cleanup,\r\n };\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAEM,SAAU,iBAAiB,CAAC,OAAoB,EAAA;IACpD,MAAM,UAAU,GAAG,MAAM,CAAoC;QAC3D,KAAK,EAAE,OAAO,CAAC,WAAW;QAC1B,MAAM,EAAE,OAAO,CAAC,YAAY;AAC7B,KAAA,CAAC;AAEF,IAAA,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;AACrC,IAAA,IAAI,OAAO,cAAc,KAAK,WAAW,EAAE;QACzC,OAAO,UAAU,CAAC;;AAEpB,IAAA,MAAM,cAAc,GAAG,IAAI,cAAc,CAAC,OAAO,IAAG;AAClD,QAAA,MAAM,UAAU,GAAG,OAAO,CAAC,CAAC,CAAC;QAC7B,UAAU,CAAC,GAAG,CAAC;AACb,YAAA,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,KAAK;AACnC,YAAA,MAAM,EAAE,UAAU,CAAC,WAAW,CAAC,MAAM;AACtC,SAAA,CAAC;AACJ,KAAC,CAAC;AACF,IAAA,cAAc,CAAC,OAAO,CAAC,OAAO,CAAC;AAC/B,IAAA,UAAU,CAAC,SAAS,CAAC,MAAK;QACxB,cAAc,CAAC,UAAU,EAAE;AAC7B,KAAC,CAAC;AACF,IAA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C;AAE1E,IAAA,SAAS,eAAe,GAAA;QACtB,OAAO,GAAG,UAAU,CAAC,WAAW,EAAE,UAAU,EAAE,MAAK;AACjD,YAAA,eAAe,CAAC,WAAW,EAAE,UAAU,EAAE,OAAO,CAAC;AACnD,SAAC,CAAC;AACF,QAAA,OAAO,OAAO;;AAGhB,IAAA,UAAU,CAAC,SAAS,CAAC,MAAK;QACxB,OAAO,IAAI;QACX,OAAO,GAAG,SAAS;AACrB,KAAC,CAAC;IACF,OAAO;QACL,KAAK,EAAE,MAAK;YACV,OAAO,IAAI;AACX,YAAA,eAAe,EAAE;SAClB;QACD,IAAI,EAAE,MAAK;YACT,OAAO,IAAI;YACX,OAAO,GAAG,SAAS;SACpB;AACD,QAAA,SAAS,EAAE,MAAM,CAAC,CAAC,OAAO;KAC3B;AACH;;ACxJA;;AAEG;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ngneers-controls-custom-types.mjs","sources":["../../../packages/controls/src/custom-types/ngneers-controls-custom-types.ts"],"sourcesContent":["/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":"AAAA;;AAEG"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { viewChild, contentChild, input, computed, Component, output, afterRenderEffect, untracked, ChangeDetectionStrategy } from '@angular/core';
|
|
4
|
+
import { templateTypesFn, NgnTemplate } from '@ngneers/controls/api';
|
|
5
|
+
import { LazyCacher } from '@ngneers/controls/lazy-cacher';
|
|
6
|
+
import { generateElementId } from '@ngneers/controls/utils';
|
|
7
|
+
|
|
8
|
+
class DialogTemplates {
|
|
9
|
+
_defaultHeaderTemplate = viewChild.required('defaultHeaderTemplate');
|
|
10
|
+
_userHeaderTemplate = contentChild('header');
|
|
11
|
+
templateHeader = input(null);
|
|
12
|
+
headerTemplate = computed(() => this._userHeaderTemplate() ?? this.templateHeader() ?? this._defaultHeaderTemplate());
|
|
13
|
+
_defaultFooterTemplate = viewChild.required('defaultFooterTemplate');
|
|
14
|
+
_userFooterTemplate = contentChild('footer');
|
|
15
|
+
templateFooter = input(null);
|
|
16
|
+
footerTemplate = computed(() => this._userFooterTemplate() ?? this.templateFooter() ?? this._defaultFooterTemplate());
|
|
17
|
+
/**
|
|
18
|
+
* Types for the dialog templates.
|
|
19
|
+
*/
|
|
20
|
+
templateTypes = templateTypesFn();
|
|
21
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.5", ngImport: i0, type: DialogTemplates, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
22
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "20.0.5", type: DialogTemplates, isStandalone: true, selector: "ng-component", inputs: { templateHeader: { classPropertyName: "templateHeader", publicName: "templateHeader", isSignal: true, isRequired: false, transformFunction: null }, templateFooter: { classPropertyName: "templateFooter", publicName: "templateFooter", isSignal: true, isRequired: false, transformFunction: null } }, queries: [{ propertyName: "_userHeaderTemplate", first: true, predicate: ["header"], descendants: true, isSignal: true }, { propertyName: "_userFooterTemplate", first: true, predicate: ["footer"], descendants: true, isSignal: true }], viewQueries: [{ propertyName: "_defaultHeaderTemplate", first: true, predicate: ["defaultHeaderTemplate"], descendants: true, isSignal: true }, { propertyName: "_defaultFooterTemplate", first: true, predicate: ["defaultFooterTemplate"], descendants: true, isSignal: true }], ngImport: i0, template: '', isInline: true });
|
|
23
|
+
}
|
|
24
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.5", ngImport: i0, type: DialogTemplates, decorators: [{
|
|
25
|
+
type: Component,
|
|
26
|
+
args: [{
|
|
27
|
+
template: '',
|
|
28
|
+
}]
|
|
29
|
+
}] });
|
|
30
|
+
|
|
31
|
+
class Dialog extends DialogTemplates {
|
|
32
|
+
headerId = generateElementId();
|
|
33
|
+
_dialogElement = viewChild.required('dialog');
|
|
34
|
+
lazyContent = contentChild('lazy');
|
|
35
|
+
open = input(true);
|
|
36
|
+
cache = input(false);
|
|
37
|
+
modal = input(false);
|
|
38
|
+
autofocus = input(this.modal());
|
|
39
|
+
title = input(null);
|
|
40
|
+
closeOnEscape = input(true);
|
|
41
|
+
closed = output();
|
|
42
|
+
constructor() {
|
|
43
|
+
super();
|
|
44
|
+
afterRenderEffect(() => {
|
|
45
|
+
if (this.open()) {
|
|
46
|
+
if (untracked(this.modal)) {
|
|
47
|
+
this._dialogElement().nativeElement.showModal();
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
this._dialogElement().nativeElement.show();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
this._dialogElement().nativeElement.close();
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
onCancel() {
|
|
59
|
+
this.closed.emit();
|
|
60
|
+
}
|
|
61
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.5", ngImport: i0, type: Dialog, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
62
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.0.5", type: Dialog, isStandalone: true, selector: "ngn-dialog", inputs: { open: { classPropertyName: "open", publicName: "open", isSignal: true, isRequired: false, transformFunction: null }, cache: { classPropertyName: "cache", publicName: "cache", isSignal: true, isRequired: false, transformFunction: null }, modal: { classPropertyName: "modal", publicName: "modal", isSignal: true, isRequired: false, transformFunction: null }, autofocus: { classPropertyName: "autofocus", publicName: "autofocus", isSignal: true, isRequired: false, transformFunction: null }, title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null }, closeOnEscape: { classPropertyName: "closeOnEscape", publicName: "closeOnEscape", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { closed: "closed" }, queries: [{ propertyName: "lazyContent", first: true, predicate: ["lazy"], descendants: true, isSignal: true }], viewQueries: [{ propertyName: "_dialogElement", first: true, predicate: ["dialog"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "<!-- eslint-disable @angular-eslint/template/no-autofocus -->\n<dialog\n #dialog\n [attr.closedby]=\"closeOnEscape() ? 'closerequest' : 'none'\"\n [autofocus]=\"autofocus()\"\n [attr.aria-labelledby]=\"headerId\"\n (cancel)=\"onCancel()\"\n>\n <header>\n <ng-template\n [ngTemplateOutlet]=\"headerTemplate()\"\n [ngTemplateOutletContext]=\"{ headerId, title: title() }\"\n ></ng-template>\n </header>\n\n <ngn-lazy-cacher [lazyContent]=\"lazyContent()\" [open]=\"open()\" [cache]=\"cache()\">\n <ng-content />\n </ngn-lazy-cacher>\n\n <footer>\n <ng-template [ngTemplateOutlet]=\"footerTemplate()\"></ng-template>\n </footer>\n</dialog>\n\n<ng-template\n #defaultHeaderTemplate\n [ngnTemplate]=\"templateTypes.header\"\n let-headerId=\"headerId\"\n let-title=\"title\"\n>\n @if (title) {\n <h2 [id]=\"headerId\">{{ title }}</h2>\n }\n</ng-template>\n\n<ng-template #defaultFooterTemplate></ng-template>\n", dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: NgnTemplate, selector: "ng-template[ngnTemplate]", inputs: ["ngnTemplate"] }, { kind: "component", type: LazyCacher, selector: "ngn-lazy-cacher", inputs: ["lazyContent", "open", "cache"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
63
|
+
}
|
|
64
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.5", ngImport: i0, type: Dialog, decorators: [{
|
|
65
|
+
type: Component,
|
|
66
|
+
args: [{ selector: 'ngn-dialog', imports: [NgTemplateOutlet, NgnTemplate, LazyCacher], changeDetection: ChangeDetectionStrategy.OnPush, template: "<!-- eslint-disable @angular-eslint/template/no-autofocus -->\n<dialog\n #dialog\n [attr.closedby]=\"closeOnEscape() ? 'closerequest' : 'none'\"\n [autofocus]=\"autofocus()\"\n [attr.aria-labelledby]=\"headerId\"\n (cancel)=\"onCancel()\"\n>\n <header>\n <ng-template\n [ngTemplateOutlet]=\"headerTemplate()\"\n [ngTemplateOutletContext]=\"{ headerId, title: title() }\"\n ></ng-template>\n </header>\n\n <ngn-lazy-cacher [lazyContent]=\"lazyContent()\" [open]=\"open()\" [cache]=\"cache()\">\n <ng-content />\n </ngn-lazy-cacher>\n\n <footer>\n <ng-template [ngTemplateOutlet]=\"footerTemplate()\"></ng-template>\n </footer>\n</dialog>\n\n<ng-template\n #defaultHeaderTemplate\n [ngnTemplate]=\"templateTypes.header\"\n let-headerId=\"headerId\"\n let-title=\"title\"\n>\n @if (title) {\n <h2 [id]=\"headerId\">{{ title }}</h2>\n }\n</ng-template>\n\n<ng-template #defaultFooterTemplate></ng-template>\n" }]
|
|
67
|
+
}], ctorParameters: () => [] });
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Generated bundle index. Do not edit.
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
export { Dialog };
|
|
74
|
+
//# sourceMappingURL=ngneers-controls-dialog.mjs.map
|