@ngb-bootstrap/core 0.0.0 → 0.1.0-next.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/LICENSE +201 -0
- package/NOTICE +18 -0
- package/README.md +26 -0
- package/fesm2022/ngb-bootstrap-core-alert.mjs +154 -0
- package/fesm2022/ngb-bootstrap-core-alert.mjs.map +1 -0
- package/fesm2022/ngb-bootstrap-core-badge.mjs +100 -0
- package/fesm2022/ngb-bootstrap-core-badge.mjs.map +1 -0
- package/fesm2022/ngb-bootstrap-core-breadcrumb.mjs +135 -0
- package/fesm2022/ngb-bootstrap-core-breadcrumb.mjs.map +1 -0
- package/fesm2022/ngb-bootstrap-core-button.mjs +513 -0
- package/fesm2022/ngb-bootstrap-core-button.mjs.map +1 -0
- package/fesm2022/ngb-bootstrap-core-card.mjs +540 -0
- package/fesm2022/ngb-bootstrap-core-card.mjs.map +1 -0
- package/fesm2022/ngb-bootstrap-core-cdk.mjs +282 -0
- package/fesm2022/ngb-bootstrap-core-cdk.mjs.map +1 -0
- package/fesm2022/ngb-bootstrap-core-checkbox.mjs +165 -0
- package/fesm2022/ngb-bootstrap-core-checkbox.mjs.map +1 -0
- package/fesm2022/ngb-bootstrap-core-chips.mjs +512 -0
- package/fesm2022/ngb-bootstrap-core-chips.mjs.map +1 -0
- package/fesm2022/ngb-bootstrap-core-floating-label.mjs +83 -0
- package/fesm2022/ngb-bootstrap-core-floating-label.mjs.map +1 -0
- package/fesm2022/ngb-bootstrap-core-footer.mjs +48 -0
- package/fesm2022/ngb-bootstrap-core-footer.mjs.map +1 -0
- package/fesm2022/ngb-bootstrap-core-icon.mjs +243 -0
- package/fesm2022/ngb-bootstrap-core-icon.mjs.map +1 -0
- package/fesm2022/ngb-bootstrap-core-input.mjs +540 -0
- package/fesm2022/ngb-bootstrap-core-input.mjs.map +1 -0
- package/fesm2022/ngb-bootstrap-core-layout.mjs +272 -0
- package/fesm2022/ngb-bootstrap-core-layout.mjs.map +1 -0
- package/fesm2022/ngb-bootstrap-core-navbar.mjs +150 -0
- package/fesm2022/ngb-bootstrap-core-navbar.mjs.map +1 -0
- package/fesm2022/ngb-bootstrap-core-radio.mjs +279 -0
- package/fesm2022/ngb-bootstrap-core-radio.mjs.map +1 -0
- package/fesm2022/ngb-bootstrap-core-sidebar.mjs +425 -0
- package/fesm2022/ngb-bootstrap-core-sidebar.mjs.map +1 -0
- package/fesm2022/ngb-bootstrap-core-spinner.mjs +126 -0
- package/fesm2022/ngb-bootstrap-core-spinner.mjs.map +1 -0
- package/fesm2022/ngb-bootstrap-core-switch.mjs +147 -0
- package/fesm2022/ngb-bootstrap-core-switch.mjs.map +1 -0
- package/fesm2022/ngb-bootstrap-core.mjs +69 -0
- package/fesm2022/ngb-bootstrap-core.mjs.map +1 -0
- package/ngb-bootstrap.css +827 -0
- package/package.json +118 -4
- package/styles/_breadcrumb.scss +9 -0
- package/styles/_button.scss +14 -0
- package/styles/_card.scss +86 -0
- package/styles/_chip.scss +10 -0
- package/styles/_choice.scss +14 -0
- package/styles/_contrast.scss +23 -0
- package/styles/_icon.scss +62 -0
- package/styles/_index.scss +33 -0
- package/styles/_input.scss +9 -0
- package/styles/_layout.scss +602 -0
- package/styles/_overlay.scss +14 -0
- package/styles/_tokens.scss +29 -0
- package/styles/_typography.scss +77 -0
- package/styles/ngb-bootstrap.scss +2 -0
- package/types/ngb-bootstrap-core-alert.d.ts +65 -0
- package/types/ngb-bootstrap-core-badge.d.ts +38 -0
- package/types/ngb-bootstrap-core-breadcrumb.d.ts +32 -0
- package/types/ngb-bootstrap-core-button.d.ts +177 -0
- package/types/ngb-bootstrap-core-card.d.ts +154 -0
- package/types/ngb-bootstrap-core-cdk.d.ts +165 -0
- package/types/ngb-bootstrap-core-checkbox.d.ts +53 -0
- package/types/ngb-bootstrap-core-chips.d.ts +170 -0
- package/types/ngb-bootstrap-core-floating-label.d.ts +22 -0
- package/types/ngb-bootstrap-core-footer.d.ts +16 -0
- package/types/ngb-bootstrap-core-icon.d.ts +99 -0
- package/types/ngb-bootstrap-core-input.d.ts +208 -0
- package/types/ngb-bootstrap-core-layout.d.ts +102 -0
- package/types/ngb-bootstrap-core-navbar.d.ts +33 -0
- package/types/ngb-bootstrap-core-radio.d.ts +96 -0
- package/types/ngb-bootstrap-core-sidebar.d.ts +62 -0
- package/types/ngb-bootstrap-core-spinner.d.ts +49 -0
- package/types/ngb-bootstrap-core-switch.d.ts +44 -0
- package/types/ngb-bootstrap-core.d.ts +82 -0
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { Overlay } from "@angular/cdk/overlay";
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
import { DestroyRef, Directive, Injectable, Injector, booleanAttribute, computed, forwardRef, inject, input, model, signal } from "@angular/core";
|
|
4
|
+
import { Subject, merge } from "rxjs";
|
|
5
|
+
import { filter, take } from "rxjs/operators";
|
|
6
|
+
import { NG_VALUE_ACCESSOR, NgControl } from "@angular/forms";
|
|
7
|
+
import { NGB_DEFAULT_I18N, NGB_I18N, provideNgbI18n } from "@ngb-bootstrap/core";
|
|
8
|
+
const OPPOSITE = {
|
|
9
|
+
top: "bottom",
|
|
10
|
+
bottom: "top",
|
|
11
|
+
start: "end",
|
|
12
|
+
end: "start"
|
|
13
|
+
};
|
|
14
|
+
function ngbPositions(placement, offset = 0) {
|
|
15
|
+
const flipped = placement.replace(/^[a-z]+/, (side) => OPPOSITE[side]);
|
|
16
|
+
return [toPosition(placement, offset), toPosition(flipped, offset)];
|
|
17
|
+
}
|
|
18
|
+
function toPosition(placement, offset) {
|
|
19
|
+
const [side, align = "center"] = placement.split("-");
|
|
20
|
+
const vertical = side === "top" || side === "bottom";
|
|
21
|
+
const pos = {
|
|
22
|
+
originX: "center",
|
|
23
|
+
originY: "center",
|
|
24
|
+
overlayX: "center",
|
|
25
|
+
overlayY: "center"
|
|
26
|
+
};
|
|
27
|
+
if (vertical) {
|
|
28
|
+
pos["originY"] = side === "top" ? "top" : "bottom";
|
|
29
|
+
pos["overlayY"] = side === "top" ? "bottom" : "top";
|
|
30
|
+
if (align !== "center") pos["originX"] = pos["overlayX"] = align;
|
|
31
|
+
} else {
|
|
32
|
+
pos["originX"] = side;
|
|
33
|
+
pos["overlayX"] = OPPOSITE[side];
|
|
34
|
+
if (align !== "center") pos["originY"] = pos["overlayY"] = align;
|
|
35
|
+
}
|
|
36
|
+
const dy = side === "top" ? 0 - offset : side === "bottom" ? offset : 0;
|
|
37
|
+
const dx = side === "start" ? 0 - offset : side === "end" ? offset : 0;
|
|
38
|
+
return {
|
|
39
|
+
...pos,
|
|
40
|
+
offsetX: dx,
|
|
41
|
+
offsetY: dy,
|
|
42
|
+
panelClass: `ngb-placement-${side}`
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
var NgbAnchoredOverlay = class NgbAnchoredOverlay {
|
|
46
|
+
overlay = inject(Overlay);
|
|
47
|
+
open(anchor, content, config = {}) {
|
|
48
|
+
const overlayConfig = {
|
|
49
|
+
positionStrategy: this.overlay.position().flexibleConnectedTo(anchor).withPositions(ngbPositions(config.placement ?? "bottom", config.offset)).withFlexibleDimensions(false).withPush(true),
|
|
50
|
+
scrollStrategy: this.overlay.scrollStrategies.reposition(),
|
|
51
|
+
panelClass: config.panelClass ?? []
|
|
52
|
+
};
|
|
53
|
+
const overlayRef = this.overlay.create(overlayConfig);
|
|
54
|
+
overlayRef.attach(content);
|
|
55
|
+
const closed = new Subject();
|
|
56
|
+
let done = false;
|
|
57
|
+
const close = () => {
|
|
58
|
+
if (done) return;
|
|
59
|
+
done = true;
|
|
60
|
+
overlayRef.dispose();
|
|
61
|
+
closed.next();
|
|
62
|
+
closed.complete();
|
|
63
|
+
};
|
|
64
|
+
const triggers = [];
|
|
65
|
+
if (config.closeOnEscape !== false) triggers.push(overlayRef.keydownEvents().pipe(filter((e) => e.key === "Escape")));
|
|
66
|
+
if (config.closeOnOutsideClick !== false) triggers.push(overlayRef.outsidePointerEvents().pipe(filter((e) => !anchor.contains(e.target))));
|
|
67
|
+
merge(...triggers).pipe(take(1)).subscribe(close);
|
|
68
|
+
return {
|
|
69
|
+
overlayRef,
|
|
70
|
+
closed: closed.asObservable(),
|
|
71
|
+
close
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
75
|
+
minVersion: "12.0.0",
|
|
76
|
+
version: "22.2.3",
|
|
77
|
+
ngImport: i0,
|
|
78
|
+
type: NgbAnchoredOverlay,
|
|
79
|
+
deps: [],
|
|
80
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
81
|
+
});
|
|
82
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
83
|
+
minVersion: "12.0.0",
|
|
84
|
+
version: "22.2.3",
|
|
85
|
+
ngImport: i0,
|
|
86
|
+
type: NgbAnchoredOverlay,
|
|
87
|
+
providedIn: "root"
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
91
|
+
minVersion: "12.0.0",
|
|
92
|
+
version: "22.2.3",
|
|
93
|
+
ngImport: i0,
|
|
94
|
+
type: NgbAnchoredOverlay,
|
|
95
|
+
decorators: [{
|
|
96
|
+
type: Injectable,
|
|
97
|
+
args: [{ providedIn: "root" }]
|
|
98
|
+
}]
|
|
99
|
+
});
|
|
100
|
+
var NgbIdGenerator = class NgbIdGenerator {
|
|
101
|
+
counters = /* @__PURE__ */ new Map();
|
|
102
|
+
next(prefix) {
|
|
103
|
+
const n = (this.counters.get(prefix) ?? 0) + 1;
|
|
104
|
+
this.counters.set(prefix, n);
|
|
105
|
+
return `${prefix}-${n}`;
|
|
106
|
+
}
|
|
107
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
108
|
+
minVersion: "12.0.0",
|
|
109
|
+
version: "22.2.3",
|
|
110
|
+
ngImport: i0,
|
|
111
|
+
type: NgbIdGenerator,
|
|
112
|
+
deps: [],
|
|
113
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
114
|
+
});
|
|
115
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
116
|
+
minVersion: "12.0.0",
|
|
117
|
+
version: "22.2.3",
|
|
118
|
+
ngImport: i0,
|
|
119
|
+
type: NgbIdGenerator,
|
|
120
|
+
providedIn: "root"
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
124
|
+
minVersion: "12.0.0",
|
|
125
|
+
version: "22.2.3",
|
|
126
|
+
ngImport: i0,
|
|
127
|
+
type: NgbIdGenerator,
|
|
128
|
+
decorators: [{
|
|
129
|
+
type: Injectable,
|
|
130
|
+
args: [{ providedIn: "root" }]
|
|
131
|
+
}]
|
|
132
|
+
});
|
|
133
|
+
function ngbId(prefix = "ngb") {
|
|
134
|
+
return inject(NgbIdGenerator).next(prefix);
|
|
135
|
+
}
|
|
136
|
+
const noop = () => {};
|
|
137
|
+
var NgbValueAccessor = class NgbValueAccessor {
|
|
138
|
+
injector = inject(Injector);
|
|
139
|
+
value = model(null, ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
|
|
140
|
+
disabled = input(false, {
|
|
141
|
+
...ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {},
|
|
142
|
+
transform: booleanAttribute
|
|
143
|
+
});
|
|
144
|
+
formDisabled = signal(false, ...ngDevMode ? [{ debugName: "formDisabled" }] : /* istanbul ignore next */ []);
|
|
145
|
+
isDisabled = computed(() => this.disabled() || this.formDisabled(), ...ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []);
|
|
146
|
+
invalid = input(void 0, {
|
|
147
|
+
...ngDevMode ? { debugName: "invalid" } : /* istanbul ignore next */ {},
|
|
148
|
+
transform: (value) => value == null ? void 0 : booleanAttribute(value)
|
|
149
|
+
});
|
|
150
|
+
touchedInvalid = signal(false, ...ngDevMode ? [{ debugName: "touchedInvalid" }] : /* istanbul ignore next */ []);
|
|
151
|
+
isInvalid = computed(() => this.invalid() ?? this.touchedInvalid(), ...ngDevMode ? [{ debugName: "isInvalid" }] : /* istanbul ignore next */ []);
|
|
152
|
+
ngControl;
|
|
153
|
+
watched = null;
|
|
154
|
+
subscription;
|
|
155
|
+
onChange = noop;
|
|
156
|
+
onTouched = noop;
|
|
157
|
+
constructor() {
|
|
158
|
+
inject(DestroyRef).onDestroy(() => this.subscription?.unsubscribe());
|
|
159
|
+
}
|
|
160
|
+
ngAfterContentChecked() {
|
|
161
|
+
this.syncControl();
|
|
162
|
+
}
|
|
163
|
+
syncControl() {
|
|
164
|
+
this.ngControl ??= this.injector.get(NgControl, null, {
|
|
165
|
+
self: true,
|
|
166
|
+
optional: true
|
|
167
|
+
});
|
|
168
|
+
const control = this.ngControl?.control ?? null;
|
|
169
|
+
if (control !== this.watched) {
|
|
170
|
+
this.subscription?.unsubscribe();
|
|
171
|
+
this.watched = control;
|
|
172
|
+
this.subscription = control?.events.subscribe(() => this.syncControl());
|
|
173
|
+
}
|
|
174
|
+
this.touchedInvalid.set(!!control?.invalid && !!control.touched);
|
|
175
|
+
}
|
|
176
|
+
setValue(value) {
|
|
177
|
+
if (this.isDisabled()) return;
|
|
178
|
+
this.value.set(value);
|
|
179
|
+
this.onChange(value);
|
|
180
|
+
}
|
|
181
|
+
markTouched() {
|
|
182
|
+
this.onTouched();
|
|
183
|
+
}
|
|
184
|
+
writeValue(value) {
|
|
185
|
+
this.value.set(value ?? null);
|
|
186
|
+
}
|
|
187
|
+
registerOnChange(fn) {
|
|
188
|
+
this.onChange = fn;
|
|
189
|
+
}
|
|
190
|
+
registerOnTouched(fn) {
|
|
191
|
+
this.onTouched = fn;
|
|
192
|
+
}
|
|
193
|
+
setDisabledState(isDisabled) {
|
|
194
|
+
this.formDisabled.set(isDisabled);
|
|
195
|
+
}
|
|
196
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
197
|
+
minVersion: "12.0.0",
|
|
198
|
+
version: "22.2.3",
|
|
199
|
+
ngImport: i0,
|
|
200
|
+
type: NgbValueAccessor,
|
|
201
|
+
deps: [],
|
|
202
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
203
|
+
});
|
|
204
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
205
|
+
minVersion: "17.1.0",
|
|
206
|
+
version: "22.2.3",
|
|
207
|
+
type: NgbValueAccessor,
|
|
208
|
+
isStandalone: true,
|
|
209
|
+
inputs: {
|
|
210
|
+
value: {
|
|
211
|
+
classPropertyName: "value",
|
|
212
|
+
publicName: "value",
|
|
213
|
+
isSignal: true,
|
|
214
|
+
isRequired: false,
|
|
215
|
+
transformFunction: null
|
|
216
|
+
},
|
|
217
|
+
disabled: {
|
|
218
|
+
classPropertyName: "disabled",
|
|
219
|
+
publicName: "disabled",
|
|
220
|
+
isSignal: true,
|
|
221
|
+
isRequired: false,
|
|
222
|
+
transformFunction: null
|
|
223
|
+
},
|
|
224
|
+
invalid: {
|
|
225
|
+
classPropertyName: "invalid",
|
|
226
|
+
publicName: "invalid",
|
|
227
|
+
isSignal: true,
|
|
228
|
+
isRequired: false,
|
|
229
|
+
transformFunction: null
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
outputs: { value: "valueChange" },
|
|
233
|
+
ngImport: i0
|
|
234
|
+
});
|
|
235
|
+
};
|
|
236
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
237
|
+
minVersion: "12.0.0",
|
|
238
|
+
version: "22.2.3",
|
|
239
|
+
ngImport: i0,
|
|
240
|
+
type: NgbValueAccessor,
|
|
241
|
+
decorators: [{ type: Directive }],
|
|
242
|
+
ctorParameters: () => [],
|
|
243
|
+
propDecorators: {
|
|
244
|
+
value: [{
|
|
245
|
+
type: i0.Input,
|
|
246
|
+
args: [{
|
|
247
|
+
isSignal: true,
|
|
248
|
+
alias: "value",
|
|
249
|
+
required: false
|
|
250
|
+
}]
|
|
251
|
+
}, {
|
|
252
|
+
type: i0.Output,
|
|
253
|
+
args: ["valueChange"]
|
|
254
|
+
}],
|
|
255
|
+
disabled: [{
|
|
256
|
+
type: i0.Input,
|
|
257
|
+
args: [{
|
|
258
|
+
isSignal: true,
|
|
259
|
+
alias: "disabled",
|
|
260
|
+
required: false
|
|
261
|
+
}]
|
|
262
|
+
}],
|
|
263
|
+
invalid: [{
|
|
264
|
+
type: i0.Input,
|
|
265
|
+
args: [{
|
|
266
|
+
isSignal: true,
|
|
267
|
+
alias: "invalid",
|
|
268
|
+
required: false
|
|
269
|
+
}]
|
|
270
|
+
}]
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
function provideNgbValueAccessor(type) {
|
|
274
|
+
return {
|
|
275
|
+
provide: NG_VALUE_ACCESSOR,
|
|
276
|
+
useExisting: forwardRef(type),
|
|
277
|
+
multi: true
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
export { NGB_DEFAULT_I18N, NGB_I18N, NgbAnchoredOverlay, NgbIdGenerator, NgbValueAccessor, ngbId, ngbPositions, provideNgbI18n, provideNgbValueAccessor };
|
|
281
|
+
|
|
282
|
+
//# sourceMappingURL=ngb-bootstrap-core-cdk.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ngb-bootstrap-core-cdk.mjs","names":[],"sources":["../../../../projects/core/cdk/anchored-overlay.ts","../../../../projects/core/cdk/id.ts","../../../../projects/core/cdk/value-accessor.ts"],"sourcesContent":["import { ConnectedPosition, Overlay, OverlayConfig, OverlayRef } from '@angular/cdk/overlay';\nimport { ComponentPortal, TemplatePortal } from '@angular/cdk/portal';\nimport { Injectable, Injector, inject } from '@angular/core';\nimport { Observable, Subject, merge } from 'rxjs';\nimport { filter, take } from 'rxjs/operators';\n\n/** Where the panel sits relative to its anchor, using Bootstrap's placement names. */\nexport type NgbPlacement =\n | 'top'\n | 'top-start'\n | 'top-end'\n | 'bottom'\n | 'bottom-start'\n | 'bottom-end'\n | 'start'\n | 'start-top'\n | 'start-bottom'\n | 'end'\n | 'end-top'\n | 'end-bottom';\n\nconst OPPOSITE: Record<string, string> = {\n top: 'bottom',\n bottom: 'top',\n start: 'end',\n end: 'start',\n};\n\n/**\n * Maps a placement to CDK connected positions: the placement first, then its opposite side as\n * a fallback (the CDK picks the first one that fits). `offset` is the gap in px.\n *\n * ```ts\n * ngbPositions('bottom-start', 8);\n * ```\n */\nexport function ngbPositions(placement: NgbPlacement, offset = 0): ConnectedPosition[] {\n const flipped = placement.replace(/^[a-z]+/, (side) => OPPOSITE[side]) as NgbPlacement;\n return [toPosition(placement, offset), toPosition(flipped, offset)];\n}\n\nfunction toPosition(placement: NgbPlacement, offset: number): ConnectedPosition {\n const [side, align = 'center'] = placement.split('-');\n const vertical = side === 'top' || side === 'bottom';\n const pos = {\n originX: 'center',\n originY: 'center',\n overlayX: 'center',\n overlayY: 'center',\n } as Record<string, string>;\n\n if (vertical) {\n pos['originY'] = side === 'top' ? 'top' : 'bottom';\n pos['overlayY'] = side === 'top' ? 'bottom' : 'top';\n if (align !== 'center') {\n pos['originX'] = pos['overlayX'] = align;\n }\n } else {\n pos['originX'] = side;\n pos['overlayX'] = OPPOSITE[side];\n if (align !== 'center') {\n pos['originY'] = pos['overlayY'] = align;\n }\n }\n const dy = side === 'top' ? 0 - offset : side === 'bottom' ? offset : 0;\n const dx = side === 'start' ? 0 - offset : side === 'end' ? offset : 0;\n return {\n ...pos,\n offsetX: dx,\n offsetY: dy,\n panelClass: `ngb-placement-${side}`,\n } as ConnectedPosition;\n}\n\nexport interface NgbAnchoredOverlayConfig {\n /** Default `bottom`. */\n placement?: NgbPlacement;\n /** Gap in px between anchor and panel. Default 0. */\n offset?: number;\n /** Close on Escape. Default true. */\n closeOnEscape?: boolean;\n /** Close on a pointer press outside the panel and anchor. Default true. */\n closeOnOutsideClick?: boolean;\n /** Extra classes for the CDK pane. */\n panelClass?: string | string[];\n /** Injector for the created component or template view. */\n injector?: Injector;\n}\n\n/** Handle to an open anchored panel. */\nexport interface NgbAnchoredOverlayRef {\n /** The underlying CDK overlay, for anything not covered here. */\n readonly overlayRef: OverlayRef;\n /** Emits once when the panel is closed (by the user or by `close()`). */\n readonly closed: Observable<void>;\n /** Closes and disposes the panel. Safe to call twice. */\n close(): void;\n}\n\n/**\n * Opens a component or template next to an anchor element using the CDK's flexible connected\n * position strategy. It adds Bootstrap placement names, a flip fallback, scroll repositioning and\n * Escape / outside-click closing; anything else is available through `overlayRef`.\n *\n * ```ts\n * const ref = inject(NgbAnchoredOverlay).open(button, new ComponentPortal(Tip), {\n * placement: 'top',\n * offset: 8,\n * });\n * ref.closed.subscribe(() => (this.open = false));\n * ```\n */\n@Injectable({ providedIn: 'root' })\nexport class NgbAnchoredOverlay {\n private readonly overlay = inject(Overlay);\n\n open(\n anchor: HTMLElement,\n content: ComponentPortal<unknown> | TemplatePortal<unknown>,\n config: NgbAnchoredOverlayConfig = {},\n ): NgbAnchoredOverlayRef {\n const overlayConfig: OverlayConfig = {\n positionStrategy: this.overlay\n .position()\n .flexibleConnectedTo(anchor)\n .withPositions(ngbPositions(config.placement ?? 'bottom', config.offset))\n .withFlexibleDimensions(false)\n .withPush(true),\n scrollStrategy: this.overlay.scrollStrategies.reposition(),\n panelClass: config.panelClass ?? [],\n };\n const overlayRef = this.overlay.create(overlayConfig);\n overlayRef.attach(content);\n\n const closed = new Subject<void>();\n let done = false;\n const close = () => {\n if (done) return;\n done = true;\n overlayRef.dispose();\n closed.next();\n closed.complete();\n };\n\n const triggers: Observable<unknown>[] = [];\n if (config.closeOnEscape !== false) {\n triggers.push(overlayRef.keydownEvents().pipe(filter((e) => e.key === 'Escape')));\n }\n if (config.closeOnOutsideClick !== false) {\n triggers.push(\n overlayRef.outsidePointerEvents().pipe(filter((e) => !anchor.contains(e.target as Node))),\n );\n }\n merge(...triggers)\n .pipe(take(1))\n .subscribe(close);\n\n return { overlayRef, closed: closed.asObservable(), close };\n }\n}\n","import { Injectable, inject } from '@angular/core';\n\n/**\n * App-scoped unique id source. Counters live in this root service rather than at module level, so\n * every application (and every SSR request) starts from zero. The server and the browser then\n * generate the same ids in the same order, which keeps hydration from mismatching on `id`,\n * `for` and `aria-*` attributes.\n */\n@Injectable({ providedIn: 'root' })\nexport class NgbIdGenerator {\n private readonly counters = new Map<string, number>();\n\n /** Returns `${prefix}-${n}`, counting separately per prefix. */\n next(prefix: string): string {\n const n = (this.counters.get(prefix) ?? 0) + 1;\n this.counters.set(prefix, n);\n return `${prefix}-${n}`;\n }\n}\n\n/**\n * Creates a unique id such as `ngb-tooltip-1`. Call it in an injection context, typically a field\n * initialiser, so ids are created in the same order on server and client.\n *\n * ```ts\n * protected readonly id = ngbId('ngb-tooltip');\n * ```\n */\nexport function ngbId(prefix = 'ngb'): string {\n return inject(NgbIdGenerator).next(prefix);\n}\n","import {\n AfterContentChecked,\n DestroyRef,\n Directive,\n Injector,\n Provider,\n Type,\n booleanAttribute,\n computed,\n forwardRef,\n inject,\n input,\n model,\n signal,\n} from '@angular/core';\nimport {\n AbstractControl,\n ControlValueAccessor,\n NG_VALUE_ACCESSOR,\n NgControl,\n} from '@angular/forms';\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nconst noop = () => {};\n\n/**\n * Base for form controls. It implements `ControlValueAccessor` on top of signals, so a control\n * only needs a template that reads `value()` / `isDisabled()` and calls `setValue()` and\n * `markTouched()`. It works with `ngModel`, reactive forms and plain `[(value)]` binding.\n *\n * ```ts\n * @Component({\n * selector: 'ngb-switch',\n * providers: [provideNgbValueAccessor(() => NgbSwitch)],\n * template: `<input type=\"checkbox\" role=\"switch\" [checked]=\"value()\" [disabled]=\"isDisabled()\"\n * (change)=\"setValue($any($event.target).checked)\" (blur)=\"markTouched()\" />`,\n * })\n * export class NgbSwitch extends NgbValueAccessor<boolean> {}\n * ```\n *\n * `writeValue` also emits `valueChange`, because `model()` always does; `onChange` fires only\n * for changes made through `setValue`. `isInvalid()` follows the form control (invalid and\n * touched), like `ngbInput`, unless the `invalid` input forces it.\n */\n@Directive()\nexport abstract class NgbValueAccessor<T> implements ControlValueAccessor, AfterContentChecked {\n private readonly injector = inject(Injector);\n /** Current value; two-way bindable with `[(value)]`. */\n readonly value = model<T | null>(null);\n /** Disabled through the `disabled` input. Forms can also disable the control. */\n readonly disabled = input(false, { transform: booleanAttribute });\n\n private readonly formDisabled = signal(false);\n /** True when disabled by the input or by the form control. */\n readonly isDisabled = computed(() => this.disabled() || this.formDisabled());\n\n /**\n * Forces the invalid state on or off, for errors the form does not know about, such as a server\n * response. By default the control is invalid when its form control is invalid and touched.\n */\n readonly invalid = input<boolean | undefined, unknown>(undefined, {\n transform: (value: unknown) => (value == null ? undefined : booleanAttribute(value)),\n });\n private readonly touchedInvalid = signal(false);\n /** True while the control shows its invalid state (`.is-invalid`, `aria-invalid`). */\n readonly isInvalid = computed(() => this.invalid() ?? this.touchedInvalid());\n\n // The NgControl on this element injects this accessor, so it can't be injected back in the\n // constructor. It is looked up lazily instead, once the forms directive exists.\n private ngControl?: NgControl | null;\n private watched: AbstractControl | null = null;\n private subscription?: { unsubscribe(): void };\n\n private onChange: (value: T | null) => void = noop;\n private onTouched: () => void = noop;\n\n constructor() {\n inject(DestroyRef).onDestroy(() => this.subscription?.unsubscribe());\n }\n\n // After content, not in ngDoCheck: the forms directive on the same element swaps in a new\n // control in its ngOnChanges, which runs after this component's ngDoCheck.\n ngAfterContentChecked(): void {\n this.syncControl();\n }\n\n /** Re-reads the form control's state. Runs on every change detection pass and on its events. */\n private syncControl(): void {\n this.ngControl ??= this.injector.get(NgControl, null, { self: true, optional: true });\n const control = this.ngControl?.control ?? null;\n if (control !== this.watched) {\n this.subscription?.unsubscribe();\n this.watched = control;\n this.subscription = control?.events.subscribe(() => this.syncControl());\n }\n this.touchedInvalid.set(!!control?.invalid && !!control.touched);\n }\n\n /** Call from the template when the user changes the value. */\n setValue(value: T | null): void {\n if (this.isDisabled()) return;\n this.value.set(value);\n this.onChange(value);\n }\n\n /** Call from the template on blur. */\n markTouched(): void {\n this.onTouched();\n }\n\n writeValue(value: T | null): void {\n this.value.set(value ?? null);\n }\n\n registerOnChange(fn: (value: T | null) => void): void {\n this.onChange = fn;\n }\n\n registerOnTouched(fn: () => void): void {\n this.onTouched = fn;\n }\n\n setDisabledState(isDisabled: boolean): void {\n this.formDisabled.set(isDisabled);\n }\n}\n\n/**\n * Provider that registers a component as an `NG_VALUE_ACCESSOR`.\n *\n * ```ts\n * providers: [provideNgbValueAccessor(() => NgbSwitch)]\n * ```\n */\nexport function provideNgbValueAccessor(type: () => Type<unknown>): Provider {\n return { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(type), multi: true };\n}\n"],"mappings":";;;;;;;AAqBA,MAAM,WAAmC;CACvC,KAAK;CACL,QAAQ;CACR,OAAO;CACP,KAAK;AACN;AAUD,SAAgB,aAAa,WAAyB,SAAS,GAAC;CAC9D,MAAM,UAAU,UAAU,QAAQ,YAAY,SAAS,SAAS,KAAK;CACrE,OAAO,CAAC,WAAW,WAAW,MAAM,GAAG,WAAW,SAAS,MAAM,CAAC;AACpE;AAEA,SAAS,WAAW,WAAyB,QAAc;CACzD,MAAM,CAAC,MAAM,QAAQ,YAAY,UAAU,MAAM,GAAG;CACpD,MAAM,WAAW,SAAS,SAAS,SAAS;CAC5C,MAAM,MAAM;EACV,SAAS;EACT,SAAS;EACT,UAAU;EACV,UAAU;CACe;CAE3B,IAAI,UAAU;EACZ,IAAI,aAAa,SAAS,QAAQ,QAAQ;EAC1C,IAAI,cAAc,SAAS,QAAQ,WAAW;EAC9C,IAAI,UAAU,UACZ,IAAI,aAAa,IAAI,cAAc;CAEvC,OAAO;EACL,IAAI,aAAa;EACjB,IAAI,cAAc,SAAS;EAC3B,IAAI,UAAU,UACZ,IAAI,aAAa,IAAI,cAAc;CAEvC;CACA,MAAM,KAAK,SAAS,QAAQ,IAAI,SAAS,SAAS,WAAW,SAAS;CACtE,MAAM,KAAK,SAAS,UAAU,IAAI,SAAS,SAAS,QAAQ,SAAS;CACrE,OAAO;EACL,GAAG;EACH,SAAS;EACT,SAAS;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,KAAK,WAAW;CAClB;CAEA,kBAAkB,IAAc;EAC9B,KAAK,YAAY;CACnB;CAEA,iBAAiB,YAAmB;EAClC,KAAK,aAAa,IAAI,UAAU;CAClC;CA/EoB,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAgB,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAhB,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAgB,cAAA;EAAA,QAAA;GAAA,OAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,UAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,SAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;EAAA;EAAA,SAAA,EAAA,OAAA,cAAA;EAAA,UAAA;CAAA,CAAA;;AAAhB,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAgB,YAAA,CAAA,EADrC,MAAA,U;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0FD,SAAgB,wBAAwB,MAAyB;CAC/D,OAAO;EAAE,SAAS;EAAmB,aAAa,WAAW,IAAI;EAAG,OAAO;CAAI;AACjF"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { ChangeDetectionStrategy, Component, computed, input, model } from "@angular/core";
|
|
3
|
+
import { NgbValueAccessor, ngbId, provideNgbValueAccessor } from "@ngb-bootstrap/core/cdk";
|
|
4
|
+
var NgbCheckbox = class NgbCheckbox extends NgbValueAccessor {
|
|
5
|
+
id = ngbId("ngb-checkbox");
|
|
6
|
+
hintId = `${this.id}-hint`;
|
|
7
|
+
indeterminate = model(false, ...ngDevMode ? [{ debugName: "indeterminate" }] : /* istanbul ignore next */ []);
|
|
8
|
+
hint = input(...ngDevMode ? [void 0, { debugName: "hint" }] : /* istanbul ignore next */ []);
|
|
9
|
+
color = input(...ngDevMode ? [void 0, { debugName: "color" }] : /* istanbul ignore next */ []);
|
|
10
|
+
size = input("md", ...ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []);
|
|
11
|
+
classes = computed(() => {
|
|
12
|
+
const classes = ["check"];
|
|
13
|
+
if (this.color()) classes.push(`theme-${this.color()}`);
|
|
14
|
+
if (this.size() !== "md") classes.push(`check-${this.size()}`);
|
|
15
|
+
if (this.isInvalid()) classes.push("is-invalid");
|
|
16
|
+
return classes.join(" ");
|
|
17
|
+
}, ...ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []);
|
|
18
|
+
toggle(event) {
|
|
19
|
+
this.indeterminate.set(false);
|
|
20
|
+
this.setValue(event.target.checked);
|
|
21
|
+
}
|
|
22
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
23
|
+
minVersion: "12.0.0",
|
|
24
|
+
version: "22.2.3",
|
|
25
|
+
ngImport: i0,
|
|
26
|
+
type: NgbCheckbox,
|
|
27
|
+
deps: null,
|
|
28
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
29
|
+
});
|
|
30
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
31
|
+
minVersion: "17.0.0",
|
|
32
|
+
version: "22.2.3",
|
|
33
|
+
type: NgbCheckbox,
|
|
34
|
+
isStandalone: true,
|
|
35
|
+
selector: "ngb-checkbox",
|
|
36
|
+
inputs: {
|
|
37
|
+
indeterminate: {
|
|
38
|
+
classPropertyName: "indeterminate",
|
|
39
|
+
publicName: "indeterminate",
|
|
40
|
+
isSignal: true,
|
|
41
|
+
isRequired: false,
|
|
42
|
+
transformFunction: null
|
|
43
|
+
},
|
|
44
|
+
hint: {
|
|
45
|
+
classPropertyName: "hint",
|
|
46
|
+
publicName: "hint",
|
|
47
|
+
isSignal: true,
|
|
48
|
+
isRequired: false,
|
|
49
|
+
transformFunction: null
|
|
50
|
+
},
|
|
51
|
+
color: {
|
|
52
|
+
classPropertyName: "color",
|
|
53
|
+
publicName: "color",
|
|
54
|
+
isSignal: true,
|
|
55
|
+
isRequired: false,
|
|
56
|
+
transformFunction: null
|
|
57
|
+
},
|
|
58
|
+
size: {
|
|
59
|
+
classPropertyName: "size",
|
|
60
|
+
publicName: "size",
|
|
61
|
+
isSignal: true,
|
|
62
|
+
isRequired: false,
|
|
63
|
+
transformFunction: null
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
outputs: { indeterminate: "indeterminateChange" },
|
|
67
|
+
host: { classAttribute: "form-field" },
|
|
68
|
+
providers: [provideNgbValueAccessor(() => NgbCheckbox)],
|
|
69
|
+
usesInheritance: true,
|
|
70
|
+
ngImport: i0,
|
|
71
|
+
template: `
|
|
72
|
+
<input
|
|
73
|
+
type="checkbox"
|
|
74
|
+
[id]="id"
|
|
75
|
+
[class]="classes()"
|
|
76
|
+
[checked]="!!value()"
|
|
77
|
+
[indeterminate]="indeterminate()"
|
|
78
|
+
[disabled]="isDisabled()"
|
|
79
|
+
[attr.aria-invalid]="isInvalid() ? 'true' : null"
|
|
80
|
+
[attr.aria-describedby]="hint() ? hintId : null"
|
|
81
|
+
(change)="toggle($event)"
|
|
82
|
+
(blur)="markTouched()"
|
|
83
|
+
/>
|
|
84
|
+
<label [for]="id"><ng-content /></label>
|
|
85
|
+
@if (hint()) {
|
|
86
|
+
<div class="form-text" [id]="hintId">{{ hint() }}</div>
|
|
87
|
+
}
|
|
88
|
+
`,
|
|
89
|
+
isInline: true,
|
|
90
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
94
|
+
minVersion: "12.0.0",
|
|
95
|
+
version: "22.2.3",
|
|
96
|
+
ngImport: i0,
|
|
97
|
+
type: NgbCheckbox,
|
|
98
|
+
decorators: [{
|
|
99
|
+
type: Component,
|
|
100
|
+
args: [{
|
|
101
|
+
selector: "ngb-checkbox",
|
|
102
|
+
providers: [provideNgbValueAccessor(() => NgbCheckbox)],
|
|
103
|
+
template: `
|
|
104
|
+
<input
|
|
105
|
+
type="checkbox"
|
|
106
|
+
[id]="id"
|
|
107
|
+
[class]="classes()"
|
|
108
|
+
[checked]="!!value()"
|
|
109
|
+
[indeterminate]="indeterminate()"
|
|
110
|
+
[disabled]="isDisabled()"
|
|
111
|
+
[attr.aria-invalid]="isInvalid() ? 'true' : null"
|
|
112
|
+
[attr.aria-describedby]="hint() ? hintId : null"
|
|
113
|
+
(change)="toggle($event)"
|
|
114
|
+
(blur)="markTouched()"
|
|
115
|
+
/>
|
|
116
|
+
<label [for]="id"><ng-content /></label>
|
|
117
|
+
@if (hint()) {
|
|
118
|
+
<div class="form-text" [id]="hintId">{{ hint() }}</div>
|
|
119
|
+
}
|
|
120
|
+
`,
|
|
121
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
122
|
+
host: { class: "form-field" }
|
|
123
|
+
}]
|
|
124
|
+
}],
|
|
125
|
+
propDecorators: {
|
|
126
|
+
indeterminate: [{
|
|
127
|
+
type: i0.Input,
|
|
128
|
+
args: [{
|
|
129
|
+
isSignal: true,
|
|
130
|
+
alias: "indeterminate",
|
|
131
|
+
required: false
|
|
132
|
+
}]
|
|
133
|
+
}, {
|
|
134
|
+
type: i0.Output,
|
|
135
|
+
args: ["indeterminateChange"]
|
|
136
|
+
}],
|
|
137
|
+
hint: [{
|
|
138
|
+
type: i0.Input,
|
|
139
|
+
args: [{
|
|
140
|
+
isSignal: true,
|
|
141
|
+
alias: "hint",
|
|
142
|
+
required: false
|
|
143
|
+
}]
|
|
144
|
+
}],
|
|
145
|
+
color: [{
|
|
146
|
+
type: i0.Input,
|
|
147
|
+
args: [{
|
|
148
|
+
isSignal: true,
|
|
149
|
+
alias: "color",
|
|
150
|
+
required: false
|
|
151
|
+
}]
|
|
152
|
+
}],
|
|
153
|
+
size: [{
|
|
154
|
+
type: i0.Input,
|
|
155
|
+
args: [{
|
|
156
|
+
isSignal: true,
|
|
157
|
+
alias: "size",
|
|
158
|
+
required: false
|
|
159
|
+
}]
|
|
160
|
+
}]
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
export { NgbCheckbox };
|
|
164
|
+
|
|
165
|
+
//# sourceMappingURL=ngb-bootstrap-core-checkbox.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ngb-bootstrap-core-checkbox.mjs","names":[],"sources":["../../../../projects/core/checkbox/checkbox.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, computed, input, model } from '@angular/core';\nimport { NgbThemeColor } from '@ngb-bootstrap/core';\nimport { NgbValueAccessor, ngbId, provideNgbValueAccessor } from '@ngb-bootstrap/core/cdk';\n\nexport type NgbCheckSize = 'sm' | 'md' | 'lg';\n\n/**\n * Checkbox built on Bootstrap 6 `.check` over a native `<input type=\"checkbox\">`. The projected\n * content is the label. The model is `value` (`true` / `false`), the same name every ngb form\n * control uses, so `[(value)]`, `[(ngModel)]` and `formControlName` all work.\n *\n * ```html\n * <ngb-checkbox [(value)]=\"accepted\" hint=\"You can change this later.\">Accept the terms</ngb-checkbox>\n * <ngb-checkbox formControlName=\"all\" [indeterminate]=\"some()\">Select all</ngb-checkbox>\n * ```\n */\n@Component({\n selector: 'ngb-checkbox',\n providers: [provideNgbValueAccessor(() => NgbCheckbox)],\n template: `\n <input\n type=\"checkbox\"\n [id]=\"id\"\n [class]=\"classes()\"\n [checked]=\"!!value()\"\n [indeterminate]=\"indeterminate()\"\n [disabled]=\"isDisabled()\"\n [attr.aria-invalid]=\"isInvalid() ? 'true' : null\"\n [attr.aria-describedby]=\"hint() ? hintId : null\"\n (change)=\"toggle($event)\"\n (blur)=\"markTouched()\"\n />\n <label [for]=\"id\"><ng-content /></label>\n @if (hint()) {\n <div class=\"form-text\" [id]=\"hintId\">{{ hint() }}</div>\n }\n `,\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: { class: 'form-field' },\n})\nexport class NgbCheckbox extends NgbValueAccessor<boolean> {\n protected readonly id = ngbId('ngb-checkbox');\n protected readonly hintId = `${this.id}-hint`;\n\n /** Mixed state, shown with a dash. A user toggle clears it. Two-way bindable. */\n readonly indeterminate = model(false);\n /** Description shown under the label and linked with `aria-describedby`. */\n readonly hint = input<string>();\n /** Theme colour (Bootstrap `.theme-*`). Defaults to the control colour. */\n readonly color = input<NgbThemeColor>();\n /** `sm`, `md` (default) or `lg`. */\n readonly size = input<NgbCheckSize>('md');\n\n protected readonly classes = computed(() => {\n const classes = ['check'];\n if (this.color()) classes.push(`theme-${this.color()}`);\n if (this.size() !== 'md') classes.push(`check-${this.size()}`);\n if (this.isInvalid()) classes.push('is-invalid');\n return classes.join(' ');\n });\n\n protected toggle(event: Event): void {\n this.indeterminate.set(false);\n this.setValue((event.target as HTMLInputElement).checked);\n }\n}\n"],"mappings":";;;AAwCA,IAAa,cAAb,MAAa,oBAAoB,iBAAyB;CACrC,KAAK,MAAM,cAAc;CACzB,SAAS,GAAG,KAAK,GAAE;CAG7B,gBAAgB,MAAM,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,gBAAA,CAAA,+BAAA,CAAA,CAAA;CAE5B,OAAO,MAAe,GAAA,YAAA,CAAA,QAAA,EAAA,WAAA,OAAA,CAAA,+BAAA,CAAA,CAAA;CAEtB,QAAQ,MAAsB,GAAA,YAAA,CAAA,QAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CAE9B,OAAO,MAAoB,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,OAAA,CAAA,+BAAA,CAAA,CAAA;CAEtB,UAAU,eAAc;EACzC,MAAM,UAAU,CAAC,OAAO;EACxB,IAAI,KAAK,MAAK,GAAI,QAAQ,KAAK,SAAS,KAAK,MAAK,GAAI;EACtD,IAAI,KAAK,KAAI,MAAO,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