@aquera/nile-elements 2.0.26 → 2.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/README.md +7 -0
  2. package/dist/index.cjs.js +1 -1
  3. package/dist/index.esm.js +1 -1
  4. package/dist/index.js +441 -418
  5. package/dist/nile-calendar/nile-calendar.cjs.js +1 -1
  6. package/dist/nile-calendar/nile-calendar.cjs.js.map +1 -1
  7. package/dist/nile-calendar/nile-calendar.esm.js +1 -1
  8. package/dist/nile-code-editor/nile-code-editor.cjs.js +2 -2
  9. package/dist/nile-code-editor/nile-code-editor.cjs.js.map +1 -1
  10. package/dist/nile-code-editor/nile-code-editor.esm.js +5 -5
  11. package/dist/nile-combobox/nile-combobox.cjs.js +1 -1
  12. package/dist/nile-combobox/nile-combobox.cjs.js.map +1 -1
  13. package/dist/nile-combobox/nile-combobox.css.cjs.js +1 -1
  14. package/dist/nile-combobox/nile-combobox.css.cjs.js.map +1 -1
  15. package/dist/nile-combobox/nile-combobox.css.esm.js +2 -0
  16. package/dist/nile-combobox/nile-combobox.esm.js +1 -1
  17. package/dist/nile-detail/nile-detail.cjs.js +1 -1
  18. package/dist/nile-detail/nile-detail.cjs.js.map +1 -1
  19. package/dist/nile-detail/nile-detail.esm.js +6 -5
  20. package/dist/nile-select/index.cjs.js +1 -1
  21. package/dist/nile-select/index.esm.js +1 -1
  22. package/dist/nile-select/nile-select.cjs.js +1 -1
  23. package/dist/nile-select/nile-select.cjs.js.map +1 -1
  24. package/dist/nile-select/nile-select.esm.js +1 -1
  25. package/dist/nile-virtual-select/index.cjs.js +1 -1
  26. package/dist/nile-virtual-select/index.esm.js +1 -1
  27. package/dist/nile-virtual-select/nile-virtual-select.cjs.js +4 -4
  28. package/dist/nile-virtual-select/nile-virtual-select.cjs.js.map +1 -1
  29. package/dist/nile-virtual-select/nile-virtual-select.css.cjs.js +1 -1
  30. package/dist/nile-virtual-select/nile-virtual-select.css.cjs.js.map +1 -1
  31. package/dist/nile-virtual-select/nile-virtual-select.css.esm.js +19 -5
  32. package/dist/nile-virtual-select/nile-virtual-select.esm.js +5 -5
  33. package/dist/nile-virtual-select/renderer.cjs.js +1 -1
  34. package/dist/nile-virtual-select/renderer.cjs.js.map +1 -1
  35. package/dist/nile-virtual-select/renderer.esm.js +23 -22
  36. package/dist/src/nile-calendar/nile-calendar.d.ts +4 -0
  37. package/dist/src/nile-calendar/nile-calendar.js +18 -2
  38. package/dist/src/nile-calendar/nile-calendar.js.map +1 -1
  39. package/dist/src/nile-calendar/nile-calendar.test.js +50 -0
  40. package/dist/src/nile-calendar/nile-calendar.test.js.map +1 -1
  41. package/dist/src/nile-code-editor/nile-code-editor.d.ts +12 -0
  42. package/dist/src/nile-code-editor/nile-code-editor.js +92 -0
  43. package/dist/src/nile-code-editor/nile-code-editor.js.map +1 -1
  44. package/dist/src/nile-combobox/nile-combobox.css.js +2 -0
  45. package/dist/src/nile-combobox/nile-combobox.css.js.map +1 -1
  46. package/dist/src/nile-combobox/nile-combobox.d.ts +1 -0
  47. package/dist/src/nile-combobox/nile-combobox.js +12 -1
  48. package/dist/src/nile-combobox/nile-combobox.js.map +1 -1
  49. package/dist/src/nile-combobox/nile-combobox.test.js +375 -0
  50. package/dist/src/nile-combobox/nile-combobox.test.js.map +1 -1
  51. package/dist/src/nile-detail/nile-detail.d.ts +4 -0
  52. package/dist/src/nile-detail/nile-detail.js +35 -3
  53. package/dist/src/nile-detail/nile-detail.js.map +1 -1
  54. package/dist/src/nile-virtual-select/nile-virtual-select.css.js +19 -5
  55. package/dist/src/nile-virtual-select/nile-virtual-select.css.js.map +1 -1
  56. package/dist/src/nile-virtual-select/nile-virtual-select.d.ts +29 -0
  57. package/dist/src/nile-virtual-select/nile-virtual-select.js +120 -13
  58. package/dist/src/nile-virtual-select/nile-virtual-select.js.map +1 -1
  59. package/dist/src/nile-virtual-select/nile-virtual-select.test.js +187 -2
  60. package/dist/src/nile-virtual-select/nile-virtual-select.test.js.map +1 -1
  61. package/dist/src/nile-virtual-select/renderer.d.ts +1 -1
  62. package/dist/src/nile-virtual-select/renderer.js +11 -4
  63. package/dist/src/nile-virtual-select/renderer.js.map +1 -1
  64. package/dist/src/version.js +1 -1
  65. package/dist/src/version.js.map +1 -1
  66. package/dist/tsconfig.tsbuildinfo +1 -1
  67. package/package.json +1 -1
  68. package/src/nile-calendar/nile-calendar.test.ts +54 -0
  69. package/src/nile-calendar/nile-calendar.ts +17 -3
  70. package/src/nile-code-editor/nile-code-editor.ts +82 -0
  71. package/src/nile-combobox/nile-combobox.css.ts +2 -0
  72. package/src/nile-combobox/nile-combobox.test.ts +416 -0
  73. package/src/nile-combobox/nile-combobox.ts +11 -1
  74. package/src/nile-detail/nile-detail.ts +34 -3
  75. package/src/nile-virtual-select/nile-virtual-select.css.ts +19 -5
  76. package/src/nile-virtual-select/nile-virtual-select.test.ts +230 -2
  77. package/src/nile-virtual-select/nile-virtual-select.ts +117 -11
  78. package/src/nile-virtual-select/renderer.ts +12 -5
  79. package/vscode-html-custom-data.json +14 -4
