solely 0.4.13 → 0.4.15
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/components/commands/modal/index.cjs +1 -1
- package/dist/components/commands/modal/index.js +1 -1
- package/dist/components/commands/modal/types.d.ts +4 -2
- package/dist/components/elements/alert/index.cjs +1 -1
- package/dist/components/elements/alert/index.d.ts +2 -0
- package/dist/components/elements/alert/index.js +1 -1
- package/dist/components/elements/breadcrumb/index.cjs +1 -1
- package/dist/components/elements/breadcrumb/index.js +1 -1
- package/dist/components/elements/coordinate-input/index.cjs +1 -1
- package/dist/components/elements/coordinate-input/index.d.ts +2 -2
- package/dist/components/elements/coordinate-input/index.js +1 -1
- package/dist/components/elements/input/index.cjs +1 -1
- package/dist/components/elements/input/index.d.ts +1 -1
- package/dist/components/elements/input/index.js +1 -1
- package/dist/components/elements/pagination/index.cjs +1 -1
- package/dist/components/elements/pagination/index.js +1 -1
- package/dist/components/elements/radio/index.cjs +1 -1
- package/dist/components/elements/radio/index.d.ts +3 -0
- package/dist/components/elements/radio/index.js +1 -1
- package/dist/components/elements/rate/index.cjs +1 -1
- package/dist/components/elements/rate/index.d.ts +4 -0
- package/dist/components/elements/rate/index.js +1 -1
- package/dist/components/elements/select/index.cjs +1 -1
- package/dist/components/elements/select/index.d.ts +2 -0
- package/dist/components/elements/select/index.js +1 -1
- package/dist/components/elements/slider/index.cjs +1 -1
- package/dist/components/elements/slider/index.d.ts +8 -1
- package/dist/components/elements/slider/index.js +1 -1
- package/dist/components/elements/steps/index.cjs +1 -1
- package/dist/components/elements/steps/index.d.ts +1 -0
- package/dist/components/elements/steps/index.js +1 -1
- package/dist/components/elements/tabs/index.cjs +1 -1
- package/dist/components/elements/tabs/index.js +1 -1
- package/dist/components/elements/tooltip/index.d.ts +4 -0
- package/dist/components/elements/upload/index.cjs +1 -1
- package/dist/components/elements/upload/index.d.ts +3 -0
- package/dist/components/elements/upload/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/runtime/component/base-element.cjs +1 -1
- package/dist/runtime/component/base-element.js +1 -1
- package/dist/runtime/component/decorators.cjs +1 -1
- package/dist/runtime/component/decorators.js +1 -1
- package/dist/runtime/reactivity/observe.cjs +1 -1
- package/dist/runtime/reactivity/observe.js +1 -1
- package/dist/runtime/renderer/html-decode.cjs +1 -1
- package/dist/runtime/renderer/html-decode.d.ts +1 -2
- package/dist/runtime/renderer/html-decode.js +1 -1
- package/dist/runtime/renderer/renderIR.cjs +1 -1
- package/dist/runtime/renderer/renderIR.js +1 -1
- package/dist/shared/case-convert.cjs +1 -0
- package/dist/shared/case-convert.d.ts +1 -0
- package/dist/shared/case-convert.js +1 -0
- package/dist/shared/index.cjs +1 -1
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/index.js +1 -1
- package/dist/shared/is-object.cjs +1 -1
- package/dist/shared/is-object.d.ts +0 -5
- package/dist/shared/is-object.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
var t=Object.defineProperty,e=(e,a,s)=>((e,a,s)=>a in e?t(e,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[a]=s)(e,"symbol"!=typeof a?a+"":a,s);import a from"./style.css.js";import{__SOLELY_IR__ as s}from"./index.html.js";import
|
|
1
|
+
var t=Object.defineProperty,e=(e,a,s)=>((e,a,s)=>a in e?t(e,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[a]=s)(e,"symbol"!=typeof a?a+"":a,s);import a from"./style.css.js";import{__SOLELY_IR__ as s}from"./index.html.js";import i from"../../../runtime/component/base-element.js";import{CustomElement as l}from"../../../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;let o=class extends i{constructor(){super(...arguments),e(this,"clickOutsideHandler"),e(this,"slotObserver"),e(this,"closeTimer")}get value(){return this.$data.value||""}set value(t){this.$data.disabled||this.setValue(t)}getSelectClasses(){const t={};return"small"===this.$data.size?t["select--sm"]=!0:"large"===this.$data.size?t["select--lg"]=!0:t["select--md"]=!0,t["is-disabled"]=!!this.$data.disabled,t["is-focused"]=!!this.$data.focused,t["is-open"]=!!this.$data.isOpen,t["use-slot"]=this.$data.useSlot,t}getDropdownClasses(){return{"select__dropdown--closing":!!this.$data.closing,"select__dropdown--top":"top"===this.$data.dropdownPlacement,"select__dropdown--bottom":"bottom"===this.$data.dropdownPlacement}}getOptionClasses(t){return{"select__option--selected":t.value===this.$data.value,"select__option--disabled":!!t.disabled}}calculateDropdownPlacement(){const t=this.getBoundingClientRect(),e=window.innerHeight-t.bottom,a=t.top;this.$data.dropdownPlacement=e<256&&a>e?"top":"bottom"}collectSlotOptions(){const t=Array.from(this.children);this.$data.hasHeaderSlot=t.some(t=>"header"===t.getAttribute("slot")),this.$data.hasFooterSlot=t.some(t=>"footer"===t.getAttribute("slot"));const e=t.filter(t=>!t.getAttribute("slot")&&t.hasAttribute("data-value"));0!==e.length?(this.$data.useSlot=!0,this.$data.slotOptions=e.map(t=>{var e;const a=t;return{value:a.getAttribute("data-value")||"",label:a.getAttribute("data-label")||(null==(e=a.textContent)?void 0:e.trim())||"",disabled:a.hasAttribute("disabled"),element:t}}),this.updateSelectedLabelFromSlot()):this.$data.useSlot=!1}updateSelectedLabelFromSlot(){if(!this.$data.slotOptions.length)return;const t=this.$data.slotOptions.find(t=>t.value===this.$data.value);this.$data.selectedLabel=(null==t?void 0:t.label)||""}mounted(){this.refresh(),this.parseOptions(),this.setupSlotObserver(),this.clickOutsideHandler=t=>{t.composedPath().some(t=>t===this)||this.closeDropdown()},document.addEventListener("click",this.clickOutsideHandler)}setupSlotObserver(){setTimeout(()=>{this.collectSlotOptions()},0),this.slotObserver=new MutationObserver(()=>{this.collectSlotOptions()}),this.slotObserver.observe(this,{childList:!0,subtree:!1,attributes:!0,attributeFilter:["data-value","data-label","disabled"]})}unmounted(){this.clickOutsideHandler&&document.removeEventListener("click",this.clickOutsideHandler),this.slotObserver&&this.slotObserver.disconnect(),this.closeTimer&&(clearTimeout(this.closeTimer),this.closeTimer=void 0)}updated(){const t=this.$data.selectedLabel,e=this.getCurrentLabel();t!==e&&(this.$data.selectedLabel=e),this.updateAriaAttributes()}updateAriaAttributes(){var t;const e=null==(t=this.shadowRoot)?void 0:t.querySelector(".select__trigger");e&&(e.setAttribute("aria-expanded",this.$data.isOpen?"true":"false"),e.setAttribute("aria-disabled",this.$data.disabled?"true":"false"))}getCurrentLabel(){if(this.$data.useSlot){const t=this.$data.slotOptions.find(t=>t.value===this.$data.value);return(null==t?void 0:t.label)||""}{const t=this.$data.parsedOptions.find(t=>t.value===this.$data.value);return(null==t?void 0:t.label)||""}}parseOptions(){this.$data.parsedOptions=Array.isArray(this.$data.options)?this.$data.options:[],this.$data.useSlot||this.updateSelectedLabel()}updateSelectedLabel(){if(!this.$data.parsedOptions.length)return;const t=this.$data.parsedOptions.find(t=>t.value===this.$data.value);this.$data.selectedLabel=(null==t?void 0:t.label)||""}handleClick(){if(this.$data.disabled)return;const t=!this.$data.isOpen;this.$data.isOpen=t,this.$data.focused=t,t&&this.calculateDropdownPlacement()}handleSelect(t,e){t.disabled||(this.$data.value=t.value,this.updateSelectedLabel(),this.closeDropdown(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}handleSlotClick(t){var e;const a=t.target.closest("[data-value]");if(!a)return;if(a.hasAttribute("data-group"))return void t.stopPropagation();const s=a.getAttribute("data-value")||"",i=a.getAttribute("data-label")||(null==(e=a.textContent)?void 0:e.trim())||"";a.hasAttribute("disabled")||(this.$data.value=s,this.$data.selectedLabel=i,this.closeDropdown(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}handleHeaderFooterClick(t){t.stopPropagation()}handleClear(t){t.stopPropagation(),this.$data.value="",this.$data.selectedLabel="",this.dispatchEvent(new Event("clear",{bubbles:!0,composed:!0})),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}closeDropdown(){this.$data.isOpen&&(this.$data.closing=!0,this.closeTimer=setTimeout(()=>{this.$data.isOpen=!1,this.$data.closing=!1,this.$data.focused=!1,this.closeTimer=void 0},200))}setValue(t,e=!1){this.$data.value=t,this.$data.useSlot?this.updateSelectedLabelFromSlot():this.updateSelectedLabel(),e||this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}getValue(){return this.$data.value||""}setOptions(t){this.$data.options=t,this.$data.useSlot=!1,this.parseOptions()}};o=((t,e)=>{for(var a,s=e,i=t.length-1;i>=0;i--)(a=t[i])&&(s=a(s)||s);return s})([l({tagName:"solely-select",template:s,styles:a,shadowDOM:{use:!0,mode:"open"},props:[{name:"value",type:"string",default:""},{name:"placeholder",type:"string",default:"请选择"},{name:"disabled",type:"boolean",default:!1},{name:"size",type:"string",default:"medium"},{name:"clearable",type:"boolean",default:!1},{name:"options",type:"array",default:[]},{name:"multiple",type:"boolean",default:!1},{name:"block",type:"boolean",default:!1}]})],o);export{o as SolelySelect};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=Object.defineProperty,e=(e,a,i)=>((e,a,i)=>a in e?t(e,a,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[a]=i)(e,"symbol"!=typeof a?a+"":a,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./style.css.cjs"),i=require("./index.html.cjs"),s=require("../../../runtime/component/base-element.cjs"),n=require("../../../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;exports.SolelySlider=class extends s.default{constructor(){super(...arguments),e(this,"railElement"),e(this,"railRect")}getSliderClasses(){return{"slider--vertical":!!this.$data.vertical,"is-disabled":!!this.$data.disabled}}get value(){return this.$data.value??this.$data.min??0}set value(t){this.$data.disabled||this.setValue(t)}getHandleClasses(){return{"slider__handle--dragging":!!this.$data.isDragging}}mounted(){this.$data.isDragging=!1,void 0===this.$data.min&&(this.$data.min=0),void 0===this.$data.max&&(this.$data.max=100),void 0===this.$data.step&&(this.$data.step=1),void 0===this.$data.value&&(this.$data.value=this.$data.min),this.refresh()}
|
|
1
|
+
"use strict";var t=Object.defineProperty,e=(e,a,i)=>((e,a,i)=>a in e?t(e,a,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[a]=i)(e,"symbol"!=typeof a?a+"":a,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./style.css.cjs"),i=require("./index.html.cjs"),s=require("../../../runtime/component/base-element.cjs"),n=require("../../../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;exports.SolelySlider=class extends s.default{constructor(){super(...arguments),e(this,"railElement"),e(this,"dragMoveHandler"),e(this,"dragUpHandler"),e(this,"touchMoveHandler"),e(this,"touchEndHandler"),e(this,"railRect")}getSliderClasses(){return{"slider--vertical":!!this.$data.vertical,"is-disabled":!!this.$data.disabled}}get value(){return this.$data.value??this.$data.min??0}set value(t){this.$data.disabled||this.setValue(t)}getHandleClasses(){return{"slider__handle--dragging":!!this.$data.isDragging}}mounted(){var t;this.$data.isDragging=!1,void 0===this.$data.min&&(this.$data.min=0),void 0===this.$data.max&&(this.$data.max=100),void 0===this.$data.step&&(this.$data.step=1),void 0===this.$data.value&&(this.$data.value=this.$data.min),this.refresh(),this.railElement=null==(t=this.shadowRoot)?void 0:t.querySelector(".slider__rail")}unmounted(){this.cleanupDragListeners()}cleanupDragListeners(){this.dragMoveHandler&&(document.removeEventListener("mousemove",this.dragMoveHandler),this.dragMoveHandler=void 0),this.dragUpHandler&&(document.removeEventListener("mouseup",this.dragUpHandler),this.dragUpHandler=void 0),this.touchMoveHandler&&(document.removeEventListener("touchmove",this.touchMoveHandler),this.touchMoveHandler=void 0),this.touchEndHandler&&(document.removeEventListener("touchend",this.touchEndHandler),this.touchEndHandler=void 0)}updated(){this.updateAriaAttributes()}updateAriaAttributes(){var t;const e=null==(t=this.shadowRoot)?void 0:t.querySelector(".slider__handle");e&&(e.setAttribute("aria-valuenow",String(this.$data.value??this.$data.min??0)),e.setAttribute("aria-valuemin",String(this.$data.min??0)),e.setAttribute("aria-valuemax",String(this.$data.max??100)),e.setAttribute("aria-disabled",this.$data.disabled?"true":"false"))}getParsedMarks(){if(!this.$data.marks)return[];try{const t=this.$data.marksData||{};return Object.entries(t).map(([t,e])=>({value:parseFloat(t),label:String(e)}))}catch{return[]}}getTrackStyle(){const t=this.getPercent();return this.$data.vertical?`height: ${t}%;`:`width: ${t}%;`}getHandleStyle(){const t=this.getPercent();return this.$data.vertical?`bottom: ${t}%;`:`left: ${t}%;`}getMarkStyle(t){const e=this.$data.min??0,a=(t-e)/((this.$data.max??100)-e)*100;return this.$data.vertical?`bottom: ${a}%;`:`left: ${a}%;`}getPercent(){const t=this.$data.min??0,e=this.$data.max??100;return(Math.max(t,Math.min(e,this.$data.value??t))-t)/(e-t)*100}handleMouseDown(t){this.$data.disabled||(t.preventDefault(),this.$data.isDragging=!0,this.railElement&&(this.railRect=this.railElement.getBoundingClientRect()),this.updateValueFromRect(t),this.cleanupDragListeners(),this.dragMoveHandler=t=>{this.$data.isDragging&&this.updateValueFromRect(t)},this.dragUpHandler=()=>{this.$data.isDragging=!1,this.railRect=void 0,this.cleanupDragListeners(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))},document.addEventListener("mousemove",this.dragMoveHandler),document.addEventListener("mouseup",this.dragUpHandler))}handleTouchStart(t){this.$data.disabled||0!==t.touches.length&&(t.preventDefault(),this.$data.isDragging=!0,this.railElement&&(this.railRect=this.railElement.getBoundingClientRect()),this.updateValueFromRect(t.touches[0]),this.cleanupDragListeners(),this.touchMoveHandler=t=>{this.$data.isDragging&&t.touches.length>0&&this.updateValueFromRect(t.touches[0])},this.touchEndHandler=()=>{this.$data.isDragging=!1,this.railRect=void 0,this.cleanupDragListeners(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))},document.addEventListener("touchmove",this.touchMoveHandler),document.addEventListener("touchend",this.touchEndHandler))}updateValueFromRect(t){if(!this.railRect)return void this.updateValue(t);const e=this.railRect;let a;a=this.$data.vertical?1-(t.clientY-e.top)/e.height:(t.clientX-e.left)/e.width,a=Math.max(0,Math.min(1,a));const i=this.$data.min??0,s=this.$data.max??100,n=i+a*(s-i),r=this.$data.step||1,d=Math.round(n/r)*r,l=Math.max(i,Math.min(s,d));this.$data.value!==l&&(this.$data.value=l,this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})))}updateValue(t){var e;if(this.railElement||(this.railElement=null==(e=this.shadowRoot)?void 0:e.querySelector(".slider__rail")),!this.railElement)return;const a=this.railElement.getBoundingClientRect();let i;i=this.$data.vertical?1-(t.clientY-a.top)/a.height:(t.clientX-a.left)/a.width,i=Math.max(0,Math.min(1,i));const s=this.$data.min??0,n=this.$data.max??100,r=s+i*(n-s),d=this.$data.step||1,l=Math.round(r/d)*d,h=Math.max(s,Math.min(n,l));this.$data.value!==h&&(this.$data.value=h,this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})))}setValue(t){const e=this.$data.min??0,a=this.$data.max??100;this.$data.value=Math.max(e,Math.min(a,t))}getValue(){return this.$data.value??this.$data.min??0}},exports.SolelySlider=((t,e)=>{for(var a,i=e,s=t.length-1;s>=0;s--)(a=t[s])&&(i=a(i)||i);return i})([n.CustomElement({tagName:"solely-slider",template:i.__SOLELY_IR__,styles:a.default,shadowDOM:{use:!0,mode:"open"},props:[{name:"value",type:"number"},{name:"min",type:"number"},{name:"max",type:"number"},{name:"step",type:"number"},{name:"disabled",type:"boolean",default:!1},{name:"tooltipVisible",type:"boolean",default:!0},{name:"marks",type:"boolean",default:!1},{name:"marksData",type:"object",default:{}},{name:"vertical",type:"boolean",default:!1},{name:"block",type:"boolean",default:!1}]})],exports.SolelySlider);
|
|
@@ -8,6 +8,10 @@ declare class SolelySlider extends BaseElement<SliderProps & {
|
|
|
8
8
|
}>;
|
|
9
9
|
}> {
|
|
10
10
|
railElement?: HTMLElement;
|
|
11
|
+
private dragMoveHandler?;
|
|
12
|
+
private dragUpHandler?;
|
|
13
|
+
private touchMoveHandler?;
|
|
14
|
+
private touchEndHandler?;
|
|
11
15
|
/**
|
|
12
16
|
* 获取 slider class 对象
|
|
13
17
|
*/
|
|
@@ -22,7 +26,10 @@ declare class SolelySlider extends BaseElement<SliderProps & {
|
|
|
22
26
|
*/
|
|
23
27
|
getHandleClasses(): Record<string, boolean>;
|
|
24
28
|
mounted(): void;
|
|
25
|
-
|
|
29
|
+
unmounted(): void;
|
|
30
|
+
private cleanupDragListeners;
|
|
31
|
+
updated(): void;
|
|
32
|
+
private updateAriaAttributes;
|
|
26
33
|
/**
|
|
27
34
|
* 获取解析后的刻度标记
|
|
28
35
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var t=Object.defineProperty,e=(e,a,i)=>((e,a,i)=>a in e?t(e,a,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[a]=i)(e,"symbol"!=typeof a?a+"":a,i);import a from"./style.css.js";import{__SOLELY_IR__ as i}from"./index.html.js";import s from"../../../runtime/component/base-element.js";import{CustomElement as n}from"../../../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;let r=class extends s{constructor(){super(...arguments),e(this,"railElement"),e(this,"railRect")}getSliderClasses(){return{"slider--vertical":!!this.$data.vertical,"is-disabled":!!this.$data.disabled}}get value(){return this.$data.value??this.$data.min??0}set value(t){this.$data.disabled||this.setValue(t)}getHandleClasses(){return{"slider__handle--dragging":!!this.$data.isDragging}}mounted(){this.$data.isDragging=!1,void 0===this.$data.min&&(this.$data.min=0),void 0===this.$data.max&&(this.$data.max=100),void 0===this.$data.step&&(this.$data.step=1),void 0===this.$data.value&&(this.$data.value=this.$data.min),this.refresh()}
|
|
1
|
+
var t=Object.defineProperty,e=(e,a,i)=>((e,a,i)=>a in e?t(e,a,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[a]=i)(e,"symbol"!=typeof a?a+"":a,i);import a from"./style.css.js";import{__SOLELY_IR__ as i}from"./index.html.js";import s from"../../../runtime/component/base-element.js";import{CustomElement as n}from"../../../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;let r=class extends s{constructor(){super(...arguments),e(this,"railElement"),e(this,"dragMoveHandler"),e(this,"dragUpHandler"),e(this,"touchMoveHandler"),e(this,"touchEndHandler"),e(this,"railRect")}getSliderClasses(){return{"slider--vertical":!!this.$data.vertical,"is-disabled":!!this.$data.disabled}}get value(){return this.$data.value??this.$data.min??0}set value(t){this.$data.disabled||this.setValue(t)}getHandleClasses(){return{"slider__handle--dragging":!!this.$data.isDragging}}mounted(){var t;this.$data.isDragging=!1,void 0===this.$data.min&&(this.$data.min=0),void 0===this.$data.max&&(this.$data.max=100),void 0===this.$data.step&&(this.$data.step=1),void 0===this.$data.value&&(this.$data.value=this.$data.min),this.refresh(),this.railElement=null==(t=this.shadowRoot)?void 0:t.querySelector(".slider__rail")}unmounted(){this.cleanupDragListeners()}cleanupDragListeners(){this.dragMoveHandler&&(document.removeEventListener("mousemove",this.dragMoveHandler),this.dragMoveHandler=void 0),this.dragUpHandler&&(document.removeEventListener("mouseup",this.dragUpHandler),this.dragUpHandler=void 0),this.touchMoveHandler&&(document.removeEventListener("touchmove",this.touchMoveHandler),this.touchMoveHandler=void 0),this.touchEndHandler&&(document.removeEventListener("touchend",this.touchEndHandler),this.touchEndHandler=void 0)}updated(){this.updateAriaAttributes()}updateAriaAttributes(){var t;const e=null==(t=this.shadowRoot)?void 0:t.querySelector(".slider__handle");e&&(e.setAttribute("aria-valuenow",String(this.$data.value??this.$data.min??0)),e.setAttribute("aria-valuemin",String(this.$data.min??0)),e.setAttribute("aria-valuemax",String(this.$data.max??100)),e.setAttribute("aria-disabled",this.$data.disabled?"true":"false"))}getParsedMarks(){if(!this.$data.marks)return[];try{const t=this.$data.marksData||{};return Object.entries(t).map(([t,e])=>({value:parseFloat(t),label:String(e)}))}catch{return[]}}getTrackStyle(){const t=this.getPercent();return this.$data.vertical?`height: ${t}%;`:`width: ${t}%;`}getHandleStyle(){const t=this.getPercent();return this.$data.vertical?`bottom: ${t}%;`:`left: ${t}%;`}getMarkStyle(t){const e=this.$data.min??0,a=(t-e)/((this.$data.max??100)-e)*100;return this.$data.vertical?`bottom: ${a}%;`:`left: ${a}%;`}getPercent(){const t=this.$data.min??0,e=this.$data.max??100;return(Math.max(t,Math.min(e,this.$data.value??t))-t)/(e-t)*100}handleMouseDown(t){this.$data.disabled||(t.preventDefault(),this.$data.isDragging=!0,this.railElement&&(this.railRect=this.railElement.getBoundingClientRect()),this.updateValueFromRect(t),this.cleanupDragListeners(),this.dragMoveHandler=t=>{this.$data.isDragging&&this.updateValueFromRect(t)},this.dragUpHandler=()=>{this.$data.isDragging=!1,this.railRect=void 0,this.cleanupDragListeners(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))},document.addEventListener("mousemove",this.dragMoveHandler),document.addEventListener("mouseup",this.dragUpHandler))}handleTouchStart(t){this.$data.disabled||0!==t.touches.length&&(t.preventDefault(),this.$data.isDragging=!0,this.railElement&&(this.railRect=this.railElement.getBoundingClientRect()),this.updateValueFromRect(t.touches[0]),this.cleanupDragListeners(),this.touchMoveHandler=t=>{this.$data.isDragging&&t.touches.length>0&&this.updateValueFromRect(t.touches[0])},this.touchEndHandler=()=>{this.$data.isDragging=!1,this.railRect=void 0,this.cleanupDragListeners(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))},document.addEventListener("touchmove",this.touchMoveHandler),document.addEventListener("touchend",this.touchEndHandler))}updateValueFromRect(t){if(!this.railRect)return void this.updateValue(t);const e=this.railRect;let a;a=this.$data.vertical?1-(t.clientY-e.top)/e.height:(t.clientX-e.left)/e.width,a=Math.max(0,Math.min(1,a));const i=this.$data.min??0,s=this.$data.max??100,n=i+a*(s-i),r=this.$data.step||1,d=Math.round(n/r)*r,l=Math.max(i,Math.min(s,d));this.$data.value!==l&&(this.$data.value=l,this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})))}updateValue(t){var e;if(this.railElement||(this.railElement=null==(e=this.shadowRoot)?void 0:e.querySelector(".slider__rail")),!this.railElement)return;const a=this.railElement.getBoundingClientRect();let i;i=this.$data.vertical?1-(t.clientY-a.top)/a.height:(t.clientX-a.left)/a.width,i=Math.max(0,Math.min(1,i));const s=this.$data.min??0,n=this.$data.max??100,r=s+i*(n-s),d=this.$data.step||1,l=Math.round(r/d)*d,h=Math.max(s,Math.min(n,l));this.$data.value!==h&&(this.$data.value=h,this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})))}setValue(t){const e=this.$data.min??0,a=this.$data.max??100;this.$data.value=Math.max(e,Math.min(a,t))}getValue(){return this.$data.value??this.$data.min??0}};r=((t,e)=>{for(var a,i=e,s=t.length-1;s>=0;s--)(a=t[s])&&(i=a(i)||i);return i})([n({tagName:"solely-slider",template:i,styles:a,shadowDOM:{use:!0,mode:"open"},props:[{name:"value",type:"number"},{name:"min",type:"number"},{name:"max",type:"number"},{name:"step",type:"number"},{name:"disabled",type:"boolean",default:!1},{name:"tooltipVisible",type:"boolean",default:!0},{name:"marks",type:"boolean",default:!1},{name:"marksData",type:"object",default:{}},{name:"vertical",type:"boolean",default:!1},{name:"block",type:"boolean",default:!1}]})],r);export{r as SolelySlider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=Object.defineProperty;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";var t=Object.defineProperty,e=(e,s,r)=>((e,s,r)=>s in e?t(e,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[s]=r)(e,"symbol"!=typeof s?s+"":s,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./style.css.cjs"),r=require("./index.html.cjs"),i=require("../utils/helpers.cjs"),o=require("../../../runtime/component/base-element.cjs"),a=require("../../../runtime/component/decorators.cjs");var n,l,d,c=Object.defineProperty;Object.getOwnPropertyDescriptor;exports.SolelySteps=class extends o.default{constructor(){super(...arguments),e(this,"slotObserver"),e(this,"slotInitTimer")}get current(){return this.$data.current}set current(t){this.$data.current=t,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{current:t}}))}getStepsClasses(){const t={};return this.$data.direction&&(t[`steps--${this.$data.direction}`]=!0),t["steps--dot"]=!!this.$data.progressDot,"small"===this.$data.size?t["steps--sm"]=!0:"large"===this.$data.size&&(t["steps--lg"]=!0),t["use-slot"]=this.$data.useSlot,t}getStepClasses(t,e){const s=this.getStepStatus(e);return{"step--wait":"wait"===s,"step--process":"process"===s,"step--finish":"finish"===s,"step--error":"error"===s,"step--disabled":!!t.disabled}}getSlotStepClasses(t,e){const s=this.getSlotStepStatus(e);return{"step--wait":"wait"===s,"step--process":"process"===s,"step--finish":"finish"===s,"step--error":"error"===s,"step--disabled":!!t.disabled}}getIconClasses(t){const e={};return t.icon&&t.color&&exports.SolelySteps.PRESET_COLORS.includes(t.color)&&(e[`step__icon-wrapper--${t.color}`]=!0),e}getIconStyle(t){return t.icon&&t.color?exports.SolelySteps.PRESET_COLORS.includes(t.color)?"":`color: ${t.color}; background-color: ${t.color}15;`:""}collectSlotItems(){const t=Array.from(this.children).filter(t=>t.hasAttribute("data-step"));0!==t.length?(this.$data.useSlot=!0,this.$data.slotItems=t.map((t,e)=>{var s;const r=t;return{step:r.getAttribute("data-step")||String(e+1),title:r.getAttribute("data-title")||(null==(s=r.textContent)?void 0:s.trim())||"",description:r.getAttribute("data-description")||void 0,disabled:r.hasAttribute("disabled"),iconHtml:r.innerHTML}})):this.$data.useSlot=!1}mounted(){this.refresh(),this.setupSlotObserver()}getParsedItems(){const t=this.$data.items;return Array.isArray(t)?t:"string"==typeof t&&t?i.safeJsonParse(t,[]):[]}setupSlotObserver(){this.slotInitTimer=setTimeout(()=>{this.collectSlotItems(),this.slotInitTimer=void 0},0),this.slotObserver=new MutationObserver(()=>{this.collectSlotItems()}),this.slotObserver.observe(this,{childList:!0,subtree:!1,attributes:!0,attributeFilter:["data-step","data-title","data-description","disabled"]})}unmounted(){this.slotObserver&&this.slotObserver.disconnect(),this.slotInitTimer&&(clearTimeout(this.slotInitTimer),this.slotInitTimer=void 0)}getStepStatus(t){const e=this.$data.current||0,s=this.getParsedItems();if(!Array.isArray(s)||t<0||t>=s.length)return"wait";const r=s[t];return(null==r?void 0:r.status)?r.status:t<e?"finish":t===e?"process":"wait"}getSlotStepStatus(t){const e=this.$data.current||0;return t<e?"finish":t===e?"process":"wait"}getStepIcon(t,e){if(t.icon)return t.icon;const s=this.getStepStatus(e);return"finish"===s?"✓":"error"===s?"✕":String(e+1)}handleStepClick(t,e){t.disabled||(this.$data.current=e,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{index:e,item:t}})))}handleSlotStepClick(t,e){t.disabled||(this.$data.current=e,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{index:e,item:t}})))}setCurrent(t){this.$data.current=t}getCurrent(){return this.$data.current}next(){const t=this.$data.useSlot?this.$data.slotItems.length-1:this.getParsedItems().length-1;this.$data.current<t&&this.$data.current++}prev(){this.$data.current>0&&this.$data.current--}setItems(t){this.$data.items=JSON.stringify(t),this.$data.useSlot=!1,this.refresh()}},n=exports.SolelySteps,d=["blue","green","red","orange","gray"],(l="PRESET_COLORS")in n?c(n,l,{enumerable:!0,configurable:!0,writable:!0,value:d}):n[l]=d,exports.SolelySteps=((t,e)=>{for(var s,r=e,i=t.length-1;i>=0;i--)(s=t[i])&&(r=s(r)||r);return r})([a.CustomElement({tagName:"solely-steps",template:r.__SOLELY_IR__,styles:s.default,shadowDOM:{use:!0,mode:"open"},props:[{name:"current",type:"number",default:0},{name:"direction",type:"string",default:"horizontal"},{name:"size",type:"string",default:"default"},{name:"items",type:"string",default:"[]"},{name:"progressDot",type:"boolean",default:!1}]})],exports.SolelySteps);
|
|
@@ -6,6 +6,7 @@ declare class SolelySteps extends BaseElement<StepsProps & {
|
|
|
6
6
|
}> {
|
|
7
7
|
private static readonly PRESET_COLORS;
|
|
8
8
|
slotObserver?: MutationObserver;
|
|
9
|
+
private slotInitTimer?;
|
|
9
10
|
get current(): number;
|
|
10
11
|
set current(value: number);
|
|
11
12
|
getStepsClasses(): Record<string, boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var t=Object.defineProperty;import
|
|
1
|
+
var t=Object.defineProperty,e=(e,s,r)=>((e,s,r)=>s in e?t(e,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[s]=r)(e,"symbol"!=typeof s?s+"":s,r);import s from"./style.css.js";import{__SOLELY_IR__ as r}from"./index.html.js";import{safeJsonParse as i}from"../utils/helpers.js";import a from"../../../runtime/component/base-element.js";import{CustomElement as o}from"../../../runtime/component/decorators.js";var n=Object.defineProperty;Object.getOwnPropertyDescriptor;let l=class extends a{constructor(){super(...arguments),e(this,"slotObserver"),e(this,"slotInitTimer")}get current(){return this.$data.current}set current(t){this.$data.current=t,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{current:t}}))}getStepsClasses(){const t={};return this.$data.direction&&(t[`steps--${this.$data.direction}`]=!0),t["steps--dot"]=!!this.$data.progressDot,"small"===this.$data.size?t["steps--sm"]=!0:"large"===this.$data.size&&(t["steps--lg"]=!0),t["use-slot"]=this.$data.useSlot,t}getStepClasses(t,e){const s=this.getStepStatus(e);return{"step--wait":"wait"===s,"step--process":"process"===s,"step--finish":"finish"===s,"step--error":"error"===s,"step--disabled":!!t.disabled}}getSlotStepClasses(t,e){const s=this.getSlotStepStatus(e);return{"step--wait":"wait"===s,"step--process":"process"===s,"step--finish":"finish"===s,"step--error":"error"===s,"step--disabled":!!t.disabled}}getIconClasses(t){const e={};return t.icon&&t.color&&l.PRESET_COLORS.includes(t.color)&&(e[`step__icon-wrapper--${t.color}`]=!0),e}getIconStyle(t){return t.icon&&t.color?l.PRESET_COLORS.includes(t.color)?"":`color: ${t.color}; background-color: ${t.color}15;`:""}collectSlotItems(){const t=Array.from(this.children).filter(t=>t.hasAttribute("data-step"));0!==t.length?(this.$data.useSlot=!0,this.$data.slotItems=t.map((t,e)=>{var s;const r=t;return{step:r.getAttribute("data-step")||String(e+1),title:r.getAttribute("data-title")||(null==(s=r.textContent)?void 0:s.trim())||"",description:r.getAttribute("data-description")||void 0,disabled:r.hasAttribute("disabled"),iconHtml:r.innerHTML}})):this.$data.useSlot=!1}mounted(){this.refresh(),this.setupSlotObserver()}getParsedItems(){const t=this.$data.items;return Array.isArray(t)?t:"string"==typeof t&&t?i(t,[]):[]}setupSlotObserver(){this.slotInitTimer=setTimeout(()=>{this.collectSlotItems(),this.slotInitTimer=void 0},0),this.slotObserver=new MutationObserver(()=>{this.collectSlotItems()}),this.slotObserver.observe(this,{childList:!0,subtree:!1,attributes:!0,attributeFilter:["data-step","data-title","data-description","disabled"]})}unmounted(){this.slotObserver&&this.slotObserver.disconnect(),this.slotInitTimer&&(clearTimeout(this.slotInitTimer),this.slotInitTimer=void 0)}getStepStatus(t){const e=this.$data.current||0,s=this.getParsedItems();if(!Array.isArray(s)||t<0||t>=s.length)return"wait";const r=s[t];return(null==r?void 0:r.status)?r.status:t<e?"finish":t===e?"process":"wait"}getSlotStepStatus(t){const e=this.$data.current||0;return t<e?"finish":t===e?"process":"wait"}getStepIcon(t,e){if(t.icon)return t.icon;const s=this.getStepStatus(e);return"finish"===s?"✓":"error"===s?"✕":String(e+1)}handleStepClick(t,e){t.disabled||(this.$data.current=e,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{index:e,item:t}})))}handleSlotStepClick(t,e){t.disabled||(this.$data.current=e,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{index:e,item:t}})))}setCurrent(t){this.$data.current=t}getCurrent(){return this.$data.current}next(){const t=this.$data.useSlot?this.$data.slotItems.length-1:this.getParsedItems().length-1;this.$data.current<t&&this.$data.current++}prev(){this.$data.current>0&&this.$data.current--}setItems(t){this.$data.items=JSON.stringify(t),this.$data.useSlot=!1,this.refresh()}};var d,c,u;u=["blue","green","red","orange","gray"],(c="PRESET_COLORS")in(d=l)?n(d,c,{enumerable:!0,configurable:!0,writable:!0,value:u}):d[c]=u,l=((t,e)=>{for(var s,r=e,i=t.length-1;i>=0;i--)(s=t[i])&&(r=s(r)||r);return r})([o({tagName:"solely-steps",template:r,styles:s,shadowDOM:{use:!0,mode:"open"},props:[{name:"current",type:"number",default:0},{name:"direction",type:"string",default:"horizontal"},{name:"size",type:"string",default:"default"},{name:"items",type:"string",default:"[]"},{name:"progressDot",type:"boolean",default:!1}]})],l);export{l as SolelySteps};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./style.css.cjs"),t=require("./index.html.cjs"),s=require("../utils/helpers.cjs"),a=require("../../../runtime/component/base-element.cjs"),i=require("../../../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;exports.SolelyTabs=class extends a.default{get activeKey(){return this.$data.activeKey}set activeKey(e){this.$data.activeKey=e,this.dispatchEvent(new
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./style.css.cjs"),t=require("./index.html.cjs"),s=require("../utils/helpers.cjs"),a=require("../../../runtime/component/base-element.cjs"),i=require("../../../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;exports.SolelyTabs=class extends a.default{get activeKey(){return this.$data.activeKey}set activeKey(e){this.$data.activeKey=e,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{activeKey:e}}))}getTabsClasses(){const e={};return this.$data.type&&(e[`tabs--${this.$data.type}`]=!0),"small"===this.$data.size?e["tabs--sm"]=!0:"large"===this.$data.size?e["tabs--lg"]=!0:e["tabs--md"]=!0,e}getTabClasses(e){return{"tabs__tab--active":e.key===this.$data.activeKey,"tabs__tab--disabled":!!e.disabled}}getPaneClasses(e){return{"tabs__pane--active":e.key===this.$data.activeKey}}mounted(){this.refresh();const e=this.getParsedItems();if(!this.$data.activeKey&&Array.isArray(e)&&e.length>0){const t=e[0];t&&t.key&&(this.$data.activeKey=t.key)}}getParsedItems(){const e=this.$data.items;return Array.isArray(e)?e:"string"==typeof e&&e?s.safeJsonParse(e,[]):[]}handleTabClick(e){e.disabled||(this.$data.activeKey=e.key,this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}handleClose(e,t){t.stopPropagation();const s=this.getParsedItems(),a=s.findIndex(t=>t.key===e.key);if(a>-1){if(s.splice(a,1),this.$data.activeKey===e.key&&Array.isArray(s)&&s.length>0){const e=s[Math.min(a,s.length-1)];e&&e.key&&(this.$data.activeKey=e.key)}this.$data.items=JSON.stringify(s)}this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0,detail:{key:e.key,label:e.label}}))}handleAdd(){const e=this.getParsedItems(),t=e.length+1,s={key:`new-${Date.now()}`,label:`新标签 ${t}`};e.push(s),this.$data.activeKey=s.key,this.$data.items=JSON.stringify(e),this.dispatchEvent(new CustomEvent("add",{bubbles:!0,composed:!0,detail:{key:s.key,label:s.label}}))}setActiveKey(e){this.$data.activeKey=e}getActiveKey(){return this.$data.activeKey}setItems(e){this.$data.items=JSON.stringify(e),this.refresh()}},exports.SolelyTabs=((e,t)=>{for(var s,a=t,i=e.length-1;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a})([i.CustomElement({tagName:"solely-tabs",template:t.__SOLELY_IR__,styles:e.default,shadowDOM:{use:!0,mode:"open"},props:[{name:"activeKey",type:"string",default:""},{name:"type",type:"string",default:"line"},{name:"position",type:"string",default:"top"},{name:"size",type:"string",default:"default"},{name:"items",type:"string",default:"[]"},{name:"closable",type:"boolean",default:!1},{name:"addable",type:"boolean",default:!1}]})],exports.SolelyTabs);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"./style.css.js";import{__SOLELY_IR__ as t}from"./index.html.js";import{safeJsonParse as a}from"../utils/helpers.js";import s from"../../../runtime/component/base-element.js";import{CustomElement as i}from"../../../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;let n=class extends s{get activeKey(){return this.$data.activeKey}set activeKey(e){this.$data.activeKey=e,this.dispatchEvent(new
|
|
1
|
+
import e from"./style.css.js";import{__SOLELY_IR__ as t}from"./index.html.js";import{safeJsonParse as a}from"../utils/helpers.js";import s from"../../../runtime/component/base-element.js";import{CustomElement as i}from"../../../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;let n=class extends s{get activeKey(){return this.$data.activeKey}set activeKey(e){this.$data.activeKey=e,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{activeKey:e}}))}getTabsClasses(){const e={};return this.$data.type&&(e[`tabs--${this.$data.type}`]=!0),"small"===this.$data.size?e["tabs--sm"]=!0:"large"===this.$data.size?e["tabs--lg"]=!0:e["tabs--md"]=!0,e}getTabClasses(e){return{"tabs__tab--active":e.key===this.$data.activeKey,"tabs__tab--disabled":!!e.disabled}}getPaneClasses(e){return{"tabs__pane--active":e.key===this.$data.activeKey}}mounted(){this.refresh();const e=this.getParsedItems();if(!this.$data.activeKey&&Array.isArray(e)&&e.length>0){const t=e[0];t&&t.key&&(this.$data.activeKey=t.key)}}getParsedItems(){const e=this.$data.items;return Array.isArray(e)?e:"string"==typeof e&&e?a(e,[]):[]}handleTabClick(e){e.disabled||(this.$data.activeKey=e.key,this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}handleClose(e,t){t.stopPropagation();const a=this.getParsedItems(),s=a.findIndex(t=>t.key===e.key);if(s>-1){if(a.splice(s,1),this.$data.activeKey===e.key&&Array.isArray(a)&&a.length>0){const e=a[Math.min(s,a.length-1)];e&&e.key&&(this.$data.activeKey=e.key)}this.$data.items=JSON.stringify(a)}this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0,detail:{key:e.key,label:e.label}}))}handleAdd(){const e=this.getParsedItems(),t=e.length+1,a={key:`new-${Date.now()}`,label:`新标签 ${t}`};e.push(a),this.$data.activeKey=a.key,this.$data.items=JSON.stringify(e),this.dispatchEvent(new CustomEvent("add",{bubbles:!0,composed:!0,detail:{key:a.key,label:a.label}}))}setActiveKey(e){this.$data.activeKey=e}getActiveKey(){return this.$data.activeKey}setItems(e){this.$data.items=JSON.stringify(e),this.refresh()}};n=((e,t)=>{for(var a,s=t,i=e.length-1;i>=0;i--)(a=e[i])&&(s=a(s)||s);return s})([i({tagName:"solely-tabs",template:t,styles:e,shadowDOM:{use:!0,mode:"open"},props:[{name:"activeKey",type:"string",default:""},{name:"type",type:"string",default:"line"},{name:"position",type:"string",default:"top"},{name:"size",type:"string",default:"default"},{name:"items",type:"string",default:"[]"},{name:"closable",type:"boolean",default:!1},{name:"addable",type:"boolean",default:!1}]})],n);export{n as SolelyTabs};
|
|
@@ -2,6 +2,9 @@ import { BaseElement } from '../../../runtime/component';
|
|
|
2
2
|
import { TooltipProps } from './types';
|
|
3
3
|
declare class SolelyTooltip extends BaseElement<TooltipProps> {
|
|
4
4
|
private _clickOutsideHandler?;
|
|
5
|
+
private _boundFocusHandler?;
|
|
6
|
+
private _boundBlurHandler?;
|
|
7
|
+
private _boundFocusable?;
|
|
5
8
|
/**
|
|
6
9
|
* 获取 tooltip class 对象
|
|
7
10
|
*/
|
|
@@ -34,6 +37,7 @@ declare class SolelyTooltip extends BaseElement<TooltipProps> {
|
|
|
34
37
|
* 绑定事件到 slot 内容元素
|
|
35
38
|
*/
|
|
36
39
|
private bindSlotEvents;
|
|
40
|
+
private unbindSlotEvents;
|
|
37
41
|
/**
|
|
38
42
|
* 点击处理
|
|
39
43
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";var e=Object.defineProperty,t=(t,s,a)=>((t,s,a)=>s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a)(t,"symbol"!=typeof s?s+"":s,a);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./style.css.cjs"),a=require("./index.html.cjs"),i=require("../utils/helpers.cjs"),r=require("../../../runtime/component/base-element.cjs"),n=require("../../../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;exports.SolelyUpload=class extends r.default{constructor(){super(...arguments),t(this,"activeXhrs",[]),t(this,"objectURLs",[])}getUploadClasses(){const e={};return this.$data.listType&&(e[`upload--${this.$data.listType}`]=!0),e["is-disabled"]=!!this.$data.disabled,e}get fileList(){return this.$data.parsedFileList}set fileList(e){this.$data.parsedFileList=e,this.$data.fileList=JSON.stringify(e)}getDragClasses(){return{"upload__drag--active":!!this.$data.isDragging}}mounted(){this.refresh(),this.parseFileList(),this.$data.isDragging=!1}unmounted(){for(const e of this.activeXhrs)e.abort();this.activeXhrs=[];for(const e of this.objectURLs)URL.revokeObjectURL(e);this.objectURLs=[]}parseFileList(){this.$data.parsedFileList=i.safeJsonParse(this.$data.fileList,[])}triggerUpload(){var e;if(this.$data.disabled)return;const t=null==(e=this.shadowRoot)?void 0:e.querySelector('input[type="file"]');t&&t.click()}handleFileChange(e){const t=e.target,s=t.files;s&&s.length>0&&this.handleFiles(s),t.value=""}handleFiles(e){const t=this.$data.maxCount||1/0,s=this.$data.maxSize||1/0;Array.from(e).forEach(e=>{if(this.$data.parsedFileList.length>=t)return void this.emit("error",{file:{name:e.name,size:e.size},message:`文件数量超过限制 (最多 ${t} 个)`});if(e.size>s)return void this.emit("error",{file:{name:e.name,size:e.size},message:`文件大小超过限制 (${this.formatSize(s)})`});const a={uid:Date.now()+Math.random().toString(36).substr(2,9),name:e.name,size:e.size,type:e.type,status:"uploading",percent:0};this.$data.parsedFileList.push(a),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),this.uploadFile(a,e)})}uploadFile(e,t){if(!this.$data.action)return e.status="done",e.percent=100,e.url=URL.createObjectURL(t),this.objectURLs.push(e.url),this.refresh(),this.emit("success",{file:e,fileList:this.$data.parsedFileList}),void this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}));const s=new XMLHttpRequest;this.activeXhrs.push(s);const a=new FormData;a.append("file",t),s.upload.addEventListener("progress",t=>{t.lengthComputable&&(e.percent=Math.round(t.loaded/t.total*100),this.$data.parsedFileList=[...this.$data.parsedFileList])}),s.addEventListener("load",()=>{if(this.activeXhrs=this.activeXhrs.filter(e=>e!==s),s.status>=200&&s.status<300){e.status="done",e.percent=100;try{const t=JSON.parse(s.responseText);t.url&&(e.url=t.url)}catch{}this.$data.parsedFileList=[...this.$data.parsedFileList],this.emit("success",{file:e,fileList:this.$data.parsedFileList})}else e.status="error",e.error=s.statusText,this.$data.parsedFileList=[...this.$data.parsedFileList],this.emit("error",{file:e,message:s.statusText});this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}),s.addEventListener("error",()=>{this.activeXhrs=this.activeXhrs.filter(e=>e!==s),e.status="error",e.error="网络错误",this.$data.parsedFileList=[...this.$data.parsedFileList],this.emit("error",{file:e,message:"网络错误"}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}),s.open("POST",this.$data.action,!0),s.send(a)}handleDragOver(e){e.preventDefault(),this.$data.isDragging=!0}handleDragLeave(e){e.preventDefault(),this.$data.isDragging=!1}handleDrop(e){var t;e.preventDefault(),this.$data.isDragging=!1;const s=null==(t=e.dataTransfer)?void 0:t.files;s&&s.length>0&&this.handleFiles(s)}handleRemove(e){const t=this.$data.parsedFileList.findIndex(t=>t.uid===e.uid);t>-1&&(this.$data.parsedFileList.splice(t,1),this.emit("remove",{file:e,fileList:this.$data.parsedFileList}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}formatSize(e){if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["B","KB","MB","GB"][t]}getStatusText(e){return{uploading:"上传中",done:"完成",error:"失败",removed:"已删除"}[e||""]||""}getFileList(){return this.$data.parsedFileList}clear(){this.$data.parsedFileList=[]}},exports.SolelyUpload=((e,t)=>{for(var s,a=t,i=e.length-1;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a})([n.CustomElement({tagName:"solely-upload",template:a.__SOLELY_IR__,styles:s.default,shadowDOM:{use:!0,mode:"open"},props:[{name:"action",type:"string"},{name:"accept",type:"string"},{name:"multiple",type:"boolean",default:!1},{name:"fileList",type:"string"},{name:"listType",type:"string"},{name:"disabled",type:"boolean",default:!1},{name:"showUploadList",type:"boolean",default:!0},{name:"buttonText",type:"string"},{name:"drag",type:"boolean",default:!1},{name:"maxCount",type:"number"},{name:"maxSize",type:"number"},{name:"block",type:"boolean",default:!1}]})],exports.SolelyUpload);
|
|
@@ -4,6 +4,8 @@ declare class SolelyUpload extends BaseElement<UploadProps & {
|
|
|
4
4
|
parsedFileList: UploadFile[];
|
|
5
5
|
isDragging: boolean;
|
|
6
6
|
}> {
|
|
7
|
+
private activeXhrs;
|
|
8
|
+
private objectURLs;
|
|
7
9
|
/**
|
|
8
10
|
* 获取 upload class 对象
|
|
9
11
|
*/
|
|
@@ -18,6 +20,7 @@ declare class SolelyUpload extends BaseElement<UploadProps & {
|
|
|
18
20
|
*/
|
|
19
21
|
getDragClasses(): Record<string, boolean>;
|
|
20
22
|
mounted(): void;
|
|
23
|
+
unmounted(): void;
|
|
21
24
|
/**
|
|
22
25
|
* 解析文件列表
|
|
23
26
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
var e=Object.defineProperty,t=(t,s,a)=>((t,s,a)=>s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a)(t,"symbol"!=typeof s?s+"":s,a);import s from"./style.css.js";import{__SOLELY_IR__ as a}from"./index.html.js";import{safeJsonParse as i}from"../utils/helpers.js";import r from"../../../runtime/component/base-element.js";import{CustomElement as n}from"../../../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;let o=class extends r{constructor(){super(...arguments),t(this,"activeXhrs",[]),t(this,"objectURLs",[])}getUploadClasses(){const e={};return this.$data.listType&&(e[`upload--${this.$data.listType}`]=!0),e["is-disabled"]=!!this.$data.disabled,e}get fileList(){return this.$data.parsedFileList}set fileList(e){this.$data.parsedFileList=e,this.$data.fileList=JSON.stringify(e)}getDragClasses(){return{"upload__drag--active":!!this.$data.isDragging}}mounted(){this.refresh(),this.parseFileList(),this.$data.isDragging=!1}unmounted(){for(const e of this.activeXhrs)e.abort();this.activeXhrs=[];for(const e of this.objectURLs)URL.revokeObjectURL(e);this.objectURLs=[]}parseFileList(){this.$data.parsedFileList=i(this.$data.fileList,[])}triggerUpload(){var e;if(this.$data.disabled)return;const t=null==(e=this.shadowRoot)?void 0:e.querySelector('input[type="file"]');t&&t.click()}handleFileChange(e){const t=e.target,s=t.files;s&&s.length>0&&this.handleFiles(s),t.value=""}handleFiles(e){const t=this.$data.maxCount||1/0,s=this.$data.maxSize||1/0;Array.from(e).forEach(e=>{if(this.$data.parsedFileList.length>=t)return void this.emit("error",{file:{name:e.name,size:e.size},message:`文件数量超过限制 (最多 ${t} 个)`});if(e.size>s)return void this.emit("error",{file:{name:e.name,size:e.size},message:`文件大小超过限制 (${this.formatSize(s)})`});const a={uid:Date.now()+Math.random().toString(36).substr(2,9),name:e.name,size:e.size,type:e.type,status:"uploading",percent:0};this.$data.parsedFileList.push(a),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),this.uploadFile(a,e)})}uploadFile(e,t){if(!this.$data.action)return e.status="done",e.percent=100,e.url=URL.createObjectURL(t),this.objectURLs.push(e.url),this.refresh(),this.emit("success",{file:e,fileList:this.$data.parsedFileList}),void this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}));const s=new XMLHttpRequest;this.activeXhrs.push(s);const a=new FormData;a.append("file",t),s.upload.addEventListener("progress",t=>{t.lengthComputable&&(e.percent=Math.round(t.loaded/t.total*100),this.$data.parsedFileList=[...this.$data.parsedFileList])}),s.addEventListener("load",()=>{if(this.activeXhrs=this.activeXhrs.filter(e=>e!==s),s.status>=200&&s.status<300){e.status="done",e.percent=100;try{const t=JSON.parse(s.responseText);t.url&&(e.url=t.url)}catch{}this.$data.parsedFileList=[...this.$data.parsedFileList],this.emit("success",{file:e,fileList:this.$data.parsedFileList})}else e.status="error",e.error=s.statusText,this.$data.parsedFileList=[...this.$data.parsedFileList],this.emit("error",{file:e,message:s.statusText});this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}),s.addEventListener("error",()=>{this.activeXhrs=this.activeXhrs.filter(e=>e!==s),e.status="error",e.error="网络错误",this.$data.parsedFileList=[...this.$data.parsedFileList],this.emit("error",{file:e,message:"网络错误"}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}),s.open("POST",this.$data.action,!0),s.send(a)}handleDragOver(e){e.preventDefault(),this.$data.isDragging=!0}handleDragLeave(e){e.preventDefault(),this.$data.isDragging=!1}handleDrop(e){var t;e.preventDefault(),this.$data.isDragging=!1;const s=null==(t=e.dataTransfer)?void 0:t.files;s&&s.length>0&&this.handleFiles(s)}handleRemove(e){const t=this.$data.parsedFileList.findIndex(t=>t.uid===e.uid);t>-1&&(this.$data.parsedFileList.splice(t,1),this.emit("remove",{file:e,fileList:this.$data.parsedFileList}),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}formatSize(e){if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["B","KB","MB","GB"][t]}getStatusText(e){return{uploading:"上传中",done:"完成",error:"失败",removed:"已删除"}[e||""]||""}getFileList(){return this.$data.parsedFileList}clear(){this.$data.parsedFileList=[]}};o=((e,t)=>{for(var s,a=t,i=e.length-1;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a})([n({tagName:"solely-upload",template:a,styles:s,shadowDOM:{use:!0,mode:"open"},props:[{name:"action",type:"string"},{name:"accept",type:"string"},{name:"multiple",type:"boolean",default:!1},{name:"fileList",type:"string"},{name:"listType",type:"string"},{name:"disabled",type:"boolean",default:!1},{name:"showUploadList",type:"boolean",default:!0},{name:"buttonText",type:"string"},{name:"drag",type:"boolean",default:!1},{name:"maxCount",type:"number"},{name:"maxSize",type:"number"},{name:"block",type:"boolean",default:!1}]})],o);export{o as SolelyUpload};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./router/index.cjs"),r=require("./shared/templateError.cjs"),t=require("./shared/gen-function.cjs"),s=require("./shared/functions.cjs"),o=require("./shared/event-listeners.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./router/index.cjs"),r=require("./shared/templateError.cjs"),t=require("./shared/gen-function.cjs"),s=require("./shared/functions.cjs"),o=require("./shared/event-listeners.cjs"),c=require("./shared/is-object.cjs"),i=require("./shared/url.cjs"),u=require("./shared/env.cjs"),a=require("./shared/case-convert.cjs"),n=require("./types/ast.cjs"),p=require("./types/lifecycle.cjs"),l=require("./runtime/component/base-element.cjs"),d=require("./router/router-link.cjs"),x=require("./router/router-view.cjs"),m=require("./runtime/renderer/html-decode.cjs"),R=require("./runtime/component/decorators.cjs"),j=require("./runtime/renderer/renderIR.cjs"),q=require("./router/core.cjs"),b=require("./compiler/ir/buildIR.cjs"),y=require("./runtime/reactivity/observe.cjs"),f=require("./compiler/parser/parser.cjs");exports.createRouter=e.createRouter,exports.showTemplateError=r.showTemplateError,exports.genFunction=t.genFunction,exports.createFunction=s.createFunction,exports.isCSPBlocked=s.isCSPBlocked,exports.listeners=o.default,exports.isObject=c.isObject,exports.parseHashUrl=i.parseHashUrl,exports.IS_DEV=u.IS_DEV,exports.IS_PROD=u.IS_PROD,exports.camelToKebab=a.camelToKebab,exports.ASTType=n.ASTType,exports.LIFECYCLE_ATTRS_MAP=p.LIFECYCLE_ATTRS_MAP,exports.isLifecycleKind=p.isLifecycleKind,exports.mapAttrKeyToLifecycleKind=p.mapAttrKeyToLifecycleKind,exports.BaseElement=l.default,Object.defineProperty(exports,"RouterLink",{enumerable:!0,get:()=>d.default}),Object.defineProperty(exports,"RouterView",{enumerable:!0,get:()=>x.default}),exports.htmlDecode=m.default,exports.CustomElement=R.CustomElement,exports.IRRenderer=j.IRRenderer,exports.createRender=j.createRender,exports.Router=q.Router,exports.getRouter=q.getRouter,exports.routerReady=q.routerReady,exports.buildIR=b.buildIR,exports.clearIRCache=b.clearIRCache,exports.transformModel=b.transformModel,exports.isProxy=y.isProxy,exports.observe=y.observe,exports.toRaw=y.toRaw,exports.parseHtml=f.parseHtml;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRouter as r}from"./router/index.js";import{showTemplateError as e}from"./shared/templateError.js";import{genFunction as o}from"./shared/gen-function.js";import{createFunction as t,isCSPBlocked as m}from"./shared/functions.js";import{default as s}from"./shared/event-listeners.js";import{isObject as i}from"./shared/is-object.js";import{parseHashUrl as a}from"./shared/url.js";import{IS_DEV as p,IS_PROD as f}from"./shared/env.js";import{
|
|
1
|
+
import{createRouter as r}from"./router/index.js";import{showTemplateError as e}from"./shared/templateError.js";import{genFunction as o}from"./shared/gen-function.js";import{createFunction as t,isCSPBlocked as m}from"./shared/functions.js";import{default as s}from"./shared/event-listeners.js";import{isObject as i}from"./shared/is-object.js";import{parseHashUrl as a}from"./shared/url.js";import{IS_DEV as p,IS_PROD as f}from"./shared/env.js";import{camelToKebab as n}from"./shared/case-convert.js";import{ASTType as d}from"./types/ast.js";import{LIFECYCLE_ATTRS_MAP as j,isLifecycleKind as u,mapAttrKeyToLifecycleKind as l}from"./types/lifecycle.js";import{default as c}from"./runtime/component/base-element.js";import{default as h}from"./router/router-link.js";import{default as v}from"./router/router-view.js";import{default as b}from"./runtime/renderer/html-decode.js";import{CustomElement as y}from"./runtime/component/decorators.js";import{IRRenderer as R,createRender as k}from"./runtime/renderer/renderIR.js";import{Router as w,getRouter as x,routerReady as E}from"./router/core.js";import{buildIR as I,clearIRCache as g,transformModel as B}from"./compiler/ir/buildIR.js";import{isProxy as D,observe as L,toRaw as V}from"./runtime/reactivity/observe.js";import{parseHtml as q}from"./compiler/parser/parser.js";export{d as ASTType,c as BaseElement,y as CustomElement,R as IRRenderer,p as IS_DEV,f as IS_PROD,j as LIFECYCLE_ATTRS_MAP,w as Router,h as RouterLink,v as RouterView,I as buildIR,n as camelToKebab,g as clearIRCache,t as createFunction,k as createRender,r as createRouter,o as genFunction,x as getRouter,b as htmlDecode,m as isCSPBlocked,u as isLifecycleKind,i as isObject,D as isProxy,s as listeners,l as mapAttrKeyToLifecycleKind,L as observe,a as parseHashUrl,q as parseHtml,E as routerReady,e as showTemplateError,V as toRaw,B as transformModel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t,e,s,i,a,n,o,r,h,l,
|
|
1
|
+
"use strict";var t,e,s,i,a,n,o,r,h,c,l,u,d,p,f,b,m,y,v,w,g,M,S,O,k,$,j=Object.defineProperty,C=t=>{throw TypeError(t)},W=(t,e,s)=>e.has(t)||C("Cannot "+s),A=(t,e,s)=>(W(t,e,"read from private field"),s?s.call(t):e.get(t)),E=(t,e,s)=>e.has(t)?C("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),N=(t,e,s,i)=>(W(t,e,"write to private field"),i?i.call(t,s):e.set(t,s),s),D=(t,e,s)=>(W(t,e,"access private method"),s);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const P=require("../../shared/is-object.cjs"),q=require("../../shared/env.cjs"),U=require("../../shared/case-convert.cjs"),I=require("../reactivity/observe.cjs"),_=require("../renderer/renderIR.cjs"),x=Symbol.for("solely.manifest"),L=class y extends HTMLElement{constructor(p={}){var b,y;super(),E(this,f),((t,e,s)=>{e in t?j(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s})(this,"symbol"!=typeof(y="$refs")?y+"":y,{}),E(this,t),E(this,e),E(this,s),E(this,i),E(this,a),E(this,n),E(this,o,!1),E(this,r,!1),E(this,h,!1),E(this,c,!1),E(this,l,!1),E(this,u,!1),E(this,d,!1);const w=this.constructor;N(this,t,w[x]||{tagName:"base-element"});const g=A(this,t);N(this,a,(null==(b=g.shadowDOM)?void 0:b.use)?this.attachShadow({mode:g.shadowDOM.mode||"open"}):this),D(this,f,m).call(this,p),D(this,f,v).call(this,g),queueMicrotask(()=>D(this,f,$).call(this))}static get observedAttributes(){const t=this[x];return(null==t?void 0:t.attributeMap)?Array.from(t.attributeMap.keys()):[]}get $data(){return A(this,i)}set $data(t){var e;P.isObject(t)||(t={}),t!==A(this,i)&&(null==(e=A(this,n))||e.call(this),D(this,f,m).call(this,t),D(this,f,g).call(this),D(this,f,S).call(this))}refresh(){D(this,f,S).call(this)}connectedCallback(){var i;N(this,l,!0);const n=A(this,t);if(D(this,f,$).call(this),(n.className||n.tagName||"").split(" ").forEach(t=>t&&this.classList.add(t)),D(this,f,k).call(this),n.attributeMap&&P.isObject(this.$data)){D(this,f,g).call(this);for(const[t,e]of n.attributeMap){const s=e.name;if(this.hasAttribute(t)){const i=this.getAttribute(t),a=D(this,f,M).call(this,i,e.default,e.type);this.$data[s]=a}else"default"in e&&void 0===this.$data[s]&&(this.$data[s]=e.default,"boolean"===e.type&&!0===e.default&&this.setAttribute(t,""))}}D(this,f,b).call(this),A(this,s)&&!A(this,e)&&N(this,e,_.createRender(A(this,s),A(this,a),this)),A(this,u)&&(N(this,u,!1),D(this,f,S).call(this)),this.mounted(),null==(i=this.onInit)||i.call(this)}disconnectedCallback(){var e,s;N(this,l,!1);const i=A(this,t);if(!(null==(e=i.shadowDOM)?void 0:e.use)&&i.styles){const t=`solely-style-${i.tagName}`,e=A(y,p).get(t)||0;e<=1?(null==(s=document.head.querySelector(`#${t}`))||s.remove(),A(y,p).delete(t)):A(y,p).set(t,e-1)}this.unmounted()}attributeChangedCallback(e,s,i){var a;if(s===i||!P.isObject(this.$data))return;const n=null==(a=A(this,t).attributeMap)?void 0:a.get(e);if(!n)return;const o=n.name,r=this.$data[o],c=D(this,f,M).call(this,i,n.default??r,n.type);this.$data[o]=c,N(this,h,!0),this.attributeChanged(e,r,c)}emit(t,e,s){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e,...s}))}emitNative(t,e){this.dispatchEvent(new Event(t,{bubbles:!0,composed:!0,...e}))}warn(t,e){if(q.IS_DEV&&t){const t=this.tagName.toLowerCase();console.warn(`[${t}] ${e}`)}}error(t,e){if(q.IS_DEV&&t){const t=this.tagName.toLowerCase();console.error(`[${t}] ${e}`)}}onInit(){}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}attributeChanged(t,e,s){}beforeAttributesUpdate(){}afterAttributesUpdate(){}};t=new WeakMap,e=new WeakMap,s=new WeakMap,i=new WeakMap,a=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakMap,h=new WeakMap,c=new WeakMap,l=new WeakMap,u=new WeakMap,d=new WeakMap,p=new WeakMap,f=new WeakSet,b=function(){const t=Object.getOwnPropertyNames(this),e=["#","_"],s=new Set(["$data","$refs","constructor","onInit","created","mounted","beforeUpdate","updated","unmounted","attributeChanged","beforeAttributesUpdate","afterAttributesUpdate","emit","refresh"]),i=new Map;let a=Object.getPrototypeOf(this);for(;a&&a!==HTMLElement.prototype;){const t=Object.getOwnPropertyDescriptors(a);for(const[e,s]of Object.entries(t))s.set&&!i.has(e)&&i.set(e,s);a=Object.getPrototypeOf(a)}for(const n of t){if(s.has(n))continue;if(e.some(t=>n.startsWith(t)))continue;const t=Object.getOwnPropertyDescriptor(this,n);if(!t||!("value"in t))continue;const a=t.value,o=i.get(n);(null==o?void 0:o.set)&&(delete this[n],this[n]=a)}},m=function(e){const{proxy:s,dispose:a}=I.observe(e,e=>{var s;if("set"===e.type){const{key:i,newValue:a}=e,n=A(this,t),o=String(i),r=null==(s=n.propMap)?void 0:s.get(o);(null==r?void 0:r.reflect)&&D(this,f,y).call(this,r,a)}this.emit("dataChange",{...e}),D(this,f,S).call(this)});N(this,i,s),N(this,n,a)},y=function(t,e){const s=U.camelToKebab(t.name);if("boolean"===t.type)e?this.setAttribute(s,""):this.removeAttribute(s);else{const t="object"==typeof e?JSON.stringify(e):String(e);this.setAttribute(s,t)}},v=function(t){t.ir&&N(this,s,t.ir)},w=function(){const e=A(this,t);if(e.attributeMap)for(const[,t]of e.attributeMap){if(!1===t.reactive)continue;const e=Object.getOwnPropertyDescriptor(this.constructor.prototype,t.name);if(!(null==e?void 0:e.get)&&!(null==e?void 0:e.set)){const e=Object.getOwnPropertyDescriptor(this,t.name);e&&"value"in e&&(this.$data[t.name]=e.value,delete this[t.name]),Object.defineProperty(this,t.name,{get:()=>this.$data[t.name],set:e=>{this.$data[t.name]=e},configurable:!0,enumerable:!0})}}},g=function(){A(this,d)||(N(this,d,!0),D(this,f,w).call(this))},M=function(t,e,s){if(null===t)return"boolean"!==s&&e;switch(s){case"boolean":return!0;case"number":{const s=Number(t);return isNaN(s)?e:s}case"object":try{return JSON.parse(t)}catch(i){return console.error(`[Solely] Failed to parse object value: "${t}", using default value.`,i),e}case"array":try{const s=t.replace(/'/g,'"'),i=JSON.parse(s);return Array.isArray(i)?i:e}catch(i){return console.error(`[Solely] Failed to parse array value: "${t}", using default value.`,i),e}default:return t}},S=function(){A(this,l)?!A(this,r)&&A(this,e)&&(N(this,r,!0),queueMicrotask(()=>{N(this,r,!1),D(this,f,O).call(this)})):N(this,u,!0)},O=function(){if(!A(this,o)&&A(this,l)){N(this,o,!0);try{A(this,h)&&this.beforeAttributesUpdate(),this.beforeUpdate(),A(this,e).update(),this.updated(),A(this,h)&&(this.afterAttributesUpdate(),N(this,h,!1))}finally{N(this,o,!1)}}},k=function(){var e;const s=A(this,t);if(!s.styles)return;const i=A(this,a);if(s.sheet&&i instanceof ShadowRoot&&"adoptedStyleSheets"in i){if(!i.adoptedStyleSheets.includes(s.sheet)){const t=Array.from(i.adoptedStyleSheets);t.push(s.sheet),i.adoptedStyleSheets=t}return}const n=i instanceof ShadowRoot?i:document.head,o=`solely-style-${s.tagName}`,r=!(null==(e=s.shadowDOM)?void 0:e.use);if(!n.querySelector(`#${o}`)){const t=document.createElement("style");t.id=o,t.textContent=s.styles,n.appendChild(t)}if(r){const t=A(L,p).get(o)||0;A(L,p).set(o,t+1)}},$=function(){A(this,c)||(N(this,c,!0),this.created())},E(L,p,new Map),(()=>{if(q.IS_DEV&&"undefined"!=typeof customElements){const t=customElements.define,e=new WeakSet;customElements.define=function(s,i,a){if(L.isPrototypeOf(i)&&!e.has(i)){e.add(i);const t=i.prototype,a=["connectedCallback","disconnectedCallback","attributeChangedCallback"];for(const e of a)t[e]!==L.prototype[e]&&console.error(`[${s}] 禁止重写 ${e}(),请使用框架钩子`)}return t.call(this,s,i,a)}}})();let T=L;exports.default=T;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var t,e,s,i,a,o,n,r,h,l,c,u,d,p,
|
|
1
|
+
var t,e,s,i,a,o,n,r,h,l,c,u,d,f,p,b,m,y,v,w,g,M,k,$,O,S,j=Object.defineProperty,C=t=>{throw TypeError(t)},W=(t,e,s)=>e.has(t)||C("Cannot "+s),A=(t,e,s)=>(W(t,e,"read from private field"),s?s.call(t):e.get(t)),N=(t,e,s)=>e.has(t)?C("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),E=(t,e,s,i)=>(W(t,e,"write to private field"),i?i.call(t,s):e.set(t,s),s),P=(t,e,s)=>(W(t,e,"access private method"),s);import{isObject as U}from"../../shared/is-object.js";import{IS_DEV as D}from"../../shared/env.js";import{camelToKebab as L}from"../../shared/case-convert.js";import{observe as q}from"../reactivity/observe.js";import{createRender as x}from"../renderer/renderIR.js";const I=Symbol.for("solely.manifest"),J=class y extends HTMLElement{constructor(f={}){var b,y;super(),N(this,p),((t,e,s)=>{e in t?j(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s})(this,"symbol"!=typeof(y="$refs")?y+"":y,{}),N(this,t),N(this,e),N(this,s),N(this,i),N(this,a),N(this,o),N(this,n,!1),N(this,r,!1),N(this,h,!1),N(this,l,!1),N(this,c,!1),N(this,u,!1),N(this,d,!1);const w=this.constructor;E(this,t,w[I]||{tagName:"base-element"});const g=A(this,t);E(this,a,(null==(b=g.shadowDOM)?void 0:b.use)?this.attachShadow({mode:g.shadowDOM.mode||"open"}):this),P(this,p,m).call(this,f),P(this,p,v).call(this,g),queueMicrotask(()=>P(this,p,S).call(this))}static get observedAttributes(){const t=this[I];return(null==t?void 0:t.attributeMap)?Array.from(t.attributeMap.keys()):[]}get $data(){return A(this,i)}set $data(t){var e;U(t)||(t={}),t!==A(this,i)&&(null==(e=A(this,o))||e.call(this),P(this,p,m).call(this,t),P(this,p,g).call(this),P(this,p,k).call(this))}refresh(){P(this,p,k).call(this)}connectedCallback(){var i;E(this,c,!0);const o=A(this,t);if(P(this,p,S).call(this),(o.className||o.tagName||"").split(" ").forEach(t=>t&&this.classList.add(t)),P(this,p,O).call(this),o.attributeMap&&U(this.$data)){P(this,p,g).call(this);for(const[t,e]of o.attributeMap){const s=e.name;if(this.hasAttribute(t)){const i=this.getAttribute(t),a=P(this,p,M).call(this,i,e.default,e.type);this.$data[s]=a}else"default"in e&&void 0===this.$data[s]&&(this.$data[s]=e.default,"boolean"===e.type&&!0===e.default&&this.setAttribute(t,""))}}P(this,p,b).call(this),A(this,s)&&!A(this,e)&&E(this,e,x(A(this,s),A(this,a),this)),A(this,u)&&(E(this,u,!1),P(this,p,k).call(this)),this.mounted(),null==(i=this.onInit)||i.call(this)}disconnectedCallback(){var e,s;E(this,c,!1);const i=A(this,t);if(!(null==(e=i.shadowDOM)?void 0:e.use)&&i.styles){const t=`solely-style-${i.tagName}`,e=A(y,f).get(t)||0;e<=1?(null==(s=document.head.querySelector(`#${t}`))||s.remove(),A(y,f).delete(t)):A(y,f).set(t,e-1)}this.unmounted()}attributeChangedCallback(e,s,i){var a;if(s===i||!U(this.$data))return;const o=null==(a=A(this,t).attributeMap)?void 0:a.get(e);if(!o)return;const n=o.name,r=this.$data[n],l=P(this,p,M).call(this,i,o.default??r,o.type);this.$data[n]=l,E(this,h,!0),this.attributeChanged(e,r,l)}emit(t,e,s){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e,...s}))}emitNative(t,e){this.dispatchEvent(new Event(t,{bubbles:!0,composed:!0,...e}))}warn(t,e){if(D&&t){const t=this.tagName.toLowerCase();console.warn(`[${t}] ${e}`)}}error(t,e){if(D&&t){const t=this.tagName.toLowerCase();console.error(`[${t}] ${e}`)}}onInit(){}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}attributeChanged(t,e,s){}beforeAttributesUpdate(){}afterAttributesUpdate(){}};t=new WeakMap,e=new WeakMap,s=new WeakMap,i=new WeakMap,a=new WeakMap,o=new WeakMap,n=new WeakMap,r=new WeakMap,h=new WeakMap,l=new WeakMap,c=new WeakMap,u=new WeakMap,d=new WeakMap,f=new WeakMap,p=new WeakSet,b=function(){const t=Object.getOwnPropertyNames(this),e=["#","_"],s=new Set(["$data","$refs","constructor","onInit","created","mounted","beforeUpdate","updated","unmounted","attributeChanged","beforeAttributesUpdate","afterAttributesUpdate","emit","refresh"]),i=new Map;let a=Object.getPrototypeOf(this);for(;a&&a!==HTMLElement.prototype;){const t=Object.getOwnPropertyDescriptors(a);for(const[e,s]of Object.entries(t))s.set&&!i.has(e)&&i.set(e,s);a=Object.getPrototypeOf(a)}for(const o of t){if(s.has(o))continue;if(e.some(t=>o.startsWith(t)))continue;const t=Object.getOwnPropertyDescriptor(this,o);if(!t||!("value"in t))continue;const a=t.value,n=i.get(o);(null==n?void 0:n.set)&&(delete this[o],this[o]=a)}},m=function(e){const{proxy:s,dispose:a}=q(e,e=>{var s;if("set"===e.type){const{key:i,newValue:a}=e,o=A(this,t),n=String(i),r=null==(s=o.propMap)?void 0:s.get(n);(null==r?void 0:r.reflect)&&P(this,p,y).call(this,r,a)}this.emit("dataChange",{...e}),P(this,p,k).call(this)});E(this,i,s),E(this,o,a)},y=function(t,e){const s=L(t.name);if("boolean"===t.type)e?this.setAttribute(s,""):this.removeAttribute(s);else{const t="object"==typeof e?JSON.stringify(e):String(e);this.setAttribute(s,t)}},v=function(t){t.ir&&E(this,s,t.ir)},w=function(){const e=A(this,t);if(e.attributeMap)for(const[,t]of e.attributeMap){if(!1===t.reactive)continue;const e=Object.getOwnPropertyDescriptor(this.constructor.prototype,t.name);if(!(null==e?void 0:e.get)&&!(null==e?void 0:e.set)){const e=Object.getOwnPropertyDescriptor(this,t.name);e&&"value"in e&&(this.$data[t.name]=e.value,delete this[t.name]),Object.defineProperty(this,t.name,{get:()=>this.$data[t.name],set:e=>{this.$data[t.name]=e},configurable:!0,enumerable:!0})}}},g=function(){A(this,d)||(E(this,d,!0),P(this,p,w).call(this))},M=function(t,e,s){if(null===t)return"boolean"!==s&&e;switch(s){case"boolean":return!0;case"number":{const s=Number(t);return isNaN(s)?e:s}case"object":try{return JSON.parse(t)}catch(i){return console.error(`[Solely] Failed to parse object value: "${t}", using default value.`,i),e}case"array":try{const s=t.replace(/'/g,'"'),i=JSON.parse(s);return Array.isArray(i)?i:e}catch(i){return console.error(`[Solely] Failed to parse array value: "${t}", using default value.`,i),e}default:return t}},k=function(){A(this,c)?!A(this,r)&&A(this,e)&&(E(this,r,!0),queueMicrotask(()=>{E(this,r,!1),P(this,p,$).call(this)})):E(this,u,!0)},$=function(){if(!A(this,n)&&A(this,c)){E(this,n,!0);try{A(this,h)&&this.beforeAttributesUpdate(),this.beforeUpdate(),A(this,e).update(),this.updated(),A(this,h)&&(this.afterAttributesUpdate(),E(this,h,!1))}finally{E(this,n,!1)}}},O=function(){var e;const s=A(this,t);if(!s.styles)return;const i=A(this,a);if(s.sheet&&i instanceof ShadowRoot&&"adoptedStyleSheets"in i){if(!i.adoptedStyleSheets.includes(s.sheet)){const t=Array.from(i.adoptedStyleSheets);t.push(s.sheet),i.adoptedStyleSheets=t}return}const o=i instanceof ShadowRoot?i:document.head,n=`solely-style-${s.tagName}`,r=!(null==(e=s.shadowDOM)?void 0:e.use);if(!o.querySelector(`#${n}`)){const t=document.createElement("style");t.id=n,t.textContent=s.styles,o.appendChild(t)}if(r){const t=A(J,f).get(n)||0;A(J,f).set(n,t+1)}},S=function(){A(this,l)||(E(this,l,!0),this.created())},N(J,f,new Map),(()=>{if(D&&"undefined"!=typeof customElements){const t=customElements.define,e=new WeakSet;customElements.define=function(s,i,a){if(J.isPrototypeOf(i)&&!e.has(i)){e.add(i);const t=i.prototype,a=["connectedCallback","disconnectedCallback","attributeChangedCallback"];for(const e of a)t[e]!==J.prototype[e]&&console.error(`[${s}] 禁止重写 ${e}(),请使用框架钩子`)}return t.call(this,s,i,a)}}})();let R=J;export{R as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../shared/env.cjs"),t=require("../../compiler/parser/parser.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../shared/env.cjs"),t=require("../../shared/case-convert.cjs"),r=require("../../compiler/parser/parser.cjs"),n=require("../../compiler/ir/buildIR.cjs"),o=Symbol.for("solely.manifest");exports.CustomElement=s=>{const l=s,a="undefined"!=typeof window&&"undefined"!=typeof customElements;return s=>{const{tagName:i}=l;if(a&&!(s.prototype instanceof HTMLElement)&&s!==HTMLElement)throw new TypeError(`[Solely] CustomElement decorator can only be applied to classes extending HTMLElement.\nReceived: ${s.name||"anonymous class"}`);if(a&&customElements.get(i))return e.IS_DEV&&console.warn(`[Solely] 标签名称 "${i}" 已经被注册,跳过重复定义。`),s[o]=l,s;if("string"!=typeof l.template||l.ir){if(l.template&&!l.ir)if("object"==typeof l.template&&null!==l.template){const t=l.template;"root"===t.t&&Array.isArray(t.fns)&&Array.isArray(t.n)?(l.ir=t,e.IS_DEV&&console.info(`[Solely] Using precompiled IR for <${i}> | Nodes: ${t.n.length} | Fns: ${t.fns.length}`)):console.error(`[Manifest Error] <${i}>: 提供的 template 不是有效的 IRRoot 对象。\n期望: { t: "root", fns: [], n: [] }\n实际: ${JSON.stringify(Object.keys(t))}`)}else console.error(`[Manifest Error] <${i}>: template 类型无效。\n期望: string 或 IRRoot 对象\n实际: ${typeof l.template}`)}else if(l.template.trim())try{const e=r.parseHtml(l.template);l.ir=n.buildIR(e,{source:l.template,filename:i})}catch(p){const t=p instanceof Error?p:new Error(String(p));console.error(`[Compiler Error] <${i}>: 模板编译失败\n错误: ${t.message}\n模板长度: ${l.template.length} 字符`,e.IS_DEV?t.stack:"")}else e.IS_DEV&&console.warn(`[Solely] <${i}>: 模板为空字符串`);if(a&&l.styles&&!l.sheet&&"CSSStyleSheet"in window)try{const e=new CSSStyleSheet;"function"==typeof e.replaceSync&&(e.replaceSync(l.styles),l.sheet=e)}catch{e.IS_DEV&&console.warn(`[Solely] <${i}>: CSSStyleSheet 不可用,将使用 style 标签回退方案`)}if(l.props&&!l.attributeMap){const e=new Map,r=new Map;l.props.forEach(n=>{const o="string"==typeof n?{name:n}:n,s=t.camelToKebab(o.name),l=o.name,a={...o,name:l};e.set(s,a),r.set(l,a)}),l.attributeMap=e,l.propMap=r}class c extends s{}return c[o]=l,a&&customElements.define(i,c),c}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{IS_DEV as e}from"../../shared/env.js";import{
|
|
1
|
+
import{IS_DEV as e}from"../../shared/env.js";import{camelToKebab as t}from"../../shared/case-convert.js";import{parseHtml as o}from"../../compiler/parser/parser.js";import{buildIR as r}from"../../compiler/ir/buildIR.js";const n=Symbol.for("solely.manifest"),s=s=>{const l=s,a="undefined"!=typeof window&&"undefined"!=typeof customElements;return s=>{const{tagName:i}=l;if(a&&!(s.prototype instanceof HTMLElement)&&s!==HTMLElement)throw new TypeError(`[Solely] CustomElement decorator can only be applied to classes extending HTMLElement.\nReceived: ${s.name||"anonymous class"}`);if(a&&customElements.get(i))return e&&console.warn(`[Solely] 标签名称 "${i}" 已经被注册,跳过重复定义。`),s[n]=l,s;if("string"!=typeof l.template||l.ir){if(l.template&&!l.ir)if("object"==typeof l.template&&null!==l.template){const t=l.template;"root"===t.t&&Array.isArray(t.fns)&&Array.isArray(t.n)?(l.ir=t,e&&console.info(`[Solely] Using precompiled IR for <${i}> | Nodes: ${t.n.length} | Fns: ${t.fns.length}`)):console.error(`[Manifest Error] <${i}>: 提供的 template 不是有效的 IRRoot 对象。\n期望: { t: "root", fns: [], n: [] }\n实际: ${JSON.stringify(Object.keys(t))}`)}else console.error(`[Manifest Error] <${i}>: template 类型无效。\n期望: string 或 IRRoot 对象\n实际: ${typeof l.template}`)}else if(l.template.trim())try{const e=o(l.template);l.ir=r(e,{source:l.template,filename:i})}catch(m){const t=m instanceof Error?m:new Error(String(m));console.error(`[Compiler Error] <${i}>: 模板编译失败\n错误: ${t.message}\n模板长度: ${l.template.length} 字符`,e?t.stack:"")}else e&&console.warn(`[Solely] <${i}>: 模板为空字符串`);if(a&&l.styles&&!l.sheet&&"CSSStyleSheet"in window)try{const e=new CSSStyleSheet;"function"==typeof e.replaceSync&&(e.replaceSync(l.styles),l.sheet=e)}catch{e&&console.warn(`[Solely] <${i}>: CSSStyleSheet 不可用,将使用 style 标签回退方案`)}if(l.props&&!l.attributeMap){const e=new Map,o=new Map;l.props.forEach(r=>{const n="string"==typeof r?{name:r}:r,s=t(n.name),l=n.name,a={...n,name:l};e.set(s,a),o.set(l,a)}),l.attributeMap=e,l.propMap=o}class p extends s{}return p[n]=l,a&&customElements.define(i,p),p}};export{s as CustomElement};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../shared/is-object.cjs"),t=Symbol("solely.raw"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../shared/is-object.cjs"),t=require("../../shared/env.cjs"),r=Symbol("solely.raw"),n=new WeakMap,i=new WeakMap,o=new WeakMap,s=new WeakMap,a=new WeakMap;function l(e){if(e&&"object"==typeof e){const t=e[r];if(t)return t}return e}const c=e=>!(!e||"object"!=typeof e)&&(e instanceof File||e instanceof Blob||e instanceof FormData||e instanceof ArrayBuffer||e instanceof Response||e instanceof Request);function u(e){return!(!e||!e[r])}const f=(e,t,r=new WeakMap,n=0)=>{if(n>10)return e===t;if(e===t)return!0;if(null==e||null==t)return e===t;if("object"!=typeof e||"object"!=typeof t)return e===t;if(Array.isArray(e)!==Array.isArray(t))return!1;if(r.has(e))return r.get(e)===t;if(r.set(e,t),Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!f(e[i],t[i],r,n+1))return!1;return!0}const i=Reflect.ownKeys(e);if(i.length!==Reflect.ownKeys(t).length)return!1;for(const o of i){if(!Reflect.has(t,o))return!1;const i=e[o],s=t[o];if(!f(i,s,r,n+1))return!1}return!0},p=(e,t)=>{if(0===t.length)return!0;const r=e.map(String).join(".");return t.some(e=>e.test(r))},y=(e,t)=>{const r=(e=>{const t=[];let r=e;for(;r;){const e=o.get(r);if(!e||null==e.key)break;t.unshift(e.key),r=e.parent}return t})(e);let i=e,s=0;for(;i;){const e=n.get(i);if(e){const n=r.slice(r.length-s);e.forEach(e=>{if(!e.active)return;if(!p(n,e.filterRegexes))return;const r={...t,path:n};e.throttle>0?(e.pending.push(r),e.timer||(e.timer=setTimeout(()=>{if(!e.active)return;const t=[...e.pending];e.pending=[],e.timer=null,t.length>0&&(e.onBatch?e.onBatch(t):e.callback(t[t.length-1]))},e.throttle))):e.onBatch?e.onBatch([r]):e.callback(r)})}const a=o.get(i);i=(null==a?void 0:a.parent)||null,s++}};exports.isProxy=u,exports.observe=function(p,d,h={}){const{throttle:g=0,onBatch:b,immediate:m=!1,deepCompare:w=!1}=h,v={callback:d,onBatch:b,throttle:g,filterRegexes:(Array.isArray(h.filter)?h.filter:h.filter?[h.filter]:[]).map(e=>{if(""===e)return/^.*$/;const t=e.replace(/\./g,"\\.").replace(/\*\*/g,"(.+)").replace(/\*/g,"[^.]+").replace(/\[\d+\]/g,"\\[\\d+\\]");return new RegExp(`^${t}$`)}),pending:[],timer:null,active:!0},A=(n,p,d)=>{if(!Object.isExtensible(n))return n;if(c(n))return n;if(n[r])return n;const h=i.get(n);if(h)return h;const g=new Proxy(n,{get(t,n,i){if(n===r)return t;if(Array.isArray(t)){const e=s.get(g);if(e&&Object.prototype.hasOwnProperty.call(e,n))return Reflect.get(e,n,i)}const o=Reflect.get(t,n,i);return"symbol"==typeof n?o:e.isObject(o)&&!c(o)?A(o,g,n):o},set(e,r,n,i){if(!v.active)return t.IS_DEV&&console.warn("[Solely] Cannot set property on a disposed reactive object"),!0;const o=e[r];if(w?f(o,n):o===n)return!0;const s=Reflect.set(e,r,n,i);return 0===(a.get(g)||0)&&(Array.isArray(o)&&Array.isArray(n)?y(g,{type:"array-replace",oldValue:o,newValue:n}):y(g,{type:"set",key:r,newValue:n,oldValue:o})),s},deleteProperty(e,r){if(!v.active)return t.IS_DEV&&console.warn("[Solely] Cannot delete property on a disposed reactive object"),!0;if(!Reflect.has(e,r))return!1;const n=e[r],i=Reflect.deleteProperty(e,r),o=a.get(g)||0;return i&&0===o&&y(g,{type:"delete",key:r,oldValue:n}),i}});return i.set(n,g),o.set(g,{parent:p,key:d}),Array.isArray(n)&&s.set(g,((e,t,r)=>{const n={};return["push","pop","shift","unshift","splice"].forEach(i=>{n[i]=function(...n){if(!t)return;const o=a.get(t)||0;a.set(t,o+1);const s=e[i].apply(e,n);if(a.set(t,o),"push"===i)r(t,{type:"array-push",index:e.length-n.length,values:n});else if("unshift"===i)r(t,{type:"array-push",index:0,values:n});else if("pop"===i)r(t,{type:"array-splice",index:e.length,deleteCount:1,insert:[]});else if("shift"===i)r(t,{type:"array-splice",index:0,deleteCount:1,insert:[]});else if("splice"===i){const[e,i,...o]=n;r(t,{type:"array-splice",index:e,deleteCount:i,insert:o})}return s}}),["sort","reverse","fill","copyWithin"].forEach(i=>{n[i]=function(...n){if(!t)return;const o=a.get(t)||0;a.set(t,o+1);const s=e[i].apply(e,n);return a.set(t,o),r(t,{type:"array-reset",method:i}),s}}),["indexOf","lastIndexOf","includes"].forEach(t=>{n[t]=function(r,...n){let i=e[t].apply(e,[r,...n]);return-1!==i&&!1!==i||!u(r)||(i=e[t].apply(e,[l(r),...n])),i}}),n})(n,g,y)),g},k=A(p,null,null);let x=n.get(k);if(x||(x=new Set,n.set(k,x)),x.add(v),m){const t=(r,n,i=new WeakSet)=>{e.isObject(r)&&!i.has(r)&&(i.add(r),Reflect.ownKeys(r).forEach(o=>{const s=r[o];e.isObject(s)&&i.has(s)||(y(n,{type:"set",key:o,newValue:s,oldValue:void 0}),e.isObject(s)&&t(s,A(s,n,o),i))}))};t(p,k)}return{proxy:k,unobserve:()=>{v.active=!1,v.pending=[],v.timer&&(clearTimeout(v.timer),v.timer=null);const e=n.get(k);e&&e.delete(v)},resume:()=>{if(v.active)return;v.active=!0;let e=n.get(k);e||(e=new Set,n.set(k,e)),e.has(v)||e.add(v)},dispose:()=>{v.active=!1,v.pending=[],v.timer&&(clearTimeout(v.timer),v.timer=null);const e=n.get(k);e&&e.delete(v),v.callback=()=>{},v.onBatch=void 0}}},exports.toRaw=l;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isObject as e}from"../../shared/is-object.js";const
|
|
1
|
+
import{isObject as e}from"../../shared/is-object.js";import{IS_DEV as t}from"../../shared/env.js";const r=Symbol("solely.raw"),n=new WeakMap,i=new WeakMap,o=new WeakMap,a=new WeakMap,s=new WeakMap;function l(e){if(e&&"object"==typeof e){const t=e[r];if(t)return t}return e}const c=e=>!(!e||"object"!=typeof e)&&(e instanceof File||e instanceof Blob||e instanceof FormData||e instanceof ArrayBuffer||e instanceof Response||e instanceof Request);function f(e){return!(!e||!e[r])}const u=(e,t,r=new WeakMap,n=0)=>{if(n>10)return e===t;if(e===t)return!0;if(null==e||null==t)return e===t;if("object"!=typeof e||"object"!=typeof t)return e===t;if(Array.isArray(e)!==Array.isArray(t))return!1;if(r.has(e))return r.get(e)===t;if(r.set(e,t),Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!u(e[i],t[i],r,n+1))return!1;return!0}const i=Reflect.ownKeys(e);if(i.length!==Reflect.ownKeys(t).length)return!1;for(const o of i){if(!Reflect.has(t,o))return!1;const i=e[o],a=t[o];if(!u(i,a,r,n+1))return!1}return!0},p=(e,t)=>{if(0===t.length)return!0;const r=e.map(String).join(".");return t.some(e=>e.test(r))},y=(e,t)=>{const r=(e=>{const t=[];let r=e;for(;r;){const e=o.get(r);if(!e||null==e.key)break;t.unshift(e.key),r=e.parent}return t})(e);let i=e,a=0;for(;i;){const e=n.get(i);if(e){const n=r.slice(r.length-a);e.forEach(e=>{if(!e.active)return;if(!p(n,e.filterRegexes))return;const r={...t,path:n};e.throttle>0?(e.pending.push(r),e.timer||(e.timer=setTimeout(()=>{if(!e.active)return;const t=[...e.pending];e.pending=[],e.timer=null,t.length>0&&(e.onBatch?e.onBatch(t):e.callback(t[t.length-1]))},e.throttle))):e.onBatch?e.onBatch([r]):e.callback(r)})}const s=o.get(i);i=(null==s?void 0:s.parent)||null,a++}};function h(p,h,d={}){const{throttle:g=0,onBatch:m,immediate:w=!1,deepCompare:b=!1}=d,v={callback:h,onBatch:m,throttle:g,filterRegexes:(Array.isArray(d.filter)?d.filter:d.filter?[d.filter]:[]).map(e=>{if(""===e)return/^.*$/;const t=e.replace(/\./g,"\\.").replace(/\*\*/g,"(.+)").replace(/\*/g,"[^.]+").replace(/\[\d+\]/g,"\\[\\d+\\]");return new RegExp(`^${t}$`)}),pending:[],timer:null,active:!0},A=(n,p,h)=>{if(!Object.isExtensible(n))return n;if(c(n))return n;if(n[r])return n;const d=i.get(n);if(d)return d;const g=new Proxy(n,{get(t,n,i){if(n===r)return t;if(Array.isArray(t)){const e=a.get(g);if(e&&Object.prototype.hasOwnProperty.call(e,n))return Reflect.get(e,n,i)}const o=Reflect.get(t,n,i);return"symbol"==typeof n?o:e(o)&&!c(o)?A(o,g,n):o},set(e,r,n,i){if(!v.active)return t&&console.warn("[Solely] Cannot set property on a disposed reactive object"),!0;const o=e[r];if(b?u(o,n):o===n)return!0;const a=Reflect.set(e,r,n,i);return 0===(s.get(g)||0)&&(Array.isArray(o)&&Array.isArray(n)?y(g,{type:"array-replace",oldValue:o,newValue:n}):y(g,{type:"set",key:r,newValue:n,oldValue:o})),a},deleteProperty(e,r){if(!v.active)return t&&console.warn("[Solely] Cannot delete property on a disposed reactive object"),!0;if(!Reflect.has(e,r))return!1;const n=e[r],i=Reflect.deleteProperty(e,r),o=s.get(g)||0;return i&&0===o&&y(g,{type:"delete",key:r,oldValue:n}),i}});return i.set(n,g),o.set(g,{parent:p,key:h}),Array.isArray(n)&&a.set(g,((e,t,r)=>{const n={};return["push","pop","shift","unshift","splice"].forEach(i=>{n[i]=function(...n){if(!t)return;const o=s.get(t)||0;s.set(t,o+1);const a=e[i].apply(e,n);if(s.set(t,o),"push"===i)r(t,{type:"array-push",index:e.length-n.length,values:n});else if("unshift"===i)r(t,{type:"array-push",index:0,values:n});else if("pop"===i)r(t,{type:"array-splice",index:e.length,deleteCount:1,insert:[]});else if("shift"===i)r(t,{type:"array-splice",index:0,deleteCount:1,insert:[]});else if("splice"===i){const[e,i,...o]=n;r(t,{type:"array-splice",index:e,deleteCount:i,insert:o})}return a}}),["sort","reverse","fill","copyWithin"].forEach(i=>{n[i]=function(...n){if(!t)return;const o=s.get(t)||0;s.set(t,o+1);const a=e[i].apply(e,n);return s.set(t,o),r(t,{type:"array-reset",method:i}),a}}),["indexOf","lastIndexOf","includes"].forEach(t=>{n[t]=function(r,...n){let i=e[t].apply(e,[r,...n]);return-1!==i&&!1!==i||!f(r)||(i=e[t].apply(e,[l(r),...n])),i}}),n})(n,g,y)),g},k=A(p,null,null);let x=n.get(k);if(x||(x=new Set,n.set(k,x)),x.add(v),w){const t=(r,n,i=new WeakSet)=>{e(r)&&!i.has(r)&&(i.add(r),Reflect.ownKeys(r).forEach(o=>{const a=r[o];e(a)&&i.has(a)||(y(n,{type:"set",key:o,newValue:a,oldValue:void 0}),e(a)&&t(a,A(a,n,o),i))}))};t(p,k)}return{proxy:k,unobserve:()=>{v.active=!1,v.pending=[],v.timer&&(clearTimeout(v.timer),v.timer=null);const e=n.get(k);e&&e.delete(v)},resume:()=>{if(v.active)return;v.active=!0;let e=n.get(k);e||(e=new Set,n.set(k,e)),e.has(v)||e.add(v)},dispose:()=>{v.active=!1,v.pending=[],v.timer&&(clearTimeout(v.timer),v.timer=null);const e=n.get(k);e&&e.delete(v),v.callback=()=>{},v.onBatch=void 0}}}export{f as isProxy,h as observe,l as toRaw};
|