@prolibu-suite/cobalt-core 0.11.4 → 0.11.6
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/custom-elements.json +65 -31
- package/dist/cjs/co-audio-player.cjs.entry.js +198 -46
- package/dist/cjs/co-kbd_2.cjs.entry.js +10 -3
- package/dist/cjs/cobalt.cjs.js +1 -1
- package/dist/cjs/index-bHoidDwv.js +4 -4
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cobalt/cobalt.esm.js +1 -1
- package/dist/cobalt/p-4a7fd0b4.entry.js +1 -0
- package/dist/cobalt/p-868d1a18.entry.js +1 -0
- package/dist/collection/components/co-audio-player/co-audio-player.js +40 -47
- package/dist/collection/components/co-audio-player/co-audio-player.peaks-cache.js +104 -0
- package/dist/collection/components/co-audio-player/co-audio-player.utils.js +61 -0
- package/dist/collection/components/co-autocomplete/co-autocomplete.js +1 -1
- package/dist/collection/components/co-avatar-group/co-avatar-group.js +1 -1
- package/dist/collection/components/co-checkbox-group/co-checkbox-group.js +1 -1
- package/dist/collection/components/co-color-area/co-color-area.js +2 -2
- package/dist/collection/components/co-color-slider/co-color-slider.js +1 -1
- package/dist/collection/components/co-combobox/co-combobox.js +1 -1
- package/dist/collection/components/co-command-search/co-command-search.js +1 -1
- package/dist/collection/components/co-data-table/co-data-table.js +1 -1
- package/dist/collection/components/co-date-range-picker/co-date-range-picker.js +2 -2
- package/dist/collection/components/co-document-editor/co-document-editor.js +5 -5
- package/dist/collection/components/co-popover/co-popover.js +1 -1
- package/dist/collection/components/co-radio-group/co-radio-group.js +1 -1
- package/dist/collection/components/co-ref-field/co-ref-field.js +4 -4
- package/dist/collection/components/co-segmented-bar/co-segmented-bar.js +1 -1
- package/dist/collection/components/co-select/co-select.js +1 -1
- package/dist/collection/components/co-sidebar-nav/co-sidebar-nav.js +1 -1
- package/dist/collection/components/co-toast/co-toast.js +2 -2
- package/dist/collection/components/co-tooltip/co-tooltip.css +14 -5
- package/dist/collection/components/co-tooltip/co-tooltip.js +29 -2
- package/dist/collection/components/co-transfer-list/co-transfer-list.js +1 -1
- package/dist/collection/components/co-tree-item/co-tree-item.js +2 -2
- package/dist/components/co-audio-player.js +1 -1
- package/dist/components/co-autocomplete.js +1 -1
- package/dist/components/co-avatar-group.js +1 -1
- package/dist/components/co-avatar.js +1 -1
- package/dist/components/co-combobox.js +1 -1
- package/dist/components/co-command-search.js +1 -1
- package/dist/components/co-data-table.js +1 -1
- package/dist/components/co-document-editor.js +1 -1
- package/dist/components/co-file-field.js +1 -1
- package/dist/components/co-list-item.js +1 -1
- package/dist/components/co-option-list.js +1 -1
- package/dist/components/co-ref-field.js +1 -1
- package/dist/components/co-sidebar-nav.js +1 -1
- package/dist/components/co-tooltip.js +1 -1
- package/dist/components/{p-BqFBZ1PT.js → p-BW10Sgiy.js} +1 -1
- package/dist/components/{p-VcrjNCew.js → p-BzNBPHen.js} +1 -1
- package/dist/components/p-V7HYy0VO.js +1 -0
- package/dist/esm/co-audio-player.entry.js +198 -46
- package/dist/esm/co-kbd_2.entry.js +10 -3
- package/dist/esm/cobalt.js +1 -1
- package/dist/esm/index-DJkaRtbb.js +4 -4
- package/dist/esm/loader.js +1 -1
- package/dist/types/components/co-audio-player/co-audio-player.d.ts +8 -1
- package/dist/types/components/co-audio-player/co-audio-player.peaks-cache.d.ts +58 -0
- package/dist/types/components/co-audio-player/co-audio-player.utils.d.ts +33 -0
- package/dist/types/components/co-tooltip/co-tooltip.d.ts +6 -0
- package/dist/types/components.d.ts +11 -0
- package/package.json +4 -4
- package/dist/cobalt/p-358a6c2a.entry.js +0 -1
- package/dist/cobalt/p-db623519.entry.js +0 -1
- package/dist/components/p-9VoFSbIH.js +0 -1
|
@@ -189,7 +189,7 @@ export class CoToast {
|
|
|
189
189
|
"references": {
|
|
190
190
|
"CoToastActionsLayout": {
|
|
191
191
|
"location": "local",
|
|
192
|
-
"path": "/Users/agox/worktrees/cobalt-
|
|
192
|
+
"path": "/Users/agox/worktrees/cobalt-tooltip-tone/packages/core/src/components/co-toast/co-toast.tsx",
|
|
193
193
|
"id": "src/components/co-toast/co-toast.tsx::CoToastActionsLayout"
|
|
194
194
|
}
|
|
195
195
|
}
|
|
@@ -215,7 +215,7 @@ export class CoToast {
|
|
|
215
215
|
"references": {
|
|
216
216
|
"CoToastVariant": {
|
|
217
217
|
"location": "local",
|
|
218
|
-
"path": "/Users/agox/worktrees/cobalt-
|
|
218
|
+
"path": "/Users/agox/worktrees/cobalt-tooltip-tone/packages/core/src/components/co-toast/co-toast.tsx",
|
|
219
219
|
"id": "src/components/co-toast/co-toast.tsx::CoToastVariant"
|
|
220
220
|
}
|
|
221
221
|
}
|
|
@@ -48,7 +48,9 @@
|
|
|
48
48
|
opacity: 0;
|
|
49
49
|
pointer-events: none;
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
/* Superficie única de panel + flecha: el tono la reemplaza en un solo lugar. */
|
|
52
|
+
--co-tooltip-surface: var(--co-color-base-negro, #1f1c1b);
|
|
53
|
+
background: var(--co-tooltip-surface);
|
|
52
54
|
color: var(--co-color-base-blanco, #fff);
|
|
53
55
|
font-family: var(--co-font-family-primary, 'Geist', sans-serif);
|
|
54
56
|
font-size: var(--co-font-size-12, 12px);
|
|
@@ -130,7 +132,7 @@
|
|
|
130
132
|
bottom: -10px;
|
|
131
133
|
left: 50%;
|
|
132
134
|
transform: translateX(-50%);
|
|
133
|
-
border-top-color: var(--co-
|
|
135
|
+
border-top-color: var(--co-tooltip-surface);
|
|
134
136
|
border-bottom: none;
|
|
135
137
|
}
|
|
136
138
|
|
|
@@ -139,7 +141,7 @@
|
|
|
139
141
|
top: -5px;
|
|
140
142
|
left: 50%;
|
|
141
143
|
transform: translateX(-50%);
|
|
142
|
-
border-bottom-color: var(--co-
|
|
144
|
+
border-bottom-color: var(--co-tooltip-surface);
|
|
143
145
|
border-top: none;
|
|
144
146
|
}
|
|
145
147
|
|
|
@@ -148,7 +150,7 @@
|
|
|
148
150
|
right: -10px;
|
|
149
151
|
top: 50%;
|
|
150
152
|
transform: translateY(-50%);
|
|
151
|
-
border-left-color: var(--co-
|
|
153
|
+
border-left-color: var(--co-tooltip-surface);
|
|
152
154
|
border-right: none;
|
|
153
155
|
}
|
|
154
156
|
|
|
@@ -157,10 +159,17 @@
|
|
|
157
159
|
left: -5px;
|
|
158
160
|
top: 50%;
|
|
159
161
|
transform: translateY(-50%);
|
|
160
|
-
border-right-color: var(--co-
|
|
162
|
+
border-right-color: var(--co-tooltip-surface);
|
|
161
163
|
border-left: none;
|
|
162
164
|
}
|
|
163
165
|
|
|
166
|
+
/* ── Tone: error (estado de un registro, p. ej. «Inactivo») ──── */
|
|
167
|
+
/* Aditivo: solo con tone="error". Sólido como el default (oscuro en ambos temas);
|
|
168
|
+
el blanco sobre status-error queda en ~6,3:1. */
|
|
169
|
+
.co-tooltip__panel--tone-error {
|
|
170
|
+
--co-tooltip-surface: var(--co-semantic-status-error, #aa2e1b);
|
|
171
|
+
}
|
|
172
|
+
|
|
164
173
|
/* ── Content ────────────────────────────────────────────── */
|
|
165
174
|
.co-tooltip__content {
|
|
166
175
|
display: block;
|
|
@@ -42,6 +42,12 @@ export class CoTooltip {
|
|
|
42
42
|
* arrow hide is CSS-only — `arrow`'s own default/behavior is unchanged.
|
|
43
43
|
*/
|
|
44
44
|
this.variant = 'default';
|
|
45
|
+
/**
|
|
46
|
+
* Color tone of the panel (and arrow). `error` = solid `--co-semantic-status-error`
|
|
47
|
+
* surface with white text, for a record/state warning (e.g. "Inactive").
|
|
48
|
+
* Independent of `variant`.
|
|
49
|
+
*/
|
|
50
|
+
this.tone = 'default';
|
|
45
51
|
// ── State ──────────────────────────────────────────────────
|
|
46
52
|
this.visible = false;
|
|
47
53
|
this.actualPlacement = 'top';
|
|
@@ -273,11 +279,12 @@ export class CoTooltip {
|
|
|
273
279
|
// ── Render ─────────────────────────────────────────────────
|
|
274
280
|
render() {
|
|
275
281
|
const side = this.actualPlacement.split('-')[0];
|
|
276
|
-
return (h("div", { key: '
|
|
282
|
+
return (h("div", { key: '53c8dbd21619fd8caa4105b86b4b1765c2361252', class: "co-tooltip" }, h("div", { key: 'f9e5e3b352b37c69a67538c6db3d10f9fc945976', class: "co-tooltip__trigger", ref: (el) => (this.triggerEl = el), onMouseEnter: this.handleMouseEnter, onMouseLeave: this.handleMouseLeave, onPointerDown: this.handlePointerDown, onFocusin: this.handleFocusIn, onFocusout: this.handleFocusOut, onKeyDown: this.handleKeyDown, "aria-describedby": this.visible ? 'tooltip-panel' : undefined }, h("slot", { key: '067ac53e5b491c7990acfa7c236ae2090a6657fc' })), (this.visible || this.closing) && this.content && (h("div", { key: '42436edfbd802bfd8c23dea5b8cfdd290fa150c7', id: "tooltip-panel", class: {
|
|
277
283
|
'co-tooltip__panel': true,
|
|
278
284
|
[`co-tooltip__panel--${side}`]: true,
|
|
279
285
|
'co-tooltip__panel--closing': this.closing,
|
|
280
286
|
'co-tooltip__panel--label': this.variant === 'label',
|
|
287
|
+
'co-tooltip__panel--tone-error': this.tone === 'error',
|
|
281
288
|
'co-tooltip__panel--with-shortcut': !!this.shortcut,
|
|
282
289
|
}, role: "tooltip", popover: "manual", part: "panel", onTransitionEnd: this.handlePanelTransitionEnd, ref: (el) => {
|
|
283
290
|
if (el && el !== this.panelEl) {
|
|
@@ -285,7 +292,7 @@ export class CoTooltip {
|
|
|
285
292
|
this.promotePanel();
|
|
286
293
|
this.scheduleUpdate();
|
|
287
294
|
}
|
|
288
|
-
}, style: { maxWidth: this.maxWidth } }, this.arrow && h("div", { key: '
|
|
295
|
+
}, style: { maxWidth: this.maxWidth } }, this.arrow && h("div", { key: '7520aaa3245fea55a7fcac31f33c56247b1fb5d8', class: `co-tooltip__arrow co-tooltip__arrow--${side}` }), h("span", { key: 'd3797d1c3a31c64cb30d4d8f448204e3a9f8c017', class: "co-tooltip__content" }, this.content), this.shortcut && h("co-kbd", { key: '01354b1fd110de3000d48ad9eaef0e3329a64e48', keys: this.shortcut, surface: "dark", size: "xs" })))));
|
|
289
296
|
}
|
|
290
297
|
static get is() { return "co-tooltip"; }
|
|
291
298
|
static get encapsulation() { return "shadow"; }
|
|
@@ -528,6 +535,26 @@ export class CoTooltip {
|
|
|
528
535
|
"attribute": "variant",
|
|
529
536
|
"defaultValue": "'default'"
|
|
530
537
|
},
|
|
538
|
+
"tone": {
|
|
539
|
+
"type": "string",
|
|
540
|
+
"mutable": false,
|
|
541
|
+
"complexType": {
|
|
542
|
+
"original": "'default' | 'error'",
|
|
543
|
+
"resolved": "\"default\" | \"error\"",
|
|
544
|
+
"references": {}
|
|
545
|
+
},
|
|
546
|
+
"required": false,
|
|
547
|
+
"optional": false,
|
|
548
|
+
"docs": {
|
|
549
|
+
"tags": [],
|
|
550
|
+
"text": "Color tone of the panel (and arrow). `error` = solid `--co-semantic-status-error`\nsurface with white text, for a record/state warning (e.g. \"Inactive\").\nIndependent of `variant`."
|
|
551
|
+
},
|
|
552
|
+
"getter": false,
|
|
553
|
+
"setter": false,
|
|
554
|
+
"reflect": false,
|
|
555
|
+
"attribute": "tone",
|
|
556
|
+
"defaultValue": "'default'"
|
|
557
|
+
},
|
|
531
558
|
"shortcut": {
|
|
532
559
|
"type": "string",
|
|
533
560
|
"mutable": false,
|
|
@@ -214,7 +214,7 @@ export class CoTransferList {
|
|
|
214
214
|
"references": {
|
|
215
215
|
"TransferOption": {
|
|
216
216
|
"location": "local",
|
|
217
|
-
"path": "/Users/agox/worktrees/cobalt-
|
|
217
|
+
"path": "/Users/agox/worktrees/cobalt-tooltip-tone/packages/core/src/components/co-transfer-list/co-transfer-list.tsx",
|
|
218
218
|
"id": "src/components/co-transfer-list/co-transfer-list.tsx::TransferOption"
|
|
219
219
|
}
|
|
220
220
|
}
|
|
@@ -243,7 +243,7 @@ export class CoTreeItem {
|
|
|
243
243
|
"references": {
|
|
244
244
|
"TreeItemSelection": {
|
|
245
245
|
"location": "local",
|
|
246
|
-
"path": "/Users/agox/worktrees/cobalt-
|
|
246
|
+
"path": "/Users/agox/worktrees/cobalt-tooltip-tone/packages/core/src/components/co-tree-item/co-tree-item.tsx",
|
|
247
247
|
"id": "src/components/co-tree-item/co-tree-item.tsx::TreeItemSelection"
|
|
248
248
|
}
|
|
249
249
|
}
|
|
@@ -269,7 +269,7 @@ export class CoTreeItem {
|
|
|
269
269
|
"references": {
|
|
270
270
|
"TreeItemSize": {
|
|
271
271
|
"location": "local",
|
|
272
|
-
"path": "/Users/agox/worktrees/cobalt-
|
|
272
|
+
"path": "/Users/agox/worktrees/cobalt-tooltip-tone/packages/core/src/components/co-tree-item/co-tree-item.tsx",
|
|
273
273
|
"id": "src/components/co-tree-item/co-tree-item.tsx::TreeItemSize"
|
|
274
274
|
}
|
|
275
275
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t,p as i,H as a,c as s,h as e}from"./index.js";import{d as o}from"./p-KK2vAKs-.js";function r(t){if(!Number.isFinite(t)||t<0)return"--:--";const i=Math.floor(t);return`${Math.floor(i/60)}:${(""+i%60).padStart(2,"0")}`}function c(t,i){const a=t.length;if(!a||i<=0)return[];const s=Math.max(1,Math.floor(a/i)),e=[];for(let o=0;o<i;o++){let i=0;const r=o*s;for(let e=r;e<r+s&&e<a;e++){const a=Math.abs(t[e]);a>i&&(i=a)}e.push(.12+.88*i)}return e}function h(t){if(t<=0)return[];const i=[];for(let a=0;a<t;a++)i.push(.12+(.6*Math.sin(a/Math.max(1,t)*Math.PI)+.3)*(.75+.25*Math.abs(Math.sin(1.7*a)))*.88);return i}const n=i(class extends a{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.coPlay=s(this,"coPlay",7),this.coPause=s(this,"coPause",7),this.coEnded=s(this,"coEnded",7),this.coError=s(this,"coError",7),this.coTimeUpdate=s(this,"coTimeUpdate",3),this.compact=!1,this.bars=64,this.barDensity=3,this.preload="metadata",this.downloadFilename="audio",this.noDownload=!1,this.isPlaying=!1,this.isLoading=!1,this.hasError=!1,this.currentTime=0,this.duration=NaN,this.peaks=[],this.containerWidth=0,this.playbackRate=1,this.rawChannelData=null,this.decodedDuration=NaN,this.loadToken=0,this.onMeta=()=>{this.syncDuration(),this.applyPendingSeek()},this.pendingSeek=null,this.onCanPlay=()=>{this.isLoading=!1,this.applyPendingSeek()},this.onWaiting=()=>{this.isLoading=!0},this.onTime=()=>{var t;this.currentTime=(null===(t=this.audio)||void 0===t?void 0:t.currentTime)||0,this.coTimeUpdate.emit({currentTime:this.currentTime,duration:this.knownDuration})},this.onEnded=()=>{this.isPlaying=!1,this.currentTime=0,this.coEnded.emit()},this.onErr=t=>{this.isLoading=!1,this.hasError=!0,this.coError.emit(t)},this.toggle=()=>{this.audio&&!this.hasError&&(this.isPlaying?(this.audio.pause(),this.isPlaying=!1,this.coPause.emit()):this.audio.play().then((()=>{this.isPlaying=!0,this.coPlay.emit()})).catch((()=>{})))},this.SPEEDS=[1,1.5,2,.5],this.cycleSpeed=()=>{const t=this.SPEEDS.indexOf(this.playbackRate);this.playbackRate=this.SPEEDS[(t+1)%this.SPEEDS.length],this.audio&&(this.audio.playbackRate=this.playbackRate)},this.seekAt=t=>{const i=this.knownDuration;if(!this.audio||!this.waveEl||!i)return;const a=function(t,i){return i.width?Math.max(0,Math.min(1,(t-i.left)/i.width)):0}(t,this.waveEl.getBoundingClientRect());this.audio.currentTime=a*i,this.currentTime=this.audio.currentTime},this.onWaveKey=t=>{if(" "===t.key||"Enter"===t.key)return t.preventDefault(),void this.toggle();if(!this.audio)return;const i=this.knownDuration,a=this.audio.currentTime;if("ArrowRight"===t.key)this.audio.currentTime=i?Math.min(i,a+5):a+5;else{if("ArrowLeft"!==t.key)return;this.audio.currentTime=Math.max(0,a-5)}this.currentTime=this.audio.currentTime}}get knownDuration(){return Number.isFinite(this.duration)&&this.duration>0?this.duration:0}get effectiveBars(){return this.containerWidth>0?Math.max(24,Math.floor(this.containerWidth/this.barDensity)):this.bars}componentWillLoad(){this.init()}componentDidLoad(){if("undefined"==typeof ResizeObserver||!this.waveEl)return;this.resizeObserver=new ResizeObserver((t=>{var i;for(const a of t){const t=(null===(i=a.contentRect)||void 0===i?void 0:i.width)||a.target.clientWidth||0;t>2&&Math.abs(t-this.containerWidth)>2&&(this.containerWidth=t,this.rebuildBars())}})),this.resizeObserver.observe(this.waveEl);const t=this.waveEl.clientWidth||0;t>2&&(this.containerWidth=t,this.rebuildBars())}disconnectedCallback(){var t;this.loadToken++,this.teardown(),null===(t=this.resizeObserver)||void 0===t||t.disconnect(),this.resizeObserver=void 0}onSrcChange(){this.init()}rebuildBars(){this.peaks=this.rawChannelData?c(this.rawChannelData,this.effectiveBars):h(this.effectiveBars)}init(){this.teardown();const t=++this.loadToken;if(this.rawChannelData=null,this.decodedDuration=NaN,this.peaks=h(this.effectiveBars),this.currentTime=0,this.duration=NaN,this.playbackRate=1,this.hasError=!1,!this.src)return;if(this.isLoading=!0,this.extractPeaks(this.src,t),"undefined"==typeof Audio)return;const i=new Audio;i.preload=this.preload,i.crossOrigin="anonymous",i.src=this.src,i.addEventListener("loadedmetadata",this.onMeta),i.addEventListener("timeupdate",this.onTime),i.addEventListener("ended",this.onEnded),i.addEventListener("error",this.onErr),i.addEventListener("canplay",this.onCanPlay),i.addEventListener("waiting",this.onWaiting),this.audio=i}teardown(){this.audio&&(this.audio.pause(),this.audio.removeEventListener("loadedmetadata",this.onMeta),this.audio.removeEventListener("timeupdate",this.onTime),this.audio.removeEventListener("ended",this.onEnded),this.audio.removeEventListener("error",this.onErr),this.audio.removeEventListener("canplay",this.onCanPlay),this.audio.removeEventListener("waiting",this.onWaiting),this.audio.src="",this.audio=void 0),this.isPlaying=!1}async extractPeaks(t,i){var a;let s;try{const a=window.OfflineAudioContext||window.webkitOfflineAudioContext,e=window.AudioContext||window.webkitAudioContext;if(!a&&!e||"undefined"==typeof fetch)return;s=a?new a(1,1,44100):new e;const o=await(await fetch(t)).arrayBuffer(),r=await s.decodeAudioData(o);if(i!==this.loadToken)return;this.rawChannelData=r.getChannelData(0),this.decodedDuration=r.duration,this.peaks=c(this.rawChannelData,this.effectiveBars)}catch(t){if(i!==this.loadToken)return;this.rawChannelData=null,this.decodedDuration=NaN,this.peaks=h(this.effectiveBars)}finally{try{await(null===(a=null==s?void 0:s.close)||void 0===a?void 0:a.call(s))}catch(t){}}i===this.loadToken&&this.syncDuration()}syncDuration(){var t,i;const a=function(t,i){return Number.isFinite(t)&&t>0?t:Number.isFinite(i)&&i>0?i:NaN}(null!==(i=null===(t=this.audio)||void 0===t?void 0:t.duration)&&void 0!==i?i:NaN,this.decodedDuration);Object.is(a,this.duration)||(this.duration=a)}applyPendingSeek(){if(null==this.pendingSeek||!this.audio)return;const t=this.pendingSeek;this.pendingSeek=null,this.audio.currentTime=t,this.currentTime=this.audio.currentTime,this.coTimeUpdate.emit({currentTime:this.currentTime,duration:this.knownDuration})}async seek(t){var i;if(!this.audio||!Number.isFinite(t))return;const a=this.knownDuration,s=Math.max(0,a?Math.min(a,t):t);this.audio.currentTime=s,Math.abs((null!==(i=this.audio.currentTime)&&void 0!==i?i:0)-s)>.05&&(this.pendingSeek=s),this.currentTime=s,this.coTimeUpdate.emit({currentTime:this.currentTime,duration:a})}async play(){if(this.audio&&!this.isPlaying&&!this.hasError)try{await this.audio.play(),this.isPlaying=!0,this.coPlay.emit()}catch(t){}}async download(){if(this.src&&"undefined"!=typeof fetch)try{const t=await(await fetch(this.src)).blob(),i=URL.createObjectURL(t),a=document.createElement("a");a.href=i,a.download=this.downloadFilename,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(i)}catch(t){}}render(){const t=Math.max(1,3*this.peaks.length),i=this.knownDuration,a=i?this.currentTime/i*100:0,s=i?Math.floor(i):void 0,o=(t,i,a=!1)=>e("rect",{key:"4b294190b3be5e7cf15282d43e7e51164a3dda4c",x:3*i,y:20-40*t/2,width:1.8,height:Math.max(40*t,2),rx:.6,class:{"co-audio-player__bar":!0,"co-audio-player__bar--played":a}});return e("div",{key:"0758a438c4a71e822de94f8b41219945f62ae62d",class:{"co-audio-player":!0,"co-audio-player--compact":this.compact,"co-audio-player--error":this.hasError,"co-audio-player--playing":this.isPlaying},part:"player"},e("button",{key:"4c4161e7ba7344a9c6a32dcc8fd92c300b750d95",type:"button",class:"co-audio-player__play",part:"play","aria-label":this.hasError?"Audio no disponible":this.isPlaying?"Pausar":"Reproducir","aria-busy":this.isLoading?"true":"false",disabled:this.hasError||!this.src,onClick:this.toggle},e("co-icon",{key:"ea749ee1cf627a49e3859029ca274170c8d69c63",name:this.hasError?"warning-circle":this.isPlaying?"pause":"play",weight:"fill",size:this.compact?12:14})),e("div",{key:"f39bf8bf114860a672979fa53287672dccea1b7f",class:"co-audio-player__wave",part:"wave",role:"slider",tabindex:"0","aria-label":"Progreso de reproducción","aria-valuemin":0,"aria-valuemax":s,"aria-valuenow":Math.floor(this.currentTime),ref:t=>this.waveEl=t,onClick:t=>this.seekAt(t.clientX),onKeyDown:this.onWaveKey},e("svg",{key:"2145f303271ca676988999b5ea7d76ab384c5e2d",class:"co-audio-player__svg",viewBox:`0 0 ${t} 40`,preserveAspectRatio:"none","aria-hidden":"true"},this.peaks.map(((t,i)=>o(t,i))),e("clipPath",{key:"6014c9f96f5df60086265a5e01344be80ebff741",id:"co-ap-clip"},e("rect",{key:"5857fa3098fc0eb9df58b643c2b44316cf819ae8",x:"0",y:"0",width:a/100*t,height:40})),e("g",{key:"241608ddfdb863ba5b18444ed2bffb39e72abeb5","clip-path":"url(#co-ap-clip)"},this.peaks.map(((t,i)=>o(t,i,!0)))))),e("span",{key:"18f190b8b23f8939da5dd2c230214d42a5b330c1",class:"co-audio-player__time",part:"time"},r(this.currentTime)," / ",r(this.duration)),!this.compact&&e("button",{key:"4a29cae938ab347997bc76e0cfe5621b402730f7",type:"button",class:"co-audio-player__speed",part:"speed","aria-label":`Velocidad de reproducción ${this.playbackRate}x`,onClick:this.cycleSpeed},this.playbackRate,"x"),!this.compact&&!this.noDownload&&e("button",{key:"c451449e629584bc3937b27b31b1124e510af91e",type:"button",class:"co-audio-player__dl",part:"download","aria-label":"Descargar",onClick:()=>this.download()},e("co-icon",{key:"f4d014129829ab57ddae0d3e32b1e0930f1bc288",name:"download-simple",size:14})))}static get watchers(){return{src:[{onSrcChange:0}]}}static get style(){return":host{display:block;font-family:var(--co-font-family-primary)}.co-audio-player{display:flex;align-items:center;gap:var(--co-spacing-md);padding:var(--co-spacing-sm) var(--co-spacing-md);border:1px solid var(--co-semantic-border-default);border-radius:var(--co-border-radius-xs);background:var(--co-semantic-surface-secondary);min-width:180px}.co-audio-player--compact{gap:var(--co-spacing-sm2);padding:var(--co-spacing-sm2) var(--co-spacing-sm);min-width:140px}.co-audio-player__play{flex:0 0 auto;width:28px;height:28px;border:none;border-radius:50%;cursor:pointer;background:var(--co-semantic-surface-primary);color:var(--co-semantic-text-inverse);display:inline-flex;align-items:center;justify-content:center}.co-audio-player--compact .co-audio-player__play{width:24px;height:24px}.co-audio-player__play:disabled{opacity:.5;cursor:not-allowed}.co-audio-player__play:focus-visible{outline:2px solid var(--co-semantic-border-focus);outline-offset:2px}.co-audio-player__wave{flex:1;height:40px;min-width:0;cursor:pointer;display:flex;align-items:center}.co-audio-player__wave:focus-visible{outline:2px solid var(--co-semantic-border-focus);outline-offset:2px;border-radius:var(--co-border-radius-xxs)}.co-audio-player__svg{width:100%;height:100%;display:block}.co-audio-player__bar{fill:var(--co-semantic-border-field);transition:fill var(--co-motion-duration-fast)}.co-audio-player__wave:hover .co-audio-player__bar{fill:var(--co-semantic-text-muted)}.co-audio-player__bar--played{fill:var(--co-semantic-surface-primary)}.co-audio-player__time{flex:0 0 auto;font-size:var(--co-font-size-12);color:var(--co-semantic-text-muted);font-variant-numeric:tabular-nums;min-width:62px;text-align:right}.co-audio-player__speed{flex:0 0 auto;border:none;background:transparent;cursor:pointer;padding:2px 4px;color:var(--co-semantic-text-muted);font-family:var(--co-font-family-primary);font-size:var(--co-font-size-12);font-variant-numeric:tabular-nums;min-width:34px;text-align:center}.co-audio-player__speed:hover{color:var(--co-semantic-text-default)}.co-audio-player__speed:focus-visible{outline:2px solid var(--co-semantic-border-focus);outline-offset:2px;border-radius:var(--co-border-radius-xxs)}.co-audio-player__dl{flex:0 0 auto;border:none;background:transparent;cursor:pointer;padding:2px;color:var(--co-semantic-text-muted);display:inline-flex}.co-audio-player__dl:hover{color:var(--co-semantic-text-default)}.co-audio-player__dl:focus-visible{outline:2px solid var(--co-semantic-border-focus);outline-offset:2px}.co-audio-player--error .co-audio-player__wave{opacity:.5}.co-audio-player--error .co-audio-player__play{background:var(--co-color-status-error);color:var(--co-semantic-text-inverse);opacity:1}"}},[1,"co-audio-player",{src:[1],compact:[4],bars:[2],barDensity:[2,"bar-density"],preload:[1],downloadFilename:[1,"download-filename"],noDownload:[4,"no-download"],isPlaying:[32],isLoading:[32],hasError:[32],currentTime:[32],duration:[32],peaks:[32],containerWidth:[32],playbackRate:[32],seek:[64],play:[64]},void 0,{src:[{onSrcChange:0}]}]);function d(){"undefined"!=typeof customElements&&["co-audio-player","co-icon"].forEach((i=>{switch(i){case"co-audio-player":customElements.get(t(i))||customElements.define(t(i),n);break;case"co-icon":customElements.get(t(i))||o()}}))}d();const l=n,u=d;export{l as CoAudioPlayer,u as defineCustomElement}
|
|
1
|
+
import{t,p as i,H as a,c as e,h as s}from"./index.js";import{d as o}from"./p-KK2vAKs-.js";function r(t){if(!Number.isFinite(t)||t<0)return"--:--";const i=Math.floor(t);return`${Math.floor(i/60)}:${(""+i%60).padStart(2,"0")}`}function n(t,i){const a=t.length;if(!a||i<=0)return[];const e=Math.max(1,Math.floor(a/i)),s=[];for(let o=0;o<i;o++){let i=0;const r=o*e;for(let s=r;s<r+e&&s<a;s++){const a=Math.abs(t[s]);a>i&&(i=a)}s.push(.12+.88*i)}return s}function h(t,i=65536){const a=t.length,e=Math.max(1,Math.ceil(a/Math.max(1,i))),s=Math.ceil(a/e),o=new Float32Array(s);for(let i=0;i<s;i++){let s=0;const r=Math.min(a,(i+1)*e);for(let a=i*e;a<r;a++){const i=Math.abs(t[a]);i>s&&(s=i)}o[i]=s}return{peaks:o,blockSize:e,length:a}}function c(t){if(t<=0)return[];const i=[];for(let a=0;a<t;a++)i.push(.12+(.6*Math.sin(a/Math.max(1,t)*Math.PI)+.3)*(.75+.25*Math.abs(Math.sin(1.7*a)))*.88);return i}const d=new Map,l=new Map;function u(t,i){for(d.delete(t),d.set(t,i);d.size>16;)d.delete(d.keys().next().value)}function p(t,i,a=f){const e=d.get(t);if(e)return u(t,e),Promise.resolve(e);const s=l.get(t);if(s)return i&&s.wanted.add(i),s.promise;const o=new Set(i?[i]:[]),r=a(t,o).then((i=>(l.delete(t),i&&u(t,i),i)),(i=>{throw l.delete(t),i}));return l.set(t,{promise:r,wanted:o}),r}async function f(t,i=new Set){var a;let e;try{const a=window.OfflineAudioContext||window.webkitOfflineAudioContext,s=window.AudioContext||window.webkitAudioContext;if(!a&&!s||"undefined"==typeof fetch)return null;e=a?new a(1,1,44100):new s;const o=await(await fetch(t)).arrayBuffer(),r=await e.decodeAudioData(o),n=r.getChannelData(0);return{envelope:h(n),exact:y(n,i),duration:r.duration}}finally{try{await(null===(a=null==e?void 0:e.close)||void 0===a?void 0:a.call(e))}catch(t){}}}function y(t,i){const a=new Map;for(const e of i){const i=e();i>0&&!a.has(i)&&a.set(i,n(t,i))}return a}const b=i(class extends a{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.coPlay=e(this,"coPlay",7),this.coPause=e(this,"coPause",7),this.coEnded=e(this,"coEnded",7),this.coError=e(this,"coError",7),this.coTimeUpdate=e(this,"coTimeUpdate",3),this.compact=!1,this.bars=64,this.barDensity=3,this.preload="metadata",this.downloadFilename="audio",this.noDownload=!1,this.isPlaying=!1,this.isLoading=!1,this.hasError=!1,this.currentTime=0,this.duration=NaN,this.peaks=[],this.containerWidth=0,this.playbackRate=1,this.peakEnvelope=null,this.exactPeaks=null,this.decodedDuration=NaN,this.loadToken=0,this.onMeta=()=>{this.syncDuration(),this.applyPendingSeek()},this.pendingSeek=null,this.onCanPlay=()=>{this.isLoading=!1,this.applyPendingSeek()},this.onWaiting=()=>{this.isLoading=!0},this.onTime=()=>{var t;this.currentTime=(null===(t=this.audio)||void 0===t?void 0:t.currentTime)||0,this.coTimeUpdate.emit({currentTime:this.currentTime,duration:this.knownDuration})},this.onEnded=()=>{this.isPlaying=!1,this.currentTime=0,this.coEnded.emit()},this.onErr=t=>{this.isLoading=!1,this.hasError=!0,this.coError.emit(t)},this.toggle=()=>{this.audio&&!this.hasError&&(this.isPlaying?(this.audio.pause(),this.isPlaying=!1,this.coPause.emit()):this.audio.play().then((()=>{this.isPlaying=!0,this.coPlay.emit()})).catch((()=>{})))},this.SPEEDS=[1,1.5,2,.5],this.cycleSpeed=()=>{const t=this.SPEEDS.indexOf(this.playbackRate);this.playbackRate=this.SPEEDS[(t+1)%this.SPEEDS.length],this.audio&&(this.audio.playbackRate=this.playbackRate)},this.seekAt=t=>{const i=this.knownDuration;if(!this.audio||!this.waveEl||!i)return;const a=function(t,i){return i.width?Math.max(0,Math.min(1,(t-i.left)/i.width)):0}(t,this.waveEl.getBoundingClientRect());this.audio.currentTime=a*i,this.currentTime=this.audio.currentTime},this.onWaveKey=t=>{if(" "===t.key||"Enter"===t.key)return t.preventDefault(),void this.toggle();if(!this.audio)return;const i=this.knownDuration,a=this.audio.currentTime;if("ArrowRight"===t.key)this.audio.currentTime=i?Math.min(i,a+5):a+5;else{if("ArrowLeft"!==t.key)return;this.audio.currentTime=Math.max(0,a-5)}this.currentTime=this.audio.currentTime}}get knownDuration(){return Number.isFinite(this.duration)&&this.duration>0?this.duration:0}get effectiveBars(){return this.containerWidth>0?Math.max(24,Math.floor(this.containerWidth/this.barDensity)):this.bars}componentWillLoad(){this.init()}componentDidLoad(){if("undefined"==typeof ResizeObserver||!this.waveEl)return;this.resizeObserver=new ResizeObserver((t=>{var i;for(const a of t){const t=(null===(i=a.contentRect)||void 0===i?void 0:i.width)||a.target.clientWidth||0;t>2&&Math.abs(t-this.containerWidth)>2&&(this.containerWidth=t,this.rebuildBars())}})),this.resizeObserver.observe(this.waveEl);const t=this.waveEl.clientWidth||0;t>2&&(this.containerWidth=t,this.rebuildBars())}disconnectedCallback(){var t;this.loadToken++,this.teardown(),null===(t=this.resizeObserver)||void 0===t||t.disconnect(),this.resizeObserver=void 0}onSrcChange(){this.init()}rebuildBars(){this.peaks=this.peakEnvelope?this.decodedBars(this.effectiveBars):c(this.effectiveBars)}decodedBars(t){var i,a;return null!==(a=null===(i=this.exactPeaks)||void 0===i?void 0:i.get(t))&&void 0!==a?a:function(t,i){const{peaks:a,blockSize:e,length:s}=t;if(!s||i<=0)return[];const o=Math.max(1,Math.floor(s/i)),r=[];for(let t=0;t<i;t++){const i=t*o,n=Math.min(i+o,s);let h=0;if(i<n){const t=Math.floor((n-1)/e);for(let s=Math.floor(i/e);s<=t;s++)a[s]>h&&(h=a[s])}r.push(.12+.88*h)}return r}(this.peakEnvelope,t)}init(){this.teardown();const t=++this.loadToken;if(this.peakEnvelope=null,this.exactPeaks=null,this.decodedDuration=NaN,this.peaks=c(this.effectiveBars),this.currentTime=0,this.duration=NaN,this.playbackRate=1,this.hasError=!1,!this.src)return;if(this.isLoading=!0,this.extractPeaks(this.src,t),"undefined"==typeof Audio)return;const i=new Audio;i.preload=this.preload,i.crossOrigin="anonymous",i.src=this.src,i.addEventListener("loadedmetadata",this.onMeta),i.addEventListener("timeupdate",this.onTime),i.addEventListener("ended",this.onEnded),i.addEventListener("error",this.onErr),i.addEventListener("canplay",this.onCanPlay),i.addEventListener("waiting",this.onWaiting),this.audio=i}teardown(){this.audio&&(this.audio.pause(),this.audio.removeEventListener("loadedmetadata",this.onMeta),this.audio.removeEventListener("timeupdate",this.onTime),this.audio.removeEventListener("ended",this.onEnded),this.audio.removeEventListener("error",this.onErr),this.audio.removeEventListener("canplay",this.onCanPlay),this.audio.removeEventListener("waiting",this.onWaiting),this.audio.src="",this.audio=void 0),this.isPlaying=!1}async extractPeaks(t,i){try{const a=await p(t,(()=>i===this.loadToken?this.effectiveBars:0));if(i!==this.loadToken)return;if(!a)return;this.peakEnvelope=a.envelope,this.exactPeaks=a.exact,this.decodedDuration=a.duration,this.peaks=this.decodedBars(this.effectiveBars)}catch(t){if(i!==this.loadToken)return;this.peakEnvelope=null,this.exactPeaks=null,this.decodedDuration=NaN,this.peaks=c(this.effectiveBars)}i===this.loadToken&&this.syncDuration()}syncDuration(){var t,i;const a=function(t,i){return Number.isFinite(t)&&t>0?t:Number.isFinite(i)&&i>0?i:NaN}(null!==(i=null===(t=this.audio)||void 0===t?void 0:t.duration)&&void 0!==i?i:NaN,this.decodedDuration);Object.is(a,this.duration)||(this.duration=a)}applyPendingSeek(){if(null==this.pendingSeek||!this.audio)return;const t=this.pendingSeek;this.pendingSeek=null,this.audio.currentTime=t,this.currentTime=this.audio.currentTime,this.coTimeUpdate.emit({currentTime:this.currentTime,duration:this.knownDuration})}async seek(t){var i;if(!this.audio||!Number.isFinite(t))return;const a=this.knownDuration,e=Math.max(0,a?Math.min(a,t):t);this.audio.currentTime=e,Math.abs((null!==(i=this.audio.currentTime)&&void 0!==i?i:0)-e)>.05&&(this.pendingSeek=e),this.currentTime=e,this.coTimeUpdate.emit({currentTime:this.currentTime,duration:a})}async play(){if(this.audio&&!this.isPlaying&&!this.hasError)try{await this.audio.play(),this.isPlaying=!0,this.coPlay.emit()}catch(t){}}async download(){if(this.src&&"undefined"!=typeof fetch)try{const t=await(await fetch(this.src)).blob(),i=URL.createObjectURL(t),a=document.createElement("a");a.href=i,a.download=this.downloadFilename,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(i)}catch(t){}}render(){const t=Math.max(1,3*this.peaks.length),i=this.knownDuration,a=i?this.currentTime/i*100:0,e=i?Math.floor(i):void 0,o=(t,i,a=!1)=>s("rect",{key:"a3d5a225a904e22ba9905ef8198fa7e1b14e0e2f",x:3*i,y:20-40*t/2,width:1.8,height:Math.max(40*t,2),rx:.6,class:{"co-audio-player__bar":!0,"co-audio-player__bar--played":a}});return s("div",{key:"afbbf524713a1146653e69928ee21e263202315f",class:{"co-audio-player":!0,"co-audio-player--compact":this.compact,"co-audio-player--error":this.hasError,"co-audio-player--playing":this.isPlaying},part:"player"},s("button",{key:"5918385fbd8fb6fad4795e1a75eed5d073e0654c",type:"button",class:"co-audio-player__play",part:"play","aria-label":this.hasError?"Audio no disponible":this.isPlaying?"Pausar":"Reproducir","aria-busy":this.isLoading?"true":"false",disabled:this.hasError||!this.src,onClick:this.toggle},s("co-icon",{key:"e7a566257df253914593712bd20029bb8f1bcdfd",name:this.hasError?"warning-circle":this.isPlaying?"pause":"play",weight:"fill",size:this.compact?12:14})),s("div",{key:"70488015726d0c966fa3e738d9f2893d71b99ebf",class:"co-audio-player__wave",part:"wave",role:"slider",tabindex:"0","aria-label":"Progreso de reproducción","aria-valuemin":0,"aria-valuemax":e,"aria-valuenow":Math.floor(this.currentTime),ref:t=>this.waveEl=t,onClick:t=>this.seekAt(t.clientX),onKeyDown:this.onWaveKey},s("svg",{key:"8c70e4f74537e5f8ab6f66bc0da464a72507e81c",class:"co-audio-player__svg",viewBox:`0 0 ${t} 40`,preserveAspectRatio:"none","aria-hidden":"true"},this.peaks.map(((t,i)=>o(t,i))),s("clipPath",{key:"f0d37d76b3d6ab09dbd09582c8657b3fe7cb8c4c",id:"co-ap-clip"},s("rect",{key:"436de0ce10f98c868760c76505d134f3db2dbb54",x:"0",y:"0",width:a/100*t,height:40})),s("g",{key:"939a1a8851d6e41b4d3c37d7201f87a6403830bb","clip-path":"url(#co-ap-clip)"},this.peaks.map(((t,i)=>o(t,i,!0)))))),s("span",{key:"bd57bdd97a780864aa633ec5174d4f733799a278",class:"co-audio-player__time",part:"time"},r(this.currentTime)," / ",r(this.duration)),!this.compact&&s("button",{key:"d1f559546da0b0f97009afca79fe922ce569e67f",type:"button",class:"co-audio-player__speed",part:"speed","aria-label":`Velocidad de reproducción ${this.playbackRate}x`,onClick:this.cycleSpeed},this.playbackRate,"x"),!this.compact&&!this.noDownload&&s("button",{key:"a1503b85bb2edf02566dcad9b8e83b1fea20b159",type:"button",class:"co-audio-player__dl",part:"download","aria-label":"Descargar",onClick:()=>this.download()},s("co-icon",{key:"dc96b8afdb8036e76a0c515d76c625460f4fc44d",name:"download-simple",size:14})))}static get watchers(){return{src:[{onSrcChange:0}]}}static get style(){return":host{display:block;font-family:var(--co-font-family-primary)}.co-audio-player{display:flex;align-items:center;gap:var(--co-spacing-md);padding:var(--co-spacing-sm) var(--co-spacing-md);border:1px solid var(--co-semantic-border-default);border-radius:var(--co-border-radius-xs);background:var(--co-semantic-surface-secondary);min-width:180px}.co-audio-player--compact{gap:var(--co-spacing-sm2);padding:var(--co-spacing-sm2) var(--co-spacing-sm);min-width:140px}.co-audio-player__play{flex:0 0 auto;width:28px;height:28px;border:none;border-radius:50%;cursor:pointer;background:var(--co-semantic-surface-primary);color:var(--co-semantic-text-inverse);display:inline-flex;align-items:center;justify-content:center}.co-audio-player--compact .co-audio-player__play{width:24px;height:24px}.co-audio-player__play:disabled{opacity:.5;cursor:not-allowed}.co-audio-player__play:focus-visible{outline:2px solid var(--co-semantic-border-focus);outline-offset:2px}.co-audio-player__wave{flex:1;height:40px;min-width:0;cursor:pointer;display:flex;align-items:center}.co-audio-player__wave:focus-visible{outline:2px solid var(--co-semantic-border-focus);outline-offset:2px;border-radius:var(--co-border-radius-xxs)}.co-audio-player__svg{width:100%;height:100%;display:block}.co-audio-player__bar{fill:var(--co-semantic-border-field);transition:fill var(--co-motion-duration-fast)}.co-audio-player__wave:hover .co-audio-player__bar{fill:var(--co-semantic-text-muted)}.co-audio-player__bar--played{fill:var(--co-semantic-surface-primary)}.co-audio-player__time{flex:0 0 auto;font-size:var(--co-font-size-12);color:var(--co-semantic-text-muted);font-variant-numeric:tabular-nums;min-width:62px;text-align:right}.co-audio-player__speed{flex:0 0 auto;border:none;background:transparent;cursor:pointer;padding:2px 4px;color:var(--co-semantic-text-muted);font-family:var(--co-font-family-primary);font-size:var(--co-font-size-12);font-variant-numeric:tabular-nums;min-width:34px;text-align:center}.co-audio-player__speed:hover{color:var(--co-semantic-text-default)}.co-audio-player__speed:focus-visible{outline:2px solid var(--co-semantic-border-focus);outline-offset:2px;border-radius:var(--co-border-radius-xxs)}.co-audio-player__dl{flex:0 0 auto;border:none;background:transparent;cursor:pointer;padding:2px;color:var(--co-semantic-text-muted);display:inline-flex}.co-audio-player__dl:hover{color:var(--co-semantic-text-default)}.co-audio-player__dl:focus-visible{outline:2px solid var(--co-semantic-border-focus);outline-offset:2px}.co-audio-player--error .co-audio-player__wave{opacity:.5}.co-audio-player--error .co-audio-player__play{background:var(--co-color-status-error);color:var(--co-semantic-text-inverse);opacity:1}"}},[1,"co-audio-player",{src:[1],compact:[4],bars:[2],barDensity:[2,"bar-density"],preload:[1],downloadFilename:[1,"download-filename"],noDownload:[4,"no-download"],isPlaying:[32],isLoading:[32],hasError:[32],currentTime:[32],duration:[32],peaks:[32],containerWidth:[32],playbackRate:[32],seek:[64],play:[64]},void 0,{src:[{onSrcChange:0}]}]);function m(){"undefined"!=typeof customElements&&["co-audio-player","co-icon"].forEach((i=>{switch(i){case"co-audio-player":customElements.get(t(i))||customElements.define(t(i),b);break;case"co-icon":customElements.get(t(i))||o()}}))}m();const v=b,w=m;export{v as CoAudioPlayer,w as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e,p as t,H as o,c,h as a}from"./index.js";import{R as i}from"./p-CWneqh4n.js";import{d as s}from"./p-VcrjNCew.js";import{d as r}from"./p-C_6szR7t.js";import{d as l}from"./p-KK2vAKs-.js";import{d as n}from"./p-8XzG8pzY.js";import{d as p}from"./p-BH184F0X.js";import{d as h}from"./p-BqFBZ1PT.js";import{d}from"./p-9VoFSbIH.js";const u=t(class extends o{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.coSearch=c(this,"coSearch",7),this.coChange=c(this,"coChange",7),this.coClear=c(this,"coClear",7),this.required=!1,this.placeholder="Search…",this.disabled=!1,this.clearable=!0,this.layout="vertical",this.size="md",this.status="default",this.options="[]",this.value="",this.multiple=!1,this.loading=!1,this.minChars=1,this.searchDebounce=300,this.emptyMessage="No results",this.isOpen=!1,this.query="",this.focused=!1,this.handleInput=e=>{const t=e.target.value;this.query=t,this.debounceTimer&&clearTimeout(this.debounceTimer),t.length>=this.minChars?(this.debounceTimer=setTimeout((()=>this.coSearch.emit(t)),this.searchDebounce),this.isOpen=!0):this.isOpen=!1},this.handleFocus=()=>{this.focused=!0,this.query.length>=this.minChars&&this.parsedOptions.length>0&&(this.isOpen=!0)},this.handleClear=e=>{var t;e.stopPropagation(),this.query="",this.value=this.multiple?"[]":"",this.isOpen=!1,this.coClear.emit(),this.coChange.emit({value:this.multiple?[]:"",item:null}),null===(t=this.inputEl)||void 0===t||t.focus()},this.handleChipRemove=e=>{const t=this.selectedValues.filter((t=>t!==e));this.value=JSON.stringify(t),this.coChange.emit({value:t,item:{_id:e,label:e}})},this.handleListChange=e=>{if(null==e.value)return this.value=this.multiple?"[]":"",this.query="",this.isOpen=!1,void this.coChange.emit({value:null,item:null});this.multiple?(this.value=JSON.stringify(e.value),this.coChange.emit({value:e.value,item:e.item})):(this.value=e.value,this.query=e.item.label,this.isOpen=!1,this.coChange.emit({value:e.value,item:e.item}))},this.handleInputKeyDown=async e=>{"Escape"!==e.key?this.isOpen&&this.optionListEl&&("ArrowDown"!==e.key&&"ArrowUp"!==e.key&&"Enter"!==e.key||(e.preventDefault(),await this.optionListEl.handleKey(e))):this.isOpen=!1}}get parsedOptions(){let e=this.options;if("string"==typeof e)try{e=JSON.parse(e)}catch(e){return[]}return Array.isArray(e)?e.map((e=>"string"==typeof e?{label:e,value:e}:e)):[]}get selectedValues(){if(this.multiple){if("string"==typeof this.value)try{return JSON.parse(this.value)}catch(e){return this.value?[this.value]:[]}return this.value}return"string"==typeof this.value&&this.value?[this.value]:[]}get hasValue(){return this.selectedValues.length>0}get statusIcon(){return{error:"warning-circle",success:"check-circle",warning:"warning",info:"info"}[this.status]||null}componentWillLoad(){this.syncQueryFromValue()}onOptionsChange(){this.query.length>=this.minChars&&(this.isOpen=!0),this.focused||this.syncQueryFromValue()}onValueChange(){this.syncQueryFromValue()}syncQueryFromValue(){if(!this.multiple&&"string"==typeof this.value&&this.value){const e=this.parsedOptions.find((e=>e.value===this.value));this.query=e?e.label:this.value}else this.multiple||this.value||(this.query="")}handleDocumentClick(e){this.el.contains(e.target)||(this.isOpen=!1,this.focused=!1)}render(){const e=this.parsedOptions,t=this.selectedValues;return a("div",{key:"02fe5e70777f1a39038af676c76032ae1fbecbc8",class:{"co-autocomplete":!0,"co-autocomplete--disabled":this.disabled,"co-autocomplete--focused":this.focused,["co-autocomplete--"+this.size]:!0,["co-autocomplete--"+this.status]:"default"!==this.status}},(this.label||this.secondaryLabel)&&a("div",{key:"a9237e72752d5d3921d70cb2d63a160625db7e62",class:"co-autocomplete__labels"},this.label&&a("label",{key:"f1284520b961bf6598e4b9c8a3d943b8b1aa847f",class:"co-autocomplete__label"},this.label,a(i,{key:"6c40530c3e2dca2b3adef8a8ce00c256b7070b48",required:this.required})),this.secondaryLabel&&a("span",{key:"37a0de4ba199f1bc6503543e18261623642c00cf",class:"co-autocomplete__secondary-label"},this.secondaryLabel)),a("div",{key:"30ff3eacbf9634085b212135356c3edbef6e8df9",class:"co-autocomplete__field"},this.iconLeft&&a("co-icon",{key:"3b8c564aae36e7db59c39fcc31fda7d98f55fae8",name:this.iconLeft,size:16,class:"co-autocomplete__icon"}),this.multiple&&t.length>0&&a("div",{key:"df7f0b08d2b456a048368f80c828ee83502b0a20",class:"co-autocomplete__chips"},t.map((e=>{const t=this.parsedOptions.find((t=>t.value===e));return a("co-chip",{label:t?t.label:e,size:"small",removable:!0,onCoRemove:()=>this.handleChipRemove(e)})}))),a("input",{key:"e2d9cfa48001c20aa9e8a4ef5800135172b2aff9",ref:e=>this.inputEl=e,class:"co-autocomplete__input",type:"text",value:this.query,placeholder:this.placeholder,disabled:this.disabled,onInput:this.handleInput,onFocus:this.handleFocus,onKeyDown:this.handleInputKeyDown}),this.loading&&a("div",{key:"e58449cb033553a123f3c2b1daa9b9c62a571273",class:"co-autocomplete__spinner"}),this.clearable&&(this.hasValue||this.query)&&!this.disabled&&a("button",{key:"ea8021e0807cd0eece9933f84772f5f497d2a63c",class:"co-autocomplete__clear",type:"button",tabIndex:-1,onClick:this.handleClear,"aria-label":"Clear"},a("co-icon",{key:"67a2f961d0ece0178811aa04fd9e5a082976ef6a",name:"x-circle",size:16,weight:"fill"}))),this.isOpen&&a("div",{key:"562cc6f307edd60c361c60974d0423550d8f681a",class:"co-autocomplete__dropdown"},a("co-option-list",{key:"3dec3da0d38adb8986b57960c74b697ffbc211dd",ref:e=>this.optionListEl=e,items:JSON.stringify(e.map((e=>({_id:e.value,label:e.label,icon:e.icon,disabled:e.disabled})))),value:this.multiple?JSON.stringify(this.selectedValues):this.selectedValues[0]||"",multiple:this.multiple,selectedAffordance:"check",virtual:!0,loading:this.loading,emptyMessage:this.emptyMessage,onCoChange:e=>this.handleListChange(e.detail)})),this.helperText&&a("div",{key:"5c21f62defe09b0160aeec8eaeaa881408dbe964",class:"co-autocomplete__helper co-autocomplete__helper--"+this.status},this.statusIcon&&a("co-icon",{key:"166ccdb5f1e308bb0212c473881bb36a33a8d2e4",name:this.statusIcon,size:14,weight:"fill",class:"co-autocomplete__helper-icon"}),a("span",{key:"bf4b038b665c269484b3bf841b19c92d5b0ceb27",class:"co-autocomplete__helper-text"},this.helperText)))}get el(){return this}static get watchers(){return{options:[{onOptionsChange:0}],value:[{onValueChange:0}]}}static get style(){return":host{display:block;font-family:var(--co-font-family-primary);font-size:var(--co-font-size-14);letter-spacing:var(--co-font-letter-spacing-body);line-height:1;position:relative}.co-autocomplete{display:flex;flex-direction:column;gap:var(--co-spacing-sm2);position:relative}.co-autocomplete__labels{display:flex;align-items:center;justify-content:space-between;padding:0 var(--co-spacing-xs);gap:var(--co-spacing-sm2)}.co-autocomplete__label{color:var(--co-semantic-text-secondary);font-size:var(--co-font-size-14);font-weight:400;line-height:1;white-space:nowrap;cursor:default}.co-autocomplete__secondary-label{color:var(--co-semantic-text-muted);font-size:var(--co-font-size-14);font-weight:400;line-height:1;white-space:nowrap;text-align:right}.co-autocomplete--disabled .co-autocomplete__label,.co-autocomplete--disabled .co-autocomplete__secondary-label{color:var(--co-semantic-text-disabled)}.co-autocomplete__field{display:flex;align-items:center;flex-wrap:wrap;gap:var(--co-spacing-xs);padding:var(--co-spacing-sm2) var(--co-spacing-md);background:var(--co-semantic-surface-page);border:1px solid var(--co-semantic-border-field);border-radius:var(--co-border-radius-xs);min-height:40px;box-sizing:border-box;transition:border-color var(--co-motion-duration-fast) var(--co-motion-ease-out), box-shadow var(--co-motion-duration-fast) var(--co-motion-ease-out)}.co-autocomplete--s .co-autocomplete__field{min-height:28px;padding:var(--co-spacing-xxs) var(--co-spacing-sm);font-size:var(--co-font-size-12)}.co-autocomplete--sm .co-autocomplete__field{min-height:32px;padding:var(--co-spacing-xs) var(--co-spacing-sm);font-size:var(--co-font-size-14)}.co-autocomplete--lg .co-autocomplete__field{min-height:48px;padding:var(--co-spacing-sm) var(--co-spacing-lg);font-size:var(--co-font-size-16)}.co-autocomplete--focused .co-autocomplete__field{border-color:var(--co-semantic-border-focus);box-shadow:0 0 0 2px var(--co-semantic-border-focus-ring)}.co-autocomplete--disabled .co-autocomplete__field{background:var(--co-semantic-surface-disabled);border-color:transparent;cursor:not-allowed}.co-autocomplete--error .co-autocomplete__field{border-color:var(--co-semantic-status-error)}.co-autocomplete--success .co-autocomplete__field{border-color:var(--co-semantic-status-success)}.co-autocomplete--warning .co-autocomplete__field{border-color:var(--co-color-status-review)}.co-autocomplete--info .co-autocomplete__field{border-color:var(--co-semantic-status-info)}.co-autocomplete__icon{flex-shrink:0;color:var(--co-semantic-text-muted);display:flex;align-items:center}.co-autocomplete__chips{display:flex;flex-wrap:wrap;gap:var(--co-spacing-xs)}.co-autocomplete__input{flex:1;min-width:80px;border:none;background:transparent;color:var(--co-semantic-text-default);font-family:inherit;font-size:inherit;font-weight:400;line-height:1;padding:0;outline:none}.co-autocomplete__input::placeholder{color:var(--co-semantic-text-muted)}.co-autocomplete--disabled .co-autocomplete__input{color:var(--co-semantic-text-disabled);cursor:not-allowed}.co-autocomplete__clear{flex-shrink:0;display:flex;align-items:center;padding:0;margin:0;border:none;background:transparent;cursor:pointer;color:var(--co-semantic-text-muted);transition:color var(--co-motion-duration-fast) var(--co-motion-ease-out)}.co-autocomplete__clear:hover{color:var(--co-semantic-text-default)}.co-autocomplete__spinner{width:16px;height:16px;border:2px solid var(--co-semantic-border-subtle);border-top-color:var(--co-semantic-text-default);border-radius:var(--co-border-radius-full);animation:co-spin 0.6s linear infinite;flex-shrink:0}@keyframes co-spin{to{transform:rotate(360deg)}}.co-autocomplete__dropdown{position:absolute;top:100%;left:0;right:0;z-index:100;margin-top:var(--co-spacing-xs);background:var(--co-semantic-surface-secondary);border:1px solid var(--co-semantic-border-subtle);border-radius:var(--co-border-radius-sm, 12px);box-shadow:0 4px 16px rgba(31, 28, 27, 0.08);overflow:hidden;}.co-autocomplete__helper{display:flex;align-items:center;gap:var(--co-spacing-xs);padding:0 var(--co-spacing-xs)}.co-autocomplete__helper-icon{flex-shrink:0;display:flex;align-items:center}.co-autocomplete__helper-text{color:var(--co-semantic-text-muted);font-size:var(--co-font-size-14);font-weight:400;line-height:1}.co-autocomplete__helper--error .co-autocomplete__helper-icon,.co-autocomplete__helper--error .co-autocomplete__helper-text{color:var(--co-semantic-status-error)}.co-autocomplete__helper--success .co-autocomplete__helper-icon,.co-autocomplete__helper--success .co-autocomplete__helper-text{color:var(--co-semantic-status-success)}.co-autocomplete__helper--warning .co-autocomplete__helper-icon,.co-autocomplete__helper--warning .co-autocomplete__helper-text{color:var(--co-color-status-review)}.co-autocomplete__helper--info .co-autocomplete__helper-icon,.co-autocomplete__helper--info .co-autocomplete__helper-text{color:var(--co-semantic-status-info)}:host([layout='horizontal']) .co-autocomplete{display:grid;grid-template-columns:var(--co-field-label-width, max-content) 1fr;align-items:start;column-gap:var(--co-spacing-md);row-gap:var(--co-spacing-sm2)}:host([layout='horizontal']) .co-autocomplete__labels{grid-column:1;grid-row:1;padding-top:var(--co-spacing-sm2);min-width:0}:host([layout='horizontal']) .co-autocomplete__label{white-space:normal}:host([layout='horizontal']) .co-autocomplete>:not(.co-autocomplete__labels){grid-column:2;min-width:0}.co-field-required{margin-left:2px;color:var(--co-color-status-error)}.co-field-required__caption{margin-left:4px;color:var(--co-semantic-text-muted);font-size:var(--co-font-size-12);font-weight:400}.co-field-required__caption::before{content:var(--co-field-required-text, ' (required)')}"}},[1,"co-autocomplete",{label:[1],required:[4],secondaryLabel:[1,"secondary-label"],placeholder:[1],disabled:[4],iconLeft:[1,"icon-left"],clearable:[4],helperText:[1,"helper-text"],layout:[513],size:[513],status:[1],options:[1],value:[1025],multiple:[4],loading:[4],minChars:[2,"min-chars"],searchDebounce:[2,"search-debounce"],emptyMessage:[1,"empty-message"],isOpen:[32],query:[32],focused:[32]},[[4,"click","handleDocumentClick"]],{options:[{onOptionsChange:0}],value:[{onValueChange:0}]}]);function m(){"undefined"!=typeof customElements&&["co-autocomplete","co-avatar","co-chip","co-icon","co-kbd","co-loader","co-option-list","co-tooltip"].forEach((t=>{switch(t){case"co-autocomplete":customElements.get(e(t))||customElements.define(e(t),u);break;case"co-avatar":customElements.get(e(t))||s();break;case"co-chip":customElements.get(e(t))||r();break;case"co-icon":customElements.get(e(t))||l();break;case"co-kbd":customElements.get(e(t))||n();break;case"co-loader":customElements.get(e(t))||p();break;case"co-option-list":customElements.get(e(t))||h();break;case"co-tooltip":customElements.get(e(t))||d()}}))}m();const f=u,b=m;export{f as CoAutocomplete,b as defineCustomElement}
|
|
1
|
+
import{t as e,p as t,H as o,c,h as a}from"./index.js";import{R as i}from"./p-CWneqh4n.js";import{d as s}from"./p-BzNBPHen.js";import{d as r}from"./p-C_6szR7t.js";import{d as l}from"./p-KK2vAKs-.js";import{d as n}from"./p-8XzG8pzY.js";import{d as p}from"./p-BH184F0X.js";import{d as h}from"./p-BW10Sgiy.js";import{d}from"./p-V7HYy0VO.js";const u=t(class extends o{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.coSearch=c(this,"coSearch",7),this.coChange=c(this,"coChange",7),this.coClear=c(this,"coClear",7),this.required=!1,this.placeholder="Search…",this.disabled=!1,this.clearable=!0,this.layout="vertical",this.size="md",this.status="default",this.options="[]",this.value="",this.multiple=!1,this.loading=!1,this.minChars=1,this.searchDebounce=300,this.emptyMessage="No results",this.isOpen=!1,this.query="",this.focused=!1,this.handleInput=e=>{const t=e.target.value;this.query=t,this.debounceTimer&&clearTimeout(this.debounceTimer),t.length>=this.minChars?(this.debounceTimer=setTimeout((()=>this.coSearch.emit(t)),this.searchDebounce),this.isOpen=!0):this.isOpen=!1},this.handleFocus=()=>{this.focused=!0,this.query.length>=this.minChars&&this.parsedOptions.length>0&&(this.isOpen=!0)},this.handleClear=e=>{var t;e.stopPropagation(),this.query="",this.value=this.multiple?"[]":"",this.isOpen=!1,this.coClear.emit(),this.coChange.emit({value:this.multiple?[]:"",item:null}),null===(t=this.inputEl)||void 0===t||t.focus()},this.handleChipRemove=e=>{const t=this.selectedValues.filter((t=>t!==e));this.value=JSON.stringify(t),this.coChange.emit({value:t,item:{_id:e,label:e}})},this.handleListChange=e=>{if(null==e.value)return this.value=this.multiple?"[]":"",this.query="",this.isOpen=!1,void this.coChange.emit({value:null,item:null});this.multiple?(this.value=JSON.stringify(e.value),this.coChange.emit({value:e.value,item:e.item})):(this.value=e.value,this.query=e.item.label,this.isOpen=!1,this.coChange.emit({value:e.value,item:e.item}))},this.handleInputKeyDown=async e=>{"Escape"!==e.key?this.isOpen&&this.optionListEl&&("ArrowDown"!==e.key&&"ArrowUp"!==e.key&&"Enter"!==e.key||(e.preventDefault(),await this.optionListEl.handleKey(e))):this.isOpen=!1}}get parsedOptions(){let e=this.options;if("string"==typeof e)try{e=JSON.parse(e)}catch(e){return[]}return Array.isArray(e)?e.map((e=>"string"==typeof e?{label:e,value:e}:e)):[]}get selectedValues(){if(this.multiple){if("string"==typeof this.value)try{return JSON.parse(this.value)}catch(e){return this.value?[this.value]:[]}return this.value}return"string"==typeof this.value&&this.value?[this.value]:[]}get hasValue(){return this.selectedValues.length>0}get statusIcon(){return{error:"warning-circle",success:"check-circle",warning:"warning",info:"info"}[this.status]||null}componentWillLoad(){this.syncQueryFromValue()}onOptionsChange(){this.query.length>=this.minChars&&(this.isOpen=!0),this.focused||this.syncQueryFromValue()}onValueChange(){this.syncQueryFromValue()}syncQueryFromValue(){if(!this.multiple&&"string"==typeof this.value&&this.value){const e=this.parsedOptions.find((e=>e.value===this.value));this.query=e?e.label:this.value}else this.multiple||this.value||(this.query="")}handleDocumentClick(e){this.el.contains(e.target)||(this.isOpen=!1,this.focused=!1)}render(){const e=this.parsedOptions,t=this.selectedValues;return a("div",{key:"02fe5e70777f1a39038af676c76032ae1fbecbc8",class:{"co-autocomplete":!0,"co-autocomplete--disabled":this.disabled,"co-autocomplete--focused":this.focused,["co-autocomplete--"+this.size]:!0,["co-autocomplete--"+this.status]:"default"!==this.status}},(this.label||this.secondaryLabel)&&a("div",{key:"a9237e72752d5d3921d70cb2d63a160625db7e62",class:"co-autocomplete__labels"},this.label&&a("label",{key:"f1284520b961bf6598e4b9c8a3d943b8b1aa847f",class:"co-autocomplete__label"},this.label,a(i,{key:"6c40530c3e2dca2b3adef8a8ce00c256b7070b48",required:this.required})),this.secondaryLabel&&a("span",{key:"37a0de4ba199f1bc6503543e18261623642c00cf",class:"co-autocomplete__secondary-label"},this.secondaryLabel)),a("div",{key:"30ff3eacbf9634085b212135356c3edbef6e8df9",class:"co-autocomplete__field"},this.iconLeft&&a("co-icon",{key:"3b8c564aae36e7db59c39fcc31fda7d98f55fae8",name:this.iconLeft,size:16,class:"co-autocomplete__icon"}),this.multiple&&t.length>0&&a("div",{key:"df7f0b08d2b456a048368f80c828ee83502b0a20",class:"co-autocomplete__chips"},t.map((e=>{const t=this.parsedOptions.find((t=>t.value===e));return a("co-chip",{label:t?t.label:e,size:"small",removable:!0,onCoRemove:()=>this.handleChipRemove(e)})}))),a("input",{key:"e2d9cfa48001c20aa9e8a4ef5800135172b2aff9",ref:e=>this.inputEl=e,class:"co-autocomplete__input",type:"text",value:this.query,placeholder:this.placeholder,disabled:this.disabled,onInput:this.handleInput,onFocus:this.handleFocus,onKeyDown:this.handleInputKeyDown}),this.loading&&a("div",{key:"e58449cb033553a123f3c2b1daa9b9c62a571273",class:"co-autocomplete__spinner"}),this.clearable&&(this.hasValue||this.query)&&!this.disabled&&a("button",{key:"ea8021e0807cd0eece9933f84772f5f497d2a63c",class:"co-autocomplete__clear",type:"button",tabIndex:-1,onClick:this.handleClear,"aria-label":"Clear"},a("co-icon",{key:"67a2f961d0ece0178811aa04fd9e5a082976ef6a",name:"x-circle",size:16,weight:"fill"}))),this.isOpen&&a("div",{key:"562cc6f307edd60c361c60974d0423550d8f681a",class:"co-autocomplete__dropdown"},a("co-option-list",{key:"3dec3da0d38adb8986b57960c74b697ffbc211dd",ref:e=>this.optionListEl=e,items:JSON.stringify(e.map((e=>({_id:e.value,label:e.label,icon:e.icon,disabled:e.disabled})))),value:this.multiple?JSON.stringify(this.selectedValues):this.selectedValues[0]||"",multiple:this.multiple,selectedAffordance:"check",virtual:!0,loading:this.loading,emptyMessage:this.emptyMessage,onCoChange:e=>this.handleListChange(e.detail)})),this.helperText&&a("div",{key:"5c21f62defe09b0160aeec8eaeaa881408dbe964",class:"co-autocomplete__helper co-autocomplete__helper--"+this.status},this.statusIcon&&a("co-icon",{key:"166ccdb5f1e308bb0212c473881bb36a33a8d2e4",name:this.statusIcon,size:14,weight:"fill",class:"co-autocomplete__helper-icon"}),a("span",{key:"bf4b038b665c269484b3bf841b19c92d5b0ceb27",class:"co-autocomplete__helper-text"},this.helperText)))}get el(){return this}static get watchers(){return{options:[{onOptionsChange:0}],value:[{onValueChange:0}]}}static get style(){return":host{display:block;font-family:var(--co-font-family-primary);font-size:var(--co-font-size-14);letter-spacing:var(--co-font-letter-spacing-body);line-height:1;position:relative}.co-autocomplete{display:flex;flex-direction:column;gap:var(--co-spacing-sm2);position:relative}.co-autocomplete__labels{display:flex;align-items:center;justify-content:space-between;padding:0 var(--co-spacing-xs);gap:var(--co-spacing-sm2)}.co-autocomplete__label{color:var(--co-semantic-text-secondary);font-size:var(--co-font-size-14);font-weight:400;line-height:1;white-space:nowrap;cursor:default}.co-autocomplete__secondary-label{color:var(--co-semantic-text-muted);font-size:var(--co-font-size-14);font-weight:400;line-height:1;white-space:nowrap;text-align:right}.co-autocomplete--disabled .co-autocomplete__label,.co-autocomplete--disabled .co-autocomplete__secondary-label{color:var(--co-semantic-text-disabled)}.co-autocomplete__field{display:flex;align-items:center;flex-wrap:wrap;gap:var(--co-spacing-xs);padding:var(--co-spacing-sm2) var(--co-spacing-md);background:var(--co-semantic-surface-page);border:1px solid var(--co-semantic-border-field);border-radius:var(--co-border-radius-xs);min-height:40px;box-sizing:border-box;transition:border-color var(--co-motion-duration-fast) var(--co-motion-ease-out), box-shadow var(--co-motion-duration-fast) var(--co-motion-ease-out)}.co-autocomplete--s .co-autocomplete__field{min-height:28px;padding:var(--co-spacing-xxs) var(--co-spacing-sm);font-size:var(--co-font-size-12)}.co-autocomplete--sm .co-autocomplete__field{min-height:32px;padding:var(--co-spacing-xs) var(--co-spacing-sm);font-size:var(--co-font-size-14)}.co-autocomplete--lg .co-autocomplete__field{min-height:48px;padding:var(--co-spacing-sm) var(--co-spacing-lg);font-size:var(--co-font-size-16)}.co-autocomplete--focused .co-autocomplete__field{border-color:var(--co-semantic-border-focus);box-shadow:0 0 0 2px var(--co-semantic-border-focus-ring)}.co-autocomplete--disabled .co-autocomplete__field{background:var(--co-semantic-surface-disabled);border-color:transparent;cursor:not-allowed}.co-autocomplete--error .co-autocomplete__field{border-color:var(--co-semantic-status-error)}.co-autocomplete--success .co-autocomplete__field{border-color:var(--co-semantic-status-success)}.co-autocomplete--warning .co-autocomplete__field{border-color:var(--co-color-status-review)}.co-autocomplete--info .co-autocomplete__field{border-color:var(--co-semantic-status-info)}.co-autocomplete__icon{flex-shrink:0;color:var(--co-semantic-text-muted);display:flex;align-items:center}.co-autocomplete__chips{display:flex;flex-wrap:wrap;gap:var(--co-spacing-xs)}.co-autocomplete__input{flex:1;min-width:80px;border:none;background:transparent;color:var(--co-semantic-text-default);font-family:inherit;font-size:inherit;font-weight:400;line-height:1;padding:0;outline:none}.co-autocomplete__input::placeholder{color:var(--co-semantic-text-muted)}.co-autocomplete--disabled .co-autocomplete__input{color:var(--co-semantic-text-disabled);cursor:not-allowed}.co-autocomplete__clear{flex-shrink:0;display:flex;align-items:center;padding:0;margin:0;border:none;background:transparent;cursor:pointer;color:var(--co-semantic-text-muted);transition:color var(--co-motion-duration-fast) var(--co-motion-ease-out)}.co-autocomplete__clear:hover{color:var(--co-semantic-text-default)}.co-autocomplete__spinner{width:16px;height:16px;border:2px solid var(--co-semantic-border-subtle);border-top-color:var(--co-semantic-text-default);border-radius:var(--co-border-radius-full);animation:co-spin 0.6s linear infinite;flex-shrink:0}@keyframes co-spin{to{transform:rotate(360deg)}}.co-autocomplete__dropdown{position:absolute;top:100%;left:0;right:0;z-index:100;margin-top:var(--co-spacing-xs);background:var(--co-semantic-surface-secondary);border:1px solid var(--co-semantic-border-subtle);border-radius:var(--co-border-radius-sm, 12px);box-shadow:0 4px 16px rgba(31, 28, 27, 0.08);overflow:hidden;}.co-autocomplete__helper{display:flex;align-items:center;gap:var(--co-spacing-xs);padding:0 var(--co-spacing-xs)}.co-autocomplete__helper-icon{flex-shrink:0;display:flex;align-items:center}.co-autocomplete__helper-text{color:var(--co-semantic-text-muted);font-size:var(--co-font-size-14);font-weight:400;line-height:1}.co-autocomplete__helper--error .co-autocomplete__helper-icon,.co-autocomplete__helper--error .co-autocomplete__helper-text{color:var(--co-semantic-status-error)}.co-autocomplete__helper--success .co-autocomplete__helper-icon,.co-autocomplete__helper--success .co-autocomplete__helper-text{color:var(--co-semantic-status-success)}.co-autocomplete__helper--warning .co-autocomplete__helper-icon,.co-autocomplete__helper--warning .co-autocomplete__helper-text{color:var(--co-color-status-review)}.co-autocomplete__helper--info .co-autocomplete__helper-icon,.co-autocomplete__helper--info .co-autocomplete__helper-text{color:var(--co-semantic-status-info)}:host([layout='horizontal']) .co-autocomplete{display:grid;grid-template-columns:var(--co-field-label-width, max-content) 1fr;align-items:start;column-gap:var(--co-spacing-md);row-gap:var(--co-spacing-sm2)}:host([layout='horizontal']) .co-autocomplete__labels{grid-column:1;grid-row:1;padding-top:var(--co-spacing-sm2);min-width:0}:host([layout='horizontal']) .co-autocomplete__label{white-space:normal}:host([layout='horizontal']) .co-autocomplete>:not(.co-autocomplete__labels){grid-column:2;min-width:0}.co-field-required{margin-left:2px;color:var(--co-color-status-error)}.co-field-required__caption{margin-left:4px;color:var(--co-semantic-text-muted);font-size:var(--co-font-size-12);font-weight:400}.co-field-required__caption::before{content:var(--co-field-required-text, ' (required)')}"}},[1,"co-autocomplete",{label:[1],required:[4],secondaryLabel:[1,"secondary-label"],placeholder:[1],disabled:[4],iconLeft:[1,"icon-left"],clearable:[4],helperText:[1,"helper-text"],layout:[513],size:[513],status:[1],options:[1],value:[1025],multiple:[4],loading:[4],minChars:[2,"min-chars"],searchDebounce:[2,"search-debounce"],emptyMessage:[1,"empty-message"],isOpen:[32],query:[32],focused:[32]},[[4,"click","handleDocumentClick"]],{options:[{onOptionsChange:0}],value:[{onValueChange:0}]}]);function m(){"undefined"!=typeof customElements&&["co-autocomplete","co-avatar","co-chip","co-icon","co-kbd","co-loader","co-option-list","co-tooltip"].forEach((t=>{switch(t){case"co-autocomplete":customElements.get(e(t))||customElements.define(e(t),u);break;case"co-avatar":customElements.get(e(t))||s();break;case"co-chip":customElements.get(e(t))||r();break;case"co-icon":customElements.get(e(t))||l();break;case"co-kbd":customElements.get(e(t))||n();break;case"co-loader":customElements.get(e(t))||p();break;case"co-option-list":customElements.get(e(t))||h();break;case"co-tooltip":customElements.get(e(t))||d()}}))}m();const f=u,b=m;export{f as CoAutocomplete,b as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as a,p as o,H as t,c as e,h as r}from"./index.js";import{d as i}from"./p-
|
|
1
|
+
import{t as a,p as o,H as t,c as e,h as r}from"./index.js";import{d as i}from"./p-BzNBPHen.js";import{d as s}from"./p-KK2vAKs-.js";import{d as c}from"./p-8XzG8pzY.js";import{d as n}from"./p-V7HYy0VO.js";const l={xl:80,lg:64,md:56,sm:48,xs:32,xxs:24},v={xl:"var(--co-font-size-26)",lg:"var(--co-font-size-22)",md:"var(--co-font-size-18)",sm:"var(--co-font-size-16)",xs:"var(--co-font-size-12)",xxs:"var(--co-font-size-10)"},p=o(class extends t{constructor(a){super(),!1!==a&&this.__registerHost(),this.__attachShadow(),this.coClick=e(this,"coClick",3),this.items=[],this.max=4,this.size="xs",this.shape="circle",this.interactive=!1,this.activate=()=>{this.coClick.emit()}}accessibleLabel(a){return this.label?this.label:a.map((a=>a.name||a.text)).filter(Boolean).join(", ")}render(){var a,o;const t=Array.isArray(this.items)?this.items:[],e=this.max>0?this.max:t.length,i=t.slice(0,e),s=Math.max(0,t.length-e),c=null!==(a=l[this.size])&&void 0!==a?a:l.xs,n=null!==(o=v[this.size])&&void 0!==o?o:v.xs,p=t.slice(e).map((a=>a.name||a.text)).filter(Boolean).join(", "),u=this.interactive?"button":"div",d=this.interactive?{type:"button","aria-label":this.accessibleLabel(t),onClick:this.activate}:{role:"group"};return r(u,Object.assign({key:"7e14b71d5b7391c15fcba50aa43964fdf65282e3",class:{"co-avatar-group":!0,"co-avatar-group--interactive":this.interactive}},d),i.map(((a,o)=>{var t,e,i;return r("co-avatar",{key:o,class:"co-avatar-group__avatar",type:null!==(t=a.type)&&void 0!==t?t:a.src?"image":a.icon?"icon":"text",size:this.size,shape:null!==(e=a.shape)&&void 0!==e?e:this.shape,text:a.text,src:a.src,icon:null!==(i=a.icon)&&void 0!==i?i:"user",color:a.color,"ring-color":a.ringColor,name:a.name||a.text||""})})),s>0&&r("co-tooltip",{key:"f3cc2f5a9f1ceac07ea3b665e6bd0c87804d27ae",class:"co-avatar-group__slot",content:p,placement:"bottom"},r("div",{key:"c0b5fcb8df88917b06a2a9b36f1c2798f10730ff",class:"co-avatar-group__overflow",style:{width:c+"px",height:c+"px",fontSize:n},role:"img","aria-label":"+"+s},"+",s)))}static get style(){return":host{display:inline-flex}.co-avatar-group{display:inline-flex;align-items:center}.co-avatar-group--interactive{appearance:none;-webkit-appearance:none;background:none;border:0;margin:0;padding:0;font:inherit;color:inherit;cursor:pointer;border-radius:var(--co-border-radius-full);outline:none;transition:opacity var(--co-motion-duration-fast) var(--co-motion-ease-out)}.co-avatar-group--interactive:hover{opacity:0.88}.co-avatar-group--interactive:focus-visible{box-shadow:0 0 0 2px var(--co-semantic-surface-page), 0 0 0 4px var(--co-semantic-border-focus)}.co-avatar-group__slot{display:inline-flex;align-items:center;line-height:0}.co-avatar-group>*:not(:first-child){margin-left:calc(-1 * var(--co-avatar-group-overlap, var(--co-spacing-sm)))}.co-avatar-group__avatar::part(avatar),.co-avatar-group__overflow{box-shadow:0 0 0 var(--co-avatar-group-ring-width, 2px) var(--co-semantic-surface-page)}.co-avatar-group__avatar,.co-avatar-group__overflow{vertical-align:middle}.co-avatar-group__overflow{display:inline-flex;align-items:center;justify-content:center;box-sizing:border-box;border-radius:var(--co-border-radius-full);background:var(--co-semantic-surface-muted);color:var(--co-semantic-text-secondary);font-family:var(--co-font-family-primary);font-weight:600;line-height:1;letter-spacing:var(--co-font-letter-spacing-body);flex-shrink:0;user-select:none;-webkit-font-smoothing:antialiased}"}},[1,"co-avatar-group",{items:[16],max:[2],size:[1],shape:[1],interactive:[4],label:[1]}]);function u(){"undefined"!=typeof customElements&&["co-avatar-group","co-avatar","co-icon","co-kbd","co-tooltip"].forEach((o=>{switch(o){case"co-avatar-group":customElements.get(a(o))||customElements.define(a(o),p);break;case"co-avatar":customElements.get(a(o))||i();break;case"co-icon":customElements.get(a(o))||s();break;case"co-kbd":customElements.get(a(o))||c();break;case"co-tooltip":customElements.get(a(o))||n()}}))}u();const d=p,f=u;export{d as CoAvatarGroup,f as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as o,d as
|
|
1
|
+
import{C as o,d as s}from"./p-BzNBPHen.js";const p=o,r=s;export{p as CoAvatar,r as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as o,H as e,c as t,h as c,t as i}from"./index.js";import{R as s}from"./p-CWneqh4n.js";import{r as a}from"./p-Ba_v-MzM.js";import{d as r}from"./p-VcrjNCew.js";import{d as n}from"./p-C_6szR7t.js";import{d as l}from"./p-KK2vAKs-.js";import{d as h}from"./p-8XzG8pzY.js";import{d as b}from"./p-Bw_b_czs.js";import{d}from"./p-BH184F0X.js";import{d as m}from"./p-BqFBZ1PT.js";import{d as p}from"./p-TGRbLkLz.js";import{d as f}from"./p-9VoFSbIH.js";const x=o(class o extends e{constructor(o){super(),!1!==o&&this.__registerHost(),this.__attachShadow(),this.coChange=t(this,"coChange",7),this.coOpen=t(this,"coOpen",3),this.coClose=t(this,"coClose",3),this.coClear=t(this,"coClear",7),this.coFooterPrimary=t(this,"coFooterPrimary",7),this.coFooterSecondary=t(this,"coFooterSecondary",7),this.required=!1,this.placeholder="",this.disabled=!1,this.clearable=!0,this.searchable=!1,this.searchPlaceholder="Search",this.showFooter=!1,this.footerPrimaryLabel="Ok",this.footerSecondaryLabel="New Tags",this.options="[]",this.emptyMessage="No results found",this.value="[]",this.multiple=!0,this.size="md",this.status="default",this.layout="vertical",this.isOpen=!1,this.searchQuery="",this.overflowCount=0,this.pendingFocus=!1,this.handleTriggerClick=o=>{this.disabled&&o.stopPropagation()},this.handleTriggerKeyDown=o=>{this.disabled||o.target===this.triggerEl&&("Enter"===o.key||" "===o.key?(o.preventDefault(),this.isOpen=!this.isOpen):"ArrowDown"!==o.key||this.isOpen||(o.preventDefault(),this.isOpen=!0))},this.handlePopoverOpen=()=>{console.log("[co-combobox] handlePopoverOpen called"),this.isOpen=!0},this.handlePopoverClose=()=>{console.log("[co-combobox] handlePopoverClose called"),this.isOpen=!1},this.handleClear=o=>{o.stopPropagation(),this.value="[]",this.coClear.emit(),this.coChange.emit({value:this.multiple?[]:"",item:null})},this.handleListChange=o=>{if(null==o.value)return this.value="[]",this.isOpen=!1,void this.coChange.emit({value:null,item:null});if(this.multiple){const e=o.value;this.value=JSON.stringify(e),this.coChange.emit({value:e,item:o.item})}else{const e=o.value;this.value=JSON.stringify([e]),this.isOpen=!1,this.coChange.emit({value:e,item:o.item})}},this.handleListRemove=o=>{const e=this.selectedValues.filter((e=>e!==o));this.value=JSON.stringify(e),this.coChange.emit({value:e,item:{_id:o,label:o}})},this.handleFooterPrimary=()=>{this.coFooterPrimary.emit(),this.isOpen=!1},this.handleFooterSecondary=()=>{this.coFooterSecondary.emit()}}normalizeOptions(o){return o.map((o=>"string"==typeof o?{label:o,value:o}:o))}get parsedOptions(){if("string"==typeof this.options)try{return this.normalizeOptions(JSON.parse(this.options))}catch(o){return[]}return this.normalizeOptions(this.options)}get selectedValues(){if("string"==typeof this.value)try{return JSON.parse(this.value)}catch(o){return[]}return this.value}get filteredOptions(){return this.searchQuery?a(this.parsedOptions,this.searchQuery,(o=>o.label)):this.parsedOptions}get listItemsJson(){return JSON.stringify(this.filteredOptions.map((o=>({_id:o.value,label:o.label,icon:o.icon}))))}get displayText(){const o=this.selectedValues;if(0===o.length)return"";const e=this.parsedOptions.find((e=>e.value===o[0]));return e?e.label:o[0]}get selectedOptions(){return this.selectedValues.map((o=>this.parsedOptions.find((e=>e.value===o)))).filter((o=>!!o))}get hasValue(){return this.selectedValues.length>0}get statusIcon(){return{error:"warning-circle",success:"check-circle",warning:"warning",info:"info"}[this.status]||null}onOpenChange(o){o?(this.searchQuery="",this.pendingFocus=!0,this.coOpen.emit()):(this.coClose.emit(),this.restoreTriggerFocus())}onValueChange(){}connectedCallback(){this.resizeObserver=new ResizeObserver((()=>{this.calcOverflow()}))}disconnectedCallback(){var o;null===(o=this.resizeObserver)||void 0===o||o.disconnect()}componentDidRender(){var o,e,t;this.chipContainerEl&&(null===(o=this.resizeObserver)||void 0===o||o.disconnect(),null===(e=this.resizeObserver)||void 0===e||e.observe(this.chipContainerEl)),this.calcOverflow(),this.pendingFocus&&(null===(t=this.optionListEl)||void 0===t?void 0:t.isConnected)&&(this.pendingFocus=!1,this.optionListEl.focusSearch())}calcOverflow(){if(!this.multiple||!this.chipContainerEl)return;const o=this.chipContainerEl,e=Array.from(o.querySelectorAll("co-chip"));if(0===e.length)return void(0!==this.overflowCount&&(this.overflowCount=0));const t=o.getBoundingClientRect().right;let c=0;for(let o=e.length-1;o>=0&&e[o].getBoundingClientRect().right>t+1;o--)c++;c!==this.overflowCount&&(this.overflowCount=c)}restoreTriggerFocus(){var o;const e=document.activeElement;(e===this.el||this.el.contains(e))&&(null===(o=this.triggerEl)||void 0===o||o.focus())}render(){return c("div",{key:"8b0ff4418cd4ef8313fb18f597423938668e7c4c",class:{"co-combobox":!0,"co-combobox--open":this.isOpen,"co-combobox--disabled":this.disabled,["co-combobox--"+this.size]:!0},part:"wrapper"},(this.label||this.secondaryLabel)&&c("div",{key:"e54542e22563eafd57909405254d85a8b4df3e4f",class:"co-combobox__labels"},this.label&&c("label",{key:"3f54d1ba25400dd89b1e3a59c564f68e8a3785df",class:"co-combobox__label",part:"label"},this.label,c(s,{key:"4b0c64794195101ef3dfac1b656cd393eb19012a",required:this.required})),this.secondaryLabel&&c("span",{key:"51f2ed8dcd890fa162011ccf1fe9e3f96afcc6b9",class:"co-combobox__secondary-label",part:"secondary-label"},this.secondaryLabel)),c("co-popover",{key:"c071e11ad27db937caa615b63d32e056b099ea4a",open:this.isOpen,placement:"bottom-start",matchWidth:!0,offset:4,onCoOpen:this.handlePopoverOpen,onCoClose:this.handlePopoverClose},c("div",{key:"c4b215350ab75d791e9f0181f43af320e32506a9",slot:"trigger",class:"co-combobox__trigger",part:"trigger",role:"combobox","aria-expanded":this.isOpen?"true":"false","aria-haspopup":"listbox","aria-label":this.label||void 0,"aria-disabled":this.disabled?"true":void 0,"aria-controls":this.isOpen?o.LIST_ID:void 0,tabIndex:this.disabled?-1:0,ref:o=>this.triggerEl=o,onClick:this.handleTriggerClick,onKeyDown:this.handleTriggerKeyDown},this.iconLeft&&c("co-icon",{key:"595cfc20ba148cd99e487002d4ce186feaf4b590",name:this.iconLeft,size:16,class:"co-combobox__icon"}),c("div",{key:"04a932c116df074d9a9e293d7dc3fead24f85e84",class:"co-combobox__input-wrapper",ref:o=>this.chipContainerEl=o},this.multiple&&this.hasValue?this.selectedOptions.map((o=>c("co-chip",{size:"small","icon-mode":"both",label:o.label},c("co-icon",{slot:"icon-left",name:o.icon||"circle",size:10}),c("co-icon",{slot:"icon-right",name:"x-circle",size:10,weight:"fill",onClick:e=>{e.stopPropagation(),this.handleListRemove(o.value)}})))):c("span",{class:{"co-combobox__text":!0,"co-combobox__text--placeholder":!this.hasValue}},this.hasValue?this.displayText:this.placeholder)),this.multiple&&this.overflowCount>0&&c("span",{key:"3717ddeb6a6cbfb50992f060a94466637d641848",class:"co-combobox__overflow-badge"},this.overflowCount),this.clearable&&this.hasValue&&!this.disabled&&c("button",{key:"3bd22162de7163e761f4deec4813c7bbd2dc7ab3",class:"co-combobox__clear",type:"button",tabIndex:-1,onClick:this.handleClear,"aria-label":"Clear selection",part:"clear"},c("co-icon",{key:"466f7859e45f36d572e2736f8c67bb028be00e90",name:"x-circle",size:16,weight:"fill"})),c("co-icon",{key:"6631ac9f8053225d79b4ec3e70733de96044a5fa",name:this.isOpen?"caret-up":"caret-down",size:16,class:"co-combobox__caret"})),c("div",{key:"3d3cf9b043e50c161f48575e625dfa167c0efefd",class:"co-combobox__dropdown",part:"dropdown"},this.isOpen&&c("co-option-list",{key:"74eb44b2f32b30f5965a24d3d46fd99dba6b05b3",id:o.LIST_ID,ref:o=>this.optionListEl=o,items:this.listItemsJson,value:this.multiple?JSON.stringify(this.selectedValues):this.selectedValues[0]||"",multiple:this.multiple,selectedAffordance:"check",removableItems:this.multiple,virtual:!0,searchable:this.searchable,searchPlaceholder:this.searchPlaceholder,searchDebounce:0,highlightMatches:!0,emptyMessage:this.emptyMessage,onCoSearch:o=>{this.searchQuery=o.detail},onCoChange:o=>this.handleListChange(o.detail),onCoRemoveItem:o=>this.handleListRemove(o.detail)},this.showFooter&&c("co-list-footer",{key:"00861de6c0f6cd87a9a21d88d9f4fe1dd31afc6c",slot:"footer",secondaryLabel:this.footerSecondaryLabel,primaryLabel:this.footerPrimaryLabel,onCoSecondary:this.handleFooterSecondary,onCoPrimary:this.handleFooterPrimary})))),this.helperText&&c("div",{key:"ac1eaf079ae327e76df9723972404a375903689e",class:"co-combobox__helper co-combobox__helper--"+this.status,part:"helper"},this.statusIcon&&c("co-icon",{key:"be90b01fda8c51b11bbc73b8ab76085e160492b1",name:this.statusIcon,size:14,weight:"fill",class:"co-combobox__helper-icon"}),c("span",{key:"c3921ff5a264d24bbba07358085d92675aadbe9b",class:"co-combobox__helper-text"},this.helperText)))}get el(){return this}static get watchers(){return{isOpen:[{onOpenChange:0}],value:[{onValueChange:0}]}}static get style(){return":host{display:block;font-family:var(--co-font-family-primary);font-size:var(--co-font-size-14);letter-spacing:var(--co-font-letter-spacing-body);line-height:1;position:relative}.co-combobox{display:flex;flex-direction:column;gap:var(--co-spacing-sm2);position:relative}.co-combobox__labels{display:flex;align-items:center;justify-content:space-between;padding:0 var(--co-spacing-xs);gap:var(--co-spacing-sm2)}.co-combobox__label{color:var(--co-semantic-text-secondary);font-size:var(--co-font-size-14);font-weight:400;letter-spacing:var(--co-font-letter-spacing-body);line-height:1;white-space:nowrap;cursor:default}.co-combobox__secondary-label{color:var(--co-semantic-text-secondary);font-size:var(--co-font-size-14);font-weight:400;letter-spacing:var(--co-font-letter-spacing-body);line-height:1;white-space:nowrap;text-align:right}.co-combobox__trigger{display:flex;align-items:center;gap:var(--co-spacing-sm2);padding:var(--co-spacing-sm2) var(--co-spacing-md);background:var(--co-semantic-surface-page);border:1px solid var(--co-semantic-border-field);border-radius:var(--co-border-radius-xs);min-height:40px;box-sizing:border-box;cursor:pointer;transition:border-color var(--co-motion-duration-fast) var(--co-motion-ease-out), box-shadow var(--co-motion-duration-fast) var(--co-motion-ease-out);overflow:hidden}.co-combobox--s .co-combobox__trigger{min-height:28px;padding:var(--co-spacing-xxs) var(--co-spacing-sm);font-size:var(--co-font-size-12)}.co-combobox--sm .co-combobox__trigger{min-height:32px;padding:var(--co-spacing-xs) var(--co-spacing-sm);font-size:var(--co-font-size-14)}.co-combobox--lg .co-combobox__trigger{min-height:48px;padding:var(--co-spacing-sm) var(--co-spacing-lg);font-size:var(--co-font-size-16)}.co-combobox--open .co-combobox__trigger{border-color:var(--co-semantic-border-focus);box-shadow:0 0 0 2px var(--co-semantic-border-focus-ring)}.co-combobox__trigger:focus-visible{outline:none;border-color:var(--co-semantic-border-focus);box-shadow:0 0 0 2px var(--co-semantic-border-focus-ring)}.co-combobox--disabled .co-combobox__trigger{background:var(--co-semantic-surface-disabled);border-color:transparent;cursor:not-allowed}.co-combobox__icon{flex-shrink:0;color:var(--co-semantic-text-muted);display:flex;align-items:center}.co-combobox--disabled .co-combobox__icon{color:var(--co-semantic-text-disabled)}.co-combobox__input-wrapper{flex:1;display:flex;align-items:center;flex-wrap:nowrap;gap:4px;min-width:0;min-height:22px;padding:0;overflow:hidden}.co-combobox__input-wrapper co-chip{--co-chip-max-width:120px;--co-chip-bg:var(--co-semantic-surface-muted);--co-chip-color:var(--co-semantic-text-default);--co-chip-border:1px solid var(--co-semantic-border-subtle);flex-shrink:0}.co-combobox__overflow-badge{flex-shrink:0;display:inline-flex;align-items:center;justify-content:center;min-width:20px;height:20px;padding:0 4px;border-radius:var(--co-border-radius-full);background:var(--co-semantic-status-info, #2d6cc5);color:var(--co-color-base-blanco, #fff);font-family:var(--co-font-family-primary);font-size:var(--co-font-size-10);font-weight:600;line-height:1;white-space:nowrap}.co-combobox__text{color:var(--co-semantic-text-default);font-family:inherit;font-size:inherit;font-weight:400;letter-spacing:inherit;line-height:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.co-combobox__text--placeholder{color:var(--co-semantic-text-muted)}.co-combobox--disabled .co-combobox__text{color:var(--co-semantic-text-disabled)}.co-combobox__clear{flex-shrink:0;display:flex;align-items:center;justify-content:center;padding:0;margin:0;border:none;background:transparent;cursor:pointer;color:var(--co-semantic-text-muted);transition:color var(--co-motion-duration-fast) var(--co-motion-ease-out)}.co-combobox__clear:hover{color:var(--co-semantic-text-default)}.co-combobox__caret{flex-shrink:0;color:var(--co-semantic-text-muted);display:flex;align-items:center}.co-combobox--disabled .co-combobox__caret{color:var(--co-semantic-text-disabled)}.co-combobox__dropdown{display:flex;flex-direction:column;gap:var(--co-spacing-sm2)}.co-combobox__helper{display:flex;align-items:center;gap:var(--co-spacing-xs);padding:0 var(--co-spacing-xs)}.co-combobox__helper-icon{flex-shrink:0;display:flex;align-items:center}.co-combobox__helper-text{color:var(--co-semantic-text-muted);font-size:var(--co-font-size-14);font-weight:400;line-height:1}.co-combobox__helper--error .co-combobox__helper-icon,.co-combobox__helper--error .co-combobox__helper-text{color:var(--co-semantic-status-error)}.co-combobox__helper--success .co-combobox__helper-icon,.co-combobox__helper--success .co-combobox__helper-text{color:var(--co-semantic-status-success)}.co-combobox__helper--warning .co-combobox__helper-icon,.co-combobox__helper--warning .co-combobox__helper-text{color:var(--co-color-status-review)}.co-combobox__helper--info .co-combobox__helper-icon,.co-combobox__helper--info .co-combobox__helper-text{color:var(--co-semantic-status-info)}:host([layout='horizontal']) .co-combobox{display:grid;grid-template-columns:var(--co-field-label-width, max-content) 1fr;align-items:start;column-gap:var(--co-spacing-md);row-gap:var(--co-spacing-sm2)}:host([layout='horizontal']) .co-combobox__labels{grid-column:1;grid-row:1;padding-top:var(--co-spacing-sm2);min-width:0}:host([layout='horizontal']) .co-combobox__label{white-space:normal}:host([layout='horizontal']) .co-combobox>:not(.co-combobox__labels){grid-column:2;min-width:0}.co-field-required{margin-left:2px;color:var(--co-color-status-error)}.co-field-required__caption{margin-left:4px;color:var(--co-semantic-text-muted);font-size:var(--co-font-size-12);font-weight:400}.co-field-required__caption::before{content:var(--co-field-required-text, ' (required)')}"}},[1,"co-combobox",{label:[1],required:[4],secondaryLabel:[1,"secondary-label"],placeholder:[1],disabled:[4],iconLeft:[1,"icon-left"],clearable:[4],searchable:[4],searchPlaceholder:[1,"search-placeholder"],showFooter:[4,"show-footer"],footerPrimaryLabel:[1,"footer-primary-label"],footerSecondaryLabel:[1,"footer-secondary-label"],options:[1],emptyMessage:[1,"empty-message"],value:[1025],multiple:[4],size:[513],helperText:[1,"helper-text"],status:[1],layout:[513],isOpen:[32],searchQuery:[32],overflowCount:[32]},void 0,{isOpen:[{onOpenChange:0}],value:[{onValueChange:0}]}]);function u(){"undefined"!=typeof customElements&&["co-combobox","co-avatar","co-chip","co-icon","co-kbd","co-list-footer","co-loader","co-option-list","co-popover","co-tooltip"].forEach((o=>{switch(o){case"co-combobox":customElements.get(i(o))||customElements.define(i(o),x);break;case"co-avatar":customElements.get(i(o))||r();break;case"co-chip":customElements.get(i(o))||n();break;case"co-icon":customElements.get(i(o))||l();break;case"co-kbd":customElements.get(i(o))||h();break;case"co-list-footer":customElements.get(i(o))||b();break;case"co-loader":customElements.get(i(o))||d();break;case"co-option-list":customElements.get(i(o))||m();break;case"co-popover":customElements.get(i(o))||p();break;case"co-tooltip":customElements.get(i(o))||f()}}))}x.LIST_ID="co-combobox-list",u();const g=x,_=u;export{g as CoCombobox,_ as defineCustomElement}
|
|
1
|
+
import{p as o,H as e,c as t,h as c,t as i}from"./index.js";import{R as s}from"./p-CWneqh4n.js";import{r as a}from"./p-Ba_v-MzM.js";import{d as r}from"./p-BzNBPHen.js";import{d as n}from"./p-C_6szR7t.js";import{d as l}from"./p-KK2vAKs-.js";import{d as h}from"./p-8XzG8pzY.js";import{d as b}from"./p-Bw_b_czs.js";import{d}from"./p-BH184F0X.js";import{d as m}from"./p-BW10Sgiy.js";import{d as p}from"./p-TGRbLkLz.js";import{d as f}from"./p-V7HYy0VO.js";const x=o(class o extends e{constructor(o){super(),!1!==o&&this.__registerHost(),this.__attachShadow(),this.coChange=t(this,"coChange",7),this.coOpen=t(this,"coOpen",3),this.coClose=t(this,"coClose",3),this.coClear=t(this,"coClear",7),this.coFooterPrimary=t(this,"coFooterPrimary",7),this.coFooterSecondary=t(this,"coFooterSecondary",7),this.required=!1,this.placeholder="",this.disabled=!1,this.clearable=!0,this.searchable=!1,this.searchPlaceholder="Search",this.showFooter=!1,this.footerPrimaryLabel="Ok",this.footerSecondaryLabel="New Tags",this.options="[]",this.emptyMessage="No results found",this.value="[]",this.multiple=!0,this.size="md",this.status="default",this.layout="vertical",this.isOpen=!1,this.searchQuery="",this.overflowCount=0,this.pendingFocus=!1,this.handleTriggerClick=o=>{this.disabled&&o.stopPropagation()},this.handleTriggerKeyDown=o=>{this.disabled||o.target===this.triggerEl&&("Enter"===o.key||" "===o.key?(o.preventDefault(),this.isOpen=!this.isOpen):"ArrowDown"!==o.key||this.isOpen||(o.preventDefault(),this.isOpen=!0))},this.handlePopoverOpen=()=>{console.log("[co-combobox] handlePopoverOpen called"),this.isOpen=!0},this.handlePopoverClose=()=>{console.log("[co-combobox] handlePopoverClose called"),this.isOpen=!1},this.handleClear=o=>{o.stopPropagation(),this.value="[]",this.coClear.emit(),this.coChange.emit({value:this.multiple?[]:"",item:null})},this.handleListChange=o=>{if(null==o.value)return this.value="[]",this.isOpen=!1,void this.coChange.emit({value:null,item:null});if(this.multiple){const e=o.value;this.value=JSON.stringify(e),this.coChange.emit({value:e,item:o.item})}else{const e=o.value;this.value=JSON.stringify([e]),this.isOpen=!1,this.coChange.emit({value:e,item:o.item})}},this.handleListRemove=o=>{const e=this.selectedValues.filter((e=>e!==o));this.value=JSON.stringify(e),this.coChange.emit({value:e,item:{_id:o,label:o}})},this.handleFooterPrimary=()=>{this.coFooterPrimary.emit(),this.isOpen=!1},this.handleFooterSecondary=()=>{this.coFooterSecondary.emit()}}normalizeOptions(o){return o.map((o=>"string"==typeof o?{label:o,value:o}:o))}get parsedOptions(){if("string"==typeof this.options)try{return this.normalizeOptions(JSON.parse(this.options))}catch(o){return[]}return this.normalizeOptions(this.options)}get selectedValues(){if("string"==typeof this.value)try{return JSON.parse(this.value)}catch(o){return[]}return this.value}get filteredOptions(){return this.searchQuery?a(this.parsedOptions,this.searchQuery,(o=>o.label)):this.parsedOptions}get listItemsJson(){return JSON.stringify(this.filteredOptions.map((o=>({_id:o.value,label:o.label,icon:o.icon}))))}get displayText(){const o=this.selectedValues;if(0===o.length)return"";const e=this.parsedOptions.find((e=>e.value===o[0]));return e?e.label:o[0]}get selectedOptions(){return this.selectedValues.map((o=>this.parsedOptions.find((e=>e.value===o)))).filter((o=>!!o))}get hasValue(){return this.selectedValues.length>0}get statusIcon(){return{error:"warning-circle",success:"check-circle",warning:"warning",info:"info"}[this.status]||null}onOpenChange(o){o?(this.searchQuery="",this.pendingFocus=!0,this.coOpen.emit()):(this.coClose.emit(),this.restoreTriggerFocus())}onValueChange(){}connectedCallback(){this.resizeObserver=new ResizeObserver((()=>{this.calcOverflow()}))}disconnectedCallback(){var o;null===(o=this.resizeObserver)||void 0===o||o.disconnect()}componentDidRender(){var o,e,t;this.chipContainerEl&&(null===(o=this.resizeObserver)||void 0===o||o.disconnect(),null===(e=this.resizeObserver)||void 0===e||e.observe(this.chipContainerEl)),this.calcOverflow(),this.pendingFocus&&(null===(t=this.optionListEl)||void 0===t?void 0:t.isConnected)&&(this.pendingFocus=!1,this.optionListEl.focusSearch())}calcOverflow(){if(!this.multiple||!this.chipContainerEl)return;const o=this.chipContainerEl,e=Array.from(o.querySelectorAll("co-chip"));if(0===e.length)return void(0!==this.overflowCount&&(this.overflowCount=0));const t=o.getBoundingClientRect().right;let c=0;for(let o=e.length-1;o>=0&&e[o].getBoundingClientRect().right>t+1;o--)c++;c!==this.overflowCount&&(this.overflowCount=c)}restoreTriggerFocus(){var o;const e=document.activeElement;(e===this.el||this.el.contains(e))&&(null===(o=this.triggerEl)||void 0===o||o.focus())}render(){return c("div",{key:"8b0ff4418cd4ef8313fb18f597423938668e7c4c",class:{"co-combobox":!0,"co-combobox--open":this.isOpen,"co-combobox--disabled":this.disabled,["co-combobox--"+this.size]:!0},part:"wrapper"},(this.label||this.secondaryLabel)&&c("div",{key:"e54542e22563eafd57909405254d85a8b4df3e4f",class:"co-combobox__labels"},this.label&&c("label",{key:"3f54d1ba25400dd89b1e3a59c564f68e8a3785df",class:"co-combobox__label",part:"label"},this.label,c(s,{key:"4b0c64794195101ef3dfac1b656cd393eb19012a",required:this.required})),this.secondaryLabel&&c("span",{key:"51f2ed8dcd890fa162011ccf1fe9e3f96afcc6b9",class:"co-combobox__secondary-label",part:"secondary-label"},this.secondaryLabel)),c("co-popover",{key:"c071e11ad27db937caa615b63d32e056b099ea4a",open:this.isOpen,placement:"bottom-start",matchWidth:!0,offset:4,onCoOpen:this.handlePopoverOpen,onCoClose:this.handlePopoverClose},c("div",{key:"c4b215350ab75d791e9f0181f43af320e32506a9",slot:"trigger",class:"co-combobox__trigger",part:"trigger",role:"combobox","aria-expanded":this.isOpen?"true":"false","aria-haspopup":"listbox","aria-label":this.label||void 0,"aria-disabled":this.disabled?"true":void 0,"aria-controls":this.isOpen?o.LIST_ID:void 0,tabIndex:this.disabled?-1:0,ref:o=>this.triggerEl=o,onClick:this.handleTriggerClick,onKeyDown:this.handleTriggerKeyDown},this.iconLeft&&c("co-icon",{key:"595cfc20ba148cd99e487002d4ce186feaf4b590",name:this.iconLeft,size:16,class:"co-combobox__icon"}),c("div",{key:"04a932c116df074d9a9e293d7dc3fead24f85e84",class:"co-combobox__input-wrapper",ref:o=>this.chipContainerEl=o},this.multiple&&this.hasValue?this.selectedOptions.map((o=>c("co-chip",{size:"small","icon-mode":"both",label:o.label},c("co-icon",{slot:"icon-left",name:o.icon||"circle",size:10}),c("co-icon",{slot:"icon-right",name:"x-circle",size:10,weight:"fill",onClick:e=>{e.stopPropagation(),this.handleListRemove(o.value)}})))):c("span",{class:{"co-combobox__text":!0,"co-combobox__text--placeholder":!this.hasValue}},this.hasValue?this.displayText:this.placeholder)),this.multiple&&this.overflowCount>0&&c("span",{key:"3717ddeb6a6cbfb50992f060a94466637d641848",class:"co-combobox__overflow-badge"},this.overflowCount),this.clearable&&this.hasValue&&!this.disabled&&c("button",{key:"3bd22162de7163e761f4deec4813c7bbd2dc7ab3",class:"co-combobox__clear",type:"button",tabIndex:-1,onClick:this.handleClear,"aria-label":"Clear selection",part:"clear"},c("co-icon",{key:"466f7859e45f36d572e2736f8c67bb028be00e90",name:"x-circle",size:16,weight:"fill"})),c("co-icon",{key:"6631ac9f8053225d79b4ec3e70733de96044a5fa",name:this.isOpen?"caret-up":"caret-down",size:16,class:"co-combobox__caret"})),c("div",{key:"3d3cf9b043e50c161f48575e625dfa167c0efefd",class:"co-combobox__dropdown",part:"dropdown"},this.isOpen&&c("co-option-list",{key:"74eb44b2f32b30f5965a24d3d46fd99dba6b05b3",id:o.LIST_ID,ref:o=>this.optionListEl=o,items:this.listItemsJson,value:this.multiple?JSON.stringify(this.selectedValues):this.selectedValues[0]||"",multiple:this.multiple,selectedAffordance:"check",removableItems:this.multiple,virtual:!0,searchable:this.searchable,searchPlaceholder:this.searchPlaceholder,searchDebounce:0,highlightMatches:!0,emptyMessage:this.emptyMessage,onCoSearch:o=>{this.searchQuery=o.detail},onCoChange:o=>this.handleListChange(o.detail),onCoRemoveItem:o=>this.handleListRemove(o.detail)},this.showFooter&&c("co-list-footer",{key:"00861de6c0f6cd87a9a21d88d9f4fe1dd31afc6c",slot:"footer",secondaryLabel:this.footerSecondaryLabel,primaryLabel:this.footerPrimaryLabel,onCoSecondary:this.handleFooterSecondary,onCoPrimary:this.handleFooterPrimary})))),this.helperText&&c("div",{key:"ac1eaf079ae327e76df9723972404a375903689e",class:"co-combobox__helper co-combobox__helper--"+this.status,part:"helper"},this.statusIcon&&c("co-icon",{key:"be90b01fda8c51b11bbc73b8ab76085e160492b1",name:this.statusIcon,size:14,weight:"fill",class:"co-combobox__helper-icon"}),c("span",{key:"c3921ff5a264d24bbba07358085d92675aadbe9b",class:"co-combobox__helper-text"},this.helperText)))}get el(){return this}static get watchers(){return{isOpen:[{onOpenChange:0}],value:[{onValueChange:0}]}}static get style(){return":host{display:block;font-family:var(--co-font-family-primary);font-size:var(--co-font-size-14);letter-spacing:var(--co-font-letter-spacing-body);line-height:1;position:relative}.co-combobox{display:flex;flex-direction:column;gap:var(--co-spacing-sm2);position:relative}.co-combobox__labels{display:flex;align-items:center;justify-content:space-between;padding:0 var(--co-spacing-xs);gap:var(--co-spacing-sm2)}.co-combobox__label{color:var(--co-semantic-text-secondary);font-size:var(--co-font-size-14);font-weight:400;letter-spacing:var(--co-font-letter-spacing-body);line-height:1;white-space:nowrap;cursor:default}.co-combobox__secondary-label{color:var(--co-semantic-text-secondary);font-size:var(--co-font-size-14);font-weight:400;letter-spacing:var(--co-font-letter-spacing-body);line-height:1;white-space:nowrap;text-align:right}.co-combobox__trigger{display:flex;align-items:center;gap:var(--co-spacing-sm2);padding:var(--co-spacing-sm2) var(--co-spacing-md);background:var(--co-semantic-surface-page);border:1px solid var(--co-semantic-border-field);border-radius:var(--co-border-radius-xs);min-height:40px;box-sizing:border-box;cursor:pointer;transition:border-color var(--co-motion-duration-fast) var(--co-motion-ease-out), box-shadow var(--co-motion-duration-fast) var(--co-motion-ease-out);overflow:hidden}.co-combobox--s .co-combobox__trigger{min-height:28px;padding:var(--co-spacing-xxs) var(--co-spacing-sm);font-size:var(--co-font-size-12)}.co-combobox--sm .co-combobox__trigger{min-height:32px;padding:var(--co-spacing-xs) var(--co-spacing-sm);font-size:var(--co-font-size-14)}.co-combobox--lg .co-combobox__trigger{min-height:48px;padding:var(--co-spacing-sm) var(--co-spacing-lg);font-size:var(--co-font-size-16)}.co-combobox--open .co-combobox__trigger{border-color:var(--co-semantic-border-focus);box-shadow:0 0 0 2px var(--co-semantic-border-focus-ring)}.co-combobox__trigger:focus-visible{outline:none;border-color:var(--co-semantic-border-focus);box-shadow:0 0 0 2px var(--co-semantic-border-focus-ring)}.co-combobox--disabled .co-combobox__trigger{background:var(--co-semantic-surface-disabled);border-color:transparent;cursor:not-allowed}.co-combobox__icon{flex-shrink:0;color:var(--co-semantic-text-muted);display:flex;align-items:center}.co-combobox--disabled .co-combobox__icon{color:var(--co-semantic-text-disabled)}.co-combobox__input-wrapper{flex:1;display:flex;align-items:center;flex-wrap:nowrap;gap:4px;min-width:0;min-height:22px;padding:0;overflow:hidden}.co-combobox__input-wrapper co-chip{--co-chip-max-width:120px;--co-chip-bg:var(--co-semantic-surface-muted);--co-chip-color:var(--co-semantic-text-default);--co-chip-border:1px solid var(--co-semantic-border-subtle);flex-shrink:0}.co-combobox__overflow-badge{flex-shrink:0;display:inline-flex;align-items:center;justify-content:center;min-width:20px;height:20px;padding:0 4px;border-radius:var(--co-border-radius-full);background:var(--co-semantic-status-info, #2d6cc5);color:var(--co-color-base-blanco, #fff);font-family:var(--co-font-family-primary);font-size:var(--co-font-size-10);font-weight:600;line-height:1;white-space:nowrap}.co-combobox__text{color:var(--co-semantic-text-default);font-family:inherit;font-size:inherit;font-weight:400;letter-spacing:inherit;line-height:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.co-combobox__text--placeholder{color:var(--co-semantic-text-muted)}.co-combobox--disabled .co-combobox__text{color:var(--co-semantic-text-disabled)}.co-combobox__clear{flex-shrink:0;display:flex;align-items:center;justify-content:center;padding:0;margin:0;border:none;background:transparent;cursor:pointer;color:var(--co-semantic-text-muted);transition:color var(--co-motion-duration-fast) var(--co-motion-ease-out)}.co-combobox__clear:hover{color:var(--co-semantic-text-default)}.co-combobox__caret{flex-shrink:0;color:var(--co-semantic-text-muted);display:flex;align-items:center}.co-combobox--disabled .co-combobox__caret{color:var(--co-semantic-text-disabled)}.co-combobox__dropdown{display:flex;flex-direction:column;gap:var(--co-spacing-sm2)}.co-combobox__helper{display:flex;align-items:center;gap:var(--co-spacing-xs);padding:0 var(--co-spacing-xs)}.co-combobox__helper-icon{flex-shrink:0;display:flex;align-items:center}.co-combobox__helper-text{color:var(--co-semantic-text-muted);font-size:var(--co-font-size-14);font-weight:400;line-height:1}.co-combobox__helper--error .co-combobox__helper-icon,.co-combobox__helper--error .co-combobox__helper-text{color:var(--co-semantic-status-error)}.co-combobox__helper--success .co-combobox__helper-icon,.co-combobox__helper--success .co-combobox__helper-text{color:var(--co-semantic-status-success)}.co-combobox__helper--warning .co-combobox__helper-icon,.co-combobox__helper--warning .co-combobox__helper-text{color:var(--co-color-status-review)}.co-combobox__helper--info .co-combobox__helper-icon,.co-combobox__helper--info .co-combobox__helper-text{color:var(--co-semantic-status-info)}:host([layout='horizontal']) .co-combobox{display:grid;grid-template-columns:var(--co-field-label-width, max-content) 1fr;align-items:start;column-gap:var(--co-spacing-md);row-gap:var(--co-spacing-sm2)}:host([layout='horizontal']) .co-combobox__labels{grid-column:1;grid-row:1;padding-top:var(--co-spacing-sm2);min-width:0}:host([layout='horizontal']) .co-combobox__label{white-space:normal}:host([layout='horizontal']) .co-combobox>:not(.co-combobox__labels){grid-column:2;min-width:0}.co-field-required{margin-left:2px;color:var(--co-color-status-error)}.co-field-required__caption{margin-left:4px;color:var(--co-semantic-text-muted);font-size:var(--co-font-size-12);font-weight:400}.co-field-required__caption::before{content:var(--co-field-required-text, ' (required)')}"}},[1,"co-combobox",{label:[1],required:[4],secondaryLabel:[1,"secondary-label"],placeholder:[1],disabled:[4],iconLeft:[1,"icon-left"],clearable:[4],searchable:[4],searchPlaceholder:[1,"search-placeholder"],showFooter:[4,"show-footer"],footerPrimaryLabel:[1,"footer-primary-label"],footerSecondaryLabel:[1,"footer-secondary-label"],options:[1],emptyMessage:[1,"empty-message"],value:[1025],multiple:[4],size:[513],helperText:[1,"helper-text"],status:[1],layout:[513],isOpen:[32],searchQuery:[32],overflowCount:[32]},void 0,{isOpen:[{onOpenChange:0}],value:[{onValueChange:0}]}]);function u(){"undefined"!=typeof customElements&&["co-combobox","co-avatar","co-chip","co-icon","co-kbd","co-list-footer","co-loader","co-option-list","co-popover","co-tooltip"].forEach((o=>{switch(o){case"co-combobox":customElements.get(i(o))||customElements.define(i(o),x);break;case"co-avatar":customElements.get(i(o))||r();break;case"co-chip":customElements.get(i(o))||n();break;case"co-icon":customElements.get(i(o))||l();break;case"co-kbd":customElements.get(i(o))||h();break;case"co-list-footer":customElements.get(i(o))||b();break;case"co-loader":customElements.get(i(o))||d();break;case"co-option-list":customElements.get(i(o))||m();break;case"co-popover":customElements.get(i(o))||p();break;case"co-tooltip":customElements.get(i(o))||f()}}))}x.LIST_ID="co-combobox-list",u();const g=x,_=u;export{g as CoCombobox,_ as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as a,p as e,H as o,c,h as t}from"./index.js";import{r as s}from"./p-Ba_v-MzM.js";import{d as r}from"./p-VcrjNCew.js";import{d as i}from"./p-C_6szR7t.js";import{d as n}from"./p-KK2vAKs-.js";import{d}from"./p-8XzG8pzY.js";import{d as h}from"./p-BH184F0X.js";import{d as l}from"./p-BqFBZ1PT.js";import{d as m}from"./p-wUXcJGdy.js";import{d as p}from"./p-9VoFSbIH.js";const f=e(class extends o{constructor(a){super(),!1!==a&&this.__registerHost(),this.__attachShadow(),this.coSelect=c(this,"coSelect",7),this.coClose=c(this,"coClose",7),this.coSearch=c(this,"coSearch",7),this.coScopeChange=c(this,"coScopeChange",1),this.coBackspaceEmpty=c(this,"coBackspaceEmpty",1),this.coChipRemove=c(this,"coChipRemove",1),this.coTabSelect=c(this,"coTabSelect",1),this.coMoreTabs=c(this,"coMoreTabs",1),this.open=!1,this.placeholder="Search...",this.items=[],this.emptyMessage="No results found",this.async=!1,this.loading=!1,this.chips="[]",this.tabs="[]",this.activeTab="",this.hasMore=!1,this.moreLabel="More",this.favorites="[]",this.query="",this.handleInput=a=>{this.query=a.target.value,this.coSearch.emit(this.query)},this.handleKeyDown=a=>{var e,o;if(function(a,e){return"Backspace"===a&&""===e}(a.key,this.query))return a.preventDefault(),void this.coBackspaceEmpty.emit(this.query);switch(a.key){case"ArrowDown":case"ArrowUp":case"Enter":a.preventDefault(),null===(e=this.optionListEl)||void 0===e||e.handleKey(a);break;case"Escape":a.preventDefault(),this.close();break;case"Tab":a.preventDefault(),null===(o=this.optionListEl)||void 0===o||o.handleKey(new KeyboardEvent("keydown",{key:a.shiftKey?"ArrowUp":"ArrowDown"}))}},this.handleListPick=a=>{const e=this.filteredItems.find((e=>e.value===a));e&&this.selectItem(e)},this.handlePanelKeyDown=a=>{"Escape"===a.key&&(a.preventDefault(),this.close())},this.handleOverlayClick=()=>{this.close()},this.handlePanelClick=a=>{a.stopPropagation()},this.handleTriggerClick=()=>{this.open=!0}}get parsedItems(){if("string"==typeof this.items)try{return JSON.parse(this.items)}catch(a){return[]}return this.items}get filteredItems(){return function(a,e,o){return o?a:e?s(a,e,(a=>[a.label,a.value])):a}(this.parsedItems,this.query,this.async)}get parsedChips(){try{const a="string"==typeof this.chips?JSON.parse(this.chips):this.chips;return Array.isArray(a)?a:[]}catch(a){return[]}}get parsedTabs(){try{const a="string"==typeof this.tabs?JSON.parse(this.tabs):this.tabs;return Array.isArray(a)?a:[]}catch(a){return[]}}get parsedFavorites(){try{const a="string"==typeof this.favorites?JSON.parse(this.favorites):this.favorites;return Array.isArray(a)?a:[]}catch(a){return[]}}onActiveTabChange(a){a&&(this.query=""),requestAnimationFrame((()=>{var a;const e=null===(a=this.el.shadowRoot)||void 0===a?void 0:a.querySelector('.co-command-search__tab[aria-selected="true"]');null==e||e.scrollIntoView({inline:"nearest",block:"nearest"})}))}onOpenChange(a){a&&(this.query="",requestAnimationFrame((()=>{var a;return null===(a=this.inputEl)||void 0===a?void 0:a.focus()})))}selectItem(a){!function(a){return!0===a.keepOpen}(a)?(this.coSelect.emit(a.value),this.close()):this.coScopeChange.emit(a.value)}close(){this.open&&(this.open=!1,this.coClose.emit())}render(){const a=this.filteredItems;return[t("div",{key:"37a7fa941fee9d90d58937fea9a968604e825daf",class:"co-command-search__trigger",onClick:this.handleTriggerClick},t("slot",{key:"23aff571c1cc19b36b1931a5c30d3d3c544eb9b8",name:"trigger"})),t("co-overlay",{key:"bc74cdb881e5005d12ae0e55f301507715303d63",open:this.open,onCoClose:this.handleOverlayClick},t("div",{key:"654ab29570bd313809b660cce6ba9f71c0730e57",class:{"co-command-search":!0,"co-command-search--open":this.open},part:"panel",role:"dialog","aria-modal":"true","aria-label":"Command palette",onClick:this.handlePanelClick,onKeyDown:this.handlePanelKeyDown},t("div",{key:"f62ae09d7384d180b4169e1f7c21d14c7f3ca0b3",class:"co-command-search__input-row",part:"input-row"},t("co-icon",{key:"800323c34524e72dd0255166e45528dcf273a642",name:"magnifying-glass",size:20}),this.parsedChips.map(((a,e)=>t("span",{class:"co-command-search__facet-chip"},a.icon&&t("co-icon",{name:a.icon,size:12}),t("span",{class:"co-command-search__facet-chip-label"},a.label),t("button",{class:"co-command-search__facet-chip-remove",type:"button","aria-label":"Remove filter "+a.label,onClick:a=>{a.stopPropagation(),this.coChipRemove.emit(e)}},t("co-icon",{name:"x",size:10,weight:"bold"}))))),t("input",{key:"5468e510b549c996e7208b691b846b2949b2870d",class:"co-command-search__input",type:"text",placeholder:this.placeholder,value:this.query,onInput:this.handleInput,onKeyDown:this.handleKeyDown,ref:a=>this.inputEl=a,part:"input",role:"combobox","aria-expanded":this.open?"true":"false","aria-autocomplete":"list"}),this.loading&&t("co-loader",{key:"300afe578342e795b968c01ec4a941b2fc07c25b",class:"co-command-search__loading",part:"loading",size:"sm"}),t("span",{key:"96c6c03f2330c1c4fbdecba635cc61aee1cef442",class:"co-command-search__shortcut"},"ESC")),(this.parsedTabs.length>0||this.hasMore)&&t("div",{key:"b05917311a4e65b98ed2e1db1c0cedb9f83bd5a2",class:"co-command-search__tabs",part:"tabs",role:"tablist"},this.parsedTabs.map((a=>{const e=a.value===this.activeTab;return t("co-chip",{class:"co-command-search__tab",role:"tab","aria-selected":e?"true":"false",clickable:!0,selected:e,variant:e?"filled":"outlined",color:e?"primary":"default",iconLeft:a.icon,label:a.label,onCoClick:()=>this.coTabSelect.emit(e?"":a.value)})})),this.hasMore&&t("co-chip",{key:"36c25c208b1e26394bd02a56dda55d5e0fd912fd",class:"co-command-search__tab co-command-search__tab--more",clickable:!0,variant:"outlined",label:this.moreLabel,iconRight:"caret-down",onCoClick:()=>this.coMoreTabs.emit()})),t("div",{key:"72497fec08f07fd6a91f62db10091d7d635eeab9",class:"co-command-search__results",part:"results"},this.parsedFavorites.length>0&&!this.query&&t("div",{key:"be18a43f0e3e5cc4c9ce0cbfacc90c7e5568017b",class:"co-command-search__fav",part:"favorites"},t("div",{key:"9c29628bb6ba66daf9253aa5d490f7dcc56e4b3b",class:"co-command-search__fav-grid"},this.parsedFavorites.map((a=>t("button",{class:"co-command-search__fav-card",type:"button",onClick:()=>this.coSelect.emit(a.value)},t("span",{class:"co-command-search__fav-icon",style:{background:a.color||"var(--co-semantic-surface-muted)"}},t("co-icon",{name:a.icon||"circle",size:26,weight:"fill"})),t("span",{class:"co-command-search__fav-label"},a.label)))))),t("co-option-list",{key:"ee50dd0d97743a7a85de59f8daf6e45e989a422d",ref:a=>this.optionListEl=a,items:JSON.stringify(a.map((a=>({_id:a.value,label:a.label,icon:a.icon,description:a.subtitle,group:a.section,disabled:a.disabled})))),autoHighlight:!0,highlightMatches:!0,highlightTerm:this.query,loading:this.loading,emptyMessage:this.emptyMessage,onCoChange:a=>this.handleListPick(a.detail.item._id)}))))]}get el(){return this}static get watchers(){return{activeTab:[{onActiveTabChange:0}],open:[{onOpenChange:0}]}}static get style(){return":host{display:contents}co-overlay{--co-overlay-bg:rgba(0, 0, 0, 0.16)}.co-command-search__trigger{display:contents}.co-command-search{display:flex;flex-direction:column;width:90vw;max-width:560px;max-height:420px;background:var(--co-semantic-surface-page);border-radius:var(--co-border-radius-lg);box-shadow:0 8px 32px rgba(0, 0, 0, 0.12);overflow:hidden;font-family:var(--co-font-family-primary);transform:translateY(8px) scale(0.98);opacity:0;transition:transform var(--co-motion-duration-fast) var(--co-motion-ease-out), opacity var(--co-motion-duration-fast) var(--co-motion-ease-out);margin-top:-15vh}.co-command-search--open{transform:translateY(0) scale(1);opacity:1}.co-command-search__input-row{display:flex;align-items:center;gap:var(--co-spacing-sm);padding:var(--co-spacing-md) var(--co-spacing-lg);border-bottom:1px solid var(--co-semantic-border-default);color:var(--co-semantic-text-muted)}.co-command-search__input{flex:1;border:none;outline:none;background:transparent;font-size:var(--co-font-size-16);font-family:var(--co-font-family-primary);color:var(--co-semantic-text-default);min-width:0}.co-command-search__input::placeholder{color:var(--co-semantic-text-muted)}.co-command-search__shortcut{font-size:var(--co-font-size-10);color:var(--co-semantic-text-muted);background:var(--co-semantic-surface-muted);padding:2px var(--co-spacing-xs);border-radius:var(--co-border-radius-xxs);font-weight:500;line-height:1.4;flex-shrink:0}.co-command-search__results{flex:1;overflow-y:auto;padding:var(--co-spacing-xs) 0}.co-command-search__loading{flex-shrink:0;display:flex;align-items:center}.co-command-search__facet-chip{display:inline-flex;align-items:center;gap:2px;padding:2px var(--co-spacing-xs);background:var(--co-color-primary-azul);color:var(--co-color-base-blanco, #fff);border-radius:var(--co-border-radius-full);font-size:var(--co-font-size-12);font-weight:500;white-space:nowrap;flex-shrink:0}.co-command-search__facet-chip-label{max-width:110px;overflow:hidden;text-overflow:ellipsis}.co-command-search__facet-chip-remove{display:inline-flex;align-items:center;justify-content:center;width:14px;height:14px;border:none;border-radius:var(--co-border-radius-full);background:rgba(255, 255, 255, 0.25);color:inherit;cursor:pointer;padding:0;line-height:1;transition:background var(--co-motion-duration-fast) var(--co-motion-ease-out)}.co-command-search__facet-chip-remove:hover{background:rgba(255, 255, 255, 0.4)}.co-command-search__tabs{display:flex;align-items:center;gap:var(--co-spacing-sm);padding:var(--co-spacing-md);overflow-x:auto;overflow-y:hidden;scrollbar-width:none;border-bottom:1px solid var(--co-semantic-border-default);scroll-padding-right:104px}.co-command-search__tabs::-webkit-scrollbar{display:none;}.co-command-search__tab{flex:0 0 auto}.co-command-search__tab--more{position:sticky;right:0;padding-left:var(--co-spacing-sm);background:var(--co-semantic-surface-page);box-shadow:-12px 0 10px -4px var(--co-semantic-surface-page)}.co-command-search__fav{padding:var(--co-spacing-sm) var(--co-spacing-lg) var(--co-spacing-md);border-bottom:1px solid var(--co-semantic-border-default)}.co-command-search__fav-grid{display:grid;grid-template-columns:repeat(auto-fill, minmax(88px, 1fr));gap:var(--co-spacing-xs)}.co-command-search__fav-card{display:flex;flex-direction:column;align-items:center;gap:var(--co-spacing-sm);padding:var(--co-spacing-sm) var(--co-spacing-xs);background:transparent;border:none;border-radius:var(--co-border-radius-sm);cursor:pointer;font-family:inherit;text-align:center;min-width:0;transition:background var(--co-motion-duration-fast) var(--co-motion-ease-out)}.co-command-search__fav-card:hover{background:var(--co-semantic-surface-hover)}.co-command-search__fav-card:focus-visible{outline:none;box-shadow:0 0 0 2px var(--co-semantic-border-focus-ring)}.co-command-search__fav-icon{flex:none;width:50px;height:50px;border-radius:var(--co-border-radius-sm);display:flex;align-items:center;justify-content:center;color:var(--co-color-base-blanco, #fff);box-shadow:0 2px 6px rgba(0, 0, 0, 0.14)}.co-command-search__fav-label{font-size:var(--co-font-size-12);font-weight:500;line-height:1.2;color:var(--co-semantic-text-default);max-width:100%;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}"}},[257,"co-command-search",{open:[1540],placeholder:[1],items:[1],emptyMessage:[1,"empty-message"],async:[516],loading:[516],chips:[513],tabs:[1],activeTab:[1,"active-tab"],hasMore:[4,"has-more"],moreLabel:[1,"more-label"],favorites:[1],query:[32]},void 0,{activeTab:[{onActiveTabChange:0}],open:[{onOpenChange:0}]}]);function b(){"undefined"!=typeof customElements&&["co-command-search","co-avatar","co-chip","co-icon","co-kbd","co-loader","co-option-list","co-overlay","co-tooltip"].forEach((e=>{switch(e){case"co-command-search":customElements.get(a(e))||customElements.define(a(e),f);break;case"co-avatar":customElements.get(a(e))||r();break;case"co-chip":customElements.get(a(e))||i();break;case"co-icon":customElements.get(a(e))||n();break;case"co-kbd":customElements.get(a(e))||d();break;case"co-loader":customElements.get(a(e))||h();break;case"co-option-list":customElements.get(a(e))||l();break;case"co-overlay":customElements.get(a(e))||m();break;case"co-tooltip":customElements.get(a(e))||p()}}))}b();const u=f,g=b;export{u as CoCommandSearch,g as defineCustomElement}
|
|
1
|
+
import{t as a,p as e,H as o,c,h as t}from"./index.js";import{r as s}from"./p-Ba_v-MzM.js";import{d as r}from"./p-BzNBPHen.js";import{d as i}from"./p-C_6szR7t.js";import{d as n}from"./p-KK2vAKs-.js";import{d}from"./p-8XzG8pzY.js";import{d as h}from"./p-BH184F0X.js";import{d as l}from"./p-BW10Sgiy.js";import{d as m}from"./p-wUXcJGdy.js";import{d as p}from"./p-V7HYy0VO.js";const f=e(class extends o{constructor(a){super(),!1!==a&&this.__registerHost(),this.__attachShadow(),this.coSelect=c(this,"coSelect",7),this.coClose=c(this,"coClose",7),this.coSearch=c(this,"coSearch",7),this.coScopeChange=c(this,"coScopeChange",1),this.coBackspaceEmpty=c(this,"coBackspaceEmpty",1),this.coChipRemove=c(this,"coChipRemove",1),this.coTabSelect=c(this,"coTabSelect",1),this.coMoreTabs=c(this,"coMoreTabs",1),this.open=!1,this.placeholder="Search...",this.items=[],this.emptyMessage="No results found",this.async=!1,this.loading=!1,this.chips="[]",this.tabs="[]",this.activeTab="",this.hasMore=!1,this.moreLabel="More",this.favorites="[]",this.query="",this.handleInput=a=>{this.query=a.target.value,this.coSearch.emit(this.query)},this.handleKeyDown=a=>{var e,o;if(function(a,e){return"Backspace"===a&&""===e}(a.key,this.query))return a.preventDefault(),void this.coBackspaceEmpty.emit(this.query);switch(a.key){case"ArrowDown":case"ArrowUp":case"Enter":a.preventDefault(),null===(e=this.optionListEl)||void 0===e||e.handleKey(a);break;case"Escape":a.preventDefault(),this.close();break;case"Tab":a.preventDefault(),null===(o=this.optionListEl)||void 0===o||o.handleKey(new KeyboardEvent("keydown",{key:a.shiftKey?"ArrowUp":"ArrowDown"}))}},this.handleListPick=a=>{const e=this.filteredItems.find((e=>e.value===a));e&&this.selectItem(e)},this.handlePanelKeyDown=a=>{"Escape"===a.key&&(a.preventDefault(),this.close())},this.handleOverlayClick=()=>{this.close()},this.handlePanelClick=a=>{a.stopPropagation()},this.handleTriggerClick=()=>{this.open=!0}}get parsedItems(){if("string"==typeof this.items)try{return JSON.parse(this.items)}catch(a){return[]}return this.items}get filteredItems(){return function(a,e,o){return o?a:e?s(a,e,(a=>[a.label,a.value])):a}(this.parsedItems,this.query,this.async)}get parsedChips(){try{const a="string"==typeof this.chips?JSON.parse(this.chips):this.chips;return Array.isArray(a)?a:[]}catch(a){return[]}}get parsedTabs(){try{const a="string"==typeof this.tabs?JSON.parse(this.tabs):this.tabs;return Array.isArray(a)?a:[]}catch(a){return[]}}get parsedFavorites(){try{const a="string"==typeof this.favorites?JSON.parse(this.favorites):this.favorites;return Array.isArray(a)?a:[]}catch(a){return[]}}onActiveTabChange(a){a&&(this.query=""),requestAnimationFrame((()=>{var a;const e=null===(a=this.el.shadowRoot)||void 0===a?void 0:a.querySelector('.co-command-search__tab[aria-selected="true"]');null==e||e.scrollIntoView({inline:"nearest",block:"nearest"})}))}onOpenChange(a){a&&(this.query="",requestAnimationFrame((()=>{var a;return null===(a=this.inputEl)||void 0===a?void 0:a.focus()})))}selectItem(a){!function(a){return!0===a.keepOpen}(a)?(this.coSelect.emit(a.value),this.close()):this.coScopeChange.emit(a.value)}close(){this.open&&(this.open=!1,this.coClose.emit())}render(){const a=this.filteredItems;return[t("div",{key:"37a7fa941fee9d90d58937fea9a968604e825daf",class:"co-command-search__trigger",onClick:this.handleTriggerClick},t("slot",{key:"23aff571c1cc19b36b1931a5c30d3d3c544eb9b8",name:"trigger"})),t("co-overlay",{key:"bc74cdb881e5005d12ae0e55f301507715303d63",open:this.open,onCoClose:this.handleOverlayClick},t("div",{key:"654ab29570bd313809b660cce6ba9f71c0730e57",class:{"co-command-search":!0,"co-command-search--open":this.open},part:"panel",role:"dialog","aria-modal":"true","aria-label":"Command palette",onClick:this.handlePanelClick,onKeyDown:this.handlePanelKeyDown},t("div",{key:"f62ae09d7384d180b4169e1f7c21d14c7f3ca0b3",class:"co-command-search__input-row",part:"input-row"},t("co-icon",{key:"800323c34524e72dd0255166e45528dcf273a642",name:"magnifying-glass",size:20}),this.parsedChips.map(((a,e)=>t("span",{class:"co-command-search__facet-chip"},a.icon&&t("co-icon",{name:a.icon,size:12}),t("span",{class:"co-command-search__facet-chip-label"},a.label),t("button",{class:"co-command-search__facet-chip-remove",type:"button","aria-label":"Remove filter "+a.label,onClick:a=>{a.stopPropagation(),this.coChipRemove.emit(e)}},t("co-icon",{name:"x",size:10,weight:"bold"}))))),t("input",{key:"5468e510b549c996e7208b691b846b2949b2870d",class:"co-command-search__input",type:"text",placeholder:this.placeholder,value:this.query,onInput:this.handleInput,onKeyDown:this.handleKeyDown,ref:a=>this.inputEl=a,part:"input",role:"combobox","aria-expanded":this.open?"true":"false","aria-autocomplete":"list"}),this.loading&&t("co-loader",{key:"300afe578342e795b968c01ec4a941b2fc07c25b",class:"co-command-search__loading",part:"loading",size:"sm"}),t("span",{key:"96c6c03f2330c1c4fbdecba635cc61aee1cef442",class:"co-command-search__shortcut"},"ESC")),(this.parsedTabs.length>0||this.hasMore)&&t("div",{key:"b05917311a4e65b98ed2e1db1c0cedb9f83bd5a2",class:"co-command-search__tabs",part:"tabs",role:"tablist"},this.parsedTabs.map((a=>{const e=a.value===this.activeTab;return t("co-chip",{class:"co-command-search__tab",role:"tab","aria-selected":e?"true":"false",clickable:!0,selected:e,variant:e?"filled":"outlined",color:e?"primary":"default",iconLeft:a.icon,label:a.label,onCoClick:()=>this.coTabSelect.emit(e?"":a.value)})})),this.hasMore&&t("co-chip",{key:"36c25c208b1e26394bd02a56dda55d5e0fd912fd",class:"co-command-search__tab co-command-search__tab--more",clickable:!0,variant:"outlined",label:this.moreLabel,iconRight:"caret-down",onCoClick:()=>this.coMoreTabs.emit()})),t("div",{key:"72497fec08f07fd6a91f62db10091d7d635eeab9",class:"co-command-search__results",part:"results"},this.parsedFavorites.length>0&&!this.query&&t("div",{key:"be18a43f0e3e5cc4c9ce0cbfacc90c7e5568017b",class:"co-command-search__fav",part:"favorites"},t("div",{key:"9c29628bb6ba66daf9253aa5d490f7dcc56e4b3b",class:"co-command-search__fav-grid"},this.parsedFavorites.map((a=>t("button",{class:"co-command-search__fav-card",type:"button",onClick:()=>this.coSelect.emit(a.value)},t("span",{class:"co-command-search__fav-icon",style:{background:a.color||"var(--co-semantic-surface-muted)"}},t("co-icon",{name:a.icon||"circle",size:26,weight:"fill"})),t("span",{class:"co-command-search__fav-label"},a.label)))))),t("co-option-list",{key:"ee50dd0d97743a7a85de59f8daf6e45e989a422d",ref:a=>this.optionListEl=a,items:JSON.stringify(a.map((a=>({_id:a.value,label:a.label,icon:a.icon,description:a.subtitle,group:a.section,disabled:a.disabled})))),autoHighlight:!0,highlightMatches:!0,highlightTerm:this.query,loading:this.loading,emptyMessage:this.emptyMessage,onCoChange:a=>this.handleListPick(a.detail.item._id)}))))]}get el(){return this}static get watchers(){return{activeTab:[{onActiveTabChange:0}],open:[{onOpenChange:0}]}}static get style(){return":host{display:contents}co-overlay{--co-overlay-bg:rgba(0, 0, 0, 0.16)}.co-command-search__trigger{display:contents}.co-command-search{display:flex;flex-direction:column;width:90vw;max-width:560px;max-height:420px;background:var(--co-semantic-surface-page);border-radius:var(--co-border-radius-lg);box-shadow:0 8px 32px rgba(0, 0, 0, 0.12);overflow:hidden;font-family:var(--co-font-family-primary);transform:translateY(8px) scale(0.98);opacity:0;transition:transform var(--co-motion-duration-fast) var(--co-motion-ease-out), opacity var(--co-motion-duration-fast) var(--co-motion-ease-out);margin-top:-15vh}.co-command-search--open{transform:translateY(0) scale(1);opacity:1}.co-command-search__input-row{display:flex;align-items:center;gap:var(--co-spacing-sm);padding:var(--co-spacing-md) var(--co-spacing-lg);border-bottom:1px solid var(--co-semantic-border-default);color:var(--co-semantic-text-muted)}.co-command-search__input{flex:1;border:none;outline:none;background:transparent;font-size:var(--co-font-size-16);font-family:var(--co-font-family-primary);color:var(--co-semantic-text-default);min-width:0}.co-command-search__input::placeholder{color:var(--co-semantic-text-muted)}.co-command-search__shortcut{font-size:var(--co-font-size-10);color:var(--co-semantic-text-muted);background:var(--co-semantic-surface-muted);padding:2px var(--co-spacing-xs);border-radius:var(--co-border-radius-xxs);font-weight:500;line-height:1.4;flex-shrink:0}.co-command-search__results{flex:1;overflow-y:auto;padding:var(--co-spacing-xs) 0}.co-command-search__loading{flex-shrink:0;display:flex;align-items:center}.co-command-search__facet-chip{display:inline-flex;align-items:center;gap:2px;padding:2px var(--co-spacing-xs);background:var(--co-color-primary-azul);color:var(--co-color-base-blanco, #fff);border-radius:var(--co-border-radius-full);font-size:var(--co-font-size-12);font-weight:500;white-space:nowrap;flex-shrink:0}.co-command-search__facet-chip-label{max-width:110px;overflow:hidden;text-overflow:ellipsis}.co-command-search__facet-chip-remove{display:inline-flex;align-items:center;justify-content:center;width:14px;height:14px;border:none;border-radius:var(--co-border-radius-full);background:rgba(255, 255, 255, 0.25);color:inherit;cursor:pointer;padding:0;line-height:1;transition:background var(--co-motion-duration-fast) var(--co-motion-ease-out)}.co-command-search__facet-chip-remove:hover{background:rgba(255, 255, 255, 0.4)}.co-command-search__tabs{display:flex;align-items:center;gap:var(--co-spacing-sm);padding:var(--co-spacing-md);overflow-x:auto;overflow-y:hidden;scrollbar-width:none;border-bottom:1px solid var(--co-semantic-border-default);scroll-padding-right:104px}.co-command-search__tabs::-webkit-scrollbar{display:none;}.co-command-search__tab{flex:0 0 auto}.co-command-search__tab--more{position:sticky;right:0;padding-left:var(--co-spacing-sm);background:var(--co-semantic-surface-page);box-shadow:-12px 0 10px -4px var(--co-semantic-surface-page)}.co-command-search__fav{padding:var(--co-spacing-sm) var(--co-spacing-lg) var(--co-spacing-md);border-bottom:1px solid var(--co-semantic-border-default)}.co-command-search__fav-grid{display:grid;grid-template-columns:repeat(auto-fill, minmax(88px, 1fr));gap:var(--co-spacing-xs)}.co-command-search__fav-card{display:flex;flex-direction:column;align-items:center;gap:var(--co-spacing-sm);padding:var(--co-spacing-sm) var(--co-spacing-xs);background:transparent;border:none;border-radius:var(--co-border-radius-sm);cursor:pointer;font-family:inherit;text-align:center;min-width:0;transition:background var(--co-motion-duration-fast) var(--co-motion-ease-out)}.co-command-search__fav-card:hover{background:var(--co-semantic-surface-hover)}.co-command-search__fav-card:focus-visible{outline:none;box-shadow:0 0 0 2px var(--co-semantic-border-focus-ring)}.co-command-search__fav-icon{flex:none;width:50px;height:50px;border-radius:var(--co-border-radius-sm);display:flex;align-items:center;justify-content:center;color:var(--co-color-base-blanco, #fff);box-shadow:0 2px 6px rgba(0, 0, 0, 0.14)}.co-command-search__fav-label{font-size:var(--co-font-size-12);font-weight:500;line-height:1.2;color:var(--co-semantic-text-default);max-width:100%;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}"}},[257,"co-command-search",{open:[1540],placeholder:[1],items:[1],emptyMessage:[1,"empty-message"],async:[516],loading:[516],chips:[513],tabs:[1],activeTab:[1,"active-tab"],hasMore:[4,"has-more"],moreLabel:[1,"more-label"],favorites:[1],query:[32]},void 0,{activeTab:[{onActiveTabChange:0}],open:[{onOpenChange:0}]}]);function b(){"undefined"!=typeof customElements&&["co-command-search","co-avatar","co-chip","co-icon","co-kbd","co-loader","co-option-list","co-overlay","co-tooltip"].forEach((e=>{switch(e){case"co-command-search":customElements.get(a(e))||customElements.define(a(e),f);break;case"co-avatar":customElements.get(a(e))||r();break;case"co-chip":customElements.get(a(e))||i();break;case"co-icon":customElements.get(a(e))||n();break;case"co-kbd":customElements.get(a(e))||d();break;case"co-loader":customElements.get(a(e))||h();break;case"co-option-list":customElements.get(a(e))||l();break;case"co-overlay":customElements.get(a(e))||m();break;case"co-tooltip":customElements.get(a(e))||p()}}))}b();const u=f,g=b;export{u as CoCommandSearch,g as defineCustomElement}
|