@@ -769,12 +769,197 @@ describe('NileVirtualSelect external value while Selected is open', () => {
769
769
  expect(el.showSelected).to.be.false;
770
770
  expect(el.data.length).to.equal(200);
771
771
  });
772
- it('E4. showtooltip: a normal uncheck in the Selected view is not treated as external', async () => {
772
+ it('E4. showtooltip: a direct uncheck in the Selected view removes that item (GI-3101)', async () => {
773
773
  const el = await mount(true);
774
774
  await toggleSelected(el);
775
775
  await pick(el, 'option-2');
776
776
  expect(el.value).to.deep.equal(['option-1']);
777
- expect(values(el)).to.deep.equal(['option-1', 'option-2']);
777
+ expect(el.showSelected).to.be.true;
778
+ expect(values(el)).to.deep.equal(['option-1']);
779
+ });
780
+ describe('GI-3101: Show Selected stays in sync after a user unselect', () => {
781
+ it('F1. unselecting one of A,B,C leaves exactly A,C and Show Selected on', async () => {
782
+ const el = await mount(false, ['option-1', 'option-2', 'option-3']);
783
+ await toggleSelected(el);
784
+ expect(values(el)).to.deep.equal(['option-1', 'option-2', 'option-3']);
785
+ await pick(el, 'option-2');
786
+ expect(el.showSelected).to.be.true;
787
+ expect(values(el)).to.deep.equal(['option-1', 'option-3']);
788
+ });
789
+ it('F2. unselected options never reappear, even after the consumer reassigns data', async () => {
790
+ const el = await mount(false, ['option-1', 'option-2', 'option-3']);
791
+ await toggleSelected(el);
792
+ await pick(el, 'option-2');
793
+ el.data = [...OPTIONS]; // lookup refresh / paging hands back the full list
794
+ await el.updateComplete;
795
+ await aTimeout(30);
796
+ expect(el.showSelected).to.be.true;
797
+ expect(values(el)).to.deep.equal(['option-1', 'option-3']);
798
+ });
799
+ it('F3. removing several selected items one after another keeps working', async () => {
800
+ const el = await mount(false, ['option-1', 'option-2', 'option-3', 'option-4']);
801
+ await toggleSelected(el);
802
+ await pick(el, 'option-1');
803
+ expect(values(el)).to.deep.equal(['option-2', 'option-3', 'option-4']);
804
+ await pick(el, 'option-3');
805
+ expect(values(el)).to.deep.equal(['option-2', 'option-4']);
806
+ await pick(el, 'option-4');
807
+ expect(values(el)).to.deep.equal(['option-2']);
808
+ });
809
+ it('F4. rapid unselects without awaiting between them end in the right list', async () => {
810
+ const el = await mount(false, ['option-1', 'option-2', 'option-3', 'option-4']);
811
+ await toggleSelected(el);
812
+ el.handleOptionSelection({ value: 'option-1' });
813
+ el.handleOptionSelection({ value: 'option-2' });
814
+ await el.updateComplete;
815
+ await aTimeout(30);
816
+ expect(el.value).to.deep.equal(['option-3', 'option-4']);
817
+ expect(values(el)).to.deep.equal(['option-3', 'option-4']);
818
+ });
819
+ it('F5. unselecting the last item leaves the Selected view with the full list', async () => {
820
+ const el = await mount(false, ['option-1']);
821
+ await toggleSelected(el);
822
+ await pick(el, 'option-1');
823
+ expect(el.showSelected).to.be.false;
824
+ expect(el.data.length).to.equal(200);
825
+ });
826
+ it('F6. toggling Show Selected off after an unselect restores the full list', async () => {
827
+ const el = await mount(false, ['option-1', 'option-2', 'option-3']);
828
+ await toggleSelected(el);
829
+ await pick(el, 'option-2');
830
+ await toggleSelected(el);
831
+ expect(el.showSelected).to.be.false;
832
+ expect(el.data.length).to.equal(200);
833
+ });
834
+ it('F7. a selected item deep in the list survives an unselect of another', async () => {
835
+ const el = await mount(false, ['option-3', 'option-150', 'option-199']);
836
+ await toggleSelected(el);
837
+ await pick(el, 'option-3');
838
+ expect(values(el)).to.deep.equal(['option-150', 'option-199']);
839
+ });
840
+ it('F8. an unselect does not reset scroll or trigger a full repaint', async () => {
841
+ const el = await mount(false, ['option-1', 'option-2', 'option-3']);
842
+ await toggleSelected(el);
843
+ let resets = 0;
844
+ el.resetScrollPosition = async () => { resets++; };
845
+ el.repaintOptionsContainer = () => { resets++; };
846
+ await pick(el, 'option-2');
847
+ expect(resets).to.equal(0);
848
+ });
849
+ it('F9. a refresh that yields the same list does not reassign data', async () => {
850
+ const el = await mount(false, ['option-1', 'option-2', 'option-3']);
851
+ await toggleSelected(el);
852
+ const before = el.data;
853
+ el.refreshSelectedList();
854
+ el.refreshSelectedList();
855
+ expect(el.data).to.equal(before);
856
+ });
857
+ it('F10. no-scroll follows real overflow, not just the item count', async () => {
858
+ const el = await mount(false, ['option-1', 'option-2', 'option-3', 'option-4', 'option-5', 'option-6', 'option-7']);
859
+ await toggleSelected(el);
860
+ // The list element is recreated when it drops below the virtualizer threshold (5), so look it up fresh.
861
+ await pick(el, 'option-7');
862
+ await pick(el, 'option-6');
863
+ await pick(el, 'option-5'); // 4 left: now below the threshold
864
+ await aTimeout(50);
865
+ const virtualized = el.shadowRoot.querySelector('.virtualized');
866
+ if (!virtualized)
867
+ throw new Error('.virtualized not rendered');
868
+ const size = (scrollHeight, clientHeight) => {
869
+ Object.defineProperty(virtualized, 'scrollHeight', { configurable: true, get: () => scrollHeight });
870
+ Object.defineProperty(virtualized, 'clientHeight', { configurable: true, get: () => clientHeight });
871
+ };
872
+ size(400, 150); // tall rows in a short popup: overflows, so it must stay scrollable
873
+ await pick(el, 'option-4');
874
+ await aTimeout(50);
875
+ expect(el.data.length).to.equal(3);
876
+ expect(virtualized.classList.contains('no-scroll')).to.be.false;
877
+ size(150, 150); // the same rows now fit: the scrollbar can be hidden
878
+ await pick(el, 'option-3');
879
+ await aTimeout(50);
880
+ expect(el.data.length).to.equal(2);
881
+ expect(virtualized.classList.contains('no-scroll')).to.be.true;
882
+ });
883
+ it('F11. shrinking below the virtualizer threshold drops its leftover min-height', async () => {
884
+ const el = await mount(false, ['option-1', 'option-2', 'option-3']);
885
+ const virtualized = () => el.shadowRoot.querySelector('.virtualized');
886
+ // While the list is long the renderer sets min-height: 0 itself; the virtualizer only fills in its 150px default
887
+ // when none is set, so the list can shrink in a short popup (flex-basis keeps 150px as the preferred height).
888
+ expect(virtualized().style.minHeight).to.equal('0px');
889
+ await toggleSelected(el);
890
+ await aTimeout(50);
891
+ expect(el.data.length).to.equal(3);
892
+ expect(virtualized().style.minHeight).to.equal('');
893
+ });
894
+ // The virtualizer measures rows during the popup's open animation (scaled to 0.9) and then keeps them too close
895
+ // together, so they overlap and the gap disappears. Once open, the component nudges the list's width by 1px so the
896
+ // virtualizer re-measures. Row rects are faked here, since the real overlap depends on animation timing.
897
+ const forceRowRects = (el, pitch) => {
898
+ const rows = [...el.shadowRoot.querySelectorAll('.virtualized nile-option')];
899
+ rows.forEach((row, i) => {
900
+ row.getBoundingClientRect = () => ({ top: i * pitch, bottom: i * pitch + 42, height: 42, left: 0, right: 100, width: 100, x: 0, y: i * pitch, toJSON() { } });
901
+ });
902
+ };
903
+ const watchWidth = (el) => {
904
+ const virtualized = el.shadowRoot.querySelector('.virtualized');
905
+ const widths = [];
906
+ const observer = new MutationObserver(() => widths.push(virtualized.style.width));
907
+ observer.observe(virtualized, { attributes: true, attributeFilter: ['style'] });
908
+ return { widths, stop: () => observer.disconnect(), virtualized };
909
+ };
910
+ it('F12. rows that overlap after open make the list nudge its width once so the virtualizer re-measures', async () => {
911
+ const el = await mount(false, ['option-1', 'option-2', 'option-3']);
912
+ const before = el.shadowRoot.querySelector('.virtualized');
913
+ forceRowRects(el, 38); // 42px rows positioned 38px apart: overlapping
914
+ const watch = watchWidth(el);
915
+ await el.healOverlappingRows();
916
+ await aTimeout(0);
917
+ watch.stop();
918
+ expect(watch.widths).to.include('calc(100% - 1px)');
919
+ expect(watch.virtualized.style.width).to.equal(''); // restored
920
+ expect(el.shadowRoot.querySelector('.virtualized')).to.equal(before); // nothing re-created
921
+ });
922
+ it('F14. opening waits for the virtualizer to lay rows out, and never blocks forever', async () => {
923
+ const el = await mount(false, ['option-1', 'option-2', 'option-3']);
924
+ const rows = [...el.shadowRoot.querySelectorAll('.virtualized nile-option')];
925
+ let reads = 0;
926
+ // The virtualizer's estimate (rows 100px apart) for the first few reads, then the real 42px pitch.
927
+ const fake = (pitch) => (row, i) => {
928
+ row.getBoundingClientRect = () => {
929
+ reads += 1;
930
+ const p = reads <= 8 ? 100 : pitch;
931
+ return { top: i * p, bottom: i * p + 42, height: 42, left: 0, right: 100, width: 100, x: 0, y: i * p, toJSON() { } };
932
+ };
933
+ };
934
+ rows.forEach(fake(42));
935
+ await el.waitForRowLayout();
936
+ expect(reads).to.be.greaterThan(8); // it kept waiting while the estimate was in place
937
+ reads = -1e9; // always the estimate: must give up after the frame cap instead of hanging
938
+ const started = performance.now();
939
+ await el.waitForRowLayout(5);
940
+ expect(performance.now() - started).to.be.lessThan(1000);
941
+ });
942
+ it('F15. re-measuring the chips does not hide chips that all fitted (no blink when the dropdown opens)', async () => {
943
+ const el = await mount(false, ['option-1', 'option-2']);
944
+ const hidden = () => [...el.shadowRoot.querySelectorAll('nile-tag')].filter((tag) => tag.classList.contains('select__invisible')).length;
945
+ el.oldMaxOptionsVisible = 0; // the last fit showed every chip
946
+ el.setFittedMaxOptionsVisible(Infinity); // a re-measure starts
947
+ await el.updateComplete;
948
+ expect(hidden()).to.equal(0);
949
+ el.oldMaxOptionsVisible = 1; // the last fit clipped everything after the first chip
950
+ el.setFittedMaxOptionsVisible(Infinity);
951
+ await el.updateComplete;
952
+ expect(hidden()).to.equal(1); // unchanged behaviour: only the previously clipped chip is hidden while measuring
953
+ });
954
+ it('F13. correctly spaced rows are left alone', async () => {
955
+ const el = await mount(false, ['option-1', 'option-2', 'option-3']);
956
+ forceRowRects(el, 44); // 2px gap
957
+ const watch = watchWidth(el);
958
+ await el.healOverlappingRows();
959
+ await aTimeout(0);
960
+ watch.stop();
961
+ expect(watch.widths).to.deep.equal([]);
962
+ });
778
963
  });
779
964
  it('E5. without showtooltip an external value leaves the Selected list as it was (pre-2.0.9)', async () => {
780
965
  const el = await mount(false);