@omegagrid/editor 0.10.92 → 0.10.93
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConditionalFormatType, Style, ThemeColumnItem, ThemeRowItem } from '@omegagrid/grid';
|
|
1
|
+
import { ConditionalFormatType, MatchItem, Style, ThemeColumnItem, ThemeRowItem } from '@omegagrid/grid';
|
|
2
2
|
import { events, OmegaComponent } from '@omegagrid/core';
|
|
3
3
|
import { RuleEditor } from './ruleEditor';
|
|
4
4
|
import { StyleEditor } from './styleEditor';
|
|
@@ -17,9 +17,19 @@ export declare class ThemeItemEditor extends OmegaComponent {
|
|
|
17
17
|
updateRuleType(type: ConditionalFormatType): void;
|
|
18
18
|
_onStyleChange: (e: events.ChangeEvent<Style>) => void;
|
|
19
19
|
_dispatchChange: () => void;
|
|
20
|
-
/**
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Conditions of the item as a list of match items. The legacy root matchers
|
|
22
|
+
* are shown converted with their original semantics (index wins over level,
|
|
23
|
+
* the name filters on top) and become themeItem.matches on the first edit.
|
|
24
|
+
*/
|
|
25
|
+
getMatchItems(): MatchItem[];
|
|
26
|
+
private commitMatchItems;
|
|
27
|
+
addCondition(property: string): void;
|
|
28
|
+
removeCondition(index: number): void;
|
|
29
|
+
/** comma-separated input = OR of the values; an empty input removes the condition */
|
|
30
|
+
_onConditionChange(index: number, raw: string): void;
|
|
31
|
+
private formatConditionValue;
|
|
32
|
+
_onSizeChange: (e: events.ChangeEvent<number>) => void;
|
|
23
33
|
render: () => import("lit-html").TemplateResult<1>;
|
|
24
34
|
}
|
|
25
35
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"themeItemEditor.d.ts","sourceRoot":"","sources":["../../../src/ui/editors/themeItemEditor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,KAAK,E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AAM,CAAC,WAAW,CAAC,MAAM,CAAC,UAK7C;IAED,MAAM,6CAkGJ;CACF"}
|
|
@@ -8,6 +8,7 @@ import { customElement, property, query } from 'lit/decorators.js';
|
|
|
8
8
|
import { css, html } from 'lit';
|
|
9
9
|
import { OmegaComponent } from '@omegagrid/core';
|
|
10
10
|
import { msg } from '@omegagrid/localize';
|
|
11
|
+
import { map } from 'lit-html/directives/map.js';
|
|
11
12
|
const ruleTypes = [
|
|
12
13
|
{ key: null, value: 'Static style' },
|
|
13
14
|
{ key: 'formula', value: 'Formula' },
|
|
@@ -15,6 +16,8 @@ const ruleTypes = [
|
|
|
15
16
|
{ key: 'bar', value: 'Data Bar' },
|
|
16
17
|
{ key: 'icon', value: 'Icon Set' },
|
|
17
18
|
];
|
|
19
|
+
/** node properties offered by the add-condition dropdown */
|
|
20
|
+
const matchProperties = ['name', 'level', 'index'];
|
|
18
21
|
let ThemeItemEditor = class ThemeItemEditor extends OmegaComponent {
|
|
19
22
|
constructor() {
|
|
20
23
|
super(...arguments);
|
|
@@ -25,11 +28,12 @@ let ThemeItemEditor = class ThemeItemEditor extends OmegaComponent {
|
|
|
25
28
|
this._dispatchChange = () => {
|
|
26
29
|
this.editor?.dispatchThemeChange();
|
|
27
30
|
};
|
|
28
|
-
this.
|
|
31
|
+
this._onSizeChange = (e) => {
|
|
32
|
+
const key = this.itemType == 'rows' ? 'height' : 'width';
|
|
29
33
|
if (e.value == null || e.value === '')
|
|
30
|
-
delete this.themeItem
|
|
34
|
+
delete this.themeItem[key];
|
|
31
35
|
else
|
|
32
|
-
this.themeItem
|
|
36
|
+
this.themeItem[key] = Number(e.value);
|
|
33
37
|
this._dispatchChange();
|
|
34
38
|
};
|
|
35
39
|
this.render = () => html `
|
|
@@ -65,34 +69,44 @@ let ThemeItemEditor = class ThemeItemEditor extends OmegaComponent {
|
|
|
65
69
|
</div>
|
|
66
70
|
|
|
67
71
|
${this.itemType != 'cells' ? html `
|
|
68
|
-
<div class="row"
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
72
|
+
<div class="row section">
|
|
73
|
+
<div>${msg('Conditions')}</div>
|
|
74
|
+
<og-dropdown-menu
|
|
75
|
+
noCaret
|
|
76
|
+
dynamicWidth
|
|
77
|
+
alignment="right"
|
|
78
|
+
color="transparent"
|
|
79
|
+
.items="${matchProperties.map(property => ({
|
|
80
|
+
key: property,
|
|
81
|
+
value: msg(property.charAt(0).toUpperCase() + property.slice(1)),
|
|
82
|
+
exec: () => this.addCondition(property)
|
|
83
|
+
}))}">
|
|
84
|
+
<div slot="label"><og-icon icon="plus"></og-icon></div>
|
|
85
|
+
</og-dropdown-menu>
|
|
81
86
|
</div>
|
|
82
87
|
|
|
83
|
-
|
|
84
|
-
<
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
${map(this.getMatchItems(), (match, i) => html `
|
|
89
|
+
<div class="row">
|
|
90
|
+
<label>${msg(match.property.charAt(0).toUpperCase() + match.property.slice(1))}</label>
|
|
91
|
+
<og-input
|
|
92
|
+
style="text-align: left"
|
|
93
|
+
.value="${this.formatConditionValue(match.value)}"
|
|
94
|
+
@change="${(e) => this._onConditionChange(i, e.value)}">
|
|
95
|
+
</og-input>
|
|
96
|
+
<og-button
|
|
97
|
+
icon="trash"
|
|
98
|
+
color="transparent"
|
|
99
|
+
style="flex: 0 0 20px; color: red"
|
|
100
|
+
@click="${() => this.removeCondition(i)}">
|
|
101
|
+
</og-button>
|
|
102
|
+
</div>
|
|
103
|
+
`)}
|
|
90
104
|
|
|
91
105
|
<div class="row">
|
|
92
106
|
<label>${msg(this.itemType == 'rows' ? 'Height' : 'Width')}</label>
|
|
93
107
|
<og-numericinput buttons min="0"
|
|
94
108
|
.value="${this.itemType == 'rows' ? this.themeItem?.height : this.themeItem?.width}"
|
|
95
|
-
@change="${
|
|
109
|
+
@change="${this._onSizeChange}">
|
|
96
110
|
</og-numericinput>
|
|
97
111
|
</div>
|
|
98
112
|
` : ''}
|
|
@@ -135,13 +149,54 @@ let ThemeItemEditor = class ThemeItemEditor extends OmegaComponent {
|
|
|
135
149
|
this.requestUpdate();
|
|
136
150
|
this.ruleEditor?.requestUpdate();
|
|
137
151
|
}
|
|
138
|
-
/**
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
152
|
+
/**
|
|
153
|
+
* Conditions of the item as a list of match items. The legacy root matchers
|
|
154
|
+
* are shown converted with their original semantics (index wins over level,
|
|
155
|
+
* the name filters on top) and become themeItem.matches on the first edit.
|
|
156
|
+
*/
|
|
157
|
+
getMatchItems() {
|
|
158
|
+
const item = this.themeItem;
|
|
159
|
+
if (item.matches)
|
|
160
|
+
return Array.isArray(item.matches) ? item.matches : [item.matches];
|
|
161
|
+
const items = [];
|
|
162
|
+
if (item.index > -1)
|
|
163
|
+
items.push({ property: 'index', value: item.index });
|
|
164
|
+
else if (item.level > -1)
|
|
165
|
+
items.push({ property: 'level', value: item.level });
|
|
166
|
+
if (item.name)
|
|
167
|
+
items.push({ property: 'name', value: item.name });
|
|
168
|
+
return items;
|
|
169
|
+
}
|
|
170
|
+
commitMatchItems(items) {
|
|
171
|
+
this.themeItem.matches = items;
|
|
172
|
+
delete this.themeItem.name;
|
|
173
|
+
delete this.themeItem.level;
|
|
174
|
+
delete this.themeItem.index;
|
|
144
175
|
this._dispatchChange();
|
|
176
|
+
this.requestUpdate();
|
|
177
|
+
}
|
|
178
|
+
addCondition(property) {
|
|
179
|
+
this.commitMatchItems([...this.getMatchItems(), { property, value: property == 'name' ? '' : 0 }]);
|
|
180
|
+
}
|
|
181
|
+
removeCondition(index) {
|
|
182
|
+
this.commitMatchItems(this.getMatchItems().filter((_, i) => i != index));
|
|
183
|
+
}
|
|
184
|
+
/** comma-separated input = OR of the values; an empty input removes the condition */
|
|
185
|
+
_onConditionChange(index, raw) {
|
|
186
|
+
const items = [...this.getMatchItems()];
|
|
187
|
+
const property = items[index].property;
|
|
188
|
+
const parts = String(raw ?? '').split(',').map(part => part.trim()).filter(part => part !== '');
|
|
189
|
+
const values = property == 'name' ? parts : parts.map(Number).filter(value => !isNaN(value));
|
|
190
|
+
if (!values.length) {
|
|
191
|
+
this.removeCondition(index);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
items[index] = { property, value: values.length == 1 ? values[0] : values };
|
|
195
|
+
this.commitMatchItems(items);
|
|
196
|
+
}
|
|
197
|
+
formatConditionValue(value) {
|
|
198
|
+
const format = (item) => item instanceof RegExp ? `/${item.source}/` : String(item ?? '');
|
|
199
|
+
return Array.isArray(value) ? value.map(format).join(', ') : format(value);
|
|
145
200
|
}
|
|
146
201
|
};
|
|
147
202
|
ThemeItemEditor.styles = [OmegaComponent.styles, css `
|
|
@@ -189,6 +244,16 @@ ThemeItemEditor.styles = [OmegaComponent.styles, css `
|
|
|
189
244
|
display: flex;
|
|
190
245
|
flex-direction: row;
|
|
191
246
|
}
|
|
247
|
+
|
|
248
|
+
.section {
|
|
249
|
+
display: flex;
|
|
250
|
+
flex-direction: row;
|
|
251
|
+
align-items: center;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
.section > div {
|
|
255
|
+
flex: 1;
|
|
256
|
+
}
|
|
192
257
|
`];
|
|
193
258
|
__decorate([
|
|
194
259
|
property({ type: Number })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"themeItemEditor.js","sourceRoot":"","sources":["../../../src/ui/editors/themeItemEditor.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,EAAoB,cAAc,EAAE,MAAM,iBA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C,IAAI,CAAC,SAAS,CAAC,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,IAAI,EAAW,CAAC;QAEhE,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,IAAI,CAAC,UAAU,EAAE,aAAa,EAAE,CAAC;IAClC,CAAC;IAWD,8FAA8F;IAC9F,gBAAgB,CAAC,GAAqC,EAAE,KAAyB;QAChF,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,EAAE;YAAE,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;;YACzD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QACzC,IAAI,CAAC,eAAe,EAAE,CAAC;IACxB,CAAC;;AA3EM,sBAAM,GAAG,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6C1C,CAAC,AA7CW,CA6CV;AAjEH;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;8CACX;AAGd;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;kDACiB;AAG1C;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;iDACD;AAGxB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;+CACL;AAGpB;IADC,KAAK,CAAC,cAAc,CAAC;mDACE;AAGxB;IADC,KAAK,CAAC,sBAAsB,CAAC;mDACP;AAGvB;IADC,KAAK,CAAC,uBAAuB,CAAC;oDACN;AArBb,eAAe;IAD3B,aAAa,CAAC,qBAAqB,CAAC;GACxB,eAAe,CAmM3B","sourcesContent":["import { customElement, property, query } from 'lit/decorators.js';\nimport { ConditionalFormatType, Style, ThemeColumnItem, ThemeItem, ThemeRowItem } from '@omegagrid/grid';\nimport { css, html } from 'lit';\nimport { events, MenuItem, OmegaComponent } from '@omegagrid/core';\nimport { msg } from '@omegagrid/localize';\nimport { RuleEditor } from './ruleEditor';\nimport { StyleEditor } from './styleEditor';\nimport { ThemeEditor } from './themeEditor';\n\ntype ThemeItemType = 'rows'|'columns'|'cells';\n\nconst ruleTypes: MenuItem[] = [\n\t{key: null, value: 'Static style'},\n\t{key: 'formula', value: 'Formula'},\n\t{key: 'scale', value: 'Scale'},\n\t{key: 'bar', value: 'Data Bar'},\n\t{key: 'icon', value: 'Icon Set'},\n];\n\n@customElement('og-editor-themeitem')\nexport class ThemeItemEditor extends OmegaComponent {\n\t\n\t@property({type: Number})\n\tindex: number;\n\n\t@property({type: Object})\n\tthemeItem: ThemeColumnItem & ThemeRowItem;\n\n\t@property({type: String})\n\titemType: ThemeItemType;\n\n\t@property({type: Object})\n\teditor: ThemeEditor;\n\n\t@query('.move-handle')\n\tmoveHandle: HTMLElement;\n\n\t@query('og-editor-ruleeditor')\n\truleEditor: RuleEditor;\n\n\t@query('og-editor-styleeditor')\n\tstyleEditor: StyleEditor;\n\n\tstatic styles = [OmegaComponent.styles, css`\n\t\t:host {\n\t\t\tline-height: 22px;\n\t\t}\n\n\t\t.row {\n\t\t\tdisplay: flex;\n\t\t\tflex-direction: row;\n\t\t\tmargin: 2px 0;\n\t\t\talign-items: center;\n\t\t}\n\n\t\tlabel {\n\t\t\tflex: 0 60px;\n\t\t\ttext-align: right;\n\t\t\tmargin-right: 10px;\n\t\t}\n\n\t\tog-dropdown-list, og-dropdown-menu, og-editor-ruleeditor {\n\t\t\tline-height: 16px;\n\t\t}\n\n\t\tog-numericinput, og-input {\n\t\t\tflex: 1;\n\t\t\tdisplay: block;\n\t\t\twidth: 100%;\n\t\t\tline-height: 20px;\n\t\t\ttext-align: center;\n\t\t}\n\n\t\t.move-handle {\n\t\t\tcursor: move;\n\t\t}\n\n\t\tog-dropdown-list {\n\t\t\tflex: 1;\n\t\t}\n\n\t\t.header {\n\t\t\tpadding-left: 5px;\n\t\t\tborder-top: 1px solid var(--og-border-color);\n\t\t\tborder-bottom: 1px solid var(--og-border-color);\n\t\t\tdisplay: flex;\n\t\t\tflex-direction: row;\n\t\t}\n\t`];\n\n\twillUpdate() {\n\t\tthis.themeItem = this.themeItem || {} as ThemeItem;\n\t\tthis.updateRuleType(this.themeItem.type);\n\t}\n\n\tupdateRuleType(type: ConditionalFormatType) {\n\t\tthis.themeItem.type = type;\n\t\tif (type) delete this.themeItem.style;\n\t\telse this.themeItem.style = this.themeItem.style || {} as Style;\n\n\t\tthis.requestUpdate();\n\t\tthis.ruleEditor?.requestUpdate();\n\t}\n\n\t_onStyleChange = (e: events.ChangeEvent<Style>) => {\n\t\tthis.themeItem.style = e.value;\n\t\tthis._dispatchChange();\n\t}\n\n\t_dispatchChange = () => {\n\t\tthis.editor?.dispatchThemeChange();\n\t}\n\n\t/** empty input deletes the property - the matchers test level/index > -1 and a truthy name */\n\t_onMatcherChange(key: 'level'|'index'|'height'|'width', value: number|string|null) {\n\t\tif (value == null || value === '') delete this.themeItem[key];\n\t\telse this.themeItem[key] = Number(value);\n\t\tthis._dispatchChange();\n\t}\n\n\t_onNameChange = (e: events.ChangeEvent<string>) => {\n\t\tif (e.value == null || e.value === '') delete this.themeItem.name;\n\t\telse this.themeItem.name = e.value;\n\t\tthis._dispatchChange();\n\t}\n\n\trender = () => html`\n\t\t<div class=\"header\">\n\t\t\t<div style=\"flex: 1\" class=\"move-handle\">${msg('Rule')} #${this.index + 1}</div>\n\n\t\t\t<div>\n\t\t\t\t<og-dropdown-menu\n\t\t\t\t\tnoCaret\n\t\t\t\t\tdynamicWidth\n\t\t\t\t\talignment=\"right\"\n\t\t\t\t\tcolor=\"transparent\"\n\t\t\t\t\t.items=\"${[{\n\t\t\t\t\t\tkey: 'moveUp',\n\t\t\t\t\t\tvalue: msg('Move up'),\n\t\t\t\t\t\ticon: 'arrow-up',\n\t\t\t\t\t\texec: () => this.editor.moveItemUp(this.index, this.itemType)\n\t\t\t\t\t}, {\n\t\t\t\t\t\tkey: 'moveDown',\n\t\t\t\t\t\tvalue: msg('Move down'),\n\t\t\t\t\t\ticon: 'arrow-down',\n\t\t\t\t\t\texec: () => this.editor.moveItemDown(this.index, this.itemType)\n\t\t\t\t\t}, {\n\t\t\t\t\t\tkey: 'delete',\n\t\t\t\t\t\tvalue: msg('Delete'),\n\t\t\t\t\t\ticon: 'trash',\n\t\t\t\t\t\tcolor: 'red',\n\t\t\t\t\t\texec: () => this.editor.deleteItem(this.index, this.itemType)\n\t\t\t\t\t}]}\">\n\t\t\t\t\t<div slot=\"label\"><og-icon icon=\"ellipsis\"></og-icon></div>\n\t\t\t\t</og-dropdown-menu>\n\t\t\t</div>\n\t\t</div>\n\n\t\t${this.itemType != 'cells' ? html`\n\t\t\t<div class=\"row\">${msg('Conditions')}</div>\n\n\t\t\t<div class=\"row\">\n\t\t\t\t<label>${msg('Level')}</label>\n\t\t\t\t<og-numericinput buttons min=\"0\"\n\t\t\t\t\t.value=\"${this.themeItem?.level}\"\n\t\t\t\t\t@change=\"${(e: events.ChangeEvent<number>) => this._onMatcherChange('level', e.value)}\">\n\t\t\t\t</og-numericinput>\n\t\t\t\t<label>${msg('Index')}</label>\n\t\t\t\t<og-numericinput buttons min=\"0\"\n\t\t\t\t\t.value=\"${this.themeItem?.index}\"\n\t\t\t\t\t@change=\"${(e: events.ChangeEvent<number>) => this._onMatcherChange('index', e.value)}\">\n\t\t\t\t</og-numericinput>\n\t\t\t</div>\n\n\t\t\t<div class=\"row\">\n\t\t\t\t<label>${msg('Name')}</label>\n\t\t\t\t<og-input\n\t\t\t\t\t.value=\"${this.themeItem?.name ?? ''}\"\n\t\t\t\t\t@change=\"${this._onNameChange}\">\n\t\t\t\t</og-input>\n\t\t\t</div>\n\n\t\t\t<div class=\"row\">\n\t\t\t\t<label>${msg(this.itemType == 'rows' ? 'Height' : 'Width')}</label>\n\t\t\t\t<og-numericinput buttons min=\"0\"\n\t\t\t\t\t.value=\"${this.itemType == 'rows' ? this.themeItem?.height : this.themeItem?.width}\"\n\t\t\t\t\t@change=\"${(e: events.ChangeEvent<number>) => this._onMatcherChange(this.itemType == 'rows' ? 'height' : 'width', e.value)}\">\n\t\t\t\t</og-numericinput>\n\t\t\t</div>\n\t\t` : ''}\n\n\t\t<div class=\"row\">${msg('Style definition')}</div>\n\n\t\t<div class=\"row\">\n\t\t\t<og-dropdown-list\n\t\t\t\t.value = \"${this.themeItem?.type ?? null}\"\n\t\t\t\t.items=\"${ruleTypes}\"\n\t\t\t\t@change=\"${(e: events.ChangeEvent<ConditionalFormatType>) => { this.updateRuleType(e.value); this._dispatchChange(); }}\">\n\t\t\t</og-dropdown-list>\n\t\t</div>\n\n\t\t<div>\n\t\t\t${this.themeItem?.type ? html`\n\t\t\t\t<og-editor-ruleeditor \n\t\t\t\t\t.format=\"${this.themeItem}\"\n\t\t\t\t\t@change=\"${this._dispatchChange}\">\n\t\t\t\t</og-editor-ruleeditor>\n\t\t\t`: html`\n\t\t\t\t<og-editor-styleeditor \n\t\t\t\t\t@change=\"${this._onStyleChange}\"\n\t\t\t\t\t.data=\"${this.themeItem.style}\">\n\t\t\t\t</og-editor-styleeditor>\n\t\t\t`}\n\t\t</div>\n\t`;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"themeItemEditor.js","sourceRoot":"","sources":["../../../src/ui/editors/themeItemEditor.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,EAAoB,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAE,GAAG,EAAE,MAAM,4BAA4B,CAAC;AAOjD,MAAM,SAAS,GAAe;IAC7B,EAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,cAAc,EAAC;IAClC,EAA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;AAG1C;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;iDACD;AAGxB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;+CACL;AAGpB;IADC,KAAK,CAAC,cAAc,CAAC;mDACE;AAGxB;IADC,KAAK,CAAC,sBAAsB,CAAC;mDACP;AAGvB;IADC,KAAK,CAAC,uBAAuB,CAAC;oDACN;AArBb,eAAe;IAD3B,aAAa,CAAC,qBAAqB,CAAC;GACxB,eAAe,CAuQ3B","sourcesContent":["import { customElement, property, query } from 'lit/decorators.js';\nimport { ConditionalFormatType, MatchItem, MatchValue, Style, ThemeColumnItem, ThemeItem, ThemeRowItem } from '@omegagrid/grid';\nimport { css, html } from 'lit';\nimport { events, MenuItem, OmegaComponent } from '@omegagrid/core';\nimport { msg } from '@omegagrid/localize';\nimport { map } from 'lit-html/directives/map.js';\nimport { RuleEditor } from './ruleEditor';\nimport { StyleEditor } from './styleEditor';\nimport { ThemeEditor } from './themeEditor';\n\ntype ThemeItemType = 'rows'|'columns'|'cells';\n\nconst ruleTypes: MenuItem[] = [\n\t{key: null, value: 'Static style'},\n\t{key: 'formula', value: 'Formula'},\n\t{key: 'scale', value: 'Scale'},\n\t{key: 'bar', value: 'Data Bar'},\n\t{key: 'icon', value: 'Icon Set'},\n];\n\n/** node properties offered by the add-condition dropdown */\nconst matchProperties = ['name', 'level', 'index'];\n\n@customElement('og-editor-themeitem')\nexport class ThemeItemEditor extends OmegaComponent {\n\t\n\t@property({type: Number})\n\tindex: number;\n\n\t@property({type: Object})\n\tthemeItem: ThemeColumnItem & ThemeRowItem;\n\n\t@property({type: String})\n\titemType: ThemeItemType;\n\n\t@property({type: Object})\n\teditor: ThemeEditor;\n\n\t@query('.move-handle')\n\tmoveHandle: HTMLElement;\n\n\t@query('og-editor-ruleeditor')\n\truleEditor: RuleEditor;\n\n\t@query('og-editor-styleeditor')\n\tstyleEditor: StyleEditor;\n\n\tstatic styles = [OmegaComponent.styles, css`\n\t\t:host {\n\t\t\tline-height: 22px;\n\t\t}\n\n\t\t.row {\n\t\t\tdisplay: flex;\n\t\t\tflex-direction: row;\n\t\t\tmargin: 2px 0;\n\t\t\talign-items: center;\n\t\t}\n\n\t\tlabel {\n\t\t\tflex: 0 60px;\n\t\t\ttext-align: right;\n\t\t\tmargin-right: 10px;\n\t\t}\n\n\t\tog-dropdown-list, og-dropdown-menu, og-editor-ruleeditor {\n\t\t\tline-height: 16px;\n\t\t}\n\n\t\tog-numericinput, og-input {\n\t\t\tflex: 1;\n\t\t\tdisplay: block;\n\t\t\twidth: 100%;\n\t\t\tline-height: 20px;\n\t\t\ttext-align: center;\n\t\t}\n\n\t\t.move-handle {\n\t\t\tcursor: move;\n\t\t}\n\n\t\tog-dropdown-list {\n\t\t\tflex: 1;\n\t\t}\n\n\t\t.header {\n\t\t\tpadding-left: 5px;\n\t\t\tborder-top: 1px solid var(--og-border-color);\n\t\t\tborder-bottom: 1px solid var(--og-border-color);\n\t\t\tdisplay: flex;\n\t\t\tflex-direction: row;\n\t\t}\n\n\t\t.section {\n\t\t\tdisplay: flex;\n\t\t\tflex-direction: row;\n\t\t\talign-items: center;\n\t\t}\n\n\t\t.section > div {\n\t\t\tflex: 1;\n\t\t}\n\t`];\n\n\twillUpdate() {\n\t\tthis.themeItem = this.themeItem || {} as ThemeItem;\n\t\tthis.updateRuleType(this.themeItem.type);\n\t}\n\n\tupdateRuleType(type: ConditionalFormatType) {\n\t\tthis.themeItem.type = type;\n\t\tif (type) delete this.themeItem.style;\n\t\telse this.themeItem.style = this.themeItem.style || {} as Style;\n\n\t\tthis.requestUpdate();\n\t\tthis.ruleEditor?.requestUpdate();\n\t}\n\n\t_onStyleChange = (e: events.ChangeEvent<Style>) => {\n\t\tthis.themeItem.style = e.value;\n\t\tthis._dispatchChange();\n\t}\n\n\t_dispatchChange = () => {\n\t\tthis.editor?.dispatchThemeChange();\n\t}\n\n\t/**\n\t * Conditions of the item as a list of match items. The legacy root matchers\n\t * are shown converted with their original semantics (index wins over level,\n\t * the name filters on top) and become themeItem.matches on the first edit.\n\t */\n\tgetMatchItems(): MatchItem[] {\n\t\tconst item = this.themeItem;\n\t\tif (item.matches) return Array.isArray(item.matches) ? item.matches : [item.matches];\n\n\t\tconst items: MatchItem[] = [];\n\t\tif (item.index > -1) items.push({property: 'index', value: item.index});\n\t\telse if (item.level > -1) items.push({property: 'level', value: item.level});\n\t\tif (item.name) items.push({property: 'name', value: item.name as MatchValue});\n\t\treturn items;\n\t}\n\n\tprivate commitMatchItems(items: MatchItem[]) {\n\t\tthis.themeItem.matches = items;\n\t\tdelete this.themeItem.name;\n\t\tdelete this.themeItem.level;\n\t\tdelete this.themeItem.index;\n\t\tthis._dispatchChange();\n\t\tthis.requestUpdate();\n\t}\n\n\taddCondition(property: string) {\n\t\tthis.commitMatchItems([...this.getMatchItems(), {property, value: property == 'name' ? '' : 0}]);\n\t}\n\n\tremoveCondition(index: number) {\n\t\tthis.commitMatchItems(this.getMatchItems().filter((_, i) => i != index));\n\t}\n\n\t/** comma-separated input = OR of the values; an empty input removes the condition */\n\t_onConditionChange(index: number, raw: string) {\n\t\tconst items = [...this.getMatchItems()];\n\t\tconst property = items[index].property;\n\t\tconst parts = String(raw ?? '').split(',').map(part => part.trim()).filter(part => part !== '');\n\t\tconst values = property == 'name' ? parts : parts.map(Number).filter(value => !isNaN(value));\n\n\t\tif (!values.length) {\n\t\t\tthis.removeCondition(index);\n\t\t\treturn;\n\t\t}\n\n\t\titems[index] = {property, value: values.length == 1 ? values[0] : values};\n\t\tthis.commitMatchItems(items);\n\t}\n\n\tprivate formatConditionValue(value: MatchValue|MatchValue[]): string {\n\t\tconst format = (item: MatchValue) => item instanceof RegExp ? `/${item.source}/` : String(item ?? '');\n\t\treturn Array.isArray(value) ? value.map(format).join(', ') : format(value);\n\t}\n\n\t_onSizeChange = (e: events.ChangeEvent<number>) => {\n\t\tconst key = this.itemType == 'rows' ? 'height' : 'width';\n\t\tif (e.value == null || e.value as unknown === '') delete this.themeItem[key];\n\t\telse this.themeItem[key] = Number(e.value);\n\t\tthis._dispatchChange();\n\t}\n\n\trender = () => html`\n\t\t<div class=\"header\">\n\t\t\t<div style=\"flex: 1\" class=\"move-handle\">${msg('Rule')} #${this.index + 1}</div>\n\n\t\t\t<div>\n\t\t\t\t<og-dropdown-menu\n\t\t\t\t\tnoCaret\n\t\t\t\t\tdynamicWidth\n\t\t\t\t\talignment=\"right\"\n\t\t\t\t\tcolor=\"transparent\"\n\t\t\t\t\t.items=\"${[{\n\t\t\t\t\t\tkey: 'moveUp',\n\t\t\t\t\t\tvalue: msg('Move up'),\n\t\t\t\t\t\ticon: 'arrow-up',\n\t\t\t\t\t\texec: () => this.editor.moveItemUp(this.index, this.itemType)\n\t\t\t\t\t}, {\n\t\t\t\t\t\tkey: 'moveDown',\n\t\t\t\t\t\tvalue: msg('Move down'),\n\t\t\t\t\t\ticon: 'arrow-down',\n\t\t\t\t\t\texec: () => this.editor.moveItemDown(this.index, this.itemType)\n\t\t\t\t\t}, {\n\t\t\t\t\t\tkey: 'delete',\n\t\t\t\t\t\tvalue: msg('Delete'),\n\t\t\t\t\t\ticon: 'trash',\n\t\t\t\t\t\tcolor: 'red',\n\t\t\t\t\t\texec: () => this.editor.deleteItem(this.index, this.itemType)\n\t\t\t\t\t}]}\">\n\t\t\t\t\t<div slot=\"label\"><og-icon icon=\"ellipsis\"></og-icon></div>\n\t\t\t\t</og-dropdown-menu>\n\t\t\t</div>\n\t\t</div>\n\n\t\t${this.itemType != 'cells' ? html`\n\t\t\t<div class=\"row section\">\n\t\t\t\t<div>${msg('Conditions')}</div>\n\t\t\t\t<og-dropdown-menu\n\t\t\t\t\tnoCaret\n\t\t\t\t\tdynamicWidth\n\t\t\t\t\talignment=\"right\"\n\t\t\t\t\tcolor=\"transparent\"\n\t\t\t\t\t.items=\"${matchProperties.map(property => ({\n\t\t\t\t\t\tkey: property,\n\t\t\t\t\t\tvalue: msg(property.charAt(0).toUpperCase() + property.slice(1)),\n\t\t\t\t\t\texec: () => this.addCondition(property)\n\t\t\t\t\t}))}\">\n\t\t\t\t\t<div slot=\"label\"><og-icon icon=\"plus\"></og-icon></div>\n\t\t\t\t</og-dropdown-menu>\n\t\t\t</div>\n\n\t\t\t${map(this.getMatchItems(), (match, i) => html`\n\t\t\t\t<div class=\"row\">\n\t\t\t\t\t<label>${msg(match.property.charAt(0).toUpperCase() + match.property.slice(1))}</label>\n\t\t\t\t\t<og-input\n\t\t\t\t\t\tstyle=\"text-align: left\"\n\t\t\t\t\t\t.value=\"${this.formatConditionValue(match.value)}\"\n\t\t\t\t\t\t@change=\"${(e: events.ChangeEvent<string>) => this._onConditionChange(i, e.value)}\">\n\t\t\t\t\t</og-input>\n\t\t\t\t\t<og-button\n\t\t\t\t\t\ticon=\"trash\"\n\t\t\t\t\t\tcolor=\"transparent\"\n\t\t\t\t\t\tstyle=\"flex: 0 0 20px; color: red\"\n\t\t\t\t\t\t@click=\"${() => this.removeCondition(i)}\">\n\t\t\t\t\t</og-button>\n\t\t\t\t</div>\n\t\t\t`)}\n\n\t\t\t<div class=\"row\">\n\t\t\t\t<label>${msg(this.itemType == 'rows' ? 'Height' : 'Width')}</label>\n\t\t\t\t<og-numericinput buttons min=\"0\"\n\t\t\t\t\t.value=\"${this.itemType == 'rows' ? this.themeItem?.height : this.themeItem?.width}\"\n\t\t\t\t\t@change=\"${this._onSizeChange}\">\n\t\t\t\t</og-numericinput>\n\t\t\t</div>\n\t\t` : ''}\n\n\t\t<div class=\"row\">${msg('Style definition')}</div>\n\n\t\t<div class=\"row\">\n\t\t\t<og-dropdown-list\n\t\t\t\t.value = \"${this.themeItem?.type ?? null}\"\n\t\t\t\t.items=\"${ruleTypes}\"\n\t\t\t\t@change=\"${(e: events.ChangeEvent<ConditionalFormatType>) => { this.updateRuleType(e.value); this._dispatchChange(); }}\">\n\t\t\t</og-dropdown-list>\n\t\t</div>\n\n\t\t<div>\n\t\t\t${this.themeItem?.type ? html`\n\t\t\t\t<og-editor-ruleeditor \n\t\t\t\t\t.format=\"${this.themeItem}\"\n\t\t\t\t\t@change=\"${this._dispatchChange}\">\n\t\t\t\t</og-editor-ruleeditor>\n\t\t\t`: html`\n\t\t\t\t<og-editor-styleeditor \n\t\t\t\t\t@change=\"${this._onStyleChange}\"\n\t\t\t\t\t.data=\"${this.themeItem.style}\">\n\t\t\t\t</og-editor-styleeditor>\n\t\t\t`}\n\t\t</div>\n\t`;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omegagrid/editor",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.93",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"description": "Spreadsheet editor",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -27,15 +27,15 @@
|
|
|
27
27
|
"_prepublish": "yarn test && yarn lint"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@omegagrid/commands": "^0.10.
|
|
31
|
-
"@omegagrid/core": "^0.10.
|
|
32
|
-
"@omegagrid/form": "^0.10.
|
|
33
|
-
"@omegagrid/grid": "^0.10.
|
|
34
|
-
"@omegagrid/localize": "^0.10.
|
|
35
|
-
"@omegagrid/statusbar": "^0.10.
|
|
36
|
-
"@omegagrid/tabs": "^0.10.
|
|
37
|
-
"@omegagrid/toolbar": "^0.10.
|
|
38
|
-
"@omegagrid/tree": "^0.10.
|
|
30
|
+
"@omegagrid/commands": "^0.10.93",
|
|
31
|
+
"@omegagrid/core": "^0.10.93",
|
|
32
|
+
"@omegagrid/form": "^0.10.93",
|
|
33
|
+
"@omegagrid/grid": "^0.10.93",
|
|
34
|
+
"@omegagrid/localize": "^0.10.93",
|
|
35
|
+
"@omegagrid/statusbar": "^0.10.93",
|
|
36
|
+
"@omegagrid/tabs": "^0.10.93",
|
|
37
|
+
"@omegagrid/toolbar": "^0.10.93",
|
|
38
|
+
"@omegagrid/tree": "^0.10.93",
|
|
39
39
|
"lit": "^3.1.1",
|
|
40
40
|
"lit-html": "^3.1.1",
|
|
41
41
|
"ts-debounce": "^4.0.0"
|