1 | import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2 | import { List, Select, Switch, Tooltip } from 'antd';
|
3 | import React from 'react';
|
4 | import { defaultSettings } from '../../defaultSettings';
|
5 | import { getFormatMessage } from './index';
|
6 | export var renderLayoutSettingItem = function renderLayoutSettingItem(item) {
|
7 | var action = React.cloneElement(item.action, {
|
8 | disabled: item.disabled
|
9 | });
|
10 | return _jsx(Tooltip, {
|
11 | title: item.disabled ? item.disabledReason : '',
|
12 | placement: "left",
|
13 | children: _jsx(List.Item, {
|
14 | actions: [action],
|
15 | children: _jsx("span", {
|
16 | style: {
|
17 | opacity: item.disabled ? 0.5 : 1
|
18 | },
|
19 | children: item.title
|
20 | })
|
21 | })
|
22 | });
|
23 | };
|
24 | var LayoutSetting = function LayoutSetting(_ref) {
|
25 | var _ref$settings = _ref.settings,
|
26 | settings = _ref$settings === void 0 ? {} : _ref$settings,
|
27 | prefixCls = _ref.prefixCls,
|
28 | changeSetting = _ref.changeSetting,
|
29 | hashId = _ref.hashId;
|
30 | var formatMessage = getFormatMessage();
|
31 | var _ref2 = settings || defaultSettings,
|
32 | contentWidth = _ref2.contentWidth,
|
33 | splitMenus = _ref2.splitMenus,
|
34 | fixedHeader = _ref2.fixedHeader,
|
35 | layout = _ref2.layout,
|
36 | fixSiderbar = _ref2.fixSiderbar;
|
37 | return _jsx(List, {
|
38 | className: "".concat(prefixCls, "-list ").concat(hashId),
|
39 | split: false,
|
40 | dataSource: [{
|
41 | title: formatMessage({
|
42 | id: 'app.setting.content-width',
|
43 | defaultMessage: 'Content Width'
|
44 | }),
|
45 | action: _jsxs(Select, {
|
46 | value: contentWidth || 'Fixed',
|
47 | size: "small",
|
48 | className: "content-width ".concat(hashId),
|
49 | onSelect: function onSelect(value) {
|
50 | changeSetting('contentWidth', value);
|
51 | },
|
52 | style: {
|
53 | width: 80
|
54 | },
|
55 | children: [layout === 'side' ? null : _jsx(Select.Option, {
|
56 | value: "Fixed",
|
57 | children: formatMessage({
|
58 | id: 'app.setting.content-width.fixed',
|
59 | defaultMessage: 'Fixed'
|
60 | })
|
61 | }), _jsx(Select.Option, {
|
62 | value: "Fluid",
|
63 | children: formatMessage({
|
64 | id: 'app.setting.content-width.fluid',
|
65 | defaultMessage: 'Fluid'
|
66 | })
|
67 | })]
|
68 | })
|
69 | }, {
|
70 | title: formatMessage({
|
71 | id: 'app.setting.fixedheader',
|
72 | defaultMessage: 'Fixed Header'
|
73 | }),
|
74 | action: _jsx(Switch, {
|
75 | size: "small",
|
76 | className: "fixed-header",
|
77 | checked: !!fixedHeader,
|
78 | onChange: function onChange(checked) {
|
79 | changeSetting('fixedHeader', checked);
|
80 | }
|
81 | })
|
82 | }, {
|
83 | title: formatMessage({
|
84 | id: 'app.setting.fixedsidebar',
|
85 | defaultMessage: 'Fixed Sidebar'
|
86 | }),
|
87 | disabled: layout === 'top',
|
88 | disabledReason: formatMessage({
|
89 | id: 'app.setting.fixedsidebar.hint',
|
90 | defaultMessage: 'Works on Side Menu Layout'
|
91 | }),
|
92 | action: _jsx(Switch, {
|
93 | size: "small",
|
94 | className: "fix-siderbar",
|
95 | checked: !!fixSiderbar,
|
96 | onChange: function onChange(checked) {
|
97 | return changeSetting('fixSiderbar', checked);
|
98 | }
|
99 | })
|
100 | }, {
|
101 | title: formatMessage({
|
102 | id: 'app.setting.splitMenus'
|
103 | }),
|
104 | disabled: layout !== 'mix',
|
105 | action: _jsx(Switch, {
|
106 | size: "small",
|
107 | checked: !!splitMenus,
|
108 | className: "split-menus",
|
109 | onChange: function onChange(checked) {
|
110 | changeSetting('splitMenus', checked);
|
111 | }
|
112 | })
|
113 | }],
|
114 | renderItem: renderLayoutSettingItem
|
115 | });
|
116 | };
|
117 | export { LayoutSetting }; |
\ | No newline at end of file |