@sveltia/ui 0.26.3 → 0.26.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.
@@ -170,7 +170,8 @@ input:focus + .label {
170
170
  opacity: 0;
171
171
  }
172
172
 
173
- :is(input::placeholder, .label) {
173
+ input::placeholder,
174
+ .label {
174
175
  color: var(--sui-textbox-placeholder-foreground-color, var(--sui-textbox-foreground-color));
175
176
  opacity: var(--sui-textbox-placeholder-opacity, 0.5);
176
177
  font-family: var(--sui-textbox-placeholder-font-family, var(--sui-textbox-font-family));
@@ -36,15 +36,12 @@
36
36
  /* eslint-enable prefer-const */
37
37
  } = $props();
38
38
 
39
- let opening = false;
40
- let closing = false;
41
-
42
39
  /**
43
40
  * Close the modal.
44
41
  * @param {string} returnValue Return value to be used for `<dialog>`.
45
42
  */
46
43
  export const close = (returnValue) => {
47
- if (!dialog || !dialog.open || opening || closing) {
44
+ if (!dialog) {
48
45
  return;
49
46
  }
50
47
 
@@ -80,15 +77,10 @@
80
77
  * Show the modal.
81
78
  */
82
79
  const openDialog = async () => {
83
- if (!dialog || dialog?.open || opening || closing) {
84
- if (closing) {
85
- open = false;
86
- }
87
-
80
+ if (!dialog || dialog?.open) {
88
81
  return;
89
82
  }
90
83
 
91
- opening = true;
92
84
  onOpening?.(new CustomEvent('Opening'));
93
85
  showContent = true;
94
86
  dialog.showModal();
@@ -97,24 +89,18 @@
97
89
  setOpenClass = true;
98
90
  await waitForTransition();
99
91
  setActiveClass = true;
100
- opening = false;
101
92
  };
102
93
 
103
94
  /**
104
95
  * Hide the modal.
105
96
  */
106
97
  const closeDialog = async () => {
107
- if (!dialog || !dialog.open || opening || closing) {
108
- if (opening) {
109
- open = false;
110
- }
111
-
98
+ if (!dialog || !dialog.open) {
112
99
  return;
113
100
  }
114
101
 
115
102
  const { returnValue } = dialog;
116
103
 
117
- closing = true;
118
104
  onClosing?.(new CustomEvent('Closing'));
119
105
  // Prevent a button behind the `<dialog>` from being clicked erroneously (Svelte bug)
120
106
  document.body.inert = true;
@@ -135,7 +121,6 @@
135
121
 
136
122
  onClose?.(new CustomEvent('Close', { detail: { returnValue } }));
137
123
  dialog.returnValue = '';
138
- closing = false;
139
124
  };
140
125
 
141
126
  $effect(() => {
@@ -177,7 +162,8 @@
177
162
  lightDismiss &&
178
163
  /** @type {HTMLElement | undefined} */ (target)?.matches('dialog')
179
164
  ) {
180
- close('cancel');
165
+ dialog.returnValue = 'cancel';
166
+ open = false;
181
167
  }
182
168
  }}
183
169
  oncancel={(event) => {
@@ -185,7 +171,8 @@
185
171
 
186
172
  // Escape key is pressed
187
173
  if (dialog && escapeDismiss) {
188
- close('cancel');
174
+ dialog.returnValue = 'cancel';
175
+ open = false;
189
176
  }
190
177
  }}
191
178
  >
@@ -109,9 +109,9 @@ class Group {
109
109
 
110
110
  allMembers.forEach((element, index) => {
111
111
  // Select the first one if no member has the `selected` attribute
112
- const isSelected = defaultSelected
113
- ? element === defaultSelected
114
- : this.selectFirst && index === 0;
112
+ const isSelected =
113
+ element.getAttribute(this.childSelectedAttr) === 'true' ||
114
+ (defaultSelected ? element === defaultSelected : this.selectFirst && index === 0);
115
115
 
116
116
  const controlTarget = /** @type {HTMLElement | null} */ (
117
117
  document.querySelector(`#${element.getAttribute('aria-controls')}`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltia/ui",
3
- "version": "0.26.3",
3
+ "version": "0.26.5",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {
@@ -38,7 +38,7 @@
38
38
  "@lexical/selection": "^0.30.0",
39
39
  "@lexical/table": "^0.30.0",
40
40
  "@lexical/utils": "^0.30.0",
41
- "@sveltia/utils": "^0.7.1",
41
+ "@sveltia/utils": "^0.7.3",
42
42
  "lexical": "^0.30.0",
43
43
  "prismjs": "^1.30.0"
44
44
  },