@aquera/nile-elements 2.0.23 → 2.0.25

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 (43) hide show
  1. package/README.md +7 -0
  2. package/dist/index.js +349 -241
  3. package/dist/nile-pagination/nile-pagination.cjs.js +1 -1
  4. package/dist/nile-pagination/nile-pagination.cjs.js.map +1 -1
  5. package/dist/nile-pagination/nile-pagination.css.cjs.js +1 -1
  6. package/dist/nile-pagination/nile-pagination.css.cjs.js.map +1 -1
  7. package/dist/nile-pagination/nile-pagination.css.esm.js +63 -0
  8. package/dist/nile-pagination/nile-pagination.esm.js +4 -8
  9. package/dist/nile-side-bar-header/nile-side-bar-header.css.cjs.js +1 -1
  10. package/dist/nile-side-bar-header/nile-side-bar-header.css.cjs.js.map +1 -1
  11. package/dist/nile-side-bar-header/nile-side-bar-header.css.esm.js +2 -2
  12. package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.cjs.js +1 -1
  13. package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.cjs.js.map +1 -1
  14. package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.css.cjs.js +1 -1
  15. package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.css.cjs.js.map +1 -1
  16. package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.css.esm.js +49 -0
  17. package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.esm.js +1 -1
  18. package/dist/src/nile-pagination/nile-pagination.css.js +63 -0
  19. package/dist/src/nile-pagination/nile-pagination.css.js.map +1 -1
  20. package/dist/src/nile-pagination/nile-pagination.d.ts +10 -0
  21. package/dist/src/nile-pagination/nile-pagination.js +48 -10
  22. package/dist/src/nile-pagination/nile-pagination.js.map +1 -1
  23. package/dist/src/nile-pagination/nile-pagination.test.js +45 -0
  24. package/dist/src/nile-pagination/nile-pagination.test.js.map +1 -1
  25. package/dist/src/nile-side-bar-header/nile-side-bar-header.css.js +2 -2
  26. package/dist/src/nile-side-bar-header/nile-side-bar-header.css.js.map +1 -1
  27. package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.css.js +49 -0
  28. package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.css.js.map +1 -1
  29. package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.js +1 -1
  30. package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.js.map +1 -1
  31. package/dist/src/version.js +1 -1
  32. package/dist/src/version.js.map +1 -1
  33. package/dist/tsconfig.tsbuildinfo +1 -1
  34. package/docs/screenshots/wysiwyg-focus-state-focused.png +0 -0
  35. package/docs/screenshots/wysiwyg-focus-state-unfocused.png +0 -0
  36. package/package.json +1 -1
  37. package/src/nile-pagination/nile-pagination.css.ts +63 -0
  38. package/src/nile-pagination/nile-pagination.test.ts +51 -0
  39. package/src/nile-pagination/nile-pagination.ts +41 -8
  40. package/src/nile-side-bar-header/nile-side-bar-header.css.ts +2 -2
  41. package/src/nile-wysiwyg-editor/nile-wysiwyg-editor.css.ts +49 -0
  42. package/src/nile-wysiwyg-editor/nile-wysiwyg-editor.ts +1 -1
  43. package/vscode-html-custom-data.json +1 -1
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Webcomponent nile-elements following open-wc recommendations",
4
4
  "license": "MIT",
5
5
  "author": "nile-elements",
6
- "version": "2.0.23",
6
+ "version": "2.0.25",
7
7
  "main": "dist/src/index.js",
8
8
  "type": "module",
9
9
  "module": "dist/src/index.js",
