@sveltia/ui 0.15.3 → 0.15.5

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.
@@ -33,6 +33,7 @@
33
33
  {#if label}
34
34
  <div role="row" class="row-group-caption">
35
35
  <!-- We need `colspan` here but cannot place `<th>` under `<div>`, so use a hack -->
36
+ <!-- prettier-ignore -->
36
37
  <svelte:element this={'th'} role="rowheader" id="{id}-label" colspan="9999">
37
38
  {label}
38
39
  </svelte:element>
@@ -87,6 +87,7 @@
87
87
  */
88
88
  const onChange = () => {
89
89
  const selected = popupComponent?.content?.querySelector(selectedSelector);
90
+
90
91
  const target = /** @type {HTMLButtonElement} */ (
91
92
  popupComponent?.content?.querySelector(`[role="option"][value="${value}"]`)
92
93
  );
@@ -87,6 +87,7 @@
87
87
 
88
88
  const fromIndex = positionList.findLastIndex((s) => s <= diff);
89
89
  const toIndex = positionList.findIndex((s) => diff <= s);
90
+
90
91
  const index =
91
92
  Math.abs(positionList[fromIndex] - diff) < Math.abs(positionList[toIndex] - diff)
92
93
  ? fromIndex
@@ -33,6 +33,7 @@
33
33
  {#if label}
34
34
  <div role="row" class="row-group-caption">
35
35
  <!-- We need `colspan` here but cannot place `<th>` under `<div>`, so use a hack -->
36
+ <!-- prettier-ignore -->
36
37
  <svelte:element this={'th'} role="rowheader" id="{id}-label" colspan="9999">
37
38
  {label}
38
39
  </svelte:element>
@@ -141,10 +141,11 @@
141
141
  margin: var(--sui-vertical-tab-list-margin, var(--sui-tab-list-margin, 0 32px 0 0));
142
142
  border-width: var(--sui-vertical-tab-list-border-width, var(--sui-tab-list-border-width, 0 1px 0 0));
143
143
  padding: var(--sui-vertical-tab-list-padding, var(--sui-tab-list-padding, 8px 0));
144
- width: var(--sui-vertical-tab-list-width, 240px);
144
+ width: var(--sui-vertical-tab-list-width, auto);
145
145
  }
146
146
  .tab-list[aria-orientation=vertical] :global(button) {
147
147
  justify-content: var(--sui-vertical-tab-justify-content, flex-start);
148
+ padding-right: 32px;
148
149
  width: var(--sui-vertical-tab-width, var(--sui-tab-width, 100%));
149
150
  height: var(--sui-vertical-tab-height, var(--sui-tab-height, auto));
150
151
  }
@@ -490,6 +490,10 @@
490
490
  color: var(--sui-primary-accent-color-text);
491
491
  text-decoration: none;
492
492
  }
493
+ :global(:root[data-underline-links=true]) :global(a), :global(:host[data-underline-links=true]) :global(a) {
494
+ text-decoration: underline;
495
+ text-underline-offset: 2px;
496
+ }
493
497
 
494
498
  :global(p),
495
499
  :global(li) {
@@ -82,10 +82,17 @@
82
82
  height: undefined,
83
83
  });
84
84
 
85
+ /**
86
+ * Initialize the popup.
87
+ */
88
+ const init = () => {
89
+ ({ open, style } = activatePopup(anchor, modal.dialog, position, positionBaseElement));
90
+ contentType = anchor?.getAttribute('aria-haspopup') ?? undefined;
91
+ };
92
+
85
93
  $: {
86
94
  if (anchor && modal?.dialog) {
87
- ({ open, style } = activatePopup(anchor, modal.dialog, position, positionBaseElement));
88
- contentType = anchor.getAttribute('aria-haspopup') ?? undefined;
95
+ init();
89
96
  }
90
97
  }
91
98
 
