@node-projects/web-component-designer 0.0.287 → 0.0.289
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/services/propertiesService/PropertyTabsService.js +3 -0
- package/dist/elements/services/propertiesService/services/CssCurrentPropertiesService copy.d.ts +34 -0
- package/dist/elements/services/propertiesService/services/CssCurrentPropertiesService copy.js +105 -0
- package/dist/elements/services/propertiesService/services/CssCustomPropertiesService.d.ts +17 -0
- package/dist/elements/services/propertiesService/services/CssCustomPropertiesService.js +43 -0
- package/dist/elements/services/undoService/transactionItems/CssStyleChangeAction.js +26 -4
- package/dist/elements/widgets/demoView/demoView.js +31 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@ import { AttachedPropertiesService } from './services/AttachedPropertiesService.
|
|
|
2
2
|
import { AttributesPropertiesService } from './services/AttributesPropertiesService.js';
|
|
3
3
|
import { CommonPropertiesService } from './services/CommonPropertiesService.js';
|
|
4
4
|
import { CssCurrentPropertiesService } from './services/CssCurrentPropertiesService.js';
|
|
5
|
+
import { CssCustomPropertiesService } from './services/CssCustomPropertiesService.js';
|
|
5
6
|
import { CssPropertiesService } from './services/CssPropertiesService.js';
|
|
6
7
|
export class PropertyTabsService {
|
|
7
8
|
_attachedPropertiesService = new AttachedPropertiesService();
|
|
@@ -11,6 +12,7 @@ export class PropertyTabsService {
|
|
|
11
12
|
{ name: 'attributes', propertiesService: new AttributesPropertiesService() },
|
|
12
13
|
{ name: 'common', propertiesService: new CommonPropertiesService() },
|
|
13
14
|
{ name: 'styles', propertiesService: new CssCurrentPropertiesService() },
|
|
15
|
+
{ name: 'css vars', propertiesService: new CssCustomPropertiesService() },
|
|
14
16
|
{ name: 'layout', propertiesService: new CssPropertiesService("layout") },
|
|
15
17
|
{ name: 'flex', propertiesService: new CssPropertiesService("flex") },
|
|
16
18
|
{ name: 'grid', propertiesService: new CssPropertiesService("grid") },
|
|
@@ -20,6 +22,7 @@ export class PropertyTabsService {
|
|
|
20
22
|
{ name: 'attached', propertiesService: this._attachedPropertiesService },
|
|
21
23
|
{ name: 'attributes', propertiesService: new AttributesPropertiesService() },
|
|
22
24
|
{ name: 'styles', propertiesService: new CssCurrentPropertiesService() },
|
|
25
|
+
{ name: 'css vars', propertiesService: new CssCustomPropertiesService() },
|
|
23
26
|
{ name: 'layout', propertiesService: new CssPropertiesService("layout") },
|
|
24
27
|
{ name: 'svg', propertiesService: new CssPropertiesService("svg") },
|
|
25
28
|
];
|
package/dist/elements/services/propertiesService/services/CssCurrentPropertiesService copy.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { IProperty } from '../IProperty.js';
|
|
2
|
+
import { IDesignItem } from '../../../item/IDesignItem.js';
|
|
3
|
+
import { RefreshMode } from '../IPropertiesService.js';
|
|
4
|
+
import { IPropertyGroup } from '../IPropertyGroup.js';
|
|
5
|
+
import { IStyleDeclaration, IStyleRule } from '../../stylesheetService/IStylesheetService.js';
|
|
6
|
+
import { CommonPropertiesService } from './CommonPropertiesService.js';
|
|
7
|
+
import { ValueType } from '../ValueType.js';
|
|
8
|
+
export declare class CssCurrentPropertiesService extends CommonPropertiesService {
|
|
9
|
+
getRefreshMode(designItem: IDesignItem): RefreshMode;
|
|
10
|
+
constructor();
|
|
11
|
+
isHandledElement(designItem: IDesignItem): boolean;
|
|
12
|
+
getProperty(designItem: IDesignItem, name: string): IProperty;
|
|
13
|
+
getProperties(designItem: IDesignItem): IProperty[] | IPropertyGroup[];
|
|
14
|
+
setValue(designItems: IDesignItem[], property: (IProperty & {
|
|
15
|
+
styleRule: IStyleRule;
|
|
16
|
+
styleDeclaration: IStyleDeclaration;
|
|
17
|
+
}), value: any): void;
|
|
18
|
+
clearValue(designItems: IDesignItem[], property: IProperty & {
|
|
19
|
+
styleRule: IStyleRule;
|
|
20
|
+
styleDeclaration: IStyleDeclaration;
|
|
21
|
+
}, clearType: 'all' | 'binding' | 'value'): void;
|
|
22
|
+
getValue(designItems: IDesignItem[], property: IProperty & {
|
|
23
|
+
styleRule: IStyleRule;
|
|
24
|
+
styleDeclaration: IStyleDeclaration;
|
|
25
|
+
}): string | boolean;
|
|
26
|
+
getUnsetValue(designItems: IDesignItem[], property: IProperty & {
|
|
27
|
+
styleRule: IStyleRule;
|
|
28
|
+
styleDeclaration: IStyleDeclaration;
|
|
29
|
+
}): any;
|
|
30
|
+
isSet(designItems: IDesignItem[], property: IProperty & {
|
|
31
|
+
styleRule: IStyleRule;
|
|
32
|
+
styleDeclaration: IStyleDeclaration;
|
|
33
|
+
}): ValueType;
|
|
34
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { PropertyType } from '../PropertyType.js';
|
|
2
|
+
import { RefreshMode } from '../IPropertiesService.js';
|
|
3
|
+
import { CommonPropertiesService } from './CommonPropertiesService.js';
|
|
4
|
+
import { ValueType } from '../ValueType.js';
|
|
5
|
+
import { NodeType } from '../../../item/NodeType.js';
|
|
6
|
+
//TODO: remove this code when import asserts are supported
|
|
7
|
+
let cssProperties;
|
|
8
|
+
//@ts-ignore
|
|
9
|
+
if (window.importShim) {
|
|
10
|
+
const cssPropertiesUrl = import.meta.resolve('./CssProperties.json');
|
|
11
|
+
//@ts-ignore
|
|
12
|
+
cssProperties = await importShim(cssPropertiesUrl, { assert: { type: 'json' } });
|
|
13
|
+
}
|
|
14
|
+
else
|
|
15
|
+
//@ts-ignore
|
|
16
|
+
cssProperties = await import("./CssProperties.json", { assert: { type: 'json' } });
|
|
17
|
+
if (cssProperties.default)
|
|
18
|
+
cssProperties = cssProperties.default;
|
|
19
|
+
const localName = '<local>';
|
|
20
|
+
export class CssCurrentPropertiesService extends CommonPropertiesService {
|
|
21
|
+
getRefreshMode(designItem) {
|
|
22
|
+
return RefreshMode.fullOnValueChange;
|
|
23
|
+
}
|
|
24
|
+
constructor() {
|
|
25
|
+
super();
|
|
26
|
+
this.name = 'styles';
|
|
27
|
+
}
|
|
28
|
+
isHandledElement(designItem) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
getProperty(designItem, name) {
|
|
32
|
+
return { name: name, type: 'string', service: this, propertyType: PropertyType.cssValue };
|
|
33
|
+
}
|
|
34
|
+
getProperties(designItem) {
|
|
35
|
+
if (!designItem || designItem.nodeType != NodeType.Element)
|
|
36
|
+
return [];
|
|
37
|
+
let styles = designItem.getAllStyles();
|
|
38
|
+
let arr = styles.map(x => ({
|
|
39
|
+
name: x.selector ?? localName, description: x.stylesheetName ?? '', properties: [
|
|
40
|
+
...x.declarations.map(y => ({
|
|
41
|
+
name: y.name,
|
|
42
|
+
renamable: true,
|
|
43
|
+
type: cssProperties[y.name]?.type ?? 'string',
|
|
44
|
+
values: cssProperties[y.name]?.values ? [...cssProperties[y.name]?.values, 'initial', 'inherit', 'unset'] : ['initial', 'inherit', 'unset'],
|
|
45
|
+
service: this,
|
|
46
|
+
propertyType: PropertyType.cssValue,
|
|
47
|
+
styleRule: x,
|
|
48
|
+
styleDeclaration: y
|
|
49
|
+
})),
|
|
50
|
+
{ name: '', type: 'addNew', service: this, propertyType: PropertyType.complex, styleRule: x }
|
|
51
|
+
]
|
|
52
|
+
}));
|
|
53
|
+
return arr;
|
|
54
|
+
}
|
|
55
|
+
setValue(designItems, property, value) {
|
|
56
|
+
// No selector means local style, styleDeclaration is null means new property
|
|
57
|
+
if (property.styleRule?.selector !== null && property.styleDeclaration) {
|
|
58
|
+
// styleDeclaration stored Propertygrid is not refreshed after entering a new value, so we need to reload
|
|
59
|
+
// TODO: we do not respect if a same style is found in a media query or another @rule, maybe we need a refresh in the stylesheet parser
|
|
60
|
+
const decls = designItems[0].instanceServiceContainer.stylesheetService?.getDeclarations(designItems[0], property.styleDeclaration.name);
|
|
61
|
+
const currentDecl = decls.find(x => x.parent.selector == property.styleDeclaration.parent.selector && x.parent.stylesheetName == property.styleDeclaration.parent.stylesheetName);
|
|
62
|
+
designItems[0].instanceServiceContainer.stylesheetService.updateDeclarationValue(currentDecl, value, false);
|
|
63
|
+
this._notifyChangedProperty(designItems[0], property, value);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (property.styleRule?.selector !== null && !property.styleDeclaration) {
|
|
67
|
+
designItems[0].instanceServiceContainer.stylesheetService.insertDeclarationIntoRule(property.styleRule, property.name, value, false);
|
|
68
|
+
this._notifyChangedProperty(designItems[0], property, value);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
for (const d of designItems) {
|
|
72
|
+
// Local style
|
|
73
|
+
d.setStyle(property.name, value);
|
|
74
|
+
//unkown css property names do not trigger the mutation observer of property grid,
|
|
75
|
+
//fixed by assinging stle again to the attribute
|
|
76
|
+
d.element.setAttribute('style', d.element.getAttribute('style'));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
clearValue(designItems, property, clearType) {
|
|
80
|
+
if (property.styleRule?.selector !== null && property.styleDeclaration) {
|
|
81
|
+
designItems[0].instanceServiceContainer.stylesheetService.removeDeclarationFromRule(property.styleRule, property.styleDeclaration.name);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
super.clearValue(designItems, property, clearType);
|
|
85
|
+
}
|
|
86
|
+
getValue(designItems, property) {
|
|
87
|
+
if (property.styleRule?.selector && property.styleDeclaration)
|
|
88
|
+
return property.styleDeclaration.value;
|
|
89
|
+
return super.getValue(designItems, property);
|
|
90
|
+
}
|
|
91
|
+
getUnsetValue(designItems, property) {
|
|
92
|
+
if (property.styleRule?.selector && property.styleDeclaration)
|
|
93
|
+
return property.styleDeclaration.value;
|
|
94
|
+
return super.getUnsetValue(designItems, property);
|
|
95
|
+
}
|
|
96
|
+
isSet(designItems, property) {
|
|
97
|
+
if (property.styleRule?.selector && property.styleDeclaration) {
|
|
98
|
+
if (designItems[0].hasStyle(property.name))
|
|
99
|
+
return ValueType.none;
|
|
100
|
+
//TODO: we need to check if this is the dec. with the highest specifity
|
|
101
|
+
return ValueType.all;
|
|
102
|
+
}
|
|
103
|
+
return super.isSet(designItems, property);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { IProperty } from '../IProperty.js';
|
|
2
|
+
import { IDesignItem } from '../../../item/IDesignItem.js';
|
|
3
|
+
import { RefreshMode } from '../IPropertiesService.js';
|
|
4
|
+
import { IPropertyGroup } from '../IPropertyGroup.js';
|
|
5
|
+
import { CommonPropertiesService } from './CommonPropertiesService.js';
|
|
6
|
+
import { ValueType } from '../ValueType.js';
|
|
7
|
+
export declare class CssCustomPropertiesService extends CommonPropertiesService {
|
|
8
|
+
getRefreshMode(designItem: IDesignItem): RefreshMode;
|
|
9
|
+
constructor();
|
|
10
|
+
isHandledElement(designItem: IDesignItem): boolean;
|
|
11
|
+
getProperty(designItem: IDesignItem, name: string): IProperty;
|
|
12
|
+
getProperties(designItem: IDesignItem): IProperty[] | IPropertyGroup[];
|
|
13
|
+
clearValue(designItems: IDesignItem[], property: IProperty, clearType: 'all' | 'binding' | 'value'): void;
|
|
14
|
+
getValue(designItems: IDesignItem[], property: IProperty): string;
|
|
15
|
+
getUnsetValue(designItems: IDesignItem[], property: IProperty): any;
|
|
16
|
+
isSet(designItems: IDesignItem[], property: IProperty): ValueType;
|
|
17
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { PropertyType } from '../PropertyType.js';
|
|
2
|
+
import { RefreshMode } from '../IPropertiesService.js';
|
|
3
|
+
import { CommonPropertiesService } from './CommonPropertiesService.js';
|
|
4
|
+
import { ValueType } from '../ValueType.js';
|
|
5
|
+
export class CssCustomPropertiesService extends CommonPropertiesService {
|
|
6
|
+
getRefreshMode(designItem) {
|
|
7
|
+
return RefreshMode.fullOnValueChange;
|
|
8
|
+
}
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
this.name = 'customProperties';
|
|
12
|
+
}
|
|
13
|
+
isHandledElement(designItem) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
getProperty(designItem, name) {
|
|
17
|
+
return { name: name, type: 'string', service: this, propertyType: PropertyType.cssValue };
|
|
18
|
+
}
|
|
19
|
+
getProperties(designItem) {
|
|
20
|
+
if (!designItem.element.computedStyleMap)
|
|
21
|
+
return null;
|
|
22
|
+
let rootMap = Array.from(designItem.instanceServiceContainer.designerCanvas.rootDesignItem.element.computedStyleMap()).map(x => x[0]).filter(key => key.startsWith("--"));
|
|
23
|
+
let props = Array.from(designItem.element.computedStyleMap()).map(x => x[0]).filter(key => key.startsWith("--"));
|
|
24
|
+
let arr = props.filter(x => !rootMap.includes(x)).map(x => ({
|
|
25
|
+
name: x,
|
|
26
|
+
service: this,
|
|
27
|
+
propertyType: PropertyType.cssValue
|
|
28
|
+
}));
|
|
29
|
+
return arr;
|
|
30
|
+
}
|
|
31
|
+
clearValue(designItems, property, clearType) {
|
|
32
|
+
super.clearValue(designItems, property, clearType);
|
|
33
|
+
}
|
|
34
|
+
getValue(designItems, property) {
|
|
35
|
+
return getComputedStyle(designItems[0].element).getPropertyValue(property.name);
|
|
36
|
+
}
|
|
37
|
+
getUnsetValue(designItems, property) {
|
|
38
|
+
return super.getUnsetValue(designItems, property);
|
|
39
|
+
}
|
|
40
|
+
isSet(designItems, property) {
|
|
41
|
+
return designItems[0].hasStyle(property.name) ? ValueType.all : ValueType.none;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -13,21 +13,43 @@ export class CssStyleChangeAction {
|
|
|
13
13
|
undo() {
|
|
14
14
|
if (this.oldValue === '' || this.oldValue == null) {
|
|
15
15
|
this.designItem._withoutUndoRemoveStyle(this.name);
|
|
16
|
-
this.
|
|
16
|
+
if (this.name.startsWith('--')) {
|
|
17
|
+
this.designItem.element.style.removeProperty(this.name);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
this.designItem.element.style[this.name] = '';
|
|
21
|
+
}
|
|
22
|
+
;
|
|
17
23
|
}
|
|
18
24
|
else {
|
|
19
25
|
this.designItem._withoutUndoSetStyle(this.name, this.oldValue);
|
|
20
|
-
this.
|
|
26
|
+
if (this.name.startsWith('--')) {
|
|
27
|
+
this.designItem.element.style.setProperty(this.name, this.oldValue);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
this.designItem.element.style[this.name] = this.oldValue;
|
|
31
|
+
}
|
|
21
32
|
}
|
|
22
33
|
}
|
|
23
34
|
do() {
|
|
24
35
|
if (this.newValue === '' || this.newValue == null) {
|
|
25
36
|
this.designItem._withoutUndoRemoveStyle(this.name);
|
|
26
|
-
this.
|
|
37
|
+
if (this.name.startsWith('--')) {
|
|
38
|
+
this.designItem.element.style.removeProperty(this.name);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
this.designItem.element.style[this.name] = '';
|
|
42
|
+
}
|
|
43
|
+
;
|
|
27
44
|
}
|
|
28
45
|
else {
|
|
29
46
|
this.designItem._withoutUndoSetStyle(this.name, this.newValue);
|
|
30
|
-
this.
|
|
47
|
+
if (this.name.startsWith('--')) {
|
|
48
|
+
this.designItem.element.style.setProperty(this.name, this.newValue);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
this.designItem.element.style[this.name] = this.newValue;
|
|
52
|
+
}
|
|
31
53
|
}
|
|
32
54
|
}
|
|
33
55
|
designItem;
|
|
@@ -9,15 +9,39 @@ export class DemoView extends BaseCustomWebComponentLazyAppend {
|
|
|
9
9
|
background: white;
|
|
10
10
|
height: 100%;
|
|
11
11
|
width: 100%;
|
|
12
|
+
position: relative;
|
|
12
13
|
}
|
|
13
14
|
#placeholder {
|
|
15
|
+
position: absolute;
|
|
16
|
+
left: 24px;
|
|
14
17
|
height: 100%;
|
|
15
|
-
width: 100
|
|
18
|
+
width: calc(100% - 24px);
|
|
16
19
|
}
|
|
17
20
|
#loading {
|
|
18
21
|
position: absolute;
|
|
19
22
|
top: 60px;
|
|
20
23
|
left: 20px;
|
|
24
|
+
}
|
|
25
|
+
#left {
|
|
26
|
+
position:absolute;
|
|
27
|
+
left: 0;
|
|
28
|
+
top: 0;
|
|
29
|
+
height: 100%;
|
|
30
|
+
width: 24px;
|
|
31
|
+
border-right: solid white 1px;
|
|
32
|
+
box-sizing: border-box;
|
|
33
|
+
background: black;
|
|
34
|
+
}
|
|
35
|
+
span {
|
|
36
|
+
color: white;
|
|
37
|
+
rotate: 270deg;
|
|
38
|
+
display: block;
|
|
39
|
+
position: absolute;
|
|
40
|
+
top: 35px;
|
|
41
|
+
left: -38px;
|
|
42
|
+
font-weight: 600;
|
|
43
|
+
font-family: monospace;
|
|
44
|
+
font-size: 24px;
|
|
21
45
|
}`;
|
|
22
46
|
constructor() {
|
|
23
47
|
super();
|
|
@@ -28,6 +52,12 @@ export class DemoView extends BaseCustomWebComponentLazyAppend {
|
|
|
28
52
|
this._loading.id = 'loading';
|
|
29
53
|
this._loading.textContent = '🛀 Hold on, loading...';
|
|
30
54
|
this.shadowRoot.appendChild(this._loading);
|
|
55
|
+
const div = document.createElement("div");
|
|
56
|
+
div.id = "left";
|
|
57
|
+
const span = document.createElement("span");
|
|
58
|
+
span.innerText = "PREVIEW";
|
|
59
|
+
div.appendChild(span);
|
|
60
|
+
this.shadowRoot.appendChild(div);
|
|
31
61
|
}
|
|
32
62
|
dispose() {
|
|
33
63
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -118,6 +118,7 @@ export * from "./elements/services/propertiesService/services/PolymerPropertiesS
|
|
|
118
118
|
export * from "./elements/services/propertiesService/services/AbstractPropertiesService.js";
|
|
119
119
|
export * from "./elements/services/propertiesService/services/WebcomponentManifestPropertiesService.js";
|
|
120
120
|
export * from "./elements/services/propertiesService/services/AttributesPropertiesService.js";
|
|
121
|
+
export * from "./elements/services/propertiesService/services/CssCustomPropertiesService.js";
|
|
121
122
|
export * from "./elements/services/propertiesService/PropertyType.js";
|
|
122
123
|
export * from "./elements/services/propertiesService/ValueType.js";
|
|
123
124
|
export * from "./elements/services/propertiesService/PropertyTabsService.js";
|
package/dist/index.js
CHANGED
|
@@ -78,6 +78,7 @@ export * from "./elements/services/propertiesService/services/PolymerPropertiesS
|
|
|
78
78
|
export * from "./elements/services/propertiesService/services/AbstractPropertiesService.js";
|
|
79
79
|
export * from "./elements/services/propertiesService/services/WebcomponentManifestPropertiesService.js";
|
|
80
80
|
export * from "./elements/services/propertiesService/services/AttributesPropertiesService.js";
|
|
81
|
+
export * from "./elements/services/propertiesService/services/CssCustomPropertiesService.js";
|
|
81
82
|
export * from "./elements/services/propertiesService/PropertyType.js";
|
|
82
83
|
export * from "./elements/services/propertiesService/ValueType.js";
|
|
83
84
|
export * from "./elements/services/propertiesService/PropertyTabsService.js";
|