@rededor/cura 0.5.2 → 0.5.4
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/dist/assets/icons/iconset-default-list.ts +1 -1
- package/dist/assets/icons/iconset-default-tmp.svg +4 -0
- package/dist/assets/icons/iconset-default.svg +1 -1
- package/dist/cjs/cura-accordion_8.cjs.entry.js +10 -17
- package/dist/cjs/cura-accordion_8.cjs.entry.js.map +1 -1
- package/dist/cjs/cura-alert.cjs.entry.js +67 -0
- package/dist/cjs/cura-alert.cjs.entry.js.map +1 -0
- package/dist/cjs/cura-button-outline.cjs.entry.js +1 -1
- package/dist/cjs/cura-button-select.cjs.entry.js +97 -0
- package/dist/cjs/cura-button-select.cjs.entry.js.map +1 -0
- package/dist/cjs/cura-button-transparent.cjs.entry.js +1 -1
- package/dist/cjs/cura-checkbox.cjs.entry.js +145 -0
- package/dist/cjs/cura-checkbox.cjs.entry.js.map +1 -0
- package/dist/cjs/cura-display.cjs.entry.js +1 -1
- package/dist/cjs/cura-forms.definitions-11be2ebd.js +20 -0
- package/dist/cjs/cura-forms.definitions-11be2ebd.js.map +1 -0
- package/dist/cjs/cura-icon.definitions-b73b0178.js +21 -0
- package/dist/cjs/cura-icon.definitions-b73b0178.js.map +1 -0
- package/dist/cjs/cura-icons-view.cjs.entry.js +13 -6
- package/dist/cjs/cura-icons-view.cjs.entry.js.map +1 -1
- package/dist/cjs/cura-input-text.cjs.entry.js +3907 -0
- package/dist/cjs/cura-input-text.cjs.entry.js.map +1 -0
- package/dist/cjs/cura-label.cjs.entry.js +1 -1
- package/dist/cjs/cura-radio.cjs.entry.js +115 -0
- package/dist/cjs/cura-radio.cjs.entry.js.map +1 -0
- package/dist/cjs/cura-switch.cjs.entry.js +90 -0
- package/dist/cjs/cura-switch.cjs.entry.js.map +1 -0
- package/dist/cjs/cura.cjs.js +2 -2
- package/dist/cjs/{index-404d93e9.js → index-7616f620.js} +35 -1
- package/dist/cjs/index-7616f620.js.map +1 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/assets/icons/iconset-default-list.js +1 -1
- package/dist/collection/assets/icons/iconset-default-list.js.map +1 -1
- package/dist/collection/assets/icons/iconset-default-tmp.svg +4 -0
- package/dist/collection/assets/icons/iconset-default.svg +1 -1
- package/dist/collection/assets-raw/icons/default/swap.svg +3 -0
- package/dist/collection/collection-manifest.json +6 -0
- package/dist/collection/components/buttons/cura-button/cura-button.css +4 -0
- package/dist/collection/components/buttons/cura-button/cura-button.stories.js +2 -2
- package/dist/collection/components/buttons/cura-button/cura-button.stories.js.map +1 -1
- package/dist/collection/components/buttons/cura-button-outline/cura-button-outline.css +4 -0
- package/dist/collection/components/buttons/cura-button-outline/cura-button-outline.stories.js +2 -2
- package/dist/collection/components/buttons/cura-button-outline/cura-button-outline.stories.js.map +1 -1
- package/dist/collection/components/buttons/cura-button-select/cura-button-select.css +139 -0
- package/dist/collection/components/buttons/cura-button-select/cura-button-select.js +263 -0
- package/dist/collection/components/buttons/cura-button-select/cura-button-select.js.map +1 -0
- package/dist/collection/components/buttons/cura-button-transparent/cura-button-transparent.css +4 -0
- package/dist/collection/components/buttons/cura-button-transparent/cura-button-transparent.stories.js +2 -2
- package/dist/collection/components/buttons/cura-button-transparent/cura-button-transparent.stories.js.map +1 -1
- package/dist/collection/components/cura-alert/cura-alert.css +30 -0
- package/dist/collection/components/cura-alert/cura-alert.js +167 -0
- package/dist/collection/components/cura-alert/cura-alert.js.map +1 -0
- package/dist/collection/components/cura-alert/cura-alert.stories.js +95 -0
- package/dist/collection/components/cura-alert/cura-alert.stories.js.map +1 -0
- package/dist/collection/components/cura-icon/cura-icon.definitions.js +15 -0
- package/dist/collection/components/cura-icon/cura-icon.definitions.js.map +1 -0
- package/dist/collection/components/cura-icon/cura-icon.js +9 -16
- package/dist/collection/components/cura-icon/cura-icon.js.map +1 -1
- package/dist/collection/components/cura-icon/cura-icon.stories.js +7 -6
- package/dist/collection/components/cura-icon/cura-icon.stories.js.map +1 -1
- package/dist/collection/components/cura-icons-view/cura-icons-view.css +16 -17
- package/dist/collection/components/cura-icons-view/cura-icons-view.js +10 -3
- package/dist/collection/components/cura-icons-view/cura-icons-view.js.map +1 -1
- package/dist/collection/components/forms/cura-checkbox/cura-checkbox.css +163 -0
- package/dist/collection/components/forms/cura-checkbox/cura-checkbox.js +432 -0
- package/dist/collection/components/forms/cura-checkbox/cura-checkbox.js.map +1 -0
- package/dist/collection/components/forms/cura-checkbox/cura-checkbox.stories.js +196 -0
- package/dist/collection/components/forms/cura-checkbox/cura-checkbox.stories.js.map +1 -0
- package/dist/collection/components/forms/cura-forms.definitions.js +15 -0
- package/dist/collection/components/forms/cura-forms.definitions.js.map +1 -0
- package/dist/collection/components/forms/cura-input-text/cura-input-text.css +326 -0
- package/dist/collection/components/forms/cura-input-text/cura-input-text.js +655 -0
- package/dist/collection/components/forms/cura-input-text/cura-input-text.js.map +1 -0
- package/dist/collection/components/forms/cura-input-text/cura-input-text.stories.js +224 -0
- package/dist/collection/components/forms/cura-input-text/cura-input-text.stories.js.map +1 -0
- package/dist/collection/components/forms/cura-input-text/mask-presets/input-mask-presets.js +46 -0
- package/dist/collection/components/forms/cura-input-text/mask-presets/input-mask-presets.js.map +1 -0
- package/dist/collection/components/forms/cura-radio/cura-radio.css +146 -0
- package/dist/collection/components/forms/cura-radio/cura-radio.js +366 -0
- package/dist/collection/components/forms/cura-radio/cura-radio.js.map +1 -0
- package/dist/collection/components/forms/cura-radio/cura-radio.stories.js +175 -0
- package/dist/collection/components/forms/cura-radio/cura-radio.stories.js.map +1 -0
- package/dist/collection/components/forms/cura-switch/cura-switch.css +100 -0
- package/dist/collection/components/forms/cura-switch/cura-switch.js +267 -0
- package/dist/collection/components/forms/cura-switch/cura-switch.js.map +1 -0
- package/dist/collection/components/forms/cura-switch/cura-switch.stories.js +137 -0
- package/dist/collection/components/forms/cura-switch/cura-switch.stories.js.map +1 -0
- package/dist/components/cura-alert.d.ts +11 -0
- package/dist/components/cura-alert.js +105 -0
- package/dist/components/cura-alert.js.map +1 -0
- package/dist/components/cura-button-select.d.ts +11 -0
- package/dist/components/cura-button-select.js +127 -0
- package/dist/components/cura-button-select.js.map +1 -0
- package/dist/components/cura-checkbox.d.ts +11 -0
- package/dist/components/cura-checkbox.js +193 -0
- package/dist/components/cura-checkbox.js.map +1 -0
- package/dist/components/cura-forms.definitions.js +18 -0
- package/dist/components/cura-forms.definitions.js.map +1 -0
- package/dist/components/cura-heading.js +1 -100
- package/dist/components/cura-heading.js.map +1 -1
- package/dist/components/cura-heading2.js +104 -0
- package/dist/components/cura-heading2.js.map +1 -0
- package/dist/components/cura-icon2.js +24 -17
- package/dist/components/cura-icon2.js.map +1 -1
- package/dist/components/cura-icons-view.js +31 -7
- package/dist/components/cura-icons-view.js.map +1 -1
- package/dist/components/cura-input-text.d.ts +11 -0
- package/dist/components/cura-input-text.js +3961 -0
- package/dist/components/cura-input-text.js.map +1 -0
- package/dist/components/cura-label.js +1 -84
- package/dist/components/cura-label.js.map +1 -1
- package/dist/components/cura-label2.js +88 -0
- package/dist/components/cura-label2.js.map +1 -0
- package/dist/components/cura-paragraph.js +1 -82
- package/dist/components/cura-paragraph.js.map +1 -1
- package/dist/components/cura-paragraph2.js +86 -0
- package/dist/components/cura-paragraph2.js.map +1 -0
- package/dist/components/cura-radio.d.ts +11 -0
- package/dist/components/cura-radio.js +155 -0
- package/dist/components/cura-radio.js.map +1 -0
- package/dist/components/cura-switch.d.ts +11 -0
- package/dist/components/cura-switch.js +120 -0
- package/dist/components/cura-switch.js.map +1 -0
- package/dist/components/index.js +12 -0
- package/dist/components/index.js.map +1 -1
- package/dist/cura/cura.esm.js +1 -1
- package/dist/cura/cura.esm.js.map +1 -1
- package/dist/cura/cura.js +1 -1
- package/dist/cura/p-1228e771.entry.js +2 -0
- package/dist/cura/p-1228e771.entry.js.map +1 -0
- package/dist/cura/p-2d42ccf4.entry.js +2 -0
- package/dist/cura/p-2d42ccf4.entry.js.map +1 -0
- package/dist/cura/p-3688570d.js +2 -0
- package/dist/cura/p-3688570d.js.map +1 -0
- package/dist/cura/p-36a83bc7.system.js +3 -0
- package/dist/cura/p-36a83bc7.system.js.map +1 -0
- package/dist/cura/p-3f3355f3.system.entry.js +2 -0
- package/dist/cura/p-3f3355f3.system.entry.js.map +1 -0
- package/dist/cura/p-3f5de5e2.entry.js +2 -0
- package/dist/cura/p-3f5de5e2.entry.js.map +1 -0
- package/dist/cura/p-4db87e8d.system.entry.js +2 -0
- package/dist/cura/p-4db87e8d.system.entry.js.map +1 -0
- package/dist/cura/p-51e00a16.entry.js +2 -0
- package/dist/cura/p-51e00a16.entry.js.map +1 -0
- package/dist/cura/{p-0c79c54e.entry.js → p-72a9ed55.entry.js} +2 -2
- package/dist/cura/{p-7c8f3c77.system.entry.js → p-75b2e4d1.system.entry.js} +2 -2
- package/dist/cura/{p-03047b3e.entry.js → p-880917c1.entry.js} +2 -2
- package/dist/cura/p-8d959fb2.entry.js +2 -0
- package/dist/cura/p-8d959fb2.entry.js.map +1 -0
- package/dist/cura/{p-d47b9cfe.system.entry.js → p-9471c93e.system.entry.js} +2 -2
- package/dist/cura/p-98014544.entry.js +2 -0
- package/dist/cura/p-98014544.entry.js.map +1 -0
- package/dist/cura/{p-223924fb.system.entry.js → p-98352c92.system.entry.js} +2 -2
- package/dist/cura/p-a32889a4.system.js +2 -0
- package/dist/cura/p-a32889a4.system.js.map +1 -0
- package/dist/cura/p-ab8c9a8f.system.entry.js +2 -0
- package/dist/cura/p-ab8c9a8f.system.entry.js.map +1 -0
- package/dist/cura/{p-91b0f78e.entry.js → p-ad194144.entry.js} +2 -2
- package/dist/cura/p-b0e13882.system.entry.js +2 -0
- package/dist/cura/p-b0e13882.system.entry.js.map +1 -0
- package/dist/cura/p-ba66d7be.js +3 -0
- package/dist/cura/{p-c0c00396.system.js.map → p-ba66d7be.js.map} +1 -1
- package/dist/cura/p-bb3f9d05.entry.js +2 -0
- package/dist/cura/p-bb3f9d05.entry.js.map +1 -0
- package/dist/cura/p-c791725b.js +2 -0
- package/dist/cura/p-c791725b.js.map +1 -0
- package/dist/cura/p-cb4e2a0c.system.entry.js +2 -0
- package/dist/cura/p-cb4e2a0c.system.entry.js.map +1 -0
- package/dist/cura/p-d3f9c888.system.js +2 -0
- package/dist/cura/p-d3f9c888.system.js.map +1 -0
- package/dist/cura/{p-ca054b07.system.entry.js → p-e5e259fd.system.entry.js} +2 -2
- package/dist/cura/{p-49813052.entry.js → p-edeffbfc.entry.js} +2 -2
- package/dist/cura/p-f51705c2.system.entry.js +2 -0
- package/dist/cura/p-f51705c2.system.entry.js.map +1 -0
- package/dist/cura/p-f89f2ecc.system.entry.js +2 -0
- package/dist/cura/p-f89f2ecc.system.entry.js.map +1 -0
- package/dist/cura/p-fc4ba4ce.system.js +2 -0
- package/dist/cura/p-fc4ba4ce.system.js.map +1 -0
- package/dist/cura/p-fef52079.entry.js +2 -0
- package/dist/cura/p-fef52079.entry.js.map +1 -0
- package/dist/cura/p-ffd41520.system.entry.js +2 -0
- package/dist/cura/p-ffd41520.system.entry.js.map +1 -0
- package/dist/esm/cura-accordion_8.entry.js +10 -17
- package/dist/esm/cura-accordion_8.entry.js.map +1 -1
- package/dist/esm/cura-alert.entry.js +63 -0
- package/dist/esm/cura-alert.entry.js.map +1 -0
- package/dist/esm/cura-button-outline.entry.js +1 -1
- package/dist/esm/cura-button-select.entry.js +93 -0
- package/dist/esm/cura-button-select.entry.js.map +1 -0
- package/dist/esm/cura-button-transparent.entry.js +1 -1
- package/dist/esm/cura-checkbox.entry.js +141 -0
- package/dist/esm/cura-checkbox.entry.js.map +1 -0
- package/dist/esm/cura-display.entry.js +1 -1
- package/dist/esm/cura-forms.definitions-0f774253.js +18 -0
- package/dist/esm/cura-forms.definitions-0f774253.js.map +1 -0
- package/dist/esm/cura-icon.definitions-a63d1862.js +18 -0
- package/dist/esm/cura-icon.definitions-a63d1862.js.map +1 -0
- package/dist/esm/cura-icons-view.entry.js +13 -6
- package/dist/esm/cura-icons-view.entry.js.map +1 -1
- package/dist/esm/cura-input-text.entry.js +3903 -0
- package/dist/esm/cura-input-text.entry.js.map +1 -0
- package/dist/esm/cura-label.entry.js +1 -1
- package/dist/esm/cura-radio.entry.js +111 -0
- package/dist/esm/cura-radio.entry.js.map +1 -0
- package/dist/esm/cura-switch.entry.js +86 -0
- package/dist/esm/cura-switch.entry.js.map +1 -0
- package/dist/esm/cura.js +3 -3
- package/dist/esm/{index-d99da69e.js → index-81f1a268.js} +35 -2
- package/dist/{esm-es5/index-d99da69e.js.map → esm/index-81f1a268.js.map} +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm-es5/cura-accordion_8.entry.js +1 -1
- package/dist/esm-es5/cura-accordion_8.entry.js.map +1 -1
- package/dist/esm-es5/cura-alert.entry.js +2 -0
- package/dist/esm-es5/cura-alert.entry.js.map +1 -0
- package/dist/esm-es5/cura-button-outline.entry.js +1 -1
- package/dist/esm-es5/cura-button-select.entry.js +2 -0
- package/dist/esm-es5/cura-button-select.entry.js.map +1 -0
- package/dist/esm-es5/cura-button-transparent.entry.js +1 -1
- package/dist/esm-es5/cura-checkbox.entry.js +2 -0
- package/dist/esm-es5/cura-checkbox.entry.js.map +1 -0
- package/dist/esm-es5/cura-display.entry.js +1 -1
- package/dist/esm-es5/cura-forms.definitions-0f774253.js +2 -0
- package/dist/esm-es5/cura-forms.definitions-0f774253.js.map +1 -0
- package/dist/esm-es5/cura-icon.definitions-a63d1862.js +2 -0
- package/dist/esm-es5/cura-icon.definitions-a63d1862.js.map +1 -0
- package/dist/esm-es5/cura-icons-view.entry.js +1 -1
- package/dist/esm-es5/cura-icons-view.entry.js.map +1 -1
- package/dist/esm-es5/cura-input-text.entry.js +2 -0
- package/dist/esm-es5/cura-input-text.entry.js.map +1 -0
- package/dist/esm-es5/cura-label.entry.js +1 -1
- package/dist/esm-es5/cura-radio.entry.js +2 -0
- package/dist/esm-es5/cura-radio.entry.js.map +1 -0
- package/dist/esm-es5/cura-switch.entry.js +2 -0
- package/dist/esm-es5/cura-switch.entry.js.map +1 -0
- package/dist/esm-es5/cura.js +1 -1
- package/dist/esm-es5/cura.js.map +1 -1
- package/dist/esm-es5/index-81f1a268.js +3 -0
- package/dist/esm-es5/index-81f1a268.js.map +1 -0
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/loader.js.map +1 -1
- package/dist/types/components/buttons/cura-button/cura-button.d.ts +1 -1
- package/dist/types/components/buttons/cura-button-select/cura-button-select.d.ts +51 -0
- package/dist/types/components/cura-alert/cura-alert.d.ts +16 -0
- package/dist/types/components/cura-alert/cura-alert.stories.d.ts +79 -0
- package/dist/types/components/cura-icon/cura-icon.d.ts +0 -42
- package/dist/types/components/cura-icon/cura-icon.definitions.d.ts +47 -0
- package/dist/types/components/cura-icons-view/cura-icons-view.d.ts +2 -1
- package/dist/types/components/forms/cura-checkbox/cura-checkbox.d.ts +100 -0
- package/dist/types/components/forms/cura-checkbox/cura-checkbox.stories.d.ts +199 -0
- package/dist/types/components/forms/cura-forms.definitions.d.ts +14 -0
- package/dist/types/components/forms/cura-input-text/cura-input-text.d.ts +138 -0
- package/dist/types/components/forms/cura-input-text/cura-input-text.stories.d.ts +224 -0
- package/dist/types/components/forms/cura-input-text/mask-presets/input-mask-presets.d.ts +5 -0
- package/dist/types/components/forms/cura-radio/cura-radio.d.ts +81 -0
- package/dist/types/components/forms/cura-radio/cura-radio.stories.d.ts +180 -0
- package/dist/types/components/forms/cura-switch/cura-switch.d.ts +62 -0
- package/dist/types/components/forms/cura-switch/cura-switch.stories.d.ts +135 -0
- package/dist/types/components.d.ts +602 -0
- package/package.json +5 -4
- package/dist/cjs/index-404d93e9.js.map +0 -1
- package/dist/cura/p-46d20db3.js +0 -3
- package/dist/cura/p-46d20db3.js.map +0 -1
- package/dist/cura/p-4bdbcdf0.system.entry.js +0 -2
- package/dist/cura/p-4bdbcdf0.system.entry.js.map +0 -1
- package/dist/cura/p-8b18b5f7.system.js +0 -2
- package/dist/cura/p-8b18b5f7.system.js.map +0 -1
- package/dist/cura/p-a0395f90.entry.js +0 -2
- package/dist/cura/p-a0395f90.entry.js.map +0 -1
- package/dist/cura/p-a7ef255f.entry.js +0 -2
- package/dist/cura/p-a7ef255f.entry.js.map +0 -1
- package/dist/cura/p-c0c00396.system.js +0 -3
- package/dist/cura/p-fc77814b.system.entry.js +0 -2
- package/dist/cura/p-fc77814b.system.entry.js.map +0 -1
- package/dist/esm/index-d99da69e.js.map +0 -1
- package/dist/esm-es5/index-d99da69e.js +0 -3
- /package/dist/cura/{p-0c79c54e.entry.js.map → p-72a9ed55.entry.js.map} +0 -0
- /package/dist/cura/{p-7c8f3c77.system.entry.js.map → p-75b2e4d1.system.entry.js.map} +0 -0
- /package/dist/cura/{p-03047b3e.entry.js.map → p-880917c1.entry.js.map} +0 -0
- /package/dist/cura/{p-d47b9cfe.system.entry.js.map → p-9471c93e.system.entry.js.map} +0 -0
- /package/dist/cura/{p-223924fb.system.entry.js.map → p-98352c92.system.entry.js.map} +0 -0
- /package/dist/cura/{p-91b0f78e.entry.js.map → p-ad194144.entry.js.map} +0 -0
- /package/dist/cura/{p-ca054b07.system.entry.js.map → p-e5e259fd.system.entry.js.map} +0 -0
- /package/dist/cura/{p-49813052.entry.js.map → p-edeffbfc.entry.js.map} +0 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
@charset "UTF-8";
|
|
2
|
+
:host {
|
|
3
|
+
display: block;
|
|
4
|
+
width: fit-content;
|
|
5
|
+
box-sizing: border-box;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.container {
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
flex-direction: row-reverse;
|
|
12
|
+
gap: var(--gap);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.position.container {
|
|
16
|
+
flex-direction: row;
|
|
17
|
+
}
|
|
18
|
+
.position .label {
|
|
19
|
+
text-align: right;
|
|
20
|
+
}
|
|
21
|
+
.position .message {
|
|
22
|
+
text-align: right;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.control {
|
|
26
|
+
width: fit-content;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* Estilos para o controle de switch */
|
|
30
|
+
.track {
|
|
31
|
+
background: var(--neutral-base-black-40);
|
|
32
|
+
border-radius: 16px;
|
|
33
|
+
transition: background-color 0.3s;
|
|
34
|
+
align-items: flex-start;
|
|
35
|
+
flex-shrink: 0;
|
|
36
|
+
box-sizing: border-box;
|
|
37
|
+
width: var(--size-track);
|
|
38
|
+
height: var(--size);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.thumb {
|
|
42
|
+
background-color: var(--neutral-white-purewhite);
|
|
43
|
+
border: 2px solid var(--neutral-medium);
|
|
44
|
+
border-radius: 50%;
|
|
45
|
+
position: absolute;
|
|
46
|
+
transition: transform 0.3s, outline 0.3s;
|
|
47
|
+
display: inline-block;
|
|
48
|
+
cursor: pointer;
|
|
49
|
+
user-select: none;
|
|
50
|
+
box-sizing: border-box;
|
|
51
|
+
width: var(--size);
|
|
52
|
+
height: var(--size);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* Estado "checked" */
|
|
56
|
+
.checked .thumb {
|
|
57
|
+
border-color: var(--color-dark-light);
|
|
58
|
+
background: var(--color-lighter);
|
|
59
|
+
transform: translateX(var(--size));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.checked .thumb:hover {
|
|
63
|
+
background: var(--neutral-white-purewhite) !important;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.checked .track {
|
|
67
|
+
background: var(--color-base-lighter-50);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* Estado "disabled" */
|
|
71
|
+
.disabled .track {
|
|
72
|
+
background: var(--primary-base-neutral-black-20);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.disabled .thumb {
|
|
76
|
+
background: var(--neutral-lighter) !important;
|
|
77
|
+
border-color: var(--primary-dark-neutral-base);
|
|
78
|
+
cursor: not-allowed;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.disabled.checked .track {
|
|
82
|
+
background: var(--primary-base-neutral-black-20);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.disabled .thumb:hover {
|
|
86
|
+
background: var(--neutral-lighter) !important;
|
|
87
|
+
border-color: var(--primary-dark-neutral-base) !important;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/* Estado hover para não disabled e não checked */
|
|
91
|
+
:not(.disabled):not(.checked) .thumb:hover {
|
|
92
|
+
border-color: var(--color-dark-light);
|
|
93
|
+
background: var(--color-lighter);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/* Estado hover para não disabled */
|
|
97
|
+
:not(.disabled) .thumb:focus {
|
|
98
|
+
border-color: var(--info-base) !important;
|
|
99
|
+
z-index: 1;
|
|
100
|
+
}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { h, Host } from '@stencil/core';
|
|
2
|
+
import { formsSizes } from '../cura-forms.definitions';
|
|
3
|
+
export class CuraSwitch {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.sizes = {
|
|
6
|
+
"large": { size: 64 },
|
|
7
|
+
"medium": { size: 48 },
|
|
8
|
+
"small": { size: 40 },
|
|
9
|
+
};
|
|
10
|
+
this.isDarkbackground = () => this.background === 'dark';
|
|
11
|
+
this.toggleSwitch = () => {
|
|
12
|
+
if (this.disabled)
|
|
13
|
+
return null;
|
|
14
|
+
this.checked = !this.checked;
|
|
15
|
+
this.onchange.emit({ checked: this.checked });
|
|
16
|
+
};
|
|
17
|
+
this.checked = false;
|
|
18
|
+
this.disabled = false;
|
|
19
|
+
this.label = '';
|
|
20
|
+
this.ontabindex = 0;
|
|
21
|
+
this.position = 'left';
|
|
22
|
+
this.size = 'medium';
|
|
23
|
+
this.background = 'light';
|
|
24
|
+
this.color = 'accent';
|
|
25
|
+
this.styles = {};
|
|
26
|
+
}
|
|
27
|
+
sizeHandler() {
|
|
28
|
+
this.styles = Object.assign(Object.assign({}, this.styles), { '--size-track': `${this.sizes[this.size].size}px`, '--size': `${formsSizes[this.size].size}px`, '--gap': `${formsSizes[this.size].gap}px` });
|
|
29
|
+
}
|
|
30
|
+
setColors() {
|
|
31
|
+
const colors = [
|
|
32
|
+
{ name: '--info-base', background: 'info-base' },
|
|
33
|
+
{ name: '--neutral-medium', background: 'neutral-medium' },
|
|
34
|
+
{ name: '--color-lighter', background: `${this.color}-lighter` },
|
|
35
|
+
{ name: '--color-base-lighter-50', background: `${this.color}-${this.isDarkbackground() ? 'base' : 'lighter'}`, opacity: 0.5 },
|
|
36
|
+
{ name: '--color-base-light', background: `${this.color}-${this.isDarkbackground() ? 'base' : 'light'}` },
|
|
37
|
+
{ name: '--color-dark-light', background: `${this.color}-${this.isDarkbackground() ? 'dark' : 'light'}` },
|
|
38
|
+
{ name: '--primary-lighter-neutral-dark', background: this.isDarkbackground() ? 'primary-lighter' : 'neutral-dark' },
|
|
39
|
+
{ name: '--primary-base-neutral-medium', background: this.isDarkbackground() ? 'primary-base' : 'neutral-medium' },
|
|
40
|
+
{ name: '--neutral-white-purewhite', background: `neutral-${this.isDarkbackground() ? 'white' : 'purewhite'}` },
|
|
41
|
+
{ name: '--primary-base-neutral-black-20', background: `${this.isDarkbackground() ? 'primary-base' : 'neutral-black'}`, opacity: 0.2 },
|
|
42
|
+
{ name: '--neutral-base-black-40', background: `neutral-${this.isDarkbackground() ? 'base' : 'black'}`, opacity: 0.4 },
|
|
43
|
+
{ name: '--primary-dark-neutral-base', background: `${this.isDarkbackground() ? 'primary-dark' : 'neutral-base'}` },
|
|
44
|
+
{ name: '--neutral-lighter', background: `${this.isDarkbackground() ? 'primary-base' : 'neutral-lighter'}` },
|
|
45
|
+
];
|
|
46
|
+
colors.forEach(color => {
|
|
47
|
+
this.styles[color.name] = window.CuraAPI.theme.colors.getColor(color.background, color === null || color === void 0 ? void 0 : color.opacity);
|
|
48
|
+
});
|
|
49
|
+
this.styles = Object.assign({}, this.styles);
|
|
50
|
+
}
|
|
51
|
+
connectedCallback() {
|
|
52
|
+
this.sizeHandler();
|
|
53
|
+
this.setColors();
|
|
54
|
+
}
|
|
55
|
+
assignColor(colorDark, colorLight) {
|
|
56
|
+
if (this.disabled)
|
|
57
|
+
return this.isDarkbackground() ? 'primary-base' : 'neutral-medium';
|
|
58
|
+
return this.isDarkbackground() ? colorDark : colorLight;
|
|
59
|
+
}
|
|
60
|
+
getClasses() {
|
|
61
|
+
const classes = {};
|
|
62
|
+
classes['container'] = true;
|
|
63
|
+
classes['checked'] = this.checked;
|
|
64
|
+
classes['disabled'] = this.disabled;
|
|
65
|
+
classes['position'] = this.position === 'right';
|
|
66
|
+
return classes;
|
|
67
|
+
}
|
|
68
|
+
render() {
|
|
69
|
+
return (h(Host, null, h("div", { class: this.getClasses(), style: this.styles }, h("div", { class: "info" }, h("cura-label", { class: "label", size: this.size === 'large' ? 'medium' : 'xsmall', lineHeight: "125%", color: this.assignColor('neutral-white', 'neutral-black') }, this.label), h("cura-label", { color: this.assignColor('primary-lighter', 'neutral-dark'), size: "xsmall", class: "message" }, h("slot", null))), h("div", { onClick: this.toggleSwitch, class: "control" }, h("div", { class: `track ${this.size.toLowerCase()}` }, h("div", { class: `thumb ${this.size.toLowerCase()}`, tabIndex: this.ontabindex }))))));
|
|
70
|
+
}
|
|
71
|
+
static get is() { return "cura-switch"; }
|
|
72
|
+
static get encapsulation() { return "shadow"; }
|
|
73
|
+
static get originalStyleUrls() {
|
|
74
|
+
return {
|
|
75
|
+
"$": ["cura-switch.scss"]
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
static get styleUrls() {
|
|
79
|
+
return {
|
|
80
|
+
"$": ["cura-switch.css"]
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
static get properties() {
|
|
84
|
+
return {
|
|
85
|
+
"checked": {
|
|
86
|
+
"type": "boolean",
|
|
87
|
+
"mutable": true,
|
|
88
|
+
"complexType": {
|
|
89
|
+
"original": "boolean",
|
|
90
|
+
"resolved": "boolean",
|
|
91
|
+
"references": {}
|
|
92
|
+
},
|
|
93
|
+
"required": false,
|
|
94
|
+
"optional": false,
|
|
95
|
+
"docs": {
|
|
96
|
+
"tags": [],
|
|
97
|
+
"text": "Indicates whether the switch is checked or not."
|
|
98
|
+
},
|
|
99
|
+
"attribute": "checked",
|
|
100
|
+
"reflect": true,
|
|
101
|
+
"defaultValue": "false"
|
|
102
|
+
},
|
|
103
|
+
"disabled": {
|
|
104
|
+
"type": "boolean",
|
|
105
|
+
"mutable": false,
|
|
106
|
+
"complexType": {
|
|
107
|
+
"original": "boolean",
|
|
108
|
+
"resolved": "boolean",
|
|
109
|
+
"references": {}
|
|
110
|
+
},
|
|
111
|
+
"required": false,
|
|
112
|
+
"optional": false,
|
|
113
|
+
"docs": {
|
|
114
|
+
"tags": [],
|
|
115
|
+
"text": "Indicates whether the switch is disabled or not."
|
|
116
|
+
},
|
|
117
|
+
"attribute": "disabled",
|
|
118
|
+
"reflect": true,
|
|
119
|
+
"defaultValue": "false"
|
|
120
|
+
},
|
|
121
|
+
"label": {
|
|
122
|
+
"type": "string",
|
|
123
|
+
"mutable": false,
|
|
124
|
+
"complexType": {
|
|
125
|
+
"original": "string",
|
|
126
|
+
"resolved": "string",
|
|
127
|
+
"references": {}
|
|
128
|
+
},
|
|
129
|
+
"required": false,
|
|
130
|
+
"optional": false,
|
|
131
|
+
"docs": {
|
|
132
|
+
"tags": [],
|
|
133
|
+
"text": "The label text to display next to the switch."
|
|
134
|
+
},
|
|
135
|
+
"attribute": "label",
|
|
136
|
+
"reflect": true,
|
|
137
|
+
"defaultValue": "''"
|
|
138
|
+
},
|
|
139
|
+
"ontabindex": {
|
|
140
|
+
"type": "number",
|
|
141
|
+
"mutable": false,
|
|
142
|
+
"complexType": {
|
|
143
|
+
"original": "number",
|
|
144
|
+
"resolved": "number",
|
|
145
|
+
"references": {}
|
|
146
|
+
},
|
|
147
|
+
"required": false,
|
|
148
|
+
"optional": false,
|
|
149
|
+
"docs": {
|
|
150
|
+
"tags": [],
|
|
151
|
+
"text": "Tab index for the switch element.\nReflects as an HTML attribute."
|
|
152
|
+
},
|
|
153
|
+
"attribute": "ontabindex",
|
|
154
|
+
"reflect": true,
|
|
155
|
+
"defaultValue": "0"
|
|
156
|
+
},
|
|
157
|
+
"position": {
|
|
158
|
+
"type": "string",
|
|
159
|
+
"mutable": false,
|
|
160
|
+
"complexType": {
|
|
161
|
+
"original": "\"left\" | \"right\"",
|
|
162
|
+
"resolved": "\"left\" | \"right\"",
|
|
163
|
+
"references": {}
|
|
164
|
+
},
|
|
165
|
+
"required": false,
|
|
166
|
+
"optional": false,
|
|
167
|
+
"docs": {
|
|
168
|
+
"tags": [],
|
|
169
|
+
"text": "Position of the label relative to the switch.\nCan be 'left' or 'right'."
|
|
170
|
+
},
|
|
171
|
+
"attribute": "position",
|
|
172
|
+
"reflect": true,
|
|
173
|
+
"defaultValue": "'left'"
|
|
174
|
+
},
|
|
175
|
+
"size": {
|
|
176
|
+
"type": "string",
|
|
177
|
+
"mutable": false,
|
|
178
|
+
"complexType": {
|
|
179
|
+
"original": "'small' | 'medium' | 'large'",
|
|
180
|
+
"resolved": "\"large\" | \"medium\" | \"small\"",
|
|
181
|
+
"references": {}
|
|
182
|
+
},
|
|
183
|
+
"required": false,
|
|
184
|
+
"optional": false,
|
|
185
|
+
"docs": {
|
|
186
|
+
"tags": [],
|
|
187
|
+
"text": "Size of the switch.\nCan be 'small', 'medium', or 'large'."
|
|
188
|
+
},
|
|
189
|
+
"attribute": "size",
|
|
190
|
+
"reflect": true,
|
|
191
|
+
"defaultValue": "'medium'"
|
|
192
|
+
},
|
|
193
|
+
"background": {
|
|
194
|
+
"type": "string",
|
|
195
|
+
"mutable": false,
|
|
196
|
+
"complexType": {
|
|
197
|
+
"original": "'dark' | 'light'",
|
|
198
|
+
"resolved": "\"dark\" | \"light\"",
|
|
199
|
+
"references": {}
|
|
200
|
+
},
|
|
201
|
+
"required": false,
|
|
202
|
+
"optional": false,
|
|
203
|
+
"docs": {
|
|
204
|
+
"tags": [],
|
|
205
|
+
"text": "Background style of the switch.\nCan be 'dark' or 'light'."
|
|
206
|
+
},
|
|
207
|
+
"attribute": "background",
|
|
208
|
+
"reflect": false,
|
|
209
|
+
"defaultValue": "'light'"
|
|
210
|
+
},
|
|
211
|
+
"color": {
|
|
212
|
+
"type": "string",
|
|
213
|
+
"mutable": false,
|
|
214
|
+
"complexType": {
|
|
215
|
+
"original": "string",
|
|
216
|
+
"resolved": "string",
|
|
217
|
+
"references": {}
|
|
218
|
+
},
|
|
219
|
+
"required": false,
|
|
220
|
+
"optional": false,
|
|
221
|
+
"docs": {
|
|
222
|
+
"tags": [],
|
|
223
|
+
"text": "Accent color of the switch."
|
|
224
|
+
},
|
|
225
|
+
"attribute": "color",
|
|
226
|
+
"reflect": false,
|
|
227
|
+
"defaultValue": "'accent'"
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
static get states() {
|
|
232
|
+
return {
|
|
233
|
+
"styles": {}
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
static get events() {
|
|
237
|
+
return [{
|
|
238
|
+
"method": "onchange",
|
|
239
|
+
"name": "onchange",
|
|
240
|
+
"bubbles": true,
|
|
241
|
+
"cancelable": true,
|
|
242
|
+
"composed": true,
|
|
243
|
+
"docs": {
|
|
244
|
+
"tags": [],
|
|
245
|
+
"text": ""
|
|
246
|
+
},
|
|
247
|
+
"complexType": {
|
|
248
|
+
"original": "{ checked: boolean }",
|
|
249
|
+
"resolved": "{ checked: boolean; }",
|
|
250
|
+
"references": {}
|
|
251
|
+
}
|
|
252
|
+
}];
|
|
253
|
+
}
|
|
254
|
+
static get watchers() {
|
|
255
|
+
return [{
|
|
256
|
+
"propName": "size",
|
|
257
|
+
"methodName": "sizeHandler"
|
|
258
|
+
}, {
|
|
259
|
+
"propName": "color",
|
|
260
|
+
"methodName": "setColors"
|
|
261
|
+
}, {
|
|
262
|
+
"propName": "background",
|
|
263
|
+
"methodName": "setColors"
|
|
264
|
+
}];
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
//# sourceMappingURL=cura-switch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cura-switch.js","sourceRoot":"","sources":["../../../../src/components/forms/cura-switch/cura-switch.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAgB,KAAK,EAAE,MAAM,eAAe,CAAC;AAC5F,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAQvD,MAAM,OAAO,UAAU;;IA0CrB,UAAK,GAAG;MACN,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;MACrB,QAAQ,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;MACtB,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;KACtB,CAAC;IAGF,qBAAgB,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,KAAK,MAAM,CAAC;IA2CpD,iBAAY,GAAG,GAAG,EAAE;MAClB,IAAI,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;MAE/B,IAAI,CAAC,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC;MAC7B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;IAC/C,CAAC,CAAC;mBA7FyD,KAAK;oBAInB,KAAK;iBAIT,EAAE;sBAKG,CAAC;oBAKO,MAAM;gBAKE,QAAQ;sBAK/B,OAAO;iBAI9B,QAAQ;kBAEN,EAAE;;EAcpB,WAAW;IACT,IAAI,CAAC,MAAM,mCACN,IAAI,CAAC,MAAM,KACd,cAAc,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,IA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;UAC9C,WAAK,KAAK,EAAE,SAAS,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE;YAC5C,WAAK,KAAK,EAAE,SAAS,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,UAAU,GAAQ,CAC7E,CACF,CACF,CACD,CACR,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Prop, Event, h, Host, Watch, EventEmitter, State } from '@stencil/core';\nimport { formsSizes } from '../cura-forms.definitions';\n\n@Component({\n tag: 'cura-switch',\n styleUrl: 'cura-switch.scss',\n shadow: true,\n})\n\nexport class CuraSwitch {\n /**\n * Indicates whether the switch is checked or not.\n */\n @Prop({ reflect: true, mutable: true }) checked: boolean = false;\n /**\n * Indicates whether the switch is disabled or not.\n */\n @Prop({ reflect: true }) disabled: boolean = false;\n /**\n * The label text to display next to the switch.\n */\n @Prop({ reflect: true }) label: string = '';\n /**\n * Tab index for the switch element.\n * Reflects as an HTML attribute.\n */\n @Prop({ reflect: true }) ontabindex: number = 0;\n /**\n * Position of the label relative to the switch.\n * Can be 'left' or 'right'.\n */\n @Prop({ reflect: true }) position: \"left\" | \"right\" = 'left';\n /**\n * Size of the switch.\n * Can be 'small', 'medium', or 'large'.\n */\n @Prop({ reflect: true }) size: 'small' | 'medium' | 'large' = 'medium';\n /**\n * Background style of the switch.\n * Can be 'dark' or 'light'.\n */\n @Prop() background: 'dark' | 'light' = 'light';\n /**\n * Accent color of the switch.\n */\n @Prop() color = 'accent';\n\n @State() styles = {};\n\n @Event({ eventName: 'onchange', composed: true, cancelable: true, bubbles: true }) onchange: EventEmitter<{ checked: boolean }>;\n\n sizes = {\n \"large\": { size: 64 },\n \"medium\": { size: 48 },\n \"small\": { size: 40 },\n };\n\n\n isDarkbackground = () => this.background === 'dark';\n\n @Watch('size')\n sizeHandler() {\n this.styles = {\n ...this.styles,\n '--size-track': `${this.sizes[this.size].size}px`,\n '--size': `${formsSizes[this.size].size}px`,\n '--gap': `${formsSizes[this.size].gap}px`\n };\n }\n\n @Watch('color')\n @Watch('background')\n setColors() {\n const colors = [\n { name: '--info-base', background: 'info-base' },\n { name: '--neutral-medium', background: 'neutral-medium' },\n { name: '--color-lighter', background: `${this.color}-lighter` },\n { name: '--color-base-lighter-50', background: `${this.color}-${this.isDarkbackground() ? 'base' : 'lighter'}`, opacity: 0.5 },\n { name: '--color-base-light', background: `${this.color}-${this.isDarkbackground() ? 'base' : 'light'}` },\n { name: '--color-dark-light', background: `${this.color}-${this.isDarkbackground() ? 'dark' : 'light'}` },\n { name: '--primary-lighter-neutral-dark', background: this.isDarkbackground() ? 'primary-lighter' : 'neutral-dark' },\n { name: '--primary-base-neutral-medium', background: this.isDarkbackground() ? 'primary-base' : 'neutral-medium' },\n { name: '--neutral-white-purewhite', background: `neutral-${this.isDarkbackground() ? 'white' : 'purewhite'}` },\n { name: '--primary-base-neutral-black-20', background: `${this.isDarkbackground() ? 'primary-base' : 'neutral-black'}`, opacity: 0.2 },\n { name: '--neutral-base-black-40', background: `neutral-${this.isDarkbackground() ? 'base' : 'black'}`, opacity: 0.4 },\n { name: '--primary-dark-neutral-base', background: `${this.isDarkbackground() ? 'primary-dark' : 'neutral-base'}` },\n { name: '--neutral-lighter', background: `${this.isDarkbackground() ? 'primary-base' : 'neutral-lighter'}` },\n ];\n\n colors.forEach(color => {\n this.styles[color.name] = window.CuraAPI.theme.colors.getColor(color.background, color?.opacity);\n });\n this.styles = { ...this.styles };\n\n }\n\n connectedCallback() {\n this.sizeHandler()\n this.setColors();\n }\n\n toggleSwitch = () => {\n if (this.disabled) return null;\n\n this.checked = !this.checked;\n this.onchange.emit({ checked: this.checked })\n };\n\n assignColor(colorDark: string, colorLight: string) {\n if (this.disabled) return this.isDarkbackground() ? 'primary-base' : 'neutral-medium';\n return this.isDarkbackground() ? colorDark : colorLight\n }\n\n getClasses() {\n const classes = {};\n classes['container'] = true;\n classes['checked'] = this.checked;\n classes['disabled'] = this.disabled;\n classes['position'] = this.position === 'right';\n\n return classes;\n }\n\n\n render() {\n return (\n <Host>\n <div class={this.getClasses()} style={this.styles}>\n <div class=\"info\">\n <cura-label class=\"label\"\n size={this.size === 'large' ? 'medium' : 'xsmall'}\n lineHeight=\"125%\"\n color={this.assignColor('neutral-white', 'neutral-black')}>\n {this.label}\n </cura-label>\n <cura-label\n color={this.assignColor('primary-lighter', 'neutral-dark')}\n size=\"xsmall\"\n class=\"message\">\n <slot></slot>\n </cura-label>\n </div>\n\n <div onClick={this.toggleSwitch} class=\"control\">\n <div class={`track ${this.size.toLowerCase()}`}>\n <div class={`thumb ${this.size.toLowerCase()}`} tabIndex={this.ontabindex}></div>\n </div>\n </div>\n </div>\n </Host>\n );\n }\n}\n"]}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s)
|
|
4
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
const renderCuraSwitch = (label, message, args) => {
|
|
14
|
+
const block = `<cura-switch${args.checked ? `
|
|
15
|
+
checked` : ''}${args.size && args.size !== 'medium' ? `
|
|
16
|
+
size="${args.size}"` : ''}${args.disabled ? `
|
|
17
|
+
disabled` : ''}${args.position && args.position !== 'left' ? `
|
|
18
|
+
position="${args.position}"` : ''}${args.ontabindex !== 0 ? `
|
|
19
|
+
ontabindex="${args.ontabindex}"` : ''}${args.background && args.background !== 'light' ? `
|
|
20
|
+
background="${args.background}"` : ''}${args.color && args.color !== 'accent' ? `
|
|
21
|
+
color="${args.color}"` : ''}${label ? `
|
|
22
|
+
label="${label}"` : ''}>${message ? `
|
|
23
|
+
${message}` : ''}
|
|
24
|
+
</cura-switch>
|
|
25
|
+
`;
|
|
26
|
+
return `${block}`;
|
|
27
|
+
};
|
|
28
|
+
export default {
|
|
29
|
+
title: 'Componentes/Forms/Switch',
|
|
30
|
+
tags: ['autodocs'],
|
|
31
|
+
render: (_a) => {
|
|
32
|
+
var { label, message } = _a, args = __rest(_a, ["label", "message"]);
|
|
33
|
+
return renderCuraSwitch(label, message, args);
|
|
34
|
+
},
|
|
35
|
+
argTypes: {
|
|
36
|
+
label: {
|
|
37
|
+
control: 'text',
|
|
38
|
+
description: 'Texto do label do switch.',
|
|
39
|
+
name: 'label',
|
|
40
|
+
table: {
|
|
41
|
+
category: 'Properties',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
message: {
|
|
45
|
+
control: 'text',
|
|
46
|
+
description: 'Texto adicional de ajuda ou mensagem.',
|
|
47
|
+
name: 'Content',
|
|
48
|
+
table: {
|
|
49
|
+
category: 'Slots',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
checked: {
|
|
53
|
+
control: 'boolean',
|
|
54
|
+
description: 'Define se o switch está checado.',
|
|
55
|
+
table: {
|
|
56
|
+
category: 'States',
|
|
57
|
+
defaultValue: { summary: false },
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
disabled: {
|
|
61
|
+
control: 'boolean',
|
|
62
|
+
description: 'Desabilita o switch.',
|
|
63
|
+
table: {
|
|
64
|
+
category: 'States',
|
|
65
|
+
defaultValue: { summary: false },
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
ontabindex: {
|
|
69
|
+
control: 'number',
|
|
70
|
+
description: 'Define o tabIndex do switch.',
|
|
71
|
+
table: {
|
|
72
|
+
category: 'Properties',
|
|
73
|
+
defaultValue: { summary: 0 },
|
|
74
|
+
},
|
|
75
|
+
name: 'ontabindex',
|
|
76
|
+
},
|
|
77
|
+
position: {
|
|
78
|
+
control: { type: 'inline-radio' },
|
|
79
|
+
options: ['left', 'right'],
|
|
80
|
+
description: 'Posição do label em relação ao switch.',
|
|
81
|
+
table: {
|
|
82
|
+
category: 'Properties',
|
|
83
|
+
defaultValue: { summary: 'left' },
|
|
84
|
+
},
|
|
85
|
+
name: 'position',
|
|
86
|
+
},
|
|
87
|
+
size: {
|
|
88
|
+
control: { type: 'inline-radio' },
|
|
89
|
+
options: ['small', 'medium', 'large'],
|
|
90
|
+
description: 'Tamanho do switch.',
|
|
91
|
+
table: {
|
|
92
|
+
category: 'Properties',
|
|
93
|
+
defaultValue: { summary: 'medium' },
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
background: {
|
|
97
|
+
control: { type: 'inline-radio' },
|
|
98
|
+
options: ['dark', 'light'],
|
|
99
|
+
description: 'Background do switch.',
|
|
100
|
+
table: {
|
|
101
|
+
category: 'Properties',
|
|
102
|
+
defaultValue: { summary: 'light' },
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
color: {
|
|
106
|
+
control: { type: 'select' },
|
|
107
|
+
options: ['primary', 'secondary', 'accent', 'info', 'success', 'error', 'warning', 'neutral'],
|
|
108
|
+
description: 'Cor do switch.',
|
|
109
|
+
table: {
|
|
110
|
+
category: 'Properties',
|
|
111
|
+
defaultValue: { summary: 'accent' },
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
onchange: {
|
|
115
|
+
control: 'none',
|
|
116
|
+
description: 'Emite evento via Listener quando o estado do Switch é alterado. `{ checked: boolean }`',
|
|
117
|
+
table: {
|
|
118
|
+
category: 'Event',
|
|
119
|
+
defaultValue: { summary: '' },
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
export const CuraSwitchStory = {
|
|
125
|
+
args: {
|
|
126
|
+
label: 'Switch',
|
|
127
|
+
color: 'accent',
|
|
128
|
+
message: 'Mensagem do switch',
|
|
129
|
+
checked: false,
|
|
130
|
+
size: 'medium',
|
|
131
|
+
disabled: false,
|
|
132
|
+
position: 'left',
|
|
133
|
+
background: 'light',
|
|
134
|
+
ontabindex: 0,
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
//# sourceMappingURL=cura-switch.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cura-switch.stories.js","sourceRoot":"","sources":["../../../../src/components/forms/cura-switch/cura-switch.stories.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;EAChD,MAAM,KAAK,GAAG,eAAe,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;UACpC,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC;UAC9C,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;WACnC,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC;cACjD,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,UAAU,KAAK,CAAC,CAAC,CAAC,CAAC;gBAC9C,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,UAAU,IAAI,I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,OAAO,EAAE,SAAS,EAAE,SAAS,CAAC;MAC7F,WAAW,EAAE,gBAAgB;MAC7B,KAAK,EAAE;QACL,QAAQ,EAAE,YAAY;QACtB,YAAY,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE;OACpC;KACF;IACD,QAAQ,EAAE;MACR,OAAO,EAAE,MAAM;MACf,WAAW,EAAE,wFAAwF;MACrG,KAAK,EAAE;QACL,QAAQ,EAAE,OAAO;QACjB,YAAY,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;OAC9B;KACF;GACF;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG;EAC7B,IAAI,EAAE;IACJ,KAAK,EAAE,QAAQ;IACf,KAAK,EAAE,QAAQ;IACf,OAAO,EAAE,oBAAoB;IAC7B,OAAO,EAAE,KAAK;IACd,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,KAAK;IACf,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE,OAAO;IACnB,UAAU,EAAE,CAAC;GACd;CACF,CAAC","sourcesContent":["const renderCuraSwitch = (label, message, args) => {\n const block = `<cura-switch${args.checked ? `\n checked` : ''}${args.size && args.size !== 'medium' ? `\n size=\"${args.size}\"` : ''}${args.disabled ? `\n disabled` : ''}${args.position && args.position !== 'left' ? `\n position=\"${args.position}\"` : ''}${args.ontabindex !== 0 ? `\n ontabindex=\"${args.ontabindex}\"` : ''}${args.background && args.background !== 'light' ? `\n background=\"${args.background}\"` : ''}${args.color && args.color !== 'accent' ? `\n color=\"${args.color}\"` : ''}${label ? `\n label=\"${label}\"` : ''}>${message ? `\n ${message}` : ''}\n</cura-switch>\n`;\n return `${block}`;\n};\n\nexport default {\n title: 'Componentes/Forms/Switch',\n tags: ['autodocs'],\n render: ({ label, message, ...args }) => {\n return renderCuraSwitch(label, message, args);\n },\n argTypes: {\n label: {\n control: 'text',\n description: 'Texto do label do switch.',\n name: 'label',\n table: {\n category: 'Properties',\n },\n },\n message: {\n control: 'text',\n description: 'Texto adicional de ajuda ou mensagem.',\n name: 'Content',\n table: {\n category: 'Slots',\n },\n },\n checked: {\n control: 'boolean',\n description: 'Define se o switch está checado.',\n table: {\n category: 'States',\n defaultValue: { summary: false },\n },\n },\n disabled: {\n control: 'boolean',\n description: 'Desabilita o switch.',\n table: {\n category: 'States',\n defaultValue: { summary: false },\n },\n },\n ontabindex: {\n control: 'number',\n description: 'Define o tabIndex do switch.',\n table: {\n category: 'Properties',\n defaultValue: { summary: 0 },\n },\n name: 'ontabindex',\n },\n position: {\n control: { type: 'inline-radio' },\n options: ['left', 'right'],\n description: 'Posição do label em relação ao switch.',\n table: {\n category: 'Properties',\n defaultValue: { summary: 'left' },\n },\n name: 'position',\n },\n size: {\n control: { type: 'inline-radio' },\n options: ['small', 'medium', 'large'],\n description: 'Tamanho do switch.',\n table: {\n category: 'Properties',\n defaultValue: { summary: 'medium' },\n },\n },\n background: {\n control: { type: 'inline-radio' },\n options: ['dark', 'light'],\n description: 'Background do switch.',\n table: {\n category: 'Properties',\n defaultValue: { summary: 'light' },\n },\n },\n color: {\n control: { type: 'select' },\n options: ['primary', 'secondary', 'accent', 'info', 'success', 'error', 'warning', 'neutral'],\n description: 'Cor do switch.',\n table: {\n category: 'Properties',\n defaultValue: { summary: 'accent' },\n },\n },\n onchange: {\n control: 'none',\n description: 'Emite evento via Listener quando o estado do Switch é alterado. `{ checked: boolean }`',\n table: {\n category: 'Event',\n defaultValue: { summary: '' },\n },\n },\n },\n};\n\nexport const CuraSwitchStory = {\n args: {\n label: 'Switch',\n color: 'accent',\n message: 'Mensagem do switch',\n checked: false,\n size: 'medium',\n disabled: false,\n position: 'left',\n background: 'light',\n ontabindex: 0,\n },\n};\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface CuraAlert extends Components.CuraAlert, HTMLElement {}
|
|
4
|
+
export const CuraAlert: {
|
|
5
|
+
prototype: CuraAlert;
|
|
6
|
+
new (): CuraAlert;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
|
2
|
+
import { d as defineCustomElement$4 } from './cura-icon2.js';
|
|
3
|
+
import { d as defineCustomElement$3 } from './cura-label2.js';
|
|
4
|
+
import { d as defineCustomElement$2 } from './cura-paragraph2.js';
|
|
5
|
+
|
|
6
|
+
const curaAlertCss = ":host{display:block;-webkit-box-sizing:border-box;box-sizing:border-box}:host .conteiner{display:-ms-flexbox;display:flex;-webkit-box-sizing:border-box;box-sizing:border-box;padding:12px;gap:12px;-ms-flex-negative:0;flex-shrink:0;border:1px solid var(--color-base);border-radius:4px;background-color:var(--color-lighter)}:host .conteiner.floating{-webkit-box-shadow:0px 4px 8px 0px rgba(38, 38, 38, 0.16);box-shadow:0px 4px 8px 0px rgba(38, 38, 38, 0.16)}:host .icon-left{margin-right:5px}:host .icon-right{margin-left:auto;cursor:pointer}:host .text{margin-top:3px}:host .actions{margin-top:5px}";
|
|
7
|
+
|
|
8
|
+
const CuraAlert$1 = /*@__PURE__*/ proxyCustomElement(class CuraAlert extends HTMLElement {
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
this.__registerHost();
|
|
12
|
+
this.__attachShadow();
|
|
13
|
+
this.close = createEvent(this, "close", 7);
|
|
14
|
+
this.handleClose = () => {
|
|
15
|
+
this.close.emit();
|
|
16
|
+
this.host.remove();
|
|
17
|
+
};
|
|
18
|
+
this.type = 'info';
|
|
19
|
+
this.floating = false;
|
|
20
|
+
this.label = undefined;
|
|
21
|
+
this.closeable = true;
|
|
22
|
+
this.styles = {};
|
|
23
|
+
}
|
|
24
|
+
setColors() {
|
|
25
|
+
const colors = [
|
|
26
|
+
{ name: '--color-lighter', theme: `${this.type}-lighter` },
|
|
27
|
+
{ name: '--neutral-black', theme: 'neutral-black' },
|
|
28
|
+
{ name: '--color-light', theme: `${this.type}-light` },
|
|
29
|
+
{ name: '--color-base', theme: `${this.type}-base` },
|
|
30
|
+
];
|
|
31
|
+
colors.forEach(color => {
|
|
32
|
+
this.styles[color.name] = window.CuraAPI.theme.colors.getColor(color.theme);
|
|
33
|
+
});
|
|
34
|
+
this.styles = Object.assign({}, this.styles);
|
|
35
|
+
}
|
|
36
|
+
connectedCallback() {
|
|
37
|
+
this.setColors();
|
|
38
|
+
}
|
|
39
|
+
getClasses() {
|
|
40
|
+
const classes = {};
|
|
41
|
+
classes['conteiner'] = true;
|
|
42
|
+
classes['floating'] = this.floating;
|
|
43
|
+
return classes;
|
|
44
|
+
}
|
|
45
|
+
getNameIcon() {
|
|
46
|
+
const iconMapping = {
|
|
47
|
+
info: 'infoCircle',
|
|
48
|
+
success: 'checkCircle',
|
|
49
|
+
warning: 'alertCircle',
|
|
50
|
+
error: 'alertTriangle',
|
|
51
|
+
};
|
|
52
|
+
return iconMapping[this.type];
|
|
53
|
+
}
|
|
54
|
+
render() {
|
|
55
|
+
return (h(Host, null, h("div", { class: this.getClasses(), style: this.styles }, h("cura-icon", { name: this.getNameIcon(), class: "icon-left", size: 16, color: `${this.type}-dark` }), h("div", { class: "content" }, h("cura-label", { class: "title", size: "small", color: "neutral-darker", weight: "bold" }, this.label), h("cura-paragraph", { class: "text", color: `${this.type}-darker`, size: "xsmall", marginBlock: "0", lineHeight: "133.33%" }, h("slot", null)), h("div", { class: "actions" }, h("slot", { name: "actions" }))), this.closeable ?
|
|
56
|
+
(h("cura-icon", { name: "close", size: 16, color: "error-dark", class: "icon-right", onClick: this.handleClose }))
|
|
57
|
+
: '')));
|
|
58
|
+
}
|
|
59
|
+
get host() { return this; }
|
|
60
|
+
static get watchers() { return {
|
|
61
|
+
"type": ["setColors"]
|
|
62
|
+
}; }
|
|
63
|
+
static get style() { return curaAlertCss; }
|
|
64
|
+
}, [1, "cura-alert", {
|
|
65
|
+
"type": [1],
|
|
66
|
+
"floating": [516],
|
|
67
|
+
"label": [513],
|
|
68
|
+
"closeable": [516],
|
|
69
|
+
"styles": [32]
|
|
70
|
+
}]);
|
|
71
|
+
function defineCustomElement$1() {
|
|
72
|
+
if (typeof customElements === "undefined") {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const components = ["cura-alert", "cura-icon", "cura-label", "cura-paragraph"];
|
|
76
|
+
components.forEach(tagName => { switch (tagName) {
|
|
77
|
+
case "cura-alert":
|
|
78
|
+
if (!customElements.get(tagName)) {
|
|
79
|
+
customElements.define(tagName, CuraAlert$1);
|
|
80
|
+
}
|
|
81
|
+
break;
|
|
82
|
+
case "cura-icon":
|
|
83
|
+
if (!customElements.get(tagName)) {
|
|
84
|
+
defineCustomElement$4();
|
|
85
|
+
}
|
|
86
|
+
break;
|
|
87
|
+
case "cura-label":
|
|
88
|
+
if (!customElements.get(tagName)) {
|
|
89
|
+
defineCustomElement$3();
|
|
90
|
+
}
|
|
91
|
+
break;
|
|
92
|
+
case "cura-paragraph":
|
|
93
|
+
if (!customElements.get(tagName)) {
|
|
94
|
+
defineCustomElement$2();
|
|
95
|
+
}
|
|
96
|
+
break;
|
|
97
|
+
} });
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const CuraAlert = CuraAlert$1;
|
|
101
|
+
const defineCustomElement = defineCustomElement$1;
|
|
102
|
+
|
|
103
|
+
export { CuraAlert, defineCustomElement };
|
|
104
|
+
|
|
105
|
+
//# sourceMappingURL=cura-alert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"cura-alert.js","mappings":";;;;;AAAA,MAAM,YAAY,GAAG,slBAAslB;;MCM9lBA,WAAS;;;;;;IAgDpB,gBAAW,GAAG;MACZ,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;MAClB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;KACpB,CAAC;gBAh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AAE,IAAI,CAAC,MAAM,IAC/C,iBAAW,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,EAAE,KAAK,EAAC,WAAW,EAAC,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,IAAI,OAAO,GAAc,EACzG,WAAK,KAAK,EAAC,SAAS,IAClB,kBAAY,KAAK,EAAC,OAAO,EAAC,IAAI,EAAC,OAAO,EAAC,KAAK,EAAC,gBAAgB,EAAC,MAAM,EAAC,MAAM,IACxE,IAAI,CAAC,KAAK,CACA,EACb,sBAAgB,KAAK,EAAC,MAAM,EAAC,KAAK,EAAE,GAAG,IAAI,CAAC,IAAI,SAAS,EAAE,IAAI,EAAC,QAAQ,EAAC,WAAW,EAAC,GAAG,EAAC,UAAU,EAAC,SAAS,IAC3G,eAAa,CACE,EACjB,WAAK,KAAK,EAAC,SAAS,IAClB,YAAM,IAAI,EAAC,SAAS,GAAQ,CACxB,CACF,EACJ,IAAI,CAAC,SAAS;OACf,iBAAW,IAAI,EAAC,OAAO,EAAC,IAAI,EAAE,EAAE,EAAE,KAAK,EAAC,YAAY,EAAC,KAAK,EAAC,YAAY,EAAC,OAAO,EAAE,IAAI,CAAC,WAAW,GAAc;QAC9G,EAAE,CACA,CACD,EACP;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["CuraAlert"],"sources":["./src/components/cura-alert/cura-alert.scss?tag=cura-alert&encapsulation=shadow","./src/components/cura-alert/cura-alert.tsx"],"sourcesContent":[":host {\n display: block;\n box-sizing: border-box;\n\n .conteiner {\n display: flex;\n box-sizing: border-box;\n padding: 12px;\n gap: 12px;\n flex-shrink: 0;\n border: 1px solid var(--color-base);\n border-radius: 4px;\n background-color: var(--color-lighter);\n &.floating {\n box-shadow: 0px 4px 8px 0px rgba(38, 38, 38, 0.16);\n }\n }\n\n .icon-left {\n margin-right: 5px;\n }\n\n .icon-right {\n margin-left: auto;\n cursor: pointer;\n }\n\n .text {\n margin-top: 3px;\n }\n\n .actions {\n margin-top: 5px;\n }\n}\n","import { Component, Element, Prop, Host, h, State, Watch, Event, EventEmitter } from '@stencil/core';\n@Component({\n tag: 'cura-alert',\n styleUrl: 'cura-alert.scss',\n shadow: true,\n})\nexport class CuraAlert {\n @Element() host: HTMLElement;\n\n @Prop() type: 'info' | 'success' | 'warning' | 'error' = 'info';\n @Prop({ reflect: true }) floating = false;\n @Prop({ reflect: true }) label: string;\n @Prop({reflect: true}) closeable = true;\n @State()\n styles = {};\n\n @Event({ eventName: 'close' }) close: EventEmitter<void>;\n\n @Watch('type')\n setColors() {\n const colors = [\n { name: '--color-lighter', theme: `${this.type}-lighter` },\n { name: '--neutral-black', theme: 'neutral-black' },\n { name: '--color-light', theme: `${this.type}-light` },\n { name: '--color-base', theme: `${this.type}-base` },\n ];\n\n colors.forEach(color => {\n this.styles[color.name] = window.CuraAPI.theme.colors.getColor(color.theme);\n });\n this.styles = {...this.styles};\n }\n\n connectedCallback() {\n this.setColors();\n }\n\n getClasses() {\n const classes = {};\n classes['conteiner'] = true;\n classes['floating'] = this.floating;\n return classes;\n }\n\n getNameIcon() {\n const iconMapping = {\n info: 'infoCircle',\n success: 'checkCircle',\n warning: 'alertCircle',\n error: 'alertTriangle',\n };\n return iconMapping[this.type];\n }\n\n handleClose = () => {\n this.close.emit();\n this.host.remove();\n };\n\n render() {\n return (\n <Host>\n <div class={this.getClasses()} style={this.styles}>\n <cura-icon name={this.getNameIcon()} class=\"icon-left\" size={16} color={`${this.type}-dark`}></cura-icon>\n <div class=\"content\">\n <cura-label class=\"title\" size=\"small\" color=\"neutral-darker\" weight=\"bold\">\n {this.label}\n </cura-label>\n <cura-paragraph class=\"text\" color={`${this.type}-darker`} size=\"xsmall\" marginBlock=\"0\" lineHeight=\"133.33%\">\n <slot></slot>\n </cura-paragraph>\n <div class=\"actions\">\n <slot name=\"actions\"></slot>\n </div>\n </div>\n { this.closeable ?\n (<cura-icon name=\"close\" size={16} color=\"error-dark\" class=\"icon-right\" onClick={this.handleClose}></cura-icon>)\n : '' }\n </div>\n </Host>\n );\n }\n}\n"],"version":3}
|