@saptanshuwanjari/react-component-library 0.1.0 → 0.1.6
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/LICENSE +21 -21
- package/README.md +56 -56
- package/dist/index.js +144 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +115 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +61 -57
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as React2 from 'react';
|
|
1
2
|
import { createContext, memo, useState, useContext, useTransition, useEffect, useMemo } from 'react';
|
|
2
3
|
import { zodResolver } from '@hookform/resolvers/zod';
|
|
3
4
|
import { Controller, useForm } from 'react-hook-form';
|
|
@@ -6,7 +7,6 @@ import { Lock, EyeOff, Eye, ChevronDownIcon, Upload, X, Pencil, ArrowUp, ArrowDo
|
|
|
6
7
|
import { clsx } from 'clsx';
|
|
7
8
|
import { twMerge } from 'tailwind-merge';
|
|
8
9
|
import { useReactTable, getPaginationRowModel, getSortedRowModel, getFilteredRowModel, getCoreRowModel, flexRender } from '@tanstack/react-table';
|
|
9
|
-
import { Slot } from '@radix-ui/react-slot';
|
|
10
10
|
import { cva } from 'class-variance-authority';
|
|
11
11
|
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
12
12
|
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
@@ -651,6 +651,120 @@ function Input5({ className, type, ...props }) {
|
|
|
651
651
|
}
|
|
652
652
|
);
|
|
653
653
|
}
|
|
654
|
+
function setRef(ref, value) {
|
|
655
|
+
if (typeof ref === "function") {
|
|
656
|
+
return ref(value);
|
|
657
|
+
} else if (ref !== null && ref !== void 0) {
|
|
658
|
+
ref.current = value;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
function composeRefs(...refs) {
|
|
662
|
+
return (node) => {
|
|
663
|
+
let hasCleanup = false;
|
|
664
|
+
const cleanups = refs.map((ref) => {
|
|
665
|
+
const cleanup = setRef(ref, node);
|
|
666
|
+
if (!hasCleanup && typeof cleanup == "function") {
|
|
667
|
+
hasCleanup = true;
|
|
668
|
+
}
|
|
669
|
+
return cleanup;
|
|
670
|
+
});
|
|
671
|
+
if (hasCleanup) {
|
|
672
|
+
return () => {
|
|
673
|
+
for (let i = 0; i < cleanups.length; i++) {
|
|
674
|
+
const cleanup = cleanups[i];
|
|
675
|
+
if (typeof cleanup == "function") {
|
|
676
|
+
cleanup();
|
|
677
|
+
} else {
|
|
678
|
+
setRef(refs[i], null);
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
// @__NO_SIDE_EFFECTS__
|
|
686
|
+
function createSlot(ownerName) {
|
|
687
|
+
const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
|
|
688
|
+
const Slot2 = React2.forwardRef((props, forwardedRef) => {
|
|
689
|
+
const { children, ...slotProps } = props;
|
|
690
|
+
const childrenArray = React2.Children.toArray(children);
|
|
691
|
+
const slottable = childrenArray.find(isSlottable);
|
|
692
|
+
if (slottable) {
|
|
693
|
+
const newElement = slottable.props.children;
|
|
694
|
+
const newChildren = childrenArray.map((child) => {
|
|
695
|
+
if (child === slottable) {
|
|
696
|
+
if (React2.Children.count(newElement) > 1) return React2.Children.only(null);
|
|
697
|
+
return React2.isValidElement(newElement) ? newElement.props.children : null;
|
|
698
|
+
} else {
|
|
699
|
+
return child;
|
|
700
|
+
}
|
|
701
|
+
});
|
|
702
|
+
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React2.isValidElement(newElement) ? React2.cloneElement(newElement, void 0, newChildren) : null });
|
|
703
|
+
}
|
|
704
|
+
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
705
|
+
});
|
|
706
|
+
Slot2.displayName = `${ownerName}.Slot`;
|
|
707
|
+
return Slot2;
|
|
708
|
+
}
|
|
709
|
+
var Slot = /* @__PURE__ */ createSlot("Slot");
|
|
710
|
+
// @__NO_SIDE_EFFECTS__
|
|
711
|
+
function createSlotClone(ownerName) {
|
|
712
|
+
const SlotClone = React2.forwardRef((props, forwardedRef) => {
|
|
713
|
+
const { children, ...slotProps } = props;
|
|
714
|
+
if (React2.isValidElement(children)) {
|
|
715
|
+
const childrenRef = getElementRef(children);
|
|
716
|
+
const props2 = mergeProps(slotProps, children.props);
|
|
717
|
+
if (children.type !== React2.Fragment) {
|
|
718
|
+
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
719
|
+
}
|
|
720
|
+
return React2.cloneElement(children, props2);
|
|
721
|
+
}
|
|
722
|
+
return React2.Children.count(children) > 1 ? React2.Children.only(null) : null;
|
|
723
|
+
});
|
|
724
|
+
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
725
|
+
return SlotClone;
|
|
726
|
+
}
|
|
727
|
+
var SLOTTABLE_IDENTIFIER = /* @__PURE__ */ Symbol("radix.slottable");
|
|
728
|
+
function isSlottable(child) {
|
|
729
|
+
return React2.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
|
|
730
|
+
}
|
|
731
|
+
function mergeProps(slotProps, childProps) {
|
|
732
|
+
const overrideProps = { ...childProps };
|
|
733
|
+
for (const propName in childProps) {
|
|
734
|
+
const slotPropValue = slotProps[propName];
|
|
735
|
+
const childPropValue = childProps[propName];
|
|
736
|
+
const isHandler = /^on[A-Z]/.test(propName);
|
|
737
|
+
if (isHandler) {
|
|
738
|
+
if (slotPropValue && childPropValue) {
|
|
739
|
+
overrideProps[propName] = (...args) => {
|
|
740
|
+
const result = childPropValue(...args);
|
|
741
|
+
slotPropValue(...args);
|
|
742
|
+
return result;
|
|
743
|
+
};
|
|
744
|
+
} else if (slotPropValue) {
|
|
745
|
+
overrideProps[propName] = slotPropValue;
|
|
746
|
+
}
|
|
747
|
+
} else if (propName === "style") {
|
|
748
|
+
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
749
|
+
} else if (propName === "className") {
|
|
750
|
+
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
return { ...slotProps, ...overrideProps };
|
|
754
|
+
}
|
|
755
|
+
function getElementRef(element) {
|
|
756
|
+
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
|
|
757
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
758
|
+
if (mayWarn) {
|
|
759
|
+
return element.ref;
|
|
760
|
+
}
|
|
761
|
+
getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
|
|
762
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
763
|
+
if (mayWarn) {
|
|
764
|
+
return element.props.ref;
|
|
765
|
+
}
|
|
766
|
+
return element.props.ref || element.ref;
|
|
767
|
+
}
|
|
654
768
|
var buttonVariants = cva(
|
|
655
769
|
"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",
|
|
656
770
|
{
|