Skip to content

Commit 131a9c2

Browse files
committed
[Typed] Use stimulus values api to set default values
1 parent 950726d commit 131a9c2

File tree

2 files changed

+56
-56
lines changed

2 files changed

+56
-56
lines changed

src/Typed/Resources/assets/dist/controller.js

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@ import Typed from 'typed.js';
44
class default_1 extends Controller {
55
connect() {
66
const options = {
7-
strings: this.stringsValue || null,
8-
typeSpeed: this.typeSpeedValue || 30,
9-
smartBackspace: this.smartBackspaceValue || true,
10-
startDelay: this.startDelayValue || 0,
11-
backSpeed: this.backSpeedValue || 0,
12-
shuffle: this.shuffleValue || false,
13-
backDelay: this.backDelayValue || 700,
14-
fadeOut: this.fadeOutValue || false,
15-
fadeOutClass: this.fadeOutClassValue || 'typed-fade-out',
16-
fadeOutDelay: this.fadeOutDelayValue || 500,
17-
loop: this.loopValue || false,
18-
loopCount: this.loopCountValue || Infinity,
19-
showCursor: this.showCursorValue || true,
20-
cursorChar: this.cursorCharValue || '.',
21-
autoInsertCss: this.autoInsertCssValue || true,
22-
attr: this.attrValue || null,
23-
bindInputFocusEvents: this.bindInputFocusEventsValue || false,
24-
contentType: this.contentTypeValue || 'html',
7+
strings: this.stringsValue,
8+
typeSpeed: this.typeSpeedValue,
9+
smartBackspace: this.smartBackspaceValue,
10+
startDelay: this.startDelayValue,
11+
backSpeed: this.backSpeedValue,
12+
shuffle: this.shuffleValue,
13+
backDelay: this.backDelayValue,
14+
fadeOut: this.fadeOutValue,
15+
fadeOutClass: this.fadeOutClassValue,
16+
fadeOutDelay: this.fadeOutDelayValue,
17+
loop: this.loopValue,
18+
loopCount: this.loopCountValue,
19+
showCursor: this.showCursorValue,
20+
cursorChar: this.cursorCharValue,
21+
autoInsertCss: this.autoInsertCssValue,
22+
attr: this.attrValue,
23+
bindInputFocusEvents: this.bindInputFocusEventsValue,
24+
contentType: this.contentTypeValue,
2525
};
2626
this._dispatchEvent('typed:pre-connect', { options });
2727
const typed = new Typed(this.element, options);
@@ -33,23 +33,23 @@ class default_1 extends Controller {
3333
}
3434
default_1.values = {
3535
strings: Array,
36-
typeSpeed: Number,
37-
smartBackspace: Boolean,
36+
typeSpeed: { type: Number, default: 30 },
37+
smartBackspace: { type: Boolean, default: true },
3838
startDelay: Number,
3939
backSpeed: Number,
4040
shuffle: Boolean,
41-
backDelay: Number,
41+
backDelay: { type: Number, default: 700 },
4242
fadeOut: Boolean,
43-
fadeOutClass: String,
44-
fadeOutDelay: Number,
43+
fadeOutClass: { type: String, default: 'typed-fade-out' },
44+
fadeOutDelay: { type: Number, default: 500 },
4545
loop: Boolean,
46-
loopCount: Number,
47-
showCursor: Boolean,
48-
cursorChar: String,
49-
autoInsertCss: Boolean,
46+
loopCount: { type: Number, default: Infinity },
47+
showCursor: { type: Boolean, default: true },
48+
cursorChar: { type: String, default: '.' },
49+
autoInsertCss: { type: Boolean, default: true },
5050
attr: String,
5151
bindInputFocusEvents: Boolean,
52-
contentType: String,
52+
contentType: { type: String, default: 'html' },
5353
};
5454

5555
export { default_1 as default };

src/Typed/Resources/assets/src/controller.ts

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,45 +15,45 @@ import Typed from 'typed.js';
1515
export default class extends Controller {
1616
static values = {
1717
strings: Array,
18-
typeSpeed: Number,
19-
smartBackspace: Boolean,
18+
typeSpeed: { type: Number, default: 30 },
19+
smartBackspace: { type: Boolean, default: true },
2020
startDelay: Number,
2121
backSpeed: Number,
2222
shuffle: Boolean,
23-
backDelay: Number,
23+
backDelay: { type: Number, default: 700 },
2424
fadeOut: Boolean,
25-
fadeOutClass: String,
26-
fadeOutDelay: Number,
25+
fadeOutClass: { type: String, default: 'typed-fade-out' },
26+
fadeOutDelay: { type: Number, default: 500 },
2727
loop: Boolean,
28-
loopCount: Number,
29-
showCursor: Boolean,
30-
cursorChar: String,
31-
autoInsertCss: Boolean,
28+
loopCount: { type: Number, default: Infinity },
29+
showCursor: { type: Boolean, default: true },
30+
cursorChar: { type: String, default: '.' },
31+
autoInsertCss: { type: Boolean, default: true },
3232
attr: String,
3333
bindInputFocusEvents: Boolean,
34-
contentType: String,
34+
contentType: { type: String, default: 'html' },
3535
};
3636

3737
connect() {
3838
const options = {
39-
strings: this.stringsValue || null,
40-
typeSpeed: this.typeSpeedValue || 30,
41-
smartBackspace: this.smartBackspaceValue || true,
42-
startDelay: this.startDelayValue || 0,
43-
backSpeed: this.backSpeedValue || 0,
44-
shuffle: this.shuffleValue || false,
45-
backDelay: this.backDelayValue || 700,
46-
fadeOut: this.fadeOutValue || false,
47-
fadeOutClass: this.fadeOutClassValue || 'typed-fade-out',
48-
fadeOutDelay: this.fadeOutDelayValue || 500,
49-
loop: this.loopValue || false,
50-
loopCount: this.loopCountValue || Infinity,
51-
showCursor: this.showCursorValue || true,
52-
cursorChar: this.cursorCharValue || '.',
53-
autoInsertCss: this.autoInsertCssValue || true,
54-
attr: this.attrValue || null,
55-
bindInputFocusEvents: this.bindInputFocusEventsValue || false,
56-
contentType: this.contentTypeValue || 'html',
39+
strings: this.stringsValue,
40+
typeSpeed: this.typeSpeedValue,
41+
smartBackspace: this.smartBackspaceValue,
42+
startDelay: this.startDelayValue,
43+
backSpeed: this.backSpeedValue,
44+
shuffle: this.shuffleValue,
45+
backDelay: this.backDelayValue,
46+
fadeOut: this.fadeOutValue,
47+
fadeOutClass: this.fadeOutClassValue,
48+
fadeOutDelay: this.fadeOutDelayValue,
49+
loop: this.loopValue,
50+
loopCount: this.loopCountValue,
51+
showCursor: this.showCursorValue,
52+
cursorChar: this.cursorCharValue,
53+
autoInsertCss: this.autoInsertCssValue,
54+
attr: this.attrValue,
55+
bindInputFocusEvents: this.bindInputFocusEventsValue,
56+
contentType: this.contentTypeValue,
5757
};
5858

5959
this._dispatchEvent('typed:pre-connect', { options });

0 commit comments

Comments
 (0)