@1interface/widgets 0.2.0-pipecat.1 → 0.3.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-DQzthytj.js → Chart.web-7wK30Xx9.js} +1 -1
- package/dist/{GoogleMapsComponent-CtYLbyvO.js → GoogleMapsComponent-BEeDydF3.js} +1 -1
- package/dist/{Markdown.web-vx2MyFJ8.js → Markdown.web-BuJtqZgM.js} +1 -1
- package/dist/{OpenStreetMapComponent-BWRPzQtp.js → OpenStreetMapComponent-BVnEhsoE.js} +1 -1
- package/dist/{constants-D8-vgQM1.js → constants-B7-_Bev7.js} +1 -1
- package/dist/index-Bdg5lAns.js +1 -0
- package/dist/index.d.ts +41 -2
- package/dist/index.mjs +1 -1
- package/native/WidgetRenderer.js +16 -2
- package/native/WidgetRenderer.native.js +1 -1
- package/native/compat/WidgetStateContext.js +1 -1
- package/native/components/FileUploadRequest.js +1 -1
- package/native/index.js +1 -1
- package/native/runtime/rootAnchor.js +1 -0
- 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/resolveBranding.js +1 -1
- package/package.json +1 -1
- package/dist/index-DvAx4AnX.js +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1149,9 +1149,12 @@ export declare interface FieldDescriptor {
|
|
|
1149
1149
|
declare interface FileUploadEntry {
|
|
1150
1150
|
file?: unknown;
|
|
1151
1151
|
fileName?: string | null;
|
|
1152
|
+
fileSize?: number | null;
|
|
1153
|
+
label?: string | null;
|
|
1152
1154
|
uploaded?: boolean;
|
|
1153
1155
|
loading?: boolean;
|
|
1154
1156
|
error?: string | null;
|
|
1157
|
+
documentId?: string | null;
|
|
1155
1158
|
}
|
|
1156
1159
|
|
|
1157
1160
|
export declare function FileUploadRequest(p: FileUploadRequest_2): JSX.Element;
|
|
@@ -1163,6 +1166,8 @@ export declare type FileUploadRequestProps = {
|
|
|
1163
1166
|
key?: string;
|
|
1164
1167
|
label: string;
|
|
1165
1168
|
fileRequestId: string;
|
|
1169
|
+
documentType?: string;
|
|
1170
|
+
required?: boolean;
|
|
1166
1171
|
icon: string;
|
|
1167
1172
|
messageId?: string;
|
|
1168
1173
|
maxFileSize?: number;
|
|
@@ -1645,11 +1650,14 @@ export declare const REDUCER_ACTIONS: {
|
|
|
1645
1650
|
readonly TOGGLE_QUANTITY: "TOGGLE_QUANTITY";
|
|
1646
1651
|
readonly UPLOAD_FILE: "UPLOAD_FILE";
|
|
1647
1652
|
readonly REMOVE_FILE: "REMOVE_FILE";
|
|
1653
|
+
readonly SET_UPLOAD_RESULT: "SET_UPLOAD_RESULT";
|
|
1648
1654
|
readonly SET_UPLOAD_ERROR: "SET_UPLOAD_ERROR";
|
|
1649
1655
|
readonly RESET_UPLOADS: "RESET_UPLOADS";
|
|
1650
1656
|
readonly SET_FORM_FIELD: "SET_FORM_FIELD";
|
|
1651
1657
|
};
|
|
1652
1658
|
|
|
1659
|
+
export declare type RemoveFileHandler = (documentId: string) => Promise<void> | void;
|
|
1660
|
+
|
|
1653
1661
|
export declare interface RendererConfig {
|
|
1654
1662
|
scroll: {
|
|
1655
1663
|
allowOrthogonalAxis: boolean;
|
|
@@ -1837,6 +1845,11 @@ export declare const TEXT_ALIGNS: {
|
|
|
1837
1845
|
readonly end: "end";
|
|
1838
1846
|
};
|
|
1839
1847
|
|
|
1848
|
+
export declare const TEXT_DIRECTIONS: {
|
|
1849
|
+
readonly ltr: "ltr";
|
|
1850
|
+
readonly rtl: "rtl";
|
|
1851
|
+
};
|
|
1852
|
+
|
|
1840
1853
|
export declare const TEXT_SIZES: {
|
|
1841
1854
|
readonly "2xs": "2xs";
|
|
1842
1855
|
readonly xs: "xs";
|
|
@@ -1875,6 +1888,8 @@ export declare type TextareaProps = {
|
|
|
1875
1888
|
allowAutofillExtensions?: boolean;
|
|
1876
1889
|
};
|
|
1877
1890
|
|
|
1891
|
+
export declare type TextDirection = (typeof TEXT_DIRECTIONS)[keyof typeof TEXT_DIRECTIONS];
|
|
1892
|
+
|
|
1878
1893
|
export declare type TextProps = {
|
|
1879
1894
|
type: "Text";
|
|
1880
1895
|
key?: string;
|
|
@@ -2274,6 +2289,14 @@ export declare type TransitionProps = {
|
|
|
2274
2289
|
children: WidgetComponent;
|
|
2275
2290
|
};
|
|
2276
2291
|
|
|
2292
|
+
export declare type UploadFileHandler = (file: unknown, meta: {
|
|
2293
|
+
fileRequestId: string;
|
|
2294
|
+
documentType?: string;
|
|
2295
|
+
fileName?: string | null;
|
|
2296
|
+
}) => Promise<{
|
|
2297
|
+
documentId: string;
|
|
2298
|
+
}>;
|
|
2299
|
+
|
|
2277
2300
|
declare function useActionHandler(): ActionHandler_2;
|
|
2278
2301
|
export { useActionHandler as defaultActionHandler }
|
|
2279
2302
|
export { useActionHandler as useAction }
|
|
@@ -2406,6 +2429,7 @@ export declare interface WidgetBrandingStyles {
|
|
|
2406
2429
|
statusInfo: StatusThemeVariant;
|
|
2407
2430
|
statusDiscovery: StatusThemeVariant;
|
|
2408
2431
|
fontFamily: string;
|
|
2432
|
+
fontFamilyMono?: string;
|
|
2409
2433
|
fontSize: number;
|
|
2410
2434
|
borderRadius: number;
|
|
2411
2435
|
cornerRadiusMode: "pill" | "rounded" | "sharp";
|
|
@@ -2438,7 +2462,7 @@ export declare interface WidgetInternalState {
|
|
|
2438
2462
|
formFields: Record<string, string>;
|
|
2439
2463
|
}
|
|
2440
2464
|
|
|
2441
|
-
export declare function WidgetRenderer({ widget, branding, brandingStyles, theme, messageId, onConsumerAction, config, errorFallback, userLocation, }: WidgetRendererProps): default_2.JSX.Element | null;
|
|
2465
|
+
export declare function WidgetRenderer({ widget, branding, brandingStyles, theme, messageId, onConsumerAction, onUploadFile, onRemoveFile, config, errorFallback, userLocation, direction, }: WidgetRendererProps): default_2.JSX.Element | null;
|
|
2442
2466
|
|
|
2443
2467
|
export declare interface WidgetRendererProps {
|
|
2444
2468
|
widget: WidgetRoot | WidgetComponent | null;
|
|
@@ -2447,9 +2471,12 @@ export declare interface WidgetRendererProps {
|
|
|
2447
2471
|
theme?: ThemeMode;
|
|
2448
2472
|
messageId?: string;
|
|
2449
2473
|
onConsumerAction?: (action: ConsumerAction) => void;
|
|
2474
|
+
onUploadFile?: UploadFileHandler;
|
|
2475
|
+
onRemoveFile?: RemoveFileHandler;
|
|
2450
2476
|
config?: DeepPartial<RendererConfig>;
|
|
2451
2477
|
errorFallback?: ReactNode;
|
|
2452
2478
|
userLocation?: LocationCoordinates | null;
|
|
2479
|
+
direction?: TextDirection;
|
|
2453
2480
|
}
|
|
2454
2481
|
|
|
2455
2482
|
export declare type WidgetRoot = Card_2 | ListView_2 | BasicRoot_2;
|
|
@@ -2485,12 +2512,20 @@ declare type WidgetStateAction = {
|
|
|
2485
2512
|
payload: {
|
|
2486
2513
|
requestId: string;
|
|
2487
2514
|
file: unknown;
|
|
2515
|
+
label?: string;
|
|
2516
|
+
pending?: boolean;
|
|
2488
2517
|
};
|
|
2489
2518
|
} | {
|
|
2490
2519
|
type: typeof REDUCER_ACTIONS.REMOVE_FILE;
|
|
2491
2520
|
payload: {
|
|
2492
2521
|
requestId: string;
|
|
2493
2522
|
};
|
|
2523
|
+
} | {
|
|
2524
|
+
type: typeof REDUCER_ACTIONS.SET_UPLOAD_RESULT;
|
|
2525
|
+
payload: {
|
|
2526
|
+
requestId: string;
|
|
2527
|
+
documentId: string;
|
|
2528
|
+
};
|
|
2494
2529
|
} | {
|
|
2495
2530
|
type: typeof REDUCER_ACTIONS.SET_UPLOAD_ERROR;
|
|
2496
2531
|
payload: {
|
|
@@ -2507,11 +2542,13 @@ declare type WidgetStateAction = {
|
|
|
2507
2542
|
};
|
|
2508
2543
|
};
|
|
2509
2544
|
|
|
2510
|
-
export declare function WidgetStateManager({ messageId, children, onConsumerAction, }: WidgetStateManagerProps_2): JSX.Element;
|
|
2545
|
+
export declare function WidgetStateManager({ messageId, children, onConsumerAction, onUploadFile, onRemoveFile, }: WidgetStateManagerProps_2): JSX.Element;
|
|
2511
2546
|
|
|
2512
2547
|
export declare type WidgetStateManagerProps = {
|
|
2513
2548
|
messageId?: string;
|
|
2514
2549
|
onConsumerAction?: (action: any) => void;
|
|
2550
|
+
onUploadFile?: UploadFileHandler;
|
|
2551
|
+
onRemoveFile?: RemoveFileHandler;
|
|
2515
2552
|
children?: ReactNode;
|
|
2516
2553
|
};
|
|
2517
2554
|
|
|
@@ -2519,6 +2556,8 @@ declare interface WidgetStateManagerProps_2 {
|
|
|
2519
2556
|
messageId?: string;
|
|
2520
2557
|
children: ReactNode;
|
|
2521
2558
|
onConsumerAction?: OnConsumerAction;
|
|
2559
|
+
onUploadFile?: UploadFileHandler;
|
|
2560
|
+
onRemoveFile?: RemoveFileHandler;
|
|
2522
2561
|
}
|
|
2523
2562
|
|
|
2524
2563
|
export declare const WidgetStateProvider: typeof WidgetStateManager;
|
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 p,G as S,I,H as x,J as A,L as F,K as R,N as W,O as E,R as N,P as O,Q as f,S as h,T as v,U as D,V as L,W as _,X as k,Y as B,Z as M,_ as U,$ as w,a0 as P,a1 as V,a2 as b,a3 as H,e as j,a4 as q,a5 as y,a6 as G,a7 as Y,a8 as z,a9 as J,e as K,e as Q,aa as X,ab as Z,f as $,ac as aa,a as ea,u as sa,ad as ta,ae as ra,af as ia,ag as oa,ah as da,ai as na}from"./index-
|
|
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 p,G as S,I,H as x,J as A,L as F,K as R,N as W,O as E,R as N,P as O,Q as f,S as h,T as v,U as D,V as L,W as _,X as k,Y as B,Z as M,_ as U,$ as w,a0 as P,a1 as V,a2 as b,a3 as H,e as j,a4 as q,a5 as y,a6 as G,a7 as Y,a8 as z,a9 as J,e as K,e as Q,aa as X,ab as Z,f as $,ac as aa,a as ea,u as sa,ad as ta,ae as ra,af as ia,ag as oa,ah as da,ai as na}from"./index-Bdg5lAns.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,p as Form,S as FormContext,I as Icon,x as Image,A as Input,F as Label,R as ListView,W as ListViewItem,E as Markdown,N as REDUCER_ACTIONS,O as RadioGroup,f as Row,h as SELF_CONTAINED_ACTIONS,v as Select,D as Spacer,L as Text,_ as Textarea,k as Title,B as Transition,M as Video,U as WidgetErrorBoundary,w as WidgetRenderer,P as WidgetStateManager,V as WidgetStateProvider,b as WidgetThemeProvider,H as configureMap,j as defaultActionHandler,q as formatOrderItems,y as markRequiredLabels,G as mergeConfig,Y as renderWidget,z as resolveTemplate,J as safeRenderWidget,K as useAction,Q as useActionHandler,X as useFileUploadState,Z as useFormContext,$ as useMessageId,aa as useSelectedCategory,ea as useTheme,sa as useTokens,ta as useVariants,ra as useWidgetDispatch,ia as useWidgetState,oa as useWidgetTheme,da as validateFields,na as validateForm};
|
package/native/WidgetRenderer.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsx as l}from"react/jsx-runtime";import{useRef as C,useState as
|
|
1
|
+
import{jsx as l}from"react/jsx-runtime";import{useRef as C,useState as v,useEffect as N,useCallback as k}from"react";import{ThemeProvider as O,useTheme as A}from"./theme";import{WidgetStateManager as P}from"./state";import{WidgetErrorBoundary as j}from"./WidgetErrorBoundary";import{renderWidget as U}from"./runtime";import{mergeConfig as _}from"./config";import{UserLocationProvider as $}from"./components/Map";import{TEXT_DIRECTIONS as z}from"./schema";const p=390,G=24;function q(e){const t=e.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i)??e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);if(!t)return e;const a=e.startsWith("#"),c=a?parseInt(t[1],16):Number(t[1]),d=a?parseInt(t[2],16):Number(t[2]),g=a?parseInt(t[3],16):Number(t[3]),n=.08,u=Math.round(c*(1-n)+80*n),m=Math.round(d*(1-n)+120*n),f=Math.round(g*(1-n)+200*n);return`rgb(${u}, ${m}, ${f})`}const Y=`
|
|
2
2
|
[data-widget-renderer][data-widget-renderer] *,
|
|
3
3
|
[data-widget-renderer][data-widget-renderer] *::before,
|
|
4
4
|
[data-widget-renderer][data-widget-renderer] *::after {
|
|
@@ -33,4 +33,18 @@ import{jsx as l}from"react/jsx-runtime";import{useRef as C,useState as w,useEffe
|
|
|
33
33
|
-webkit-box-shadow: 0 0 0 9999px var(--widget-input-bg) inset !important;
|
|
34
34
|
-webkit-text-fill-color: var(--widget-input-fg) !important;
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
/* Anchor the widget to the reading edge symmetrically. Both directions use ONE
|
|
37
|
+
mechanism \u2014 the writing direction \u2014 never mismatched align values (stretch for
|
|
38
|
+
LTR / flex-end for RTL is what collapsed LTR fill). LTR is the default (no
|
|
39
|
+
rule), which restores the pre-RTL stretch: a width-capped surface (a maxWidth
|
|
40
|
+
Card, or the card wrapper inside the 100%-wide shell) fills to its cap at the
|
|
41
|
+
leading edge, and a no-width root fills the container. RTL just flips the
|
|
42
|
+
direction on the root, so the same clamp lands at the trailing edge. The root's
|
|
43
|
+
own content is reset to ltr one level down so the card's children never mirror. */
|
|
44
|
+
[data-widget-renderer][data-widget-dir="rtl"] > * {
|
|
45
|
+
direction: rtl;
|
|
46
|
+
}
|
|
47
|
+
[data-widget-renderer][data-widget-dir="rtl"] > * > * {
|
|
48
|
+
direction: ltr;
|
|
49
|
+
}
|
|
50
|
+
`;let y=!1;function V(){if(y||typeof document>"u")return;if(document.getElementById("widget-renderer-style")){y=!0;return}const e=document.createElement("style");e.id="widget-renderer-style",e.textContent=Y,document.head.appendChild(e),y=!0}function se({widget:e,branding:t,brandingStyles:a,theme:c="light",messageId:d,onConsumerAction:g,onUploadFile:n,onRemoveFile:u,config:m,errorFallback:f,userLocation:w,direction:b=z.ltr}){const h=C(null),R=C(null),[E,I]=v(1),[M,F]=v(!1),[H,L]=v(void 0),x=k(()=>{const o=h.current;if(!o)return;const r=o.clientWidth;F(s=>s?r<p+G:r<p);const i=Math.min(r<p?r/p:1,1);I(s=>Math.abs(s-i)<.005?s:i)},[]),S=k(()=>{const o=R.current;if(!o)return;const r=o.scrollHeight;L(i=>i!==void 0&&Math.abs(i-r)<1?i:r)},[]);if(N(()=>{V();const o=h.current,r=R.current;if(!o||!r)return;let i=0;const s=()=>{cancelAnimationFrame(i),i=requestAnimationFrame(()=>{x(),S()})},T=new ResizeObserver(s);T.observe(o);const W=new ResizeObserver(s);return W.observe(r),()=>{cancelAnimationFrame(i),T.disconnect(),W.disconnect()}},[x,S]),!e)return null;const B=t??a,D=_(m);return l(O,{branding:B,mode:c,config:D,children:l(P,{messageId:d,onConsumerAction:g,onUploadFile:n,onRemoveFile:u,children:l($,{location:w??null,children:l(X,{outerRef:h,innerRef:R,theme:c,direction:b,needsScaling:M,innerHeight:H,scale:E,errorFallback:f,widget:e})})})})}function X({outerRef:e,innerRef:t,theme:a,direction:c,needsScaling:d,innerHeight:g,scale:n,errorFallback:u,widget:m}){const{tokens:f,variants:w}=A(),b=w.input.soft.bg,h=q(b);return l("div",{ref:e,style:{direction:"ltr",width:"100%",overflow:"hidden",height:d&&g?g*n:void 0},children:l("div",{ref:t,"data-widget-renderer":"","data-widget-dir":c,"data-theme":a,style:{width:d?`${p}px`:"100%",transformOrigin:"top left",transform:d?`scale(${n})`:void 0,WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale","--widget-input-fg":f.color.text,"--widget-input-bg":h},children:l(j,{fallback:u,children:U(m)})})})}export{Y as WIDGET_CSS,se as WidgetRenderer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{View as
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{View as C}from"react-native";import{ThemeProvider as W}from"./theme";import{WidgetStateManager as R}from"./state";import{WidgetErrorBoundary as u}from"./WidgetErrorBoundary";import{renderWidget as y}from"./runtime";import{mergeConfig as v}from"./config";import{UserLocationProvider as F}from"./components/Map";import{TEXT_DIRECTIONS as T}from"./schema";import{rootAlignItems as h}from"./runtime/rootAnchor";function E({widget:o,branding:r,brandingStyles:i,theme:n="light",messageId:t,onConsumerAction:d,onUploadFile:a,onRemoveFile:m,config:l,errorFallback:g,userLocation:p,direction:s=T.ltr}){if(!o)return null;const c=r??i,f=v(l);return e(W,{branding:c,mode:n,config:f,children:e(R,{messageId:t,onConsumerAction:d,onUploadFile:a,onRemoveFile:m,children:e(F,{location:p??null,children:e(C,{style:{width:"100%",direction:"ltr",alignItems:h(s)},children:e(u,{fallback:g,children:y(o)})})})})})}export{E as WidgetRenderer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{WidgetStateManager as e,useWidgetState as t,useWidgetDispatch as a,useMessageId as
|
|
1
|
+
import{WidgetStateManager as e,useWidgetState as t,useWidgetDispatch as a,useMessageId as o,useSelectedCategory as r,useFileUploadState as i}from"../state";const p=e;export{e as WidgetStateManager,p as WidgetStateProvider,i as useFileUploadState,o as useMessageId,r as useSelectedCategory,a as useWidgetDispatch,t as useWidgetState};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as p,jsxs as
|
|
1
|
+
import{jsx as p,jsxs as E}from"react/jsx-runtime";import{Text as O,View as P,Pressable as x,Platform as z}from"react-native";import{ACTION_TYPES as f}from"../schema";import{PRIMITIVE_KINDS as F,resolveStyle as q,useTheme as M}from"../theme";import{useActionHandler as _,useFileUploadState as v,useMessageId as V}from"../state";import{Icon as T}from"./Icon";import{useRegisterRequired as B,useFieldError as $}from"./Form";let y=null,m=null;try{y=require("expo-document-picker")}catch{y=null}try{m=require("expo-image-picker")}catch{m=null}function G(e){return new Promise(l=>{const n=document.createElement("input");n.type="file",e&&(n.accept=e),n.style.display="none",document.body.appendChild(n);const r=c=>{window.removeEventListener("focus",a),n.remove(),l(c)},a=()=>setTimeout(()=>r(n.files?.[0]??null),300);n.addEventListener("change",()=>r(n.files?.[0]??null)),n.addEventListener("cancel",()=>r(null)),window.addEventListener("focus",a),n.click()})}const t={IDLE:"idle",UPLOADING:"uploading",ERROR:"error",DONE:"done"};function C(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Q(e){const{tokens:l,config:n}=M(),r=_(),a=V(),c=v(e.fileRequestId);B(e.fileRequestId,e.required,"file");const U=$(e.fileRequestId),g=c?.uploaded??e.uploaded,R=c?.fileName??e.fileName,I=c?.fileSize??null,L=c?.error??e.error,i=c?.loading??!1?t.UPLOADING:L?t.ERROR:g?t.DONE:t.IDLE,b=e.maxFileSize??n.fileUpload.maxSizeBytes,S=e.allowedFileExtensions??n.fileUpload.allowedExtensions;function w(o){if(o.size&&o.size>b)return`File too large (max ${Math.round(b/1024/1024)} MB)`;if(S.length>0&&o.name){const d=o.name.toLowerCase().split(".").pop()??"";if(!S.map(s=>s.replace(/^\./,"").toLowerCase()).includes(d))return`Unsupported extension .${d}`}return null}async function A(){try{let o=null;if(z.OS==="web"&&typeof document<"u"){const s=S.map(u=>u.startsWith(".")?u:`.${u}`).join(",");o=await G(s)}else if(y?.getDocumentAsync){const s=await y.getDocumentAsync({type:"*/*"});!s.canceled&&s.assets&&s.assets[0]&&(o=s.assets[0])}else if(m?.launchImageLibraryAsync){const s=await m.launchImageLibraryAsync({mediaTypes:m.MediaTypeOptions?.Images,allowsMultipleSelection:!1});if(!s.canceled&&s.assets&&s.assets[0]){const u=s.assets[0];o={uri:u.uri,name:u.fileName??"photo.jpg",size:u.fileSize,mimeType:u.mimeType}}}else{r({type:f.UPLOAD_ERROR,payload:{fileRequestId:e.fileRequestId,error:"File picker unavailable \u2014 install expo-document-picker or expo-image-picker",...a?{messageId:a}:{}}});return}if(!o)return;const d=w(o);if(d){r({type:f.UPLOAD_ERROR,payload:{fileRequestId:e.fileRequestId,error:d,...a?{messageId:a}:{}}});return}r({type:f.UPLOAD_SELECT,payload:{fileRequestId:e.fileRequestId,file:o,label:e.label,...e.documentType?{documentType:e.documentType}:{},...a?{messageId:a}:{}}})}catch(o){const d=o instanceof Error?o.message:"File selection failed";r({type:f.UPLOAD_ERROR,payload:{fileRequestId:e.fileRequestId,error:d,...a?{messageId:a}:{}}})}}function D(){r({type:f.UPLOAD_REMOVE,payload:{fileRequestId:e.fileRequestId,...a?{messageId:a}:{}}})}const h={...l.layout.fileUpload.row,backgroundColor:l.color.surfaceAlt,borderRadius:l.radius.lg,gap:l.fileUpload.rowGap,paddingVertical:l.fileUpload.padV,paddingHorizontal:l.fileUpload.padH},k=q(h,F.BOX,{hasBackground:!0}),N=i===t.ERROR||i===t.IDLE&&!!U;return E(x,{onPress:i===t.UPLOADING?void 0:g?D:A,disabled:i===t.UPLOADING,style:({pressed:o})=>[k,{opacity:o?l.ui.pressedOpacity:1}],accessibilityRole:"button",accessibilityLabel:i===t.UPLOADING?`Uploading ${R??"file"}`:g?`Remove ${R??"file"}`:e.label,children:[p(T,{name:i===t.ERROR?"alert-triangle":i===t.DONE?"check-circle-filled":e.icon??"upload-01",size:"md",color:i===t.ERROR?"danger":i===t.DONE?"success":"primary"}),E(P,{style:[l.layout.fileUpload.col,{gap:l.fileUpload.colGap}],children:[E(P,{style:l.layout.label.row,children:[p(O,{style:{color:l.color.text,fontFamily:l.font.family,fontSize:l.fileUpload.label.fontSize,fontWeight:l.fileUpload.label.weight,flexShrink:1},numberOfLines:1,children:e.label}),e.required?p(O,{style:{color:l.color.danger.solid,fontFamily:l.font.family,fontSize:l.fileUpload.label.fontSize,marginLeft:l.text.requiredMarker.marginLeft},children:"*"}):null]}),p(O,{style:{color:N?l.color.danger.solid:l.color.textFaint,fontFamily:l.font.family,fontSize:l.fileUpload.hint.fontSize},numberOfLines:i===t.ERROR?2:1,children:i===t.UPLOADING?"Uploading\u2026":i===t.DONE?[R,I!=null?C(I):null].filter(Boolean).join(" \xB7 "):i===t.ERROR?`${L} \u2014 tap to retry`:U??"Tap to select"})]}),i===t.DONE?p(T,{name:"x",size:"sm",color:"secondary"}):null]})}export{Q as FileUploadRequest};
|
package/native/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Badge as
|
|
1
|
+
import{Badge as r}from"./components/Badge";import{BasicRoot as a}from"./components/BasicRoot";import{Box as p,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 W}from"./components/Divider";import{FileUploadRequest as T}from"./components/FileUploadRequest";import{Form as R}from"./components/Form";import{Icon as h}from"./components/Icon";import{Image as I}from"./components/Image";import{Video as E}from"./components/Video";import{Input as O}from"./components/Input";import{Label as v}from"./components/Text";import{ListView as N,ListViewItem as w}from"./components/ListView";import{RadioGroup as H}from"./components/RadioGroup";import{Select as U}from"./components/Select";import{Spacer as _}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 pe}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}from"./schema";import{renderWidget as We}from"./runtime";import{safeRenderWidget as Te}from"./utils/safeRender";import{useActionHandler as Re,formatOrderItems as Fe,resolveTemplate as he,ActionHandlerContext as Ae,defaultActionHandler as Ie}from"./utils/widgetUtils";import{useWidgetState as Ee,useWidgetDispatch as Me,useActionHandler as Oe}from"./state";import{REDUCER_ACTIONS as ve}from"./state";import{validateFields as Ne}from"./utils/formValidationCore";import{validateForm as Be,markRequiredLabels as He}from"./utils/formValidation";import{useFormContext as Ue,FormContext as ke}from"./compat/FormContext";import{useTheme as be,useTokens as qe,useVariants as Ge}from"./theme";import{mergeConfig as je,DEFAULT_CONFIG as ze}from"./config";import{configureMap as Ke}from"./components/Map";export{ge as ACTION_TYPES,Ae as ActionHandlerContext,r as Badge,a as BasicRoot,p as Box,f as Button,ue as CONSUMER_ACTIONS,Y as Caption,s as Card,X as Chart,g as Checkbox,d as Col,ze as DEFAULT_CONFIG,u as DatePicker,W as Divider,T as FileUploadRequest,R as Form,ke as FormContext,h as Icon,I as Image,O as Input,v as Label,N as ListView,w as ListViewItem,$ as Markdown,ve as REDUCER_ACTIONS,H as RadioGroup,m as Row,Ce as SELF_CONTAINED_ACTIONS,U as Select,_ as Spacer,q as Text,z as Textarea,G as Title,K as Transition,E as Video,pe as WidgetErrorBoundary,ae as WidgetRenderer,de as WidgetStateManager,se as WidgetStateProvider,oe as WidgetThemeProvider,Ke as configureMap,Ie as defaultActionHandler,Fe as formatOrderItems,He as markRequiredLabels,je as mergeConfig,We as renderWidget,he as resolveTemplate,Te as safeRenderWidget,Oe as useAction,Re as useActionHandler,xe as useFileUploadState,Ue as useFormContext,ne as useMessageId,fe as useSelectedCategory,be as useTheme,qe as useTokens,Ge as useVariants,Me as useWidgetDispatch,Ee as useWidgetState,re as useWidgetTheme,Ne as validateFields,Be as validateForm};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{TEXT_DIRECTIONS as e}from"../schema";function n(t){return t===e.rtl?"flex-end":"stretch"}export{n as rootAlignItems};
|
|
@@ -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={start:"start",center:"center",end:"end",baseline:"baseline",stretch:"stretch"},
|
|
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"},p={start:"start",center:"center",end:"end"},s={normal:"normal",medium:"medium",semibold:"semibold",bold:"bold"},a={light:"light",dark:"dark"},l={clear:"clear"},g={"2xs":"2xs",xs:"xs",sm:"sm",md:"md",lg:"lg",xl:"xl","2xl":"2xl","3xl":"3xl","4xl":"4xl",full:"full","100%":"100%",none:"none"},y={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",email:"email",text:"text",password:"password",tel:"tel",url:"url",card_number:"card_number",month_year:"month_year",cvc:"cvc",counter:"counter"},M={top:"top",bottom:"bottom",left:"left",right:"right"},R={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,y 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,s 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,R as POPOVER_ALIGNS,M as POPOVER_SIDES,B as PRELOAD_MODES,g as RADIUS_VALUES,N as SERIES_TYPES,p 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
|
|
1
|
+
import{jsx as b}from"react/jsx-runtime";import{createContext as L,useCallback as W,useContext as S,useMemo as N,useReducer as H,useRef as y}from"react";import{Linking as M}from"react-native";import{ACTION_TYPES as a,CONSUMER_ACTIONS as j,SELF_CONTAINED_ACTIONS as q}from"../schema";import{createInitialWidgetState as U,REDUCER_ACTIONS as c,widgetStateReducer as G}from"./reducer";import{useRendererConfig as V}from"../theme/ThemeContext";import{DEFAULT_CONFIG as B}from"../config";const Y=i=>{console.warn("[widget-renderer] action dispatched outside WidgetStateManager:",i)},k=L(Y);function te(){return S(k)}const A=L({state:U(),dispatch:()=>{}});function ne({messageId:i,children:l,onConsumerAction:p,onUploadFile:s,onRemoveFile:r}){const[d,o]=H(G,void 0,U),m=V(),f=y(d);f.current=d;const C=y(p);C.current=p;const I=y(s);I.current=s;const g=y(r);g.current=r;const _=y(m);_.current=m;const x=y(i);x.current=i;const F=N(()=>({messageId:i,state:d,dispatch:o}),[i,d]),P=W(O=>{if(!O?.type)return;const u=O.type,e=O.payload||{};if(u===a.URL){const t=e.text;typeof t=="string"&&t&&M.openURL(t).catch(()=>{});return}if(q.has(u)){switch(u){case a.TABS:o({type:c.SET_SELECTED_CATEGORY,payload:{id:String(e.id??"")}});break;case a.DATA_CHECKBOX:case a.DATA_SELECT:o({type:c.TOGGLE_CHECKBOX,payload:{data:String(e.data??"")}});break;case a.QUANTITY_CHANGE:{const t=String(e.name??""),n=Number(e.delta??0);o({type:c.TOGGLE_QUANTITY,payload:{id:t,delta:Number.isFinite(n)?n:0}});break}case a.UPLOAD_SELECT:{const t=String(e.fileRequestId??""),n=e.file,E=typeof e.label=="string"?e.label:void 0,T=I.current;if(!T){o({type:c.UPLOAD_FILE,payload:{requestId:t,file:n,label:E}});break}const w=typeof e.documentType=="string"?e.documentType:void 0,D=n&&typeof n=="object"&&"name"in n&&String(n.name??"")||null,h=f.current.fileUpload.files[t]?.documentId,v=g.current;h&&v&&Promise.resolve(v(h)).catch(R=>{console.warn("[widget-renderer] document delete failed",R)}),o({type:c.UPLOAD_FILE,payload:{requestId:t,file:n,label:E,pending:!0}}),T(n,{fileRequestId:t,documentType:w,fileName:D}).then(R=>{o({type:c.SET_UPLOAD_RESULT,payload:{requestId:t,documentId:R.documentId}})}).catch(R=>{o({type:c.SET_UPLOAD_ERROR,payload:{requestId:t,error:R instanceof Error?R.message:"Upload failed"}})});break}case a.UPLOAD_REMOVE:{const t=String(e.fileRequestId??""),n=f.current.fileUpload.files[t]?.documentId,E=g.current;n&&E&&Promise.resolve(E(n)).catch(T=>{console.warn("[widget-renderer] document delete failed",T)}),o({type:c.REMOVE_FILE,payload:{requestId:t}});break}case a.UPLOAD_ERROR:o({type:c.SET_UPLOAD_ERROR,payload:{requestId:String(e.fileRequestId??""),error:typeof e.error=="string"?e.error:null}});break}return}if(j.has(u)){const t=f.current,n={...e};x.current&&!n.messageId&&(n.messageId=x.current),u===a.REPLY_TEMPLATE&&(n.resolvedText=K(String(e.text??""),t,e,_.current)),u===a.ORDER_SUBMIT&&(n.resolvedText=Q(t.formFields)),C.current?.({type:u,payload:n,state:t});return}console.warn("[widget-renderer] unhandled action",u,e)},[]);return b(A.Provider,{value:F,children:b(k.Provider,{value:P,children:l})})}function re(){return S(A).state}function oe(){return S(A).dispatch}function ie(){return S(A).messageId}function ae(){return S(A).state.selectedCategory}function se(i){return S(A).state.fileUpload.files[i]}function K(i,l,p={},s=B){let r=i;const d=l.checkboxes?.selected?.join(", ")||"";r=r.split(s.template.dataSelectToken).join(d),r=r.split(s.template.dataCheckboxToken).join(d);const{text:o,messageId:m,...f}=p,C=Object.values(f).filter(Boolean).join(", ");return r=r.split(s.template.dataInputToken).join(C),l.formFields&&(r=r.replace(new RegExp(s.template.dataFieldPattern.source,"g"),(I,g)=>l.formFields?.[g]||"")),r=r.replace(new RegExp(s.template.formPlaceholderPattern.source,"g"),(I,g)=>String(f[g.trim()]??"")),r}function Q(i){const l=Object.entries(i),p=l.filter(([r])=>r.startsWith("items."));return(p.length>0?p:l).map(([r,d])=>{const o=Number(d);if(!Number.isFinite(o)||o<=0)return null;const m=r.replace(/^items\./,"");return`${o}x ${m}`}).filter(Boolean).join(", ")}export{k as ActionHandlerContext,ne as WidgetStateManager,Q as formatOrderItems,K as resolveTemplate,te as useActionHandler,se as useFileUploadState,ie as useMessageId,ae as useSelectedCategory,oe as useWidgetDispatch,re as useWidgetState};
|
package/native/state/reducer.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function f(){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",RESET_UPLOADS:"RESET_UPLOADS",SET_FORM_FIELD:"SET_FORM_FIELD"};function u(e,r){switch(r.type){case d.TOGGLE_CHECKBOX:{const{data:l}=r.payload,{selected:n,maxSelection:i}=e.checkboxes;return n.includes(l)?{...e,checkboxes:{...e.checkboxes,selected:n.filter(o=>o!==l)}}:n.length>=i?e:{...e,checkboxes:{...e.checkboxes,selected:[...n,l]}}}case d.SET_CHECKBOX_DATA:{const{data:l,checked:n}=r.payload,{selected:i,maxSelection:o}=e.checkboxes,E=i.includes(l);return n===E?e:n?i.length>=o?e:{...e,checkboxes:{...e.checkboxes,selected:[...i,l]}}:{...e,checkboxes:{...e.checkboxes,selected:i.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:n}=r.payload;if(!l||n===0)return e;const i=e.quantities[l]??0,o=Math.max(0,i+n),E={...e.quantities};return o===0?delete E[l]:E[l]=o,{...e,quantities:E}}case d.UPLOAD_FILE:{const{requestId:l,file:n,label:i,pending:o}=r.payload,E=(n&&typeof n=="object"&&"name"in n?String(n.name??""):null)||null,a=n&&typeof n=="object"&&"size"in n?n.size:null,t=typeof a=="number"?a:null,{[l]:c,...s}=e.formFields;return{...e,formFields:o?s:{...s,[l]:E??"uploaded"},fileUpload:{...e.fileUpload,loading:!1,files:{...e.fileUpload.files,[l]:{file:n,fileName:E,fileSize:t,label:i??null,uploaded:!o,loading:!!o,error:null,documentId:null}}}}}case d.SET_UPLOAD_RESULT:{const{requestId:l,documentId:n}=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:n}}}}:e}case d.REMOVE_FILE:{const{requestId:l}=r.payload,{[l]:n,...i}=e.fileUpload.files,{[l]:o,...E}=e.formFields;return{...e,formFields:E,fileUpload:{...e.fileUpload,files:i}}}case d.SET_UPLOAD_ERROR:{const{requestId:l,error:n}=r.payload;if(!e.fileUpload.files[l])return e;const{[l]:i,...o}=e.formFields;return{...e,formFields:o,fileUpload:{...e.fileUpload,files:{...e.fileUpload.files,[l]:{...e.fileUpload.files[l],error:n,uploaded:!1,fileName:null,fileSize:null,loading:!1,documentId:null}}}}}case d.RESET_UPLOADS:return{...e,fileUpload:f().fileUpload};case d.SET_FORM_FIELD:{const{name:l,value:n}=r.payload;return{...e,formFields:{...e.formFields,[l]:n}}}default:return e}}export{d as REDUCER_ACTIONS,f as createInitialWidgetState,u as widgetStateReducer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{BASE_TOKENS as p,freshTokens as
|
|
1
|
+
import{BASE_TOKENS as p,freshTokens as y}from"./tokens";import{hexToRgba as b}from"./style";const i={solid:"#3B4FFE",background:"#E5F3FF",text:"#FFFFFF"},l={surface:"#212121",surfaceAlt:"#181818",surfaceTertiary:"#131313",text:"#DCDCDC",textMuted:"#8F8F8F",textFaint:"#767676",border:"rgba(255,255,255,0.12)"};function f(r,e,t="rgba(0,0,0,0.1)"){if(!r)return t;const d=typeof e=="number"?e:100;if(d>=100)return r;const n=Math.max(0,Math.min(1,d/100));return b(r,n)??r}function B(r){return r.widgetBg!==void 0}function m(r){if(typeof r=="number")return r;if(typeof r!="string")return 12;switch(r){case"none":case"sharp":return 0;case"sm":return 8;case"md":case"rounded":return 12;case"pill":return 16;default:{const e=parseFloat(r);return Number.isFinite(e)?e:12}}}function x(r){return typeof r=="string"&&r==="pill"}function h(r,e){if(typeof r=="number")return r;if(typeof r!="string")return e;const t=parseFloat(r);return Number.isFinite(t)?t:e}function g(r){return typeof r!="string"||!r?"System":r.includes(",")?r:`${/\s/.test(r)?`"${r}"`:r}, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif`}function S(r){return{none:0,"2xs":Math.max(Math.round(r*.125),1),xs:Math.max(Math.round(r*.25),2),sm:Math.max(Math.round(r*.375),2),md:Math.max(Math.round(r*.5),4),lg:Math.max(Math.round(r*.625),6),xl:Math.max(Math.round(r*.75),8),"2xl":Math.round(r),"3xl":Math.round(r*1.25),"4xl":Math.round(r*1.5),pill:9999}}function M(r,e){const t=y(),d=r.borderRadius??12;t.radius=S(d);const n=e?l:void 0;return t.color.surface=r.widgetBg||n?.surface||"#FFFFFF",t.color.surfaceAlt=r.inputBgColor||n?.surfaceAlt||"#F4F4F5",t.color.surfaceTertiary=n?.surfaceTertiary??"#F3F3F3",t.color.text=r.primaryText||n?.text||"#1A1A1A",t.color.textMuted=r.secondaryText||n?.textMuted||"#6B6B6B",t.color.textFaint=r.tertiaryText||n?.textFaint||"#9B9B9B",t.color.placeholder=r.placeholderColor||n?.textFaint||"#9B9B9B",t.color.border=e?l.border:f(r.widgetBorderColor,r.widgetBorderOpacity),t.color.borderInput=e?l.border:f(r.inputBorderColor,r.inputBorderOpacity),r.widgetBorderStyle==="none"&&(t.ui.cardBorderWidth=0),t.color.primary=s(r.statusPrimary),t.color.secondary=s(r.statusSecondary),t.color.success=s(r.statusSuccess),t.color.danger=s(r.statusDanger),t.color.warning=s(r.statusWarning),t.color.info=s(r.statusInfo),t.color.discovery=s(r.statusDiscovery),t.font.family=g(r.fontFamily),t.font.monoFamily=r.fontFamilyMono?g(r.fontFamilyMono):t.font.monoFamily,t.font.baseSize=r.fontSize||p.font.baseSize,t.button.alwaysPill=r.cornerRadiusMode==="pill",t}function s(r){return{solid:r?.solid??i.solid,bg:r?.background??i.background,text:r?.text??i.text}}function T(r,e,t,d,n){const o=y();o.radius=S(t);const a=r.surface.widget,u=r.surface.input,c=n?l:void 0;o.color.surface=a?.background??c?.surface??"#FFFFFF",o.color.surfaceAlt=u?.background??c?.surfaceAlt??"#F4F4F5",o.color.surfaceTertiary=c?.surfaceTertiary??"#F3F3F3",o.color.text=r.text.primary??c?.text??"#1A1A1A",o.color.textMuted=r.text.secondary??c?.textMuted??"#6B6B6B",o.color.textFaint=r.text.tertiary??c?.textFaint??"#9B9B9B",o.color.placeholder=u?.placeholder_color??r.text.tertiary??c?.textFaint??"#9B9B9B";const F=n?"rgba(255,255,255,0.12)":"rgba(0,0,0,0.1)";return o.color.border=f(a?.border?.color,a?.border?.opacity,F),o.color.borderInput=f(u?.border?.color,u?.border?.opacity,F),a?.border?.style==="none"&&(o.ui.cardBorderWidth=0),o.color.primary=s(r.status.primary),o.color.secondary=s(r.status.secondary),o.color.success=s(r.status.success),o.color.danger=s(r.status.danger),o.color.warning=s(r.status.warning),o.color.info=s(r.status.info??i),o.color.discovery=s(r.status.discovery??i),o.font.family=g(e.font_family),o.font.baseSize=h(e.font_size,p.font.baseSize),o.button.alwaysPill=d,o}function C(r,e="light"){const t=e==="dark";if(!r)return y();if(B(r))return M(r,t);const d=t&&r.themes.dark||r.themes.light,n=m(r.corner_radius),o=x(r.corner_radius);return T(d,r.typography,n,o,t)}function _(r,e="light"){if(B(r))return r;const t=e==="dark"&&r.themes.dark||r.themes.light,d=m(r.corner_radius),n=x(r.corner_radius),o=t.surface.widget,a=t.surface.input;return{widgetBg:o?.background??"#FFFFFF",inputBgColor:a?.background??"#F4F4F5",widgetBorderStyle:o?.border?.style??"solid",widgetBorderColor:o?.border?.color??"#000000",widgetBorderWidth:o?.border?.width??"1px",widgetBorderOpacity:o?.border?.opacity??10,inputBorderStyle:a?.border?.style??"solid",inputBorderColor:a?.border?.color??"#000000",inputBorderWidth:a?.border?.width??"1px",inputBorderOpacity:a?.border?.opacity??10,primaryText:t.text.primary,secondaryText:t.text.secondary,tertiaryText:t.text.tertiary,placeholderColor:a?.placeholder_color??t.text.tertiary,statusPrimary:t.status.primary??i,statusSecondary:t.status.secondary??i,statusSuccess:t.status.success??i,statusDanger:t.status.danger??i,statusWarning:t.status.warning??i,statusInfo:t.status.info??i,statusDiscovery:t.status.discovery??i,fontFamily:g(r.typography.font_family),fontSize:h(r.typography.font_size,14),borderRadius:d,cornerRadiusMode:n?"pill":typeof r.corner_radius=="string"&&r.corner_radius==="sharp"?"sharp":"rounded"}}export{C as resolveBranding,_ as resolveBrandingStyles};
|