@tailng-ui/primitives 0.51.0 → 0.53.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/package.json +2 -2
- package/src/lib/form/_shared/select/tng-select.overlay.shared.d.ts +6 -0
- package/src/lib/form/_shared/select/tng-select.overlay.shared.d.ts.map +1 -1
- package/src/lib/form/_shared/select/tng-select.overlay.shared.js +65 -11
- package/src/lib/form/_shared/select/tng-select.overlay.shared.js.map +1 -1
- package/src/lib/form/autocomplete/tng-autocomplete.overlay.d.ts +6 -1
- package/src/lib/form/autocomplete/tng-autocomplete.overlay.d.ts.map +1 -1
- package/src/lib/form/autocomplete/tng-autocomplete.overlay.js +76 -17
- package/src/lib/form/autocomplete/tng-autocomplete.overlay.js.map +1 -1
- package/src/lib/form/datepicker/tng-datepicker.overlay.d.ts +11 -0
- package/src/lib/form/datepicker/tng-datepicker.overlay.d.ts.map +1 -1
- package/src/lib/form/datepicker/tng-datepicker.overlay.js +73 -3
- package/src/lib/form/datepicker/tng-datepicker.overlay.js.map +1 -1
- package/src/lib/form/index.d.ts +1 -0
- package/src/lib/form/index.d.ts.map +1 -1
- package/src/lib/form/index.js +1 -0
- package/src/lib/form/index.js.map +1 -1
- package/src/lib/form/input/tng-adornment.d.ts +6 -6
- package/src/lib/form/input/tng-adornment.d.ts.map +1 -1
- package/src/lib/form/input/tng-adornment.js +12 -12
- package/src/lib/form/input/tng-adornment.js.map +1 -1
- package/src/lib/form/input/tng-input-group.d.ts +4 -4
- package/src/lib/form/input/tng-input-group.d.ts.map +1 -1
- package/src/lib/form/input/tng-input-group.js +8 -8
- package/src/lib/form/input/tng-input-group.js.map +1 -1
- package/src/lib/form/multi-autocomplete/tng-multi-autocomplete.overlay.d.ts +5 -0
- package/src/lib/form/multi-autocomplete/tng-multi-autocomplete.overlay.d.ts.map +1 -1
- package/src/lib/form/multi-autocomplete/tng-multi-autocomplete.overlay.js +59 -6
- package/src/lib/form/multi-autocomplete/tng-multi-autocomplete.overlay.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailng-ui/primitives",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.53.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"@angular/core": "^21.1.0",
|
|
20
|
-
"@tailng-ui/cdk": "^0.
|
|
20
|
+
"@tailng-ui/cdk": "^0.39.0",
|
|
21
21
|
"tslib": "^2.3.0"
|
|
22
22
|
},
|
|
23
23
|
"sideEffects": false
|
|
@@ -31,6 +31,12 @@ export declare class TngSelectOverlay {
|
|
|
31
31
|
private setupRepositionListeners;
|
|
32
32
|
private teardownRepositionListeners;
|
|
33
33
|
private findTriggerEl;
|
|
34
|
+
/**
|
|
35
|
+
* Anchor for overlay positioning, width, and dismiss boundary.
|
|
36
|
+
* Prefer the enclosing form-field (so the overlay aligns with the visible
|
|
37
|
+
* field frame), else the select trigger itself.
|
|
38
|
+
*/
|
|
39
|
+
private findAnchorEl;
|
|
34
40
|
private syncPortalledThemeVars;
|
|
35
41
|
private applyPortalledStacking;
|
|
36
42
|
private clearPortalledThemeVars;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tng-select.overlay.shared.d.ts","sourceRoot":"","sources":["../../../../../../../../../libs/tailng-ui/primitives/src/lib/form/_shared/select/tng-select.overlay.shared.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"tng-select.overlay.shared.d.ts","sourceRoot":"","sources":["../../../../../../../../../libs/tailng-ui/primitives/src/lib/form/_shared/select/tng-select.overlay.shared.ts"],"names":[],"mappings":";AA4JA,qBAIa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA6C;IAClE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA+C;IACrE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAsB;IACjD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA+B;IAC1D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAExB;IAEH,OAAO,CAAC,qBAAqB,CAA4B;IACzD,OAAO,CAAC,oBAAoB,CAA6B;IACzD,OAAO,CAAC,cAAc,CAA+B;IAErD,SAAgB,SAAS;;;oBAAqD;IAC9E,SAAgB,MAAM;;;oBAAkD;IACxE,SAAgB,SAAS;;;;oBAA4D;IAGrF,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAG,gBAAgB,CAAU;IAGxD,SAAS,KAAK,MAAM,IAAI,EAAE,GAAG,IAAI,CAEhC;IAED,OAAO,CAAC,WAAW,CAAwB;IAC3C,OAAO,CAAC,cAAc,CAAqB;IAC3C,OAAO,CAAC,wBAAwB,CAA6B;;IAsB7D,OAAO,CAAC,UAAU;IAuBlB,OAAO,CAAC,wBAAwB;IAsBhC,OAAO,CAAC,2BAA2B;IAOnC,OAAO,CAAC,aAAa;IAKrB;;;;OAIG;IACH,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,sBAAsB;IAqB9B,OAAO,CAAC,sBAAsB;IAK9B,OAAO,CAAC,uBAAuB;IAU/B,OAAO,CAAC,sBAAsB;IAoD9B,OAAO,CAAC,oBAAoB;IAwC5B,OAAO,CAAC,mBAAmB;IA0B3B,OAAO,CAAC,sBAAsB;IAK9B,OAAO,CAAC,mBAAmB;yCAlRhB,gBAAgB;2CAAhB,gBAAgB;CA+R5B"}
|
|
@@ -80,6 +80,48 @@ function isInside(target, container) {
|
|
|
80
80
|
function resolveOverlayOwnerId(host) {
|
|
81
81
|
return host.closest(`[${TNG_OVERLAY_LAYER_ID_ATTR}]`)?.getAttribute(TNG_OVERLAY_LAYER_ID_ATTR) ?? null;
|
|
82
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* When the overlay's host element lives inside a `tng-form-field`, the form-field
|
|
85
|
+
* is the visible frame the consumer sees, so the overlay should align with it
|
|
86
|
+
* (width + left/right edges). For the `left` label layout the form-field's root
|
|
87
|
+
* spans the label column too, so anchor on the inner control-row instead.
|
|
88
|
+
*/
|
|
89
|
+
function findFormFieldAnchor(host) {
|
|
90
|
+
const formField = host.closest('[data-slot="form-field"]');
|
|
91
|
+
if (!formField)
|
|
92
|
+
return null;
|
|
93
|
+
if (formField.getAttribute('data-label-position') === 'left') {
|
|
94
|
+
const row = formField.querySelector('.tng-form-field__control-row');
|
|
95
|
+
return row ?? formField;
|
|
96
|
+
}
|
|
97
|
+
return formField;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Rect to use for overlay positioning. When the anchor is a form-field root, the
|
|
101
|
+
* horizontal extent is taken from the form-field (so the overlay spans the field
|
|
102
|
+
* frame) but the vertical extent is taken from the inner fieldset (the input row)
|
|
103
|
+
* so the overlay opens directly under the input rather than below the messages
|
|
104
|
+
* region beneath the frame.
|
|
105
|
+
*/
|
|
106
|
+
function anchorRectFor(anchorEl) {
|
|
107
|
+
const widthRect = anchorEl.getBoundingClientRect();
|
|
108
|
+
if (!anchorEl.matches('[data-slot="form-field"]')) {
|
|
109
|
+
return rectFromClientRect(widthRect);
|
|
110
|
+
}
|
|
111
|
+
const labelPosition = anchorEl.getAttribute('data-label-position');
|
|
112
|
+
const fieldset = anchorEl.querySelector('[data-slot="form-field-control-row"]');
|
|
113
|
+
const innerRow = anchorEl.querySelector('.tng-form-field__control-row');
|
|
114
|
+
const positionEl = labelPosition === 'outline' ? (fieldset ?? innerRow) : (innerRow ?? fieldset);
|
|
115
|
+
if (!positionEl)
|
|
116
|
+
return rectFromClientRect(widthRect);
|
|
117
|
+
const positionRect = positionEl.getBoundingClientRect();
|
|
118
|
+
return {
|
|
119
|
+
left: widthRect.left,
|
|
120
|
+
width: widthRect.width,
|
|
121
|
+
top: positionRect.top,
|
|
122
|
+
height: positionRect.height,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
83
125
|
export class TngSelectOverlay {
|
|
84
126
|
host = inject(TNG_SELECT_HOST);
|
|
85
127
|
elRef = inject(ElementRef);
|
|
@@ -124,10 +166,10 @@ export class TngSelectOverlay {
|
|
|
124
166
|
if (!this.host.open())
|
|
125
167
|
return;
|
|
126
168
|
const panel = this.elRef.nativeElement;
|
|
127
|
-
const
|
|
128
|
-
if (!
|
|
169
|
+
const anchorEl = this.findAnchorEl();
|
|
170
|
+
if (!anchorEl)
|
|
129
171
|
return;
|
|
130
|
-
const anchor =
|
|
172
|
+
const anchor = anchorRectFor(anchorEl);
|
|
131
173
|
const overlay = rectFromClientRect(panel.getBoundingClientRect());
|
|
132
174
|
const viewport = viewportRect();
|
|
133
175
|
const result = computeOverlayPosition({
|
|
@@ -156,9 +198,9 @@ export class TngSelectOverlay {
|
|
|
156
198
|
this.removeResizeListener = () => window.removeEventListener('resize', onResize);
|
|
157
199
|
if ('ResizeObserver' in window) {
|
|
158
200
|
this.resizeObserver = new ResizeObserver(() => schedule());
|
|
159
|
-
const
|
|
160
|
-
if (
|
|
161
|
-
this.resizeObserver.observe(
|
|
201
|
+
const anchorEl = this.findAnchorEl();
|
|
202
|
+
if (anchorEl)
|
|
203
|
+
this.resizeObserver.observe(anchorEl);
|
|
162
204
|
this.resizeObserver.observe(this.elRef.nativeElement);
|
|
163
205
|
}
|
|
164
206
|
}
|
|
@@ -172,6 +214,14 @@ export class TngSelectOverlay {
|
|
|
172
214
|
const root = this.host.hostElement;
|
|
173
215
|
return root.querySelector('[data-slot="select-trigger"]');
|
|
174
216
|
}
|
|
217
|
+
/**
|
|
218
|
+
* Anchor for overlay positioning, width, and dismiss boundary.
|
|
219
|
+
* Prefer the enclosing form-field (so the overlay aligns with the visible
|
|
220
|
+
* field frame), else the select trigger itself.
|
|
221
|
+
*/
|
|
222
|
+
findAnchorEl() {
|
|
223
|
+
return findFormFieldAnchor(this.host.hostElement) ?? this.findTriggerEl();
|
|
224
|
+
}
|
|
175
225
|
syncPortalledThemeVars() {
|
|
176
226
|
const panel = this.elRef.nativeElement;
|
|
177
227
|
const hostStyles = getComputedStyle(this.host.hostElement);
|
|
@@ -223,14 +273,17 @@ export class TngSelectOverlay {
|
|
|
223
273
|
queueMicrotask(() => {
|
|
224
274
|
if (!this.host.open())
|
|
225
275
|
return;
|
|
226
|
-
const
|
|
227
|
-
if (!
|
|
276
|
+
const anchorEl = this.findAnchorEl();
|
|
277
|
+
if (!anchorEl)
|
|
228
278
|
return;
|
|
229
|
-
const anchor =
|
|
279
|
+
const anchor = anchorRectFor(anchorEl);
|
|
230
280
|
const viewportWidth = viewportRect().width;
|
|
231
281
|
const inlineSize = Math.max(0, Math.min(anchor.width, viewportWidth - 16));
|
|
232
282
|
panel.style.width = `${inlineSize}px`;
|
|
233
283
|
panel.style.minWidth = `${inlineSize}px`;
|
|
284
|
+
if (findFormFieldAnchor(this.host.hostElement)) {
|
|
285
|
+
panel.style.maxWidth = 'none';
|
|
286
|
+
}
|
|
234
287
|
const overlay = rectFromClientRect(panel.getBoundingClientRect());
|
|
235
288
|
const viewport = viewportRect();
|
|
236
289
|
const result = computeOverlayPosition({
|
|
@@ -275,6 +328,7 @@ export class TngSelectOverlay {
|
|
|
275
328
|
panel.style.zIndex = '';
|
|
276
329
|
panel.style.width = '';
|
|
277
330
|
panel.style.minWidth = '';
|
|
331
|
+
panel.style.maxWidth = '';
|
|
278
332
|
panel.removeAttribute(TNG_OVERLAY_OWNER_ID_ATTR);
|
|
279
333
|
this.clearPortalledThemeVars();
|
|
280
334
|
this.teardownOutsidePointer();
|
|
@@ -286,10 +340,10 @@ export class TngSelectOverlay {
|
|
|
286
340
|
if (!this.host.open())
|
|
287
341
|
return;
|
|
288
342
|
const panel = this.elRef.nativeElement;
|
|
289
|
-
const
|
|
343
|
+
const anchorEl = this.findAnchorEl();
|
|
290
344
|
if (isInside(ev.target, panel))
|
|
291
345
|
return;
|
|
292
|
-
if (
|
|
346
|
+
if (anchorEl && isInside(ev.target, anchorEl))
|
|
293
347
|
return;
|
|
294
348
|
if (this.host.multiple() &&
|
|
295
349
|
ev.target &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tng-select.overlay.shared.js","sourceRoot":"","sources":["../../../../../../../../../libs/tailng-ui/primitives/src/lib/form/_shared/select/tng-select.overlay.shared.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,UAAU,EACV,WAAW,EACX,MAAM,EACN,KAAK,EACL,MAAM,GACP,MAAM,eAAe,CAAC;AAMvB,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,0BAA0B,GAC3B,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;;AAS7D,MAAM,2BAA2B,GAAG;IAClC,qBAAqB;IACrB,4BAA4B;IAC5B,iCAAiC;IACjC,yBAAyB;IACzB,yBAAyB;IACzB,0BAA0B;IAC1B,wBAAwB;IACxB,2BAA2B;IAC3B,uCAAuC;IACvC,8BAA8B;IAC9B,6BAA6B;IAC7B,6BAA6B;IAC7B,gCAAgC;IAChC,wBAAwB;IACxB,8BAA8B;IAC9B,iBAAiB;IACjB,6BAA6B;IAC7B,yBAAyB;IACzB,iCAAiC;IACjC,0BAA0B;IAC1B,gCAAgC;IAChC,wBAAwB;IACxB,wBAAwB;IACxB,4BAA4B;IAC5B,+BAA+B;IAC/B,mCAAmC;IACnC,iCAAiC;IACjC,qCAAqC;IACrC,iCAAiC;IACjC,wCAAwC;IACxC,4CAA4C;IAC5C,4CAA4C;IAC5C,sCAAsC;IACtC,iCAAiC;IACjC,8BAA8B;IAC9B,gCAAgC;IAChC,0BAA0B;IAC1B,qCAAqC;IACrC,qBAAqB;IACrB,4BAA4B;IAC5B,2BAA2B;IAC3B,iBAAiB;IACjB,sBAAsB;IACtB,iBAAiB;IACjB,oBAAoB;IACpB,oBAAoB;IACpB,qBAAqB;IACrB,yBAAyB;IACzB,mBAAmB;IACnB,qBAAqB;IACr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AAQ,EAAE,oBAAoB;oBAC9B,QAAQ,EAAE,kBAAkB;iBAC7B;;sBAkBE,WAAW;uBAAC,gBAAgB;;sBAG5B,WAAW;uBAAC,aAAa","sourcesContent":["import {\n DestroyRef,\n Directive,\n ElementRef,\n HostBinding,\n inject,\n input,\n effect,\n} from '@angular/core';\nimport type {\n TngOverlayCollisionOptions,\n TngOverlayOffset,\n TngOverlayPlacement,\n} from '@tailng-ui/cdk';\nimport {\n computeOverlayPosition,\n createTngIdFactory,\n getGlobalScrollLockManager,\n} from '@tailng-ui/cdk';\n\nimport type { TngSelectHostApi } from './tng-select.host-api';\nimport { TNG_SELECT_HOST } from './tng-select.tokens.shared';\n\ntype MaybeRect = Readonly<{\n left: number;\n top: number;\n width: number;\n height: number;\n}>;\n\nconst PORTALLED_SELECT_THEME_VARS = [\n '--tng-select-radius',\n '--tng-select-trigger-width',\n '--tng-select-trigger-min-height',\n '--tng-select-trigger-py',\n '--tng-select-trigger-px',\n '--tng-select-trigger-gap',\n '--tng-select-icon-size',\n '--tng-select-icon-opacity',\n '--tng-select-icon-margin-inline-start',\n '--tng-select-overlay-padding',\n '--tng-select-overlay-radius',\n '--tng-select-overlay-shadow',\n '--tng-select-overlay-max-width',\n '--tng-select-z-overlay',\n '--tng-select-overlay-z-index',\n '--tng-z-overlay',\n '--tng-select-overlay-border',\n '--tng-select-overlay-bg',\n '--tng-select-overlay-max-height',\n '--tng-select-listbox-gap',\n '--tng-select-option-min-height',\n '--tng-select-option-py',\n '--tng-select-option-px',\n '--tng-select-option-radius',\n '--tng-select-option-bg-active',\n '--tng-select-option-border-active',\n '--tng-select-option-bg-selected',\n '--tng-select-option-border-selected',\n '--tng-select-option-fg-selected',\n '--tng-select-option-bg-selected-active',\n '--tng-select-option-border-selected-active',\n '--tng-select-option-shadow-selected-active',\n '--tng-select-option-disabled-opacity',\n '--tng-select-option-font-weight',\n '--tng-select-value-font-size',\n '--tng-select-value-font-weight',\n '--tng-select-value-color',\n '--tng-select-icon-margin-inline-end',\n '--tng-select-border',\n '--tng-select-border-strong',\n '--tng-select-border-hover',\n '--tng-select-bg',\n '--tng-select-surface',\n '--tng-select-fg',\n '--tng-select-muted',\n '--tng-select-brand',\n '--tng-select-danger',\n '--tng-select-focus-ring',\n '--tng-select-ease',\n '--tng-select-shadow',\n '--tng-select-shadow-focus',\n '--tng-semantic-background-base',\n '--tng-semantic-background-surface',\n '--tng-semantic-border-subtle',\n '--tng-semantic-border-strong',\n '--tng-semantic-foreground-primary',\n '--tng-semantic-foreground-secondary',\n '--tng-semantic-foreground-muted',\n '--tng-semantic-accent-brand',\n '--tng-semantic-accent-danger',\n '--tng-semantic-focus-ring',\n] as const;\n\nconst TNG_OVERLAY_LAYER_ID_ATTR = 'data-tng-overlay-layer-id';\nconst TNG_OVERLAY_OWNER_ID_ATTR = 'data-tng-overlay-owner-id';\nconst createSelectOverlayLockId = createTngIdFactory('tng-select-overlay-lock');\n\nfunction rectFromClientRect(r: DOMRect | ClientRect): MaybeRect {\n return { left: r.left, top: r.top, width: r.width, height: r.height };\n}\n\nfunction viewportRect(): MaybeRect {\n return { left: 0, top: 0, width: window.innerWidth || 1024, height: window.innerHeight || 768 };\n}\n\nfunction isInside(target: EventTarget | null, container: HTMLElement): boolean {\n return !!target && target instanceof Node && container.contains(target);\n}\n\nfunction resolveOverlayOwnerId(host: HTMLElement): string | null {\n return host.closest<HTMLElement>(`[${TNG_OVERLAY_LAYER_ID_ATTR}]`)?.getAttribute(TNG_OVERLAY_LAYER_ID_ATTR) ?? null;\n}\n\n@Directive({\n selector: '[tngSelectOverlay]',\n exportAs: 'tngSelectOverlay',\n})\nexport class TngSelectOverlay {\n private readonly host = inject<TngSelectHostApi>(TNG_SELECT_HOST);\n private readonly elRef = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly destroyRef = inject(DestroyRef);\n private readonly instanceId = createSelectOverlayLockId();\n private readonly scrollLock = getGlobalScrollLockManager({\n documentRef: this.elRef.nativeElement.ownerDocument,\n });\n\n private lastFocusedBeforeOpen: HTMLElement | null = null;\n private removeResizeListener: (() => void) | null = null;\n private resizeObserver: ResizeObserver | null = null;\n\n public readonly placement = input<TngOverlayPlacement | undefined>(undefined);\n public readonly offset = input<TngOverlayOffset | undefined>(undefined);\n public readonly collision = input<TngOverlayCollisionOptions | undefined>(undefined);\n\n @HostBinding('attr.data-slot')\n protected readonly dataSlot = 'select-overlay' as const;\n\n @HostBinding('attr.hidden')\n protected get hidden(): '' | null {\n return this.host.open() ? null : '';\n }\n\n private placeholder: Comment | null = null;\n private originalParent: Node | null = null;\n private removeDocPointerListener: (() => void) | null = null;\n\n public constructor() {\n this.placeholder = document.createComment('tng-select-overlay-anchor');\n const hostEl = this.elRef.nativeElement;\n this.originalParent = hostEl.parentNode;\n this.originalParent?.insertBefore(this.placeholder, hostEl);\n\n effect(() => {\n const open = this.host.open();\n if (open) this.mountToBodyAndPosition();\n else this.restoreToPlaceholder();\n });\n\n this.destroyRef.onDestroy(() => {\n this.teardownOutsidePointer();\n this.restoreToPlaceholder(true);\n this.placeholder = null;\n this.originalParent = null;\n });\n }\n\n private reposition(): void {\n if (!this.host.open()) return;\n const panel = this.elRef.nativeElement;\n const trigger = this.findTriggerEl();\n if (!trigger) return;\n\n const anchor = rectFromClientRect(trigger.getBoundingClientRect());\n const overlay = rectFromClientRect(panel.getBoundingClientRect());\n const viewport = viewportRect();\n\n const result = computeOverlayPosition({\n anchorRect: anchor,\n overlayRect: overlay,\n viewportRect: viewport,\n placement: this.placement(),\n offset: this.offset(),\n collision: this.collision(),\n });\n\n panel.style.left = `${result.x}px`;\n panel.style.top = `${result.y}px`;\n }\n\n private setupRepositionListeners(): void {\n let rafId: number | null = null;\n const schedule = (): void => {\n if (rafId !== null) return;\n rafId = requestAnimationFrame(() => {\n rafId = null;\n this.reposition();\n });\n };\n\n const onResize = (): void => schedule();\n window.addEventListener('resize', onResize);\n this.removeResizeListener = (): void => window.removeEventListener('resize', onResize);\n\n if ('ResizeObserver' in window) {\n this.resizeObserver = new ResizeObserver(() => schedule());\n const trigger = this.findTriggerEl();\n if (trigger) this.resizeObserver.observe(trigger);\n this.resizeObserver.observe(this.elRef.nativeElement);\n }\n }\n\n private teardownRepositionListeners(): void {\n this.removeResizeListener?.();\n this.removeResizeListener = null;\n this.resizeObserver?.disconnect();\n this.resizeObserver = null;\n }\n\n private findTriggerEl(): HTMLElement | null {\n const root = this.host.hostElement;\n return root.querySelector('[data-slot=\"select-trigger\"]') as HTMLElement | null;\n }\n\n private syncPortalledThemeVars(): void {\n const panel = this.elRef.nativeElement;\n const hostStyles = getComputedStyle(this.host.hostElement);\n\n for (const cssVar of PORTALLED_SELECT_THEME_VARS) {\n const value = hostStyles.getPropertyValue(cssVar).trim();\n if (value) {\n panel.style.setProperty(cssVar, value);\n } else {\n panel.style.removeProperty(cssVar);\n }\n }\n\n const colorScheme = hostStyles.colorScheme?.trim();\n if (colorScheme && colorScheme !== 'normal') {\n panel.style.colorScheme = colorScheme;\n } else {\n panel.style.removeProperty('color-scheme');\n }\n }\n\n private applyPortalledStacking(): void {\n this.elRef.nativeElement.style.zIndex =\n 'var(--tng-select-z-overlay, var(--tng-select-overlay-z-index, var(--tng-z-overlay, 2)))';\n }\n\n private clearPortalledThemeVars(): void {\n const panel = this.elRef.nativeElement;\n\n for (const cssVar of PORTALLED_SELECT_THEME_VARS) {\n panel.style.removeProperty(cssVar);\n }\n\n panel.style.removeProperty('color-scheme');\n }\n\n private mountToBodyAndPosition(): void {\n this.lastFocusedBeforeOpen = document.activeElement as HTMLElement | null;\n this.scrollLock.acquire(this.instanceId);\n this.setupRepositionListeners();\n const panel = this.elRef.nativeElement;\n const ownerId = resolveOverlayOwnerId(this.host.hostElement);\n if (ownerId !== null) {\n panel.setAttribute(TNG_OVERLAY_OWNER_ID_ATTR, ownerId);\n }\n\n if (panel.parentNode !== document.body) {\n document.body.appendChild(panel);\n }\n\n panel.style.position = 'fixed';\n panel.style.left = '0px';\n panel.style.top = '0px';\n this.syncPortalledThemeVars();\n this.applyPortalledStacking();\n\n queueMicrotask(() => {\n if (!this.host.open()) return;\n const trigger = this.findTriggerEl();\n if (!trigger) return;\n\n const anchor = rectFromClientRect(trigger.getBoundingClientRect());\n const viewportWidth = viewportRect().width;\n const inlineSize = Math.max(0, Math.min(anchor.width, viewportWidth - 16));\n panel.style.width = `${inlineSize}px`;\n panel.style.minWidth = `${inlineSize}px`;\n\n const overlay = rectFromClientRect(panel.getBoundingClientRect());\n const viewport = viewportRect();\n const result = computeOverlayPosition({\n anchorRect: anchor,\n overlayRect: overlay,\n viewportRect: viewport,\n placement: this.placement(),\n offset: this.offset(),\n collision: this.collision(),\n });\n\n panel.style.left = `${result.x}px`;\n panel.style.top = `${result.y}px`;\n });\n\n this.setupOutsidePointer();\n }\n\n private restoreToPlaceholder(force = false): void {\n const panel = this.elRef.nativeElement;\n if (!force && panel.parentNode !== document.body) {\n this.teardownOutsidePointer();\n return;\n }\n\n if (this.placeholder?.parentNode) {\n this.placeholder.parentNode.insertBefore(panel, this.placeholder);\n } else if (this.originalParent) {\n this.originalParent.appendChild(panel);\n }\n\n this.teardownRepositionListeners();\n this.scrollLock.release(this.instanceId);\n\n if (\n this.lastFocusedBeforeOpen &&\n document.contains(this.lastFocusedBeforeOpen)\n ) {\n const active = document.activeElement as HTMLElement | null;\n const panelEl = this.elRef.nativeElement;\n if (!active || panelEl.contains(active)) {\n this.lastFocusedBeforeOpen.focus();\n }\n }\n\n this.restoreFocusOnClose();\n panel.style.position = '';\n panel.style.left = '';\n panel.style.top = '';\n panel.style.zIndex = '';\n panel.style.width = '';\n panel.style.minWidth = '';\n panel.removeAttribute(TNG_OVERLAY_OWNER_ID_ATTR);\n this.clearPortalledThemeVars();\n this.teardownOutsidePointer();\n }\n\n private setupOutsidePointer(): void {\n if (this.removeDocPointerListener) return;\n\n const onPointerDown = (ev: PointerEvent): void => {\n if (!this.host.open()) return;\n const panel = this.elRef.nativeElement;\n const trigger = this.findTriggerEl();\n if (isInside(ev.target, panel)) return;\n if (trigger && isInside(ev.target, trigger)) return;\n if (\n this.host.multiple() &&\n ev.target &&\n (ev.target as Element).closest?.(\n '[data-slot=\"select-option\"], [data-slot=\"multi-select-option\"]'\n )\n )\n return;\n this.host.close();\n };\n\n document.addEventListener('pointerdown', onPointerDown, true);\n this.removeDocPointerListener = (): void => {\n document.removeEventListener('pointerdown', onPointerDown, true);\n };\n }\n\n private teardownOutsidePointer(): void {\n this.removeDocPointerListener?.();\n this.removeDocPointerListener = null;\n }\n\n private restoreFocusOnClose(): void {\n const panel = this.elRef.nativeElement;\n const active = document.activeElement as HTMLElement | null;\n if (active && panel.contains(active)) {\n const trigger = this.findTriggerEl();\n trigger?.focus();\n return;\n }\n if (document.activeElement === document.body) {\n const trigger = this.findTriggerEl();\n trigger?.focus();\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tng-select.overlay.shared.js","sourceRoot":"","sources":["../../../../../../../../../libs/tailng-ui/primitives/src/lib/form/_shared/select/tng-select.overlay.shared.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,UAAU,EACV,WAAW,EACX,MAAM,EACN,KAAK,EACL,MAAM,GACP,MAAM,eAAe,CAAC;AAMvB,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,0BAA0B,GAC3B,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;;AAS7D,MAAM,2BAA2B,GAAG;IAClC,qBAAqB;IACrB,4BAA4B;IAC5B,iCAAiC;IACjC,yBAAyB;IACzB,yBAAyB;IACzB,0BAA0B;IAC1B,wBAAwB;IACxB,2BAA2B;IAC3B,uCAAuC;IACvC,8BAA8B;IAC9B,6BAA6B;IAC7B,6BAA6B;IAC7B,gCAAgC;IAChC,wBAAwB;IACxB,8BAA8B;IAC9B,iBAAiB;IACjB,6BAA6B;IAC7B,yBAAyB;IACzB,iCAAiC;IACjC,0BAA0B;IAC1B,gCAAgC;I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,EAAE;YACzC,QAAQ,CAAC,mBAAmB,CAAC,aAAa,EAAE,aAAa,EAAE,IAAI,CAAC,CAAC;QACnE,CAAC,CAAC;IACJ,CAAC;IAEO,sBAAsB;QAC5B,IAAI,CAAC,wBAAwB,EAAE,EAAE,CAAC;QAClC,IAAI,CAAC,wBAAwB,GAAG,IAAI,CAAC;IACvC,CAAC;IAEO,mBAAmB;QACzB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC;QACvC,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAmC,CAAC;QAC5D,IAAI,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YACrC,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;YACrC,OAAO,EAAE,KAAK,EAAE,CAAC;YACjB,OAAO;QACT,CAAC;QACD,IAAI,QAAQ,CAAC,aAAa,KAAK,QAAQ,CAAC,IAAI,EAAE,CAAC;YAC7C,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;YACrC,OAAO,EAAE,KAAK,EAAE,CAAC;QACnB,CAAC;IACH,CAAC;uGA9RU,gBAAgB;2FAAhB,gBAAgB;;2FAAhB,gBAAgB;kBAJ5B,SAAS;mBAAC;oBACT,QAAQ,EAAE,oBAAoB;oBAC9B,QAAQ,EAAE,kBAAkB;iBAC7B;;sBAkBE,WAAW;uBAAC,gBAAgB;;sBAG5B,WAAW;uBAAC,aAAa","sourcesContent":["import {\n DestroyRef,\n Directive,\n ElementRef,\n HostBinding,\n inject,\n input,\n effect,\n} from '@angular/core';\nimport type {\n TngOverlayCollisionOptions,\n TngOverlayOffset,\n TngOverlayPlacement,\n} from '@tailng-ui/cdk';\nimport {\n computeOverlayPosition,\n createTngIdFactory,\n getGlobalScrollLockManager,\n} from '@tailng-ui/cdk';\n\nimport type { TngSelectHostApi } from './tng-select.host-api';\nimport { TNG_SELECT_HOST } from './tng-select.tokens.shared';\n\ntype MaybeRect = Readonly<{\n left: number;\n top: number;\n width: number;\n height: number;\n}>;\n\nconst PORTALLED_SELECT_THEME_VARS = [\n '--tng-select-radius',\n '--tng-select-trigger-width',\n '--tng-select-trigger-min-height',\n '--tng-select-trigger-py',\n '--tng-select-trigger-px',\n '--tng-select-trigger-gap',\n '--tng-select-icon-size',\n '--tng-select-icon-opacity',\n '--tng-select-icon-margin-inline-start',\n '--tng-select-overlay-padding',\n '--tng-select-overlay-radius',\n '--tng-select-overlay-shadow',\n '--tng-select-overlay-max-width',\n '--tng-select-z-overlay',\n '--tng-select-overlay-z-index',\n '--tng-z-overlay',\n '--tng-select-overlay-border',\n '--tng-select-overlay-bg',\n '--tng-select-overlay-max-height',\n '--tng-select-listbox-gap',\n '--tng-select-option-min-height',\n '--tng-select-option-py',\n '--tng-select-option-px',\n '--tng-select-option-radius',\n '--tng-select-option-bg-active',\n '--tng-select-option-border-active',\n '--tng-select-option-bg-selected',\n '--tng-select-option-border-selected',\n '--tng-select-option-fg-selected',\n '--tng-select-option-bg-selected-active',\n '--tng-select-option-border-selected-active',\n '--tng-select-option-shadow-selected-active',\n '--tng-select-option-disabled-opacity',\n '--tng-select-option-font-weight',\n '--tng-select-value-font-size',\n '--tng-select-value-font-weight',\n '--tng-select-value-color',\n '--tng-select-icon-margin-inline-end',\n '--tng-select-border',\n '--tng-select-border-strong',\n '--tng-select-border-hover',\n '--tng-select-bg',\n '--tng-select-surface',\n '--tng-select-fg',\n '--tng-select-muted',\n '--tng-select-brand',\n '--tng-select-danger',\n '--tng-select-focus-ring',\n '--tng-select-ease',\n '--tng-select-shadow',\n '--tng-select-shadow-focus',\n '--tng-semantic-background-base',\n '--tng-semantic-background-surface',\n '--tng-semantic-border-subtle',\n '--tng-semantic-border-strong',\n '--tng-semantic-foreground-primary',\n '--tng-semantic-foreground-secondary',\n '--tng-semantic-foreground-muted',\n '--tng-semantic-accent-brand',\n '--tng-semantic-accent-danger',\n '--tng-semantic-focus-ring',\n] as const;\n\nconst TNG_OVERLAY_LAYER_ID_ATTR = 'data-tng-overlay-layer-id';\nconst TNG_OVERLAY_OWNER_ID_ATTR = 'data-tng-overlay-owner-id';\nconst createSelectOverlayLockId = createTngIdFactory('tng-select-overlay-lock');\n\nfunction rectFromClientRect(r: DOMRect | ClientRect): MaybeRect {\n return { left: r.left, top: r.top, width: r.width, height: r.height };\n}\n\nfunction viewportRect(): MaybeRect {\n return { left: 0, top: 0, width: window.innerWidth || 1024, height: window.innerHeight || 768 };\n}\n\nfunction isInside(target: EventTarget | null, container: HTMLElement): boolean {\n return !!target && target instanceof Node && container.contains(target);\n}\n\nfunction resolveOverlayOwnerId(host: HTMLElement): string | null {\n return host.closest<HTMLElement>(`[${TNG_OVERLAY_LAYER_ID_ATTR}]`)?.getAttribute(TNG_OVERLAY_LAYER_ID_ATTR) ?? null;\n}\n\n/**\n * When the overlay's host element lives inside a `tng-form-field`, the form-field\n * is the visible frame the consumer sees, so the overlay should align with it\n * (width + left/right edges). For the `left` label layout the form-field's root\n * spans the label column too, so anchor on the inner control-row instead.\n */\nfunction findFormFieldAnchor(host: HTMLElement): HTMLElement | null {\n const formField = host.closest('[data-slot=\"form-field\"]') as HTMLElement | null;\n if (!formField) return null;\n if (formField.getAttribute('data-label-position') === 'left') {\n const row = formField.querySelector('.tng-form-field__control-row') as HTMLElement | null;\n return row ?? formField;\n }\n return formField;\n}\n\n/**\n * Rect to use for overlay positioning. When the anchor is a form-field root, the\n * horizontal extent is taken from the form-field (so the overlay spans the field\n * frame) but the vertical extent is taken from the inner fieldset (the input row)\n * so the overlay opens directly under the input rather than below the messages\n * region beneath the frame.\n */\nfunction anchorRectFor(anchorEl: HTMLElement): MaybeRect {\n const widthRect = anchorEl.getBoundingClientRect();\n if (!anchorEl.matches('[data-slot=\"form-field\"]')) {\n return rectFromClientRect(widthRect);\n }\n const labelPosition = anchorEl.getAttribute('data-label-position');\n const fieldset = anchorEl.querySelector('[data-slot=\"form-field-control-row\"]') as HTMLElement | null;\n const innerRow = anchorEl.querySelector('.tng-form-field__control-row') as HTMLElement | null;\n const positionEl = labelPosition === 'outline' ? (fieldset ?? innerRow) : (innerRow ?? fieldset);\n if (!positionEl) return rectFromClientRect(widthRect);\n const positionRect = positionEl.getBoundingClientRect();\n return {\n left: widthRect.left,\n width: widthRect.width,\n top: positionRect.top,\n height: positionRect.height,\n };\n}\n\n@Directive({\n selector: '[tngSelectOverlay]',\n exportAs: 'tngSelectOverlay',\n})\nexport class TngSelectOverlay {\n private readonly host = inject<TngSelectHostApi>(TNG_SELECT_HOST);\n private readonly elRef = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly destroyRef = inject(DestroyRef);\n private readonly instanceId = createSelectOverlayLockId();\n private readonly scrollLock = getGlobalScrollLockManager({\n documentRef: this.elRef.nativeElement.ownerDocument,\n });\n\n private lastFocusedBeforeOpen: HTMLElement | null = null;\n private removeResizeListener: (() => void) | null = null;\n private resizeObserver: ResizeObserver | null = null;\n\n public readonly placement = input<TngOverlayPlacement | undefined>(undefined);\n public readonly offset = input<TngOverlayOffset | undefined>(undefined);\n public readonly collision = input<TngOverlayCollisionOptions | undefined>(undefined);\n\n @HostBinding('attr.data-slot')\n protected readonly dataSlot = 'select-overlay' as const;\n\n @HostBinding('attr.hidden')\n protected get hidden(): '' | null {\n return this.host.open() ? null : '';\n }\n\n private placeholder: Comment | null = null;\n private originalParent: Node | null = null;\n private removeDocPointerListener: (() => void) | null = null;\n\n public constructor() {\n this.placeholder = document.createComment('tng-select-overlay-anchor');\n const hostEl = this.elRef.nativeElement;\n this.originalParent = hostEl.parentNode;\n this.originalParent?.insertBefore(this.placeholder, hostEl);\n\n effect(() => {\n const open = this.host.open();\n if (open) this.mountToBodyAndPosition();\n else this.restoreToPlaceholder();\n });\n\n this.destroyRef.onDestroy(() => {\n this.teardownOutsidePointer();\n this.restoreToPlaceholder(true);\n this.placeholder = null;\n this.originalParent = null;\n });\n }\n\n private reposition(): void {\n if (!this.host.open()) return;\n const panel = this.elRef.nativeElement;\n const anchorEl = this.findAnchorEl();\n if (!anchorEl) return;\n\n const anchor = anchorRectFor(anchorEl);\n const overlay = rectFromClientRect(panel.getBoundingClientRect());\n const viewport = viewportRect();\n\n const result = computeOverlayPosition({\n anchorRect: anchor,\n overlayRect: overlay,\n viewportRect: viewport,\n placement: this.placement(),\n offset: this.offset(),\n collision: this.collision(),\n });\n\n panel.style.left = `${result.x}px`;\n panel.style.top = `${result.y}px`;\n }\n\n private setupRepositionListeners(): void {\n let rafId: number | null = null;\n const schedule = (): void => {\n if (rafId !== null) return;\n rafId = requestAnimationFrame(() => {\n rafId = null;\n this.reposition();\n });\n };\n\n const onResize = (): void => schedule();\n window.addEventListener('resize', onResize);\n this.removeResizeListener = (): void => window.removeEventListener('resize', onResize);\n\n if ('ResizeObserver' in window) {\n this.resizeObserver = new ResizeObserver(() => schedule());\n const anchorEl = this.findAnchorEl();\n if (anchorEl) this.resizeObserver.observe(anchorEl);\n this.resizeObserver.observe(this.elRef.nativeElement);\n }\n }\n\n private teardownRepositionListeners(): void {\n this.removeResizeListener?.();\n this.removeResizeListener = null;\n this.resizeObserver?.disconnect();\n this.resizeObserver = null;\n }\n\n private findTriggerEl(): HTMLElement | null {\n const root = this.host.hostElement;\n return root.querySelector('[data-slot=\"select-trigger\"]') as HTMLElement | null;\n }\n\n /**\n * Anchor for overlay positioning, width, and dismiss boundary.\n * Prefer the enclosing form-field (so the overlay aligns with the visible\n * field frame), else the select trigger itself.\n */\n private findAnchorEl(): HTMLElement | null {\n return findFormFieldAnchor(this.host.hostElement) ?? this.findTriggerEl();\n }\n\n private syncPortalledThemeVars(): void {\n const panel = this.elRef.nativeElement;\n const hostStyles = getComputedStyle(this.host.hostElement);\n\n for (const cssVar of PORTALLED_SELECT_THEME_VARS) {\n const value = hostStyles.getPropertyValue(cssVar).trim();\n if (value) {\n panel.style.setProperty(cssVar, value);\n } else {\n panel.style.removeProperty(cssVar);\n }\n }\n\n const colorScheme = hostStyles.colorScheme?.trim();\n if (colorScheme && colorScheme !== 'normal') {\n panel.style.colorScheme = colorScheme;\n } else {\n panel.style.removeProperty('color-scheme');\n }\n }\n\n private applyPortalledStacking(): void {\n this.elRef.nativeElement.style.zIndex =\n 'var(--tng-select-z-overlay, var(--tng-select-overlay-z-index, var(--tng-z-overlay, 2)))';\n }\n\n private clearPortalledThemeVars(): void {\n const panel = this.elRef.nativeElement;\n\n for (const cssVar of PORTALLED_SELECT_THEME_VARS) {\n panel.style.removeProperty(cssVar);\n }\n\n panel.style.removeProperty('color-scheme');\n }\n\n private mountToBodyAndPosition(): void {\n this.lastFocusedBeforeOpen = document.activeElement as HTMLElement | null;\n this.scrollLock.acquire(this.instanceId);\n this.setupRepositionListeners();\n const panel = this.elRef.nativeElement;\n const ownerId = resolveOverlayOwnerId(this.host.hostElement);\n if (ownerId !== null) {\n panel.setAttribute(TNG_OVERLAY_OWNER_ID_ATTR, ownerId);\n }\n\n if (panel.parentNode !== document.body) {\n document.body.appendChild(panel);\n }\n\n panel.style.position = 'fixed';\n panel.style.left = '0px';\n panel.style.top = '0px';\n this.syncPortalledThemeVars();\n this.applyPortalledStacking();\n\n queueMicrotask(() => {\n if (!this.host.open()) return;\n const anchorEl = this.findAnchorEl();\n if (!anchorEl) return;\n\n const anchor = anchorRectFor(anchorEl);\n const viewportWidth = viewportRect().width;\n const inlineSize = Math.max(0, Math.min(anchor.width, viewportWidth - 16));\n panel.style.width = `${inlineSize}px`;\n panel.style.minWidth = `${inlineSize}px`;\n if (findFormFieldAnchor(this.host.hostElement)) {\n panel.style.maxWidth = 'none';\n }\n\n const overlay = rectFromClientRect(panel.getBoundingClientRect());\n const viewport = viewportRect();\n const result = computeOverlayPosition({\n anchorRect: anchor,\n overlayRect: overlay,\n viewportRect: viewport,\n placement: this.placement(),\n offset: this.offset(),\n collision: this.collision(),\n });\n\n panel.style.left = `${result.x}px`;\n panel.style.top = `${result.y}px`;\n });\n\n this.setupOutsidePointer();\n }\n\n private restoreToPlaceholder(force = false): void {\n const panel = this.elRef.nativeElement;\n if (!force && panel.parentNode !== document.body) {\n this.teardownOutsidePointer();\n return;\n }\n\n if (this.placeholder?.parentNode) {\n this.placeholder.parentNode.insertBefore(panel, this.placeholder);\n } else if (this.originalParent) {\n this.originalParent.appendChild(panel);\n }\n\n this.teardownRepositionListeners();\n this.scrollLock.release(this.instanceId);\n\n if (\n this.lastFocusedBeforeOpen &&\n document.contains(this.lastFocusedBeforeOpen)\n ) {\n const active = document.activeElement as HTMLElement | null;\n const panelEl = this.elRef.nativeElement;\n if (!active || panelEl.contains(active)) {\n this.lastFocusedBeforeOpen.focus();\n }\n }\n\n this.restoreFocusOnClose();\n panel.style.position = '';\n panel.style.left = '';\n panel.style.top = '';\n panel.style.zIndex = '';\n panel.style.width = '';\n panel.style.minWidth = '';\n panel.style.maxWidth = '';\n panel.removeAttribute(TNG_OVERLAY_OWNER_ID_ATTR);\n this.clearPortalledThemeVars();\n this.teardownOutsidePointer();\n }\n\n private setupOutsidePointer(): void {\n if (this.removeDocPointerListener) return;\n\n const onPointerDown = (ev: PointerEvent): void => {\n if (!this.host.open()) return;\n const panel = this.elRef.nativeElement;\n const anchorEl = this.findAnchorEl();\n if (isInside(ev.target, panel)) return;\n if (anchorEl && isInside(ev.target, anchorEl)) return;\n if (\n this.host.multiple() &&\n ev.target &&\n (ev.target as Element).closest?.(\n '[data-slot=\"select-option\"], [data-slot=\"multi-select-option\"]'\n )\n )\n return;\n this.host.close();\n };\n\n document.addEventListener('pointerdown', onPointerDown, true);\n this.removeDocPointerListener = (): void => {\n document.removeEventListener('pointerdown', onPointerDown, true);\n };\n }\n\n private teardownOutsidePointer(): void {\n this.removeDocPointerListener?.();\n this.removeDocPointerListener = null;\n }\n\n private restoreFocusOnClose(): void {\n const panel = this.elRef.nativeElement;\n const active = document.activeElement as HTMLElement | null;\n if (active && panel.contains(active)) {\n const trigger = this.findTriggerEl();\n trigger?.focus();\n return;\n }\n if (document.activeElement === document.body) {\n const trigger = this.findTriggerEl();\n trigger?.focus();\n }\n }\n}\n"]}
|
|
@@ -26,7 +26,12 @@ export declare class TngAutocompleteOverlay {
|
|
|
26
26
|
protected readonly dataSlot: "autocomplete-overlay";
|
|
27
27
|
protected get hidden(): '' | null;
|
|
28
28
|
constructor();
|
|
29
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Anchor for overlay positioning, width, and dismiss boundary.
|
|
31
|
+
* Prefer the enclosing form-field (so the overlay aligns with the visible
|
|
32
|
+
* field frame), else the trigger container (trigger + icon), else the input
|
|
33
|
+
* trigger itself.
|
|
34
|
+
*/
|
|
30
35
|
private findAnchorEl;
|
|
31
36
|
private findTriggerEl;
|
|
32
37
|
private reposition;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tng-autocomplete.overlay.d.ts","sourceRoot":"","sources":["../../../../../../../../libs/tailng-ui/primitives/src/lib/form/autocomplete/tng-autocomplete.overlay.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"tng-autocomplete.overlay.d.ts","sourceRoot":"","sources":["../../../../../../../../libs/tailng-ui/primitives/src/lib/form/autocomplete/tng-autocomplete.overlay.ts"],"names":[],"mappings":";AAwIA,qBAIa,sBAAsB;IACjC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA6C;IAC1E,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAmC;IACzD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAsB;IAEjD,OAAO,CAAC,qBAAqB,CAA4B;IACzD,OAAO,CAAC,oBAAoB,CAA6B;IACzD,OAAO,CAAC,oBAAoB,CAA6B;IACzD,OAAO,CAAC,cAAc,CAA+B;IACrD,OAAO,CAAC,wBAAwB,CAA6B;IAE7D,QAAQ,CAAC,SAAS;;;oBAAqD;IACvE,QAAQ,CAAC,MAAM;;;oBAAkD;IACjE,QAAQ,CAAC,SAAS;;;;oBAA4D;IAE9E,OAAO,CAAC,WAAW,CAAwB;IAC3C,OAAO,CAAC,cAAc,CAAqB;IAG3C,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAG,sBAAsB,CAAU;IAG9D,SAAS,KAAK,MAAM,IAAI,EAAE,GAAG,IAAI,CAEhC;;IAsBD;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,aAAa;IAKrB,OAAO,CAAC,UAAU;IA4BlB,OAAO,CAAC,wBAAwB;IAuBhC,OAAO,CAAC,2BAA2B;IASnC,OAAO,CAAC,mBAAmB;IAgB3B,OAAO,CAAC,sBAAsB;IAK9B,OAAO,CAAC,sBAAsB;IAqB9B,OAAO,CAAC,sBAAsB;IAM9B,OAAO,CAAC,uBAAuB;IAU/B,OAAO,CAAC,sBAAsB;IAgD9B,OAAO,CAAC,oBAAoB;IAqC5B,OAAO,CAAC,mBAAmB;yCA7QhB,sBAAsB;2CAAtB,sBAAsB;CA+RlC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DestroyRef, Directive, ElementRef, HostBinding, inject, input, effect, } from '@angular/core';
|
|
2
|
-
import { computeOverlayPosition } from '@tailng-ui/cdk';
|
|
2
|
+
import { computeOverlayPosition, resolveAnchoredYWhenOffscreen } from '@tailng-ui/cdk';
|
|
3
3
|
import { TNG_AUTOCOMPLETE } from './tng-autocomplete.tokens';
|
|
4
4
|
import * as i0 from "@angular/core";
|
|
5
5
|
const PORTALLED_AUTOCOMPLETE_THEME_VARS = [
|
|
@@ -69,20 +69,51 @@ function rectFromClientRect(r) {
|
|
|
69
69
|
function viewportRect() {
|
|
70
70
|
return { left: 0, top: 0, width: window.innerWidth || 1024, height: window.innerHeight || 768 };
|
|
71
71
|
}
|
|
72
|
-
function resolveAnchoredYWhenOffscreen(resultY, anchor, overlay, viewport, side, sideOffset) {
|
|
73
|
-
const viewportBottom = viewport.top + viewport.height;
|
|
74
|
-
const anchorBottom = anchor.top + anchor.height;
|
|
75
|
-
if (anchorBottom < viewport.top && side === 'bottom') {
|
|
76
|
-
return anchorBottom + sideOffset;
|
|
77
|
-
}
|
|
78
|
-
if (anchor.top > viewportBottom && side === 'top') {
|
|
79
|
-
return anchor.top - overlay.height - sideOffset;
|
|
80
|
-
}
|
|
81
|
-
return resultY;
|
|
82
|
-
}
|
|
83
72
|
function isInside(target, container) {
|
|
84
73
|
return !!target && target instanceof Node && container.contains(target);
|
|
85
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* When the overlay's host element lives inside a `tng-form-field`, the form-field
|
|
77
|
+
* is the visible frame the consumer sees, so the overlay should align with it
|
|
78
|
+
* (width + left/right edges). For the `left` label layout the form-field's root
|
|
79
|
+
* spans the label column too, so anchor on the inner control-row instead.
|
|
80
|
+
*/
|
|
81
|
+
function findFormFieldAnchor(host) {
|
|
82
|
+
const formField = host.closest('[data-slot="form-field"]');
|
|
83
|
+
if (!formField)
|
|
84
|
+
return null;
|
|
85
|
+
if (formField.getAttribute('data-label-position') === 'left') {
|
|
86
|
+
const row = formField.querySelector('.tng-form-field__control-row');
|
|
87
|
+
return row ?? formField;
|
|
88
|
+
}
|
|
89
|
+
return formField;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Rect to use for overlay positioning. When the anchor is a form-field root, the
|
|
93
|
+
* horizontal extent is taken from the form-field (so the overlay spans the field
|
|
94
|
+
* frame) but the vertical extent is taken from the inner fieldset (the input row)
|
|
95
|
+
* so the overlay opens directly under the input rather than below the messages
|
|
96
|
+
* region beneath the frame.
|
|
97
|
+
*/
|
|
98
|
+
function anchorRectFor(anchorEl) {
|
|
99
|
+
const widthRect = anchorEl.getBoundingClientRect();
|
|
100
|
+
if (!anchorEl.matches('[data-slot="form-field"]')) {
|
|
101
|
+
return rectFromClientRect(widthRect);
|
|
102
|
+
}
|
|
103
|
+
const labelPosition = anchorEl.getAttribute('data-label-position');
|
|
104
|
+
const fieldset = anchorEl.querySelector('[data-slot="form-field-control-row"]');
|
|
105
|
+
const innerRow = anchorEl.querySelector('.tng-form-field__control-row');
|
|
106
|
+
const positionEl = labelPosition === 'outline' ? (fieldset ?? innerRow) : (innerRow ?? fieldset);
|
|
107
|
+
if (!positionEl)
|
|
108
|
+
return rectFromClientRect(widthRect);
|
|
109
|
+
const positionRect = positionEl.getBoundingClientRect();
|
|
110
|
+
return {
|
|
111
|
+
left: widthRect.left,
|
|
112
|
+
width: widthRect.width,
|
|
113
|
+
top: positionRect.top,
|
|
114
|
+
height: positionRect.height,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
86
117
|
export class TngAutocompleteOverlay {
|
|
87
118
|
autocomplete = inject(TNG_AUTOCOMPLETE);
|
|
88
119
|
elRef = inject((ElementRef));
|
|
@@ -120,9 +151,17 @@ export class TngAutocompleteOverlay {
|
|
|
120
151
|
this.originalParent = null;
|
|
121
152
|
});
|
|
122
153
|
}
|
|
123
|
-
/**
|
|
154
|
+
/**
|
|
155
|
+
* Anchor for overlay positioning, width, and dismiss boundary.
|
|
156
|
+
* Prefer the enclosing form-field (so the overlay aligns with the visible
|
|
157
|
+
* field frame), else the trigger container (trigger + icon), else the input
|
|
158
|
+
* trigger itself.
|
|
159
|
+
*/
|
|
124
160
|
findAnchorEl() {
|
|
125
161
|
const root = this.autocomplete.hostElement;
|
|
162
|
+
const formFieldAnchor = findFormFieldAnchor(root);
|
|
163
|
+
if (formFieldAnchor)
|
|
164
|
+
return formFieldAnchor;
|
|
126
165
|
const container = root.querySelector('[data-slot="autocomplete-trigger-container"]');
|
|
127
166
|
if (container)
|
|
128
167
|
return container;
|
|
@@ -139,7 +178,7 @@ export class TngAutocompleteOverlay {
|
|
|
139
178
|
const anchorEl = this.findAnchorEl();
|
|
140
179
|
if (!anchorEl)
|
|
141
180
|
return;
|
|
142
|
-
const anchor =
|
|
181
|
+
const anchor = anchorRectFor(anchorEl);
|
|
143
182
|
const overlay = rectFromClientRect(panel.getBoundingClientRect());
|
|
144
183
|
const viewport = viewportRect();
|
|
145
184
|
const offset = this.offset();
|
|
@@ -152,7 +191,14 @@ export class TngAutocompleteOverlay {
|
|
|
152
191
|
collision: this.collision(),
|
|
153
192
|
});
|
|
154
193
|
panel.style.left = `${result.x}px`;
|
|
155
|
-
panel.style.top = `${resolveAnchoredYWhenOffscreen(
|
|
194
|
+
panel.style.top = `${resolveAnchoredYWhenOffscreen({
|
|
195
|
+
anchorRect: anchor,
|
|
196
|
+
overlayRect: overlay,
|
|
197
|
+
side: result.side,
|
|
198
|
+
sideOffset: offset?.side,
|
|
199
|
+
viewportRect: viewport,
|
|
200
|
+
y: result.y,
|
|
201
|
+
})}px`;
|
|
156
202
|
}
|
|
157
203
|
setupRepositionListeners() {
|
|
158
204
|
let rafId = null;
|
|
@@ -258,8 +304,12 @@ export class TngAutocompleteOverlay {
|
|
|
258
304
|
const anchorEl = this.findAnchorEl();
|
|
259
305
|
if (!anchorEl)
|
|
260
306
|
return;
|
|
261
|
-
const anchor =
|
|
307
|
+
const anchor = anchorRectFor(anchorEl);
|
|
262
308
|
panel.style.minWidth = `${anchor.width}px`;
|
|
309
|
+
if (findFormFieldAnchor(this.autocomplete.hostElement)) {
|
|
310
|
+
panel.style.width = `${anchor.width}px`;
|
|
311
|
+
panel.style.maxWidth = 'none';
|
|
312
|
+
}
|
|
263
313
|
const overlay = rectFromClientRect(panel.getBoundingClientRect());
|
|
264
314
|
const viewport = viewportRect();
|
|
265
315
|
const offset = this.offset();
|
|
@@ -272,7 +322,14 @@ export class TngAutocompleteOverlay {
|
|
|
272
322
|
collision: this.collision(),
|
|
273
323
|
});
|
|
274
324
|
panel.style.left = `${result.x}px`;
|
|
275
|
-
panel.style.top = `${resolveAnchoredYWhenOffscreen(
|
|
325
|
+
panel.style.top = `${resolveAnchoredYWhenOffscreen({
|
|
326
|
+
anchorRect: anchor,
|
|
327
|
+
overlayRect: overlay,
|
|
328
|
+
side: result.side,
|
|
329
|
+
sideOffset: offset?.side,
|
|
330
|
+
viewportRect: viewport,
|
|
331
|
+
y: result.y,
|
|
332
|
+
})}px`;
|
|
276
333
|
});
|
|
277
334
|
this.setupOutsidePointer();
|
|
278
335
|
}
|
|
@@ -304,6 +361,8 @@ export class TngAutocompleteOverlay {
|
|
|
304
361
|
panel.style.top = '';
|
|
305
362
|
panel.style.zIndex = '';
|
|
306
363
|
panel.style.minWidth = '';
|
|
364
|
+
panel.style.width = '';
|
|
365
|
+
panel.style.maxWidth = '';
|
|
307
366
|
this.clearPortalledThemeVars();
|
|
308
367
|
this.teardownOutsidePointer();
|
|
309
368
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tng-autocomplete.overlay.js","sourceRoot":"","sources":["../../../../../../../../libs/tailng-ui/primitives/src/lib/form/autocomplete/tng-autocomplete.overlay.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,UAAU,EACV,WAAW,EACX,MAAM,EACN,KAAK,EACL,MAAM,GACP,MAAM,eAAe,CAAC;AAMvB,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;;AAK7D,MAAM,iCAAiC,GAAG;IACxC,2BAA2B;IAC3B,kCAAkC;IAClC,uCAAuC;IACvC,iDAAiD;IACjD,0CAA0C;IAC1C,yCAAyC;IACzC,+BAA+B;IAC/B,+BAA+B;IAC/B,8BAA8B;IAC9B,kCAAkC;IAClC,iCAAiC;IACjC,2CAA2C;IAC3C,oCAAoC;IACpC,mCAAmC;IACnC,mCAAmC;IACnC,sCAAsC;IACtC,8BAA8B;IAC9B,oCAAoC;IACpC,iBAAiB;IACjB,mCAAmC;IACnC,+BAA+B;IAC/B,gCAAgC;IAChC,sCAAsC;IACtC,8BAA8B;IAC9B,8BAA8B;IAC9B,kCAAkC;IAClC,qCAAqC;IACrC,yCAAyC;IACzC,uCAAuC;IACvC,2CAA2C;IAC3C,uCAAuC;IACvC,8CAA8C;IAC9C,kDAAkD;IAClD,kDAAkD;IAClD,4CAA4C;IAC5C,2BAA2B;IAC3B,kCAAkC;IAClC,iCAAiC;IACjC,uBAAuB;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,CAAC;IAEO,mBAAmB;QACzB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC;QACvC,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAmC,CAAC;QAC5D,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QACrC,IAAI,CAAC,OAAO;YAAE,OAAO;QAErB,IAAI,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YACrC,IAAI,CAAC,YAAY,CAAC,eAAe,GAAG,IAAI,CAAC;YACzC,OAAO,CAAC,KAAK,EAAE,CAAC;YAChB,cAAc,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC,eAAe,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YACrE,OAAO;QACT,CAAC;QACD,IAAI,QAAQ,CAAC,aAAa,KAAK,QAAQ,CAAC,IAAI,EAAE,CAAC;YAC7C,IAAI,CAAC,YAAY,CAAC,eAAe,GAAG,IAAI,CAAC;YACzC,OAAO,CAAC,KAAK,EAAE,CAAC;YAChB,cAAc,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC,eAAe,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;uGAjRU,sBAAsB;2FAAtB,sBAAsB;;2FAAtB,sBAAsB;kBAJlC,SAAS;mBAAC;oBACT,QAAQ,EAAE,0BAA0B;oBACpC,QAAQ,EAAE,wBAAwB;iBACnC;;sBAmBE,WAAW;uBAAC,gBAAgB;;sBAG5B,WAAW;uBAAC,aAAa","sourcesContent":["import {\n DestroyRef,\n Directive,\n ElementRef,\n HostBinding,\n inject,\n input,\n effect,\n} from '@angular/core';\nimport type {\n TngOverlayCollisionOptions,\n TngOverlayOffset,\n TngOverlayPlacement,\n} from '@tailng-ui/cdk';\nimport { computeOverlayPosition } from '@tailng-ui/cdk';\nimport { TNG_AUTOCOMPLETE } from './tng-autocomplete.tokens';\nimport type { TngAutocomplete } from './tng-autocomplete';\n\ntype MaybeRect = Readonly<{ left: number; top: number; width: number; height: number }>;\n\nconst PORTALLED_AUTOCOMPLETE_THEME_VARS = [\n '--tng-autocomplete-radius',\n '--tng-autocomplete-trigger-width',\n '--tng-autocomplete-trigger-min-height',\n '--tng-autocomplete-trigger-container-min-height',\n '--tng-autocomplete-trigger-container-gap',\n '--tng-autocomplete-trigger-container-px',\n '--tng-autocomplete-trigger-py',\n '--tng-autocomplete-trigger-px',\n '--tng-autocomplete-icon-size',\n '--tng-autocomplete-icon-box-size',\n '--tng-autocomplete-icon-opacity',\n '--tng-autocomplete-icon-margin-inline-end',\n '--tng-autocomplete-overlay-padding',\n '--tng-autocomplete-overlay-radius',\n '--tng-autocomplete-overlay-shadow',\n '--tng-autocomplete-overlay-max-width',\n '--tng-autocomplete-z-overlay',\n '--tng-autocomplete-overlay-z-index',\n '--tng-z-overlay',\n '--tng-autocomplete-overlay-border',\n '--tng-autocomplete-overlay-bg',\n '--tng-autocomplete-listbox-gap',\n '--tng-autocomplete-option-min-height',\n '--tng-autocomplete-option-py',\n '--tng-autocomplete-option-px',\n '--tng-autocomplete-option-radius',\n '--tng-autocomplete-option-bg-active',\n '--tng-autocomplete-option-border-active',\n '--tng-autocomplete-option-bg-selected',\n '--tng-autocomplete-option-border-selected',\n '--tng-autocomplete-option-fg-selected',\n '--tng-autocomplete-option-bg-selected-active',\n '--tng-autocomplete-option-border-selected-active',\n '--tng-autocomplete-option-shadow-selected-active',\n '--tng-autocomplete-option-disabled-opacity',\n '--tng-autocomplete-border',\n '--tng-autocomplete-border-strong',\n '--tng-autocomplete-border-hover',\n '--tng-autocomplete-bg',\n '--tng-autocomplete-surface',\n '--tng-autocomplete-fg',\n '--tng-autocomplete-muted',\n '--tng-autocomplete-brand',\n '--tng-autocomplete-danger',\n '--tng-autocomplete-focus-ring',\n '--tng-autocomplete-ease',\n '--tng-autocomplete-shadow',\n '--tng-autocomplete-shadow-focus',\n '--tng-semantic-background-base',\n '--tng-semantic-background-canvas',\n '--tng-semantic-background-surface',\n '--tng-semantic-border-subtle',\n '--tng-semantic-border-strong',\n '--tng-semantic-foreground-primary',\n '--tng-semantic-foreground-secondary',\n '--tng-semantic-foreground-muted',\n '--tng-semantic-accent-brand',\n '--tng-semantic-accent-danger',\n '--tng-semantic-focus-ring',\n] as const;\n\nfunction rectFromClientRect(r: DOMRect | ClientRect): MaybeRect {\n return { left: r.left, top: r.top, width: r.width, height: r.height };\n}\n\nfunction viewportRect(): MaybeRect {\n return { left: 0, top: 0, width: window.innerWidth || 1024, height: window.innerHeight || 768 };\n}\n\nfunction resolveAnchoredYWhenOffscreen(\n resultY: number,\n anchor: MaybeRect,\n overlay: MaybeRect,\n viewport: MaybeRect,\n side: 'bottom' | 'top' | 'left' | 'right',\n sideOffset: number,\n): number {\n const viewportBottom = viewport.top + viewport.height;\n const anchorBottom = anchor.top + anchor.height;\n\n if (anchorBottom < viewport.top && side === 'bottom') {\n return anchorBottom + sideOffset;\n }\n\n if (anchor.top > viewportBottom && side === 'top') {\n return anchor.top - overlay.height - sideOffset;\n }\n\n return resultY;\n}\n\nfunction isInside(target: EventTarget | null, container: HTMLElement): boolean {\n return !!target && target instanceof Node && container.contains(target);\n}\n\n@Directive({\n selector: '[tngAutocompleteOverlay]',\n exportAs: 'tngAutocompleteOverlay',\n})\nexport class TngAutocompleteOverlay {\n private readonly autocomplete = inject<TngAutocomplete>(TNG_AUTOCOMPLETE);\n private readonly elRef = inject(ElementRef<HTMLElement>);\n private readonly destroyRef = inject(DestroyRef);\n\n private lastFocusedBeforeOpen: HTMLElement | null = null;\n private removeResizeListener: (() => void) | null = null;\n private removeScrollListener: (() => void) | null = null;\n private resizeObserver: ResizeObserver | null = null;\n private removeDocPointerListener: (() => void) | null = null;\n\n readonly placement = input<TngOverlayPlacement | undefined>(undefined);\n readonly offset = input<TngOverlayOffset | undefined>(undefined);\n readonly collision = input<TngOverlayCollisionOptions | undefined>(undefined);\n\n private placeholder: Comment | null = null;\n private originalParent: Node | null = null;\n\n @HostBinding('attr.data-slot')\n protected readonly dataSlot = 'autocomplete-overlay' as const;\n\n @HostBinding('attr.hidden')\n protected get hidden(): '' | null {\n return this.autocomplete.open() ? null : '';\n }\n\n constructor() {\n this.placeholder = document.createComment('tng-autocomplete-overlay-anchor');\n const hostEl = this.elRef.nativeElement;\n this.originalParent = hostEl.parentNode;\n this.originalParent?.insertBefore(this.placeholder, hostEl);\n\n effect(() => {\n const open = this.autocomplete.open();\n if (open) this.mountToBodyAndPosition();\n else this.restoreToPlaceholder();\n });\n\n this.destroyRef.onDestroy(() => {\n this.teardownOutsidePointer();\n this.restoreToPlaceholder(true);\n this.placeholder = null;\n this.originalParent = null;\n });\n }\n\n /** Anchor for overlay: container (trigger+icon) if present, else the input trigger. */\n private findAnchorEl(): HTMLElement | null {\n const root = this.autocomplete.hostElement;\n const container = root.querySelector('[data-slot=\"autocomplete-trigger-container\"]') as HTMLElement | null;\n if (container) return container;\n return root.querySelector('[data-slot=\"autocomplete-trigger\"]') as HTMLElement | null;\n }\n\n private findTriggerEl(): HTMLElement | null {\n const root = this.autocomplete.hostElement;\n return root.querySelector('[data-slot=\"autocomplete-trigger\"]') as HTMLElement | null;\n }\n\n private reposition(): void {\n if (!this.autocomplete.open()) return;\n const panel = this.elRef.nativeElement;\n const anchorEl = this.findAnchorEl();\n if (!anchorEl) return;\n const anchor = rectFromClientRect(anchorEl.getBoundingClientRect());\n const overlay = rectFromClientRect(panel.getBoundingClientRect());\n const viewport = viewportRect();\n const offset = this.offset();\n const result = computeOverlayPosition({\n anchorRect: anchor,\n overlayRect: overlay,\n viewportRect: viewport,\n placement: this.placement(),\n offset,\n collision: this.collision(),\n });\n panel.style.left = `${result.x}px`;\n panel.style.top = `${resolveAnchoredYWhenOffscreen(\n result.y,\n anchor,\n overlay,\n viewport,\n result.side,\n offset?.side ?? 0,\n )}px`;\n }\n\n private setupRepositionListeners(): void {\n let rafId: number | null = null;\n const schedule = () => {\n if (rafId !== null) return;\n rafId = requestAnimationFrame(() => {\n rafId = null;\n this.reposition();\n });\n };\n const onResize = () => schedule();\n const onScroll = () => schedule();\n window.addEventListener('resize', onResize);\n window.addEventListener('scroll', onScroll, true);\n this.removeResizeListener = () => window.removeEventListener('resize', onResize);\n this.removeScrollListener = () => window.removeEventListener('scroll', onScroll, true);\n if ('ResizeObserver' in window) {\n this.resizeObserver = new ResizeObserver(() => schedule());\n const anchorEl = this.findAnchorEl();\n if (anchorEl) this.resizeObserver.observe(anchorEl);\n this.resizeObserver.observe(this.elRef.nativeElement);\n }\n }\n\n private teardownRepositionListeners(): void {\n this.removeResizeListener?.();\n this.removeScrollListener?.();\n this.removeResizeListener = null;\n this.removeScrollListener = null;\n this.resizeObserver?.disconnect();\n this.resizeObserver = null;\n }\n\n private setupOutsidePointer(): void {\n if (this.removeDocPointerListener) return;\n const onPointerDown = (ev: PointerEvent) => {\n if (!this.autocomplete.open()) return;\n const panel = this.elRef.nativeElement;\n const anchorEl = this.findAnchorEl();\n if (isInside(ev.target, panel)) return;\n if (anchorEl && isInside(ev.target, anchorEl)) return;\n if (ev.target && (ev.target as Element).closest?.('[data-slot=\"autocomplete-option\"]')) return;\n this.autocomplete.close();\n };\n document.addEventListener('pointerdown', onPointerDown, true);\n this.removeDocPointerListener = () =>\n document.removeEventListener('pointerdown', onPointerDown, true);\n }\n\n private teardownOutsidePointer(): void {\n this.removeDocPointerListener?.();\n this.removeDocPointerListener = null;\n }\n\n private syncPortalledThemeVars(): void {\n const panel = this.elRef.nativeElement;\n const hostStyles = getComputedStyle(this.autocomplete.hostElement);\n\n for (const cssVar of PORTALLED_AUTOCOMPLETE_THEME_VARS) {\n const value = hostStyles.getPropertyValue(cssVar).trim();\n if (value) {\n panel.style.setProperty(cssVar, value);\n } else {\n panel.style.removeProperty(cssVar);\n }\n }\n\n const colorScheme = hostStyles.colorScheme?.trim();\n if (colorScheme && colorScheme !== 'normal') {\n panel.style.colorScheme = colorScheme;\n } else {\n panel.style.removeProperty('color-scheme');\n }\n }\n\n private applyPortalledStacking(): void {\n const panel = this.elRef.nativeElement;\n\n panel.style.zIndex = 'var(--tng-autocomplete-z-overlay, var(--tng-autocomplete-overlay-z-index, var(--tng-z-overlay, 2)))';\n }\n\n private clearPortalledThemeVars(): void {\n const panel = this.elRef.nativeElement;\n\n for (const cssVar of PORTALLED_AUTOCOMPLETE_THEME_VARS) {\n panel.style.removeProperty(cssVar);\n }\n\n panel.style.removeProperty('color-scheme');\n }\n\n private mountToBodyAndPosition(): void {\n this.lastFocusedBeforeOpen = document.activeElement as HTMLElement | null;\n this.setupRepositionListeners();\n const panel = this.elRef.nativeElement;\n if (panel.parentNode !== document.body) {\n document.body.appendChild(panel);\n }\n panel.style.position = 'fixed';\n panel.style.left = '0px';\n panel.style.top = '0px';\n this.syncPortalledThemeVars();\n this.applyPortalledStacking();\n\n queueMicrotask(() => {\n if (!this.autocomplete.open()) return;\n const anchorEl = this.findAnchorEl();\n if (!anchorEl) return;\n const anchor = rectFromClientRect(anchorEl.getBoundingClientRect());\n panel.style.minWidth = `${anchor.width}px`;\n const overlay = rectFromClientRect(panel.getBoundingClientRect());\n const viewport = viewportRect();\n const offset = this.offset();\n const result = computeOverlayPosition({\n anchorRect: anchor,\n overlayRect: overlay,\n viewportRect: viewport,\n placement: this.placement(),\n offset,\n collision: this.collision(),\n });\n panel.style.left = `${result.x}px`;\n panel.style.top = `${resolveAnchoredYWhenOffscreen(\n result.y,\n anchor,\n overlay,\n viewport,\n result.side,\n offset?.side ?? 0,\n )}px`;\n });\n\n this.setupOutsidePointer();\n }\n\n private restoreToPlaceholder(force = false): void {\n const panel = this.elRef.nativeElement;\n if (!force && panel.parentNode !== document.body) {\n this.teardownOutsidePointer();\n return;\n }\n if (this.placeholder?.parentNode) {\n this.placeholder.parentNode.insertBefore(panel, this.placeholder);\n } else if (this.originalParent) {\n this.originalParent.appendChild(panel);\n }\n this.teardownRepositionListeners();\n\n if (\n this.lastFocusedBeforeOpen &&\n document.contains(this.lastFocusedBeforeOpen)\n ) {\n const active = document.activeElement as HTMLElement | null;\n if (!active || panel.contains(active)) {\n this.autocomplete._restoringFocus = true;\n this.lastFocusedBeforeOpen.focus();\n queueMicrotask(() => { this.autocomplete._restoringFocus = false; });\n }\n }\n this.restoreFocusOnClose();\n\n panel.style.position = '';\n panel.style.left = '';\n panel.style.top = '';\n panel.style.zIndex = '';\n panel.style.minWidth = '';\n this.clearPortalledThemeVars();\n this.teardownOutsidePointer();\n }\n\n private restoreFocusOnClose(): void {\n const panel = this.elRef.nativeElement;\n const active = document.activeElement as HTMLElement | null;\n const trigger = this.findTriggerEl();\n if (!trigger) return;\n\n if (active && panel.contains(active)) {\n this.autocomplete._restoringFocus = true;\n trigger.focus();\n queueMicrotask(() => { this.autocomplete._restoringFocus = false; });\n return;\n }\n if (document.activeElement === document.body) {\n this.autocomplete._restoringFocus = true;\n trigger.focus();\n queueMicrotask(() => { this.autocomplete._restoringFocus = false; });\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tng-autocomplete.overlay.js","sourceRoot":"","sources":["../../../../../../../../libs/tailng-ui/primitives/src/lib/form/autocomplete/tng-autocomplete.overlay.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,UAAU,EACV,WAAW,EACX,MAAM,EACN,KAAK,EACL,MAAM,GACP,MAAM,eAAe,CAAC;AAMvB,OAAO,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AACvF,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;;AAK7D,MAAM,iCAAiC,GAAG;IACxC,2BAA2B;IAC3B,kCAAkC;IAClC,uCAAuC;IACvC,iDAAiD;IACjD,0CAA0C;IAC1C,yCAAyC;IACzC,+BAA+B;IAC/B,+BAA+B;IAC/B,8BAA8B;IAC9B,kCAAkC;IAClC,iCAAiC;IACjC,2CAA2C;IAC3C,oCAAoC;IACpC,mC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C;uGA9RU,sBAAsB;2FAAtB,sBAAsB;;2FAAtB,sBAAsB;kBAJlC,SAAS;mBAAC;oBACT,QAAQ,EAAE,0BAA0B;oBACpC,QAAQ,EAAE,wBAAwB;iBACnC;;sBAmBE,WAAW;uBAAC,gBAAgB;;sBAG5B,WAAW;uBAAC,aAAa","sourcesContent":["import {\n DestroyRef,\n Directive,\n ElementRef,\n HostBinding,\n inject,\n input,\n effect,\n} from '@angular/core';\nimport type {\n TngOverlayCollisionOptions,\n TngOverlayOffset,\n TngOverlayPlacement,\n} from '@tailng-ui/cdk';\nimport { computeOverlayPosition, resolveAnchoredYWhenOffscreen } from '@tailng-ui/cdk';\nimport { TNG_AUTOCOMPLETE } from './tng-autocomplete.tokens';\nimport type { TngAutocomplete } from './tng-autocomplete';\n\ntype MaybeRect = Readonly<{ left: number; top: number; width: number; height: number }>;\n\nconst PORTALLED_AUTOCOMPLETE_THEME_VARS = [\n '--tng-autocomplete-radius',\n '--tng-autocomplete-trigger-width',\n '--tng-autocomplete-trigger-min-height',\n '--tng-autocomplete-trigger-container-min-height',\n '--tng-autocomplete-trigger-container-gap',\n '--tng-autocomplete-trigger-container-px',\n '--tng-autocomplete-trigger-py',\n '--tng-autocomplete-trigger-px',\n '--tng-autocomplete-icon-size',\n '--tng-autocomplete-icon-box-size',\n '--tng-autocomplete-icon-opacity',\n '--tng-autocomplete-icon-margin-inline-end',\n '--tng-autocomplete-overlay-padding',\n '--tng-autocomplete-overlay-radius',\n '--tng-autocomplete-overlay-shadow',\n '--tng-autocomplete-overlay-max-width',\n '--tng-autocomplete-z-overlay',\n '--tng-autocomplete-overlay-z-index',\n '--tng-z-overlay',\n '--tng-autocomplete-overlay-border',\n '--tng-autocomplete-overlay-bg',\n '--tng-autocomplete-listbox-gap',\n '--tng-autocomplete-option-min-height',\n '--tng-autocomplete-option-py',\n '--tng-autocomplete-option-px',\n '--tng-autocomplete-option-radius',\n '--tng-autocomplete-option-bg-active',\n '--tng-autocomplete-option-border-active',\n '--tng-autocomplete-option-bg-selected',\n '--tng-autocomplete-option-border-selected',\n '--tng-autocomplete-option-fg-selected',\n '--tng-autocomplete-option-bg-selected-active',\n '--tng-autocomplete-option-border-selected-active',\n '--tng-autocomplete-option-shadow-selected-active',\n '--tng-autocomplete-option-disabled-opacity',\n '--tng-autocomplete-border',\n '--tng-autocomplete-border-strong',\n '--tng-autocomplete-border-hover',\n '--tng-autocomplete-bg',\n '--tng-autocomplete-surface',\n '--tng-autocomplete-fg',\n '--tng-autocomplete-muted',\n '--tng-autocomplete-brand',\n '--tng-autocomplete-danger',\n '--tng-autocomplete-focus-ring',\n '--tng-autocomplete-ease',\n '--tng-autocomplete-shadow',\n '--tng-autocomplete-shadow-focus',\n '--tng-semantic-background-base',\n '--tng-semantic-background-canvas',\n '--tng-semantic-background-surface',\n '--tng-semantic-border-subtle',\n '--tng-semantic-border-strong',\n '--tng-semantic-foreground-primary',\n '--tng-semantic-foreground-secondary',\n '--tng-semantic-foreground-muted',\n '--tng-semantic-accent-brand',\n '--tng-semantic-accent-danger',\n '--tng-semantic-focus-ring',\n] as const;\n\nfunction rectFromClientRect(r: DOMRect | ClientRect): MaybeRect {\n return { left: r.left, top: r.top, width: r.width, height: r.height };\n}\n\nfunction viewportRect(): MaybeRect {\n return { left: 0, top: 0, width: window.innerWidth || 1024, height: window.innerHeight || 768 };\n}\n\nfunction isInside(target: EventTarget | null, container: HTMLElement): boolean {\n return !!target && target instanceof Node && container.contains(target);\n}\n\n/**\n * When the overlay's host element lives inside a `tng-form-field`, the form-field\n * is the visible frame the consumer sees, so the overlay should align with it\n * (width + left/right edges). For the `left` label layout the form-field's root\n * spans the label column too, so anchor on the inner control-row instead.\n */\nfunction findFormFieldAnchor(host: HTMLElement): HTMLElement | null {\n const formField = host.closest('[data-slot=\"form-field\"]') as HTMLElement | null;\n if (!formField) return null;\n if (formField.getAttribute('data-label-position') === 'left') {\n const row = formField.querySelector('.tng-form-field__control-row') as HTMLElement | null;\n return row ?? formField;\n }\n return formField;\n}\n\n/**\n * Rect to use for overlay positioning. When the anchor is a form-field root, the\n * horizontal extent is taken from the form-field (so the overlay spans the field\n * frame) but the vertical extent is taken from the inner fieldset (the input row)\n * so the overlay opens directly under the input rather than below the messages\n * region beneath the frame.\n */\nfunction anchorRectFor(anchorEl: HTMLElement): MaybeRect {\n const widthRect = anchorEl.getBoundingClientRect();\n if (!anchorEl.matches('[data-slot=\"form-field\"]')) {\n return rectFromClientRect(widthRect);\n }\n const labelPosition = anchorEl.getAttribute('data-label-position');\n const fieldset = anchorEl.querySelector('[data-slot=\"form-field-control-row\"]') as HTMLElement | null;\n const innerRow = anchorEl.querySelector('.tng-form-field__control-row') as HTMLElement | null;\n const positionEl = labelPosition === 'outline' ? (fieldset ?? innerRow) : (innerRow ?? fieldset);\n if (!positionEl) return rectFromClientRect(widthRect);\n const positionRect = positionEl.getBoundingClientRect();\n return {\n left: widthRect.left,\n width: widthRect.width,\n top: positionRect.top,\n height: positionRect.height,\n };\n}\n\n@Directive({\n selector: '[tngAutocompleteOverlay]',\n exportAs: 'tngAutocompleteOverlay',\n})\nexport class TngAutocompleteOverlay {\n private readonly autocomplete = inject<TngAutocomplete>(TNG_AUTOCOMPLETE);\n private readonly elRef = inject(ElementRef<HTMLElement>);\n private readonly destroyRef = inject(DestroyRef);\n\n private lastFocusedBeforeOpen: HTMLElement | null = null;\n private removeResizeListener: (() => void) | null = null;\n private removeScrollListener: (() => void) | null = null;\n private resizeObserver: ResizeObserver | null = null;\n private removeDocPointerListener: (() => void) | null = null;\n\n readonly placement = input<TngOverlayPlacement | undefined>(undefined);\n readonly offset = input<TngOverlayOffset | undefined>(undefined);\n readonly collision = input<TngOverlayCollisionOptions | undefined>(undefined);\n\n private placeholder: Comment | null = null;\n private originalParent: Node | null = null;\n\n @HostBinding('attr.data-slot')\n protected readonly dataSlot = 'autocomplete-overlay' as const;\n\n @HostBinding('attr.hidden')\n protected get hidden(): '' | null {\n return this.autocomplete.open() ? null : '';\n }\n\n constructor() {\n this.placeholder = document.createComment('tng-autocomplete-overlay-anchor');\n const hostEl = this.elRef.nativeElement;\n this.originalParent = hostEl.parentNode;\n this.originalParent?.insertBefore(this.placeholder, hostEl);\n\n effect(() => {\n const open = this.autocomplete.open();\n if (open) this.mountToBodyAndPosition();\n else this.restoreToPlaceholder();\n });\n\n this.destroyRef.onDestroy(() => {\n this.teardownOutsidePointer();\n this.restoreToPlaceholder(true);\n this.placeholder = null;\n this.originalParent = null;\n });\n }\n\n /**\n * Anchor for overlay positioning, width, and dismiss boundary.\n * Prefer the enclosing form-field (so the overlay aligns with the visible\n * field frame), else the trigger container (trigger + icon), else the input\n * trigger itself.\n */\n private findAnchorEl(): HTMLElement | null {\n const root = this.autocomplete.hostElement;\n const formFieldAnchor = findFormFieldAnchor(root);\n if (formFieldAnchor) return formFieldAnchor;\n const container = root.querySelector('[data-slot=\"autocomplete-trigger-container\"]') as HTMLElement | null;\n if (container) return container;\n return root.querySelector('[data-slot=\"autocomplete-trigger\"]') as HTMLElement | null;\n }\n\n private findTriggerEl(): HTMLElement | null {\n const root = this.autocomplete.hostElement;\n return root.querySelector('[data-slot=\"autocomplete-trigger\"]') as HTMLElement | null;\n }\n\n private reposition(): void {\n if (!this.autocomplete.open()) return;\n const panel = this.elRef.nativeElement;\n const anchorEl = this.findAnchorEl();\n if (!anchorEl) return;\n const anchor = anchorRectFor(anchorEl);\n const overlay = rectFromClientRect(panel.getBoundingClientRect());\n const viewport = viewportRect();\n const offset = this.offset();\n const result = computeOverlayPosition({\n anchorRect: anchor,\n overlayRect: overlay,\n viewportRect: viewport,\n placement: this.placement(),\n offset,\n collision: this.collision(),\n });\n panel.style.left = `${result.x}px`;\n panel.style.top = `${resolveAnchoredYWhenOffscreen({\n anchorRect: anchor,\n overlayRect: overlay,\n side: result.side,\n sideOffset: offset?.side,\n viewportRect: viewport,\n y: result.y,\n })}px`;\n }\n\n private setupRepositionListeners(): void {\n let rafId: number | null = null;\n const schedule = () => {\n if (rafId !== null) return;\n rafId = requestAnimationFrame(() => {\n rafId = null;\n this.reposition();\n });\n };\n const onResize = () => schedule();\n const onScroll = () => schedule();\n window.addEventListener('resize', onResize);\n window.addEventListener('scroll', onScroll, true);\n this.removeResizeListener = () => window.removeEventListener('resize', onResize);\n this.removeScrollListener = () => window.removeEventListener('scroll', onScroll, true);\n if ('ResizeObserver' in window) {\n this.resizeObserver = new ResizeObserver(() => schedule());\n const anchorEl = this.findAnchorEl();\n if (anchorEl) this.resizeObserver.observe(anchorEl);\n this.resizeObserver.observe(this.elRef.nativeElement);\n }\n }\n\n private teardownRepositionListeners(): void {\n this.removeResizeListener?.();\n this.removeScrollListener?.();\n this.removeResizeListener = null;\n this.removeScrollListener = null;\n this.resizeObserver?.disconnect();\n this.resizeObserver = null;\n }\n\n private setupOutsidePointer(): void {\n if (this.removeDocPointerListener) return;\n const onPointerDown = (ev: PointerEvent) => {\n if (!this.autocomplete.open()) return;\n const panel = this.elRef.nativeElement;\n const anchorEl = this.findAnchorEl();\n if (isInside(ev.target, panel)) return;\n if (anchorEl && isInside(ev.target, anchorEl)) return;\n if (ev.target && (ev.target as Element).closest?.('[data-slot=\"autocomplete-option\"]')) return;\n this.autocomplete.close();\n };\n document.addEventListener('pointerdown', onPointerDown, true);\n this.removeDocPointerListener = () =>\n document.removeEventListener('pointerdown', onPointerDown, true);\n }\n\n private teardownOutsidePointer(): void {\n this.removeDocPointerListener?.();\n this.removeDocPointerListener = null;\n }\n\n private syncPortalledThemeVars(): void {\n const panel = this.elRef.nativeElement;\n const hostStyles = getComputedStyle(this.autocomplete.hostElement);\n\n for (const cssVar of PORTALLED_AUTOCOMPLETE_THEME_VARS) {\n const value = hostStyles.getPropertyValue(cssVar).trim();\n if (value) {\n panel.style.setProperty(cssVar, value);\n } else {\n panel.style.removeProperty(cssVar);\n }\n }\n\n const colorScheme = hostStyles.colorScheme?.trim();\n if (colorScheme && colorScheme !== 'normal') {\n panel.style.colorScheme = colorScheme;\n } else {\n panel.style.removeProperty('color-scheme');\n }\n }\n\n private applyPortalledStacking(): void {\n const panel = this.elRef.nativeElement;\n\n panel.style.zIndex = 'var(--tng-autocomplete-z-overlay, var(--tng-autocomplete-overlay-z-index, var(--tng-z-overlay, 2)))';\n }\n\n private clearPortalledThemeVars(): void {\n const panel = this.elRef.nativeElement;\n\n for (const cssVar of PORTALLED_AUTOCOMPLETE_THEME_VARS) {\n panel.style.removeProperty(cssVar);\n }\n\n panel.style.removeProperty('color-scheme');\n }\n\n private mountToBodyAndPosition(): void {\n this.lastFocusedBeforeOpen = document.activeElement as HTMLElement | null;\n this.setupRepositionListeners();\n const panel = this.elRef.nativeElement;\n if (panel.parentNode !== document.body) {\n document.body.appendChild(panel);\n }\n panel.style.position = 'fixed';\n panel.style.left = '0px';\n panel.style.top = '0px';\n this.syncPortalledThemeVars();\n this.applyPortalledStacking();\n\n queueMicrotask(() => {\n if (!this.autocomplete.open()) return;\n const anchorEl = this.findAnchorEl();\n if (!anchorEl) return;\n const anchor = anchorRectFor(anchorEl);\n panel.style.minWidth = `${anchor.width}px`;\n if (findFormFieldAnchor(this.autocomplete.hostElement)) {\n panel.style.width = `${anchor.width}px`;\n panel.style.maxWidth = 'none';\n }\n const overlay = rectFromClientRect(panel.getBoundingClientRect());\n const viewport = viewportRect();\n const offset = this.offset();\n const result = computeOverlayPosition({\n anchorRect: anchor,\n overlayRect: overlay,\n viewportRect: viewport,\n placement: this.placement(),\n offset,\n collision: this.collision(),\n });\n panel.style.left = `${result.x}px`;\n panel.style.top = `${resolveAnchoredYWhenOffscreen({\n anchorRect: anchor,\n overlayRect: overlay,\n side: result.side,\n sideOffset: offset?.side,\n viewportRect: viewport,\n y: result.y,\n })}px`;\n });\n\n this.setupOutsidePointer();\n }\n\n private restoreToPlaceholder(force = false): void {\n const panel = this.elRef.nativeElement;\n if (!force && panel.parentNode !== document.body) {\n this.teardownOutsidePointer();\n return;\n }\n if (this.placeholder?.parentNode) {\n this.placeholder.parentNode.insertBefore(panel, this.placeholder);\n } else if (this.originalParent) {\n this.originalParent.appendChild(panel);\n }\n this.teardownRepositionListeners();\n\n if (\n this.lastFocusedBeforeOpen &&\n document.contains(this.lastFocusedBeforeOpen)\n ) {\n const active = document.activeElement as HTMLElement | null;\n if (!active || panel.contains(active)) {\n this.autocomplete._restoringFocus = true;\n this.lastFocusedBeforeOpen.focus();\n queueMicrotask(() => { this.autocomplete._restoringFocus = false; });\n }\n }\n this.restoreFocusOnClose();\n\n panel.style.position = '';\n panel.style.left = '';\n panel.style.top = '';\n panel.style.zIndex = '';\n panel.style.minWidth = '';\n panel.style.width = '';\n panel.style.maxWidth = '';\n this.clearPortalledThemeVars();\n this.teardownOutsidePointer();\n }\n\n private restoreFocusOnClose(): void {\n const panel = this.elRef.nativeElement;\n const active = document.activeElement as HTMLElement | null;\n const trigger = this.findTriggerEl();\n if (!trigger) return;\n\n if (active && panel.contains(active)) {\n this.autocomplete._restoringFocus = true;\n trigger.focus();\n queueMicrotask(() => { this.autocomplete._restoringFocus = false; });\n return;\n }\n if (document.activeElement === document.body) {\n this.autocomplete._restoringFocus = true;\n trigger.focus();\n queueMicrotask(() => { this.autocomplete._restoringFocus = false; });\n }\n }\n}\n"]}
|
|
@@ -56,6 +56,17 @@ export declare class TngDatepickerOverlay {
|
|
|
56
56
|
protected onKeydown(event: KeyboardEvent): void;
|
|
57
57
|
constructor();
|
|
58
58
|
private initializeOverlayPortal;
|
|
59
|
+
/**
|
|
60
|
+
* Resolve the explicit/datepicker-owned anchor (input-shell or trigger).
|
|
61
|
+
* This is the element used to read datepicker-scoped CSS custom properties
|
|
62
|
+
* (e.g. `--tng-datepicker-overlay-gap`) and to align the overlay vertically.
|
|
63
|
+
*/
|
|
64
|
+
private findDatepickerAnchorEl;
|
|
65
|
+
/**
|
|
66
|
+
* Anchor for overlay positioning, width, and dismiss boundary. Prefer the
|
|
67
|
+
* enclosing form-field (so the overlay spans the visible frame) and fall
|
|
68
|
+
* back to the datepicker-owned anchor otherwise.
|
|
69
|
+
*/
|
|
59
70
|
private findAnchorEl;
|
|
60
71
|
private scheduleReposition;
|
|
61
72
|
private positionOverlay;
|