@d3-polytree/editor 0.1.0 → 0.2.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/index.d.cts CHANGED
@@ -1,5 +1,159 @@
1
1
  import { InteractiveViewer, InteractiveViewerOptions } from '@d3-polytree/interactive-viewer';
2
2
  import { DiagramModule, CreateParameters, ModellingModelElement } from '@d3-polytree/core';
3
+ import EventEmitter from 'eventemitter3';
4
+
5
+ /** A moddle model element as read/written by the properties panel. */
6
+ interface Definition {
7
+ id?: string;
8
+ label?: Definition;
9
+ $instanceOf(type: string): boolean;
10
+ get(property: string): unknown;
11
+ [key: string]: unknown;
12
+ }
13
+
14
+ /** A `{name,value}` option for a select entry. */
15
+ interface SelectOption {
16
+ name: string;
17
+ value: string;
18
+ }
19
+ /** Options accepted when building an entry. */
20
+ interface EntryOptions {
21
+ id: string;
22
+ modelProperty: string;
23
+ label?: string;
24
+ description?: string;
25
+ type?: string;
26
+ allowEmpty?: boolean;
27
+ selectOptions?: SelectOption[];
28
+ }
29
+ /** A rendered property entry: its markup plus get/set behaviour. */
30
+ interface EntryResource extends EntryOptions {
31
+ html: string;
32
+ get: (element: Definition, formNode: HTMLElement) => void;
33
+ set: (element: Definition, values: Record<string, unknown>) => boolean;
34
+ validate: () => Record<string, unknown>;
35
+ triggerUpdate: (propertyId: string, element: Definition) => void;
36
+ }
37
+ /**
38
+ * Builds property-panel entries (text / select / colour / spreadsheet). Ported
39
+ * from `@d3-polytree/properties-panel`'s `entryFactory/*`, de-jQuery-ed onto
40
+ * native DOM; the colour entry uses a native `<input type="color">` in place of
41
+ * spectrum-colorpicker.
42
+ */
43
+ declare class EntryFactory {
44
+ static readonly $inject: string[];
45
+ private readonly _eventBus;
46
+ constructor(eventBus: EventEmitter);
47
+ setDefaultParameters(options: EntryOptions): EntryResource;
48
+ textField(options: EntryOptions): EntryResource;
49
+ selectBox(options: EntryOptions): EntryResource;
50
+ colorPicker(options: EntryOptions): EntryResource;
51
+ spreadsheet(options: EntryOptions): EntryResource;
52
+ }
53
+ /** didi module contributing the entry factory. */
54
+ declare const entryFactoryModule: {
55
+ __init__: string[];
56
+ entryFactory: (string | typeof EntryFactory)[];
57
+ };
58
+
59
+ /** A group of entries within a tab. */
60
+ interface PropertiesGroup {
61
+ id: string;
62
+ label: string;
63
+ entries: EntryResource[];
64
+ }
65
+ /** A properties-panel tab. */
66
+ interface PropertiesTab {
67
+ id: string;
68
+ label: string;
69
+ groups: PropertiesGroup[];
70
+ }
71
+ /** Icon registry token: icon type → SVG source. */
72
+ type IconMap = Record<string, string>;
73
+ /** A properties provider: supplies the tabs for a selected element. */
74
+ interface PropertiesProvider {
75
+ getTabs(element: Definition): PropertiesTab[];
76
+ updateDrawing(definition: Definition): void;
77
+ }
78
+ /**
79
+ * The PFDN properties provider: builds the Properties + Format tabs for the
80
+ * selected element, and applies edits back to the drawing. Ported from
81
+ * `provider/pfdn/*`.
82
+ */
83
+ declare class PfdnPropertiesProvider implements PropertiesProvider {
84
+ static readonly $inject: string[];
85
+ private readonly _icons;
86
+ private readonly _entryFactory;
87
+ private readonly _eventBus;
88
+ constructor(icons: IconMap, entryFactory: EntryFactory, eventBus: EventEmitter);
89
+ updateDrawing(definition: Definition): void;
90
+ getTabs(element: Definition): PropertiesTab[];
91
+ private _propertiesTab;
92
+ private _formatTab;
93
+ }
94
+ /** didi module contributing the PFDN properties provider. */
95
+ declare const pfdnPropertiesProviderModule: {
96
+ __init__: string[];
97
+ propertiesProvider: (string | typeof PfdnPropertiesProvider)[];
98
+ };
99
+
100
+ /** The side-tab registration surface the panel needs (structural). */
101
+ interface SideTabRegistration {
102
+ title?: string;
103
+ iconClassName?: string;
104
+ action: {
105
+ created?: (content: HTMLElement | null) => void;
106
+ [gesture: string]: ((content: HTMLElement | null) => void) | undefined;
107
+ };
108
+ }
109
+ interface SideTabsRegistrar {
110
+ registerSideTab(tab: SideTabRegistration, index?: number): void;
111
+ }
112
+ /**
113
+ * The editor properties panel: a tabbed editor for the selected element's
114
+ * model properties. Ported from `@d3-polytree/properties-panel`'s
115
+ * `PropertiesPanel.js`, de-jQuery-ed onto native DOM; the `scroll-tabs` widget
116
+ * is replaced by native click-to-select tabs.
117
+ */
118
+ declare class PropertiesPanel {
119
+ static readonly $inject: string[];
120
+ private readonly _eventBus;
121
+ private readonly _propertiesProvider;
122
+ private readonly _diagramSettings;
123
+ private _entries;
124
+ private _container;
125
+ private _tabsEl;
126
+ private _contentsEl;
127
+ constructor(sideTabsProvider: SideTabsRegistrar, eventBus: EventEmitter, propertiesProvider: PropertiesProvider, diagramSettings: Definition);
128
+ private _registerSideTab;
129
+ private _registerSelectionListener;
130
+ private _drawPanel;
131
+ private _drawContainer;
132
+ private _registerInputChangeHandlers;
133
+ private _applyChange;
134
+ private _applyChangeByProperty;
135
+ private _commit;
136
+ private _selectTab;
137
+ private _update;
138
+ private _drawEntries;
139
+ static readonly HTML_MARKUP: string;
140
+ }
141
+
142
+ /**
143
+ * @d3-polytree/properties-panel — the editor's element-properties panel.
144
+ *
145
+ * Modernised (B6) from the 2017 jQuery/spectrum/scroll-tabs source to TypeScript
146
+ * + ESM with native DOM: jQuery is gone, the colour entry uses a native
147
+ * `<input type="color">`, and the `scroll-tabs` widget is replaced by native
148
+ * click-to-select tabs. Ships three didi modules (entry factory, PFDN provider,
149
+ * panel) for the editor to compose.
150
+ */
151
+
152
+ /** didi module contributing the properties panel (composes with the provider). */
153
+ declare const propertiesPanelModule: {
154
+ __init__: string[];
155
+ propertiesPanel: (string | typeof PropertiesPanel)[];
156
+ };
3
157
 
