amotify 0.2.206 → 0.2.207
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.
|
@@ -108,23 +108,10 @@ let Page = () => {
|
|
|
108
108
|
<Literal>
|
|
109
109
|
val_value { val_value || "null" }
|
|
110
110
|
</Literal>
|
|
111
|
-
<input
|
|
112
|
-
type='text'
|
|
113
|
-
onChange={ event => {
|
|
114
|
-
let {
|
|
115
|
-
value: rawValue,
|
|
116
|
-
selectionStart,
|
|
117
|
-
selectionEnd,
|
|
118
|
-
} = event.target as HTMLInputElement
|
|
119
|
-
console.log(
|
|
120
|
-
rawValue,
|
|
121
|
-
( event as any ).key
|
|
122
|
-
)
|
|
123
|
-
} }
|
|
124
|
-
/>
|
|
125
111
|
<Input.TextField
|
|
126
|
-
override='force'
|
|
112
|
+
// override='force'
|
|
127
113
|
value={ val_value }
|
|
114
|
+
required
|
|
128
115
|
onUpdateValidValue={ value => {
|
|
129
116
|
console.log(
|
|
130
117
|
'[onUpdateValidValue]',value
|
|
@@ -132,6 +119,19 @@ let Page = () => {
|
|
|
132
119
|
set_value( value )
|
|
133
120
|
} }
|
|
134
121
|
/>
|
|
122
|
+
<Input.Switch
|
|
123
|
+
onUserAction={ ( value,opt ) => {
|
|
124
|
+
// console.log(
|
|
125
|
+
// '[onUserAction]',value,opt
|
|
126
|
+
// )
|
|
127
|
+
} }
|
|
128
|
+
onUpdateValue={ ( ...args ) => {
|
|
129
|
+
// console.log( '[onUpdateValue]',args )
|
|
130
|
+
} }
|
|
131
|
+
onUpdateValidValue={ ( ...args ) => {
|
|
132
|
+
console.log( '[onUpdateValidValue]',args )
|
|
133
|
+
} }
|
|
134
|
+
/>
|
|
135
135
|
</Box>
|
|
136
136
|
</Column>
|
|
137
137
|
</Plate>
|
package/dist/fn/Input/Switch.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as
|
|
1
|
+
import{b as o,c as l,d as D}from"../../chunk-C5N2D3ZX.js";import{jsx as a,jsxs as z}from"react/jsx-runtime";import{UUID as S}from"jmini";import{useState as M}from"react";import I from"../../atoms/Box";import{Row as U}from"../../mols";import{Label as A}from"../Button";import{OptionalInputWrapper as W,BoxWrapper as P,CoreEffects as N}from"./core";import{InputSwitchClasses as g}from"../../@styles/componentClasses";function H(e){let{value:n,states:s}=e,{required:x}=s,r=[];return x&&!n&&r.push({type:"invalid",label:"ON\u306B\u306A\u3063\u3066\u3044\u307E\u305B\u3093"}),{ok:!r.filter(({type:f})=>f=="invalid").length,notice:r}}const O=e=>{let B=e,{componentId:n,color:s="posi",required:x,form:r,id:f,enableFormSubmit:E,checkValidationAtFirst:q,onChange:F,onKeyDown:T,onValidate:K,onValidateDelay:$,onUpdateValue:G,onUpdateValidValue:J,onUserAction:Q,size:R="regular",value:L="",icon:V="",isApply:p=!1}=B,t=D(B,["componentId","color","required","form","id","enableFormSubmit","checkValidationAtFirst","onChange","onKeyDown","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","size","value","icon","isApply"]),[u,c]=M({componentId:e.componentId||"",dataValue:L,eventType:"init",eventID:S()}),[v,k]=M({ok:!1,notice:[]}),d=!!u.dataValue;N.CommonEffects({type:"switch",states:e,val_status:u,set_status:c,val_validate:v,set_validate:k,SystemValidation:H});let y="middle",w=5,C=3;return p&&(C=4),z(P,{val_status:u,set_status:c,val_validate:v,states:e,children:[a(I,l(o({htmlTag:"input",type:"checkbox","data-component-id":u.componentId,checked:u.dataValue,className:g("Input"),id:f,onKeyDown:i=>{T&&T(i),E&&N.SubmitForm(i,r)},onChange:i=>{let{checked:m}=i.target;v.ok&&k({ok:!1,notice:[]}),c(_=>l(o({},_),{dataValue:m,eventType:"update",eventID:S()})),F&&F(i)}},t),{onFocus:i=>{t!=null&&t.onFocus&&(t==null||t.onFocus(i)),c(m=>l(o({},m),{eventID:S(),isFocusing:!0}))},onBlur:i=>{t!=null&&t.onBlur&&(t==null||t.onBlur(i)),c(m=>l(o({},m),{eventID:S(),isFocusing:!1}))}})),a(A.Plain,{tabIndex:-1,htmlFor:f,padding:"1/4",transition:y,borderRadius:"1.tone.primary",className:g("Label"),children:a(I,l(o({},p?{padding:"1/4",isRounded:!0,backgroundColor:d?s:"layer.3"}:{}),{children:z(U.Center,{unitHeight:R=="small"?2:R=="regular"?2.5:R=="large"?3:0,position:"relative",freeCSS:{aspectRatio:(w+C)/w},children:[!p&&a(I,{position:"absolute",backgroundColor:d?s:"layer.5",isRounded:!0,transition:y,width:1,opacity:"middle",className:g("Bar"),freeCSS:{height:"40%"}}),a(I,{position:"absolute",top:0,backgroundColor:!p&&d?s:"white",transition:y,isRounded:!0,flexCenter:!0,boxShadow:"1.remark",className:g("Dot"),freeCSS:{height:"100%",aspectRatio:"1",left:d?`calc(${C.ratio(w+C)}%)`:0},children:V&&a(I,{transition:y,flexCenter:!0,fontColor:d?p?s:"white":"6.clear",children:V})})]})}))})]})},b=e=>{let n=o({},e);return n.value=!!n.value,n.color=n.color||"theme",a(W,{componentId:n.componentId,children:O,states:n})},h=b;h.S=e=>a(b,l(o({},e),{size:"small"})),h.R=e=>a(b,l(o({},e),{size:"regular"})),h.L=e=>a(b,l(o({},e),{size:"large"}));export{h as Switch,h as default};
|
package/dist/fn/Input/core.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as
|
|
1
|
+
import{b as i,c as p,e as b}from"../../chunk-C5N2D3ZX.js";import{jsx as m,jsxs as h}from"react/jsx-runtime";import{useState as x,useEffect as S}from"react";import f,{UUID as y,useStore as v}from"jmini";import{$$fromRoot as D}from"../../@utils";import{InputClasses as _}from"../../@styles/componentClasses";import{Box as B,Flex as E,FAI as V,Column as F}from"../../atoms";import{Row as k,Literal as N}from"../../mols";import{Button as w}from"../Button";import C from"../Tooltips";const et=t=>{let[n]=x(t.componentId||y());t=i({},t),t.states=p(i({enableFormSubmit:!0,status_id:y(),override:"never",form:"",id:y(),"aria-label":"Input-"+n},t.states),{componentId:n});let{children:e}=t;return m(e,i({},t.states))},at=t=>{let{children:n,val_status:e,val_validate:a,states:o}=t,{leftIcon:r,wrapStyles:d}=o;return o.checkValidationAtFirst||e.eventType=="init"&&(a.notice=[]),h(k.Center,p(i({position:"relative",verticalAlign:"unset",gap:0},d),{className:_("Wrapper"),"data-notice-uid":e.componentId,children:[m(T.Notice,{notice:a.notice,val_status:e}),o.leftIndicator,h(E,{position:"relative",flexSizing:"auto",children:[n,r,m(T.RightIcon,i({},t)),m(T.ClearButton,i({},t))]}),o.rightIndicator]}))},T={ClearButton:t=>!t.states.clearButton||!t.val_status.dataValue?null:m(w.Normal,{ssSphere:2,flexCenter:!0,fontColor:"5.translucent",ssEffectsOnActive:["ripple.theme"],position:"absolute",right:1,top:"50%",freeCSS:{zIndex:3,transform:"translateY(-50%)"},onClick:()=>{t.set_status(n=>p(i({},n),{dataValue:"",formatValue:"",eventType:"update",eventID:y()}))},children:m(V.X,{})}),RightIcon:t=>t.states.clearButton&&t.val_status.dataValue?null:t.states.rightIcon,Notice:t=>{let{notice:n,val_status:e}=t,{componentId:a}=e,o="NoticeTimer-"+a,r="NoticeTimerClose-"+a,d="notice-tips-"+a;return S(()=>{f.interval.once(()=>{if(!n.length){C.close(d);return}C.open({tipsID:d,parent:`[data-notice-uid="${a}"]`,gravityPoint:24,padding:[1,0],closeAtParentBlur:!1,content:h(C.Body,{padding:["1/2","2/3"],fontSize:"1.mini",position:"relative",children:[m(B,{position:"absolute",unitHeight:1,unitWidth:1,right:1,backgroundColor:"dark",freeCSS:{zIndex:1,transform:"rotate(45deg)",top:-6}}),m(F,{backgroundColor:"inherit",gap:"1/3",position:"relative",freeCSS:{zIndex:2},children:n.map((I,g)=>{let{type:s,label:u}=I,c=s=="invalid"?V.Exclamation:s=="warn"?V.Exclamation:V.Check;return h(k.Left,{gap:0,borderRadius:"2.tone.secondary",children:[m(c,{flexCenter:!0,fontSize:"2.normal",fontColor:{invalid:"nega",warn:"warn",valid:"posi"}[s]}),m(N.Supplement,{fontSize:"0.xs",fontColor:"white",children:u})]},g+"-"+f.Stringify(I))})})]})})},350,o),f.interval.once(()=>{C.close(d)},6e3,r)},[n]),null}},A={DefaultStatus:(t,n)=>({componentId:t,dataValue:n,eventType:"init",eventID:y()}),CommonEffects:function(t){let{type:n,states:e,val_status:a,set_status:o,val_validate:r,set_validate:d,SystemValidation:I}=t;e=i({},e);let{componentId:g}=a;S(()=>(v.update({[g]:{ResolveRefresh:null,Refresh:()=>new Promise((s,u)=>{v.get(g).ResolveRefresh=s,o(c=>p(i({},c),{eventType:"refresh",eventID:y()}))}),GenNotice:s=>{let{ok:u,notice:c}=s;d({ok:u,notice:c})}}}),()=>{v.delete(g)}),[]),f.scope(()=>{let{override:s}=e;if(s=="never"||s=="beforeModified"&&!["init","override"].includes(a.eventType)||a.isComposing)return;let u=v.get(a.componentId);if(u){if(e.value==a.dataValue){u.status_id=e.status_id;return}e.status_id!=u.status_id&&o(c=>p(i(p(i({},c),{dataValue:e.value}),t.ExtraOverrideStates&&t.ExtraOverrideStates()),{eventType:"override",eventID:y()}))}}),S(()=>{A.ValidationCheck({val_status:a,set_validate:d,SystemValidation:I,states:e})},[a.eventID,a.dataValue]),S(()=>{let{componentId:s,eventType:u,dataValue:c}=a,l=c;n=="autocomplete.single"||n=="list.radio"?l=l[0]:e.isChecker&&(l=!!l[0]),e.onUserAction&&e.onUserAction(l,{eventType:u,componentId:s,isValidated:!!r.ok,isComposing:!!a.isComposing,isFocusing:!!a.isFocusing})},[a]),S(()=>(f.scope(()=>{let{componentId:s,eventType:u,dataValue:c}=a,l=c;if(n=="autocomplete.single"||n=="list.radio"?l=l[0]:e.isChecker&&(l=!!l[0]),e.form=e.form||"testForm",e.name&&e.form&&v.update({[["form-data",e.form].join("-")]:{[e.name]:{componentId:s,type:n,value:l,validation:r.ok}}}),u=="refresh"){let R=v.get(s);R&&R.ResolveRefresh&&R.ResolveRefresh(null)}else u=="update"&&(e.onUpdateValue&&e.onUpdateValue(l,{eventType:u,componentId:s,isValidated:!!r.ok,isComposing:!!a.isComposing,isFocusing:!!a.isFocusing}),f.scope(()=>{e.onUpdateValidValue&&r.ok&&e.onUpdateValidValue(l,{eventType:u,componentId:s,isValidated:!!r.ok,isComposing:!!a.isComposing,isFocusing:!!a.isFocusing})}))}),()=>{v.update({[["form-data",e.form].join("-")]:{[e.name]:null}})}),[r.ok,a.dataValue])},ValidationCheck:t=>{let{states:n}=t,e="ValidationTimer-"+t.val_status.componentId;f.interval.abort(e);let a=t.SystemValidation({value:t.val_status.dataValue,states:n});if(!a.ok){t.set_validate(a);return}let o=a.notice;const r=()=>b(void 0,null,function*(){if(!n.onValidate)return;let d=yield n.onValidate(t.val_status.dataValue,t.val_status.eventType,t);t.set_validate({ok:d.ok,notice:[...o,...d.notice]})});if(n.onValidate){if(t.val_status.eventType=="refresh"){r();return}f.interval.once(r,n.onValidateDelay||500,e);return}t.set_validate({ok:!0,notice:o})},SubmitForm:(t,n)=>{let e=!1;if(!n)return e;let a=D(`[data-form-submit-button="${n}"]`)[0];if(!a)return e;let o=a.dataset.sdfike||"",r=t.key,d=t.ctrlKey||t.metaKey;return f.scope(()=>{o.includes("enter")&&(r!="Enter"||t.nativeEvent.isComposing||(t==null?void 0:t.keyCode)==229)||((r=="Enter"&&(o.includes("enter")||o.includes("auxEnter")&&d)||r==" "&&o.includes("space"))&&(a.click(),t.preventDefault()),e=!0)}),e},isShowValidation:(t,n,e)=>{let a=t.ok;return!e&&n.eventType=="init"?!0:a}},nt=function(t){t=i({tone:"border"},t);let n=f.scope(()=>{if(t.tone=="plain")return{};let a={padding:1,transition:"middle",flexSizing:"auto",boxShadow:"0.min"};return t.tone=="border"?a=p(i({},a),{border:!0,borderRadius:"2.tone.secondary",backgroundColor:"layer.1"}):t.tone=="cloud"?a=p(i({},a),{border:"1.thin",borderRadius:"2.tone.secondary",backgroundColor:"cloud"}):t.tone=="bottomBorder"&&(a=p(i({},a),{borderRadius:0,border:"unset",borderBottom:!0,backgroundColor:"cloud"})),a});return p(i(i(i(i(i(i({fontColor:"2.normal"},n),!!t.rightIcon&&{paddingRight:3}),!!t.leftIcon&&{paddingLeft:3}),!!t.leftIndicator&&{borderTopLeftRadius:"2/3",borderBottomLeftRadius:"2/3",marginLeft:"1/4"}),!!t.rightIndicator&&{borderTopRightRadius:"2/3",borderBottomRightRadius:"2/3",marginRight:"1/4"}),t),{freeCSS:i({letterSpacing:"1px",resize:"none"},t.freeCSS),className:[_("Input"),t.className].join(" ")})};export{at as BoxWrapper,A as CoreEffects,nt as DefaultBoxishStyles,et as OptionalInputWrapper};
|
package/dist/fn/Input/index.d.ts
CHANGED
|
@@ -3,7 +3,13 @@ import { ReactElement, StyleTags } from '../../@declares';
|
|
|
3
3
|
export declare namespace InputTypes {
|
|
4
4
|
type BoxTone = 'border' | 'cloud' | 'bottomBorder' | 'plain';
|
|
5
5
|
type Type = 'hidden' | 'textfield' | 'textfield.multiline' | 'select' | 'list.radio' | 'list.checkbox' | 'autocomplete.single' | 'autocomplete.multi' | 'time' | 'switch' | 'slider' | 'file' | 'contenteditable' | 'color' | '';
|
|
6
|
-
type OnUpdateValue<T = any> = (value: T,
|
|
6
|
+
type OnUpdateValue<T = any> = (value: T, option: {
|
|
7
|
+
eventType?: Validation.EventType;
|
|
8
|
+
componentId?: string;
|
|
9
|
+
isValidated?: boolean;
|
|
10
|
+
isComposing?: boolean;
|
|
11
|
+
isFocusing?: boolean;
|
|
12
|
+
}) => void;
|
|
7
13
|
type OnUserAction<T = any> = (value: T, option: {
|
|
8
14
|
eventType?: Validation.EventType;
|
|
9
15
|
componentId?: string;
|
package/dist/fn/Input/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../../chunk-C5N2D3ZX.js";import*as t from"./Parts";export*from"./Parts";import i from"./Plain";import a from"./Hidden";import p from"./TextField";import m from"./Contenteditable";import n from"./DigitCharacters";import l from"./Time";import d from"./Select";import s from"./Autocomplete";import*as r from"./List";import c from"./Search";import x from"./Filer";import y from"./Slider";import T from"./Switch";import f from"./Checker";import g from"./Segmented";import
|
|
1
|
+
import"../../chunk-C5N2D3ZX.js";import*as t from"./Parts";export*from"./Parts";import i from"./Plain";import a from"./Hidden";import p from"./TextField";import m from"./Contenteditable";import n from"./DigitCharacters";import l from"./Time";import d from"./Select";import s from"./Autocomplete";import*as r from"./List";import c from"./Search";import x from"./Filer";import y from"./Slider";import T from"./Switch";import f from"./Checker";import g from"./Segmented";import b from"./Color";import S from"./CollectForm";var o;(e=>(e.Plain=i,e.Hidden=a,e.TextField=p,e.Contenteditable=m,e.DigitCharacters=n,e.Time=l,e.Select=d,e.Autocomplete=s,e.List=r.List,e.Radio=r.Radio,e.Checkbox=r.Checkbox,e.Checker=f,e.Search=c,e.Filer=x,e.Slider=y,e.Switch=T,e.Segmented=g,e.Color=b,e.LeftIcon=t.LeftIcon,e.RightIcon=t.RightIcon,e.LeftIndicator=t.LeftIndicator,e.RightIndicator=t.RightIndicator,e.RequiredSign=t.RequiredSign,e.RequiredShortSign=t.RequiredShortSign,e.OmitSign=t.OmitSign,e.CollectForm=S))(o||(o={}));export{o as Input,o as default};
|