@everymatrix/pam-consent-item 0.1.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.
Files changed (56) hide show
  1. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  2. package/dist/cjs/index-9a334d0d.js +1217 -0
  3. package/dist/cjs/index.cjs.js +10 -0
  4. package/dist/cjs/loader.cjs.js +15 -0
  5. package/dist/cjs/pam-consent-item-d3c126e6.js +534 -0
  6. package/dist/cjs/pam-consent-item.cjs.entry.js +10 -0
  7. package/dist/cjs/pam-consent-item.cjs.js +25 -0
  8. package/dist/collection/collection-manifest.json +12 -0
  9. package/dist/collection/components/pam-consent-item/index.js +1 -0
  10. package/dist/collection/components/pam-consent-item/pam-consent-item.css +59 -0
  11. package/dist/collection/components/pam-consent-item/pam-consent-item.js +320 -0
  12. package/dist/collection/index.js +1 -0
  13. package/dist/collection/utils/locale.utils.js +348 -0
  14. package/dist/collection/utils/utils.js +3 -0
  15. package/dist/esm/app-globals-0f993ce5.js +3 -0
  16. package/dist/esm/index-118c07e1.js +1190 -0
  17. package/dist/esm/index.js +2 -0
  18. package/dist/esm/loader.js +11 -0
  19. package/dist/esm/pam-consent-item-648fff6a.js +532 -0
  20. package/dist/esm/pam-consent-item.entry.js +2 -0
  21. package/dist/esm/pam-consent-item.js +20 -0
  22. package/dist/index.cjs.js +1 -0
  23. package/dist/index.js +1 -0
  24. package/dist/pam-consent-item/index.esm.js +1 -0
  25. package/dist/pam-consent-item/p-38e163d6.js +2 -0
  26. package/dist/pam-consent-item/p-4494a6bd.js +1 -0
  27. package/dist/pam-consent-item/p-510b9421.entry.js +1 -0
  28. package/dist/pam-consent-item/p-e1255160.js +1 -0
  29. package/dist/pam-consent-item/pam-consent-item.esm.js +1 -0
  30. package/dist/stencil.config.dev.js +19 -0
  31. package/dist/stencil.config.js +18 -0
  32. package/dist/storybook/main.js +43 -0
  33. package/dist/storybook/preview.js +9 -0
  34. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-consent-item/.stencil/libs/common/src/storybook/storybook-utils.d.ts +39 -0
  35. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-consent-item/.stencil/packages/stencil/pam-consent-item/stencil.config.d.ts +2 -0
  36. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-consent-item/.stencil/packages/stencil/pam-consent-item/stencil.config.dev.d.ts +2 -0
  37. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-consent-item/.stencil/packages/stencil/pam-consent-item/storybook/main.d.ts +3 -0
  38. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-consent-item/.stencil/packages/stencil/pam-consent-item/storybook/preview.d.ts +70 -0
  39. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-consent-item/.stencil/tools/plugins/index.d.ts +3 -0
  40. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-consent-item/.stencil/tools/plugins/stencil-clean-deps-plugin.d.ts +5 -0
  41. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-consent-item/.stencil/tools/plugins/vite-chunk-plugin.d.ts +6 -0
  42. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-consent-item/.stencil/tools/plugins/vite-clean-deps-plugin.d.ts +4 -0
  43. package/dist/types/components/pam-consent-item/index.d.ts +1 -0
  44. package/dist/types/components/pam-consent-item/pam-consent-item.d.ts +66 -0
  45. package/dist/types/components.d.ts +125 -0
  46. package/dist/types/index.d.ts +1 -0
  47. package/dist/types/stencil-public-runtime.d.ts +1674 -0
  48. package/dist/types/utils/locale.utils.d.ts +2 -0
  49. package/dist/types/utils/utils.d.ts +1 -0
  50. package/loader/cdn.js +1 -0
  51. package/loader/index.cjs.js +1 -0
  52. package/loader/index.d.ts +24 -0
  53. package/loader/index.es2017.js +1 -0
  54. package/loader/index.js +2 -0
  55. package/loader/package.json +11 -0
  56. package/package.json +27 -0
