@aquera/nile-elements 2.0.26 → 2.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +441 -418
- package/dist/nile-calendar/nile-calendar.cjs.js +1 -1
- package/dist/nile-calendar/nile-calendar.cjs.js.map +1 -1
- package/dist/nile-calendar/nile-calendar.esm.js +1 -1
- package/dist/nile-code-editor/nile-code-editor.cjs.js +2 -2
- package/dist/nile-code-editor/nile-code-editor.cjs.js.map +1 -1
- package/dist/nile-code-editor/nile-code-editor.esm.js +5 -5
- package/dist/nile-combobox/nile-combobox.cjs.js +1 -1
- package/dist/nile-combobox/nile-combobox.cjs.js.map +1 -1
- package/dist/nile-combobox/nile-combobox.css.cjs.js +1 -1
- package/dist/nile-combobox/nile-combobox.css.cjs.js.map +1 -1
- package/dist/nile-combobox/nile-combobox.css.esm.js +2 -0
- package/dist/nile-combobox/nile-combobox.esm.js +1 -1
- package/dist/nile-detail/nile-detail.cjs.js +1 -1
- package/dist/nile-detail/nile-detail.cjs.js.map +1 -1
- package/dist/nile-detail/nile-detail.esm.js +6 -5
- package/dist/nile-rich-text-editor/nile-rte-link.cjs.js +1 -1
- package/dist/nile-rich-text-editor/nile-rte-link.cjs.js.map +1 -1
- package/dist/nile-rich-text-editor/nile-rte-link.esm.js +1 -1
- package/dist/nile-select/index.cjs.js +1 -1
- package/dist/nile-select/index.esm.js +1 -1
- package/dist/nile-select/nile-select.cjs.js +1 -1
- package/dist/nile-select/nile-select.cjs.js.map +1 -1
- package/dist/nile-select/nile-select.esm.js +1 -1
- package/dist/nile-virtual-select/index.cjs.js +1 -1
- package/dist/nile-virtual-select/index.esm.js +1 -1
- package/dist/nile-virtual-select/nile-virtual-select.cjs.js +4 -4
- package/dist/nile-virtual-select/nile-virtual-select.cjs.js.map +1 -1
- package/dist/nile-virtual-select/nile-virtual-select.css.cjs.js +1 -1
- package/dist/nile-virtual-select/nile-virtual-select.css.cjs.js.map +1 -1
- package/dist/nile-virtual-select/nile-virtual-select.css.esm.js +19 -5
- package/dist/nile-virtual-select/nile-virtual-select.esm.js +5 -5
- package/dist/nile-virtual-select/renderer.cjs.js +1 -1
- package/dist/nile-virtual-select/renderer.cjs.js.map +1 -1
- package/dist/nile-virtual-select/renderer.esm.js +23 -22
- package/dist/src/nile-calendar/nile-calendar.d.ts +4 -0
- package/dist/src/nile-calendar/nile-calendar.js +18 -2
- package/dist/src/nile-calendar/nile-calendar.js.map +1 -1
- package/dist/src/nile-calendar/nile-calendar.test.js +50 -0
- package/dist/src/nile-calendar/nile-calendar.test.js.map +1 -1
- package/dist/src/nile-code-editor/nile-code-editor.d.ts +12 -0
- package/dist/src/nile-code-editor/nile-code-editor.js +92 -0
- package/dist/src/nile-code-editor/nile-code-editor.js.map +1 -1
- package/dist/src/nile-combobox/nile-combobox.css.js +2 -0
- package/dist/src/nile-combobox/nile-combobox.css.js.map +1 -1
- package/dist/src/nile-combobox/nile-combobox.d.ts +1 -0
- package/dist/src/nile-combobox/nile-combobox.js +12 -1
- package/dist/src/nile-combobox/nile-combobox.js.map +1 -1
- package/dist/src/nile-combobox/nile-combobox.test.js +375 -0
- package/dist/src/nile-combobox/nile-combobox.test.js.map +1 -1
- package/dist/src/nile-detail/nile-detail.d.ts +4 -0
- package/dist/src/nile-detail/nile-detail.js +35 -3
- package/dist/src/nile-detail/nile-detail.js.map +1 -1
- package/dist/src/nile-rich-text-editor/nile-rte-link.js +1 -1
- package/dist/src/nile-rich-text-editor/nile-rte-link.js.map +1 -1
- package/dist/src/nile-rich-text-editor/nile-rte-link.test.js +7 -0
- package/dist/src/nile-rich-text-editor/nile-rte-link.test.js.map +1 -1
- package/dist/src/nile-virtual-select/nile-virtual-select.css.js +19 -5
- package/dist/src/nile-virtual-select/nile-virtual-select.css.js.map +1 -1
- package/dist/src/nile-virtual-select/nile-virtual-select.d.ts +29 -0
- package/dist/src/nile-virtual-select/nile-virtual-select.js +120 -13
- package/dist/src/nile-virtual-select/nile-virtual-select.js.map +1 -1
- package/dist/src/nile-virtual-select/nile-virtual-select.test.js +187 -2
- package/dist/src/nile-virtual-select/nile-virtual-select.test.js.map +1 -1
- package/dist/src/nile-virtual-select/renderer.d.ts +1 -1
- package/dist/src/nile-virtual-select/renderer.js +11 -4
- package/dist/src/nile-virtual-select/renderer.js.map +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/nile-calendar/nile-calendar.test.ts +54 -0
- package/src/nile-calendar/nile-calendar.ts +17 -3
- package/src/nile-code-editor/nile-code-editor.ts +82 -0
- package/src/nile-combobox/nile-combobox.css.ts +2 -0
- package/src/nile-combobox/nile-combobox.test.ts +416 -0
- package/src/nile-combobox/nile-combobox.ts +11 -1
- package/src/nile-detail/nile-detail.ts +34 -3
- package/src/nile-rich-text-editor/nile-rte-link.test.ts +10 -0
- package/src/nile-rich-text-editor/nile-rte-link.ts +1 -1
- package/src/nile-virtual-select/nile-virtual-select.css.ts +19 -5
- package/src/nile-virtual-select/nile-virtual-select.test.ts +230 -2
- package/src/nile-virtual-select/nile-virtual-select.ts +117 -11
- package/src/nile-virtual-select/renderer.ts +12 -5
- package/vscode-html-custom-data.json +14 -4
package/package.json
CHANGED
|
@@ -3897,3 +3897,57 @@ describe('CS. variant day-label part and the height-lock class (no inline presen
|
|
|
3897
3897
|
}
|
|
3898
3898
|
});
|
|
3899
3899
|
});
|
|
3900
|
+
|
|
3901
|
+
/**
|
|
3902
|
+
* OC-3086: a typed From/To date outside `allowedDates` must be rejected (the grid already greyed those cells out),
|
|
3903
|
+
* and the manual inputs must stay usable when the viewed month has no allowed day so the user can type back in range.
|
|
3904
|
+
*/
|
|
3905
|
+
describe('NileCalendar manual date entry respects allowedDates (OC-3086)', () => {
|
|
3906
|
+
const ALLOWED = JSON.stringify({ startDate: '2026-11-01', endDate: '2026-11-20' });
|
|
3907
|
+
const make = async () => {
|
|
3908
|
+
const el = await fixture<NileCalendar>(html`
|
|
3909
|
+
<nile-calendar range .showManualInputs=${true} dateFormat="YYYY-MM-DD" allowedDates=${ALLOWED}></nile-calendar>`);
|
|
3910
|
+
await el.updateComplete;
|
|
3911
|
+
return el;
|
|
3912
|
+
};
|
|
3913
|
+
const dateInput = (el: NileCalendar, which: 0 | 1) =>
|
|
3914
|
+
el.shadowRoot!.querySelectorAll('.calender-input .date-input')[which] as any;
|
|
3915
|
+
const type = async (el: NileCalendar, which: 0 | 1, value: string) => {
|
|
3916
|
+
const input = dateInput(el, which);
|
|
3917
|
+
input.value = value;
|
|
3918
|
+
input.dispatchEvent(new CustomEvent('nile-change', { detail: { value }, bubbles: true, composed: true }));
|
|
3919
|
+
await el.updateComplete;
|
|
3920
|
+
return input;
|
|
3921
|
+
};
|
|
3922
|
+
|
|
3923
|
+
it('O1. a typed From date after the allowed range is rejected and the field reverts', async () => {
|
|
3924
|
+
const el = await make();
|
|
3925
|
+
const input = await type(el, 0, '2026-12-12');
|
|
3926
|
+
expect(el.startDate, 'startDate must not move to a disallowed date').to.satisfy((d: Date | null) => !d || d.getMonth() !== 11);
|
|
3927
|
+
expect(input.value).to.not.equal('2026-12-12');
|
|
3928
|
+
});
|
|
3929
|
+
|
|
3930
|
+
it('O2. a typed To date after the allowed range is rejected', async () => {
|
|
3931
|
+
const el = await make();
|
|
3932
|
+
const input = await type(el, 1, '2026-12-12');
|
|
3933
|
+
expect(el.endDate, 'endDate must not move to a disallowed date').to.satisfy((d: Date | null) => !d || d.getMonth() !== 11);
|
|
3934
|
+
expect(input.value).to.not.equal('2026-12-12');
|
|
3935
|
+
});
|
|
3936
|
+
|
|
3937
|
+
it('O3. a typed date inside the allowed range is accepted', async () => {
|
|
3938
|
+
const el = await make();
|
|
3939
|
+
await type(el, 0, '2026-11-10');
|
|
3940
|
+
expect(el.startDate!.getFullYear()).to.equal(2026);
|
|
3941
|
+
expect(el.startDate!.getMonth()).to.equal(10);
|
|
3942
|
+
expect(el.startDate!.getDate()).to.equal(10);
|
|
3943
|
+
});
|
|
3944
|
+
|
|
3945
|
+
it('O4. manual inputs stay enabled when the viewed month has no allowed day', async () => {
|
|
3946
|
+
const el = await make();
|
|
3947
|
+
el.currentYear = 2026; el.currentMonth = 11; // December: entirely out of range
|
|
3948
|
+
await el.updateComplete;
|
|
3949
|
+
const inputs = Array.from(el.shadowRoot!.querySelectorAll('.calender-input nile-input')) as any[];
|
|
3950
|
+
expect(inputs.length).to.equal(4);
|
|
3951
|
+
for (const i of inputs) expect(i.hasAttribute('disabled'), 'input must stay enabled').to.be.false;
|
|
3952
|
+
});
|
|
3953
|
+
});
|
|
@@ -629,27 +629,41 @@ export class NileCalendar extends NileElement {
|
|
|
629
629
|
private handleStartDateInput(event: CustomEvent): void {
|
|
630
630
|
event.stopPropagation();
|
|
631
631
|
const newDate = this.parseDate(event.detail.value, this.startDate);
|
|
632
|
-
if (newDate) {
|
|
632
|
+
if (newDate && this.isDateAllowed(newDate)) {
|
|
633
633
|
newDate.setHours(0, 0, 0);
|
|
634
634
|
this.startDate = newDate;
|
|
635
635
|
this.currentMonth = newDate.getMonth();
|
|
636
636
|
this.currentYear = newDate.getFullYear();
|
|
637
637
|
this.requestUpdate();
|
|
638
|
+
} else if (newDate) {
|
|
639
|
+
this.revertManualInput(event, this.startDate);
|
|
638
640
|
}
|
|
639
641
|
}
|
|
640
642
|
private handleEndDateInput(event: CustomEvent): void {
|
|
641
643
|
event.stopPropagation();
|
|
642
644
|
const newDate = this.parseDate(event.detail.value, this.endDate);
|
|
643
|
-
if (newDate) {
|
|
645
|
+
if (newDate && this.isDateAllowed(newDate)) {
|
|
644
646
|
newDate.setHours(23, 59, 59);
|
|
645
647
|
this.endDate = newDate;
|
|
646
648
|
this.currentMonth = newDate.getMonth();
|
|
647
649
|
this.currentYear = newDate.getFullYear();
|
|
648
650
|
this.requestUpdate();
|
|
651
|
+
} else if (newDate) {
|
|
652
|
+
this.revertManualInput(event, this.endDate);
|
|
649
653
|
}
|
|
650
654
|
}
|
|
651
655
|
|
|
652
|
-
|
|
656
|
+
/** True when the date falls inside `allowedDates` (always true when none is set). */
|
|
657
|
+
private isDateAllowed(date: Date): boolean {
|
|
658
|
+
return this.isAllowedDate(date.getDate(), date.getMonth(), date.getFullYear());
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
/** Puts the previous valid value back into a manual input after an out-of-range entry. */
|
|
662
|
+
private revertManualInput(event: Event, previous: Date | null): void {
|
|
663
|
+
const input = event.target as (HTMLElement & { value: string }) | null;
|
|
664
|
+
if (input) input.value = this.formatDate(previous);
|
|
665
|
+
}
|
|
666
|
+
|
|
653
667
|
private maskValuesMap = new WeakMap<HTMLInputElement, string[]>();
|
|
654
668
|
|
|
655
669
|
private boundMaskInputs: Element[] = [];
|
|
@@ -111,6 +111,9 @@ export class NileCodeEditor extends NileElement {
|
|
|
111
111
|
|
|
112
112
|
@property({ type: Boolean, reflect: true, attribute: true }) hideReadOnlyCursor: boolean = false;
|
|
113
113
|
|
|
114
|
+
/** Mounts the autocomplete/tooltip layer on `document.body` so ancestors that clip fixed content can't cut it off. */
|
|
115
|
+
@property({ type: Boolean, reflect: true, attribute: true }) portal: boolean = false;
|
|
116
|
+
|
|
114
117
|
public view: EditorView;
|
|
115
118
|
public viewState:EditorState;
|
|
116
119
|
private timeOut: any = null;
|
|
@@ -127,6 +130,9 @@ export class NileCodeEditor extends NileElement {
|
|
|
127
130
|
private autoCompletionComp = new Compartment();
|
|
128
131
|
private autoCompleteStyleComp = new Compartment();
|
|
129
132
|
private darkThemeComp = new Compartment();
|
|
133
|
+
private portalComp = new Compartment();
|
|
134
|
+
private portalSheet?: CSSStyleSheet;
|
|
135
|
+
private portalRuleSignature = '';
|
|
130
136
|
|
|
131
137
|
private isSpacePressed:boolean = false;
|
|
132
138
|
|
|
@@ -140,7 +146,10 @@ export class NileCodeEditor extends NileElement {
|
|
|
140
146
|
this.defaultSyntaxHighlightingComp.reconfigure(this.getDefaultSyntaxHighlightingExtension()),
|
|
141
147
|
]
|
|
142
148
|
});
|
|
149
|
+
this.syncPortalStyles();
|
|
143
150
|
};
|
|
151
|
+
|
|
152
|
+
private onAncestorScroll = () => { this.view?.requestMeasure(); };
|
|
144
153
|
/**
|
|
145
154
|
* The styles for CodeEditor
|
|
146
155
|
* @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`
|
|
@@ -163,6 +172,7 @@ export class NileCodeEditor extends NileElement {
|
|
|
163
172
|
this.resizeObserver?.disconnect();
|
|
164
173
|
this.themeObserver?.disconnect();
|
|
165
174
|
this.colorSchemeQuery?.removeEventListener('change', this.onThemeChange);
|
|
175
|
+
this.teardownPortal();
|
|
166
176
|
this.view.destroy()
|
|
167
177
|
this.emit('nile-destroy',undefined,false);
|
|
168
178
|
}
|
|
@@ -219,6 +229,7 @@ export class NileCodeEditor extends NileElement {
|
|
|
219
229
|
this.readOnlyComp.reconfigure(this.getReadOnlyExtension()),
|
|
220
230
|
]
|
|
221
231
|
})
|
|
232
|
+
this.syncPortalStyles();
|
|
222
233
|
}
|
|
223
234
|
if (changedProperties.has('disabled') && this.view) {
|
|
224
235
|
this.view.dispatch({
|
|
@@ -227,6 +238,10 @@ export class NileCodeEditor extends NileElement {
|
|
|
227
238
|
]
|
|
228
239
|
})
|
|
229
240
|
}
|
|
241
|
+
if (changedProperties.has('portal') && this.view) {
|
|
242
|
+
this.view.dispatch({ effects: [this.portalComp.reconfigure(this.getPortalExtension())] });
|
|
243
|
+
this.syncPortalStyles();
|
|
244
|
+
}
|
|
230
245
|
if (changedProperties.has('aboveCursor')) {
|
|
231
246
|
this.view.dispatch({
|
|
232
247
|
effects: [
|
|
@@ -272,6 +287,7 @@ export class NileCodeEditor extends NileElement {
|
|
|
272
287
|
this.themeComp.reconfigure(this.getCustomThemeExtension())
|
|
273
288
|
]
|
|
274
289
|
})
|
|
290
|
+
this.syncPortalStyles();
|
|
275
291
|
}
|
|
276
292
|
if(changedProperties.has('autoCompleteStyle') && this.view){
|
|
277
293
|
if (this.autoCompleteStyle?.width) {
|
|
@@ -294,6 +310,7 @@ export class NileCodeEditor extends NileElement {
|
|
|
294
310
|
this.autoCompleteStyleComp.reconfigure(this.getAutoCompleteStyleExtension())
|
|
295
311
|
]
|
|
296
312
|
})
|
|
313
|
+
this.syncPortalStyles();
|
|
297
314
|
}
|
|
298
315
|
}
|
|
299
316
|
|
|
@@ -342,6 +359,7 @@ export class NileCodeEditor extends NileElement {
|
|
|
342
359
|
state: this.viewState,
|
|
343
360
|
parent: this.codeEditor
|
|
344
361
|
});
|
|
362
|
+
this.syncPortalStyles();
|
|
345
363
|
|
|
346
364
|
this.view.dom.addEventListener('keydown', (e: KeyboardEvent) => {
|
|
347
365
|
this.checkForSpaceKey(e);
|
|
@@ -405,6 +423,7 @@ export class NileCodeEditor extends NileElement {
|
|
|
405
423
|
language,
|
|
406
424
|
// Before customThemeExtension so the tokenised autocomplete popup styles still win.
|
|
407
425
|
this.darkThemeComp.of(this.getDarkThemeExtension()),
|
|
426
|
+
this.portalComp.of(this.getPortalExtension()),
|
|
408
427
|
customThemeExtension,
|
|
409
428
|
autoCompleteStyleExtension,
|
|
410
429
|
this.getTabCompletionKeymap(),
|
|
@@ -743,6 +762,69 @@ export class NileCodeEditor extends NileElement {
|
|
|
743
762
|
return [];
|
|
744
763
|
}
|
|
745
764
|
|
|
765
|
+
/** Mounts the tooltip layer on document.body when `portal` is set. */
|
|
766
|
+
getPortalExtension(): Extension {
|
|
767
|
+
if (!this.portal) return [];
|
|
768
|
+
return [
|
|
769
|
+
tooltips({ parent: document.body, position: 'fixed' }),
|
|
770
|
+
EditorView.updateListener.of((u: ViewUpdate) => {
|
|
771
|
+
const was = completionStatus(u.startState);
|
|
772
|
+
const now = completionStatus(u.state);
|
|
773
|
+
this.syncPortalStyles(!!now && now !== was);
|
|
774
|
+
}),
|
|
775
|
+
];
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
/** Cheap fingerprint of the shadow root's style rules, used to skip re-copying when nothing changed. */
|
|
779
|
+
private shadowRuleSignature(): string {
|
|
780
|
+
const root = this.shadowRoot as any;
|
|
781
|
+
if (!root) return '';
|
|
782
|
+
const counts: number[] = [];
|
|
783
|
+
for (const sheet of root.adoptedStyleSheets || []) counts.push(sheet.cssRules.length);
|
|
784
|
+
root.querySelectorAll('style').forEach((el: HTMLStyleElement) => counts.push(el.sheet ? el.sheet.cssRules.length : -1));
|
|
785
|
+
return counts.join(',');
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
private syncPortalStyles(force = true) {
|
|
789
|
+
if (!this.portal) { this.teardownPortal(); return; }
|
|
790
|
+
const root = this.shadowRoot;
|
|
791
|
+
if (!root || typeof CSSStyleSheet === 'undefined') return;
|
|
792
|
+
const signature = this.shadowRuleSignature();
|
|
793
|
+
if (!force && this.portalSheet && this.portalRuleSignature === signature) return;
|
|
794
|
+
const isCm = (text: string) => /\.(cm-|\u037c)/.test(text) || /^@keyframes\s+cm-/.test(text);
|
|
795
|
+
const rules: string[] = [];
|
|
796
|
+
const collect = (list: CSSRuleList) => {
|
|
797
|
+
for (const r of Array.from(list)) if (isCm(r.cssText)) rules.push(r.cssText);
|
|
798
|
+
};
|
|
799
|
+
try {
|
|
800
|
+
for (const sheet of (root as any).adoptedStyleSheets || []) collect(sheet.cssRules);
|
|
801
|
+
root.querySelectorAll('style').forEach(el => el.sheet && collect(el.sheet.cssRules));
|
|
802
|
+
} catch { return; }
|
|
803
|
+
if (!this.portalSheet) {
|
|
804
|
+
this.portalSheet = new CSSStyleSheet();
|
|
805
|
+
document.adoptedStyleSheets = [...document.adoptedStyleSheets, this.portalSheet];
|
|
806
|
+
window.addEventListener('scroll', this.onAncestorScroll, true);
|
|
807
|
+
window.addEventListener('resize', this.onAncestorScroll);
|
|
808
|
+
}
|
|
809
|
+
this.portalRuleSignature = signature;
|
|
810
|
+
// Rebuilt from this editor's shadow root every time, never appended to what the sheet already held.
|
|
811
|
+
const css = rules.join('\n');
|
|
812
|
+
if ((this.portalSheet as any).__css !== css) {
|
|
813
|
+
this.portalSheet.replaceSync(css);
|
|
814
|
+
(this.portalSheet as any).__css = css;
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
private teardownPortal() {
|
|
819
|
+
window.removeEventListener('scroll', this.onAncestorScroll, true);
|
|
820
|
+
window.removeEventListener('resize', this.onAncestorScroll);
|
|
821
|
+
if (this.portalSheet) {
|
|
822
|
+
document.adoptedStyleSheets = document.adoptedStyleSheets.filter(s => s !== this.portalSheet);
|
|
823
|
+
this.portalSheet = undefined;
|
|
824
|
+
this.portalRuleSignature = '';
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
|
|
746
828
|
private updateAutocompleteWidth(width: number) {
|
|
747
829
|
if (this.view) {
|
|
748
830
|
this.view.dispatch({
|
|
@@ -370,6 +370,7 @@ export const styles = css`
|
|
|
370
370
|
overflow-y: auto;
|
|
371
371
|
flex: 0 1 auto;
|
|
372
372
|
min-height: 0;
|
|
373
|
+
max-height: 150px;
|
|
373
374
|
}
|
|
374
375
|
|
|
375
376
|
/* ── Options ── */
|
|
@@ -579,6 +580,7 @@ export const styles = css`
|
|
|
579
580
|
}
|
|
580
581
|
|
|
581
582
|
.combobox__listbox--bidirectional .combobox__options-scroll {
|
|
583
|
+
max-height: none; /* height is set from grid-rows on the listbox */
|
|
582
584
|
overflow: auto;
|
|
583
585
|
scrollbar-width: thin;
|
|
584
586
|
scrollbar-color: var(--nile-colors-neutral-500, var(--ng-colors-bg-quaternary)) transparent;
|