@qfei-design/make-app-approval 0.2.15 → 0.2.17

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/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=1024,a=e=>{if(typeof e!="string"||!e.trim())return"请填写撤回意见";if(e.trim().length>s)return`撤回意见不能超过 ${s} 个字符`},n="qfei_process_instance_status",i="qfei_is_locked",o={UNSUBMITTED:{label:"-",tone:"neutral"},IN_APPROVAL:{label:"审批中",tone:"processing"},RETURNING:{label:"审批中",tone:"processing"},APPROVED:{label:"已同意",tone:"success"},REJECTED:{label:"已拒绝",tone:"danger"},CANCELLED:{label:"已撤回",tone:"neutral"}},l=e=>e==null?o.UNSUBMITTED:typeof e=="string"&&Object.hasOwn(o,e)?o[e]:{label:"状态未知",tone:"unknown"},p=e=>!!e?.bpmDefinitionKey?.trim(),A=e=>e===n||e===i,r={locked:{reason:"locked",message:"该数据正在审批中,已被锁定,暂不可编辑"},"in-progress":{reason:"in-progress",message:"该数据正在审批中,暂不可编辑"},approved:{reason:"approved",message:"该数据审批已通过,不可编辑"}},c=(e,_={})=>{const t=e[n];return e[i]===!0?r.locked:t==="IN_APPROVAL"||t==="RETURNING"?r["in-progress"]:t==="APPROVED"?r.approved:null};exports.APPROVAL_LOCK_FIELD=i;exports.APPROVAL_STATUS_FIELD=n;exports.APPROVAL_WITHDRAW_COMMENT_MAX_LENGTH=s;exports.getApprovalStatusDisplay=l;exports.getApprovalWithdrawalCommentError=a;exports.getRecordApprovalWriteRestriction=c;exports.hasApprovalDefinition=p;exports.isApprovalSystemField=A;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m="make-app-approval/semantic-theme/v1",y=["primary","onPrimary","primarySoft","link","focusRing","text","headingText","secondaryText","tertiaryText","placeholderText","page","surface","elevatedSurface","subtleSurface","hoverSurface","selectedSurface","activeSurface","mask","success","warning","danger"],b=["primary","onPrimary","primarySoft","link","focusRing"],T=["recordTitle","sectionTitle","body","fieldLabel","controlText","meta"],l=e=>e.replace(/[A-Z]/g,a=>`-${a.toLowerCase()}`),_=(e,a="desktop")=>{const r={},n=(o,t)=>{typeof t=="string"&&t.trim()&&(r[`--make-approval-theme-${o}`]=t.trim())},s=(o,t,A="px",u=!0)=>{typeof t=="number"&&Number.isFinite(t)&&(u?t>=0:t>0)&&(r[`--make-approval-theme-${o}`]=`${t}${A}`)};if(!e)return r;for(const o of a==="mobile"?b:y)n(l(o),e.colors?.[o]);if(a==="mobile")return r;const i=e.typography;n("font-family",i?.fontFamily),n("heading-font-family",i?.headingFontFamily);for(const o of T)s(`font-size-${l(o)}`,i?.roles?.[o],"px",!1);s("line-height",i?.lineHeight,"",!1),s("font-weight-body",i?.weights?.body,"",!1),s("font-weight-heading",i?.weights?.heading,"",!1);for(const o of["body","heading"]){const t=i?.tracking?.[o];typeof t=="number"&&Number.isFinite(t)&&(r[`--make-approval-theme-tracking-${o}`]=`${t}em`)}for(const o of["controlHeight","rowHeight","headerHeight"])s(l(o),e.density?.[o],"px",!1);for(const o of["controlInline","controlBlock","field","section","tableCell","tableHeader"])s(`spacing-${l(o)}`,e.spacing?.[o]);for(const o of["control","panel","popup"])s(`radius-${o}`,e.radius?.[o]);return s("border-width",e.border?.width),n("border-color",e.border?.color),n("border-subtle-color",e.border?.subtleColor),n("shadow-panel",e.shadow?.panel),n("shadow-popup",e.shadow?.popup),r},f=1024,h=e=>{if(typeof e!="string"||!e.trim())return"请填写撤回意见";if(e.trim().length>f)return`撤回意见不能超过 ${f} 个字符`},d="qfei_process_instance_status",g="qfei_is_locked",p={UNSUBMITTED:{label:"-",tone:"neutral"},IN_APPROVAL:{label:"审批中",tone:"processing"},RETURNING:{label:"审批中",tone:"processing"},APPROVED:{label:"已同意",tone:"success"},REJECTED:{label:"已拒绝",tone:"danger"},CANCELLED:{label:"已撤回",tone:"neutral"}},E=e=>e==null?p.UNSUBMITTED:typeof e=="string"&&Object.hasOwn(p,e)?p[e]:{label:"状态未知",tone:"unknown"},P=e=>!!e?.bpmDefinitionKey?.trim(),R=e=>e===d||e===g,c={locked:{reason:"locked",message:"该数据正在审批中,已被锁定,暂不可编辑"},"in-progress":{reason:"in-progress",message:"该数据正在审批中,暂不可编辑"},approved:{reason:"approved",message:"该数据审批已通过,不可编辑"}},k=(e,a={})=>{const r=e[d];return e[g]===!0?c.locked:r==="IN_APPROVAL"||r==="RETURNING"?c["in-progress"]:r==="APPROVED"?c.approved:null};exports.APPROVAL_LOCK_FIELD=g;exports.APPROVAL_STATUS_FIELD=d;exports.APPROVAL_WITHDRAW_COMMENT_MAX_LENGTH=f;exports.MAKE_APPROVAL_THEME_CONTRACT=m;exports.getApprovalStatusDisplay=E;exports.getApprovalWithdrawalCommentError=h;exports.getRecordApprovalWriteRestriction=k;exports.hasApprovalDefinition=P;exports.isApprovalSystemField=R;exports.toMakeApprovalThemeStyle=_;
package/dist/index.d.ts CHANGED
@@ -19,3 +19,5 @@ export declare const getRecordApprovalWriteRestriction: (record: Readonly<Record
19
19
  approvalEnabled?: boolean;
20
20
  }) => ApprovalWriteRestriction | null;
21
21
  export * from "./withdrawal.js";
