@teipublisher/pb-components 3.4.1 → 3.6.0
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/CHANGELOG.md +14 -0
- package/dist/demo/pb-highlight.html +2 -0
- package/dist/pb-components-bundle.js +32 -24
- package/dist/pb-elements.json +31 -5
- package/package.json +1 -1
- package/pb-elements.json +31 -5
- package/src/pb-highlight.js +65 -16
package/dist/pb-elements.json
CHANGED
|
@@ -4723,7 +4723,7 @@
|
|
|
4723
4723
|
},
|
|
4724
4724
|
{
|
|
4725
4725
|
"name": "key",
|
|
4726
|
-
"description": "
|
|
4726
|
+
"description": "One or more keys (space or comma separated) to which this element is connected.",
|
|
4727
4727
|
"type": "string"
|
|
4728
4728
|
},
|
|
4729
4729
|
{
|
|
@@ -4743,6 +4743,12 @@
|
|
|
4743
4743
|
"type": "boolean",
|
|
4744
4744
|
"default": "false"
|
|
4745
4745
|
},
|
|
4746
|
+
{
|
|
4747
|
+
"name": "trigger",
|
|
4748
|
+
"description": "Defines one or more actions (space separated) which should cause\nthe highlight to show. Default is `mouseenter`. If `click` is among the triggers, matching elements scroll into view.",
|
|
4749
|
+
"type": "\"click\" | \"mouseenter\"",
|
|
4750
|
+
"default": "\"mouseenter\""
|
|
4751
|
+
},
|
|
4746
4752
|
{
|
|
4747
4753
|
"name": "subscribe",
|
|
4748
4754
|
"description": "The name of the channel to subscribe to. Only events on a channel corresponding\nto this property are listened to.",
|
|
@@ -4819,7 +4825,7 @@
|
|
|
4819
4825
|
{
|
|
4820
4826
|
"name": "key",
|
|
4821
4827
|
"attribute": "key",
|
|
4822
|
-
"description": "
|
|
4828
|
+
"description": "One or more keys (space or comma separated) to which this element is connected.",
|
|
4823
4829
|
"type": "string"
|
|
4824
4830
|
},
|
|
4825
4831
|
{
|
|
@@ -4842,6 +4848,13 @@
|
|
|
4842
4848
|
"type": "boolean",
|
|
4843
4849
|
"default": "false"
|
|
4844
4850
|
},
|
|
4851
|
+
{
|
|
4852
|
+
"name": "trigger",
|
|
4853
|
+
"attribute": "trigger",
|
|
4854
|
+
"description": "Defines one or more actions (space separated) which should cause\nthe highlight to show. Default is `mouseenter`. If `click` is among the triggers, matching elements scroll into view.",
|
|
4855
|
+
"type": "\"click\" | \"mouseenter\"",
|
|
4856
|
+
"default": "\"mouseenter\""
|
|
4857
|
+
},
|
|
4845
4858
|
{
|
|
4846
4859
|
"name": "subscribe",
|
|
4847
4860
|
"attribute": "subscribe",
|
|
@@ -5185,11 +5198,11 @@
|
|
|
5185
5198
|
{
|
|
5186
5199
|
"name": "pb-highlight",
|
|
5187
5200
|
"path": "./src/pb-highlight.js",
|
|
5188
|
-
"description": "Link elements to each other:
|
|
5201
|
+
"description": "Link elements to each other: when a trigger action occurs on one element,\nthe others are highlighted by changing their background color. Which elements\nare linked is determined by the `key` property: elements with the same key\nare linked. Multiple keys (space or comma separated) may be specified; in that\ncase the emitted `pb-highlight-on` event passes an array of ids and receivers\nhighlight when any of their keys matches. The trigger action is configured via the `trigger` property and\nsends a `pb-highlight-on` event. Other elements with the same key react to this event.\n\n`pb-highlight` should be output for relevant elements via ODD processing model.",
|
|
5189
5202
|
"attributes": [
|
|
5190
5203
|
{
|
|
5191
5204
|
"name": "key",
|
|
5192
|
-
"description": "
|
|
5205
|
+
"description": "One or more keys (space or comma separated) to which this element is connected.",
|
|
5193
5206
|
"type": "string"
|
|
5194
5207
|
},
|
|
5195
5208
|
{
|
|
@@ -5209,6 +5222,12 @@
|
|
|
5209
5222
|
"type": "boolean",
|
|
5210
5223
|
"default": "false"
|
|
5211
5224
|
},
|
|
5225
|
+
{
|
|
5226
|
+
"name": "trigger",
|
|
5227
|
+
"description": "Defines one or more actions (space separated) which should cause\nthe highlight to show. Default is `mouseenter`. If `click` is among the triggers, matching elements scroll into view.",
|
|
5228
|
+
"type": "\"click\" | \"mouseenter\"",
|
|
5229
|
+
"default": "\"mouseenter\""
|
|
5230
|
+
},
|
|
5212
5231
|
{
|
|
5213
5232
|
"name": "subscribe",
|
|
5214
5233
|
"description": "The name of the channel to subscribe to. Only events on a channel corresponding\nto this property are listened to.",
|
|
@@ -5245,7 +5264,7 @@
|
|
|
5245
5264
|
{
|
|
5246
5265
|
"name": "key",
|
|
5247
5266
|
"attribute": "key",
|
|
5248
|
-
"description": "
|
|
5267
|
+
"description": "One or more keys (space or comma separated) to which this element is connected.",
|
|
5249
5268
|
"type": "string"
|
|
5250
5269
|
},
|
|
5251
5270
|
{
|
|
@@ -5268,6 +5287,13 @@
|
|
|
5268
5287
|
"type": "boolean",
|
|
5269
5288
|
"default": "false"
|
|
5270
5289
|
},
|
|
5290
|
+
{
|
|
5291
|
+
"name": "trigger",
|
|
5292
|
+
"attribute": "trigger",
|
|
5293
|
+
"description": "Defines one or more actions (space separated) which should cause\nthe highlight to show. Default is `mouseenter`. If `click` is among the triggers, matching elements scroll into view.",
|
|
5294
|
+
"type": "\"click\" | \"mouseenter\"",
|
|
5295
|
+
"default": "\"mouseenter\""
|
|
5296
|
+
},
|
|
5271
5297
|
{
|
|
5272
5298
|
"name": "subscribe",
|
|
5273
5299
|
"attribute": "subscribe",
|
package/package.json
CHANGED
package/pb-elements.json
CHANGED
|
@@ -4723,7 +4723,7 @@
|
|
|
4723
4723
|
},
|
|
4724
4724
|
{
|
|
4725
4725
|
"name": "key",
|
|
4726
|
-
"description": "
|
|
4726
|
+
"description": "One or more keys (space or comma separated) to which this element is connected.",
|
|
4727
4727
|
"type": "string"
|
|
4728
4728
|
},
|
|
4729
4729
|
{
|
|
@@ -4743,6 +4743,12 @@
|
|
|
4743
4743
|
"type": "boolean",
|
|
4744
4744
|
"default": "false"
|
|
4745
4745
|
},
|
|
4746
|
+
{
|
|
4747
|
+
"name": "trigger",
|
|
4748
|
+
"description": "Defines one or more actions (space separated) which should cause\nthe highlight to show. Default is `mouseenter`. If `click` is among the triggers, matching elements scroll into view.",
|
|
4749
|
+
"type": "\"click\" | \"mouseenter\"",
|
|
4750
|
+
"default": "\"mouseenter\""
|
|
4751
|
+
},
|
|
4746
4752
|
{
|
|
4747
4753
|
"name": "subscribe",
|
|
4748
4754
|
"description": "The name of the channel to subscribe to. Only events on a channel corresponding\nto this property are listened to.",
|
|
@@ -4819,7 +4825,7 @@
|
|
|
4819
4825
|
{
|
|
4820
4826
|
"name": "key",
|
|
4821
4827
|
"attribute": "key",
|
|
4822
|
-
"description": "
|
|
4828
|
+
"description": "One or more keys (space or comma separated) to which this element is connected.",
|
|
4823
4829
|
"type": "string"
|
|
4824
4830
|
},
|
|
4825
4831
|
{
|
|
@@ -4842,6 +4848,13 @@
|
|
|
4842
4848
|
"type": "boolean",
|
|
4843
4849
|
"default": "false"
|
|
4844
4850
|
},
|
|
4851
|
+
{
|
|
4852
|
+
"name": "trigger",
|
|
4853
|
+
"attribute": "trigger",
|
|
4854
|
+
"description": "Defines one or more actions (space separated) which should cause\nthe highlight to show. Default is `mouseenter`. If `click` is among the triggers, matching elements scroll into view.",
|
|
4855
|
+
"type": "\"click\" | \"mouseenter\"",
|
|
4856
|
+
"default": "\"mouseenter\""
|
|
4857
|
+
},
|
|
4845
4858
|
{
|
|
4846
4859
|
"name": "subscribe",
|
|
4847
4860
|
"attribute": "subscribe",
|
|
@@ -5185,11 +5198,11 @@
|
|
|
5185
5198
|
{
|
|
5186
5199
|
"name": "pb-highlight",
|
|
5187
5200
|
"path": "./src/pb-highlight.js",
|
|
5188
|
-
"description": "Link elements to each other:
|
|
5201
|
+
"description": "Link elements to each other: when a trigger action occurs on one element,\nthe others are highlighted by changing their background color. Which elements\nare linked is determined by the `key` property: elements with the same key\nare linked. Multiple keys (space or comma separated) may be specified; in that\ncase the emitted `pb-highlight-on` event passes an array of ids and receivers\nhighlight when any of their keys matches. The trigger action is configured via the `trigger` property and\nsends a `pb-highlight-on` event. Other elements with the same key react to this event.\n\n`pb-highlight` should be output for relevant elements via ODD processing model.",
|
|
5189
5202
|
"attributes": [
|
|
5190
5203
|
{
|
|
5191
5204
|
"name": "key",
|
|
5192
|
-
"description": "
|
|
5205
|
+
"description": "One or more keys (space or comma separated) to which this element is connected.",
|
|
5193
5206
|
"type": "string"
|
|
5194
5207
|
},
|
|
5195
5208
|
{
|
|
@@ -5209,6 +5222,12 @@
|
|
|
5209
5222
|
"type": "boolean",
|
|
5210
5223
|
"default": "false"
|
|
5211
5224
|
},
|
|
5225
|
+
{
|
|
5226
|
+
"name": "trigger",
|
|
5227
|
+
"description": "Defines one or more actions (space separated) which should cause\nthe highlight to show. Default is `mouseenter`. If `click` is among the triggers, matching elements scroll into view.",
|
|
5228
|
+
"type": "\"click\" | \"mouseenter\"",
|
|
5229
|
+
"default": "\"mouseenter\""
|
|
5230
|
+
},
|
|
5212
5231
|
{
|
|
5213
5232
|
"name": "subscribe",
|
|
5214
5233
|
"description": "The name of the channel to subscribe to. Only events on a channel corresponding\nto this property are listened to.",
|
|
@@ -5245,7 +5264,7 @@
|
|
|
5245
5264
|
{
|
|
5246
5265
|
"name": "key",
|
|
5247
5266
|
"attribute": "key",
|
|
5248
|
-
"description": "
|
|
5267
|
+
"description": "One or more keys (space or comma separated) to which this element is connected.",
|
|
5249
5268
|
"type": "string"
|
|
5250
5269
|
},
|
|
5251
5270
|
{
|
|
@@ -5268,6 +5287,13 @@
|
|
|
5268
5287
|
"type": "boolean",
|
|
5269
5288
|
"default": "false"
|
|
5270
5289
|
},
|
|
5290
|
+
{
|
|
5291
|
+
"name": "trigger",
|
|
5292
|
+
"attribute": "trigger",
|
|
5293
|
+
"description": "Defines one or more actions (space separated) which should cause\nthe highlight to show. Default is `mouseenter`. If `click` is among the triggers, matching elements scroll into view.",
|
|
5294
|
+
"type": "\"click\" | \"mouseenter\"",
|
|
5295
|
+
"default": "\"mouseenter\""
|
|
5296
|
+
},
|
|
5271
5297
|
{
|
|
5272
5298
|
"name": "subscribe",
|
|
5273
5299
|
"attribute": "subscribe",
|
package/src/pb-highlight.js
CHANGED
|
@@ -2,11 +2,13 @@ import { LitElement, html, css } from 'lit-element';
|
|
|
2
2
|
import { pbMixin } from './pb-mixin';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Link elements to each other:
|
|
5
|
+
* Link elements to each other: when a trigger action occurs on one element,
|
|
6
6
|
* the others are highlighted by changing their background color. Which elements
|
|
7
7
|
* are linked is determined by the `key` property: elements with the same key
|
|
8
|
-
* are linked.
|
|
9
|
-
*
|
|
8
|
+
* are linked. Multiple keys (space or comma separated) may be specified; in that
|
|
9
|
+
* case the emitted `pb-highlight-on` event passes an array of ids and receivers
|
|
10
|
+
* highlight when any of their keys matches. The trigger action is configured via the `trigger` property and
|
|
11
|
+
* sends a `pb-highlight-on` event. Other elements with the same key react to this event.
|
|
10
12
|
*
|
|
11
13
|
* `pb-highlight` should be output for relevant elements via ODD processing model.
|
|
12
14
|
*
|
|
@@ -16,7 +18,9 @@ import { pbMixin } from './pb-mixin';
|
|
|
16
18
|
* @fires pb-highlight-off - Fires removal of all highlights that might have existed before
|
|
17
19
|
* @fires pb-highlight-on - Fires highlight event with a key passed to which other pb-highlight elements with the same key will react
|
|
18
20
|
* @fires pb-highlight-off - When received, triggers removal of a highlight that might have been on for this element before
|
|
19
|
-
* @fires pb-highlight-on - When received, switches the highlight on if
|
|
21
|
+
* @fires pb-highlight-on - When received, switches the highlight on if any received key matches one of this element's keys
|
|
22
|
+
* @prop {"click" | "mouseenter"} trigger - Defines one or more actions (space separated) which should cause
|
|
23
|
+
* the highlight to show. Default is `mouseenter`. If `click` is among the triggers, matching elements scroll into view.
|
|
20
24
|
* @cssprop --pb-highlight-color - Background color to highlight an element
|
|
21
25
|
*/
|
|
22
26
|
export class PbHighlight extends pbMixin(LitElement) {
|
|
@@ -24,7 +28,7 @@ export class PbHighlight extends pbMixin(LitElement) {
|
|
|
24
28
|
return {
|
|
25
29
|
...super.properties,
|
|
26
30
|
/**
|
|
27
|
-
*
|
|
31
|
+
* One or more keys (space or comma separated) to which this element is connected.
|
|
28
32
|
*/
|
|
29
33
|
key: {
|
|
30
34
|
type: String,
|
|
@@ -46,6 +50,12 @@ export class PbHighlight extends pbMixin(LitElement) {
|
|
|
46
50
|
type: Boolean,
|
|
47
51
|
attribute: 'highlight-self',
|
|
48
52
|
},
|
|
53
|
+
/**
|
|
54
|
+
* Defines one or more actions (space separated) which should cause the highlight to show.
|
|
55
|
+
*/
|
|
56
|
+
trigger: {
|
|
57
|
+
type: String,
|
|
58
|
+
},
|
|
49
59
|
_className: {
|
|
50
60
|
type: String,
|
|
51
61
|
},
|
|
@@ -58,9 +68,38 @@ export class PbHighlight extends pbMixin(LitElement) {
|
|
|
58
68
|
this.duration = 0;
|
|
59
69
|
this.scroll = false;
|
|
60
70
|
this.highlightSelf = false;
|
|
71
|
+
this.trigger = 'mouseenter';
|
|
61
72
|
this._className = 'highlight-off';
|
|
62
73
|
}
|
|
63
74
|
|
|
75
|
+
_getTriggers() {
|
|
76
|
+
return (this.trigger || 'mouseenter').trim().split(/\s+/);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
_getKeys() {
|
|
80
|
+
return (this.key || '').trim().split(/[\s,]+/).filter(Boolean);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
_getEventId() {
|
|
84
|
+
const keys = this._getKeys();
|
|
85
|
+
return keys.length > 1 ? keys : keys[0] || null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
_matchesKey(eventId) {
|
|
89
|
+
const keys = this._getKeys();
|
|
90
|
+
if (!keys.length || eventId == null) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
if (Array.isArray(eventId)) {
|
|
94
|
+
return keys.some(key => eventId.includes(key));
|
|
95
|
+
}
|
|
96
|
+
return keys.includes(eventId);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
_isClickable() {
|
|
100
|
+
return this._getTriggers().includes('click');
|
|
101
|
+
}
|
|
102
|
+
|
|
64
103
|
connectedCallback() {
|
|
65
104
|
super.connectedCallback();
|
|
66
105
|
this.subscribeTo('pb-highlight-on', this._highlightOn.bind(this));
|
|
@@ -74,17 +113,18 @@ export class PbHighlight extends pbMixin(LitElement) {
|
|
|
74
113
|
}
|
|
75
114
|
}
|
|
76
115
|
|
|
77
|
-
|
|
116
|
+
_triggerHighlight() {
|
|
78
117
|
this.emitTo('pb-highlight-off', {
|
|
79
118
|
source: this,
|
|
80
119
|
});
|
|
120
|
+
const id = this._getEventId();
|
|
81
121
|
if (this.highlightSelf) {
|
|
82
|
-
this._highlightOn({ detail: { id
|
|
122
|
+
this._highlightOn({ detail: { id } });
|
|
83
123
|
}
|
|
84
124
|
this.emitTo('pb-highlight-on', {
|
|
85
|
-
id
|
|
125
|
+
id,
|
|
86
126
|
source: this,
|
|
87
|
-
scroll: this.scroll,
|
|
127
|
+
scroll: this.scroll || this._isClickable(),
|
|
88
128
|
});
|
|
89
129
|
}
|
|
90
130
|
|
|
@@ -92,7 +132,12 @@ export class PbHighlight extends pbMixin(LitElement) {
|
|
|
92
132
|
if (this.disabled) {
|
|
93
133
|
return html`<slot></slot>`;
|
|
94
134
|
}
|
|
95
|
-
|
|
135
|
+
const triggers = this._getTriggers();
|
|
136
|
+
return html`<span
|
|
137
|
+
id="content"
|
|
138
|
+
class="${this._className}${this._isClickable() ? ' clickable' : ''}"
|
|
139
|
+
@mouseenter="${triggers.includes('mouseenter') ? this._triggerHighlight : null}"
|
|
140
|
+
@click="${triggers.includes('click') ? this._triggerHighlight : null}"
|
|
96
141
|
><slot></slot
|
|
97
142
|
></span>`;
|
|
98
143
|
}
|
|
@@ -127,14 +172,18 @@ export class PbHighlight extends pbMixin(LitElement) {
|
|
|
127
172
|
.highlight-off {
|
|
128
173
|
background-color: inherit;
|
|
129
174
|
}
|
|
175
|
+
|
|
176
|
+
.clickable {
|
|
177
|
+
cursor: pointer;
|
|
178
|
+
}
|
|
130
179
|
`;
|
|
131
180
|
}
|
|
132
181
|
|
|
133
182
|
_highlightOn(ev) {
|
|
134
|
-
if (ev.detail.source != this && ev.detail.id
|
|
183
|
+
if (ev.detail.source != this && this._matchesKey(ev.detail.id)) {
|
|
135
184
|
this._className = 'highlight-on';
|
|
136
185
|
if (ev.detail.scroll && this.disabled == false) {
|
|
137
|
-
this.scrollIntoView({ block: 'center',
|
|
186
|
+
this.scrollIntoView({ block: 'center', behavior: 'smooth' });
|
|
138
187
|
}
|
|
139
188
|
if (this.duration > 0) {
|
|
140
189
|
setTimeout(() => {
|
|
@@ -151,16 +200,16 @@ export class PbHighlight extends pbMixin(LitElement) {
|
|
|
151
200
|
}
|
|
152
201
|
|
|
153
202
|
/**
|
|
154
|
-
* Fired
|
|
203
|
+
* Fired when a trigger action occurs on the element
|
|
155
204
|
*
|
|
156
205
|
* @event pb-highlight-on
|
|
157
|
-
* @param {String} id key
|
|
206
|
+
* @param {String|Array<String>} id key or keys
|
|
158
207
|
* @param {Object} source this element
|
|
159
|
-
* @param {
|
|
208
|
+
* @param {Boolean} scroll should target scroll to highlighted position
|
|
160
209
|
*/
|
|
161
210
|
|
|
162
211
|
/**
|
|
163
|
-
* Fired
|
|
212
|
+
* Fired before a new highlight is applied
|
|
164
213
|
*
|
|
165
214
|
* @event pb-highlight-off
|
|
166
215
|
* @param {Object} source this element
|