@syntrologie/adapt-faq 2.8.0-canary.211 → 2.8.0-canary.213
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.editable.d.ts +130 -0
- package/dist/FAQWidgetLit.editable.d.ts.map +1 -0
- package/dist/editor.d.ts +28 -3
- package/dist/editor.d.ts.map +1 -1
- package/dist/editor.js +492 -113
- package/dist/editor.js.map +4 -4
- package/dist/faq-item-editor.d.ts +33 -0
- package/dist/faq-item-editor.d.ts.map +1 -0
- package/dist/schema.d.ts +202 -202
- package/dist/schema.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adaptive FAQ - FAQWidgetLit.editable
|
|
3
|
+
*
|
|
4
|
+
* Editable variant of the FAQ accordion for the canvas editor surface.
|
|
5
|
+
* Renders the same Q&A rows as <syntro-faq-accordion> but adds:
|
|
6
|
+
* - Pencil button per row (shows on hover, calls controller.editItem on click)
|
|
7
|
+
* - Double-click on row calls controller.editItem
|
|
8
|
+
* - Drag handle per row when items.length >= 2
|
|
9
|
+
* - Drag-and-drop reorder via the sortable utility (injected via mount config)
|
|
10
|
+
* - Read-only fallback when controller is null
|
|
11
|
+
*
|
|
12
|
+
* Tag name: <syntro-faq-accordion-editable>
|
|
13
|
+
*
|
|
14
|
+
* Decorator-free: uses `static override properties` (matches codebase convention).
|
|
15
|
+
* Light DOM: inherits host-page CSS variables (same as <syntro-faq-accordion>).
|
|
16
|
+
*
|
|
17
|
+
* Cross-package import safety:
|
|
18
|
+
* The controller is typed as a structural `ControllerLike` interface defined
|
|
19
|
+
* locally — NOT imported from @syntrologie/editor-sdk. This prevents a
|
|
20
|
+
* dependency cycle (editor-sdk imports adapt-faq's editable; adapt-faq cannot
|
|
21
|
+
* import editor-sdk). The real EditModeController satisfies ControllerLike
|
|
22
|
+
* structurally.
|
|
23
|
+
*
|
|
24
|
+
* Similarly, `makeSortable` is passed in as a `SortableFn` option rather than
|
|
25
|
+
* imported directly. The editor-sdk bootstrap (setupEditModeBootstrap.ts) threads
|
|
26
|
+
* the real makeSortable through the FAQWidgetLitEditableMountable.mount() call.
|
|
27
|
+
* This is Alternative C from the architecture decision log, and matches the
|
|
28
|
+
* structural-interface pattern already used for the controller.
|
|
29
|
+
*/
|
|
30
|
+
import { LitElement } from 'lit';
|
|
31
|
+
import type { FAQConfig } from './types';
|
|
32
|
+
/**
|
|
33
|
+
* Structural interface — describes only the methods the editable widget needs.
|
|
34
|
+
* The real EditModeController satisfies this by structural subtyping.
|
|
35
|
+
*/
|
|
36
|
+
export interface ControllerLike {
|
|
37
|
+
editItem(adaptive: string, itemId: string): void;
|
|
38
|
+
isModalOpen(): boolean;
|
|
39
|
+
reorderItems(adaptive: string, newOrder: string[]): void;
|
|
40
|
+
}
|
|
41
|
+
/** Return value from makeSortable. */
|
|
42
|
+
export interface SortableHandle {
|
|
43
|
+
destroy(): void;
|
|
44
|
+
}
|
|
45
|
+
/** Options subset that FAQAccordionEditableElement passes into the sortable. */
|
|
46
|
+
export interface SortableOptions {
|
|
47
|
+
itemSelector: string;
|
|
48
|
+
handleSelector: string;
|
|
49
|
+
getItems: () => string[];
|
|
50
|
+
onReorder: (newOrder: string[]) => void;
|
|
51
|
+
liveRegion: HTMLElement;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Structural type matching `makeSortable` from editor-sdk's sortable.ts.
|
|
55
|
+
* Injected at mount time by FAQWidgetLitEditableMountable.
|
|
56
|
+
*/
|
|
57
|
+
export type SortableFn = (host: HTMLElement, opts: SortableOptions) => SortableHandle;
|
|
58
|
+
/**
|
|
59
|
+
* <syntro-faq-accordion-editable> — light-DOM Lit element.
|
|
60
|
+
*
|
|
61
|
+
* Set properties imperatively (no attribute serialisation for objects):
|
|
62
|
+
* el.faqConfig = { ... };
|
|
63
|
+
* el.controller = editModeControllerInstance; // null → read-only
|
|
64
|
+
*/
|
|
65
|
+
export declare class FAQAccordionEditableElement extends LitElement {
|
|
66
|
+
static properties: {
|
|
67
|
+
faqConfig: {
|
|
68
|
+
attribute: boolean;
|
|
69
|
+
};
|
|
70
|
+
controller: {
|
|
71
|
+
attribute: boolean;
|
|
72
|
+
};
|
|
73
|
+
_hoveredId: {
|
|
74
|
+
state: boolean;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
faqConfig: FAQConfig;
|
|
78
|
+
/** Null when loaded without an editor context — renders read-only accordion. */
|
|
79
|
+
controller: ControllerLike | null;
|
|
80
|
+
/**
|
|
81
|
+
* The `makeSortable` factory to use. Injected by FAQWidgetLitEditableMountable
|
|
82
|
+
* from the editor-sdk bootstrap so there is no direct import from editor-sdk
|
|
83
|
+
* into this package (which would create a circular dependency).
|
|
84
|
+
*
|
|
85
|
+
* Null when running without the editor context (read-only mode).
|
|
86
|
+
*/
|
|
87
|
+
sortable: SortableFn | null;
|
|
88
|
+
/**
|
|
89
|
+
* Shared aria-live region from the modal host, threaded in via mount config.
|
|
90
|
+
* Falls back to a detached element when running outside the editor context.
|
|
91
|
+
*
|
|
92
|
+
* TODO(phase-2-a11y): wire shared live region from modal host for real a11y.
|
|
93
|
+
*/
|
|
94
|
+
liveRegion: HTMLElement | null;
|
|
95
|
+
_hoveredId: string | null;
|
|
96
|
+
private _sortableHandle;
|
|
97
|
+
createRenderRoot(): this;
|
|
98
|
+
/**
|
|
99
|
+
* Wire (or re-wire) the sortable whenever the properties it depends on change.
|
|
100
|
+
* `updated()` fires after every render, including the first, so we don't need
|
|
101
|
+
* a separate `firstUpdated()` call — using `updated()` alone avoids a double
|
|
102
|
+
* attach on mount (firstUpdated + updated both fire on first render).
|
|
103
|
+
*/
|
|
104
|
+
protected updated(changed: Map<string, unknown>): void;
|
|
105
|
+
disconnectedCallback(): void;
|
|
106
|
+
private _attachSortable;
|
|
107
|
+
private _handleEdit;
|
|
108
|
+
private _handleRowDblClick;
|
|
109
|
+
private _handlePencilClick;
|
|
110
|
+
private _renderRow;
|
|
111
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Mountable for <syntro-faq-accordion-editable>.
|
|
115
|
+
*
|
|
116
|
+
* Follows the same mount pattern as FAQWidgetLitMountable in runtime.ts.
|
|
117
|
+
* Accepts a `controller` in addition to `faqConfig` so the editor can
|
|
118
|
+
* wire up the EditModeController at mount time.
|
|
119
|
+
*/
|
|
120
|
+
export declare const FAQWidgetLitEditableMountable: {
|
|
121
|
+
mount(container: HTMLElement, config?: FAQConfig & {
|
|
122
|
+
instanceId?: string;
|
|
123
|
+
controller?: ControllerLike | null;
|
|
124
|
+
/** makeSortable factory injected by editor-sdk bootstrap. Null → drag disabled. */
|
|
125
|
+
sortable?: SortableFn | null;
|
|
126
|
+
/** Shared aria-live region from the modal host for sortable announcements. */
|
|
127
|
+
liveRegion?: HTMLElement | null;
|
|
128
|
+
}): () => void;
|
|
129
|
+
};
|
|
130
|
+
//# sourceMappingURL=FAQWidgetLit.editable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FAQWidgetLit.editable.d.ts","sourceRoot":"","sources":["../src/FAQWidgetLit.editable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAQ,UAAU,EAAW,MAAM,KAAK,CAAC;AAEhD,OAAO,KAAK,EAAE,SAAS,EAAqB,MAAM,SAAS,CAAC;AAM5D;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACjD,WAAW,IAAI,OAAO,CAAC;IACvB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;CAC1D;AAMD,sCAAsC;AACtC,MAAM,WAAW,cAAc;IAC7B,OAAO,IAAI,I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CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;QAC7B,8EAA8E;QAC9E,UAAU,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;KACjC;CAgCJ,CAAC"}
|
package/dist/editor.d.ts
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { LitElement } from 'lit';
|
|
12
12
|
import '@syntrologie/shared-editor-ui/lit-elements';
|
|
13
|
+
import './faq-item-editor';
|
|
13
14
|
import { type FAQEditorConfig } from './types';
|
|
14
15
|
export declare class FAQEditorLit extends LitElement {
|
|
15
16
|
static properties: {
|
|
@@ -27,11 +28,18 @@ export declare class FAQEditorLit extends LitElement {
|
|
|
27
28
|
onChange: ((updated: Record<string, unknown>) => void) | null;
|
|
28
29
|
private _editingKey;
|
|
29
30
|
createRenderRoot(): this;
|
|
30
|
-
private _handleBack;
|
|
31
31
|
private _handleItemClick;
|
|
32
|
-
private _emitFieldChange;
|
|
33
|
-
private _handleFieldChange;
|
|
34
32
|
private _handleDelete;
|
|
33
|
+
/**
|
|
34
|
+
* Build the FAQConfig slice and onChange handler to pass to <syntro-faq-item-editor>.
|
|
35
|
+
*
|
|
36
|
+
* For flat configs the full config is passed directly.
|
|
37
|
+
* For grouped configs a synthetic FAQConfig is built from the item's group actions so the
|
|
38
|
+
* inner element can find the item by ID. When onChange fires the patched flat actions are
|
|
39
|
+
* spliced back into the correct group of the grouped config before bubbling to the panel's
|
|
40
|
+
* own onChange.
|
|
41
|
+
*/
|
|
42
|
+
private _buildInnerProps;
|
|
35
43
|
private _renderEditMode;
|
|
36
44
|
private _renderItemCard;
|
|
37
45
|
private _handleNavigateFromPill;
|
|
@@ -39,4 +47,21 @@ export declare class FAQEditorLit extends LitElement {
|
|
|
39
47
|
private _renderListMode;
|
|
40
48
|
render(): import("lit-html").TemplateResult<1>;
|
|
41
49
|
}
|
|
50
|
+
export { FAQAccordionEditableElement, FAQWidgetLitEditableMountable, } from './FAQWidgetLit.editable';
|
|
51
|
+
export { FAQItemEditorLit } from './faq-item-editor';
|
|
52
|
+
interface ModalHostLike {
|
|
53
|
+
registerEditorFactory: (adaptive: 'adaptive-faq:accordion', factory: {
|
|
54
|
+
item: (args: {
|
|
55
|
+
itemId: string;
|
|
56
|
+
appConfig: Record<string, unknown>;
|
|
57
|
+
onChange: (next: Record<string, unknown>) => void;
|
|
58
|
+
}) => HTMLElement;
|
|
59
|
+
container: (args: {
|
|
60
|
+
appConfig: Record<string, unknown>;
|
|
61
|
+
onChange: (next: Record<string, unknown>) => void;
|
|
62
|
+
}) => HTMLElement;
|
|
63
|
+
}) => void;
|
|
64
|
+
}
|
|
65
|
+
/** Wires the FAQ adaptive's editor factories into the modal host. Called by editor-sdk bootstrap. */
|
|
66
|
+
export declare function registerFaqEditorFactories(modalHost: ModalHostLike): void;
|
|
42
67
|
//# sourceMappingURL=editor.d.ts.map
|
package/dist/editor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../src/editor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAQ,UAAU,EAAW,MAAM,KAAK,CAAC;AAGhD,OAAO,4CAA4C,CAAC;AAGpD,OAAO,
|
|
1
|
+
{"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../src/editor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAQ,UAAU,EAAW,MAAM,KAAK,CAAC;AAGhD,OAAO,4CAA4C,CAAC;AAGpD,OAAO,mBAAmB,CAAC;AAG3B,OAAO,EAEL,KAAK,eAAe,EAMrB,MAAM,SAAS,CAAC;AAoHjB,qBAAa,YAAa,SAAQ,UAAU;IAC1C,OAAgB,UAAU;;;;;;;;;;MAIxB;IAEF,MAAM,EAAE,eAAe,GAAG,IAAI,CAAQ;IACtC,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KA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