@usecapsule/core-components 3.0.0 → 3.0.1-dev.1
Sign up to get free protection for your applications and to get access to all the features.
- package/css/capsule-core.css +83 -14
- package/css/capsule-core.css.map +1 -1
- package/dist/capsule/capsule.esm.js +1 -1
- package/dist/capsule/capsule.esm.js.map +1 -1
- package/dist/capsule/index.esm.js +1 -1
- package/dist/capsule/index.esm.js.map +1 -1
- package/dist/capsule/{p-0d0a0037.entry.js → p-127ac658.entry.js} +2 -2
- package/dist/capsule/{p-0d0a0037.entry.js.map → p-127ac658.entry.js.map} +1 -1
- package/dist/capsule/p-39584a7b.entry.js +2 -0
- package/dist/capsule/p-39584a7b.entry.js.map +1 -0
- package/dist/capsule/p-69756614.entry.js +10 -0
- package/dist/capsule/{p-d28b96ba.entry.js.map → p-69756614.entry.js.map} +1 -1
- package/dist/capsule/p-73398222.entry.js +2 -0
- package/dist/capsule/{p-fcead80b.entry.js.map → p-73398222.entry.js.map} +1 -1
- package/dist/capsule/p-8de15b15.entry.js +29 -0
- package/dist/capsule/p-8de15b15.entry.js.map +1 -0
- package/dist/capsule/p-97c33636.js +3 -0
- package/dist/capsule/p-97c33636.js.map +1 -0
- package/dist/capsule/p-f2393be6.js +2 -0
- package/dist/capsule/p-f2393be6.js.map +1 -0
- package/dist/capsule/p-f72482c3.entry.js +2 -0
- package/dist/capsule/{p-ad14a817.entry.js.map → p-f72482c3.entry.js.map} +1 -1
- package/dist/capsule/{p-fa078837.entry.js → p-fd26ce6e.entry.js} +2 -2
- package/dist/capsule/{p-fa078837.entry.js.map → p-fd26ce6e.entry.js.map} +1 -1
- package/dist/cjs/capsule.cjs.js +10 -10
- package/dist/cjs/capsule.cjs.js.map +1 -1
- package/dist/cjs/{constants-0869a780.js → constants-9b1b01bb.js} +3 -3
- package/dist/cjs/{constants-0869a780.js.map → constants-9b1b01bb.js.map} +1 -1
- package/dist/cjs/{cpsl-alert_29.cjs.entry.js → cpsl-alert_33.cjs.entry.js} +608 -95
- package/dist/cjs/cpsl-alert_33.cjs.entry.js.map +1 -0
- package/dist/cjs/cpsl-animation.cjs.entry.js +2 -2
- package/dist/cjs/cpsl-col.cjs.entry.js +2 -2
- package/dist/cjs/cpsl-grid.cjs.entry.js +3 -3
- package/dist/cjs/cpsl-info-box.cjs.entry.js +3 -3
- package/dist/cjs/cpsl-info-box.cjs.entry.js.map +1 -1
- package/dist/cjs/cpsl-modal-v2.cjs.entry.js +55 -0
- package/dist/cjs/cpsl-modal-v2.cjs.entry.js.map +1 -0
- package/dist/cjs/cpsl-row.cjs.entry.js +2 -2
- package/dist/cjs/index-5293d431.js +1414 -0
- package/dist/cjs/index-5293d431.js.map +1 -0
- package/dist/cjs/index.cjs.js +16 -4
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/assets/icons/brush.svg +3 -0
- package/dist/collection/assets/icons/chevron-up.svg +2 -2
- package/dist/collection/assets/icons/close.svg +3 -4
- package/dist/collection/assets/icons/cube.svg +3 -0
- package/dist/collection/assets/icons/file.svg +3 -0
- package/dist/collection/assets/icons/image.svg +3 -0
- package/dist/collection/assets/icons/index.js +10 -1
- package/dist/collection/assets/icons/index.js.map +1 -1
- package/dist/collection/assets/icons/lightning-01.svg +3 -0
- package/dist/collection/assets/icons/lightning.svg +2 -2
- package/dist/collection/assets/icons/menu.svg +3 -0
- package/dist/collection/assets/icons/refresh.svg +3 -0
- package/dist/collection/assets/icons/stars.svg +4 -0
- package/dist/collection/assets/icons/x.svg +3 -0
- package/dist/collection/collection-manifest.json +7 -2
- package/dist/collection/components/cpsl-alert/cpsl-alert.js +2 -2
- package/dist/collection/components/cpsl-alert/cpsl-alert.js.map +1 -1
- package/dist/collection/components/cpsl-animation/cpsl-animation.js +1 -1
- package/dist/collection/components/cpsl-app-bar/cpsl-app-bar.js +20 -4
- package/dist/collection/components/cpsl-app-bar/cpsl-app-bar.js.map +1 -1
- package/dist/collection/components/cpsl-avatar/cpsl-avatar.js +1 -1
- package/dist/collection/components/cpsl-button/cpsl-button.css +113 -17
- package/dist/collection/components/cpsl-button/cpsl-button.js +63 -7
- package/dist/collection/components/cpsl-button/cpsl-button.js.map +1 -1
- package/dist/collection/components/cpsl-button-group/cpsl-button-group.css +1 -0
- package/dist/collection/components/cpsl-button-group/cpsl-button-group.js +1 -1
- package/dist/collection/components/cpsl-card/cpsl-card.css +1 -1
- package/dist/collection/components/cpsl-card/cpsl-card.js +1 -1
- package/dist/collection/components/cpsl-card/cpsl-card.js.map +1 -1
- package/dist/collection/components/cpsl-checkbox/cpsl-checkbox.css +2 -2
- package/dist/collection/components/cpsl-checkbox/cpsl-checkbox.js +1 -1
- package/dist/collection/components/cpsl-code-input/cpsl-code-input.css +1 -1
- package/dist/collection/components/cpsl-code-input/cpsl-code-input.js +2 -2
- package/dist/collection/components/cpsl-code-input/cpsl-code-input.js.map +1 -1
- package/dist/collection/components/cpsl-col/cpsl-col.js +1 -1
- package/dist/collection/components/cpsl-divider/cpsl-divider.css +1 -1
- package/dist/collection/components/cpsl-divider/cpsl-divider.js +1 -1
- package/dist/collection/components/cpsl-drawer/cpsl-drawer.js +84 -11
- package/dist/collection/components/cpsl-drawer/cpsl-drawer.js.map +1 -1
- package/dist/collection/components/cpsl-dropdown/cpsl-dropdown.js +1 -1
- package/dist/collection/components/cpsl-dropdown/cpsl-dropdown.js.map +1 -1
- package/dist/collection/components/cpsl-file-upload/cpsl-file-upload.css +210 -0
- package/dist/collection/components/cpsl-file-upload/cpsl-file-upload.js +406 -0
- package/dist/collection/components/cpsl-file-upload/cpsl-file-upload.js.map +1 -0
- package/dist/collection/components/cpsl-file-upload/test/cpsl-file-upload.e2e.js +29 -0
- package/dist/collection/components/cpsl-file-upload/test/cpsl-file-upload.e2e.js.map +1 -0
- package/dist/collection/components/cpsl-file-upload/test/cpsl-file-upload.spec.js +37 -0
- package/dist/collection/components/cpsl-file-upload/test/cpsl-file-upload.spec.js.map +1 -0
- package/dist/collection/components/cpsl-grid/cpsl-grid.js +2 -2
- package/dist/collection/components/cpsl-icon/cpsl-icon.js +2 -2
- package/dist/collection/components/cpsl-info-box/cpsl-info-box.css +1 -1
- package/dist/collection/components/cpsl-info-box/cpsl-info-box.js +1 -1
- package/dist/collection/components/cpsl-input/cpsl-input.css +7 -6
- package/dist/collection/components/cpsl-input/cpsl-input.js +3 -8
- package/dist/collection/components/cpsl-input/cpsl-input.js.map +1 -1
- package/dist/collection/components/cpsl-modal/cpsl-modal.css +4 -4
- package/dist/collection/components/cpsl-modal/cpsl-modal.js +1 -0
- package/dist/collection/components/cpsl-modal/cpsl-modal.js.map +1 -1
- package/dist/collection/components/cpsl-modal-v2/cpsl-modal-v2.css +91 -0
- package/dist/collection/components/cpsl-modal-v2/cpsl-modal-v2.js +224 -0
- package/dist/collection/components/cpsl-modal-v2/cpsl-modal-v2.js.map +1 -0
- package/dist/collection/components/cpsl-modal-v2/test/cpsl-modal-v2.e2e.js +29 -0
- package/dist/collection/components/cpsl-modal-v2/test/cpsl-modal-v2.e2e.js.map +1 -0
- package/dist/collection/components/cpsl-modal-v2/test/cpsl-modal-v2.spec.js +37 -0
- package/dist/collection/components/cpsl-modal-v2/test/cpsl-modal-v2.spec.js.map +1 -0
- package/dist/collection/components/cpsl-nav-button-group/cpsl-nav-button-group.js +1 -1
- package/dist/collection/components/cpsl-overlay/cpsl-overlay.css +1 -1
- package/dist/collection/components/cpsl-overlay/cpsl-overlay.js +1 -1
- package/dist/collection/components/cpsl-pagination/cpsl-pagination.js +1 -1
- package/dist/collection/components/cpsl-pill/cpsl-pill.css +1 -1
- package/dist/collection/components/cpsl-pill/cpsl-pill.js +1 -1
- package/dist/collection/components/cpsl-popover/cpsl-popover.css +98 -0
- package/dist/collection/components/cpsl-popover/cpsl-popover.js +470 -0
- package/dist/collection/components/cpsl-popover/cpsl-popover.js.map +1 -0
- package/dist/collection/components/cpsl-popover/test/cpsl-popover.e2e.js +29 -0
- package/dist/collection/components/cpsl-popover/test/cpsl-popover.e2e.js.map +1 -0
- package/dist/collection/components/cpsl-popover/test/cpsl-popover.spec.js +37 -0
- package/dist/collection/components/cpsl-popover/test/cpsl-popover.spec.js.map +1 -0
- package/dist/collection/components/cpsl-progress-indicator/cpsl-progress-indicator.css +3 -3
- package/dist/collection/components/cpsl-qr-code/cpsl-qr-code.css +1 -1
- package/dist/collection/components/cpsl-qr-code/cpsl-qr-code.js +1 -1
- package/dist/collection/components/cpsl-radio/cpsl-radio.css +2 -2
- package/dist/collection/components/cpsl-radio/cpsl-radio.js +1 -1
- package/dist/collection/components/cpsl-row/cpsl-row.js +1 -1
- package/dist/collection/components/cpsl-select/cpsl-select.css +227 -0
- package/dist/collection/components/cpsl-select/cpsl-select.js +393 -0
- package/dist/collection/components/cpsl-select/cpsl-select.js.map +1 -0
- package/dist/collection/components/cpsl-select/test/cpsl-select.e2e.js +29 -0
- package/dist/collection/components/cpsl-select/test/cpsl-select.e2e.js.map +1 -0
- package/dist/collection/components/cpsl-select/test/cpsl-select.spec.js +37 -0
- package/dist/collection/components/cpsl-select/test/cpsl-select.spec.js.map +1 -0
- package/dist/collection/components/cpsl-select-item/cpsl-select-item.css +104 -0
- package/dist/collection/components/cpsl-select-item/cpsl-select-item.js +85 -0
- package/dist/collection/components/cpsl-select-item/cpsl-select-item.js.map +1 -0
- package/dist/collection/components/cpsl-select-item/test/cpsl-select-item.e2e.js +29 -0
- package/dist/collection/components/cpsl-select-item/test/cpsl-select-item.e2e.js.map +1 -0
- package/dist/collection/components/cpsl-select-item/test/cpsl-select-item.spec.js +37 -0
- package/dist/collection/components/cpsl-select-item/test/cpsl-select-item.spec.js.map +1 -0
- package/dist/collection/components/cpsl-slide-button/cpsl-slide-button.css +3 -3
- package/dist/collection/components/cpsl-slide-button/cpsl-slide-button.js +3 -3
- package/dist/collection/components/cpsl-spinner/cpsl-spinner.js +2 -2
- package/dist/collection/components/cpsl-switch/cpsl-switch.css +4 -4
- package/dist/collection/components/cpsl-switch/cpsl-switch.js +1 -1
- package/dist/collection/components/cpsl-tab/cpsl-tab.js +1 -1
- package/dist/collection/components/cpsl-table/cpsl-table.css +25 -64
- package/dist/collection/components/cpsl-table/cpsl-table.js +1 -63
- package/dist/collection/components/cpsl-table/cpsl-table.js.map +1 -1
- package/dist/collection/components/cpsl-tabs/cpsl-tabs.css +2 -2
- package/dist/collection/components/cpsl-tabs/cpsl-tabs.js +1 -1
- package/dist/collection/components/cpsl-text/cpsl-text.css +4 -0
- package/dist/collection/components/cpsl-text/cpsl-text.js +5 -4
- package/dist/collection/components/cpsl-text/cpsl-text.js.map +1 -1
- package/dist/collection/components/cpsl-tile-button/cpsl-tile-button.css +1 -1
- package/dist/collection/components/cpsl-tile-button/cpsl-tile-button.js +2 -2
- package/dist/collection/constants.js +2 -2
- package/dist/collection/constants.js.map +1 -1
- package/dist/collection/index.js.map +1 -1
- package/dist/collection/interface.js.map +1 -1
- package/dist/collection/utils/theme/generateBorderRadii.js +4 -0
- package/dist/collection/utils/theme/generateBorderRadii.js.map +1 -1
- package/dist/collection/utils/theme/generatePalette.js +11 -3
- package/dist/collection/utils/theme/generatePalette.js.map +1 -1
- package/dist/esm/capsule.js +11 -11
- package/dist/esm/capsule.js.map +1 -1
- package/dist/esm/{constants-6acf4ea8.js → constants-fce138fa.js} +3 -3
- package/dist/esm/{constants-6acf4ea8.js.map → constants-fce138fa.js.map} +1 -1
- package/dist/esm/{cpsl-alert_29.entry.js → cpsl-alert_33.entry.js} +605 -96
- package/dist/esm/cpsl-alert_33.entry.js.map +1 -0
- package/dist/esm/cpsl-animation.entry.js +2 -2
- package/dist/esm/cpsl-col.entry.js +2 -2
- package/dist/esm/cpsl-grid.entry.js +3 -3
- package/dist/esm/cpsl-info-box.entry.js +3 -3
- package/dist/esm/cpsl-info-box.entry.js.map +1 -1
- package/dist/esm/cpsl-modal-v2.entry.js +51 -0
- package/dist/esm/cpsl-modal-v2.entry.js.map +1 -0
- package/dist/esm/cpsl-row.entry.js +2 -2
- package/dist/esm/index-97ed6ec1.js +1383 -0
- package/dist/esm/index-97ed6ec1.js.map +1 -0
- package/dist/esm/index.js +16 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/loader/cdn.js +1 -3
- package/dist/loader/index.cjs.js +1 -3
- package/dist/loader/index.es2017.js +1 -3
- package/dist/loader/index.js +1 -3
- package/dist/types/assets/icons/index.d.ts +9 -0
- package/dist/types/components/cpsl-app-bar/cpsl-app-bar.d.ts +1 -0
- package/dist/types/components/cpsl-button/cpsl-button.d.ts +4 -1
- package/dist/types/components/cpsl-drawer/cpsl-drawer.d.ts +10 -1
- package/dist/types/components/cpsl-file-upload/cpsl-file-upload.d.ts +34 -0
- package/dist/types/components/cpsl-input/cpsl-input.d.ts +1 -1
- package/dist/types/components/cpsl-modal-v2/cpsl-modal-v2.d.ts +17 -0
- package/dist/types/components/cpsl-popover/cpsl-popover.d.ts +33 -0
- package/dist/types/components/cpsl-select/cpsl-select.d.ts +35 -0
- package/dist/types/components/cpsl-select-item/cpsl-select-item.d.ts +8 -0
- package/dist/types/components/cpsl-table/cpsl-table.d.ts +0 -3
- package/dist/types/components/cpsl-text/cpsl-text.d.ts +1 -1
- package/dist/types/components.d.ts +580 -28
- package/dist/types/constants.d.ts +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/interface.d.ts +44 -0
- package/dist/types/stencil-public-runtime.d.ts +3 -8
- package/package.json +2 -3
- package/dist/capsule/p-4d8e4d86.entry.js +0 -29
- package/dist/capsule/p-4d8e4d86.entry.js.map +0 -1
- package/dist/capsule/p-86e48e61.js +0 -3
- package/dist/capsule/p-86e48e61.js.map +0 -1
- package/dist/capsule/p-ad14a817.entry.js +0 -2
- package/dist/capsule/p-b6b38e73.js +0 -2
- package/dist/capsule/p-b6b38e73.js.map +0 -1
- package/dist/capsule/p-d28b96ba.entry.js +0 -10
- package/dist/capsule/p-fcead80b.entry.js +0 -2
- package/dist/cjs/cpsl-alert_29.cjs.entry.js.map +0 -1
- package/dist/cjs/index-5733071e.js +0 -2020
- package/dist/cjs/index-5733071e.js.map +0 -1
- package/dist/collection/components/cpsl-table/table-interface.js +0 -2
- package/dist/collection/components/cpsl-table/table-interface.js.map +0 -1
- package/dist/esm/cpsl-alert_29.entry.js.map +0 -1
- package/dist/esm/index-8fe9f35e.js +0 -1990
- package/dist/esm/index-8fe9f35e.js.map +0 -1
- package/dist/esm/polyfills/core-js.js +0 -11
- package/dist/esm/polyfills/dom.js +0 -79
- package/dist/esm/polyfills/es5-html-element.js +0 -1
- package/dist/esm/polyfills/index.js +0 -34
- package/dist/esm/polyfills/system.js +0 -6
- package/dist/types/components/cpsl-table/table-interface.d.ts +0 -19
@@ -0,0 +1,227 @@
|
|
1
|
+
/**
|
2
|
+
* Convert a font size to a dynamic font size.
|
3
|
+
* Fonts that participate in Dynamic Type should use
|
4
|
+
* dynamic font sizes.
|
5
|
+
* @param size - The initial font size including the unit (i.e. px or pt)
|
6
|
+
* @param unit (optional) - The unit to convert to. Use this if you want to
|
7
|
+
* convert to a unit other than $baselineUnit.
|
8
|
+
*/
|
9
|
+
/**
|
10
|
+
* Convert a font size to a dynamic font size but impose
|
11
|
+
* a maximum font size.
|
12
|
+
* @param size - The initial font size including the unit (i.e. px or pt)
|
13
|
+
* @param maxScale - The maximum scale of the font (i.e. 2.5 for a maximum 250% scale).
|
14
|
+
* @param unit (optional) - The unit to convert the initial font size to. Use this if you want to
|
15
|
+
* convert to a unit other than $baselineUnit.
|
16
|
+
*/
|
17
|
+
/**
|
18
|
+
* Convert a font size to a dynamic font size but impose
|
19
|
+
* a minimum font size.
|
20
|
+
* @param size - The initial font size including the unit (i.e. px or pt)
|
21
|
+
* @param minScale - The minimum scale of the font (i.e. 0.8 for a minimum 80% scale).
|
22
|
+
* @param unit (optional) - The unit to convert the initial font size to. Use this if you want to
|
23
|
+
* convert to a unit other than $baselineUnit.
|
24
|
+
*/
|
25
|
+
/**
|
26
|
+
* Convert a font size to a dynamic font size but impose
|
27
|
+
* maximum and minimum font sizes.
|
28
|
+
* @param size - The initial font size including the unit (i.e. px or pt)
|
29
|
+
* @param minScale - The minimum scale of the font (i.e. 0.8 for a minimum 80% scale).
|
30
|
+
* @param maxScale - The maximum scale of the font (i.e. 2.5 for a maximum 250% scale).
|
31
|
+
* @param unit (optional) - The unit to convert the initial font size to. Use this if you want to
|
32
|
+
* convert to a unit other than $baselineUnit.
|
33
|
+
*/
|
34
|
+
/**
|
35
|
+
* A heuristic that applies CSS to tablet
|
36
|
+
* viewports.
|
37
|
+
*
|
38
|
+
* Usage:
|
39
|
+
* @include tablet-viewport() {
|
40
|
+
* :host {
|
41
|
+
* background-color: green;
|
42
|
+
* }
|
43
|
+
* }
|
44
|
+
*/
|
45
|
+
/**
|
46
|
+
* A heuristic that applies CSS to mobile
|
47
|
+
* viewports (i.e. phones, not tablets).
|
48
|
+
*
|
49
|
+
* Usage:
|
50
|
+
* @include mobile-viewport() {
|
51
|
+
* :host {
|
52
|
+
* background-color: blue;
|
53
|
+
* }
|
54
|
+
* }
|
55
|
+
*/
|
56
|
+
:host {
|
57
|
+
--container-box-shadow: none;
|
58
|
+
--container-box-shadow-color: var(--cpsl-color-select-border-placeholder);
|
59
|
+
--container-border-color: var(--cpsl-color-select-border-active);
|
60
|
+
--container-border-error-color: var(--cpsl-color-select-border-error);
|
61
|
+
--container-background-color: var(--cpsl-color-select-surface-default);
|
62
|
+
--container-background-color-disabled: var(--cpsl-color-select-surface-disabled);
|
63
|
+
--container-border-width: 1px;
|
64
|
+
--container-border-radius: var(--cpsl-border-radius-select);
|
65
|
+
--container-padding-top: 0px;
|
66
|
+
--container-padding-bottom: 0px;
|
67
|
+
--container-padding-end: 12px;
|
68
|
+
--container-padding-start: 12px;
|
69
|
+
--container-height: 48px;
|
70
|
+
--container-gap: 8px;
|
71
|
+
--dropdown-margin-top: 4px;
|
72
|
+
--dropdown-border-width: 1px;
|
73
|
+
--dropdown-border-radius: var(--cpsl-border-radius-select);
|
74
|
+
--dropdown-border-color: var(--cpsl-color-select-dropdown-border);
|
75
|
+
--optional-label-color: var(--cpsl-color-text-secondary);
|
76
|
+
--label-color: var(--cpsl-color-text-primary);
|
77
|
+
--label-font-size: var(--cpsl-font-size-body-s);
|
78
|
+
--label-margin-bottom: 0px;
|
79
|
+
--helper-text-color: var(--cpsl-color-text-secondary);
|
80
|
+
--helper-text-error-color: var(--cpsl-color-text-error);
|
81
|
+
--helper-text-icon-color: var(--cpsl-color-text-secondary);
|
82
|
+
--helper-text-icon-error-color: var(--cpsl-color-text-error);
|
83
|
+
--helper-text-icon-size: 16px;
|
84
|
+
--helper-text-font-size: var(--cpsl-font-size-body-xs);
|
85
|
+
--helper-text-margin-top: 0px;
|
86
|
+
display: flex;
|
87
|
+
flex-direction: column;
|
88
|
+
gap: 4px;
|
89
|
+
font-family: var(--cpsl-font-family, inherit);
|
90
|
+
}
|
91
|
+
|
92
|
+
input {
|
93
|
+
box-sizing: border-box;
|
94
|
+
position: absolute;
|
95
|
+
width: 100%;
|
96
|
+
height: 100%;
|
97
|
+
margin: 0px;
|
98
|
+
opacity: 0;
|
99
|
+
top: 0;
|
100
|
+
left: 0;
|
101
|
+
cursor: pointer;
|
102
|
+
}
|
103
|
+
input.disabled {
|
104
|
+
cursor: default;
|
105
|
+
}
|
106
|
+
|
107
|
+
:host(:not(.has-value)) {
|
108
|
+
--container-border-color: var(--cpsl-color-select-border-placeholder);
|
109
|
+
--select-color: var(--cpsl-color-text-secondary);
|
110
|
+
}
|
111
|
+
|
112
|
+
:host(.disabled) {
|
113
|
+
--container-background-color: var(--container-background-color-disabled);
|
114
|
+
--select-background-color: var(--select-background-color-disabled);
|
115
|
+
--select-color: var(--cpsl-color-text-disabled);
|
116
|
+
}
|
117
|
+
|
118
|
+
:host(.focused) {
|
119
|
+
--container-box-shadow: 0px 0px 0px 2px var(--container-box-shadow-color);
|
120
|
+
--container-border-color: var(--cpsl-color-select-border-active);
|
121
|
+
--container-background-color: var(--cpsl-color-select-surface-default);
|
122
|
+
}
|
123
|
+
|
124
|
+
.select-container {
|
125
|
+
-webkit-padding-start: var(--container-padding-start);
|
126
|
+
padding-inline-start: var(--container-padding-start);
|
127
|
+
-webkit-padding-end: var(--container-padding-end);
|
128
|
+
padding-inline-end: var(--container-padding-end);
|
129
|
+
padding-top: var(--container-padding-top);
|
130
|
+
padding-bottom: var(--container-padding-bottom);
|
131
|
+
position: relative;
|
132
|
+
display: flex;
|
133
|
+
align-items: center;
|
134
|
+
justify-content: space-between;
|
135
|
+
gap: 8px;
|
136
|
+
box-sizing: border-box;
|
137
|
+
height: var(--container-height);
|
138
|
+
gap: var(--container-gap);
|
139
|
+
border-style: solid;
|
140
|
+
border-width: var(--container-border-width);
|
141
|
+
border-color: var(--container-border-color);
|
142
|
+
border-radius: var(--container-border-radius);
|
143
|
+
background: var(--container-background-color);
|
144
|
+
box-shadow: var(--container-box-shadow);
|
145
|
+
}
|
146
|
+
|
147
|
+
.error-container {
|
148
|
+
border-color: var(--container-border-error-color);
|
149
|
+
}
|
150
|
+
|
151
|
+
.label {
|
152
|
+
display: inline-block;
|
153
|
+
color: var(--label-color);
|
154
|
+
font-size: var(--label-font-size);
|
155
|
+
font-weight: 500;
|
156
|
+
margin-bottom: var(--label-margin-bottom);
|
157
|
+
}
|
158
|
+
|
159
|
+
.optional-label {
|
160
|
+
display: inline-block;
|
161
|
+
color: var(--optional-label-color);
|
162
|
+
font-size: var(--label-font-size);
|
163
|
+
font-weight: 500;
|
164
|
+
}
|
165
|
+
|
166
|
+
.helper-text-container {
|
167
|
+
display: flex;
|
168
|
+
align-items: center;
|
169
|
+
gap: 4px;
|
170
|
+
color: var(--helper-text-color);
|
171
|
+
font-size: var(--helper-text-font-size);
|
172
|
+
font-weight: 500;
|
173
|
+
margin-top: var(--helper-text-margin-top);
|
174
|
+
}
|
175
|
+
.helper-text-container cpsl-icon {
|
176
|
+
--height: var(--helper-text-icon-size);
|
177
|
+
--width: var(--helper-text-icon-size);
|
178
|
+
--icon-color: var(--helper-text-icon-color);
|
179
|
+
}
|
180
|
+
|
181
|
+
.error-text {
|
182
|
+
color: var(--helper-text-error-color);
|
183
|
+
}
|
184
|
+
.error-text cpsl-icon {
|
185
|
+
--icon-color: var(--helper-text-icon-error-color);
|
186
|
+
}
|
187
|
+
|
188
|
+
.selected-container-content {
|
189
|
+
flex: 1;
|
190
|
+
}
|
191
|
+
|
192
|
+
.chevron {
|
193
|
+
transition: transform 0.3s ease;
|
194
|
+
transform: rotate(180deg);
|
195
|
+
--icon-color: var(--cpsl-color-text-disabled);
|
196
|
+
}
|
197
|
+
.chevron.open {
|
198
|
+
transform: rotate(0deg);
|
199
|
+
--icon-color: var(--cpsl-color-text-primary);
|
200
|
+
}
|
201
|
+
.chevron.has-value {
|
202
|
+
--icon-color: var(--cpsl-color-text-primary);
|
203
|
+
}
|
204
|
+
|
205
|
+
.selected-text {
|
206
|
+
color: var(--cpsl-color-text-primary);
|
207
|
+
}
|
208
|
+
.selected-text.placeholder {
|
209
|
+
color: var(--cpsl-color-text-disabled);
|
210
|
+
}
|
211
|
+
|
212
|
+
.dropdown {
|
213
|
+
margin-top: var(--dropdown-margin-top);
|
214
|
+
border-style: solid;
|
215
|
+
border-width: var(--dropdown-border-width);
|
216
|
+
border-color: var(--dropdown-border-color);
|
217
|
+
border-radius: var(--dropdown-border-radius);
|
218
|
+
overflow: hidden;
|
219
|
+
}
|
220
|
+
.dropdown ::slotted(*:last-child) {
|
221
|
+
--container-border-width: 0px;
|
222
|
+
}
|
223
|
+
|
224
|
+
.dropdown-inner {
|
225
|
+
overflow: auto;
|
226
|
+
scrollbar-width: thin;
|
227
|
+
}
|
@@ -0,0 +1,393 @@
|
|
1
|
+
import { Host, h } from "@stencil/core";
|
2
|
+
export class CpslSelect {
|
3
|
+
constructor() {
|
4
|
+
this.inputId = `cpsl-select-${inputIds++}`;
|
5
|
+
this.onBlur = (ev) => {
|
6
|
+
this.hasFocus = false;
|
7
|
+
this.cpslBlur.emit(ev);
|
8
|
+
};
|
9
|
+
this.onFocus = (ev) => {
|
10
|
+
this.hasFocus = true;
|
11
|
+
this.cpslFocus.emit(ev);
|
12
|
+
};
|
13
|
+
this.handleEnterPress = (ev) => {
|
14
|
+
if (ev.key === 'Enter') {
|
15
|
+
ev.preventDefault();
|
16
|
+
this.el.dispatchEvent(new MouseEvent('mousedown'));
|
17
|
+
}
|
18
|
+
};
|
19
|
+
this.selectItem = () => {
|
20
|
+
const items = Array.from(this.el.querySelectorAll('cpsl-select-item'));
|
21
|
+
items.forEach(item => {
|
22
|
+
if (item.value === this.selectedValue) {
|
23
|
+
item.setAttribute('selected', 'true');
|
24
|
+
this.hasSelectedItem = true;
|
25
|
+
}
|
26
|
+
else {
|
27
|
+
item.setAttribute('selected', 'false');
|
28
|
+
}
|
29
|
+
});
|
30
|
+
if (!Boolean(this.selectedValue)) {
|
31
|
+
this.hasSelectedItem = false;
|
32
|
+
}
|
33
|
+
};
|
34
|
+
this.hasFocus = false;
|
35
|
+
this.popoverOpen = false;
|
36
|
+
this.hasSelectedItem = false;
|
37
|
+
this.disabled = false;
|
38
|
+
this.dropdownMaxHeight = undefined;
|
39
|
+
this.errorText = undefined;
|
40
|
+
this.formatValue = undefined;
|
41
|
+
this.helperText = undefined;
|
42
|
+
this.id = `${this.inputId}-trigger`;
|
43
|
+
this.label = undefined;
|
44
|
+
this.placeholder = undefined;
|
45
|
+
this.required = false;
|
46
|
+
this.selectedValue = undefined;
|
47
|
+
this.showFormattedSelectedItem = undefined;
|
48
|
+
this.showOptionalLabel = false;
|
49
|
+
}
|
50
|
+
onValueChange() {
|
51
|
+
this.popoverEl.closePopover();
|
52
|
+
}
|
53
|
+
handleValueChange() {
|
54
|
+
this.selectItem();
|
55
|
+
}
|
56
|
+
selectItemClickHandler(event) {
|
57
|
+
this.cpslSelectValueChange.emit(event.detail);
|
58
|
+
}
|
59
|
+
onPopoverOpen() {
|
60
|
+
this.popoverOpen = true;
|
61
|
+
}
|
62
|
+
onPopoverClose() {
|
63
|
+
this.popoverOpen = false;
|
64
|
+
}
|
65
|
+
componentDidLoad() {
|
66
|
+
this.popoverEl = this.el.shadowRoot.querySelector(`cpsl-popover`);
|
67
|
+
this.selectItem();
|
68
|
+
}
|
69
|
+
render() {
|
70
|
+
var _a, _b, _c, _d;
|
71
|
+
return (h(Host, { key: '7ad387377c9e3a14fd9e9ed39627d65df33a255a', id: this.id, class: { 'disabled': this.disabled, 'focused': this.hasFocus, 'has-value': Boolean(this.selectedValue) } }, this.label && (h("label", { key: 'a04cdb05dac058b57301b4052ca8e49992319048', class: "label", htmlFor: this.inputId }, this.label, this.required ? '*' : ' ', !this.required && this.showOptionalLabel ? h("span", { class: "optional-label" }, "(optional)") : '')), h("div", { key: '04baa7155a989015a3a57318d653eaad6fb8e0e9', class: { 'select-container': true, 'error-container': Boolean(this.errorText) } }, this.hasSelectedItem && this.showFormattedSelectedItem && h("slot", { key: '447dcce739659ff4139197ffaf7d5d9f0775de89', name: "selected-item" }), h("div", { key: '46cbfcc9afee9132e7d254bdd064296970f28f47', class: "selected-container-content", id: "selected-container-content" }, (!this.hasSelectedItem || !this.showFormattedSelectedItem) && (h("cpsl-text", { key: 'fc77344729bcef824db7f32325293bf031c1fb74', class: { 'selected-text': true, 'placeholder': !Boolean(this.selectedValue) } }, !Boolean(this.selectedValue) ? (_a = this.placeholder) !== null && _a !== void 0 ? _a : 'Select' : (_c = (_b = this.formatValue) === null || _b === void 0 ? void 0 : _b.call(this, this.selectedValue)) !== null && _c !== void 0 ? _c : this.selectedValue))), h("cpsl-icon", { key: '44d40d1b80105809f446ed169467a8c583b8afd5', class: { 'chevron': true, 'open': this.popoverOpen, 'has-value': Boolean(this.selectedValue) }, icon: "chevronUp" }), h("input", { key: 'cbeb30eb519dd7db84da6f5e5366ea924ec6c715', id: this.inputId, disabled: this.disabled, class: { disabled: this.disabled }, value: this.selectedValue, onFocus: this.onFocus, onBlur: this.onBlur, onKeyPress: this.handleEnterPress })), (this.errorText || this.helperText) && (h("div", { key: '9f3475b40c6ab3872af65d8aecc4e653add2ba2d', class: { 'helper-text-container': true, 'error-text': Boolean(this.errorText) } }, h("span", { key: '04dcc76a6c5b93969b16ac2b400fe86c96189a9b' }, (_d = this.errorText) !== null && _d !== void 0 ? _d : this.helperText))), h("cpsl-popover", { key: '7909618009a8080bc570b761e6800779eb482a61', autoWidth: false, trigger: this.id, preventBlur: this.hasFocus }, h("div", { key: '1fe3de1d21302f76669dd8f6730373d47de0fb27', class: "dropdown" }, h("div", { key: 'c888c8bc3da0a85b31b37dc44bfc826c6ac635f8', class: "dropdown-inner", style: { maxHeight: `${this.dropdownMaxHeight}px` } }, h("slot", { key: '69cd9e6df64d26a5ec68912bf52042cb8eebda1f', name: "items" }))))));
|
72
|
+
}
|
73
|
+
static get is() { return "cpsl-select"; }
|
74
|
+
static get encapsulation() { return "shadow"; }
|
75
|
+
static get originalStyleUrls() {
|
76
|
+
return {
|
77
|
+
"$": ["cpsl-select.scss"]
|
78
|
+
};
|
79
|
+
}
|
80
|
+
static get styleUrls() {
|
81
|
+
return {
|
82
|
+
"$": ["cpsl-select.css"]
|
83
|
+
};
|
84
|
+
}
|
85
|
+
static get properties() {
|
86
|
+
return {
|
87
|
+
"disabled": {
|
88
|
+
"type": "boolean",
|
89
|
+
"mutable": false,
|
90
|
+
"complexType": {
|
91
|
+
"original": "boolean",
|
92
|
+
"resolved": "boolean",
|
93
|
+
"references": {}
|
94
|
+
},
|
95
|
+
"required": false,
|
96
|
+
"optional": false,
|
97
|
+
"docs": {
|
98
|
+
"tags": [],
|
99
|
+
"text": "If `true`, the user cannot interact with the input."
|
100
|
+
},
|
101
|
+
"attribute": "disabled",
|
102
|
+
"reflect": false,
|
103
|
+
"defaultValue": "false"
|
104
|
+
},
|
105
|
+
"dropdownMaxHeight": {
|
106
|
+
"type": "number",
|
107
|
+
"mutable": false,
|
108
|
+
"complexType": {
|
109
|
+
"original": "number",
|
110
|
+
"resolved": "number",
|
111
|
+
"references": {}
|
112
|
+
},
|
113
|
+
"required": false,
|
114
|
+
"optional": true,
|
115
|
+
"docs": {
|
116
|
+
"tags": [],
|
117
|
+
"text": "Set the max height of the dropdown."
|
118
|
+
},
|
119
|
+
"attribute": "dropdown-max-height",
|
120
|
+
"reflect": false
|
121
|
+
},
|
122
|
+
"errorText": {
|
123
|
+
"type": "string",
|
124
|
+
"mutable": false,
|
125
|
+
"complexType": {
|
126
|
+
"original": "string",
|
127
|
+
"resolved": "string",
|
128
|
+
"references": {}
|
129
|
+
},
|
130
|
+
"required": false,
|
131
|
+
"optional": true,
|
132
|
+
"docs": {
|
133
|
+
"tags": [],
|
134
|
+
"text": "Error text to show below the input. If this is provided the input will enter an error state."
|
135
|
+
},
|
136
|
+
"attribute": "error-text",
|
137
|
+
"reflect": false
|
138
|
+
},
|
139
|
+
"formatValue": {
|
140
|
+
"type": "unknown",
|
141
|
+
"mutable": false,
|
142
|
+
"complexType": {
|
143
|
+
"original": "(value: string) => string",
|
144
|
+
"resolved": "(value: string) => string",
|
145
|
+
"references": {}
|
146
|
+
},
|
147
|
+
"required": false,
|
148
|
+
"optional": true,
|
149
|
+
"docs": {
|
150
|
+
"tags": [],
|
151
|
+
"text": "Format value for display when selected."
|
152
|
+
}
|
153
|
+
},
|
154
|
+
"helperText": {
|
155
|
+
"type": "string",
|
156
|
+
"mutable": false,
|
157
|
+
"complexType": {
|
158
|
+
"original": "string",
|
159
|
+
"resolved": "string",
|
160
|
+
"references": {}
|
161
|
+
},
|
162
|
+
"required": false,
|
163
|
+
"optional": true,
|
164
|
+
"docs": {
|
165
|
+
"tags": [],
|
166
|
+
"text": "Helper text to show below the input. If `\"errorText\"` is provided that will take precedence."
|
167
|
+
},
|
168
|
+
"attribute": "helper-text",
|
169
|
+
"reflect": false
|
170
|
+
},
|
171
|
+
"id": {
|
172
|
+
"type": "string",
|
173
|
+
"mutable": false,
|
174
|
+
"complexType": {
|
175
|
+
"original": "string",
|
176
|
+
"resolved": "string",
|
177
|
+
"references": {}
|
178
|
+
},
|
179
|
+
"required": false,
|
180
|
+
"optional": false,
|
181
|
+
"docs": {
|
182
|
+
"tags": [],
|
183
|
+
"text": "ID of the element, must be unique for the popover trigger."
|
184
|
+
},
|
185
|
+
"attribute": "id",
|
186
|
+
"reflect": false,
|
187
|
+
"defaultValue": "`${this.inputId}-trigger`"
|
188
|
+
},
|
189
|
+
"label": {
|
190
|
+
"type": "string",
|
191
|
+
"mutable": false,
|
192
|
+
"complexType": {
|
193
|
+
"original": "string",
|
194
|
+
"resolved": "string",
|
195
|
+
"references": {}
|
196
|
+
},
|
197
|
+
"required": false,
|
198
|
+
"optional": true,
|
199
|
+
"docs": {
|
200
|
+
"tags": [],
|
201
|
+
"text": "The label for the input."
|
202
|
+
},
|
203
|
+
"attribute": "label",
|
204
|
+
"reflect": false
|
205
|
+
},
|
206
|
+
"placeholder": {
|
207
|
+
"type": "string",
|
208
|
+
"mutable": false,
|
209
|
+
"complexType": {
|
210
|
+
"original": "string",
|
211
|
+
"resolved": "string",
|
212
|
+
"references": {}
|
213
|
+
},
|
214
|
+
"required": false,
|
215
|
+
"optional": true,
|
216
|
+
"docs": {
|
217
|
+
"tags": [],
|
218
|
+
"text": "Placeholder to display if `selectedValue` is empty."
|
219
|
+
},
|
220
|
+
"attribute": "placeholder",
|
221
|
+
"reflect": false
|
222
|
+
},
|
223
|
+
"required": {
|
224
|
+
"type": "boolean",
|
225
|
+
"mutable": false,
|
226
|
+
"complexType": {
|
227
|
+
"original": "boolean",
|
228
|
+
"resolved": "boolean",
|
229
|
+
"references": {}
|
230
|
+
},
|
231
|
+
"required": false,
|
232
|
+
"optional": false,
|
233
|
+
"docs": {
|
234
|
+
"tags": [],
|
235
|
+
"text": "If `true`, the user must fill in a value before submitting a form."
|
236
|
+
},
|
237
|
+
"attribute": "required",
|
238
|
+
"reflect": false,
|
239
|
+
"defaultValue": "false"
|
240
|
+
},
|
241
|
+
"selectedValue": {
|
242
|
+
"type": "string",
|
243
|
+
"mutable": false,
|
244
|
+
"complexType": {
|
245
|
+
"original": "string",
|
246
|
+
"resolved": "string",
|
247
|
+
"references": {}
|
248
|
+
},
|
249
|
+
"required": false,
|
250
|
+
"optional": true,
|
251
|
+
"docs": {
|
252
|
+
"tags": [],
|
253
|
+
"text": "Value of the selected item."
|
254
|
+
},
|
255
|
+
"attribute": "selected-value",
|
256
|
+
"reflect": false
|
257
|
+
},
|
258
|
+
"showFormattedSelectedItem": {
|
259
|
+
"type": "boolean",
|
260
|
+
"mutable": false,
|
261
|
+
"complexType": {
|
262
|
+
"original": "boolean",
|
263
|
+
"resolved": "boolean",
|
264
|
+
"references": {}
|
265
|
+
},
|
266
|
+
"required": false,
|
267
|
+
"optional": true,
|
268
|
+
"docs": {
|
269
|
+
"tags": [],
|
270
|
+
"text": "Will show the formatted selected item (passed in the `selected-item` slot) in the select rather than the item value."
|
271
|
+
},
|
272
|
+
"attribute": "show-formatted-selected-item",
|
273
|
+
"reflect": false
|
274
|
+
},
|
275
|
+
"showOptionalLabel": {
|
276
|
+
"type": "boolean",
|
277
|
+
"mutable": false,
|
278
|
+
"complexType": {
|
279
|
+
"original": "boolean",
|
280
|
+
"resolved": "boolean",
|
281
|
+
"references": {}
|
282
|
+
},
|
283
|
+
"required": false,
|
284
|
+
"optional": false,
|
285
|
+
"docs": {
|
286
|
+
"tags": [],
|
287
|
+
"text": "If `true`, the label will display an \"optional\" tag."
|
288
|
+
},
|
289
|
+
"attribute": "show-optional-label",
|
290
|
+
"reflect": false,
|
291
|
+
"defaultValue": "false"
|
292
|
+
}
|
293
|
+
};
|
294
|
+
}
|
295
|
+
static get states() {
|
296
|
+
return {
|
297
|
+
"hasFocus": {},
|
298
|
+
"popoverOpen": {},
|
299
|
+
"hasSelectedItem": {}
|
300
|
+
};
|
301
|
+
}
|
302
|
+
static get events() {
|
303
|
+
return [{
|
304
|
+
"method": "cpslBlur",
|
305
|
+
"name": "cpslBlur",
|
306
|
+
"bubbles": true,
|
307
|
+
"cancelable": true,
|
308
|
+
"composed": true,
|
309
|
+
"docs": {
|
310
|
+
"tags": [],
|
311
|
+
"text": "Emitted when the input loses focus."
|
312
|
+
},
|
313
|
+
"complexType": {
|
314
|
+
"original": "FocusEvent",
|
315
|
+
"resolved": "FocusEvent",
|
316
|
+
"references": {
|
317
|
+
"FocusEvent": {
|
318
|
+
"location": "global",
|
319
|
+
"id": "global::FocusEvent"
|
320
|
+
}
|
321
|
+
}
|
322
|
+
}
|
323
|
+
}, {
|
324
|
+
"method": "cpslFocus",
|
325
|
+
"name": "cpslFocus",
|
326
|
+
"bubbles": true,
|
327
|
+
"cancelable": true,
|
328
|
+
"composed": true,
|
329
|
+
"docs": {
|
330
|
+
"tags": [],
|
331
|
+
"text": "Emitted when the input has focus."
|
332
|
+
},
|
333
|
+
"complexType": {
|
334
|
+
"original": "FocusEvent",
|
335
|
+
"resolved": "FocusEvent",
|
336
|
+
"references": {
|
337
|
+
"FocusEvent": {
|
338
|
+
"location": "global",
|
339
|
+
"id": "global::FocusEvent"
|
340
|
+
}
|
341
|
+
}
|
342
|
+
}
|
343
|
+
}, {
|
344
|
+
"method": "cpslSelectValueChange",
|
345
|
+
"name": "cpslSelectValueChange",
|
346
|
+
"bubbles": true,
|
347
|
+
"cancelable": true,
|
348
|
+
"composed": true,
|
349
|
+
"docs": {
|
350
|
+
"tags": [],
|
351
|
+
"text": "Emitted when the value changes."
|
352
|
+
},
|
353
|
+
"complexType": {
|
354
|
+
"original": "string",
|
355
|
+
"resolved": "string",
|
356
|
+
"references": {}
|
357
|
+
}
|
358
|
+
}];
|
359
|
+
}
|
360
|
+
static get elementRef() { return "el"; }
|
361
|
+
static get watchers() {
|
362
|
+
return [{
|
363
|
+
"propName": "selectedValue",
|
364
|
+
"methodName": "onValueChange"
|
365
|
+
}, {
|
366
|
+
"propName": "selectedValue",
|
367
|
+
"methodName": "handleValueChange"
|
368
|
+
}];
|
369
|
+
}
|
370
|
+
static get listeners() {
|
371
|
+
return [{
|
372
|
+
"name": "cpslSelectItemClick",
|
373
|
+
"method": "selectItemClickHandler",
|
374
|
+
"target": undefined,
|
375
|
+
"capture": false,
|
376
|
+
"passive": false
|
377
|
+
}, {
|
378
|
+
"name": "cpslOpen",
|
379
|
+
"method": "onPopoverOpen",
|
380
|
+
"target": undefined,
|
381
|
+
"capture": false,
|
382
|
+
"passive": false
|
383
|
+
}, {
|
384
|
+
"name": "cpslClose",
|
385
|
+
"method": "onPopoverClose",
|
386
|
+
"target": undefined,
|
387
|
+
"capture": false,
|
388
|
+
"passive": false
|
389
|
+
}];
|
390
|
+
}
|
391
|
+
}
|
392
|
+
let inputIds = 0;
|
393
|
+
//# sourceMappingURL=cpsl-select.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"cpsl-select.js","sourceRoot":"","sources":["../../../../src/components/cpsl-select/cpsl-select.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAgB,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAO7G,MAAM,OAAO,UAAU;;QAGb,YAAO,GAAG,eAAe,QAAQ,EAAE,EAAE,CAAC;QAgHtC,WAAM,GAAG,CAAC,EAAc,EAAE,EAAE;YAClC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;YAEtB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACzB,CAAC,CAAC;QAEM,YAAO,GAAG,CAAC,EAAc,EAAE,EAAE;YACnC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;YAErB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC1B,CAAC,CAAC;QAEM,qBAAgB,GAAG,CAAC,EAAiB,EAAE,EAAE;YAC/C,IAAI,EAAE,CAAC,GAAG,KAAK,OAAO,EAAE,CAAC;gBACvB,EAAE,CAAC,cAAc,EAAE,CAAC;gBACpB,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,IAAI,UAAU,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF;AAED,IAAI,QAAQ,GAAG,CAAC,CAAC","sourcesContent":["import { Component, Host, Element, h, Prop, State, EventEmitter, Event, Watch, Listen } from '@stencil/core';\n\n@Component({\n tag: 'cpsl-select',\n styleUrl: 'cpsl-select.scss',\n shadow: true,\n})\nexport class CpslSelect {\n @Element() el!: HTMLCpslSelectElement;\n private popoverEl!: HTMLCpslPopoverElement;\n private inputId = `cpsl-select-${inputIds++}`;\n\n @State() hasFocus = false;\n @State() popoverOpen = false;\n @State() hasSelectedItem = false;\n\n /**\n * If `true`, the user cannot interact with the input.\n */\n @Prop() disabled = false;\n\n /**\n * Set the max height of the dropdown.\n */\n @Prop() dropdownMaxHeight?: number;\n\n /**\n * Error text to show below the input. If this is provided the input will enter an error state.\n */\n @Prop() errorText?: string;\n\n /**\n * Format value for display when selected.\n */\n @Prop() formatValue?: (value: string) => string;\n\n /**\n * Helper text to show below the input. If `\"errorText\"` is provided that will take precedence.\n */\n @Prop() helperText?: string;\n\n /**\n * ID of the element, must be unique for the popover trigger.\n */\n // eslint-disable-next-line @stencil-community/reserved-member-names\n @Prop() id: string = `${this.inputId}-trigger`;\n\n /**\n * The label for the input.\n */\n @Prop() label?: string;\n\n /**\n * Placeholder to display if `selectedValue` is empty.\n */\n @Prop() placeholder?: string;\n\n /**\n * If `true`, the user must fill in a value before submitting a form.\n */\n @Prop() required = false;\n\n /**\n * Value of the selected item.\n */\n @Prop() selectedValue?: string;\n\n /**\n * Will show the formatted selected item (passed in the `selected-item` slot) in the select rather than the item value.\n */\n @Prop() showFormattedSelectedItem?: boolean;\n\n /**\n * If `true`, the label will display an \"optional\" tag.\n */\n @Prop() showOptionalLabel = false;\n\n /**\n * Emitted when the input loses focus.\n */\n @Event() cpslBlur!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the input has focus.\n */\n @Event() cpslFocus!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the value changes.\n */\n @Event() cpslSelectValueChange!: EventEmitter<string>;\n\n @Watch('selectedValue')\n onValueChange() {\n this.popoverEl.closePopover();\n }\n\n @Watch('selectedValue')\n handleValueChange() {\n this.selectItem();\n }\n\n @Listen('cpslSelectItemClick')\n selectItemClickHandler(event: CustomEvent<string>) {\n this.cpslSelectValueChange.emit(event.detail);\n }\n\n @Listen('cpslOpen')\n onPopoverOpen() {\n this.popoverOpen = true;\n }\n\n @Listen('cpslClose')\n onPopoverClose() {\n this.popoverOpen = false;\n }\n componentDidLoad() {\n this.popoverEl = this.el.shadowRoot.querySelector(`cpsl-popover`) as HTMLCpslPopoverElement;\n\n this.selectItem();\n }\n\n private onBlur = (ev: FocusEvent) => {\n this.hasFocus = false;\n\n this.cpslBlur.emit(ev);\n };\n\n private onFocus = (ev: FocusEvent) => {\n this.hasFocus = true;\n\n this.cpslFocus.emit(ev);\n };\n\n private handleEnterPress = (ev: KeyboardEvent) => {\n if (ev.key === 'Enter') {\n ev.preventDefault();\n this.el.dispatchEvent(new MouseEvent('mousedown'));\n }\n };\n\n private selectItem = () => {\n const items = Array.from(this.el.querySelectorAll('cpsl-select-item')) as HTMLCpslSelectItemElement[];\n\n items.forEach(item => {\n if (item.value === this.selectedValue) {\n item.setAttribute('selected', 'true');\n this.hasSelectedItem = true;\n } else {\n item.setAttribute('selected', 'false');\n }\n });\n\n if (!Boolean(this.selectedValue)) {\n this.hasSelectedItem = false;\n }\n };\n\n render() {\n return (\n <Host id={this.id} class={{ 'disabled': this.disabled, 'focused': this.hasFocus, 'has-value': Boolean(this.selectedValue) }}>\n {this.label && (\n <label class=\"label\" htmlFor={this.inputId}>\n {this.label}\n {this.required ? '*' : ' '}\n {!this.required && this.showOptionalLabel ? <span class=\"optional-label\">(optional)</span> : ''}\n </label>\n )}\n <div class={{ 'select-container': true, 'error-container': Boolean(this.errorText) }}>\n {this.hasSelectedItem && this.showFormattedSelectedItem && <slot name=\"selected-item\"></slot>}\n <div class=\"selected-container-content\" id=\"selected-container-content\">\n {(!this.hasSelectedItem || !this.showFormattedSelectedItem) && (\n <cpsl-text class={{ 'selected-text': true, 'placeholder': !Boolean(this.selectedValue) }}>\n {!Boolean(this.selectedValue) ? this.placeholder ?? 'Select' : this.formatValue?.(this.selectedValue) ?? this.selectedValue}\n </cpsl-text>\n )}\n </div>\n <cpsl-icon class={{ 'chevron': true, 'open': this.popoverOpen, 'has-value': Boolean(this.selectedValue) }} icon=\"chevronUp\" />\n <input\n id={this.inputId}\n disabled={this.disabled}\n class={{ disabled: this.disabled }}\n value={this.selectedValue}\n onFocus={this.onFocus}\n onBlur={this.onBlur}\n onKeyPress={this.handleEnterPress}\n />\n </div>\n {(this.errorText || this.helperText) && (\n <div class={{ 'helper-text-container': true, 'error-text': Boolean(this.errorText) }}>\n <span>{this.errorText ?? this.helperText}</span>\n </div>\n )}\n <cpsl-popover autoWidth={false} trigger={this.id} preventBlur={this.hasFocus}>\n <div class=\"dropdown\">\n <div class=\"dropdown-inner\" style={{ maxHeight: `${this.dropdownMaxHeight}px` }}>\n <slot name=\"items\"></slot>\n </div>\n </div>\n </cpsl-popover>\n </Host>\n );\n }\n}\n\nlet inputIds = 0;\n"]}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
4
|
+
function fulfilled(value) { try {
|
5
|
+
step(generator.next(value));
|
6
|
+
}
|
7
|
+
catch (e) {
|
8
|
+
reject(e);
|
9
|
+
} }
|
10
|
+
function rejected(value) { try {
|
11
|
+
step(generator["throw"](value));
|
12
|
+
}
|
13
|
+
catch (e) {
|
14
|
+
reject(e);
|
15
|
+
} }
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
18
|
+
});
|
19
|
+
};
|
20
|
+
import { newE2EPage } from "@stencil/core/testing";
|
21
|
+
describe('cpsl-select', () => {
|
22
|
+
it('renders', () => __awaiter(void 0, void 0, void 0, function* () {
|
23
|
+
const page = yield newE2EPage();
|
24
|
+
yield page.setContent('<cpsl-select></cpsl-select>');
|
25
|
+
const element = yield page.find('cpsl-select');
|
26
|
+
expect(element).toHaveClass('hydrated');
|
27
|
+
}));
|
28
|
+
});
|
29
|
+
//# sourceMappingURL=cpsl-select.e2e.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"cpsl-select.e2e.js","sourceRoot":"","sources":["../../../../../src/components/cpsl-select/test/cpsl-select.e2e.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,EAAE,CAAC,SAAS,EAAE,GAAS,EAAE;QACvB,MAAM,IAAI,GAAG,MAAM,UAAU,EAAE,CAAC;QAChC,MAAM,IAAI,CAAC,UAAU,CAAC,6BAA6B,CAAC,CAAC;QAErD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC/C,MAAM,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAC1C,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { newE2EPage } from '@stencil/core/testing';\n\ndescribe('cpsl-select', () => {\n it('renders', async () => {\n const page = await newE2EPage();\n await page.setContent('<cpsl-select></cpsl-select>');\n\n const element = await page.find('cpsl-select');\n expect(element).toHaveClass('hydrated');\n });\n});\n"]}
|