@haiilo/catalyst 1.0.2 → 1.1.1
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/catalyst/catalyst.css +1 -1
- package/dist/catalyst/catalyst.esm.js +1 -1
- package/dist/catalyst/catalyst.esm.js.map +1 -1
- package/dist/catalyst/p-a4d0b054.entry.js +10 -0
- package/dist/catalyst/p-a4d0b054.entry.js.map +1 -0
- package/dist/catalyst/scss/utils/_sizing.mixins.scss +1 -1
- package/dist/cjs/cat-alert_23.cjs.entry.js +320 -129
- package/dist/cjs/cat-alert_23.cjs.entry.js.map +1 -1
- package/dist/cjs/catalyst.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/cat-alert/cat-alert.css +13 -19
- package/dist/collection/components/cat-alert/cat-alert.js +19 -20
- package/dist/collection/components/cat-alert/cat-alert.js.map +1 -1
- package/dist/collection/components/cat-avatar/cat-avatar.css +8 -8
- package/dist/collection/components/cat-badge/cat-badge.css +20 -26
- package/dist/collection/components/cat-badge/cat-badge.js +9 -12
- package/dist/collection/components/cat-badge/cat-badge.js.map +1 -1
- package/dist/collection/components/cat-card/cat-card.js +2 -3
- package/dist/collection/components/cat-card/cat-card.js.map +1 -1
- package/dist/collection/components/cat-checkbox/cat-checkbox.css +1 -1
- package/dist/collection/components/cat-select/cat-select.css +6 -1
- package/dist/collection/components/cat-select/cat-select.js +290 -89
- package/dist/collection/components/cat-select/cat-select.js.map +1 -1
- package/dist/collection/components/cat-select-demo/cat-select-demo.js +43 -30
- package/dist/collection/components/cat-select-demo/cat-select-demo.js.map +1 -1
- package/dist/collection/components/cat-tooltip/cat-tooltip.css +26 -2
- package/dist/collection/components/cat-tooltip/cat-tooltip.js +51 -3
- package/dist/collection/components/cat-tooltip/cat-tooltip.js.map +1 -1
- package/dist/collection/index.js.map +1 -1
- package/dist/collection/scss/utils/_sizing.mixins.scss +1 -1
- package/dist/collection/utils/setDefault.js +9 -0
- package/dist/collection/utils/setDefault.js.map +1 -0
- package/dist/components/cat-alert.js +16 -14
- package/dist/components/cat-alert.js.map +1 -1
- package/dist/components/cat-avatar2.js +1 -1
- package/dist/components/cat-avatar2.js.map +1 -1
- package/dist/components/cat-badge.js +9 -9
- package/dist/components/cat-badge.js.map +1 -1
- package/dist/components/cat-card.js +2 -2
- package/dist/components/cat-card.js.map +1 -1
- package/dist/components/cat-checkbox2.js +1 -1
- package/dist/components/cat-checkbox2.js.map +1 -1
- package/dist/components/cat-select-demo.js +33 -22
- package/dist/components/cat-select-demo.js.map +1 -1
- package/dist/components/cat-select2.js +238 -77
- package/dist/components/cat-select2.js.map +1 -1
- package/dist/components/cat-tooltip.js +17 -3
- package/dist/components/cat-tooltip.js.map +1 -1
- package/dist/components/setDefault.js +12 -0
- package/dist/components/setDefault.js.map +1 -0
- package/dist/esm/cat-alert_23.entry.js +321 -130
- package/dist/esm/cat-alert_23.entry.js.map +1 -1
- package/dist/esm/catalyst.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/types/components/cat-alert/cat-alert.d.ts +3 -3
- package/dist/types/components/cat-badge/cat-badge.d.ts +2 -2
- package/dist/types/components/cat-select/cat-select.d.ts +34 -1
- package/dist/types/components/cat-select-demo/cat-select-demo.d.ts +3 -0
- package/dist/types/components/cat-tooltip/cat-tooltip.d.ts +8 -0
- package/dist/types/components.d.ts +37 -5
- package/dist/types/index.d.ts +1 -1
- package/dist/types/utils/setDefault.d.ts +6 -0
- package/package.json +2 -2
- package/dist/catalyst/p-a2ddc7fa.entry.js +0 -10
- package/dist/catalyst/p-a2ddc7fa.entry.js.map +0 -1
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
import { r as registerInstance, h, H as Host,
|
|
1
|
+
import { r as registerInstance, h, H as Host, g as getElement, c as createEvent } from './index-df195301.js';
|
|
2
2
|
import { l as loglevel, a as CatIconRegistry, C as CatI18nRegistry, N as NotificationsService } from './cat-notification-8bcf6fa2.js';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
function setAttributeDefault(host, attr, value) {
|
|
5
|
+
if (!host.hostElement.hasAttribute(attr) && value != null) {
|
|
6
|
+
host.hostElement.setAttribute(attr, String(value));
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
function setPropertyDefault(host, prop) {
|
|
10
|
+
setAttributeDefault(host, String(prop), host[prop]);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const catAlertCss = ":host{display:flex;gap:0.5rem;padding:1.25rem;border-radius:0.5rem;margin-bottom:1rem}:host([hidden]){display:none}:host(:focus-visible){outline:2px solid rgb(var(--cat-border-color-focus, 0, 113, 255));outline-offset:1px}.content{align-self:center}::slotted(:last-child){margin-bottom:0 !important}:host([color=primary]){background-color:rgba(var(--cat-primary-bg, 32, 127, 138), 0.1)}:host([color=primary]) cat-icon{color:#207f8a}:host([color=secondary]){background-color:rgba(105, 118, 135, 0.1)}:host([color=secondary]) cat-icon{color:#697687}:host([color=success]){background-color:rgba(0, 132, 88, 0.1)}:host([color=success]) cat-icon{color:#008458}:host([color=warning]){background-color:rgba(255, 206, 128, 0.1)}:host([color=warning]) cat-icon{color:#ebb663}:host([color=danger]){background-color:rgba(217, 52, 13, 0.1)}:host([color=danger]) cat-icon{color:#d9340d}";
|
|
5
14
|
|
|
6
15
|
const CatAlert = class {
|
|
7
16
|
constructor(hostRef) {
|
|
@@ -13,6 +22,13 @@ const CatAlert = class {
|
|
|
13
22
|
['warning', 'danger-filled'],
|
|
14
23
|
['danger', 'cross-circle-filled']
|
|
15
24
|
]);
|
|
25
|
+
this.mapRole = new Map([
|
|
26
|
+
['primary', 'status'],
|
|
27
|
+
['secondary', 'status'],
|
|
28
|
+
['success', 'status'],
|
|
29
|
+
['warning', 'alert'],
|
|
30
|
+
['danger', 'alert']
|
|
31
|
+
]);
|
|
16
32
|
/**
|
|
17
33
|
* The color palette of the alert.
|
|
18
34
|
*/
|
|
@@ -22,21 +38,15 @@ const CatAlert = class {
|
|
|
22
38
|
*/
|
|
23
39
|
this.noIcon = false;
|
|
24
40
|
}
|
|
41
|
+
connectedCallback() {
|
|
42
|
+
setAttributeDefault(this, 'tabindex', 0);
|
|
43
|
+
setAttributeDefault(this, 'role', this.mapRole.get(this.color));
|
|
44
|
+
setPropertyDefault(this, 'color');
|
|
45
|
+
}
|
|
25
46
|
render() {
|
|
26
|
-
return (h(Host, {
|
|
27
|
-
alert: true,
|
|
28
|
-
[`alert-${this.color}`]: Boolean(this.color)
|
|
29
|
-
} }, !this.noIcon && h("cat-icon", { size: "l", icon: this.icon ? this.icon : this.mapIcon.get(this.color) }), h("div", { class: "content" }, h("slot", null)))));
|
|
30
|
-
}
|
|
31
|
-
get role() {
|
|
32
|
-
switch (this.color) {
|
|
33
|
-
case 'danger':
|
|
34
|
-
case 'warning':
|
|
35
|
-
return 'alert';
|
|
36
|
-
default:
|
|
37
|
-
return 'status';
|
|
38
|
-
}
|
|
47
|
+
return (h(Host, null, !this.noIcon && h("cat-icon", { size: "l", icon: this.icon ? this.icon : this.mapIcon.get(this.color) }), h("div", { class: "content" }, h("slot", null))));
|
|
39
48
|
}
|
|
49
|
+
get hostElement() { return getElement(this); }
|
|
40
50
|
};
|
|
41
51
|
CatAlert.style = catAlertCss;
|
|
42
52
|
|
|
@@ -55,7 +65,7 @@ const loadImg = (src) => {
|
|
|
55
65
|
});
|
|
56
66
|
};
|
|
57
67
|
|
|
58
|
-
const catAvatarCss = ":host{display:
|
|
68
|
+
const catAvatarCss = ":host{display:contents}:host([hidden]){display:none}.avatar{display:inline-flex;align-items:center;justify-content:center;border-radius:0.25rem;text-decoration:inherit;color:var(--cat-avatar-fill, white);background-color:var(--cat-avatar-bg, #697687);background-size:cover;background-position:center;white-space:nowrap;overflow:hidden;vertical-align:middle;-webkit-user-select:none;-ms-user-select:none;user-select:none;}.avatar:focus-visible{outline:2px solid rgb(var(--cat-border-color-focus, 0, 113, 255));outline-offset:1px}.avatar-round{border-radius:50%}.avatar-xs{width:var(--cat-avatar-size, 1.5rem);height:var(--cat-avatar-size, 1.5rem);line-height:var(--cat-avatar-size, 1.5rem);font-size:var(--cat-avatar-font-size, 0.75rem)}.avatar-s{width:var(--cat-avatar-size, 2rem);height:var(--cat-avatar-size, 2rem);line-height:var(--cat-avatar-size, 2rem);font-size:var(--cat-avatar-font-size, 0.875rem)}.avatar-m{width:var(--cat-avatar-size, 2.5rem);height:var(--cat-avatar-size, 2.5rem);line-height:var(--cat-avatar-size, 2.5rem);font-size:var(--cat-avatar-font-size, 0.9375rem)}.avatar-l{width:var(--cat-avatar-size, 3rem);height:var(--cat-avatar-size, 3rem);line-height:var(--cat-avatar-size, 3rem);font-size:var(--cat-avatar-font-size, 1.125rem)}.avatar-xl{width:var(--cat-avatar-size, 3.5rem);height:var(--cat-avatar-size, 3.5rem);line-height:var(--cat-avatar-size, 3.5rem);font-size:var(--cat-avatar-font-size, 1.25rem)}";
|
|
59
69
|
|
|
60
70
|
const CatAvatar = class {
|
|
61
71
|
constructor(hostRef) {
|
|
@@ -125,7 +135,7 @@ const CatAvatar = class {
|
|
|
125
135
|
};
|
|
126
136
|
CatAvatar.style = catAvatarCss;
|
|
127
137
|
|
|
128
|
-
const catBadgeCss = ":host{display:inline-
|
|
138
|
+
const catBadgeCss = ":host([hidden]){display:none}:host{display:inline-flex;max-width:100%;vertical-align:baseline;align-items:center;justify-content:center;border-radius:0.125rem;text-decoration:none;line-height:1}:host slot{display:inline-block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}:host([round]){border-radius:10rem}:host([variant=filled]){background-color:rgb(var(--bg));color:rgb(var(--fill));font-weight:600;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:greyscale}:host([variant=outlined]){background-color:white;box-shadow:inset 0 0 0 1px rgba(var(--border), 0.2);color:rgb(var(--text))}:host([color=primary]){--bg:var(--cat-primary-bg, 32, 127, 138);--fill:var(--cat-primary-fill, 255, 255, 255);--text:var(--cat-primary-text, 32, 127, 138);--border:var(--cat-primary-text, 32, 127, 138)}:host([color=secondary]){--bg:105, 118, 135;--fill:255, 255, 255;--text:0, 0, 0;--border:105, 118, 135}:host([color=success]){--bg:0, 132, 88;--fill:255, 255, 255;--text:0, 132, 88;--border:0, 132, 88}:host([color=warning]){--bg:255, 206, 128;--fill:0, 0, 0;--text:159, 97, 0;--border:159, 97, 0}:host([color=danger]){--bg:217, 52, 13;--fill:255, 255, 255;--text:217, 52, 13;--border:217, 52, 13}:host([size=xs]){height:1rem;min-width:1rem;font-size:0.75rem;padding:0 0.25rem}:host([size=s]){height:1.5rem;min-width:1.5rem;font-size:0.75rem;padding:0 0.5rem}:host([size=m]){height:2rem;min-width:2rem;font-size:0.875rem;padding:0 0.75rem}:host([size=l]){height:2.5rem;min-width:2.5rem;font-size:0.9375rem;padding:0 1rem}:host([size=xl]){height:3rem;min-width:3rem;font-size:1.125rem;padding:0 1rem}:host([pulse][variant=filled]){animation:1.5s ease 0s infinite normal none running pulse}:host([pulse][variant=outlined]){animation:1.5s ease 0s infinite normal none running pulse-outlined}@keyframes pulse{0%{box-shadow:0 0 0 0 rgb(var(--bg))}70%{box-shadow:transparent 0 0 0 0.5rem}100%{box-shadow:transparent 0 0 0 0}}@keyframes pulse-outlined{0%{box-shadow:0 0 0 0 rgb(var(--bg)), inset 0 0 0 1px rgba(var(--border), 0.2)}70%{box-shadow:transparent 0 0 0 0.5rem, inset 0 0 0 1px rgba(var(--border), 0.2)}100%{box-shadow:transparent 0 0 0 0, inset 0 0 0 1px rgba(var(--border), 0.2)}}";
|
|
129
139
|
|
|
130
140
|
const CatBadge = class {
|
|
131
141
|
constructor(hostRef) {
|
|
@@ -151,16 +161,15 @@ const CatBadge = class {
|
|
|
151
161
|
*/
|
|
152
162
|
this.pulse = false;
|
|
153
163
|
}
|
|
164
|
+
connectedCallback() {
|
|
165
|
+
setPropertyDefault(this, 'variant');
|
|
166
|
+
setPropertyDefault(this, 'color');
|
|
167
|
+
setPropertyDefault(this, 'size');
|
|
168
|
+
}
|
|
154
169
|
render() {
|
|
155
|
-
return
|
|
156
|
-
badge: true,
|
|
157
|
-
'badge-round': this.round,
|
|
158
|
-
'badge-pulse': this.pulse,
|
|
159
|
-
[`badge-${this.variant}`]: Boolean(this.variant),
|
|
160
|
-
[`badge-${this.color}`]: Boolean(this.color),
|
|
161
|
-
[`badge-${this.size}`]: Boolean(this.size)
|
|
162
|
-
} }, h("slot", null)));
|
|
170
|
+
return h("slot", null);
|
|
163
171
|
}
|
|
172
|
+
get hostElement() { return getElement(this); }
|
|
164
173
|
};
|
|
165
174
|
CatBadge.style = catBadgeCss;
|
|
166
175
|
|
|
@@ -463,7 +472,7 @@ const CatCard = class {
|
|
|
463
472
|
registerInstance(this, hostRef);
|
|
464
473
|
}
|
|
465
474
|
render() {
|
|
466
|
-
return
|
|
475
|
+
return h("slot", null);
|
|
467
476
|
}
|
|
468
477
|
};
|
|
469
478
|
CatCard.style = catCardCss;
|
|
@@ -483,7 +492,7 @@ const CatFormHint = props => {
|
|
|
483
492
|
]));
|
|
484
493
|
};
|
|
485
494
|
|
|
486
|
-
const catCheckboxCss = ".hint-section{display:flex;gap:0.5rem;flex-direction:column}.hint-section .input-hint,.hint-section ::slotted([slot=hint]){font-size:0.875rem;line-height:1rem;font-weight:var(--cat-font-weight-body, 400);margin:0 !important}:host-context(.cat-error) .hint-section{color:#d9340d}:host{display:flex;flex-direction:column;gap:0.5rem;margin-bottom:1rem}:host([hidden]){display:none}label{flex:0 1 auto;display:flex;gap:0.5rem;font-size:0.9375rem;line-height:1.25rem;font-weight:var(--cat-font-weight-body, 400);-webkit-user-select:none;-ms-user-select:none;user-select:none;cursor:pointer;position:relative}.label-left{flex-direction:row-reverse}.label-left input{right:1px;left:unset}input{position:absolute;width:1.25rem;height:1.25rem;margin:0;opacity:0;cursor:inherit;left:1px;top:0.5px}.box{flex:0 0 auto;display:flex;position:relative;height:1.25rem;width:1.25rem;background-color:white;border:1px solid #d7dbe0;border-radius:0.125rem;transition:background-color 0.13s ease, border-color 0.13s ease;pointer-events:none}.box svg{fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:16px;stroke-dashoffset:16px;transition:all 0.13s ease;width:
|
|
495
|
+
const catCheckboxCss = ".hint-section{display:flex;gap:0.5rem;flex-direction:column}.hint-section .input-hint,.hint-section ::slotted([slot=hint]){font-size:0.875rem;line-height:1rem;font-weight:var(--cat-font-weight-body, 400);margin:0 !important}:host-context(.cat-error) .hint-section{color:#d9340d}:host{display:flex;flex-direction:column;gap:0.5rem;margin-bottom:1rem}:host([hidden]){display:none}label{flex:0 1 auto;display:flex;gap:0.5rem;font-size:0.9375rem;line-height:1.25rem;font-weight:var(--cat-font-weight-body, 400);-webkit-user-select:none;-ms-user-select:none;user-select:none;cursor:pointer;position:relative}.label-left{flex-direction:row-reverse}.label-left input{right:1px;left:unset}input{position:absolute;width:1.25rem;height:1.25rem;margin:0;opacity:0;cursor:inherit;left:1px;top:0.5px}.box{flex:0 0 auto;display:flex;position:relative;height:1.25rem;width:1.25rem;background-color:white;border:1px solid #d7dbe0;border-radius:0.125rem;transition:background-color 0.13s ease, border-color 0.13s ease;pointer-events:none}.box svg{fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:16px;stroke-dashoffset:16px;transition:all 0.13s ease;width:50%;position:absolute;top:50%;left:50%;transform:translate(-50%, -50%) scale(0.99)}:checked+.box{background-color:rgb(var(--cat-primary-bg, 32, 127, 138));border-color:rgb(var(--cat-primary-bg, 32, 127, 138));stroke:rgb(var(--cat-primary-fill, 255, 255, 255))}:checked+.box .check{stroke-dashoffset:0}:indeterminate+.box{background-color:rgb(var(--cat-primary-bg, 32, 127, 138));border-color:rgb(var(--cat-primary-bg, 32, 127, 138));stroke:rgb(var(--cat-primary-fill, 255, 255, 255))}:indeterminate+.box .dash{stroke-dashoffset:0}:focus-visible+.box{outline:2px solid rgb(var(--cat-border-color-focus, 0, 113, 255));outline-offset:1px}:host(.cat-error) .box{border:1px solid #d9340d}:host(.cat-error) :checked+.box,:host(.cat-error) :indeterminate+.box{background-color:#d9340d;border-color:#d9340d;stroke:white}.label{flex:1 1 auto;min-width:0}.is-hidden .label{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;margin:-1px !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;white-space:nowrap !important;border:0 !important}.is-disabled{cursor:not-allowed;color:rgb(var(--cat-font-color-muted, 105, 118, 135))}";
|
|
487
496
|
|
|
488
497
|
let nextUniqueId$8 = 0;
|
|
489
498
|
const CatCheckbox = class {
|
|
@@ -5219,7 +5228,7 @@ var autosizeInput = function (element, options) {
|
|
|
5219
5228
|
}
|
|
5220
5229
|
};
|
|
5221
5230
|
|
|
5222
|
-
const catSelectCss = ".hint-section{display:flex;gap:0.5rem;flex-direction:column}.hint-section .input-hint,.hint-section ::slotted([slot=hint]){font-size:0.875rem;line-height:1rem;font-weight:var(--cat-font-weight-body, 400);margin:0 !important}:host-context(.cat-error) .hint-section{color:#d9340d}:host{display:flex;flex-direction:column;gap:0.5rem;position:relative;margin-bottom:1rem}:host([hidden]){display:none}label{align-self:flex-start}label.hidden{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;margin:-1px !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;white-space:nowrap !important;border:0 !important}.input-optional{margin-left:0.25rem;font-size:0.75rem;line-height:1rem;font-weight:var(--cat-font-weight-body, 400);color:rgb(var(--cat-font-color-muted, 105, 118, 135))}.select-wrapper{display:flex;align-items:flex-start;background:white;border-radius:0.25rem;box-shadow:0 0 0 1px #d7dbe0;transition:box-shadow 0.13s linear;padding:0.25rem}.select-wrapper:not(.select-disabled):hover{box-shadow:0 0 0 2px #d7dbe0}.select-wrapper:not(.select-disabled):focus-within{outline:2px solid rgb(var(--cat-border-color-focus, 0, 113, 255))}:host(.cat-error) .select-wrapper{box-shadow:0 0 0 1px #d9340d}:host(.cat-error) .select-wrapper:not(.input-disabled):hover{box-shadow:0 0 0 2px #d9340d}.select-disabled{background:#f8f8fb;cursor:not-allowed;color:rgb(var(--cat-font-color-muted, 105, 118, 135));pointer-events:none}.select-wrapper-inner{display:flex;flex:1 1 auto;flex-wrap:wrap;align-items:center;gap:0.25rem;min-width:0}.select-wrapper-inner>cat-avatar{padding-left:0.25rem}.select-wrapper-inner cat-avatar{--cat-avatar-size:1.25rem}.select-input{font:inherit;background:none;border:none;outline:none;padding:0.375rem 0.5rem;flex:1 1 auto;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}.select-disabled .select-input{cursor:inherit}.select-pills{display:contents}.pill{display:inline-flex;align-items:center;gap:0.5rem;padding:0.25rem 0.5rem;background:#
|
|
5231
|
+
const catSelectCss = ".hint-section{display:flex;gap:0.5rem;flex-direction:column}.hint-section .input-hint,.hint-section ::slotted([slot=hint]){font-size:0.875rem;line-height:1rem;font-weight:var(--cat-font-weight-body, 400);margin:0 !important}:host-context(.cat-error) .hint-section{color:#d9340d}:host{display:flex;flex-direction:column;gap:0.5rem;position:relative;margin-bottom:1rem}:host([hidden]){display:none}label{align-self:flex-start}label.hidden{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;margin:-1px !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;white-space:nowrap !important;border:0 !important}.input-optional{margin-left:0.25rem;font-size:0.75rem;line-height:1rem;font-weight:var(--cat-font-weight-body, 400);color:rgb(var(--cat-font-color-muted, 105, 118, 135))}.select-wrapper{display:flex;align-items:flex-start;background:white;border-radius:0.25rem;box-shadow:0 0 0 1px #d7dbe0;transition:box-shadow 0.13s linear;padding:0.25rem}.select-wrapper:not(.select-disabled):hover{box-shadow:0 0 0 2px #d7dbe0}.select-wrapper:not(.select-disabled):focus-within{outline:2px solid rgb(var(--cat-border-color-focus, 0, 113, 255))}:host(.cat-error) .select-wrapper{box-shadow:0 0 0 1px #d9340d}:host(.cat-error) .select-wrapper:not(.input-disabled):hover{box-shadow:0 0 0 2px #d9340d}.select-disabled{background:#f8f8fb;cursor:not-allowed;color:rgb(var(--cat-font-color-muted, 105, 118, 135));pointer-events:none}.select-wrapper-inner{display:flex;flex:1 1 auto;flex-wrap:wrap;align-items:center;gap:0.25rem;min-width:0}.select-wrapper-inner>cat-avatar{padding-left:0.25rem}.select-wrapper-inner cat-avatar{--cat-avatar-size:1.25rem}.select-input{font:inherit;background:none;border:none;outline:none;padding:0.375rem 0.5rem;flex:1 1 auto;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}.select-disabled .select-input{cursor:inherit}.select-pills{display:contents}.pill{display:inline-flex;align-items:center;gap:0.5rem;padding:0.25rem 0.5rem;background:#f2f4f7;border-radius:0.125rem;white-space:nowrap;min-width:0}.pill>span{overflow:hidden;text-overflow:ellipsis;flex:1 1 0%}.pill>cat-button{margin-right:-0.25rem;margin-left:-0.25rem}.select-btn{transition:transform 0.13s linear}.select-btn::part(button){outline:none}cat-spinner{padding:0.375rem}.select-btn-open{transform:rotate(180deg)}.select-dropdown{position:absolute;right:0;background:white;display:none;overflow:auto;box-shadow:0 1px 4px 0 rgba(16, 29, 48, 0.2);border-radius:0.25rem;z-index:100}.select-options-wrapper{max-height:16rem;width:100%}.select-empty{margin:1rem 0;padding:0 1.25rem}.select-options{list-style-type:none;margin:0;padding:0.5rem 0}.select-options cat-checkbox,.select-options .select-option-single{margin:0;padding:0.5rem 1rem}.select-option-inner{display:flex;gap:0.5rem;--cat-avatar-size:1.25rem}.select-option-text{flex:1 1 0%}.select-option-single{cursor:pointer}.select-input-transparent-caret{caret-color:transparent}.select-option-empty,.select-option-loading{padding:0.5rem 1rem}.select-option:hover{background-color:rgba(105, 118, 135, 0.05)}.select-option-active{outline:2px solid rgb(var(--cat-border-color-focus, 0, 113, 255));outline-offset:-2px}.select-option-label{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;}.select-option-description{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;color:rgb(var(--cat-font-color-muted, 105, 118, 135))}";
|
|
5223
5232
|
|
|
5224
5233
|
const INIT_STATE = {
|
|
5225
5234
|
term: '',
|
|
@@ -5281,6 +5290,10 @@ const CatSelect = class {
|
|
|
5281
5290
|
* Whether the select should show a clear button.
|
|
5282
5291
|
*/
|
|
5283
5292
|
this.clearable = false;
|
|
5293
|
+
/**
|
|
5294
|
+
* Whether the select should add new items.
|
|
5295
|
+
*/
|
|
5296
|
+
this.tags = false;
|
|
5284
5297
|
}
|
|
5285
5298
|
onConnectorChange(connector) {
|
|
5286
5299
|
this.reset(connector);
|
|
@@ -5300,11 +5313,25 @@ const CatSelect = class {
|
|
|
5300
5313
|
this.hide();
|
|
5301
5314
|
}
|
|
5302
5315
|
const idsSelected = this.state.selection.map(item => item.item.id);
|
|
5303
|
-
if (this.
|
|
5304
|
-
this.
|
|
5316
|
+
if (!this.tags) {
|
|
5317
|
+
if (this.multiple) {
|
|
5318
|
+
this.value = idsSelected;
|
|
5319
|
+
}
|
|
5320
|
+
else {
|
|
5321
|
+
this.value = idsSelected.length ? idsSelected[0] : '';
|
|
5322
|
+
}
|
|
5305
5323
|
}
|
|
5306
5324
|
else {
|
|
5307
|
-
|
|
5325
|
+
const ids = idsSelected.filter(id => !id.startsWith(`select-${this.id}-tag`));
|
|
5326
|
+
const tags = this.state.selection
|
|
5327
|
+
.filter(item => item.item.id.startsWith(`select-${this.id}-tag`))
|
|
5328
|
+
.map(item => item.render.label);
|
|
5329
|
+
if (this.multiple) {
|
|
5330
|
+
this.value = { ids, tags };
|
|
5331
|
+
}
|
|
5332
|
+
else {
|
|
5333
|
+
this.value = { id: ids.length ? ids[0] : '', tag: tags.length ? tags[0] : '' };
|
|
5334
|
+
}
|
|
5308
5335
|
}
|
|
5309
5336
|
this.catChange.emit();
|
|
5310
5337
|
}
|
|
@@ -5325,7 +5352,12 @@ const CatSelect = class {
|
|
|
5325
5352
|
}
|
|
5326
5353
|
onBlur(event) {
|
|
5327
5354
|
if (!this.multiple && this.state.activeOptionIndex >= 0) {
|
|
5328
|
-
this.
|
|
5355
|
+
if (this.tags && this.state.options[this.state.activeOptionIndex].item.id === `select-${this.id}-option-tag`) {
|
|
5356
|
+
this.createTag(this.state.term);
|
|
5357
|
+
}
|
|
5358
|
+
else {
|
|
5359
|
+
this.select(this.state.options[this.state.activeOptionIndex]);
|
|
5360
|
+
}
|
|
5329
5361
|
}
|
|
5330
5362
|
this.hide();
|
|
5331
5363
|
this.patchState({ activeSelectionIndex: -1 });
|
|
@@ -5337,8 +5369,19 @@ const CatSelect = class {
|
|
|
5337
5369
|
if (['ArrowDown', 'ArrowUp', 'ArrowLeft', 'ArrowRight'].includes(event.key)) {
|
|
5338
5370
|
this.onArrowKeyDown(event);
|
|
5339
5371
|
}
|
|
5340
|
-
else if (['Enter', ' '].includes(event.key)) {
|
|
5341
|
-
if (
|
|
5372
|
+
else if (['Enter', ' '].includes(event.key) && isInputFocused) {
|
|
5373
|
+
if (this.tags &&
|
|
5374
|
+
this.state.activeOptionIndex === 0 &&
|
|
5375
|
+
this.state.options[0].item.id === `select-${this.id}-option-tag`) {
|
|
5376
|
+
event.preventDefault();
|
|
5377
|
+
if (this.multiple) {
|
|
5378
|
+
this.toggleTag(this.state.options[0]);
|
|
5379
|
+
}
|
|
5380
|
+
else {
|
|
5381
|
+
this.createTag(this.state.options[0].render.label);
|
|
5382
|
+
}
|
|
5383
|
+
}
|
|
5384
|
+
else if (this.state.activeOptionIndex >= 0) {
|
|
5342
5385
|
event.preventDefault();
|
|
5343
5386
|
if (this.multiple) {
|
|
5344
5387
|
this.toggle(this.state.options[this.state.activeOptionIndex]);
|
|
@@ -5347,6 +5390,9 @@ const CatSelect = class {
|
|
|
5347
5390
|
this.select(this.state.options[this.state.activeOptionIndex]);
|
|
5348
5391
|
}
|
|
5349
5392
|
}
|
|
5393
|
+
else if (this.tags && event.key === 'Enter' && this.state.activeOptionIndex < 0) {
|
|
5394
|
+
this.createTag(this.state.term);
|
|
5395
|
+
}
|
|
5350
5396
|
}
|
|
5351
5397
|
else if (event.key === 'Escape') {
|
|
5352
5398
|
this.hide();
|
|
@@ -5370,7 +5416,12 @@ const CatSelect = class {
|
|
|
5370
5416
|
this.patchState({ activeSelectionIndex: -1, activeOptionIndex: -1 });
|
|
5371
5417
|
}
|
|
5372
5418
|
else if (this.state.activeOptionIndex >= 0) {
|
|
5373
|
-
this.
|
|
5419
|
+
if (this.tags && this.state.options[this.state.activeOptionIndex].item.id === `select-${this.id}-option-tag`) {
|
|
5420
|
+
this.createTag(this.state.term);
|
|
5421
|
+
}
|
|
5422
|
+
else {
|
|
5423
|
+
this.select(this.state.options[this.state.activeOptionIndex]);
|
|
5424
|
+
}
|
|
5374
5425
|
}
|
|
5375
5426
|
}
|
|
5376
5427
|
else if (event.key.length === 1) {
|
|
@@ -5408,12 +5459,28 @@ const CatSelect = class {
|
|
|
5408
5459
|
this.subscription = this.term$
|
|
5409
5460
|
.asObservable()
|
|
5410
5461
|
.pipe(debounce(term => (term ? timer(this.debounce) : of(0))), distinctUntilChanged(), tap(() => (number$ = this.more$.pipe(filter(() => !this.state.isLoading), scan(n => n + 1, 0), startWith(0)))), tap(() => this.patchState({ options: [] })), switchMap(term => number$.pipe(tap(() => this.patchState({ isLoading: true })), switchMap(number => this.connectorSafe.retrieve(term, number)), tap(page => this.patchState({ isLoading: false, totalElements: page.totalElements })), takeWhile(page => !page.last, true), scan((items, page) => [...items, ...page.content], []))))
|
|
5411
|
-
.subscribe(items =>
|
|
5412
|
-
|
|
5413
|
-
|
|
5462
|
+
.subscribe(items => {
|
|
5463
|
+
var _a;
|
|
5464
|
+
const options = items === null || items === void 0 ? void 0 : items.map(item => ({
|
|
5465
|
+
item: Object.assign(Object.assign({}, item), { id: this.connectorSafe.customId ? this.connectorSafe.customId(item) : item.id }),
|
|
5414
5466
|
render: this.connectorSafe.render(item)
|
|
5415
|
-
}))
|
|
5416
|
-
|
|
5467
|
+
}));
|
|
5468
|
+
if (this.tags &&
|
|
5469
|
+
this.state.term.trim().length &&
|
|
5470
|
+
!options.find(value1 => value1.render.label.toLowerCase() === this.state.term.toLowerCase())) {
|
|
5471
|
+
let label;
|
|
5472
|
+
if (this.isAlreadyCreated(this.state.term)) {
|
|
5473
|
+
label = (_a = this.state.selection.find(item => item.render.label.toLowerCase() === this.state.term.toLowerCase())) === null || _a === void 0 ? void 0 : _a.render.label;
|
|
5474
|
+
}
|
|
5475
|
+
options.unshift({
|
|
5476
|
+
item: { id: `select-${this.id}-option-tag` },
|
|
5477
|
+
render: { label: label ? label : this.state.term }
|
|
5478
|
+
});
|
|
5479
|
+
}
|
|
5480
|
+
this.patchState({
|
|
5481
|
+
options
|
|
5482
|
+
});
|
|
5483
|
+
});
|
|
5417
5484
|
}
|
|
5418
5485
|
render() {
|
|
5419
5486
|
return (h(Host, null, (this.hasSlottedLabel || this.label) && (h("label", { htmlFor: this.id, class: { hidden: this.labelHidden } }, h("span", { part: "label" }, (this.hasSlottedLabel && h("slot", { name: "label" })) || this.label, !this.required && (h("span", { class: "input-optional", "aria-hidden": "true" }, "(", this.i18n.t('input.optional'), ")"))))), h("div", { class: { 'select-wrapper': true, 'select-disabled': this.disabled }, ref: el => (this.trigger = el), id: this.id, role: "combobox", "aria-expanded": this.state.isOpen || this.isPillboxActive(), "aria-controls": this.isPillboxActive() ? `select-pillbox-${this.id}` : `select-listbox-${this.id}`, "aria-required": this.required, "aria-activedescendant": this.activeDescendant, onClick: e => this.onClick(e) }, h("div", { class: "select-wrapper-inner" }, this.multiple && this.state.selection.length ? (h("div", { id: `select-pillbox-${this.id}`, role: "listbox", "aria-orientation": "horizontal", class: "select-pills" }, this.state.selection.map((item, i) => (h("span", { class: {
|
|
@@ -5423,16 +5490,35 @@ const CatSelect = class {
|
|
|
5423
5490
|
}, role: "option", "aria-selected": "true", id: `select-${this.id}-selection-${i}` }, item.render.avatar ? (h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, initials: '' })) : null, h("span", null, item.render.label), !this.disabled && (h("cat-button", { size: "xs", variant: "text", icon: "16-cross", iconOnly: true, a11yLabel: this.i18n.t('select.deselect'), onClick: () => this.deselect(item.item.id), tabIndex: -1 }))))))) : this.state.selection.length && this.state.selection[0].render.avatar ? (h("cat-avatar", { label: this.state.selection[0].render.label, round: this.state.selection[0].render.avatar.round, src: this.state.selection[0].render.avatar.src, initials: '' })) : null, h("input", { class: "select-input", ref: el => (this.input = el), "aria-controls": this.isPillboxActive() ? `select-pillbox-${this.id}` : `select-listbox-${this.id}`, "aria-activedescendant": this.activeDescendant, onInput: () => this.onInput(), value: !this.multiple ? this.state.term : undefined, placeholder: this.placeholder, disabled: this.disabled || this.state.isResolving })), this.state.isResolving && h("cat-spinner", null), (this.state.selection.length || this.state.term.length) &&
|
|
5424
5491
|
!this.disabled &&
|
|
5425
5492
|
!this.state.isResolving &&
|
|
5426
|
-
this.clearable ? (h("cat-button", { id: `select-clear-btn-${this.id}`, iconOnly: true, icon: "cross-circle-outlined", variant: "text", size: "s", a11yLabel: this.i18n.t('input.clear'), onClick: () => this.clear() })) : null, !this.state.isResolving && (h("cat-button", { iconOnly: true, icon: "chevron-down-outlined", class: { 'select-btn': true, 'select-btn-open': this.state.isOpen }, variant: "text", size: "s", a11yLabel: this.state.isOpen ? this.i18n.t('select.close') : this.i18n.t('select.open'), "aria-controls": `select-listbox-${this.id}`, "aria-expanded": this.state.isOpen, tabIndex: -1, disabled: this.disabled || this.state.isResolving }))), this.hintSection, h("div", { class: "select-dropdown", ref: el => (this.dropdown = el), style: { display: this.state.isOpen ? 'block' : undefined } }, this.state.isOpen && (h("cat-scrollable", { class: "select-options-wrapper", scrolledBuffer: 56, noOverflowX: true, noOverscroll: true, noScrolledInit: true, onScrolledBottom: () => this.more$.next() }, h("ul", { class: "select-options", role: "listbox", "aria-multiselectable": this.multiple, "aria-setsize": this.state.totalElements, id: `select-listbox-${this.id}` }, this.
|
|
5427
|
-
this.toggle(item);
|
|
5428
|
-
e.stopPropagation();
|
|
5429
|
-
} }, h("span", { slot: "label", class: "select-option-inner" }, item.render.avatar ? (h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, initials: '' })) : null, h("span", { class: "select-option-text" }, h("span", { class: "select-option-label" }, item.render.label), h("span", { class: "select-option-description" }, item.render.description))))) : (h("div", { class: {
|
|
5430
|
-
'select-option-inner': true,
|
|
5431
|
-
'select-option-single': true,
|
|
5432
|
-
'select-option-active': this.state.activeOptionIndex === i
|
|
5433
|
-
}, onFocus: () => { var _a; return (_a = this.input) === null || _a === void 0 ? void 0 : _a.focus(); }, onClick: () => this.select(item), tabIndex: -1 }, item.render.avatar ? (h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, initials: '' })) : null, h("span", { class: "select-option-text" }, h("span", { class: "select-option-label" }, item.render.label), h("span", { class: "select-option-description" }, item.render.description))))))), this.state.isLoading
|
|
5493
|
+
this.clearable ? (h("cat-button", { id: `select-clear-btn-${this.id}`, iconOnly: true, icon: "cross-circle-outlined", variant: "text", size: "s", a11yLabel: this.i18n.t('input.clear'), onClick: () => this.clear() })) : null, !this.state.isResolving && (h("cat-button", { iconOnly: true, icon: "chevron-down-outlined", class: { 'select-btn': true, 'select-btn-open': this.state.isOpen }, variant: "text", size: "s", a11yLabel: this.state.isOpen ? this.i18n.t('select.close') : this.i18n.t('select.open'), "aria-controls": `select-listbox-${this.id}`, "aria-expanded": this.state.isOpen, tabIndex: -1, disabled: this.disabled || this.state.isResolving }))), this.hintSection, h("div", { class: "select-dropdown", ref: el => (this.dropdown = el), style: { display: this.state.isOpen ? 'block' : undefined } }, this.state.isOpen && (h("cat-scrollable", { class: "select-options-wrapper", scrolledBuffer: 56, noOverflowX: true, noOverscroll: true, noScrolledInit: true, onScrolledBottom: () => this.more$.next() }, h("ul", { class: "select-options", role: "listbox", "aria-multiselectable": this.multiple, "aria-setsize": this.state.totalElements, id: `select-listbox-${this.id}` }, this.optionsList, this.state.isLoading
|
|
5434
5494
|
? Array.from(Array(CatSelect.SKELETON_COUNT)).map(() => (h("li", { class: "select-option-loading" }, h("cat-skeleton", { variant: "body", lines: 1 }), h("cat-skeleton", { variant: "body", lines: 1 }))))
|
|
5435
|
-
: !this.state.options.length &&
|
|
5495
|
+
: !this.state.options.length &&
|
|
5496
|
+
!this.tags && h("li", { class: "select-option-empty" }, this.i18n.t('select.empty'))))))));
|
|
5497
|
+
}
|
|
5498
|
+
get optionsList() {
|
|
5499
|
+
return this.state.options.map((item, i) => {
|
|
5500
|
+
const isTagOption = this.tags && item.item.id === `select-${this.id}-option-tag`;
|
|
5501
|
+
const getAriaSelected = () => {
|
|
5502
|
+
if (isTagOption) {
|
|
5503
|
+
return this.isAlreadyCreated(item.render.label) ? 'true' : 'false';
|
|
5504
|
+
}
|
|
5505
|
+
return this.isSelected(item.item.id) ? 'true' : 'false';
|
|
5506
|
+
};
|
|
5507
|
+
const getLabel = () => {
|
|
5508
|
+
if (isTagOption) {
|
|
5509
|
+
return item.render.label + this.tagTextHelp;
|
|
5510
|
+
}
|
|
5511
|
+
return item.render.label;
|
|
5512
|
+
};
|
|
5513
|
+
return (h("li", { role: "option", class: "select-option", id: `select-${this.id}-option-${i}`, "aria-selected": getAriaSelected() }, this.multiple ? (h("cat-checkbox", { class: { 'select-option-active': this.state.activeOptionIndex === i }, checked: !isTagOption ? this.isSelected(item.item.id) : this.isAlreadyCreated(item.render.label), tabIndex: -1, labelLeft: true, onFocus: () => { var _a; return (_a = this.input) === null || _a === void 0 ? void 0 : _a.focus(); }, onCatChange: e => {
|
|
5514
|
+
!isTagOption ? this.toggle(item) : this.toggleTag(item);
|
|
5515
|
+
e.stopPropagation();
|
|
5516
|
+
} }, h("span", { slot: "label", class: "select-option-inner" }, item.render.avatar ? (h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, initials: '' })) : null, h("span", { class: "select-option-text" }, h("span", { class: "select-option-label" }, getLabel()), h("span", { class: "select-option-description" }, item.render.description))))) : (h("div", { class: {
|
|
5517
|
+
'select-option-inner': true,
|
|
5518
|
+
'select-option-single': true,
|
|
5519
|
+
'select-option-active': this.state.activeOptionIndex === i
|
|
5520
|
+
}, onFocus: () => { var _a; return (_a = this.input) === null || _a === void 0 ? void 0 : _a.focus(); }, onClick: () => (isTagOption ? this.createTag(item.render.label) : this.select(item)), tabIndex: -1 }, item.render.avatar ? (h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, initials: '' })) : null, h("span", { class: "select-option-text" }, h("span", { class: "select-option-label" }, getLabel()), h("span", { class: "select-option-description" }, item.render.description))))));
|
|
5521
|
+
});
|
|
5436
5522
|
}
|
|
5437
5523
|
get hintSection() {
|
|
5438
5524
|
const hasSlottedHint = !!this.hostElement.querySelector('[slot="hint"]');
|
|
@@ -5445,21 +5531,27 @@ const CatSelect = class {
|
|
|
5445
5531
|
throw new Error('CatSelectConnector not set');
|
|
5446
5532
|
}
|
|
5447
5533
|
resolve() {
|
|
5448
|
-
var _a;
|
|
5449
5534
|
this.patchState({ isResolving: true });
|
|
5450
|
-
|
|
5451
|
-
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
|
|
5457
|
-
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
|
|
5462
|
-
|
|
5535
|
+
const ids = this.initIds();
|
|
5536
|
+
let tags;
|
|
5537
|
+
if (this.tags) {
|
|
5538
|
+
tags = this.initTags();
|
|
5539
|
+
}
|
|
5540
|
+
const data$ = ids.length ? this.connectorSafe.resolve(ids).pipe(first()) : of([]);
|
|
5541
|
+
data$.pipe(catchError(() => of([]))).subscribe(items => {
|
|
5542
|
+
const selection = items.length ? items === null || items === void 0 ? void 0 : items.map(item => ({ item, render: this.connectorSafe.render(item) })) : [];
|
|
5543
|
+
if (this.tags) {
|
|
5544
|
+
tags === null || tags === void 0 ? void 0 : tags.forEach((tag, index) => {
|
|
5545
|
+
const item = { id: `select-${this.id}-tag-${index}`, name: tag };
|
|
5546
|
+
selection.push({ item, render: { label: item.name } });
|
|
5547
|
+
});
|
|
5548
|
+
}
|
|
5549
|
+
this.patchState({
|
|
5550
|
+
isResolving: false,
|
|
5551
|
+
selection,
|
|
5552
|
+
term: !this.multiple && selection.length ? selection[0].render.label : ''
|
|
5553
|
+
});
|
|
5554
|
+
});
|
|
5463
5555
|
}
|
|
5464
5556
|
show() {
|
|
5465
5557
|
var _a;
|
|
@@ -5484,7 +5576,6 @@ const CatSelect = class {
|
|
|
5484
5576
|
return this.state.selection.findIndex(s => s.item.id === id) >= 0;
|
|
5485
5577
|
}
|
|
5486
5578
|
select(item) {
|
|
5487
|
-
var _a;
|
|
5488
5579
|
if (!this.isSelected(item.item.id)) {
|
|
5489
5580
|
let newSelection;
|
|
5490
5581
|
if (this.multiple) {
|
|
@@ -5495,11 +5586,13 @@ const CatSelect = class {
|
|
|
5495
5586
|
this.search(item.render.label);
|
|
5496
5587
|
}
|
|
5497
5588
|
this.patchState({ selection: newSelection });
|
|
5589
|
+
if (this.multiple && this.state.term.trim() && this.input) {
|
|
5590
|
+
this.patchState({ term: '', activeOptionIndex: -1 });
|
|
5591
|
+
this.term$.next('');
|
|
5592
|
+
this.input.value = '';
|
|
5593
|
+
}
|
|
5498
5594
|
}
|
|
5499
|
-
|
|
5500
|
-
this.hide();
|
|
5501
|
-
(_a = this.input) === null || _a === void 0 ? void 0 : _a.classList.add('select-input-transparent-caret');
|
|
5502
|
-
}
|
|
5595
|
+
this.setTransparentCaret();
|
|
5503
5596
|
}
|
|
5504
5597
|
deselect(id) {
|
|
5505
5598
|
if (this.isSelected(id)) {
|
|
@@ -5546,7 +5639,12 @@ const CatSelect = class {
|
|
|
5546
5639
|
}
|
|
5547
5640
|
onInput() {
|
|
5548
5641
|
var _a;
|
|
5549
|
-
this.search(((_a = this.input) === null || _a === void 0 ? void 0 : _a.value) || '');
|
|
5642
|
+
this.search(((_a = this.input) === null || _a === void 0 ? void 0 : _a.value.trim()) || '');
|
|
5643
|
+
if (!this.multiple && this.state.selection.length) {
|
|
5644
|
+
const selectionClone = [...this.state.selection];
|
|
5645
|
+
selectionClone.pop();
|
|
5646
|
+
this.patchState({ selection: selectionClone });
|
|
5647
|
+
}
|
|
5550
5648
|
this.show();
|
|
5551
5649
|
}
|
|
5552
5650
|
update() {
|
|
@@ -5584,52 +5682,122 @@ const CatSelect = class {
|
|
|
5584
5682
|
var _a, _b;
|
|
5585
5683
|
let preventDefault = false;
|
|
5586
5684
|
(_a = this.input) === null || _a === void 0 ? void 0 : _a.focus();
|
|
5587
|
-
|
|
5588
|
-
|
|
5589
|
-
this.state.isOpen
|
|
5590
|
-
? this.patchState({
|
|
5591
|
-
activeOptionIndex: Math.min(this.state.activeOptionIndex + 1, this.state.options.length - 1),
|
|
5592
|
-
activeSelectionIndex: -1
|
|
5593
|
-
})
|
|
5594
|
-
: this.show();
|
|
5595
|
-
}
|
|
5596
|
-
else if (event.key === 'ArrowUp') {
|
|
5597
|
-
preventDefault = true;
|
|
5598
|
-
this.state.activeOptionIndex >= 0
|
|
5599
|
-
? this.patchState({
|
|
5600
|
-
activeOptionIndex: Math.max(this.state.activeOptionIndex - 1, -1),
|
|
5601
|
-
activeSelectionIndex: -1
|
|
5602
|
-
})
|
|
5603
|
-
: this.hide();
|
|
5604
|
-
}
|
|
5605
|
-
else if (event.key === 'ArrowLeft') {
|
|
5606
|
-
if (((_b = this.input) === null || _b === void 0 ? void 0 : _b.selectionStart) === 0) {
|
|
5685
|
+
switch (event.key) {
|
|
5686
|
+
case 'ArrowDown':
|
|
5607
5687
|
preventDefault = true;
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
|
|
5613
|
-
|
|
5614
|
-
|
|
5615
|
-
|
|
5616
|
-
if (this.state.activeSelectionIndex >= 0) {
|
|
5688
|
+
this.state.isOpen
|
|
5689
|
+
? this.patchState({
|
|
5690
|
+
activeOptionIndex: Math.min(this.state.activeOptionIndex + 1, this.state.options.length - 1),
|
|
5691
|
+
activeSelectionIndex: -1
|
|
5692
|
+
})
|
|
5693
|
+
: this.show();
|
|
5694
|
+
break;
|
|
5695
|
+
case 'ArrowUp':
|
|
5617
5696
|
preventDefault = true;
|
|
5618
|
-
|
|
5619
|
-
|
|
5620
|
-
|
|
5697
|
+
this.state.activeOptionIndex >= 0
|
|
5698
|
+
? this.patchState({
|
|
5699
|
+
activeOptionIndex: Math.max(this.state.activeOptionIndex - 1, -1),
|
|
5700
|
+
activeSelectionIndex: -1
|
|
5701
|
+
})
|
|
5702
|
+
: this.hide();
|
|
5703
|
+
break;
|
|
5704
|
+
case 'ArrowLeft':
|
|
5705
|
+
if (((_b = this.input) === null || _b === void 0 ? void 0 : _b.selectionStart) === 0) {
|
|
5706
|
+
preventDefault = true;
|
|
5707
|
+
let index;
|
|
5708
|
+
this.state.activeSelectionIndex > 0
|
|
5709
|
+
? (index = Math.max(this.state.activeSelectionIndex - 1, -1))
|
|
5710
|
+
: (index = this.state.selection.length - 1);
|
|
5711
|
+
this.patchState({ activeSelectionIndex: index, activeOptionIndex: -1 });
|
|
5621
5712
|
}
|
|
5622
|
-
|
|
5623
|
-
|
|
5713
|
+
break;
|
|
5714
|
+
case 'ArrowRight':
|
|
5715
|
+
if (this.state.activeSelectionIndex >= 0) {
|
|
5716
|
+
preventDefault = true;
|
|
5717
|
+
let index = -1;
|
|
5718
|
+
if (this.state.activeSelectionIndex < this.state.selection.length - 1) {
|
|
5719
|
+
index = Math.min(this.state.activeSelectionIndex + 1, this.state.selection.length - 1);
|
|
5720
|
+
}
|
|
5721
|
+
else if (!this.state.term) {
|
|
5722
|
+
index = 0;
|
|
5723
|
+
}
|
|
5724
|
+
this.patchState({ activeSelectionIndex: index, activeOptionIndex: -1 });
|
|
5624
5725
|
}
|
|
5625
|
-
this.patchState({ activeSelectionIndex: index, activeOptionIndex: -1 });
|
|
5626
|
-
}
|
|
5627
5726
|
}
|
|
5628
5727
|
if (preventDefault) {
|
|
5629
5728
|
event.preventDefault();
|
|
5630
5729
|
event.stopPropagation();
|
|
5631
5730
|
}
|
|
5632
5731
|
}
|
|
5732
|
+
get tagTextHelp() {
|
|
5733
|
+
return this.tagHint && !this.isAlreadyCreated(this.state.term) ? ' (' + this.tagHint + ')' : '';
|
|
5734
|
+
}
|
|
5735
|
+
isAlreadyCreated(term) {
|
|
5736
|
+
return this.state.selection.findIndex(item => item.render.label.toLowerCase() === term.toLowerCase()) >= 0;
|
|
5737
|
+
}
|
|
5738
|
+
createTag(term) {
|
|
5739
|
+
if (term.trim().length && !this.isAlreadyCreated(term)) {
|
|
5740
|
+
const value = this.value;
|
|
5741
|
+
const tags = value === null || value === void 0 ? void 0 : value.tags;
|
|
5742
|
+
const tag = { id: `select-${this.id}-tag-${tags ? tags.length : 0}`, name: term };
|
|
5743
|
+
this.select({ item: tag, render: { label: tag.name } });
|
|
5744
|
+
}
|
|
5745
|
+
this.setTransparentCaret();
|
|
5746
|
+
}
|
|
5747
|
+
initIds() {
|
|
5748
|
+
let ids = [];
|
|
5749
|
+
if (this.value) {
|
|
5750
|
+
if (!this.tags) {
|
|
5751
|
+
if (this.multiple) {
|
|
5752
|
+
ids = this.value;
|
|
5753
|
+
}
|
|
5754
|
+
else {
|
|
5755
|
+
ids = [this.value];
|
|
5756
|
+
}
|
|
5757
|
+
}
|
|
5758
|
+
else {
|
|
5759
|
+
if (this.multiple) {
|
|
5760
|
+
const value = this.value;
|
|
5761
|
+
ids = value.ids ? value.ids : [];
|
|
5762
|
+
}
|
|
5763
|
+
else {
|
|
5764
|
+
const value = this.value;
|
|
5765
|
+
ids = value.id ? [value.id] : [];
|
|
5766
|
+
}
|
|
5767
|
+
}
|
|
5768
|
+
}
|
|
5769
|
+
return ids;
|
|
5770
|
+
}
|
|
5771
|
+
initTags() {
|
|
5772
|
+
let tags = [];
|
|
5773
|
+
if (this.value) {
|
|
5774
|
+
if (this.multiple) {
|
|
5775
|
+
const value = this.value;
|
|
5776
|
+
tags = value.tags ? value.tags : [];
|
|
5777
|
+
}
|
|
5778
|
+
else {
|
|
5779
|
+
const value = this.value;
|
|
5780
|
+
tags = value.tag ? [value.tag] : [];
|
|
5781
|
+
}
|
|
5782
|
+
}
|
|
5783
|
+
return tags;
|
|
5784
|
+
}
|
|
5785
|
+
toggleTag(item) {
|
|
5786
|
+
this.isAlreadyCreated(item.render.label) ? this.removeTag(item.render.label) : this.createTag(item.render.label);
|
|
5787
|
+
}
|
|
5788
|
+
removeTag(label) {
|
|
5789
|
+
if (this.isAlreadyCreated(label)) {
|
|
5790
|
+
const item = this.state.selection.find(item => item.render.label.toLowerCase() === label.toLowerCase());
|
|
5791
|
+
item && this.deselect(item.item.id);
|
|
5792
|
+
}
|
|
5793
|
+
}
|
|
5794
|
+
setTransparentCaret() {
|
|
5795
|
+
var _a;
|
|
5796
|
+
if (!this.multiple) {
|
|
5797
|
+
this.hide();
|
|
5798
|
+
(_a = this.input) === null || _a === void 0 ? void 0 : _a.classList.add('select-input-transparent-caret');
|
|
5799
|
+
}
|
|
5800
|
+
}
|
|
5633
5801
|
get hostElement() { return getElement(this); }
|
|
5634
5802
|
static get watchers() { return {
|
|
5635
5803
|
"connector": ["onConnectorChange"],
|
|
@@ -5645,7 +5813,7 @@ const CatSelectTest = class {
|
|
|
5645
5813
|
registerInstance(this, hostRef);
|
|
5646
5814
|
}
|
|
5647
5815
|
componentDidLoad() {
|
|
5648
|
-
var _a, _b, _c, _d;
|
|
5816
|
+
var _a, _b, _c, _d, _e, _f;
|
|
5649
5817
|
(_a = this.multipleSelect) === null || _a === void 0 ? void 0 : _a.connect({
|
|
5650
5818
|
resolve: (ids) => {
|
|
5651
5819
|
console.info(`Resolving data... (${ids.join(', ')})`);
|
|
@@ -5710,31 +5878,45 @@ const CatSelectTest = class {
|
|
|
5710
5878
|
}
|
|
5711
5879
|
})
|
|
5712
5880
|
});
|
|
5713
|
-
(_c = this.
|
|
5881
|
+
(_c = this.multipleSelectTagging) === null || _c === void 0 ? void 0 : _c.connect(Object.assign(Object.assign({}, this.countryConnector), { customId: (item) => item.country }));
|
|
5882
|
+
(_d = this.singleSelect) === null || _d === void 0 ? void 0 : _d.connect({
|
|
5714
5883
|
resolve: (ids) => {
|
|
5715
5884
|
console.info(`Resolving data... (${ids.join(', ')})`);
|
|
5716
|
-
return of(ids.map(id =>
|
|
5885
|
+
return of(ids.map(id => ({
|
|
5886
|
+
id,
|
|
5887
|
+
firstName: 'John',
|
|
5888
|
+
lastName: `Doe (${id})`,
|
|
5889
|
+
desc: 'resolved'
|
|
5890
|
+
}))).pipe(delay(500));
|
|
5717
5891
|
},
|
|
5718
5892
|
retrieve: (term, page) => {
|
|
5719
5893
|
console.info(`Retrieving data... ("${term}", ${page})`);
|
|
5720
|
-
|
|
5721
|
-
|
|
5722
|
-
|
|
5723
|
-
|
|
5724
|
-
|
|
5725
|
-
|
|
5726
|
-
|
|
5727
|
-
|
|
5728
|
-
|
|
5729
|
-
|
|
5730
|
-
|
|
5894
|
+
return term === 'no'
|
|
5895
|
+
? of({ last: true, content: [], totalElements: 0 })
|
|
5896
|
+
: of({
|
|
5897
|
+
last: false,
|
|
5898
|
+
totalElements: 10000,
|
|
5899
|
+
content: Array.from({ length: 10 }, (_, i) => ({
|
|
5900
|
+
id: '' + (i + page * 10),
|
|
5901
|
+
firstName: 'John',
|
|
5902
|
+
lastName: `Doe (${i + page * 10})`,
|
|
5903
|
+
desc: `"${term}": page ${page}`
|
|
5904
|
+
}))
|
|
5905
|
+
}).pipe(delay(500));
|
|
5731
5906
|
},
|
|
5732
|
-
render: (
|
|
5733
|
-
label:
|
|
5734
|
-
description:
|
|
5907
|
+
render: (user) => ({
|
|
5908
|
+
label: `${user.firstName} ${user.lastName}`,
|
|
5909
|
+
description: user.desc
|
|
5735
5910
|
})
|
|
5736
5911
|
});
|
|
5737
|
-
(
|
|
5912
|
+
(_e = this.singleSelectAvatar) === null || _e === void 0 ? void 0 : _e.connect(Object.assign(Object.assign({}, this.countryConnector), { customId: (item) => item.country }));
|
|
5913
|
+
(_f = this.singleSelectTagging) === null || _f === void 0 ? void 0 : _f.connect(this.countryConnector);
|
|
5914
|
+
}
|
|
5915
|
+
render() {
|
|
5916
|
+
return (h(Host, { style: { display: 'flex', flexDirection: 'column' } }, h("cat-select", { label: "Multiple Select", hint: "This is a hint!", ref: el => (this.multipleSelect = el), value: ['1'], placeholder: "Hello World", onCatChange: () => { var _a; return console.log((_a = this.multipleSelect) === null || _a === void 0 ? void 0 : _a.value); }, onCatBlur: e => console.log('Multiple blur', e), multiple: true, clearable: true }, h("span", { slot: "hint" }, "Searching for \"no\" -", '>', " no options are returned!")), h("cat-select", { label: "Multiple with img", ref: el => (this.multipleSelectAvatar = el), value: ['1'], placeholder: "Hello World", multiple: true, clearable: true }), h("cat-select", { label: "Multiple with tagging support", hint: "This is a hint!", ref: el => (this.multipleSelectTagging = el), value: { ids: ['1'], tags: ['Test', 'Albania'] }, placeholder: "Select country", onCatChange: () => { var _a; return console.log((_a = this.multipleSelectTagging) === null || _a === void 0 ? void 0 : _a.value); }, multiple: true, tags: true, clearable: true }), h("cat-select", { label: "Single Select", hint: "This is a hint!", ref: el => (this.singleSelect = el), placeholder: "Search for a country or capital", onCatBlur: e => console.log('Single blur', e), clearable: true }), h("cat-select", { label: "Single with img", ref: el => (this.singleSelectAvatar = el), value: '1', onCatChange: () => { var _a; return console.log((_a = this.singleSelectAvatar) === null || _a === void 0 ? void 0 : _a.value); }, placeholder: "Search for a country or capital", clearable: true }), h("cat-select", { label: "Single with tagging support", ref: el => (this.singleSelectTagging = el), value: { id: '1', tag: '' }, placeholder: "Search for a country or capital", onCatChange: () => { var _a; return console.log('Single', (_a = this.singleSelectTagging) === null || _a === void 0 ? void 0 : _a.value); }, tagHint: "new country", tags: true, clearable: true })));
|
|
5917
|
+
}
|
|
5918
|
+
get countryConnector() {
|
|
5919
|
+
return {
|
|
5738
5920
|
resolve: (ids) => {
|
|
5739
5921
|
console.info(`Resolving data... (${ids.join(', ')})`);
|
|
5740
5922
|
return of(ids.map(id => countries.find(value => value.id === id))).pipe(delay(500));
|
|
@@ -5761,10 +5943,7 @@ const CatSelectTest = class {
|
|
|
5761
5943
|
round: true
|
|
5762
5944
|
}
|
|
5763
5945
|
})
|
|
5764
|
-
}
|
|
5765
|
-
}
|
|
5766
|
-
render() {
|
|
5767
|
-
return (h(Host, { style: { display: 'flex', flexDirection: 'column' } }, h("cat-select", { label: "Multiple Select", hint: "This is a hint!", ref: el => (this.multipleSelect = el), value: ['1'], placeholder: "Hello World", onCatChange: e => console.log('Multiple', e), onCatBlur: e => console.log('Multiple blur', e), multiple: true, clearable: true }, h("span", { slot: "hint" }, "Searching for \"no\" -", '>', " no options are returned!")), h("cat-select", { label: "Multiple with img", ref: el => (this.multipleSelectAvatar = el), value: ['1'], placeholder: "Hello World", multiple: true, clearable: true }), h("cat-select", { label: "Single Select", hint: "This is a hint!", ref: el => (this.singleSelect = el), value: '1', placeholder: "Search for a country or capital", onCatChange: e => console.log('Single', e), onCatBlur: e => console.log('Single blur', e), clearable: true }), h("cat-select", { label: "Single with img", ref: el => (this.singleSelectAvatar = el), value: '1', placeholder: "Search for a country or capital", clearable: true })));
|
|
5946
|
+
};
|
|
5768
5947
|
}
|
|
5769
5948
|
};
|
|
5770
5949
|
const countries = [
|
|
@@ -7380,7 +7559,7 @@ CatToggle.style = catToggleCss;
|
|
|
7380
7559
|
|
|
7381
7560
|
const isTouchDevice = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
|
|
7382
7561
|
|
|
7383
|
-
const catTooltipCss = ":host{display:contents}:host([hidden]){display:none}.tooltip{position:absolute;font-size:0.875rem;line-height:1rem;font-weight:500;
|
|
7562
|
+
const catTooltipCss = ":host{display:contents}:host([hidden]){display:none}.tooltip{position:absolute;font-size:0.875rem;line-height:1rem;font-weight:500;background-color:black;border-radius:0.25rem;color:white;transition:opacity 0.25s linear, visibility 0.25s linear;visibility:hidden;opacity:0;box-shadow:rgba(0, 0, 0, 0.08) 0 1px 8px 0;z-index:200;max-width:20rem}.tooltip-show{opacity:1;visibility:visible}.tooltip-round{border-radius:10rem}.tooltip-s{padding:0.375rem 0.5rem}.tooltip-s.tooltip-round{padding:0.375rem 0.75rem}.tooltip-m{padding:0.75rem}.tooltip-m.tooltip-round{padding:0.75rem 1rem}.tooltip-l{padding:1rem}.tooltip-l.tooltip-round{padding:1rem 1.5rem}.tooltip-trigger{display:inline-block}.tooltip-trigger:focus{outline:none}";
|
|
7384
7563
|
|
|
7385
7564
|
let nextUniqueId = 0;
|
|
7386
7565
|
const CatTooltip = class {
|
|
@@ -7400,10 +7579,18 @@ const CatTooltip = class {
|
|
|
7400
7579
|
* The placement of the tooltip.
|
|
7401
7580
|
*/
|
|
7402
7581
|
this.placement = 'top';
|
|
7582
|
+
/**
|
|
7583
|
+
* Use round tooltip edges.
|
|
7584
|
+
*/
|
|
7585
|
+
this.round = false;
|
|
7586
|
+
/**
|
|
7587
|
+
* The size of the tooltip.
|
|
7588
|
+
*/
|
|
7589
|
+
this.size = 'm';
|
|
7403
7590
|
/**
|
|
7404
7591
|
* The delay time for showing tooltip in ms.
|
|
7405
7592
|
*/
|
|
7406
|
-
this.showDelay =
|
|
7593
|
+
this.showDelay = 250;
|
|
7407
7594
|
/**
|
|
7408
7595
|
* The delay time for hiding tooltip in ms.
|
|
7409
7596
|
*/
|
|
@@ -7452,7 +7639,11 @@ const CatTooltip = class {
|
|
|
7452
7639
|
}
|
|
7453
7640
|
}
|
|
7454
7641
|
render() {
|
|
7455
|
-
return (h(Host, null, h("div", { ref: el => (this.triggerElement = el), "aria-describedby": this.id, class: "tooltip-trigger" }, h("slot", null)), this.content && !this.disabled && (h("div", { ref: el => (this.tooltip = el), id: this.id, class:
|
|
7642
|
+
return (h(Host, null, h("div", { ref: el => (this.triggerElement = el), "aria-describedby": this.id, class: "tooltip-trigger" }, h("slot", null)), this.content && !this.disabled && (h("div", { ref: el => (this.tooltip = el), id: this.id, class: {
|
|
7643
|
+
tooltip: true,
|
|
7644
|
+
'tooltip-round': this.round,
|
|
7645
|
+
[`tooltip-${this.size}`]: Boolean(this.size)
|
|
7646
|
+
} }, this.content))));
|
|
7456
7647
|
}
|
|
7457
7648
|
get isTabbable() {
|
|
7458
7649
|
return firstTabbable(this.trigger);
|