@agnos-ui/angular-headless 0.0.1-alpha.4 → 0.0.1-alpha.6
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/components/accordion/accordion.d.ts +11 -0
- package/components/alert/alert.d.ts +7 -0
- package/components/modal/modal.d.ts +7 -0
- package/components/pagination/pagination.d.ts +8 -0
- package/components/progressbar/progressbar.d.ts +7 -0
- package/components/rating/rating.d.ts +6 -0
- package/components/select/select.d.ts +8 -0
- package/components/slider/slider.d.ts +1 -0
- package/config.d.ts +36 -0
- package/esm2022/agnos-ui-angular-headless.mjs +2 -2
- package/esm2022/components/accordion/accordion.mjs +4 -0
- package/esm2022/components/alert/alert.mjs +4 -0
- package/esm2022/components/modal/modal.mjs +4 -0
- package/esm2022/components/pagination/pagination.mjs +4 -0
- package/esm2022/components/progressbar/progressbar.mjs +4 -0
- package/esm2022/components/rating/rating.mjs +4 -0
- package/esm2022/components/select/select.mjs +4 -0
- package/esm2022/components/slider/slider.mjs +2 -0
- package/esm2022/config.mjs +104 -0
- package/esm2022/generated/config.mjs +2 -0
- package/esm2022/generated/index.mjs +23 -0
- package/esm2022/generated/services/extendWidget.mjs +2 -0
- package/esm2022/generated/services/floatingUI.mjs +2 -0
- package/esm2022/generated/services/focustrack.mjs +2 -0
- package/esm2022/generated/services/intersection.mjs +2 -0
- package/esm2022/generated/services/navManager.mjs +2 -0
- package/esm2022/generated/services/portal.mjs +2 -0
- package/esm2022/generated/services/siblingsInert.mjs +2 -0
- package/esm2022/generated/services/transitions/baseTransitions.mjs +2 -0
- package/esm2022/generated/services/transitions/bootstrap.mjs +2 -0
- package/esm2022/generated/services/transitions/collapse.mjs +2 -0
- package/esm2022/generated/services/transitions/cssTransitions.mjs +2 -0
- package/esm2022/generated/services/transitions/simpleClassTransition.mjs +2 -0
- package/esm2022/generated/slot.directive.mjs +2 -0
- package/esm2022/generated/slotDefault.directive.mjs +2 -0
- package/esm2022/generated/types.mjs +2 -0
- package/esm2022/generated/utils/coercion.mjs +2 -0
- package/esm2022/generated/utils/directive.mjs +2 -0
- package/esm2022/generated/utils/stores.mjs +2 -0
- package/esm2022/generated/utils/widget.mjs +2 -0
- package/esm2022/generated/utils/writables.mjs +2 -0
- package/esm2022/generated/utils/zone.mjs +2 -0
- package/esm2022/index.mjs +13 -0
- package/esm2022/slot.directive.mjs +199 -0
- package/esm2022/slotDefault.directive.mjs +20 -0
- package/esm2022/types.mjs +21 -0
- package/esm2022/utils/coercion.mjs +34 -0
- package/esm2022/utils/directive.mjs +63 -0
- package/esm2022/utils/stores.mjs +14 -0
- package/esm2022/utils/widget.mjs +114 -0
- package/esm2022/utils/zone.mjs +67 -0
- package/fesm2022/agnos-ui-angular-headless.mjs +300 -154
- package/fesm2022/agnos-ui-angular-headless.mjs.map +1 -1
- package/generated/config.d.ts +1 -0
- package/generated/index.d.ts +22 -0
- package/generated/services/extendWidget.d.ts +1 -0
- package/generated/services/floatingUI.d.ts +1 -0
- package/generated/services/focustrack.d.ts +1 -0
- package/generated/services/intersection.d.ts +1 -0
- package/generated/services/navManager.d.ts +1 -0
- package/generated/services/portal.d.ts +1 -0
- package/generated/services/siblingsInert.d.ts +1 -0
- package/generated/services/transitions/baseTransitions.d.ts +1 -0
- package/generated/services/transitions/bootstrap.d.ts +1 -0
- package/generated/services/transitions/collapse.d.ts +1 -0
- package/generated/services/transitions/cssTransitions.d.ts +1 -0
- package/generated/services/transitions/simpleClassTransition.d.ts +1 -0
- package/generated/slot.directive.d.ts +1 -0
- package/generated/slotDefault.directive.d.ts +1 -0
- package/generated/types.d.ts +1 -0
- package/generated/utils/coercion.d.ts +1 -0
- package/generated/utils/directive.d.ts +1 -0
- package/generated/utils/stores.d.ts +1 -0
- package/generated/utils/widget.d.ts +1 -0
- package/generated/utils/writables.d.ts +1 -0
- package/generated/utils/zone.d.ts +1 -0
- package/index.d.ts +9 -5
- package/package.json +15 -14
- package/{lib/slot.directive.d.ts → slot.directive.d.ts} +1 -1
- package/{lib/slotDefault.directive.d.ts → slotDefault.directive.d.ts} +1 -1
- package/{lib/slotTypes.d.ts → types.d.ts} +19 -2
- package/utils/coercion.d.ts +22 -0
- package/{lib/use.directive.d.ts → utils/directive.d.ts} +2 -1
- package/utils/stores.d.ts +4 -0
- package/utils/widget.d.ts +27 -0
- package/utils/zone.d.ts +16 -0
- package/esm2022/lib/config.mjs +0 -102
- package/esm2022/lib/slot.directive.mjs +0 -199
- package/esm2022/lib/slotDefault.directive.mjs +0 -20
- package/esm2022/lib/slotTypes.mjs +0 -7
- package/esm2022/lib/use.directive.mjs +0 -62
- package/esm2022/lib/utils.mjs +0 -127
- package/esm2022/public-api.mjs +0 -19
- package/lib/config.d.ts +0 -50
- package/lib/utils.d.ts +0 -17
- package/public-api.d.ts +0 -52
|
@@ -1,31 +1,57 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export * from '@agnos-ui/core';
|
|
3
|
-
import {
|
|
1
|
+
import { createAccordion as createAccordion$1 } from '@agnos-ui/core/components/accordion';
|
|
2
|
+
export * from '@agnos-ui/core/components/accordion';
|
|
3
|
+
import { createAlert as createAlert$1 } from '@agnos-ui/core/components/alert';
|
|
4
|
+
export * from '@agnos-ui/core/components/alert';
|
|
5
|
+
import { createModal as createModal$1 } from '@agnos-ui/core/components/modal';
|
|
6
|
+
export * from '@agnos-ui/core/components/modal';
|
|
7
|
+
import { createPagination as createPagination$1 } from '@agnos-ui/core/components/pagination';
|
|
8
|
+
export * from '@agnos-ui/core/components/pagination';
|
|
9
|
+
import { createProgressbar as createProgressbar$1 } from '@agnos-ui/core/components/progressbar';
|
|
10
|
+
export * from '@agnos-ui/core/components/progressbar';
|
|
11
|
+
import { createRating as createRating$1 } from '@agnos-ui/core/components/rating';
|
|
12
|
+
export * from '@agnos-ui/core/components/rating';
|
|
13
|
+
import { createSelect as createSelect$1 } from '@agnos-ui/core/components/select';
|
|
14
|
+
export * from '@agnos-ui/core/components/select';
|
|
15
|
+
export * from '@agnos-ui/core/components/slider';
|
|
16
|
+
export * from '@agnos-ui/core/services/siblingsInert';
|
|
17
|
+
export * from '@agnos-ui/core/services/portal';
|
|
18
|
+
export * from '@agnos-ui/core/services/navManager';
|
|
19
|
+
export * from '@agnos-ui/core/services/intersection';
|
|
20
|
+
export * from '@agnos-ui/core/services/focustrack';
|
|
21
|
+
export * from '@agnos-ui/core/services/floatingUI';
|
|
22
|
+
export * from '@agnos-ui/core/services/extendWidget';
|
|
23
|
+
export * from '@agnos-ui/core/services/transitions/simpleClassTransition';
|
|
24
|
+
export * from '@agnos-ui/core/services/transitions/cssTransitions';
|
|
25
|
+
export * from '@agnos-ui/core/services/transitions/collapse';
|
|
26
|
+
export * from '@agnos-ui/core/services/transitions/bootstrap';
|
|
27
|
+
export * from '@agnos-ui/core/services/transitions/baseTransitions';
|
|
28
|
+
export * from '@agnos-ui/core/utils/writables';
|
|
4
29
|
import * as i0 from '@angular/core';
|
|
5
|
-
import {
|
|
30
|
+
import { NgZone, inject, Injectable, signal, DestroyRef, ElementRef, Directive, Input, Injector, runInInjectionContext, SkipSelf, Optional, InjectionToken, booleanAttribute, numberAttribute, TemplateRef, EnvironmentInjector, createComponent, reflectComponentType, ViewContainerRef } from '@angular/core';
|
|
31
|
+
import { toReadableStore } from '@agnos-ui/core/utils/stores';
|
|
32
|
+
export * from '@agnos-ui/core/utils/stores';
|
|
33
|
+
export * from '@agnos-ui/core/utils/directive';
|
|
34
|
+
import { toSlotContextWidget } from '@agnos-ui/core/types';
|
|
35
|
+
export * from '@agnos-ui/core/types';
|
|
36
|
+
import { createWidgetsConfig } from '@agnos-ui/core/config';
|
|
37
|
+
export * from '@agnos-ui/core/config';
|
|
38
|
+
import { writable, computed } from '@amadeus-it-group/tansu';
|
|
6
39
|
import { DOCUMENT } from '@angular/common';
|
|
7
40
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
if (hasChange) {
|
|
24
|
-
lastValue = newValue;
|
|
25
|
-
set(newValue);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
};
|
|
41
|
+
const createAccordion = createAccordion$1;
|
|
42
|
+
|
|
43
|
+
const createAlert = createAlert$1;
|
|
44
|
+
|
|
45
|
+
const createModal = createModal$1;
|
|
46
|
+
|
|
47
|
+
const createPagination = createPagination$1;
|
|
48
|
+
|
|
49
|
+
const createProgressbar = createProgressbar$1;
|
|
50
|
+
|
|
51
|
+
const createRating = createRating$1;
|
|
52
|
+
|
|
53
|
+
const createSelect = createSelect$1;
|
|
54
|
+
|
|
29
55
|
const noop = () => { };
|
|
30
56
|
const identity = (a) => a;
|
|
31
57
|
const createObjectWrapper = (wrap) => (object) => {
|
|
@@ -51,7 +77,7 @@ class ZoneWrapper {
|
|
|
51
77
|
this.#runNeeded = true;
|
|
52
78
|
if (!this.#runPlanned) {
|
|
53
79
|
this.#runPlanned = true;
|
|
54
|
-
(async () => {
|
|
80
|
+
void (async () => {
|
|
55
81
|
await 0;
|
|
56
82
|
this.#runPlanned = false;
|
|
57
83
|
if (this.#runNeeded) {
|
|
@@ -81,15 +107,16 @@ class ZoneWrapper {
|
|
|
81
107
|
this.#runNeeded = false;
|
|
82
108
|
return this.#zone.run(fn);
|
|
83
109
|
}
|
|
84
|
-
static { this.ɵfac =
|
|
85
|
-
static { this.ɵprov = i0.ɵɵ
|
|
110
|
+
static { this.ɵfac = function ZoneWrapper_Factory(t) { return new (t || ZoneWrapper)(); }; }
|
|
111
|
+
static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ZoneWrapper, factory: ZoneWrapper.ɵfac, providedIn: 'root' }); }
|
|
86
112
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
113
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ZoneWrapper, [{
|
|
114
|
+
type: Injectable,
|
|
115
|
+
args: [{
|
|
116
|
+
providedIn: 'root',
|
|
117
|
+
}]
|
|
118
|
+
}], null, null); })();
|
|
119
|
+
|
|
93
120
|
const toAngularSignal = (tansuSignal) => {
|
|
94
121
|
const zoneWrapper = inject(ZoneWrapper);
|
|
95
122
|
const res = signal(undefined);
|
|
@@ -100,23 +127,147 @@ const toAngularSignal = (tansuSignal) => {
|
|
|
100
127
|
inject(DestroyRef).onDestroy(zoneWrapper.outsideNgZone(subscription));
|
|
101
128
|
return res;
|
|
102
129
|
};
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
130
|
+
|
|
131
|
+
// All calls of the directive in this class are done asynchronously (with await 0)
|
|
132
|
+
// in order to avoid ExpressionChangedAfterItHasBeenCheckedError
|
|
133
|
+
// or the corresponding issue with signals (https://github.com/angular/angular/issues/50320)
|
|
134
|
+
// This is relevant especially if calling the directive changes variables used in a template.
|
|
135
|
+
const useDirectiveForHost = (use, params) => {
|
|
136
|
+
const ref = inject(ElementRef);
|
|
137
|
+
let instance = use?.(ref.nativeElement, params);
|
|
138
|
+
async function destroyDirectiveInstance() {
|
|
139
|
+
const oldInstance = instance;
|
|
140
|
+
instance = undefined;
|
|
141
|
+
use = undefined;
|
|
142
|
+
if (oldInstance?.destroy) {
|
|
143
|
+
await 0;
|
|
144
|
+
oldInstance.destroy?.();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
inject(DestroyRef).onDestroy(destroyDirectiveInstance);
|
|
148
|
+
async function update(newUse, newParams) {
|
|
149
|
+
if (newUse !== use) {
|
|
150
|
+
void destroyDirectiveInstance();
|
|
151
|
+
use = newUse;
|
|
152
|
+
params = newParams;
|
|
153
|
+
if (newUse) {
|
|
154
|
+
await 0;
|
|
155
|
+
// checks that the directive did not change while waiting:
|
|
156
|
+
if (use === newUse && !instance) {
|
|
157
|
+
instance = use(ref.nativeElement, params);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
else if (newParams != params) {
|
|
162
|
+
params = newParams;
|
|
163
|
+
await 0;
|
|
164
|
+
instance?.update?.(params);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return { update };
|
|
168
|
+
};
|
|
169
|
+
class UseDirective {
|
|
170
|
+
#useDirective = useDirectiveForHost();
|
|
171
|
+
ngOnChanges() {
|
|
172
|
+
void this.#useDirective.update(this.use, this.params);
|
|
173
|
+
}
|
|
174
|
+
static { this.ɵfac = function UseDirective_Factory(t) { return new (t || UseDirective)(); }; }
|
|
175
|
+
static { this.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: UseDirective, selectors: [["", "auUse", ""]], inputs: { use: ["auUse", "use"], params: ["auUseParams", "params"] }, standalone: true, features: [i0.ɵɵNgOnChangesFeature] }); }
|
|
176
|
+
}
|
|
177
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(UseDirective, [{
|
|
178
|
+
type: Directive,
|
|
179
|
+
args: [{
|
|
180
|
+
standalone: true,
|
|
181
|
+
selector: '[auUse]',
|
|
182
|
+
}]
|
|
183
|
+
}], null, { use: [{
|
|
184
|
+
type: Input,
|
|
185
|
+
args: ['auUse']
|
|
186
|
+
}], params: [{
|
|
187
|
+
type: Input,
|
|
188
|
+
args: ['auUseParams']
|
|
189
|
+
}] }); })();
|
|
190
|
+
|
|
191
|
+
class ComponentTemplate {
|
|
192
|
+
constructor(component, templateProp) {
|
|
193
|
+
this.component = component;
|
|
194
|
+
this.templateProp = templateProp;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
class SlotComponent {
|
|
198
|
+
static { this.ɵfac = function SlotComponent_Factory(t) { return new (t || SlotComponent)(); }; }
|
|
199
|
+
static { this.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: SlotComponent, inputs: { state: "state", widget: "widget" } }); }
|
|
200
|
+
}
|
|
201
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SlotComponent, [{
|
|
202
|
+
type: Directive
|
|
203
|
+
}], null, { state: [{
|
|
204
|
+
type: Input
|
|
205
|
+
}], widget: [{
|
|
206
|
+
type: Input
|
|
207
|
+
}] }); })();
|
|
208
|
+
|
|
209
|
+
const createPatchSlots = (set) => {
|
|
210
|
+
let lastValue = {};
|
|
211
|
+
return (object) => {
|
|
212
|
+
const newValue = {};
|
|
213
|
+
let hasChange = false;
|
|
214
|
+
for (const key of Object.keys(object)) {
|
|
215
|
+
const objectKey = object[key];
|
|
216
|
+
if (objectKey != null) {
|
|
217
|
+
// only use defined slots
|
|
218
|
+
newValue[key] = objectKey;
|
|
219
|
+
}
|
|
220
|
+
if (objectKey != lastValue[key]) {
|
|
221
|
+
hasChange = true;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
if (hasChange) {
|
|
225
|
+
lastValue = newValue;
|
|
226
|
+
set(newValue);
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
};
|
|
230
|
+
const callWidgetFactoryWithConfig = ({ factory, defaultConfig, widgetConfig, events, afterInit, }) => {
|
|
231
|
+
const injector = inject(Injector);
|
|
107
232
|
const slots$ = writable({});
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
patch: zoneWrapper.outsideNgZone(widget.patch),
|
|
115
|
-
directives: zoneWrapper.outsideNgZoneWrapDirectivesObject(widget.directives),
|
|
116
|
-
actions: zoneWrapper.outsideNgZoneWrapFunctionsObject(widget.actions),
|
|
117
|
-
api: zoneWrapper.outsideNgZoneWrapFunctionsObject(widget.api),
|
|
233
|
+
const props = {};
|
|
234
|
+
let initDone;
|
|
235
|
+
const res = {
|
|
236
|
+
initialized: new Promise((resolve) => {
|
|
237
|
+
initDone = resolve;
|
|
238
|
+
}),
|
|
118
239
|
patchSlots: createPatchSlots(slots$.set),
|
|
240
|
+
patch(newProps) {
|
|
241
|
+
// temporary function replaced in ngInit
|
|
242
|
+
Object.assign(props, newProps);
|
|
243
|
+
},
|
|
244
|
+
ngInit() {
|
|
245
|
+
runInInjectionContext(injector, () => {
|
|
246
|
+
const zoneWrapper = inject(ZoneWrapper);
|
|
247
|
+
factory = zoneWrapper.outsideNgZone(factory);
|
|
248
|
+
const defaultConfig$ = toReadableStore(defaultConfig);
|
|
249
|
+
events = zoneWrapper.insideNgZoneWrapFunctionsObject(events);
|
|
250
|
+
const widget = factory({
|
|
251
|
+
config: computed(() => ({ ...defaultConfig$(), ...widgetConfig?.(), ...slots$(), ...events })),
|
|
252
|
+
props,
|
|
253
|
+
});
|
|
254
|
+
const wrappedWidget = {
|
|
255
|
+
...widget,
|
|
256
|
+
patch: zoneWrapper.outsideNgZone(widget.patch),
|
|
257
|
+
directives: zoneWrapper.outsideNgZoneWrapDirectivesObject(widget.directives),
|
|
258
|
+
actions: zoneWrapper.outsideNgZoneWrapFunctionsObject(widget.actions),
|
|
259
|
+
api: zoneWrapper.outsideNgZoneWrapFunctionsObject(widget.api),
|
|
260
|
+
};
|
|
261
|
+
Object.assign(res, wrappedWidget, {
|
|
262
|
+
widget: toSlotContextWidget(wrappedWidget),
|
|
263
|
+
ngState: toAngularSignal(wrappedWidget.state$),
|
|
264
|
+
});
|
|
265
|
+
afterInit?.();
|
|
266
|
+
initDone();
|
|
267
|
+
});
|
|
268
|
+
},
|
|
119
269
|
};
|
|
270
|
+
return res;
|
|
120
271
|
};
|
|
121
272
|
function patchSimpleChanges(patchFn, changes) {
|
|
122
273
|
const obj = {};
|
|
@@ -127,6 +278,41 @@ function patchSimpleChanges(patchFn, changes) {
|
|
|
127
278
|
}
|
|
128
279
|
patchFn(obj);
|
|
129
280
|
}
|
|
281
|
+
/**
|
|
282
|
+
* Stores the result of the first call to the getter and returns that result directly for subsequent calls
|
|
283
|
+
*
|
|
284
|
+
* Applies to: class getters
|
|
285
|
+
*/
|
|
286
|
+
const CachedProperty = (target, property, descriptor) => {
|
|
287
|
+
const originalGet = descriptor.get;
|
|
288
|
+
descriptor.get = function () {
|
|
289
|
+
const value = originalGet?.call(this);
|
|
290
|
+
Object.defineProperty(this, property, { value, writable: false });
|
|
291
|
+
return value;
|
|
292
|
+
};
|
|
293
|
+
};
|
|
294
|
+
class BaseWidgetDirective {
|
|
295
|
+
get api() {
|
|
296
|
+
return this._widget.api;
|
|
297
|
+
}
|
|
298
|
+
get state() {
|
|
299
|
+
return this._widget.ngState;
|
|
300
|
+
}
|
|
301
|
+
get widget() {
|
|
302
|
+
return this._widget.widget;
|
|
303
|
+
}
|
|
304
|
+
ngOnChanges(changes) {
|
|
305
|
+
patchSimpleChanges(this._widget.patch, changes);
|
|
306
|
+
}
|
|
307
|
+
ngOnInit() {
|
|
308
|
+
this._widget.ngInit();
|
|
309
|
+
}
|
|
310
|
+
static { this.ɵfac = function BaseWidgetDirective_Factory(t) { return new (t || BaseWidgetDirective)(); }; }
|
|
311
|
+
static { this.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: BaseWidgetDirective, features: [i0.ɵɵNgOnChangesFeature] }); }
|
|
312
|
+
}
|
|
313
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseWidgetDirective, [{
|
|
314
|
+
type: Directive
|
|
315
|
+
}], null, null); })();
|
|
130
316
|
|
|
131
317
|
const widgetsConfigFactory = (widgetsConfigInjectionToken = new InjectionToken('widgetsConfig')) => {
|
|
132
318
|
/**
|
|
@@ -207,11 +393,12 @@ const widgetsConfigFactory = (widgetsConfigInjectionToken = new InjectionToken('
|
|
|
207
393
|
const widgetsConfig = inject(widgetsConfigInjectionToken, { optional: true });
|
|
208
394
|
return computed(() => widgetsConfig?.()[widgetName]);
|
|
209
395
|
};
|
|
210
|
-
const callWidgetFactory = ({ factory, widgetName = null, defaultConfig = {}, events, }) => callWidgetFactoryWithConfig({
|
|
396
|
+
const callWidgetFactory = ({ factory, widgetName = null, defaultConfig = {}, events, afterInit, }) => callWidgetFactoryWithConfig({
|
|
211
397
|
factory,
|
|
212
398
|
widgetConfig: widgetName ? injectWidgetConfig(widgetName) : null,
|
|
213
399
|
defaultConfig,
|
|
214
400
|
events,
|
|
401
|
+
afterInit,
|
|
215
402
|
});
|
|
216
403
|
return {
|
|
217
404
|
/**
|
|
@@ -226,12 +413,56 @@ const widgetsConfigFactory = (widgetsConfigInjectionToken = new InjectionToken('
|
|
|
226
413
|
};
|
|
227
414
|
const { widgetsConfigInjectionToken, provideWidgetsConfig, injectWidgetConfig, injectWidgetsConfig, callWidgetFactory } = widgetsConfigFactory();
|
|
228
415
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
416
|
+
/**
|
|
417
|
+
* Transforms a value (typically a string) to a boolean.
|
|
418
|
+
* Intended to be used as a transform function of an input.
|
|
419
|
+
*
|
|
420
|
+
* @usageNotes
|
|
421
|
+
* ```typescript
|
|
422
|
+
* @Input({ transform: auBooleanAttribute }) status: boolean | undefined;
|
|
423
|
+
* ```
|
|
424
|
+
* @param value Value to be transformed.
|
|
425
|
+
*/
|
|
426
|
+
function auBooleanAttribute(value) {
|
|
427
|
+
if (value === undefined) {
|
|
428
|
+
return undefined;
|
|
429
|
+
}
|
|
430
|
+
return booleanAttribute(value);
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Transforms a value (typically a string) to a number.
|
|
434
|
+
* Intended to be used as a transform function of an input.
|
|
435
|
+
* @param value Value to be transformed.
|
|
436
|
+
*
|
|
437
|
+
* @usageNotes
|
|
438
|
+
* ```typescript
|
|
439
|
+
* @Input({ transform: auNumberAttribute }) id: number | undefined;
|
|
440
|
+
* ```
|
|
441
|
+
*/
|
|
442
|
+
function auNumberAttribute(value) {
|
|
443
|
+
if (value === undefined) {
|
|
444
|
+
return undefined;
|
|
445
|
+
}
|
|
446
|
+
return numberAttribute(value);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
class SlotDefaultDirective {
|
|
450
|
+
constructor() {
|
|
451
|
+
this.templateRef = inject((TemplateRef));
|
|
233
452
|
}
|
|
453
|
+
ngOnInit() {
|
|
454
|
+
this.auSlotDefault.update((value) => ({ ...value, slotDefault: this.templateRef }));
|
|
455
|
+
}
|
|
456
|
+
static { this.ɵfac = function SlotDefaultDirective_Factory(t) { return new (t || SlotDefaultDirective)(); }; }
|
|
457
|
+
static { this.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: SlotDefaultDirective, selectors: [["", "auSlotDefault", ""]], inputs: { auSlotDefault: "auSlotDefault" }, standalone: true }); }
|
|
234
458
|
}
|
|
459
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SlotDefaultDirective, [{
|
|
460
|
+
type: Directive,
|
|
461
|
+
args: [{ selector: '[auSlotDefault]', standalone: true }]
|
|
462
|
+
}], null, { auSlotDefault: [{
|
|
463
|
+
type: Input,
|
|
464
|
+
args: ['auSlotDefault']
|
|
465
|
+
}] }); })();
|
|
235
466
|
|
|
236
467
|
class SlotHandler {
|
|
237
468
|
constructor(viewContainerRef, document) {
|
|
@@ -411,115 +642,30 @@ class SlotDirective {
|
|
|
411
642
|
this._slotHandler?.destroy();
|
|
412
643
|
this._slotHandler = undefined;
|
|
413
644
|
}
|
|
414
|
-
static { this.ɵfac =
|
|
415
|
-
static { this.ɵdir = i0.ɵɵ
|
|
416
|
-
}
|
|
417
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SlotDirective, decorators: [{
|
|
418
|
-
type: Directive,
|
|
419
|
-
args: [{
|
|
420
|
-
selector: '[auSlot]',
|
|
421
|
-
standalone: true,
|
|
422
|
-
}]
|
|
423
|
-
}], propDecorators: { slot: [{
|
|
424
|
-
type: Input,
|
|
425
|
-
args: ['auSlot']
|
|
426
|
-
}], props: [{
|
|
427
|
-
type: Input,
|
|
428
|
-
args: ['auSlotProps']
|
|
429
|
-
}] } });
|
|
430
|
-
|
|
431
|
-
class SlotDefaultDirective {
|
|
432
|
-
constructor() {
|
|
433
|
-
this.templateRef = inject((TemplateRef));
|
|
434
|
-
}
|
|
435
|
-
ngOnInit() {
|
|
436
|
-
this.auSlotDefault.update((value) => ({ ...value, slotDefault: this.templateRef }));
|
|
437
|
-
}
|
|
438
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SlotDefaultDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
439
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: SlotDefaultDirective, isStandalone: true, selector: "[auSlotDefault]", inputs: { auSlotDefault: "auSlotDefault" }, ngImport: i0 }); }
|
|
440
|
-
}
|
|
441
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SlotDefaultDirective, decorators: [{
|
|
442
|
-
type: Directive,
|
|
443
|
-
args: [{ selector: '[auSlotDefault]', standalone: true }]
|
|
444
|
-
}], propDecorators: { auSlotDefault: [{
|
|
445
|
-
type: Input,
|
|
446
|
-
args: ['auSlotDefault']
|
|
447
|
-
}] } });
|
|
448
|
-
|
|
449
|
-
// All calls of the directive in this class are done asynchronously (with await 0)
|
|
450
|
-
// in order to avoid ExpressionChangedAfterItHasBeenCheckedError
|
|
451
|
-
// or the corresponding issue with signals (https://github.com/angular/angular/issues/50320)
|
|
452
|
-
// This is relevant especially if calling the directive changes variables used in a template.
|
|
453
|
-
const useDirectiveForHost = (use, params) => {
|
|
454
|
-
const ref = inject(ElementRef);
|
|
455
|
-
let instance = use?.(ref.nativeElement, params);
|
|
456
|
-
async function destroyDirectiveInstance() {
|
|
457
|
-
const oldInstance = instance;
|
|
458
|
-
instance = undefined;
|
|
459
|
-
use = undefined;
|
|
460
|
-
if (oldInstance?.destroy) {
|
|
461
|
-
await 0;
|
|
462
|
-
oldInstance.destroy?.();
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
inject(DestroyRef).onDestroy(destroyDirectiveInstance);
|
|
466
|
-
async function update(newUse, newParams) {
|
|
467
|
-
if (newUse !== use) {
|
|
468
|
-
destroyDirectiveInstance();
|
|
469
|
-
use = newUse;
|
|
470
|
-
params = newParams;
|
|
471
|
-
if (newUse) {
|
|
472
|
-
await 0;
|
|
473
|
-
// checks that the directive did not change while waiting:
|
|
474
|
-
if (use === newUse && !instance) {
|
|
475
|
-
instance = use(ref.nativeElement, params);
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
else if (newParams != params) {
|
|
480
|
-
params = newParams;
|
|
481
|
-
await 0;
|
|
482
|
-
instance?.update?.(params);
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
return { update };
|
|
486
|
-
};
|
|
487
|
-
class UseDirective {
|
|
488
|
-
#useDirective = useDirectiveForHost();
|
|
489
|
-
ngOnChanges() {
|
|
490
|
-
this.#useDirective.update(this.use, this.params);
|
|
491
|
-
}
|
|
492
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: UseDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
493
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: UseDirective, isStandalone: true, selector: "[auUse]", inputs: { use: ["auUse", "use"], params: ["auUseParams", "params"] }, usesOnChanges: true, ngImport: i0 }); }
|
|
645
|
+
static { this.ɵfac = function SlotDirective_Factory(t) { return new (t || SlotDirective)(); }; }
|
|
646
|
+
static { this.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: SlotDirective, selectors: [["", "auSlot", ""]], inputs: { slot: ["auSlot", "slot"], props: ["auSlotProps", "props"] }, standalone: true, features: [i0.ɵɵNgOnChangesFeature] }); }
|
|
494
647
|
}
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
648
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SlotDirective, [{
|
|
649
|
+
type: Directive,
|
|
650
|
+
args: [{
|
|
651
|
+
selector: '[auSlot]',
|
|
652
|
+
standalone: true,
|
|
653
|
+
}]
|
|
654
|
+
}], null, { slot: [{
|
|
655
|
+
type: Input,
|
|
656
|
+
args: ['auSlot']
|
|
657
|
+
}], props: [{
|
|
658
|
+
type: Input,
|
|
659
|
+
args: ['auSlotProps']
|
|
660
|
+
}] }); })();
|
|
508
661
|
|
|
509
662
|
/*
|
|
510
663
|
* Public API Surface of @agnos-ui/angular-headless
|
|
511
664
|
*/
|
|
512
|
-
const createAccordion = createAccordion$1;
|
|
513
|
-
const createAlert = createAlert$1;
|
|
514
|
-
const createModal = createModal$1;
|
|
515
|
-
const createPagination = createPagination$1;
|
|
516
|
-
const createRating = createRating$1;
|
|
517
|
-
const createSelect = createSelect$1;
|
|
518
|
-
const createProgressbar = createProgressbar$1;
|
|
519
665
|
|
|
520
666
|
/**
|
|
521
667
|
* Generated bundle index. Do not edit.
|
|
522
668
|
*/
|
|
523
669
|
|
|
524
|
-
export { ComponentTemplate, SlotDefaultDirective, SlotDirective, UseDirective, callWidgetFactory, callWidgetFactoryWithConfig, createAccordion, createAlert, createModal, createPagination, createProgressbar, createRating, createSelect, injectWidgetConfig, injectWidgetsConfig,
|
|
670
|
+
export { BaseWidgetDirective, CachedProperty, ComponentTemplate, SlotComponent, SlotDefaultDirective, SlotDirective, UseDirective, ZoneWrapper, auBooleanAttribute, auNumberAttribute, callWidgetFactory, callWidgetFactoryWithConfig, createAccordion, createAlert, createModal, createPagination, createProgressbar, createRating, createSelect, injectWidgetConfig, injectWidgetsConfig, provideWidgetsConfig, toAngularSignal, useDirectiveForHost, widgetsConfigFactory, widgetsConfigInjectionToken };
|
|
525
671
|
//# sourceMappingURL=agnos-ui-angular-headless.mjs.map
|