@@ -398,6 +398,69 @@ export const styles = css`
398
398
  .next-button[disabled]::part(base) {
399
399
  border: 1px solid var(--nile-colors-neutral-400, var(--ng-colors-border-disabled));
400
400
  }
401
+
402
+ /* Responsive text for the fluid (default) variant: never wraps; texts shorten at the md tier
403
+ and truncate with an ellipsis when there still isn't room. The page list never shrinks. */
404
+ .page-size-label .label-short {
405
+ display: none;
406
+ }
407
+
408
+ .pagination-wrapper.fluid {
409
+ flex-wrap: nowrap;
410
+ gap: var(--nile-spacing-spacing-md, var(--ng-spacing-md));
411
+ }
412
+
413
+ .pagination-wrapper.fluid > nav {
414
+ flex-shrink: 0;
415
+ }
416
+
417
+ /* Grid so the texts can shrink to zero while the page-size dropdown always keeps its full
418
+ width; the container's minimum width is the dropdown, so nothing overlaps the page list. */
419
+ .pagination-wrapper.fluid .pager-container {
420
+ flex: 1 1 auto;
421
+ display: grid;
422
+ grid-template-columns: minmax(0, max-content) max-content minmax(0, max-content);
423
+ align-items: center;
424
+ gap: 0;
425
+ }
426
+
427
+ .pagination-wrapper.fluid .page-size-select {
428
+ display: contents;
429
+ }
430
+
431
+ .pagination-wrapper.fluid .range-text {
432
+ grid-column: 1;
433
+ margin-right: var(--nile-spacing-spacing-3xl, var(--ng-spacing-3xl));
434
+ }
435
+
436
+ .pagination-wrapper.fluid .page-size-dropdown {
437
+ grid-column: 2;
438
+ }
439
+
440
+ .pagination-wrapper.fluid .page-size-label {
441
+ grid-column: 3;
442
+ }
443
+
444
+ .pagination-wrapper.fluid .range-text,
445
+ .pagination-wrapper.fluid .page-size-label {
446
+ min-width: 0;
447
+ overflow: hidden;
448
+ white-space: nowrap;
449
+ text-overflow: ellipsis;
450
+ }
451
+
452
+ .pagination-wrapper.fluid.size-md .range-text {
453
+ margin-right: var(--nile-spacing-spacing-lg, var(--ng-spacing-lg));
454
+ }
455
+
456
+ .pagination-wrapper.fluid.size-md .range-prefix,
457
+ .pagination-wrapper.fluid.size-md .page-size-label .label-long {
458
+ display: none;
459
+ }
460
+
461
+ .pagination-wrapper.fluid.size-md .page-size-label .label-short {
462
+ display: inline;
463
+ }
401
464
  `;
402
465
 
403
466
  export default [styles];
@@ -1390,4 +1390,55 @@ describe('NilePagination', () => {
1390
1390
  expect(el.shadowRoot!.querySelector('.mini-prev-button')).to.exist;
1391
1391
  expect(el.shadowRoot!.querySelector('.mini-next-button')).to.exist;
1392
1392
  });
1393
+
1394
+ describe('responsive text (fluid variant)', () => {
1395
+ const frames = () => new Promise(r => requestAnimationFrame(() => requestAnimationFrame(r)));
1396
+
1397
+ async function renderAt(width: number) {
1398
+ const wrap = await fixture<HTMLDivElement>(html`
1399
+ <div style="width:${width}px"><nile-pagination totalitems="500" pagesize="50"></nile-pagination></div>
1400
+ `);
1401
+ const el = wrap.querySelector('nile-pagination') as NilePagination;
1402
+ await el.updateComplete;
1403
+ await frames();
1404
+ await el.updateComplete;
1405
+ const visible = (sel: string) => getComputedStyle(el.shadowRoot!.querySelector(sel)!).display !== 'none';
1406
+ return { el, visible };
1407
+ }
1408
+
1409
+ it('shows full texts when wide', async () => {
1410
+ const { el, visible } = await renderAt(1000);
1411
+ expect(el.shadowRoot!.querySelector('.pagination-wrapper')!.classList.contains('size-lg')).to.be.true;
1412
+ expect(visible('.range-prefix')).to.be.true;
1413
+ expect(visible('.label-long')).to.be.true;
1414
+ expect(visible('.label-short')).to.be.false;
1415
+ });
1416
+
1417
+ it('drops "Showing" and shortens the page-size label at medium width', async () => {
1418
+ const { el, visible } = await renderAt(650);
1419
+ expect(el.shadowRoot!.querySelector('.pagination-wrapper')!.classList.contains('size-md')).to.be.true;
1420
+ expect(visible('.range-prefix')).to.be.false;
1421
+ expect(visible('.label-long')).to.be.false;
1422
+ expect(visible('.label-short')).to.be.true;
1423
+ });
1424
+
1425
+ it('does not wrap and truncates texts with an ellipsis when very narrow', async () => {
1426
+ const { el } = await renderAt(220);
1427
+ const root = el.shadowRoot!;
1428
+ const wrapper = root.querySelector('.pagination-wrapper') as HTMLElement;
1429
+ expect(getComputedStyle(wrapper).flexWrap).to.equal('nowrap');
1430
+ const range = root.querySelector('.range-text') as HTMLElement;
1431
+ expect(getComputedStyle(range).textOverflow).to.equal('ellipsis');
1432
+ expect(getComputedStyle(root.querySelector('.page-size-label')!).textOverflow).to.equal('ellipsis');
1433
+ // everything stays on one row
1434
+ const navTop = root.querySelector('nav')!.getBoundingClientRect().top;
1435
+ expect(Math.abs(navTop - root.querySelector('.pager-container')!.getBoundingClientRect().top)).to.be.lessThan(16);
1436
+ expect(range.scrollWidth).to.be.greaterThan(range.clientWidth);
1437
+ });
1438
+
1439
+ it('keeps the full range text available as a tooltip', async () => {
1440
+ const { el } = await renderAt(400);
1441
+ expect(el.shadowRoot!.querySelector('.range-text')!.getAttribute('title')).to.equal('Showing 1–50 of 500');
1442
+ });
1443
+ });
1393
1444
  });
