zmdms-webui 0.0.1
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 +104 -0
- package/dist/es/_virtual/_commonjsHelpers.js +5 -0
- package/dist/es/_virtual/_tslib.js +51 -0
- package/dist/es/_virtual/index.js +3 -0
- package/dist/es/_virtual/index2.js +3 -0
- package/dist/es/button/button.d.ts +10 -0
- package/dist/es/button/button.js +39 -0
- package/dist/es/button/index.d.ts +5 -0
- package/dist/es/button/index.js +5 -0
- package/dist/es/calendar/index.d.ts +6 -0
- package/dist/es/calendar/index.js +6 -0
- package/dist/es/config/ZtxkContext.d.ts +11 -0
- package/dist/es/config/ZtxkContext.js +8 -0
- package/dist/es/config/commonHooks.js +28 -0
- package/dist/es/config/i18n/en.js +5 -0
- package/dist/es/config/i18n/zh_cn.js +5 -0
- package/dist/es/config/index.js +3 -0
- package/dist/es/config/isEqual.js +44 -0
- package/dist/es/config/useLocale.js +21 -0
- package/dist/es/container/container.d.ts +13 -0
- package/dist/es/container/container.js +24 -0
- package/dist/es/container/index.d.ts +5 -0
- package/dist/es/container/index.js +5 -0
- package/dist/es/datepicker/index.d.ts +55 -0
- package/dist/es/datepicker/index.js +6 -0
- package/dist/es/dynamicsetting/dynamicDrawer.js +76 -0
- package/dist/es/dynamicsetting/dynamicSetting.d.ts +6 -0
- package/dist/es/dynamicsetting/dynamicSetting.js +38 -0
- package/dist/es/dynamicsetting/hooks.js +50 -0
- package/dist/es/dynamicsetting/index.d.ts +5 -0
- package/dist/es/dynamicsetting/index.js +5 -0
- package/dist/es/dynamicsetting/interface.d.ts +18 -0
- package/dist/es/dynamicsetting/sortable.js +68 -0
- package/dist/es/dynamicsetting/useDynamic.js +125 -0
- package/dist/es/footer/footer.d.ts +6 -0
- package/dist/es/footer/footer.js +37 -0
- package/dist/es/footer/index.d.ts +5 -0
- package/dist/es/footer/index.js +5 -0
- package/dist/es/footer/interface.d.ts +33 -0
- package/dist/es/forgetpassword/forgetPassword.js +9 -0
- package/dist/es/forgetpassword/index.js +5 -0
- package/dist/es/form/form.d.ts +16 -0
- package/dist/es/form/form.js +89 -0
- package/dist/es/form/formItems.js +14 -0
- package/dist/es/form/hooks.js +105 -0
- package/dist/es/form/index.d.ts +5 -0
- package/dist/es/form/index.js +5 -0
- package/dist/es/form/interface.d.ts +39 -0
- package/dist/es/formitem/formItem.d.ts +43 -0
- package/dist/es/formitem/formItem.js +128 -0
- package/dist/es/formitem/index.d.ts +5 -0
- package/dist/es/formitem/index.js +5 -0
- package/dist/es/icon/index.d.ts +6 -0
- package/dist/es/icon/index.js +7 -0
- package/dist/es/input/index.d.ts +5 -0
- package/dist/es/input/index.js +5 -0
- package/dist/es/input/input.d.ts +20 -0
- package/dist/es/input/input.js +16 -0
- package/dist/es/inputnumber/index.d.ts +5 -0
- package/dist/es/inputnumber/index.js +5 -0
- package/dist/es/inputnumber/inputNumber.d.ts +20 -0
- package/dist/es/inputnumber/inputNumber.js +26 -0
- package/dist/es/inputnumber/interface.d.ts +4 -0
- package/dist/es/inputnumber/utils.js +132 -0
- package/dist/es/login/index.d.ts +13 -0
- package/dist/es/login/index.js +26 -0
- package/dist/es/node_modules/@ant-design/colors/dist/index.esm.js +223 -0
- package/dist/es/node_modules/@ant-design/icons/es/components/AntdIcon.js +63 -0
- package/dist/es/node_modules/@ant-design/icons/es/components/Context.js +6 -0
- package/dist/es/node_modules/@ant-design/icons/es/components/Icon.js +69 -0
- package/dist/es/node_modules/@ant-design/icons/es/components/IconBase.js +63 -0
- package/dist/es/node_modules/@ant-design/icons/es/components/IconFont.js +71 -0
- package/dist/es/node_modules/@ant-design/icons/es/components/twoTonePrimaryColor.js +23 -0
- package/dist/es/node_modules/@ant-design/icons/es/icons/SettingOutlined.js +15 -0
- package/dist/es/node_modules/@ant-design/icons/es/utils.js +76 -0
- package/dist/es/node_modules/@ant-design/icons-svg/es/asn/SettingOutlined.js +5 -0
- package/dist/es/node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js +7 -0
- package/dist/es/node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js +5 -0
- package/dist/es/node_modules/@babel/runtime/helpers/esm/defineProperty.js +18 -0
- package/dist/es/node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js +29 -0
- package/dist/es/node_modules/@babel/runtime/helpers/esm/nonIterableRest.js +5 -0
- package/dist/es/node_modules/@babel/runtime/helpers/esm/objectSpread2.js +25 -0
- package/dist/es/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js +19 -0
- package/dist/es/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js +14 -0
- package/dist/es/node_modules/@babel/runtime/helpers/esm/slicedToArray.js +10 -0
- package/dist/es/node_modules/@babel/runtime/helpers/esm/toPrimitive.js +14 -0
- package/dist/es/node_modules/@babel/runtime/helpers/esm/toPropertyKey.js +9 -0
- package/dist/es/node_modules/@babel/runtime/helpers/esm/typeof.js +11 -0
- package/dist/es/node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js +12 -0
- package/dist/es/node_modules/@ctrl/tinycolor/dist/module/conversion.js +150 -0
- package/dist/es/node_modules/@ctrl/tinycolor/dist/module/css-color-names.js +156 -0
- package/dist/es/node_modules/@ctrl/tinycolor/dist/module/format-input.js +186 -0
- package/dist/es/node_modules/@ctrl/tinycolor/dist/module/util.js +77 -0
- package/dist/es/node_modules/@react-dnd/asap/dist/AsapQueue.js +140 -0
- package/dist/es/node_modules/@react-dnd/asap/dist/RawTask.js +20 -0
- package/dist/es/node_modules/@react-dnd/asap/dist/TaskFactory.js +17 -0
- package/dist/es/node_modules/@react-dnd/asap/dist/asap.js +17 -0
- package/dist/es/node_modules/@react-dnd/asap/dist/makeRequestCall.js +77 -0
- package/dist/es/node_modules/@react-dnd/invariant/dist/index.js +36 -0
- package/dist/es/node_modules/@react-dnd/shallowequal/dist/index.js +34 -0
- package/dist/es/node_modules/classnames/index.js +64 -0
- package/dist/es/node_modules/dnd-core/dist/actions/dragDrop/beginDrag.js +85 -0
- package/dist/es/node_modules/dnd-core/dist/actions/dragDrop/drop.js +74 -0
- package/dist/es/node_modules/dnd-core/dist/actions/dragDrop/endDrag.js +24 -0
- package/dist/es/node_modules/dnd-core/dist/actions/dragDrop/hover.js +57 -0
- package/dist/es/node_modules/dnd-core/dist/actions/dragDrop/index.js +17 -0
- package/dist/es/node_modules/dnd-core/dist/actions/dragDrop/local/setClientOffset.js +13 -0
- package/dist/es/node_modules/dnd-core/dist/actions/dragDrop/publishDragSource.js +15 -0
- package/dist/es/node_modules/dnd-core/dist/actions/dragDrop/types.js +8 -0
- package/dist/es/node_modules/dnd-core/dist/actions/registry.js +38 -0
- package/dist/es/node_modules/dnd-core/dist/classes/DragDropManagerImpl.js +57 -0
- package/dist/es/node_modules/dnd-core/dist/classes/DragDropMonitorImpl.js +153 -0
- package/dist/es/node_modules/dnd-core/dist/classes/HandlerRegistryImpl.js +130 -0
- package/dist/es/node_modules/dnd-core/dist/contracts.js +22 -0
- package/dist/es/node_modules/dnd-core/dist/createDragDropManager.js +25 -0
- package/dist/es/node_modules/dnd-core/dist/interfaces.js +7 -0
- package/dist/es/node_modules/dnd-core/dist/reducers/dirtyHandlerIds.js +45 -0
- package/dist/es/node_modules/dnd-core/dist/reducers/dragOffset.js +62 -0
- package/dist/es/node_modules/dnd-core/dist/reducers/dragOperation.js +90 -0
- package/dist/es/node_modules/dnd-core/dist/reducers/index.js +51 -0
- package/dist/es/node_modules/dnd-core/dist/reducers/refCount.js +16 -0
- package/dist/es/node_modules/dnd-core/dist/reducers/stateId.js +5 -0
- package/dist/es/node_modules/dnd-core/dist/utils/coords.js +47 -0
- package/dist/es/node_modules/dnd-core/dist/utils/dirtiness.js +23 -0
- package/dist/es/node_modules/dnd-core/dist/utils/equality.js +32 -0
- package/dist/es/node_modules/dnd-core/dist/utils/getNextUniqueId.js +6 -0
- package/dist/es/node_modules/dnd-core/dist/utils/js_utils.js +51 -0
- package/dist/es/node_modules/dnd-core/dist/utils/matchesType.js +9 -0
- package/dist/es/node_modules/fast-deep-equal/index.js +50 -0
- package/dist/es/node_modules/immutability-helper/index.js +259 -0
- package/dist/es/node_modules/rc-picker/es/generate/dayjs.js +219 -0
- package/dist/es/node_modules/rc-util/es/Dom/canUseDom.js +5 -0
- package/dist/es/node_modules/rc-util/es/Dom/contains.js +22 -0
- package/dist/es/node_modules/rc-util/es/Dom/dynamicCSS.js +116 -0
- package/dist/es/node_modules/rc-util/es/warning.js +54 -0
- package/dist/es/node_modules/react-dnd/dist/core/DndContext.js +9 -0
- package/dist/es/node_modules/react-dnd/dist/core/DndProvider.js +92 -0
- package/dist/es/node_modules/react-dnd/dist/hooks/useCollectedProps.js +9 -0
- package/dist/es/node_modules/react-dnd/dist/hooks/useCollector.js +38 -0
- package/dist/es/node_modules/react-dnd/dist/hooks/useDrag/DragSourceImpl.js +49 -0
- package/dist/es/node_modules/react-dnd/dist/hooks/useDrag/connectors.js +16 -0
- package/dist/es/node_modules/react-dnd/dist/hooks/useDrag/useDrag.js +26 -0
- package/dist/es/node_modules/react-dnd/dist/hooks/useDrag/useDragSource.js +18 -0
- package/dist/es/node_modules/react-dnd/dist/hooks/useDrag/useDragSourceConnector.js +33 -0
- package/dist/es/node_modules/react-dnd/dist/hooks/useDrag/useDragSourceMonitor.js +13 -0
- package/dist/es/node_modules/react-dnd/dist/hooks/useDrag/useDragType.js +14 -0
- package/dist/es/node_modules/react-dnd/dist/hooks/useDrag/useRegisteredDragSource.js +28 -0
- package/dist/es/node_modules/react-dnd/dist/hooks/useDragDropManager.js +13 -0
- package/dist/es/node_modules/react-dnd/dist/hooks/useDrop/DropTargetImpl.js +28 -0
- package/dist/es/node_modules/react-dnd/dist/hooks/useDrop/connectors.js +10 -0
- package/dist/es/node_modules/react-dnd/dist/hooks/useDrop/useAccept.js +20 -0
- package/dist/es/node_modules/react-dnd/dist/hooks/useDrop/useDrop.js +23 -0
- package/dist/es/node_modules/react-dnd/dist/hooks/useDrop/useDropTarget.js +17 -0
- package/dist/es/node_modules/react-dnd/dist/hooks/useDrop/useDropTargetConnector.js +23 -0
- package/dist/es/node_modules/react-dnd/dist/hooks/useDrop/useDropTargetMonitor.js +13 -0
- package/dist/es/node_modules/react-dnd/dist/hooks/useDrop/useRegisteredDropTarget.js +26 -0
- package/dist/es/node_modules/react-dnd/dist/hooks/useIsomorphicLayoutEffect.js +6 -0
- package/dist/es/node_modules/react-dnd/dist/hooks/useMonitorOutput.js +23 -0
- package/dist/es/node_modules/react-dnd/dist/hooks/useOptionalFactory.js +15 -0
- package/dist/es/node_modules/react-dnd/dist/internals/DragSourceMonitorImpl.js +93 -0
- package/dist/es/node_modules/react-dnd/dist/internals/DropTargetMonitorImpl.js +68 -0
- package/dist/es/node_modules/react-dnd/dist/internals/SourceConnector.js +157 -0
- package/dist/es/node_modules/react-dnd/dist/internals/TargetConnector.js +89 -0
- package/dist/es/node_modules/react-dnd/dist/internals/isRef.js +6 -0
- package/dist/es/node_modules/react-dnd/dist/internals/registration.js +18 -0
- package/dist/es/node_modules/react-dnd/dist/internals/wrapConnectorHooks.js +74 -0
- package/dist/es/node_modules/react-dnd-html5-backend/dist/BrowserDetector.js +8 -0
- package/dist/es/node_modules/react-dnd-html5-backend/dist/EnterLeaveCounter.js +27 -0
- package/dist/es/node_modules/react-dnd-html5-backend/dist/HTML5BackendImpl.js +572 -0
- package/dist/es/node_modules/react-dnd-html5-backend/dist/MonotonicInterpolant.js +86 -0
- package/dist/es/node_modules/react-dnd-html5-backend/dist/NativeDragSources/NativeDragSource.js +50 -0
- package/dist/es/node_modules/react-dnd-html5-backend/dist/NativeDragSources/getDataFromDataTransfer.js +7 -0
- package/dist/es/node_modules/react-dnd-html5-backend/dist/NativeDragSources/index.js +28 -0
- package/dist/es/node_modules/react-dnd-html5-backend/dist/NativeDragSources/nativeTypesConfig.js +52 -0
- package/dist/es/node_modules/react-dnd-html5-backend/dist/NativeTypes.js +6 -0
- package/dist/es/node_modules/react-dnd-html5-backend/dist/OffsetUtils.js +100 -0
- package/dist/es/node_modules/react-dnd-html5-backend/dist/OptionsReader.js +31 -0
- package/dist/es/node_modules/react-dnd-html5-backend/dist/index.js +7 -0
- package/dist/es/node_modules/react-dnd-html5-backend/dist/utils/js_utils.js +30 -0
- package/dist/es/node_modules/redux/es/redux.js +383 -0
- package/dist/es/pagination/index.d.ts +5 -0
- package/dist/es/pagination/index.js +5 -0
- package/dist/es/pagination/pagination.d.ts +8 -0
- package/dist/es/pagination/pagination.js +12 -0
- package/dist/es/protectedroute/index.d.ts +14 -0
- package/dist/es/protectedroute/index.js +17 -0
- package/dist/es/suspensecomponent/index.d.ts +9 -0
- package/dist/es/suspensecomponent/index.js +10 -0
- package/dist/es/table/components/CopyIcon.js +10 -0
- package/dist/es/table/components/EnhanceCell.js +48 -0
- package/dist/es/table/components/EnhanceRow.js +11 -0
- package/dist/es/table/components/hooks.js +24 -0
- package/dist/es/table/constant.js +3 -0
- package/dist/es/table/hooks.js +24 -0
- package/dist/es/table/index.d.ts +5 -0
- package/dist/es/table/index.js +5 -0
- package/dist/es/table/interface.d.ts +43 -0
- package/dist/es/table/table.d.ts +5 -0
- package/dist/es/table/table.js +60 -0
- package/dist/es/table/useColumns.js +48 -0
- package/dist/es/table/useDynamicListByColumns.js +47 -0
- package/dist/es/table/utils.js +82 -0
- package/dist/es/timepicker/index.d.ts +9 -0
- package/dist/es/timepicker/index.js +11 -0
- package/dist/index.build.d.ts +19 -0
- package/dist/index.dark.css +2 -0
- package/dist/index.default.css +2 -0
- package/dist/index.es.js +19 -0
- package/dist/index.umd.js +6 -0
- package/package.json +103 -0
package/dist/es/node_modules/react-dnd-html5-backend/dist/NativeDragSources/NativeDragSource.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
class NativeDragSource {
|
|
2
|
+
initializeExposedProperties() {
|
|
3
|
+
Object.keys(this.config.exposeProperties).forEach((property)=>{
|
|
4
|
+
Object.defineProperty(this.item, property, {
|
|
5
|
+
configurable: true,
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get () {
|
|
8
|
+
// eslint-disable-next-line no-console
|
|
9
|
+
console.warn(`Browser doesn't allow reading "${property}" until the drop event.`);
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
loadDataTransfer(dataTransfer) {
|
|
16
|
+
if (dataTransfer) {
|
|
17
|
+
const newProperties = {};
|
|
18
|
+
Object.keys(this.config.exposeProperties).forEach((property)=>{
|
|
19
|
+
const propertyFn = this.config.exposeProperties[property];
|
|
20
|
+
if (propertyFn != null) {
|
|
21
|
+
newProperties[property] = {
|
|
22
|
+
value: propertyFn(dataTransfer, this.config.matchesTypes),
|
|
23
|
+
configurable: true,
|
|
24
|
+
enumerable: true
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperties(this.item, newProperties);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
canDrag() {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
beginDrag() {
|
|
35
|
+
return this.item;
|
|
36
|
+
}
|
|
37
|
+
isDragging(monitor, handle) {
|
|
38
|
+
return handle === monitor.getSourceId();
|
|
39
|
+
}
|
|
40
|
+
endDrag() {
|
|
41
|
+
// empty
|
|
42
|
+
}
|
|
43
|
+
constructor(config){
|
|
44
|
+
this.config = config;
|
|
45
|
+
this.item = {};
|
|
46
|
+
this.initializeExposedProperties();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { NativeDragSource };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
function getDataFromDataTransfer(dataTransfer, typesToTry, defaultValue) {
|
|
2
|
+
const result = typesToTry.reduce((resultSoFar, typeToTry)=>resultSoFar || dataTransfer.getData(typeToTry)
|
|
3
|
+
, '');
|
|
4
|
+
return result != null ? result : defaultValue;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export { getDataFromDataTransfer };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { NativeDragSource } from './NativeDragSource.js';
|
|
2
|
+
import { nativeTypesConfig } from './nativeTypesConfig.js';
|
|
3
|
+
|
|
4
|
+
function createNativeDragSource(type, dataTransfer) {
|
|
5
|
+
const config = nativeTypesConfig[type];
|
|
6
|
+
if (!config) {
|
|
7
|
+
throw new Error(`native type ${type} has no configuration`);
|
|
8
|
+
}
|
|
9
|
+
const result = new NativeDragSource(config);
|
|
10
|
+
result.loadDataTransfer(dataTransfer);
|
|
11
|
+
return result;
|
|
12
|
+
}
|
|
13
|
+
function matchNativeItemType(dataTransfer) {
|
|
14
|
+
if (!dataTransfer) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const dataTransferTypes = Array.prototype.slice.call(dataTransfer.types || []);
|
|
18
|
+
return Object.keys(nativeTypesConfig).filter((nativeItemType)=>{
|
|
19
|
+
const typeConfig = nativeTypesConfig[nativeItemType];
|
|
20
|
+
if (!(typeConfig === null || typeConfig === void 0 ? void 0 : typeConfig.matchesTypes)) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
return typeConfig.matchesTypes.some((t)=>dataTransferTypes.indexOf(t) > -1
|
|
24
|
+
);
|
|
25
|
+
})[0] || null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { createNativeDragSource, matchNativeItemType };
|
package/dist/es/node_modules/react-dnd-html5-backend/dist/NativeDragSources/nativeTypesConfig.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { FILE, HTML, URL, TEXT } from '../NativeTypes.js';
|
|
2
|
+
import { getDataFromDataTransfer } from './getDataFromDataTransfer.js';
|
|
3
|
+
|
|
4
|
+
const nativeTypesConfig = {
|
|
5
|
+
[FILE]: {
|
|
6
|
+
exposeProperties: {
|
|
7
|
+
files: (dataTransfer)=>Array.prototype.slice.call(dataTransfer.files)
|
|
8
|
+
,
|
|
9
|
+
items: (dataTransfer)=>dataTransfer.items
|
|
10
|
+
,
|
|
11
|
+
dataTransfer: (dataTransfer)=>dataTransfer
|
|
12
|
+
},
|
|
13
|
+
matchesTypes: [
|
|
14
|
+
'Files'
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
[HTML]: {
|
|
18
|
+
exposeProperties: {
|
|
19
|
+
html: (dataTransfer, matchesTypes)=>getDataFromDataTransfer(dataTransfer, matchesTypes, '')
|
|
20
|
+
,
|
|
21
|
+
dataTransfer: (dataTransfer)=>dataTransfer
|
|
22
|
+
},
|
|
23
|
+
matchesTypes: [
|
|
24
|
+
'Html',
|
|
25
|
+
'text/html'
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
[URL]: {
|
|
29
|
+
exposeProperties: {
|
|
30
|
+
urls: (dataTransfer, matchesTypes)=>getDataFromDataTransfer(dataTransfer, matchesTypes, '').split('\n')
|
|
31
|
+
,
|
|
32
|
+
dataTransfer: (dataTransfer)=>dataTransfer
|
|
33
|
+
},
|
|
34
|
+
matchesTypes: [
|
|
35
|
+
'Url',
|
|
36
|
+
'text/uri-list'
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
[TEXT]: {
|
|
40
|
+
exposeProperties: {
|
|
41
|
+
text: (dataTransfer, matchesTypes)=>getDataFromDataTransfer(dataTransfer, matchesTypes, '')
|
|
42
|
+
,
|
|
43
|
+
dataTransfer: (dataTransfer)=>dataTransfer
|
|
44
|
+
},
|
|
45
|
+
matchesTypes: [
|
|
46
|
+
'Text',
|
|
47
|
+
'text/plain'
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export { nativeTypesConfig };
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { isFirefox, isSafari } from './BrowserDetector.js';
|
|
2
|
+
import { MonotonicInterpolant } from './MonotonicInterpolant.js';
|
|
3
|
+
|
|
4
|
+
const ELEMENT_NODE = 1;
|
|
5
|
+
function getNodeClientOffset(node) {
|
|
6
|
+
const el = node.nodeType === ELEMENT_NODE ? node : node.parentElement;
|
|
7
|
+
if (!el) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
const { top , left } = el.getBoundingClientRect();
|
|
11
|
+
return {
|
|
12
|
+
x: left,
|
|
13
|
+
y: top
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function getEventClientOffset(e) {
|
|
17
|
+
return {
|
|
18
|
+
x: e.clientX,
|
|
19
|
+
y: e.clientY
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function isImageNode(node) {
|
|
23
|
+
var ref;
|
|
24
|
+
return node.nodeName === 'IMG' && (isFirefox() || !((ref = document.documentElement) === null || ref === void 0 ? void 0 : ref.contains(node)));
|
|
25
|
+
}
|
|
26
|
+
function getDragPreviewSize(isImage, dragPreview, sourceWidth, sourceHeight) {
|
|
27
|
+
let dragPreviewWidth = isImage ? dragPreview.width : sourceWidth;
|
|
28
|
+
let dragPreviewHeight = isImage ? dragPreview.height : sourceHeight;
|
|
29
|
+
// Work around @2x coordinate discrepancies in browsers
|
|
30
|
+
if (isSafari() && isImage) {
|
|
31
|
+
dragPreviewHeight /= window.devicePixelRatio;
|
|
32
|
+
dragPreviewWidth /= window.devicePixelRatio;
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
dragPreviewWidth,
|
|
36
|
+
dragPreviewHeight
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function getDragPreviewOffset(sourceNode, dragPreview, clientOffset, anchorPoint, offsetPoint) {
|
|
40
|
+
// The browsers will use the image intrinsic size under different conditions.
|
|
41
|
+
// Firefox only cares if it's an image, but WebKit also wants it to be detached.
|
|
42
|
+
const isImage = isImageNode(dragPreview);
|
|
43
|
+
const dragPreviewNode = isImage ? sourceNode : dragPreview;
|
|
44
|
+
const dragPreviewNodeOffsetFromClient = getNodeClientOffset(dragPreviewNode);
|
|
45
|
+
const offsetFromDragPreview = {
|
|
46
|
+
x: clientOffset.x - dragPreviewNodeOffsetFromClient.x,
|
|
47
|
+
y: clientOffset.y - dragPreviewNodeOffsetFromClient.y
|
|
48
|
+
};
|
|
49
|
+
const { offsetWidth: sourceWidth , offsetHeight: sourceHeight } = sourceNode;
|
|
50
|
+
const { anchorX , anchorY } = anchorPoint;
|
|
51
|
+
const { dragPreviewWidth , dragPreviewHeight } = getDragPreviewSize(isImage, dragPreview, sourceWidth, sourceHeight);
|
|
52
|
+
const calculateYOffset = ()=>{
|
|
53
|
+
const interpolantY = new MonotonicInterpolant([
|
|
54
|
+
0,
|
|
55
|
+
0.5,
|
|
56
|
+
1
|
|
57
|
+
], [
|
|
58
|
+
// Dock to the top
|
|
59
|
+
offsetFromDragPreview.y,
|
|
60
|
+
// Align at the center
|
|
61
|
+
(offsetFromDragPreview.y / sourceHeight) * dragPreviewHeight,
|
|
62
|
+
// Dock to the bottom
|
|
63
|
+
offsetFromDragPreview.y + dragPreviewHeight - sourceHeight,
|
|
64
|
+
]);
|
|
65
|
+
let y = interpolantY.interpolate(anchorY);
|
|
66
|
+
// Work around Safari 8 positioning bug
|
|
67
|
+
if (isSafari() && isImage) {
|
|
68
|
+
// We'll have to wait for @3x to see if this is entirely correct
|
|
69
|
+
y += (window.devicePixelRatio - 1) * dragPreviewHeight;
|
|
70
|
+
}
|
|
71
|
+
return y;
|
|
72
|
+
};
|
|
73
|
+
const calculateXOffset = ()=>{
|
|
74
|
+
// Interpolate coordinates depending on anchor point
|
|
75
|
+
// If you know a simpler way to do this, let me know
|
|
76
|
+
const interpolantX = new MonotonicInterpolant([
|
|
77
|
+
0,
|
|
78
|
+
0.5,
|
|
79
|
+
1
|
|
80
|
+
], [
|
|
81
|
+
// Dock to the left
|
|
82
|
+
offsetFromDragPreview.x,
|
|
83
|
+
// Align at the center
|
|
84
|
+
(offsetFromDragPreview.x / sourceWidth) * dragPreviewWidth,
|
|
85
|
+
// Dock to the right
|
|
86
|
+
offsetFromDragPreview.x + dragPreviewWidth - sourceWidth,
|
|
87
|
+
]);
|
|
88
|
+
return interpolantX.interpolate(anchorX);
|
|
89
|
+
};
|
|
90
|
+
// Force offsets if specified in the options.
|
|
91
|
+
const { offsetX , offsetY } = offsetPoint;
|
|
92
|
+
const isManualOffsetX = offsetX === 0 || offsetX;
|
|
93
|
+
const isManualOffsetY = offsetY === 0 || offsetY;
|
|
94
|
+
return {
|
|
95
|
+
x: isManualOffsetX ? offsetX : calculateXOffset(),
|
|
96
|
+
y: isManualOffsetY ? offsetY : calculateYOffset()
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export { getDragPreviewOffset, getEventClientOffset, getNodeClientOffset };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
class OptionsReader {
|
|
2
|
+
get window() {
|
|
3
|
+
if (this.globalContext) {
|
|
4
|
+
return this.globalContext;
|
|
5
|
+
} else if (typeof window !== 'undefined') {
|
|
6
|
+
return window;
|
|
7
|
+
}
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
get document() {
|
|
11
|
+
var ref;
|
|
12
|
+
if ((ref = this.globalContext) === null || ref === void 0 ? void 0 : ref.document) {
|
|
13
|
+
return this.globalContext.document;
|
|
14
|
+
} else if (this.window) {
|
|
15
|
+
return this.window.document;
|
|
16
|
+
} else {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
get rootElement() {
|
|
21
|
+
var ref;
|
|
22
|
+
return ((ref = this.optionsArgs) === null || ref === void 0 ? void 0 : ref.rootElement) || this.window;
|
|
23
|
+
}
|
|
24
|
+
constructor(globalContext, options){
|
|
25
|
+
this.ownerDocument = null;
|
|
26
|
+
this.globalContext = globalContext;
|
|
27
|
+
this.optionsArgs = options;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { OptionsReader };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// cheap lodash replacements
|
|
2
|
+
function memoize(fn) {
|
|
3
|
+
let result = null;
|
|
4
|
+
const memoized = ()=>{
|
|
5
|
+
if (result == null) {
|
|
6
|
+
result = fn();
|
|
7
|
+
}
|
|
8
|
+
return result;
|
|
9
|
+
};
|
|
10
|
+
return memoized;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* drop-in replacement for _.without
|
|
14
|
+
*/ function without(items, item) {
|
|
15
|
+
return items.filter((i)=>i !== item
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
function union(itemsA, itemsB) {
|
|
19
|
+
const set = new Set();
|
|
20
|
+
const insertItem = (item)=>set.add(item)
|
|
21
|
+
;
|
|
22
|
+
itemsA.forEach(insertItem);
|
|
23
|
+
itemsB.forEach(insertItem);
|
|
24
|
+
const result = [];
|
|
25
|
+
set.forEach((key)=>result.push(key)
|
|
26
|
+
);
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { memoize, union, without };
|