@ptcwebops/ptcw-design 5.3.6 → 5.3.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.
Files changed (33) hide show
  1. package/dist/cjs/blog-detail-content_2.cjs.entry.js +1 -1
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/ptc-inline-cta.cjs.entry.js +2 -2
  4. package/dist/cjs/ptc-readmore-new.cjs.entry.js +109 -0
  5. package/dist/cjs/ptc-readmore-v3.cjs.entry.js +108 -0
  6. package/dist/cjs/ptcw-design.cjs.js +1 -1
  7. package/dist/collection/collection-manifest.json +2 -0
  8. package/dist/collection/components/ptc-inline-cta/ptc-inline-cta.css +15 -3
  9. package/dist/collection/components/ptc-inline-cta/ptc-inline-cta.js +1 -1
  10. package/dist/collection/components/ptc-readmore-new/ptc-readmore-new.css +74 -0
  11. package/dist/collection/components/ptc-readmore-new/ptc-readmore-new.js +232 -0
  12. package/dist/collection/components/ptc-readmore-v2/ptc-readmore-v2.css +1 -1
  13. package/dist/collection/components/ptc-readmore-v3/ptc-readmore-v3.css +21 -0
  14. package/dist/collection/components/ptc-readmore-v3/ptc-readmore-v3.js +231 -0
  15. package/dist/custom-elements/index.d.ts +12 -0
  16. package/dist/custom-elements/index.js +215 -4
  17. package/dist/esm/blog-detail-content_2.entry.js +1 -1
  18. package/dist/esm/loader.js +1 -1
  19. package/dist/esm/ptc-inline-cta.entry.js +2 -2
  20. package/dist/esm/ptc-readmore-new.entry.js +105 -0
  21. package/dist/esm/ptc-readmore-v3.entry.js +104 -0
  22. package/dist/esm/ptcw-design.js +1 -1
  23. package/dist/ptcw-design/p-1921baf7.entry.js +1 -0
  24. package/dist/ptcw-design/{p-a11dbfda.entry.js → p-4721a749.entry.js} +1 -1
  25. package/dist/ptcw-design/p-520b4e6f.entry.js +1 -0
  26. package/dist/ptcw-design/p-6b32020a.entry.js +1 -0
  27. package/dist/ptcw-design/ptcw-design.esm.js +1 -1
  28. package/dist/types/components/ptc-readmore-new/ptc-readmore-new.d.ts +21 -0
  29. package/dist/types/components/ptc-readmore-v3/ptc-readmore-v3.d.ts +21 -0
  30. package/dist/types/components.d.ts +54 -0
  31. package/package.json +1 -1
  32. package/readme.md +1 -1
  33. package/dist/ptcw-design/p-c75d6045.entry.js +0 -1