@@ -65,7 +65,42 @@ export class NilePagination extends NileElement {
65
65
  @state() private _pageSizeOpen = false;
66
66
  @state() private _pageOpen = false;
67
67
  @state() private _miniPageOpen = false;
68
+ /** Width tier of the fluid layout; drives how much of the label text is shown. */
69
+ @state() private _sizeTier: 'lg' | 'md' = 'lg';
68
70
  @query('.page-size-dropdown') private _pageSizeDropdown!: HTMLElement;
71
+ @query('.pagination-wrapper') private _wrapper?: HTMLElement;
72
+
73
+ private _resizeObserver?: ResizeObserver;
74
+ private _observedWrapper?: HTMLElement;
75
+
76
+ /** Below this width the "Showing" prefix is dropped and the page-size label shortens. */
77
+ private static readonly MD_BREAKPOINT = 768;
78
+
79
+ disconnectedCallback() {
80
+ super.disconnectedCallback();
81
+ this._resizeObserver?.disconnect();
82
+ this._observedWrapper = undefined;
83
+ }
84
+
85
+ updated() {
86
+ this._observeWrapper();
87
+ }
88
+
89
+ private _observeWrapper() {
90
+ if (typeof ResizeObserver === 'undefined') return;
91
+ const wrapper = this.variant === 'fluid' ? this._wrapper : undefined;
92
+ if (wrapper === this._observedWrapper) return;
93
+ this._resizeObserver ??= new ResizeObserver(entries => {
94
+ const width = entries[entries.length - 1]?.contentRect.width ?? 0;
95
+ if (width <= 0) return;
96
+ const tier = width < NilePagination.MD_BREAKPOINT ? 'md' : 'lg';
97
+ if (tier !== this._sizeTier) this._sizeTier = tier;
98
+ });
99
+ this._resizeObserver.disconnect();
100
+ this._observedWrapper = wrapper;
101
+ if (wrapper) this._resizeObserver.observe(wrapper);
102
+ else this._sizeTier = 'lg';
103
+ }
69
104
 
70
105
  firstUpdated() {
71
106
  if (this._pageSizeDropdown) {
@@ -112,13 +147,11 @@ private renderCompactRangeText(): TemplateResult {
112
147
 
113
148
  private renderRangeText(): TemplateResult {
114
149
  if (this.totalItems === 0) {
115
- return html`<div class="range-text">Showing 0 of 0</div>`;
150
+ return html`<div part="range-text" class="range-text"><span class="range-prefix">Showing </span>0 of 0</div>`;
116
151
  }
117
- return html`
118
- <div part="range-text" class="range-text">
119
- ${getRangeText(this.totalItems, this.pageSize, this.currentPage)}
120
- </div>
121
- `;
152
+ const full = getRangeText(this.totalItems, this.pageSize, this.currentPage);
153
+ const range = full.replace(/^Showing\s*/, '');
154
+ return html`<div part="range-text" class="range-text" title=${full}><span class="range-prefix">Showing </span>${range}</div>`;
122
155
  }
123
156
 
124
157
  /** Icon colour: text-primary's component utility token; unset when disabled so the button's disabled colour applies. */
@@ -160,7 +193,7 @@ private renderCompactRangeText(): TemplateResult {
160
193
  </div>
161
194
  </nile-menu>
162
195
  </nile-dropdown>
163
- <span part="pagesize-label" class="page-size-label">Items per page</span>
196
+ <span part="pagesize-label" class="page-size-label" title="Items per page"><span class="label-long">Items per page</span><span class="label-short">Per page</span></span>
164
197
  </div>
165
198
  `;
166
199
  }
@@ -434,7 +467,7 @@ private renderCompactRangeText(): TemplateResult {
434
467
  return this.renderMini();
435
468
  }
436
469
  return html`
437
- <div part="wrapper" class="pagination-wrapper ${this.variant}">
470
+ <div part="wrapper" class="pagination-wrapper ${this.variant} ${this.variant === 'fluid' ? `size-${this._sizeTier}` : ''}">
438
471
  <div part="pager-container" class="pager-container">
439
472
  ${this.variant === 'fluid' && this.showTitle
440
473
  ? this.renderRangeText()
@@ -15,8 +15,8 @@ export const styles = css`
15
15
  display: flex;
16
16
  align-items: center;
17
17
  justify-content: space-between;
18
- padding-top: var(--nile-spacing-xl, var(--ng-spacing-lg));
19
- padding-bottom: var(--nile-spacing-lg, var(--ng-spacing-xl));
18
+ padding-top: var(--nile-spacing-lg, var(--ng-spacing-lg));
19
+ padding-bottom: var(--nile-spacing-xl, var(--ng-spacing-xl));
20
20
  padding-left: var(--nile-spacing-xl, var(--ng-spacing-xl));
21
21
  padding-right: var(--nile-spacing-xl, var(--ng-spacing-xl));
22
22
  top: 0;
@@ -61,6 +61,55 @@ export const styles = css`
61
61
  box-sizing: border-box;
62
62
  }
63
63
 
64
+ /* --- Focused (active) state: only the writing area is highlighted, the
65
+ toolbar keeps the neutral frame (like CKEditor). The surface pulls itself
66
+ 1px over the frame/toolbar divider with negative margins, so its border
67
+ replaces those lines instead of doubling them, with no layout shift. --- */
68
+ .nile-wysiwyg__surface {
69
+ border: 1px solid transparent;
70
+ margin: -1px;
71
+ position: relative;
72
+ /* A themed surface background must not paint over the frame's border. */
73
+ background-clip: padding-box;
74
+ transition: border-color 0.15s ease;
75
+ }
76
+
77
+ /* The surface is the bottom of the frame unless the counter follows it
78
+ (the floating menus after it are absolutely positioned). */
79
+ .nile-wysiwyg__surface {
80
+ border-radius: 0 0 var(--nile-wysiwyg-radius, var(--nile-radius-radius-xl, 8px))
81
+ var(--nile-wysiwyg-radius, var(--nile-radius-radius-xl, 8px));
82
+ }
83
+
84
+ .nile-wysiwyg__surface:first-child {
85
+ border-radius: var(--nile-wysiwyg-radius, var(--nile-radius-radius-xl, 8px));
86
+ }
87
+
88
+ .nile-wysiwyg__surface:has(+ .nile-wysiwyg__counter) {
89
+ border-bottom-left-radius: 0;
90
+ border-bottom-right-radius: 0;
91
+ }
92
+
93
+ .nile-wysiwyg__surface:first-child:has(+ .nile-wysiwyg__counter) {
94
+ border-radius: var(--nile-wysiwyg-radius, var(--nile-radius-radius-xl, 8px))
95
+ var(--nile-wysiwyg-radius, var(--nile-radius-radius-xl, 8px)) 0 0;
96
+ }
97
+
98
+ :host(:not([disabled]):not([readonly]):not([fullscreen]))
99
+ .nile-wysiwyg--focused
100
+ .nile-wysiwyg__surface {
101
+ border-color: var(
102
+ --nile-wysiwyg-focus-border-color,
103
+ var(--nile-colors-primary-500, var(--ng-colors-border-brand))
104
+ );
105
+ }
106
+
107
+ @media (prefers-reduced-motion: reduce) {
108
+ .nile-wysiwyg__surface {
109
+ transition: none;
110
+ }
111
+ }
112
+
64
113
  /* --- Fullscreen (distraction-free) mode --- */
65
114
  :host([fullscreen]) {
66
115
  position: fixed;
@@ -2226,7 +2226,7 @@ export class NileWysiwygEditor extends NileElement {
2226
2226
  (this.toolbar !== 'none' || hasAuthoredToolbar) && !this.readonly;
2227
2227
  return html`
2228
2228
  <div
2229
- class="nile-wysiwyg ${this.showBlocks ? 'nile-wysiwyg--show-blocks' : ''}"
2229
+ class="nile-wysiwyg ${this.showBlocks ? 'nile-wysiwyg--show-blocks' : ''} ${this.hasFocus ? 'nile-wysiwyg--focused' : ''}"
2230
2230
  part="base"
2231
2231
  data-no-theme=${this.noThemeComponentsAttr() || nothing}
2232
2232
  @wysiwyg-command=${this.handleCommand}
@@ -5975,7 +5975,7 @@
5975
5975
  },
5976
5976
  {
5977
5977
  "name": "nile-pagination",
5978
- "description": "Attributes:\n\n * `totalitems` {`number`} - \n\n * `currentpage` {`number`} - \n\n * `pagesize` {`number`} - \n\n * `pagesizeoptions` {`number[]`} - \n\n * `variant` {`\"fluid\" | \"compact\" | \"mini\"`} - \n\n * `disabled` {`boolean`} - \n\n * `showTitle` {`boolean`} - \n\n * `portal` {`boolean`} - \n\nProperties:\n\n * `totalItems` {`number`} - \n\n * `currentPage` {`number`} - \n\n * `pageSize` {`number`} - \n\n * `pageSizeOptions` {`number[]`} - \n\n * `variant` {`\"fluid\" | \"compact\" | \"mini\"`} - \n\n * `disabled` {`boolean`} - \n\n * `showTitle` {`boolean`} - \n\n * `portal` {`boolean`} - \n\n * `_pageSizeOpen` {`boolean`} - \n\n * `_pageOpen` {`boolean`} - \n\n * `_miniPageOpen` {`boolean`} - \n\n * `_pageSizeDropdown` {`HTMLElement`} - \n\n * `totalPages` {`number`} - \n\n * `BUBBLES` {`boolean`} - \n\n * `COMPOSED` {`boolean`} - \n\n * `CANCELABLE` {`boolean`} - ",
5978
+ "description": "Attributes:\n\n * `totalitems` {`number`} - \n\n * `currentpage` {`number`} - \n\n * `pagesize` {`number`} - \n\n * `pagesizeoptions` {`number[]`} - \n\n * `variant` {`\"fluid\" | \"compact\" | \"mini\"`} - \n\n * `disabled` {`boolean`} - \n\n * `showTitle` {`boolean`} - \n\n * `portal` {`boolean`} - \n\nProperties:\n\n * `totalItems` {`number`} - \n\n * `currentPage` {`number`} - \n\n * `pageSize` {`number`} - \n\n * `pageSizeOptions` {`number[]`} - \n\n * `variant` {`\"fluid\" | \"compact\" | \"mini\"`} - \n\n * `disabled` {`boolean`} - \n\n * `showTitle` {`boolean`} - \n\n * `portal` {`boolean`} - \n\n * `_pageSizeOpen` {`boolean`} - \n\n * `_pageOpen` {`boolean`} - \n\n * `_miniPageOpen` {`boolean`} - \n\n * `_sizeTier` {`\"md\" | \"lg\"`} - Width tier of the fluid layout; drives how much of the label text is shown.\n\n * `_pageSizeDropdown` {`HTMLElement`} - \n\n * `_wrapper` {`HTMLElement | undefined`} - \n\n * `_resizeObserver` - \n\n * `_observedWrapper` {`HTMLElement | undefined`} - \n\n * `MD_BREAKPOINT` {`768`} - Below this width the \"Showing\" prefix is dropped and the page-size label shortens.\n\n * `totalPages` {`number`} - \n\n * `BUBBLES` {`boolean`} - \n\n * `COMPOSED` {`boolean`} - \n\n * `CANCELABLE` {`boolean`} - ",
5979
5979
  "attributes": [
5980
5980
  {
5981
5981
  "name": "totalitems",