codicent-app-sdk 0.4.24 → 0.4.25

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.
@@ -1 +1 @@
1
- {"version":3,"file":"ListView.d.ts","sourceRoot":"","sources":["../../../src/components/ListView.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAiB5D,uEAAuE;AACvE,MAAM,WAAW,YAAY;IAC3B,kHAAkH;IAClH,IAAI,EAAE,KAAK,CAAC,aAAa,CAAC;IAC1B,uCAAuC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iFAAiF;IACjF,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;CACrD;AA2JD,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,UAAU,GAAG,MAAM,GAAG,SAAS,CAAC;IAC7D,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oCAAoC;IACpC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gHAAgH;IAChH,WAAW,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAC7B,2HAA2H;IAC3H,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,oIAAoI;IACpI,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,CAAC;CACrC;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MA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I,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAChH,oBAAoB,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,IAAI,CAAC;CAC1E;AAID,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CA0e5C,CAAC;;AAGF,wBAAoC"}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),n=require("@fluentui/react-components"),i=require("@fluentui/react-icons"),r=require("../services/codicent.js"),o=require("../hooks/useLocalization.js");const l=n.makeStyles({container:{width:"100%",overflowX:"auto",userSelect:"text"},table:{width:"100%",borderCollapse:"collapse",backgroundColor:"#ffffff",fontSize:"14px",tableLayout:"fixed",userSelect:"text"},th:{textAlign:"left",padding:"12px 8px",borderBottom:"2px solid #e0e0e0",fontWeight:"600",backgroundColor:"#f5f5f5",position:"sticky",top:0,zIndex:1,cursor:"pointer",userSelect:"none","&:hover":{backgroundColor:"#e8e8e8"}},td:{padding:"12px 8px",borderBottom:"1px solid #e0e0e0",verticalAlign:"top",wordWrap:"break-word",overflow:"hidden",userSelect:"text"},tdTruncated:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap","@media (hover: none)":{cursor:"pointer"}},tr:{"&:hover":{backgroundColor:"#f9f9f9"}},emptyState:{padding:"20px",textAlign:"center",color:"#666"},sortIndicator:{marginLeft:"4px",fontSize:"10px"},hideOnMobile:{"@media (max-width: 768px)":{display:"none"}},dialogContent:{wordWrap:"break-word",whiteSpace:"pre-wrap",maxHeight:"60vh",overflowY:"auto"},thumbnail:{maxWidth:"50px",maxHeight:"50px",objectFit:"cover"},tooltip:{maxWidth:"600px",whiteSpace:"normal",wordWrap:"break-word"},editButton:{minWidth:"auto",padding:"4px 8px"},actionsColumn:{width:"100px",textAlign:"center"},filterInput:{width:"100%",padding:"4px 8px",fontSize:"14px",border:"1px solid #e0e0e0",borderRadius:"4px",paddingRight:"28px"},filterWrapper:{position:"relative"},clearFilterButton:{position:"absolute",right:"6px",top:"50%",transform:"translateY(-50%)",minWidth:"auto",height:"20px",padding:"0 6px",lineHeight:"18px"},filterToolbar:{display:"flex",justifyContent:"flex-end",padding:"8px",gap:"8px"},cellWithAction:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"4px"},actionIcon:{minWidth:"auto",padding:"2px",marginLeft:"4px",flexShrink:0,cursor:"pointer",opacity:.7,"&:hover":{opacity:1}},cellText:{flex:1,overflow:"hidden",textOverflow:"ellipsis"}}),a=(e,t)=>{if("string"==typeof t)return e[t];for(const n of t)if(void 0!==e[n])return e[n]},s=({data:s,columns:c,canEdit:d,onEdit:p,onDelete:h,onToggleCheckbox:x,onEnumChange:u,onFilteredDataChange:m})=>{const f=l(),{visibleColumns:g,defaultSortIndex:y,defaultSortDirection:j}=t.useMemo((()=>{const e=s&&s.length>0?Array.from(new Set(s.flatMap((e=>Object.keys(e))))):[],t=(c||e.map((e=>({key:e})))).filter((e=>!e.hidden)),n=t.findIndex((e=>e.defaultSort));return{visibleColumns:t,defaultSortIndex:n,defaultSortDirection:n>=0&&t[n].defaultSort||null}}),[s,c]),[b,w]=t.useState(y>=0?y:null),[k,C]=t.useState(j),[S,v]=t.useState(!1),[W,N]=t.useState({title:"",text:""}),[$,M]=t.useState({}),[A,O]=t.useState(0),{t:B}=o.default(),D=e=>e.title?B(e.title):Array.isArray(e.key)?e.key[0]:e.key,I=e=>{const t=[];return e.hideOnMobile&&t.push(f.hideOnMobile),t.join(" ")},T=e=>null==e||"string"==typeof e&&e.startsWith("[")&&e.endsWith("]")?"":"object"==typeof e?JSON.stringify(e):String(e),F=t.useMemo((()=>{const e=[...s];if(null!==b&&k){const t=g[b];e.sort(((e,n)=>{const i=a(e,t.key),r=a(n,t.key);if(null==i)return 1;if(null==r)return-1;let o=0;return o="string"==typeof i&&"string"==typeof r?i.localeCompare(r):"number"==typeof i&&"number"==typeof r?i-r:String(i).localeCompare(String(r)),"asc"===k?o:-o}))}return e}),[s,b,k,g]),L=t.useMemo((()=>F.filter((e=>{for(const[t,n]of Object.entries($)){const i=parseInt(t),r=g[i],o=a(e,r.key),l=T(o).toLowerCase(),s=n.toLowerCase();if(!l.includes(s))return!1}return!0}))),[F,$,g]);t.useEffect((()=>{m&&m(L)}),[L,m]);const q="undefined"!=typeof window?window.innerHeight-250:600,z=Math.max(0,Math.floor(A/49)-5),E=Math.min(L.length,Math.ceil((A+q)/49)+5),H=L.slice(z,E),P=49*L.length,R=49*z,_=(e,t)=>{if(void 0!==e.id)return String(e.id);return`row-${t}-${(e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t)})(g.slice(0,3).map((t=>String(a(e,t.key)??""))).join("-"))}`};return s&&0!==s.length?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:f.container,onScroll:e=>{O(e.currentTarget.scrollTop)},style:{maxHeight:"calc(100vh - 200px)",overflowY:"auto"},children:e.jsxs("table",{className:f.table,children:[e.jsxs("thead",{children:[e.jsxs("tr",{children:[g.map(((t,n)=>{const i=t.maxWidth?{width:`${t.maxWidth}px`,maxWidth:`${t.maxWidth}px`}:{};return e.jsxs("th",{className:`${f.th} ${I(t)}`.trim(),style:i,onClick:()=>(e=>{b===e?"asc"===k?C("desc"):"desc"===k&&(w(null),C(null)):(w(e),C("asc"))})(n),children:[D(t),b===n&&e.jsx("span",{className:f.sortIndicator,children:"asc"===k?"▲":"▼"})]},n)})),d&&e.jsx("th",{className:`${f.th} ${f.actionsColumn}`,style:{width:"100px"},children:B("Actions")})]}),e.jsxs("tr",{children:[g.map(((t,i)=>{const r=t.maxWidth?{width:`${t.maxWidth}px`,maxWidth:`${t.maxWidth}px`}:{};return e.jsx("th",{className:I(t),style:r,children:t.filterable&&e.jsxs("div",{className:f.filterWrapper,children:[e.jsx("input",{type:"text",className:f.filterInput,placeholder:B("Filter")+"...",value:$[i]||"",onChange:e=>((e,t)=>{M((n=>{const i={...n};return""===t.trim()?delete i[e]:i[e]=t,i}))})(i,e.target.value),onClick:e=>e.stopPropagation()}),($[i]||"").length>0&&e.jsx(n.Button,{appearance:"subtle",className:f.clearFilterButton,onClick:e=>{e.stopPropagation(),(e=>{M((t=>{const n={...t};return delete n[e],n}))})(i)},children:"×"})]})},i)})),d&&e.jsx("th",{className:f.actionsColumn})]})]}),e.jsxs("tbody",{children:[z>0&&e.jsx("tr",{style:{height:`${R}px`},children:e.jsx("td",{colSpan:g.length+(d?1:0),style:{padding:0,border:"none"}})}),H.map(((t,o)=>{const l=t._index,s="number"==typeof l?l:z+o;return e.jsxs("tr",{className:f.tr,children:[g.map(((i,o)=>{const l=a(t,i.key),c=i.format?i.format(l):T(l),d=i.maxWidth?`${f.td} ${f.tdTruncated} ${I(i)}`.trim():`${f.td} ${I(i)}`.trim(),p=()=>{window.matchMedia("(hover: hover)").matches||i.maxWidth&&c.length>0&&(N({title:D(i),text:c}),v(!0))};if("file"===i.type&&c)return e.jsx("td",{className:d,onClick:p,children:e.jsx("a",{href:r.CodicentService.getFileUrl(c),target:"_blank",rel:"noopener noreferrer",children:B("Download")})},o);if("checkbox"===i.type){const r=!0===l||"true"===l||"yes"===l||"1"===l;return e.jsx("td",{className:d,children:e.jsx(n.Checkbox,{checked:r,onChange:(e,n)=>{x&&x(t,i.key,!0===n.checked,s)}})},o)}if("enum"===i.type&&i.enumOptions)return e.jsx("td",{className:d,children:e.jsxs(n.Select,{value:c,"aria-label":i.title?B(i.title):Array.isArray(i.key)?i.key[0]:i.key,onChange:(e,n)=>{u&&u(t,i.key,n.value,s)},style:{width:"100%"},children:[!i.enumOptions.includes(c)&&c&&e.jsx("option",{value:c,children:c}),i.enumOptions.map((t=>e.jsx("option",{value:t,children:B(t)},t)))]})},o);const h=()=>i.maxWidth&&c.length>0?e.jsx(n.Tooltip,{content:{children:c,style:{maxWidth:"600px",whiteSpace:"normal"}},relationship:"description",children:e.jsx("span",{children:c})}):c;return e.jsx("td",{className:d,onClick:p,children:i.action?e.jsxs("div",{className:f.cellWithAction,children:[e.jsx("span",{className:f.cellText,children:h()}),(()=>{if(!i.action)return null;const r=i.action,o=i.action.icon,l=e.jsx(n.Button,{appearance:"subtle",icon:e.jsx(o,{}),className:f.actionIcon,onClick:e=>{e.stopPropagation(),r.onClick(t)},size:"small"});return r.tooltip?e.jsx(n.Tooltip,{content:B(r.tooltip),relationship:"label",children:l}):l})()]}):h()},o)})),d&&(p||h)&&e.jsx("td",{className:`${f.td} ${f.actionsColumn}`,children:e.jsxs("div",{style:{display:"flex",gap:"4px",justifyContent:"center"},children:[p&&e.jsx(n.Button,{appearance:"subtle",icon:e.jsx(i.Edit24Regular,{}),className:f.editButton,onClick:()=>p(t,s),title:B("Edit")}),h&&e.jsx(n.Button,{appearance:"subtle",icon:e.jsx(i.Delete24Regular,{}),className:f.editButton,onClick:()=>h(t,s),title:B("Delete")})]})})]},_(t,s))})),E<L.length&&e.jsx("tr",{style:{height:P-R-49*H.length+"px"},children:e.jsx("td",{colSpan:g.length+(d?1:0),style:{padding:0,border:"none"}})})]})]})}),e.jsx(n.Dialog,{open:S,onOpenChange:(e,t)=>v(t.open),children:e.jsx(n.DialogSurface,{children:e.jsxs(n.DialogBody,{children:[e.jsx(n.DialogTitle,{children:W.title}),e.jsx(n.DialogContent,{className:f.dialogContent,children:W.text})]})})})]}):e.jsx("div",{className:f.emptyState,children:B("No data to display")})};var c=t.memo(s);exports.ListView=s,exports.default=c;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),n=require("@fluentui/react-components"),i=require("@fluentui/react-icons"),r=require("../services/codicent.js"),o=require("../hooks/useLocalization.js");const l=n.makeStyles({container:{width:"100%",overflowX:"auto",userSelect:"text"},table:{width:"100%",borderCollapse:"collapse",backgroundColor:"#ffffff",fontSize:"14px",tableLayout:"fixed",userSelect:"text"},th:{textAlign:"left",padding:"12px 8px",borderBottom:"2px solid #e0e0e0",fontWeight:"600",backgroundColor:"#f5f5f5",position:"sticky",top:0,zIndex:1,cursor:"pointer",userSelect:"none","&:hover":{backgroundColor:"#e8e8e8"}},td:{padding:"12px 8px",borderBottom:"1px solid #e0e0e0",verticalAlign:"top",wordWrap:"break-word",overflow:"hidden",userSelect:"text"},tdTruncated:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap","@media (hover: none)":{cursor:"pointer"}},tr:{"&:hover":{backgroundColor:"#f9f9f9"}},emptyState:{padding:"20px",textAlign:"center",color:"#666"},sortIndicator:{marginLeft:"4px",fontSize:"10px"},hideOnMobile:{"@media (max-width: 768px)":{display:"none"}},dialogContent:{wordWrap:"break-word",whiteSpace:"pre-wrap",maxHeight:"60vh",overflowY:"auto"},thumbnail:{maxWidth:"50px",maxHeight:"50px",objectFit:"cover"},tooltip:{maxWidth:"600px",whiteSpace:"normal",wordWrap:"break-word"},editButton:{minWidth:"auto",padding:"4px 8px"},actionsColumn:{width:"100px",textAlign:"center"},filterInput:{width:"100%",padding:"4px 8px",fontSize:"14px",border:"1px solid #e0e0e0",borderRadius:"4px",paddingRight:"28px"},filterWrapper:{position:"relative"},clearFilterButton:{position:"absolute",right:"6px",top:"50%",transform:"translateY(-50%)",minWidth:"auto",height:"20px",padding:"0 6px",lineHeight:"18px"},filterToolbar:{display:"flex",justifyContent:"flex-end",padding:"8px",gap:"8px"},cellWithAction:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"4px"},actionIcon:{minWidth:"auto",padding:"2px",marginLeft:"4px",flexShrink:0,cursor:"pointer",opacity:.7,"&:hover":{opacity:1}},cellText:{flex:1,overflow:"hidden",textOverflow:"ellipsis"}}),a=e=>{if(/^\d{4}-\d{2}-\d{2}/.test(e)){const t=new Date(e);if(!isNaN(t.getTime()))return t.getTime()}const t=e.match(/^(\d{1,2})\.(\d{1,2})\.(\d{4})/);if(t){const e=parseInt(t[1],10),n=parseInt(t[2],10)-1,i=parseInt(t[3],10),r=new Date(i,n,e);if(r.getFullYear()===i&&r.getMonth()===n&&r.getDate()===e)return r.getTime()}return null},s=(e,t)=>{if("string"==typeof t)return e[t];for(const n of t)if(void 0!==e[n])return e[n]},c=({data:c,columns:d,canEdit:p,onEdit:h,onDelete:u,onToggleCheckbox:x,onEnumChange:m,onFilteredDataChange:f})=>{const g=l(),{visibleColumns:y,defaultSortIndex:j,defaultSortDirection:b}=t.useMemo((()=>{const e=c&&c.length>0?Array.from(new Set(c.flatMap((e=>Object.keys(e))))):[],t=(d||e.map((e=>({key:e})))).filter((e=>!e.hidden)),n=t.findIndex((e=>e.defaultSort));return{visibleColumns:t,defaultSortIndex:n,defaultSortDirection:n>=0&&t[n].defaultSort||null}}),[c,d]),[w,k]=t.useState(j>=0?j:null),[C,S]=t.useState(b),[v,N]=t.useState(!1),[W,$]=t.useState({title:"",text:""}),[D,I]=t.useState({}),[M,T]=t.useState(0),{t:A}=o.default(),O=e=>e.title?A(e.title):Array.isArray(e.key)?e.key[0]:e.key,B=e=>{const t=[];return e.hideOnMobile&&t.push(g.hideOnMobile),t.join(" ")},F=e=>null==e||"string"==typeof e&&e.startsWith("[")&&e.endsWith("]")?"":"object"==typeof e?JSON.stringify(e):String(e),L=t.useMemo((()=>{const e=[...c];if(null!==w&&C){const t=y[w];e.sort(((e,n)=>{const i=s(e,t.key),r=s(n,t.key);if(null==i)return 1;if(null==r)return-1;let o=0;if("string"==typeof i&&"string"==typeof r){const e=a(i),t=a(r);if(null!==e&&null!==t)o=e-t;else{const e=Number(i.trim()),t=Number(r.trim());o=""!==i.trim()&&""!==r.trim()&&isFinite(e)&&isFinite(t)?e-t:i.localeCompare(r)}}else o="number"==typeof i&&"number"==typeof r?i-r:String(i).localeCompare(String(r));return"asc"===C?o:-o}))}return e}),[c,w,C,y]),q=t.useMemo((()=>L.filter((e=>{for(const[t,n]of Object.entries(D)){const i=parseInt(t),r=y[i],o=s(e,r.key),l=F(o).toLowerCase(),a=n.toLowerCase();if(!l.includes(a))return!1}return!0}))),[L,D,y]);t.useEffect((()=>{f&&f(q)}),[q,f]);const z="undefined"!=typeof window?window.innerHeight-250:600,E=Math.max(0,Math.floor(M/49)-5),H=Math.min(q.length,Math.ceil((M+z)/49)+5),P=q.slice(E,H),R=49*q.length,Y=49*E,_=(e,t)=>{if(void 0!==e.id)return String(e.id);return`row-${t}-${(e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t)})(y.slice(0,3).map((t=>String(s(e,t.key)??""))).join("-"))}`};return c&&0!==c.length?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:g.container,onScroll:e=>{T(e.currentTarget.scrollTop)},style:{maxHeight:"calc(100vh - 200px)",overflowY:"auto"},children:e.jsxs("table",{className:g.table,children:[e.jsxs("thead",{children:[e.jsxs("tr",{children:[y.map(((t,n)=>{const i=t.maxWidth?{width:`${t.maxWidth}px`,maxWidth:`${t.maxWidth}px`}:{};return e.jsxs("th",{className:`${g.th} ${B(t)}`.trim(),style:i,onClick:()=>(e=>{w===e?"asc"===C?S("desc"):"desc"===C&&(k(null),S(null)):(k(e),S("asc"))})(n),children:[O(t),w===n&&e.jsx("span",{className:g.sortIndicator,children:"asc"===C?"▲":"▼"})]},n)})),p&&e.jsx("th",{className:`${g.th} ${g.actionsColumn}`,style:{width:"100px"},children:A("Actions")})]}),e.jsxs("tr",{children:[y.map(((t,i)=>{const r=t.maxWidth?{width:`${t.maxWidth}px`,maxWidth:`${t.maxWidth}px`}:{};return e.jsx("th",{className:B(t),style:r,children:t.filterable&&e.jsxs("div",{className:g.filterWrapper,children:[e.jsx("input",{type:"text",className:g.filterInput,placeholder:A("Filter")+"...",value:D[i]||"",onChange:e=>((e,t)=>{I((n=>{const i={...n};return""===t.trim()?delete i[e]:i[e]=t,i}))})(i,e.target.value),onClick:e=>e.stopPropagation()}),(D[i]||"").length>0&&e.jsx(n.Button,{appearance:"subtle",className:g.clearFilterButton,onClick:e=>{e.stopPropagation(),(e=>{I((t=>{const n={...t};return delete n[e],n}))})(i)},children:"×"})]})},i)})),p&&e.jsx("th",{className:g.actionsColumn})]})]}),e.jsxs("tbody",{children:[E>0&&e.jsx("tr",{style:{height:`${Y}px`},children:e.jsx("td",{colSpan:y.length+(p?1:0),style:{padding:0,border:"none"}})}),P.map(((t,o)=>{const l=t._index,a="number"==typeof l?l:E+o;return e.jsxs("tr",{className:g.tr,children:[y.map(((i,o)=>{const l=s(t,i.key),c=i.format?i.format(l):F(l),d=i.maxWidth?`${g.td} ${g.tdTruncated} ${B(i)}`.trim():`${g.td} ${B(i)}`.trim(),p=()=>{window.matchMedia("(hover: hover)").matches||i.maxWidth&&c.length>0&&($({title:O(i),text:c}),N(!0))};if("file"===i.type&&c)return e.jsx("td",{className:d,onClick:p,children:e.jsx("a",{href:r.CodicentService.getFileUrl(c),target:"_blank",rel:"noopener noreferrer",children:A("Download")})},o);if("checkbox"===i.type){const r=!0===l||"true"===l||"yes"===l||"1"===l;return e.jsx("td",{className:d,children:e.jsx(n.Checkbox,{checked:r,onChange:(e,n)=>{x&&x(t,i.key,!0===n.checked,a)}})},o)}if("enum"===i.type&&i.enumOptions)return e.jsx("td",{className:d,children:e.jsxs(n.Select,{value:c,"aria-label":i.title?A(i.title):Array.isArray(i.key)?i.key[0]:i.key,onChange:(e,n)=>{m&&m(t,i.key,n.value,a)},style:{width:"100%"},children:[!i.enumOptions.includes(c)&&c&&e.jsx("option",{value:c,children:c}),i.enumOptions.map((t=>e.jsx("option",{value:t,children:A(t)},t)))]})},o);const h=()=>i.maxWidth&&c.length>0?e.jsx(n.Tooltip,{content:{children:c,style:{maxWidth:"600px",whiteSpace:"normal"}},relationship:"description",children:e.jsx("span",{children:c})}):c;return e.jsx("td",{className:d,onClick:p,children:i.action?e.jsxs("div",{className:g.cellWithAction,children:[e.jsx("span",{className:g.cellText,children:h()}),(()=>{if(!i.action)return null;const r=i.action,o=i.action.icon,l=e.jsx(n.Button,{appearance:"subtle",icon:e.jsx(o,{}),className:g.actionIcon,onClick:e=>{e.stopPropagation(),r.onClick(t)},size:"small"});return r.tooltip?e.jsx(n.Tooltip,{content:A(r.tooltip),relationship:"label",children:l}):l})()]}):h()},o)})),p&&(h||u)&&e.jsx("td",{className:`${g.td} ${g.actionsColumn}`,children:e.jsxs("div",{style:{display:"flex",gap:"4px",justifyContent:"center"},children:[h&&e.jsx(n.Button,{appearance:"subtle",icon:e.jsx(i.Edit24Regular,{}),className:g.editButton,onClick:()=>h(t,a),title:A("Edit")}),u&&e.jsx(n.Button,{appearance:"subtle",icon:e.jsx(i.Delete24Regular,{}),className:g.editButton,onClick:()=>u(t,a),title:A("Delete")})]})})]},_(t,a))})),H<q.length&&e.jsx("tr",{style:{height:R-Y-49*P.length+"px"},children:e.jsx("td",{colSpan:y.length+(p?1:0),style:{padding:0,border:"none"}})})]})]})}),e.jsx(n.Dialog,{open:v,onOpenChange:(e,t)=>N(t.open),children:e.jsx(n.DialogSurface,{children:e.jsxs(n.DialogBody,{children:[e.jsx(n.DialogTitle,{children:W.title}),e.jsx(n.DialogContent,{className:g.dialogContent,children:W.text})]})})})]}):e.jsx("div",{className:g.emptyState,children:A("No data to display")})};var d=t.memo(c);exports.ListView=c,exports.default=d;
@@ -1 +1 @@
1
- {"version":3,"file":"RecordModal.d.ts","sourceRoot":"","sources":["../../../src/components/RecordModal.tsx"],"names":[],"mappings":"AAWA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAmBnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAoB9C,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CA0IlD,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"RecordModal.d.ts","sourceRoot":"","sources":["../../../src/components/RecordModal.tsx"],"names":[],"mappings":"AAWA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAkBnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAoB9C,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAsIlD,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),a=require("react"),r=require("@fluentui/react-components"),l=require("../hooks/useLocalization.js");const n=r.makeStyles({surface:{backgroundColor:r.tokens.colorNeutralBackground1},content:{display:"flex",flexDirection:"column",gap:"16px",minWidth:"400px",maxHeight:"60vh",overflowY:"auto"},field:{display:"flex",flexDirection:"column"}}),t=({open:t,onClose:o,onSave:i,columns:s,initialData:c,title:d})=>{const u=n(),{t:p}=l.default(),[x,h]=a.useState({}),[f,y]=a.useState(!1);a.useEffect((()=>{t&&h(c||{})}),[t,c]);const g=e=>Array.isArray(e.key)?e.key[0]:e.key,j=e=>{if(Array.isArray(e.key))for(const a of e.key)if(void 0!==x[a])return a;return g(e)},m=(e,a)=>{const r=j(e);h((e=>({...e,[r]:a})))},k=s.filter((e=>!e.hidden&&"file"!==e.type&&"createdAt"!==g(e)));return e.jsx(r.Dialog,{open:t,onOpenChange:(e,a)=>!f&&!1===a.open&&o(),children:e.jsx(r.DialogSurface,{className:u.surface,backdrop:{style:{backgroundColor:"rgba(0, 0, 0, 0.4)"}},children:e.jsxs(r.DialogBody,{children:[e.jsx(r.DialogTitle,{children:d||p(c?"Edit Record":"Add Record")}),e.jsx(r.DialogContent,{className:u.content,children:k.map(((a,l)=>{const n=g(a),t=(e=>{const a=j(e);return x[a]})(a),o=a.title||n;return"checkbox"===a.type?e.jsx(r.Field,{label:o,className:u.field,children:e.jsx(r.Checkbox,{checked:!0===t||"true"===t||"yes"===t||"1"===t,onChange:(e,r)=>m(a,r.checked)})},l):"textarea"===a.type?e.jsx(r.Field,{label:o,className:u.field,children:e.jsx(r.Textarea,{value:String(t??""),rows:a.rows??3,onChange:(e,r)=>m(a,r.value),placeholder:p("Enter")+" "+o.toLowerCase(),resize:"vertical"})},l):"enum"===a.type&&a.enumOptions?e.jsx(r.Field,{label:o,className:u.field,children:e.jsxs(r.Select,{value:String(t??""),onChange:(e,r)=>m(a,r.value),children:[e.jsx(r.Option,{value:"",children:p("Select")+" "+o.toLowerCase()}),a.enumOptions.map((a=>e.jsx(r.Option,{value:a,children:a},a)))]})},l):e.jsx(r.Field,{label:o,className:u.field,children:e.jsx(r.Input,{value:String(t??""),onChange:(e,r)=>m(a,r.value),placeholder:p("Enter")+" "+o.toLowerCase()})},l)}))}),e.jsxs(r.DialogActions,{children:[e.jsx(r.Button,{appearance:"secondary",onClick:o,disabled:f,children:p("Cancel")}),e.jsx(r.Button,{appearance:"primary",onClick:async()=>{y(!0);try{await i(x),o()}catch(e){console.error("Failed to save record:",e)}finally{y(!1)}},disabled:f,children:p(f?"Saving...":"Save")})]})]})})})};exports.RecordModal=t,exports.default=t;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),a=require("react"),r=require("@fluentui/react-components"),l=require("../hooks/useLocalization.js");const n=r.makeStyles({surface:{backgroundColor:r.tokens.colorNeutralBackground1},content:{display:"flex",flexDirection:"column",gap:"16px",minWidth:"400px",maxHeight:"60vh",overflowY:"auto"},field:{display:"flex",flexDirection:"column"}}),o=({open:o,onClose:t,onSave:i,columns:s,initialData:c,title:d})=>{const u=n(),{t:p}=l.default(),[x,h]=a.useState({}),[f,y]=a.useState(!1);a.useEffect((()=>{o&&h(c||{})}),[o,c]);const g=e=>Array.isArray(e.key)?e.key[0]:e.key,j=e=>{if(Array.isArray(e.key))for(const a of e.key)if(void 0!==x[a])return a;return g(e)},m=(e,a)=>{const r=j(e);h((e=>({...e,[r]:a})))},k=s.filter((e=>!e.hidden&&"file"!==e.type&&"createdAt"!==g(e)));return e.jsx(r.Dialog,{open:o,onOpenChange:(e,a)=>!f&&!1===a.open&&t(),children:e.jsx(r.DialogSurface,{className:u.surface,backdrop:{style:{backgroundColor:"rgba(0, 0, 0, 0.4)"}},children:e.jsxs(r.DialogBody,{children:[e.jsx(r.DialogTitle,{children:d||p(c?"Edit Record":"Add Record")}),e.jsx(r.DialogContent,{className:u.content,children:k.map(((a,l)=>{const n=g(a),o=(e=>{const a=j(e);return x[a]})(a),t=a.title||n;return"checkbox"===a.type?e.jsx(r.Field,{label:t,className:u.field,children:e.jsx(r.Checkbox,{checked:!0===o||"true"===o||"yes"===o||"1"===o,onChange:(e,r)=>m(a,r.checked)})},l):"textarea"===a.type?e.jsx(r.Field,{label:t,className:u.field,children:e.jsx(r.Textarea,{value:String(o??""),rows:a.rows??3,onChange:(e,r)=>m(a,r.value),placeholder:p("Enter")+" "+t.toLowerCase(),resize:"vertical"})},l):"enum"===a.type&&a.enumOptions?e.jsx(r.Field,{label:t,className:u.field,children:e.jsx(r.Select,{value:String(o??""),onChange:(e,r)=>m(a,r.value),children:a.enumOptions.map((a=>e.jsx("option",{value:a,children:a||p("(None)")},a)))})},l):e.jsx(r.Field,{label:t,className:u.field,children:e.jsx(r.Input,{value:String(o??""),onChange:(e,r)=>m(a,r.value),placeholder:p("Enter")+" "+t.toLowerCase()})},l)}))}),e.jsxs(r.DialogActions,{children:[e.jsx(r.Button,{appearance:"secondary",onClick:t,disabled:f,children:p("Cancel")}),e.jsx(r.Button,{appearance:"primary",onClick:async()=>{y(!0);try{await i(x),t()}catch(e){console.error("Failed to save record:",e)}finally{y(!1)}},disabled:f,children:p(f?"Saving...":"Save")})]})]})})})};exports.RecordModal=o,exports.default=o;
@@ -1 +1 @@
1
- {"version":3,"file":"ListView.d.ts","sourceRoot":"","sources":["../../../src/components/ListView.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAiB5D,uEAAuE;AACvE,MAAM,WAAW,YAAY;IAC3B,kHAAkH;IAClH,IAAI,EAAE,KAAK,CAAC,aAAa,CAAC;IAC1B,uCAAuC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iFAAiF;IACjF,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;CACrD;AA2JD,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC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,Select as s,Dialog as p,DialogSurface as h,DialogBody as u,DialogTitle as m,DialogContent as f,Tooltip as x}from"@fluentui/react-components";import{Edit24Regular as g,Delete24Regular as y}from"@fluentui/react-icons";import{CodicentService as b}from"../services/codicent.js";import w from"../hooks/useLocalization.js";const k=a({container:{width:"100%",overflowX:"auto",userSelect:"text"},table:{width:"100%",borderCollapse:"collapse",backgroundColor:"#ffffff",fontSize:"14px",tableLayout:"fixed",userSelect:"text"},th:{textAlign:"left",padding:"12px 8px",borderBottom:"2px solid #e0e0e0",fontWeight:"600",backgroundColor:"#f5f5f5",position:"sticky",top:0,zIndex:1,cursor:"pointer",userSelect:"none","&:hover":{backgroundColor:"#e8e8e8"}},td:{padding:"12px 8px",borderBottom:"1px solid #e0e0e0",verticalAlign:"top",wordWrap:"break-word",overflow:"hidden",userSelect:"text"},tdTruncated:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap","@media (hover: none)":{cursor:"pointer"}},tr:{"&:hover":{backgroundColor:"#f9f9f9"}},emptyState:{padding:"20px",textAlign:"center",color:"#666"},sortIndicator:{marginLeft:"4px",fontSize:"10px"},hideOnMobile:{"@media (max-width: 768px)":{display:"none"}},dialogContent:{wordWrap:"break-word",whiteSpace:"pre-wrap",maxHeight:"60vh",overflowY:"auto"},thumbnail:{maxWidth:"50px",maxHeight:"50px",objectFit:"cover"},tooltip:{maxWidth:"600px",whiteSpace:"normal",wordWrap:"break-word"},editButton:{minWidth:"auto",padding:"4px 8px"},actionsColumn:{width:"100px",textAlign:"center"},filterInput:{width:"100%",padding:"4px 8px",fontSize:"14px",border:"1px solid #e0e0e0",borderRadius:"4px",paddingRight:"28px"},filterWrapper:{position:"relative"},clearFilterButton:{position:"absolute",right:"6px",top:"50%",transform:"translateY(-50%)",minWidth:"auto",height:"20px",padding:"0 6px",lineHeight:"18px"},filterToolbar:{display:"flex",justifyContent:"flex-end",padding:"8px",gap:"8px"},cellWithAction:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"4px"},actionIcon:{minWidth:"auto",padding:"2px",marginLeft:"4px",flexShrink:0,cursor:"pointer",opacity:.7,"&:hover":{opacity:1}},cellText:{flex:1,overflow:"hidden",textOverflow:"ellipsis"}}),C=(e,t)=>{if("string"==typeof t)return e[t];for(const n of t)if(void 0!==e[n])return e[n]},v=({data:i,columns:a,canEdit:v,onEdit:S,onDelete:W,onToggleCheckbox:N,onEnumChange:$,onFilteredDataChange:A})=>{const j=k(),{visibleColumns:I,defaultSortIndex:O,defaultSortDirection:M}=r((()=>{const e=i&&i.length>0?Array.from(new Set(i.flatMap((e=>Object.keys(e))))):[],t=(a||e.map((e=>({key:e})))).filter((e=>!e.hidden)),n=t.findIndex((e=>e.defaultSort));return{visibleColumns:t,defaultSortIndex:n,defaultSortDirection:n>=0&&t[n].defaultSort||null}}),[i,a]),[T,B]=o(O>=0?O:null),[z,D]=o(M),[F,L]=o(!1),[H,E]=o({title:"",text:""}),[P,Y]=o({}),[R,_]=o(0),{t:J}=w(),U=e=>e.title?J(e.title):Array.isArray(e.key)?e.key[0]:e.key,X=e=>{const t=[];return e.hideOnMobile&&t.push(j.hideOnMobile),t.join(" ")},q=e=>null==e||"string"==typeof e&&e.startsWith("[")&&e.endsWith("]")?"":"object"==typeof e?JSON.stringify(e):String(e),G=r((()=>{const e=[...i];if(null!==T&&z){const t=I[T];e.sort(((e,n)=>{const i=C(e,t.key),r=C(n,t.key);if(null==i)return 1;if(null==r)return-1;let o=0;return o="string"==typeof i&&"string"==typeof r?i.localeCompare(r):"number"==typeof i&&"number"==typeof r?i-r:String(i).localeCompare(String(r)),"asc"===z?o:-o}))}return e}),[i,T,z,I]),K=r((()=>G.filter((e=>{for(const[t,n]of Object.entries(P)){const i=parseInt(t),r=I[i],o=C(e,r.key),l=q(o).toLowerCase(),a=n.toLowerCase();if(!l.includes(a))return!1}return!0}))),[G,P,I]);l((()=>{A&&A(K)}),[K,A]);const Q="undefined"!=typeof window?window.innerHeight-250:600,V=Math.max(0,Math.floor(R/49)-5),Z=Math.min(K.length,Math.ceil((R+Q)/49)+5),ee=K.slice(V,Z),te=49*K.length,ne=49*V,ie=(e,t)=>{if(void 0!==e.id)return String(e.id);return`row-${t}-${(e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t)})(I.slice(0,3).map((t=>String(C(e,t.key)??""))).join("-"))}`};return i&&0!==i.length?t(n,{children:[e("div",{className:j.container,onScroll:e=>{_(e.currentTarget.scrollTop)},style:{maxHeight:"calc(100vh - 200px)",overflowY:"auto"},children:t("table",{className:j.table,children:[t("thead",{children:[t("tr",{children:[I.map(((n,i)=>{const r=n.maxWidth?{width:`${n.maxWidth}px`,maxWidth:`${n.maxWidth}px`}:{};return t("th",{className:`${j.th} ${X(n)}`.trim(),style:r,onClick:()=>(e=>{T===e?"asc"===z?D("desc"):"desc"===z&&(B(null),D(null)):(B(e),D("asc"))})(i),children:[U(n),T===i&&e("span",{className:j.sortIndicator,children:"asc"===z?"▲":"▼"})]},i)})),v&&e("th",{className:`${j.th} ${j.actionsColumn}`,style:{width:"100px"},children:J("Actions")})]}),t("tr",{children:[I.map(((n,i)=>{const r=n.maxWidth?{width:`${n.maxWidth}px`,maxWidth:`${n.maxWidth}px`}:{};return e("th",{className:X(n),style:r,children:n.filterable&&t("div",{className:j.filterWrapper,children:[e("input",{type:"text",className:j.filterInput,placeholder:J("Filter")+"...",value:P[i]||"",onChange:e=>((e,t)=>{Y((n=>{const i={...n};return""===t.trim()?delete i[e]:i[e]=t,i}))})(i,e.target.value),onClick:e=>e.stopPropagation()}),(P[i]||"").length>0&&e(c,{appearance:"subtle",className:j.clearFilterButton,onClick:e=>{e.stopPropagation(),(e=>{Y((t=>{const n={...t};return delete n[e],n}))})(i)},children:"×"})]})},i)})),v&&e("th",{className:j.actionsColumn})]})]}),t("tbody",{children:[V>0&&e("tr",{style:{height:`${ne}px`},children:e("td",{colSpan:I.length+(v?1:0),style:{padding:0,border:"none"}})}),ee.map(((n,i)=>{const r=n._index,o="number"==typeof r?r:V+i;return t("tr",{className:j.tr,children:[I.map(((i,r)=>{const l=C(n,i.key),a=i.format?i.format(l):q(l),p=i.maxWidth?`${j.td} ${j.tdTruncated} ${X(i)}`.trim():`${j.td} ${X(i)}`.trim(),h=()=>{window.matchMedia("(hover: hover)").matches||i.maxWidth&&a.length>0&&(E({title:U(i),text:a}),L(!0))};if("file"===i.type&&a)return e("td",{className:p,onClick:h,children:e("a",{href:b.getFileUrl(a),target:"_blank",rel:"noopener noreferrer",children:J("Download")})},r);if("checkbox"===i.type){return e("td",{className:p,children:e(d,{checked:!0===l||"true"===l||"yes"===l||"1"===l,onChange:(e,t)=>{N&&N(n,i.key,!0===t.checked,o)}})},r)}if("enum"===i.type&&i.enumOptions)return e("td",{className:p,children:t(s,{value:a,"aria-label":i.title?J(i.title):Array.isArray(i.key)?i.key[0]:i.key,onChange:(e,t)=>{$&&$(n,i.key,t.value,o)},style:{width:"100%"},children:[!i.enumOptions.includes(a)&&a&&e("option",{value:a,children:a}),i.enumOptions.map((t=>e("option",{value:t,children:J(t)},t)))]})},r);const u=()=>i.maxWidth&&a.length>0?e(x,{content:{children:a,style:{maxWidth:"600px",whiteSpace:"normal"}},relationship:"description",children:e("span",{children:a})}):a;return e("td",{className:p,onClick:h,children:i.action?t("div",{className:j.cellWithAction,children:[e("span",{className:j.cellText,children:u()}),(()=>{if(!i.action)return null;const t=i.action,r=i.action.icon,o=e(c,{appearance:"subtle",icon:e(r,{}),className:j.actionIcon,onClick:e=>{e.stopPropagation(),t.onClick(n)},size:"small"});return t.tooltip?e(x,{content:J(t.tooltip),relationship:"label",children:o}):o})()]}):u()},r)})),v&&(S||W)&&e("td",{className:`${j.td} ${j.actionsColumn}`,children:t("div",{style:{display:"flex",gap:"4px",justifyContent:"center"},children:[S&&e(c,{appearance:"subtle",icon:e(g,{}),className:j.editButton,onClick:()=>S(n,o),title:J("Edit")}),W&&e(c,{appearance:"subtle",icon:e(y,{}),className:j.editButton,onClick:()=>W(n,o),title:J("Delete")})]})})]},ie(n,o))})),Z<K.length&&e("tr",{style:{height:te-ne-49*ee.length+"px"},children:e("td",{colSpan:I.length+(v?1:0),style:{padding:0,border:"none"}})})]})]})}),e(p,{open:F,onOpenChange:(e,t)=>L(t.open),children:e(h,{children:t(u,{children:[e(m,{children:H.title}),e(f,{className:j.dialogContent,children:H.text})]})})})]}):e("div",{className:j.emptyState,children:J("No data to display")})};var S=i.memo(v);export{v as ListView,S as default};
1
+ import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import i,{useMemo as r,useState as o,useEffect as l}from"react";import{makeStyles as a,Button as c,Checkbox as d,Select as s,Dialog as p,DialogSurface as h,DialogBody as u,DialogTitle as m,DialogContent as f,Tooltip as x}from"@fluentui/react-components";import{Edit24Regular as g,Delete24Regular as y}from"@fluentui/react-icons";import{CodicentService as b}from"../services/codicent.js";import w from"../hooks/useLocalization.js";const k=a({container:{width:"100%",overflowX:"auto",userSelect:"text"},table:{width:"100%",borderCollapse:"collapse",backgroundColor:"#ffffff",fontSize:"14px",tableLayout:"fixed",userSelect:"text"},th:{textAlign:"left",padding:"12px 8px",borderBottom:"2px solid #e0e0e0",fontWeight:"600",backgroundColor:"#f5f5f5",position:"sticky",top:0,zIndex:1,cursor:"pointer",userSelect:"none","&:hover":{backgroundColor:"#e8e8e8"}},td:{padding:"12px 8px",borderBottom:"1px solid #e0e0e0",verticalAlign:"top",wordWrap:"break-word",overflow:"hidden",userSelect:"text"},tdTruncated:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap","@media (hover: none)":{cursor:"pointer"}},tr:{"&:hover":{backgroundColor:"#f9f9f9"}},emptyState:{padding:"20px",textAlign:"center",color:"#666"},sortIndicator:{marginLeft:"4px",fontSize:"10px"},hideOnMobile:{"@media (max-width: 768px)":{display:"none"}},dialogContent:{wordWrap:"break-word",whiteSpace:"pre-wrap",maxHeight:"60vh",overflowY:"auto"},thumbnail:{maxWidth:"50px",maxHeight:"50px",objectFit:"cover"},tooltip:{maxWidth:"600px",whiteSpace:"normal",wordWrap:"break-word"},editButton:{minWidth:"auto",padding:"4px 8px"},actionsColumn:{width:"100px",textAlign:"center"},filterInput:{width:"100%",padding:"4px 8px",fontSize:"14px",border:"1px solid #e0e0e0",borderRadius:"4px",paddingRight:"28px"},filterWrapper:{position:"relative"},clearFilterButton:{position:"absolute",right:"6px",top:"50%",transform:"translateY(-50%)",minWidth:"auto",height:"20px",padding:"0 6px",lineHeight:"18px"},filterToolbar:{display:"flex",justifyContent:"flex-end",padding:"8px",gap:"8px"},cellWithAction:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"4px"},actionIcon:{minWidth:"auto",padding:"2px",marginLeft:"4px",flexShrink:0,cursor:"pointer",opacity:.7,"&:hover":{opacity:1}},cellText:{flex:1,overflow:"hidden",textOverflow:"ellipsis"}}),C=e=>{if(/^\d{4}-\d{2}-\d{2}/.test(e)){const t=new Date(e);if(!isNaN(t.getTime()))return t.getTime()}const t=e.match(/^(\d{1,2})\.(\d{1,2})\.(\d{4})/);if(t){const e=parseInt(t[1],10),n=parseInt(t[2],10)-1,i=parseInt(t[3],10),r=new Date(i,n,e);if(r.getFullYear()===i&&r.getMonth()===n&&r.getDate()===e)return r.getTime()}return null},v=(e,t)=>{if("string"==typeof t)return e[t];for(const n of t)if(void 0!==e[n])return e[n]},S=({data:i,columns:a,canEdit:S,onEdit:N,onDelete:W,onToggleCheckbox:$,onEnumChange:I,onFilteredDataChange:A})=>{const j=k(),{visibleColumns:O,defaultSortIndex:M,defaultSortDirection:T}=r((()=>{const e=i&&i.length>0?Array.from(new Set(i.flatMap((e=>Object.keys(e))))):[],t=(a||e.map((e=>({key:e})))).filter((e=>!e.hidden)),n=t.findIndex((e=>e.defaultSort));return{visibleColumns:t,defaultSortIndex:n,defaultSortDirection:n>=0&&t[n].defaultSort||null}}),[i,a]),[D,F]=o(M>=0?M:null),[B,z]=o(T),[L,H]=o(!1),[E,Y]=o({title:"",text:""}),[P,R]=o({}),[_,J]=o(0),{t:U}=w(),X=e=>e.title?U(e.title):Array.isArray(e.key)?e.key[0]:e.key,q=e=>{const t=[];return e.hideOnMobile&&t.push(j.hideOnMobile),t.join(" ")},G=e=>null==e||"string"==typeof e&&e.startsWith("[")&&e.endsWith("]")?"":"object"==typeof e?JSON.stringify(e):String(e),K=r((()=>{const e=[...i];if(null!==D&&B){const t=O[D];e.sort(((e,n)=>{const i=v(e,t.key),r=v(n,t.key);if(null==i)return 1;if(null==r)return-1;let o=0;if("string"==typeof i&&"string"==typeof r){const e=C(i),t=C(r);if(null!==e&&null!==t)o=e-t;else{const e=Number(i.trim()),t=Number(r.trim());o=""!==i.trim()&&""!==r.trim()&&isFinite(e)&&isFinite(t)?e-t:i.localeCompare(r)}}else o="number"==typeof i&&"number"==typeof r?i-r:String(i).localeCompare(String(r));return"asc"===B?o:-o}))}return e}),[i,D,B,O]),Q=r((()=>K.filter((e=>{for(const[t,n]of Object.entries(P)){const i=parseInt(t),r=O[i],o=v(e,r.key),l=G(o).toLowerCase(),a=n.toLowerCase();if(!l.includes(a))return!1}return!0}))),[K,P,O]);l((()=>{A&&A(Q)}),[Q,A]);const V="undefined"!=typeof window?window.innerHeight-250:600,Z=Math.max(0,Math.floor(_/49)-5),ee=Math.min(Q.length,Math.ceil((_+V)/49)+5),te=Q.slice(Z,ee),ne=49*Q.length,ie=49*Z,re=(e,t)=>{if(void 0!==e.id)return String(e.id);return`row-${t}-${(e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t)})(O.slice(0,3).map((t=>String(v(e,t.key)??""))).join("-"))}`};return i&&0!==i.length?t(n,{children:[e("div",{className:j.container,onScroll:e=>{J(e.currentTarget.scrollTop)},style:{maxHeight:"calc(100vh - 200px)",overflowY:"auto"},children:t("table",{className:j.table,children:[t("thead",{children:[t("tr",{children:[O.map(((n,i)=>{const r=n.maxWidth?{width:`${n.maxWidth}px`,maxWidth:`${n.maxWidth}px`}:{};return t("th",{className:`${j.th} ${q(n)}`.trim(),style:r,onClick:()=>(e=>{D===e?"asc"===B?z("desc"):"desc"===B&&(F(null),z(null)):(F(e),z("asc"))})(i),children:[X(n),D===i&&e("span",{className:j.sortIndicator,children:"asc"===B?"▲":"▼"})]},i)})),S&&e("th",{className:`${j.th} ${j.actionsColumn}`,style:{width:"100px"},children:U("Actions")})]}),t("tr",{children:[O.map(((n,i)=>{const r=n.maxWidth?{width:`${n.maxWidth}px`,maxWidth:`${n.maxWidth}px`}:{};return e("th",{className:q(n),style:r,children:n.filterable&&t("div",{className:j.filterWrapper,children:[e("input",{type:"text",className:j.filterInput,placeholder:U("Filter")+"...",value:P[i]||"",onChange:e=>((e,t)=>{R((n=>{const i={...n};return""===t.trim()?delete i[e]:i[e]=t,i}))})(i,e.target.value),onClick:e=>e.stopPropagation()}),(P[i]||"").length>0&&e(c,{appearance:"subtle",className:j.clearFilterButton,onClick:e=>{e.stopPropagation(),(e=>{R((t=>{const n={...t};return delete n[e],n}))})(i)},children:"×"})]})},i)})),S&&e("th",{className:j.actionsColumn})]})]}),t("tbody",{children:[Z>0&&e("tr",{style:{height:`${ie}px`},children:e("td",{colSpan:O.length+(S?1:0),style:{padding:0,border:"none"}})}),te.map(((n,i)=>{const r=n._index,o="number"==typeof r?r:Z+i;return t("tr",{className:j.tr,children:[O.map(((i,r)=>{const l=v(n,i.key),a=i.format?i.format(l):G(l),p=i.maxWidth?`${j.td} ${j.tdTruncated} ${q(i)}`.trim():`${j.td} ${q(i)}`.trim(),h=()=>{window.matchMedia("(hover: hover)").matches||i.maxWidth&&a.length>0&&(Y({title:X(i),text:a}),H(!0))};if("file"===i.type&&a)return e("td",{className:p,onClick:h,children:e("a",{href:b.getFileUrl(a),target:"_blank",rel:"noopener noreferrer",children:U("Download")})},r);if("checkbox"===i.type){return e("td",{className:p,children:e(d,{checked:!0===l||"true"===l||"yes"===l||"1"===l,onChange:(e,t)=>{$&&$(n,i.key,!0===t.checked,o)}})},r)}if("enum"===i.type&&i.enumOptions)return e("td",{className:p,children:t(s,{value:a,"aria-label":i.title?U(i.title):Array.isArray(i.key)?i.key[0]:i.key,onChange:(e,t)=>{I&&I(n,i.key,t.value,o)},style:{width:"100%"},children:[!i.enumOptions.includes(a)&&a&&e("option",{value:a,children:a}),i.enumOptions.map((t=>e("option",{value:t,children:U(t)},t)))]})},r);const u=()=>i.maxWidth&&a.length>0?e(x,{content:{children:a,style:{maxWidth:"600px",whiteSpace:"normal"}},relationship:"description",children:e("span",{children:a})}):a;return e("td",{className:p,onClick:h,children:i.action?t("div",{className:j.cellWithAction,children:[e("span",{className:j.cellText,children:u()}),(()=>{if(!i.action)return null;const t=i.action,r=i.action.icon,o=e(c,{appearance:"subtle",icon:e(r,{}),className:j.actionIcon,onClick:e=>{e.stopPropagation(),t.onClick(n)},size:"small"});return t.tooltip?e(x,{content:U(t.tooltip),relationship:"label",children:o}):o})()]}):u()},r)})),S&&(N||W)&&e("td",{className:`${j.td} ${j.actionsColumn}`,children:t("div",{style:{display:"flex",gap:"4px",justifyContent:"center"},children:[N&&e(c,{appearance:"subtle",icon:e(g,{}),className:j.editButton,onClick:()=>N(n,o),title:U("Edit")}),W&&e(c,{appearance:"subtle",icon:e(y,{}),className:j.editButton,onClick:()=>W(n,o),title:U("Delete")})]})})]},re(n,o))})),ee<Q.length&&e("tr",{style:{height:ne-ie-49*te.length+"px"},children:e("td",{colSpan:O.length+(S?1:0),style:{padding:0,border:"none"}})})]})]})}),e(p,{open:L,onOpenChange:(e,t)=>H(t.open),children:e(h,{children:t(u,{children:[e(m,{children:E.title}),e(f,{className:j.dialogContent,children:E.text})]})})})]}):e("div",{className:j.emptyState,children:U("No data to display")})};var N=i.memo(S);export{S as ListView,N as default};
@@ -1 +1 @@
1
- {"version":3,"file":"RecordModal.d.ts","sourceRoot":"","sources":["../../../src/components/RecordModal.tsx"],"names":[],"mappings":"AAWA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAmBnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAoB9C,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CA0IlD,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"RecordModal.d.ts","sourceRoot":"","sources":["../../../src/components/RecordModal.tsx"],"names":[],"mappings":"AAWA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAkBnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAoB9C,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAsIlD,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -1 +1 @@
1
- import{jsx as e,jsxs as r}from"react/jsx-runtime";import{useState as a,useEffect as n}from"react";import{makeStyles as l,tokens as o,Dialog as c,DialogSurface as t,DialogBody as i,DialogTitle as s,DialogContent as d,Field as u,Checkbox as h,Textarea as p,Select as m,Option as f,Input as y,DialogActions as v,Button as g}from"@fluentui/react-components";import k from"../hooks/useLocalization.js";const C=l({surface:{backgroundColor:o.colorNeutralBackground1},content:{display:"flex",flexDirection:"column",gap:"16px",minWidth:"400px",maxHeight:"60vh",overflowY:"auto"},field:{display:"flex",flexDirection:"column"}}),b=({open:l,onClose:o,onSave:b,columns:x,initialData:w,title:N})=>{const S=C(),{t:A}=k(),[L,D]=a({}),[E,O]=a(!1);n((()=>{l&&D(w||{})}),[l,w]);const j=e=>Array.isArray(e.key)?e.key[0]:e.key,z=e=>{if(Array.isArray(e.key))for(const r of e.key)if(void 0!==L[r])return r;return j(e)},R=(e,r)=>{const a=z(e);D((e=>({...e,[a]:r})))},B=x.filter((e=>!e.hidden&&"file"!==e.type&&"createdAt"!==j(e)));return e(c,{open:l,onOpenChange:(e,r)=>!E&&!1===r.open&&o(),children:e(t,{className:S.surface,backdrop:{style:{backgroundColor:"rgba(0, 0, 0, 0.4)"}},children:r(i,{children:[e(s,{children:N||A(w?"Edit Record":"Add Record")}),e(d,{className:S.content,children:B.map(((a,n)=>{const l=j(a),o=(e=>{const r=z(e);return L[r]})(a),c=a.title||l;return"checkbox"===a.type?e(u,{label:c,className:S.field,children:e(h,{checked:!0===o||"true"===o||"yes"===o||"1"===o,onChange:(e,r)=>R(a,r.checked)})},n):"textarea"===a.type?e(u,{label:c,className:S.field,children:e(p,{value:String(o??""),rows:a.rows??3,onChange:(e,r)=>R(a,r.value),placeholder:A("Enter")+" "+c.toLowerCase(),resize:"vertical"})},n):"enum"===a.type&&a.enumOptions?e(u,{label:c,className:S.field,children:r(m,{value:String(o??""),onChange:(e,r)=>R(a,r.value),children:[e(f,{value:"",children:A("Select")+" "+c.toLowerCase()}),a.enumOptions.map((r=>e(f,{value:r,children:r},r)))]})},n):e(u,{label:c,className:S.field,children:e(y,{value:String(o??""),onChange:(e,r)=>R(a,r.value),placeholder:A("Enter")+" "+c.toLowerCase()})},n)}))}),r(v,{children:[e(g,{appearance:"secondary",onClick:o,disabled:E,children:A("Cancel")}),e(g,{appearance:"primary",onClick:async()=>{O(!0);try{await b(L),o()}catch(e){console.error("Failed to save record:",e)}finally{O(!1)}},disabled:E,children:A(E?"Saving...":"Save")})]})]})})})};export{b as RecordModal,b as default};
1
+ import{jsx as e,jsxs as r}from"react/jsx-runtime";import{useState as a,useEffect as n}from"react";import{makeStyles as o,tokens as l,Dialog as c,DialogSurface as t,DialogBody as i,DialogTitle as s,DialogContent as d,Field as p,Checkbox as u,Textarea as h,Select as m,Input as f,DialogActions as y,Button as g}from"@fluentui/react-components";import k from"../hooks/useLocalization.js";const v=o({surface:{backgroundColor:l.colorNeutralBackground1},content:{display:"flex",flexDirection:"column",gap:"16px",minWidth:"400px",maxHeight:"60vh",overflowY:"auto"},field:{display:"flex",flexDirection:"column"}}),C=({open:o,onClose:l,onSave:C,columns:b,initialData:x,title:N})=>{const w=v(),{t:A}=k(),[S,D]=a({}),[E,L]=a(!1);n((()=>{o&&D(x||{})}),[o,x]);const O=e=>Array.isArray(e.key)?e.key[0]:e.key,j=e=>{if(Array.isArray(e.key))for(const r of e.key)if(void 0!==S[r])return r;return O(e)},z=(e,r)=>{const a=j(e);D((e=>({...e,[a]:r})))},R=b.filter((e=>!e.hidden&&"file"!==e.type&&"createdAt"!==O(e)));return e(c,{open:o,onOpenChange:(e,r)=>!E&&!1===r.open&&l(),children:e(t,{className:w.surface,backdrop:{style:{backgroundColor:"rgba(0, 0, 0, 0.4)"}},children:r(i,{children:[e(s,{children:N||A(x?"Edit Record":"Add Record")}),e(d,{className:w.content,children:R.map(((r,a)=>{const n=O(r),o=(e=>{const r=j(e);return S[r]})(r),l=r.title||n;return"checkbox"===r.type?e(p,{label:l,className:w.field,children:e(u,{checked:!0===o||"true"===o||"yes"===o||"1"===o,onChange:(e,a)=>z(r,a.checked)})},a):"textarea"===r.type?e(p,{label:l,className:w.field,children:e(h,{value:String(o??""),rows:r.rows??3,onChange:(e,a)=>z(r,a.value),placeholder:A("Enter")+" "+l.toLowerCase(),resize:"vertical"})},a):"enum"===r.type&&r.enumOptions?e(p,{label:l,className:w.field,children:e(m,{value:String(o??""),onChange:(e,a)=>z(r,a.value),children:r.enumOptions.map((r=>e("option",{value:r,children:r||A("(None)")},r)))})},a):e(p,{label:l,className:w.field,children:e(f,{value:String(o??""),onChange:(e,a)=>z(r,a.value),placeholder:A("Enter")+" "+l.toLowerCase()})},a)}))}),r(y,{children:[e(g,{appearance:"secondary",onClick:l,disabled:E,children:A("Cancel")}),e(g,{appearance:"primary",onClick:async()=>{L(!0);try{await C(S),l()}catch(e){console.error("Failed to save record:",e)}finally{L(!1)}},disabled:E,children:A(E?"Saving...":"Save")})]})]})})})};export{C as RecordModal,C as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codicent-app-sdk",
3
- "version": "0.4.24",
3
+ "version": "0.4.25",
4
4
  "description": "SDK for building AI-powered applications with Codicent",
5
5
  "type": "module",
6
6
  "main": "dist/cjs/index.js",