@@ -41,7 +41,7 @@ _.extend(ThreeType.prototype, BaseType.prototype, {
41
41
// allow type unions
42
42
if ( this . typeName instanceof Array ) {
43
43
var instances = this . typeName . map ( function ( typeName ) {
44
- return ' Instance(' + typeName + ' , allow_none=' + nullableStr + ')' ;
44
+ return ` Instance(${ typeName } , allow_none=${ nullableStr } )` ;
45
45
} ) ;
46
46
return 'Union([\n' + instances . join ( ',\n' ) + '\n ]).tag(sync=True, **widget_serialization)' ;
47
47
}
@@ -50,14 +50,14 @@ _.extend(ThreeType.prototype, BaseType.prototype, {
50
50
return 'This().tag(sync=True, **widget_serialization)' ;
51
51
}
52
52
53
- var ret = ' Instance(' + this . typeName ;
53
+ var ret = ` Instance(${ this . typeName } ` ;
54
54
if ( this . args !== undefined ) {
55
- ret += ' , args=' + this . args ;
55
+ ret += ` , args=${ this . args } ` ;
56
56
}
57
57
if ( this . kwargs !== undefined ) {
58
- ret += ' , kw=' + this . kwargs ;
58
+ ret += ` , kw=${ this . kwargs } ` ;
59
59
}
60
- ret += ' , allow_none=' + nullableStr + ' ).tag(sync=True, **widget_serialization)' ;
60
+ ret += ` , allow_none=${ nullableStr } ).tag(sync=True, **widget_serialization)` ;
61
61
return ret ;
62
62
} ,
63
63
getPropArrayName : function ( ) {
@@ -81,7 +81,7 @@ _.extend(ForwardDeclaredThreeType.prototype, ThreeType.prototype, {
81
81
// allow type unions
82
82
if ( this . typeName instanceof Array ) {
83
83
var instances = this . typeName . map ( function ( typeName ) {
84
- return ' Instance(\'' + this . forwardType ( ) + '\' , allow_none=' + nullableStr + ')' ;
84
+ return ` Instance(' ${ this . forwardType ( ) } ' , allow_none=${ nullableStr } )` ;
85
85
} ) ;
86
86
return 'Union([\n' + instances . join ( ',\n' ) + '\n ]).tag(sync=True, **widget_serialization)' ;
87
87
}
@@ -90,14 +90,14 @@ _.extend(ForwardDeclaredThreeType.prototype, ThreeType.prototype, {
90
90
return 'This().tag(sync=True, **widget_serialization)' ;
91
91
}
92
92
93
- var ret = ' Instance(\'' + this . forwardType ( ) + '\'' ;
93
+ var ret = ` Instance(' ${ this . forwardType ( ) } '` ;
94
94
if ( this . args !== undefined ) {
95
- ret += ' , args=' + this . args ;
95
+ ret += ` , args=${ this . args } ` ;
96
96
}
97
97
if ( this . kwargs !== undefined ) {
98
- ret += ' , kw=' + this . kwargs ;
98
+ ret += ` , kw=${ this . kwargs } ` ;
99
99
}
100
- ret += ' , allow_none=' + nullableStr + ' ).tag(sync=True, **widget_serialization)' ;
100
+ ret += ` , allow_none=${ nullableStr } ).tag(sync=True, **widget_serialization)` ;
101
101
return ret ;
102
102
} ,
103
103
} ) ;
@@ -143,7 +143,7 @@ _.extend(ThreeTypeDict.prototype, BaseType.prototype, {
143
143
if ( this . typeName === 'this' ) {
144
144
return 'Dict(This()).tag(sync=True, **widget_serialization)' ;
145
145
}
146
- return ' Dict(Instance(' + this . typeName + ' )).tag(sync=True, **widget_serialization)' ;
146
+ return ` Dict(Instance(${ this . typeName } )).tag(sync=True, **widget_serialization)` ;
147
147
} ,
148
148
getPropArrayName : function ( ) {
149
149
return 'three_dict_properties' ;
@@ -159,32 +159,31 @@ function Bool(defaultValue, nullable) {
159
159
}
160
160
_ . extend ( Bool . prototype , BaseType . prototype , {
161
161
getTraitlet : function ( ) {
162
- var pyBoolValue = this . defaultValue ? 'True' : 'False' ;
163
162
var nullableStr = this . nullable ? 'True' : 'False' ;
164
- return ' Bool(' + pyBoolValue + ' , allow_none=' + nullableStr + ' ).tag(sync=True)' ;
163
+ return ` Bool(${ this . getPythonDefaultValue ( ) } , allow_none=${ nullableStr } ).tag(sync=True)` ;
165
164
} ,
166
165
} ) ;
167
166
168
167
function Int ( defaultValue , nullable ) {
169
168
this . nullable = nullable === true ;
170
- this . defaultValue = defaultValue == null && ! this . nullable ? 0 : defaultValue ;
169
+ this . defaultValue = defaultValue === null ? ! this . nullable ? 0 : 'None' : defaultValue ;
171
170
}
172
171
_ . extend ( Int . prototype , BaseType . prototype , {
173
172
getTraitlet : function ( ) {
174
173
var nullableStr = this . nullable ? 'True' : 'False' ;
175
- return ' CInt(' + this . defaultValue + ' , allow_none=' + nullableStr + ' ).tag(sync=True)' ;
174
+ return ` CInt(${ this . getPythonDefaultValue ( ) } , allow_none=${ nullableStr } ).tag(sync=True)` ;
176
175
} ,
177
176
178
177
} ) ;
179
178
180
179
function Float ( defaultValue , nullable ) {
181
180
this . nullable = nullable === true ;
182
- this . defaultValue = defaultValue == null && ! this . nullable ? 0.0 : defaultValue ;
181
+ this . defaultValue = defaultValue == null ? ! this . nullable ? 0.0 : 'None' : defaultValue ;
183
182
}
184
183
_ . extend ( Float . prototype , BaseType . prototype , {
185
184
getTraitlet : function ( ) {
186
185
var nullableStr = this . nullable ? 'True' : 'False' ;
187
- return ' CFloat(' + this . getPythonDefaultValue ( ) + ' , allow_none=' + nullableStr + ' ).tag(sync=True)' ;
186
+ return ` CFloat(${ this . getPythonDefaultValue ( ) } , allow_none=${ nullableStr } ).tag(sync=True)` ;
188
187
} ,
189
188
getPropertyConverterFn : function ( ) {
190
189
return 'convertFloat' ;
@@ -199,7 +198,7 @@ function StringType(defaultValue, nullable) {
199
198
_ . extend ( StringType . prototype , BaseType . prototype , {
200
199
getTraitlet : function ( ) {
201
200
var nullableStr = this . nullable ? 'True' : 'False' ;
202
- return ' Unicode(' + JSON . stringify ( this . defaultValue ) + ' , allow_none=' + nullableStr + ' ).tag(sync=True)' ;
201
+ return ` Unicode(${ this . getPythonDefaultValue ( ) } , allow_none=${ nullableStr } ).tag(sync=True)` ;
203
202
} ,
204
203
205
204
} ) ;
@@ -212,7 +211,7 @@ function Enum(enumTypeName, defaultValue, nullable) {
212
211
_ . extend ( Enum . prototype , BaseType . prototype , {
213
212
getTraitlet : function ( ) {
214
213
var nullableStr = this . nullable ? 'True' : 'False' ;
215
- return ' Enum(' + this . enumTypeName + ', "' + this . defaultValue + ' , allow_none=' + nullableStr + '" ).tag(sync=True)' ;
214
+ return ` Enum(${ this . enumTypeName } , ${ this . getPythonDefaultValue ( ) } , allow_none=${ nullableStr } ).tag(sync=True)` ;
216
215
} ,
217
216
getPropertyConverterFn : function ( ) {
218
217
return 'convertEnum' ;
@@ -224,7 +223,7 @@ function Color(defaultValue) {
224
223
}
225
224
_ . extend ( Color . prototype , BaseType . prototype , {
226
225
getTraitlet : function ( ) {
227
- return ' Unicode(' + JSON . stringify ( this . defaultValue ) + ' ).tag(sync=True)'
226
+ return ` Unicode(${ this . getPythonDefaultValue ( ) } ).tag(sync=True)` ;
228
227
} ,
229
228
getPropertyConverterFn : function ( ) {
230
229
return 'convertColor' ;
@@ -279,7 +278,7 @@ function DictType(defaultValue={}, nullable) {
279
278
_ . extend ( DictType . prototype , BaseType . prototype , {
280
279
getTraitlet : function ( ) {
281
280
var nullableStr = this . nullable ? 'True' : 'False' ;
282
- return ' Dict(default_value=' + this . defaultValue + ' , allow_none=' + nullableStr + ' ).tag(sync=True)' ;
281
+ return ` Dict(default_value=${ this . getPythonDefaultValue ( ) } , allow_none=${ nullableStr } ).tag(sync=True)` ;
283
282
} ,
284
283
} ) ;
285
284
@@ -288,7 +287,7 @@ function FunctionType(fn) {
288
287
}
289
288
_ . extend ( FunctionType . prototype , BaseType . prototype , {
290
289
getTraitlet : function ( ) {
291
- return " Unicode('" + this . defaultValue . toString ( ) + " ').tag(sync=True)" ;
290
+ return ` Unicode('${ this . defaultValue . toString ( ) } ').tag(sync=True)` ;
292
291
} ,
293
292
getJSPropertyValue : function ( ) {
294
293
return this . defaultValue . toString ( ) ;
0 commit comments