@@ -0,0 +1,59 @@
1
+ :host {
2
+ display: block;
3
+ font-family: inherit;
4
+ }
5
+
6
+ .ConsentTitle {
7
+ margin-bottom: 0.2rem;
8
+ font-weight: 600;
9
+ }
10
+
11
+ .UserConsent:hover {
12
+ cursor: pointer;
13
+ }
14
+
15
+ .UserConsent {
16
+ display: flex;
17
+ align-items: center;
18
+ }
19
+ .UserConsent input {
20
+ appearance: none;
21
+ width: 18px;
22
+ border-radius: 3px;
23
+ height: 18px;
24
+ border: 1px solid var(--emw--color-black, #000000);
25
+ background-color: var(--emw--color-white, #FFFFFF);
26
+ cursor: pointer;
27
+ position: relative;
28
+ }
29
+ .UserConsent input:checked {
30
+ background-color: var(--emw--color-white, #FFFFFF);
31
+ border: 1px solid var(--emw--color-black, #000000);
32
+ }
33
+ .UserConsent input:checked::after {
34
+ content: "";
35
+ position: absolute;
36
+ width: 4px;
37
+ height: 8px;
38
+ border: solid var(--emw--color-black, #000000);
39
+ background-color: var(--emw--color-white, #FFFFFF);
40
+ border-width: 0 2px 2px 0;
41
+ top: 2px;
42
+ left: 5px;
43
+ transform: rotate(45deg);
44
+ }
45
+
46
+ .MandatoryItem {
47
+ color: var(--emw--color-error, var(--emw--color-red, #ed0909));
48
+ font-size: 1.2rem;
49
+ }
50
+
51
+ .ConsentLink {
52
+ text-decoration: underline;
53
+ color: var(--emw--color-primary, #52d004);
54
+ font-weight: bold;
55
+ }
56
+
57
+ .ConsentGroup {
58
+ margin-left: 25px;
59
+ }
@@ -0,0 +1,320 @@
1
+ import { h } from "@stencil/core";
2
+ import { setClientStyling, setClientStylingURL, setStreamStyling } from "../../../../../../../../libs/common/src/styling/index";
3
+ import { getTranslations, translate } from "../../utils/locale.utils";
4
+ export class PamConsentItem {
5
+ constructor() {
6
+ this.consentConfig = [];
7
+ this.inputRefs = { parent: null, children: {} };
8
+ this.goToTermsAndConditions = () => {
9
+ window.postMessage({ type: 'GoToTermsAndConditions' });
10
+ };
11
+ this.goToPrivacyPolicy = () => {
12
+ window.postMessage({ type: 'GoToPrivacyPolicy' });
13
+ };
14
+ this.userLegislationConsentHandler = () => {
15
+ if (this.group) {
16
+ this.updateGroupParent();
17
+ }
18
+ if (this.mandatory || this.queried) {
19
+ const consents = [];
20
+ if (this.group) {
21
+ for (const [consentType, inputRef] of Object.entries(this.inputRefs.children)) {
22
+ consents.push({ type: consentType, value: inputRef.checked });
23
+ }
24
+ }
25
+ else {
26
+ consents.push({ type: this.consentConfig[0].tagCode, value: this.inputRefs.parent.checked });
27
+ }
28
+ this.userLegislationConsent.emit(consents);
29
+ }
30
+ };
31
+ this.updateGroupParent = () => {
32
+ this.inputRefs.parent.checked = Object.values(this.inputRefs.children).every(inputRef => inputRef.checked);
33
+ };
34
+ this.toggleGroupChildren = () => {
35
+ Object.values(this.inputRefs.children).forEach(inputRef => inputRef.checked = this.inputRefs.parent.checked);
36
+ };
37
+ this.language = 'en';
38
+ this.queried = false;
39
+ this.group = undefined;
40
+ this.consentTypes = '';
41
+ this.mandatory = 'false';
42
+ this.clientStyling = '';
43
+ this.clientStylingUrl = '';
44
+ this.translationUrl = '';
45
+ this.mbSource = undefined;
46
+ }
47
+ handleClientStylingChange(newValue, oldValue) {
48
+ if (newValue != oldValue) {
49
+ setClientStyling(this.stylingContainer, this.clientStyling);
50
+ }
51
+ }
52
+ handleClientStylingUrlChange(newValue, oldValue) {
53
+ if (newValue != oldValue) {
54
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
55
+ }
56
+ }
57
+ handleMbSourceChange(newValue, oldValue) {
58
+ if (newValue != oldValue) {
59
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
60
+ }
61
+ }
62
+ async componentWillLoad() {
63
+ const consentTypesArray = this.consentTypes.split(',');
64
+ const consentMandatoryArray = this.mandatory.split(',');
65
+ for (let i = 0; i < consentTypesArray.length; ++i) {
66
+ this.consentConfig.push({
67
+ tagCode: consentTypesArray[i],
68
+ mandatory: consentMandatoryArray[i] === 'true'
69
+ });
70
+ }
71
+ if (this.translationUrl.length > 2) {
72
+ await getTranslations(this.translationUrl);
73
+ }
74
+ }
75
+ componentDidLoad() {
76
+ if (this.stylingContainer) {
77
+ if (this.mbSource)
78
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
79
+ if (this.clientStyling)
80
+ setClientStyling(this.stylingContainer, this.clientStyling);
81
+ if (this.clientStylingUrl)
82
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
83
+ }
84
+ }
85
+ disconnectedCallback() {
86
+ this.stylingSubscription && this.stylingSubscription.unsubscribe();
87
+ }
88
+ determineTextContent(consentType) {
89
+ if (consentType === 'termsandconditions') {
90
+ return h("p", null, translate('termsandconditions.textPart1', this.language), h("span", { class: "ConsentLink", onClick: this.goToTermsAndConditions }, translate('termsandconditions.link', this.language)), translate('termsandconditions.textPart2', this.language));
91
+ }
92
+ if (consentType === 'privacypolicy') {
93
+ return h("p", null, translate('privacypolicy.textPart1', this.language), h("span", { class: "ConsentLink", onClick: this.goToPrivacyPolicy }, translate('privacypolicy.link', this.language)), translate('privacypolicy.textPart2', this.language));
94
+ }
95
+ return h("p", null, translate(`${consentType}.text`, this.language));
96
+ }
97
+ render() {
98
+ if (this.queried) {
99
+ this.userLegislationConsentHandler();
100
+ }
101
+ return (h("div", { key: '255d7bbf241891327f3181047c0203f6b482f14a', ref: el => this.stylingContainer = el }, !this.group
102
+ ? [
103
+ h("h5", { class: "ConsentTitle" }, translate(`${this.consentConfig[0].tagCode}.title`, this.language)),
104
+ h("label", { class: "UserConsent", htmlFor: "userConsent" }, h("input", { ref: el => this.inputRefs.parent = el, type: "checkbox", onInput: this.userLegislationConsentHandler }), this.determineTextContent(this.consentConfig[0].tagCode), this.consentConfig[0].mandatory && h("span", { class: "MandatoryItem" }, "*"))
105
+ ]
106
+ : [
107
+ h("h5", { class: "ConsentTitle" }, translate(`${this.group}.title`, this.language)),
108
+ h("label", { class: "UserConsent Parent" }, h("input", { ref: el => this.inputRefs.parent = el, type: "checkbox", onInput: this.toggleGroupChildren }), this.determineTextContent(this.group), this.consentConfig.every(consent => consent.mandatory) && h("span", { class: "MandatoryItem" }, "*")),
109
+ h("div", { class: "ConsentGroup" }, this.consentConfig.map((consent) => {
110
+ return (h("label", { class: "UserConsent" }, h("input", { ref: el => this.inputRefs.children[consent.tagCode] = el, type: "checkbox", onInput: this.userLegislationConsentHandler }), this.determineTextContent(consent.tagCode), consent.mandatory && h("span", { class: "MandatoryItem" }, "*")));
111
+ }))
112
+ ]));
113
+ }
114
+ static get is() { return "pam-consent-item"; }
115
+ static get encapsulation() { return "shadow"; }
116
+ static get originalStyleUrls() {
117
+ return {
118
+ "$": ["pam-consent-item.scss"]
119
+ };
120
+ }
121
+ static get styleUrls() {
122
+ return {
123
+ "$": ["pam-consent-item.css"]
124
+ };
125
+ }
126
+ static get properties() {
127
+ return {
128
+ "language": {
129
+ "type": "string",
130
+ "mutable": true,
131
+ "complexType": {
132
+ "original": "string",
133
+ "resolved": "string",
134
+ "references": {}
135
+ },
136
+ "required": false,
137
+ "optional": false,
138
+ "docs": {
139
+ "tags": [],
140
+ "text": "Language"
141
+ },
142
+ "attribute": "language",
143
+ "reflect": true,
144
+ "defaultValue": "'en'"
145
+ },
146
+ "queried": {
147
+ "type": "boolean",
148
+ "mutable": false,
149
+ "complexType": {
150
+ "original": "boolean",
151
+ "resolved": "boolean",
152
+ "references": {}
153
+ },
154
+ "required": false,
155
+ "optional": false,
156
+ "docs": {
157
+ "tags": [],
158
+ "text": "'true' when parent expects component to emit it's current value"
159
+ },
160
+ "attribute": "queried",
161
+ "reflect": true,
162
+ "defaultValue": "false"
163
+ },
164
+ "group": {
165
+ "type": "string",
166
+ "mutable": false,
167
+ "complexType": {
168
+ "original": "string",
169
+ "resolved": "string",
170
+ "references": {}
171
+ },
172
+ "required": false,
173
+ "optional": false,
174
+ "docs": {
175
+ "tags": [],
176
+ "text": "group (consent category). If it is empty, it's assumed that only one consent is passed in consentTypes"
177
+ },
178
+ "attribute": "group",
179
+ "reflect": true
180
+ },
181
+ "consentTypes": {
182
+ "type": "string",
183
+ "mutable": false,
184
+ "complexType": {
185
+ "original": "string",
186
+ "resolved": "string",
187
+ "references": {}
188
+ },
189
+ "required": false,
190
+ "optional": false,
191
+ "docs": {
192
+ "tags": [],
193
+ "text": "the tagCodes of the consents separated by a \",\"."
194
+ },
195
+ "attribute": "consent-types",
196
+ "reflect": true,
197
+ "defaultValue": "''"
198
+ },
199
+ "mandatory": {
200
+ "type": "string",
201
+ "mutable": false,
202
+ "complexType": {
203
+ "original": "string",
204
+ "resolved": "string",
205
+ "references": {}
206
+ },
207
+ "required": false,
208
+ "optional": false,
209
+ "docs": {
210
+ "tags": [],
211
+ "text": "mandatory status of consents separated by a \",\"."
212
+ },
213
+ "attribute": "mandatory",
214
+ "reflect": true,
215
+ "defaultValue": "'false'"
216
+ },
217
+ "clientStyling": {
218
+ "type": "string",
219
+ "mutable": false,
220
+ "complexType": {
221
+ "original": "string",
222
+ "resolved": "string",
223
+ "references": {}
224
+ },
225
+ "required": false,
226
+ "optional": false,
227
+ "docs": {
228
+ "tags": [],
229
+ "text": "Client custom styling via inline style"
230
+ },
231
+ "attribute": "client-styling",
232
+ "reflect": true,
233
+ "defaultValue": "''"
234
+ },
235
+ "clientStylingUrl": {
236
+ "type": "string",
237
+ "mutable": false,
238
+ "complexType": {
239
+ "original": "string",
240
+ "resolved": "string",
241
+ "references": {}
242
+ },
243
+ "required": false,
244
+ "optional": false,
245
+ "docs": {
246
+ "tags": [],
247
+ "text": "Client custom styling via url"
248
+ },
249
+ "attribute": "client-styling-url",
250
+ "reflect": true,
251
+ "defaultValue": "''"
252
+ },
253
+ "translationUrl": {
254
+ "type": "string",
255
+ "mutable": false,
256
+ "complexType": {
257
+ "original": "string",
258
+ "resolved": "string",
259
+ "references": {}
260
+ },
261
+ "required": false,
262
+ "optional": false,
263
+ "docs": {
264
+ "tags": [],
265
+ "text": "Translation url"
266
+ },
267
+ "attribute": "translation-url",
268
+ "reflect": true,
269
+ "defaultValue": "''"
270
+ },
271
+ "mbSource": {
272
+ "type": "string",
273
+ "mutable": false,
274
+ "complexType": {
275
+ "original": "string",
276
+ "resolved": "string",
277
+ "references": {}
278
+ },
279
+ "required": false,
280
+ "optional": false,
281
+ "docs": {
282
+ "tags": [],
283
+ "text": "the text content to be rendered by the component. Determined at runtime"
284
+ },
285
+ "attribute": "mb-source",
286
+ "reflect": true
287
+ }
288
+ };
289
+ }
290
+ static get events() {
291
+ return [{
292
+ "method": "userLegislationConsent",
293
+ "name": "userLegislationConsent",
294
+ "bubbles": true,
295
+ "cancelable": true,
296
+ "composed": true,
297
+ "docs": {
298
+ "tags": [],
299
+ "text": ""
300
+ },
301
+ "complexType": {
302
+ "original": "{ type: string, value: boolean}[]",
303
+ "resolved": "{ type: string; value: boolean; }[]",
304
+ "references": {}
305
+ }
306
+ }];
307
+ }
308
+ static get watchers() {
309
+ return [{
310
+ "propName": "clientStyling",
311
+ "methodName": "handleClientStylingChange"
312
+ }, {
313
+ "propName": "clientStylingUrl",
314
+ "methodName": "handleClientStylingUrlChange"
315
+ }, {
316
+ "propName": "mbSource",
317
+ "methodName": "handleMbSourceChange"
318
+ }];
319
+ }
320
+ }
@@ -0,0 +1 @@
1
+ export * from './components/pam-consent-item';