@onereach/ui-components 2.70.1-beta.2196.0 → 2.70.2-beta.2198.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/{OrExpansionPanel-995caa85.js → OrExpansionPanel-d9a260e2.js} +32 -5
- package/dist/bundled/v2/{OrSelect-67dc7976.js → OrSelect-c49e1bcf.js} +2 -2
- package/dist/bundled/v2/OrSidebar-2a7d62a8.js +455 -0
- package/dist/bundled/v2/{OrTag-30fecee5.js → OrTag-e3e6fdd6.js} +1 -1
- package/dist/bundled/v2/components/index.js +4 -4
- package/dist/bundled/v2/components/or-expansion-panel-v3/OrExpansionPanel.vue.d.ts +22 -3
- package/dist/bundled/v2/components/or-expansion-panel-v3/index.js +1 -1
- package/dist/bundled/v2/components/or-select-v3/index.js +3 -3
- 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 +59 -0
- package/dist/bundled/v2/components/or-sidebar-v3/index.js +13 -1
- package/dist/bundled/v2/components/or-sidebar-v3/styles.d.ts +7 -1
- package/dist/bundled/v2/components/or-tag-v3/index.js +1 -1
- package/dist/bundled/v2/index.js +5 -5
- package/dist/bundled/v3/{OrExpansionPanel.vue_vue_type_script_lang-7f9c6721.js → OrExpansionPanel.vue_vue_type_script_lang-5360f580.js} +31 -4
- package/dist/bundled/v3/{OrSelect.vue_vue_type_script_lang-29aed61b.js → OrSelect.vue_vue_type_script_lang-58e5a52b.js} +3 -3
- package/dist/bundled/v3/OrSidebar.vue_vue_type_script_lang-b4fa1550.js +347 -0
- package/dist/bundled/v3/{OrTag.vue_vue_type_script_lang-3e30f662.js → OrTag.vue_vue_type_script_lang-e45c345b.js} +1 -1
- package/dist/bundled/v3/components/index.js +4 -4
- package/dist/bundled/v3/components/or-expansion-panel-v3/OrExpansionPanel.vue.d.ts +22 -3
- package/dist/bundled/v3/components/or-expansion-panel-v3/index.js +1 -1
- package/dist/bundled/v3/components/or-select-v3/index.js +3 -3
- 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 +59 -0
- package/dist/bundled/v3/components/or-sidebar-v3/index.js +15 -1
- package/dist/bundled/v3/components/or-sidebar-v3/styles.d.ts +7 -1
- package/dist/bundled/v3/components/or-tag-v3/index.js +1 -1
- package/dist/bundled/v3/index.js +29 -13
- package/dist/esm/v2/{OrExpansionPanel-968ddc61.js → OrExpansionPanel-a123024e.js} +32 -5
- package/dist/esm/v2/{OrSelect-ae7a13a5.js → OrSelect-1d705445.js} +2 -2
- package/dist/esm/v2/OrSidebar-1e02702f.js +452 -0
- package/dist/esm/v2/{OrTag-5c404031.js → OrTag-52e4cc94.js} +1 -1
- package/dist/esm/v2/components/index.js +4 -4
- package/dist/esm/v2/components/or-expansion-panel-v3/OrExpansionPanel.vue.d.ts +22 -3
- package/dist/esm/v2/components/or-expansion-panel-v3/index.js +1 -1
- package/dist/esm/v2/components/or-select-v3/index.js +3 -3
- 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 +59 -0
- package/dist/esm/v2/components/or-sidebar-v3/index.js +13 -1
- package/dist/esm/v2/components/or-sidebar-v3/styles.d.ts +7 -1
- package/dist/esm/v2/components/or-tag-v3/index.js +1 -1
- package/dist/esm/v2/index.js +4 -4
- package/dist/esm/v3/{OrExpansionPanel-311e64cf.js → OrExpansionPanel-f8d7ff8d.js} +32 -5
- package/dist/esm/v3/{OrSelect-7ef568f4.js → OrSelect-dfa4885f.js} +2 -2
- package/dist/esm/v3/OrSidebar-749bbcba.js +387 -0
- package/dist/esm/v3/{OrTag-5d54f37d.js → OrTag-efa7578f.js} +1 -1
- package/dist/esm/v3/components/index.js +4 -4
- package/dist/esm/v3/components/or-expansion-panel-v3/OrExpansionPanel.vue.d.ts +22 -3
- package/dist/esm/v3/components/or-expansion-panel-v3/index.js +1 -1
- package/dist/esm/v3/components/or-select-v3/index.js +3 -3
- 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 +59 -0
- package/dist/esm/v3/components/or-sidebar-v3/index.js +12 -1
- package/dist/esm/v3/components/or-sidebar-v3/styles.d.ts +7 -1
- package/dist/esm/v3/components/or-tag-v3/index.js +1 -1
- package/dist/esm/v3/index.js +4 -4
- package/package.json +1 -1
- package/src/components/or-expansion-panel-v3/OrExpansionPanel.stories3.ts +12 -2
- package/src/components/or-expansion-panel-v3/OrExpansionPanel.vue +39 -3
- package/src/components/or-sidebar-v3/OrSidebar.docs.mdx +6 -0
- package/src/components/or-sidebar-v3/OrSidebar.stories3.ts +219 -6
- package/src/components/or-sidebar-v3/OrSidebar.vue +121 -22
- package/src/components/or-sidebar-v3/OrSidebarCollapseButton.stories3.ts +48 -0
- package/src/components/or-sidebar-v3/OrSidebarCollapseButton.vue +64 -0
- package/src/components/or-sidebar-v3/styles.ts +153 -9
- package/src/components/or-tag-v3/styles.ts +0 -3
- 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
|
@@ -3,8 +3,11 @@ 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';
|
|
6
7
|
import * as Faker from 'faker';
|
|
7
8
|
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';
|
|
8
11
|
|
|
9
12
|
export default {
|
|
10
13
|
title: 'Components/Sidebar',
|
|
@@ -39,6 +42,15 @@ export default {
|
|
|
39
42
|
control: { type: 'text' },
|
|
40
43
|
},
|
|
41
44
|
|
|
45
|
+
toolbar: {
|
|
46
|
+
type: {
|
|
47
|
+
name: 'string',
|
|
48
|
+
required: false,
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
control: { type: 'text' },
|
|
52
|
+
},
|
|
53
|
+
|
|
42
54
|
// Props
|
|
43
55
|
width: {
|
|
44
56
|
control: { type: 'number' },
|
|
@@ -52,6 +64,14 @@ export default {
|
|
|
52
64
|
control: { type: 'select' },
|
|
53
65
|
options: Object.values(OrSidebarPlacement),
|
|
54
66
|
},
|
|
67
|
+
|
|
68
|
+
draggable: {
|
|
69
|
+
control: { type: 'boolean' },
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
collapsible: {
|
|
73
|
+
control: { type: 'boolean' },
|
|
74
|
+
},
|
|
55
75
|
},
|
|
56
76
|
|
|
57
77
|
parameters: {
|
|
@@ -67,6 +87,7 @@ const DefaultTemplate: StoryFn<typeof OrSidebar> = (args) => ({
|
|
|
67
87
|
components: {
|
|
68
88
|
OrSidebar,
|
|
69
89
|
OrButton,
|
|
90
|
+
OrIconButton,
|
|
70
91
|
},
|
|
71
92
|
|
|
72
93
|
setup() {
|
|
@@ -78,9 +99,9 @@ const DefaultTemplate: StoryFn<typeof OrSidebar> = (args) => ({
|
|
|
78
99
|
},
|
|
79
100
|
|
|
80
101
|
template: `
|
|
81
|
-
<div style="display: flex; flex-direction: row; border: 1px solid gray; max-height:
|
|
102
|
+
<div style="display: flex; flex-direction: row; border: 1px solid gray; max-height: 750px">
|
|
82
103
|
<div style="flex-grow: 1; overflow: auto">
|
|
83
|
-
${Faker.lorem.paragraphs(
|
|
104
|
+
${Faker.lorem.paragraphs(10)}
|
|
84
105
|
</div>
|
|
85
106
|
<OrSidebar v-bind="args" @change:width="onChangeWidth">
|
|
86
107
|
<template v-if="${!!args.header}" v-slot:header>
|
|
@@ -92,6 +113,9 @@ const DefaultTemplate: StoryFn<typeof OrSidebar> = (args) => ({
|
|
|
92
113
|
<template v-if="${!!args.footer}" v-slot:footer>
|
|
93
114
|
${args.footer}
|
|
94
115
|
</template>
|
|
116
|
+
<template v-if="${!!args.toolbar}" v-slot:toolbar>
|
|
117
|
+
${args.toolbar}
|
|
118
|
+
</template>
|
|
95
119
|
</OrSidebar>
|
|
96
120
|
</div>
|
|
97
121
|
`,
|
|
@@ -101,6 +125,7 @@ const LeftTemplate: StoryFn<typeof OrSidebar> = (args) => ({
|
|
|
101
125
|
components: {
|
|
102
126
|
OrSidebar,
|
|
103
127
|
OrButton,
|
|
128
|
+
OrIconButton,
|
|
104
129
|
},
|
|
105
130
|
|
|
106
131
|
setup() {
|
|
@@ -112,7 +137,7 @@ const LeftTemplate: StoryFn<typeof OrSidebar> = (args) => ({
|
|
|
112
137
|
},
|
|
113
138
|
|
|
114
139
|
template: `
|
|
115
|
-
<div style="display: flex; flex-direction: row; border: 1px solid gray; max-height:
|
|
140
|
+
<div style="display: flex; flex-direction: row; border: 1px solid gray; max-height: 750px">
|
|
116
141
|
<OrSidebar v-bind="args" @change:width="onChangeWidth">
|
|
117
142
|
<template v-if="${!!args.header}" v-slot:header>
|
|
118
143
|
${args.header}
|
|
@@ -123,14 +148,137 @@ const LeftTemplate: StoryFn<typeof OrSidebar> = (args) => ({
|
|
|
123
148
|
<template v-if="${!!args.footer}" v-slot:footer>
|
|
124
149
|
${args.footer}
|
|
125
150
|
</template>
|
|
151
|
+
<template v-if="${!!args.toolbar}" v-slot:toolbar>
|
|
152
|
+
${args.toolbar}
|
|
153
|
+
</template>
|
|
126
154
|
</OrSidebar>
|
|
127
155
|
<div style="flex-grow: 1; overflow: auto">
|
|
128
|
-
${Faker.lorem.paragraphs(
|
|
156
|
+
${Faker.lorem.paragraphs(10)}
|
|
129
157
|
</div>
|
|
130
158
|
</div>
|
|
131
159
|
`,
|
|
132
160
|
});
|
|
133
161
|
|
|
162
|
+
const TabsTemplate: StoryFn<typeof OrSidebar> = (args) => ({
|
|
163
|
+
components: {
|
|
164
|
+
OrSidebar,
|
|
165
|
+
OrButton,
|
|
166
|
+
OrIconButton,
|
|
167
|
+
OrTabs,
|
|
168
|
+
},
|
|
169
|
+
|
|
170
|
+
setup() {
|
|
171
|
+
// State
|
|
172
|
+
const model = ref<string>();
|
|
173
|
+
|
|
174
|
+
return {
|
|
175
|
+
args,
|
|
176
|
+
model,
|
|
177
|
+
};
|
|
178
|
+
},
|
|
179
|
+
|
|
180
|
+
methods: {
|
|
181
|
+
onChangeWidth: action('change:width'),
|
|
182
|
+
},
|
|
183
|
+
|
|
184
|
+
template: `
|
|
185
|
+
<div style="display: flex; flex-direction: row; border: 1px solid gray; max-height: 750px">
|
|
186
|
+
<div style="flex-grow: 1; overflow: auto">
|
|
187
|
+
${Faker.lorem.paragraphs(10)}
|
|
188
|
+
</div>
|
|
189
|
+
<OrSidebar v-bind="args" @change:width="onChangeWidth">
|
|
190
|
+
<template v-if="${!!args.header}" v-slot:header>
|
|
191
|
+
${args.header}
|
|
192
|
+
</template>
|
|
193
|
+
<template v-if="${!!args.default}" v-slot:default>
|
|
194
|
+
${args.default}
|
|
195
|
+
</template>
|
|
196
|
+
<template v-else v-slot:default>
|
|
197
|
+
<or-tabs
|
|
198
|
+
v-model="model"
|
|
199
|
+
:items="args.items"
|
|
200
|
+
>
|
|
201
|
+
<template v-for="item in args.items" #[item.value]>
|
|
202
|
+
{{ item.label }} Content
|
|
203
|
+
${Faker.lorem.paragraphs(3)}
|
|
204
|
+
</template>
|
|
205
|
+
</or-tabs>
|
|
206
|
+
</template>
|
|
207
|
+
<template v-if="${!!args.footer}" v-slot:footer>
|
|
208
|
+
${args.footer}
|
|
209
|
+
</template>
|
|
210
|
+
<template v-if="${!!args.toolbar}" v-slot:toolbar>
|
|
211
|
+
${args.toolbar}
|
|
212
|
+
</template>
|
|
213
|
+
</OrSidebar>
|
|
214
|
+
</div>
|
|
215
|
+
`,
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
const longToolbar = `
|
|
219
|
+
<or-icon-button
|
|
220
|
+
icon="refresh"
|
|
221
|
+
color="inherit"
|
|
222
|
+
/>
|
|
223
|
+
<hr class="w-full border-outline-variant dark:border-outline-variant-dark" />
|
|
224
|
+
<or-icon-button
|
|
225
|
+
icon="add"
|
|
226
|
+
color="inherit"
|
|
227
|
+
/>
|
|
228
|
+
<or-icon-button
|
|
229
|
+
icon="zoom_out_map"
|
|
230
|
+
color="inherit"
|
|
231
|
+
/>
|
|
232
|
+
<or-icon-button
|
|
233
|
+
icon="remove"
|
|
234
|
+
color="inherit"
|
|
235
|
+
/>
|
|
236
|
+
<hr class="w-full border-outline-variant dark:border-outline-variant-dark" />
|
|
237
|
+
<or-icon-button
|
|
238
|
+
icon="description"
|
|
239
|
+
color="inherit"
|
|
240
|
+
/>
|
|
241
|
+
<or-icon-button
|
|
242
|
+
icon="tab_unselected"
|
|
243
|
+
color="inherit"
|
|
244
|
+
/>
|
|
245
|
+
<hr class="w-full border-outline-variant dark:border-outline-variant-dark" />
|
|
246
|
+
<or-icon-button
|
|
247
|
+
icon="create_new_folder"
|
|
248
|
+
color="inherit"
|
|
249
|
+
/>
|
|
250
|
+
<or-icon-button
|
|
251
|
+
icon="content_paste"
|
|
252
|
+
color="inherit"
|
|
253
|
+
/>
|
|
254
|
+
<or-icon-button
|
|
255
|
+
icon="location_on"
|
|
256
|
+
color="inherit"
|
|
257
|
+
/>
|
|
258
|
+
<or-icon-button
|
|
259
|
+
icon="copy_all"
|
|
260
|
+
color="inherit"
|
|
261
|
+
/>
|
|
262
|
+
<or-icon-button
|
|
263
|
+
icon="call_split"
|
|
264
|
+
color="inherit"
|
|
265
|
+
/>
|
|
266
|
+
<hr class="w-full border-outline-variant dark:border-outline-variant-dark" />
|
|
267
|
+
<or-icon-button
|
|
268
|
+
icon="sell"
|
|
269
|
+
color="inherit"
|
|
270
|
+
/>
|
|
271
|
+
<div class="mt-auto" />
|
|
272
|
+
<or-icon-button
|
|
273
|
+
icon="terminal"
|
|
274
|
+
color="inherit"
|
|
275
|
+
/>
|
|
276
|
+
<or-icon-button
|
|
277
|
+
icon="delete"
|
|
278
|
+
color="inherit"
|
|
279
|
+
/>
|
|
280
|
+
`;
|
|
281
|
+
|
|
134
282
|
export const Default = DefaultTemplate.bind({});
|
|
135
283
|
Default.args = {
|
|
136
284
|
header: 'Header',
|
|
@@ -138,11 +286,24 @@ Default.args = {
|
|
|
138
286
|
footer: 'Footer',
|
|
139
287
|
};
|
|
140
288
|
|
|
141
|
-
export const
|
|
142
|
-
|
|
289
|
+
export const WithCustomWidthConstraints = DefaultTemplate.bind({});
|
|
290
|
+
WithCustomWidthConstraints.args = {
|
|
143
291
|
...Default.args,
|
|
144
292
|
width: 250,
|
|
145
293
|
minimumWidth: 200,
|
|
294
|
+
maximumWidth: 500,
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
export const NotDraggable = DefaultTemplate.bind({});
|
|
298
|
+
NotDraggable.args = {
|
|
299
|
+
...Default.args,
|
|
300
|
+
draggable: false,
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
export const Collapsible = DefaultTemplate.bind({});
|
|
304
|
+
Collapsible.args = {
|
|
305
|
+
...Default.args,
|
|
306
|
+
collapsible: true,
|
|
146
307
|
};
|
|
147
308
|
|
|
148
309
|
export const OnlyContent = DefaultTemplate.bind({});
|
|
@@ -167,8 +328,60 @@ WithFooter.args = {
|
|
|
167
328
|
`,
|
|
168
329
|
};
|
|
169
330
|
|
|
331
|
+
export const WithToolbar = DefaultTemplate.bind({});
|
|
332
|
+
WithToolbar.args = {
|
|
333
|
+
...OnlyContent.args,
|
|
334
|
+
toolbar: longToolbar,
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
export const CollapsibleWithToolbar = DefaultTemplate.bind({});
|
|
338
|
+
CollapsibleWithToolbar.args = {
|
|
339
|
+
...WithToolbar.args,
|
|
340
|
+
collapsible: true,
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
export const WithTabs = TabsTemplate.bind({});
|
|
344
|
+
WithTabs.args = {
|
|
345
|
+
minimumWidth: 352,
|
|
346
|
+
header: 'Headline',
|
|
347
|
+
items: Array.from<string, TabsItem>([
|
|
348
|
+
'Alfa',
|
|
349
|
+
'Bravo',
|
|
350
|
+
'Charlie',
|
|
351
|
+
'Delta',
|
|
352
|
+
'Echo',
|
|
353
|
+
'Foxtrot',
|
|
354
|
+
'Golf',
|
|
355
|
+
'Hotel',
|
|
356
|
+
'India',
|
|
357
|
+
'Juliett',
|
|
358
|
+
], (item) => ({
|
|
359
|
+
value: item.toLowerCase(),
|
|
360
|
+
label: item,
|
|
361
|
+
})),
|
|
362
|
+
footer: `
|
|
363
|
+
<div style="display: flex; flex-direction: row; justify-content: end; gap: 16px">
|
|
364
|
+
<or-button color="danger" variant="outlined">Delete</or-button>
|
|
365
|
+
<or-button variant="outlined" class="ml-auto">Cancel</or-button>
|
|
366
|
+
<or-button>Save</or-button>
|
|
367
|
+
</div>
|
|
368
|
+
`,
|
|
369
|
+
};
|
|
370
|
+
|
|
170
371
|
export const LeftSidebar = LeftTemplate.bind({});
|
|
171
372
|
LeftSidebar.args = {
|
|
172
373
|
...Default.args,
|
|
173
374
|
side: 'left',
|
|
174
375
|
};
|
|
376
|
+
|
|
377
|
+
export const WithLeftToolbar = LeftTemplate.bind({});
|
|
378
|
+
WithLeftToolbar.args = {
|
|
379
|
+
...LeftSidebar.args,
|
|
380
|
+
toolbar: longToolbar,
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
export const CollapsibleWithWithLeftToolbar = LeftTemplate.bind({});
|
|
384
|
+
CollapsibleWithWithLeftToolbar.args = {
|
|
385
|
+
...WithLeftToolbar.args,
|
|
386
|
+
collapsible: true,
|
|
387
|
+
};
|
|
@@ -2,28 +2,55 @@
|
|
|
2
2
|
<aside
|
|
3
3
|
ref="root"
|
|
4
4
|
:class="rootStyles"
|
|
5
|
-
:style="sidebarStyle"
|
|
6
5
|
>
|
|
7
6
|
<div
|
|
8
|
-
|
|
9
|
-
:class="
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
v-if="side === 'right' && isShowingToolbar"
|
|
8
|
+
:class="toolbarStyles"
|
|
9
|
+
>
|
|
10
|
+
<slot name="toolbar" />
|
|
11
|
+
</div>
|
|
12
|
+
<div
|
|
13
|
+
:class="sidebarStyles"
|
|
14
|
+
:style="sidebarStyle"
|
|
15
|
+
>
|
|
12
16
|
<div
|
|
13
|
-
v-if="
|
|
14
|
-
|
|
17
|
+
v-if="draggable && !isCollapsed"
|
|
18
|
+
ref="resizeBar"
|
|
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"
|
|
15
30
|
>
|
|
16
|
-
<
|
|
31
|
+
<div
|
|
32
|
+
v-if="$slots.header"
|
|
33
|
+
:class="headerStyles"
|
|
34
|
+
>
|
|
35
|
+
<slot name="header" />
|
|
36
|
+
</div>
|
|
37
|
+
<div :class="contentStyles">
|
|
38
|
+
<slot />
|
|
39
|
+
</div>
|
|
17
40
|
</div>
|
|
18
|
-
<div
|
|
19
|
-
|
|
41
|
+
<div
|
|
42
|
+
v-if="$slots.footer"
|
|
43
|
+
v-show="!isCollapsed"
|
|
44
|
+
:class="footerStyles"
|
|
45
|
+
>
|
|
46
|
+
<slot name="footer" />
|
|
20
47
|
</div>
|
|
21
48
|
</div>
|
|
22
49
|
<div
|
|
23
|
-
v-if="
|
|
24
|
-
:class="
|
|
50
|
+
v-if="side === 'left' && isShowingToolbar"
|
|
51
|
+
:class="toolbarStyles"
|
|
25
52
|
>
|
|
26
|
-
<slot name="
|
|
53
|
+
<slot name="toolbar" />
|
|
27
54
|
</div>
|
|
28
55
|
</aside>
|
|
29
56
|
</template>
|
|
@@ -31,34 +58,47 @@
|
|
|
31
58
|
<script lang="ts">
|
|
32
59
|
import { useDraggable, useElementBounding } from '@vueuse/core';
|
|
33
60
|
import _ from 'lodash';
|
|
34
|
-
import { computed, defineComponent, PropType, ref, watch } from 'vue-demi';
|
|
61
|
+
import { computed, defineComponent, PropType, ref, watch, useSlots } from 'vue-demi';
|
|
35
62
|
import { OrSidebarPlacement } from './props';
|
|
36
63
|
import {
|
|
37
64
|
SidebarRoot,
|
|
38
|
-
|
|
65
|
+
SidebarBar,
|
|
66
|
+
SidebarToolbar,
|
|
67
|
+
SidebarSides,
|
|
68
|
+
SidebarToolbarSides,
|
|
39
69
|
SidebarResize,
|
|
40
70
|
SidebarResizeSides,
|
|
71
|
+
SidebarCollapseButton,
|
|
72
|
+
SidebarCollapseButtonSides,
|
|
41
73
|
SidebarResizingSides,
|
|
42
74
|
SidebarMain,
|
|
43
75
|
SidebarHeader,
|
|
44
76
|
SidebarContent,
|
|
45
77
|
SidebarFooter,
|
|
46
78
|
} from './styles';
|
|
79
|
+
import OrSidebarCollapseButton from './OrSidebarCollapseButton.vue';
|
|
47
80
|
|
|
48
81
|
export default defineComponent({
|
|
49
82
|
name: 'OrSidebar',
|
|
50
83
|
|
|
84
|
+
components: {
|
|
85
|
+
OrSidebarCollapseButton,
|
|
86
|
+
},
|
|
87
|
+
|
|
51
88
|
props: {
|
|
52
89
|
width: {
|
|
53
90
|
type: Number,
|
|
54
|
-
|
|
55
|
-
default: 0,
|
|
91
|
+
default: 320,
|
|
56
92
|
validator: (value?: any) => _.isNumber(value) && value >= 0,
|
|
57
93
|
},
|
|
58
94
|
minimumWidth: {
|
|
59
95
|
type: Number,
|
|
60
|
-
|
|
61
|
-
|
|
96
|
+
default: 256,
|
|
97
|
+
validator: (value?: any) => _.isNumber(value) && value >= 0,
|
|
98
|
+
},
|
|
99
|
+
maximumWidth: {
|
|
100
|
+
type: Number,
|
|
101
|
+
default: 384,
|
|
62
102
|
validator: (value?: any) => _.isNumber(value) && value >= 0,
|
|
63
103
|
},
|
|
64
104
|
/**
|
|
@@ -73,10 +113,24 @@ export default defineComponent({
|
|
|
73
113
|
default: OrSidebarPlacement.right,
|
|
74
114
|
validator: (value?: any) => _.includes(_.values(OrSidebarPlacement), value),
|
|
75
115
|
},
|
|
116
|
+
draggable: {
|
|
117
|
+
type: Boolean,
|
|
118
|
+
default: true,
|
|
119
|
+
},
|
|
120
|
+
collapsible: {
|
|
121
|
+
type: Boolean,
|
|
122
|
+
default: false,
|
|
123
|
+
},
|
|
76
124
|
},
|
|
77
125
|
|
|
78
126
|
emits: ['change:width'],
|
|
79
127
|
|
|
128
|
+
expose: [
|
|
129
|
+
'root',
|
|
130
|
+
'open',
|
|
131
|
+
'close',
|
|
132
|
+
],
|
|
133
|
+
|
|
80
134
|
setup(props, { emit }) {
|
|
81
135
|
// Refs
|
|
82
136
|
const root = ref<HTMLElement>();
|
|
@@ -84,20 +138,36 @@ export default defineComponent({
|
|
|
84
138
|
|
|
85
139
|
const parentContainer = computed(() => root.value?.parentElement);
|
|
86
140
|
|
|
141
|
+
// Slots
|
|
142
|
+
const { toolbar: toolbarSlot } = useSlots();
|
|
143
|
+
|
|
87
144
|
// State
|
|
88
145
|
const startPositionX = ref(0);
|
|
89
146
|
const isResizing = ref(false);
|
|
147
|
+
const isCollapsed = ref(false);
|
|
148
|
+
const maximumWidth = ref(props.maximumWidth || 384);
|
|
90
149
|
const localWidth = ref(props.width >= props.minimumWidth ? props.width : props.minimumWidth);
|
|
91
150
|
|
|
151
|
+
const isShowingToolbar = computed(() => !!toolbarSlot);
|
|
152
|
+
|
|
92
153
|
// Styles
|
|
93
154
|
const sidebarStyle = computed(() => ({
|
|
94
|
-
width: localWidth.value + 'px',
|
|
155
|
+
width: (isCollapsed.value ? 16 : localWidth.value) + 'px',
|
|
95
156
|
}));
|
|
96
157
|
|
|
97
158
|
const rootStyles = computed(() => [
|
|
98
159
|
'or-sidebar',
|
|
99
160
|
...SidebarRoot,
|
|
100
|
-
|
|
161
|
+
]);
|
|
162
|
+
|
|
163
|
+
const sidebarStyles = computed(() => [
|
|
164
|
+
...SidebarBar,
|
|
165
|
+
...SidebarSides[props.side],
|
|
166
|
+
]);
|
|
167
|
+
|
|
168
|
+
const toolbarStyles = computed(() => [
|
|
169
|
+
...SidebarToolbar,
|
|
170
|
+
...SidebarToolbarSides[props.side],
|
|
101
171
|
]);
|
|
102
172
|
|
|
103
173
|
const resizeStyles = computed(() => [
|
|
@@ -106,6 +176,11 @@ export default defineComponent({
|
|
|
106
176
|
...(isResizing.value ? SidebarResizingSides[props.side] : []),
|
|
107
177
|
]);
|
|
108
178
|
|
|
179
|
+
const collapsibleButtonStyles = computed(() => [
|
|
180
|
+
...SidebarCollapseButton,
|
|
181
|
+
...SidebarCollapseButtonSides[props.side],
|
|
182
|
+
]);
|
|
183
|
+
|
|
109
184
|
const mainStyles = computed(() => [...SidebarMain]);
|
|
110
185
|
|
|
111
186
|
const headerStyles = computed(() => [...SidebarHeader]);
|
|
@@ -137,7 +212,16 @@ export default defineComponent({
|
|
|
137
212
|
},
|
|
138
213
|
});
|
|
139
214
|
|
|
140
|
-
|
|
215
|
+
// Methods
|
|
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);
|
|
141
225
|
|
|
142
226
|
watch(() => props.width, (newValue: number) => {
|
|
143
227
|
if (newValue !== localWidth.value) {
|
|
@@ -150,6 +234,14 @@ export default defineComponent({
|
|
|
150
234
|
if (newMinimum > localWidth.value) localWidth.value = newMinimum;
|
|
151
235
|
});
|
|
152
236
|
|
|
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
|
+
|
|
153
245
|
watch(maximumWidth, (newMaximum: number) => {
|
|
154
246
|
if (newMaximum < localWidth.value) localWidth.value = newMaximum;
|
|
155
247
|
});
|
|
@@ -160,14 +252,21 @@ export default defineComponent({
|
|
|
160
252
|
root,
|
|
161
253
|
resizeBar,
|
|
162
254
|
isResizing,
|
|
255
|
+
isCollapsed,
|
|
163
256
|
localWidth,
|
|
257
|
+
isShowingToolbar,
|
|
164
258
|
sidebarStyle,
|
|
165
259
|
rootStyles,
|
|
260
|
+
sidebarStyles,
|
|
261
|
+
toolbarStyles,
|
|
166
262
|
resizeStyles,
|
|
263
|
+
collapsibleButtonStyles,
|
|
167
264
|
mainStyles,
|
|
168
265
|
headerStyles,
|
|
169
266
|
contentStyles,
|
|
170
267
|
footerStyles,
|
|
268
|
+
open,
|
|
269
|
+
close,
|
|
171
270
|
};
|
|
172
271
|
},
|
|
173
272
|
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Meta, StoryFn } from '@storybook/vue3';
|
|
2
|
+
import OrSidebarCollapseButton from './OrSidebarCollapseButton.vue';
|
|
3
|
+
import { OrSidebarPlacement } from './props';
|
|
4
|
+
import { action } from '@storybook/addon-actions';
|
|
5
|
+
import { ref } from 'vue-demi';
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: 'Components/Sidebar/Parts/CollapseButton',
|
|
9
|
+
component: OrSidebarCollapseButton,
|
|
10
|
+
|
|
11
|
+
argTypes: {
|
|
12
|
+
// Props
|
|
13
|
+
modelValue: {
|
|
14
|
+
control: { type: 'boolean' },
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
side: {
|
|
18
|
+
control: { type: 'select' },
|
|
19
|
+
options: Object.values(OrSidebarPlacement),
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
} as Meta<typeof OrSidebarCollapseButton>;
|
|
23
|
+
|
|
24
|
+
const DefaultTemplate: StoryFn<typeof OrSidebarCollapseButton> = (args) => ({
|
|
25
|
+
components: {
|
|
26
|
+
OrSidebarCollapseButton,
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
setup() {
|
|
30
|
+
const collapsed = ref<boolean>(!!args.modelValue);
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
args,
|
|
34
|
+
collapsed,
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
methods: {
|
|
39
|
+
onUpdateModelValue: action('update:modelValue'),
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
template: '<OrSidebarCollapseButton v-model="collapsed" v-bind="args" @update:modelValue="onUpdateModelValue" />',
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export const Default = DefaultTemplate.bind({});
|
|
46
|
+
Default.args = {
|
|
47
|
+
side: OrSidebarPlacement.right,
|
|
48
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<or-icon-button
|
|
3
|
+
ref="root"
|
|
4
|
+
:class="rootStyles"
|
|
5
|
+
:icon="{ icon, size: 'inherit' }"
|
|
6
|
+
color="inherit"
|
|
7
|
+
@click="$emit('update:modelValue', !modelValue)"
|
|
8
|
+
/>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<script lang="ts">
|
|
12
|
+
import _ from 'lodash';
|
|
13
|
+
import { computed, defineComponent, PropType, ref } from 'vue-demi';
|
|
14
|
+
import { OrSidebarPlacement } from './props';
|
|
15
|
+
import { OrIconButtonV3 as OrIconButton } from '../or-icon-button-v3';
|
|
16
|
+
import { CollapseButton } from './styles';
|
|
17
|
+
|
|
18
|
+
export default defineComponent({
|
|
19
|
+
name: 'OrSidebarCollapseButton',
|
|
20
|
+
|
|
21
|
+
components: {
|
|
22
|
+
OrIconButton,
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
props: {
|
|
26
|
+
/**
|
|
27
|
+
* Must be `true` if sidebar is collapsed.
|
|
28
|
+
*/
|
|
29
|
+
modelValue: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
default: false,
|
|
32
|
+
},
|
|
33
|
+
side: {
|
|
34
|
+
type: String as PropType<OrSidebarPlacement>,
|
|
35
|
+
default: OrSidebarPlacement.right,
|
|
36
|
+
validator: (value?: any) => _.includes(_.values(OrSidebarPlacement), value),
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
emits: ['update:modelValue'],
|
|
41
|
+
|
|
42
|
+
expose: ['root'],
|
|
43
|
+
|
|
44
|
+
setup(props) {
|
|
45
|
+
// Refs
|
|
46
|
+
const root = ref<InstanceType<typeof OrIconButton>>();
|
|
47
|
+
|
|
48
|
+
const rootStyles = computed(() => [
|
|
49
|
+
...CollapseButton,
|
|
50
|
+
]);
|
|
51
|
+
|
|
52
|
+
const icon = computed(() => (props.side === OrSidebarPlacement.left !== props.modelValue) ?
|
|
53
|
+
'keyboard_arrow_left' :
|
|
54
|
+
'keyboard_arrow_right',
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
root,
|
|
59
|
+
rootStyles,
|
|
60
|
+
icon,
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
</script>
|