@onereach/ui-components 2.72.1-beta.2252.0 → 2.72.1
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-c95ef614.js +230 -0
- package/dist/bundled/v2/components/index.js +1 -1
- package/dist/bundled/v2/components/or-sidebar-v3/OrSidebar.stories3.d.ts +1 -36
- package/dist/bundled/v2/components/or-sidebar-v3/OrSidebar.vue.d.ts +4 -49
- package/dist/bundled/v2/components/or-sidebar-v3/index.js +1 -12
- package/dist/bundled/v2/components/or-sidebar-v3/styles.d.ts +1 -9
- package/dist/bundled/v2/index.js +2 -2
- package/dist/bundled/v3/OrSidebar.vue_vue_type_script_lang-ce0b152c.js +181 -0
- package/dist/bundled/v3/components/index.js +1 -1
- package/dist/bundled/v3/components/or-sidebar-v3/OrSidebar.stories3.d.ts +1 -36
- package/dist/bundled/v3/components/or-sidebar-v3/OrSidebar.vue.d.ts +4 -49
- package/dist/bundled/v3/components/or-sidebar-v3/index.js +1 -14
- package/dist/bundled/v3/components/or-sidebar-v3/styles.d.ts +1 -9
- package/dist/bundled/v3/index.js +9 -25
- package/dist/esm/v2/OrSidebar-fabc7bc9.js +228 -0
- package/dist/esm/v2/components/index.js +1 -1
- package/dist/esm/v2/components/or-sidebar-v3/OrSidebar.stories3.d.ts +1 -36
- package/dist/esm/v2/components/or-sidebar-v3/OrSidebar.vue.d.ts +4 -49
- package/dist/esm/v2/components/or-sidebar-v3/index.js +1 -12
- package/dist/esm/v2/components/or-sidebar-v3/styles.d.ts +1 -9
- package/dist/esm/v2/index.js +1 -1
- package/dist/esm/v3/OrSidebar-a62972f5.js +206 -0
- package/dist/esm/v3/components/index.js +1 -1
- package/dist/esm/v3/components/or-sidebar-v3/OrSidebar.stories3.d.ts +1 -36
- package/dist/esm/v3/components/or-sidebar-v3/OrSidebar.vue.d.ts +4 -49
- package/dist/esm/v3/components/or-sidebar-v3/index.js +1 -11
- package/dist/esm/v3/components/or-sidebar-v3/styles.d.ts +1 -9
- package/dist/esm/v3/index.js +1 -1
- package/package.json +4 -3
- package/src/components/or-sidebar-v3/OrSidebar.docs.mdx +0 -6
- package/src/components/or-sidebar-v3/OrSidebar.stories3.ts +12 -253
- package/src/components/or-sidebar-v3/OrSidebar.vue +23 -130
- package/src/components/or-sidebar-v3/styles.ts +9 -164
- package/dist/bundled/v2/OrSidebar-efd4b98a.js +0 -464
- package/dist/bundled/v2/components/or-sidebar-v3/OrSidebarCollapseButton.stories3.d.ts +0 -12
- package/dist/bundled/v2/components/or-sidebar-v3/OrSidebarCollapseButton.vue.d.ts +0 -53
- package/dist/bundled/v3/OrSidebar.vue_vue_type_script_lang-66f8f0fd.js +0 -356
- package/dist/bundled/v3/components/or-sidebar-v3/OrSidebarCollapseButton.stories3.d.ts +0 -12
- package/dist/bundled/v3/components/or-sidebar-v3/OrSidebarCollapseButton.vue.d.ts +0 -53
- package/dist/esm/v2/OrSidebar-b7202f16.js +0 -461
- package/dist/esm/v2/components/or-sidebar-v3/OrSidebarCollapseButton.stories3.d.ts +0 -12
- package/dist/esm/v2/components/or-sidebar-v3/OrSidebarCollapseButton.vue.d.ts +0 -53
- package/dist/esm/v3/OrSidebar-3567338f.js +0 -396
- package/dist/esm/v3/components/or-sidebar-v3/OrSidebarCollapseButton.stories3.d.ts +0 -12
- package/dist/esm/v3/components/or-sidebar-v3/OrSidebarCollapseButton.vue.d.ts +0 -53
- package/src/components/or-sidebar-v3/OrSidebarCollapseButton.stories3.ts +0 -48
- package/src/components/or-sidebar-v3/OrSidebarCollapseButton.vue +0 -74
|
@@ -3,11 +3,8 @@ import OrSidebarDocs from './OrSidebar.docs.mdx';
|
|
|
3
3
|
import OrSidebar from './OrSidebar.vue';
|
|
4
4
|
import { OrSidebarPlacement } from './props';
|
|
5
5
|
import { action } from '@storybook/addon-actions';
|
|
6
|
-
import { ref } from 'vue-demi';
|
|
7
6
|
import * as Faker from 'faker';
|
|
8
7
|
import { OrButtonV3 as OrButton } from '../or-button-v3';
|
|
9
|
-
import { OrIconButtonV3 as OrIconButton } from '../or-icon-button-v3';
|
|
10
|
-
import { OrTabsV3 as OrTabs, TabsItem } from '../or-tabs-v3';
|
|
11
8
|
|
|
12
9
|
export default {
|
|
13
10
|
title: 'Components/Sidebar',
|
|
@@ -42,15 +39,6 @@ export default {
|
|
|
42
39
|
control: { type: 'text' },
|
|
43
40
|
},
|
|
44
41
|
|
|
45
|
-
toolbar: {
|
|
46
|
-
type: {
|
|
47
|
-
name: 'string',
|
|
48
|
-
required: false,
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
control: { type: 'text' },
|
|
52
|
-
},
|
|
53
|
-
|
|
54
42
|
// Props
|
|
55
43
|
width: {
|
|
56
44
|
control: { type: 'number' },
|
|
@@ -64,17 +52,11 @@ export default {
|
|
|
64
52
|
control: { type: 'select' },
|
|
65
53
|
options: Object.values(OrSidebarPlacement),
|
|
66
54
|
},
|
|
67
|
-
|
|
68
|
-
draggable: {
|
|
69
|
-
control: { type: 'boolean' },
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
collapsible: {
|
|
73
|
-
control: { type: 'boolean' },
|
|
74
|
-
},
|
|
75
55
|
},
|
|
76
56
|
|
|
77
57
|
parameters: {
|
|
58
|
+
layout: 'centered',
|
|
59
|
+
|
|
78
60
|
docs: {
|
|
79
61
|
page: OrSidebarDocs,
|
|
80
62
|
},
|
|
@@ -85,7 +67,6 @@ const DefaultTemplate: StoryFn<typeof OrSidebar> = (args) => ({
|
|
|
85
67
|
components: {
|
|
86
68
|
OrSidebar,
|
|
87
69
|
OrButton,
|
|
88
|
-
OrIconButton,
|
|
89
70
|
},
|
|
90
71
|
|
|
91
72
|
setup() {
|
|
@@ -94,24 +75,14 @@ const DefaultTemplate: StoryFn<typeof OrSidebar> = (args) => ({
|
|
|
94
75
|
|
|
95
76
|
methods: {
|
|
96
77
|
onChangeWidth: action('change:width'),
|
|
97
|
-
onOpen: action('open'),
|
|
98
|
-
onClose: action('close'),
|
|
99
78
|
},
|
|
100
79
|
|
|
101
80
|
template: `
|
|
102
|
-
<div style="display: flex; flex-direction: row; border: 1px solid gray; height:
|
|
103
|
-
<div
|
|
104
|
-
|
|
105
|
-
style="flex-grow: 1; overflow: auto; padding: 16px"
|
|
106
|
-
>
|
|
107
|
-
${Faker.lorem.paragraphs(10)}
|
|
81
|
+
<div style="display: flex; flex-direction: row; border: 1px solid gray; max-height: 500px">
|
|
82
|
+
<div style="flex-grow: 1; overflow: auto">
|
|
83
|
+
${Faker.lorem.paragraphs(3)}
|
|
108
84
|
</div>
|
|
109
|
-
<OrSidebar
|
|
110
|
-
v-bind="args"
|
|
111
|
-
@change:width="onChangeWidth"
|
|
112
|
-
@open="onOpen"
|
|
113
|
-
@close="onClose"
|
|
114
|
-
>
|
|
85
|
+
<OrSidebar v-bind="args" @change:width="onChangeWidth">
|
|
115
86
|
<template v-if="${!!args.header}" v-slot:header>
|
|
116
87
|
${args.header}
|
|
117
88
|
</template>
|
|
@@ -121,9 +92,6 @@ const DefaultTemplate: StoryFn<typeof OrSidebar> = (args) => ({
|
|
|
121
92
|
<template v-if="${!!args.footer}" v-slot:footer>
|
|
122
93
|
${args.footer}
|
|
123
94
|
</template>
|
|
124
|
-
<template v-if="${!!args.toolbar}" v-slot:toolbar>
|
|
125
|
-
${args.toolbar}
|
|
126
|
-
</template>
|
|
127
95
|
</OrSidebar>
|
|
128
96
|
</div>
|
|
129
97
|
`,
|
|
@@ -133,7 +101,6 @@ const LeftTemplate: StoryFn<typeof OrSidebar> = (args) => ({
|
|
|
133
101
|
components: {
|
|
134
102
|
OrSidebar,
|
|
135
103
|
OrButton,
|
|
136
|
-
OrIconButton,
|
|
137
104
|
},
|
|
138
105
|
|
|
139
106
|
setup() {
|
|
@@ -142,18 +109,11 @@ const LeftTemplate: StoryFn<typeof OrSidebar> = (args) => ({
|
|
|
142
109
|
|
|
143
110
|
methods: {
|
|
144
111
|
onChangeWidth: action('change:width'),
|
|
145
|
-
onOpen: action('open'),
|
|
146
|
-
onClose: action('close'),
|
|
147
112
|
},
|
|
148
113
|
|
|
149
114
|
template: `
|
|
150
|
-
<div style="display: flex; flex-direction: row; border: 1px solid gray; height:
|
|
151
|
-
<OrSidebar
|
|
152
|
-
v-bind="args"
|
|
153
|
-
@change:width="onChangeWidth"
|
|
154
|
-
@open="onOpen"
|
|
155
|
-
@close="onClose"
|
|
156
|
-
>
|
|
115
|
+
<div style="display: flex; flex-direction: row; border: 1px solid gray; max-height: 500px">
|
|
116
|
+
<OrSidebar v-bind="args" @change:width="onChangeWidth">
|
|
157
117
|
<template v-if="${!!args.header}" v-slot:header>
|
|
158
118
|
${args.header}
|
|
159
119
|
</template>
|
|
@@ -163,150 +123,14 @@ const LeftTemplate: StoryFn<typeof OrSidebar> = (args) => ({
|
|
|
163
123
|
<template v-if="${!!args.footer}" v-slot:footer>
|
|
164
124
|
${args.footer}
|
|
165
125
|
</template>
|
|
166
|
-
<template v-if="${!!args.toolbar}" v-slot:toolbar>
|
|
167
|
-
${args.toolbar}
|
|
168
|
-
</template>
|
|
169
126
|
</OrSidebar>
|
|
170
|
-
<div
|
|
171
|
-
|
|
172
|
-
style="flex-grow: 1; overflow: auto; padding: 16px"
|
|
173
|
-
>
|
|
174
|
-
${Faker.lorem.paragraphs(10)}
|
|
175
|
-
</div>
|
|
176
|
-
</div>
|
|
177
|
-
`,
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
const TabsTemplate: StoryFn<typeof OrSidebar> = (args) => ({
|
|
181
|
-
components: {
|
|
182
|
-
OrSidebar,
|
|
183
|
-
OrButton,
|
|
184
|
-
OrIconButton,
|
|
185
|
-
OrTabs,
|
|
186
|
-
},
|
|
187
|
-
|
|
188
|
-
setup() {
|
|
189
|
-
// State
|
|
190
|
-
const model = ref<string>();
|
|
191
|
-
|
|
192
|
-
return {
|
|
193
|
-
args,
|
|
194
|
-
model,
|
|
195
|
-
};
|
|
196
|
-
},
|
|
197
|
-
|
|
198
|
-
methods: {
|
|
199
|
-
onChangeWidth: action('change:width'),
|
|
200
|
-
onOpen: action('open'),
|
|
201
|
-
onClose: action('close'),
|
|
202
|
-
},
|
|
203
|
-
|
|
204
|
-
template: `
|
|
205
|
-
<div style="display: flex; flex-direction: row; border: 1px solid gray; height: 650px">
|
|
206
|
-
<div
|
|
207
|
-
class="theme-background-surface-1 dark:theme-background-surface-1-dark text-on-background dark:text-on-background-dark"
|
|
208
|
-
style="flex-grow: 1; overflow: auto; padding: 16px"
|
|
209
|
-
>
|
|
210
|
-
${Faker.lorem.paragraphs(10)}
|
|
127
|
+
<div style="flex-grow: 1; overflow: auto">
|
|
128
|
+
${Faker.lorem.paragraphs(3)}
|
|
211
129
|
</div>
|
|
212
|
-
<OrSidebar
|
|
213
|
-
v-bind="args"
|
|
214
|
-
@change:width="onChangeWidth"
|
|
215
|
-
@open="onOpen"
|
|
216
|
-
@close="onClose"
|
|
217
|
-
>
|
|
218
|
-
<template v-if="${!!args.header}" v-slot:header>
|
|
219
|
-
${args.header}
|
|
220
|
-
</template>
|
|
221
|
-
<template v-if="${!!args.default}" v-slot:default>
|
|
222
|
-
${args.default}
|
|
223
|
-
</template>
|
|
224
|
-
<template v-else v-slot:default>
|
|
225
|
-
<or-tabs
|
|
226
|
-
v-model="model"
|
|
227
|
-
:items="args.items"
|
|
228
|
-
>
|
|
229
|
-
<template v-for="item in args.items" #[item.value]>
|
|
230
|
-
{{ item.label }} Content
|
|
231
|
-
${Faker.lorem.paragraphs(3)}
|
|
232
|
-
</template>
|
|
233
|
-
</or-tabs>
|
|
234
|
-
</template>
|
|
235
|
-
<template v-if="${!!args.footer}" v-slot:footer>
|
|
236
|
-
${args.footer}
|
|
237
|
-
</template>
|
|
238
|
-
<template v-if="${!!args.toolbar}" v-slot:toolbar>
|
|
239
|
-
${args.toolbar}
|
|
240
|
-
</template>
|
|
241
|
-
</OrSidebar>
|
|
242
130
|
</div>
|
|
243
131
|
`,
|
|
244
132
|
});
|
|
245
133
|
|
|
246
|
-
const longToolbar = `
|
|
247
|
-
<or-icon-button
|
|
248
|
-
icon="refresh"
|
|
249
|
-
color="inherit"
|
|
250
|
-
/>
|
|
251
|
-
<hr class="w-full border-outline-variant dark:border-outline-variant-dark" />
|
|
252
|
-
<or-icon-button
|
|
253
|
-
icon="add"
|
|
254
|
-
color="inherit"
|
|
255
|
-
/>
|
|
256
|
-
<or-icon-button
|
|
257
|
-
icon="zoom_out_map"
|
|
258
|
-
color="inherit"
|
|
259
|
-
/>
|
|
260
|
-
<or-icon-button
|
|
261
|
-
icon="remove"
|
|
262
|
-
color="inherit"
|
|
263
|
-
/>
|
|
264
|
-
<hr class="w-full border-outline-variant dark:border-outline-variant-dark" />
|
|
265
|
-
<or-icon-button
|
|
266
|
-
icon="description"
|
|
267
|
-
color="inherit"
|
|
268
|
-
/>
|
|
269
|
-
<or-icon-button
|
|
270
|
-
icon="tab_unselected"
|
|
271
|
-
color="inherit"
|
|
272
|
-
/>
|
|
273
|
-
<hr class="w-full border-outline-variant dark:border-outline-variant-dark" />
|
|
274
|
-
<or-icon-button
|
|
275
|
-
icon="create_new_folder"
|
|
276
|
-
color="inherit"
|
|
277
|
-
/>
|
|
278
|
-
<or-icon-button
|
|
279
|
-
icon="content_paste"
|
|
280
|
-
color="inherit"
|
|
281
|
-
/>
|
|
282
|
-
<or-icon-button
|
|
283
|
-
icon="location_on"
|
|
284
|
-
color="inherit"
|
|
285
|
-
/>
|
|
286
|
-
<or-icon-button
|
|
287
|
-
icon="copy_all"
|
|
288
|
-
color="inherit"
|
|
289
|
-
/>
|
|
290
|
-
<or-icon-button
|
|
291
|
-
icon="call_split"
|
|
292
|
-
color="inherit"
|
|
293
|
-
/>
|
|
294
|
-
<hr class="w-full border-outline-variant dark:border-outline-variant-dark" />
|
|
295
|
-
<or-icon-button
|
|
296
|
-
icon="sell"
|
|
297
|
-
color="inherit"
|
|
298
|
-
/>
|
|
299
|
-
<div class="mt-auto" />
|
|
300
|
-
<or-icon-button
|
|
301
|
-
icon="terminal"
|
|
302
|
-
color="inherit"
|
|
303
|
-
/>
|
|
304
|
-
<or-icon-button
|
|
305
|
-
icon="delete"
|
|
306
|
-
color="inherit"
|
|
307
|
-
/>
|
|
308
|
-
`;
|
|
309
|
-
|
|
310
134
|
export const Default = DefaultTemplate.bind({});
|
|
311
135
|
Default.args = {
|
|
312
136
|
header: 'Header',
|
|
@@ -314,24 +138,11 @@ Default.args = {
|
|
|
314
138
|
footer: 'Footer',
|
|
315
139
|
};
|
|
316
140
|
|
|
317
|
-
export const
|
|
318
|
-
|
|
141
|
+
export const WithMinimumWidth = DefaultTemplate.bind({});
|
|
142
|
+
WithMinimumWidth.args = {
|
|
319
143
|
...Default.args,
|
|
320
144
|
width: 250,
|
|
321
145
|
minimumWidth: 200,
|
|
322
|
-
maximumWidth: 500,
|
|
323
|
-
};
|
|
324
|
-
|
|
325
|
-
export const NotDraggable = DefaultTemplate.bind({});
|
|
326
|
-
NotDraggable.args = {
|
|
327
|
-
...Default.args,
|
|
328
|
-
draggable: false,
|
|
329
|
-
};
|
|
330
|
-
|
|
331
|
-
export const Collapsible = DefaultTemplate.bind({});
|
|
332
|
-
Collapsible.args = {
|
|
333
|
-
...Default.args,
|
|
334
|
-
collapsible: true,
|
|
335
146
|
};
|
|
336
147
|
|
|
337
148
|
export const OnlyContent = DefaultTemplate.bind({});
|
|
@@ -356,60 +167,8 @@ WithFooter.args = {
|
|
|
356
167
|
`,
|
|
357
168
|
};
|
|
358
169
|
|
|
359
|
-
export const WithToolbar = DefaultTemplate.bind({});
|
|
360
|
-
WithToolbar.args = {
|
|
361
|
-
...OnlyContent.args,
|
|
362
|
-
toolbar: longToolbar,
|
|
363
|
-
};
|
|
364
|
-
|
|
365
|
-
export const CollapsibleWithToolbar = DefaultTemplate.bind({});
|
|
366
|
-
CollapsibleWithToolbar.args = {
|
|
367
|
-
...WithToolbar.args,
|
|
368
|
-
collapsible: true,
|
|
369
|
-
};
|
|
370
|
-
|
|
371
|
-
export const WithTabs = TabsTemplate.bind({});
|
|
372
|
-
WithTabs.args = {
|
|
373
|
-
minimumWidth: 352,
|
|
374
|
-
header: 'Headline',
|
|
375
|
-
items: Array.from<string, TabsItem>([
|
|
376
|
-
'Alfa',
|
|
377
|
-
'Bravo',
|
|
378
|
-
'Charlie',
|
|
379
|
-
'Delta',
|
|
380
|
-
'Echo',
|
|
381
|
-
'Foxtrot',
|
|
382
|
-
'Golf',
|
|
383
|
-
'Hotel',
|
|
384
|
-
'India',
|
|
385
|
-
'Juliett',
|
|
386
|
-
], (item) => ({
|
|
387
|
-
value: item.toLowerCase(),
|
|
388
|
-
label: item,
|
|
389
|
-
})),
|
|
390
|
-
footer: `
|
|
391
|
-
<div style="display: flex; flex-direction: row; justify-content: end; gap: 16px">
|
|
392
|
-
<or-button color="danger" variant="outlined">Delete</or-button>
|
|
393
|
-
<or-button variant="outlined" class="ml-auto">Cancel</or-button>
|
|
394
|
-
<or-button>Save</or-button>
|
|
395
|
-
</div>
|
|
396
|
-
`,
|
|
397
|
-
};
|
|
398
|
-
|
|
399
170
|
export const LeftSidebar = LeftTemplate.bind({});
|
|
400
171
|
LeftSidebar.args = {
|
|
401
172
|
...Default.args,
|
|
402
173
|
side: 'left',
|
|
403
174
|
};
|
|
404
|
-
|
|
405
|
-
export const WithLeftToolbar = LeftTemplate.bind({});
|
|
406
|
-
WithLeftToolbar.args = {
|
|
407
|
-
...LeftSidebar.args,
|
|
408
|
-
toolbar: longToolbar,
|
|
409
|
-
};
|
|
410
|
-
|
|
411
|
-
export const CollapsibleWithWithLeftToolbar = LeftTemplate.bind({});
|
|
412
|
-
CollapsibleWithWithLeftToolbar.args = {
|
|
413
|
-
...WithLeftToolbar.args,
|
|
414
|
-
collapsible: true,
|
|
415
|
-
};
|
|
@@ -2,55 +2,28 @@
|
|
|
2
2
|
<aside
|
|
3
3
|
ref="root"
|
|
4
4
|
:class="rootStyles"
|
|
5
|
+
:style="sidebarStyle"
|
|
5
6
|
>
|
|
6
7
|
<div
|
|
7
|
-
|
|
8
|
-
:class="
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
</div>
|
|
12
|
-
<div
|
|
13
|
-
:class="sidebarStyles"
|
|
14
|
-
:style="sidebarStyle"
|
|
15
|
-
>
|
|
8
|
+
ref="resizeBar"
|
|
9
|
+
:class="resizeStyles"
|
|
10
|
+
/>
|
|
11
|
+
<div :class="mainStyles">
|
|
16
12
|
<div
|
|
17
|
-
v-if="
|
|
18
|
-
|
|
19
|
-
:class="resizeStyles"
|
|
20
|
-
/>
|
|
21
|
-
<or-sidebar-collapse-button
|
|
22
|
-
v-if="collapsible"
|
|
23
|
-
v-model="isCollapsed"
|
|
24
|
-
:class="collapsibleButtonStyles"
|
|
25
|
-
:side="side"
|
|
26
|
-
/>
|
|
27
|
-
<div
|
|
28
|
-
v-show="!isCollapsed"
|
|
29
|
-
:class="mainStyles"
|
|
13
|
+
v-if="$slots.header"
|
|
14
|
+
:class="headerStyles"
|
|
30
15
|
>
|
|
31
|
-
<
|
|
32
|
-
v-if="$slots.header"
|
|
33
|
-
:class="headerStyles"
|
|
34
|
-
>
|
|
35
|
-
<slot name="header" />
|
|
36
|
-
</div>
|
|
37
|
-
<div :class="contentStyles">
|
|
38
|
-
<slot />
|
|
39
|
-
</div>
|
|
16
|
+
<slot name="header" />
|
|
40
17
|
</div>
|
|
41
|
-
<div
|
|
42
|
-
|
|
43
|
-
v-show="!isCollapsed"
|
|
44
|
-
:class="footerStyles"
|
|
45
|
-
>
|
|
46
|
-
<slot name="footer" />
|
|
18
|
+
<div :class="contentStyles">
|
|
19
|
+
<slot />
|
|
47
20
|
</div>
|
|
48
21
|
</div>
|
|
49
22
|
<div
|
|
50
|
-
v-if="
|
|
51
|
-
:class="
|
|
23
|
+
v-if="$slots.footer"
|
|
24
|
+
:class="footerStyles"
|
|
52
25
|
>
|
|
53
|
-
<slot name="
|
|
26
|
+
<slot name="footer" />
|
|
54
27
|
</div>
|
|
55
28
|
</aside>
|
|
56
29
|
</template>
|
|
@@ -58,48 +31,34 @@
|
|
|
58
31
|
<script lang="ts">
|
|
59
32
|
import { useDraggable, useElementBounding } from '@vueuse/core';
|
|
60
33
|
import _ from 'lodash';
|
|
61
|
-
import { computed, defineComponent, PropType, ref, watch
|
|
34
|
+
import { computed, defineComponent, PropType, ref, watch } from 'vue-demi';
|
|
62
35
|
import { OrSidebarPlacement } from './props';
|
|
63
36
|
import {
|
|
64
37
|
SidebarRoot,
|
|
65
|
-
|
|
66
|
-
SidebarToolbar,
|
|
67
|
-
CollapsibleSidebarToolbar,
|
|
68
|
-
SidebarSides,
|
|
69
|
-
SidebarToolbarSides,
|
|
38
|
+
SidebarRootSides,
|
|
70
39
|
SidebarResize,
|
|
71
40
|
SidebarResizeSides,
|
|
72
|
-
SidebarCollapseButton,
|
|
73
|
-
SidebarCollapseButtonSides,
|
|
74
41
|
SidebarResizingSides,
|
|
75
42
|
SidebarMain,
|
|
76
43
|
SidebarHeader,
|
|
77
44
|
SidebarContent,
|
|
78
45
|
SidebarFooter,
|
|
79
46
|
} from './styles';
|
|
80
|
-
import OrSidebarCollapseButton from './OrSidebarCollapseButton.vue';
|
|
81
47
|
|
|
82
48
|
export default defineComponent({
|
|
83
49
|
name: 'OrSidebar',
|
|
84
50
|
|
|
85
|
-
components: {
|
|
86
|
-
OrSidebarCollapseButton,
|
|
87
|
-
},
|
|
88
|
-
|
|
89
51
|
props: {
|
|
90
52
|
width: {
|
|
91
53
|
type: Number,
|
|
92
|
-
|
|
54
|
+
required: false,
|
|
55
|
+
default: 0,
|
|
93
56
|
validator: (value?: any) => _.isNumber(value) && value >= 0,
|
|
94
57
|
},
|
|
95
58
|
minimumWidth: {
|
|
96
59
|
type: Number,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
},
|
|
100
|
-
maximumWidth: {
|
|
101
|
-
type: Number,
|
|
102
|
-
default: 384,
|
|
60
|
+
required: false,
|
|
61
|
+
default: 350,
|
|
103
62
|
validator: (value?: any) => _.isNumber(value) && value >= 0,
|
|
104
63
|
},
|
|
105
64
|
/**
|
|
@@ -114,27 +73,9 @@ export default defineComponent({
|
|
|
114
73
|
default: OrSidebarPlacement.right,
|
|
115
74
|
validator: (value?: any) => _.includes(_.values(OrSidebarPlacement), value),
|
|
116
75
|
},
|
|
117
|
-
draggable: {
|
|
118
|
-
type: Boolean,
|
|
119
|
-
default: true,
|
|
120
|
-
},
|
|
121
|
-
collapsible: {
|
|
122
|
-
type: Boolean,
|
|
123
|
-
default: false,
|
|
124
|
-
},
|
|
125
76
|
},
|
|
126
77
|
|
|
127
|
-
emits: [
|
|
128
|
-
'change:width',
|
|
129
|
-
'open',
|
|
130
|
-
'close',
|
|
131
|
-
],
|
|
132
|
-
|
|
133
|
-
expose: [
|
|
134
|
-
'root',
|
|
135
|
-
'open',
|
|
136
|
-
'close',
|
|
137
|
-
],
|
|
78
|
+
emits: ['change:width'],
|
|
138
79
|
|
|
139
80
|
setup(props, { emit }) {
|
|
140
81
|
// Refs
|
|
@@ -143,37 +84,20 @@ export default defineComponent({
|
|
|
143
84
|
|
|
144
85
|
const parentContainer = computed(() => root.value?.parentElement);
|
|
145
86
|
|
|
146
|
-
// Slots
|
|
147
|
-
const { toolbar: toolbarSlot } = useSlots();
|
|
148
|
-
|
|
149
87
|
// State
|
|
150
88
|
const startPositionX = ref(0);
|
|
151
89
|
const isResizing = ref(false);
|
|
152
|
-
const isCollapsed = ref(false);
|
|
153
|
-
const maximumWidth = ref(props.maximumWidth || 384);
|
|
154
90
|
const localWidth = ref(props.width >= props.minimumWidth ? props.width : props.minimumWidth);
|
|
155
91
|
|
|
156
|
-
const isShowingToolbar = computed(() => !!toolbarSlot);
|
|
157
|
-
|
|
158
92
|
// Styles
|
|
159
93
|
const sidebarStyle = computed(() => ({
|
|
160
|
-
width:
|
|
94
|
+
width: localWidth.value + 'px',
|
|
161
95
|
}));
|
|
162
96
|
|
|
163
97
|
const rootStyles = computed(() => [
|
|
164
98
|
'or-sidebar',
|
|
165
99
|
...SidebarRoot,
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
const sidebarStyles = computed(() => [
|
|
169
|
-
...SidebarBar,
|
|
170
|
-
...SidebarSides[props.side],
|
|
171
|
-
]);
|
|
172
|
-
|
|
173
|
-
const toolbarStyles = computed(() => [
|
|
174
|
-
...SidebarToolbar,
|
|
175
|
-
...(props.collapsible ? CollapsibleSidebarToolbar : []),
|
|
176
|
-
...SidebarToolbarSides[props.side],
|
|
100
|
+
...SidebarRootSides[props.side],
|
|
177
101
|
]);
|
|
178
102
|
|
|
179
103
|
const resizeStyles = computed(() => [
|
|
@@ -182,11 +106,6 @@ export default defineComponent({
|
|
|
182
106
|
...(isResizing.value ? SidebarResizingSides[props.side] : []),
|
|
183
107
|
]);
|
|
184
108
|
|
|
185
|
-
const collapsibleButtonStyles = computed(() => [
|
|
186
|
-
...SidebarCollapseButton,
|
|
187
|
-
...SidebarCollapseButtonSides[props.side],
|
|
188
|
-
]);
|
|
189
|
-
|
|
190
109
|
const mainStyles = computed(() => [...SidebarMain]);
|
|
191
110
|
|
|
192
111
|
const headerStyles = computed(() => [...SidebarHeader]);
|
|
@@ -218,16 +137,7 @@ export default defineComponent({
|
|
|
218
137
|
},
|
|
219
138
|
});
|
|
220
139
|
|
|
221
|
-
|
|
222
|
-
function open(): void {
|
|
223
|
-
isCollapsed.value = false;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
function close(): void {
|
|
227
|
-
isCollapsed.value = true;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
const { width: containerWidth } = useElementBounding(parentContainer);
|
|
140
|
+
const { width: maximumWidth } = useElementBounding(parentContainer);
|
|
231
141
|
|
|
232
142
|
watch(() => props.width, (newValue: number) => {
|
|
233
143
|
if (newValue !== localWidth.value) {
|
|
@@ -240,41 +150,24 @@ export default defineComponent({
|
|
|
240
150
|
if (newMinimum > localWidth.value) localWidth.value = newMinimum;
|
|
241
151
|
});
|
|
242
152
|
|
|
243
|
-
watch(() => props.maximumWidth, (newMaximum: number) => {
|
|
244
|
-
if (newMaximum < maximumWidth.value) maximumWidth.value = newMaximum;
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
watch(containerWidth, (newMaximum: number) => {
|
|
248
|
-
if (newMaximum < maximumWidth.value) maximumWidth.value = newMaximum;
|
|
249
|
-
});
|
|
250
|
-
|
|
251
153
|
watch(maximumWidth, (newMaximum: number) => {
|
|
252
154
|
if (newMaximum < localWidth.value) localWidth.value = newMaximum;
|
|
253
155
|
});
|
|
254
156
|
|
|
255
157
|
watch(localWidth, (val: number) => emit('change:width', val));
|
|
256
158
|
|
|
257
|
-
watch(isCollapsed, (val: boolean) => emit(val ? 'close' : 'open'));
|
|
258
|
-
|
|
259
159
|
return {
|
|
260
160
|
root,
|
|
261
161
|
resizeBar,
|
|
262
162
|
isResizing,
|
|
263
|
-
isCollapsed,
|
|
264
163
|
localWidth,
|
|
265
|
-
isShowingToolbar,
|
|
266
164
|
sidebarStyle,
|
|
267
165
|
rootStyles,
|
|
268
|
-
sidebarStyles,
|
|
269
|
-
toolbarStyles,
|
|
270
166
|
resizeStyles,
|
|
271
|
-
collapsibleButtonStyles,
|
|
272
167
|
mainStyles,
|
|
273
168
|
headerStyles,
|
|
274
169
|
contentStyles,
|
|
275
170
|
footerStyles,
|
|
276
|
-
open,
|
|
277
|
-
close,
|
|
278
171
|
};
|
|
279
172
|
},
|
|
280
173
|
});
|