@node-projects/web-component-designer 0.0.183 → 0.0.185
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/elements/helper/Helper.d.ts +2 -0
- package/dist/elements/helper/Helper.js +10 -0
- package/dist/elements/helper/NpmPackageLoader.d.ts +17 -0
- package/dist/elements/helper/NpmPackageLoader.js +207 -0
- package/dist/elements/services/designerAddons/IDesignerAddonJson.d.ts +6 -0
- package/dist/elements/services/{propertiesService/IProperty copy.js → designerAddons/IDesignerAddonJson.js} +0 -0
- package/dist/elements/services/elementsService/WebcomponentManifestElementsService.js +2 -1
- package/dist/elements/services/manifestParsers/WebcomponentManifestParserService.js +3 -2
- package/dist/elements/services/propertiesService/services/WebcomponentManifestPropertiesService.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +4 -4
- package/dist/elements/controls/ThicknessEditor copy.d.ts +0 -33
- package/dist/elements/controls/ThicknessEditor copy.js +0 -145
- package/dist/elements/helper/IndentedTextWriter copy.d.ts +0 -14
- package/dist/elements/helper/IndentedTextWriter copy.js +0 -34
- package/dist/elements/helper/SimpleTextWriter copy.d.ts +0 -12
- package/dist/elements/helper/SimpleTextWriter copy.js +0 -26
- package/dist/elements/services/htmlParserService/AbstractClassElementParserService.d.ts +0 -12
- package/dist/elements/services/htmlParserService/AbstractClassElementParserService.js +0 -120
- package/dist/elements/services/htmlParserService/LitElementParserService copy.d.ts +0 -12
- package/dist/elements/services/htmlParserService/LitElementParserService copy.js +0 -120
- package/dist/elements/services/propertiesService/IProperty copy.d.ts +0 -22
- package/dist/elements/services/propertiesService/IPropertyGroupsService.d.ts +0 -8
- package/dist/elements/services/propertiesService/IPropertyGroupsService.js +0 -1
- package/dist/elements/services/propertiesService/PropertyGroupsService.d.ts +0 -17
- package/dist/elements/services/propertiesService/PropertyGroupsService.js +0 -29
- package/dist/elements/services/propertiesService/propertyEditors/MetricsEditor.d.ts +0 -0
- package/dist/elements/services/propertiesService/propertyEditors/MetricsEditor.js +0 -1
- package/dist/elements/services/propertiesService/services/AbstractBasePropertiesService.d.ts +0 -7
- package/dist/elements/services/propertiesService/services/AbstractBasePropertiesService.js +0 -44
- package/dist/elements/services/propertiesService/services/CssCurrentPropertiesService copy.d.ts +0 -18
- package/dist/elements/services/propertiesService/services/CssCurrentPropertiesService copy.js +0 -221
- package/dist/elements/services/propertiesService/services/CssPropertiesService copy.d.ts +0 -18
- package/dist/elements/services/propertiesService/services/CssPropertiesService copy.js +0 -221
- package/dist/elements/services/propertiesService/services/UnkownElementPropertiesService.d.ts +0 -20
- package/dist/elements/services/propertiesService/services/UnkownElementPropertiesService.js +0 -162
- package/dist/elements/services/stylesheetService/CssTreeStylesheetService copy.d.ts +0 -48
- package/dist/elements/services/stylesheetService/CssTreeStylesheetService copy.js +0 -185
- package/dist/elements/services/stylesheetService/StylesheetService.d.ts +0 -28
- package/dist/elements/services/stylesheetService/StylesheetService.js +0 -108
- package/dist/elements/services/undoService/transactionItems/PropertyChangeAction.d.ts +0 -15
- package/dist/elements/services/undoService/transactionItems/PropertyChangeAction.js +0 -36
- package/dist/elements/widgets/codeView/code-view-monaco copy.d.ts +0 -25
- package/dist/elements/widgets/codeView/code-view-monaco copy.js +0 -119
- package/dist/elements/widgets/designerView/ButtonSeperatorProvider.d.ts +0 -8
- package/dist/elements/widgets/designerView/ButtonSeperatorProvider.js +0 -11
- package/dist/elements/widgets/designerView/IDesignViewConfigButtonsProvider.d.ts +0 -5
- package/dist/elements/widgets/designerView/IDesignViewConfigButtonsProvider.js +0 -1
- package/dist/elements/widgets/designerView/extensions/FlexboxExtensionDesignViewConfigButtons.d.ts +0 -6
- package/dist/elements/widgets/designerView/extensions/FlexboxExtensionDesignViewConfigButtons.js +0 -22
- package/dist/elements/widgets/designerView/extensions/GridExtension copy.d.ts +0 -10
- package/dist/elements/widgets/designerView/extensions/GridExtension copy.js +0 -30
- package/dist/elements/widgets/designerView/extensions/GridExtensionDesignViewConfigButtons copy.d.ts +0 -6
- package/dist/elements/widgets/designerView/extensions/GridExtensionDesignViewConfigButtons copy.js +0 -21
- package/dist/elements/widgets/designerView/extensions/GridExtensionDesignViewConfigButtons.d.ts +0 -6
- package/dist/elements/widgets/designerView/extensions/GridExtensionDesignViewConfigButtons.js +0 -22
- package/dist/elements/widgets/designerView/extensions/GridExtensionProvider copy.d.ts +0 -11
- package/dist/elements/widgets/designerView/extensions/GridExtensionProvider copy.js +0 -18
- package/dist/elements/widgets/designerView/extensions/InvisibleDivExtension.d.ts +0 -11
- package/dist/elements/widgets/designerView/extensions/InvisibleDivExtension.js +0 -19
- package/dist/elements/widgets/designerView/extensions/InvisibleDivExtensionDesignViewConfigButtons.d.ts +0 -6
- package/dist/elements/widgets/designerView/extensions/InvisibleDivExtensionDesignViewConfigButtons.js +0 -22
- package/dist/elements/widgets/designerView/extensions/InvisibleDivExtensionProvider.d.ts +0 -11
- package/dist/elements/widgets/designerView/extensions/InvisibleDivExtensionProvider.js +0 -20
- package/dist/elements/widgets/designerView/extensions/InvisibleElementExtensionDesignViewConfigButtons.d.ts +0 -6
- package/dist/elements/widgets/designerView/extensions/InvisibleElementExtensionDesignViewConfigButtons.js +0 -22
- package/dist/elements/widgets/designerView/extensions/MouseOverExtension.d.ts +0 -11
- package/dist/elements/widgets/designerView/extensions/MouseOverExtension.js +0 -20
- package/dist/elements/widgets/designerView/extensions/MouseOverExtensionProvider.d.ts +0 -10
- package/dist/elements/widgets/designerView/extensions/MouseOverExtensionProvider.js +0 -13
- package/dist/elements/widgets/designerView/extensions/buttons/StylesheetServiceDesignViewConfigButtons copy.d.ts +0 -7
- package/dist/elements/widgets/designerView/extensions/buttons/StylesheetServiceDesignViewConfigButtons copy.js +0 -21
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
import { BindingTarget } from '../../../item/BindingTarget.js';
|
|
2
|
-
import { PropertyType } from '../PropertyType.js';
|
|
3
|
-
import { CommonPropertiesService } from './CommonPropertiesService.js';
|
|
4
|
-
import { RefreshMode } from '../IPropertiesService.js';
|
|
5
|
-
export class CssPropertiesService extends CommonPropertiesService {
|
|
6
|
-
getRefreshMode(designItem) {
|
|
7
|
-
return this.name == 'styles' ? RefreshMode.fullOnValueChange : RefreshMode.none;
|
|
8
|
-
}
|
|
9
|
-
layout = [
|
|
10
|
-
{
|
|
11
|
-
name: "display",
|
|
12
|
-
type: "list",
|
|
13
|
-
values: ["block", "inline", "inline-block", "flex", "inline-flex", "contents", "grid", "inline-grid", "inherit", "initial", "none"],
|
|
14
|
-
service: this,
|
|
15
|
-
propertyType: PropertyType.cssValue
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
name: "color",
|
|
19
|
-
type: "color",
|
|
20
|
-
service: this,
|
|
21
|
-
propertyType: PropertyType.cssValue
|
|
22
|
-
}, {
|
|
23
|
-
name: "background-color",
|
|
24
|
-
type: "color",
|
|
25
|
-
service: this,
|
|
26
|
-
propertyType: PropertyType.cssValue
|
|
27
|
-
}, {
|
|
28
|
-
name: "box-sizing",
|
|
29
|
-
type: "list",
|
|
30
|
-
values: ["border-box", "content-box"],
|
|
31
|
-
service: this,
|
|
32
|
-
propertyType: PropertyType.cssValue
|
|
33
|
-
}, {
|
|
34
|
-
name: "border",
|
|
35
|
-
type: "string",
|
|
36
|
-
default: "0px none rbg(0,0,0)",
|
|
37
|
-
service: this,
|
|
38
|
-
propertyType: PropertyType.cssValue
|
|
39
|
-
}, {
|
|
40
|
-
name: "box-shadow",
|
|
41
|
-
type: "string",
|
|
42
|
-
default: "none",
|
|
43
|
-
service: this,
|
|
44
|
-
propertyType: PropertyType.cssValue
|
|
45
|
-
}, {
|
|
46
|
-
name: "opacity",
|
|
47
|
-
type: "number",
|
|
48
|
-
min: 0,
|
|
49
|
-
max: 1,
|
|
50
|
-
step: 0.1,
|
|
51
|
-
service: this,
|
|
52
|
-
propertyType: PropertyType.cssValue
|
|
53
|
-
}, {
|
|
54
|
-
name: "metrics",
|
|
55
|
-
type: "metrics",
|
|
56
|
-
service: this,
|
|
57
|
-
propertyType: PropertyType.complex
|
|
58
|
-
}, {
|
|
59
|
-
name: "position",
|
|
60
|
-
type: "list",
|
|
61
|
-
values: ["static", "relative", "absolute"],
|
|
62
|
-
service: this,
|
|
63
|
-
propertyType: PropertyType.cssValue
|
|
64
|
-
}, {
|
|
65
|
-
name: "font-size",
|
|
66
|
-
type: "css-length",
|
|
67
|
-
service: this,
|
|
68
|
-
propertyType: PropertyType.cssValue
|
|
69
|
-
}, {
|
|
70
|
-
name: "font-weight",
|
|
71
|
-
type: "list",
|
|
72
|
-
values: ["normal", "bold", "100", "200", "300", "400", "500", "600", "700", "800", "900", "lighter", "bolder"],
|
|
73
|
-
service: this,
|
|
74
|
-
propertyType: PropertyType.cssValue
|
|
75
|
-
}
|
|
76
|
-
];
|
|
77
|
-
grid = [
|
|
78
|
-
{
|
|
79
|
-
name: "display",
|
|
80
|
-
type: "list",
|
|
81
|
-
values: ["block", "inline-block", "flex", "contents", "grid", "inherit", "initial", "none"],
|
|
82
|
-
service: this,
|
|
83
|
-
propertyType: PropertyType.cssValue
|
|
84
|
-
}, {
|
|
85
|
-
name: "position",
|
|
86
|
-
type: "list",
|
|
87
|
-
values: ["static", "relative", "absolute"],
|
|
88
|
-
service: this,
|
|
89
|
-
propertyType: PropertyType.cssValue
|
|
90
|
-
}, {
|
|
91
|
-
name: "grid-template-columns",
|
|
92
|
-
type: "string",
|
|
93
|
-
service: this,
|
|
94
|
-
propertyType: PropertyType.cssValue
|
|
95
|
-
}, {
|
|
96
|
-
name: "grid-template-rows",
|
|
97
|
-
type: "string",
|
|
98
|
-
service: this,
|
|
99
|
-
propertyType: PropertyType.cssValue
|
|
100
|
-
}, {
|
|
101
|
-
name: "column-gap",
|
|
102
|
-
type: "css-length",
|
|
103
|
-
service: this,
|
|
104
|
-
propertyType: PropertyType.cssValue
|
|
105
|
-
}, {
|
|
106
|
-
name: "row-gap",
|
|
107
|
-
type: "css-length",
|
|
108
|
-
service: this,
|
|
109
|
-
propertyType: PropertyType.cssValue
|
|
110
|
-
}, {
|
|
111
|
-
name: "align-content",
|
|
112
|
-
type: "img-list",
|
|
113
|
-
values: ["center", "space-between", "space-around", "space-evenly", "stretch"],
|
|
114
|
-
service: this,
|
|
115
|
-
propertyType: PropertyType.cssValue
|
|
116
|
-
}, {
|
|
117
|
-
name: "justify-content",
|
|
118
|
-
type: "img-list",
|
|
119
|
-
values: ["center", "start", "end", "space-between", "space-around", "space-evenly"],
|
|
120
|
-
service: this,
|
|
121
|
-
propertyType: PropertyType.cssValue
|
|
122
|
-
}, {
|
|
123
|
-
name: "align-items",
|
|
124
|
-
type: "img-list",
|
|
125
|
-
values: ["center", "start", "end", "stretch", "baseline"],
|
|
126
|
-
service: this,
|
|
127
|
-
propertyType: PropertyType.cssValue
|
|
128
|
-
}, {
|
|
129
|
-
name: "justify-items",
|
|
130
|
-
type: "img-list",
|
|
131
|
-
values: ["center", "start", "end", "stretch"],
|
|
132
|
-
service: this,
|
|
133
|
-
propertyType: PropertyType.cssValue
|
|
134
|
-
}
|
|
135
|
-
];
|
|
136
|
-
flex = [
|
|
137
|
-
{
|
|
138
|
-
name: "display",
|
|
139
|
-
type: "list",
|
|
140
|
-
values: ["block", "inline-block", "flex", "contents", "grid", "inherit", "initial", "none"],
|
|
141
|
-
service: this,
|
|
142
|
-
propertyType: PropertyType.cssValue
|
|
143
|
-
}, {
|
|
144
|
-
name: "position",
|
|
145
|
-
type: "list",
|
|
146
|
-
values: ["static", "relative", "absolute"],
|
|
147
|
-
service: this,
|
|
148
|
-
propertyType: PropertyType.cssValue
|
|
149
|
-
}, {
|
|
150
|
-
name: "flex-direction",
|
|
151
|
-
type: "img-list",
|
|
152
|
-
values: ["row", "column"],
|
|
153
|
-
service: this,
|
|
154
|
-
propertyType: PropertyType.cssValue
|
|
155
|
-
}, {
|
|
156
|
-
name: "flex-wrap",
|
|
157
|
-
type: "img-list",
|
|
158
|
-
values: ["nowrap", "wrap"],
|
|
159
|
-
service: this,
|
|
160
|
-
propertyType: PropertyType.cssValue
|
|
161
|
-
}, {
|
|
162
|
-
name: "align-content",
|
|
163
|
-
type: "img-list",
|
|
164
|
-
values: ["center", "flex-start", "flex-end", "space-between", "space-around", "stretch"],
|
|
165
|
-
service: this,
|
|
166
|
-
propertyType: PropertyType.cssValue
|
|
167
|
-
}, {
|
|
168
|
-
name: "justify-content",
|
|
169
|
-
type: "img-list",
|
|
170
|
-
values: ["center", "flex-start", "flex-end", "space-between", "space-around", "space-evenly"],
|
|
171
|
-
service: this,
|
|
172
|
-
propertyType: PropertyType.cssValue
|
|
173
|
-
}, {
|
|
174
|
-
name: "align-items",
|
|
175
|
-
type: "img-list",
|
|
176
|
-
values: ["center", "flex-start", "flex-end", "stretch", "baseline"],
|
|
177
|
-
service: this,
|
|
178
|
-
propertyType: PropertyType.cssValue
|
|
179
|
-
}
|
|
180
|
-
];
|
|
181
|
-
constructor(name) {
|
|
182
|
-
super();
|
|
183
|
-
this.name = name;
|
|
184
|
-
}
|
|
185
|
-
isHandledElement(designItem) {
|
|
186
|
-
return true;
|
|
187
|
-
}
|
|
188
|
-
getProperty(designItem, name) {
|
|
189
|
-
if (this.name == 'styles') {
|
|
190
|
-
return { name: name, type: 'string', service: this, propertyType: PropertyType.cssValue };
|
|
191
|
-
}
|
|
192
|
-
return this[this.name][name];
|
|
193
|
-
}
|
|
194
|
-
getProperties(designItem) {
|
|
195
|
-
if (this.name == 'styles') {
|
|
196
|
-
if (!designItem)
|
|
197
|
-
return [];
|
|
198
|
-
let styles = designItem.getAllStyles();
|
|
199
|
-
let arr = styles.map(x => ({ name: x.selector ?? '<local>', description: x.stylesheetName ?? '', properties: [
|
|
200
|
-
...x.declarations.map(y => ({ name: y.name, renamable: true, type: 'string', service: this, propertyType: PropertyType.cssValue })),
|
|
201
|
-
{ name: '', type: 'addNew', service: this, propertyType: PropertyType.complex }
|
|
202
|
-
]
|
|
203
|
-
}));
|
|
204
|
-
//let arr: IProperty[] = Array.from(designItem.styles(), ([key, value]) => ({ name: key, renamable: true, type: 'string', service: this, propertyType: PropertyType.cssValue }));
|
|
205
|
-
//arr.push({ name: '', type: 'addNew', service: this, propertyType: PropertyType.complex });
|
|
206
|
-
return arr;
|
|
207
|
-
}
|
|
208
|
-
return this[this.name];
|
|
209
|
-
}
|
|
210
|
-
getPropertyTarget(designItem, property) {
|
|
211
|
-
return BindingTarget.css;
|
|
212
|
-
}
|
|
213
|
-
setValue(designItems, property, value) {
|
|
214
|
-
if (this.name == 'styles') {
|
|
215
|
-
super.setValue(designItems, { ...property, propertyType: PropertyType.cssValue }, value);
|
|
216
|
-
}
|
|
217
|
-
else {
|
|
218
|
-
super.setValue(designItems, property, value);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
package/dist/elements/services/propertiesService/services/UnkownElementPropertiesService.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { IPropertiesService } from "../IPropertiesService";
|
|
2
|
-
import { IProperty } from '../IProperty';
|
|
3
|
-
import { IDesignItem } from '../../../item/IDesignItem';
|
|
4
|
-
import { ValueType } from "../ValueType";
|
|
5
|
-
import { BindingTarget } from "../../../item/BindingTarget";
|
|
6
|
-
import { IBinding } from "../../../item/IBinding";
|
|
7
|
-
export declare abstract class UnkownElementPropertiesService implements IPropertiesService {
|
|
8
|
-
abstract listNeedsRefresh(designItem: IDesignItem): boolean;
|
|
9
|
-
abstract isHandledElement(designItem: IDesignItem): boolean;
|
|
10
|
-
protected _notifyChangedProperty(designItem: IDesignItem, property: IProperty, value: any): void;
|
|
11
|
-
getProperty(designItem: IDesignItem, name: string): IProperty;
|
|
12
|
-
abstract getProperties(designItem: IDesignItem): IProperty[];
|
|
13
|
-
setValue(designItems: IDesignItem[], property: IProperty, value: any): void;
|
|
14
|
-
getPropertyTarget(designItem: IDesignItem, property: IProperty): BindingTarget;
|
|
15
|
-
clearValue(designItems: IDesignItem[], property: IProperty): void;
|
|
16
|
-
isSet(designItems: IDesignItem[], property: IProperty): ValueType;
|
|
17
|
-
getValue(designItems: IDesignItem[], property: IProperty): string | boolean;
|
|
18
|
-
getBinding(designItems: IDesignItem[], property: IProperty): IBinding;
|
|
19
|
-
getUnsetValue(designItems: IDesignItem[], property: IProperty): any;
|
|
20
|
-
}
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import { ValueType } from "../ValueType";
|
|
2
|
-
import { PropertiesHelper } from './PropertiesHelper';
|
|
3
|
-
import { BindingTarget } from "../../../item/BindingTarget";
|
|
4
|
-
import { PropertyType } from "../PropertyType";
|
|
5
|
-
import { NodeType } from "../../../item/NodeType";
|
|
6
|
-
export class UnkownElementPropertiesService {
|
|
7
|
-
_notifyChangedProperty(designItem, property, value) {
|
|
8
|
-
}
|
|
9
|
-
getProperty(designItem, name) {
|
|
10
|
-
return this.getProperties(designItem).find(x => x.name == name);
|
|
11
|
-
}
|
|
12
|
-
setValue(designItems, property, value) {
|
|
13
|
-
const cg = designItems[0].openGroup("properties changed");
|
|
14
|
-
for (let d of designItems) {
|
|
15
|
-
if (property.propertyType == PropertyType.cssValue) {
|
|
16
|
-
d.styles.set(property.name, value);
|
|
17
|
-
d.element.style[property.name] = value;
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
let attributeName = property.attributeName;
|
|
21
|
-
if (!attributeName)
|
|
22
|
-
attributeName = PropertiesHelper.camelToDashCase(property.name);
|
|
23
|
-
if (property.type === 'object') {
|
|
24
|
-
const json = JSON.stringify(value);
|
|
25
|
-
d.attributes.set(attributeName, json);
|
|
26
|
-
d.element.setAttribute(attributeName, json);
|
|
27
|
-
}
|
|
28
|
-
else if (property.type == 'boolean' && !value) {
|
|
29
|
-
d.attributes.delete(attributeName);
|
|
30
|
-
d.element.removeAttribute(attributeName);
|
|
31
|
-
}
|
|
32
|
-
else if (property.type == 'boolean' && value) {
|
|
33
|
-
d.attributes.set(attributeName, "");
|
|
34
|
-
d.element.setAttribute(attributeName, "");
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
d.attributes.set(attributeName, value);
|
|
38
|
-
d.element.setAttribute(attributeName, value);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
this._notifyChangedProperty(d, property, value);
|
|
42
|
-
}
|
|
43
|
-
cg.commit();
|
|
44
|
-
}
|
|
45
|
-
getPropertyTarget(designItem, property) {
|
|
46
|
-
return BindingTarget.property;
|
|
47
|
-
}
|
|
48
|
-
clearValue(designItems, property) {
|
|
49
|
-
const cg = designItems[0].openGroup("properties cleared");
|
|
50
|
-
for (let d of designItems) {
|
|
51
|
-
if (property.propertyType == PropertyType.cssValue) {
|
|
52
|
-
d.styles.delete(property.name);
|
|
53
|
-
d.element.style[property.name] = '';
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
let attributeName = property.attributeName;
|
|
57
|
-
if (!attributeName)
|
|
58
|
-
attributeName = PropertiesHelper.camelToDashCase(property.name);
|
|
59
|
-
d.attributes.delete(attributeName);
|
|
60
|
-
d.element.removeAttribute(attributeName);
|
|
61
|
-
}
|
|
62
|
-
d.serviceContainer.forSomeServicesTillResult('bindingService', (s) => {
|
|
63
|
-
return s.clearBinding(d, property.name, this.getPropertyTarget(d, property));
|
|
64
|
-
});
|
|
65
|
-
this._notifyChangedProperty(d, property, undefined);
|
|
66
|
-
}
|
|
67
|
-
cg.commit();
|
|
68
|
-
}
|
|
69
|
-
isSet(designItems, property) {
|
|
70
|
-
let all = true;
|
|
71
|
-
let some = false;
|
|
72
|
-
if (designItems != null && designItems.length !== 0) {
|
|
73
|
-
let attributeName = property.attributeName;
|
|
74
|
-
if (!attributeName)
|
|
75
|
-
attributeName = PropertiesHelper.camelToDashCase(property.name);
|
|
76
|
-
designItems.forEach((x) => {
|
|
77
|
-
let has = false;
|
|
78
|
-
if (property.propertyType == PropertyType.cssValue)
|
|
79
|
-
has = x.styles.has(property.name);
|
|
80
|
-
else
|
|
81
|
-
has = x.attributes.has(attributeName);
|
|
82
|
-
all = all && has;
|
|
83
|
-
some = some || has;
|
|
84
|
-
});
|
|
85
|
-
//todo: optimize perf, do not call bindings service for each property.
|
|
86
|
-
const bindings = designItems[0].serviceContainer.forSomeServicesTillResult('bindingService', (s) => {
|
|
87
|
-
return s.getBindings(designItems[0]);
|
|
88
|
-
});
|
|
89
|
-
if (property.propertyType == PropertyType.cssValue) {
|
|
90
|
-
if (bindings && bindings.find(x => x.target == BindingTarget.css && x.targetName == property.name))
|
|
91
|
-
return ValueType.bound;
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
if (bindings && bindings.find(x => x.target == BindingTarget.property && x.targetName == property.name))
|
|
95
|
-
return ValueType.bound;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
else
|
|
99
|
-
return ValueType.none;
|
|
100
|
-
return all ? ValueType.all : some ? ValueType.some : ValueType.none;
|
|
101
|
-
}
|
|
102
|
-
getValue(designItems, property) {
|
|
103
|
-
if (designItems != null && designItems.length !== 0) {
|
|
104
|
-
if (property.propertyType == PropertyType.cssValue) {
|
|
105
|
-
let lastValue = designItems[0].styles.get(property.name);
|
|
106
|
-
for (const x of designItems) {
|
|
107
|
-
let value = x.styles.get(property.name);
|
|
108
|
-
if (value != lastValue) {
|
|
109
|
-
lastValue = null;
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return lastValue;
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
let attributeName = property.attributeName;
|
|
117
|
-
if (!attributeName)
|
|
118
|
-
attributeName = PropertiesHelper.camelToDashCase(property.name);
|
|
119
|
-
if (property.type == 'boolean')
|
|
120
|
-
return designItems[0].attributes.has(attributeName);
|
|
121
|
-
let lastValue = designItems[0].attributes.get(attributeName);
|
|
122
|
-
/*
|
|
123
|
-
for (const x of designItems) {
|
|
124
|
-
let value = x.attributes.get(attributeName);
|
|
125
|
-
if (value != lastValue) {
|
|
126
|
-
lastValue = null;
|
|
127
|
-
break;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
*/
|
|
131
|
-
return lastValue;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
return null;
|
|
135
|
-
}
|
|
136
|
-
getBinding(designItems, property) {
|
|
137
|
-
//TODO: optimize perf, do not call bindings service for each property.
|
|
138
|
-
const bindings = designItems[0].serviceContainer.forSomeServicesTillResult('bindingService', (s) => {
|
|
139
|
-
return s.getBindings(designItems[0]);
|
|
140
|
-
});
|
|
141
|
-
if (property.propertyType == PropertyType.cssValue) {
|
|
142
|
-
return bindings.find(x => (x.target == BindingTarget.css) && x.targetName == property.name);
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
return bindings.find(x => (x.target == BindingTarget.property || x.target == BindingTarget.attribute) && x.targetName == property.name);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
//todo: optimize perf, call window.getComputedStyle only once per item, and not per property
|
|
149
|
-
getUnsetValue(designItems, property) {
|
|
150
|
-
if (property.propertyType == PropertyType.cssValue) {
|
|
151
|
-
if (designItems != null && designItems.length !== 0) {
|
|
152
|
-
if (designItems[0].nodeType == NodeType.Element) {
|
|
153
|
-
let v = window.getComputedStyle(designItems[0].element)[property.name];
|
|
154
|
-
return v;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
return null;
|
|
158
|
-
}
|
|
159
|
-
else
|
|
160
|
-
return property.defaultValue;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { IDesignItem } from "../../item/IDesignItem.js";
|
|
2
|
-
import { IProperty } from "../propertiesService/IProperty.js";
|
|
3
|
-
import { IStyleDeclaration, IStyleRule, IStylesheet, IStylesheetService } from "./IStylesheetService.js";
|
|
4
|
-
import type * as csstree from 'css-tree';
|
|
5
|
-
import { TypedEvent } from "@node-projects/base-custom-webcomponent";
|
|
6
|
-
declare global {
|
|
7
|
-
interface Window {
|
|
8
|
-
csstree: {
|
|
9
|
-
fromPlainObject(node: csstree.CssNodePlain): csstree.CssNode;
|
|
10
|
-
toPlainObject(node: csstree.CssNode): csstree.CssNodePlain;
|
|
11
|
-
parse(text: string, options?: csstree.ParseOptions): csstree.CssNode;
|
|
12
|
-
generate(ast: csstree.CssNode, options?: csstree.GenerateOptions): string;
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
interface IRuleWithAST extends IStyleRule {
|
|
17
|
-
ast: csstree.RulePlain;
|
|
18
|
-
declarations: IDeclarationWithAST[];
|
|
19
|
-
}
|
|
20
|
-
interface IDeclarationWithAST extends IStyleDeclaration {
|
|
21
|
-
ast: csstree.DeclarationPlain;
|
|
22
|
-
parent: IStyleRule;
|
|
23
|
-
}
|
|
24
|
-
export declare class CssTreeStylesheetService implements IStylesheetService {
|
|
25
|
-
private _stylesheets;
|
|
26
|
-
stylesheetChanged: TypedEvent<{
|
|
27
|
-
stylesheet: IStylesheet;
|
|
28
|
-
}>;
|
|
29
|
-
stylesheetsChanged: TypedEvent<void>;
|
|
30
|
-
constructor();
|
|
31
|
-
setStylesheets(stylesheets: IStylesheet[]): void;
|
|
32
|
-
getStylesheets(): IStylesheet[];
|
|
33
|
-
private getAppliedRulesInternal;
|
|
34
|
-
getAppliedRules(designItem: IDesignItem): IRuleWithAST[];
|
|
35
|
-
private getDeclarationInternal;
|
|
36
|
-
getDeclarations(designItem: IDesignItem, prop: IProperty): IDeclarationWithAST[];
|
|
37
|
-
updateDeclarationWithProperty(designItem: IDesignItem, property: IProperty, value: string, important: boolean): boolean;
|
|
38
|
-
updateDeclarationWithDeclaration(declaration: IDeclarationWithAST, value: string, important: boolean): boolean;
|
|
39
|
-
private rulesFromAST;
|
|
40
|
-
private astHasChildren;
|
|
41
|
-
private buildSelectorString;
|
|
42
|
-
private getSpecificity;
|
|
43
|
-
private findDeclarationInRule;
|
|
44
|
-
private elementMatchesASelector;
|
|
45
|
-
private buildAtRuleString;
|
|
46
|
-
private sortDeclarations;
|
|
47
|
-
}
|
|
48
|
-
export {};
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import { TypedEvent } from "@node-projects/base-custom-webcomponent";
|
|
2
|
-
import { calculate as calculateSpecifity } from "./SpecificityCalculator.js";
|
|
3
|
-
export class CssTreeStylesheetService {
|
|
4
|
-
_stylesheets = new Map();
|
|
5
|
-
stylesheetChanged = new TypedEvent();
|
|
6
|
-
stylesheetsChanged = new TypedEvent();
|
|
7
|
-
constructor() { }
|
|
8
|
-
setStylesheets(stylesheets) {
|
|
9
|
-
if (stylesheets != null) {
|
|
10
|
-
this._stylesheets = new Map();
|
|
11
|
-
for (let stylesheet of stylesheets) {
|
|
12
|
-
this._stylesheets.set(stylesheet.name, {
|
|
13
|
-
stylesheet: stylesheet,
|
|
14
|
-
ast: window.csstree.toPlainObject((window.csstree.parse(stylesheet.stylesheet, { positions: true, parseValue: false })))
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
this.stylesheetsChanged.emit();
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
this._stylesheets = null;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
getStylesheets() {
|
|
24
|
-
let stylesheets = [];
|
|
25
|
-
for (let item of this._stylesheets) {
|
|
26
|
-
stylesheets.push(item[1].stylesheet);
|
|
27
|
-
}
|
|
28
|
-
;
|
|
29
|
-
return stylesheets;
|
|
30
|
-
}
|
|
31
|
-
/* Section covers the retrieval of rules and declarations */
|
|
32
|
-
getAppliedRulesInternal(designItem) {
|
|
33
|
-
let styles = [];
|
|
34
|
-
for (let item of this._stylesheets) {
|
|
35
|
-
if (!item[1].ast || !this.astHasChildren(item[1].ast))
|
|
36
|
-
break;
|
|
37
|
-
styles = styles.concat(Array.from(this.rulesFromAST(item[1].ast, item[1].stylesheet.stylesheet, item[0], designItem)));
|
|
38
|
-
}
|
|
39
|
-
;
|
|
40
|
-
return styles;
|
|
41
|
-
}
|
|
42
|
-
getAppliedRules(designItem) {
|
|
43
|
-
let rules = this.getAppliedRulesInternal(designItem);
|
|
44
|
-
if (!rules || rules.length == 0)
|
|
45
|
-
return [];
|
|
46
|
-
let retCollection = [];
|
|
47
|
-
for (let rule of rules) {
|
|
48
|
-
retCollection.push({
|
|
49
|
-
...rule,
|
|
50
|
-
declarations: rule.ast.block.children.map((declaration) => {
|
|
51
|
-
return {
|
|
52
|
-
name: declaration.property,
|
|
53
|
-
value: declaration.value.value,
|
|
54
|
-
important: declaration.important == true,
|
|
55
|
-
specificity: rule.specificity,
|
|
56
|
-
parent: rule,
|
|
57
|
-
ast: declaration,
|
|
58
|
-
};
|
|
59
|
-
})
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
return retCollection;
|
|
63
|
-
}
|
|
64
|
-
getDeclarationInternal(designItem, prop) {
|
|
65
|
-
let rules = this.getAppliedRulesInternal(designItem);
|
|
66
|
-
if (!rules)
|
|
67
|
-
return null;
|
|
68
|
-
let declarations = [];
|
|
69
|
-
for (let rule of rules) {
|
|
70
|
-
let declaration = this.findDeclarationInRule(rule.ast, prop);
|
|
71
|
-
if (!declaration)
|
|
72
|
-
continue;
|
|
73
|
-
declarations.push({
|
|
74
|
-
ast: declaration,
|
|
75
|
-
parent: rule,
|
|
76
|
-
name: prop.name,
|
|
77
|
-
value: declaration.value.value,
|
|
78
|
-
important: declaration.important == true,
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
;
|
|
82
|
-
return declarations;
|
|
83
|
-
}
|
|
84
|
-
getDeclarations(designItem, prop) {
|
|
85
|
-
let declarations = this.getDeclarationInternal(designItem, prop);
|
|
86
|
-
if (!declarations)
|
|
87
|
-
return null;
|
|
88
|
-
return this.sortDeclarations(declarations);
|
|
89
|
-
}
|
|
90
|
-
/* Section covers the update of rules and declarations */
|
|
91
|
-
updateDeclarationWithProperty(designItem, property, value, important) {
|
|
92
|
-
let sortedDecl = this.sortDeclarations(this.getDeclarationInternal(designItem, property));
|
|
93
|
-
if (!sortedDecl) {
|
|
94
|
-
// no declaration of property yet
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
99
|
-
updateDeclarationWithDeclaration(declaration, value, important) {
|
|
100
|
-
declaration.ast.value = window.csstree.toPlainObject(window.csstree.parse(declaration.name + ": " + value, { context: 'declaration', parseValue: false })).value;
|
|
101
|
-
this._stylesheets.get(declaration.parent.stylesheetName).stylesheet.stylesheet = window.csstree.generate(window.csstree.fromPlainObject(this._stylesheets.get(declaration.parent.stylesheetName).ast));
|
|
102
|
-
this.stylesheetChanged.emit({ stylesheet: this._stylesheets.get(declaration.parent.stylesheetName).stylesheet });
|
|
103
|
-
return true;
|
|
104
|
-
}
|
|
105
|
-
/* Section covers the internal traversal creation of rules and declarations */
|
|
106
|
-
*rulesFromAST(ast, stylesheet, source, designItem, previousCheck = '') {
|
|
107
|
-
let parent = ast["children"] != null ? ast : ast.block;
|
|
108
|
-
for (const child of parent.children) {
|
|
109
|
-
if (child.type == "Atrule") {
|
|
110
|
-
const currentCheck = this.buildAtRuleString(child, stylesheet);
|
|
111
|
-
if (currentCheck.type === "@media" && !window.matchMedia(currentCheck.sel))
|
|
112
|
-
continue;
|
|
113
|
-
if (currentCheck.type === "@supports" && !CSS.supports(currentCheck.sel))
|
|
114
|
-
continue;
|
|
115
|
-
let ruleCollection = this.rulesFromAST(child, stylesheet, source, designItem, previousCheck + currentCheck.type + " " + currentCheck.sel + "\n");
|
|
116
|
-
if (ruleCollection) {
|
|
117
|
-
for (const r of ruleCollection) {
|
|
118
|
-
if (!this.elementMatchesASelector(designItem, this.buildSelectorString(r.ast.prelude)))
|
|
119
|
-
continue;
|
|
120
|
-
yield r;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
if (child.type == "Rule") {
|
|
125
|
-
let selectors = this.buildSelectorString(child.prelude);
|
|
126
|
-
if (!this.elementMatchesASelector(designItem, selectors))
|
|
127
|
-
continue;
|
|
128
|
-
yield ({
|
|
129
|
-
ast: child,
|
|
130
|
-
selector: previousCheck + this.buildSelectorString(child.prelude).join(", "),
|
|
131
|
-
specificity: this.getSpecificity(child.prelude),
|
|
132
|
-
stylesheetName: source,
|
|
133
|
-
declarations: null,
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
;
|
|
138
|
-
}
|
|
139
|
-
/* Utility functions for building selectors, specificity and so on */
|
|
140
|
-
astHasChildren(ast) {
|
|
141
|
-
return ast != null && ast["children"] != null && ast["children"].length > 0;
|
|
142
|
-
}
|
|
143
|
-
buildSelectorString(selectorsAST) {
|
|
144
|
-
let selectors = [];
|
|
145
|
-
for (let selector of selectorsAST.children) {
|
|
146
|
-
let sel = "";
|
|
147
|
-
for (let fraction of selector.children) {
|
|
148
|
-
sel += fraction.name;
|
|
149
|
-
}
|
|
150
|
-
selectors.push(sel);
|
|
151
|
-
}
|
|
152
|
-
;
|
|
153
|
-
return selectors;
|
|
154
|
-
}
|
|
155
|
-
getSpecificity(selector) {
|
|
156
|
-
const specificities = calculateSpecifity(selector);
|
|
157
|
-
let sum = 0;
|
|
158
|
-
specificities.forEach(specificity => sum += specificity.a * 10000 + specificity.b * 100 + specificity.c);
|
|
159
|
-
return sum;
|
|
160
|
-
}
|
|
161
|
-
findDeclarationInRule(rule, property) {
|
|
162
|
-
return rule.block.children.find(declaration => declaration.property == property.name);
|
|
163
|
-
}
|
|
164
|
-
elementMatchesASelector(designItem, selectors) {
|
|
165
|
-
for (const selector of selectors)
|
|
166
|
-
if (designItem.element.matches(selector))
|
|
167
|
-
return true;
|
|
168
|
-
return false;
|
|
169
|
-
}
|
|
170
|
-
buildAtRuleString(ast, stylesheet) {
|
|
171
|
-
return {
|
|
172
|
-
sel: stylesheet.slice(ast.prelude.loc.start.offset, ast.prelude.loc.end.offset),
|
|
173
|
-
type: "@" + ast.name
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
sortDeclarations(declarations) {
|
|
177
|
-
if (declarations == null || declarations.length == 0)
|
|
178
|
-
return null;
|
|
179
|
-
return declarations.sort((dec1, dec2) => {
|
|
180
|
-
if (dec1.parent.specificity > dec2.parent.specificity)
|
|
181
|
-
return -1;
|
|
182
|
-
return 1;
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { IDesignItem } from "../../item/IDesignItem.js";
|
|
2
|
-
import { IProperty } from "../propertiesService/IProperty.js";
|
|
3
|
-
import { IStyleDeclaration, IStyleRule, IStylesheetService } from "./IStylesheetService.js";
|
|
4
|
-
import * as csstree from 'css-tree';
|
|
5
|
-
import { TypedEvent } from "@node-projects/base-custom-webcomponent";
|
|
6
|
-
type RuleWithSpecificity = {
|
|
7
|
-
rule: csstree.RulePlain;
|
|
8
|
-
selector: string;
|
|
9
|
-
specificity: number;
|
|
10
|
-
};
|
|
11
|
-
export declare class StylesheetService implements IStylesheetService {
|
|
12
|
-
stylesheets: string[];
|
|
13
|
-
stylesheetChanged: TypedEvent<{
|
|
14
|
-
stylesheet: string;
|
|
15
|
-
}>;
|
|
16
|
-
styles: RuleWithSpecificity[];
|
|
17
|
-
constructor(stylesheets: string[]);
|
|
18
|
-
updateDefiningRule(designItem: IDesignItem, property: IProperty, value: string): boolean;
|
|
19
|
-
private getAppliedRulesInternal;
|
|
20
|
-
getAppliedRules(designItem: IDesignItem, prop: IProperty): IStyleRule[];
|
|
21
|
-
private getDeclarationInternal;
|
|
22
|
-
getDeclarations(designItem: IDesignItem, prop: IProperty): IStyleDeclaration[];
|
|
23
|
-
private parseStylesheetToRuleset;
|
|
24
|
-
private buildSelectorString;
|
|
25
|
-
private getSpecificity;
|
|
26
|
-
private returnRuleDeclarationIndex;
|
|
27
|
-
}
|
|
28
|
-
export {};
|