@wirekyt/angular 0.0.2 → 0.0.4

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.
@@ -0,0 +1,247 @@
1
+ import * as collapsible from '@wirekyt/dom/machines/collapsible';
2
+ export { anatomy as collapsibleAnatomy } from '@wirekyt/dom/machines/collapsible';
3
+ import * as i0 from '@angular/core';
4
+ import { InjectionToken, inject, signal, effect, computed, input, output, booleanAttribute, EnvironmentInjector, Injector, DestroyRef, Renderer2, ElementRef, forwardRef, Directive, TemplateRef, ViewContainerRef } from '@angular/core';
5
+ import { injectLocale, injectEnvironment, createId, useMachine, buildRootCarrier, bindProps } from '@wirekyt/angular';
6
+
7
+ const COLLAPSIBLE_CONTEXT = new InjectionToken("WIREKIT.COLLAPSIBLE_CONTEXT");
8
+ function injectCollapsibleContext() {
9
+ return inject(COLLAPSIBLE_CONTEXT);
10
+ }
11
+
12
+ function useCollapsible(options) {
13
+ const locale = injectLocale();
14
+ const environment = injectEnvironment();
15
+ const fallbackId = createId();
16
+ const wasVisible = signal(false, /* @ts-ignore */
17
+ ...(ngDevMode ? [{ debugName: "wasVisible" }] : /* istanbul ignore next */ []));
18
+ const machine = useMachine({
19
+ machine: collapsible.machine,
20
+ context: () => {
21
+ const props = options.context();
22
+ const { lazyMount: _lazyMount, unmountOnExit: _unmountOnExit, ...collapsibleProps } = props;
23
+ return {
24
+ ...collapsibleProps,
25
+ dir: locale.dir,
26
+ getRootNode: environment.getRootNode,
27
+ id: collapsibleProps.id ?? fallbackId,
28
+ };
29
+ },
30
+ connect: (service, normalize) => collapsible.connect(service, normalize),
31
+ });
32
+ effect(() => {
33
+ if (machine.api().visible) {
34
+ wasVisible.set(true);
35
+ }
36
+ });
37
+ const isUnmounted = computed(() => {
38
+ const { lazyMount, unmountOnExit } = options.context();
39
+ const visible = machine.api().visible;
40
+ return Boolean((!visible && !wasVisible() && lazyMount) || (unmountOnExit && !visible && wasVisible()));
41
+ }, /* @ts-ignore */
42
+ ...(ngDevMode ? [{ debugName: "isUnmounted" }] : /* istanbul ignore next */ []));
43
+ return {
44
+ ...machine,
45
+ isUnmounted,
46
+ };
47
+ }
48
+
49
+ class CollapsibleRoot {
50
+ id = input(undefined, /* @ts-ignore */
51
+ ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
52
+ ids = input(undefined, /* @ts-ignore */
53
+ ...(ngDevMode ? [{ debugName: "ids" }] : /* istanbul ignore next */ []));
54
+ open = input(undefined, /* @ts-ignore */
55
+ ...(ngDevMode ? [{ debugName: "open" }] : /* istanbul ignore next */ []));
56
+ openChange = output();
57
+ defaultOpen = input(false, { ...(ngDevMode ? { debugName: "defaultOpen" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
58
+ disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
59
+ collapsedHeight = input(undefined, /* @ts-ignore */
60
+ ...(ngDevMode ? [{ debugName: "collapsedHeight" }] : /* istanbul ignore next */ []));
61
+ collapsedWidth = input(undefined, /* @ts-ignore */
62
+ ...(ngDevMode ? [{ debugName: "collapsedWidth" }] : /* istanbul ignore next */ []));
63
+ lazyMount = input(false, { ...(ngDevMode ? { debugName: "lazyMount" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
64
+ unmountOnExit = input(false, { ...(ngDevMode ? { debugName: "unmountOnExit" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
65
+ exitComplete = output();
66
+ machine = useCollapsible({
67
+ context: () => ({
68
+ id: this.id(),
69
+ ids: this.ids(),
70
+ open: this.open(),
71
+ defaultOpen: this.defaultOpen(),
72
+ disabled: this.disabled(),
73
+ collapsedHeight: this.collapsedHeight(),
74
+ collapsedWidth: this.collapsedWidth(),
75
+ lazyMount: this.lazyMount(),
76
+ unmountOnExit: this.unmountOnExit(),
77
+ onOpenChange: (details) => {
78
+ this.openChange.emit(details);
79
+ },
80
+ onExitComplete: () => {
81
+ this.exitComplete.emit();
82
+ },
83
+ }),
84
+ });
85
+ state = this.machine.state;
86
+ api = this.machine.api;
87
+ isUnmounted = computed(() => this.machine.isUnmounted(), /* @ts-ignore */
88
+ ...(ngDevMode ? [{ debugName: "isUnmounted" }] : /* istanbul ignore next */ []));
89
+ service = this.machine.service;
90
+ send = this.machine.send;
91
+ arkContextCarrier = buildRootCarrier({
92
+ root: this,
93
+ rootToken: COLLAPSIBLE_CONTEXT,
94
+ originInjector: inject(Injector),
95
+ environmentInjector: inject(EnvironmentInjector),
96
+ });
97
+ constructor() {
98
+ bindProps({
99
+ elementRef: inject(ElementRef),
100
+ renderer: inject(Renderer2),
101
+ destroyRef: inject(DestroyRef),
102
+ props: () => this.api().getRootProps(),
103
+ });
104
+ }
105
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: CollapsibleRoot, deps: [], target: i0.ɵɵFactoryTarget.Directive });
106
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.1.0", type: CollapsibleRoot, isStandalone: true, selector: "[collapsibleRoot]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, ids: { classPropertyName: "ids", publicName: "ids", isSignal: true, isRequired: false, transformFunction: null }, open: { classPropertyName: "open", publicName: "open", isSignal: true, isRequired: false, transformFunction: null }, defaultOpen: { classPropertyName: "defaultOpen", publicName: "defaultOpen", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, collapsedHeight: { classPropertyName: "collapsedHeight", publicName: "collapsedHeight", isSignal: true, isRequired: false, transformFunction: null }, collapsedWidth: { classPropertyName: "collapsedWidth", publicName: "collapsedWidth", isSignal: true, isRequired: false, transformFunction: null }, lazyMount: { classPropertyName: "lazyMount", publicName: "lazyMount", isSignal: true, isRequired: false, transformFunction: null }, unmountOnExit: { classPropertyName: "unmountOnExit", publicName: "unmountOnExit", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { openChange: "openChange", exitComplete: "exitComplete" }, providers: [{ provide: COLLAPSIBLE_CONTEXT, useExisting: forwardRef(() => CollapsibleRoot) }], exportAs: ["collapsibleRoot"], ngImport: i0 });
107
+ }
108
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: CollapsibleRoot, decorators: [{
109
+ type: Directive,
110
+ args: [{
111
+ selector: "[collapsibleRoot]",
112
+ standalone: true,
113
+ exportAs: "collapsibleRoot",
114
+ providers: [{ provide: COLLAPSIBLE_CONTEXT, useExisting: forwardRef(() => CollapsibleRoot) }],
115
+ }]
116
+ }], ctorParameters: () => [], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], ids: [{ type: i0.Input, args: [{ isSignal: true, alias: "ids", required: false }] }], open: [{ type: i0.Input, args: [{ isSignal: true, alias: "open", required: false }] }], openChange: [{ type: i0.Output, args: ["openChange"] }], defaultOpen: [{ type: i0.Input, args: [{ isSignal: true, alias: "defaultOpen", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], collapsedHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "collapsedHeight", required: false }] }], collapsedWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "collapsedWidth", required: false }] }], lazyMount: [{ type: i0.Input, args: [{ isSignal: true, alias: "lazyMount", required: false }] }], unmountOnExit: [{ type: i0.Input, args: [{ isSignal: true, alias: "unmountOnExit", required: false }] }], exitComplete: [{ type: i0.Output, args: ["exitComplete"] }] } });
117
+
118
+ class CollapsibleRootProvider {
119
+ value = input.required(/* @ts-ignore */
120
+ ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
121
+ state = computed(() => this.value().state(), /* @ts-ignore */
122
+ ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
123
+ api = computed(() => this.value().api(), /* @ts-ignore */
124
+ ...(ngDevMode ? [{ debugName: "api" }] : /* istanbul ignore next */ []));
125
+ isUnmounted = computed(() => this.value().isUnmounted(), /* @ts-ignore */
126
+ ...(ngDevMode ? [{ debugName: "isUnmounted" }] : /* istanbul ignore next */ []));
127
+ send = (event) => this.value().send(event);
128
+ get service() {
129
+ return this.value().service;
130
+ }
131
+ constructor() {
132
+ bindProps({
133
+ elementRef: inject(ElementRef),
134
+ renderer: inject(Renderer2),
135
+ destroyRef: inject(DestroyRef),
136
+ props: () => this.api().getRootProps(),
137
+ });
138
+ }
139
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: CollapsibleRootProvider, deps: [], target: i0.ɵɵFactoryTarget.Directive });
140
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.1.0", type: CollapsibleRootProvider, isStandalone: true, selector: "[collapsibleRootProvider]", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: true, transformFunction: null } }, providers: [
141
+ { provide: COLLAPSIBLE_CONTEXT, useExisting: forwardRef(() => CollapsibleRootProvider) },
142
+ ], exportAs: ["collapsibleRootProvider"], ngImport: i0 });
143
+ }
144
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: CollapsibleRootProvider, decorators: [{
145
+ type: Directive,
146
+ args: [{
147
+ selector: "[collapsibleRootProvider]",
148
+ standalone: true,
149
+ exportAs: "collapsibleRootProvider",
150
+ providers: [
151
+ { provide: COLLAPSIBLE_CONTEXT, useExisting: forwardRef(() => CollapsibleRootProvider) },
152
+ ],
153
+ }]
154
+ }], ctorParameters: () => [], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: true }] }] } });
155
+
156
+ class CollapsibleTrigger {
157
+ constructor() {
158
+ const context = injectCollapsibleContext();
159
+ bindProps({
160
+ elementRef: inject(ElementRef),
161
+ renderer: inject(Renderer2),
162
+ destroyRef: inject(DestroyRef),
163
+ props: () => context.api().getTriggerProps(),
164
+ });
165
+ }
166
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: CollapsibleTrigger, deps: [], target: i0.ɵɵFactoryTarget.Directive });
167
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.1.0", type: CollapsibleTrigger, isStandalone: true, selector: "[collapsibleTrigger]", exportAs: ["collapsibleTrigger"], ngImport: i0 });
168
+ }
169
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: CollapsibleTrigger, decorators: [{
170
+ type: Directive,
171
+ args: [{
172
+ selector: "[collapsibleTrigger]",
173
+ standalone: true,
174
+ exportAs: "collapsibleTrigger",
175
+ }]
176
+ }], ctorParameters: () => [] });
177
+
178
+ class CollapsibleContent {
179
+ context = injectCollapsibleContext();
180
+ template = inject((TemplateRef));
181
+ viewContainer = inject(ViewContainerRef);
182
+ elementRef = { nativeElement: null };
183
+ view;
184
+ constructor() {
185
+ effect(() => {
186
+ if (this.context.isUnmounted()) {
187
+ this.elementRef.nativeElement = null;
188
+ this.viewContainer.clear();
189
+ this.view = undefined;
190
+ return;
191
+ }
192
+ if (!this.view) {
193
+ this.view = this.viewContainer.createEmbeddedView(this.template);
194
+ this.elementRef.nativeElement =
195
+ this.view.rootNodes.find((node) => node.nodeType === 1) ?? null;
196
+ }
197
+ });
198
+ bindProps({
199
+ elementRef: this.elementRef,
200
+ renderer: inject(Renderer2),
201
+ destroyRef: inject(DestroyRef),
202
+ props: () => {
203
+ this.context.isUnmounted();
204
+ return this.context.api().getContentProps();
205
+ },
206
+ });
207
+ }
208
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: CollapsibleContent, deps: [], target: i0.ɵɵFactoryTarget.Directive });
209
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.1.0", type: CollapsibleContent, isStandalone: true, selector: "[collapsibleContent]", exportAs: ["collapsibleContent"], ngImport: i0 });
210
+ }
211
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: CollapsibleContent, decorators: [{
212
+ type: Directive,
213
+ args: [{
214
+ selector: "[collapsibleContent]",
215
+ standalone: true,
216
+ exportAs: "collapsibleContent",
217
+ }]
218
+ }], ctorParameters: () => [] });
219
+
220
+ class CollapsibleIndicator {
221
+ constructor() {
222
+ const context = injectCollapsibleContext();
223
+ bindProps({
224
+ elementRef: inject(ElementRef),
225
+ renderer: inject(Renderer2),
226
+ destroyRef: inject(DestroyRef),
227
+ props: () => context.api().getIndicatorProps(),
228
+ });
229
+ }
230
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: CollapsibleIndicator, deps: [], target: i0.ɵɵFactoryTarget.Directive });
231
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.1.0", type: CollapsibleIndicator, isStandalone: true, selector: "[collapsibleIndicator]", exportAs: ["collapsibleIndicator"], ngImport: i0 });
232
+ }
233
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: CollapsibleIndicator, decorators: [{
234
+ type: Directive,
235
+ args: [{
236
+ selector: "[collapsibleIndicator]",
237
+ standalone: true,
238
+ exportAs: "collapsibleIndicator",
239
+ }]
240
+ }], ctorParameters: () => [] });
241
+
242
+ /**
243
+ * Generated bundle index. Do not edit.
244
+ */
245
+
246
+ export { COLLAPSIBLE_CONTEXT, CollapsibleContent, CollapsibleIndicator, CollapsibleRoot, CollapsibleRootProvider, CollapsibleTrigger, injectCollapsibleContext, useCollapsible };
247
+ //# sourceMappingURL=wirekyt-angular-collapsible.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wirekyt-angular-collapsible.mjs","sources":["../../src/components/collapsible/use-context.ts","../../src/components/collapsible/use.ts","../../src/components/collapsible/root.ts","../../src/components/collapsible/root-provider.ts","../../src/components/collapsible/trigger.ts","../../src/components/collapsible/content.ts","../../src/components/collapsible/indicator.ts","../../src/components/collapsible/wirekyt-angular-collapsible.ts"],"sourcesContent":["import { InjectionToken, inject } from \"@angular/core\";\n\nimport type { UseCollapsibleReturn } from \"./use\";\n\nexport const COLLAPSIBLE_CONTEXT = new InjectionToken<UseCollapsibleReturn>(\n \"WIREKIT.COLLAPSIBLE_CONTEXT\",\n);\n\nexport function injectCollapsibleContext(): UseCollapsibleReturn {\n return inject(COLLAPSIBLE_CONTEXT);\n}\n","import { computed, effect, signal, type Signal } from \"@angular/core\";\nimport { useMachine, UseMachineReturn } from \"@wirekyt/angular\";\nimport { createId, injectEnvironment, injectLocale } from \"@wirekyt/angular\";\nimport { Machine } from \"@wirekyt/dom\";\nimport * as collapsible from \"@wirekyt/dom/machines/collapsible\";\n\ntype OptionalId<T extends { id: string }> = Omit<T, \"id\"> & { id?: string };\n\nexport interface UseCollapsibleProps extends OptionalId<\n Omit<collapsible.Props, \"dir\" | \"getRootNode\">\n> {\n lazyMount?: boolean;\n unmountOnExit?: boolean;\n}\n\nexport interface UseCollapsibleReturn extends UseMachineReturn<\n collapsible.Service[\"state\"],\n collapsible.Api,\n collapsible.Service\n> {\n readonly isUnmounted: Signal<boolean>;\n}\n\nexport interface UseCollapsibleOptions {\n context: () => UseCollapsibleProps;\n}\n\ntype CollapsibleContext = Record<string, unknown>;\ntype CollapsibleSchema = collapsible.Machine extends Machine<infer TSchema> ? TSchema : never;\n\nexport function useCollapsible(options: UseCollapsibleOptions): UseCollapsibleReturn {\n const locale = injectLocale();\n const environment = injectEnvironment();\n const fallbackId = createId();\n const wasVisible = signal(false);\n\n const machine = useMachine<CollapsibleSchema, collapsible.Api>({\n machine: collapsible.machine,\n context: () => {\n const props = options.context();\n const { lazyMount: _lazyMount, unmountOnExit: _unmountOnExit, ...collapsibleProps } = props;\n return {\n ...collapsibleProps,\n dir: locale.dir,\n getRootNode: environment.getRootNode,\n id: collapsibleProps.id ?? fallbackId,\n } as CollapsibleContext;\n },\n connect: (service, normalize) => collapsible.connect(service, normalize),\n });\n\n effect(() => {\n if (machine.api().visible) {\n wasVisible.set(true);\n }\n });\n\n const isUnmounted = computed(() => {\n const { lazyMount, unmountOnExit } = options.context();\n const visible = machine.api().visible;\n return Boolean(\n (!visible && !wasVisible() && lazyMount) || (unmountOnExit && !visible && wasVisible()),\n );\n });\n\n return {\n ...machine,\n isUnmounted,\n };\n}\n","import type * as collapsible from \"@wirekyt/dom/machines/collapsible\";\n\nimport {\n DestroyRef,\n Directive,\n ElementRef,\n EnvironmentInjector,\n Injector,\n type ProviderToken,\n Renderer2,\n booleanAttribute,\n computed,\n forwardRef,\n inject,\n input,\n output,\n type InputSignal,\n type InputSignalWithTransform,\n type OutputEmitterRef,\n type Signal,\n} from \"@angular/core\";\nimport { bindProps, buildRootCarrier, ContextCarrier } from \"@wirekyt/angular\";\n\nimport { CollapsibleElementIds } from \"./types\";\nimport { useCollapsible, UseCollapsibleReturn } from \"./use\";\nimport { COLLAPSIBLE_CONTEXT } from \"./use-context\";\n\n@Directive({\n selector: \"[collapsibleRoot]\",\n standalone: true,\n exportAs: \"collapsibleRoot\",\n providers: [{ provide: COLLAPSIBLE_CONTEXT, useExisting: forwardRef(() => CollapsibleRoot) }],\n})\nexport class CollapsibleRoot implements UseCollapsibleReturn {\n readonly id: InputSignal<string | undefined> = input<string | undefined>(undefined);\n readonly ids: InputSignal<Partial<CollapsibleElementIds> | undefined> = input<\n Partial<CollapsibleElementIds> | undefined\n >(undefined);\n readonly open: InputSignal<boolean | undefined> = input<boolean | undefined>(undefined);\n readonly openChange: OutputEmitterRef<collapsible.OpenChangeDetails> =\n output<collapsible.OpenChangeDetails>();\n readonly defaultOpen: InputSignalWithTransform<boolean, unknown> = input(false, {\n transform: booleanAttribute,\n });\n readonly disabled: InputSignalWithTransform<boolean, unknown> = input(false, {\n transform: booleanAttribute,\n });\n readonly collapsedHeight: InputSignal<number | string | undefined> = input<\n number | string | undefined\n >(undefined);\n readonly collapsedWidth: InputSignal<number | string | undefined> = input<\n number | string | undefined\n >(undefined);\n readonly lazyMount: InputSignalWithTransform<boolean, unknown> = input(false, {\n transform: booleanAttribute,\n });\n readonly unmountOnExit: InputSignalWithTransform<boolean, unknown> = input(false, {\n transform: booleanAttribute,\n });\n readonly exitComplete: OutputEmitterRef<void> = output<void>();\n\n private readonly machine = useCollapsible({\n context: () => ({\n id: this.id(),\n ids: this.ids(),\n open: this.open(),\n defaultOpen: this.defaultOpen(),\n disabled: this.disabled(),\n collapsedHeight: this.collapsedHeight(),\n collapsedWidth: this.collapsedWidth(),\n lazyMount: this.lazyMount(),\n unmountOnExit: this.unmountOnExit(),\n onOpenChange: (details) => {\n this.openChange.emit(details);\n },\n onExitComplete: () => {\n this.exitComplete.emit();\n },\n }),\n });\n\n readonly state: Signal<collapsible.Service[\"state\"]> = this.machine.state;\n readonly api: Signal<collapsible.Api> = this.machine.api;\n readonly isUnmounted: Signal<boolean> = computed(() => this.machine.isUnmounted());\n readonly service: collapsible.Service = this.machine.service;\n readonly send: collapsible.Service[\"send\"] = this.machine.send;\n\n protected readonly arkContextCarrier: ContextCarrier<CollapsibleRoot> =\n buildRootCarrier<CollapsibleRoot>({\n root: this,\n rootToken: COLLAPSIBLE_CONTEXT as ProviderToken<CollapsibleRoot>,\n originInjector: inject(Injector),\n environmentInjector: inject(EnvironmentInjector),\n });\n\n constructor() {\n bindProps({\n elementRef: inject(ElementRef),\n renderer: inject(Renderer2),\n destroyRef: inject(DestroyRef),\n props: () => this.api().getRootProps(),\n });\n }\n}\n","import type * as collapsible from \"@wirekyt/dom/machines/collapsible\";\n\nimport {\n DestroyRef,\n Directive,\n ElementRef,\n Renderer2,\n type InputSignal,\n type Signal,\n computed,\n forwardRef,\n inject,\n input,\n} from \"@angular/core\";\nimport { bindProps } from \"@wirekyt/angular\";\n\nimport { UseCollapsibleReturn } from \"./use\";\nimport { COLLAPSIBLE_CONTEXT } from \"./use-context\";\n\n@Directive({\n selector: \"[collapsibleRootProvider]\",\n standalone: true,\n exportAs: \"collapsibleRootProvider\",\n providers: [\n { provide: COLLAPSIBLE_CONTEXT, useExisting: forwardRef(() => CollapsibleRootProvider) },\n ],\n})\nexport class CollapsibleRootProvider implements UseCollapsibleReturn {\n readonly value: InputSignal<UseCollapsibleReturn> = input.required<UseCollapsibleReturn>();\n readonly state: Signal<collapsible.Service[\"state\"]> = computed(() => this.value().state());\n readonly api: Signal<collapsible.Api> = computed(() => this.value().api());\n readonly isUnmounted: Signal<boolean> = computed(() => this.value().isUnmounted());\n readonly send: collapsible.Service[\"send\"] = (event) => this.value().send(event);\n\n get service(): collapsible.Service {\n return this.value().service;\n }\n\n constructor() {\n bindProps({\n elementRef: inject(ElementRef),\n renderer: inject(Renderer2),\n destroyRef: inject(DestroyRef),\n props: () => this.api().getRootProps(),\n });\n }\n}\n","import { DestroyRef, Directive, ElementRef, Renderer2, inject } from \"@angular/core\";\nimport { bindProps } from \"@wirekyt/angular\";\n\nimport { injectCollapsibleContext } from \"./use-context\";\n\n@Directive({\n selector: \"[collapsibleTrigger]\",\n standalone: true,\n exportAs: \"collapsibleTrigger\",\n})\nexport class CollapsibleTrigger {\n constructor() {\n const context = injectCollapsibleContext();\n bindProps({\n elementRef: inject(ElementRef),\n renderer: inject(Renderer2),\n destroyRef: inject(DestroyRef),\n props: () => context.api().getTriggerProps(),\n });\n }\n}\n","import {\n DestroyRef,\n Directive,\n ElementRef,\n EmbeddedViewRef,\n Renderer2,\n TemplateRef,\n ViewContainerRef,\n effect,\n inject,\n} from \"@angular/core\";\nimport { bindProps } from \"@wirekyt/angular\";\n\nimport { injectCollapsibleContext } from \"./use-context\";\n\n@Directive({\n selector: \"[collapsibleContent]\",\n standalone: true,\n exportAs: \"collapsibleContent\",\n})\nexport class CollapsibleContent {\n private readonly context = injectCollapsibleContext();\n private readonly template = inject(TemplateRef<unknown>);\n private readonly viewContainer = inject(ViewContainerRef);\n private readonly elementRef = { nativeElement: null as HTMLElement | null };\n private view: EmbeddedViewRef<unknown> | undefined;\n\n constructor() {\n effect(() => {\n if (this.context.isUnmounted()) {\n this.elementRef.nativeElement = null;\n this.viewContainer.clear();\n this.view = undefined;\n return;\n }\n\n if (!this.view) {\n this.view = this.viewContainer.createEmbeddedView(this.template);\n this.elementRef.nativeElement =\n this.view.rootNodes.find((node: Node) => node.nodeType === 1) ?? null;\n }\n });\n\n bindProps({\n elementRef: this.elementRef as ElementRef<HTMLElement>,\n renderer: inject(Renderer2),\n destroyRef: inject(DestroyRef),\n props: () => {\n this.context.isUnmounted();\n return this.context.api().getContentProps();\n },\n });\n }\n}\n","import { DestroyRef, Directive, ElementRef, Renderer2, inject } from \"@angular/core\";\nimport { bindProps } from \"@wirekyt/angular\";\n\nimport { injectCollapsibleContext } from \"./use-context\";\n\n@Directive({\n selector: \"[collapsibleIndicator]\",\n standalone: true,\n exportAs: \"collapsibleIndicator\",\n})\nexport class CollapsibleIndicator {\n constructor() {\n const context = injectCollapsibleContext();\n bindProps({\n elementRef: inject(ElementRef),\n renderer: inject(Renderer2),\n destroyRef: inject(DestroyRef),\n props: () => context.api().getIndicatorProps(),\n });\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;MAIa,mBAAmB,GAAG,IAAI,cAAc,CACnD,6BAA6B;SAGf,wBAAwB,GAAA;AACtC,IAAA,OAAO,MAAM,CAAC,mBAAmB,CAAC;AACpC;;ACoBM,SAAU,cAAc,CAAC,OAA8B,EAAA;AAC3D,IAAA,MAAM,MAAM,GAAG,YAAY,EAAE;AAC7B,IAAA,MAAM,WAAW,GAAG,iBAAiB,EAAE;AACvC,IAAA,MAAM,UAAU,GAAG,QAAQ,EAAE;AAC7B,IAAA,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK;mFAAC;IAEhC,MAAM,OAAO,GAAG,UAAU,CAAqC;QAC7D,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AAA;2FAApB,oBAAoB,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,wBAAA,EAAA,QAAA,EAAA,CAAA,sBAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA;;2FAApB,oBAAoB,EAAA,UAAA,EAAA,CAAA;kBALhC,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,wBAAwB;AAClC,oBAAA,UAAU,EAAE,IAAI;AAChB,oBAAA,QAAQ,EAAE,sBAAsB;AACjC,iBAAA;;;ACTD;;AAEG;;;;"}
@@ -1,8 +1,10 @@
1
1
  import { createScope, MachineStatus, hasTag, matchesState, getExitEnterStates, INIT_STATE, resolveStateValue, findTransition } from '@wirekyt/dom';