@@ -0,0 +1,232 @@
1
+ import { Host, h } from '@stencil/core';
2
+ export class PtcReadmoreNew {
3
+ constructor() {
4
+ this.maxCharacters = 100;
5
+ this.readMoreText = "Read More";
6
+ this.readLessText = "Read Less";
7
+ this.maxLines = undefined;
8
+ this.expanded = false;
9
+ this.fullText = '';
10
+ this.truncated = false;
11
+ }
12
+ componentWillLoad() {
13
+ requestAnimationFrame(() => {
14
+ let slot = this.el.shadowRoot.querySelector('slot');
15
+ this.processText(slot);
16
+ });
17
+ }
18
+ slotChangeHandler(event) {
19
+ const slot = event.target;
20
+ this.processText(slot);
21
+ }
22
+ processText(slot) {
23
+ if (slot) {
24
+ const nodes = slot.assignedNodes({ flatten: true });
25
+ this.fullText = nodes
26
+ .map(node => node.textContent)
27
+ .join('')
28
+ .trim();
29
+ if (this.maxLines) {
30
+ this.truncateByLines();
31
+ }
32
+ else if (this.fullText.length > this.maxCharacters) {
33
+ this.truncated = true;
34
+ }
35
+ }
36
+ this.displayText.emit(this.truncated);
37
+ }
38
+ truncateByLines() {
39
+ const paragraph = document.createElement('p');
40
+ paragraph.style.visibility = 'hidden';
41
+ paragraph.style.position = 'fixed';
42
+ paragraph.innerText = this.fullText;
43
+ document.body.appendChild(paragraph);
44
+ const lineHeight = parseInt(window.getComputedStyle(paragraph).lineHeight, 10);
45
+ const maxHeight = lineHeight * this.maxLines;
46
+ paragraph.style.maxHeight = `${maxHeight}px`;
47
+ paragraph.style.overflow = 'hidden';
48
+ if (paragraph.scrollHeight > maxHeight) {
49
+ this.truncated = true;
50
+ }
51
+ document.body.removeChild(paragraph);
52
+ }
53
+ getContent() {
54
+ if (this.expanded) {
55
+ return this.fullText;
56
+ }
57
+ else if (this.maxLines) {
58
+ const paragraph = document.createElement('p');
59
+ paragraph.style.visibility = 'hidden';
60
+ paragraph.style.position = 'fixed';
61
+ paragraph.innerText = this.fullText;
62
+ document.body.appendChild(paragraph);
63
+ const lineHeight = parseInt(window.getComputedStyle(paragraph).lineHeight, 10);
64
+ const maxHeight = lineHeight * this.maxLines;
65
+ console.log("lineHeight: " + lineHeight);
66
+ paragraph.style.maxHeight = `${maxHeight}px`;
67
+ paragraph.style.overflow = 'hidden';
68
+ let truncatedText = '';
69
+ for (let i = 0; i < this.fullText.length; i++) {
70
+ paragraph.innerText = this.fullText.slice(0, i) + '...';
71
+ if (paragraph.scrollHeight > maxHeight) {
72
+ truncatedText = this.fullText.slice(0, i - 1) + '...';
73
+ break;
74
+ }
75
+ }
76
+ document.body.removeChild(paragraph);
77
+ return truncatedText;
78
+ }
79
+ else {
80
+ return this.fullText.substring(0, this.maxCharacters) + '...';
81
+ }
82
+ }
83
+ getLabel() {
84
+ return this.expanded ? this.readLessText : this.readMoreText;
85
+ }
86
+ toggleExpand() {
87
+ this.expanded = !this.expanded;
88
+ this.readMoreTrigger.emit(this.expanded);
89
+ }
90
+ render() {
91
+ return (h(Host, null, h("p", { class: "description" }, this.truncated ? this.getContent() : h("slot", null)), this.truncated ?
92
+ h("label", { class: "label", onClick: () => this.toggleExpand() }, this.getLabel())
93
+ : null));
94
+ }
95
+ static get is() { return "ptc-readmore-new"; }
96
+ static get encapsulation() { return "shadow"; }
97
+ static get originalStyleUrls() {
98
+ return {
99
+ "$": ["ptc-readmore-new.scss"]
100
+ };
101
+ }
102
+ static get styleUrls() {
103
+ return {
104
+ "$": ["ptc-readmore-new.css"]
105
+ };
106
+ }
107
+ static get properties() {
108
+ return {
109
+ "maxCharacters": {
110
+ "type": "number",
111
+ "mutable": false,
112
+ "complexType": {
113
+ "original": "number",
114
+ "resolved": "number",
115
+ "references": {}
116
+ },
117
+ "required": false,
118
+ "optional": false,
119
+ "docs": {
120
+ "tags": [],
121
+ "text": ""
122
+ },
123
+ "attribute": "max-characters",
124
+ "reflect": false,
125
+ "defaultValue": "100"
126
+ },
127
+ "readMoreText": {
128
+ "type": "string",
129
+ "mutable": false,
130
+ "complexType": {
131
+ "original": "string",
132
+ "resolved": "string",
133
+ "references": {}
134
+ },
135
+ "required": false,
136
+ "optional": false,
137
+ "docs": {
138
+ "tags": [],
139
+ "text": ""
140
+ },
141
+ "attribute": "read-more-text",
142
+ "reflect": false,
143
+ "defaultValue": "\"Read More\""
144
+ },
145
+ "readLessText": {
146
+ "type": "string",
147
+ "mutable": false,
148
+ "complexType": {
149
+ "original": "string",
150
+ "resolved": "string",
151
+ "references": {}
152
+ },
153
+ "required": false,
154
+ "optional": false,
155
+ "docs": {
156
+ "tags": [],
157
+ "text": ""
158
+ },
159
+ "attribute": "read-less-text",
160
+ "reflect": false,
161
+ "defaultValue": "\"Read Less\""
162
+ },
163
+ "maxLines": {
164
+ "type": "number",
165
+ "mutable": false,
166
+ "complexType": {
167
+ "original": "number",
168
+ "resolved": "number",
169
+ "references": {}
170
+ },
171
+ "required": false,
172
+ "optional": false,
173
+ "docs": {
174
+ "tags": [],
175
+ "text": ""
176
+ },
177
+ "attribute": "max-lines",
178
+ "reflect": false
179
+ }
180
+ };
181
+ }
182
+ static get states() {
183
+ return {
184
+ "expanded": {},
185
+ "fullText": {},
186
+ "truncated": {}
187
+ };
188
+ }
189
+ static get events() {
190
+ return [{
191
+ "method": "readMoreTrigger",
192
+ "name": "readMoreTrigger",
193
+ "bubbles": true,
194
+ "cancelable": true,
195
+ "composed": true,
196
+ "docs": {
197
+ "tags": [],
198
+ "text": ""
199
+ },
200
+ "complexType": {
201
+ "original": "boolean",
202
+ "resolved": "boolean",
203
+ "references": {}
204
+ }
205
+ }, {
206
+ "method": "displayText",
207
+ "name": "displayText",
208
+ "bubbles": true,
209
+ "cancelable": true,
210
+ "composed": true,
211
+ "docs": {
212
+ "tags": [],
213
+ "text": ""
214
+ },
215
+ "complexType": {
216
+ "original": "boolean",
217
+ "resolved": "boolean",
218
+ "references": {}
219
+ }
220
+ }];
221
+ }
222
+ static get elementRef() { return "el"; }
223
+ static get listeners() {
224
+ return [{
225
+ "name": "slotchange",
226
+ "method": "slotChangeHandler",
227
+ "target": undefined,
228
+ "capture": false,
229
+ "passive": false
230
+ }];
231
+ }
232
+ }
@@ -70,5 +70,5 @@ ptc-link, ptc-square-card,
70
70
  }
