1 | import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
2 | import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
3 | import _extends from "@babel/runtime/helpers/esm/extends";
|
4 | import { createVNode as _createVNode, resolveDirective as _resolveDirective } from "vue";
|
5 | import { computed, createVNode, defineComponent, provide, ref } from 'vue';
|
6 | import PropTypes from '../_util/vue-types';
|
7 | import useConfigInject from '../_util/hooks/useConfigInject';
|
8 | import { SiderHookProviderKey } from './injectionKey';
|
9 | export var basicProps = {
|
10 | prefixCls: PropTypes.string,
|
11 | hasSider: PropTypes.looseBool,
|
12 | tagName: PropTypes.string
|
13 | };
|
14 |
|
15 | function generator(_ref) {
|
16 | var suffixCls = _ref.suffixCls,
|
17 | tagName = _ref.tagName,
|
18 | name = _ref.name;
|
19 | return function (BasicComponent) {
|
20 | var Adapter = defineComponent({
|
21 | name: name,
|
22 | props: basicProps,
|
23 | setup: function setup(props, _ref2) {
|
24 | var slots = _ref2.slots;
|
25 |
|
26 | var _useConfigInject = useConfigInject(suffixCls, props),
|
27 | prefixCls = _useConfigInject.prefixCls;
|
28 |
|
29 | return function () {
|
30 | var basicComponentProps = _extends(_extends({}, props), {
|
31 | prefixCls: prefixCls.value,
|
32 | tagName: tagName
|
33 | });
|
34 |
|
35 | return _createVNode(BasicComponent, basicComponentProps, slots);
|
36 | };
|
37 | }
|
38 | });
|
39 | return Adapter;
|
40 | };
|
41 | }
|
42 |
|
43 | var Basic = defineComponent({
|
44 | props: basicProps,
|
45 | setup: function setup(props, _ref3) {
|
46 | var slots = _ref3.slots;
|
47 | return function () {
|
48 | return createVNode(props.tagName, {
|
49 | class: props.prefixCls
|
50 | }, slots);
|
51 | };
|
52 | }
|
53 | });
|
54 | var BasicLayout = defineComponent({
|
55 | props: basicProps,
|
56 | setup: function setup(props, _ref4) {
|
57 | var slots = _ref4.slots;
|
58 |
|
59 | var _useConfigInject2 = useConfigInject('', props),
|
60 | direction = _useConfigInject2.direction;
|
61 |
|
62 | var siders = ref([]);
|
63 | var siderHookProvider = {
|
64 | addSider: function addSider(id) {
|
65 | siders.value = [].concat(_toConsumableArray(siders.value), [id]);
|
66 | },
|
67 | removeSider: function removeSider(id) {
|
68 | siders.value = siders.value.filter(function (currentId) {
|
69 | return currentId !== id;
|
70 | });
|
71 | }
|
72 | };
|
73 | provide(SiderHookProviderKey, siderHookProvider);
|
74 | var divCls = computed(function () {
|
75 | var _ref5;
|
76 |
|
77 | var prefixCls = props.prefixCls,
|
78 | hasSider = props.hasSider;
|
79 | return _ref5 = {}, _defineProperty(_ref5, "".concat(prefixCls), true), _defineProperty(_ref5, "".concat(prefixCls, "-has-sider"), typeof hasSider === 'boolean' ? hasSider : siders.value.length > 0), _defineProperty(_ref5, "".concat(prefixCls, "-rtl"), direction.value === 'rtl'), _ref5;
|
80 | });
|
81 | return function () {
|
82 | var tagName = props.tagName;
|
83 | return createVNode(tagName, {
|
84 | class: divCls.value
|
85 | }, slots);
|
86 | };
|
87 | }
|
88 | });
|
89 | var Layout = generator({
|
90 | suffixCls: 'layout',
|
91 | tagName: 'section',
|
92 | name: 'ALayout'
|
93 | })(BasicLayout);
|
94 | var Header = generator({
|
95 | suffixCls: 'layout-header',
|
96 | tagName: 'header',
|
97 | name: 'ALayoutHeader'
|
98 | })(Basic);
|
99 | var Footer = generator({
|
100 | suffixCls: 'layout-footer',
|
101 | tagName: 'footer',
|
102 | name: 'ALayoutFooter'
|
103 | })(Basic);
|
104 | var Content = generator({
|
105 | suffixCls: 'layout-content',
|
106 | tagName: 'main',
|
107 | name: 'ALayoutContent'
|
108 | })(Basic);
|
109 | export { Header, Footer, Content };
|
110 | export default Layout; |
\ | No newline at end of file |