@niledatabase/react 3.0.0-alpha.9 → 3.0.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/index.d.mts +355 -0
- package/dist/index.d.ts +355 -11
- package/dist/index.js +3 -8
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +3 -0
- package/dist/index.mjs.map +1 -0
- package/dist/styles.css +1 -0
- package/package.json +52 -32
- package/dist/GoogleLoginButton/GoogleLoginButton.d.ts +0 -10
- package/dist/GoogleLoginButton/GoogleLoginButton.stories.d.ts +0 -11
- package/dist/GoogleLoginButton/index.d.ts +0 -1
- package/dist/SignInForm/SignInForm.d.ts +0 -3
- package/dist/SignInForm/UserLoginForm.stories.d.ts +0 -5
- package/dist/SignInForm/index.d.ts +0 -1
- package/dist/SignInForm/types.d.ts +0 -16
- package/dist/SignUpForm/NewUserSignUp.stories.d.ts +0 -5
- package/dist/SignUpForm/SignUpForm.d.ts +0 -3
- package/dist/SignUpForm/index.d.ts +0 -1
- package/dist/SignUpForm/types.d.ts +0 -13
- package/dist/UserTenantList/CreateUser.d.ts +0 -8
- package/dist/UserTenantList/UserList.d.ts +0 -17
- package/dist/UserTenantList/UserList.stories.d.ts +0 -5
- package/dist/UserTenantList/UserModal.d.ts +0 -7
- package/dist/UserTenantList/index.d.ts +0 -1
- package/dist/UserTenantList/useDataParser.d.ts +0 -4
- package/dist/context/index.d.ts +0 -9
- package/dist/context/theme.d.ts +0 -7
- package/dist/context/types.d.ts +0 -22
- package/dist/hooks/useResults.d.ts +0 -22
- package/dist/hooks/useTextSizer.d.ts +0 -1
- package/dist/lib/SimpleForm/CheckGroup/index.d.ts +0 -10
- package/dist/lib/SimpleForm/index.d.ts +0 -11
- package/dist/lib/SimpleForm/types.d.ts +0 -37
- package/dist/react.cjs.development.js +0 -943
- package/dist/react.cjs.development.js.map +0 -1
- package/dist/react.cjs.production.min.js +0 -2
- package/dist/react.cjs.production.min.js.map +0 -1
- package/dist/react.esm.d.ts +0 -11
- package/dist/react.esm.js +0 -911
- package/dist/react.esm.js.map +0 -1
- package/dist/utils/getColumnSize.d.ts +0 -2
|
@@ -1,943 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var React = require('react');
|
|
6
|
-
var Browser = require('@niledatabase/browser');
|
|
7
|
-
var reactQuery = require('@tanstack/react-query');
|
|
8
|
-
var CssBaseline = require('@mui/material/CssBaseline');
|
|
9
|
-
var styles = require('@mui/joy/styles');
|
|
10
|
-
var Box = require('@mui/joy/Box');
|
|
11
|
-
var Button = require('@mui/joy/Button');
|
|
12
|
-
var Stack = require('@mui/joy/Stack');
|
|
13
|
-
var Typography = require('@mui/joy/Typography');
|
|
14
|
-
var react = require('next-auth/react');
|
|
15
|
-
var Alert = require('@mui/joy/Alert');
|
|
16
|
-
var reactHookForm = require('react-hook-form');
|
|
17
|
-
var Input = require('@mui/joy/Input');
|
|
18
|
-
var FormControl = require('@mui/joy/FormControl');
|
|
19
|
-
var FormHelperText = require('@mui/joy/FormHelperText');
|
|
20
|
-
var Error$1 = require('@mui/icons-material/Error');
|
|
21
|
-
var FormLabel = require('@mui/joy/FormLabel');
|
|
22
|
-
var Select = require('@mui/joy/Select');
|
|
23
|
-
var Option = require('@mui/joy/Option');
|
|
24
|
-
var Tooltip = require('@mui/joy/Tooltip');
|
|
25
|
-
var joy = require('@mui/joy');
|
|
26
|
-
var Checkbox = require('@mui/joy/Checkbox');
|
|
27
|
-
var List = require('@mui/joy/List');
|
|
28
|
-
var ListItem = require('@mui/joy/ListItem');
|
|
29
|
-
var xDataGrid = require('@mui/x-data-grid');
|
|
30
|
-
var Add = require('@mui/icons-material/Add');
|
|
31
|
-
|
|
32
|
-
function _interopNamespaceDefault(e) {
|
|
33
|
-
var n = Object.create(null);
|
|
34
|
-
if (e) {
|
|
35
|
-
Object.keys(e).forEach(function (k) {
|
|
36
|
-
if (k !== 'default') {
|
|
37
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
38
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
39
|
-
enumerable: true,
|
|
40
|
-
get: function () { return e[k]; }
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
n.default = e;
|
|
46
|
-
return n;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
50
|
-
|
|
51
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
52
|
-
function Themer({
|
|
53
|
-
theme,
|
|
54
|
-
children,
|
|
55
|
-
slotProps
|
|
56
|
-
}) {
|
|
57
|
-
return /*#__PURE__*/React.createElement(styles.CssVarsProvider, {
|
|
58
|
-
...slotProps,
|
|
59
|
-
theme: theme
|
|
60
|
-
}, /*#__PURE__*/React.createElement(CssBaseline, {
|
|
61
|
-
enableColorScheme: true
|
|
62
|
-
}), children);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const queryClient = /*#__PURE__*/new reactQuery.QueryClient();
|
|
66
|
-
const defaultContext = {
|
|
67
|
-
api: /*#__PURE__*/new Browser({
|
|
68
|
-
basePath: 'https://api.thenile.dev',
|
|
69
|
-
credentials: 'include'
|
|
70
|
-
}),
|
|
71
|
-
apiUrl: ''
|
|
72
|
-
};
|
|
73
|
-
const context = /*#__PURE__*/React.createContext(defaultContext);
|
|
74
|
-
const {
|
|
75
|
-
Provider
|
|
76
|
-
} = context;
|
|
77
|
-
const BaseQueryProvider = ({
|
|
78
|
-
children
|
|
79
|
-
}) => {
|
|
80
|
-
return /*#__PURE__*/React.createElement(reactQuery.QueryClientProvider, {
|
|
81
|
-
client: queryClient
|
|
82
|
-
}, children);
|
|
83
|
-
};
|
|
84
|
-
const NileProvider = props => {
|
|
85
|
-
const {
|
|
86
|
-
children,
|
|
87
|
-
theme,
|
|
88
|
-
slotProps,
|
|
89
|
-
tenantId,
|
|
90
|
-
QueryProvider = BaseQueryProvider,
|
|
91
|
-
appUrl,
|
|
92
|
-
apiUrl = 'https://api.thenile.dev',
|
|
93
|
-
api
|
|
94
|
-
} = props;
|
|
95
|
-
const values = React.useMemo(() => {
|
|
96
|
-
return {
|
|
97
|
-
api: api ?? new Browser({
|
|
98
|
-
basePath: appUrl,
|
|
99
|
-
credentials: 'include'
|
|
100
|
-
}),
|
|
101
|
-
tenantId: String(tenantId),
|
|
102
|
-
apiUrl,
|
|
103
|
-
appUrl
|
|
104
|
-
};
|
|
105
|
-
}, [api, apiUrl, appUrl, tenantId]);
|
|
106
|
-
return /*#__PURE__*/React.createElement(QueryProvider, null, /*#__PURE__*/React.createElement(Themer, {
|
|
107
|
-
slotProps: slotProps?.provider,
|
|
108
|
-
theme: theme
|
|
109
|
-
}, /*#__PURE__*/React.createElement(Provider, {
|
|
110
|
-
value: values
|
|
111
|
-
}, children)));
|
|
112
|
-
};
|
|
113
|
-
const useNileContext = () => {
|
|
114
|
-
return React.useContext(context);
|
|
115
|
-
};
|
|
116
|
-
const useNileConfig = () => {
|
|
117
|
-
const {
|
|
118
|
-
apiUrl,
|
|
119
|
-
tenantId,
|
|
120
|
-
appUrl
|
|
121
|
-
} = useNileContext();
|
|
122
|
-
return React.useMemo(() => ({
|
|
123
|
-
tenantId,
|
|
124
|
-
apiUrl,
|
|
125
|
-
appUrl
|
|
126
|
-
}), [apiUrl, tenantId, appUrl]);
|
|
127
|
-
};
|
|
128
|
-
const useApi = () => {
|
|
129
|
-
return useNileContext().api;
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
var _g;
|
|
133
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
134
|
-
var SvgGoogle = function SvgGoogle(props) {
|
|
135
|
-
return /*#__PURE__*/React__namespace.createElement("svg", _extends({
|
|
136
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
137
|
-
width: 18,
|
|
138
|
-
height: 18
|
|
139
|
-
}, props), _g || (_g = /*#__PURE__*/React__namespace.createElement("g", {
|
|
140
|
-
fillRule: "evenodd"
|
|
141
|
-
}, /*#__PURE__*/React__namespace.createElement("path", {
|
|
142
|
-
fill: "#EA4335",
|
|
143
|
-
d: "M9 3.48c1.69 0 2.83.73 3.48 1.34l2.54-2.48C13.46.89 11.43 0 9 0 5.48 0 2.44 2.02.96 4.96l2.91 2.26C4.6 5.05 6.62 3.48 9 3.48"
|
|
144
|
-
}), /*#__PURE__*/React__namespace.createElement("path", {
|
|
145
|
-
fill: "#4285F4",
|
|
146
|
-
d: "M17.64 9.2c0-.74-.06-1.28-.19-1.84H9v3.34h4.96c-.1.83-.64 2.08-1.84 2.92l2.84 2.2c1.7-1.57 2.68-3.88 2.68-6.62"
|
|
147
|
-
}), /*#__PURE__*/React__namespace.createElement("path", {
|
|
148
|
-
fill: "#FBBC05",
|
|
149
|
-
d: "M3.88 10.78A5.5 5.5 0 0 1 3.58 9c0-.62.11-1.22.29-1.78L.96 4.96A9 9 0 0 0 0 9c0 1.45.35 2.82.96 4.04z"
|
|
150
|
-
}), /*#__PURE__*/React__namespace.createElement("path", {
|
|
151
|
-
fill: "#34A853",
|
|
152
|
-
d: "M9 18c2.43 0 4.47-.8 5.96-2.18l-2.84-2.2c-.76.53-1.78.9-3.12.9-2.38 0-4.4-1.57-5.12-3.74L.97 13.04C2.45 15.98 5.48 18 9 18"
|
|
153
|
-
}), /*#__PURE__*/React__namespace.createElement("path", {
|
|
154
|
-
fill: "none",
|
|
155
|
-
d: "M0 0h18v18H0z"
|
|
156
|
-
}))));
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* A component for a Google login button, according to their design language.
|
|
161
|
-
* This works when an identity provider is configured in the admin dashboard.
|
|
162
|
-
* @param props href: a string to override the URL provided by the context
|
|
163
|
-
* @returns a JSX.Element to render
|
|
164
|
-
*/
|
|
165
|
-
function GoogleSSOButton(props) {
|
|
166
|
-
const {
|
|
167
|
-
callbackUrl
|
|
168
|
-
} = props;
|
|
169
|
-
return /*#__PURE__*/React.createElement(Box, {
|
|
170
|
-
display: "flex",
|
|
171
|
-
flex: 1,
|
|
172
|
-
sx: {
|
|
173
|
-
textDecoration: 'none'
|
|
174
|
-
},
|
|
175
|
-
onClick: () => {
|
|
176
|
-
react.signIn('google', {
|
|
177
|
-
callbackUrl
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
}, /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Button, {
|
|
181
|
-
sx: {
|
|
182
|
-
padding: 0,
|
|
183
|
-
textTransform: 'initial',
|
|
184
|
-
flex: 1
|
|
185
|
-
},
|
|
186
|
-
"aria-label": "log in with google"
|
|
187
|
-
}, /*#__PURE__*/React.createElement(Stack, {
|
|
188
|
-
direction: "row",
|
|
189
|
-
alignItems: "center",
|
|
190
|
-
p: 0,
|
|
191
|
-
flex: 1,
|
|
192
|
-
fontFamily: "Roboto, sans-serif",
|
|
193
|
-
fontSize: "14px",
|
|
194
|
-
display: "inline-flex",
|
|
195
|
-
color: "rgb(255 255, 255)",
|
|
196
|
-
boxShadow: "rgb(0 0 0 / 24%) 0px 2px 2px 0px rgb(0 0 0 / 24%) 0px 0px 1px 0px",
|
|
197
|
-
borderRadius: "4px",
|
|
198
|
-
border: "1px solid transparent",
|
|
199
|
-
fontWeight: "500",
|
|
200
|
-
sx: {
|
|
201
|
-
backgroundColor: 'rgb(66 133, 244)'
|
|
202
|
-
}
|
|
203
|
-
}, /*#__PURE__*/React.createElement(Box, {
|
|
204
|
-
padding: "11px",
|
|
205
|
-
display: "flex",
|
|
206
|
-
border: "1px solid rgb(66, 133, 244)",
|
|
207
|
-
borderRadius: "4px",
|
|
208
|
-
sx: {
|
|
209
|
-
background: 'rgb(255, 255, 255)'
|
|
210
|
-
}
|
|
211
|
-
}, /*#__PURE__*/React.createElement(SvgGoogle, {
|
|
212
|
-
"aria-hidden": "true"
|
|
213
|
-
})), /*#__PURE__*/React.createElement(Box, {
|
|
214
|
-
padding: "10px",
|
|
215
|
-
flex: 1
|
|
216
|
-
}, /*#__PURE__*/React.createElement(Typography, {
|
|
217
|
-
sx: {
|
|
218
|
-
color: 'white'
|
|
219
|
-
},
|
|
220
|
-
fontWeight: 700,
|
|
221
|
-
fontFamily: "Roboto, sans-serif",
|
|
222
|
-
fontSize: "14px",
|
|
223
|
-
height: "20px"
|
|
224
|
-
}, "Continue with Google"))))));
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
function CheckGroup(props) {
|
|
228
|
-
const {
|
|
229
|
-
options,
|
|
230
|
-
attribute,
|
|
231
|
-
display,
|
|
232
|
-
helperText
|
|
233
|
-
} = props;
|
|
234
|
-
const {
|
|
235
|
-
watch,
|
|
236
|
-
control
|
|
237
|
-
} = reactHookForm.useFormContext();
|
|
238
|
-
const currentVals = watch(attribute.name);
|
|
239
|
-
const checkProps = {};
|
|
240
|
-
if (helperText) {
|
|
241
|
-
checkProps.color = 'danger';
|
|
242
|
-
}
|
|
243
|
-
return /*#__PURE__*/React__namespace.createElement(reactHookForm.Controller, {
|
|
244
|
-
name: attribute.name,
|
|
245
|
-
rules: {
|
|
246
|
-
required: Boolean(attribute.required)
|
|
247
|
-
},
|
|
248
|
-
control: control,
|
|
249
|
-
render: ({
|
|
250
|
-
field
|
|
251
|
-
}) => {
|
|
252
|
-
return /*#__PURE__*/React__namespace.createElement(Stack, null, /*#__PURE__*/React__namespace.createElement(FormLabel, {
|
|
253
|
-
htmlFor: `${field.name}`
|
|
254
|
-
}, display.label), /*#__PURE__*/React__namespace.createElement(Box, {
|
|
255
|
-
role: "group",
|
|
256
|
-
"aria-labelledby": attribute.name,
|
|
257
|
-
sx: {
|
|
258
|
-
borderRadius: 'var(--joy-radius-sm)',
|
|
259
|
-
p: 0.5,
|
|
260
|
-
border: helperText ? '1px solid var(--joy-palette-danger-outlinedBorder)' : 'none'
|
|
261
|
-
}
|
|
262
|
-
}, /*#__PURE__*/React__namespace.createElement(List, {
|
|
263
|
-
orientation: "horizontal",
|
|
264
|
-
wrap: true,
|
|
265
|
-
sx: {
|
|
266
|
-
'--List-gap': '8px'
|
|
267
|
-
}
|
|
268
|
-
}, options.map(item => {
|
|
269
|
-
checkProps.id = String(item.value);
|
|
270
|
-
return /*#__PURE__*/React__namespace.createElement(ListItem, {
|
|
271
|
-
key: `${item.value}-${item.label}`
|
|
272
|
-
}, /*#__PURE__*/React__namespace.createElement(Checkbox, {
|
|
273
|
-
overlay: options.length > 1,
|
|
274
|
-
...checkProps,
|
|
275
|
-
checked: currentVals.includes(item.value),
|
|
276
|
-
disableIcon: options.length > 1,
|
|
277
|
-
variant: "soft",
|
|
278
|
-
label: item.label,
|
|
279
|
-
onChange: event => {
|
|
280
|
-
if (attribute.allowMultiple) {
|
|
281
|
-
if (event.target.checked) {
|
|
282
|
-
if (!currentVals) {
|
|
283
|
-
field.onChange([item.value]);
|
|
284
|
-
} else {
|
|
285
|
-
field.onChange(currentVals.concat(item.value));
|
|
286
|
-
}
|
|
287
|
-
} else {
|
|
288
|
-
const remaining = currentVals.filter(val => val !== item.value);
|
|
289
|
-
if (remaining.length > 0) {
|
|
290
|
-
field.onChange(remaining);
|
|
291
|
-
} else {
|
|
292
|
-
field.onChange('');
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
} else {
|
|
296
|
-
if (event.target.checked) {
|
|
297
|
-
field.onChange(item.value);
|
|
298
|
-
} else {
|
|
299
|
-
field.onChange('');
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
}));
|
|
304
|
-
}))), /*#__PURE__*/React__namespace.createElement(Typography, {
|
|
305
|
-
sx: {
|
|
306
|
-
color: 'var(--joy-palette-danger-500)'
|
|
307
|
-
},
|
|
308
|
-
level: "body-sm"
|
|
309
|
-
}, helperText));
|
|
310
|
-
}
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
exports.FormAttributeType = void 0;
|
|
315
|
-
(function (AttributeType) {
|
|
316
|
-
AttributeType["Text"] = "text";
|
|
317
|
-
AttributeType["Email"] = "email";
|
|
318
|
-
AttributeType["Password"] = "password";
|
|
319
|
-
AttributeType["Select"] = "select";
|
|
320
|
-
AttributeType["Number"] = "number";
|
|
321
|
-
AttributeType["Float"] = "float";
|
|
322
|
-
AttributeType["Checkbox"] = "checkbox";
|
|
323
|
-
AttributeType["Switch"] = "switch";
|
|
324
|
-
})(exports.FormAttributeType || (exports.FormAttributeType = {}));
|
|
325
|
-
|
|
326
|
-
const getAttributeDefault = attribute => {
|
|
327
|
-
// have to look to see if it is an enum
|
|
328
|
-
if (attribute.allowMultiple === true) {
|
|
329
|
-
if (!Array.isArray(attribute.defaultValue) && attribute.defaultValue) {
|
|
330
|
-
if (typeof attribute.defaultValue === 'number') {
|
|
331
|
-
return [attribute.defaultValue];
|
|
332
|
-
}
|
|
333
|
-
return [String(attribute.defaultValue)];
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
return attribute.defaultValue ?? '';
|
|
337
|
-
};
|
|
338
|
-
function Labler(props) {
|
|
339
|
-
const {
|
|
340
|
-
error,
|
|
341
|
-
attr
|
|
342
|
-
} = props;
|
|
343
|
-
if (error) {
|
|
344
|
-
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
345
|
-
title: error,
|
|
346
|
-
color: "danger",
|
|
347
|
-
sx: {
|
|
348
|
-
cursor: 'pointer'
|
|
349
|
-
}
|
|
350
|
-
}, /*#__PURE__*/React.createElement(FormLabel, null, attr.label ?? attr.name, /*#__PURE__*/React.createElement(Error$1, {
|
|
351
|
-
sx: {
|
|
352
|
-
ml: 0.5,
|
|
353
|
-
'--Icon-color': '#c41c1c'
|
|
354
|
-
},
|
|
355
|
-
fontSize: "small"
|
|
356
|
-
})));
|
|
357
|
-
}
|
|
358
|
-
return /*#__PURE__*/React.createElement(FormLabel, null, attr.label ?? attr.name);
|
|
359
|
-
}
|
|
360
|
-
function SimpleForm(props) {
|
|
361
|
-
const {
|
|
362
|
-
mutation,
|
|
363
|
-
buttonText,
|
|
364
|
-
attributes,
|
|
365
|
-
cancelButton,
|
|
366
|
-
loading,
|
|
367
|
-
successMessage
|
|
368
|
-
} = props;
|
|
369
|
-
const defaultValues = React.useMemo(() => attributes.reduce((accum, attr) => {
|
|
370
|
-
accum[attr.name] = getAttributeDefault(attr);
|
|
371
|
-
return accum;
|
|
372
|
-
}, {}), [attributes]);
|
|
373
|
-
const methods = reactHookForm.useForm({
|
|
374
|
-
defaultValues
|
|
375
|
-
});
|
|
376
|
-
const {
|
|
377
|
-
register,
|
|
378
|
-
control,
|
|
379
|
-
handleSubmit,
|
|
380
|
-
formState: {
|
|
381
|
-
errors
|
|
382
|
-
}
|
|
383
|
-
} = methods;
|
|
384
|
-
const onSubmit = React.useCallback(
|
|
385
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
386
|
-
data => {
|
|
387
|
-
mutation.mutate(data);
|
|
388
|
-
}, [mutation]);
|
|
389
|
-
return /*#__PURE__*/React.createElement(reactHookForm.FormProvider, {
|
|
390
|
-
...methods
|
|
391
|
-
}, /*#__PURE__*/React.createElement(Stack, {
|
|
392
|
-
component: "form",
|
|
393
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
394
|
-
onSubmit: handleSubmit(data => onSubmit(data)),
|
|
395
|
-
spacing: 2
|
|
396
|
-
}, attributes.map(attr => {
|
|
397
|
-
const fieldConfig = {};
|
|
398
|
-
const display = {
|
|
399
|
-
key: attr.name,
|
|
400
|
-
label: attr.label ?? attr.name,
|
|
401
|
-
id: attr.label ?? attr.name,
|
|
402
|
-
placeholder: attr.placeholder ?? attr.label ?? attr.name,
|
|
403
|
-
error: Boolean(errors[attr.name]),
|
|
404
|
-
disabled: Boolean(attr.disabled)
|
|
405
|
-
};
|
|
406
|
-
const options = attr.options ?? [];
|
|
407
|
-
const helperText = attr.helpText ?? '';
|
|
408
|
-
let error = '';
|
|
409
|
-
if (attr.required) {
|
|
410
|
-
error = errors[attr.name] ? `${attr.label ?? attr.name} is required` : '';
|
|
411
|
-
fieldConfig.required = true;
|
|
412
|
-
}
|
|
413
|
-
switch (attr.type) {
|
|
414
|
-
case exports.FormAttributeType.Switch:
|
|
415
|
-
return /*#__PURE__*/React.createElement(FormControl, {
|
|
416
|
-
key: display.key,
|
|
417
|
-
id: display.id,
|
|
418
|
-
orientation: "horizontal",
|
|
419
|
-
sx: {
|
|
420
|
-
alignItems: 'center'
|
|
421
|
-
},
|
|
422
|
-
required: attr.required
|
|
423
|
-
}, /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Labler, {
|
|
424
|
-
error: error,
|
|
425
|
-
attr: attr
|
|
426
|
-
}), /*#__PURE__*/React.createElement(FormHelperText, {
|
|
427
|
-
id: `${attr.name}-helper-text`
|
|
428
|
-
}, helperText)), /*#__PURE__*/React.createElement(reactHookForm.Controller, {
|
|
429
|
-
control: control,
|
|
430
|
-
rules: {
|
|
431
|
-
required: Boolean(attr.required)
|
|
432
|
-
},
|
|
433
|
-
name: attr.name,
|
|
434
|
-
render: ({
|
|
435
|
-
field
|
|
436
|
-
}) => {
|
|
437
|
-
const color = {};
|
|
438
|
-
if (errors[attr.name]) {
|
|
439
|
-
color.color = 'danger';
|
|
440
|
-
}
|
|
441
|
-
return /*#__PURE__*/React.createElement(joy.Switch, {
|
|
442
|
-
id: `switch-field-${attr.name}`,
|
|
443
|
-
...color,
|
|
444
|
-
...field,
|
|
445
|
-
checked: Boolean(field.value),
|
|
446
|
-
onChange: event => {
|
|
447
|
-
field.onChange(event.target.checked);
|
|
448
|
-
},
|
|
449
|
-
color: field.value ? 'success' : 'neutral',
|
|
450
|
-
endDecorator: field.value ? options[0].label : options[1].label
|
|
451
|
-
});
|
|
452
|
-
}
|
|
453
|
-
}));
|
|
454
|
-
case exports.FormAttributeType.Checkbox:
|
|
455
|
-
return /*#__PURE__*/React.createElement(CheckGroup, {
|
|
456
|
-
key: display.key,
|
|
457
|
-
attribute: attr,
|
|
458
|
-
display: display,
|
|
459
|
-
options: options,
|
|
460
|
-
helperText: helperText
|
|
461
|
-
});
|
|
462
|
-
case exports.FormAttributeType.Select:
|
|
463
|
-
return /*#__PURE__*/React.createElement(FormControl, {
|
|
464
|
-
key: display.key,
|
|
465
|
-
id: display.id,
|
|
466
|
-
required: attr.required
|
|
467
|
-
}, /*#__PURE__*/React.createElement(Labler, {
|
|
468
|
-
error: error,
|
|
469
|
-
attr: attr
|
|
470
|
-
}), /*#__PURE__*/React.createElement(reactHookForm.Controller, {
|
|
471
|
-
control: control,
|
|
472
|
-
rules: {
|
|
473
|
-
required: Boolean(attr.required)
|
|
474
|
-
},
|
|
475
|
-
name: attr.name,
|
|
476
|
-
render: ({
|
|
477
|
-
field
|
|
478
|
-
}) => {
|
|
479
|
-
const color = {};
|
|
480
|
-
if (errors[attr.name]) {
|
|
481
|
-
color.color = 'danger';
|
|
482
|
-
}
|
|
483
|
-
const value = String(field.value);
|
|
484
|
-
return /*#__PURE__*/React.createElement(Stack, null, /*#__PURE__*/React.createElement(Select, {
|
|
485
|
-
id: `select-field-${attr.name}`,
|
|
486
|
-
placeholder: `${display.placeholder}...`,
|
|
487
|
-
...color,
|
|
488
|
-
...field,
|
|
489
|
-
value: value,
|
|
490
|
-
onChange: (_, newValue) => {
|
|
491
|
-
field.onChange(newValue);
|
|
492
|
-
}
|
|
493
|
-
}, options.map(option => {
|
|
494
|
-
return /*#__PURE__*/React.createElement(Option, {
|
|
495
|
-
key: String(option.value ?? ''),
|
|
496
|
-
value: option.value
|
|
497
|
-
}, option.label);
|
|
498
|
-
})), /*#__PURE__*/React.createElement(FormHelperText, {
|
|
499
|
-
id: `${attr.name}-helper-text`
|
|
500
|
-
}, helperText));
|
|
501
|
-
}
|
|
502
|
-
}));
|
|
503
|
-
case exports.FormAttributeType.Password:
|
|
504
|
-
return /*#__PURE__*/React.createElement(FormControl, {
|
|
505
|
-
key: display.key,
|
|
506
|
-
id: display.id,
|
|
507
|
-
required: attr.required
|
|
508
|
-
}, /*#__PURE__*/React.createElement(Labler, {
|
|
509
|
-
error: error,
|
|
510
|
-
attr: attr
|
|
511
|
-
}), /*#__PURE__*/React.createElement(Input, {
|
|
512
|
-
...display,
|
|
513
|
-
...register(attr.name, fieldConfig),
|
|
514
|
-
type: exports.FormAttributeType.Password
|
|
515
|
-
}), /*#__PURE__*/React.createElement(FormHelperText, {
|
|
516
|
-
id: `${attr.name}-helper-text`
|
|
517
|
-
}, helperText));
|
|
518
|
-
case exports.FormAttributeType.Number:
|
|
519
|
-
return /*#__PURE__*/React.createElement(FormControl, {
|
|
520
|
-
key: display.key,
|
|
521
|
-
id: display.id,
|
|
522
|
-
required: attr.required
|
|
523
|
-
}, /*#__PURE__*/React.createElement(Labler, {
|
|
524
|
-
error: error,
|
|
525
|
-
attr: attr
|
|
526
|
-
}), /*#__PURE__*/React.createElement(Input, {
|
|
527
|
-
...display,
|
|
528
|
-
...register(attr.name, fieldConfig),
|
|
529
|
-
type: exports.FormAttributeType.Number
|
|
530
|
-
}), /*#__PURE__*/React.createElement(FormHelperText, {
|
|
531
|
-
id: `${attr.name}-helper-text`
|
|
532
|
-
}, helperText));
|
|
533
|
-
case exports.FormAttributeType.Text:
|
|
534
|
-
default:
|
|
535
|
-
return /*#__PURE__*/React.createElement(FormControl, {
|
|
536
|
-
key: display.key,
|
|
537
|
-
id: display.id,
|
|
538
|
-
required: attr.required
|
|
539
|
-
}, /*#__PURE__*/React.createElement(Labler, {
|
|
540
|
-
error: error,
|
|
541
|
-
attr: attr
|
|
542
|
-
}), /*#__PURE__*/React.createElement(Input, {
|
|
543
|
-
...display,
|
|
544
|
-
...register(attr.name, fieldConfig)
|
|
545
|
-
}), /*#__PURE__*/React.createElement(FormHelperText, {
|
|
546
|
-
id: `${attr.name}-helper-text`
|
|
547
|
-
}, helperText));
|
|
548
|
-
}
|
|
549
|
-
}), cancelButton ? ( /*#__PURE__*/React.createElement(Stack, {
|
|
550
|
-
spacing: 2,
|
|
551
|
-
direction: "row"
|
|
552
|
-
}, cancelButton, /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Button, {
|
|
553
|
-
type: "submit"
|
|
554
|
-
}, buttonText)))) : ( /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Stack, {
|
|
555
|
-
direction: "row",
|
|
556
|
-
gap: 2
|
|
557
|
-
}, /*#__PURE__*/React.createElement(Button, {
|
|
558
|
-
type: "submit",
|
|
559
|
-
loading: loading
|
|
560
|
-
}, buttonText), successMessage)))));
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
function SignUpForm(props) {
|
|
564
|
-
const [error, setError] = React.useState();
|
|
565
|
-
const {
|
|
566
|
-
buttonText = 'Sign up',
|
|
567
|
-
onSuccess,
|
|
568
|
-
onError,
|
|
569
|
-
attributes,
|
|
570
|
-
beforeMutate
|
|
571
|
-
} = props;
|
|
572
|
-
const api = useApi();
|
|
573
|
-
const mutation = reactQuery.useMutation(async _data => {
|
|
574
|
-
setError(undefined);
|
|
575
|
-
const possibleData = beforeMutate && beforeMutate(_data);
|
|
576
|
-
const data = {
|
|
577
|
-
..._data,
|
|
578
|
-
...possibleData
|
|
579
|
-
};
|
|
580
|
-
const {
|
|
581
|
-
name,
|
|
582
|
-
givenName,
|
|
583
|
-
familyName,
|
|
584
|
-
picture,
|
|
585
|
-
email,
|
|
586
|
-
password,
|
|
587
|
-
newTenantName,
|
|
588
|
-
...metadata
|
|
589
|
-
} = data;
|
|
590
|
-
if (Object.keys(metadata).length > 0) {
|
|
591
|
-
// eslint-disable-next-line no-console
|
|
592
|
-
console.warn('additional metadata not supported yet.');
|
|
593
|
-
}
|
|
594
|
-
return await api.users.createUser({
|
|
595
|
-
createBasicUserRequest: {
|
|
596
|
-
email,
|
|
597
|
-
password,
|
|
598
|
-
name,
|
|
599
|
-
familyName,
|
|
600
|
-
picture,
|
|
601
|
-
givenName,
|
|
602
|
-
newTenantName
|
|
603
|
-
}
|
|
604
|
-
});
|
|
605
|
-
}, {
|
|
606
|
-
onSuccess,
|
|
607
|
-
onError: (e, vars) => {
|
|
608
|
-
setError(e.message);
|
|
609
|
-
onError && onError(e, vars);
|
|
610
|
-
}
|
|
611
|
-
});
|
|
612
|
-
const completeAttributes = React.useMemo(() => {
|
|
613
|
-
const mainAttributes = [{
|
|
614
|
-
name: 'email',
|
|
615
|
-
label: 'Email',
|
|
616
|
-
type: exports.FormAttributeType.Email,
|
|
617
|
-
defaultValue: '',
|
|
618
|
-
required: true
|
|
619
|
-
}, {
|
|
620
|
-
name: 'password',
|
|
621
|
-
label: 'Password',
|
|
622
|
-
type: exports.FormAttributeType.Password,
|
|
623
|
-
defaultValue: '',
|
|
624
|
-
required: true
|
|
625
|
-
}];
|
|
626
|
-
if (attributes && attributes.length > 0) {
|
|
627
|
-
return mainAttributes.concat(attributes);
|
|
628
|
-
}
|
|
629
|
-
return mainAttributes;
|
|
630
|
-
}, [attributes]);
|
|
631
|
-
return /*#__PURE__*/React.createElement(Stack, {
|
|
632
|
-
gap: 2
|
|
633
|
-
}, error ? /*#__PURE__*/React.createElement(Alert, {
|
|
634
|
-
color: "danger"
|
|
635
|
-
}, error) : null, /*#__PURE__*/React.createElement(SimpleForm, {
|
|
636
|
-
mutation: mutation,
|
|
637
|
-
buttonText: buttonText,
|
|
638
|
-
attributes: completeAttributes
|
|
639
|
-
}));
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
function SignInForm(props) {
|
|
643
|
-
const [error, setError] = React.useState();
|
|
644
|
-
const {
|
|
645
|
-
attributes,
|
|
646
|
-
onSuccess,
|
|
647
|
-
onError,
|
|
648
|
-
beforeMutate,
|
|
649
|
-
callbackUrl
|
|
650
|
-
} = props;
|
|
651
|
-
const mutation = reactQuery.useMutation(async _data => {
|
|
652
|
-
setError(undefined);
|
|
653
|
-
const d = {
|
|
654
|
-
..._data,
|
|
655
|
-
callbackUrl
|
|
656
|
-
};
|
|
657
|
-
const possibleData = beforeMutate && beforeMutate(d);
|
|
658
|
-
const data = possibleData ?? d;
|
|
659
|
-
react.signIn('credentials', data);
|
|
660
|
-
}, {
|
|
661
|
-
onSuccess,
|
|
662
|
-
onError
|
|
663
|
-
});
|
|
664
|
-
const completeAttributes = React.useMemo(() => {
|
|
665
|
-
const mainAttributes = [{
|
|
666
|
-
name: 'email',
|
|
667
|
-
label: 'Email',
|
|
668
|
-
type: exports.FormAttributeType.Text,
|
|
669
|
-
defaultValue: '',
|
|
670
|
-
required: true
|
|
671
|
-
}, {
|
|
672
|
-
name: 'password',
|
|
673
|
-
label: 'Password',
|
|
674
|
-
type: exports.FormAttributeType.Password,
|
|
675
|
-
defaultValue: '',
|
|
676
|
-
required: true
|
|
677
|
-
}];
|
|
678
|
-
if (attributes && attributes.length > 0) {
|
|
679
|
-
return mainAttributes.concat(attributes);
|
|
680
|
-
}
|
|
681
|
-
return mainAttributes;
|
|
682
|
-
}, [attributes]);
|
|
683
|
-
return /*#__PURE__*/React.createElement(Stack, {
|
|
684
|
-
gap: 2
|
|
685
|
-
}, error ? /*#__PURE__*/React.createElement(Alert, {
|
|
686
|
-
color: "danger"
|
|
687
|
-
}, error) : null, /*#__PURE__*/React.createElement(SimpleForm, {
|
|
688
|
-
mutation: mutation,
|
|
689
|
-
buttonText: "Log in",
|
|
690
|
-
attributes: completeAttributes
|
|
691
|
-
}));
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
695
|
-
function AddUser(props) {
|
|
696
|
-
const {
|
|
697
|
-
open,
|
|
698
|
-
setOpen,
|
|
699
|
-
refetch
|
|
700
|
-
} = props;
|
|
701
|
-
const {
|
|
702
|
-
tenantId
|
|
703
|
-
} = useNileConfig();
|
|
704
|
-
const api = useApi();
|
|
705
|
-
const [errorText, setErrorText] = React.useState();
|
|
706
|
-
const {
|
|
707
|
-
watch,
|
|
708
|
-
register,
|
|
709
|
-
handleSubmit
|
|
710
|
-
} = reactHookForm.useForm();
|
|
711
|
-
const email = watch('email');
|
|
712
|
-
React.useEffect(() => {
|
|
713
|
-
if (errorText != null) {
|
|
714
|
-
setErrorText();
|
|
715
|
-
}
|
|
716
|
-
// if email changes, no more error
|
|
717
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
718
|
-
}, [email]);
|
|
719
|
-
const mutation = reactQuery.useMutation(data => api.users.createTenantUser({
|
|
720
|
-
createBasicUserRequest: data,
|
|
721
|
-
tenantId: String(tenantId)
|
|
722
|
-
}), {
|
|
723
|
-
onSuccess(data) {
|
|
724
|
-
refetch && refetch(data);
|
|
725
|
-
setOpen(false);
|
|
726
|
-
},
|
|
727
|
-
onError(e) {
|
|
728
|
-
if (e instanceof Error) {
|
|
729
|
-
setErrorText(e.message);
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
});
|
|
733
|
-
const handleUpdate = React.useCallback(async data => {
|
|
734
|
-
setErrorText('');
|
|
735
|
-
mutation.mutate(data);
|
|
736
|
-
}, [mutation]);
|
|
737
|
-
return /*#__PURE__*/React.createElement(joy.Modal, {
|
|
738
|
-
open: open
|
|
739
|
-
}, /*#__PURE__*/React.createElement(joy.ModalDialog, null, /*#__PURE__*/React.createElement(joy.Stack, {
|
|
740
|
-
spacing: 2
|
|
741
|
-
}, /*#__PURE__*/React.createElement(joy.Typography, {
|
|
742
|
-
level: "h4"
|
|
743
|
-
}, "Create user"), /*#__PURE__*/React.createElement(React.Fragment, null, errorText && /*#__PURE__*/React.createElement(joy.Typography, {
|
|
744
|
-
color: "danger"
|
|
745
|
-
}, errorText)), /*#__PURE__*/React.createElement(joy.Stack, {
|
|
746
|
-
component: "form",
|
|
747
|
-
sx: {
|
|
748
|
-
width: '40ch'
|
|
749
|
-
},
|
|
750
|
-
spacing: 1,
|
|
751
|
-
onSubmit: handleSubmit(data => handleUpdate(data))
|
|
752
|
-
}, /*#__PURE__*/React.createElement(joy.FormControl, {
|
|
753
|
-
sx: {
|
|
754
|
-
'--FormHelperText-color': 'var(--joy-palette-danger-500)'
|
|
755
|
-
}
|
|
756
|
-
}, /*#__PURE__*/React.createElement(joy.FormLabel, {
|
|
757
|
-
htmlFor: "email"
|
|
758
|
-
}, "Email"), /*#__PURE__*/React.createElement(joy.Input, {
|
|
759
|
-
...register('email'),
|
|
760
|
-
fullWidth: true,
|
|
761
|
-
size: "lg",
|
|
762
|
-
id: "email",
|
|
763
|
-
name: "email",
|
|
764
|
-
autoComplete: "current-email",
|
|
765
|
-
required: true,
|
|
766
|
-
error: Boolean(errorText)
|
|
767
|
-
})), /*#__PURE__*/React.createElement(joy.FormControl, {
|
|
768
|
-
sx: {
|
|
769
|
-
'--FormHelperText-color': 'var(--joy-palette-danger-500)'
|
|
770
|
-
}
|
|
771
|
-
}, /*#__PURE__*/React.createElement(joy.FormLabel, {
|
|
772
|
-
htmlFor: "password"
|
|
773
|
-
}, "Password"), /*#__PURE__*/React.createElement(joy.Input, {
|
|
774
|
-
...register('password'),
|
|
775
|
-
fullWidth: true,
|
|
776
|
-
size: "lg",
|
|
777
|
-
id: "password",
|
|
778
|
-
autoComplete: "current-password",
|
|
779
|
-
type: "password",
|
|
780
|
-
required: true
|
|
781
|
-
})), /*#__PURE__*/React.createElement(joy.Stack, {
|
|
782
|
-
direction: "row",
|
|
783
|
-
sx: {
|
|
784
|
-
pt: 2
|
|
785
|
-
},
|
|
786
|
-
spacing: 2
|
|
787
|
-
}, /*#__PURE__*/React.createElement(joy.Button, {
|
|
788
|
-
onClick: () => setOpen(false),
|
|
789
|
-
variant: "plain"
|
|
790
|
-
}, "Cancel"), /*#__PURE__*/React.createElement(joy.Button, {
|
|
791
|
-
type: "submit"
|
|
792
|
-
}, "Create"))))));
|
|
793
|
-
}
|
|
794
|
-
|
|
795
|
-
function CreateUser(props) {
|
|
796
|
-
const {
|
|
797
|
-
allowCreation,
|
|
798
|
-
buttonText,
|
|
799
|
-
onUserCreateSuccess
|
|
800
|
-
} = props;
|
|
801
|
-
const [open, setOpen] = React.useState(false);
|
|
802
|
-
if (!allowCreation) {
|
|
803
|
-
return null;
|
|
804
|
-
}
|
|
805
|
-
return /*#__PURE__*/React.createElement(Stack, {
|
|
806
|
-
alignItems: "flex-end",
|
|
807
|
-
gap: 1
|
|
808
|
-
}, /*#__PURE__*/React.createElement(AddUser, {
|
|
809
|
-
open: open,
|
|
810
|
-
setOpen: setOpen,
|
|
811
|
-
refetch: onUserCreateSuccess
|
|
812
|
-
}), /*#__PURE__*/React.createElement(Button, {
|
|
813
|
-
startDecorator: /*#__PURE__*/React.createElement(Add, null),
|
|
814
|
-
size: "sm",
|
|
815
|
-
onClick: () => setOpen(true)
|
|
816
|
-
}, buttonText));
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
function getColumnSize(column, rows, canvasContext) {
|
|
820
|
-
const dataWidthReducer = (longest,
|
|
821
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
822
|
-
nextRow) => {
|
|
823
|
-
let value = nextRow[String(column)];
|
|
824
|
-
if (value == null) {
|
|
825
|
-
value = '';
|
|
826
|
-
}
|
|
827
|
-
value = value?.toString();
|
|
828
|
-
return longest.length > value.length ? longest : value;
|
|
829
|
-
};
|
|
830
|
-
let columnHeaderLen = canvasContext && column ? canvasContext.measureText(String(column)).width : 50;
|
|
831
|
-
/* padding 12, icon-width 15 */
|
|
832
|
-
columnHeaderLen += 15 + 12;
|
|
833
|
-
let width = columnHeaderLen;
|
|
834
|
-
width = 16 + Math.ceil(canvasContext ? canvasContext.measureText(rows.reduce(dataWidthReducer, '')).width : 50);
|
|
835
|
-
if (width < columnHeaderLen) {
|
|
836
|
-
width = columnHeaderLen;
|
|
837
|
-
}
|
|
838
|
-
/* Gracefull */
|
|
839
|
-
width += 8;
|
|
840
|
-
return width;
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
function useTextSizer() {
|
|
844
|
-
const [ctx, setCtx] = React.useState();
|
|
845
|
-
React.useEffect(() => {
|
|
846
|
-
const canvas = document.createElement('canvas');
|
|
847
|
-
const canvasContext = canvas.getContext('2d');
|
|
848
|
-
if (canvasContext) {
|
|
849
|
-
canvasContext.font = '18px Roboto';
|
|
850
|
-
setCtx(canvasContext);
|
|
851
|
-
}
|
|
852
|
-
}, []);
|
|
853
|
-
return ctx;
|
|
854
|
-
}
|
|
855
|
-
|
|
856
|
-
const makeRenderable = vals => {
|
|
857
|
-
return Object.keys(vals).reduce((cleaned, key) => {
|
|
858
|
-
const val = vals[key];
|
|
859
|
-
if (val instanceof Set) {
|
|
860
|
-
cleaned[key] = Array.from(val).join(', ');
|
|
861
|
-
} else if (Array.isArray(val)) {
|
|
862
|
-
cleaned[key] = val.join(', ');
|
|
863
|
-
} else {
|
|
864
|
-
cleaned[key] = val;
|
|
865
|
-
}
|
|
866
|
-
return cleaned;
|
|
867
|
-
}, {});
|
|
868
|
-
};
|
|
869
|
-
const parseResults = (data, ctx, include) => {
|
|
870
|
-
if (!data) {
|
|
871
|
-
return [[], []];
|
|
872
|
-
}
|
|
873
|
-
const rows = data.map(makeRenderable);
|
|
874
|
-
const fields = Object.keys(rows[0]);
|
|
875
|
-
const existentCols = {};
|
|
876
|
-
const mapCols = col => {
|
|
877
|
-
const width = getColumnSize(col, rows, ctx);
|
|
878
|
-
const name = col.slice();
|
|
879
|
-
if (include.includes(name)) {
|
|
880
|
-
// add spaces to the end of column names so they are not duplicated in the UI
|
|
881
|
-
if (existentCols[name] == null) {
|
|
882
|
-
existentCols[name] = name.length;
|
|
883
|
-
} else {
|
|
884
|
-
existentCols[name] += 1;
|
|
885
|
-
}
|
|
886
|
-
return {
|
|
887
|
-
field: name.padEnd(existentCols[name]),
|
|
888
|
-
headerName: name.padEnd(existentCols[name]),
|
|
889
|
-
width
|
|
890
|
-
};
|
|
891
|
-
}
|
|
892
|
-
};
|
|
893
|
-
const cols = fields?.map(mapCols).filter(Boolean) ?? [];
|
|
894
|
-
return [cols, rows];
|
|
895
|
-
};
|
|
896
|
-
function useDataParser(data, include) {
|
|
897
|
-
const ctx = useTextSizer();
|
|
898
|
-
const [cols, rows] = React.useMemo(() => parseResults(data, ctx, include), [data, ctx, include]);
|
|
899
|
-
return [cols, rows];
|
|
900
|
-
}
|
|
901
|
-
|
|
902
|
-
function UserList(props) {
|
|
903
|
-
const {
|
|
904
|
-
data,
|
|
905
|
-
allowCreation = true,
|
|
906
|
-
buttonText = 'Add a user',
|
|
907
|
-
onUserCreateSuccess,
|
|
908
|
-
slots,
|
|
909
|
-
include = ['email', 'preferredName']
|
|
910
|
-
} = props;
|
|
911
|
-
const dataGridSx = {
|
|
912
|
-
width: '100%',
|
|
913
|
-
height: '100%',
|
|
914
|
-
...(slots?.dataGrid ?? {})
|
|
915
|
-
};
|
|
916
|
-
const [columns, rows] = useDataParser(data, include);
|
|
917
|
-
return /*#__PURE__*/React.createElement(Stack, {
|
|
918
|
-
flex: 1
|
|
919
|
-
}, /*#__PURE__*/React.createElement(CreateUser, {
|
|
920
|
-
allowCreation: allowCreation,
|
|
921
|
-
buttonText: buttonText,
|
|
922
|
-
onUserCreateSuccess: onUserCreateSuccess
|
|
923
|
-
}), /*#__PURE__*/React.createElement(xDataGrid.DataGrid, {
|
|
924
|
-
sx: dataGridSx,
|
|
925
|
-
rows: rows,
|
|
926
|
-
columns: columns,
|
|
927
|
-
hideFooter: true
|
|
928
|
-
}));
|
|
929
|
-
}
|
|
930
|
-
|
|
931
|
-
exports.Google = GoogleSSOButton;
|
|
932
|
-
exports.NileProvider = NileProvider;
|
|
933
|
-
exports.SignInForm = SignInForm;
|
|
934
|
-
exports.SignUpForm = SignUpForm;
|
|
935
|
-
exports.UserTenantList = UserList;
|
|
936
|
-
exports.useApi = useApi;
|
|
937
|
-
Object.keys(react).forEach(function (k) {
|
|
938
|
-
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
939
|
-
enumerable: true,
|
|
940
|
-
get: function () { return react[k]; }
|
|
941
|
-
});
|
|
942
|
-
});
|
|
943
|
-
//# sourceMappingURL=react.cjs.development.js.map
|