UNPKG

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