@sveltia/ui 0.1.4 → 0.1.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.
@@ -81,7 +81,9 @@
81
81
  {...$$restProps}
82
82
  bind:this={comboboxElement}
83
83
  >
84
- {value !== undefined ? label || value : $_('sui.combobox.select_an_option')}
84
+ <div class="label">
85
+ {value !== undefined ? label || value : $_('sui.combobox.select_an_option')}
86
+ </div>
85
87
  </div>
86
88
  {:else}
87
89
  <TextInput
@@ -177,6 +179,13 @@
177
179
  opacity: 0.4;
178
180
  cursor: default;
179
181
  }
182
+ .combobox div[role=combobox] .label {
183
+ display: block;
184
+ overflow: hidden;
185
+ width: 100%;
186
+ white-space: nowrap;
187
+ text-overflow: ellipsis;
188
+ }
180
189
  .combobox :global(input) {
181
190
  padding: 0 32px 0 8px;
182
191
  width: 100%;
@@ -54,6 +54,7 @@
54
54
  }
55
55
  .select-button-group :global(button) {
56
56
  border-radius: 0;
57
+ color: var(--secondary-foreground-color);
57
58
  }
58
59
  .select-button-group :global(button):first-child {
59
60
  border-radius: 4px 0 0 4px;
@@ -33,10 +33,6 @@
33
33
  const id = getRandomId('checkbox');
34
34
  /** @type {Button} */
35
35
  let button;
36
-
37
- $: {
38
- dispatch('change', { checked });
39
- }
40
36
  </script>
41
37
 
42
38
  {#if name && value && checked && !indeterminate}
@@ -63,6 +59,7 @@
63
59
  event.stopPropagation();
64
60
  checked = indeterminate ? true : !checked;
65
61
  indeterminate = false;
62
+ dispatch('change', { checked });
66
63
  }}
67
64
  >
68
65
  <Icon slot="start-icon" name={indeterminate ? 'remove' : 'check'} />
@@ -20,13 +20,21 @@ class Popup {
20
20
  }
21
21
 
22
22
  const contentHeight = this.popupElement.querySelector('.content').scrollHeight;
23
+ const topMargin = intersectionRect.top - 8;
23
24
  const bottomMargin = rootBounds.height - intersectionRect.bottom - 8;
24
25
  let { position } = this;
26
+ let height;
25
27
 
28
+ // Alter the position if the space is limited
26
29
  // @todo Handle more overflow cases
