@vritti/quantum-ui 0.1.22 → 0.1.23
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/Checkbox.js +2 -253
- package/dist/Checkbox.js.map +1 -1
- package/dist/Combination.js +3869 -0
- package/dist/Combination.js.map +1 -0
- package/dist/DataTable.d.ts +31 -0
- package/dist/DataTable.js +4989 -0
- package/dist/DataTable.js.map +1 -0
- package/dist/DatePicker.d.ts +68 -0
- package/dist/DatePicker.js +8229 -0
- package/dist/DatePicker.js.map +1 -0
- package/dist/Input.js +22 -0
- package/dist/Input.js.map +1 -0
- package/dist/Label.js +40 -0
- package/dist/Label.js.map +1 -0
- package/dist/Skeleton.d.ts +6 -0
- package/dist/Skeleton.js +18 -0
- package/dist/Skeleton.js.map +1 -0
- package/dist/TextField.js +2 -18
- package/dist/TextField.js.map +1 -1
- package/dist/assets/quantum-ui.css +22 -16
- package/dist/axios.d.ts +11 -6
- package/dist/axios.js +191 -147
- package/dist/axios.js.map +1 -1
- package/dist/check.js +15 -0
- package/dist/check.js.map +1 -0
- package/dist/components/Button.d.ts +7 -0
- package/dist/components/Card.d.ts +7 -0
- package/dist/components/Checkbox.d.ts +7 -0
- package/dist/components/DataTable.d.ts +9 -0
- package/dist/components/DataTable.js +2 -0
- package/dist/components/DataTable.js.map +1 -0
- package/dist/components/DatePicker.d.ts +9 -0
- package/dist/components/DatePicker.js +2 -0
- package/dist/components/DatePicker.js.map +1 -0
- package/dist/components/Form.d.ts +7 -0
- package/dist/components/OTPField.d.ts +7 -0
- package/dist/components/PasswordField.d.ts +7 -0
- package/dist/components/PhoneField.d.ts +7 -0
- package/dist/components/Progress.d.ts +7 -0
- package/dist/components/Skeleton.d.ts +9 -0
- package/dist/components/Skeleton.js +2 -0
- package/dist/components/Skeleton.js.map +1 -0
- package/dist/components/TextArea.d.ts +7 -0
- package/dist/components/TextField.d.ts +7 -0
- package/dist/components/ThemeToggle.d.ts +7 -0
- package/dist/components/Typography.d.ts +7 -0
- package/dist/field.js +1 -34
- package/dist/field.js.map +1 -1
- package/dist/index.d.ts +69 -38
- package/dist/index.js +8 -6
- package/dist/index.js.map +1 -1
- package/dist/index5.js +5 -2
- package/dist/index5.js.map +1 -1
- package/dist/index6.js +246 -0
- package/dist/index6.js.map +1 -0
- package/dist/shadcn/shadcnField.d.ts +7 -0
- package/dist/utils/axios.d.ts +21 -6
- package/dist/utils/axios.js +1 -1
- package/package.json +20 -6
- package/dist/AuthProvider.d.ts +0 -34
- package/dist/OnboardingProvider.js +0 -113
- package/dist/OnboardingProvider.js.map +0 -1
- package/dist/context/AuthProvider.d.ts +0 -2
- package/dist/context/AuthProvider.js +0 -2
- package/dist/context/AuthProvider.js.map +0 -1
package/dist/Input.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { c as cn } from './utils.js';
|
|
3
|
+
|
|
4
|
+
function Input({ className, type, ...props }) {
|
|
5
|
+
return /* @__PURE__ */ jsx(
|
|
6
|
+
"input",
|
|
7
|
+
{
|
|
8
|
+
type,
|
|
9
|
+
"data-slot": "input",
|
|
10
|
+
className: cn(
|
|
11
|
+
"file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
|
12
|
+
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[1px]",
|
|
13
|
+
"aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
|
14
|
+
className
|
|
15
|
+
),
|
|
16
|
+
...props
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { Input as I };
|
|
22
|
+
//# sourceMappingURL=Input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Input.js","sources":["../shadcn/shadcnInput/Input.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { cn } from '../utils';\n\nfunction Input({ className, type, ...props }: React.ComponentProps<'input'>) {\n return (\n <input\n type={type}\n data-slot='input'\n className={cn(\n 'file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm',\n 'focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[1px]',\n 'aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive',\n className\n )}\n {...props}\n />\n );\n}\n\nexport { Input };\n"],"names":[],"mappings":";;;AAIA,SAAS,MAAM,EAAE,SAAA,EAAW,IAAA,EAAM,GAAG,OAAM,EAAkC;AAC3E,EAAA,uBACE,GAAA;AAAA,IAAC,OAAA;AAAA,IAAA;AAAA,MACC,IAAA;AAAA,MACA,WAAA,EAAU,OAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,icAAA;AAAA,QACA,+EAAA;AAAA,QACA,wGAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ;;;;"}
|
package/dist/Label.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { P as Primitive } from './index5.js';
|
|
4
|
+
import { c as cn } from './utils.js';
|
|
5
|
+
|
|
6
|
+
var NAME = "Label";
|
|
7
|
+
var Label$1 = React.forwardRef((props, forwardedRef) => {
|
|
8
|
+
return /* @__PURE__ */ jsx(
|
|
9
|
+
Primitive.label,
|
|
10
|
+
{
|
|
11
|
+
...props,
|
|
12
|
+
ref: forwardedRef,
|
|
13
|
+
onMouseDown: (event) => {
|
|
14
|
+
const target = event.target;
|
|
15
|
+
if (target.closest("button, input, select, textarea")) return;
|
|
16
|
+
props.onMouseDown?.(event);
|
|
17
|
+
if (!event.defaultPrevented && event.detail > 1) event.preventDefault();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
});
|
|
22
|
+
Label$1.displayName = NAME;
|
|
23
|
+
var Root = Label$1;
|
|
24
|
+
|
|
25
|
+
function Label({ className, ...props }) {
|
|
26
|
+
return /* @__PURE__ */ jsx(
|
|
27
|
+
Root,
|
|
28
|
+
{
|
|
29
|
+
"data-slot": "label",
|
|
30
|
+
className: cn(
|
|
31
|
+
"flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
|
|
32
|
+
className
|
|
33
|
+
),
|
|
34
|
+
...props
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { Label as L };
|
|
40
|
+
//# sourceMappingURL=Label.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Label.js","sources":["../node_modules/@radix-ui/react-label/dist/index.mjs","../shadcn/shadcnLabel/Label.tsx"],"sourcesContent":["\"use client\";\n\n// src/label.tsx\nimport * as React from \"react\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { jsx } from \"react/jsx-runtime\";\nvar NAME = \"Label\";\nvar Label = React.forwardRef((props, forwardedRef) => {\n return /* @__PURE__ */ jsx(\n Primitive.label,\n {\n ...props,\n ref: forwardedRef,\n onMouseDown: (event) => {\n const target = event.target;\n if (target.closest(\"button, input, select, textarea\")) return;\n props.onMouseDown?.(event);\n if (!event.defaultPrevented && event.detail > 1) event.preventDefault();\n }\n }\n );\n});\nLabel.displayName = NAME;\nvar Root = Label;\nexport {\n Label,\n Root\n};\n//# sourceMappingURL=index.mjs.map\n","import * as LabelPrimitive from '@radix-ui/react-label';\nimport * as React from 'react';\n\nimport { cn } from '../utils';\n\nfunction Label({ className, ...props }: React.ComponentProps<typeof LabelPrimitive.Root>) {\n return (\n <LabelPrimitive.Root\n data-slot='label'\n className={cn(\n 'flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50',\n className\n )}\n {...props}\n />\n );\n}\n\nexport { Label };\n"],"names":["Label","LabelPrimitive.Root"],"mappings":";;;;;AAMA,IAAI,IAAI,GAAG,OAAO;AAClB,IAAIA,OAAK,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,YAAY,KAAK;AACtD,EAAE,uBAAuB,GAAG;AAC5B,IAAI,SAAS,CAAC,KAAK;AACnB,IAAI;AACJ,MAAM,GAAG,KAAK;AACd,MAAM,GAAG,EAAE,YAAY;AACvB,MAAM,WAAW,EAAE,CAAC,KAAK,KAAK;AAC9B,QAAQ,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM;AACnC,QAAQ,IAAI,MAAM,CAAC,OAAO,CAAC,iCAAiC,CAAC,EAAE;AAC/D,QAAQ,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC;AAClC,QAAQ,IAAI,CAAC,KAAK,CAAC,gBAAgB,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,KAAK,CAAC,cAAc,EAAE;AAC/E,MAAM;AACN;AACA,GAAG;AACH,CAAC,CAAC;AACFA,OAAK,CAAC,WAAW,GAAG,IAAI;AACxB,IAAI,IAAI,GAAGA,OAAK;;AClBhB,SAAS,KAAA,CAAM,EAAE,SAAA,EAAW,GAAG,OAAM,EAAqD;AACxF,EAAA,uBACE,GAAA;AAAA,IAACC,IAAe;AAAA,IAAf;AAAA,MACC,WAAA,EAAU,OAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,qNAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ;;;;","x_google_ignoreList":[0]}
|
package/dist/Skeleton.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { c as cn } from './utils.js';
|
|
3
|
+
|
|
4
|
+
function Skeleton({
|
|
5
|
+
className,
|
|
6
|
+
...props
|
|
7
|
+
}) {
|
|
8
|
+
return /* @__PURE__ */ jsx(
|
|
9
|
+
"div",
|
|
10
|
+
{
|
|
11
|
+
className: cn("animate-pulse rounded-md bg-muted", className),
|
|
12
|
+
...props
|
|
13
|
+
}
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { Skeleton as S };
|
|
18
|
+
//# sourceMappingURL=Skeleton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Skeleton.js","sources":["../lib/components/Skeleton/Skeleton.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../../shadcn/utils';\n\nfunction Skeleton({\n className,\n ...props\n}: React.HTMLAttributes<HTMLDivElement>) {\n return (\n <div\n className={cn('animate-pulse rounded-md bg-muted', className)}\n {...props}\n />\n );\n}\n\nexport { Skeleton };\n"],"names":[],"mappings":";;;AAGA,SAAS,QAAA,CAAS;AAAA,EAChB,SAAA;AAAA,EACA,GAAG;AACL,CAAA,EAAyC;AACvC,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,SAAA,EAAW,EAAA,CAAG,mCAAA,EAAqC,SAAS,CAAA;AAAA,MAC3D,GAAG;AAAA;AAAA,GACN;AAEJ;;;;"}
|
package/dist/TextField.js
CHANGED
|
@@ -1,24 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
import { c as cn } from './utils.js';
|
|
4
4
|
import { F as Field, e as FieldLabel, b as FieldDescription, c as FieldError } from './field.js';
|
|
5
|
-
|
|
6
|
-
function Input({ className, type, ...props }) {
|
|
7
|
-
return /* @__PURE__ */ jsx(
|
|
8
|
-
"input",
|
|
9
|
-
{
|
|
10
|
-
type,
|
|
11
|
-
"data-slot": "input",
|
|
12
|
-
className: cn(
|
|
13
|
-
"file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
|
14
|
-
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[1px]",
|
|
15
|
-
"aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
|
16
|
-
className
|
|
17
|
-
),
|
|
18
|
-
...props
|
|
19
|
-
}
|
|
20
|
-
);
|
|
21
|
-
}
|
|
5
|
+
import { I as Input } from './Input.js';
|
|
22
6
|
|
|
23
7
|
const TextField = React__default.forwardRef(
|
|
24
8
|
({ label, description, error, className, id, startAdornment, endAdornment, ...props }, ref) => {
|
package/dist/TextField.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextField.js","sources":["../
|
|
1
|
+
{"version":3,"file":"TextField.js","sources":["../lib/components/TextField/TextField.tsx"],"sourcesContent":["import React from 'react';\nimport { Input } from '../../../shadcn/shadcnInput';\nimport { cn } from '../../../shadcn/utils';\nimport { Field, FieldDescription, FieldError, FieldLabel } from '../Field';\n\nexport interface TextFieldProps extends React.ComponentProps<'input'> {\n /**\n * Label for the field\n */\n label?: string;\n\n /**\n * Helper text to display below the field\n */\n description?: React.ReactNode;\n\n /**\n * Error message to display\n */\n error?: string;\n\n /**\n * Element to display at the start of the input (e.g., icon)\n */\n startAdornment?: React.ReactNode;\n\n /**\n * Element to display at the end of the input (e.g., icon button)\n */\n endAdornment?: React.ReactNode;\n}\n\n// TextField molecule - Input + Label composition using Field system\nexport const TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(\n ({ label, description, error, className, id, startAdornment, endAdornment, ...props }, ref) => {\n return (\n <Field >\n {label && <FieldLabel>{label}</FieldLabel>}\n\n <div className='relative'>\n {startAdornment && (\n <div className='absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none'>\n {startAdornment}\n </div>\n )}\n <Input\n aria-invalid={!!error}\n ref={ref}\n className={cn(className, startAdornment && 'pl-10', endAdornment && 'pr-10')}\n id={id}\n {...props}\n />\n {endAdornment && (\n <div className='absolute inset-y-0 right-0 flex items-center pr-3'>{endAdornment}</div>\n )}\n </div>\n\n {description && !error && <FieldDescription>{description}</FieldDescription>}\n {error && <FieldError>{error}</FieldError>}\n </Field>\n );\n }\n);\n\nTextField.displayName = 'TextField';\n"],"names":["React"],"mappings":";;;;;;AAiCO,MAAM,YAAYA,cAAA,CAAM,UAAA;AAAA,EAC7B,CAAC,EAAE,KAAA,EAAO,WAAA,EAAa,KAAA,EAAO,SAAA,EAAW,EAAA,EAAI,cAAA,EAAgB,YAAA,EAAc,GAAG,KAAA,EAAM,EAAG,GAAA,KAAQ;AAC7F,IAAA,4BACG,KAAA,EAAA,EACE,QAAA,EAAA;AAAA,MAAA,KAAA,oBAAS,GAAA,CAAC,cAAY,QAAA,EAAA,KAAA,EAAM,CAAA;AAAA,sBAE7B,IAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,UAAA,EACZ,QAAA,EAAA;AAAA,QAAA,cAAA,oBACC,GAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,sEAAA,EACZ,QAAA,EAAA,cAAA,EACH,CAAA;AAAA,wBAEF,GAAA;AAAA,UAAC,KAAA;AAAA,UAAA;AAAA,YACC,cAAA,EAAc,CAAC,CAAC,KAAA;AAAA,YAChB,GAAA;AAAA,YACA,WAAW,EAAA,CAAG,SAAA,EAAW,cAAA,IAAkB,OAAA,EAAS,gBAAgB,OAAO,CAAA;AAAA,YAC3E,EAAA;AAAA,YACC,GAAG;AAAA;AAAA,SACN;AAAA,QACC,YAAA,oBACC,GAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,qDAAqD,QAAA,EAAA,YAAA,EAAa;AAAA,OAAA,EAErF,CAAA;AAAA,MAEC,WAAA,IAAe,CAAC,KAAA,oBAAS,GAAA,CAAC,oBAAkB,QAAA,EAAA,WAAA,EAAY,CAAA;AAAA,MACxD,KAAA,oBAAS,GAAA,CAAC,UAAA,EAAA,EAAY,QAAA,EAAA,KAAA,EAAM;AAAA,KAAA,EAC/B,CAAA;AAAA,EAEJ;AACF;AAEA,SAAA,CAAU,WAAA,GAAc,WAAA;;;;"}
|
|
@@ -169,14 +169,14 @@
|
|
|
169
169
|
--chart-3: oklch(0.7729 0.1535 163.2231);
|
|
170
170
|
--chart-4: oklch(0.8369 0.1644 84.4286);
|
|
171
171
|
--chart-5: oklch(0.6368 0.2078 25.3313);
|
|
172
|
-
--sidebar: oklch(0.
|
|
173
|
-
--sidebar-foreground: oklch(0.
|
|
174
|
-
--sidebar-primary: oklch(0.
|
|
175
|
-
--sidebar-primary-foreground: oklch(
|
|
176
|
-
--sidebar-accent: oklch(0.
|
|
177
|
-
--sidebar-accent-foreground: oklch(0.
|
|
178
|
-
--sidebar-border: oklch(0.
|
|
179
|
-
--sidebar-ring: oklch(0.
|
|
172
|
+
--sidebar: oklch(0.985 0 0);
|
|
173
|
+
--sidebar-foreground: oklch(0.145 0 0);
|
|
174
|
+
--sidebar-primary: oklch(0.205 0 0);
|
|
175
|
+
--sidebar-primary-foreground: oklch(0.985 0 0);
|
|
176
|
+
--sidebar-accent: oklch(0.97 0 0);
|
|
177
|
+
--sidebar-accent-foreground: oklch(0.205 0 0);
|
|
178
|
+
--sidebar-border: oklch(0.922 0 0);
|
|
179
|
+
--sidebar-ring: oklch(0.708 0 0);
|
|
180
180
|
--font-sans: 'IBM Plex Sans', sans-serif;
|
|
181
181
|
--font-serif: 'Playfair Display', serif;
|
|
182
182
|
--font-mono: 'JetBrains Mono', monospace;
|
|
@@ -227,14 +227,14 @@
|
|
|
227
227
|
--chart-3: oklch(0.6731 0.1624 144.2083);
|
|
228
228
|
--chart-4: oklch(0.8442 0.1722 84.9338);
|
|
229
229
|
--chart-5: oklch(0.6083 0.2090 27.0276);
|
|
230
|
-
--sidebar: oklch(0.
|
|
231
|
-
--sidebar-foreground: oklch(0.
|
|
232
|
-
--sidebar-primary: oklch(0.
|
|
233
|
-
--sidebar-primary-foreground: oklch(0.
|
|
234
|
-
--sidebar-accent: oklch(0.
|
|
235
|
-
--sidebar-accent-foreground: oklch(0.
|
|
236
|
-
--sidebar-border: oklch(0
|
|
237
|
-
--sidebar-ring: oklch(0.
|
|
230
|
+
--sidebar: oklch(0.205 0 0);
|
|
231
|
+
--sidebar-foreground: oklch(0.985 0 0);
|
|
232
|
+
--sidebar-primary: oklch(0.488 0.243 264.376);
|
|
233
|
+
--sidebar-primary-foreground: oklch(0.985 0 0);
|
|
234
|
+
--sidebar-accent: oklch(0.269 0 0);
|
|
235
|
+
--sidebar-accent-foreground: oklch(0.985 0 0);
|
|
236
|
+
--sidebar-border: oklch(1 0 0 / 10%);
|
|
237
|
+
--sidebar-ring: oklch(0.439 0 0);
|
|
238
238
|
--font-sans: 'IBM Plex Sans', sans-serif;
|
|
239
239
|
--font-serif: 'Playfair Display', serif;
|
|
240
240
|
--font-mono: 'JetBrains Mono', monospace;
|
|
@@ -327,4 +327,10 @@ body {
|
|
|
327
327
|
.PhoneInputCountryIcon {
|
|
328
328
|
max-width: 1rem;
|
|
329
329
|
max-height: 1rem;
|
|
330
|
+
}
|
|
331
|
+
/* Loading animation for skeleton progress bars */
|
|
332
|
+
@keyframes loading {
|
|
333
|
+
0% { width: 0%; }
|
|
334
|
+
50% { width: 70%; }
|
|
335
|
+
100% { width: 100%; }
|
|
330
336
|
}
|
package/dist/axios.d.ts
CHANGED
|
@@ -4,20 +4,25 @@ declare const axios: AxiosInstance;
|
|
|
4
4
|
export { axios }
|
|
5
5
|
export default axios;
|
|
6
6
|
|
|
7
|
-
export declare
|
|
7
|
+
export declare function cancelTokenRefresh(): void;
|
|
8
8
|
|
|
9
9
|
export declare const clearCsrfToken: () => void;
|
|
10
10
|
|
|
11
|
-
export declare const clearToken: (
|
|
11
|
+
export declare const clearToken: () => void;
|
|
12
12
|
|
|
13
13
|
export declare const getCsrfToken: () => string | null;
|
|
14
14
|
|
|
15
|
-
export declare const getToken: (
|
|
15
|
+
export declare const getToken: () => string | null;
|
|
16
16
|
|
|
17
|
-
export declare
|
|
17
|
+
export declare function recoverSession(): Promise<{
|
|
18
|
+
success: boolean;
|
|
19
|
+
expiresIn: number;
|
|
20
|
+
}>;
|
|
21
|
+
|
|
22
|
+
export declare function scheduleTokenRefresh(expiresIn: number): void;
|
|
18
23
|
|
|
19
|
-
export declare const
|
|
24
|
+
export declare const setCsrfToken: (token: string) => void;
|
|
20
25
|
|
|
21
|
-
export declare
|
|
26
|
+
export declare const setToken: (token: string) => void;
|
|
22
27
|
|
|
23
28
|
export { }
|
package/dist/axios.js
CHANGED
|
@@ -1,3 +1,54 @@
|
|
|
1
|
+
const defaultConfig = {
|
|
2
|
+
csrf: {
|
|
3
|
+
endpoint: "/csrf/token",
|
|
4
|
+
enabled: true,
|
|
5
|
+
headerName: "x-csrf-token"
|
|
6
|
+
},
|
|
7
|
+
axios: {
|
|
8
|
+
baseURL: "/api",
|
|
9
|
+
timeout: 3e4,
|
|
10
|
+
withCredentials: true,
|
|
11
|
+
headers: {
|
|
12
|
+
"Content-Type": "application/json",
|
|
13
|
+
Accept: "application/json"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
auth: {
|
|
17
|
+
tokenHeaderName: "Authorization",
|
|
18
|
+
tokenPrefix: "Bearer"
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
let currentConfig = { ...defaultConfig };
|
|
22
|
+
function defineConfig(config) {
|
|
23
|
+
return config;
|
|
24
|
+
}
|
|
25
|
+
function configureQuantumUI(userConfig) {
|
|
26
|
+
currentConfig = {
|
|
27
|
+
csrf: {
|
|
28
|
+
...defaultConfig.csrf,
|
|
29
|
+
...userConfig.csrf || {}
|
|
30
|
+
},
|
|
31
|
+
axios: {
|
|
32
|
+
...defaultConfig.axios,
|
|
33
|
+
...userConfig.axios || {},
|
|
34
|
+
headers: {
|
|
35
|
+
...defaultConfig.axios.headers,
|
|
36
|
+
...userConfig.axios?.headers || {}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
auth: {
|
|
40
|
+
...defaultConfig.auth,
|
|
41
|
+
...userConfig.auth || {}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function getConfig() {
|
|
46
|
+
return currentConfig;
|
|
47
|
+
}
|
|
48
|
+
function resetConfig() {
|
|
49
|
+
currentConfig = { ...defaultConfig };
|
|
50
|
+
}
|
|
51
|
+
|
|
1
52
|
function bind(fn, thisArg) {
|
|
2
53
|
return function wrap() {
|
|
3
54
|
return fn.apply(thisArg, arguments);
|
|
@@ -3841,111 +3892,109 @@ const {
|
|
|
3841
3892
|
mergeConfig
|
|
3842
3893
|
} = axios$1;
|
|
3843
3894
|
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
enabled: true,
|
|
3848
|
-
headerName: "x-csrf-token"
|
|
3849
|
-
},
|
|
3850
|
-
axios: {
|
|
3851
|
-
baseURL: "/api",
|
|
3852
|
-
timeout: 3e4,
|
|
3853
|
-
withCredentials: true,
|
|
3854
|
-
headers: {
|
|
3855
|
-
"Content-Type": "application/json",
|
|
3856
|
-
Accept: "application/json"
|
|
3857
|
-
}
|
|
3858
|
-
},
|
|
3859
|
-
auth: {
|
|
3860
|
-
tokenHeaderName: "Authorization",
|
|
3861
|
-
tokenPrefix: "Bearer"
|
|
3862
|
-
}
|
|
3863
|
-
};
|
|
3864
|
-
let currentConfig = { ...defaultConfig };
|
|
3865
|
-
function defineConfig(config) {
|
|
3866
|
-
return config;
|
|
3867
|
-
}
|
|
3868
|
-
function configureQuantumUI(userConfig) {
|
|
3869
|
-
currentConfig = {
|
|
3870
|
-
csrf: {
|
|
3871
|
-
...defaultConfig.csrf,
|
|
3872
|
-
...userConfig.csrf || {}
|
|
3873
|
-
},
|
|
3874
|
-
axios: {
|
|
3875
|
-
...defaultConfig.axios,
|
|
3876
|
-
...userConfig.axios || {},
|
|
3877
|
-
headers: {
|
|
3878
|
-
...defaultConfig.axios.headers,
|
|
3879
|
-
...userConfig.axios?.headers || {}
|
|
3880
|
-
}
|
|
3881
|
-
},
|
|
3882
|
-
auth: {
|
|
3883
|
-
...defaultConfig.auth,
|
|
3884
|
-
...userConfig.auth || {}
|
|
3885
|
-
}
|
|
3886
|
-
};
|
|
3887
|
-
}
|
|
3888
|
-
function getConfig() {
|
|
3889
|
-
return currentConfig;
|
|
3890
|
-
}
|
|
3891
|
-
function resetConfig() {
|
|
3892
|
-
currentConfig = { ...defaultConfig };
|
|
3893
|
-
}
|
|
3894
|
-
|
|
3895
|
-
const tokenStore = {};
|
|
3895
|
+
let accessToken = null;
|
|
3896
|
+
let refreshTimer = null;
|
|
3897
|
+
let sessionRecoveryPromise = null;
|
|
3896
3898
|
let csrfToken = null;
|
|
3897
3899
|
let csrfFetchPromise = null;
|
|
3898
|
-
const
|
|
3899
|
-
if (
|
|
3900
|
-
|
|
3901
|
-
return;
|
|
3900
|
+
const setToken = (token) => {
|
|
3901
|
+
if (token && typeof token === "string") {
|
|
3902
|
+
accessToken = token;
|
|
3902
3903
|
}
|
|
3903
|
-
csrfToken = token;
|
|
3904
3904
|
};
|
|
3905
|
-
const
|
|
3906
|
-
|
|
3905
|
+
const getToken = () => accessToken;
|
|
3906
|
+
const clearToken = () => {
|
|
3907
|
+
accessToken = null;
|
|
3908
|
+
cancelTokenRefresh();
|
|
3907
3909
|
};
|
|
3910
|
+
const setCsrfToken = (token) => {
|
|
3911
|
+
if (token && typeof token === "string") {
|
|
3912
|
+
csrfToken = token;
|
|
3913
|
+
}
|
|
3914
|
+
};
|
|
3915
|
+
const getCsrfToken = () => csrfToken;
|
|
3908
3916
|
const clearCsrfToken = () => {
|
|
3909
3917
|
csrfToken = null;
|
|
3910
3918
|
};
|
|
3911
|
-
|
|
3912
|
-
const
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3919
|
+
async function recoverSession() {
|
|
3920
|
+
const config = getConfig();
|
|
3921
|
+
try {
|
|
3922
|
+
const response = await axios$1.get(
|
|
3923
|
+
"/auth/token",
|
|
3924
|
+
{
|
|
3925
|
+
baseURL: config.axios.baseURL,
|
|
3926
|
+
withCredentials: true,
|
|
3927
|
+
timeout: config.axios.timeout
|
|
3928
|
+
}
|
|
3929
|
+
);
|
|
3930
|
+
if (response.data.accessToken) {
|
|
3931
|
+
setToken(response.data.accessToken);
|
|
3932
|
+
return { success: true, expiresIn: response.data.expiresIn };
|
|
3933
|
+
}
|
|
3934
|
+
return { success: false, expiresIn: 0 };
|
|
3935
|
+
} catch {
|
|
3936
|
+
clearToken();
|
|
3937
|
+
return { success: false, expiresIn: 0 };
|
|
3916
3938
|
}
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
const
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
}
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3939
|
+
}
|
|
3940
|
+
async function recoverSessionIfNeeded() {
|
|
3941
|
+
if (accessToken) return true;
|
|
3942
|
+
if (sessionRecoveryPromise) {
|
|
3943
|
+
return sessionRecoveryPromise;
|
|
3944
|
+
}
|
|
3945
|
+
sessionRecoveryPromise = (async () => {
|
|
3946
|
+
try {
|
|
3947
|
+
const result = await recoverSession();
|
|
3948
|
+
if (result.success) {
|
|
3949
|
+
scheduleTokenRefresh(result.expiresIn);
|
|
3950
|
+
return true;
|
|
3951
|
+
}
|
|
3952
|
+
return false;
|
|
3953
|
+
} catch {
|
|
3954
|
+
return false;
|
|
3955
|
+
} finally {
|
|
3956
|
+
sessionRecoveryPromise = null;
|
|
3957
|
+
}
|
|
3958
|
+
})();
|
|
3959
|
+
return sessionRecoveryPromise;
|
|
3960
|
+
}
|
|
3961
|
+
function scheduleTokenRefresh(expiresIn) {
|
|
3962
|
+
cancelTokenRefresh();
|
|
3963
|
+
const refreshAt = expiresIn * 0.8 * 1e3;
|
|
3964
|
+
refreshTimer = setTimeout(async () => {
|
|
3965
|
+
const config = getConfig();
|
|
3966
|
+
try {
|
|
3967
|
+
const response = await axios$1.post(
|
|
3968
|
+
"/auth/refresh",
|
|
3969
|
+
{},
|
|
3970
|
+
{
|
|
3971
|
+
baseURL: config.axios.baseURL,
|
|
3972
|
+
withCredentials: true,
|
|
3973
|
+
timeout: config.axios.timeout
|
|
3974
|
+
}
|
|
3975
|
+
);
|
|
3976
|
+
if (response.data.accessToken) {
|
|
3977
|
+
setToken(response.data.accessToken);
|
|
3978
|
+
scheduleTokenRefresh(response.data.expiresIn);
|
|
3979
|
+
}
|
|
3980
|
+
} catch {
|
|
3981
|
+
clearToken();
|
|
3982
|
+
redirectToLogin();
|
|
3935
3983
|
}
|
|
3984
|
+
}, refreshAt);
|
|
3985
|
+
}
|
|
3986
|
+
function cancelTokenRefresh() {
|
|
3987
|
+
if (refreshTimer) {
|
|
3988
|
+
clearTimeout(refreshTimer);
|
|
3989
|
+
refreshTimer = null;
|
|
3936
3990
|
}
|
|
3937
|
-
|
|
3938
|
-
};
|
|
3991
|
+
}
|
|
3939
3992
|
async function fetchCsrfToken() {
|
|
3940
|
-
if (csrfFetchPromise)
|
|
3941
|
-
return csrfFetchPromise;
|
|
3942
|
-
}
|
|
3993
|
+
if (csrfFetchPromise) return csrfFetchPromise;
|
|
3943
3994
|
csrfFetchPromise = (async () => {
|
|
3944
3995
|
try {
|
|
3945
3996
|
const config = getConfig();
|
|
3946
|
-
if (!config.csrf.enabled)
|
|
3947
|
-
return null;
|
|
3948
|
-
}
|
|
3997
|
+
if (!config.csrf.enabled) return null;
|
|
3949
3998
|
const response = await axios$1.get(config.csrf.endpoint, {
|
|
3950
3999
|
baseURL: config.axios.baseURL,
|
|
3951
4000
|
withCredentials: config.axios.withCredentials,
|
|
@@ -3956,10 +4005,8 @@ async function fetchCsrfToken() {
|
|
|
3956
4005
|
setCsrfToken(token);
|
|
3957
4006
|
return token;
|
|
3958
4007
|
}
|
|
3959
|
-
console.warn("[axios] CSRF endpoint did not return a csrfToken field");
|
|
3960
4008
|
return null;
|
|
3961
|
-
} catch
|
|
3962
|
-
console.error("[axios] Failed to fetch CSRF token:", error);
|
|
4009
|
+
} catch {
|
|
3963
4010
|
return null;
|
|
3964
4011
|
} finally {
|
|
3965
4012
|
csrfFetchPromise = null;
|
|
@@ -3967,6 +4014,22 @@ async function fetchCsrfToken() {
|
|
|
3967
4014
|
})();
|
|
3968
4015
|
return csrfFetchPromise;
|
|
3969
4016
|
}
|
|
4017
|
+
function redirectToLogin() {
|
|
4018
|
+
if (typeof window !== "undefined") {
|
|
4019
|
+
window.location.href = "/login";
|
|
4020
|
+
}
|
|
4021
|
+
}
|
|
4022
|
+
function getSubdomain() {
|
|
4023
|
+
if (typeof window === "undefined") return null;
|
|
4024
|
+
const parts = window.location.hostname.split(".");
|
|
4025
|
+
if (parts.length >= 2 && parts[parts.length - 1] === "localhost") {
|
|
4026
|
+
return parts[0];
|
|
4027
|
+
}
|
|
4028
|
+
if (parts.length >= 3) {
|
|
4029
|
+
return parts[0];
|
|
4030
|
+
}
|
|
4031
|
+
return null;
|
|
4032
|
+
}
|
|
3970
4033
|
function createAxiosInstance() {
|
|
3971
4034
|
const config = getConfig();
|
|
3972
4035
|
return axios$1.create({
|
|
@@ -3977,65 +4040,46 @@ function createAxiosInstance() {
|
|
|
3977
4040
|
});
|
|
3978
4041
|
}
|
|
3979
4042
|
const axios = createAxiosInstance();
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
}
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
if (
|
|
4005
|
-
config.headers["x-subdomain"] = subdomain;
|
|
4006
|
-
}
|
|
4007
|
-
const isStateChangingRequest = ["post", "put", "patch", "delete"].includes(
|
|
4008
|
-
config.method?.toLowerCase() || ""
|
|
4009
|
-
);
|
|
4010
|
-
if (isStateChangingRequest && quantumConfig.csrf.enabled) {
|
|
4011
|
-
let csrfTokenValue = getCsrfToken();
|
|
4012
|
-
if (!csrfTokenValue) {
|
|
4013
|
-
csrfTokenValue = await fetchCsrfToken();
|
|
4014
|
-
}
|
|
4015
|
-
if (csrfTokenValue) {
|
|
4016
|
-
config.headers[quantumConfig.csrf.headerName] = csrfTokenValue;
|
|
4017
|
-
} else {
|
|
4018
|
-
console.warn("[axios] CSRF token not available for state-changing request");
|
|
4019
|
-
}
|
|
4020
|
-
}
|
|
4021
|
-
return config;
|
|
4022
|
-
},
|
|
4023
|
-
(error) => {
|
|
4024
|
-
return Promise.reject(error);
|
|
4043
|
+
axios.interceptors.request.use(async (config) => {
|
|
4044
|
+
const quantumConfig = getConfig();
|
|
4045
|
+
const isPublicRequest = config.public === true;
|
|
4046
|
+
if (!isPublicRequest) {
|
|
4047
|
+
const hasSession = await recoverSessionIfNeeded();
|
|
4048
|
+
if (!hasSession) {
|
|
4049
|
+
redirectToLogin();
|
|
4050
|
+
return Promise.reject(new Error("No valid session"));
|
|
4051
|
+
}
|
|
4052
|
+
}
|
|
4053
|
+
const token = getToken();
|
|
4054
|
+
if (token) {
|
|
4055
|
+
config.headers[quantumConfig.auth.tokenHeaderName] = `${quantumConfig.auth.tokenPrefix} ${token}`;
|
|
4056
|
+
}
|
|
4057
|
+
const subdomain = getSubdomain();
|
|
4058
|
+
if (subdomain) {
|
|
4059
|
+
config.headers["x-subdomain"] = subdomain;
|
|
4060
|
+
}
|
|
4061
|
+
const isStateChanging = ["post", "put", "patch", "delete"].includes(
|
|
4062
|
+
config.method?.toLowerCase() || ""
|
|
4063
|
+
);
|
|
4064
|
+
if (isStateChanging && quantumConfig.csrf.enabled) {
|
|
4065
|
+
let csrf = getCsrfToken();
|
|
4066
|
+
if (!csrf) csrf = await fetchCsrfToken();
|
|
4067
|
+
if (csrf) config.headers[quantumConfig.csrf.headerName] = csrf;
|
|
4025
4068
|
}
|
|
4026
|
-
|
|
4069
|
+
return config;
|
|
4070
|
+
});
|
|
4027
4071
|
axios.interceptors.response.use(
|
|
4028
|
-
(response) =>
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4072
|
+
(response) => response,
|
|
4073
|
+
(error) => {
|
|
4074
|
+
const isPublicRequest = error.config?.public === true;
|
|
4075
|
+
if (error.response?.status === 401 && !isPublicRequest) {
|
|
4076
|
+
clearToken();
|
|
4077
|
+
cancelTokenRefresh();
|
|
4078
|
+
redirectToLogin();
|
|
4035
4079
|
}
|
|
4036
4080
|
return Promise.reject(error);
|
|
4037
4081
|
}
|
|
4038
4082
|
);
|
|
4039
4083
|
|
|
4040
|
-
export { axios as a, getToken as b, configureQuantumUI as c, defineConfig as d, clearToken as e,
|
|
4084
|
+
export { axios as a, getToken as b, configureQuantumUI as c, defineConfig as d, clearToken as e, recoverSession as f, getConfig as g, scheduleTokenRefresh as h, cancelTokenRefresh as i, setCsrfToken as j, getCsrfToken as k, clearCsrfToken as l, resetConfig as r, setToken as s };
|
|
4041
4085
|
//# sourceMappingURL=axios.js.map
|