@difizen/libro-core 0.3.3 → 0.3.5
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/es/components/dnd-component/default-dnd-content.d.ts.map +1 -1
- package/es/components/dnd-component/default-dnd-content.js +88 -165
- package/es/components/dnd-component/dnd-list.d.ts +12 -0
- package/es/components/dnd-component/dnd-list.d.ts.map +1 -1
- package/es/components/dnd-component/dnd-list.js +306 -62
- package/es/components/dnd-component/index.d.ts +0 -2
- package/es/components/dnd-component/index.d.ts.map +1 -1
- package/es/components/dnd-component/index.js +0 -2
- package/es/components/dnd-component/index.less +84 -0
- package/es/components/dnd-component/virtualized-manager.d.ts.map +1 -1
- package/es/components/dnd-component/virtualized-manager.js +2 -8
- package/es/formatter/libro-formatter-json-contribution.d.ts +1 -1
- package/es/formatter/libro-formatter-string-contribution.d.ts +1 -1
- package/es/index.less +0 -22
- package/es/libro-view.d.ts.map +1 -1
- package/es/libro-view.js +7 -11
- package/es/virtualized-manager.d.ts.map +1 -1
- package/es/virtualized-manager.js +1 -8
- package/package.json +10 -6
- package/src/components/dnd-component/default-dnd-content.tsx +99 -163
- package/src/components/dnd-component/dnd-list.tsx +303 -34
- package/src/components/dnd-component/index.less +84 -0
- package/src/components/dnd-component/index.tsx +0 -2
- package/src/components/dnd-component/virtualized-manager.ts +10 -7
- package/src/index.less +0 -22
- package/src/libro-view.tsx +7 -17
- package/src/virtualized-manager.ts +9 -7
- package/es/components/dnd-component/custom-drag-layer.d.ts +0 -9
- package/es/components/dnd-component/custom-drag-layer.d.ts.map +0 -1
- package/es/components/dnd-component/custom-drag-layer.js +0 -140
- package/es/components/dnd-component/dnd-context.d.ts +0 -3
- package/es/components/dnd-component/dnd-context.d.ts.map +0 -1
- package/es/components/dnd-component/dnd-context.js +0 -20
- package/src/components/dnd-component/custom-drag-layer.tsx +0 -144
- package/src/components/dnd-component/dnd-context.tsx +0 -28
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
-
/* eslint-disable react-hooks/exhaustive-deps */
|
|
14
|
-
import { useInject, ViewInstance } from '@difizen/mana-app';
|
|
15
|
-
import { ViewRender } from '@difizen/mana-app';
|
|
16
|
-
import { useState, useEffect, memo } from 'react';
|
|
17
|
-
import { useDragLayer } from 'react-dnd';
|
|
18
|
-
import { LibroCellService } from "../../cell/index.js";
|
|
19
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
20
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
21
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
22
|
-
var layerStyles = {
|
|
23
|
-
position: 'fixed',
|
|
24
|
-
pointerEvents: 'none',
|
|
25
|
-
zIndex: 1000,
|
|
26
|
-
left: 0,
|
|
27
|
-
top: 0,
|
|
28
|
-
width: '300px',
|
|
29
|
-
height: '50px'
|
|
30
|
-
};
|
|
31
|
-
var getItemStyles = function getItemStyles(currentOffset) {
|
|
32
|
-
if (!currentOffset) {
|
|
33
|
-
return {
|
|
34
|
-
display: 'none'
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
var x = currentOffset.x,
|
|
38
|
-
y = currentOffset.y;
|
|
39
|
-
var transform = "translate(".concat(x, "px, ").concat(y, "px)");
|
|
40
|
-
return {
|
|
41
|
-
transform: transform,
|
|
42
|
-
WebkitTransform: transform
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
var MultipleSelectionPreview = function MultipleSelectionPreview(_ref) {
|
|
46
|
-
var activeCell = _ref.activeCell;
|
|
47
|
-
var cellService = useInject(LibroCellService);
|
|
48
|
-
var _useState = useState(),
|
|
49
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
50
|
-
multipleSelectionPreview = _useState2[0],
|
|
51
|
-
setMultipleSelectionPreview = _useState2[1];
|
|
52
|
-
useEffect(function () {
|
|
53
|
-
cellService.getOrCreateView(activeCell.model.options, activeCell.parent.id).then(function (view) {
|
|
54
|
-
setMultipleSelectionPreview(view);
|
|
55
|
-
return;
|
|
56
|
-
}).catch(function (e) {
|
|
57
|
-
//
|
|
58
|
-
});
|
|
59
|
-
}, []);
|
|
60
|
-
return /*#__PURE__*/_jsxs("div", {
|
|
61
|
-
className: "libro-dnd-multiple-selection-preview",
|
|
62
|
-
children: [/*#__PURE__*/_jsx("div", {
|
|
63
|
-
className: "libro-dnd-active-selection",
|
|
64
|
-
children: multipleSelectionPreview && /*#__PURE__*/_jsx(ViewRender, {
|
|
65
|
-
view: multipleSelectionPreview
|
|
66
|
-
})
|
|
67
|
-
}), /*#__PURE__*/_jsx("div", {
|
|
68
|
-
className: "libro-dnd-cascading-multiple-selection"
|
|
69
|
-
})]
|
|
70
|
-
});
|
|
71
|
-
};
|
|
72
|
-
export var MultipleSelectionPreviewMemo = /*#__PURE__*/memo(MultipleSelectionPreview);
|
|
73
|
-
var SingleSelectionDragPreview = function SingleSelectionDragPreview(_ref2) {
|
|
74
|
-
var activeCell = _ref2.activeCell;
|
|
75
|
-
var cellService = useInject(LibroCellService);
|
|
76
|
-
var _useState3 = useState(),
|
|
77
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
78
|
-
singleSelectionPreview = _useState4[0],
|
|
79
|
-
setSingleSelectionPreview = _useState4[1];
|
|
80
|
-
useEffect(function () {
|
|
81
|
-
cellService.getOrCreateView(_objectSpread(_objectSpread({}, activeCell.model.options), {}, {
|
|
82
|
-
modelId: activeCell.model.id,
|
|
83
|
-
singleSelectionDragPreview: true
|
|
84
|
-
}), activeCell.parent.id).then(function (view) {
|
|
85
|
-
setSingleSelectionPreview(view);
|
|
86
|
-
return;
|
|
87
|
-
}).catch(function (e) {
|
|
88
|
-
//
|
|
89
|
-
});
|
|
90
|
-
}, []);
|
|
91
|
-
return /*#__PURE__*/_jsx("div", {
|
|
92
|
-
className: "libro-dnd-active-selection",
|
|
93
|
-
children: singleSelectionPreview && /*#__PURE__*/_jsx(ViewRender, {
|
|
94
|
-
view: singleSelectionPreview
|
|
95
|
-
})
|
|
96
|
-
});
|
|
97
|
-
};
|
|
98
|
-
export var SingleSelectionPreviewMemo = /*#__PURE__*/memo(SingleSelectionDragPreview);
|
|
99
|
-
export var CustomDragLayer = function CustomDragLayer() {
|
|
100
|
-
var _useDragLayer = useDragLayer(function (monitor) {
|
|
101
|
-
return {
|
|
102
|
-
item: monitor.getItem(),
|
|
103
|
-
itemType: monitor.getItemType(),
|
|
104
|
-
currentOffset: monitor.getClientOffset(),
|
|
105
|
-
isDragging: monitor.isDragging()
|
|
106
|
-
};
|
|
107
|
-
}),
|
|
108
|
-
isDragging = _useDragLayer.isDragging,
|
|
109
|
-
item = _useDragLayer.item,
|
|
110
|
-
currentOffset = _useDragLayer.currentOffset;
|
|
111
|
-
var instance = useInject(ViewInstance);
|
|
112
|
-
function renderItem() {
|
|
113
|
-
var isItemSelected = instance.model.selections.findIndex(function (select) {
|
|
114
|
-
return select.id === item.cell.id;
|
|
115
|
-
}) >= 0;
|
|
116
|
-
if (instance.model.selections.length !== 0 && isItemSelected) {
|
|
117
|
-
return /*#__PURE__*/_jsx(_Fragment, {
|
|
118
|
-
children: instance.model.active && /*#__PURE__*/_jsx(MultipleSelectionPreviewMemo, {
|
|
119
|
-
activeCell: instance.model.active
|
|
120
|
-
})
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
return /*#__PURE__*/_jsx(_Fragment, {
|
|
124
|
-
children: instance.model.active && /*#__PURE__*/_jsx(SingleSelectionPreviewMemo, {
|
|
125
|
-
activeCell: instance.model.active
|
|
126
|
-
})
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
if (!isDragging) {
|
|
130
|
-
return null;
|
|
131
|
-
}
|
|
132
|
-
return /*#__PURE__*/_jsx("div", {
|
|
133
|
-
className: "libro-custom-drag-layer",
|
|
134
|
-
style: layerStyles,
|
|
135
|
-
children: /*#__PURE__*/_jsx("div", {
|
|
136
|
-
style: getItemStyles(currentOffset),
|
|
137
|
-
children: renderItem()
|
|
138
|
-
})
|
|
139
|
-
});
|
|
140
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dnd-context.d.ts","sourceRoot":"","sources":["../../../src/components/dnd-component/dnd-context.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAMhC,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,GAAG,CAmB9B,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { getOrigin, useInject } from '@difizen/mana-app';
|
|
2
|
-
import { ViewInstance } from '@difizen/mana-app';
|
|
3
|
-
import { DndProvider } from 'react-dnd';
|
|
4
|
-
import { HTML5Backend } from 'react-dnd-html5-backend';
|
|
5
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
-
export var DndContext = function DndContext(_ref) {
|
|
7
|
-
var _getOrigin$container;
|
|
8
|
-
var children = _ref.children;
|
|
9
|
-
var instance = useInject(ViewInstance);
|
|
10
|
-
if (!instance.isVisible && !instance.model.dndAreaNullEnable) {
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
return /*#__PURE__*/_jsx(DndProvider, {
|
|
14
|
-
backend: HTML5Backend,
|
|
15
|
-
options: {
|
|
16
|
-
rootElement: instance.isVisible || !instance.model.dndAreaNullEnable ? (_getOrigin$container = getOrigin(instance).container) === null || _getOrigin$container === void 0 ? void 0 : _getOrigin$container.current : null
|
|
17
|
-
},
|
|
18
|
-
children: children
|
|
19
|
-
});
|
|
20
|
-
};
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
/* eslint-disable react-hooks/exhaustive-deps */
|
|
2
|
-
import { useInject, ViewInstance } from '@difizen/mana-app';
|
|
3
|
-
import { ViewRender } from '@difizen/mana-app';
|
|
4
|
-
import type { FC, CSSProperties } from 'react';
|
|
5
|
-
import { useState, useEffect, memo } from 'react';
|
|
6
|
-
import type { XYCoord } from 'react-dnd';
|
|
7
|
-
import { useDragLayer } from 'react-dnd';
|
|
8
|
-
|
|
9
|
-
import type { CellService } from '../../cell/index.js';
|
|
10
|
-
import { LibroCellService } from '../../cell/index.js';
|
|
11
|
-
import type { CellView } from '../../libro-protocol.js';
|
|
12
|
-
import type { LibroView } from '../../libro-view.js';
|
|
13
|
-
|
|
14
|
-
export interface SelectionPreviewProps {
|
|
15
|
-
activeCell: CellView;
|
|
16
|
-
}
|
|
17
|
-
const layerStyles: CSSProperties = {
|
|
18
|
-
position: 'fixed',
|
|
19
|
-
pointerEvents: 'none',
|
|
20
|
-
zIndex: 1000,
|
|
21
|
-
left: 0,
|
|
22
|
-
top: 0,
|
|
23
|
-
width: '300px',
|
|
24
|
-
height: '50px',
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const getItemStyles = (currentOffset: XYCoord | null) => {
|
|
28
|
-
if (!currentOffset) {
|
|
29
|
-
return {
|
|
30
|
-
display: 'none',
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const { x, y } = currentOffset;
|
|
35
|
-
|
|
36
|
-
const transform = `translate(${x}px, ${y}px)`;
|
|
37
|
-
return {
|
|
38
|
-
transform,
|
|
39
|
-
WebkitTransform: transform,
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const MultipleSelectionPreview: FC<{ activeCell: CellView }> = ({ activeCell }) => {
|
|
44
|
-
const cellService = useInject<CellService>(LibroCellService);
|
|
45
|
-
const [multipleSelectionPreview, setMultipleSelectionPreview] = useState<CellView>();
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
cellService
|
|
48
|
-
.getOrCreateView(activeCell.model.options, activeCell.parent.id)
|
|
49
|
-
.then((view) => {
|
|
50
|
-
setMultipleSelectionPreview(view);
|
|
51
|
-
return;
|
|
52
|
-
})
|
|
53
|
-
.catch((e) => {
|
|
54
|
-
//
|
|
55
|
-
});
|
|
56
|
-
}, []);
|
|
57
|
-
|
|
58
|
-
return (
|
|
59
|
-
<div className="libro-dnd-multiple-selection-preview">
|
|
60
|
-
<div className="libro-dnd-active-selection">
|
|
61
|
-
{multipleSelectionPreview && <ViewRender view={multipleSelectionPreview} />}
|
|
62
|
-
</div>
|
|
63
|
-
<div className="libro-dnd-cascading-multiple-selection" />
|
|
64
|
-
</div>
|
|
65
|
-
);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export const MultipleSelectionPreviewMemo: FC<SelectionPreviewProps> = memo(
|
|
69
|
-
MultipleSelectionPreview,
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
const SingleSelectionDragPreview: FC<{ activeCell: CellView }> = ({ activeCell }) => {
|
|
73
|
-
const cellService = useInject<CellService>(LibroCellService);
|
|
74
|
-
const [singleSelectionPreview, setSingleSelectionPreview] = useState<CellView>();
|
|
75
|
-
useEffect(() => {
|
|
76
|
-
cellService
|
|
77
|
-
.getOrCreateView(
|
|
78
|
-
{
|
|
79
|
-
...activeCell.model.options,
|
|
80
|
-
modelId: activeCell.model.id,
|
|
81
|
-
singleSelectionDragPreview: true,
|
|
82
|
-
},
|
|
83
|
-
activeCell.parent.id,
|
|
84
|
-
)
|
|
85
|
-
.then((view) => {
|
|
86
|
-
setSingleSelectionPreview(view);
|
|
87
|
-
return;
|
|
88
|
-
})
|
|
89
|
-
.catch((e) => {
|
|
90
|
-
//
|
|
91
|
-
});
|
|
92
|
-
}, []);
|
|
93
|
-
|
|
94
|
-
return (
|
|
95
|
-
<div className="libro-dnd-active-selection">
|
|
96
|
-
{singleSelectionPreview && <ViewRender view={singleSelectionPreview} />}
|
|
97
|
-
</div>
|
|
98
|
-
);
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
export const SingleSelectionPreviewMemo: FC<SelectionPreviewProps> = memo(
|
|
102
|
-
SingleSelectionDragPreview,
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
export const CustomDragLayer = () => {
|
|
106
|
-
const { isDragging, item, currentOffset } = useDragLayer((monitor) => ({
|
|
107
|
-
item: monitor.getItem(),
|
|
108
|
-
itemType: monitor.getItemType(),
|
|
109
|
-
currentOffset: monitor.getClientOffset(),
|
|
110
|
-
isDragging: monitor.isDragging(),
|
|
111
|
-
}));
|
|
112
|
-
|
|
113
|
-
const instance = useInject<LibroView>(ViewInstance);
|
|
114
|
-
|
|
115
|
-
function renderItem() {
|
|
116
|
-
const isItemSelected =
|
|
117
|
-
instance.model.selections.findIndex((select) => select.id === item.cell.id) >= 0;
|
|
118
|
-
if (instance.model.selections.length !== 0 && isItemSelected) {
|
|
119
|
-
return (
|
|
120
|
-
<>
|
|
121
|
-
{instance.model.active && (
|
|
122
|
-
<MultipleSelectionPreviewMemo activeCell={instance.model.active} />
|
|
123
|
-
)}
|
|
124
|
-
</>
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
return (
|
|
128
|
-
<>
|
|
129
|
-
{instance.model.active && (
|
|
130
|
-
<SingleSelectionPreviewMemo activeCell={instance.model.active} />
|
|
131
|
-
)}
|
|
132
|
-
</>
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (!isDragging) {
|
|
137
|
-
return null;
|
|
138
|
-
}
|
|
139
|
-
return (
|
|
140
|
-
<div className="libro-custom-drag-layer" style={layerStyles}>
|
|
141
|
-
<div style={getItemStyles(currentOffset)}>{renderItem()}</div>
|
|
142
|
-
</div>
|
|
143
|
-
);
|
|
144
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { getOrigin, useInject } from '@difizen/mana-app';
|
|
2
|
-
import { ViewInstance } from '@difizen/mana-app';
|
|
3
|
-
import type { FC } from 'react';
|
|
4
|
-
import { DndProvider } from 'react-dnd';
|
|
5
|
-
import { HTML5Backend } from 'react-dnd-html5-backend';
|
|
6
|
-
|
|
7
|
-
import type { LibroView } from '../../libro-view.js';
|
|
8
|
-
|
|
9
|
-
export const DndContext: FC<any> = ({ children }) => {
|
|
10
|
-
const instance = useInject<LibroView>(ViewInstance);
|
|
11
|
-
|
|
12
|
-
if (!instance.isVisible && !instance.model.dndAreaNullEnable) {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
return (
|
|
16
|
-
<DndProvider
|
|
17
|
-
backend={HTML5Backend}
|
|
18
|
-
options={{
|
|
19
|
-
rootElement:
|
|
20
|
-
instance.isVisible || !instance.model.dndAreaNullEnable
|
|
21
|
-
? getOrigin(instance).container?.current
|
|
22
|
-
: null,
|
|
23
|
-
}}
|
|
24
|
-
>
|
|
25
|
-
{children}
|
|
26
|
-
</DndProvider>
|
|
27
|
-
);
|
|
28
|
-
};
|