@nuraly/lumenui 0.3.5 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/nuralyui.bundle.js +2577 -1486
- package/dist/nuralyui.bundle.js.gz +0 -0
- package/dist/src/components/button/bundle.js +130 -39
- package/dist/src/components/button/bundle.js.gz +0 -0
- package/dist/src/components/button/button.component.js +7 -4
- package/dist/src/components/button/button.style.js +92 -2
- package/dist/src/components/canvas/base-canvas.component.d.ts +8 -0
- package/dist/src/components/canvas/base-canvas.component.js +75 -3
- package/dist/src/components/canvas/bundle.js +2540 -1201
- package/dist/src/components/canvas/bundle.js.gz +0 -0
- package/dist/src/components/canvas/controllers/collaboration.controller.d.ts +24 -11
- package/dist/src/components/canvas/controllers/collaboration.controller.js +176 -120
- package/dist/src/components/canvas/controllers/selection.controller.js +20 -0
- package/dist/src/components/canvas/interfaces/collaboration.interface.d.ts +8 -0
- package/dist/src/components/canvas/templates/index.d.ts +1 -0
- package/dist/src/components/canvas/templates/index.js +2 -0
- package/dist/src/components/canvas/templates/lock-overlay.template.d.ts +20 -0
- package/dist/src/components/canvas/templates/lock-overlay.template.js +33 -0
- package/dist/src/components/canvas/workflow-canvas.component.js +52 -24
- package/dist/src/components/canvas/workflow-canvas.style.js +62 -1
- package/dist/src/components/canvas/workflow-canvas.types.js +50 -4
- package/dist/src/components/chat-panel/bundle.js +10 -10
- package/dist/src/components/chat-panel/bundle.js.gz +0 -0
- package/dist/src/components/chat-panel/chat-panel.component.js +8 -8
- package/dist/src/components/chatbot/bundle.js +400 -242
- package/dist/src/components/chatbot/bundle.js.gz +0 -0
- package/dist/src/components/chatbot/chatbot.style.js +156 -22
- package/dist/src/components/chatbot/chatbot.types.d.ts +1 -0
- package/dist/src/components/chatbot/core/chatbot-core.controller.js +13 -7
- package/dist/src/components/chatbot/plugins/artifact-plugin.js +0 -19
- package/dist/src/components/chatbot/plugins/flight-card-plugin.js +0 -35
- package/dist/src/components/chatbot/plugins/markdown-plugin.js +0 -4
- package/dist/src/components/chatbot/plugins/print-job-card-plugin.js +0 -36
- package/dist/src/components/chatbot/plugins/selection-card-plugin.js +0 -34
- package/dist/src/components/chatbot/providers/workflow-socket-provider.js +1 -2
- package/dist/src/components/chatbot/templates/input-box.template.js +58 -30
- package/dist/src/components/chatbot/templates/message.template.js +41 -31
- package/dist/src/components/chatbot/templates/thread-sidebar.template.js +38 -39
- package/dist/src/components/colorpicker/bundle.js +15 -10
- package/dist/src/components/colorpicker/bundle.js.gz +0 -0
- package/dist/src/components/colorpicker/color-picker.component.js +15 -10
- package/dist/src/components/datepicker/bundle.js +10 -10
- package/dist/src/components/datepicker/bundle.js.gz +0 -0
- package/dist/src/components/datepicker/datepicker.component.js +14 -22
- package/dist/src/components/dropdown/bundle.js +15 -14
- package/dist/src/components/dropdown/bundle.js.gz +0 -0
- package/dist/src/components/dropdown/dropdown.component.js +10 -9
- package/dist/src/components/dropdown/dropdown.style.js +2 -2
- package/dist/src/components/file-upload/bundle.js +15 -14
- package/dist/src/components/file-upload/bundle.js.gz +0 -0
- package/dist/src/components/file-upload/file-upload.component.js +15 -14
- package/dist/src/components/icon/bundle.js +7 -7
- package/dist/src/components/icon/bundle.js.gz +0 -0
- package/dist/src/components/icon/icon-paths.js +15 -0
- package/dist/src/components/iconpicker/bundle.js +216 -124
- package/dist/src/components/iconpicker/bundle.js.gz +0 -0
- package/dist/src/components/iconpicker/icon-picker.component.js +4 -4
- package/dist/src/components/menu/bundle.js +5 -2
- package/dist/src/components/menu/bundle.js.gz +0 -0
- package/dist/src/components/menu/menu.component.js +5 -2
- package/dist/src/components/modal/bundle.js +16 -13
- package/dist/src/components/modal/bundle.js.gz +0 -0
- package/dist/src/components/modal/modal.component.js +16 -13
- package/dist/src/components/panel/bundle.js +28 -28
- package/dist/src/components/panel/bundle.js.gz +0 -0
- package/dist/src/components/popconfirm/bundle.js +135 -41
- package/dist/src/components/popconfirm/bundle.js.gz +0 -0
- package/dist/src/components/popconfirm/popconfirm.component.d.ts +15 -119
- package/dist/src/components/popconfirm/popconfirm.component.js +158 -162
- package/dist/src/components/popconfirm/popconfirm.style.js +94 -0
- package/dist/src/components/presence/bundle.js +2 -1
- package/dist/src/components/presence/bundle.js.gz +0 -0
- package/dist/src/components/presence/presence.component.js +2 -1
- package/dist/src/components/table/bundle.js +3 -2
- package/dist/src/components/table/bundle.js.gz +0 -0
- package/dist/src/components/table/table.component.js +3 -2
- package/dist/src/components/tabs/bundle.js +3 -3
- package/dist/src/components/tabs/bundle.js.gz +0 -0
- package/dist/src/components/timepicker/bundle.js +3 -3
- package/dist/src/components/timepicker/bundle.js.gz +0 -0
- package/package.json +1 -1
- package/packages/common/dist/VERSIONS.md +1 -1
- package/packages/common/dist/shared/controllers/dropdown.controller.d.ts +4 -0
- package/packages/common/dist/shared/controllers/dropdown.controller.d.ts.map +1 -1
- package/packages/common/dist/shared/controllers/dropdown.controller.js +29 -3
- package/packages/common/dist/shared/controllers/dropdown.controller.js.map +1 -1
|
Binary file
|
|
@@ -71,7 +71,7 @@ import './utils/locale.helper.js';
|
|
|
71
71
|
let HyDatePickerElement = class HyDatePickerElement extends NuralyUIBaseMixin(LitElement) {
|
|
72
72
|
constructor() {
|
|
73
73
|
super(...arguments);
|
|
74
|
-
this.requiredComponents = ['nr-input', 'nr-button', 'nr-icon', '
|
|
74
|
+
this.requiredComponents = ['nr-input', 'nr-button', 'nr-icon', 'nr-select'];
|
|
75
75
|
// Controllers - following the delegation pattern
|
|
76
76
|
this.calendarController = new DatePickerCalendarController(this);
|
|
77
77
|
this.selectionController = new DatePickerSelectionController(this);
|
|
@@ -185,6 +185,11 @@ let HyDatePickerElement = class HyDatePickerElement extends NuralyUIBaseMixin(Li
|
|
|
185
185
|
this.addEventListener('calendar-close-request', () => {
|
|
186
186
|
this.positioningController.closeCalendar();
|
|
187
187
|
});
|
|
188
|
+
// Sync openedCalendar when the dropdown controller closes
|
|
189
|
+
// (outside-click, Escape, scroll-away all flow through here)
|
|
190
|
+
this.addEventListener('dropdown-close', () => {
|
|
191
|
+
this.openedCalendar = false;
|
|
192
|
+
});
|
|
188
193
|
}
|
|
189
194
|
/**
|
|
190
195
|
* Initialize range properties if range mode is enabled
|
|
@@ -273,26 +278,13 @@ let HyDatePickerElement = class HyDatePickerElement extends NuralyUIBaseMixin(Li
|
|
|
273
278
|
* Open calendar - DELEGATES to dropdown controller for better positioning
|
|
274
279
|
*/
|
|
275
280
|
openCalendar() {
|
|
276
|
-
console.log('openCalendar called');
|
|
277
281
|
this.openedCalendar = true;
|
|
278
282
|
this.requestUpdate();
|
|
279
|
-
// Wait for DOM update, then setup positioning
|
|
280
283
|
this.updateComplete.then(() => {
|
|
281
|
-
console.log('DOM updated, checking elements:', {
|
|
282
|
-
calendarContainer: !!this.calendarContainer,
|
|
283
|
-
dateInput: !!this.dateInput
|
|
284
|
-
});
|
|
285
284
|
if (this.calendarContainer && this.dateInput) {
|
|
286
|
-
console.log('Setting up dropdown controller');
|
|
287
285
|
this.dropdownController.setElements(this.calendarContainer, this.dateInput);
|
|
288
286
|
this.dropdownController.open();
|
|
289
287
|
}
|
|
290
|
-
else {
|
|
291
|
-
console.error('Elements not found:', {
|
|
292
|
-
calendarContainer: this.calendarContainer,
|
|
293
|
-
dateInput: this.dateInput
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
288
|
});
|
|
297
289
|
}
|
|
298
290
|
/**
|
|
@@ -439,7 +431,7 @@ let HyDatePickerElement = class HyDatePickerElement extends NuralyUIBaseMixin(Li
|
|
|
439
431
|
<nr-button
|
|
440
432
|
type="text"
|
|
441
433
|
class="header-prev-button prev-month"
|
|
442
|
-
.icon="${['
|
|
434
|
+
.icon="${['chevron-left']}"
|
|
443
435
|
@click="${this.prevMonth}"
|
|
444
436
|
aria-label="Previous month"
|
|
445
437
|
></nr-button>
|
|
@@ -447,7 +439,7 @@ let HyDatePickerElement = class HyDatePickerElement extends NuralyUIBaseMixin(Li
|
|
|
447
439
|
<nr-button
|
|
448
440
|
type="text"
|
|
449
441
|
class="header-next-button next-month"
|
|
450
|
-
.icon="${['
|
|
442
|
+
.icon="${['chevron-right']}"
|
|
451
443
|
@click="${this.nextMonth}"
|
|
452
444
|
aria-label="Next month"
|
|
453
445
|
></nr-button>
|
|
@@ -481,7 +473,7 @@ let HyDatePickerElement = class HyDatePickerElement extends NuralyUIBaseMixin(Li
|
|
|
481
473
|
${this.currentMode !== DatePickerMode.Year
|
|
482
474
|
? html `
|
|
483
475
|
<div class="month-selector">
|
|
484
|
-
<
|
|
476
|
+
<nr-select
|
|
485
477
|
.options="${this.monthOptions}"
|
|
486
478
|
.value="${this.navigationDates.start.month.toString()}"
|
|
487
479
|
.defaultValue="${[this.navigationDates.start.month.toString()]}"
|
|
@@ -491,13 +483,13 @@ let HyDatePickerElement = class HyDatePickerElement extends NuralyUIBaseMixin(Li
|
|
|
491
483
|
placeholder=""
|
|
492
484
|
.clearable=${false}
|
|
493
485
|
max-height="200px"
|
|
494
|
-
></
|
|
486
|
+
></nr-select>
|
|
495
487
|
</div>
|
|
496
488
|
`
|
|
497
489
|
: nothing}
|
|
498
490
|
|
|
499
491
|
<div class="current-year-container">
|
|
500
|
-
<
|
|
492
|
+
<nr-select
|
|
501
493
|
.options="${this.yearOptions}"
|
|
502
494
|
.value="${this.navigationDates.start.year.toString()}"
|
|
503
495
|
.defaultValue="${[this.navigationDates.start.year.toString()]}"
|
|
@@ -507,17 +499,17 @@ let HyDatePickerElement = class HyDatePickerElement extends NuralyUIBaseMixin(Li
|
|
|
507
499
|
placeholder=""
|
|
508
500
|
.clearable=${false}
|
|
509
501
|
max-height="200px"
|
|
510
|
-
></
|
|
502
|
+
></nr-select>
|
|
511
503
|
<div class="year-icons-toggler">
|
|
512
504
|
<nr-button
|
|
513
505
|
class="next-year"
|
|
514
|
-
.icon="${['
|
|
506
|
+
.icon="${['chevron-up']}"
|
|
515
507
|
@click="${this.nextYear}"
|
|
516
508
|
aria-label="Next year"
|
|
517
509
|
></nr-button>
|
|
518
510
|
<nr-button
|
|
519
511
|
class="previous-year"
|
|
520
|
-
.icon="${['
|
|
512
|
+
.icon="${['chevron-down']}"
|
|
521
513
|
@click="${this.prevYear}"
|
|
522
514
|
aria-label="Previous year"
|
|
523
515
|
></nr-button>
|
|
@@ -23,7 +23,7 @@ import{css as t,html as e,nothing as o,LitElement as i}from"lit";import{property
|
|
|
23
23
|
|
|
24
24
|
.dropdown__panel {
|
|
25
25
|
position: fixed;
|
|
26
|
-
z-index: 9999;
|
|
26
|
+
z-index: var(--nuraly-dropdown-z-index, 9999);
|
|
27
27
|
background: #ffffff;
|
|
28
28
|
border: 1px solid #e0e0e0;
|
|
29
29
|
border-radius: 6px;
|
|
@@ -340,7 +340,7 @@ import{css as t,html as e,nothing as o,LitElement as i}from"lit";import{property
|
|
|
340
340
|
.dropdown__submenu {
|
|
341
341
|
position: absolute;
|
|
342
342
|
top: 0;
|
|
343
|
-
z-index: calc(9999 + 1);
|
|
343
|
+
z-index: calc(var(--nuraly-dropdown-z-index, 9999) + 1);
|
|
344
344
|
background: #ffffff;
|
|
345
345
|
border: 1px solid #e0e0e0;
|
|
346
346
|
border-radius: 6px;
|
|
@@ -460,7 +460,7 @@ import{css as t,html as e,nothing as o,LitElement as i}from"lit";import{property
|
|
|
460
460
|
* @license
|
|
461
461
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
462
462
|
* SPDX-License-Identifier: MIT
|
|
463
|
-
*/,
|
|
463
|
+
*/,p=t=>class extends t{constructor(){super(...arguments),this.handleSystemThemeChange=()=>{this.closest("[data-theme]")||document.documentElement.hasAttribute("data-theme")||this.requestUpdate()}}connectedCallback(){super.connectedCallback(),this.setupThemeObserver(),this.setupDesignSystemObserver(),this.setupSystemThemeListener()}disconnectedCallback(){var t,e,o;super.disconnectedCallback(),null===(t=this.themeObserver)||void 0===t||t.disconnect(),null===(e=this.designSystemObserver)||void 0===e||e.disconnect(),null===(o=this.mediaQuery)||void 0===o||o.removeEventListener("change",this.handleSystemThemeChange)}get currentTheme(){var t,e;const o=(null===(t=this.closest("[data-theme]"))||void 0===t?void 0:t.getAttribute("data-theme"))||document.documentElement.getAttribute("data-theme");return o||((null===(e=window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-color-scheme: dark)").matches)?"dark":"light")}get currentDesignSystem(){var t;const e=(null===(t=this.closest("[design-system]"))||void 0===t?void 0:t.getAttribute("design-system"))||document.documentElement.getAttribute("design-system");return"carbon"===e?e:"default"}setupThemeObserver(){this.themeObserver=new MutationObserver(()=>{this.requestUpdate()}),this.themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})}setupDesignSystemObserver(){this.designSystemObserver=new MutationObserver(()=>{this.requestUpdate()}),this.designSystemObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["design-system"]})}setupSystemThemeListener(){window.matchMedia&&(this.mediaQuery=window.matchMedia("(prefers-color-scheme: dark)"),this.mediaQuery.addEventListener("change",this.handleSystemThemeChange))}},h=()=>{var t;return void 0!==globalThis.litElementVersions||"undefined"!=typeof process&&"development"===(null===(t=process.env)||void 0===t?void 0:t.NODE_ENV)||"undefined"!=typeof window&&("localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname)},c=t=>class extends t{constructor(){super(...arguments),this.requiredComponents=[]}validateDependencies(){if(h())for(const t of this.requiredComponents)if(!this.isComponentAvailable(t))throw new Error(`Required component "${t}" is not registered. Please import and register the component before using ${this.tagName.toLowerCase()}. Example: import '@nuralyui/${t}';`)}validateDependenciesWithHandler(t){if(!h())return!0;let e=!0;for(const o of this.requiredComponents)if(!this.isComponentAvailable(o)){e=!1;const i=new Error(`Required component "${o}" is not registered. Please import and register the component before using ${this.tagName.toLowerCase()}.`);t?t(o,i):console.error(i.message)}return e}isComponentAvailable(t){return!!customElements.get(t)}getMissingDependencies(){return this.requiredComponents.filter(t=>!this.isComponentAvailable(t))}areDependenciesAvailable(){return this.requiredComponents.every(t=>this.isComponentAvailable(t))}addRequiredComponent(t){this.requiredComponents.includes(t)||this.requiredComponents.push(t)}removeRequiredComponent(t){const e=this.requiredComponents.indexOf(t);e>-1&&this.requiredComponents.splice(e,1)}},u=t=>class extends t{dispatchCustomEvent(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!0,composed:!0}))}dispatchEventWithMetadata(t,e){var o;const i=Object.assign(Object.assign({},e),{timestamp:Date.now(),componentName:(null===(o=this.tagName)||void 0===o?void 0:o.toLowerCase())||"unknown"});this.dispatchCustomEvent(t,i)}dispatchInputEvent(t,e){const o=Object.assign({target:e.target||this,value:e.value,originalEvent:e.originalEvent},e);this.dispatchCustomEvent(t,o)}dispatchFocusEvent(t,e){const o=Object.assign({target:e.target||this,value:e.value,focused:e.focused,cursorPosition:e.cursorPosition,selectedText:e.selectedText},e);this.dispatchCustomEvent(t,o)}dispatchValidationEvent(t,e){var o;const i=Object.assign({target:e.target||this,value:e.value,isValid:null!==(o=e.isValid)&&void 0!==o&&o,error:e.error},e);this.dispatchCustomEvent(t,i)}dispatchActionEvent(t,e){const o=Object.assign({target:e.target||this,action:e.action,previousValue:e.previousValue,newValue:e.newValue},e);this.dispatchCustomEvent(t,o)}isReadonlyKeyAllowed(t){if(t.ctrlKey||t.metaKey){return["KeyA","KeyC"].includes(t.code)}return["Tab","Escape","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(t.key)}isActivationKey(t){return"Enter"===t.key||" "===t.key}},m=new Set,w=new Map;
|
|
464
464
|
/**
|
|
465
465
|
* @license
|
|
466
466
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
@@ -471,12 +471,12 @@ const _=t=>{class e extends t{constructor(){super(...arguments),this.t=null}crea
|
|
|
471
471
|
* @license
|
|
472
472
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
473
473
|
* SPDX-License-Identifier: MIT
|
|
474
|
-
*/class v{constructor(t){this._host=t,t.addController(this)}get host(){return this._host}hostConnected(){}hostDisconnected(){}hostUpdate(){}hostUpdated(){}requestUpdate(){try{this._host.requestUpdate()}catch(t){this.handleError(t,"requestUpdate")}}dispatchEvent(t){try{return this._host.dispatchEvent(t)}catch(t){return this.handleError(t,"dispatchEvent"),!1}}handleError(t,e){console.error(`[${this.constructor.name}] Error in ${e}:`,t);try{this._host.dispatchEvent(new CustomEvent("nr-controller-error",{detail:{error:t.message,context:e,controller:this.constructor.name},bubbles:!0,composed:!0}))}catch(t){}}safeExecute(t,e,o){try{return t()}catch(t){return this.handleError(t,e),o}}debounce(t,e){let o;const i=(...i)=>{void 0!==o&&clearTimeout(o),o=setTimeout(()=>{o=void 0,t.apply(this,i)},e)};return i.cancel=()=>{void 0!==o&&(clearTimeout(o),o=void 0)},i}}class b extends v{findElement(t){var e;return null===(e=this._host.shadowRoot)||void 0===e?void 0:e.querySelector(t)}findElements(t){var e;return null===(e=this._host.shadowRoot)||void 0===e?void 0:e.querySelectorAll(t)}}class g extends b{constructor(t){super(t),this._isOpen=!1,this._position={top:0,left:0,width:0,placement:"bottom"},this._triggerElement=null,this._dropdownElement=null,this._outsideClickHandler=null,this._keydownHandler=null,this._hoverTimer=null,this._triggerClickHandler=null,this._triggerHoverHandler=null,this._triggerLeaveHandler=null,this._triggerFocusHandler=null,this._triggerBlurHandler=null,this._scrollHandler=null,this._resizeHandler=null,this._isOpen=t.open}get isOpen(){return this._isOpen}get position(){return Object.assign({},this._position)}hostConnected(){}hostUpdated(){this._isOpen!==this.host.open&&(this._isOpen=this.host.open),this._triggerElement||this.setupTriggerListeners()}hostDisconnected(){this.cleanup()}open(){try{this._isOpen||this.host.disabled||(this._isOpen=!0,this.host.open=!0,this.requestUpdate(),setTimeout(()=>{this.calculatePosition(),this.setupEventListeners()},10),this.dispatchEvent(new CustomEvent("nr-dropdown-open",{bubbles:!0,composed:!0,detail:{dropdown:this.host}})))}catch(t){this.handleError(t,"open")}}close(){try{this._isOpen&&(this.removeEventListeners(),this._isOpen=!1,this.host.open=!1,this.requestUpdate(),this.dispatchEvent(new CustomEvent("nr-dropdown-close",{bubbles:!0,composed:!0,detail:{dropdown:this.host}})))}catch(t){this.handleError(t,"close")}}toggle(){try{this._isOpen?this.close():this.open()}catch(t){this.handleError(t,"toggle")}}removeTriggerListeners(){this._triggerElement&&(this._triggerClickHandler&&(this._triggerElement.removeEventListener("click",this._triggerClickHandler),this._triggerClickHandler=null),this._triggerHoverHandler&&(this._triggerElement.removeEventListener("mouseenter",this._triggerHoverHandler),this._triggerHoverHandler=null),this._triggerLeaveHandler&&(this._triggerElement.removeEventListener("mouseleave",this._triggerLeaveHandler),this._triggerLeaveHandler=null),this._triggerFocusHandler&&(this._triggerElement.removeEventListener("focusin",this._triggerFocusHandler),this._triggerFocusHandler=null),this._triggerBlurHandler&&(this._triggerElement.removeEventListener("focusout",this._triggerBlurHandler),this._triggerBlurHandler=null))}findDropdownElements(){this._dropdownElement=this.findElement(".dropdown__panel"),this._triggerElement=this.findElement(".dropdown__trigger")}setupTriggerListeners(){if(this.findDropdownElements(),this._triggerElement)switch(this.removeTriggerListeners(),this.host.trigger){case"click":this._triggerClickHandler=this.handleTriggerClick.bind(this),this._triggerElement.addEventListener("click",this._triggerClickHandler);break;case"hover":this._triggerHoverHandler=this.handleTriggerHover.bind(this),this._triggerLeaveHandler=this.handleTriggerLeave.bind(this),this._triggerElement.addEventListener("mouseenter",this._triggerHoverHandler),this._triggerElement.addEventListener("mouseleave",this._triggerLeaveHandler);break;case"focus":this._triggerFocusHandler=this.handleTriggerFocus.bind(this),this._triggerBlurHandler=this.handleTriggerBlur.bind(this),this._triggerElement.addEventListener("focusin",this._triggerFocusHandler),this._triggerElement.addEventListener("focusout",this._triggerBlurHandler)}}setupEventListeners(){this.host.closeOnOutsideClick&&(this._outsideClickHandler=this.handleOutsideClick.bind(this),document.addEventListener("click",this._outsideClickHandler,!0)),this.host.closeOnEscape&&(this._keydownHandler=this.handleKeydown.bind(this),document.addEventListener("keydown",this._keydownHandler)),this._scrollHandler=this.handleScroll.bind(this),this._resizeHandler=this.handleResize.bind(this),window.addEventListener("scroll",this._scrollHandler,!0),window.addEventListener("resize",this._resizeHandler)}removeEventListeners(){this._outsideClickHandler&&(document.removeEventListener("click",this._outsideClickHandler,!0),this._outsideClickHandler=null),this._keydownHandler&&(document.removeEventListener("keydown",this._keydownHandler),this._keydownHandler=null),this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler,!0),this._scrollHandler=null),this._resizeHandler&&(window.removeEventListener("resize",this._resizeHandler),this._resizeHandler=null)}handleTriggerClick(){this.host.disabled||this.toggle()}handleTriggerHover(){this.host.disabled||(this._hoverTimer&&clearTimeout(this._hoverTimer),this._hoverTimer=window.setTimeout(()=>{this.open()},this.host.delay))}handleTriggerLeave(){this._hoverTimer&&(clearTimeout(this._hoverTimer),this._hoverTimer=null),setTimeout(()=>{this.isHoveringDropdown()||this.close()},100)}handleTriggerFocus(){this.host.disabled||this.open()}handleTriggerBlur(){setTimeout(()=>{this.isDropdownFocused()||this.close()},100)}handleOutsideClick(t){var e,o,i,n;if(!this.host.closeOnOutsideClick)return;const s=t.target;if(null===(e=this._triggerElement)||void 0===e?void 0:e.contains(s))return;if(null===(o=this._dropdownElement)||void 0===o?void 0:o.contains(s))return;const r=t.composedPath();for(const t of r){if(t===this._dropdownElement)return;if(t instanceof Element&&(null===(i=this._dropdownElement)||void 0===i?void 0:i.contains(t)))return}let d=s;for(;d;){const t=d.getRootNode();if(!(t instanceof ShadowRoot&&t.host))break;if(null===(n=this._dropdownElement)||void 0===n?void 0:n.contains(t.host))return;d=t.host}this.close()}handleKeydown(t){"Escape"===t.key&&this.close()}handleScroll(){this._isOpen&&this.calculatePosition()}handleResize(){this._isOpen&&this.calculatePosition()}calculatePosition(){var t,e;try{if(this._dropdownElement&&this._triggerElement||this.findDropdownElements(),!this._dropdownElement||!this._triggerElement)return;const o=this._triggerElement.getBoundingClientRect(),i=this._dropdownElement.getBoundingClientRect(),n=(null===(t=window.visualViewport)||void 0===t?void 0:t.height)||window.innerHeight,s=(null===(e=window.visualViewport)||void 0===e?void 0:e.width)||window.innerWidth,r=n-o.bottom,d=o.top,a=s-o.right,l=o.left,
|
|
474
|
+
*/class v{constructor(t){this._host=t,t.addController(this)}get host(){return this._host}hostConnected(){}hostDisconnected(){}hostUpdate(){}hostUpdated(){}requestUpdate(){try{this._host.requestUpdate()}catch(t){this.handleError(t,"requestUpdate")}}dispatchEvent(t){try{return this._host.dispatchEvent(t)}catch(t){return this.handleError(t,"dispatchEvent"),!1}}handleError(t,e){console.error(`[${this.constructor.name}] Error in ${e}:`,t);try{this._host.dispatchEvent(new CustomEvent("nr-controller-error",{detail:{error:t.message,context:e,controller:this.constructor.name},bubbles:!0,composed:!0}))}catch(t){}}safeExecute(t,e,o){try{return t()}catch(t){return this.handleError(t,e),o}}debounce(t,e){let o;const i=(...i)=>{void 0!==o&&clearTimeout(o),o=setTimeout(()=>{o=void 0,t.apply(this,i)},e)};return i.cancel=()=>{void 0!==o&&(clearTimeout(o),o=void 0)},i}}class b extends v{findElement(t){var e;return null===(e=this._host.shadowRoot)||void 0===e?void 0:e.querySelector(t)}findElements(t){var e;return null===(e=this._host.shadowRoot)||void 0===e?void 0:e.querySelectorAll(t)}}class g extends b{constructor(t){super(t),this._isOpen=!1,this._position={top:0,left:0,width:0,placement:"bottom"},this._triggerElement=null,this._dropdownElement=null,this._outsideClickHandler=null,this._keydownHandler=null,this._hoverTimer=null,this._triggerClickHandler=null,this._triggerHoverHandler=null,this._triggerLeaveHandler=null,this._triggerFocusHandler=null,this._triggerBlurHandler=null,this._scrollHandler=null,this._resizeHandler=null,this._isOpen=t.open}get isOpen(){return this._isOpen}get position(){return Object.assign({},this._position)}hostConnected(){}hostUpdated(){this._isOpen!==this.host.open&&(this._isOpen=this.host.open),this._triggerElement||this.setupTriggerListeners()}hostDisconnected(){this.cleanup()}open(){try{this._isOpen||this.host.disabled||(this._isOpen=!0,this.host.open=!0,this.requestUpdate(),setTimeout(()=>{this.calculatePosition(),this.setupEventListeners()},10),this.dispatchEvent(new CustomEvent("nr-dropdown-open",{bubbles:!0,composed:!0,detail:{dropdown:this.host}})))}catch(t){this.handleError(t,"open")}}close(){try{this._isOpen&&(this.removeEventListeners(),this._isOpen=!1,this.host.open=!1,this.requestUpdate(),this.dispatchEvent(new CustomEvent("nr-dropdown-close",{bubbles:!0,composed:!0,detail:{dropdown:this.host}})))}catch(t){this.handleError(t,"close")}}toggle(){try{this._isOpen?this.close():this.open()}catch(t){this.handleError(t,"toggle")}}removeTriggerListeners(){this._triggerElement&&(this._triggerClickHandler&&(this._triggerElement.removeEventListener("click",this._triggerClickHandler),this._triggerClickHandler=null),this._triggerHoverHandler&&(this._triggerElement.removeEventListener("mouseenter",this._triggerHoverHandler),this._triggerHoverHandler=null),this._triggerLeaveHandler&&(this._triggerElement.removeEventListener("mouseleave",this._triggerLeaveHandler),this._triggerLeaveHandler=null),this._triggerFocusHandler&&(this._triggerElement.removeEventListener("focusin",this._triggerFocusHandler),this._triggerFocusHandler=null),this._triggerBlurHandler&&(this._triggerElement.removeEventListener("focusout",this._triggerBlurHandler),this._triggerBlurHandler=null))}findDropdownElements(){this._dropdownElement=this.findElement(".dropdown__panel"),this._triggerElement=this.findElement(".dropdown__trigger")}setupTriggerListeners(){if(this.findDropdownElements(),this._triggerElement)switch(this.removeTriggerListeners(),this.host.trigger){case"click":this._triggerClickHandler=this.handleTriggerClick.bind(this),this._triggerElement.addEventListener("click",this._triggerClickHandler);break;case"hover":this._triggerHoverHandler=this.handleTriggerHover.bind(this),this._triggerLeaveHandler=this.handleTriggerLeave.bind(this),this._triggerElement.addEventListener("mouseenter",this._triggerHoverHandler),this._triggerElement.addEventListener("mouseleave",this._triggerLeaveHandler);break;case"focus":this._triggerFocusHandler=this.handleTriggerFocus.bind(this),this._triggerBlurHandler=this.handleTriggerBlur.bind(this),this._triggerElement.addEventListener("focusin",this._triggerFocusHandler),this._triggerElement.addEventListener("focusout",this._triggerBlurHandler)}}setupEventListeners(){this.host.closeOnOutsideClick&&(this._outsideClickHandler=this.handleOutsideClick.bind(this),document.addEventListener("click",this._outsideClickHandler,!0)),this.host.closeOnEscape&&(this._keydownHandler=this.handleKeydown.bind(this),document.addEventListener("keydown",this._keydownHandler)),this._scrollHandler=this.handleScroll.bind(this),this._resizeHandler=this.handleResize.bind(this),window.addEventListener("scroll",this._scrollHandler,!0),window.addEventListener("resize",this._resizeHandler)}removeEventListeners(){this._outsideClickHandler&&(document.removeEventListener("click",this._outsideClickHandler,!0),this._outsideClickHandler=null),this._keydownHandler&&(document.removeEventListener("keydown",this._keydownHandler),this._keydownHandler=null),this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler,!0),this._scrollHandler=null),this._resizeHandler&&(window.removeEventListener("resize",this._resizeHandler),this._resizeHandler=null)}handleTriggerClick(){this.host.disabled||this.toggle()}handleTriggerHover(){this.host.disabled||(this._hoverTimer&&clearTimeout(this._hoverTimer),this._hoverTimer=window.setTimeout(()=>{this.open()},this.host.delay))}handleTriggerLeave(){this._hoverTimer&&(clearTimeout(this._hoverTimer),this._hoverTimer=null),setTimeout(()=>{this.isHoveringDropdown()||this.close()},100)}handleTriggerFocus(){this.host.disabled||this.open()}handleTriggerBlur(){setTimeout(()=>{this.isDropdownFocused()||this.close()},100)}handleOutsideClick(t){var e,o,i,n;if(!this.host.closeOnOutsideClick)return;const s=t.target;if(null===(e=this._triggerElement)||void 0===e?void 0:e.contains(s))return;if(null===(o=this._dropdownElement)||void 0===o?void 0:o.contains(s))return;const r=t.composedPath();for(const t of r){if(t===this._dropdownElement)return;if(t instanceof Element&&(null===(i=this._dropdownElement)||void 0===i?void 0:i.contains(t)))return}let d=s;for(;d;){const t=d.getRootNode();if(!(t instanceof ShadowRoot&&t.host))break;if(null===(n=this._dropdownElement)||void 0===n?void 0:n.contains(t.host))return;d=t.host}this.close()}handleKeydown(t){"Escape"===t.key&&this.close()}handleScroll(){this._isOpen&&this.calculatePosition()}handleResize(){this._isOpen&&this.calculatePosition()}calculatePosition(){var t,e;try{if(this._dropdownElement&&this._triggerElement||this.findDropdownElements(),!this._dropdownElement||!this._triggerElement)return;const o=this._triggerElement.getBoundingClientRect(),i=this._dropdownElement.getBoundingClientRect(),n=(null===(t=window.visualViewport)||void 0===t?void 0:t.height)||window.innerHeight,s=(null===(e=window.visualViewport)||void 0===e?void 0:e.width)||window.innerWidth,r=n-o.bottom,d=o.top,a=s-o.right,l=o.left,p=i.height||200,h=i.width||300,c=function(t,e,o){return o>=t?"bottom":e>=t||e>o?"top":"bottom"}(p,d,r),u=this.determineHorizontalPlacement(h,l,a);let m,w;m="bottom"===c?o.bottom+this.host.offset:o.top-p-this.host.offset,w="left"===u?o.right-h:o.left,w=Math.max(8,Math.min(w,s-h-8)),m=Math.max(8,Math.min(m,n-p-8)),this._dropdownElement.style.top=`${m}px`,this._dropdownElement.style.left=`${w}px`,this.applyPlacement(c,u)}catch(t){this.handleError(t,"calculatePosition")}}determineHorizontalPlacement(t,e,o){const i=this.host.placement;if(i.includes("left")||i.includes("right")){if(i.includes("left")&&e>=t)return"left";if(i.includes("right")&&o>=t)return"right"}return o>=t?"right":e>=t?"left":o>e?"right":"left"}applyPlacement(t,e){this._dropdownElement&&(this._dropdownElement.classList.remove("dropdown__panel--top","dropdown__panel--bottom","dropdown__panel--left-aligned","dropdown__panel--right-aligned"),this._dropdownElement.classList.add(`dropdown__panel--${t}`),"left"===e?this._dropdownElement.classList.add("dropdown__panel--right-aligned"):"right"===e&&this._dropdownElement.classList.add("dropdown__panel--left-aligned"),this._position.placement=t)}isHoveringDropdown(){var t;return(null===(t=this._dropdownElement)||void 0===t?void 0:t.matches(":hover"))||!1}isDropdownFocused(){var t;const e=document.activeElement;if(!e)return!1;if(null===(t=this._dropdownElement)||void 0===t?void 0:t.contains(e))return!0;if(e.closest(".dropdown__custom-content"))return!0;if(["INPUT","BUTTON","TEXTAREA","SELECT","A"].includes(e.tagName)){if(e.closest(".dropdown__panel"))return!0}return!1}handleItemClick(t,e){this.dispatchEvent(new CustomEvent("nr-dropdown-item-click",{bubbles:!0,composed:!0,detail:{item:t,dropdown:this.host,originalEvent:e}})),this.host.autoClose&&this.close()}cleanup(){this.removeEventListeners(),this.removeTriggerListeners(),this._hoverTimer&&(clearTimeout(this._hoverTimer),this._hoverTimer=null)}}
|
|
475
475
|
/**
|
|
476
476
|
* @license
|
|
477
477
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
478
478
|
* SPDX-License-Identifier: MIT
|
|
479
|
-
*/var y=function(t,e,o,i){for(var n,s=arguments.length,r=s<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i,d=t.length-1;d>=0;d--)(n=t[d])&&(r=(s<3?n(r):s>3?n(e,o,r):n(e,o))||r);return s>3&&r&&Object.defineProperty(e,o,r),r};let x=class extends((t=>c(
|
|
479
|
+
*/var y=function(t,e,o,i){for(var n,s=arguments.length,r=s<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i,d=t.length-1;d>=0;d--)(n=t[d])&&(r=(s<3?n(r):s>3?n(e,o,r):n(e,o))||r);return s>3&&r&&Object.defineProperty(e,o,r),r};let x=class extends((t=>c(p(u(_(t)))))(i)){constructor(){super(...arguments),this.requiredComponents=["nr-icon"],this.items=[],this.open=!1,this.placement="bottom",this.trigger="hover",this.size="medium",this.animation="fade",this.disabled=!1,this.arrow=!1,this.autoClose=!1,this.closeOnOutsideClick=!0,this.closeOnEscape=!0,this.offset=4,this.delay=50,this.maxHeight="300px",this.minWidth="auto",this.cascadeDirection="auto",this.cascadeDelay=50,this.cascadeOnHover=!0,this.allowOverflow=!1,this.dropdownController=new g(this),this.openSubmenus=new Set,this.submenuTimers=new Map,this.handleDropdownPanelClick=t=>{t.stopPropagation()},this.handleItemClick=(t,e)=>{t.disabled||(t.options&&t.options.length>0||t.customContent?this.toggleSubmenu(t.id):this.dropdownController.handleItemClick(t,e))},this.handleItemHover=t=>{var e;if(((null===(e=t.options)||void 0===e?void 0:e.length)||t.customContent)&&(this.clearSubmenuTimer(t.id),this.cascadeOnHover)){const e=window.setTimeout(()=>{this.showSubmenu(t.id)},this.cascadeDelay);this.submenuTimers.set(t.id,e)}},this.handleItemLeave=t=>{var e;if(!(null===(e=t.options)||void 0===e?void 0:e.length)&&!t.customContent)return;this.clearSubmenuTimer(t.id);const o=window.setTimeout(()=>{this.hideSubmenu(t.id)},100);this.submenuTimers.set(`hide-${t.id}`,o)},this.handleSubmenuEnter=t=>{this.clearSubmenuTimer(`hide-${t}`)},this.handleSubmenuLeave=t=>{const e=window.setTimeout(()=>{this.hideSubmenu(t)},100);this.submenuTimers.set(`hide-${t}`,e)}}connectedCallback(){super.connectedCallback(),this.updateCascadingAttribute()}updated(t){super.updated(t),t.has("items")&&this.updateCascadingAttribute()}disconnectedCallback(){super.disconnectedCallback()}firstUpdated(){}updateCascadingAttribute(){this.items.some(t=>t.options&&t.options.length>0||!!t.customContent)?this.setAttribute("has-cascading",""):this.removeAttribute("has-cascading")}clearSubmenuTimer(t){const e=this.submenuTimers.get(t);e&&(clearTimeout(e),this.submenuTimers.delete(t))}toggleSubmenu(t){this.openSubmenus.has(t)?this.hideSubmenu(t):this.showSubmenu(t)}showSubmenu(t){this.openSubmenus.add(t),this.requestUpdate()}hideSubmenu(t){this.openSubmenus.delete(t),this.requestUpdate()}show(){this.dropdownController.open()}hide(){this.dropdownController.close()}toggle(){this.dropdownController.toggle()}renderCustomContent(t){return"string"==typeof t.customContent?e`<div>${a(t.customContent)}</div>`:t.customContent}renderSubmenuContent(t){return t.customContent?e`
|
|
480
480
|
<div class="dropdown__custom-content">
|
|
481
481
|
${this.renderCustomContent(t)}
|
|
482
482
|
</div>
|
|
@@ -520,24 +520,25 @@ const _=t=>{class e extends t{constructor(){super(...arguments),this.t=null}crea
|
|
|
520
520
|
`})}
|
|
521
521
|
</div>
|
|
522
522
|
`:o}render(){const t={dropdown__panel:!0,"dropdown__panel--open":this.open,[`dropdown__panel--${this.size}`]:!0,[`dropdown__panel--${this.animation}`]:!0,[`dropdown__panel--${this.placement}`]:!0,"dropdown__panel--with-arrow":this.arrow},i={maxHeight:this.maxHeight,minWidth:this.minWidth};return e`
|
|
523
|
-
<div class="dropdown">
|
|
524
|
-
<div class="dropdown__trigger">
|
|
523
|
+
<div class="dropdown" part="container">
|
|
524
|
+
<div class="dropdown__trigger" part="trigger">
|
|
525
525
|
<slot name="trigger"></slot>
|
|
526
526
|
</div>
|
|
527
|
-
|
|
528
|
-
<div
|
|
527
|
+
|
|
528
|
+
<div
|
|
529
529
|
class="${r(t)}"
|
|
530
530
|
style="${d(i)}"
|
|
531
|
+
part="panel"
|
|
531
532
|
@click="${this.handleDropdownPanelClick}"
|
|
532
533
|
>
|
|
533
|
-
${this.arrow?e`<div class="dropdown__arrow"></div>`:o}
|
|
534
|
-
|
|
534
|
+
${this.arrow?e`<div class="dropdown__arrow" part="arrow"></div>`:o}
|
|
535
|
+
|
|
535
536
|
<slot name="header"></slot>
|
|
536
|
-
|
|
537
|
-
<div class="dropdown__content">
|
|
537
|
+
|
|
538
|
+
<div class="dropdown__content" part="content">
|
|
538
539
|
<slot name="content">${this.renderItems()}</slot>
|
|
539
540
|
</div>
|
|
540
|
-
|
|
541
|
+
|
|
541
542
|
<slot name="footer"></slot>
|
|
542
543
|
</div>
|
|
543
544
|
</div>
|
|
Binary file
|
|
@@ -301,24 +301,25 @@ let NrDropdownElement = class NrDropdownElement extends NuralyUIBaseMixin(LitEle
|
|
|
301
301
|
minWidth: this.minWidth
|
|
302
302
|
};
|
|
303
303
|
return html `
|
|
304
|
-
<div class="dropdown">
|
|
305
|
-
<div class="dropdown__trigger">
|
|
304
|
+
<div class="dropdown" part="container">
|
|
305
|
+
<div class="dropdown__trigger" part="trigger">
|
|
306
306
|
<slot name="trigger"></slot>
|
|
307
307
|
</div>
|
|
308
|
-
|
|
309
|
-
<div
|
|
308
|
+
|
|
309
|
+
<div
|
|
310
310
|
class="${classMap(panelClasses)}"
|
|
311
311
|
style="${styleMap(panelStyles)}"
|
|
312
|
+
part="panel"
|
|
312
313
|
@click="${this.handleDropdownPanelClick}"
|
|
313
314
|
>
|
|
314
|
-
${this.arrow ? html `<div class="dropdown__arrow"></div>` : nothing}
|
|
315
|
-
|
|
315
|
+
${this.arrow ? html `<div class="dropdown__arrow" part="arrow"></div>` : nothing}
|
|
316
|
+
|
|
316
317
|
<slot name="header"></slot>
|
|
317
|
-
|
|
318
|
-
<div class="dropdown__content">
|
|
318
|
+
|
|
319
|
+
<div class="dropdown__content" part="content">
|
|
319
320
|
<slot name="content">${this.renderItems()}</slot>
|
|
320
321
|
</div>
|
|
321
|
-
|
|
322
|
+
|
|
322
323
|
<slot name="footer"></slot>
|
|
323
324
|
</div>
|
|
324
325
|
</div>
|
|
@@ -24,7 +24,7 @@ export const styles = css `
|
|
|
24
24
|
|
|
25
25
|
.dropdown__panel {
|
|
26
26
|
position: fixed;
|
|
27
|
-
z-index: 9999;
|
|
27
|
+
z-index: var(--nuraly-dropdown-z-index, 9999);
|
|
28
28
|
background: #ffffff;
|
|
29
29
|
border: 1px solid #e0e0e0;
|
|
30
30
|
border-radius: 6px;
|
|
@@ -341,7 +341,7 @@ export const styles = css `
|
|
|
341
341
|
.dropdown__submenu {
|
|
342
342
|
position: absolute;
|
|
343
343
|
top: 0;
|
|
344
|
-
z-index: calc(9999 + 1);
|
|
344
|
+
z-index: calc(var(--nuraly-dropdown-z-index, 9999) + 1);
|
|
345
345
|
background: #ffffff;
|
|
346
346
|
border: 1px solid #e0e0e0;
|
|
347
347
|
border-radius: 6px;
|
|
@@ -375,7 +375,7 @@ import{css as e,html as t,LitElement as i}from"lit";import{property as o,state a
|
|
|
375
375
|
* SPDX-License-Identifier: MIT
|
|
376
376
|
*/
|
|
377
377
|
const f=e=>{class t extends e{constructor(){super(...arguments),this.t=null}createRenderRoot(){return this.constructor.useShadowDom?super.createRenderRoot():this}connectedCallback(){const e=this.constructor.useShadowDom;if(!e&&null===this.t)for(this.t=[];this.firstChild;)this.t.push(this.removeChild(this.firstChild));if(super.connectedCallback(),!e){const e=this.constructor,t=this.tagName.toLowerCase(),i=e.styles;if(i){const e=g(i);e&&function(e,t,i){var o;if(!u.has(e)){const i=new CSSStyleSheet;i.replaceSync(t),u.set(e,i)}const s=u.get(e),r=`doc:${e}`;if(p.has(r)||(document.adoptedStyleSheets=[...document.adoptedStyleSheets,s],p.add(r)),i){let t=i;for(;t;){const i=t.getRootNode();if(!(i instanceof ShadowRoot))break;{const r=`shadow:${((null===(o=i.host)||void 0===o?void 0:o.tagName)||"").toLowerCase()}:${e}`;p.has(r)||(i.adoptedStyleSheets=[...i.adoptedStyleSheets,s],p.add(r)),t=i.host}}}}(t,e,this)}}}get lightChildren(){return this.t?this.t.filter(e=>!(e instanceof Element&&e.hasAttribute("slot"))):[]}lightChildrenNamed(e){return this.t?this.t.filter(t=>t instanceof Element&&t.getAttribute("slot")===e):[]}}return t.useShadowDom=!1,t};function g(e){return Array.isArray(e)?e.map(e=>g(e)).filter(Boolean).join("\n"):e&&"string"==typeof e.cssText?e.cssText:"string"==typeof e?e:""}var m=function(e,t,i,o){for(var s,r=arguments.length,a=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,i):o,n=e.length-1;n>=0;n--)(s=e[n])&&(a=(r<3?s(a):r>3?s(t,i,a):s(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a},v=function(e,t,i,o){return new(i||(i=Promise))(function(s,r){function a(e){try{d(o.next(e))}catch(e){r(e)}}function n(e){try{d(o.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(a,n)}d((o=o.apply(e,t||[])).next())})};let w=class extends((e=>h(d(c(f(e)))))(i)){constructor(){super(...arguments),this.accept="",this.multiple=!1,this.drag=!0,this.tip="",this.limit=0,this.preview=!0,this.generatePreviewOnUpload=!1,this.fileList=[],this.isDragOver=!1,this.showDragArea=!1,this.inputElement=null,this.dragCounter=0,this.previewImage=null,this._onDocumentDragEnter=e=>{e.preventDefault(),this.dragCounter++,1===this.dragCounter&&(this.showDragArea=!0)},this._onDocumentDragLeave=e=>{e.preventDefault(),this.dragCounter--,0===this.dragCounter&&(this.showDragArea=!1,this.isDragOver=!1)},this._onDocumentDrop=e=>{e.target===this||this.contains(e.target)||(e.preventDefault(),this.dragCounter=0,this.showDragArea=!1,this.isDragOver=!1)},this._onDocumentDragOver=e=>{e.preventDefault();const t=e.composedPath().includes(this);this.isDragOver=!!t},this._onDrop=e=>{var t;e.preventDefault(),e.stopPropagation(),this.dragCounter=0,this.isDragOver=!1,this.showDragArea=!1,(null===(t=e.dataTransfer)||void 0===t?void 0:t.files)&&(this.dispatchEvent(new CustomEvent("files-changed",{detail:e.dataTransfer.files,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("file-drop",{detail:{files:e.dataTransfer.files},bubbles:!0,composed:!0})),this._handleFiles(e.dataTransfer.files))},this._onClick=()=>{var e;null===(e=this.inputElement)||void 0===e||e.click()},this._onChange=e=>{const t=e.target;t.files&&(this.dispatchEvent(new CustomEvent("files-changed",{detail:t.files,bubbles:!0,composed:!0})),this._handleFiles(t.files),t.value="")}}connectedCallback(){super.connectedCallback(),this._updateThemeAttribute(),this.drag&&(document.addEventListener("dragenter",this._onDocumentDragEnter),document.addEventListener("dragleave",this._onDocumentDragLeave),document.addEventListener("drop",this._onDocumentDrop),document.addEventListener("dragover",this._onDocumentDragOver))}updated(e){super.updated(e),this._updateThemeAttribute()}_updateThemeAttribute(){const e=this.explicitTheme;e?this.setAttribute("data-theme",e):this.removeAttribute("data-theme")}disconnectedCallback(){super.disconnectedCallback(),this.drag&&(document.removeEventListener("dragenter",this._onDocumentDragEnter),document.removeEventListener("dragleave",this._onDocumentDragLeave),document.removeEventListener("drop",this._onDocumentDrop),document.removeEventListener("dragover",this._onDocumentDragOver))}firstUpdated(e){var t;super.firstUpdated(e),this.inputElement=(null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('input[type="file"]'))||null}_handleFiles(e){return v(this,void 0,void 0,function*(){if(this.multiple&&this.limit>0&&this.fileList.length+e.length>this.limit)return void this._dispatchEvent("exceed",{files:e});if(!this.multiple&&e.length>0){const t=e[e.length-1];this.previewImage&&this.fileList.some(e=>e.url===this.previewImage)&&(this.previewImage=null);const i=[...this.fileList];for(const e of i)this._dispatchEvent("remove",{file:e});this.fileList=[];const o=n.isImageFile(t),s={name:t.name,size:n.formatFileSize(t.size),raw:t,status:"ready",percentage:0,uid:Date.now()+Math.random().toString(36).substring(2),isImage:o};return this.preview&&this.generatePreviewOnUpload&&o&&(s.url=yield n.createFilePreview(t)),this.fileList=[s],this.requestUpdate(),void this._dispatchEvent("select",{files:[s],fileList:this.fileList})}const t=[];for(const i of Array.from(e)){const e=n.isImageFile(i),o={name:i.name,size:n.formatFileSize(i.size),raw:i,status:"ready",percentage:0,uid:Date.now()+Math.random().toString(36).substring(2),isImage:e};this.preview&&this.generatePreviewOnUpload&&e&&(o.url=yield n.createFilePreview(i)),this.fileList=[...this.fileList,o],t.push(o)}this.requestUpdate(),this._dispatchEvent("select",{files:t,fileList:this.fileList})})}updateFileStatus(e,t,i){const o=this.fileList.find(t=>t.uid===e);o&&(o.status=t,void 0!==i&&(o.percentage=i),this._updateFile(o))}_updateFile(e){this.fileList=this.fileList.map(t=>t.uid===e.uid?e:t),this.requestUpdate()}_removeFile(e){const t=this.fileList.find(t=>t.uid===e);this.fileList=this.fileList.filter(t=>t.uid!==e),t&&this._dispatchEvent("remove",{file:t}),this.requestUpdate()}_dispatchEvent(e,t){this.dispatchEvent(new CustomEvent(`file-${e}`,{detail:t,bubbles:!0,composed:!0}))}_showPreview(e){this.previewImage=e}_closePreview(){this.previewImage=null}render(){return t`
|
|
378
|
-
<div class="upload" @drop=${this._onDrop} @dragover=${e=>e.preventDefault()}>
|
|
378
|
+
<div class="upload" part="container" @drop=${this._onDrop} @dragover=${e=>e.preventDefault()}>
|
|
379
379
|
<input
|
|
380
380
|
type="file"
|
|
381
381
|
class="hidden"
|
|
@@ -385,28 +385,29 @@ const f=e=>{class t extends e{constructor(){super(...arguments),this.t=null}crea
|
|
|
385
385
|
/>
|
|
386
386
|
|
|
387
387
|
${this.showDragArea?t`
|
|
388
|
-
<div
|
|
389
|
-
class="upload-dragger ${this.isDragOver?"is-dragover":""}"
|
|
388
|
+
<div
|
|
389
|
+
class="upload-dragger ${this.isDragOver?"is-dragover":""}"
|
|
390
|
+
part="dragger"
|
|
390
391
|
@click=${this._onClick}
|
|
391
392
|
>
|
|
392
|
-
<div class="upload-icon">
|
|
393
|
+
<div class="upload-icon" part="icon">
|
|
393
394
|
<svg width="40" height="40" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
394
395
|
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path>
|
|
395
396
|
<polyline points="17 8 12 3 7 8"></polyline>
|
|
396
397
|
<line x1="12" y1="3" x2="12" y2="15"></line>
|
|
397
398
|
</svg>
|
|
398
399
|
</div>
|
|
399
|
-
<div class="upload-text">Drop file here or click to upload</div>
|
|
400
|
-
${this.tip?t`<div class="upload-tip">${this.tip}</div>`:""}
|
|
400
|
+
<div class="upload-text" part="text">Drop file here or click to upload</div>
|
|
401
|
+
${this.tip?t`<div class="upload-tip" part="tip">${this.tip}</div>`:""}
|
|
401
402
|
</div>
|
|
402
403
|
`:t`
|
|
403
|
-
<nr-button
|
|
404
|
-
${this.tip?t`<div class="upload-tip">${this.tip}</div>`:""}
|
|
404
|
+
<nr-button part="button" @click=${this._onClick}>Upload File</nr-button>
|
|
405
|
+
${this.tip?t`<div class="upload-tip" part="tip">${this.tip}</div>`:""}
|
|
405
406
|
`}
|
|
406
407
|
|
|
407
|
-
<div class="file-list">
|
|
408
|
+
<div class="file-list" part="file-list">
|
|
408
409
|
${this.fileList.map(e=>t`
|
|
409
|
-
<div class="file-item">
|
|
410
|
+
<div class="file-item" part="file-item">
|
|
410
411
|
${e.isImage?t`
|
|
411
412
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
412
413
|
<rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect>
|
|
@@ -433,7 +434,7 @@ const f=e=>{class t extends e{constructor(){super(...arguments),this.t=null}crea
|
|
|
433
434
|
</svg>
|
|
434
435
|
`:"uploading"===e.status?t`${e.percentage}%`:""}
|
|
435
436
|
</div>
|
|
436
|
-
<div class="file-actions">
|
|
437
|
+
<div class="file-actions" part="file-actions">
|
|
437
438
|
${e.isImage&&e.url?t`
|
|
438
439
|
<button class="preview-icon" @click=${()=>this._showPreview(e.url)}>
|
|
439
440
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
@@ -469,9 +470,9 @@ const f=e=>{class t extends e{constructor(){super(...arguments),this.t=null}crea
|
|
|
469
470
|
</div>
|
|
470
471
|
|
|
471
472
|
${this.previewImage?t`
|
|
472
|
-
<div class="preview-modal" @click=${this._closePreview}>
|
|
473
|
-
<button class="preview-close">×</button>
|
|
474
|
-
<img src="${this.previewImage}" alt="Preview" />
|
|
473
|
+
<div class="preview-modal" part="preview-modal" @click=${this._closePreview}>
|
|
474
|
+
<button class="preview-close" part="preview-close">×</button>
|
|
475
|
+
<img src="${this.previewImage}" alt="Preview" part="preview-image" />
|
|
475
476
|
</div>
|
|
476
477
|
`:""}
|
|
477
478
|
</div>
|
|
Binary file
|
|
@@ -248,7 +248,7 @@ let FileUpload = class FileUpload extends NuralyUIBaseMixin(LitElement) {
|
|
|
248
248
|
}
|
|
249
249
|
render() {
|
|
250
250
|
return html `
|
|
251
|
-
<div class="upload" @drop=${this._onDrop} @dragover=${(e) => e.preventDefault()}>
|
|
251
|
+
<div class="upload" part="container" @drop=${this._onDrop} @dragover=${(e) => e.preventDefault()}>
|
|
252
252
|
<input
|
|
253
253
|
type="file"
|
|
254
254
|
class="hidden"
|
|
@@ -258,28 +258,29 @@ let FileUpload = class FileUpload extends NuralyUIBaseMixin(LitElement) {
|
|
|
258
258
|
/>
|
|
259
259
|
|
|
260
260
|
${this.showDragArea ? html `
|
|
261
|
-
<div
|
|
262
|
-
class="upload-dragger ${this.isDragOver ? 'is-dragover' : ''}"
|
|
261
|
+
<div
|
|
262
|
+
class="upload-dragger ${this.isDragOver ? 'is-dragover' : ''}"
|
|
263
|
+
part="dragger"
|
|
263
264
|
@click=${this._onClick}
|
|
264
265
|
>
|
|
265
|
-
<div class="upload-icon">
|
|
266
|
+
<div class="upload-icon" part="icon">
|
|
266
267
|
<svg width="40" height="40" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
267
268
|
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path>
|
|
268
269
|
<polyline points="17 8 12 3 7 8"></polyline>
|
|
269
270
|
<line x1="12" y1="3" x2="12" y2="15"></line>
|
|
270
271
|
</svg>
|
|
271
272
|
</div>
|
|
272
|
-
<div class="upload-text">Drop file here or click to upload</div>
|
|
273
|
-
${this.tip ? html `<div class="upload-tip">${this.tip}</div>` : ''}
|
|
273
|
+
<div class="upload-text" part="text">Drop file here or click to upload</div>
|
|
274
|
+
${this.tip ? html `<div class="upload-tip" part="tip">${this.tip}</div>` : ''}
|
|
274
275
|
</div>
|
|
275
276
|
` : html `
|
|
276
|
-
<nr-button
|
|
277
|
-
${this.tip ? html `<div class="upload-tip">${this.tip}</div>` : ''}
|
|
277
|
+
<nr-button part="button" @click=${this._onClick}>Upload File</nr-button>
|
|
278
|
+
${this.tip ? html `<div class="upload-tip" part="tip">${this.tip}</div>` : ''}
|
|
278
279
|
`}
|
|
279
280
|
|
|
280
|
-
<div class="file-list">
|
|
281
|
+
<div class="file-list" part="file-list">
|
|
281
282
|
${this.fileList.map(file => html `
|
|
282
|
-
<div class="file-item">
|
|
283
|
+
<div class="file-item" part="file-item">
|
|
283
284
|
${file.isImage ? html `
|
|
284
285
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
285
286
|
<rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect>
|
|
@@ -306,7 +307,7 @@ let FileUpload = class FileUpload extends NuralyUIBaseMixin(LitElement) {
|
|
|
306
307
|
</svg>
|
|
307
308
|
` : file.status === 'uploading' ? html `${file.percentage}%` : ''}
|
|
308
309
|
</div>
|
|
309
|
-
<div class="file-actions">
|
|
310
|
+
<div class="file-actions" part="file-actions">
|
|
310
311
|
${file.isImage && file.url ? html `
|
|
311
312
|
<button class="preview-icon" @click=${() => this._showPreview(file.url)}>
|
|
312
313
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
@@ -342,9 +343,9 @@ let FileUpload = class FileUpload extends NuralyUIBaseMixin(LitElement) {
|
|
|
342
343
|
</div>
|
|
343
344
|
|
|
344
345
|
${this.previewImage ? html `
|
|
345
|
-
<div class="preview-modal" @click=${this._closePreview}>
|
|
346
|
-
<button class="preview-close">×</button>
|
|
347
|
-
<img src="${this.previewImage}" alt="Preview" />
|
|
346
|
+
<div class="preview-modal" part="preview-modal" @click=${this._closePreview}>
|
|
347
|
+
<button class="preview-close" part="preview-close">×</button>
|
|
348
|
+
<img src="${this.previewImage}" alt="Preview" part="preview-image" />
|
|
348
349
|
</div>
|
|
349
350
|
` : ''}
|
|
350
351
|
</div>
|