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