@abtnode/ux 1.8.39 → 1.8.41

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.
@@ -0,0 +1,613 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _propTypes = _interopRequireDefault(require("prop-types"));
8
+ var _Button = _interopRequireDefault(require("@arcblock/ux/lib/Button"));
9
+ var _Dialog = _interopRequireDefault(require("@arcblock/ux/lib/Dialog"));
10
+ var _context = require("@arcblock/ux/lib/Locale/context");
11
+ var _material = require("@mui/material");
12
+ var _ahooks = require("ahooks");
13
+ var _omit = _interopRequireDefault(require("lodash/omit"));
14
+ var _pick = _interopRequireDefault(require("lodash/pick"));
15
+ var _values = _interopRequireDefault(require("lodash/values"));
16
+ var _without = _interopRequireDefault(require("lodash/without"));
17
+ var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
18
+ var _isString = _interopRequireDefault(require("lodash/isString"));
19
+ var _isObject = _interopRequireDefault(require("lodash/isObject"));
20
+ var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
21
+ var _react = require("react");
22
+ var _reactHookForm = require("react-hook-form");
23
+ var _react2 = require("@iconify/react");
24
+ var _notistack = require("notistack");
25
+ var _parseNavigationFromBlocklet = require("@blocklet/meta/lib/parse-navigation-from-blocklet");
26
+ var _urlJoin = _interopRequireDefault(require("url-join"));
27
+ var _index = require("ufo/dist/index.mjs");
28
+ var _isAbsoluteUrl = _interopRequireDefault(require("is-absolute-url"));
29
+ var _localeTabs = _interopRequireDefault(require("./locale-tabs"));
30
+ var _simpleSelect = _interopRequireDefault(require("./simple-select"));
31
+ var _team = require("../../../contexts/team");
32
+ var _jsxRuntime = require("react/jsx-runtime");
33
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
34
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
35
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
36
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
37
+ const MAX_TITLE_LENGTH = 24;
38
+ const defaultType = 'add';
39
+ const defaultLocale = 'en';
40
+ const initialFormState = {
41
+ title: {
42
+ [defaultLocale]: ''
43
+ },
44
+ link: {
45
+ [defaultLocale]: ''
46
+ }
47
+ };
48
+ function IconSuffix(_ref) {
49
+ let {
50
+ icon
51
+ } = _ref;
52
+ const [loaded, setLoaded] = (0, _react.useState)(false);
53
+ (0, _ahooks.useAsyncEffect)(async () => {
54
+ setLoaded(false);
55
+ await (0, _react2.loadIcon)(icon);
56
+ setLoaded(true);
57
+ }, [icon]);
58
+ if (icon) {
59
+ if (loaded) {
60
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_react2.Icon, {
61
+ icon: icon
62
+ });
63
+ }
64
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_react2.Icon, {
65
+ color: "#f06f6e",
66
+ icon: "ic:baseline-error"
67
+ });
68
+ }
69
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_react2.Icon, {
70
+ icon: "codicon:blank"
71
+ });
72
+ }
73
+ IconSuffix.propTypes = {
74
+ icon: _propTypes.default.string.isRequired
75
+ };
76
+ const NavigationDialog = /*#__PURE__*/(0, _react.forwardRef)(function NavigationDialog(_ref2, ref) {
77
+ let {
78
+ section,
79
+ components,
80
+ rawNavigations
81
+ } = _ref2;
82
+ const {
83
+ roles
84
+ } = (0, _team.useTeamContext)();
85
+ const {
86
+ t,
87
+ locale
88
+ } = (0, _context.useLocaleContext)();
89
+ const saveFn = (0, _react.useRef)(() => {});
90
+ const [show, {
91
+ setFalse,
92
+ setTrue
93
+ }] = (0, _ahooks.useBoolean)(false);
94
+ const {
95
+ enqueueSnackbar
96
+ } = (0, _notistack.useSnackbar)();
97
+ const state = (0, _ahooks.useReactive)({
98
+ isRoot: true,
99
+ type: defaultType,
100
+ linkDisabled: false,
101
+ locale: defaultLocale,
102
+ formState: (0, _cloneDeep.default)(initialFormState),
103
+ get localeList() {
104
+ // eslint-disable-next-line react/no-this-in-sfc
105
+ return (0, _without.default)(Object.keys(this.formState.title), defaultLocale);
106
+ }
107
+ });
108
+ const {
109
+ handleSubmit,
110
+ control,
111
+ watch,
112
+ setValue,
113
+ clearErrors,
114
+ formState: {
115
+ errors
116
+ }
117
+ } = (0, _reactHookForm.useForm)({
118
+ mode: 'onChange',
119
+ defaultValues: {
120
+ id: undefined,
121
+ title: undefined,
122
+ icon: undefined,
123
+ link: undefined,
124
+ component: undefined,
125
+ parent: undefined,
126
+ role: []
127
+ }
128
+ });
129
+ (0, _react.useEffect)(() => {
130
+ setValue('title', state.formState.title[state.locale]);
131
+ setValue('link', state.formState.link[state.locale]);
132
+ // eslint-disable-next-line react-hooks/exhaustive-deps
133
+ }, [setValue, state.locale, show]);
134
+ const watchComponent = watch('component');
135
+ const watchTitle = watch('title');
136
+ const watchLink = watch('link');
137
+ const watchIcon = watch('icon');
138
+ const watchParent = watch('parent');
139
+ (0, _react.useEffect)(() => {
140
+ state.formState.title[state.locale] = watchTitle;
141
+ // eslint-disable-next-line react-hooks/exhaustive-deps
142
+ }, [watchTitle]);
143
+ (0, _react.useEffect)(() => {
144
+ state.formState.link[state.locale] = watchLink;
145
+ // eslint-disable-next-line react-hooks/exhaustive-deps
146
+ }, [watchLink]);
147
+ const selectedOption = (0, _react.useMemo)(() => {
148
+ const parentData = rawNavigations.find(item => {
149
+ if (watchComponent) {
150
+ return item.component === watchComponent;
151
+ }
152
+ return item.id === watchParent;
153
+ });
154
+ return parentData;
155
+ }, [rawNavigations, watchComponent, watchParent]);
156
+ const linkPrefix = (0, _react.useMemo)(() => {
157
+ if (selectedOption !== null && selectedOption !== void 0 && selectedOption.component) {
158
+ const findComponent = components.find(item => item.name === selectedOption.component);
159
+ const {
160
+ link
161
+ } = findComponent || {};
162
+ const stringLink = (0, _isObject.default)(link) ? link[locale] : link;
163
+ return (0, _index.withoutTrailingSlash)((0, _urlJoin.default)(stringLink, selectedOption.link || '/'));
164
+ }
165
+ return null;
166
+ }, [components, locale, selectedOption]);
167
+ const autocompleteOptions = (0, _react.useMemo)(() => {
168
+ const {
169
+ component
170
+ } = selectedOption || {};
171
+ const componentBlocklet = components.find(item => item.name === component);
172
+ const {
173
+ navigation = []
174
+ } = componentBlocklet || {};
175
+ const flatternedNavigation = (0, _parseNavigationFromBlocklet.flatternNavigation)(navigation, {
176
+ transform(item, parent) {
177
+ if (parent !== null && parent !== void 0 && parent.section) {
178
+ item.section = item.section || parent.section;
179
+ }
180
+ return item;
181
+ }
182
+ });
183
+ return flatternedNavigation.filter(item => item.link)
184
+ // 在指定 section 下只展示能够展示的 navigation
185
+ .filter(item => (0, _parseNavigationFromBlocklet.isMatchSection)(item.section, section)).map(item => {
186
+ return {
187
+ label: item.link,
188
+ title: item.title[locale] || item.title
189
+ };
190
+ });
191
+ }, [selectedOption, components, section, locale]);
192
+ const name = (0, _react.useMemo)(() => {
193
+ const typeMap = {
194
+ add: t('common.create'),
195
+ edit: t('common.edit')
196
+ };
197
+ const typeName = typeMap[state.type];
198
+ if (typeName) {
199
+ return "".concat(typeName, " ").concat(t('navigation.navigation'));
200
+ }
201
+ return '--';
202
+ }, [state.type, t]);
203
+ const reset = (0, _react.useCallback)(() => {
204
+ state.type = defaultType;
205
+ state.linkDisabled = false;
206
+ saveFn.current = () => {};
207
+ setValue('id', undefined);
208
+ setValue('icon', undefined);
209
+ setValue('title', undefined);
210
+ setValue('link', undefined);
211
+ setValue('component', undefined);
212
+ setValue('parent', undefined);
213
+ setValue('role', []);
214
+ state.formState = (0, _cloneDeep.default)(initialFormState);
215
+ clearErrors();
216
+ }, [clearErrors, setValue, state]);
217
+ const patchFormValues = (0, _react.useCallback)(function () {
218
+ let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
219
+ if (state.localeList.length > 0) {
220
+ if (new Set((0, _values.default)(state.formState.title)).size > 1) {
221
+ params.title = state.formState.title;
222
+ }
223
+ if (new Set((0, _values.default)(state.formState.link)).size > 1) {
224
+ params.link = state.formState.link;
225
+ }
226
+ }
227
+ if ((0, _isEmpty.default)(params.role)) {
228
+ params.role = undefined;
229
+ }
230
+ return params;
231
+ }, [state.formState.link, state.formState.title, state.localeList]);
232
+ const close = (0, _react.useCallback)(() => {
233
+ setFalse();
234
+ setTimeout(() => {
235
+ reset();
236
+ });
237
+ }, [reset, setFalse]);
238
+ const add = (0, _react.useCallback)(function () {
239
+ let {
240
+ parent
241
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
242
+ let cb = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : () => {};
243
+ state.type = 'add';
244
+ state.isRoot = !parent;
245
+ setValue('parent', parent === null || parent === void 0 ? void 0 : parent.id);
246
+ saveFn.current = params => {
247
+ cb(close, params);
248
+ };
249
+ setTrue();
250
+ }, [close, setTrue, setValue, state]);
251
+ const edit = (0, _react.useCallback)(function () {
252
+ let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
253
+ let cb = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : () => {};
254
+ const {
255
+ id,
256
+ title,
257
+ icon,
258
+ link,
259
+ parent,
260
+ component,
261
+ role = []
262
+ } = data;
263
+ setValue('id', id);
264
+ setValue('icon', icon);
265
+ if (data.from === 'tmpl') {
266
+ state.linkDisabled = true;
267
+ }
268
+ if ((0, _isString.default)(title)) {
269
+ state.formState.title = state.localeList.reduce((resData, localeItem) => {
270
+ resData[localeItem] = title;
271
+ return resData;
272
+ }, {
273
+ [defaultLocale]: title
274
+ });
275
+ } else if ((0, _isObject.default)(title)) {
276
+ state.formState.title = (0, _cloneDeep.default)(title);
277
+ } else {
278
+ state.formState.title = {};
279
+ }
280
+ if ((0, _isString.default)(link)) {
281
+ state.formState.link = state.localeList.reduce((resData, localeItem) => {
282
+ resData[localeItem] = link;
283
+ return resData;
284
+ }, {
285
+ [defaultLocale]: link
286
+ });
287
+ } else if ((0, _isObject.default)(link)) {
288
+ state.formState.link = (0, _cloneDeep.default)(link);
289
+ } else {
290
+ state.formState.link = {};
291
+ }
292
+ setValue('component', component);
293
+ setValue('parent', parent);
294
+ setValue('role', role || []);
295
+ setTrue();
296
+ state.type = 'edit';
297
+ state.isRoot = !parent;
298
+ saveFn.current = params => {
299
+ const pickData = (0, _pick.default)(params, ['id', 'title', 'icon', 'link', 'role']);
300
+ cb(close, pickData);
301
+ };
302
+ }, [close, setTrue, setValue, state]);
303
+ (0, _react.useImperativeHandle)(ref, () => {
304
+ return {
305
+ add,
306
+ edit,
307
+ close
308
+ };
309
+ }, [add, close, edit]);
310
+ function validTitle(raw) {
311
+ const value = raw === null || raw === void 0 ? void 0 : raw.trim();
312
+ if (!value) return t('common.requiredErrorText', {
313
+ name: t('navigation.form.title')
314
+ });
315
+ if (value.length > MAX_TITLE_LENGTH) return t('navigation.form.titleTooLong', {
316
+ len: MAX_TITLE_LENGTH
317
+ });
318
+ return true;
319
+ }
320
+ async function validIcon(raw) {
321
+ const value = raw === null || raw === void 0 ? void 0 : raw.trim();
322
+ if (value) {
323
+ try {
324
+ await (0, _react2.loadIcon)(value);
325
+ } catch (_unused) {
326
+ return t('navigation.form.invalidIcon');
327
+ }
328
+ }
329
+ return true;
330
+ }
331
+ function validLink(raw) {
332
+ const value = raw === null || raw === void 0 ? void 0 : raw.trim();
333
+ if (!value) {
334
+ if (!state.isRoot) {
335
+ return t('common.requiredErrorText', {
336
+ name: t('navigation.form.link')
337
+ });
338
+ }
339
+ return true;
340
+ }
341
+ if (!(0, _parseNavigationFromBlocklet.checkLink)(value)) {
342
+ return t('navigation.form.invalidLink');
343
+ }
344
+ return true;
345
+ }
346
+ const handleChangeLocale = (0, _react.useCallback)(currentLocale => {
347
+ state.locale = currentLocale;
348
+ if (!state.formState.title[currentLocale]) {
349
+ state.formState.title[currentLocale] = '';
350
+ }
351
+ if (!state.formState.link[currentLocale]) {
352
+ state.formState.link[currentLocale] = '';
353
+ }
354
+ setTimeout(() => {
355
+ clearErrors();
356
+ });
357
+ }, [clearErrors, state]);
358
+ const checkFormState = (0, _react.useCallback)(() => {
359
+ const {
360
+ title,
361
+ link
362
+ } = state.formState;
363
+ for (const key of Object.keys(title)) {
364
+ const validRes = validTitle(title[key]);
365
+ if (validRes !== true) {
366
+ return validRes;
367
+ }
368
+ }
369
+ for (const key of Object.keys(link)) {
370
+ const validRes = validLink(link[key]);
371
+ if (validRes !== true) {
372
+ return validRes;
373
+ }
374
+ }
375
+ return true;
376
+ // eslint-disable-next-line react-hooks/exhaustive-deps
377
+ }, [state.formState]);
378
+ const handleFormSubmit = (0, _react.useCallback)(params => {
379
+ const checkRes = checkFormState();
380
+ if (checkRes === true) {
381
+ saveFn.current(patchFormValues(params));
382
+ } else {
383
+ enqueueSnackbar(checkRes, {
384
+ variant: 'error'
385
+ });
386
+ }
387
+ }, [checkFormState, enqueueSnackbar, patchFormValues]);
388
+ const handleRemoveLocale = (0, _react.useCallback)(currentLocale => {
389
+ state.formState.title = (0, _omit.default)(state.formState.title, currentLocale);
390
+ state.formState.link = (0, _omit.default)(state.formState.link, currentLocale);
391
+ }, [state.formState]);
392
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Dialog.default, {
393
+ open: show,
394
+ title: name,
395
+ onClose: close,
396
+ actions: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
397
+ onClick: handleSubmit(handleFormSubmit),
398
+ color: "primary",
399
+ autoFocus: true,
400
+ variant: "contained",
401
+ children: t('common.confirm')
402
+ }),
403
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_localeTabs.default, {
404
+ sx: {
405
+ mb: 1
406
+ },
407
+ onChange: handleChangeLocale,
408
+ onRemoveLocale: handleRemoveLocale,
409
+ locales: state.localeList
410
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("form", {
411
+ noValidate: true,
412
+ autoComplete: "off",
413
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactHookForm.Controller, {
414
+ name: "title",
415
+ control: control,
416
+ rules: {
417
+ validate: validTitle
418
+ },
419
+ render: _ref3 => {
420
+ var _errors$title, _errors$title2;
421
+ let {
422
+ field
423
+ } = _ref3;
424
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TextField, _objectSpread({
425
+ fullWidth: true,
426
+ variant: "outlined",
427
+ margin: "dense",
428
+ required: true,
429
+ placeholder: t('navigation.form.titlePlaceholder'),
430
+ label: t('navigation.form.title'),
431
+ disabled: state.isEdit,
432
+ error: !!(errors !== null && errors !== void 0 && (_errors$title = errors.title) !== null && _errors$title !== void 0 && _errors$title.message),
433
+ helperText: (errors === null || errors === void 0 ? void 0 : (_errors$title2 = errors.title) === null || _errors$title2 === void 0 ? void 0 : _errors$title2.message) || ' '
434
+ }, field));
435
+ }
436
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactHookForm.Controller, {
437
+ name: "icon",
438
+ control: control,
439
+ rules: {
440
+ validate: validIcon
441
+ },
442
+ render: _ref4 => {
443
+ var _errors$icon, _errors$icon2;
444
+ let {
445
+ field
446
+ } = _ref4;
447
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TextField, _objectSpread(_objectSpread({
448
+ fullWidth: true,
449
+ variant: "outlined",
450
+ margin: "dense",
451
+ placeholder: t('navigation.form.iconPlaceholder'),
452
+ label: t('navigation.form.icon'),
453
+ error: !!(errors !== null && errors !== void 0 && (_errors$icon = errors.icon) !== null && _errors$icon !== void 0 && _errors$icon.message),
454
+ helperText: (errors === null || errors === void 0 ? void 0 : (_errors$icon2 = errors.icon) === null || _errors$icon2 === void 0 ? void 0 : _errors$icon2.message) || /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
455
+ display: "flex",
456
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
457
+ component: "a",
458
+ href: "https://icones.js.org",
459
+ target: "_blank",
460
+ display: "flex",
461
+ alignItems: "center",
462
+ children: [t('navigation.form.findMoreIcon'), ' ', /*#__PURE__*/(0, _jsxRuntime.jsx)(_react2.Icon, {
463
+ style: {
464
+ marginLeft: 4
465
+ },
466
+ icon: "radix-icons:external-link"
467
+ })]
468
+ })
469
+ })
470
+ }, field), {}, {
471
+ InputProps: {
472
+ endAdornment: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.InputAdornment, {
473
+ position: "end",
474
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.IconButton, {
475
+ sx: {
476
+ cursor: 'default'
477
+ },
478
+ disableFocusRipple: true,
479
+ disableRipple: true,
480
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(IconSuffix, {
481
+ icon: watchIcon
482
+ })
483
+ })
484
+ })
485
+ }
486
+ }));
487
+ }
488
+ }), state.isRoot && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactHookForm.Controller, {
489
+ name: "component",
490
+ control: control,
491
+ render: _ref5 => {
492
+ var _errors$component, _errors$component2;
493
+ let {
494
+ field
495
+ } = _ref5;
496
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_simpleSelect.default, _objectSpread({
497
+ fullWidth: true,
498
+ margin: "dense",
499
+ disabled: state.type === 'edit',
500
+ label: t('navigation.form.component'),
501
+ placeholer: t('navigation.form.componentPlaceholder'),
502
+ options: components.map(item => ({
503
+ title: item.title,
504
+ value: item.name,
505
+ description: item.link
506
+ })),
507
+ error: !!(errors !== null && errors !== void 0 && (_errors$component = errors.component) !== null && _errors$component !== void 0 && _errors$component.message),
508
+ helperText: (errors === null || errors === void 0 ? void 0 : (_errors$component2 = errors.component) === null || _errors$component2 === void 0 ? void 0 : _errors$component2.message) || ' '
509
+ }, field));
510
+ }
511
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactHookForm.Controller, {
512
+ name: "link",
513
+ control: control,
514
+ rules: {
515
+ validate: validLink
516
+ },
517
+ render: _ref6 => {
518
+ var _errors$link3, _errors$link4;
519
+ let {
520
+ field
521
+ } = _ref6;
522
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.FormControl, {
523
+ fullWidth: true,
524
+ margin: "dense",
525
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Autocomplete, _objectSpread(_objectSpread({
526
+ disablePortal: true,
527
+ freeSolo: true,
528
+ blurOnSelect: true,
529
+ autoSelect: true,
530
+ fullWidth: true,
531
+ disabled: state.linkDisabled,
532
+ isOptionEqualToValue: option => option.label,
533
+ options: autocompleteOptions,
534
+ renderInput: params => {
535
+ var _errors$link, _errors$link2;
536
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TextField, _objectSpread(_objectSpread({}, params), {}, {
537
+ placeholder: t('navigation.form.linkPlaceholder'),
538
+ label: t('navigation.form.link'),
539
+ error: !!(errors !== null && errors !== void 0 && (_errors$link = errors.link) !== null && _errors$link !== void 0 && _errors$link.message),
540
+ helperText: (errors === null || errors === void 0 ? void 0 : (_errors$link2 = errors.link) === null || _errors$link2 === void 0 ? void 0 : _errors$link2.message) || '/abc/bcd or /abc or https://arcblock.io'
541
+ // FIXME: 添加了 startAdornment 后,autocomplete 选项无法显示,之后换成 antd 的 autocomplete 可以解决这个问题
542
+ ,
543
+ InputProps: {
544
+ startAdornment: linkPrefix ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.InputAdornment, {
545
+ position: "start",
546
+ sx: {
547
+ textDecoration: (0, _isAbsoluteUrl.default)(watchLink || '') ? 'line-through' : ''
548
+ },
549
+ children: linkPrefix
550
+ }) : null
551
+ }
552
+ }));
553
+ },
554
+ renderOption: (props, option) => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, _objectSpread(_objectSpread({
555
+ component: "li"
556
+ }, props), {}, {
557
+ children: [option.label, /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
558
+ marginLeft: 1,
559
+ component: "span",
560
+ variant: "body2",
561
+ color: "text.secondary",
562
+ children: option.title
563
+ })]
564
+ })),
565
+ error: !!(errors !== null && errors !== void 0 && (_errors$link3 = errors.link) !== null && _errors$link3 !== void 0 && _errors$link3.message),
566
+ helperText: (errors === null || errors === void 0 ? void 0 : (_errors$link4 = errors.link) === null || _errors$link4 === void 0 ? void 0 : _errors$link4.message) || ' ',
567
+ margin: "dense"
568
+ }, field), {}, {
569
+ onChange: () => {},
570
+ onInputChange: (e, value) => {
571
+ field.onChange(value);
572
+ }
573
+ }))
574
+ });
575
+ }
576
+ }), ['dashboard', 'sessionManager'].includes(section) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactHookForm.Controller, {
577
+ name: "role",
578
+ control: control,
579
+ render: _ref7 => {
580
+ var _errors$role, _errors$role2;
581
+ let {
582
+ field
583
+ } = _ref7;
584
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_simpleSelect.default, _objectSpread({
585
+ fullWidth: true,
586
+ multiple: true,
587
+ margin: "dense",
588
+ label: t('navigation.form.role'),
589
+ placeholer: t('navigation.form.rolePlaceholder'),
590
+ options: roles.map(role => ({
591
+ title: role.title,
592
+ value: role.name
593
+ })),
594
+ error: !!(errors !== null && errors !== void 0 && (_errors$role = errors.role) !== null && _errors$role !== void 0 && _errors$role.message),
595
+ helperText: (errors === null || errors === void 0 ? void 0 : (_errors$role2 = errors.role) === null || _errors$role2 === void 0 ? void 0 : _errors$role2.message) || ' '
596
+ }, field));
597
+ }
598
+ })]
599
+ })]
600
+ });
601
+ });
602
+ NavigationDialog.propTypes = {
603
+ section: _propTypes.default.string,
604
+ components: _propTypes.default.array,
605
+ rawNavigations: _propTypes.default.array
606
+ };
607
+ NavigationDialog.defaultProps = {
608
+ section: '',
609
+ components: [],
610
+ rawNavigations: []
611
+ };
612
+ var _default = NavigationDialog;
613
+ exports.default = _default;