@silexlabs/grapesjs-advanced-selector 1.0.8-0 → 1.0.8-2

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 (98) hide show
  1. package/README.md +7 -1
  2. package/package.json +2 -1
  3. package/dist/StylableElement.d.ts +0 -6
  4. package/dist/StylableElement.d.ts.map +0 -1
  5. package/dist/StylableElement.js +0 -26
  6. package/dist/StylableElement.js.map +0 -1
  7. package/dist/components/complex-selector.d.ts +0 -38
  8. package/dist/components/complex-selector.d.ts.map +0 -1
  9. package/dist/components/complex-selector.js +0 -177
  10. package/dist/components/complex-selector.js.map +0 -1
  11. package/dist/components/compound-selector.d.ts +0 -38
  12. package/dist/components/compound-selector.d.ts.map +0 -1
  13. package/dist/components/compound-selector.js +0 -205
  14. package/dist/components/compound-selector.js.map +0 -1
  15. package/dist/components/current-selector-display.d.ts +0 -23
  16. package/dist/components/current-selector-display.d.ts.map +0 -1
  17. package/dist/components/current-selector-display.js +0 -266
  18. package/dist/components/current-selector-display.js.map +0 -1
  19. package/dist/components/inline-select.d.ts +0 -29
  20. package/dist/components/inline-select.d.ts.map +0 -1
  21. package/dist/components/inline-select.js +0 -201
  22. package/dist/components/inline-select.js.map +0 -1
  23. package/dist/components/resize-input.d.ts +0 -5
  24. package/dist/components/resize-input.d.ts.map +0 -1
  25. package/dist/components/resize-input.js +0 -17
  26. package/dist/components/resize-input.js.map +0 -1
  27. package/dist/components/simple-selector.d.ts +0 -45
  28. package/dist/components/simple-selector.d.ts.map +0 -1
  29. package/dist/components/simple-selector.js +0 -468
  30. package/dist/components/simple-selector.js.map +0 -1
  31. package/dist/i18n/en.d.ts +0 -75
  32. package/dist/i18n/en.d.ts.map +0 -1
  33. package/dist/i18n/en.js +0 -74
  34. package/dist/i18n/en.js.map +0 -1
  35. package/dist/i18n/fr.d.ts +0 -75
  36. package/dist/i18n/fr.d.ts.map +0 -1
  37. package/dist/i18n/fr.js +0 -74
  38. package/dist/i18n/fr.js.map +0 -1
  39. package/dist/index.d.ts +0 -18
  40. package/dist/index.d.ts.map +0 -1
  41. package/dist/index.js +0 -637
  42. package/dist/index.js.map +0 -1
  43. package/dist/model/ComplexSelector.d.ts +0 -34
  44. package/dist/model/ComplexSelector.d.ts.map +0 -1
  45. package/dist/model/ComplexSelector.js +0 -137
  46. package/dist/model/ComplexSelector.js.map +0 -1
  47. package/dist/model/ComplexSelector.test.d.ts +0 -2
  48. package/dist/model/ComplexSelector.test.d.ts.map +0 -1
  49. package/dist/model/ComplexSelector.test.js +0 -308
  50. package/dist/model/ComplexSelector.test.js.map +0 -1
  51. package/dist/model/CompoundSelector.d.ts +0 -25
  52. package/dist/model/CompoundSelector.d.ts.map +0 -1
  53. package/dist/model/CompoundSelector.js +0 -113
  54. package/dist/model/CompoundSelector.js.map +0 -1
  55. package/dist/model/CompoundSelector.test.d.ts +0 -2
  56. package/dist/model/CompoundSelector.test.d.ts.map +0 -1
  57. package/dist/model/CompoundSelector.test.js +0 -193
  58. package/dist/model/CompoundSelector.test.js.map +0 -1
  59. package/dist/model/GrapesJsSelectors.d.ts +0 -48
  60. package/dist/model/GrapesJsSelectors.d.ts.map +0 -1
  61. package/dist/model/GrapesJsSelectors.js +0 -488
  62. package/dist/model/GrapesJsSelectors.js.map +0 -1
  63. package/dist/model/GrapesJsSelectors.test.d.ts +0 -2
  64. package/dist/model/GrapesJsSelectors.test.d.ts.map +0 -1
  65. package/dist/model/GrapesJsSelectors.test.js +0 -695
  66. package/dist/model/GrapesJsSelectors.test.js.map +0 -1
  67. package/dist/model/Operator.d.ts +0 -28
  68. package/dist/model/Operator.d.ts.map +0 -1
  69. package/dist/model/Operator.js +0 -116
  70. package/dist/model/Operator.js.map +0 -1
  71. package/dist/model/Operator.test.d.ts +0 -2
  72. package/dist/model/Operator.test.d.ts.map +0 -1
  73. package/dist/model/Operator.test.js +0 -42
  74. package/dist/model/Operator.test.js.map +0 -1
  75. package/dist/model/PseudoClass.d.ts +0 -56
  76. package/dist/model/PseudoClass.d.ts.map +0 -1
  77. package/dist/model/PseudoClass.js +0 -123
  78. package/dist/model/PseudoClass.js.map +0 -1
  79. package/dist/model/PseudoClass.test.d.ts +0 -2
  80. package/dist/model/PseudoClass.test.d.ts.map +0 -1
  81. package/dist/model/PseudoClass.test.js +0 -19
  82. package/dist/model/PseudoClass.test.js.map +0 -1
  83. package/dist/model/SimpleSelector.d.ts +0 -104
  84. package/dist/model/SimpleSelector.d.ts.map +0 -1
  85. package/dist/model/SimpleSelector.js +0 -295
  86. package/dist/model/SimpleSelector.js.map +0 -1
  87. package/dist/model/SimpleSelector.test.d.ts +0 -2
  88. package/dist/model/SimpleSelector.test.d.ts.map +0 -1
  89. package/dist/model/SimpleSelector.test.js +0 -143
  90. package/dist/model/SimpleSelector.test.js.map +0 -1
  91. package/dist/plugin.d.ts +0 -18
  92. package/dist/plugin.d.ts.map +0 -1
  93. package/dist/plugin.js +0 -187
  94. package/dist/plugin.js.map +0 -1
  95. package/dist/styles.d.ts +0 -4
  96. package/dist/styles.d.ts.map +0 -1
  97. package/dist/styles.js +0 -38
  98. package/dist/styles.js.map +0 -1
