@syntrologie/adapt-nav 2.20.0 → 2.21.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.
@@ -0,0 +1,151 @@
1
+ /**
2
+ * Adaptive Nav - NavWidgetLit.editable
3
+ *
4
+ * Editable variant of the Nav tips accordion for the canvas editor surface.
5
+ * Renders the same tip rows as <syntro-nav-tips> but adds:
6
+ * - Pencil button per row (shows on hover, calls controller.editItem on click)
7
+ * - Pencil click calls controller.editItem to open the modal editor
8
+ * - Read-only fallback when controller is null
9
+ * - Normal clicks pass through — only pencil and drag handle trigger edit actions
10
+ *
11
+ * Tag name: <syntro-nav-tips-editable>
12
+ *
13
+ * Decorator-free: uses `static override properties` (matches codebase pattern).
14
+ * Light DOM: inherits host-page CSS variables (same as <syntro-nav-tips>).
15
+ *
16
+ * Cross-package import safety:
17
+ * The controller is typed as a structural `ControllerLike` interface defined
18
+ * locally — NOT imported from @syntrologie/editor-sdk. This prevents a
19
+ * dependency cycle. The real EditModeController satisfies ControllerLike
20
+ * structurally.
21
+ *
22
+ * Similarly, `makeSortable` is passed in as a `SortableFn` option rather than
23
+ * imported directly — matching the FAQ editable widget pattern (Alternative C
24
+ * from the architecture decision log). The sortable is wired via _attachSortable()
25
+ * in the updated() lifecycle hook, exactly mirroring FAQAccordionEditableElement.
26
+ *
27
+ * Click strategy:
28
+ * Row clicks pass through normally — the editable variant does NOT intercept
29
+ * them. Only the pencil button (opens modal editor) and drag handle (reorder)
30
+ * trigger edit-mode actions. This lets the underlying widget behavior (e.g.
31
+ * navigation, scrolling) work as expected in the editor preview.
32
+ */
33
+ import { LitElement } from 'lit';
34
+ import type { NavConfig } from './types';
35
+ /**
36
+ * Structural interface — describes only the methods the editable widget needs.
37
+ * The real EditModeController satisfies this by structural subtyping.
38
+ *
39
+ * `tileId` (the host tile's id, threaded in via `instanceId` at mount) scopes
40
+ * controller calls to the active tile when a canvas has multiple Nav tiles.
41
+ * It is optional so single-tile and v2 actions-shape canvases continue to work.
42
+ */
43
+ export interface ControllerLike {
44
+ editItem(adaptive: string, itemId: string, tileId?: string): void;
45
+ editContainer(adaptive: string, tileId?: string): void;
46
+ isModalOpen(): boolean;
47
+ reorderItems(adaptive: string, newOrder: string[], tileId?: string): void;
48
+ }
49
+ /** Return value from makeSortable. */
50
+ export interface SortableHandle {
51
+ destroy(): void;
52
+ }
53
+ /** Options subset that NavTipsEditableElement passes into the sortable. */
54
+ export interface SortableOptions {
55
+ itemSelector: string;
56
+ handleSelector: string;
57
+ getItems: () => string[];
58
+ onReorder: (newOrder: string[]) => void;
59
+ liveRegion: HTMLElement;
60
+ }
61
+ /**
62
+ * Structural type matching `makeSortable` from editor-sdk's sortable.ts.
63
+ * Injected at mount time by NavWidgetLitEditableMountable.
64
+ * Phase 3.3 will actually wire this; it is accepted here for forward compat.
65
+ */
66
+ export type SortableFn = (host: HTMLElement, opts: SortableOptions) => SortableHandle;
67
+ /**
68
+ * <syntro-nav-tips-editable> — light-DOM Lit element.
69
+ *
70
+ * Set properties imperatively (no attribute serialisation for objects):
71
+ * el.navConfig = { ... };
72
+ * el.controller = editModeControllerInstance; // null → read-only
73
+ */
74
+ export declare class NavTipsEditableElement extends LitElement {
75
+ static properties: {
76
+ navConfig: {
77
+ attribute: boolean;
78
+ };
79
+ controller: {
80
+ attribute: boolean;
81
+ };
82
+ tileId: {
83
+ attribute: boolean;
84
+ };
85
+ _hoveredId: {
86
+ state: boolean;
87
+ };
88
+ _containerHovered: {
89
+ state: boolean;
90
+ };
91
+ };
92
+ navConfig: NavConfig;
93
+ /** Null when loaded without an editor context — renders read-only list. */
94
+ controller: ControllerLike | null;
95
+ /**
96
+ * Host tile id, threaded in via the mountable's `instanceId`. Scopes every
97
+ * controller call so the right tile is targeted when the canvas has more
98
+ * than one Nav tile (per-route navs). Empty string when unknown.
99
+ */
100
+ tileId: string;
101
+ /**
102
+ * The `makeSortable` factory to use. Injected by NavWidgetLitEditableMountable
103
+ * from the editor-sdk bootstrap so there is no direct import from editor-sdk
104
+ * into this package (which would create a circular dependency).
105
+ *
106
+ * Null when running without the editor context (read-only mode).
107
+ */
108
+ sortable: SortableFn | null;
109
+ /**
110
+ * Shared aria-live region from the modal host, threaded in via mount config.
111
+ * Falls back to a detached element when running outside the editor context.
112
+ */
113
+ liveRegion: HTMLElement | null;
114
+ _hoveredId: string | null;
115
+ _containerHovered: boolean;
116
+ private _sortableHandle;
117
+ createRenderRoot(): this;
118
+ connectedCallback(): void;
119
+ /**
120
+ * Wire (or re-wire) the sortable whenever the properties it depends on change.
121
+ * `updated()` fires after every render, including the first, so we don't need
122
+ * a separate `firstUpdated()` call — using `updated()` alone avoids a double
123
+ * attach on mount (firstUpdated + updated both fire on first render).
124
+ */
125
+ protected updated(changed: Map<string, unknown>): void;
126
+ disconnectedCallback(): void;
127
+ private _attachSortable;
128
+ private _handleEdit;
129
+ private _handlePencilClick;
130
+ private _handleContainerEdit;
131
+ private _renderRow;
132
+ render(): import("lit-html").TemplateResult<1>;
133
+ }
134
+ /**
135
+ * Mountable for <syntro-nav-tips-editable>.
136
+ *
137
+ * Follows the same mount pattern as NavWidgetLitMountable in runtime.ts.
138
+ * Accepts a `controller` in addition to `navConfig` so the editor can
139
+ * wire up the EditModeController at mount time.
140
+ */
141
+ export declare const NavWidgetLitEditableMountable: {
142
+ mount(container: HTMLElement, config?: NavConfig & {
143
+ instanceId?: string;
144
+ controller?: ControllerLike | null;
145
+ /** makeSortable factory injected by editor-sdk bootstrap. Phase 3.3 wires this. */
146
+ sortable?: SortableFn | null;
147
+ /** Shared aria-live region from the modal host for sortable announcements. */
148
+ liveRegion?: HTMLElement | null;
149
+ }): () => void;
150
+ };
151
+ //# sourceMappingURL=NavWidgetLit.editable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NavWidgetLit.editable.d.ts","sourceRoot":"","sources":["../src/NavWidgetLit.editable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;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IAEnC;;;OAGG;IACH,UAAU,EAAE,WAAW,GAAG,IAAI,CAAQ;IAEtC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAQ;IACjC,iBAAiB,UAAS;IAM1B,OAAO,CAAC,eAAe,CAA+B;IAM7C,gBAAgB;IAIhB,iBAAiB,IAAI,IAAI;IASlC;;;;;OAKG;cACgB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAQtD,oBAAoB,IAAI,IAAI;IAMrC,OAAO,CAAC,eAAe;IAsBvB,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,kBAAkB;IAM1B,OAAO,CAAC,oBAAoB;IAU5B,OAAO,CAAC,UAAU;IAqDT,MAAM;CA8EhB;AAcD;;;;;;GAMG;AACH,eAAO,MAAM,6BAA6B;qBAE3B,WAAW,WACb,SAAS,GAAG;QACnB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;QACnC,mFAAmF;QACnF,QAAQ,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;QAC7B,8EAA8E;QAC9E,UAAU,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;KACjC;CAiCJ,CAAC"}
package/dist/editor.d.ts CHANGED
@@ -13,6 +13,8 @@
13
13
  import { LitElement } from 'lit';
