@cdx-ui/components 0.2.2 → 0.2.3
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 +4 -2
- package/coverage.svg +1 -1
- package/lib/commonjs/components/Checkbox/index.js.map +1 -1
- package/lib/commonjs/components/Heading/index.js.map +1 -1
- package/lib/commonjs/components/Icon/index.js.map +1 -1
- package/lib/commonjs/components/ListItem/index.js +170 -9
- package/lib/commonjs/components/ListItem/index.js.map +1 -1
- package/lib/commonjs/components/ListItem/styles.js +36 -1
- package/lib/commonjs/components/ListItem/styles.js.map +1 -1
- package/lib/commonjs/components/Menu/index.js.map +1 -1
- package/lib/commonjs/components/RangeCalendar/index.js.map +1 -1
- package/lib/commonjs/components/ReorderableList/ReorderableListShared.js +91 -0
- package/lib/commonjs/components/ReorderableList/ReorderableListShared.js.map +1 -0
- package/lib/commonjs/components/ReorderableList/index.js +135 -0
- package/lib/commonjs/components/ReorderableList/index.js.map +1 -0
- package/lib/commonjs/components/ReorderableList/index.web.js +233 -0
- package/lib/commonjs/components/ReorderableList/index.web.js.map +1 -0
- package/lib/commonjs/components/ReorderableList/labels.js +47 -0
- package/lib/commonjs/components/ReorderableList/labels.js.map +1 -0
- package/lib/commonjs/components/ReorderableList/reorderItems.js +16 -0
- package/lib/commonjs/components/ReorderableList/reorderItems.js.map +1 -0
- package/lib/commonjs/components/ReorderableList/rowContext.js +42 -0
- package/lib/commonjs/components/ReorderableList/rowContext.js.map +1 -0
- package/lib/commonjs/components/ReorderableList/types.js +6 -0
- package/lib/commonjs/components/ReorderableList/types.js.map +1 -0
- package/lib/commonjs/components/ReorderableList/useReorder.js +131 -0
- package/lib/commonjs/components/ReorderableList/useReorder.js.map +1 -0
- package/lib/commonjs/components/ReorderableList/webDnd.js +64 -0
- package/lib/commonjs/components/ReorderableList/webDnd.js.map +1 -0
- package/lib/commonjs/components/ScopedTheme/index.js.map +1 -1
- package/lib/commonjs/components/Skeleton/index.js.map +1 -1
- package/lib/commonjs/components/TablePagination/index.js.map +1 -1
- package/lib/commonjs/components/Text/index.js.map +1 -1
- package/lib/commonjs/components/Tile/styles.js +1 -1
- package/lib/commonjs/components/Tile/styles.js.map +1 -1
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/reorderable-list.js +17 -0
- package/lib/commonjs/reorderable-list.js.map +1 -0
- package/lib/module/components/Checkbox/index.js.map +1 -1
- package/lib/module/components/Heading/index.js.map +1 -1
- package/lib/module/components/Icon/index.js.map +1 -1
- package/lib/module/components/ListItem/index.js +163 -14
- package/lib/module/components/ListItem/index.js.map +1 -1
- package/lib/module/components/ListItem/styles.js +35 -0
- package/lib/module/components/ListItem/styles.js.map +1 -1
- package/lib/module/components/Menu/index.js.map +1 -1
- package/lib/module/components/RangeCalendar/index.js.map +1 -1
- package/lib/module/components/ReorderableList/ReorderableListShared.js +86 -0
- package/lib/module/components/ReorderableList/ReorderableListShared.js.map +1 -0
- package/lib/module/components/ReorderableList/index.js +130 -0
- package/lib/module/components/ReorderableList/index.js.map +1 -0
- package/lib/module/components/ReorderableList/index.web.js +229 -0
- package/lib/module/components/ReorderableList/index.web.js.map +1 -0
- package/lib/module/components/ReorderableList/labels.js +41 -0
- package/lib/module/components/ReorderableList/labels.js.map +1 -0
- package/lib/module/components/ReorderableList/reorderItems.js +12 -0
- package/lib/module/components/ReorderableList/reorderItems.js.map +1 -0
- package/lib/module/components/ReorderableList/rowContext.js +38 -0
- package/lib/module/components/ReorderableList/rowContext.js.map +1 -0
- package/lib/module/components/ReorderableList/types.js +4 -0
- package/lib/module/components/ReorderableList/types.js.map +1 -0
- package/lib/module/components/ReorderableList/useReorder.js +123 -0
- package/lib/module/components/ReorderableList/useReorder.js.map +1 -0
- package/lib/module/components/ReorderableList/webDnd.js +59 -0
- package/lib/module/components/ReorderableList/webDnd.js.map +1 -0
- package/lib/module/components/ScopedTheme/index.js.map +1 -1
- package/lib/module/components/Skeleton/index.js.map +1 -1
- package/lib/module/components/TablePagination/index.js.map +1 -1
- package/lib/module/components/Text/index.js.map +1 -1
- package/lib/module/components/Tile/styles.js +1 -1
- package/lib/module/components/Tile/styles.js.map +1 -1
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/reorderable-list.js +4 -0
- package/lib/module/reorderable-list.js.map +1 -0
- package/lib/typescript/components/Checkbox/index.d.ts +22 -0
- package/lib/typescript/components/Checkbox/index.d.ts.map +1 -1
- package/lib/typescript/components/Heading/index.d.ts +20 -2
- package/lib/typescript/components/Heading/index.d.ts.map +1 -1
- package/lib/typescript/components/Icon/index.d.ts +2 -0
- package/lib/typescript/components/Icon/index.d.ts.map +1 -1
- package/lib/typescript/components/ListItem/index.d.ts +23 -1
- package/lib/typescript/components/ListItem/index.d.ts.map +1 -1
- package/lib/typescript/components/ListItem/styles.d.ts +5 -0
- package/lib/typescript/components/ListItem/styles.d.ts.map +1 -1
- package/lib/typescript/components/Menu/index.d.ts +116 -4
- package/lib/typescript/components/Menu/index.d.ts.map +1 -1
- package/lib/typescript/components/RangeCalendar/index.d.ts +2 -0
- package/lib/typescript/components/RangeCalendar/index.d.ts.map +1 -1
- package/lib/typescript/components/ReorderableList/ReorderableListShared.d.ts +31 -0
- package/lib/typescript/components/ReorderableList/ReorderableListShared.d.ts.map +1 -0
- package/lib/typescript/components/ReorderableList/index.d.ts +8 -0
- package/lib/typescript/components/ReorderableList/index.d.ts.map +1 -0
- package/lib/typescript/components/ReorderableList/index.web.d.ts +8 -0
- package/lib/typescript/components/ReorderableList/index.web.d.ts.map +1 -0
- package/lib/typescript/components/ReorderableList/labels.d.ts +16 -0
- package/lib/typescript/components/ReorderableList/labels.d.ts.map +1 -0
- package/lib/typescript/components/ReorderableList/reorderItems.d.ts +3 -0
- package/lib/typescript/components/ReorderableList/reorderItems.d.ts.map +1 -0
- package/lib/typescript/components/ReorderableList/rowContext.d.ts +57 -0
- package/lib/typescript/components/ReorderableList/rowContext.d.ts.map +1 -0
- package/lib/typescript/components/ReorderableList/types.d.ts +75 -0
- package/lib/typescript/components/ReorderableList/types.d.ts.map +1 -0
- package/lib/typescript/components/ReorderableList/useReorder.d.ts +31 -0
- package/lib/typescript/components/ReorderableList/useReorder.d.ts.map +1 -0
- package/lib/typescript/components/ReorderableList/webDnd.d.ts +27 -0
- package/lib/typescript/components/ReorderableList/webDnd.d.ts.map +1 -0
- package/lib/typescript/components/ScopedTheme/index.d.ts +6 -1
- package/lib/typescript/components/ScopedTheme/index.d.ts.map +1 -1
- package/lib/typescript/components/Skeleton/index.d.ts +3 -0
- package/lib/typescript/components/Skeleton/index.d.ts.map +1 -1
- package/lib/typescript/components/TablePagination/index.d.ts +54 -0
- package/lib/typescript/components/TablePagination/index.d.ts.map +1 -1
- package/lib/typescript/components/Text/index.d.ts +12 -2
- package/lib/typescript/components/Text/index.d.ts.map +1 -1
- package/lib/typescript/components/Tile/styles.d.ts.map +1 -1
- package/lib/typescript/components/ToggleButton/styles.d.ts +1 -1
- package/lib/typescript/components/index.d.ts +1 -0
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/lib/typescript/reorderable-list.d.ts +2 -0
- package/lib/typescript/reorderable-list.d.ts.map +1 -0
- package/package.json +34 -7
- package/src/components/Checkbox/index.tsx +22 -0
- package/src/components/Heading/index.tsx +10 -1
- package/src/components/Icon/index.tsx +2 -0
- package/src/components/ListItem/index.tsx +227 -11
- package/src/components/ListItem/styles.ts +40 -0
- package/src/components/Menu/index.tsx +117 -4
- package/src/components/RangeCalendar/index.tsx +2 -0
- package/src/components/ReorderableList/ReorderableListShared.tsx +113 -0
- package/src/components/ReorderableList/index.tsx +162 -0
- package/src/components/ReorderableList/index.web.tsx +254 -0
- package/src/components/ReorderableList/labels.ts +52 -0
- package/src/components/ReorderableList/reorderItems.ts +16 -0
- package/src/components/ReorderableList/rowContext.tsx +72 -0
- package/src/components/ReorderableList/types.ts +80 -0
- package/src/components/ReorderableList/useReorder.ts +159 -0
- package/src/components/ReorderableList/webDnd.ts +60 -0
- package/src/components/ScopedTheme/index.tsx +6 -1
- package/src/components/Skeleton/index.tsx +3 -0
- package/src/components/TablePagination/index.tsx +54 -0
- package/src/components/Text/index.tsx +6 -1
- package/src/components/Tile/styles.ts +4 -1
- package/src/components/index.ts +5 -0
- package/src/reorderable-list.ts +1 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ReorderableListShared = void 0;
|
|
7
|
+
exports.flexLonghands = flexLonghands;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _reactNative = require("react-native");
|
|
10
|
+
var _primitives = require("@cdx-ui/primitives");
|
|
11
|
+
var _useReorder = require("./useReorder");
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
let hasWarnedDuplicateKeys = false;
|
|
14
|
+
const styles = _reactNative.StyleSheet.create({
|
|
15
|
+
root: {
|
|
16
|
+
flexGrow: 0,
|
|
17
|
+
minHeight: 0
|
|
18
|
+
},
|
|
19
|
+
content: {
|
|
20
|
+
flexGrow: 0
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Longhands for a consumer `flex`, placed between the `flexGrow: 0` default and the consumer style.
|
|
26
|
+
* Yoga lets a longhand beat the shorthand, so `flex: 1` alone keeps grow 0 with basis 0 and the
|
|
27
|
+
* list collapses to zero height.
|
|
28
|
+
*/
|
|
29
|
+
function flexLonghands(flex) {
|
|
30
|
+
if (flex === undefined) return undefined;
|
|
31
|
+
if (flex > 0) return {
|
|
32
|
+
flexGrow: flex,
|
|
33
|
+
flexShrink: 1,
|
|
34
|
+
flexBasis: 0
|
|
35
|
+
};
|
|
36
|
+
if (flex < 0) return {
|
|
37
|
+
flexGrow: 0,
|
|
38
|
+
flexShrink: -flex
|
|
39
|
+
};
|
|
40
|
+
return {
|
|
41
|
+
flexGrow: 0,
|
|
42
|
+
flexShrink: 0
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function ReorderableListSharedInner({
|
|
46
|
+
data,
|
|
47
|
+
keyExtractor,
|
|
48
|
+
renderRow,
|
|
49
|
+
children,
|
|
50
|
+
ScrollComponent = _reactNative.ScrollView,
|
|
51
|
+
style,
|
|
52
|
+
contentContainerStyle,
|
|
53
|
+
...props
|
|
54
|
+
}, ref) {
|
|
55
|
+
const keyToIndex = (0, _react.useMemo)(() => {
|
|
56
|
+
const map = new Map();
|
|
57
|
+
data.forEach((item, index) => map.set(keyExtractor(item, index), index));
|
|
58
|
+
return map;
|
|
59
|
+
}, [data, keyExtractor]);
|
|
60
|
+
(0, _react.useEffect)(() => {
|
|
61
|
+
if (!__DEV__ || hasWarnedDuplicateKeys) return;
|
|
62
|
+
const duplicates = (0, _useReorder.findDuplicateKeys)(data, keyExtractor);
|
|
63
|
+
if (duplicates.length > 0) {
|
|
64
|
+
hasWarnedDuplicateKeys = true;
|
|
65
|
+
console.warn(`[ReorderableList] keyExtractor returned duplicate keys (${duplicates.join(', ')}). Keys must be stable and unique per item — do not derive them from the index.`);
|
|
66
|
+
}
|
|
67
|
+
}, [data, keyExtractor]);
|
|
68
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(ScrollComponent, {
|
|
69
|
+
ref: ref,
|
|
70
|
+
style: [styles.root, flexLonghands(_reactNative.StyleSheet.flatten(style)?.flex), style],
|
|
71
|
+
contentContainerStyle: [styles.content, contentContainerStyle],
|
|
72
|
+
...props,
|
|
73
|
+
role: "list",
|
|
74
|
+
...(0, _primitives.mergeDataAttributes)(props, (0, _primitives.dataAttributes)({
|
|
75
|
+
slot: 'reorderable-list'
|
|
76
|
+
})),
|
|
77
|
+
children: children ?? data.map((item, index) => {
|
|
78
|
+
const key = keyExtractor(item, index);
|
|
79
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Fragment, {
|
|
80
|
+
children: renderRow?.({
|
|
81
|
+
item,
|
|
82
|
+
key,
|
|
83
|
+
index: keyToIndex.get(key) ?? index,
|
|
84
|
+
count: data.length
|
|
85
|
+
})
|
|
86
|
+
}, key);
|
|
87
|
+
})
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
const ReorderableListShared = exports.ReorderableListShared = /*#__PURE__*/(0, _react.forwardRef)(ReorderableListSharedInner);
|
|
91
|
+
//# sourceMappingURL=ReorderableListShared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_primitives","_useReorder","_jsxRuntime","hasWarnedDuplicateKeys","styles","StyleSheet","create","root","flexGrow","minHeight","content","flexLonghands","flex","undefined","flexShrink","flexBasis","ReorderableListSharedInner","data","keyExtractor","renderRow","children","ScrollComponent","ScrollView","style","contentContainerStyle","props","ref","keyToIndex","useMemo","map","Map","forEach","item","index","set","useEffect","__DEV__","duplicates","findDuplicateKeys","length","console","warn","join","jsx","flatten","role","mergeDataAttributes","dataAttributes","slot","key","Fragment","get","count","ReorderableListShared","exports","forwardRef"],"sourceRoot":"../../../../src","sources":["components/ReorderableList/ReorderableListShared.tsx"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AASA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAAiD,IAAAI,WAAA,GAAAJ,OAAA;AAuBjD,IAAIK,sBAAsB,GAAG,KAAK;AAElC,MAAMC,MAAM,GAAGC,uBAAU,CAACC,MAAM,CAAC;EAC/BC,IAAI,EAAE;IAAEC,QAAQ,EAAE,CAAC;IAAEC,SAAS,EAAE;EAAE,CAAC;EACnCC,OAAO,EAAE;IAAEF,QAAQ,EAAE;EAAE;AACzB,CAAC,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACO,SAASG,aAAaA,CAACC,IAAwB,EAAyB;EAC7E,IAAIA,IAAI,KAAKC,SAAS,EAAE,OAAOA,SAAS;EACxC,IAAID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C,GAAA,EAACtB,eAAe;IACdK,GAAG,EAAEA,GAAI;IACTH,KAAK,EAAE,CAACnB,MAAM,CAACG,IAAI,EAAEI,aAAa,CAACN,uBAAU,CAACuC,OAAO,CAACrB,KAAK,CAAC,EAAEX,IAAI,CAAC,EAAEW,KAAK,CAAE;IAC5EC,qBAAqB,EAAE,CAACpB,MAAM,CAACM,OAAO,EAAEc,qBAAqB,CAAE;IAAA,GAC3DC,KAAK;IACToB,IAAI,EAAC,MAAM;IAAA,GACP,IAAAC,+BAAmB,EAACrB,KAAK,EAAE,IAAAsB,0BAAc,EAAC;MAAEC,IAAI,EAAE;IAAmB,CAAC,CAAC,CAAC;IAAA5B,QAAA,EAE3EA,QAAQ,IACPH,IAAI,CAACY,GAAG,CAAC,CAACG,IAAI,EAAEC,KAAK,KAAK;MACxB,MAAMgB,GAAG,GAAG/B,YAAY,CAACc,IAAI,EAAEC,KAAK,CAAC;MACrC,oBACE,IAAA/B,WAAA,CAAAyC,GAAA,EAAC9C,MAAA,CAAAqD,QAAQ;QAAA9B,QAAA,EACND,SAAS,GAAG;UACXa,IAAI;UACJiB,GAAG;UACHhB,KAAK,EAAEN,UAAU,CAACwB,GAAG,CAACF,GAAG,CAAC,IAAIhB,KAAK;UACnCmB,KAAK,EAAEnC,IAAI,CAACsB;QACd,CAAC;MAAC,GANWU,GAOL,CAAC;IAEf,CAAC;EAAC,CACW,CAAC;AAEtB;AAEO,MAAMI,qBAAqB,GAAAC,OAAA,CAAAD,qBAAA,gBAAG,IAAAE,iBAAU,EAACvC,0BAA0B,CAElD","ignoreList":[]}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ReorderableList = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
|
|
10
|
+
var _reactNativeSortables = _interopRequireWildcard(require("react-native-sortables"));
|
|
11
|
+
var _reactNativeWorklets = require("react-native-worklets");
|
|
12
|
+
var _utils = require("@cdx-ui/utils");
|
|
13
|
+
var _ReorderableListShared = require("./ReorderableListShared");
|
|
14
|
+
var _rowContext = require("./rowContext");
|
|
15
|
+
var _useReorder = require("./useReorder");
|
|
16
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
18
|
+
const nativeHandle = {
|
|
19
|
+
props: {},
|
|
20
|
+
ref: undefined,
|
|
21
|
+
wrap: (host, style) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSortables.default.Handle, {
|
|
22
|
+
style: style,
|
|
23
|
+
children: host
|
|
24
|
+
})
|
|
25
|
+
};
|
|
26
|
+
const AnimatedScrollView = _reactNativeReanimated.default.ScrollView;
|
|
27
|
+
const NativeListContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* sortables keeps rendered rows mounted and only re-renders a row when its item, index, or the
|
|
31
|
+
* grid's `renderItem` identity changes. The grid gets a stable `renderItem`; the consumer's
|
|
32
|
+
* (usually inline) `renderItem` reaches rows through context instead.
|
|
33
|
+
*/
|
|
34
|
+
function NativeRow({
|
|
35
|
+
item,
|
|
36
|
+
index
|
|
37
|
+
}) {
|
|
38
|
+
const list = (0, _react.useContext)(NativeListContext);
|
|
39
|
+
const {
|
|
40
|
+
isActive
|
|
41
|
+
} = (0, _reactNativeSortables.useItemContext)();
|
|
42
|
+
const [isDragging, setIsDragging] = (0, _react.useState)(false);
|
|
43
|
+
(0, _reactNativeReanimated.useAnimatedReaction)(() => isActive.get(), (active, previous) => {
|
|
44
|
+
if (active !== (previous ?? false)) (0, _reactNativeWorklets.scheduleOnRN)(setIsDragging, active);
|
|
45
|
+
});
|
|
46
|
+
const rowValue = (0, _useReorder.useReorderableRowValue)({
|
|
47
|
+
index,
|
|
48
|
+
count: list.controller.data.length,
|
|
49
|
+
isDragging,
|
|
50
|
+
handle: nativeHandle,
|
|
51
|
+
labels: list.controller.labels,
|
|
52
|
+
moveItem: list.controller.moveItem
|
|
53
|
+
});
|
|
54
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_rowContext.ReorderableRowProvider, {
|
|
55
|
+
value: rowValue,
|
|
56
|
+
children: list.renderItem({
|
|
57
|
+
item,
|
|
58
|
+
index,
|
|
59
|
+
isDragging
|
|
60
|
+
})
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
const renderGridItem = info => /*#__PURE__*/(0, _jsxRuntime.jsx)(NativeRow, {
|
|
64
|
+
...info
|
|
65
|
+
});
|
|
66
|
+
function ReorderableListInner({
|
|
67
|
+
data,
|
|
68
|
+
keyExtractor,
|
|
69
|
+
onReorder,
|
|
70
|
+
onReorderIndices,
|
|
71
|
+
renderItem,
|
|
72
|
+
getItemLabel,
|
|
73
|
+
labels,
|
|
74
|
+
scrollEventThrottle = 16,
|
|
75
|
+
...rest
|
|
76
|
+
}, ref) {
|
|
77
|
+
const scrollableRef = (0, _reactNativeReanimated.useAnimatedRef)();
|
|
78
|
+
const mergedRef = (0, _react.useMemo)(() => (0, _utils.mergeRefs)(ref, scrollableRef), [ref, scrollableRef]);
|
|
79
|
+
const controller = (0, _useReorder.useReorderController)({
|
|
80
|
+
data,
|
|
81
|
+
onReorder,
|
|
82
|
+
onReorderIndices,
|
|
83
|
+
getItemLabel,
|
|
84
|
+
labels,
|
|
85
|
+
announce: _reactNative.AccessibilityInfo.announceForAccessibility
|
|
86
|
+
});
|
|
87
|
+
const listValue = (0, _react.useMemo)(() => ({
|
|
88
|
+
renderItem,
|
|
89
|
+
controller
|
|
90
|
+
}), [controller, renderItem]);
|
|
91
|
+
const gridKeyExtractor = (0, _react.useMemo)(() => {
|
|
92
|
+
const keys = new Map();
|
|
93
|
+
data.forEach((item, index) => keys.set(item, keyExtractor(item, index)));
|
|
94
|
+
return item => keys.get(item) ?? keyExtractor(item, data.indexOf(item));
|
|
95
|
+
}, [data, keyExtractor]);
|
|
96
|
+
const handleDragEnd = (0, _react.useCallback)(({
|
|
97
|
+
fromIndex,
|
|
98
|
+
toIndex,
|
|
99
|
+
data: reordered
|
|
100
|
+
}) => {
|
|
101
|
+
if (fromIndex === toIndex) return;
|
|
102
|
+
const message = controller.describe('dropped', fromIndex, toIndex);
|
|
103
|
+
onReorder(reordered);
|
|
104
|
+
onReorderIndices?.(fromIndex, toIndex);
|
|
105
|
+
if (message) _reactNative.AccessibilityInfo.announceForAccessibility(message);
|
|
106
|
+
}, [controller, onReorder, onReorderIndices]);
|
|
107
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(NativeListContext.Provider, {
|
|
108
|
+
value: listValue,
|
|
109
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ReorderableListShared.ReorderableListShared, {
|
|
110
|
+
ref: mergedRef,
|
|
111
|
+
ScrollComponent: AnimatedScrollView,
|
|
112
|
+
data: data,
|
|
113
|
+
keyExtractor: keyExtractor,
|
|
114
|
+
scrollEventThrottle: scrollEventThrottle,
|
|
115
|
+
...rest,
|
|
116
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSortables.default.Grid, {
|
|
117
|
+
columns: 1,
|
|
118
|
+
data: data,
|
|
119
|
+
keyExtractor: gridKeyExtractor,
|
|
120
|
+
renderItem: renderGridItem,
|
|
121
|
+
scrollableRef: scrollableRef,
|
|
122
|
+
customHandle: true,
|
|
123
|
+
dragActivationDelay: 0,
|
|
124
|
+
overDrag: "vertical",
|
|
125
|
+
activeItemScale: 1,
|
|
126
|
+
inactiveItemOpacity: 1,
|
|
127
|
+
activeItemShadowOpacity: 0,
|
|
128
|
+
onDragEnd: handleDragEnd
|
|
129
|
+
})
|
|
130
|
+
})
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
const ReorderableList = exports.ReorderableList = /*#__PURE__*/(0, _react.forwardRef)(ReorderableListInner);
|
|
134
|
+
ReorderableList.displayName = 'ReorderableList';
|
|
135
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_reactNativeReanimated","_interopRequireWildcard","_reactNativeSortables","_reactNativeWorklets","_utils","_ReorderableListShared","_rowContext","_useReorder","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","nativeHandle","props","ref","undefined","wrap","host","style","jsx","Handle","children","AnimatedScrollView","Animated","ScrollView","NativeListContext","createContext","NativeRow","item","index","list","useContext","isActive","useItemContext","isDragging","setIsDragging","useState","useAnimatedReaction","active","previous","scheduleOnRN","rowValue","useReorderableRowValue","count","controller","data","length","handle","labels","moveItem","ReorderableRowProvider","value","renderItem","renderGridItem","info","ReorderableListInner","keyExtractor","onReorder","onReorderIndices","getItemLabel","scrollEventThrottle","rest","scrollableRef","useAnimatedRef","mergedRef","useMemo","mergeRefs","useReorderController","announce","AccessibilityInfo","announceForAccessibility","listValue","gridKeyExtractor","keys","Map","forEach","indexOf","handleDragEnd","useCallback","fromIndex","toIndex","reordered","message","describe","Provider","ReorderableListShared","ScrollComponent","Grid","columns","customHandle","dragActivationDelay","overDrag","activeItemScale","inactiveItemOpacity","activeItemShadowOpacity","onDragEnd","ReorderableList","exports","forwardRef","displayName"],"s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AA,EAACjC,qBAAA,CAAAiB,OAAQ,CAACoF,IAAI;QACZC,OAAO,EAAE,CAAE;QACX3C,IAAI,EAAEA,IAAK;QACXW,YAAY,EAAEgB,gBAAiB;QAC/BpB,UAAU,EAAEC,cAAwE;QACpFS,aAAa,EAAEA,aAAc;QAC7B2B,YAAY;QACZC,mBAAmB,EAAE,CAAE;QACvBC,QAAQ,EAAC,UAAU;QACnBC,eAAe,EAAE,CAAE;QACnBC,mBAAmB,EAAE,CAAE;QACvBC,uBAAuB,EAAE,CAAE;QAC3BC,SAAS,EAAElB;MAAc,CAC1B;IAAC,CACmB;EAAC,CACE,CAAC;AAEjC;AAEO,MAAMmB,eAAe,GAAAC,OAAA,CAAAD,eAAA,gBAAG,IAAAE,iBAAU,EAAC3C,oBAAoB,CAEtC;AAEvByC,eAAe,CAA8BG,WAAW,GAAG,iBAAiB","ignoreList":[]}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ReorderableList = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _core = require("@dnd-kit/core");
|
|
10
|
+
var _sortable = require("@dnd-kit/sortable");
|
|
11
|
+
var _utilities = require("@dnd-kit/utilities");
|
|
12
|
+
var _utils = require("@cdx-ui/utils");
|
|
13
|
+
var _ReorderableListShared = require("./ReorderableListShared");
|
|
14
|
+
var _reorderItems = require("./reorderItems");
|
|
15
|
+
var _rowContext = require("./rowContext");
|
|
16
|
+
var _useReorder = require("./useReorder");
|
|
17
|
+
var _webDnd = require("./webDnd");
|
|
18
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
+
const handleTouchStyle = {
|
|
20
|
+
touchAction: 'none'
|
|
21
|
+
};
|
|
22
|
+
const passThrough = host => host;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* react-native-web's `Pressable` stops Enter/Space `keydown` from bubbling, so when the handle is a
|
|
26
|
+
* pressable control (`asChild` with an `IconButton`) the drop key never reaches dnd-kit's document
|
|
27
|
+
* listener. While dragging, take the key at the handle and hand it to the document directly.
|
|
28
|
+
*/
|
|
29
|
+
function forwardDropKeyToDocument(event) {
|
|
30
|
+
const {
|
|
31
|
+
key,
|
|
32
|
+
code
|
|
33
|
+
} = event.nativeEvent;
|
|
34
|
+
if (key !== 'Enter' && key !== ' ' && code !== 'Enter' && code !== 'Space') return;
|
|
35
|
+
event.preventDefault();
|
|
36
|
+
event.stopPropagation();
|
|
37
|
+
const {
|
|
38
|
+
ownerDocument
|
|
39
|
+
} = event.currentTarget;
|
|
40
|
+
ownerDocument?.dispatchEvent(new KeyboardEvent('keydown', {
|
|
41
|
+
key,
|
|
42
|
+
code,
|
|
43
|
+
cancelable: true
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
function SortableRow({
|
|
47
|
+
info,
|
|
48
|
+
renderItem,
|
|
49
|
+
controller
|
|
50
|
+
}) {
|
|
51
|
+
const {
|
|
52
|
+
item,
|
|
53
|
+
index,
|
|
54
|
+
count,
|
|
55
|
+
key
|
|
56
|
+
} = info;
|
|
57
|
+
const {
|
|
58
|
+
attributes,
|
|
59
|
+
listeners,
|
|
60
|
+
setNodeRef,
|
|
61
|
+
setActivatorNodeRef,
|
|
62
|
+
transform,
|
|
63
|
+
transition,
|
|
64
|
+
isDragging
|
|
65
|
+
} = (0, _sortable.useSortable)({
|
|
66
|
+
id: key
|
|
67
|
+
});
|
|
68
|
+
const {
|
|
69
|
+
activatorEvent
|
|
70
|
+
} = (0, _core.useDndContext)();
|
|
71
|
+
const nodeRef = (0, _react.useRef)(null);
|
|
72
|
+
const swallowNextClickRef = (0, _react.useRef)(false);
|
|
73
|
+
const setRowRef = (0, _react.useCallback)(node => {
|
|
74
|
+
const element = node;
|
|
75
|
+
nodeRef.current = element;
|
|
76
|
+
setNodeRef(element);
|
|
77
|
+
}, [setNodeRef]);
|
|
78
|
+
|
|
79
|
+
// dnd-kit's shift/drop animation is written to the row's DOM node; React never owns these keys.
|
|
80
|
+
(0, _react.useLayoutEffect)(() => {
|
|
81
|
+
const node = nodeRef.current;
|
|
82
|
+
if (!node) return;
|
|
83
|
+
node.style.transform = transform ? _utilities.CSS.Translate.toString({
|
|
84
|
+
...transform,
|
|
85
|
+
x: 0
|
|
86
|
+
}) ?? '' : '';
|
|
87
|
+
node.style.transition = transition ?? '';
|
|
88
|
+
}, [transform, transition]);
|
|
89
|
+
|
|
90
|
+
// A pointer drag ends with a click on the row; swallow that one click so a pressable row does
|
|
91
|
+
// not fire after a drop or cancel. Scoped to this row, and reset by the next pointerdown.
|
|
92
|
+
(0, _react.useEffect)(() => {
|
|
93
|
+
if (isDragging && activatorEvent?.type.startsWith('pointer')) {
|
|
94
|
+
swallowNextClickRef.current = true;
|
|
95
|
+
}
|
|
96
|
+
}, [activatorEvent, isDragging]);
|
|
97
|
+
(0, _react.useEffect)(() => {
|
|
98
|
+
const node = nodeRef.current;
|
|
99
|
+
if (!node) return undefined;
|
|
100
|
+
const onClick = event => {
|
|
101
|
+
if (!swallowNextClickRef.current) return;
|
|
102
|
+
swallowNextClickRef.current = false;
|
|
103
|
+
event.stopPropagation();
|
|
104
|
+
event.preventDefault();
|
|
105
|
+
};
|
|
106
|
+
const onPointerDown = () => {
|
|
107
|
+
swallowNextClickRef.current = false;
|
|
108
|
+
};
|
|
109
|
+
node.addEventListener('click', onClick, true);
|
|
110
|
+
node.addEventListener('pointerdown', onPointerDown, true);
|
|
111
|
+
return () => {
|
|
112
|
+
node.removeEventListener('click', onClick, true);
|
|
113
|
+
node.removeEventListener('pointerdown', onPointerDown, true);
|
|
114
|
+
};
|
|
115
|
+
}, []);
|
|
116
|
+
const handle = (0, _react.useMemo)(() => {
|
|
117
|
+
const {
|
|
118
|
+
tabIndex,
|
|
119
|
+
role,
|
|
120
|
+
...aria
|
|
121
|
+
} = attributes;
|
|
122
|
+
return {
|
|
123
|
+
props: {
|
|
124
|
+
...aria,
|
|
125
|
+
role: role,
|
|
126
|
+
tabIndex: tabIndex === 0 || tabIndex === -1 ? tabIndex : undefined,
|
|
127
|
+
style: handleTouchStyle,
|
|
128
|
+
...listeners,
|
|
129
|
+
onKeyDownCapture: isDragging ? forwardDropKeyToDocument : undefined
|
|
130
|
+
},
|
|
131
|
+
ref: node => setActivatorNodeRef(node),
|
|
132
|
+
wrap: passThrough
|
|
133
|
+
};
|
|
134
|
+
}, [attributes, isDragging, listeners, setActivatorNodeRef]);
|
|
135
|
+
const rowValue = (0, _useReorder.useReorderableRowValue)({
|
|
136
|
+
index,
|
|
137
|
+
count,
|
|
138
|
+
isDragging,
|
|
139
|
+
handle,
|
|
140
|
+
labels: controller.labels,
|
|
141
|
+
moveItem: controller.moveItem
|
|
142
|
+
});
|
|
143
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_rowContext.ReorderableRowProvider, {
|
|
144
|
+
value: rowValue,
|
|
145
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
146
|
+
ref: setRowRef,
|
|
147
|
+
className: (0, _utils.cn)(isDragging && 'relative z-20'),
|
|
148
|
+
children: renderItem({
|
|
149
|
+
item,
|
|
150
|
+
index,
|
|
151
|
+
isDragging
|
|
152
|
+
})
|
|
153
|
+
})
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
function ReorderableListInner({
|
|
157
|
+
data,
|
|
158
|
+
keyExtractor,
|
|
159
|
+
renderItem,
|
|
160
|
+
onReorder,
|
|
161
|
+
onReorderIndices,
|
|
162
|
+
getItemLabel,
|
|
163
|
+
labels,
|
|
164
|
+
...rest
|
|
165
|
+
}, ref) {
|
|
166
|
+
const [announcement, setAnnouncement] = (0, _react.useState)('');
|
|
167
|
+
const controller = (0, _useReorder.useReorderController)({
|
|
168
|
+
data,
|
|
169
|
+
onReorder,
|
|
170
|
+
onReorderIndices,
|
|
171
|
+
getItemLabel,
|
|
172
|
+
labels,
|
|
173
|
+
announce: setAnnouncement
|
|
174
|
+
});
|
|
175
|
+
const sortableIds = (0, _react.useMemo)(() => data.map((item, index) => keyExtractor(item, index)), [data, keyExtractor]);
|
|
176
|
+
const sensors = (0, _core.useSensors)((0, _core.useSensor)(_core.PointerSensor, {
|
|
177
|
+
activationConstraint: {
|
|
178
|
+
distance: 4
|
|
179
|
+
}
|
|
180
|
+
}), (0, _core.useSensor)(_core.KeyboardSensor, {
|
|
181
|
+
coordinateGetter: _sortable.sortableKeyboardCoordinates
|
|
182
|
+
}));
|
|
183
|
+
const {
|
|
184
|
+
describe,
|
|
185
|
+
labels: resolvedLabels
|
|
186
|
+
} = controller;
|
|
187
|
+
const accessibility = (0, _react.useMemo)(() => ({
|
|
188
|
+
announcements: (0, _webDnd.createReorderAnnouncements)(sortableIds, describe),
|
|
189
|
+
screenReaderInstructions: {
|
|
190
|
+
draggable: resolvedLabels.screenReaderInstructions
|
|
191
|
+
}
|
|
192
|
+
}), [describe, resolvedLabels, sortableIds]);
|
|
193
|
+
const handleDragEnd = (0, _react.useCallback)(({
|
|
194
|
+
active,
|
|
195
|
+
over
|
|
196
|
+
}) => {
|
|
197
|
+
const move = (0, _webDnd.resolveDragEnd)(sortableIds, active.id, over?.id);
|
|
198
|
+
if (!move) return;
|
|
199
|
+
onReorder((0, _reorderItems.reorderItems)(data, move.from, move.to));
|
|
200
|
+
onReorderIndices?.(move.from, move.to);
|
|
201
|
+
}, [data, onReorder, onReorderIndices, sortableIds]);
|
|
202
|
+
const renderRow = (0, _react.useCallback)(info => /*#__PURE__*/(0, _jsxRuntime.jsx)(SortableRow, {
|
|
203
|
+
info: info,
|
|
204
|
+
renderItem: renderItem,
|
|
205
|
+
controller: controller
|
|
206
|
+
}), [controller, renderItem]);
|
|
207
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_core.DndContext, {
|
|
208
|
+
accessibility: accessibility,
|
|
209
|
+
collisionDetection: _core.closestCenter,
|
|
210
|
+
onDragEnd: handleDragEnd,
|
|
211
|
+
sensors: sensors,
|
|
212
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_sortable.SortableContext, {
|
|
213
|
+
items: sortableIds,
|
|
214
|
+
strategy: _sortable.verticalListSortingStrategy,
|
|
215
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ReorderableListShared.ReorderableListShared, {
|
|
216
|
+
ref: ref,
|
|
217
|
+
data: data,
|
|
218
|
+
keyExtractor: keyExtractor,
|
|
219
|
+
renderRow: renderRow,
|
|
220
|
+
...rest
|
|
221
|
+
})
|
|
222
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
223
|
+
"aria-live": "polite",
|
|
224
|
+
className: "sr-only",
|
|
225
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
226
|
+
children: announcement
|
|
227
|
+
})
|
|
228
|
+
})]
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
const ReorderableList = exports.ReorderableList = /*#__PURE__*/(0, _react.forwardRef)(ReorderableListInner);
|
|
232
|
+
ReorderableList.displayName = 'ReorderableList';
|
|
233
|
+
//# sourceMappingURL=index.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_core","_sortable","_utilities","_utils","_ReorderableListShared","_reorderItems","_rowContext","_useReorder","_webDnd","_jsxRuntime","handleTouchStyle","touchAction","passThrough","host","forwardDropKeyToDocument","event","key","code","nativeEvent","preventDefault","stopPropagation","ownerDocument","currentTarget","dispatchEvent","KeyboardEvent","cancelable","SortableRow","info","renderItem","controller","item","index","count","attributes","listeners","setNodeRef","setActivatorNodeRef","transform","transition","isDragging","useSortable","id","activatorEvent","useDndContext","nodeRef","useRef","swallowNextClickRef","setRowRef","useCallback","node","element","current","useLayoutEffect","style","CSS","Translate","toString","x","useEffect","type","startsWith","undefined","onClick","onPointerDown","addEventListener","removeEventListener","handle","useMemo","tabIndex","role","aria","props","onKeyDownCapture","ref","wrap","rowValue","useReorderableRowValue","labels","moveItem","jsx","ReorderableRowProvider","value","children","View","className","cn","ReorderableListInner","data","keyExtractor","onReorder","onReorderIndices","getItemLabel","rest","announcement","setAnnouncement","useState","useReorderController","announce","sortableIds","map","sensors","useSensors","useSensor","PointerSensor","activationConstraint","distance","KeyboardSensor","coordinateGetter","sortableKeyboardCoordinates","describe","resolvedLabels","accessibility","announcements","createReorderAnnouncements","screenReaderInstructions","draggable","handleDragEnd","active","over","move","resolveDragEnd","reorderItems","from","to","renderRow","jsxs","DndContext","collisionDetection","closestCenter","onDragEnd","SortableContext","items","strategy","verticalListSortingStrategy","ReorderableListShared","Text","ReorderableList","exports","forwardRef","displayName"],"sourceRoot":"../../../../src","sources":["components/ReorderableList/index.web.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAYA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAUA,IAAAG,SAAA,GAAAH,OAAA;AAMA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,sBAAA,GAAAN,OAAA;AACA,IAAAO,aAAA,GAAAP,OAAA;AACA,IAAAQ,WAAA,GAAAR,OAAA;AAEA,IAAAS,WAAA,GAAAT,OAAA;AACA,IAAAU,OAAA,GAAAV,OAAA;AAAsE,IAAAW,WAAA,GAAAX,OAAA;AAQtE,MAAMY,gBAAgB,GAAG;EAAEC,WAAW,EAAE;AAAO,CAAc;AAC7D,MAAMC,WAAyC,GAAIC,IAAI,IAAKA,IAAI;;AAEhE;AACA;AACA;AACA;AACA;AACA,SAASC,wBAAwBA,CAACC,KAAyB,EAAE;EAC3D,MAAM;IAAEC,GAAG;IAAEC;EAAK,CAAC,GAAGF,KAAK,CAACG,WAAW;EACvC,IAAIF,GAAG,KAAK,OAAO,IAAIA,GAAG,KAAK,GAAG,I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E,GAAA,EAAChF,YAAA,CAAAoF,IAAI;MAAC,aAAU,QAAQ;MAACC,SAAS,EAAC,SAAS;MAAAF,QAAA,eAC1C,IAAAzE,WAAA,CAAAsE,GAAA,EAAChF,YAAA,CAAAwI,IAAI;QAAArD,QAAA,EAAEW;MAAY,CAAO;IAAC,CACvB,CAAC;EAAA,CACG,CAAC;AAEjB;AAEO,MAAM2C,eAAe,GAAAC,OAAA,CAAAD,eAAA,gBAAG,IAAAE,iBAAU,EAACpD,oBAAoB,CAEtC;AAEvBkD,eAAe,CAA8BG,WAAW,GAAG,iBAAiB","ignoreList":[]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DEFAULT_REORDERABLE_LIST_LABELS = void 0;
|
|
7
|
+
exports.formatReorderMessage = formatReorderMessage;
|
|
8
|
+
exports.resolveReorderableListLabels = resolveReorderableListLabels;
|
|
9
|
+
const DEFAULT_REORDERABLE_LIST_LABELS = exports.DEFAULT_REORDERABLE_LIST_LABELS = {
|
|
10
|
+
item: 'item {position}',
|
|
11
|
+
pickedUp: 'Picked up {item}. Position {position} of {count}.',
|
|
12
|
+
movedTo: 'Moved {item} to position {position} of {count}.',
|
|
13
|
+
dropped: 'Dropped {item} at position {position} of {count}.',
|
|
14
|
+
cancelled: 'Reorder cancelled. {item} returned to position {position} of {count}.',
|
|
15
|
+
screenReaderInstructions: 'To pick up an item, press Space or Enter. Use the arrow keys to move it, then press Space or Enter to drop it, or Escape to cancel.',
|
|
16
|
+
moveUp: 'Move up',
|
|
17
|
+
moveDown: 'Move down',
|
|
18
|
+
moveToTop: 'Move to top',
|
|
19
|
+
moveToBottom: 'Move to bottom'
|
|
20
|
+
};
|
|
21
|
+
function resolveReorderableListLabels(partial) {
|
|
22
|
+
return {
|
|
23
|
+
...DEFAULT_REORDERABLE_LIST_LABELS,
|
|
24
|
+
...partial
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function fill(template, values) {
|
|
28
|
+
return template.replace(/\{(\w+)\}/g, (match, name) => values[name] ?? match);
|
|
29
|
+
}
|
|
30
|
+
function formatReorderMessage(key, {
|
|
31
|
+
labels,
|
|
32
|
+
getItemLabel,
|
|
33
|
+
item,
|
|
34
|
+
fromIndex,
|
|
35
|
+
position,
|
|
36
|
+
count
|
|
37
|
+
}) {
|
|
38
|
+
const itemName = getItemLabel ? getItemLabel(item, fromIndex) : fill(labels.item, {
|
|
39
|
+
position: String(fromIndex + 1)
|
|
40
|
+
});
|
|
41
|
+
return fill(labels[key], {
|
|
42
|
+
item: itemName,
|
|
43
|
+
position: String(position + 1),
|
|
44
|
+
count: String(count)
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=labels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["DEFAULT_REORDERABLE_LIST_LABELS","exports","item","pickedUp","movedTo","dropped","cancelled","screenReaderInstructions","moveUp","moveDown","moveToTop","moveToBottom","resolveReorderableListLabels","partial","fill","template","values","replace","match","name","formatReorderMessage","key","labels","getItemLabel","fromIndex","position","count","itemName","String"],"sourceRoot":"../../../../src","sources":["components/ReorderableList/labels.ts"],"mappings":";;;;;;;;AAEO,MAAMA,+BAAsD,GAAAC,OAAA,CAAAD,+BAAA,GAAG;EACpEE,IAAI,EAAE,iBAAiB;EACvBC,QAAQ,EAAE,mDAAmD;EAC7DC,OAAO,EAAE,iDAAiD;EAC1DC,OAAO,EAAE,mDAAmD;EAC5DC,SAAS,EAAE,uEAAuE;EAClFC,wBAAwB,EACtB,qIAAqI;EACvIC,MAAM,EAAE,SAAS;EACjBC,QAAQ,EAAE,WAAW;EACrBC,SAAS,EAAE,aAAa;EACxBC,YAAY,EAAE;AAChB,CAAC;AAEM,SAASC,4BAA4BA,CAC1CC,OAAwC,EACjB;EACvB,OAAO;IAAE,GAAGb,+BAA+B;IAAE,GAAGa;EAAQ,CAAC;AAC3D;AAeA,SAASC,IAAIA,CAACC,QAAgB,EAAEC,MAA8B,EAAU;EACtE,OAAOD,QAAQ,CAACE,OAAO,CAAC,YAAY,EAAE,CAACC,KAAK,EAAEC,IAAY,KAAKH,MAAM,CAACG,IAAI,CAAC,IAAID,KAAK,CAAC;AACvF;AAEO,SAASE,oBAAoBA,CAClCC,GAAsB,EACtB;EAAEC,MAAM;EAAEC,YAAY;EAAErB,IAAI;EAAEsB,SAAS;EAAEC,QAAQ;EAAEC;AAA8B,CAAC,EAC1E;EACR,MAAMC,QAAQ,GAAGJ,YAAY,GACzBA,YAAY,CAACrB,IAAI,EAAEsB,SAAS,CAAC,GAC7BV,IAAI,CAACQ,MAAM,CAACpB,IAAI,EAAE;IAAEuB,QAAQ,EAAEG,MAAM,CAACJ,SAAS,GAAG,CAAC;EAAE,CAAC,CAAC;EAC1D,OAAOV,IAAI,CAACQ,MAAM,CAACD,GAAG,CAAC,EAAE;IACvBnB,IAAI,EAAEyB,QAAQ;IACdF,QAAQ,EAAEG,MAAM,CAACH,QAAQ,GAAG,CAAC,CAAC;IAC9BC,KAAK,EAAEE,MAAM,CAACF,KAAK;EACrB,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.reorderItems = reorderItems;
|
|
7
|
+
/** Immutable insert-strategy move. No-ops when indices are equal or out of range. */
|
|
8
|
+
function reorderItems(data, fromIndex, toIndex) {
|
|
9
|
+
if (fromIndex === toIndex || fromIndex < 0 || toIndex < 0 || fromIndex >= data.length || toIndex >= data.length) {
|
|
10
|
+
return data;
|
|
11
|
+
}
|
|
12
|
+
const next = data.slice();
|
|
13
|
+
next.splice(toIndex, 0, ...next.splice(fromIndex, 1));
|
|
14
|
+
return next;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=reorderItems.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["reorderItems","data","fromIndex","toIndex","length","next","slice","splice"],"sourceRoot":"../../../../src","sources":["components/ReorderableList/reorderItems.ts"],"mappings":";;;;;;AAAA;AACO,SAASA,YAAYA,CAAIC,IAAS,EAAEC,SAAiB,EAAEC,OAAe,EAAO;EAClF,IACED,SAAS,KAAKC,OAAO,IACrBD,SAAS,GAAG,CAAC,IACbC,OAAO,GAAG,CAAC,IACXD,SAAS,IAAID,IAAI,CAACG,MAAM,IACxBD,OAAO,IAAIF,IAAI,CAACG,MAAM,EACtB;IACA,OAAOH,IAAI;EACb;EAEA,MAAMI,IAAI,GAAGJ,IAAI,CAACK,KAAK,CAAC,CAAC;EACzBD,IAAI,CAACE,MAAM,CAACJ,OAAO,EAAE,CAAC,EAAE,GAAGE,IAAI,CAACE,MAAM,CAACL,SAAS,EAAE,CAAC,CAAC,CAAC;EACrD,OAAOG,IAAI;AACb","ignoreList":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ReorderableRowProvider = void 0;
|
|
7
|
+
exports.useReorderableRow = useReorderableRow;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
/**
|
|
10
|
+
* Props that make a host element the row's drag activator.
|
|
11
|
+
*
|
|
12
|
+
* - **Web:** dnd-kit `attributes` (`role`, `tabIndex`, `aria-*`), `listeners` (`onPointerDown`,
|
|
13
|
+
* `onKeyDown`), and `style: { touchAction: 'none' }`. Some keys (`aria-roledescription`,
|
|
14
|
+
* `aria-describedby`) are outside `ViewProps`, hence the index signature.
|
|
15
|
+
* - **Native:** empty — the gesture is attached by `wrap`.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Binds a handle element to the row's drag gesture without adding a focusable wrapper.
|
|
20
|
+
*
|
|
21
|
+
* Render one host (a `View`, or the consumer child under `asChild` via `Slot`), then:
|
|
22
|
+
* 1. spread `props` onto it before consumer props (handlers compose through `Slot`),
|
|
23
|
+
* 2. compose `ref` with the host's own ref,
|
|
24
|
+
* 3. return `wrap(host)`.
|
|
25
|
+
*
|
|
26
|
+
* Web: `ref` is dnd-kit's `setActivatorNodeRef` and `wrap` returns the host unchanged.
|
|
27
|
+
* Native: `ref` is `undefined` and `wrap` places the host inside `Sortable.Handle`, which must
|
|
28
|
+
* wrap because react-native-sortables only attaches its handle gesture through that component. It
|
|
29
|
+
* renders a non-accessible `View`, so the host stays the single focusable element; pass layout
|
|
30
|
+
* styles that must sit on the outer box (flex, alignSelf, margin) as `wrap`'s second argument.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/** Per-row reorder state and actions, provided to every row rendered by `ReorderableList`. */
|
|
34
|
+
|
|
35
|
+
const ReorderableRowContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
36
|
+
const ReorderableRowProvider = exports.ReorderableRowProvider = ReorderableRowContext.Provider;
|
|
37
|
+
|
|
38
|
+
/** Reorder state for the enclosing `ReorderableList` row, or `null` outside a list. */
|
|
39
|
+
function useReorderableRow() {
|
|
40
|
+
return (0, _react.useContext)(ReorderableRowContext);
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=rowContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","ReorderableRowContext","createContext","ReorderableRowProvider","exports","Provider","useReorderableRow","useContext"],"sourceRoot":"../../../../src","sources":["components/ReorderableList/rowContext.tsx"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA;;AAwBA,MAAMC,qBAAqB,gBAAG,IAAAC,oBAAa,EAAoC,IAAI,CAAC;AAE7E,MAAMC,sBAAsB,GAAAC,OAAA,CAAAD,sBAAA,GAAGF,qBAAqB,CAACI,QAAQ;;AAEpE;AACO,SAASC,iBAAiBA,CAAA,EAAsC;EACrE,OAAO,IAAAC,iBAAU,EAACN,qBAAqB,CAAC;AAC1C","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["components/ReorderableList/types.ts"],"mappings":"","ignoreList":[]}
|