@selvajs/ui 4.10.0 → 4.12.0

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.
@@ -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;
@@ -54,7 +56,7 @@
54
56
  header?: Snippet;
55
57
  // Scopes sessionStorage for external-input values; falls back to definitionKey then schema.id.
56
58
  externalScopeKey?: string;
57
- // Renders client-sourced inputs with presentation === 'slot'; receives { inputId, displayName, slotLabel, value }.
59
+ // Renders client-sourced inputs with presentation === 'slot'; receives { inputId, displayName, value, onValueChange }.
58
60
  clientSlot?: ClientSlot;
59
61
  /**
60
62
  * UI language for the app's own chrome (viewer, panels, status text).
@@ -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?: boolean) {
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;
@@ -59,12 +59,10 @@
59
59
  // Client-sourced input set to render a host element in its place. The 'hidden'
60
60
  // presentation never reaches here (visible:false filters it out upstream), so a
61
61
  // client slot source means presentation === 'slot'.
62
- const clientSlotConfig = $derived.by(() => {
63
- const source = (
64
- item as { source?: { kind?: string; client?: { presentation?: string; slotLabel?: string } } }
65
- ).source;
66
- if (source?.kind !== 'client' || source.client?.presentation !== 'slot') return null;
67
- return { slotLabel: source.client.slotLabel };
62
+ const isClientSlot = $derived.by(() => {
63
+ const source = (item as { source?: { kind?: string; client?: { presentation?: string } } })
64
+ .source;
65
+ return source?.kind === 'client' && source.client?.presentation === 'slot';
68
66
  });
69
67
  const clientSlot = getClientSlot();
70
68
 
@@ -144,15 +142,32 @@
144
142
  }
145
143
  </script>
146
144
 
147
- {#if clientSlotConfig}
145
+ {#if isClientSlot}
148
146
  {#if clientSlot}
149
- {@render clientSlot({
150
- inputId: item.paramId,
151
- displayName: label,
152
- slotLabel: clientSlotConfig.slotLabel,
153
- value,
154
- onValueChange: commit
155
- })}
147
+ <Field.Field>
148
+ <Field.Label class="gap-2 flex items-center">
149
+ {label}
150
+ {#if item.description}
151
+ <Dialog.Root>
152
+ <Dialog.Trigger class="p-1 cursor-help opacity-60 transition-opacity hover:opacity-100">
153
+ <HelpCircle size={16} />
154
+ </Dialog.Trigger>
155
+ <Dialog.Content class="sm:max-w-md">
156
+ <Dialog.Header>
157
+ <Dialog.Title>{label}</Dialog.Title>
158
+ <Dialog.Description>{item.description}</Dialog.Description>
159
+ </Dialog.Header>
160
+ </Dialog.Content>
161
+ </Dialog.Root>
162
+ {/if}
163
+ </Field.Label>
164
+ {@render clientSlot({
165
+ inputId: item.paramId,
166
+ displayName: label,
167
+ value,
168
+ onValueChange: commit
169
+ })}
170
+ </Field.Field>
156
171
  {/if}
157
172
  {:else if !hideDynamicListWhenEmpty}
158
173
  <Field.Field>
@@ -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: 150,
5
- MAX_SIZE_BYTES: 150 * 1024 * 1024
9
+ MAX_SIZE_MB: 300,
10
+ MAX_SIZE_BYTES: 300 * 1024 * 1024
6
11
  },
7
12
  // Timing & performance thresholds
8
13
  TIMEOUTS: {
@@ -4,8 +4,6 @@ export interface ClientSlotArgs {
4
4
  /** Grasshopper parameter instance GUID (LayoutItem.paramId / SchemaInput.id). */
5
5
  inputId: string;
6
6
  displayName: string;
7
- /** Author-set label from the schema, passed through untouched. May be undefined. */
8
- slotLabel?: string;
9
7
  /** The current value held for this input (e.g. the prefilled JSON), if any. */
10
8
  value: unknown;
11
9
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@selvajs/ui",
3
- "version": "4.10.0",
3
+ "version": "4.12.0",
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": "^2.1.0",
40
+ "@selvajs/compute": "^3.0.0-beta.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.5.0"
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/config": "0.0.1",
76
- "@selvajs/schemas": "4.5.0"
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;
@@ -54,7 +56,7 @@
54
56
  header?: Snippet;
55
57
  // Scopes sessionStorage for external-input values; falls back to definitionKey then schema.id.