@@ -106,6 +106,7 @@ class Group {
106
106
  const isSelected = defaultSelected
107
107
  ? element === defaultSelected
108
108
  : this.selectFirst && index === 0;
109
+
109
110
  const controlTarget = /** @type {HTMLElement | null} */ (
110
111
  document.querySelector(`#${element.getAttribute('aria-controls')}`)
111
112
  );
@@ -221,6 +222,7 @@ class Group {
221
222
  const targetRole = newTarget.getAttribute('role');
222
223
  const targetParent = newTarget.closest(this.parentGroupSelector);
223
224
  const selectByClick = event.type === 'click';
225
+
224
226
  const selectByKeydown =
225
227
  event.type === 'keydown' && /** @type {KeyboardEvent} */ (event).key === ' ';
226
228
 
@@ -336,6 +338,7 @@ class Group {
336
338
  onClick(event) {
337
339
  // eslint-disable-next-line prefer-destructuring
338
340
  const target = /** @type {HTMLElement} */ (event.target);
341
+
339
342
  const newTarget = target.matches(this.selector)
340
343
  ? target
341
344
  : /** @type {HTMLElement | null} */ (target.closest(this.selector));
@@ -362,6 +365,7 @@ class Group {
362
365
  // eslint-disable-next-line prefer-destructuring
363
366
  const target = /** @type {HTMLElement} */ (event.target);
364
367
  const { allMembers, activeMembers } = this;
368
+
365
369
  /** @type {HTMLElement | undefined} */
366
370
  const currentTarget = (() => {
367
371
  if (!this.focusChild) {
@@ -460,6 +464,7 @@ class Group {
460
464
  onUpdate({ searchTerms }) {
461
465
  const terms = searchTerms.trim().toLocaleLowerCase();
462
466
  const _terms = terms ? terms.split(/\s+/) : [];
467
+
463
468
  const matched = this.allMembers
464
469
  .map((member) => {
465
470
  const searchValue =
@@ -469,6 +474,7 @@ class Group {
469
474
  member.querySelector('.label')?.textContent ??
470
475
  member.textContent
471
476
  )?.toLocaleLowerCase() ?? '';
477
+
472
478
  const hidden = !_terms.every((term) => searchValue.includes(term));
473
479
 
474
480
  member.dispatchEvent(new CustomEvent('toggle', { detail: { hidden } }));
@@ -65,22 +65,27 @@ class Popup {
65
65
  : position.endsWith('-top')
66
66
  ? `${Math.round(intersectionRect.top)}px`
67
67
  : 'auto';
68
+
68
69
  const right = position.startsWith('left-')
69
70
  ? `${Math.round(rootBounds.width - intersectionRect.left)}px`
70
71
  : position.endsWith('-right')
71
72
  ? `${Math.round(rootBounds.width - intersectionRect.right)}px`
72
73
  : 'auto';
74
+
73
75
  const bottom = position.startsWith('top-')
74
76
  ? `${Math.round(rootBounds.height - intersectionRect.top)}px`
75
77
  : position.endsWith('-bottom')
76
78
  ? `${Math.round(rootBounds.height - intersectionRect.bottom)}px`
77
79
  : 'auto';
80
+
78
81
  const left = position.startsWith('right-')
79
82
  ? `${Math.round(intersectionRect.right)}px`
80
83
  : position.endsWith('-left')
81
84
  ? `${Math.round(intersectionRect.left)}px`
82
85
  : 'auto';
86
+
83
87
  const anchorPopup = /** @type {HTMLElement} */ (this.anchorElement.closest('.popup'));
88
+
84
89
  const style = {
85
90
  inset: [top, right, bottom, left].join(' '),
86
91
  zIndex: anchorPopup ? Number(anchorPopup.style.zIndex) + 1 : 1000,
@@ -95,6 +95,12 @@ strong {
95
95
  a {
96
96
  color: var(--sui-primary-accent-color-text);
97
97
  text-decoration: none;
98
+
99
+ :root[data-underline-links="true"] &,
100
+ :host[data-underline-links="true"] & {
101
+ text-decoration: underline;
102
+ text-underline-offset: 2px;
103
+ }
98
104
  }
99
105
 
100
106
  p,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltia/ui",
3
- "version": "0.15.3",
3
+ "version": "0.15.5",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -41,28 +41,28 @@
41
41
  "@sveltejs/adapter-auto": "^3.2.1",
42
42
  "@sveltejs/kit": "^2.5.10",
43
43
  "@sveltejs/package": "^2.3.1",
44
- "@sveltejs/vite-plugin-svelte": "^3.1.0",
44
+ "@sveltejs/vite-plugin-svelte": "^3.1.1",
45
45
  "cspell": "^8.8.3",
46
46
  "eslint": "^8.57.0",
47
47
  "eslint-config-airbnb-base": "^15.0.0",
48
48
  "eslint-config-prettier": "^9.1.0",
49
49
  "eslint-plugin-import": "^2.29.1",
50
- "eslint-plugin-jsdoc": "^48.2.6",
50
+ "eslint-plugin-jsdoc": "^48.2.7",
51
51
  "eslint-plugin-svelte": "^2.39.0",
52
52
  "npm-run-all": "^4.1.5",
53
53
  "postcss": "^8.4.38",
54
54
  "postcss-html": "^1.7.0",
55
- "prettier": "^3.2.5",
55
+ "prettier": "^3.3.0",
56
56
  "prettier-plugin-svelte": "^3.2.3",
57
- "sass": "^1.77.2",
58
- "stylelint": "^16.6.0",
57
+ "sass": "^1.77.4",
58
+ "stylelint": "^16.6.1",
59
59
  "stylelint-config-recommended-scss": "^14.0.0",
60
60
  "stylelint-scss": "^6.3.0",
61
- "svelte-check": "^3.7.1",
61
+ "svelte-check": "^3.8.0",
62
62
  "svelte-i18n": "^4.0.0",
63
63
  "svelte-preprocess": "^5.1.4",
64
64
  "tslib": "^2.6.2",
65
- "vite": "^5.2.11",
65
+ "vite": "^5.2.12",
66
66
  "vitest": "^1.6.0"
67
67
  },
68
68
  "exports": {