@filip.mazev/blocks 1.4.15 → 1.4.17
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/core/styles/_a11y.scss +5 -0
- package/core/styles/_field-actions.scss +36 -0
- package/core/styles/_field-state.scss +12 -3
- package/core/styles/_helpers.scss +3 -0
- package/core/styles/_index.scss +1 -0
- package/core/styles/_slider-rail.scss +11 -0
- package/core/styles/_slider.scss +119 -11
- package/core/styles/_text-overflow.scss +7 -0
- package/core/styles/_text.scss +5 -0
- package/core/styles/_validation.scss +48 -0
- package/fesm2022/filip.mazev-blocks-core.mjs +83 -18
- package/fesm2022/filip.mazev-blocks-core.mjs.map +1 -1
- package/fesm2022/filip.mazev-blocks-effects-runtime.mjs +14 -3
- package/fesm2022/filip.mazev-blocks-effects-runtime.mjs.map +1 -1
- package/fesm2022/filip.mazev-blocks-effects.mjs +16 -8
- package/fesm2022/filip.mazev-blocks-effects.mjs.map +1 -1
- package/fesm2022/filip.mazev-blocks-forms.mjs +5282 -1093
- package/fesm2022/filip.mazev-blocks-forms.mjs.map +1 -1
- package/fesm2022/filip.mazev-blocks-primitives.mjs +2373 -1294
- package/fesm2022/filip.mazev-blocks-primitives.mjs.map +1 -1
- package/fesm2022/filip.mazev-blocks.mjs +1 -1
- package/fesm2022/filip.mazev-blocks.mjs.map +1 -1
- package/forms/README.md +80 -0
- package/package.json +1 -1
- package/types/filip.mazev-blocks-core.d.ts +22 -2
- package/types/filip.mazev-blocks-effects.d.ts +1 -1
- package/types/filip.mazev-blocks-forms.d.ts +1290 -76
- package/types/filip.mazev-blocks-primitives.d.ts +304 -6
- package/types/filip.mazev-blocks.d.ts +1 -1
|
@@ -168,25 +168,33 @@ function optionalNumber(value) {
|
|
|
168
168
|
function optionalBoolean(value) {
|
|
169
169
|
return value === void 0 || value === null ? void 0 : booleanAttribute(value);
|
|
170
170
|
}
|
|
171
|
-
function injectComponentSurface(options = () => ({})) {
|
|
171
|
+
function injectComponentSurface(options = () => ({}), enabled = () => true) {
|
|
172
172
|
const element = inject(ElementRef);
|
|
173
173
|
const zone = inject(NgZone);
|
|
174
174
|
const a11y = inject(BxA11yService);
|
|
175
175
|
inject(ThemingService);
|
|
176
176
|
let surface;
|
|
177
|
+
let rendered = false;
|
|
177
178
|
const browser = isPlatformBrowser(inject(PLATFORM_ID));
|
|
178
|
-
|
|
179
|
+
const sync = () => {
|
|
179
180
|
const current = {
|
|
180
181
|
...options(),
|
|
181
182
|
reducedMotion: a11y.isReducedMotion()
|
|
182
183
|
};
|
|
183
|
-
|
|
184
|
-
|
|
184
|
+
const active = enabled();
|
|
185
|
+
if (!browser || !rendered) return;
|
|
186
|
+
zone.runOutsideAngular(() => {
|
|
187
|
+
if (!active) {
|
|
188
|
+
surface?.destroy();
|
|
189
|
+
surface = void 0;
|
|
190
|
+
} else if (surface) surface.update(current);
|
|
191
|
+
else if (!element.nativeElement.hasAttribute("data-bx-surface")) surface = mountSurface(element.nativeElement, current);
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
effect(sync);
|
|
185
195
|
afterNextRender(() => {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
reducedMotion: a11y.isReducedMotion()
|
|
189
|
-
}));
|
|
196
|
+
rendered = true;
|
|
197
|
+
sync();
|
|
190
198
|
});
|
|
191
199
|
inject(DestroyRef).onDestroy(() => surface?.destroy());
|
|
192
200
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filip.mazev-blocks-effects.mjs","names":[],"sources":["../../../projects/blocks/effects/directives/surface.directive.ts","../../../projects/blocks/effects/component-surface.ts","../../../projects/blocks/effects/lighting.service.ts"],"sourcesContent":["import { isPlatformBrowser } from '@angular/common';\nimport { AfterViewInit, booleanAttribute, DestroyRef, Directive, effect, ElementRef, inject, input, NgZone, numberAttribute, PLATFORM_ID } from '@angular/core';\nimport { BxA11yService, ThemingService } from '@filip.mazev/blocks/core';\nimport { mountSurface, SurfaceOptions } from '@filip.mazev/blocks/effects/runtime';\n\n/** Adds a decorative material without replacing native controls or their content. */\n@Directive({\n selector: '[bxSurface]',\n standalone: true,\n exportAs: 'bxSurface'\n})\nexport class BxSurfaceDirective implements AfterViewInit {\n private readonly element = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly theme = inject(ThemingService);\n private readonly a11y = inject(BxA11yService);\n private readonly zone = inject(NgZone);\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n public readonly bxSurfaceInteractive = input<boolean | undefined, unknown>(undefined, { transform: optionalBoolean });\n public readonly bxSurfaceGlassiness = input<number | undefined, unknown>(undefined, { transform: optionalNumber });\n public readonly bxSurfaceEmission = input<string | undefined>();\n public readonly bxSurfaceFocusEmission = input<string | undefined>();\n public readonly bxReducedTransparency = input<boolean | undefined, unknown>(undefined, {\n transform: optionalBoolean\n });\n\n private surface?: ReturnType<typeof mountSurface>;\n\n constructor() {\n effect(() => {\n const options = this.options();\n this.zone.runOutsideAngular(() => this.surface?.update(options));\n });\n\n inject(DestroyRef).onDestroy(() => {\n this.surface?.destroy();\n this.surface = undefined;\n });\n }\n\n public ngAfterViewInit(): void {\n if (this.isBrowser) {\n const options = this.options();\n this.surface = this.zone.runOutsideAngular(() => mountSurface(this.element.nativeElement, options));\n }\n }\n\n private options(): SurfaceOptions {\n return {\n glassiness: this.bxSurfaceGlassiness(),\n interactive: this.bxSurfaceInteractive(),\n reducedMotion: this.a11y.isReducedMotion(),\n reducedTransparency: this.bxReducedTransparency(),\n emission: this.bxSurfaceEmission(),\n focusEmission: this.bxSurfaceFocusEmission()\n };\n }\n}\n\nfunction optionalNumber(value: unknown): number | undefined {\n return value === undefined || value === null ? undefined : numberAttribute(value);\n}\n\nfunction optionalBoolean(value: unknown): boolean | undefined {\n return value === undefined || value === null ? undefined : booleanAttribute(value);\n}\n","import { isPlatformBrowser } from '@angular/common';\nimport { afterNextRender, DestroyRef, effect, ElementRef, inject, NgZone, PLATFORM_ID } from '@angular/core';\nimport { BxA11yService, ThemingService } from '@filip.mazev/blocks/core';\nimport { mountSurface, SurfaceOptions } from '@filip.mazev/blocks/effects/runtime';\n\n/** Internal component integration. An explicit bxSurface directive takes precedence. */\nexport function injectComponentSurface(options: () => SurfaceOptions = () => ({})): void {\n const element = inject<ElementRef<HTMLElement>>(ElementRef);\n const zone = inject(NgZone);\n const a11y = inject(BxA11yService);\n inject(ThemingService);\n let surface: ReturnType<typeof mountSurface> | undefined;\n const browser = isPlatformBrowser(inject(PLATFORM_ID));\n
|
|
1
|
+
{"version":3,"file":"filip.mazev-blocks-effects.mjs","names":[],"sources":["../../../projects/blocks/effects/directives/surface.directive.ts","../../../projects/blocks/effects/component-surface.ts","../../../projects/blocks/effects/lighting.service.ts"],"sourcesContent":["import { isPlatformBrowser } from '@angular/common';\nimport { AfterViewInit, booleanAttribute, DestroyRef, Directive, effect, ElementRef, inject, input, NgZone, numberAttribute, PLATFORM_ID } from '@angular/core';\nimport { BxA11yService, ThemingService } from '@filip.mazev/blocks/core';\nimport { mountSurface, SurfaceOptions } from '@filip.mazev/blocks/effects/runtime';\n\n/** Adds a decorative material without replacing native controls or their content. */\n@Directive({\n selector: '[bxSurface]',\n standalone: true,\n exportAs: 'bxSurface'\n})\nexport class BxSurfaceDirective implements AfterViewInit {\n private readonly element = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly theme = inject(ThemingService);\n private readonly a11y = inject(BxA11yService);\n private readonly zone = inject(NgZone);\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n public readonly bxSurfaceInteractive = input<boolean | undefined, unknown>(undefined, { transform: optionalBoolean });\n public readonly bxSurfaceGlassiness = input<number | undefined, unknown>(undefined, { transform: optionalNumber });\n public readonly bxSurfaceEmission = input<string | undefined>();\n public readonly bxSurfaceFocusEmission = input<string | undefined>();\n public readonly bxReducedTransparency = input<boolean | undefined, unknown>(undefined, {\n transform: optionalBoolean\n });\n\n private surface?: ReturnType<typeof mountSurface>;\n\n constructor() {\n effect(() => {\n const options = this.options();\n this.zone.runOutsideAngular(() => this.surface?.update(options));\n });\n\n inject(DestroyRef).onDestroy(() => {\n this.surface?.destroy();\n this.surface = undefined;\n });\n }\n\n public ngAfterViewInit(): void {\n if (this.isBrowser) {\n const options = this.options();\n this.surface = this.zone.runOutsideAngular(() => mountSurface(this.element.nativeElement, options));\n }\n }\n\n private options(): SurfaceOptions {\n return {\n glassiness: this.bxSurfaceGlassiness(),\n interactive: this.bxSurfaceInteractive(),\n reducedMotion: this.a11y.isReducedMotion(),\n reducedTransparency: this.bxReducedTransparency(),\n emission: this.bxSurfaceEmission(),\n focusEmission: this.bxSurfaceFocusEmission()\n };\n }\n}\n\nfunction optionalNumber(value: unknown): number | undefined {\n return value === undefined || value === null ? undefined : numberAttribute(value);\n}\n\nfunction optionalBoolean(value: unknown): boolean | undefined {\n return value === undefined || value === null ? undefined : booleanAttribute(value);\n}\n","import { isPlatformBrowser } from '@angular/common';\nimport { afterNextRender, DestroyRef, effect, ElementRef, inject, NgZone, PLATFORM_ID } from '@angular/core';\nimport { BxA11yService, ThemingService } from '@filip.mazev/blocks/core';\nimport { mountSurface, SurfaceOptions } from '@filip.mazev/blocks/effects/runtime';\n\n/** Internal component integration. An explicit bxSurface directive takes precedence. */\nexport function injectComponentSurface(options: () => SurfaceOptions = () => ({}), enabled: () => boolean = () => true): void {\n const element = inject<ElementRef<HTMLElement>>(ElementRef);\n const zone = inject(NgZone);\n const a11y = inject(BxA11yService);\n inject(ThemingService);\n let surface: ReturnType<typeof mountSurface> | undefined;\n let rendered = false;\n const browser = isPlatformBrowser(inject(PLATFORM_ID));\n const sync = () => {\n const current = { ...options(), reducedMotion: a11y.isReducedMotion() };\n const active = enabled();\n\n if (!browser || !rendered) return;\n\n zone.runOutsideAngular(() => {\n if (!active) {\n surface?.destroy();\n surface = undefined;\n } else if (surface) surface.update(current);\n else if (!element.nativeElement.hasAttribute('data-bx-surface')) surface = mountSurface(element.nativeElement, current);\n });\n };\n effect(sync);\n afterNextRender(() => {\n rendered = true;\n sync();\n });\n inject(DestroyRef).onDestroy(() => surface?.destroy());\n}\n","import { Injectable, NgZone, inject } from '@angular/core';\nimport { GlassLight, GlassScene, mountGlassScene } from '@filip.mazev/blocks/effects/runtime';\n\nexport interface BxGlassLight {\n update(light: GlassLight): void;\n destroy(): void;\n}\n\n/** Combine local semantic emitters without replacing another field's or toast's light. */\n@Injectable({ providedIn: 'root' })\nexport class BxGlassLightingService {\n private readonly zone = inject(NgZone);\n private readonly groups = new Map<HTMLElement, { scene: GlassScene; lights: Map<symbol, GlassLight> }>();\n\n public register(root: HTMLElement, light: GlassLight): BxGlassLight {\n let group = this.groups.get(root);\n if (!group) {\n group = { scene: this.zone.runOutsideAngular(() => mountGlassScene(root)), lights: new Map() };\n this.groups.set(root, group);\n }\n const current = group;\n const id = Symbol();\n let disposed = false;\n const sync = () => this.zone.runOutsideAngular(() => current.scene.update({ lights: [...current.lights.values()] }));\n current.lights.set(id, light);\n sync();\n return {\n update: (next) => {\n if (!disposed) {\n current.lights.set(id, next);\n sync();\n }\n },\n destroy: () => {\n if (disposed) return;\n disposed = true;\n current.lights.delete(id);\n if (current.lights.size) sync();\n else {\n this.zone.runOutsideAngular(() => current.scene.destroy());\n this.groups.delete(root);\n }\n }\n };\n }\n}\n"],"mappings":";;;;;AAWA,IAAa,qBAAb,MAAa,mBAAkB;CACZ,UAAU,OAAgC,UAAU;CACpD,QAAQ,OAAO,cAAc;CAC7B,OAAO,OAAO,aAAa;CAC3B,OAAO,OAAO,MAAM;CACpB,YAAY,kBAAkB,OAAO,WAAW,CAAC;CAClD,uBAAuB,MAAoC,QAAS;EAAA,GAAA,YAAA,EAAA,WAAA,uBAAA,+BAAA,CAAA;EAAI,WAAW;CAAe,CAAA;CAClG,sBAAsB,MAAmC,QAAS;EAAA,GAAA,YAAA,EAAA,WAAA,sBAAA,+BAAA,CAAA;EAAI,WAAW;CAAc,CAAA;CAC/F,oBAAoB,MAA2B,GAAA,YAAA,CAAA,Q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