ember-sortable 2.2.6 → 2.3.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.
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
* Merge pull request #430 from jacojoubert/refactor-disabled (364fc80)
|
|
2
|
+
* (51ea46f)
|
|
3
|
+
* Merge pull request #444 from snewcomer/sn/deprecate-components (b70d5cd)
|
|
4
|
+
* Deprecate use of components (ffbd488)
|
|
5
|
+
* Add deprecation warning for `isDraggingDisabled` (ad38e58)
|
|
6
|
+
* Reset sortable-item (cebbe62)
|
|
7
|
+
* Merge pull request #440 from ntnz/patch-2 (2cbc2b5)
|
|
8
|
+
* Merge branch 'master' into refactor-disabled (0f315a6)
|
|
9
|
+
* Merge branch 'master' into refactor-disabled (36aa312)
|
|
10
|
+
* Fix syntax issues in readme (d2f8cc9)
|
|
11
|
+
* Update README.md (c0e88e7)
|
|
12
|
+
* Add disabled argument to sortable-item (888dc5c)
|
|
13
|
+
* Add examples of disabled item (4db5107)
|
|
14
|
+
|
|
1
15
|
## v2.2.6 (2021-10-21)
|
|
2
16
|
|
|
3
17
|
#### :bug: Bug Fix
|
package/README.md
CHANGED
|
@@ -42,9 +42,9 @@ $ ember install ember-sortable
|
|
|
42
42
|
```hbs
|
|
43
43
|
{{! app/templates/my-route.hbs }}
|
|
44
44
|
|
|
45
|
-
<SortableGroup @model={{this.model.items}} @onChange={{this.reorderItems}} as |group
|
|
45
|
+
<SortableGroup @model={{this.model.items}} @onChange={{this.reorderItems}} as |group|>
|
|
46
46
|
{{#each group.model as |modelItem|}}
|
|
47
|
-
<group.item @model={{modelItem}} as |item
|
|
47
|
+
<group.item @model={{modelItem}} as |item|>
|
|
48
48
|
{{modelItem.name}}
|
|
49
49
|
<item.handle>
|
|
50
50
|
<span class="handle">↕</span>
|
|
@@ -292,7 +292,7 @@ modifier
|
|
|
292
292
|
</li>
|
|
293
293
|
```
|
|
294
294
|
|
|
295
|
-
### Multiple Ember-Sortables renders simultaneously (Modifier version)
|
|
295
|
+
### Multiple Ember-Sortables renders simultaneously (Modifier version)
|
|
296
296
|
|
|
297
297
|
The modifier version uses a service behind the scenes for communication between the group and the items and to maintain state. It does this seemlessly when the elements are rendered on the screen. However, if there are two sortables rendered at the same time, either in the same component or different components, the state management does not know which items belong to which group.
|
|
298
298
|
|
|
@@ -326,8 +326,10 @@ Ensure that the same name is passed to both the group and the items, this would
|
|
|
326
326
|
|
|
327
327
|
|
|
328
328
|
### Disabling Drag (Experimental)
|
|
329
|
-
`sortable-item` (component and modifier) exposes an optional `isDraggingDisabled` flag that you can use to disable
|
|
329
|
+
`sortable-item` (component and modifier) exposes an optional `disabled` (previously `isDraggingDisabled`) flag that you can use to disable reordering for that particular item. Disabling and item won't prevent it from changing position in the array. The user can still move other non-disabled items to over it.
|
|
330
|
+
|
|
330
331
|
This flag is intended as an utility to make your life easier with 3 main benefits:
|
|
332
|
+
|
|
331
333
|
1. You can now specify which `sortable-item` are not intended to be draggable/sortable.
|
|
332
334
|
2. You do not have to duplicate the `sortable-item` UI just for the purpose of disabling the `sorting` behavior.
|
|
333
335
|
3. Allows you to access the entire list of `models` for your `onChange` action, which can now be a mix of sortable and non-sortable items.
|
|
@@ -350,8 +352,8 @@ component
|
|
|
350
352
|
an ordered list, `ol`, by default.
|
|
351
353
|
- `sortable-item`
|
|
352
354
|
a list item, `li`, by default.
|
|
353
|
-
|
|
354
|
-
The modifier version can be attached to to any element that makes sense,
|
|
355
|
+
|
|
356
|
+
The modifier version can be attached to to any element that makes sense,
|
|
355
357
|
|
|
356
358
|
##### Keyboard Navigation
|
|
357
359
|
There are 4 modes during keyboard navigation:
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
isRightArrowKey,
|
|
14
14
|
} from '../utils/keyboard';
|
|
15
15
|
import { ANNOUNCEMENT_ACTION_TYPES } from '../utils/constant';
|
|
16
|
+
import { deprecate } from '@ember/debug';
|
|
16
17
|
|
|
17
18
|
const a = A;
|
|
18
19
|
const NO_MODEL = {};
|
|
@@ -130,6 +131,20 @@ export default Component.extend({
|
|
|
130
131
|
init() {
|
|
131
132
|
this._super(...arguments);
|
|
132
133
|
|
|
134
|
+
deprecate(
|
|
135
|
+
'The <SortableGroup> component is deprecated. Please use the modifier version {{sortable-group}}.',
|
|
136
|
+
false,
|
|
137
|
+
{
|
|
138
|
+
id: 'ember-sortable:sortable-group-component-deprecated',
|
|
139
|
+
until: '3.0.0',
|
|
140
|
+
for: 'ember-sortable',
|
|
141
|
+
since: {
|
|
142
|
+
available: '2.2.6',
|
|
143
|
+
enabled: '2.2.6',
|
|
144
|
+
},
|
|
145
|
+
}
|
|
146
|
+
);
|
|
147
|
+
|
|
133
148
|
this._setGetterSetters();
|
|
134
149
|
this.set('moves', []);
|
|
135
150
|
},
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Component from '@ember/component';
|
|
2
|
+
import { deprecate } from '@ember/debug';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* This component represents the handle of a `sortable-item`.
|
|
@@ -8,4 +9,22 @@ export default Component.extend({
|
|
|
8
9
|
role: 'button',
|
|
9
10
|
attributeBindings: ["dataSortableHandle:data-sortable-handle", "tabindex", "role"],
|
|
10
11
|
dataSortableHandle: true,
|
|
12
|
+
|
|
13
|
+
init() {
|
|
14
|
+
this._super(...arguments);
|
|
15
|
+
|
|
16
|
+
deprecate(
|
|
17
|
+
'The <SortableHandle> component is deprecated. Please use the modifier version {{sortable-handle}}.',
|
|
18
|
+
false,
|
|
19
|
+
{
|
|
20
|
+
id: 'ember-sortable:sortable-handle-component-deprecated',
|
|
21
|
+
until: '3.0.0',
|
|
22
|
+
for: 'ember-sortable',
|
|
23
|
+
since: {
|
|
24
|
+
available: '2.2.6',
|
|
25
|
+
enabled: '2.2.6',
|
|
26
|
+
},
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
},
|
|
11
30
|
});
|
|
@@ -12,6 +12,8 @@ import { DRAG_ACTIONS, ELEMENT_CLICK_ACTION, END_ACTIONS } from '../utils/consta
|
|
|
12
12
|
import { getX, getY } from '../utils/coordinate';
|
|
13
13
|
import { buildWaiter } from '@ember/test-waiters';
|
|
14
14
|
import config from 'ember-get-config';
|
|
15
|
+
import { deprecate } from '@ember/debug';
|
|
16
|
+
|
|
15
17
|
const { environment } = config;
|
|
16
18
|
const isTesting = environment === 'test';
|
|
17
19
|
|
|
@@ -158,6 +160,20 @@ export default Component.extend({
|
|
|
158
160
|
|
|
159
161
|
init() {
|
|
160
162
|
this._super(...arguments);
|
|
163
|
+
|
|
164
|
+
deprecate(
|
|
165
|
+
'The <SortableItem> component is deprecated. Please use the modifier version {{sortable-item}}.',
|
|
166
|
+
false,
|
|
167
|
+
{
|
|
168
|
+
id: 'ember-sortable:sortable-item-component-deprecated',
|
|
169
|
+
until: '3.0.0',
|
|
170
|
+
for: 'ember-sortable',
|
|
171
|
+
since: {
|
|
172
|
+
available: '2.2.6',
|
|
173
|
+
enabled: '2.2.6',
|
|
174
|
+
},
|
|
175
|
+
}
|
|
176
|
+
);
|
|
161
177
|
this._setGetterSetters();
|
|
162
178
|
},
|
|
163
179
|
|
|
@@ -12,7 +12,7 @@ import scrollParent from "../system/scroll-parent";
|
|
|
12
12
|
import {getBorderSpacing} from "../utils/css-calculation";
|
|
13
13
|
import { buildWaiter } from '@ember/test-waiters';
|
|
14
14
|
import {inject as service} from '@ember/service';
|
|
15
|
-
import {assert} from '@ember/debug';
|
|
15
|
+
import { assert, deprecate } from '@ember/debug';
|
|
16
16
|
import config from 'ember-get-config';
|
|
17
17
|
const { environment } = config;
|
|
18
18
|
const isTesting = environment === 'test';
|
|
@@ -23,7 +23,7 @@ const sortableItemWaiter = buildWaiter("sortable-item-waiter");
|
|
|
23
23
|
* Modifier to mark an element as an item to be reordered
|
|
24
24
|
*
|
|
25
25
|
* @param {Object} model The model that this item will represent
|
|
26
|
-
* @param {boolean} [
|
|
26
|
+
* @param {boolean} [disabled=false] Set to true to make this item not sortable
|
|
27
27
|
* @param {Function} [onDragStart] An optional callback for when dragging starts.
|
|
28
28
|
* @param {Function} [onDragStop] An optional callback for when dragging stops.
|
|
29
29
|
*
|
|
@@ -64,7 +64,7 @@ export default class SortableItemModifier extends Modifier {
|
|
|
64
64
|
direction;
|
|
65
65
|
|
|
66
66
|
@reads("sortableGroup.disabled")
|
|
67
|
-
|
|
67
|
+
groupDisabled;
|
|
68
68
|
|
|
69
69
|
@service('ember-sortable@ember-sortable')
|
|
70
70
|
sortableService;
|
|
@@ -102,13 +102,27 @@ export default class SortableItemModifier extends Modifier {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
/**
|
|
105
|
-
Removes the ability for the current item to be
|
|
106
|
-
@property
|
|
105
|
+
Removes the ability for the current item to be sorted
|
|
106
|
+
@property disabled
|
|
107
107
|
@type boolean
|
|
108
108
|
@default false
|
|
109
109
|
*/
|
|
110
|
-
get
|
|
111
|
-
|
|
110
|
+
get isDisabled() {
|
|
111
|
+
deprecate(
|
|
112
|
+
'"isDraggingDisabled" is deprecated. Please migrate to "disabled" named argument',
|
|
113
|
+
!("isDraggingDisabled" in this.args.named),
|
|
114
|
+
{
|
|
115
|
+
id: 'ember-sortable.is-dragging-disabled',
|
|
116
|
+
url: 'https://github.com/adopted-ember-addons/ember-sortable#readme',
|
|
117
|
+
until: '3.0.0',
|
|
118
|
+
for: 'ember-sortable',
|
|
119
|
+
since: {
|
|
120
|
+
available: '2.2.6',
|
|
121
|
+
enabled: '2.2.6',
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
return this.groupDisabled || this.args.named.disabled || this.args.named.isDraggingDisabled || false;
|
|
112
126
|
}
|
|
113
127
|
|
|
114
128
|
/**
|
|
@@ -220,10 +234,7 @@ export default class SortableItemModifier extends Modifier {
|
|
|
220
234
|
isBusy;
|
|
221
235
|
|
|
222
236
|
/**
|
|
223
|
-
|
|
224
|
-
@property isDraggingDisabled
|
|
225
|
-
@type boolean
|
|
226
|
-
@default false
|
|
237
|
+
@property disableCheckScrollBounds
|
|
227
238
|
*/
|
|
228
239
|
get disableCheckScrollBounds() {
|
|
229
240
|
return this.args.named.disableCheckScrollBounds != undefined ? this.args.named.disableCheckScrollBounds : isTesting;
|
|
@@ -242,8 +253,7 @@ export default class SortableItemModifier extends Modifier {
|
|
|
242
253
|
|
|
243
254
|
@action
|
|
244
255
|
keyDown(event) {
|
|
245
|
-
|
|
246
|
-
if (this.disabled) { return; }
|
|
256
|
+
if (this.isDisabled) { return; }
|
|
247
257
|
|
|
248
258
|
// If the event is coming from within the item, we do not want to activate keyboard reorder mode.
|
|
249
259
|
if (event.target === this.handleElement || event.target === this.element) {
|
|
@@ -302,13 +312,7 @@ export default class SortableItemModifier extends Modifier {
|
|
|
302
312
|
* @private
|
|
303
313
|
*/
|
|
304
314
|
_primeDrag(startEvent) {
|
|
305
|
-
|
|
306
|
-
if (this.disabled) { return; }
|
|
307
|
-
|
|
308
|
-
// Prevent dragging if the sortable-item is disabled.
|
|
309
|
-
if (this.isDraggingDisabled) {
|
|
310
|
-
return;
|
|
311
|
-
}
|
|
315
|
+
if (this.isDisabled) { return; }
|
|
312
316
|
|
|
313
317
|
if (this.handleElement && !startEvent.target.closest(this.handle)) {
|
|
314
318
|
return;
|