@nys-cui/cui-section 0.2.5 → 0.2.7
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/package.json +1 -1
- package/src/section.js +54 -25
package/package.json
CHANGED
package/src/section.js
CHANGED
|
@@ -6,7 +6,7 @@ export default class CUI_SECTION extends HTMLElement {
|
|
|
6
6
|
|
|
7
7
|
super();
|
|
8
8
|
|
|
9
|
-
this.attachShadow({mode: 'open'});
|
|
9
|
+
this.attachShadow({ mode: 'open' });
|
|
10
10
|
|
|
11
11
|
this.state = {
|
|
12
12
|
sTitle: null
|
|
@@ -96,17 +96,17 @@ export default class CUI_SECTION extends HTMLElement {
|
|
|
96
96
|
// have the dContainer transition to the height of its inner content
|
|
97
97
|
dContainer.style.height = sectionHeight + 'px';
|
|
98
98
|
dContainer.style.overflow = "hidden";
|
|
99
|
-
|
|
99
|
+
|
|
100
100
|
// when the next css transition finishes (which should be the one we just triggered)
|
|
101
101
|
dContainer.addEventListener('transitionend', transitionEnd, true);
|
|
102
|
-
|
|
102
|
+
|
|
103
103
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
collapse(dContainer) {
|
|
107
107
|
|
|
108
108
|
function transitionEnd(e) {
|
|
109
|
-
|
|
109
|
+
|
|
110
110
|
dContainer.style.height = "";
|
|
111
111
|
dContainer.style.overflow = null;
|
|
112
112
|
|
|
@@ -121,22 +121,22 @@ export default class CUI_SECTION extends HTMLElement {
|
|
|
121
121
|
|
|
122
122
|
// get the height of the dContainer's inner content, regardless of its actual size
|
|
123
123
|
var sectionHeight = dContainer.scrollHeight;
|
|
124
|
-
|
|
124
|
+
|
|
125
125
|
// temporarily disable all css transitions
|
|
126
126
|
var dContainerTransition = dContainer.style.transition;
|
|
127
127
|
dContainer.style.transition = '';
|
|
128
|
-
|
|
128
|
+
|
|
129
129
|
// on the next frame (as soon as the previous style change has taken effect),
|
|
130
130
|
// explicitly set the dContainer's height to its current pixel height, so we
|
|
131
131
|
// aren't transitioning out of 'auto'
|
|
132
|
-
requestAnimationFrame(function() {
|
|
132
|
+
requestAnimationFrame(function () {
|
|
133
133
|
dContainer.style.height = sectionHeight + 'px';
|
|
134
134
|
dContainer.style.transition = dContainerTransition;
|
|
135
135
|
dContainer.style.overflow = "hidden";
|
|
136
|
-
|
|
136
|
+
|
|
137
137
|
// on the next frame (as soon as the previous style change has taken effect),
|
|
138
138
|
// have the dContainer transition to height: 0
|
|
139
|
-
requestAnimationFrame(function() {
|
|
139
|
+
requestAnimationFrame(function () {
|
|
140
140
|
|
|
141
141
|
dContainer.style.height = 0 + 'px';
|
|
142
142
|
|
|
@@ -145,7 +145,7 @@ export default class CUI_SECTION extends HTMLElement {
|
|
|
145
145
|
});
|
|
146
146
|
|
|
147
147
|
});
|
|
148
|
-
|
|
148
|
+
|
|
149
149
|
|
|
150
150
|
}
|
|
151
151
|
|
|
@@ -160,6 +160,11 @@ export default class CUI_SECTION extends HTMLElement {
|
|
|
160
160
|
|
|
161
161
|
this.sIconBasePath = this.getAttribute('iconbase') || null;
|
|
162
162
|
|
|
163
|
+
let dMessageList = this.querySelector(`[slot="section-messages"]`);
|
|
164
|
+
if (dMessageList) {
|
|
165
|
+
this._cMessageList = dMessageList;
|
|
166
|
+
}
|
|
167
|
+
|
|
163
168
|
this.render();
|
|
164
169
|
}
|
|
165
170
|
|
|
@@ -173,7 +178,7 @@ export default class CUI_SECTION extends HTMLElement {
|
|
|
173
178
|
|
|
174
179
|
this.sdSectionTitle.appendChild(document.createTextNode(this.state.sTitle));
|
|
175
180
|
|
|
176
|
-
|
|
181
|
+
if (!this.state.bHideControls) {
|
|
177
182
|
|
|
178
183
|
this.sdSectionCollapseControl = this.shadowRoot.querySelector(`#collapse-control`);
|
|
179
184
|
|
|
@@ -188,25 +193,25 @@ export default class CUI_SECTION extends HTMLElement {
|
|
|
188
193
|
}
|
|
189
194
|
|
|
190
195
|
this.sdSectionCollapseControl.addEventListener('click', () => {
|
|
191
|
-
|
|
196
|
+
|
|
192
197
|
if (!this.bLock) {
|
|
193
|
-
|
|
198
|
+
|
|
194
199
|
if (this.sdContentsContainer.getAttribute('data-collapsed') === "true") {
|
|
195
|
-
|
|
200
|
+
|
|
196
201
|
this.sdSectionCollapseControl.classList.remove('collapsed');
|
|
197
|
-
|
|
202
|
+
|
|
198
203
|
this.expand(this.sdContentsContainer);
|
|
199
204
|
}
|
|
200
205
|
else {
|
|
201
|
-
|
|
206
|
+
|
|
202
207
|
this.sdSectionCollapseControl.classList.add('collapsed');
|
|
203
|
-
|
|
208
|
+
|
|
204
209
|
this.collapse(this.sdContentsContainer);
|
|
205
210
|
}
|
|
206
|
-
|
|
211
|
+
|
|
207
212
|
this.bLock = false;
|
|
208
213
|
}
|
|
209
|
-
|
|
214
|
+
|
|
210
215
|
});
|
|
211
216
|
}
|
|
212
217
|
|
|
@@ -216,7 +221,7 @@ export default class CUI_SECTION extends HTMLElement {
|
|
|
216
221
|
|
|
217
222
|
for (let sStyle of this.state.asStyles) {
|
|
218
223
|
|
|
219
|
-
switch(sStyle.toLowerCase()) {
|
|
224
|
+
switch (sStyle.toLowerCase()) {
|
|
220
225
|
|
|
221
226
|
case "subsection":
|
|
222
227
|
|
|
@@ -238,16 +243,40 @@ export default class CUI_SECTION extends HTMLElement {
|
|
|
238
243
|
|
|
239
244
|
}
|
|
240
245
|
|
|
241
|
-
get messages()
|
|
242
|
-
|
|
243
|
-
if(!this._cMessageList)
|
|
244
|
-
{
|
|
246
|
+
get messages() {
|
|
247
|
+
if (!this._cMessageList) {
|
|
245
248
|
this._cMessageList = document.createElement('cui-message-list');
|
|
246
|
-
this._cMessageList.slot = "messages";
|
|
249
|
+
this._cMessageList.slot = "section-messages";
|
|
247
250
|
this.appendChild(this._cMessageList);
|
|
248
251
|
}
|
|
249
252
|
|
|
250
253
|
return this._cMessageList;
|
|
251
254
|
}
|
|
252
255
|
|
|
256
|
+
reset() {
|
|
257
|
+
if (this._cMessageList) {
|
|
258
|
+
this._cMessageList.reset();
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
setMessages(aoMessages) {
|
|
263
|
+
for (let i = 0; i < aoMessages.length; i++) {
|
|
264
|
+
if (this.messages) {
|
|
265
|
+
this.messages.add(aoMessages[i]);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
removeMessages() {
|
|
271
|
+
this.messages.removeAll();
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
removeMessage(id) {
|
|
275
|
+
this.messages.removeMessageWithId(id);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
removeMessageIndex(index) {
|
|
279
|
+
this.messages.removeMessageAtIndex(index);
|
|
280
|
+
}
|
|
281
|
+
|
|
253
282
|
}
|