@happyvertical/smrt-playground 0.42.7 → 0.43.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/README.md
CHANGED
|
@@ -35,6 +35,11 @@ That module should:
|
|
|
35
35
|
|
|
36
36
|
The shared host discovers these modules and renders them. Package pages do not need to be mounted into the shared playground.
|
|
37
37
|
|
|
38
|
+
`PlaygroundHost` accepts a qualified entry ID through `selectedEntryId`. When a
|
|
39
|
+
parent changes a non-null controlled selection to `null`, the host restores its
|
|
40
|
+
default module and entry. This keeps reactive route state aligned in both
|
|
41
|
+
directions without remounting the host.
|
|
42
|
+
|
|
38
43
|
## Relationship To `smrt playground`
|
|
39
44
|
|
|
40
45
|
The `smrt playground` CLI commands are the public entry point.
|
|
@@ -20,6 +20,10 @@ export interface Props {
|
|
|
20
20
|
title?: string;
|
|
21
21
|
subtitle?: string;
|
|
22
22
|
embedded?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Qualified entry ID controlled by the parent. Clearing a previously
|
|
25
|
+
* controlled selection restores the playground's default selection.
|
|
26
|
+
*/
|
|
23
27
|
selectedEntryId?: string | null;
|
|
24
28
|
hideEntryList?: boolean;
|
|
25
29
|
}
|
|
@@ -45,6 +49,7 @@ let selectedModuleName = $state<string | null>(null);
|
|
|
45
49
|
let selectedEntryId = $state<string | null>(null);
|
|
46
50
|
let selectedMode = $state<SmrtPlaygroundMode>('mock');
|
|
47
51
|
let isHydrated = $state(false);
|
|
52
|
+
let previousControlledSelectedEntryId: string | null = null;
|
|
48
53
|
const inheritedThemeContext = tryGetThemeContext();
|
|
49
54
|
|
|
50
55
|
onMount(() => {
|
|
@@ -133,6 +138,11 @@ const foundationGroups = $derived.by(() => {
|
|
|
133
138
|
});
|
|
134
139
|
|
|
135
140
|
$effect(() => {
|
|
141
|
+
const controlledSelectionWasCleared =
|
|
142
|
+
previousControlledSelectedEntryId !== null &&
|
|
143
|
+
controlledSelectedEntryId === null;
|
|
144
|
+
previousControlledSelectedEntryId = controlledSelectedEntryId;
|
|
145
|
+
|
|
136
146
|
const controlledModule = controlledSelectedEntryId
|
|
137
147
|
? (orderedModules.find((module) =>
|
|
138
148
|
module.entries.some(
|
|
@@ -147,6 +157,16 @@ $effect(() => {
|
|
|
147
157
|
return;
|
|
148
158
|
}
|
|
149
159
|
|
|
160
|
+
if (controlledSelectionWasCleared) {
|
|
161
|
+
selectedModuleName = firstModule.packageName;
|
|
162
|
+
selectedEntryId =
|
|
163
|
+
firstModule.packageName === foundationPackageName || hideEntryList
|
|
164
|
+
? (firstModule.entries[0]?.qualifiedId ?? null)
|
|
165
|
+
: null;
|
|
166
|
+
selectedMode = firstModule.entries[0]?.availableModes[0] ?? 'mock';
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
|
|
150
170
|
const activeModule =
|
|
151
171
|
controlledModule ??
|
|
152
172
|
orderedModules.find(
|
|
@@ -5,6 +5,10 @@ export interface Props {
|
|
|
5
5
|
title?: string;
|
|
6
6
|
subtitle?: string;
|
|
7
7
|
embedded?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Qualified entry ID controlled by the parent. Clearing a previously
|
|
10
|
+
* controlled selection restores the playground's default selection.
|
|
11
|
+
*/
|
|
8
12
|
selectedEntryId?: string | null;
|
|
9
13
|
hideEntryList?: boolean;
|
|
10
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlaygroundHost.svelte.d.ts","sourceRoot":"","sources":["../../src/svelte/PlaygroundHost.svelte.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAGxC,OAAO,KAAK,EAIV,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAGpB,MAAM,WAAW,KAAK;IACpB,OAAO,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;
|
|
1
|
+
{"version":3,"file":"PlaygroundHost.svelte.d.ts","sourceRoot":"","sources":["../../src/svelte/PlaygroundHost.svelte.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAGxC,OAAO,KAAK,EAIV,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAGpB,MAAM,WAAW,KAAK;IACpB,OAAO,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAoeD,QAAA,MAAM,cAAc,0BAAwC,CAAC;AAC7D,KAAK,cAAc,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AACxD,eAAe,cAAc,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@happyvertical/smrt-playground",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.43.1",
|
|
4
4
|
"description": "Shared playground discovery, runtime, and host components for SMRT UI packages",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"fast-glob": "3.3.3",
|
|
31
31
|
"tsx": "^4.23.0",
|
|
32
|
-
"@happyvertical/smrt-ui": "0.
|
|
32
|
+
"@happyvertical/smrt-ui": "0.43.1"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"svelte": "^5.56.4",
|