@mypolis.eu/action-controller 3.0.1 → 4.0.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 +11 -11
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -55,7 +55,7 @@ of UI. The Controller base class handles the setup of action listeners.
|
|
|
55
55
|
Actions link DOM events on elements within a controller's template to methods
|
|
56
56
|
on that controller instance. They are defined using the data-action attribute.
|
|
57
57
|
|
|
58
|
-
**Syntax**: `data-action="eventType
|
|
58
|
+
**Syntax**: `data-action="eventType->controllerTagName#methodName eventType2->controllerTagName#methodName2 ..."`
|
|
59
59
|
|
|
60
60
|
- **eventType**: The name of the DOM event (e.g., click, input, custom-event).
|
|
61
61
|
|
|
@@ -63,15 +63,14 @@ on that controller instance. They are defined using the data-action attribute.
|
|
|
63
63
|
my-greeter). This must match the tag name of the controller component where the
|
|
64
64
|
data-action attribute is placed.
|
|
65
65
|
|
|
66
|
-
- **methodName**: The name of the method to call on the controller instance.
|
|
67
|
-
omitted (e.g., click:my-greeter), it defaults to handleEvent.
|
|
66
|
+
- **methodName**: The name of the method to call on the controller instance.
|
|
68
67
|
|
|
69
68
|
### Registration
|
|
70
69
|
|
|
71
|
-
Controllers are registered as custom elements using the
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
my-example-controller).
|
|
70
|
+
Controllers are registered as custom elements using the `@customElement`
|
|
71
|
+
decorator from `lit/decorators.js`. This decorator requires you to explicitly
|
|
72
|
+
provide the custom element's tag name (e.g.,
|
|
73
|
+
`@customElement("my-example-controller")`).
|
|
75
74
|
|
|
76
75
|
### Targets
|
|
77
76
|
|
|
@@ -85,10 +84,11 @@ using the query and queryAll helper functions.
|
|
|
85
84
|
// dialog-trigger.ts
|
|
86
85
|
|
|
87
86
|
```typescript
|
|
88
|
-
import {
|
|
87
|
+
import {customElement} from "lit/decorators.js";
|
|
88
|
+
import {Controller, target} from "@mypolis.eu/action-controller";
|
|
89
89
|
import type {SlDialog} from "@shoelace-style/shoelace";
|
|
90
90
|
|
|
91
|
-
@
|
|
91
|
+
@customElement("dialog-trigger")
|
|
92
92
|
export class DialogTrigger extends Controller {
|
|
93
93
|
@target dialog!: SlDialog;
|
|
94
94
|
|
|
@@ -115,7 +115,7 @@ export class DialogTrigger extends Controller {
|
|
|
115
115
|
<sl-button
|
|
116
116
|
size="small"
|
|
117
117
|
title="Cancelar"
|
|
118
|
-
data-action="click
|
|
118
|
+
data-action="click->dialog-trigger#close"
|
|
119
119
|
circle
|
|
120
120
|
>
|
|
121
121
|
<sl-icon
|
|
@@ -131,7 +131,7 @@ export class DialogTrigger extends Controller {
|
|
|
131
131
|
</p>
|
|
132
132
|
</div>
|
|
133
133
|
<button
|
|
134
|
-
data-action="click
|
|
134
|
+
data-action="click->dialog-trigger#close"
|
|
135
135
|
style="width: 100%"
|
|
136
136
|
>
|
|
137
137
|
Fechar
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AAIxC,OAAO,EAAC,MAAM,EAAE,OAAO,EAAC,MAAM,SAAS,CAAC;AAExC,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AAIxC,OAAO,EAAC,MAAM,EAAE,OAAO,EAAC,MAAM,SAAS,CAAC;AAExC,OAAO,EAAC,eAAe,EAAC,MAAM,cAAc,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AAExC,OAAO,EAAC,KAAK,MAAM,EAAC,MAAM,UAAU,CAAC;AAErC,OAAO,EAAC,MAAM,EAAE,OAAO,EAAC,MAAM,SAAS,CAAC;AAExC,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AAExC,OAAO,EAAC,KAAK,MAAM,EAAC,MAAM,UAAU,CAAC;AAErC,OAAO,EAAC,MAAM,EAAE,OAAO,EAAC,MAAM,SAAS,CAAC;AAExC,OAAO,EAAC,eAAe,EAAC,MAAM,cAAc,CAAC"}
|