@saptanshuwanjari/react-component-library 0.1.0 → 0.1.8

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.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var react = require('react');
3
+ var React2 = require('react');
4
4
  var zod = require('@hookform/resolvers/zod');
5
5
  var reactHookForm = require('react-hook-form');
6
6
  var jsxRuntime = require('react/jsx-runtime');
@@ -8,7 +8,6 @@ var lucideReact = require('lucide-react');
8
8
  var clsx = require('clsx');
9
9
  var tailwindMerge = require('tailwind-merge');
10
10
  var reactTable = require('@tanstack/react-table');
11
- var reactSlot = require('@radix-ui/react-slot');
12
11
  var classVarianceAuthority = require('class-variance-authority');
13
12
  var SelectPrimitive = require('@radix-ui/react-select');
14
13
  var PopoverPrimitive = require('@radix-ui/react-popover');
@@ -32,12 +31,13 @@ function _interopNamespace(e) {
32
31
  return Object.freeze(n);
33
32
  }
34
33
 
34
+ var React2__namespace = /*#__PURE__*/_interopNamespace(React2);
35
35
  var SelectPrimitive__namespace = /*#__PURE__*/_interopNamespace(SelectPrimitive);
36
36
  var PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespace(PopoverPrimitive);
37
37
  var CheckboxPrimitive__namespace = /*#__PURE__*/_interopNamespace(CheckboxPrimitive);
38
38
 
39
39
  // src/components/form/root.tsx
40
- var FormContext = react.createContext(null);
40
+ var FormContext = React2.createContext(null);
41
41
  var DEFAULT_FORM_KEY = "__default_form__";
42
42
  var formRegistry = /* @__PURE__ */ new Map();
