shirkasoft-ui-components 1.13.18 → 2.0.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/README.md +415 -42
- package/fesm2022/shirkasoft-ui-components-breadcrumb.mjs +189 -100
- package/fesm2022/shirkasoft-ui-components-breadcrumb.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-button.mjs +367 -73
- package/fesm2022/shirkasoft-ui-components-button.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-chart.mjs +206 -142
- package/fesm2022/shirkasoft-ui-components-chart.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-config.mjs +976 -0
- package/fesm2022/shirkasoft-ui-components-config.mjs.map +1 -0
- package/fesm2022/shirkasoft-ui-components-confirm-dialog.mjs +307 -142
- package/fesm2022/shirkasoft-ui-components-confirm-dialog.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-date-picker.mjs +1624 -1400
- package/fesm2022/shirkasoft-ui-components-date-picker.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-fieldset.mjs +347 -92
- package/fesm2022/shirkasoft-ui-components-fieldset.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-file-upload.mjs +484 -293
- package/fesm2022/shirkasoft-ui-components-file-upload.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-icons.mjs +1141 -0
- package/fesm2022/shirkasoft-ui-components-icons.mjs.map +1 -0
- package/fesm2022/shirkasoft-ui-components-knob.mjs +395 -180
- package/fesm2022/shirkasoft-ui-components-knob.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-loading.mjs +505 -128
- package/fesm2022/shirkasoft-ui-components-loading.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-modal.mjs +311 -303
- package/fesm2022/shirkasoft-ui-components-modal.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-notification.mjs +188 -142
- package/fesm2022/shirkasoft-ui-components-notification.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-price-input.mjs +517 -277
- package/fesm2022/shirkasoft-ui-components-price-input.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-rail-sidebar.mjs +669 -289
- package/fesm2022/shirkasoft-ui-components-rail-sidebar.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-select.mjs +1014 -814
- package/fesm2022/shirkasoft-ui-components-select.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-sidebar.mjs +508 -184
- package/fesm2022/shirkasoft-ui-components-sidebar.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-skeleton.mjs +197 -57
- package/fesm2022/shirkasoft-ui-components-skeleton.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-table.mjs +1918 -1676
- package/fesm2022/shirkasoft-ui-components-table.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-tabs.mjs +419 -177
- package/fesm2022/shirkasoft-ui-components-tabs.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-tag.mjs +177 -51
- package/fesm2022/shirkasoft-ui-components-tag.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-text-field.mjs +687 -369
- package/fesm2022/shirkasoft-ui-components-text-field.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-theme-picker.mjs +466 -0
- package/fesm2022/shirkasoft-ui-components-theme-picker.mjs.map +1 -0
- package/fesm2022/shirkasoft-ui-components-theme.mjs +147 -0
- package/fesm2022/shirkasoft-ui-components-theme.mjs.map +1 -0
- package/fesm2022/shirkasoft-ui-components-timeline.mjs +791 -215
- package/fesm2022/shirkasoft-ui-components-timeline.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-toggle.mjs +205 -128
- package/fesm2022/shirkasoft-ui-components-toggle.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-tooltip.mjs +244 -180
- package/fesm2022/shirkasoft-ui-components-tooltip.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-utils.mjs +97 -125
- package/fesm2022/shirkasoft-ui-components-utils.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-wizard.mjs +673 -166
- package/fesm2022/shirkasoft-ui-components-wizard.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components.mjs +0 -9
- package/package.json +37 -7
- package/src/baseline.css +2472 -0
- package/src/theme.css +15 -543
- package/src/themes/ocean.css +56 -0
- package/src/themes/sunset.css +55 -0
- package/src/themes/violet.css +25 -0
- package/src/tokens.css +612 -0
- package/types/shirkasoft-ui-components-breadcrumb.d.ts +59 -44
- package/types/shirkasoft-ui-components-button.d.ts +142 -49
- package/types/shirkasoft-ui-components-chart.d.ts +59 -44
- package/types/shirkasoft-ui-components-config.d.ts +357 -0
- package/types/shirkasoft-ui-components-confirm-dialog.d.ts +107 -65
- package/types/shirkasoft-ui-components-date-picker.d.ts +527 -373
- package/types/shirkasoft-ui-components-fieldset.d.ts +135 -59
- package/types/shirkasoft-ui-components-file-upload.d.ts +176 -106
- package/types/shirkasoft-ui-components-icons.d.ts +1430 -0
- package/types/shirkasoft-ui-components-knob.d.ts +151 -64
- package/types/shirkasoft-ui-components-loading.d.ts +155 -64
- package/types/shirkasoft-ui-components-modal.d.ts +134 -132
- package/types/shirkasoft-ui-components-notification.d.ts +63 -58
- package/types/shirkasoft-ui-components-price-input.d.ts +198 -85
- package/types/shirkasoft-ui-components-rail-sidebar.d.ts +262 -142
- package/types/shirkasoft-ui-components-select.d.ts +301 -192
- package/types/shirkasoft-ui-components-sidebar.d.ts +198 -92
- package/types/shirkasoft-ui-components-skeleton.d.ts +68 -27
- package/types/shirkasoft-ui-components-table.d.ts +849 -649
- package/types/shirkasoft-ui-components-tabs.d.ts +102 -61
- package/types/shirkasoft-ui-components-tag.d.ts +54 -23
- package/types/shirkasoft-ui-components-text-field.d.ts +231 -111
- package/types/shirkasoft-ui-components-theme-picker.d.ts +117 -0
- package/types/shirkasoft-ui-components-theme.d.ts +80 -0
- package/types/shirkasoft-ui-components-timeline.d.ts +326 -150
- package/types/shirkasoft-ui-components-toggle.d.ts +76 -45
- package/types/shirkasoft-ui-components-tooltip.d.ts +64 -43
- package/types/shirkasoft-ui-components-utils.d.ts +26 -17
- package/types/shirkasoft-ui-components-wizard.d.ts +236 -86
- package/types/shirkasoft-ui-components.d.ts +1 -2
- package/fesm2022/shirkasoft-ui-components.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shirkasoft-ui-components-toggle.mjs","sources":["../../../projects/ui-components/toggle/toggle.component.ts"
|
|
1
|
+
{"version":3,"file":"shirkasoft-ui-components-toggle.mjs","names":[],"sources":["../../../projects/ui-components/toggle/toggle.component.ts"],"sourcesContent":["import { Component, ChangeDetectionStrategy, forwardRef, input, model, output, signal, computed } from '@angular/core';\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\nimport type { FormCheckboxControl } from '@angular/forms/signals';\nimport { CommonModule } from '@angular/common';\n\n/**\n * Shirkasoft UI Components.\n * Authors: Roberto Valladares Martin (Ansem13), Julio César García García (Sanjuli14).\n * Belongs to Shirkasoft.\n */\n\n/**\n * Switch / checkbox component that implements ControlValueAccessor so it can\n * be used with reactive and template-driven forms.\n *\n * It also implements the Angular Signal Forms `FormCheckboxControl` contract\n * through its `checked` model, so it works with `[formField]` as well.\n */\n@Component({\n selector: 'shk-toggle',\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [CommonModule],\n template: `\n <div class=\"relative\">\n <!-- El click va en el label: responde el control y tambien el texto. -->\n <label\n class=\"inline-flex items-center gap-3 cursor-pointer select-none\"\n (click)=\"toggle()\"\n [class.opacity-50]=\"isDisabled()\"\n [class.cursor-not-allowed]=\"isDisabled()\"\n [class.shk-toggle-disabled]=\"isDisabled()\"\n >\n @if (mode() === 'toggle') {\n <div\n class=\"shk-toggle-control relative flex-shrink-0 rounded-full\"\n role=\"switch\"\n [attr.aria-checked]=\"checked()\"\n [attr.aria-disabled]=\"isDisabled() || null\"\n [attr.aria-label]=\"label() || null\"\n [attr.tabindex]=\"isDisabled() ? -1 : 0\"\n (keydown)=\"onKeydown($event)\"\n (blur)=\"onBlur()\"\n >\n <div\n class=\"w-10 h-6 rounded-full transition-colors duration-200\"\n [class._shk-bg-primary]=\"checked()\"\n [class._shk-bg-surface-300]=\"!checked()\"\n [class._shk-dark-bg-surface-600]=\"!checked()\"\n ></div>\n <div\n class=\"shk-toggle-thumb absolute top-0.5 left-0.5 w-5 h-5 _shk-bg-white rounded-full shadow transition-transform duration-200\"\n [class.translate-x-4]=\"checked()\"\n ></div>\n </div>\n } @else {\n <div\n class=\"shk-toggle-control shk-toggle-box flex-shrink-0 w-4 h-4 rounded border-2 transition-colors duration-200 flex items-center justify-center\"\n role=\"checkbox\"\n [attr.aria-checked]=\"checked()\"\n [attr.aria-disabled]=\"isDisabled() || null\"\n [attr.aria-label]=\"label() || null\"\n [attr.tabindex]=\"isDisabled() ? -1 : 0\"\n (keydown)=\"onKeydown($event)\"\n (blur)=\"onBlur()\"\n [class._shk-bg-primary]=\"checked()\"\n [class._shk-border-primary]=\"checked()\"\n [class._shk-border-surface-300]=\"!checked()\"\n [class._shk-dark-border-surface-600]=\"!checked()\"\n >\n @if (checked()) {\n <svg class=\"w-3 h-3 text-white\" viewBox=\"0 0 12 12\" fill=\"none\">\n <path d=\"M2 6l3 3 5-5\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n </svg>\n }\n </div>\n }\n @if (label()) {\n <span class=\"text-sm _shk-text-surface-700 _shk-dark-text-surface-300\">\n {{ label() }}\n </span>\n }\n </label>\n </div>\n `,\n styles: [\n `\n .shk-toggle-control {\n outline: none;\n transition: box-shadow 0.15s ease;\n }\n .shk-toggle-control:focus-visible {\n box-shadow: 0 0 0 3px color-mix(in srgb, var(--shk-primary-500) 30%, transparent);\n }\n .shk-toggle-box {\n border-radius: 0.3rem;\n }\n label:not(.shk-toggle-disabled):hover .shk-toggle-box[aria-checked='false'] {\n border-color: var(--shk-primary-400);\n }\n `,\n ],\n providers: [\n {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => ToggleComponent),\n multi: true,\n },\n ],\n})\nexport class ToggleComponent implements ControlValueAccessor, FormCheckboxControl {\n /** Text displayed next to the control. */\n label = input<string>('');\n /** Visual style: 'toggle' (switch) or 'checkbox'. Defaults to 'toggle'. */\n mode = input<'toggle' | 'checkbox'>('toggle');\n /**\n * Checked state. Two-way bindable with `[(checked)]`; also the model that\n * Signal Forms binds to. The implicit `checkedChange` output fires with the\n * new value whenever the user toggles the control.\n */\n checked = model<boolean>(false);\n /** Disables the control (also settable through reactive forms). */\n disabled = input<boolean>(false);\n /** Emitted on blur so Signal Forms can mark the field as touched. */\n touch = output<void>();\n\n /** Reactive disabled state. */\n _disabled = signal(false);\n /** Disabled through the `disabled` input or the form control. */\n isDisabled = computed(() => this.disabled() || this._disabled());\n\n /** Callback notified with the new value on change (ControlValueAccessor). */\n private onChange: (value: boolean) => void = () => {};\n\n /** Callback notified when the control loses focus or is touched. */\n private onTouched: () => void = () => {};\n\n /** Sets the value from the form control. */\n writeValue(value: any): void {\n this.checked.set(!!value);\n }\n\n /** Registers the callback invoked on value changes (ControlValueAccessor). */\n registerOnChange(fn: any): void {\n this.onChange = fn;\n }\n\n /** Registers the callback invoked when the control is touched. */\n registerOnTouched(fn: any): void {\n this.onTouched = fn;\n }\n\n /** Reflects the disabled state of the form control. */\n setDisabledState(isDisabled: boolean): void {\n this._disabled.set(isDisabled);\n }\n\n /** Marks the control as touched when focus leaves it. */\n onBlur(): void {\n this.onTouched();\n this.touch.emit();\n }\n\n /** Space/Enter toggles the focused switch or checkbox. */\n onKeydown(event: KeyboardEvent): void {\n if (event.key === ' ' || event.key === 'Enter') {\n event.preventDefault();\n this.toggle();\n }\n }\n\n /**\n * Inverts the current value (unless disabled), notifies the form control and\n * marks the control as touched. The `checked` model emits `checkedChange`.\n */\n toggle(): void {\n if (this.isDisabled()) return;\n const newValue = !this.checked();\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,UACb;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DT,WAkBU,CACT;IACE,SAAS;IACT,aAAa,iBAAgB,eAAgB;IAC7C,OAAO;GACR,CACF;GAAA,QAAA,CAAA,wUAAA;EAAA,CAAA"}
|
|
@@ -1,187 +1,251 @@
|
|
|
1
|
-
import * as i0 from
|
|
2
|
-
import {
|
|
3
|
-
import { DOCUMENT } from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { ChangeDetectionStrategy, Component, ElementRef, HostListener, inject, input } from "@angular/core";
|
|
3
|
+
import { DOCUMENT } from "@angular/common";
|
|
4
|
+
const TOOLTIP_Z_INDEX = "2147483647";
|
|
5
|
+
var TooltipComponent = class TooltipComponent {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.text = input("", ...ngDevMode ? [{ debugName: "text" }] : /* istanbul ignore next */ []);
|
|
8
|
+
this.position = input("bottom", ...ngDevMode ? [{ debugName: "position" }] : /* istanbul ignore next */ []);
|
|
9
|
+
this.mode = input("hover", ...ngDevMode ? [{ debugName: "mode" }] : /* istanbul ignore next */ []);
|
|
10
|
+
this.offset = input(8, ...ngDevMode ? [{ debugName: "offset" }] : /* istanbul ignore next */ []);
|
|
11
|
+
this.host = inject(ElementRef);
|
|
12
|
+
this.document = inject(DOCUMENT);
|
|
13
|
+
this.tooltipEl = null;
|
|
14
|
+
this.cleanup = null;
|
|
15
|
+
}
|
|
16
|
+
onMouseEnter() {
|
|
17
|
+
this.open();
|
|
18
|
+
}
|
|
19
|
+
onMouseLeave() {
|
|
20
|
+
this.hide();
|
|
21
|
+
}
|
|
22
|
+
onFocusIn() {
|
|
23
|
+
this.open();
|
|
24
|
+
}
|
|
25
|
+
onFocusOut() {
|
|
26
|
+
this.hide();
|
|
27
|
+
}
|
|
28
|
+
open() {
|
|
29
|
+
if (!this.text()) return;
|
|
30
|
+
const trigger = this.host.nativeElement.querySelector(".shk-tooltip-trigger");
|
|
31
|
+
if (!trigger) return;
|
|
32
|
+
this.show(trigger);
|
|
33
|
+
}
|
|
34
|
+
show(trigger) {
|
|
35
|
+
this.removeTooltip();
|
|
36
|
+
const el = this.document.createElement("span");
|
|
37
|
+
el.className = "shk-tooltip-dynamic";
|
|
38
|
+
el.textContent = this.text();
|
|
39
|
+
Object.assign(el.style, {
|
|
40
|
+
position: "fixed",
|
|
41
|
+
zIndex: TOOLTIP_Z_INDEX,
|
|
42
|
+
backgroundColor: "var(--shk-tooltip-bg, #27272a)",
|
|
43
|
+
color: "var(--shk-tooltip-text, #fff)",
|
|
44
|
+
padding: "4px 8px",
|
|
45
|
+
borderRadius: "6px",
|
|
46
|
+
fontSize: "12px",
|
|
47
|
+
lineHeight: "1.4",
|
|
48
|
+
whiteSpace: "pre-line",
|
|
49
|
+
maxWidth: "min(80vw, 22rem)",
|
|
50
|
+
boxShadow: "0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",
|
|
51
|
+
pointerEvents: "none",
|
|
52
|
+
opacity: "0",
|
|
53
|
+
transition: "opacity 0.15s ease"
|
|
54
|
+
});
|
|
55
|
+
this.document.body.appendChild(el);
|
|
56
|
+
this.tooltipEl = el;
|
|
57
|
+
const place = () => {
|
|
58
|
+
const rect = trigger.getBoundingClientRect();
|
|
59
|
+
const w = el.offsetWidth;
|
|
60
|
+
const h = el.offsetHeight;
|
|
61
|
+
const { left, top } = this.computePosition(rect, w, h);
|
|
62
|
+
el.style.left = `${left}px`;
|
|
63
|
+
el.style.top = `${top}px`;
|
|
64
|
+
};
|
|
65
|
+
place();
|
|
66
|
+
requestAnimationFrame(() => {
|
|
67
|
+
if (this.tooltipEl === el) el.style.opacity = "1";
|
|
68
|
+
});
|
|
69
|
+
const onScrollOrResize = () => place();
|
|
70
|
+
window.addEventListener("scroll", onScrollOrResize, true);
|
|
71
|
+
window.addEventListener("resize", onScrollOrResize);
|
|
72
|
+
this.cleanup = () => {
|
|
73
|
+
window.removeEventListener("scroll", onScrollOrResize, true);
|
|
74
|
+
window.removeEventListener("resize", onScrollOrResize);
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
computePosition(rect, width, height) {
|
|
78
|
+
const off = this.offset();
|
|
79
|
+
const viewportW = this.document.defaultView?.innerWidth ?? 0;
|
|
80
|
+
const viewportH = this.document.defaultView?.innerHeight ?? 0;
|
|
81
|
+
let x;
|
|
82
|
+
let y;
|
|
83
|
+
if (this.position() === "right") {
|
|
84
|
+
x = rect.right + off;
|
|
85
|
+
y = rect.top + rect.height / 2 - height / 2;
|
|
86
|
+
} else if (this.position() === "bottom") {
|
|
87
|
+
x = rect.left + rect.width / 2 - width / 2;
|
|
88
|
+
y = rect.bottom + off;
|
|
89
|
+
} else {
|
|
90
|
+
x = rect.left + rect.width / 2 - width / 2;
|
|
91
|
+
y = rect.top - off - height;
|
|
92
|
+
}
|
|
93
|
+
const margin = 4;
|
|
94
|
+
return {
|
|
95
|
+
left: Math.max(margin, Math.min(x, Math.max(margin, viewportW - width - margin))),
|
|
96
|
+
top: Math.max(margin, Math.min(y, Math.max(margin, viewportH - height - margin)))
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
hide() {
|
|
100
|
+
if (!this.tooltipEl) return;
|
|
101
|
+
const el = this.tooltipEl;
|
|
102
|
+
el.style.opacity = "0";
|
|
103
|
+
this.tooltipEl = null;
|
|
104
|
+
setTimeout(() => {
|
|
105
|
+
el.remove();
|
|
106
|
+
}, 150);
|
|
107
|
+
}
|
|
108
|
+
removeTooltip() {
|
|
109
|
+
this.cleanup?.();
|
|
110
|
+
this.cleanup = null;
|
|
111
|
+
this.tooltipEl?.remove();
|
|
112
|
+
this.tooltipEl = null;
|
|
113
|
+
}
|
|
114
|
+
ngOnDestroy() {
|
|
115
|
+
this.removeTooltip();
|
|
116
|
+
}
|
|
117
|
+
static {
|
|
118
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
119
|
+
minVersion: "12.0.0",
|
|
120
|
+
version: "22.3.2",
|
|
121
|
+
ngImport: i0,
|
|
122
|
+
type: TooltipComponent,
|
|
123
|
+
deps: [],
|
|
124
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
static {
|
|
128
|
+
this.ɵcmp = i0.ɵɵngDeclareComponent({
|
|
129
|
+
minVersion: "17.1.0",
|
|
130
|
+
version: "22.3.2",
|
|
131
|
+
type: TooltipComponent,
|
|
132
|
+
isStandalone: true,
|
|
133
|
+
selector: "shk-tooltip",
|
|
134
|
+
inputs: {
|
|
135
|
+
text: {
|
|
136
|
+
classPropertyName: "text",
|
|
137
|
+
publicName: "text",
|
|
138
|
+
isSignal: true,
|
|
139
|
+
isRequired: false,
|
|
140
|
+
transformFunction: null
|
|
141
|
+
},
|
|
142
|
+
position: {
|
|
143
|
+
classPropertyName: "position",
|
|
144
|
+
publicName: "position",
|
|
145
|
+
isSignal: true,
|
|
146
|
+
isRequired: false,
|
|
147
|
+
transformFunction: null
|
|
148
|
+
},
|
|
149
|
+
mode: {
|
|
150
|
+
classPropertyName: "mode",
|
|
151
|
+
publicName: "mode",
|
|
152
|
+
isSignal: true,
|
|
153
|
+
isRequired: false,
|
|
154
|
+
transformFunction: null
|
|
155
|
+
},
|
|
156
|
+
offset: {
|
|
157
|
+
classPropertyName: "offset",
|
|
158
|
+
publicName: "offset",
|
|
159
|
+
isSignal: true,
|
|
160
|
+
isRequired: false,
|
|
161
|
+
transformFunction: null
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
host: { listeners: {
|
|
165
|
+
"mouseenter": "onMouseEnter()",
|
|
166
|
+
"mouseleave": "onMouseLeave()",
|
|
167
|
+
"focusin": "onFocusIn()",
|
|
168
|
+
"focusout": "onFocusOut()"
|
|
169
|
+
} },
|
|
170
|
+
ngImport: i0,
|
|
171
|
+
template: `
|
|
152
172
|
<div class="shk-tooltip-trigger inline-flex">
|
|
153
173
|
<ng-content></ng-content>
|
|
154
174
|
</div>
|
|
155
|
-
`,
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
175
|
+
`,
|
|
176
|
+
isInline: true,
|
|
177
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
182
|
+
minVersion: "12.0.0",
|
|
183
|
+
version: "22.3.2",
|
|
184
|
+
ngImport: i0,
|
|
185
|
+
type: TooltipComponent,
|
|
186
|
+
decorators: [{
|
|
187
|
+
type: Component,
|
|
188
|
+
args: [{
|
|
189
|
+
selector: "shk-tooltip",
|
|
190
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
191
|
+
template: `
|
|
163
192
|
<div class="shk-tooltip-trigger inline-flex">
|
|
164
193
|
<ng-content></ng-content>
|
|
165
194
|
</div>
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
195
|
+
`
|
|
196
|
+
}]
|
|
197
|
+
}],
|
|
198
|
+
propDecorators: {
|
|
199
|
+
text: [{
|
|
200
|
+
type: i0.Input,
|
|
201
|
+
args: [{
|
|
202
|
+
isSignal: true,
|
|
203
|
+
alias: "text",
|
|
204
|
+
required: false
|
|
205
|
+
}]
|
|
206
|
+
}],
|
|
207
|
+
position: [{
|
|
208
|
+
type: i0.Input,
|
|
209
|
+
args: [{
|
|
210
|
+
isSignal: true,
|
|
211
|
+
alias: "position",
|
|
212
|
+
required: false
|
|
213
|
+
}]
|
|
214
|
+
}],
|
|
215
|
+
mode: [{
|
|
216
|
+
type: i0.Input,
|
|
217
|
+
args: [{
|
|
218
|
+
isSignal: true,
|
|
219
|
+
alias: "mode",
|
|
220
|
+
required: false
|
|
221
|
+
}]
|
|
222
|
+
}],
|
|
223
|
+
offset: [{
|
|
224
|
+
type: i0.Input,
|
|
225
|
+
args: [{
|
|
226
|
+
isSignal: true,
|
|
227
|
+
alias: "offset",
|
|
228
|
+
required: false
|
|
229
|
+
}]
|
|
230
|
+
}],
|
|
231
|
+
onMouseEnter: [{
|
|
232
|
+
type: HostListener,
|
|
233
|
+
args: ["mouseenter"]
|
|
234
|
+
}],
|
|
235
|
+
onMouseLeave: [{
|
|
236
|
+
type: HostListener,
|
|
237
|
+
args: ["mouseleave"]
|
|
238
|
+
}],
|
|
239
|
+
onFocusIn: [{
|
|
240
|
+
type: HostListener,
|
|
241
|
+
args: ["focusin"]
|
|
242
|
+
}],
|
|
243
|
+
onFocusOut: [{
|
|
244
|
+
type: HostListener,
|
|
245
|
+
args: ["focusout"]
|
|
246
|
+
}]
|
|
247
|
+
}
|
|
248
|
+
});
|
|
186
249
|
export { TooltipComponent };
|
|
187
|
-
|
|
250
|
+
|
|
251
|
+
//# sourceMappingURL=shirkasoft-ui-components-tooltip.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shirkasoft-ui-components-tooltip.mjs","sources":["../../../projects/ui-components/tooltip/tooltip.component.ts","../../../projects/ui-components/tooltip/shirkasoft-ui-components-tooltip.ts"],"sourcesContent":["import {\n Component,\n input,\n ElementRef,\n inject,\n HostListener,\n OnDestroy,\n} from '@angular/core';\nimport { DOCUMENT } from '@angular/common';\n\nconst TOOLTIP_Z_INDEX = '2147483647';\n\n/**\n * Shirkasoft UI Components.\n * Authors: Roberto Valladares Martin (Ansem13), Julio César García García (Sanjuli14).\n * Belongs to Shirkasoft.\n */\n\n/**\n * Tooltip rendered in `document.body` with `position: fixed`, so it always\n * floats above any container (tables with `overflow: hidden`, modals, scroll\n * wrappers, etc.) and never gets clipped or hidden behind its anchor element.\n */\n@Component({\n selector: 'shk-tooltip',\n standalone: true,\n template: `\n <div class=\"shk-tooltip-trigger inline-flex\">\n <ng-content></ng-content>\n </div>\n `,\n})\nexport class TooltipComponent implements OnDestroy {\n /** Content of the tooltip. */\n readonly text = input<string>('');\n /** Preferred placement relative to the trigger. */\n readonly position = input<'top' | 'bottom' | 'right'>('bottom');\n /** 'hover' shows on mouse enter; 'fixed' stays pinned to the content. */\n readonly mode = input<'hover' | 'fixed'>('hover');\n /** Distance (px) between the tooltip and the trigger. */\n readonly offset = input(8);\n\n private readonly host = inject(ElementRef<HTMLElement>);\n private readonly document = inject(DOCUMENT);\n\n /** The dynamically created tooltip element. */\n private tooltipEl: HTMLElement | null = null;\n /** Unsubscribe callbacks for the scroll/resize listeners. */\n private cleanup: (() => void) | null = null;\n\n /** Shows the tooltip over the host trigger on mouseenter. */\n @HostListener('mouseenter')\n onMouseEnter(): void {\n this.open();\n }\n\n /** Hides the tooltip on mouseleave. */\n @HostListener('mouseleave')\n onMouseLeave(): void {\n this.hide();\n }\n\n /** Also opens on keyboard focus, so icon-only triggers are readable. */\n @HostListener('focusin')\n onFocusIn(): void {\n this.open();\n }\n\n /** Closes when the focus leaves the trigger. */\n @HostListener('focusout')\n onFocusOut(): void {\n this.hide();\n }\n\n /** Opens the tooltip when there is text to show. */\n private open(): void {\n if (!this.text()) return;\n const trigger = this.host.nativeElement.querySelector(\n '.shk-tooltip-trigger',\n ) as HTMLElement | null;\n if (!trigger) return;\n this.show(trigger);\n }\n\n /** Creates and positions the tooltip element on `document.body`. */\n private show(trigger: HTMLElement): void {\n this.removeTooltip();\n\n const el = this.document.createElement('span');\n el.className = 'shk-tooltip-dynamic';\n el.textContent = this.text();\n Object.assign(el.style, {\n position: 'fixed',\n zIndex: TOOLTIP_Z_INDEX,\n backgroundColor: 'var(--shk-tooltip-bg, #27272a)',\n color: 'var(--shk-tooltip-text, #fff)',\n padding: '4px 8px',\n borderRadius: '6px',\n fontSize: '12px',\n lineHeight: '1.4',\n whiteSpace: 'pre-line',\n maxWidth: 'min(80vw, 22rem)',\n boxShadow:\n '0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)',\n pointerEvents: 'none',\n opacity: '0',\n transition: 'opacity 0.15s ease',\n });\n\n this.document.body.appendChild(el);\n this.tooltipEl = el;\n\n const place = () => {\n const rect = trigger.getBoundingClientRect();\n const w = el.offsetWidth;\n const h = el.offsetHeight;\n const { left, top } = this.computePosition(rect, w, h);\n el.style.left = `${left}px`;\n el.style.top = `${top}px`;\n };\n\n place();\n requestAnimationFrame(() => {\n if (this.tooltipEl === el) {\n el.style.opacity = '1';\n }\n });\n\n const onScrollOrResize = () => place();\n window.addEventListener('scroll', onScrollOrResize, true);\n window.addEventListener('resize', onScrollOrResize);\n this.cleanup = () => {\n window.removeEventListener('scroll', onScrollOrResize, true);\n window.removeEventListener('resize', onScrollOrResize);\n };\n }\n\n /** Computes the tooltip position, clamped to the viewport. */\n private computePosition(\n rect: DOMRect,\n width: number,\n height: number,\n ): { left: number; top: number } {\n const off = this.offset();\n const viewportW = this.document.defaultView?.innerWidth ?? 0;\n const viewportH = this.document.defaultView?.innerHeight ?? 0;\n\n let x: number;\n let y: number;\n\n if (this.position() === 'right') {\n x = rect.right + off;\n y = rect.top + rect.height / 2 - height / 2;\n } else if (this.position() === 'bottom') {\n x = rect.left + rect.width / 2 - width / 2;\n y = rect.bottom + off;\n } else {\n x = rect.left + rect.width / 2 - width / 2;\n y = rect.top - off - height;\n }\n\n const margin = 4;\n const left = Math.max(\n margin,\n Math.min(x, Math.max(margin, viewportW - width - margin)),\n );\n const top = Math.max(\n margin,\n Math.min(y, Math.max(margin, viewportH - height - margin)),\n );\n return { left, top };\n }\n\n /** Fades the tooltip out and removes it from the DOM. */\n private hide(): void {\n if (!this.tooltipEl) return;\n const el = this.tooltipEl;\n el.style.opacity = '0';\n this.tooltipEl = null;\n setTimeout(() => {\n el.remove();\n }, 150);\n }\n\n /** Removes the tooltip and its listeners. */\n private removeTooltip(): void {\n this.cleanup?.();\n this.cleanup = null;\n this.tooltipEl?.remove();\n this.tooltipEl = null;\n }\n\n /** Cleans up the tooltip on component destroy. */\n ngOnDestroy(): void {\n this.removeTooltip();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAUA,MAAM,eAAe,GAAG,YAAY;AAEpC;;;;AAIG;AAEH;;;;AAIG;MAUU,gBAAgB,CAAA;AAT7B,IAAA,WAAA,GAAA;;AAWW,QAAA,IAAA,CAAA,IAAI,GAAG,KAAK,CAAS,EAAE,2EAAC;;AAExB,QAAA,IAAA,CAAA,QAAQ,GAAG,KAAK,CAA6B,QAAQ,+EAAC;;AAEtD,QAAA,IAAA,CAAA,IAAI,GAAG,KAAK,CAAoB,OAAO,2EAAC;;AAExC,QAAA,IAAA,CAAA,MAAM,GAAG,KAAK,CAAC,CAAC,6EAAC;AAET,QAAA,IAAA,CAAA,IAAI,GAAG,MAAM,EAAC,UAAuB,EA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A,EAAA,IAAA,EAAA,EAAA,QAAA,EAAA,EAAA,iBAAA,EAAA,UAAA,EAAA,UAAA,EAAA,UAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,IAAA,EAAA,EAAA,iBAAA,EAAA,MAAA,EAAA,UAAA,EAAA,MAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,MAAA,EAAA,EAAA,iBAAA,EAAA,QAAA,EAAA,UAAA,EAAA,QAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,IAAA,EAAA,EAAA,SAAA,EAAA,EAAA,YAAA,EAAA,gBAAA,EAAA,YAAA,EAAA,gBAAA,EAAA,SAAA,EAAA,aAAA,EAAA,UAAA,EAAA,cAAA,EAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,QAAA,EANjB;;;;AAIT,EAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,CAAA;;4FAEU,gBAAgB,EAAA,UAAA,EAAA,CAAA;kBAT5B,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,aAAa;AACvB,oBAAA,UAAU,EAAE,IAAI;AAChB,oBAAA,QAAQ,EAAE;;;;AAIT,EAAA,CAAA;AACF,iBAAA;;sBAoBE,YAAY;uBAAC,YAAY;;sBAMzB,YAAY;uBAAC,YAAY;;sBAMzB,YAAY;uBAAC,SAAS;;sBAMtB,YAAY;uBAAC,UAAU;;;ACrE1B;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"shirkasoft-ui-components-tooltip.mjs","names":[],"sources":["../../../projects/ui-components/tooltip/tooltip.component.ts"],"sourcesContent":["import {\n Component,\n ChangeDetectionStrategy,\n input,\n ElementRef,\n inject,\n HostListener,\n OnDestroy,\n} from '@angular/core';\nimport { DOCUMENT } from '@angular/common';\n\nconst TOOLTIP_Z_INDEX = '2147483647';\n\n/**\n * Shirkasoft UI Components.\n * Authors: Roberto Valladares Martin (Ansem13), Julio César García García (Sanjuli14).\n * Belongs to Shirkasoft.\n */\n\n/**\n * Tooltip rendered in `document.body` with `position: fixed`, so it always\n * floats above any container (tables with `overflow: hidden`, modals, scroll\n * wrappers, etc.) and never gets clipped or hidden behind its anchor element.\n */\n@Component({\n selector: 'shk-tooltip',\n changeDetection: ChangeDetectionStrategy.OnPush,\n template: `\n <div class=\"shk-tooltip-trigger inline-flex\">\n <ng-content></ng-content>\n </div>\n `,\n})\nexport class TooltipComponent implements OnDestroy {\n /** Content of the tooltip. */\n readonly text = input<string>('');\n /** Preferred placement relative to the trigger. */\n readonly position = input<'top' | 'bottom' | 'right'>('bottom');\n /** 'hover' shows on mouse enter; 'fixed' stays pinned to the content. */\n readonly mode = input<'hover' | 'fixed'>('hover');\n /** Distance (px) between the tooltip and the trigger. */\n readonly offset = input(8);\n\n private readonly host = inject(ElementRef<HTMLElement>);\n private readonly document = inject(DOCUMENT);\n\n /** The dynamically created tooltip element. */\n private tooltipEl: HTMLElement | null = null;\n /** Unsubscribe callbacks for the scroll/resize listeners. */\n private cleanup: (() => void) | null = null;\n\n /** Shows the tooltip over the host trigger on mouseenter. */\n @HostListener('mouseenter')\n onMouseEnter(): void {\n this.open();\n }\n\n /** Hides the tooltip on mouseleave. */\n @HostListener('mouseleave')\n onMouseLeave(): void {\n this.hide();\n }\n\n /** Also opens on keyboard focus, so icon-only triggers are readable. */\n @HostListener('focusin')\n onFocusIn(): void {\n this.open();\n }\n\n /** Closes when the focus leaves the trigger. */\n @HostListener('focusout')\n onFocusOut(): void {\n this.hide();\n }\n\n /** Opens the tooltip when there is text to show. */\n private open(): void {\n if (!this.text()) return;\n const trigger = this.host.nativeElement.querySelector(\n '.shk-tooltip-trigger',\n ) as HTMLElement | null;\n if (!trigger) return;\n this.show(trigger);\n }\n\n /** Creates and positions the tooltip element on `document.body`. */\n private show(trigger: HTMLElement): void {\n this.removeTooltip();\n\n const el = this.document.createElement('span');\n el.className = 'shk-tooltip-dynamic';\n el.textContent = this.text();\n Object.assign(el.style, {\n position: 'fixed',\n zIndex: TOOLTIP_Z_INDEX,\n backgroundColor: 'var(--shk-tooltip-bg, #27272a)',\n color: 'var(--shk-tooltip-text, #fff)',\n padding: '4px 8px',\n borderRadius: '6px',\n fontSize: '12px',\n lineHeight: '1.4',\n whiteSpace: 'pre-line',\n maxWidth: 'min(80vw, 22rem)',\n boxShadow:\n '0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)',\n pointerEvents: 'none',\n opacity: '0',\n transition: 'opacity 0.15s ease',\n });\n\n this.document.body.appendChild(el);\n this.tooltipEl = el;\n\n const place = () => {\n const rect = trigger.getBoundingClientRect();\n const w = el.offsetWidth;\n const h = el.offsetHeight;\n const { left, top } = this.computePosition(rect, w, h);\n el.style.left = `${left}px`;\n el.style.top = `${top}px`;\n };\n\n place();\n requestAnimationFrame(() => {\n if (this.tooltipEl === el) {\n el.style.opacity = '1';\n }\n });\n\n const onScrollOrResize = () => place();\n window.addEventListener('scroll', onScrollOrResize, true);\n window.addEventListener('resize', onScrollOrResize);\n this.cleanup = () => {\n window.removeEventListener('scroll', onScrollOrResize, true);\n window.removeEventListener('resize', onScrollOrResize);\n };\n }\n\n /** Computes the tooltip position, clamped to the viewport. */\n private computePosition(\n rect: DOMRect,\n width: number,\n height: number,\n ): { left: number; top: number } {\n const off = this.offset();\n const viewportW = this.document.defaultView?.innerWidth ?? 0;\n const viewportH = this.document.defaultView?.innerHeight ?? 0;\n\n let x: number;\n let y: number;\n\n if (this.position() === 'right') {\n x = rect.right + off;\n y = rect.top + rect.height / 2 - height / 2;\n } else if (this.position() === 'bottom') {\n x = rect.left + rect.width / 2 - width / 2;\n y = rect.bottom + off;\n } else {\n x = rect.left + rect.width / 2 - width / 2;\n y = rect.top - off - height;\n }\n\n const margin = 4;\n const left = Math.max(\n margin,\n Math.min(x, Math.max(margin, viewportW - width - margin)),\n );\n const top = Math.max(\n margin,\n Math.min(y, Math.max(margin, viewportH - height - margin)),\n );\n return { left, top };\n }\n\n /** Fades the tooltip out and removes it from the DOM. */\n private hide(): void {\n if (!this.tooltipEl) return;\n const el = this.tooltipEl;\n el.style.opacity = '0';\n this.tooltipEl = null;\n setTimeout(() => {\n el.remove();\n }, 150);\n }\n\n /** Removes the tooltip and its listeners. */\n private removeTooltip(): void {\n this.cleanup?.();\n this.cleanup = null;\n this.tooltipEl?.remove();\n this.tooltipEl = null;\n }\n\n /** Cleans up the tooltip on component destroy. */\n ngOnDestroy(): void {\n this.removeTooltip();\n }\n}\n"],"mappings":";;;AAWA,MAAM,kBAAkB;AAsBxB,IAAa,mBAAb,MAAa,iBAAgB;CAT7B,cAAA;EAWW,KAAA,OAAO,MAAc,IAAG,GAAA,YAAA,CAAA,EAAA,WAAA,OAAA,CAAA,+BAAA,CAAA,CAAA;EAExB,KAAA,WAAW,MAAkC,UAAS,GAAA,YAAA,CAAA,EAAA,WAAA,WAAA,CAAA,+BAAA,CAAA,CAAA;EAEtD,KAAA,OAAO,MAAyB,SAAQ,GAAA,YAAA,CAAA,EAAA,WAAA,OAAA,CAAA,+BAAA,CAAA,CAAA;EAExC,KAAA,SAAS,MAAM,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,SAAA,CAAA,+BAAA,CAAA,CAAA;EAET,KAAA,OAAO,OAAO,UAAuB;EACrC,KAAA,WAAW,OAAO,QAAQ;EAGnC,KAAA,YAAgC;EAEhC,KAAA,UAA+B;CAoJxC;CAhJC,eAAY;EACV,KAAK,KAAI;CACX;CAIA,eAAY;EACV,KAAK,KAAI;CACX;CAIA,YAAS;EACP,KAAK,KAAI;CACX;CAIA,aAAU;EACR,KAAK,KAAI;CACX;CAGQ,OAAI;EACV,IAAI,CAAC,KAAK,KAAI,GAAI;EAClB,MAA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