27
- if (contentHeight > bottomMargin) {
28
- if (position.startsWith('bottom-')) {
29
- position = position.replace('bottom-', 'top-');
30
+ if (position.startsWith('bottom-')) {
31
+ if (contentHeight > bottomMargin) {
32
+ if (topMargin > bottomMargin) {
33
+ position = position.replace('bottom-', 'top-');
34
+ height = topMargin;
35
+ } else {
36
+ height = bottomMargin;
37
+ }
30
38
  }
31
39
  }
32
40
 
@@ -60,7 +68,7 @@ class Popup {
60
68
  inset: [top, right, bottom, left].join(' '),
61
69
  zIndex: anchorPopup ? Number(anchorPopup.style.zIndex) + 1 : 1000,
62
70
  width: `${Math.round(intersectionRect.width)}px`,
63
- height: `${Math.round(Math.max(bottomMargin, contentHeight))}px`,
71
+ height: height ? `${Math.round(height)}px` : 'auto',
64
72
  };
65
73
 
66
74
  if (JSON.stringify(style) !== JSON.stringify(get(this.style))) {
@@ -112,7 +112,7 @@
112
112
  --background-color-2-hsl: var(--hue) 5% 98%;
113
113
  --background-color-3-hsl: var(--hue) 5% 96%;
114
114
  --background-color-4-hsl: var(--hue) 5% 94%;
115
- --background-color-5-hsl: var(--hue) 5% 90%;
115
+ --background-color-5-hsl: var(--hue) 5% 80%;
116
116
  --shadow-color: var(--hue) 10% 0%;
117
117
  --primary-accent-color: hsl(var(--hue) 80% 45%);
118
118
  --primary-accent-color-lighter: hsl(var(--hue) 80% 40%);
@@ -28,6 +28,7 @@
28
28
 
29
29
  let showDialog = false;
30
30
  let showContent = false;
31
+ let contentType;
31
32
  let closeDialogTimer = 0;
32
33
 
33
34
  let style = writable({
@@ -40,6 +41,7 @@
40
41
  $: {
41
42
  if (anchor && dialog) {
42
43
  ({ open, style } = activatePopup(anchor, dialog, position));
44
+ contentType = anchor.getAttribute('aria-haspopup');
43
45
  }
44
46
  }
45
47
 
@@ -91,7 +93,7 @@
91
93
  <!-- svelte-ignore a11y-no-noninteractive-tabindex -->
92
94
  <div
93
95
  tabindex="0"
94
- class="content"
96
+ class="content {contentType}"
95
97
  style:inset={$style.inset}
96
98
  style:z-index={$style.zIndex}
97
99
  style:min-width={$style.width}
@@ -128,4 +130,16 @@
128
130
  box-shadow: 0 8px 16px var(--popup-shadow-color);
129
131
  will-change: opacity, transform;
130
132
  transition-property: opacity, transform;
133
+ }
134
+ .content.listbox, .content.menu {
135
+ border-width: 1px;
136
+ border-style: solid;
137
+ border-color: var(--secondary-border-color);
138
+ border-radius: 4px;
139
+ }
140
+ .content.listbox :global(.sui.listbox),
141
+ .content.listbox :global(.sui.menu), .content.menu :global(.sui.listbox),
142
+ .content.menu :global(.sui.menu) {
143
+ border-width: 0;
144
+ border-radius: 0;
131
145
  }</style>
@@ -80,7 +80,7 @@
80
80
  --background-color-2-hsl: var(--hue) 5% 98%; // primary
81
81
  --background-color-3-hsl: var(--hue) 5% 96%; // secondary/ternary
82
82
  --background-color-4-hsl: var(--hue) 5% 94%; // disabled
83
- --background-color-5-hsl: var(--hue) 5% 90%; // highlight
83
+ --background-color-5-hsl: var(--hue) 5% 80%; // highlight
84
84
  --shadow-color: var(--hue) 10% 0%;
85
85
  // Accents
86
86
  --primary-accent-color: hsl(var(--hue) 80% 45%);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltia/ui",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -29,12 +29,12 @@
29
29
  "devDependencies": {
30
30
  "@babel/core": "^7.21.4",
31
31
  "@babel/eslint-parser": "^7.21.3",
32
- "@playwright/test": "^1.32.1",
32
+ "@playwright/test": "^1.32.2",
33
33
  "@sveltejs/adapter-auto": "2.0.0",
34
- "@sveltejs/kit": "1.15.0",
34
+ "@sveltejs/kit": "1.15.2",
35
35
  "@sveltejs/package": "^2.0.2",
36
36
  "cspell": "^6.31.1",
37
- "eslint": "^8.37.0",
37
+ "eslint": "^8.38.0",
38
38
  "eslint-config-airbnb-base": "^15.0.0",
39
39
  "eslint-config-prettier": "^8.8.0",
40
40
  "eslint-plugin-import": "^2.27.5",
@@ -44,17 +44,17 @@
44
44
  "postcss-html": "^1.5.0",
45
45
  "prettier": "^2.8.7",
46
46
  "prettier-plugin-svelte": "^2.10.0",
47
- "sass": "^1.60.0",
47
+ "sass": "^1.61.0",
48
48
  "stylelint": "^15.4.0",
49
49
  "stylelint-config-recommended-scss": "^9.0.1",
50
50
  "stylelint-scss": "^4.6.0",
51
- "svelte-check": "^3.1.4",
51
+ "svelte-check": "^3.2.0",
52
52
  "svelte-i18n": "^3.6.0",
53
53
  "svelte-migrate": "^1.1.3",
54
54
  "svelte-preprocess": "^5.0.3",
55
55
  "tslib": "^2.5.0",
56
56
  "vite": "^4.2.1",
57
- "vitest": "^0.29.8"
57
+ "vitest": "^0.30.0"
58
58
  },
59
59
  "exports": {
60
60
  "./package.json": "./package.json",