@node-projects/web-component-designer 0.0.168 → 0.0.169

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.
Files changed (44) hide show
  1. package/dist/elements/documentContainer.d.ts +7 -0
  2. package/dist/elements/documentContainer.js +23 -0
  3. package/dist/elements/helper/CssUnitConverter.js +11 -1
  4. package/dist/elements/item/DesignItem.d.ts +4 -1
  5. package/dist/elements/item/DesignItem.js +28 -1
  6. package/dist/elements/item/IDesignItem.d.ts +4 -1
  7. package/dist/elements/services/BaseServiceContainer.d.ts +4 -0
  8. package/dist/elements/services/BaseServiceContainer.js +4 -0
  9. package/dist/elements/services/DefaultServiceBootstrap.js +9 -2
  10. package/dist/elements/services/InstanceServiceContainer.d.ts +3 -0
  11. package/dist/elements/services/InstanceServiceContainer.js +3 -0
  12. package/dist/elements/services/ServiceContainer.d.ts +12 -3
  13. package/dist/elements/services/elementsService/IElementDefinition.d.ts +0 -3
  14. package/dist/elements/services/instanceService/DefaultInstanceService.js +0 -12
  15. package/dist/elements/services/propertiesService/IPropertiesService.d.ts +2 -1
  16. package/dist/elements/services/propertiesService/IProperty copy.d.ts +22 -0
  17. package/dist/elements/services/propertiesService/IProperty copy.js +1 -0
  18. package/dist/elements/services/propertiesService/IPropertyGroup.d.ts +6 -0
  19. package/dist/elements/services/propertiesService/IPropertyGroup.js +1 -0
  20. package/dist/elements/services/propertiesService/IPropertyTabsService.d.ts +8 -0
  21. package/dist/elements/services/propertiesService/IPropertyTabsService.js +1 -0
  22. package/dist/elements/services/propertiesService/PropertyGroupsService.d.ts +2 -2
  23. package/dist/elements/services/propertiesService/PropertyTabsService.d.ts +17 -0
  24. package/dist/elements/services/propertiesService/PropertyTabsService.js +29 -0
  25. package/dist/elements/services/propertiesService/services/AbstractPropertiesService.d.ts +2 -1
  26. package/dist/elements/services/propertiesService/services/AbstractPropertiesService.js +7 -7
  27. package/dist/elements/services/propertiesService/services/CommonPropertiesService.d.ts +2 -1
  28. package/dist/elements/services/propertiesService/services/CssPropertiesService.d.ts +2 -1
  29. package/dist/elements/services/propertiesService/services/CssPropertiesService.js +8 -2
  30. package/dist/elements/services/stylesheetService/CssTreeStylesheetService.d.ts +47 -0
  31. package/dist/elements/services/stylesheetService/CssTreeStylesheetService.js +183 -0
  32. package/dist/elements/services/stylesheetService/IStylesheetService.d.ts +29 -0
  33. package/dist/elements/services/stylesheetService/IStylesheetService.js +1 -0
  34. package/dist/elements/services/stylesheetService/SpecificityCalculator.d.ts +7 -0
  35. package/dist/elements/services/stylesheetService/SpecificityCalculator.js +178 -0
  36. package/dist/elements/services/stylesheetService/StylesheetService.d.ts +28 -0
  37. package/dist/elements/services/stylesheetService/StylesheetService.js +108 -0
  38. package/dist/elements/widgets/designerView/designerCanvas.d.ts +6 -0
  39. package/dist/elements/widgets/designerView/designerCanvas.js +73 -34
  40. package/dist/elements/widgets/propertyGrid/PropertyGridPropertyList.d.ts +2 -0
  41. package/dist/elements/widgets/propertyGrid/PropertyGridPropertyList.js +96 -66
  42. package/dist/index.d.ts +6 -2
  43. package/dist/index.js +3 -1
  44. package/package.json +6 -3
@@ -8,6 +8,7 @@ import { IUiCommandHandler } from '../commandHandling/IUiCommandHandler.js';
8
8
  import { IUiCommand } from '../commandHandling/IUiCommand.js';
9
9
  import { IDisposable } from '../interfaces/IDisposable.js';
10
10
  import { ISelectionChangedEvent } from "./services/selectionService/ISelectionChangedEvent.js";
