@haiilo/catalyst 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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-78b3fc17.entry.js +10 -0
- package/dist/catalyst/p-78b3fc17.entry.js.map +1 -0
- package/dist/catalyst/scss/utils/_sizing.mixins.scss +1 -1
- package/dist/cjs/cat-alert_23.cjs.entry.js +302 -120
- 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 +17 -18
- package/dist/collection/components/cat-alert/cat-alert.js.map +1 -1
- package/dist/collection/components/cat-checkbox/cat-checkbox.css +1 -1
- package/dist/collection/components/cat-select/cat-select.css +2 -1
- package/dist/collection/components/cat-select/cat-select.js +293 -94
- 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/components/cat-alert.js +14 -12
- package/dist/components/cat-alert.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 +240 -81
- 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/esm/cat-alert_23.entry.js +303 -121
- 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 -2
- package/dist/types/components/cat-select/cat-select.d.ts +32 -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/package.json +2 -2
- package/dist/catalyst/p-081aece8.entry.js +0 -10
- package/dist/catalyst/p-081aece8.entry.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
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
|
-
const catAlertCss = ":host{display:
|
|
4
|
+
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
5
|
|
|
6
6
|
const CatAlert = class {
|
|
7
7
|
constructor(hostRef) {
|
|
@@ -13,6 +13,13 @@ const CatAlert = class {
|
|
|
13
13
|
['warning', 'danger-filled'],
|
|
14
14
|
['danger', 'cross-circle-filled']
|
|
15
15
|
]);
|
|
16
|
+
this.mapRole = new Map([
|
|
17
|
+
['primary', 'status'],
|
|
18
|
+
['secondary', 'status'],
|
|
19
|
+
['success', 'status'],
|
|
20
|
+
['warning', 'alert'],
|
|
21
|
+
['danger', 'alert']
|
|
22
|
+
]);
|
|
16
23
|
/**
|
|
17
24
|
* The color palette of the alert.
|
|
18
25
|
*/
|
|
@@ -23,20 +30,15 @@ const CatAlert = class {
|
|
|
23
30
|
this.noIcon = false;
|
|
24
31
|
}
|
|
25
32
|
render() {
|
|
26
|
-
return (h(Host, { tabindex:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
33
|
+
return (h(Host, { tabindex: this.tabIndex, role: this.role }, !this.noIcon && h("cat-icon", { size: "l", icon: this.icon ? this.icon : this.mapIcon.get(this.color) }), h("div", { class: "content" }, h("slot", null))));
|
|
34
|
+
}
|
|
35
|
+
get tabIndex() {
|
|
36
|
+
return this.hostElement.getAttribute('tabindex') || '0';
|
|
30
37
|
}
|
|
31
38
|
get role() {
|
|
32
|
-
|
|
33
|
-
case 'danger':
|
|
34
|
-
case 'warning':
|
|
35
|
-
return 'alert';
|
|
36
|
-
default:
|
|
37
|
-
return 'status';
|
|
38
|
-
}
|
|
39
|
+
return this.hostElement.getAttribute('role') || this.mapRole.get(this.color) || null;
|
|
39
40
|
}
|
|
41
|
+
get hostElement() { return getElement(this); }
|
|
40
42
|
};
|
|
41
43
|
CatAlert.style = catAlertCss;
|
|
42
44
|
|
|
@@ -483,7 +485,7 @@ const CatFormHint = props => {
|
|
|
483
485
|
]));
|
|
484
486
|
};
|
|
485
487
|
|
|
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:
|
|
488
|
+
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
489
|
|
|
488
490
|
let nextUniqueId$8 = 0;
|
|
489
491
|
const CatCheckbox = class {
|
|
@@ -5219,7 +5221,7 @@ var autosizeInput = function (element, options) {
|
|
|
5219
5221
|
}
|
|
5220
5222
|
};
|
|
5221
5223
|
|
|
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))}.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:#
|
|
5224
|
+
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}.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-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
5225
|
|
|
5224
5226
|
const INIT_STATE = {
|
|
5225
5227
|
term: '',
|
|
@@ -5281,6 +5283,10 @@ const CatSelect = class {
|
|
|
5281
5283
|
* Whether the select should show a clear button.
|
|
5282
5284
|
*/
|
|
5283
5285
|
this.clearable = false;
|
|
5286
|
+
/**
|
|
5287
|
+
* Whether the select should add new items.
|
|
5288
|
+
*/
|
|
5289
|
+
this.tags = false;
|
|
5284
5290
|
}
|
|
5285
5291
|
onConnectorChange(connector) {
|
|
5286
5292
|
this.reset(connector);
|
|
@@ -5300,11 +5306,25 @@ const CatSelect = class {
|
|
|
5300
5306
|
this.hide();
|
|
5301
5307
|
}
|
|
5302
5308
|
const idsSelected = this.state.selection.map(item => item.item.id);
|
|
5303
|
-
if (this.
|
|
5304
|
-
this.
|
|
5309
|
+
if (!this.tags) {
|
|
5310
|
+
if (this.multiple) {
|
|
5311
|
+
this.value = idsSelected;
|
|
5312
|
+
}
|
|
5313
|
+
else {
|
|
5314
|
+
this.value = idsSelected.length ? idsSelected[0] : '';
|
|
5315
|
+
}
|
|
5305
5316
|
}
|
|
5306
5317
|
else {
|
|
5307
|
-
|
|
5318
|
+
const ids = idsSelected.filter(id => !id.startsWith(`select-${this.id}-tag`));
|
|
5319
|
+
const tags = this.state.selection
|
|
5320
|
+
.filter(item => item.item.id.startsWith(`select-${this.id}-tag`))
|
|
5321
|
+
.map(item => item.render.label);
|
|
5322
|
+
if (this.multiple) {
|
|
5323
|
+
this.value = { ids, tags };
|
|
5324
|
+
}
|
|
5325
|
+
else {
|
|
5326
|
+
this.value = { id: ids.length ? ids[0] : '', tag: tags.length ? tags[0] : '' };
|
|
5327
|
+
}
|
|
5308
5328
|
}
|
|
5309
5329
|
this.catChange.emit();
|
|
5310
5330
|
}
|
|
@@ -5325,7 +5345,12 @@ const CatSelect = class {
|
|
|
5325
5345
|
}
|
|
5326
5346
|
onBlur(event) {
|
|
5327
5347
|
if (!this.multiple && this.state.activeOptionIndex >= 0) {
|
|
5328
|
-
this.
|
|
5348
|
+
if (this.tags && this.state.options[this.state.activeOptionIndex].item.id === `select-${this.id}-option-tag`) {
|
|
5349
|
+
this.createTag(this.state.term);
|
|
5350
|
+
}
|
|
5351
|
+
else {
|
|
5352
|
+
this.select(this.state.options[this.state.activeOptionIndex]);
|
|
5353
|
+
}
|
|
5329
5354
|
}
|
|
5330
5355
|
this.hide();
|
|
5331
5356
|
this.patchState({ activeSelectionIndex: -1 });
|
|
@@ -5337,8 +5362,19 @@ const CatSelect = class {
|
|
|
5337
5362
|
if (['ArrowDown', 'ArrowUp', 'ArrowLeft', 'ArrowRight'].includes(event.key)) {
|
|
5338
5363
|
this.onArrowKeyDown(event);
|
|
5339
5364
|
}
|
|
5340
|
-
else if (['Enter', ' '].includes(event.key)) {
|
|
5341
|
-
if (
|
|
5365
|
+
else if (['Enter', ' '].includes(event.key) && isInputFocused) {
|
|
5366
|
+
if (this.tags &&
|
|
5367
|
+
this.state.activeOptionIndex === 0 &&
|
|
5368
|
+
this.state.options[0].item.id === `select-${this.id}-option-tag`) {
|
|
5369
|
+
event.preventDefault();
|
|
5370
|
+
if (this.multiple) {
|
|
5371
|
+
this.toggleTag(this.state.options[0]);
|
|
5372
|
+
}
|
|
5373
|
+
else {
|
|
5374
|
+
this.createTag(this.state.options[0].render.label);
|
|
5375
|
+
}
|
|
5376
|
+
}
|
|
5377
|
+
else if (this.state.activeOptionIndex >= 0) {
|
|
5342
5378
|
event.preventDefault();
|
|
5343
5379
|
if (this.multiple) {
|
|
5344
5380
|
this.toggle(this.state.options[this.state.activeOptionIndex]);
|
|
@@ -5347,6 +5383,9 @@ const CatSelect = class {
|
|
|
5347
5383
|
this.select(this.state.options[this.state.activeOptionIndex]);
|
|
5348
5384
|
}
|
|
5349
5385
|
}
|
|
5386
|
+
else if (this.tags && event.key === 'Enter' && this.state.activeOptionIndex < 0) {
|
|
5387
|
+
this.createTag(this.state.term);
|
|
5388
|
+
}
|
|
5350
5389
|
}
|
|
5351
5390
|
else if (event.key === 'Escape') {
|
|
5352
5391
|
this.hide();
|
|
@@ -5357,11 +5396,6 @@ const CatSelect = class {
|
|
|
5357
5396
|
if (this.state.activeSelectionIndex >= 0) {
|
|
5358
5397
|
this.deselect(this.state.selection[this.state.activeSelectionIndex].item.id);
|
|
5359
5398
|
}
|
|
5360
|
-
else if (this.state.selection.length) {
|
|
5361
|
-
const selectionClone = [...this.state.selection];
|
|
5362
|
-
selectionClone.pop();
|
|
5363
|
-
this.patchState({ selection: selectionClone });
|
|
5364
|
-
}
|
|
5365
5399
|
}
|
|
5366
5400
|
}
|
|
5367
5401
|
else if (event.key === 'Tab') {
|
|
@@ -5370,7 +5404,12 @@ const CatSelect = class {
|
|
|
5370
5404
|
this.patchState({ activeSelectionIndex: -1, activeOptionIndex: -1 });
|
|
5371
5405
|
}
|
|
5372
5406
|
else if (this.state.activeOptionIndex >= 0) {
|
|
5373
|
-
this.
|
|
5407
|
+
if (this.tags && this.state.options[this.state.activeOptionIndex].item.id === `select-${this.id}-option-tag`) {
|
|
5408
|
+
this.createTag(this.state.term);
|
|
5409
|
+
}
|
|
5410
|
+
else {
|
|
5411
|
+
this.select(this.state.options[this.state.activeOptionIndex]);
|
|
5412
|
+
}
|
|
5374
5413
|
}
|
|
5375
5414
|
}
|
|
5376
5415
|
else if (event.key.length === 1) {
|
|
@@ -5408,12 +5447,28 @@ const CatSelect = class {
|
|
|
5408
5447
|
this.subscription = this.term$
|
|
5409
5448
|
.asObservable()
|
|
5410
5449
|
.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
|
-
|
|
5450
|
+
.subscribe(items => {
|
|
5451
|
+
var _a;
|
|
5452
|
+
const options = items === null || items === void 0 ? void 0 : items.map(item => ({
|
|
5413
5453
|
item,
|
|
5414
5454
|
render: this.connectorSafe.render(item)
|
|
5415
|
-
}))
|
|
5416
|
-
|
|
5455
|
+
}));
|
|
5456
|
+
if (this.tags &&
|
|
5457
|
+
this.state.term.trim().length &&
|
|
5458
|
+
!options.find(value1 => value1.render.label.toLowerCase() === this.state.term.toLowerCase())) {
|
|
5459
|
+
let label;
|
|
5460
|
+
if (this.isAlreadyCreated(this.state.term)) {
|
|
5461
|
+
label = (_a = this.state.selection.find(item => item.render.label.toLowerCase() === this.state.term.toLowerCase())) === null || _a === void 0 ? void 0 : _a.render.label;
|
|
5462
|
+
}
|
|
5463
|
+
options.unshift({
|
|
5464
|
+
item: { id: `select-${this.id}-option-tag` },
|
|
5465
|
+
render: { label: label ? label : this.state.term }
|
|
5466
|
+
});
|
|
5467
|
+
}
|
|
5468
|
+
this.patchState({
|
|
5469
|
+
options
|
|
5470
|
+
});
|
|
5471
|
+
});
|
|
5417
5472
|
}
|
|
5418
5473
|
render() {
|
|
5419
5474
|
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 +5478,35 @@ const CatSelect = class {
|
|
|
5423
5478
|
}, 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
5479
|
!this.disabled &&
|
|
5425
5480
|
!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
|
|
5481
|
+
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
5482
|
? 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 &&
|
|
5483
|
+
: !this.state.options.length &&
|
|
5484
|
+
!this.tags && h("li", { class: "select-option-empty" }, this.i18n.t('select.empty'))))))));
|
|
5485
|
+
}
|
|
5486
|
+
get optionsList() {
|
|
5487
|
+
return this.state.options.map((item, i) => {
|
|
5488
|
+
const isTagOption = this.tags && item.item.id === `select-${this.id}-option-tag`;
|
|
5489
|
+
const getAriaSelected = () => {
|
|
5490
|
+
if (isTagOption) {
|
|
5491
|
+
return this.isAlreadyCreated(item.render.label) ? 'true' : 'false';
|
|
5492
|
+
}
|
|
5493
|
+
return this.isSelected(item.item.id) ? 'true' : 'false';
|
|
5494
|
+
};
|
|
5495
|
+
const getLabel = () => {
|
|
5496
|
+
if (isTagOption) {
|
|
5497
|
+
return item.render.label + this.tagTextHelp;
|
|
5498
|
+
}
|
|
5499
|
+
return item.render.label;
|
|
5500
|
+
};
|
|
5501
|
+
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 => {
|
|
5502
|
+
!isTagOption ? this.toggle(item) : this.toggleTag(item);
|
|
5503
|
+
e.stopPropagation();
|
|
5504
|
+
} }, 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: {
|
|
5505
|
+
'select-option-inner': true,
|
|
5506
|
+
'select-option-single': true,
|
|
5507
|
+
'select-option-active': this.state.activeOptionIndex === i
|
|
5508
|
+
}, 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))))));
|
|
5509
|
+
});
|
|
5436
5510
|
}
|
|
5437
5511
|
get hintSection() {
|
|
5438
5512
|
const hasSlottedHint = !!this.hostElement.querySelector('[slot="hint"]');
|
|
@@ -5445,21 +5519,27 @@ const CatSelect = class {
|
|
|
5445
5519
|
throw new Error('CatSelectConnector not set');
|
|
5446
5520
|
}
|
|
5447
5521
|
resolve() {
|
|
5448
|
-
var _a;
|
|
5449
5522
|
this.patchState({ isResolving: true });
|
|
5450
|
-
|
|
5451
|
-
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
|
|
5457
|
-
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
|
|
5462
|
-
|
|
5523
|
+
const ids = this.initIds();
|
|
5524
|
+
let tags;
|
|
5525
|
+
if (this.tags) {
|
|
5526
|
+
tags = this.initTags();
|
|
5527
|
+
}
|
|
5528
|
+
const data$ = ids.length ? this.connectorSafe.resolve(ids).pipe(first()) : of([]);
|
|
5529
|
+
data$.pipe(catchError(() => of([]))).subscribe(items => {
|
|
5530
|
+
const selection = items.length ? items === null || items === void 0 ? void 0 : items.map(item => ({ item, render: this.connectorSafe.render(item) })) : [];
|
|
5531
|
+
if (this.tags) {
|
|
5532
|
+
tags === null || tags === void 0 ? void 0 : tags.forEach((tag, index) => {
|
|
5533
|
+
const item = { id: `select-${this.id}-tag-${index}`, name: tag };
|
|
5534
|
+
selection.push({ item, render: { label: item.name } });
|
|
5535
|
+
});
|
|
5536
|
+
}
|
|
5537
|
+
this.patchState({
|
|
5538
|
+
isResolving: false,
|
|
5539
|
+
selection,
|
|
5540
|
+
term: !this.multiple && selection.length ? selection[0].render.label : ''
|
|
5541
|
+
});
|
|
5542
|
+
});
|
|
5463
5543
|
}
|
|
5464
5544
|
show() {
|
|
5465
5545
|
var _a;
|
|
@@ -5484,7 +5564,6 @@ const CatSelect = class {
|
|
|
5484
5564
|
return this.state.selection.findIndex(s => s.item.id === id) >= 0;
|
|
5485
5565
|
}
|
|
5486
5566
|
select(item) {
|
|
5487
|
-
var _a;
|
|
5488
5567
|
if (!this.isSelected(item.item.id)) {
|
|
5489
5568
|
let newSelection;
|
|
5490
5569
|
if (this.multiple) {
|
|
@@ -5495,11 +5574,13 @@ const CatSelect = class {
|
|
|
5495
5574
|
this.search(item.render.label);
|
|
5496
5575
|
}
|
|
5497
5576
|
this.patchState({ selection: newSelection });
|
|
5577
|
+
if (this.multiple && this.state.term.trim() && this.input) {
|
|
5578
|
+
this.patchState({ term: '', activeOptionIndex: -1 });
|
|
5579
|
+
this.term$.next('');
|
|
5580
|
+
this.input.value = '';
|
|
5581
|
+
}
|
|
5498
5582
|
}
|
|
5499
|
-
|
|
5500
|
-
this.hide();
|
|
5501
|
-
(_a = this.input) === null || _a === void 0 ? void 0 : _a.classList.add('select-input-transparent-caret');
|
|
5502
|
-
}
|
|
5583
|
+
this.setTransparentCaret();
|
|
5503
5584
|
}
|
|
5504
5585
|
deselect(id) {
|
|
5505
5586
|
if (this.isSelected(id)) {
|
|
@@ -5531,6 +5612,9 @@ const CatSelect = class {
|
|
|
5531
5612
|
}
|
|
5532
5613
|
onClick(event) {
|
|
5533
5614
|
var _a, _b;
|
|
5615
|
+
if (this.disabled) {
|
|
5616
|
+
return;
|
|
5617
|
+
}
|
|
5534
5618
|
const elem = event.target;
|
|
5535
5619
|
(_a = this.trigger) === null || _a === void 0 ? void 0 : _a.setAttribute('tabindex', '0');
|
|
5536
5620
|
(_b = this.input) === null || _b === void 0 ? void 0 : _b.focus();
|
|
@@ -5543,7 +5627,12 @@ const CatSelect = class {
|
|
|
5543
5627
|
}
|
|
5544
5628
|
onInput() {
|
|
5545
5629
|
var _a;
|
|
5546
|
-
this.search(((_a = this.input) === null || _a === void 0 ? void 0 : _a.value) || '');
|
|
5630
|
+
this.search(((_a = this.input) === null || _a === void 0 ? void 0 : _a.value.trim()) || '');
|
|
5631
|
+
if (!this.multiple && this.state.selection.length) {
|
|
5632
|
+
const selectionClone = [...this.state.selection];
|
|
5633
|
+
selectionClone.pop();
|
|
5634
|
+
this.patchState({ selection: selectionClone });
|
|
5635
|
+
}
|
|
5547
5636
|
this.show();
|
|
5548
5637
|
}
|
|
5549
5638
|
update() {
|
|
@@ -5581,52 +5670,122 @@ const CatSelect = class {
|
|
|
5581
5670
|
var _a, _b;
|
|
5582
5671
|
let preventDefault = false;
|
|
5583
5672
|
(_a = this.input) === null || _a === void 0 ? void 0 : _a.focus();
|
|
5584
|
-
|
|
5585
|
-
|
|
5586
|
-
this.state.isOpen
|
|
5587
|
-
? this.patchState({
|
|
5588
|
-
activeOptionIndex: Math.min(this.state.activeOptionIndex + 1, this.state.options.length - 1),
|
|
5589
|
-
activeSelectionIndex: -1
|
|
5590
|
-
})
|
|
5591
|
-
: this.show();
|
|
5592
|
-
}
|
|
5593
|
-
else if (event.key === 'ArrowUp') {
|
|
5594
|
-
preventDefault = true;
|
|
5595
|
-
this.state.activeOptionIndex >= 0
|
|
5596
|
-
? this.patchState({
|
|
5597
|
-
activeOptionIndex: Math.max(this.state.activeOptionIndex - 1, -1),
|
|
5598
|
-
activeSelectionIndex: -1
|
|
5599
|
-
})
|
|
5600
|
-
: this.hide();
|
|
5601
|
-
}
|
|
5602
|
-
else if (event.key === 'ArrowLeft') {
|
|
5603
|
-
if (((_b = this.input) === null || _b === void 0 ? void 0 : _b.selectionStart) === 0) {
|
|
5673
|
+
switch (event.key) {
|
|
5674
|
+
case 'ArrowDown':
|
|
5604
5675
|
preventDefault = true;
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
|
|
5613
|
-
if (this.state.activeSelectionIndex >= 0) {
|
|
5676
|
+
this.state.isOpen
|
|
5677
|
+
? this.patchState({
|
|
5678
|
+
activeOptionIndex: Math.min(this.state.activeOptionIndex + 1, this.state.options.length - 1),
|
|
5679
|
+
activeSelectionIndex: -1
|
|
5680
|
+
})
|
|
5681
|
+
: this.show();
|
|
5682
|
+
break;
|
|
5683
|
+
case 'ArrowUp':
|
|
5614
5684
|
preventDefault = true;
|
|
5615
|
-
|
|
5616
|
-
|
|
5617
|
-
|
|
5685
|
+
this.state.activeOptionIndex >= 0
|
|
5686
|
+
? this.patchState({
|
|
5687
|
+
activeOptionIndex: Math.max(this.state.activeOptionIndex - 1, -1),
|
|
5688
|
+
activeSelectionIndex: -1
|
|
5689
|
+
})
|
|
5690
|
+
: this.hide();
|
|
5691
|
+
break;
|
|
5692
|
+
case 'ArrowLeft':
|
|
5693
|
+
if (((_b = this.input) === null || _b === void 0 ? void 0 : _b.selectionStart) === 0) {
|
|
5694
|
+
preventDefault = true;
|
|
5695
|
+
let index;
|
|
5696
|
+
this.state.activeSelectionIndex > 0
|
|
5697
|
+
? (index = Math.max(this.state.activeSelectionIndex - 1, -1))
|
|
5698
|
+
: (index = this.state.selection.length - 1);
|
|
5699
|
+
this.patchState({ activeSelectionIndex: index, activeOptionIndex: -1 });
|
|
5618
5700
|
}
|
|
5619
|
-
|
|
5620
|
-
|
|
5701
|
+
break;
|
|
5702
|
+
case 'ArrowRight':
|
|
5703
|
+
if (this.state.activeSelectionIndex >= 0) {
|
|
5704
|
+
preventDefault = true;
|
|
5705
|
+
let index = -1;
|
|
5706
|
+
if (this.state.activeSelectionIndex < this.state.selection.length - 1) {
|
|
5707
|
+
index = Math.min(this.state.activeSelectionIndex + 1, this.state.selection.length - 1);
|
|
5708
|
+
}
|
|
5709
|
+
else if (!this.state.term) {
|
|
5710
|
+
index = 0;
|
|
5711
|
+
}
|
|
5712
|
+
this.patchState({ activeSelectionIndex: index, activeOptionIndex: -1 });
|
|
5621
5713
|
}
|
|
5622
|
-
this.patchState({ activeSelectionIndex: index, activeOptionIndex: -1 });
|
|
5623
|
-
}
|
|
5624
5714
|
}
|
|
5625
5715
|
if (preventDefault) {
|
|
5626
5716
|
event.preventDefault();
|
|
5627
5717
|
event.stopPropagation();
|
|
5628
5718
|
}
|
|
5629
5719
|
}
|
|
5720
|
+
get tagTextHelp() {
|
|
5721
|
+
return this.tagHint && !this.isAlreadyCreated(this.state.term) ? ' (' + this.tagHint + ')' : '';
|
|
5722
|
+
}
|
|
5723
|
+
isAlreadyCreated(term) {
|
|
5724
|
+
return this.state.selection.findIndex(item => item.render.label.toLowerCase() === term.toLowerCase()) >= 0;
|
|
5725
|
+
}
|
|
5726
|
+
createTag(term) {
|
|
5727
|
+
if (term.trim().length && !this.isAlreadyCreated(term)) {
|
|
5728
|
+
const value = this.value;
|
|
5729
|
+
const tags = value === null || value === void 0 ? void 0 : value.tags;
|
|
5730
|
+
const tag = { id: `select-${this.id}-tag-${tags ? tags.length : 0}`, name: term };
|
|
5731
|
+
this.select({ item: tag, render: { label: tag.name } });
|
|
5732
|
+
}
|
|
5733
|
+
this.setTransparentCaret();
|
|
5734
|
+
}
|
|
5735
|
+
initIds() {
|
|
5736
|
+
let ids = [];
|
|
5737
|
+
if (this.value) {
|
|
5738
|
+
if (!this.tags) {
|
|
5739
|
+
if (this.multiple) {
|
|
5740
|
+
ids = this.value;
|
|
5741
|
+
}
|
|
5742
|
+
else {
|
|
5743
|
+
ids = [this.value];
|
|
5744
|
+
}
|
|
5745
|
+
}
|
|
5746
|
+
else {
|
|
5747
|
+
if (this.multiple) {
|
|
5748
|
+
const value = this.value;
|
|
5749
|
+
ids = value.ids ? value.ids : [];
|
|
5750
|
+
}
|
|
5751
|
+
else {
|
|
5752
|
+
const value = this.value;
|
|
5753
|
+
ids = value.id ? [value.id] : [];
|
|
5754
|
+
}
|
|
5755
|
+
}
|
|
5756
|
+
}
|
|
5757
|
+
return ids;
|
|
5758
|
+
}
|
|
5759
|
+
initTags() {
|
|
5760
|
+
let tags = [];
|
|
5761
|
+
if (this.value) {
|
|
5762
|
+
if (this.multiple) {
|
|
5763
|
+
const value = this.value;
|
|
5764
|
+
tags = value.tags ? value.tags : [];
|
|
5765
|
+
}
|
|
5766
|
+
else {
|
|
5767
|
+
const value = this.value;
|
|
5768
|
+
tags = value.tag ? [value.tag] : [];
|
|
5769
|
+
}
|
|
5770
|
+
}
|
|
5771
|
+
return tags;
|
|
5772
|
+
}
|
|
5773
|
+
toggleTag(item) {
|
|
5774
|
+
this.isAlreadyCreated(item.render.label) ? this.removeTag(item.render.label) : this.createTag(item.render.label);
|
|
5775
|
+
}
|
|
5776
|
+
removeTag(label) {
|
|
5777
|
+
if (this.isAlreadyCreated(label)) {
|
|
5778
|
+
const item = this.state.selection.find(item => item.render.label.toLowerCase() === label.toLowerCase());
|
|
5779
|
+
item && this.deselect(item.item.id);
|
|
5780
|
+
}
|
|
5781
|
+
}
|
|
5782
|
+
setTransparentCaret() {
|
|
5783
|
+
var _a;
|
|
5784
|
+
if (!this.multiple) {
|
|
5785
|
+
this.hide();
|
|
5786
|
+
(_a = this.input) === null || _a === void 0 ? void 0 : _a.classList.add('select-input-transparent-caret');
|
|
5787
|
+
}
|
|
5788
|
+
}
|
|
5630
5789
|
get hostElement() { return getElement(this); }
|
|
5631
5790
|
static get watchers() { return {
|
|
5632
5791
|
"connector": ["onConnectorChange"],
|
|
@@ -5642,7 +5801,7 @@ const CatSelectTest = class {
|
|
|
5642
5801
|
registerInstance(this, hostRef);
|
|
5643
5802
|
}
|
|
5644
5803
|
componentDidLoad() {
|
|
5645
|
-
var _a, _b, _c, _d;
|
|
5804
|
+
var _a, _b, _c, _d, _e, _f;
|
|
5646
5805
|
(_a = this.multipleSelect) === null || _a === void 0 ? void 0 : _a.connect({
|
|
5647
5806
|
resolve: (ids) => {
|
|
5648
5807
|
console.info(`Resolving data... (${ids.join(', ')})`);
|
|
@@ -5707,31 +5866,45 @@ const CatSelectTest = class {
|
|
|
5707
5866
|
}
|
|
5708
5867
|
})
|
|
5709
5868
|
});
|
|
5710
|
-
(_c = this.
|
|
5869
|
+
(_c = this.multipleSelectTagging) === null || _c === void 0 ? void 0 : _c.connect(this.countryConnector);
|
|
5870
|
+
(_d = this.singleSelect) === null || _d === void 0 ? void 0 : _d.connect({
|
|
5711
5871
|
resolve: (ids) => {
|
|
5712
5872
|
console.info(`Resolving data... (${ids.join(', ')})`);
|
|
5713
|
-
return of(ids.map(id =>
|
|
5873
|
+
return of(ids.map(id => ({
|
|
5874
|
+
id,
|
|
5875
|
+
firstName: 'John',
|
|
5876
|
+
lastName: `Doe (${id})`,
|
|
5877
|
+
desc: 'resolved'
|
|
5878
|
+
}))).pipe(delay(500));
|
|
5714
5879
|
},
|
|
5715
5880
|
retrieve: (term, page) => {
|
|
5716
5881
|
console.info(`Retrieving data... ("${term}", ${page})`);
|
|
5717
|
-
|
|
5718
|
-
|
|
5719
|
-
|
|
5720
|
-
|
|
5721
|
-
|
|
5722
|
-
|
|
5723
|
-
|
|
5724
|
-
|
|
5725
|
-
|
|
5726
|
-
|
|
5727
|
-
|
|
5882
|
+
return term === 'no'
|
|
5883
|
+
? of({ last: true, content: [], totalElements: 0 })
|
|
5884
|
+
: of({
|
|
5885
|
+
last: false,
|
|
5886
|
+
totalElements: 10000,
|
|
5887
|
+
content: Array.from({ length: 10 }, (_, i) => ({
|
|
5888
|
+
id: '' + (i + page * 10),
|
|
5889
|
+
firstName: 'John',
|
|
5890
|
+
lastName: `Doe (${i + page * 10})`,
|
|
5891
|
+
desc: `"${term}": page ${page}`
|
|
5892
|
+
}))
|
|
5893
|
+
}).pipe(delay(500));
|
|
5728
5894
|
},
|
|
5729
|
-
render: (
|
|
5730
|
-
label:
|
|
5731
|
-
description:
|
|
5895
|
+
render: (user) => ({
|
|
5896
|
+
label: `${user.firstName} ${user.lastName}`,
|
|
5897
|
+
description: user.desc
|
|
5732
5898
|
})
|
|
5733
5899
|
});
|
|
5734
|
-
(
|
|
5900
|
+
(_e = this.singleSelectAvatar) === null || _e === void 0 ? void 0 : _e.connect(this.countryConnector);
|
|
5901
|
+
(_f = this.singleSelectTagging) === null || _f === void 0 ? void 0 : _f.connect(this.countryConnector);
|
|
5902
|
+
}
|
|
5903
|
+
render() {
|
|
5904
|
+
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", 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'] }, 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', 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 })));
|
|
5905
|
+
}
|
|
5906
|
+
get countryConnector() {
|
|
5907
|
+
return {
|
|
5735
5908
|
resolve: (ids) => {
|
|
5736
5909
|
console.info(`Resolving data... (${ids.join(', ')})`);
|
|
5737
5910
|
return of(ids.map(id => countries.find(value => value.id === id))).pipe(delay(500));
|
|
@@ -5758,10 +5931,7 @@ const CatSelectTest = class {
|
|
|
5758
5931
|
round: true
|
|
5759
5932
|
}
|
|
5760
5933
|
})
|
|
5761
|
-
}
|
|
5762
|
-
}
|
|
5763
|
-
render() {
|
|
5764
|
-
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 })));
|
|
5934
|
+
};
|
|
5765
5935
|
}
|
|
5766
5936
|
};
|
|
5767
5937
|
const countries = [
|
|
@@ -7377,7 +7547,7 @@ CatToggle.style = catToggleCss;
|
|
|
7377
7547
|
|
|
7378
7548
|
const isTouchDevice = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
|
|
7379
7549
|
|
|
7380
|
-
const catTooltipCss = ":host{display:contents}:host([hidden]){display:none}.tooltip{position:absolute;font-size:0.875rem;line-height:1rem;font-weight:500;
|
|
7550
|
+
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}";
|
|
7381
7551
|
|
|
7382
7552
|
let nextUniqueId = 0;
|
|
7383
7553
|
const CatTooltip = class {
|
|
@@ -7397,10 +7567,18 @@ const CatTooltip = class {
|
|
|
7397
7567
|
* The placement of the tooltip.
|
|
7398
7568
|
*/
|
|
7399
7569
|
this.placement = 'top';
|
|
7570
|
+
/**
|
|
7571
|
+
* Use round tooltip edges.
|
|
7572
|
+
*/
|
|
7573
|
+
this.round = false;
|
|
7574
|
+
/**
|
|
7575
|
+
* The size of the tooltip.
|
|
7576
|
+
*/
|
|
7577
|
+
this.size = 'm';
|
|
7400
7578
|
/**
|
|
7401
7579
|
* The delay time for showing tooltip in ms.
|
|
7402
7580
|
*/
|
|
7403
|
-
this.showDelay =
|
|
7581
|
+
this.showDelay = 250;
|
|
7404
7582
|
/**
|
|
7405
7583
|
* The delay time for hiding tooltip in ms.
|
|
7406
7584
|
*/
|
|
@@ -7449,7 +7627,11 @@ const CatTooltip = class {
|
|
|
7449
7627
|
}
|
|
7450
7628
|
}
|
|
7451
7629
|
render() {
|
|
7452
|
-
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:
|
|
7630
|
+
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: {
|
|
7631
|
+
tooltip: true,
|
|
7632
|
+
'tooltip-round': this.round,
|
|
7633
|
+
[`tooltip-${this.size}`]: Boolean(this.size)
|
|
7634
|
+
} }, this.content))));
|
|
7453
7635
|
}
|
|
7454
7636
|
get isTabbable() {
|
|
7455
7637
|
return firstTabbable(this.trigger);
|