@mypolis.eu/action-controller 0.1.0 → 2.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/dist/action.js +13 -0
- package/dist/action.js.map +1 -0
- package/dist/action.test.js +31 -0
- package/dist/action.test.js.map +1 -0
- package/dist/attributes.test.js +7 -7
- package/dist/attributes.test.js.map +1 -1
- package/dist/controller.js +48 -61
- package/dist/controller.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/query.js +29 -54
- package/dist/query.js.map +1 -1
- package/dist/types/action.d.ts +7 -0
- package/dist/types/action.d.ts.map +1 -0
- package/dist/types/action.test.d.ts +2 -0
- package/dist/types/action.test.d.ts.map +1 -0
- package/dist/types/controller.d.ts +2 -5
- package/dist/types/controller.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/query.d.ts +11 -5
- package/dist/types/query.d.ts.map +1 -1
- package/package.json +10 -5
package/dist/action.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const pattern = /(.+?)->(.+?)#(.+)/;
|
|
2
|
+
export function parseActions(action) {
|
|
3
|
+
const rawActions = action.split(/\s+/).filter((s) => s.length > 0);
|
|
4
|
+
return rawActions.map((str) => {
|
|
5
|
+
const match = str.match(pattern);
|
|
6
|
+
if (!match) {
|
|
7
|
+
throw new Error(`invalid action format: ${str}`);
|
|
8
|
+
}
|
|
9
|
+
const [_, event, controller, method] = match;
|
|
10
|
+
return { event, controller, method };
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action.js","sourceRoot":"","sources":["../src/action.ts"],"names":[],"mappings":"AAMA,MAAM,OAAO,GAAG,mBAAmB,CAAC;AAEpC,MAAM,UAAU,YAAY,CAAC,MAAc;IAC1C,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACnE,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;QAC7B,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACjC,IAAI,CAAC,KAAK,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,0BAA0B,GAAG,EAAE,CAAC,CAAC;QAClD,CAAC;QACD,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,CAAC,GAAG,KAAK,CAAC;QAC7C,OAAO,EAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { assert } from "@open-wc/testing";
|
|
2
|
+
import { parseActions } from "./action";
|
|
3
|
+
describe("parseActions", () => {
|
|
4
|
+
it("can parse an action from a string", () => {
|
|
5
|
+
const str = "htmx:beforeRequest->loading-state#start";
|
|
6
|
+
const actions = parseActions(str);
|
|
7
|
+
assert.strictEqual(actions[0].event, "htmx:beforeRequest");
|
|
8
|
+
assert.strictEqual(actions[0].controller, "loading-state");
|
|
9
|
+
assert.strictEqual(actions[0].method, "start");
|
|
10
|
+
});
|
|
11
|
+
it("can parse multiple actions from a string", () => {
|
|
12
|
+
const str = `
|
|
13
|
+
htmx:beforeRequest->loading-state#start
|
|
14
|
+
htmx:afterRequest->loading-state#stop
|
|
15
|
+
`;
|
|
16
|
+
const actions = parseActions(str);
|
|
17
|
+
assert.strictEqual(actions[0].event, "htmx:beforeRequest");
|
|
18
|
+
assert.strictEqual(actions[0].controller, "loading-state");
|
|
19
|
+
assert.strictEqual(actions[0].method, "start");
|
|
20
|
+
assert.strictEqual(actions[1].event, "htmx:afterRequest");
|
|
21
|
+
assert.strictEqual(actions[1].controller, "loading-state");
|
|
22
|
+
assert.strictEqual(actions[1].method, "stop");
|
|
23
|
+
});
|
|
24
|
+
it("throws an error if action if not valid", () => {
|
|
25
|
+
const badStrs = ["foo", "->loading-state#start", "foo->bar", "foo#bar"];
|
|
26
|
+
for (const str of badStrs) {
|
|
27
|
+
assert.throws(() => parseActions(str), "invalid action format: " + str);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=action.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action.test.js","sourceRoot":"","sources":["../src/action.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAC,YAAY,EAAC,MAAM,UAAU,CAAC;AAEtC,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC7B,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;QAC5C,MAAM,GAAG,GAAG,yCAAyC,CAAC;QAEtD,MAAM,OAAO,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;QAElC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,oBAAoB,CAAC,CAAC;QAC3D,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;QAC3D,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0CAA0C,EAAE,GAAG,EAAE;QACnD,MAAM,GAAG,GAAG;;;GAGX,CAAC;QAEF,MAAM,OAAO,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;QAElC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,oBAAoB,CAAC,CAAC;QAC3D,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;QAC3D,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAE/C,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,mBAAmB,CAAC,CAAC;QAC1D,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;QAC3D,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wCAAwC,EAAE,GAAG,EAAE;QACjD,MAAM,OAAO,GAAG,CAAC,KAAK,EAAE,uBAAuB,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;QACxE,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;YAC3B,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,yBAAyB,GAAG,GAAG,CAAC,CAAC;QACzE,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
package/dist/attributes.test.js
CHANGED
|
@@ -5,11 +5,11 @@ describe("parseAttributes", () => {
|
|
|
5
5
|
beforeEach(() => {
|
|
6
6
|
element = document.createElement("div");
|
|
7
7
|
});
|
|
8
|
-
|
|
8
|
+
it("parses string attributes", () => {
|
|
9
9
|
element.setAttribute("data-url", "/products");
|
|
10
10
|
assert.deepStrictEqual(parseAttributes(element), { url: "/products" });
|
|
11
11
|
});
|
|
12
|
-
|
|
12
|
+
it("parses boolean attributes", () => {
|
|
13
13
|
element.setAttribute("data-active", "true");
|
|
14
14
|
element.setAttribute("data-disabled", "false");
|
|
15
15
|
assert.deepStrictEqual(parseAttributes(element), {
|
|
@@ -17,23 +17,23 @@ describe("parseAttributes", () => {
|
|
|
17
17
|
disabled: false
|
|
18
18
|
});
|
|
19
19
|
});
|
|
20
|
-
|
|
20
|
+
it("parses number attributes", () => {
|
|
21
21
|
element.setAttribute("data-count", "42");
|
|
22
22
|
assert.deepStrictEqual(parseAttributes(element), { count: 42 });
|
|
23
23
|
});
|
|
24
|
-
|
|
24
|
+
it("parses array attributes", () => {
|
|
25
25
|
element.setAttribute("data-tags", "one,two,three");
|
|
26
26
|
assert.deepStrictEqual(parseAttributes(element), {
|
|
27
27
|
tags: ["one", "two", "three"]
|
|
28
28
|
});
|
|
29
29
|
});
|
|
30
|
-
|
|
30
|
+
it("parses JSON attributes", () => {
|
|
31
31
|
element.setAttribute("data-config", '{"foo": "bar", "num": 123}');
|
|
32
32
|
assert.deepStrictEqual(parseAttributes(element), {
|
|
33
33
|
config: { foo: "bar", num: 123 }
|
|
34
34
|
});
|
|
35
35
|
});
|
|
36
|
-
|
|
36
|
+
it("handles kebab-case attributes", () => {
|
|
37
37
|
element.setAttribute("data-user-name", "John");
|
|
38
38
|
element.setAttribute("data-last-login-date", "2024-01-21");
|
|
39
39
|
assert.deepStrictEqual(parseAttributes(element), {
|
|
@@ -41,7 +41,7 @@ describe("parseAttributes", () => {
|
|
|
41
41
|
lastLoginDate: "2024-01-21"
|
|
42
42
|
});
|
|
43
43
|
});
|
|
44
|
-
|
|
44
|
+
it("ignores non-data attributes", () => {
|
|
45
45
|
element.setAttribute("id", "test");
|
|
46
46
|
element.setAttribute("data-name", "John");
|
|
47
47
|
assert.deepStrictEqual(parseAttributes(element), { name: "John" });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attributes.test.js","sourceRoot":"","sources":["../src/attributes.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAC,eAAe,EAAC,MAAM,cAAc,CAAC;AAE7C,QAA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AAC,CAAC;IAClE,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
package/dist/controller.js
CHANGED
|
@@ -9,31 +9,34 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
10
10
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
11
|
};
|
|
12
|
-
var _Controller_instances, _Controller_handlers, _Controller_observer,
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
12
|
+
var _Controller_instances, _Controller_handlers, _Controller_observer, _Controller_handleAction, _Controller_listenActions, _Controller_updateQueries, _Controller_cleanupActions;
|
|
13
|
+
import { html, LitElement } from "lit";
|
|
14
|
+
import { parseActions } from "./action";
|
|
15
15
|
import { parseAttributes } from "./attributes";
|
|
16
|
+
import { findElements, targetKey } from "./query";
|
|
16
17
|
export class Controller extends LitElement {
|
|
17
18
|
constructor() {
|
|
18
19
|
super();
|
|
19
20
|
_Controller_instances.add(this);
|
|
20
|
-
_Controller_handlers.set(this, new
|
|
21
|
+
_Controller_handlers.set(this, new Map());
|
|
21
22
|
_Controller_observer.set(this, void 0);
|
|
22
23
|
__classPrivateFieldSet(this, _Controller_observer, new MutationObserver(() => {
|
|
23
24
|
__classPrivateFieldGet(this, _Controller_instances, "m", _Controller_cleanupActions).call(this); // Clean up existing listeners
|
|
24
25
|
__classPrivateFieldGet(this, _Controller_instances, "m", _Controller_listenActions).call(this); // Add new listeners
|
|
26
|
+
__classPrivateFieldGet(this, _Controller_instances, "m", _Controller_updateQueries).call(this); // Refresh the queries
|
|
25
27
|
}), "f");
|
|
26
28
|
}
|
|
27
29
|
connectedCallback() {
|
|
28
30
|
super.connectedCallback();
|
|
29
31
|
// Initial setup
|
|
32
|
+
__classPrivateFieldGet(this, _Controller_instances, "m", _Controller_updateQueries).call(this);
|
|
30
33
|
__classPrivateFieldGet(this, _Controller_instances, "m", _Controller_listenActions).call(this);
|
|
31
34
|
// Start observing changes
|
|
32
35
|
__classPrivateFieldGet(this, _Controller_observer, "f").observe(this, {
|
|
33
36
|
childList: true,
|
|
34
37
|
subtree: true,
|
|
35
38
|
attributes: true,
|
|
36
|
-
attributeFilter: ["data-action", "data-
|
|
39
|
+
attributeFilter: ["data-action", "data-target"]
|
|
37
40
|
});
|
|
38
41
|
}
|
|
39
42
|
disconnectedCallback() {
|
|
@@ -58,44 +61,7 @@ export class Controller extends LitElement {
|
|
|
58
61
|
return parseAttributes(target);
|
|
59
62
|
}
|
|
60
63
|
}
|
|
61
|
-
_Controller_handlers = new WeakMap(), _Controller_observer = new WeakMap(), _Controller_instances = new WeakSet(),
|
|
62
|
-
if (!actionString)
|
|
63
|
-
return [];
|
|
64
|
-
return actionString
|
|
65
|
-
.trim()
|
|
66
|
-
.split(/\s+/) // Split multiple actions defined in the string
|
|
67
|
-
.map((action) => {
|
|
68
|
-
// 1. Find the method separator first
|
|
69
|
-
const hashIndex = action.indexOf("#");
|
|
70
|
-
let eventAndControllerPart;
|
|
71
|
-
let method;
|
|
72
|
-
if (hashIndex === -1) {
|
|
73
|
-
// No '#' found, method defaults to 'handleEvent'
|
|
74
|
-
eventAndControllerPart = action;
|
|
75
|
-
method = "handleEvent";
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
eventAndControllerPart = action.substring(0, hashIndex);
|
|
79
|
-
method = action.substring(hashIndex + 1) || "handleEvent";
|
|
80
|
-
}
|
|
81
|
-
// 2. Find the LAST colon in the remaining part to separate event type from controller
|
|
82
|
-
const lastColonIndex = eventAndControllerPart.lastIndexOf(":");
|
|
83
|
-
// Check if a colon exists and separates non-empty parts
|
|
84
|
-
if (lastColonIndex <= 0 || lastColonIndex === eventAndControllerPart.length - 1) {
|
|
85
|
-
console.warn(`[Controller] Invalid action format: Could not determine event and controller in "${action}". Skipping.`);
|
|
86
|
-
return null; // Invalid format
|
|
87
|
-
}
|
|
88
|
-
const eventType = eventAndControllerPart.substring(0, lastColonIndex);
|
|
89
|
-
const controller = eventAndControllerPart.substring(lastColonIndex + 1);
|
|
90
|
-
// Final validation
|
|
91
|
-
if (!eventType || !controller || !method) {
|
|
92
|
-
console.warn(`[Controller] Invalid action format: Empty parts detected in "${action}". Skipping.`);
|
|
93
|
-
return null;
|
|
94
|
-
}
|
|
95
|
-
return { type: eventType, controller, method };
|
|
96
|
-
})
|
|
97
|
-
.filter((action) => action !== null);
|
|
98
|
-
}, _Controller_handleAction = function _Controller_handleAction(event, element, action) {
|
|
64
|
+
_Controller_handlers = new WeakMap(), _Controller_observer = new WeakMap(), _Controller_instances = new WeakSet(), _Controller_handleAction = function _Controller_handleAction(event, element, action) {
|
|
99
65
|
// look for the nearest controller matching the action's controller name
|
|
100
66
|
const controller = element.closest(action.controller);
|
|
101
67
|
if (!controller) {
|
|
@@ -111,35 +77,56 @@ _Controller_handlers = new WeakMap(), _Controller_observer = new WeakMap(), _Con
|
|
|
111
77
|
method.call(controller, event);
|
|
112
78
|
}, _Controller_listenActions = function _Controller_listenActions() {
|
|
113
79
|
findElements(this, "[data-action]").forEach((element) => {
|
|
114
|
-
const
|
|
115
|
-
if (!
|
|
80
|
+
const str = element.dataset.action;
|
|
81
|
+
if (!str)
|
|
116
82
|
return;
|
|
117
83
|
const handlers = [];
|
|
118
|
-
for (const action of
|
|
84
|
+
for (const action of parseActions(str)) {
|
|
119
85
|
if (action.controller !== this.tagName.toLowerCase())
|
|
120
86
|
continue;
|
|
121
87
|
const handler = (event) => __classPrivateFieldGet(this, _Controller_instances, "m", _Controller_handleAction).call(this, event, element, action);
|
|
122
|
-
element.addEventListener(action.
|
|
123
|
-
handlers.push(handler);
|
|
88
|
+
element.addEventListener(action.event, handler);
|
|
89
|
+
handlers.push({ event: action.event, handler });
|
|
124
90
|
}
|
|
125
91
|
if (handlers.length) {
|
|
126
92
|
__classPrivateFieldGet(this, _Controller_handlers, "f").set(element, handlers);
|
|
127
93
|
}
|
|
128
94
|
});
|
|
95
|
+
}, _Controller_updateQueries = function _Controller_updateQueries() {
|
|
96
|
+
if (!this[targetKey] || this[targetKey].length === 0)
|
|
97
|
+
return;
|
|
98
|
+
let needsUpdate = false;
|
|
99
|
+
for (const target of this[targetKey]) {
|
|
100
|
+
const propertyKey = target.propertyKey;
|
|
101
|
+
const nextElement = target.query;
|
|
102
|
+
const current = this[propertyKey];
|
|
103
|
+
let hasChanged = false;
|
|
104
|
+
if (Array.isArray(nextElement)) {
|
|
105
|
+
const currentElements = (current || []);
|
|
106
|
+
if (currentElements.length !== nextElement.length ||
|
|
107
|
+
nextElement.some((el) => !currentElements.includes(el))) {
|
|
108
|
+
hasChanged = true;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
if (current !== nextElement) {
|
|
113
|
+
hasChanged = true;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (hasChanged) {
|
|
117
|
+
this[propertyKey] = nextElement;
|
|
118
|
+
needsUpdate = true;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (needsUpdate) {
|
|
122
|
+
this.requestUpdate();
|
|
123
|
+
}
|
|
129
124
|
}, _Controller_cleanupActions = function _Controller_cleanupActions() {
|
|
130
|
-
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
return;
|
|
134
|
-
const actionString = element.dataset.action;
|
|
135
|
-
if (!actionString)
|
|
136
|
-
return;
|
|
137
|
-
for (const action of __classPrivateFieldGet(this, _Controller_instances, "m", _Controller_parseActions).call(this, actionString)) {
|
|
138
|
-
handlers.forEach((handler) => {
|
|
139
|
-
element.removeEventListener(action.type, handler);
|
|
140
|
-
});
|
|
125
|
+
for (const [element, handlers] of __classPrivateFieldGet(this, _Controller_handlers, "f").entries()) {
|
|
126
|
+
for (const { event, handler } of handlers) {
|
|
127
|
+
element.removeEventListener(event, handler);
|
|
141
128
|
}
|
|
142
|
-
}
|
|
143
|
-
|
|
129
|
+
}
|
|
130
|
+
__classPrivateFieldGet(this, _Controller_handlers, "f").clear();
|
|
144
131
|
};
|
|
145
132
|
//# sourceMappingURL=controller.js.map
|
package/dist/controller.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../src/controller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../src/controller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAC,IAAI,EAAE,UAAU,EAAC,MAAM,KAAK,CAAC;AACrC,OAAO,EAAC,YAAY,EAAc,MAAM,UAAU,CAAC;AACnD,OAAO,EAAC,eAAe,EAAC,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAC,YAAY,EAAU,SAAS,EAAC,MAAM,SAAS,CAAC;AAIxD,MAAM,OAAO,UAAW,SAAQ,UAAU;IAMzC;QACC,KAAK,EAAE,CAAC;;QANT,+BAAY,IAAI,GAAG,EAAsB,EAAC;QAC1C,uCAA4B;QAM3B,uBAAA,IAAI,wBAAa,IAAI,gBAAgB,CAAC,GAAG,EAAE;YAC1C,uBAAA,IAAI,yDAAgB,MAApB,IAAI,CAAkB,CAAC,CAAC,8BAA8B;YACtD,uBAAA,IAAI,wDAAe,MAAnB,IAAI,CAAiB,CAAC,CAAC,oBAAoB;YAC3C,uBAAA,IAAI,wDAAe,MAAnB,IAAI,CAAiB,CAAC,CAAC,sBAAsB;QAC9C,CAAC,CAAC,MAAA,CAAC;IACJ,CAAC;IAED,iBAAiB;QAChB,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAE1B,gBAAgB;QAChB,uBAAA,IAAI,wDAAe,MAAnB,IAAI,CAAiB,CAAC;QACtB,uBAAA,IAAI,wDAAe,MAAnB,IAAI,CAAiB,CAAC;QAEtB,0BAA0B;QAC1B,uBAAA,IAAI,4BAAU,CAAC,OAAO,CAAC,IAAI,EAA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, targets } from "./query";
|
|
3
3
|
export { register } from "./register";
|
|
4
4
|
export { parseAttributes } from "./attributes";
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
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,
|
|
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,QAAQ,EAAC,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAC,eAAe,EAAC,MAAM,cAAc,CAAC"}
|
package/dist/query.js
CHANGED
|
@@ -21,63 +21,38 @@ export function findElements(controller, query) {
|
|
|
21
21
|
}
|
|
22
22
|
return elements;
|
|
23
23
|
}
|
|
24
|
-
export
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
export function query(target, propertyKey) {
|
|
40
|
-
const ctor = target.constructor;
|
|
41
|
-
ctor.addInitializer((instance) => {
|
|
42
|
-
const getter = function () {
|
|
43
|
-
const controller = this.tagName.toLowerCase();
|
|
44
|
-
const query = `[data-query~="${controller}.${propertyKey}"]`;
|
|
45
|
-
return findElements(this, query)?.[0];
|
|
46
|
-
};
|
|
47
|
-
Object.defineProperty(instance, propertyKey, {
|
|
48
|
-
get: getter,
|
|
49
|
-
enumerable: true,
|
|
50
|
-
configurable: true,
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
export function target(target, propertyKey) {
|
|
55
|
-
const ctor = target.constructor;
|
|
56
|
-
ctor.addInitializer((instance) => {
|
|
57
|
-
const getter = function () {
|
|
58
|
-
const controller = this.tagName.toLowerCase();
|
|
59
|
-
const query = `[data-target~="${controller}.${propertyKey}"]`;
|
|
60
|
-
return findElements(this, query)?.[0];
|
|
61
|
-
};
|
|
62
|
-
Object.defineProperty(instance, propertyKey, {
|
|
63
|
-
get: getter,
|
|
64
|
-
enumerable: true,
|
|
65
|
-
configurable: true,
|
|
24
|
+
export const targetKey = Symbol("targets");
|
|
25
|
+
export function target(_value, context) {
|
|
26
|
+
const propertyKey = context.name;
|
|
27
|
+
context.addInitializer(function () {
|
|
28
|
+
const instance = this;
|
|
29
|
+
if (!instance[targetKey]) {
|
|
30
|
+
instance[targetKey] = [];
|
|
31
|
+
}
|
|
32
|
+
instance[targetKey].push({
|
|
33
|
+
propertyKey,
|
|
34
|
+
get query() {
|
|
35
|
+
const controller = instance.tagName.toLowerCase();
|
|
36
|
+
const query = `[data-target~="${controller}.${propertyKey}"]`;
|
|
37
|
+
return findElements(instance, query)?.[0];
|
|
38
|
+
}
|
|
66
39
|
});
|
|
67
40
|
});
|
|
68
41
|
}
|
|
69
|
-
export function targets(
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
get
|
|
79
|
-
|
|
80
|
-
|
|
42
|
+
export function targets(_value, context) {
|
|
43
|
+
const propertyKey = context.name;
|
|
44
|
+
context.addInitializer(function () {
|
|
45
|
+
const instance = this;
|
|
46
|
+
if (!instance[targetKey]) {
|
|
47
|
+
instance[targetKey] = [];
|
|
48
|
+
}
|
|
49
|
+
instance[targetKey].push({
|
|
50
|
+
propertyKey,
|
|
51
|
+
get query() {
|
|
52
|
+
const controller = instance.tagName.toLowerCase();
|
|
53
|
+
const query = `[data-target~="${controller}.${propertyKey}"]`;
|
|
54
|
+
return findElements(instance, query);
|
|
55
|
+
}
|
|
81
56
|
});
|
|
82
57
|
});
|
|
83
58
|
}
|
package/dist/query.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.js","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,YAAY,CAAoB,UAAuB,EAAE,KAAa;IACrF,MAAM,GAAG,GAAG,UAAU,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;IAC7C,MAAM,QAAQ,GAAQ,EAAE,CAAC;IAEzB,oBAAoB;IACpB,IAAI,UAAU,CAAC,UAAU,EAAE,CAAC;QAC3B,MAAM,cAAc,GAAG,UAAU,CAAC,UAAU,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;QACrE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAChD,MAAM,EAAE,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC;YAC7B,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;gBACtB,QAAQ,CAAC,IAAI,CAAC,EAAO,CAAC,CAAC;YACxB,CAAC;QACF,CAAC;IACF,CAAC;IAED,mBAAmB;IACnB,MAAM,aAAa,GAAG,UAAU,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;IACzD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC/C,MAAM,EAAE,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;QAC5B,IAAI,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,UAAU,EAAE,CAAC;YACpC,QAAQ,CAAC,IAAI,CAAC,EAAO,CAAC,CAAC;QACxB,CAAC;IACF,CAAC;IAED,OAAO,QAAQ,CAAC;AACjB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CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;YACtC,CAAC;SACD,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../src/action.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GAAG;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CACf,CAAC;AAIF,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAUrD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action.test.d.ts","sourceRoot":"","sources":["../../src/action.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { LitElement } from "lit";
|
|
2
|
-
|
|
3
|
-
type: string;
|
|
4
|
-
controller: string;
|
|
5
|
-
method: string;
|
|
6
|
-
};
|
|
2
|
+
import { Target, targetKey } from "./query";
|
|
7
3
|
export declare class Controller extends LitElement {
|
|
8
4
|
#private;
|
|
5
|
+
[targetKey]?: Target[];
|
|
9
6
|
constructor();
|
|
10
7
|
connectedCallback(): void;
|
|
11
8
|
disconnectedCallback(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/controller.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,UAAU,EAAC,MAAM,KAAK,CAAC;AAGrC,OAAO,EAAe,MAAM,EAAE,SAAS,EAAC,MAAM,SAAS,CAAC;AAIxD,qBAAa,UAAW,SAAQ,UAAU;;IAIzC,CAAC,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC;;IAWvB,iBAAiB;IAgBjB,oBAAoB;IAQpB,MAAM;IAIN,WAAW,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC;CA+FrF"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export { Controller
|
|
2
|
-
export {
|
|
1
|
+
export { Controller } from "./controller";
|
|
2
|
+
export { type Action } from "./action";
|
|
3
|
+
export { target, targets } from "./query";
|
|
3
4
|
export { register } from "./register";
|
|
4
5
|
export { parseAttributes } from "./attributes";
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,
|
|
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,QAAQ,EAAC,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAC,eAAe,EAAC,MAAM,cAAc,CAAC"}
|
package/dist/types/query.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
export type Target<T extends Element = Element> = {
|
|
2
|
+
propertyKey: string;
|
|
3
|
+
query: T | T[];
|
|
4
|
+
};
|
|
2
5
|
export declare function findElements<T extends Element>(controller: HTMLElement, query: string): T[];
|
|
3
|
-
export declare
|
|
4
|
-
export declare function
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
export declare const targetKey: unique symbol;
|
|
7
|
+
export declare function target(_value: undefined, context: ClassFieldDecoratorContext & {
|
|
8
|
+
name: string;
|
|
9
|
+
}): void;
|
|
10
|
+
export declare function targets(_value: undefined, context: ClassFieldDecoratorContext & {
|
|
11
|
+
name: string;
|
|
12
|
+
}): void;
|
|
7
13
|
//# sourceMappingURL=query.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/query.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/query.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IAAI;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,CAAA;CAAC,CAAC;AAExF,wBAAgB,YAAY,CAAC,CAAC,SAAS,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,EAAE,CAyB3F;AAED,eAAO,MAAM,SAAS,eAAoB,CAAC;AAE3C,wBAAgB,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,0BAA0B,GAAG;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,QAgB7F;AAED,wBAAgB,OAAO,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,0BAA0B,GAAG;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,QAgB9F"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mypolis.eu/action-controller",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -24,14 +24,19 @@
|
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@open-wc/testing": "^4.0.0",
|
|
27
|
-
"@tsconfig/node22": "^22.0.2",
|
|
28
27
|
"@types/mocha": "^10.0.10",
|
|
29
28
|
"@web/dev-server-esbuild": "^1.0.4",
|
|
30
|
-
"@web/test-runner": "^0.20.
|
|
31
|
-
"
|
|
32
|
-
"
|
|
29
|
+
"@web/test-runner": "^0.20.2",
|
|
30
|
+
"lit": "^3.3.1",
|
|
31
|
+
"typescript": "^5.9.3",
|
|
32
|
+
"vite": "^7.2.2"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@tsconfig/node24": "^24.0.1"
|
|
33
36
|
},
|
|
34
37
|
"scripts": {
|
|
38
|
+
"dev": "vite ./playground",
|
|
39
|
+
"test": "wtr ./src/**/*.test.ts --node-resolve",
|
|
35
40
|
"build": "tsc -p tsconfig.json"
|
|
36
41
|
}
|
|
37
42
|
}
|