lituix 0.1.2 → 0.1.4
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/components.json +2 -2
- package/dist/components/lui-form.d.ts +6 -0
- package/dist/components/lui-form.d.ts.map +1 -1
- package/dist/components/lui-pagination.d.ts +1 -0
- package/dist/components/lui-pagination.d.ts.map +1 -1
- package/dist/index.browser.js +17 -14
- package/dist/index.browser.js.map +3 -3
- package/dist/index.cjs +17 -14
- package/dist/index.cjs.map +3 -3
- package/dist/index.mjs +17 -14
- package/dist/index.mjs.map +3 -3
- package/llm.txt +266 -266
- package/llms-full.txt +444 -444
- package/llms.txt +70 -70
- package/package.json +1 -1
- package/recipes.json +111 -111
package/dist/index.cjs
CHANGED
|
@@ -3306,7 +3306,7 @@
|
|
|
3306
3306
|
padding: 0 38px 0 14px;
|
|
3307
3307
|
font-size: var(--lui-font-size);
|
|
3308
3308
|
}
|
|
3309
|
-
`],a([(0,ie.property)({reflect:!0})],me.prototype,"value",2),a([(0,ie.property)({attribute:!1})],me.prototype,"source",2),a([(0,ie.property)({reflect:!0,attribute:"label-key"})],me.prototype,"labelKey",2),a([(0,ie.property)({reflect:!0,attribute:"value-key"})],me.prototype,"valueKey",2),a([(0,ie.property)({reflect:!0,attribute:"disabled-key"})],me.prototype,"disabledKey",2),a([(0,ie.property)({reflect:!0,attribute:"group-key"})],me.prototype,"groupKey",2),a([(0,ie.property)({attribute:!1})],me.prototype,"renderOption",2),a([(0,ie.property)({attribute:!1})],me.prototype,"renderTag",2),a([(0,ie.property)({type:Boolean,attribute:"virtualized",reflect:!0})],me.prototype,"virtualized",2),a([(0,ie.property)({type:Number,attribute:"virtual-threshold"})],me.prototype,"virtualThreshold",2),a([(0,ie.property)({reflect:!0})],me.prototype,"placeholder",2),a([(0,ie.property)({type:Boolean,reflect:!0})],me.prototype,"disabled",2),a([(0,ie.property)({type:Boolean,reflect:!0})],me.prototype,"noborder",2),a([(0,ie.property)({type:Boolean,reflect:!0})],me.prototype,"multiple",2),a([(0,ie.property)({type:Boolean,reflect:!0})],me.prototype,"searchable",2),a([(0,ie.property)({type:Boolean,reflect:!0})],me.prototype,"clearable",2),a([(0,ie.property)({reflect:!0,attribute:"search-placeholder"})],me.prototype,"searchPlaceholder",2),a([(0,ie.property)({reflect:!0,attribute:"empty-text"})],me.prototype,"emptyText",2),a([(0,ie.property)({type:Boolean,reflect:!0})],me.prototype,"open",2),a([(0,ie.property)({reflect:!0})],me.prototype,"placement",2),a([(0,ie.property)({reflect:!0})],me.prototype,"size",2),a([(0,ie.property)({type:Boolean,attribute:"close-on-select"})],me.prototype,"closeOnSelect",2),a([(0,ie.property)({reflect:!0,attribute:"multiple-display"})],me.prototype,"multipleDisplay",2),a([(0,ie.property)()],me.prototype,"locale",2),a([(0,ie.property)({attribute:!1})],me.prototype,"translations",2),a([(0,ie.property)({attribute:"max-tag-count",converter:{fromAttribute(e){if(e==null||e==="")return;if(e==="responsive"||e==="auto")return e;let t=Number(e);return Number.isFinite(t)?t:void 0},toAttribute(e){return e==null?null:String(e)}}})],me.prototype,"maxTagCount",2),a([(0,ie.property)({attribute:!1})],me.prototype,"values",2),a([(0,ie.state)()],me.prototype,"_displayLabel",2),a([(0,ie.state)()],me.prototype,"_currentOptionValue",2),a([(0,ie.state)()],me.prototype,"_searchKeyword",2),a([(0,ie.state)()],me.prototype,"_responsiveMaxTagCount",2),a([(0,ie.query)('[part~="trigger"]')],me.prototype,"_triggerNode",2),a([(0,ie.query)('[part="value-wrap"]')],me.prototype,"_valueWrapNode",2),a([(0,ie.query)('[part~="panel"]')],me.prototype,"_panelNode",2),a([(0,ie.query)('[part="search-input"]')],me.prototype,"_searchInputNode",2),me=a([(0,ie.customElement)("lui-select")],me);var Ye=class extends xt.LitElement{constructor(){super(...arguments);this.current=1;this.total=0;this.pageSize=10;this.maxVisible=7;this.size="md";this.showSummary=!1;this.showTotal=!1;this.showJumper=!1;this.showSizeChanger=!1;this.showFirstLast=!1;this.hideOnSinglePage=!1;this.simple=!1;this.compact=!1;this.responsive=!1;this.pageSizeOptions=[10,20,50,100];this.selectProps={};this._jumperValue="";this._responsiveMode="normal";this._layoutFrame=0;this._indicatorFrame=0;this._explicitAttrs=new Set;this._onJumperInput=e=>{e.stopPropagation(),this._jumperValue=e.target.value};this._onPageSizeChange=e=>{e.stopPropagation(),this._setPageSize(Number(e.detail?.value))};this._commitJumper=()=>{let e=Number(this._jumperValue);Number.isFinite(e)&&(this._setPage(e,"jumper"),this._jumperValue="")};this._onJumperKeydown=e=>{e.key==="Enter"&&(e.preventDefault(),this._commitJumper())}}willUpdate(e){let t=N(this,"pagination");this._explicitAttrs.size||(this._explicitAttrs=new Set(this.getAttributeNames())),!this._explicitAttrs.has("size")&&typeof t.size=="string"&&this.size!==t.size&&(this.size=t.size),!this._explicitAttrs.has("compact")&&typeof t.compact=="boolean"&&this.compact!==t.compact&&(this.compact=t.compact)}updated(e){let t=N(this,"pagination");se(this._sizeSelect,{...t.selectProps??{},...this.selectProps??{}}),this.parentElement&&this.parentElement!==this._observedParent&&(this._observedParent&&this._resizeObserver?.unobserve(this._observedParent),this._observedParent=this.parentElement,this._resizeObserver?.observe(this.parentElement)),(e.has("responsive")||e.has("size")||e.has("showTotal")||e.has("showSummary")||e.has("showJumper")||e.has("showSizeChanger")||e.has("showFirstLast")||e.has("simple")||e.has("compact")||e.has("current")||e.has("total")||e.has("pageSize")||e.has("maxVisible"))&&this._scheduleResponsiveLayout(),this._schedulePageIndicatorLayout()}connectedCallback(){super.connectedCallback(),this._explicitAttrs=new Set(this.getAttributeNames()),this._disposeLocaleChange=xe(()=>this.requestUpdate()),this._resizeObserver=new ResizeObserver(()=>this._scheduleResponsiveLayout())}firstUpdated(){this._resizeObserver?.observe(this),this.parentElement&&(this._observedParent=this.parentElement,this._resizeObserver?.observe(this.parentElement)),this._scheduleResponsiveLayout()}disconnectedCallback(){super.disconnectedCallback(),this._disposeLocaleChange?.(),this._resizeObserver?.disconnect(),this._layoutFrame&&cancelAnimationFrame(this._layoutFrame),this._indicatorFrame&&cancelAnimationFrame(this._indicatorFrame)}_t(e,t,r){let n=nt(this,this.locale,this.translations);return ae(ne(n.locale,n.translations),e,t,r)}get _pageSize(){let e=Number(this.pageSize);return Number.isFinite(e)&&e>0?Math.floor(e):10}get _pageCount(){let e=Number(this.total);return Math.max(1,Math.ceil((Number.isFinite(e)?e:0)/this._pageSize))}get _current(){let e=Number(this.current);return Math.min(this._pageCount,Math.max(1,Number.isFinite(e)?Math.floor(e):1))}_scheduleResponsiveLayout(){this._layoutFrame&&cancelAnimationFrame(this._layoutFrame),this._indicatorFrame&&cancelAnimationFrame(this._indicatorFrame),this._layoutFrame=requestAnimationFrame(()=>{this._layoutFrame=0,this._updateResponsiveMode(),this._schedulePageIndicatorLayout()})}_schedulePageIndicatorLayout(){this._indicatorFrame&&cancelAnimationFrame(this._indicatorFrame),this._indicatorFrame=requestAnimationFrame(()=>{this._indicatorFrame=0,this._updatePageIndicator()})}_updatePageIndicator(){let e=this._pagerNode;if(!e||this._effectiveSimple){e?.style.setProperty("--lui-pagination-indicator-opacity","0");return}let t=e.querySelector(`button.page[data-page="${this._current}"]`);if(!t){e.style.setProperty("--lui-pagination-indicator-opacity","0");return}let r=e.getBoundingClientRect(),n=t.getBoundingClientRect();e.style.setProperty("--lui-pagination-indicator-x",`${n.left-r.left+e.scrollLeft}px`),e.style.setProperty("--lui-pagination-indicator-y",`${n.top-r.top+e.scrollTop}px`),e.style.setProperty("--lui-pagination-indicator-width",`${n.width}px`),e.style.setProperty("--lui-pagination-indicator-height",`${n.height}px`),e.style.setProperty("--lui-pagination-indicator-opacity","1")}_getResponsiveAvailableWidth(){let e=Math.floor(this.clientWidth||this.getBoundingClientRect().width||0);if(e>0)return e;let t=this.parentElement;return t?Math.floor(t.clientWidth||t.getBoundingClientRect().width||0):0}_updateResponsiveMode(){if(!this.responsive){this._responsiveMode!=="normal"&&(this._responsiveMode="normal"),this.dataset.responsiveMode="normal";return}let e=Math.floor(this._getResponsiveAvailableWidth()),t=e>0&&e<360?"simple":e>0&&e<860?"compact":"normal";this.dataset.responsiveMode=t,t!==this._responsiveMode&&(this._responsiveMode=t)}get _effectiveSimple(){return this.simple||this.responsive&&this._responsiveMode==="simple"}get _effectiveMaxVisible(){return this.responsive?this._responsiveMode==="simple"?1:this._responsiveMode==="compact"?Math.min(this.maxVisible||5,5):this.maxVisible:this.maxVisible}get _showAuxiliaryControls(){return!this.responsive||this._responsiveMode==="normal"}get _showCompactSizeChanger(){return!this.responsive||this._responsiveMode==="normal"}get _normalizedPageSizeOptions(){let e=new Set,t=r=>{let n=Number(r);Number.isFinite(n)&&n>0&&e.add(Math.floor(n))};return this.pageSizeOptions.forEach(t),t(this._pageSize),[...e].sort((r,n)=>r-n)}_emitChange(e,t){this.dispatchEvent(new CustomEvent("change",{detail:{page:e,current:e,pageSize:this._pageSize,total:Number.isFinite(Number(this.total))?Number(this.total):0,pageCount:this._pageCount,action:t},bubbles:!0,composed:!0}))}_setPage(e,t){let r=Math.min(this._pageCount,Math.max(1,e));r!==this._current&&(this.current=r,this._emitChange(r,t))}_setPageSize(e){if(!Number.isFinite(e))return;let t=Math.max(1,Math.floor(e));if(t===this.pageSize)return;let r=(this._current-1)*this._pageSize;this.pageSize=t;let n=Math.floor(r/t)+1;this.current=Math.min(Math.max(1,n),Math.max(1,Math.ceil(this.total/t))),this._emitChange(this.current,"page-size")}_buildPages(e=this.maxVisible){let t=this._pageCount,r=this._current,n=Math.max(5,e||7);if(t<=n)return Array.from({length:t},(f,x)=>x+1);let s=[1],d=n-2,h=Math.max(2,r-Math.floor(d/2)),p=h+d-1;p>=t&&(p=t-1,h=p-d+1),h>2&&s.push("ellipsis");for(let f=h;f<=p;f+=1)s.push(f);return p<t-1&&s.push("ellipsis"),s.push(t),s}_renderPager(){let e=this._current,t=this._pageCount,r=this._effectiveSimple,n=this.showFirstLast&&this._showAuxiliaryControls&&!r;return xt.html`
|
|
3309
|
+
`],a([(0,ie.property)({reflect:!0})],me.prototype,"value",2),a([(0,ie.property)({attribute:!1})],me.prototype,"source",2),a([(0,ie.property)({reflect:!0,attribute:"label-key"})],me.prototype,"labelKey",2),a([(0,ie.property)({reflect:!0,attribute:"value-key"})],me.prototype,"valueKey",2),a([(0,ie.property)({reflect:!0,attribute:"disabled-key"})],me.prototype,"disabledKey",2),a([(0,ie.property)({reflect:!0,attribute:"group-key"})],me.prototype,"groupKey",2),a([(0,ie.property)({attribute:!1})],me.prototype,"renderOption",2),a([(0,ie.property)({attribute:!1})],me.prototype,"renderTag",2),a([(0,ie.property)({type:Boolean,attribute:"virtualized",reflect:!0})],me.prototype,"virtualized",2),a([(0,ie.property)({type:Number,attribute:"virtual-threshold"})],me.prototype,"virtualThreshold",2),a([(0,ie.property)({reflect:!0})],me.prototype,"placeholder",2),a([(0,ie.property)({type:Boolean,reflect:!0})],me.prototype,"disabled",2),a([(0,ie.property)({type:Boolean,reflect:!0})],me.prototype,"noborder",2),a([(0,ie.property)({type:Boolean,reflect:!0})],me.prototype,"multiple",2),a([(0,ie.property)({type:Boolean,reflect:!0})],me.prototype,"searchable",2),a([(0,ie.property)({type:Boolean,reflect:!0})],me.prototype,"clearable",2),a([(0,ie.property)({reflect:!0,attribute:"search-placeholder"})],me.prototype,"searchPlaceholder",2),a([(0,ie.property)({reflect:!0,attribute:"empty-text"})],me.prototype,"emptyText",2),a([(0,ie.property)({type:Boolean,reflect:!0})],me.prototype,"open",2),a([(0,ie.property)({reflect:!0})],me.prototype,"placement",2),a([(0,ie.property)({reflect:!0})],me.prototype,"size",2),a([(0,ie.property)({type:Boolean,attribute:"close-on-select"})],me.prototype,"closeOnSelect",2),a([(0,ie.property)({reflect:!0,attribute:"multiple-display"})],me.prototype,"multipleDisplay",2),a([(0,ie.property)()],me.prototype,"locale",2),a([(0,ie.property)({attribute:!1})],me.prototype,"translations",2),a([(0,ie.property)({attribute:"max-tag-count",converter:{fromAttribute(e){if(e==null||e==="")return;if(e==="responsive"||e==="auto")return e;let t=Number(e);return Number.isFinite(t)?t:void 0},toAttribute(e){return e==null?null:String(e)}}})],me.prototype,"maxTagCount",2),a([(0,ie.property)({attribute:!1})],me.prototype,"values",2),a([(0,ie.state)()],me.prototype,"_displayLabel",2),a([(0,ie.state)()],me.prototype,"_currentOptionValue",2),a([(0,ie.state)()],me.prototype,"_searchKeyword",2),a([(0,ie.state)()],me.prototype,"_responsiveMaxTagCount",2),a([(0,ie.query)('[part~="trigger"]')],me.prototype,"_triggerNode",2),a([(0,ie.query)('[part="value-wrap"]')],me.prototype,"_valueWrapNode",2),a([(0,ie.query)('[part~="panel"]')],me.prototype,"_panelNode",2),a([(0,ie.query)('[part="search-input"]')],me.prototype,"_searchInputNode",2),me=a([(0,ie.customElement)("lui-select")],me);var Ye=class extends xt.LitElement{constructor(){super(...arguments);this.current=1;this.total=0;this.pageSize=10;this.maxVisible=7;this.size="md";this.showSummary=!1;this.showTotal=!1;this.showJumper=!1;this.showSizeChanger=!1;this.showFirstLast=!1;this.hideOnSinglePage=!1;this.simple=!1;this.compact=!1;this.responsive=!1;this.pageSizeOptions=[10,20,50,100];this.selectProps={};this._jumperValue="";this._responsiveMode="normal";this._layoutFrame=0;this._indicatorFrame=0;this._indicatorSettled=!1;this._explicitAttrs=new Set;this._onJumperInput=e=>{e.stopPropagation(),this._jumperValue=e.target.value};this._onPageSizeChange=e=>{e.stopPropagation(),this._setPageSize(Number(e.detail?.value))};this._commitJumper=()=>{let e=Number(this._jumperValue);Number.isFinite(e)&&(this._setPage(e,"jumper"),this._jumperValue="")};this._onJumperKeydown=e=>{e.key==="Enter"&&(e.preventDefault(),this._commitJumper())}}willUpdate(e){let t=N(this,"pagination");this._explicitAttrs.size||(this._explicitAttrs=new Set(this.getAttributeNames())),!this._explicitAttrs.has("size")&&typeof t.size=="string"&&this.size!==t.size&&(this.size=t.size),!this._explicitAttrs.has("compact")&&typeof t.compact=="boolean"&&this.compact!==t.compact&&(this.compact=t.compact)}updated(e){let t=N(this,"pagination");se(this._sizeSelect,{...t.selectProps??{},...this.selectProps??{}}),this.parentElement&&this.parentElement!==this._observedParent&&(this._observedParent&&this._resizeObserver?.unobserve(this._observedParent),this._observedParent=this.parentElement,this._resizeObserver?.observe(this.parentElement)),(e.has("responsive")||e.has("size")||e.has("showTotal")||e.has("showSummary")||e.has("showJumper")||e.has("showSizeChanger")||e.has("showFirstLast")||e.has("simple")||e.has("compact")||e.has("current")||e.has("total")||e.has("pageSize")||e.has("maxVisible"))&&this._scheduleResponsiveLayout(),this._schedulePageIndicatorLayout()}connectedCallback(){super.connectedCallback(),this._explicitAttrs=new Set(this.getAttributeNames()),this._disposeLocaleChange=xe(()=>this.requestUpdate()),this._resizeObserver=new ResizeObserver(()=>this._scheduleResponsiveLayout())}firstUpdated(){this._resizeObserver?.observe(this),this.parentElement&&(this._observedParent=this.parentElement,this._resizeObserver?.observe(this.parentElement)),this._scheduleResponsiveLayout()}disconnectedCallback(){super.disconnectedCallback(),this._disposeLocaleChange?.(),this._resizeObserver?.disconnect(),this._layoutFrame&&cancelAnimationFrame(this._layoutFrame),this._indicatorFrame&&cancelAnimationFrame(this._indicatorFrame)}_t(e,t,r){let n=nt(this,this.locale,this.translations);return ae(ne(n.locale,n.translations),e,t,r)}get _pageSize(){let e=Number(this.pageSize);return Number.isFinite(e)&&e>0?Math.floor(e):10}get _pageCount(){let e=Number(this.total);return Math.max(1,Math.ceil((Number.isFinite(e)?e:0)/this._pageSize))}get _current(){let e=Number(this.current);return Math.min(this._pageCount,Math.max(1,Number.isFinite(e)?Math.floor(e):1))}_scheduleResponsiveLayout(){this._layoutFrame&&cancelAnimationFrame(this._layoutFrame),this._indicatorFrame&&cancelAnimationFrame(this._indicatorFrame),this._layoutFrame=requestAnimationFrame(()=>{this._layoutFrame=0,this._updateResponsiveMode(),this._schedulePageIndicatorLayout()})}_schedulePageIndicatorLayout(){this._indicatorFrame&&cancelAnimationFrame(this._indicatorFrame),this._indicatorFrame=requestAnimationFrame(()=>{this._indicatorFrame=0,this._updatePageIndicator()})}_updatePageIndicator(){let e=this._pagerNode;if(!e||this._effectiveSimple){e?.style.setProperty("--lui-pagination-indicator-opacity","0"),this._indicatorSettled=!1;return}let t=e.querySelector(`button.page[data-page="${this._current}"]`);if(!t){e.style.setProperty("--lui-pagination-indicator-opacity","0"),this._indicatorSettled=!1;return}let r=e.getBoundingClientRect(),n=t.getBoundingClientRect(),s=!this._indicatorSettled;s&&e.setAttribute("data-indicator-still",""),e.style.setProperty("--lui-pagination-indicator-x",`${n.left-r.left+e.scrollLeft}px`),e.style.setProperty("--lui-pagination-indicator-y",`${n.top-r.top+e.scrollTop}px`),e.style.setProperty("--lui-pagination-indicator-width",`${n.width}px`),e.style.setProperty("--lui-pagination-indicator-height",`${n.height}px`),e.style.setProperty("--lui-pagination-indicator-opacity","1"),s?requestAnimationFrame(()=>{e.removeAttribute("data-indicator-still"),this._indicatorSettled=!0}):this._indicatorSettled=!0}_getResponsiveAvailableWidth(){let e=Math.floor(this.clientWidth||this.getBoundingClientRect().width||0);if(e>0)return e;let t=this.parentElement;return t?Math.floor(t.clientWidth||t.getBoundingClientRect().width||0):0}_updateResponsiveMode(){if(!this.responsive){this._responsiveMode!=="normal"&&(this._responsiveMode="normal"),this.dataset.responsiveMode="normal";return}let e=Math.floor(this._getResponsiveAvailableWidth()),t=e>0&&e<360?"simple":e>0&&e<860?"compact":"normal";this.dataset.responsiveMode=t,t!==this._responsiveMode&&(this._responsiveMode=t,this._indicatorSettled=!1)}get _effectiveSimple(){return this.simple||this.responsive&&this._responsiveMode==="simple"}get _effectiveMaxVisible(){return this.responsive?this._responsiveMode==="simple"?1:this._responsiveMode==="compact"?Math.min(this.maxVisible||5,5):this.maxVisible:this.maxVisible}get _showAuxiliaryControls(){return!this.responsive||this._responsiveMode==="normal"}get _showCompactSizeChanger(){return!this.responsive||this._responsiveMode==="normal"}get _normalizedPageSizeOptions(){let e=new Set,t=r=>{let n=Number(r);Number.isFinite(n)&&n>0&&e.add(Math.floor(n))};return this.pageSizeOptions.forEach(t),t(this._pageSize),[...e].sort((r,n)=>r-n)}_emitChange(e,t){this.dispatchEvent(new CustomEvent("change",{detail:{page:e,current:e,pageSize:this._pageSize,total:Number.isFinite(Number(this.total))?Number(this.total):0,pageCount:this._pageCount,action:t},bubbles:!0,composed:!0}))}_setPage(e,t){let r=Math.min(this._pageCount,Math.max(1,e));r!==this._current&&(this.current=r,this._emitChange(r,t))}_setPageSize(e){if(!Number.isFinite(e))return;let t=Math.max(1,Math.floor(e));if(t===this.pageSize)return;let r=(this._current-1)*this._pageSize;this.pageSize=t;let n=Math.floor(r/t)+1;this.current=Math.min(Math.max(1,n),Math.max(1,Math.ceil(this.total/t))),this._emitChange(this.current,"page-size")}_buildPages(e=this.maxVisible){let t=this._pageCount,r=this._current,n=Math.max(5,e||7);if(t<=n)return Array.from({length:t},(f,x)=>x+1);let s=[1],d=n-2,h=Math.max(2,r-Math.floor(d/2)),p=h+d-1;p>=t&&(p=t-1,h=p-d+1),h>2&&s.push("ellipsis");for(let f=h;f<=p;f+=1)s.push(f);return p<t-1&&s.push("ellipsis"),s.push(t),s}_renderPager(){let e=this._current,t=this._pageCount,r=this._effectiveSimple,n=this.showFirstLast&&this._showAuxiliaryControls&&!r;return xt.html`
|
|
3310
3310
|
<div class="pager" part="pager" aria-label=${this._t("pagination.label","Pagination")}>
|
|
3311
3311
|
<span class="page-indicator" part="page-indicator" aria-hidden="true"></span>
|
|
3312
3312
|
${n?xt.html`
|
|
@@ -3530,6 +3530,9 @@
|
|
|
3530
3530
|
will-change: transform, width, height;
|
|
3531
3531
|
z-index: 0;
|
|
3532
3532
|
}
|
|
3533
|
+
[data-indicator-still] .page-indicator {
|
|
3534
|
+
transition: none;
|
|
3535
|
+
}
|
|
3533
3536
|
.ellipsis {
|
|
3534
3537
|
color: var(--lui-color-fg-subtle);
|
|
3535
3538
|
padding: 0 2px;
|
|
@@ -11401,7 +11404,7 @@
|
|
|
11401
11404
|
--lui-form-item-control-height: var(--lui-control-height-lg, 44px);
|
|
11402
11405
|
--lui-form-item-gap: 6px;
|
|
11403
11406
|
}
|
|
11404
|
-
`],a([(0,Jr.property)()],ar.prototype,"label",2),a([(0,Jr.property)({type:Boolean})],ar.prototype,"required",2),a([(0,Jr.property)()],ar.prototype,"description",2),a([(0,Jr.property)()],ar.prototype,"help",2),a([(0,Jr.property)()],ar.prototype,"extra",2),a([(0,Jr.property)()],ar.prototype,"tooltip",2),a([(0,Jr.property)({attribute:!1})],ar.prototype,"errors",2),a([(0,Jr.property)({type:Boolean,reflect:!0})],ar.prototype,"invalid",2),a([(0,Jr.property)({type:Boolean,attribute:"hidden-label"})],ar.prototype,"hiddenLabel",2),a([(0,Jr.property)({type:Boolean,reflect:!0})],ar.prototype,"inline",2),a([(0,Jr.property)({reflect:!0})],ar.prototype,"size",2),a([(0,Jr.property)({reflect:!0,attribute:"label-placement"})],ar.prototype,"labelPlacement",2),a([(0,Jr.property)({attribute:"label-width"})],ar.prototype,"labelWidth",2),ar=a([(0,Jr.customElement)("lui-form-item")],ar);function md(i,o){if(!i||!o)return;let e=i;for(let[t,r]of Object.entries(o))r!=null&&(t==="style"&&typeof r=="string"?i.setAttribute("style",r):typeof r=="boolean"?r?i.setAttribute(t,""):i.removeAttribute(t):e[t]=r)}var hs=new Map;function Bp(i,o){return hs.set(i,o),()=>{hs.get(i)===o&&hs.delete(i)}}function qp(i){hs.delete(i)}function gd(i){let o={};for(let e of i)e.type==="group"&&e.fields?Object.assign(o,gd(e.fields)):e.type==="array"?o[e.name]=e.defaultValue!==void 0?e.defaultValue:[]:o[e.name]=e.defaultValue!==void 0?e.defaultValue:e.type==="switch"||e.type==="checkbox"?!1:e.type==="checkbox-group"?[]:e.type==="number"||e.type==="slider"?0:(e.type==="date"||e.type==="time"||e.type==="datetime","");return o}function vl(i,o){return o.split(/[.[\]]/).filter(Boolean).reduce((e,t)=>e?.[t],i)}function Sg(i,o){if(!i)return{visible:!0,disabled:!1,required:!1};let e=Array.isArray(i.when)?i.when:[i.when],t=!1;for(let n of e){let s=vl(o,n);if(i.is!==void 0?t=s===i.is:i.isNot!==void 0?t=s!==i.isNot:i.contains!==void 0?t=Array.isArray(s)&&s.includes(i.contains):i.pattern!==void 0?t=new RegExp(i.pattern).test(String(s??"")):t=!!s,t)break}let r=t?i.then??{visible:!0}:i.else??{visible:!1};return{visible:r.visible??!0,disabled:r.disabled??!1,required:r.required??!1}}function $g(i){let e={...i.validators??{}};i.validator&&(e.onSubmit=e.onSubmit??i.validator);let t=r=>{if(r!=null)return(0,xa.isStandardSchemaValidator)(r)?n=>xa.standardSchemaValidators.validate({value:n.value,validationSource:"field"},r)??void 0:r};return e.onChange=t(e.onChange),e.onSubmit=t(e.onSubmit),Object.keys(e).length?e:void 0}function Dn(i,o={}){if(i==null)return[];if(typeof i=="string")return i?[i]:[];if(typeof i=="number"||typeof i=="boolean")return[String(i)];if(i instanceof Error)return i.message?[i.message]:[String(i)];if(Array.isArray(i))return Array.from(new Set(i.flatMap(e=>Dn(e,o))));if(typeof i=="object"){let e=i,t=[];return typeof e.message=="string"&&e.message&&t.push(e.message),"form"in e&&t.push(...Dn(e.form,o)),o.includeFieldErrors&&"fields"in e&&t.push(...Dn(e.fields,o)),Array.from(new Set(t))}return[]}function ya(i){return i==null||i===!1?!1:typeof i=="string"?i.length>0:typeof i=="number"||typeof i=="boolean"||i instanceof Error?!0:Array.isArray(i)?i.some(ya):typeof i=="object"?Object.values(i).some(ya):!1}function Tg(i,o){let e=i.successMessage;return typeof e=="function"?e(o):e??"\u63D0\u4EA4\u6210\u529F"}var ge,Lt=class extends D.LitElement{constructor(){super(...arguments);this.schema=null;this.showActions=!0;this.size="md";this.labelPlacement="top";this.labelWidth="120px";this._currentStep=0;this._isStepPending=!1;this._submitErrorMessages=[];this._submitSuccessMessage="";Hu(this,ge);this._explicitAttrs=new Set;this._collapsedArrayItems=new Set;this._initializedSchema=null}connectedCallback(){super.connectedCallback(),this._explicitAttrs=new Set(this.getAttributeNames()),this._ensureControllerInitialized()}submit(){this._ensureControllerInitialized(),this._submitForm()}_dispatchValidate(e){ye(this,ge)&&this.dispatchEvent(new CustomEvent("validate",{detail:{valid:e,errors:ye(this,ge).api.getAllErrors(),values:this.getValues()},bubbles:!0,composed:!0}))}getValues(){return this._ensureControllerInitialized(),{...ye(this,ge)?.api.state.values??{}}}setValues(e,t={}){if(this._ensureControllerInitialized(),!!ye(this,ge)){for(let[r,n]of Object.entries(e))ye(this,ge).api.setFieldValue(r,n,{dontUpdateMeta:!t.touch});this._emitFormChange("setValues",void 0,void 0,this.getValues())}}getValue(e){return vl(this.getValues(),e)}setValue(e,t,r={}){this._ensureControllerInitialized(),ye(this,ge)&&(ye(this,ge).api.setFieldValue(e,t,{dontUpdateMeta:!r.touch}),this._emitFormChange("setValue",e,t,this.getValues()))}async validate(){if(this._ensureControllerInitialized(),!ye(this,ge)||!this.schema)return!0;this._clearSubmissionFeedback();let e=this.schema.steps?this.schema.steps.flatMap(d=>d.fields):this.schema.fields??[],t=Array.from(new Set(this._collectVisibleFieldNames(e)));this._markFieldsTouched(t);let r=await Promise.all(t.map(d=>ye(this,ge).api.validateField(d,"submit"))),n=await ye(this,ge).api.validate("submit"),s=!r.some(ya)&&!this._hasFieldErrors(t)&&!ya(n)&&this._getFormErrorMessages(ye(this,ge)).length===0;return this._dispatchValidate(s),this.requestUpdate(),s}clearValidate(e){if(this._ensureControllerInitialized(),!ye(this,ge)||!this.schema)return;this._clearSubmissionFeedback();let t=this.schema.steps?this.schema.steps.flatMap(n=>n.fields):this.schema.fields??[],r=e?.length?e:Array.from(new Set(this._collectVisibleFieldNames(t)));for(let n of r)ye(this,ge).api.setFieldMeta(n,s=>({...s,isValidating:!1,isTouched:!1,isBlurred:!1,isValid:!0,errors:[],errorMap:{},errorSourceMap:{}}));this.requestUpdate()}_clearSubmissionFeedback(){(this._submitErrorMessages.length||this._submitSuccessMessage)&&(this._submitErrorMessages=[],this._submitSuccessMessage="")}async _submitForm(){if(!ye(this,ge)||!this.schema)return;if(this._clearSubmissionFeedback(),!await this.validate()){this._scrollToFirstError(),this.requestUpdate();return}await ye(this,ge).api.handleSubmit(),this.requestUpdate()}reset(e){this._ensureControllerInitialized(),this._clearSubmissionFeedback(),ye(this,ge)?.api.reset(e),this._collapsedArrayItems.clear(),this._emitFormChange("reset",void 0,void 0,ye(this,ge)?.api.state.values??{})}_emitFormChange(e,t,r,n=this.getValues()){this.dispatchEvent(new CustomEvent("change",{detail:{reason:e,name:t,value:r,values:n},bubbles:!0,composed:!0}))}_emitFieldChange(e,t,r){let n=this.getValues();this._emitFormChange("field",e.name,t,n)}focusField(e){let r=this._fieldElement(e)?.querySelector("lui-input,lui-textarea,lui-select,lui-input-number,lui-datepicker,lui-color-picker,lui-input-opt,lui-checkbox,lui-switch,lui-radio,button,input,textarea,select");return r?.focus?.(),!!r}scrollToField(e,t={block:"center",behavior:"smooth"}){let r=this._fieldElement(e);return r?.scrollIntoView(t),!!r}_fieldElement(e){return this.renderRoot.querySelector(`[data-field-name="${CSS.escape(e)}"]`)}_findFieldDef(e){let t=e.replace(/\[\d+\]/g,""),r=this.schema?.steps?this.schema.steps.flatMap(s=>s.fields):this.schema?.fields??[],n=s=>{for(let d of s){if(d.name===e||d.name===t||t.endsWith(`.${d.name}`))return d;if(d.fields){let h=n(d.fields);if(h)return h}}};return n(r)}_firstErrorFieldName(){if(!ye(this,ge)||!this.schema)return;let e=this.schema.steps?this.schema.steps.flatMap(r=>r.fields):this.schema.fields??[];return Array.from(new Set(this._collectVisibleFieldNames(e))).find(r=>(ye(this,ge).api.getFieldMeta(r)?.errors?.length??0)>0)}_scrollToFirstError(){let e=this._firstErrorFieldName();e&&requestAnimationFrame(()=>{this.scrollToField(e),this.focusField(e)})}_effectiveSize(e){return e?.size??this.schema?.size??this.size}_effectiveLabelPlacement(e){return e?.labelPlacement??this.schema?.labelPlacement??this.labelPlacement}_normalizedLabelPlacement(e){let t=this._effectiveLabelPlacement(e);return t==="left"||t==="horizontal"?"left":"top"}_effectiveLabelWidth(e){return Ot(e?.labelWidth??this.schema?.labelWidth??this.labelWidth)||"120px"}_effectiveValidateTrigger(e){return e?.validateTrigger??this.schema?.validateTrigger??"change"}_fieldClass(e){return`field ${this._normalizedLabelPlacement(e)}`}_fieldStyle(e){return`--lui-form-label-width:${this._effectiveLabelWidth(e)}`}willUpdate(){this._ensureControllerInitialized();let e=N(this,"form");!this._explicitAttrs.has("size")&&typeof e.size=="string"&&this.size!==e.size&&(this.size=e.size),!this._explicitAttrs.has("label-placement")&&typeof e.labelPlacement=="string"&&this.labelPlacement!==e.labelPlacement&&(this.labelPlacement=e.labelPlacement),!this._explicitAttrs.has("label-width")&&(typeof e.labelWidth=="string"||typeof e.labelWidth=="number")&&this.labelWidth!==e.labelWidth&&(this.labelWidth=e.labelWidth),!this._explicitAttrs.has("show-actions")&&typeof e.showActions=="boolean"&&this.showActions!==e.showActions&&(this.showActions=e.showActions)}updated(e){super.updated(e),e.has("schema")&&this.schema&&(this._currentStep=0,this._clearSubmissionFeedback(),this._initializedSchema!==this.schema&&(this._initForm(),this.requestUpdate()))}_initForm(){if(!this.schema)return;let e=this.schema.steps?this.schema.steps.flatMap(n=>n.fields):this.schema.fields??[],t={...gd(e),...this.schema.defaultValues},r={...this.schema.validators??{}};this.schema.validator&&(r.onSubmit=r.onSubmit??this.schema.validator),Ru(this,ge,new xa.TanStackFormController(this,{defaultValues:t,validators:r,validationLogic:this.schema.validationLogic,onSubmit:async({value:n})=>{this._clearSubmissionFeedback(),this.dispatchEvent(new CustomEvent("submit",{detail:{value:n},bubbles:!0,composed:!0}));try{typeof this.schema.onSubmit=="function"&&await this.schema.onSubmit(n),this._submitSuccessMessage=Tg(this.schema,n)}catch(s){let d=Dn(s);throw this._submitErrorMessages=d.length?d:["\u63D0\u4EA4\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"],this._submitSuccessMessage="",s}},onSubmitInvalid:()=>{this._submitSuccessMessage="",this._dispatchValidate(!1),this._scrollToFirstError()}})),this._initializedSchema=this.schema}_ensureControllerInitialized(){ye(this,ge)&&this._initializedSchema===this.schema||this.schema&&this._initForm()}_isGroupInline(e){return e.length>1&&e.every(t=>t.type!=="textarea"&&t.type!=="array"&&t.type!=="slider"&&t.type!=="date"&&t.type!=="time"&&t.type!=="datetime"&&t.type!=="file")}_getFieldCondition(e){let t=ye(this,ge)?.api?.state?.values??{},r=Sg(e.condition,t);return{visible:!e.hidden&&r.visible,disabled:(this.schema?.disabled??!1)||(e.disabled??!1)||r.disabled,readonly:(this.schema?.readonly??!1)||(e.readonly??!1),required:(e.required??!1)||r.required}}_renderField(e,t,r=!1,n=!1){if(e.type==="group"&&e.fields)return this._renderGroup(e,t,r,n);if(e.type==="array")return this._renderArrayField(e,t,r,n);if(e.type==="button")return this._renderButtonField(e,r);let s=this._getFieldCondition(e);if(!s.visible)return D.nothing;let d={name:e.name},h={...e,required:s.required},p=$g(h);return p&&(d.validators=p),t.field(d,f=>{let x=Dn(f.state.meta.errors||[],{includeFieldErrors:!0}),y=f.state.meta.isTouched||ye(this,ge).api.state.submissionAttempts>0,C=y&&x.length>0,S=ke=>{let Ve=f.state.value;this._clearSubmissionFeedback(),f.handleChange(ke),this._effectiveValidateTrigger(h)==="change"&&f.validate?.("change"),this._emitFieldChange(h,ke,Ve)},E={field:h,value:f.state.value,errors:x,disabled:s.disabled||r,readonly:s.readonly||n,required:!!h.required,touched:y,invalid:x.length>0,formValues:ye(this,ge).api.state.values,fieldApi:f,blur:()=>f.handleBlur(),clearFeedback:()=>this._clearSubmissionFeedback(),handleChange:S,submit:()=>void this._submitForm(),reset:()=>this.reset()},T=this._withProps(h,this._renderControl(h,f,s.disabled||r,s.readonly||n,E)),O=h.hiddenLabel?"":h.label??"",H=D.html`
|
|
11407
|
+
`],a([(0,Jr.property)()],ar.prototype,"label",2),a([(0,Jr.property)({type:Boolean})],ar.prototype,"required",2),a([(0,Jr.property)()],ar.prototype,"description",2),a([(0,Jr.property)()],ar.prototype,"help",2),a([(0,Jr.property)()],ar.prototype,"extra",2),a([(0,Jr.property)()],ar.prototype,"tooltip",2),a([(0,Jr.property)({attribute:!1})],ar.prototype,"errors",2),a([(0,Jr.property)({type:Boolean,reflect:!0})],ar.prototype,"invalid",2),a([(0,Jr.property)({type:Boolean,attribute:"hidden-label"})],ar.prototype,"hiddenLabel",2),a([(0,Jr.property)({type:Boolean,reflect:!0})],ar.prototype,"inline",2),a([(0,Jr.property)({reflect:!0})],ar.prototype,"size",2),a([(0,Jr.property)({reflect:!0,attribute:"label-placement"})],ar.prototype,"labelPlacement",2),a([(0,Jr.property)({attribute:"label-width"})],ar.prototype,"labelWidth",2),ar=a([(0,Jr.customElement)("lui-form-item")],ar);function md(i,o){if(!i||!o)return;let e=i;for(let[t,r]of Object.entries(o))r!=null&&(t==="style"&&typeof r=="string"?i.setAttribute("style",r):typeof r=="boolean"?r?i.setAttribute(t,""):i.removeAttribute(t):e[t]=r)}var hs=new Map;function Bp(i,o){return hs.set(i,o),()=>{hs.get(i)===o&&hs.delete(i)}}function qp(i){hs.delete(i)}function gd(i){let o={};for(let e of i)e.type==="group"&&e.fields?Object.assign(o,gd(e.fields)):e.type==="array"?o[e.name]=e.defaultValue!==void 0?e.defaultValue:[]:o[e.name]=e.defaultValue!==void 0?e.defaultValue:e.type==="switch"||e.type==="checkbox"?!1:e.type==="checkbox-group"?[]:e.type==="number"||e.type==="slider"?0:(e.type==="date"||e.type==="time"||e.type==="datetime","");return o}function vl(i,o){return o.split(/[.[\]]/).filter(Boolean).reduce((e,t)=>e?.[t],i)}function Sg(i,o){if(!i)return{visible:!0,disabled:!1,required:!1};let e=Array.isArray(i.when)?i.when:[i.when],t=!1;for(let n of e){let s=vl(o,n);if(i.is!==void 0?t=s===i.is:i.isNot!==void 0?t=s!==i.isNot:i.contains!==void 0?t=Array.isArray(s)&&s.includes(i.contains):i.pattern!==void 0?t=new RegExp(i.pattern).test(String(s??"")):t=!!s,t)break}let r=t?i.then??{visible:!0}:i.else??{visible:!1};return{visible:r.visible??!0,disabled:r.disabled??!1,required:r.required??!1}}function $g(i){let e={...i.validators??{}};i.validator&&(e.onSubmit=e.onSubmit??i.validator);let t=r=>{if(r!=null)return(0,xa.isStandardSchemaValidator)(r)?n=>xa.standardSchemaValidators.validate({value:n.value,validationSource:"field"},r)??void 0:r};return e.onChange=t(e.onChange),e.onSubmit=t(e.onSubmit),Object.keys(e).length?e:void 0}function Dn(i,o={}){if(i==null)return[];if(typeof i=="string")return i?[i]:[];if(typeof i=="number"||typeof i=="boolean")return[String(i)];if(i instanceof Error)return i.message?[i.message]:[String(i)];if(Array.isArray(i))return Array.from(new Set(i.flatMap(e=>Dn(e,o))));if(typeof i=="object"){let e=i,t=[];return typeof e.message=="string"&&e.message&&t.push(e.message),"form"in e&&t.push(...Dn(e.form,o)),o.includeFieldErrors&&"fields"in e&&t.push(...Dn(e.fields,o)),Array.from(new Set(t))}return[]}function ya(i){return i==null||i===!1?!1:typeof i=="string"?i.length>0:typeof i=="number"||typeof i=="boolean"||i instanceof Error?!0:Array.isArray(i)?i.some(ya):typeof i=="object"?Object.values(i).some(ya):!1}function Tg(i,o){let e=i.successMessage;return typeof e=="function"?e(o):e??"\u63D0\u4EA4\u6210\u529F"}var ge,Lt=class extends D.LitElement{constructor(){super(...arguments);this.schema=null;this.showActions=!0;this.size="md";this.labelPlacement="top";this.labelWidth="120px";this._currentStep=0;this._isStepPending=!1;this._submitErrorMessages=[];this._submitSuccessMessage="";Hu(this,ge);this._explicitAttrs=new Set;this._collapsedArrayItems=new Set;this._initializedSchema=null}connectedCallback(){super.connectedCallback(),this._explicitAttrs=new Set(this.getAttributeNames()),this._ensureControllerInitialized()}submit(){this._ensureControllerInitialized(),this._submitForm()}_dispatchValidate(e){ye(this,ge)&&this.dispatchEvent(new CustomEvent("validate",{detail:{valid:e,errors:ye(this,ge).api.getAllErrors(),values:this.getValues()},bubbles:!0,composed:!0}))}getValues(){return this._ensureControllerInitialized(),{...ye(this,ge)?.api.state.values??{}}}setValues(e,t={}){if(this._ensureControllerInitialized(),!!ye(this,ge)){for(let[r,n]of Object.entries(e))ye(this,ge).api.setFieldValue(r,n,{dontUpdateMeta:!t.touch});this._emitFormChange("setValues",void 0,void 0,this.getValues())}}getValue(e){return vl(this.getValues(),e)}setValue(e,t,r={}){this._ensureControllerInitialized(),ye(this,ge)&&(ye(this,ge).api.setFieldValue(e,t,{dontUpdateMeta:!r.touch}),this._emitFormChange("setValue",e,t,this.getValues()))}async validate(){if(this._ensureControllerInitialized(),!ye(this,ge)||!this.schema)return!0;this._clearSubmissionFeedback();let e=this.schema.steps?this.schema.steps.flatMap(d=>d.fields):this.schema.fields??[],t=Array.from(new Set(this._collectVisibleFieldNames(e)));this._markFieldsTouched(t);let r=await Promise.all(t.map(d=>ye(this,ge).api.validateField(d,"submit"))),n=await ye(this,ge).api.validate("submit"),s=!r.some(ya)&&!this._hasFieldErrors(t)&&!ya(n)&&this._getFormErrorMessages(ye(this,ge)).length===0;return this._dispatchValidate(s),this.requestUpdate(),s}clearValidate(e){if(this._ensureControllerInitialized(),!ye(this,ge)||!this.schema)return;this._clearSubmissionFeedback();let t=this.schema.steps?this.schema.steps.flatMap(n=>n.fields):this.schema.fields??[],r=e?.length?e:Array.from(new Set(this._collectVisibleFieldNames(t)));for(let n of r)ye(this,ge).api.setFieldMeta(n,s=>({...s,isValidating:!1,isTouched:!1,isBlurred:!1,isValid:!0,errors:[],errorMap:{},errorSourceMap:{}}));this.requestUpdate()}_clearSubmissionFeedback(){(this._submitErrorMessages.length||this._submitSuccessMessage)&&(this._submitErrorMessages=[],this._submitSuccessMessage="")}async _submitForm(){if(!ye(this,ge)||!this.schema)return;if(this._clearSubmissionFeedback(),!await this.validate()){this._scrollToFirstError(),this.requestUpdate();return}await ye(this,ge).api.handleSubmit(),this.requestUpdate()}reset(e){this._ensureControllerInitialized(),this._clearSubmissionFeedback(),ye(this,ge)?.api.reset(e),this._collapsedArrayItems.clear(),this._emitFormChange("reset",void 0,void 0,ye(this,ge)?.api.state.values??{})}_emitFormChange(e,t,r,n=this.getValues()){this.dispatchEvent(new CustomEvent("change",{detail:{reason:e,name:t,value:r,values:n},bubbles:!0,composed:!0}))}_emitFieldChange(e,t,r){let n=this.getValues();this._emitFormChange("field",e.name,t,n)}focusField(e){let r=this._fieldElement(e)?.querySelector("lui-input,lui-textarea,lui-select,lui-input-number,lui-datepicker,lui-color-picker,lui-input-opt,lui-checkbox,lui-switch,lui-radio,button,input,textarea,select");return r?.focus?.(),!!r}scrollToField(e,t={block:"center",behavior:"smooth"}){let r=this._fieldElement(e);return r?.scrollIntoView(t),!!r}_fieldElement(e){return this.renderRoot.querySelector(`[data-field-name="${CSS.escape(e)}"]`)}_findFieldDef(e){let t=e.replace(/\[\d+\]/g,""),r=this.schema?.steps?this.schema.steps.flatMap(s=>s.fields):this.schema?.fields??[],n=s=>{for(let d of s){if(d.name===e||d.name===t||t.endsWith(`.${d.name}`))return d;if(d.fields){let h=n(d.fields);if(h)return h}}};return n(r)}_firstErrorFieldName(){if(!ye(this,ge)||!this.schema)return;let e=this.schema.steps?this.schema.steps.flatMap(r=>r.fields):this.schema.fields??[];return Array.from(new Set(this._collectVisibleFieldNames(e))).find(r=>(ye(this,ge).api.getFieldMeta(r)?.errors?.length??0)>0)}_scrollToFirstError(){let e=this._firstErrorFieldName();e&&requestAnimationFrame(()=>{this.scrollToField(e),this.focusField(e)})}_effectiveSize(e){return e?.size??this.schema?.size??this.size}_effectiveLabelPlacement(e){return e?.labelPlacement??this.schema?.labelPlacement??this.labelPlacement}_normalizedLabelPlacement(e){let t=this._effectiveLabelPlacement(e);return t==="left"||t==="horizontal"?"left":"top"}_effectiveLabelWidth(e){return Ot(e?.labelWidth??this.schema?.labelWidth??this.labelWidth)||"120px"}_effectiveValidateTrigger(e){return e?.validateTrigger??this.schema?.validateTrigger??"change"}_fieldClass(e){return`field ${this._normalizedLabelPlacement(e)}`}_fieldStyle(e){return`--lui-form-label-width:${this._effectiveLabelWidth(e)}`}willUpdate(){this._ensureControllerInitialized();let e=N(this,"form");!this._explicitAttrs.has("size")&&typeof e.size=="string"&&this.size!==e.size&&(this.size=e.size),!this._explicitAttrs.has("label-placement")&&typeof e.labelPlacement=="string"&&this.labelPlacement!==e.labelPlacement&&(this.labelPlacement=e.labelPlacement),!this._explicitAttrs.has("label-width")&&(typeof e.labelWidth=="string"||typeof e.labelWidth=="number")&&this.labelWidth!==e.labelWidth&&(this.labelWidth=e.labelWidth),!this._explicitAttrs.has("show-actions")&&typeof e.showActions=="boolean"&&this.showActions!==e.showActions&&(this.showActions=e.showActions)}updated(e){super.updated(e),e.has("schema")&&this.schema&&(this._currentStep=0,this._clearSubmissionFeedback(),this._initializedSchema!==this.schema&&(this._initForm(),this.requestUpdate()))}_initForm(){if(!this.schema)return;let e=this.schema.steps?this.schema.steps.flatMap(n=>n.fields):this.schema.fields??[],t={...gd(e),...this.schema.defaultValues},r={...this.schema.validators??{}};this.schema.validator&&(r.onSubmit=r.onSubmit??this.schema.validator),Ru(this,ge,new xa.TanStackFormController(this,{defaultValues:t,validators:r,validationLogic:this.schema.validationLogic,onSubmit:async({value:n})=>{this._clearSubmissionFeedback(),this.dispatchEvent(new CustomEvent("submit",{detail:{value:n},bubbles:!0,composed:!0}));try{typeof this.schema.onSubmit=="function"&&await this.schema.onSubmit(n),this._submitSuccessMessage=Tg(this.schema,n)}catch(s){let d=Dn(s);throw this._submitErrorMessages=d.length?d:["\u63D0\u4EA4\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"],this._submitSuccessMessage="",s}},onSubmitInvalid:()=>{this._submitSuccessMessage="",this._dispatchValidate(!1),this._scrollToFirstError()}})),this._initializedSchema=this.schema}_ensureControllerInitialized(){ye(this,ge)&&this._initializedSchema===this.schema||this.schema&&this._initForm()}_isGroupInline(e){return e.length>1&&e.every(t=>t.type!=="textarea"&&t.type!=="array"&&t.type!=="slider"&&t.type!=="date"&&t.type!=="time"&&t.type!=="datetime"&&t.type!=="file")}_getFieldCondition(e){let t=ye(this,ge)?.api?.state?.values??{},r=Sg(e.condition,t);return{visible:!e.hidden&&r.visible,disabled:(this.schema?.disabled??!1)||(e.disabled??!1)||r.disabled,readonly:(this.schema?.readonly??!1)||(e.readonly??!1),required:(e.required??!1)||r.required}}_isFieldRenderable(e){return e.type==="group"||e.type==="array"||e.type==="button"?!0:this._getFieldCondition(e).visible}_renderField(e,t,r=!1,n=!1){if(e.type==="group"&&e.fields)return this._renderGroup(e,t,r,n);if(e.type==="array")return this._renderArrayField(e,t,r,n);if(e.type==="button")return this._renderButtonField(e,r);let s=this._getFieldCondition(e);if(!s.visible)return D.nothing;let d={name:e.name},h={...e,required:s.required},p=$g(h);return p&&(d.validators=p),t.field(d,f=>{let x=Dn(f.state.meta.errors||[],{includeFieldErrors:!0}),y=f.state.meta.isTouched||ye(this,ge).api.state.submissionAttempts>0,C=y&&x.length>0,S=ke=>{let Ve=f.state.value;this._clearSubmissionFeedback(),f.handleChange(ke),this._effectiveValidateTrigger(h)==="change"&&f.validate?.("change"),this._emitFieldChange(h,ke,Ve)},E={field:h,value:f.state.value,errors:x,disabled:s.disabled||r,readonly:s.readonly||n,required:!!h.required,touched:y,invalid:x.length>0,formValues:ye(this,ge).api.state.values,fieldApi:f,blur:()=>f.handleBlur(),clearFeedback:()=>this._clearSubmissionFeedback(),handleChange:S,submit:()=>void this._submitForm(),reset:()=>this.reset()},T=this._withProps(h,this._renderControl(h,f,s.disabled||r,s.readonly||n,E)),O=h.hiddenLabel?"":h.label??"",H=D.html`
|
|
11405
11408
|
<lui-form-item
|
|
11406
11409
|
data-field-name=${h.name}
|
|
11407
11410
|
.label=${O}
|
|
@@ -11649,27 +11652,27 @@
|
|
|
11649
11652
|
type=${e.type}
|
|
11650
11653
|
@input=${f}
|
|
11651
11654
|
@blur=${x}
|
|
11652
|
-
></lui-input>`}}_renderFields(e,t){
|
|
11655
|
+
></lui-input>`}}_renderFields(e,t){if(!(!!this.schema?.gutter||!!this.schema?.align||!!this.schema?.justify||!!this.schema?.nowrap||e.some(s=>s.span!=null||s.xs!=null||s.sm!=null||s.md!=null||s.lg!=null||s.xl!=null||s.offset!=null||s.order!=null)))return e.map(s=>this._renderField(s,t));let n=e.filter(s=>this._isFieldRenderable(s));return D.html`
|
|
11653
11656
|
<lui-row
|
|
11654
11657
|
.gutter=${this.schema?.gutter??[12,12]}
|
|
11655
11658
|
.align=${this.schema?.align??"top"}
|
|
11656
11659
|
.justify=${this.schema?.justify??"start"}
|
|
11657
11660
|
.nowrap=${this.schema?.nowrap??!1}
|
|
11658
11661
|
>
|
|
11659
|
-
${
|
|
11660
|
-
.span=${
|
|
11661
|
-
.xs=${
|
|
11662
|
-
.sm=${
|
|
11663
|
-
.md=${
|
|
11664
|
-
.lg=${
|
|
11665
|
-
.xl=${
|
|
11666
|
-
.offset=${
|
|
11667
|
-
.colOrder=${
|
|
11662
|
+
${n.map(s=>D.html`<lui-col
|
|
11663
|
+
.span=${s.span}
|
|
11664
|
+
.xs=${s.xs}
|
|
11665
|
+
.sm=${s.sm}
|
|
11666
|
+
.md=${s.md}
|
|
11667
|
+
.lg=${s.lg}
|
|
11668
|
+
.xl=${s.xl}
|
|
11669
|
+
.offset=${s.offset}
|
|
11670
|
+
.colOrder=${s.order}
|
|
11668
11671
|
>
|
|
11669
|
-
${this._renderField(
|
|
11672
|
+
${this._renderField(s,t)}
|
|
11670
11673
|
</lui-col>`)}
|
|
11671
11674
|
</lui-row>
|
|
11672
|
-
|
|
11675
|
+
`}_renderWizard(e){let t=this.schema.steps,r=t[this._currentStep];if(!r)return D.nothing;let n=this._currentStep===0,s=this._currentStep===t.length-1,d=e.api.state.isSubmitting||this._isStepPending;return D.html`
|
|
11673
11676
|
<div class="wizard-steps">
|
|
11674
11677
|
${t.map((h,p)=>D.html`
|
|
11675
11678
|
<div
|