@povio/ui 0.0.10 → 2.1.0
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/components/Menu/MenuItem.js +2 -1
- package/dist/components/buttons/Button/Button.d.ts +3 -2
- package/dist/components/buttons/Button/Button.js +6 -1
- package/dist/components/buttons/Button/button.cva.d.ts +5 -5
- package/dist/components/buttons/Button/button.cva.js +188 -214
- package/dist/components/buttons/IconButton/IconButton.d.ts +3 -2
- package/dist/components/buttons/InlineIconButton/InlineIconButton.d.ts +3 -2
- package/dist/components/buttons/InlineIconButton/InlineIconButton.js +1 -1
- package/dist/components/buttons/PillButton/pillButton.cva.d.ts +2 -0
- package/dist/components/buttons/PillButton/pillButton.cva.js +227 -45
- package/dist/components/buttons/SplitButton/SplitButton.d.ts +3 -2
- package/dist/components/buttons/SplitButton/SplitButton.js +2 -2
- package/dist/components/buttons/TextButton/TextButton.d.ts +3 -2
- package/dist/components/buttons/TextButton/TextButton.js +1 -1
- package/dist/components/inputs/Checkbox/CheckboxCheckmark.js +2 -19
- package/dist/components/inputs/Checkbox/checkbox.cva.js +4 -0
- package/dist/components/inputs/DateTime/shared/CalendarCell.js +3 -3
- package/dist/components/inputs/DateTime/shared/CalendarSelectHeader.js +1 -1
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +1 -1
- package/dist/components/inputs/DateTime/shared/RangeCalendar.js +6 -4
- package/dist/components/inputs/File/FileUpload.js +2 -2
- package/dist/components/inputs/File/shared/FileUploadContentLoading.js +3 -3
- package/dist/components/inputs/File/shared/InputUploadContent.js +1 -2
- package/dist/components/inputs/File/shared/ProgressBar.d.ts +6 -0
- package/dist/components/inputs/File/shared/ProgressBar.js +42 -0
- package/dist/components/inputs/File/shared/inputUploadButton.cva.js +2 -2
- package/dist/components/inputs/FormField/FormFieldHeader.js +1 -1
- package/dist/components/inputs/RadioGroup/RadioGroup.js +1 -11
- package/dist/components/inputs/RadioGroup/radio.cva.js +12 -2
- package/dist/components/inputs/shared/input.cva.js +23 -17
- package/dist/components/inputs/shared/label.cva.js +9 -14
- package/dist/components/overlays/Modal/Modal.d.ts +2 -1
- package/dist/components/overlays/Modal/Modal.js +7 -3
- package/dist/components/overlays/Tooltip/Tooltip.js +9 -1
- package/dist/components/overlays/Tooltip/tooltip.cva.js +4 -4
- package/dist/components/segment/SegmentItem.js +9 -8
- package/dist/components/shared/pagination/PaginationList.d.ts +1 -1
- package/dist/components/shared/pagination/minWidth.cva.d.ts +1 -1
- package/dist/components/status/Toast/Toast.js +2 -1
- package/dist/components/text/Link/Link.d.ts +3 -1
- package/dist/components/text/Link/Link.js +7 -1
- package/dist/config/link.context.d.ts +10 -0
- package/dist/config/link.context.js +19 -0
- package/dist/hooks/useFilters.d.ts +5 -1
- package/dist/hooks/useFilters.js +123 -69
- package/dist/index.d.ts +3 -4
- package/dist/index.js +5 -3
- package/dist/utils/vendor/acl/AclGuard.d.ts +5 -5
- package/dist/utils/vendor/acl/AclGuard.js +2 -3
- package/dist/utils/vendor/auth/auth.context.d.ts +2 -1
- package/dist/utils/vendor/auth/auth.context.js +2 -0
- package/package.json +1 -1
- package/dist/components/inputs/File/shared/FileProgressBar.d.ts +0 -3
- package/dist/components/inputs/File/shared/FileProgressBar.js +0 -32
- package/dist/utils/vendor/auth/withPrivateAuthGuard.d.ts +0 -6
- package/dist/utils/vendor/auth/withPrivateAuthGuard.js +0 -17
package/dist/hooks/useFilters.js
CHANGED
|
@@ -1,107 +1,160 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { useNavigate, useLocation } from "@tanstack/react-router";
|
|
2
|
+
import { useMemo, useRef, useState, useEffect } from "react";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
function getFieldType(schema, fieldKey) {
|
|
5
|
+
if (!schema || !schema.shape) return "unknown";
|
|
6
|
+
let fieldSchema = schema.shape[fieldKey];
|
|
7
|
+
while (fieldSchema) {
|
|
8
|
+
if (fieldSchema instanceof z.ZodOptional || fieldSchema instanceof z.ZodNullable) {
|
|
9
|
+
fieldSchema = fieldSchema.unwrap();
|
|
10
|
+
} else {
|
|
11
|
+
break;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
if (!fieldSchema) return "unknown";
|
|
15
|
+
if (fieldSchema instanceof z.ZodNumber) return "number";
|
|
16
|
+
if (fieldSchema instanceof z.ZodBoolean) return "boolean";
|
|
17
|
+
if (fieldSchema instanceof z.ZodString) return "string";
|
|
18
|
+
return "unknown";
|
|
19
|
+
}
|
|
20
|
+
function serializeFiltersToQuery(filterData, prefix) {
|
|
4
21
|
const query = {};
|
|
5
22
|
for (const [key, value] of Object.entries(filterData)) {
|
|
6
23
|
if (value === null || value === void 0) {
|
|
7
24
|
continue;
|
|
8
25
|
}
|
|
9
|
-
const filterKey = `filter[${prefix && `${prefix}-`}${key}]`;
|
|
10
26
|
if (Array.isArray(value) || typeof value === "object") {
|
|
11
|
-
query[
|
|
27
|
+
query[`filter[${prefix && `${prefix}-`}${key}]`] = JSON.stringify(value);
|
|
12
28
|
} else if (typeof value === "boolean") {
|
|
13
|
-
query[
|
|
29
|
+
query[`filter[${prefix && `${prefix}-`}${key}]`] = value ? "true" : "false";
|
|
30
|
+
} else if (typeof value === "number") {
|
|
31
|
+
query[`filter[${prefix && `${prefix}-`}${key}]`] = value.toString();
|
|
14
32
|
} else {
|
|
15
|
-
query[
|
|
33
|
+
query[`filter[${prefix && `${prefix}-`}${key}]`] = value;
|
|
16
34
|
}
|
|
17
35
|
}
|
|
18
36
|
return query;
|
|
19
|
-
}
|
|
20
|
-
|
|
37
|
+
}
|
|
38
|
+
function parseFilterFromQuery(query, schema) {
|
|
21
39
|
const filter = {};
|
|
22
40
|
for (const [key, value] of Object.entries(query)) {
|
|
23
|
-
const match = /^filter\[(.+?)\]
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
41
|
+
const match = key.match(/^filter\[(.+?)\]$/);
|
|
42
|
+
if (match) {
|
|
43
|
+
const filterKey = match[1];
|
|
44
|
+
const baseKey = filterKey.includes("-") ? filterKey.split("-").pop() || filterKey : filterKey;
|
|
45
|
+
if (value.startsWith("[") && value.endsWith("]") || value.startsWith("{") && value.endsWith("}")) {
|
|
46
|
+
filter[filterKey] = JSON.parse(value);
|
|
47
|
+
} else if (["true", "false"].includes(value)) {
|
|
48
|
+
filter[filterKey] = value === "true";
|
|
49
|
+
} else {
|
|
50
|
+
const expectedType = getFieldType(schema, baseKey);
|
|
51
|
+
if (expectedType === "number" && !Number.isNaN(Number(value)) && value !== "" && value !== null) {
|
|
52
|
+
filter[filterKey] = Number(value);
|
|
53
|
+
} else if (expectedType === "boolean" && ["true", "false"].includes(value)) {
|
|
54
|
+
filter[filterKey] = value === "true";
|
|
55
|
+
} else {
|
|
56
|
+
filter[filterKey] = value;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
38
59
|
}
|
|
39
60
|
}
|
|
40
61
|
return filter;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
const
|
|
62
|
+
}
|
|
63
|
+
function useFilters(defaultFilterValues, prefix = "", schema) {
|
|
64
|
+
const navigate = useNavigate();
|
|
65
|
+
const location = useLocation();
|
|
66
|
+
const queryObject = useMemo(
|
|
67
|
+
() => Object.fromEntries(new URLSearchParams(location.searchStr || "").entries()),
|
|
68
|
+
[location.searchStr]
|
|
69
|
+
);
|
|
70
|
+
const hasAppliedDefaultsRef = useRef(false);
|
|
71
|
+
const lastPathnameRef = useRef(location.pathname);
|
|
72
|
+
const queryFilters = parseFilterFromQuery(queryObject, schema);
|
|
45
73
|
const [filterData, setFilterData] = useState(queryFilters);
|
|
46
74
|
useEffect(() => {
|
|
47
|
-
|
|
75
|
+
if (lastPathnameRef.current !== location.pathname) {
|
|
76
|
+
hasAppliedDefaultsRef.current = false;
|
|
77
|
+
lastPathnameRef.current = location.pathname;
|
|
78
|
+
}
|
|
79
|
+
}, [location.pathname]);
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
const currentQueryObject = Object.fromEntries(new URLSearchParams(location.searchStr || "").entries());
|
|
82
|
+
const currentFilters = parseFilterFromQuery(currentQueryObject, schema);
|
|
83
|
+
const shouldApplyDefaults = defaultFilterValues && Object.keys(currentFilters).length === 0 && !hasAppliedDefaultsRef.current;
|
|
84
|
+
if (shouldApplyDefaults) {
|
|
48
85
|
const flatFilterQuery = serializeFiltersToQuery(defaultFilterValues, prefix);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
86
|
+
const sp = new URLSearchParams(location.searchStr || "");
|
|
87
|
+
let needsNavigation = false;
|
|
88
|
+
Object.entries(flatFilterQuery).forEach(([k, v]) => {
|
|
89
|
+
const currentValue = sp.get(k);
|
|
90
|
+
if (Array.isArray(v)) {
|
|
91
|
+
const currentValues = sp.getAll(k);
|
|
92
|
+
if (JSON.stringify(currentValues.sort()) !== JSON.stringify(v.sort())) {
|
|
93
|
+
needsNavigation = true;
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
if (currentValue !== v) {
|
|
97
|
+
needsNavigation = true;
|
|
98
|
+
}
|
|
54
99
|
}
|
|
55
100
|
});
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
101
|
+
if (needsNavigation) {
|
|
102
|
+
Object.entries(flatFilterQuery).forEach(([k, v]) => {
|
|
103
|
+
sp.delete(k);
|
|
104
|
+
if (Array.isArray(v)) {
|
|
105
|
+
v.forEach((val) => sp.append(k, val));
|
|
106
|
+
} else {
|
|
107
|
+
sp.set(k, v);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
const to = `${location.pathname}${sp.toString() ? `?${sp.toString()}` : ""}`;
|
|
111
|
+
navigate({ to, replace: true });
|
|
112
|
+
}
|
|
113
|
+
hasAppliedDefaultsRef.current = true;
|
|
61
114
|
}
|
|
62
|
-
}, [defaultFilterValues, prefix]);
|
|
115
|
+
}, [defaultFilterValues, prefix, location.pathname, location.searchStr]);
|
|
63
116
|
useEffect(() => {
|
|
64
|
-
const newQueryFilters = parseFilterFromQuery(
|
|
117
|
+
const newQueryFilters = parseFilterFromQuery(queryObject, schema);
|
|
65
118
|
setFilterData(newQueryFilters);
|
|
66
|
-
}, [
|
|
119
|
+
}, [queryObject, schema]);
|
|
67
120
|
const setFilterValue = (data) => {
|
|
68
|
-
|
|
121
|
+
const next = { ...filterData };
|
|
69
122
|
const isReset = Object.keys(data).length === 0;
|
|
70
123
|
const isResetToDefault = data === defaultFilterValues;
|
|
71
124
|
if (isResetToDefault) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
} else {
|
|
125
|
+
Object.keys(next).forEach((key) => delete next[key]);
|
|
126
|
+
Object.entries(defaultFilterValues ?? {}).forEach(([key, value]) => {
|
|
127
|
+
next[key] = value;
|
|
128
|
+
});
|
|
129
|
+
} else if (!isReset) {
|
|
78
130
|
Object.entries(data).forEach(([key, value]) => {
|
|
79
131
|
if (value === void 0) {
|
|
80
|
-
delete
|
|
132
|
+
delete next[key];
|
|
81
133
|
} else {
|
|
82
|
-
|
|
134
|
+
next[key] = value;
|
|
83
135
|
}
|
|
84
136
|
});
|
|
137
|
+
} else {
|
|
138
|
+
Object.keys(next).forEach((key) => delete next[key]);
|
|
85
139
|
}
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
(
|
|
89
|
-
|
|
90
|
-
acc[k] = query[k];
|
|
91
|
-
}
|
|
92
|
-
return acc;
|
|
93
|
-
},
|
|
94
|
-
{}
|
|
95
|
-
);
|
|
96
|
-
const flatFilterQuery = serializeFiltersToQuery(newFilters, prefix);
|
|
97
|
-
replace({
|
|
98
|
-
pathname,
|
|
99
|
-
query: {
|
|
100
|
-
...cleanedQuery,
|
|
101
|
-
...flatFilterQuery
|
|
140
|
+
const sp = new URLSearchParams(location.searchStr || "");
|
|
141
|
+
Array.from(sp.keys()).forEach((key) => {
|
|
142
|
+
if (key.startsWith(`filter[${prefix && `${prefix}-`}`)) {
|
|
143
|
+
sp.delete(key);
|
|
102
144
|
}
|
|
103
145
|
});
|
|
104
|
-
|
|
146
|
+
const flatFilterQuery = serializeFiltersToQuery(next, prefix);
|
|
147
|
+
Object.entries(flatFilterQuery).forEach(([k, v]) => {
|
|
148
|
+
sp.delete(k);
|
|
149
|
+
if (Array.isArray(v)) {
|
|
150
|
+
v.forEach((val) => sp.append(k, val));
|
|
151
|
+
} else {
|
|
152
|
+
sp.set(k, v);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
const to = `${location.pathname}${sp.toString() ? `?${sp.toString()}` : ""}`;
|
|
156
|
+
navigate({ to, replace: true });
|
|
157
|
+
setFilterData(next);
|
|
105
158
|
};
|
|
106
159
|
const getFilterValue = (keys) => {
|
|
107
160
|
const result = {};
|
|
@@ -114,7 +167,8 @@ const useFilters = (defaultFilterValues, prefix = "") => {
|
|
|
114
167
|
setFilterValue(defaultFilterValues ?? {});
|
|
115
168
|
};
|
|
116
169
|
return { filterData, setFilterValue, getFilterValue, clearAllFilters };
|
|
117
|
-
}
|
|
170
|
+
}
|
|
118
171
|
export {
|
|
172
|
+
parseFilterFromQuery,
|
|
119
173
|
useFilters
|
|
120
174
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -69,6 +69,7 @@ export type { FileUploadContainerProps } from './components/inputs/File/FileUplo
|
|
|
69
69
|
export { FileUploadContainer } from './components/inputs/File/FileUploadContainer';
|
|
70
70
|
export type { InputUploadProps } from './components/inputs/File/InputUpload';
|
|
71
71
|
export { InputUpload } from './components/inputs/File/InputUpload';
|
|
72
|
+
export { ProgressBar } from './components/inputs/File/shared/ProgressBar';
|
|
72
73
|
export type { FormFieldProps } from './components/inputs/FormField/FormField';
|
|
73
74
|
export { FormField } from './components/inputs/FormField/FormField';
|
|
74
75
|
export type { ControlledNumberInputProps, NumberInputProps } from './components/inputs/Input/NumberInput/NumberInput';
|
|
@@ -143,7 +144,7 @@ export { PaginatedTable } from './components/table/PaginatedTable';
|
|
|
143
144
|
export type { TableProps, TableWrapperProps } from './components/table/Table';
|
|
144
145
|
export { Table } from './components/table/Table';
|
|
145
146
|
export type { TableRowVariantProps } from './components/table/table.cva';
|
|
146
|
-
export type { LinkProps } from './components/text/Link/Link';
|
|
147
|
+
export type { LinkNavigationProps, LinkProps } from './components/text/Link/Link';
|
|
147
148
|
export { Link } from './components/text/Link/Link';
|
|
148
149
|
export type { LinkVariantProps } from './components/text/Link/link.cva';
|
|
149
150
|
export type { TagProps } from './components/text/Tag/Tag';
|
|
@@ -154,6 +155,7 @@ export { Typography } from './components/text/Typography/Typography';
|
|
|
154
155
|
export type { TypographyVariantProps } from './components/text/Typography/typography.cva';
|
|
155
156
|
export { Confirmation } from './config/confirmation.context';
|
|
156
157
|
export { ns, resources } from './config/i18n';
|
|
158
|
+
export { LinkContext } from './config/link.context';
|
|
157
159
|
export { UIRouter } from './config/router.context';
|
|
158
160
|
export { UIConfig } from './config/uiConfig.context';
|
|
159
161
|
export { UIStyle } from './config/uiStyle.context';
|
|
@@ -200,11 +202,8 @@ export { createAclGuard } from './utils/vendor/acl/AclGuard';
|
|
|
200
202
|
export { AbilityContext } from './utils/vendor/acl/ability.context';
|
|
201
203
|
export type { AppAbilities, AppAbility } from './utils/vendor/acl/appAbility.types';
|
|
202
204
|
export { Can } from './utils/vendor/acl/Can';
|
|
203
|
-
export type { AuthGuardProps } from './utils/vendor/auth/AuthGuard';
|
|
204
205
|
export { AuthGuard } from './utils/vendor/auth/AuthGuard';
|
|
205
206
|
export { AuthContext } from './utils/vendor/auth/auth.context';
|
|
206
|
-
export type { WithPrivateAuthGuardProps } from './utils/vendor/auth/withPrivateAuthGuard';
|
|
207
|
-
export { withPrivateAuthGuard } from './utils/vendor/auth/withPrivateAuthGuard';
|
|
208
207
|
export type { GeneralErrorCodes } from './utils/vendor/error-handling';
|
|
209
208
|
export { ApplicationException, ErrorHandler, SharedErrorHandler } from './utils/vendor/error-handling';
|
|
210
209
|
export type { RequestConfig, RequestInfo, Response, RestClient as IRestClient, } from './utils/vendor/rest-client.types';
|
package/dist/index.js
CHANGED
|
@@ -51,6 +51,7 @@ import { TimePicker } from "./components/inputs/DateTime/TimePicker/TimePicker.j
|
|
|
51
51
|
import { FileUpload } from "./components/inputs/File/FileUpload.js";
|
|
52
52
|
import { FileUploadContainer } from "./components/inputs/File/FileUploadContainer.js";
|
|
53
53
|
import { InputUpload } from "./components/inputs/File/InputUpload.js";
|
|
54
|
+
import { ProgressBar } from "./components/inputs/File/shared/ProgressBar.js";
|
|
54
55
|
import { FormField } from "./components/inputs/FormField/FormField.js";
|
|
55
56
|
import { NumberInput } from "./components/inputs/Input/NumberInput/NumberInput.js";
|
|
56
57
|
import { PasswordInput } from "./components/inputs/Input/PasswordInput/PasswordInput.js";
|
|
@@ -93,6 +94,7 @@ import { Tag } from "./components/text/Tag/Tag.js";
|
|
|
93
94
|
import { Typography } from "./components/text/Typography/Typography.js";
|
|
94
95
|
import { Confirmation } from "./config/confirmation.context.js";
|
|
95
96
|
import { ns, resources } from "./config/i18n.js";
|
|
97
|
+
import { LinkContext } from "./config/link.context.js";
|
|
96
98
|
import { UIRouter } from "./config/router.context.js";
|
|
97
99
|
import { UIConfig } from "./config/uiConfig.context.js";
|
|
98
100
|
import { UIStyle } from "./config/uiStyle.context.js";
|
|
@@ -133,7 +135,6 @@ import { AbilityContext } from "./utils/vendor/acl/ability.context.js";
|
|
|
133
135
|
import { Can } from "./utils/vendor/acl/Can.js";
|
|
134
136
|
import { AuthGuard } from "./utils/vendor/auth/AuthGuard.js";
|
|
135
137
|
import { AuthContext } from "./utils/vendor/auth/auth.context.js";
|
|
136
|
-
import { withPrivateAuthGuard } from "./utils/vendor/auth/withPrivateAuthGuard.js";
|
|
137
138
|
import { ApplicationException, ErrorHandler, SharedErrorHandler } from "./utils/vendor/error-handling.js";
|
|
138
139
|
import { RestInterceptor } from "./utils/vendor/rest-interceptor.js";
|
|
139
140
|
export {
|
|
@@ -199,6 +200,7 @@ export {
|
|
|
199
200
|
Inputs,
|
|
200
201
|
ItalicIcon,
|
|
201
202
|
Link,
|
|
203
|
+
LinkContext,
|
|
202
204
|
LinkIcon,
|
|
203
205
|
Loader,
|
|
204
206
|
Menu,
|
|
@@ -215,6 +217,7 @@ export {
|
|
|
215
217
|
PillButton,
|
|
216
218
|
PointerHorizontalIcon,
|
|
217
219
|
PointerVerticalIcon,
|
|
220
|
+
ProgressBar,
|
|
218
221
|
QueriesUtils,
|
|
219
222
|
QueryAutocomplete,
|
|
220
223
|
RadioGroup,
|
|
@@ -279,6 +282,5 @@ export {
|
|
|
279
282
|
useTableColumnConfig,
|
|
280
283
|
useTableNav,
|
|
281
284
|
useToast,
|
|
282
|
-
useTranslationMemo
|
|
283
|
-
withPrivateAuthGuard
|
|
285
|
+
useTranslationMemo
|
|
284
286
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
2
|
import { AppAbilities } from './appAbility.types';
|
|
3
|
-
|
|
3
|
+
interface AclGuardProps<TAppAbilities extends AppAbilities = AppAbilities> {
|
|
4
4
|
canUse: TAppAbilities;
|
|
5
5
|
redirectTo?: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
}
|
|
6
|
+
}
|
|
7
|
+
export declare const createAclGuard: <TAppAbilities extends AppAbilities = AppAbilities>() => ({ canUse, redirectTo, children }: PropsWithChildren<AclGuardProps<TAppAbilities>>) => import('react').ReactNode;
|
|
8
|
+
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { UIRouter } from "../../../config/router.context.js";
|
|
2
2
|
import { AbilityContext } from "./ability.context.js";
|
|
3
|
-
|
|
4
|
-
const createAclGuard = () => withPrivateAuthGuard(({ canUse, redirectTo = "/", children }) => {
|
|
3
|
+
const createAclGuard = () => ({ canUse, redirectTo = "/", children }) => {
|
|
5
4
|
const ability = AbilityContext.useAbility();
|
|
6
5
|
const { replace } = UIRouter.useUIRouter();
|
|
7
6
|
if (!ability.can(canUse[0], canUse[1])) {
|
|
@@ -9,7 +8,7 @@ const createAclGuard = () => withPrivateAuthGuard(({ canUse, redirectTo = "/", c
|
|
|
9
8
|
return null;
|
|
10
9
|
}
|
|
11
10
|
return children;
|
|
12
|
-
}
|
|
11
|
+
};
|
|
13
12
|
export {
|
|
14
13
|
createAclGuard
|
|
15
14
|
};
|
|
@@ -11,11 +11,12 @@ export declare namespace AuthContext {
|
|
|
11
11
|
updateTokens?: (accessToken: string | null, refreshToken?: string | null) => void;
|
|
12
12
|
accessToken?: string | null;
|
|
13
13
|
user?: TUser | null;
|
|
14
|
+
userPromise?: () => Promise<TUser | null>;
|
|
14
15
|
routes?: Routes;
|
|
15
16
|
loadingState?: ReactNode;
|
|
16
17
|
}
|
|
17
18
|
type ProviderProps<TUser = unknown> = Type<TUser>;
|
|
18
|
-
export const Provider: <TUser = unknown>({ isAuthenticated, isInitializing, logout, updateTokens, accessToken, user, routes, loadingState, children, }: PropsWithChildren<ProviderProps<TUser>>) => import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export const Provider: <TUser = unknown>({ isAuthenticated, isInitializing, logout, updateTokens, accessToken, user, userPromise, routes, loadingState, children, }: PropsWithChildren<ProviderProps<TUser>>) => import("react/jsx-runtime").JSX.Element;
|
|
19
20
|
export const useAuth: <TUser = unknown>() => Type<TUser>;
|
|
20
21
|
export {};
|
|
21
22
|
}
|
package/package.json
CHANGED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Typography } from "../../../text/Typography/Typography.js";
|
|
3
|
-
const FileProgressBar = ({ progress = 0 }) => {
|
|
4
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-center gap-file-upload-content-gap-progress-actions", children: [
|
|
5
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-fill flex-col items-start gap-2 py-progress-height-height", children: /* @__PURE__ */ jsxs("div", { className: "relative h-1 w-full", children: [
|
|
6
|
-
/* @__PURE__ */ jsx("div", { className: "h-1 w-full flex-shrink-0 rounded-xs bg-input-filled-idle" }),
|
|
7
|
-
/* @__PURE__ */ jsx(
|
|
8
|
-
"div",
|
|
9
|
-
{
|
|
10
|
-
className: "absolute top-0 left-0 h-1 flex-shrink-0 rounded-xs bg-interactive-contained-primary-idle transition-all duration-300",
|
|
11
|
-
style: { width: `${progress}%` }
|
|
12
|
-
}
|
|
13
|
-
)
|
|
14
|
-
] }) }),
|
|
15
|
-
/* @__PURE__ */ jsxs(
|
|
16
|
-
Typography,
|
|
17
|
-
{
|
|
18
|
-
variant: "default",
|
|
19
|
-
size: "label-2",
|
|
20
|
-
as: "span",
|
|
21
|
-
className: "text-center text-text-default-1",
|
|
22
|
-
children: [
|
|
23
|
-
progress,
|
|
24
|
-
"%"
|
|
25
|
-
]
|
|
26
|
-
}
|
|
27
|
-
)
|
|
28
|
-
] });
|
|
29
|
-
};
|
|
30
|
-
export {
|
|
31
|
-
FileProgressBar
|
|
32
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ComponentType, PropsWithChildren } from 'react';
|
|
2
|
-
import { AuthGuardProps } from './AuthGuard';
|
|
3
|
-
export interface WithPrivateAuthGuardProps {
|
|
4
|
-
privateAuthGuardProps?: Omit<AuthGuardProps, "type">;
|
|
5
|
-
}
|
|
6
|
-
export declare const withPrivateAuthGuard: <T extends PropsWithChildren & WithPrivateAuthGuardProps>(WrappedComponent: ComponentType<T & WithPrivateAuthGuardProps>) => ({ privateAuthGuardProps, ...props }: T & WithPrivateAuthGuardProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { AuthGuard } from "./AuthGuard.js";
|
|
3
|
-
const withPrivateAuthGuard = (WrappedComponent) => {
|
|
4
|
-
return ({ privateAuthGuardProps, ...props }) => {
|
|
5
|
-
return /* @__PURE__ */ jsx(
|
|
6
|
-
AuthGuard,
|
|
7
|
-
{
|
|
8
|
-
type: "private",
|
|
9
|
-
...privateAuthGuardProps,
|
|
10
|
-
children: /* @__PURE__ */ jsx(WrappedComponent, { ...props })
|
|
11
|
-
}
|
|
12
|
-
);
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
export {
|
|
16
|
-
withPrivateAuthGuard
|
|
17
|
-
};
|