Skip to content

Commit 394f468

Browse files
Merge pull request #9 from sho918/bump-stimulus-to-v3.0.0
Bump stimulus to v3.0.0
2 parents aff36ae + d4ab49a commit 394f468

File tree

6 files changed

+20
-44
lines changed

6 files changed

+20
-44
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
### Chore
10+
11+
- **Breaking** Upgrading Stimulus to `3.x` and change namespace from `stimulus` to `@hotwired/stimulus`.
12+
- Using default value option for `wrapperSelector`.
13+
914
## [3.0.0] - 2021-05-09
1015

1116
## Chore

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<title>Stimulus Rails Nested Form</title>
1313

1414
<script type="module" defer>
15-
import { Application } from 'stimulus'
15+
import { Application } from '@hotwired/stimulus'
1616
import NestedForm from './src/index'
1717

1818
const application = Application.start()

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"@babel/polyfill": "^7.12.1",
2626
"@babel/preset-env": "^7.14.1",
2727
"@babel/preset-typescript": "^7.13.0",
28+
"@hotwired/stimulus": "^3.0.0",
2829
"@snowpack/plugin-babel": "2.1.3",
2930
"@testing-library/dom": "^7.30.4",
3031
"@types/jest": "^26.0.14",
@@ -33,7 +34,6 @@
3334
"mutationobserver-shim": "^0.3.7",
3435
"np": "^7.5.0",
3536
"prettier-standard": "16.4.1",
36-
"stimulus": "^2.0.0",
3737
"typescript": "^4.2.4",
3838
"vite": "^2.2.4"
3939
},
@@ -43,6 +43,6 @@
4343
]
4444
},
4545
"peerDependencies": {
46-
"stimulus": "^2.0.0"
46+
"@hotwired/stimulus": "^3.0.0"
4747
}
4848
}

spec/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Application } from 'stimulus'
1+
import { Application } from '@hotwired/stimulus'
22
import NestedForm from '../src/index'
33

