@itrocks/list 0.0.22 → 0.1.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.
Files changed (2) hide show
  1. package/build.js +18 -25
  2. package/package.json +1 -1
package/build.js CHANGED
@@ -3,37 +3,30 @@ import { TableFeed } from '../table/feed.js';
3
3
  import { TableFreeze } from '../table/freeze.js';
4
4
  import { TableFreezeInheritBackground } from '../table/freeze/inherit-background.js';
5
5
  import { TableFreezeInheritBorder } from '../table/freeze/inherit-border.js';
6
+ import { TableLink } from '../table/link.js';
6
7
  import { tableByElement } from '../table/table.js';
7
8
  import { xTargetCall } from '../xtarget/xtarget.js';
9
+ const tableLink = new TableLink({
10
+ call: url => xTargetCall(url, 'main'),
11
+ href: 'action',
12
+ id: (element) => {
13
+ const input = element.closest('tr')?.querySelector(':scope > th.select > input[name=id]');
14
+ if (input)
15
+ return { element: input, value: input.value };
16
+ }
17
+ });
8
18
  build('article[data-action="list"] > form > table.objects', element => {
9
19
  tableByElement(element, {
10
- plugins: [TableFeed, TableFreeze, TableFreezeInheritBackground, TableFreezeInheritBorder]
20
+ plugins: [TableFeed, TableFreeze, TableFreezeInheritBackground, TableFreezeInheritBorder, tableLink]
11
21
  });
12
- element.querySelector(':scope > tbody')?.addEventListener('click', async (event) => {
13
- const td = event.target;
14
- if (!(td instanceof HTMLTableCellElement))
15
- return;
16
- const tr = td.closest('tr');
17
- if (!tr)
18
- return;
19
- let select = td.closest('.select');
20
- if (select) {
21
- const input = select.querySelector('input');
22
- if (!input)
23
- return;
24
- input.click();
25
- input.focus();
26
- return;
27
- }
28
- const checkBox = tr.querySelector(':scope > th.select > input[name=id]');
29
- if (!checkBox)
30
- return;
31
- const id = checkBox.value;
32
- if (!id)
22
+ element.addEventListener('click', event => {
23
+ const element = event.target;
24
+ if (!(element instanceof HTMLTableCellElement) || !element.classList.contains('select'))
33
25
  return;
34
- const form = tr.closest('form');
35
- if (!form)
26
+ const input = element.querySelector('input[type=checkbox]');
27
+ if (!input)
36
28
  return;
37
- return xTargetCall(form.getAttribute('action') + '/' + id, 'main');
29
+ input.click();
30
+ input.focus();
38
31
  });
39
32
  });
package/package.json CHANGED
@@ -67,5 +67,5 @@
67
67
  "build:front": "tsc -p esm/tsconfig.json && ../prepare-module/prepare-module.js esm"
68
68
  },
69
69
  "types": "./cjs/list.d.ts",
70
- "version": "0.0.22"
70
+ "version": "0.1.0"
71
71
  }