@swisspost/design-system-components 1.4.0 → 1.5.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 (146) hide show
  1. package/dist/cjs/check-one-of-4c2e8b2e.js +10 -0
  2. package/dist/cjs/check-one-of-4c2e8b2e.js.map +1 -0
  3. package/dist/cjs/{check-type-f24cf91d.js → check-type-508a21a5.js} +1 -7
  4. package/dist/cjs/check-type-508a21a5.js.map +1 -0
  5. package/dist/cjs/fade-8c6d4fa7.js +12 -0
  6. package/dist/cjs/fade-8c6d4fa7.js.map +1 -0
  7. package/dist/cjs/{index-50d7d035.js → index-12cc37c9.js} +107 -5
  8. package/dist/cjs/index-12cc37c9.js.map +1 -0
  9. package/dist/cjs/index-f8f6f146.js +28 -0
  10. package/dist/cjs/index-f8f6f146.js.map +1 -0
  11. package/dist/cjs/loader.cjs.js +2 -2
  12. package/dist/cjs/package-67091813.js +7 -0
  13. package/dist/cjs/package-67091813.js.map +1 -0
  14. package/dist/cjs/post-alert.cjs.entry.js +106 -0
  15. package/dist/cjs/post-alert.cjs.entry.js.map +1 -0
  16. package/dist/cjs/post-collapsible.cjs.entry.js +5 -4
  17. package/dist/cjs/post-collapsible.cjs.entry.js.map +1 -1
  18. package/dist/cjs/post-components.cjs.js +2 -2
  19. package/dist/cjs/post-icon.cjs.entry.js +11 -20
  20. package/dist/cjs/post-icon.cjs.entry.js.map +1 -1
  21. package/dist/cjs/post-tab-header.cjs.entry.js +2 -2
  22. package/dist/cjs/post-tab-panel.cjs.entry.js +2 -2
  23. package/dist/cjs/post-tabs.cjs.entry.js +5 -10
  24. package/dist/cjs/post-tabs.cjs.entry.js.map +1 -1
  25. package/dist/cjs/post-tooltip.cjs.entry.js +5097 -0
  26. package/dist/cjs/post-tooltip.cjs.entry.js.map +1 -0
  27. package/dist/collection/collection-manifest.json +3 -1
  28. package/dist/collection/components/post-alert/alert-types.js +2 -0
  29. package/dist/collection/components/post-alert/alert-types.js.map +1 -0
  30. package/dist/collection/components/post-alert/post-alert.css +563 -0
  31. package/dist/collection/components/post-alert/post-alert.js +256 -0
  32. package/dist/collection/components/post-alert/post-alert.js.map +1 -0
  33. package/dist/collection/components/post-collapsible/post-collapsible.css +7 -0
  34. package/dist/collection/components/post-tooltip/post-tooltip.css +194 -0
  35. package/dist/collection/components/post-tooltip/post-tooltip.js +338 -0
  36. package/dist/collection/components/post-tooltip/post-tooltip.js.map +1 -0
  37. package/dist/collection/components/post-tooltip/types.js +2 -0
  38. package/dist/collection/components/post-tooltip/types.js.map +1 -0
  39. package/dist/collection/utils/property-checkers/check-one-of.js.map +1 -1
  40. package/dist/collection/utils/property-checkers/check-pattern.js +5 -0
  41. package/dist/collection/utils/property-checkers/check-pattern.js.map +1 -0
  42. package/dist/collection/utils/property-checkers/index.js +3 -0
  43. package/dist/collection/utils/property-checkers/index.js.map +1 -1
  44. package/dist/components/check-one-of.js +8 -0
  45. package/dist/components/check-one-of.js.map +1 -0
  46. package/dist/components/check-type.js +1 -6
  47. package/dist/components/check-type.js.map +1 -1
  48. package/dist/components/fade.js +9 -0
  49. package/dist/components/fade.js.map +1 -0
  50. package/dist/components/package.js +1 -1
  51. package/dist/components/post-alert.d.ts +11 -0
  52. package/dist/components/post-alert.js +136 -0
  53. package/dist/components/post-alert.js.map +1 -0
  54. package/dist/components/post-collapsible.js +2 -1
  55. package/dist/components/post-collapsible.js.map +1 -1
  56. package/dist/components/post-icon.js +1 -135
  57. package/dist/components/post-icon.js.map +1 -1
  58. package/dist/components/post-icon2.js +146 -0
  59. package/dist/components/post-icon2.js.map +1 -0
  60. package/dist/components/post-tabs.js +1 -6
  61. package/dist/components/post-tabs.js.map +1 -1
  62. package/dist/components/post-tooltip.d.ts +11 -0
  63. package/dist/components/post-tooltip.js +5118 -0
  64. package/dist/components/post-tooltip.js.map +1 -0
  65. package/dist/docs.json +313 -3
  66. package/dist/esm/check-one-of-ded5e15e.js +8 -0
  67. package/dist/esm/check-one-of-ded5e15e.js.map +1 -0
  68. package/dist/esm/{check-type-67411ed3.js → check-type-18ebb4e7.js} +2 -7
  69. package/dist/esm/check-type-18ebb4e7.js.map +1 -0
  70. package/dist/esm/fade-671f1489.js +9 -0
  71. package/dist/esm/fade-671f1489.js.map +1 -0
  72. package/dist/esm/{index-cc0e53f0.js → index-5611074b.js} +107 -5
  73. package/dist/esm/index-5611074b.js.map +1 -0
  74. package/dist/esm/index-7f723686.js +24 -0
  75. package/dist/esm/index-7f723686.js.map +1 -0
  76. package/dist/esm/loader.js +3 -3
  77. package/dist/esm/package-f5cb3167.js +5 -0
  78. package/dist/esm/package-f5cb3167.js.map +1 -0
  79. package/dist/esm/post-alert.entry.js +102 -0
  80. package/dist/esm/post-alert.entry.js.map +1 -0
  81. package/dist/esm/post-collapsible.entry.js +4 -3
  82. package/dist/esm/post-collapsible.entry.js.map +1 -1
  83. package/dist/esm/post-components.js +3 -3
  84. package/dist/esm/post-icon.entry.js +6 -15
  85. package/dist/esm/post-icon.entry.js.map +1 -1
  86. package/dist/esm/post-tab-header.entry.js +2 -2
  87. package/dist/esm/post-tab-panel.entry.js +2 -2
  88. package/dist/esm/post-tabs.entry.js +3 -8
  89. package/dist/esm/post-tabs.entry.js.map +1 -1
  90. package/dist/esm/post-tooltip.entry.js +5093 -0
  91. package/dist/esm/post-tooltip.entry.js.map +1 -0
  92. package/dist/post-components/p-12046db8.entry.js +2 -0
  93. package/dist/post-components/{p-6dad6a8a.entry.js.map → p-12046db8.entry.js.map} +1 -1
  94. package/dist/post-components/p-15fc087f.js +2 -0
  95. package/dist/post-components/p-15fc087f.js.map +1 -0
  96. package/dist/post-components/p-24b07f64.js +2 -0
  97. package/dist/post-components/{p-b95ec099.entry.js → p-29535fea.entry.js} +2 -2
  98. package/dist/post-components/p-296af738.entry.js +2 -0
  99. package/dist/post-components/p-296af738.entry.js.map +1 -0
  100. package/dist/post-components/p-2b6ab354.entry.js +9 -0
  101. package/dist/post-components/p-2b6ab354.entry.js.map +1 -0
  102. package/dist/post-components/p-75a7b352.js +2 -0
  103. package/dist/post-components/p-75a7b352.js.map +1 -0
  104. package/dist/post-components/p-a14ec7bb.entry.js +2 -0
  105. package/dist/post-components/p-a14ec7bb.entry.js.map +1 -0
  106. package/dist/post-components/p-bcc705f1.js +2 -0
  107. package/dist/post-components/p-bcc705f1.js.map +1 -0
  108. package/dist/post-components/{p-1388585d.entry.js → p-c7497ecb.entry.js} +2 -2
  109. package/dist/post-components/p-cc6e4eb8.entry.js +2 -0
  110. package/dist/post-components/p-cc6e4eb8.entry.js.map +1 -0
  111. package/dist/post-components/p-d94db268.js +3 -0
  112. package/dist/post-components/p-d94db268.js.map +1 -0
  113. package/dist/post-components/p-e5306504.js +2 -0
  114. package/dist/post-components/p-e5306504.js.map +1 -0
  115. package/dist/post-components/post-components.esm.js +1 -1
  116. package/dist/post-components/post-components.esm.js.map +1 -1
  117. package/dist/types/components/post-alert/alert-types.d.ts +2 -0
  118. package/dist/types/components/post-alert/post-alert.d.ts +49 -0
  119. package/dist/types/components/post-tooltip/post-tooltip.d.ts +66 -0
  120. package/dist/types/components/post-tooltip/types.d.ts +2 -0
  121. package/dist/types/components.d.ts +115 -0
  122. package/dist/types/utils/property-checkers/check-one-of.d.ts +1 -1
  123. package/dist/types/utils/property-checkers/check-pattern.d.ts +1 -0
  124. package/dist/types/utils/property-checkers/index.d.ts +3 -1
  125. package/package.json +12 -8
  126. package/dist/cjs/check-type-f24cf91d.js.map +0 -1
  127. package/dist/cjs/index-50d7d035.js.map +0 -1
  128. package/dist/cjs/package-e8a6597e.js +0 -7
  129. package/dist/cjs/package-e8a6597e.js.map +0 -1
  130. package/dist/esm/check-type-67411ed3.js.map +0 -1
  131. package/dist/esm/index-cc0e53f0.js.map +0 -1
  132. package/dist/esm/package-b514d0f6.js +0 -5
  133. package/dist/esm/package-b514d0f6.js.map +0 -1
  134. package/dist/post-components/p-58916755.js +0 -2
  135. package/dist/post-components/p-5b3445dc.entry.js +0 -2
  136. package/dist/post-components/p-5b3445dc.entry.js.map +0 -1
  137. package/dist/post-components/p-6341b9b4.js +0 -3
  138. package/dist/post-components/p-6341b9b4.js.map +0 -1
  139. package/dist/post-components/p-6dad6a8a.entry.js +0 -2
  140. package/dist/post-components/p-cc92afb7.entry.js +0 -2
  141. package/dist/post-components/p-cc92afb7.entry.js.map +0 -1
  142. package/dist/post-components/p-f549b3fc.js +0 -2
  143. package/dist/post-components/p-f549b3fc.js.map +0 -1
  144. /package/dist/post-components/{p-58916755.js.map → p-24b07f64.js.map} +0 -0
  145. /package/dist/post-components/{p-b95ec099.entry.js.map → p-29535fea.entry.js.map} +0 -0
  146. /package/dist/post-components/{p-1388585d.entry.js.map → p-c7497ecb.entry.js.map} +0 -0
