@scion/components 22.4.0 → 22.5.0
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/fesm2022/scion-components-common.mjs +48 -2
- package/fesm2022/scion-components-common.mjs.map +1 -1
- package/fesm2022/scion-components-menu.mjs +3 -9
- package/fesm2022/scion-components-menu.mjs.map +1 -1
- package/fesm2022/scion-components-splitter.mjs +1 -1
- package/fesm2022/scion-components-splitter.mjs.map +1 -1
- package/fesm2022/scion-components-table.mjs +260 -51
- package/fesm2022/scion-components-table.mjs.map +1 -1
- package/package.json +2 -2
- package/types/scion-components-common.d.ts +36 -2
- package/types/scion-components-table.d.ts +359 -37
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { isSignal, signal, inject, Injector, effect, untracked, DestroyRef, assertInInjectionContext as assertInInjectionContext$1, input, ElementRef, IterableDiffers, Renderer2, Directive, ViewContainerRef, inputBinding } from '@angular/core';
|
|
2
|
+
import { isSignal, signal, inject, Injector, effect, untracked, DestroyRef, assertInInjectionContext as assertInInjectionContext$1, input, ElementRef, IterableDiffers, Renderer2, Directive, ViewContainerRef, inputBinding, InjectionToken, LOCALE_ID } from '@angular/core';
|
|
3
3
|
import { of, Observable } from 'rxjs';
|
|
4
4
|
|
|
5
5
|
/*
|
|
@@ -228,6 +228,52 @@ function createComponent(viewContainerRef, descriptor) {
|
|
|
228
228
|
});
|
|
229
229
|
}
|
|
230
230
|
|
|
231
|
+
/*
|
|
232
|
+
* Copyright (c) 2018-2026 Swiss Federal Railways
|
|
233
|
+
*
|
|
234
|
+
* This program and the accompanying materials are made
|
|
235
|
+
* available under the terms of the Eclipse Public License 2.0
|
|
236
|
+
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
237
|
+
*
|
|
238
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
239
|
+
*/
|
|
240
|
+
/**
|
|
241
|
+
* DI token providing the current locale to SCION components for localizing dates and numbers.
|
|
242
|
+
*
|
|
243
|
+
* Defaults to {@link LOCALE_ID}. Changing the locale updates formatting in SCION components, unless overridden at the component level.
|
|
244
|
+
*
|
|
245
|
+
* Change the locale at runtime as follows:
|
|
246
|
+
* ```ts
|
|
247
|
+
* inject(SCI_LOCALE).set('de-CH');
|
|
248
|
+
* ```
|
|
249
|
+
*
|
|
250
|
+
* Angular includes only `en-US` by default. Register other locales via `registerLocaleData()`, typically in an environment initializer at app startup:
|
|
251
|
+
*
|
|
252
|
+
* ```ts
|
|
253
|
+
* import {bootstrapApplication} from '@angular/platform-browser';
|
|
254
|
+
* import {provideEnvironmentInitializer} from '@angular/core';
|
|
255
|
+
* import {registerLocaleData} from '@angular/common';
|
|
256
|
+
*
|
|
257
|
+
* import localeDeCH from '@angular/common/locales/de-CH';
|
|
258
|
+
* import localeFrCH from '@angular/common/locales/fr-CH';
|
|
259
|
+
* import localeItCH from '@angular/common/locales/it-CH';
|
|
260
|
+
*
|
|
261
|
+
* bootstrapApplication(AppComponent, {
|
|
262
|
+
* providers: [
|
|
263
|
+
* provideEnvironmentInitializer(() => {
|
|
264
|
+
* registerLocaleData(localeDeCH);
|
|
265
|
+
* registerLocaleData(localeFrCH);
|
|
266
|
+
* registerLocaleData(localeItCH);
|
|
267
|
+
* }),
|
|
268
|
+
* ],
|
|
269
|
+
* });
|
|
270
|
+
* ```
|
|
271
|
+
*/
|
|
272
|
+
const SCI_LOCALE = new InjectionToken('SCI_LOCALE', {
|
|
273
|
+
providedIn: 'root',
|
|
274
|
+
factory: () => signal(inject(LOCALE_ID)),
|
|
275
|
+
});
|
|
276
|
+
|
|
231
277
|
/*
|
|
232
278
|
* Copyright (c) 2018-2026 Swiss Federal Railways
|
|
233
279
|
*
|
|
@@ -247,5 +293,5 @@ function createComponent(viewContainerRef, descriptor) {
|
|
|
247
293
|
* Generated bundle index. Do not edit.
|
|
248
294
|
*/
|
|
249
295
|
|
|
250
|
-
export { SciAttributesDirective, SciComponentOutletDirective, assertInInjectionContext, coerceSignal, createDestroyableInjector, toLazyObservable };
|
|
296
|
+
export { SCI_LOCALE, SciAttributesDirective, SciComponentOutletDirective, assertInInjectionContext, coerceSignal, createDestroyableInjector, toLazyObservable };
|
|
251
297
|
//# sourceMappingURL=scion-components-common.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scion-components-common.mjs","sources":["../../../../projects/scion/components/common/src/signal.util.ts","../../../../projects/scion/components/common/src/injector.util.ts","../../../../projects/scion/components/common/src/attributes.directive.ts","../../../../projects/scion/components/common/src/component-outlet.directive.ts","../../../../projects/scion/components/common/src/public_api.ts","../../../../projects/scion/components/common/src/scion-components-common.ts"],"sourcesContent":["/*\n * Copyright (c) 2018-2026 Swiss Federal Railways\n *\n * This program and the accompanying materials are made\n * available under the terms of the Eclipse Public License 2.0\n * which is available at https://www.eclipse.org/legal/epl-2.0/\n *\n * SPDX-License-Identifier: EPL-2.0\n */\n\nimport {effect, inject, Injector, isSignal, signal, Signal, untracked} from '@angular/core';\nimport {Observable, of} from 'rxjs';\n\n/**\n * Represents a value or a {@link Signal} of that value.\n */\nexport type MaybeSignal<T> = T | Signal<T>;\n\n/**\n * Coerces the given value into a {@link Signal}. If the value is already a signal, it is returned as-is; otherwise, it is wrapped in a signal.\n *\n * Passing `undefined` returns `undefined`, unless the option `coerceUndefined` is set to `true`.\n *\n * @param value - Specifies the value to coerece.\n */\nexport function coerceSignal<T extends MaybeSignal<unknown>>(value: T): T extends Signal<unknown> ? T : T extends undefined ? undefined : Signal<T>;\n/**\n * Coerces the given value into a {@link Signal}. If the value is already a signal, it is returned as-is; otherwise, it is wrapped in a signal.\n *\n * @param value - Specifies the value to coerece.\n * @param options - Controls coercion.\n * @param options.coerceUndefined - If `true`, returns `signal(undefined)` for a `undefined` value. Defaults to `false`.\n */\nexport function coerceSignal<T>(value: MaybeSignal<T> | undefined, options: {coerceUndefined: true}): Signal<T | undefined>;\n\nexport function coerceSignal<T>(value: MaybeSignal<T>, options?: {coerceUndefined?: true}): Signal<T> | undefined {\n if (value === undefined && !options?.coerceUndefined) {\n return undefined;\n }\n return isSignal(value) ? value : signal(value);\n}\n\n/**\n * Like {@link toObservable}, but lazily creates the effect upon subscription, binding it to the subscription lifecycle instead of the injection context, plus, emits the signal's initial value synchronously.\n */\nexport function toLazyObservable<T>(signal: MaybeSignal<NonNullable<T>>, options?: {injector?: Injector}): Observable<NonNullable<T>>;\nexport function toLazyObservable<T>(signal: MaybeSignal<NonNullable<T>> | undefined, options?: {injector?: Injector}): Observable<NonNullable<T>> | undefined;\nexport function toLazyObservable<T>(signal: MaybeSignal<NonNullable<T>> | undefined, options?: {injector?: Injector}): Observable<NonNullable<T>> | undefined {\n if (signal === undefined) {\n return undefined;\n }\n if (!isSignal(signal)) {\n return of(signal);\n }\n\n const injector = options?.injector ?? inject(Injector);\n return new Observable(observer => {\n const initialValue = signal();\n let isFirstEffectRun = true;\n\n // Emit initial value synchronously.\n observer.next(initialValue);\n\n const effectRef = effect(() => {\n const value = signal();\n\n untracked(() => {\n if (!isFirstEffectRun || initialValue !== value) {\n observer.next(value);\n }\n isFirstEffectRun = false;\n });\n }, {injector, manualCleanup: true});\n\n return () => effectRef.destroy();\n });\n}\n","/*\n * Copyright (c) 2018-2026 Swiss Federal Railways\n *\n * This program and the accompanying materials are made\n * available under the terms of the Eclipse Public License 2.0\n * which is available at https://www.eclipse.org/legal/epl-2.0/\n *\n * SPDX-License-Identifier: EPL-2.0\n */\n\nimport {assertInInjectionContext as ngAssertInInjectionContext, DestroyableInjector, DestroyRef, inject, Injector, Provider} from '@angular/core';\n\n/**\n * Creates a {@link DestroyableInjector} bound to the lifecycle of its parent injector. Defaults to the current injector if not configuring a parent injector.\n *\n * Unlike injectors created via {@link Injector.create}, the returned injector:\n * - Is destroyed with its parent, also if used outside a component injection context.\n * - Does not throw an error when invoking {@link DestroyableInjector.destroy} if already destroyed.\n * - Uses the current injection context as parent if no explicit parent injector is specified.\n *\n * @docs-private Not public API. For internal use only.\n *\n * @param options - Configures the injector.\n * @param options.parent - Specifies the parent injector. Defaults to the current injector.\n * @param options.providers - Specifies providers to associate with the injector.\n * @param options.name - Names the injector, useful for debugging the injector hierarchy.\n */\nexport function createDestroyableInjector(options?: {parent?: Injector; providers?: Provider[]; name?: string}): DestroyableInjector {\n const parentInjector = options?.parent ?? inject(Injector);\n const injector = Injector.create({parent: parentInjector, providers: options?.providers ?? [], name: options?.name});\n\n // Destroy injector manually since not destroyed when the parent injector is destroyed.\n // Angular only destroys child injectors in the scope of a component injector.\n parentInjector.get(DestroyRef).onDestroy(() => injector.destroy());\n\n // Patch `Injector.destroy` to not error if already destroyed.\n const realDestroyFn = injector.destroy;\n const destroyRef = injector.get(DestroyRef);\n injector.destroy = () => !destroyRef.destroyed && realDestroyFn.apply(injector);\n return injector;\n}\n\n/**\n * Asserts that the current stack frame is within an injection context and has access to inject.\n *\n * Delegates to `assertInInjectionContext` from @angular/core, adding the given message to the error if the assertion fails.\n *\n * @docs-private Not public API. For internal use only.\n */\nexport function assertInInjectionContext(debugFn: Function, message: string): void { // eslint-disable-line @typescript-eslint/no-unsafe-function-type\n try {\n ngAssertInInjectionContext(debugFn);\n }\n catch {\n throw Error([`${debugFn.name}() can only be used within an injection context.`].concat(message ? message : []).join(' '));\n }\n}\n","/*\n * Copyright (c) 2018-2026 Swiss Federal Railways\n *\n * This program and the accompanying materials are made\n * available under the terms of the Eclipse Public License 2.0\n * which is available at https://www.eclipse.org/legal/epl-2.0/\n *\n * SPDX-License-Identifier: EPL-2.0\n */\n\nimport {Directive, effect, ElementRef, inject, input, IterableDiffers, Renderer2, untracked} from '@angular/core';\n\n/**\n * Use to add specified attributes to the host element.\n */\n@Directive({selector: '[sciAttributes]'})\nexport class SciAttributesDirective {\n\n /**\n * Specifies attributes to add to the host element.\n *\n * Attributes with `null` or `undefined` values are removed.\n */\n public readonly attributes = input<{[name: string]: unknown | undefined | null} | undefined | null>(undefined, {alias: 'sciAttributes'});\n\n constructor() {\n const host = inject(ElementRef).nativeElement as HTMLElement;\n const attributeDiffer = inject(IterableDiffers).find([]).create<string>();\n const renderer = inject(Renderer2);\n\n effect(() => {\n const attributes = this.attributes() ?? {};\n\n untracked(() => {\n // Delete removed attributes.\n const diff = attributeDiffer.diff(Object.keys(attributes));\n diff?.forEachRemovedItem(({item: name}) => renderer.removeAttribute(host, name));\n\n // Update added or changed attributes.\n Object.entries(attributes).forEach(([key, value]) => {\n if (value !== undefined && value !== null) {\n renderer.setAttribute(host, key, `${value}`);\n }\n else {\n renderer.removeAttribute(host, key);\n }\n });\n });\n });\n }\n}\n","/*\n * Copyright (c) 2018-2026 Swiss Federal Railways\n *\n * This program and the accompanying materials are made\n * available under the terms of the Eclipse Public License 2.0\n * which is available at https://www.eclipse.org/legal/epl-2.0/\n *\n * SPDX-License-Identifier: EPL-2.0\n */\n\nimport {Binding, ComponentRef, Directive, effect, inject, Injector, input, inputBinding, Provider, Type, untracked, ViewContainerRef} from '@angular/core';\nimport {ComponentType} from '@angular/cdk/portal';\nimport {SciAttributesDirective} from './attributes.directive';\nimport {coerceSignal, MaybeSignal} from './signal.util';\n\n/**\n * Renders a component based on a descriptor, similar to `ngComponentOutlet`, but with input bindings.\n *\n * Usage:\n *\n * ```html\n * <ng-container *sciComponentOutlet=\"descriptor\"/>\n * ````\n *\n * ```ts\n * protected readonly descriptor: SciComponentDescriptor = {\n * component: FilterComponent,\n * bindings: [\n * inputBinding('placeholder', signal('Filter items...')),\n * ],\n * };\n * ```\n */\n@Directive({selector: 'ng-template[sciComponentOutlet]'})\nexport class SciComponentOutletDirective {\n\n /**\n * Specifies the component to render.\n */\n public readonly descriptor = input.required<SciComponentDescriptor | undefined | null>({alias: 'sciComponentOutlet'});\n\n constructor() {\n const viewContainerRef = inject(ViewContainerRef);\n\n effect(onCleanup => {\n const descriptor = this.descriptor();\n\n untracked(() => {\n const component = descriptor && createComponent(viewContainerRef, descriptor);\n onCleanup(() => component?.destroy());\n });\n });\n }\n}\n\n/**\n * Instantiates the specified component and inserts it after the specified view container.\n */\nfunction createComponent(viewContainerRef: ViewContainerRef, descriptor: SciComponentDescriptor): ComponentRef<unknown> {\n // Provide providers via host directive.\n @Directive({providers: descriptor.providers ?? []})\n class ProvidersDirective {\n }\n\n // Provide CSS classes via host directive.\n @Directive({host: {'[class]': 'cssClass?.()'}})\n class CssClassDirective {\n protected readonly cssClass = coerceSignal(descriptor.cssClass);\n }\n\n return viewContainerRef.createComponent(descriptor.component, {\n directives: [\n ProvidersDirective,\n CssClassDirective,\n {type: SciAttributesDirective, bindings: [inputBinding('sciAttributes', coerceSignal(descriptor.attributes ?? {}))]},\n ...descriptor.directives ?? [],\n ],\n bindings: descriptor.bindings,\n injector: descriptor.injector,\n });\n}\n\n/**\n * Describes the rendering of a component.\n */\nexport interface SciComponentDescriptor {\n /**\n * Specifies the component to render.\n */\n component: ComponentType<unknown>;\n /**\n * Specifies input and output bindings.\n *\n * @example - Passing inputs to the component\n * ```ts\n * bindings: [inputBinding('placeholder', signal('Filter items...'))];\n * ```\n *\n * Inputs are available as input properties in the component.\n *\n * @example - Reading inputs in the component\n * ```ts\n * public placeholder = input.required<string>();\n * ```\n *\n * @see inputBinding\n * @see outputBinding\n * @see twoWayBinding\n */\n bindings?: Binding[];\n /**\n * Specifies directives to be applied to the component.\n */\n directives?: Array<Type<unknown> | {type: Type<unknown>; bindings: Binding[]}>;\n /**\n * Specifies the injector used to instantiate the component, giving control over which objects are available for injection. Defaults to the element injector.\n *\n * ```ts\n * Injector.create({\n * parent: ...,\n * providers: [\n * {provide: <TOKEN>, useValue: <VALUE>}\n * ],\n * })\n * ```\n */\n injector?: Injector;\n /**\n * Specifies providers available for injection in the component.\n */\n providers?: Provider[];\n /**\n * Specifies CSS classes to associate with the component.\n */\n cssClass?: MaybeSignal<string | string[]>;\n /**\n * Specifies HTML attributes to associate with the component.\n *\n * Data attributes should start with the `data-` prefix.\n */\n attributes?: MaybeSignal<{[name: string]: string | undefined}>;\n}\n","/*\n * Copyright (c) 2018-2026 Swiss Federal Railways\n *\n * This program and the accompanying materials are made\n * available under the terms of the Eclipse Public License 2.0\n * which is available at https://www.eclipse.org/legal/epl-2.0/\n *\n * SPDX-License-Identifier: EPL-2.0\n */\n\n/*\n * Secondary entrypoint: '@scion/components/common'\n *\n * @see https://github.com/ng-packagr/ng-packagr/blob/master/docs/secondary-entrypoints.md\n */\nexport {coerceSignal, type MaybeSignal, toLazyObservable} from './signal.util';\nexport {createDestroyableInjector, assertInInjectionContext} from './injector.util';\nexport {type SciComponentDescriptor, SciComponentOutletDirective} from './component-outlet.directive';\nexport {SciAttributesDirective} from './attributes.directive';\nexport {type SciTemplateDescriptor} from './template-descriptor';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["ngAssertInInjectionContext"],"mappings":";;;;AAAA;;;;;;;;AAQG;AA2BG,SAAU,YAAY,CAAI,KAAqB,EAAE,OAAkC,EAAA;IACvF,IAAI,KAAK,KAAK,SAAS,IAAI,CAAC,OAAO,EAAE,eAAe,EAAE;AACpD,QAAA,OAAO,SAAS;IAClB;AACA,IAAA,OAAO,QAAQ,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;AAChD;AAOM,SAAU,gBAAgB,CAAI,MAA+C,EAAE,OAA+B,EAAA;AAClH,IAAA,IAAI,MAAM,KAAK,SAAS,EAAE;AACxB,QAAA,OAAO,SAAS;IAClB;AACA,IAAA,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;AACrB,QAAA,OAAO,EAAE,CAAC,MAAM,CAAC;IACnB;IAEA,MAAM,QAAQ,GAAG,OAAO,EAAE,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC;AACtD,IAAA,OAAO,IAAI,UAAU,CAAC,QAAQ,IAAG;AAC/B,QAAA,MAAM,YAAY,GAAG,MAAM,EAAE;QAC7B,IAAI,gBAAgB,GAAG,IAAI;;AAG3B,QAAA,QAAQ,CAAC,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AAiB,EAAA,YAAA,EAAA,IAAA,EAAA,IAAA,EAAA,EAAA,UAAA,EAAA,EAAA,OAAA,EAAA,cAAA,EAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA;;+FAAjB,iBAAiB,EAAA,UAAA,EAAA,CAAA;sBADtB,SAAS;AAAC,gBAAA,IAAA,EAAA,CAAA,EAAC,IAAI,EAAE,EAAC,SAAS,EAAE,cAAc,EAAC,EAAC;;AAK9C,IAAA,OAAO,gBAAgB,CAAC,eAAe,CAAC,UAAU,CAAC,SAAS,EAAE;AAC5D,QAAA,UAAU,EAAE;YACV,kBAAkB;YAClB,iBAAiB;YACjB,EAAC,IAAI,EAAE,sBAAsB,EAAE,QAAQ,EAAE,CAAC,YAAY,CAAC,eAAe,EAAE,YAAY,CAAC,UAAU,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,CAAC,EAAC;AACpH,YAAA,GAAG,UAAU,CAAC,UAAU,IAAI,EAAE;AAC/B,SAAA;QACD,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,QAAQ,EAAE,UAAU,CAAC,QAAQ;AAC9B,KAAA,CAAC;AACH;;AChFD;;;;;;;;AAQG;AAEH;;;;AAIG;;ACdH;;AAEG;;"}
|
|
1
|
+
{"version":3,"file":"scion-components-common.mjs","sources":["../../../../projects/scion/components/common/src/signal.util.ts","../../../../projects/scion/components/common/src/injector.util.ts","../../../../projects/scion/components/common/src/attributes.directive.ts","../../../../projects/scion/components/common/src/component-outlet.directive.ts","../../../../projects/scion/components/common/src/locale.ts","../../../../projects/scion/components/common/src/public_api.ts","../../../../projects/scion/components/common/src/scion-components-common.ts"],"sourcesContent":["/*\n * Copyright (c) 2018-2026 Swiss Federal Railways\n *\n * This program and the accompanying materials are made\n * available under the terms of the Eclipse Public License 2.0\n * which is available at https://www.eclipse.org/legal/epl-2.0/\n *\n * SPDX-License-Identifier: EPL-2.0\n */\n\nimport {effect, inject, Injector, isSignal, signal, Signal, untracked} from '@angular/core';\nimport {Observable, of} from 'rxjs';\n\n/**\n * Represents a value or a {@link Signal} of that value.\n */\nexport type MaybeSignal<T> = T | Signal<T>;\n\n/**\n * Coerces the given value into a {@link Signal}. If the value is already a signal, it is returned as-is; otherwise, it is wrapped in a signal.\n *\n * Passing `undefined` returns `undefined`, unless the option `coerceUndefined` is set to `true`.\n *\n * @param value - Specifies the value to coerece.\n */\nexport function coerceSignal<T extends MaybeSignal<unknown>>(value: T): T extends Signal<unknown> ? T : T extends undefined ? undefined : Signal<T>;\n/**\n * Coerces the given value into a {@link Signal}. If the value is already a signal, it is returned as-is; otherwise, it is wrapped in a signal.\n *\n * @param value - Specifies the value to coerece.\n * @param options - Controls coercion.\n * @param options.coerceUndefined - If `true`, returns `signal(undefined)` for a `undefined` value. Defaults to `false`.\n */\nexport function coerceSignal<T>(value: MaybeSignal<T> | undefined, options: {coerceUndefined: true}): Signal<T | undefined>;\n\nexport function coerceSignal<T>(value: MaybeSignal<T>, options?: {coerceUndefined?: true}): Signal<T> | undefined {\n if (value === undefined && !options?.coerceUndefined) {\n return undefined;\n }\n return isSignal(value) ? value : signal(value);\n}\n\n/**\n * Like {@link toObservable}, but lazily creates the effect upon subscription, binding it to the subscription lifecycle instead of the injection context, plus, emits the signal's initial value synchronously.\n */\nexport function toLazyObservable<T>(signal: MaybeSignal<NonNullable<T>>, options?: {injector?: Injector}): Observable<NonNullable<T>>;\nexport function toLazyObservable<T>(signal: MaybeSignal<NonNullable<T>> | undefined, options?: {injector?: Injector}): Observable<NonNullable<T>> | undefined;\nexport function toLazyObservable<T>(signal: MaybeSignal<NonNullable<T>> | undefined, options?: {injector?: Injector}): Observable<NonNullable<T>> | undefined {\n if (signal === undefined) {\n return undefined;\n }\n if (!isSignal(signal)) {\n return of(signal);\n }\n\n const injector = options?.injector ?? inject(Injector);\n return new Observable(observer => {\n const initialValue = signal();\n let isFirstEffectRun = true;\n\n // Emit initial value synchronously.\n observer.next(initialValue);\n\n const effectRef = effect(() => {\n const value = signal();\n\n untracked(() => {\n if (!isFirstEffectRun || initialValue !== value) {\n observer.next(value);\n }\n isFirstEffectRun = false;\n });\n }, {injector, manualCleanup: true});\n\n return () => effectRef.destroy();\n });\n}\n","/*\n * Copyright (c) 2018-2026 Swiss Federal Railways\n *\n * This program and the accompanying materials are made\n * available under the terms of the Eclipse Public License 2.0\n * which is available at https://www.eclipse.org/legal/epl-2.0/\n *\n * SPDX-License-Identifier: EPL-2.0\n */\n\nimport {assertInInjectionContext as ngAssertInInjectionContext, DestroyableInjector, DestroyRef, inject, Injector, Provider} from '@angular/core';\n\n/**\n * Creates a {@link DestroyableInjector} bound to the lifecycle of its parent injector. Defaults to the current injector if not configuring a parent injector.\n *\n * Unlike injectors created via {@link Injector.create}, the returned injector:\n * - Is destroyed with its parent, also if used outside a component injection context.\n * - Does not throw an error when invoking {@link DestroyableInjector.destroy} if already destroyed.\n * - Uses the current injection context as parent if no explicit parent injector is specified.\n *\n * @docs-private Not public API. For internal use only.\n *\n * @param options - Configures the injector.\n * @param options.parent - Specifies the parent injector. Defaults to the current injector.\n * @param options.providers - Specifies providers to associate with the injector.\n * @param options.name - Names the injector, useful for debugging the injector hierarchy.\n */\nexport function createDestroyableInjector(options?: {parent?: Injector; providers?: Provider[]; name?: string}): DestroyableInjector {\n const parentInjector = options?.parent ?? inject(Injector);\n const injector = Injector.create({parent: parentInjector, providers: options?.providers ?? [], name: options?.name});\n\n // Destroy injector manually since not destroyed when the parent injector is destroyed.\n // Angular only destroys child injectors in the scope of a component injector.\n parentInjector.get(DestroyRef).onDestroy(() => injector.destroy());\n\n // Patch `Injector.destroy` to not error if already destroyed.\n const realDestroyFn = injector.destroy;\n const destroyRef = injector.get(DestroyRef);\n injector.destroy = () => !destroyRef.destroyed && realDestroyFn.apply(injector);\n return injector;\n}\n\n/**\n * Asserts that the current stack frame is within an injection context and has access to inject.\n *\n * Delegates to `assertInInjectionContext` from @angular/core, adding the given message to the error if the assertion fails.\n *\n * @docs-private Not public API. For internal use only.\n */\nexport function assertInInjectionContext(debugFn: Function, message: string): void { // eslint-disable-line @typescript-eslint/no-unsafe-function-type\n try {\n ngAssertInInjectionContext(debugFn);\n }\n catch {\n throw Error([`${debugFn.name}() can only be used within an injection context.`].concat(message ? message : []).join(' '));\n }\n}\n","/*\n * Copyright (c) 2018-2026 Swiss Federal Railways\n *\n * This program and the accompanying materials are made\n * available under the terms of the Eclipse Public License 2.0\n * which is available at https://www.eclipse.org/legal/epl-2.0/\n *\n * SPDX-License-Identifier: EPL-2.0\n */\n\nimport {Directive, effect, ElementRef, inject, input, IterableDiffers, Renderer2, untracked} from '@angular/core';\n\n/**\n * Use to add specified attributes to the host element.\n */\n@Directive({selector: '[sciAttributes]'})\nexport class SciAttributesDirective {\n\n /**\n * Specifies attributes to add to the host element.\n *\n * Attributes with `null` or `undefined` values are removed.\n */\n public readonly attributes = input<{[name: string]: unknown | undefined | null} | undefined | null>(undefined, {alias: 'sciAttributes'});\n\n constructor() {\n const host = inject(ElementRef).nativeElement as HTMLElement;\n const attributeDiffer = inject(IterableDiffers).find([]).create<string>();\n const renderer = inject(Renderer2);\n\n effect(() => {\n const attributes = this.attributes() ?? {};\n\n untracked(() => {\n // Delete removed attributes.\n const diff = attributeDiffer.diff(Object.keys(attributes));\n diff?.forEachRemovedItem(({item: name}) => renderer.removeAttribute(host, name));\n\n // Update added or changed attributes.\n Object.entries(attributes).forEach(([key, value]) => {\n if (value !== undefined && value !== null) {\n renderer.setAttribute(host, key, `${value}`);\n }\n else {\n renderer.removeAttribute(host, key);\n }\n });\n });\n });\n }\n}\n","/*\n * Copyright (c) 2018-2026 Swiss Federal Railways\n *\n * This program and the accompanying materials are made\n * available under the terms of the Eclipse Public License 2.0\n * which is available at https://www.eclipse.org/legal/epl-2.0/\n *\n * SPDX-License-Identifier: EPL-2.0\n */\n\nimport {Binding, ComponentRef, Directive, effect, inject, Injector, input, inputBinding, Provider, Type, untracked, ViewContainerRef} from '@angular/core';\nimport {ComponentType} from '@angular/cdk/portal';\nimport {SciAttributesDirective} from './attributes.directive';\nimport {coerceSignal, MaybeSignal} from './signal.util';\n\n/**\n * Renders a component based on a descriptor, similar to `ngComponentOutlet`, but with input bindings.\n *\n * Usage:\n *\n * ```html\n * <ng-container *sciComponentOutlet=\"descriptor\"/>\n * ````\n *\n * ```ts\n * protected readonly descriptor: SciComponentDescriptor = {\n * component: FilterComponent,\n * bindings: [\n * inputBinding('placeholder', signal('Filter items...')),\n * ],\n * };\n * ```\n */\n@Directive({selector: 'ng-template[sciComponentOutlet]'})\nexport class SciComponentOutletDirective {\n\n /**\n * Specifies the component to render.\n */\n public readonly descriptor = input.required<SciComponentDescriptor | undefined | null>({alias: 'sciComponentOutlet'});\n\n constructor() {\n const viewContainerRef = inject(ViewContainerRef);\n\n effect(onCleanup => {\n const descriptor = this.descriptor();\n\n untracked(() => {\n const component = descriptor && createComponent(viewContainerRef, descriptor);\n onCleanup(() => component?.destroy());\n });\n });\n }\n}\n\n/**\n * Instantiates the specified component and inserts it after the specified view container.\n */\nfunction createComponent(viewContainerRef: ViewContainerRef, descriptor: SciComponentDescriptor): ComponentRef<unknown> {\n // Provide providers via host directive.\n @Directive({providers: descriptor.providers ?? []})\n class ProvidersDirective {\n }\n\n // Provide CSS classes via host directive.\n @Directive({host: {'[class]': 'cssClass?.()'}})\n class CssClassDirective {\n protected readonly cssClass = coerceSignal(descriptor.cssClass);\n }\n\n return viewContainerRef.createComponent(descriptor.component, {\n directives: [\n ProvidersDirective,\n CssClassDirective,\n {type: SciAttributesDirective, bindings: [inputBinding('sciAttributes', coerceSignal(descriptor.attributes ?? {}))]},\n ...descriptor.directives ?? [],\n ],\n bindings: descriptor.bindings,\n injector: descriptor.injector,\n });\n}\n\n/**\n * Describes the rendering of a component.\n */\nexport interface SciComponentDescriptor {\n /**\n * Specifies the component to render.\n */\n component: ComponentType<unknown>;\n /**\n * Specifies input and output bindings.\n *\n * @example - Passing inputs to the component\n * ```ts\n * bindings: [inputBinding('placeholder', signal('Filter items...'))];\n * ```\n *\n * Inputs are available as input properties in the component.\n *\n * @example - Reading inputs in the component\n * ```ts\n * public placeholder = input.required<string>();\n * ```\n *\n * @see inputBinding\n * @see outputBinding\n * @see twoWayBinding\n */\n bindings?: Binding[];\n /**\n * Specifies directives to be applied to the component.\n */\n directives?: Array<Type<unknown> | {type: Type<unknown>; bindings: Binding[]}>;\n /**\n * Specifies the injector used to instantiate the component, giving control over which objects are available for injection. Defaults to the element injector.\n *\n * ```ts\n * Injector.create({\n * parent: ...,\n * providers: [\n * {provide: <TOKEN>, useValue: <VALUE>}\n * ],\n * })\n * ```\n */\n injector?: Injector;\n /**\n * Specifies providers available for injection in the component.\n */\n providers?: Provider[];\n /**\n * Specifies CSS classes to associate with the component.\n */\n cssClass?: MaybeSignal<string | string[]>;\n /**\n * Specifies HTML attributes to associate with the component.\n *\n * Data attributes should start with the `data-` prefix.\n */\n attributes?: MaybeSignal<{[name: string]: string | undefined}>;\n}\n","/*\n * Copyright (c) 2018-2026 Swiss Federal Railways\n *\n * This program and the accompanying materials are made\n * available under the terms of the Eclipse Public License 2.0\n * which is available at https://www.eclipse.org/legal/epl-2.0/\n *\n * SPDX-License-Identifier: EPL-2.0\n */\n\nimport {inject, InjectionToken, LOCALE_ID, signal, WritableSignal} from '@angular/core';\n\n/**\n * DI token providing the current locale to SCION components for localizing dates and numbers.\n *\n * Defaults to {@link LOCALE_ID}. Changing the locale updates formatting in SCION components, unless overridden at the component level.\n *\n * Change the locale at runtime as follows:\n * ```ts\n * inject(SCI_LOCALE).set('de-CH');\n * ```\n *\n * Angular includes only `en-US` by default. Register other locales via `registerLocaleData()`, typically in an environment initializer at app startup:\n *\n * ```ts\n * import {bootstrapApplication} from '@angular/platform-browser';\n * import {provideEnvironmentInitializer} from '@angular/core';\n * import {registerLocaleData} from '@angular/common';\n *\n * import localeDeCH from '@angular/common/locales/de-CH';\n * import localeFrCH from '@angular/common/locales/fr-CH';\n * import localeItCH from '@angular/common/locales/it-CH';\n *\n * bootstrapApplication(AppComponent, {\n * providers: [\n * provideEnvironmentInitializer(() => {\n * registerLocaleData(localeDeCH);\n * registerLocaleData(localeFrCH);\n * registerLocaleData(localeItCH);\n * }),\n * ],\n * });\n * ```\n */\nexport const SCI_LOCALE = new InjectionToken<WritableSignal<string>>('SCI_LOCALE', {\n providedIn: 'root',\n factory: () => signal(inject(LOCALE_ID)),\n});\n","/*\n * Copyright (c) 2018-2026 Swiss Federal Railways\n *\n * This program and the accompanying materials are made\n * available under the terms of the Eclipse Public License 2.0\n * which is available at https://www.eclipse.org/legal/epl-2.0/\n *\n * SPDX-License-Identifier: EPL-2.0\n */\n\n/*\n * Secondary entrypoint: '@scion/components/common'\n *\n * @see https://github.com/ng-packagr/ng-packagr/blob/master/docs/secondary-entrypoints.md\n */\nexport {coerceSignal, type MaybeSignal, toLazyObservable} from './signal.util';\nexport {createDestroyableInjector, assertInInjectionContext} from './injector.util';\nexport {type SciComponentDescriptor, SciComponentOutletDirective} from './component-outlet.directive';\nexport {SciAttributesDirective} from './attributes.directive';\nexport {type SciTemplateDescriptor} from './template-descriptor';\nexport {SCI_LOCALE} from './locale';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["ngAssertInInjectionContext"],"mappings":";;;;AAAA;;;;;;;;AAQG;AA2BG,SAAU,YAAY,CAAI,KAAqB,EAAE,OAAkC,EAAA;IACvF,IAAI,KAAK,KAAK,SAAS,IAAI,CAAC,OAAO,EAAE,eAAe,EAAE;AACpD,QAAA,OAAO,SAAS;IAClB;AACA,IAAA,OAAO,QAAQ,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;AAChD;AAOM,SAAU,gBAAgB,CAAI,MAA+C,EAAE,OAA+B,EAAA;AAClH,IAAA,IAAI,MAAM,KAAK,SAAS,EAAE;AACxB,QAAA,OAAO,SAAS;IAClB;AACA,IAAA,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;AACrB,QAAA,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EH;;;;AAIG;;ACdH;;AAEG;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { untracked, inject, Injector, InjectionToken, computed, runInInjectionContext, effect, assertNotInReactiveContext, NgZone, DOCUMENT, DestroyRef, isSignal, Injectable, Pipe, input, createComponent, inputBinding, ElementRef, EnvironmentInjector, ApplicationRef, Component, model, viewChild, signal, viewChildren, linkedSignal, ViewContainerRef, afterRenderEffect, Directive } from '@angular/core';
|
|
2
|
+
import { untracked, inject, Injector, InjectionToken, computed, runInInjectionContext, effect, assertNotInReactiveContext, NgZone, DOCUMENT, DestroyRef, isSignal, Injectable, Pipe, input, createComponent, inputBinding, ElementRef, EnvironmentInjector, ApplicationRef, Component, model, viewChild, signal, viewChildren, linkedSignal, ViewContainerRef, onIdle, afterRenderEffect, Directive } from '@angular/core';
|
|
3
3
|
import * as i1$1 from '@scion/components/common';
|
|
4
4
|
import { coerceSignal, createDestroyableInjector, SciComponentOutletDirective, SciAttributesDirective, assertInInjectionContext } from '@scion/components/common';
|
|
5
5
|
import { Objects, Arrays, prune, Maps } from '@scion/toolkit/util';
|
|
@@ -1595,14 +1595,8 @@ class SciMenuComponent {
|
|
|
1595
1595
|
// Wait until menu items are available, maximal until idle; may initially be empty due to asynchronous menu contributions.
|
|
1596
1596
|
toObservable(this.menuItems)
|
|
1597
1597
|
.pipe(filter(menuItems => !!menuItems.length), observeOn(animationFrameScheduler), // Wait until next render cycle to capture menu width.
|
|
1598
|
-
raceWith(
|
|
1599
|
-
|
|
1600
|
-
requestIdleCallback(resolve, { timeout: 250 });
|
|
1601
|
-
}
|
|
1602
|
-
else {
|
|
1603
|
-
setTimeout(resolve, 250); // Fallback if browser does not support `requestIdleCallback`, e.g., Safari
|
|
1604
|
-
}
|
|
1605
|
-
})), take(1), takeUntilDestroyed())
|
|
1598
|
+
raceWith(onIdle({ timeout: 250 })), // Fallback if no menu items are contributed.
|
|
1599
|
+
take(1), takeUntilDestroyed())
|
|
1606
1600
|
.subscribe(() => {
|
|
1607
1601
|
this.menuSize.update(size => ({ ...size, width: `${host.getBoundingClientRect().width}px` }));
|
|
1608
1602
|
});
|