react-gridix 0.0.0-stage → 0.1.0

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.
@@ -0,0 +1,299 @@
1
+ import { ButtonHTMLAttributes } from 'react';
2
+ import { ComponentType } from 'react';
3
+ import { CSSProperties } from 'react';
4
+ import { ForwardRefExoticComponent } from 'react';
5
+ import { HTMLAttributes } from 'react';
6
+ import { InputHTMLAttributes } from 'react';
7
+ import { JSX as JSX_2 } from 'react';
8
+ import { ReactNode } from 'react';
9
+ import { ReactPortal } from 'react';
10
+ import { RefAttributes } from 'react';
11
+
12
+ export declare function Alert({ tone, title, onClose, className, children, ...rest }: AlertProps): JSX_2.Element;
13
+
14
+ export declare interface AlertProps extends Omit<HTMLAttributes<HTMLDivElement>, "title"> {
15
+ tone?: "info" | "success" | "warning" | "danger";
16
+ title?: ReactNode;
17
+ onClose?: () => void;
18
+ }
19
+
20
+ declare type AnyRow = Record<string, any>;
21
+
22
+ export declare function Badge({ tone, className, children, ...rest }: BadgeProps): JSX_2.Element;
23
+
24
+ export declare interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {
25
+ tone?: "neutral" | "info" | "success" | "warning" | "danger";
26
+ }
27
+
28
+ export declare const Button: ForwardRefExoticComponent<ButtonProps & RefAttributes<HTMLButtonElement>>;
29
+
30
+ export declare interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
31
+ variant?: "primary" | "secondary" | "ghost" | "danger";
32
+ size?: "sm" | "md" | "lg";
33
+ loading?: boolean;
34
+ }
35
+
36
+ export declare function Card({ title, footer, className, children, ...rest }: CardProps): JSX_2.Element;
37
+
38
+ export declare interface CardProps extends Omit<HTMLAttributes<HTMLDivElement>, "title"> {
39
+ title?: ReactNode;
40
+ footer?: ReactNode;
41
+ }
42
+
43
+ export declare interface CellEditableParams<T = Record<string, any>> {
44
+ /** The raw value stored in the row. */
45
+ value: unknown;
46
+ /** The value as text, after `valueFormatter`. */
47
+ formattedValue: string;
48
+ row: T;
49
+ rowIndex: number;
50
+ field: string;
51
+ column: ColumnDef<T>;
52
+ }
53
+
54
+ export declare interface CellEditEvent<T> {
55
+ rowId: string | number;
56
+ rowIndex: number;
57
+ field: string;
58
+ oldValue: unknown;
59
+ newValue: unknown;
60
+ row: T;
61
+ }
62
+
63
+ /** Props received by a column's `cellEditor` component. */
64
+ export declare interface CellEditorProps<T = Record<string, any>> {
65
+ /** The current draft value (starts as the cell's raw value). */
66
+ value: unknown;
67
+ row: T;
68
+ rowIndex: number;
69
+ field: string;
70
+ column: ColumnDef<T>;
71
+ /** Update the draft value without saving it. */
72
+ onChange: (value: unknown) => void;
73
+ /**
74
+ * Save and close the editor. Pass the value to save, or call with no value to save the
75
+ * current draft. `move` also starts editing the neighbouring cell ("down" and so on).
76
+ */
77
+ onCommit: (value?: unknown, move?: MoveDirection) => void;
78
+ /** Close the editor without saving. */
79
+ onCancel: () => void;
80
+ }
81
+
82
+ export declare interface CellParams<T = Record<string, any>> extends CellEditableParams<T> {
83
+ /** Whether this cell may be changed (the column's `editable` setting, or the grid's). */
84
+ editable: boolean;
85
+ /**
86
+ * Saves a new value for this cell straight away, without opening the editor. It runs `validate`
87
+ * and fires `onCellEdit` / `onRowsChange` like any edit. Returns false if the value was rejected
88
+ * or the cell is not editable.
89
+ */
90
+ updateValue: (value: unknown) => boolean;
91
+ }
92
+
93
+ export declare function Checkbox({ checked, onChange, indeterminate, variant, disabled, label, "aria-label": ariaLabel, id, name, indicator, className, style, classNames, styles, }: CheckboxProps): JSX_2.Element;
94
+
95
+ export declare interface CheckboxProps {
96
+ checked: boolean;
97
+ /** Called once per click (or Space key press) with the new value. */
98
+ onChange: (checked: boolean) => void;
99
+ /**
100
+ * Shows the mixed ("some are selected") state, with a dash instead of a tick. Use it together
101
+ * with `checked={false}`. Clicking a mixed checkbox calls `onChange(true)`.
102
+ */
103
+ indeterminate?: boolean;
104
+ /** Default `"native"`. */
105
+ variant?: CheckboxVariant;
106
+ disabled?: boolean;
107
+ /** Text next to the box. Clicking it toggles the checkbox. */
108
+ label?: ReactNode;
109
+ /** Accessible name when there is no visible `label`. */
110
+ "aria-label"?: string;
111
+ id?: string;
112
+ /** Only used by the `"native"` variant. */
113
+ name?: string;
114
+ /** Replaces what is drawn inside the `"button"` and `"tick"` variants (for example `"★"` or your own icon). */
115
+ indicator?: ReactNode;
116
+ /** Classes for the root element (same as `classNames.root`). */
117
+ className?: string;
118
+ /** Inline styles for the root element (same as `styles.root`). */
119
+ style?: CSSProperties;
120
+ /** Classes per part. */
121
+ classNames?: Partial<Record<CheckboxSlot, string>>;
122
+ /** Inline styles per part. */
123
+ styles?: Partial<Record<CheckboxSlot, CSSProperties>>;
124
+ }
125
+
126
+ export declare type CheckboxSlot = "root" | "control" | "indicator" | "label";
127
+
128
+ /**
129
+ * - `"button"`: a `<button>` box with a `<span>` inside that is shown when checked.
130
+ * - `"tick"`: a `<button>` box that fills in and shows a tick when checked.
131
+ * - `"native"`: the browser's own `<input type="checkbox">`.
132
+ */
133
+ export declare type CheckboxVariant = "button" | "tick" | "native";
134
+
135
+ /** Options for the checkbox drawn in a `type: "boolean"` column. */
136
+ export declare interface ColumnCheckboxOptions {
137
+ /** Overrides the grid's `checkboxVariant` for this column. */
138
+ variant?: CheckboxVariant;
139
+ /** Replaces what is drawn inside the `"button"` and `"tick"` variants. */
140
+ indicator?: ReactNode;
141
+ className?: string;
142
+ style?: CSSProperties;
143
+ classNames?: Partial<Record<CheckboxSlot, string>>;
144
+ styles?: Partial<Record<CheckboxSlot, CSSProperties>>;
145
+ }
146
+
147
+ export declare interface ColumnDef<T = Record<string, any>> {
148
+ /** Key of the row object this column reads and writes. */
149
+ field: keyof T & string;
150
+ /** Text shown in the header. Defaults to the field name. */
151
+ headerName?: string;
152
+ /**
153
+ * "number" columns sort numerically and parse edits as numbers.
154
+ * "boolean" columns show a checkbox that toggles with one click (see `checkbox`).
155
+ */
156
+ type?: "text" | "number" | "boolean";
157
+ width?: number | string;
158
+ minWidth?: number | string;
159
+ align?: "left" | "center" | "right";
160
+ /** Overrides the grid-level `sortable`. */
161
+ sortable?: boolean;
162
+ /** Overrides the grid-level `columnFilters`. */
163
+ filterable?: boolean;
164
+ /**
165
+ * `true` / `false`, or a function that decides per cell. Overrides the grid-level `editable`.
166
+ * Example: `editable: ({ row }) => row.status !== "locked"`.
167
+ */
168
+ editable?: boolean | ((params: CellEditableParams<T>) => boolean);
169
+ /** Text used for display, global search and filtering. */
170
+ valueFormatter?: (value: any, row: T) => string;
171
+ /** Turns the typed text into the stored value. */
172
+ valueParser?: (text: string, row: T) => unknown;
173
+ /** Return false to reject an edit. The editor stays open and is marked invalid. */
174
+ validate?: (value: unknown, row: T) => boolean;
175
+ /** Custom sort. Return a negative, zero or positive number. */
176
+ comparator?: (a: any, b: any, rowA: T, rowB: T) => number;
177
+ /** A React component that renders the cell content. Define it outside render so it keeps its identity. */
178
+ cellRenderer?: ComponentType<CellParams<T>>;
179
+ /** A React component used instead of the text box when editing this column. */
180
+ cellEditor?: ComponentType<CellEditorProps<T>>;
181
+ /** A React component that renders the header label (the sort arrow is still added). */
182
+ headerRenderer?: ComponentType<HeaderRendererProps<T>>;
183
+ /** A React component that replaces the filter text box under the header. */
184
+ filterRenderer?: ComponentType<FilterRendererProps<T>>;
185
+ headerClassName?: string;
186
+ headerStyle?: CSSProperties;
187
+ cellClassName?: string | ((params: CellParams<T>) => string);
188
+ cellStyle?: CSSProperties | ((params: CellParams<T>) => CSSProperties);
189
+ /** Look of the checkbox in a `type: "boolean"` column. */
190
+ checkbox?: ColumnCheckboxOptions;
191
+ /**
192
+ * For `type: "boolean"` columns: draws a checkbox in the header, with the header name as its
193
+ * label. Clicking it checks every row that matches the current search and filters (all pages),
194
+ * or unchecks them all when they are already checked. It shows a mixed state when only some
195
+ * are checked. Ignored when the column has a `headerRenderer`.
196
+ */
197
+ headerCheckbox?: boolean;
198
+ }
199
+
200
+ export declare function DataGrid<T extends AnyRow = AnyRow>({ columns, rows, getRowId, editable, enterMovesDown, onCellEdit, onRowsChange, sortable, defaultSort, onSortChange, searchable, searchPlaceholder, columnFilters, pagination, paginationPosition, pageSize: initialPageSize, pageSizeOptions, onRowClick, toolbar, emptyMessage, striped, checkboxVariant, maxHeight, className, style, classNames, styles, rowClassName, rowStyle, }: DataGridProps<T>): JSX_2.Element;
201
+
202
+ export declare interface DataGridProps<T = Record<string, any>> {
203
+ columns: ColumnDef<T>[];
204
+ rows: T[];
205
+ /** Stable id for each row. Defaults to the row's index in `rows`. */
206
+ getRowId?: (row: T, index: number) => string | number;
207
+ /** Allow editing cells (double-click, Enter/F2, or just start typing). Default false. */
208
+ editable?: boolean;
209
+ /**
210
+ * After Enter saves a cell, start editing the cell below (Shift+Enter: the cell above).
211
+ * Tab and Shift+Tab move across the row. Default true.
212
+ */
213
+ enterMovesDown?: boolean;
214
+ /** Fires after a cell edit is committed. */
215
+ onCellEdit?: (event: CellEditEvent<T>) => void;
216
+ /** Fires with the full updated array after a cell edit. Handy for `setRows`. */
217
+ onRowsChange?: (rows: T[]) => void;
218
+ /** Header click sorting. Default true. */
219
+ sortable?: boolean;
220
+ /** Uncontrolled initial sort. */
221
+ defaultSort?: SortModel | null;
222
+ onSortChange?: (sort: SortModel | null) => void;
223
+ /** Global search box above the grid. Default true. */
224
+ searchable?: boolean;
225
+ searchPlaceholder?: string;
226
+ /** Per-column filter inputs under the header. Default true. */
227
+ columnFilters?: boolean;
228
+ /** Default true. */
229
+ pagination?: boolean;
230
+ /** Where the row count and page controls go: "bottom" (default), "top" or "both". */
231
+ paginationPosition?: PaginationPosition;
232
+ pageSize?: number;
233
+ pageSizeOptions?: number[];
234
+ onRowClick?: (row: T, rowIndex: number) => void;
235
+ /** Extra content on the right side of the toolbar. */
236
+ toolbar?: ReactNode;
237
+ emptyMessage?: ReactNode;
238
+ striped?: boolean;
239
+ /** Checkbox style for `type: "boolean"` columns: "button", "tick" or "native" (default). */
240
+ checkboxVariant?: CheckboxVariant;
241
+ /** Makes the body scroll with a sticky header, e.g. 400 or "60vh". */
242
+ maxHeight?: number | string;
243
+ /** Tailwind or any CSS classes for the root element. */
244
+ className?: string;
245
+ /** Inline styles for the root element. */
246
+ style?: CSSProperties;
247
+ /** Classes per part of the grid. */
248
+ classNames?: Partial<Record<GridSlot, string>>;
249
+ /** Inline styles per part of the grid. */
250
+ styles?: Partial<Record<GridSlot, CSSProperties>>;
251
+ rowClassName?: string | ((row: T, rowIndex: number) => string);
252
+ rowStyle?: CSSProperties | ((row: T, rowIndex: number) => CSSProperties);
253
+ }
254
+
255
+ /** Props received by a column's `filterRenderer` component. */
256
+ export declare interface FilterRendererProps<T = Record<string, any>> {
257
+ column: ColumnDef<T>;
258
+ value: string;
259
+ onChange: (value: string) => void;
260
+ }
261
+
262
+ export declare type GridSlot = "root" | "toolbar" | "search" | "scroll" | "table" | "thead" | "headerRow" | "headerCell" | "filterRow" | "filterCell" | "filterInput" | "tbody" | "row" | "cell" | "editor" | "empty" | "footer" | "rowCount" | "pageInfo" | "pageSize" | "pagination" | "pageButton" | "checkbox" | "checkboxControl" | "checkboxIndicator";
263
+
264
+ /** Props received by a column's `headerRenderer` component. */
265
+ export declare interface HeaderRendererProps<T = Record<string, any>> {
266
+ column: ColumnDef<T>;
267
+ sortDirection: SortDirection | null;
268
+ }
269
+
270
+ export declare const Input: ForwardRefExoticComponent<InputProps & RefAttributes<HTMLInputElement>>;
271
+
272
+ export declare interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
273
+ label?: string;
274
+ error?: string;
275
+ hint?: string;
276
+ }
277
+
278
+ export declare function Modal({ open, onClose, title, footer, children }: ModalProps): ReactPortal | null;
279
+
280
+ export declare interface ModalProps {
281
+ open: boolean;
282
+ onClose: () => void;
283
+ title?: ReactNode;
284
+ footer?: ReactNode;
285
+ children?: ReactNode;
286
+ }
287
+
288
+ export declare type MoveDirection = "down" | "up" | "left" | "right" | "none";
289
+
290
+ export declare type PaginationPosition = "bottom" | "top" | "both";
291
+
292
+ export declare type SortDirection = "asc" | "desc";
293
+
294
+ export declare interface SortModel {
295
+ field: string;
296
+ direction: SortDirection;
297
+ }
298
+
299
+ export { }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),h=require("react"),Ue=require("react-dom"),Xe=h.forwardRef(function({variant:d="primary",size:c="md",loading:k=!1,disabled:_,className:b,children:p,...m},D){const v=["rk-btn",`rk-btn--${d}`,`rk-btn--${c}`,b].filter(Boolean).join(" ");return l.jsxs("button",{ref:D,className:v,disabled:_||k,"aria-busy":k||void 0,...m,children:[k&&l.jsx("span",{className:"rk-spinner","aria-hidden":"true"}),p]})}),Ze=h.forwardRef(function({label:d,error:c,hint:k,id:_,className:b,...p},m){const D=h.useId(),v=_??D,C=c||k?`${v}-desc`:void 0;return l.jsxs("div",{className:["rk-field",b].filter(Boolean).join(" "),children:[d&&l.jsx("label",{className:"rk-label",htmlFor:v,children:d}),l.jsx("input",{ref:m,id:v,className:`rk-input${c?" rk-input--error":""}`,"aria-invalid":c?!0:void 0,"aria-describedby":C,...p}),(c||k)&&l.jsx("span",{id:C,className:c?"rk-error-text":"rk-hint",children:c??k})]})});function et({title:i,footer:d,className:c,children:k,..._}){return l.jsxs("div",{className:["rk-card",c].filter(Boolean).join(" "),..._,children:[i&&l.jsx("div",{className:"rk-card__header",children:i}),l.jsx("div",{className:"rk-card__body",children:k}),d&&l.jsx("div",{className:"rk-card__footer",children:d})]})}function tt({tone:i="neutral",className:d,children:c,...k}){return l.jsx("span",{className:["rk-badge",`rk-badge--${i}`,d].filter(Boolean).join(" "),...k,children:c})}function rt({tone:i="info",title:d,onClose:c,className:k,children:_,...b}){return l.jsxs("div",{role:i==="danger"||i==="warning"?"alert":"status",className:["rk-alert",`rk-alert--${i}`,k].filter(Boolean).join(" "),...b,children:[l.jsxs("div",{className:"rk-alert__content",children:[d&&l.jsx("strong",{className:"rk-alert__title",children:d}),l.jsx("div",{children:_})]}),c&&l.jsx("button",{type:"button",className:"rk-alert__close","aria-label":"Dismiss",onClick:c,children:"×"})]})}function nt({open:i,onClose:d,title:c,footer:k,children:_}){const b=h.useId(),p=h.useRef(null);return h.useEffect(()=>{var C;if(!i)return;const m=document.activeElement;(C=p.current)==null||C.focus();const D=M=>{M.key==="Escape"&&d()};document.addEventListener("keydown",D);const v=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{var M;document.removeEventListener("keydown",D),document.body.style.overflow=v,(M=m==null?void 0:m.focus)==null||M.call(m)}},[i,d]),!i||typeof document>"u"?null:Ue.createPortal(l.jsx("div",{className:"rk-overlay",onMouseDown:m=>m.target===m.currentTarget&&d(),children:l.jsxs("div",{ref:p,role:"dialog","aria-modal":"true","aria-labelledby":c?b:void 0,tabIndex:-1,className:"rk-modal",children:[c&&l.jsxs("div",{className:"rk-modal__header",children:[l.jsx("h2",{id:b,className:"rk-modal__title",children:c}),l.jsx("button",{type:"button",className:"rk-alert__close","aria-label":"Close",onClick:d,children:"×"})]}),l.jsx("div",{className:"rk-modal__body",children:_}),k&&l.jsx("div",{className:"rk-modal__footer",children:k})]})}),document.body)}const H=(...i)=>i.filter(Boolean).join(" ");function lt(){return l.jsx("svg",{viewBox:"0 0 16 16",width:"100%",height:"100%","aria-hidden":"true",focusable:"false",children:l.jsx("path",{d:"M3.5 8.5l3 3 6-7",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function it(){return l.jsx("svg",{viewBox:"0 0 16 16",width:"100%",height:"100%","aria-hidden":"true",focusable:"false",children:l.jsx("path",{d:"M4 8h8",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round"})})}function fe({checked:i,onChange:d,indeterminate:c=!1,variant:k="native",disabled:_=!1,label:b,"aria-label":p,id:m,name:D,indicator:v,className:C,style:M,classNames:P={},styles:j={}}){const S=c?"indeterminate":i?"checked":"unchecked";return l.jsxs("label",{className:H("rk-checkbox",`rk-checkbox--${k}`,S==="checked"&&"rk-checkbox--checked",c&&"rk-checkbox--indeterminate",_&&"rk-checkbox--disabled",P.root,C),style:{...j.root,...M},"data-state":S,children:[k==="native"?l.jsx("input",{type:"checkbox",id:m,name:D,ref:K=>{K&&(K.indeterminate=c)},className:H("rk-checkbox__control",P.control),style:j.control,checked:i,disabled:_,"aria-label":p,"data-state":S,onChange:K=>d(K.target.checked)}):l.jsx("button",{type:"button",role:"checkbox",id:m,className:H("rk-checkbox__control",P.control),style:j.control,"aria-checked":c?"mixed":i,"aria-label":p,disabled:_,"data-state":S,onClick:()=>d(!i),children:l.jsx("span",{className:H("rk-checkbox__indicator",v!==void 0&&!c&&"rk-checkbox__indicator--custom",P.indicator),style:j.indicator,"data-state":S,"aria-hidden":"true",children:c?k==="tick"?l.jsx(it,{}):null:v!==void 0?v:k==="tick"?l.jsx(lt,{}):null})}),b!=null&&l.jsx("span",{className:H("rk-checkbox__label",P.label),style:j.label,children:b})]})}const T=(...i)=>i.filter(Boolean).join(" "),Se=(i,d)=>`${typeof i}:${i}\0${d}`;function ue(i,d){const c=d[i.field];return i.valueFormatter?i.valueFormatter(c,d):i.type==="boolean"&&typeof c=="boolean"?c?"Yes":"No":c==null?"":c instanceof Date?c.toLocaleDateString():String(c)}function ot(i,d){return typeof i=="number"&&typeof d=="number"?i-d:i instanceof Date&&d instanceof Date?i.getTime()-d.getTime():typeof i=="boolean"&&typeof d=="boolean"?Number(i)-Number(d):String(i).localeCompare(String(d),void 0,{numeric:!0,sensitivity:"base"})}function at({columns:i,rows:d,getRowId:c,editable:k=!1,enterMovesDown:_=!0,onCellEdit:b,onRowsChange:p,sortable:m=!0,defaultSort:D=null,onSortChange:v,searchable:C=!0,searchPlaceholder:M="Search…",columnFilters:P=!0,pagination:j=!0,paginationPosition:S="bottom",pageSize:K=10,pageSizeOptions:ne=[5,10,25,50],onRowClick:le,toolbar:he,emptyMessage:Ie="No rows to show",striped:Be=!1,checkboxVariant:Te="native",maxHeight:ke,className:$e,style:Me,classNames:I={},styles:w={},rowClassName:ie,rowStyle:oe}){const g=(e,t)=>({className:T(t,I[e]),style:w[e]}),[xe,be]=h.useState(d),V=h.useRef(d);h.useEffect(()=>{V.current=d,be(d)},[d]);const ge=e=>{V.current=e,be(e)},[J,Pe]=h.useState(""),[A,me]=h.useState({}),[N,Ke]=h.useState(D),[Re,q]=h.useState(0),[B,Fe]=h.useState(K),[z,W]=h.useState(null),R=h.useRef(0),Q=h.useRef(null),ae=h.useRef(new Map),pe=h.useMemo(()=>xe.map((e,t)=>({row:e,index:t,id:c?c(e,t):t})),[xe,c]),G=h.useMemo(()=>{const e=J.trim().toLowerCase(),t=Object.entries(A).filter(([,n])=>n.trim()!=="");let r=pe.filter(({row:n})=>e&&!i.some(s=>ue(s,n).toLowerCase().includes(e))?!1:t.every(([o,s])=>{const f=i.find(a=>a.field===o);return f?ue(f,n).toLowerCase().includes(s.trim().toLowerCase()):!0}));if(N){const n=i.find(o=>o.field===N.field);if(n){const o=N.direction==="asc"?1:-1;r=[...r].sort((s,f)=>{const a=s.row[n.field],u=f.row[n.field],x=a==null||a==="",y=u==null||u==="";return x||y?x===y?0:x?1:-1:(n.comparator?n.comparator(a,u,s.row,f.row):ot(a,u))*o})}}return r},[pe,i,J,A,N]);h.useEffect(()=>q(0),[J,A,N,B]);const F=G.length,O=j?Math.max(1,Math.ceil(F/B)):1,E=Math.min(Re,O-1),$=j?G.slice(E*B,E*B+B):G,Le=F===0?0:j?E*B+1:1,Ve=j?Math.min(F,(E+1)*B):F,_e=e=>e.sortable??m,ve=e=>e.filterable??P,U=(e,t,r)=>({value:t[e.field],formattedValue:ue(e,t),row:t,rowIndex:r,field:e.field,column:e}),se=(e,t)=>{const r=e.editable??k;return typeof r=="function"?r(t):!!r},X=(e,t)=>se(e,t)&&!(e.type==="boolean"&&!e.cellEditor),Ae=(e,t)=>{const r=U(e,t.row,t.index),n=se(e,r);return{...r,editable:n,updateValue:o=>n&&ye(t,e,{value:o})}},je=e=>{if(!_e(e))return;let t;!N||N.field!==e.field?t={field:e.field,direction:"asc"}:N.direction==="asc"?t={field:e.field,direction:"desc"}:t=null,Ke(t),v==null||v(t)},Z=(e,t)=>{var r;return(r=ae.current.get(Se(e,t)))==null?void 0:r.focus()},L=()=>{R.current+=1,W(null)},ee=(e,t,r={})=>{if(!X(t,U(t,e.row,e.index)))return!1;const n=e.row[t.field],o=t.cellEditor?n:r.text??(n==null?"":String(n));return Q.current=o,R.current+=1,W({id:e.id,field:t.field,draft:o,session:R.current,select:r.select??"end",invalid:!1}),!0},ye=(e,t,r)=>{const n=V.current[e.index]??e.row,o=n[t.field];let s;if("value"in r)s=r.value;else if(t.valueParser)s=t.valueParser(r.text,n);else if(t.type==="number")if(r.text.trim()==="")s=null;else{const u=Number(r.text);if(!Number.isFinite(u))return!1;s=u}else s=r.text;if(Object.is(s,o))return!0;if(t.validate&&!t.validate(s,n))return!1;const f={...n,[t.field]:s},a=V.current.map((u,x)=>x===e.index?f:u);return ge(a),b==null||b({rowId:e.id,rowIndex:e.index,field:t.field,oldValue:o,newValue:s,row:f}),p==null||p(a),!0},Ne=(e,t,r)=>{const n=$.findIndex(x=>x.id===e.id),o=i.findIndex(x=>x.field===t);if(n<0||o<0)return null;const s=(x,y)=>X(y,U(y,x.row,x.index));if(r==="down"||r==="up"){const x=r==="down"?1:-1;for(let y=n+x;y>=0&&y<$.length;y+=x)if(s($[y],i[o]))return{entry:$[y],col:i[o]};return null}const f=r==="right"?1:-1;let a=n,u=o+f;for(;a>=0&&a<$.length;){for(;u>=0&&u<i.length;){if(s($[a],i[u]))return{entry:$[a],col:i[u]};u+=f}a+=f,u=f>0?0:i.length-1}return null},Y=(e,t,r,n={})=>{const{move:o="none",focus:s=!0}=n;if(!ye(e,t,r))return W(a=>a&&{...a,invalid:!0}),!1;const f=o==="none"?null:Ne(e,t.field,o);return f?ee(f.entry,f.col,{select:"all"}):(L(),s&&Z(e.id,t.field)),!0},qe=(e,t,r)=>{if(e.nativeEvent.isComposing)return;const n=e.currentTarget.value;if(e.key==="Enter"){e.preventDefault();const o=_?e.shiftKey?"up":"down":"none";Y(t,r,{text:n},{move:o})}else if(e.key==="Escape")e.preventDefault(),L(),Z(t.id,r.field);else if(e.key==="Tab"){const o=e.shiftKey?"left":"right";Ne(t,r.field,o)&&(e.preventDefault(),Y(t,r,{text:n},{move:o}))}},ze=(e,t,r,n)=>{e.target!==e.currentTarget||!X(r,n)||(e.key==="Enter"||e.key==="F2"?(e.preventDefault(),ee(t,r)):!r.cellEditor&&e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&(e.preventDefault(),ee(t,r,{text:e.key})))},We=(e,t,r)=>t.cellEditor?l.jsx("div",{className:"rk-grid__custom-editor",onBlur:n=>{n.currentTarget.contains(n.relatedTarget)||r.session===R.current&&(Y(e,t,{value:Q.current},{focus:!1})||L())},onKeyDown:n=>{n.key==="Escape"&&(n.preventDefault(),n.stopPropagation(),L(),Z(e.id,t.field))},children:h.createElement(t.cellEditor,{value:r.draft,row:e.row,rowIndex:e.index,field:t.field,column:t,onChange:n=>{Q.current=n,W(o=>o&&o.session===r.session?{...o,draft:n,invalid:!1}:o)},onCommit:(n,o="none")=>{r.session===R.current&&Y(e,t,{value:n===void 0?Q.current:n},{move:o})},onCancel:()=>{L(),Z(e.id,t.field)}})}):l.jsx("input",{autoFocus:!0,className:T("rk-grid__editor",r.invalid&&"rk-grid__editor--invalid",I.editor),style:{textAlign:t.align,...w.editor},value:r.draft===null||r.draft===void 0?"":String(r.draft),inputMode:t.type==="number"?"decimal":void 0,"aria-label":`Edit ${t.headerName??t.field}`,"aria-invalid":r.invalid||void 0,onChange:n=>{const o=n.target.value;W(s=>s&&{...s,draft:o,invalid:!1})},onFocus:n=>{const o=n.currentTarget;r.select==="all"?o.select():o.setSelectionRange(o.value.length,o.value.length)},onBlur:n=>{r.session===R.current&&(Y(e,t,{text:n.currentTarget.value},{focus:!1})||L())},onKeyDown:n=>qe(n,e,t)}),we=e=>{var r,n,o,s,f,a,u,x;const t=e.checkbox??{};return{variant:t.variant??Te,indicator:t.indicator,className:t.className,style:t.style,classNames:{root:T(I.checkbox,(r=t.classNames)==null?void 0:r.root),control:T(I.checkboxControl,(n=t.classNames)==null?void 0:n.control),indicator:T(I.checkboxIndicator,(o=t.classNames)==null?void 0:o.indicator),label:(s=t.classNames)==null?void 0:s.label},styles:{root:{...w.checkbox,...(f=t.styles)==null?void 0:f.root},control:{...w.checkboxControl,...(a=t.styles)==null?void 0:a.control},indicator:{...w.checkboxIndicator,...(u=t.styles)==null?void 0:u.indicator},label:(x=t.styles)==null?void 0:x.label}}},te=e=>e.stopPropagation(),Ge=(e,t)=>l.jsx("span",{className:"rk-grid__checkbox-cell",onClick:te,onDoubleClick:te,children:l.jsx(fe,{...we(e),checked:!!t.value,disabled:!t.editable,"aria-label":`Toggle ${e.headerName??e.field}`,onChange:r=>t.updateValue(r)})}),Ee=e=>G.filter(t=>se(e,U(e,t.row,t.index))),Oe=(e,t)=>{const r=new Map(Ee(e).map(s=>[s.index,s])),n=[],o=V.current.map((s,f)=>{const a=r.get(f);if(!a)return s;const u=s[e.field];if(!!u===t||e.validate&&!e.validate(t,s))return s;const x={...s,[e.field]:t};return n.push({rowId:a.id,rowIndex:f,field:e.field,oldValue:u,newValue:t,row:x}),x});n.length!==0&&(ge(o),n.forEach(s=>b==null?void 0:b(s)),p==null||p(o))},Ye=e=>{const t=Ee(e),r=t.length>0?t:G,n=r.filter(s=>!!s.row[e.field]).length,o=r.length>0&&n===r.length;return l.jsx("span",{className:"rk-grid__header-checkbox",onClick:te,onDoubleClick:te,children:l.jsx(fe,{...we(e),checked:o,indeterminate:n>0&&!o,disabled:t.length===0,label:e.headerName??e.field,onChange:s=>Oe(e,s)})})},He=j&&(S==="top"||S==="both"),Je=!j||S==="bottom"||S==="both",De=e=>l.jsxs("div",{className:T("rk-grid__footer",e==="top"&&"rk-grid__footer--top",I.footer),style:w.footer,"data-position":e,children:[l.jsx("span",{...g("rowCount","rk-grid__count"),children:F===0?"0 rows":`${Le}–${Ve} of ${F}`}),j&&l.jsxs("div",{...g("pagination","rk-grid__pagination"),children:[l.jsxs("label",{className:"rk-grid__page-size-label",children:["Rows per page",l.jsx("select",{value:B,onChange:t=>Fe(Number(t.target.value)),...g("pageSize","rk-grid__page-size"),children:(ne.includes(B)?ne:[...ne,B].sort((t,r)=>t-r)).map(t=>l.jsx("option",{value:t,children:t},t))})]}),l.jsx("button",{type:"button","aria-label":"First page",disabled:E===0,onClick:()=>q(0),...g("pageButton","rk-grid__page-btn"),children:"«"}),l.jsx("button",{type:"button","aria-label":"Previous page",disabled:E===0,onClick:()=>q(E-1),...g("pageButton","rk-grid__page-btn"),children:"‹"}),l.jsxs("span",{...g("pageInfo","rk-grid__page-info"),children:["Page ",E+1," of ",O]}),l.jsx("button",{type:"button","aria-label":"Next page",disabled:E>=O-1,onClick:()=>q(E+1),...g("pageButton","rk-grid__page-btn"),children:"›"}),l.jsx("button",{type:"button","aria-label":"Last page",disabled:E>=O-1,onClick:()=>q(O-1),...g("pageButton","rk-grid__page-btn"),children:"»"})]})]}),Qe=i.some(ve);return l.jsxs("div",{className:T("rk-grid",I.root,$e),style:{...w.root,...Me},children:[(C||he)&&l.jsxs("div",{...g("toolbar","rk-grid__toolbar"),children:[C?l.jsx("input",{type:"search",value:J,onChange:e=>Pe(e.target.value),placeholder:M,"aria-label":"Search all columns",...g("search","rk-grid__search")}):l.jsx("span",{}),he]}),He&&De("top"),l.jsx("div",{...g("scroll","rk-grid__scroll"),style:{...w.scroll,...ke!==void 0?{maxHeight:ke}:null},children:l.jsxs("table",{...g("table","rk-grid__table"),role:"grid",children:[l.jsxs("thead",{...g("thead","rk-grid__thead"),children:[l.jsx("tr",{...g("headerRow","rk-grid__tr"),children:i.map(e=>{const t=(N==null?void 0:N.field)===e.field?N.direction:null,r=_e(e);return l.jsx("th",{scope:"col","aria-sort":t?t==="asc"?"ascending":"descending":r?"none":void 0,tabIndex:r?0:void 0,onClick:()=>je(e),onKeyDown:n=>{r&&n.target===n.currentTarget&&(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),je(e))},className:T("rk-grid__th",r&&"rk-grid__th--sortable",I.headerCell,e.headerClassName),style:{width:e.width,minWidth:e.minWidth,textAlign:e.align,...w.headerCell,...e.headerStyle},children:l.jsxs("span",{className:"rk-grid__th-content",children:[e.headerRenderer?h.createElement(e.headerRenderer,{column:e,sortDirection:t}):e.headerCheckbox&&e.type==="boolean"?Ye(e):e.headerName??e.field,r&&l.jsx("span",{className:"rk-grid__sort","aria-hidden":"true",children:t==="asc"?"▲":t==="desc"?"▼":"↕"})]})},e.field)})}),Qe&&l.jsx("tr",{...g("filterRow","rk-grid__tr"),children:i.map(e=>l.jsx("th",{...g("filterCell","rk-grid__filter-cell"),children:ve(e)&&(e.filterRenderer?h.createElement(e.filterRenderer,{column:e,value:A[e.field]??"",onChange:t=>me(r=>({...r,[e.field]:t}))}):l.jsx("input",{value:A[e.field]??"",onChange:t=>me(r=>({...r,[e.field]:t.target.value})),placeholder:"Filter","aria-label":`Filter ${e.headerName??e.field}`,...g("filterInput","rk-grid__filter-input")}))},e.field))})]}),l.jsx("tbody",{...g("tbody","rk-grid__tbody"),children:$.length===0?l.jsx("tr",{children:l.jsx("td",{colSpan:i.length,...g("empty","rk-grid__empty"),children:Ie})}):$.map((e,t)=>{const{row:r,id:n,index:o}=e,s=typeof ie=="function"?ie(r,o):ie,f=typeof oe=="function"?oe(r,o):oe;return l.jsx("tr",{onClick:le?()=>le(r,o):void 0,className:T("rk-grid__tr","rk-grid__row",Be&&t%2===1&&"rk-grid__row--striped",le&&"rk-grid__row--clickable",I.row,s),style:{...w.row,...f},children:i.map(a=>{const u=Ae(a,e),x=typeof a.cellClassName=="function"?a.cellClassName(u):a.cellClassName,y=typeof a.cellStyle=="function"?a.cellStyle(u):a.cellStyle,de=z!==null&&z.id===n&&z.field===a.field,ce=X(a,u);return l.jsx("td",{ref:re=>{const Ce=Se(n,a.field);re?ae.current.set(Ce,re):ae.current.delete(Ce)},tabIndex:ce?0:void 0,onDoubleClick:ce?()=>ee(e,a):void 0,onKeyDown:re=>ze(re,e,a,u),className:T("rk-grid__td",ce&&"rk-grid__td--editable",de&&"rk-grid__td--editing",I.cell,x),style:{textAlign:a.align,...w.cell,...y},children:de&&z?We(e,a,z):a.cellRenderer?h.createElement(a.cellRenderer,u):a.type==="boolean"&&!a.cellEditor?Ge(a,u):u.formattedValue},a.field)})},n)})})]})}),Je&&De("bottom")]})}exports.Alert=rt;exports.Badge=tt;exports.Button=Xe;exports.Card=et;exports.Checkbox=fe;exports.DataGrid=at;exports.Input=Ze;exports.Modal=nt;
@@ -0,0 +1,614 @@
1
+ import { jsxs as p, jsx as o } from "react/jsx-runtime";
2
+ import { forwardRef as je, useId as Me, useRef as Q, useEffect as be, useState as M, useMemo as $e, createElement as ie } from "react";
3
+ import { createPortal as lt } from "react-dom";
4
+ const ut = je(function({ variant: s = "primary", size: c = "md", loading: h = !1, disabled: v, className: b, children: _, ...m }, E) {
5
+ const x = ["rk-btn", `rk-btn--${s}`, `rk-btn--${c}`, b].filter(Boolean).join(" ");
6
+ return /* @__PURE__ */ p("button", { ref: E, className: x, disabled: v || h, "aria-busy": h || void 0, ...m, children: [
7
+ h && /* @__PURE__ */ o("span", { className: "rk-spinner", "aria-hidden": "true" }),
8
+ _
9
+ ] });
10
+ }), ft = je(function({ label: s, error: c, hint: h, id: v, className: b, ..._ }, m) {
11
+ const E = Me(), x = v ?? E, I = c || h ? `${x}-desc` : void 0;
12
+ return /* @__PURE__ */ p("div", { className: ["rk-field", b].filter(Boolean).join(" "), children: [
13
+ s && /* @__PURE__ */ o("label", { className: "rk-label", htmlFor: x, children: s }),
14
+ /* @__PURE__ */ o(
15
+ "input",
16
+ {
17
+ ref: m,
18
+ id: x,
19
+ className: `rk-input${c ? " rk-input--error" : ""}`,
20
+ "aria-invalid": c ? !0 : void 0,
21
+ "aria-describedby": I,
22
+ ..._
23
+ }
24
+ ),
25
+ (c || h) && /* @__PURE__ */ o("span", { id: I, className: c ? "rk-error-text" : "rk-hint", children: c ?? h })
26
+ ] });
27
+ });
28
+ function ht({ title: l, footer: s, className: c, children: h, ...v }) {
29
+ return /* @__PURE__ */ p("div", { className: ["rk-card", c].filter(Boolean).join(" "), ...v, children: [
30
+ l && /* @__PURE__ */ o("div", { className: "rk-card__header", children: l }),
31
+ /* @__PURE__ */ o("div", { className: "rk-card__body", children: h }),
32
+ s && /* @__PURE__ */ o("div", { className: "rk-card__footer", children: s })
33
+ ] });
34
+ }
35
+ function kt({ tone: l = "neutral", className: s, children: c, ...h }) {
36
+ return /* @__PURE__ */ o("span", { className: ["rk-badge", `rk-badge--${l}`, s].filter(Boolean).join(" "), ...h, children: c });
37
+ }
38
+ function bt({ tone: l = "info", title: s, onClose: c, className: h, children: v, ...b }) {
39
+ return /* @__PURE__ */ p(
40
+ "div",
41
+ {
42
+ role: l === "danger" || l === "warning" ? "alert" : "status",
43
+ className: ["rk-alert", `rk-alert--${l}`, h].filter(Boolean).join(" "),
44
+ ...b,
45
+ children: [
46
+ /* @__PURE__ */ p("div", { className: "rk-alert__content", children: [
47
+ s && /* @__PURE__ */ o("strong", { className: "rk-alert__title", children: s }),
48
+ /* @__PURE__ */ o("div", { children: v })
49
+ ] }),
50
+ c && /* @__PURE__ */ o("button", { type: "button", className: "rk-alert__close", "aria-label": "Dismiss", onClick: c, children: "×" })
51
+ ]
52
+ }
53
+ );
54
+ }
55
+ function gt({ open: l, onClose: s, title: c, footer: h, children: v }) {
56
+ const b = Me(), _ = Q(null);
57
+ return be(() => {
58
+ var I;
59
+ if (!l) return;
60
+ const m = document.activeElement;
61
+ (I = _.current) == null || I.focus();
62
+ const E = (P) => {
63
+ P.key === "Escape" && s();
64
+ };
65
+ document.addEventListener("keydown", E);
66
+ const x = document.body.style.overflow;
67
+ return document.body.style.overflow = "hidden", () => {
68
+ var P;
69
+ document.removeEventListener("keydown", E), document.body.style.overflow = x, (P = m == null ? void 0 : m.focus) == null || P.call(m);
70
+ };
71
+ }, [l, s]), !l || typeof document > "u" ? null : lt(
72
+ /* @__PURE__ */ o("div", { className: "rk-overlay", onMouseDown: (m) => m.target === m.currentTarget && s(), children: /* @__PURE__ */ p(
73
+ "div",
74
+ {
75
+ ref: _,
76
+ role: "dialog",
77
+ "aria-modal": "true",
78
+ "aria-labelledby": c ? b : void 0,
79
+ tabIndex: -1,
80
+ className: "rk-modal",
81
+ children: [
82
+ c && /* @__PURE__ */ p("div", { className: "rk-modal__header", children: [
83
+ /* @__PURE__ */ o("h2", { id: b, className: "rk-modal__title", children: c }),
84
+ /* @__PURE__ */ o("button", { type: "button", className: "rk-alert__close", "aria-label": "Close", onClick: s, children: "×" })
85
+ ] }),
86
+ /* @__PURE__ */ o("div", { className: "rk-modal__body", children: v }),
87
+ h && /* @__PURE__ */ o("div", { className: "rk-modal__footer", children: h })
88
+ ]
89
+ }
90
+ ) }),
91
+ document.body
92
+ );
93
+ }
94
+ const J = (...l) => l.filter(Boolean).join(" ");
95
+ function it() {
96
+ return /* @__PURE__ */ o("svg", { viewBox: "0 0 16 16", width: "100%", height: "100%", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ o(
97
+ "path",
98
+ {
99
+ d: "M3.5 8.5l3 3 6-7",
100
+ fill: "none",
101
+ stroke: "currentColor",
102
+ strokeWidth: "2.2",
103
+ strokeLinecap: "round",
104
+ strokeLinejoin: "round"
105
+ }
106
+ ) });
107
+ }
108
+ function ot() {
109
+ return /* @__PURE__ */ o("svg", { viewBox: "0 0 16 16", width: "100%", height: "100%", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ o("path", { d: "M4 8h8", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round" }) });
110
+ }
111
+ function Ke({
112
+ checked: l,
113
+ onChange: s,
114
+ indeterminate: c = !1,
115
+ variant: h = "native",
116
+ disabled: v = !1,
117
+ label: b,
118
+ "aria-label": _,
119
+ id: m,
120
+ name: E,
121
+ indicator: x,
122
+ className: I,
123
+ style: P,
124
+ classNames: j = {},
125
+ styles: y = {}
126
+ }) {
127
+ const B = c ? "indeterminate" : l ? "checked" : "unchecked";
128
+ return /* @__PURE__ */ p(
129
+ "label",
130
+ {
131
+ className: J(
132
+ "rk-checkbox",
133
+ `rk-checkbox--${h}`,
134
+ B === "checked" && "rk-checkbox--checked",
135
+ c && "rk-checkbox--indeterminate",
136
+ v && "rk-checkbox--disabled",
137
+ j.root,
138
+ I
139
+ ),
140
+ style: { ...y.root, ...P },
141
+ "data-state": B,
142
+ children: [
143
+ h === "native" ? /* @__PURE__ */ o(
144
+ "input",
145
+ {
146
+ type: "checkbox",
147
+ id: m,
148
+ name: E,
149
+ ref: (F) => {
150
+ F && (F.indeterminate = c);
151
+ },
152
+ className: J("rk-checkbox__control", j.control),
153
+ style: y.control,
154
+ checked: l,
155
+ disabled: v,
156
+ "aria-label": _,
157
+ "data-state": B,
158
+ onChange: (F) => s(F.target.checked)
159
+ }
160
+ ) : /* @__PURE__ */ o(
161
+ "button",
162
+ {
163
+ type: "button",
164
+ role: "checkbox",
165
+ id: m,
166
+ className: J("rk-checkbox__control", j.control),
167
+ style: y.control,
168
+ "aria-checked": c ? "mixed" : l,
169
+ "aria-label": _,
170
+ disabled: v,
171
+ "data-state": B,
172
+ onClick: () => s(!l),
173
+ children: /* @__PURE__ */ o(
174
+ "span",
175
+ {
176
+ className: J(
177
+ "rk-checkbox__indicator",
178
+ x !== void 0 && !c && "rk-checkbox__indicator--custom",
179
+ j.indicator
180
+ ),
181
+ style: y.indicator,
182
+ "data-state": B,
183
+ "aria-hidden": "true",
184
+ children: c ? h === "tick" ? /* @__PURE__ */ o(ot, {}) : null : x !== void 0 ? x : h === "tick" ? /* @__PURE__ */ o(it, {}) : null
185
+ }
186
+ )
187
+ }
188
+ ),
189
+ b != null && /* @__PURE__ */ o("span", { className: J("rk-checkbox__label", j.label), style: y.label, children: b })
190
+ ]
191
+ }
192
+ );
193
+ }
194
+ const $ = (...l) => l.filter(Boolean).join(" "), Pe = (l, s) => `${typeof l}:${l}\0${s}`;
195
+ function ke(l, s) {
196
+ const c = s[l.field];
197
+ return l.valueFormatter ? l.valueFormatter(c, s) : l.type === "boolean" && typeof c == "boolean" ? c ? "Yes" : "No" : c == null ? "" : c instanceof Date ? c.toLocaleDateString() : String(c);
198
+ }
199
+ function at(l, s) {
200
+ return typeof l == "number" && typeof s == "number" ? l - s : l instanceof Date && s instanceof Date ? l.getTime() - s.getTime() : typeof l == "boolean" && typeof s == "boolean" ? Number(l) - Number(s) : String(l).localeCompare(String(s), void 0, { numeric: !0, sensitivity: "base" });
201
+ }
202
+ function mt({
203
+ columns: l,
204
+ rows: s,
205
+ getRowId: c,
206
+ editable: h = !1,
207
+ enterMovesDown: v = !0,
208
+ onCellEdit: b,
209
+ onRowsChange: _,
210
+ sortable: m = !0,
211
+ defaultSort: E = null,
212
+ onSortChange: x,
213
+ searchable: I = !0,
214
+ searchPlaceholder: P = "Search…",
215
+ columnFilters: j = !0,
216
+ pagination: y = !0,
217
+ paginationPosition: B = "bottom",
218
+ pageSize: F = 10,
219
+ pageSizeOptions: oe = [5, 10, 25, 50],
220
+ onRowClick: ae,
221
+ toolbar: ge,
222
+ emptyMessage: Fe = "No rows to show",
223
+ striped: Le = !1,
224
+ checkboxVariant: Ve = "native",
225
+ maxHeight: me,
226
+ className: Re,
227
+ style: Ae,
228
+ classNames: S = {},
229
+ styles: D = {},
230
+ rowClassName: de,
231
+ rowStyle: se
232
+ }) {
233
+ const g = (e, t) => ({
234
+ className: $(t, S[e]),
235
+ style: D[e]
236
+ }), [pe, _e] = M(s), A = Q(s);
237
+ be(() => {
238
+ A.current = s, _e(s);
239
+ }, [s]);
240
+ const ve = (e) => {
241
+ A.current = e, _e(e);
242
+ }, [U, ze] = M(""), [z, xe] = M({}), [w, We] = M(E), [qe, W] = M(0), [T, Ge] = M(F), [q, G] = M(null), L = Q(0), X = Q(null), ce = Q(/* @__PURE__ */ new Map()), ye = $e(
243
+ () => pe.map((e, t) => ({ row: e, index: t, id: c ? c(e, t) : t })),
244
+ [pe, c]
245
+ ), O = $e(() => {
246
+ const e = U.trim().toLowerCase(), t = Object.entries(z).filter(([, n]) => n.trim() !== "");
247
+ let r = ye.filter(({ row: n }) => e && !l.some((d) => ke(d, n).toLowerCase().includes(e)) ? !1 : t.every(([i, d]) => {
248
+ const f = l.find((a) => a.field === i);
249
+ return f ? ke(f, n).toLowerCase().includes(d.trim().toLowerCase()) : !0;
250
+ }));
251
+ if (w) {
252
+ const n = l.find((i) => i.field === w.field);
253
+ if (n) {
254
+ const i = w.direction === "asc" ? 1 : -1;
255
+ r = [...r].sort((d, f) => {
256
+ const a = d.row[n.field], u = f.row[n.field], k = a == null || a === "", N = u == null || u === "";
257
+ return k || N ? k === N ? 0 : k ? 1 : -1 : (n.comparator ? n.comparator(a, u, d.row, f.row) : at(a, u)) * i;
258
+ });
259
+ }
260
+ }
261
+ return r;
262
+ }, [ye, l, U, z, w]);
263
+ be(() => W(0), [U, z, w, T]);
264
+ const V = O.length, Y = y ? Math.max(1, Math.ceil(V / T)) : 1, C = Math.min(qe, Y - 1), K = y ? O.slice(C * T, C * T + T) : O, Oe = V === 0 ? 0 : y ? C * T + 1 : 1, Ye = y ? Math.min(V, (C + 1) * T) : V, Ne = (e) => e.sortable ?? m, we = (e) => e.filterable ?? j, Z = (e, t, r) => ({
265
+ value: t[e.field],
266
+ formattedValue: ke(e, t),
267
+ row: t,
268
+ rowIndex: r,
269
+ field: e.field,
270
+ column: e
271
+ }), ue = (e, t) => {
272
+ const r = e.editable ?? h;
273
+ return typeof r == "function" ? r(t) : !!r;
274
+ }, ee = (e, t) => ue(e, t) && !(e.type === "boolean" && !e.cellEditor), He = (e, t) => {
275
+ const r = Z(e, t.row, t.index), n = ue(e, r);
276
+ return {
277
+ ...r,
278
+ editable: n,
279
+ updateValue: (i) => n && Ce(t, e, { value: i })
280
+ };
281
+ }, De = (e) => {
282
+ if (!Ne(e)) return;
283
+ let t;
284
+ !w || w.field !== e.field ? t = { field: e.field, direction: "asc" } : w.direction === "asc" ? t = { field: e.field, direction: "desc" } : t = null, We(t), x == null || x(t);
285
+ }, te = (e, t) => {
286
+ var r;
287
+ return (r = ce.current.get(Pe(e, t))) == null ? void 0 : r.focus();
288
+ }, R = () => {
289
+ L.current += 1, G(null);
290
+ }, re = (e, t, r = {}) => {
291
+ if (!ee(t, Z(t, e.row, e.index))) return !1;
292
+ const n = e.row[t.field], i = t.cellEditor ? n : r.text ?? (n == null ? "" : String(n));
293
+ return X.current = i, L.current += 1, G({
294
+ id: e.id,
295
+ field: t.field,
296
+ draft: i,
297
+ session: L.current,
298
+ select: r.select ?? "end",
299
+ invalid: !1
300
+ }), !0;
301
+ }, Ce = (e, t, r) => {
302
+ const n = A.current[e.index] ?? e.row, i = n[t.field];
303
+ let d;
304
+ if ("value" in r)
305
+ d = r.value;
306
+ else if (t.valueParser)
307
+ d = t.valueParser(r.text, n);
308
+ else if (t.type === "number")
309
+ if (r.text.trim() === "") d = null;
310
+ else {
311
+ const u = Number(r.text);
312
+ if (!Number.isFinite(u)) return !1;
313
+ d = u;
314
+ }
315
+ else
316
+ d = r.text;
317
+ if (Object.is(d, i)) return !0;
318
+ if (t.validate && !t.validate(d, n)) return !1;
319
+ const f = { ...n, [t.field]: d }, a = A.current.map((u, k) => k === e.index ? f : u);
320
+ return ve(a), b == null || b({ rowId: e.id, rowIndex: e.index, field: t.field, oldValue: i, newValue: d, row: f }), _ == null || _(a), !0;
321
+ }, Ee = (e, t, r) => {
322
+ const n = K.findIndex((k) => k.id === e.id), i = l.findIndex((k) => k.field === t);
323
+ if (n < 0 || i < 0) return null;
324
+ const d = (k, N) => ee(N, Z(N, k.row, k.index));
325
+ if (r === "down" || r === "up") {
326
+ const k = r === "down" ? 1 : -1;
327
+ for (let N = n + k; N >= 0 && N < K.length; N += k)
328
+ if (d(K[N], l[i])) return { entry: K[N], col: l[i] };
329
+ return null;
330
+ }
331
+ const f = r === "right" ? 1 : -1;
332
+ let a = n, u = i + f;
333
+ for (; a >= 0 && a < K.length; ) {
334
+ for (; u >= 0 && u < l.length; ) {
335
+ if (d(K[a], l[u])) return { entry: K[a], col: l[u] };
336
+ u += f;
337
+ }
338
+ a += f, u = f > 0 ? 0 : l.length - 1;
339
+ }
340
+ return null;
341
+ }, H = (e, t, r, n = {}) => {
342
+ const { move: i = "none", focus: d = !0 } = n;
343
+ if (!Ce(e, t, r))
344
+ return G((a) => a && { ...a, invalid: !0 }), !1;
345
+ const f = i === "none" ? null : Ee(e, t.field, i);
346
+ return f ? re(f.entry, f.col, { select: "all" }) : (R(), d && te(e.id, t.field)), !0;
347
+ }, Je = (e, t, r) => {
348
+ if (e.nativeEvent.isComposing) return;
349
+ const n = e.currentTarget.value;
350
+ if (e.key === "Enter") {
351
+ e.preventDefault();
352
+ const i = v ? e.shiftKey ? "up" : "down" : "none";
353
+ H(t, r, { text: n }, { move: i });
354
+ } else if (e.key === "Escape")
355
+ e.preventDefault(), R(), te(t.id, r.field);
356
+ else if (e.key === "Tab") {
357
+ const i = e.shiftKey ? "left" : "right";
358
+ Ee(t, r.field, i) && (e.preventDefault(), H(t, r, { text: n }, { move: i }));
359
+ }
360
+ }, Qe = (e, t, r, n) => {
361
+ e.target !== e.currentTarget || !ee(r, n) || (e.key === "Enter" || e.key === "F2" ? (e.preventDefault(), re(t, r)) : !r.cellEditor && e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey && (e.preventDefault(), re(t, r, { text: e.key })));
362
+ }, Ue = (e, t, r) => t.cellEditor ? /* @__PURE__ */ o(
363
+ "div",
364
+ {
365
+ className: "rk-grid__custom-editor",
366
+ onBlur: (n) => {
367
+ n.currentTarget.contains(n.relatedTarget) || r.session === L.current && (H(e, t, { value: X.current }, { focus: !1 }) || R());
368
+ },
369
+ onKeyDown: (n) => {
370
+ n.key === "Escape" && (n.preventDefault(), n.stopPropagation(), R(), te(e.id, t.field));
371
+ },
372
+ children: ie(t.cellEditor, {
373
+ value: r.draft,
374
+ row: e.row,
375
+ rowIndex: e.index,
376
+ field: t.field,
377
+ column: t,
378
+ onChange: (n) => {
379
+ X.current = n, G((i) => i && i.session === r.session ? { ...i, draft: n, invalid: !1 } : i);
380
+ },
381
+ onCommit: (n, i = "none") => {
382
+ r.session === L.current && H(e, t, { value: n === void 0 ? X.current : n }, { move: i });
383
+ },
384
+ onCancel: () => {
385
+ R(), te(e.id, t.field);
386
+ }
387
+ })
388
+ }
389
+ ) : /* @__PURE__ */ o(
390
+ "input",
391
+ {
392
+ autoFocus: !0,
393
+ className: $("rk-grid__editor", r.invalid && "rk-grid__editor--invalid", S.editor),
394
+ style: { textAlign: t.align, ...D.editor },
395
+ value: r.draft === null || r.draft === void 0 ? "" : String(r.draft),
396
+ inputMode: t.type === "number" ? "decimal" : void 0,
397
+ "aria-label": `Edit ${t.headerName ?? t.field}`,
398
+ "aria-invalid": r.invalid || void 0,
399
+ onChange: (n) => {
400
+ const i = n.target.value;
401
+ G((d) => d && { ...d, draft: i, invalid: !1 });
402
+ },
403
+ onFocus: (n) => {
404
+ const i = n.currentTarget;
405
+ r.select === "all" ? i.select() : i.setSelectionRange(i.value.length, i.value.length);
406
+ },
407
+ onBlur: (n) => {
408
+ r.session === L.current && (H(e, t, { text: n.currentTarget.value }, { focus: !1 }) || R());
409
+ },
410
+ onKeyDown: (n) => Je(n, e, t)
411
+ }
412
+ ), Ie = (e) => {
413
+ var r, n, i, d, f, a, u, k;
414
+ const t = e.checkbox ?? {};
415
+ return {
416
+ variant: t.variant ?? Ve,
417
+ indicator: t.indicator,
418
+ className: t.className,
419
+ style: t.style,
420
+ classNames: {
421
+ root: $(S.checkbox, (r = t.classNames) == null ? void 0 : r.root),
422
+ control: $(S.checkboxControl, (n = t.classNames) == null ? void 0 : n.control),
423
+ indicator: $(S.checkboxIndicator, (i = t.classNames) == null ? void 0 : i.indicator),
424
+ label: (d = t.classNames) == null ? void 0 : d.label
425
+ },
426
+ styles: {
427
+ root: { ...D.checkbox, ...(f = t.styles) == null ? void 0 : f.root },
428
+ control: { ...D.checkboxControl, ...(a = t.styles) == null ? void 0 : a.control },
429
+ indicator: { ...D.checkboxIndicator, ...(u = t.styles) == null ? void 0 : u.indicator },
430
+ label: (k = t.styles) == null ? void 0 : k.label
431
+ }
432
+ };
433
+ }, ne = (e) => e.stopPropagation(), Xe = (e, t) => /* @__PURE__ */ o("span", { className: "rk-grid__checkbox-cell", onClick: ne, onDoubleClick: ne, children: /* @__PURE__ */ o(
434
+ Ke,
435
+ {
436
+ ...Ie(e),
437
+ checked: !!t.value,
438
+ disabled: !t.editable,
439
+ "aria-label": `Toggle ${e.headerName ?? e.field}`,
440
+ onChange: (r) => t.updateValue(r)
441
+ }
442
+ ) }), Be = (e) => O.filter((t) => ue(e, Z(e, t.row, t.index))), Ze = (e, t) => {
443
+ const r = new Map(Be(e).map((d) => [d.index, d])), n = [], i = A.current.map((d, f) => {
444
+ const a = r.get(f);
445
+ if (!a) return d;
446
+ const u = d[e.field];
447
+ if (!!u === t || e.validate && !e.validate(t, d)) return d;
448
+ const k = { ...d, [e.field]: t };
449
+ return n.push({ rowId: a.id, rowIndex: f, field: e.field, oldValue: u, newValue: t, row: k }), k;
450
+ });
451
+ n.length !== 0 && (ve(i), n.forEach((d) => b == null ? void 0 : b(d)), _ == null || _(i));
452
+ }, et = (e) => {
453
+ const t = Be(e), r = t.length > 0 ? t : O, n = r.filter((d) => !!d.row[e.field]).length, i = r.length > 0 && n === r.length;
454
+ return /* @__PURE__ */ o("span", { className: "rk-grid__header-checkbox", onClick: ne, onDoubleClick: ne, children: /* @__PURE__ */ o(
455
+ Ke,
456
+ {
457
+ ...Ie(e),
458
+ checked: i,
459
+ indeterminate: n > 0 && !i,
460
+ disabled: t.length === 0,
461
+ label: e.headerName ?? e.field,
462
+ onChange: (d) => Ze(e, d)
463
+ }
464
+ ) });
465
+ }, tt = y && (B === "top" || B === "both"), rt = !y || B === "bottom" || B === "both", Se = (e) => /* @__PURE__ */ p(
466
+ "div",
467
+ {
468
+ className: $("rk-grid__footer", e === "top" && "rk-grid__footer--top", S.footer),
469
+ style: D.footer,
470
+ "data-position": e,
471
+ children: [
472
+ /* @__PURE__ */ o("span", { ...g("rowCount", "rk-grid__count"), children: V === 0 ? "0 rows" : `${Oe}–${Ye} of ${V}` }),
473
+ y && /* @__PURE__ */ p("div", { ...g("pagination", "rk-grid__pagination"), children: [
474
+ /* @__PURE__ */ p("label", { className: "rk-grid__page-size-label", children: [
475
+ "Rows per page",
476
+ /* @__PURE__ */ o(
477
+ "select",
478
+ {
479
+ value: T,
480
+ onChange: (t) => Ge(Number(t.target.value)),
481
+ ...g("pageSize", "rk-grid__page-size"),
482
+ children: (oe.includes(T) ? oe : [...oe, T].sort((t, r) => t - r)).map(
483
+ (t) => /* @__PURE__ */ o("option", { value: t, children: t }, t)
484
+ )
485
+ }
486
+ )
487
+ ] }),
488
+ /* @__PURE__ */ o("button", { type: "button", "aria-label": "First page", disabled: C === 0, onClick: () => W(0), ...g("pageButton", "rk-grid__page-btn"), children: "«" }),
489
+ /* @__PURE__ */ o("button", { type: "button", "aria-label": "Previous page", disabled: C === 0, onClick: () => W(C - 1), ...g("pageButton", "rk-grid__page-btn"), children: "‹" }),
490
+ /* @__PURE__ */ p("span", { ...g("pageInfo", "rk-grid__page-info"), children: [
491
+ "Page ",
492
+ C + 1,
493
+ " of ",
494
+ Y
495
+ ] }),
496
+ /* @__PURE__ */ o("button", { type: "button", "aria-label": "Next page", disabled: C >= Y - 1, onClick: () => W(C + 1), ...g("pageButton", "rk-grid__page-btn"), children: "›" }),
497
+ /* @__PURE__ */ o("button", { type: "button", "aria-label": "Last page", disabled: C >= Y - 1, onClick: () => W(Y - 1), ...g("pageButton", "rk-grid__page-btn"), children: "»" })
498
+ ] })
499
+ ]
500
+ }
501
+ ), nt = l.some(we);
502
+ return /* @__PURE__ */ p("div", { className: $("rk-grid", S.root, Re), style: { ...D.root, ...Ae }, children: [
503
+ (I || ge) && /* @__PURE__ */ p("div", { ...g("toolbar", "rk-grid__toolbar"), children: [
504
+ I ? /* @__PURE__ */ o(
505
+ "input",
506
+ {
507
+ type: "search",
508
+ value: U,
509
+ onChange: (e) => ze(e.target.value),
510
+ placeholder: P,
511
+ "aria-label": "Search all columns",
512
+ ...g("search", "rk-grid__search")
513
+ }
514
+ ) : /* @__PURE__ */ o("span", {}),
515
+ ge
516
+ ] }),
517
+ tt && Se("top"),
518
+ /* @__PURE__ */ o("div", { ...g("scroll", "rk-grid__scroll"), style: { ...D.scroll, ...me !== void 0 ? { maxHeight: me } : null }, children: /* @__PURE__ */ p("table", { ...g("table", "rk-grid__table"), role: "grid", children: [
519
+ /* @__PURE__ */ p("thead", { ...g("thead", "rk-grid__thead"), children: [
520
+ /* @__PURE__ */ o("tr", { ...g("headerRow", "rk-grid__tr"), children: l.map((e) => {
521
+ const t = (w == null ? void 0 : w.field) === e.field ? w.direction : null, r = Ne(e);
522
+ return /* @__PURE__ */ o(
523
+ "th",
524
+ {
525
+ scope: "col",
526
+ "aria-sort": t ? t === "asc" ? "ascending" : "descending" : r ? "none" : void 0,
527
+ tabIndex: r ? 0 : void 0,
528
+ onClick: () => De(e),
529
+ onKeyDown: (n) => {
530
+ r && n.target === n.currentTarget && (n.key === "Enter" || n.key === " ") && (n.preventDefault(), De(e));
531
+ },
532
+ className: $("rk-grid__th", r && "rk-grid__th--sortable", S.headerCell, e.headerClassName),
533
+ style: { width: e.width, minWidth: e.minWidth, textAlign: e.align, ...D.headerCell, ...e.headerStyle },
534
+ children: /* @__PURE__ */ p("span", { className: "rk-grid__th-content", children: [
535
+ e.headerRenderer ? ie(e.headerRenderer, { column: e, sortDirection: t }) : e.headerCheckbox && e.type === "boolean" ? et(e) : e.headerName ?? e.field,
536
+ r && /* @__PURE__ */ o("span", { className: "rk-grid__sort", "aria-hidden": "true", children: t === "asc" ? "▲" : t === "desc" ? "▼" : "↕" })
537
+ ] })
538
+ },
539
+ e.field
540
+ );
541
+ }) }),
542
+ nt && /* @__PURE__ */ o("tr", { ...g("filterRow", "rk-grid__tr"), children: l.map((e) => /* @__PURE__ */ o("th", { ...g("filterCell", "rk-grid__filter-cell"), children: we(e) && (e.filterRenderer ? ie(e.filterRenderer, {
543
+ column: e,
544
+ value: z[e.field] ?? "",
545
+ onChange: (t) => xe((r) => ({ ...r, [e.field]: t }))
546
+ }) : /* @__PURE__ */ o(
547
+ "input",
548
+ {
549
+ value: z[e.field] ?? "",
550
+ onChange: (t) => xe((r) => ({ ...r, [e.field]: t.target.value })),
551
+ placeholder: "Filter",
552
+ "aria-label": `Filter ${e.headerName ?? e.field}`,
553
+ ...g("filterInput", "rk-grid__filter-input")
554
+ }
555
+ )) }, e.field)) })
556
+ ] }),
557
+ /* @__PURE__ */ o("tbody", { ...g("tbody", "rk-grid__tbody"), children: K.length === 0 ? /* @__PURE__ */ o("tr", { children: /* @__PURE__ */ o("td", { colSpan: l.length, ...g("empty", "rk-grid__empty"), children: Fe }) }) : K.map((e, t) => {
558
+ const { row: r, id: n, index: i } = e, d = typeof de == "function" ? de(r, i) : de, f = typeof se == "function" ? se(r, i) : se;
559
+ return /* @__PURE__ */ o(
560
+ "tr",
561
+ {
562
+ onClick: ae ? () => ae(r, i) : void 0,
563
+ className: $(
564
+ "rk-grid__tr",
565
+ "rk-grid__row",
566
+ Le && t % 2 === 1 && "rk-grid__row--striped",
567
+ ae && "rk-grid__row--clickable",
568
+ S.row,
569
+ d
570
+ ),
571
+ style: { ...D.row, ...f },
572
+ children: l.map((a) => {
573
+ const u = He(a, e), k = typeof a.cellClassName == "function" ? a.cellClassName(u) : a.cellClassName, N = typeof a.cellStyle == "function" ? a.cellStyle(u) : a.cellStyle, fe = q !== null && q.id === n && q.field === a.field, he = ee(a, u);
574
+ return /* @__PURE__ */ o(
575
+ "td",
576
+ {
577
+ ref: (le) => {
578
+ const Te = Pe(n, a.field);
579
+ le ? ce.current.set(Te, le) : ce.current.delete(Te);
580
+ },
581
+ tabIndex: he ? 0 : void 0,
582
+ onDoubleClick: he ? () => re(e, a) : void 0,
583
+ onKeyDown: (le) => Qe(le, e, a, u),
584
+ className: $(
585
+ "rk-grid__td",
586
+ he && "rk-grid__td--editable",
587
+ fe && "rk-grid__td--editing",
588
+ S.cell,
589
+ k
590
+ ),
591
+ style: { textAlign: a.align, ...D.cell, ...N },
592
+ children: fe && q ? Ue(e, a, q) : a.cellRenderer ? ie(a.cellRenderer, u) : a.type === "boolean" && !a.cellEditor ? Xe(a, u) : u.formattedValue
593
+ },
594
+ a.field
595
+ );
596
+ })
597
+ },
598
+ n
599
+ );
600
+ }) })
601
+ ] }) }),
602
+ rt && Se("bottom")
603
+ ] });
604
+ }
605
+ export {
606
+ bt as Alert,
607
+ kt as Badge,
608
+ ut as Button,
609
+ ht as Card,
610
+ Ke as Checkbox,
611
+ mt as DataGrid,
612
+ ft as Input,
613
+ gt as Modal
614
+ };
package/dist/style.css ADDED
@@ -0,0 +1 @@
1
+ :root{--rk-primary: #4f46e5;--rk-primary-hover: #4338ca;--rk-danger: #dc2626;--rk-danger-hover: #b91c1c;--rk-text: #111827;--rk-muted: #6b7280;--rk-border: #d1d5db;--rk-surface: #ffffff;--rk-bg-subtle: #f3f4f6;--rk-radius: 0px;--rk-font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif}.rk-btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;font-family:var(--rk-font);font-weight:500;border:1px solid transparent;border-radius:var(--rk-radius);cursor:pointer;transition:background .15s,border-color .15s}.rk-btn:focus-visible{outline:2px solid var(--rk-primary);outline-offset:2px}.rk-btn:disabled{opacity:.55;cursor:not-allowed}.rk-btn--sm{padding:4px 10px;font-size:13px}.rk-btn--md{padding:8px 16px;font-size:14px}.rk-btn--lg{padding:12px 22px;font-size:16px}.rk-btn--primary{background:var(--rk-primary);color:#fff}.rk-btn--primary:hover:not(:disabled){background:var(--rk-primary-hover)}.rk-btn--secondary{background:var(--rk-surface);color:var(--rk-text);border-color:var(--rk-border)}.rk-btn--secondary:hover:not(:disabled){background:var(--rk-bg-subtle)}.rk-btn--ghost{background:transparent;color:var(--rk-primary)}.rk-btn--ghost:hover:not(:disabled){background:var(--rk-bg-subtle)}.rk-btn--danger{background:var(--rk-danger);color:#fff}.rk-btn--danger:hover:not(:disabled){background:var(--rk-danger-hover)}.rk-spinner{width:1em;height:1em;border-radius:50%;border:1px solid currentColor;border-right-color:transparent;animation:rk-spin .7s linear infinite}@keyframes rk-spin{to{transform:rotate(360deg)}}.rk-field{display:flex;flex-direction:column;gap:4px;font-family:var(--rk-font)}.rk-label{font-size:14px;font-weight:500;color:var(--rk-text)}.rk-input{padding:8px 12px;font:inherit;font-size:14px;color:var(--rk-text);background:var(--rk-surface);border:1px solid var(--rk-border);border-radius:var(--rk-radius)}.rk-input:focus{outline:2px solid var(--rk-primary);outline-offset:0;border-color:var(--rk-primary)}.rk-input--error{border-color:var(--rk-danger)}.rk-hint{font-size:12px;color:var(--rk-muted)}.rk-error-text{font-size:12px;color:var(--rk-danger)}.rk-card{font-family:var(--rk-font);background:var(--rk-surface);color:var(--rk-text);border:1px solid var(--rk-border);border-radius:calc(var(--rk-radius) + 4px);box-shadow:0 1px 3px #0000000f;overflow:hidden}.rk-card__header{padding:14px 18px;font-weight:600;border-bottom:1px solid var(--rk-border)}.rk-card__body{padding:18px}.rk-card__footer{padding:12px 18px;background:var(--rk-bg-subtle);border-top:1px solid var(--rk-border)}.rk-badge{display:inline-block;padding:2px 10px;border-radius:999px;font-family:var(--rk-font);font-size:12px;font-weight:500}.rk-badge--neutral{background:#e5e7eb;color:#374151}.rk-badge--info{background:#dbeafe;color:#1e40af}.rk-badge--success{background:#dcfce7;color:#166534}.rk-badge--warning{background:#fef3c7;color:#92400e}.rk-badge--danger{background:#fee2e2;color:#991b1b}.rk-alert{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;padding:12px 16px;border-radius:var(--rk-radius);border:1px solid;font-family:var(--rk-font);font-size:14px}.rk-alert__title{display:block;margin-bottom:2px}.rk-alert__close{background:none;border:none;font-size:20px;line-height:1;cursor:pointer;color:inherit;opacity:.7}.rk-alert__close:hover{opacity:1}.rk-alert--info{background:#eff6ff;border-color:#bfdbfe;color:#1e40af}.rk-alert--success{background:#f0fdf4;border-color:#bbf7d0;color:#166534}.rk-alert--warning{background:#fffbeb;border-color:#fde68a;color:#92400e}.rk-alert--danger{background:#fef2f2;border-color:#fecaca;color:#991b1b}.rk-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1000;display:flex;align-items:center;justify-content:center;background:#11182780;padding:16px}.rk-modal{width:100%;max-width:480px;max-height:90vh;overflow:auto;background:var(--rk-surface);color:var(--rk-text);font-family:var(--rk-font);border-radius:12px;box-shadow:0 20px 50px #00000040}.rk-modal:focus{outline:none}.rk-modal__header{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid var(--rk-border)}.rk-modal__title{margin:0;font-size:18px}.rk-modal__body{padding:20px}.rk-modal__footer{display:flex;justify-content:flex-end;gap:8px;padding:14px 20px;border-top:1px solid var(--rk-border)}:where(.rk-checkbox){display:inline-flex;align-items:center;gap:8px;cursor:pointer;font-family:inherit;line-height:1;vertical-align:middle}:where(.rk-checkbox--disabled){cursor:not-allowed;opacity:.55}:where(.rk-checkbox__control){box-sizing:border-box;flex:none;margin:0;cursor:inherit;width:var(--rk-checkbox-size, 20px);height:var(--rk-checkbox-size, 20px)}:where(.rk-checkbox__control:disabled){cursor:not-allowed}:where(.rk-checkbox__control:focus-visible){outline:2px solid var(--rk-checkbox-color, #4f46e5);outline-offset:2px}:where(.rk-checkbox--button .rk-checkbox__control,.rk-checkbox--tick .rk-checkbox__control){display:inline-flex;align-items:center;justify-content:center;padding:0;border:2px solid var(--rk-checkbox-border, #9ca3af);border-radius:var(--rk-checkbox-radius, 2px);background:var(--rk-checkbox-bg, #fff);color:var(--rk-checkbox-tick, #fff);transition:background .12s,border-color .12s}:where(.rk-checkbox--button .rk-checkbox__control[aria-checked=true],.rk-checkbox--button .rk-checkbox__control[aria-checked=mixed]){border-color:var(--rk-checkbox-color, #4f46e5)}:where(.rk-checkbox--tick .rk-checkbox__control[aria-checked=true],.rk-checkbox--tick .rk-checkbox__control[aria-checked=mixed]){background:var(--rk-checkbox-color, #4f46e5);border-color:var(--rk-checkbox-color, #4f46e5)}:where(.rk-checkbox__indicator){display:block;line-height:1;text-align:center;visibility:hidden}:where(.rk-checkbox__indicator[data-state=checked],.rk-checkbox__indicator[data-state=indeterminate]){visibility:visible}:where(.rk-checkbox--button .rk-checkbox__indicator){width:55%;height:55%;border-radius:calc(var(--rk-checkbox-radius, 3px) - 2px);background:var(--rk-checkbox-color, #4f46e5)}:where(.rk-checkbox--tick .rk-checkbox__indicator){width:80%;height:80%}:where(.rk-checkbox--button .rk-checkbox__indicator[data-state=indeterminate]){height:16%;border-radius:1px}:where(.rk-checkbox__indicator--custom){width:auto;height:auto;background:none}:where(.rk-checkbox--native .rk-checkbox__control){accent-color:var(--rk-checkbox-color, #4f46e5)}:where(.rk-checkbox__label){font-size:14px}:where(.rk-grid){display:flex;flex-direction:column;font-family:var(--rk-font, system-ui, sans-serif);font-size:14px;color:var(--rk-text, #111827);background:var(--rk-surface, #fff);border:1px solid var(--rk-border, #d1d5db);border-radius:10px;overflow:hidden}:where(.rk-grid__toolbar){display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 12px;border-bottom:1px solid var(--rk-border, #d1d5db)}:where(.rk-grid__search){width:260px;max-width:100%;padding:7px 12px;font:inherit;border:1px solid var(--rk-border, #d1d5db);border-radius:8px;background:var(--rk-surface, #fff);color:inherit}:where(.rk-grid__search:focus,.rk-grid__filter-input:focus,.rk-grid__page-size:focus){outline:2px solid var(--rk-primary, #4f46e5);outline-offset:-1px}:where(.rk-grid__scroll){overflow:auto}:where(.rk-grid__table){width:100%;border-collapse:collapse}:where(.rk-grid__thead){position:sticky;top:0;z-index:1;background:var(--rk-bg-subtle, #f3f4f6)}:where(.rk-grid__th){padding:10px 12px;text-align:left;font-weight:600;white-space:nowrap;background:var(--rk-bg-subtle, #f3f4f6);border-bottom:1px solid var(--rk-border, #d1d5db);-webkit-user-select:none;user-select:none}:where(.rk-grid__th--sortable){cursor:pointer}:where(.rk-grid__th--sortable:hover){background:#e5e7eb}:where(.rk-grid__th:focus-visible,.rk-grid__td:focus-visible){outline:2px solid var(--rk-primary, #4f46e5);outline-offset:-2px}:where(.rk-grid__th-content){display:inline-flex;align-items:center;gap:6px}:where(.rk-grid__sort){font-size:10px;opacity:.55}:where(.rk-grid__filter-cell){padding:4px 8px;background:var(--rk-surface, #fff);border-bottom:1px solid var(--rk-border, #d1d5db);font-weight:400}:where(.rk-grid__filter-input){width:100%;box-sizing:border-box;padding:4px 8px;font:inherit;font-size:13px;border:1px solid var(--rk-border, #d1d5db);border-radius:6px;background:var(--rk-surface, #fff);color:inherit}:where(.rk-grid__td){padding:9px 12px;border-bottom:1px solid #eef0f3}:where(.rk-grid__td--editable){cursor:text}:where(.rk-grid__td--editing){padding:3px 6px}:where(.rk-grid__row:hover){background:#f9fafb}:where(.rk-grid__row--striped){background:#fafafa}:where(.rk-grid__row--clickable){cursor:pointer}:where(.rk-grid__editor){width:100%;box-sizing:border-box;padding:5px 8px;font:inherit;border:2px solid var(--rk-primary, #4f46e5);border-radius:6px;background:var(--rk-surface, #fff);color:inherit}:where(.rk-grid__editor:focus){outline:none}:where(.rk-grid__editor--invalid){border-color:var(--rk-danger, #dc2626);background:#fef2f2}:where(.rk-grid__custom-editor){display:flex;align-items:center;min-height:30px}:where(.rk-grid__checkbox-cell,.rk-grid__header-checkbox){display:inline-flex;vertical-align:middle}:where(.rk-grid__empty){padding:32px 12px;text-align:center;color:var(--rk-muted, #6b7280)}:where(.rk-grid__footer){display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:8px;padding:8px 12px;border-top:1px solid var(--rk-border, #d1d5db);background:var(--rk-bg-subtle, #f3f4f6);color:var(--rk-muted, #6b7280);font-size:13px}:where(.rk-grid__footer--top){border-top:0;border-bottom:1px solid var(--rk-border, #d1d5db)}:where(.rk-grid__pagination){display:flex;align-items:center;gap:8px}:where(.rk-grid__page-size-label){display:inline-flex;align-items:center;gap:6px;margin-right:8px}:where(.rk-grid__page-size){padding:3px 6px;font:inherit;border:1px solid var(--rk-border, #d1d5db);border-radius:6px;background:var(--rk-surface, #fff)}:where(.rk-grid__page-btn){min-width:30px;padding:3px 8px;font:inherit;cursor:pointer;color:var(--rk-text, #111827);background:var(--rk-surface, #fff);border:1px solid var(--rk-border, #d1d5db);border-radius:6px}:where(.rk-grid__page-btn:hover:not(:disabled)){background:#e5e7eb}:where(.rk-grid__page-btn:disabled){opacity:.4;cursor:not-allowed}
package/package.json CHANGED
@@ -1,6 +1,41 @@
1
1
  {
2
2
  "name": "react-gridix",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "A simple React component library",
5
+ "author": "Felix Ongom",
6
+ "type": "module",
7
+ "main": "./dist/react-gridix.cjs",
8
+ "module": "./dist/react-gridix.js",
9
+ "types": "./dist/index.d.ts",
10
+ "license": "MIT",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/react-gridix.js",
15
+ "require": "./dist/react-gridix.cjs"
16
+ },
17
+ "./style.css": "./dist/style.css"
18
+ },
19
+ "files": ["dist"],
20
+ "sideEffects": ["**/*.css"],
21
+ "scripts": {
22
+ "dev": "vite --config vite.demo.config.ts",
23
+ "build": "vite build",
24
+ "typecheck": "tsc --noEmit"
25
+ },
26
+ "peerDependencies": {
27
+ "react": ">=17",
28
+ "react-dom": ">=17"
29
+ },
30
+ "devDependencies": {
31
+ "@types/node": "^20.14.0",
32
+ "@types/react": "^18.3.0",
33
+ "@types/react-dom": "^18.3.0",
34
+ "@vitejs/plugin-react": "^4.3.0",
35
+ "react": "^18.3.1",
36
+ "react-dom": "^18.3.1",
37
+ "typescript": "^5.5.0",
38
+ "vite": "^5.4.0",
39
+ "vite-plugin-dts": "^4.0.0"
40
+ }
41
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.