22
+ export { MAKE_APPROVAL_THEME_CONTRACT, toMakeApprovalThemeStyle } from "./theme.js";
23
+ export type { MakeApprovalTheme, MakeApprovalThemeStyle, MakeApprovalColor, MakeApprovalTypographyRole, MakeApprovalPresentation } from "./theme.js";
package/dist/index.mjs CHANGED
@@ -1,29 +1,52 @@
1
- const a = 1024, p = (e) => {
1
+ const y = "make-app-approval/semantic-theme/v1", b = ["primary", "onPrimary", "primarySoft", "link", "focusRing", "text", "headingText", "secondaryText", "tertiaryText", "placeholderText", "page", "surface", "elevatedSurface", "subtleSurface", "hoverSurface", "selectedSurface", "activeSurface", "mask", "success", "warning", "danger"], A = ["primary", "onPrimary", "primarySoft", "link", "focusRing"], m = ["recordTitle", "sectionTitle", "body", "fieldLabel", "controlText", "meta"], l = (e) => e.replace(/[A-Z]/g, (a) => `-${a.toLowerCase()}`), T = (e, a = "desktop") => {
2
+ const t = {}, n = (o, r) => {
3
+ typeof r == "string" && r.trim() && (t[`--make-approval-theme-${o}`] = r.trim());
4
+ }, s = (o, r, g = "px", u = !0) => {
5
+ typeof r == "number" && Number.isFinite(r) && (u ? r >= 0 : r > 0) && (t[`--make-approval-theme-${o}`] = `${r}${g}`);
6
+ };
7
+ if (!e) return t;
8
+ for (const o of a === "mobile" ? A : b) n(l(o), e.colors?.[o]);
9
+ if (a === "mobile") return t;
10
+ const i = e.typography;
11
+ n("font-family", i?.fontFamily), n("heading-font-family", i?.headingFontFamily);
12
+ for (const o of m) s(`font-size-${l(o)}`, i?.roles?.[o], "px", !1);
13
+ s("line-height", i?.lineHeight, "", !1), s("font-weight-body", i?.weights?.body, "", !1), s("font-weight-heading", i?.weights?.heading, "", !1);
14
+ for (const o of ["body", "heading"]) {
15
+ const r = i?.tracking?.[o];
16
+ typeof r == "number" && Number.isFinite(r) && (t[`--make-approval-theme-tracking-${o}`] = `${r}em`);
17
+ }
18
+ for (const o of ["controlHeight", "rowHeight", "headerHeight"]) s(l(o), e.density?.[o], "px", !1);
19
+ for (const o of ["controlInline", "controlBlock", "field", "section", "tableCell", "tableHeader"]) s(`spacing-${l(o)}`, e.spacing?.[o]);
20
+ for (const o of ["control", "panel", "popup"]) s(`radius-${o}`, e.radius?.[o]);
21
+ return s("border-width", e.border?.width), n("border-color", e.border?.color), n("border-subtle-color", e.border?.subtleColor), n("shadow-panel", e.shadow?.panel), n("shadow-popup", e.shadow?.popup), t;
22
+ }, _ = 1024, h = (e) => {
2
23
  if (typeof e != "string" || !e.trim()) return "请填写撤回意见";
3
24
  if (e.trim().length > 1024)
4
25
  return "撤回意见不能超过 1024 个字符";
5
- }, s = "qfei_process_instance_status", r = "qfei_is_locked", n = {
26
+ }, f = "qfei_process_instance_status", d = "qfei_is_locked", c = {
6
27
  UNSUBMITTED: { label: "-", tone: "neutral" },
7
28
  IN_APPROVAL: { label: "审批中", tone: "processing" },
8
29
  RETURNING: { label: "审批中", tone: "processing" },
9
30
  APPROVED: { label: "已同意", tone: "success" },
10
31
  REJECTED: { label: "已拒绝", tone: "danger" },
11
32
  CANCELLED: { label: "已撤回", tone: "neutral" }
12
- }, A = (e) => e == null ? n.UNSUBMITTED : typeof e == "string" && Object.hasOwn(n, e) ? n[e] : { label: "状态未知", tone: "unknown" }, c = (e) => !!e?.bpmDefinitionKey?.trim(), _ = (e) => e === s || e === r, o = {
33
+ }, k = (e) => e == null ? c.UNSUBMITTED : typeof e == "string" && Object.hasOwn(c, e) ? c[e] : { label: "状态未知", tone: "unknown" }, E = (e) => !!e?.bpmDefinitionKey?.trim(), R = (e) => e === f || e === d, p = {
13
34
  locked: { reason: "locked", message: "该数据正在审批中,已被锁定,暂不可编辑" },
14
35
  "in-progress": { reason: "in-progress", message: "该数据正在审批中,暂不可编辑" },
15
36
  approved: { reason: "approved", message: "该数据审批已通过,不可编辑" }
16
- }, E = (e, i = {}) => {
17
- const t = e[s];
18
- return e[r] === !0 ? o.locked : t === "IN_APPROVAL" || t === "RETURNING" ? o["in-progress"] : t === "APPROVED" ? o.approved : null;
37
+ }, P = (e, a = {}) => {
38
+ const t = e[f];
39
+ return e[d] === !0 ? p.locked : t === "IN_APPROVAL" || t === "RETURNING" ? p["in-progress"] : t === "APPROVED" ? p.approved : null;
19
40
  };
20
41
  export {
21
- r as APPROVAL_LOCK_FIELD,
22
- s as APPROVAL_STATUS_FIELD,
23
- a as APPROVAL_WITHDRAW_COMMENT_MAX_LENGTH,
24
- A as getApprovalStatusDisplay,
25
- p as getApprovalWithdrawalCommentError,
26
- E as getRecordApprovalWriteRestriction,
27
- c as hasApprovalDefinition,
28
- _ as isApprovalSystemField
42
+ d as APPROVAL_LOCK_FIELD,
43
+ f as APPROVAL_STATUS_FIELD,
44
+ _ as APPROVAL_WITHDRAW_COMMENT_MAX_LENGTH,
45
+ y as MAKE_APPROVAL_THEME_CONTRACT,
46
+ k as getApprovalStatusDisplay,
47
+ h as getApprovalWithdrawalCommentError,
48
+ P as getRecordApprovalWriteRestriction,
49
+ E as hasApprovalDefinition,
50
+ R as isApprovalSystemField,
51
+ T as toMakeApprovalThemeStyle
29
52
  };
@@ -0,0 +1,7 @@
1
+ import type { TableCanvasProps } from "@qfei-design/canvas-table";
2
+ import { type MakeApprovalTheme } from "../theme.js";
3
+ /** Candidate Canvas semantic fields require its public runtime theme contract. */
4
+ export type ApprovalCanvasThemeStyle = NonNullable<TableCanvasProps["style"]> & Partial<Record<"canvasBgColor" | "headerTextColor" | "secondaryTextColor" | "placeholderTextColor" | "selectedBgColor" | "activeBgColor" | "activeBorderColor" | "onPrimaryColor" | "tooltipBgColor" | "tooltipTextColor", string>> & Partial<Record<"headerFontSize" | "headerFontWeight" | "fontWeight" | "secondaryFontSize" | "headerCellPadding" | "tooltipFontSize" | "tooltipBorderRadius", number>>;
5
+ export declare const toApprovalCanvasTheme: (theme?: MakeApprovalTheme) => ApprovalCanvasThemeStyle;
6
+ /** Gate capabilities by a public contract, never by a guessed package version or arbitrary style keys. */
7
+ export declare const filterApprovalCanvasTheme: (style: ApprovalCanvasThemeStyle, contract: unknown) => ApprovalCanvasThemeStyle;
@@ -1,4 +1,4 @@
1
1
  import type { IColumn } from "@qfei-design/canvas-table";
2
2
  import type { ApprovalListTab } from "./types.js";
3
3
  export declare const approvalRowHeadWidth = 64;
4
- export declare const getApprovalColumns: (containerWidth: number, tab?: ApprovalListTab) => IColumn[];
4
+ export declare const getApprovalColumns: (containerWidth: number, tab?: ApprovalListTab, headerColor?: string | (() => string | undefined)) => IColumn[];
@@ -1 +1,3 @@
1
1
  export declare const approvalHeaderIcons: Readonly<Record<string, string>>;
2
+ /** Text is escaped before entering an SVG attribute; no theme text becomes markup. */
3
+ export declare const getApprovalHeaderIcons: (color: string) => Readonly<Record<string, string>>;
@@ -61,6 +61,8 @@ export type ApprovalDiagnostic = Readonly<{
61
61
  page?: number;
62
62
  pageSize?: number;
63
63
  rowCount?: number;
64
+ /** Fixed safe capability diagnostic; never carries theme/query values. */
65
+ reason?: "canvas-theme-contract-unavailable";
64
66
  }>;
65
67
  export type ApprovalLogger = (event: ApprovalDiagnostic) => void;
66
68
  export type MyApprovalsPageProps = Readonly<{
@@ -70,6 +72,8 @@ export type MyApprovalsPageProps = Readonly<{
70
72
  scopeKey: string;
71
73
  /** 由宿主响应式上下文选择,默认保留桌面行为。 */
72
74
  presentation?: "desktop" | "mobile";
75
+ /** standard 由包自有容器提供跨控件库留白;省略时保留旧宿主布局。 */
76
+ spacing?: "standard" | "host";
73
77
  /** 宿主组件与主题;包只控制功能和布局,不提供原生控件兜底。 */
74
78
  components: ApprovalUIComponents;
75
79
  provider: ApprovalListProvider;
@@ -9,7 +9,11 @@ export type ApprovalInputProps = Readonly<{
9
9
  placeholder?: string;
10
10
  disabled?: boolean;
11
11
  }>;
12
- export type ApprovalSelectProps = ApprovalInputProps & Readonly<{
12
+ export type ApprovalSelectProps = Omit<ApprovalInputProps, "onChange"> & Readonly<{
13
+ /** 第二参为可选显示元数据;远程候选适配器应回传,旧单参调用继续兼容。 */
14
+ onChange: (value: string, selectedOption?: ApprovalSelectOption) => void;
15
+ /** 标准模式用于跨端回显的已选名称,不透传到 DOM,也不发送给 Service。 */
16
+ selectedOption?: ApprovalSelectOption;
13
17
  options: readonly ApprovalSelectOption[];
14
18
  /** 可供宿主注入 users 候选及其加载/搜索/重试;不得透传给 DOM。 */
15
19
  purpose?: "applicant";
package/dist/list.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var ge=Object.create;var ne=Object.defineProperty;var ve=Object.getOwnPropertyDescriptor;var be=Object.getOwnPropertyNames;var we=Object.getPrototypeOf,ke=Object.prototype.hasOwnProperty;var ye=(e,t,i,R)=>{if(t&&typeof t=="object"||typeof t=="function")for(let z of be(t))!ke.call(e,z)&&z!==i&&ne(e,z,{get:()=>t[z],enumerable:!(R=ve(t,z))||R.enumerable});return e};var xe=(e,t,i)=>(i=e!=null?ge(we(e)):{},ye(t||!e||!e.__esModule?ne(i,"default",{value:e,enumerable:!0}):i,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),c=require("react"),Se=require("./index.cjs"),de=e=>typeof e=="object"&&e!==null,je=e=>de(e)?["id","entityKey","recordId"].every(t=>typeof e[t]=="string"&&e[t].trim().length>0)&&["applicationNo","applicationType","applicantName","applicationTime"].every(t=>typeof e[t]=="string")&&["taskId","processInstanceId"].every(t=>e[t]===void 0||typeof e[t]=="string"&&e[t].trim().length>0)&&["completionTime","completionResult"].every(t=>e[t]===void 0||typeof e[t]=="string")&&(e.referenceType===void 0||e.referenceType==="task"||e.referenceType==="instance")&&(e.referenceType!=="instance"||typeof e.processInstanceId=="string"&&e.processInstanceId.trim().length>0)&&(typeof e.processStatus=="string"||e.processStatus===null):!1,Q=(e,t)=>{if(!de(e)||!Array.isArray(e.rows)||!e.rows.every(je)||typeof e.total!="number"||!Number.isSafeInteger(e.total)||e.total<0||e.rows.length>t||e.rows.length>e.total||new Set(e.rows.map(i=>i.id)).size!==e.rows.length)throw new Error("Invalid approval page contract");return{rows:e.rows,total:e.total}},A=(e,t)=>{try{e?e(t):t.phase==="error"?console.warn("[make-app-approval]",t):console.info("[make-app-approval]",t)}catch{console.warn("[make-app-approval] diagnostic sink failed")}},ae=e=>e==null||e==="UNSUBMITTED"?"状态未知":Se.getApprovalStatusDisplay(e).label,Ne=({initialPage:e,query:t,provider:i,components:R,onOpen:z,onReload:M,logger:E})=>{const[v,x]=c.useState(e),[w,P]=c.useState(2),[d,j]=c.useState("idle"),u=c.useRef(void 0),[S,L]=c.useState(!1),N=c.useRef(void 0);c.useEffect(()=>()=>{N.current?.abort()},[]);const p=async()=>{if(N.current||v.rows.length>=v.total)return;const s=new AbortController;N.current=s,j("loading");const f={operation:"list",tab:t.tab,page:w,pageSize:t.pageSize};A(E,{...f,phase:"start"});try{const h=Q(await i.loadPage({...t,page:w},{signal:s.signal}),t.pageSize);if(s.signal.aborted)return;if(h.total<v.total){A(E,{...f,phase:"skip",rowCount:h.rows.length}),M();return}const m=new Set(v.rows.map(T=>T.id));if(!h.rows.length||h.rows.some(T=>m.has(T.id)))throw new Error("Invalid append page");x({rows:[...v.rows,...h.rows],total:h.total}),P(T=>T+1),j("idle"),A(E,{...f,phase:"success",rowCount:h.rows.length})}catch{s.signal.aborted||(j("error"),A(E,{...f,phase:"error"}))}finally{N.current===s&&(N.current=void 0)}},C=s=>{const{scrollHeight:f,scrollTop:h,clientHeight:m}=s.currentTarget;d==="idle"&&f-h-m<120&&p()},{Button:D}=R;return a.jsxs("div",{className:"make-app-approval-mobile-list",onScroll:C,onTouchStart:s=>{u.current=s.currentTarget.scrollTop<=0&&s.touches.length===1&&d!=="loading"?{start:s.touches[0].clientY,distance:0}:void 0},onTouchMove:s=>{!u.current||s.touches.length!==1||(u.current.distance=s.touches[0].clientY-u.current.start,L(u.current.distance>=60))},onTouchEnd:()=>{const s=(u.current?.distance??0)>=60;u.current=void 0,L(!1),s&&M()},onTouchCancel:()=>{u.current=void 0,L(!1)},"aria-label":"审批卡片列表","aria-busy":d==="loading",children:[S&&a.jsx("p",{role:"status",className:"make-app-approval-mobile-feedback",children:"松开刷新"}),v.rows.map(s=>a.jsxs("button",{type:"button",className:"make-app-approval-mobile-card",onClick:()=>z(s),"aria-label":`打开 ${s.applicationNo} 的审批详情`,children:[a.jsx("strong",{children:s.applicationType||"审批申请"}),a.jsxs("span",{className:"make-app-approval-mobile-card-line",children:[a.jsx("span",{children:"申请单ID:"}),a.jsx("span",{children:s.applicationNo})]}),t.tab==="approved"&&a.jsxs("span",{className:"make-app-approval-mobile-card-line",children:[a.jsx("span",{children:"审批结果:"}),a.jsx("span",{children:s.completionResult||"—"})]}),t.tab==="initiated"&&a.jsxs("span",{className:"make-app-approval-mobile-card-line",children:[a.jsx("span",{children:"流程状态:"}),a.jsx("span",{children:ae(s.processStatus)})]}),a.jsxs("span",{className:"make-app-approval-mobile-card-footer",children:[a.jsxs("span",{className:"make-app-approval-mobile-person",children:[a.jsx("span",{className:"make-app-approval-mobile-avatar","aria-hidden":"true",children:s.applicantName.slice(-2)}),a.jsx("span",{children:s.applicantName||"—"})]}),a.jsx("span",{children:t.tab==="approved"?`完成于 ${s.completionTime||"—"}`:`申请于 ${s.applicationTime||"—"}`})]})]},s.id)),!v.rows.length&&a.jsx("p",{className:"make-app-approval-mobile-feedback",children:"暂无审批记录"}),d==="error"?a.jsxs("div",{role:"alert",className:"make-app-approval-mobile-feedback",children:["部分审批记录加载失败",a.jsx(D,{htmlType:"button",variant:"text",onClick:()=>{p()},children:"重试加载"})]}):d==="loading"?a.jsx("p",{role:"status",className:"make-app-approval-mobile-feedback",children:"加载中"}):v.rows.length<v.total?a.jsx(D,{htmlType:"button",variant:"text",onClick:()=>{p()},children:"加载更多"}):v.rows.length>0&&a.jsx("p",{className:"make-app-approval-mobile-feedback",children:"没有更多了"})]})},Te={applicationNo:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#1d212a" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-fingerprint-pattern" aria-hidden="true"><path d="M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4"></path><path d="M14 13.12c0 2.38 0 6.38-1 8.88"></path><path d="M17.29 21.02c.12-.6.43-2.3.5-3.02"></path><path d="M2 12a10 10 0 0 1 18-6"></path><path d="M2 16h.01"></path><path d="M21.8 16c.2-2 .131-5.354 0-6"></path><path d="M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2"></path><path d="M8.65 22c.21-.66.45-1.32.57-2"></path><path d="M9 6.8a6 6 0 0 1 9 5.2v2"></path></svg>',applicationType:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#1d212a" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-type" aria-hidden="true"><path d="M12 4v16"></path><path d="M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2"></path><path d="M9 20h6"></path></svg>',applicantName:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#1d212a" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-user-round" aria-hidden="true"><circle cx="12" cy="8" r="5"></circle><path d="M20 21a8 8 0 0 0-16 0"></path></svg>',applicationTime:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#1d212a" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-calendar-clock" aria-hidden="true"><path d="M16 14v2.2l1.6 1"></path><path d="M16 2v3"></path><path d="M21 7.338V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h2.338"></path><path d="M3 9h5.859"></path><path d="M8 2v3"></path><circle cx="16" cy="16" r="6"></circle></svg>'},ie=Object.fromEntries(Object.entries(Te).map(([e,t])=>[e,`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`])),te=64,le=[{key:"applicationNo",title:"申请单ID",width:260},{key:"applicationType",title:"业务表单",width:180},{key:"applicantName",title:"申请人",width:170},{key:"applicationTime",title:"申请时间",width:220}],ce=(e,t)=>{const i=t==="initiated"?[...le,{key:"statusLabel",title:"流程状态",width:140}]:le,R=i.reduce((M,E)=>M+E.width,te),z=Math.max(0,e-R)/i.length;return i.map(M=>({...M,width:M.width+z,showEllipsis:!0,sortable:!1,prefixRender:()=>({icon:ie[M.key]??ie.applicationType})}))},Re=({table:e,query:t,initialPage:i,loadPage:R,onChange:z,retryViewport:M,onReload:E,logger:v})=>{const x=new Map,w=new Set;let P=[];const d=new WeakMap,j=new Set;let u=i,S=i.total,L=0,N=!1,p=!1,C;const D=o=>Number.isSafeInteger(o)&&o>=0&&o*t.pageSize<S,s=(o,r,g)=>A(v,{operation:"list",phase:r,tab:t.tab,page:o+1,pageSize:t.pageSize,rowCount:g}),f=()=>{N||z({total:S,rows:P,failed:p||j.size>0,loading:x.size>0})},h=o=>{o.finished||(o.finished=!0,o.removeAbort(),x.get(o.page)===o&&x.delete(o.page),e.markPageLoadFailed(o.page,o.request),o.controller.abort(),s(o.page,"cancel"))},m=o=>{L=o;const r=e.getPagesInView()??[],g=new Set([L,...r].flatMap(k=>[k-1,k,k+1]).filter(D));for(const k of x.values())g.has(k.page)||h(k);for(const k of j)g.has(k)||j.delete(k)},T=(o,r,g)=>{const k=r.rows.map(b=>{const H={...b,statusLabel:ae(b.processStatus)};return d.set(H,b),H});if(!e.setVirtualPageData(k,o,r.total,g)){s(o,"skip");return}S=r.total;try{P=Q({rows:e.getTableData()??[],total:S},Number.MAX_SAFE_INTEGER).rows.map(b=>d.get(b)??b)}catch(b){p=!0,P=[],u=void 0,C&&clearTimeout(C),C=void 0;for(const H of x.values())h(H);throw b}u&&u.total!==S&&(u=void 0),j.delete(o);for(const b of x.values())D(b.page)||h(b);!D(o)&&o>0&&e.scrollToRow(Math.max(0,S-1)),s(o,"success",r.rows.length)},B=()=>{if(N||C)return;const o=[...x.values()].filter(r=>!r.running&&!r.finished).sort((r,g)=>Math.abs(r.page-L)-Math.abs(g.page-L)||r.page-g.page);for(const r of o){if(w.size>=2)break;r.running=!0,w.add(r),s(r.page,"start"),(async()=>{try{const g=await R({...t,page:r.page+1},{signal:r.controller.signal});if(N||r.finished||r.controller.signal.aborted)return;const k=Q(g,t.pageSize);r.finished=!0,r.removeAbort(),x.delete(r.page),T(r.page,k,r.request)}catch{!N&&!r.controller.signal.aborted&&(j.add(r.page),s(r.page,"error"),e.markPageLoadFailed(r.page,r.request))}finally{r.finished||(r.finished=!0,r.removeAbort(),x.get(r.page)===r&&x.delete(r.page)),w.delete(r),f(),B()}})()}f()},O=()=>{C&&clearTimeout(C),C=setTimeout(()=>{C=void 0,B()},120)};return{load(o,r){if(r.useRequestIdentity(),N||p||r.signal.aborted||!D(o)){e.markPageLoadFailed(o,r),s(o,"skip");return}const g=x.get(o);if(g?.request===r&&!g.finished)return;if(g&&h(g),m(o),o===0&&u){const b=u;u=void 0;try{T(0,b,r)}catch{j.add(o),e.markPageLoadFailed(o,r),s(o,"error")}f();return}const k={page:o,request:r,controller:new AbortController,running:!1,finished:!1,removeAbort:()=>{}},V=()=>{h(k),f()};r.signal.addEventListener("abort",V,{once:!0}),k.removeAbort=()=>r.signal.removeEventListener("abort",V),x.set(o,k),O(),f()},viewportChanged(){if(N)return;const o=e.getPagesInView();o?.length&&(m(o[0]),x.size&&O(),f())},retry(){if(!N){if(p){E();return}j.size!==0&&(j.clear(),M(),f())}},dispose(){N=!0,C&&clearTimeout(C),C=void 0;for(const o of x.values())h(o);P=[],j.clear(),u=void 0}}},pe=40,Ce=e=>{const t=c.useRef(void 0);return e.initialPage?a.jsx(Me,{...e,initialPage:e.initialPage,restoreScroll:t.current?.query===e.query?t.current.position:void 0,rememberScroll:i=>{t.current={query:e.query,position:i}}}):a.jsx("div",{className:"make-app-approval-canvas",role:"group","aria-label":"审批记录表格"})},Me=({components:{Button:e},initialPage:t,query:i,provider:R,themeKey:z,onOpen:M,onReload:E,logger:v,restoreScroll:x,rememberScroll:w})=>{const P=c.useRef(null),d=c.useRef(null),j=c.useRef(null),[u,S]=c.useState(!1),[L,N]=c.useState(0),[p,C]=c.useState({...t,failed:!1,loading:!1}),D=c.useRef(t.rows),s=c.useRef(x),f=c.useRef({provider:R,onOpen:M,onReload:E,logger:v,rememberScroll:w});f.current={provider:R,onOpen:M,onReload:E,logger:v,rememberScroll:w};const h=c.useRef(()=>{});return c.useEffect(()=>{const m=P.current;if(!m)return;let T=!1,B,O,o,r,g,k=t.total;A(f.current.logger,{operation:"table",phase:"start"});const V=()=>{T||(S(!0),A(f.current.logger,{operation:"table",phase:"error"}))};return import("@qfei-design/canvas-table").then(b=>{if(T)return;const H=()=>{const n=d.current,l=n?.getScrollState();n&&l&&b.globalEventBus.emitWithNamespace("scroll:change",n.tableId,l)},Y=(n=!1)=>{if(!T)try{const{width:l,height:W}=m.getBoundingClientRect();if(l<=0||W<=0||!n&&g?.width===l&&g.height===W)return;const $=getComputedStyle(m),re={rowHeight:pe,headerHeight:40,fontSize:14,fontFamily:$.fontFamily||"Arial, sans-serif",...$.color?{textColor:$.color}:{},...$.getPropertyValue("--make-approval-bg").trim()?{rowBgColor:$.getPropertyValue("--make-approval-bg").trim()}:{},...$.getPropertyValue("--make-approval-header").trim()?{headerBgColor:$.getPropertyValue("--make-approval-header").trim()}:{},...$.getPropertyValue("--make-approval-border").trim()?{borderColor:$.getPropertyValue("--make-approval-border").trim()}:{}},fe=Math.max(Math.ceil(300/i.pageSize),Math.ceil(W*3/pe/i.pageSize)+2)*i.pageSize,oe={enabled:!0,totalRowCount:k,pageSize:i.pageSize,maxCachedRows:fe};if(d.current){const y=g?.width!==l?ce(l,i.tab):void 0;if(d.current.updateProps({canvasWidth:l,canvasHeight:W,style:re,virtualOptions:oe,...y?{columns:y}:{}}),y){const I=d.current.getScrollState(),K=Math.max(0,y.reduce((U,q)=>U+q.width,te)-l);I&&I.scrollX>K&&d.current.scrollTo(K,I.scrollY,!1)}g={width:l,height:W},H();return}d.current=new b.CanvasTableComponent(m,{columns:ce(l,i.tab),canvasWidth:l,canvasHeight:W,style:re,rowKey:"id",minCanvasWidth:0,minCanvasHeight:0,showSN:{enabled:!0,width:te,formatter:(y,I)=>I+1},virtualOptions:oe,selectable:{enabled:!1},rowSortable:{enabled:!1},editApplyMode:"controlled",customEdit:y=>{y.cancel()},emptyStateOptions:{text:"暂无审批记录"},bodyRowHeadSuffixOptions:{enabled:!0,width:20,render:({group:y,x:I,height:K,rowData:U})=>{const q=U?.id,_=new b.RectShape({name:"approval-open",x:I,y:K/2-10,cursor:"pointer",tooltip:"查看审批详情",attrs:{width:20,height:20,fill:"transparent",stroke:"transparent"}});_.addChild(new b.ImgShape({name:"approval-open-icon",x:3,y:3,attrs:{width:14,height:14,img:"data:image/svg+xml;charset=utf-8,"+encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="${$.color||"#64748b"}" stroke-width="1.8"><path d="M8 3H3v5m13-5h5v5M3 16v5h5m13-5v5h-5"/></svg>`)}})),_.on("mousedown",ee=>ee.stopPropagation?.()),_.on("click",ee=>{ee.stopPropagation?.();const se=D.current.find(me=>me.id===q);se&&f.current.onOpen(se)}),y.addChild(_)}}});const X=d.current;g={width:l,height:W};const Z=Re({table:X,query:i,initialPage:t,retryViewport:H,onReload:()=>f.current.onReload(),loadPage:(y,I)=>f.current.provider.loadPage(y,I),logger:y=>A(f.current.logger,y),onChange:y=>{T||(k=y.total,D.current=y.rows,C(I=>I.total===y.total&&I.failed===y.failed&&I.loading===y.loading&&I.rows.length===y.rows.length&&I.rows.every((K,U)=>K===y.rows[U])?I:y))}});j.current=Z,O=b.globalEventBus.onWithNamespace("data:load",X.tableId,(y,I)=>Z.load(y,I)),o=b.globalEventBus.onWithNamespace("scroll:change",X.tableId,()=>Z.viewportChanged()),s.current&&X.scrollTo(s.current.scrollX,s.current.scrollY),S(!1),A(f.current.logger,{operation:"table",phase:"success"})}catch{V()}};h.current=()=>Y(!0);const F=()=>Y();B=new ResizeObserver(F),B.observe(m),window.addEventListener("resize",F),r=()=>window.removeEventListener("resize",F),Y()}).catch(V),()=>{T=!0,B?.disconnect(),r?.(),h.current=()=>{},d.current&&(s.current=d.current.getScrollState(),s.current&&f.current.rememberScroll(s.current)),O?.(),o?.(),j.current?.dispose(),j.current=null,d.current?.destroy(),d.current=null,A(f.current.logger,{operation:"table",phase:"destroy"})}},[t,i,L]),c.useEffect(()=>{h.current()},[z]),a.jsxs("div",{className:"make-app-approval-table-frame","aria-busy":p.loading,children:[a.jsx("div",{ref:P,className:"make-app-approval-canvas",role:"group","aria-label":"审批记录表格"}),u&&a.jsxs("div",{className:"make-app-approval-overlay",role:"alert",children:["表格加载失败 ",a.jsx(e,{htmlType:"button",variant:"default",onClick:()=>{S(!1),N(m=>m+1)},children:"重新加载表格"})]}),!u&&p.failed&&a.jsxs("div",{className:"make-app-approval-table-feedback",role:"alert",children:["部分审批记录加载失败 ",a.jsx(e,{htmlType:"button",variant:"default",onClick:()=>j.current?.retry(),children:"重试加载"})]}),!u&&!p.failed&&p.loading&&a.jsxs("div",{className:"make-app-approval-table-loading",role:"status","aria-label":"正在加载审批记录","aria-live":"polite",children:[a.jsx("span",{className:"make-app-approval-loading-spinner","aria-hidden":"true"}),a.jsx("span",{children:"加载中"})]}),a.jsxs("ul",{className:"make-app-approval-accessible-rows","aria-label":"审批记录文字视图",children:[p.total===0&&a.jsx("li",{children:"暂无审批记录"}),p.rows.map(m=>a.jsxs("li",{children:[a.jsxs("span",{children:[m.applicationNo,",",m.applicationType,",",m.applicantName,",",m.applicationTime,i.tab==="initiated"?`,${ae(m.processStatus)}`:"","。"]}),a.jsxs(e,{htmlType:"button",variant:"text",onClick:()=>M(m),children:["打开 ",m.applicationNo||m.applicationType," 的审批详情"]})]},m.id))]})]})},Pe=[],Ie=(e,t,i,R)=>{const[z,M]=c.useState(0),[E,v]=c.useState(),x=c.useRef({provider:e,logger:R});x.current={provider:e,logger:R};const w=c.useMemo(()=>({}),[t,i,z]);c.useEffect(()=>{const d=new AbortController,{provider:j,logger:u}=x.current,S={operation:"list",tab:t.tab,page:t.page,pageSize:t.pageSize};A(u,{...S,phase:"start"});let L=!1;return(async()=>{try{if(await Promise.resolve(),d.signal.aborted)return;const N=await j.loadPage(t,{signal:d.signal});if(d.signal.aborted)return;const p=Q(N,t.pageSize);L=!0,v({...p,token:w,status:"success"}),A(u,{...S,phase:"success",rowCount:p.rows.length})}catch{if(d.signal.aborted)return;L=!0,v({token:w,status:"error",rows:Pe,total:0}),A(u,{...S,phase:"error"})}})(),()=>{d.abort(),L||A(u,{...S,phase:"cancel"})}},[t,w]);const P=E?.token===w?E:void 0;return{initialPage:P?.status==="success"?P:void 0,total:P?.total??0,status:P?.status??"loading",reload:()=>M(d=>d+1)}},J={keyword:"",applicantId:"",processStatus:"",startDate:"",endDate:""},he=["pending","approved"],ue={pending:"待处理",approved:"已完成",initiated:"已发起"},G=e=>{if(e==="")return!0;if(!/^\d{4}-\d{2}-\d{2}$/.test(e))return!1;const t=new Date(`${e}T00:00:00Z`);return Number.isFinite(t.getTime())&&t.toISOString().slice(0,10)===e},ze=({components:e,provider:t,onOpenApproval:i,applicantOptions:R=[],pageSize:z=20,refreshKey:M,themeKey:E,logger:v,className:x,presentation:w="desktop",tabs:P=he})=>{const{Input:d,Select:j,DateRangePicker:u,Button:S,Tabs:L}=e,N=c.useId(),[p,C]=c.useState(J),[D,s]=c.useState(0),[f,h]=c.useState(""),[m,T]=c.useState(""),[B,O]=c.useState({...J,tab:P[0],page:1,pageSize:z}),{initialPage:o,status:r,reload:g}=Ie(t,B,M,v),k=c.useRef(!1),V=c.useRef(!0);c.useEffect(()=>(V.current=!0,()=>{V.current=!1}),[]);const b=r==="loading",H=async n=>{if(!k.current){k.current=!0,T(""),A(v,{operation:"open",phase:"start"});try{await i(n),A(v,{operation:"open",phase:"success"})}catch{V.current&&T("审批详情打开失败,请重试"),A(v,{operation:"open",phase:"error"})}finally{k.current=!1}}},Y=n=>{n===B.tab||!P.includes(n)||(h(""),T(""),n==="initiated"&&C(l=>({...l,keyword:"",applicantId:"",processStatus:""})),O(l=>({...l,...n==="initiated"?{keyword:"",applicantId:"",processStatus:""}:{},tab:n,page:1})))},F=n=>{C(l=>({...l,...n})),w==="mobile"&&(h(""),T(""),O(l=>({...l,...n,page:1})))};return a.jsx("section",{className:["make-app-approval",w==="mobile"&&"make-app-approval--mobile",x].filter(Boolean).join(" "),"aria-label":"我的审批",children:a.jsxs(L,{items:P.map(n=>({value:n,label:ue[n]})),value:B.tab,onChange:Y,ariaLabel:"审批分类",children:[a.jsxs("form",{className:"make-app-approval-filters",onSubmit:n=>{if(n.preventDefault(),w==="mobile"){h(""),T(""),O(l=>({...l,keyword:p.keyword.trim(),page:1}));return}if(!G(p.startDate)||!G(p.endDate)){h("请选择有效日期");return}if(p.startDate&&p.endDate&&p.startDate>p.endDate){h("开始日期不能晚于结束日期");return}h(""),T(""),O(l=>({...l,...p,keyword:p.keyword.trim(),page:1}))},children:[B.tab!=="initiated"&&a.jsxs("div",{className:"make-app-approval-filter-field",children:[w==="mobile"&&a.jsx(S,{htmlType:"submit",variant:"text",ariaLabel:"搜索申请单ID",children:a.jsxs("svg",{"aria-hidden":"true",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[a.jsx("circle",{cx:"10.5",cy:"10.5",r:"6.5"}),a.jsx("path",{d:"m16 16 5 5"})]})}),a.jsx(d,{id:`${N}-keyword`,ariaLabel:"申请单ID",placeholder:"搜索申请单ID",value:p.keyword,onChange:n=>{C(l=>({...l,keyword:n})),w==="mobile"&&!n&&O(l=>({...l,keyword:"",page:1}))}})]}),a.jsx("div",{className:"make-app-approval-date-control",children:a.jsx(u,{id:`${N}-period`,ariaLabel:"申请时间",placeholder:["开始日期","结束日期"],value:[p.startDate,p.endDate],onChange:([n,l])=>{if(w==="mobile"&&(!G(n)||!G(l)||n&&l&&n>l)){h("请选择有效日期范围");return}if(w==="mobile"&&!!n!=!!l){C(W=>({...W,startDate:n,endDate:l}));return}F({startDate:n,endDate:l})}},D)}),B.tab!=="initiated"&&a.jsx("div",{className:"make-app-approval-filter-field",children:a.jsx(j,{id:`${N}-applicant`,ariaLabel:"申请人",purpose:"applicant",value:p.applicantId??"",options:[{value:"",label:"全部申请人"},...R.filter(n=>n.value!=="")],onChange:n=>F({applicantId:n})})}),w!=="mobile"&&a.jsxs("div",{className:"make-app-approval-filter-actions",children:[a.jsx(S,{htmlType:"submit",variant:"primary",children:"查询"}),a.jsx(S,{htmlType:"button",variant:"default",onClick:()=>{C(J),s(n=>n+1),h(""),T(""),O(n=>({...n,...J,page:1}))},children:"重置"}),a.jsx(S,{htmlType:"button",variant:"default",disabled:b,loading:b,onClick:g,children:"刷新"})]})]}),f&&a.jsx("p",{role:"alert",className:"make-app-approval-error",children:f}),m&&a.jsx("p",{role:"alert",className:"make-app-approval-error",children:m}),a.jsxs("div",{className:"make-app-approval-results","aria-busy":b,children:[w==="mobile"?o&&a.jsx(Ne,{initialPage:o,query:B,provider:t,onReload:g,components:e,onOpen:n=>{H(n)},logger:v},JSON.stringify([B,M,o])):a.jsx(Ce,{components:e,initialPage:o,query:B,provider:t,onOpen:n=>{H(n)},onReload:g,themeKey:E,logger:v}),b&&a.jsx("div",{className:"make-app-approval-overlay",role:"status",children:"正在加载审批记录…"}),r==="error"&&a.jsxs("div",{className:"make-app-approval-overlay",role:"alert",children:[a.jsx("span",{children:"审批列表加载失败,请重试"}),a.jsx(S,{htmlType:"button",variant:"default",onClick:g,children:"重试"})]})]})]})})},Ae=e=>{const t=e.pageSize??20,i=e.tabs??he;if(!i.length||new Set(i).size!==i.length||i.some(R=>!Object.hasOwn(ue,R)))throw new Error("MyApprovalsPage requires valid unique tabs");if(!e.scopeKey.trim())throw new Error("MyApprovalsPage requires scopeKey");for(const R of["Input","Select","DateRangePicker","Button","Tabs"])if(!e.components?.[R])throw new Error(`MyApprovalsPage requires components.${R}`);if(!Number.isSafeInteger(t)||t<1||t>200)throw new Error("pageSize must be an integer from 1 to 200");return a.jsx(ze,{...e,tabs:i,pageSize:t},JSON.stringify([e.scopeKey,t,i]))};exports.MyApprovalsPage=Ae;
1
+ "use strict";var Me=Object.create;var me=Object.defineProperty;var Ae=Object.getOwnPropertyDescriptor;var Pe=Object.getOwnPropertyNames;var Ie=Object.getPrototypeOf,ze=Object.prototype.hasOwnProperty;var Ee=(e,t,s,f)=>{if(t&&typeof t=="object"||typeof t=="function")for(let R of Pe(t))!ze.call(e,R)&&R!==s&&me(e,R,{get:()=>t[R],enumerable:!(f=Ae(t,R))||f.enumerable});return e};var Be=(e,t,s)=>(s=e!=null?Me(Ie(e)):{},Ee(t||!e||!e.__esModule?me(s,"default",{value:e,enumerable:!0}):s,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),ye=require("./theme-pzn9q1zq.cjs"),c=require("react"),ke=require("./index.cjs"),xe=e=>typeof e=="object"&&e!==null,Le=e=>xe(e)?["id","entityKey","recordId"].every(t=>typeof e[t]=="string"&&e[t].trim().length>0)&&["applicationNo","applicationType","applicantName","applicationTime"].every(t=>typeof e[t]=="string")&&["taskId","processInstanceId"].every(t=>e[t]===void 0||typeof e[t]=="string"&&e[t].trim().length>0)&&["completionTime","completionResult"].every(t=>e[t]===void 0||typeof e[t]=="string")&&(e.referenceType===void 0||e.referenceType==="task"||e.referenceType==="instance")&&(e.referenceType!=="instance"||typeof e.processInstanceId=="string"&&e.processInstanceId.trim().length>0)&&(typeof e.processStatus=="string"||e.processStatus===null):!1,ne=(e,t)=>{if(!xe(e)||!Array.isArray(e.rows)||!e.rows.every(Le)||typeof e.total!="number"||!Number.isSafeInteger(e.total)||e.total<0||e.rows.length>t||e.rows.length>e.total||new Set(e.rows.map(s=>s.id)).size!==e.rows.length)throw new Error("Invalid approval page contract");return{rows:e.rows,total:e.total}},E=(e,t)=>{try{e?e(t):t.phase==="error"?console.warn("[make-app-approval]",t):console.info("[make-app-approval]",t)}catch{console.warn("[make-app-approval] diagnostic sink failed")}},pe=e=>e==null||e==="UNSUBMITTED"?"状态未知":ke.getApprovalStatusDisplay(e).label,Oe=({initialPage:e,query:t,provider:s,components:f,onOpen:R,onReload:S,logger:g})=>{const[p,w]=c.useState(e),[l,j]=c.useState(2),[k,C]=c.useState("idle"),v=c.useRef(void 0),[P,T]=c.useState(!1),h=c.useRef(void 0);c.useEffect(()=>()=>{h.current?.abort()},[]);const M=async()=>{if(h.current||p.rows.length>=p.total)return;const i=new AbortController;h.current=i,C("loading");const A={operation:"list",tab:t.tab,page:l,pageSize:t.pageSize};E(g,{...A,phase:"start"});try{const y=ne(await s.loadPage({...t,page:l},{signal:i.signal}),t.pageSize);if(i.signal.aborted)return;if(y.total<p.total){E(g,{...A,phase:"skip",rowCount:y.rows.length}),S();return}const V=new Set(p.rows.map(H=>H.id));if(!y.rows.length||y.rows.some(H=>V.has(H.id)))throw new Error("Invalid append page");w({rows:[...p.rows,...y.rows],total:y.total}),j(H=>H+1),C("idle"),E(g,{...A,phase:"success",rowCount:y.rows.length})}catch{i.signal.aborted||(C("error"),E(g,{...A,phase:"error"}))}finally{h.current===i&&(h.current=void 0)}},d=i=>{const{scrollHeight:A,scrollTop:y,clientHeight:V}=i.currentTarget;k==="idle"&&A-y-V<120&&M()},{Button:B}=f;return r.jsxs("div",{className:"make-app-approval-mobile-list",onScroll:d,onTouchStart:i=>{v.current=i.currentTarget.scrollTop<=0&&i.touches.length===1&&k!=="loading"?{start:i.touches[0].clientY,distance:0}:void 0},onTouchMove:i=>{!v.current||i.touches.length!==1||(v.current.distance=i.touches[0].clientY-v.current.start,T(v.current.distance>=60))},onTouchEnd:()=>{const i=(v.current?.distance??0)>=60;v.current=void 0,T(!1),i&&S()},onTouchCancel:()=>{v.current=void 0,T(!1)},"aria-label":"审批卡片列表","aria-busy":k==="loading",children:[P&&r.jsx("p",{role:"status",className:"make-app-approval-mobile-feedback",children:"松开刷新"}),p.rows.map(i=>r.jsxs("button",{type:"button",className:"make-app-approval-mobile-card",onClick:()=>R(i),"aria-label":`打开 ${i.applicationNo} 的审批详情`,children:[r.jsx("strong",{children:i.applicationType||"审批申请"}),r.jsxs("span",{className:"make-app-approval-mobile-card-line",children:[r.jsx("span",{children:"申请单ID:"}),r.jsx("span",{children:i.applicationNo})]}),t.tab==="approved"&&r.jsxs("span",{className:"make-app-approval-mobile-card-line",children:[r.jsx("span",{children:"审批结果:"}),r.jsx("span",{children:i.completionResult||"—"})]}),t.tab==="initiated"&&r.jsxs("span",{className:"make-app-approval-mobile-card-line",children:[r.jsx("span",{children:"流程状态:"}),r.jsx("span",{children:pe(i.processStatus)})]}),r.jsxs("span",{className:"make-app-approval-mobile-card-footer",children:[r.jsxs("span",{className:"make-app-approval-mobile-person",children:[r.jsx("span",{className:"make-app-approval-mobile-avatar","aria-hidden":"true",children:i.applicantName.slice(-2)}),r.jsx("span",{children:i.applicantName||"—"})]}),r.jsx("span",{children:t.tab==="approved"?`完成于 ${i.completionTime||"—"}`:`申请于 ${i.applicationTime||"—"}`})]})]},i.id)),!p.rows.length&&r.jsx("p",{className:"make-app-approval-mobile-feedback",children:"暂无审批记录"}),k==="error"?r.jsxs("div",{role:"alert",className:"make-app-approval-mobile-feedback",children:["部分审批记录加载失败",r.jsx(B,{htmlType:"button",variant:"text",onClick:()=>{M()},children:"重试加载"})]}):k==="loading"?r.jsx("p",{role:"status",className:"make-app-approval-mobile-feedback",children:"加载中"}):p.rows.length<p.total?r.jsx(B,{htmlType:"button",variant:"text",onClick:()=>{M()},children:"加载更多"}):p.rows.length>0&&r.jsx("p",{className:"make-app-approval-mobile-feedback",children:"没有更多了"})]})},He=e=>{const t=ke.toMakeApprovalThemeStyle(e),s={},f=(S,g)=>{const p=t[`--make-approval-theme-${g}`];p!==void 0&&(s[S]=p)},R=(S,g)=>{const p=t[`--make-approval-theme-${g}`];p!==void 0&&(s[S]=Number.parseFloat(p))};for(const[S,g]of Object.entries({primaryColor:"primary",onPrimaryColor:"on-primary",textColor:"text",headerTextColor:"heading-text",rowBgColor:"surface",canvasBgColor:"page",headerBgColor:"subtle-surface",borderColor:"border-color",hoverColor:"hover-surface",selectedBgColor:"selected-surface",activeBgColor:"active-surface",activeBorderColor:"focus-ring",secondaryTextColor:"secondary-text",placeholderTextColor:"placeholder-text",tooltipBgColor:"elevated-surface",tooltipTextColor:"text",fontFamily:"font-family"}))f(S,g);for(const[S,g]of Object.entries({fontSize:"font-size-body",fontWeight:"font-weight-body",headerFontSize:"font-size-field-label",headerFontWeight:"font-weight-heading",secondaryFontSize:"font-size-meta",rowHeight:"row-height",headerHeight:"header-height",cellPadding:"spacing-table-cell",headerCellPadding:"spacing-table-header",tooltipFontSize:"font-size-meta",tooltipBorderRadius:"radius-popup"}))R(S,g);return s.headerTextColor===void 0&&s.textColor!==void 0&&(s.headerTextColor=s.textColor),s},De=(e,t)=>t==="canvas-table/semantic-theme/v1"?e:{},Se={applicationNo:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#1d212a" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-fingerprint-pattern" aria-hidden="true"><path d="M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4"></path><path d="M14 13.12c0 2.38 0 6.38-1 8.88"></path><path d="M17.29 21.02c.12-.6.43-2.3.5-3.02"></path><path d="M2 12a10 10 0 0 1 18-6"></path><path d="M2 16h.01"></path><path d="M21.8 16c.2-2 .131-5.354 0-6"></path><path d="M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2"></path><path d="M8.65 22c.21-.66.45-1.32.57-2"></path><path d="M9 6.8a6 6 0 0 1 9 5.2v2"></path></svg>',applicationType:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#1d212a" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-type" aria-hidden="true"><path d="M12 4v16"></path><path d="M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2"></path><path d="M9 20h6"></path></svg>',applicantName:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#1d212a" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-user-round" aria-hidden="true"><circle cx="12" cy="8" r="5"></circle><path d="M20 21a8 8 0 0 0-16 0"></path></svg>',applicationTime:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#1d212a" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-calendar-clock" aria-hidden="true"><path d="M16 14v2.2l1.6 1"></path><path d="M16 2v3"></path><path d="M21 7.338V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h2.338"></path><path d="M3 9h5.859"></path><path d="M8 2v3"></path><circle cx="16" cy="16" r="6"></circle></svg>'},fe=Object.fromEntries(Object.entries(Se).map(([e,t])=>[e,`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`])),Fe=e=>{const t=e.replace(/[&<>"']/g,s=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&apos;"})[s]);return Object.fromEntries(Object.entries(Se).map(([s,f])=>[s,`data:image/svg+xml;charset=utf-8,${encodeURIComponent(f.replaceAll("#1d212a",t))}`]))},ce=64,ge=[{key:"applicationNo",title:"申请单ID",width:260},{key:"applicationType",title:"业务表单",width:180},{key:"applicantName",title:"申请人",width:170},{key:"applicationTime",title:"申请时间",width:220}],ve=(e,t,s)=>{let f,R=fe;const S=()=>{const l=typeof s=="function"?s():s;return l!==f&&(f=l,R=l?Fe(l):fe),R},g=t==="initiated"?[...ge,{key:"statusLabel",title:"流程状态",width:140}]:ge,p=g.reduce((l,j)=>l+j.width,ce),w=Math.max(0,e-p)/g.length;return g.map(l=>({...l,width:l.width+w,showEllipsis:!0,sortable:!1,prefixRender:()=>{const j=S();return{icon:j[l.key]??j.applicationType}}}))},Ve=({table:e,query:t,initialPage:s,loadPage:f,onChange:R,retryViewport:S,onReload:g,logger:p})=>{const w=new Map,l=new Set;let j=[];const k=new WeakMap,C=new Set;let v=s,P=s.total,T=0,h=!1,M=!1,d;const B=o=>Number.isSafeInteger(o)&&o>=0&&o*t.pageSize<P,i=(o,a,u)=>E(p,{operation:"list",phase:a,tab:t.tab,page:o+1,pageSize:t.pageSize,rowCount:u}),A=()=>{h||R({total:P,rows:j,failed:M||C.size>0,loading:w.size>0})},y=o=>{o.finished||(o.finished=!0,o.removeAbort(),w.get(o.page)===o&&w.delete(o.page),e.markPageLoadFailed(o.page,o.request),o.controller.abort(),i(o.page,"cancel"))},V=o=>{T=o;const a=e.getPagesInView()??[],u=new Set([T,...a].flatMap(b=>[b-1,b,b+1]).filter(B));for(const b of w.values())u.has(b.page)||y(b);for(const b of C)u.has(b)||C.delete(b)},H=(o,a,u)=>{const b=a.rows.map(N=>{const D={...N,statusLabel:pe(N.processStatus)};return k.set(D,N),D});if(!e.setVirtualPageData(b,o,a.total,u)){i(o,"skip");return}P=a.total;try{j=ne({rows:e.getTableData()??[],total:P},Number.MAX_SAFE_INTEGER).rows.map(N=>k.get(N)??N)}catch(N){M=!0,j=[],v=void 0,d&&clearTimeout(d),d=void 0;for(const D of w.values())y(D);throw N}v&&v.total!==P&&(v=void 0),C.delete(o);for(const N of w.values())B(N.page)||y(N);!B(o)&&o>0&&e.scrollToRow(Math.max(0,P-1)),i(o,"success",a.rows.length)},I=()=>{if(h||d)return;const o=[...w.values()].filter(a=>!a.running&&!a.finished).sort((a,u)=>Math.abs(a.page-T)-Math.abs(u.page-T)||a.page-u.page);for(const a of o){if(l.size>=2)break;a.running=!0,l.add(a),i(a.page,"start"),(async()=>{try{const u=await f({...t,page:a.page+1},{signal:a.controller.signal});if(h||a.finished||a.controller.signal.aborted)return;const b=ne(u,t.pageSize);a.finished=!0,a.removeAbort(),w.delete(a.page),H(a.page,b,a.request)}catch{!h&&!a.controller.signal.aborted&&(C.add(a.page),i(a.page,"error"),e.markPageLoadFailed(a.page,a.request))}finally{a.finished||(a.finished=!0,a.removeAbort(),w.get(a.page)===a&&w.delete(a.page)),l.delete(a),A(),I()}})()}A()},L=()=>{d&&clearTimeout(d),d=setTimeout(()=>{d=void 0,I()},120)};return{load(o,a){if(a.useRequestIdentity(),h||M||a.signal.aborted||!B(o)){e.markPageLoadFailed(o,a),i(o,"skip");return}const u=w.get(o);if(u?.request===a&&!u.finished)return;if(u&&y(u),V(o),o===0&&v){const N=v;v=void 0;try{H(0,N,a)}catch{C.add(o),e.markPageLoadFailed(o,a),i(o,"error")}A();return}const b={page:o,request:a,controller:new AbortController,running:!1,finished:!1,removeAbort:()=>{}},W=()=>{y(b),A()};a.signal.addEventListener("abort",W,{once:!0}),b.removeAbort=()=>a.signal.removeEventListener("abort",W),w.set(o,b),L(),A()},viewportChanged(){if(h)return;const o=e.getPagesInView();o?.length&&(V(o[0]),w.size&&L(),A())},retry(){if(!h){if(M){g();return}C.size!==0&&(C.clear(),S(),A())}},dispose(){h=!0,d&&clearTimeout(d),d=void 0;for(const o of w.values())y(o);j=[],C.clear(),v=void 0}}},be=40,$e=e=>{const t=c.useRef(void 0);return e.initialPage?r.jsx(We,{...e,initialPage:e.initialPage,restoreScroll:t.current?.query===e.query?t.current.position:void 0,rememberScroll:s=>{t.current={query:e.query,position:s}}}):r.jsx("div",{className:"make-app-approval-canvas",role:"group","aria-label":"审批记录表格"})},We=({components:{Button:e},initialPage:t,query:s,provider:f,themeKey:R,onOpen:S,onReload:g,logger:p,restoreScroll:w,rememberScroll:l})=>{const j=ye.useApprovalThemeState("desktop"),k=He(j.theme),C=c.useRef(k);C.current=k;const v=JSON.stringify(k),P=c.useRef({}),T=c.useRef(null),h=c.useRef(null),M=c.useRef(null),[d,B]=c.useState(!1),[i,A]=c.useState(0),[y,V]=c.useState({...t,failed:!1,loading:!1}),H=c.useRef(t.rows),I=c.useRef(w),L=c.useRef({provider:f,onOpen:S,onReload:g,logger:p,rememberScroll:l});L.current={provider:f,onOpen:S,onReload:g,logger:p,rememberScroll:l};const o=c.useRef(()=>{});return c.useEffect(()=>{const a=T.current;if(!a)return;let u=!1,b,W,N,D,_,U=t.total,G=!1;E(L.current.logger,{operation:"table",phase:"start"});const ee=()=>{u||(B(!0),E(L.current.logger,{operation:"table",phase:"error"}))};return import("@qfei-design/canvas-table").then(F=>{if(u)return;const Q="CANVAS_TABLE_THEME_CONTRACT"in F?F.CANVAS_TABLE_THEME_CONTRACT:void 0,X=()=>{const $=h.current,O=$?.getScrollState();$&&O&&F.globalEventBus.emitWithNamespace("scroll:change",$.tableId,O)},n=($=!1)=>{if(!u)try{const{width:O,height:Y}=a.getBoundingClientRect();if(O<=0||Y<=0||!$&&_?.width===O&&_.height===Y)return;const K=getComputedStyle(a);Q!=="canvas-table/semantic-theme/v1"&&Object.keys(C.current).length>0&&!G&&(G=!0,E(L.current.logger,{operation:"table",phase:"skip",reason:"canvas-theme-contract-unavailable"}));const te={rowHeight:be,headerHeight:40,fontSize:14,fontFamily:K.fontFamily||"Arial, sans-serif",...K.color?{textColor:K.color}:{},...K.getPropertyValue("--make-approval-bg").trim()?{rowBgColor:K.getPropertyValue("--make-approval-bg").trim()}:{},...K.getPropertyValue("--make-approval-header").trim()?{headerBgColor:K.getPropertyValue("--make-approval-header").trim()}:{},...K.getPropertyValue("--make-approval-border").trim()?{borderColor:K.getPropertyValue("--make-approval-border").trim()}:{},...De(C.current,Q)};P.current=te;const Te=te.rowHeight??be,de=()=>P.current.headerTextColor,Ne=Math.max(Math.ceil(300/s.pageSize),Math.ceil(Y*3/Te/s.pageSize)+2)*s.pageSize,he={enabled:!0,totalRowCount:U,pageSize:s.pageSize,maxCachedRows:Ne};if(h.current){const x=_?.width!==O?ve(O,s.tab,de):void 0;if(h.current.updateProps({canvasWidth:O,canvasHeight:Y,style:te,virtualOptions:he,...x?{columns:x}:{}}),x){const z=h.current.getScrollState(),J=Math.max(0,x.reduce((Z,le)=>Z+le.width,ce)-O);z&&z.scrollX>J&&h.current.scrollTo(J,z.scrollY,!1)}_={width:O,height:Y},X();return}h.current=new F.CanvasTableComponent(a,{columns:ve(O,s.tab,de),canvasWidth:O,canvasHeight:Y,style:te,rowKey:"id",minCanvasWidth:0,minCanvasHeight:0,showSN:{enabled:!0,width:ce,formatter:(x,z)=>z+1},virtualOptions:he,selectable:{enabled:!1},rowSortable:{enabled:!1},editApplyMode:"controlled",customEdit:x=>{x.cancel()},emptyStateOptions:{text:"暂无审批记录"},bodyRowHeadSuffixOptions:{enabled:!0,width:20,render:({group:x,x:z,height:J,rowData:Z})=>{const le=Z?.id,re=new F.RectShape({name:"approval-open",x:z,y:J/2-10,cursor:"pointer",tooltip:"查看审批详情",attrs:{width:20,height:20,fill:"transparent",stroke:"transparent"}});re.addChild(new F.ImgShape({name:"approval-open-icon",x:3,y:3,attrs:{width:14,height:14,img:"data:image/svg+xml;charset=utf-8,"+encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="${String(P.current.textColor||"#64748b").replace(/[&<>"']/g,q=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&apos;"})[q])}" stroke-width="1.8"><path d="M8 3H3v5m13-5h5v5M3 16v5h5m13-5v5h-5"/></svg>`)}})),re.on("mousedown",q=>q.stopPropagation?.()),re.on("click",q=>{q.stopPropagation?.();const ue=H.current.find(Re=>Re.id===le);ue&&L.current.onOpen(ue)}),x.addChild(re)}}});const ae=h.current;_={width:O,height:Y};const ie=Ve({table:ae,query:s,initialPage:t,retryViewport:X,onReload:()=>L.current.onReload(),loadPage:(x,z)=>L.current.provider.loadPage(x,z),logger:x=>E(L.current.logger,x),onChange:x=>{u||(U=x.total,H.current=x.rows,V(z=>z.total===x.total&&z.failed===x.failed&&z.loading===x.loading&&z.rows.length===x.rows.length&&z.rows.every((J,Z)=>J===x.rows[Z])?z:x))}});M.current=ie,W=F.globalEventBus.onWithNamespace("data:load",ae.tableId,(x,z)=>ie.load(x,z)),N=F.globalEventBus.onWithNamespace("scroll:change",ae.tableId,()=>ie.viewportChanged()),I.current&&ae.scrollTo(I.current.scrollX,I.current.scrollY),B(!1),E(L.current.logger,{operation:"table",phase:"success"})}catch{ee()}};o.current=()=>n(!0);const m=()=>n();b=new ResizeObserver(m),b.observe(a),window.addEventListener("resize",m),D=()=>window.removeEventListener("resize",m),n()}).catch(ee),()=>{u=!0,b?.disconnect(),D?.(),o.current=()=>{},h.current&&(I.current=h.current.getScrollState(),I.current&&L.current.rememberScroll(I.current)),W?.(),N?.(),M.current?.dispose(),M.current=null,h.current?.destroy(),h.current=null,E(L.current.logger,{operation:"table",phase:"destroy"})}},[t,s,i]),c.useEffect(()=>{o.current()},[R,v]),r.jsxs("div",{className:"make-app-approval-table-frame","aria-busy":y.loading,children:[r.jsx("div",{ref:T,className:"make-app-approval-canvas",role:"group","aria-label":"审批记录表格"}),d&&r.jsxs("div",{className:"make-app-approval-overlay",role:"alert",children:["表格加载失败 ",r.jsx(e,{htmlType:"button",variant:"default",onClick:()=>{B(!1),A(a=>a+1)},children:"重新加载表格"})]}),!d&&y.failed&&r.jsxs("div",{className:"make-app-approval-table-feedback",role:"alert",children:["部分审批记录加载失败 ",r.jsx(e,{htmlType:"button",variant:"default",onClick:()=>M.current?.retry(),children:"重试加载"})]}),!d&&!y.failed&&y.loading&&r.jsxs("div",{className:"make-app-approval-table-loading",role:"status","aria-label":"正在加载审批记录","aria-live":"polite",children:[r.jsx("span",{className:"make-app-approval-loading-spinner","aria-hidden":"true"}),r.jsx("span",{children:"加载中"})]}),r.jsxs("ul",{className:"make-app-approval-accessible-rows","aria-label":"审批记录文字视图",children:[y.total===0&&r.jsx("li",{children:"暂无审批记录"}),y.rows.map(a=>r.jsxs("li",{children:[r.jsxs("span",{children:[a.applicationNo,",",a.applicationType,",",a.applicantName,",",a.applicationTime,s.tab==="initiated"?`,${pe(a.processStatus)}`:"","。"]}),r.jsxs(e,{htmlType:"button",variant:"text",onClick:()=>S(a),children:["打开 ",a.applicationNo||a.applicationType," 的审批详情"]})]},a.id))]})]})},_e=[],Ke=(e,t,s,f)=>{const[R,S]=c.useState(0),[g,p]=c.useState(),w=c.useRef({provider:e,logger:f});w.current={provider:e,logger:f};const l=c.useMemo(()=>({}),[t,s,R]);c.useEffect(()=>{const k=new AbortController,{provider:C,logger:v}=w.current,P={operation:"list",tab:t.tab,page:t.page,pageSize:t.pageSize};E(v,{...P,phase:"start"});let T=!1;return(async()=>{try{if(await Promise.resolve(),k.signal.aborted)return;const h=await C.loadPage(t,{signal:k.signal});if(k.signal.aborted)return;const M=ne(h,t.pageSize);T=!0,p({...M,token:l,status:"success"}),E(v,{...P,phase:"success",rowCount:M.rows.length})}catch{if(k.signal.aborted)return;T=!0,p({token:l,status:"error",rows:_e,total:0}),E(v,{...P,phase:"error"})}})(),()=>{k.abort(),T||E(v,{...P,phase:"cancel"})}},[t,l]);const j=g?.token===l?g:void 0;return{initialPage:j?.status==="success"?j:void 0,total:j?.total??0,status:j?.status??"loading",reload:()=>S(k=>k+1)}},oe={keyword:"",applicantId:"",processStatus:"",startDate:"",endDate:""},je=["pending","approved"],Ce={pending:"待处理",approved:"已完成",initiated:"已发起"},we=r.jsxs("svg",{"aria-hidden":"true",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[r.jsx("circle",{cx:"10.5",cy:"10.5",r:"6.5"}),r.jsx("path",{d:"m16 16 5 5"})]}),se=e=>{if(e==="")return!0;if(!/^\d{4}-\d{2}-\d{2}$/.test(e))return!1;const t=new Date(`${e}T00:00:00Z`);return Number.isFinite(t.getTime())&&t.toISOString().slice(0,10)===e},Ue=({components:e,provider:t,onOpenApproval:s,applicantOptions:f=[],pageSize:R=20,refreshKey:S,themeKey:g,logger:p,className:w,presentation:l="desktop",spacing:j="host",tabs:k=je})=>{const{Input:C,Select:v,DateRangePicker:P,Button:T,Tabs:h}=e,M=c.useId(),[d,B]=c.useState(oe),[i,A]=c.useState(),[y,V]=c.useState(0),[H,I]=c.useState(""),[L,o]=c.useState(""),[a,u]=c.useState({...oe,tab:k[0],page:1,pageSize:R}),{initialPage:b,status:W,reload:N}=Ke(t,a,S,p),D=c.useRef(!1),_=c.useRef(!0);c.useEffect(()=>(_.current=!0,()=>{_.current=!1}),[]);const U=W==="loading",G=async n=>{if(!D.current){D.current=!0,o(""),E(p,{operation:"open",phase:"start"});try{await s(n),E(p,{operation:"open",phase:"success"})}catch{_.current&&o("审批详情打开失败,请重试"),E(p,{operation:"open",phase:"error"})}finally{D.current=!1}}},ee=n=>{n===a.tab||!k.includes(n)||(I(""),o(""),n==="initiated"&&(B(m=>({...m,keyword:"",applicantId:"",processStatus:""})),A(void 0)),u(m=>({...m,...n==="initiated"?{keyword:"",applicantId:"",processStatus:""}:{},tab:n,page:1})))},F=n=>{B(m=>({...m,...n})),l==="mobile"&&(I(""),o(""),u(m=>({...m,...n,page:1})))},Q=r.jsxs(r.Fragment,{children:[r.jsxs("form",{className:"make-app-approval-filters",onSubmit:n=>{if(n.preventDefault(),l==="mobile"){I(""),o(""),u(m=>({...m,keyword:d.keyword.trim(),page:1}));return}if(!se(d.startDate)||!se(d.endDate)){I("请选择有效日期");return}if(d.startDate&&d.endDate&&d.startDate>d.endDate){I("开始日期不能晚于结束日期");return}I(""),o(""),u(m=>({...m,...d,keyword:d.keyword.trim(),page:1}))},children:[a.tab!=="initiated"&&r.jsxs("div",{className:"make-app-approval-filter-field",children:[l==="mobile"&&(j==="standard"?r.jsx("button",{type:"submit",className:"make-app-approval-mobile-search-button","aria-label":"搜索申请单ID",children:we}):r.jsx(T,{htmlType:"submit",variant:"text",ariaLabel:"搜索申请单ID",children:we})),r.jsx(C,{id:`${M}-keyword`,ariaLabel:"申请单ID",placeholder:"搜索申请单ID",value:d.keyword,onChange:n=>{B(m=>({...m,keyword:n})),l==="mobile"&&!n&&u(m=>({...m,keyword:"",page:1}))}})]}),r.jsx("div",{className:"make-app-approval-date-control",children:r.jsx(P,{id:`${M}-period`,ariaLabel:"申请时间",placeholder:["开始日期","结束日期"],value:[d.startDate,d.endDate],onChange:([n,m])=>{if(l==="mobile"&&(!se(n)||!se(m)||n&&m&&n>m)){I("请选择有效日期范围");return}if(l==="mobile"&&!!n!=!!m){B($=>({...$,startDate:n,endDate:m}));return}F({startDate:n,endDate:m})}},y)}),a.tab!=="initiated"&&r.jsx("div",{className:"make-app-approval-filter-field",children:r.jsx(v,{id:`${M}-applicant`,ariaLabel:"申请人",purpose:"applicant",value:d.applicantId??"",...j==="standard"&&i?.value===d.applicantId?{selectedOption:i}:{},options:[{value:"",label:"全部申请人"},...f.filter(n=>n.value!=="")],onChange:(n,m)=>{A($=>n?m?.value===n?m:f.find(O=>O.value===n)??($?.value===n?$:void 0):void 0),F({applicantId:n})}})}),l!=="mobile"&&r.jsxs("div",{className:"make-app-approval-filter-actions",children:[r.jsx(T,{htmlType:"submit",variant:"primary",children:"查询"}),r.jsx(T,{htmlType:"button",variant:"default",onClick:()=>{B(oe),A(void 0),V(n=>n+1),I(""),o(""),u(n=>({...n,...oe,page:1}))},children:"重置"}),r.jsx(T,{htmlType:"button",variant:"default",disabled:U,loading:U,onClick:N,children:"刷新"})]})]}),H&&r.jsx("p",{role:"alert",className:"make-app-approval-error",children:H}),L&&r.jsx("p",{role:"alert",className:"make-app-approval-error",children:L}),r.jsxs("div",{className:"make-app-approval-results","aria-busy":U,children:[l==="mobile"?b&&r.jsx(Oe,{initialPage:b,query:a,provider:t,onReload:N,components:e,onOpen:n=>{G(n)},logger:p},JSON.stringify([a,S,b])):r.jsx($e,{components:e,initialPage:b,query:a,provider:t,onOpen:n=>{G(n)},onReload:N,themeKey:g,logger:p}),U&&r.jsx("div",{className:"make-app-approval-overlay",role:"status",children:"正在加载审批记录…"}),W==="error"&&r.jsxs("div",{className:"make-app-approval-overlay",role:"alert",children:[r.jsx("span",{children:"审批列表加载失败,请重试"}),r.jsx(T,{htmlType:"button",variant:"default",onClick:N,children:"重试"})]})]})]}),X=ye.useApprovalThemeState(l);return r.jsx("section",{className:["make-app-approval",l==="mobile"&&"make-app-approval--mobile",j==="standard"&&"make-app-approval--standard",w].filter(Boolean).join(" "),"aria-label":"我的审批",style:X.style,"data-make-approval-theme":X.style?X.presentation:void 0,"data-make-approval-presentation":l==="mobile"?"mobile":void 0,children:r.jsx(h,{items:k.map(n=>({value:n,label:Ce[n]})),value:a.tab,onChange:ee,ariaLabel:"审批分类",children:j==="standard"?r.jsx("div",{className:"make-app-approval-panel",children:Q}):Q})})},Ye=e=>{const t=e.pageSize??20,s=e.tabs??je;if(!s.length||new Set(s).size!==s.length||s.some(f=>!Object.hasOwn(Ce,f)))throw new Error("MyApprovalsPage requires valid unique tabs");if(!e.scopeKey.trim())throw new Error("MyApprovalsPage requires scopeKey");for(const f of["Input","Select","DateRangePicker","Button","Tabs"])if(!e.components?.[f])throw new Error(`MyApprovalsPage requires components.${f}`);if(!Number.isSafeInteger(t)||t<1||t>200)throw new Error("pageSize must be an integer from 1 to 200");return r.jsx(Ue,{...e,tabs:s,pageSize:t},JSON.stringify([e.scopeKey,t,s]))};exports.MyApprovalsPage=Ye;