71
71
  :host .truncated-label::before {
72
72
  content: "";
73
- padding-left: 8px;
73
+ padding-left: var(--ptc-element-spacing-02);
74
74
  }
@@ -0,0 +1,21 @@
1
+ :host {
2
+ display: block;
3
+
4
+ .description{
5
+ display: inline;
6
+ }
7
+
8
+ .label{
9
+ cursor: pointer;
10
+ color: var(--color-hyperlink);
11
+ font-size: var(--ptc-font-size-small);
12
+ font-weight: var(--ptc-font-weight-bold);
13
+ text-decoration-line: underline;
14
+ line-height: var(--ptc-line-height-densest);
15
+
16
+ &::before{
17
+ content: '';
18
+ padding-left: 8px;
19
+ }
20
+ }
21
+ }
@@ -0,0 +1,231 @@
1
+ import { Host, h } from '@stencil/core';
2
+ export class PtcReadmoreV3 {
3
+ constructor() {
4
+ this.maxCharacters = 100;
5
+ this.readMoreText = 'Read More';
6
+ this.readLessText = 'Read Less';
7
+ this.maxLines = undefined;
8
+ this.expanded = false;
9
+ this.fullText = '';
10
+ this.truncated = false;
11
+ }
12
+ componentWillLoad() {
13
+ requestAnimationFrame(() => {
14
+ let slot = this.el.shadowRoot.querySelector('slot');
15
+ this.processText(slot);
16
+ });
17
+ }
18
+ slotChangeHandler(event) {
19
+ const slot = event.target;
20
+ this.processText(slot);
21
+ }
22
+ processText(slot) {
23
+ if (slot) {
24
+ const nodes = slot.assignedNodes({ flatten: true });
25
+ this.fullText = nodes
26
+ .map(node => node.textContent)
27
+ .join('')
28
+ .trim();
29
+ if (this.maxLines) {
30
+ this.truncateByLines();
31
+ }
32
+ else if (this.fullText.length > this.maxCharacters) {
33
+ this.truncated = true;
34
+ }
35
+ }
36
+ this.displayText.emit(this.truncated);
37
+ }
38
+ truncateByLines() {
39
+ const paragraph = document.createElement('p');
40
+ paragraph.style.visibility = 'hidden';
41
+ paragraph.style.position = 'fixed';
42
+ paragraph.innerText = this.fullText;
43
+ document.body.appendChild(paragraph);
44
+ const lineHeight = parseFloat(window.getComputedStyle(paragraph).lineHeight);
45
+ console.log('lineHeight: ' + lineHeight);
46
+ const maxHeight = lineHeight * this.maxLines;
47
+ paragraph.style.maxHeight = `${maxHeight}px`;
48
+ paragraph.style.overflow = 'hidden';
49
+ if (paragraph.scrollHeight > maxHeight) {
50
+ this.truncated = true;
51
+ }
52
+ document.body.removeChild(paragraph);
53
+ }
54
+ getContent() {
55
+ if (this.expanded) {
56
+ return this.fullText;
57
+ }
58
+ else if (this.maxLines) {
59
+ const paragraph = document.createElement('p');
60
+ paragraph.style.visibility = 'hidden';
61
+ paragraph.style.position = 'fixed';
62
+ paragraph.innerText = this.fullText;
63
+ document.body.appendChild(paragraph);
64
+ const lineHeight = parseFloat(window.getComputedStyle(paragraph).lineHeight);
65
+ const maxHeight = lineHeight * this.maxLines;
66
+ console.log('lineHeight: ' + lineHeight);
67
+ paragraph.style.maxHeight = `${maxHeight}px`;
68
+ paragraph.style.overflow = 'hidden';
69
+ let truncatedText = '';
70
+ for (let i = 0; i < this.fullText.length; i++) {
71
+ paragraph.innerText = this.fullText.slice(0, i) + '...';
72
+ if (paragraph.scrollHeight > maxHeight) {
73
+ truncatedText = this.fullText.slice(0, i - 1) + '...';
74
+ break;
75
+ }
76
+ }
77
+ document.body.removeChild(paragraph);
78
+ return truncatedText;
79
+ }
80
+ else {
81
+ return this.fullText.substring(0, this.maxCharacters) + '...';
82
+ }
83
+ }
84
+ getLabel() {
85
+ return this.expanded ? this.readLessText : this.readMoreText;
86
+ }
87
+ toggleExpand() {
88
+ this.expanded = !this.expanded;
89
+ this.readMoreTrigger.emit(this.expanded);
90
+ }
91
+ render() {
92
+ return (h(Host, null, h("p", { class: "description" }, this.truncated ? this.getContent() : h("slot", null)), this.truncated ? (h("label", { class: "label", onClick: () => this.toggleExpand() }, this.getLabel())) : null));
93
+ }
94
+ static get is() { return "ptc-readmore-v3"; }
95
+ static get encapsulation() { return "shadow"; }
96
+ static get originalStyleUrls() {
97
+ return {
98
+ "$": ["ptc-readmore-v3.css"]
99
+ };
100
+ }
101
+ static get styleUrls() {
102
+ return {
103
+ "$": ["ptc-readmore-v3.css"]
104
+ };
105
+ }
106
+ static get properties() {
107
+ return {
108
+ "maxCharacters": {
109
+ "type": "number",
110
+ "mutable": false,
111
+ "complexType": {
112
+ "original": "number",
113
+ "resolved": "number",
114
+ "references": {}
115
+ },
116
+ "required": false,
117
+ "optional": false,
118
+ "docs": {
119
+ "tags": [],
120
+ "text": ""
121
+ },
122
+ "attribute": "max-characters",
123
+ "reflect": false,
124
+ "defaultValue": "100"
125
+ },
126
+ "readMoreText": {
127
+ "type": "string",
128
+ "mutable": false,
129
+ "complexType": {
130
+ "original": "string",
131
+ "resolved": "string",
132
+ "references": {}
133
+ },
134
+ "required": false,
135
+ "optional": false,
136
+ "docs": {
137
+ "tags": [],
138
+ "text": ""
139
+ },
140
+ "attribute": "read-more-text",
141
+ "reflect": false,
142
+ "defaultValue": "'Read More'"
143
+ },
144
+ "readLessText": {
145
+ "type": "string",
146
+ "mutable": false,
147
+ "complexType": {
148
+ "original": "string",
149
+ "resolved": "string",
150
+ "references": {}
151
+ },
152
+ "required": false,
153
+ "optional": false,
154
+ "docs": {
155
+ "tags": [],
156
+ "text": ""
157
+ },
158
+ "attribute": "read-less-text",
159
+ "reflect": false,
160
+ "defaultValue": "'Read Less'"
161
+ },
162
+ "maxLines": {
163
+ "type": "number",
164
+ "mutable": false,
165
+ "complexType": {
166
+ "original": "number",
167
+ "resolved": "number",
168
+ "references": {}
169
+ },
170
+ "required": false,
171
+ "optional": false,
172
+ "docs": {
173
+ "tags": [],
174
+ "text": ""
175
+ },
176
+ "attribute": "max-lines",
177
+ "reflect": false
178
+ }
179
+ };
180
+ }
181
+ static get states() {
182
+ return {
183
+ "expanded": {},
184
+ "fullText": {},
185
+ "truncated": {}
186
+ };
187
+ }
188
+ static get events() {
189
+ return [{
190
+ "method": "readMoreTrigger",
191
+ "name": "readMoreTrigger",
192
+ "bubbles": true,
193
+ "cancelable": true,
194
+ "composed": true,
195
+ "docs": {
196
+ "tags": [],
197
+ "text": ""
198
+ },
199
+ "complexType": {
200
+ "original": "boolean",
201
+ "resolved": "boolean",
202
+ "references": {}
203
+ }
204
+ }, {
205
+ "method": "displayText",
206
+ "name": "displayText",
207
+ "bubbles": true,
208
+ "cancelable": true,
209
+ "composed": true,
210
+ "docs": {
211
+ "tags": [],
212
+ "text": ""
213
+ },
214
+ "complexType": {
215
+ "original": "boolean",
216
+ "resolved": "boolean",
217
+ "references": {}
218
+ }
219
+ }];
220
+ }
221
+ static get elementRef() { return "el"; }
222
+ static get listeners() {
223
+ return [{
224
+ "name": "slotchange",
225
+ "method": "slotChangeHandler",
226
+ "target": undefined,
227
+ "capture": false,
228
+ "passive": false
229
+ }];
230
+ }
231
+ }
@@ -704,12 +704,24 @@ export const PtcReadmoreChar: {
704
704
  new (): PtcReadmoreChar;
705
705
  };
706
706
 
707
+ interface PtcReadmoreNew extends Components.PtcReadmoreNew, HTMLElement {}
708
+ export const PtcReadmoreNew: {
709
+ prototype: PtcReadmoreNew;
710
+ new (): PtcReadmoreNew;
711
+ };
712
+
707
713
  interface PtcReadmoreV2 extends Components.PtcReadmoreV2, HTMLElement {}
708
714
  export const PtcReadmoreV2: {
709
715
  prototype: PtcReadmoreV2;
710
716
  new (): PtcReadmoreV2;
711
717
  };
712
718
 
719
+ interface PtcReadmoreV3 extends Components.PtcReadmoreV3, HTMLElement {}
720
+ export const PtcReadmoreV3: {
721
+ prototype: PtcReadmoreV3;
722
+ new (): PtcReadmoreV3;
723
+ };
724
+
713
725
  interface PtcRelatedCardRail extends Components.PtcRelatedCardRail, HTMLElement {}
714
726
  export const PtcRelatedCardRail: {
715
727
  prototype: PtcRelatedCardRail;