14
14
  import { type NavConfig } from './types';
15
15
  import '@syntrologie/shared-editor-ui/lit-elements';
16
+ import './nav-item-editor';
17
+ import './NavWidgetLit.editable';
16
18
  export declare class NavEditorLit extends LitElement {
17
19
  static properties: {
18
20
  config: {
@@ -41,7 +43,6 @@ export declare class NavEditorLit extends LitElement {
41
43
  private _runDetection;
42
44
  private _handleItemClick;
43
45
  private _emitConfig;
44
- private _handleFieldChange;
45
46
  private _handleDelete;
46
47
  private _handleLocate;
47
48
  private _handleNavigateToRoute;
@@ -51,4 +52,21 @@ export declare class NavEditorLit extends LitElement {
51
52
  private _renderListMode;
52
53
  render(): import("lit-html").TemplateResult<1>;
53
54
  }
55
+ export { NavTipsEditableElement, NavWidgetLitEditableMountable, } from './NavWidgetLit.editable';
56
+ export { NavItemEditorLit } from './nav-item-editor';
57
+ interface ModalHostLike {
58
+ registerEditorFactory: (adaptive: 'adaptive-nav:tips', factory: {
59
+ item: (args: {
60
+ itemId: string;
61
+ appConfig: Record<string, unknown>;
62
+ onChange: (next: Record<string, unknown>) => void;
63
+ }) => HTMLElement;
64
+ container: (args: {
65
+ appConfig: Record<string, unknown>;
66
+ onChange: (next: Record<string, unknown>) => void;
67
+ }) => HTMLElement;
68
+ }) => void;
69
+ }
70
+ /** Wires the Nav adaptive's editor factories into the modal host. Called by editor-sdk bootstrap. */
71
+ export declare function registerNavEditorFactories(modalHost: ModalHostLike): void;
54
72
  //# sourceMappingURL=editor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../src/editor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EAAQ,UAAU,EAAW,MAAM,KAAK,CAAC;AAGhD,OAAO,EAAe,KAAK,SAAS,EAAqB,MAAM,SAAS,CAAC;AAEzE,OAAO,4CAA4C,CAAC;AAsHpD,qBAAa,YAAa,SAAQ,UAAU;IAC1C,OAAgB,UAAU;;;;;;;;;;;;;MAKxB;IAEF,MAAM,EAAE,SAAS,GAAG,IAAI,CAAQ;IAChC,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC,GAAG,IAAI,CAAQ;IAErE,OAAO,CAAC,WAAW,CAAuB;IAC1C,OAAO,CAAC,aAAa,CAA0C;IAC/D,OAAO,CAAC,WAAW,CAA8B;IAExC,gBAAgB;IAIhB,iBAAiB,IAAI,IAAI;IAKzB,oBAAoB,IAAI,IAAI;IAK5B,YAAY,IAAI,IAAI;IAIpB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,MAA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