@object-ui/fields 4.0.4 → 4.0.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@object-ui/fields",
3
- "version": "4.0.4",
3
+ "version": "4.0.6",
4
4
  "description": "Field renderers and registry for Object UI",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -27,12 +27,12 @@
27
27
  "clsx": "^2.1.1",
28
28
  "lucide-react": "^1.14.0",
29
29
  "tailwind-merge": "^3.5.0",
30
- "@object-ui/components": "4.0.4",
31
- "@object-ui/core": "4.0.4",
32
- "@object-ui/i18n": "4.0.4",
33
- "@object-ui/providers": "4.0.4",
34
- "@object-ui/react": "4.0.4",
35
- "@object-ui/types": "4.0.4"
30
+ "@object-ui/components": "4.0.6",
31
+ "@object-ui/core": "4.0.6",
32
+ "@object-ui/i18n": "4.0.6",
33
+ "@object-ui/providers": "4.0.6",
34
+ "@object-ui/react": "4.0.6",
35
+ "@object-ui/types": "4.0.6"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "react": "^18.0.0 || ^19.0.0",
package/src/index.tsx CHANGED
@@ -290,7 +290,7 @@ export function PercentCellRenderer({ value, field }: CellRendererProps): React.
290
290
  return (
291
291
  <div className="flex items-center gap-2">
292
292
  <div
293
- className="h-1.5 w-16 rounded-full bg-muted overflow-hidden flex-shrink-0"
293
+ className="h-1.5 w-16 rounded-full bg-muted overflow-hidden shrink-0"
294
294
  role="progressbar"
295
295
  aria-valuenow={clampedBar}
296
296
  aria-valuemin={0}
@@ -1217,7 +1217,11 @@ const fieldWidgetMap: Record<string, () => Promise<{ default: React.ComponentTyp
1217
1217
  'markdown': () => import('./widgets/RichTextField').then(m => ({ default: m.RichTextField })),
1218
1218
  'html': () => import('./widgets/RichTextField').then(m => ({ default: m.RichTextField })),
1219
1219
  'lookup': () => import('./widgets/LookupField').then(m => ({ default: m.LookupField })),
1220
- 'master_detail': () => import('./widgets/MasterDetailField').then(m => ({ default: m.MasterDetailField })),
1220
+ // master_detail represents the child-side FK to its parent. In create/edit forms it
1221
+ // must render as a single-value lookup picker (it is typically NOT NULL). The legacy
1222
+ // MasterDetailField widget modelled this as a one-to-many list, which is incorrect
1223
+ // for the child-side and prevented users from filling the required parent reference.
1224
+ 'master_detail': () => import('./widgets/LookupField').then(m => ({ default: m.LookupField })),
1221
1225
 
1222
1226
  // File fields
1223
1227
  'file': () => import('./widgets/FileField').then(m => ({ default: m.FileField })),
@@ -1317,7 +1321,9 @@ export function registerFields() {
1317
1321
  ComponentRegistry.register('markdown', createFieldRenderer(RichTextField), { namespace: 'field' });
1318
1322
  ComponentRegistry.register('html', createFieldRenderer(RichTextField), { namespace: 'field' });
1319
1323
  ComponentRegistry.register('lookup', createFieldRenderer(LookupField), { namespace: 'field' });
1320
- ComponentRegistry.register('master_detail', createFieldRenderer(MasterDetailField), { namespace: 'field' });
1324
+ // master_detail = child-side FK lookup (single value, typically required). See
1325
+ // fieldWidgetMap above for rationale.
1326
+ ComponentRegistry.register('master_detail', createFieldRenderer(LookupField), { namespace: 'field' });
1321
1327
 
1322
1328
  // File fields
1323
1329
  ComponentRegistry.register('file', createFieldRenderer(FileField), { namespace: 'field' });
@@ -266,11 +266,11 @@ export function FileField({ value, onChange, field, readonly, ...props }: FieldW
266
266
  >
267
267
  <div className="flex items-center gap-2 flex-1 min-w-0">
268
268
  {isImage(file) && file.url ? (
269
- <img src={file.url} alt={file.name} className="size-8 object-cover rounded flex-shrink-0" />
269
+ <img src={file.url} alt={file.name} className="size-8 object-cover rounded shrink-0" />
270
270
  ) : isImage(file) ? (
271
- <ImageIcon className="size-4 text-muted-foreground flex-shrink-0" />
271
+ <ImageIcon className="size-4 text-muted-foreground shrink-0" />
272
272
  ) : (
273
- <FileIcon className="size-4 text-muted-foreground flex-shrink-0" />
273
+ <FileIcon className="size-4 text-muted-foreground shrink-0" />
274
274
  )}
275
275
  <span className="text-sm truncate">
276
276
  {file.name || file.original_name || 'File'}
@@ -1 +0,0 @@
1
- const e=require(`./chunk-D-qHiVGv.cjs`);let t=require(`react`);t=e.n(t,1);let n=require(`@object-ui/components`),r=require(`lucide-react`),i=require(`react/jsx-runtime`);var a=e.t({ImageCropperDialog:()=>o}),o=({open:e,onOpenChange:a,src:o,outputType:s=`image/png`,outputName:c=`cropped.png`,onConfirm:l})=>{let u=(0,t.useRef)(null),d=(0,t.useRef)(null),[f,p]=(0,t.useState)(0),[m,h]=(0,t.useState)({x:0,y:0,width:100,height:100}),[g,_]=(0,t.useState)(null),[v,y]=(0,t.useState)(!1);(0,t.useEffect)(()=>{if(!e||!o)return;y(!1);let t=new Image;t.crossOrigin=`anonymous`,t.onload=()=>{d.current=t;let e=t.naturalWidth*.8,n=t.naturalHeight*.8;h({x:(t.naturalWidth-e)/2,y:(t.naturalHeight-n)/2,width:e,height:n}),p(0),y(!0)},t.onerror=()=>y(!1),t.src=o},[e,o]),(0,t.useEffect)(()=>{if(!v||!d.current||!u.current)return;let e=d.current,t=u.current,n=t.getContext(`2d`);if(!n)return;let r=480/e.naturalWidth,i=e.naturalHeight*r;t.width=480,t.height=i,n.clearRect(0,0,480,i),n.save(),n.translate(480/2,i/2),n.rotate(f*Math.PI/180);let a=f%180==0?480:i,o=f%180==0?i:480;n.drawImage(e,-a/2,-o/2,a,o),n.restore();let s=m.x*r,c=m.y*r,l=m.width*r,p=m.height*r;n.fillStyle=`rgba(0,0,0,0.45)`,n.fillRect(0,0,480,c),n.fillRect(0,c+p,480,i-c-p),n.fillRect(0,c,s,p),n.fillRect(s+l,c,480-s-l,p),n.strokeStyle=`#3b82f6`,n.lineWidth=2,n.strokeRect(s,c,l,p)},[v,m,f]);let b=(0,t.useCallback)(e=>{if(!d.current||!u.current)return;let t=u.current.getBoundingClientRect(),n=d.current.naturalWidth/t.width;_({ox:(e.clientX-t.left)*n,oy:(e.clientY-t.top)*n,cx:m.x,cy:m.y}),e.target.setPointerCapture(e.pointerId)},[m]),x=(0,t.useCallback)(e=>{if(!g||!d.current||!u.current)return;let t=u.current.getBoundingClientRect(),n=d.current.naturalWidth/t.width,r=(e.clientX-t.left)*n-g.ox,i=(e.clientY-t.top)*n-g.oy,a=Math.max(0,Math.min(g.cx+r,d.current.naturalWidth-m.width)),o=Math.max(0,Math.min(g.cy+i,d.current.naturalHeight-m.height));h(e=>({...e,x:a,y:o}))},[g,m.width,m.height]),S=(0,t.useCallback)(()=>_(null),[]),C=(0,t.useCallback)(()=>p(e=>(e+90)%360),[]),w=(0,t.useCallback)(async()=>{if(!d.current)return;let e=d.current,t=document.createElement(`canvas`),n=m.width,r=m.height;t.width=f%180==0?n:r,t.height=f%180==0?r:n;let i=t.getContext(`2d`);if(!i)return;i.save(),i.translate(t.width/2,t.height/2),i.rotate(f*Math.PI/180),i.drawImage(e,m.x,m.y,n,r,-n/2,-r/2,n,r),i.restore();let o=await new Promise(e=>t.toBlob(e,s));o&&(l(o,c),a(!1))},[m,f,c,s,l,a]);return(0,i.jsx)(n.Dialog,{open:e,onOpenChange:a,children:(0,i.jsxs)(n.DialogContent,{className:`max-w-xl`,children:[(0,i.jsxs)(n.DialogHeader,{children:[(0,i.jsx)(n.DialogTitle,{children:`Crop & rotate image`}),(0,i.jsx)(n.DialogDescription,{children:`Drag the highlighted box to reposition the crop. Use the rotate button to spin the image in 90° increments.`})]}),(0,i.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[v?(0,i.jsx)(`canvas`,{ref:u,"data-testid":`image-cropper-canvas`,role:`img`,"aria-label":`Image crop preview`,className:`border rounded-md cursor-move touch-none max-w-full`,onPointerDown:b,onPointerMove:x,onPointerUp:S,onPointerCancel:S}):(0,i.jsx)(`div`,{className:`flex h-[270px] w-full items-center justify-center text-sm text-muted-foreground`,children:`Loading image…`}),(0,i.jsxs)(`div`,{className:`flex w-full items-center justify-between text-xs text-muted-foreground`,children:[(0,i.jsxs)(`span`,{children:[`Crop: `,Math.round(m.width),` × `,Math.round(m.height),` px`]}),(0,i.jsxs)(`span`,{children:[`Rotation: `,f,`°`]})]})]}),(0,i.jsxs)(n.DialogFooter,{className:`flex justify-between sm:justify-between`,children:[(0,i.jsxs)(n.Button,{type:`button`,variant:`outline`,onClick:C,"data-testid":`image-cropper-rotate`,children:[(0,i.jsx)(r.RotateCw,{className:`size-4 mr-2`}),`Rotate 90°`]}),(0,i.jsxs)(`div`,{className:`flex gap-2`,children:[(0,i.jsx)(n.Button,{type:`button`,variant:`ghost`,onClick:()=>a(!1),children:`Cancel`}),(0,i.jsxs)(n.Button,{type:`button`,onClick:w,disabled:!v,"data-testid":`image-cropper-confirm`,children:[(0,i.jsx)(r.Crop,{className:`size-4 mr-2`}),`Apply crop`]})]})]})]})})};Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return o}});
@@ -1,147 +0,0 @@
1
- import { t as e } from "./rolldown-runtime-CAFD8bLK.js";
2
- import { useCallback as t, useEffect as n, useRef as r, useState as i } from "react";
3
- import { Button as a, Dialog as o, DialogContent as s, DialogDescription as c, DialogFooter as l, DialogHeader as u, DialogTitle as d } from "@object-ui/components";
4
- import { Crop as f, RotateCw as p } from "lucide-react";
5
- import { jsx as m, jsxs as h } from "react/jsx-runtime";
6
- //#region src/widgets/ImageCropperDialog.tsx
7
- var g = /* @__PURE__ */ e({ ImageCropperDialog: () => _ }), _ = ({ open: e, onOpenChange: g, src: _, outputType: v = "image/png", outputName: y = "cropped.png", onConfirm: b }) => {
8
- let x = r(null), S = r(null), [C, w] = i(0), [T, E] = i({
9
- x: 0,
10
- y: 0,
11
- width: 100,
12
- height: 100
13
- }), [D, O] = i(null), [k, A] = i(!1);
14
- n(() => {
15
- if (!e || !_) return;
16
- A(!1);
17
- let t = new Image();
18
- t.crossOrigin = "anonymous", t.onload = () => {
19
- S.current = t;
20
- let e = t.naturalWidth * .8, n = t.naturalHeight * .8;
21
- E({
22
- x: (t.naturalWidth - e) / 2,
23
- y: (t.naturalHeight - n) / 2,
24
- width: e,
25
- height: n
26
- }), w(0), A(!0);
27
- }, t.onerror = () => A(!1), t.src = _;
28
- }, [e, _]), n(() => {
29
- if (!k || !S.current || !x.current) return;
30
- let e = S.current, t = x.current, n = t.getContext("2d");
31
- if (!n) return;
32
- let r = 480 / e.naturalWidth, i = e.naturalHeight * r;
33
- t.width = 480, t.height = i, n.clearRect(0, 0, 480, i), n.save(), n.translate(480 / 2, i / 2), n.rotate(C * Math.PI / 180);
34
- let a = C % 180 == 0 ? 480 : i, o = C % 180 == 0 ? i : 480;
35
- n.drawImage(e, -a / 2, -o / 2, a, o), n.restore();
36
- let s = T.x * r, c = T.y * r, l = T.width * r, u = T.height * r;
37
- n.fillStyle = "rgba(0,0,0,0.45)", n.fillRect(0, 0, 480, c), n.fillRect(0, c + u, 480, i - c - u), n.fillRect(0, c, s, u), n.fillRect(s + l, c, 480 - s - l, u), n.strokeStyle = "#3b82f6", n.lineWidth = 2, n.strokeRect(s, c, l, u);
38
- }, [
39
- k,
40
- T,
41
- C
42
- ]);
43
- let j = t((e) => {
44
- if (!S.current || !x.current) return;
45
- let t = x.current.getBoundingClientRect(), n = S.current.naturalWidth / t.width;
46
- O({
47
- ox: (e.clientX - t.left) * n,
48
- oy: (e.clientY - t.top) * n,
49
- cx: T.x,
50
- cy: T.y
51
- }), e.target.setPointerCapture(e.pointerId);
52
- }, [T]), M = t((e) => {
53
- if (!D || !S.current || !x.current) return;
54
- let t = x.current.getBoundingClientRect(), n = S.current.naturalWidth / t.width, r = (e.clientX - t.left) * n - D.ox, i = (e.clientY - t.top) * n - D.oy, a = Math.max(0, Math.min(D.cx + r, S.current.naturalWidth - T.width)), o = Math.max(0, Math.min(D.cy + i, S.current.naturalHeight - T.height));
55
- E((e) => ({
56
- ...e,
57
- x: a,
58
- y: o
59
- }));
60
- }, [
61
- D,
62
- T.width,
63
- T.height
64
- ]), N = t(() => O(null), []), P = t(() => w((e) => (e + 90) % 360), []), F = t(async () => {
65
- if (!S.current) return;
66
- let e = S.current, t = document.createElement("canvas"), n = T.width, r = T.height;
67
- t.width = C % 180 == 0 ? n : r, t.height = C % 180 == 0 ? r : n;
68
- let i = t.getContext("2d");
69
- if (!i) return;
70
- i.save(), i.translate(t.width / 2, t.height / 2), i.rotate(C * Math.PI / 180), i.drawImage(e, T.x, T.y, n, r, -n / 2, -r / 2, n, r), i.restore();
71
- let a = await new Promise((e) => t.toBlob(e, v));
72
- a && (b(a, y), g(!1));
73
- }, [
74
- T,
75
- C,
76
- y,
77
- v,
78
- b,
79
- g
80
- ]);
81
- return /* @__PURE__ */ m(o, {
82
- open: e,
83
- onOpenChange: g,
84
- children: /* @__PURE__ */ h(s, {
85
- className: "max-w-xl",
86
- children: [
87
- /* @__PURE__ */ h(u, { children: [/* @__PURE__ */ m(d, { children: "Crop & rotate image" }), /* @__PURE__ */ m(c, { children: "Drag the highlighted box to reposition the crop. Use the rotate button to spin the image in 90° increments." })] }),
88
- /* @__PURE__ */ h("div", {
89
- className: "flex flex-col items-center gap-3",
90
- children: [k ? /* @__PURE__ */ m("canvas", {
91
- ref: x,
92
- "data-testid": "image-cropper-canvas",
93
- role: "img",
94
- "aria-label": "Image crop preview",
95
- className: "border rounded-md cursor-move touch-none max-w-full",
96
- onPointerDown: j,
97
- onPointerMove: M,
98
- onPointerUp: N,
99
- onPointerCancel: N
100
- }) : /* @__PURE__ */ m("div", {
101
- className: "flex h-[270px] w-full items-center justify-center text-sm text-muted-foreground",
102
- children: "Loading image…"
103
- }), /* @__PURE__ */ h("div", {
104
- className: "flex w-full items-center justify-between text-xs text-muted-foreground",
105
- children: [/* @__PURE__ */ h("span", { children: [
106
- "Crop: ",
107
- Math.round(T.width),
108
- " × ",
109
- Math.round(T.height),
110
- " px"
111
- ] }), /* @__PURE__ */ h("span", { children: [
112
- "Rotation: ",
113
- C,
114
- "°"
115
- ] })]
116
- })]
117
- }),
118
- /* @__PURE__ */ h(l, {
119
- className: "flex justify-between sm:justify-between",
120
- children: [/* @__PURE__ */ h(a, {
121
- type: "button",
122
- variant: "outline",
123
- onClick: P,
124
- "data-testid": "image-cropper-rotate",
125
- children: [/* @__PURE__ */ m(p, { className: "size-4 mr-2" }), "Rotate 90°"]
126
- }), /* @__PURE__ */ h("div", {
127
- className: "flex gap-2",
128
- children: [/* @__PURE__ */ m(a, {
129
- type: "button",
130
- variant: "ghost",
131
- onClick: () => g(!1),
132
- children: "Cancel"
133
- }), /* @__PURE__ */ h(a, {
134
- type: "button",
135
- onClick: F,
136
- disabled: !k,
137
- "data-testid": "image-cropper-confirm",
138
- children: [/* @__PURE__ */ m(f, { className: "size-4 mr-2" }), "Apply crop"]
139
- })]
140
- })]
141
- })
142
- ]
143
- })
144
- });
145
- };
146
- //#endregion
147
- export { g as n, _ as t };
@@ -1 +0,0 @@
1
- const e=require(`./chunk-D-qHiVGv.cjs`),t=require(`./useFieldTranslation-BYPwtuNZ.cjs`);let n=require(`react`);n=e.n(n,1);let r=require(`@object-ui/components`),i=require(`lucide-react`),a=require(`react/jsx-runtime`),o=require(`@object-ui/react`);var ee=10,te=60,s=5;function c(e){return typeof e==`string`?{field:e}:e}function l(e){return e.replace(/_/g,` `).replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/\b\w/g,e=>e.toUpperCase())}function u(e){let t={};for(let n of e)switch(n.operator){case`eq`:t[n.field]=n.value;break;case`ne`:t[n.field]={$ne:n.value};break;case`gt`:t[n.field]={$gt:n.value};break;case`lt`:t[n.field]={$lt:n.value};break;case`gte`:t[n.field]={$gte:n.value};break;case`lte`:t[n.field]={$lte:n.value};break;case`contains`:t[n.field]={$contains:n.value};break;case`in`:t[n.field]={$in:n.value};break;case`notIn`:t[n.field]={$nin:n.value};break}return t}function ne(e,t){let n={};for(let r of t){let t=e[r.field];t==null||t===``||(r.type===`boolean`?n[r.field]=!!t:r.type===`text`?n[r.field]={$contains:t}:n[r.field]=t)}return n}function d({open:e,onOpenChange:t,title:o=`Select Record`,multiple:d=!1,dataSource:f,objectName:p,columns:re,displayField:m=`name`,idField:ie=`id`,pageSize:h=ee,value:g,onSelect:ae,onSelectRecords:_,lookupFilters:v,cellRenderer:y,filterColumns:b,renderFilterBar:x,renderGrid:oe}){let[S,se]=(0,n.useState)([]),[C,w]=(0,n.useState)(!1),[T,E]=(0,n.useState)(null),[D,O]=(0,n.useState)(0),[k,ce]=(0,n.useState)(``),[A,j]=(0,n.useState)(1),M=(0,n.useRef)(null),[N,P]=(0,n.useState)(null),[F,le]=(0,n.useState)(`asc`),[I,L]=(0,n.useState)(new Set),R=(0,n.useRef)(new Map),[z,B]=(0,n.useState)(-1),ue=(0,n.useRef)(null),[V,H]=(0,n.useState)(!1),[U,W]=(0,n.useState)({}),[G,de]=(0,n.useState)({}),K=(0,n.useRef)(null),[q,J]=(0,n.useState)(``),Y=(0,n.useMemo)(()=>re&&re.length>0?re.map(c):[{field:m,label:l(m)}],[re,m]),X=(0,n.useMemo)(()=>{if(b&&b.length>0)return b;if(v&&v.length>0)return v.map(e=>{let t=`text`;return typeof e.value==`boolean`?t=`boolean`:Array.isArray(e.value)?t=`select`:typeof e.value==`number`||e.operator===`gt`||e.operator===`lt`||e.operator===`gte`||e.operator===`lte`?t=`number`:(e.operator===`in`||e.operator===`notIn`)&&(t=`select`),{field:e.field,label:l(e.field),type:t,...Array.isArray(e.value)?{options:e.value.map(e=>{if(typeof e==`object`&&e){let t=e;return{label:String(t.name||t.label||t.title||e),value:e}}return{label:String(e),value:e}})}:{}}})},[b,v]),fe=(0,n.useMemo)(()=>{let e=v?.length?u(v):{},t=X?.length?ne(U,X):{},n={...e,...t};return Object.keys(n).length>0?n:void 0},[v,X,U]),Z=Math.max(1,Math.ceil(D/h)),Q=(0,n.useCallback)(async(e,t=1,n,r)=>{if(!(!f||!p)){w(!0),E(null);try{let i={$top:h,$skip:(t-1)*h};e&&e.trim()&&(i.$search=e.trim()),n&&(i.$orderby={[n.field]:n.direction});let a=r===void 0?fe:r;a&&Object.keys(a).length>0&&(i.$filter=a);let o=await f.find(p,i),ee=o?.data??o??[];se(ee),O(o?.total??ee.length),B(-1)}catch(e){E(e instanceof Error?e.message:String(e)),se([])}finally{w(!1)}}},[f,p,h,fe]),pe=(0,n.useMemo)(()=>N?{field:N,direction:F}:null,[N,F]);(0,n.useEffect)(()=>{e||(ce(``),j(1),E(null),se([]),P(null),le(`asc`),B(-1),H(!1),W({}),de({}),J(``),L(new Set(d&&Array.isArray(g)?g:[])),R.current.clear())},[e]),(0,n.useEffect)(()=>{e&&Q(k||void 0,A,pe)},[e,A,pe,fe]),(0,n.useEffect)(()=>{e&&d&&L(new Set(Array.isArray(g)?g:[]))},[e,d,g]);let me=(0,n.useCallback)(e=>{ce(e),j(1),M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{Q(e||void 0,1,pe)},300)},[Q,pe]);(0,n.useEffect)(()=>()=>{M.current&&clearTimeout(M.current)},[]);let he=(0,n.useCallback)(e=>{P(t=>t===e?(le(e=>e===`asc`?`desc`:`asc`),e):(le(`asc`),e)),j(1)},[]),ge=(0,n.useCallback)(e=>e[ie]??e.id??e._id,[ie]),_e=(0,n.useCallback)(e=>{let t=ge(e);return d?I.has(t):g===t},[d,g,I,ge]),ve=(0,n.useCallback)(e=>{let n=ge(e);d?L(t=>{let r=new Set(t);return r.has(n)?(r.delete(n),R.current.delete(n)):(r.add(n),R.current.set(n,e)),r}):(ae(n),_?.([e]),t(!1))},[d,ge,ae,_,t]),ye=(0,n.useCallback)(()=>{let e=Array.from(I);ae(e);let n=e.map(e=>R.current.get(e)).filter(Boolean);_?.(n),t(!1)},[I,ae,_,t]),be=(0,n.useCallback)(()=>{j(e=>Math.max(1,e-1))},[]),xe=(0,n.useCallback)(()=>{j(e=>Math.min(Z,e+1))},[Z]),Se=(0,n.useCallback)(e=>{if(e.key!==`Enter`)return;let t=parseInt(q,10);!isNaN(t)&&t>=1&&t<=Z&&j(t),J(``)},[q,Z]),Ce=(0,n.useCallback)(e=>{S.length!==0&&(e.key===`ArrowDown`?(e.preventDefault(),B(e=>Math.min(e+1,S.length-1))):e.key===`ArrowUp`?(e.preventDefault(),B(e=>Math.max(e-1,0))):(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),z>=0&&z<S.length&&ve(S[z])))},[S,z,ve]);(0,n.useEffect)(()=>{if(z>=0&&ue.current){let e=ue.current.querySelector(`[data-row-index="${z}"]`);e&&typeof e.scrollIntoView==`function`&&e.scrollIntoView({block:`nearest`})}},[z]);let we=(0,n.useCallback)((e,t)=>{let n=e[t.field];if(t.type&&y){let e=y(t.type);if(e)return(0,a.jsx)(e,{value:n,field:{name:t.field,type:t.type}})}return n==null?``:typeof n==`object`?n.$numberDecimal?String(Number(n.$numberDecimal)):n.$oid?String(n.$oid):n.$date?new Date(n.$date).toLocaleDateString():n.name||n.label?String(n.name||n.label):JSON.stringify(n):typeof n==`boolean`?n?`Yes`:`No`:String(n)},[y]),Te=(0,n.useCallback)(e=>N===e?F===`asc`?(0,a.jsx)(i.ArrowUp,{className:`ml-1 size-3`}):(0,a.jsx)(i.ArrowDown,{className:`ml-1 size-3`}):(0,a.jsx)(i.ArrowUpDown,{className:`ml-1 size-3 opacity-40`}),[N,F]),Ee=(0,n.useCallback)((e,t,n)=>{e.preventDefault(),e.stopPropagation(),K.current={field:t,startX:e.clientX,startWidth:n};let r=e=>{if(!K.current)return;let t=e.clientX-K.current.startX,n=Math.max(te,K.current.startWidth+t);de(e=>({...e,[K.current.field]:n}))},i=()=>{K.current=null,document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i)};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i)},[]),$=(0,n.useCallback)((e,t)=>{W(n=>({...n,[e]:t})),j(1)},[]),De=(0,n.useCallback)(()=>{W({}),j(1)},[]),Oe=(0,n.useMemo)(()=>Object.values(U).filter(e=>e!=null&&e!==``).length,[U]),ke=(0,n.useCallback)(e=>{let t=U[e.field],n=e.label||l(e.field);switch(e.type){case`select`:return(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsx)(r.Label,{className:`text-xs text-muted-foreground`,children:n}),(0,a.jsxs)(r.Select,{value:t==null?``:String(t),onValueChange:t=>$(e.field,t),children:[(0,a.jsx)(r.SelectTrigger,{className:`h-8 text-xs`,children:(0,a.jsx)(r.SelectValue,{placeholder:`Filter ${n}`})}),(0,a.jsx)(r.SelectContent,{children:e.options?.map(e=>(0,a.jsx)(r.SelectItem,{value:String(e.value),children:e.label},String(e.value)))})]})]});case`number`:return(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsx)(r.Label,{className:`text-xs text-muted-foreground`,children:n}),(0,a.jsx)(r.Input,{type:`number`,className:`h-8 text-xs`,value:t??``,placeholder:`Filter ${n}`,onChange:t=>{let n=t.target.value;$(e.field,n===``?``:Number(n))}})]});case`date`:return(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsx)(r.Label,{className:`text-xs text-muted-foreground`,children:n}),(0,a.jsx)(r.Input,{type:`date`,className:`h-8 text-xs`,value:t??``,onChange:t=>$(e.field,t.target.value)})]});case`boolean`:return(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsx)(r.Label,{className:`text-xs text-muted-foreground`,children:n}),(0,a.jsxs)(`div`,{className:`flex items-center gap-2 h-8`,children:[(0,a.jsx)(r.Checkbox,{checked:!!t,onCheckedChange:t=>$(e.field,!!t)}),(0,a.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Yes`})]})]});default:return(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsx)(r.Label,{className:`text-xs text-muted-foreground`,children:n}),(0,a.jsx)(r.Input,{className:`h-8 text-xs`,value:t??``,placeholder:`Filter ${n}`,onChange:t=>$(e.field,t.target.value)})]})}},[U,$]),Ae=(0,n.useCallback)((e,t)=>e?`bg-primary/5 hover:bg-primary/10`:t%2==1?`bg-muted/20 hover:bg-accent/30`:`hover:bg-accent/30`,[]);return(0,a.jsx)(r.Dialog,{open:e,onOpenChange:t,children:(0,a.jsxs)(r.DialogContent,{className:`w-[95vw] sm:max-w-3xl lg:max-w-5xl max-h-[85vh] sm:max-h-[80vh] flex flex-col gap-0`,"data-testid":`record-picker-dialog`,children:[(0,a.jsx)(r.DialogHeader,{children:(0,a.jsxs)(r.DialogTitle,{children:[o,d&&(0,a.jsx)(`span`,{className:`sr-only`,children:` (multiple selection)`})]})}),(0,a.jsxs)(`div`,{className:`relative rounded-md border bg-muted/30 mb-3`,children:[(0,a.jsx)(i.Search,{className:`absolute left-3 top-1/2 -translate-y-1/2 size-4 text-muted-foreground`}),(0,a.jsx)(r.Input,{placeholder:`Search...`,value:k,onChange:e=>me(e.target.value),className:`pl-9 border-0 bg-transparent shadow-none focus-visible:ring-0`,"data-testid":`record-picker-search`}),C&&(0,a.jsx)(i.Loader2,{className:`absolute right-3 top-1/2 -translate-y-1/2 size-4 animate-spin text-muted-foreground`,"data-testid":`record-picker-loading-indicator`})]}),X&&X.length>0&&(0,a.jsx)(`div`,{className:`py-2`,children:x?(0,a.jsx)(`div`,{"data-testid":`record-picker-filter-bar`,children:x({filterColumns:X,values:U,onChange:$,onClear:De,activeCount:Oe})}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-2`,"data-testid":`record-picker-filter-bar`,children:[(0,a.jsxs)(r.Button,{type:`button`,variant:Oe>0?`secondary`:`outline`,size:`sm`,className:`gap-1.5 shrink-0`,onClick:()=>H(e=>!e),children:[(0,a.jsx)(i.SlidersHorizontal,{className:`size-3.5`}),`Filters`,Oe>0&&(0,a.jsx)(`span`,{className:`inline-flex h-5 min-w-[20px] items-center justify-center rounded-full bg-primary/10 px-1 text-xs font-medium text-primary`,children:Oe})]}),Oe>0&&(0,a.jsxs)(r.Button,{type:`button`,variant:`ghost`,size:`sm`,className:`gap-1 text-xs`,onClick:De,children:[(0,a.jsx)(i.X,{className:`size-3`}),`Clear`]})]}),V&&(0,a.jsx)(`div`,{className:`mt-2 grid gap-3 sm:grid-cols-2 lg:grid-cols-3 border rounded-md p-3 bg-muted/30`,"data-testid":`record-picker-filter-panel`,children:X.map(e=>(0,a.jsx)(`div`,{children:ke(e)},e.field))})]})}),T&&(0,a.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-4`,role:`alert`,children:[(0,a.jsx)(i.AlertCircle,{className:`size-5 text-destructive`}),(0,a.jsx)(`p`,{className:`text-sm text-destructive`,children:T}),(0,a.jsx)(r.Button,{variant:`outline`,size:`sm`,onClick:()=>Q(k||void 0,A,pe),type:`button`,children:`Retry`})]}),oe?(0,a.jsx)(`div`,{className:`flex-1 min-h-0`,"data-testid":`record-picker-grid-slot`,children:oe({columns:Y,records:S,loading:C,totalCount:D,currentPage:A,pageSize:h,sortField:N,sortDirection:F,onSort:he,onPageChange:j,onRowClick:ve,isSelected:_e,multiple:d,idField:ie,cellRenderer:y})}):(0,a.jsxs)(a.Fragment,{children:[C&&S.length===0&&!T&&(0,a.jsx)(`div`,{className:`flex-1 overflow-hidden min-h-0 border rounded-md`,role:`status`,"aria-live":`polite`,"data-testid":`record-picker-skeleton`,children:(0,a.jsxs)(r.Table,{children:[(0,a.jsx)(r.TableHeader,{children:(0,a.jsxs)(r.TableRow,{className:`bg-muted/40`,children:[d&&(0,a.jsx)(r.TableHead,{className:`w-10`}),Y.map(e=>(0,a.jsx)(r.TableHead,{children:(0,a.jsx)(r.Skeleton,{className:`h-4 w-20`})},e.field))]})}),(0,a.jsx)(r.TableBody,{children:Array.from({length:s},(e,t)=>(0,a.jsxs)(r.TableRow,{children:[d&&(0,a.jsx)(r.TableCell,{className:`w-10`,children:(0,a.jsx)(r.Skeleton,{className:`size-4 rounded`})}),Y.map(e=>(0,a.jsx)(r.TableCell,{children:(0,a.jsx)(r.Skeleton,{className:`h-4 w-full`})},e.field))]},t))})]})}),!C&&!T&&S.length===0&&(0,a.jsx)(`div`,{className:`py-8 text-center`,children:(0,a.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No records found`})}),!T&&S.length>0&&(0,a.jsxs)(`div`,{className:`relative flex-1 overflow-auto min-h-0 border rounded-md`,tabIndex:0,onKeyDown:Ce,role:`grid`,"aria-label":`Records`,children:[C&&(0,a.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-background/60`,"data-testid":`record-picker-loading-overlay`,children:(0,a.jsx)(i.Loader2,{className:`size-6 animate-spin text-muted-foreground`})}),(0,a.jsxs)(r.Table,{style:Object.keys(G).length>0?{tableLayout:`fixed`}:void 0,children:[(0,a.jsx)(r.TableHeader,{className:`sticky top-0 z-[5] bg-muted/50 [&_tr]:border-b`,"data-testid":`record-picker-sticky-header`,children:(0,a.jsxs)(r.TableRow,{children:[d&&(0,a.jsx)(r.TableHead,{className:`w-10`}),Y.map(e=>{let t=G[e.field];return(0,a.jsxs)(r.TableHead,{style:t?{width:`${t}px`,minWidth:`${t}px`}:e.width?{width:e.width}:void 0,className:`cursor-pointer select-none relative group text-xs font-semibold uppercase tracking-wider`,onClick:()=>he(e.field),"aria-sort":N===e.field?F===`asc`?`ascending`:`descending`:`none`,children:[(0,a.jsxs)(`span`,{className:`inline-flex items-center`,children:[e.label||l(e.field),Te(e.field)]}),(0,a.jsx)(`span`,{role:`separator`,"aria-orientation":`vertical`,className:`absolute right-0 top-0 bottom-0 w-1 cursor-col-resize opacity-0 group-hover:opacity-100 bg-border hover:bg-primary/50 transition-opacity`,onMouseDown:t=>{let n=t.currentTarget.parentElement?.getBoundingClientRect();Ee(t,e.field,n?.width??100)},onClick:e=>e.stopPropagation(),"data-testid":`resize-handle-${e.field}`})]},e.field)})]})}),(0,a.jsx)(r.TableBody,{ref:ue,children:S.map((e,t)=>{let n=ge(e),o=_e(e),ee=t===z;return(0,a.jsxs)(r.TableRow,{"data-row-index":t,className:(0,r.cn)(`cursor-pointer transition-colors`,Ae(o,t),ee&&`ring-2 ring-primary ring-inset`),onClick:()=>ve(e),"data-testid":`record-row-${n}`,"aria-selected":o,children:[d&&(0,a.jsx)(r.TableCell,{className:`w-10`,children:o&&(0,a.jsx)(i.Check,{className:`size-4 text-primary`})}),Y.map(t=>(0,a.jsx)(r.TableCell,{className:`py-2.5`,children:we(e,t)},t.field))]},n??t)})})]})]}),!T&&D>0&&(0,a.jsxs)(`div`,{className:`flex items-center justify-between text-sm text-muted-foreground border-t pt-3 mt-2 px-1`,"data-testid":`record-picker-pagination`,children:[(0,a.jsxs)(`span`,{children:[D,` `,D===1?`record`:`records`,Z>1&&` · Page ${A} of ${Z}`]}),Z>1&&(0,a.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,a.jsx)(r.Button,{variant:`outline`,size:`icon`,className:`size-7`,onClick:be,disabled:A<=1,type:`button`,"aria-label":`Previous page`,children:(0,a.jsx)(i.ChevronLeft,{className:`size-4`})}),(0,a.jsx)(r.Input,{className:`h-7 w-12 text-center text-xs px-1`,placeholder:String(A),value:q,onChange:e=>J(e.target.value),onKeyDown:Se,"aria-label":`Jump to page`,"data-testid":`record-picker-page-jump`}),(0,a.jsx)(r.Button,{variant:`outline`,size:`icon`,className:`size-7`,onClick:xe,disabled:A>=Z,type:`button`,"aria-label":`Next page`,children:(0,a.jsx)(i.ChevronRight,{className:`size-4`})})]})]})]}),d&&(0,a.jsx)(r.DialogFooter,{children:(0,a.jsxs)(`div`,{className:`flex items-center gap-2 w-full justify-between`,children:[(0,a.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[I.size,` selected`]}),(0,a.jsxs)(`div`,{className:`flex gap-2`,children:[(0,a.jsx)(r.Button,{variant:`outline`,type:`button`,onClick:()=>t(!1),children:`Cancel`}),(0,a.jsx)(r.Button,{type:`button`,onClick:ye,children:`Confirm`})]})]})})]})})}var f;function p(e){f=e}function re(){return f}var m=e.t({LookupField:()=>_}),ie=50,h=o.SchemaRendererContext;function g(e,t,n,r){let i=e[n]??e.id??e._id,a=e[t]??e.label??e.name??String(i),o=r?e[r]:void 0;return{value:i,label:String(a),description:o,...e}}function ae(e){return{text:`text`,number:`number`,currency:`number`,percent:`number`,select:`select`,status:`select`,date:`date`,datetime:`date`,boolean:`boolean`}[e]}function _({value:e,onChange:o,field:ee,readonly:te,...s}){let[c,l]=(0,n.useState)(!1),[u,ne]=(0,n.useState)(``),{t:f}=t.t(),[p,m]=(0,n.useState)([]),[_,v]=(0,n.useState)(!1),[y,b]=(0,n.useState)(null),[x,oe]=(0,n.useState)(0),S=(0,n.useRef)(null),[se,C]=(0,n.useState)([]),[w,T]=(0,n.useState)(-1),E=(0,n.useRef)(null),D=ee||s.schema,O=D?.field,k=O&&typeof O==`object`&&(`reference_to`in O||`reference`in O||`type`in O)?O:D,ce=k?.options||[],A=k?.multiple||!1,j=k?.display_field||k?.reference_field||`name`,M=k?.description_field,N=k?.id_field||`id`,P=k?.reference_to||k?.reference,F=k?.lookup_columns,le=k?.lookup_page_size,I=k?.lookup_filters,L=(0,n.useMemo)(()=>{let e=k?.depends_on??k?.dependsOn;return e&&Array.isArray(e)?e.map(e=>typeof e==`string`?{field:e,param:e}:{field:e.field,param:e.param??e.field}):[]},[k?.depends_on,k?.dependsOn]),R=s.dependentValues,z=(0,n.useMemo)(()=>{if(!F)return;let e=[];for(let t of F)if(typeof t==`object`&&t.type){let n=ae(t.type);n&&e.push({field:t.field,label:t.label,type:n})}return e.length>0?e:void 0},[F]),B=(0,n.useContext)(h),ue=B?.dataSource??null,V=s.dataSource??D?.dataSource??k?.dataSource??ue,H=(0,n.useMemo)(()=>R||(B?.formValues??B?.data??{}),[R,B?.formValues,B?.data]),U=(0,n.useMemo)(()=>L.length===0?!1:L.some(({field:e})=>{let t=H[e];return t==null||t===``||Array.isArray(t)&&t.length===0}),[L,H]),W=V!=null&&typeof V.find==`function`&&!!P,G=s.onCreateNew??D?.onCreateNew,[de,K]=(0,n.useState)(!1),q=W?p:ce,J=(0,n.useMemo)(()=>{if(W||!u)return q;let e=u.toLowerCase();return q.filter(t=>t.label.toLowerCase().includes(e)||t.description&&t.description.toLowerCase().includes(e))},[W,q,u]);(0,n.useEffect)(()=>{T(-1)},[J.length]);let Y=(0,n.useCallback)(async e=>{if(!(!V||!P)){if(U){m([]),oe(0);return}v(!0),b(null);try{let t={$top:ie};if(e&&e.trim()&&(t.$search=e.trim()),L.length>0){let e={};for(let{field:t,param:n}of L){let r=H[t];r==null||r===``||(e[n]=typeof r==`number`?r:String(r))}Object.keys(e).length>0&&(t.$filter=e)}let n=await V.find(P,t),r=n?.data??n??[];m(r.map(e=>g(e,j,N,M))),oe(n?.total??r.length)}catch(e){b(e instanceof Error?e.message:String(e)),m([])}finally{v(!1)}}},[V,P,j,N,M,U,L,H]);(0,n.useEffect)(()=>{c&&W&&L.length>0&&Y(u||void 0)},[(0,n.useMemo)(()=>L.map(e=>`${e.param}=${H[e.field]??``}`).join(`|`),[L,H])]),(0,n.useEffect)(()=>{c&&W&&Y(u||void 0),c||(ne(``),b(null),T(-1))},[c]);let X=(0,n.useCallback)(e=>{ne(e),W&&(S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{Y(e||void 0)},300))},[W,Y]);(0,n.useEffect)(()=>()=>{S.current&&clearTimeout(S.current)},[]);let fe=(0,n.useCallback)(e=>ce.find(t=>t.value===e)??p.find(t=>t.value===e)??se.find(t=>t.value===e),[ce,p,se]),Z=A?(Array.isArray(e)?e:[]).map(fe).filter(Boolean):e?[fe(e)].filter(Boolean):[],Q=(0,n.useCallback)(t=>{if(A){let n=Array.isArray(e)?e:[];n.includes(t.value)?o(n.filter(e=>e!==t.value)):o([...n,t.value])}else o(t.value),l(!1)},[A,e,o]),pe=t=>{o(A?(Array.isArray(e)?e:[]).filter(e=>e!==t):null)},me=(0,n.useCallback)(e=>{C(e.map(e=>g(e,j,N,M)))},[j,N,M]),he=(0,n.useCallback)(e=>{e.key===`ArrowDown`?(e.preventDefault(),T(e=>e<J.length-1?e+1:e)):e.key===`ArrowUp`?(e.preventDefault(),T(e=>e>0?e-1:0)):e.key===`Enter`&&(e.preventDefault(),w>=0&&w<J.length&&Q(J[w]))},[J,w,Q]);return(0,n.useEffect)(()=>{w>=0&&E.current&&E.current.querySelector(`[data-lookup-index="${w}"]`)?.scrollIntoView({block:`nearest`})},[w]),te?Z.length?A?(0,a.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Z.map((e,t)=>(0,a.jsx)(r.Badge,{variant:`outline`,children:e?.[j]||e?.label},t))}):(0,a.jsx)(`span`,{className:`text-sm`,children:Z[0]?.[j]||Z[0]?.label}):(0,a.jsx)(r.EmptyValue,{}):(0,a.jsxs)(`div`,{className:`space-y-2`,children:[Z.length>0&&(0,a.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Z.map((e,t)=>(0,a.jsxs)(r.Badge,{variant:`outline`,className:`gap-1`,children:[e?.[j]||e?.label,(0,a.jsx)(`button`,{onClick:()=>pe(e?.value),className:`ml-1 hover:text-destructive`,type:`button`,"aria-label":`Remove ${e?.[j]||e?.label}`,children:(0,a.jsx)(i.X,{className:`size-3`})})]},t))}),(0,a.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,a.jsxs)(r.Popover,{open:c,onOpenChange:e=>!U&&l(e),children:[(0,a.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,a.jsxs)(r.Button,{variant:`outline`,className:`min-w-0 flex-1 justify-start text-left font-normal`,type:`button`,disabled:U||s.disabled,"data-testid":U?`lookup-trigger-gated`:void 0,title:U?`Select ${L.map(e=>e.field).join(`, `)} first`:void 0,children:[(0,a.jsx)(i.Search,{className:`mr-2 size-4`}),U?`Select ${L.map(e=>e.field).join(`, `)} first`:Z.length===0?D?.placeholder||f(`common.select`):A?f(`table.selected`,{count:Z.length}):f(`common.select`)]})}),(0,a.jsxs)(r.PopoverContent,{className:`w-[var(--radix-popover-trigger-width)] p-0`,align:`start`,children:[(0,a.jsx)(`div`,{className:`p-2`,children:(0,a.jsxs)(`div`,{className:`relative`,children:[(0,a.jsx)(i.Search,{className:`absolute left-3 top-1/2 -translate-y-1/2 size-4 text-muted-foreground`}),(0,a.jsx)(r.Input,{placeholder:f(`common.search`)+`...`,value:u,onChange:e=>X(e.target.value),onKeyDown:he,className:`w-full pl-9 h-8 text-sm`}),_&&(0,a.jsx)(i.Loader2,{className:`absolute right-3 top-1/2 -translate-y-1/2 size-4 animate-spin text-muted-foreground`,"data-testid":`lookup-loading`})]})}),y&&(0,a.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-4 px-2`,role:`alert`,children:[(0,a.jsx)(i.AlertCircle,{className:`size-5 text-destructive`}),(0,a.jsx)(`p`,{className:`text-sm text-destructive`,children:y}),(0,a.jsx)(r.Button,{variant:`outline`,size:`sm`,onClick:()=>Y(u||void 0),type:`button`,children:`Retry`})]}),_&&J.length===0&&!y&&(0,a.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-6`,role:`status`,"aria-live":`polite`,children:[(0,a.jsx)(i.Loader2,{className:`size-6 animate-spin text-muted-foreground`}),(0,a.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading…`})]}),!y&&!(_&&J.length===0)&&(0,a.jsx)(`div`,{ref:E,className:`max-h-64 overflow-y-auto px-1 pb-1`,role:`listbox`,children:J.length===0?(0,a.jsxs)(`div`,{className:`py-4 text-center`,children:[(0,a.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No options found`}),G&&(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:`mt-2 gap-1`,type:`button`,onClick:()=>{G(u),l(!1)},children:[(0,a.jsx)(i.Plus,{className:`size-4`}),`Create new`]})]}):(0,a.jsxs)(a.Fragment,{children:[J.map((t,n)=>{let i=A?(Array.isArray(e)?e:[]).includes(t.value):e===t.value;return(0,a.jsxs)(`button`,{"data-lookup-index":n,role:`option`,"aria-selected":i,onClick:()=>Q(t),className:`w-full text-left px-3 py-2 rounded-md text-sm hover:bg-accent flex items-center justify-between ${n===w?`bg-accent text-accent-foreground`:i?`bg-accent/50 text-accent-foreground`:``}`,type:`button`,children:[(0,a.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,a.jsx)(`span`,{className:`block truncate`,children:t.label}),t.description&&(0,a.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:t.description})]}),i&&(0,a.jsx)(r.Badge,{variant:`default`,className:`ml-2 shrink-0`,children:`Selected`})]},t.value)}),W&&x>J.length&&(0,a.jsxs)(`p`,{className:`text-xs text-muted-foreground text-center py-2`,children:[`Showing `,J.length,` of `,x,` results.`]}),W&&x>J.length&&(0,a.jsxs)(`button`,{type:`button`,className:`w-full text-center px-3 py-2 rounded-md text-sm font-medium text-primary hover:bg-accent flex items-center justify-center gap-1.5`,onClick:()=>{l(!1),K(!0)},"data-testid":`show-all-results`,children:[(0,a.jsx)(i.TableProperties,{className:`size-3.5`}),`Show All Results (`,x,`)`]}),G&&(0,a.jsxs)(`button`,{type:`button`,className:`w-full text-left px-3 py-2 rounded-md text-sm hover:bg-accent flex items-center gap-1.5 text-muted-foreground`,onClick:()=>{G(u),l(!1)},children:[(0,a.jsx)(i.Plus,{className:`size-3.5`}),`Create new`,u?` "${u}"`:``]})]})})]})]}),W&&(0,a.jsx)(r.Button,{variant:`outline`,size:`icon`,className:`shrink-0`,type:`button`,onClick:()=>K(!0),"aria-label":`Browse all records`,title:`Browse all records`,"data-testid":`browse-all-records`,children:(0,a.jsx)(i.TableProperties,{className:`size-4`})})]}),W&&V&&P&&(0,a.jsx)(d,{open:de,onOpenChange:K,title:D?.label||`Select`,multiple:A,dataSource:V,objectName:P,columns:F,displayField:j,idField:N,pageSize:le,value:e,onSelect:o,onSelectRecords:me,lookupFilters:I,cellRenderer:re(),filterColumns:z})]})}Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return _}});