ember-sortable 4.0.0 → 4.0.2
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/CHANGELOG.md +25 -4
- package/MIGRATION_GUIDE_MODIFIERS.md +4 -4
- package/README.md +18 -20
- package/addon/modifiers/sortable-group.js +11 -11
- package/addon/modifiers/sortable-item.js +26 -19
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# ember-sortable changelog
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
4
5
|
|
|
6
|
+
## v4.0.2 (2022-10-06)
|
|
7
|
+
|
|
8
|
+
#### :bug: Bug Fix
|
|
9
|
+
* [#493](https://github.com/adopted-ember-addons/ember-sortable/pull/493) fix: Handle element in sortable item should be the most recent ([@nicolechung](https://github.com/nicolechung))
|
|
10
|
+
|
|
11
|
+
#### Committers: 1
|
|
12
|
+
- nicole chung ([@nicolechung](https://github.com/nicolechung))
|
|
5
13
|
|
|
14
|
+
## v4.0.1 (2022-10-03)
|
|
15
|
+
|
|
16
|
+
#### :memo: Documentation
|
|
17
|
+
* [#480](https://github.com/adopted-ember-addons/ember-sortable/pull/480) fix type in modifier migration doc ([@nlfurniss](https://github.com/nlfurniss))
|
|
18
|
+
* [#475](https://github.com/adopted-ember-addons/ember-sortable/pull/475) Update CHANGELOG.md ([@sandstrom](https://github.com/sandstrom))
|
|
19
|
+
|
|
20
|
+
#### :house: Internal
|
|
21
|
+
* [#487](https://github.com/adopted-ember-addons/ember-sortable/pull/487) Resolve `ember-modifier.no-args-property` deprecation warnings ([@bertdeblock](https://github.com/bertdeblock))
|
|
22
|
+
|
|
23
|
+
#### Committers: 3
|
|
24
|
+
- Bert De Block ([@bertdeblock](https://github.com/bertdeblock))
|
|
25
|
+
- Nathaniel Furniss ([@nlfurniss](https://github.com/nlfurniss))
|
|
26
|
+
- [@sandstrom](https://github.com/sandstrom)
|
|
6
27
|
|
|
7
28
|
## v4.0.0 (2022-05-16)
|
|
8
29
|
|
|
@@ -708,6 +729,6 @@ Must provide GITHUB_AUTH
|
|
|
708
729
|
|
|
709
730
|
- [#28](https://github.com/jgwhite/ember-sortable/pull/28) Add `model` attr to `sortable-group` [@ujamer](https://github.com/ujamer)
|
|
710
731
|
|
|
711
|
-
###
|
|
732
|
+
### 1.0.0 (2015-05-13)
|
|
712
733
|
|
|
713
734
|
First stable release.
|
|
@@ -32,7 +32,7 @@ To use modifiers, you must use angle-bracket syntax
|
|
|
32
32
|
{{#sortable-group model=model.items onChange=(action 'reorderItems') as |group|}}
|
|
33
33
|
{{#each group.model as |item|}}
|
|
34
34
|
{{#group.item model=item}}
|
|
35
|
-
{{
|
|
35
|
+
{{item.name}}
|
|
36
36
|
{{/group.item}}
|
|
37
37
|
{{/each}}
|
|
38
38
|
{{/sortable-group}}
|
|
@@ -44,7 +44,7 @@ To use modifiers, you must use angle-bracket syntax
|
|
|
44
44
|
<ol {{sortable-group onChange=(action 'reorderItems')}}>
|
|
45
45
|
{{#each model.items as |item|}}
|
|
46
46
|
<li {{sortable-item model=item}}>
|
|
47
|
-
{{
|
|
47
|
+
{{item.name}}
|
|
48
48
|
</li>
|
|
49
49
|
{{/each}}
|
|
50
50
|
</ol>
|
|
@@ -73,7 +73,7 @@ To use modifiers, you must use angle-bracket syntax
|
|
|
73
73
|
<ol {{sortable-group onChange=(action 'reorderItems')}}>
|
|
74
74
|
{{#each model.items as |item|}}
|
|
75
75
|
<li {{sortable-item model=item}}>
|
|
76
|
-
{{
|
|
76
|
+
{{item.name}}
|
|
77
77
|
<span class='handle' {{sortable-handle}}>↕</span>
|
|
78
78
|
</li>
|
|
79
79
|
{{/each}}
|
|
@@ -87,7 +87,7 @@ To use modifiers, you must use angle-bracket syntax
|
|
|
87
87
|
<ol {{sortable-group onChange=(action 'reorderItems' model)}}>
|
|
88
88
|
{{#each model.items as |item|}}
|
|
89
89
|
<li {{sortable-item model=item}}>
|
|
90
|
-
{{
|
|
90
|
+
{{item.name}}
|
|
91
91
|
<span class='handle' {{sortable-handle}}>↕</span>
|
|
92
92
|
</li>
|
|
93
93
|
{{/each}}
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ember-sortable
|
|
2
2
|
|
|
3
3
|
[](http://badge.fury.io/js/ember-sortable)
|
|
4
4
|
[](https://github.com/adopted-ember-addons/ember-sortable/actions?query=branch%3Amaster+workflow%3A%22build%22)
|
|
@@ -12,29 +12,10 @@ Sortable UI primitives for Ember.
|
|
|
12
12
|
|
|
13
13
|
[Check out the demo](https://adopted-ember-addons.github.io/ember-sortable/demo/)
|
|
14
14
|
|
|
15
|
-
## v2 -> v3 Migration
|
|
16
|
-
|
|
17
|
-
The component versions have been removed and you must use the modifier.
|
|
18
|
-
The modifier version does not support `groupModel`, use the currying of the `fn` helper.
|
|
19
|
-
|
|
20
|
-
## v1 -> v2 Migration
|
|
21
|
-
|
|
22
|
-
If you are migrating from `1.x.x` to `2.x.x`,
|
|
23
|
-
For components, please read this [migration guide](/MIGRATION_GUIDE_V2.md).
|
|
24
|
-
For modifiers, please read this [migration guide](/MIGRATION_GUIDE_MODIFIERS.md).
|
|
25
|
-
|
|
26
15
|
## Requirements
|
|
27
16
|
|
|
28
17
|
In version 3.0.0+, Node.js v12 or above And Ember.js v3.24 or above
|
|
29
18
|
|
|
30
|
-
In version 2.0.0+, our `closest` polyfill seems to break some app's `production` build. To mitigate this, the `closest` polyfill will only enabled if it doesn't break the `production` build (if the `polyfill` file is recognized by the build). Affected apps will need to supply their own [closest](https://developer.mozilla.org/en-US/docs/Web/API/Element/closest#Polyfill) polyfill to ensure compatibility with IE. This issue is tracked [here](https://github.com/adopted-ember-addons/ember-sortable/issues/333).
|
|
31
|
-
|
|
32
|
-
We require the `ember-decorators-polyfill` to be installed if you are using this addon with versions of Ember < 3.10.0.
|
|
33
|
-
|
|
34
|
-
Version 1.0 depends upon the availability of 2D CSS transforms.
|
|
35
|
-
Check [the matrix on caniuse.com](http://caniuse.com/#feat=transforms2d)
|
|
36
|
-
to see if your target browsers are compatible.
|
|
37
|
-
|
|
38
19
|
## Installation
|
|
39
20
|
|
|
40
21
|
```sh
|
|
@@ -396,6 +377,23 @@ await drag('mouse', '[data-test-scrollable-demo-handle] .handle', () => {
|
|
|
396
377
|
await triggerKeyEvent('[data-test-vertical-demo-handle]', 'keydown', ENTER_KEY_CODE);
|
|
397
378
|
```
|
|
398
379
|
|
|
380
|
+
## Migrating
|
|
381
|
+
|
|
382
|
+
### v3 -> v4
|
|
383
|
+
|
|
384
|
+
None, just make sure Node v14+ and Ember is v3.24+. Although older versions might work, but are no longer tested against. Specifically ember-modifier dropped support for older versions of Ember.
|
|
385
|
+
|
|
386
|
+
### v2 -> v3
|
|
387
|
+
|
|
388
|
+
The component versions have been removed and you must use the modifier.
|
|
389
|
+
The modifier version does not support `groupModel`, use the currying of the `fn` helper.
|
|
390
|
+
|
|
391
|
+
### v1 -> v2
|
|
392
|
+
|
|
393
|
+
If you are migrating from `1.x.x` to `2.x.x`,
|
|
394
|
+
For components, please read this [migration guide](/MIGRATION_GUIDE_V2.md).
|
|
395
|
+
For modifiers, please read this [migration guide](/MIGRATION_GUIDE_MODIFIERS.md).
|
|
396
|
+
|
|
399
397
|
## Developing
|
|
400
398
|
|
|
401
399
|
### Setup
|
|
@@ -57,7 +57,7 @@ export default class SortableGroupModifier extends Modifier {
|
|
|
57
57
|
/** End of keyboard utils */
|
|
58
58
|
|
|
59
59
|
get disabled() {
|
|
60
|
-
return this.
|
|
60
|
+
return this.named.disabled || false;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
/** Start of a11y properties */
|
|
@@ -74,7 +74,7 @@ export default class SortableGroupModifier extends Modifier {
|
|
|
74
74
|
* }
|
|
75
75
|
*/
|
|
76
76
|
get handleVisualClass() {
|
|
77
|
-
return this.
|
|
77
|
+
return this.named.handleVisualClass || NO_MODEL;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
/**
|
|
@@ -89,15 +89,15 @@ export default class SortableGroupModifier extends Modifier {
|
|
|
89
89
|
* }
|
|
90
90
|
*/
|
|
91
91
|
get a11yAnnouncementConfig() {
|
|
92
|
-
return this.
|
|
92
|
+
return this.named.a11yAnnouncementConfig || defaultA11yAnnouncementConfig;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
get itemVisualClass() {
|
|
96
|
-
return this.
|
|
96
|
+
return this.named.itemVisualClass || 'is-activated';
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
get a11yItemName() {
|
|
100
|
-
return this.
|
|
100
|
+
return this.named.a11yItemName || 'item';
|
|
101
101
|
}
|
|
102
102
|
/** End of a11y properties */
|
|
103
103
|
|
|
@@ -473,7 +473,7 @@ export default class SortableGroupModifier extends Modifier {
|
|
|
473
473
|
@default y
|
|
474
474
|
*/
|
|
475
475
|
get direction() {
|
|
476
|
-
return this.
|
|
476
|
+
return this.named.direction || 'y';
|
|
477
477
|
}
|
|
478
478
|
|
|
479
479
|
/**
|
|
@@ -486,7 +486,7 @@ export default class SortableGroupModifier extends Modifier {
|
|
|
486
486
|
@default null
|
|
487
487
|
*/
|
|
488
488
|
get onChange() {
|
|
489
|
-
return this.
|
|
489
|
+
return this.named.onChange;
|
|
490
490
|
}
|
|
491
491
|
|
|
492
492
|
@service('ember-sortable-internal-state')
|
|
@@ -500,11 +500,9 @@ export default class SortableGroupModifier extends Modifier {
|
|
|
500
500
|
* @returns {*|string}
|
|
501
501
|
*/
|
|
502
502
|
get groupName() {
|
|
503
|
-
return this.
|
|
503
|
+
return this.named.groupName || '_EmberSortableGroup';
|
|
504
504
|
}
|
|
505
505
|
|
|
506
|
-
_groupDef = this.sortableService.fetchGroup(this.groupName);
|
|
507
|
-
|
|
508
506
|
/**
|
|
509
507
|
This is an array of SortableItemModifiers
|
|
510
508
|
|
|
@@ -719,12 +717,14 @@ export default class SortableGroupModifier extends Modifier {
|
|
|
719
717
|
registerDestructor(this, cleanup);
|
|
720
718
|
}
|
|
721
719
|
|
|
722
|
-
modify(element
|
|
720
|
+
modify(element, _positional, named) {
|
|
723
721
|
this.element = element;
|
|
722
|
+
this.named = named;
|
|
724
723
|
|
|
725
724
|
this.removeEventListener();
|
|
726
725
|
|
|
727
726
|
if (!this.didSetup) {
|
|
727
|
+
this._groupDef = this.sortableService.fetchGroup(this.groupName);
|
|
728
728
|
this.announcer = this._createAnnouncer();
|
|
729
729
|
this.element.insertAdjacentElement('afterend', this.announcer);
|
|
730
730
|
this.sortableService.registerGroup(this.groupName, this);
|
|
@@ -63,7 +63,7 @@ export default class SortableItemModifier extends Modifier {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
get model() {
|
|
66
|
-
return this.
|
|
66
|
+
return this.named.model;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
get direction() {
|
|
@@ -82,7 +82,7 @@ export default class SortableItemModifier extends Modifier {
|
|
|
82
82
|
* @returns {*|string}
|
|
83
83
|
*/
|
|
84
84
|
get groupName() {
|
|
85
|
-
return this.
|
|
85
|
+
return this.named.groupName || '_EmberSortableGroup';
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
/**
|
|
@@ -93,7 +93,7 @@ export default class SortableItemModifier extends Modifier {
|
|
|
93
93
|
@default 125
|
|
94
94
|
*/
|
|
95
95
|
get updateInterval() {
|
|
96
|
-
return this.
|
|
96
|
+
return this.named.updateInterval || 125;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
/**
|
|
@@ -103,7 +103,7 @@ export default class SortableItemModifier extends Modifier {
|
|
|
103
103
|
@default 0[px]
|
|
104
104
|
*/
|
|
105
105
|
get spacing() {
|
|
106
|
-
return this.
|
|
106
|
+
return this.named.spacing || 0;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
/**
|
|
@@ -115,7 +115,7 @@ export default class SortableItemModifier extends Modifier {
|
|
|
115
115
|
get isDisabled() {
|
|
116
116
|
deprecate(
|
|
117
117
|
'"isDraggingDisabled" is deprecated. Please migrate to "disabled" named argument',
|
|
118
|
-
!('isDraggingDisabled' in this.
|
|
118
|
+
!('isDraggingDisabled' in this.named),
|
|
119
119
|
{
|
|
120
120
|
id: 'ember-sortable.is-dragging-disabled',
|
|
121
121
|
url: 'https://github.com/adopted-ember-addons/ember-sortable#readme',
|
|
@@ -128,7 +128,7 @@ export default class SortableItemModifier extends Modifier {
|
|
|
128
128
|
}
|
|
129
129
|
);
|
|
130
130
|
|
|
131
|
-
return this.groupDisabled || this.
|
|
131
|
+
return this.groupDisabled || this.named.disabled || this.named.isDraggingDisabled || false;
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
/**
|
|
@@ -143,7 +143,7 @@ export default class SortableItemModifier extends Modifier {
|
|
|
143
143
|
@default "[data-sortable-handle]"
|
|
144
144
|
*/
|
|
145
145
|
get handle() {
|
|
146
|
-
return this.
|
|
146
|
+
return this.named.handle || '[data-sortable-handle]';
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
handleElement;
|
|
@@ -159,7 +159,7 @@ export default class SortableItemModifier extends Modifier {
|
|
|
159
159
|
* @default 0
|
|
160
160
|
*/
|
|
161
161
|
get distance() {
|
|
162
|
-
return this.
|
|
162
|
+
return this.named.distance || 0;
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
/**
|
|
@@ -191,7 +191,7 @@ export default class SortableItemModifier extends Modifier {
|
|
|
191
191
|
@default null
|
|
192
192
|
*/
|
|
193
193
|
get onDragStart() {
|
|
194
|
-
return this.
|
|
194
|
+
return this.named.onDragStart || ((item) => item);
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
/**
|
|
@@ -202,7 +202,7 @@ export default class SortableItemModifier extends Modifier {
|
|
|
202
202
|
@default null
|
|
203
203
|
*/
|
|
204
204
|
get onDragStop() {
|
|
205
|
-
return this.
|
|
205
|
+
return this.named.onDragStop || ((item) => item);
|
|
206
206
|
}
|
|
207
207
|
|
|
208
208
|
/**
|
|
@@ -244,7 +244,7 @@ export default class SortableItemModifier extends Modifier {
|
|
|
244
244
|
@property disableCheckScrollBounds
|
|
245
245
|
*/
|
|
246
246
|
get disableCheckScrollBounds() {
|
|
247
|
-
return this.
|
|
247
|
+
return this.named.disableCheckScrollBounds != undefined ? this.named.disableCheckScrollBounds : isTesting;
|
|
248
248
|
}
|
|
249
249
|
|
|
250
250
|
/**
|
|
@@ -268,6 +268,8 @@ export default class SortableItemModifier extends Modifier {
|
|
|
268
268
|
return;
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
+
this.setupHandleElement();
|
|
272
|
+
|
|
271
273
|
// If the event is coming from within the item, we do not want to activate keyboard reorder mode.
|
|
272
274
|
if (event.target === this.handleElement || event.target === this.element) {
|
|
273
275
|
this.sortableGroup.activateKeyDown(this);
|
|
@@ -811,6 +813,16 @@ export default class SortableItemModifier extends Modifier {
|
|
|
811
813
|
this.element.removeEventListener('touchstart', this.touchStart);
|
|
812
814
|
}
|
|
813
815
|
|
|
816
|
+
setupHandleElement() {
|
|
817
|
+
this.handleElement = this.element.querySelector(this.handle);
|
|
818
|
+
|
|
819
|
+
if (this.handleElement) {
|
|
820
|
+
this.handleElement.style['touch-action'] = 'none';
|
|
821
|
+
} else {
|
|
822
|
+
this.element.style['touch-action'] = 'none';
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
|
|
814
826
|
element;
|
|
815
827
|
didSetup = false;
|
|
816
828
|
|
|
@@ -819,20 +831,15 @@ export default class SortableItemModifier extends Modifier {
|
|
|
819
831
|
registerDestructor(this, cleanup);
|
|
820
832
|
}
|
|
821
833
|
|
|
822
|
-
modify(element
|
|
834
|
+
modify(element, _positional, named) {
|
|
823
835
|
this.element = element;
|
|
836
|
+
this.named = named;
|
|
824
837
|
|
|
825
838
|
this.element.classList.add(this.className);
|
|
826
839
|
|
|
827
840
|
// Instead of using `event.preventDefault()` in the 'primeDrag' event,
|
|
828
841
|
// (doesn't work in Chrome 56), we set touch-action: none as a workaround.
|
|
829
|
-
this.
|
|
830
|
-
|
|
831
|
-
if (this.handleElement) {
|
|
832
|
-
this.handleElement.style['touch-action'] = 'none';
|
|
833
|
-
} else {
|
|
834
|
-
this.element.style['touch-action'] = 'none';
|
|
835
|
-
}
|
|
842
|
+
this.setupHandleElement();
|
|
836
843
|
|
|
837
844
|
if (!this.didSetup) {
|
|
838
845
|
this.addEventListener();
|