ember-sortable 5.1.1 → 5.2.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/README.md +20 -12
- package/{addon-main.js → addon-main.cjs} +2 -0
- package/declarations/modifiers/sortable-group.d.ts +326 -0
- package/declarations/modifiers/sortable-group.d.ts.map +1 -0
- package/declarations/modifiers/sortable-handle.d.ts +24 -0
- package/declarations/modifiers/sortable-handle.d.ts.map +1 -0
- package/declarations/modifiers/sortable-item.d.ts +346 -0
- package/declarations/modifiers/sortable-item.d.ts.map +1 -0
- package/declarations/services/ember-sortable-internal-state.d.ts +58 -0
- package/declarations/services/ember-sortable-internal-state.d.ts.map +1 -0
- package/declarations/system/scroll-container.d.ts +18 -0
- package/declarations/system/scroll-container.d.ts.map +1 -0
- package/declarations/system/scroll-parent.d.ts +2 -0
- package/declarations/system/scroll-parent.d.ts.map +1 -0
- package/declarations/template-registry.d.ts +9 -0
- package/declarations/template-registry.d.ts.map +1 -0
- package/declarations/test-support/helpers/drag.d.ts +37 -0
- package/declarations/test-support/helpers/drag.d.ts.map +1 -0
- package/declarations/test-support/helpers/reorder.d.ts +25 -0
- package/declarations/test-support/helpers/reorder.d.ts.map +1 -0
- package/declarations/test-support/index.d.ts +5 -0
- package/declarations/test-support/index.d.ts.map +1 -0
- package/declarations/test-support/utils/keyboard.d.ts +17 -0
- package/declarations/test-support/utils/keyboard.d.ts.map +1 -0
- package/declarations/test-support/utils/offset.d.ts +11 -0
- package/declarations/test-support/utils/offset.d.ts.map +1 -0
- package/declarations/utils/constant.d.ts +11 -0
- package/declarations/utils/constant.d.ts.map +1 -0
- package/declarations/utils/coordinate.d.ts +17 -0
- package/declarations/utils/coordinate.d.ts.map +1 -0
- package/declarations/utils/css-calculation.d.ts +13 -0
- package/declarations/utils/css-calculation.d.ts.map +1 -0
- package/declarations/utils/defaults.d.ts +23 -0
- package/declarations/utils/defaults.d.ts.map +1 -0
- package/declarations/utils/keyboard.d.ts +17 -0
- package/declarations/utils/keyboard.d.ts.map +1 -0
- package/dist/{_rollupPluginBabelHelpers-543b1c36.js → _rollupPluginBabelHelpers-a7bede49.js} +2 -2
- package/dist/_rollupPluginBabelHelpers-a7bede49.js.map +1 -0
- package/dist/modifiers/sortable-group.js +63 -30
- package/dist/modifiers/sortable-group.js.map +1 -1
- package/dist/modifiers/sortable-handle.js +4 -4
- package/dist/modifiers/sortable-handle.js.map +1 -1
- package/dist/modifiers/sortable-item.js +187 -80
- package/dist/modifiers/sortable-item.js.map +1 -1
- package/dist/services/ember-sortable-internal-state.js +11 -5
- package/dist/services/ember-sortable-internal-state.js.map +1 -1
- package/dist/test-support/helpers/drag.js +4 -1
- package/dist/test-support/helpers/drag.js.map +1 -1
- package/dist/test-support/helpers/reorder.js +12 -2
- package/dist/test-support/helpers/reorder.js.map +1 -1
- package/dist/test-support/utils/keyboard.js.map +1 -1
- package/dist/test-support/utils/offset.js.map +1 -1
- package/dist/utils/constant.js.map +1 -1
- package/dist/utils/coordinate.js +4 -4
- package/dist/utils/coordinate.js.map +1 -1
- package/dist/utils/css-calculation.js +4 -4
- package/dist/utils/css-calculation.js.map +1 -1
- package/dist/utils/defaults.js.map +1 -1
- package/dist/utils/keyboard.js.map +1 -1
- package/package.json +92 -27
- package/dist/_rollupPluginBabelHelpers-543b1c36.js.map +0 -1
- package/dist/system/scroll-container.js +0 -54
- package/dist/system/scroll-container.js.map +0 -1
- package/dist/system/scroll-parent.js +0 -35
- package/dist/system/scroll-parent.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
# ember-sortable
|
|
2
2
|
|
|
3
3
|
[](http://badge.fury.io/js/ember-sortable)
|
|
4
|
-
[](https://github.com/adopted-ember-addons/ember-sortable/actions?query=branch%3Amaster)
|
|
5
5
|
[](http://badge.fury.io/js/ember-sortable)
|
|
6
6
|
[](http://emberobserver.com/addons/ember-sortable)
|
|
7
7
|
[](https://codeclimate.com/github/jgwhite/ember-sortable)
|
|
8
8
|
|
|
9
9
|
Sortable UI primitives for Ember.
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
[Check out the demo](https://adopted-ember-addons.github.io/ember-sortable/demo/)
|
|
11
|
+
[Check out the demo](https://ember-sortable.netlify.app/)
|
|
14
12
|
|
|
15
13
|
## Requirements
|
|
16
14
|
|
|
@@ -82,18 +80,22 @@ The modifier version does not support `groupModel`, use the currying of `action`
|
|
|
82
80
|
|
|
83
81
|
### Changing sort direction
|
|
84
82
|
|
|
85
|
-
To change sort direction, define `direction` on `sortable-group`
|
|
83
|
+
To change sort direction, define `direction` on `sortable-group`
|
|
84
|
+
Possible values are:
|
|
85
|
+
- `y` (default): allowes to move items up/down
|
|
86
|
+
- `x`: allowes to move items left/right
|
|
87
|
+
- `grid`: items can be moved in all directions inside a group
|
|
86
88
|
|
|
87
89
|
```hbs
|
|
88
|
-
<ol {{sortable-group direction="x" onChange=
|
|
90
|
+
<ol {{sortable-group direction="x" onChange=this.reorderItems}}>
|
|
89
91
|
```
|
|
90
92
|
|
|
91
93
|
### Changing spacing between currently dragged element and the rest of the group
|
|
92
94
|
|
|
93
|
-
When user starts to drag element, other elements jump back. Works
|
|
95
|
+
When user starts to drag element, other elements jump back. Works for all direction option.
|
|
94
96
|
|
|
95
97
|
In `y` case: elements above current one jump up, and elements below current one - jump down.
|
|
96
|
-
In `x` case: elements before current one jump to the left, and elements after current one - jump to the right.
|
|
98
|
+
In `x` / `grid` case: elements before current one jump to the left, and elements after current one - jump to the right.
|
|
97
99
|
|
|
98
100
|
To change this property, define `spacing` on `sortable-item` (default is `0`):
|
|
99
101
|
|
|
@@ -135,7 +137,7 @@ The classes look like this:
|
|
|
135
137
|
<li class="sortable-item is-activated">...</li>
|
|
136
138
|
```
|
|
137
139
|
|
|
138
|
-
In our [example app.css](
|
|
140
|
+
In our [example app.css](docs/app/styles/app.css) we apply a
|
|
139
141
|
transition of `.125s` in the default case:
|
|
140
142
|
|
|
141
143
|
```css
|
|
@@ -174,7 +176,7 @@ removed. Use this class to add a visual indicator that the item is selected and
|
|
|
174
176
|
### Drag Actions
|
|
175
177
|
|
|
176
178
|
The `onDragStart` and `onDragStop` actions are available for the
|
|
177
|
-
`sortable-item`s. You can provide an action
|
|
179
|
+
`sortable-item`s. You can provide an action to listen to these actions to
|
|
178
180
|
be notified when an item is being dragged or not.
|
|
179
181
|
|
|
180
182
|
When the action is called, the item's model will be provided as the only
|
|
@@ -402,24 +404,30 @@ For modifiers, please read this [migration guide](/MIGRATION_GUIDE_MODIFIERS.md)
|
|
|
402
404
|
|
|
403
405
|
## Developing
|
|
404
406
|
|
|
407
|
+
### Requirement
|
|
408
|
+
|
|
409
|
+
You need to install nodejs and [pnpm](https://pnpm.io/installation).
|
|
410
|
+
The specific versions you need, you can find [here](package.json#L19-L22)
|
|
411
|
+
|
|
405
412
|
### Setup
|
|
406
413
|
|
|
407
414
|
```sh
|
|
408
415
|
$ git clone git@github.com:adopted-ember-addons/ember-sortable
|
|
409
416
|
$ cd ember-sortable
|
|
410
|
-
$
|
|
417
|
+
$ pnpm install
|
|
411
418
|
```
|
|
412
419
|
|
|
413
420
|
### Dev Server
|
|
414
421
|
|
|
415
422
|
```sh
|
|
423
|
+
$ cd test-app
|
|
416
424
|
$ ember serve
|
|
417
425
|
```
|
|
418
426
|
|
|
419
427
|
### Running Tests
|
|
420
428
|
|
|
421
429
|
```sh
|
|
422
|
-
$
|
|
430
|
+
$ pnpm run test
|
|
423
431
|
```
|
|
424
432
|
|
|
425
433
|
### Publishing Demo
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import Modifier from 'ember-modifier';
|
|
2
|
+
import { type A11yAnnouncementConfig } from '../utils/defaults.ts';
|
|
3
|
+
import type { ArgsFor, PositionalArgs, NamedArgs } from 'ember-modifier';
|
|
4
|
+
import type Owner from '@ember/owner';
|
|
5
|
+
import type EmberSortableService from '../services/ember-sortable-internal-state.ts';
|
|
6
|
+
import type { Group } from '../services/ember-sortable-internal-state.ts';
|
|
7
|
+
import type SortableItemModifier from './sortable-item.ts';
|
|
8
|
+
import type { MoveDirection } from './sortable-item.ts';
|
|
9
|
+
export interface HandleVisualClass {
|
|
10
|
+
UP?: string;
|
|
11
|
+
DOWN?: string;
|
|
12
|
+
LEFT?: string;
|
|
13
|
+
RIGHT?: string;
|
|
14
|
+
}
|
|
15
|
+
interface Position {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
}
|
|
19
|
+
export type TDirection = 'x' | 'y' | 'grid';
|
|
20
|
+
interface SortableGroupModifierSignature<T> {
|
|
21
|
+
Args: {
|
|
22
|
+
Named: {
|
|
23
|
+
direction?: TDirection;
|
|
24
|
+
groupName?: string;
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
handleVisualClass?: HandleVisualClass;
|
|
27
|
+
a11yAnnouncementConfig?: A11yAnnouncementConfig;
|
|
28
|
+
itemVisualClass?: string;
|
|
29
|
+
a11yItemName?: string;
|
|
30
|
+
onChange: (itemModels: T[], draggedModel: T | undefined) => void;
|
|
31
|
+
};
|
|
32
|
+
Positional: unknown[];
|
|
33
|
+
};
|
|
34
|
+
Element: HTMLElement;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Modifier to apply a11y support to a group container for the Sortable component
|
|
38
|
+
*
|
|
39
|
+
* @param {String} [a11yItemName] A name for each model, used for creating more meaningful a11y announcements.
|
|
40
|
+
* @param {Object} [a11yAnnouncementConfig] A map of action to function to build meaningful a11y announcements.
|
|
41
|
+
* @param {String} [itemVisualClass] A class for styling visual indicators on the yielded `sortable-item`.
|
|
42
|
+
* @param {Object} [handleVisualClass] An object for styling visual indicators on the yielded `sortable-handle` on different `move`.
|
|
43
|
+
* @param {Function} [onChange] An optional callback for when position rearrangements are confirmed.
|
|
44
|
+
*
|
|
45
|
+
* @module drag-drop/draggable-group
|
|
46
|
+
* @example
|
|
47
|
+
* <ol {{sortable-group onChange=this.update a11yAnnouncementConfig=this.myA11yConfig}}>
|
|
48
|
+
* {{#each model.items as |item|}}
|
|
49
|
+
* <li {{sortable-item model=item}}>
|
|
50
|
+
* {{item.name}}
|
|
51
|
+
* <span class="handle" {{sortable-handle}}>↕</span>
|
|
52
|
+
* </li>
|
|
53
|
+
* {{/each}}
|
|
54
|
+
* </ol>
|
|
55
|
+
*/
|
|
56
|
+
export default class SortableGroupModifier<T> extends Modifier<SortableGroupModifierSignature<T>> {
|
|
57
|
+
/** Primary keyboard utils */
|
|
58
|
+
_selectedItem: SortableItemModifier<T> | null;
|
|
59
|
+
_group: SortableGroupModifier<T> | null;
|
|
60
|
+
_firstItemPosition?: Position;
|
|
61
|
+
_groupDef: Group<T>;
|
|
62
|
+
move: null;
|
|
63
|
+
moves: [number, number][];
|
|
64
|
+
isKeyboardReorderModeEnabled: boolean;
|
|
65
|
+
isKeyDownEnabled: boolean;
|
|
66
|
+
isRetainingFocus: boolean;
|
|
67
|
+
/** End of keyboard utils */
|
|
68
|
+
get disabled(): boolean;
|
|
69
|
+
/** Start of a11y properties */
|
|
70
|
+
/**
|
|
71
|
+
* @property an object containing different classes for visual indicators
|
|
72
|
+
* @type {Object}
|
|
73
|
+
* @default null
|
|
74
|
+
* @example
|
|
75
|
+
* {
|
|
76
|
+
* UP: 'up'
|
|
77
|
+
* DOWN: 'down',
|
|
78
|
+
* LEFT: 'left',
|
|
79
|
+
* RIGHT: 'right',
|
|
80
|
+
* }
|
|
81
|
+
*/
|
|
82
|
+
get handleVisualClass(): HandleVisualClass;
|
|
83
|
+
/**
|
|
84
|
+
* @property an object containing functions for producing screen reader announcements
|
|
85
|
+
* @type {Object}
|
|
86
|
+
* @example
|
|
87
|
+
* {
|
|
88
|
+
* MOVE: function() {},
|
|
89
|
+
* ACTIVATE: function() {},
|
|
90
|
+
* CONFIRM: function() {},
|
|
91
|
+
* CANCEL: function() {},
|
|
92
|
+
* }
|
|
93
|
+
*/
|
|
94
|
+
get a11yAnnouncementConfig(): A11yAnnouncementConfig;
|
|
95
|
+
get itemVisualClass(): string;
|
|
96
|
+
get a11yItemName(): string;
|
|
97
|
+
/** End of a11y properties */
|
|
98
|
+
/**
|
|
99
|
+
* Make sure that we cancel any ongoing keyboard operation when the focus is lost from the handle.
|
|
100
|
+
* Because this can be fired pre-maturely, effectively cancelling before other keyboard operations,
|
|
101
|
+
* we need to wait until other operations are completed, so this will cancel properly.
|
|
102
|
+
*
|
|
103
|
+
* @param {Event} event a DOM event.
|
|
104
|
+
*/
|
|
105
|
+
focusOut(): void;
|
|
106
|
+
/**
|
|
107
|
+
* Explanation
|
|
108
|
+
* 1. `KeyboardReorderMode` is disabled: users can activate it via ENTER or SPACE.
|
|
109
|
+
* 2. `KeyboardReorderMode` is enabled: users can reorder via UP or DOWN arrow keys. TODO: Expand to more keys, e.g LEFT, RIGHT
|
|
110
|
+
* 3. `KeyboardReorderMode` is enabled: users can finalize/save the reordering via ENTER or SPACE.
|
|
111
|
+
* 4. `KeyboardReorderMode` is enabled: users can discard the reordering via ESC.
|
|
112
|
+
*
|
|
113
|
+
* @param {Event} event a DOM event
|
|
114
|
+
*/
|
|
115
|
+
keyDown(event: KeyboardEvent): void;
|
|
116
|
+
/**
|
|
117
|
+
* Checks if the given element is a child of a handle.
|
|
118
|
+
*
|
|
119
|
+
* @param {Element} element a DOM element.
|
|
120
|
+
*/
|
|
121
|
+
_isElementWithinHandle(element: Element | null): boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Moves an sortedItem from one index to another index, effectively performing an reorder.
|
|
124
|
+
*
|
|
125
|
+
* @param {Integer} fromIndex the original index
|
|
126
|
+
* @param {Integer} toIndex the new index
|
|
127
|
+
*/
|
|
128
|
+
_move(fromIndex: number, toIndex: number): void;
|
|
129
|
+
/**
|
|
130
|
+
* Handles all of the keyboard operations, such as
|
|
131
|
+
* 1. Keyboard navigation for UP, DOWN, LEFT, RIGHT
|
|
132
|
+
* 2. Confirming reorder
|
|
133
|
+
* 3. Discard reorder
|
|
134
|
+
* 4. Also handles refocusing the element that triggered the interaction.
|
|
135
|
+
*
|
|
136
|
+
* @param {Event} event a DOM event.
|
|
137
|
+
*/
|
|
138
|
+
_handleKeyboardReorder(event: KeyboardEvent): void;
|
|
139
|
+
/**
|
|
140
|
+
* Moves the item to its new position and adds the move to our history.
|
|
141
|
+
*
|
|
142
|
+
* @param {SortableItemModifier} item the item to be moved.
|
|
143
|
+
* @param {Integer} delta how much to move index-wise.
|
|
144
|
+
*/
|
|
145
|
+
moveItem(item: SortableItemModifier<T>, delta: number): void;
|
|
146
|
+
/**
|
|
147
|
+
* Handles all the necessary operations needed for cancelling the current keyboard selection.
|
|
148
|
+
* 1. Disables keyboard reorder mode.
|
|
149
|
+
* 2. Undo all of the tracked moves.
|
|
150
|
+
* 3. Tears down the application container, so we are not focus locked within the application.
|
|
151
|
+
* 4. Resets the current selected item.
|
|
152
|
+
*/
|
|
153
|
+
cancelKeyboardSelection(): void;
|
|
154
|
+
/**
|
|
155
|
+
* Handles all th necessary operations needed for confirming the current keyboard selection.
|
|
156
|
+
* 1. Disables keyboard reorder mode.
|
|
157
|
+
* 2. Tears down the application container, so we are not focus locked within the container.
|
|
158
|
+
* 3. Make sure to update and sync all the internal items and UI.
|
|
159
|
+
* 4. Triggers the `onChange` action if provided.
|
|
160
|
+
* 5. Resets the currently selected item.
|
|
161
|
+
*/
|
|
162
|
+
confirmKeyboardSelection(): void;
|
|
163
|
+
/**
|
|
164
|
+
* Announces the message constructed from `a11yAnnouncementConfig`.
|
|
165
|
+
*
|
|
166
|
+
* @param {String} type the action type.
|
|
167
|
+
* @param {Number} delta how much distance (item-wise) is being moved.
|
|
168
|
+
*/
|
|
169
|
+
_announceAction(type: keyof A11yAnnouncementConfig, delta?: number): void;
|
|
170
|
+
/**
|
|
171
|
+
* Reset the selected item.
|
|
172
|
+
*/
|
|
173
|
+
_resetItemSelection(): void;
|
|
174
|
+
/**
|
|
175
|
+
* Updates the selected item's visual indicators.
|
|
176
|
+
*
|
|
177
|
+
* @param {SortableItemModifier} item the selected item.
|
|
178
|
+
* @param {Boolean} isActive to activate or deactivate the class.
|
|
179
|
+
*/
|
|
180
|
+
_updateItemVisualIndicators(item: SortableItemModifier<T>, isActive: boolean): void;
|
|
181
|
+
/**
|
|
182
|
+
* Updates the selected item's handle's visual indicators
|
|
183
|
+
*
|
|
184
|
+
* @param {SortableItemModifier} item the selected item.
|
|
185
|
+
* @param {boolean} isUpdate to update or not update.
|
|
186
|
+
*/
|
|
187
|
+
_updateHandleVisualIndicators(item: SortableItemModifier<T>, isUpdate: boolean): void;
|
|
188
|
+
/**
|
|
189
|
+
* Sets focus on the current item or its handle.
|
|
190
|
+
*
|
|
191
|
+
* @param {Element} itemElement an DOM element representing an sortable-item.
|
|
192
|
+
*/
|
|
193
|
+
_focusItem(itemElement: HTMLElement): void;
|
|
194
|
+
/**
|
|
195
|
+
* Enables keyboard reorder mode.
|
|
196
|
+
*/
|
|
197
|
+
_enableKeyboardReorderMode(): void;
|
|
198
|
+
/**
|
|
199
|
+
* Disables keyboard reorder mode
|
|
200
|
+
*/
|
|
201
|
+
_disableKeyboardReorderMode(): void;
|
|
202
|
+
/**
|
|
203
|
+
* Sets up the group as an application and make it programmatically focusable.
|
|
204
|
+
*/
|
|
205
|
+
_setupA11yApplicationContainer(): void;
|
|
206
|
+
/**
|
|
207
|
+
* Tears down the `role=application` container.
|
|
208
|
+
*/
|
|
209
|
+
_tearDownA11yApplicationContainer(): void;
|
|
210
|
+
_prepareKeyboardReorderMode(): void;
|
|
211
|
+
/**
|
|
212
|
+
@property direction
|
|
213
|
+
@type string
|
|
214
|
+
@default y
|
|
215
|
+
*/
|
|
216
|
+
get direction(): TDirection;
|
|
217
|
+
/**
|
|
218
|
+
Called when order of items has been changed
|
|
219
|
+
@property onChange
|
|
220
|
+
@type Function
|
|
221
|
+
@param {Object} groupModel group model (omitted if not set)
|
|
222
|
+
@param {Object[]} newModel models in their new order
|
|
223
|
+
@param {Object} itemModel model just dragged
|
|
224
|
+
@default null
|
|
225
|
+
*/
|
|
226
|
+
get onChange(): (itemModels: T[], draggedModel: T | undefined) => void;
|
|
227
|
+
sortableService: EmberSortableService<T>;
|
|
228
|
+
/**
|
|
229
|
+
* This is the group name used to keep groups separate if there are more than one on the screen at a time.
|
|
230
|
+
* If no group is assigned a default is used
|
|
231
|
+
*
|
|
232
|
+
* @default "_EmberSortableGroup"
|
|
233
|
+
* @returns {*|string}
|
|
234
|
+
*/
|
|
235
|
+
get groupName(): string;
|
|
236
|
+
/**
|
|
237
|
+
This is an array of SortableItemModifiers
|
|
238
|
+
|
|
239
|
+
@property items
|
|
240
|
+
@type SortableItemModifier[]
|
|
241
|
+
*/
|
|
242
|
+
get items(): SortableItemModifier<T>[];
|
|
243
|
+
set(items: SortableItemModifier<T>[]): void;
|
|
244
|
+
/**
|
|
245
|
+
* Announcer element
|
|
246
|
+
*
|
|
247
|
+
* @type {Element}
|
|
248
|
+
*/
|
|
249
|
+
announcer: Element | null;
|
|
250
|
+
/**
|
|
251
|
+
Position for the first item.
|
|
252
|
+
If spacing is present, first item's position will have to change as well.
|
|
253
|
+
@property firstItemPosition
|
|
254
|
+
@type Number
|
|
255
|
+
*/
|
|
256
|
+
get firstItemPosition(): Position;
|
|
257
|
+
/**
|
|
258
|
+
An array of DOM elements.
|
|
259
|
+
@property sortedItems
|
|
260
|
+
@type SortableItemModifier[]
|
|
261
|
+
*/
|
|
262
|
+
get sortedItems(): SortableItemModifier<T>[];
|
|
263
|
+
/**
|
|
264
|
+
* Enables keyboard navigation
|
|
265
|
+
*/
|
|
266
|
+
activateKeyDown(selectedItem: SortableItemModifier<T>): void;
|
|
267
|
+
/**
|
|
268
|
+
* Disables keyboard navigation
|
|
269
|
+
* Currently used to handle keydown events bubbling up from
|
|
270
|
+
* elements that aren't meant to invoke keyboard navigation
|
|
271
|
+
* by ignoring them.
|
|
272
|
+
*/
|
|
273
|
+
deactivateKeyDown(): void;
|
|
274
|
+
/**
|
|
275
|
+
Register the group with this Sortable.
|
|
276
|
+
@method registerGroup
|
|
277
|
+
@param {SortableGroupModifier} group
|
|
278
|
+
*/
|
|
279
|
+
registerGroup(group: SortableGroupModifier<T>): void;
|
|
280
|
+
/**
|
|
281
|
+
De-register the group with this Sortable.
|
|
282
|
+
@method deregisterGroup
|
|
283
|
+
@param {SortableGroupModifier} group
|
|
284
|
+
*/
|
|
285
|
+
deregisterGroup(group: SortableGroupModifier<T>): void;
|
|
286
|
+
/**
|
|
287
|
+
Prepare for sorting.
|
|
288
|
+
Main purpose is to stash the current firstItemPosition so
|
|
289
|
+
we don’t incur expensive re-layouts.
|
|
290
|
+
@method _prepare
|
|
291
|
+
*/
|
|
292
|
+
prepare(): void;
|
|
293
|
+
/**
|
|
294
|
+
Update item positions (relatively to the first element position).
|
|
295
|
+
@method update
|
|
296
|
+
@param {SortableItemModifier[]} sortedItems
|
|
297
|
+
*/
|
|
298
|
+
update(sortedItems: SortableItemModifier<T>[]): void;
|
|
299
|
+
/**
|
|
300
|
+
@method _commit
|
|
301
|
+
*/
|
|
302
|
+
commit(): void;
|
|
303
|
+
_onChange(itemModels: T[], draggedModel: T | undefined): void;
|
|
304
|
+
/**
|
|
305
|
+
* Keeps the UI in sync with actual changes.
|
|
306
|
+
* Needed for drag and keyboard operations.
|
|
307
|
+
*/
|
|
308
|
+
_updateItems(): void;
|
|
309
|
+
_createAnnouncer(): HTMLSpanElement;
|
|
310
|
+
_calculateGridPosition(a: SortableItemModifier<T>, b: SortableItemModifier<T>, groupWidth: number): {
|
|
311
|
+
ax: number;
|
|
312
|
+
ay: number;
|
|
313
|
+
bx: number;
|
|
314
|
+
by: number;
|
|
315
|
+
};
|
|
316
|
+
_calculateGridDragItemPos(x: number, y: number, otherX: number, otherY: number, width: number, height: number, moveDirection: MoveDirection, groupTopPos: number, groupLeftPos: number, groupWidth: number): Position;
|
|
317
|
+
addEventListener(): void;
|
|
318
|
+
removeEventListener(): void;
|
|
319
|
+
element: HTMLElement;
|
|
320
|
+
didSetup: boolean;
|
|
321
|
+
named: NamedArgs<SortableGroupModifierSignature<T>>;
|
|
322
|
+
constructor(owner: Owner, args: ArgsFor<SortableGroupModifierSignature<T>>);
|
|
323
|
+
modify(element: HTMLElement, _positional: PositionalArgs<SortableGroupModifierSignature<T>>, named: NamedArgs<SortableGroupModifierSignature<T>>): void;
|
|
324
|
+
}
|
|
325
|
+
export {};
|
|
326
|
+
//# sourceMappingURL=sortable-group.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sortable-group.d.ts","sourceRoot":"","sources":["../../src/modifiers/sortable-group.ts"],"names":[],"mappings":"AAEA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAYtC,OAAO,EAAiC,KAAK,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAIlG,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,oBAAoB,MAAM,8CAA8C,CAAC;AACrF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8CAA8C,CAAC;AAC1E,OAAO,KAAK,oBAAoB,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAIxD,MAAM,WAAW,iBAAiB;IAChC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,QAAQ;IAChB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,MAAM,UAAU,GAAG,GAAG,GAAG,GAAG,GAAG,MAAM,CAAC;AAE5C,UAAU,8BAA8B,CAAC,CAAC;IACxC,IAAI,EAAE;QACJ,KAAK,EAAE;YACL,SAAS,CAAC,EAAE,UAAU,CAAC;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B,CACvB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GACjB,QAAQ;IAiDX,gBAAgB,IAAI,IAAI;IAKxB,mBAAmB,IAAI,IAAI;IAK3B,OAAO,EAAG,WAAW,CAAC;IACtB,QAAQ,UAAS;IACjB,KAAK,EAAG,SAAS,CAAC,8BAA8B,CAAC,CAAC,CAAC,CAAC,CAAC;gBAEzC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,8BAA8B,CAAC,CAAC,CAAC,CAAC;IAKjE,MAAM,CACb,OAAO,EAAE,WAAW,EACpB,WAAW,EAAE,cAAc,CAAC,8BAA8B,CAAC,CAAC,CAAC,CAAC,EAC9D,KAAK,EAAE,SAAS,CAAC,8BAA8B,CAAC,CAAC,CAAC,CAAC;CAsBtD"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import Modifier from 'ember-modifier';
|
|
2
|
+
interface SortableHandleModifierSignature {
|
|
3
|
+
Element: HTMLElement;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Modifier to to mark the handle of an item. If this is not supplied the item will be the handle
|
|
7
|
+
*
|
|
8
|
+
* @module drag-drop/draggable-group
|
|
9
|
+
* @example*
|
|
10
|
+
* <ol {{sortable-group onChange=this.update a11yAnnouncementConfig=this.myA11yConfig}}>
|
|
11
|
+
* {{#each model.items as |item|}}
|
|
12
|
+
* <li {{sortable-item model=item}}>
|
|
13
|
+
* {{item.name}}
|
|
14
|
+
* <span class="handle" {{sortable-handle}}>↕</span>
|
|
15
|
+
* </li>
|
|
16
|
+
* {{/each}}
|
|
17
|
+
* </ol>
|
|
18
|
+
*/
|
|
19
|
+
export default class SortableHandleModifier extends Modifier<SortableHandleModifierSignature> {
|
|
20
|
+
didSetup: boolean;
|
|
21
|
+
modify(element: HTMLElement): void;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=sortable-handle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sortable-handle.d.ts","sourceRoot":"","sources":["../../src/modifiers/sortable-handle.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAEtC,UAAU,+BAA+B;IACvC,OAAO,EAAE,WAAW,CAAC;CACtB;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,OAAO,sBAAuB,SAAQ,QAAQ,CAAC,+BAA+B,CAAC;IAC3F,QAAQ,UAAS;IAER,MAAM,CAAC,OAAO,EAAE,WAAW;CASrC"}
|