Skip to content

Commit dcf2f80

Browse files
committed
Combine index and task-lists-element files
1 parent b2e891f commit dcf2f80

File tree

8 files changed

+90
-94
lines changed

8 files changed

+90
-94
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import '@github/task-lists-element'
2121
With a script tag:
2222

2323
```html
24-
<script type="module" src="./node_modules/@github/task-lists-element/dist/index.js">
24+
<script type="module" src="./node_modules/@github/task-lists-element/dist/task-lists-element.js">
2525
```
2626
2727
### Markup

examples/index.html

Lines changed: 68 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,74 @@
1-
<!doctype html>
1+
<!DOCTYPE html>
22
<html lang="en">
3-
<head>
4-
<meta charset="utf-8">
5-
<!-- <script type="module" src="../dist/index.js"></script> -->
6-
<script type="module" src="https://unpkg.com/@github/task-lists-element@latest"></script>
7-
<title>task-lists-element demo</title>
8-
</head>
9-
<body>
10-
<task-lists sortable>
11-
<ul class="contains-task-list">
12-
<li class="task-list-item">
13-
<label>
14-
<input type="checkbox" class="task-list-item-checkbox">
15-
Hubot
16-
</label>
17-
</li>
18-
<li class="task-list-item">
19-
<label>
20-
<input type="checkbox" class="task-list-item-checkbox">
21-
Bender
22-
</label>
23-
</li>
24-
</ul>
3+
<head>
4+
<meta charset="utf-8" />
5+
<!-- <script type="module" src="../dist/task-lists-element.js"></script> -->
6+
<script type="module" src="https://unpkg.com/@github/task-lists-element@latest"></script>
7+
<title>task-lists-element demo</title>
8+
</head>
9+
<body>
10+
<task-lists sortable>
11+
<ul class="contains-task-list">
12+
<li class="task-list-item">
13+
<label>
14+
<input type="checkbox" class="task-list-item-checkbox" />
15+
Hubot
16+
</label>
17+
</li>
18+
<li class="task-list-item">
19+
<label>
20+
<input type="checkbox" class="task-list-item-checkbox" />
21+
Bender
22+
</label>
23+
</li>
24+
</ul>
2525

26-
<ul>
27-
<li>
28-
Nested
26+
<ul>
27+
<li>
28+
Nested
2929

30-
<ul class="contains-task-list">
31-
<li class="task-list-item">
32-
<label>
33-
<input type="checkbox" class="task-list-item-checkbox">
34-
WALL-E
35-
</label>
36-
</li>
37-
<li class="task-list-item">
38-
<label>
39-
<input type="checkbox" class="task-list-item-checkbox">
40-
R2-D2
41-
</label>
30+
<ul class="contains-task-list">
31+
<li class="task-list-item">
32+
<label>
33+
<input type="checkbox" class="task-list-item-checkbox" />
34+
WALL-E
35+
</label>
36+
</li>
37+
<li class="task-list-item">
38+
<label>
39+
<input type="checkbox" class="task-list-item-checkbox" />
40+
R2-D2
41+
</label>
4242

43-
<ul class="contains-task-list">
44-
<li class="task-list-item">
45-
<label>
46-
<input type="checkbox" class="task-list-item-checkbox">
47-
Baymax
48-
</label>
49-
</li>
50-
</ul>
51-
</li>
52-
<li class="task-list-item">
53-
<label>
54-
<input type="checkbox" class="task-list-item-checkbox">
55-
BB-8
56-
</label>
57-
</li>
58-
</ul>
59-
</li>
60-
</ul>
61-
</task-lists>
62-
<pre class="events"></pre>
63-
<script type="text/javascript">
64-
const events = document.querySelector('.events')
65-
document.addEventListener('task-lists-check', function(event) {
66-
events.append(`task-lists-check - checked: ${event.detail.checked}, position: ${event.detail.position}\n`)
67-
})
43+
<ul class="contains-task-list">
44+
<li class="task-list-item">
45+
<label>
46+
<input type="checkbox" class="task-list-item-checkbox" />
47+
Baymax
48+
</label>
49+
</li>
50+
</ul>
51+
</li>
52+
<li class="task-list-item">
53+
<label>
54+
<input type="checkbox" class="task-list-item-checkbox" />
55+
BB-8
56+
</label>
57+
</li>
58+
</ul>
59+
</li>
60+
</ul>
61+
</task-lists>
62+
<pre class="events"></pre>
63+
<script type="text/javascript">
64+
const events = document.querySelector('.events')
65+
document.addEventListener('task-lists-check', function (event) {
66+
events.append(`task-lists-check - checked: ${event.detail.checked}, position: ${event.detail.position}\n`)
67+
})
6868

69-
document.addEventListener('task-lists-move', function(event) {
70-
events.append(`task-lists-move - from: ${event.detail.src}, to: ${event.detail.dst}\n`)
71-
})
72-
</script>
73-
</body>
69+
document.addEventListener('task-lists-move', function (event) {
70+
events.append(`task-lists-move - from: ${event.detail.src}, to: ${event.detail.dst}\n`)
71+
})
72+
</script>
73+
</body>
7474
</html>

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"version": "2.0.0",
44
"description": "Drag and drop task list items.",
55
"repository": "github/task-lists-element",
6-
"main": "dist/index.js",
7-
"module": "dist/index.js",
6+
"main": "dist/task-lists-element.js",
7+
"module": "dist/task-lists-element.js",
88
"type": "module",
9-
"types": "dist/index.d.ts",
9+
"types": "dist/task-lists-element.d.ts",
1010
"scripts": {
1111
"clean": "rm -rf dist",
1212
"lint": "eslint . --ext .js,.ts && tsc --noEmit",

rollup.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pkg from './package.json'
22

33
export default {
4-
input: 'dist/index.js',
4+
input: 'dist/task-lists-element.js',
55
output: [
66
{
77
file: pkg['module'],

src/index.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/task-lists-element.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,3 +244,17 @@ function onHandleMouseOut(event: MouseEvent) {
244244

245245
item.setAttribute('draggable', 'false')
246246
}
247+
248+
declare global {
249+
interface Window {
250+
TaskListsElement: typeof TaskListsElement
251+
}
252+
interface HTMLElementTagNameMap {
253+
'task-lists': TaskListsElement
254+
}
255+
}
256+
257+
if (!window.customElements.get('task-lists')) {
258+
window.TaskListsElement = TaskListsElement
259+
window.customElements.define('task-lists', TaskListsElement)
260+
}

test/karma.config.cjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
module.exports = function(config) {
1+
module.exports = function (config) {
22
config.set({
33
frameworks: ['mocha', 'chai'],
4-
files: [{pattern: '../dist/index.js', type: 'module'}, 'test.js'],
4+
files: [{pattern: '../dist/task-lists-element.js', type: 'module'}, 'test.js'],
55
reporters: ['mocha'],
66
port: 9876,
77
colors: true,

tsconfig.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,5 @@
77
"outDir": "dist",
88
"removeComments": true
99
},
10-
"files": [
11-
"src/index.ts"
12-
]
10+
"files": ["src/task-lists-element.ts"]
1311
}

0 commit comments

Comments
 (0)