@@ -0,0 +1,256 @@
1
+ import { h, Host } from '@stencil/core';
2
+ import { version } from '../../../package.json';
3
+ import { fadeOut } from '../../animations';
4
+ import { checkEmptyOrOneOf, checkEmptyOrPattern, checkNonEmpty, checkType } from '../../utils';
5
+ import { ALERT_TYPES } from './alert-types';
6
+ export class PostAlert {
7
+ constructor() {
8
+ this.alertId = crypto.randomUUID();
9
+ this.classes = undefined;
10
+ this.hasActions = undefined;
11
+ this.hasHeading = undefined;
12
+ this.onDismissButtonClick = () => this.dismiss();
13
+ this.dismissible = false;
14
+ this.dismissLabel = undefined;
15
+ this.fixed = false;
16
+ this.icon = undefined;
17
+ this.type = 'primary';
18
+ }
19
+ validateDismissible(isDismissible = this.dismissible) {
20
+ checkType(isDismissible, 'boolean', 'The post-alert "dismissible" prop should be a boolean.');
21
+ setTimeout(() => this.validateDismissLabel());
22
+ }
23
+ validateDismissLabel(dismissLabel = this.dismissLabel) {
24
+ if (this.dismissible) {
25
+ checkNonEmpty(dismissLabel, 'Dismissible post-alert\'s require a "dismiss-label" prop.');
26
+ }
27
+ }
28
+ validateFixed(isFixed = this.fixed) {
29
+ checkType(isFixed, 'boolean', 'The post-alert "fixed" prop should be a boolean.');
30
+ }
31
+ validateIcon(icon = this.icon) {
32
+ checkEmptyOrPattern(icon, /\d{4}|none/, 'The post-alert "icon" prop should be a 4-digits string.');
33
+ }
34
+ validateType(type = this.type) {
35
+ checkEmptyOrOneOf(type, ALERT_TYPES, `The post-alert requires a type form: ${ALERT_TYPES.join(', ')}`);
36
+ }
37
+ connectedCallback() {
38
+ this.validateDismissible();
39
+ this.validateFixed();
40
+ this.validateIcon();
41
+ this.validateType();
42
+ }
43
+ componentWillRender() {
44
+ var _a;
45
+ this.hasHeading = this.host.querySelectorAll('[slot=heading]').length > 0;
46
+ this.hasActions = this.host.querySelectorAll('[slot=actions]').length > 0;
47
+ this.classes = `alert alert-${(_a = this.type) !== null && _a !== void 0 ? _a : 'primary'}`;
48
+ if (this.dismissible)
49
+ this.classes += ' alert-dismissible';
50
+ if (this.hasActions)
51
+ this.classes += ' alert-action';
52
+ if (this.fixed)
53
+ this.classes += ' alert-fixed-bottom';
54
+ if (this.icon === 'none')
55
+ this.classes += ' no-icon';
56
+ }
57
+ /**
58
+ * Triggers alert dismissal programmatically (same as clicking on the close button (×)).
59
+ */
60
+ async dismiss() {
61
+ const dismissal = fadeOut(this.host);
62
+ await dismissal.finished;
63
+ this.host.remove();
64
+ this.dismissed.emit();
65
+ }
66
+ render() {
67
+ const defaultAlertContent = [
68
+ this.icon && this.icon !== 'none' && (h("post-icon", { key: `${this.alertId}-icon`, name: this.icon })),
69
+ this.hasHeading && (h("div", { key: `${this.alertId}-heading`, class: "alert-heading" }, h("slot", { name: "heading" }))),
70
+ h("slot", { key: `${this.alertId}-message` })
71
+ ];
72
+ const actionAlertContent = [
73
+ h("div", { key: `${this.alertId}-content`, class: "alert-content" }, defaultAlertContent),
74
+ h("div", { key: `${this.alertId}-buttons`, class: "alert-buttons" }, h("slot", { name: "actions" })),
75
+ ];
76
+ return (h(Host, { "data-version": version }, h("div", { role: "alert", class: this.classes }, this.dismissible && (h("button", { class: "btn-close", onClick: this.onDismissButtonClick }, h("span", { class: "visually-hidden" }, this.dismissLabel))), this.hasActions
77
+ ? actionAlertContent
78
+ : defaultAlertContent)));
79
+ }
80
+ static get is() { return "post-alert"; }
81
+ static get encapsulation() { return "shadow"; }
82
+ static get originalStyleUrls() {
83
+ return {
84
+ "$": ["post-alert.scss"]
85
+ };
86
+ }
87
+ static get styleUrls() {
88
+ return {
89
+ "$": ["post-alert.css"]
90
+ };
91
+ }
92
+ static get properties() {
93
+ return {
94
+ "dismissible": {
95
+ "type": "boolean",
96
+ "mutable": false,
97
+ "complexType": {
98
+ "original": "boolean",
99
+ "resolved": "boolean",
100
+ "references": {}
101
+ },
102
+ "required": false,
103
+ "optional": false,
104
+ "docs": {
105
+ "tags": [],
106
+ "text": "If `true`, a close button (\u00D7) is displayed and the alert can be dismissed by the user."
107
+ },
108
+ "attribute": "dismissible",
109
+ "reflect": false,
110
+ "defaultValue": "false"
111
+ },
112
+ "dismissLabel": {
113
+ "type": "string",
114
+ "mutable": false,
115
+ "complexType": {
116
+ "original": "string",
117
+ "resolved": "string",
118
+ "references": {}
119
+ },
120
+ "required": false,
121
+ "optional": false,
122
+ "docs": {
123
+ "tags": [],
124
+ "text": "The label to use for the close button of a dismissible alert."
125
+ },
126
+ "attribute": "dismiss-label",
127
+ "reflect": false
128
+ },
129
+ "fixed": {
130
+ "type": "boolean",
131
+ "mutable": false,
132
+ "complexType": {
133
+ "original": "boolean",
134
+ "resolved": "boolean",
135
+ "references": {}
136
+ },
137
+ "required": false,
138
+ "optional": false,
139
+ "docs": {
140
+ "tags": [],
141
+ "text": "If `true`, the alert is positioned at the bottom of the window, from edge to edge."
142
+ },
143
+ "attribute": "fixed",
144
+ "reflect": false,
145
+ "defaultValue": "false"
146
+ },
147
+ "icon": {
148
+ "type": "string",
149
+ "mutable": false,
150
+ "complexType": {
151
+ "original": "string",
152
+ "resolved": "string",
153
+ "references": {}
154
+ },
155
+ "required": false,
156
+ "optional": false,
157
+ "docs": {
158
+ "tags": [],
159
+ "text": "The icon to display in the alert. By default, the icon depends on the alert type.\n\nIf `none`, no icon is displayed."
160
+ },
161
+ "attribute": "icon",
162
+ "reflect": false
163
+ },
164
+ "type": {
165
+ "type": "string",
166
+ "mutable": false,
167
+ "complexType": {
168
+ "original": "AlertType",
169
+ "resolved": "\"danger\" | \"gray\" | \"info\" | \"primary\" | \"success\" | \"warning\"",
170
+ "references": {
171
+ "AlertType": {
172
+ "location": "import",
173
+ "path": "./alert-types"
174
+ }
175
+ }
176
+ },
177
+ "required": false,
178
+ "optional": false,
179
+ "docs": {
180
+ "tags": [],
181
+ "text": "The type of the alert."
182
+ },
183
+ "attribute": "type",
184
+ "reflect": false,
185
+ "defaultValue": "'primary'"
186
+ }
187
+ };
188
+ }
189
+ static get states() {
190
+ return {
191
+ "alertId": {},
192
+ "classes": {},
193
+ "hasActions": {},
194
+ "hasHeading": {},
195
+ "onDismissButtonClick": {}
196
+ };
197
+ }
198
+ static get events() {
199
+ return [{
200
+ "method": "dismissed",
201
+ "name": "dismissed",
202
+ "bubbles": true,
203
+ "cancelable": true,
204
+ "composed": true,
205
+ "docs": {
206
+ "tags": [],
207
+ "text": "An event emitted when the alert element is dismissed, after the transition.\nIt has no payload and only relevant for dismissible alerts."
208
+ },
209
+ "complexType": {
210
+ "original": "void",
211
+ "resolved": "void",
212
+ "references": {}
213
+ }
214
+ }];
215
+ }
216
+ static get methods() {
217
+ return {
218
+ "dismiss": {
219
+ "complexType": {
220
+ "signature": "() => Promise<void>",
221
+ "parameters": [],
222
+ "references": {
223
+ "Promise": {
224
+ "location": "global"
225
+ }
226
+ },
227
+ "return": "Promise<void>"
228
+ },
229
+ "docs": {
230
+ "text": "Triggers alert dismissal programmatically (same as clicking on the close button (\u00D7)).",
231
+ "tags": []
232
+ }
233
+ }
234
+ };
235
+ }
236
+ static get elementRef() { return "host"; }
237
+ static get watchers() {
238
+ return [{
239
+ "propName": "dismissible",
240
+ "methodName": "validateDismissible"
241
+ }, {
242
+ "propName": "dismissLabel",
243
+ "methodName": "validateDismissLabel"
244
+ }, {
245
+ "propName": "fixed",
246
+ "methodName": "validateFixed"
247
+ }, {
248
+ "propName": "icon",
249
+ "methodName": "validateIcon"
250
+ }, {
251
+ "propName": "type",
252
+ "methodName": "validateType"
253
+ }];
254
+ }
255
+ }
256
+ //# sourceMappingURL=post-alert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"post-alert.js","sourceRoot":"","sources":["../../../../src/components/post-alert/post-alert.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC7G,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC/F,OAAO,EAAE,WAAW,EAAa,MAAM,eAAe,CAAC;AAOvD,MAAM,OAAO,SAAS;;mBAGD,MAAM,CAAC,UAAU,EAAE;;;;gCAIN,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE;uBAKZ,KAAK;;iBAuBX,KAAK;;gBAsBJ,SAAS;;EA1C5C,mBAAmB,CAAC,aAAa,GAAG,IAAI,CAAC,WAAW;IAClD,SAAS,CAAC,aAAa,EAAE,SAAS,EAAE,wDAAwD,CAAC,CAAC;IAC9F,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,oBAAoB,EAAE,CAAC,CAAC;EAChD,CAAC;EAQD,oBAAoB,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY;IACnD,IAAI,IAAI,CAAC,WAAW,EAAE;MACpB,aAAa,CAAC,YAAY,EAAE,2DAA2D,CAAC,CAAC;KAC1F;EACH,CAAC;EAQD,aAAa,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK;IAChC,SAAS,CAAC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AAmB,CAEnB,CACD,CACR,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAEF","sourcesContent":["import { Component, Element, Event, EventEmitter, h, Host, Method, Prop, State, Watch } from '@stencil/core';\nimport { version } from '../../../package.json';\nimport { fadeOut } from '../../animations';\nimport { checkEmptyOrOneOf, checkEmptyOrPattern, checkNonEmpty, checkType } from '../../utils';\nimport { ALERT_TYPES, AlertType } from './alert-types';\n\n@Component({\n tag: 'post-alert',\n styleUrl: 'post-alert.scss',\n shadow: true,\n})\nexport class PostAlert {\n @Element() host: HTMLPostAlertElement;\n\n @State() alertId = crypto.randomUUID();\n @State() classes: string;\n @State() hasActions: boolean;\n @State() hasHeading: boolean;\n @State() onDismissButtonClick = () => this.dismiss();\n\n /**\n * If `true`, a close button (×) is displayed and the alert can be dismissed by the user.\n */\n @Prop() readonly dismissible: boolean = false;\n\n @Watch('dismissible')\n validateDismissible(isDismissible = this.dismissible) {\n checkType(isDismissible, 'boolean', 'The post-alert \"dismissible\" prop should be a boolean.');\n setTimeout(() => this.validateDismissLabel());\n }\n\n /**\n * The label to use for the close button of a dismissible alert.\n */\n @Prop() readonly dismissLabel: string;\n\n @Watch('dismissLabel')\n validateDismissLabel(dismissLabel = this.dismissLabel) {\n if (this.dismissible) {\n checkNonEmpty(dismissLabel, 'Dismissible post-alert\\'s require a \"dismiss-label\" prop.');\n }\n }\n\n /**\n * If `true`, the alert is positioned at the bottom of the window, from edge to edge.\n */\n @Prop() readonly fixed: boolean = false;\n\n @Watch('fixed')\n validateFixed(isFixed = this.fixed) {\n checkType(isFixed, 'boolean', 'The post-alert \"fixed\" prop should be a boolean.');\n }\n\n /**\n * The icon to display in the alert. By default, the icon depends on the alert type.\n *\n * If `none`, no icon is displayed.\n */\n @Prop() readonly icon: string;\n\n @Watch('icon')\n validateIcon(icon = this.icon) {\n checkEmptyOrPattern(icon, /\\d{4}|none/, 'The post-alert \"icon\" prop should be a 4-digits string.');\n }\n\n /**\n * The type of the alert.\n */\n @Prop() readonly type: AlertType = 'primary';\n\n @Watch('type')\n validateType(type = this.type) {\n checkEmptyOrOneOf(type, ALERT_TYPES, `The post-alert requires a type form: ${ALERT_TYPES.join(', ')}`);\n }\n\n /**\n * An event emitted when the alert element is dismissed, after the transition.\n * It has no payload and only relevant for dismissible alerts.\n */\n @Event() dismissed: EventEmitter<void>;\n\n connectedCallback() {\n this.validateDismissible();\n this.validateFixed();\n this.validateIcon();\n this.validateType();\n }\n\n componentWillRender() {\n this.hasHeading = this.host.querySelectorAll('[slot=heading]').length > 0;\n this.hasActions = this.host.querySelectorAll('[slot=actions]').length > 0;\n\n this.classes = `alert alert-${this.type ?? 'primary'}`;\n if (this.dismissible) this.classes += ' alert-dismissible';\n if (this.hasActions) this.classes += ' alert-action';\n if (this.fixed) this.classes += ' alert-fixed-bottom';\n if (this.icon === 'none') this.classes += ' no-icon';\n }\n\n /**\n * Triggers alert dismissal programmatically (same as clicking on the close button (×)).\n */\n @Method()\n async dismiss() {\n const dismissal = fadeOut(this.host);\n\n await dismissal.finished;\n\n this.host.remove();\n this.dismissed.emit();\n }\n\n render() {\n const defaultAlertContent = [\n this.icon && this.icon !== 'none' && (\n <post-icon key={`${this.alertId}-icon`} name={this.icon} />\n ),\n this.hasHeading && (\n <div key={`${this.alertId}-heading`} class=\"alert-heading\">\n <slot name=\"heading\"/>\n </div>\n ),\n <slot key={`${this.alertId}-message`}/>\n ];\n\n const actionAlertContent = [\n <div key={`${this.alertId}-content`} class=\"alert-content\">\n {defaultAlertContent}\n </div>,\n <div key={`${this.alertId}-buttons`} class=\"alert-buttons\">\n <slot name=\"actions\"/>\n </div>,\n ];\n\n return (\n <Host data-version={version}>\n <div role=\"alert\" class={this.classes}>\n {this.dismissible && (\n <button class=\"btn-close\" onClick={this.onDismissButtonClick}>\n <span class=\"visually-hidden\">{this.dismissLabel}</span>\n </button>\n )}\n\n {this.hasActions\n ? actionAlertContent\n : defaultAlertContent\n }\n </div>\n </Host>\n );\n }\n\n}\n"]}
@@ -21,6 +21,13 @@
21
21
  * will be available as sass-variables
