1- import { defineComponent , h } from " vue"
1+ import { defineComponent , h } from ' vue'
22
3-
4- const CSidebarProps = {
5- /**
6- * A string of all className you want applied to the base component.
3+ const CSidebar = defineComponent ( {
4+ name : 'CSidebar' ,
5+ props : {
6+ /**
7+ * Hide sidebar.
8+ */
9+ hide : Boolean ,
10+ /**
11+ * Make sidebar narrow.
712 */
8- className : {
9- type : String ,
10- required : false
11- } ,
12- // hide?: boolean
1313 narrow : {
14- type : Boolean ,
15- required : false
14+ type : Boolean ,
15+ required : false ,
1616 } ,
1717 /**
18- * Method called before the hide animation has started.
19- */
20- //onHide?: () => void,
21- /**
22- * Method called before the show animation has started.
23- */
24- //onShow?: () => void,
25-
18+ * Set sidebar to overlaid variant.
19+ */
2620 overlaid : {
27- type : String ,
28- required : false
21+ type : Boolean ,
22+ required : false ,
2923 } ,
24+ /**
25+ * Place sidebar in non-static positions.
26+ */
3027 position : {
31- type : String ,
32- validator : function ( value :string ) {
33- return [ 'fixed' , 'sticky' ] . includes ( value )
34- }
28+ type : String ,
29+ default : undefined ,
30+ validator : ( value : string ) => {
31+ return [ 'fixed' ] . includes ( value )
32+ } ,
3533 } ,
34+ /**
35+ * Make any sidebar self hiding across all viewports or pick a maximum breakpoint with which to have a self hiding up to.
36+ *
37+ * @values 'xs', 'sm', 'md', 'lg', 'xl', 'xxl'
38+ */
3639 selfHiding : {
37- validator : function ( value :any ) {
38- if ( typeof value === 'string' ) {
39- return [ 'xs' , 'sm' , 'md' , 'lg' , 'xl' , 'xxl' ] . includes ( value )
40- } else if ( typeof value === 'boolean' ) {
41- return true
42- } else {
43- return false
44- }
45- }
46- } ,
47- show : {
48- type : String ,
49- required : false
40+ type : [ Boolean , String ] ,
41+ default : undefined ,
42+ validator : ( value : boolean | string ) => {
43+ if ( typeof value === 'string' ) {
44+ return [ 'xs' , 'sm' , 'md' , 'lg' , 'xl' , 'xxl' ] . includes ( value )
45+ } else if ( typeof value === 'boolean' ) {
46+ return true
47+ } else {
48+ return false
49+ }
50+ } ,
5051 } ,
52+ /**
53+ * Expand narrowed sidebar on hover.
54+ */
5155 unfoldable : {
52- type : String ,
53- required : false
54- }
55- }
56-
57- const CSidebar = defineComponent ( {
58- name : 'CSidebar' ,
59- props : CSidebarProps ,
60- setup ( props , { slots } ) {
61- return ( ) => h (
62- 'div' ,
63- {
64- class : [
65- 'sidebar' ,
66- {
67- 'sidebar-narrow' : props . narrow ,
68- 'sidebar-overlaid' : props . overlaid ,
69- [ `sidebar-${ props . position } ` ] : props . position ,
70- [ `sidebar-self-hiding${ typeof props . selfHiding !== 'boolean' && '-' + props . selfHiding } ` ] : props . selfHiding ,
71- 'sidebar-narrow-unfoldable' : props . unfoldable ,
72- 'show' : props . show ,
73- } ,
74- props . className ,
75- ] ,
56+ type : String ,
57+ default : undefined ,
58+ required : false ,
59+ } ,
60+ /**
61+ * Toggle the visibility of sidebar component.
62+ */
63+ visible : Boolean ,
64+ } ,
65+ setup ( props , { slots } ) {
66+ return ( ) =>
67+ h (
68+ 'div' ,
69+ {
70+ class : [
71+ 'sidebar' ,
72+ {
73+ 'sidebar-narrow' : props . narrow ,
74+ 'sidebar-overlaid' : props . overlaid ,
75+ [ `sidebar-${ props . position } ` ] : props . position ,
76+ [ `sidebar-self-hiding${
77+ typeof props . selfHiding !== 'boolean' && '-' + props . selfHiding
78+ } `] : props . selfHiding ,
79+ 'sidebar-narrow-unfoldable' : props . unfoldable ,
80+ show : props . visible ,
81+ } ,
82+ ] ,
7683 } ,
77- slots . default && slots . default ( )
84+ slots . default && slots . default ( ) ,
7885 )
79- }
86+ } ,
8087} )
8188
82- export { CSidebar }
89+ export { CSidebar }
0 commit comments