@stereopt/data-table 0.1.9 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +525 -33
- package/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +521 -33
- package/dist/styles.css +302 -52
- package/package.json +6 -3
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
@@ -111,9 +121,457 @@ function TableCell({ className, ...props }) {
|
|
|
111
121
|
);
|
|
112
122
|
}
|
|
113
123
|
|
|
124
|
+
// src/components/ui/input.tsx
|
|
125
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
126
|
+
function Input({ className, type, ...props }) {
|
|
127
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
128
|
+
"input",
|
|
129
|
+
{
|
|
130
|
+
className: cn(
|
|
131
|
+
"h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
|
|
132
|
+
className
|
|
133
|
+
),
|
|
134
|
+
"data-slot": "input",
|
|
135
|
+
type,
|
|
136
|
+
...props
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// src/dataTable/DataTableControls.tsx
|
|
142
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
143
|
+
var DataTableControls = ({
|
|
144
|
+
table,
|
|
145
|
+
search,
|
|
146
|
+
filters
|
|
147
|
+
}) => {
|
|
148
|
+
const value = table.getState().globalFilter ?? "";
|
|
149
|
+
const setValue = table.setGlobalFilter;
|
|
150
|
+
if (!filters || !search) return null;
|
|
151
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex items-center gap-4 pb-4", children: [
|
|
152
|
+
search && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
153
|
+
Input,
|
|
154
|
+
{
|
|
155
|
+
className: "max-w-sm",
|
|
156
|
+
onChange: (event) => setValue(() => event.target.value),
|
|
157
|
+
placeholder: search?.placeholder,
|
|
158
|
+
value
|
|
159
|
+
}
|
|
160
|
+
),
|
|
161
|
+
filters?.map((filter) => {
|
|
162
|
+
return null;
|
|
163
|
+
})
|
|
164
|
+
] });
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
// src/components/ui/button.tsx
|
|
168
|
+
var import_class_variance_authority = require("class-variance-authority");
|
|
169
|
+
|
|
170
|
+
// node_modules/@radix-ui/react-slot/dist/index.mjs
|
|
171
|
+
var dist_exports = {};
|
|
172
|
+
__export(dist_exports, {
|
|
173
|
+
Root: () => Slot,
|
|
174
|
+
Slot: () => Slot,
|
|
175
|
+
Slottable: () => Slottable,
|
|
176
|
+
createSlot: () => createSlot,
|
|
177
|
+
createSlottable: () => createSlottable
|
|
178
|
+
});
|
|
179
|
+
var React2 = __toESM(require("react"), 1);
|
|
180
|
+
|
|
181
|
+
// node_modules/@radix-ui/react-compose-refs/dist/index.mjs
|
|
182
|
+
var React = __toESM(require("react"), 1);
|
|
183
|
+
function setRef(ref, value) {
|
|
184
|
+
if (typeof ref === "function") {
|
|
185
|
+
return ref(value);
|
|
186
|
+
} else if (ref !== null && ref !== void 0) {
|
|
187
|
+
ref.current = value;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
function composeRefs(...refs) {
|
|
191
|
+
return (node) => {
|
|
192
|
+
let hasCleanup = false;
|
|
193
|
+
const cleanups = refs.map((ref) => {
|
|
194
|
+
const cleanup = setRef(ref, node);
|
|
195
|
+
if (!hasCleanup && typeof cleanup == "function") {
|
|
196
|
+
hasCleanup = true;
|
|
197
|
+
}
|
|
198
|
+
return cleanup;
|
|
199
|
+
});
|
|
200
|
+
if (hasCleanup) {
|
|
201
|
+
return () => {
|
|
202
|
+
for (let i = 0; i < cleanups.length; i++) {
|
|
203
|
+
const cleanup = cleanups[i];
|
|
204
|
+
if (typeof cleanup == "function") {
|
|
205
|
+
cleanup();
|
|
206
|
+
} else {
|
|
207
|
+
setRef(refs[i], null);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// node_modules/@radix-ui/react-slot/dist/index.mjs
|
|
216
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
217
|
+
// @__NO_SIDE_EFFECTS__
|
|
218
|
+
function createSlot(ownerName) {
|
|
219
|
+
const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
|
|
220
|
+
const Slot2 = React2.forwardRef((props, forwardedRef) => {
|
|
221
|
+
const { children, ...slotProps } = props;
|
|
222
|
+
const childrenArray = React2.Children.toArray(children);
|
|
223
|
+
const slottable = childrenArray.find(isSlottable);
|
|
224
|
+
if (slottable) {
|
|
225
|
+
const newElement = slottable.props.children;
|
|
226
|
+
const newChildren = childrenArray.map((child) => {
|
|
227
|
+
if (child === slottable) {
|
|
228
|
+
if (React2.Children.count(newElement) > 1) return React2.Children.only(null);
|
|
229
|
+
return React2.isValidElement(newElement) ? newElement.props.children : null;
|
|
230
|
+
} else {
|
|
231
|
+
return child;
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SlotClone, { ...slotProps, ref: forwardedRef, children: React2.isValidElement(newElement) ? React2.cloneElement(newElement, void 0, newChildren) : null });
|
|
235
|
+
}
|
|
236
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
237
|
+
});
|
|
238
|
+
Slot2.displayName = `${ownerName}.Slot`;
|
|
239
|
+
return Slot2;
|
|
240
|
+
}
|
|
241
|
+
var Slot = /* @__PURE__ */ createSlot("Slot");
|
|
242
|
+
// @__NO_SIDE_EFFECTS__
|
|
243
|
+
function createSlotClone(ownerName) {
|
|
244
|
+
const SlotClone = React2.forwardRef((props, forwardedRef) => {
|
|
245
|
+
const { children, ...slotProps } = props;
|
|
246
|
+
if (React2.isValidElement(children)) {
|
|
247
|
+
const childrenRef = getElementRef(children);
|
|
248
|
+
const props2 = mergeProps(slotProps, children.props);
|
|
249
|
+
if (children.type !== React2.Fragment) {
|
|
250
|
+
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
251
|
+
}
|
|
252
|
+
return React2.cloneElement(children, props2);
|
|
253
|
+
}
|
|
254
|
+
return React2.Children.count(children) > 1 ? React2.Children.only(null) : null;
|
|
255
|
+
});
|
|
256
|
+
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
257
|
+
return SlotClone;
|
|
258
|
+
}
|
|
259
|
+
var SLOTTABLE_IDENTIFIER = /* @__PURE__ */ Symbol("radix.slottable");
|
|
260
|
+
// @__NO_SIDE_EFFECTS__
|
|
261
|
+
function createSlottable(ownerName) {
|
|
262
|
+
const Slottable2 = ({ children }) => {
|
|
263
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children });
|
|
264
|
+
};
|
|
265
|
+
Slottable2.displayName = `${ownerName}.Slottable`;
|
|
266
|
+
Slottable2.__radixId = SLOTTABLE_IDENTIFIER;
|
|
267
|
+
return Slottable2;
|
|
268
|
+
}
|
|
269
|
+
var Slottable = /* @__PURE__ */ createSlottable("Slottable");
|
|
270
|
+
function isSlottable(child) {
|
|
271
|
+
return React2.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
|
|
272
|
+
}
|
|
273
|
+
function mergeProps(slotProps, childProps) {
|
|
274
|
+
const overrideProps = { ...childProps };
|
|
275
|
+
for (const propName in childProps) {
|
|
276
|
+
const slotPropValue = slotProps[propName];
|
|
277
|
+
const childPropValue = childProps[propName];
|
|
278
|
+
const isHandler = /^on[A-Z]/.test(propName);
|
|
279
|
+
if (isHandler) {
|
|
280
|
+
if (slotPropValue && childPropValue) {
|
|
281
|
+
overrideProps[propName] = (...args) => {
|
|
282
|
+
const result = childPropValue(...args);
|
|
283
|
+
slotPropValue(...args);
|
|
284
|
+
return result;
|
|
285
|
+
};
|
|
286
|
+
} else if (slotPropValue) {
|
|
287
|
+
overrideProps[propName] = slotPropValue;
|
|
288
|
+
}
|
|
289
|
+
} else if (propName === "style") {
|
|
290
|
+
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
291
|
+
} else if (propName === "className") {
|
|
292
|
+
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
return { ...slotProps, ...overrideProps };
|
|
296
|
+
}
|
|
297
|
+
function getElementRef(element) {
|
|
298
|
+
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
|
|
299
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
300
|
+
if (mayWarn) {
|
|
301
|
+
return element.ref;
|
|
302
|
+
}
|
|
303
|
+
getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
|
|
304
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
305
|
+
if (mayWarn) {
|
|
306
|
+
return element.props.ref;
|
|
307
|
+
}
|
|
308
|
+
return element.props.ref || element.ref;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// src/components/ui/button.tsx
|
|
312
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
313
|
+
var buttonVariants = (0, import_class_variance_authority.cva)(
|
|
314
|
+
"group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
315
|
+
{
|
|
316
|
+
variants: {
|
|
317
|
+
variant: {
|
|
318
|
+
default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
|
|
319
|
+
outline: "border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
|
|
320
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
|
|
321
|
+
ghost: "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
|
|
322
|
+
destructive: "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
|
|
323
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
324
|
+
},
|
|
325
|
+
size: {
|
|
326
|
+
default: "h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
327
|
+
xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
|
|
328
|
+
sm: "h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
|
|
329
|
+
lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
330
|
+
icon: "size-8",
|
|
331
|
+
"icon-xs": "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
|
|
332
|
+
"icon-sm": "size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
|
|
333
|
+
"icon-lg": "size-9"
|
|
334
|
+
}
|
|
335
|
+
},
|
|
336
|
+
defaultVariants: {
|
|
337
|
+
variant: "default",
|
|
338
|
+
size: "default"
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
);
|
|
342
|
+
function Button({
|
|
343
|
+
className,
|
|
344
|
+
variant = "default",
|
|
345
|
+
size = "default",
|
|
346
|
+
asChild = false,
|
|
347
|
+
...props
|
|
348
|
+
}) {
|
|
349
|
+
const Comp = asChild ? dist_exports.Root : "button";
|
|
350
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
351
|
+
Comp,
|
|
352
|
+
{
|
|
353
|
+
className: cn(buttonVariants({ variant, size, className })),
|
|
354
|
+
"data-size": size,
|
|
355
|
+
"data-slot": "button",
|
|
356
|
+
"data-variant": variant,
|
|
357
|
+
...props
|
|
358
|
+
}
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// node_modules/lucide-react/dist/esm/createLucideIcon.js
|
|
363
|
+
var import_react2 = require("react");
|
|
364
|
+
|
|
365
|
+
// node_modules/lucide-react/dist/esm/shared/src/utils/mergeClasses.js
|
|
366
|
+
var mergeClasses = (...classes) => classes.filter((className, index, array) => {
|
|
367
|
+
return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
|
|
368
|
+
}).join(" ").trim();
|
|
369
|
+
|
|
370
|
+
// node_modules/lucide-react/dist/esm/shared/src/utils/toKebabCase.js
|
|
371
|
+
var toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
372
|
+
|
|
373
|
+
// node_modules/lucide-react/dist/esm/shared/src/utils/toCamelCase.js
|
|
374
|
+
var toCamelCase = (string) => string.replace(
|
|
375
|
+
/^([A-Z])|[\s-_]+(\w)/g,
|
|
376
|
+
(match, p1, p2) => p2 ? p2.toUpperCase() : p1.toLowerCase()
|
|
377
|
+
);
|
|
378
|
+
|
|
379
|
+
// node_modules/lucide-react/dist/esm/shared/src/utils/toPascalCase.js
|
|
380
|
+
var toPascalCase = (string) => {
|
|
381
|
+
const camelCase = toCamelCase(string);
|
|
382
|
+
return camelCase.charAt(0).toUpperCase() + camelCase.slice(1);
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
// node_modules/lucide-react/dist/esm/Icon.js
|
|
386
|
+
var import_react = require("react");
|
|
387
|
+
|
|
388
|
+
// node_modules/lucide-react/dist/esm/defaultAttributes.js
|
|
389
|
+
var defaultAttributes = {
|
|
390
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
391
|
+
width: 24,
|
|
392
|
+
height: 24,
|
|
393
|
+
viewBox: "0 0 24 24",
|
|
394
|
+
fill: "none",
|
|
395
|
+
stroke: "currentColor",
|
|
396
|
+
strokeWidth: 2,
|
|
397
|
+
strokeLinecap: "round",
|
|
398
|
+
strokeLinejoin: "round"
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
// node_modules/lucide-react/dist/esm/shared/src/utils/hasA11yProp.js
|
|
402
|
+
var hasA11yProp = (props) => {
|
|
403
|
+
for (const prop in props) {
|
|
404
|
+
if (prop.startsWith("aria-") || prop === "role" || prop === "title") {
|
|
405
|
+
return true;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
return false;
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
// node_modules/lucide-react/dist/esm/Icon.js
|
|
412
|
+
var Icon = (0, import_react.forwardRef)(
|
|
413
|
+
({
|
|
414
|
+
color = "currentColor",
|
|
415
|
+
size = 24,
|
|
416
|
+
strokeWidth = 2,
|
|
417
|
+
absoluteStrokeWidth,
|
|
418
|
+
className = "",
|
|
419
|
+
children,
|
|
420
|
+
iconNode,
|
|
421
|
+
...rest
|
|
422
|
+
}, ref) => (0, import_react.createElement)(
|
|
423
|
+
"svg",
|
|
424
|
+
{
|
|
425
|
+
ref,
|
|
426
|
+
...defaultAttributes,
|
|
427
|
+
width: size,
|
|
428
|
+
height: size,
|
|
429
|
+
stroke: color,
|
|
430
|
+
strokeWidth: absoluteStrokeWidth ? Number(strokeWidth) * 24 / Number(size) : strokeWidth,
|
|
431
|
+
className: mergeClasses("lucide", className),
|
|
432
|
+
...!children && !hasA11yProp(rest) && { "aria-hidden": "true" },
|
|
433
|
+
...rest
|
|
434
|
+
},
|
|
435
|
+
[
|
|
436
|
+
...iconNode.map(([tag, attrs]) => (0, import_react.createElement)(tag, attrs)),
|
|
437
|
+
...Array.isArray(children) ? children : [children]
|
|
438
|
+
]
|
|
439
|
+
)
|
|
440
|
+
);
|
|
441
|
+
|
|
442
|
+
// node_modules/lucide-react/dist/esm/createLucideIcon.js
|
|
443
|
+
var createLucideIcon = (iconName, iconNode) => {
|
|
444
|
+
const Component = (0, import_react2.forwardRef)(
|
|
445
|
+
({ className, ...props }, ref) => (0, import_react2.createElement)(Icon, {
|
|
446
|
+
ref,
|
|
447
|
+
iconNode,
|
|
448
|
+
className: mergeClasses(
|
|
449
|
+
`lucide-${toKebabCase(toPascalCase(iconName))}`,
|
|
450
|
+
`lucide-${iconName}`,
|
|
451
|
+
className
|
|
452
|
+
),
|
|
453
|
+
...props
|
|
454
|
+
})
|
|
455
|
+
);
|
|
456
|
+
Component.displayName = toPascalCase(iconName);
|
|
457
|
+
return Component;
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
// node_modules/lucide-react/dist/esm/icons/chevron-left.js
|
|
461
|
+
var __iconNode = [["path", { d: "m15 18-6-6 6-6", key: "1wnfg3" }]];
|
|
462
|
+
var ChevronLeft = createLucideIcon("chevron-left", __iconNode);
|
|
463
|
+
|
|
464
|
+
// node_modules/lucide-react/dist/esm/icons/chevron-right.js
|
|
465
|
+
var __iconNode2 = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]];
|
|
466
|
+
var ChevronRight = createLucideIcon("chevron-right", __iconNode2);
|
|
467
|
+
|
|
468
|
+
// node_modules/lucide-react/dist/esm/icons/chevrons-left.js
|
|
469
|
+
var __iconNode3 = [
|
|
470
|
+
["path", { d: "m11 17-5-5 5-5", key: "13zhaf" }],
|
|
471
|
+
["path", { d: "m18 17-5-5 5-5", key: "h8a8et" }]
|
|
472
|
+
];
|
|
473
|
+
var ChevronsLeft = createLucideIcon("chevrons-left", __iconNode3);
|
|
474
|
+
|
|
475
|
+
// node_modules/lucide-react/dist/esm/icons/chevrons-right.js
|
|
476
|
+
var __iconNode4 = [
|
|
477
|
+
["path", { d: "m6 17 5-5-5-5", key: "xnjwq" }],
|
|
478
|
+
["path", { d: "m13 17 5-5-5-5", key: "17xmmf" }]
|
|
479
|
+
];
|
|
480
|
+
var ChevronsRight = createLucideIcon("chevrons-right", __iconNode4);
|
|
481
|
+
|
|
482
|
+
// src/dataTable/pagination/DataTablePagination.tsx
|
|
483
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
484
|
+
function DataTablePagination({
|
|
485
|
+
table
|
|
486
|
+
}) {
|
|
487
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex items-center justify-between px-2 pt-4", children: [
|
|
488
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "text-muted-foreground flex-1 text-sm", children: [
|
|
489
|
+
table.getFilteredRowModel().rows.length,
|
|
490
|
+
" rows"
|
|
491
|
+
] }),
|
|
492
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex items-center space-x-6 lg:space-x-8", children: [
|
|
493
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex w-[100px] items-center justify-center text-sm font-medium", children: [
|
|
494
|
+
"Page ",
|
|
495
|
+
table.getState().pagination.pageIndex + 1,
|
|
496
|
+
" of",
|
|
497
|
+
" ",
|
|
498
|
+
table.getPageCount() || 1
|
|
499
|
+
] }),
|
|
500
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex items-center space-x-2", children: [
|
|
501
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
502
|
+
Button,
|
|
503
|
+
{
|
|
504
|
+
className: "hidden size-8 lg:flex",
|
|
505
|
+
disabled: !table.getCanPreviousPage(),
|
|
506
|
+
onClick: () => table.setPageIndex(0),
|
|
507
|
+
size: "icon",
|
|
508
|
+
variant: "outline",
|
|
509
|
+
children: [
|
|
510
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "sr-only", children: "Go to first page" }),
|
|
511
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ChevronsLeft, {})
|
|
512
|
+
]
|
|
513
|
+
}
|
|
514
|
+
),
|
|
515
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
516
|
+
Button,
|
|
517
|
+
{
|
|
518
|
+
className: "size-8",
|
|
519
|
+
disabled: !table.getCanPreviousPage(),
|
|
520
|
+
onClick: () => table.previousPage(),
|
|
521
|
+
size: "icon",
|
|
522
|
+
variant: "outline",
|
|
523
|
+
children: [
|
|
524
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "sr-only", children: "Go to previous page" }),
|
|
525
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ChevronLeft, {})
|
|
526
|
+
]
|
|
527
|
+
}
|
|
528
|
+
),
|
|
529
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
530
|
+
Button,
|
|
531
|
+
{
|
|
532
|
+
className: "size-8",
|
|
533
|
+
disabled: !table.getCanNextPage(),
|
|
534
|
+
onClick: () => table.nextPage(),
|
|
535
|
+
size: "icon",
|
|
536
|
+
variant: "outline",
|
|
537
|
+
children: [
|
|
538
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "sr-only", children: "Go to next page" }),
|
|
539
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ChevronRight, {})
|
|
540
|
+
]
|
|
541
|
+
}
|
|
542
|
+
),
|
|
543
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
544
|
+
Button,
|
|
545
|
+
{
|
|
546
|
+
className: "hidden size-8 lg:flex",
|
|
547
|
+
disabled: !table.getCanNextPage(),
|
|
548
|
+
onClick: () => table.setPageIndex(table.getPageCount() - 1),
|
|
549
|
+
size: "icon",
|
|
550
|
+
variant: "outline",
|
|
551
|
+
children: [
|
|
552
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "sr-only", children: "Go to last page" }),
|
|
553
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ChevronsRight, {})
|
|
554
|
+
]
|
|
555
|
+
}
|
|
556
|
+
)
|
|
557
|
+
] })
|
|
558
|
+
] })
|
|
559
|
+
] });
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
// src/lib/search.ts
|
|
563
|
+
var import_match_sorter_utils = require("@tanstack/match-sorter-utils");
|
|
564
|
+
var fuzzyFilterFn = (searchableColumns) => (row, columnId, filterValue, addMeta) => {
|
|
565
|
+
if (!searchableColumns) return false;
|
|
566
|
+
if (!searchableColumns.includes(columnId)) return false;
|
|
567
|
+
const itemRank = (0, import_match_sorter_utils.rankItem)(row.getValue(columnId), filterValue);
|
|
568
|
+
addMeta({ itemRank });
|
|
569
|
+
return itemRank.passed;
|
|
570
|
+
};
|
|
571
|
+
|
|
114
572
|
// src/dataTable/DataTable.tsx
|
|
115
573
|
var import_react_table = require("@tanstack/react-table");
|
|
116
|
-
var
|
|
574
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
117
575
|
function DataTable({
|
|
118
576
|
columns,
|
|
119
577
|
data,
|
|
@@ -127,47 +585,81 @@ function DataTable({
|
|
|
127
585
|
getFilteredRowModel: (0, import_react_table.getFilteredRowModel)(),
|
|
128
586
|
getFacetedRowModel: (0, import_react_table.getFacetedRowModel)(),
|
|
129
587
|
getFacetedUniqueValues: (0, import_react_table.getFacetedUniqueValues)(),
|
|
588
|
+
globalFilterFn: fuzzyFilterFn(config?.search?.filterFields),
|
|
130
589
|
autoResetPageIndex: false,
|
|
131
590
|
initialState: {
|
|
132
591
|
columnVisibility: config?.columnVisibility
|
|
133
592
|
}
|
|
134
593
|
});
|
|
135
|
-
return /* @__PURE__ */ (0,
|
|
136
|
-
/* @__PURE__ */ (0,
|
|
137
|
-
|
|
138
|
-
TableHead,
|
|
139
|
-
{
|
|
140
|
-
colSpan: header.colSpan,
|
|
141
|
-
style: { width: header.getSize() },
|
|
142
|
-
children: header.isPlaceholder ? null : (0, import_react_table.flexRender)(
|
|
143
|
-
header.column.columnDef.header,
|
|
144
|
-
header.getContext()
|
|
145
|
-
)
|
|
146
|
-
},
|
|
147
|
-
header.id
|
|
148
|
-
);
|
|
149
|
-
}) }, headerGroup.id)) }),
|
|
150
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TableBody, { children: table.getRowModel().rows?.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
151
|
-
TableRow,
|
|
152
|
-
{
|
|
153
|
-
"data-state": row.getIsSelected() && "selected",
|
|
154
|
-
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TableCell, { className: "truncate max-w-0", children: (0, import_react_table.flexRender)(
|
|
155
|
-
cell.column.columnDef.cell,
|
|
156
|
-
cell.getContext()
|
|
157
|
-
) }, cell.id))
|
|
158
|
-
},
|
|
159
|
-
row.id
|
|
160
|
-
)) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TableRow, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
161
|
-
TableCell,
|
|
594
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "w-full", children: [
|
|
595
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
596
|
+
DataTableControls,
|
|
162
597
|
{
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
598
|
+
filters: config?.filters,
|
|
599
|
+
search: config?.search,
|
|
600
|
+
table
|
|
166
601
|
}
|
|
167
|
-
)
|
|
168
|
-
|
|
602
|
+
),
|
|
603
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "rounded-md border overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Table, { children: [
|
|
604
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TableHeader, { className: "bg-muted", children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TableRow, { children: headerGroup.headers.map((header) => {
|
|
605
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
606
|
+
TableHead,
|
|
607
|
+
{
|
|
608
|
+
colSpan: header.colSpan,
|
|
609
|
+
style: { width: header.getSize() },
|
|
610
|
+
children: header.isPlaceholder ? null : (0, import_react_table.flexRender)(
|
|
611
|
+
header.column.columnDef.header,
|
|
612
|
+
header.getContext()
|
|
613
|
+
)
|
|
614
|
+
},
|
|
615
|
+
header.id
|
|
616
|
+
);
|
|
617
|
+
}) }, headerGroup.id)) }),
|
|
618
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TableBody, { children: table.getRowModel().rows?.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
619
|
+
TableRow,
|
|
620
|
+
{
|
|
621
|
+
"data-state": row.getIsSelected() && "selected",
|
|
622
|
+
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TableCell, { className: "truncate max-w-0", children: (0, import_react_table.flexRender)(
|
|
623
|
+
cell.column.columnDef.cell,
|
|
624
|
+
cell.getContext()
|
|
625
|
+
) }, cell.id))
|
|
626
|
+
},
|
|
627
|
+
row.id
|
|
628
|
+
)) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TableRow, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
629
|
+
TableCell,
|
|
630
|
+
{
|
|
631
|
+
className: "h-24 text-center",
|
|
632
|
+
colSpan: columns.length,
|
|
633
|
+
children: "No results."
|
|
634
|
+
}
|
|
635
|
+
) }) })
|
|
636
|
+
] }) }),
|
|
637
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DataTablePagination, { table })
|
|
638
|
+
] });
|
|
169
639
|
}
|
|
170
640
|
// Annotate the CommonJS export names for ESM import in node:
|
|
171
641
|
0 && (module.exports = {
|
|
172
642
|
DataTable
|
|
173
643
|
});
|
|
644
|
+
/*! Bundled license information:
|
|
645
|
+
|
|
646
|
+
lucide-react/dist/esm/shared/src/utils/mergeClasses.js:
|
|
647
|
+
lucide-react/dist/esm/shared/src/utils/toKebabCase.js:
|
|
648
|
+
lucide-react/dist/esm/shared/src/utils/toCamelCase.js:
|
|
649
|
+
lucide-react/dist/esm/shared/src/utils/toPascalCase.js:
|
|
650
|
+
lucide-react/dist/esm/defaultAttributes.js:
|
|
651
|
+
lucide-react/dist/esm/shared/src/utils/hasA11yProp.js:
|
|
652
|
+
lucide-react/dist/esm/Icon.js:
|
|
653
|
+
lucide-react/dist/esm/createLucideIcon.js:
|
|
654
|
+
lucide-react/dist/esm/icons/chevron-left.js:
|
|
655
|
+
lucide-react/dist/esm/icons/chevron-right.js:
|
|
656
|
+
lucide-react/dist/esm/icons/chevrons-left.js:
|
|
657
|
+
lucide-react/dist/esm/icons/chevrons-right.js:
|
|
658
|
+
lucide-react/dist/esm/lucide-react.js:
|
|
659
|
+
(**
|
|
660
|
+
* @license lucide-react v0.574.0 - ISC
|
|
661
|
+
*
|
|
662
|
+
* This source code is licensed under the ISC license.
|
|
663
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
664
|
+
*)
|
|
665
|
+
*/
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ColumnDef } from '@tanstack/react-table';
|
|
3
3
|
|
|
4
|
+
type Filter<TData> = {
|
|
5
|
+
column: keyof TData;
|
|
6
|
+
type: "select" | "date";
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type Search<TData> = {
|
|
10
|
+
filterFields: (keyof TData)[];
|
|
11
|
+
placeholder: string;
|
|
12
|
+
};
|
|
13
|
+
type Filters<TData> = Filter<TData>[];
|
|
4
14
|
type ColumnVisibility<TData> = {
|
|
5
15
|
[K in keyof TData]?: boolean;
|
|
6
16
|
} & Record<string, boolean>;
|
|
@@ -8,6 +18,8 @@ interface DataTableProps<TData, TValue> {
|
|
|
8
18
|
columns: ColumnDef<TData, TValue>[];
|
|
9
19
|
data: TData[];
|
|
10
20
|
config?: {
|
|
21
|
+
search?: Search<TData>;
|
|
22
|
+
filters?: Filters<TData>;
|
|
11
23
|
columnVisibility?: ColumnVisibility<TData>;
|
|
12
24
|
};
|
|
13
25
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ColumnDef } from '@tanstack/react-table';
|
|
3
3
|
|
|
4
|
+
type Filter<TData> = {
|
|
5
|
+
column: keyof TData;
|
|
6
|
+
type: "select" | "date";
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type Search<TData> = {
|
|
10
|
+
filterFields: (keyof TData)[];
|
|
11
|
+
placeholder: string;
|
|
12
|
+
};
|
|
13
|
+
type Filters<TData> = Filter<TData>[];
|
|
4
14
|
type ColumnVisibility<TData> = {
|
|
5
15
|
[K in keyof TData]?: boolean;
|
|
6
16
|
} & Record<string, boolean>;
|
|
@@ -8,6 +18,8 @@ interface DataTableProps<TData, TValue> {
|
|
|
8
18
|
columns: ColumnDef<TData, TValue>[];
|
|
9
19
|
data: TData[];
|
|
10
20
|
config?: {
|
|
21
|
+
search?: Search<TData>;
|
|
22
|
+
filters?: Filters<TData>;
|
|
11
23
|
columnVisibility?: ColumnVisibility<TData>;
|
|
12
24
|
};
|
|
13
25
|
}
|