@onereach/ui-components 2.72.0 → 2.72.1-beta.2249.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/bundled/v2/OrSidebar-efd4b98a.js +464 -0
- package/dist/bundled/v2/components/index.js +1 -1
- package/dist/bundled/v2/components/or-sidebar-v3/OrSidebar.stories3.d.ts +36 -1
- package/dist/bundled/v2/components/or-sidebar-v3/OrSidebar.vue.d.ts +49 -4
- package/dist/bundled/v2/components/or-sidebar-v3/OrSidebarCollapseButton.stories3.d.ts +12 -0
- package/dist/bundled/v2/components/or-sidebar-v3/OrSidebarCollapseButton.vue.d.ts +53 -0
- package/dist/bundled/v2/components/or-sidebar-v3/index.js +12 -1
- package/dist/bundled/v2/components/or-sidebar-v3/styles.d.ts +9 -1
- package/dist/bundled/v2/index.js +2 -2
- package/dist/bundled/v3/OrSidebar.vue_vue_type_script_lang-66f8f0fd.js +356 -0
- package/dist/bundled/v3/components/index.js +1 -1
- package/dist/bundled/v3/components/or-sidebar-v3/OrSidebar.stories3.d.ts +36 -1
- package/dist/bundled/v3/components/or-sidebar-v3/OrSidebar.vue.d.ts +49 -4
- package/dist/bundled/v3/components/or-sidebar-v3/OrSidebarCollapseButton.stories3.d.ts +12 -0
- package/dist/bundled/v3/components/or-sidebar-v3/OrSidebarCollapseButton.vue.d.ts +53 -0
- package/dist/bundled/v3/components/or-sidebar-v3/index.js +14 -1
- package/dist/bundled/v3/components/or-sidebar-v3/styles.d.ts +9 -1
- package/dist/bundled/v3/index.js +25 -9
- package/dist/esm/v2/OrSidebar-b7202f16.js +461 -0
- package/dist/esm/v2/components/index.js +1 -1
- package/dist/esm/v2/components/or-sidebar-v3/OrSidebar.stories3.d.ts +36 -1
- package/dist/esm/v2/components/or-sidebar-v3/OrSidebar.vue.d.ts +49 -4
- package/dist/esm/v2/components/or-sidebar-v3/OrSidebarCollapseButton.stories3.d.ts +12 -0
- package/dist/esm/v2/components/or-sidebar-v3/OrSidebarCollapseButton.vue.d.ts +53 -0
- package/dist/esm/v2/components/or-sidebar-v3/index.js +12 -1
- package/dist/esm/v2/components/or-sidebar-v3/styles.d.ts +9 -1
- package/dist/esm/v2/index.js +1 -1
- package/dist/esm/v3/OrSidebar-3567338f.js +396 -0
- package/dist/esm/v3/components/index.js +1 -1
- package/dist/esm/v3/components/or-sidebar-v3/OrSidebar.stories3.d.ts +36 -1
- package/dist/esm/v3/components/or-sidebar-v3/OrSidebar.vue.d.ts +49 -4
- package/dist/esm/v3/components/or-sidebar-v3/OrSidebarCollapseButton.stories3.d.ts +12 -0
- package/dist/esm/v3/components/or-sidebar-v3/OrSidebarCollapseButton.vue.d.ts +53 -0
- package/dist/esm/v3/components/or-sidebar-v3/index.js +11 -1
- package/dist/esm/v3/components/or-sidebar-v3/styles.d.ts +9 -1
- package/dist/esm/v3/index.js +1 -1
- package/package.json +2 -3
- package/src/components/or-sidebar-v3/OrSidebar.docs.mdx +6 -0
- package/src/components/or-sidebar-v3/OrSidebar.stories3.ts +253 -12
- package/src/components/or-sidebar-v3/OrSidebar.vue +130 -23
- package/src/components/or-sidebar-v3/OrSidebarCollapseButton.stories3.ts +48 -0
- package/src/components/or-sidebar-v3/OrSidebarCollapseButton.vue +74 -0
- package/src/components/or-sidebar-v3/styles.ts +164 -9
- package/dist/bundled/v2/OrSidebar-c95ef614.js +0 -230
- package/dist/bundled/v3/OrSidebar.vue_vue_type_script_lang-ce0b152c.js +0 -181
- package/dist/esm/v2/OrSidebar-fabc7bc9.js +0 -228
- package/dist/esm/v3/OrSidebar-a62972f5.js +0 -206
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
import { useDraggable, useElementBounding } from '@vueuse/core';
|
|
2
|
-
import _ from 'lodash';
|
|
3
|
-
import './index-fa6eb4ca.js';
|
|
4
|
-
import { defineComponent, ref, computed, watch } from '@vue/composition-api/dist/vue-composition-api.mjs';
|
|
5
|
-
import { n as normalizeComponent } from './normalize-component-6e8e3d80.js';
|
|
6
|
-
|
|
7
|
-
var OrSidebarPlacement;
|
|
8
|
-
(function (OrSidebarPlacement) {
|
|
9
|
-
OrSidebarPlacement["left"] = "left";
|
|
10
|
-
OrSidebarPlacement["right"] = "right";
|
|
11
|
-
})(OrSidebarPlacement || (OrSidebarPlacement = {}));
|
|
12
|
-
|
|
13
|
-
const SidebarRoot = [
|
|
14
|
-
// Position
|
|
15
|
-
'relative',
|
|
16
|
-
// Layout
|
|
17
|
-
'flex', 'flex-col', 'shrink-0',
|
|
18
|
-
// Box
|
|
19
|
-
'min-h-0', 'p-0'];
|
|
20
|
-
const SidebarRootSides = {
|
|
21
|
-
[OrSidebarPlacement.left]: [
|
|
22
|
-
// Borders
|
|
23
|
-
'border-r-[1px]', 'border-r-solid', 'border-r-secondary dark:border-r-secondary-dark'],
|
|
24
|
-
[OrSidebarPlacement.right]: [
|
|
25
|
-
// Borders
|
|
26
|
-
'border-l-[1px]', 'border-l-solid', 'border-l-secondary dark:border-l-secondary-dark']
|
|
27
|
-
};
|
|
28
|
-
const SidebarResize = [
|
|
29
|
-
// Position
|
|
30
|
-
'absolute', 'inset-y-none', 'z-[1]',
|
|
31
|
-
// Box
|
|
32
|
-
'w-[12px]', 'h-[100%]',
|
|
33
|
-
// Cursor
|
|
34
|
-
'cursor-ew-resize'];
|
|
35
|
-
const SidebarResizeSides = {
|
|
36
|
-
[OrSidebarPlacement.left]: [
|
|
37
|
-
// Position
|
|
38
|
-
'-right-[1px]',
|
|
39
|
-
// Borders
|
|
40
|
-
'hover:border-r-2', 'hover:border-r-primary hover:dark:border-r-primary-dark',
|
|
41
|
-
// Transition
|
|
42
|
-
'transition-[border-right]'],
|
|
43
|
-
[OrSidebarPlacement.right]: [
|
|
44
|
-
// Position
|
|
45
|
-
'-left-[1px]',
|
|
46
|
-
// Borders
|
|
47
|
-
'hover:border-l-2', 'hover:border-l-primary hover:dark:border-l-primary-dark',
|
|
48
|
-
// Transition
|
|
49
|
-
'transition-[border-left]']
|
|
50
|
-
};
|
|
51
|
-
const SidebarResizingSides = {
|
|
52
|
-
[OrSidebarPlacement.left]: [
|
|
53
|
-
// Borders
|
|
54
|
-
'border-r-2', 'border-r-primary dark:border-r-primary-dark'],
|
|
55
|
-
[OrSidebarPlacement.right]: [
|
|
56
|
-
// Borders
|
|
57
|
-
'border-l-2', 'border-l-primary dark:border-l-primary-dark']
|
|
58
|
-
};
|
|
59
|
-
const SidebarMain = [
|
|
60
|
-
// Layout
|
|
61
|
-
'flex', 'flex-col', 'grow',
|
|
62
|
-
// Box
|
|
63
|
-
'min-h-0'];
|
|
64
|
-
const SidebarHeader = [
|
|
65
|
-
// Sizing
|
|
66
|
-
'p-md'];
|
|
67
|
-
const SidebarContent = [
|
|
68
|
-
// Layout
|
|
69
|
-
'grow', 'overflow-auto',
|
|
70
|
-
// Sizing
|
|
71
|
-
'p-md'];
|
|
72
|
-
const SidebarFooter = [
|
|
73
|
-
// Sizing
|
|
74
|
-
'p-md',
|
|
75
|
-
// Borders
|
|
76
|
-
'border-t-[1px]', 'border-t-solid', 'border-t-secondary dark:border-t-secondary-dark'];
|
|
77
|
-
|
|
78
|
-
var script = defineComponent({
|
|
79
|
-
name: 'OrSidebar',
|
|
80
|
-
props: {
|
|
81
|
-
width: {
|
|
82
|
-
type: Number,
|
|
83
|
-
required: false,
|
|
84
|
-
default: 0,
|
|
85
|
-
validator: value => _.isNumber(value) && value >= 0
|
|
86
|
-
},
|
|
87
|
-
minimumWidth: {
|
|
88
|
-
type: Number,
|
|
89
|
-
required: false,
|
|
90
|
-
default: 350,
|
|
91
|
-
validator: value => _.isNumber(value) && value >= 0
|
|
92
|
-
},
|
|
93
|
-
/**
|
|
94
|
-
* User may put the component on the right or the left side of a container.
|
|
95
|
-
* This property mirrors the resizing behavior (drag direction) and styling (horizontal border) of the sidebar.
|
|
96
|
-
*
|
|
97
|
-
* Note: the property doesn't reposition the component in the parent container.
|
|
98
|
-
* @values left, right
|
|
99
|
-
*/
|
|
100
|
-
side: {
|
|
101
|
-
type: String,
|
|
102
|
-
default: OrSidebarPlacement.right,
|
|
103
|
-
validator: value => _.includes(_.values(OrSidebarPlacement), value)
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
emits: ['change:width'],
|
|
107
|
-
setup(props, {
|
|
108
|
-
emit
|
|
109
|
-
}) {
|
|
110
|
-
// Refs
|
|
111
|
-
const root = ref();
|
|
112
|
-
const resizeBar = ref(null);
|
|
113
|
-
const parentContainer = computed(() => {
|
|
114
|
-
var _a;
|
|
115
|
-
return (_a = root.value) === null || _a === void 0 ? void 0 : _a.parentElement;
|
|
116
|
-
});
|
|
117
|
-
// State
|
|
118
|
-
const startPositionX = ref(0);
|
|
119
|
-
const isResizing = ref(false);
|
|
120
|
-
const localWidth = ref(props.width >= props.minimumWidth ? props.width : props.minimumWidth);
|
|
121
|
-
// Styles
|
|
122
|
-
const sidebarStyle = computed(() => ({
|
|
123
|
-
width: localWidth.value + 'px'
|
|
124
|
-
}));
|
|
125
|
-
const rootStyles = computed(() => ['or-sidebar', ...SidebarRoot, ...SidebarRootSides[props.side]]);
|
|
126
|
-
const resizeStyles = computed(() => [...SidebarResize, ...SidebarResizeSides[props.side], ...(isResizing.value ? SidebarResizingSides[props.side] : [])]);
|
|
127
|
-
const mainStyles = computed(() => [...SidebarMain]);
|
|
128
|
-
const headerStyles = computed(() => [...SidebarHeader]);
|
|
129
|
-
const contentStyles = computed(() => [...SidebarContent]);
|
|
130
|
-
const footerStyles = computed(() => [...SidebarFooter]);
|
|
131
|
-
// Effects
|
|
132
|
-
useDraggable(resizeBar, {
|
|
133
|
-
preventDefault: true,
|
|
134
|
-
onStart: (position, event) => {
|
|
135
|
-
document.body.style.cursor = 'ew-resize';
|
|
136
|
-
document.body.style.userSelect = 'none';
|
|
137
|
-
startPositionX.value = event.x;
|
|
138
|
-
isResizing.value = true;
|
|
139
|
-
},
|
|
140
|
-
onMove: position => {
|
|
141
|
-
const delta = (position.x - startPositionX.value) * (props.side === OrSidebarPlacement.left ? -1 : 1);
|
|
142
|
-
const newWidth = localWidth.value - delta;
|
|
143
|
-
localWidth.value = newWidth > maximumWidth.value ? maximumWidth.value : newWidth < props.minimumWidth ? props.minimumWidth : newWidth;
|
|
144
|
-
startPositionX.value = position.x;
|
|
145
|
-
},
|
|
146
|
-
onEnd: () => {
|
|
147
|
-
document.body.style.cursor = '';
|
|
148
|
-
document.body.style.userSelect = '';
|
|
149
|
-
isResizing.value = false;
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
const {
|
|
153
|
-
width: maximumWidth
|
|
154
|
-
} = useElementBounding(parentContainer);
|
|
155
|
-
watch(() => props.width, newValue => {
|
|
156
|
-
if (newValue !== localWidth.value) {
|
|
157
|
-
localWidth.value = newValue > maximumWidth.value ? maximumWidth.value : newValue < props.minimumWidth ? props.minimumWidth : newValue;
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
watch(() => props.minimumWidth, newMinimum => {
|
|
161
|
-
if (newMinimum > localWidth.value) localWidth.value = newMinimum;
|
|
162
|
-
});
|
|
163
|
-
watch(maximumWidth, newMaximum => {
|
|
164
|
-
if (newMaximum < localWidth.value) localWidth.value = newMaximum;
|
|
165
|
-
});
|
|
166
|
-
watch(localWidth, val => emit('change:width', val));
|
|
167
|
-
return {
|
|
168
|
-
root,
|
|
169
|
-
resizeBar,
|
|
170
|
-
isResizing,
|
|
171
|
-
localWidth,
|
|
172
|
-
sidebarStyle,
|
|
173
|
-
rootStyles,
|
|
174
|
-
resizeStyles,
|
|
175
|
-
mainStyles,
|
|
176
|
-
headerStyles,
|
|
177
|
-
contentStyles,
|
|
178
|
-
footerStyles
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
/* script */
|
|
184
|
-
const __vue_script__ = script;
|
|
185
|
-
|
|
186
|
-
/* template */
|
|
187
|
-
var __vue_render__ = function () {
|
|
188
|
-
var _vm = this;
|
|
189
|
-
var _h = _vm.$createElement;
|
|
190
|
-
var _c = _vm._self._c || _h;
|
|
191
|
-
return _c('aside', {
|
|
192
|
-
ref: "root",
|
|
193
|
-
class: _vm.rootStyles,
|
|
194
|
-
style: _vm.sidebarStyle
|
|
195
|
-
}, [_c('div', {
|
|
196
|
-
ref: "resizeBar",
|
|
197
|
-
class: _vm.resizeStyles
|
|
198
|
-
}), _vm._v(" "), _c('div', {
|
|
199
|
-
class: _vm.mainStyles
|
|
200
|
-
}, [_vm.$slots.header ? _c('div', {
|
|
201
|
-
class: _vm.headerStyles
|
|
202
|
-
}, [_vm._t("header")], 2) : _vm._e(), _vm._v(" "), _c('div', {
|
|
203
|
-
class: _vm.contentStyles
|
|
204
|
-
}, [_vm._t("default")], 2)]), _vm._v(" "), _vm.$slots.footer ? _c('div', {
|
|
205
|
-
class: _vm.footerStyles
|
|
206
|
-
}, [_vm._t("footer")], 2) : _vm._e()]);
|
|
207
|
-
};
|
|
208
|
-
var __vue_staticRenderFns__ = [];
|
|
209
|
-
|
|
210
|
-
/* style */
|
|
211
|
-
const __vue_inject_styles__ = undefined;
|
|
212
|
-
/* scoped */
|
|
213
|
-
const __vue_scope_id__ = undefined;
|
|
214
|
-
/* module identifier */
|
|
215
|
-
const __vue_module_identifier__ = undefined;
|
|
216
|
-
/* functional template */
|
|
217
|
-
const __vue_is_functional_template__ = false;
|
|
218
|
-
/* style inject */
|
|
219
|
-
|
|
220
|
-
/* style inject SSR */
|
|
221
|
-
|
|
222
|
-
/* style inject shadow dom */
|
|
223
|
-
|
|
224
|
-
const __vue_component__ = /*#__PURE__*/normalizeComponent({
|
|
225
|
-
render: __vue_render__,
|
|
226
|
-
staticRenderFns: __vue_staticRenderFns__
|
|
227
|
-
}, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, false, undefined, undefined, undefined);
|
|
228
|
-
var __vue_component__$1 = __vue_component__;
|
|
229
|
-
|
|
230
|
-
export { OrSidebarPlacement as O, __vue_component__$1 as _ };
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
import { useDraggable, useElementBounding } from '@vueuse/core';
|
|
2
|
-
import _ from 'lodash';
|
|
3
|
-
import { defineComponent, ref, computed, watch } from 'vue';
|
|
4
|
-
|
|
5
|
-
var OrSidebarPlacement;
|
|
6
|
-
(function (OrSidebarPlacement) {
|
|
7
|
-
OrSidebarPlacement["left"] = "left";
|
|
8
|
-
OrSidebarPlacement["right"] = "right";
|
|
9
|
-
})(OrSidebarPlacement || (OrSidebarPlacement = {}));
|
|
10
|
-
|
|
11
|
-
const SidebarRoot = [
|
|
12
|
-
// Position
|
|
13
|
-
'relative',
|
|
14
|
-
// Layout
|
|
15
|
-
'flex', 'flex-col', 'shrink-0',
|
|
16
|
-
// Box
|
|
17
|
-
'min-h-0', 'p-0'];
|
|
18
|
-
const SidebarRootSides = {
|
|
19
|
-
[OrSidebarPlacement.left]: [
|
|
20
|
-
// Borders
|
|
21
|
-
'border-r-[1px]', 'border-r-solid', 'border-r-secondary dark:border-r-secondary-dark'],
|
|
22
|
-
[OrSidebarPlacement.right]: [
|
|
23
|
-
// Borders
|
|
24
|
-
'border-l-[1px]', 'border-l-solid', 'border-l-secondary dark:border-l-secondary-dark']
|
|
25
|
-
};
|
|
26
|
-
const SidebarResize = [
|
|
27
|
-
// Position
|
|
28
|
-
'absolute', 'inset-y-none', 'z-[1]',
|
|
29
|
-
// Box
|
|
30
|
-
'w-[12px]', 'h-[100%]',
|
|
31
|
-
// Cursor
|
|
32
|
-
'cursor-ew-resize'];
|
|
33
|
-
const SidebarResizeSides = {
|
|
34
|
-
[OrSidebarPlacement.left]: [
|
|
35
|
-
// Position
|
|
36
|
-
'-right-[1px]',
|
|
37
|
-
// Borders
|
|
38
|
-
'hover:border-r-2', 'hover:border-r-primary hover:dark:border-r-primary-dark',
|
|
39
|
-
// Transition
|
|
40
|
-
'transition-[border-right]'],
|
|
41
|
-
[OrSidebarPlacement.right]: [
|
|
42
|
-
// Position
|
|
43
|
-
'-left-[1px]',
|
|
44
|
-
// Borders
|
|
45
|
-
'hover:border-l-2', 'hover:border-l-primary hover:dark:border-l-primary-dark',
|
|
46
|
-
// Transition
|
|
47
|
-
'transition-[border-left]']
|
|
48
|
-
};
|
|
49
|
-
const SidebarResizingSides = {
|
|
50
|
-
[OrSidebarPlacement.left]: [
|
|
51
|
-
// Borders
|
|
52
|
-
'border-r-2', 'border-r-primary dark:border-r-primary-dark'],
|
|
53
|
-
[OrSidebarPlacement.right]: [
|
|
54
|
-
// Borders
|
|
55
|
-
'border-l-2', 'border-l-primary dark:border-l-primary-dark']
|
|
56
|
-
};
|
|
57
|
-
const SidebarMain = [
|
|
58
|
-
// Layout
|
|
59
|
-
'flex', 'flex-col', 'grow',
|
|
60
|
-
// Box
|
|
61
|
-
'min-h-0'];
|
|
62
|
-
const SidebarHeader = [
|
|
63
|
-
// Sizing
|
|
64
|
-
'p-md'];
|
|
65
|
-
const SidebarContent = [
|
|
66
|
-
// Layout
|
|
67
|
-
'grow', 'overflow-auto',
|
|
68
|
-
// Sizing
|
|
69
|
-
'p-md'];
|
|
70
|
-
const SidebarFooter = [
|
|
71
|
-
// Sizing
|
|
72
|
-
'p-md',
|
|
73
|
-
// Borders
|
|
74
|
-
'border-t-[1px]', 'border-t-solid', 'border-t-secondary dark:border-t-secondary-dark'];
|
|
75
|
-
|
|
76
|
-
var script = defineComponent({
|
|
77
|
-
name: 'OrSidebar',
|
|
78
|
-
props: {
|
|
79
|
-
width: {
|
|
80
|
-
type: Number,
|
|
81
|
-
required: false,
|
|
82
|
-
default: 0,
|
|
83
|
-
validator: value => _.isNumber(value) && value >= 0
|
|
84
|
-
},
|
|
85
|
-
minimumWidth: {
|
|
86
|
-
type: Number,
|
|
87
|
-
required: false,
|
|
88
|
-
default: 350,
|
|
89
|
-
validator: value => _.isNumber(value) && value >= 0
|
|
90
|
-
},
|
|
91
|
-
/**
|
|
92
|
-
* User may put the component on the right or the left side of a container.
|
|
93
|
-
* This property mirrors the resizing behavior (drag direction) and styling (horizontal border) of the sidebar.
|
|
94
|
-
*
|
|
95
|
-
* Note: the property doesn't reposition the component in the parent container.
|
|
96
|
-
* @values left, right
|
|
97
|
-
*/
|
|
98
|
-
side: {
|
|
99
|
-
type: String,
|
|
100
|
-
default: OrSidebarPlacement.right,
|
|
101
|
-
validator: value => _.includes(_.values(OrSidebarPlacement), value)
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
emits: ['change:width'],
|
|
105
|
-
setup(props, {
|
|
106
|
-
emit
|
|
107
|
-
}) {
|
|
108
|
-
// Refs
|
|
109
|
-
const root = ref();
|
|
110
|
-
const resizeBar = ref(null);
|
|
111
|
-
const parentContainer = computed(() => {
|
|
112
|
-
var _a;
|
|
113
|
-
return (_a = root.value) === null || _a === void 0 ? void 0 : _a.parentElement;
|
|
114
|
-
});
|
|
115
|
-
// State
|
|
116
|
-
const startPositionX = ref(0);
|
|
117
|
-
const isResizing = ref(false);
|
|
118
|
-
const localWidth = ref(props.width >= props.minimumWidth ? props.width : props.minimumWidth);
|
|
119
|
-
// Styles
|
|
120
|
-
const sidebarStyle = computed(() => ({
|
|
121
|
-
width: localWidth.value + 'px'
|
|
122
|
-
}));
|
|
123
|
-
const rootStyles = computed(() => ['or-sidebar', ...SidebarRoot, ...SidebarRootSides[props.side]]);
|
|
124
|
-
const resizeStyles = computed(() => [...SidebarResize, ...SidebarResizeSides[props.side], ...(isResizing.value ? SidebarResizingSides[props.side] : [])]);
|
|
125
|
-
const mainStyles = computed(() => [...SidebarMain]);
|
|
126
|
-
const headerStyles = computed(() => [...SidebarHeader]);
|
|
127
|
-
const contentStyles = computed(() => [...SidebarContent]);
|
|
128
|
-
const footerStyles = computed(() => [...SidebarFooter]);
|
|
129
|
-
// Effects
|
|
130
|
-
useDraggable(resizeBar, {
|
|
131
|
-
preventDefault: true,
|
|
132
|
-
onStart: (position, event) => {
|
|
133
|
-
document.body.style.cursor = 'ew-resize';
|
|
134
|
-
document.body.style.userSelect = 'none';
|
|
135
|
-
startPositionX.value = event.x;
|
|
136
|
-
isResizing.value = true;
|
|
137
|
-
},
|
|
138
|
-
onMove: position => {
|
|
139
|
-
const delta = (position.x - startPositionX.value) * (props.side === OrSidebarPlacement.left ? -1 : 1);
|
|
140
|
-
const newWidth = localWidth.value - delta;
|
|
141
|
-
localWidth.value = newWidth > maximumWidth.value ? maximumWidth.value : newWidth < props.minimumWidth ? props.minimumWidth : newWidth;
|
|
142
|
-
startPositionX.value = position.x;
|
|
143
|
-
},
|
|
144
|
-
onEnd: () => {
|
|
145
|
-
document.body.style.cursor = '';
|
|
146
|
-
document.body.style.userSelect = '';
|
|
147
|
-
isResizing.value = false;
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
const {
|
|
151
|
-
width: maximumWidth
|
|
152
|
-
} = useElementBounding(parentContainer);
|
|
153
|
-
watch(() => props.width, newValue => {
|
|
154
|
-
if (newValue !== localWidth.value) {
|
|
155
|
-
localWidth.value = newValue > maximumWidth.value ? maximumWidth.value : newValue < props.minimumWidth ? props.minimumWidth : newValue;
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
watch(() => props.minimumWidth, newMinimum => {
|
|
159
|
-
if (newMinimum > localWidth.value) localWidth.value = newMinimum;
|
|
160
|
-
});
|
|
161
|
-
watch(maximumWidth, newMaximum => {
|
|
162
|
-
if (newMaximum < localWidth.value) localWidth.value = newMaximum;
|
|
163
|
-
});
|
|
164
|
-
watch(localWidth, val => emit('change:width', val));
|
|
165
|
-
return {
|
|
166
|
-
root,
|
|
167
|
-
resizeBar,
|
|
168
|
-
isResizing,
|
|
169
|
-
localWidth,
|
|
170
|
-
sidebarStyle,
|
|
171
|
-
rootStyles,
|
|
172
|
-
resizeStyles,
|
|
173
|
-
mainStyles,
|
|
174
|
-
headerStyles,
|
|
175
|
-
contentStyles,
|
|
176
|
-
footerStyles
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
export { OrSidebarPlacement as O, script as s };
|
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
import { useDraggable, useElementBounding } from '@vueuse/core';
|
|
2
|
-
import _ from 'lodash';
|
|
3
|
-
import { defineComponent, ref, computed, watch } from 'vue-demi';
|
|
4
|
-
import { n as normalizeComponent } from './normalize-component-6e8e3d80.js';
|
|
5
|
-
|
|
6
|
-
var OrSidebarPlacement;
|
|
7
|
-
(function (OrSidebarPlacement) {
|
|
8
|
-
OrSidebarPlacement["left"] = "left";
|
|
9
|
-
OrSidebarPlacement["right"] = "right";
|
|
10
|
-
})(OrSidebarPlacement || (OrSidebarPlacement = {}));
|
|
11
|
-
|
|
12
|
-
const SidebarRoot = [
|
|
13
|
-
// Position
|
|
14
|
-
'relative',
|
|
15
|
-
// Layout
|
|
16
|
-
'flex', 'flex-col', 'shrink-0',
|
|
17
|
-
// Box
|
|
18
|
-
'min-h-0', 'p-0'];
|
|
19
|
-
const SidebarRootSides = {
|
|
20
|
-
[OrSidebarPlacement.left]: [
|
|
21
|
-
// Borders
|
|
22
|
-
'border-r-[1px]', 'border-r-solid', 'border-r-secondary dark:border-r-secondary-dark'],
|
|
23
|
-
[OrSidebarPlacement.right]: [
|
|
24
|
-
// Borders
|
|
25
|
-
'border-l-[1px]', 'border-l-solid', 'border-l-secondary dark:border-l-secondary-dark']
|
|
26
|
-
};
|
|
27
|
-
const SidebarResize = [
|
|
28
|
-
// Position
|
|
29
|
-
'absolute', 'inset-y-none', 'z-[1]',
|
|
30
|
-
// Box
|
|
31
|
-
'w-[12px]', 'h-[100%]',
|
|
32
|
-
// Cursor
|
|
33
|
-
'cursor-ew-resize'];
|
|
34
|
-
const SidebarResizeSides = {
|
|
35
|
-
[OrSidebarPlacement.left]: [
|
|
36
|
-
// Position
|
|
37
|
-
'-right-[1px]',
|
|
38
|
-
// Borders
|
|
39
|
-
'hover:border-r-2', 'hover:border-r-primary hover:dark:border-r-primary-dark',
|
|
40
|
-
// Transition
|
|
41
|
-
'transition-[border-right]'],
|
|
42
|
-
[OrSidebarPlacement.right]: [
|
|
43
|
-
// Position
|
|
44
|
-
'-left-[1px]',
|
|
45
|
-
// Borders
|
|
46
|
-
'hover:border-l-2', 'hover:border-l-primary hover:dark:border-l-primary-dark',
|
|
47
|
-
// Transition
|
|
48
|
-
'transition-[border-left]']
|
|
49
|
-
};
|
|
50
|
-
const SidebarResizingSides = {
|
|
51
|
-
[OrSidebarPlacement.left]: [
|
|
52
|
-
// Borders
|
|
53
|
-
'border-r-2', 'border-r-primary dark:border-r-primary-dark'],
|
|
54
|
-
[OrSidebarPlacement.right]: [
|
|
55
|
-
// Borders
|
|
56
|
-
'border-l-2', 'border-l-primary dark:border-l-primary-dark']
|
|
57
|
-
};
|
|
58
|
-
const SidebarMain = [
|
|
59
|
-
// Layout
|
|
60
|
-
'flex', 'flex-col', 'grow',
|
|
61
|
-
// Box
|
|
62
|
-
'min-h-0'];
|
|
63
|
-
const SidebarHeader = [
|
|
64
|
-
// Sizing
|
|
65
|
-
'p-md'];
|
|
66
|
-
const SidebarContent = [
|
|
67
|
-
// Layout
|
|
68
|
-
'grow', 'overflow-auto',
|
|
69
|
-
// Sizing
|
|
70
|
-
'p-md'];
|
|
71
|
-
const SidebarFooter = [
|
|
72
|
-
// Sizing
|
|
73
|
-
'p-md',
|
|
74
|
-
// Borders
|
|
75
|
-
'border-t-[1px]', 'border-t-solid', 'border-t-secondary dark:border-t-secondary-dark'];
|
|
76
|
-
|
|
77
|
-
var script = defineComponent({
|
|
78
|
-
name: 'OrSidebar',
|
|
79
|
-
props: {
|
|
80
|
-
width: {
|
|
81
|
-
type: Number,
|
|
82
|
-
required: false,
|
|
83
|
-
default: 0,
|
|
84
|
-
validator: value => _.isNumber(value) && value >= 0
|
|
85
|
-
},
|
|
86
|
-
minimumWidth: {
|
|
87
|
-
type: Number,
|
|
88
|
-
required: false,
|
|
89
|
-
default: 350,
|
|
90
|
-
validator: value => _.isNumber(value) && value >= 0
|
|
91
|
-
},
|
|
92
|
-
/**
|
|
93
|
-
* User may put the component on the right or the left side of a container.
|
|
94
|
-
* This property mirrors the resizing behavior (drag direction) and styling (horizontal border) of the sidebar.
|
|
95
|
-
*
|
|
96
|
-
* Note: the property doesn't reposition the component in the parent container.
|
|
97
|
-
* @values left, right
|
|
98
|
-
*/
|
|
99
|
-
side: {
|
|
100
|
-
type: String,
|
|
101
|
-
default: OrSidebarPlacement.right,
|
|
102
|
-
validator: value => _.includes(_.values(OrSidebarPlacement), value)
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
emits: ['change:width'],
|
|
106
|
-
setup(props, {
|
|
107
|
-
emit
|
|
108
|
-
}) {
|
|
109
|
-
// Refs
|
|
110
|
-
const root = ref();
|
|
111
|
-
const resizeBar = ref(null);
|
|
112
|
-
const parentContainer = computed(() => {
|
|
113
|
-
var _a;
|
|
114
|
-
return (_a = root.value) === null || _a === void 0 ? void 0 : _a.parentElement;
|
|
115
|
-
});
|
|
116
|
-
// State
|
|
117
|
-
const startPositionX = ref(0);
|
|
118
|
-
const isResizing = ref(false);
|
|
119
|
-
const localWidth = ref(props.width >= props.minimumWidth ? props.width : props.minimumWidth);
|
|
120
|
-
// Styles
|
|
121
|
-
const sidebarStyle = computed(() => ({
|
|
122
|
-
width: localWidth.value + 'px'
|
|
123
|
-
}));
|
|
124
|
-
const rootStyles = computed(() => ['or-sidebar', ...SidebarRoot, ...SidebarRootSides[props.side]]);
|
|
125
|
-
const resizeStyles = computed(() => [...SidebarResize, ...SidebarResizeSides[props.side], ...(isResizing.value ? SidebarResizingSides[props.side] : [])]);
|
|
126
|
-
const mainStyles = computed(() => [...SidebarMain]);
|
|
127
|
-
const headerStyles = computed(() => [...SidebarHeader]);
|
|
128
|
-
const contentStyles = computed(() => [...SidebarContent]);
|
|
129
|
-
const footerStyles = computed(() => [...SidebarFooter]);
|
|
130
|
-
// Effects
|
|
131
|
-
useDraggable(resizeBar, {
|
|
132
|
-
preventDefault: true,
|
|
133
|
-
onStart: (position, event) => {
|
|
134
|
-
document.body.style.cursor = 'ew-resize';
|
|
135
|
-
document.body.style.userSelect = 'none';
|
|
136
|
-
startPositionX.value = event.x;
|
|
137
|
-
isResizing.value = true;
|
|
138
|
-
},
|
|
139
|
-
onMove: position => {
|
|
140
|
-
const delta = (position.x - startPositionX.value) * (props.side === OrSidebarPlacement.left ? -1 : 1);
|
|
141
|
-
const newWidth = localWidth.value - delta;
|
|
142
|
-
localWidth.value = newWidth > maximumWidth.value ? maximumWidth.value : newWidth < props.minimumWidth ? props.minimumWidth : newWidth;
|
|
143
|
-
startPositionX.value = position.x;
|
|
144
|
-
},
|
|
145
|
-
onEnd: () => {
|
|
146
|
-
document.body.style.cursor = '';
|
|
147
|
-
document.body.style.userSelect = '';
|
|
148
|
-
isResizing.value = false;
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
const {
|
|
152
|
-
width: maximumWidth
|
|
153
|
-
} = useElementBounding(parentContainer);
|
|
154
|
-
watch(() => props.width, newValue => {
|
|
155
|
-
if (newValue !== localWidth.value) {
|
|
156
|
-
localWidth.value = newValue > maximumWidth.value ? maximumWidth.value : newValue < props.minimumWidth ? props.minimumWidth : newValue;
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
watch(() => props.minimumWidth, newMinimum => {
|
|
160
|
-
if (newMinimum > localWidth.value) localWidth.value = newMinimum;
|
|
161
|
-
});
|
|
162
|
-
watch(maximumWidth, newMaximum => {
|
|
163
|
-
if (newMaximum < localWidth.value) localWidth.value = newMaximum;
|
|
164
|
-
});
|
|
165
|
-
watch(localWidth, val => emit('change:width', val));
|
|
166
|
-
return {
|
|
167
|
-
root,
|
|
168
|
-
resizeBar,
|
|
169
|
-
isResizing,
|
|
170
|
-
localWidth,
|
|
171
|
-
sidebarStyle,
|
|
172
|
-
rootStyles,
|
|
173
|
-
resizeStyles,
|
|
174
|
-
mainStyles,
|
|
175
|
-
headerStyles,
|
|
176
|
-
contentStyles,
|
|
177
|
-
footerStyles
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
/* script */
|
|
183
|
-
const __vue_script__ = script;
|
|
184
|
-
|
|
185
|
-
/* template */
|
|
186
|
-
var __vue_render__ = function () {
|
|
187
|
-
var _vm = this;
|
|
188
|
-
var _h = _vm.$createElement;
|
|
189
|
-
var _c = _vm._self._c || _h;
|
|
190
|
-
return _c('aside', {
|
|
191
|
-
ref: "root",
|
|
192
|
-
class: _vm.rootStyles,
|
|
193
|
-
style: _vm.sidebarStyle
|
|
194
|
-
}, [_c('div', {
|
|
195
|
-
ref: "resizeBar",
|
|
196
|
-
class: _vm.resizeStyles
|
|
197
|
-
}), _vm._v(" "), _c('div', {
|
|
198
|
-
class: _vm.mainStyles
|
|
199
|
-
}, [_vm.$slots.header ? _c('div', {
|
|
200
|
-
class: _vm.headerStyles
|
|
201
|
-
}, [_vm._t("header")], 2) : _vm._e(), _vm._v(" "), _c('div', {
|
|
202
|
-
class: _vm.contentStyles
|
|
203
|
-
}, [_vm._t("default")], 2)]), _vm._v(" "), _vm.$slots.footer ? _c('div', {
|
|
204
|
-
class: _vm.footerStyles
|
|
205
|
-
}, [_vm._t("footer")], 2) : _vm._e()]);
|
|
206
|
-
};
|
|
207
|
-
var __vue_staticRenderFns__ = [];
|
|
208
|
-
|
|
209
|
-
/* style */
|
|
210
|
-
const __vue_inject_styles__ = undefined;
|
|
211
|
-
/* scoped */
|
|
212
|
-
const __vue_scope_id__ = undefined;
|
|
213
|
-
/* module identifier */
|
|
214
|
-
const __vue_module_identifier__ = undefined;
|
|
215
|
-
/* functional template */
|
|
216
|
-
const __vue_is_functional_template__ = false;
|
|
217
|
-
/* style inject */
|
|
218
|
-
|
|
219
|
-
/* style inject SSR */
|
|
220
|
-
|
|
221
|
-
/* style inject shadow dom */
|
|
222
|
-
|
|
223
|
-
const __vue_component__ = /*#__PURE__*/normalizeComponent({
|
|
224
|
-
render: __vue_render__,
|
|
225
|
-
staticRenderFns: __vue_staticRenderFns__
|
|
226
|
-
}, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, false, undefined, undefined, undefined);
|
|
227
|
-
|
|
228
|
-
export { OrSidebarPlacement as O, __vue_component__ as _ };
|