1
+ const chalk = require ( 'chalk' )
2
+ const custom = require ( '../customcolors' )
3
+ const colorComment = custom . colorComment
4
+ const colorPrimitive = custom . colorPrimitive
5
+ const colorError = custom . colorError
6
+ const colorArgs = custom . colorArgs
7
+
8
+ const NAME = {
9
+ category : 'Options/Misc' ,
10
+ name : 'name' ,
11
+ type : 'string' ,
12
+ restrictions : 'only respected when used as a component option' ,
13
+ details : `Allow the component to recursively invoke itself in its template.
14
+ Note that when a component is registered globally with ${ colorArgs ( 'Vue.component()' ) } ,
15
+ the global ID is automatically set as its name.
16
+ Another benefit of specifying a ${ colorArgs ( 'name' ) } option is debugging.
17
+ Named components result in more helpful warning messages.
18
+ Also, when inspecting an app in the ${ chalk . green ( 'vue-devtools' ) } , unnamed components
19
+ will show up as ${ colorArgs ( '<AnonymousComponent>' ) } , which isn’t very informative.
20
+ By providing the ${ colorArgs ( 'name' ) } option, you will get a much more informative
21
+ component tree.
22
+ `
23
+
24
+ }
25
+ const DELIMITERS = {
26
+ category : 'Options/Misc' ,
27
+ name : 'delimiters' ,
28
+ type : 'Array<string>' ,
29
+ def : '["{{", "}}"]' ,
30
+ details : `Change the plain text interpolation delimiters.
31
+ ${ chalk . bold ( 'This option is only available in the full build' ) } .` ,
32
+ example : `
33
+ ${ colorArgs ( 'new' ) } Vue({
34
+ delimiters: [${ chalk . green ( "'${'" ) } , ${ chalk . green ( "'}'" ) } ]
35
+ })
36
+ ${ colorComment ( '// Delimiters changed to ES6 template string style' ) }
37
+ `
38
+
39
+ }
40
+ const FUNCTIONAL = {
41
+ category : 'Option/Misc' ,
42
+ name : 'functional' ,
43
+ type : 'boolean' ,
44
+ details : `Causes a component to be stateless (no ${ colorArgs ( 'data' ) } and instanceless (no ${ colorArgs ( 'this' ) } context).
45
+ They are simply a ${ colorArgs ( 'render' ) } function that returns virtual nodes making them much cheaper to render.`
46
+ }
47
+ const MODEL = {
48
+ category : 'Options/Misc' ,
49
+ name : 'model' ,
50
+ type : '{ prop?: string, event?: string }' ,
51
+ details : `Allows a custom component to customize the prop and event used when it’s used with ${ colorArgs ( 'v-model' ) } .
52
+ By default, ${ colorArgs ( 'v-model' ) } on a component uses ${ colorArgs ( 'value' ) } as the prop and input as the event,
53
+ but some input types such as checkboxes and radio buttons may want to use the ${ colorArgs ( 'value' ) }
54
+ prop for a different purpose. Using the ${ colorArgs ( 'model' ) } option can avoid the conflict in such cases.
55
+ ` ,
56
+ example : `
57
+ Vue.component(${ chalk . green ( "'my-checkbox'" ) } , {
58
+ model: {
59
+ prop: ${ chalk . green ( "'checked'" ) } ,
60
+ event: ${ chalk . green ( "'change'" ) }
61
+ },
62
+ props: {
63
+ ${ colorComment ( `// this allows using the 'value' prop for a different purpose` ) }
64
+ value: ${ chalk . green ( "String" ) } ,
65
+ ${ colorComment ( `// use 'checked' as the prop which take the place of 'value'` ) }
66
+ checked: {
67
+ type: ${ chalk . green ( "Number" ) } ,
68
+ default: ${ colorPrimitive ( "0" ) }
69
+ }
70
+ },
71
+ ${ colorComment ( '// ...' ) }
72
+ })
73
+
74
+ ${ chalk . blue ( '<my-checkbox v-model=' ) } ${ chalk . green ( '"foo"' ) } ${ chalk . blue ( 'value=' ) } ${ chalk . green ( '"foo"' ) } ${ chalk . blue ( '></my-checkbox>' ) }
75
+
76
+ The above will be equivalent to:
77
+
78
+ ${ chalk . blue ( '<my-checkbox' ) }
79
+ :checked=${ chalk . green ( '"foo"' ) }
80
+ @change=${ chalk . green ( '"val => { foo = val }"' ) }
81
+ value=${ chalk . green ( '"some value"' ) } >
82
+ ${ chalk . blue ( '</my-checkbox>' ) }
83
+
84
+ `
85
+ }
86
+ const INHERIT_ATTRS = {
87
+ category : 'Options/Misc' ,
88
+ name : 'inheritAttrs' ,
89
+ type : 'boolean' ,
90
+ def : 'true' ,
91
+ details : `By default, parent scope attribute bindings that are not recognized as props will “fallthrough”
92
+ and be applied to the root element of the child component as normal HTML attributes.
93
+ When authoring a component that wraps a target element or another component,
94
+ this may not always be the desired behavior. By setting ${ colorArgs ( 'inheritAttrs' ) } to ${ colorArgs ( 'false' ) } ,
95
+ this default behavior can be disabled. The attributes are available via the ${ colorArgs ( '$attrs' ) } instance property
96
+ (also new in 2.4) and can be explicitly bound to a non-root element using ${ colorArgs ( 'v-bind' ) } .
97
+
98
+ `
99
+ }
100
+ const COMMENTS = {
101
+ category : 'Options/Misc' ,
102
+ name : 'comments' ,
103
+ type : 'boolean' ,
104
+ def : 'false' ,
105
+ details : `When set to ${ colorArgs ( 'true' ) } , will preserve and render HTML comments found in templates.
106
+ The default behavior is discarding them.`
107
+ }
108
+
109
+
110
+ module . exports = {
111
+ NAME ,
112
+ DELIMITERS ,
113
+ FUNCTIONAL ,
114
+ MODEL ,
115
+ INHERIT_ATTRS ,
116
+ COMMENTS
117
+ }
0 commit comments