@selvajs/ui 4.11.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.
- package/dist/components/compute/AppLayout.svelte +6 -1
- package/dist/components/compute/AppLayout.svelte.d.ts +2 -0
- package/dist/components/compute/ComputeApp.svelte +5 -1
- package/dist/components/compute/ComputeApp.svelte.d.ts +2 -0
- package/dist/components/preview/InputControl.svelte +17 -10
- package/dist/components/viewer/Viewer.svelte +24 -0
- package/dist/components/viewer/Viewer.svelte.d.ts +5 -0
- package/dist/constants.js +7 -2
- package/package.json +5 -5
- package/src/lib/components/compute/AppLayout.svelte +6 -1
- package/src/lib/components/compute/ComputeApp.svelte +5 -1
- package/src/lib/components/preview/InputControl.svelte +17 -10
- package/src/lib/components/viewer/Viewer.svelte +24 -0
- package/src/lib/constants.ts +7 -2
|
@@ -37,6 +37,8 @@
|
|
|
37
37
|
onListStates?: () => ParameterPreset[] | Promise<ParameterPreset[]>;
|
|
38
38
|
presetLabels?: Partial<PresetLabels>;
|
|
39
39
|
viewerConfig?: ViewerConfig;
|
|
40
|
+
/** Branding logo URL shown as a watermark in the viewer's bottom-right corner. */
|
|
41
|
+
logoUrl?: string;
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
let {
|
|
@@ -57,7 +59,8 @@
|
|
|
57
59
|
onSaveState,
|
|
58
60
|
onListStates,
|
|
59
61
|
presetLabels,
|
|
60
|
-
viewerConfig = {}
|
|
62
|
+
viewerConfig = {},
|
|
63
|
+
logoUrl
|
|
61
64
|
}: Props = $props();
|
|
62
65
|
|
|
63
66
|
const hasViewer = $derived(
|
|
@@ -185,6 +188,7 @@
|
|
|
185
188
|
{isSolving}
|
|
186
189
|
isBlurred={drawerOpen}
|
|
187
190
|
{drawerOpen}
|
|
191
|
+
{logoUrl}
|
|
188
192
|
viewerConfig={{
|
|
189
193
|
...viewerConfig,
|
|
190
194
|
backgroundColor: schema?.viewerOptions?.backgroundColor,
|
|
@@ -347,6 +351,7 @@
|
|
|
347
351
|
{meshes}
|
|
348
352
|
bind:isFullscreen={isViewerFullscreen}
|
|
349
353
|
{isSolving}
|
|
354
|
+
{logoUrl}
|
|
350
355
|
viewerConfig={{
|
|
351
356
|
backgroundColor: schema?.viewerOptions?.backgroundColor
|
|
352
357
|
}}
|
|
@@ -21,6 +21,8 @@ interface Props {
|
|
|
21
21
|
onListStates?: () => ParameterPreset[] | Promise<ParameterPreset[]>;
|
|
22
22
|
presetLabels?: Partial<PresetLabels>;
|
|
23
23
|
viewerConfig?: ViewerConfig;
|
|
24
|
+
/** Branding logo URL shown as a watermark in the viewer's bottom-right corner. */
|
|
25
|
+
logoUrl?: string;
|
|
24
26
|
}
|
|
25
27
|
declare const AppLayout: import("svelte").Component<Props, {}, "isViewerFullscreen">;
|
|
26
28
|
type AppLayout = ReturnType<typeof AppLayout>;
|
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
onSolve: SolveFn;
|
|
27
27
|
definitionKey?: string;
|
|
28
28
|
title?: string;
|
|
29
|
+
/** Branding logo URL shown as a watermark in the viewer's bottom-right corner. Hidden when unset. */
|
|
30
|
+
logo?: string;
|
|
29
31
|
isEmbedded?: boolean;
|
|
30
32
|
primaryColor?: string;
|
|
31
33
|
showModeToggle?: boolean;
|
|
@@ -70,6 +72,7 @@
|
|
|
70
72
|
onSolve,
|
|
71
73
|
definitionKey = '',
|
|
72
74
|
title,
|
|
75
|
+
logo,
|
|
73
76
|
isEmbedded,
|
|
74
77
|
primaryColor,
|
|
75
78
|
showModeToggle = false,
|
|
@@ -150,7 +153,7 @@
|
|
|
150
153
|
});
|
|
151
154
|
});
|
|
152
155
|
|
|
153
|
-
function handleValueChange(id: string, val: unknown, forceSolve
|
|
156
|
+
function handleValueChange(id: string, val: unknown, forceSolve = false) {
|
|
154
157
|
session.setValue(id, val, forceSolve);
|
|
155
158
|
}
|
|
156
159
|
|
|
@@ -212,6 +215,7 @@
|
|
|
212
215
|
hasNeverSolved={session.hasNeverSolved}
|
|
213
216
|
bind:isViewerFullscreen
|
|
214
217
|
values={session.values}
|
|
218
|
+
logoUrl={logo}
|
|
215
219
|
{panelActions}
|
|
216
220
|
{showSaveButton}
|
|
217
221
|
{showLoadButton}
|
|
@@ -10,6 +10,8 @@ interface Props {
|
|
|
10
10
|
onSolve: SolveFn;
|
|
11
11
|
definitionKey?: string;
|
|
12
12
|
title?: string;
|
|
13
|
+
/** Branding logo URL shown as a watermark in the viewer's bottom-right corner. Hidden when unset. */
|
|
14
|
+
logo?: string;
|
|
13
15
|
isEmbedded?: boolean;
|
|
14
16
|
primaryColor?: string;
|
|
15
17
|
showModeToggle?: boolean;
|
|
@@ -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
|
|
127
|
-
|
|
128
|
-
|
|
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 (
|
|
134
|
-
|
|
135
|
-
|
|
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
|
|
|
@@ -52,6 +52,11 @@
|
|
|
52
52
|
isBlurred?: boolean;
|
|
53
53
|
drawerOpen?: boolean;
|
|
54
54
|
viewerConfig?: ViewerConfig;
|
|
55
|
+
/**
|
|
56
|
+
* Branding logo URL. When set, shown as a small watermark in the viewer's
|
|
57
|
+
* bottom-right corner. Omitted/empty renders nothing.
|
|
58
|
+
*/
|
|
59
|
+
logoUrl?: string;
|
|
55
60
|
/**
|
|
56
61
|
* UI language for the viewer's own chrome (tools menu, panels, dialogs).
|
|
57
62
|
* When set, the viewer provides it to its subtree. When omitted, the viewer
|
|
@@ -78,6 +83,7 @@
|
|
|
78
83
|
isBlurred = false,
|
|
79
84
|
drawerOpen = false,
|
|
80
85
|
viewerConfig = {},
|
|
86
|
+
logoUrl,
|
|
81
87
|
lang
|
|
82
88
|
}: Props = $props();
|
|
83
89
|
|
|
@@ -272,6 +278,24 @@
|
|
|
272
278
|
></div>
|
|
273
279
|
{/if}
|
|
274
280
|
|
|
281
|
+
{#if logoUrl}
|
|
282
|
+
<!-- Branding watermark, bottom-right. Matches the tools menu's
|
|
283
|
+
bottom offset so it clears the mobile drawer handle, and is
|
|
284
|
+
non-interactive so it never intercepts canvas drags. -->
|
|
285
|
+
<div
|
|
286
|
+
class="right-4 {isFullscreen ? 'bottom-4' : 'bottom-16 sm:bottom-4'} absolute z-20"
|
|
287
|
+
style={hideButton
|
|
288
|
+
? 'opacity: 0; pointer-events: none;'
|
|
289
|
+
: 'opacity: 1; pointer-events: none;'}
|
|
290
|
+
>
|
|
291
|
+
<img
|
|
292
|
+
src={logoUrl}
|
|
293
|
+
alt=""
|
|
294
|
+
class="h-8 max-w-32 drop-shadow-sm sm:h-10 w-auto object-contain opacity-80"
|
|
295
|
+
/>
|
|
296
|
+
</div>
|
|
297
|
+
{/if}
|
|
298
|
+
|
|
275
299
|
{#if config.showToolsMenu}
|
|
276
300
|
{@const itemClass =
|
|
277
301
|
'gap-2 px-2 py-1.5 text-sm flex cursor-pointer select-none items-center rounded-sm outline-none transition-colors hover:bg-muted focus:bg-muted'}
|
|
@@ -16,6 +16,11 @@ interface Props {
|
|
|
16
16
|
isBlurred?: boolean;
|
|
17
17
|
drawerOpen?: boolean;
|
|
18
18
|
viewerConfig?: ViewerConfig;
|
|
19
|
+
/**
|
|
20
|
+
* Branding logo URL. When set, shown as a small watermark in the viewer's
|
|
21
|
+
* bottom-right corner. Omitted/empty renders nothing.
|
|
22
|
+
*/
|
|
23
|
+
logoUrl?: string;
|
|
19
24
|
/**
|
|
20
25
|
* UI language for the viewer's own chrome (tools menu, panels, dialogs).
|
|
21
26
|
* When set, the viewer provides it to its subtree. When omitted, the viewer
|
package/dist/constants.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
export const APP_DEFAULTS = {
|
|
2
2
|
// File upload limits
|
|
3
|
+
// TEMP (dev): raised 150 MB → 300 MB so large dev file-widget inputs aren't
|
|
4
|
+
// blocked client-side. The server request cap (COMPUTE_REQUEST_MAX_BYTES) was
|
|
5
|
+
// bumped to 300 MB to match, but base64 inflates a raw file by ~4/3, so a
|
|
6
|
+
// full 300 MB upload still won't fit the 300 MB request body. Revert to 150
|
|
7
|
+
// before release.
|
|
3
8
|
FILE_UPLOAD: {
|
|
4
|
-
MAX_SIZE_MB:
|
|
5
|
-
MAX_SIZE_BYTES:
|
|
9
|
+
MAX_SIZE_MB: 300,
|
|
10
|
+
MAX_SIZE_BYTES: 300 * 1024 * 1024
|
|
6
11
|
},
|
|
7
12
|
// Timing & performance thresholds
|
|
8
13
|
TIMEOUTS: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@selvajs/ui",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.12.1",
|
|
4
4
|
"description": "Shared UI components and utilities for Selva applications",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
"**/*.css"
|
|
38
38
|
],
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@selvajs/compute": "^
|
|
40
|
+
"@selvajs/compute": "^3.0.1",
|
|
41
41
|
"@sveltejs/kit": "^2",
|
|
42
42
|
"bits-ui": "^2.18.0",
|
|
43
43
|
"svelte": "^5",
|
|
44
44
|
"tailwind-variants": "^3.2.2",
|
|
45
45
|
"three": "^0.184.0",
|
|
46
|
-
"@selvajs/schemas": "^4.6.
|
|
46
|
+
"@selvajs/schemas": "^4.6.1"
|
|
47
47
|
},
|
|
48
48
|
"peerDependenciesMeta": {
|
|
49
49
|
"three": {
|
|
@@ -72,8 +72,8 @@
|
|
|
72
72
|
"svelte": "5.55.5",
|
|
73
73
|
"tailwind-variants": "^3.2.2",
|
|
74
74
|
"vitest": "^3.2.6",
|
|
75
|
-
"@selvajs/
|
|
76
|
-
"@selvajs/
|
|
75
|
+
"@selvajs/schemas": "4.6.1",
|
|
76
|
+
"@selvajs/config": "0.0.2"
|
|
77
77
|
},
|
|
78
78
|
"scripts": {
|
|
79
79
|
"dev": "vite dev",
|
|
@@ -37,6 +37,8 @@
|
|
|
37
37
|
onListStates?: () => ParameterPreset[] | Promise<ParameterPreset[]>;
|
|
38
38
|
presetLabels?: Partial<PresetLabels>;
|
|
39
39
|
viewerConfig?: ViewerConfig;
|
|
40
|
+
/** Branding logo URL shown as a watermark in the viewer's bottom-right corner. */
|
|
41
|
+
logoUrl?: string;
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
let {
|
|
@@ -57,7 +59,8 @@
|
|
|
57
59
|
onSaveState,
|
|
58
60
|
onListStates,
|
|
59
61
|
presetLabels,
|
|
60
|
-
viewerConfig = {}
|
|
62
|
+
viewerConfig = {},
|
|
63
|
+
logoUrl
|
|
61
64
|
}: Props = $props();
|
|
62
65
|
|
|
63
66
|
const hasViewer = $derived(
|
|
@@ -185,6 +188,7 @@
|
|
|
185
188
|
{isSolving}
|
|
186
189
|
isBlurred={drawerOpen}
|
|
187
190
|
{drawerOpen}
|
|
191
|
+
{logoUrl}
|
|
188
192
|
viewerConfig={{
|
|
189
193
|
...viewerConfig,
|
|
190
194
|
backgroundColor: schema?.viewerOptions?.backgroundColor,
|
|
@@ -347,6 +351,7 @@
|
|
|
347
351
|
{meshes}
|
|
348
352
|
bind:isFullscreen={isViewerFullscreen}
|
|
349
353
|
{isSolving}
|
|
354
|
+
{logoUrl}
|
|
350
355
|
viewerConfig={{
|
|
351
356
|
backgroundColor: schema?.viewerOptions?.backgroundColor
|
|
352
357
|
}}
|
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
onSolve: SolveFn;
|
|
27
27
|
definitionKey?: string;
|
|
28
28
|
title?: string;
|
|
29
|
+
/** Branding logo URL shown as a watermark in the viewer's bottom-right corner. Hidden when unset. */
|
|
30
|
+
logo?: string;
|
|
29
31
|
isEmbedded?: boolean;
|
|
30
32
|
primaryColor?: string;
|
|
31
33
|
showModeToggle?: boolean;
|
|
@@ -70,6 +72,7 @@
|
|
|
70
72
|
onSolve,
|
|
71
73
|
definitionKey = '',
|
|
72
74
|
title,
|
|
75
|
+
logo,
|
|
73
76
|
isEmbedded,
|
|
74
77
|
primaryColor,
|
|
75
78
|
showModeToggle = false,
|
|
@@ -150,7 +153,7 @@
|
|
|
150
153
|
});
|
|
151
154
|
});
|
|
152
155
|
|
|
153
|
-
function handleValueChange(id: string, val: unknown, forceSolve
|
|
156
|
+
function handleValueChange(id: string, val: unknown, forceSolve = false) {
|
|
154
157
|
session.setValue(id, val, forceSolve);
|
|
155
158
|
}
|
|
156
159
|
|
|
@@ -212,6 +215,7 @@
|
|
|
212
215
|
hasNeverSolved={session.hasNeverSolved}
|
|
213
216
|
bind:isViewerFullscreen
|
|
214
217
|
values={session.values}
|
|
218
|
+
logoUrl={logo}
|
|
215
219
|
{panelActions}
|
|
216
220
|
{showSaveButton}
|
|
217
221
|
{showLoadButton}
|
|
@@ -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
|
|
127
|
-
|
|
128
|
-
|
|
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 (
|
|
134
|
-
|
|
135
|
-
|
|
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
|
|
|
@@ -52,6 +52,11 @@
|
|
|
52
52
|
isBlurred?: boolean;
|
|
53
53
|
drawerOpen?: boolean;
|
|
54
54
|
viewerConfig?: ViewerConfig;
|
|
55
|
+
/**
|
|
56
|
+
* Branding logo URL. When set, shown as a small watermark in the viewer's
|
|
57
|
+
* bottom-right corner. Omitted/empty renders nothing.
|
|
58
|
+
*/
|
|
59
|
+
logoUrl?: string;
|
|
55
60
|
/**
|
|
56
61
|
* UI language for the viewer's own chrome (tools menu, panels, dialogs).
|
|
57
62
|
* When set, the viewer provides it to its subtree. When omitted, the viewer
|
|
@@ -78,6 +83,7 @@
|
|
|
78
83
|
isBlurred = false,
|
|
79
84
|
drawerOpen = false,
|
|
80
85
|
viewerConfig = {},
|
|
86
|
+
logoUrl,
|
|
81
87
|
lang
|
|
82
88
|
}: Props = $props();
|
|
83
89
|
|
|
@@ -272,6 +278,24 @@
|
|
|
272
278
|
></div>
|
|
273
279
|
{/if}
|
|
274
280
|
|
|
281
|
+
{#if logoUrl}
|
|
282
|
+
<!-- Branding watermark, bottom-right. Matches the tools menu's
|
|
283
|
+
bottom offset so it clears the mobile drawer handle, and is
|
|
284
|
+
non-interactive so it never intercepts canvas drags. -->
|
|
285
|
+
<div
|
|
286
|
+
class="right-4 {isFullscreen ? 'bottom-4' : 'bottom-16 sm:bottom-4'} absolute z-20"
|
|
287
|
+
style={hideButton
|
|
288
|
+
? 'opacity: 0; pointer-events: none;'
|
|
289
|
+
: 'opacity: 1; pointer-events: none;'}
|
|
290
|
+
>
|
|
291
|
+
<img
|
|
292
|
+
src={logoUrl}
|
|
293
|
+
alt=""
|
|
294
|
+
class="h-8 max-w-32 drop-shadow-sm sm:h-10 w-auto object-contain opacity-80"
|
|
295
|
+
/>
|
|
296
|
+
</div>
|
|
297
|
+
{/if}
|
|
298
|
+
|
|
275
299
|
{#if config.showToolsMenu}
|
|
276
300
|
{@const itemClass =
|
|
277
301
|
'gap-2 px-2 py-1.5 text-sm flex cursor-pointer select-none items-center rounded-sm outline-none transition-colors hover:bg-muted focus:bg-muted'}
|
package/src/lib/constants.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
export const APP_DEFAULTS = {
|
|
2
2
|
// File upload limits
|
|
3
|
+
// TEMP (dev): raised 150 MB → 300 MB so large dev file-widget inputs aren't
|
|
4
|
+
// blocked client-side. The server request cap (COMPUTE_REQUEST_MAX_BYTES) was
|
|
5
|
+
// bumped to 300 MB to match, but base64 inflates a raw file by ~4/3, so a
|
|
6
|
+
// full 300 MB upload still won't fit the 300 MB request body. Revert to 150
|
|
7
|
+
// before release.
|
|
3
8
|
FILE_UPLOAD: {
|
|
4
|
-
MAX_SIZE_MB:
|
|
5
|
-
MAX_SIZE_BYTES:
|
|
9
|
+
MAX_SIZE_MB: 300,
|
|
10
|
+
MAX_SIZE_BYTES: 300 * 1024 * 1024
|
|
6
11
|
},
|
|
7
12
|
|
|
8
13
|
// Timing & performance thresholds
|