@vritti/quantum-ui 0.1.10 → 0.1.12
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/AuthProvider.d.ts +25 -2
- package/dist/Button.js +3 -43
- package/dist/Button.js.map +1 -1
- package/dist/Checkbox.d.ts +10 -1
- package/dist/Checkbox.js +35 -7
- package/dist/Checkbox.js.map +1 -1
- package/dist/Form.d.ts +21 -0
- package/dist/Form.js +662 -0
- package/dist/Form.js.map +1 -0
- package/dist/OTPField.d.ts +3 -3
- package/dist/OTPField.js +135 -0
- package/dist/OTPField.js.map +1 -0
- package/dist/OnboardingProvider.js +91 -0
- package/dist/OnboardingProvider.js.map +1 -0
- package/dist/PasswordField.d.ts +3 -3
- package/dist/PasswordField.js +63 -57
- package/dist/PasswordField.js.map +1 -1
- package/dist/PhoneField.d.ts +3 -3
- package/dist/PhoneField.js +55 -58
- package/dist/PhoneField.js.map +1 -1
- package/dist/TextArea.d.ts +11 -0
- package/dist/TextArea.js +54 -0
- package/dist/TextArea.js.map +1 -0
- package/dist/TextField.d.ts +3 -3
- package/dist/TextField.js +26 -39
- package/dist/TextField.js.map +1 -1
- package/dist/assets/quantum-ui.css +126 -1
- package/dist/components/Form.d.ts +2 -0
- package/dist/components/Form.js +2 -0
- package/dist/components/Form.js.map +1 -0
- package/dist/components/OTPField.js +1 -134
- package/dist/components/OTPField.js.map +1 -1
- package/dist/components/Progress.js +2 -2
- package/dist/components/TextArea.d.ts +2 -0
- package/dist/components/TextArea.js +2 -0
- package/dist/components/TextArea.js.map +1 -0
- package/dist/context/AuthProvider.d.ts +2 -7
- package/dist/context/AuthProvider.js +1 -1
- package/dist/field.js +431 -0
- package/dist/field.js.map +1 -0
- package/dist/index.d.ts +320 -27
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/index2.js +116 -54
- package/dist/index2.js.map +1 -1
- package/dist/index3.js +42 -38
- package/dist/index3.js.map +1 -1
- package/dist/index4.js +54 -116
- package/dist/index4.js.map +1 -1
- package/dist/index5.js +41 -0
- package/dist/index5.js.map +1 -0
- package/dist/shadcn/shadcnField.d.ts +1 -0
- package/dist/shadcn/shadcnField.js +2 -0
- package/dist/shadcn/shadcnField.js.map +1 -0
- package/dist/shadcnField.d.ts +1 -0
- package/package.json +21 -4
- package/dist/AuthProvider.js +0 -137
- package/dist/AuthProvider.js.map +0 -1
- package/dist/Label.js +0 -40
- package/dist/Label.js.map +0 -1
package/dist/index3.js
CHANGED
|
@@ -1,41 +1,45 @@
|
|
|
1
|
-
import
|
|
2
|
-
import 'react-dom';
|
|
3
|
-
import { c as createSlot } from './index4.js';
|
|
4
|
-
import { jsx } from 'react/jsx-runtime';
|
|
1
|
+
import { a as clsx } from './utils.js';
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
3
|
+
const falsyToString = (value)=>typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
|
|
4
|
+
const cx = clsx;
|
|
5
|
+
const cva = (base, config)=>(props)=>{
|
|
6
|
+
var _config_compoundVariants;
|
|
7
|
+
if ((config === null || config === void 0 ? void 0 : config.variants) == null) return cx(base, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
|
|
8
|
+
const { variants, defaultVariants } = config;
|
|
9
|
+
const getVariantClassNames = Object.keys(variants).map((variant)=>{
|
|
10
|
+
const variantProp = props === null || props === void 0 ? void 0 : props[variant];
|
|
11
|
+
const defaultVariantProp = defaultVariants === null || defaultVariants === void 0 ? void 0 : defaultVariants[variant];
|
|
12
|
+
if (variantProp === null) return null;
|
|
13
|
+
const variantKey = falsyToString(variantProp) || falsyToString(defaultVariantProp);
|
|
14
|
+
return variants[variant][variantKey];
|
|
15
|
+
});
|
|
16
|
+
const propsWithoutUndefined = props && Object.entries(props).reduce((acc, param)=>{
|
|
17
|
+
let [key, value] = param;
|
|
18
|
+
if (value === undefined) {
|
|
19
|
+
return acc;
|
|
20
|
+
}
|
|
21
|
+
acc[key] = value;
|
|
22
|
+
return acc;
|
|
23
|
+
}, {});
|
|
24
|
+
const getCompoundVariantClassNames = config === null || config === void 0 ? void 0 : (_config_compoundVariants = config.compoundVariants) === null || _config_compoundVariants === void 0 ? void 0 : _config_compoundVariants.reduce((acc, param)=>{
|
|
25
|
+
let { class: cvClass, className: cvClassName, ...compoundVariantOptions } = param;
|
|
26
|
+
return Object.entries(compoundVariantOptions).every((param)=>{
|
|
27
|
+
let [key, value] = param;
|
|
28
|
+
return Array.isArray(value) ? value.includes({
|
|
29
|
+
...defaultVariants,
|
|
30
|
+
...propsWithoutUndefined
|
|
31
|
+
}[key]) : ({
|
|
32
|
+
...defaultVariants,
|
|
33
|
+
...propsWithoutUndefined
|
|
34
|
+
})[key] === value;
|
|
35
|
+
}) ? [
|
|
36
|
+
...acc,
|
|
37
|
+
cvClass,
|
|
38
|
+
cvClassName
|
|
39
|
+
] : acc;
|
|
40
|
+
}, []);
|
|
41
|
+
return cx(base, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
|
|
42
|
+
};
|
|
39
43
|
|
|
40
|
-
export {
|
|
44
|
+
export { cva as c };
|
|
41
45
|
//# sourceMappingURL=index3.js.map
|
package/dist/index3.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index3.js","sources":["../node_modules
|
|
1
|
+
{"version":3,"file":"index3.js","sources":["../node_modules/class-variance-authority/dist/index.mjs"],"sourcesContent":["/**\n * Copyright 2022 Joe Bell. All rights reserved.\n *\n * This file is licensed to you under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with the\n * License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations under\n * the License.\n */ import { clsx } from \"clsx\";\nconst falsyToString = (value)=>typeof value === \"boolean\" ? `${value}` : value === 0 ? \"0\" : value;\nexport const cx = clsx;\nexport const cva = (base, config)=>(props)=>{\n var _config_compoundVariants;\n if ((config === null || config === void 0 ? void 0 : config.variants) == null) return cx(base, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);\n const { variants, defaultVariants } = config;\n const getVariantClassNames = Object.keys(variants).map((variant)=>{\n const variantProp = props === null || props === void 0 ? void 0 : props[variant];\n const defaultVariantProp = defaultVariants === null || defaultVariants === void 0 ? void 0 : defaultVariants[variant];\n if (variantProp === null) return null;\n const variantKey = falsyToString(variantProp) || falsyToString(defaultVariantProp);\n return variants[variant][variantKey];\n });\n const propsWithoutUndefined = props && Object.entries(props).reduce((acc, param)=>{\n let [key, value] = param;\n if (value === undefined) {\n return acc;\n }\n acc[key] = value;\n return acc;\n }, {});\n const getCompoundVariantClassNames = config === null || config === void 0 ? void 0 : (_config_compoundVariants = config.compoundVariants) === null || _config_compoundVariants === void 0 ? void 0 : _config_compoundVariants.reduce((acc, param)=>{\n let { class: cvClass, className: cvClassName, ...compoundVariantOptions } = param;\n return Object.entries(compoundVariantOptions).every((param)=>{\n let [key, value] = param;\n return Array.isArray(value) ? value.includes({\n ...defaultVariants,\n ...propsWithoutUndefined\n }[key]) : ({\n ...defaultVariants,\n ...propsWithoutUndefined\n })[key] === value;\n }) ? [\n ...acc,\n cvClass,\n cvClassName\n ] : acc;\n }, []);\n return cx(base, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);\n };\n\n"],"names":[],"mappings":";;AAeA,MAAM,aAAa,GAAG,CAAC,KAAK,GAAG,OAAO,KAAK,KAAK,SAAS,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG,GAAG,GAAG,KAAK;AAC3F,MAAM,EAAE,GAAG,IAAI;AACV,MAAC,GAAG,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,KAAK,GAAG;AAC5C,QAAQ,IAAI,wBAAwB;AACpC,QAAQ,IAAI,CAAC,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,QAAQ,KAAK,IAAI,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC;AAChO,QAAQ,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,GAAG,MAAM;AACpD,QAAQ,MAAM,oBAAoB,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,GAAG;AAC1E,YAAY,MAAM,WAAW,GAAG,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC;AAC5F,YAAY,MAAM,kBAAkB,GAAG,eAAe,KAAK,IAAI,IAAI,eAAe,KAAK,MAAM,GAAG,MAAM,GAAG,eAAe,CAAC,OAAO,CAAC;AACjI,YAAY,IAAI,WAAW,KAAK,IAAI,EAAE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AC,GAAG,CAAC,CAAC,GAAG,CAAC;AAC3B,oBAAoB,GAAG,eAAe;AACtC,oBAAoB,GAAG;AACvB,iBAAiB,EAAE,GAAG,CAAC,KAAK,KAAK;AACjC,YAAY,CAAC,CAAC,GAAG;AACjB,gBAAgB,GAAG,GAAG;AACtB,gBAAgB,OAAO;AACvB,gBAAgB;AAChB,aAAa,GAAG,GAAG;AACnB,QAAQ,CAAC,EAAE,EAAE,CAAC;AACd,QAAQ,OAAO,EAAE,CAAC,IAAI,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC;AACrM,IAAI;;;;","x_google_ignoreList":[0]}
|
package/dist/index4.js
CHANGED
|
@@ -1,126 +1,64 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
|
|
4
|
-
// packages/react/
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
// packages/react/context/src/create-context.tsx
|
|
5
|
+
function createContextScope(scopeName, createContextScopeDeps = []) {
|
|
6
|
+
let defaultContexts = [];
|
|
7
|
+
function createContext3(rootComponentName, defaultContext) {
|
|
8
|
+
const BaseContext = React.createContext(defaultContext);
|
|
9
|
+
const index = defaultContexts.length;
|
|
10
|
+
defaultContexts = [...defaultContexts, defaultContext];
|
|
11
|
+
const Provider = (props) => {
|
|
12
|
+
const { scope, children, ...context } = props;
|
|
13
|
+
const Context = scope?.[scopeName]?.[index] || BaseContext;
|
|
14
|
+
const value = React.useMemo(() => context, Object.values(context));
|
|
15
|
+
return /* @__PURE__ */ jsx(Context.Provider, { value, children });
|
|
16
|
+
};
|
|
17
|
+
Provider.displayName = rootComponentName + "Provider";
|
|
18
|
+
function useContext2(consumerName, scope) {
|
|
19
|
+
const Context = scope?.[scopeName]?.[index] || BaseContext;
|
|
20
|
+
const context = React.useContext(Context);
|
|
21
|
+
if (context) return context;
|
|
22
|
+
if (defaultContext !== void 0) return defaultContext;
|
|
23
|
+
throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
|
|
24
|
+
}
|
|
25
|
+
return [Provider, useContext2];
|
|
10
26
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
let hasCleanup = false;
|
|
15
|
-
const cleanups = refs.map((ref) => {
|
|
16
|
-
const cleanup = setRef(ref, node);
|
|
17
|
-
if (!hasCleanup && typeof cleanup == "function") {
|
|
18
|
-
hasCleanup = true;
|
|
19
|
-
}
|
|
20
|
-
return cleanup;
|
|
27
|
+
const createScope = () => {
|
|
28
|
+
const scopeContexts = defaultContexts.map((defaultContext) => {
|
|
29
|
+
return React.createContext(defaultContext);
|
|
21
30
|
});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
setRef(refs[i], null);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
}
|
|
31
|
+
return function useScope(scope) {
|
|
32
|
+
const contexts = scope?.[scopeName] || scopeContexts;
|
|
33
|
+
return React.useMemo(
|
|
34
|
+
() => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),
|
|
35
|
+
[scope, contexts]
|
|
36
|
+
);
|
|
37
|
+
};
|
|
34
38
|
};
|
|
39
|
+
createScope.scopeName = scopeName;
|
|
40
|
+
return [createContext3, composeContextScopes(createScope, ...createContextScopeDeps)];
|
|
35
41
|
}
|
|
36
|
-
function
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return child;
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React.isValidElement(newElement) ? React.cloneElement(newElement, void 0, newChildren) : null });
|
|
59
|
-
}
|
|
60
|
-
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
61
|
-
});
|
|
62
|
-
Slot2.displayName = `${ownerName}.Slot`;
|
|
63
|
-
return Slot2;
|
|
64
|
-
}
|
|
65
|
-
var Slot = /* @__PURE__ */ createSlot("Slot");
|
|
66
|
-
// @__NO_SIDE_EFFECTS__
|
|
67
|
-
function createSlotClone(ownerName) {
|
|
68
|
-
const SlotClone = React.forwardRef((props, forwardedRef) => {
|
|
69
|
-
const { children, ...slotProps } = props;
|
|
70
|
-
if (React.isValidElement(children)) {
|
|
71
|
-
const childrenRef = getElementRef(children);
|
|
72
|
-
const props2 = mergeProps(slotProps, children.props);
|
|
73
|
-
if (children.type !== React.Fragment) {
|
|
74
|
-
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
75
|
-
}
|
|
76
|
-
return React.cloneElement(children, props2);
|
|
77
|
-
}
|
|
78
|
-
return React.Children.count(children) > 1 ? React.Children.only(null) : null;
|
|
79
|
-
});
|
|
80
|
-
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
81
|
-
return SlotClone;
|
|
82
|
-
}
|
|
83
|
-
var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
|
|
84
|
-
function isSlottable(child) {
|
|
85
|
-
return React.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
|
|
86
|
-
}
|
|
87
|
-
function mergeProps(slotProps, childProps) {
|
|
88
|
-
const overrideProps = { ...childProps };
|
|
89
|
-
for (const propName in childProps) {
|
|
90
|
-
const slotPropValue = slotProps[propName];
|
|
91
|
-
const childPropValue = childProps[propName];
|
|
92
|
-
const isHandler = /^on[A-Z]/.test(propName);
|
|
93
|
-
if (isHandler) {
|
|
94
|
-
if (slotPropValue && childPropValue) {
|
|
95
|
-
overrideProps[propName] = (...args) => {
|
|
96
|
-
const result = childPropValue(...args);
|
|
97
|
-
slotPropValue(...args);
|
|
98
|
-
return result;
|
|
99
|
-
};
|
|
100
|
-
} else if (slotPropValue) {
|
|
101
|
-
overrideProps[propName] = slotPropValue;
|
|
102
|
-
}
|
|
103
|
-
} else if (propName === "style") {
|
|
104
|
-
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
105
|
-
} else if (propName === "className") {
|
|
106
|
-
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return { ...slotProps, ...overrideProps };
|
|
110
|
-
}
|
|
111
|
-
function getElementRef(element) {
|
|
112
|
-
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
|
|
113
|
-
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
114
|
-
if (mayWarn) {
|
|
115
|
-
return element.ref;
|
|
116
|
-
}
|
|
117
|
-
getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
|
|
118
|
-
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
119
|
-
if (mayWarn) {
|
|
120
|
-
return element.props.ref;
|
|
121
|
-
}
|
|
122
|
-
return element.props.ref || element.ref;
|
|
42
|
+
function composeContextScopes(...scopes) {
|
|
43
|
+
const baseScope = scopes[0];
|
|
44
|
+
if (scopes.length === 1) return baseScope;
|
|
45
|
+
const createScope = () => {
|
|
46
|
+
const scopeHooks = scopes.map((createScope2) => ({
|
|
47
|
+
useScope: createScope2(),
|
|
48
|
+
scopeName: createScope2.scopeName
|
|
49
|
+
}));
|
|
50
|
+
return function useComposedScopes(overrideScopes) {
|
|
51
|
+
const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {
|
|
52
|
+
const scopeProps = useScope(overrideScopes);
|
|
53
|
+
const currentScope = scopeProps[`__scope${scopeName}`];
|
|
54
|
+
return { ...nextScopes2, ...currentScope };
|
|
55
|
+
}, {});
|
|
56
|
+
return React.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
createScope.scopeName = baseScope.scopeName;
|
|
60
|
+
return createScope;
|
|
123
61
|
}
|
|
124
62
|
|
|
125
|
-
export {
|
|
63
|
+
export { createContextScope as c };
|
|
126
64
|
//# sourceMappingURL=index4.js.map
|
package/dist/index4.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index4.js","sources":["../node_modules/@radix-ui/react-compose-refs/dist/index.mjs","../node_modules/@radix-ui/react-slot/dist/index.mjs"],"sourcesContent":["// packages/react/compose-refs/src/compose-refs.tsx\nimport * as React from \"react\";\nfunction setRef(ref, value) {\n if (typeof ref === \"function\") {\n return ref(value);\n } else if (ref !== null && ref !== void 0) {\n ref.current = value;\n }\n}\nfunction composeRefs(...refs) {\n return (node) => {\n let hasCleanup = false;\n const cleanups = refs.map((ref) => {\n const cleanup = setRef(ref, node);\n if (!hasCleanup && typeof cleanup == \"function\") {\n hasCleanup = true;\n }\n return cleanup;\n });\n if (hasCleanup) {\n return () => {\n for (let i = 0; i < cleanups.length; i++) {\n const cleanup = cleanups[i];\n if (typeof cleanup == \"function\") {\n cleanup();\n } else {\n setRef(refs[i], null);\n }\n }\n };\n }\n };\n}\nfunction useComposedRefs(...refs) {\n return React.useCallback(composeRefs(...refs), refs);\n}\nexport {\n composeRefs,\n useComposedRefs\n};\n//# sourceMappingURL=index.mjs.map\n","// src/slot.tsx\nimport * as React from \"react\";\nimport { composeRefs } from \"@radix-ui/react-compose-refs\";\nimport { Fragment as Fragment2, jsx } from \"react/jsx-runtime\";\n// @__NO_SIDE_EFFECTS__\nfunction createSlot(ownerName) {\n const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);\n const Slot2 = React.forwardRef((props, forwardedRef) => {\n const { children, ...slotProps } = props;\n const childrenArray = React.Children.toArray(children);\n const slottable = childrenArray.find(isSlottable);\n if (slottable) {\n const newElement = slottable.props.children;\n const newChildren = childrenArray.map((child) => {\n if (child === slottable) {\n if (React.Children.count(newElement) > 1) return React.Children.only(null);\n return React.isValidElement(newElement) ? newElement.props.children : null;\n } else {\n return child;\n }\n });\n return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React.isValidElement(newElement) ? React.cloneElement(newElement, void 0, newChildren) : null });\n }\n return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });\n });\n Slot2.displayName = `${ownerName}.Slot`;\n return Slot2;\n}\nvar Slot = /* @__PURE__ */ createSlot(\"Slot\");\n// @__NO_SIDE_EFFECTS__\nfunction createSlotClone(ownerName) {\n const SlotClone = React.forwardRef((props, forwardedRef) => {\n const { children, ...slotProps } = props;\n if (React.isValidElement(children)) {\n const childrenRef = getElementRef(children);\n const props2 = mergeProps(slotProps, children.props);\n if (children.type !== React.Fragment) {\n props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;\n }\n return React.cloneElement(children, props2);\n }\n return React.Children.count(children) > 1 ? React.Children.only(null) : null;\n });\n SlotClone.displayName = `${ownerName}.SlotClone`;\n return SlotClone;\n}\nvar SLOTTABLE_IDENTIFIER = Symbol(\"radix.slottable\");\n// @__NO_SIDE_EFFECTS__\nfunction createSlottable(ownerName) {\n const Slottable2 = ({ children }) => {\n return /* @__PURE__ */ jsx(Fragment2, { children });\n };\n Slottable2.displayName = `${ownerName}.Slottable`;\n Slottable2.__radixId = SLOTTABLE_IDENTIFIER;\n return Slottable2;\n}\nvar Slottable = /* @__PURE__ */ createSlottable(\"Slottable\");\nfunction isSlottable(child) {\n return React.isValidElement(child) && typeof child.type === \"function\" && \"__radixId\" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;\n}\nfunction mergeProps(slotProps, childProps) {\n const overrideProps = { ...childProps };\n for (const propName in childProps) {\n const slotPropValue = slotProps[propName];\n const childPropValue = childProps[propName];\n const isHandler = /^on[A-Z]/.test(propName);\n if (isHandler) {\n if (slotPropValue && childPropValue) {\n overrideProps[propName] = (...args) => {\n const result = childPropValue(...args);\n slotPropValue(...args);\n return result;\n };\n } else if (slotPropValue) {\n overrideProps[propName] = slotPropValue;\n }\n } else if (propName === \"style\") {\n overrideProps[propName] = { ...slotPropValue, ...childPropValue };\n } else if (propName === \"className\") {\n overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(\" \");\n }\n }\n return { ...slotProps, ...overrideProps };\n}\nfunction getElementRef(element) {\n let getter = Object.getOwnPropertyDescriptor(element.props, \"ref\")?.get;\n let mayWarn = getter && \"isReactWarning\" in getter && getter.isReactWarning;\n if (mayWarn) {\n return element.ref;\n }\n getter = Object.getOwnPropertyDescriptor(element, \"ref\")?.get;\n mayWarn = getter && \"isReactWarning\" in getter && getter.isReactWarning;\n if (mayWarn) {\n return element.props.ref;\n }\n return element.props.ref || element.ref;\n}\nexport {\n Slot as Root,\n Slot,\n Slottable,\n createSlot,\n createSlottable\n};\n//# sourceMappingURL=index.mjs.map\n"],"names":[],"mappings":";;;AAAA;AAEA,SAAS,MAAM,CAAC,GAAG,EAAE,KAAK,EAAE;AAC5B,EAAE,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE;AACjC,IAAI,OAAO,GAAG,CAAC,KAAK,CAAC;AACrB,EAAE,CAAC,MAAM,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,MAAM,EAAE;AAC7C,IAAI,GAAG,CAAC,OAAO,GAAG,KAAK;AACvB,EAAE;AACF;AACA,SAAS,WAAW,CAAC,GAAG,IAAI,EAAE;AAC9B,EAAE,OAAO,CAAC,IAAI,KAAK;AACnB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AAI,MAAM,IAAI,MAAM,CAAC,cAAc;AAC7E,EAAE,IAAI,OAAO,EAAE;AACf,IAAI,OAAO,OAAO,CAAC,GAAG;AACtB,EAAE;AACF,EAAE,MAAM,GAAG,MAAM,CAAC,wBAAwB,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,GAAG;AAC/D,EAAE,OAAO,GAAG,MAAM,IAAI,gBAAgB,IAAI,MAAM,IAAI,MAAM,CAAC,cAAc;AACzE,EAAE,IAAI,OAAO,EAAE;AACf,IAAI,OAAO,OAAO,CAAC,KAAK,CAAC,GAAG;AAC5B,EAAE;AACF,EAAE,OAAO,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG;AACzC;;;;","x_google_ignoreList":[0,1]}
|
|
1
|
+
{"version":3,"file":"index4.js","sources":["../node_modules/@radix-ui/react-context/dist/index.mjs"],"sourcesContent":["// packages/react/context/src/create-context.tsx\nimport * as React from \"react\";\nimport { jsx } from \"react/jsx-runtime\";\nfunction createContext2(rootComponentName, defaultContext) {\n const Context = React.createContext(defaultContext);\n const Provider = (props) => {\n const { children, ...context } = props;\n const value = React.useMemo(() => context, Object.values(context));\n return /* @__PURE__ */ jsx(Context.Provider, { value, children });\n };\n Provider.displayName = rootComponentName + \"Provider\";\n function useContext2(consumerName) {\n const context = React.useContext(Context);\n if (context) return context;\n if (defaultContext !== void 0) return defaultContext;\n throw new Error(`\\`${consumerName}\\` must be used within \\`${rootComponentName}\\``);\n }\n return [Provider, useContext2];\n}\nfunction createContextScope(scopeName, createContextScopeDeps = []) {\n let defaultContexts = [];\n function createContext3(rootComponentName, defaultContext) {\n const BaseContext = React.createContext(defaultContext);\n const index = defaultContexts.length;\n defaultContexts = [...defaultContexts, defaultContext];\n const Provider = (props) => {\n const { scope, children, ...context } = props;\n const Context = scope?.[scopeName]?.[index] || BaseContext;\n const value = React.useMemo(() => context, Object.values(context));\n return /* @__PURE__ */ jsx(Context.Provider, { value, children });\n };\n Provider.displayName = rootComponentName + \"Provider\";\n function useContext2(consumerName, scope) {\n const Context = scope?.[scopeName]?.[index] || BaseContext;\n const context = React.useContext(Context);\n if (context) return context;\n if (defaultContext !== void 0) return defaultContext;\n throw new Error(`\\`${consumerName}\\` must be used within \\`${rootComponentName}\\``);\n }\n return [Provider, useContext2];\n }\n const createScope = () => {\n const scopeContexts = defaultContexts.map((defaultContext) => {\n return React.createContext(defaultContext);\n });\n return function useScope(scope) {\n const contexts = scope?.[scopeName] || scopeContexts;\n return React.useMemo(\n () => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),\n [scope, contexts]\n );\n };\n };\n createScope.scopeName = scopeName;\n return [createContext3, composeContextScopes(createScope, ...createContextScopeDeps)];\n}\nfunction composeContextScopes(...scopes) {\n const baseScope = scopes[0];\n if (scopes.length === 1) return baseScope;\n const createScope = () => {\n const scopeHooks = scopes.map((createScope2) => ({\n useScope: createScope2(),\n scopeName: createScope2.scopeName\n }));\n return function useComposedScopes(overrideScopes) {\n const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {\n const scopeProps = useScope(overrideScopes);\n const currentScope = scopeProps[`__scope${scopeName}`];\n return { ...nextScopes2, ...currentScope };\n }, {});\n return React.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);\n };\n };\n createScope.scopeName = baseScope.scopeName;\n return createScope;\n}\nexport {\n createContext2 as createContext,\n createContextScope\n};\n//# sourceMappingURL=index.mjs.map\n"],"names":[],"mappings":";;;AAAA;AAmBA,SAAS,kBAAkB,CAAC,SAAS,EAAE,sBAAsB,GAAG,EAAE,EAAE;AACpE,EAAE,IAAI,eAAe,GAAG,EAAE;AAC1B,EAAE,SAAS,cAAc,CAAC,iBAAiB,EAAE,cAAc,EAAE;AAC7D,IAAI,MAAM,WAAW,GAAG,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC;AAC3D,IAAI,MAAM,KAAK,GAAG,eAAe,CAAC,MAAM;AACxC,IAAI,eAAe,G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EAAE;AAClD,MAAM,CAAC,EAAE,EAAE,CAAC;AACZ,MAAM,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC,GAAG,UAAU,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC;AACnG,IAAI,CAAC;AACL,EAAE,CAAC;AACH,EAAE,WAAW,CAAC,SAAS,GAAG,SAAS,CAAC,SAAS;AAC7C,EAAE,OAAO,WAAW;AACpB;;;;","x_google_ignoreList":[0]}
|
package/dist/index5.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import 'react-dom';
|
|
3
|
+
import { c as createSlot } from './index2.js';
|
|
4
|
+
import { jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
// src/primitive.tsx
|
|
7
|
+
var NODES = [
|
|
8
|
+
"a",
|
|
9
|
+
"button",
|
|
10
|
+
"div",
|
|
11
|
+
"form",
|
|
12
|
+
"h2",
|
|
13
|
+
"h3",
|
|
14
|
+
"img",
|
|
15
|
+
"input",
|
|
16
|
+
"label",
|
|
17
|
+
"li",
|
|
18
|
+
"nav",
|
|
19
|
+
"ol",
|
|
20
|
+
"p",
|
|
21
|
+
"select",
|
|
22
|
+
"span",
|
|
23
|
+
"svg",
|
|
24
|
+
"ul"
|
|
25
|
+
];
|
|
26
|
+
var Primitive = NODES.reduce((primitive, node) => {
|
|
27
|
+
const Slot = createSlot(`Primitive.${node}`);
|
|
28
|
+
const Node = React.forwardRef((props, forwardedRef) => {
|
|
29
|
+
const { asChild, ...primitiveProps } = props;
|
|
30
|
+
const Comp = asChild ? Slot : node;
|
|
31
|
+
if (typeof window !== "undefined") {
|
|
32
|
+
window[Symbol.for("radix-ui")] = true;
|
|
33
|
+
}
|
|
34
|
+
return /* @__PURE__ */ jsx(Comp, { ...primitiveProps, ref: forwardedRef });
|
|
35
|
+
});
|
|
36
|
+
Node.displayName = `Primitive.${node}`;
|
|
37
|
+
return { ...primitive, [node]: Node };
|
|
38
|
+
}, {});
|
|
39
|
+
|
|
40
|
+
export { Primitive as P };
|
|
41
|
+
//# sourceMappingURL=index5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index5.js","sources":["../node_modules/@radix-ui/react-primitive/dist/index.mjs"],"sourcesContent":["// src/primitive.tsx\nimport * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { createSlot } from \"@radix-ui/react-slot\";\nimport { jsx } from \"react/jsx-runtime\";\nvar NODES = [\n \"a\",\n \"button\",\n \"div\",\n \"form\",\n \"h2\",\n \"h3\",\n \"img\",\n \"input\",\n \"label\",\n \"li\",\n \"nav\",\n \"ol\",\n \"p\",\n \"select\",\n \"span\",\n \"svg\",\n \"ul\"\n];\nvar Primitive = NODES.reduce((primitive, node) => {\n const Slot = createSlot(`Primitive.${node}`);\n const Node = React.forwardRef((props, forwardedRef) => {\n const { asChild, ...primitiveProps } = props;\n const Comp = asChild ? Slot : node;\n if (typeof window !== \"undefined\") {\n window[Symbol.for(\"radix-ui\")] = true;\n }\n return /* @__PURE__ */ jsx(Comp, { ...primitiveProps, ref: forwardedRef });\n });\n Node.displayName = `Primitive.${node}`;\n return { ...primitive, [node]: Node };\n}, {});\nfunction dispatchDiscreteCustomEvent(target, event) {\n if (target) ReactDOM.flushSync(() => target.dispatchEvent(event));\n}\nvar Root = Primitive;\nexport {\n Primitive,\n Root,\n dispatchDiscreteCustomEvent\n};\n//# sourceMappingURL=index.mjs.map\n"],"names":[],"mappings":";;;;;AAAA;AAKA,IAAI,KAAK,GAAG;AACZ,EAAE,GAAG;AACL,EAAE,QAAQ;AACV,EAAE,KAAK;AACP,EAAE,MAAM;AACR,EAAE,IAAI;AACN,EAAE,IAAI;AACN,EAAE,KAAK;AACP,EAAE,OAAO;AACT,EAAE,OAAO;AACT,EAAE,IAAI;AACN,EAAE,KAAK;AACP,EAAE,IAAI;AACN,EAAE,GAAG;AACL,EAAE,QAAQ;AACV,EAAE,MAAM;AACR,EAAE,KAAK;AACP,EAAE;AACF,CAAC;AACE,IAAC,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,IAAI,KAAK;AAClD,EAAE,MAAM,IAAI,GAAG,UAAU,CAAC,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC;AAC9C,EAAE,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,YAAY,KAAK;AACzD,IAAI,MAAM,EAAE,OAAO,EAAE,GAAG,cAAc,EAAE,GAAG,KAAK;AAChD,IAAI,MAAM,IAAI,GAAG,OAAO,GAAG,IAAI,GAAG,IAAI;AACtC,IAAI,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;AACvC,MAAM,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,GAAG,IAAI;AAC3C,IAAI;AACJ,IAAI,uBAAuB,GAAG,CAAC,IAAI,EAAE,EAAE,GAAG,cAAc,EAAE,GAAG,EAAE,YAAY,EAAE,CAAC;AAC9E,EAAE,CAAC,CAAC;AACJ,EAAE,IAAI,CAAC,WAAW,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;AACxC,EAAE,OAAO,EAAE,GAAG,SAAS,EAAE,CAAC,IAAI,GAAG,IAAI,EAAE;AACvC,CAAC,EAAE,EAAE;;;;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shadcnField.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { }
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vritti/quantum-ui",
|
|
3
|
-
"description": "A modern, TypeScript-first React component library built on Radix UI primitives and styled with Tailwind CSS v4. Fully typed, accessible, and tree-shakeable components including
|
|
3
|
+
"description": "A modern, TypeScript-first React component library built on Radix UI primitives and styled with Tailwind CSS v4. Features a powerful Field system and smart Form component with react-hook-form integration. Fully typed, accessible, and tree-shakeable components including TextField, TextArea, PhoneField, PasswordField, OTPField, Checkbox, Form, and more.",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
|
-
"version": "0.1.
|
|
8
|
+
"version": "0.1.12",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"sideEffects": false,
|
|
11
11
|
"repository": {
|
|
@@ -76,6 +76,18 @@
|
|
|
76
76
|
"types": "./dist/OTPField.d.ts",
|
|
77
77
|
"import": "./dist/components/OTPField.js"
|
|
78
78
|
},
|
|
79
|
+
"./TextArea": {
|
|
80
|
+
"types": "./dist/TextArea.d.ts",
|
|
81
|
+
"import": "./dist/components/TextArea.js"
|
|
82
|
+
},
|
|
83
|
+
"./Form": {
|
|
84
|
+
"types": "./dist/Form.d.ts",
|
|
85
|
+
"import": "./dist/components/Form.js"
|
|
86
|
+
},
|
|
87
|
+
"./Field": {
|
|
88
|
+
"types": "./dist/Field.d.ts",
|
|
89
|
+
"import": "./dist/shadcn/shadcnField.js"
|
|
90
|
+
},
|
|
79
91
|
"./axios": {
|
|
80
92
|
"types": "./dist/axios.d.ts",
|
|
81
93
|
"import": "./dist/utils/axios.js"
|
|
@@ -84,7 +96,7 @@
|
|
|
84
96
|
"types": "./dist/AuthProvider.d.ts",
|
|
85
97
|
"import": "./dist/context/AuthProvider.js"
|
|
86
98
|
},
|
|
87
|
-
"./
|
|
99
|
+
"./index.css": "./dist/assets/quantum-ui.css"
|
|
88
100
|
},
|
|
89
101
|
"files": [
|
|
90
102
|
"dist"
|
|
@@ -135,9 +147,12 @@
|
|
|
135
147
|
"vite-plugin-dts": "^4.5.4"
|
|
136
148
|
},
|
|
137
149
|
"dependencies": {
|
|
150
|
+
"@hookform/resolvers": "^5.2.2",
|
|
138
151
|
"@radix-ui/react-checkbox": "^1.3.3",
|
|
139
152
|
"@radix-ui/react-label": "^2.1.7",
|
|
140
153
|
"@radix-ui/react-progress": "^1.1.7",
|
|
154
|
+
"@radix-ui/react-select": "^2.2.6",
|
|
155
|
+
"@radix-ui/react-separator": "^1.1.8",
|
|
141
156
|
"@radix-ui/react-slot": "^1.2.3",
|
|
142
157
|
"@tailwindcss/vite": "^4.1.13",
|
|
143
158
|
"axios": "^1.12.2",
|
|
@@ -145,7 +160,9 @@
|
|
|
145
160
|
"clsx": "^2.1.1",
|
|
146
161
|
"input-otp": "^1.4.2",
|
|
147
162
|
"lucide-react": "^0.544.0",
|
|
163
|
+
"react-hook-form": "^7.66.0",
|
|
148
164
|
"react-phone-number-input": "^3.4.12",
|
|
149
|
-
"tailwind-merge": "^3.3.1"
|
|
165
|
+
"tailwind-merge": "^3.3.1",
|
|
166
|
+
"zod": "^4.1.12"
|
|
150
167
|
}
|
|
151
168
|
}
|
package/dist/AuthProvider.js
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import { createContext, useContext, useState, useRef, useCallback, useEffect } from 'react';
|
|
3
|
-
import { useNavigate } from 'react-router-dom';
|
|
4
|
-
import { axios } from './utils/axios.js';
|
|
5
|
-
|
|
6
|
-
const AuthContext = createContext(void 0);
|
|
7
|
-
const useAuth = () => {
|
|
8
|
-
const context = useContext(AuthContext);
|
|
9
|
-
if (!context) {
|
|
10
|
-
throw new Error("useAuth must be used within an AuthProvider");
|
|
11
|
-
}
|
|
12
|
-
return context;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const TOKEN_REFRESH_INTERVAL = 15 * 60 * 1e3;
|
|
16
|
-
const AuthProvider = ({ children }) => {
|
|
17
|
-
const [accessToken, setAccessToken] = useState(null);
|
|
18
|
-
const [isAuthenticated, setIsAuthenticated] = useState(false);
|
|
19
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
20
|
-
const [error, setError] = useState(null);
|
|
21
|
-
const navigate = useNavigate();
|
|
22
|
-
const refreshTimerRef = useRef(null);
|
|
23
|
-
const isRefreshingRef = useRef(false);
|
|
24
|
-
const refreshToken = useCallback(async () => {
|
|
25
|
-
if (isRefreshingRef.current) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
try {
|
|
29
|
-
isRefreshingRef.current = true;
|
|
30
|
-
setError(null);
|
|
31
|
-
const response = await axios.get("/auth/refresh-application");
|
|
32
|
-
const { accessToken: newToken } = response.data;
|
|
33
|
-
if (newToken) {
|
|
34
|
-
setAccessToken(newToken);
|
|
35
|
-
setIsAuthenticated(true);
|
|
36
|
-
} else {
|
|
37
|
-
throw new Error("No access token received");
|
|
38
|
-
}
|
|
39
|
-
} catch (err) {
|
|
40
|
-
console.error("Token refresh failed:", err);
|
|
41
|
-
setError("Authentication failed");
|
|
42
|
-
setAccessToken(null);
|
|
43
|
-
setIsAuthenticated(false);
|
|
44
|
-
navigate("/login", { replace: true });
|
|
45
|
-
} finally {
|
|
46
|
-
isRefreshingRef.current = false;
|
|
47
|
-
setIsLoading(false);
|
|
48
|
-
}
|
|
49
|
-
}, [navigate]);
|
|
50
|
-
const setToken = useCallback((token) => {
|
|
51
|
-
setAccessToken(token);
|
|
52
|
-
setIsAuthenticated(true);
|
|
53
|
-
}, []);
|
|
54
|
-
const logout = useCallback(() => {
|
|
55
|
-
setAccessToken(null);
|
|
56
|
-
setIsAuthenticated(false);
|
|
57
|
-
setError(null);
|
|
58
|
-
if (refreshTimerRef.current) {
|
|
59
|
-
clearInterval(refreshTimerRef.current);
|
|
60
|
-
refreshTimerRef.current = null;
|
|
61
|
-
}
|
|
62
|
-
navigate("/login", { replace: true });
|
|
63
|
-
}, [navigate]);
|
|
64
|
-
useEffect(() => {
|
|
65
|
-
refreshToken();
|
|
66
|
-
}, [refreshToken]);
|
|
67
|
-
useEffect(() => {
|
|
68
|
-
if (isAuthenticated && accessToken) {
|
|
69
|
-
if (refreshTimerRef.current) {
|
|
70
|
-
clearInterval(refreshTimerRef.current);
|
|
71
|
-
}
|
|
72
|
-
refreshTimerRef.current = setInterval(() => {
|
|
73
|
-
refreshToken();
|
|
74
|
-
}, TOKEN_REFRESH_INTERVAL);
|
|
75
|
-
}
|
|
76
|
-
return () => {
|
|
77
|
-
if (refreshTimerRef.current) {
|
|
78
|
-
clearInterval(refreshTimerRef.current);
|
|
79
|
-
refreshTimerRef.current = null;
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
}, [isAuthenticated, accessToken, refreshToken]);
|
|
83
|
-
useEffect(() => {
|
|
84
|
-
const requestInterceptor = axios.interceptors.request.use(
|
|
85
|
-
(config) => {
|
|
86
|
-
if (accessToken && config.headers) {
|
|
87
|
-
config.headers.Authorization = `Bearer ${accessToken}`;
|
|
88
|
-
}
|
|
89
|
-
return config;
|
|
90
|
-
},
|
|
91
|
-
(error2) => Promise.reject(error2)
|
|
92
|
-
);
|
|
93
|
-
const responseInterceptor = axios.interceptors.response.use(
|
|
94
|
-
(response) => response,
|
|
95
|
-
async (error2) => {
|
|
96
|
-
const originalRequest = error2.config;
|
|
97
|
-
if (error2.response?.status === 401 && !originalRequest._retry) {
|
|
98
|
-
originalRequest._retry = true;
|
|
99
|
-
try {
|
|
100
|
-
await refreshToken();
|
|
101
|
-
if (accessToken && originalRequest.headers) {
|
|
102
|
-
originalRequest.headers.Authorization = `Bearer ${accessToken}`;
|
|
103
|
-
}
|
|
104
|
-
return axios(originalRequest);
|
|
105
|
-
} catch (refreshError) {
|
|
106
|
-
logout();
|
|
107
|
-
return Promise.reject(refreshError);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
return Promise.reject(error2);
|
|
111
|
-
}
|
|
112
|
-
);
|
|
113
|
-
return () => {
|
|
114
|
-
axios.interceptors.request.eject(requestInterceptor);
|
|
115
|
-
axios.interceptors.response.eject(responseInterceptor);
|
|
116
|
-
};
|
|
117
|
-
}, [accessToken, refreshToken, logout]);
|
|
118
|
-
const value = {
|
|
119
|
-
accessToken,
|
|
120
|
-
isAuthenticated,
|
|
121
|
-
isLoading,
|
|
122
|
-
error,
|
|
123
|
-
refreshToken,
|
|
124
|
-
logout,
|
|
125
|
-
setToken
|
|
126
|
-
};
|
|
127
|
-
if (isLoading) {
|
|
128
|
-
return /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center min-h-screen", children: /* @__PURE__ */ jsxs("div", { className: "text-center space-y-4", children: [
|
|
129
|
-
/* @__PURE__ */ jsx("div", { className: "animate-spin rounded-full h-12 w-12 border-b-2 border-primary mx-auto" }),
|
|
130
|
-
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: "Loading..." })
|
|
131
|
-
] }) });
|
|
132
|
-
}
|
|
133
|
-
return /* @__PURE__ */ jsx(AuthContext.Provider, { value, children });
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
export { AuthContext as A, AuthProvider as a, useAuth as u };
|
|
137
|
-
//# sourceMappingURL=AuthProvider.js.map
|
package/dist/AuthProvider.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AuthProvider.js","sources":["../lib/context/AuthContext.tsx","../lib/context/AuthProvider.tsx"],"sourcesContent":["import { createContext, useContext } from 'react';\n\nexport interface AuthContextType {\n accessToken: string | null;\n isAuthenticated: boolean;\n isLoading: boolean;\n error: string | null;\n refreshToken: () => Promise<void>;\n logout: () => void;\n setToken: (token: string) => void;\n}\n\nexport const AuthContext = createContext<AuthContextType | undefined>(undefined);\n\nexport const useAuth = (): AuthContextType => {\n const context = useContext(AuthContext);\n if (!context) {\n throw new Error('useAuth must be used within an AuthProvider');\n }\n return context;\n};\n","import React, { useEffect, useState, useCallback, useRef } from 'react';\nimport { useNavigate } from 'react-router-dom';\nimport { AuthContext, type AuthContextType } from './AuthContext';\nimport { axios } from '../utils/axios';\nimport type { AxiosError, InternalAxiosRequestConfig } from 'axios';\n\ninterface AuthProviderProps {\n children: React.ReactNode;\n}\n\ninterface RefreshResponse {\n accessToken: string;\n}\n\nconst TOKEN_REFRESH_INTERVAL = 15 * 60 * 1000; // 15 minutes in milliseconds\n\nexport const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {\n const [accessToken, setAccessToken] = useState<string | null>(null);\n const [isAuthenticated, setIsAuthenticated] = useState(false);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<string | null>(null);\n const navigate = useNavigate();\n\n const refreshTimerRef = useRef<NodeJS.Timeout | null>(null);\n const isRefreshingRef = useRef(false);\n\n // Fetch and set token\n const refreshToken = useCallback(async () => {\n // Prevent multiple simultaneous refresh attempts\n if (isRefreshingRef.current) {\n return;\n }\n\n try {\n isRefreshingRef.current = true;\n setError(null);\n\n const response = await axios.get<RefreshResponse>('/auth/refresh-application');\n\n const { accessToken: newToken } = response.data;\n\n if (newToken) {\n setAccessToken(newToken);\n setIsAuthenticated(true);\n } else {\n throw new Error('No access token received');\n }\n } catch (err) {\n console.error('Token refresh failed:', err);\n setError('Authentication failed');\n setAccessToken(null);\n setIsAuthenticated(false);\n\n // Redirect to login on failure\n navigate('/login', { replace: true });\n } finally {\n isRefreshingRef.current = false;\n setIsLoading(false);\n }\n }, [navigate]);\n\n // Set token manually\n const setToken = useCallback((token: string) => {\n setAccessToken(token);\n setIsAuthenticated(true);\n }, []);\n\n // Logout function\n const logout = useCallback(() => {\n setAccessToken(null);\n setIsAuthenticated(false);\n setError(null);\n\n // Clear refresh timer\n if (refreshTimerRef.current) {\n clearInterval(refreshTimerRef.current);\n refreshTimerRef.current = null;\n }\n\n navigate('/login', { replace: true });\n }, [navigate]);\n\n // Initial token fetch on mount\n useEffect(() => {\n refreshToken();\n }, [refreshToken]);\n\n // Set up periodic token refresh\n useEffect(() => {\n if (isAuthenticated && accessToken) {\n // Clear any existing timer\n if (refreshTimerRef.current) {\n clearInterval(refreshTimerRef.current);\n }\n\n // Set up new refresh timer\n refreshTimerRef.current = setInterval(() => {\n refreshToken();\n }, TOKEN_REFRESH_INTERVAL);\n }\n\n // Cleanup on unmount or when auth state changes\n return () => {\n if (refreshTimerRef.current) {\n clearInterval(refreshTimerRef.current);\n refreshTimerRef.current = null;\n }\n };\n }, [isAuthenticated, accessToken, refreshToken]);\n\n // Set up axios interceptors\n useEffect(() => {\n // Request interceptor - Add authorization header\n const requestInterceptor = axios.interceptors.request.use(\n (config: InternalAxiosRequestConfig) => {\n if (accessToken && config.headers) {\n config.headers.Authorization = `Bearer ${accessToken}`;\n }\n return config;\n },\n (error) => Promise.reject(error)\n );\n\n // Response interceptor - Handle 401 errors\n const responseInterceptor = axios.interceptors.response.use(\n (response) => response,\n async (error: AxiosError) => {\n const originalRequest = error.config as InternalAxiosRequestConfig & { _retry?: boolean };\n\n // If 401 error and not already retried\n if (error.response?.status === 401 && !originalRequest._retry) {\n originalRequest._retry = true;\n\n try {\n // Try to refresh token\n await refreshToken();\n\n // Retry original request with new token\n if (accessToken && originalRequest.headers) {\n originalRequest.headers.Authorization = `Bearer ${accessToken}`;\n }\n\n return axios(originalRequest);\n } catch (refreshError) {\n // Refresh failed, logout user\n logout();\n return Promise.reject(refreshError);\n }\n }\n\n return Promise.reject(error);\n }\n );\n\n // Cleanup interceptors on unmount\n return () => {\n axios.interceptors.request.eject(requestInterceptor);\n axios.interceptors.response.eject(responseInterceptor);\n };\n }, [accessToken, refreshToken, logout]);\n\n const value: AuthContextType = {\n accessToken,\n isAuthenticated,\n isLoading,\n error,\n refreshToken,\n logout,\n setToken,\n };\n\n // Show loading state during initial authentication\n if (isLoading) {\n return (\n <div className=\"flex items-center justify-center min-h-screen\">\n <div className=\"text-center space-y-4\">\n <div className=\"animate-spin rounded-full h-12 w-12 border-b-2 border-primary mx-auto\"></div>\n <p className=\"text-muted-foreground\">Loading...</p>\n </div>\n </div>\n );\n }\n\n return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;\n};\n"],"names":["error"],"mappings":";;;;;AAYO,MAAM,WAAA,GAAc,c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