@redi.run/redi-components 0.0.65 → 0.0.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/redi-components.js +21 -11
- package/dist/redi-components.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -264,6 +264,7 @@ export declare interface Column<T> {
|
|
|
264
264
|
draggable?: boolean;
|
|
265
265
|
isAction?: boolean;
|
|
266
266
|
shouldBeRefetch?: boolean;
|
|
267
|
+
filterLabelAccessor?: keyof T | ((row: T) => string);
|
|
267
268
|
fetchColumn?: () => Promise<FilterOption[]>;
|
|
268
269
|
editable?: boolean;
|
|
269
270
|
inputType?: 'text' | 'number' | 'select' | 'date';
|
package/dist/redi-components.js
CHANGED
|
@@ -13012,7 +13012,7 @@ var AdvancedTable_module_default = {
|
|
|
13012
13012
|
}),
|
|
13013
13013
|
/* @__PURE__ */ jsx("span", {
|
|
13014
13014
|
className: AdvancedTable_module_default.filterOptionLabel,
|
|
13015
|
-
children: e.
|
|
13015
|
+
children: e.label
|
|
13016
13016
|
}),
|
|
13017
13017
|
/* @__PURE__ */ jsx("span", {
|
|
13018
13018
|
className: AdvancedTable_module_default.filterOptionCount,
|
|
@@ -13198,26 +13198,36 @@ var AdvancedTable_module_default = {
|
|
|
13198
13198
|
return i.type === "text" && (c = s.includes(String(i.value).toLowerCase())), i.type === "select" && (c = s === String(i.value).toLowerCase()), i.type === "multiselect" && Array.isArray(i.value) && (c = i.value.some((e) => s === String(e).toLowerCase())), c;
|
|
13199
13199
|
})), a = /* @__PURE__ */ new Map();
|
|
13200
13200
|
i.forEach((e) => {
|
|
13201
|
-
let n = typeof t.accessor == "function" ? t.accessor(e) : e[t.accessor], i = formatCellValue(n);
|
|
13202
|
-
|
|
13201
|
+
let n = typeof t.accessor == "function" ? t.accessor(e) : e[t.accessor], i = formatCellValue(n), o = i;
|
|
13202
|
+
t.filterLabelAccessor && (o = typeof t.filterLabelAccessor == "function" ? t.filterLabelAccessor(e) : String(e[t.filterLabelAccessor]));
|
|
13203
|
+
let s = a.get(i);
|
|
13204
|
+
s ? s.count += 1 : a.set(i, {
|
|
13205
|
+
count: 1,
|
|
13206
|
+
label: o
|
|
13207
|
+
});
|
|
13203
13208
|
});
|
|
13204
13209
|
let o = /* @__PURE__ */ new Map();
|
|
13205
13210
|
n.forEach((e) => {
|
|
13206
|
-
let n = typeof t.accessor == "function" ? t.accessor(e) : e[t.accessor], i = formatCellValue(n);
|
|
13207
|
-
|
|
13211
|
+
let n = typeof t.accessor == "function" ? t.accessor(e) : e[t.accessor], i = formatCellValue(n), a = i;
|
|
13212
|
+
t.filterLabelAccessor && (a = typeof t.filterLabelAccessor == "function" ? t.filterLabelAccessor(e) : String(e[t.filterLabelAccessor]));
|
|
13213
|
+
let s = o.get(i);
|
|
13214
|
+
s ? s.count += 1 : o.set(i, {
|
|
13215
|
+
count: 1,
|
|
13216
|
+
label: a
|
|
13217
|
+
});
|
|
13208
13218
|
});
|
|
13209
13219
|
let s = [], c = [];
|
|
13210
13220
|
return o.forEach((e, t) => {
|
|
13211
|
-
let n = a.get(t);
|
|
13212
|
-
|
|
13221
|
+
let n = a.get(t), i = n ? n.count : 0, o = e.label;
|
|
13222
|
+
i > 0 ? s.push({
|
|
13213
13223
|
value: t,
|
|
13214
|
-
count:
|
|
13215
|
-
label: `${
|
|
13224
|
+
count: i,
|
|
13225
|
+
label: `${o} (${i})`,
|
|
13216
13226
|
group: "Disponibles"
|
|
13217
13227
|
}) : c.push({
|
|
13218
13228
|
value: t,
|
|
13219
|
-
count: e,
|
|
13220
|
-
label: `${
|
|
13229
|
+
count: e.count,
|
|
13230
|
+
label: `${o} (0)`,
|
|
13221
13231
|
group: "Otros"
|
|
13222
13232
|
});
|
|
13223
13233
|
}), s.sort((e, t) => e.value.localeCompare(t.value)), c.sort((e, t) => e.value.localeCompare(t.value)), c.length === 0 ? s.map((e) => ({
|
|
@@ -110,7 +110,7 @@ function Wd(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function
|
|
|
110
110
|
${v&&!y?`shadow-[2px_0_5px_-2px_rgba(0,0,0,0.1)]`:``}
|
|
111
111
|
${y?`shadow-[-2px_0_5px_-2px_rgba(0,0,0,0.1)]`:``}
|
|
112
112
|
${y?`group-hover:bg-gray-100`:``}
|
|
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
|
|
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.label}),(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),a=r;t.filterLabelAccessor&&(a=typeof t.filterLabelAccessor==`function`?t.filterLabelAccessor(e):String(e[t.filterLabelAccessor]));let o=i.get(r);o?o.count+=1:i.set(r,{count:1,label:a})});let a=new Map;n.forEach(e=>{let n=typeof t.accessor==`function`?t.accessor(e):e[t.accessor],r=Jf(n),i=r;t.filterLabelAccessor&&(i=typeof t.filterLabelAccessor==`function`?t.filterLabelAccessor(e):String(e[t.filterLabelAccessor]));let o=a.get(r);o?o.count+=1:a.set(r,{count:1,label:i})});let o=[],s=[];return a.forEach((e,t)=>{let n=i.get(t),r=n?n.count:0,a=e.label;r>0?o.push({value:t,count:r,label:`${a} (${r})`,group:`Disponibles`}):s.push({value:t,count:e.count,label:`${a} (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.67",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Jonathan Manchego Sosa",
|