package/README.md CHANGED
@@ -11,7 +11,13 @@ Before: GrapesJs default Selector Manager
11
11
 
12
12
  After:
13
13
 
14
- [GrapesJs Advanced Selector Manager](https://github.com/silexlabs/grapesjs-advanced-selector)
14
+ [GrapesJs Advanced Selector Manager](https://github.com/user-attachments/assets/14417ce8-004c-4657-a5a0-26d1969d06be)
15
+
16
+ With `body h1.btn` selected:
17
+
18
+ ![Advanced Selector Manager with complex selector](https://github.com/user-attachments/assets/8628cdf5-d19e-4838-9584-b94a20b12434)
19
+
20
+
15
21
 
16
22
  ### Links
17
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@silexlabs/grapesjs-advanced-selector",
3
- "version": "1.0.8-0",
3
+ "version": "1.0.8-2",
4
4
  "description": "A GrapesJS plugin for managing advanced CSS selectors with a visual interface",
5
5
  "keywords": [
6
6
  "grapesjs",
@@ -53,6 +53,7 @@
53
53
  "@types/jest": "^29.5.14",
54
54
  "babel-jest": "^29.7.0",
55
55
  "eslint": "^9.25.1",
56
+ "grapesjs-cli": "^4.1.3",
56
57
  "http-server": "^14.1.1",
57
58
  "husky": "^9.1.7",
58
59
  "jest": "^29.7.0",
@@ -1,6 +0,0 @@
1
- import { LitElement } from 'lit';
2
- export default class StylableElement extends LitElement {
3
- t: (key: string) => string;
4
- connectedCallback(): void;
5
- }
6
- //# sourceMappingURL=StylableElement.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"StylableElement.d.ts","sourceRoot":"","sources":["../src/StylableElement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAGhC,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,UAAU;IAEnD,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAe;IAElC,iBAAiB;CAO3B"}
@@ -1,26 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import { LitElement } from 'lit';
8
- import { property } from 'lit/decorators.js';
9
- export default class StylableElement extends LitElement {
10
- constructor() {
11
- super(...arguments);
12
- this.t = (key) => key;
13
- }
14
- connectedCallback() {
15
- super.connectedCallback();
16
- const styles = document.querySelectorAll('style, link[rel="stylesheet"]');
17
- styles.forEach(style => {
18
- var _a;
19
- (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.appendChild(style.cloneNode(true));
20
- });
21
- }
22
- }
23
- __decorate([
24
- property()
25
- ], StylableElement.prototype, "t", void 0);
26
- //# sourceMappingURL=StylableElement.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"StylableElement.js","sourceRoot":"","sources":["../src/StylableElement.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE5C,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,UAAU;IAAvD;;QAEI,MAAC,GAA4B,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAA;IAS7C,CAAC;IAPU,iBAAiB;QACxB,KAAK,CAAC,iBAAiB,EAAE,CAAA;QACzB,MAAM,MAAM,GAAG,QAAQ,CAAC,gBAAgB,CAAC,+BAA+B,CAAC,CAAA;QACzE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;;YACrB,MAAA,IAAI,CAAC,UAAU,0CAAE,WAAW,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAA;QACrD,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AATG;IADD,QAAQ,EAAE;0CACgC","sourcesContent":["import { LitElement } from 'lit'\nimport { property } from 'lit/decorators.js'\n\nexport default class StylableElement extends LitElement {\n @property()\n t: (key: string) => string = (key) => key\n\n override connectedCallback() {\n super.connectedCallback()\n const styles = document.querySelectorAll('style, link[rel=\"stylesheet\"]')\n styles.forEach(style => {\n this.shadowRoot?.appendChild(style.cloneNode(true))\n })\n }\n}\n"]}
@@ -1,38 +0,0 @@
1
- import StylableElement from '../StylableElement';
2
- import { TemplateResult } from 'lit';
3
- import './resize-input';
4
- import { SimpleSelector } from '../model/SimpleSelector';
5
- import { ComplexSelector } from '../model/ComplexSelector';
6
- import './inline-select';
7
- import './compound-selector';
8
- /**
9
- * A component to display and edit a complex selector
10
- * A complex selector is a main selector, an operator, and a related selector
11
- * @emits change
12
- * @emits rename (when a simple selector in the main compound selector is renamed)
13
- */
14
- export default class ComplexSelectorComponent extends StylableElement {
15
- /**
16
- * The selector to display
17
- */
18
- get value(): ComplexSelector | undefined;
19
- set value(value: ComplexSelector | string | undefined);
20
- private _value;
21
- /**
22
- * A list of all the classes, IDs, tags, custom tags, attributes, custom attributes
23
- * that are available in the document, applicable to the current selection
24
- */
25
- suggestions: SimpleSelector[];
26
- /**
27
- * A list of all the classes, IDs, tags, custom tags, attributes, custom attributes
28
- * that are available to the related selector
29
- */
30
- relations: SimpleSelector[];
31
- static styles: import("lit").CSSResult;
32
- render(): TemplateResult;
33
- private changeOperator;
34
- private addOperator;
35
- private changeRelatedSelector;
36
- toString(): string;
37
- }
38
- //# sourceMappingURL=complex-selector.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"complex-selector.d.ts","sourceRoot":"","sources":["../../src/components/complex-selector.ts"],"names":[],"mappings":"AACA,OAAO,eAAe,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAa,cAAc,EAAE,MAAM,KAAK,CAAA;AAC/C,OAAO,gBAAgB,CAAA;AACvB,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,EAAE,eAAe,EAAY,MAAM,0BAA0B,CAAA;AAMpE,OAAO,iBAAiB,CAAA;AACxB,OAAO,qBAAqB,CAAA;AAE5B;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,wBAAyB,SAAQ,eAAe;IAGnE;;OAEG;IACH,IACW,KAAK,IAAI,eAAe,GAAG,SAAS,CAE9C;IACD,IAAW,KAAK,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,GAAG,SAAS,EAO3D;IACD,OAAO,CAAC,MAAM,CAA6B;IAE3C;;;OAGG;IAEI,WAAW,EAAE,cAAc,EAAE,CAAK;IAGzC;;;OAGG;IAEI,SAAS,EAAE,cAAc,EAAE,CAAK;IAQvC,OAAgB,MAAM,0BAiBrB;IAOQ,MAAM,IAAI,cAAc;IA6CjC,OAAO,CAAC,cAAc;IAkBtB,OAAO,CAAC,WAAW;IAYnB,OAAO,CAAC,qBAAqB;IAUpB,QAAQ,IAAI,MAAM;CAG5B"}
@@ -1,177 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import { property } from 'lit/decorators.js';
8
- import StylableElement from '../StylableElement';
9
- import { css, html } from 'lit';
10
- import './resize-input';
11
- import { toString } from '../model/ComplexSelector';
12
- import { OPERATORS } from '../model/Operator';
13
- import { FOCUS_VISIBLE } from '../styles';
14
- /**
15
- * A component to display and edit a complex selector
16
- * A complex selector is a main selector, an operator, and a related selector
17
- * @emits change
18
- * @emits rename (when a simple selector in the main compound selector is renamed)
19
- */
20
- class ComplexSelectorComponent extends StylableElement {
21
- constructor() {
22
- super(...arguments);
23
- /**
24
- * A list of all the classes, IDs, tags, custom tags, attributes, custom attributes
25
- * that are available in the document, applicable to the current selection
26
- */
27
- this.suggestions = [];
28
- /**
29
- * A list of all the classes, IDs, tags, custom tags, attributes, custom attributes
30
- * that are available to the related selector
31
- */
32
- this.relations = [];
33
- }
34
- // /////////////////
35
- // Attributes
36
- /**
37
- * The selector to display
38
- */
39
- get value() {
40
- return this._value;
41
- }
42
- set value(value) {
43
- try {
44
- this._value = typeof value === 'string' ? JSON.parse(value) : value;
45
- }
46
- catch (error) {
47
- console.error('Error parsing value for selector', { value, error });
48
- }
49
- this.requestUpdate();
50
- }
51
- dispatchEvent(event) {
52
- console.info('[COMPLEX] Dispatching event', event);
53
- return super.dispatchEvent(event);
54
- }
55
- render() {
56
- var _a, _b, _c, _d, _e, _f;
57
- return html `
58
- <compound-selector
59
- .t=${this.t}
60
- .value=${(_a = this.value) === null || _a === void 0 ? void 0 : _a.mainSelector}
61
- .suggestions=${this.suggestions}
62
- @change=${(event) => {
63
- const target = event.target;
64
- this.value = {
65
- ...this.value,
66
- mainSelector: target.value,
67
- };
68
- event.stopPropagation();
69
- this.dispatchEvent(new CustomEvent('change', { detail: this.value }));
70
- }}
71
- @rename=${(event) => this.dispatchEvent(new CustomEvent('rename', { detail: event.detail }))}
72
- ></compound-selector>
73
- ${((_b = this.value) === null || _b === void 0 ? void 0 : _b.operator) ? html `
74
- <inline-select
75
- .t=${this.t}
76
- .value=${(_c = this.value) === null || _c === void 0 ? void 0 : _c.operator}
77
- .options=${OPERATORS}
78
- placeholder=""
79
- @change=${this.changeOperator}
80
- ></inline-select>
81
- ` : html `
82
- <button
83
- class="gjs-btn-prim asm__add-inline"
84
- @click=${this.addOperator}
85
- >\u2192 ${this.t('Relation')}</button>
86
- `}
87
- ${((_d = this.value) === null || _d === void 0 ? void 0 : _d.operator) ? html `
88
- <compound-selector
89
- .t=${this.t}
90
- .value=${(_e = this.value) === null || _e === void 0 ? void 0 : _e.relatedSelector}
91
- .suggestions=${this.relations}
92
- ?disable-pseudo-class=${((_f = this.value) === null || _f === void 0 ? void 0 : _f.operator.isCombinator) === false}
93
- @change=${this.changeRelatedSelector}
94
- ></compound-selector>
95
- ` : ''}
96
- `;
97
- }
98
- // /////////////////
99
- // Methods
100
- changeOperator(event) {
101
- var _a, _b, _c, _d, _e;
102
- const target = event.target;
103
- if (((_a = target.value) === null || _a === void 0 ? void 0 : _a.isCombinator) === false) {
104
- // Make sure we don't have a pseudo class as a param of a pseudo class
105
- (_c = (_b = this.value) === null || _b === void 0 ? void 0 : _b.relatedSelector) === null || _c === void 0 ? true : delete _c.pseudoClass;
106
- }
107
- this.value = {
108
- ...this.value,
109
- operator: target.value,
110
- };
111
- if (!target.value) {
112
- (_d = this.value) === null || _d === void 0 ? true : delete _d.relatedSelector;
113
- (_e = this.value) === null || _e === void 0 ? true : delete _e.operator;
114
- }
115
- event.stopPropagation();
116
- this.dispatchEvent(new CustomEvent('change', { detail: this.value }));
117
- }
118
- addOperator() {
119
- this.requestUpdate();
120
- this.value = {
121
- ...this.value,
122
- operator: OPERATORS[0],
123
- relatedSelector: {
124
- selectors: [],
125
- },
126
- };
127
- this.dispatchEvent(new CustomEvent('change', { detail: this.value }));
128
- }
129
- changeRelatedSelector(event) {
130
- const target = event.target;
131
- this.value = {
132
- ...this.value,
133
- relatedSelector: target.value,
134
- };
135
- event.stopPropagation();
136
- this.dispatchEvent(new CustomEvent('change', { detail: this.value }));
137
- }
138
- toString() {
139
- return toString(this.value);
140
- }
141
- }
142
- // /////////////////
143
- // Properties
144
- // /////////////////
145
- // Element overrides
146
- ComplexSelectorComponent.styles = css `
147
- :host {
148
- ${FOCUS_VISIBLE}
149
- & {
150
- display: block;
151
- text-align: left;
152
- padding: 0.5rem 0;
153
- }
154
- button:hover, a:hover {
155
- transform: translateX(1px);
156
- font-weight: bold;
157
- }
158
- button.asm__add-inline {
159
- font-size: 0.8rem;
160
- background: transparent;
161
- }
162
- }
163
- `;
164
- export default ComplexSelectorComponent;
165
- __decorate([
166
- property({ type: Object, attribute: true, reflect: false })
167
- ], ComplexSelectorComponent.prototype, "value", null);
168
- __decorate([
169
- property({ type: Array, attribute: true, reflect: false })
170
- ], ComplexSelectorComponent.prototype, "suggestions", void 0);
171
- __decorate([
172
- property({ type: Array, attribute: true, reflect: false })
173
- ], ComplexSelectorComponent.prototype, "relations", void 0);
174
- if (!customElements.get('complex-selector')) {
175
- customElements.define('complex-selector', ComplexSelectorComponent);
176
- }
177
- //# sourceMappingURL=complex-selector.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"complex-selector.js","sourceRoot":"","sources":["../../src/components/complex-selector.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,QAAQ,EAA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,WAAW,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;IACvE,CAAC;IAEQ,QAAQ;QACf,OAAO,QAAQ,CAAC,IAAI,CAAC,KAAM,CAAC,CAAA;IAC9B,CAAC;;AApHD,oBAAoB;AACpB,aAAa;AAEb,oBAAoB;AACpB,oBAAoB;AACJ,+BAAM,GAAG,GAAG,CAAA;;MAEvB,aAAc;;;;;;;;;;;;;;;GAelB,AAjBqB,CAiBrB;eA1DkB,wBAAwB;AAO3C;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;qDAG3D;AAgBM;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;6DAClB;AAQlC;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;2DACpB;AA0HzC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,kBAAkB,CAAC,EAAE,CAAC;IAC5C,cAAc,CAAC,MAAM,CAAC,kBAAkB,EAAE,wBAAwB,CAAC,CAAA;AACrE,CAAC","sourcesContent":["import { property } from 'lit/decorators.js'\nimport StylableElement from '../StylableElement'\nimport { css, html, TemplateResult } from 'lit'\nimport './resize-input'\nimport { SimpleSelector } from '../model/SimpleSelector'\nimport { ComplexSelector, toString } from '../model/ComplexSelector'\nimport { Operator, OPERATORS } from '../model/Operator'\nimport InlineSelectComponent from './inline-select'\nimport CompoundSelectorComponent from './compound-selector'\nimport { CompoundSelector } from '../model/CompoundSelector'\nimport { FOCUS_VISIBLE } from '../styles'\n\n/**\n * A component to display and edit a complex selector\n * A complex selector is a main selector, an operator, and a related selector\n * @emits change\n * @emits rename (when a simple selector in the main compound selector is renamed)\n */\nexport default class ComplexSelectorComponent extends StylableElement {\n // /////////////////\n // Attributes\n /**\n * The selector to display\n */\n @property({ type: Object, attribute: true, reflect: false })\n public get value(): ComplexSelector | undefined {\n return this._value\n }\n public set value(value: ComplexSelector | string | undefined) {\n try {\n this._value = typeof value === 'string' ? JSON.parse(value) : value\n } catch (error) {\n console.error('Error parsing value for selector', { value, error })\n }\n this.requestUpdate()\n }\n private _value: ComplexSelector | undefined\n\n /**\n * A list of all the classes, IDs, tags, custom tags, attributes, custom attributes\n * that are available in the document, applicable to the current selection\n */\n @property({ type: Array, attribute: true, reflect: false })\n public suggestions: SimpleSelector[] = []\n\n\n /**\n * A list of all the classes, IDs, tags, custom tags, attributes, custom attributes\n * that are available to the related selector\n */\n @property({ type: Array, attribute: true, reflect: false })\n public relations: SimpleSelector[] = []\n\n\n // /////////////////\n // Properties\n\n // /////////////////\n // Element overrides\n static override styles = css`\n :host {\n ${ FOCUS_VISIBLE }\n & {\n display: block;\n text-align: left;\n padding: 0.5rem 0;\n }\n button:hover, a:hover {\n transform: translateX(1px);\n font-weight: bold;\n }\n button.asm__add-inline {\n font-size: 0.8rem;\n background: transparent;\n }\n }\n `\n\n override dispatchEvent(event: Event): boolean {\n console.info('[COMPLEX] Dispatching event', event)\n return super.dispatchEvent(event)\n }\n\n override render(): TemplateResult {\n return html`\n <compound-selector\n .t=${ this.t }\n .value=${ this.value?.mainSelector }\n .suggestions=${ this.suggestions }\n @change=${ (event: CustomEvent) => {\n const target = event.target as CompoundSelectorComponent\n this.value = {\n ...this.value!,\n mainSelector: target.value as CompoundSelector,\n }\n event.stopPropagation()\n this.dispatchEvent(new CustomEvent('change', { detail: this.value }))\n }}\n @rename=${ (event: CustomEvent) => this.dispatchEvent(new CustomEvent('rename', { detail: event.detail })) }\n ></compound-selector>\n ${ this.value?.operator ? html`\n <inline-select\n .t=${ this.t }\n .value=${ this.value?.operator }\n .options=${ OPERATORS }\n placeholder=\"\"\n @change=${ this.changeOperator }\n ></inline-select>\n ` : html`\n <button\n class=\"gjs-btn-prim asm__add-inline\"\n @click=${ this.addOperator }\n >\\u2192 ${ this.t('Relation') }</button>\n `}\n ${ this.value?.operator ? html`\n <compound-selector\n .t=${ this.t }\n .value=${ this.value?.relatedSelector }\n .suggestions=${ this.relations }\n ?disable-pseudo-class=${ this.value?.operator.isCombinator === false }\n @change=${ this.changeRelatedSelector }\n ></compound-selector>\n ` : ''}\n `\n }\n\n // /////////////////\n // Methods\n private changeOperator(event: CustomEvent<Operator>) {\n const target = event.target as InlineSelectComponent\n if ((target.value as Operator)?.isCombinator === false) {\n // Make sure we don't have a pseudo class as a param of a pseudo class\n delete this.value?.relatedSelector?.pseudoClass\n }\n this.value = {\n ...this.value!,\n operator: target.value as Operator,\n }\n if (!target.value) {\n delete this.value?.relatedSelector\n delete this.value?.operator\n }\n event.stopPropagation()\n this.dispatchEvent(new CustomEvent('change', { detail: this.value }))\n }\n\n private addOperator() {\n this.requestUpdate()\n this.value = {\n ...this.value!,\n operator: OPERATORS[0],\n relatedSelector: {\n selectors: [],\n },\n } as ComplexSelector\n this.dispatchEvent(new CustomEvent('change', { detail: this.value }))\n }\n\n private changeRelatedSelector(event: CustomEvent<CompoundSelector>) {\n const target = event.target as CompoundSelectorComponent\n this.value = {\n ...this.value!,\n relatedSelector: target.value as CompoundSelector,\n }\n event.stopPropagation()\n this.dispatchEvent(new CustomEvent('change', { detail: this.value }))\n }\n\n override toString(): string {\n return toString(this.value!)\n }\n}\n\nif (!customElements.get('complex-selector')) {\n customElements.define('complex-selector', ComplexSelectorComponent)\n}\n"]}
@@ -1,38 +0,0 @@
1
- import StylableElement from '../StylableElement';
2
- import { CompoundSelector } from '../model/CompoundSelector';
3
- import { SimpleSelector } from '../model/SimpleSelector';
4
- import { TemplateResult } from 'lit';
5
- import './inline-select';
6
- import './simple-selector';
7
- /**
8
- * A component to display and edit a compound selector
9
- * A compound selector is a list of simple selectors and a pseudo class
10
- * @emits change
11
- * @emits rename (when a simple selector in the selector is renamed)
12
- * @emits delete
13
- * @emits add
14
- */
15
- export default class CompoundSelectorComponent extends StylableElement {
16
- /**
17
- * The selector to display
18
- */
19
- get value(): CompoundSelector | undefined;
20
- set value(value: CompoundSelector | string | undefined);
21
- private _value;
22
- /**
23
- * A list of all the classes, IDs, tags, custom tags, attributes, custom attributes
24
- * that are available in the document, applicable to the current selection
25
- */
26
- suggestions: SimpleSelector[];
27
- disablePseudoClass: boolean;
28
- static styles: import("lit").CSSResult;
29
- toString(): string;
30
- render(): TemplateResult;
31
- private changeSelector;
32
- private addSelector;
33
- private focusLastSelector;
34
- private deleteSelector;
35
- private addPseudoClass;
36
- private changePseudoClass;
37
- }
38
- //# sourceMappingURL=compound-selector.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"compound-selector.d.ts","sourceRoot":"","sources":["../../src/components/compound-selector.ts"],"names":[],"mappings":"AACA,OAAO,eAAe,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,gBAAgB,EAAY,MAAM,2BAA2B,CAAA;AACtE,OAAO,EAAkB,cAAc,EAAmC,MAAM,yBAAyB,CAAA;AACzG,OAAO,EAAa,cAAc,EAAE,MAAM,KAAK,CAAA;AAI/C,OAAO,iBAAiB,CAAA;AACxB,OAAO,mBAAmB,CAAA;AAE1B;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,OAAO,yBAA0B,SAAQ,eAAe;IAIpE;;OAEG;IACH,IACW,KAAK,IAAI,gBAAgB,GAAG,SAAS,CAE/C;IACD,IAAW,KAAK,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,GAAG,SAAS,EAO5D;IACD,OAAO,CAAC,MAAM,CAA8B;IAE5C;;;OAGG;IAEI,WAAW,EAAE,cAAc,EAAE,CAAK;IAGlC,kBAAkB,EAAE,OAAO,CAAQ;IAO1C,OAAgB,MAAM,0BAwBrB;IAOQ,QAAQ,IAAI,MAAM;IAGlB,MAAM,IAAI,cAAc;IAmDjC,OAAO,CAAC,cAAc;IAoBtB,OAAO,CAAC,WAAW;IAQnB,OAAO,CAAC,iBAAiB;IAUzB,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,iBAAiB;CAK1B"}
@@ -1,205 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import { property } from 'lit/decorators.js';
8
- import StylableElement from '../StylableElement';
9
- import { toString } from '../model/CompoundSelector';
10
- import { isSameSelector, SimpleSelectorType, specificity } from '../model/SimpleSelector';
11
- import { css, html } from 'lit';
12
- import { PSEUDO_CLASSES } from '../model/PseudoClass';
13
- import { FOCUS_VISIBLE } from '../styles';
14
- import './inline-select';
15
- /**
16
- * A component to display and edit a compound selector
17
- * A compound selector is a list of simple selectors and a pseudo class
18
- * @emits change
19
- * @emits rename (when a simple selector in the selector is renamed)
20
- * @emits delete
21
- * @emits add
22
- */
23
- class CompoundSelectorComponent extends StylableElement {
24
- constructor() {
25
- super(...arguments);
26
- /**
27
- * A list of all the classes, IDs, tags, custom tags, attributes, custom attributes
28
- * that are available in the document, applicable to the current selection
29
- */
30
- this.suggestions = [];
31
- this.disablePseudoClass = false;
32
- }
33
- // /////////////////
34
- // Attributes
35
- /**
36
- * The selector to display
37
- */
38
- get value() {
39
- return this._value;
40
- }
41
- set value(value) {
42
- try {
43
- this._value = typeof value === 'string' ? JSON.parse(value) : value;
44
- }
45
- catch (error) {
46
- console.error('Error parsing value for selector', { value, error });
47
- }
48
- this.requestUpdate();
49
- }
50
- dispatchEvent(event) {
51
- console.info('[COMPOUND] Dispatching event', event);
52
- return super.dispatchEvent(event);
53
- }
54
- toString() {
55
- return toString(this.value);
56
- }
57
- render() {
58
- var _a, _b, _c;
59
- return html `
60
- <section>
61
- <div
62
- class="asm-compound__selectors"
63
- >
64
- ${(_a = this.value) === null || _a === void 0 ? void 0 : _a.selectors.sort((a, b) => specificity(b, true) - specificity(a, true)).map((selector, idx) => html `
65
- <simple-selector
66
- .t=${this.t}
67
- .value=${selector}
68
- .suggestions=${this.suggestions}
69
- ?readonly=${![SimpleSelectorType.CLASS, SimpleSelectorType.UNKNOWN].includes(selector.type)}
70
- @change=${(event) => this.changeSelector(event, idx)}
71
- @delete=${(event) => this.deleteSelector(event, idx)}
72
- ></simple-selector>
73
- `)}
74
- <button
75
- id="gjs-clm-add-tag"
76
- class="gjs-clm-tags-btn gjs-clm-tags-btn__add asm-compound__add"
77
- .title=${this.t('Add a new selector')}
78
- @click=${this.addSelector}
79
- >
80
- <svg viewBox="0 0 24 24"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path></svg>
81
- </button>
82
- </div>
83
- ${this.disablePseudoClass ? '' : html `
84
- ${((_b = this.value) === null || _b === void 0 ? void 0 : _b.pseudoClass) ? html `
85
- <div>
86
- <inline-select
87
- .t=${this.t}
88
- .value=${(_c = this.value) === null || _c === void 0 ? void 0 : _c.pseudoClass}
89
- .options=${PSEUDO_CLASSES}
90
- @change=${this.changePseudoClass}
91
- placeholder=""
92
- ></inline-select>
93
- </div>
94
- ` : html `
95
- <button
96
- class="gjs-btn-prim asm__add-inline"
97
- @click=${this.addPseudoClass}
98
- >\u2192 ${this.t('Pseudo Class')}</button>
99
- `}
100
- `}
101
- </section>
102
- `;
103
- }
104
- // /////////////////
105
- // Methods
106
- changeSelector(event, idx) {
107
- const oldValue = this.value.selectors[idx];
108
- const onlyId = event.detail.type === SimpleSelectorType.ID && event.detail.active;
109
- this.value = {
110
- ...this.value,
111
- selectors: this.value.selectors
112
- // Replace the old value with the new one
113
- .map((selector, i) => i === idx ? event.detail : selector)
114
- .map(selector => onlyId && selector.type !== SimpleSelectorType.ID ? { ...selector, active: false } : selector),
115
- };
116
- if (!isSameSelector(oldValue, event.detail, false)) {
117
- this.dispatchEvent(new CustomEvent('rename', { detail: {
118
- oldValue,
119
- value: event.detail,
120
- } }));
121
- this.dispatchEvent(new CustomEvent('change', { detail: this.value }));
122
- }
123
- event.stopPropagation();
124
- this.requestUpdate();
125
- }
126
- addSelector(event) {
127
- var _a;
128
- this.value = (_a = this.value) !== null && _a !== void 0 ? _a : { selectors: [] };
129
- this.value.selectors.push({ type: SimpleSelectorType.UNKNOWN, active: true });
130
- event.stopPropagation();
131
- this.requestUpdate();
132
- // Make the last selector editable
133
- requestAnimationFrame(() => this.focusLastSelector());
134
- }
135
- focusLastSelector() {
136
- if (!this.value) {
137
- return;
138
- }
139
- const selector = this.shadowRoot.querySelectorAll('simple-selector')[this.value.selectors.length - 1];
140
- selector.editing = true;
141
- requestAnimationFrame(() => {
142
- selector.focus();
143
- });
144
- }
145
- deleteSelector(event, idx) {
146
- var _a;
147
- (_a = this.value) === null || _a === void 0 ? void 0 : _a.selectors.splice(idx, 1);
148
- this.dispatchEvent(new CustomEvent('change', { detail: this.value }));
149
- event.stopPropagation();
150
- this.requestUpdate();
151
- }
152
- addPseudoClass(event) {
153
- this.value = { ...this.value, pseudoClass: PSEUDO_CLASSES[0] };
154
- this.dispatchEvent(new CustomEvent('change', { detail: this.value }));
155
- event.stopPropagation();
156
- }
157
- changePseudoClass(event) {
158
- this.value = { ...this.value, pseudoClass: event.detail };
159
- this.dispatchEvent(new CustomEvent('change', { detail: this.value }));
160
- event.stopPropagation();
161
- }
162
- }
163
- // /////////////////
164
- // Properties
165
- // /////////////////
166
- // Element overrides
167
- CompoundSelectorComponent.styles = css `
168
- :host {
169
- ${FOCUS_VISIBLE}
170
- button:hover, a:hover {
171
- transform: translateX(1px);
172
- font-weight: bold;
173
- }
174
- .asm-compound__selectors {
175
- display: flex;
176
- gap: 0.5rem;
177
- align-items: center;
178
- flex-wrap: wrap;
179
- /* material design card style */
180
- padding: 0.5rem;
181
- background-color: var(--gjs-main-dark-color);
182
- }
183
- .asm-compound__add {
184
- color: var(--gjs-secondary-color, #b9a5a6);
185
- }
186
- .asm__add-inline {
187
- font-size: 0.8rem;
188
- background: transparent;
189
- }
190
- }
191
- `;
192
- export default CompoundSelectorComponent;
193
- __decorate([
194
- property({ type: Object, attribute: true, reflect: false })
195
- ], CompoundSelectorComponent.prototype, "value", null);
196
- __decorate([
197
- property({ type: Array, attribute: true, reflect: false })
198
- ], CompoundSelectorComponent.prototype, "suggestions", void 0);
199
- __decorate([
200
- property({ type: Boolean, attribute: 'disable-pseudo-class' })
201
- ], CompoundSelectorComponent.prototype, "disablePseudoClass", void 0);
202
- if (!customElements.get('compound-selector')) {
203
- customElements.define('compound-selector', CompoundSelectorComponent);
204
- }
205
- //# sourceMappingURL=compound-selector.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"compound-selector.js","sourceRoot":"","sources":["../../src/components/compound-selector.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,eAAe,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAoB,QAAQ,EAAE,MAAM,2BAA2B,CAAA;AACtE,OAAO,EAAE,cAAc,EAAkB,kBAAkB,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACzG,OAAO,EAAE,GAAG,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAA;AAE/C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,iBAAiB,CAAA;AAExB;;;;;;;GAOG;AACH,MAAqB,yBAA0B,SAAQ,eAAe;IAAtE;;QAqBE;;;WAGG;QAEI,gBAAW,GAAqB,EAAE,CAAA;QAGlC,uBAAkB,GAAY,KAAK,CAAA;IA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AACpB,oBAAoB;AACJ,gCAAM,GAAG,GAAG,CAAA;;MAEvB,aAAc;;;;;;;;;;;;;;;;;;;;;;GAsBlB,AAxBqB,CAwBrB;eA5DkB,yBAAyB;AAQ5C;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;sDAG3D;AAgBM;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;8DAClB;AAGlC;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAE,CAAC;qEACrB;AAoJ5C,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,mBAAmB,CAAC,EAAE,CAAC;IAC7C,cAAc,CAAC,MAAM,CAAC,mBAAmB,EAAE,yBAAyB,CAAC,CAAA;AACvE,CAAC","sourcesContent":["import { property } from 'lit/decorators.js'\nimport StylableElement from '../StylableElement'\nimport { CompoundSelector, toString } from '../model/CompoundSelector'\nimport { isSameSelector, SimpleSelector, SimpleSelectorType, specificity } from '../model/SimpleSelector'\nimport { css, html, TemplateResult } from 'lit'\nimport SimpleSelectorComponent from './simple-selector'\nimport { PSEUDO_CLASSES } from '../model/PseudoClass'\nimport { FOCUS_VISIBLE } from '../styles'\nimport './inline-select'\n\n/**\n * A component to display and edit a compound selector\n * A compound selector is a list of simple selectors and a pseudo class\n * @emits change\n * @emits rename (when a simple selector in the selector is renamed)\n * @emits delete\n * @emits add\n */\nexport default class CompoundSelectorComponent extends StylableElement {\n\n // /////////////////\n // Attributes\n /**\n * The selector to display\n */\n @property({ type: Object, attribute: true, reflect: false })\n public get value(): CompoundSelector | undefined {\n return this._value\n }\n public set value(value: CompoundSelector | string | undefined) {\n try {\n this._value = typeof value === 'string' ? JSON.parse(value) : value\n } catch (error) {\n console.error('Error parsing value for selector', { value, error })\n }\n this.requestUpdate()\n }\n private _value: CompoundSelector | undefined\n\n /**\n * A list of all the classes, IDs, tags, custom tags, attributes, custom attributes\n * that are available in the document, applicable to the current selection\n */\n @property({ type: Array, attribute: true, reflect: false })\n public suggestions: SimpleSelector[] = []\n\n @property({ type: Boolean, attribute: 'disable-pseudo-class' })\n public disablePseudoClass: boolean = false\n\n // /////////////////\n // Properties\n\n // /////////////////\n // Element overrides\n static override styles = css`\n :host {\n ${ FOCUS_VISIBLE }\n button:hover, a:hover {\n transform: translateX(1px);\n font-weight: bold;\n }\n .asm-compound__selectors {\n display: flex;\n gap: 0.5rem;\n align-items: center;\n flex-wrap: wrap;\n /* material design card style */\n padding: 0.5rem;\n background-color: var(--gjs-main-dark-color);\n }\n .asm-compound__add {\n color: var(--gjs-secondary-color, #b9a5a6);\n }\n .asm__add-inline {\n font-size: 0.8rem;\n background: transparent;\n }\n }\n `\n\n override dispatchEvent(event: Event): boolean {\n console.info('[COMPOUND] Dispatching event', event)\n return super.dispatchEvent(event)\n }\n\n override toString(): string {\n return toString(this.value!)\n }\n override render(): TemplateResult {\n return html`\n <section>\n <div\n class=\"asm-compound__selectors\"\n >\n ${ this.value?.selectors\n .sort((a, b) => specificity(b, true) - specificity(a, true))\n .map((selector, idx) => html`\n <simple-selector\n .t=${ this.t }\n .value=${ selector }\n .suggestions=${ this.suggestions }\n ?readonly=${ ![SimpleSelectorType.CLASS, SimpleSelectorType.UNKNOWN].includes(selector.type) }\n @change=${ (event: CustomEvent<SimpleSelector>) => this.changeSelector(event, idx) }\n @delete=${ (event: CustomEvent) => this.deleteSelector(event, idx) }\n ></simple-selector>\n `) }\n <button\n id=\"gjs-clm-add-tag\"\n class=\"gjs-clm-tags-btn gjs-clm-tags-btn__add asm-compound__add\"\n .title=${ this.t('Add a new selector') }\n @click=${ this.addSelector }\n >\n <svg viewBox=\"0 0 24 24\"><path d=\"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z\"></path></svg>\n </button>\n </div>\n ${ this.disablePseudoClass ? '' : html`\n ${ this.value?.pseudoClass ? html`\n <div>\n <inline-select\n .t=${ this.t }\n .value=${ this.value?.pseudoClass }\n .options=${ PSEUDO_CLASSES }\n @change=${ this.changePseudoClass }\n placeholder=\"\"\n ></inline-select>\n </div>\n ` : html`\n <button\n class=\"gjs-btn-prim asm__add-inline\"\n @click=${ this.addPseudoClass }\n >\\u2192 ${ this.t('Pseudo Class') }</button>\n ` }\n `}\n </section>\n `\n }\n\n // /////////////////\n // Methods\n private changeSelector(event: CustomEvent<SimpleSelector>, idx: number) {\n const oldValue: SimpleSelector = this.value!.selectors[idx]\n const onlyId = event.detail.type === SimpleSelectorType.ID && event.detail.active\n this.value = {\n ...this.value!,\n selectors: this.value!.selectors\n // Replace the old value with the new one\n .map((selector, i) => i === idx ? event.detail : selector)\n .map(selector => onlyId && selector.type !== SimpleSelectorType.ID ? { ...selector, active: false } : selector),\n }\n if(!isSameSelector(oldValue, event.detail, false)) {\n this.dispatchEvent(new CustomEvent('rename', { detail: {\n oldValue,\n value: event.detail,\n } }))\n this.dispatchEvent(new CustomEvent('change', { detail: this.value }))\n }\n event.stopPropagation()\n this.requestUpdate()\n }\n private addSelector(event: MouseEvent) {\n this.value = this.value ?? { selectors: [] }\n this.value.selectors.push({ type: SimpleSelectorType.UNKNOWN, active: true })\n event.stopPropagation()\n this.requestUpdate()\n // Make the last selector editable\n requestAnimationFrame(() => this.focusLastSelector())\n }\n private focusLastSelector() {\n if (!this.value) {\n return\n }\n const selector = this.shadowRoot!.querySelectorAll('simple-selector')[this.value!.selectors.length - 1] as SimpleSelectorComponent\n selector.editing = true\n requestAnimationFrame(() => {\n selector.focus()\n })\n }\n private deleteSelector(event: CustomEvent, idx: number) {\n this.value?.selectors.splice(idx, 1)\n this.dispatchEvent(new CustomEvent('change', { detail: this.value }))\n event.stopPropagation()\n this.requestUpdate()\n }\n private addPseudoClass(event: MouseEvent) {\n this.value = { ...this.value!, pseudoClass: PSEUDO_CLASSES[0] }\n this.dispatchEvent(new CustomEvent('change', { detail: this.value }))\n event.stopPropagation()\n }\n private changePseudoClass(event: CustomEvent) {\n this.value = { ...this.value!, pseudoClass: event.detail }\n this.dispatchEvent(new CustomEvent('change', { detail: this.value }))\n event.stopPropagation()\n }\n}\n\nif (!customElements.get('compound-selector')) {\n customElements.define('compound-selector', CompoundSelectorComponent)\n}\n"]}
@@ -1,23 +0,0 @@
1
- import { TemplateResult } from 'lit';
2
- import StylableElement from '../StylableElement';
3
- import { ComplexSelector } from '../model/ComplexSelector';
4
- export declare class CurrentSelectorDisplay extends StylableElement {
5
- /**
6
- * The selector to display
7
- */
8
- get value(): ComplexSelector | undefined;
9
- set value(value: ComplexSelector | string | undefined);
10
- private _value;
11
- placeholder: string;
12
- selectors: ComplexSelector[];
13
- helpLink: string;
14
- error: string;
15
- warning: string;
16
- specificity: number;
17
- private selectRef;
18
- static styles: import("lit").CSSResult;
19
- render(): TemplateResult;
20
- private changeSelector;
21
- private clearStyle;
22
- }
23
- //# sourceMappingURL=current-selector-display.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"current-selector-display.d.ts","sourceRoot":"","sources":["../../src/components/current-selector-display.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,cAAc,EAAE,MAAM,KAAK,CAAA;AAC/C,OAAO,eAAe,MAAM,oBAAoB,CAAA;AAEhD,OAAO,EAAE,eAAe,EAA2C,MAAM,0BAA0B,CAAA;AAInG,qBAAa,sBAAuB,SAAQ,eAAe;IACzD;;OAEG;IACH,IACW,KAAK,IAAI,eAAe,GAAG,SAAS,CAE9C;IACD,IAAW,KAAK,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,GAAG,SAAS,EAO3D;IACD,OAAO,CAAC,MAAM,CAA6B;IAGpC,WAAW,SAAqB;IAGhC,SAAS,EAAE,eAAe,EAAE,CAAK;IAGjC,QAAQ,SAAK;IAGb,KAAK,SAAK;IAGV,OAAO,SAAK;IAGZ,WAAW,SAAI;IACtB,OAAO,CAAC,SAAS,CAAiC;IAElD,OAAgB,MAAM,0BA0FrB;IAEQ,MAAM,IAAI,cAAc;IA2GjC,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,UAAU;CAGnB"}