43
43
  function Root({
@@ -52,8 +52,8 @@ function Root({
52
52
  formId
53
53
  }) {
54
54
  const resolver = schema ? zod.zodResolver(schema) : void 0;
55
- const [isPending, startTransition] = react.useTransition();
56
- const [isEditing, setIsEditing] = react.useState(!enableEditMode);
55
+ const [isPending, startTransition] = React2.useTransition();
56
+ const [isEditing, setIsEditing] = React2.useState(!enableEditMode);
57
57
  const methods = reactHookForm.useForm({
58
58
  resolver,
59
59
  defaultValues
@@ -67,7 +67,7 @@ function Root({
67
67
  }
68
68
  return onSubmit(data);
69
69
  });
70
- react.useEffect(() => {
70
+ React2.useEffect(() => {
71
71
  const key = formId ?? DEFAULT_FORM_KEY;
72
72
  formRegistry.set(key, setIsEditing);
73
73
  return () => {
@@ -91,7 +91,7 @@ function Root({
91
91
  }
92
92
  var root_default = Root;
93
93
  function useFormCtx() {
94
- const ctx = react.useContext(FormContext);
94
+ const ctx = React2.useContext(FormContext);
95
95
  if (!ctx) throw new Error("Form components must be used inside Form.Root");
96
96
  return ctx;
97
97
  }
@@ -125,7 +125,7 @@ var Input = ({ className = "", ...props }) => /* @__PURE__ */ jsxRuntime.jsx(
125
125
  ...props
126
126
  }
127
127
  );
128
- var InputField = react.memo(function InputField2({
128
+ var InputField = React2.memo(function InputField2({
129
129
  name,
130
130
  label,
131
131
  placeholder,
@@ -150,12 +150,12 @@ var InputField = react.memo(function InputField2({
150
150
  ) });
151
151
  });
152
152
  var input_field_default = InputField;
153
- var PasswordField = react.memo(function PasswordField2({
153
+ var PasswordField = React2.memo(function PasswordField2({
154
154
  name,
155
155
  label,
156
156
  placeholder
157
157
  }) {
158
- const [show, setShow] = react.useState(false);
158
+ const [show, setShow] = React2.useState(false);
159
159
  return /* @__PURE__ */ jsxRuntime.jsx(field_default, { name, label, children: (field) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
160
160
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Lock, { className: "h-4 w-4 text-muted-foreground" }) }),
161
161
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -188,7 +188,7 @@ var Textarea = ({ className = "", ...props }) => /* @__PURE__ */ jsxRuntime.jsx(
188
188
  ...props
189
189
  }
190
190
  );
191
- var TextareaField = react.memo(function TextareaField2({
191
+ var TextareaField = React2.memo(function TextareaField2({
192
192
  name,
193
193
  label,
194
194
  placeholder,
@@ -227,7 +227,7 @@ var Input2 = ({ className = "", ...props }) => /* @__PURE__ */ jsxRuntime.jsx(
227
227
  ...props
228
228
  }
229
229
  );
230
- var SelectField = react.memo(function SelectField2({
230
+ var SelectField = React2.memo(function SelectField2({
231
231
  name,
232
232
  label,
233
233
  placeholder = "Select an option",
@@ -262,7 +262,7 @@ var Checkbox = ({ checked, onCheckedChange, disabled, id }) => /* @__PURE__ */ j
262
262
  className: "h-4 w-4 rounded border-gray-300"
263
263
  }
264
264
  );
265
- var CheckboxField = react.memo(function CheckboxField2({
265
+ var CheckboxField = React2.memo(function CheckboxField2({
266
266
  name,
267
267
  label,
268
268
  description
@@ -310,12 +310,12 @@ var Button = ({ children, className = "", ...props }) => /* @__PURE__ */ jsxRunt
310
310
  children
311
311
  }
312
312
  );
313
- var DateField = react.memo(function DateField2({
313
+ var DateField = React2.memo(function DateField2({
314
314
  name,
315
315
  label,
316
316
  placeholder = "Select date"
317
317
  }) {
318
- const [open, setOpen] = react.useState(false);
318
+ const [open, setOpen] = React2.useState(false);
319
319
  const { isEditing } = useFormCtx();
320
320
  return /* @__PURE__ */ jsxRuntime.jsx(field_default, { name, label, children: (field) => !isEditing ? /* @__PURE__ */ jsxRuntime.jsxs(
321
321
  Button,
@@ -351,7 +351,7 @@ var Input3 = ({ className = "", ...props }) => /* @__PURE__ */ jsxRuntime.jsx(
351
351
  var InputGroup = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative flex items-center", children });
352
352
  var InputGroupAddon = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute left-3 flex items-center", children });
353
353
  var InputGroupInput = (props) => /* @__PURE__ */ jsxRuntime.jsx(Input3, { className: "pl-10", ...props });
354
- var FileField = react.memo(function FileField2({
354
+ var FileField = React2.memo(function FileField2({
355
355
  name,
356
356
  label,
357
357
  accept,
@@ -405,7 +405,7 @@ var AvatarFallback = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("div", { c
405
405
  var Label = ({ htmlFor, children, className }) => /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor, className, children });
406
406
  var Input4 = (props) => /* @__PURE__ */ jsxRuntime.jsx("input", { ...props });
407
407
  var Button2 = ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("button", { className: "px-3 py-1 text-sm rounded hover:bg-accent", ...props, children });
408
- var ProfilePictureField = react.memo(function ProfilePictureField2({
408
+ var ProfilePictureField = React2.memo(function ProfilePictureField2({
409
409
  name,
410
410
  label,
411
411
  className,
@@ -413,7 +413,7 @@ var ProfilePictureField = react.memo(function ProfilePictureField2({
413
413
  fallback = "User"
414
414
  }) {
415
415
  const { isEditing } = useFormCtx();
416
- const [preview, setPreview] = react.useState(null);
416
+ const [preview, setPreview] = React2.useState(null);
417
417
  return /* @__PURE__ */ jsxRuntime.jsx(field_default, { name, label, children: (field) => {
418
418
  const currentValue = field.value;
419
419
  const displayUrl = preview || (typeof currentValue === "string" ? currentValue : null);
@@ -498,7 +498,7 @@ var Button4 = ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx(
498
498
  }
499
499
  );
500
500
  function EditButton({ children, formId, ...props }) {
501
- const ctx = react.useContext(FormContext);
501
+ const ctx = React2.useContext(FormContext);
502
502
  if (ctx) {
503
503
  const { isEditing, setIsEditing } = ctx;
504
504
  if (isEditing) return null;
@@ -585,9 +585,9 @@ var Form = Object.assign(root_default, {
585
585
  LinkField: link_field_default
586
586
  });
587
587
  var form_default = Form;
588
- var DataTableContext = react.createContext(null);
588
+ var DataTableContext = React2.createContext(null);
589
589
  function useDataTable() {
590
- const context = react.useContext(DataTableContext);
590
+ const context = React2.useContext(DataTableContext);
591
591
  if (!context) {
592
592
  throw new Error("DataTable components must be used within DataTable.Root");
593
593
  }
@@ -598,17 +598,22 @@ function Root2({
598
598
  data,
599
599
  filters = [],
600
600
  defaultViewMode = "table",
601
+ viewMode: controlledViewMode,
602
+ onViewModeChange: controlledOnViewModeChange,
601
603
  defaultPageSize = 10,
602
604
  children
603
605
  }) {
604
- const [viewMode, setViewMode] = react.useState(defaultViewMode);
605
- const [sorting, setSorting] = react.useState([]);
606
- const [columnFilters, setColumnFilters] = react.useState([]);
607
- const [columnVisibility, setColumnVisibility] = react.useState({});
608
- const [globalFilter, setGlobalFilter] = react.useState("");
609
- const [pagination, setPagination] = react.useState({ pageIndex: 0, pageSize: defaultPageSize });
610
- const [activeFilters, setActiveFilters] = react.useState({});
611
- const filteredData = react.useMemo(() => {
606
+ const [internalViewMode, setInternalViewMode] = React2.useState(defaultViewMode);
607
+ const [sorting, setSorting] = React2.useState([]);
608
+ const [columnFilters, setColumnFilters] = React2.useState([]);
609
+ const [columnVisibility, setColumnVisibility] = React2.useState({});
610
+ const [globalFilter, setGlobalFilter] = React2.useState("");
611
+ const [pagination, setPagination] = React2.useState({ pageIndex: 0, pageSize: defaultPageSize });
612
+ const [activeFilters, setActiveFilters] = React2.useState({});
613
+ const isControlled = controlledViewMode !== void 0 && controlledOnViewModeChange !== void 0;
614
+ const viewMode = isControlled ? controlledViewMode : internalViewMode;
615
+ const setViewMode = isControlled ? controlledOnViewModeChange : setInternalViewMode;
616
+ const filteredData = React2.useMemo(() => {
612
617
  if (Object.keys(activeFilters).length === 0) return data;
613
618
  return data.filter((row) => {
614
619
  return Object.entries(activeFilters).every(([filterId, filterValue]) => {
@@ -675,6 +680,120 @@ function Input5({ className, type, ...props }) {
675
680
  }
676
681
  );
677
682
  }
683
+ function setRef(ref, value) {
684
+ if (typeof ref === "function") {
685
+ return ref(value);
686
+ } else if (ref !== null && ref !== void 0) {
687
+ ref.current = value;
688
+ }
689
+ }
690
+ function composeRefs(...refs) {
691
+ return (node) => {
692
+ let hasCleanup = false;
693
+ const cleanups = refs.map((ref) => {
694
+ const cleanup = setRef(ref, node);
695
+ if (!hasCleanup && typeof cleanup == "function") {
696
+ hasCleanup = true;
697
+ }
698
+ return cleanup;
699
+ });
700
+ if (hasCleanup) {
701
+ return () => {
702
+ for (let i = 0; i < cleanups.length; i++) {
703
+ const cleanup = cleanups[i];
704
+ if (typeof cleanup == "function") {
705
+ cleanup();
706
+ } else {
707
+ setRef(refs[i], null);
708
+ }
709
+ }
710
+ };
711
+ }
712
+ };
713
+ }
714
+ // @__NO_SIDE_EFFECTS__
715
+ function createSlot(ownerName) {
716
+ const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
717
+ const Slot2 = React2__namespace.forwardRef((props, forwardedRef) => {
718
+ const { children, ...slotProps } = props;
719
+ const childrenArray = React2__namespace.Children.toArray(children);
720
+ const slottable = childrenArray.find(isSlottable);
721
+ if (slottable) {
722
+ const newElement = slottable.props.children;
723
+ const newChildren = childrenArray.map((child) => {
724
+ if (child === slottable) {
725
+ if (React2__namespace.Children.count(newElement) > 1) return React2__namespace.Children.only(null);
726
+ return React2__namespace.isValidElement(newElement) ? newElement.props.children : null;
727
+ } else {
728
+ return child;
729
+ }
730
+ });
731
+ return /* @__PURE__ */ jsxRuntime.jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React2__namespace.isValidElement(newElement) ? React2__namespace.cloneElement(newElement, void 0, newChildren) : null });
732
+ }
733
+ return /* @__PURE__ */ jsxRuntime.jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
734
+ });
735
+ Slot2.displayName = `${ownerName}.Slot`;
736
+ return Slot2;
737
+ }
738
+ var Slot = /* @__PURE__ */ createSlot("Slot");
739
+ // @__NO_SIDE_EFFECTS__
740
+ function createSlotClone(ownerName) {
741
+ const SlotClone = React2__namespace.forwardRef((props, forwardedRef) => {
742
+ const { children, ...slotProps } = props;
743
+ if (React2__namespace.isValidElement(children)) {
744
+ const childrenRef = getElementRef(children);
745
+ const props2 = mergeProps(slotProps, children.props);
746
+ if (children.type !== React2__namespace.Fragment) {
747
+ props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
748
+ }
749
+ return React2__namespace.cloneElement(children, props2);
750
+ }
751
+ return React2__namespace.Children.count(children) > 1 ? React2__namespace.Children.only(null) : null;
752
+ });
753
+ SlotClone.displayName = `${ownerName}.SlotClone`;
754
+ return SlotClone;
755
+ }
756
+ var SLOTTABLE_IDENTIFIER = /* @__PURE__ */ Symbol("radix.slottable");
757
+ function isSlottable(child) {
758
+ return React2__namespace.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
759
+ }
760
+ function mergeProps(slotProps, childProps) {
761
+ const overrideProps = { ...childProps };
762
+ for (const propName in childProps) {
763
+ const slotPropValue = slotProps[propName];
764
+ const childPropValue = childProps[propName];
765
+ const isHandler = /^on[A-Z]/.test(propName);
766
+ if (isHandler) {
767
+ if (slotPropValue && childPropValue) {
768
+ overrideProps[propName] = (...args) => {
769
+ const result = childPropValue(...args);
770
+ slotPropValue(...args);
771
+ return result;
772
+ };
773
+ } else if (slotPropValue) {
774
+ overrideProps[propName] = slotPropValue;
775
+ }
776
+ } else if (propName === "style") {
777
+ overrideProps[propName] = { ...slotPropValue, ...childPropValue };
778
+ } else if (propName === "className") {
779
+ overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
780
+ }
781
+ }
782
+ return { ...slotProps, ...overrideProps };
783
+ }
784
+ function getElementRef(element) {
785
+ let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
786
+ let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
787
+ if (mayWarn) {
788
+ return element.ref;
789
+ }
790
+ getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
791
+ mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
792
+ if (mayWarn) {
793
+ return element.props.ref;
794
+ }
795
+ return element.props.ref || element.ref;
796
+ }
678
797
  var buttonVariants = classVarianceAuthority.cva(
679
798
  "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
680
799
  {
@@ -709,7 +828,7 @@ function Button6({
709
828
  asChild = false,
710
829
  ...props
711
830
  }) {
712
- const Comp = asChild ? reactSlot.Slot : "button";
831
+ const Comp = asChild ? Slot : "button";
713
832
  return /* @__PURE__ */ jsxRuntime.jsx(
714
833
  Comp,
715
834
  {
@@ -906,8 +1025,41 @@ function Checkbox2({
906
1025
  }
907
1026
  );
908
1027
  }
909
- function Toolbar() {
910
- const { table, viewMode, setViewMode, filters, activeFilters, setActiveFilters } = useDataTable();
1028
+ function ViewOptions({ viewMode: propViewMode, onViewModeChange: propOnViewModeChange }) {
1029
+ let contextStr;
1030
+ try {
1031
+ contextStr = useDataTable();
1032
+ } catch (e) {
1033
+ }
1034
+ const mode = propViewMode ?? contextStr?.viewMode ?? "table";
1035
+ const setMode = propOnViewModeChange ?? contextStr?.setViewMode ?? (() => {
1036
+ });
1037
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center border rounded-md bg-background", children: [
1038
+ /* @__PURE__ */ jsxRuntime.jsx(
1039
+ Button6,
1040
+ {
1041
+ variant: mode === "table" ? "secondary" : "ghost",
1042
+ size: "sm",
1043
+ onClick: () => setMode("table"),
1044
+ className: "rounded-r-none h-8 px-2 lg:px-3",
1045
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Table, { className: "h-4 w-4" })
1046
+ }
1047
+ ),
1048
+ /* @__PURE__ */ jsxRuntime.jsx(
1049
+ Button6,
1050
+ {
1051
+ variant: mode === "grid" ? "secondary" : "ghost",
1052
+ size: "sm",
1053
+ onClick: () => setMode("grid"),
1054
+ className: "rounded-l-none h-8 px-2 lg:px-3",
1055
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.LayoutGrid, { className: "h-4 w-4" })
1056
+ }
1057
+ )
1058
+ ] });
1059
+ }
1060
+ var view_options_default = ViewOptions;
1061
+ function Toolbar({ viewOptions } = {}) {
1062
+ const { table, filters, activeFilters, setActiveFilters } = useDataTable();
911
1063
  const handleFilterChange = (filterId, value) => {
912
1064
  setActiveFilters((prev) => ({
913
1065
  ...prev,
@@ -924,115 +1076,116 @@ function Toolbar() {
924
1076
  return { ...prev, [filterId]: newValues };
925
1077
  });
926
1078
  };
927
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4", children: [
928
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 max-w-sm", children: /* @__PURE__ */ jsxRuntime.jsx(
1079
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4 py-4", children: [
1080
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxRuntime.jsx(
929
1081
  Input5,
930
1082
  {
931
1083
  placeholder: "Search...",
932
1084
  value: table.getState().globalFilter ?? "",
933
1085
  onChange: (e) => table.setGlobalFilter(e.target.value),
934
- className: "w-full"
1086
+ className: "w-full max-w-sm"
935
1087
  }
936
1088
  ) }),
937
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 flex-wrap", children: [
938
- filters.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(Popover, { children: [
939
- /* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(Button6, { variant: "outline", size: "sm", children: [
940
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.SlidersHorizontal, { className: "h-4 w-4 mr-2" }),
941
- "Filters"
942
- ] }) }),
943
- /* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "w-80", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
944
- /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "font-medium text-sm", children: "Filters" }),
945
- filters.map((filter) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
946
- /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-sm font-medium", children: filter.label }),
947
- filter.multiSelect ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-2", children: filter.options.map((option) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center space-x-2", children: [
948
- /* @__PURE__ */ jsxRuntime.jsx(
949
- Checkbox2,
950
- {
951
- id: `${filter.id}-${option.value}`,
952
- checked: Array.isArray(activeFilters[filter.id]) && activeFilters[filter.id].includes(option.value),
953
- onCheckedChange: () => handleMultiFilterToggle(filter.id, option.value)
954
- }
955
- ),
1089
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4", children: [
1090
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 flex-wrap flex-1", children: [
1091
+ filters.map((filter) => /* @__PURE__ */ jsxRuntime.jsx("div", { children: filter.multiSelect ? /* @__PURE__ */ jsxRuntime.jsxs(Popover, { children: [
1092
+ /* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(Button6, { variant: "outline", size: "sm", className: "h-8 border-dashed", children: [
1093
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.SlidersHorizontal, { className: "h-4 w-4 mr-2" }),
1094
+ filter.label,
1095
+ activeFilters[filter.id] && (Array.isArray(activeFilters[filter.id]) ? activeFilters[filter.id].length > 0 : true) && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-1 rounded-sm bg-primary px-1 text-xs text-primary-foreground", children: Array.isArray(activeFilters[filter.id]) ? activeFilters[filter.id].length : 1 })
1096
+ ] }) }),
1097
+ /* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "w-[200px] p-0", align: "start", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-1", children: [
1098
+ filter.options.map((option) => /* @__PURE__ */ jsxRuntime.jsxs(
1099
+ "div",
1100
+ {
1101
+ className: "flex items-center space-x-2 rounded-sm px-2 py-1.5 hover:bg-accent cursor-pointer",
1102
+ onClick: () => handleMultiFilterToggle(filter.id, option.value),
1103
+ children: [
1104
+ /* @__PURE__ */ jsxRuntime.jsx(
1105
+ Checkbox2,
1106
+ {
1107
+ id: `${filter.id}-${option.value}`,
1108
+ checked: Array.isArray(activeFilters[filter.id]) && activeFilters[filter.id].includes(option.value),
1109
+ onCheckedChange: () => handleMultiFilterToggle(filter.id, option.value)
1110
+ }
1111
+ ),
1112
+ /* @__PURE__ */ jsxRuntime.jsx(
1113
+ "label",
1114
+ {
1115
+ className: "text-sm cursor-pointer flex-1",
1116
+ children: option.label
1117
+ }
1118
+ )
1119
+ ]
1120
+ },
1121
+ option.value
1122
+ )),
1123
+ activeFilters[filter.id] && (Array.isArray(activeFilters[filter.id]) ? activeFilters[filter.id].length > 0 : false) && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1124
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-px bg-border my-1" }),
956
1125
  /* @__PURE__ */ jsxRuntime.jsx(
957
- "label",
1126
+ "div",
958
1127
  {
959
- htmlFor: `${filter.id}-${option.value}`,
960
- className: "text-sm cursor-pointer",
961
- children: option.label
1128
+ className: "px-2 py-1.5 text-center text-sm cursor-pointer hover:bg-accent rounded-sm",
1129
+ onClick: () => setActiveFilters((prev) => ({ ...prev, [filter.id]: [] })),
1130
+ children: "Clear filters"
962
1131
  }
963
1132
  )
964
- ] }, option.value)) }) : /* @__PURE__ */ jsxRuntime.jsxs(
965
- Select2,
966
- {
967
- value: activeFilters[filter.id] || "all",
968
- onValueChange: (value) => handleFilterChange(filter.id, value),
969
- children: [
970
- /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue2, { placeholder: filter.placeholder || "Select..." }) }),
971
- /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { children: [
972
- /* @__PURE__ */ jsxRuntime.jsx(SelectItem2, { value: "all", children: "All" }),
973
- filter.options.map((option) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem2, { value: option.value, children: option.label }, option.value))
974
- ] })
975
- ]
976
- }
977
- )
978
- ] }, filter.id))
979
- ] }) })
980
- ] }),
981
- /* @__PURE__ */ jsxRuntime.jsxs(Popover, { children: [
982
- /* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(Button6, { variant: "outline", size: "sm", children: [
983
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Eye, { className: "h-4 w-4 mr-2" }),
984
- "Columns"
985
- ] }) }),
986
- /* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "w-56", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
987
- /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "font-medium text-sm", children: "Toggle Columns" }),
988
- table.getAllColumns().filter((column) => column.getCanHide()).map((column) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center space-x-2", children: [
989
- /* @__PURE__ */ jsxRuntime.jsx(
990
- Checkbox2,
991
- {
992
- id: column.id,
993
- checked: column.getIsVisible(),
994
- onCheckedChange: (value) => column.toggleVisibility(!!value)
995
- }
996
- ),
997
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: column.id, className: "text-sm cursor-pointer", children: column.id })
998
- ] }, column.id))
999
- ] }) })
1000
- ] }),
1001
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center border rounded-md", children: [
1002
- /* @__PURE__ */ jsxRuntime.jsx(
1003
- Button6,
1004
- {
1005
- variant: viewMode === "table" ? "default" : "ghost",
1006
- size: "sm",
1007
- onClick: () => setViewMode("table"),
1008
- className: "rounded-r-none",
1009
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Table, { className: "h-4 w-4" })
1010
- }
1011
- ),
1012
- /* @__PURE__ */ jsxRuntime.jsx(
1013
- Button6,
1014
- {
1015
- variant: viewMode === "grid" ? "default" : "ghost",
1016
- size: "sm",
1017
- onClick: () => setViewMode("grid"),
1018
- className: "rounded-l-none",
1019
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.LayoutGrid, { className: "h-4 w-4" })
1020
- }
1021
- )
1022
- ] }),
1023
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
1024
- /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-sm text-muted-foreground", children: "Rows" }),
1025
- /* @__PURE__ */ jsxRuntime.jsxs(
1133
+ ] })
1134
+ ] }) })
1135
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs(
1026
1136
  Select2,
1027
1137
  {
1028
- value: String(table.getState().pagination.pageSize),
1029
- onValueChange: (value) => table.setPageSize(Number(value)),
1138
+ value: activeFilters[filter.id] || "all",
1139
+ onValueChange: (value) => handleFilterChange(filter.id, value),
1030
1140
  children: [
1031
- /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "w-20", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue2, {}) }),
1032
- /* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: [10, 20, 30, 40, 50].map((size) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem2, { value: String(size), children: size }, size)) })
1141
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-8 w-[150px] border-dashed", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue2, { placeholder: filter.placeholder || filter.label }) }),
1142
+ /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { children: [
1143
+ /* @__PURE__ */ jsxRuntime.jsxs(SelectItem2, { value: "all", children: [
1144
+ "All ",
1145
+ filter.label
1146
+ ] }),
1147
+ filter.options.map((option) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem2, { value: option.value, children: option.label }, option.value))
1148
+ ] })
1033
1149
  ]
1034
1150
  }
1035
- )
1151
+ ) }, filter.id)),
1152
+ /* @__PURE__ */ jsxRuntime.jsxs(Popover, { children: [
1153
+ /* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(Button6, { variant: "outline", size: "sm", className: "h-8 ml-auto sm:ml-0", children: [
1154
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Eye, { className: "h-4 w-4 mr-2" }),
1155
+ "Columns"
1156
+ ] }) }),
1157
+ /* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "w-56", align: "end", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
1158
+ /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "font-medium text-sm", children: "Toggle Columns" }),
1159
+ table.getAllColumns().filter((column) => column.getCanHide()).map((column) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center space-x-2", children: [
1160
+ /* @__PURE__ */ jsxRuntime.jsx(
1161
+ Checkbox2,
1162
+ {
1163
+ id: column.id,
1164
+ checked: column.getIsVisible(),
1165
+ onCheckedChange: (value) => column.toggleVisibility(!!value)
1166
+ }
1167
+ ),
1168
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: column.id, className: "text-sm cursor-pointer", children: column.id })
1169
+ ] }, column.id))
1170
+ ] }) })
1171
+ ] })
1172
+ ] }),
1173
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
1174
+ viewOptions ? viewOptions : /* @__PURE__ */ jsxRuntime.jsx(ViewOptions, {}),
1175
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
1176
+ /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-sm text-muted-foreground whitespace-nowrap hidden sm:inline-block", children: "Rows" }),
1177
+ /* @__PURE__ */ jsxRuntime.jsxs(
1178
+ Select2,
1179
+ {
1180
+ value: String(table.getState().pagination.pageSize),
1181
+ onValueChange: (value) => table.setPageSize(Number(value)),
1182
+ children: [
1183
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "w-16 h-8", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue2, {}) }),
1184
+ /* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: [10, 20, 30, 40, 50].map((size) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem2, { value: String(size), children: size }, size)) })
1185
+ ]
1186
+ }
1187
+ )
1188
+ ] })
1036
1189
  ] })
1037
1190
  ] })
1038
1191
  ] });
@@ -1230,7 +1383,8 @@ var DataTable = Object.assign(root_default2, {
1230
1383
  Content: content_default,
1231
1384
  TableView: table_view_default,
1232
1385
  GridView: grid_view_default,
1233
- Pagination: pagination_default
1386
+ Pagination: pagination_default,
1387
+ ViewOptions: view_options_default
1234
1388
  });
1235
1389
  var data_table_default = DataTable;
1236
1390