@selvajs/ui 4.12.0 → 4.12.1

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.
@@ -118,21 +118,28 @@
118
118
  $effect(() => {
119
119
  if (!isDynamicValueListWidget(item) || !dynamicListHasOptions) return;
120
120
  const validValues = new Set(Object.values(dynamicListOptions));
121
+ const firstOption = Object.values(dynamicListOptions)[0];
121
122
  // Route through onChange (not commit) — value is a one-way prop here, so writing it
122
123
  // directly from an effect trips Svelte's binding-ownership check.
124
+ // A NEVER-made selection (empty string/array, e.g. no default on a fresh page)
125
+ // gets the same first-option fallback as a stale one: an empty selection solves
126
+ // as an empty string, which cascades through the definition as null-data errors
127
+ // ("File not found: .dmf", Text→Number conversion failures, …) and the empty
128
+ // result then gets replayed by the solve caches.
123
129
  if (Array.isArray(value)) {
124
130
  const pruned = value.filter((v) => typeof v === 'string' && validValues.has(v));
125
- if (pruned.length !== value.length) {
126
- // Fall back to first option when checklist becomes fully empty after pruning
127
- onChange(
128
- item.paramId,
129
- pruned.length > 0 ? pruned : [Object.values(dynamicListOptions)[0]],
130
- true
131
- );
131
+ if (value.length === 0 || pruned.length !== value.length) {
132
+ // Fall back to first option when the checklist is empty (never selected
133
+ // or fully pruned).
134
+ onChange(item.paramId, pruned.length > 0 ? pruned : [firstOption], true);
132
135
  }
133
- } else if (typeof value === 'string' && value && !validValues.has(value)) {
134
- // Fall back to first available option instead of clearing to empty
135
- onChange(item.paramId, Object.values(dynamicListOptions)[0], true);
136
+ } else if (
137
+ value == null ||
138
+ value === '' ||
139
+ (typeof value === 'string' && !validValues.has(value))
140
+ ) {
141
+ // Stale or never-selected single value — fall back to the first option.
142
+ onChange(item.paramId, firstOption, true);
136
143
  }
137
144
  });
138
145
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@selvajs/ui",
3
- "version": "4.12.0",
3
+ "version": "4.12.1",
4
4
  "description": "Shared UI components and utilities for Selva applications",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -37,7 +37,7 @@
37
37
  "**/*.css"
38
38
  ],
39
39
  "peerDependencies": {
40
- "@selvajs/compute": "^3.0.0-beta.1",
40
+ "@selvajs/compute": "^3.0.1",
41
41
  "@sveltejs/kit": "^2",
42
42
  "bits-ui": "^2.18.0",
43
43
  "svelte": "^5",
@@ -118,21 +118,28 @@
118
118
  $effect(() => {
119
119
  if (!isDynamicValueListWidget(item) || !dynamicListHasOptions) return;
120
120
  const validValues = new Set(Object.values(dynamicListOptions));
121
+ const firstOption = Object.values(dynamicListOptions)[0];
121
122
  // Route through onChange (not commit) — value is a one-way prop here, so writing it
122
123
  // directly from an effect trips Svelte's binding-ownership check.
124
+ // A NEVER-made selection (empty string/array, e.g. no default on a fresh page)
125
+ // gets the same first-option fallback as a stale one: an empty selection solves
126
+ // as an empty string, which cascades through the definition as null-data errors
127
+ // ("File not found: .dmf", Text→Number conversion failures, …) and the empty
128
+ // result then gets replayed by the solve caches.
123
129
  if (Array.isArray(value)) {
124
130
  const pruned = value.filter((v) => typeof v === 'string' && validValues.has(v));
125
- if (pruned.length !== value.length) {
126
- // Fall back to first option when checklist becomes fully empty after pruning
127
- onChange(
128
- item.paramId,
129
- pruned.length > 0 ? pruned : [Object.values(dynamicListOptions)[0]],
130
- true
131
- );
131
+ if (value.length === 0 || pruned.length !== value.length) {
132
+ // Fall back to first option when the checklist is empty (never selected
133
+ // or fully pruned).
134
+ onChange(item.paramId, pruned.length > 0 ? pruned : [firstOption], true);
132
135
  }
133
- } else if (typeof value === 'string' && value && !validValues.has(value)) {
134
- // Fall back to first available option instead of clearing to empty
135
- onChange(item.paramId, Object.values(dynamicListOptions)[0], true);
136
+ } else if (
137
+ value == null ||
138
+ value === '' ||
139
+ (typeof value === 'string' && !validValues.has(value))
140
+ ) {
141
+ // Stale or never-selected single value — fall back to the first option.
142
+ onChange(item.paramId, firstOption, true);
136
143
  }
137
144
  });
138
145