11
+ import { IStylesheet } from "./services/stylesheetService/IStylesheetService.js";
11
12
  export declare class DocumentContainer extends BaseCustomWebComponentLazyAppend implements IUiCommandHandler, IDisposable {
12
13
  designerView: DesignerView;
13
14
  codeView: ICodeView & HTMLElement;
@@ -16,6 +17,12 @@ export declare class DocumentContainer extends BaseCustomWebComponentLazyAppend
16
17
  private _additionalStyle;
17
18
  set additionalStyleString(style: string);
18
19
  get additionalStyleString(): string;
20
+ private _additionalStylesheets;
21
+ set additionalStylesheets(stylesheets: IStylesheet[]);
22
+ get additionalStylesheets(): IStylesheet[];
23
+ additionalStylesheetChanged: TypedEvent<{
24
+ stylesheet: IStylesheet;
25
+ }>;
19
26
  onContentChanged: TypedEvent<void>;
20
27
  private _serviceContainer;
21
28
  private _content;
@@ -17,6 +17,29 @@ export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
17
17
  return this._additionalStyle;
18
18
  }
19
19
  ;
20
+ _additionalStylesheets;
21
+ set additionalStylesheets(stylesheets) {
22
+ this._additionalStylesheets = stylesheets;
23
+ if (!this.instanceServiceContainer.stylesheetService) {
24
+ const stylesheetService = this.designerView.serviceContainer.getLastService('stylesheetService');
25
+ if (stylesheetService) {
26
+ const instance = stylesheetService(this.designerView.designerCanvas);
27
+ this.instanceServiceContainer.register("stylesheetService", instance);
28
+ instance.stylesheetChanged.on(s => this.additionalStylesheetChanged.emit(s));
29
+ }
30
+ else {
31
+ console.warn("no Stylesheet-Service registered, but additionalStylesheets are used.");
32
+ }
33
+ }
34
+ if (this.designerView.instanceServiceContainer.stylesheetService)
35
+ this.designerView.instanceServiceContainer.stylesheetService.setStylesheets(stylesheets);
36
+ }
37
+ ;
38
+ get additionalStylesheets() {
39
+ return this._additionalStylesheets;
40
+ }
41
+ ;
42
+ additionalStylesheetChanged = new TypedEvent;
20
43
  onContentChanged = new TypedEvent();
21
44
  _serviceContainer;
22
45
  _content = '';
@@ -1,5 +1,5 @@
1
1
  //unsupported: ex, ch, svw, svh, vw, lvh, dvw, dvh
2
- const units = ['px', 'cm', 'mm', 'q', 'in', 'pc', 'pt', 'rem', 'em', 'vw', 'vh', 'vmin', 'vmax', 'lh', 'rlh', '%', 'ms', 's', 'deg', 'rad', 'grad', 'turn'];
2
+ const units = ['px', 'cm', 'mm', 'q', 'in', 'pc', 'pt', 'rem', 'em', 'vw', 'vh', 'vmin', 'vmax', 'lh', 'rlh', '%', 'ms', 's', 'deg', 'rad', 'grad', 'turn', 'cqw', 'cqh', 'cqi', 'cqb', 'cqmin', 'cqmax'];
3
3
  const pattern = new RegExp(`^([\-\+]?(?:\\d+(?:\\.\\d+)?))(${units.join('|')})$`, 'i');
