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.
Files changed (98) hide show
  1. package/README.md +415 -42
  2. package/fesm2022/shirkasoft-ui-components-breadcrumb.mjs +189 -100
  3. package/fesm2022/shirkasoft-ui-components-breadcrumb.mjs.map +1 -1
  4. package/fesm2022/shirkasoft-ui-components-button.mjs +367 -73
  5. package/fesm2022/shirkasoft-ui-components-button.mjs.map +1 -1
  6. package/fesm2022/shirkasoft-ui-components-chart.mjs +206 -142
  7. package/fesm2022/shirkasoft-ui-components-chart.mjs.map +1 -1
  8. package/fesm2022/shirkasoft-ui-components-config.mjs +976 -0
  9. package/fesm2022/shirkasoft-ui-components-config.mjs.map +1 -0
  10. package/fesm2022/shirkasoft-ui-components-confirm-dialog.mjs +307 -142
  11. package/fesm2022/shirkasoft-ui-components-confirm-dialog.mjs.map +1 -1
  12. package/fesm2022/shirkasoft-ui-components-date-picker.mjs +1624 -1400
  13. package/fesm2022/shirkasoft-ui-components-date-picker.mjs.map +1 -1
  14. package/fesm2022/shirkasoft-ui-components-fieldset.mjs +347 -92
  15. package/fesm2022/shirkasoft-ui-components-fieldset.mjs.map +1 -1
  16. package/fesm2022/shirkasoft-ui-components-file-upload.mjs +484 -293
  17. package/fesm2022/shirkasoft-ui-components-file-upload.mjs.map +1 -1
  18. package/fesm2022/shirkasoft-ui-components-icons.mjs +1141 -0
  19. package/fesm2022/shirkasoft-ui-components-icons.mjs.map +1 -0
  20. package/fesm2022/shirkasoft-ui-components-knob.mjs +395 -180
  21. package/fesm2022/shirkasoft-ui-components-knob.mjs.map +1 -1
  22. package/fesm2022/shirkasoft-ui-components-loading.mjs +505 -128
  23. package/fesm2022/shirkasoft-ui-components-loading.mjs.map +1 -1
  24. package/fesm2022/shirkasoft-ui-components-modal.mjs +311 -303
  25. package/fesm2022/shirkasoft-ui-components-modal.mjs.map +1 -1
  26. package/fesm2022/shirkasoft-ui-components-notification.mjs +188 -142
  27. package/fesm2022/shirkasoft-ui-components-notification.mjs.map +1 -1
  28. package/fesm2022/shirkasoft-ui-components-price-input.mjs +517 -277
  29. package/fesm2022/shirkasoft-ui-components-price-input.mjs.map +1 -1
  30. package/fesm2022/shirkasoft-ui-components-rail-sidebar.mjs +669 -289
  31. package/fesm2022/shirkasoft-ui-components-rail-sidebar.mjs.map +1 -1
  32. package/fesm2022/shirkasoft-ui-components-select.mjs +1014 -814
  33. package/fesm2022/shirkasoft-ui-components-select.mjs.map +1 -1
  34. package/fesm2022/shirkasoft-ui-components-sidebar.mjs +508 -184
  35. package/fesm2022/shirkasoft-ui-components-sidebar.mjs.map +1 -1
  36. package/fesm2022/shirkasoft-ui-components-skeleton.mjs +197 -57
  37. package/fesm2022/shirkasoft-ui-components-skeleton.mjs.map +1 -1
  38. package/fesm2022/shirkasoft-ui-components-table.mjs +1918 -1676
  39. package/fesm2022/shirkasoft-ui-components-table.mjs.map +1 -1
  40. package/fesm2022/shirkasoft-ui-components-tabs.mjs +419 -177
  41. package/fesm2022/shirkasoft-ui-components-tabs.mjs.map +1 -1
  42. package/fesm2022/shirkasoft-ui-components-tag.mjs +177 -51
  43. package/fesm2022/shirkasoft-ui-components-tag.mjs.map +1 -1
  44. package/fesm2022/shirkasoft-ui-components-text-field.mjs +687 -369
  45. package/fesm2022/shirkasoft-ui-components-text-field.mjs.map +1 -1
  46. package/fesm2022/shirkasoft-ui-components-theme-picker.mjs +466 -0
  47. package/fesm2022/shirkasoft-ui-components-theme-picker.mjs.map +1 -0
  48. package/fesm2022/shirkasoft-ui-components-theme.mjs +147 -0
  49. package/fesm2022/shirkasoft-ui-components-theme.mjs.map +1 -0
  50. package/fesm2022/shirkasoft-ui-components-timeline.mjs +791 -215
  51. package/fesm2022/shirkasoft-ui-components-timeline.mjs.map +1 -1
  52. package/fesm2022/shirkasoft-ui-components-toggle.mjs +205 -128
  53. package/fesm2022/shirkasoft-ui-components-toggle.mjs.map +1 -1
  54. package/fesm2022/shirkasoft-ui-components-tooltip.mjs +244 -180
  55. package/fesm2022/shirkasoft-ui-components-tooltip.mjs.map +1 -1
  56. package/fesm2022/shirkasoft-ui-components-utils.mjs +97 -125
  57. package/fesm2022/shirkasoft-ui-components-utils.mjs.map +1 -1
  58. package/fesm2022/shirkasoft-ui-components-wizard.mjs +673 -166
  59. package/fesm2022/shirkasoft-ui-components-wizard.mjs.map +1 -1
  60. package/fesm2022/shirkasoft-ui-components.mjs +0 -9
  61. package/package.json +37 -7
  62. package/src/baseline.css +2472 -0
  63. package/src/theme.css +15 -543
  64. package/src/themes/ocean.css +56 -0
  65. package/src/themes/sunset.css +55 -0
  66. package/src/themes/violet.css +25 -0
  67. package/src/tokens.css +612 -0
  68. package/types/shirkasoft-ui-components-breadcrumb.d.ts +59 -44
  69. package/types/shirkasoft-ui-components-button.d.ts +142 -49
  70. package/types/shirkasoft-ui-components-chart.d.ts +59 -44
  71. package/types/shirkasoft-ui-components-config.d.ts +357 -0
  72. package/types/shirkasoft-ui-components-confirm-dialog.d.ts +107 -65
  73. package/types/shirkasoft-ui-components-date-picker.d.ts +527 -373
  74. package/types/shirkasoft-ui-components-fieldset.d.ts +135 -59
  75. package/types/shirkasoft-ui-components-file-upload.d.ts +176 -106
  76. package/types/shirkasoft-ui-components-icons.d.ts +1430 -0
  77. package/types/shirkasoft-ui-components-knob.d.ts +151 -64
  78. package/types/shirkasoft-ui-components-loading.d.ts +155 -64
  79. package/types/shirkasoft-ui-components-modal.d.ts +134 -132
  80. package/types/shirkasoft-ui-components-notification.d.ts +63 -58
  81. package/types/shirkasoft-ui-components-price-input.d.ts +198 -85
  82. package/types/shirkasoft-ui-components-rail-sidebar.d.ts +262 -142
  83. package/types/shirkasoft-ui-components-select.d.ts +301 -192
  84. package/types/shirkasoft-ui-components-sidebar.d.ts +198 -92
  85. package/types/shirkasoft-ui-components-skeleton.d.ts +68 -27
  86. package/types/shirkasoft-ui-components-table.d.ts +849 -649
  87. package/types/shirkasoft-ui-components-tabs.d.ts +102 -61
  88. package/types/shirkasoft-ui-components-tag.d.ts +54 -23
  89. package/types/shirkasoft-ui-components-text-field.d.ts +231 -111
  90. package/types/shirkasoft-ui-components-theme-picker.d.ts +117 -0
  91. package/types/shirkasoft-ui-components-theme.d.ts +80 -0
  92. package/types/shirkasoft-ui-components-timeline.d.ts +326 -150
  93. package/types/shirkasoft-ui-components-toggle.d.ts +76 -45
  94. package/types/shirkasoft-ui-components-tooltip.d.ts +64 -43
  95. package/types/shirkasoft-ui-components-utils.d.ts +26 -17
  96. package/types/shirkasoft-ui-components-wizard.d.ts +236 -86
  97. package/types/shirkasoft-ui-components.d.ts +1 -2
  98. 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","../../../projects/ui-components/toggle/shirkasoft-ui-components-toggle.ts"],"sourcesContent":["import { Component, forwardRef, input, output, signal, effect, computed } from '@angular/core';\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\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@Component({\n selector: 'shk-toggle',\n standalone: true,\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]=\"_value()\"\n [attr.aria-disabled]=\"isDisabled() || null\"\n [attr.aria-label]=\"label() || null\"\n [attr.tabindex]=\"isDisabled() ? -1 : 0\"\n (keydown)=\"onKeydown($event)\"\n >\n <div\n class=\"w-10 h-6 rounded-full transition-colors duration-200\"\n [class._shk-bg-primary]=\"_value()\"\n [class._shk-bg-surface-300]=\"!_value()\"\n [class._shk-dark-bg-surface-600]=\"!_value()\"\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]=\"_value()\"\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]=\"_value()\"\n [attr.aria-disabled]=\"isDisabled() || null\"\n [attr.aria-label]=\"label() || null\"\n [attr.tabindex]=\"isDisabled() ? -1 : 0\"\n (keydown)=\"onKeydown($event)\"\n [class._shk-bg-primary]=\"_value()\"\n [class._shk-border-primary]=\"_value()\"\n [class._shk-border-surface-300]=\"!_value()\"\n [class._shk-dark-border-surface-600]=\"!_value()\"\n >\n @if (_value()) {\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 {\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 /** Manually controlled checked state (supports one-way binding). */\n checked = input<boolean | undefined>(undefined);\n /** Emitted with the new value when the user toggles the control. */\n checkedChange = output<boolean>();\n /** Disables the control (also settable through reactive forms). */\n disabled = input<boolean>(false);\n\n /** Internal controlled/reactive value. */\n _value = signal(false);\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 constructor() {\n effect(() => {\n const manual = this.checked();\n if (manual !== undefined) {\n this._value.set(manual);\n }\n });\n }\n\n /** Sets the value from the form control. */\n writeValue(value: any): void {\n this._value.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 /**\n * Inverts the current value (unless disabled), notifies the form control,\n * marks the control as touched and emits `checkedChange`.\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 toggle(): void {\n if (this.isDisabled()) return;\n const newValue = !this._value();\n this._value.set(newValue);\n this.onChange(newValue);\n this.onT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ACE,4BAAA,OAAO,EAAE,iBAAiB;AAC1B,4BAAA,WAAW,EAAE,UAAU,CAAC,qBAAqB,CAAC;AAC9C,4BAAA,KAAK,EAAE,IAAI;AACZ,yBAAA;AACF,qBAAA,EAAA,MAAA,EAAA,CAAA,wUAAA,CAAA,EAAA;;;ACrGH;;AAEG;;;;"}
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();\n this.checked.set(newValue);\n this.onChange(newValue);\n this.onTouched();\n }\n}\n"],"mappings":";;;;AA6GA,IAAa,kBAAb,MAAa,gBAAe;CA3F5B,cAAA;EA6FE,K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,iBAAgB,eAAgB;IAC7C,OAAO;GACR,CACF;GAAA,QAAA,CAAA,wUAAA;EAAA,CAAA"}
@@ -1,187 +1,251 @@
1
- import * as i0 from '@angular/core';
2
- import { input, inject, ElementRef, HostListener, Component } from '@angular/core';
3
- import { DOCUMENT } from '@angular/common';
4
-
5
- const TOOLTIP_Z_INDEX = '2147483647';
6
- /**
7
- * Shirkasoft UI Components.
8
- * Authors: Roberto Valladares Martin (Ansem13), Julio César García García (Sanjuli14).
9
- * Belongs to Shirkasoft.
10
- */
11
- /**
12
- * Tooltip rendered in `document.body` with `position: fixed`, so it always
13
- * floats above any container (tables with `overflow: hidden`, modals, scroll
14
- * wrappers, etc.) and never gets clipped or hidden behind its anchor element.
15
- */
16
- class TooltipComponent {
17
- constructor() {
18
- /** Content of the tooltip. */
19
- this.text = input('', ...(ngDevMode ? [{ debugName: "text" }] : /* istanbul ignore next */ []));
20
- /** Preferred placement relative to the trigger. */
21
- this.position = input('bottom', ...(ngDevMode ? [{ debugName: "position" }] : /* istanbul ignore next */ []));
22
- /** 'hover' shows on mouse enter; 'fixed' stays pinned to the content. */
23
- this.mode = input('hover', ...(ngDevMode ? [{ debugName: "mode" }] : /* istanbul ignore next */ []));
24
- /** Distance (px) between the tooltip and the trigger. */
25
- this.offset = input(8, ...(ngDevMode ? [{ debugName: "offset" }] : /* istanbul ignore next */ []));
26
- this.host = inject((ElementRef));
27
- this.document = inject(DOCUMENT);
28
- /** The dynamically created tooltip element. */
29
- this.tooltipEl = null;
30
- /** Unsubscribe callbacks for the scroll/resize listeners. */
31
- this.cleanup = null;
32
- }
33
- /** Shows the tooltip over the host trigger on mouseenter. */
34
- onMouseEnter() {
35
- this.open();
36
- }
37
- /** Hides the tooltip on mouseleave. */
38
- onMouseLeave() {
39
- this.hide();
40
- }
41
- /** Also opens on keyboard focus, so icon-only triggers are readable. */
42
- onFocusIn() {
43
- this.open();
44
- }
45
- /** Closes when the focus leaves the trigger. */
46
- onFocusOut() {
47
- this.hide();
48
- }
49
- /** Opens the tooltip when there is text to show. */
50
- open() {
51
- if (!this.text())
52
- return;
53
- const trigger = this.host.nativeElement.querySelector('.shk-tooltip-trigger');
54
- if (!trigger)
55
- return;
56
- this.show(trigger);
57
- }
58
- /** Creates and positions the tooltip element on `document.body`. */
59
- show(trigger) {
60
- this.removeTooltip();
61
- const el = this.document.createElement('span');
62
- el.className = 'shk-tooltip-dynamic';
63
- el.textContent = this.text();
64
- Object.assign(el.style, {
65
- position: 'fixed',
66
- zIndex: TOOLTIP_Z_INDEX,
67
- backgroundColor: 'var(--shk-tooltip-bg, #27272a)',
68
- color: 'var(--shk-tooltip-text, #fff)',
69
- padding: '4px 8px',
70
- borderRadius: '6px',
71
- fontSize: '12px',
72
- lineHeight: '1.4',
73
- whiteSpace: 'pre-line',
74
- maxWidth: 'min(80vw, 22rem)',
75
- boxShadow: '0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)',
76
- pointerEvents: 'none',
77
- opacity: '0',
78
- transition: 'opacity 0.15s ease',
79
- });
80
- this.document.body.appendChild(el);
81
- this.tooltipEl = el;
82
- const place = () => {
83
- const rect = trigger.getBoundingClientRect();
84
- const w = el.offsetWidth;
85
- const h = el.offsetHeight;
86
- const { left, top } = this.computePosition(rect, w, h);
87
- el.style.left = `${left}px`;
88
- el.style.top = `${top}px`;
89
- };
90
- place();
91
- requestAnimationFrame(() => {
92
- if (this.tooltipEl === el) {
93
- el.style.opacity = '1';
94
- }
95
- });
96
- const onScrollOrResize = () => place();
97
- window.addEventListener('scroll', onScrollOrResize, true);
98
- window.addEventListener('resize', onScrollOrResize);
99
- this.cleanup = () => {
100
- window.removeEventListener('scroll', onScrollOrResize, true);
101
- window.removeEventListener('resize', onScrollOrResize);
102
- };
103
- }
104
- /** Computes the tooltip position, clamped to the viewport. */
105
- computePosition(rect, width, height) {
106
- const off = this.offset();
107
- const viewportW = this.document.defaultView?.innerWidth ?? 0;
108
- const viewportH = this.document.defaultView?.innerHeight ?? 0;
109
- let x;
110
- let y;
111
- if (this.position() === 'right') {
112
- x = rect.right + off;
113
- y = rect.top + rect.height / 2 - height / 2;
114
- }
115
- else if (this.position() === 'bottom') {
116
- x = rect.left + rect.width / 2 - width / 2;
117
- y = rect.bottom + off;
118
- }
119
- else {
120
- x = rect.left + rect.width / 2 - width / 2;
121
- y = rect.top - off - height;
122
- }
123
- const margin = 4;
124
- const left = Math.max(margin, Math.min(x, Math.max(margin, viewportW - width - margin)));
125
- const top = Math.max(margin, Math.min(y, Math.max(margin, viewportH - height - margin)));
126
- return { left, top };
127
- }
128
- /** Fades the tooltip out and removes it from the DOM. */
129
- hide() {
130
- if (!this.tooltipEl)
131
- return;
132
- const el = this.tooltipEl;
133
- el.style.opacity = '0';
134
- this.tooltipEl = null;
135
- setTimeout(() => {
136
- el.remove();
137
- }, 150);
138
- }
139
- /** Removes the tooltip and its listeners. */
140
- removeTooltip() {
141
- this.cleanup?.();
142
- this.cleanup = null;
143
- this.tooltipEl?.remove();
144
- this.tooltipEl = null;
145
- }
146
- /** Cleans up the tooltip on component destroy. */
147
- ngOnDestroy() {
148
- this.removeTooltip();
149
- }
150
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.23", ngImport: i0, type: TooltipComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
151
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.23", type: TooltipComponent, isStandalone: true, selector: "shk-tooltip", inputs: { text: { classPropertyName: "text", publicName: "text", isSignal: true, isRequired: false, transformFunction: null }, position: { classPropertyName: "position", publicName: "position", isSignal: true, isRequired: false, transformFunction: null }, mode: { classPropertyName: "mode", publicName: "mode", isSignal: true, isRequired: false, transformFunction: null }, offset: { classPropertyName: "offset", publicName: "offset", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "mouseenter": "onMouseEnter()", "mouseleave": "onMouseLeave()", "focusin": "onFocusIn()", "focusout": "onFocusOut()" } }, ngImport: i0, template: `
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
- `, isInline: true }); }
156
- }
157
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.23", ngImport: i0, type: TooltipComponent, decorators: [{
158
- type: Component,
159
- args: [{
160
- selector: 'shk-tooltip',
161
- standalone: true,
162
- template: `
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
- }], propDecorators: { text: [{ type: i0.Input, args: [{ isSignal: true, alias: "text", required: false }] }], position: [{ type: i0.Input, args: [{ isSignal: true, alias: "position", required: false }] }], mode: [{ type: i0.Input, args: [{ isSignal: true, alias: "mode", required: false }] }], offset: [{ type: i0.Input, args: [{ isSignal: true, alias: "offset", required: false }] }], onMouseEnter: [{
169
- type: HostListener,
170
- args: ['mouseenter']
171
- }], onMouseLeave: [{
172
- type: HostListener,
173
- args: ['mouseleave']
174
- }], onFocusIn: [{
175
- type: HostListener,
176
- args: ['focusin']
177
- }], onFocusOut: [{
178
- type: HostListener,
179
- args: ['focusout']
180
- }] } });
181
-
182
- /**
183
- * Generated bundle index. Do not edit.
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
- //# sourceMappingURL=shirkasoft-ui-components-tooltip.mjs.map
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,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"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,eA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