22
22
  * but should not be used.
23
23
  */
24
+ /**
25
+ * Colors used by the post style guide
26
+ */
27
+ /**
28
+ * Maps. Allow maps to have custom colors from the project
29
+ * by always merging into a default empty map
30
+ */
24
31
  .accordion-item {
25
32
  border-block-start: 2px solid hsl(0, 0%, 90%);
26
33
  }
@@ -0,0 +1,194 @@
1
+ /**
2
+ * Colors used by the post style guide
3
+ */
4
+ /**
5
+ * Maps. Allow maps to have custom colors from the project
6
+ * by always merging into a default empty map
7
+ */
8
+ :host, .bg-yellow {
9
+ --post-bg-opacity: 1;
10
+ background-color: rgba(var(--post-bg-rgb), var(--post-bg-opacity)) !important;
11
+ color: var(--post-contrast-color) !important;
12
+ }
13
+
14
+ .bg-yellow {
15
+ --post-contrast-color: #000;
16
+ --post-contrast-color-inverted: #fff;
17
+ --post-gray-10: hsl(0, 0%, 90%);
18
+ --post-gray-20: hsl(0, 0%, 80%);
19
+ --post-gray-40: hsl(0, 0%, 60%);
20
+ --post-gray-60: hsl(0, 0%, 40%);
21
+ --post-gray-80: hsl(0, 0%, 20%);
22
+ --post-yellow: #fc0;
23
+ --post-light: #faf9f8;
24
+ --post-gray: #f4f3f1;
25
+ --post-dark: hsl(0, 0%, 20%);
26
+ --post-primary: hsl(0, 0%, 20%);
27
+ --post-white: #fff;
28
+ --post-black: #000;
29
+ --post-success: #2c911c;
30
+ --post-info: #cce4ee;
31
+ --post-warning: #f49e00;
32
+ --post-danger: #a51728;
33
+ --post-nightblue: #004976;
34
+ --post-nightblue-bright: #0076a8;
35
+ --post-petrol: #006d68;
36
+ --post-petrol-bright: #00968f;
37
+ --post-coral: #9e2a2f;
38
+ --post-coral-bright: #e03c31;
39
+ --post-olive: #716135;
40
+ --post-olive-bright: #aa9d2e;
41
+ --post-purple: #80276c;
42
+ --post-purple-bright: #c5299b;
43
+ --post-aubergine: #523178;
44
+ --post-aubergine-bright: #7566a0;
45
+ --post-contrast-color-rgb: 0, 0, 0;
46
+ --post-contrast-color-inverted-rgb: 255, 255, 255;
47
+ --post-gray-10-rgb: 230, 230, 230;
48
+ --post-gray-20-rgb: 204, 204, 204;
49
+ --post-gray-40-rgb: 153, 153, 153;
50
+ --post-gray-60-rgb: 102, 102, 102;
51
+ --post-gray-80-rgb: 51, 51, 51;
52
+ --post-yellow-rgb: 255, 204, 0;
53
+ --post-light-rgb: 250, 249, 248;
54
+ --post-gray-rgb: 244, 243, 241;
55
+ --post-dark-rgb: 51, 51, 51;
56
+ --post-primary-rgb: 51, 51, 51;
57
+ --post-white-rgb: 255, 255, 255;
58
+ --post-black-rgb: 0, 0, 0;
59
+ --post-success-rgb: 44, 145, 28;
60
+ --post-info-rgb: 204, 228, 238;
61
+ --post-warning-rgb: 244, 158, 0;
62
+ --post-danger-rgb: 165, 23, 40;
63
+ --post-nightblue-rgb: 0, 73, 118;
64
+ --post-nightblue-bright-rgb: 0, 118, 168;
65
+ --post-petrol-rgb: 0, 109, 104;
66
+ --post-petrol-bright-rgb: 0, 150, 143;
67
+ --post-coral-rgb: 158, 42, 47;
68
+ --post-coral-bright-rgb: 224, 60, 49;
69
+ --post-olive-rgb: 113, 97, 53;
70
+ --post-olive-bright-rgb: 170, 157, 46;
71
+ --post-purple-rgb: 128, 39, 108;
72
+ --post-purple-bright-rgb: 197, 41, 155;
73
+ --post-aubergine-rgb: 82, 49, 120;
74
+ --post-aubergine-bright-rgb: 117, 102, 160;
75
+ }
76
+
77
+ :host {
78
+ --post-contrast-color: #fff;
79
+ --post-contrast-color-inverted: #000;
80
+ --post-dark: #faf9f8;
81
+ --post-light: hsl(0, 0%, 20%);
82
+ --post-gray-80: hsl(0, 0%, 90%);
83
+ --post-gray-60: hsl(0, 0%, 80%);
84
+ --post-gray-40: hsl(0, 0%, 60%);
85
+ --post-gray-20: hsl(0, 0%, 40%);
86
+ --post-gray-10: hsl(0, 0%, 20%);
87
+ --post-contrast-color-rgb: 255, 255, 255;
88
+ --post-contrast-color-inverted-rgb: 0, 0, 0;
89
+ --post-dark-rgb: 250, 249, 248;
90
+ --post-light-rgb: 51, 51, 51;
91
+ --post-gray-80-rgb: 230, 230, 230;
92
+ --post-gray-60-rgb: 204, 204, 204;
93
+ --post-gray-40-rgb: 153, 153, 153;
94
+ --post-gray-20-rgb: 102, 102, 102;
95
+ --post-gray-10-rgb: 51, 51, 51;
96
+ }
97
+
98
+ @layer polyfill {
99
+ [popover] {
100
+ position: fixed;
101
+ z-index: 2147483647;
102
+ inset: 0;
103
+ padding: 0.25em;
104
+ width: fit-content;
105
+ height: fit-content;
106
+ border-width: initial;
107
+ border-color: initial;
108
+ border-image: initial;
109
+ border-style: solid;
110
+ background-color: canvas;
111
+ color: canvastext;
112
+ overflow: auto;
113
+ margin: auto;
114
+ }
115
+ [popover]:not(.\:popover-open) {
116
+ display: none;
117
+ }
118
+ [popover]:is(dialog[open]) {
119
+ display: revert;
120
+ }
121
+ [anchor].\:popover-open {
122
+ inset: auto;
123
+ }
124
+ @supports selector([popover]:open) {
125
+ [popover]:not(.\:popover-open, dialog[open]) {
126
+ display: revert;
127
+ }
128
+ [anchor]:is(:open) {
129
+ inset: auto;
130
+ }
131
+ }
132
+ @supports selector([popover]:popover-open) {
133
+ [popover]:not(.\:popover-open, dialog[open]) {
134
+ display: revert;
135
+ }
136
+ [anchor]:is(:popover-open) {
137
+ inset: auto;
138
+ }
139
+ }
140
+ @supports not (background-color: canvas) {
141
+ [popover] {
142
+ background-color: white;
143
+ color: black;
144
+ }
145
+ }
146
+ @supports (width: -moz-fit-content) {
147
+ [popover] {
148
+ width: -moz-fit-content;
149
+ height: -moz-fit-content;
150
+ }
151
+ }
152
+ @supports not (inset: 0) {
153
+ [popover] {
154
+ top: 0;
155
+ left: 0;
156
+ right: 0;
157
+ bottom: 0;
158
+ }
159
+ }
160
+ }
161
+ :host {
162
+ --post-bg-rgb: 51, 51, 51;
163
+ }
164
+
165
+ div {
166
+ position: absolute;
167
+ z-index: 1070;
168
+ width: max-content;
169
+ max-width: 30ch;
170
+ margin: 0;
171
+ padding: 0.25rem 0.5rem;
172
+ color: inherit;
173
+ background-color: inherit;
174
+ border-color: transparent;
175
+ border-radius: 4px;
176
+ overflow: visible;
177
+ pointer-events: none;
178
+ }
179
+
180
+ .arrow {
181
+ position: absolute;
182
+ width: 0.7071067812rem;
183
+ aspect-ratio: 1/1;
184
+ background-color: inherit;
185
+ rotate: 45deg;
186
+ pointer-events: none;
187
+ z-index: -1;
188
+ border-right: 2px solid transparent;
189
+ border-bottom: 2px solid transparent;
190
+ }
191
+
192
+ .bg-yellow {
193
+ --post-bg-rgb: 255, 204, 0;
194
+ }