@driveflux/ui 1.0.14 → 1.1.1
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.d.ts +4 -0
- package/dist/bottom-sheet/BottomSheetProvider.d.ts.map +1 -0
- package/dist/bottom-sheet/BottomSheetProvider.js +190 -0
- package/dist/bottom-sheet/context.d.ts +15 -0
- package/dist/bottom-sheet/context.d.ts.map +1 -0
- package/dist/bottom-sheet/context.js +6 -0
- package/dist/bottom-sheet/index.d.ts +4 -0
- package/dist/bottom-sheet/index.d.ts.map +1 -0
- package/dist/bottom-sheet/index.js +3 -0
- package/dist/bottom-sheet/use-bottom-sheet.d.ts +6 -0
- package/dist/bottom-sheet/use-bottom-sheet.d.ts.map +1 -0
- package/dist/bottom-sheet/use-bottom-sheet.js +5 -0
- package/dist/bottom-sheet/utils.d.ts +2 -0
- package/dist/bottom-sheet/utils.d.ts.map +1 -0
- package/dist/bottom-sheet/utils.js +15 -0
- package/dist/chakra.d.ts.map +1 -1
- package/dist/chakra.js +1 -0
- package/dist/modal/ModalProvider.d.ts.map +1 -1
- package/dist/modal/ModalProvider.js +1 -4
- package/dist/modal/components/EnhancedModalCustomWrapper.d.ts.map +1 -1
- package/dist/modal/components/EnhancedModalFooter.d.ts +2 -2
- package/dist/modal/components/EnhancedModalFooter.d.ts.map +1 -1
- package/dist/modal/components/MinimalModalContent.d.ts.map +1 -1
- package/dist/modal/components/StandardModalContent.d.ts.map +1 -1
- package/dist/modal/context.d.ts.map +1 -1
- package/dist/modal/use-enhanced-modal.d.ts.map +1 -1
- package/dist/theme/colors.d.ts.map +1 -1
- package/dist/theme/colors.js +36 -36
- package/dist/toast/index.d.ts.map +1 -1
- package/dist/toast/use-toast-result.d.ts +2 -2
- package/dist/toast/use-toast-result.d.ts.map +1 -1
- package/dist/toast/use-toast-result.js +2 -2
- package/dist/translations.d.ts.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/accessors.d.ts.map +1 -1
- package/dist/utils/react.d.ts.map +1 -1
- package/package.json +44 -43
- package/.eslintrc.json +0 -3
- package/.swcrc +0 -14
- package/.turbo/turbo-build.log +0 -11
- package/CHANGELOG.md +0 -159
- package/dist/cjs/chakra.js +0 -18
- package/dist/cjs/index.js +0 -20
- package/dist/cjs/modal/ModalProvider.js +0 -255
- package/dist/cjs/modal/components/EnhancedModalCustomWrapper.js +0 -139
- package/dist/cjs/modal/components/EnhancedModalFooter.js +0 -163
- package/dist/cjs/modal/components/MinimalModalContent.js +0 -94
- package/dist/cjs/modal/components/StandardModalContent.js +0 -359
- package/dist/cjs/modal/context.js +0 -20
- package/dist/cjs/modal/index.js +0 -48
- package/dist/cjs/modal/use-enhanced-modal.js +0 -15
- package/dist/cjs/package.json +0 -3
- package/dist/cjs/theme/colors.js +0 -147
- package/dist/cjs/theme/index.js +0 -18
- package/dist/cjs/toast/index.js +0 -19
- package/dist/cjs/toast/use-toast-result.js +0 -210
- package/dist/cjs/translations.js +0 -42
- package/dist/cjs/types.js +0 -4
- package/dist/cjs/utils/accessors.js +0 -65
- package/dist/cjs/utils/index.js +0 -19
- package/dist/cjs/utils/react.js +0 -56
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -3
- package/index.cjs +0 -1
- package/index.d.ts +0 -1
- package/modal.cjs +0 -1
- package/modal.d.ts +0 -1
- package/src/chakra.ts +0 -2
- package/src/index.ts +0 -4
- package/src/modal/ModalProvider.tsx +0 -143
- package/src/modal/components/EnhancedModalCustomWrapper.tsx +0 -39
- package/src/modal/components/EnhancedModalFooter.tsx +0 -51
- package/src/modal/components/MinimalModalContent.tsx +0 -24
- package/src/modal/components/StandardModalContent.tsx +0 -65
- package/src/modal/context.tsx +0 -81
- package/src/modal/index.ts +0 -7
- package/src/modal/use-enhanced-modal.ts +0 -7
- package/src/theme/colors.ts +0 -179
- package/src/theme/index.ts +0 -1
- package/src/toast/index.ts +0 -3
- package/src/toast/use-toast-result.tsx +0 -168
- package/src/translations.ts +0 -25
- package/src/types.ts +0 -22
- package/src/utils/accessors.ts +0 -64
- package/src/utils/index.ts +0 -2
- package/src/utils/react.ts +0 -35
- package/theme.cjs +0 -1
- package/theme.d.ts +0 -1
- package/toast.cjs +0 -1
- package/toast.d.ts +0 -1
- package/translations.cjs +0 -1
- package/translations.d.ts +0 -1
- package/tsconfig.json +0 -14
- package/tsconfig.tsbuildinfo +0 -1
- package/utils.cjs +0 -1
- package/utils.d.ts +0 -1
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
getValidationErrorsList: function() {
|
|
13
|
-
return getValidationErrorsList;
|
|
14
|
-
},
|
|
15
|
-
useToastResult: function() {
|
|
16
|
-
return useToastResult;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
var _jsxruntime = require("react/jsx-runtime");
|
|
20
|
-
var _merge = /*#__PURE__*/ _interop_require_default(require("lodash/merge.js"));
|
|
21
|
-
var _react = require("react");
|
|
22
|
-
var _chakra = require("../chakra.js");
|
|
23
|
-
var _translations = require("../translations.js");
|
|
24
|
-
var _accessors = require("../utils/accessors.js");
|
|
25
|
-
function _define_property(obj, key, value) {
|
|
26
|
-
if (key in obj) {
|
|
27
|
-
Object.defineProperty(obj, key, {
|
|
28
|
-
value: value,
|
|
29
|
-
enumerable: true,
|
|
30
|
-
configurable: true,
|
|
31
|
-
writable: true
|
|
32
|
-
});
|
|
33
|
-
} else {
|
|
34
|
-
obj[key] = value;
|
|
35
|
-
}
|
|
36
|
-
return obj;
|
|
37
|
-
}
|
|
38
|
-
function _interop_require_default(obj) {
|
|
39
|
-
return obj && obj.__esModule ? obj : {
|
|
40
|
-
default: obj
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
function _object_spread(target) {
|
|
44
|
-
for(var i = 1; i < arguments.length; i++){
|
|
45
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
46
|
-
var ownKeys = Object.keys(source);
|
|
47
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
48
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
49
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
50
|
-
}));
|
|
51
|
-
}
|
|
52
|
-
ownKeys.forEach(function(key) {
|
|
53
|
-
_define_property(target, key, source[key]);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
return target;
|
|
57
|
-
}
|
|
58
|
-
function ownKeys(object, enumerableOnly) {
|
|
59
|
-
var keys = Object.keys(object);
|
|
60
|
-
if (Object.getOwnPropertySymbols) {
|
|
61
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
62
|
-
if (enumerableOnly) {
|
|
63
|
-
symbols = symbols.filter(function(sym) {
|
|
64
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
keys.push.apply(keys, symbols);
|
|
68
|
-
}
|
|
69
|
-
return keys;
|
|
70
|
-
}
|
|
71
|
-
function _object_spread_props(target, source) {
|
|
72
|
-
source = source != null ? source : {};
|
|
73
|
-
if (Object.getOwnPropertyDescriptors) {
|
|
74
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
75
|
-
} else {
|
|
76
|
-
ownKeys(Object(source)).forEach(function(key) {
|
|
77
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
return target;
|
|
81
|
-
}
|
|
82
|
-
function _object_without_properties(source, excluded) {
|
|
83
|
-
if (source == null) return {};
|
|
84
|
-
var target = _object_without_properties_loose(source, excluded);
|
|
85
|
-
var key, i;
|
|
86
|
-
if (Object.getOwnPropertySymbols) {
|
|
87
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
88
|
-
for(i = 0; i < sourceSymbolKeys.length; i++){
|
|
89
|
-
key = sourceSymbolKeys[i];
|
|
90
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
91
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
92
|
-
target[key] = source[key];
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return target;
|
|
96
|
-
}
|
|
97
|
-
function _object_without_properties_loose(source, excluded) {
|
|
98
|
-
if (source == null) return {};
|
|
99
|
-
var target = {};
|
|
100
|
-
var sourceKeys = Object.keys(source);
|
|
101
|
-
var key, i;
|
|
102
|
-
for(i = 0; i < sourceKeys.length; i++){
|
|
103
|
-
key = sourceKeys[i];
|
|
104
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
105
|
-
target[key] = source[key];
|
|
106
|
-
}
|
|
107
|
-
return target;
|
|
108
|
-
}
|
|
109
|
-
var accessStatus = function(s, data) {
|
|
110
|
-
return typeof s === 'function' ? s(data) : s;
|
|
111
|
-
};
|
|
112
|
-
var defaultUseToastResultOptions = {
|
|
113
|
-
success: {
|
|
114
|
-
status: 'success',
|
|
115
|
-
title: _translations.translations.success,
|
|
116
|
-
description: _translations.translations.successDescription,
|
|
117
|
-
isClosable: true
|
|
118
|
-
},
|
|
119
|
-
error: {
|
|
120
|
-
status: 'error',
|
|
121
|
-
title: _translations.translations.failed,
|
|
122
|
-
defaultDescription: _translations.translations.failedDescription,
|
|
123
|
-
showValidationErrors: true,
|
|
124
|
-
isClosable: true
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
var getValidationErrorsList = function(validation) {
|
|
128
|
-
return Object.values(validation.fieldErrors).map(function(v) {
|
|
129
|
-
return v.map(function(vd) {
|
|
130
|
-
return vd.message;
|
|
131
|
-
});
|
|
132
|
-
}).flat();
|
|
133
|
-
};
|
|
134
|
-
var accessOptions = function(options, data) {
|
|
135
|
-
if (!options) {
|
|
136
|
-
return options;
|
|
137
|
-
}
|
|
138
|
-
return _object_spread_props(_object_spread({}, options), {
|
|
139
|
-
status: accessStatus(options.status, data),
|
|
140
|
-
title: (0, _accessors.accessReactNode)(options.title, data),
|
|
141
|
-
description: (0, _accessors.accessReactNode)(options.description, data)
|
|
142
|
-
});
|
|
143
|
-
};
|
|
144
|
-
var useToastResult = function(options) {
|
|
145
|
-
var originalToast = (0, _chakra.useToast)(accessOptions(options === null || options === void 0 ? void 0 : options.defaultOptions));
|
|
146
|
-
var toastProblem = (0, _react.useCallback)(function(problem, providedOptions) {
|
|
147
|
-
var _merge1 = (0, _merge.default)({}, defaultUseToastResultOptions.error, providedOptions), description = _merge1.description, defaultDescription = _merge1.defaultDescription, showValidationErrors = _merge1.showValidationErrors, rest = _object_without_properties(_merge1, [
|
|
148
|
-
"description",
|
|
149
|
-
"defaultDescription",
|
|
150
|
-
"showValidationErrors"
|
|
151
|
-
]);
|
|
152
|
-
var problemMessage = problem.message || defaultDescription;
|
|
153
|
-
return originalToast(_object_spread_props(_object_spread({}, accessOptions(rest, problem)), {
|
|
154
|
-
description: (0, _accessors.accessReactNode)(description, problem) || /*#__PURE__*/ (0, _jsxruntime.jsx)(_chakra.Box, {
|
|
155
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
156
|
-
children: [
|
|
157
|
-
problemMessage && /*#__PURE__*/ (0, _jsxruntime.jsx)(_chakra.Text, {
|
|
158
|
-
color: 'inherit',
|
|
159
|
-
children: problemMessage
|
|
160
|
-
}),
|
|
161
|
-
problem.validation && showValidationErrors && /*#__PURE__*/ (0, _jsxruntime.jsx)(_chakra.UnorderedList, {
|
|
162
|
-
color: 'inherit',
|
|
163
|
-
children: getValidationErrorsList(problem.validation).map(function(message, i) {
|
|
164
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_chakra.ListItem, {
|
|
165
|
-
children: message
|
|
166
|
-
}, i);
|
|
167
|
-
})
|
|
168
|
-
})
|
|
169
|
-
]
|
|
170
|
-
})
|
|
171
|
-
})
|
|
172
|
-
}));
|
|
173
|
-
}, [
|
|
174
|
-
originalToast
|
|
175
|
-
]);
|
|
176
|
-
var toastError = (0, _react.useCallback)(function(providedOptions) {
|
|
177
|
-
var _$options = accessOptions((0, _merge.default)({}, defaultUseToastResultOptions.error, providedOptions));
|
|
178
|
-
return originalToast(_object_spread({}, _$options));
|
|
179
|
-
}, [
|
|
180
|
-
originalToast
|
|
181
|
-
]);
|
|
182
|
-
var toastSuccess = (0, _react.useCallback)(function(providedOptions) {
|
|
183
|
-
var _$options = accessOptions((0, _merge.default)({}, defaultUseToastResultOptions.success, providedOptions));
|
|
184
|
-
return originalToast(_object_spread({}, _$options));
|
|
185
|
-
}, [
|
|
186
|
-
originalToast
|
|
187
|
-
]);
|
|
188
|
-
var toastResult = (0, _react.useCallback)(function(result, generalToastOptions) {
|
|
189
|
-
var _$options = (0, _merge.default)({}, defaultUseToastResultOptions, generalToastOptions);
|
|
190
|
-
var toastType = result.ok ? 'success' : 'error';
|
|
191
|
-
var toastOptions = _$options[toastType];
|
|
192
|
-
if (!toastOptions) {
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
var finalToastOptions = _object_spread({}, accessOptions(typeof toastOptions === 'boolean' ? defaultUseToastResultOptions[toastType] : toastOptions, result.val));
|
|
196
|
-
console.log('finalToastOptions????', finalToastOptions);
|
|
197
|
-
return result.ok ? toastSuccess(finalToastOptions) : toastProblem(result.val, finalToastOptions);
|
|
198
|
-
}, [
|
|
199
|
-
originalToast,
|
|
200
|
-
toastProblem,
|
|
201
|
-
toastSuccess
|
|
202
|
-
]);
|
|
203
|
-
return {
|
|
204
|
-
toastProblem: toastProblem,
|
|
205
|
-
toastSuccess: toastSuccess,
|
|
206
|
-
toastResult: toastResult,
|
|
207
|
-
toastError: toastError,
|
|
208
|
-
toast: originalToast
|
|
209
|
-
};
|
|
210
|
-
};
|
package/dist/cjs/translations.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
setTranslation: function() {
|
|
13
|
-
return setTranslation;
|
|
14
|
-
},
|
|
15
|
-
setTranslations: function() {
|
|
16
|
-
return setTranslations;
|
|
17
|
-
},
|
|
18
|
-
translations: function() {
|
|
19
|
-
return translations;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
var _singleton = require("@driveflux/singleton");
|
|
23
|
-
var translations = (0, _singleton.singleton)('uiTranslations', {
|
|
24
|
-
success: 'Success',
|
|
25
|
-
successDescription: 'Operation completed successfully.',
|
|
26
|
-
failed: 'Operation Failed',
|
|
27
|
-
failedDescription: 'There was a problem while performing this operation.',
|
|
28
|
-
cancel: 'Cancel',
|
|
29
|
-
confirm: 'Confirm',
|
|
30
|
-
close: 'Close',
|
|
31
|
-
ok: 'Ok'
|
|
32
|
-
});
|
|
33
|
-
var setTranslations = function(ts) {
|
|
34
|
-
for(var key in ts){
|
|
35
|
-
// TODO
|
|
36
|
-
// @ts-expect-error
|
|
37
|
-
translations[key] = ts[key];
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
var setTranslation = function(key, value) {
|
|
41
|
-
translations[key] = value;
|
|
42
|
-
};
|
package/dist/cjs/types.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
accessBoolean: function() {
|
|
13
|
-
return accessBoolean;
|
|
14
|
-
},
|
|
15
|
-
accessFunction: function() {
|
|
16
|
-
return accessFunction;
|
|
17
|
-
},
|
|
18
|
-
accessQuery: function() {
|
|
19
|
-
return accessQuery;
|
|
20
|
-
},
|
|
21
|
-
accessReactNode: function() {
|
|
22
|
-
return accessReactNode;
|
|
23
|
-
},
|
|
24
|
-
accessSelf: function() {
|
|
25
|
-
return accessSelf;
|
|
26
|
-
},
|
|
27
|
-
accessString: function() {
|
|
28
|
-
return accessString;
|
|
29
|
-
},
|
|
30
|
-
accessStringOrNull: function() {
|
|
31
|
-
return accessStringOrNull;
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
function _type_of(obj) {
|
|
35
|
-
"@swc/helpers - typeof";
|
|
36
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
37
|
-
}
|
|
38
|
-
var accessSelf = function(s, data, defaultValue) {
|
|
39
|
-
if (!s) {
|
|
40
|
-
return defaultValue;
|
|
41
|
-
}
|
|
42
|
-
return typeof s === 'function' ? s(data) : s;
|
|
43
|
-
};
|
|
44
|
-
var accessBoolean = function(s, data, defaultBoolean) {
|
|
45
|
-
return accessSelf(s, data, defaultBoolean);
|
|
46
|
-
};
|
|
47
|
-
var accessString = function(s, data, defaultText) {
|
|
48
|
-
return accessSelf(s, data, defaultText);
|
|
49
|
-
};
|
|
50
|
-
var accessStringOrNull = function(s, data) {
|
|
51
|
-
var defaultText = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : null;
|
|
52
|
-
return accessSelf(s, data, defaultText);
|
|
53
|
-
};
|
|
54
|
-
var accessQuery = function(s, data, defaultQuery) {
|
|
55
|
-
return accessSelf(s, data, defaultQuery);
|
|
56
|
-
};
|
|
57
|
-
var accessReactNode = function(s, data, defaultNode) {
|
|
58
|
-
return accessSelf(s, data, defaultNode);
|
|
59
|
-
};
|
|
60
|
-
var accessFunction = function(f, data, defaultFunction) {
|
|
61
|
-
if (!f) {
|
|
62
|
-
return defaultFunction;
|
|
63
|
-
}
|
|
64
|
-
return (typeof f === "undefined" ? "undefined" : _type_of(f)) === 'object' && 'generateFunction' in f ? f.generateFunction(data) : f;
|
|
65
|
-
};
|
package/dist/cjs/utils/index.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
_export_star(require("./accessors.js"), exports);
|
|
6
|
-
_export_star(require("./react.js"), exports);
|
|
7
|
-
function _export_star(from, to) {
|
|
8
|
-
Object.keys(from).forEach(function(k) {
|
|
9
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
10
|
-
Object.defineProperty(to, k, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function() {
|
|
13
|
-
return from[k];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
return from;
|
|
19
|
-
}
|
package/dist/cjs/utils/react.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
isReactComponent: function() {
|
|
13
|
-
return isReactComponent;
|
|
14
|
-
},
|
|
15
|
-
isReactElement: function() {
|
|
16
|
-
return isReactElement;
|
|
17
|
-
},
|
|
18
|
-
isReactNode: function() {
|
|
19
|
-
return isReactNode;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
var _react = require("react");
|
|
23
|
-
function _instanceof(left, right) {
|
|
24
|
-
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
25
|
-
return !!right[Symbol.hasInstance](left);
|
|
26
|
-
} else {
|
|
27
|
-
return left instanceof right;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function isReactComponent(Component) {
|
|
31
|
-
return typeof Component === 'function' && // TODO
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- React component, it's fine
|
|
33
|
-
(_instanceof(Component.prototype, Component) || Component.displayName !== undefined);
|
|
34
|
-
}
|
|
35
|
-
function isReactElement(element) {
|
|
36
|
-
// TODO
|
|
37
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- isValidElement is a validation function
|
|
38
|
-
return (0, _react.isValidElement)(element);
|
|
39
|
-
}
|
|
40
|
-
function isReactNode(node) {
|
|
41
|
-
if (// TODO
|
|
42
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- isValidElement is a validation function
|
|
43
|
-
(0, _react.isValidElement)(node) || // Check if it's a React element
|
|
44
|
-
typeof node === 'string' || // Check if it's a string
|
|
45
|
-
typeof node === 'number' // Check if it's a number
|
|
46
|
-
) {
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
// Check if it's an array of React nodes
|
|
50
|
-
if (Array.isArray(node) && node.every(function(element) {
|
|
51
|
-
return isReactNode(element);
|
|
52
|
-
})) {
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
return false;
|
|
56
|
-
}
|
package/dist/index.d.ts
DELETED
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,aAAa,CAAA"}
|
package/dist/index.js
DELETED
package/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('./dist/cjs/index.js')
|
package/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './dist/index'
|
package/modal.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('./dist/cjs/modal/index.js')
|
package/modal.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './dist/modal/index'
|
package/src/chakra.ts
DELETED
package/src/index.ts
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import isEmpty from 'lodash/isEmpty.js'
|
|
2
|
-
import { useCallback, useMemo, useState, type FC, type PropsWithChildren } from 'react'
|
|
3
|
-
import {
|
|
4
|
-
Modal,
|
|
5
|
-
ModalContent,
|
|
6
|
-
ModalOverlay,
|
|
7
|
-
useDisclosure
|
|
8
|
-
} from '../chakra.js'
|
|
9
|
-
import { isReactNode } from '../utils/react.js'
|
|
10
|
-
import MinimalModalContent from './components/MinimalModalContent.js'
|
|
11
|
-
import StandardModalContent from './components/StandardModalContent.js'
|
|
12
|
-
import { ModalContext, type ModalCloseOptions, type ModalContentConfig, type ModalContextState, type ModalControlProps, type ModalOpenOptions, type ModalOptions, type ModalUpdateOptions } from './context.js'
|
|
13
|
-
|
|
14
|
-
const getModalComponent = (modalContentConfig: ModalContentConfig, controls: ModalControlProps) => {
|
|
15
|
-
const otherProps = modalContentConfig.contentProps || {}
|
|
16
|
-
switch (modalContentConfig.type) {
|
|
17
|
-
case 'standard': {
|
|
18
|
-
return <StandardModalContent controls={controls} modalContentConfig={modalContentConfig} {...otherProps} />
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
case 'minimal': {
|
|
22
|
-
return <MinimalModalContent controls={controls} modalContentConfig={modalContentConfig} {...otherProps} />
|
|
23
|
-
}
|
|
24
|
-
case 'custom':
|
|
25
|
-
return isReactNode(modalContentConfig.content) ? modalContentConfig.content : <modalContentConfig.content open={open} close={close} {...otherProps} />
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const isModalOpenOptions = (options?: ModalOpenOptions | ModalContentConfig): options is ModalOpenOptions => {
|
|
30
|
-
return (options as ModalOpenOptions)?.modalContentConfig !== undefined
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const ModalProvider: FC<PropsWithChildren> = ({ children }) => {
|
|
34
|
-
const { isOpen, onClose: onCloseRaw, onOpen: onOpenRaw } = useDisclosure()
|
|
35
|
-
const [modalContentConfig, setModalContentConfig] = useState<ModalContentConfig | undefined>()
|
|
36
|
-
const [modalOptions, setModalOptions] = useState<ModalOptions | undefined>()
|
|
37
|
-
const [modalState, setModalState] = useState<any>()
|
|
38
|
-
|
|
39
|
-
const onClose = useCallback((options?: ModalCloseOptions) => {
|
|
40
|
-
onCloseRaw()
|
|
41
|
-
|
|
42
|
-
if (modalOptions?.onClose) {
|
|
43
|
-
modalOptions.onClose()
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (!options?.keepModalContentConfig) {
|
|
47
|
-
setModalContentConfig(undefined)
|
|
48
|
-
setModalOptions(undefined)
|
|
49
|
-
setModalState(undefined)
|
|
50
|
-
}
|
|
51
|
-
}, [modalOptions])
|
|
52
|
-
|
|
53
|
-
const onOpen = useCallback((modalContentConfigOrOptions?: ModalOpenOptions | ModalContentConfig) => {
|
|
54
|
-
let newModalContentConfig: ModalContentConfig | undefined
|
|
55
|
-
let newModalSate: any
|
|
56
|
-
let newModalOptions: ModalOptions | undefined
|
|
57
|
-
// Here, we know we're passing the global options object
|
|
58
|
-
if (isModalOpenOptions(modalContentConfigOrOptions)) {
|
|
59
|
-
newModalContentConfig = modalContentConfigOrOptions.modalContentConfig
|
|
60
|
-
newModalSate = modalContentConfigOrOptions.modalContentConfig.initialModalState
|
|
61
|
-
newModalOptions = modalContentConfigOrOptions
|
|
62
|
-
}
|
|
63
|
-
// we will set the state only when we're passing the modal content config. Maybe the modal
|
|
64
|
-
// was closed with keepModalContentConfig set to true, so we don't want to override the state
|
|
65
|
-
else if (modalContentConfigOrOptions) {
|
|
66
|
-
newModalContentConfig = modalContentConfigOrOptions
|
|
67
|
-
newModalSate = undefined
|
|
68
|
-
newModalOptions = undefined
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
setModalContentConfig((oldModalContentConfig) => {
|
|
72
|
-
const modalContentConfig = newModalContentConfig || oldModalContentConfig
|
|
73
|
-
|
|
74
|
-
if (modalContentConfig) {
|
|
75
|
-
onOpenRaw()
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return modalContentConfig
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
setModalState(newModalSate)
|
|
82
|
-
setModalOptions(newModalOptions)
|
|
83
|
-
}, [])
|
|
84
|
-
|
|
85
|
-
const update = useCallback((updateOptions: ModalUpdateOptions) => {
|
|
86
|
-
if (!updateOptions || isEmpty(updateOptions)) {
|
|
87
|
-
return
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
setModalContentConfig((oldModalContentConfig) => {
|
|
91
|
-
if (!oldModalContentConfig) {
|
|
92
|
-
return oldModalContentConfig
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return {
|
|
96
|
-
...oldModalContentConfig,
|
|
97
|
-
...updateOptions.modalContentConfig,
|
|
98
|
-
contentProps: {
|
|
99
|
-
...updateOptions.contentProps,
|
|
100
|
-
...oldModalContentConfig.contentProps,
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
})
|
|
104
|
-
}, [])
|
|
105
|
-
|
|
106
|
-
const state = useMemo((): ModalContextState => {
|
|
107
|
-
return {
|
|
108
|
-
isOpen,
|
|
109
|
-
// TODO
|
|
110
|
-
// @ts-expect-error
|
|
111
|
-
open: onOpen,
|
|
112
|
-
close: onClose,
|
|
113
|
-
update,
|
|
114
|
-
modalState,
|
|
115
|
-
setModalState,
|
|
116
|
-
}
|
|
117
|
-
}, [onOpen, onClose, update, modalState, setModalState, isOpen])
|
|
118
|
-
|
|
119
|
-
const content = useMemo(() => modalContentConfig && getModalComponent(modalContentConfig, state), [modalContentConfig])
|
|
120
|
-
|
|
121
|
-
return (
|
|
122
|
-
<ModalContext.Provider value={state}>
|
|
123
|
-
{children}
|
|
124
|
-
{/* The modal is already rendered in a portal */}
|
|
125
|
-
<Modal
|
|
126
|
-
scrollBehavior={'inside'}
|
|
127
|
-
isCentered
|
|
128
|
-
blockScrollOnMount
|
|
129
|
-
closeOnOverlayClick
|
|
130
|
-
size={modalContentConfig?.size || { base: 'full', md: '3xl' }}
|
|
131
|
-
isOpen={isOpen}
|
|
132
|
-
onClose={onClose}
|
|
133
|
-
>
|
|
134
|
-
<ModalOverlay />
|
|
135
|
-
<ModalContent borderRadius={0}>
|
|
136
|
-
{content}
|
|
137
|
-
</ModalContent>
|
|
138
|
-
</Modal>
|
|
139
|
-
</ModalContext.Provider>
|
|
140
|
-
)
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
export default ModalProvider
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import IconClose from '@driveflux/icons/icons/IconClose'
|
|
2
|
-
import type { FC, PropsWithChildren, ReactNode } from 'react'
|
|
3
|
-
import { Button, HStack, Heading, Stack, type StackProps } from '../../chakra.js'
|
|
4
|
-
import { useEnhancedModal } from '../use-enhanced-modal.js'
|
|
5
|
-
|
|
6
|
-
type Props = {
|
|
7
|
-
title?: ReactNode
|
|
8
|
-
isCloseHidden?: boolean
|
|
9
|
-
} & StackProps
|
|
10
|
-
|
|
11
|
-
const EnhancedModalCustomWrapper: FC<PropsWithChildren<Props>> = ({ title, children, isCloseHidden, ...props }) => {
|
|
12
|
-
const { close } = useEnhancedModal()
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<Stack overflowY={'scroll'} px={'32px'} py={'24px'} spacing={'18px'} {...props}>
|
|
16
|
-
<HStack justifyContent={'space-between'}>
|
|
17
|
-
<Heading fontSize={'18px'} textTransform={'uppercase'}>
|
|
18
|
-
{title}
|
|
19
|
-
</Heading>
|
|
20
|
-
{!isCloseHidden && (
|
|
21
|
-
<Button
|
|
22
|
-
p={0}
|
|
23
|
-
variant={'unstyled'}
|
|
24
|
-
border={0}
|
|
25
|
-
w={'fit-content'}
|
|
26
|
-
onClick={() => {
|
|
27
|
-
close()
|
|
28
|
-
}}
|
|
29
|
-
>
|
|
30
|
-
<IconClose size={'28px'} />
|
|
31
|
-
</Button>
|
|
32
|
-
)}
|
|
33
|
-
</HStack>
|
|
34
|
-
{children}
|
|
35
|
-
</Stack>
|
|
36
|
-
)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export default EnhancedModalCustomWrapper
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { FC, ReactNode } from 'react'
|
|
2
|
-
import { Button, ButtonProps, Stack, StackProps } from '../../chakra.js'
|
|
3
|
-
import { colors } from '../../theme/colors.js'
|
|
4
|
-
import { translations } from '../../translations.js'
|
|
5
|
-
import { useEnhancedModal } from '../use-enhanced-modal.js'
|
|
6
|
-
|
|
7
|
-
type Props = {
|
|
8
|
-
sticky?: boolean
|
|
9
|
-
cancelProps?: ButtonProps
|
|
10
|
-
okProps?: ButtonProps
|
|
11
|
-
children?: ReactNode
|
|
12
|
-
suffix?: ReactNode
|
|
13
|
-
} & StackProps
|
|
14
|
-
|
|
15
|
-
const EnhancedModalFooter: FC<Props> = ({ sticky, cancelProps, okProps, children, suffix, ...props }) => {
|
|
16
|
-
const { close } = useEnhancedModal()
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<Stack
|
|
20
|
-
pos={{ base: 'absolute', md: sticky ? 'absolute' : 'static' }}
|
|
21
|
-
bottom={0}
|
|
22
|
-
left={0}
|
|
23
|
-
right={0}
|
|
24
|
-
py={'32px'}
|
|
25
|
-
px={{ base: '32px', md: sticky ? '32px' : '0' }}
|
|
26
|
-
borderTop={sticky ? `1px solid ${colors.primary2}` : ''}
|
|
27
|
-
background={colors.white}
|
|
28
|
-
spacing={'24px'}
|
|
29
|
-
zIndex={'sticky'}
|
|
30
|
-
{...props}
|
|
31
|
-
>
|
|
32
|
-
{children ? (
|
|
33
|
-
<Stack direction={{ base: 'column-reverse', md: 'row' }} spacing={'24px'}>
|
|
34
|
-
{children}
|
|
35
|
-
</Stack>
|
|
36
|
-
) : (
|
|
37
|
-
<Stack direction={{ base: 'column-reverse', md: 'row' }} spacing={'24px'}>
|
|
38
|
-
<Button w={'full'} variant={'outline'} onClick={() => close()} {...cancelProps} fontSize={'10px'} fontWeight={'700'} letterSpacing={'3px'}>
|
|
39
|
-
{cancelProps?.children ? cancelProps.children : translations.cancel}
|
|
40
|
-
</Button>
|
|
41
|
-
<Button w={'full'} {...okProps} fontSize={'10px'} fontWeight={'700'} letterSpacing={'3px'}>
|
|
42
|
-
{okProps?.children ? okProps.children : translations.confirm}
|
|
43
|
-
</Button>
|
|
44
|
-
</Stack>
|
|
45
|
-
)}
|
|
46
|
-
{suffix}
|
|
47
|
-
</Stack>
|
|
48
|
-
)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export default EnhancedModalFooter
|