amotify 0.2.123 → 0.2.124
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/demo/esbuild/app.tsx +38 -3
- package/demo/esbuild/public/index.js +55 -55
- package/dist/fn/Input/Select.d.ts +1 -0
- package/dist/fn/Input/Select.js +1 -1
- package/dist/fn/SwipeView.js +1 -1
- package/package.json +1 -1
|
@@ -20,6 +20,7 @@ declare namespace Select {
|
|
|
20
20
|
emptySelect?: boolean;
|
|
21
21
|
SelectedCellStyles?: StyleTags.PropsNFreeCSS;
|
|
22
22
|
SelectorCellStyles?: StyleTags.PropsNFreeCSS;
|
|
23
|
+
SelectorMode?: 'original' | 'legacy';
|
|
23
24
|
SelectorStyles?: StyleTags.PropsNFreeCSS;
|
|
24
25
|
SelectorPosition?: 1 | 2 | 3 | 4;
|
|
25
26
|
};
|
package/dist/fn/Input/Select.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as n,c as p,d as j}from"../../chunk-C5N2D3ZX.js";import{Fragment as ee,jsx as l,jsxs as E}from"react/jsx-runtime";import f,{UUID as R}from"jmini";import{useState as x,useEffect as G}from"react";import{ExtractStyles as re}from"../../@utils";import{Box as h,Span as se,FAI as Q,Column as ie}from"../../atoms";import{Text as F,Row as Y}from"../../mols";import{Button as ue}from"../Button";import{Sheet as ce}from"../Sheet";import{OptionalInputWrapper as pe,BoxWrapper as Se,CoreEffects as k,DefaultBoxishStyles as de}from"./core";import{InputAutocompleteClasses as w}from"../../@styles/componentClasses";import{InputLabel as fe}from"./Label";import{RightIcon as me}from".";function ve(e){let{value:t,states:a}=e,{required:r,options:o}=a,S=[];return r&&t===null&&S.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}),{ok:!S.filter(({type:m})=>m=="invalid").length,notice:S}}const P={FilterSelectableOptions:(e,t)=>{let a=e.rootStates.options;return t||(a=a.filter(r=>r.type!="label")),a}},T={Shallow:e=>{let{rootStates:t,val_status:a}=e,r=re(t);return l(h,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:l(F.Description,p(n({className:t.className},r),{position:"absolute",width:1,freeCSS:p(n({},r.freeCSS),{color:"orange"}),children:l(h,{"data-input-value-shallow":a.componentID,children:"A"})}))})},Button:e=>{let{rootStates:t,val_preventOpenSelectorOnFocus:a,set_preventOpenSelectorOnFocus:r,val_optionFocused:o,set_optionFocused:S,val_validate:m,set_validate:A,val_status:v,set_status:y,val_selectorOpen:c,set_selectorOpen:u}=e,L=t,{tone:D,required:_,form:te,className:le,label:ye,isLabelActive:be,placeholder:Ie,enableFormSubmit:ae,emptySelect:ge,checkValidationAtFirst:oe,onValidate:he,onUpdateValue:Ce,onUpdateValidValue:Te,value:_e="",options:xe,leftIndicator:De,rightIndicator:Oe,leftIcon:Ve,rightIcon:Re,componentID:Fe,status_id:ke,wrapStyles:we,SelectedCellStyles:Ee,SelectorCellStyles:Ae,SelectorStyles:Be,SelectorPosition:We}=L,s=j(L,["tone","required","form","className","label","isLabelActive","placeholder","enableFormSubmit","emptySelect","checkValidationAtFirst","onValidate","onUpdateValue","onUpdateValidValue","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentID","status_id","wrapStyles","SelectedCellStyles","SelectorCellStyles","SelectorStyles","SelectorPosition"]);return G(()=>{if(t.disabled)return;let i="select-click-"+t.componentID;if(c){if(!f('[data-input-origin="'+t.componentID+'"]'))return;f(document).addEvent({eventID:i,eventType:"click",callback:B=>{let O=f(B.target),V=!!f(O).parent("."+w("Core")).length;f(O).parent("."+w("Selector")).length||V||u(!1)}})}else f(document).removeEvent([i])},[c]),G(()=>{if(v.eventType=="init"||!c)return;let i=f('[data-input-origin="'+t.componentID+'"]');i&&i.focus()},[v.dataValue]),E(ee,{children:[l(h,p(n({tabIndex:0},s),{"data-disabled":t.disabled,"data-show-validation":k.isShowValidation(m,v,!!oe),"data-component-id":v.componentID,"data-input-origin":v.componentID,className:[le,w("Core")].join(" "),onFocus:i=>{if(s!=null&&s.onFocus&&(s==null||s.onFocus(i)),!t.disabled){if(a)return r(!1);u(!0)}},onClick:i=>{s!=null&&s.onClick&&(s==null||s.onClick(i)),!t.disabled&&u(!0)},onKeyDown:i=>{let{key:b,metaKey:B,ctrlKey:O}=i,V=B||O;if(s!=null&&s.onKeyDown&&(s==null||s.onKeyDown(i)),ae&&k.SubmitForm(i,te),!t.disabled){if(f.scope(()=>{if(!["ArrowDown","ArrowUp"].includes(b))return;if(i.preventDefault(),!c)return u(!0);let I=b=="ArrowDown"?1:-1,d=P.FilterSelectableOptions(e),W=d.length-1,g=null;f.scope(()=>{var N,K,q,z,U,H,M,$,J,X;let C=d.findIndex(ne=>ne.value==o);if(I==1){if(g=(K=(N=d[0])==null?void 0:N.value)!=null?K:null,V){g=(q=d[W].value)!=null?q:null;return}if(C==-1||C==W)return;g=(U=(z=d[C+1])==null?void 0:z.value)!=null?U:null}else{if(g=(H=d[W].value)!=null?H:null,V){g=($=(M=d[0])==null?void 0:M.value)!=null?$:null;return}if(C==-1||C==0)return;g=(X=(J=d[C-1])==null?void 0:J.value)!=null?X:null}}),S(g)}),b=="Escape")u(!1);else if(b=="Tab")u(!1);else if(b=="Backspace")y(I=>p(n({},I),{dataValue:null,eventType:"update",eventID:R()}));else if(b==" ")i.preventDefault(),u(!0);else if(b=="Enter"){if(!c)return u(!0);i.preventDefault();let I=t.options.find(d=>d.value==o);if(!I)return;y(d=>p(n({},d),{dataValue:I.value,eventType:"update",eventID:R()})),u(!1)}}},children:E(Y.Left,{flexWrap:!0,gap:"1/3",freeCSS:{letterSpacing:".5px"},children:[l(T.Placeholder,n({},e)),l(T.Selected,n({},e)),l(se,{width:0,overflow:"hidden",opacity:"trans",children:"A"})]})})),c&&l(T.Selector,n({},e))]})},Placeholder:e=>!e.rootStates.placeholder||e.val_status.dataValue!==null?null:l(h,{position:"absolute",opacity:"middle",fontColor:"3.blur",children:e.rootStates.placeholder||""}),Selector:e=>{var S;let t=[],a=P.FilterSelectableOptions(e,!0),r=P.FilterSelectableOptions(e);a.forEach((m,A)=>{let{type:v,value:y}=m,c=e.val_optionFocused==y,u=e.val_status.dataValue===y;if(v=="selector"){t.push(l(ue.Sub.S,p(n({color:"cloud",backgroundColor:"trans",borderRadius:0,fontColor:"2.normal",textAlign:"left",padding:["1/2",1],isActive:u||c,isActiveStyles:c?{backgroundColor:"cloud"}:{backgroundColor:"theme.opa.few",fontColor:"theme"}},e.rootStates.SelectorCellStyles),{onClick:D=>{e.set_status(_=>p(n({},_),{dataValue:y,eventType:"update",eventID:R()})),e.set_selectorOpen(!1),e.set_preventOpenSelectorOnFocus(!0)},children:E(Y.Left,{gap:"1/2",children:[u&&l(Q.Check,{fontColor:"theme"}),l(F.Supplement,{transition:"short",flexSizing:0,children:m.label})]})}),String(y)));return}t.push(l(h,{children:m.label},R()))}),r.length||(t=[l(F.Supplement,{padding:[0,1],fontColor:"4.thin",children:"\u5019\u88DC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"},"no-selector-notice")]);let o={position:"absolute",minWidth:1,freeCSS:{zIndex:1e3}};switch(e.rootStates.SelectorPosition){case 1:o.bottom="100%",o.left=0,o.paddingBottom="1/3";break;case 2:o.bottom="100%",o.right=0,o.paddingBottom="1/3";break;case 3:o.top="100%",o.left=0,o.paddingTop="1/3";break;case 4:o.top="100%",o.right=0,o.paddingTop="1/3";break;default:break}return l(h,p(n({},o),{children:l(ce.Body,p(n({className:w("Selector"),ssCardBox:!0,borderRadius:"2.tone.secondary",boxShadow:"1.normal",overflow:"auto"},e.rootStates.SelectorStyles),{freeCSS:n({minWidth:12*6,maxHeight:12*24},(S=e.rootStates.SelectorStyles)==null?void 0:S.freeCSS),children:l(ie,{gap:"1/12",padding:[1,0],children:t})}))}))},Selected:e=>{let t=[];return e.val_status.dataValue!==null&&f.scope(()=>{let a=e.rootStates.options.find(r=>f.is.equal(r.value,e.val_status.dataValue));a&&t.push(l(h,p(n({},e.rootStates.SelectedCellStyles),{children:a.label}),String(a.value)))}),l(ee,{children:t})},Core:e=>{var _;let{value:t}=e,[a,r]=x(k.DefaultStatus(e.componentID,t)),[o,S]=x(!1),[m,A]=x(!1),[v,y]=x((_=e.value)!=null?_:null),[c,u]=x({ok:!1,notice:[]}),D={rootStates:e,val_preventOpenSelectorOnFocus:o,set_preventOpenSelectorOnFocus:S,val_optionFocused:v,set_optionFocused:y,val_selectorOpen:m,set_selectorOpen:A,val_status:a,set_status:r,val_validate:c,set_validate:u};return k.CommonEffects({type:"select",states:e,val_status:a,set_status:r,val_validate:c,set_validate:u,SystemValidation:ve}),E(Se,{val_status:a,set_status:r,val_validate:c,states:e,children:[l(fe,{componentID:e.componentID,fontSize:e.fontSize,required:e.required,label:e.label,isActive:e.isLabelActive||a.dataValue!==null}),l(T.Shallow,n({},D)),l(T.Button,n({},D))]})}},Z=e=>{var a;let t=n({},e);return t=p(n({emptySelect:!0,SelectorPosition:3},t),{freeCSS:n({cursor:"pointer"},t.freeCSS)}),t.emptySelect&&(t.options=[{value:null,label:l(F.Supplement,{fontColor:"4.thin",children:"\u672A\u9078\u629E"})},...t.options]),t.value=(a=t.value)!=null?a:null,t.options.forEach((r,o)=>{let{type:S,value:m}=r;t.options[o]=p(n({},r),{value:m,type:S||"selector"})}),f.is.nullish(t.rightIcon)&&(t.rightIcon=l(me,{ssSphere:2,children:l(Q.AngleDown,{})})),l(pe,{componentID:t.componentID,children:T.Core,states:de(t)})};export{Z as Select,Z as default};
|
|
1
|
+
import{b as a,c,d as z}from"../../chunk-C5N2D3ZX.js";import{Fragment as $,jsx as l,jsxs as F}from"react/jsx-runtime";import y,{UUID as k}from"jmini";import{useState as A,useEffect as ne}from"react";import{ExtractStyles as xe}from"../../@utils";import{Box as I,Span as Ve,FAI as re,Column as Fe}from"../../atoms";import{Text as B,Row as se}from"../../mols";import{Button as we}from"../Button";import{Sheet as Re}from"../Sheet";import{OptionalInputWrapper as ke,BoxWrapper as Ae,CoreEffects as V,DefaultBoxishStyles as Ee}from"./core";import{InputAutocompleteClasses as E}from"../../@styles/componentClasses";import{InputLabel as Be}from"./Label";import{RightIcon as We}from".";function Le(e){let{value:t,states:o}=e,{required:r,options:n}=o,f=[];return r&&t===null&&f.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}),{ok:!f.filter(({type:p})=>p=="invalid").length,notice:f}}const H={FilterSelectableOptions:(e,t)=>{let o=e.rootStates.options;return t||(o=o.filter(r=>r.type!="label")),o}},h={Shallow:e=>{let{rootStates:t,val_status:o}=e,r=xe(t);return l(I,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:l(B.Description,c(a({className:t.className},r),{position:"absolute",width:1,freeCSS:c(a({},r.freeCSS),{color:"orange"}),children:l(I,{"data-input-value-shallow":o.componentID,children:"A"})}))})},Button:e=>F($,{children:[l(h.LegacySelector,a({},e)),l(h.Original,a({},e))]}),Placeholder:e=>!e.rootStates.placeholder||e.val_status.dataValue!==null?null:l(I,{position:"absolute",opacity:"middle",fontColor:"3.blur",children:e.rootStates.placeholder||""}),Original:e=>{let{rootStates:t,val_preventOpenSelectorOnFocus:o,set_preventOpenSelectorOnFocus:r,val_optionFocused:n,set_optionFocused:f,val_validate:p,set_validate:w,val_status:m,set_status:b,val_selectorOpen:S,set_selectorOpen:u}=e,U=t,{tone:R,required:D,form:W,className:L,label:ue,isLabelActive:ce,placeholder:pe,enableFormSubmit:P,emptySelect:j,checkValidationAtFirst:M,onValidate:Se,onUpdateValue:de,onUpdateValidValue:fe,value:N="",options:K,leftIndicator:me,rightIndicator:J,leftIcon:ve,rightIcon:ye,componentID:be,status_id:ge,wrapStyles:Ie,SelectedCellStyles:he,SelectorCellStyles:Ce,SelectorMode:_e,SelectorStyles:De,SelectorPosition:Oe}=U,s=z(U,["tone","required","form","className","label","isLabelActive","placeholder","enableFormSubmit","emptySelect","checkValidationAtFirst","onValidate","onUpdateValue","onUpdateValidValue","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentID","status_id","wrapStyles","SelectedCellStyles","SelectorCellStyles","SelectorMode","SelectorStyles","SelectorPosition"]);return ne(()=>{if(e.rootStates.SelectorMode!="original"||t.disabled)return;let i="select-click-"+t.componentID;if(S){if(!y('[data-input-origin="'+t.componentID+'"]'))return;y(document).addEvent({eventID:i,eventType:"click",callback:d=>{let O=y(d.target),T=!!y(O).parent("."+E("Core")).length;y(O).parent("."+E("Selector")).length||T||u(!1)}})}else y(document).removeEvent([i])},[S]),ne(()=>{if(e.rootStates.SelectorMode!="original"||m.eventType=="init"||!S)return;let i=y('[data-input-origin="'+t.componentID+'"]');i&&i.focus()},[m.dataValue]),e.rootStates.SelectorMode!="original"?null:F($,{children:[l(I,c(a({tabIndex:0},s),{"data-disabled":t.disabled,"data-show-validation":V.isShowValidation(p,m,!!M),"data-component-id":m.componentID,"data-input-origin":m.componentID,className:[L,E("Core")].join(" "),onFocus:i=>{if(s!=null&&s.onFocus&&(s==null||s.onFocus(i)),!t.disabled){if(o)return r(!1);u(!0)}},onClick:i=>{s!=null&&s.onClick&&(s==null||s.onClick(i)),!t.disabled&&u(!0)},onKeyDown:i=>{let{key:g,metaKey:d,ctrlKey:O}=i,T=d||O;if(s!=null&&s.onKeyDown&&(s==null||s.onKeyDown(i)),P&&V.SubmitForm(i,W),!t.disabled){if(y.scope(()=>{if(!["ArrowDown","ArrowUp"].includes(g))return;if(i.preventDefault(),!S)return u(!0);let C=g=="ArrowDown"?1:-1,v=H.FilterSelectableOptions(e),q=v.length-1,_=null;y.scope(()=>{var X,G,Q,Y,Z,ee,te,le,ae,oe;let x=v.findIndex(Te=>Te.value==n);if(C==1){if(_=(G=(X=v[0])==null?void 0:X.value)!=null?G:null,T){_=(Q=v[q].value)!=null?Q:null;return}if(x==-1||x==q)return;_=(Z=(Y=v[x+1])==null?void 0:Y.value)!=null?Z:null}else{if(_=(ee=v[q].value)!=null?ee:null,T){_=(le=(te=v[0])==null?void 0:te.value)!=null?le:null;return}if(x==-1||x==0)return;_=(oe=(ae=v[x-1])==null?void 0:ae.value)!=null?oe:null}}),f(_)}),g=="Escape")u(!1);else if(g=="Tab")u(!1);else if(g=="Backspace")b(C=>c(a({},C),{dataValue:null,eventType:"update",eventID:k()}));else if(g==" ")i.preventDefault(),u(!0);else if(g=="Enter"){if(!S)return u(!0);i.preventDefault();let C=t.options.find(v=>v.value==n);if(!C)return;b(v=>c(a({},v),{dataValue:C.value,eventType:"update",eventID:k()})),u(!1)}}},children:F(se.Left,{flexWrap:!0,gap:"1/3",freeCSS:{letterSpacing:".5px"},children:[l(h.Placeholder,a({},e)),l(h.Selected,a({},e)),l(Ve,{width:0,overflow:"hidden",opacity:"trans",children:"A"})]})})),S&&l(h.Selector,a({},e))]})},LegacySelector:e=>{let{rootStates:t,val_preventOpenSelectorOnFocus:o,set_preventOpenSelectorOnFocus:r,val_optionFocused:n,set_optionFocused:f,val_validate:p,set_validate:w,val_status:m,set_status:b,val_selectorOpen:S,set_selectorOpen:u}=e,g=t,{tone:R,required:D,form:W,className:L,label:ue,isLabelActive:ce,placeholder:pe,enableFormSubmit:P,emptySelect:j,checkValidationAtFirst:M,onValidate:Se,onUpdateValue:de,onUpdateValidValue:fe,onKeyDown:N,onChange:K,value:me="",options:J,leftIndicator:ve,rightIndicator:ye,leftIcon:be,rightIcon:ge,componentID:Ie,status_id:he,wrapStyles:Ce,SelectedCellStyles:_e,SelectorCellStyles:De,SelectorMode:Oe,SelectorStyles:s,SelectorPosition:U}=g,i=z(g,["tone","required","form","className","label","isLabelActive","placeholder","enableFormSubmit","emptySelect","checkValidationAtFirst","onValidate","onUpdateValue","onUpdateValidValue","onKeyDown","onChange","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentID","status_id","wrapStyles","SelectedCellStyles","SelectorCellStyles","SelectorMode","SelectorStyles","SelectorPosition"]);return e.rootStates.SelectorMode!="legacy"?null:F(I,c(a({htmlTag:"select",tabIndex:0},i),{"data-disabled":t.disabled,"data-show-validation":V.isShowValidation(p,m,!!M),"data-component-id":m.componentID,"data-input-origin":m.componentID,className:[L,E("Core")].join(" "),onKeyDown:d=>{N&&N(d),P&&V.SubmitForm(d,W)},onChange:d=>{let{value:O}=d.target;p.ok&&w({ok:!1,notice:[]}),b(T=>c(a({},T),{dataValue:O,eventType:"update",eventID:k()})),K&&K(d)},children:[!!j&&l("option",{value:"null",children:"\u9078\u629E"}),J.map(d=>d.value?l("option",{value:d.value,children:d.label},String(d.value)):null)]}))},Selector:e=>{var f;let t=[],o=H.FilterSelectableOptions(e,!0),r=H.FilterSelectableOptions(e);o.forEach((p,w)=>{let{type:m,value:b}=p,S=e.val_optionFocused==b,u=e.val_status.dataValue===b;if(m=="selector"){t.push(l(we.Sub.S,c(a({color:"cloud",backgroundColor:"trans",borderRadius:0,fontColor:"2.normal",textAlign:"left",padding:["1/2",1],isActive:u||S,isActiveStyles:S?{backgroundColor:"cloud"}:{backgroundColor:"theme.opa.few",fontColor:"theme"}},e.rootStates.SelectorCellStyles),{onClick:R=>{e.set_status(D=>c(a({},D),{dataValue:b,eventType:"update",eventID:k()})),e.set_selectorOpen(!1),e.set_preventOpenSelectorOnFocus(!0)},children:F(se.Left,{gap:"1/2",children:[u&&l(re.Check,{fontColor:"theme"}),l(B.Supplement,{transition:"short",flexSizing:0,children:p.label})]})}),String(b)));return}t.push(l(I,{children:p.label},k()))}),r.length||(t=[l(B.Supplement,{padding:[0,1],fontColor:"4.thin",children:"\u5019\u88DC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"},"no-selector-notice")]);let n={position:"absolute",minWidth:1,freeCSS:{zIndex:1e3}};switch(e.rootStates.SelectorPosition){case 1:n.bottom="100%",n.left=0,n.paddingBottom="1/3";break;case 2:n.bottom="100%",n.right=0,n.paddingBottom="1/3";break;case 3:n.top="100%",n.left=0,n.paddingTop="1/3";break;case 4:n.top="100%",n.right=0,n.paddingTop="1/3";break;default:break}return l(I,c(a({},n),{children:l(Re.Body,c(a({className:E("Selector"),ssCardBox:!0,borderRadius:"2.tone.secondary",boxShadow:"1.normal",overflow:"auto"},e.rootStates.SelectorStyles),{freeCSS:a({minWidth:12*6,maxHeight:12*24},(f=e.rootStates.SelectorStyles)==null?void 0:f.freeCSS),children:l(Fe,{gap:"1/12",padding:[1,0],children:t})}))}))},Selected:e=>{let t=[];return e.val_status.dataValue!==null&&y.scope(()=>{let o=e.rootStates.options.find(r=>y.is.equal(r.value,e.val_status.dataValue));o&&t.push(l(I,c(a({},e.rootStates.SelectedCellStyles),{children:o.label}),String(o.value)))}),l($,{children:t})},Core:e=>{var D;let{value:t}=e,[o,r]=A(V.DefaultStatus(e.componentID,t)),[n,f]=A(!1),[p,w]=A(!1),[m,b]=A((D=e.value)!=null?D:null),[S,u]=A({ok:!1,notice:[]}),R={rootStates:e,val_preventOpenSelectorOnFocus:n,set_preventOpenSelectorOnFocus:f,val_optionFocused:m,set_optionFocused:b,val_selectorOpen:p,set_selectorOpen:w,val_status:o,set_status:r,val_validate:S,set_validate:u};return V.CommonEffects({type:"select",states:e,val_status:o,set_status:r,val_validate:S,set_validate:u,SystemValidation:Le}),F(Ae,{val_status:o,set_status:r,val_validate:S,states:e,children:[l(Be,{componentID:e.componentID,fontSize:e.fontSize,required:e.required,label:e.label,isActive:e.isLabelActive||o.dataValue!==null}),l(h.Shallow,a({},R)),l(h.Button,a({},R))]})}},ie=e=>{var o;let t=a({},e);return t=c(a({emptySelect:!0,SelectorMode:"original",SelectorPosition:3},t),{freeCSS:a({cursor:"pointer"},t.freeCSS)}),t.emptySelect&&(t.options=[{value:null,label:l(B.Supplement,{fontColor:"4.thin",children:"\u672A\u9078\u629E"})},...t.options]),t.value=(o=t.value)!=null?o:null,t.options.forEach((r,n)=>{let{type:f,value:p}=r;t.options[n]=c(a({},r),{value:p,type:f||"selector"})}),y.is.nullish(t.rightIcon)&&(t.rightIcon=l(We,{ssSphere:2,children:l(re.AngleDown,{})})),l(ke,{componentID:t.componentID,children:h.Core,states:Ee(t)})};export{ie as Select,ie as default};
|
package/dist/fn/SwipeView.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as w,c as m,d as D}from"../chunk-C5N2D3ZX.js";import{jsx as T}from"react/jsx-runtime";import c,{UUID as P}from"jmini";import{useState as V,useEffect as k,useRef as X}from"react";import{$$fromRoot as f}from"../@utils";import{Box as L,Flex as j}from"../atoms";import{LayoutClasses as a}from"../@styles/componentClasses";const _=t=>{let M=t,{options:{onSlideCallback:e,visibilitySurroundSlide:u=!0,autoSwipems:o=0,loop:s=!1,disableMousedrag:
|
|
1
|
+
import{b as w,c as m,d as D}from"../chunk-C5N2D3ZX.js";import{jsx as T}from"react/jsx-runtime";import c,{UUID as P}from"jmini";import{useState as V,useEffect as k,useRef as X}from"react";import{$$fromRoot as f}from"../@utils";import{Box as L,Flex as j}from"../atoms";import{LayoutClasses as a}from"../@styles/componentClasses";const _=t=>{let M=t,{options:{onSlideCallback:e,visibilitySurroundSlide:u=!0,autoSwipems:o=0,loop:s=!1,disableMousedrag:n=!1,disableTouch:l=!1}={},wrapper:i=r=>r,slides:S=[],slideIndex:B}=M,g=D(M,["options","wrapper","slides","slideIndex"]),[h]=V(P()),[d,b]=V({eventType:"init",index:t.slideIndex});const C=X(!1);k(()=>{b({eventType:"usr",index:t.slideIndex}),C.current||(C.current=!0)},[t.slideIndex]),k(()=>{let r=d.index+(s?1:0),v=[-1,S.length].includes(d.index);v||e&&setTimeout(()=>{e(d.index)},300);let E=f("#Swiper-"+h);if(d.eventType=="adjustLoop")E.await(250).css({transition:"0s",transform:x(r)}).children().removeClass(a("Display")).parent().children(r).addClass([a("Display"),a("LoopAdjusting")]).await(100).removeClass(a("LoopAdjusting"));else if(d.eventType=="sys")E.await(250).css({transform:x(r)}).children().removeClass(a("Display")).parent().children(r).addClass(a("Display"));else if(E.children().removeClass(a("Display")).parent().children(r).addClass(a("Display")).parent().css({transition:"0.3s",transform:x(r)}).await(250).css({transition:"0s"}),v){let y=d.index==-1?S.length-1:0;b({eventType:"adjustLoop",index:y})}o&&!v&&c.interval.once(()=>{let y=d.index+1;!s&&y>S.length-1&&(y=0),b({eventType:"usr",index:y})},o-(d.eventType=="sys"?310:0),"SwipeTimer-"+h)},[d]);let p=S.map((r,v)=>T(L,{flexSizing:"none",width:1,height:0,className:a("Child"),children:i(r)},v));s&&(p.push(m(w({},p[0]),{key:p[0].key+"-Shallow0"})),p.unshift(m(w({},p[p.length-2]),{key:p[p.length-2].key+"-Shallow0"})));let A={x:0,y:0,process:!1,effectStartAt:0,id:h,loop:s,index:d.index,minIndex:s?-1:0,maxIndex:S.length+(s?1:-1),width:0,set_event:b},N=d.index+ +!!s;return T(L,m(w({overflow:"hidden",position:"relative"},g),{className:[g.className,a("SwipeView")].join(" "),freeCSS:w({zIndex:1},g.freeCSS),"data-swipe-id":h,onPointerDown:r=>{if(r.pointerType=="touch"){if(l)return}else if(r.pointerType=="mouse"&&(n||r.buttons!=1))return;I.Start(r,A)},children:T(j,{flexWrap:!1,gap:1,transition:"long",className:[a("Rail"),a("ShowOther_"+u)].join(" "),id:"Swiper-"+h,freeCSS:w({},C.current?{}:{transform:x(N)}),children:p})}))},x=t=>`translateX( calc( ${-100*t}% - ${12*t}px ) )`,I={Start:(t,e)=>{let{x:u,y:o}=c.getCursor(t),s=t.currentTarget,n=t.target;if(["SELECT","BUTTON","LABEL","INPUT"].includes(n.tagName))return;e=m(w({},e),{x:u-e.x+window.scrollX,y:o-e.y+window.scrollY,effectStartAt:new Date().getTime(),width:f("#Swiper-"+e.id).position().width});let{swipeId:l}=s.dataset;l==e.id&&c(document).addEvent({eventID:"SwipeView.PointerMove",eventType:"pointermove",callback:i=>{I.Check(i,e)},options:{passive:!1}}).addEvent({eventID:"SwipeView.PointerUp",eventType:"pointerup",callback:i=>{I.End(i,e)},options:{passive:!1}})},Check:(t,e)=>{if(e.process)return;let{x:u,y:o}=c.getCursor(t),s=Math.abs(u-e.x+window.scrollX),n=Math.abs(o-e.y+window.scrollY);if(!(t.touches&&t.touches.length>1)&&!(n+s<15))if(n>s/2)c(document).removeEvent(["SwipeView.PointerMove"]);else{e.process=!0;let l=e.index+(e.loop?1:0);f("#Swiper-"+e.id).children(l-1).addClass(a("Display")),c(document).addEvent({eventID:"SwipeView.Check.MouseMove",eventType:"mousemove",callback:i=>{I.Move(i,e)},options:{passive:!1}}).addEvent({eventID:"SwipeView.Check.TouchMove",eventType:"touchmove",callback:i=>{I.Move(i,e)},options:{passive:!1}}),t.preventDefault();return}},Move:(t,e)=>{if(t.touches&&t.touches.length>1)return;let{x:u}=c.getCursor(t),o=u-e.x+window.scrollX,n=e.index+(e.loop?1:0)-o/e.width;if(n<0)n/=2;else if(n>e.maxIndex){let l=n-e.maxIndex;n=e.maxIndex+l/2}f("#Swiper-"+e.id).css({transition:"0s",transform:x(n)}),t.preventDefault()},End:(t,e)=>{if(e.process){let o=c.getCursor(t).x-e.x+window.scrollX,s=new Date().getTime(),n=s-e.effectStartAt,l=e.index+(e.loop?1:0),i=0;n<400?i=l-(+(o>0)*2-1):i=Math.round(l-o/e.width),i=Math.max(Math.min(i,e.maxIndex),e.minIndex),e.process=!1,l===i?(e.effectStartAt=s,f("#Swiper-"+e.id).css({transition:".2s",transform:x(i)}).await(310).css({transition:"0s"}).children().removeClass(a("Display")).parent().children(l).addClass(a("Display"))):e.set_event({eventType:"usr",index:i+e.minIndex})}c(document).removeEvent(["SwipeView.PointerMove","SwipeView.Check.MouseMove","SwipeView.Check.TouchMove","SwipeView.PointerUp"])}},R=t=>T(_,m(w({},t),{slideIndex:Math.max(Math.min(t.slideIndex,t.slides.length-1),0)}));export{R as SwipeView,R as default};
|