2
2
  export { mergeProps } from '@wirekyt/dom';
3
- import { RendererStyleFlags2, effect, inject, DestroyRef, signal, computed, untracked, afterNextRender } from '@angular/core';
3
+ import * as i0 from '@angular/core';
4
+ import { RendererStyleFlags2, effect, inject, DestroyRef, signal, computed, untracked, afterNextRender, InjectionToken, PLATFORM_ID, Injectable, createComponent, Injector, isDevMode } from '@angular/core';
4
5
  import { compact, isFunction, toArray, warn, isString, ensure, isEqual, callAll } from '@wirekyt/dom/utils';
5
6
  import { createNormalizer } from '@wirekyt/dom/types';
7
+ import { isPlatformBrowser, DOCUMENT } from '@angular/common';
6
8
 
7
9
  const isAttributeKey = (key) => key === "role" ||
8
10
  key === "id" ||
@@ -98,6 +100,7 @@ const computeStyleMap = (value) => {
98
100
  function bindProps(options) {
99
101
  const { elementRef, renderer, destroyRef } = options;
100
102
  let prev = {};
103
+ let prevElement = null;
101
104
  const listeners = new Map();
102
105
  const appliedClasses = new Set();
103
106
  const appliedStyles = new Set();
@@ -155,11 +158,29 @@ function bindProps(options) {
155
158
  }
156
159
  appliedStyles.clear();
157
160
  };
161
+ const resetElement = (el) => {
162
+ for (const { dispose } of listeners.values())
163
+ dispose();
164
+ listeners.clear();
165
+ if (el) {
166
+ removeAllClasses(el);
167
+ removeAllStyles(el);
168
+ }
169
+ else {
170
+ appliedClasses.clear();
171
+ appliedStyles.clear();
172
+ }
173
+ prev = {};
174
+ };
158
175
  effect(() => {
159
176
  const el = elementRef.nativeElement;
177
+ const next = (options.props() ?? {});
178
+ if (el !== prevElement) {
179
+ resetElement(prevElement);
180
+ prevElement = el;
181
+ }
160
182
  if (!el)
161
183
  return;
162
- const next = (options.props() ?? {});
163
184
  for (const key of Object.keys(next)) {
164
185
  const nextValue = next[key];
165
186
  const prevValue = prev[key];
@@ -191,7 +212,8 @@ function bindProps(options) {
191
212
  continue;
192
213
  }
193
214
  if (isAttributeKey(key)) {
194
- if (nextValue == null || nextValue === false) {
215
+ const remove = nextValue == null || (nextValue === false && !key.startsWith("aria-"));
216
+ if (remove) {
195
217
  if (prevValue !== undefined && prevValue !== null && prevValue !== false) {
196
218
  removeAttribute(el, key);
197
219
  }
@@ -238,16 +260,8 @@ function bindProps(options) {
238
260
  prev = { ...next };
239
261
  });
240
262
  destroyRef.onDestroy(() => {
241
- const el = elementRef.nativeElement;
242
- for (const { dispose } of listeners.values()) {
243
- dispose();
244
- }
245
- listeners.clear();
246
- if (el) {
247
- removeAllClasses(el);
248
- removeAllStyles(el);
249
- }
250
- prev = {};
263
+ resetElement(prevElement);
264
+ prevElement = null;
251
265
  });
252
266
  }
253
267
 
@@ -706,9 +720,293 @@ function useMachine(options) {
706
720
  };
707
721
  }
708
722
 
723
+ const ENVIRONMENT_TOKEN = new InjectionToken("WIREKIT.ENVIRONMENT_TOKEN");
724
+ const createDefaultContext = (platformId) => ({
725
+ getRootNode: () => (isPlatformBrowser(platformId) ? document : undefined),
726
+ });
727
+ function provideEnvironment(config = {}) {
728
+ return {
729
+ provide: ENVIRONMENT_TOKEN,
730
+ useFactory: () => {
731
+ if (config.getRootNode) {
732
+ const getRootNode = config.getRootNode;
733
+ return { getRootNode };
734
+ }
735
+ const platformId = inject(PLATFORM_ID);
736
+ return createDefaultContext(platformId);
737
+ },
738
+ };
739
+ }
740
+ function injectEnvironment() {
741
+ const platformId = inject(PLATFORM_ID);
742
+ const ctx = inject(ENVIRONMENT_TOKEN, { optional: true });
743
+ return ctx ?? createDefaultContext(platformId);
744
+ }
745
+
746
+ const MODALITY_KEYS = new Set([
747
+ "Tab",
748
+ "ArrowUp",
749
+ "ArrowDown",
750
+ "ArrowLeft",
751
+ "ArrowRight",
752
+ "Enter",
753
+ "Escape",
754
+ " ",
755
+ ]);
756
+ function isModalityKey(key) {
757
+ return MODALITY_KEYS.has(key);
758
+ }
759
+ class InteractionService {
760
+ _modality = signal(null, /* @ts-ignore */
761
+ ...(ngDevMode ? [{ debugName: "_modality" }] : /* istanbul ignore next */ []));
762
+ modality = this._modality.asReadonly();
763
+ isFocusVisible = computed(() => this._modality() === "keyboard", /* @ts-ignore */
764
+ ...(ngDevMode ? [{ debugName: "isFocusVisible" }] : /* istanbul ignore next */ []));
765
+ constructor() {
766
+ const platformId = inject(PLATFORM_ID);
767
+ const document = inject(DOCUMENT);
768
+ const destroyRef = inject(DestroyRef);
769
+ if (!isPlatformBrowser(platformId))
770
+ return;
771
+ const onPointer = () => this._modality.set("pointer");
772
+ const onKey = (event) => {
773
+ if (isModalityKey(event.key))
774
+ this._modality.set("keyboard");
775
+ };
776
+ document.addEventListener("pointerdown", onPointer, true);
777
+ document.addEventListener("keydown", onKey, true);
778
+ destroyRef.onDestroy(() => {
779
+ document.removeEventListener("pointerdown", onPointer, true);
780
+ document.removeEventListener("keydown", onKey, true);
781
+ });
782
+ }
783
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: InteractionService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
784
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: InteractionService });
785
+ }
786
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: InteractionService, decorators: [{
787
+ type: Injectable
788
+ }], ctorParameters: () => [] });
789
+ const INTERACTION_TOKEN = new InjectionToken("WIREKIT.INTERACTION_TOKEN");
790
+ function provideInteraction() {
791
+ return [InteractionService, { provide: INTERACTION_TOKEN, useExisting: InteractionService }];
792
+ }
793
+ function injectInteraction() {
794
+ const ctx = inject(INTERACTION_TOKEN, { optional: true });
795
+ if (ctx)
796
+ return ctx;
797
+ return {
798
+ modality: signal(null).asReadonly(),
799
+ isFocusVisible: signal(false).asReadonly(),
800
+ };
801
+ }
802
+
803
+ const DEFAULT_LOCALE = "en-US";
804
+ const RTL_LANG_CODES = new Set([
805
+ "ae",
806
+ "ar",
807
+ "arc",
808
+ "bcc",
809
+ "bqi",
810
+ "ckb",
811
+ "dv",
812
+ "fa",
813
+ "glk",
814
+ "he",
815
+ "iw",
816
+ "khw",
817
+ "ks",
818
+ "ku",
819
+ "mzn",
820
+ "nqo",
821
+ "pnb",
822
+ "ps",
823
+ "sd",
824
+ "ug",
825
+ "ur",
826
+ "yi",
827
+ ]);
828
+ function getDirection(locale) {
829
+ const lang = locale.toLowerCase().split("-")[0] ?? "";
830
+ return RTL_LANG_CODES.has(lang) ? "rtl" : "ltr";
831
+ }
832
+ const LOCALE_TOKEN = new InjectionToken("WIREKYT.LOCALE_TOKEN");
833
+ function provideLocale(config = {}) {
834
+ return {
835
+ provide: LOCALE_TOKEN,
836
+ useFactory: () => {
837
+ const locale = config.locale ?? DEFAULT_LOCALE;
838
+ const dir = config.dir ?? getDirection(locale);
839
+ return { locale, dir };
840
+ },
841
+ };
842
+ }
843
+ function injectLocale() {
844
+ const ctx = inject(LOCALE_TOKEN, { optional: true });
845
+ return ctx ?? { locale: DEFAULT_LOCALE, dir: getDirection(DEFAULT_LOCALE) };
846
+ }
847
+ const collatorCache = new Map();
848
+ const dateFormatterCache = new Map();
849
+ const filterCache = new Map();
850
+ const MAX_CACHE_SIZE = 64;
851
+ const stableSerialize = (value) => {
852
+ if (value === null || typeof value !== "object")
853
+ return JSON.stringify(value);
854
+ if (Array.isArray(value))
855
+ return `[${value.map(stableSerialize).join(",")}]`;
856
+ const record = value;
857
+ return `{${Object.keys(record)
858
+ .sort()
859
+ .filter((key) => record[key] !== undefined)
860
+ .map((key) => `${JSON.stringify(key)}:${stableSerialize(record[key])}`)
861
+ .join(",")}}`;
862
+ };
863
+ const cacheKey = (locale, options) => `${locale}:${stableSerialize(options ?? {})}`;
864
+ const setCached = (cache, key, value) => {
865
+ if (!cache.has(key) && cache.size >= MAX_CACHE_SIZE) {
866
+ const oldest = cache.keys().next().value;
867
+ if (oldest !== undefined)
868
+ cache.delete(oldest);
869
+ }
870
+ cache.set(key, value);
871
+ };
872
+ function getCollator(locale, options) {
873
+ const key = cacheKey(locale, options);
874
+ let collator = collatorCache.get(key);
875
+ if (!collator) {
876
+ collator = new Intl.Collator(locale, options);
877
+ setCached(collatorCache, key, collator);
878
+ }
879
+ return collator;
880
+ }
881
+ function getDateFormatter(locale, options) {
882
+ const key = cacheKey(locale, options);
883
+ let formatter = dateFormatterCache.get(key);
884
+ if (!formatter) {
885
+ formatter = new Intl.DateTimeFormat(locale, options);
886
+ setCached(dateFormatterCache, key, formatter);
887
+ }
888
+ return formatter;
889
+ }
890
+ function getFilter(locale, options = { sensitivity: "base" }) {
891
+ const normalizedOptions = { ...options, usage: "search" };
892
+ const key = cacheKey(locale, normalizedOptions);
893
+ const cached = filterCache.get(key);
894
+ if (cached)
895
+ return cached;
896
+ const collator = getCollator(locale, normalizedOptions);
897
+ const filter = {
898
+ contains(s, sub) {
899
+ if (sub.length === 0)
900
+ return true;
901
+ for (let i = 0; i + sub.length <= s.length; i++) {
902
+ if (collator.compare(s.slice(i, i + sub.length), sub) === 0)
903
+ return true;
904
+ }
905
+ return false;
906
+ },
907
+ startsWith(s, sub) {
908
+ if (sub.length > s.length)
909
+ return false;
910
+ return collator.compare(s.slice(0, sub.length), sub) === 0;
911
+ },
912
+ endsWith(s, sub) {
913
+ if (sub.length > s.length)
914
+ return false;
915
+ return collator.compare(s.slice(s.length - sub.length), sub) === 0;
916
+ },
917
+ };
918
+ setCached(filterCache, key, filter);
919
+ return filter;
920
+ }
921
+
922
+ function createContextCarrier(options) {
923
+ return {
924
+ originInjector: options.originInjector,
925
+ environmentInjector: options.environmentInjector,
926
+ elementInjector: options.elementInjector,
927
+ root: options.root,
928
+ };
929
+ }
930
+ function createEmbeddedViewWithCarrier(viewContainer, template, carrier, context) {
931
+ return viewContainer.createEmbeddedView(template, context, {
932
+ injector: carrier.elementInjector,
933
+ });
934
+ }
935
+ function createComponentWithCarrier(component, carrier) {
936
+ return createComponent(component, {
937
+ environmentInjector: carrier.environmentInjector,
938
+ elementInjector: carrier.elementInjector,
939
+ });
940
+ }
941
+ function buildRootCarrier(options) {
942
+ const elementInjector = Injector.create({
943
+ parent: options.originInjector,
944
+ providers: [
945
+ { provide: options.rootToken, useValue: options.root },
946
+ ...(options.providers ?? []),
947
+ ],
948
+ });
949
+ return createContextCarrier({
950
+ originInjector: options.originInjector,
951
+ environmentInjector: options.environmentInjector,
952
+ elementInjector,
953
+ root: options.root,
954
+ });
955
+ }
956
+
957
+ const warnMixedFormAndModelBinding = (componentName) => {
958
+ if (!isDevMode())
959
+ return;
960
+ console.warn(`[@wyrekit/angular] ${componentName}: a form binding and [(value)] are both present on the same root. The form binding remains the source of truth.`);
961
+ };
962
+
963
+ const noopChange = (_value) => { };
964
+ const noopTouched = () => { };
965
+ const createCvaController = (options) => {
966
+ let onChange = noopChange;
967
+ let onTouched = noopTouched;
968
+ let warned = false;
969
+ const maybeWarn = () => {
970
+ if (warned)
971
+ return;
972
+ if (!options.hasExternalModelBinding())
973
+ return;
974
+ warned = true;
975
+ warnMixedFormAndModelBinding(options.componentName);
976
+ };
977
+ return {
978
+ writeValue(value) {
979
+ maybeWarn();
980
+ options.value.set(value === null ? undefined : value);
981
+ },
982
+ registerOnChange(fn) {
983
+ maybeWarn();
984
+ onChange = fn;
985
+ },
986
+ registerOnTouched(fn) {
987
+ onTouched = fn;
988
+ },
989
+ setDisabledState(disabled) {
990
+ options.setDisabled(disabled);
991
+ },
992
+ notifyValueChange(value) {
993
+ onChange(value);
994
+ },
995
+ markTouched() {
996
+ onTouched();
997
+ },
998
+ };
999
+ };
1000
+
1001
+ let counter = 0;
1002
+ const createId = () => {
1003
+ counter += 1;
1004
+ return String(counter);
1005
+ };
1006
+
709
1007
  /**
710
1008
  * Generated bundle index. Do not edit.
711
1009
  */
712
1010
 
713
- export { bindProps, normalizeProps, useMachine };
1011
+ export { DEFAULT_LOCALE, ENVIRONMENT_TOKEN, INTERACTION_TOKEN, InteractionService, LOCALE_TOKEN, bindProps, buildRootCarrier, createComponentWithCarrier, createContextCarrier, createCvaController, createEmbeddedViewWithCarrier, createId, getCollator, getDateFormatter, getDirection, getFilter, injectEnvironment, injectInteraction, injectLocale, normalizeProps, provideEnvironment, provideInteraction, provideLocale, useMachine, warnMixedFormAndModelBinding };
714
1012
  //# sourceMappingURL=wirekyt-angular.mjs.map