@dhis2-ui/transfer 10.13.1 → 10.14.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/build/cjs/__e2e__/reorder-with-buttons.e2e.stories.js +15 -4
- package/build/cjs/__tests__/helper/default-filter-callback.test.js +6 -0
- package/build/cjs/__tests__/helper/is-reorder-down-disabled.test.js +50 -11
- package/build/cjs/__tests__/helper/is-reorder-up-disabled.test.js +50 -11
- package/build/cjs/__tests__/helper/move-highlighted-picked-option-down.test.js +65 -11
- package/build/cjs/__tests__/helper/move-highlighted-picked-option-to-bottom.test.js +85 -0
- package/build/cjs/__tests__/helper/move-highlighted-picked-option-to-top.test.js +85 -0
- package/build/cjs/__tests__/helper/move-highlighted-picked-option-up.test.js +65 -11
- package/build/cjs/__tests__/reordering-actions.test.js +104 -0
- package/build/cjs/features/reorder-with-buttons/index.js +70 -2
- package/build/cjs/features/reorder-with-buttons.feature +97 -5
- package/build/cjs/icons.js +53 -13
- package/build/cjs/locales/en/translations.json +7 -0
- package/build/cjs/locales/index.js +21 -0
- package/build/cjs/reordering-actions.js +93 -27
- package/build/cjs/transfer/default-filter-callback.js +17 -6
- package/build/cjs/transfer/get-highlighted-picked-indices.js +34 -0
- package/build/cjs/transfer/index.js +33 -0
- package/build/cjs/transfer/is-reorder-down-disabled.js +19 -8
- package/build/cjs/transfer/is-reorder-up-disabled.js +18 -8
- package/build/cjs/transfer/move-highlighted-picked-option-down.js +23 -6
- package/build/cjs/transfer/move-highlighted-picked-option-to-bottom.js +45 -0
- package/build/cjs/transfer/move-highlighted-picked-option-to-top.js +44 -0
- package/build/cjs/transfer/move-highlighted-picked-option-up.js +21 -6
- package/build/cjs/transfer.js +58 -6
- package/build/cjs/transfer.prod.stories.js +89 -19
- package/build/es/__e2e__/reorder-with-buttons.e2e.stories.js +14 -2
- package/build/es/__tests__/helper/default-filter-callback.test.js +6 -0
- package/build/es/__tests__/helper/is-reorder-down-disabled.test.js +50 -11
- package/build/es/__tests__/helper/is-reorder-up-disabled.test.js +50 -11
- package/build/es/__tests__/helper/move-highlighted-picked-option-down.test.js +65 -11
- package/build/es/__tests__/helper/move-highlighted-picked-option-to-bottom.test.js +83 -0
- package/build/es/__tests__/helper/move-highlighted-picked-option-to-top.test.js +83 -0
- package/build/es/__tests__/helper/move-highlighted-picked-option-up.test.js +65 -11
- package/build/es/__tests__/reordering-actions.test.js +101 -0
- package/build/es/features/reorder-with-buttons/index.js +70 -2
- package/build/es/features/reorder-with-buttons.feature +97 -5
- package/build/es/icons.js +51 -13
- package/build/es/locales/en/translations.json +7 -0
- package/build/es/locales/index.js +13 -0
- package/build/es/reordering-actions.js +94 -28
- package/build/es/transfer/default-filter-callback.js +17 -6
- package/build/es/transfer/get-highlighted-picked-indices.js +27 -0
- package/build/es/transfer/index.js +3 -0
- package/build/es/transfer/is-reorder-down-disabled.js +20 -8
- package/build/es/transfer/is-reorder-up-disabled.js +19 -8
- package/build/es/transfer/move-highlighted-picked-option-down.js +24 -6
- package/build/es/transfer/move-highlighted-picked-option-to-bottom.js +39 -0
- package/build/es/transfer/move-highlighted-picked-option-to-top.js +38 -0
- package/build/es/transfer/move-highlighted-picked-option-up.js +22 -6
- package/build/es/transfer.js +60 -8
- package/build/es/transfer.prod.stories.js +88 -18
- package/package.json +9 -7
|
@@ -1,4 +1,11 @@
|
|
|
1
|
+
import { getHighlightedPickedIndices } from './get-highlighted-picked-indices.js';
|
|
2
|
+
|
|
1
3
|
/**
|
|
4
|
+
* Moves the highlighted picked options down by one slot as a group.
|
|
5
|
+
* If the selection is non-contiguous, the group collapses into a contiguous
|
|
6
|
+
* block (preserving relative order) with its bottom edge landing at
|
|
7
|
+
* `min(selected.length - 1, bottommostHighlightedIndex + 1)`.
|
|
8
|
+
*
|
|
2
9
|
* @param {Object} args
|
|
3
10
|
* @param {string[]} args.selected
|
|
4
11
|
* @param {string[]} args.highlightedPickedOptions
|
|
@@ -11,15 +18,26 @@ export const moveHighlightedPickedOptionDown = _ref => {
|
|
|
11
18
|
highlightedPickedOptions,
|
|
12
19
|
onChange
|
|
13
20
|
} = _ref;
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
const indices = getHighlightedPickedIndices({
|
|
22
|
+
selected,
|
|
23
|
+
highlightedPickedOptions
|
|
24
|
+
});
|
|
25
|
+
if (indices.length === 0) {
|
|
18
26
|
return;
|
|
19
27
|
}
|
|
28
|
+
const lastIndex = selected.length - 1;
|
|
20
29
|
|
|
21
|
-
//
|
|
22
|
-
|
|
30
|
+
// Already flush to the bottom — nothing to do
|
|
31
|
+
if (indices.every((index, i) => index === lastIndex - (indices.length - 1 - i))) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const indexSet = new Set(indices);
|
|
35
|
+
const highlightedBlock = indices.map(index => selected[index]);
|
|
36
|
+
const remaining = selected.filter((_, index) => !indexSet.has(index));
|
|
37
|
+
const bottommost = indices.at(-1);
|
|
38
|
+
const targetBottom = Math.min(lastIndex, bottommost + 1);
|
|
39
|
+
const insertPos = targetBottom - (indices.length - 1);
|
|
40
|
+
const reordered = [...remaining.slice(0, insertPos), ...highlightedBlock, ...remaining.slice(insertPos)];
|
|
23
41
|
onChange({
|
|
24
42
|
selected: reordered
|
|
25
43
|
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { getHighlightedPickedIndices } from './get-highlighted-picked-indices.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Moves the highlighted picked options to the very bottom of the list as a
|
|
5
|
+
* single contiguous block, preserving their relative order. Non-contiguous
|
|
6
|
+
* selections are collapsed.
|
|
7
|
+
*
|
|
8
|
+
* @param {Object} args
|
|
9
|
+
* @param {string[]} args.selected
|
|
10
|
+
* @param {string[]} args.highlightedPickedOptions
|
|
11
|
+
* @param {Function} args.onChange
|
|
12
|
+
* @returns {void}
|
|
13
|
+
*/
|
|
14
|
+
export const moveHighlightedPickedOptionToBottom = _ref => {
|
|
15
|
+
let {
|
|
16
|
+
selected,
|
|
17
|
+
highlightedPickedOptions,
|
|
18
|
+
onChange
|
|
19
|
+
} = _ref;
|
|
20
|
+
const indices = getHighlightedPickedIndices({
|
|
21
|
+
selected,
|
|
22
|
+
highlightedPickedOptions
|
|
23
|
+
});
|
|
24
|
+
if (indices.length === 0) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const lastIndex = selected.length - 1;
|
|
28
|
+
|
|
29
|
+
// Already a contiguous block flush to the bottom — nothing to do
|
|
30
|
+
if (indices.every((index, i) => index === lastIndex - (indices.length - 1 - i))) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const indexSet = new Set(indices);
|
|
34
|
+
const highlightedBlock = indices.map(index => selected[index]);
|
|
35
|
+
const remaining = selected.filter((_, index) => !indexSet.has(index));
|
|
36
|
+
onChange({
|
|
37
|
+
selected: [...remaining, ...highlightedBlock]
|
|
38
|
+
});
|
|
39
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { getHighlightedPickedIndices } from './get-highlighted-picked-indices.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Moves the highlighted picked options to the very top of the list as a
|
|
5
|
+
* single contiguous block, preserving their relative order. Non-contiguous
|
|
6
|
+
* selections are collapsed.
|
|
7
|
+
*
|
|
8
|
+
* @param {Object} args
|
|
9
|
+
* @param {string[]} args.selected
|
|
10
|
+
* @param {string[]} args.highlightedPickedOptions
|
|
11
|
+
* @param {Function} args.onChange
|
|
12
|
+
* @returns {void}
|
|
13
|
+
*/
|
|
14
|
+
export const moveHighlightedPickedOptionToTop = _ref => {
|
|
15
|
+
let {
|
|
16
|
+
selected,
|
|
17
|
+
highlightedPickedOptions,
|
|
18
|
+
onChange
|
|
19
|
+
} = _ref;
|
|
20
|
+
const indices = getHighlightedPickedIndices({
|
|
21
|
+
selected,
|
|
22
|
+
highlightedPickedOptions
|
|
23
|
+
});
|
|
24
|
+
if (indices.length === 0) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Already a contiguous block flush to the top — nothing to do
|
|
29
|
+
if (indices.every((index, i) => index === i)) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const indexSet = new Set(indices);
|
|
33
|
+
const highlightedBlock = indices.map(index => selected[index]);
|
|
34
|
+
const remaining = selected.filter((_, index) => !indexSet.has(index));
|
|
35
|
+
onChange({
|
|
36
|
+
selected: [...highlightedBlock, ...remaining]
|
|
37
|
+
});
|
|
38
|
+
};
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
+
import { getHighlightedPickedIndices } from './get-highlighted-picked-indices.js';
|
|
2
|
+
|
|
1
3
|
/**
|
|
4
|
+
* Moves the highlighted picked options up by one slot as a group.
|
|
5
|
+
* If the selection is non-contiguous, the group collapses into a contiguous
|
|
6
|
+
* block (preserving relative order) with its top edge landing at
|
|
7
|
+
* `max(0, topmostHighlightedIndex - 1)`.
|
|
8
|
+
*
|
|
2
9
|
* @param {Object} args
|
|
3
10
|
* @param {string[]} args.selected
|
|
4
11
|
* @param {string[]} args.highlightedPickedOptions
|
|
@@ -11,15 +18,24 @@ export const moveHighlightedPickedOptionUp = _ref => {
|
|
|
11
18
|
highlightedPickedOptions,
|
|
12
19
|
onChange
|
|
13
20
|
} = _ref;
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
const indices = getHighlightedPickedIndices({
|
|
22
|
+
selected,
|
|
23
|
+
highlightedPickedOptions
|
|
24
|
+
});
|
|
25
|
+
if (indices.length === 0) {
|
|
18
26
|
return;
|
|
19
27
|
}
|
|
20
28
|
|
|
21
|
-
//
|
|
22
|
-
|
|
29
|
+
// Already flush to the top — nothing to do
|
|
30
|
+
if (indices.every((index, i) => index === i)) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const indexSet = new Set(indices);
|
|
34
|
+
const highlightedBlock = indices.map(index => selected[index]);
|
|
35
|
+
const remaining = selected.filter((_, index) => !indexSet.has(index));
|
|
36
|
+
const topmost = indices[0];
|
|
37
|
+
const insertPos = Math.max(0, topmost - 1);
|
|
38
|
+
const reordered = [...remaining.slice(0, insertPos), ...highlightedBlock, ...remaining.slice(insertPos)];
|
|
23
39
|
onChange({
|
|
24
40
|
selected: reordered
|
|
25
41
|
});
|
package/build/es/transfer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
|
-
import React, { useMemo } from 'react';
|
|
2
|
+
import React, { useEffect, useMemo, useRef } from 'react';
|
|
3
3
|
import { Actions } from './actions.js';
|
|
4
4
|
import { AddAll } from './add-all.js';
|
|
5
5
|
import { AddIndividual } from './add-individual.js';
|
|
@@ -15,7 +15,7 @@ import { ReorderingActions } from './reordering-actions.js';
|
|
|
15
15
|
import { RightFooter } from './right-footer.js';
|
|
16
16
|
import { RightHeader } from './right-header.js';
|
|
17
17
|
import { RightSide } from './right-side.js';
|
|
18
|
-
import { addAllSelectableSourceOptions, addIndividualSourceOptions, createDoubleClickHandlers, defaultFilterCallback, getOptionClickHandlers, isReorderDownDisabled, isReorderUpDisabled, moveHighlightedPickedOptionDown, moveHighlightedPickedOptionUp, removeAllPickedOptions, removeIndividualPickedOptions, useFilter, useHighlightedOptions } from './transfer/index.js';
|
|
18
|
+
import { addAllSelectableSourceOptions, addIndividualSourceOptions, createDoubleClickHandlers, defaultFilterCallback, getOptionClickHandlers, isReorderDownDisabled, isReorderUpDisabled, moveHighlightedPickedOptionDown, moveHighlightedPickedOptionToBottom, moveHighlightedPickedOptionToTop, moveHighlightedPickedOptionUp, removeAllPickedOptions, removeIndividualPickedOptions, useFilter, useHighlightedOptions } from './transfer/index.js';
|
|
19
19
|
import { TransferOption } from './transfer-option.js';
|
|
20
20
|
const identity = value => value;
|
|
21
21
|
const defaultSelected = [];
|
|
@@ -121,6 +121,7 @@ export const Transfer = _ref => {
|
|
|
121
121
|
externalSearchTerm: searchTermPicked,
|
|
122
122
|
filterCallback: filterCallbackPicked
|
|
123
123
|
});
|
|
124
|
+
const filterActivePicked = Boolean(actualFilterPicked);
|
|
124
125
|
|
|
125
126
|
/*
|
|
126
127
|
* Actual picked options:
|
|
@@ -165,6 +166,26 @@ export const Transfer = _ref => {
|
|
|
165
166
|
maxSelections
|
|
166
167
|
});
|
|
167
168
|
|
|
169
|
+
/*
|
|
170
|
+
* Reorder scroll-into-view:
|
|
171
|
+
* After a reorder move, scroll the moved block so the leading edge
|
|
172
|
+
* (top on Up, bottom on Down) is visible inside the picked-side
|
|
173
|
+
* scroll container. `block: 'nearest'` means no scroll when the
|
|
174
|
+
* element is already fully in view.
|
|
175
|
+
*/
|
|
176
|
+
const reorderScrollTargetRef = useRef(null);
|
|
177
|
+
useEffect(() => {
|
|
178
|
+
const target = reorderScrollTargetRef.current;
|
|
179
|
+
if (target == null) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
reorderScrollTargetRef.current = null;
|
|
183
|
+
const element = document.querySelector(`[data-test="${dataTest}-pickedoptions"] [data-value="${CSS.escape(target)}"]`);
|
|
184
|
+
element === null || element === void 0 ? void 0 : element.scrollIntoView({
|
|
185
|
+
block: 'nearest'
|
|
186
|
+
});
|
|
187
|
+
}, [selected, dataTest]);
|
|
188
|
+
|
|
168
189
|
/**
|
|
169
190
|
* Disabled button states
|
|
170
191
|
*/
|
|
@@ -301,25 +322,56 @@ export const Transfer = _ref => {
|
|
|
301
322
|
dataTest: `${dataTest}-rightfooter`
|
|
302
323
|
}, enableOrderChange && /*#__PURE__*/React.createElement(ReorderingActions, {
|
|
303
324
|
dataTest: `${dataTest}-reorderingactions`,
|
|
325
|
+
filterActive: filterActivePicked,
|
|
304
326
|
disabledDown: isReorderDownDisabled({
|
|
305
327
|
highlightedPickedOptions,
|
|
306
|
-
selected
|
|
328
|
+
selected,
|
|
329
|
+
filterActivePicked
|
|
307
330
|
}),
|
|
308
331
|
disabledUp: isReorderUpDisabled({
|
|
309
332
|
highlightedPickedOptions,
|
|
310
|
-
selected
|
|
311
|
-
}),
|
|
312
|
-
onChangeUp: () => moveHighlightedPickedOptionUp({
|
|
313
333
|
selected,
|
|
314
|
-
|
|
315
|
-
onChange
|
|
334
|
+
filterActivePicked
|
|
316
335
|
}),
|
|
336
|
+
onChangeUp: () => {
|
|
337
|
+
var _selected$find;
|
|
338
|
+
const highlightedSet = new Set(highlightedPickedOptions);
|
|
339
|
+
reorderScrollTargetRef.current = (_selected$find = selected.find(value => highlightedSet.has(value))) !== null && _selected$find !== void 0 ? _selected$find : null;
|
|
340
|
+
moveHighlightedPickedOptionUp({
|
|
341
|
+
selected,
|
|
342
|
+
highlightedPickedOptions,
|
|
343
|
+
onChange
|
|
344
|
+
});
|
|
345
|
+
},
|
|
317
346
|
onChangeDown: () => {
|
|
347
|
+
var _selected$findLast;
|
|
348
|
+
const highlightedSet = new Set(highlightedPickedOptions);
|
|
349
|
+
reorderScrollTargetRef.current = (_selected$findLast = selected.findLast(value => highlightedSet.has(value))) !== null && _selected$findLast !== void 0 ? _selected$findLast : null;
|
|
318
350
|
moveHighlightedPickedOptionDown({
|
|
319
351
|
selected,
|
|
320
352
|
highlightedPickedOptions,
|
|
321
353
|
onChange
|
|
322
354
|
});
|
|
355
|
+
},
|
|
356
|
+
onChangeToTop: () => {
|
|
357
|
+
var _selected$find2;
|
|
358
|
+
const highlightedSet = new Set(highlightedPickedOptions);
|
|
359
|
+
reorderScrollTargetRef.current = (_selected$find2 = selected.find(value => highlightedSet.has(value))) !== null && _selected$find2 !== void 0 ? _selected$find2 : null;
|
|
360
|
+
moveHighlightedPickedOptionToTop({
|
|
361
|
+
selected,
|
|
362
|
+
highlightedPickedOptions,
|
|
363
|
+
onChange
|
|
364
|
+
});
|
|
365
|
+
},
|
|
366
|
+
onChangeToBottom: () => {
|
|
367
|
+
var _selected$findLast2;
|
|
368
|
+
const highlightedSet = new Set(highlightedPickedOptions);
|
|
369
|
+
reorderScrollTargetRef.current = (_selected$findLast2 = selected.findLast(value => highlightedSet.has(value))) !== null && _selected$findLast2 !== void 0 ? _selected$findLast2 : null;
|
|
370
|
+
moveHighlightedPickedOptionToBottom({
|
|
371
|
+
selected,
|
|
372
|
+
highlightedPickedOptions,
|
|
373
|
+
onChange
|
|
374
|
+
});
|
|
323
375
|
}
|
|
324
376
|
}), rightFooter)));
|
|
325
377
|
};
|
|
@@ -302,14 +302,84 @@ PickedEmptyComponent.args = {
|
|
|
302
302
|
export const Reordering = StatefulTemplate.bind({});
|
|
303
303
|
Reordering.args = {
|
|
304
304
|
enableOrderChange: true,
|
|
305
|
-
options: options.slice(0,
|
|
306
|
-
initiallySelected: options.slice(0,
|
|
305
|
+
options: options.slice(0, 20),
|
|
306
|
+
initiallySelected: options.slice(0, 8).map(_ref6 => {
|
|
307
307
|
let {
|
|
308
308
|
value
|
|
309
309
|
} = _ref6;
|
|
310
310
|
return value;
|
|
311
311
|
})
|
|
312
312
|
};
|
|
313
|
+
export const ReorderingWithPickedFilter = StatefulTemplate.bind({});
|
|
314
|
+
ReorderingWithPickedFilter.storyName = 'Reordering with picked filter';
|
|
315
|
+
ReorderingWithPickedFilter.args = {
|
|
316
|
+
enableOrderChange: true,
|
|
317
|
+
filterablePicked: true,
|
|
318
|
+
filterPlaceholderPicked: 'Search picked options',
|
|
319
|
+
options: options.slice(0, 20),
|
|
320
|
+
initiallySelected: options.slice(0, 8).map(_ref7 => {
|
|
321
|
+
let {
|
|
322
|
+
value
|
|
323
|
+
} = _ref7;
|
|
324
|
+
return value;
|
|
325
|
+
})
|
|
326
|
+
};
|
|
327
|
+
const ReorderingWithRightFooterTemplate = _ref8 => {
|
|
328
|
+
let {
|
|
329
|
+
initiallySelected = [],
|
|
330
|
+
...args
|
|
331
|
+
} = _ref8;
|
|
332
|
+
const [selected, setSelected] = useState(initiallySelected);
|
|
333
|
+
const onChange = payload => setSelected(payload.selected);
|
|
334
|
+
return /*#__PURE__*/React.createElement(Transfer, _extends({}, args, {
|
|
335
|
+
selected: selected,
|
|
336
|
+
onChange: onChange,
|
|
337
|
+
rightFooter: /*#__PURE__*/React.createElement("span", {
|
|
338
|
+
style: {
|
|
339
|
+
padding: '0 8px'
|
|
340
|
+
}
|
|
341
|
+
}, "Right footer content")
|
|
342
|
+
}));
|
|
343
|
+
};
|
|
344
|
+
ReorderingWithRightFooterTemplate.propTypes = {
|
|
345
|
+
initiallySelected: PropTypes.array
|
|
346
|
+
};
|
|
347
|
+
export const ReorderingWithRightFooterContent = ReorderingWithRightFooterTemplate.bind({});
|
|
348
|
+
ReorderingWithRightFooterContent.storyName = 'Reordering with right footer content';
|
|
349
|
+
ReorderingWithRightFooterContent.args = {
|
|
350
|
+
enableOrderChange: true,
|
|
351
|
+
options: options.slice(0, 20),
|
|
352
|
+
initiallySelected: options.slice(0, 8).map(_ref9 => {
|
|
353
|
+
let {
|
|
354
|
+
value
|
|
355
|
+
} = _ref9;
|
|
356
|
+
return value;
|
|
357
|
+
})
|
|
358
|
+
};
|
|
359
|
+
export const ReorderingWithCustomOptions = StatefulTemplateCustomRenderOption.bind({});
|
|
360
|
+
ReorderingWithCustomOptions.storyName = 'Reordering with custom options';
|
|
361
|
+
ReorderingWithCustomOptions.args = {
|
|
362
|
+
enableOrderChange: true,
|
|
363
|
+
options: options.slice(0, 20),
|
|
364
|
+
initiallySelected: options.slice(0, 8).map(_ref10 => {
|
|
365
|
+
let {
|
|
366
|
+
value
|
|
367
|
+
} = _ref10;
|
|
368
|
+
return value;
|
|
369
|
+
}),
|
|
370
|
+
renderOption: option => {
|
|
371
|
+
if (option.value === options[0].value) {
|
|
372
|
+
return renderOption(option);
|
|
373
|
+
}
|
|
374
|
+
if (option.value === options[2].value) {
|
|
375
|
+
return renderOption(option);
|
|
376
|
+
}
|
|
377
|
+
if (option.value === options[5].value) {
|
|
378
|
+
return renderOption(option);
|
|
379
|
+
}
|
|
380
|
+
return /*#__PURE__*/React.createElement(TransferOption, option);
|
|
381
|
+
}
|
|
382
|
+
};
|
|
313
383
|
export const IncreasedOptionsHeight = StatefulTemplate.bind({});
|
|
314
384
|
IncreasedOptionsHeight.args = {
|
|
315
385
|
maxSelections: Infinity,
|
|
@@ -333,13 +403,13 @@ const createCustomFilteringInHeader = hideFilterInput => {
|
|
|
333
403
|
year: index < 5 ? '2020' : '2019'
|
|
334
404
|
}));
|
|
335
405
|
const allOptions = [...relativePeriods, ...fixedPeriods];
|
|
336
|
-
const Header =
|
|
406
|
+
const Header = _ref11 => {
|
|
337
407
|
let {
|
|
338
408
|
onClick,
|
|
339
409
|
relativePeriod,
|
|
340
410
|
selectedYear,
|
|
341
411
|
onSelectedYearChange
|
|
342
|
-
} =
|
|
412
|
+
} = _ref11;
|
|
343
413
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TabBar, null, /*#__PURE__*/React.createElement(Tab, {
|
|
344
414
|
selected: relativePeriod,
|
|
345
415
|
onClick: () => onClick({
|
|
@@ -379,26 +449,26 @@ const createCustomFilteringInHeader = hideFilterInput => {
|
|
|
379
449
|
if (filter === '') {
|
|
380
450
|
return optionsWithPeriod;
|
|
381
451
|
}
|
|
382
|
-
return optionsWithPeriod.filter(
|
|
452
|
+
return optionsWithPeriod.filter(_ref12 => {
|
|
383
453
|
let {
|
|
384
454
|
label
|
|
385
|
-
} =
|
|
455
|
+
} = _ref12;
|
|
386
456
|
return label.indexOf(filter) !== -1;
|
|
387
457
|
});
|
|
388
458
|
};
|
|
389
459
|
const header = /*#__PURE__*/React.createElement(Header, {
|
|
390
460
|
relativePeriod: relativePeriod,
|
|
391
461
|
selectedYear: year,
|
|
392
|
-
onSelectedYearChange:
|
|
462
|
+
onSelectedYearChange: _ref13 => {
|
|
393
463
|
let {
|
|
394
464
|
selected
|
|
395
|
-
} =
|
|
465
|
+
} = _ref13;
|
|
396
466
|
return setYear(selected);
|
|
397
467
|
},
|
|
398
|
-
onClick:
|
|
468
|
+
onClick: _ref14 => {
|
|
399
469
|
let {
|
|
400
470
|
relativePeriod: newRelativePeriod
|
|
401
|
-
} =
|
|
471
|
+
} = _ref14;
|
|
402
472
|
return setRelativePeriod(newRelativePeriod);
|
|
403
473
|
}
|
|
404
474
|
});
|
|
@@ -410,10 +480,10 @@ const createCustomFilteringInHeader = hideFilterInput => {
|
|
|
410
480
|
filterCallback: filterCallback,
|
|
411
481
|
leftHeader: header,
|
|
412
482
|
rightHeader: /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("b", null, "Selected Periods")),
|
|
413
|
-
onFilterChange:
|
|
483
|
+
onFilterChange: _ref15 => {
|
|
414
484
|
let {
|
|
415
485
|
value
|
|
416
|
-
} =
|
|
486
|
+
} = _ref15;
|
|
417
487
|
return setFilter(value);
|
|
418
488
|
},
|
|
419
489
|
height: "400px",
|
|
@@ -421,11 +491,11 @@ const createCustomFilteringInHeader = hideFilterInput => {
|
|
|
421
491
|
filterPlaceholder: "Search"
|
|
422
492
|
}));
|
|
423
493
|
};
|
|
424
|
-
return
|
|
494
|
+
return _ref16 => {
|
|
425
495
|
let {
|
|
426
496
|
initiallySelected,
|
|
427
497
|
...args
|
|
428
|
-
} =
|
|
498
|
+
} = _ref16;
|
|
429
499
|
const [selected, setSelected] = useState(initiallySelected);
|
|
430
500
|
const onChange = payload => setSelected(payload.selected);
|
|
431
501
|
return /*#__PURE__*/React.createElement(CustomTransfer, _extends({}, args, {
|
|
@@ -459,10 +529,10 @@ export const InfiniteLoading = args => {
|
|
|
459
529
|
// selected options
|
|
460
530
|
const [selected] = useState(
|
|
461
531
|
// Last 4 options preselected
|
|
462
|
-
preSelectedOptions.map(
|
|
532
|
+
preSelectedOptions.map(_ref17 => {
|
|
463
533
|
let {
|
|
464
534
|
value
|
|
465
|
-
} =
|
|
535
|
+
} = _ref17;
|
|
466
536
|
return value;
|
|
467
537
|
}));
|
|
468
538
|
const selectedOptionsLookup = useMemo(() => preSelectedOptions.reduce((lookup, option) => {
|
|
@@ -503,10 +573,10 @@ export const LoadingPicked = StatefulTemplate.bind({});
|
|
|
503
573
|
LoadingPicked.args = {
|
|
504
574
|
loadingPicked: true,
|
|
505
575
|
options: options.slice(0, 3),
|
|
506
|
-
initiallySelected: options.slice(0, 2).map(
|
|
576
|
+
initiallySelected: options.slice(0, 2).map(_ref18 => {
|
|
507
577
|
let {
|
|
508
578
|
value
|
|
509
|
-
} =
|
|
579
|
+
} = _ref18;
|
|
510
580
|
return value;
|
|
511
581
|
})
|
|
512
582
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhis2-ui/transfer",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.14.0",
|
|
4
4
|
"description": "UI Transfer",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,18 +27,20 @@
|
|
|
27
27
|
"test": "d2-app-scripts test --jestConfig ../../jest.config.shared.js"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
+
"@dhis2/d2-i18n": "^1",
|
|
30
31
|
"react": "^16.13 || ^18",
|
|
31
32
|
"react-dom": "^16.13 || ^18",
|
|
32
33
|
"styled-jsx": "^4"
|
|
33
34
|
},
|
|
34
35
|
"dependencies": {
|
|
35
36
|
"@dhis2/prop-types": "^3.1.2",
|
|
36
|
-
"@dhis2-ui/button": "10.
|
|
37
|
-
"@dhis2-ui/field": "10.
|
|
38
|
-
"@dhis2-ui/input": "10.
|
|
39
|
-
"@dhis2-ui/intersection-detector": "10.
|
|
40
|
-
"@dhis2-ui/loader": "10.
|
|
41
|
-
"@dhis2/
|
|
37
|
+
"@dhis2-ui/button": "10.14.0",
|
|
38
|
+
"@dhis2-ui/field": "10.14.0",
|
|
39
|
+
"@dhis2-ui/input": "10.14.0",
|
|
40
|
+
"@dhis2-ui/intersection-detector": "10.14.0",
|
|
41
|
+
"@dhis2-ui/loader": "10.14.0",
|
|
42
|
+
"@dhis2-ui/tooltip": "10.14.0",
|
|
43
|
+
"@dhis2/ui-constants": "10.14.0",
|
|
42
44
|
"classnames": "^2.3.1",
|
|
43
45
|
"prop-types": "^15.7.2"
|
|
44
46
|
},
|