@1interface/widgets 0.4.0 → 0.5.0
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/{Chart.web-hrwFpYNo.js → Chart.web-ClszuBrC.js} +1 -1
- package/dist/{GoogleMapsComponent-BzTpTirq.js → GoogleMapsComponent-Bkv8dLp8.js} +1 -1
- package/dist/{Markdown.web-Cb6DGzuq.js → Markdown.web-B0cvTytd.js} +1 -1
- package/dist/{OpenStreetMapComponent-DwUAjMIU.js → OpenStreetMapComponent-BFVXLPw-.js} +1 -1
- package/dist/{constants-CoEHFWGs.js → constants-CqihBfAx.js} +1 -1
- package/dist/index-CYbTnXm0.js +1 -0
- package/dist/index.d.ts +65 -3
- package/dist/index.mjs +1 -1
- package/native/components/FileUploadRequest.js +1 -1
- package/native/components/Input.js +1 -1
- package/native/index.js +1 -1
- package/native/lib/utils.js +1 -1
- package/native/schema/action-types.js +1 -1
- package/native/schema/widget-types.js +1 -1
- package/native/state/context.js +1 -1
- package/native/state/reducer.js +1 -1
- package/native/theme/tokens.js +1 -1
- package/package.json +2 -2
- package/dist/index-CuqDLhq-.js +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -410,16 +410,28 @@ declare const BASE_TOKENS: {
|
|
|
410
410
|
};
|
|
411
411
|
};
|
|
412
412
|
readonly fileUpload: {
|
|
413
|
-
readonly rowGap:
|
|
413
|
+
readonly rowGap: 6;
|
|
414
414
|
readonly padV: 10;
|
|
415
415
|
readonly padH: 14;
|
|
416
|
-
readonly colGap:
|
|
416
|
+
readonly colGap: 3;
|
|
417
|
+
readonly iconSize: "xl";
|
|
418
|
+
readonly removeHitSlop: 12;
|
|
417
419
|
readonly label: {
|
|
418
420
|
readonly fontSize: 14;
|
|
419
421
|
readonly weight: "500";
|
|
422
|
+
readonly lineHeight: 17;
|
|
420
423
|
};
|
|
421
424
|
readonly hint: {
|
|
422
425
|
readonly fontSize: 11;
|
|
426
|
+
readonly lineHeight: 14;
|
|
427
|
+
};
|
|
428
|
+
readonly progress: {
|
|
429
|
+
readonly height: 3;
|
|
430
|
+
readonly marginTop: 5;
|
|
431
|
+
readonly uploadShare: 0.5;
|
|
432
|
+
readonly verifyCap: 0.97;
|
|
433
|
+
readonly verifyDurationMs: 12000;
|
|
434
|
+
readonly uploadCreepDurationMs: 12000;
|
|
423
435
|
};
|
|
424
436
|
};
|
|
425
437
|
readonly banner: {
|
|
@@ -1155,6 +1167,9 @@ declare interface FileUploadEntry {
|
|
|
1155
1167
|
loading?: boolean;
|
|
1156
1168
|
error?: string | null;
|
|
1157
1169
|
documentId?: string | null;
|
|
1170
|
+
phase?: UploadPhase;
|
|
1171
|
+
progress?: number | null;
|
|
1172
|
+
statusDetail?: string | null;
|
|
1158
1173
|
}
|
|
1159
1174
|
|
|
1160
1175
|
export declare function FileUploadRequest(p: FileUploadRequest_2): JSX.Element;
|
|
@@ -1172,6 +1187,8 @@ export declare type FileUploadRequestProps = {
|
|
|
1172
1187
|
messageId?: string;
|
|
1173
1188
|
maxFileSize?: number;
|
|
1174
1189
|
allowedFileExtensions?: string[];
|
|
1190
|
+
showProgress?: boolean;
|
|
1191
|
+
statusLabels?: Partial<Record<UploadPhase, string>>;
|
|
1175
1192
|
uploaded?: boolean;
|
|
1176
1193
|
fileName?: string | null;
|
|
1177
1194
|
error?: string | null;
|
|
@@ -1653,6 +1670,8 @@ export declare const REDUCER_ACTIONS: {
|
|
|
1653
1670
|
readonly REMOVE_FILE: "REMOVE_FILE";
|
|
1654
1671
|
readonly SET_UPLOAD_RESULT: "SET_UPLOAD_RESULT";
|
|
1655
1672
|
readonly SET_UPLOAD_ERROR: "SET_UPLOAD_ERROR";
|
|
1673
|
+
readonly SET_UPLOAD_PROGRESS: "SET_UPLOAD_PROGRESS";
|
|
1674
|
+
readonly SET_UPLOAD_PHASE: "SET_UPLOAD_PHASE";
|
|
1656
1675
|
readonly RESET_UPLOADS: "RESET_UPLOADS";
|
|
1657
1676
|
readonly SET_FORM_FIELD: "SET_FORM_FIELD";
|
|
1658
1677
|
};
|
|
@@ -2170,12 +2189,24 @@ declare interface Tokens {
|
|
|
2170
2189
|
padV: number;
|
|
2171
2190
|
padH: number;
|
|
2172
2191
|
colGap: number;
|
|
2192
|
+
iconSize: IconSizeKey;
|
|
2193
|
+
removeHitSlop: number;
|
|
2173
2194
|
label: {
|
|
2174
2195
|
fontSize: number;
|
|
2175
2196
|
weight: "500";
|
|
2197
|
+
lineHeight: number;
|
|
2176
2198
|
};
|
|
2177
2199
|
hint: {
|
|
2178
2200
|
fontSize: number;
|
|
2201
|
+
lineHeight: number;
|
|
2202
|
+
};
|
|
2203
|
+
progress: {
|
|
2204
|
+
height: number;
|
|
2205
|
+
marginTop: number;
|
|
2206
|
+
uploadShare: number;
|
|
2207
|
+
verifyCap: number;
|
|
2208
|
+
verifyDurationMs: number;
|
|
2209
|
+
uploadCreepDurationMs: number;
|
|
2179
2210
|
};
|
|
2180
2211
|
};
|
|
2181
2212
|
banner: {
|
|
@@ -2290,14 +2321,31 @@ export declare type TransitionProps = {
|
|
|
2290
2321
|
children: WidgetComponent;
|
|
2291
2322
|
};
|
|
2292
2323
|
|
|
2324
|
+
export declare const UPLOAD_PHASES: {
|
|
2325
|
+
readonly IDLE: "idle";
|
|
2326
|
+
readonly UPLOADING: "uploading";
|
|
2327
|
+
readonly PROCESSING: "processing";
|
|
2328
|
+
readonly DONE: "done";
|
|
2329
|
+
readonly ERROR: "error";
|
|
2330
|
+
};
|
|
2331
|
+
|
|
2293
2332
|
export declare type UploadFileHandler = (file: unknown, meta: {
|
|
2294
2333
|
fileRequestId: string;
|
|
2295
2334
|
documentType?: string;
|
|
2296
2335
|
fileName?: string | null;
|
|
2297
|
-
}) => Promise<{
|
|
2336
|
+
} & UploadProgressReporter) => Promise<{
|
|
2298
2337
|
documentId: string;
|
|
2299
2338
|
}>;
|
|
2300
2339
|
|
|
2340
|
+
export declare type UploadInFlightPhase = typeof UPLOAD_PHASES.UPLOADING | typeof UPLOAD_PHASES.PROCESSING;
|
|
2341
|
+
|
|
2342
|
+
export declare type UploadPhase = (typeof UPLOAD_PHASES)[keyof typeof UPLOAD_PHASES];
|
|
2343
|
+
|
|
2344
|
+
export declare interface UploadProgressReporter {
|
|
2345
|
+
onProgress?: (loaded: number, total: number) => void;
|
|
2346
|
+
onPhase?: (phase: UploadInFlightPhase, detail?: string) => void;
|
|
2347
|
+
}
|
|
2348
|
+
|
|
2301
2349
|
declare function useActionHandler(): ActionHandler_2;
|
|
2302
2350
|
export { useActionHandler as defaultActionHandler }
|
|
2303
2351
|
export { useActionHandler as useAction }
|
|
@@ -2533,6 +2581,20 @@ declare type WidgetStateAction = {
|
|
|
2533
2581
|
requestId: string;
|
|
2534
2582
|
error: string | null;
|
|
2535
2583
|
};
|
|
2584
|
+
} | {
|
|
2585
|
+
type: typeof REDUCER_ACTIONS.SET_UPLOAD_PROGRESS;
|
|
2586
|
+
payload: {
|
|
2587
|
+
requestId: string;
|
|
2588
|
+
loaded: number;
|
|
2589
|
+
total: number;
|
|
2590
|
+
};
|
|
2591
|
+
} | {
|
|
2592
|
+
type: typeof REDUCER_ACTIONS.SET_UPLOAD_PHASE;
|
|
2593
|
+
payload: {
|
|
2594
|
+
requestId: string;
|
|
2595
|
+
phase: UploadInFlightPhase;
|
|
2596
|
+
detail?: string;
|
|
2597
|
+
};
|
|
2536
2598
|
} | {
|
|
2537
2599
|
type: typeof REDUCER_ACTIONS.RESET_UPLOADS;
|
|
2538
2600
|
} | {
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as a,m as e,B as s,n as t,o as r,p as i,C as o,q as d,t as n,v as u,w as l,x as m,D as g,y as C,z as T,F as c,E as
|
|
1
|
+
import{A as a,m as e,B as s,n as t,o as r,p as i,C as o,q as d,t as n,v as u,w as l,x as m,D as g,y as C,z as T,F as c,E as S,G as p,I as A,H as I,J as x,L as F,K as R,N as W,O as E,R as O,P as N,Q as D,S as L,T as _,U as f,V as h,W as v,X as P,Y as U,Z as k,_ as B,$ as M,a0 as w,a1 as H,a2 as V,a3 as b,a4 as j,e as q,a5 as y,a6 as G,a7 as Y,a8 as z,a9 as J,aa as K,e as Q,e as X,ab as Z,ac as $,f as aa,ad as ea,a as sa,u as ta,ae as ra,af as ia,ag as oa,ah as da,ai as na,aj as ua}from"./index-CYbTnXm0.js";import"react/jsx-runtime";import"react";export{a as ACTION_TYPES,e as ActionHandlerContext,s as Badge,t as BasicRoot,r as Box,i as Button,o as CONSUMER_ACTIONS,d as Caption,n as Card,u as Chart,l as Checkbox,m as Col,g as DEFAULT_CONFIG,C as DatePicker,T as Divider,c as FileUploadRequest,S as Form,p as FormContext,A as Icon,I as Image,x as Input,F as Label,R as ListView,W as ListViewItem,E as Markdown,O as REDUCER_ACTIONS,N as RadioGroup,D as Row,L as SELF_CONTAINED_ACTIONS,_ as Select,f as Spacer,h as Text,v as Textarea,P as Title,U as Transition,k as UPLOAD_PHASES,B as Video,M as WidgetErrorBoundary,w as WidgetRenderer,H as WidgetStateManager,V as WidgetStateProvider,b as WidgetThemeProvider,j as configureMap,q as defaultActionHandler,y as formatOrderItems,G as markRequiredLabels,Y as mergeConfig,z as renderWidget,J as resolveTemplate,K as safeRenderWidget,Q as useAction,X as useActionHandler,Z as useFileUploadState,$ as useFormContext,aa as useMessageId,ea as useSelectedCategory,sa as useTheme,ta as useTokens,ra as useVariants,ia as useWidgetDispatch,oa as useWidgetState,da as useWidgetTheme,na as validateFields,ua as validateForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as d,jsxs as N}from"react/jsx-runtime";import{useEffect as E,useRef as Y,useState as X}from"react";import{Animated as g,Easing as m,Text as U,View as S,Pressable as M,Platform as J}from"react-native";import{ACTION_TYPES as R,UPLOAD_PHASES as i}from"../schema";import{PRIMITIVE_KINDS as Q,resolveStyle as Z,useTheme as q}from"../theme";import{useActionHandler as ee,useFileUploadState as te,useMessageId as ie}from"../state";import{Icon as T}from"./Icon";import{useRegisterRequired as oe,useFieldError as le}from"./Form";let P=null,h=null;try{P=require("expo-document-picker")}catch{P=null}try{h=require("expo-image-picker")}catch{h=null}function ne(e){return new Promise(t=>{const a=document.createElement("input");a.type="file",e&&(a.accept=e),a.style.display="none",document.body.appendChild(a);let o=!1,l;const u=O=>{o||(o=!0,clearTimeout(l),window.removeEventListener("focus",r),a.remove(),t(O))},r=()=>{clearTimeout(l),l=setTimeout(()=>{a.files&&a.files.length>0||u(null)},1e3)};a.addEventListener("change",()=>u(a.files?.[0]??null)),a.addEventListener("cancel",()=>u(null)),"oncancel"in a||window.addEventListener("focus",r),a.click()})}const ae=300,se=450;function re(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function ue({phase:e,progress:t}){const{tokens:a}=q(),o=a.fileUpload.progress,l=Y(new g.Value(0)).current;E(()=>{if(e!==i.UPLOADING)return;const r=t==null?g.timing(l,{toValue:o.uploadShare*.9,duration:o.uploadCreepDurationMs,easing:m.out(m.exp),useNativeDriver:!1}):g.timing(l,{toValue:t*o.uploadShare,duration:120,easing:m.linear,useNativeDriver:!1});return r.start(),()=>r.stop()},[e,t,l,o.uploadShare,o.uploadCreepDurationMs]),E(()=>{if(e!==i.DONE)return;const r=g.timing(l,{toValue:1,duration:250,easing:m.out(m.quad),useNativeDriver:!1});return r.start(),()=>r.stop()},[e,l]),E(()=>{if(e!==i.PROCESSING)return;const r=g.sequence([g.timing(l,{toValue:o.uploadShare,duration:200,easing:m.out(m.quad),useNativeDriver:!1}),g.timing(l,{toValue:o.verifyCap,duration:o.verifyDurationMs,easing:m.out(m.exp),useNativeDriver:!1})]);return r.start(),()=>r.stop()},[e,l,o.uploadShare,o.verifyCap,o.verifyDurationMs]);const u=l.interpolate({inputRange:[0,1],outputRange:["0%","100%"],extrapolate:"clamp"});return d(S,{style:{height:o.height,marginTop:o.marginTop,borderRadius:o.height/2,backgroundColor:a.color.border,overflow:"hidden"},children:d(g.View,{style:{height:"100%",width:u,borderRadius:o.height/2,backgroundColor:a.color.success.solid}})})}function Re(e){const{tokens:t,config:a}=q(),o=ee(),l=ie(),u=te(e.fileRequestId);oe(e.fileRequestId,e.required,"file");const r=le(e.fileRequestId),O=u?.uploaded??e.uploaded,b=u?.fileName??e.fileName,L=u?.fileSize??null,A=u?.error??e.error,F=u?.loading??!1,V=u?.progress??null,C=u?.statusDetail??null,s=u?.phase??(F?i.UPLOADING:A?i.ERROR:O?i.DONE:i.IDLE),f=s===i.UPLOADING||s===i.PROCESSING,D=t.icon.size[t.fileUpload.iconSize],[B,I]=X(!1);E(()=>{if(f){const n=setTimeout(()=>I(!0),ae);return()=>clearTimeout(n)}if(s===i.DONE){const n=setTimeout(()=>I(!1),se);return()=>clearTimeout(n)}return()=>I(!1)},[f,s]);const k=!!e.showProgress&&B&&(f||s===i.DONE),v=e.maxFileSize??a.fileUpload.maxSizeBytes,w=e.allowedFileExtensions??a.fileUpload.allowedExtensions;function _(n){if(n.size&&n.size>v)return`File too large (max ${Math.round(v/1024/1024)} MB)`;if(w.length>0&&n.name){const y=n.name.toLowerCase().split(".").pop()??"";if(!w.map(c=>c.replace(/^\./,"").toLowerCase()).includes(y))return`Unsupported extension .${y}`}return null}async function H(){try{let n=null;if(J.OS==="web"&&typeof document<"u"){const c=w.map(p=>p.startsWith(".")?p:`.${p}`).join(",");n=await ne(c)}else if(P?.getDocumentAsync){const c=await P.getDocumentAsync({type:"*/*"});!c.canceled&&c.assets&&c.assets[0]&&(n=c.assets[0])}else if(h?.launchImageLibraryAsync){const c=await h.launchImageLibraryAsync({mediaTypes:h.MediaTypeOptions?.Images,allowsMultipleSelection:!1});if(!c.canceled&&c.assets&&c.assets[0]){const p=c.assets[0];n={uri:p.uri,name:p.fileName??"photo.jpg",size:p.fileSize,mimeType:p.mimeType}}}else{o({type:R.UPLOAD_ERROR,payload:{fileRequestId:e.fileRequestId,error:"File picker unavailable. Install expo-document-picker or expo-image-picker.",...l?{messageId:l}:{}}});return}if(!n)return;const y=_(n);if(y){o({type:R.UPLOAD_ERROR,payload:{fileRequestId:e.fileRequestId,error:y,...l?{messageId:l}:{}}});return}o({type:R.UPLOAD_SELECT,payload:{fileRequestId:e.fileRequestId,file:n,label:e.label,...e.documentType?{documentType:e.documentType}:{},...l?{messageId:l}:{}}})}catch(n){const y=n instanceof Error?n.message:"File selection failed";o({type:R.UPLOAD_ERROR,payload:{fileRequestId:e.fileRequestId,error:y,...l?{messageId:l}:{}}})}}function G(){o({type:R.UPLOAD_REMOVE,payload:{fileRequestId:e.fileRequestId,...l?{messageId:l}:{}}})}const $={...t.layout.fileUpload.row,backgroundColor:t.color.surfaceAlt,borderRadius:t.radius.lg,gap:t.fileUpload.rowGap,paddingVertical:t.fileUpload.padV,paddingHorizontal:t.fileUpload.padH},j=Z($,Q.BOX,{hasBackground:!0}),W={[i.IDLE]:r??"Tap to select",[i.UPLOADING]:"Uploading\u2026",[i.PROCESSING]:"Processing\u2026",[i.DONE]:[b,L!=null?re(L):null].filter(Boolean).join(" \xB7 "),[i.ERROR]:[A,"Tap to retry"].filter(Boolean).join(" \xB7 ")},x=f&&!!r,z=[e.statusLabels?.[s]??W[s],C,x?"Please wait while it finishes":null].filter(Boolean).join(" \xB7 "),K=s===i.ERROR||s===i.IDLE&&r||x?t.color.danger.solid:t.color.textFaint;return N(M,{onPress:f||s===i.DONE?void 0:H,disabled:f,style:({pressed:n})=>[j,{opacity:n&&s!==i.DONE?t.ui.pressedOpacity:1}],accessibilityRole:"button",accessibilityState:{disabled:f,busy:f},accessibilityLabel:f?`${z} ${b??"file"}`:s===i.DONE?`Uploaded ${b??"file"}`:e.label,children:[s===i.ERROR?d(S,{style:{width:D,height:D,borderRadius:D/2,backgroundColor:t.color.danger.solid,alignItems:"center",justifyContent:"center"},children:d(T,{name:"x",size:"xs",color:t.color.danger.text})}):d(T,{name:s===i.DONE?"check-circle-filled":e.icon??"upload-01",size:t.fileUpload.iconSize,color:s===i.DONE?"success":"primary"}),N(S,{style:[t.layout.fileUpload.col,{gap:t.fileUpload.colGap}],children:[N(S,{style:[t.layout.label.row,{marginBottom:0}],children:[d(U,{style:{color:t.color.text,fontFamily:t.font.family,fontSize:t.fileUpload.label.fontSize,lineHeight:t.fileUpload.label.lineHeight,fontWeight:t.fileUpload.label.weight,flexShrink:1},numberOfLines:1,children:e.label}),e.required?d(U,{style:{color:t.color.danger.solid,fontFamily:t.font.family,fontSize:t.fileUpload.label.fontSize,lineHeight:t.fileUpload.label.lineHeight,marginLeft:t.text.requiredMarker.marginLeft},children:"*"}):null]}),d(U,{style:{color:K,fontFamily:t.font.family,fontSize:t.fileUpload.hint.fontSize,lineHeight:t.fileUpload.hint.lineHeight},numberOfLines:s===i.ERROR?2:1,children:z}),k?d(ue,{phase:s,progress:V}):null]}),s===i.DONE&&!k?d(M,{onPress:G,hitSlop:t.fileUpload.removeHitSlop,accessibilityRole:"button",accessibilityLabel:`Remove ${b??"file"}`,style:({pressed:n})=>({opacity:n?t.ui.pressedOpacity:1}),children:d(T,{name:"x",size:"lg",color:"secondary"})}):null]})}export{Re as FileUploadRequest};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as o,jsxs as
|
|
1
|
+
import{jsx as o,jsxs as _}from"react/jsx-runtime";import{useEffect as U,useRef as A,useState as S}from"react";import{Platform as X,Pressable as k,TextInput as j,View as v,Text as T}from"react-native";import{PRIMITIVE_KINDS as J,resolveStyle as Q,useTheme as D}from"../theme";import{controlRadius as R}from"../theme/style";import{useActionHandler as N,useMessageId as P,useWidgetDispatch as H,useWidgetState as M}from"../state";import{REDUCER_ACTIONS as O}from"../state";import{useRegisterRequired as Y,useFieldError as Z}from"./Form";import{applyMask as ee,isMaskedInputType as W}from"../lib/utils";function te(e){switch(e){case"email":return"email-address";case"number":case"currency":case"card_number":case"cvc":return"number-pad";case"tel":return"phone-pad";case"url":return"url";default:return"default"}}function ne(e){switch(e){case"email":return"email";case"password":return"password";case"tel":return"tel";case"card_number":return"cc-number";case"cvc":return"cc-csc";case"month_year":return"cc-exp";default:return}}function ye(e){const{tokens:t,variants:x}=D(),C=N(),h=H(),m=P(),s=M(),l=t.control.size[e.size],r=x.input[e.variant],I=e.gutterSize?t.control.size[e.gutterSize].padH:l.padH;Y(e.name,e.required,e.inputType??"text",e.pattern);const d=Z(e.name);if(e.inputType==="counter")return o(oe,{...e});const g=s.formFields[e.name],[a,w]=S(g??e.defaultValue??""),[n,y]=S(!1),E=!!d,f=W(e.inputType),[z,V]=S(void 0),F=A(null),p=A(null);U(()=>{a!==(s.formFields[e.name]??"")&&h({type:O.SET_FORM_FIELD,payload:{name:e.name,value:a}})},[a]);const B={...t.layout.input.wrap,borderRadius:R(e.size,t,e.pill),backgroundColor:r.bg,borderColor:r.border,borderWidth:r.borderWidth},K=Q(B,J.BOX,{controlHeightPx:l.h,hasBackground:r.bg!==void 0});function L(i){if(!f)return;const u=i.nativeEvent.target;if(typeof u?.selectionStart=="number"){p.current=u.selectionStart;return}const b=F.current;if(b){const c=i.nativeEvent.text??"";p.current=b.end+(c.length-a.length)}else p.current=null}function q(i){F.current=i.nativeEvent.selection,z&&V(void 0)}function $(i){let u=i;if(f&&W(e.inputType)){const b=p.current;p.current=null;const c=ee(e.inputType,i,b);u=c.value,c.caret!==null&&V({start:c.caret,end:c.caret})}w(u),e.onChangeAction&&C({...e.onChangeAction,payload:{...e.onChangeAction.payload??{},[e.name]:u,...m?{messageId:m}:{}}})}function G(){if(e.pattern)try{const i=new RegExp(e.pattern);y(!i.test(a))}catch{}}return _(v,{children:[o(v,{style:[K,E?{borderColor:t.color.danger.solid}:null],children:o(j,{value:a,onChange:f?L:void 0,onChangeText:$,onSelectionChange:f?q:void 0,selection:f?z:void 0,onBlur:G,placeholder:e.placeholder,placeholderTextColor:t.color.placeholder,editable:!e.disabled,autoFocus:e.autoFocus,selectTextOnFocus:!!e.autoSelect,secureTextEntry:e.inputType==="password",keyboardType:te(e.inputType),autoComplete:e.allowAutofillExtensions===!1?"off":ne(e.inputType),style:[t.layout.input.field,{fontSize:l.font,color:r.fg,caretColor:r.fg,fontFamily:t.font.family,outlineStyle:"none",paddingHorizontal:I,...X.OS==="web"?{height:"100%"}:{flex:1,paddingVertical:Math.max(6,(l.h-l.font-4)/2)},borderRadius:R(e.size,t,e.pill)},n?{color:t.color.danger.solid}:null]})}),E?o(T,{style:{color:t.color.danger.solid,fontSize:12,marginTop:4,fontFamily:t.font.family},children:d}):null]})}function oe(e){const{tokens:t}=D(),x=N(),C=H(),h=P(),m=M(),s=t.control.size[e.size],l=m.formFields[e.name]??e.defaultValue??"0",[r,I]=S(()=>parseInt(l,10)||0);function d(n){if(e.disabled)return;const y=Math.max(0,r+n);I(y),C({type:O.SET_FORM_FIELD,payload:{name:e.name,value:String(y)}}),e.onChangeAction&&x({...e.onChangeAction,payload:{...e.onChangeAction.payload??{},name:e.name,delta:n,value:y,...h?{messageId:h}:{}}})}const g=n=>({...t.layout.counter.btn,width:t.counter.btn,height:t.counter.btn,borderRadius:t.counter.btnRadius,opacity:n?t.ui.pressedOpacity:1}),a={color:t.color.text,fontSize:t.counter.glyph.fontSize,fontWeight:t.counter.glyph.weight,lineHeight:t.counter.glyph.lineHeight},w={height:s.h,minWidth:t.counter.valueMinWidth,paddingHorizontal:t.space[12],borderRadius:R(e.size,t,e.pill),borderColor:t.color.borderInput,borderWidth:t.ui.hairlineBorder,alignItems:"center",justifyContent:"center"};return _(v,{style:[t.layout.counter.row,{gap:t.counter.rowGap,height:s.h}],children:[o(k,{accessibilityLabel:`Decrease ${e.name}`,onPress:()=>d(-1),disabled:e.disabled,style:({pressed:n})=>g(n),children:o(T,{style:a,children:"\u2212"})}),o(v,{style:w,children:o(T,{style:[t.layout.counter.valueText,{color:t.color.text,fontSize:s.font,fontWeight:t.font.weight.normal}],children:r})}),o(k,{accessibilityLabel:`Increase ${e.name}`,onPress:()=>d(1),disabled:e.disabled,style:({pressed:n})=>g(n),children:o(T,{style:a,children:"+"})})]})}export{ye as Input};
|
package/native/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Badge as r}from"./components/Badge";import{BasicRoot as a}from"./components/BasicRoot";import{Box as
|
|
1
|
+
import{Badge as r}from"./components/Badge";import{BasicRoot as a}from"./components/BasicRoot";import{Box as i,Row as m,Col as d}from"./components/Box";import{Button as f}from"./components/Button";import{Card as s}from"./components/Card";import{Checkbox as g}from"./components/Checkbox";import{DatePicker as u}from"./components/DatePicker";import{Divider as S}from"./components/Divider";import{FileUploadRequest as T}from"./components/FileUploadRequest";import{Form as h}from"./components/Form";import{Icon as A}from"./components/Icon";import{Image as I}from"./components/Image";import{Video as V}from"./components/Video";import{Input as U}from"./components/Input";import{Label as O}from"./components/Text";import{ListView as v,ListViewItem as H}from"./components/ListView";import{RadioGroup as N}from"./components/RadioGroup";import{Select as B}from"./components/Select";import{Spacer as k}from"./components/Spacer";import{Text as q,Title as G,Caption as Y}from"./components/Text";import{Textarea as z}from"./components/Textarea";import{Transition as K}from"./components/Transition";import{ChartWidget as X}from"./components/ChartWidget";import{MarkdownWidget as $}from"./components/MarkdownWidget";import{WidgetThemeProvider as oe,useWidgetTheme as re}from"./compat/WidgetThemeContext";import{WidgetRenderer as ae}from"./WidgetRenderer";import{WidgetErrorBoundary as ie}from"./WidgetErrorBoundary";import{WidgetStateManager as de,useMessageId as ne,useSelectedCategory as fe,useFileUploadState as xe,WidgetStateProvider as se}from"./compat/WidgetStateContext";import{ACTION_TYPES as ge,SELF_CONTAINED_ACTIONS as Ce,CONSUMER_ACTIONS as ue,UPLOAD_PHASES as ce}from"./schema";import{renderWidget as We}from"./runtime";import{safeRenderWidget as ye}from"./utils/safeRender";import{useActionHandler as Re,formatOrderItems as Ae,resolveTemplate as Fe,ActionHandlerContext as Ie,defaultActionHandler as Pe}from"./utils/widgetUtils";import{useWidgetState as Ee,useWidgetDispatch as Ue,useActionHandler as Me}from"./state";import{REDUCER_ACTIONS as De}from"./state";import{validateFields as He}from"./utils/formValidationCore";import{validateForm as Ne,markRequiredLabels as we}from"./utils/formValidation";import{useFormContext as _e,FormContext as ke}from"./compat/FormContext";import{useTheme as qe,useTokens as Ge,useVariants as Ye}from"./theme";import{mergeConfig as ze,DEFAULT_CONFIG as Je}from"./config";import{configureMap as Qe}from"./components/Map";export{ge as ACTION_TYPES,Ie as ActionHandlerContext,r as Badge,a as BasicRoot,i as Box,f as Button,ue as CONSUMER_ACTIONS,Y as Caption,s as Card,X as Chart,g as Checkbox,d as Col,Je as DEFAULT_CONFIG,u as DatePicker,S as Divider,T as FileUploadRequest,h as Form,ke as FormContext,A as Icon,I as Image,U as Input,O as Label,v as ListView,H as ListViewItem,$ as Markdown,De as REDUCER_ACTIONS,N as RadioGroup,m as Row,Ce as SELF_CONTAINED_ACTIONS,B as Select,k as Spacer,q as Text,z as Textarea,G as Title,K as Transition,ce as UPLOAD_PHASES,V as Video,ie as WidgetErrorBoundary,ae as WidgetRenderer,de as WidgetStateManager,se as WidgetStateProvider,oe as WidgetThemeProvider,Qe as configureMap,Pe as defaultActionHandler,Ae as formatOrderItems,we as markRequiredLabels,ze as mergeConfig,We as renderWidget,Fe as resolveTemplate,ye as safeRenderWidget,Me as useAction,Re as useActionHandler,xe as useFileUploadState,_e as useFormContext,ne as useMessageId,fe as useSelectedCategory,qe as useTheme,Ge as useTokens,Ye as useVariants,Ue as useWidgetDispatch,Ee as useWidgetState,re as useWidgetTheme,He as validateFields,Ne as validateForm};
|
package/native/lib/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{clsx as
|
|
1
|
+
import{clsx as u}from"clsx";import{twMerge as l}from"tailwind-merge";function C(...e){return l(u(e))}const D=(e,t)=>{if(!e)return"";const r=e.split(" ");return r.length>t?r.slice(0,t).join(" "):e},$=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)}),k=(e,t=new Date)=>{if(!e)return"";const r=new Date(e);if(isNaN(r.getTime()))return"";const s=t.getTime()-r.getTime(),n=Math.floor(s/(1e3*60)),i=Math.floor(s/(1e3*60*60)),o=Math.floor(s/(1e3*60*60*24));return n<1?"Just now":n<60?`${n}m ago`:i<24?`${i}h ago`:o<7?`${o}d ago`:new Intl.DateTimeFormat("en-GB",{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(r)},A=e=>e?e.split(" ").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" "):"",I=e=>e?e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/^(.)/,t=>t.toUpperCase()).split(" ").map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" ").trim():"",S=e=>e?e.toLowerCase().replace(/[^a-z0-9\s]/g,"").replace(/\s+/g,"").trim():"",f=new Set(["card_number","month_year","cvc","currency"]);function E(e){return e!==void 0&&f.has(e)}function p(e){return e.replace(/\D/g,"").slice(0,19).replace(/(.{4})/g,"$1 ").trim()}function g(e){const t=e.replace(/\D/g,"").slice(0,4);return t.length<3?t:`${t.slice(0,2)}/${t.slice(2)}`}function x(e){return e.replace(/\D/g,"").slice(0,4)}function m(e){const t=e.replace(/[^\d.]/g,""),r=t.indexOf("."),s=(r===-1?t:t.slice(0,r)).replace(/\B(?=(\d{3})+(?!\d))/g,",");if(r===-1)return s;const n=t.slice(r+1).replace(/\./g,"").slice(0,2);return`${s}.${n}`}function d(e,t){switch(e){case"card_number":return p(t);case"month_year":return g(t);case"cvc":return x(t);case"currency":return m(t)}}function h(e){return e==="currency"?/[\d.]/:/\d/}function y(e,t,r){if(t<=0)return 0;let s=0;for(let n=0;n<e.length;n++)if(r.test(e[n])&&++s===t)return n+1;return e.length}function N(e,t,r){const s=d(e,t);if(r===null)return{value:s,caret:null};const n=h(e),i=Math.max(0,Math.min(r,t.length));let o=0;for(let a=0;a<i;a++)n.test(t[a])&&o++;let c=y(s,o,n);if(o>0&&i>0&&!n.test(t[i-1]))for(;c<s.length&&!n.test(s[c]);)c++;return{value:s,caret:c}}const M=e=>{const t=e.match(/^(\d{2})\/(\d{2})$/);if(!t)return!1;const r=Number(t[1]),s=Number(t[2]);if(r<1||r>12)return!1;const n=new Date,i=n.getFullYear()%100,o=n.getMonth()+1;return!(s<i||s===i&&r<o||r>12)},_=e=>{if(!e)return"";if(!M(e)){const t=e.match(/^(\d{2})\/(\d{2})$/);if(t){const r=Number(t[1]),s=Number(t[2]),n=new Date,i=n.getFullYear()%100,o=n.getMonth()+1;if(s<i||s===i&&r<o||r>12)return""}}return e};function v(e){return Array.isArray(e)&&Array.isArray(e[0])?e.flat():e}export{N as applyMask,A as capitalizeFirst,C as cn,x as formatCVC,I as formatCamelCaseToTitle,p as formatCardNumber,m as formatCurrency,g as formatExpiry,d as formatMasked,k as formatTimestamp,$ as generateUniqueId,v as getArrayOfObjects,E as isMaskedInputType,S as removeSpecialCharsAndSpaces,_ as sanitizeExpiryDate,D as truncateWordLimit,M as validateExpiryDate};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e={URL:"url",TABS:"tabs",DATA_CHECKBOX:"data-checkbox",DATA_SELECT:"data-select",QUANTITY_CHANGE:"quantity.change",UPLOAD_SELECT:"upload.select",UPLOAD_REMOVE:"upload.remove",UPLOAD_ERROR:"upload.error",REPLY:"reply",REPLY_TEMPLATE:"reply-template",UPLOAD_SUBMIT:"upload.submit",ORDER_SUBMIT:"order.submit",MODE_CHANGE:"mode-change"},
|
|
1
|
+
const e={URL:"url",TABS:"tabs",DATA_CHECKBOX:"data-checkbox",DATA_SELECT:"data-select",QUANTITY_CHANGE:"quantity.change",UPLOAD_SELECT:"upload.select",UPLOAD_REMOVE:"upload.remove",UPLOAD_ERROR:"upload.error",REPLY:"reply",REPLY_TEMPLATE:"reply-template",UPLOAD_SUBMIT:"upload.submit",ORDER_SUBMIT:"order.submit",MODE_CHANGE:"mode-change"},o=new Set([e.URL,e.TABS,e.DATA_CHECKBOX,e.DATA_SELECT,e.QUANTITY_CHANGE,e.UPLOAD_SELECT,e.UPLOAD_REMOVE,e.UPLOAD_ERROR]),t=new Set([e.REPLY,e.REPLY_TEMPLATE,e.UPLOAD_SUBMIT,e.ORDER_SUBMIT,e.MODE_CHANGE]),n={IDLE:"idle",UPLOADING:"uploading",PROCESSING:"processing",DONE:"done",ERROR:"error"};export{e as ACTION_TYPES,t as CONSUMER_ACTIONS,o as SELF_CONTAINED_ACTIONS,n as UPLOAD_PHASES};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e={Basic:"Basic",Card:"Card",ListView:"ListView",ListViewItem:"ListViewItem",Box:"Box",Row:"Row",Col:"Col",Form:"Form",Spacer:"Spacer",Divider:"Divider",Transition:"Transition",Title:"Title",Caption:"Caption",Text:"Text",Markdown:"Markdown",Badge:"Badge",Icon:"Icon",Image:"Image",Video:"Video",Button:"Button",Input:"Input",Textarea:"Textarea",Select:"Select",DatePicker:"DatePicker",Checkbox:"Checkbox",RadioGroup:"RadioGroup",Label:"Label",Chart:"Chart",FileUploadRequest:"FileUploadRequest",Map:"Map",MapMarker:"MapMarker",MapPolyline:"MapPolyline",MapCircle:"MapCircle",MapPolygon:"MapPolygon"},t={row:"row",col:"col"},o={ltr:"ltr",rtl:"rtl"},r={start:"start",center:"center",end:"end",baseline:"baseline",stretch:"stretch"},n={start:"start",center:"center",end:"end",between:"between",around:"around",evenly:"evenly",stretch:"stretch"},i={nowrap:"nowrap",wrap:"wrap","wrap-reverse":"wrap-reverse"},
|
|
1
|
+
const e={Basic:"Basic",Card:"Card",ListView:"ListView",ListViewItem:"ListViewItem",Box:"Box",Row:"Row",Col:"Col",Form:"Form",Spacer:"Spacer",Divider:"Divider",Transition:"Transition",Title:"Title",Caption:"Caption",Text:"Text",Markdown:"Markdown",Badge:"Badge",Icon:"Icon",Image:"Image",Video:"Video",Button:"Button",Input:"Input",Textarea:"Textarea",Select:"Select",DatePicker:"DatePicker",Checkbox:"Checkbox",RadioGroup:"RadioGroup",Label:"Label",Chart:"Chart",FileUploadRequest:"FileUploadRequest",Map:"Map",MapMarker:"MapMarker",MapPolyline:"MapPolyline",MapCircle:"MapCircle",MapPolygon:"MapPolygon"},t={row:"row",col:"col"},o={ltr:"ltr",rtl:"rtl"},r={start:"start",center:"center",end:"end",baseline:"baseline",stretch:"stretch"},n={start:"start",center:"center",end:"end",between:"between",around:"around",evenly:"evenly",stretch:"stretch"},i={nowrap:"nowrap",wrap:"wrap","wrap-reverse":"wrap-reverse"},s={start:"start",center:"center",end:"end"},p={normal:"normal",medium:"medium",semibold:"semibold",bold:"bold"},a={light:"light",dark:"dark"},l={clear:"clear"},y={"2xs":"2xs",xs:"xs",sm:"sm",md:"md",lg:"lg",xl:"xl","2xl":"2xl","3xl":"3xl","4xl":"4xl",full:"full","100%":"100%",none:"none"},g={solid:"solid",dashed:"dashed",dotted:"dotted",double:"double",groove:"groove",ridge:"ridge",inset:"inset",outset:"outset"},d={cover:"cover",contain:"contain",fill:"fill","scale-down":"scale-down",none:"none"},c={"top left":"top left",top:"top","top right":"top right",left:"left",center:"center",right:"right","bottom left":"bottom left",bottom:"bottom","bottom right":"bottom right"},x={solid:"solid",soft:"soft",outline:"outline",ghost:"ghost",tabs:"tabs"},u={soft:"soft",outline:"outline"},S={"3xs":"3xs","2xs":"2xs",xs:"xs",sm:"sm",md:"md",lg:"lg",xl:"xl","2xl":"2xl","3xl":"3xl"},b={"2xs":"2xs",xs:"xs",sm:"sm",md:"md",lg:"lg",xl:"xl"},m={"2xs":"2xs",xs:"xs",sm:"sm",md:"md",lg:"lg",xl:"xl","2xl":"2xl","3xl":"3xl"},T={sm:"sm",md:"md",lg:"lg",xl:"xl","2xl":"2xl","3xl":"3xl","4xl":"4xl","5xl":"5xl"},f={sm:"sm",md:"md",lg:"lg"},I={xs:"xs",sm:"sm",md:"md",lg:"lg",xl:"xl","2xl":"2xl","3xl":"3xl",button:"button"},C={sm:"sm",md:"md",lg:"lg",xl:"xl","2xl":"2xl"},P={sm:"sm",md:"md",lg:"lg",full:"full"},E={primary:"primary",secondary:"secondary",info:"info",discovery:"discovery",success:"success",caution:"caution",warning:"warning",danger:"danger"},k={primary:"primary",secondary:"secondary"},A={primary:"primary",secondary:"secondary",success:"success",danger:"danger",warning:"warning",info:"info",discovery:"discovery"},h={solid:"solid",soft:"soft",outline:"outline"},_={sm:"sm",md:"md",lg:"lg"},O={number:"number",currency:"currency",email:"email",text:"text",password:"password",tel:"tel",url:"url",card_number:"card_number",month_year:"month_year",cvc:"cvc",counter:"counter"},R={top:"top",bottom:"bottom",left:"left",right:"right"},M={start:"start",center:"center",end:"end"},B={auto:"auto",metadata:"metadata",none:"none"},V="auto",w={display:"display",input:"input"},N={bar:"bar",area:"area",line:"line"},D={basis:"basis",basisClosed:"basisClosed",basisOpen:"basisOpen",bumpX:"bumpX",bumpY:"bumpY",bump:"bump",linear:"linear",linearClosed:"linearClosed",natural:"natural",monotoneX:"monotoneX",monotoneY:"monotoneY",monotone:"monotone",step:"step",stepBefore:"stepBefore",stepAfter:"stepAfter"};export{r as ALIGNMENTS,A as BADGE_COLORS,_ as BADGE_SIZES,h as BADGE_VARIANTS,g as BORDER_STYLES,E as BUTTON_COLORS,C as BUTTON_ICON_SIZES,k as BUTTON_STYLE_SHORTHANDS,f as CAPTION_SIZES,P as CARD_SIZES,S as CONTROL_SIZES,x as CONTROL_VARIANTS,D as CURVE_TYPES,t as DIRECTIONS,d as FIT_MODES,p as FONT_WEIGHTS,b as GUTTER_SIZES,I as ICON_SIZES,c as IMAGE_POSITIONS,O as INPUT_TYPES,u as INPUT_VARIANTS,n as JUSTIFICATIONS,V as LIMIT_AUTO,w as MAP_MODES,M as POPOVER_ALIGNS,R as POPOVER_SIDES,B as PRELOAD_MODES,y as RADIUS_VALUES,N as SERIES_TYPES,s as TEXT_ALIGNS,o as TEXT_DIRECTIONS,m as TEXT_SIZES,a as THEME_MODES,l as TINTS,T as TITLE_SIZES,e as WIDGET_TYPES,i as WRAP_MODES};
|
package/native/state/context.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as b}from"react/jsx-runtime";import{createContext as L,useCallback as
|
|
1
|
+
import{jsx as b}from"react/jsx-runtime";import{createContext as L,useCallback as H,useContext as R,useMemo as N,useReducer as M,useRef as y}from"react";import{Linking as j}from"react-native";import{ACTION_TYPES as d,CONSUMER_ACTIONS as q,SELF_CONTAINED_ACTIONS as G}from"../schema";import{createInitialWidgetState as U,REDUCER_ACTIONS as a,widgetStateReducer as V}from"./reducer";import{useRendererConfig as B}from"../theme/ThemeContext";import{DEFAULT_CONFIG as Y}from"../config";const K=i=>{console.warn("[widget-renderer] action dispatched outside WidgetStateManager:",i)},k=L(K);function ne(){return R(k)}const E=L({state:U(),dispatch:()=>{}});function re({messageId:i,children:u,onConsumerAction:f,onUploadFile:c,onRemoveFile:r}){const[l,o]=M(V,void 0,U),S=B(),g=y(l);g.current=l;const T=y(f);T.current=f;const C=y(c);C.current=c;const m=y(r);m.current=r;const h=y(S);h.current=S;const _=y(i);_.current=i;const F=N(()=>({messageId:i,state:l,dispatch:o}),[i,l]),w=H(O=>{if(!O?.type)return;const p=O.type,t=O.payload||{};if(p===d.URL){const e=t.text;typeof e=="string"&&e&&j.openURL(e).catch(()=>{});return}if(G.has(p)){switch(p){case d.TABS:o({type:a.SET_SELECTED_CATEGORY,payload:{id:String(t.id??"")}});break;case d.DATA_CHECKBOX:case d.DATA_SELECT:o({type:a.TOGGLE_CHECKBOX,payload:{data:String(t.data??"")}});break;case d.QUANTITY_CHANGE:{const e=String(t.name??""),n=Number(t.delta??0);o({type:a.TOGGLE_QUANTITY,payload:{id:e,delta:Number.isFinite(n)?n:0}});break}case d.UPLOAD_SELECT:{const e=String(t.fileRequestId??""),n=t.file,A=typeof t.label=="string"?t.label:void 0,I=C.current;if(!I){o({type:a.UPLOAD_FILE,payload:{requestId:e,file:n,label:A}});break}const D=typeof t.documentType=="string"?t.documentType:void 0,W=n&&typeof n=="object"&&"name"in n&&String(n.name??"")||null,P=g.current.fileUpload.files[e]?.documentId,v=m.current;P&&v&&Promise.resolve(v(P)).catch(s=>{console.warn("[widget-renderer] document delete failed",s)}),o({type:a.UPLOAD_FILE,payload:{requestId:e,file:n,label:A,pending:!0}}),I(n,{fileRequestId:e,documentType:D,fileName:W,onProgress:(s,x)=>o({type:a.SET_UPLOAD_PROGRESS,payload:{requestId:e,loaded:s,total:x}}),onPhase:(s,x)=>o({type:a.SET_UPLOAD_PHASE,payload:{requestId:e,phase:s,detail:x}})}).then(s=>{o({type:a.SET_UPLOAD_RESULT,payload:{requestId:e,documentId:s.documentId}})}).catch(s=>{o({type:a.SET_UPLOAD_ERROR,payload:{requestId:e,error:s instanceof Error?s.message:"Upload failed"}})});break}case d.UPLOAD_REMOVE:{const e=String(t.fileRequestId??""),n=g.current.fileUpload.files[e]?.documentId,A=m.current;n&&A&&Promise.resolve(A(n)).catch(I=>{console.warn("[widget-renderer] document delete failed",I)}),o({type:a.REMOVE_FILE,payload:{requestId:e}});break}case d.UPLOAD_ERROR:o({type:a.SET_UPLOAD_ERROR,payload:{requestId:String(t.fileRequestId??""),error:typeof t.error=="string"?t.error:null}});break}return}if(q.has(p)){const e=g.current,n={...t};_.current&&!n.messageId&&(n.messageId=_.current),p===d.REPLY_TEMPLATE&&(n.resolvedText=Q(String(t.text??""),e,t,h.current)),p===d.ORDER_SUBMIT&&(n.resolvedText=X(e.formFields)),T.current?.({type:p,payload:n,state:e});return}console.warn("[widget-renderer] unhandled action",p,t)},[]);return b(E.Provider,{value:F,children:b(k.Provider,{value:w,children:u})})}function oe(){return R(E).state}function ie(){return R(E).dispatch}function ae(){return R(E).messageId}function se(){return R(E).state.selectedCategory}function de(i){return R(E).state.fileUpload.files[i]}function Q(i,u,f={},c=Y){let r=i;const l=u.checkboxes?.selected?.join(", ")||"";r=r.split(c.template.dataSelectToken).join(l),r=r.split(c.template.dataCheckboxToken).join(l);const{text:o,messageId:S,...g}=f,T=Object.values(g).filter(Boolean).join(", ");return r=r.split(c.template.dataInputToken).join(T),u.formFields&&(r=r.replace(new RegExp(c.template.dataFieldPattern.source,"g"),(C,m)=>u.formFields?.[m]||"")),r=r.replace(new RegExp(c.template.formPlaceholderPattern.source,"g"),(C,m)=>String(g[m.trim()]??"")),r}function X(i){const u=Object.entries(i),f=u.filter(([r])=>r.startsWith("items."));return(f.length>0?f:u).map(([r,l])=>{const o=Number(l);if(!Number.isFinite(o)||o<=0)return null;const S=r.replace(/^items\./,"");return`${o}x ${S}`}).filter(Boolean).join(", ")}export{k as ActionHandlerContext,re as WidgetStateManager,X as formatOrderItems,Q as resolveTemplate,ne as useActionHandler,de as useFileUploadState,ae as useMessageId,se as useSelectedCategory,ie as useWidgetDispatch,oe as useWidgetState};
|
package/native/state/reducer.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{UPLOAD_PHASES as s}from"../schema/action-types";function u(){return{fileUpload:{files:{},loading:!1,error:null},checkboxes:{selected:[],disabled:[],maxSelection:20},quantities:{},selectedCategory:void 0,formFields:{}}}const d={TOGGLE_CHECKBOX:"TOGGLE_CHECKBOX",SET_CHECKBOX_DATA:"SET_CHECKBOX_DATA",CLEAR_SELECTIONS:"CLEAR_SELECTIONS",SET_SELECTED_CATEGORY:"SET_SELECTED_CATEGORY",TOGGLE_QUANTITY:"TOGGLE_QUANTITY",UPLOAD_FILE:"UPLOAD_FILE",REMOVE_FILE:"REMOVE_FILE",SET_UPLOAD_RESULT:"SET_UPLOAD_RESULT",SET_UPLOAD_ERROR:"SET_UPLOAD_ERROR",SET_UPLOAD_PROGRESS:"SET_UPLOAD_PROGRESS",SET_UPLOAD_PHASE:"SET_UPLOAD_PHASE",RESET_UPLOADS:"RESET_UPLOADS",SET_FORM_FIELD:"SET_FORM_FIELD"};function _(e,r){switch(r.type){case d.TOGGLE_CHECKBOX:{const{data:l}=r.payload,{selected:i,maxSelection:o}=e.checkboxes;return i.includes(l)?{...e,checkboxes:{...e.checkboxes,selected:i.filter(n=>n!==l)}}:i.length>=o?e:{...e,checkboxes:{...e.checkboxes,selected:[...i,l]}}}case d.SET_CHECKBOX_DATA:{const{data:l,checked:i}=r.payload,{selected:o,maxSelection:n}=e.checkboxes,E=o.includes(l);return i===E?e:i?o.length>=n?e:{...e,checkboxes:{...e.checkboxes,selected:[...o,l]}}:{...e,checkboxes:{...e.checkboxes,selected:o.filter(a=>a!==l)}}}case d.CLEAR_SELECTIONS:return{...e,checkboxes:{...e.checkboxes,disabled:e.checkboxes.selected,selected:[]}};case d.SET_SELECTED_CATEGORY:return{...e,selectedCategory:r.payload.id};case d.TOGGLE_QUANTITY:{const{id:l,delta:i}=r.payload;if(!l||i===0)return e;const o=e.quantities[l]??0,n=Math.max(0,o+i),E={...e.quantities};return n===0?delete E[l]:E[l]=n,{...e,quantities:E}}case d.UPLOAD_FILE:{const{requestId:l,file:i,label:o,pending:n}=r.payload,E=(i&&typeof i=="object"&&"name"in i?String(i.name??""):null)||null,a=i&&typeof i=="object"&&"size"in i?i.size:null,p=typeof a=="number"?a:null,{[l]:f,...t}=e.formFields;return{...e,formFields:n?t:{...t,[l]:E??"uploaded"},fileUpload:{...e.fileUpload,loading:!1,files:{...e.fileUpload.files,[l]:{file:i,fileName:E,fileSize:p,label:o??null,uploaded:!n,loading:!!n,error:null,documentId:null,phase:n?s.UPLOADING:s.DONE,progress:null,statusDetail:null}}}}}case d.SET_UPLOAD_RESULT:{const{requestId:l,documentId:i}=r.payload;return e.fileUpload.files[l]?{...e,formFields:{...e.formFields,[l]:e.fileUpload.files[l]?.fileName??"uploaded"},fileUpload:{...e.fileUpload,files:{...e.fileUpload.files,[l]:{...e.fileUpload.files[l],uploaded:!0,loading:!1,error:null,documentId:i,phase:s.DONE,progress:null,statusDetail:null}}}}:e}case d.REMOVE_FILE:{const{requestId:l}=r.payload,{[l]:i,...o}=e.fileUpload.files,{[l]:n,...E}=e.formFields;return{...e,formFields:E,fileUpload:{...e.fileUpload,files:o}}}case d.SET_UPLOAD_ERROR:{const{requestId:l,error:i}=r.payload;if(!e.fileUpload.files[l])return e;const{[l]:o,...n}=e.formFields;return{...e,formFields:n,fileUpload:{...e.fileUpload,files:{...e.fileUpload.files,[l]:{...e.fileUpload.files[l],error:i,uploaded:!1,fileName:null,fileSize:null,loading:!1,documentId:null,phase:s.ERROR,progress:null,statusDetail:null}}}}}case d.SET_UPLOAD_PROGRESS:{const{requestId:l,loaded:i,total:o}=r.payload;return e.fileUpload.files[l]?{...e,fileUpload:{...e.fileUpload,files:{...e.fileUpload.files,[l]:{...e.fileUpload.files[l],progress:o>0?Math.min(1,Math.max(0,i/o)):null}}}}:e}case d.SET_UPLOAD_PHASE:{const{requestId:l,phase:i,detail:o}=r.payload;return e.fileUpload.files[l]?{...e,fileUpload:{...e.fileUpload,files:{...e.fileUpload.files,[l]:{...e.fileUpload.files[l],phase:i,loading:!0,statusDetail:o??null,progress:i===s.UPLOADING?e.fileUpload.files[l]?.progress??null:null}}}}:e}case d.RESET_UPLOADS:return{...e,fileUpload:u().fileUpload};case d.SET_FORM_FIELD:{const{name:l,value:i}=r.payload;return{...e,formFields:{...e.formFields,[l]:i}}}default:return e}}export{d as REDUCER_ACTIONS,u as createInitialWidgetState,_ as widgetStateReducer};
|
package/native/theme/tokens.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Platform as e}from"react-native";const r=3,s=1.2,i={xs:12,sm:14,md:16,lg:18,xl:20,"2xl":24,"3xl":32},n={xs:14,sm:16,md:18,lg:20,xl:22,"2xl":24,"3xl":26};function t(){try{return require("react-native")?.StyleSheet?.hairlineWidth??.5}catch{return .5}}const a={spacingUnit:r,space:{0:0,2:2,4:4,6:6,8:8,10:10,12:12,14:14,16:16,20:20,24:24,32:32},radius:{none:0,"2xs":2,xs:4,sm:6,md:8,lg:10,xl:12,"2xl":16,"3xl":20,"4xl":24,pill:9999},font:{family:"System",monoFamily:"monospace",baseSize:14,weight:{normal:"400",medium:"500",semibold:e.OS==="android"?"700":"600",bold:"700"},size:{text:{"2xs":10,...i},title:{sm:18,md:20,lg:24,xl:32,"2xl":36,"3xl":48,"4xl":60,"5xl":72},caption:{sm:14,md:16,lg:18}}},color:{surface:"#FFFFFF",surfaceAlt:"#F4F4F5",surfaceTertiary:"#F3F3F3",text:"#1A1A1A",textMuted:"#6B6B6B",textFaint:"#9B9B9B",placeholder:"#9B9B9B",border:"rgba(0,0,0,0.1)",borderInput:"rgba(0,0,0,0.1)",transparent:"transparent",primary:{solid:"#3B4FFE",bg:"#E5F3FF",text:"#FFFFFF"},secondary:{solid:"#5D5D5D",bg:"#F3F3F3",text:"#0D0D0D"},success:{solid:"#00A240",bg:"#D9F4E4",text:"#FFFFFF"},danger:{solid:"#E02E2A",bg:"#FFD9D9",text:"#FFFFFF"},warning:{solid:"#E25507",bg:"#FFE4D0",text:"#FFFFFF"},info:{solid:"#0285FF",bg:"#D7ECFF",text:"#FFFFFF"},discovery:{solid:"#8B5CF6",bg:"#EDE6FF",text:"#FFFFFF"}},control:{size:{"3xs":{h:22,padH:6,font:12,gap:3,iconPx:12,radiusScale:.375},"2xs":{h:24,padH:8,font:12,gap:4,iconPx:12,radiusScale:.375},xs:{h:26,padH:8,font:14,gap:4,iconPx:14,radiusScale:.375},sm:{h:28,padH:10,font:14,gap:4,iconPx:16,radiusScale:.375},md:{h:32,padH:12,font:14,gap:6,iconPx:18,radiusScale:.5},lg:{h:36,padH:12,font:14,gap:6,iconPx:20,radiusScale:.5},xl:{h:40,padH:14,font:16,gap:6,iconPx:22,radiusScale:.625},"2xl":{h:44,padH:16,font:16,gap:6,iconPx:24,radiusScale:.625},"3xl":{h:48,padH:16,font:16,gap:6,iconPx:24,radiusScale:.625}}},badge:{size:{sm:{padH:5,font:12,lineHeight:20,radiusScale:.25},md:{padH:6,font:14,lineHeight:22,radiusScale:.25},lg:{padH:8,font:14,lineHeight:24,radiusScale:.375}},gap:4,fontWeight:e.OS==="android"?"700":"600"},card:{size:{sm:400,md:448,lg:800,full:9999},defaultPadPx:16,contentGap:12,actionRowGap:8,shellGap:12,actionButtonSize:"lg"},icon:{size:{button:18,...n},wrapperPad:6,wrapperRoundingPct:.2},ui:{disabledOpacity:.5,pressedOpacity:.85,pressedOverlayAlpha:.04,hairlineAlpha:.1,hairlineBorder:t(),cardBorderWidth:t()},button:{alwaysPill:!1},checkbox:{size:18,borderWidth:1.5,radius:4,tick:{fontSize:12,lineHeight:14,weight:"700"},rowGap:8},radio:{ring:20,ringBorder:2,dot:10,rowGap:8,groupGap:12},counter:{btn:32,btnRadius:8,glyph:{fontSize:20,lineHeight:22,weight:e.OS==="android"?"700":"400"},valueMinWidth:24,rowGap:8},modal:{backdrop:"rgba(0,0,0,0.4)",sheetMaxHeight:"60%",sheetTopRadius:16,sheetPadV:4,optionPadV:12,optionPadH:16},overlay:{video:"rgba(0,0,0,0.15)",videoDefaultH:200},glass:{fallbackBg:"rgba(255,255,255,0.04)",fallbackBorder:"rgba(255,255,255,0.10)",fallbackBorderWidth:.5,webFilter:"blur(40px) saturate(1.3) brightness(1.1)",nativeIntensity:28,nativeTint:{dark:"systemUltraThinMaterialDark",light:"systemUltraThinMaterialLight"},androidTint:{dark:"dark",light:"light"},androidBlurMethod:"dimezisBlurView"},placeholder:{padding:16,minHeight:80,innerGap:4,borderWidth:1,label:{fontSize:13,weight:e.OS==="android"?"700":"600"},note:{fontSize:11}},fileUpload:{rowGap:
|
|
1
|
+
import{Platform as e}from"react-native";const r=3,s=1.2,i={xs:12,sm:14,md:16,lg:18,xl:20,"2xl":24,"3xl":32},n={xs:14,sm:16,md:18,lg:20,xl:22,"2xl":24,"3xl":26};function t(){try{return require("react-native")?.StyleSheet?.hairlineWidth??.5}catch{return .5}}const a={spacingUnit:r,space:{0:0,2:2,4:4,6:6,8:8,10:10,12:12,14:14,16:16,20:20,24:24,32:32},radius:{none:0,"2xs":2,xs:4,sm:6,md:8,lg:10,xl:12,"2xl":16,"3xl":20,"4xl":24,pill:9999},font:{family:"System",monoFamily:"monospace",baseSize:14,weight:{normal:"400",medium:"500",semibold:e.OS==="android"?"700":"600",bold:"700"},size:{text:{"2xs":10,...i},title:{sm:18,md:20,lg:24,xl:32,"2xl":36,"3xl":48,"4xl":60,"5xl":72},caption:{sm:14,md:16,lg:18}}},color:{surface:"#FFFFFF",surfaceAlt:"#F4F4F5",surfaceTertiary:"#F3F3F3",text:"#1A1A1A",textMuted:"#6B6B6B",textFaint:"#9B9B9B",placeholder:"#9B9B9B",border:"rgba(0,0,0,0.1)",borderInput:"rgba(0,0,0,0.1)",transparent:"transparent",primary:{solid:"#3B4FFE",bg:"#E5F3FF",text:"#FFFFFF"},secondary:{solid:"#5D5D5D",bg:"#F3F3F3",text:"#0D0D0D"},success:{solid:"#00A240",bg:"#D9F4E4",text:"#FFFFFF"},danger:{solid:"#E02E2A",bg:"#FFD9D9",text:"#FFFFFF"},warning:{solid:"#E25507",bg:"#FFE4D0",text:"#FFFFFF"},info:{solid:"#0285FF",bg:"#D7ECFF",text:"#FFFFFF"},discovery:{solid:"#8B5CF6",bg:"#EDE6FF",text:"#FFFFFF"}},control:{size:{"3xs":{h:22,padH:6,font:12,gap:3,iconPx:12,radiusScale:.375},"2xs":{h:24,padH:8,font:12,gap:4,iconPx:12,radiusScale:.375},xs:{h:26,padH:8,font:14,gap:4,iconPx:14,radiusScale:.375},sm:{h:28,padH:10,font:14,gap:4,iconPx:16,radiusScale:.375},md:{h:32,padH:12,font:14,gap:6,iconPx:18,radiusScale:.5},lg:{h:36,padH:12,font:14,gap:6,iconPx:20,radiusScale:.5},xl:{h:40,padH:14,font:16,gap:6,iconPx:22,radiusScale:.625},"2xl":{h:44,padH:16,font:16,gap:6,iconPx:24,radiusScale:.625},"3xl":{h:48,padH:16,font:16,gap:6,iconPx:24,radiusScale:.625}}},badge:{size:{sm:{padH:5,font:12,lineHeight:20,radiusScale:.25},md:{padH:6,font:14,lineHeight:22,radiusScale:.25},lg:{padH:8,font:14,lineHeight:24,radiusScale:.375}},gap:4,fontWeight:e.OS==="android"?"700":"600"},card:{size:{sm:400,md:448,lg:800,full:9999},defaultPadPx:16,contentGap:12,actionRowGap:8,shellGap:12,actionButtonSize:"lg"},icon:{size:{button:18,...n},wrapperPad:6,wrapperRoundingPct:.2},ui:{disabledOpacity:.5,pressedOpacity:.85,pressedOverlayAlpha:.04,hairlineAlpha:.1,hairlineBorder:t(),cardBorderWidth:t()},button:{alwaysPill:!1},checkbox:{size:18,borderWidth:1.5,radius:4,tick:{fontSize:12,lineHeight:14,weight:"700"},rowGap:8},radio:{ring:20,ringBorder:2,dot:10,rowGap:8,groupGap:12},counter:{btn:32,btnRadius:8,glyph:{fontSize:20,lineHeight:22,weight:e.OS==="android"?"700":"400"},valueMinWidth:24,rowGap:8},modal:{backdrop:"rgba(0,0,0,0.4)",sheetMaxHeight:"60%",sheetTopRadius:16,sheetPadV:4,optionPadV:12,optionPadH:16},overlay:{video:"rgba(0,0,0,0.15)",videoDefaultH:200},glass:{fallbackBg:"rgba(255,255,255,0.04)",fallbackBorder:"rgba(255,255,255,0.10)",fallbackBorderWidth:.5,webFilter:"blur(40px) saturate(1.3) brightness(1.1)",nativeIntensity:28,nativeTint:{dark:"systemUltraThinMaterialDark",light:"systemUltraThinMaterialLight"},androidTint:{dark:"dark",light:"light"},androidBlurMethod:"dimezisBlurView"},placeholder:{padding:16,minHeight:80,innerGap:4,borderWidth:1,label:{fontSize:13,weight:e.OS==="android"?"700":"600"},note:{fontSize:11}},fileUpload:{rowGap:6,padV:10,padH:14,colGap:3,iconSize:"xl",removeHitSlop:12,label:{fontSize:14,weight:"500",lineHeight:17},hint:{fontSize:11,lineHeight:14},progress:{height:3,marginTop:5,uploadShare:.5,verifyCap:.97,verifyDurationMs:12e3,uploadCreepDurationMs:12e3}},banner:{padV:8,padH:12,gap:6,defaultTextSize:"sm"},listItem:{gap:4,padV:8},text:{captionOpacity:.9,titleLetterSpacing:-.1,requiredMarker:{marginLeft:4}},layout:{button:{base:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",justifyContent:"center"},block:{alignSelf:"stretch",flexShrink:1,...e.OS==="web"?{width:"100%"}:{flex:1}}},badge:{pill:{flexDirection:"row",alignItems:"center",justifyContent:"center"}},card:{shell:{width:"100%",flexShrink:0},wrapper:{width:"100%",overflow:"hidden"},banner:{flexDirection:"row",alignItems:"center"},actionRow:{flexDirection:"row",flexWrap:"wrap",justifyContent:"flex-start",alignItems:"center",width:"100%",flexShrink:0}},checkbox:{row:{flexDirection:"row",alignItems:"center"},box:{alignItems:"center",justifyContent:"center"}},radio:{row:{flexDirection:"row",alignItems:"center"},ring:{alignItems:"center",justifyContent:"center"},group:{flexWrap:"wrap"}},counter:{row:{flexDirection:"row",alignItems:"center"},btn:{alignItems:"center",justifyContent:"center"},valueText:{textAlign:"center"}},input:{wrap:{justifyContent:"center"},field:{flex:1}},select:{backdrop:{flex:1,justifyContent:"flex-end"},trigger:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},block:{alignSelf:"stretch"},sheetList:{flexGrow:0},option:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},label:{flex:1}},textarea:{input:{textAlignVertical:"top"}},datePicker:{input:{flex:1}},label:{row:{flexDirection:"row",alignItems:"center",marginBottom:4}},fileUpload:{row:{flexDirection:"row",alignItems:"center"},col:{flex:1}},placeholder:{wrap:{borderStyle:"dashed",alignItems:"center",justifyContent:"center"}},video:{wrap:{overflow:"hidden",alignItems:"center",justifyContent:"center"},overlay:{alignItems:"center",justifyContent:"center"}},icon:{wrapper:{alignItems:"center",justifyContent:"center",flexShrink:0}},image:{base:{backgroundColor:"transparent"},placeholder:{alignItems:"center",justifyContent:"center"}},divider:{base:{alignSelf:"stretch"}},spacer:{base:{flex:1}},listItem:{row:{flexDirection:"row",alignSelf:"stretch"}},backgroundFill:{imageWrap:{overflow:"hidden"}}}};function p(){return JSON.parse(JSON.stringify(a))}export{a as BASE_TOKENS,n as ICON_SIZE_SCALE,s as LINE_HEIGHT_RATIO,r as SPACING_UNIT,i as TEXT_SIZE_SCALE,p as freshTokens};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1interface/widgets",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"private": false,
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"expo-blur": ">=12.0.0",
|
|
37
|
-
"expo-glass-effect": ">=0.1.0",
|
|
38
37
|
"expo-document-picker": ">=12.0.0",
|
|
38
|
+
"expo-glass-effect": ">=0.1.0",
|
|
39
39
|
"expo-image-picker": ">=15.0.0",
|
|
40
40
|
"expo-linear-gradient": ">=13.0.0",
|
|
41
41
|
"expo-video": ">=2.0.0",
|