@natachah/vanilla-frontend 0.1.16 → 0.1.17
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.
|
@@ -18,7 +18,7 @@ class DocLayout extends HTMLElement {
|
|
|
18
18
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-pin-angle" viewBox="0 0 16 16">
|
|
19
19
|
<path d="M9.828.722a.5.5 0 0 1 .354.146l4.95 4.95a.5.5 0 0 1 0 .707c-.48.48-1.072.588-1.503.588-.177 0-.335-.018-.46-.039l-3.134 3.134a6 6 0 0 1 .16 1.013c.046.702-.032 1.687-.72 2.375a.5.5 0 0 1-.707 0l-2.829-2.828-3.182 3.182c-.195.195-1.219.902-1.414.707s.512-1.22.707-1.414l3.182-3.182-2.828-2.829a.5.5 0 0 1 0-.707c.688-.688 1.673-.767 2.375-.72a6 6 0 0 1 1.013.16l3.134-3.133a3 3 0 0 1-.04-.461c0-.43.108-1.022.589-1.503a.5.5 0 0 1 .353-.146m.122 2.112v-.002zm0-.002v.002a.5.5 0 0 1-.122.51L6.293 6.878a.5.5 0 0 1-.511.12H5.78l-.014-.004a5 5 0 0 0-.288-.076 5 5 0 0 0-.765-.116c-.422-.028-.836.008-1.175.15l5.51 5.509c.141-.34.177-.753.149-1.175a5 5 0 0 0-.192-1.054l-.004-.013v-.001a.5.5 0 0 1 .12-.512l3.536-3.535a.5.5 0 0 1 .532-.115l.096.022c.087.017.208.034.344.034q.172.002.343-.04L9.927 2.028q-.042.172-.04.343a1.8 1.8 0 0 0 .062.46z"/>
|
|
20
20
|
</svg>
|
|
21
|
-
0.1.
|
|
21
|
+
0.1.17
|
|
22
22
|
</span>
|
|
23
23
|
</li>
|
|
24
24
|
<li>
|
package/js/_sortable.js
CHANGED
|
@@ -26,7 +26,6 @@ export default class Sortable extends BaseComponent {
|
|
|
26
26
|
super(el, options, 'sortable')
|
|
27
27
|
|
|
28
28
|
// Define the properties
|
|
29
|
-
this._items = null
|
|
30
29
|
this._withHandle = this._element.querySelector('[data-handle=sortable]') ? true : false
|
|
31
30
|
this._current = null
|
|
32
31
|
|
|
@@ -57,6 +56,17 @@ export default class Sortable extends BaseComponent {
|
|
|
57
56
|
|
|
58
57
|
}
|
|
59
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Get the list of the items
|
|
61
|
+
* This is used for the emmitEvent
|
|
62
|
+
*
|
|
63
|
+
* @return {object}
|
|
64
|
+
*/
|
|
65
|
+
get _items() {
|
|
66
|
+
return this._element.querySelectorAll('[draggable]')
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
60
70
|
/**
|
|
61
71
|
* Init the items and the event listeners
|
|
62
72
|
*
|
|
@@ -65,7 +75,7 @@ export default class Sortable extends BaseComponent {
|
|
|
65
75
|
#initEvents() {
|
|
66
76
|
|
|
67
77
|
// Get the items
|
|
68
|
-
this._items = this._element.querySelectorAll('[draggable]')
|
|
78
|
+
//this._items = this._element.querySelectorAll('[draggable]')
|
|
69
79
|
|
|
70
80
|
// Add the events
|
|
71
81
|
this._items.forEach(item => {
|
|
@@ -148,7 +158,7 @@ export default class Sortable extends BaseComponent {
|
|
|
148
158
|
item.setAttribute('aria-grabbed', true)
|
|
149
159
|
|
|
150
160
|
// Run custom event
|
|
151
|
-
this.emmitEvent('drag', { items: this.
|
|
161
|
+
this.emmitEvent('drag', { items: this._items, current: item })
|
|
152
162
|
|
|
153
163
|
}
|
|
154
164
|
|
|
@@ -208,7 +218,7 @@ export default class Sortable extends BaseComponent {
|
|
|
208
218
|
item.draggable = false
|
|
209
219
|
|
|
210
220
|
// Run custom event
|
|
211
|
-
this.emmitEvent('drop', { items: this.
|
|
221
|
+
this.emmitEvent('drop', { items: this._items, current: item })
|
|
212
222
|
|
|
213
223
|
}
|
|
214
224
|
|
|
@@ -29,9 +29,9 @@ beforeAll(() => {
|
|
|
29
29
|
|
|
30
30
|
document.body.innerHTML =
|
|
31
31
|
'<ul id="fakeList">' +
|
|
32
|
-
'<li id="first" draggable="false"
|
|
33
|
-
'<li draggable="false"
|
|
34
|
-
'<li draggable="false"
|
|
32
|
+
'<li id="first" draggable="false">One</li>' +
|
|
33
|
+
'<li draggable="false">Two</li>' +
|
|
34
|
+
'<li draggable="false">Three</li>' +
|
|
35
35
|
'</ul>' +
|
|
36
36
|
'<table id="fakeTable">' +
|
|
37
37
|
'<tr draggable="false"><td data-handle="sortable">DRAG</td><td>One</td></tr>' +
|
|
@@ -101,7 +101,7 @@ describe('Drag()', () => {
|
|
|
101
101
|
expect(eventSpy).not.toHaveBeenCalled()
|
|
102
102
|
fireEvent(fakeListItem, new MouseEvent('mousedown'))
|
|
103
103
|
fireEvent(fakeListItem, new MouseEvent('dragstart'))
|
|
104
|
-
expect(eventSpy).toHaveBeenCalledWith('drag', { current: fakeListItem, items: fakeListSortable.
|
|
104
|
+
expect(eventSpy).toHaveBeenCalledWith('drag', { current: fakeListItem, items: fakeListSortable._items })
|
|
105
105
|
})
|
|
106
106
|
|
|
107
107
|
})
|
|
@@ -119,7 +119,7 @@ describe('Drop()', () => {
|
|
|
119
119
|
fireEvent(fakeListItem, new MouseEvent('mousedown')) // First drag item
|
|
120
120
|
fireEvent(fakeListItem, new MouseEvent('dragstart')) // First drag item
|
|
121
121
|
fireEvent(fakeListItem, new MouseEvent('dragend'))
|
|
122
|
-
expect(eventSpy).toHaveBeenCalledWith('drop', { current: fakeListItem, items: fakeListSortable.
|
|
122
|
+
expect(eventSpy).toHaveBeenCalledWith('drop', { current: fakeListItem, items: fakeListSortable._items })
|
|
123
123
|
})
|
|
124
124
|
|
|
125
125
|
})
|
|
Binary file
|
package/package.json
CHANGED
|
Binary file
|