@digipair/skill-web-interact 0.2.1 → 0.2.4

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/index.esm.js ADDED
@@ -0,0 +1,29 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-unused-vars */ let DomService = class DomService {
2
+ async setAttribute(params, _pinsSettingsList, _context) {
3
+ const { selector, attribute, value } = params;
4
+ const element = document.querySelector(selector);
5
+ if (attribute === 'textContent') {
6
+ element.textContent = value;
7
+ } else if (attribute === 'value') {
8
+ element.value = value;
9
+ } else if (typeof value === 'string') {
10
+ element.setAttribute(attribute, value);
11
+ } else {
12
+ element['__' + attribute] = value;
13
+ element.requestUpdate();
14
+ }
15
+ return;
16
+ }
17
+ async dispatchEvent(params, _pinsSettingsList, _context) {
18
+ const { selector, name, detail } = params;
19
+ const element = document.querySelector(selector);
20
+ element.dispatchEvent(new CustomEvent(name, {
21
+ detail
22
+ }));
23
+ return;
24
+ }
25
+ };
26
+ const setAttribute = (params, pinsSettingsList, context)=>new DomService().setAttribute(params, pinsSettingsList, context);
27
+ const dispatchEvent = (params, pinsSettingsList, context)=>new DomService().dispatchEvent(params, pinsSettingsList, context);
28
+
29
+ export { dispatchEvent, setAttribute };
package/package.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "@digipair/skill-web-interact",
3
- "version": "0.2.1",
3
+ "version": "0.2.4",
4
4
  "dependencies": {},
5
- "type": "commonjs",
6
5
  "main": "./index.cjs.js",
7
- "module": "./index.js"
6
+ "module": "./index.esm.js"
8
7
  }
File without changes