@syntrologie/adapt-faq 2.14.0 → 2.15.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.
- package/dist/FAQWidgetLit.d.ts +85 -0
- package/dist/FAQWidgetLit.d.ts.map +1 -0
- package/dist/FAQWidgetLit.js +534 -0
- package/dist/editor-lit.d.ts +37 -0
- package/dist/editor-lit.d.ts.map +1 -0
- package/dist/editor-lit.js +195 -0
- package/dist/faq-types.d.ts +4 -0
- package/dist/faq-types.d.ts.map +1 -1
- package/dist/runtime-lit.d.ts +85 -0
- package/dist/runtime-lit.d.ts.map +1 -0
- package/dist/runtime-lit.js +94 -0
- package/dist/runtime.d.ts +17 -2
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +28 -0
- package/dist/schema.d.ts +100 -100
- package/package.json +12 -1
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adaptive FAQ - Lit Editor Component
|
|
3
|
+
*
|
|
4
|
+
* Lit web component port of the React FAQ editor (editor.tsx).
|
|
5
|
+
* Displays FAQ question cards with inline editing, detection,
|
|
6
|
+
* dismiss/restore, and rationale display.
|
|
7
|
+
*
|
|
8
|
+
* Custom events:
|
|
9
|
+
* navigate-home — user clicked back
|
|
10
|
+
* dirty-change — { dirty: boolean }
|
|
11
|
+
*/
|
|
12
|
+
import { html, LitElement, nothing } from 'lit';
|
|
13
|
+
import { summarizeFAQItem } from './summarize';
|
|
14
|
+
import { isOwnAction } from './types';
|
|
15
|
+
// ============================================================================
|
|
16
|
+
// Helpers
|
|
17
|
+
// ============================================================================
|
|
18
|
+
const getAnswerText = (answer) => {
|
|
19
|
+
if (typeof answer === 'string')
|
|
20
|
+
return answer;
|
|
21
|
+
if (answer.type === 'rich')
|
|
22
|
+
return answer.html;
|
|
23
|
+
return answer.content;
|
|
24
|
+
};
|
|
25
|
+
const flattenItems = (config) => {
|
|
26
|
+
const actions = (config.actions || []).filter(isOwnAction);
|
|
27
|
+
return actions.map((q, i) => ({
|
|
28
|
+
key: String(i),
|
|
29
|
+
index: i,
|
|
30
|
+
summary: summarizeFAQItem(q),
|
|
31
|
+
question: q,
|
|
32
|
+
}));
|
|
33
|
+
};
|
|
34
|
+
// ============================================================================
|
|
35
|
+
// Element
|
|
36
|
+
// ============================================================================
|
|
37
|
+
export class FAQEditorLit extends LitElement {
|
|
38
|
+
constructor() {
|
|
39
|
+
super(...arguments);
|
|
40
|
+
this.config = null;
|
|
41
|
+
this.onChange = null;
|
|
42
|
+
this._editingKey = null;
|
|
43
|
+
// No auto-dirty on load — only dirty when user makes changes (matching React behavior).
|
|
44
|
+
// ---- Actions ----
|
|
45
|
+
this._handleBack = () => {
|
|
46
|
+
if (this._editingKey !== null) {
|
|
47
|
+
this._editingKey = null;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
this.dispatchEvent(new CustomEvent('navigate-home', { bubbles: true }));
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
this._handleItemClick = (key) => {
|
|
54
|
+
this._editingKey = key;
|
|
55
|
+
};
|
|
56
|
+
this._handleFieldChange = (index, field, value) => {
|
|
57
|
+
if (!this.config || !this.onChange)
|
|
58
|
+
return;
|
|
59
|
+
const ownActions = (this.config.actions || []).filter(isOwnAction).slice();
|
|
60
|
+
const q = { ...ownActions[index], config: { ...ownActions[index].config } };
|
|
61
|
+
q.config[field] = value;
|
|
62
|
+
ownActions[index] = q;
|
|
63
|
+
const otherActions = (this.config.actions || []).filter((a) => !isOwnAction(a));
|
|
64
|
+
const updated = { ...this.config, actions: [...otherActions, ...ownActions] };
|
|
65
|
+
this.onChange(updated);
|
|
66
|
+
this.dispatchEvent(new CustomEvent('dirty-change', { detail: { dirty: true }, bubbles: true }));
|
|
67
|
+
};
|
|
68
|
+
// ---- Render ----
|
|
69
|
+
this._renderEditMode = (item) => {
|
|
70
|
+
const q = item.question;
|
|
71
|
+
return html `
|
|
72
|
+
<div class="se-py-1">
|
|
73
|
+
<div class="se-flex se-items-center se-gap-2 se-mb-3 se-text-[13px] se-font-semibold se-text-text-primary">
|
|
74
|
+
<span>❓</span>
|
|
75
|
+
<span>${item.summary}</span>
|
|
76
|
+
</div>
|
|
77
|
+
|
|
78
|
+
<div class="se-mb-3">
|
|
79
|
+
<label class="se-text-[11px] se-font-semibold se-text-text-secondary se-mb-1 se-block">Question</label>
|
|
80
|
+
<input
|
|
81
|
+
type="text"
|
|
82
|
+
.value=${q.config.question}
|
|
83
|
+
@input=${(e) => this._handleFieldChange(item.index, 'question', e.target.value)}
|
|
84
|
+
class="se-w-full se-p-2 se-rounded se-border se-border-border-primary se-bg-input-field-bg se-text-text-primary se-text-sm"
|
|
85
|
+
/>
|
|
86
|
+
</div>
|
|
87
|
+
|
|
88
|
+
<div class="se-mb-3">
|
|
89
|
+
<label class="se-text-[11px] se-font-semibold se-text-text-secondary se-mb-1 se-block">Answer</label>
|
|
90
|
+
<textarea
|
|
91
|
+
.value=${getAnswerText(q.config.answer)}
|
|
92
|
+
@input=${(e) => this._handleFieldChange(item.index, 'answer', e.target.value)}
|
|
93
|
+
rows="4"
|
|
94
|
+
class="se-w-full se-p-2 se-rounded se-border se-border-border-primary se-bg-input-field-bg se-text-text-primary se-text-sm se-resize-none"
|
|
95
|
+
></textarea>
|
|
96
|
+
</div>
|
|
97
|
+
|
|
98
|
+
<div class="se-mb-3">
|
|
99
|
+
<label class="se-text-[11px] se-font-semibold se-text-text-secondary se-mb-1 se-block">Category</label>
|
|
100
|
+
<input
|
|
101
|
+
type="text"
|
|
102
|
+
.value=${q.config.category || ''}
|
|
103
|
+
placeholder="e.g., Billing, Account"
|
|
104
|
+
@input=${(e) => this._handleFieldChange(item.index, 'category', e.target.value)}
|
|
105
|
+
class="se-w-full se-p-2 se-rounded se-border se-border-border-primary se-bg-input-field-bg se-text-text-primary se-text-sm"
|
|
106
|
+
/>
|
|
107
|
+
</div>
|
|
108
|
+
|
|
109
|
+
${q.rationale
|
|
110
|
+
? html `
|
|
111
|
+
<div>
|
|
112
|
+
<span class="se-text-[11px] se-font-semibold se-text-text-secondary se-mb-1 se-block">AI Rationale</span>
|
|
113
|
+
<div class="se-p-2 se-rounded se-border se-border-dashed se-border-border-primary se-bg-card-bg se-text-text-secondary se-text-xs se-mb-2">
|
|
114
|
+
${q.rationale.why}
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
`
|
|
118
|
+
: nothing}
|
|
119
|
+
</div>
|
|
120
|
+
`;
|
|
121
|
+
};
|
|
122
|
+
this._renderListMode = (items) => {
|
|
123
|
+
if (items.length === 0) {
|
|
124
|
+
return html `<div class="se-text-center se-py-8 se-px-4 se-text-text-secondary se-text-sm">
|
|
125
|
+
No FAQ questions configured.
|
|
126
|
+
</div>`;
|
|
127
|
+
}
|
|
128
|
+
return html `
|
|
129
|
+
<div class="se-text-[11px] se-font-semibold se-uppercase se-tracking-wider se-text-text-secondary se-mb-2 se-px-1">
|
|
130
|
+
FAQ <span class="se-text-text-tertiary se-font-normal">${items.length}</span>
|
|
131
|
+
</div>
|
|
132
|
+
${items.map((item) => html `
|
|
133
|
+
<div
|
|
134
|
+
data-item-key=${item.key}
|
|
135
|
+
@click=${() => this._handleItemClick(item.key)}
|
|
136
|
+
class="se-p-3 se-rounded-lg se-border se-border-border-primary se-bg-card-bg se-cursor-pointer se-mb-2 se-transition-all hover:se-border-pink-4/40 hover:se-bg-pink-4/5"
|
|
137
|
+
>
|
|
138
|
+
<div class="se-flex se-items-center se-gap-2">
|
|
139
|
+
<span class="se-flex-1 se-overflow-hidden se-text-ellipsis se-whitespace-nowrap se-text-sm se-text-text-primary">
|
|
140
|
+
${item.summary}
|
|
141
|
+
</span>
|
|
142
|
+
</div>
|
|
143
|
+
${item.question.rationale
|
|
144
|
+
? html `
|
|
145
|
+
<div class="se-text-[10px] se-text-text-tertiary se-mt-1">
|
|
146
|
+
WHY: ${item.question.rationale.why}
|
|
147
|
+
</div>
|
|
148
|
+
`
|
|
149
|
+
: nothing}
|
|
150
|
+
</div>
|
|
151
|
+
`)}
|
|
152
|
+
`;
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
createRenderRoot() {
|
|
156
|
+
return this;
|
|
157
|
+
}
|
|
158
|
+
render() {
|
|
159
|
+
if (!this.config) {
|
|
160
|
+
return html `<div class="se-p-8 se-text-center se-text-text-secondary se-text-sm">Loading...</div>`;
|
|
161
|
+
}
|
|
162
|
+
const items = flattenItems(this.config);
|
|
163
|
+
const editItem = this._editingKey !== null ? items.find((it) => it.key === this._editingKey) : null;
|
|
164
|
+
return html `
|
|
165
|
+
<div class="se-flex se-flex-col se-h-full">
|
|
166
|
+
<!-- Header (no Back button — panel provides that) -->
|
|
167
|
+
<div class="se-px-4 se-pt-3 se-pb-1">
|
|
168
|
+
<h2 class="se-m-0 se-text-base se-font-semibold se-text-text-primary">Review Questions</h2>
|
|
169
|
+
<p class="se-m-0 se-mt-0.5 se-text-xs se-text-text-secondary">
|
|
170
|
+
${items.length} question${items.length !== 1 ? 's' : ''}
|
|
171
|
+
</p>
|
|
172
|
+
</div>
|
|
173
|
+
|
|
174
|
+
<div class="se-flex-1 se-overflow-auto se-p-4">
|
|
175
|
+
${editItem
|
|
176
|
+
? html `
|
|
177
|
+
<button type="button" @click=${() => {
|
|
178
|
+
this._editingKey = null;
|
|
179
|
+
}}
|
|
180
|
+
class="se-mb-3 se-py-1 se-px-2 se-rounded se-border-none se-bg-card-bg se-text-text-secondary se-text-xs se-cursor-pointer"
|
|
181
|
+
>← Back to list</button>
|
|
182
|
+
${this._renderEditMode(editItem)}
|
|
183
|
+
`
|
|
184
|
+
: this._renderListMode(items)}
|
|
185
|
+
</div>
|
|
186
|
+
</div>
|
|
187
|
+
`;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
FAQEditorLit.properties = {
|
|
191
|
+
config: { attribute: false },
|
|
192
|
+
onChange: { attribute: false },
|
|
193
|
+
_editingKey: { state: true },
|
|
194
|
+
};
|
|
195
|
+
customElements.define('se-faq-editor', FAQEditorLit);
|
package/dist/faq-types.d.ts
CHANGED
|
@@ -46,6 +46,10 @@ export interface FAQWidgetRuntime {
|
|
|
46
46
|
subscribe: (callback: () => void) => () => void;
|
|
47
47
|
register: (key: string, predicate: (event: any) => boolean) => void;
|
|
48
48
|
};
|
|
49
|
+
/** Session metrics for reactive triggerWhen re-evaluation */
|
|
50
|
+
sessionMetrics?: {
|
|
51
|
+
subscribe: (callback: () => void) => () => void;
|
|
52
|
+
};
|
|
49
53
|
}
|
|
50
54
|
export interface FAQWidgetProps {
|
|
51
55
|
config: FAQConfig;
|
package/dist/faq-types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"faq-types.d.ts","sourceRoot":"","sources":["../src/faq-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAM3D,MAAM,WAAW,gBAAgB;IAC/B,YAAY,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,gBAAgB,CAAC,CAAC,CAAC,KAAK;QAAE,KAAK,EAAE,CAAC,CAAC;QAAC,UAAU,EAAE,OAAO,CAAA;KAAE,CAAC;IACtF,OAAO,EAAE;QAAE,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAA;KAAE,CAAC;IAC7D,MAAM,EAAE;QACN,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;QACjE,SAAS,CAAC,EAAE,CACV,gBAAgB,EACZ;YAAE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;YAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;YAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;SAAE,GAC7D,CAAC,CAAC,KAAK,EAAE;YAAE,IAA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K,CAAC,EAAE,MAAM,EAAE,CAAC;YAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;SAAE,EAClD,KAAK,CAAC,EAAE,MAAM,KACX,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAAC,EAAE,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KAC3E,CAAC;IACF,KAAK,CAAC,EAAE;QAAE,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;QAAC,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;KAAE,CAAC;IACtF,+DAA+D;IAC/D,WAAW,CAAC,EAAE;QACZ,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;QAChD,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,KAAK,IAAI,CAAC;KACrE,CAAC;IACF,6DAA6D;IAC7D,cAAc,CAAC,EAAE;QACf,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;KACjD,CAAC;CACH;AAMD,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,SAAS,CAAC;IAClB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adaptive FAQ - Runtime Module (Lit)
|
|
3
|
+
*
|
|
4
|
+
* Runtime manifest for the FAQ accordion adaptive.
|
|
5
|
+
* Uses the Lit web component mountable instead of the React one.
|
|
6
|
+
* Provides action executors and widget registration.
|
|
7
|
+
*/
|
|
8
|
+
import './FAQWidgetLit';
|
|
9
|
+
import type { FAQWidgetRuntime } from './faq-types';
|
|
10
|
+
import type { FAQConfig } from './types';
|
|
11
|
+
/**
|
|
12
|
+
* Mountable widget interface for <syntro-faq-accordion> (Lit web component).
|
|
13
|
+
*
|
|
14
|
+
* Mirrors FAQMountableWidget but mounts the Lit element instead of a React
|
|
15
|
+
* root — no React dependency required at mount time.
|
|
16
|
+
*/
|
|
17
|
+
export declare const FAQWidgetLitMountable: {
|
|
18
|
+
mount(container: HTMLElement, config?: FAQConfig & {
|
|
19
|
+
runtime?: FAQWidgetRuntime;
|
|
20
|
+
instanceId?: string;
|
|
21
|
+
}): () => void;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Runtime manifest for adaptive-faq (Lit variant).
|
|
25
|
+
*
|
|
26
|
+
* Provides:
|
|
27
|
+
* - FAQ action executors (scroll_to, toggle_item, update)
|
|
28
|
+
* - Widget-based accordion using the Lit web component
|
|
29
|
+
*/
|
|
30
|
+
export declare const runtime: {
|
|
31
|
+
id: string;
|
|
32
|
+
version: string;
|
|
33
|
+
name: string;
|
|
34
|
+
description: string;
|
|
35
|
+
/**
|
|
36
|
+
* Action executors for programmatic FAQ interaction.
|
|
37
|
+
*/
|
|
38
|
+
executors: readonly [{
|
|
39
|
+
readonly kind: "faq:scroll_to";
|
|
40
|
+
readonly executor: typeof import("./executors").executeScrollToFaq;
|
|
41
|
+
}, {
|
|
42
|
+
readonly kind: "faq:toggle_item";
|
|
43
|
+
readonly executor: typeof import("./executors").executeToggleFaqItem;
|
|
44
|
+
}, {
|
|
45
|
+
readonly kind: "faq:update";
|
|
46
|
+
readonly executor: typeof import("./executors").executeUpdateFaq;
|
|
47
|
+
}];
|
|
48
|
+
/**
|
|
49
|
+
* Widget definitions for the runtime's WidgetRegistry.
|
|
50
|
+
*/
|
|
51
|
+
widgets: {
|
|
52
|
+
id: string;
|
|
53
|
+
component: {
|
|
54
|
+
mount(container: HTMLElement, config?: FAQConfig & {
|
|
55
|
+
runtime?: FAQWidgetRuntime;
|
|
56
|
+
instanceId?: string;
|
|
57
|
+
}): () => void;
|
|
58
|
+
};
|
|
59
|
+
metadata: {
|
|
60
|
+
name: string;
|
|
61
|
+
description: string;
|
|
62
|
+
icon: string;
|
|
63
|
+
subtitle: string;
|
|
64
|
+
};
|
|
65
|
+
}[];
|
|
66
|
+
/**
|
|
67
|
+
* Extract notify watcher entries from tile config props.
|
|
68
|
+
* The runtime evaluates these continuously (even with drawer closed)
|
|
69
|
+
* and publishes faq:question_revealed when triggerWhen transitions false → true.
|
|
70
|
+
*/
|
|
71
|
+
notifyWatchers(props: Record<string, unknown>): {
|
|
72
|
+
id: string;
|
|
73
|
+
strategy: import("./types").DecisionStrategy<boolean>;
|
|
74
|
+
eventName: string;
|
|
75
|
+
eventProps: {
|
|
76
|
+
questionId: string;
|
|
77
|
+
question: string;
|
|
78
|
+
title: string | undefined;
|
|
79
|
+
body: string | undefined;
|
|
80
|
+
icon: string | undefined;
|
|
81
|
+
};
|
|
82
|
+
}[];
|
|
83
|
+
};
|
|
84
|
+
export default runtime;
|
|
85
|
+
//# sourceMappingURL=runtime-lit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-lit.d.ts","sourceRoot":"","sources":["../src/runtime-lit.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAqB,MAAM,SAAS,CAAC;AAM5D;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB;qBAEnB,WAAW,WACb,SAAS,GAAG;QAAE,OAAO,CAAC,EAAE,gBAAgB,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE;CA4B3E,CAAC;AAMF;;;;;;GAMG;AACH,eAAO,MAAM,OAAO;;;;;IAOlB;;OAEG;;;;;;;;;;;IAGH;;OAEG;;;;6BAxDU,WAAW,WACb,SAAS,GAAG;gBAAE,OAAO,CAAC,EAAE,gBAAgB,CAAC;gBAAC,UAAU,CAAC,EAAE,MAAM,CAAA;aAAE;;;;;;;;;IAqE1E;;;;OAIG;0BACmB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;;;;;;;;CAiB9C,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adaptive FAQ - Runtime Module (Lit)
|
|
3
|
+
*
|
|
4
|
+
* Runtime manifest for the FAQ accordion adaptive.
|
|
5
|
+
* Uses the Lit web component mountable instead of the React one.
|
|
6
|
+
* Provides action executors and widget registration.
|
|
7
|
+
*/
|
|
8
|
+
import { executorDefinitions } from './executors';
|
|
9
|
+
import './FAQWidgetLit'; // registers <syntro-faq-accordion> custom element
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Lit Mountable Widget
|
|
12
|
+
// ============================================================================
|
|
13
|
+
/**
|
|
14
|
+
* Mountable widget interface for <syntro-faq-accordion> (Lit web component).
|
|
15
|
+
*
|
|
16
|
+
* Mirrors FAQMountableWidget but mounts the Lit element instead of a React
|
|
17
|
+
* root — no React dependency required at mount time.
|
|
18
|
+
*/
|
|
19
|
+
export const FAQWidgetLitMountable = {
|
|
20
|
+
mount(container, config) {
|
|
21
|
+
const { runtime, instanceId = 'faq-widget', ...faqConfig } = config ?? {
|
|
22
|
+
expandBehavior: 'single',
|
|
23
|
+
searchable: false,
|
|
24
|
+
theme: 'auto',
|
|
25
|
+
actions: [],
|
|
26
|
+
};
|
|
27
|
+
const el = document.createElement('syntro-faq-accordion');
|
|
28
|
+
Object.assign(el, {
|
|
29
|
+
faqConfig: faqConfig,
|
|
30
|
+
runtime: runtime ?? null,
|
|
31
|
+
instanceId,
|
|
32
|
+
});
|
|
33
|
+
container.appendChild(el);
|
|
34
|
+
return () => el.remove();
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
// ============================================================================
|
|
38
|
+
// App Runtime Manifest
|
|
39
|
+
// ============================================================================
|
|
40
|
+
/**
|
|
41
|
+
* Runtime manifest for adaptive-faq (Lit variant).
|
|
42
|
+
*
|
|
43
|
+
* Provides:
|
|
44
|
+
* - FAQ action executors (scroll_to, toggle_item, update)
|
|
45
|
+
* - Widget-based accordion using the Lit web component
|
|
46
|
+
*/
|
|
47
|
+
export const runtime = {
|
|
48
|
+
id: 'adaptive-faq',
|
|
49
|
+
version: '2.0.0',
|
|
50
|
+
name: 'FAQ Accordion',
|
|
51
|
+
description: 'Collapsible Q&A accordion with actions, rich content, feedback, and personalization',
|
|
52
|
+
/**
|
|
53
|
+
* Action executors for programmatic FAQ interaction.
|
|
54
|
+
*/
|
|
55
|
+
executors: executorDefinitions,
|
|
56
|
+
/**
|
|
57
|
+
* Widget definitions for the runtime's WidgetRegistry.
|
|
58
|
+
*/
|
|
59
|
+
widgets: [
|
|
60
|
+
{
|
|
61
|
+
id: 'adaptive-faq:accordion',
|
|
62
|
+
component: FAQWidgetLitMountable,
|
|
63
|
+
metadata: {
|
|
64
|
+
name: 'FAQ Accordion',
|
|
65
|
+
description: 'Collapsible Q&A accordion with search, categories, and feedback',
|
|
66
|
+
icon: '❓',
|
|
67
|
+
subtitle: 'Curated just for you.',
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
/**
|
|
72
|
+
* Extract notify watcher entries from tile config props.
|
|
73
|
+
* The runtime evaluates these continuously (even with drawer closed)
|
|
74
|
+
* and publishes faq:question_revealed when triggerWhen transitions false → true.
|
|
75
|
+
*/
|
|
76
|
+
notifyWatchers(props) {
|
|
77
|
+
const actions = (props.actions ?? []);
|
|
78
|
+
return actions
|
|
79
|
+
.filter((a) => a.notify && a.triggerWhen)
|
|
80
|
+
.map((a) => ({
|
|
81
|
+
id: `faq:${a.config.id}`,
|
|
82
|
+
strategy: a.triggerWhen,
|
|
83
|
+
eventName: 'faq:question_revealed',
|
|
84
|
+
eventProps: {
|
|
85
|
+
questionId: a.config.id,
|
|
86
|
+
question: a.config.question,
|
|
87
|
+
title: a.notify.title,
|
|
88
|
+
body: a.notify.body,
|
|
89
|
+
icon: a.notify.icon,
|
|
90
|
+
},
|
|
91
|
+
}));
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
export default runtime;
|
package/dist/runtime.d.ts
CHANGED
|
@@ -4,6 +4,21 @@
|
|
|
4
4
|
* Runtime manifest for the FAQ accordion adaptive.
|
|
5
5
|
* Provides action executors and widget registration.
|
|
6
6
|
*/
|
|
7
|
+
import './FAQWidgetLit';
|
|
8
|
+
import type { FAQWidgetRuntime } from './faq-types';
|
|
9
|
+
import type { FAQConfig } from './types';
|
|
10
|
+
/**
|
|
11
|
+
* Mountable widget interface for <syntro-faq-accordion> (Lit web component).
|
|
12
|
+
*
|
|
13
|
+
* Mirrors FAQMountableWidget but mounts the Lit element instead of a React
|
|
14
|
+
* root — no React dependency required at mount time.
|
|
15
|
+
*/
|
|
16
|
+
export declare const FAQWidgetLitMountable: {
|
|
17
|
+
mount(container: HTMLElement, config?: FAQConfig & {
|
|
18
|
+
runtime?: FAQWidgetRuntime;
|
|
19
|
+
instanceId?: string;
|
|
20
|
+
}): () => void;
|
|
21
|
+
};
|
|
7
22
|
/**
|
|
8
23
|
* Runtime manifest for adaptive-faq.
|
|
9
24
|
*
|
|
@@ -35,8 +50,8 @@ export declare const runtime: {
|
|
|
35
50
|
widgets: {
|
|
36
51
|
id: string;
|
|
37
52
|
component: {
|
|
38
|
-
mount(container: HTMLElement, config?:
|
|
39
|
-
runtime?:
|
|
53
|
+
mount(container: HTMLElement, config?: FAQConfig & {
|
|
54
|
+
runtime?: FAQWidgetRuntime;
|
|
40
55
|
instanceId?: string;
|
|
41
56
|
}): (() => void) | undefined;
|
|
42
57
|
};
|
package/dist/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAqB,MAAM,SAAS,CAAC;AAM5D;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB;qBAEnB,WAAW,WACb,SAAS,GAAG;QAAE,OAAO,CAAC,EAAE,gBAAgB,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE;CA4B3E,CAAC;AAMF;;;;;;GAMG;AACH,eAAO,MAAM,OAAO;;;;;IAOlB;;OAEG;;;;;;;;;;;IAGH;;OAEG;;;;;uBAuCm5e,CAAC;0BAA8B,CAAC;;;;;;;;;;IAzBt7e;;;;OAIG;0BACmB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;;;;;;;;CAiB9C,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
package/dist/runtime.js
CHANGED
|
@@ -6,6 +6,34 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { executorDefinitions } from './executors';
|
|
8
8
|
import { FAQMountableWidget } from './FAQWidget';
|
|
9
|
+
import './FAQWidgetLit'; // registers <syntro-faq-accordion> custom element
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Lit Mountable Widget
|
|
12
|
+
// ============================================================================
|
|
13
|
+
/**
|
|
14
|
+
* Mountable widget interface for <syntro-faq-accordion> (Lit web component).
|
|
15
|
+
*
|
|
16
|
+
* Mirrors FAQMountableWidget but mounts the Lit element instead of a React
|
|
17
|
+
* root — no React dependency required at mount time.
|
|
18
|
+
*/
|
|
19
|
+
export const FAQWidgetLitMountable = {
|
|
20
|
+
mount(container, config) {
|
|
21
|
+
const { runtime, instanceId = 'faq-widget', ...faqConfig } = config ?? {
|
|
22
|
+
expandBehavior: 'single',
|
|
23
|
+
searchable: false,
|
|
24
|
+
theme: 'auto',
|
|
25
|
+
actions: [],
|
|
26
|
+
};
|
|
27
|
+
const el = document.createElement('syntro-faq-accordion');
|
|
28
|
+
Object.assign(el, {
|
|
29
|
+
faqConfig: faqConfig,
|
|
30
|
+
runtime: runtime ?? null,
|
|
31
|
+
instanceId,
|
|
32
|
+
});
|
|
33
|
+
container.appendChild(el);
|
|
34
|
+
return () => el.remove();
|
|
35
|
+
},
|
|
36
|
+
};
|
|
9
37
|
// ============================================================================
|
|
10
38
|
// App Runtime Manifest
|
|
11
39
|
// ============================================================================
|