@driveflux/ui 3.0.5 → 3.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bottom-sheet/BottomSheetProvider.js +157 -29
- package/dist/bottom-sheet/context.js +3 -4
- package/dist/bottom-sheet/index.js +0 -1
- package/dist/bottom-sheet/use-bottom-sheet.js +3 -2
- package/dist/bottom-sheet/utils.js +4 -5
- package/dist/chakra.js +0 -1
- package/dist/modal/ModalProvider.js +197 -59
- package/dist/modal/components/EnhancedModalCustomWrapper.js +127 -6
- package/dist/modal/components/EnhancedModalFooter.js +156 -5
- package/dist/modal/components/MinimalModalContent.js +88 -6
- package/dist/modal/components/StandardModalContent.js +359 -25
- package/dist/modal/context.js +7 -8
- package/dist/modal/index.js +0 -1
- package/dist/modal/use-enhanced-modal.js +1 -2
- package/dist/theme/colors.js +44 -63
- package/dist/theme/index.js +0 -1
- package/dist/toast/index.js +1 -3
- package/dist/toast/use-toast-result.js +161 -54
- package/dist/translations.js +5 -6
- package/dist/types.js +1 -2
- package/dist/utils/accessors.js +23 -11
- package/dist/utils/index.js +0 -1
- package/dist/utils/react.js +18 -12
- package/package.json +7 -7
|
@@ -1,85 +1,192 @@
|
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
|
+
if (key in obj) {
|
|
3
|
+
Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
} else {
|
|
10
|
+
obj[key] = value;
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
function _object_spread(target) {
|
|
15
|
+
for(var i = 1; i < arguments.length; i++){
|
|
16
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
17
|
+
var ownKeys = Object.keys(source);
|
|
18
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
19
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
20
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
ownKeys.forEach(function(key) {
|
|
24
|
+
_define_property(target, key, source[key]);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return target;
|
|
28
|
+
}
|
|
29
|
+
function ownKeys(object, enumerableOnly) {
|
|
30
|
+
var keys = Object.keys(object);
|
|
31
|
+
if (Object.getOwnPropertySymbols) {
|
|
32
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
33
|
+
if (enumerableOnly) {
|
|
34
|
+
symbols = symbols.filter(function(sym) {
|
|
35
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
keys.push.apply(keys, symbols);
|
|
39
|
+
}
|
|
40
|
+
return keys;
|
|
41
|
+
}
|
|
42
|
+
function _object_spread_props(target, source) {
|
|
43
|
+
source = source != null ? source : {};
|
|
44
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
45
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
46
|
+
} else {
|
|
47
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
48
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return target;
|
|
52
|
+
}
|
|
53
|
+
function _object_without_properties(source, excluded) {
|
|
54
|
+
if (source == null) return {};
|
|
55
|
+
var target = {}, sourceKeys, key, i;
|
|
56
|
+
if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
|
|
57
|
+
sourceKeys = Reflect.ownKeys(Object(source));
|
|
58
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
59
|
+
key = sourceKeys[i];
|
|
60
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
61
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
62
|
+
target[key] = source[key];
|
|
63
|
+
}
|
|
64
|
+
return target;
|
|
65
|
+
}
|
|
66
|
+
target = _object_without_properties_loose(source, excluded);
|
|
67
|
+
if (Object.getOwnPropertySymbols) {
|
|
68
|
+
sourceKeys = Object.getOwnPropertySymbols(source);
|
|
69
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
70
|
+
key = sourceKeys[i];
|
|
71
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
72
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
73
|
+
target[key] = source[key];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return target;
|
|
77
|
+
}
|
|
78
|
+
function _object_without_properties_loose(source, excluded) {
|
|
79
|
+
if (source == null) return {};
|
|
80
|
+
var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
|
|
81
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
82
|
+
key = sourceKeys[i];
|
|
83
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
84
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
85
|
+
target[key] = source[key];
|
|
86
|
+
}
|
|
87
|
+
return target;
|
|
88
|
+
}
|
|
1
89
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
90
|
import merge from 'lodash/merge.js';
|
|
3
91
|
import { useCallback } from 'react';
|
|
4
|
-
import { Box, ListItem, Text, UnorderedList, useToast
|
|
92
|
+
import { Box, ListItem, Text, UnorderedList, useToast } from '../chakra.js';
|
|
5
93
|
import { translations } from '../translations.js';
|
|
6
94
|
import { accessReactNode } from '../utils/accessors.js';
|
|
7
|
-
|
|
95
|
+
var accessStatus = function accessStatus(s, data) {
|
|
8
96
|
return typeof s === 'function' ? s(data) : s;
|
|
9
97
|
};
|
|
10
|
-
|
|
98
|
+
var defaultUseToastResultOptions = {
|
|
11
99
|
success: {
|
|
12
100
|
status: 'success',
|
|
13
101
|
title: translations.success,
|
|
14
102
|
description: translations.successDescription,
|
|
15
|
-
isClosable: true
|
|
103
|
+
isClosable: true
|
|
16
104
|
},
|
|
17
105
|
error: {
|
|
18
106
|
status: 'error',
|
|
19
107
|
title: translations.failed,
|
|
20
108
|
defaultDescription: translations.failedDescription,
|
|
21
109
|
showValidationErrors: true,
|
|
22
|
-
isClosable: true
|
|
23
|
-
}
|
|
110
|
+
isClosable: true
|
|
111
|
+
}
|
|
24
112
|
};
|
|
25
|
-
export
|
|
26
|
-
return Object.values(validation.fieldErrors).flatMap((v)
|
|
113
|
+
export var getValidationErrorsList = function getValidationErrorsList(validation) {
|
|
114
|
+
return Object.values(validation.fieldErrors).flatMap(function(v) {
|
|
115
|
+
return v.map(function(vd) {
|
|
116
|
+
return vd.message;
|
|
117
|
+
});
|
|
118
|
+
});
|
|
27
119
|
};
|
|
28
|
-
|
|
120
|
+
var accessOptions = function accessOptions(options, data) {
|
|
29
121
|
if (!options) {
|
|
30
122
|
return options;
|
|
31
123
|
}
|
|
32
|
-
return {
|
|
33
|
-
...options,
|
|
124
|
+
return _object_spread_props(_object_spread({}, options), {
|
|
34
125
|
status: accessStatus(options.status, data),
|
|
35
126
|
title: accessReactNode(options.title, data),
|
|
36
|
-
description: accessReactNode(options.description, data)
|
|
37
|
-
};
|
|
127
|
+
description: accessReactNode(options.description, data)
|
|
128
|
+
});
|
|
38
129
|
};
|
|
39
|
-
export
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
130
|
+
export var useToastResult = function useToastResult(options) {
|
|
131
|
+
var originalToast = useToast(accessOptions(options === null || options === void 0 ? void 0 : options.defaultOptions));
|
|
132
|
+
var toastProblem = useCallback(function(problem, providedOptions) {
|
|
133
|
+
var _merge = merge({}, defaultUseToastResultOptions.error, providedOptions), description = _merge.description, defaultDescription = _merge.defaultDescription, showValidationErrors = _merge.showValidationErrors, rest = _object_without_properties(_merge, [
|
|
134
|
+
"description",
|
|
135
|
+
"defaultDescription",
|
|
136
|
+
"showValidationErrors"
|
|
137
|
+
]);
|
|
138
|
+
var problemMessage = problem.message || defaultDescription;
|
|
139
|
+
return originalToast(_object_spread_props(_object_spread({}, accessOptions(rest, problem)), {
|
|
140
|
+
description: accessReactNode(description, problem) || /*#__PURE__*/ _jsxs(Box, {
|
|
141
|
+
children: [
|
|
142
|
+
problemMessage && /*#__PURE__*/ _jsx(Text, {
|
|
143
|
+
color: 'inherit',
|
|
144
|
+
children: problemMessage
|
|
145
|
+
}),
|
|
146
|
+
problem.validation && showValidationErrors && /*#__PURE__*/ _jsx(UnorderedList, {
|
|
147
|
+
color: 'inherit',
|
|
148
|
+
children: getValidationErrorsList(problem.validation).map(function(message, _i) {
|
|
149
|
+
return /*#__PURE__*/ _jsx(ListItem, {
|
|
150
|
+
children: message
|
|
151
|
+
}, message);
|
|
152
|
+
})
|
|
153
|
+
})
|
|
154
|
+
]
|
|
155
|
+
})
|
|
156
|
+
}));
|
|
157
|
+
}, [
|
|
158
|
+
originalToast
|
|
159
|
+
]);
|
|
160
|
+
var toastError = useCallback(function(providedOptions) {
|
|
161
|
+
var _$options = accessOptions(merge({}, defaultUseToastResultOptions.error, providedOptions));
|
|
162
|
+
return originalToast(_object_spread({}, _$options));
|
|
163
|
+
}, [
|
|
164
|
+
originalToast
|
|
165
|
+
]);
|
|
166
|
+
var toastSuccess = useCallback(function(providedOptions) {
|
|
167
|
+
var _$options = accessOptions(merge({}, defaultUseToastResultOptions.success, providedOptions));
|
|
168
|
+
return originalToast(_object_spread({}, _$options));
|
|
169
|
+
}, [
|
|
170
|
+
originalToast
|
|
171
|
+
]);
|
|
172
|
+
var toastResult = useCallback(function(result, generalToastOptions) {
|
|
173
|
+
var _$options = merge({}, defaultUseToastResultOptions, generalToastOptions);
|
|
174
|
+
var toastType = result.ok ? 'success' : 'error';
|
|
175
|
+
var toastOptions = _$options[toastType];
|
|
65
176
|
if (!toastOptions) {
|
|
66
177
|
return;
|
|
67
178
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
: toastOptions, result.val),
|
|
72
|
-
};
|
|
73
|
-
return result.ok
|
|
74
|
-
? toastSuccess(finalToastOptions)
|
|
75
|
-
: toastProblem(result.val, finalToastOptions);
|
|
76
|
-
}, [toastProblem, toastSuccess]);
|
|
77
|
-
return {
|
|
179
|
+
var finalToastOptions = _object_spread({}, accessOptions(typeof toastOptions === 'boolean' ? defaultUseToastResultOptions[toastType] : toastOptions, result.val));
|
|
180
|
+
return result.ok ? toastSuccess(finalToastOptions) : toastProblem(result.val, finalToastOptions);
|
|
181
|
+
}, [
|
|
78
182
|
toastProblem,
|
|
79
|
-
toastSuccess
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
183
|
+
toastSuccess
|
|
184
|
+
]);
|
|
185
|
+
return {
|
|
186
|
+
toastProblem: toastProblem,
|
|
187
|
+
toastSuccess: toastSuccess,
|
|
188
|
+
toastResult: toastResult,
|
|
189
|
+
toastError: toastError,
|
|
190
|
+
toast: originalToast
|
|
83
191
|
};
|
|
84
192
|
};
|
|
85
|
-
//# sourceMappingURL=use-toast-result.js.map
|
package/dist/translations.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { singleton } from '@driveflux/singleton';
|
|
2
|
-
export
|
|
2
|
+
export var translations = singleton('uiTranslations', {
|
|
3
3
|
success: 'Success',
|
|
4
4
|
successDescription: 'Operation completed successfully.',
|
|
5
5
|
failed: 'Operation Failed',
|
|
@@ -7,16 +7,15 @@ export const translations = singleton('uiTranslations', {
|
|
|
7
7
|
cancel: 'Cancel',
|
|
8
8
|
confirm: 'Confirm',
|
|
9
9
|
close: 'Close',
|
|
10
|
-
ok: 'Ok'
|
|
10
|
+
ok: 'Ok'
|
|
11
11
|
});
|
|
12
|
-
export
|
|
13
|
-
for
|
|
12
|
+
export var setTranslations = function setTranslations(ts) {
|
|
13
|
+
for(var key in ts){
|
|
14
14
|
// TODO
|
|
15
15
|
// @ts-expect-error
|
|
16
16
|
translations[key] = ts[key];
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
|
-
export
|
|
19
|
+
export var setTranslation = function setTranslation(key, value) {
|
|
20
20
|
translations[key] = value;
|
|
21
21
|
};
|
|
22
|
-
//# sourceMappingURL=translations.js.map
|
package/dist/types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export {};
|
|
2
|
-
//# sourceMappingURL=types.js.map
|
|
1
|
+
export { };
|
package/dist/utils/accessors.js
CHANGED
|
@@ -1,20 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
function _type_of(obj) {
|
|
2
|
+
"@swc/helpers - typeof";
|
|
3
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
4
|
+
}
|
|
5
|
+
export var accessSelf = function accessSelf(s, data, defaultValue) {
|
|
2
6
|
if (!s) {
|
|
3
7
|
return defaultValue;
|
|
4
8
|
}
|
|
5
9
|
return typeof s === 'function' ? s(data) : s;
|
|
6
10
|
};
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
export var accessBoolean = function accessBoolean(s, data, defaultBoolean) {
|
|
12
|
+
return accessSelf(s, data, defaultBoolean);
|
|
13
|
+
};
|
|
14
|
+
export var accessString = function accessString(s, data, defaultText) {
|
|
15
|
+
return accessSelf(s, data, defaultText);
|
|
16
|
+
};
|
|
17
|
+
export var accessStringOrNull = function accessStringOrNull(s, data) {
|
|
18
|
+
var defaultText = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : null;
|
|
19
|
+
return accessSelf(s, data, defaultText);
|
|
20
|
+
};
|
|
21
|
+
export var accessQuery = function accessQuery(s, data, defaultQuery) {
|
|
22
|
+
return accessSelf(s, data, defaultQuery);
|
|
23
|
+
};
|
|
24
|
+
export var accessReactNode = function accessReactNode(s, data, defaultNode) {
|
|
25
|
+
return accessSelf(s, data, defaultNode);
|
|
26
|
+
};
|
|
27
|
+
export var accessFunction = function accessFunction(f, data, defaultFunction) {
|
|
13
28
|
if (!f) {
|
|
14
29
|
return defaultFunction;
|
|
15
30
|
}
|
|
16
|
-
return typeof f === 'object' && 'generateFunction' in f
|
|
17
|
-
? f.generateFunction(data)
|
|
18
|
-
: f;
|
|
31
|
+
return (typeof f === "undefined" ? "undefined" : _type_of(f)) === 'object' && 'generateFunction' in f ? f.generateFunction(data) : f;
|
|
19
32
|
};
|
|
20
|
-
//# sourceMappingURL=accessors.js.map
|
package/dist/utils/index.js
CHANGED
package/dist/utils/react.js
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
function _instanceof(left, right) {
|
|
2
|
+
"@swc/helpers - instanceof";
|
|
3
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
4
|
+
return !!right[Symbol.hasInstance](left);
|
|
5
|
+
} else {
|
|
6
|
+
return left instanceof right;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
import { isValidElement } from 'react';
|
|
2
10
|
export function isReactComponent(Component) {
|
|
3
|
-
return
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
(Component.prototype instanceof Component ||
|
|
7
|
-
Component.displayName !== undefined));
|
|
11
|
+
return typeof Component === 'function' && // TODO
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- React component, it's fine
|
|
13
|
+
(_instanceof(Component.prototype, Component) || Component.displayName !== undefined);
|
|
8
14
|
}
|
|
9
15
|
export function isReactElement(element) {
|
|
10
16
|
// TODO
|
|
@@ -12,19 +18,19 @@ export function isReactElement(element) {
|
|
|
12
18
|
return isValidElement(element);
|
|
13
19
|
}
|
|
14
20
|
export function isReactNode(node) {
|
|
15
|
-
if (
|
|
16
|
-
// TODO
|
|
21
|
+
if (// TODO
|
|
17
22
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- isValidElement is a validation function
|
|
18
23
|
isValidElement(node) || // Check if it's a React element
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
typeof node === 'string' || // Check if it's a string
|
|
25
|
+
typeof node === 'number' // Check if it's a number
|
|
21
26
|
) {
|
|
22
27
|
return true;
|
|
23
28
|
}
|
|
24
29
|
// Check if it's an array of React nodes
|
|
25
|
-
if (Array.isArray(node) && node.every((element)
|
|
30
|
+
if (Array.isArray(node) && node.every(function(element) {
|
|
31
|
+
return isReactNode(element);
|
|
32
|
+
})) {
|
|
26
33
|
return true;
|
|
27
34
|
}
|
|
28
35
|
return false;
|
|
29
36
|
}
|
|
30
|
-
//# sourceMappingURL=react.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@driveflux/ui",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -37,20 +37,20 @@
|
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@chakra-ui/react": "^2.10.9",
|
|
40
|
-
"@driveflux/icons": "3.0.
|
|
41
|
-
"@driveflux/singleton": "3.0.
|
|
40
|
+
"@driveflux/icons": "3.0.3",
|
|
41
|
+
"@driveflux/singleton": "3.0.3",
|
|
42
42
|
"@emotion/react": "^11.14.0",
|
|
43
43
|
"@emotion/styled": "^11.14.1",
|
|
44
|
-
"framer-motion": "^12.
|
|
44
|
+
"framer-motion": "^12.40.0",
|
|
45
45
|
"lodash": "^4.18.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@driveflux/fab": "4.0.
|
|
48
|
+
"@driveflux/fab": "4.0.3",
|
|
49
49
|
"@driveflux/problem": "6.0.3",
|
|
50
|
-
"@driveflux/result": "6.0.
|
|
50
|
+
"@driveflux/result": "6.0.4",
|
|
51
51
|
"@driveflux/tsconfig": "3.0.2",
|
|
52
52
|
"@swc/cli": "^0.8.1",
|
|
53
|
-
"@swc/core": "^1.15.
|
|
53
|
+
"@swc/core": "^1.15.40",
|
|
54
54
|
"@types/lodash": "^4.17.24",
|
|
55
55
|
"@types/node": "^25.9.1",
|
|
56
56
|
"@types/react": "19.2.15",
|