4
158
  /**
5
159
  * @d3-polytree/editor — create and modify polytree diagrams.
@@ -26,4 +180,4 @@ declare class Editor extends InteractiveViewer {
26
180
  deleteSelected(): void;
27
181
  }
28
182
 
29
- export { Editor, type EditorOptions, Editor as default };
183
+ export { type Definition, Editor, type EditorOptions, EntryFactory, type EntryOptions, type EntryResource, type IconMap, PfdnPropertiesProvider, type PropertiesGroup, PropertiesPanel, type PropertiesProvider, type PropertiesTab, type SelectOption, type SideTabRegistration, type SideTabsRegistrar, Editor as default, entryFactoryModule, pfdnPropertiesProviderModule, propertiesPanelModule };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,159 @@
1
1
  import { InteractiveViewer, InteractiveViewerOptions } from '@d3-polytree/interactive-viewer';
2
2
  import { DiagramModule, CreateParameters, ModellingModelElement } from '@d3-polytree/core';
3
+ import EventEmitter from 'eventemitter3';
4
+
5
+ /** A moddle model element as read/written by the properties panel. */
6
+ interface Definition {
7
+ id?: string;
8
+ label?: Definition;
9
+ $instanceOf(type: string): boolean;
10
+ get(property: string): unknown;
11
+ [key: string]: unknown;
12
+ }
13
+
14
+ /** A `{name,value}` option for a select entry. */
15
+ interface SelectOption {
16
+ name: string;
17
+ value: string;
18
+ }
19
+ /** Options accepted when building an entry. */
20
+ interface EntryOptions {
21
+ id: string;
22
+ modelProperty: string;
23
+ label?: string;
24
+ description?: string;
25
+ type?: string;
26
+ allowEmpty?: boolean;
27
+ selectOptions?: SelectOption[];
28
+ }
29
+ /** A rendered property entry: its markup plus get/set behaviour. */
30
+ interface EntryResource extends EntryOptions {
31
+ html: string;
32
+ get: (element: Definition, formNode: HTMLElement) => void;
33
+ set: (element: Definition, values: Record<string, unknown>) => boolean;
34
+ validate: () => Record<string, unknown>;
35
+ triggerUpdate: (propertyId: string, element: Definition) => void;
36
+ }
37
+ /**
38
+ * Builds property-panel entries (text / select / colour / spreadsheet). Ported
39
+ * from `@d3-polytree/properties-panel`'s `entryFactory/*`, de-jQuery-ed onto
40
+ * native DOM; the colour entry uses a native `<input type="color">` in place of
41
+ * spectrum-colorpicker.
42
+ */
43
+ declare class EntryFactory {
44
+ static readonly $inject: string[];
45
+ private readonly _eventBus;
46
+ constructor(eventBus: EventEmitter);
47
+ setDefaultParameters(options: EntryOptions): EntryResource;
48
+ textField(options: EntryOptions): EntryResource;
49
+ selectBox(options: EntryOptions): EntryResource;
50
+ colorPicker(options: EntryOptions): EntryResource;
51
+ spreadsheet(options: EntryOptions): EntryResource;
52
+ }
53
+ /** didi module contributing the entry factory. */
54
+ declare const entryFactoryModule: {
55
+ __init__: string[];
56
+ entryFactory: (string | typeof EntryFactory)[];
57
+ };
58
+
59
+ /** A group of entries within a tab. */
60
+ interface PropertiesGroup {
61
+ id: string;
62
+ label: string;
63
+ entries: EntryResource[];
64
+ }
65
+ /** A properties-panel tab. */
66
+ interface PropertiesTab {
67
+ id: string;
68
+ label: string;
69
+ groups: PropertiesGroup[];
70
+ }
71
+ /** Icon registry token: icon type → SVG source. */
72
+ type IconMap = Record<string, string>;
73
+ /** A properties provider: supplies the tabs for a selected element. */
74
+ interface PropertiesProvider {
75
+ getTabs(element: Definition): PropertiesTab[];
76
+ updateDrawing(definition: Definition): void;
77
+ }
78
+ /**
79
+ * The PFDN properties provider: builds the Properties + Format tabs for the
80
+ * selected element, and applies edits back to the drawing. Ported from
81
+ * `provider/pfdn/*`.
82
+ */
83
+ declare class PfdnPropertiesProvider implements PropertiesProvider {
84
+ static readonly $inject: string[];
85
+ private readonly _icons;
86
+ private readonly _entryFactory;
87
+ private readonly _eventBus;
88
+ constructor(icons: IconMap, entryFactory: EntryFactory, eventBus: EventEmitter);
89
+ updateDrawing(definition: Definition): void;
90
+ getTabs(element: Definition): PropertiesTab[];
91
+ private _propertiesTab;
92
+ private _formatTab;
93
+ }
94
+ /** didi module contributing the PFDN properties provider. */
95
+ declare const pfdnPropertiesProviderModule: {
96
+ __init__: string[];
97
+ propertiesProvider: (string | typeof PfdnPropertiesProvider)[];
98
+ };
99
+
100
+ /** The side-tab registration surface the panel needs (structural). */
101
+ interface SideTabRegistration {
102
+ title?: string;
103
+ iconClassName?: string;
104
+ action: {
105
+ created?: (content: HTMLElement | null) => void;
106
+ [gesture: string]: ((content: HTMLElement | null) => void) | undefined;
107
+ };
108
+ }
109
+ interface SideTabsRegistrar {
110
+ registerSideTab(tab: SideTabRegistration, index?: number): void;
111
+ }
112
+ /**
113
+ * The editor properties panel: a tabbed editor for the selected element's
114
+ * model properties. Ported from `@d3-polytree/properties-panel`'s
115
+ * `PropertiesPanel.js`, de-jQuery-ed onto native DOM; the `scroll-tabs` widget
116
+ * is replaced by native click-to-select tabs.
117
+ */
118
+ declare class PropertiesPanel {
119
+ static readonly $inject: string[];
120
+ private readonly _eventBus;
121
+ private readonly _propertiesProvider;
122
+ private readonly _diagramSettings;
123
+ private _entries;
124
+ private _container;
125
+ private _tabsEl;
126
+ private _contentsEl;
127
+ constructor(sideTabsProvider: SideTabsRegistrar, eventBus: EventEmitter, propertiesProvider: PropertiesProvider, diagramSettings: Definition);
128
+ private _registerSideTab;
129
+ private _registerSelectionListener;
130
+ private _drawPanel;
131
+ private _drawContainer;
132
+ private _registerInputChangeHandlers;
133
+ private _applyChange;
134
+ private _applyChangeByProperty;
135
+ private _commit;
136
+ private _selectTab;
137
+ private _update;
138
+ private _drawEntries;
139
+ static readonly HTML_MARKUP: string;
140
+ }
141
+
142
+ /**
143
+ * @d3-polytree/properties-panel — the editor's element-properties panel.
144
+ *
145
+ * Modernised (B6) from the 2017 jQuery/spectrum/scroll-tabs source to TypeScript
146
+ * + ESM with native DOM: jQuery is gone, the colour entry uses a native
147
+ * `<input type="color">`, and the `scroll-tabs` widget is replaced by native
148
+ * click-to-select tabs. Ships three didi modules (entry factory, PFDN provider,
149
+ * panel) for the editor to compose.
150
+ */
151
+
152
+ /** didi module contributing the properties panel (composes with the provider). */
153
+ declare const propertiesPanelModule: {
154
+ __init__: string[];
155
+ propertiesPanel: (string | typeof PropertiesPanel)[];
156
+ };
3
157
 
4
158
  /**
5
159
  * @d3-polytree/editor — create and modify polytree diagrams.
@@ -26,4 +180,4 @@ declare class Editor extends InteractiveViewer {
26
180
  deleteSelected(): void;
27
181
  }
28
182
 
29
- export { Editor, type EditorOptions, Editor as default };
183
+ export { type Definition, Editor, type EditorOptions, EntryFactory, type EntryOptions, type EntryResource, type IconMap, PfdnPropertiesProvider, type PropertiesGroup, PropertiesPanel, type PropertiesProvider, type PropertiesTab, type SelectOption, type SideTabRegistration, type SideTabsRegistrar, Editor as default, entryFactoryModule, pfdnPropertiesProviderModule, propertiesPanelModule };