@snowui-design-system/components 0.3.0-alpha.5 → 0.3.0-alpha.6

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.
@@ -111,19 +111,21 @@ export default function Frame($$anchor, $$props) {
111
111
  // === 6. 感知 (Perception) ===
112
112
  // 根据开关决定是否提供 Context
113
113
  // svelte-ignore state_referenced_locally
114
- const inheritedLoading = $.derived(() => parentSkeletonContext?.loading ?? false);
115
-
116
114
  const inheritedSkeleton = $.derived(() => parentSkeletonContext?.skeleton ?? true);
117
- const explicitLoading = $.derived(() => $.get(frameProps).loading === true);
115
+
118
116
  const explicitSkeleton = $.derived(() => $.get(frameProps).skeleton);
119
- const stateLoading = $.derived(() => frameState.currentState === "StartLoad" || frameState.currentState === "Load");
120
- const effectiveLoading = $.derived(() => $.get(inheritedLoading) || $.get(explicitLoading) || $.get(stateLoading));
117
+
118
+ function resolveEffectiveLoading() {
119
+ return (parentSkeletonContext?.loading ?? false) || $$props.loading === true || frameState.currentState === "StartLoad" || frameState.currentState === "Load";
120
+ }
121
+
122
+ const effectiveLoading = $.derived(resolveEffectiveLoading);
121
123
  const effectiveSkeleton = $.derived(() => $.get(explicitSkeleton) ?? $.get(inheritedSkeleton));
122
124
 
123
125
  // svelte-ignore state_referenced_locally
124
126
  if ($.get(enableContext)) {
125
127
  // svelte-ignore state_referenced_locally
126
- new FramePerception($.get(frameProps), frameState, layout, responsive, () => $.get(effectiveLoading), () => $.get(effectiveSkeleton));
128
+ new FramePerception($.get(frameProps), frameState, layout, responsive, resolveEffectiveLoading, () => $.get(effectiveSkeleton));
127
129
 
128
130
  // 提供尺寸上下文给子组件(如资源组件选择正确分辨率)
129
131
  // svelte-ignore state_referenced_locally
@@ -232,7 +234,7 @@ export default function Frame($$anchor, $$props) {
232
234
  const domRuntime = createFrameDomRuntime({
233
235
  getFrameProps: () => $.get(frameProps),
234
236
  frameState,
235
- getEffectiveLoading: () => $.get(effectiveLoading),
237
+ getEffectiveLoading: resolveEffectiveLoading,
236
238
  getHasScaleApplyConfig: () => $.get(hasScaleApplyConfig)
237
239
  });
238
240
 
@@ -154,6 +154,16 @@ export default function Select($$anchor, $$props) {
154
154
  // 通过 MenuItem 注册收集的选项
155
155
  let registeredOptions = $.state($.proxy([]));
156
156
 
157
+ // options 模式以调用方当前数据为准;MenuItem 的注册只发生在挂载时,
158
+ // 同一 value 的标签随语言或业务状态更新时不能继续使用旧注册快照。
159
+ const availableOptions = $.derived(() => $.get(children)
160
+ ? $.get(registeredOptions)
161
+ : $.get(options).map((option) => ({
162
+ value: option.value,
163
+ label: option.label,
164
+ disabled: option.disabled ?? false
165
+ })));
166
+
157
167
  // 搜索过滤状态
158
168
  let filterText = $.state("");
159
169
 
@@ -166,15 +176,15 @@ export default function Select($$anchor, $$props) {
166
176
  // 自定义项始终显示(不参与过滤,由 MenuItem 自身判断)
167
177
  // 匹配策略由 src/lib/search-filter.ts 的 matchesSearch 统一处理
168
178
  const filteredOptions = $.derived(() => {
169
- if (!$.get(filterText)) return $.get(registeredOptions);
179
+ if (!$.get(filterText)) return $.get(availableOptions);
170
180
 
171
- return $.get(registeredOptions).filter((o) => matchesSearch(o.label, $.get(filterText)));
181
+ return $.get(availableOptions).filter((o) => matchesSearch(o.label, $.get(filterText)));
172
182
  });
173
183
 
174
184
  // 派生显示值
175
185
  const hasValue = $.derived(() => $.get(resolvedValueStr) !== undefined && $.get(resolvedValueStr) !== "");
176
186
 
177
- const selectedOption = $.derived(() => $.get(registeredOptions).find((o) => o.value === $.get(resolvedValueStr)) ?? $.get(customOptions).find((o) => o.value === $.get(resolvedValueStr)));
187
+ const selectedOption = $.derived(() => $.get(availableOptions).find((o) => o.value === $.get(resolvedValueStr)) ?? $.get(customOptions).find((o) => o.value === $.get(resolvedValueStr)));
178
188
  const selectedLabel = $.derived(() => $.get(selectedOption)?.label ?? ($.get(hasValue) ? $.get(resolvedValueStr) : undefined));
179
189
  const isPlaceholderVisible = $.derived(() => !$.get(hasValue));
180
190
 
@@ -299,7 +309,7 @@ export default function Select($$anchor, $$props) {
299
309
  if (!trimmed) return;
300
310
 
301
311
  // 不与已有静态项或自定义项重复
302
- if ($.get(registeredOptions).some((o) => o.value === trimmed)) return;
312
+ if ($.get(availableOptions).some((o) => o.value === trimmed)) return;
303
313
 
304
314
  if ($.get(customOptions).some((o) => o.value === trimmed)) return;
305
315
 
@@ -334,7 +344,7 @@ export default function Select($$anchor, $$props) {
334
344
 
335
345
  // 打开 Listbox
336
346
  function openListbox() {
337
- const allOptions = [...$.get(registeredOptions), ...$.get(customOptions)];
347
+ const allOptions = [...$.get(availableOptions), ...$.get(customOptions)];
338
348
  const idx = allOptions.findIndex((o) => o.value === $.get(resolvedValueStr));
339
349
 
340
350
  $.set(activeIndex, idx >= 0 ? idx : 0, true);
@@ -1,9 +1,10 @@
1
1
  /**
2
2
  * frame-dom-runtime.svelte.ts
3
- * v1.0.0
3
+ * v1.0.1
4
4
  * 职责:统一拼装 Frame 根节点的 DOM props、事件包装器与运行时 data 属性。
5
5
  *
6
6
  * Log:
7
+ * - [2026-10-18] Fix: 事件包装器改读稳定源状态,避免同步卸载后读取已销毁派生状态,并保留同一事件中的实时禁用/加载语义。
7
8
  * - [2026-03-09] Init: 从 Frame.svelte 抽离 DOM 透传过滤、disabled/aria 补齐、readonly capture、原生事件包装与 data-* 运行时属性组装。
8
9
  */
9
10
  import type { FrameProps } from "./frame-types";
@@ -93,7 +93,7 @@ export function createFrameDomRuntime(options) {
93
93
 
94
94
  function wrap(handler, internal) {
95
95
  return (e) => {
96
- if ($.get(filteredProps).disabled || options.frameState.currentState === "Disabled" || options.getEffectiveLoading()) {
96
+ if (!!options.getFrameProps().disabled || options.frameState.currentState === "Disabled" || options.getEffectiveLoading()) {
97
97
  e.preventDefault();
98
98
  e.stopPropagation();
99
99
 
@@ -97,19 +97,21 @@ export default function Frame($$renderer, $$props) {
97
97
  // === 6. 感知 (Perception) ===
98
98
  // 根据开关决定是否提供 Context
99
99
  // svelte-ignore state_referenced_locally
100
- const inheritedLoading = $.derived(() => parentSkeletonContext?.loading ?? false);
101
-
102
100
  const inheritedSkeleton = $.derived(() => parentSkeletonContext?.skeleton ?? true);
103
- const explicitLoading = $.derived(() => frameProps().loading === true);
101
+
104
102
  const explicitSkeleton = $.derived(() => frameProps().skeleton);
105
- const stateLoading = $.derived(() => frameState.currentState === "StartLoad" || frameState.currentState === "Load");
106
- const effectiveLoading = $.derived(() => inheritedLoading() || explicitLoading() || stateLoading());
103
+
104
+ function resolveEffectiveLoading() {
105
+ return (parentSkeletonContext?.loading ?? false) || rawProps.loading === true || frameState.currentState === "StartLoad" || frameState.currentState === "Load";
106
+ }
107
+
108
+ const effectiveLoading = $.derived(resolveEffectiveLoading);
107
109
  const effectiveSkeleton = $.derived(() => explicitSkeleton() ?? inheritedSkeleton());
108
110
 
109
111
  // svelte-ignore state_referenced_locally
110
112
  if (enableContext()) {
111
113
  // svelte-ignore state_referenced_locally
112
- new FramePerception(frameProps(), frameState, layout, responsive, () => effectiveLoading(), () => effectiveSkeleton());
114
+ new FramePerception(frameProps(), frameState, layout, responsive, resolveEffectiveLoading, () => effectiveSkeleton());
113
115
 
114
116
  // 提供尺寸上下文给子组件(如资源组件选择正确分辨率)
115
117
  // svelte-ignore state_referenced_locally
@@ -192,7 +194,7 @@ export default function Frame($$renderer, $$props) {
192
194
  const domRuntime = createFrameDomRuntime({
193
195
  getFrameProps: () => frameProps(),
194
196
  frameState,
195
- getEffectiveLoading: () => effectiveLoading(),
197
+ getEffectiveLoading: resolveEffectiveLoading,
196
198
  getHasScaleApplyConfig: () => hasScaleApplyConfig()
197
199
  });
198
200
 
@@ -147,6 +147,16 @@ export default function Select($$renderer, $$props) {
147
147
  // 通过 MenuItem 注册收集的选项
148
148
  let registeredOptions = [];
149
149
 
150
+ // options 模式以调用方当前数据为准;MenuItem 的注册只发生在挂载时,
151
+ // 同一 value 的标签随语言或业务状态更新时不能继续使用旧注册快照。
152
+ const availableOptions = $.derived(() => children()
153
+ ? registeredOptions
154
+ : options().map((option) => ({
155
+ value: option.value,
156
+ label: option.label,
157
+ disabled: option.disabled ?? false
158
+ })));
159
+
150
160
  // 搜索过滤状态
151
161
  let filterText = "";
152
162
 
@@ -159,15 +169,15 @@ export default function Select($$renderer, $$props) {
159
169
  // 自定义项始终显示(不参与过滤,由 MenuItem 自身判断)
160
170
  // 匹配策略由 src/lib/search-filter.ts 的 matchesSearch 统一处理
161
171
  const filteredOptions = $.derived(() => {
162
- if (!filterText) return registeredOptions;
172
+ if (!filterText) return availableOptions();
163
173
 
164
- return registeredOptions.filter((o) => matchesSearch(o.label, filterText));
174
+ return availableOptions().filter((o) => matchesSearch(o.label, filterText));
165
175
  });
166
176
 
167
177
  // 派生显示值
168
178
  const hasValue = $.derived(() => resolvedValueStr() !== undefined && resolvedValueStr() !== "");
169
179
 
170
- const selectedOption = $.derived(() => registeredOptions.find((o) => o.value === resolvedValueStr()) ?? customOptions.find((o) => o.value === resolvedValueStr()));
180
+ const selectedOption = $.derived(() => availableOptions().find((o) => o.value === resolvedValueStr()) ?? customOptions.find((o) => o.value === resolvedValueStr()));
171
181
  const selectedLabel = $.derived(() => selectedOption()?.label ?? (hasValue() ? resolvedValueStr() : undefined));
172
182
  const isPlaceholderVisible = $.derived(() => !hasValue());
173
183
 
@@ -260,7 +270,7 @@ export default function Select($$renderer, $$props) {
260
270
  if (!trimmed) return;
261
271
 
262
272
  // 不与已有静态项或自定义项重复
263
- if (registeredOptions.some((o) => o.value === trimmed)) return;
273
+ if (availableOptions().some((o) => o.value === trimmed)) return;
264
274
 
265
275
  if (customOptions.some((o) => o.value === trimmed)) return;
266
276
 
@@ -285,7 +295,7 @@ export default function Select($$renderer, $$props) {
285
295
  // 关闭时清空搜索文本
286
296
  // 打开 Listbox
287
297
  function openListbox() {
288
- const allOptions = [...registeredOptions, ...customOptions];
298
+ const allOptions = [...availableOptions(), ...customOptions];
289
299
  const idx = allOptions.findIndex((o) => o.value === resolvedValueStr());
290
300
 
291
301
  activeIndex = idx >= 0 ? idx : 0;
@@ -1,9 +1,10 @@
1
1
  /**
2
2
  * frame-dom-runtime.svelte.ts
3
- * v1.0.0
3
+ * v1.0.1
4
4
  * 职责:统一拼装 Frame 根节点的 DOM props、事件包装器与运行时 data 属性。
5
5
  *
6
6
  * Log:
7
+ * - [2026-10-18] Fix: 事件包装器改读稳定源状态,避免同步卸载后读取已销毁派生状态,并保留同一事件中的实时禁用/加载语义。
7
8
  * - [2026-03-09] Init: 从 Frame.svelte 抽离 DOM 透传过滤、disabled/aria 补齐、readonly capture、原生事件包装与 data-* 运行时属性组装。
8
9
  */
9
10
  import type { FrameProps } from "./frame-types";
@@ -93,7 +93,7 @@ export function createFrameDomRuntime(options) {
93
93
 
94
94
  function wrap(handler, internal) {
95
95
  return (e) => {
96
- if (filteredProps().disabled || options.frameState.currentState === "Disabled" || options.getEffectiveLoading()) {
96
+ if (!!options.getFrameProps().disabled || options.frameState.currentState === "Disabled" || options.getEffectiveLoading()) {
97
97
  e.preventDefault();
98
98
  e.stopPropagation();
99
99
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "license": "SEE LICENSE IN LICENSE",
3
3
  "name": "@snowui-design-system/components",
4
- "version": "0.3.0-alpha.5",
4
+ "version": "0.3.0-alpha.6",
5
5
  "private": false,
6
6
  "type": "module",
7
7
  "exports": {