astro-tractstack 2.0.0-rc.66 → 2.0.0-rc.67
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/package.json
CHANGED
|
@@ -327,7 +327,7 @@ function processStoryfragmentUpdate(update, config) {
|
|
|
327
327
|
`Target pane element for scrolling not found: #pane-${update.gotoPaneId}`
|
|
328
328
|
);
|
|
329
329
|
}
|
|
330
|
-
},
|
|
330
|
+
}, 350);
|
|
331
331
|
}
|
|
332
332
|
}
|
|
333
333
|
|
|
@@ -361,6 +361,7 @@ function initializeCurrentView() {
|
|
|
361
361
|
|
|
362
362
|
function resetViewState() {
|
|
363
363
|
log('Resetting view state before new page preparation.');
|
|
364
|
+
flushPendingPaneEvents();
|
|
364
365
|
isPageInitialized = false;
|
|
365
366
|
paneViewTimes.clear();
|
|
366
367
|
}
|
|
@@ -385,8 +386,13 @@ if (!window.tractstackViewLifecycleListenersAttached) {
|
|
|
385
386
|
|
|
386
387
|
let beliefValue;
|
|
387
388
|
if (target.type === 'checkbox') {
|
|
388
|
-
|
|
389
|
-
|
|
389
|
+
const onVerb = target.getAttribute('data-verb');
|
|
390
|
+
const offVerb = target.getAttribute('data-off-verb');
|
|
391
|
+
if (onVerb && offVerb) {
|
|
392
|
+
beliefValue = target.checked ? onVerb : offVerb;
|
|
393
|
+
} else {
|
|
394
|
+
beliefValue = target.checked ? 'BELIEVES_YES' : 'BELIEVES_NO';
|
|
395
|
+
}
|
|
390
396
|
} else {
|
|
391
397
|
beliefValue = target.value;
|
|
392
398
|
}
|
|
@@ -931,6 +931,12 @@ export default function SaveModal({
|
|
|
931
931
|
>
|
|
932
932
|
Keep Editing
|
|
933
933
|
</button>
|
|
934
|
+
<a
|
|
935
|
+
href="/storykeep/content"
|
|
936
|
+
className={`rounded bg-black px-4 py-2 text-white transition-colors hover:bg-white hover:text-black`}
|
|
937
|
+
>
|
|
938
|
+
Dashboard
|
|
939
|
+
</a>
|
|
934
940
|
</>
|
|
935
941
|
)}
|
|
936
942
|
{stage === 'ERROR' && (
|
|
@@ -12,28 +12,27 @@ export default function ToggleWidget({ node, onUpdate }: ToggleWidgetProps) {
|
|
|
12
12
|
const [beliefs, setBeliefs] = useState<BeliefNode[]>([]);
|
|
13
13
|
const [selectedBeliefTag, setSelectedBeliefTag] = useState<string>('');
|
|
14
14
|
const [currentPrompt, setCurrentPrompt] = useState<string>('');
|
|
15
|
+
const [currentScale, setCurrentScale] = useState<string>('');
|
|
15
16
|
const [isInitialized, setIsInitialized] = useState(false);
|
|
16
17
|
|
|
17
|
-
// Get parameter metadata from the widgetMeta constant
|
|
18
18
|
const widgetInfo = widgetMeta.toggle;
|
|
19
19
|
|
|
20
20
|
const params = node.codeHookParams || [];
|
|
21
21
|
const beliefTag = String(params[0] || '');
|
|
22
22
|
const prompt = String(params[1] || '');
|
|
23
|
+
const scale = String(params[2] || '');
|
|
23
24
|
|
|
24
|
-
// Check if beliefTag is the placeholder value
|
|
25
25
|
const isPlaceholder = beliefTag === 'BeliefTag';
|
|
26
26
|
|
|
27
|
-
// Update local state when props change
|
|
28
27
|
useEffect(() => {
|
|
29
28
|
if (!isPlaceholder && beliefTag) {
|
|
30
29
|
setSelectedBeliefTag(beliefTag);
|
|
31
30
|
}
|
|
32
31
|
setCurrentPrompt(prompt);
|
|
32
|
+
setCurrentScale(scale);
|
|
33
33
|
setIsInitialized(true);
|
|
34
|
-
}, [beliefTag, prompt, isPlaceholder]);
|
|
34
|
+
}, [beliefTag, prompt, scale, isPlaceholder]);
|
|
35
35
|
|
|
36
|
-
// Fetch beliefs using new Go backend pattern
|
|
37
36
|
useEffect(() => {
|
|
38
37
|
const fetchData = async () => {
|
|
39
38
|
try {
|
|
@@ -41,7 +40,6 @@ export default function ToggleWidget({ node, onUpdate }: ToggleWidgetProps) {
|
|
|
41
40
|
import.meta.env.PUBLIC_GO_BACKEND || 'http://localhost:8080';
|
|
42
41
|
const tenantId = import.meta.env.PUBLIC_TENANTID || 'default';
|
|
43
42
|
|
|
44
|
-
// Step 1: Get all belief IDs
|
|
45
43
|
const idsResponse = await fetch(`${goBackend}/api/v1/nodes/beliefs`, {
|
|
46
44
|
headers: {
|
|
47
45
|
'X-Tenant-ID': tenantId,
|
|
@@ -60,7 +58,6 @@ export default function ToggleWidget({ node, onUpdate }: ToggleWidgetProps) {
|
|
|
60
58
|
return;
|
|
61
59
|
}
|
|
62
60
|
|
|
63
|
-
// Step 2: Get belief data by IDs
|
|
64
61
|
const beliefsResponse = await fetch(
|
|
65
62
|
`${goBackend}/api/v1/nodes/beliefs`,
|
|
66
63
|
{
|
|
@@ -92,34 +89,30 @@ export default function ToggleWidget({ node, onUpdate }: ToggleWidgetProps) {
|
|
|
92
89
|
const handleBeliefChange = (selectedValue: string) => {
|
|
93
90
|
if (!isInitialized) return;
|
|
94
91
|
setSelectedBeliefTag(selectedValue);
|
|
95
|
-
|
|
92
|
+
const selectedBelief = beliefs.find((b) => b.slug === selectedValue);
|
|
93
|
+
const newScale = selectedBelief ? selectedBelief.scale || '' : '';
|
|
94
|
+
setCurrentScale(newScale);
|
|
95
|
+
onUpdate([selectedValue, currentPrompt, newScale]);
|
|
96
96
|
};
|
|
97
97
|
|
|
98
98
|
const handlePromptChange = (value: string) => {
|
|
99
99
|
if (!isInitialized) return;
|
|
100
|
-
// Sanitize the input value (remove newlines and pipe characters)
|
|
101
100
|
const sanitizedValue = value.replace(/[\n\r|]/g, '');
|
|
102
101
|
setCurrentPrompt(sanitizedValue);
|
|
103
|
-
|
|
104
|
-
// Use the actual selected tag (from state) or the original belief tag as fallback
|
|
105
102
|
const tagToUse = selectedBeliefTag || (isPlaceholder ? '' : beliefTag);
|
|
106
|
-
onUpdate([tagToUse, sanitizedValue]);
|
|
103
|
+
onUpdate([tagToUse, sanitizedValue, currentScale]);
|
|
107
104
|
};
|
|
108
105
|
|
|
109
|
-
// Show beliefs that can be selected for the toggle
|
|
110
106
|
const filteredBeliefs = beliefs.filter(
|
|
111
107
|
(b) => b.scale === 'yn' || b.scale === 'tf'
|
|
112
108
|
);
|
|
113
109
|
|
|
114
|
-
// Find the selected belief (if any)
|
|
115
110
|
const selectedBelief = beliefs.find(
|
|
116
111
|
(b) => b.slug === (selectedBeliefTag || (isPlaceholder ? '' : beliefTag))
|
|
117
112
|
);
|
|
118
113
|
|
|
119
|
-
// Determine if we have a real selection - either from state or props
|
|
120
114
|
const hasRealSelection = !!selectedBelief || (!isPlaceholder && !!beliefTag);
|
|
121
115
|
|
|
122
|
-
// Calculate the current value to show in the select dropdown
|
|
123
116
|
const selectValue = selectedBeliefTag || (isPlaceholder ? '' : beliefTag);
|
|
124
117
|
|
|
125
118
|
return (
|