ng-primitives 0.7.1 → 0.7.2
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.
|
@@ -13,7 +13,7 @@ export const NgpDisabledToken = new InjectionToken('NgpDisabledToken');
|
|
|
13
13
|
* @returns The disabled signal.
|
|
14
14
|
*/
|
|
15
15
|
export function injectDisabled(disabled = signal(false)) {
|
|
16
|
-
const provider = inject(NgpDisabledToken, { optional: true });
|
|
16
|
+
const provider = inject(NgpDisabledToken, { optional: true, self: true });
|
|
17
17
|
return provider ? provider.disabled : disabled;
|
|
18
18
|
}
|
|
19
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
19
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGlzYWJsZWQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9uZy1wcmltaXRpdmVzL2ludGVybmFsL3NyYy9kaXNhYmxlZC9kaXNhYmxlZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFDSCxPQUFPLEVBQUUsTUFBTSxFQUFFLGNBQWMsRUFBRSxNQUFNLEVBQVUsTUFBTSxlQUFlLENBQUM7QUFFdkUsTUFBTSxDQUFDLE1BQU0sZ0JBQWdCLEdBQUcsSUFBSSxjQUFjLENBQWdCLGtCQUFrQixDQUFDLENBQUM7QUFTdEY7Ozs7R0FJRztBQUNILE1BQU0sVUFBVSxjQUFjLENBQzVCLFdBQTRCLE1BQU0sQ0FBVSxLQUFLLENBQUM7SUFFbEQsTUFBTSxRQUFRLEdBQUcsTUFBTSxDQUFDLGdCQUFnQixFQUFFLEVBQUUsUUFBUSxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUUsSUFBSSxFQUFFLENBQUMsQ0FBQztJQUUxRSxPQUFPLFFBQVEsQ0FBQyxDQUFDLENBQUM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ChcbiAgZGlzYWJsZWQ6IFNpZ25hbDxib29sZWFuPiA9IHNpZ25hbDxib29sZWFuPihmYWxzZSksXG4pOiBTaWduYWw8Ym9vbGVhbj4ge1xuICBjb25zdCBwcm92aWRlciA9IGluamVjdChOZ3BEaXNhYmxlZFRva2VuLCB7IG9wdGlvbmFsOiB0cnVlLCBzZWxmOiB0cnVlIH0pO1xuXG4gIHJldHVybiBwcm92aWRlciA/IHByb3ZpZGVyLmRpc2FibGVkIDogZGlzYWJsZWQ7XG59XG4iXX0=
|
|
@@ -16,7 +16,7 @@ const NgpDisabledToken = new InjectionToken('NgpDisabledToken');
|
|
|
16
16
|
* @returns The disabled signal.
|
|
17
17
|
*/
|
|
18
18
|
function injectDisabled(disabled = signal(false)) {
|
|
19
|
-
const provider = inject(NgpDisabledToken, { optional: true });
|
|
19
|
+
const provider = inject(NgpDisabledToken, { optional: true, self: true });
|
|
20
20
|
return provider ? provider.disabled : disabled;
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-primitives-internal.mjs","sources":["../../../../packages/ng-primitives/internal/src/disabled/disabled.ts","../../../../packages/ng-primitives/internal/src/orientation/orientation.ts","../../../../packages/ng-primitives/internal/src/style-injector/style-injector.ts","../../../../packages/ng-primitives/internal/src/index.ts","../../../../packages/ng-primitives/internal/src/ng-primitives-internal.ts"],"sourcesContent":["/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the Apache 2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { inject, InjectionToken, signal, Signal } from '@angular/core';\n\nexport const NgpDisabledToken = new InjectionToken<NgpCanDisable>('NgpDisabledToken');\n\nexport interface NgpCanDisable {\n /**\n * Whether the element is disabled.\n */\n readonly disabled: Signal<boolean>;\n}\n\n/**\n * Determine if we are in a disabled context.\n * @param disabled The disabled signal for the local context.\n * @returns The disabled signal.\n */\nexport function injectDisabled(\n disabled: Signal<boolean> = signal<boolean>(false),\n): Signal<boolean> {\n const provider = inject(NgpDisabledToken, { optional: true });\n\n return provider ? provider.disabled : disabled;\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the Apache 2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { inject, InjectionToken, signal, Signal } from '@angular/core';\n\nexport const NgpOrientationToken = new InjectionToken<NgpCanOrientate>('NgpOrientationToken');\n\nexport interface NgpCanOrientate {\n /**\n * The desired orientation.\n */\n readonly orientation: Signal<NgpOrientation>;\n}\n\n/**\n * Determine if we are in a orientation context.\n * @param orientation The orientation signal for the local context.\n * @returns The orientation signal.\n */\nexport function injectOrientation(\n orientation: Signal<NgpOrientation> = signal<NgpOrientation>('horizontal'),\n): Signal<NgpOrientation> {\n const provider = inject(NgpOrientationToken, { optional: true });\n\n return provider ? provider.orientation : orientation;\n}\n\nexport type NgpOrientation = 'horizontal' | 'vertical';\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the Apache 2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { isPlatformBrowser } from '@angular/common';\nimport { inject, Injectable, PLATFORM_ID } from '@angular/core';\n\n/**\n * A utility service for injecting styles into the document.\n * Angular doesn't allow directives to specify styles, only components.\n * As we ship directives, occasionally we need to associate styles with them.\n * This service allows us to programmatically inject styles into the document.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class StyleInjector {\n /**\n * Detect the platform.\n */\n private readonly platformId = inject(PLATFORM_ID);\n\n /**\n * Store the map of style elements with their unique identifiers.\n */\n private readonly styleElements = new Map<string, HTMLStyleElement>();\n\n constructor() {\n if (isPlatformBrowser(this.platformId)) {\n this.collectServerStyles();\n }\n }\n\n /**\n * Inject a style into the document.\n * @param id The unique identifier for the style.\n * @param style The style to inject.\n */\n add(id: string, style: string): void {\n if (this.styleElements.has(id)) {\n return;\n }\n\n const styleElement = document.createElement('style');\n styleElement.setAttribute('data-ngp-style', id);\n styleElement.textContent = style;\n\n document.head.appendChild(styleElement);\n this.styleElements.set(id, styleElement);\n }\n\n /**\n * Remove a style from the document.\n * @param id The unique identifier for the style.\n */\n remove(id: string): void {\n const styleElement = this.styleElements.get(id);\n\n if (styleElement) {\n document.head.removeChild(styleElement);\n this.styleElements.delete(id);\n }\n }\n\n /**\n * Collect any styles that were rendered by the server.\n */\n private collectServerStyles(): void {\n const styleElements = document.querySelectorAll<HTMLStyleElement>('style[data-ngp-style]');\n\n styleElements.forEach(styleElement => {\n const id = styleElement.getAttribute('data-ngp-style');\n\n if (id) {\n this.styleElements.set(id, styleElement);\n }\n });\n }\n}\n\nexport function injectStyleInjector(): StyleInjector {\n return inject(StyleInjector);\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the Apache 2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nexport * from './disabled/disabled';\nexport * from './orientation/orientation';\nexport * from './style-injector/style-injector';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAAA;;;;;;AAMG;MAGU,gBAAgB,GAAG,IAAI,cAAc,CAAgB,kBAAkB,EAAE;AAStF;;;;AAIG;SACa,cAAc,CAC5B,WAA4B,MAAM,CAAU,KAAK,CAAC,EAAA;AAElD,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAC,gBAAgB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"ng-primitives-internal.mjs","sources":["../../../../packages/ng-primitives/internal/src/disabled/disabled.ts","../../../../packages/ng-primitives/internal/src/orientation/orientation.ts","../../../../packages/ng-primitives/internal/src/style-injector/style-injector.ts","../../../../packages/ng-primitives/internal/src/index.ts","../../../../packages/ng-primitives/internal/src/ng-primitives-internal.ts"],"sourcesContent":["/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the Apache 2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { inject, InjectionToken, signal, Signal } from '@angular/core';\n\nexport const NgpDisabledToken = new InjectionToken<NgpCanDisable>('NgpDisabledToken');\n\nexport interface NgpCanDisable {\n /**\n * Whether the element is disabled.\n */\n readonly disabled: Signal<boolean>;\n}\n\n/**\n * Determine if we are in a disabled context.\n * @param disabled The disabled signal for the local context.\n * @returns The disabled signal.\n */\nexport function injectDisabled(\n disabled: Signal<boolean> = signal<boolean>(false),\n): Signal<boolean> {\n const provider = inject(NgpDisabledToken, { optional: true, self: true });\n\n return provider ? provider.disabled : disabled;\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the Apache 2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { inject, InjectionToken, signal, Signal } from '@angular/core';\n\nexport const NgpOrientationToken = new InjectionToken<NgpCanOrientate>('NgpOrientationToken');\n\nexport interface NgpCanOrientate {\n /**\n * The desired orientation.\n */\n readonly orientation: Signal<NgpOrientation>;\n}\n\n/**\n * Determine if we are in a orientation context.\n * @param orientation The orientation signal for the local context.\n * @returns The orientation signal.\n */\nexport function injectOrientation(\n orientation: Signal<NgpOrientation> = signal<NgpOrientation>('horizontal'),\n): Signal<NgpOrientation> {\n const provider = inject(NgpOrientationToken, { optional: true });\n\n return provider ? provider.orientation : orientation;\n}\n\nexport type NgpOrientation = 'horizontal' | 'vertical';\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the Apache 2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { isPlatformBrowser } from '@angular/common';\nimport { inject, Injectable, PLATFORM_ID } from '@angular/core';\n\n/**\n * A utility service for injecting styles into the document.\n * Angular doesn't allow directives to specify styles, only components.\n * As we ship directives, occasionally we need to associate styles with them.\n * This service allows us to programmatically inject styles into the document.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class StyleInjector {\n /**\n * Detect the platform.\n */\n private readonly platformId = inject(PLATFORM_ID);\n\n /**\n * Store the map of style elements with their unique identifiers.\n */\n private readonly styleElements = new Map<string, HTMLStyleElement>();\n\n constructor() {\n if (isPlatformBrowser(this.platformId)) {\n this.collectServerStyles();\n }\n }\n\n /**\n * Inject a style into the document.\n * @param id The unique identifier for the style.\n * @param style The style to inject.\n */\n add(id: string, style: string): void {\n if (this.styleElements.has(id)) {\n return;\n }\n\n const styleElement = document.createElement('style');\n styleElement.setAttribute('data-ngp-style', id);\n styleElement.textContent = style;\n\n document.head.appendChild(styleElement);\n this.styleElements.set(id, styleElement);\n }\n\n /**\n * Remove a style from the document.\n * @param id The unique identifier for the style.\n */\n remove(id: string): void {\n const styleElement = this.styleElements.get(id);\n\n if (styleElement) {\n document.head.removeChild(styleElement);\n this.styleElements.delete(id);\n }\n }\n\n /**\n * Collect any styles that were rendered by the server.\n */\n private collectServerStyles(): void {\n const styleElements = document.querySelectorAll<HTMLStyleElement>('style[data-ngp-style]');\n\n styleElements.forEach(styleElement => {\n const id = styleElement.getAttribute('data-ngp-style');\n\n if (id) {\n this.styleElements.set(id, styleElement);\n }\n });\n }\n}\n\nexport function injectStyleInjector(): StyleInjector {\n return inject(StyleInjector);\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the Apache 2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nexport * from './disabled/disabled';\nexport * from './orientation/orientation';\nexport * from './style-injector/style-injector';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAAA;;;;;;AAMG;MAGU,gBAAgB,GAAG,IAAI,cAAc,CAAgB,kBAAkB,EAAE;AAStF;;;;AAIG;SACa,cAAc,CAC5B,WAA4B,MAAM,CAAU,KAAK,CAAC,EAAA;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