4
4
  export function convertCssUnitToPixel(cssValue, target, percentTarget) {
5
5
  const supportedUnits = {
@@ -21,6 +21,16 @@ export function convertCssUnitToPixel(cssValue, target, percentTarget) {
21
21
  'lh': value => value * parseFloat(getComputedStyle(target).lineHeight),
22
22
  'rlh': value => value * parseFloat(getComputedStyle(document.documentElement).lineHeight),
23
23
  '%': value => value / 100 * (percentTarget == 'heigth' ? target.getBoundingClientRect().height : target.getBoundingClientRect().width),
24
+ /* todo
25
+ //find parent with computed style where contaner-type is inline-size or size (regarding to query type)
26
+ //use this size for calculation
27
+ 'cqw':
28
+ 'cqh':
29
+ 'cqi':
30
+ 'cqb':
31
+ 'cqmin':
32
+ 'cqmax':
33
+ */
24
34
  // Times
25
35
  'ms': value => value,
26
36
  's': value => value * 1000,
@@ -7,6 +7,7 @@ import { ExtensionType } from '../widgets/designerView/extensions/ExtensionType.
7
7
  import { IDesignerExtension } from '../widgets/designerView/extensions/IDesignerExtension.js';
8
8
  import { ISize } from '../../interfaces/ISize.js';
9
9
  import { IDesignerExtensionProvider } from '../widgets/designerView/extensions/IDesignerExtensionProvider.js';
10
+ import { IStyleRule } from '../services/stylesheetService/IStylesheetService.js';
10
11
  export declare class DesignItem implements IDesignItem {
11
12
  lastContainerSize: ISize;
12
13
  parsedNode: any;
@@ -72,8 +73,10 @@ export declare class DesignItem implements IDesignItem {
72
73
  getOrCreateDesignItem(node: Node): IDesignItem;
73
74
  static GetOrCreateDesignItem(node: Node, serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer): IDesignItem;
74
75
  static GetDesignItem(node: Node): IDesignItem;
75
- setStyle(name: string, value?: string | null): void;
76
+ setStyle(name: string, value?: string | null, important?: boolean): void;
76
77
  removeStyle(name: string): void;
78
+ updateStyleInSheetOrLocal(name: string, value?: string | null, important?: boolean): void;
79
+ getAllStyles(): IStyleRule[];
77
80
  setAttribute(name: string, value?: string | null): void;
78
81
  removeAttribute(name: string): void;
79
82
  _insertChildInternal(designItem: IDesignItem, index?: number): void;
@@ -292,7 +292,7 @@ export class DesignItem {
292
292
  let designItem = DesignItem._designItemMap.get(node);
293
293
  return designItem;
294
294
  }
295
- setStyle(name, value) {
295
+ setStyle(name, value, important) {
296
296
  let nm = PropertiesHelper.camelToDashCase(name);
297
297
  const action = new CssStyleChangeAction(this, nm, value, this._styles.get(nm));
298
298
  this.instanceServiceContainer.undoService.execute(action);
@@ -302,6 +302,33 @@ export class DesignItem {
302
302
  const action = new CssStyleChangeAction(this, nm, '', this._styles.get(nm));
303
303
  this.instanceServiceContainer.undoService.execute(action);
304
304
  }
305
+ updateStyleInSheetOrLocal(name, value, important) {
306
+ let nm = PropertiesHelper.camelToDashCase(name);
307
+ const declaration = null;
308
+ //const declaration = this.serviceContainer.stylesheetService?.getDeclarations(d, property);
309
+ //const rules = this.serviceContainer.stylesheetService?.getAppliedRules(d, property);
310
+ if (!declaration) {
311
+ if (this.getStyle(nm) != value) {
312
+ this.setStyle(nm, value);
313
+ }
314
+ else if (value == null) {
315
+ this.removeStyle(nm);
316
+ }
317
+ }
318
+ //todo -> modify stylesheet, or local css
319
+ //we need undo for modification of stylesheet, look how we do this
320
+ //maybe undo in stylsheet service?
321
+ }
322
+ getAllStyles() {
323
+ const localStyles = [...this._styles.entries()].map(x => ({ name: x[0], value: x[1], important: false }));
324
+ if (this.instanceServiceContainer.stylesheetService) {
325
+ const rules = this.instanceServiceContainer.stylesheetService?.getAppliedRules(this);
326
+ if (rules) {
327
+ return [{ selector: null, declarations: localStyles, specificity: -1 }, ...rules];
328
+ }
329
+ }
330
+ return [{ selector: null, declarations: localStyles, specificity: -1 }];
331
+ }
305
332
  setAttribute(name, value) {
306
333
  const action = new AttributeChangeAction(this, name, value, this._attributes.get(name));
307
334
  this.instanceServiceContainer.undoService.execute(action);
@@ -6,6 +6,7 @@ import { ExtensionType } from '../widgets/designerView/extensions/ExtensionType.
6
6
  import { IDesignerExtension } from '../widgets/designerView/extensions/IDesignerExtension.js';
7
7
  import { ISize } from "../../interfaces/ISize.js";
8
8
  import { IDesignerExtensionProvider } from '../widgets/designerView/extensions/IDesignerExtensionProvider.js';
9
+ import { IStyleRule } from '../services/stylesheetService/IStylesheetService.js';
9
10
  export interface IDesignItem {
10
11
  lastContainerSize: ISize;
11
12
  replaceNode(newNode: Node): any;
@@ -51,8 +52,10 @@ export interface IDesignItem {
51
52
  styles(): Iterable<[name: string, value: string]>;
52
53
  getStyle(name: string): any;
53
54
  hasStyle(name: string): any;
54
- setStyle(name: string, value?: string | null): any;
55
+ setStyle(name: string, value?: string | null, important?: boolean): any;
55
56
  removeStyle(name: string): any;
57
+ updateStyleInSheetOrLocal(name: string, value?: string | null, important?: boolean): any;
58
+ getAllStyles(): IStyleRule[];
56
59
  attributes(): Iterable<[name: string, value: string]>;
57
60
  getAttribute(name: string): any;
58
61
  hasAttribute(name: string): any;
@@ -1,6 +1,10 @@
1
+ import { TypedEvent } from '@node-projects/base-custom-webcomponent';
1
2
  import { IService } from './IService.js';
2
3
  export declare class BaseServiceContainer<NameMap> {
3
4
  protected _services: Map<string, IService[]>;
5
+ servicesChanged: TypedEvent<{
6
+ serviceName: keyof NameMap;
7
+ }>;
4
8
  getLastService<K extends keyof NameMap>(service: K): NameMap[K];
5
9
  getServices<K extends keyof NameMap>(service: K): NameMap[K][];
6
10
  register<K extends keyof NameMap>(name: K, service: NameMap[K]): void;
@@ -1,5 +1,7 @@
1
+ import { TypedEvent } from '@node-projects/base-custom-webcomponent';
1
2
  export class BaseServiceContainer {
2
3
  _services = new Map();
4
+ servicesChanged = new TypedEvent();
3
5
  getLastService(service) {
4
6
  let list = this._services.get(service);
5
7
  if (list && list.length)
@@ -13,12 +15,14 @@ export class BaseServiceContainer {
13
15
  if (!this._services.has(name))
14
16
  this._services.set(name, []);
15
17
  this._services.get(name).push(service);
18
+ this.servicesChanged.emit({ serviceName: name });
16
19
  }
17
20
  registerMultiple(names, service) {
18
21
  for (const name of names) {
19
22
  if (!this._services.has(name))
20
23
  this._services.set(name, []);
21
24
  this._services.get(name).push(service);
25
+ this.servicesChanged.emit({ serviceName: name });
22
26
  }
23
27
  }
24
28
  forSomeServicesTillResult(service, callback) {
@@ -67,11 +67,14 @@ import { GrayOutDragOverContainerExtensionProvider } from '../widgets/designerVi
67
67
  import { LineExtensionProvider } from '../widgets/designerView/extensions/svg/LineExtensionProvider.js';
68
68
  import { RectExtentionProvider } from '../widgets/designerView/extensions/svg/RectExtensionProvider.js';
69
69
  import { EllipsisExtensionProvider } from '../widgets/designerView/extensions/svg/EllipsisExtensionProvider.js';
70
- import { PropertyGroupsService } from './propertiesService/PropertyGroupsService.js';
70
+ import { PropertyTabsService } from './propertiesService/PropertyTabsService.js';
71
71
  import { PlacementExtensionProvider } from '../widgets/designerView/extensions/PlacementExtensionProvider.js';
72
72
  import { FlexboxExtensionProvider } from '../widgets/designerView/extensions/FlexboxExtensionProvider.js';
73
73
  import { FlexboxExtensionDesignViewConfigButtons } from '../widgets/designerView/extensions/FlexboxExtensionDesignViewConfigButtons.js';
74
74
  import { InvisibleElementExtensionDesignViewConfigButtons } from '../widgets/designerView/extensions/InvisibleElementExtensionDesignViewConfigButtons.js';
75
+ import { UndoService } from './undoService/UndoService.js';
76
+ import { SelectionService } from './selectionService/SelectionService.js';
77
+ import { ContentService } from './contentService/ContentService.js';
75
78
  export function createDefaultServiceContainer() {
76
79
  let serviceContainer = new ServiceContainer();
77
80
  serviceContainer.register("propertyService", new PolymerPropertiesService());
@@ -80,7 +83,7 @@ export function createDefaultServiceContainer() {
80
83
  serviceContainer.register("propertyService", new SVGElementsPropertiesService());
81
84
  serviceContainer.register("propertyService", new Lit2PropertiesService());
82
85
  serviceContainer.register("propertyService", new BaseCustomWebComponentPropertiesService());
83
- serviceContainer.register("propertyGroupsService", new PropertyGroupsService());
86
+ serviceContainer.register("propertyGroupsService", new PropertyTabsService());
84
87
  serviceContainer.register("instanceService", new DefaultInstanceService());
85
88
  serviceContainer.register("editorTypesService", new DefaultEditorTypesService());
86
89
  serviceContainer.register("htmlWriterService", new HtmlWriterService());
@@ -94,6 +97,10 @@ export function createDefaultServiceContainer() {
94
97
  serviceContainer.register("copyPasteService", new CopyPasteService());
95
98
  serviceContainer.register("modelCommandService", new DefaultModelCommandService());
96
99
  serviceContainer.register("demoProviderService", new DemoProviderService());
100
+ serviceContainer.register("undoService", (designerCanvas) => new UndoService(designerCanvas));
101
+ serviceContainer.register("selectionService", (designerCanvas) => new SelectionService(designerCanvas));
102
+ serviceContainer.register("contentService", (designerCanvas) => new ContentService(designerCanvas.rootDesignItem));
103
+ //serviceContainer.register("stylesheetService", new DemoProviderService());
97
104
  serviceContainer.designerExtensions.set(ExtensionType.Permanent, [
98
105
  // new ResizeExtensionProvider(false),
99
106
  new InvisibleElementExtensionProvider(),
@@ -4,10 +4,12 @@ import { BaseServiceContainer } from './BaseServiceContainer.js';
4
4
  import { IContentService } from './contentService/IContentService.js';
5
5
  import { IDesignContext } from '../widgets/designerView/IDesignContext.js';
6
6
  import { IDesignerCanvas } from '../widgets/designerView/IDesignerCanvas.js';
7
+ import { IStylesheetService } from './stylesheetService/IStylesheetService.js';
7
8
  interface InstanceServiceNameMap {
8
9
  "undoService": IUndoService;
9
10
  "selectionService": ISelectionService;
10
11
  "contentService": IContentService;
12
+ "stylesheetService": IStylesheetService;
11
13
  }
12
14
  export declare class InstanceServiceContainer extends BaseServiceContainer<InstanceServiceNameMap> {
13
15
  designContext: IDesignContext;
@@ -17,5 +19,6 @@ export declare class InstanceServiceContainer extends BaseServiceContainer<Insta
17
19
  get undoService(): IUndoService;
18
20
  get selectionService(): ISelectionService;
19
21
  get contentService(): IContentService;
22
+ get stylesheetService(): IStylesheetService;
20
23
  }
21
24
  export {};
@@ -17,4 +17,7 @@ export class InstanceServiceContainer extends BaseServiceContainer {
17
17
  get contentService() {
18
18
  return this.getLastService('contentService');
19
19
  }
20
+ get stylesheetService() {
21
+ return this.getLastService('stylesheetService');
22
+ }
20
23
  }
@@ -32,7 +32,12 @@ import { IProperty } from "./propertiesService/IProperty.js";
32
32
  import { IDesignItem } from "../item/IDesignItem.js";
33
33
  import { IBinding } from '../item/IBinding.js';
34
34
  import { BindingTarget } from '../item/BindingTarget.js';
35
- import { IPropertyGroupsService } from './propertiesService/IPropertyGroupsService.js';
35
+ import { IPropertyTabsService } from './propertiesService/IPropertyTabsService.js';
36
+ import { IUndoService } from './undoService/IUndoService.js';
37
+ import { ISelectionService } from './selectionService/ISelectionService.js';
38
+ import { IContentService } from './contentService/IContentService.js';
39
+ import { IStylesheetService } from './stylesheetService/IStylesheetService.js';
40
+ import { IDesignerCanvas } from '../widgets/designerView/IDesignerCanvas.js';
36
41
  interface ServiceNameMap {
37
42
  "propertyService": IPropertiesService;
38
43
  "containerService": IPlacementService;
@@ -52,7 +57,11 @@ interface ServiceNameMap {
52
57
  "modelCommandService": IModelCommandService;
53
58
  "demoProviderService": IDemoProviderService;
54
59
  "elementInteractionService": IElementInteractionService;
55
- "propertyGroupsService": IPropertyGroupsService;
60
+ "propertyGroupsService": IPropertyTabsService;
61
+ "undoService": (designerCanvas: IDesignerCanvas) => IUndoService;
62
+ "selectionService": (designerCanvas: IDesignerCanvas) => ISelectionService;
63
+ "contentService": (designerCanvas: IDesignerCanvas) => IContentService;
64
+ "stylesheetService": (designerCanvas: IDesignerCanvas) => IStylesheetService;
56
65
  }
57
66
  export declare class ServiceContainer extends BaseServiceContainer<ServiceNameMap> {
58
67
  readonly config: {
@@ -76,7 +85,7 @@ export declare class ServiceContainer extends BaseServiceContainer<ServiceNameMa
76
85
  get bindableObjectDragDropService(): IBindableObjectDragDropService;
77
86
  get elementInteractionServices(): IElementInteractionService[];
78
87
  get propertiesServices(): IPropertiesService[];
79
- get propertyGroupService(): IPropertyGroupsService;
88
+ get propertyGroupService(): IPropertyTabsService;
80
89
  get containerServices(): IPlacementService[];
81
90
  get snaplinesProviderService(): ISnaplinesProviderService;
82
91
  get elementsServices(): IElementsService[];
@@ -13,9 +13,6 @@ export interface IElementDefinition {
13
13
  defaultStyles?: {
14
14
  [key: string]: string;
15
15
  };
16
- defaultProperties?: {
17
- [key: string]: any;
18
- };
19
16
  defaultWidth?: string;
20
17
  defaultHeight?: string;
21
18
  ghostElement?: Element;
@@ -66,18 +66,6 @@ export class DefaultInstanceService {
66
66
  }
67
67
  }
68
68
  let designItem = DesignItem.createDesignItemFromInstance(element, serviceContainer, instanceServiceContainer);
69
- if (definition.defaultProperties) {
70
- let propertiesService = null;
71
- if (definition.type) {
72
- propertiesService = serviceContainer.getLastServiceWhere('propertyService', (x) => x.isHandledElement(designItem));
73
- }
74
- let properties = propertiesService.getProperties(designItem);
75
- for (let a in definition.defaultProperties) {
76
- let value = definition.defaultProperties[a];
77
- let p = properties.find(x => x.name == a);
78
- propertiesService.setValue([designItem], p, value);
79
- }
80
- }
81
69
  return designItem;
82
70
  }
83
71
  }
@@ -4,6 +4,7 @@ import { IDesignItem } from '../../item/IDesignItem.js';
4
4
  import { ValueType } from './ValueType.js';
5
5
  import { BindingTarget } from '../../item/BindingTarget.js';
6
6
  import { IBinding } from '../../item/IBinding.js';
7
+ import { IPropertyGroup } from './IPropertyGroup.js';
7
8
  export declare enum RefreshMode {
8
9
  none = 0,
9
10
  full = 1,
@@ -12,7 +13,7 @@ export declare enum RefreshMode {
12
13
  export interface IPropertiesService extends IService {
13
14
  getRefreshMode(designItem: IDesignItem): RefreshMode;
14
15
  isHandledElement(designItem: IDesignItem): boolean;
15
- getProperties(designItem: IDesignItem): IProperty[];
16
+ getProperties(designItem: IDesignItem): IProperty[] | IPropertyGroup[];
16
17
  getProperty(designItem: IDesignItem, name: string): IProperty;
17
18
  getBinding(designItems: IDesignItem[], property: IProperty): IBinding;
18
19
  getPropertyTarget(designItem: IDesignItem, property: IProperty): BindingTarget;
@@ -0,0 +1,22 @@
1
+ import { IPropertiesService } from './IPropertiesService.js';
2
+ import { IPropertyEditor } from './IPropertyEditor.js';
3
+ import { PropertyType } from './PropertyType.js';
4
+ export interface IProperty {
5
+ name: string;
6
+ renamable?: boolean;
7
+ propertyName?: string;
8
+ attributeName?: string;
9
+ description?: string;
10
+ type?: 'addNew' | 'json' | 'color' | 'date' | 'number' | 'list' | 'enum' | 'boolean' | 'img-lis' | 'thickness' | 'css-length' | 'string' | string;
11
+ default?: any;
12
+ min?: number;
13
+ max?: number;
14
+ step?: number;
15
+ values?: string[];
16
+ enumValues?: [name: string, value: string | number][];
17
+ createEditor?: (property: IProperty) => IPropertyEditor;
18
+ value?: any;
19
+ service: IPropertiesService;
20
+ defaultValue?: any;
21
+ propertyType: PropertyType;
22
+ }
@@ -0,0 +1,6 @@
1
+ import { IProperty } from './IProperty.js';
2
+ export interface IPropertyGroup {
3
+ name: string;
4
+ description?: string;
5
+ properties: IProperty[];
6
+ }
@@ -0,0 +1,8 @@
1
+ import { IDesignItem } from '../../item/IDesignItem.js';
2
+ import { IPropertiesService } from './IPropertiesService.js';
3
+ export interface IPropertyTabsService {
4
+ getPropertygroups(designItems: IDesignItem[]): {
5
+ name: string;
6
+ propertiesService: IPropertiesService;
7
+ }[];
8
+ }
@@ -1,7 +1,7 @@
1
1
  import { IDesignItem } from '../../item/IDesignItem.js';
2
2
  import { IPropertiesService } from './IPropertiesService.js';
3
- import { IPropertyGroupsService } from './IPropertyGroupsService.js';
4
- export declare class PropertyGroupsService implements IPropertyGroupsService {
3
+ import { IPropertyTabsService } from './IPropertyTabsService.js';
4
+ export declare class PropertyGroupsService implements IPropertyTabsService {
5
5
  protected _pgList: {
6
6
  name: string;
7
7
  propertiesService: IPropertiesService;
@@ -0,0 +1,17 @@
1
+ import { IDesignItem } from '../../item/IDesignItem.js';
2
+ import { IPropertiesService } from './IPropertiesService.js';
3
+ import { IPropertyTabsService } from './IPropertyTabsService.js';
4
+ export declare class PropertyTabsService implements IPropertyTabsService {
5
+ protected _pgList: {
6
+ name: string;
7
+ propertiesService: IPropertiesService;
8
+ }[];
9
+ protected _svgPgList: {
10
+ name: string;
11
+ propertiesService: IPropertiesService;
12
+ }[];
13
+ getPropertygroups(designItems: IDesignItem[]): {
14
+ name: string;
15
+ propertiesService: IPropertiesService;
16
+ }[];
17
+ }
@@ -0,0 +1,29 @@
1
+ import { AttributesPropertiesService } from './services/AttributesPropertiesService.js';
2
+ import { CommonPropertiesService } from './services/CommonPropertiesService.js';
3
+ import { CssPropertiesService } from './services/CssPropertiesService.js';
4
+ export class PropertyTabsService {
5
+ _pgList = [
6
+ { name: 'properties', propertiesService: null },
7
+ { name: 'attributes', propertiesService: new AttributesPropertiesService() },
8
+ { name: 'common', propertiesService: new CommonPropertiesService() },
9
+ { name: 'styles', propertiesService: new CssPropertiesService("styles") },
10
+ { name: 'layout', propertiesService: new CssPropertiesService("layout") },
11
+ { name: 'flex', propertiesService: new CssPropertiesService("flex") },
12
+ { name: 'grid', propertiesService: new CssPropertiesService("grid") },
13
+ ];
14
+ _svgPgList = [
15
+ { name: 'properties', propertiesService: null },
16
+ { name: 'attributes', propertiesService: new AttributesPropertiesService() },
17
+ { name: 'styles', propertiesService: new CssPropertiesService("styles") },
18
+ { name: 'layout', propertiesService: new CssPropertiesService("layout") },
19
+ ];
20
+ getPropertygroups(designItems) {
21
+ if (designItems == null || designItems.length == 0)
22
+ return [];
23
+ this._pgList[0].propertiesService = designItems[0].serviceContainer.getLastServiceWhere('propertyService', x => x.isHandledElement(designItems[0]));
24
+ this._svgPgList[0].propertiesService = designItems[0].serviceContainer.getLastServiceWhere('propertyService', x => x.isHandledElement(designItems[0]));
25
+ if (designItems[0].element instanceof SVGElement)
26
+ return this._svgPgList;
27
+ return this._pgList;
28
+ }
29
+ }
@@ -4,12 +4,13 @@ import { IDesignItem } from '../../../item/IDesignItem.js';
4
4
  import { ValueType } from '../ValueType.js';
5
5
  import { BindingTarget } from '../../../item/BindingTarget.js';
6
6
  import { IBinding } from '../../../item/IBinding.js';
7
+ import { IPropertyGroup } from '../IPropertyGroup.js';
7
8
  export declare abstract class AbstractPropertiesService implements IPropertiesService {
8
9
  abstract getRefreshMode(designItem: IDesignItem): RefreshMode;
9
10
  abstract isHandledElement(designItem: IDesignItem): boolean;
10
11
  protected _notifyChangedProperty(designItem: IDesignItem, property: IProperty, value: any): void;
11
12
  getProperty(designItem: IDesignItem, name: string): IProperty;
12
- abstract getProperties(designItem: IDesignItem): IProperty[];
13
+ abstract getProperties(designItem: IDesignItem): IProperty[] | IPropertyGroup[];
13
14
  setValue(designItems: IDesignItem[], property: IProperty, value: any): void;
14
15
  getPropertyTarget(designItem: IDesignItem, property: IProperty): BindingTarget;
15
16
  clearValue(designItems: IDesignItem[], property: IProperty): void;
@@ -7,18 +7,18 @@ export class AbstractPropertiesService {
7
7
  _notifyChangedProperty(designItem, property, value) {
8
8
  }
9
9
  getProperty(designItem, name) {
10
- return this.getProperties(designItem).find(x => x.name == name);
10
+ let properties = this.getProperties(designItem);
11
+ if ('properties' in properties[0]) {
12
+ return properties.flatMap(x => x.properties).find(x => x.name == name);
13
+ }
14
+ else
15
+ return properties.find(x => x.name == name);
11
16
  }
12
17
  setValue(designItems, property, value) {
13
18
  const cg = designItems[0].openGroup("properties changed");
14
19
  for (let d of designItems) {
15
20
  if (property.propertyType == PropertyType.cssValue) {
16
- if (d.getStyle(property.name) != value) {
17
- d.setStyle(property.name, value);
18
- }
19
- else {
20
- this.clearValue(designItems, property);
21
- }
21
+ d.updateStyleInSheetOrLocal(property.name, value);
22
22
  //unkown css property names do not trigger the mutation observer of property grid,
23
23
  //fixed by assinging stle again to the attribute
24
24
  d.element.setAttribute('style', d.element.getAttribute('style'));
@@ -2,11 +2,12 @@ import { IProperty } from '../IProperty.js';
2
2
  import { IDesignItem } from '../../../item/IDesignItem.js';
3
3
  import { AbstractPropertiesService } from './AbstractPropertiesService.js';
4
4
  import { RefreshMode } from '../IPropertiesService.js';
5
+ import { IPropertyGroup } from '../IPropertyGroup.js';
5
6
  export declare class CommonPropertiesService extends AbstractPropertiesService {
6
7
  getRefreshMode(designItem: IDesignItem): RefreshMode;
7
8
  private commonProperties;
8
9
  name: string;
9
10
  isHandledElement(designItem: IDesignItem): boolean;
10
11
  getProperty(designItem: IDesignItem, name: string): IProperty;
11
- getProperties(designItem: IDesignItem): IProperty[];
12
+ getProperties(designItem: IDesignItem): IProperty[] | IPropertyGroup[];
12
13
  }
@@ -3,6 +3,7 @@ import { IDesignItem } from '../../../item/IDesignItem.js';
3
3
  import { BindingTarget } from '../../../item/BindingTarget.js';
4
4
  import { CommonPropertiesService } from './CommonPropertiesService.js';
5
5
  import { RefreshMode } from '../IPropertiesService.js';
6
+ import { IPropertyGroup } from '../IPropertyGroup.js';
6
7
  export declare class CssPropertiesService extends CommonPropertiesService {
7
8
  getRefreshMode(designItem: IDesignItem): RefreshMode.none | RefreshMode.fullOnValueChange;
8
9
  layout: IProperty[];
@@ -11,7 +12,7 @@ export declare class CssPropertiesService extends CommonPropertiesService {
11
12
  constructor(name: 'styles' | 'layout' | 'grid' | 'flex');
12
13
  isHandledElement(designItem: IDesignItem): boolean;
13
14
  getProperty(designItem: IDesignItem, name: string): IProperty;
14
- getProperties(designItem: IDesignItem): IProperty[];
15
+ getProperties(designItem: IDesignItem): IProperty[] | IPropertyGroup[];
15
16
  getPropertyTarget(designItem: IDesignItem, property: IProperty): BindingTarget;
16
17
  setValue(designItems: IDesignItem[], property: IProperty, value: any): void;
17
18
  }
@@ -195,8 +195,14 @@ export class CssPropertiesService extends CommonPropertiesService {
195
195
  if (this.name == 'styles') {
196
196
  if (!designItem)
197
197
  return [];
198
- let arr = Array.from(designItem.styles(), ([key, value]) => ({ name: key, renamable: true, type: 'string', service: this, propertyType: PropertyType.cssValue }));
199
- arr.push({ name: '', type: 'addNew', service: this, propertyType: PropertyType.complex });
198
+ let styles = designItem.getAllStyles();
199
+ let arr = styles.map(x => ({ name: x.selector ?? '&lt;local&gt;', 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 });
200
206
  return arr;
201
207
  }
202
208
  return this[this.name];
@@ -0,0 +1,47 @@
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
+ constructor();
30
+ setStylesheets(stylesheets: IStylesheet[]): void;
31
+ getStylesheets(): IStylesheet[];
32
+ private getAppliedRulesInternal;
33
+ getAppliedRules(designItem: IDesignItem): IRuleWithAST[];
34
+ private getDeclarationInternal;
35
+ getDeclarations(designItem: IDesignItem, prop: IProperty): IDeclarationWithAST[];
36
+ updateDeclarationWithProperty(designItem: IDesignItem, property: IProperty, value: string, important: boolean): boolean;
37
+ updateDeclarationWithDeclaration(declaration: IDeclarationWithAST, value: string, important: boolean): boolean;
38
+ private rulesFromAST;
39
+ private astHasChildren;
40
+ private buildSelectorString;
41
+ private getSpecificity;
42
+ private findDeclarationInRule;
43
+ private elementMatchesASelector;
44
+ private buildAtRuleString;
45
+ private sortDeclarations;
46
+ }
47
+ export {};