2024-12-02 16:59:57 +08:00
var ka = Object . defineProperty ;
var Ft = ( e ) => {
throw TypeError ( e ) ;
} ;
var va = ( e , t , a ) => t in e ? ka ( e , t , { enumerable : ! 0 , configurable : ! 0 , writable : ! 0 , value : a } ) : e [ t ] = a ;
var v = ( e , t , a ) => va ( e , typeof t != "symbol" ? t + "" : t , a ) , Rt = ( e , t , a ) => t . has ( e ) || Ft ( "Cannot " + a ) ;
var g = ( e , t , a ) => ( Rt ( e , t , "read from private field" ) , a ? a . call ( e ) : t . get ( e ) ) , P = ( e , t , a ) => t . has ( e ) ? Ft ( "Cannot add the same private member more than once" ) : t instanceof WeakSet ? t . add ( e ) : t . set ( e , a ) , B = ( e , t , a , n ) => ( Rt ( e , t , "write to private field" ) , n ? n . call ( e , a ) : t . set ( e , a ) , a ) ;
var Ot = ( e , t , a , n ) => ( {
set _ ( r ) {
B ( e , t , r , a ) ;
} ,
get _ ( ) {
return g ( e , t , n ) ;
}
} ) ;
2024-12-02 17:31:31 +08:00
import { jsx as d , jsxs as T } from "react/jsx-runtime" ;
2024-12-02 16:59:57 +08:00
import C , { useEffect as x , useState as N , useCallback as ce , useMemo as Z , useRef as q , useContext as Ue , useId as Ye , useLayoutEffect as Sa } from "react" ;
import p from "lodash" ;
import Ht from "immutability-helper" ;
2024-12-03 10:15:14 +08:00
import R from "classnames" ;
2024-12-02 16:59:57 +08:00
import { Form as _e , Input as $a , Button as ot , Breadcrumb as Na , Tree as Pa , Pagination as xa , Table as Ta , Empty as Ea , Popconfirm as Fa , Tooltip as Ra , Popover as Oa } from "antd" ;
import { useMergedState as La } from "rc-util" ;
import X , { FieldContext as Va , Field as Jt } from "rc-field-form" ;
import { useParams as Aa , generatePath as ja , createBrowserRouter as Ia , useInRouterContext as Ma , Navigate as za } from "react-router-dom" ;
2024-12-03 10:15:14 +08:00
import V from "prop-types" ;
2024-12-02 16:59:57 +08:00
import * as Lt from "react-is" ;
import { useNotification as Wa } from "rc-notification" ;
import { N as Re , a as Oe , T as lt , S as Ua } from "./vender-DMK1apIA.js" ;
import "rc-util/lib/hooks/useMergedState" ;
import Ba from "rc-drawer" ;
import Da from "rc-dialog" ;
var Ne , Ae , Pe , ie , Ce , be ;
class Kt {
constructor ( t , a ) {
P ( this , Ne , /* @__PURE__ */ new Map ( ) ) ;
P ( this , Ae , ! 0 ) ;
P ( this , Pe , [ ] ) ;
P ( this , ie ) ;
P ( this , Ce , ( ) => g ( this , ie ) ) ;
P ( this , be , ( ) => Promise . resolve ( ) ) ;
v ( this , "get" , ( ... t ) => new Promise ( ( a , n ) => {
const r = JSON . stringify ( t ) ;
if ( g ( this , Ne ) . has ( r ) ) return a ( g ( this , be ) . call ( this , g ( this , ie ) , ... t ) ) ;
if ( g ( this , ie ) === void 0 ) g ( this , Pe ) . push ( [ t , a , n ] ) , g ( this , Ae ) && ( B ( this , Ae , ! 1 ) , Promise . resolve ( typeof g ( this , Ce ) == "function" ? g ( this , Ce ) . call ( this ) : g ( this , Ce ) ) . then ( ( s ) => B ( this , ie , s || null ) ) . finally ( ( ) => {
g ( this , Pe ) . forEach ( ( [ s , i , o ] ) => {
try {
const l = g ( this , be ) . call ( this , g ( this , ie ) , ... s ) ;
g ( this , Ne ) . set ( JSON . stringify ( s ) , l ) , i ( l ) ;
} catch ( l ) {
o ( l ) ;
}
} ) , g ( this , Pe ) . length = 0 ;
} ) ) ;
else {
const s = g ( this , be ) . call ( this , g ( this , ie ) , ... t ) ;
g ( this , Ne ) . set ( r , s ) , a ( s ) ;
}
} ) ) ;
B ( this , be , a ) , B ( this , Ce , t ) ;
}
}
Ne = new WeakMap ( ) , Ae = new WeakMap ( ) , Pe = new WeakMap ( ) , ie = new WeakMap ( ) , Ce = new WeakMap ( ) , be = new WeakMap ( ) ;
2024-12-02 17:31:31 +08:00
const Xn = ( ) => d ( "div" , { children : "Empty" } ) , Be = C . createContext ( { ele : { } , mount : ( ) => {
2024-12-02 16:59:57 +08:00
} , unmount : ( ) => {
} } ) , K = ( { rootClassName : e , className : t , children : a , actions : n , title : r , subTitle : s , extras : i , style : o = { } } ) => {
2024-12-02 17:31:31 +08:00
const { mount : l , unmount : c } = C . useContext ( Be ) ;
2024-12-03 10:15:14 +08:00
return n && K . Action ( { children : n } ) , r && K . Title ( { children : r } ) , s && K . SubTitle ( { children : s } ) , i && K . Extra ( { children : i } ) , x ( ( ) => ( l ( "rootClassName" , e ) , ( ) => c ( e ) ) , [ e ] ) , d ( "div" , { className : R ( "ff-container" , t ) , style : o , children : a } ) ;
2024-12-02 16:59:57 +08:00
} , Ke = ( e ) => ( { children : t , className : a } ) => {
const { mount : n , unmount : r } = C . useContext ( Be ) ;
2024-12-03 10:15:14 +08:00
return x ( ( ) => ( n ( e , C . createElement ( "div" , { key : ` ff- ${ e } ` , className : R ( ` ff-popup- ${ e } ` , a ) } , t ) ) , ( ) => r ( e ) ) , [ a , t ] ) , null ;
2024-12-02 16:59:57 +08:00
} ;
2024-12-03 10:15:14 +08:00
K . Action = Ke ( "actions" ) , K . Title = Ke ( "title" ) , K . SubTitle = Ke ( "sub-title" ) , K . Extra = Ke ( "extras" ) , K . propTypes = { className : V . string , style : V . object , title : V . any , subTitle : V . any , actions : V . any , extras : V . any } ;
2024-12-02 17:31:31 +08:00
const Zn = ( ) => d ( K , { className : "ff-loading" , children : T ( "div" , { className : "loader" , children : [ T ( "div" , { className : "square" , children : [ d ( "span" , { } ) , d ( "span" , { } ) , d ( "span" , { } ) ] } ) , T ( "div" , { className : "square" , children : [ d ( "span" , { } ) , d ( "span" , { } ) , d ( "span" , { } ) ] } ) , T ( "div" , { className : "square" , children : [ d ( "span" , { } ) , d ( "span" , { } ) , d ( "span" , { } ) ] } ) , T ( "div" , { className : "square" , children : [ d ( "span" , { } ) , d ( "span" , { } ) , d ( "span" , { } ) ] } ) ] } ) } ) , er = ( ) => d ( "div" , { children : "NotFound" } ) , _t = ( { children : e } ) => {
2024-12-02 16:59:57 +08:00
const [ t , a ] = N ( { } ) , n = ce ( ( s , i ) => a ( ( o ) => ( { ... o , [ s ] : i } ) ) , [ ] ) , r = ce ( ( s ) => a ( ( i ) => ( { ... i , [ s ] : void 0 } ) ) , [ ] ) ;
2024-12-02 17:31:31 +08:00
return typeof ( e == null ? void 0 : e . type ) == "string" ? e : d ( Be . Provider , { value : { ele : t , mount : n , unmount : r } , children : C . cloneElement ( e , { className : t . rootClassName , title : t . title , subTitle : t [ "sub-title" ] , actions : t . actions , extras : t . extras } ) } ) ;
2024-12-02 16:59:57 +08:00
} ;
2024-12-03 10:15:14 +08:00
_t . propTypes = { children : V . element . isRequired } ;
const Vt = { close : [ "M563.8 512l262.5-312.9c4.4-5.2 0.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9c-4.4 5.2-0.7 13.1 6.1 13.1h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z" ] , check : [ "M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474c-6.1-7.7-15.3-12.2-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1 0.4-12.8-6.3-12.8z" ] , info : [ "M512 224m-64 0a64 64 0 1 0 128 0 64 64 0 1 0-128 0Z" , "M544 392h-64c-4.4 0-8 3.6-8 8v464c0 4.4 3.6 8 8 8h64c4.4 0 8-3.6 8-8V400c0-4.4-3.6-8-8-8z" ] } , bt = ( { type : e , props : t } ) => d ( "i" , { ... t , children : d ( "svg" , { viewBox : "0 0 1024 1024" , width : "1em" , height : "1em" , fill : "currentColor" , children : ( Vt [ e ] || Vt . info ) . map ( ( a , n ) => d ( "path" , { d : a } , n ) ) } ) } ) , Gt = ( { className : e , content : t , icon : a , $close : n } ) => T ( C . Fragment , { children : [ a && d ( "div" , { className : R ( "ff-notification-icon" , e ) , children : d ( bt , { type : a } ) } ) , t ] } ) , qa = ( { } ) => d ( K , { children : "Confirm" } ) ;
2024-12-02 16:59:57 +08:00
var de , xe ;
const ee = class ee {
constructor ( ) {
P ( this , xe , null ) ;
v ( this , "init" , ( t ) => B ( this , xe , new Map ( t ) ) ) ;
v ( this , "check" , ( t ) => ! g ( this , xe ) . has ( t ) || g ( this , xe ) . get ( t ) ) ;
if ( g ( ee , de ) ) return g ( ee , de ) ;
}
} ;
de = new WeakMap ( ) , xe = new WeakMap ( ) , P ( ee , de , null ) , v ( ee , "getInstance" , ( ) => ( g ( ee , de ) || B ( ee , de , new ee ( ) ) , g ( ee , de ) ) ) ;
let ct = ee ;
const Ha = ct . getInstance ( ) ;
var ue , je ;
const te = class te {
constructor ( ) {
P ( this , je , null ) ;
v ( this , "init" , ( t ) => B ( this , je , t ) ) ;
v ( this , "get" , ( t , a ) => p . get ( g ( this , je ) , t , a ) ) ;
if ( g ( te , ue ) ) return g ( te , ue ) ;
}
} ;
ue = new WeakMap ( ) , je = new WeakMap ( ) , P ( te , ue , null ) , v ( te , "getInstance" , ( ) => ( g ( te , ue ) || B ( te , ue , new te ( ) ) , g ( te , ue ) ) ) ;
let dt = te ;
const Le = dt . getInstance ( ) , At = { null2json : ( e ) => Object . create ( ) , null2array : ( e ) => [ ] , null2number : ( e ) => 0 , null2bool : ( e ) => ! 1 , null2string : ( e ) => "" , null2integer : ( e ) => 0 , null2float : ( e ) => 0 , string2json : ( e ) => e ? JSON . parse ( e ) : "{}" , string2array : ( e ) => e . substr ( 0 , 1 ) === "[" && e . substr ( - 1 ) === "]" ? JSON . parse ( e ) : e . split ( "," ) , string2number : ( e ) => e == "" ? 0 : + e , string2integer : ( e ) => e == "" ? 0 : + e , string2float : ( e ) => e == "" ? 0 : + e , string2bool : ( e ) => {
switch ( ` ${ e } ` . toLowerCase ( ) ) {
case "0" :
case "false" :
case "[]" :
case "{}" :
return ! 1 ;
}
return ! ! e ;
} , string2string : ( e ) => e , json2json : ( e ) => e , json2array : ( e ) => e ? Object . values ( e ) : [ ] , json2number : ( e ) => Object . keys ( e ) . length , json2integer : ( e ) => Object . keys ( e ) . length , json2float : ( e ) => Object . keys ( e ) . length , json2bool : ( e ) => Object . keys ( e ) . length > 0 , json2string : ( e ) => e ? JSON . stringify ( e ) : "" , array2json : ( e ) => ( { ... e } ) , array2array : ( e ) => e , array2number : ( e ) => e . length , array2integer : ( e ) => e . length , array2float : ( e ) => e . length , array2bool : ( e ) => e . length > 0 , array2string : ( e ) => JSON . stringify ( e ) , number2json : ( e ) => ( { } ) , number2array : ( e ) => [ e ] , number2number : ( e ) => e , number2integer : ( e ) => e , number2float : ( e ) => e , number2bool : ( e ) => ! ! e , number2string : ( e ) => e . toString ( ) , boolean2json : ( e ) => ( { } ) , boolean2array : ( e ) => [ ] , boolean2number : ( e ) => + e , boolean2integer : ( e ) => + e , boolean2float : ( e ) => + e , boolean2bool : ( e ) => e , boolean2string : ( e ) => e ? "true" : "false" } , Q = ( e , t ) => {
let a = "string" ;
a = Array . isArray ( e ) ? "array" : typeof e , p . isObject ( e ) && ( a = "json" ) ;
const n = ` ${ a } 2 ${ t } ` ;
return Reflect . has ( At , n ) ? At [ n ] ( e ) : e ;
} , Yt = ( e = { } , t = { } , a = { } , n = "" ) => Qt ( e , ( r , s ) => s === "type" && r === "code" ) ? Xt ( e , t , a , n ) : Zt ( e , t , n ) , Qt = ( e , t = ( ) => ! 1 ) => p . some ( e , ( a ) => ! ! p . some ( a , t ) || ( p . isEmpty ( a ) || ! p . isPlainObject ( a ) && ! p . isArray ( a ) ? void 0 : Qt ( a , t ) ) ) , Xt = async ( e = { } , t = { } , a = { } , n = "" ) => {
let r = /* @__PURE__ */ Object . create ( null ) ;
for ( let s in e ) {
let i ;
if ( Reflect . has ( e [ s ] , "type" ) && [ "code" , "field" , "router" , "query" , "string" ] . includes ( e [ s ] . type ) ) {
2024-12-02 17:31:31 +08:00
const { type : o , value : l = "" , default : c = n } = e [ s ] ;
2024-12-02 16:59:57 +08:00
switch ( o ) {
case "code" :
i = await we . exec ( l , t , a ) ;
break ;
case "field" :
i = p . get ( t , l ) ? ? p . get ( t , l . substring ( l . indexOf ( "." ) + 1 ) ) ;
break ;
case "router" :
case "query" :
i = le . getPageParams ( l ) ;
break ;
case "string" :
i = l ;
}
2024-12-02 17:31:31 +08:00
i ? ? ( i = c ) ;
2024-12-02 16:59:57 +08:00
} else i = await Xt ( e [ s ] , t , a , n ) ;
p . set ( r , s , i ) ;
}
return r ;
} , Zt = ( e = { } , t = { } , a = "" ) => Object . keys ( e || { } ) . reduce ( ( n , r ) => {
if ( p . isPlainObject ( e [ r ] ) ) {
let s ;
if ( Reflect . has ( e [ r ] , "type" ) && [ "field" , "router" , "query" , "string" ] . includes ( e [ r ] . type ) ) {
const { type : i , value : o = "" , default : l = a } = e [ r ] ;
switch ( i ) {
case "field" :
s = p . get ( t , o ) ? ? p . get ( t , o . substring ( o . indexOf ( "." ) + 1 ) ) ;
break ;
case "router" :
case "query" :
s = le . getPageParams ( o ) ;
break ;
case "string" :
s = o ;
}
s ? ? ( s = l ) ;
} else s = Zt ( e [ r ] , t , a ) ;
p . set ( n , r , s ) ;
}
return n ;
} , { } ) , rt = ( e , t ) => e && typeof e == "object" ? Array . isArray ( e ) ? e . map ( ( a ) => rt ( a , t ) ) : Object . keys ( e ) . reduce ( ( a , n ) => ( t [ n ] ? a [ t [ n ] ] = rt ( e [ n ] , t ) : a [ n ] = rt ( e [ n ] , t ) , a ) , { } ) : e ;
var Qe , Ie , Me , Xe ;
const Ze = class Ze {
constructor ( ... t ) {
P ( this , Ie , [ ] ) ;
P ( this , Me , ( t ) => {
var a ;
for ( let n of t ) Array . isArray ( n [ 0 ] ) ? g ( this , Me ) . call ( this , n ) : g ( this , Ie ) . push ( g ( a = Ze , Qe ) . call ( a , n [ 0 ] , n [ 1 ] ) ) ;
} ) ;
v ( this , "toValue" , async ( t , a = null ) => {
const n = { getValue : ( ) => t , getRecord : ( ) => a } ;
return await g ( this , Ie ) . reduce ( async ( r , s ) => {
try {
const i = await r ;
return ( await s ) . call ( n , i ) ;
} catch ( i ) {
return console . error ( i ) , r ;
}
} , t ) ;
} ) ;
v ( this , "toRender" , ( t , a , n = null ) => C . createElement ( g ( this , Xe ) , { value : t , record : a } , n ) ) ;
P ( this , Xe , ( { value : t , record : a , children : n } ) => {
const [ r , s ] = N ( n ) ;
return $t ( ( ) => {
let i = ! 1 ;
return s ( n ) , this . toValue ( t , a ) . then ( ( o ) => Q ( o , "string" ) ) . then ( ( o ) => ! i && s ( o ) ) . catch ( ( o ) => ! i && s ( ` ${ o } ` ) ) , ( ) => i = ! 0 ;
} , [ t , a ] ) , r ;
} ) ;
g ( this , Me ) . call ( this , t ) ;
}
} ;
Qe = new WeakMap ( ) , Ie = new WeakMap ( ) , Me = new WeakMap ( ) , Xe = new WeakMap ( ) , P ( Ze , Qe , p . memoize ( ( t , a ) => G . getWidgetComponent ( t ) . then ( ( n ) => {
var r ;
return ( ( r = n . default ) == null ? void 0 : r . call ( n , a ) ) || ( ( s ) => s ) ;
} ) , ( t , a ) => ` ${ t } :: ${ Q ( a , "string" ) } ` ) ) ;
let ut = Ze ;
const Ja = ( e , t = { } ) => Z ( ( ) => e == null ? void 0 : e . map ( ( { widgetByJs : a , widgetByJsSetting : n , ... r } , s ) => a ? { ... r , render : ( i , o ) => new ut ( [ a , n ] ) . toRender ( i , o , "-" ) } : r ) , [ e , t ] ) , tr = ( e ) => {
const [ t , a ] = N ( { } ) ;
return x ( ( ) => {
let n = ! 1 ;
2024-12-03 10:15:14 +08:00
return e && F . get ( ` /api/_/ ${ e } ` ) . then ( ( r ) => p . pick ( r , [ "uuid" , "name" , "code" , "resource" , "marginX" , "marginY" , "cols" , "rowHeight" , "primaryKey" , "columns" , "itemOperations" , "batchOperations" , "isConditionFormLayout" , "layout" , "tabs" , "pageSize" , "layoutConfig" ] ) ) . then ( ( r ) => ! n && a ( r ) ) , ( ) => n = ! 0 ;
2024-12-02 16:59:57 +08:00
} , [ e ] ) , t ;
} , ar = ( e , t = { } ) => {
const [ a , n ] = N ( { dataSource : [ ] } ) ;
return De ( ( ) => {
let r = ! 1 ;
2024-12-03 10:15:14 +08:00
return e && F . get ( ` /api/ ${ e } / ${ F . encode ( { page : 1 , ... t } )} ` ) . then ( ( s ) => ! r && n ( s ) ) , ( ) => r = ! 0 ;
2024-12-02 16:59:57 +08:00
} , [ e , t ] ) , a ;
} , gt = ( e , t = null , a = null , n = "id" ) => Z ( ( ) => {
if ( p . isEmpty ( e ) || ! e . some ( ( { uuid : s } ) => Ha . check ( s ) ) ) return ! 1 ;
if ( p . isEmpty ( a ) || p . isEmpty ( t ) ) return ! 0 ;
const r = t . map ( ( s ) => ` ${ s == null ? void 0 : s [ n ] } ` ) ;
return e . some ( ( { uuid : s } ) => ! s || ! a . has ( s ) || a . get ( s ) . some ( ( i ) => r . includes ( ` ${ i } ` ) ) ) ;
2024-12-03 10:15:14 +08:00
} , [ e , t , a , n ] ) , Ka = ( e , t , a = "id" , n = null ) => {
const r = St ( ) , s = q ( ! 1 ) , i = q ( e . dataSource ) , o = q ( e . itemOperationsAccess ) ;
return x ( ( ) => ( i . current = e . dataSource , o . current = e . itemOperationsAccess , ( ) => s . current = ! 1 ) , [ e . dataSource , e . itemOperationsAccess ] ) , s . current && ( e . dataSource = i . current , e . itemOperationsAccess = o . current ) , [ e , ( l = 0 , c = null ) => {
var u , h ;
if ( l === 2 ) {
s . current = ! 0 ;
const m = p . get ( c , "__PARENT_ID__" , "" ) , f = p . get ( c , a , p . get ( c , [ n , a ] , "" ) ) , y = p . findIndex ( i . current , [ "__PARENT_ID__" , m ] ) , b = p . findIndex ( y > - 1 ? p . get ( i . current , [ y , "children" ] ) : i . current , [ a , f ] ) ;
b > - 1 ? ( F . get ( ` /api/ ${ t } /detail/ ${ f } ` ) . then ( ( w ) => {
const k = p . get ( i . current , y > - 1 ? [ y , "children" , b , "children" ] : [ b , "children" ] ) ;
i . current = Ht ( i . current , y > - 1 ? { [ y ] : { children : { $splice : [ [ b , 1 , { ... w , children : k } ] ] } } } : { $splice : [ [ b , 1 , { ... w , children : k } ] ] } ) , r ( ) ;
} ) , F . post ( ` /api/ ${ t } /list-operations-access ` , { ids : f } ) . then ( ( w ) => new Map ( w ) ) . then ( ( w ) => {
o . current . forEach ( ( k , E ) => {
var z ;
( z = w . get ( E ) ) != null && z . some ( ( j ) => j == f ) || o . current . set ( E , k . filter ( ( j ) => j !== f ) ) ;
} ) , w . forEach ( ( k , E ) => {
o . current . has ( E ) ? o . current . set ( E , p . uniq ( [ ... o . current . get ( E ) || [ ] , ... k ] ) ) : o . current . set ( E , k ) ;
} ) , r ( ) ;
} ) ) : ( u = e . onReload ) == null || u . call ( e ) ;
} else l === 1 && ( ( h = e . onReload ) == null || h . call ( e ) ) ;
2024-12-02 16:59:57 +08:00
} ] ;
} , _a = ( e , t ) => {
const a = St ( ) , n = q ( t ) , r = q ( /* @__PURE__ */ new Map ( ) ) , s = q ( [ ] ) , i = p . throttle ( ( l ) => {
2024-12-03 10:15:14 +08:00
s . current = [ ] , F . list ( e , p . pick ( { ... n . current , ... l } , [ "tab" , "page" , "pageSize" , "condition" , "sider" , "keyword" ] ) ) . then ( ( { keyword : c , condition : u , total : h , tab : m , sider : f , page : y , pageSize : b , operationsAccess : w , dataSource : k } ) => {
n . current = { tab : m , condition : u , sider : f , keyword : c , total : h , pageSize : b , page : k != null && k . length ? y : 1 } , s . current = k , r . current = new Map ( w ) , a ( ) ;
2024-12-02 16:59:57 +08:00
} ) ;
} , 380 , { leading : ! 1 , trailing : ! 0 } ) ;
$t ( ( ) => {
s . current = [ ] , e && i ( t ) ;
} , [ e , t ] ) ;
const o = Z ( ( ) => p . pick ( n . current , [ "total" , "tab" , "page" , "pageSize" , "condition" , "sider" , "keyword" ] ) , [ n . current ] ) ;
2024-12-02 17:31:31 +08:00
return Object . assign ( o , { onTabChange : ( l ) => i ( { tab : l , page : 1 } ) , onPageChange : ( l , c ) => i ( { page : l , pageSize : c } ) , onPageSizeChange : ( l ) => i ( { pageSize : l , page : 1 } ) , onConditionChange : ( l , c ) => i ( { keyword : c , condition : Ht ( n . current . condition || { } , { $merge : l || { } } ) , page : 1 } ) , onSiderChange : ( l ) => i ( { sider : l , page : 1 } ) , onKeywordChange : ( l ) => i ( { keyword : l , page : 1 } ) , itemOperationsAccess : r . current , dataSource : s . current , onReload : i } ) ;
2024-12-03 10:15:14 +08:00
} , Ga = ( { className : e , itemClassName : t , classNames : a = { } , dataSource : n , isPaginate : r , isItemOperations : s , isBatchOperations : i , batchOperations : o , itemOperations : l , itemOperationsAccess : c , resource : u , primaryKey : h , title : m , itemGridLayout : f , $setting : y , tabs : b , isConditionFormLayout : w , isTreeSider : k , treeSiderConfig : E } ) => {
const { getBase62params : z , onClickCallback : j , onTabChange : D } = Ue ( ve ) , { total : S , page : I , pageSize : L , tab : U } = ( z == null ? void 0 : z ( ) ) || { } , H = ce ( ( W , O , se ) => d ( Ya , { className : R ( "ff-data-list-framework-item" , t ) , operations : s && O ? l == null ? void 0 : l . filter ( ( A ) => ! ( h && A . uuid && c . has ( A . uuid ) ) || c . get ( A . uuid ) . includes ( O == null ? void 0 : O [ h ] ) ) : [ ] , data : u ? { [ u ] : O } : O , children : W , onClickCallback : j } ) , [ u , h , s , j , l , c ] ) ;
return T ( "div" , { className : R ( "ff-data-list-framework" , e ) , children : [ d ( na , { className : a == null ? void 0 : a . sider , isTreeSider : k , ... E } ) , T ( "div" , { className : R ( "ff-data-list-container" , a == null ? void 0 : a . container ) , children : [ d ( vt , { className : a == null ? void 0 : a . filter , isConditionFormLayout : w } ) , d ( aa , { title : m , className : a == null ? void 0 : a . toolbar , tabs : b , tab : U , onTabChange : D } ) , d ( on , { ... f , className : a == null ? void 0 : a . content , style : { "--col-num" : ( y == null ? void 0 : y . colNum ) || 1 } , primaryKey : h , itemRender : H , dataSource : n } ) , d ( ra , { className : a == null ? void 0 : a . footer , isPaginate : r , isOperations : i , operations : o , total : S , page : I , pageSize : L } ) ] } ) ] } ) ;
} , Ya = ( { className : e , operations : t , children : a , data : n , onClickCallback : r } ) => T ( "div" , { className : R ( "data-list-grid-layout-item-container" , e ) , children : [ a , ! ! ( t != null && t . length ) && d ( "div" , { className : "data-list-grid-layout-item-actions" , children : t . map ( ( s ) => d ( "span" , { className : "data-list-grid-layout-item-action" , children : d ( $ . Link , { uuid : s . uuid , type : s . type , name : s . name , widget : s . widget , widgetType : s . widgetType , widgetProps : s . widgetProps , widgetSetting : s . widgetSetting , widgetContainerProps : s . widgetContainerSetting , data : n , onAfterClick : ( i ) => i !== ! 1 && ( r == null ? void 0 : r ( s . isRefresh , n ) ) } , s . uuid || Ye ( ) ) } , ( s == null ? void 0 : s . uuid ) || Ye ( ) ) ) } ) ] } ) , Qa = ( { listCode : e , className : t , classNames : a = { } , itemClassName : n , dataSource : r , columns : s , isItemOperations : i , isBatchOperations : o , batchOperations : l , itemOperations : c , itemOperationsAccess : u , resource : h , primaryKey : m , title : f , tabs : y , isPaginate : b , isTreeSider : w , treeSiderConfig : k , isConditionFormLayout : E , ... z } ) => {
const { getBase62params : j , onClickCallback : D , onTabChange : S } = Ue ( ve ) , { total : I , page : L , tab : U , pageSize : H } = ( j == null ? void 0 : j ( ) ) || { } , W = gt ( c , r , u , m ) ;
return T ( "div" , { className : R ( "ff-data-table-framework" , t ) , children : [ d ( na , { className : a == null ? void 0 : a . sider , isTreeSider : w , ... k } ) , T ( "div" , { className : R ( "ff-data-table-container" , a == null ? void 0 : a . container ) , children : [ d ( vt , { listCode : e , isConditionFormLayout : E } ) , d ( aa , { title : f , className : a == null ? void 0 : a . toolbar , tabs : y , tab : U , onTabChange : S } ) , d ( tn , { ... z , primaryKey : m , className : "ff-data-table-content" , columns : s , dataSource : r , operationRender : W ? ( O ) => d ( "div" , { className : "ff-data-table-actions" , children : c == null ? void 0 : c . reduce ( ( se , A , Fe ) => [ ... se , d ( $ . Link , { size : "small" , uuid : A . uuid , type : A . type , name : A . name , widget : A . widget , widgetType : A . widgetType , widgetProps : A . widgetProps , widgetData : A . widgetData , widgetSetting : A . widgetSetting , widgetContainerProps : A . widgetContainerSetting , data : O , onAfterClick : ( Se ) => Se !== ! 1 && ( D == null ? void 0 : D ( A . isRefresh , data ) ) } , A . uuid || Fe ) ] , [ ] ) } ) : null } ) , d ( ra , { isPaginate : b , isOperations : o , operations : l , total : I , page : L , pageSize : H } ) ] } ) ] } ) ;
2024-12-02 16:59:57 +08:00
} , ve = C . createContext ( { listCode : "" , getBase62params : ( e , t ) => {
} , onReload : ( ) => {
} , onClickCallback : ( ) => {
} , onConditionChange : ( ) => {
} , onTabChange : ( ) => {
} , onSiderChange : ( ) => {
} , onKeywordChange : ( ) => {
} , onPageChange : ( ) => {
} , onPageSizeChange : ( ) => {
2024-12-03 10:15:14 +08:00
} } ) , Xa = ( { isItemGridLayout : e , theme : t , themeProps : a , onClickCallback : n , onReload : r , listCode : s , total : i = 0 , page : o = 0 , onPageChange : l , pageSize : c = 30 , onPageSizeChange : u , tab : h , onTabChange : m , keyword : f , onKeywordChange : y , condition : b , onConditionChange : w , sider : k , onSiderChange : E , ... z } ) => {
const [ j , D ] = N ( ) ;
2024-12-02 16:59:57 +08:00
return x ( ( ) => {
t ? G . getWidgetComponent ( t ) . then ( ( S ) => {
if ( ! S ) throw ` ${ t } not found ` ;
return S ;
2024-12-03 10:15:14 +08:00
} ) . catch ( ( S ) => ( { default : ( ) => ` ${ S } ` } ) ) . then ( ( S ) => D ( C . createElement ( S . default , { ... z , $setting : a } ) ) ) : D ( d ( e ? Ga : Qa , { ... z , $setting : a } ) ) ;
2024-12-02 17:31:31 +08:00
} , [ t , a ] ) , d ( ve . Provider , { value : { listCode : s , onClickCallback : n , onReload : r , getBase62params : ( S , I ) => {
2024-12-03 10:15:14 +08:00
const L = { tab : h , page : o , pageSize : c , keyword : f , sider : k , condition : b , total : i } ;
return S && S != "init" ? L [ S ] ? ? I : L ;
} , onPageChange : l , onPageSizeChange : u , onTabChange : m , onSiderChange : E , onKeywordChange : y , onConditionChange : w } , children : j && C . cloneElement ( j , z ) } ) ;
2024-12-02 16:59:57 +08:00
} ;
var ge , oe , ke , et ;
const ae = class ae {
constructor ( ) {
P ( this , oe , null ) ;
P ( this , ke , /* @__PURE__ */ new Map ( ) ) ;
P ( this , et , ( ) => {
if ( g ( this , oe ) ) return g ( this , oe ) . port . postMessage ( { command : "status" , data : [ ] } ) ;
B ( this , oe , new SharedWorker ( new URL ( "/ff-worker/res-ws.js" , self . location ) ) ) , g ( this , oe ) . port . onmessage = ( t ) => {
var a , n ;
( a = t . data ) != null && a . uuid ? g ( this , ke ) . forEach ( ( r , s ) => {
var i ;
( r == "*" || ( i = r == null ? void 0 : r . includes ) != null && i . call ( r , t . data . uuid ) ) && s ( t . data ) ;
2024-12-03 10:15:14 +08:00
} ) : ( ( n = t . data ) == null ? void 0 : n . readyState ) == WebSocket . CLOSED && F . get ( "/api/user-api-token" ) . then ( ( { token : r , expire _at : s } ) => {
g ( this , oe ) . port . postMessage ( { command : "initWs" , data : [ ` ws ${ p . trimStart ( F . appUrl , "http" ) } api/user-resource-status-ws?token= ${ r } ` ] } ) ;
2024-12-02 16:59:57 +08:00
} ) ;
} , g ( this , oe ) . port . postMessage ( { command : "status" , data : [ ] } ) ;
} ) ;
v ( this , "subscribe" , ( t , a = [ ] ) => ( a ? Array . isArray ( a ) && a . length == 0 ? a = "*" : Array . isArray ( a ) || ( a = [ a ] . flat ( ) ) : a = "*" , g ( this , ke ) . set ( t , a ) , g ( this , ke ) . size == 1 && g ( this , et ) . call ( this ) , ( ) => this . unsubscribe ( t ) ) ) ;
v ( this , "unsubscribe" , ( t ) => g ( this , ke ) . delete ( t ) ) ;
if ( g ( ae , ge ) ) return g ( ae , ge ) ;
}
} ;
ge = new WeakMap ( ) , oe = new WeakMap ( ) , ke = new WeakMap ( ) , et = new WeakMap ( ) , P ( ae , ge , null ) , v ( ae , "getInstance" , ( ) => ( g ( ae , ge ) || B ( ae , ge , new ae ( ) ) , g ( ae , ge ) ) ) ;
let pt = ae ;
const ea = pt . getInstance ( ) , kt = C . forwardRef ( ( { listCode : e , base62params : t , className : a , itemClassName : n , theme : r , themeProps : s , classNames : i } , o ) => {
2024-12-03 10:15:14 +08:00
const [ { resource : l , primaryKey : c , batchOperations : u = [ ] , itemOperations : h = [ ] , columns : m = [ ] , themeConfig : f , theme : y , isConditionFormLayout : b = ! 1 , isTreeSider : w , treeSiderConfig : k , isItemGridLayout : E , itemGridLayout : z , title : j , isPaginate : D , tabs : S } , I ] = N ( { isItemGridLayout : ! 1 , itemGridLayout : { } } ) , L = _a ( e , t ) , [ { dataSource : U , itemOperationsAccess : H , condition : W , tab : O , keyword : se , page : A , total : Fe , pageSize : Se , sider : at , onConditionChange : Tt , onTabChange : pa , onKeywordChange : ma , onPageChange : ha , onPageSizeChange : fa , onSiderChange : ya , onReload : nt } , Et ] = Ka ( L , e , c , l ) , wa = gt ( h , U , H , c ) , Ca = gt ( u ) ;
2024-12-02 16:59:57 +08:00
return x ( ( ) => {
let He = null ;
2024-12-03 10:15:14 +08:00
return e && F . get ( ` /api/_/ ${ e } ` ) . resp ( ( { data : Je , res : ba } ) => {
2024-12-02 16:59:57 +08:00
Je != null && Je . isDynamicRefresh && ( He = ea . subscribe ( ( ) => nt ( ) , ba ) ) , I ( Je ) ;
} ) . catch ( ( ) => I ( { } ) ) , ( ) => He == null ? void 0 : He ( ) ;
2024-12-03 10:15:14 +08:00
} , [ e ] ) , C . useImperativeHandle ( o , ( ) => ( { onReload : nt , onClickCallback : Et } ) ) , d ( Xa , { listCode : e , title : j , itemClassName : n , classNames : i , resource : l , primaryKey : c , theme : r || y , themeProps : s || f , isTreeSider : w , treeSiderConfig : k , isPaginate : D , tabs : S , isItemOperations : wa , isBatchOperations : Ca , batchOperations : u , itemOperations : h , isItemGridLayout : E , columns : m , itemGridLayout : z , isConditionFormLayout : b , itemOperationsAccess : H , dataSource : U , onConditionChange : Tt , onTabChange : pa , onKeywordChange : ma , onPageChange : ha , onPageSizeChange : fa , onSiderChange : ya , condition : W , tab : O , keyword : se , page : A , total : Fe , pageSize : Se , sider : at , className : R ( "ff-data-list-helper" , a ) , onReload : nt , onClickCallback : Et } ) ;
2024-12-02 16:59:57 +08:00
} ) , ta = ( e , t , a , n , r = { } , s = 0 ) => {
const i = { "--grid-layout-h" : ` ${ n } ` , "--grid-layout-w" : ` ${ a } ` , "--grid-layout-x" : ` ${ e } ` , "--grid-layout-y" : ` ${ t } ` , "--grid-layout-row-height-offset" : "0px" } ;
return r != null && r . autoHeight ? i . height = "fit-content" : i [ "--grid-layout-row" ] = ` ${ n } ` , i [ "--grid-layout-box-margin" ] = jt ( r == null ? void 0 : r . marginTop , r == null ? void 0 : r . marginRight , r == null ? void 0 : r . marginBottom , r == null ? void 0 : r . marginLeft ) , i [ "--grid-layout-box-padding" ] = jt ( r == null ? void 0 : r . paddingTop , r == null ? void 0 : r . paddingRight , r == null ? void 0 : r . paddingBottom , r == null ? void 0 : r . paddingLeft ) , s && ( i . height = ` ${ s } px ` ) , i ;
} , jt = ( e , t , a , n ) => ` ${ e || 0 } px ${ t || 0 } px ${ a || 0 } px ${ n || 0 } px ` , vt = ( { className : e , isConditionFormLayout : t } ) => {
2024-12-03 10:15:14 +08:00
var h , m ;
2024-12-02 17:31:31 +08:00
const [ a , n ] = N ( { } ) , { listCode : r , onKeywordChange : s , onConditionChange : i , getBase62params : o } = C . useContext ( ve ) , { keyword : l , condition : c } = ( o == null ? void 0 : o ( ) ) || { } , [ u ] = _e . useForm ( ) ;
2024-12-02 16:59:57 +08:00
return x ( ( ) => {
2024-12-03 10:15:14 +08:00
r && t && F . get ( ` /api/_/ ${ r } /list-condition-form-layout ` ) . then ( ( { resource : f , marginX : y , marginY : b , rowHeight : w , cols : k , fields : E } ) => {
n ( { resource : f , itemMargin : [ y , b ] , rowHeight : w , cols : k , fields : E } ) ;
2024-12-02 16:59:57 +08:00
} ) . catch ( ( ) => n ( { } ) ) ;
} , [ r , t ] ) , x ( ( ) => {
2024-12-02 17:31:31 +08:00
u . setFieldsValue ( { keyword : l , ... c } ) ;
2024-12-03 10:15:14 +08:00
} , [ JSON . stringify ( [ l , c ] ) ] ) , d ( "div" , { className : R ( "ff-data-list-filter" , e ) , children : d ( _e , { form : u , layout : "vertical" , autoComplete : "off" , onFinish : ( ( h = a . fields ) == null ? void 0 : h . length ) > 1 ? ( f ) => i ( { [ a . resource ] : f [ a . resource ] } , f . keyword ) : ( ) => {
} , onValuesChange : ( f ) => {
p . isEmpty ( p . omit ( f , [ "keyword" ] ) ) || u . submit ( ) ;
2024-12-02 17:31:31 +08:00
} , children : ( ( m = a . fields ) == null ? void 0 : m . length ) > 1 ? d ( Nt , { ... a , children : d ( Za , { onReset : ( ) => {
2024-12-03 10:15:14 +08:00
const { keyword : f , condition : y } = o ( "init" ) || { } ;
u . setFieldsValue ( { keyword : f , ... y } ) ;
} } ) } ) : d ( "div" , { className : "ff-data-list-filter-default-form ff-grid-layout-form" , children : d ( "div" , { className : "grid-layout-item" , style : ta ( 20 , 0 , 5 , 2 ) , children : d ( _e . Item , { name : [ "keyword" ] , children : d ( $a . Search , { allowClear : ! 0 , enterButton : "搜索" , placeholder : "多关键字 | 分割" , onSearch : ( f ) => s ( f ) } ) } ) } ) } ) } ) } ) ;
2024-12-02 16:59:57 +08:00
} , Za = ( { cols : e , fields : t , onReset : a } ) => {
const [ n , r ] = N ( ! 1 ) , s = Z ( ( ) => t == null ? void 0 : t . toReversed ( ) . some ( ( i ) => i . y > 1 || i . x + i . w >= e - 5 ) , [ e , t ] ) ;
2024-12-03 10:15:14 +08:00
return T ( _e . Item , { label : " " , style : { "--item-span" : 5 } , className : R ( "ff-data-list-filter-actions" , { expanded : n } ) , children : [ d ( ot , { onClick : a , children : "重置" } ) , d ( ot , { type : "primary" , htmlType : "submit" , children : "查询" } ) , s && d ( $ . Link , { className : "ff-data-list-filter-expanded-button" , widget : ( ) => r ( ( i ) => ! i ) , type : "primary" , name : n ? "关闭" : "展开" , icon : n ? "icon-up" : "icon-down" , iconPosition : "end" } ) ] } ) ;
2024-12-02 16:59:57 +08:00
} ;
vt . reservedFields = [ { x : 0 , y : 0 , h : 3 , w : 5 , field : { isVirtual : ! 0 , widgetPrefix : "@pkg/ff/grid-layout-forms" , widget : "Input" , code : "keyword" , label : "关键字" , placeholder : "多关键字 | 分割" , extras : { prefix : "icon-search" } } } ] ;
const aa = ( { className : e , title : t , tabs : a , tab : n , onTabChange : r } ) => {
2024-12-02 17:31:31 +08:00
const [ s , i ] = La ( ( a == null ? void 0 : a [ 0 ] . value ) ? ? ( a == null ? void 0 : a [ 0 ] . code ) , { value : n , onChange : r } ) ;
2024-12-03 10:15:14 +08:00
return T ( "div" , { className : R ( "ff-data-list-toolbar" , e ) , children : [ d ( "div" , { className : "ff-data-list-title" , children : t } ) , d ( Na , { className : "ff-data-list-tabs" , itemRender : ( { label : o , code : l , value : c } ) => d ( "span" , { onClick : ( ) => i ( c ? ? l ) , className : R ( "ff-data-list-tab" , { active : ( c ? ? l ) == s } ) , children : o } ) , items : a } ) , T ( "div" , { className : "ff-data-list-actions" , children : [ d ( $ . Link , { icon : "icon-reload" } ) , d ( $ . Link , { icon : "icon-setting" } ) ] } ) ] } ) ;
} , en = [ { title : "parent 1" , key : "0-0" , children : [ { title : "parent 1-0" , key : "0-0-0" , disabled : ! 0 , children : [ { title : "leaf" , key : "0-0-0-0" , disableCheckbox : ! 0 } , { title : "leaf" , key : "0-0-0-1" } ] } , { title : "parent 1-1" , key : "0-0-1" , children : [ { title : d ( "span" , { style : { color : "#1677ff" } , children : "sss" } ) , key : "0-0-1-0" } ] } ] } ] , na = ( { className : e , width : t = 280 , isTreeSider : a } ) => a ? d ( Pa . DirectoryTree , { className : R ( "ff-data-list-sider" , e ) , style : { "--sider-width" : t } , showLine : ! 0 , showIcon : ! 1 , treeData : en } ) : null , ra = ( { className : e , operations : t , isOperations : a , isPaginate : n , total : r , page : s , pageSize : i } ) => {
2024-12-02 17:31:31 +08:00
const { onPageChange : o , onPageSizeChange : l , onClickCallback : c } = C . useContext ( ve ) ;
2024-12-03 10:15:14 +08:00
return a && ! p . isEmpty ( t ) || n ? T ( "div" , { className : R ( "ff-data-list-footer" , e ) , children : [ d ( "div" , { className : "ff-data-list-actions" , children : t == null ? void 0 : t . map ( ( u , h ) => d ( $ , { uuid : u . uuid , type : u . type , name : u . name , widget : u . widget , widgetType : u . widgetType , widgetProps : u . widgetProps , widgetData : u . widgetData , widgetSetting : u . widgetSetting , widgetContainerProps : u . widgetContainerSetting , onAfterClick : ( m ) => m !== ! 1 && ( c == null ? void 0 : c ( u . isRefresh , null ) ) } , u . uuid || h ) ) } ) , n && d ( xa , { size : "small" , total : r , pageSize : i , showSizeChanger : ! 1 , showTotal : ( u ) => ` 第 ${ s } 页 / 总共 ${ u } 条 ` , onChange : o , onShowSizeChange : l } ) ] } ) : null ;
2024-12-02 16:59:57 +08:00
} , sa = ( e , t , a = ! 0 ) => a !== ! 0 && a -- <= 0 ? [ ] : p . isArray ( e ) && ! p . isEmpty ( e ) ? e . reduce ( ( n , r ) => ( Reflect . has ( r , t ) && Reflect . has ( r , "children" ) && n . push ( r [ t ] ) , Reflect . has ( r , "children" ) && ! p . isEmpty ( r . children ) ? n . concat ( sa ( r . children , t , a ) ) : n ) , [ ] ) : [ ] , tn = ( { className : e , primaryKey : t , columns : a = [ ] , dataSource : n = [ ] , operationRender : r , operationWidth : s = 180 , ... i } ) => {
Ye ( ) ;
2024-12-03 10:15:14 +08:00
const o = q ( null ) , l = q ( null ) , [ c , u ] = N ( [ ] ) , [ h , m ] = N ( { width : 0 , height : 0 } ) ;
2024-12-02 16:59:57 +08:00
x ( ( ) => {
2024-12-02 17:31:31 +08:00
u ( sa ( n , t ) ) ;
2024-12-02 16:59:57 +08:00
} , [ n , t ] ) , Sa ( ( ) => {
const y = new ResizeObserver ( ( ) => {
var b ;
m ( { width : ( ( b = o . current ) == null ? void 0 : b . nativeElement . querySelector ( ".ant-table-body" ) . scrollWidth ) || l . current . offsetWidth , height : l . current . offsetHeight } ) ;
} ) ;
return l . current && y . observe ( l . current ) , ( ) => {
l . current && y . unobserve ( l . current ) ;
} ;
} , [ ] ) ;
2024-12-03 10:15:14 +08:00
const f = Ja ( a ) ;
return d ( "div" , { ref : l , className : R ( "ff-data-list-table" , e ) , children : h . height ? d ( Ta , { ... i , ref : o , rowKey : ( y ) => ( y == null ? void 0 : y [ t ] ) ? ? Math . random ( ) , columns : f == null ? void 0 : f . concat ( r ? [ { title : "操作" , align : "center" , fixed : "right" , width : ` ${ Math . ceil ( s / h . width * 100 ) . toFixed ( 2 ) } % ` , render : ( y , b , w ) => r ( b , w ) } ] : [ ] ) , dataSource : n , size : "middle" , scroll : { x : "max-content" , y : h . height - 50 } , pagination : ! 1 , expandable : { defaultExpandAllRows : ! 0 , expandRowByClick : ! 0 , onExpandedRowsChange : u , expandedRowKeys : c } } ) : null } ) ;
2024-12-02 16:59:57 +08:00
} , an = "RC_FORM_INTERNAL_HOOKS" , ia = ( e , { initialValue : t , initialValueLanguage : a , convertJs : n , convertJsSetting : r , type : s = "string" } , i = null ) => {
2024-12-03 10:15:14 +08:00
const o = q ( ! 1 ) , l = Ue ( Va ) , [ c , u ] = N ( ) , [ h , m ] = N ( a != "javascript" && e ? l . getFieldValue ( e ) : void 0 ) , { registerWatch : f } = l . getInternalHooks ( an ) || { } ;
return x ( ( ) => f == null ? void 0 : f ( ( y , b , w ) => {
2024-12-02 16:59:57 +08:00
if ( ! o . current ) return ;
const k = p . get ( b , e ) ;
2024-12-03 10:15:14 +08:00
p . isEqual ( k , h ) || m ( Q ( k , s ) ) ;
} ) , [ h ] ) , x ( ( ) => {
2024-12-02 16:59:57 +08:00
a == "javascript" && t ? we . exec ( t , { } , { getFieldValueForBasicForm : ( y ) => i ? i . getFieldValue ( y ) : l . getFieldValue ( y ) , getFieldValue : ( y ) => l . getFieldValue ( y ) } ) . then ( ( y ) => m ( Q ( y , s ) ) ) . catch ( ( y ) => notification . error ( { message : ` 布局数据错误: ${ JSON . stringify ( y ) } ` } ) ) . finally ( ( ) => o . current = ! 0 ) : ( t && m ( Q ( t ? ? l . getFieldValue ( e ) , s ) ) , o . current = ! 0 ) ;
} , [ t , a ] ) , De ( ( ) => {
2024-12-03 10:15:14 +08:00
o . current && n && G . getWidgetComponent ( n ) . then ( ( { default : y } ) => y ( { value : h , record : l . getFieldsValue ( ! 0 ) , $setting : r } ) ) . then ( u ) . catch ( ( y ) => console . error ( "布局数据转换错误: " , y , n ) ) ;
} , [ h , n , r ] ) , [ c || h , h ] ;
2024-12-02 16:59:57 +08:00
} , oa = ( e , t , a = "@pkg/ff/grid-layouts" , n = null ) => Z ( ( ) => {
var r ;
2024-12-03 10:15:14 +08:00
return ( r = p . sortBy ( e , [ "y" , "x" ] ) ) == null ? void 0 : r . map ( ( { i : s , x : i , y : o , w : l , h : c , field : { boxStyle : u , widgetPrefix : h = a , widget : m , ... f } } , y ) => d ( "div" , { className : "grid-layout-item" , style : ta ( i , o , l , c , u , m === "Height" && ( f == null ? void 0 : f . initialValue ) ) , children : d ( nn , { ... f , basicForm : n , itemWidget : m != null && m . startsWith ( "@" ) || m != null && m . startsWith ( "blob:" ) ? m : ` ${ h } / ${ m } ` , itemWidgetRender : t } ) } , s || y ) ) ;
2024-12-02 16:59:57 +08:00
} , [ e ] ) , nn = ( { itemWidget : e , itemWidgetRender : t , basicForm : a , ... n } ) => {
const [ r , s ] = N ( ) ;
return x ( ( ) => {
G . getWidgetComponent ( e ) . then ( ( { defaultProps : i = { } , default : o } ) => {
s ( C . createElement ( t ( o , i , a ) , n ) ) ;
} ) . catch ( ( i ) => {
console . error ( i ) , s ( e ) ;
} ) ;
} , [ e ] ) , r ;
} , la = ( { cols : e = 12 , rowHeight : t = 21 , fields : a = [ ] , data : n , containerPadding : r = [ 0 , 0 ] , itemMargin : s = [ 4 , 0 ] , formProps : i = { } , className : o , ... l } ) => {
2024-12-03 10:15:14 +08:00
const [ c ] = X . useForm ( ) , u = oa ( a , rn , "@pkg/ff/grid-layouts" ) , h = Z ( ( ) => [ { name : "__PROPS__" , value : i } ] , [ i ] ) ;
2024-12-02 16:59:57 +08:00
return De ( ( ) => {
2024-12-02 17:31:31 +08:00
c . setFieldsValue ( n ) ;
2024-12-03 10:15:14 +08:00
} , [ n ] ) , d ( X , { fields : h , form : c , component : ! 1 , children : d ( "div" , { ... l , className : R ( "ff-grid-layout" , o ) , style : { "--grid-layout-item-margin-y" : ` ${ ( s == null ? void 0 : s [ 0 ] ) || 0 } px ` , "--grid-layout-item-margin-x" : ` ${ ( s == null ? void 0 : s [ 1 ] ) || 0 } px ` , "--grid-layout-container-padding-y" : ` ${ ( r == null ? void 0 : r [ 0 ] ) || 0 } px ` , "--grid-layout-container-padding-x" : ` ${ ( r == null ? void 0 : r [ 1 ] ) || 0 } px ` , "--grid-layout-cols" : e , "--grid-layout-row-height" : ` ${ t } px ` } , children : u } ) } ) ;
2024-12-02 16:59:57 +08:00
} , rn = ( e , t = { } , a = null ) => ( n ) => {
2024-12-03 10:15:14 +08:00
const { code : r , label : s , extras : i , isVirtual : o , initialValue : l , initialValueLanguage : c , convertJs : u , convertJsSetting : h , ... m } = p . merge ( { } , t , n ) , [ f , y ] = ia ( o ? null : r , { initialValue : l , initialValueLanguage : c , convertJs : u , convertJsSetting : h , type : ( m == null ? void 0 : m . type ) || "string" } , a ) ;
return d ( e , { ... m , value : f , rawValue : y , $setting : i || { } } ) ;
2024-12-02 16:59:57 +08:00
} , nr = ( It = la , function ( { code : e , data : t , ... a } ) {
const [ n , r ] = N ( { resource : null , cols : 12 , rowHeight : 21 , fields : [ ] } ) ;
return x ( ( ) => {
2024-12-03 10:15:14 +08:00
e && F . get ( ` /api/_/ ${ e } ` ) . then ( ( s ) => r ( p . pick ( s , [ "resource" , "cols" , "rowHeight" , "fields" ] ) ) ) ;
2024-12-02 17:31:31 +08:00
} , [ e ] ) , ( n == null ? void 0 : n . resource ) && d ( It , { ... a , rowHeight : n . rowHeight , cols : n . cols , fields : n . fields , data : n != null && n . resource ? { [ n == null ? void 0 : n . resource ] : t } : { } } ) ;
2024-12-02 16:59:57 +08:00
} ) ;
var It ;
const rr = ( { widget : e , widgetPrefix : t = "@pkg/ff/grid-layouts" , basicForm : a , ... n } ) => {
const r = e != null && e . startsWith ( "@" ) || e != null && e . startsWith ( "blob:" ) ? e : ` ${ t } / ${ e } ` , [ s , i ] = N ( ) ;
return x ( ( ) => {
r && G . getWidgetComponent ( r ) . then ( ( { defaultProps : o = { } , default : l } ) => ( { default : sn ( l , o , a ) } ) ) . catch ( ( o ) => ( { default : ( ) => ` ${ o } ` } ) ) . then ( ( o ) => i ( C . createElement ( o . default , n ) ) ) ;
} , [ r ] ) , s ;
} , sn = ( e , t = { } , a = null ) => ( n ) => {
2024-12-03 10:15:14 +08:00
const { code : r , label : s , extras : i , isVirtual : o , initialValue : l , initialValueLanguage : c , convertJs : u , convertJsSetting : h , value : m , ... f } = p . merge ( { } , t , n ) , [ y , b ] = ia ( o ? null : r , { initialValue : l , initialValueLanguage : c , convertJs : u , convertJsSetting : h , type : ( f == null ? void 0 : f . type ) || "string" } , a ) ;
return d ( e , { ... f , value : y , rawValue : b , $setting : i || { } } ) ;
} , on = ( { cols : e , rowHeight : t , itemMargin : a , fields : n , primaryKey : r , dataSource : s , itemClassName : i , itemRender : o = ( h , m , f ) => h , empty : l = d ( Ea , { description : null } ) , className : c , style : u = { } } ) => {
const h = Ye ( ) , m = Z ( ( ) => d ( la , { cols : e , rowHeight : t , itemMargin : a , fields : n , className : i } ) , [ n , e , t , a ] ) ;
return d ( "div" , { className : R ( "ff-data-list-content" , c ) , style : u , children : p . isEmpty ( s ) ? l : s == null ? void 0 : s . map ( ( f , y ) => d ( C . Fragment , { children : o ( C . cloneElement ( m , { data : f } ) , f , y ) } , ` ${ h } - ${ ( f == null ? void 0 : f [ r ] ) || y } ` ) ) } ) ;
2024-12-02 16:59:57 +08:00
} , ln = ( { component : e } ) => {
const { base62params : t } = Aa ( ) ;
2024-12-03 10:15:14 +08:00
return d ( K , { children : d ( kt , { listCode : e , base62params : F . decode ( t ) } ) } ) ;
2024-12-02 16:59:57 +08:00
} , cn = ( ) => "Empty" , dn = ( { component : e , $setting : t } ) => {
const [ a , n ] = N ( ) ;
x ( ( ) => {
2024-12-02 17:31:31 +08:00
if ( ! e ) return n ( d ( cn , { description : null } ) ) ;
2024-12-02 16:59:57 +08:00
G . getWidgetComponent ( e ) . catch ( ( s ) => ( { default : ( ) => ` ${ s } ` } ) ) . then ( ( s ) => C . createElement ( s . default , { $setting : t } ) ) . then ( n ) ;
} , [ e ] ) ;
const r = le . getPageParams ( ) || { } ;
return a ? C . cloneElement ( a , r ) : null ;
} ;
var pe , Y , me , he , ze , We ;
const ne = class ne {
constructor ( ) {
P ( this , Y , /* @__PURE__ */ new Map ( ) ) ;
P ( this , me , { } ) ;
P ( this , he , null ) ;
v ( this , "init" , ( t , a ) => {
B ( this , Y , t ) , B ( this , me , a ) ;
} ) ;
v ( this , "get" , ( t ) => ( g ( this , Y ) . has ( t ) || ( t = Array . from ( g ( this , Y ) . keys ( ) ) . find ( ( a ) => g ( this , Y ) . get ( a ) . uri === t ) ) , g ( this , Y ) . get ( t ) || { } ) ) ;
v ( this , "redirect" , ( t , a , n = { } ) => {
const { uri : r , type : s , widgetProps : i } = this . get ( t ) || { } ;
2024-12-03 10:15:14 +08:00
let o = ja ( r || t , s != "list" ? a : p . mapValues ( a , ( c ) => F . encode ( c ) ) ) ;
2024-12-02 16:59:57 +08:00
const l = new URLSearchParams ( ) ;
2024-12-02 17:31:31 +08:00
for ( const c in i || { } ) ( i == null ? void 0 : i . type ) == "query" && l . append ( c , a [ c ] ) ;
2024-12-02 16:59:57 +08:00
return l . size > 0 && ( o = ` ${ o } ? ${ l . toString ( ) } ` ) , g ( this , he ) . navigate ( o , n ) ;
} ) ;
v ( this , "getMenus" , ( t ) => {
var a ;
return ( ( a = g ( this , me ) ) == null ? void 0 : a [ t ] ) || [ ] ;
} ) ;
v ( this , "findMenuPathByUuid" , ( t ) => {
let a = [ ] ;
for ( const n in g ( this , me ) ) if ( a = g ( this , ze ) . call ( this , g ( this , me ) [ n ] , t , [ n ] ) , a . length > 1 ) return a ;
return a ;
} ) ;
v ( this , "getMenusByRouteUuid" , ( t ) => g ( this , We ) . call ( this , t , Object . values ( g ( this , me ) ) . flat ( ) ) ) ;
P ( this , ze , ( t , a , n = [ ] ) => {
if ( p . isEmpty ( t ) ) return n ;
for ( const { uuid : r , children : s } of t ) {
if ( r == a ) return n . concat ( r ) ;
if ( ! p . isEmpty ( s ) ) return n . concat ( r , g ( this , ze ) . call ( this , s , a ) ) ;
}
return n ;
} ) ;
P ( this , We , ( t , a ) => {
var r ;
let n = [ ] ;
for ( const s of a ) s . widgetType == "redirect" && ( s . uuid == t || s . widget == t ? n . push ( s ) : ( r = s . children ) != null && r . length && ( n = n . concat ( g ( this , We ) . call ( this , t , s . children ) ) ) ) ;
return n ;
} ) ;
v ( this , "getCurrentMenu" , ( ) => {
const { uuid : t } = this . getCurrentRoute ( ) || { } ;
if ( ! t ) return ;
const a = this . getMenusByRouteUuid ( t ) ;
return p . isEmpty ( a ) ? void 0 : a [ 0 ] ;
} ) ;
v ( this , "getCurrentRoute" , ( t = 0 ) => {
var n ;
const a = ( n = g ( this , he ) . state . matches [ g ( this , he ) . state . matches . length - 1 - t ] ) == null ? void 0 : n . route ;
if ( ! a ) return null ;
for ( let [ r , s ] of g ( this , Y ) ) if ( s . uri === a . path ) return s ;
return null ;
} ) ;
v ( this , "getPageParams" , ( t ) => {
var s ;
const { location : a , matches : n } = g ( this , he ) . state , r = ( ( s = n [ n . length - 1 ] ) == null ? void 0 : s . params ) || { } ;
return a . search && new URLSearchParams ( a . search ) . forEach ( ( i , o ) => {
r [ o ] = i ;
} ) , t ? p . get ( r , t ) : r ;
} ) ;
v ( this , "createBrowserRouter" , ( t = { } ) => {
if ( g ( this , Y ) . size == 0 ) return null ;
2024-12-02 17:31:31 +08:00
const a = Le . get ( "Common.WEBSITE_DEFAULT_THEME" , "@pkg/ff/frameworks/BasicLayout" ) , n = Le . get ( G . checkUserToken ( ) ? "Common.WEBSITE_LOGIN_REDIRECT" : "Common.WEBSITE_DEFAULT" , "/index" ) , r = { [ a ] : 0 } , s = ( o , l ) => ( ) => G . getWidgetComponent ( o ) . then ( ( c ) => c . default || function ( ) {
2024-12-02 16:59:57 +08:00
return ` ${ o } ` ;
2024-12-03 10:15:14 +08:00
} ) . then ( ( c ) => ( { Component : ( ) => C . createElement ( _t , { } , C . createElement ( c , l ) ) } ) ) , i = Array . from ( g ( this , Y ) . values ( ) ) . reduce ( ( o , { uuid : l , uri : c , name : u , type : h , component : m , widgetSetting : f , isLogin : y , isLayout : b , extra : w } ) => {
let k = { } , E = 0 ;
switch ( h ) {
2024-12-02 16:59:57 +08:00
case "list" :
k . element = C . createElement ( ln , { component : m } ) ;
break ;
case "fsdpf-component" :
2024-12-03 10:15:14 +08:00
k . element = C . createElement ( dn , { key : m , component : m , $setting : f } ) ;
2024-12-02 16:59:57 +08:00
}
if ( w != null && w . layout ) {
2024-12-02 17:31:31 +08:00
if ( ! r [ w == null ? void 0 : w . layout ] ) return r [ w == null ? void 0 : w . layout ] = o . length , [ ... o , { path : "/" , lazy : s ( w == null ? void 0 : w . layout , { } ) , children : [ { path : c , ... k } ] } ] ;
2024-12-03 10:15:14 +08:00
E = r [ w == null ? void 0 : w . layout ] ;
2024-12-02 16:59:57 +08:00
}
2024-12-03 10:15:14 +08:00
return b && E > - 1 ? ( o [ E ] . children . push ( { path : c , ... k } ) , o ) : [ ... o , { path : c , ... k } ] ;
2024-12-02 16:59:57 +08:00
} , [ { path : "/" , lazy : s ( a , { } ) , children : [ ] } ] ) ;
return i . push ( { index : ! 0 , element : C . createElement ( un , { to : n , replace : ! 0 } ) } ) , B ( this , he , Ia ( i , t ) ) ;
} ) ;
if ( g ( ne , pe ) ) return g ( ne , pe ) ;
}
} ;
pe = new WeakMap ( ) , Y = new WeakMap ( ) , me = new WeakMap ( ) , he = new WeakMap ( ) , ze = new WeakMap ( ) , We = new WeakMap ( ) , P ( ne , pe , null ) , v ( ne , "getInstance" , ( ) => ( g ( ne , pe ) || B ( ne , pe , new ne ( ) ) , g ( ne , pe ) ) ) ;
let mt = ne ;
const un = ( { to : e , replace : t } ) => Ma ( ) ? C . createElement ( za , { to : e , replace : t } ) : ( window . document . location = e , "redirect" ) , le = mt . getInstance ( ) , $e = new Worker ( new URL ( "/ff-worker/index.js" , self . location ) ) , Mt = { getConfigure : ( e ) => Le . get ( e ) , route : { redirect : ( ... e ) => le . redirect ( ... e ) , getPageParams : ( ... e ) => le . getPageParams ( ... e ) , getCurrentRoute : ( ) => le . getCurrentRoute ( ) } , popup : { notification : ( ... e ) => _ . notification ( ... e ) , success : ( ... e ) => _ . success ( ... e ) , error : ( ... e ) => _ . error ( ... e ) , form : ( ... e ) => _ . form ( ... e ) , modal : ( ... e ) => _ . modal ( ... e ) , confirm : ( ... e ) => _ . confirm ( ... e ) } } ;
var tt , Te , fe ;
const M = class M {
constructor ( ) {
v ( this , "exec" , ( t , a = { } , n = { } , r = "" ) => new Promise ( ( s , i ) => {
const o = Ot ( M , tt ) . _ ++ ;
g ( M , Te ) . set ( o , n ) , M . mQueue . set ( o , [ s , i ] ) , $e . postMessage ( { id : o , session : r , category : "eval" , method : t , args : a } ) ;
} ) ) ;
v ( this , "clear" , ( t ) => $e . postMessage ( { session : t , category : "clear" } ) ) ;
if ( g ( M , fe ) ) return g ( M , fe ) ;
Promise . resolve ( ) . then ( ( ) => Vn ) . then ( ( t ) => {
Mt . http = t . http ;
} ) , $e . addEventListener ( "message" , ( { data : { id : t , task _id : a , method : n , args : r , category : s , data : i , error : o , session : l } } ) => {
if ( s === "eval" && M . mQueue . has ( t ) ) o !== null ? M . mQueue . get ( t ) [ 1 ] ( o ) : M . mQueue . get ( t ) [ 0 ] ( i ) , g ( M , Te ) . delete ( t ) , M . mQueue . delete ( t ) ;
else if ( s === "util" ) try {
2024-12-02 17:31:31 +08:00
const c = p . get ( Mt , n . split ( "/" ) ) || p . get ( g ( M , Te ) . get ( a ) , n . split ( "/" ) ) ;
if ( ! p . isFunction ( c ) ) throw ` ${ n } not found ` ;
Promise . resolve ( Reflect . apply ( c , void 0 , r ) ) . then ( ( u ) => {
$e . postMessage ( { id : t , task _id : a , category : s , method : n , args : r , session : l , data : u , error : null } ) ;
} ) . catch ( ( u ) => {
$e . postMessage ( { id : t , task _id : a , category : s , method : n , args : r , session : l , data : null , error : u } ) ;
2024-12-02 16:59:57 +08:00
} ) ;
2024-12-02 17:31:31 +08:00
} catch ( c ) {
$e . postMessage ( { id : t , task _id : a , category : s , method : n , args : r , session : l , data : null , error : c } ) ;
2024-12-02 16:59:57 +08:00
}
} , ! 1 ) ;
}
} ;
tt = new WeakMap ( ) , Te = new WeakMap ( ) , fe = new WeakMap ( ) , v ( M , "mQueue" , /* @__PURE__ */ new Map ( ) ) , P ( M , tt , 0 ) , P ( M , Te , /* @__PURE__ */ new Map ( ) ) , P ( M , fe , null ) , v ( M , "getInstance" , ( ) => ( g ( M , fe ) || B ( M , fe , new M ( ) ) , g ( M , fe ) ) ) ;
let ht = M ;
const we = ht . getInstance ( ) , St = ( ) => {
const e = q ( ! 0 ) , [ , t ] = C . useReducer ( ( a ) => a + 1 , 0 ) ;
return x ( ( ) => ( ) => e . current = ! 1 , [ ] ) , ( ) => e . current && t ( ) ;
} , sr = ( e ) => {
const t = q ( ) ;
return x ( ( ) => {
t . current = e ;
} , [ e ] ) , t . current ;
} , ir = ( e ) => {
const [ t , a ] = N ( e ) , n = q ( null ) , r = ce ( ( s , i ) => {
n . current = i , a ( s ) ;
} , [ ] ) ;
return x ( ( ) => {
n . current && ( n . current ( t ) , n . current = null ) ;
} , [ t ] ) , [ t , r ] ;
} , De = ( e = ( n ) => {
} , t , a = p . isEqual ) => {
const n = C . useRef ( ) ;
a ( t , n . current ) || ( n . current = p . cloneDeep ( t ) ) , C . useEffect ( e , [ n . current ] ) ;
} , $t = De , ca = ( e , t = "string" ) => {
var a ;
if ( ! Array . isArray ( e ) ) return e ;
for ( let n = 0 ; n < e . length ; n ++ ) e [ n ] . value = Q ( ( a = e [ n ] ) == null ? void 0 : a . value , t ) , e [ n ] && Reflect . has ( e [ n ] , "children" ) && ( e [ n ] . children = ca ( e [ n ] . children , t ) ) ;
return e ;
} , or = ( e , t = "json" , a = "string" , n , r = null ) => {
2024-12-02 17:31:31 +08:00
const [ s ] = X . useForm ( n ) , [ i , o ] = N ( [ { label : "无" , value : "" , disabled : ! 0 } ] ) , l = q ( [ ] ) , c = X . useWatch ( ( u ) => l . current . length === 0 ? null : p . pick ( u , l . current ) , s ) || null ;
2024-12-02 16:59:57 +08:00
return x ( ( ) => {
2024-12-02 17:31:31 +08:00
Array . isArray ( e ) ? o ( e ) : t === "javascript" && e ? we . exec ( e , { } , { getFieldValue : ( u ) => ( l . current . includes ( u ) || l . current . push ( u ) , s . getFieldValue ( u ) ) , getFieldValueForBasicForm : ( u ) => ( l . current . includes ( u ) || l . current . push ( u ) , r ? r . getFieldValue ( u ) : s . getFieldValue ( u ) ) } ) . then ( ( u ) => {
o ( Q ( u , "array" ) ) ;
2024-12-02 16:59:57 +08:00
} ) : e && o ( Q ( e , "array" ) ) ;
2024-12-02 17:31:31 +08:00
} , [ e , t , c ] ) , ca ( i , a ) ;
2024-12-02 16:59:57 +08:00
} , lr = ( e ) => {
const [ t , a ] = N ( ) , n = { type : "GET" } ;
if ( typeof e == "string" ? n . url = e : p . isPlainObject ( e ) && Object . assign ( n , e ) , ! ( n != null && n . url ) ) throw "url is required" ;
2024-12-03 10:15:14 +08:00
const r = ( s ) => F . request ( n , ! 1 ) . resp ( ( i ) => ( console . log ( "useSubscribeRequest" , s ) , a ( i ) , i ) ) ;
2024-12-02 16:59:57 +08:00
return De ( ( ) => {
let s = null ;
return r ( ) . then ( ( i ) => {
s = ea . subscribe ( p . throttle ( r , 180 , { leading : ! 1 , trailing : ! 0 } ) , i . res ) ;
} ) , ( ) => s == null ? void 0 : s ( ) ;
} , n ) , t ;
} , gn = ( e ) => {
const [ t , a ] = C . useState ( { gridItems : [ ] , hideItems : [ ] } ) ;
return C . useEffect ( ( ) => {
2024-12-03 10:15:14 +08:00
e && F . get ( ` /api/_/ ${ e } ` ) . then ( ( { pk : n , uuid : r , code : s , resource : i , align : o , cols : l , rowHeight : c , marginX : u , marginY : h , listenChangeFields : m , listenChangeFieldsFunc : f , fields : y } ) => ( { pk : n , uuid : r , code : s , resource : i , align : o , cols : l , rowHeight : c , marginX : u , marginY : h , listenChangeFields : m , listenChangeFieldsFunc : f , ... y . reduce ( ( b , w ) => {
2024-12-02 16:59:57 +08:00
var k ;
return ( k = w == null ? void 0 : w . field ) != null && k . hidden ? b . hides . push ( w == null ? void 0 : w . field ) : b . items . push ( w ) , b ;
} , { items : [ ] , hides : [ ] } ) } ) ) . then ( a ) ;
} , [ e ] ) , t ;
} , pn = ( { max : e = 0 , min : t = 0 , type : a = "" , message : n , pattern : r , required : s = ! 1 , validator : i } = { } , o , l ) => {
2024-12-02 17:31:31 +08:00
const [ c , u ] = N ( [ ] ) ;
2024-12-02 16:59:57 +08:00
return x ( ( ) => {
2024-12-03 10:15:14 +08:00
const h = [ ] ;
2024-12-02 16:59:57 +08:00
if ( s ) {
let m = l ;
switch ( l ) {
case "number" :
case "string" :
case "array" :
break ;
case "bool" :
m = "boolean" ;
break ;
case "json" :
m = "object" ;
}
2024-12-03 10:15:14 +08:00
h . push ( { type : m , required : ! 0 , whitespace : ! 0 , message : "该项必填" } ) ;
2024-12-02 16:59:57 +08:00
}
switch ( a ) {
case "string" :
2024-12-03 10:15:14 +08:00
h . push ( { type : a , max : e , min : t , message : n || ( t && e ? ` 字符必须在 ${ t } ~ ${ e } 之间 ` : ` ${ e ? "最多能有" : "最少要有" } ${ t || e } 个字符 ` ) } ) ;
2024-12-02 16:59:57 +08:00
break ;
case "pattern" :
2024-12-03 10:15:14 +08:00
h . push ( { type : "string" , pattern : r , message : n } ) ;
2024-12-02 16:59:57 +08:00
break ;
case "validator" :
2024-12-03 10:15:14 +08:00
i && h . push ( ( { getFieldValue : m } ) => ( { validator : async ( f , y ) => {
2024-12-02 16:59:57 +08:00
const b = await we . exec ( i , { value : y , fieldName : o } , { getFieldValue : m } ) ;
return p . isString ( b ) && b ? Promise . reject ( b ) : p . isBoolean ( b ) && ! b ? Promise . reject ( n ) : Promise . resolve ( ) ;
} } ) ) ;
}
2024-12-03 10:15:14 +08:00
u ( h ) ;
2024-12-02 17:31:31 +08:00
} , [ e , t , a , n , r , s , i ] ) , c ;
2024-12-02 16:59:57 +08:00
} , mn = ( e , t , a ) => {
const [ n , r ] = N ( null ) ;
return x ( ( ) => {
const { initDataUri : s = ` /api/ ${ e } ` , initDataMethod : i = "GET" } = a || { } ;
2024-12-03 10:15:14 +08:00
t && F . request ( { method : i , url : p . trimEnd ( ` ${ s } / ${ t } ` , "/" ) } ) . then ( ( o ) => {
2024-12-02 16:59:57 +08:00
r ( o ) ;
} ) ;
} , [ e , t , a ] ) , n ;
} , hn = ( e , t , a , n = { } ) => {
2024-12-02 17:31:31 +08:00
const r = St ( ) , s = q ( ! 0 ) , i = q ( [ ] ) , [ o , l ] = N ( a ) , c = X . useWatch ( ( u ) => JSON . stringify ( p . pick ( u , i . current ) ) , t ) || "{}" ;
2024-12-02 16:59:57 +08:00
return x ( ( ) => {
2024-12-03 10:15:14 +08:00
e && we . exec ( e , n , { getFieldValue : p . wrap ( t . getFieldValue , ( u , h ) => ( i . current . some ( ( m ) => p . isEqual ( m , h ) ) || ( i . current . push ( h ) , r ( ) ) , u ( h ) ) ) , isFieldTouched : t . isFieldTouched , isFieldsTouched : t . isFieldsTouched } ) . then ( ( u ) => s . current && l ( u ) ) ;
2024-12-02 17:31:31 +08:00
} , [ e , c , t , n ] ) , x ( ( ) => ( ) => s . current = ! 1 , [ ] ) , o ;
2024-12-02 16:59:57 +08:00
} , cr = ( { value : e , onChange : t } , a = null ) => {
const n = q ( ) , [ r ] = X . useForm ( a ) ;
return $t ( ( ) => {
p . isEqual ( n . current , e ) || r . setFieldsValue ( e ) ;
} , [ e ] ) , x ( ( ) => ( ) => r . resetFields ( ) , [ ] ) , [ Z ( ( ) => r . _ _INTERNAL _ _ ? r : { ... r , _ _INTERNAL _ _ : { } } , [ r ] ) , ( s , i ) => {
n . current = i , t ( i ) ;
} ] ;
} , fn = ( { type : e , initialValue : t , initialValueLanguage : a , onChange : n , form : r } ) => {
const s = hn ( a == "javascript" && t , r , a == "javascript" ? void 0 : t , { } ) ;
return x ( ( ) => {
a == "javascript" ? n ( Q ( s , e ) ) : t && n ( Q ( t , e ) ) ;
} , [ e , t , s ] ) , null ;
} , yn = ( { widget : e = "Input" , widgetPrefix : t = "@pkg/ff/grid-layout-forms" , widgetDecorator : a , subWidgets : n , basicForm : r , ... s } ) => {
const i = e != null && e . startsWith ( "@" ) || e != null && e . startsWith ( "blob:" ) ? e : ` ${ t } / ${ e } ` , [ o , l ] = N ( ) ;
return x ( ( ) => {
2024-12-02 17:31:31 +08:00
i && G . getWidgetComponent ( i ) . then ( ( { defaultProps : c = { } , default : u } ) => ( { default : da ( u , c , r ) } ) ) . catch ( ( c ) => ( { default : ( ) => ` ${ c } ` } ) ) . then ( ( c ) => l ( C . createElement ( c . default , s ) ) ) ;
2024-12-02 16:59:57 +08:00
} , [ i ] ) , o && C . cloneElement ( o , s ) ;
} , da = ( e , t = { } , a = null ) => ( n ) => {
2024-12-03 10:15:14 +08:00
const { type : r , code : s , label : i , noStyle : o , placeholder : l , extras : c , validators : u , help : h , isVirtual : m , $isReserved : f , initialValue : y , initialValueLanguage : b , convertJs : w , convertJsSetting : k , widgetPerfix : E , boxStyle : z , widgetDecorator : j , subWidgets : D , ... S } = { ... t , ... n } , I = pn ( u || { } , s , r ) , L = { label : i , noStyle : o , colon : ! 1 , layout : "vertical" } , U = { placeholder : l , ... S } , H = ce ( ( W ) => W == null ? void 0 : Q ( W , r ) , [ r ] ) ;
return d ( Jt , { name : s , rules : I , initialValue : H ( y ) , normalize : H , children : ( W , O , se ) => {
2024-12-02 16:59:57 +08:00
var A ;
2024-12-03 10:15:14 +08:00
return d ( e , { type : r , rcform : se , itemProps : { validateStatus : O . errors . length > 0 ? "error" : "success" , tooltip : h , help : O . errors . length > 0 ? O . errors . join ( "、" ) : null , required : ( ( A = I == null ? void 0 : I [ 0 ] ) == null ? void 0 : A . required ) || ! 1 , ... L } , fieldProps : { ... U , ... W } , $setting : c || { } } ) ;
2024-12-02 16:59:57 +08:00
} } ) ;
} , Nt = ( { cols : e = 24 , rowHeight : t = 16 , itemMargin : a = [ 8 , 16 ] , containerPadding : n = [ 0 , 0 ] , fields : r = [ ] , children : s , basicForm : i = null } ) => {
const o = oa ( r , da , "@pkg/ff/grid-layout-forms" ) ;
return T ( "div" , { className : "ff-grid-layout-form" , style : { "--grid-layout-item-margin-x" : ` ${ ( a == null ? void 0 : a [ 0 ] ) ? ? 8 } px ` , "--grid-layout-item-margin-y" : ` ${ ( a == null ? void 0 : a [ 1 ] ) ? ? 16 } px ` , "--grid-layout-container-padding-y" : ` ${ ( n == null ? void 0 : n [ 0 ] ) || 0 } px ` , "--grid-layout-container-padding-x" : ` ${ ( n == null ? void 0 : n [ 1 ] ) || 0 } px ` , "--grid-layout-cols" : e , "--grid-layout-row-height" : ` ${ t } px ` } , children : [ o , s && C . cloneElement ( s , { cols : e , rowHeight : t , itemMargin : a , containerPadding : n , fields : r } ) ] } ) ;
} ;
2024-12-03 10:15:14 +08:00
Nt . propTypes = { fields : V . array } ;
2024-12-02 17:31:31 +08:00
const wn = ( zt = Nt , ( { code : e , layout : t , name : a , primaryKey : n = 0 , style : r = { } , formProps : s = { } , form : i , isPreview : o = ! 1 , className : l , onFinish : c , onValuesChange : u = ( ) => {
2024-12-03 10:15:14 +08:00
} , ... h } ) => {
const { align : m , autoComplete : f , resource : y , items : b , hides : w , rowHeight : k , marginX : E , marginY : z , cols : j , listenChangeFields : D , listenChangeFieldsFunc : S , pk : I , uuid : L } = gn ( e ) , [ U ] = X . useForm ( i ) , H = Z ( ( ) => [ { name : "__PK__" , value : I } , { name : "__PROPS__" , value : s } , { name : "__RESOURCE__" , value : y } , { name : "__LAYOUT_KEY__" , value : e } , { name : "__LAYOUT_UUID__" , value : L } , { name : "__PRIMARY_KEY__" , value : n } ] , [ I , e , L , y , n , s ] ) ;
return T ( X , { className : l , name : a || e , layout : t || m , fields : H , form : U , autoComplete : f , style : { ... r , position : "relative" } , onFinish : c , onValuesChange : ( W , O ) => ( ( { changedValues : se , allValues : A , listenChangeFields : Fe , listenChangeFieldsFunc : Se , onValuesChange : at , code : Tt } ) => {
at ( se , A ) , Se && Array . isArray ( Fe ) && we . exec ( Se , { changedValues : se , allValues : A } , { getFieldValue : U . getFieldValue , setFieldValue : U . setFieldValue , setFieldsValue : U . setFieldsValue , isFieldTouched : U . isFieldTouched , isFieldsTouched : U . isFieldsTouched } ) ;
} ) ( { changedValues : W , allValues : O , listenChangeFields : D , listenChangeFieldsFunc : S , onValuesChange : u , code : e } ) , children : [ d ( zt , { ... h , form : U , code : e , fields : b , cols : j , rowHeight : k , itemMargin : [ E , z ] } ) , w == null ? void 0 : w . map ( ( W ) => {
var O ;
return d ( Jt , { name : W . code , children : d ( fn , { form : U , name : W . code , type : W . type , initialValue : W . initialValue , initialValueLanguage : ( O = W . extras ) == null ? void 0 : O . initialValueLanguage } ) } , JSON . stringify ( W . code ) ) ;
2024-12-02 16:59:57 +08:00
} ) ] } , e ) ;
} ) ;
var zt ;
const ua = ( { $setting : e , $close : t , extras : a , code : n , primaryKey : r , ... s } ) => {
const [ i ] = X . useForm ( ) , o = mn ( n , r , e ) ;
return x ( ( ) => {
o && i . setFieldsValue ( o ) ;
2024-12-02 17:31:31 +08:00
} , [ o ] ) , d ( K , { actions : T ( C . Fragment , { children : [ d ( $ , { name : "保存" , type : "primary" , widget : ( ) => {
const l = i . getFieldValue ( "__RESOURCE__" ) , { initDataUri : c = ` /api/ ${ n } ` } = e || { } ;
2024-12-03 10:15:14 +08:00
i . validateFields ( ! 0 ) . then ( ( u ) => l ? p . pick ( u , [ l ] ) : u ) . then ( ( u ) => F . post ( r ? ` ${ c } / ${ r } ` : ` ${ c } ` , u ) . msg ( t ) ) . catch ( ( ) => _ . error ( "请先完善表单信息" , { duration : 2e3 } ) ) ;
2024-12-02 17:31:31 +08:00
} } ) , d ( $ , { name : "取消" , widget : ( ) => t ( ! 1 ) } ) ] } ) , extras : a , children : d ( wn , { form : i , code : n , primaryKey : r , ... s } ) } ) ;
2024-12-02 16:59:57 +08:00
} , Cn = ( e , t , a , { isReplaceRouteHistory : n = ! 1 } = { } ) => le . redirect ( a , t , { replace : n } ) , Wt = ( e , t , a , { status : { loading : n , disabled : r } , setStatus : s } ) => {
const i = { loading : ( o ) => o === void 0 ? n : s ( ( l ) => ( { ... l , loading : o } ) ) , disabled : ( o ) => o === void 0 ? r : s ( ( l ) => ( { ... l , disabled : o } ) ) } ;
return p . isFunction ( a ) ? a . call ( null , { ... t , ... i } ) : p . isString ( a ) && a ? we . exec ( a , t , i ) : null ;
} , Ut = ( e , t , a , n , r ) => p . isString ( a ) && a ? G . getWidgetComponent ( a ) . then ( ( { default : s } ) => _ . modal ( s , { ... t , $setting : n } , r != null && r . title ? { ... r , title : p . template ( r . title ) ( e ) } : r ) ) . catch ( ( s ) => {
_ . error ( a , { content : s . toString ( ) } ) ;
} ) : _ . modal ( a , { ... t , $setting : n } , r != null && r . title ? { ... r , title : p . template ( r . title ) ( e ) } : r ) , bn = ( e , t , a , n , r ) => _ . modal ( ua , { ... t , $setting : n , code : a } , r != null && r . title ? { ... r , title : p . template ( r . title ) ( e ) } : r ) , kn = ( e , t , a , n , r ) => _ . modal ( kt , { base62params : t , $setting : n , listCode : a } , r != null && r . title ? { ... r , title : p . template ( r . title ) ( e ) } : r ) , vn = ( { widget : e , widgetType : t , widgetData : a , widgetProps : n , widgetSetting : r , widgetContainerProps : s } , { onAfterClick : i , onBeforeClick : o } ) => {
2024-12-03 10:15:14 +08:00
const l = Ue ( ve ) , [ c , u ] = N ( { leading : ! 0 , trailing : ! 1 } ) , h = Z ( ( ) => {
2024-12-02 16:59:57 +08:00
switch ( t ) {
case "redirect" :
return p . partialRight ( Cn , e , r ) ;
case "func" :
2024-12-02 17:31:31 +08:00
return p . partialRight ( Wt , ( r == null ? void 0 : r . code ) ? ? e , { status : c , setStatus : u } ) ;
2024-12-02 16:59:57 +08:00
case "fsdpf-component" :
return p . partialRight ( Ut , e , r , s ) ;
case "grid-layout-form" :
return p . partialRight ( bn , e , r , s ) ;
case "data-list" :
return p . partialRight ( kn , e , r , s ) ;
default :
if ( xt ( e ) || C . isValidElement ( e ) ) return p . partialRight ( Ut , e , r , s ) ;
2024-12-02 17:31:31 +08:00
if ( p . isFunction ( e ) ) return p . partialRight ( Wt , ( r == null ? void 0 : r . code ) || e , { status : c , setStatus : u } ) ;
2024-12-02 16:59:57 +08:00
}
return ( ... m ) => console . error ( "useButton unknown widgetType" , t , ... m ) ;
} , [ e , t ] ) ;
2024-12-03 10:15:14 +08:00
return [ p . debounce ( ( m ) => ( o == null || o ( m ) , Promise . resolve ( Yt ( n , m , { list : l } ) ) . then ( ( f ) => h ( m , { ... a , ... f } ) ) . then ( ( f ) => i == null ? void 0 : i ( f ) ) . catch ( console . error ) ) , 300 , { leading : ! 0 , trailing : ! 1 } ) , c ] ;
2024-12-02 16:59:57 +08:00
} , Bt = /* @__PURE__ */ new Set ( ) , ft = ( e = [ ] , t = 0 ) => {
const a = e [ t ] ;
if ( a . length && ! Bt . has ( a ) ) {
const n = document . createElement ( "script" ) ;
n . setAttribute ( "src" , a ) , n . setAttribute ( "data-namespace" , a ) , e . length > t + 1 && ( n . onload = ( ) => {
ft ( e , t + 1 ) ;
} , n . onerror = ( ) => {
ft ( e , t + 1 ) ;
} ) , Bt . add ( a ) , document . body . appendChild ( n ) ;
}
2024-12-03 10:15:14 +08:00
} , yt = ( { className : e , type : t , style : a = { } , ... n } ) => d ( "span" , { role : "img" , className : R ( "ff-iconfont" , e ) , style : a , ... n , children : d ( "svg" , { style : { width : "1em" , height : "1em" , fill : "currentColor" , overflow : "hidden" } , viewBox : "0 0 1024 1024" , children : d ( "use" , { xlinkHref : ` # ${ t } ` } ) } ) } ) ;
yt . propTypes = { className : V . string , type : V . string . isRequired , style : V . object } , yt . init = ft ;
const qe = ( e ) => function ( { className : t , children : a , name : n , icon : r , type : s = "default" , iconPosition : i = "start" , noAuthType : o , onAfterClick : l , onBeforeClick : c , data : u , loading : h , disabled : m , tooltip : f , popConfirm : y , widget : b , widgetType : w , widgetData : k , widgetProps : E , widgetSetting : z , widgetContainerProps : j , ... D } ) {
const S = { type : "primary" , className : R ( "ff-button" , t ) , iconPosition : i } ;
s === "danger" ? S . danger = ! 0 : s === "default" && ( S . type = s ) , e === "link" || e === "dashed" ? ( S . type = e , s === "default" && ( S . className = R ( S . className , "ff-default" ) ) ) : e !== "circle" && e !== "round" || ( S . shape = e ) , r && ( S . icon = d ( yt , { type : r } ) ) ;
const [ I , L ] = N ( ! 1 ) , [ U , { disabled : H , loading : W } ] = vn ( { widget : b , widgetType : w , widgetData : k , widgetProps : E , widgetSetting : z , widgetContainerProps : j } , { onAfterClick : l , onBeforeClick : c } ) ;
return d ( Fa , { okText : "确定" , cancelText : "取消" , ... y || { } , disabled : H || m , open : I , onOpenChange : ( O ) => {
if ( ! O ) return L ( O ) ;
y ? L ( O ) : U ( u ) ;
2024-12-02 16:59:57 +08:00
} , onConfirm : ( ) => {
2024-12-03 10:15:14 +08:00
U ( u ) ;
} , onClick : ( O ) => {
O . stopPropagation ( ) ;
} , children : d ( Ra , { ... f , title : I ? null : f == null ? void 0 : f . title , trigger : [ "hover" , "click" ] , children : d ( ot , { loading : W || h , disabled : H || m , ... S , ... D , children : a || n } ) } ) } ) ;
2024-12-02 16:59:57 +08:00
} , $ = qe ( "default" ) , Sn = qe ( "link" ) , $n = qe ( "circle" ) , Nn = qe ( "round" ) , Pn = qe ( "dashed" ) , Dt = ( { data : e , widget : t , widgetType : a = "fsdpf-component" , children : n , widgetData : r , widgetProps : s , widgetSetting : i , widgetContainerProps : o } ) => {
2024-12-03 10:15:14 +08:00
const l = Ue ( ve ) , [ c , u ] = N ( ! 1 ) , [ h , m ] = N ( "hover" ) , [ f , y ] = N ( { } ) , [ b , w ] = N ( ) , { placement : k , align : E , arrow : z = { pointAtCenter : ! 0 } , getPopupContainer : j , ... D } = o || { } ;
2024-12-02 16:59:57 +08:00
x ( ( ) => {
2024-12-03 10:15:14 +08:00
a == "grid-layout-form" ? w ( C . createElement ( ua , { ... r , $setting : i , code : t } ) ) : a == "data-list" ? w ( C . createElement ( kt , { base62params : e , $setting : i , listCode : t } ) ) : p . isString ( t ) ? G . getWidgetComponent ( t ) . then ( ( { default : L } ) => {
w ( C . createElement ( L , { ... r , $setting : i } ) ) ;
} ) . catch ( ( L ) => w ( L . toString ( ) ) ) : xt ( t ) ? w ( C . createElement ( t , { ... r , $setting : i } ) ) : C . isValidElement ( t ) && w ( C . cloneElement ( t , { ... r , $setting : i } ) ) ;
2024-12-02 16:59:57 +08:00
} , [ t , a , r ] ) , x ( ( ) => {
Promise . resolve ( Yt ( s , e , { list : l } ) ) . then ( y ) ;
} , [ s , e ] ) ;
2024-12-03 10:15:14 +08:00
const S = ( L ) => {
u ( L ) , ! L && m ( "hover" ) ;
} , I = ( L ) => {
2024-12-02 17:31:31 +08:00
u ( ! 0 ) , m ( "click" ) ;
2024-12-02 16:59:57 +08:00
} ;
2024-12-03 10:15:14 +08:00
return d ( Oa , { zIndex : 1080 , placement : k , onPopupClick : I , onClick : I , open : c , align : E , arrow : z , trigger : h , getPopupContainer : j , content : d ( xn , { ... D , children : b && C . cloneElement ( b , { ... f , $close : ( ) => S ( ! 1 ) } ) } ) , children : n , onOpenChange : S } ) ;
2024-12-02 16:59:57 +08:00
} , xn = ( { title : e , className : t , children : a , width : n , height : r , ... s } ) => {
2024-12-03 10:15:14 +08:00
const [ i , o ] = N ( { } ) , l = ce ( ( h , m ) => o ( ( f ) => ( { ... f , [ h ] : m } ) ) , [ ] ) , c = ce ( ( h ) => o ( ( m ) => ( { ... m , [ h ] : void 0 } ) ) , [ ] ) , u = e ? C . createElement ( "div" , { className : "ff-popup-title" } , e ) : i == null ? void 0 : i . title ;
return d ( Be . Provider , { value : { ele : i , mount : l , unmount : c } , children : T ( "div" , { className : R ( "ff-popup ff-popover" , t ) , style : { width : n , height : r } , ... s , children : [ T ( "div" , { className : "ff-popup-header" , children : [ u , i == null ? void 0 : i [ "sub-title" ] ] } ) , a , T ( "div" , { className : "ff-popup-footer" , children : [ i == null ? void 0 : i . extras , i == null ? void 0 : i . actions ] } ) ] } ) } ) ;
2024-12-02 16:59:57 +08:00
} ;
2024-12-03 10:15:14 +08:00
Dt . propTypes = { widgetType : V . oneOf ( [ "fsdpf-component" , "grid-layout-form" , "data-list" ] ) } , $ . propTypes = { type : V . oneOf ( [ "primary" , "default" , "danger" , "" ] ) , name : V . string , icon : V . string , iconPosition : V . oneOf ( [ "start" , "end" ] ) , data : V . any , widget : V . any , widgetType : V . oneOf ( [ "destroy" , "redirect" , "func" , "fsdpf-component" , "grid-layout-form" , "grid-layout" , "data-list" ] ) , widgetData : V . object , widgetProps : V . object , widgetSetting : V . object , widgetContainerProps : V . object } , $ . Link = Sn , $ . Link . defaultProps = $ . defaultProps , $ . Link . propTypes = $ . propTypes , $ . Circle = $n , $ . Circle . defaultProps = $ . defaultProps , $ . Circle . propTypes = $ . propTypes , $ . Round = Nn , $ . Round . defaultProps = $ . defaultProps , $ . Round . propTypes = $ . propTypes , $ . Dashed = Pn , $ . Dashed . defaultProps = $ . defaultProps , $ . Dashed . propTypes = $ . propTypes , $ . Popover = Dt ;
2024-12-02 16:59:57 +08:00
const Tn = ( { fields : e , formProps : t , $close : a } ) => {
const [ n ] = X . useForm ( ) , r = Z ( ( ) => [ { name : "__PROPS__" , value : t } ] , [ t ] ) ;
2024-12-02 17:31:31 +08:00
return d ( K , { actions : T ( C . Fragment , { children : [ d ( $ , { name : "取消" , widget : ( ) => a ( ! 1 ) } ) , d ( $ , { name : "确定" , type : "primary" , widget : ( ) => n . validateFields ( ! 0 ) . then ( a ) } ) ] } ) , children : d ( X , { fields : r , form : n , className : "ff-modal-form" , children : e == null ? void 0 : e . map ( ( { code : s , ... i } ) => d ( yn , { code : s , ... i } , s ) ) } ) } ) ;
2024-12-03 10:15:14 +08:00
} , En = ( { className : e , $close : t , children : a , title : n , subTitle : r , actions : s , extras : i , zIndex : o , ... l } ) => T ( Ba , { ... l , prefixCls : "ff-drawer" , className : R ( "ff-popup" , e ) , maskMotion : { motionAppear : ! 0 , motionName : "mask-motion" } , motion : ( c ) => ( { motionAppear : ! 0 , motionName : ` panel-motion- ${ c } ` } ) , children : [ T ( "div" , { className : "ff-popup-header" , children : [ d ( "button" , { "aria-label" : "Close" , className : "ff-popup-close" , onClick : l . onClose , children : d ( bt , { type : "close" } ) } ) , n , r ] } ) , d ( "div" , { className : "ff-popup-body" , children : a } ) , T ( "div" , { className : "ff-popup-footer" , children : [ i , s ] } ) ] } ) , Fn = ( { className : e , $close : t , $event : a , children : n , title : r , subTitle : s , actions : i , extras : o , zIndex : l , placement : c , ... u } ) => {
const h = ( a == null ? void 0 : a . pageX ) === void 0 ? { animation : null , maskAnimation : null , mousePosition : { x : null , y : null } } : { animation : "zoom" , maskAnimation : "fade" , mousePosition : { x : a == null ? void 0 : a . pageX , y : a == null ? void 0 : a . pageY } } ;
return d ( Da , { ... u , ... h , prefixCls : "ff-modal" , modalRender : ( ) => T ( "div" , { className : R ( "ff-modal-content ff-popup" , e ) , children : [ T ( "div" , { className : "ff-popup-header" , children : [ d ( "button" , { "aria-label" : "Close" , className : "ff-popup-close" , onClick : u . onClose , children : d ( bt , { type : "close" } ) } ) , r , s ] } ) , d ( "div" , { className : "ff-popup-body" , children : n } ) , T ( "div" , { className : "ff-popup-footer" , children : [ o , i ] } ) ] } ) } ) ;
2024-12-02 16:59:57 +08:00
} , ga = ( { placement : e , $close : t , $event : a , children : n , title : r , ... s } ) => {
2024-12-03 10:15:14 +08:00
const [ i , o ] = N ( { } ) , [ l , c ] = N ( ! 0 ) , u = ce ( ( y , b ) => o ( ( w ) => ( { ... w , [ y ] : b } ) ) , [ ] ) , h = ce ( ( y ) => o ( ( b ) => ( { ... b , [ y ] : void 0 } ) ) , [ ] ) ;
let m = { ... s , className : i . rootClassName , title : i . title || r && C . createElement ( "div" , { className : R ( "ff-popup-title" ) } , r ) , subTitle : i [ "sub-title" ] , actions : i . actions , extras : i . extras , children : n , $close : t , $event : a , onClose : ( ) => c ( ! 1 ) } ;
const f = ( ) => {
2024-12-02 16:59:57 +08:00
t ( ! 1 ) ;
} ;
2024-12-03 10:15:14 +08:00
return d ( Be . Provider , { value : { ele : i , mount : u , unmount : h } , children : e && e !== "center" ? d ( En , { ... m , placement : e , open : l , afterOpenChange : ( y ) => ! y && f ( ) } ) : d ( Fn , { ... m , visible : l , afterClose : f } ) } ) ;
2024-12-02 16:59:57 +08:00
} ;
2024-12-03 10:15:14 +08:00
ga . propTypes = { placement : V . oneOf ( [ "center" , "left" , "top" , "right" , "bottom" ] ) } ;
2024-12-02 16:59:57 +08:00
const J = ( ) => {
const [ e , t ] = Wa ( { maxCount : 6 , motion : { motionName : "ff-notification-fade" , motionAppear : ! 0 , motionEnter : ! 0 , motionLeave : ! 0 , onLeaveStart : ( s ) => {
const { offsetHeight : i } = s ;
return { height : i } ;
} , onLeaveActive : ( ) => ( { height : 0 , opacity : 0 , margin : 0 } ) } , prefixCls : "ff-notification" } ) , [ , a ] = C . useReducer ( ( s ) => s + 1 , 0 ) ;
x ( ( ) => {
2024-12-02 17:31:31 +08:00
J . $onClick = n , J . $queue . forEach ( ( [ s , i , o ] , l , c ) => {
r ( [ i , o ] , ... s ) , delete c [ l ] ;
2024-12-02 16:59:57 +08:00
} ) ;
} , [ ] ) ;
2024-12-02 17:31:31 +08:00
const n = ( s , i = { } , o = { } ) => new Promise ( ( l , c ) => r ( [ l , c ] , s , i , o ) ) , r = ( [ s , i ] , o , l = { } , c = { } ) => {
2024-12-03 10:15:14 +08:00
const u = J . $index ++ , h = ( m ) => ( ( f , y ) => ( J . $popups . delete ( f ) , a ( ) , y == null ? void 0 : y ( ) ) ) ( u , ( ) => s ( m ) ) ;
2024-12-02 17:31:31 +08:00
if ( o === Gt ) return e . open ( { ... c , key : u , content : C . createElement ( o , { ... l , $close : ( ) => e . close ( u ) } ) } ) ;
2024-12-03 10:15:14 +08:00
J . $popups . set ( u , C . createElement ( ga , { zIndex : u , maskClosable : ! 1 , $event : l == null ? void 0 : l . $event , ... c , key : u , $close : h } , C . isValidElement ( o ) ? C . cloneElement ( o , { ... l , $close : h } ) : o != null && o . name || Lt . isForwardRef ( o ) || ( o == null ? void 0 : o . $$typeof ) === Lt . ForwardRef ? C . createElement ( o , { ... l , $close : h } ) : o ) ) , a ( ) ;
2024-12-02 16:59:57 +08:00
} ;
return T ( C . Fragment , { children : [ Array . from ( J . $popups ) . map ( ( [ s , i ] ) => i ) , t ] } ) ;
} ;
J . $popups = /* @__PURE__ */ new Map ( ) , J . $index = 0 , J . $queue = [ ] , J . $onClick = ( ... e ) => new Promise ( ( t , a ) => {
J . $queue . push ( [ e , t , a ] ) ;
} ) ;
const qt = ( e , t , a = { } ) => J . $onClick ( e , t , a ) , st = ( e , { showProgress : t , duration : a , ... n } = { duration : 1.5 } ) => J . $onClick ( Gt , { content : e , ... n } , { showProgress : t , duration : a } ) , _ = { modal : qt , confirm : ( e , t = { } ) => J . $onClick ( qa , { content : e , ... t } , { placement : "center" } ) , form : ( e , t = { } , a = { } ) => qt ( Tn , { formProps : a , fields : e } , { placement : "center" , ... t } ) . then ( ( n ) => {
if ( n === ! 1 ) throw ! 1 ;
return n ;
} ) , notification : st , success : ( e , t = { duration : 1.5 } ) => st ( e , { ... t , className : "ff-notification-success" , icon : "check" } ) , error : ( e , t = { duration : 1.5 } ) => st ( e , { ... t , className : "ff-notification-error" , icon : "close" } ) } ;
Re . configure ( { showSpinner : ! 1 } ) , Oe . interceptors . request . use ( ( e ) => {
e . headers . Platform = "web" , e . headers . SaaS = window . localStorage . getItem ( "SaaS" ) ;
const t = window . localStorage . getItem ( Ge ) ;
return e . headers . Authorization = t ? ` Bearer ${ t } ` : void 0 , Re . inc ( ) , e ;
} , ( e ) => ( Re . done ( ) , Promise . reject ( { code : - 1 , msg : e } ) ) ) , Oe . interceptors . response . use ( ( { data : e , headers : t } ) => ( Re . done ( ) , { ... e , res : t == null ? void 0 : t . res } ) , function ( e ) {
return Re . done ( ) , Promise . reject ( e . message ) ;
} ) , window . addEventListener ( "unhandledrejection" , lt . onUnhandledRejection ) , lt . onMsg = ( e , t ) => _ [ [ 0 , 1 ] . includes ( e ) ? "success" : "error" ] ( t ) . then ( ( ) => e === 20300 && le . redirect ( Le . get ( "Common.WEBSITE_LOGIN_PAGE" ) ) ) ;
const wt = { appUrl : "" , init : ( e , t , a ) => {
wt . appUrl = a , Oe . defaults . baseURL = a , Oe . defaults . timeout = 15e3 , Object . assign ( wt , new lt ( e , t , Oe ) ) ;
2024-12-03 10:15:14 +08:00
} } , F = wt ;
2024-12-02 16:59:57 +08:00
class Pt extends Error {
constructor ( t , a ) {
super ( a ) , Error . captureStackTrace && Error . captureStackTrace ( this , Pt ) , ! a instanceof Ve && ( this . name = ` ${ t } Error Runtime ` ) ;
}
}
class Ve extends Error {
constructor ( t , ... a ) {
super ( ... a ) , Error . captureStackTrace && Error . captureStackTrace ( this , Ve ) , this . name = ` ${ t } Not Found ` ;
}
}
const it = "mine" , Ge = "token" ;
var ye , Ee ;
const re = class re {
constructor ( ) {
P ( this , Ee , /* @__PURE__ */ new Map ( ) ) ;
v ( this , "setVendor" , ( t , a ) => g ( this , Ee ) . set ( t , new Kt ( a , async ( n , r ) => {
var i , o ;
if ( ! ( n != null && n . default ) ) throw "@pkg not found" ;
let s = ( ) => r ;
switch ( "function" ) {
case typeof ( s = ( i = n . default ) == null ? void 0 : i [ ` ./ ${ r } /index.jsx ` ] ) :
case typeof ( s = ( o = n . default ) == null ? void 0 : o [ ` ./ ${ r } /index.js ` ] ) :
return s ( ) ;
}
throw new Ve ( r ) ;
} ) ) ) ;
v ( this , "getWidgetComponent" , async ( t ) => {
if ( ! t ) throw "getWidgetComponent widget is required" ;
if ( t != null && t . startsWith ( "blob:" ) || t != null && t . startsWith ( "http:" ) || t != null && t . startsWith ( "https:" ) ) return await import ( t ) ;
const [ , a ] = t == null ? void 0 : t . split ( "@pkg/" ) ;
if ( ! a ) throw new Ve ( t ) ;
try {
2024-12-03 10:15:14 +08:00
return g ( this , Ee ) . has ( "pkg" ) ? await g ( this , Ee ) . get ( "pkg" ) . get ( a ) : await import ( ` ${ F . appUrl } /api/pkg-import/web?name= ${ t } ` ) ;
2024-12-02 16:59:57 +08:00
} catch ( n ) {
throw new Pt ( t , n ) ;
}
} ) ;
2024-12-03 10:15:14 +08:00
v ( this , "getRoutes" , ( ) => F . get ( "/api/my-router" ) . then ( ( t ) => [ ... t , { uuid : "data-list-setting" , isLayout : ! 0 , uri : "/data-list-setting/:category/:categoryUuid" , type : "fsdpf-component" , component : "@pkg/ff-design/components/DataListSetting" , extra : { layout : "@pkg/ff-design/frameworks/DesignTheme" } } , { uuid : "grid-layout-setting" , isLayout : ! 0 , uri : "/grid-layout-setting/:category/:categoryUuid" , type : "fsdpf-component" , component : "@pkg/ff-design/components/GridLayoutSetting" , extra : { layout : "@pkg/ff-design/frameworks/DesignTheme" } } , { uuid : "grid-layout-form-setting" , isLayout : ! 0 , uri : "/grid-layout-form-setting/:category/:categoryUuid" , type : "fsdpf-component" , component : "@pkg/ff-design/components/GridLayoutFormSetting" , extra : { layout : "@pkg/ff-design/frameworks/DesignTheme" } } , { uuid : "resource-api-setting" , isLayout : ! 0 , uri : "/resource-api-setting/:category/:categoryUuid" , type : "fsdpf-component" , component : "@pkg/ff-design/components/ResourceApiSetting" , extra : { layout : "@pkg/ff-design/frameworks/DesignTheme" } } , { uuid : "charts-setting" , isLayout : ! 0 , uri : "/resource-api-setting/:category/:categoryUuid" , type : "fsdpf-component" , component : "@pkg/ff-design/components/ChartsSetting" , extra : { layout : "@pkg/ff-design/frameworks/DesignTheme" } } , { uuid : "fsm-setting" , isLayout : ! 0 , uri : "/fsm-setting/:category/:categoryUuid" , type : "fsdpf-component" , component : "@pkg/ff-design/components/FsmSetting" , extra : { layout : "@pkg/ff-design/frameworks/DesignTheme" } } , { uuid : "component-setting" , isLayout : ! 0 , uri : "/component-setting/:category/:categoryUuid" , type : "fsdpf-component" , component : "@pkg/ff-design/components/ComponentSetting" , extra : { layout : "@pkg/ff-design/frameworks/DesignTheme" } } , { uuid : "login" , uri : "/login" , name : "登录" , type : "fsdpf-component" , isLogin : ! 1 , component : "@pkg/ff/components/Login" } , { uuid : "not-found" , uri : "*" , name : "Not Found" , type : "fsdpf-component" , isLogin : ! 1 , component : "@pkg/ff/components/NotFound" } ] . map ( ( { uuid : a , ... n } ) => [ a , { uuid : a , ... n } ] ) ) . then ( ( t ) => new Map ( t ) ) ) ;
v ( this , "getMenus" , ( ) => F . get ( "/api/my-menu" ) ) ;
v ( this , "getConfigure" , ( ) => F . get ( "api/init-configure" ) ) ;
v ( this , "getWidgetOperationAuth" , ( ) => F . get ( "/api/init-widget-operation-auth" ) . then ( ( t ) => t . reduce ( ( a , { uuid : n , auth : r } ) => [ ... a , [ n , r ] ] , [ ] ) ) ) ;
v ( this , "getPhoneNumber" , ( t ) => F . get ( ` /api/user-wx-phone-number/ ${ t } ` ) ) ;
2024-12-02 16:59:57 +08:00
v ( this , "getUserToken" , ( ) => {
const t = window . localStorage . getItem ( Ge ) ;
if ( ! t ) return "" ;
const a = t . split ( "." ) ;
if ( ! Array . isArray ( a ) || a . length !== 3 ) throw "登录令牌无效!" ;
const { iat : n } = JSON . parse ( window . atob ( a [ 1 ] ) ) ;
if ( Math . floor ( ( /* @__PURE__ */ new Date ( ) ) . getTime ( ) / 1e3 ) - n > 2592e3 ) throw "登录令牌已过期, 请重新登录!" ;
return t ;
} ) ;
v ( this , "checkUserToken" , ( ) => {
try {
return ! ! this . getUserToken ( ) ;
} catch {
return ! 1 ;
}
} ) ;
v ( this , "getUserInfo" , ( t = ! 0 ) => {
var a ;
try {
const n = this . getUserToken ( ) ;
if ( ! n ) return Promise . resolve ( null ) ;
2024-12-03 10:15:14 +08:00
const { iat : r } = JSON . parse ( window . atob ( ( a = n == null ? void 0 : n . split ( "." ) ) == null ? void 0 : a [ 1 ] ) ) , { iat : s , ... i } = F . decode ( window . localStorage . getItem ( it ) || "" , { } ) ;
return s === r ? Promise . resolve ( i ) : F . get ( "/api/mine-info" ) . then ( ( { User : o = null } ) => ( window . localStorage . setItem ( it , F . encode ( { ... o , iat : r } ) ) , o ) ) ;
2024-12-02 16:59:57 +08:00
} catch ( n ) {
console . error ( n ) , t && Popup . error ( "请登录" ) . then ( logout ) ;
}
return Promise . resolve ( null ) ;
} ) ;
2024-12-03 10:15:14 +08:00
v ( this , "login" , ( t , a , n = { } ) => F . post ( "/api/user-token" , { username : t , passwd : Ua . hash ( a ) , platform : "web" , ... n } ) . then ( ( { token : r } ) => ( window . localStorage . setItem ( Ge , r ) , r ) ) ) ;
2024-12-02 16:59:57 +08:00
v ( this , "logout" , ( ) => {
window . localStorage . removeItem ( it ) , window . localStorage . removeItem ( Ge ) ;
} ) ;
if ( g ( re , ye ) ) return g ( re , ye ) ;
}
} ;
ye = new WeakMap ( ) , Ee = new WeakMap ( ) , P ( re , ye , null ) , v ( re , "getInstance" , ( ) => ( g ( re , ye ) || B ( re , ye , new re ( ) ) , g ( re , ye ) ) ) ;
let Ct = re ;
const G = Ct . getInstance ( ) , Rn = C . createContext ( { user : { } , initUser : ( ) => {
} , initUserComplete : ! 1 } ) , On = C . createContext ( { set : ( ) => {
} , get : ( ) => {
} , assign : ( ) => {
} , currentRoute : ( ) => {
} } ) , xt = ( e ) => ! ! ( e != null && e . name ) && ( e . prototype instanceof C . Component || /^[A-Z]/ . test ( e . name ) ) , Ln = ( e , t ) => {
if ( ! e || typeof window > "u" ) return ;
let a = document . querySelector ( ` style[ff-style-token=" ${ t } "] ` ) ;
return a ? ( a . innerHTML = e , e ) : ( a = document . createElement ( "style" ) , a . setAttribute ( "ff-style-token" , t ) , a . setAttribute ( "type" , "text/css" ) , a . innerHTML = e , document . head . appendChild ( a ) , e ) ;
2024-12-03 10:15:14 +08:00
} , Vn = Object . freeze ( Object . defineProperty ( { _ _proto _ _ : null , AppContext : Rn , AppGlobalParamsContext : On , cache : Kt , configure : Le , default : G , func : we , http : F , insertStyle : Ln , isReactComponent : xt , route : le } , Symbol . toStringTag , { value : "Module" } ) ) , An = ( e , t , a = "children" ) => {
2024-12-02 16:59:57 +08:00
if ( p . isEmpty ( e ) ) return { } ;
const n = p . find ( e , [ "value" , t ] ) ;
if ( ! p . isEmpty ( n ) ) return n ;
const r = e . length ;
for ( let s = 0 ; s < r ; s ++ ) {
const { [ a ] : i } = e [ s ] , o = An ( i , t , a ) ;
if ( ! p . isEmpty ( o ) ) return o ;
}
return { } ;
} ;
export {
J as $ ,
St as A ,
sr as B ,
ir as C ,
ut as D ,
De as E ,
$t as F ,
nr as G ,
an as H ,
or as I ,
lr as J ,
wn as K ,
Nt as L ,
yn as M ,
ua as N ,
gn as O ,
pn as P ,
mn as Q ,
ea as R ,
hn as S ,
cr as T ,
yt as U ,
$ as V ,
Ha as W ,
vn as X ,
K as Y ,
Be as Z ,
_t as _ ,
ta as a ,
_ as a0 ,
Xn as a1 ,
Zn as a2 ,
er as a3 ,
G as a4 ,
xt as a5 ,
Ln as a6 ,
2024-12-03 10:15:14 +08:00
F as a7 ,
2024-12-02 16:59:57 +08:00
Kt as a8 ,
Le as a9 ,
we as aa ,
le as ab ,
Rn as ac ,
On as ad ,
An as ae ,
sa as b ,
la as c ,
rr as d ,
oa as e ,
Xa as f ,
Yt as g ,
vt as h ,
aa as i ,
na as j ,
ra as k ,
kt as l ,
ve as m ,
tn as n ,
on as o ,
Ga as p ,
Qa as q ,
rt as r ,
Ja as s ,
Q as t ,
ia as u ,
tr as v ,
ar as w ,
gt as x ,
Ka as y ,
_a as z
} ;