@pixstella/components 0.3.0 → 0.3.1
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/COPY-PASTE.md +109 -0
- package/README.md +9 -75
- package/dist/app/components/Dashboard/dashboardRegistry.cjs +1 -1
- package/dist/app/components/Dashboard/dashboardRegistry.mjs +202 -201
- package/dist/app/components/Table/DataTable.cjs +1 -1
- package/dist/app/components/Table/DataTable.mjs +46 -49
- package/dist/app/components/ai/ConfidenceSuggestions/ConfidenceSuggestions.cjs +1 -1
- package/dist/app/components/ai/ConfidenceSuggestions/ConfidenceSuggestions.mjs +53 -53
- package/dist/app/components/ai/ProposalCard/ProposalCard.cjs +1 -1
- package/dist/app/components/ai/ProposalCard/ProposalCard.mjs +227 -227
- package/dist/app/components/ai/ReviewTable/ReviewTable.cjs +1 -1
- package/dist/app/components/ai/ReviewTable/ReviewTable.mjs +81 -81
- package/dist/app/components/ai/SuggestionChecklist/SuggestionChecklist.cjs +1 -1
- package/dist/app/components/ai/SuggestionChecklist/SuggestionChecklist.mjs +15 -14
- package/dist/app/components/ui/AuthSection/AuthSection.cjs +1 -1
- package/dist/app/components/ui/AuthSection/AuthSection.mjs +19 -18
- package/dist/app/components/ui/Checkbox/Checkbox.cjs +1 -0
- package/dist/app/components/ui/Checkbox/Checkbox.css +1 -0
- package/dist/app/components/ui/Checkbox/Checkbox.mjs +87 -0
- package/dist/app/components/ui/DataGrid/DataGrid.cjs +1 -1
- package/dist/app/components/ui/DataGrid/DataGrid.mjs +196 -199
- package/dist/app/components/ui/PreviewConfirmDialog/PreviewConfirmDialog.cjs +1 -1
- package/dist/app/components/ui/PreviewConfirmDialog/PreviewConfirmDialog.mjs +47 -48
- package/dist/browser/pixstella.esm.js +70 -70
- package/dist/browser/pixstella.standalone.js +72 -72
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +32 -1
- package/dist/index.d.ts +32 -1
- package/dist/index.mjs +2886 -2884
- package/dist/registry/files/174512e8f294ad2f +101 -0
- package/dist/registry/files/4c7e419c8caf02c3 +119 -0
- package/dist/registry/files/{f23e788832b45fc0 → 67ac8b4abe3fc564} +2 -1
- package/dist/registry/files/{e84f443f3fc3f261 → 995feaa023211faf} +4 -8
- package/dist/registry/files/{5ba71aa83263995e → a27872a7d58aeb58} +4 -5
- package/dist/registry/files/{162078d04cb26276 → df919b524be27e88} +4 -5
- package/dist/registry/index.json +1 -1
- package/dist/styles.css +3 -0
- package/package.json +3 -10
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { jsxs as d, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as $, useId as O, useRef as W, useCallback as z, useState as E, useEffect as F } from "react";
|
|
3
|
+
import M from "../../../icons/glyphs/Check.mjs";
|
|
4
|
+
import P from "../../../icons/glyphs/Minus.mjs";
|
|
5
|
+
import './Checkbox.css';/* empty css */
|
|
6
|
+
const J = $(function({
|
|
7
|
+
checked: t,
|
|
8
|
+
defaultChecked: h,
|
|
9
|
+
onChange: g,
|
|
10
|
+
onCheckedChange: B,
|
|
11
|
+
indeterminate: o,
|
|
12
|
+
disabled: a = !1,
|
|
13
|
+
invalid: p = !1,
|
|
14
|
+
label: n,
|
|
15
|
+
description: r,
|
|
16
|
+
size: u = "md",
|
|
17
|
+
tone: f,
|
|
18
|
+
id: C,
|
|
19
|
+
className: k = "",
|
|
20
|
+
style: b,
|
|
21
|
+
...N
|
|
22
|
+
}, s) {
|
|
23
|
+
const m = O(), l = C ?? (n ? `px-checkbox-${m}` : void 0), _ = r ? `${l ?? m}-desc` : void 0, x = W(null), I = z(
|
|
24
|
+
(c) => {
|
|
25
|
+
x.current = c, typeof s == "function" ? s(c) : s && (s.current = c);
|
|
26
|
+
},
|
|
27
|
+
[s]
|
|
28
|
+
), i = t !== void 0, [j, w] = E(!!h), y = i ? !!t : j;
|
|
29
|
+
F(() => {
|
|
30
|
+
x.current && o !== void 0 && (x.current.indeterminate = !!o);
|
|
31
|
+
}, [o]);
|
|
32
|
+
const R = (c) => {
|
|
33
|
+
i || w(c.target.checked), g?.(c), B?.(c.target.checked, c);
|
|
34
|
+
}, v = /* @__PURE__ */ d(
|
|
35
|
+
"span",
|
|
36
|
+
{
|
|
37
|
+
className: [
|
|
38
|
+
"px-checkbox",
|
|
39
|
+
`px-checkbox--${u === "sm" ? "sm" : u === "lg" ? "lg" : "md"}`,
|
|
40
|
+
(y || o) && "px-checkbox--on",
|
|
41
|
+
a && "px-checkbox--disabled",
|
|
42
|
+
p && "px-checkbox--invalid",
|
|
43
|
+
!n && k
|
|
44
|
+
].filter(Boolean).join(" "),
|
|
45
|
+
style: { ...f ? { "--px-checkbox-accent": f } : null, ...n ? null : b },
|
|
46
|
+
children: [
|
|
47
|
+
/* @__PURE__ */ e(
|
|
48
|
+
"input",
|
|
49
|
+
{
|
|
50
|
+
ref: I,
|
|
51
|
+
type: "checkbox",
|
|
52
|
+
id: l,
|
|
53
|
+
className: "px-checkbox__input",
|
|
54
|
+
checked: i ? !!t : void 0,
|
|
55
|
+
defaultChecked: i ? void 0 : h,
|
|
56
|
+
onChange: R,
|
|
57
|
+
disabled: a,
|
|
58
|
+
"aria-invalid": p || void 0,
|
|
59
|
+
"aria-describedby": _,
|
|
60
|
+
"aria-checked": o ? "mixed" : void 0,
|
|
61
|
+
...N
|
|
62
|
+
}
|
|
63
|
+
),
|
|
64
|
+
/* @__PURE__ */ e("span", { className: "px-checkbox__box", "aria-hidden": "true", children: o ? /* @__PURE__ */ e(P, { trim: !0, size: 12, strokeWidth: 3 }) : /* @__PURE__ */ e(M, { trim: !0, size: 12, strokeWidth: 3 }) })
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
return n ? /* @__PURE__ */ d(
|
|
69
|
+
"label",
|
|
70
|
+
{
|
|
71
|
+
htmlFor: l,
|
|
72
|
+
className: ["px-checkbox-field", a && "px-checkbox-field--disabled", k].filter(Boolean).join(" "),
|
|
73
|
+
style: b,
|
|
74
|
+
children: [
|
|
75
|
+
v,
|
|
76
|
+
/* @__PURE__ */ d("span", { className: "px-checkbox-field__text", children: [
|
|
77
|
+
/* @__PURE__ */ e("span", { className: "px-checkbox-field__label", children: n }),
|
|
78
|
+
r ? /* @__PURE__ */ e("span", { id: _, className: "px-checkbox-field__description", children: r }) : null
|
|
79
|
+
] })
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
) : v;
|
|
83
|
+
});
|
|
84
|
+
export {
|
|
85
|
+
J as Checkbox,
|
|
86
|
+
J as default
|
|
87
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),x=require("react"),xt=require("../NavIcon/NavIcon.cjs"),ta=require("../Alert/Alert.cjs"),me=require("../Skeleton/Skeleton.cjs"),_t=require("../RowCard/RowCard.cjs"),vt=require("../Money/Money.cjs"),aa=require("../CloseButton/CloseButton.cjs"),he=require("../Button/Button.cjs"),X=require("../IconButton/IconButton.cjs");;/* empty css */const sa=require("../../../icons/glyphs/ArrowDownRight.cjs"),na=require("../../../icons/glyphs/ArrowUp.cjs"),kt=require("../../../icons/glyphs/ArrowUpRight.cjs"),ra=require("../../../icons/glyphs/ChevronDown.cjs"),ia=require("../../../icons/glyphs/Close.cjs"),ze=new Set(["number","currency","money","percent","trend","progress","rating","sparkline"]),Re=new Set(["number","currency","money","percent","trend"]),la=new Set(["text","badge","avatar","tags","link","code"]),Nt=new Set(["success","warning","danger","info","neutral","accent"]),ca={paid:"success",active:"success",done:"success",delivered:"success",completed:"success",complete:"success",shipped:"info",fulfilled:"success",approved:"success",live:"success",merged:"success",pending:"warning",processing:"info","in progress":"info","in review":"warning",review:"warning",draft:"neutral",scheduled:"info",open:"info","on hold":"warning",blocked:"danger",failed:"danger",refunded:"danger",cancelled:"danger",canceled:"danger",overdue:"danger",declined:"danger",disputed:"danger",urgent:"danger",high:"danger",medium:"warning",low:"neutral"},Le=new Map;function fe(a,i){const n=a+JSON.stringify(i);return Le.has(n)||Le.set(n,new Intl.NumberFormat(a,i)),Le.get(n)}const Te=new Map;function oa(a,i){const n=a+JSON.stringify(i);return Te.has(n)||Te.set(n,new Intl.DateTimeFormat(a,i)),Te.get(n)}const ee=a=>a==null||a===""||Array.isArray(a)&&a.length===0,k=a=>typeof a=="number"?a:Number.parseFloat(a);function St(a){if(a instanceof Date)return a;if(typeof a=="number")return new Date(a);if(typeof a!="string")return null;const i=new Date(/^\d{4}-\d{2}-\d{2}$/.test(a)?`${a}T00:00:00Z`:a);return Number.isNaN(i.getTime())?null:i}function da(a){const i=String(a??"").trim().split(/\s+/).filter(Boolean);return i.length?i.length===1?i[0].slice(0,2).toUpperCase():(i[0][0]+i[i.length-1][0]).toUpperCase():"?"}function ua(a){let i=0;for(let n=0;n<a.length;n++)i=i*31+a.charCodeAt(n)|0;return Math.abs(i)}function ga(a,i){const n=String(a??""),l=i?.[n]??i?.[n.toLowerCase()]??ca[n.toLowerCase()];return Nt.has(l)?l:"neutral"}const ma=a=>a&&typeof a=="object"?{value:a.value,label:a.label??String(a.value)}:{value:a,label:String(a)};function H(a,i){const n=i?.[a.key],l=a.options??{};if(typeof a.format=="function"&&!ee(n))return String(a.format(n,i));if(ee(n))return"";const c=l.locale??"en-US";switch(a.type){case"number":return fe(c,{maximumFractionDigits:l.decimals??2,minimumFractionDigits:l.decimals??0,...l.compact?{notation:"compact"}:{}}).format(k(n))+(l.suffix??"");case"money":return vt.formatNumberValue(n,{currency:a.currency??l.currency??(l.currencyKey?i[l.currencyKey]:void 0),locale:l.locale,options:l.intl});case"currency":{const d=a.currency??l.currency??(l.currencyKey?i[l.currencyKey]:null)??"USD",o=l.decimals??2;return fe(c,{style:"currency",currency:d,minimumFractionDigits:o,maximumFractionDigits:o,...l.compact?{notation:"compact"}:{}}).format(k(n))}case"percent":{const d=l.fraction?k(n):k(n)/100;return fe(c,{style:"percent",maximumFractionDigits:l.decimals??1}).format(d)}case"trend":{const d=k(n),o=fe(c,{maximumFractionDigits:l.decimals??1,signDisplay:"never"}).format(d);return`${d>0?"+":d<0?"−":""}${o}${l.suffix??"%"}`}case"date":{const d=St(n);if(!d)return String(n);const{locale:o,timeZone:p="UTC",time:f,...N}=l,$=Object.keys(N).some(A=>["dateStyle","timeStyle","year","month","day","weekday","hour","minute"].includes(A))?N:{month:"short",day:"numeric",year:"numeric",...f?{hour:"numeric",minute:"2-digit"}:{}},P={};for(const A of["dateStyle","timeStyle","year","month","day","weekday","hour","minute","hour12"])$[A]!=null&&(P[A]=$[A]);return oa(c,{...P,timeZone:p}).format(d)}case"avatar":return[n,l.subtitleKey?i[l.subtitleKey]:null].filter(Boolean).join(" ");case"tags":return(Array.isArray(n)?n:[n]).join(", ");case"progress":return`${Math.round(k(n))}%`;case"rating":return String(n);case"sparkline":return Array.isArray(n)?String(n.at(-1)):String(n);default:return String(n)}}function ha(a,i){const n=i?.[a.key];if(ee(n))return null;if(a.type==="sparkline")return Array.isArray(n)?k(n.at(-1)):k(n);if(ze.has(a.type))return k(n);if(a.type==="date")return St(n)?.getTime()??null;if(a.type==="tags")return(Array.isArray(n)?n:[n]).join(", ").toLowerCase();if(a.type==="badge"&&Array.isArray(a.options?.order)){const l=a.options.order.indexOf(n);return l===-1?Number.MAX_SAFE_INTEGER:l}return String(n).toLowerCase()}const fa=()=>t.jsx(na.default,{className:"data-grid__sort-icon",trim:!0,size:null,strokeWidth:2.4}),pa=()=>t.jsx(ra.default,{trim:!0,size:null,strokeWidth:2}),ya=()=>t.jsx(ia.default,{trim:!0,size:null,strokeWidth:2.4}),xa=()=>t.jsx(kt.default,{trim:!0,size:null,strokeWidth:2.4}),_a=()=>t.jsx(sa.default,{trim:!0,size:null,strokeWidth:2.4}),ja=()=>t.jsx(kt.default,{trim:!0,size:null,strokeWidth:2}),jt="M12 2.8l2.8 5.8 6.3.9-4.6 4.4 1.1 6.3L12 17.2l-5.6 3 1.1-6.3L2.9 9.5l6.3-.9z";function ba({values:a,mode:i}){const n=(Array.isArray(a)?a:[]).map(k).filter(Number.isFinite);if(n.length<2)return t.jsx("span",{className:"data-grid__empty-val",children:"—"});const l=84,c=26,d=3,o=Math.min(...n),f=Math.max(...n)-o||1,N=n.map((C,F)=>[d+F/(n.length-1)*(l-d*2),d+(1-(C-o)/f)*(c-d*2)]),$=N.map(([C,F])=>`${C.toFixed(1)},${F.toFixed(1)}`).join(" "),P=`${d},${c} ${$} ${(l-d).toFixed(1)},${c}`,A=n.at(-1)>=n[0]?"up":"down",ye=i==="trend"?` is-${A}`:"",[B,xe]=N.at(-1);return t.jsxs("svg",{className:`data-grid__spark${ye}`,viewBox:`0 0 ${l} ${c}`,role:"img","aria-label":`Trend ${A}, from ${n[0]} to ${n.at(-1)}`,children:[t.jsx("polygon",{points:P}),t.jsx("polyline",{points:$}),t.jsx("circle",{cx:B,cy:xe,r:"2.2"})]})}function va({value:a,max:i=5,showValue:n}){const l=Math.max(0,Math.min(i,k(a)||0));return t.jsxs("span",{className:"data-grid__rating",role:"img","aria-label":`${l} out of ${i}`,children:[Array.from({length:i},(c,d)=>{const o=Math.max(0,Math.min(1,l-d));return t.jsxs("svg",{viewBox:"0 0 24 24","aria-hidden":!0,children:[t.jsx("path",{className:"is-off",d:jt}),o>0&&t.jsx("path",{className:"is-on",d:jt,style:o<1?{clipPath:`inset(0 ${((1-o)*100).toFixed(0)}% 0 0)`}:void 0})]},d)}),n!==!1&&t.jsx("span",{className:"data-grid__rating-val",children:l.toFixed(1)})]})}function Fe({col:a,row:i,index:n}){if(typeof a.cell=="function")return a.cell(i,n);const l=i?.[a.key],c=a.options??{};if(ee(l)&&a.type!=="avatar")return t.jsx("span",{className:"data-grid__empty-val",children:"—"});const d=H(a,i);switch(a.type){case"money":return t.jsx(vt.default,{className:"data-grid__money",value:l,currency:a.currency??c.currency??(c.currencyKey?i[c.currencyKey]:void 0),locale:c.locale,options:c.intl,format:typeof a.format=="function"?o=>a.format(o,i):void 0,tone:c.tone,zeroAsDash:c.zeroAsDash});case"code":return t.jsx("span",{className:"data-grid__text is-mono data-grid__code",children:d});case"number":case"percent":return t.jsx("span",{className:"data-grid__num",children:d});case"currency":return t.jsx("span",{className:"data-grid__money",children:d});case"date":return t.jsx("time",{className:"data-grid__text",dateTime:typeof l=="string"?l:void 0,children:d});case"badge":return t.jsx("span",{className:`data-grid__badge data-grid__badge--${ga(l,c.tones)}`,children:d});case"avatar":{const o=String(l??""),p=c.subtitleKey?i[c.subtitleKey]:null,f=c.imageKey?i[c.imageKey]:null,N=ua(o)%6+1;return t.jsxs("span",{className:"data-grid__person",children:[t.jsx("span",{className:"data-grid__avatar",style:{"--c":`var(--chart-series-${N}, var(--dg-accent))`},"aria-hidden":!0,children:f?t.jsx("img",{src:f,alt:"",loading:"lazy"}):da(o)}),t.jsxs("span",{className:"data-grid__person-text",children:[t.jsx("span",{className:"data-grid__person-name",children:typeof a.format=="function"?d:o||"—"}),p&&t.jsx("span",{className:"data-grid__person-sub",children:p})]})]})}case"progress":{const o=c.max??100,p=Math.max(0,Math.min(100,k(l)/o*100||0));return t.jsxs("span",{className:"data-grid__progress",children:[t.jsx("span",{className:"data-grid__progress-track",role:"progressbar","aria-valuemin":0,"aria-valuemax":o,"aria-valuenow":k(l),"aria-label":a.label,children:t.jsx("span",{className:`data-grid__progress-fill${p>=100?" is-done":""}`,style:{width:`${p}%`}})}),t.jsx("span",{className:"data-grid__progress-val",children:typeof a.format=="function"?d:`${Math.round(p)}%`})]})}case"sparkline":return t.jsx(ba,{values:l,mode:c.color??"accent"});case"rating":return t.jsx(va,{value:l,max:c.max??5,showValue:c.showValue});case"tags":{const o=Array.isArray(l)?l:[l],p=c.max??3,f=o.slice(0,p);return t.jsxs("span",{className:"data-grid__tags",children:[f.map(N=>{const $=c.tones?.[N];return t.jsx("span",{className:`data-grid__tag${Nt.has($)&&$!=="neutral"?` data-grid__tag--${$}`:""}`,children:N},N)}),o.length>p&&t.jsxs("span",{className:"data-grid__tag is-more",title:o.slice(p).join(", "),children:["+",o.length-p]})]})}case"link":{const o=c.hrefKey?i[c.hrefKey]:c.href;if(!o)return t.jsx("span",{className:"data-grid__text is-strong",children:d});const p=c.external??/^https?:\/\//.test(o);return t.jsxs("a",{className:"data-grid__link",href:o,...p?{target:"_blank",rel:"noreferrer noopener"}:{},onClick:f=>f.stopPropagation(),children:[d,p&&t.jsx(ja,{})]})}case"trend":{const o=k(l),p=c.invert?o<0:o>0,f=o===0?"":p?" is-good":" is-bad";return t.jsxs("span",{className:`data-grid__trend${f}`,children:[o>0?t.jsx(xa,{}):o<0?t.jsx(_a,{}):null,d]})}default:{const o=["data-grid__text",c.strong&&"is-strong",c.mono&&"is-mono",c.muted&&"is-muted",c.maxWidth&&"is-clamp"].filter(Boolean).join(" ");return t.jsx("span",{className:o,style:c.maxWidth?{"--dg-max":typeof c.maxWidth=="number"?`${c.maxWidth}px`:c.maxWidth}:void 0,title:c.maxWidth?d:void 0,children:d})}}}function pe({checked:a,indeterminate:i,onChange:n,label:l}){const c=x.useRef(null);return x.useEffect(()=>{c.current&&(c.current.indeterminate=!!i)},[i]),t.jsx("input",{ref:c,type:"checkbox",className:"data-grid__check",checked:!!a,"aria-checked":i?"mixed":!!a,"aria-label":l,onChange:n,onClick:d=>d.stopPropagation()})}function We({value:a,onChange:i,label:n,children:l,small:c}){return t.jsxs("label",{className:`data-grid__select${c?" data-grid__select--sm":""}`,children:[t.jsx("span",{className:"data-grid__select-label",children:n}),t.jsx("select",{value:a,onChange:d=>i(d.target.value),children:l}),t.jsx(pa,{})]})}const $t={search:"Search…",clearSearch:"Clear search",sortBy:"Sort by",sortDefault:"Sort: default",selected:a=>`${a} selected`,clear:"Clear",clearFilters:"Clear filters",bulkActions:"Bulk actions",selectAll:"Select all rows",deselectAll:"Deselect all rows",selectAllShort:"Select all",selectRow:a=>`Select ${a}`,rowsPerPage:"Rows per page",previous:"Previous page",next:"Next page",pageOf:(a,i)=>`${a} / ${i}`,goToPage:a=>`Page ${a}`,pagination:"Pagination",noResults:"0 results",range:null,of:"of",resultCount:(a,i)=>`${a} of ${i}`,table:"Data table",loading:"Loading…",error:"Couldn't load the data.",retry:"Retry",all:"All",allOf:a=>`All ${String(a).toLowerCase()}`,action:"Action"};function ka(a,i){if(i<=7)return Array.from({length:i},(d,o)=>o+1);const n=new Set([1,i,a-1,a,a+1]);a<=3&&[2,3,4].forEach(d=>n.add(d)),a>=i-2&&[i-1,i-2,i-3].forEach(d=>n.add(d));const l=[...n].filter(d=>d>=1&&d<=i).sort((d,o)=>d-o),c=[];return l.forEach((d,o)=>{o>0&&d-l[o-1]>1&&c.push(`gap-${d}`),c.push(d)}),c}const bt=[72,54,86,64,48,78,60,92];function Na({columns:a=[],rows:i=[],rowKey:n="id",searchable:l=!1,filters:c=[],sort:d,pageSize:o,pageSizeOptions:p,selectable:f=!1,defaultSelected:N=[],bulkActions:$=[],density:P="comfortable",striped:A=!1,stickyHeader:ye=!1,maxHeight:B,emptyText:xe="No matching rows",title:C,subtitle:F,actions:_e=[],responsive:Ie="scroll",caption:te,className:Ct="",onBulkAction:At,onAction:qe,onRowClick:G,onSelectionChange:wt,onSortChange:Pe,serverSide:D=!1,page:Dt,pageCount:Be,onPageChange:Ke,totalRows:ae,selected:se,onSelectedChange:Mt,rowTone:Ue,rowHighlighted:Ve,rowHref:Ge,renderLink:Et,bulkBar:Y,loading:O=!1,loadingRows:Ot,error:v,onRetry:Ye,empty:Rt,stickyFirstColumn:je="narrow",mobile:Lt="scroll",renderCard:Je,labels:Tt}){const Ft=x.useId(),g={...$t,...Tt||{}},b=x.useMemo(()=>(Array.isArray(a)?a:[]).filter(e=>e&&e.key!=null),[a]),W=Array.isArray(i)?i:[],be=(e,s)=>(typeof n=="function"?n(e,s):e?.[n])??s,ne=(e,s)=>String(be(e,s)),ve=e=>typeof e.label=="string"?e.label:typeof e.header=="string"?e.header:String(e.key),Ze=e=>e?.key?{key:e.key,dir:e.dir==="desc"?"desc":"asc"}:null,[K,re]=x.useState(""),[ie,Qe]=x.useState({}),[Wt,Xe]=x.useState(()=>Ze(d)),S=D?Ze(d):Wt,[He,et]=x.useState(o>0?o:0),[zt,z]=x.useState(0),le=Array.isArray(se),[tt,It]=x.useState(()=>new Set((N??[]).map(String))),R=x.useMemo(()=>le?new Set(se.map(String)):tt,[le,se,tt]);x.useEffect(()=>{o>0&&et(o)},[o]);const at=x.useRef(null),[qt,Pt]=x.useState("");x.useEffect(()=>{const e=at.current;if(!e)return;const s=()=>{const u=e.scrollWidth-e.clientWidth,m=u<=1?"":`${e.scrollLeft>1?" is-left":""}${e.scrollLeft<u-1?" is-right":""}`;Pt(h=>h===m?h:m)};s(),e.addEventListener("scroll",s,{passive:!0});const r=typeof ResizeObserver<"u"?new ResizeObserver(s):null;return r?.observe(e),e.firstElementChild&&r?.observe(e.firstElementChild),()=>{e.removeEventListener("scroll",s),r?.disconnect()}},[]);const ke=(Array.isArray(c)?c:[]).filter(e=>e&&e.key!=null),st=x.useMemo(()=>Object.fromEntries(b.map(e=>[e.key,e])),[b]),nt=(e,s,r)=>{if(r===""||r==null)return!0;const u=e?.[s.key];return Array.isArray(u)?u.map(String).includes(String(r)):String(u)===String(r)},ce=x.useMemo(()=>{const e=K.trim().toLowerCase(),s=b.filter(r=>r.searchable??la.has(r.type??"text"));return W.filter(r=>{for(const u of ke)if(!nt(r,u,ie[u.key]))return!1;return e?s.some(u=>H(u,r).toLowerCase().includes(e))||String(typeof n=="function"?n(r):r?.[n]??"").toLowerCase().includes(e):!0})},[W,b,K,ie,c,n]),oe=x.useMemo(()=>{if(D)return ce;const e=S&&st[S.key];if(!e)return ce;const s=S.dir==="desc"?-1:1,r=typeof e.sortValue=="function"?u=>e.sortValue(u):u=>ha(e,u);return ce.map((u,m)=>({row:u,i:m,v:r(u)})).sort((u,m)=>u.v==null&&m.v==null?u.i-m.i:u.v==null?1:m.v==null?-1:(typeof u.v=="number"&&typeof m.v=="number"?u.v-m.v:String(u.v).localeCompare(String(m.v),"en",{numeric:!0}))*s||u.i-m.i).map(u=>u.row)},[ce,S,st,D]),w=Be!=null,L=oe.length,M=w?0:He,T=w?Math.max(1,Number(Be)||1):M>0?Math.max(1,Math.ceil(L/M)):1,y=Math.min(w?Math.max(0,(Number(Dt)||1)-1):zt,T-1),E=M>0?y*M:0,I=M>0?oe.slice(E,E+M):oe,U=(D||w?I:oe).map((e,s)=>ne(e,s)),Ne=U.filter(e=>R.has(e)).length,V=U.length>0&&Ne===U.length,rt=Ne>0&&!V,de=D||w?R.size:Ne,ue=new Map;(le?se:[]).forEach(e=>ue.set(String(e),e)),W.forEach((e,s)=>ue.set(ne(e,s),be(e,s)));const Se=e=>e.map(s=>ue.has(s)?ue.get(s):s),$e=e=>{le||It(e);const s=Se([...e]);wt?.(s),Mt?.(s)},Ce=e=>{const s=new Set(R);s.has(e)?s.delete(e):s.add(e),$e(s)},it=()=>{const e=new Set(R);V?U.forEach(s=>e.delete(s)):U.forEach(s=>e.add(s)),$e(e)},lt=()=>$e(new Set),ct=D||w?[...R]:[...R].filter(e=>U.includes(e)),Bt=e=>e.firstDir==="asc"||e.firstDir==="desc"?e.firstDir:ze.has(e.type)||e.type==="date"||e.numeric?"desc":"asc",Kt=e=>{const s=Bt(e);let r;!S||S.key!==e.key?r={key:e.key,dir:s}:S.dir===s?r={key:e.key,dir:s==="asc"?"desc":"asc"}:r=D?{key:e.key,dir:s}:null,D||(Xe(r),z(0)),Pe?.(r,r?.key??null,r?.dir??null)},ot=(e,s)=>{Qe(r=>({...r,[e]:s})),z(0)},Ut=()=>{re(""),Qe({}),z(0)},J=e=>{w||z(e),Ke?.(e+1)},Vt=(e,s)=>W.filter(r=>nt(r,e,s)).length,dt=typeof l=="string"?l:g.search,Gt=l||ke.length>0,Ae=K.trim()!==""||Object.values(ie).some(e=>e!==""&&e!=null),ut=b.filter(e=>e.sortable!==!1),gt=[...new Set([...(p??[o,10,25,50]).filter(e=>e>0)])].sort((e,s)=>e-s),Yt=b.length+(f?1:0),we=Lt==="cards",mt=je===!0||je==="always"?"always":je===!1||b[0]?.sticky===!1?null:"narrow",Jt=["data-grid",`data-grid--${P==="compact"?"compact":"comfortable"}`,A&&"data-grid--striped",ye&&"data-grid--sticky",Ie==="stack"&&"data-grid--stack",mt&&`data-grid--sticky-first-${mt}`,we&&"data-grid--cards",Ct].filter(Boolean).join(" "),ge=e=>e.align??(Re.has(e.type)||e.numeric?"right":"left"),De=b[0]?.key,ht=e=>{const s=typeof Ue=="function"?Ue(e):null;return s==="danger"||s==="warning"?s:null},ft=e=>typeof Ve=="function"?!!Ve(e):!1,Zt=!O&&!v,pt=Math.max(1,Math.min(12,Ot??(M||o||5))),yt=Rt??t.jsxs("div",{className:"data-grid__empty-inner",children:[t.jsx("span",{className:"data-grid__empty-icon",children:t.jsx(xt.default,{name:Ae?"search":"inbox",size:18})}),t.jsx("p",{className:"data-grid__empty-text",children:xe}),Ae&&t.jsx(he.default,{variant:"ghost",size:"sm",onClick:Ut,children:g.clearFilters})]}),Z=(e,s)=>b.find(r=>r.card===e)??(s?b.find(r=>r.card!==!1&&s(r)):void 0),Qt=(()=>{if(!we)return null;const e=Z("title")??b[0],s=Z("value",_=>_!==e&&(Re.has(_.type)||_.numeric)),r=Z("badge",_=>_!==e&&_.type==="badge"),u=new Set([e,s,r]),m=_=>!u.has(_)&&!ze.has(_.type)&&!_.numeric&&_.type!=="badge"&&_.type!=="tags",h=Z("subtitle",m);u.add(h);const q=Z("meta",m);return{titleCol:e,subtitleCol:h,metaCol:q,valueCol:s,badgeCol:r}})(),Me=(e,s,r)=>e?typeof e.cell=="function"?e.cell(s,r):ee(s?.[e.key])?void 0:H(e,s):void 0,Xt=(e,s)=>{const r=ne(e,E+s),u=f&&R.has(r),m={index:E+s,key:be(e,E+s),selected:u,toggle:()=>Ce(r),tone:ht(e),highlighted:ft(e)};if(typeof Je=="function")return t.jsx("div",{children:Je(e,m)},r);const{titleCol:h,subtitleCol:q,metaCol:_,valueCol:j,badgeCol:Q}=Qt,Oe=H(h??{key:n},e)||r;return t.jsx(_t.default,{title:Me(h,e,s)??r,subtitle:Me(q,e,s),meta:_?Me(_,e,s):void 0,value:j?t.jsx(Fe,{col:j,row:e,index:s}):void 0,badge:Q?t.jsx(Fe,{col:Q,row:e,index:s}):void 0,tone:m.tone,highlighted:m.highlighted,selected:u,href:typeof Ge=="function"?Ge(e):void 0,renderLink:Et,onClick:typeof G=="function"?()=>G(e):void 0,leading:f?t.jsx(pe,{checked:u,onChange:()=>Ce(r),label:typeof g.selectRow=="function"?g.selectRow(Oe):g.selectRow}):void 0},r)},Ee=(()=>{if(w){if(ae!=null&&o>0){const r=L===0?0:y*o+1,u=Math.min(y*o+I.length,ae);return typeof g.range=="function"?g.range(r,u,ae):t.jsxs(t.Fragment,{children:[t.jsxs("strong",{children:[r,"–",u]})," ",g.of," ",t.jsx("strong",{children:ae})]})}return null}if(L===0)return g.noResults;const e=E+1,s=Math.min(E+M,L);return typeof g.range=="function"?g.range(e,s,L):t.jsxs(t.Fragment,{children:[t.jsxs("strong",{children:[e,"–",s]})," ",g.of," ",t.jsx("strong",{children:L})]})})(),Ht=f&&de>0&&Y!=null?typeof Y=="function"?Y({count:de,selected:Se(ct),clear:lt}):Y:null,ea=v?t.jsx(ta.default,{tone:"danger",title:typeof v=="string"?v:v?.message??g.error,description:typeof v=="object"&&v&&!(v instanceof Error)&&!v.message?v:void 0,actions:typeof Ye=="function"?[{label:g.retry,onClick:Ye}]:void 0,className:"data-grid__error"}):null;return t.jsxs("div",{className:Jt,children:[(C||F||_e?.length>0)&&t.jsxs("div",{className:"data-grid__header",children:[t.jsxs("div",{className:"data-grid__titles",children:[C&&t.jsx("h3",{className:"data-grid__title",children:C}),F&&t.jsx("p",{className:"data-grid__subtitle",children:F})]}),_e?.length>0&&t.jsx("div",{className:"data-grid__actions",children:_e.map((e,s)=>e.label?t.jsx(he.default,{size:"sm",variant:e.variant==="primary"?"primary":"secondary",icon:e.icon,onClick:()=>qe?.(e.label),children:e.label},e.label??s):t.jsx(X.default,{size:"sm",variant:e.variant==="primary"?"primary":"secondary",icon:e.icon,label:e.ariaLabel??g.action,onClick:()=>qe?.(e.label)},s))})]}),Gt&&t.jsxs("div",{className:"data-grid__controls",children:[l&&t.jsxs("div",{className:"data-grid__search",role:"search",children:[t.jsx(xt.default,{name:"search",size:15}),t.jsx("input",{type:"search",value:K,placeholder:dt,"aria-label":dt.replace(/…$/,""),onChange:e=>{re(e.target.value),z(0)},onKeyDown:e=>e.key==="Escape"&&K&&(e.preventDefault(),re(""))}),K&&t.jsx(aa.default,{icon:t.jsx(ya,{}),label:g.clearSearch,appearance:"clear",className:"data-grid__search-clear",onClick:()=>re("")})]}),ke.map(e=>{const s=(e.options??[]).map(ma),r=ie[e.key]??"",u=e.type==="select"||e.type!=="pills"&&s.length>5,m=e.allLabel??(u?typeof g.allOf=="function"?g.allOf(e.label??e.key):g.allOf:g.all);return u?t.jsxs(We,{label:e.label??e.key,value:r,onChange:h=>ot(e.key,h),children:[t.jsx("option",{value:"",children:m}),s.map(h=>t.jsx("option",{value:String(h.value),children:h.label},String(h.value)))]},e.key):t.jsx("div",{className:"data-grid__pills",role:"group","aria-label":e.label??e.key,children:[{value:"",label:m},...s].map(h=>{const q=String(r)===String(h.value);return t.jsxs("button",{type:"button",className:"data-grid__pill","aria-pressed":q,onClick:()=>ot(e.key,h.value),children:[h.label,e.counts!==!1&&t.jsx("span",{className:"data-grid__pill-count",children:h.value===""?W.length:Vt(e,h.value)})]},String(h.value))})},e.key)}),Ie==="stack"&&ut.length>0&&t.jsx("span",{className:"data-grid__sort-mobile",children:t.jsxs(We,{label:g.sortBy,value:S?`${S.key}:${S.dir}`:"",onChange:e=>{const[s,r]=e.split(":"),u=s?{key:s,dir:r}:null;D||(Xe(u),z(0)),Pe?.(u,u?.key??null,u?.dir??null)},children:[t.jsx("option",{value:"",children:g.sortDefault}),ut.flatMap(e=>[t.jsxs("option",{value:`${e.key}:asc`,children:[ve(e)," ↑"]},`${e.key}:asc`),t.jsxs("option",{value:`${e.key}:desc`,children:[ve(e)," ↓"]},`${e.key}:desc`)])]})}),Ae&&t.jsx("span",{className:"data-grid__result","aria-live":"polite",children:typeof g.resultCount=="function"?g.resultCount(L,W.length):`${L} / ${W.length}`})]}),f&&de>0&&Y==null&&t.jsxs("div",{className:"data-grid__bulk",role:"region","aria-label":g.bulkActions,children:[t.jsx("span",{className:"data-grid__bulk-count","aria-live":"polite",children:typeof g.selected=="function"?g.selected(de):g.selected}),($??[]).map((e,s)=>t.jsx(he.default,{size:"sm",tone:e.tone==="danger"?"danger":void 0,icon:e.icon,onClick:()=>At?.(e.label,Se(ct)),children:e.label},e.label??s)),t.jsx(he.default,{variant:"ghost",size:"sm",onClick:lt,children:g.clear})]}),ea,!v&&t.jsx("div",{className:`data-grid__frame${qt}`,children:t.jsx("div",{ref:at,className:"data-grid__scroll",style:B?{maxHeight:typeof B=="number"?`${B}px`:B}:void 0,tabIndex:0,role:"region","aria-label":C??te??g.table,"aria-busy":O||void 0,children:t.jsxs("table",{className:"data-grid__table",children:[(te||C)&&t.jsx("caption",{className:"data-grid__select-label",children:te??C}),t.jsx("thead",{children:t.jsxs("tr",{children:[f&&t.jsx("th",{className:"data-grid__th data-grid__check-cell",scope:"col",children:t.jsx(pe,{checked:V,indeterminate:rt,onChange:it,label:V?g.deselectAll:g.selectAll})}),b.map(e=>{const s=ge(e),r=e.sortable!==!1,u=S?.key===e.key?S.dir==="desc"?"descending":"ascending":r?"none":void 0,m=e.width!=null?typeof e.width=="number"?`${e.width}px`:e.width:void 0,h=e.minWidth!=null?typeof e.minWidth=="number"?`${e.minWidth}px`:e.minWidth:m;return t.jsx("th",{scope:"col",className:`data-grid__th${s!=="left"?` is-${s}`:""}${e.key===De?" is-primary":""}`,style:m||h?{width:m,minWidth:h}:void 0,"aria-sort":u,children:r?t.jsxs("button",{type:"button",className:"data-grid__sort",onClick:()=>Kt(e),children:[t.jsx("span",{children:e.header??e.label??e.key}),t.jsx(fa,{})]}):e.header??e.label??e.key},e.key)})]})}),t.jsx("tbody",{children:O?Array.from({length:pt},(e,s)=>t.jsxs("tr",{className:"data-grid__row data-grid__row--loading","aria-hidden":"true",children:[f&&t.jsx("td",{className:"data-grid__td data-grid__check-cell",children:t.jsx(me.SkeletonRect,{width:16,height:16,radius:5})}),b.map((r,u)=>t.jsx("td",{className:`data-grid__td${ge(r)!=="left"?` is-${ge(r)}`:""}${r.key===De?" is-primary":""}`,children:t.jsx(me.SkeletonRect,{width:`${bt[(s+u)%bt.length]}%`,height:10,radius:5,className:"data-grid__skeleton"})},r.key))]},`sk-${s}`)):I.length===0?t.jsx("tr",{children:t.jsx("td",{className:"data-grid__td data-grid__empty",colSpan:Yt,children:yt})}):I.map((e,s)=>{const r=ne(e,E+s),u=f&&R.has(r),m=typeof G=="function",h=ht(e),q=ft(e),_=["data-grid__row",u&&"is-selected",m&&"is-clickable",h&&`is-tone-${h}`,q&&"is-lit"].filter(Boolean).join(" ");return t.jsxs("tr",{className:_,"aria-selected":f?u:void 0,tabIndex:m?0:void 0,onClick:m?()=>G(e):void 0,onKeyDown:m?j=>{j.target===j.currentTarget&&(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),G(e))}:void 0,children:[f&&t.jsx("td",{className:"data-grid__td data-grid__check-cell",children:t.jsx(pe,{checked:u,onChange:()=>Ce(r),label:typeof g.selectRow=="function"?g.selectRow(H(b[0]??{key:n},e)||r):g.selectRow})}),b.map(j=>{const Q=ge(j),Oe=["data-grid__td",Q!=="left"&&`is-${Q}`,j.key===De&&"is-primary",(j.numeric||Re.has(j.type))&&"is-num",j.wrap&&"is-wrap"].filter(Boolean).join(" ");return t.jsx("td",{className:Oe,"data-label":ve(j),children:t.jsx(Fe,{col:j,row:e,index:E+s})},j.key)})]},r)})})]})})}),we&&!v&&t.jsxs("div",{className:"data-grid__cards","aria-busy":O||void 0,children:[f&&Zt&&I.length>0&&t.jsxs("label",{className:"data-grid__cards-all",children:[t.jsx(pe,{checked:V,indeterminate:rt,onChange:it,label:V?g.deselectAll:g.selectAll}),t.jsx("span",{"aria-hidden":"true",children:g.selectAllShort})]}),O?t.jsx("div",{className:"data-grid__cards-loading","aria-label":g.loading,children:Array.from({length:Math.min(pt,5)},(e,s)=>t.jsxs("div",{className:"data-grid__card-skeleton","aria-hidden":"true",children:[t.jsx(me.SkeletonRect,{width:"58%",height:12,radius:6}),t.jsx(me.SkeletonRect,{width:"36%",height:10,radius:5})]},s))}):I.length===0?t.jsx("div",{className:"data-grid__cards-empty",children:yt}):t.jsx(_t.RowCards,{ariaLabel:C??te??g.table,children:I.map((e,s)=>Xt(e,s))})]}),w&&T>1&&!v&&t.jsxs("nav",{className:"data-grid__footer data-grid__footer--center","aria-label":g.pagination,children:[Ee!=null&&t.jsx("span",{className:"data-grid__range","aria-live":"polite",children:Ee}),t.jsxs("span",{className:"data-grid__page-btns",children:[t.jsx(X.default,{size:"sm",icon:"chevron-left",label:g.previous,tooltip:!1,disabled:y===0||O,onClick:()=>J(y-1)}),ka(y+1,T).map(e=>typeof e=="string"?t.jsx("span",{className:"data-grid__page-gap","aria-hidden":"true",children:"…"},e):t.jsx("button",{type:"button",className:`data-grid__btn data-grid__page${e===y+1?" is-current":""}`,"aria-label":typeof g.goToPage=="function"?g.goToPage(e):`${g.goToPage} ${e}`,"aria-current":e===y+1?"page":void 0,disabled:O&&e!==y+1,onClick:()=>e!==y+1&&J(e-1),children:e},e)),t.jsx(X.default,{size:"sm",icon:"chevron-right",label:g.next,tooltip:!1,disabled:y>=T-1||O,onClick:()=>J(y+1)})]})]}),!w&&M>0&&!v&&t.jsxs("div",{className:"data-grid__footer",children:[t.jsx("span",{className:"data-grid__range","aria-live":"polite",children:Ee}),t.jsxs("div",{className:"data-grid__pager",children:[gt.length>1&&t.jsxs("span",{className:"data-grid__per-page",children:[t.jsx("span",{className:"data-grid__per-page-label","aria-hidden":!0,children:g.rowsPerPage}),t.jsx(We,{small:!0,label:g.rowsPerPage,value:String(He),onChange:e=>{et(Number(e)),z(0)},children:gt.map(e=>t.jsx("option",{value:e,children:e},e))})]}),t.jsxs("span",{className:"data-grid__page-btns",children:[t.jsx(X.default,{size:"sm",icon:"chevron-left",label:g.previous,tooltip:!1,disabled:y===0,onClick:()=>J(y-1)}),t.jsx("span",{className:"data-grid__page-num",id:`${Ft}-page`,children:typeof g.pageOf=="function"?g.pageOf(y+1,T):`${y+1} / ${T}`}),t.jsx(X.default,{size:"sm",icon:"chevron-right",label:g.next,tooltip:!1,disabled:y>=T-1,onClick:()=>J(y+1)})]})]})]}),Ht]})}exports.DATA_GRID_LABELS=$t;exports.default=Na;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),j=require("react"),xt=require("../NavIcon/NavIcon.cjs"),ta=require("../Alert/Alert.cjs"),me=require("../Skeleton/Skeleton.cjs"),_t=require("../RowCard/RowCard.cjs"),vt=require("../Money/Money.cjs"),aa=require("../CloseButton/CloseButton.cjs"),he=require("../Button/Button.cjs"),X=require("../IconButton/IconButton.cjs");;/* empty css */const sa=require("../../../icons/glyphs/ArrowDownRight.cjs"),na=require("../../../icons/glyphs/ArrowUp.cjs"),kt=require("../../../icons/glyphs/ArrowUpRight.cjs"),ra=require("../../../icons/glyphs/ChevronDown.cjs"),ia=require("../../../icons/glyphs/Close.cjs"),la=require("../Checkbox/Checkbox.cjs"),ze=new Set(["number","currency","money","percent","trend","progress","rating","sparkline"]),Re=new Set(["number","currency","money","percent","trend"]),ca=new Set(["text","badge","avatar","tags","link","code"]),Nt=new Set(["success","warning","danger","info","neutral","accent"]),oa={paid:"success",active:"success",done:"success",delivered:"success",completed:"success",complete:"success",shipped:"info",fulfilled:"success",approved:"success",live:"success",merged:"success",pending:"warning",processing:"info","in progress":"info","in review":"warning",review:"warning",draft:"neutral",scheduled:"info",open:"info","on hold":"warning",blocked:"danger",failed:"danger",refunded:"danger",cancelled:"danger",canceled:"danger",overdue:"danger",declined:"danger",disputed:"danger",urgent:"danger",high:"danger",medium:"warning",low:"neutral"},Le=new Map;function fe(a,i){const n=a+JSON.stringify(i);return Le.has(n)||Le.set(n,new Intl.NumberFormat(a,i)),Le.get(n)}const Te=new Map;function da(a,i){const n=a+JSON.stringify(i);return Te.has(n)||Te.set(n,new Intl.DateTimeFormat(a,i)),Te.get(n)}const ee=a=>a==null||a===""||Array.isArray(a)&&a.length===0,k=a=>typeof a=="number"?a:Number.parseFloat(a);function St(a){if(a instanceof Date)return a;if(typeof a=="number")return new Date(a);if(typeof a!="string")return null;const i=new Date(/^\d{4}-\d{2}-\d{2}$/.test(a)?`${a}T00:00:00Z`:a);return Number.isNaN(i.getTime())?null:i}function ua(a){const i=String(a??"").trim().split(/\s+/).filter(Boolean);return i.length?i.length===1?i[0].slice(0,2).toUpperCase():(i[0][0]+i[i.length-1][0]).toUpperCase():"?"}function ga(a){let i=0;for(let n=0;n<a.length;n++)i=i*31+a.charCodeAt(n)|0;return Math.abs(i)}function ma(a,i){const n=String(a??""),l=i?.[n]??i?.[n.toLowerCase()]??oa[n.toLowerCase()];return Nt.has(l)?l:"neutral"}const ha=a=>a&&typeof a=="object"?{value:a.value,label:a.label??String(a.value)}:{value:a,label:String(a)};function H(a,i){const n=i?.[a.key],l=a.options??{};if(typeof a.format=="function"&&!ee(n))return String(a.format(n,i));if(ee(n))return"";const c=l.locale??"en-US";switch(a.type){case"number":return fe(c,{maximumFractionDigits:l.decimals??2,minimumFractionDigits:l.decimals??0,...l.compact?{notation:"compact"}:{}}).format(k(n))+(l.suffix??"");case"money":return vt.formatNumberValue(n,{currency:a.currency??l.currency??(l.currencyKey?i[l.currencyKey]:void 0),locale:l.locale,options:l.intl});case"currency":{const u=a.currency??l.currency??(l.currencyKey?i[l.currencyKey]:null)??"USD",o=l.decimals??2;return fe(c,{style:"currency",currency:u,minimumFractionDigits:o,maximumFractionDigits:o,...l.compact?{notation:"compact"}:{}}).format(k(n))}case"percent":{const u=l.fraction?k(n):k(n)/100;return fe(c,{style:"percent",maximumFractionDigits:l.decimals??1}).format(u)}case"trend":{const u=k(n),o=fe(c,{maximumFractionDigits:l.decimals??1,signDisplay:"never"}).format(u);return`${u>0?"+":u<0?"−":""}${o}${l.suffix??"%"}`}case"date":{const u=St(n);if(!u)return String(n);const{locale:o,timeZone:p="UTC",time:f,...N}=l,$=Object.keys(N).some(A=>["dateStyle","timeStyle","year","month","day","weekday","hour","minute"].includes(A))?N:{month:"short",day:"numeric",year:"numeric",...f?{hour:"numeric",minute:"2-digit"}:{}},P={};for(const A of["dateStyle","timeStyle","year","month","day","weekday","hour","minute","hour12"])$[A]!=null&&(P[A]=$[A]);return da(c,{...P,timeZone:p}).format(u)}case"avatar":return[n,l.subtitleKey?i[l.subtitleKey]:null].filter(Boolean).join(" ");case"tags":return(Array.isArray(n)?n:[n]).join(", ");case"progress":return`${Math.round(k(n))}%`;case"rating":return String(n);case"sparkline":return Array.isArray(n)?String(n.at(-1)):String(n);default:return String(n)}}function fa(a,i){const n=i?.[a.key];if(ee(n))return null;if(a.type==="sparkline")return Array.isArray(n)?k(n.at(-1)):k(n);if(ze.has(a.type))return k(n);if(a.type==="date")return St(n)?.getTime()??null;if(a.type==="tags")return(Array.isArray(n)?n:[n]).join(", ").toLowerCase();if(a.type==="badge"&&Array.isArray(a.options?.order)){const l=a.options.order.indexOf(n);return l===-1?Number.MAX_SAFE_INTEGER:l}return String(n).toLowerCase()}const pa=()=>t.jsx(na.default,{className:"data-grid__sort-icon",trim:!0,size:null,strokeWidth:2.4}),ya=()=>t.jsx(ra.default,{trim:!0,size:null,strokeWidth:2}),xa=()=>t.jsx(ia.default,{trim:!0,size:null,strokeWidth:2.4}),_a=()=>t.jsx(kt.default,{trim:!0,size:null,strokeWidth:2.4}),ja=()=>t.jsx(sa.default,{trim:!0,size:null,strokeWidth:2.4}),ba=()=>t.jsx(kt.default,{trim:!0,size:null,strokeWidth:2}),jt="M12 2.8l2.8 5.8 6.3.9-4.6 4.4 1.1 6.3L12 17.2l-5.6 3 1.1-6.3L2.9 9.5l6.3-.9z";function va({values:a,mode:i}){const n=(Array.isArray(a)?a:[]).map(k).filter(Number.isFinite);if(n.length<2)return t.jsx("span",{className:"data-grid__empty-val",children:"—"});const l=84,c=26,u=3,o=Math.min(...n),f=Math.max(...n)-o||1,N=n.map((C,F)=>[u+F/(n.length-1)*(l-u*2),u+(1-(C-o)/f)*(c-u*2)]),$=N.map(([C,F])=>`${C.toFixed(1)},${F.toFixed(1)}`).join(" "),P=`${u},${c} ${$} ${(l-u).toFixed(1)},${c}`,A=n.at(-1)>=n[0]?"up":"down",ye=i==="trend"?` is-${A}`:"",[B,xe]=N.at(-1);return t.jsxs("svg",{className:`data-grid__spark${ye}`,viewBox:`0 0 ${l} ${c}`,role:"img","aria-label":`Trend ${A}, from ${n[0]} to ${n.at(-1)}`,children:[t.jsx("polygon",{points:P}),t.jsx("polyline",{points:$}),t.jsx("circle",{cx:B,cy:xe,r:"2.2"})]})}function ka({value:a,max:i=5,showValue:n}){const l=Math.max(0,Math.min(i,k(a)||0));return t.jsxs("span",{className:"data-grid__rating",role:"img","aria-label":`${l} out of ${i}`,children:[Array.from({length:i},(c,u)=>{const o=Math.max(0,Math.min(1,l-u));return t.jsxs("svg",{viewBox:"0 0 24 24","aria-hidden":!0,children:[t.jsx("path",{className:"is-off",d:jt}),o>0&&t.jsx("path",{className:"is-on",d:jt,style:o<1?{clipPath:`inset(0 ${((1-o)*100).toFixed(0)}% 0 0)`}:void 0})]},u)}),n!==!1&&t.jsx("span",{className:"data-grid__rating-val",children:l.toFixed(1)})]})}function Fe({col:a,row:i,index:n}){if(typeof a.cell=="function")return a.cell(i,n);const l=i?.[a.key],c=a.options??{};if(ee(l)&&a.type!=="avatar")return t.jsx("span",{className:"data-grid__empty-val",children:"—"});const u=H(a,i);switch(a.type){case"money":return t.jsx(vt.default,{className:"data-grid__money",value:l,currency:a.currency??c.currency??(c.currencyKey?i[c.currencyKey]:void 0),locale:c.locale,options:c.intl,format:typeof a.format=="function"?o=>a.format(o,i):void 0,tone:c.tone,zeroAsDash:c.zeroAsDash});case"code":return t.jsx("span",{className:"data-grid__text is-mono data-grid__code",children:u});case"number":case"percent":return t.jsx("span",{className:"data-grid__num",children:u});case"currency":return t.jsx("span",{className:"data-grid__money",children:u});case"date":return t.jsx("time",{className:"data-grid__text",dateTime:typeof l=="string"?l:void 0,children:u});case"badge":return t.jsx("span",{className:`data-grid__badge data-grid__badge--${ma(l,c.tones)}`,children:u});case"avatar":{const o=String(l??""),p=c.subtitleKey?i[c.subtitleKey]:null,f=c.imageKey?i[c.imageKey]:null,N=ga(o)%6+1;return t.jsxs("span",{className:"data-grid__person",children:[t.jsx("span",{className:"data-grid__avatar",style:{"--c":`var(--chart-series-${N}, var(--dg-accent))`},"aria-hidden":!0,children:f?t.jsx("img",{src:f,alt:"",loading:"lazy"}):ua(o)}),t.jsxs("span",{className:"data-grid__person-text",children:[t.jsx("span",{className:"data-grid__person-name",children:typeof a.format=="function"?u:o||"—"}),p&&t.jsx("span",{className:"data-grid__person-sub",children:p})]})]})}case"progress":{const o=c.max??100,p=Math.max(0,Math.min(100,k(l)/o*100||0));return t.jsxs("span",{className:"data-grid__progress",children:[t.jsx("span",{className:"data-grid__progress-track",role:"progressbar","aria-valuemin":0,"aria-valuemax":o,"aria-valuenow":k(l),"aria-label":a.label,children:t.jsx("span",{className:`data-grid__progress-fill${p>=100?" is-done":""}`,style:{width:`${p}%`}})}),t.jsx("span",{className:"data-grid__progress-val",children:typeof a.format=="function"?u:`${Math.round(p)}%`})]})}case"sparkline":return t.jsx(va,{values:l,mode:c.color??"accent"});case"rating":return t.jsx(ka,{value:l,max:c.max??5,showValue:c.showValue});case"tags":{const o=Array.isArray(l)?l:[l],p=c.max??3,f=o.slice(0,p);return t.jsxs("span",{className:"data-grid__tags",children:[f.map(N=>{const $=c.tones?.[N];return t.jsx("span",{className:`data-grid__tag${Nt.has($)&&$!=="neutral"?` data-grid__tag--${$}`:""}`,children:N},N)}),o.length>p&&t.jsxs("span",{className:"data-grid__tag is-more",title:o.slice(p).join(", "),children:["+",o.length-p]})]})}case"link":{const o=c.hrefKey?i[c.hrefKey]:c.href;if(!o)return t.jsx("span",{className:"data-grid__text is-strong",children:u});const p=c.external??/^https?:\/\//.test(o);return t.jsxs("a",{className:"data-grid__link",href:o,...p?{target:"_blank",rel:"noreferrer noopener"}:{},onClick:f=>f.stopPropagation(),children:[u,p&&t.jsx(ba,{})]})}case"trend":{const o=k(l),p=c.invert?o<0:o>0,f=o===0?"":p?" is-good":" is-bad";return t.jsxs("span",{className:`data-grid__trend${f}`,children:[o>0?t.jsx(_a,{}):o<0?t.jsx(ja,{}):null,u]})}default:{const o=["data-grid__text",c.strong&&"is-strong",c.mono&&"is-mono",c.muted&&"is-muted",c.maxWidth&&"is-clamp"].filter(Boolean).join(" ");return t.jsx("span",{className:o,style:c.maxWidth?{"--dg-max":typeof c.maxWidth=="number"?`${c.maxWidth}px`:c.maxWidth}:void 0,title:c.maxWidth?u:void 0,children:u})}}}function pe({checked:a,indeterminate:i,onChange:n,label:l}){return t.jsx(la.Checkbox,{size:"sm",className:"data-grid__check",checked:!!a,indeterminate:!!i,"aria-label":l,onChange:n,onClick:c=>c.stopPropagation()})}function We({value:a,onChange:i,label:n,children:l,small:c}){return t.jsxs("label",{className:`data-grid__select${c?" data-grid__select--sm":""}`,children:[t.jsx("span",{className:"data-grid__select-label",children:n}),t.jsx("select",{value:a,onChange:u=>i(u.target.value),children:l}),t.jsx(ya,{})]})}const $t={search:"Search…",clearSearch:"Clear search",sortBy:"Sort by",sortDefault:"Sort: default",selected:a=>`${a} selected`,clear:"Clear",clearFilters:"Clear filters",bulkActions:"Bulk actions",selectAll:"Select all rows",deselectAll:"Deselect all rows",selectAllShort:"Select all",selectRow:a=>`Select ${a}`,rowsPerPage:"Rows per page",previous:"Previous page",next:"Next page",pageOf:(a,i)=>`${a} / ${i}`,goToPage:a=>`Page ${a}`,pagination:"Pagination",noResults:"0 results",range:null,of:"of",resultCount:(a,i)=>`${a} of ${i}`,table:"Data table",loading:"Loading…",error:"Couldn't load the data.",retry:"Retry",all:"All",allOf:a=>`All ${String(a).toLowerCase()}`,action:"Action"};function Na(a,i){if(i<=7)return Array.from({length:i},(u,o)=>o+1);const n=new Set([1,i,a-1,a,a+1]);a<=3&&[2,3,4].forEach(u=>n.add(u)),a>=i-2&&[i-1,i-2,i-3].forEach(u=>n.add(u));const l=[...n].filter(u=>u>=1&&u<=i).sort((u,o)=>u-o),c=[];return l.forEach((u,o)=>{o>0&&u-l[o-1]>1&&c.push(`gap-${u}`),c.push(u)}),c}const bt=[72,54,86,64,48,78,60,92];function Sa({columns:a=[],rows:i=[],rowKey:n="id",searchable:l=!1,filters:c=[],sort:u,pageSize:o,pageSizeOptions:p,selectable:f=!1,defaultSelected:N=[],bulkActions:$=[],density:P="comfortable",striped:A=!1,stickyHeader:ye=!1,maxHeight:B,emptyText:xe="No matching rows",title:C,subtitle:F,actions:_e=[],responsive:qe="scroll",caption:te,className:Ct="",onBulkAction:At,onAction:Ie,onRowClick:G,onSelectionChange:wt,onSortChange:Pe,serverSide:D=!1,page:Dt,pageCount:Be,onPageChange:Ke,totalRows:ae,selected:se,onSelectedChange:Mt,rowTone:Ue,rowHighlighted:Ve,rowHref:Ge,renderLink:Et,bulkBar:Y,loading:O=!1,loadingRows:Ot,error:v,onRetry:Ye,empty:Rt,stickyFirstColumn:je="narrow",mobile:Lt="scroll",renderCard:Je,labels:Tt}){const Ft=j.useId(),g={...$t,...Tt||{}},b=j.useMemo(()=>(Array.isArray(a)?a:[]).filter(e=>e&&e.key!=null),[a]),W=Array.isArray(i)?i:[],be=(e,s)=>(typeof n=="function"?n(e,s):e?.[n])??s,ne=(e,s)=>String(be(e,s)),ve=e=>typeof e.label=="string"?e.label:typeof e.header=="string"?e.header:String(e.key),Ze=e=>e?.key?{key:e.key,dir:e.dir==="desc"?"desc":"asc"}:null,[K,re]=j.useState(""),[ie,Qe]=j.useState({}),[Wt,Xe]=j.useState(()=>Ze(u)),S=D?Ze(u):Wt,[He,et]=j.useState(o>0?o:0),[zt,z]=j.useState(0),le=Array.isArray(se),[tt,qt]=j.useState(()=>new Set((N??[]).map(String))),R=j.useMemo(()=>le?new Set(se.map(String)):tt,[le,se,tt]);j.useEffect(()=>{o>0&&et(o)},[o]);const at=j.useRef(null),[It,Pt]=j.useState("");j.useEffect(()=>{const e=at.current;if(!e)return;const s=()=>{const d=e.scrollWidth-e.clientWidth,m=d<=1?"":`${e.scrollLeft>1?" is-left":""}${e.scrollLeft<d-1?" is-right":""}`;Pt(h=>h===m?h:m)};s(),e.addEventListener("scroll",s,{passive:!0});const r=typeof ResizeObserver<"u"?new ResizeObserver(s):null;return r?.observe(e),e.firstElementChild&&r?.observe(e.firstElementChild),()=>{e.removeEventListener("scroll",s),r?.disconnect()}},[]);const ke=(Array.isArray(c)?c:[]).filter(e=>e&&e.key!=null),st=j.useMemo(()=>Object.fromEntries(b.map(e=>[e.key,e])),[b]),nt=(e,s,r)=>{if(r===""||r==null)return!0;const d=e?.[s.key];return Array.isArray(d)?d.map(String).includes(String(r)):String(d)===String(r)},ce=j.useMemo(()=>{const e=K.trim().toLowerCase(),s=b.filter(r=>r.searchable??ca.has(r.type??"text"));return W.filter(r=>{for(const d of ke)if(!nt(r,d,ie[d.key]))return!1;return e?s.some(d=>H(d,r).toLowerCase().includes(e))||String(typeof n=="function"?n(r):r?.[n]??"").toLowerCase().includes(e):!0})},[W,b,K,ie,c,n]),oe=j.useMemo(()=>{if(D)return ce;const e=S&&st[S.key];if(!e)return ce;const s=S.dir==="desc"?-1:1,r=typeof e.sortValue=="function"?d=>e.sortValue(d):d=>fa(e,d);return ce.map((d,m)=>({row:d,i:m,v:r(d)})).sort((d,m)=>d.v==null&&m.v==null?d.i-m.i:d.v==null?1:m.v==null?-1:(typeof d.v=="number"&&typeof m.v=="number"?d.v-m.v:String(d.v).localeCompare(String(m.v),"en",{numeric:!0}))*s||d.i-m.i).map(d=>d.row)},[ce,S,st,D]),w=Be!=null,L=oe.length,M=w?0:He,T=w?Math.max(1,Number(Be)||1):M>0?Math.max(1,Math.ceil(L/M)):1,y=Math.min(w?Math.max(0,(Number(Dt)||1)-1):zt,T-1),E=M>0?y*M:0,q=M>0?oe.slice(E,E+M):oe,U=(D||w?q:oe).map((e,s)=>ne(e,s)),Ne=U.filter(e=>R.has(e)).length,V=U.length>0&&Ne===U.length,rt=Ne>0&&!V,de=D||w?R.size:Ne,ue=new Map;(le?se:[]).forEach(e=>ue.set(String(e),e)),W.forEach((e,s)=>ue.set(ne(e,s),be(e,s)));const Se=e=>e.map(s=>ue.has(s)?ue.get(s):s),$e=e=>{le||qt(e);const s=Se([...e]);wt?.(s),Mt?.(s)},Ce=e=>{const s=new Set(R);s.has(e)?s.delete(e):s.add(e),$e(s)},it=()=>{const e=new Set(R);V?U.forEach(s=>e.delete(s)):U.forEach(s=>e.add(s)),$e(e)},lt=()=>$e(new Set),ct=D||w?[...R]:[...R].filter(e=>U.includes(e)),Bt=e=>e.firstDir==="asc"||e.firstDir==="desc"?e.firstDir:ze.has(e.type)||e.type==="date"||e.numeric?"desc":"asc",Kt=e=>{const s=Bt(e);let r;!S||S.key!==e.key?r={key:e.key,dir:s}:S.dir===s?r={key:e.key,dir:s==="asc"?"desc":"asc"}:r=D?{key:e.key,dir:s}:null,D||(Xe(r),z(0)),Pe?.(r,r?.key??null,r?.dir??null)},ot=(e,s)=>{Qe(r=>({...r,[e]:s})),z(0)},Ut=()=>{re(""),Qe({}),z(0)},J=e=>{w||z(e),Ke?.(e+1)},Vt=(e,s)=>W.filter(r=>nt(r,e,s)).length,dt=typeof l=="string"?l:g.search,Gt=l||ke.length>0,Ae=K.trim()!==""||Object.values(ie).some(e=>e!==""&&e!=null),ut=b.filter(e=>e.sortable!==!1),gt=[...new Set([...(p??[o,10,25,50]).filter(e=>e>0)])].sort((e,s)=>e-s),Yt=b.length+(f?1:0),we=Lt==="cards",mt=je===!0||je==="always"?"always":je===!1||b[0]?.sticky===!1?null:"narrow",Jt=["data-grid",`data-grid--${P==="compact"?"compact":"comfortable"}`,A&&"data-grid--striped",ye&&"data-grid--sticky",qe==="stack"&&"data-grid--stack",mt&&`data-grid--sticky-first-${mt}`,we&&"data-grid--cards",Ct].filter(Boolean).join(" "),ge=e=>e.align??(Re.has(e.type)||e.numeric?"right":"left"),De=b[0]?.key,ht=e=>{const s=typeof Ue=="function"?Ue(e):null;return s==="danger"||s==="warning"?s:null},ft=e=>typeof Ve=="function"?!!Ve(e):!1,Zt=!O&&!v,pt=Math.max(1,Math.min(12,Ot??(M||o||5))),yt=Rt??t.jsxs("div",{className:"data-grid__empty-inner",children:[t.jsx("span",{className:"data-grid__empty-icon",children:t.jsx(xt.default,{name:Ae?"search":"inbox",size:18})}),t.jsx("p",{className:"data-grid__empty-text",children:xe}),Ae&&t.jsx(he.default,{variant:"ghost",size:"sm",onClick:Ut,children:g.clearFilters})]}),Z=(e,s)=>b.find(r=>r.card===e)??(s?b.find(r=>r.card!==!1&&s(r)):void 0),Qt=(()=>{if(!we)return null;const e=Z("title")??b[0],s=Z("value",x=>x!==e&&(Re.has(x.type)||x.numeric)),r=Z("badge",x=>x!==e&&x.type==="badge"),d=new Set([e,s,r]),m=x=>!d.has(x)&&!ze.has(x.type)&&!x.numeric&&x.type!=="badge"&&x.type!=="tags",h=Z("subtitle",m);d.add(h);const I=Z("meta",m);return{titleCol:e,subtitleCol:h,metaCol:I,valueCol:s,badgeCol:r}})(),Me=(e,s,r)=>e?typeof e.cell=="function"?e.cell(s,r):ee(s?.[e.key])?void 0:H(e,s):void 0,Xt=(e,s)=>{const r=ne(e,E+s),d=f&&R.has(r),m={index:E+s,key:be(e,E+s),selected:d,toggle:()=>Ce(r),tone:ht(e),highlighted:ft(e)};if(typeof Je=="function")return t.jsx("div",{children:Je(e,m)},r);const{titleCol:h,subtitleCol:I,metaCol:x,valueCol:_,badgeCol:Q}=Qt,Oe=H(h??{key:n},e)||r;return t.jsx(_t.default,{title:Me(h,e,s)??r,subtitle:Me(I,e,s),meta:x?Me(x,e,s):void 0,value:_?t.jsx(Fe,{col:_,row:e,index:s}):void 0,badge:Q?t.jsx(Fe,{col:Q,row:e,index:s}):void 0,tone:m.tone,highlighted:m.highlighted,selected:d,href:typeof Ge=="function"?Ge(e):void 0,renderLink:Et,onClick:typeof G=="function"?()=>G(e):void 0,leading:f?t.jsx(pe,{checked:d,onChange:()=>Ce(r),label:typeof g.selectRow=="function"?g.selectRow(Oe):g.selectRow}):void 0},r)},Ee=(()=>{if(w){if(ae!=null&&o>0){const r=L===0?0:y*o+1,d=Math.min(y*o+q.length,ae);return typeof g.range=="function"?g.range(r,d,ae):t.jsxs(t.Fragment,{children:[t.jsxs("strong",{children:[r,"–",d]})," ",g.of," ",t.jsx("strong",{children:ae})]})}return null}if(L===0)return g.noResults;const e=E+1,s=Math.min(E+M,L);return typeof g.range=="function"?g.range(e,s,L):t.jsxs(t.Fragment,{children:[t.jsxs("strong",{children:[e,"–",s]})," ",g.of," ",t.jsx("strong",{children:L})]})})(),Ht=f&&de>0&&Y!=null?typeof Y=="function"?Y({count:de,selected:Se(ct),clear:lt}):Y:null,ea=v?t.jsx(ta.default,{tone:"danger",title:typeof v=="string"?v:v?.message??g.error,description:typeof v=="object"&&v&&!(v instanceof Error)&&!v.message?v:void 0,actions:typeof Ye=="function"?[{label:g.retry,onClick:Ye}]:void 0,className:"data-grid__error"}):null;return t.jsxs("div",{className:Jt,children:[(C||F||_e?.length>0)&&t.jsxs("div",{className:"data-grid__header",children:[t.jsxs("div",{className:"data-grid__titles",children:[C&&t.jsx("h3",{className:"data-grid__title",children:C}),F&&t.jsx("p",{className:"data-grid__subtitle",children:F})]}),_e?.length>0&&t.jsx("div",{className:"data-grid__actions",children:_e.map((e,s)=>e.label?t.jsx(he.default,{size:"sm",variant:e.variant==="primary"?"primary":"secondary",icon:e.icon,onClick:()=>Ie?.(e.label),children:e.label},e.label??s):t.jsx(X.default,{size:"sm",variant:e.variant==="primary"?"primary":"secondary",icon:e.icon,label:e.ariaLabel??g.action,onClick:()=>Ie?.(e.label)},s))})]}),Gt&&t.jsxs("div",{className:"data-grid__controls",children:[l&&t.jsxs("div",{className:"data-grid__search",role:"search",children:[t.jsx(xt.default,{name:"search",size:15}),t.jsx("input",{type:"search",value:K,placeholder:dt,"aria-label":dt.replace(/…$/,""),onChange:e=>{re(e.target.value),z(0)},onKeyDown:e=>e.key==="Escape"&&K&&(e.preventDefault(),re(""))}),K&&t.jsx(aa.default,{icon:t.jsx(xa,{}),label:g.clearSearch,appearance:"clear",className:"data-grid__search-clear",onClick:()=>re("")})]}),ke.map(e=>{const s=(e.options??[]).map(ha),r=ie[e.key]??"",d=e.type==="select"||e.type!=="pills"&&s.length>5,m=e.allLabel??(d?typeof g.allOf=="function"?g.allOf(e.label??e.key):g.allOf:g.all);return d?t.jsxs(We,{label:e.label??e.key,value:r,onChange:h=>ot(e.key,h),children:[t.jsx("option",{value:"",children:m}),s.map(h=>t.jsx("option",{value:String(h.value),children:h.label},String(h.value)))]},e.key):t.jsx("div",{className:"data-grid__pills",role:"group","aria-label":e.label??e.key,children:[{value:"",label:m},...s].map(h=>{const I=String(r)===String(h.value);return t.jsxs("button",{type:"button",className:"data-grid__pill","aria-pressed":I,onClick:()=>ot(e.key,h.value),children:[h.label,e.counts!==!1&&t.jsx("span",{className:"data-grid__pill-count",children:h.value===""?W.length:Vt(e,h.value)})]},String(h.value))})},e.key)}),qe==="stack"&&ut.length>0&&t.jsx("span",{className:"data-grid__sort-mobile",children:t.jsxs(We,{label:g.sortBy,value:S?`${S.key}:${S.dir}`:"",onChange:e=>{const[s,r]=e.split(":"),d=s?{key:s,dir:r}:null;D||(Xe(d),z(0)),Pe?.(d,d?.key??null,d?.dir??null)},children:[t.jsx("option",{value:"",children:g.sortDefault}),ut.flatMap(e=>[t.jsxs("option",{value:`${e.key}:asc`,children:[ve(e)," ↑"]},`${e.key}:asc`),t.jsxs("option",{value:`${e.key}:desc`,children:[ve(e)," ↓"]},`${e.key}:desc`)])]})}),Ae&&t.jsx("span",{className:"data-grid__result","aria-live":"polite",children:typeof g.resultCount=="function"?g.resultCount(L,W.length):`${L} / ${W.length}`})]}),f&&de>0&&Y==null&&t.jsxs("div",{className:"data-grid__bulk",role:"region","aria-label":g.bulkActions,children:[t.jsx("span",{className:"data-grid__bulk-count","aria-live":"polite",children:typeof g.selected=="function"?g.selected(de):g.selected}),($??[]).map((e,s)=>t.jsx(he.default,{size:"sm",tone:e.tone==="danger"?"danger":void 0,icon:e.icon,onClick:()=>At?.(e.label,Se(ct)),children:e.label},e.label??s)),t.jsx(he.default,{variant:"ghost",size:"sm",onClick:lt,children:g.clear})]}),ea,!v&&t.jsx("div",{className:`data-grid__frame${It}`,children:t.jsx("div",{ref:at,className:"data-grid__scroll",style:B?{maxHeight:typeof B=="number"?`${B}px`:B}:void 0,tabIndex:0,role:"region","aria-label":C??te??g.table,"aria-busy":O||void 0,children:t.jsxs("table",{className:"data-grid__table",children:[(te||C)&&t.jsx("caption",{className:"data-grid__select-label",children:te??C}),t.jsx("thead",{children:t.jsxs("tr",{children:[f&&t.jsx("th",{className:"data-grid__th data-grid__check-cell",scope:"col",children:t.jsx(pe,{checked:V,indeterminate:rt,onChange:it,label:V?g.deselectAll:g.selectAll})}),b.map(e=>{const s=ge(e),r=e.sortable!==!1,d=S?.key===e.key?S.dir==="desc"?"descending":"ascending":r?"none":void 0,m=e.width!=null?typeof e.width=="number"?`${e.width}px`:e.width:void 0,h=e.minWidth!=null?typeof e.minWidth=="number"?`${e.minWidth}px`:e.minWidth:m;return t.jsx("th",{scope:"col",className:`data-grid__th${s!=="left"?` is-${s}`:""}${e.key===De?" is-primary":""}`,style:m||h?{width:m,minWidth:h}:void 0,"aria-sort":d,children:r?t.jsxs("button",{type:"button",className:"data-grid__sort",onClick:()=>Kt(e),children:[t.jsx("span",{children:e.header??e.label??e.key}),t.jsx(pa,{})]}):e.header??e.label??e.key},e.key)})]})}),t.jsx("tbody",{children:O?Array.from({length:pt},(e,s)=>t.jsxs("tr",{className:"data-grid__row data-grid__row--loading","aria-hidden":"true",children:[f&&t.jsx("td",{className:"data-grid__td data-grid__check-cell",children:t.jsx(me.SkeletonRect,{width:16,height:16,radius:5})}),b.map((r,d)=>t.jsx("td",{className:`data-grid__td${ge(r)!=="left"?` is-${ge(r)}`:""}${r.key===De?" is-primary":""}`,children:t.jsx(me.SkeletonRect,{width:`${bt[(s+d)%bt.length]}%`,height:10,radius:5,className:"data-grid__skeleton"})},r.key))]},`sk-${s}`)):q.length===0?t.jsx("tr",{children:t.jsx("td",{className:"data-grid__td data-grid__empty",colSpan:Yt,children:yt})}):q.map((e,s)=>{const r=ne(e,E+s),d=f&&R.has(r),m=typeof G=="function",h=ht(e),I=ft(e),x=["data-grid__row",d&&"is-selected",m&&"is-clickable",h&&`is-tone-${h}`,I&&"is-lit"].filter(Boolean).join(" ");return t.jsxs("tr",{className:x,"aria-selected":f?d:void 0,tabIndex:m?0:void 0,onClick:m?()=>G(e):void 0,onKeyDown:m?_=>{_.target===_.currentTarget&&(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),G(e))}:void 0,children:[f&&t.jsx("td",{className:"data-grid__td data-grid__check-cell",children:t.jsx(pe,{checked:d,onChange:()=>Ce(r),label:typeof g.selectRow=="function"?g.selectRow(H(b[0]??{key:n},e)||r):g.selectRow})}),b.map(_=>{const Q=ge(_),Oe=["data-grid__td",Q!=="left"&&`is-${Q}`,_.key===De&&"is-primary",(_.numeric||Re.has(_.type))&&"is-num",_.wrap&&"is-wrap"].filter(Boolean).join(" ");return t.jsx("td",{className:Oe,"data-label":ve(_),children:t.jsx(Fe,{col:_,row:e,index:E+s})},_.key)})]},r)})})]})})}),we&&!v&&t.jsxs("div",{className:"data-grid__cards","aria-busy":O||void 0,children:[f&&Zt&&q.length>0&&t.jsxs("label",{className:"data-grid__cards-all",children:[t.jsx(pe,{checked:V,indeterminate:rt,onChange:it,label:V?g.deselectAll:g.selectAll}),t.jsx("span",{"aria-hidden":"true",children:g.selectAllShort})]}),O?t.jsx("div",{className:"data-grid__cards-loading","aria-label":g.loading,children:Array.from({length:Math.min(pt,5)},(e,s)=>t.jsxs("div",{className:"data-grid__card-skeleton","aria-hidden":"true",children:[t.jsx(me.SkeletonRect,{width:"58%",height:12,radius:6}),t.jsx(me.SkeletonRect,{width:"36%",height:10,radius:5})]},s))}):q.length===0?t.jsx("div",{className:"data-grid__cards-empty",children:yt}):t.jsx(_t.RowCards,{ariaLabel:C??te??g.table,children:q.map((e,s)=>Xt(e,s))})]}),w&&T>1&&!v&&t.jsxs("nav",{className:"data-grid__footer data-grid__footer--center","aria-label":g.pagination,children:[Ee!=null&&t.jsx("span",{className:"data-grid__range","aria-live":"polite",children:Ee}),t.jsxs("span",{className:"data-grid__page-btns",children:[t.jsx(X.default,{size:"sm",icon:"chevron-left",label:g.previous,tooltip:!1,disabled:y===0||O,onClick:()=>J(y-1)}),Na(y+1,T).map(e=>typeof e=="string"?t.jsx("span",{className:"data-grid__page-gap","aria-hidden":"true",children:"…"},e):t.jsx("button",{type:"button",className:`data-grid__btn data-grid__page${e===y+1?" is-current":""}`,"aria-label":typeof g.goToPage=="function"?g.goToPage(e):`${g.goToPage} ${e}`,"aria-current":e===y+1?"page":void 0,disabled:O&&e!==y+1,onClick:()=>e!==y+1&&J(e-1),children:e},e)),t.jsx(X.default,{size:"sm",icon:"chevron-right",label:g.next,tooltip:!1,disabled:y>=T-1||O,onClick:()=>J(y+1)})]})]}),!w&&M>0&&!v&&t.jsxs("div",{className:"data-grid__footer",children:[t.jsx("span",{className:"data-grid__range","aria-live":"polite",children:Ee}),t.jsxs("div",{className:"data-grid__pager",children:[gt.length>1&&t.jsxs("span",{className:"data-grid__per-page",children:[t.jsx("span",{className:"data-grid__per-page-label","aria-hidden":!0,children:g.rowsPerPage}),t.jsx(We,{small:!0,label:g.rowsPerPage,value:String(He),onChange:e=>{et(Number(e)),z(0)},children:gt.map(e=>t.jsx("option",{value:e,children:e},e))})]}),t.jsxs("span",{className:"data-grid__page-btns",children:[t.jsx(X.default,{size:"sm",icon:"chevron-left",label:g.previous,tooltip:!1,disabled:y===0,onClick:()=>J(y-1)}),t.jsx("span",{className:"data-grid__page-num",id:`${Ft}-page`,children:typeof g.pageOf=="function"?g.pageOf(y+1,T):`${y+1} / ${T}`}),t.jsx(X.default,{size:"sm",icon:"chevron-right",label:g.next,tooltip:!1,disabled:y>=T-1,onClick:()=>J(y+1)})]})]})]}),Ht]})}exports.DATA_GRID_LABELS=$t;exports.default=Sa;
|