44
const startStimulus = (): void => {

src/index.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
import { Controller } from 'stimulus'
1+
import { Controller } from '@hotwired/stimulus'
22

33
export default class extends Controller {
44
targetTarget: HTMLElement
55
templateTarget: HTMLElement
66
wrapperSelectorValue: string
7-
wrapperSelector: string
87

98
static targets = ['target', 'template']
109
static values = {
11-
wrapperSelector: String
12-
}
13-
14-
initialize (): void {
15-
this.wrapperSelector = this.wrapperSelectorValue || '.nested-form-wrapper'
10+
wrapperSelector: {
11+
type: String,
12+
default: '.nested-form-wrapper'
13+
}
1614
}
1715

1816
add (e: Event) {
@@ -26,7 +24,7 @@ export default class extends Controller {
2624
e.preventDefault()
2725

2826
// @ts-ignore
29-
const wrapper: HTMLElement = e.target.closest(this.wrapperSelector)
27+
const wrapper: HTMLElement = e.target.closest(this.wrapperSelectorValue)
3028

3129
if (wrapper.dataset.newRecord === 'true') {
3230
wrapper.remove()

yarn.lock

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,6 +1268,11 @@
12681268
resolved "https://registry.yarnpkg.com/@glimmer/util/-/util-0.41.4.tgz#508fd82ca40305416e130f0da7b537295ded7989"
12691269
integrity sha512-DwS94K+M0vtG+cymxH0rslJr09qpdjyOLdCjmpKcG/nNiZQfMA1ybAaFEmwk9UaVlUG9STENFeQwyrLevJB+7g==
12701270

1271+
"@hotwired/stimulus@^3.0.0":
1272+
version "3.0.0"
1273+
resolved "https://registry.yarnpkg.com/@hotwired/stimulus/-/stimulus-3.0.0.tgz#45171e61417af60f0e546665c52fae5b67295cee"
1274+
integrity sha512-UFIuuf7GjKJoIYromuTmqfzT8gZ8eu5zIB5m2QoEsopymGeN7rfDSTRPyRfwHIqP0x+0vWo4O1LFozw+/sWXxg==
1275+
12711276
12721277
version "2.2.3"
12731278
resolved "https://registry.yarnpkg.com/@iarna/toml/-/toml-2.2.3.tgz#f060bf6eaafae4d56a7dac618980838b0696e2ab"
@@ -1546,30 +1551,6 @@
15461551
"@babel/core" "^7.10.5"
15471552
workerpool "^6.0.0"
15481553

1549-
"@stimulus/core@^2.0.0":
1550-
version "2.0.0"
1551-
resolved "https://registry.yarnpkg.com/@stimulus/core/-/core-2.0.0.tgz#140c85318d6a8a8210c0faf182223b8459348877"
1552-
integrity sha512-ff70GafKtzc8zQ1/cG+UvL06GcifPWovf2wBEdjLMh9xO2GOYURO3y2RYgzIGYUIBefQwyfX2CLfJdZFJrEPTw==
1553-
dependencies:
1554-
"@stimulus/mutation-observers" "^2.0.0"
1555-
1556-
"@stimulus/multimap@^2.0.0":
1557-
version "2.0.0"
1558-
resolved "https://registry.yarnpkg.com/@stimulus/multimap/-/multimap-2.0.0.tgz#420cfa096ed6538df4a91dbd2b2842c1779952b2"
1559-
integrity sha512-pMBCewkZCFVB3e5mEMoyO9+9aKzHDITmf3OnPun51YWxlcPdHcwbjqm1ylK63fsoduIE+RowBpFwFqd3poEz4w==
1560-
1561-
"@stimulus/mutation-observers@^2.0.0":
1562-
version "2.0.0"
1563-
resolved "https://registry.yarnpkg.com/@stimulus/mutation-observers/-/mutation-observers-2.0.0.tgz#3dbe37453bda47a6c795a90204ee8d77a799fb87"
1564-
integrity sha512-kx4VAJdPhIGBQKGIoUDC2tupEKorG3A+ckc2b1UiwInKTMAC1axOHU8ebcwhaJIxRqIrs8//4SJo9YAAOx6FEg==
1565-
dependencies:
1566-
"@stimulus/multimap" "^2.0.0"
1567-
1568-
"@stimulus/webpack-helpers@^2.0.0":
1569-
version "2.0.0"
1570-
resolved "https://registry.yarnpkg.com/@stimulus/webpack-helpers/-/webpack-helpers-2.0.0.tgz#54296d2a2dffd4f962d2e802d99a3fdd84b8845f"
1571-
integrity sha512-D6tJWsAC024MwGEIKlUVYU8Ln87mlrmiwHvYAjipg+s8H4eLxUMQ3PZkWyPevfipH+oR3leuHsjYsK1gN5ViQA==
1572-
15731554
"@szmarczak/http-timer@^1.1.2":
15741555
version "1.1.2"
15751556
resolved "https://registry.yarnpkg.com/@szmarczak/http-timer/-/http-timer-1.1.2.tgz#b1665e2c461a2cd92f4c1bbf50d5454de0d4b421"
@@ -7050,14 +7031,6 @@ stealthy-require@^1.1.1:
70507031
resolved "https://registry.yarnpkg.com/stealthy-require/-/stealthy-require-1.1.1.tgz#35b09875b4ff49f26a777e509b3090a3226bf24b"
70517032
integrity sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks=
70527033

7053-
stimulus@^2.0.0:
7054-
version "2.0.0"
7055-
resolved "https://registry.yarnpkg.com/stimulus/-/stimulus-2.0.0.tgz#713c8b91a72ef90914b90955f0e705f004403047"
7056-
integrity sha512-xipy7BS5TVpg4fX6S8LhrYZp7cmHGjmk09WSAiVx1gF5S5g43IWsuetfUhIk8HfHUG+4MQ9nY0FQz4dRFLs/8w==
7057-
dependencies:
7058-
"@stimulus/core" "^2.0.0"
7059-
"@stimulus/webpack-helpers" "^2.0.0"
7060-
70617034
string-argv@^0.3.0:
70627035
version "0.3.1"
70637036
resolved "https://registry.yarnpkg.com/string-argv/-/string-argv-0.3.1.tgz#95e2fbec0427ae19184935f816d74aaa4c5c19da"

0 commit comments

Comments
 (0)