@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
|
@@ -5,7 +5,16 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
const index = require('./index-8ab22379.js');
|
|
6
6
|
const catNotification = require('./cat-notification-bcb9fb86.js');
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
function setAttributeDefault(host, attr, value) {
|
|
9
|
+
if (!host.hostElement.hasAttribute(attr) && value != null) {
|
|
10
|
+
host.hostElement.setAttribute(attr, String(value));
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function setPropertyDefault(host, prop) {
|
|
14
|
+
setAttributeDefault(host, String(prop), host[prop]);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
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}";
|
|
9
18
|
|
|
10
19
|
const CatAlert = class {
|
|
11
20
|
constructor(hostRef) {
|
|
@@ -17,6 +26,13 @@ const CatAlert = class {
|
|
|
17
26
|
['warning', 'danger-filled'],
|
|
18
27
|
['danger', 'cross-circle-filled']
|
|
19
28
|
]);
|
|
29
|
+
this.mapRole = new Map([
|
|
30
|
+
['primary', 'status'],
|
|
31
|
+
['secondary', 'status'],
|
|
32
|
+
['success', 'status'],
|
|
33
|
+
['warning', 'alert'],
|
|
34
|
+
['danger', 'alert']
|
|
35
|
+
]);
|
|
20
36
|
/**
|
|
21
37
|
* The color palette of the alert.
|
|
22
38
|
*/
|
|
@@ -26,21 +42,15 @@ const CatAlert = class {
|
|
|
26
42
|
*/
|
|
27
43
|
this.noIcon = false;
|
|
28
44
|
}
|
|
45
|
+
connectedCallback() {
|
|
46
|
+
setAttributeDefault(this, 'tabindex', 0);
|
|
47
|
+
setAttributeDefault(this, 'role', this.mapRole.get(this.color));
|
|
48
|
+
setPropertyDefault(this, 'color');
|
|
49
|
+
}
|
|
29
50
|
render() {
|
|
30
|
-
return (index.h(index.Host, {
|
|
31
|
-
alert: true,
|
|
32
|
-
[`alert-${this.color}`]: Boolean(this.color)
|
|
33
|
-
} }, !this.noIcon && index.h("cat-icon", { size: "l", icon: this.icon ? this.icon : this.mapIcon.get(this.color) }), index.h("div", { class: "content" }, index.h("slot", null)))));
|
|
34
|
-
}
|
|
35
|
-
get role() {
|
|
36
|
-
switch (this.color) {
|
|
37
|
-
case 'danger':
|
|
38
|
-
case 'warning':
|
|
39
|
-
return 'alert';
|
|
40
|
-
default:
|
|
41
|
-
return 'status';
|
|
42
|
-
}
|
|
51
|
+
return (index.h(index.Host, null, !this.noIcon && index.h("cat-icon", { size: "l", icon: this.icon ? this.icon : this.mapIcon.get(this.color) }), index.h("div", { class: "content" }, index.h("slot", null))));
|
|
43
52
|
}
|
|
53
|
+
get hostElement() { return index.getElement(this); }
|
|
44
54
|
};
|
|
45
55
|
CatAlert.style = catAlertCss;
|
|
46
56
|
|
|
@@ -59,7 +69,7 @@ const loadImg = (src) => {
|
|
|
59
69
|
});
|
|
60
70
|
};
|
|
61
71
|
|
|
62
|
-
const catAvatarCss = ":host{display:
|
|
72
|
+
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)}";
|
|
63
73
|
|
|
64
74
|
const CatAvatar = class {
|
|
65
75
|
constructor(hostRef) {
|
|
@@ -129,7 +139,7 @@ const CatAvatar = class {
|
|
|
129
139
|
};
|
|
130
140
|
CatAvatar.style = catAvatarCss;
|
|
131
141
|
|
|
132
|
-
const catBadgeCss = ":host{display:inline-
|
|
142
|
+
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)}}";
|
|
133
143
|
|
|
134
144
|
const CatBadge = class {
|
|
135
145
|
constructor(hostRef) {
|
|
@@ -155,16 +165,15 @@ const CatBadge = class {
|
|
|
155
165
|
*/
|
|
156
166
|
this.pulse = false;
|
|
157
167
|
}
|
|
168
|
+
connectedCallback() {
|
|
169
|
+
setPropertyDefault(this, 'variant');
|
|
170
|
+
setPropertyDefault(this, 'color');
|
|
171
|
+
setPropertyDefault(this, 'size');
|
|
172
|
+
}
|
|
158
173
|
render() {
|
|
159
|
-
return
|
|
160
|
-
badge: true,
|
|
161
|
-
'badge-round': this.round,
|
|
162
|
-
'badge-pulse': this.pulse,
|
|
163
|
-
[`badge-${this.variant}`]: Boolean(this.variant),
|
|
164
|
-
[`badge-${this.color}`]: Boolean(this.color),
|
|
165
|
-
[`badge-${this.size}`]: Boolean(this.size)
|
|
166
|
-
} }, index.h("slot", null)));
|
|
174
|
+
return index.h("slot", null);
|
|
167
175
|
}
|
|
176
|
+
get hostElement() { return index.getElement(this); }
|
|
168
177
|
};
|
|
169
178
|
CatBadge.style = catBadgeCss;
|
|
170
179
|
|
|
@@ -467,7 +476,7 @@ const CatCard = class {
|
|
|
467
476
|
index.registerInstance(this, hostRef);
|
|
468
477
|
}
|
|
469
478
|
render() {
|
|
470
|
-
return
|
|
479
|
+
return index.h("slot", null);
|
|
471
480
|
}
|
|
472
481
|
};
|
|
473
482
|
CatCard.style = catCardCss;
|
|
@@ -487,7 +496,7 @@ const CatFormHint = props => {
|
|
|
487
496
|
]));
|
|
488
497
|
};
|
|
489
498
|
|
|
490
|
-
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:
|
|
499
|
+
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))}";
|
|
491
500
|
|
|
492
501
|
let nextUniqueId$8 = 0;
|
|
493
502
|
const CatCheckbox = class {
|
|
@@ -5223,7 +5232,7 @@ var autosizeInput = function (element, options) {
|
|
|
5223
5232
|
}
|
|
5224
5233
|
};
|
|
5225
5234
|
|
|
5226
|
-
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:#
|
|
5235
|
+
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))}";
|
|
5227
5236
|
|
|
5228
5237
|
const INIT_STATE = {
|
|
5229
5238
|
term: '',
|
|
@@ -5285,6 +5294,10 @@ const CatSelect = class {
|
|
|
5285
5294
|
* Whether the select should show a clear button.
|
|
5286
5295
|
*/
|
|
5287
5296
|
this.clearable = false;
|
|
5297
|
+
/**
|
|
5298
|
+
* Whether the select should add new items.
|
|
5299
|
+
*/
|
|
5300
|
+
this.tags = false;
|
|
5288
5301
|
}
|
|
5289
5302
|
onConnectorChange(connector) {
|
|
5290
5303
|
this.reset(connector);
|
|
@@ -5304,11 +5317,25 @@ const CatSelect = class {
|
|
|
5304
5317
|
this.hide();
|
|
5305
5318
|
}
|
|
5306
5319
|
const idsSelected = this.state.selection.map(item => item.item.id);
|
|
5307
|
-
if (this.
|
|
5308
|
-
this.
|
|
5320
|
+
if (!this.tags) {
|
|
5321
|
+
if (this.multiple) {
|
|
5322
|
+
this.value = idsSelected;
|
|
5323
|
+
}
|
|
5324
|
+
else {
|
|
5325
|
+
this.value = idsSelected.length ? idsSelected[0] : '';
|
|
5326
|
+
}
|
|
5309
5327
|
}
|
|
5310
5328
|
else {
|
|
5311
|
-
|
|
5329
|
+
const ids = idsSelected.filter(id => !id.startsWith(`select-${this.id}-tag`));
|
|
5330
|
+
const tags = this.state.selection
|
|
5331
|
+
.filter(item => item.item.id.startsWith(`select-${this.id}-tag`))
|
|
5332
|
+
.map(item => item.render.label);
|
|
5333
|
+
if (this.multiple) {
|
|
5334
|
+
this.value = { ids, tags };
|
|
5335
|
+
}
|
|
5336
|
+
else {
|
|
5337
|
+
this.value = { id: ids.length ? ids[0] : '', tag: tags.length ? tags[0] : '' };
|
|
5338
|
+
}
|
|
5312
5339
|
}
|
|
5313
5340
|
this.catChange.emit();
|
|
5314
5341
|
}
|
|
@@ -5329,7 +5356,12 @@ const CatSelect = class {
|
|
|
5329
5356
|
}
|
|
5330
5357
|
onBlur(event) {
|
|
5331
5358
|
if (!this.multiple && this.state.activeOptionIndex >= 0) {
|
|
5332
|
-
this.
|
|
5359
|
+
if (this.tags && this.state.options[this.state.activeOptionIndex].item.id === `select-${this.id}-option-tag`) {
|
|
5360
|
+
this.createTag(this.state.term);
|
|
5361
|
+
}
|
|
5362
|
+
else {
|
|
5363
|
+
this.select(this.state.options[this.state.activeOptionIndex]);
|
|
5364
|
+
}
|
|
5333
5365
|
}
|
|
5334
5366
|
this.hide();
|
|
5335
5367
|
this.patchState({ activeSelectionIndex: -1 });
|
|
@@ -5341,8 +5373,19 @@ const CatSelect = class {
|
|
|
5341
5373
|
if (['ArrowDown', 'ArrowUp', 'ArrowLeft', 'ArrowRight'].includes(event.key)) {
|
|
5342
5374
|
this.onArrowKeyDown(event);
|
|
5343
5375
|
}
|
|
5344
|
-
else if (['Enter', ' '].includes(event.key)) {
|
|
5345
|
-
if (
|
|
5376
|
+
else if (['Enter', ' '].includes(event.key) && isInputFocused) {
|
|
5377
|
+
if (this.tags &&
|
|
5378
|
+
this.state.activeOptionIndex === 0 &&
|
|
5379
|
+
this.state.options[0].item.id === `select-${this.id}-option-tag`) {
|
|
5380
|
+
event.preventDefault();
|
|
5381
|
+
if (this.multiple) {
|
|
5382
|
+
this.toggleTag(this.state.options[0]);
|
|
5383
|
+
}
|
|
5384
|
+
else {
|
|
5385
|
+
this.createTag(this.state.options[0].render.label);
|
|
5386
|
+
}
|
|
5387
|
+
}
|
|
5388
|
+
else if (this.state.activeOptionIndex >= 0) {
|
|
5346
5389
|
event.preventDefault();
|
|
5347
5390
|
if (this.multiple) {
|
|
5348
5391
|
this.toggle(this.state.options[this.state.activeOptionIndex]);
|
|
@@ -5351,6 +5394,9 @@ const CatSelect = class {
|
|
|
5351
5394
|
this.select(this.state.options[this.state.activeOptionIndex]);
|
|
5352
5395
|
}
|
|
5353
5396
|
}
|
|
5397
|
+
else if (this.tags && event.key === 'Enter' && this.state.activeOptionIndex < 0) {
|
|
5398
|
+
this.createTag(this.state.term);
|
|
5399
|
+
}
|
|
5354
5400
|
}
|
|
5355
5401
|
else if (event.key === 'Escape') {
|
|
5356
5402
|
this.hide();
|
|
@@ -5374,7 +5420,12 @@ const CatSelect = class {
|
|
|
5374
5420
|
this.patchState({ activeSelectionIndex: -1, activeOptionIndex: -1 });
|
|
5375
5421
|
}
|
|
5376
5422
|
else if (this.state.activeOptionIndex >= 0) {
|
|
5377
|
-
this.
|
|
5423
|
+
if (this.tags && this.state.options[this.state.activeOptionIndex].item.id === `select-${this.id}-option-tag`) {
|
|
5424
|
+
this.createTag(this.state.term);
|
|
5425
|
+
}
|
|
5426
|
+
else {
|
|
5427
|
+
this.select(this.state.options[this.state.activeOptionIndex]);
|
|
5428
|
+
}
|
|
5378
5429
|
}
|
|
5379
5430
|
}
|
|
5380
5431
|
else if (event.key.length === 1) {
|
|
@@ -5412,12 +5463,28 @@ const CatSelect = class {
|
|
|
5412
5463
|
this.subscription = this.term$
|
|
5413
5464
|
.asObservable()
|
|
5414
5465
|
.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], []))))
|
|
5415
|
-
.subscribe(items =>
|
|
5416
|
-
|
|
5417
|
-
|
|
5466
|
+
.subscribe(items => {
|
|
5467
|
+
var _a;
|
|
5468
|
+
const options = items === null || items === void 0 ? void 0 : items.map(item => ({
|
|
5469
|
+
item: Object.assign(Object.assign({}, item), { id: this.connectorSafe.customId ? this.connectorSafe.customId(item) : item.id }),
|
|
5418
5470
|
render: this.connectorSafe.render(item)
|
|
5419
|
-
}))
|
|
5420
|
-
|
|
5471
|
+
}));
|
|
5472
|
+
if (this.tags &&
|
|
5473
|
+
this.state.term.trim().length &&
|
|
5474
|
+
!options.find(value1 => value1.render.label.toLowerCase() === this.state.term.toLowerCase())) {
|
|
5475
|
+
let label;
|
|
5476
|
+
if (this.isAlreadyCreated(this.state.term)) {
|
|
5477
|
+
label = (_a = this.state.selection.find(item => item.render.label.toLowerCase() === this.state.term.toLowerCase())) === null || _a === void 0 ? void 0 : _a.render.label;
|
|
5478
|
+
}
|
|
5479
|
+
options.unshift({
|
|
5480
|
+
item: { id: `select-${this.id}-option-tag` },
|
|
5481
|
+
render: { label: label ? label : this.state.term }
|
|
5482
|
+
});
|
|
5483
|
+
}
|
|
5484
|
+
this.patchState({
|
|
5485
|
+
options
|
|
5486
|
+
});
|
|
5487
|
+
});
|
|
5421
5488
|
}
|
|
5422
5489
|
render() {
|
|
5423
5490
|
return (index.h(index.Host, null, (this.hasSlottedLabel || this.label) && (index.h("label", { htmlFor: this.id, class: { hidden: this.labelHidden } }, index.h("span", { part: "label" }, (this.hasSlottedLabel && index.h("slot", { name: "label" })) || this.label, !this.required && (index.h("span", { class: "input-optional", "aria-hidden": "true" }, "(", this.i18n.t('input.optional'), ")"))))), index.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) }, index.h("div", { class: "select-wrapper-inner" }, this.multiple && this.state.selection.length ? (index.h("div", { id: `select-pillbox-${this.id}`, role: "listbox", "aria-orientation": "horizontal", class: "select-pills" }, this.state.selection.map((item, i) => (index.h("span", { class: {
|
|
@@ -5427,16 +5494,35 @@ const CatSelect = class {
|
|
|
5427
5494
|
}, role: "option", "aria-selected": "true", id: `select-${this.id}-selection-${i}` }, item.render.avatar ? (index.h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, initials: '' })) : null, index.h("span", null, item.render.label), !this.disabled && (index.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 ? (index.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, index.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 && index.h("cat-spinner", null), (this.state.selection.length || this.state.term.length) &&
|
|
5428
5495
|
!this.disabled &&
|
|
5429
5496
|
!this.state.isResolving &&
|
|
5430
|
-
this.clearable ? (index.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 && (index.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, index.h("div", { class: "select-dropdown", ref: el => (this.dropdown = el), style: { display: this.state.isOpen ? 'block' : undefined } }, this.state.isOpen && (index.h("cat-scrollable", { class: "select-options-wrapper", scrolledBuffer: 56, noOverflowX: true, noOverscroll: true, noScrolledInit: true, onScrolledBottom: () => this.more$.next() }, index.h("ul", { class: "select-options", role: "listbox", "aria-multiselectable": this.multiple, "aria-setsize": this.state.totalElements, id: `select-listbox-${this.id}` }, this.
|
|
5431
|
-
this.toggle(item);
|
|
5432
|
-
e.stopPropagation();
|
|
5433
|
-
} }, index.h("span", { slot: "label", class: "select-option-inner" }, item.render.avatar ? (index.h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, initials: '' })) : null, index.h("span", { class: "select-option-text" }, index.h("span", { class: "select-option-label" }, item.render.label), index.h("span", { class: "select-option-description" }, item.render.description))))) : (index.h("div", { class: {
|
|
5434
|
-
'select-option-inner': true,
|
|
5435
|
-
'select-option-single': true,
|
|
5436
|
-
'select-option-active': this.state.activeOptionIndex === i
|
|
5437
|
-
}, onFocus: () => { var _a; return (_a = this.input) === null || _a === void 0 ? void 0 : _a.focus(); }, onClick: () => this.select(item), tabIndex: -1 }, item.render.avatar ? (index.h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, initials: '' })) : null, index.h("span", { class: "select-option-text" }, index.h("span", { class: "select-option-label" }, item.render.label), index.h("span", { class: "select-option-description" }, item.render.description))))))), this.state.isLoading
|
|
5497
|
+
this.clearable ? (index.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 && (index.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, index.h("div", { class: "select-dropdown", ref: el => (this.dropdown = el), style: { display: this.state.isOpen ? 'block' : undefined } }, this.state.isOpen && (index.h("cat-scrollable", { class: "select-options-wrapper", scrolledBuffer: 56, noOverflowX: true, noOverscroll: true, noScrolledInit: true, onScrolledBottom: () => this.more$.next() }, index.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
|
|
5438
5498
|
? Array.from(Array(CatSelect.SKELETON_COUNT)).map(() => (index.h("li", { class: "select-option-loading" }, index.h("cat-skeleton", { variant: "body", lines: 1 }), index.h("cat-skeleton", { variant: "body", lines: 1 }))))
|
|
5439
|
-
: !this.state.options.length &&
|
|
5499
|
+
: !this.state.options.length &&
|
|
5500
|
+
!this.tags && index.h("li", { class: "select-option-empty" }, this.i18n.t('select.empty'))))))));
|
|
5501
|
+
}
|
|
5502
|
+
get optionsList() {
|
|
5503
|
+
return this.state.options.map((item, i) => {
|
|
5504
|
+
const isTagOption = this.tags && item.item.id === `select-${this.id}-option-tag`;
|
|
5505
|
+
const getAriaSelected = () => {
|
|
5506
|
+
if (isTagOption) {
|
|
5507
|
+
return this.isAlreadyCreated(item.render.label) ? 'true' : 'false';
|
|
5508
|
+
}
|
|
5509
|
+
return this.isSelected(item.item.id) ? 'true' : 'false';
|
|
5510
|
+
};
|
|
5511
|
+
const getLabel = () => {
|
|
5512
|
+
if (isTagOption) {
|
|
5513
|
+
return item.render.label + this.tagTextHelp;
|
|
5514
|
+
}
|
|
5515
|
+
return item.render.label;
|
|
5516
|
+
};
|
|
5517
|
+
return (index.h("li", { role: "option", class: "select-option", id: `select-${this.id}-option-${i}`, "aria-selected": getAriaSelected() }, this.multiple ? (index.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 => {
|
|
5518
|
+
!isTagOption ? this.toggle(item) : this.toggleTag(item);
|
|
5519
|
+
e.stopPropagation();
|
|
5520
|
+
} }, index.h("span", { slot: "label", class: "select-option-inner" }, item.render.avatar ? (index.h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, initials: '' })) : null, index.h("span", { class: "select-option-text" }, index.h("span", { class: "select-option-label" }, getLabel()), index.h("span", { class: "select-option-description" }, item.render.description))))) : (index.h("div", { class: {
|
|
5521
|
+
'select-option-inner': true,
|
|
5522
|
+
'select-option-single': true,
|
|
5523
|
+
'select-option-active': this.state.activeOptionIndex === i
|
|
5524
|
+
}, 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 ? (index.h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, initials: '' })) : null, index.h("span", { class: "select-option-text" }, index.h("span", { class: "select-option-label" }, getLabel()), index.h("span", { class: "select-option-description" }, item.render.description))))));
|
|
5525
|
+
});
|
|
5440
5526
|
}
|
|
5441
5527
|
get hintSection() {
|
|
5442
5528
|
const hasSlottedHint = !!this.hostElement.querySelector('[slot="hint"]');
|
|
@@ -5449,21 +5535,27 @@ const CatSelect = class {
|
|
|
5449
5535
|
throw new Error('CatSelectConnector not set');
|
|
5450
5536
|
}
|
|
5451
5537
|
resolve() {
|
|
5452
|
-
var _a;
|
|
5453
5538
|
this.patchState({ isResolving: true });
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
|
|
5457
|
-
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
|
|
5462
|
-
|
|
5463
|
-
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
|
|
5539
|
+
const ids = this.initIds();
|
|
5540
|
+
let tags;
|
|
5541
|
+
if (this.tags) {
|
|
5542
|
+
tags = this.initTags();
|
|
5543
|
+
}
|
|
5544
|
+
const data$ = ids.length ? this.connectorSafe.resolve(ids).pipe(first()) : of([]);
|
|
5545
|
+
data$.pipe(catchError(() => of([]))).subscribe(items => {
|
|
5546
|
+
const selection = items.length ? items === null || items === void 0 ? void 0 : items.map(item => ({ item, render: this.connectorSafe.render(item) })) : [];
|
|
5547
|
+
if (this.tags) {
|
|
5548
|
+
tags === null || tags === void 0 ? void 0 : tags.forEach((tag, index) => {
|
|
5549
|
+
const item = { id: `select-${this.id}-tag-${index}`, name: tag };
|
|
5550
|
+
selection.push({ item, render: { label: item.name } });
|
|
5551
|
+
});
|
|
5552
|
+
}
|
|
5553
|
+
this.patchState({
|
|
5554
|
+
isResolving: false,
|
|
5555
|
+
selection,
|
|
5556
|
+
term: !this.multiple && selection.length ? selection[0].render.label : ''
|
|
5557
|
+
});
|
|
5558
|
+
});
|
|
5467
5559
|
}
|
|
5468
5560
|
show() {
|
|
5469
5561
|
var _a;
|
|
@@ -5488,7 +5580,6 @@ const CatSelect = class {
|
|
|
5488
5580
|
return this.state.selection.findIndex(s => s.item.id === id) >= 0;
|
|
5489
5581
|
}
|
|
5490
5582
|
select(item) {
|
|
5491
|
-
var _a;
|
|
5492
5583
|
if (!this.isSelected(item.item.id)) {
|
|
5493
5584
|
let newSelection;
|
|
5494
5585
|
if (this.multiple) {
|
|
@@ -5499,11 +5590,13 @@ const CatSelect = class {
|
|
|
5499
5590
|
this.search(item.render.label);
|
|
5500
5591
|
}
|
|
5501
5592
|
this.patchState({ selection: newSelection });
|
|
5593
|
+
if (this.multiple && this.state.term.trim() && this.input) {
|
|
5594
|
+
this.patchState({ term: '', activeOptionIndex: -1 });
|
|
5595
|
+
this.term$.next('');
|
|
5596
|
+
this.input.value = '';
|
|
5597
|
+
}
|
|
5502
5598
|
}
|
|
5503
|
-
|
|
5504
|
-
this.hide();
|
|
5505
|
-
(_a = this.input) === null || _a === void 0 ? void 0 : _a.classList.add('select-input-transparent-caret');
|
|
5506
|
-
}
|
|
5599
|
+
this.setTransparentCaret();
|
|
5507
5600
|
}
|
|
5508
5601
|
deselect(id) {
|
|
5509
5602
|
if (this.isSelected(id)) {
|
|
@@ -5550,7 +5643,12 @@ const CatSelect = class {
|
|
|
5550
5643
|
}
|
|
5551
5644
|
onInput() {
|
|
5552
5645
|
var _a;
|
|
5553
|
-
this.search(((_a = this.input) === null || _a === void 0 ? void 0 : _a.value) || '');
|
|
5646
|
+
this.search(((_a = this.input) === null || _a === void 0 ? void 0 : _a.value.trim()) || '');
|
|
5647
|
+
if (!this.multiple && this.state.selection.length) {
|
|
5648
|
+
const selectionClone = [...this.state.selection];
|
|
5649
|
+
selectionClone.pop();
|
|
5650
|
+
this.patchState({ selection: selectionClone });
|
|
5651
|
+
}
|
|
5554
5652
|
this.show();
|
|
5555
5653
|
}
|
|
5556
5654
|
update() {
|
|
@@ -5588,52 +5686,122 @@ const CatSelect = class {
|
|
|
5588
5686
|
var _a, _b;
|
|
5589
5687
|
let preventDefault = false;
|
|
5590
5688
|
(_a = this.input) === null || _a === void 0 ? void 0 : _a.focus();
|
|
5591
|
-
|
|
5592
|
-
|
|
5593
|
-
this.state.isOpen
|
|
5594
|
-
? this.patchState({
|
|
5595
|
-
activeOptionIndex: Math.min(this.state.activeOptionIndex + 1, this.state.options.length - 1),
|
|
5596
|
-
activeSelectionIndex: -1
|
|
5597
|
-
})
|
|
5598
|
-
: this.show();
|
|
5599
|
-
}
|
|
5600
|
-
else if (event.key === 'ArrowUp') {
|
|
5601
|
-
preventDefault = true;
|
|
5602
|
-
this.state.activeOptionIndex >= 0
|
|
5603
|
-
? this.patchState({
|
|
5604
|
-
activeOptionIndex: Math.max(this.state.activeOptionIndex - 1, -1),
|
|
5605
|
-
activeSelectionIndex: -1
|
|
5606
|
-
})
|
|
5607
|
-
: this.hide();
|
|
5608
|
-
}
|
|
5609
|
-
else if (event.key === 'ArrowLeft') {
|
|
5610
|
-
if (((_b = this.input) === null || _b === void 0 ? void 0 : _b.selectionStart) === 0) {
|
|
5689
|
+
switch (event.key) {
|
|
5690
|
+
case 'ArrowDown':
|
|
5611
5691
|
preventDefault = true;
|
|
5612
|
-
|
|
5613
|
-
|
|
5614
|
-
|
|
5615
|
-
|
|
5616
|
-
|
|
5617
|
-
|
|
5618
|
-
|
|
5619
|
-
|
|
5620
|
-
if (this.state.activeSelectionIndex >= 0) {
|
|
5692
|
+
this.state.isOpen
|
|
5693
|
+
? this.patchState({
|
|
5694
|
+
activeOptionIndex: Math.min(this.state.activeOptionIndex + 1, this.state.options.length - 1),
|
|
5695
|
+
activeSelectionIndex: -1
|
|
5696
|
+
})
|
|
5697
|
+
: this.show();
|
|
5698
|
+
break;
|
|
5699
|
+
case 'ArrowUp':
|
|
5621
5700
|
preventDefault = true;
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
|
|
5701
|
+
this.state.activeOptionIndex >= 0
|
|
5702
|
+
? this.patchState({
|
|
5703
|
+
activeOptionIndex: Math.max(this.state.activeOptionIndex - 1, -1),
|
|
5704
|
+
activeSelectionIndex: -1
|
|
5705
|
+
})
|
|
5706
|
+
: this.hide();
|
|
5707
|
+
break;
|
|
5708
|
+
case 'ArrowLeft':
|
|
5709
|
+
if (((_b = this.input) === null || _b === void 0 ? void 0 : _b.selectionStart) === 0) {
|
|
5710
|
+
preventDefault = true;
|
|
5711
|
+
let index;
|
|
5712
|
+
this.state.activeSelectionIndex > 0
|
|
5713
|
+
? (index = Math.max(this.state.activeSelectionIndex - 1, -1))
|
|
5714
|
+
: (index = this.state.selection.length - 1);
|
|
5715
|
+
this.patchState({ activeSelectionIndex: index, activeOptionIndex: -1 });
|
|
5625
5716
|
}
|
|
5626
|
-
|
|
5627
|
-
|
|
5717
|
+
break;
|
|
5718
|
+
case 'ArrowRight':
|
|
5719
|
+
if (this.state.activeSelectionIndex >= 0) {
|
|
5720
|
+
preventDefault = true;
|
|
5721
|
+
let index = -1;
|
|
5722
|
+
if (this.state.activeSelectionIndex < this.state.selection.length - 1) {
|
|
5723
|
+
index = Math.min(this.state.activeSelectionIndex + 1, this.state.selection.length - 1);
|
|
5724
|
+
}
|
|
5725
|
+
else if (!this.state.term) {
|
|
5726
|
+
index = 0;
|
|
5727
|
+
}
|
|
5728
|
+
this.patchState({ activeSelectionIndex: index, activeOptionIndex: -1 });
|
|
5628
5729
|
}
|
|
5629
|
-
this.patchState({ activeSelectionIndex: index, activeOptionIndex: -1 });
|
|
5630
|
-
}
|
|
5631
5730
|
}
|
|
5632
5731
|
if (preventDefault) {
|
|
5633
5732
|
event.preventDefault();
|
|
5634
5733
|
event.stopPropagation();
|
|
5635
5734
|
}
|
|
5636
5735
|
}
|
|
5736
|
+
get tagTextHelp() {
|
|
5737
|
+
return this.tagHint && !this.isAlreadyCreated(this.state.term) ? ' (' + this.tagHint + ')' : '';
|
|
5738
|
+
}
|
|
5739
|
+
isAlreadyCreated(term) {
|
|
5740
|
+
return this.state.selection.findIndex(item => item.render.label.toLowerCase() === term.toLowerCase()) >= 0;
|
|
5741
|
+
}
|
|
5742
|
+
createTag(term) {
|
|
5743
|
+
if (term.trim().length && !this.isAlreadyCreated(term)) {
|
|
5744
|
+
const value = this.value;
|
|
5745
|
+
const tags = value === null || value === void 0 ? void 0 : value.tags;
|
|
5746
|
+
const tag = { id: `select-${this.id}-tag-${tags ? tags.length : 0}`, name: term };
|
|
5747
|
+
this.select({ item: tag, render: { label: tag.name } });
|
|
5748
|
+
}
|
|
5749
|
+
this.setTransparentCaret();
|
|
5750
|
+
}
|
|
5751
|
+
initIds() {
|
|
5752
|
+
let ids = [];
|
|
5753
|
+
if (this.value) {
|
|
5754
|
+
if (!this.tags) {
|
|
5755
|
+
if (this.multiple) {
|
|
5756
|
+
ids = this.value;
|
|
5757
|
+
}
|
|
5758
|
+
else {
|
|
5759
|
+
ids = [this.value];
|
|
5760
|
+
}
|
|
5761
|
+
}
|
|
5762
|
+
else {
|
|
5763
|
+
if (this.multiple) {
|
|
5764
|
+
const value = this.value;
|
|
5765
|
+
ids = value.ids ? value.ids : [];
|
|
5766
|
+
}
|
|
5767
|
+
else {
|
|
5768
|
+
const value = this.value;
|
|
5769
|
+
ids = value.id ? [value.id] : [];
|
|
5770
|
+
}
|
|
5771
|
+
}
|
|
5772
|
+
}
|
|
5773
|
+
return ids;
|
|
5774
|
+
}
|
|
5775
|
+
initTags() {
|
|
5776
|
+
let tags = [];
|
|
5777
|
+
if (this.value) {
|
|
5778
|
+
if (this.multiple) {
|
|
5779
|
+
const value = this.value;
|
|
5780
|
+
tags = value.tags ? value.tags : [];
|
|
5781
|
+
}
|
|
5782
|
+
else {
|
|
5783
|
+
const value = this.value;
|
|
5784
|
+
tags = value.tag ? [value.tag] : [];
|
|
5785
|
+
}
|
|
5786
|
+
}
|
|
5787
|
+
return tags;
|
|
5788
|
+
}
|
|
5789
|
+
toggleTag(item) {
|
|
5790
|
+
this.isAlreadyCreated(item.render.label) ? this.removeTag(item.render.label) : this.createTag(item.render.label);
|
|
5791
|
+
}
|
|
5792
|
+
removeTag(label) {
|
|
5793
|
+
if (this.isAlreadyCreated(label)) {
|
|
5794
|
+
const item = this.state.selection.find(item => item.render.label.toLowerCase() === label.toLowerCase());
|
|
5795
|
+
item && this.deselect(item.item.id);
|
|
5796
|
+
}
|
|
5797
|
+
}
|
|
5798
|
+
setTransparentCaret() {
|
|
5799
|
+
var _a;
|
|
5800
|
+
if (!this.multiple) {
|
|
5801
|
+
this.hide();
|
|
5802
|
+
(_a = this.input) === null || _a === void 0 ? void 0 : _a.classList.add('select-input-transparent-caret');
|
|
5803
|
+
}
|
|
5804
|
+
}
|
|
5637
5805
|
get hostElement() { return index.getElement(this); }
|
|
5638
5806
|
static get watchers() { return {
|
|
5639
5807
|
"connector": ["onConnectorChange"],
|
|
@@ -5649,7 +5817,7 @@ const CatSelectTest = class {
|
|
|
5649
5817
|
index.registerInstance(this, hostRef);
|
|
5650
5818
|
}
|
|
5651
5819
|
componentDidLoad() {
|
|
5652
|
-
var _a, _b, _c, _d;
|
|
5820
|
+
var _a, _b, _c, _d, _e, _f;
|
|
5653
5821
|
(_a = this.multipleSelect) === null || _a === void 0 ? void 0 : _a.connect({
|
|
5654
5822
|
resolve: (ids) => {
|
|
5655
5823
|
console.info(`Resolving data... (${ids.join(', ')})`);
|
|
@@ -5714,31 +5882,45 @@ const CatSelectTest = class {
|
|
|
5714
5882
|
}
|
|
5715
5883
|
})
|
|
5716
5884
|
});
|
|
5717
|
-
(_c = this.
|
|
5885
|
+
(_c = this.multipleSelectTagging) === null || _c === void 0 ? void 0 : _c.connect(Object.assign(Object.assign({}, this.countryConnector), { customId: (item) => item.country }));
|
|
5886
|
+
(_d = this.singleSelect) === null || _d === void 0 ? void 0 : _d.connect({
|
|
5718
5887
|
resolve: (ids) => {
|
|
5719
5888
|
console.info(`Resolving data... (${ids.join(', ')})`);
|
|
5720
|
-
return of(ids.map(id =>
|
|
5889
|
+
return of(ids.map(id => ({
|
|
5890
|
+
id,
|
|
5891
|
+
firstName: 'John',
|
|
5892
|
+
lastName: `Doe (${id})`,
|
|
5893
|
+
desc: 'resolved'
|
|
5894
|
+
}))).pipe(delay(500));
|
|
5721
5895
|
},
|
|
5722
5896
|
retrieve: (term, page) => {
|
|
5723
5897
|
console.info(`Retrieving data... ("${term}", ${page})`);
|
|
5724
|
-
|
|
5725
|
-
|
|
5726
|
-
|
|
5727
|
-
|
|
5728
|
-
|
|
5729
|
-
|
|
5730
|
-
|
|
5731
|
-
|
|
5732
|
-
|
|
5733
|
-
|
|
5734
|
-
|
|
5898
|
+
return term === 'no'
|
|
5899
|
+
? of({ last: true, content: [], totalElements: 0 })
|
|
5900
|
+
: of({
|
|
5901
|
+
last: false,
|
|
5902
|
+
totalElements: 10000,
|
|
5903
|
+
content: Array.from({ length: 10 }, (_, i) => ({
|
|
5904
|
+
id: '' + (i + page * 10),
|
|
5905
|
+
firstName: 'John',
|
|
5906
|
+
lastName: `Doe (${i + page * 10})`,
|
|
5907
|
+
desc: `"${term}": page ${page}`
|
|
5908
|
+
}))
|
|
5909
|
+
}).pipe(delay(500));
|
|
5735
5910
|
},
|
|
5736
|
-
render: (
|
|
5737
|
-
label:
|
|
5738
|
-
description:
|
|
5911
|
+
render: (user) => ({
|
|
5912
|
+
label: `${user.firstName} ${user.lastName}`,
|
|
5913
|
+
description: user.desc
|
|
5739
5914
|
})
|
|
5740
5915
|
});
|
|
5741
|
-
(
|
|
5916
|
+
(_e = this.singleSelectAvatar) === null || _e === void 0 ? void 0 : _e.connect(Object.assign(Object.assign({}, this.countryConnector), { customId: (item) => item.country }));
|
|
5917
|
+
(_f = this.singleSelectTagging) === null || _f === void 0 ? void 0 : _f.connect(this.countryConnector);
|
|
5918
|
+
}
|
|
5919
|
+
render() {
|
|
5920
|
+
return (index.h(index.Host, { style: { display: 'flex', flexDirection: 'column' } }, index.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 }, index.h("span", { slot: "hint" }, "Searching for \"no\" -", '>', " no options are returned!")), index.h("cat-select", { label: "Multiple with img", ref: el => (this.multipleSelectAvatar = el), value: ['1'], placeholder: "Hello World", multiple: true, clearable: true }), index.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 }), index.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 }), index.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 }), index.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 })));
|
|
5921
|
+
}
|
|
5922
|
+
get countryConnector() {
|
|
5923
|
+
return {
|
|
5742
5924
|
resolve: (ids) => {
|
|
5743
5925
|
console.info(`Resolving data... (${ids.join(', ')})`);
|
|
5744
5926
|
return of(ids.map(id => countries.find(value => value.id === id))).pipe(delay(500));
|
|
@@ -5765,10 +5947,7 @@ const CatSelectTest = class {
|
|
|
5765
5947
|
round: true
|
|
5766
5948
|
}
|
|
5767
5949
|
})
|
|
5768
|
-
}
|
|
5769
|
-
}
|
|
5770
|
-
render() {
|
|
5771
|
-
return (index.h(index.Host, { style: { display: 'flex', flexDirection: 'column' } }, index.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 }, index.h("span", { slot: "hint" }, "Searching for \"no\" -", '>', " no options are returned!")), index.h("cat-select", { label: "Multiple with img", ref: el => (this.multipleSelectAvatar = el), value: ['1'], placeholder: "Hello World", multiple: true, clearable: true }), index.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 }), index.h("cat-select", { label: "Single with img", ref: el => (this.singleSelectAvatar = el), value: '1', placeholder: "Search for a country or capital", clearable: true })));
|
|
5950
|
+
};
|
|
5772
5951
|
}
|
|
5773
5952
|
};
|
|
5774
5953
|
const countries = [
|
|
@@ -7384,7 +7563,7 @@ CatToggle.style = catToggleCss;
|
|
|
7384
7563
|
|
|
7385
7564
|
const isTouchDevice = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
|
|
7386
7565
|
|
|
7387
|
-
const catTooltipCss = ":host{display:contents}:host([hidden]){display:none}.tooltip{position:absolute;font-size:0.875rem;line-height:1rem;font-weight:500;
|
|
7566
|
+
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}";
|
|
7388
7567
|
|
|
7389
7568
|
let nextUniqueId = 0;
|
|
7390
7569
|
const CatTooltip = class {
|
|
@@ -7404,10 +7583,18 @@ const CatTooltip = class {
|
|
|
7404
7583
|
* The placement of the tooltip.
|
|
7405
7584
|
*/
|
|
7406
7585
|
this.placement = 'top';
|
|
7586
|
+
/**
|
|
7587
|
+
* Use round tooltip edges.
|
|
7588
|
+
*/
|
|
7589
|
+
this.round = false;
|
|
7590
|
+
/**
|
|
7591
|
+
* The size of the tooltip.
|
|
7592
|
+
*/
|
|
7593
|
+
this.size = 'm';
|
|
7407
7594
|
/**
|
|
7408
7595
|
* The delay time for showing tooltip in ms.
|
|
7409
7596
|
*/
|
|
7410
|
-
this.showDelay =
|
|
7597
|
+
this.showDelay = 250;
|
|
7411
7598
|
/**
|
|
7412
7599
|
* The delay time for hiding tooltip in ms.
|
|
7413
7600
|
*/
|
|
@@ -7456,7 +7643,11 @@ const CatTooltip = class {
|
|
|
7456
7643
|
}
|
|
7457
7644
|
}
|
|
7458
7645
|
render() {
|
|
7459
|
-
return (index.h(index.Host, null, index.h("div", { ref: el => (this.triggerElement = el), "aria-describedby": this.id, class: "tooltip-trigger" }, index.h("slot", null)), this.content && !this.disabled && (index.h("div", { ref: el => (this.tooltip = el), id: this.id, class:
|
|
7646
|
+
return (index.h(index.Host, null, index.h("div", { ref: el => (this.triggerElement = el), "aria-describedby": this.id, class: "tooltip-trigger" }, index.h("slot", null)), this.content && !this.disabled && (index.h("div", { ref: el => (this.tooltip = el), id: this.id, class: {
|
|
7647
|
+
tooltip: true,
|
|
7648
|
+
'tooltip-round': this.round,
|
|
7649
|
+
[`tooltip-${this.size}`]: Boolean(this.size)
|
|
7650
|
+
} }, this.content))));
|
|
7460
7651
|
}
|
|
7461
7652
|
get isTabbable() {
|
|
7462
7653
|
return firstTabbable(this.trigger);
|