56
58
  externalScopeKey?: string;
57
- // Renders client-sourced inputs with presentation === 'slot'; receives { inputId, displayName, slotLabel, value }.
59
+ // Renders client-sourced inputs with presentation === 'slot'; receives { inputId, displayName, value, onValueChange }.
58
60
  clientSlot?: ClientSlot;
59
61
  /**
60
62
  * UI language for the app's own chrome (viewer, panels, status text).
@@ -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?: boolean) {
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}
@@ -59,12 +59,10 @@
59
59
  // Client-sourced input set to render a host element in its place. The 'hidden'
60
60
  // presentation never reaches here (visible:false filters it out upstream), so a
61
61
  // client slot source means presentation === 'slot'.
62
- const clientSlotConfig = $derived.by(() => {
63
- const source = (
64
- item as { source?: { kind?: string; client?: { presentation?: string; slotLabel?: string } } }
65
- ).source;
66
- if (source?.kind !== 'client' || source.client?.presentation !== 'slot') return null;
67
- return { slotLabel: source.client.slotLabel };
62
+ const isClientSlot = $derived.by(() => {
63
+ const source = (item as { source?: { kind?: string; client?: { presentation?: string } } })
64
+ .source;
65
+ return source?.kind === 'client' && source.client?.presentation === 'slot';
68
66
  });
69
67
  const clientSlot = getClientSlot();
70
68
 
@@ -144,15 +142,32 @@
144
142
  }
145
143
  </script>
146
144
 
147
- {#if clientSlotConfig}
145
+ {#if isClientSlot}
148
146
  {#if clientSlot}
149
- {@render clientSlot({
150
- inputId: item.paramId,
151
- displayName: label,
152
- slotLabel: clientSlotConfig.slotLabel,
153
- value,
154
- onValueChange: commit
155
- })}
147
+ <Field.Field>
148
+ <Field.Label class="gap-2 flex items-center">
149
+ {label}
150
+ {#if item.description}
151
+ <Dialog.Root>
152
+ <Dialog.Trigger class="p-1 cursor-help opacity-60 transition-opacity hover:opacity-100">
153
+ <HelpCircle size={16} />
154
+ </Dialog.Trigger>
155
+ <Dialog.Content class="sm:max-w-md">
156
+ <Dialog.Header>
157
+ <Dialog.Title>{label}</Dialog.Title>
158
+ <Dialog.Description>{item.description}</Dialog.Description>
159
+ </Dialog.Header>
160
+ </Dialog.Content>
161
+ </Dialog.Root>
162
+ {/if}
163
+ </Field.Label>
164
+ {@render clientSlot({
165
+ inputId: item.paramId,
166
+ displayName: label,
167
+ value,
168
+ onValueChange: commit
169
+ })}
170
+ </Field.Field>
156
171
  {/if}
157
172
  {:else if !hideDynamicListWhenEmpty}
158
173
  <Field.Field>
@@ -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'}
@@ -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: 150,
5
- MAX_SIZE_BYTES: 150 * 1024 * 1024
9
+ MAX_SIZE_MB: 300,
10
+ MAX_SIZE_BYTES: 300 * 1024 * 1024
6
11
  },
7
12
 
8
13
  // Timing & performance thresholds
@@ -9,16 +9,14 @@ import type { SupportedTypes } from '@selvajs/schemas';
9
9
  // An input with source.kind === 'client' and source.client.presentation === 'slot'
10
10
  // reserves its cell but renders nothing itself. Instead Selva invokes this snippet
11
11
  // so the host can render its own element (e.g. an "Edit JSON" button, or a custom
12
- // picker). Selva never interprets what the host renders; `slotLabel` is passed
13
- // through untouched. The host may COMMIT a value back via `onValueChange`, which
14
- // flows into the solve exactly like any built-in widget's change.
12
+ // picker). Selva never interprets what the host renders. The host may COMMIT a value
13
+ // back via `onValueChange`, which flows into the solve exactly like any built-in
14
+ // widget's change.
15
15
 
16
16
  export interface ClientSlotArgs {
17
17
  /** Grasshopper parameter instance GUID (LayoutItem.paramId / SchemaInput.id). */
18
18
  inputId: string;
19
19
  displayName: string;
20
- /** Author-set label from the schema, passed through untouched. May be undefined. */
21
- slotLabel?: string;
22
20
  /** The current value held for this input (e.g. the prefilled JSON), if any. */
23
21
  value: unknown;
24
22
  /**