@redi.run/redi-components 0.0.64 → 0.0.65
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/redi-components.js
CHANGED
|
@@ -12829,11 +12829,11 @@ var buildThemePalette$1 = (e) => {
|
|
|
12829
12829
|
children: n.map((h, g) => {
|
|
12830
12830
|
let _ = typeof h.accessor == "function" ? h.accessor(e) : e[h.accessor], v = h.isAction, y = i(h), b = a.includes(h.id), x = v && o, S = 0;
|
|
12831
12831
|
if (b) for (let e = 0; e < g; e++) a.includes(n[e].id) && (S += i(n[e]));
|
|
12832
|
-
let C = `py-2 px-3 text-redi-text font-normal leading-6 align-middle border-r border-solid border-r-gray-300
|
|
12832
|
+
let C = `py-2 px-3 text-redi-text font-normal leading-6 align-middle border-r border-solid border-r-gray-300 table-cell last:border-r-0 first:font-medium
|
|
12833
|
+
${x ? "" : "static"}
|
|
12833
12834
|
${v ? "border-l border-gray-300" : ""}
|
|
12834
12835
|
${b && !x ? "shadow-[2px_0_5px_-2px_rgba(0,0,0,0.1)]" : ""}
|
|
12835
12836
|
${x ? "shadow-[-2px_0_5px_-2px_rgba(0,0,0,0.1)]" : ""}
|
|
12836
|
-
${x ? t % 2 == 0 ? "bg-white" : "bg-gray-50" : ""}
|
|
12837
12837
|
${x ? "group-hover:bg-gray-100" : ""}
|
|
12838
12838
|
`, w = {
|
|
12839
12839
|
width: y,
|
|
@@ -12843,7 +12843,8 @@ var buildThemePalette$1 = (e) => {
|
|
|
12843
12843
|
...x ? {
|
|
12844
12844
|
position: "sticky",
|
|
12845
12845
|
right: 0,
|
|
12846
|
-
zIndex: 15
|
|
12846
|
+
zIndex: 15,
|
|
12847
|
+
backgroundColor: t % 2 == 0 ? "#ffffff" : "#f9fafb"
|
|
12847
12848
|
} : b ? {
|
|
12848
12849
|
position: "sticky",
|
|
12849
12850
|
left: S,
|
|
@@ -13241,7 +13242,7 @@ var AdvancedTable_module_default = {
|
|
|
13241
13242
|
...u ? {
|
|
13242
13243
|
position: "sticky",
|
|
13243
13244
|
right: 0,
|
|
13244
|
-
zIndex:
|
|
13245
|
+
zIndex: 30,
|
|
13245
13246
|
backgroundColor: "#f9fafb"
|
|
13246
13247
|
} : l ? {
|
|
13247
13248
|
position: "sticky",
|
|
@@ -104,13 +104,13 @@ function Wd(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function
|
|
|
104
104
|
${e===`icon`?w[r]:C[r]}
|
|
105
105
|
${S?`cursor-pointer`:`cursor-not-allowed opacity-60`}
|
|
106
106
|
${m||``}
|
|
107
|
-
`,...h,children:[s&&(0,n.jsxs)(`svg`,{className:`animate-spin -ml-1 mr-1 h-4 w-4 text-current`,xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,children:[(0,n.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,n.jsx)(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z`})]}),u||(0,n.jsxs)(n.Fragment,{children:[l&&a===`left`&&!s&&l,c&&e!==`icon`&&(0,n.jsx)(`span`,{children:c}),l&&a===`right`&&!s&&l]})]})},np=({loading:e,paginatedData:t,displayColumns:r,getColumnWidth:i,pinnedColumns:a,stickyActionsColumn:o,rowKey:s,editingRowId:c,enableInlineEditing:l,editValues:u,validationErrors:d,handleInputChange:f,labels:p})=>(0,n.jsx)(`tbody`,{children:e?Array.from({length:5}).map((e,t)=>(0,n.jsx)(`tr`,{className:`border-b border-solid border-gray-100`,children:r.map((e,t)=>{let s=i(e),c=a.includes(e.id),l=e.isAction&&o,u=0;if(c)for(let e=0;e<t;e++)a.includes(r[e].id)&&(u+=i(r[e]));let d={width:s,minWidth:s,maxWidth:s,...l?{position:`sticky`,right:0,zIndex:10,backgroundColor:`white`}:c?{position:`sticky`,left:u,zIndex:10,backgroundColor:`white`}:{}};return(0,n.jsx)(`td`,{className:`py-2 px-3 ${e.isAction?`bg-white border-l border-gray-200`:``} ${c&&!l?`shadow-[2px_0_5px_-2px_rgba(0,0,0,0.1)]`:``} ${l?`shadow-[-2px_0_5px_-2px_rgba(0,0,0,0.1)]`:``}`,style:d,children:(0,n.jsx)(`div`,{className:`h-4 bg-gray-200 rounded animate-pulse w-3/4`})},`skeleton-cell-${t}`)})},`skeleton-${t}`)):t.length>0?t.map((e,t)=>(0,n.jsx)(`tr`,{className:`group even:bg-gray-50 hover:bg-gray-100 border-b border-solid border-b-gray-100 odd:bg-white`,children:r.map((p,m)=>{let h=typeof p.accessor==`function`?p.accessor(e):e[p.accessor],g=p.isAction,_=i(p),v=a.includes(p.id),y=g&&o,b=0;if(v)for(let e=0;e<m;e++)a.includes(r[e].id)&&(b+=i(r[e]));let x=`py-2 px-3 text-redi-text font-normal leading-6 align-middle border-r border-solid border-r-gray-300
|
|
107
|
+
`,...h,children:[s&&(0,n.jsxs)(`svg`,{className:`animate-spin -ml-1 mr-1 h-4 w-4 text-current`,xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,children:[(0,n.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,n.jsx)(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z`})]}),u||(0,n.jsxs)(n.Fragment,{children:[l&&a===`left`&&!s&&l,c&&e!==`icon`&&(0,n.jsx)(`span`,{children:c}),l&&a===`right`&&!s&&l]})]})},np=({loading:e,paginatedData:t,displayColumns:r,getColumnWidth:i,pinnedColumns:a,stickyActionsColumn:o,rowKey:s,editingRowId:c,enableInlineEditing:l,editValues:u,validationErrors:d,handleInputChange:f,labels:p})=>(0,n.jsx)(`tbody`,{children:e?Array.from({length:5}).map((e,t)=>(0,n.jsx)(`tr`,{className:`border-b border-solid border-gray-100`,children:r.map((e,t)=>{let s=i(e),c=a.includes(e.id),l=e.isAction&&o,u=0;if(c)for(let e=0;e<t;e++)a.includes(r[e].id)&&(u+=i(r[e]));let d={width:s,minWidth:s,maxWidth:s,...l?{position:`sticky`,right:0,zIndex:10,backgroundColor:`white`}:c?{position:`sticky`,left:u,zIndex:10,backgroundColor:`white`}:{}};return(0,n.jsx)(`td`,{className:`py-2 px-3 ${e.isAction?`bg-white border-l border-gray-200`:``} ${c&&!l?`shadow-[2px_0_5px_-2px_rgba(0,0,0,0.1)]`:``} ${l?`shadow-[-2px_0_5px_-2px_rgba(0,0,0,0.1)]`:``}`,style:d,children:(0,n.jsx)(`div`,{className:`h-4 bg-gray-200 rounded animate-pulse w-3/4`})},`skeleton-cell-${t}`)})},`skeleton-${t}`)):t.length>0?t.map((e,t)=>(0,n.jsx)(`tr`,{className:`group even:bg-gray-50 hover:bg-gray-100 border-b border-solid border-b-gray-100 odd:bg-white`,children:r.map((p,m)=>{let h=typeof p.accessor==`function`?p.accessor(e):e[p.accessor],g=p.isAction,_=i(p),v=a.includes(p.id),y=g&&o,b=0;if(v)for(let e=0;e<m;e++)a.includes(r[e].id)&&(b+=i(r[e]));let x=`py-2 px-3 text-redi-text font-normal leading-6 align-middle border-r border-solid border-r-gray-300 table-cell last:border-r-0 first:font-medium
|
|
108
|
+
${y?``:`static`}
|
|
108
109
|
${g?`border-l border-gray-300`:``}
|
|
109
110
|
${v&&!y?`shadow-[2px_0_5px_-2px_rgba(0,0,0,0.1)]`:``}
|
|
110
111
|
${y?`shadow-[-2px_0_5px_-2px_rgba(0,0,0,0.1)]`:``}
|
|
111
|
-
${y?t%2==0?`bg-white`:`bg-gray-50`:``}
|
|
112
112
|
${y?`group-hover:bg-gray-100`:``}
|
|
113
|
-
`,S={width:_,minWidth:_,maxWidth:_,overflowWrap:`break-word`,...y?{position:`sticky`,right:0,zIndex:15}:v?{position:`sticky`,left:b,zIndex:10,backgroundColor:`inherit`}:{}},C=c===(typeof s==`function`?s(e):e[s]);if(l&&C&&p.editable){let e=u[p.id]??h,t=d[p.id];return(0,n.jsx)(`td`,{className:`${x} p-1`,style:S,children:(0,n.jsxs)(`div`,{className:`flex flex-col`,children:[p.inputType===`select`?(0,n.jsxs)(`select`,{className:`w-full border ${t?`border-red-500`:`border-gray-300`} rounded px-2 py-1 text-sm focus:outline-none focus:ring-1 focus:ring-redi-primary`,value:e,onChange:e=>f(p.id,e.target.value),onClick:e=>e.stopPropagation(),children:[(0,n.jsx)(`option`,{value:``,children:`Select...`}),p.options?.map(e=>(0,n.jsx)(`option`,{value:e.value,children:e.label},e.value))]}):(0,n.jsx)(`input`,{type:p.inputType||`text`,className:`w-full border ${t?`border-red-500`:`border-gray-300`} rounded px-2 py-1 text-sm focus:outline-none focus:ring-1 focus:ring-redi-primary`,value:e,onChange:e=>f(p.id,e.target.value),onClick:e=>e.stopPropagation()}),t&&(0,n.jsx)(`span`,{className:`text-xs text-red-500 mt-1`,children:t})]})},p.id)}return p.render?(0,n.jsx)(`td`,{className:x,style:S,children:p.render({value:h,row:e,column:p,index:t})},p.id):(0,n.jsx)(`td`,{className:x,style:S,children:Jf(h)},p.id)})},t)):(0,n.jsx)(`tr`,{children:(0,n.jsx)(`td`,{colSpan:r.length,className:`py-12 text-center text-gray-500`,children:(0,n.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2`,children:[(0,n.jsx)(`svg`,{className:`w-12 h-12 text-gray-300`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,n.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.5,d:`M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4`})}),(0,n.jsx)(`span`,{className:`text-sm font-medium`,children:p.noData})]})})})});let rp=({color:e,size:t=24})=>(0,n.jsx)(`svg`,{fill:e,stroke:`currentColor`,viewBox:`0 0 24 24`,width:t,height:t,children:(0,n.jsx)(`path`,{fillRule:`evenodd`,d:`M3 3a1 1 0 011-1h12a1 1 0 011 1v3a1 1 0 01-.293.707L12 11.414V15a1 1 0 01-.293.707l-2 2A1 1 0 018 17v-5.586L3.293 6.707A1 1 0 013 6V3z`,clipRule:`evenodd`,fill:`currentColor`})});var ip={controls:`_controls_1pwn9_1`,leftControls:`_leftControls_1pwn9_10`,rightControls:`_rightControls_1pwn9_16`,configButton:`_configButton_1pwn9_23`,configIcon:`_configIcon_1pwn9_42`,configSection:`_configSection_1pwn9_49`,configSectionTitle:`_configSectionTitle_1pwn9_57`,configOptions:`_configOptions_1pwn9_66`,configOption:`_configOption_1pwn9_66`,actionButton:`_actionButton_1pwn9_91`,export:`_export_1pwn9_110`,reset:`_reset_1pwn9_120`,buttonIcon:`_buttonIcon_1pwn9_130`,filtersContainer:`_filtersContainer_1pwn9_137`,active:`_active_1pwn9_145`,filtersRow:`_filtersRow_1pwn9_149`,filterGroup:`_filterGroup_1pwn9_156`,filterLabel:`_filterLabel_1pwn9_162`,filterDropdown:`_filterDropdown_1pwn9_172`,filterDropdownButton:`_filterDropdownButton_1pwn9_177`,filterDropdownIcon:`_filterDropdownIcon_1pwn9_200`,filterModalHeader:`_filterModalHeader_1pwn9_212`,filterSearchInput:`_filterSearchInput_1pwn9_217`,filterOptions:`_filterOptions_1pwn9_231`,filterOption:`_filterOption_1pwn9_231`,selected:`_selected_1pwn9_250`,filterOptionCheckbox:`_filterOptionCheckbox_1pwn9_254`,filterOptionLabel:`_filterOptionLabel_1pwn9_260`,filterOptionCount:`_filterOptionCount_1pwn9_266`,filterModalActions:`_filterModalActions_1pwn9_275`,filterClearButton:`_filterClearButton_1pwn9_284`,filterApplyButton:`_filterApplyButton_1pwn9_285`,tableWrapper:`_tableWrapper_1pwn9_315`,table:`_table_1pwn9_315`,header:`_header_1pwn9_332`,dragging:`_dragging_1pwn9_349`,dragOver:`_dragOver_1pwn9_354`,headerContent:`_headerContent_1pwn9_359`,dragHandle:`_dragHandle_1pwn9_367`,columnTitle:`_columnTitle_1pwn9_384`,sortable:`_sortable_1pwn9_391`,sortIcon:`_sortIcon_1pwn9_408`,filterButton:`_filterButton_1pwn9_415`,filterButtonIcon:`_filterButtonIcon_1pwn9_451`,filterModal:`_filterModal_1pwn9_212`,row:`_row_1pwn9_474`,cell:`_cell_1pwn9_486`,statusBadge:`_statusBadge_1pwn9_507`,statusActive:`_statusActive_1pwn9_517`,statusInactive:`_statusInactive_1pwn9_522`,statusPending:`_statusPending_1pwn9_527`,statusCompleted:`_statusCompleted_1pwn9_532`,statusDraft:`_statusDraft_1pwn9_537`,pagination:`_pagination_1pwn9_543`,paginationInfo:`_paginationInfo_1pwn9_553`,paginationControls:`_paginationControls_1pwn9_560`,pageSizeSelect:`_pageSizeSelect_1pwn9_575`,pageButtons:`_pageButtons_1pwn9_591`,pageButton:`_pageButton_1pwn9_591`,exportButton:`_exportButton_1pwn9_659`,resetButton:`_resetButton_1pwn9_660`,filterModalSlideIn:`_filterModalSlideIn_1pwn9_1`,shimmer:`_shimmer_1pwn9_1`,columnCheckboxes:`_columnCheckboxes_1pwn9_1195`},ap=({option:e,selectedValues:t,handleOptionToggle:r})=>(0,n.jsxs)(`div`,{className:`${ip.filterOption} ${t.includes(e.value)?ip.selected:``}`,onClick:()=>r(e),children:[(0,n.jsx)(`input`,{type:`checkbox`,className:ip.filterOptionCheckbox,checked:t.includes(e.value),onChange:()=>r(e),onClick:e=>e.stopPropagation()}),(0,n.jsx)(`span`,{className:ip.filterOptionLabel,children:e.value}),(0,n.jsx)(`span`,{className:ip.filterOptionCount,children:e.count})]},e.value),op=({label:e,options:r,textValue:i,selectedValues:a,onTextChange:o,onSelectionChange:s,onClose:c,loading:l=!1,isServerRefetch:u=!1})=>{let[d,f]=(0,t.useState)(``),p=(0,t.useRef)(null),m=r.filter(e=>e.value.toLowerCase().includes(d.toLowerCase())||e.label.toLowerCase().includes(d.toLowerCase())),h=e=>{let t=a.includes(e.value)?a.filter(t=>t!==e.value):[...a,e.value];s(t)},g=()=>{let e=m.map(e=>e.value);s(e)},_=()=>{s([]),o(``)};return(0,t.useEffect)(()=>{let e=e=>{p.current&&!p.current.contains(e.target)&&c()};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[c]),(0,n.jsxs)(`div`,{className:ip.filterModal,ref:p,children:[(0,n.jsx)(`div`,{className:ip.filterModalHeader,children:(0,n.jsx)(`input`,{type:`text`,className:ip.filterSearchInput,placeholder:`Buscar texto en ${e.toLowerCase()}...`,value:d,onChange:e=>f(e.target.value),style:{marginTop:`8px`}})}),(0,n.jsxs)(`div`,{className:ip.filterOptions,children:[(0,n.jsxs)(`div`,{className:ip.filterOption,style:{borderBottom:`1px solid #e5e7eb`,marginBottom:`4px`,paddingBottom:`8px`},children:[(0,n.jsx)(Q,{onClick:g,size:`small`,level:`tertiary`,children:`Seleccionar todo`}),(0,n.jsx)(Q,{onClick:_,size:`small`,level:`tertiary`,children:`Limpiar todo`})]}),l?(0,n.jsx)(`div`,{className:ip.filterOption,children:(0,n.jsx)(`span`,{className:ip.filterOptionLabel,children:`Cargando opciones...`})}):m.length>0?m.map((e,t)=>{let r=m[t-1],i=e.group&&(!r||r.group!==e.group);return(0,n.jsxs)(`div`,{children:[i&&(0,n.jsx)(`div`,{className:`px-3 py-1 text-xs font-bold text-gray-500 bg-gray-50 uppercase tracking-wider`,children:e.group}),(0,n.jsx)(ap,{option:e,selectedValues:a,handleOptionToggle:h})]},e.value)}):(0,n.jsx)(`div`,{className:ip.filterOption,children:(0,n.jsx)(`span`,{className:ip.filterOptionLabel,children:`No se encontraron opciones`})})]}),(0,n.jsxs)(`div`,{className:ip.filterModalActions,children:[(0,n.jsx)(Q,{onClick:_,level:`tertiary`,children:`Limpiar todo`}),u?(0,n.jsx)(Q,{onClick:()=>{if(d.trim()){let e=d.trim();a.includes(e)||s([...a,e])}c()},level:`primary`,children:`Buscar Avanzado`}):(0,n.jsxs)(Q,{onClick:c,level:`primary`,children:[`Aplicar (`,a.length+(i?1:0),`)`]})]})]})},sp=({displayColumns:e,getColumnWidth:r,pinnedColumns:i,stickyActionsColumn:a,enableColumnReordering:o,handleColumnReorder:s,sortConfig:c,handleSort:l,enableSorting:u,filters:d,handleFilter:f,fetchData:p,data:m,paginatedData:h,enableColumnResizing:g,handleColumnResize:_,tableColumns:v,rowKey:y,selectedRows:b,handleSelectAll:x,stateColumnOrder:S})=>{let[C,w]=(0,t.useState)(null),[T,E]=(0,t.useState)(null),[D,O]=(0,t.useState)(null),[k,A]=(0,t.useState)({}),[j,M]=(0,t.useState)({}),N=(0,t.useRef)(null);(0,t.useEffect)(()=>{let e=e=>{if(!N.current)return;let{columnId:t,startX:n,startWidth:r}=N.current,i=e.clientX-n;_(t,r+i)},t=()=>{N.current=null,document.body.style.cursor=`default`,document.body.style.userSelect=`auto`};if(g)return document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,t),()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,t)}},[g,_]);let ee=(e,t,n)=>{e.preventDefault(),e.stopPropagation(),N.current={columnId:t,startX:e.clientX,startWidth:n},document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`},te=(e,t)=>{w(t),e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/html`,``)},ne=(e,t)=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`,E(t)},re=()=>{E(null)},P=(t,n)=>{if(t.preventDefault(),C===null)return;let r=e[C].id,i=e[n].id;if(r===i){w(null),E(null);return}let a=t.currentTarget.getBoundingClientRect(),o=t.clientX-a.left>a.width/2,c=[...S],l=c.indexOf(r),u=c.indexOf(i);l===-1||u===-1||(c.splice(l,1),u=c.indexOf(i),o?c.splice(u+1,0,r):c.splice(u,0,r),s(c),w(null),E(null))},ie=()=>{w(null),E(null)},F=(0,t.useCallback)(async e=>{let t=v.find(t=>t.id===e);if(t?.fetchColumn&&!k[e]){M(t=>({...t,[e]:!0}));try{let n=await t.fetchColumn();A(t=>({...t,[e]:n}))}catch(t){console.error(`Failed to load options for column ${e}:`,t)}finally{M(t=>({...t,[e]:!1}))}}},[v,k]),ae=e=>{let t=D!==e;O(t?e:null),t&&F(e)},oe=(0,t.useCallback)(e=>{let t=v.find(t=>t.id===e);if(!t)return[];if(t.fetchColumn&&k[e])return k[e];if(t.fetchColumn&&!k[e])return[];let n=p?h:m,r=n.filter(t=>Object.entries(d).every(([n,r])=>{if(n===e||!r.value)return!0;let i=v.find(e=>e.id===n);if(!i)return!0;let a=typeof i.accessor==`function`?i.accessor(t):t[i.accessor],o=String(a||``).toLowerCase(),s=!0;return r.type===`text`&&(s=o.includes(String(r.value).toLowerCase())),r.type===`select`&&(s=o===String(r.value).toLowerCase()),r.type===`multiselect`&&Array.isArray(r.value)&&(s=r.value.some(e=>o===String(e).toLowerCase())),s})),i=new Map;r.forEach(e=>{let n=typeof t.accessor==`function`?t.accessor(e):e[t.accessor],r=Jf(n);i.set(r,(i.get(r)||0)+1)});let a=new Map;n.forEach(e=>{let n=typeof t.accessor==`function`?t.accessor(e):e[t.accessor],r=Jf(n);a.set(r,(a.get(r)||0)+1)});let o=[],s=[];return a.forEach((e,t)=>{let n=i.get(t);n!==void 0&&n>0?o.push({value:t,count:n,label:`${t} (${n})`,group:`Disponibles`}):s.push({value:t,count:e,label:`${t} (0)`,group:`Otros`})}),o.sort((e,t)=>e.value.localeCompare(t.value)),s.sort((e,t)=>e.value.localeCompare(t.value)),s.length===0?o.map(e=>({...e,group:void 0})):[...o,...s]},[m,h,p,d,v,k]);return(0,n.jsx)(`thead`,{children:(0,n.jsx)(`tr`,{children:e.map((t,s)=>{let m=r(t),_=i.includes(t.id),v=t.isAction&&a,S=0;if(_)for(let t=0;t<s;t++)i.includes(e[t].id)&&(S+=r(e[t]));let w={width:m,minWidth:m,maxWidth:m,...v?{position:`sticky`,right:0,zIndex:25,backgroundColor:`#f9fafb`}:_?{position:`sticky`,left:S,zIndex:20,backgroundColor:`#f9fafb`}:{}};return(0,n.jsx)(`th`,{className:`bg-gray-50 border-b border-solid border-gray-200 text-left font-semibold text-redi-text p-0 sticky top-0 z-10 select-none hover:bg-gray-200
|
|
113
|
+
`,S={width:_,minWidth:_,maxWidth:_,overflowWrap:`break-word`,...y?{position:`sticky`,right:0,zIndex:15,backgroundColor:t%2==0?`#ffffff`:`#f9fafb`}:v?{position:`sticky`,left:b,zIndex:10,backgroundColor:`inherit`}:{}},C=c===(typeof s==`function`?s(e):e[s]);if(l&&C&&p.editable){let e=u[p.id]??h,t=d[p.id];return(0,n.jsx)(`td`,{className:`${x} p-1`,style:S,children:(0,n.jsxs)(`div`,{className:`flex flex-col`,children:[p.inputType===`select`?(0,n.jsxs)(`select`,{className:`w-full border ${t?`border-red-500`:`border-gray-300`} rounded px-2 py-1 text-sm focus:outline-none focus:ring-1 focus:ring-redi-primary`,value:e,onChange:e=>f(p.id,e.target.value),onClick:e=>e.stopPropagation(),children:[(0,n.jsx)(`option`,{value:``,children:`Select...`}),p.options?.map(e=>(0,n.jsx)(`option`,{value:e.value,children:e.label},e.value))]}):(0,n.jsx)(`input`,{type:p.inputType||`text`,className:`w-full border ${t?`border-red-500`:`border-gray-300`} rounded px-2 py-1 text-sm focus:outline-none focus:ring-1 focus:ring-redi-primary`,value:e,onChange:e=>f(p.id,e.target.value),onClick:e=>e.stopPropagation()}),t&&(0,n.jsx)(`span`,{className:`text-xs text-red-500 mt-1`,children:t})]})},p.id)}return p.render?(0,n.jsx)(`td`,{className:x,style:S,children:p.render({value:h,row:e,column:p,index:t})},p.id):(0,n.jsx)(`td`,{className:x,style:S,children:Jf(h)},p.id)})},t)):(0,n.jsx)(`tr`,{children:(0,n.jsx)(`td`,{colSpan:r.length,className:`py-12 text-center text-gray-500`,children:(0,n.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2`,children:[(0,n.jsx)(`svg`,{className:`w-12 h-12 text-gray-300`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,n.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.5,d:`M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4`})}),(0,n.jsx)(`span`,{className:`text-sm font-medium`,children:p.noData})]})})})});let rp=({color:e,size:t=24})=>(0,n.jsx)(`svg`,{fill:e,stroke:`currentColor`,viewBox:`0 0 24 24`,width:t,height:t,children:(0,n.jsx)(`path`,{fillRule:`evenodd`,d:`M3 3a1 1 0 011-1h12a1 1 0 011 1v3a1 1 0 01-.293.707L12 11.414V15a1 1 0 01-.293.707l-2 2A1 1 0 018 17v-5.586L3.293 6.707A1 1 0 013 6V3z`,clipRule:`evenodd`,fill:`currentColor`})});var ip={controls:`_controls_1pwn9_1`,leftControls:`_leftControls_1pwn9_10`,rightControls:`_rightControls_1pwn9_16`,configButton:`_configButton_1pwn9_23`,configIcon:`_configIcon_1pwn9_42`,configSection:`_configSection_1pwn9_49`,configSectionTitle:`_configSectionTitle_1pwn9_57`,configOptions:`_configOptions_1pwn9_66`,configOption:`_configOption_1pwn9_66`,actionButton:`_actionButton_1pwn9_91`,export:`_export_1pwn9_110`,reset:`_reset_1pwn9_120`,buttonIcon:`_buttonIcon_1pwn9_130`,filtersContainer:`_filtersContainer_1pwn9_137`,active:`_active_1pwn9_145`,filtersRow:`_filtersRow_1pwn9_149`,filterGroup:`_filterGroup_1pwn9_156`,filterLabel:`_filterLabel_1pwn9_162`,filterDropdown:`_filterDropdown_1pwn9_172`,filterDropdownButton:`_filterDropdownButton_1pwn9_177`,filterDropdownIcon:`_filterDropdownIcon_1pwn9_200`,filterModalHeader:`_filterModalHeader_1pwn9_212`,filterSearchInput:`_filterSearchInput_1pwn9_217`,filterOptions:`_filterOptions_1pwn9_231`,filterOption:`_filterOption_1pwn9_231`,selected:`_selected_1pwn9_250`,filterOptionCheckbox:`_filterOptionCheckbox_1pwn9_254`,filterOptionLabel:`_filterOptionLabel_1pwn9_260`,filterOptionCount:`_filterOptionCount_1pwn9_266`,filterModalActions:`_filterModalActions_1pwn9_275`,filterClearButton:`_filterClearButton_1pwn9_284`,filterApplyButton:`_filterApplyButton_1pwn9_285`,tableWrapper:`_tableWrapper_1pwn9_315`,table:`_table_1pwn9_315`,header:`_header_1pwn9_332`,dragging:`_dragging_1pwn9_349`,dragOver:`_dragOver_1pwn9_354`,headerContent:`_headerContent_1pwn9_359`,dragHandle:`_dragHandle_1pwn9_367`,columnTitle:`_columnTitle_1pwn9_384`,sortable:`_sortable_1pwn9_391`,sortIcon:`_sortIcon_1pwn9_408`,filterButton:`_filterButton_1pwn9_415`,filterButtonIcon:`_filterButtonIcon_1pwn9_451`,filterModal:`_filterModal_1pwn9_212`,row:`_row_1pwn9_474`,cell:`_cell_1pwn9_486`,statusBadge:`_statusBadge_1pwn9_507`,statusActive:`_statusActive_1pwn9_517`,statusInactive:`_statusInactive_1pwn9_522`,statusPending:`_statusPending_1pwn9_527`,statusCompleted:`_statusCompleted_1pwn9_532`,statusDraft:`_statusDraft_1pwn9_537`,pagination:`_pagination_1pwn9_543`,paginationInfo:`_paginationInfo_1pwn9_553`,paginationControls:`_paginationControls_1pwn9_560`,pageSizeSelect:`_pageSizeSelect_1pwn9_575`,pageButtons:`_pageButtons_1pwn9_591`,pageButton:`_pageButton_1pwn9_591`,exportButton:`_exportButton_1pwn9_659`,resetButton:`_resetButton_1pwn9_660`,filterModalSlideIn:`_filterModalSlideIn_1pwn9_1`,shimmer:`_shimmer_1pwn9_1`,columnCheckboxes:`_columnCheckboxes_1pwn9_1195`},ap=({option:e,selectedValues:t,handleOptionToggle:r})=>(0,n.jsxs)(`div`,{className:`${ip.filterOption} ${t.includes(e.value)?ip.selected:``}`,onClick:()=>r(e),children:[(0,n.jsx)(`input`,{type:`checkbox`,className:ip.filterOptionCheckbox,checked:t.includes(e.value),onChange:()=>r(e),onClick:e=>e.stopPropagation()}),(0,n.jsx)(`span`,{className:ip.filterOptionLabel,children:e.value}),(0,n.jsx)(`span`,{className:ip.filterOptionCount,children:e.count})]},e.value),op=({label:e,options:r,textValue:i,selectedValues:a,onTextChange:o,onSelectionChange:s,onClose:c,loading:l=!1,isServerRefetch:u=!1})=>{let[d,f]=(0,t.useState)(``),p=(0,t.useRef)(null),m=r.filter(e=>e.value.toLowerCase().includes(d.toLowerCase())||e.label.toLowerCase().includes(d.toLowerCase())),h=e=>{let t=a.includes(e.value)?a.filter(t=>t!==e.value):[...a,e.value];s(t)},g=()=>{let e=m.map(e=>e.value);s(e)},_=()=>{s([]),o(``)};return(0,t.useEffect)(()=>{let e=e=>{p.current&&!p.current.contains(e.target)&&c()};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[c]),(0,n.jsxs)(`div`,{className:ip.filterModal,ref:p,children:[(0,n.jsx)(`div`,{className:ip.filterModalHeader,children:(0,n.jsx)(`input`,{type:`text`,className:ip.filterSearchInput,placeholder:`Buscar texto en ${e.toLowerCase()}...`,value:d,onChange:e=>f(e.target.value),style:{marginTop:`8px`}})}),(0,n.jsxs)(`div`,{className:ip.filterOptions,children:[(0,n.jsxs)(`div`,{className:ip.filterOption,style:{borderBottom:`1px solid #e5e7eb`,marginBottom:`4px`,paddingBottom:`8px`},children:[(0,n.jsx)(Q,{onClick:g,size:`small`,level:`tertiary`,children:`Seleccionar todo`}),(0,n.jsx)(Q,{onClick:_,size:`small`,level:`tertiary`,children:`Limpiar todo`})]}),l?(0,n.jsx)(`div`,{className:ip.filterOption,children:(0,n.jsx)(`span`,{className:ip.filterOptionLabel,children:`Cargando opciones...`})}):m.length>0?m.map((e,t)=>{let r=m[t-1],i=e.group&&(!r||r.group!==e.group);return(0,n.jsxs)(`div`,{children:[i&&(0,n.jsx)(`div`,{className:`px-3 py-1 text-xs font-bold text-gray-500 bg-gray-50 uppercase tracking-wider`,children:e.group}),(0,n.jsx)(ap,{option:e,selectedValues:a,handleOptionToggle:h})]},e.value)}):(0,n.jsx)(`div`,{className:ip.filterOption,children:(0,n.jsx)(`span`,{className:ip.filterOptionLabel,children:`No se encontraron opciones`})})]}),(0,n.jsxs)(`div`,{className:ip.filterModalActions,children:[(0,n.jsx)(Q,{onClick:_,level:`tertiary`,children:`Limpiar todo`}),u?(0,n.jsx)(Q,{onClick:()=>{if(d.trim()){let e=d.trim();a.includes(e)||s([...a,e])}c()},level:`primary`,children:`Buscar Avanzado`}):(0,n.jsxs)(Q,{onClick:c,level:`primary`,children:[`Aplicar (`,a.length+(i?1:0),`)`]})]})]})},sp=({displayColumns:e,getColumnWidth:r,pinnedColumns:i,stickyActionsColumn:a,enableColumnReordering:o,handleColumnReorder:s,sortConfig:c,handleSort:l,enableSorting:u,filters:d,handleFilter:f,fetchData:p,data:m,paginatedData:h,enableColumnResizing:g,handleColumnResize:_,tableColumns:v,rowKey:y,selectedRows:b,handleSelectAll:x,stateColumnOrder:S})=>{let[C,w]=(0,t.useState)(null),[T,E]=(0,t.useState)(null),[D,O]=(0,t.useState)(null),[k,A]=(0,t.useState)({}),[j,M]=(0,t.useState)({}),N=(0,t.useRef)(null);(0,t.useEffect)(()=>{let e=e=>{if(!N.current)return;let{columnId:t,startX:n,startWidth:r}=N.current,i=e.clientX-n;_(t,r+i)},t=()=>{N.current=null,document.body.style.cursor=`default`,document.body.style.userSelect=`auto`};if(g)return document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,t),()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,t)}},[g,_]);let ee=(e,t,n)=>{e.preventDefault(),e.stopPropagation(),N.current={columnId:t,startX:e.clientX,startWidth:n},document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`},te=(e,t)=>{w(t),e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/html`,``)},ne=(e,t)=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`,E(t)},re=()=>{E(null)},P=(t,n)=>{if(t.preventDefault(),C===null)return;let r=e[C].id,i=e[n].id;if(r===i){w(null),E(null);return}let a=t.currentTarget.getBoundingClientRect(),o=t.clientX-a.left>a.width/2,c=[...S],l=c.indexOf(r),u=c.indexOf(i);l===-1||u===-1||(c.splice(l,1),u=c.indexOf(i),o?c.splice(u+1,0,r):c.splice(u,0,r),s(c),w(null),E(null))},ie=()=>{w(null),E(null)},F=(0,t.useCallback)(async e=>{let t=v.find(t=>t.id===e);if(t?.fetchColumn&&!k[e]){M(t=>({...t,[e]:!0}));try{let n=await t.fetchColumn();A(t=>({...t,[e]:n}))}catch(t){console.error(`Failed to load options for column ${e}:`,t)}finally{M(t=>({...t,[e]:!1}))}}},[v,k]),ae=e=>{let t=D!==e;O(t?e:null),t&&F(e)},oe=(0,t.useCallback)(e=>{let t=v.find(t=>t.id===e);if(!t)return[];if(t.fetchColumn&&k[e])return k[e];if(t.fetchColumn&&!k[e])return[];let n=p?h:m,r=n.filter(t=>Object.entries(d).every(([n,r])=>{if(n===e||!r.value)return!0;let i=v.find(e=>e.id===n);if(!i)return!0;let a=typeof i.accessor==`function`?i.accessor(t):t[i.accessor],o=String(a||``).toLowerCase(),s=!0;return r.type===`text`&&(s=o.includes(String(r.value).toLowerCase())),r.type===`select`&&(s=o===String(r.value).toLowerCase()),r.type===`multiselect`&&Array.isArray(r.value)&&(s=r.value.some(e=>o===String(e).toLowerCase())),s})),i=new Map;r.forEach(e=>{let n=typeof t.accessor==`function`?t.accessor(e):e[t.accessor],r=Jf(n);i.set(r,(i.get(r)||0)+1)});let a=new Map;n.forEach(e=>{let n=typeof t.accessor==`function`?t.accessor(e):e[t.accessor],r=Jf(n);a.set(r,(a.get(r)||0)+1)});let o=[],s=[];return a.forEach((e,t)=>{let n=i.get(t);n!==void 0&&n>0?o.push({value:t,count:n,label:`${t} (${n})`,group:`Disponibles`}):s.push({value:t,count:e,label:`${t} (0)`,group:`Otros`})}),o.sort((e,t)=>e.value.localeCompare(t.value)),s.sort((e,t)=>e.value.localeCompare(t.value)),s.length===0?o.map(e=>({...e,group:void 0})):[...o,...s]},[m,h,p,d,v,k]);return(0,n.jsx)(`thead`,{children:(0,n.jsx)(`tr`,{children:e.map((t,s)=>{let m=r(t),_=i.includes(t.id),v=t.isAction&&a,S=0;if(_)for(let t=0;t<s;t++)i.includes(e[t].id)&&(S+=r(e[t]));let w={width:m,minWidth:m,maxWidth:m,...v?{position:`sticky`,right:0,zIndex:30,backgroundColor:`#f9fafb`}:_?{position:`sticky`,left:S,zIndex:20,backgroundColor:`#f9fafb`}:{}};return(0,n.jsx)(`th`,{className:`bg-gray-50 border-b border-solid border-gray-200 text-left font-semibold text-redi-text p-0 sticky top-0 z-10 select-none hover:bg-gray-200
|
|
114
114
|
${C===s?`opacity-50 bg-gray-300`:``}
|
|
115
115
|
${T===s?`bg-redi-primary-bg border-l border-solid border-redi-primary`:``}
|
|
116
116
|
${_&&!v?`shadow-[2px_0_5px_-2px_rgba(0,0,0,0.1)]`:``}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redi.run/redi-components",
|
|
3
3
|
"description": "This project was created to define the style of the UI and improve the UX in all projects from REDI",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.65",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Jonathan Manchego Sosa",
|