@nys-cui/cui-section 0.2.17 → 0.2.19

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 CHANGED
@@ -6,7 +6,7 @@
6
6
  },
7
7
  "main": "./dist/js/section.js",
8
8
  "type": "module",
9
- "version": "0.2.17",
9
+ "version": "0.2.19",
10
10
  "scripts": {
11
11
  "clean": "rm -rf ./dist",
12
12
  "build": "npm run clean && cui --dep",
package/src/section.js CHANGED
@@ -29,10 +29,11 @@ export default class CUI_SECTION extends HTMLElement {
29
29
  this.oPropsToStateNames = {
30
30
  "sectiontitle": "sTitle",
31
31
  "hideControls": "bHideControls",
32
+ "hideHeader": "bHideHeader",
32
33
  "collapsed": "bCollapsed",
33
34
  "styles": "asStyles",
34
- "label": "sTitle"
35
-
35
+ "label": "sTitle",
36
+ "instructions": "oInstructions"
36
37
  }
37
38
  }
38
39
 
@@ -42,31 +43,34 @@ export default class CUI_SECTION extends HTMLElement {
42
43
 
43
44
  get template() {
44
45
 
45
- let sTemplate = `<section part="root-section"><header part="section-header">
46
- <div class='header-info' part='header-info'><h2 id="section-title" part="section-title"></h2><slot name='section-help-tag'></slot></div>`;
46
+ let sTemplate = `<section part="root-section"><header part="section-header ${this.state.bHideHeader ? `headless" class="headless"` : `"`}>`;
47
47
 
48
- if (!this.state.bHideControls) {
48
+ if(!this.state.bHideHeader) {
49
+ sTemplate += `<div class='header-info' part='header-info'><h2 id="section-title" part="section-title"></h2><slot name='section-help-tag'></slot></div>`;
49
50
 
50
- if (this.sIconBasePath) {
51
+ if (!this.state.bHideControls) {
51
52
 
52
- sTemplate += `
53
- <div class="header-controls" part="header-controls">
54
- <button type="button" id="collapse-control" aria-controls="container" part="collapse-control">
55
- <cui-icon src="caret-down" basePath="${this.sIconBasePath}" part="collapse-control-icon"></cui-icon>
56
- </button>
57
- </div>`;
53
+ if (this.sIconBasePath) {
58
54
 
59
- }
60
- else {
61
-
62
- sTemplate += `
63
- <div class="header-controls" part="header-controls">
64
- <button type="button" id="collapse-control" aria-controls="container" part="collapse-control">
65
- <cui-icon src="caret-down" part="collapse-control-icon"></cui-icon>
66
- </button>
67
- </div>`;
68
- }
55
+ sTemplate += `
56
+ <div class="header-controls" part="header-controls">
57
+ <button type="button" id="collapse-control" aria-controls="container" part="collapse-control">
58
+ <cui-icon src="caret-down" basePath="${this.sIconBasePath}" part="collapse-control-icon"></cui-icon>
59
+ </button>
60
+ </div>`;
61
+
62
+ }
63
+ else {
64
+
65
+ sTemplate += `
66
+ <div class="header-controls" part="header-controls">
67
+ <button type="button" id="collapse-control" aria-controls="container" part="collapse-control">
68
+ <cui-icon src="caret-down" part="collapse-control-icon"></cui-icon>
69
+ </button>
70
+ </div>`;
71
+ }
69
72
 
73
+ }
70
74
  }
71
75
 
72
76
  sTemplate += `</header><div class="container" id="container" part="container">
@@ -201,9 +205,11 @@ export default class CUI_SECTION extends HTMLElement {
201
205
 
202
206
  this.state = {
203
207
  sTitle: this.state.sTitle || this.getAttribute('sectiontitle') || "SECTION TITLE",
204
- bHideControls: this.hasAttribute("hideControls") ? true : false,
205
- bCollapsed: (this.getAttribute('collapsed') === "true") ? true : false,
206
- asStyles: (this.getAttribute('styles')) ? this.getAttribute('styles').split(',') : null
208
+ bHideControls: this.state.bHideControls || this.hasAttribute("hideControls") ? true : false,
209
+ bHideHeader: this.state.bHideHeader || this.hasAttribute("hideHeader") ? true : false,
210
+ bCollapsed: this.state.bCollapsed || (this.getAttribute('collapsed') === "true") ? true : false,
211
+ asStyles: this.state.asStyles || (this.getAttribute('styles')) ? this.getAttribute('styles').split(',') : null,
212
+ oInstructions: this.state.oInstructions || null
207
213
  }
208
214
 
209
215
  this.sIconBasePath = this.getAttribute('iconbase') || null;
@@ -290,6 +296,14 @@ export default class CUI_SECTION extends HTMLElement {
290
296
  })
291
297
  })
292
298
 
299
+ if(this.state.oInstructions && (this.state.oInstructions.text || this.state.oInstructions.html)) {
300
+ let dSectionInstructions = document.createElement("div");
301
+ dSectionInstructions.innerHTML = this.state.oInstructions.html || this.state.oInstructions.text;
302
+ dSectionInstructions.classList.add("section-instructions");
303
+ dSectionInstructions.setAttribute('slot', 'section-text');
304
+ this.appendChild(dSectionInstructions);
305
+ }
306
+
293
307
  }
294
308
 
295
309
  get messages() {
package/src/section.scss CHANGED
@@ -68,6 +68,11 @@
68
68
  }
69
69
  }
70
70
 
71
+ &.headless {
72
+ border-bottom: none;
73
+ margin: 0.75em 0.75em;
74
+ }
75
+
71
76
  }
72
77
 
73
78
  .container {