stimulus-library 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,43 +1,43 @@
1
- # Stimulus-Library
2
-
3
- [Documentation](https://sub-xaero.github.io/stimulus-library/) | [Full List of Controllers](https://sub-xaero.github.io/stimulus-library/)
4
-
5
- ---
6
- ![npm](https://img.shields.io/npm/dt/stimulus-library)
7
- ![npm bundle size (version)](https://img.shields.io/bundlephobia/minzip/stimulus-library/latest?label=minified%20size)
8
- ---
9
-
10
- ## Installation
11
-
12
- To get started, you'll need to add the `stimulus-library` package to your project.
13
-
14
- To do so, either add `stimulus-library` to your package.json manually
15
-
16
- ```json
17
- {
18
- "dependencies": {
19
- "stimulus-library": "latest"
20
- }
21
- }
22
- ```
23
-
24
- or run
25
- `npm install --save stimulus-library` or `yarn add stimulus-library`
26
-
27
-
28
- Then, to get started, import and register the controllers you want to use.
29
-
30
- *Please Note* as below, that when registering the name for the controller, you should use `kebab-case` and omit the `-controller` suffix.
31
-
32
- ```js
33
- import { Application } from "@hotwired/stimulus";
34
- import { AutoSubmitFormController } from "stimulus-library";
35
-
36
- const application = Application.start();
37
- application.register("auto-submit-form", AutoSubmitFormController);
38
- ```
39
-
40
- ## Tree-shaking
41
- If you use the ESM builds of the library, this library fully supports tree-shaking,
42
- only the controllers you directly import will be bundled with your application.
43
-
1
+ # Stimulus-Library
2
+
3
+ [Documentation](https://sub-xaero.github.io/stimulus-library/) | [Full List of Controllers](https://sub-xaero.github.io/stimulus-library/)
4
+
5
+ ---
6
+ ![npm](https://img.shields.io/npm/dt/stimulus-library)
7
+ ![npm bundle size (version)](https://img.shields.io/bundlephobia/minzip/stimulus-library/latest?label=minified%20size)
8
+ ---
9
+
10
+ ## Installation
11
+
12
+ To get started, you'll need to add the `stimulus-library` package to your project.
13
+
14
+ To do so, either add `stimulus-library` to your package.json manually
15
+
16
+ ```json
17
+ {
18
+ "dependencies": {
19
+ "stimulus-library": "latest"
20
+ }
21
+ }
22
+ ```
23
+
24
+ or run
25
+ `npm install --save stimulus-library` or `yarn add stimulus-library`
26
+
27
+
28
+ Then, to get started, import and register the controllers you want to use.
29
+
30
+ *Please Note* as below, that when registering the name for the controller, you should use `kebab-case` and omit the `-controller` suffix.
31
+
32
+ ```js
33
+ import { Application } from "@hotwired/stimulus";
34
+ import { AutoSubmitFormController } from "stimulus-library";
35
+
36
+ const application = Application.start();
37
+ application.register("auto-submit-form", AutoSubmitFormController);
38
+ ```
39
+
40
+ ## Tree-shaking
41
+ If you use the ESM builds of the library, this library fully supports tree-shaking,
42
+ only the controllers you directly import will be bundled with your application.
43
+
@@ -19,6 +19,7 @@ export * from './dismissable_controller';
19
19
  export * from './element_save_controller';
20
20
  export * from './equalize_controller';
21
21
  export * from './empty_dom_controller';
22
+ export * from './persisted_dismissable_controller';
22
23
  export * from './prefetch_controller';
23
24
  export * from './print_button_controller';
24
25
  export * from './responsive_iframe_controller';
@@ -0,0 +1,19 @@
1
+ import { DismissableController } from "./dismissable_controller";
2
+ import { useLocalStorage } from "../mixins";
3
+ export class PersistedDismissableController extends DismissableController {
4
+ connect() {
5
+ this.localStorage = useLocalStorage(this, this.keyValue, false, { writeDefaults: false });
6
+ if (this.localStorage.value == true) {
7
+ this.dismiss();
8
+ }
9
+ }
10
+ dismiss() {
11
+ this.localStorage.value = true;
12
+ super.dismiss();
13
+ }
14
+ }
15
+ PersistedDismissableController.values = {
16
+ key: String,
17
+ };
18
+ export class PersistedRemoveController extends PersistedDismissableController {
19
+ }
package/package.json CHANGED
@@ -1,56 +1,56 @@
1
- {
2
- "name": "stimulus-library",
3
- "description": "A library of useful controllers for Stimulus",
4
- "keywords": [
5
- "stimulusjs",
6
- "stimulus-js",
7
- "stimulus library",
8
- "stimulus controller",
9
- "ruby on rails",
10
- "ruby-on-rails"
11
- ],
12
- "version": "0.8.0",
13
- "license": "MIT",
14
- "author": {
15
- "name": "Sub-Xaero",
16
- "url": "https://github.com/Sub-Xaero/"
17
- },
18
- "homepage": "https://sub-xaero.github.io/stimulus-library/",
19
- "repository": {
20
- "type": "git",
21
- "url": "https://github.com/Sub-Xaero/stimulus-library"
22
- },
23
- "files": [
24
- "dist"
25
- ],
26
- "module": "dist/index.js",
27
- "types": "dist/index.d.ts",
28
- "scripts": {
29
- "build": "tsc",
30
- "dev": "tsc --watch",
31
- "prepack": "yarn build",
32
- "release": "standard-version",
33
- "test": "cypress run",
34
- "test:treeshake": "agadoo dist"
35
- },
36
- "dependencies": {
37
- "@babel/runtime": "^7.17.9",
38
- "@hotwired/stimulus": "^3.0.1",
39
- "date-fns": "^2.28.0",
40
- "dialog-polyfill": "^0.5.6",
41
- "lodash-es": "^4.17.21",
42
- "mitt": "^3.0.0",
43
- "smoothscroll-polyfill": "^0.4.4"
44
- },
45
- "devDependencies": {
46
- "@types/lodash-es": "^4.17.6",
47
- "@types/smoothscroll-polyfill": "^0.3.1",
48
- "agadoo": "^2.0.0",
49
- "cypress": "^10.0.3",
50
- "fast-glob": "^3.2.11",
51
- "rimraf": "^3.0.2",
52
- "standard-version": "^9.5.0",
53
- "typescript": "^4.7.3",
54
- "vite": "^2.9.10"
55
- }
56
- }
1
+ {
2
+ "name": "stimulus-library",
3
+ "description": "A library of useful controllers for Stimulus",
4
+ "keywords": [
5
+ "stimulusjs",
6
+ "stimulus-js",
7
+ "stimulus library",
8
+ "stimulus controller",
9
+ "ruby on rails",
10
+ "ruby-on-rails"
11
+ ],
12
+ "version": "0.9.0",
13
+ "license": "MIT",
14
+ "author": {
15
+ "name": "Sub-Xaero",
16
+ "url": "https://github.com/Sub-Xaero/"
17
+ },
18
+ "homepage": "https://sub-xaero.github.io/stimulus-library/",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/Sub-Xaero/stimulus-library"
22
+ },
23
+ "files": [
24
+ "dist"
25
+ ],
26
+ "module": "dist/index.js",
27
+ "types": "dist/index.d.ts",
28
+ "scripts": {
29
+ "build": "tsc",
30
+ "dev": "tsc --watch",
31
+ "prepack": "yarn build",
32
+ "release": "standard-version",
33
+ "test": "cypress run",
34
+ "test:treeshake": "agadoo dist"
35
+ },
36
+ "dependencies": {
37
+ "@babel/runtime": "^7.17.9",
38
+ "@hotwired/stimulus": "^3.0.1",
39
+ "date-fns": "^2.28.0",
40
+ "dialog-polyfill": "^0.5.6",
41
+ "lodash-es": "^4.17.21",
42
+ "mitt": "^3.0.0",
43
+ "smoothscroll-polyfill": "^0.4.4"
44
+ },
45
+ "devDependencies": {
46
+ "@types/lodash-es": "^4.17.6",
47
+ "@types/smoothscroll-polyfill": "^0.3.1",
48
+ "agadoo": "^2.0.0",
49
+ "cypress": "^10.0.3",
50
+ "fast-glob": "^3.2.11",
51
+ "rimraf": "^3.0.2",
52
+ "standard-version": "^9.5.0",
53
+ "typescript": "^4.7.3",
54
+ "vite": "^2.9.10"
55
+ }
56
+ }