UNPKG

20.4 kBTypeScriptView Raw
1import { OverrideContext, bindingMode } from 'aurelia-binding';
2import { View, ViewFactory, ViewSlot } from 'aurelia-templating';
3
4declare enum ActivationStrategy {
5 /**
6 * Default activation strategy; the 'activate' lifecycle hook will be invoked when the model changes.
7 */
8 InvokeLifecycle = "invoke-lifecycle",
9 /**
10 * The view/view-model will be recreated, when the "model" changes.
11 */
12 Replace = "replace"
13}
14/**
15 * Used to compose a new view / view-model template or bind to an existing instance.
16 */
17export declare class Compose {
18 /**
19 * Model to bind the custom element to.
20 *
21 * @property model
22 * @type {CustomElement}
23 */
24 model: any;
25 /**
26 * View to bind the custom element to.
27 *
28 * @property view
29 * @type {HtmlElement}
30 */
31 view: any;
32 /**
33 * View-model to bind the custom element's template to.
34 *
35 * @property viewModel
36 * @type {Class}
37 */
38 viewModel: any;
39 /**
40 * Strategy to activate the view-model. Default is "invoke-lifecycle".
41 * Bind "replace" to recreate the view/view-model when the model changes.
42 *
43 * @property activationStrategy
44 * @type {ActivationStrategy}
45 */
46 activationStrategy: ActivationStrategy;
47 /**
48 * SwapOrder to control the swapping order of the custom element's view.
49 *
50 * @property view
51 * @type {String}
52 */
53 swapOrder: any;
54 /**
55 * Creates an instance of Compose.
56 * @param element The Compose element.
57 * @param container The dependency injection container instance.
58 * @param compositionEngine CompositionEngine instance to compose the element.
59 * @param viewSlot The slot the view is injected in to.
60 * @param viewResources Collection of resources used to compile the the view.
61 * @param taskQueue The TaskQueue instance.
62 */
63 constructor(element: any, container: any, compositionEngine: any, viewSlot: any, viewResources: any, taskQueue: any);
64 /**
65 * Invoked when the component has been created.
66 *
67 * @param owningView The view that this component was created inside of.
68 */
69 created(owningView: View): void;
70 /**
71 * Used to set the bindingContext.
72 *
73 * @param bindingContext The context in which the view model is executed in.
74 * @param overrideContext The context in which the view model is executed in.
75 */
76 bind(bindingContext: any, overrideContext: any): void;
77 /**
78 * Unbinds the Compose.
79 */
80 unbind(): void;
81 /**
82 * Invoked everytime the bound model changes.
83 * @param newValue The new value.
84 * @param oldValue The old value.
85 */
86 modelChanged(newValue: any, oldValue: any): void;
87 /**
88 * Invoked everytime the bound view changes.
89 * @param newValue The new value.
90 * @param oldValue The old value.
91 */
92 viewChanged(newValue: any, oldValue: any): void;
93 /**
94 * Invoked everytime the bound view model changes.
95 * @param newValue The new value.
96 * @param oldValue The old value.
97 */
98 viewModelChanged(newValue: any, oldValue: any): void;
99}
100declare class IfCore {
101 constructor(viewFactory: ViewFactory, viewSlot: ViewSlot);
102 bind(bindingContext: any, overrideContext: any): void;
103 unbind(): void;
104}
105/**
106 * Binding to conditionally include or not include template logic depending on returned result
107 * - value should be Boolean or will be treated as such (truthy / falsey)
108 */
109export declare class If extends IfCore {
110 condition: any;
111 swapOrder: 'before' | 'with' | 'after';
112 cache: boolean | string;
113 /**
114 * Binds the if to the binding context and override context
115 * @param bindingContext The binding context
116 * @param overrideContext An override context for binding.
117 */
118 bind(bindingContext: any, overrideContext: any): void;
119 /**
120 * Invoked everytime value property changes.
121 * @param newValue The new value
122 */
123 conditionChanged(newValue: any): void;
124}
125export declare class Else extends IfCore {
126 constructor(viewFactory: any, viewSlot: any);
127 bind(bindingContext: any, overrideContext: any): void;
128}
129/**
130 * Creates a binding context for decandant elements to bind to.
131 */
132export declare class With {
133 value: any;
134 /**
135 * Creates an instance of With.
136 * @param viewFactory The factory generating the view.
137 * @param viewSlot The slot the view is injected in to.
138 */
139 constructor(viewFactory: ViewFactory, viewSlot: ViewSlot);
140 /**
141 * Binds the With with provided binding context and override context.
142 * @param bindingContext The binding context.
143 * @param overrideContext An override context for binding.
144 */
145 bind(bindingContext: any, overrideContext: any): void;
146 /**
147 * Invoked everytime the bound value changes.
148 * @param newValue The new value.
149 */
150 valueChanged(newValue: any): void;
151 /**
152 * Unbinds With
153 */
154 unbind(): void;
155}
156/**
157* An abstract base class for elements and attributes that repeat
158* views.
159*/
160export declare class AbstractRepeater {
161 constructor(options: any);
162 /**
163 * Returns the number of views the repeater knows about.
164 *
165 * @return {Number} the number of views.
166 */
167 viewCount(): number;
168 /**
169 * Returns all of the repeaters views as an array.
170 *
171 * @return {Array} The repeater's array of views;
172 */
173 views(): any[];
174 /**
175 * Returns a single view from the repeater at the provided index.
176 *
177 * @param {Number} index The index of the requested view.
178 * @return {View|ViewSlot} The requested view.
179 */
180 view(index: any): any;
181 /**
182 * Returns the matcher function to be used by the repeater, or null if strict matching is to be performed.
183 *
184 * @return {Function|null} The requested matcher function.
185 */
186 matcher(): void;
187 /**
188 * Adds a view to the repeater, binding the view to the
189 * provided contexts.
190 *
191 * @param {Object} bindingContext The binding context to bind the new view to.
192 * @param {Object} overrideContext A secondary binding context that can override the primary context.
193 */
194 addView(bindingContext: any, overrideContext: any): void;
195 /**
196 * Inserts a view to the repeater at a specific index, binding the view to the
197 * provided contexts.
198 *
199 * @param {Number} index The index at which to create the new view at.
200 * @param {Object} bindingContext The binding context to bind the new view to.
201 * @param {Object} overrideContext A secondary binding context that can override the primary context.
202 */
203 insertView(index: any, bindingContext: any, overrideContext: any): void;
204 /**
205 * Moves a view across the repeater.
206 *
207 * @param {Number} sourceIndex The index of the view to be moved.
208 * @param {Number} sourceIndex The index where the view should be placed at.
209 */
210 moveView(sourceIndex: any, targetIndex: any): void;
211 /**
212 * Removes all views from the repeater.
213 * @param {Boolean} returnToCache Should the view be returned to the view cache?
214 * @param {Boolean} skipAnimation Should the removal animation be skipped?
215 * @return {Promise|null}
216 */
217 removeAllViews(returnToCache?: boolean, skipAnimation?: boolean): void;
218 /**
219 * Removes an array of Views from the repeater.
220 *
221 * @param {Array} viewsToRemove The array of views to be removed.
222 * @param {Boolean} returnToCache Should the view be returned to the view cache?
223 * @param {Boolean} skipAnimation Should the removal animation be skipped?
224 * @return {Promise|null}
225 */
226 removeViews(viewsToRemove: Array<View>, returnToCache?: boolean, skipAnimation?: boolean): void;
227 /**
228 * Removes a view from the repeater at a specific index.
229 *
230 * @param {Number} index The index of the view to be removed.
231 * @param {Boolean} returnToCache Should the view be returned to the view cache?
232 * @param {Boolean} skipAnimation Should the removal animation be skipped?
233 * @return {Promise|null}
234 */
235 removeView(index: number, returnToCache?: boolean, skipAnimation?: boolean): void;
236 /**
237 * Forces a particular view to update it's bindings, called as part of
238 * an in-place processing of items for better performance
239 *
240 * @param {Object} view the target view for bindings updates
241 */
242 updateBindings(view: View): void;
243}
244/**
245 * Binding to iterate over iterable objects (Array, Map and Number) to genereate a template for each iteration.
246 */
247export declare class Repeat extends AbstractRepeater {
248 /**
249 * Setting this to `true` to enable legacy behavior, where a repeat would take first `matcher` binding
250 * any where inside its view if there's no `matcher` binding on the repeated element itself.
251 *
252 * Default value is true to avoid breaking change
253 * @default true
254 */
255 static useInnerMatcher: boolean;
256 /**
257 * List of items to bind the repeater to.
258 *
259 * @property items
260 */
261 items: any;
262 /**
263 * Local variable which gets assigned on each iteration.
264 *
265 * @property local
266 */
267 local: any;
268 /**
269 * Key when iterating over Maps.
270 *
271 * @property key
272 */
273 key: any;
274 /**
275 * Value when iterating over Maps.
276 *
277 * @property value
278 */
279 value: any;
280 /**
281 * Creates an instance of Repeat.
282 * @param viewFactory The factory generating the view
283 * @param instruction The instructions for how the element should be enhanced.
284 * @param viewResources Collection of resources used to compile the the views.
285 * @param viewSlot The slot the view is injected in to.
286 * @param observerLocator The observer locator instance.
287 * @param collectionStrategyLocator The strategy locator to locate best strategy to iterate the collection.
288 */
289 constructor(viewFactory: any, instruction: any, viewSlot: any, viewResources: any, observerLocator: any, strategyLocator: any);
290 call(context: any, changes: any): void;
291 /**
292 * Binds the repeat to the binding context and override context.
293 * @param bindingContext The binding context.
294 * @param overrideContext An override context for binding.
295 */
296 bind(bindingContext: any, overrideContext: any): void;
297 /**
298 * Unbinds the repeat
299 */
300 unbind(): void;
301 /**
302 * Invoked everytime the item property changes.
303 */
304 itemsChanged(): void;
305 /**
306 * Invoked when the underlying collection changes.
307 */
308 handleCollectionMutated(collection: any, changes: any): void;
309 /**
310 * Invoked when the underlying inner collection changes.
311 */
312 handleInnerCollectionMutated(collection: any, changes: any): void;
313 viewCount(): any;
314 views(): any;
315 view(index: any): any;
316 matcher(): any;
317 addView(bindingContext: any, overrideContext: any): void;
318 insertView(index: any, bindingContext: any, overrideContext: any): void;
319 moveView(sourceIndex: any, targetIndex: any): void;
320 removeAllViews(returnToCache: any, skipAnimation: any): any;
321 removeViews(viewsToRemove: any, returnToCache: any, skipAnimation: any): any;
322 removeView(index: any, returnToCache: any, skipAnimation: any): any;
323 updateBindings(view: View): void;
324}
325/**
326 * Binding to conditionally show markup in the DOM based on the value.
327 * - different from "if" in that the markup is still added to the DOM, simply not shown.
328 */
329export declare class Show {
330 value: any;
331 /**
332 * Creates a new instance of Show.
333 * @param element Target element to conditionally show.
334 * @param animator The animator that conditionally adds or removes the aurelia-hide css class.
335 * @param domBoundary The DOM boundary. Used when the behavior appears within a component that utilizes the shadow DOM.
336 */
337 constructor(element: any, animator: any, domBoundary: any);
338 /**
339 * Invoked when the behavior is created.
340 */
341 created(): void;
342 /**
343 * Invoked everytime the bound value changes.
344 * @param newValue The new value.
345 */
346 valueChanged(newValue: any): void;
347 /**
348 * Binds the Show attribute.
349 */
350 bind(bindingContext: any): void;
351}
352/**
353 * Binding to conditionally show markup in the DOM based on the value.
354 * - different from "if" in that the markup is still added to the DOM, simply not shown.
355 */
356export declare class Hide {
357 /**
358 * Creates a new instance of Hide.
359 * @param element Target element to conditionally hide.
360 * @param animator The animator that conditionally adds or removes the aurelia-hide css class.
361 * @param domBoundary The DOM boundary. Used when the behavior appears within a component that utilizes the shadow DOM.
362 */
363 constructor(element: any, animator: any, domBoundary: any);
364 /**
365 * Invoked when the behavior is created.
366 */
367 created(): void;
368 /**
369 * Invoked everytime the bound value changes.
370 * @param newValue The new value.
371 */
372 valueChanged(newValue: any): void;
373 /**
374 * Binds the Hide attribute.
375 */
376 bind(bindingContext: any): void;
377 value(value: any): void;
378}
379/**
380 * Default Html Sanitizer to prevent script injection.
381 */
382export declare class HTMLSanitizer {
383 /**
384 * Sanitizes the provided input.
385 * @param input The input to be sanitized.
386 */
387 sanitize(input: any): any;
388}
389/**
390 * Simple html sanitization converter to preserve whitelisted elements and attributes on a bound property containing html.
391 */
392export declare class SanitizeHTMLValueConverter {
393 /**
394 * Creates an instanse of the value converter.
395 * @param sanitizer The html sanitizer.
396 */
397 constructor(sanitizer: HTMLSanitizer);
398 /**
399 * Process the provided markup that flows to the view.
400 * @param untrustedMarkup The untrusted markup to be sanitized.
401 */
402 toView(untrustedMarkup: any): any;
403}
404/**
405 * Marks any part of a view to be replacable by the consumer.
406 */
407export declare class Replaceable {
408 /**
409 * @param viewFactory target The factory generating the view.
410 * @param viewSlot viewSlot The slot the view is injected in to.
411 */
412 constructor(viewFactory: ViewFactory, viewSlot: ViewSlot);
413 /**
414 * Binds the replaceable to the binding context and override context.
415 * @param bindingContext The binding context.
416 * @param overrideContext An override context for binding.
417 */
418 bind(bindingContext: any, overrideContext: any): void;
419 /**
420 * Unbinds the replaceable.
421 */
422 unbind(): void;
423}
424/**
425 * CustomAttribute that binds provided DOM element's focus attribute with a property on the viewmodel.
426 */
427export declare class Focus {
428 /**
429 * Creates an instance of Focus.
430 * @paramelement Target element on where attribute is placed on.
431 * @param taskQueue The TaskQueue instance.
432 */
433 constructor(element: any, taskQueue: any);
434 /**
435 * Invoked everytime the bound value changes.
436 * @param newValue The new value.
437 */
438 valueChanged(newValue: any): void;
439 /**
440 * Invoked when the attribute is attached to the DOM.
441 */
442 attached(): void;
443 /**
444 * Invoked when the attribute is detached from the DOM.
445 */
446 detached(): void;
447 handleEvent(e: any): void;
448}
449export declare class AttrBindingBehavior {
450 bind(binding: any, source: any): void;
451 unbind(binding: any, source: any): void;
452}
453export declare class OneTimeBindingBehavior {
454 mode: bindingMode;
455 constructor();
456}
457export declare class OneWayBindingBehavior {
458 mode: bindingMode;
459 constructor();
460}
461export declare class ToViewBindingBehavior {
462 mode: bindingMode;
463 constructor();
464}
465export declare class FromViewBindingBehavior {
466 mode: bindingMode;
467 constructor();
468}
469export declare class TwoWayBindingBehavior {
470 mode: bindingMode;
471 constructor();
472}
473export declare class ThrottleBindingBehavior {
474 bind(binding: any, source: any, delay?: number): void;
475 unbind(binding: any, source: any): void;
476}
477export declare class DebounceBindingBehavior {
478 bind(binding: any, source: any, delay?: number): void;
479 unbind(binding: any, source: any): void;
480}
481export declare class SelfBindingBehavior {
482 bind(binding: any, source: any): void;
483 unbind(binding: any, source: any): void;
484}
485export declare class SignalBindingBehavior {
486 signals: any;
487 constructor(bindingSignaler: any);
488 bind(binding: any, source: any, ...names: any[]): void;
489 unbind(binding: any, source: any): void;
490}
491export declare class BindingSignaler {
492 signals: {};
493 signal(name: string): void;
494}
495export declare class UpdateTriggerBindingBehavior {
496 bind(binding: any, source: any, ...events: any[]): void;
497 unbind(binding: any, source: any): void;
498}
499/**
500 * A strategy is for repeating a template over an iterable or iterable-like object.
501 */
502export interface RepeatStrategy {
503 instanceChanged(repeat: Repeat, items: any): void;
504 instanceMutated(repeat: Repeat, items: any, changes: any): void;
505 getCollectionObserver(observerLocator: any, items: any): any;
506}
507/**
508 * Locates the best strategy to best repeating a template over different types of collections.
509 * Custom strategies can be plugged in as well.
510 */
511export declare class RepeatStrategyLocator {
512 /**
513 * Creates a new RepeatStrategyLocator.
514 */
515 constructor();
516 /**
517 * Adds a repeat strategy to be located when repeating a template over different collection types.
518 * @param strategy A repeat strategy that can iterate a specific collection type.
519 */
520 addStrategy(matcher: (items: any) => boolean, strategy: RepeatStrategy): void;
521 /**
522 * Gets the best strategy to handle iteration.
523 */
524 getStrategy(items: any): RepeatStrategy;
525}
526/**
527 * A strategy for repeating a template over null or undefined (does nothing)
528 */
529export declare class NullRepeatStrategy {
530 instanceChanged(repeat: any, items: any): void;
531 getCollectionObserver(observerLocator: any, items: any): void;
532}
533/**
534 * A strategy for repeating a template over an array.
535 */
536export declare class ArrayRepeatStrategy {
537 /**
538 * Gets an observer for the specified collection.
539 * @param observerLocator The observer locator instance.
540 * @param items The items to be observed.
541 */
542 getCollectionObserver(observerLocator: any, items: any): any;
543 /**
544 * Handle the repeat's collection instance changing.
545 * @param repeat The repeater instance.
546 * @param items The new array instance.
547 */
548 instanceChanged(repeat: any, items: any): void;
549 /**
550 * Handle the repeat's collection instance mutating.
551 * @param repeat The repeat instance.
552 * @param array The modified array.
553 * @param splices Records of array changes.
554 */
555 instanceMutated(repeat: any, array: any, splices: any): void;
556}
557/**
558 * A strategy for repeating a template over a Map.
559 */
560export declare class MapRepeatStrategy {
561 /**
562 * Gets a Map observer.
563 * @param items The items to be observed.
564 */
565 getCollectionObserver(observerLocator: any, items: any): any;
566 /**
567 * Process the provided Map entries.
568 * @param items The entries to process.
569 */
570 instanceChanged(repeat: any, items: any): void;
571 /**
572 * Handle changes in a Map collection.
573 * @param map The underlying Map collection.
574 * @param records The change records.
575 */
576 instanceMutated(repeat: any, map: any, records: any): void;
577}
578/**
579 * A strategy for repeating a template over a Set.
580 */
581export declare class SetRepeatStrategy {
582 /**
583 * Gets a Set observer.
584 * @param items The items to be observed.
585 */
586 getCollectionObserver(observerLocator: any, items: any): any;
587 /**
588 * Process the provided Set entries.
589 * @param items The entries to process.
590 */
591 instanceChanged(repeat: any, items: any): void;
592 /**
593 * Handle changes in a Set collection.
594 * @param repeat The repeat instance.
595 * @param set The underlying Set collection.
596 * @param records The change records.
597 */
598 instanceMutated(repeat: any, set: any, records: any): void;
599}
600/**
601 * A strategy for repeating a template over a number.
602 */
603export declare class NumberRepeatStrategy {
604 /**
605 * Return the strategies collection observer. In this case none.
606 */
607 getCollectionObserver(): any;
608 /**
609 * Process the provided Number.
610 * @param value The Number of how many time to iterate.
611 */
612 instanceChanged(repeat: any, value: any): void;
613}
614/**
615 * Creates a complete override context.
616 * @param data The item's value.
617 * @param index The item's index.
618 * @param length The collections total length.
619 * @param key The key in a key/value pair.
620 */
621export declare function createFullOverrideContext(repeat: any, data: any, index: any, length: any, key?: string): OverrideContext;
622/**
623 * Updates the override context.
624 * @param context The context to be updated.
625 * @param index The context's index.
626 * @param length The collection's length.
627 */
628export declare function updateOverrideContext(overrideContext: any, index: any, length: any): void;
629/**
630 * Gets a repeat instruction's source expression.
631 */
632export declare function getItemsSourceExpression(instruction: any, attrName: any): any;
633/**
634 * Unwraps an expression to expose the inner, pre-converted / behavior-free expression.
635 */
636export declare function unwrapExpression(expression: any): any;
637/**
638 * Returns whether an expression has the OneTimeBindingBehavior applied.
639 */
640export declare function isOneTime(expression: any): boolean;
641/**
642 * Forces a binding instance to reevaluate.
643 */
644export declare function updateOneTimeBinding(binding: any): void;
645export declare function viewsRequireLifecycle(viewFactory: any): any;
646export declare function configure(config: any): void;
\No newline at end of file